Admin
8 years ago
Column
8 years ago
Form
8 years ago
Helper
8 years ago
ListScreen
8 years ago
Meta
8 years ago
Notice
8 years ago
Plugin
8 years ago
Relation
8 years ago
Settings
8 years ago
ThirdParty
8 years ago
API.php
8 years ago
Addon.php
8 years ago
Admin.php
8 years ago
Autoloader.php
8 years ago
Collection.php
8 years ago
Column.php
8 years ago
Groups.php
8 years ago
Helper.php
8 years ago
ListScreen.php
8 years ago
ListScreenPost.php
8 years ago
ListScreenWP.php
8 years ago
Plugin.php
8 years ago
PluginInformation.php
8 years ago
Preferences.php
8 years ago
Relation.php
8 years ago
TableScreen.php
8 years ago
View.php
8 years ago
ViewInterface.php
8 years ago
ListScreenWP.php
114 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * @since 3.1 |
| 9 | */ |
| 10 | abstract class AC_ListScreenWP extends AC_ListScreen { |
| 11 | |
| 12 | /** |
| 13 | * Class name of the WP_List_Table instance |
| 14 | * |
| 15 | * @see WP_List_Table |
| 16 | * |
| 17 | * @since 3.0 |
| 18 | * @deprecated 3.1 |
| 19 | * |
| 20 | * @var string |
| 21 | */ |
| 22 | private $list_table_class; |
| 23 | |
| 24 | /** |
| 25 | * @return WP_List_Table |
| 26 | */ |
| 27 | abstract protected function get_list_table(); |
| 28 | |
| 29 | /** |
| 30 | * @param int $id |
| 31 | * |
| 32 | * @return object |
| 33 | */ |
| 34 | abstract protected function get_object( $id ); |
| 35 | |
| 36 | /** |
| 37 | * @param int $id |
| 38 | * |
| 39 | * @return string HTML |
| 40 | */ |
| 41 | public function get_single_row( $id ) { |
| 42 | ob_start(); |
| 43 | $this->get_list_table()->single_row( $this->get_object( $id ) ); |
| 44 | |
| 45 | return ob_get_clean(); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * @return array [ $column_name => [ $orderby, $order ], ... ] |
| 50 | */ |
| 51 | public function get_default_sortable_columns() { |
| 52 | $sortables = array(); |
| 53 | |
| 54 | foreach ( $this->get_list_table()->get_sortable_columns() as $name => $data ) { |
| 55 | $data = (array) $data; |
| 56 | |
| 57 | if ( ! isset( $data[1] ) ) { |
| 58 | $data[1] = false; |
| 59 | } |
| 60 | |
| 61 | $sortables[ $name ] = $data; |
| 62 | } |
| 63 | |
| 64 | return $sortables; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Get default column headers |
| 69 | * |
| 70 | * @see WP_List_Table::get_columns() |
| 71 | * |
| 72 | * @return array |
| 73 | */ |
| 74 | public function get_default_column_headers() { |
| 75 | $this->get_list_table(); |
| 76 | |
| 77 | return (array) get_column_headers( $this->get_screen_id() ); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * @deprecated 3.1 |
| 82 | * |
| 83 | * @return string |
| 84 | */ |
| 85 | public function get_list_table_class() { |
| 86 | return $this->list_table_class; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * @deprecated 3.1 |
| 91 | * |
| 92 | * @param string $list_table_class |
| 93 | */ |
| 94 | public function set_list_table_class( $list_table_class ) { |
| 95 | _deprecated_function( __METHOD__, '3.1', 'AC_ListScreenWP::get_list_table()' ); |
| 96 | |
| 97 | $this->list_table_class = (string) $list_table_class; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * @deprecated 3.1.2 |
| 102 | * |
| 103 | * @param int $id |
| 104 | * |
| 105 | * @return object |
| 106 | */ |
| 107 | protected function get_object_by_id( $id ) { |
| 108 | _deprecated_function( __METHOD__, 'NEWVERSION', 'AC_ListScreenWP::get_object()' ); |
| 109 | |
| 110 | return $this->get_object( $id ); |
| 111 | } |
| 112 | |
| 113 | } |
| 114 |