Post.php
69 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | class AC_ListScreen_Post extends AC_ListScreenPost { |
| 8 | |
| 9 | public function __construct( $post_type ) { |
| 10 | parent::__construct( $post_type ); |
| 11 | |
| 12 | $this->set_screen_base( 'edit' ); |
| 13 | $this->set_group( 'post' ); |
| 14 | $this->set_key( $post_type ); |
| 15 | $this->set_screen_id( $this->get_screen_base() . '-' . $post_type ); |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * @see WP_Posts_List_Table::column_default |
| 20 | */ |
| 21 | public function set_manage_value_callback() { |
| 22 | add_action( "manage_" . $this->get_post_type() . "_posts_custom_column", array( $this, 'manage_value' ), 100, 2 ); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * @return WP_Posts_List_Table |
| 27 | */ |
| 28 | protected function get_list_table() { |
| 29 | require_once( ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php' ); |
| 30 | |
| 31 | return new WP_Posts_List_Table( array( 'screen' => $this->get_screen_id() ) ); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * @since 2.0 |
| 36 | */ |
| 37 | public function get_screen_link() { |
| 38 | return add_query_arg( array( 'post_type' => $this->get_post_type() ), parent::get_screen_link() ); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * @return string|false |
| 43 | */ |
| 44 | public function get_label() { |
| 45 | return $this->get_post_type_label_var( 'name' ); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * @return false|string |
| 50 | */ |
| 51 | public function get_singular_label() { |
| 52 | return $this->get_post_type_label_var( 'singular_name' ); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * @since 2.4.7 |
| 57 | */ |
| 58 | public function manage_value( $column_name, $id ) { |
| 59 | echo $this->get_display_value_by_column_name( $column_name, $id ); |
| 60 | } |
| 61 | |
| 62 | protected function register_column_types() { |
| 63 | parent::register_column_types(); |
| 64 | |
| 65 | $this->register_column_types_from_dir( AC()->get_plugin_dir() . 'classes/Column/Post', AC()->get_prefix() ); |
| 66 | } |
| 67 | |
| 68 | } |
| 69 |