PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 2.0.1
Admin Columns v2.0.1
7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / storage_model / post.php
codepress-admin-columns / classes / storage_model Last commit date
comment.php 12 years ago link.php 12 years ago media.php 12 years ago post.php 12 years ago user.php 12 years ago
post.php
126 lines
1 <?php
2
3 class CPAC_Storage_Model_Post extends CPAC_Storage_Model {
4
5 /**
6 * Constructor
7 *
8 * @since 2.0.0
9 */
10 function __construct( $post_type ) {
11
12 $this->key = $post_type;
13 $this->label = $this->get_label();
14 $this->type = 'post';
15 $this->page = 'edit';
16
17 $this->set_custom_columns();
18
19 // Headings
20
21 // Since 3.1
22 add_filter( "manage_{$post_type}_posts_columns", array( $this, 'add_headings' ), 10, 1 );
23
24 // Deprecated ( as of 3.1 ) Note: This one is still used by woocommerce.
25 // @todo_minor check compatibility issues for this deprecated filter
26 add_filter( "manage_{$this->page}-{$post_type}_columns", array( $this, 'add_headings' ), 10, 1 );
27
28 // values
29 add_action( "manage_{$post_type}_posts_custom_column", array( $this, 'manage_value' ), 10, 2 );
30 }
31
32 /**
33 * Get screen link
34 *
35 * @since 2.0.0
36 *
37 * @return string Link
38 */
39 protected function get_screen_link() {
40
41 return add_query_arg( array( 'post_type' => $this->key ), admin_url( $this->page . '.php' ) );
42 }
43
44 /**
45 * Get Label
46 *
47 * @since 2.0.0
48 *
49 * @return string Singular posttype name
50 */
51 private function get_label() {
52 $posttype_obj = get_post_type_object( $this->key );
53
54 return $posttype_obj->labels->name;
55 }
56
57 /**
58 * Get WP default supported admin columns per post type.
59 *
60 * @see CPAC_Type::get_default_columns()
61 * @since 1.0.0
62 *
63 * @return array
64 */
65 public function get_default_columns() {
66 global $pagenow;
67
68 // You can use this filter to add thirdparty columns by hooking into this.
69 // See classes/third_party.php for an example.
70 do_action( "cac/columns/default/posts" );
71 do_action( "cac/columns/default/storage_key={$this->key}" );
72
73 // Get columns that have been set by other plugins. If a plugin use the hook "manage_edit-{$post_type}_columns"
74 // we know that the columns have been overwritten. Use these columns instead of the WP default ones.
75 //
76 // We have to make sure this filter only loads on the Admin Columns settings page. To prevent a loop
77 // when it's being called by CPAC_Storage_Model::add_headings()
78 $columns = array();
79
80 if ( 'options-general.php' == $pagenow && isset( $_GET['page'] ) && 'codepress-admin-columns' == $_GET['page'] )
81 $columns = get_column_headers( "edit-{$this->key}" );
82
83 // Get the WP default columns
84 $table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => $this->key ) );
85
86 // Merge the available hooked columns with the WP default columns
87 $columns = array_filter( array_merge( $columns, $table->get_columns() ) );
88
89 return $columns;
90 }
91
92 /**
93 * Get Meta
94 *
95 * @since 2.0.0
96 *
97 * @return array
98 */
99 public function get_meta() {
100 global $wpdb;
101
102 return $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT meta_key FROM {$wpdb->postmeta} pm JOIN {$wpdb->posts} p ON pm.post_id = p.ID WHERE p.post_type = %s ORDER BY 1", $this->key ), ARRAY_N );
103 }
104
105 /**
106 * Manage value
107 *
108 * @since 2.0.0
109 *
110 * @param string $column_name
111 * @param int $post_id
112 */
113 public function manage_value( $column_name, $post_id ) {
114
115 $value = '';
116
117 // get column instance
118 if ( $column = $this->get_column_by_name( $column_name ) )
119 $value = $column->get_value( $post_id );
120
121 $value = apply_filters( "cac/column/value/posts", $value, $column );
122 $value = apply_filters( "cac/column/value/type={$this->key}", $value, $column );
123
124 echo $value;
125 }
126 }