link.php
2.0 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
83
84
85
86
87
88
89
90
91
92
93
<?php
class CPAC_Storage_Model_Link extends CPAC_Storage_Model {
/**
* Constructor
*
* @since 2.0
*/
function __construct() {
$this->key = 'wp-links';
$this->label = __( 'Links' );
$this->singular_label = __( 'Link' );
$this->type = 'link';
$this->page = 'link-manager';
$this->menu_type = 'other';
// headings
add_filter( "manage_{$this->page}_columns", array( $this, 'add_headings' ), 100 );
// values
add_action( 'manage_link_custom_column', array( $this, 'manage_value' ), 100, 2 );
parent::__construct();
}
/**
* Get WP default supported admin columns per post type.
*
* @since 1.0
*
* @return array
*/
public function get_default_columns() {
if ( ! function_exists('_get_list_table') ) {
return array();
}
// You can use this filter to add thirdparty columns by hooking into this.
// See classes/third_party.php for an example.
do_action( "cac/columns/default/storage_key={$this->key}" );
// get columns
$table = _get_list_table( 'WP_Links_List_Table', array( 'screen' => 'link-manager' ) );
$columns = (array) $table->get_columns();
return $columns;
}
/**
* Get original columns
*
* @since 2.4.4
*/
public function get_default_column_names() {
return array();
}
/**
* Get Meta
*
* @since 2.0
*
* @return array
*/
public function get_meta() {}
/**
* Manage value
*
* @since 2.0
*
* @param string $column_name
* @param int $post_id
*/
public function manage_value( $column_name, $link_id ) {
if ( ! ( $column = $this->get_column_by_name( $column_name ) ) ) {
return false;
}
$value = $column->get_value( $link_id );
// add hook
$value = apply_filters( "cac/column/value", $value, $link_id, $column, $this->key );
$value = apply_filters( "cac/column/value/{$this->type}", $value, $link_id, $column, $this->key );
echo $value;
}
}