permalink.php
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* Columng displaying full item permalink (including URL).
*
* @since 2.0
*/
class CPAC_Column_Post_Permalink extends CPAC_Column {
/**
* @see CPAC_Column::init()
* @since 2.2.1
*/
public function init() {
parent::init();
// Properties
$this->properties['type'] = 'column-permalink';
$this->properties['label'] = __( 'Permalink', 'codepress-admin-columns' );
// Options
$this->options['link_to_post'] = false;
}
/**
* @see CPAC_Column::get_value()
* @since 2.0
*/
public function get_value( $post_id ) {
$value = $this->get_raw_value( $post_id );
if ( $this->options->link_to_post == 'on' ) {
$value = '<a href="' . esc_attr( $value ) .'" target="_blank">' . $value . '</a>';
}
return $value;
}
/**
* @see CPAC_Column::get_value()
* @since 2.0.3
*/
public function get_raw_value( $post_id ) {
return get_permalink( $post_id );
}
/**
* @see CPAC_Column::display_settings()
* @since 2.2.1
*/
public function display_settings() {
$this->display_field_link_to_post();
}
/**
* Display the settings field for selecting whether the column value should link to the corresponding post
*
* @since 2.2.1
*/
public function display_field_link_to_post() {
$field_key = 'link_to_post';
?>
<tr class="column_<?php echo $field_key; ?>">
<?php $this->label_view( __( 'Link to post', 'codepress-admin-columns' ), __( 'This will make the permalink clickable.', 'codepress-admin-columns' ), $field_key ); ?>
<td class="input">
<label for="<?php $this->attr_id( $field_key ); ?>-on">
<input type="radio" value="on" name="<?php $this->attr_name( $field_key ); ?>" id="<?php $this->attr_id( $field_key ); ?>-on"<?php checked( $this->options->link_to_post, 'on' ); ?> />
<?php _e( 'Yes' ); ?>
</label>
<label for="<?php $this->attr_id( $field_key ); ?>-off">
<input type="radio" value="off" name="<?php $this->attr_name( $field_key ); ?>" id="<?php $this->attr_id( $field_key ); ?>-off"<?php checked( in_array( $this->options->link_to_post, array( '', 'off' ) ) ); ?> />
<?php _e( 'No' ); ?>
</label>
</td>
</tr>
<?php
}
}