author | ymh <ymh.work@gmail.com> |
Mon, 08 Sep 2025 19:44:41 +0200 | |
changeset 23 | 417f20492bf7 |
parent 22 | 8c2e4d02f4ef |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3 |
* Administration API: WP_List_Table class |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
4 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5 |
* @package WordPress |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6 |
* @subpackage List_Table |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
7 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
8 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
9 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
10 |
/** |
0 | 11 |
* Base class for displaying a list of items in an ajaxified HTML table. |
12 |
* |
|
13 |
* @since 3.1.0 |
|
14 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
15 |
#[AllowDynamicProperties] |
0 | 16 |
class WP_List_Table { |
17 |
||
18 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
19 |
* The current list of items. |
0 | 20 |
* |
21 |
* @since 3.1.0 |
|
22 |
* @var array |
|
23 |
*/ |
|
5 | 24 |
public $items; |
0 | 25 |
|
26 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
27 |
* Various information about the current table. |
0 | 28 |
* |
29 |
* @since 3.1.0 |
|
30 |
* @var array |
|
31 |
*/ |
|
5 | 32 |
protected $_args; |
0 | 33 |
|
34 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
* Various information needed for displaying the pagination. |
0 | 36 |
* |
37 |
* @since 3.1.0 |
|
38 |
* @var array |
|
39 |
*/ |
|
5 | 40 |
protected $_pagination_args = array(); |
0 | 41 |
|
42 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
43 |
* The current screen. |
0 | 44 |
* |
45 |
* @since 3.1.0 |
|
18 | 46 |
* @var WP_Screen |
0 | 47 |
*/ |
5 | 48 |
protected $screen; |
0 | 49 |
|
50 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
51 |
* Cached bulk actions. |
0 | 52 |
* |
53 |
* @since 3.1.0 |
|
54 |
* @var array |
|
55 |
*/ |
|
5 | 56 |
private $_actions; |
0 | 57 |
|
58 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
59 |
* Cached pagination output. |
0 | 60 |
* |
61 |
* @since 3.1.0 |
|
62 |
* @var string |
|
63 |
*/ |
|
5 | 64 |
private $_pagination; |
65 |
||
66 |
/** |
|
67 |
* The view switcher modes. |
|
68 |
* |
|
69 |
* @since 4.1.0 |
|
70 |
* @var array |
|
71 |
*/ |
|
72 |
protected $modes = array(); |
|
73 |
||
74 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
* Stores the value returned by ->get_column_info(). |
5 | 76 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
* @since 4.1.0 |
5 | 78 |
* @var array |
79 |
*/ |
|
80 |
protected $_column_headers; |
|
81 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
82 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
83 |
* {@internal Missing Summary} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
* @var array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
*/ |
5 | 87 |
protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' ); |
88 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
89 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
* {@internal Missing Summary} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
91 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
92 |
* @var array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
93 |
*/ |
9 | 94 |
protected $compat_methods = array( |
95 |
'set_pagination_args', |
|
96 |
'get_views', |
|
97 |
'get_bulk_actions', |
|
98 |
'bulk_actions', |
|
99 |
'row_actions', |
|
100 |
'months_dropdown', |
|
101 |
'view_switcher', |
|
102 |
'comments_bubble', |
|
103 |
'get_items_per_page', |
|
104 |
'pagination', |
|
105 |
'get_sortable_columns', |
|
106 |
'get_column_info', |
|
107 |
'get_table_classes', |
|
108 |
'display_tablenav', |
|
109 |
'extra_tablenav', |
|
110 |
'single_row_columns', |
|
111 |
); |
|
0 | 112 |
|
113 |
/** |
|
5 | 114 |
* Constructor. |
115 |
* |
|
116 |
* The child class should call this constructor from its own constructor to override |
|
117 |
* the default $args. |
|
118 |
* |
|
119 |
* @since 3.1.0 |
|
120 |
* |
|
121 |
* @param array|string $args { |
|
122 |
* Array or string of arguments. |
|
0 | 123 |
* |
5 | 124 |
* @type string $plural Plural value used for labels and the objects being listed. |
125 |
* This affects things such as CSS class-names and nonces used |
|
126 |
* in the list table, e.g. 'posts'. Default empty. |
|
127 |
* @type string $singular Singular label for an object being listed, e.g. 'post'. |
|
128 |
* Default empty |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
129 |
* @type bool $ajax Whether the list table supports Ajax. This includes loading |
5 | 130 |
* and sorting data, for example. If true, the class will call |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
131 |
* the _js_vars() method in the footer to provide variables |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
132 |
* to any scripts handling Ajax events. Default false. |
5 | 133 |
* @type string $screen String containing the hook name used to determine the current |
134 |
* screen. If left null, the current screen will be automatically set. |
|
135 |
* Default null. |
|
136 |
* } |
|
0 | 137 |
*/ |
5 | 138 |
public function __construct( $args = array() ) { |
9 | 139 |
$args = wp_parse_args( |
140 |
$args, |
|
141 |
array( |
|
142 |
'plural' => '', |
|
143 |
'singular' => '', |
|
144 |
'ajax' => false, |
|
145 |
'screen' => null, |
|
146 |
) |
|
147 |
); |
|
0 | 148 |
|
149 |
$this->screen = convert_to_screen( $args['screen'] ); |
|
150 |
||
151 |
add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 ); |
|
152 |
||
9 | 153 |
if ( ! $args['plural'] ) { |
0 | 154 |
$args['plural'] = $this->screen->base; |
9 | 155 |
} |
0 | 156 |
|
9 | 157 |
$args['plural'] = sanitize_key( $args['plural'] ); |
0 | 158 |
$args['singular'] = sanitize_key( $args['singular'] ); |
159 |
||
160 |
$this->_args = $args; |
|
161 |
||
162 |
if ( $args['ajax'] ) { |
|
163 |
// wp_enqueue_script( 'list-table' ); |
|
164 |
add_action( 'admin_footer', array( $this, '_js_vars' ) ); |
|
165 |
} |
|
5 | 166 |
|
167 |
if ( empty( $this->modes ) ) { |
|
168 |
$this->modes = array( |
|
16 | 169 |
'list' => __( 'Compact view' ), |
170 |
'excerpt' => __( 'Extended view' ), |
|
5 | 171 |
); |
172 |
} |
|
173 |
} |
|
174 |
||
175 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
176 |
* Makes private properties readable for backward compatibility. |
5 | 177 |
* |
178 |
* @since 4.0.0 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
179 |
* @since 6.4.0 Getting a dynamic property is deprecated. |
5 | 180 |
* |
181 |
* @param string $name Property to get. |
|
182 |
* @return mixed Property. |
|
183 |
*/ |
|
184 |
public function __get( $name ) { |
|
16 | 185 |
if ( in_array( $name, $this->compat_fields, true ) ) { |
5 | 186 |
return $this->$name; |
187 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
188 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
189 |
wp_trigger_error( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
190 |
__METHOD__, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
191 |
"The property `{$name}` is not declared. Getting a dynamic property is " . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
192 |
'deprecated since version 6.4.0! Instead, declare the property on the class.', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
193 |
E_USER_DEPRECATED |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
194 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
195 |
return null; |
5 | 196 |
} |
197 |
||
198 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
199 |
* Makes private properties settable for backward compatibility. |
5 | 200 |
* |
201 |
* @since 4.0.0 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
202 |
* @since 6.4.0 Setting a dynamic property is deprecated. |
5 | 203 |
* |
204 |
* @param string $name Property to check if set. |
|
205 |
* @param mixed $value Property value. |
|
206 |
*/ |
|
207 |
public function __set( $name, $value ) { |
|
16 | 208 |
if ( in_array( $name, $this->compat_fields, true ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
209 |
$this->$name = $value; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
210 |
return; |
5 | 211 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
212 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
213 |
wp_trigger_error( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
214 |
__METHOD__, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
215 |
"The property `{$name}` is not declared. Setting a dynamic property is " . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
216 |
'deprecated since version 6.4.0! Instead, declare the property on the class.', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
217 |
E_USER_DEPRECATED |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
218 |
); |
5 | 219 |
} |
220 |
||
221 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
222 |
* Makes private properties checkable for backward compatibility. |
5 | 223 |
* |
224 |
* @since 4.0.0 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
225 |
* @since 6.4.0 Checking a dynamic property is deprecated. |
5 | 226 |
* |
227 |
* @param string $name Property to check if set. |
|
19 | 228 |
* @return bool Whether the property is a back-compat property and it is set. |
5 | 229 |
*/ |
230 |
public function __isset( $name ) { |
|
16 | 231 |
if ( in_array( $name, $this->compat_fields, true ) ) { |
5 | 232 |
return isset( $this->$name ); |
233 |
} |
|
19 | 234 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
235 |
wp_trigger_error( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
236 |
__METHOD__, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
237 |
"The property `{$name}` is not declared. Checking `isset()` on a dynamic property " . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
238 |
'is deprecated since version 6.4.0! Instead, declare the property on the class.', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
239 |
E_USER_DEPRECATED |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
240 |
); |
19 | 241 |
return false; |
5 | 242 |
} |
243 |
||
244 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
245 |
* Makes private properties un-settable for backward compatibility. |
5 | 246 |
* |
247 |
* @since 4.0.0 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
248 |
* @since 6.4.0 Unsetting a dynamic property is deprecated. |
5 | 249 |
* |
250 |
* @param string $name Property to unset. |
|
251 |
*/ |
|
252 |
public function __unset( $name ) { |
|
16 | 253 |
if ( in_array( $name, $this->compat_fields, true ) ) { |
5 | 254 |
unset( $this->$name ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
255 |
return; |
5 | 256 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
257 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
258 |
wp_trigger_error( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
259 |
__METHOD__, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
260 |
"A property `{$name}` is not declared. Unsetting a dynamic property is " . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
261 |
'deprecated since version 6.4.0! Instead, declare the property on the class.', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
262 |
E_USER_DEPRECATED |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
263 |
); |
5 | 264 |
} |
265 |
||
266 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
267 |
* Makes private/protected methods readable for backward compatibility. |
5 | 268 |
* |
269 |
* @since 4.0.0 |
|
270 |
* |
|
16 | 271 |
* @param string $name Method to call. |
272 |
* @param array $arguments Arguments to pass when calling. |
|
5 | 273 |
* @return mixed|bool Return value of the callback, false otherwise. |
274 |
*/ |
|
275 |
public function __call( $name, $arguments ) { |
|
16 | 276 |
if ( in_array( $name, $this->compat_methods, true ) ) { |
277 |
return $this->$name( ...$arguments ); |
|
5 | 278 |
} |
279 |
return false; |
|
0 | 280 |
} |
281 |
||
282 |
/** |
|
283 |
* Checks the current user's permissions |
|
284 |
* |
|
285 |
* @since 3.1.0 |
|
286 |
* @abstract |
|
287 |
*/ |
|
5 | 288 |
public function ajax_user_can() { |
16 | 289 |
die( 'function WP_List_Table::ajax_user_can() must be overridden in a subclass.' ); |
0 | 290 |
} |
291 |
||
292 |
/** |
|
293 |
* Prepares the list of items for displaying. |
|
9 | 294 |
* |
0 | 295 |
* @uses WP_List_Table::set_pagination_args() |
296 |
* |
|
297 |
* @since 3.1.0 |
|
298 |
* @abstract |
|
299 |
*/ |
|
5 | 300 |
public function prepare_items() { |
16 | 301 |
die( 'function WP_List_Table::prepare_items() must be overridden in a subclass.' ); |
0 | 302 |
} |
303 |
||
304 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
305 |
* Sets all the necessary pagination arguments. |
0 | 306 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
307 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
308 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
309 |
* @param array|string $args Array or string of arguments with information about the pagination. |
0 | 310 |
*/ |
5 | 311 |
protected function set_pagination_args( $args ) { |
9 | 312 |
$args = wp_parse_args( |
313 |
$args, |
|
314 |
array( |
|
315 |
'total_items' => 0, |
|
316 |
'total_pages' => 0, |
|
317 |
'per_page' => 0, |
|
318 |
) |
|
319 |
); |
|
0 | 320 |
|
9 | 321 |
if ( ! $args['total_pages'] && $args['per_page'] > 0 ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
322 |
$args['total_pages'] = (int) ceil( $args['total_items'] / $args['per_page'] ); |
9 | 323 |
} |
0 | 324 |
|
5 | 325 |
// Redirect if page number is invalid and headers are not already sent. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
326 |
if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) { |
0 | 327 |
wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) ); |
328 |
exit; |
|
329 |
} |
|
330 |
||
331 |
$this->_pagination_args = $args; |
|
332 |
} |
|
333 |
||
334 |
/** |
|
5 | 335 |
* Access the pagination args. |
0 | 336 |
* |
337 |
* @since 3.1.0 |
|
338 |
* |
|
5 | 339 |
* @param string $key Pagination argument to retrieve. Common values include 'total_items', |
340 |
* 'total_pages', 'per_page', or 'infinite_scroll'. |
|
341 |
* @return int Number of items that correspond to the given pagination argument. |
|
0 | 342 |
*/ |
5 | 343 |
public function get_pagination_arg( $key ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
if ( 'page' === $key ) { |
0 | 345 |
return $this->get_pagenum(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
} |
0 | 347 |
|
9 | 348 |
if ( isset( $this->_pagination_args[ $key ] ) ) { |
349 |
return $this->_pagination_args[ $key ]; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
350 |
} |
19 | 351 |
|
352 |
return 0; |
|
0 | 353 |
} |
354 |
||
355 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
356 |
* Determines whether the table has items to display or not |
0 | 357 |
* |
358 |
* @since 3.1.0 |
|
359 |
* |
|
360 |
* @return bool |
|
361 |
*/ |
|
5 | 362 |
public function has_items() { |
9 | 363 |
return ! empty( $this->items ); |
0 | 364 |
} |
365 |
||
366 |
/** |
|
367 |
* Message to be displayed when there are no items |
|
368 |
* |
|
369 |
* @since 3.1.0 |
|
370 |
*/ |
|
5 | 371 |
public function no_items() { |
0 | 372 |
_e( 'No items found.' ); |
373 |
} |
|
374 |
||
375 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
376 |
* Displays the search box. |
0 | 377 |
* |
378 |
* @since 3.1.0 |
|
379 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
380 |
* @param string $text The 'submit' button label. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
* @param string $input_id ID attribute value for the search input field. |
0 | 382 |
*/ |
5 | 383 |
public function search_box( $text, $input_id ) { |
9 | 384 |
if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
0 | 385 |
return; |
9 | 386 |
} |
0 | 387 |
|
388 |
$input_id = $input_id . '-search-input'; |
|
389 |
||
9 | 390 |
if ( ! empty( $_REQUEST['orderby'] ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
391 |
if ( is_array( $_REQUEST['orderby'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
392 |
foreach ( $_REQUEST['orderby'] as $key => $value ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
393 |
echo '<input type="hidden" name="orderby[' . esc_attr( $key ) . ']" value="' . esc_attr( $value ) . '" />'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
394 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
395 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
396 |
echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
397 |
} |
9 | 398 |
} |
399 |
if ( ! empty( $_REQUEST['order'] ) ) { |
|
0 | 400 |
echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
9 | 401 |
} |
402 |
if ( ! empty( $_REQUEST['post_mime_type'] ) ) { |
|
0 | 403 |
echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />'; |
9 | 404 |
} |
405 |
if ( ! empty( $_REQUEST['detached'] ) ) { |
|
0 | 406 |
echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />'; |
9 | 407 |
} |
408 |
?> |
|
0 | 409 |
<p class="search-box"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
410 |
<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
411 |
<input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
9 | 412 |
<?php submit_button( $text, '', '', false, array( 'id' => 'search-submit' ) ); ?> |
0 | 413 |
</p> |
9 | 414 |
<?php |
0 | 415 |
} |
416 |
||
417 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
418 |
* Generates views links. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
419 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
420 |
* @since 6.1.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
421 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
422 |
* @param array $link_data { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
423 |
* An array of link data. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
424 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
425 |
* @type string $url The link URL. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
426 |
* @type string $label The link label. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
427 |
* @type bool $current Optional. Whether this is the currently selected view. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
428 |
* } |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
429 |
* @return string[] An array of link markup. Keys match the `$link_data` input array. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
430 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
431 |
protected function get_views_links( $link_data = array() ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
432 |
if ( ! is_array( $link_data ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
433 |
_doing_it_wrong( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
434 |
__METHOD__, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
435 |
sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
436 |
/* translators: %s: The $link_data argument. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
437 |
__( 'The %s argument must be an array.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
438 |
'<code>$link_data</code>' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
439 |
), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
440 |
'6.1.0' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
441 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
442 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
443 |
return array( '' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
444 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
445 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
446 |
$views_links = array(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
447 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
448 |
foreach ( $link_data as $view => $link ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
449 |
if ( empty( $link['url'] ) || ! is_string( $link['url'] ) || '' === trim( $link['url'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
450 |
_doing_it_wrong( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
451 |
__METHOD__, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
452 |
sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
453 |
/* translators: %1$s: The argument name. %2$s: The view name. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
454 |
__( 'The %1$s argument must be a non-empty string for %2$s.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
455 |
'<code>url</code>', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
456 |
'<code>' . esc_html( $view ) . '</code>' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
457 |
), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
458 |
'6.1.0' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
459 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
460 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
461 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
462 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
463 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
464 |
if ( empty( $link['label'] ) || ! is_string( $link['label'] ) || '' === trim( $link['label'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
465 |
_doing_it_wrong( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
466 |
__METHOD__, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
467 |
sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
468 |
/* translators: %1$s: The argument name. %2$s: The view name. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
469 |
__( 'The %1$s argument must be a non-empty string for %2$s.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
470 |
'<code>label</code>', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
471 |
'<code>' . esc_html( $view ) . '</code>' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
472 |
), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
473 |
'6.1.0' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
474 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
475 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
476 |
continue; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
477 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
478 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
479 |
$views_links[ $view ] = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
480 |
'<a href="%s"%s>%s</a>', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
481 |
esc_url( $link['url'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
482 |
isset( $link['current'] ) && true === $link['current'] ? ' class="current" aria-current="page"' : '', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
483 |
$link['label'] |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
484 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
485 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
486 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
487 |
return $views_links; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
488 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
489 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
490 |
/** |
16 | 491 |
* Gets the list of views available on this table. |
492 |
* |
|
493 |
* The format is an associative array: |
|
494 |
* - `'id' => 'link'` |
|
0 | 495 |
* |
496 |
* @since 3.1.0 |
|
497 |
* |
|
498 |
* @return array |
|
499 |
*/ |
|
5 | 500 |
protected function get_views() { |
0 | 501 |
return array(); |
502 |
} |
|
503 |
||
504 |
/** |
|
16 | 505 |
* Displays the list of views available on this table. |
0 | 506 |
* |
507 |
* @since 3.1.0 |
|
508 |
*/ |
|
5 | 509 |
public function views() { |
0 | 510 |
$views = $this->get_views(); |
5 | 511 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
512 |
* Filters the list of available list table views. |
5 | 513 |
* |
514 |
* The dynamic portion of the hook name, `$this->screen->id`, refers |
|
18 | 515 |
* to the ID of the current screen. |
5 | 516 |
* |
16 | 517 |
* @since 3.1.0 |
5 | 518 |
* |
9 | 519 |
* @param string[] $views An array of available list table views. |
5 | 520 |
*/ |
521 |
$views = apply_filters( "views_{$this->screen->id}", $views ); |
|
0 | 522 |
|
9 | 523 |
if ( empty( $views ) ) { |
0 | 524 |
return; |
9 | 525 |
} |
0 | 526 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
527 |
$this->screen->render_screen_reader_content( 'heading_views' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
528 |
|
0 | 529 |
echo "<ul class='subsubsub'>\n"; |
530 |
foreach ( $views as $class => $view ) { |
|
531 |
$views[ $class ] = "\t<li class='$class'>$view"; |
|
532 |
} |
|
533 |
echo implode( " |</li>\n", $views ) . "</li>\n"; |
|
9 | 534 |
echo '</ul>'; |
0 | 535 |
} |
536 |
||
537 |
/** |
|
18 | 538 |
* Retrieves the list of bulk actions available for this table. |
539 |
* |
|
540 |
* The format is an associative array where each element represents either a top level option value and label, or |
|
541 |
* an array representing an optgroup and its options. |
|
542 |
* |
|
543 |
* For a standard option, the array element key is the field value and the array element value is the field label. |
|
544 |
* |
|
545 |
* For an optgroup, the array element key is the label and the array element value is an associative array of |
|
546 |
* options as above. |
|
16 | 547 |
* |
18 | 548 |
* Example: |
549 |
* |
|
550 |
* [ |
|
551 |
* 'edit' => 'Edit', |
|
552 |
* 'delete' => 'Delete', |
|
553 |
* 'Change State' => [ |
|
554 |
* 'feature' => 'Featured', |
|
555 |
* 'sale' => 'On Sale', |
|
556 |
* ] |
|
557 |
* ] |
|
0 | 558 |
* |
559 |
* @since 3.1.0 |
|
18 | 560 |
* @since 5.6.0 A bulk action can now contain an array of options in order to create an optgroup. |
0 | 561 |
* |
562 |
* @return array |
|
563 |
*/ |
|
5 | 564 |
protected function get_bulk_actions() { |
0 | 565 |
return array(); |
566 |
} |
|
567 |
||
568 |
/** |
|
16 | 569 |
* Displays the bulk actions dropdown. |
0 | 570 |
* |
571 |
* @since 3.1.0 |
|
5 | 572 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
573 |
* @param string $which The location of the bulk actions: Either 'top' or 'bottom'. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
574 |
* This is designated as optional for backward compatibility. |
0 | 575 |
*/ |
5 | 576 |
protected function bulk_actions( $which = '' ) { |
0 | 577 |
if ( is_null( $this->_actions ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
578 |
$this->_actions = $this->get_bulk_actions(); |
16 | 579 |
|
5 | 580 |
/** |
18 | 581 |
* Filters the items in the bulk actions menu of the list table. |
5 | 582 |
* |
583 |
* The dynamic portion of the hook name, `$this->screen->id`, refers |
|
18 | 584 |
* to the ID of the current screen. |
5 | 585 |
* |
16 | 586 |
* @since 3.1.0 |
18 | 587 |
* @since 5.6.0 A bulk action can now contain an array of options in order to create an optgroup. |
5 | 588 |
* |
18 | 589 |
* @param array $actions An array of the available bulk actions. |
5 | 590 |
*/ |
16 | 591 |
$this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
592 |
||
593 |
$two = ''; |
|
0 | 594 |
} else { |
595 |
$two = '2'; |
|
596 |
} |
|
597 |
||
9 | 598 |
if ( empty( $this->_actions ) ) { |
0 | 599 |
return; |
9 | 600 |
} |
0 | 601 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
602 |
echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
603 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
604 |
__( 'Select bulk action' ) . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
605 |
'</label>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
606 |
echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">\n"; |
16 | 607 |
echo '<option value="-1">' . __( 'Bulk actions' ) . "</option>\n"; |
0 | 608 |
|
18 | 609 |
foreach ( $this->_actions as $key => $value ) { |
610 |
if ( is_array( $value ) ) { |
|
611 |
echo "\t" . '<optgroup label="' . esc_attr( $key ) . '">' . "\n"; |
|
612 |
||
613 |
foreach ( $value as $name => $title ) { |
|
614 |
$class = ( 'edit' === $name ) ? ' class="hide-if-no-js"' : ''; |
|
0 | 615 |
|
18 | 616 |
echo "\t\t" . '<option value="' . esc_attr( $name ) . '"' . $class . '>' . $title . "</option>\n"; |
617 |
} |
|
618 |
echo "\t" . "</optgroup>\n"; |
|
619 |
} else { |
|
620 |
$class = ( 'edit' === $key ) ? ' class="hide-if-no-js"' : ''; |
|
621 |
||
622 |
echo "\t" . '<option value="' . esc_attr( $key ) . '"' . $class . '>' . $value . "</option>\n"; |
|
623 |
} |
|
0 | 624 |
} |
625 |
||
626 |
echo "</select>\n"; |
|
627 |
||
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
628 |
submit_button( __( 'Apply' ), 'action', 'bulk_action', false, array( 'id' => "doaction$two" ) ); |
0 | 629 |
echo "\n"; |
630 |
} |
|
631 |
||
632 |
/** |
|
16 | 633 |
* Gets the current action selected from the bulk actions dropdown. |
0 | 634 |
* |
635 |
* @since 3.1.0 |
|
636 |
* |
|
16 | 637 |
* @return string|false The action name. False if no action was selected. |
0 | 638 |
*/ |
5 | 639 |
public function current_action() { |
9 | 640 |
if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) { |
5 | 641 |
return false; |
9 | 642 |
} |
5 | 643 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
644 |
if ( isset( $_REQUEST['action'] ) && '-1' !== $_REQUEST['action'] ) { |
0 | 645 |
return $_REQUEST['action']; |
9 | 646 |
} |
0 | 647 |
|
648 |
return false; |
|
649 |
} |
|
650 |
||
651 |
/** |
|
16 | 652 |
* Generates the required HTML for a list of row action links. |
0 | 653 |
* |
654 |
* @since 3.1.0 |
|
655 |
* |
|
9 | 656 |
* @param string[] $actions An array of action links. |
657 |
* @param bool $always_visible Whether the actions should be always visible. |
|
16 | 658 |
* @return string The HTML for the row actions. |
0 | 659 |
*/ |
5 | 660 |
protected function row_actions( $actions, $always_visible = false ) { |
0 | 661 |
$action_count = count( $actions ); |
662 |
||
9 | 663 |
if ( ! $action_count ) { |
0 | 664 |
return ''; |
9 | 665 |
} |
0 | 666 |
|
16 | 667 |
$mode = get_user_setting( 'posts_list_mode', 'list' ); |
668 |
||
669 |
if ( 'excerpt' === $mode ) { |
|
670 |
$always_visible = true; |
|
671 |
} |
|
672 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
673 |
$output = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
16 | 674 |
|
675 |
$i = 0; |
|
676 |
||
0 | 677 |
foreach ( $actions as $action => $link ) { |
678 |
++$i; |
|
16 | 679 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
680 |
$separator = ( $i < $action_count ) ? ' | ' : ''; |
16 | 681 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
682 |
$output .= "<span class='$action'>{$link}{$separator}</span>"; |
0 | 683 |
} |
16 | 684 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
685 |
$output .= '</div>'; |
0 | 686 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
687 |
$output .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
688 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
689 |
__( 'Show more details' ) . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
690 |
'</span></button>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
691 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
692 |
return $output; |
0 | 693 |
} |
694 |
||
695 |
/** |
|
16 | 696 |
* Displays a dropdown for filtering items in the list table by month. |
0 | 697 |
* |
698 |
* @since 3.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
699 |
* |
16 | 700 |
* @global wpdb $wpdb WordPress database abstraction object. |
701 |
* @global WP_Locale $wp_locale WordPress date and time locale object. |
|
5 | 702 |
* |
16 | 703 |
* @param string $post_type The post type. |
0 | 704 |
*/ |
5 | 705 |
protected function months_dropdown( $post_type ) { |
0 | 706 |
global $wpdb, $wp_locale; |
707 |
||
5 | 708 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
709 |
* Filters whether to remove the 'Months' drop-down from the post list table. |
5 | 710 |
* |
711 |
* @since 4.2.0 |
|
712 |
* |
|
713 |
* @param bool $disable Whether to disable the drop-down. Default false. |
|
714 |
* @param string $post_type The post type. |
|
715 |
*/ |
|
716 |
if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) { |
|
717 |
return; |
|
718 |
} |
|
719 |
||
18 | 720 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
721 |
* Filters whether to short-circuit performing the months dropdown query. |
18 | 722 |
* |
723 |
* @since 5.7.0 |
|
724 |
* |
|
725 |
* @param object[]|false $months 'Months' drop-down results. Default false. |
|
726 |
* @param string $post_type The post type. |
|
727 |
*/ |
|
728 |
$months = apply_filters( 'pre_months_dropdown_query', false, $post_type ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
729 |
|
18 | 730 |
if ( ! is_array( $months ) ) { |
731 |
$extra_checks = "AND post_status != 'auto-draft'"; |
|
732 |
if ( ! isset( $_GET['post_status'] ) || 'trash' !== $_GET['post_status'] ) { |
|
733 |
$extra_checks .= " AND post_status != 'trash'"; |
|
734 |
} elseif ( isset( $_GET['post_status'] ) ) { |
|
735 |
$extra_checks = $wpdb->prepare( ' AND post_status = %s', $_GET['post_status'] ); |
|
736 |
} |
|
737 |
||
738 |
$months = $wpdb->get_results( |
|
739 |
$wpdb->prepare( |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
740 |
"SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
741 |
FROM $wpdb->posts |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
742 |
WHERE post_type = %s |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
743 |
$extra_checks |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
744 |
ORDER BY post_date DESC", |
18 | 745 |
$post_type |
746 |
) |
|
747 |
); |
|
748 |
} |
|
0 | 749 |
|
750 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
751 |
* Filters the 'Months' drop-down results. |
0 | 752 |
* |
753 |
* @since 3.7.0 |
|
754 |
* |
|
16 | 755 |
* @param object[] $months Array of the months drop-down query results. |
756 |
* @param string $post_type The post type. |
|
0 | 757 |
*/ |
758 |
$months = apply_filters( 'months_dropdown_results', $months, $post_type ); |
|
759 |
||
760 |
$month_count = count( $months ); |
|
761 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
762 |
if ( ! $month_count || ( 1 === $month_count && 0 === (int) $months[0]->month ) ) { |
0 | 763 |
return; |
9 | 764 |
} |
0 | 765 |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
766 |
$selected_month = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; |
9 | 767 |
?> |
18 | 768 |
<label for="filter-by-date" class="screen-reader-text"><?php echo get_post_type_object( $post_type )->labels->filter_by_date; ?></label> |
5 | 769 |
<select name="m" id="filter-by-date"> |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
770 |
<option<?php selected( $selected_month, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option> |
9 | 771 |
<?php |
0 | 772 |
foreach ( $months as $arc_row ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
773 |
if ( 0 === (int) $arc_row->year ) { |
0 | 774 |
continue; |
9 | 775 |
} |
0 | 776 |
|
777 |
$month = zeroise( $arc_row->month, 2 ); |
|
9 | 778 |
$year = $arc_row->year; |
0 | 779 |
|
9 | 780 |
printf( |
781 |
"<option %s value='%s'>%s</option>\n", |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
782 |
selected( $selected_month, $year . $month, false ), |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
783 |
esc_attr( $year . $month ), |
16 | 784 |
/* translators: 1: Month name, 2: 4-digit year. */ |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
785 |
esc_html( sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year ) ) |
0 | 786 |
); |
787 |
} |
|
9 | 788 |
?> |
0 | 789 |
</select> |
9 | 790 |
<?php |
0 | 791 |
} |
792 |
||
793 |
/** |
|
16 | 794 |
* Displays a view switcher. |
0 | 795 |
* |
796 |
* @since 3.1.0 |
|
5 | 797 |
* |
798 |
* @param string $current_mode |
|
0 | 799 |
*/ |
5 | 800 |
protected function view_switcher( $current_mode ) { |
9 | 801 |
?> |
0 | 802 |
<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" /> |
803 |
<div class="view-switch"> |
|
9 | 804 |
<?php |
805 |
foreach ( $this->modes as $mode => $title ) { |
|
16 | 806 |
$classes = array( 'view-' . $mode ); |
807 |
$aria_current = ''; |
|
808 |
||
9 | 809 |
if ( $current_mode === $mode ) { |
16 | 810 |
$classes[] = 'current'; |
811 |
$aria_current = ' aria-current="page"'; |
|
0 | 812 |
} |
16 | 813 |
|
9 | 814 |
printf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
815 |
"<a href='%s' class='%s' id='view-switch-$mode'$aria_current>" . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
816 |
"<span class='screen-reader-text'>%s</span>" . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
817 |
"</a>\n", |
16 | 818 |
esc_url( remove_query_arg( 'attachment-filter', add_query_arg( 'mode', $mode ) ) ), |
9 | 819 |
implode( ' ', $classes ), |
820 |
$title |
|
821 |
); |
|
822 |
} |
|
0 | 823 |
?> |
824 |
</div> |
|
9 | 825 |
<?php |
0 | 826 |
} |
827 |
||
828 |
/** |
|
16 | 829 |
* Displays a comment count bubble. |
0 | 830 |
* |
831 |
* @since 3.1.0 |
|
832 |
* |
|
5 | 833 |
* @param int $post_id The post ID. |
834 |
* @param int $pending_comments Number of pending comments. |
|
0 | 835 |
*/ |
5 | 836 |
protected function comments_bubble( $post_id, $pending_comments ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
837 |
$post_object = get_post( $post_id ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
838 |
$edit_post_cap = $post_object ? 'edit_post' : 'edit_posts'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
839 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
840 |
if ( ! current_user_can( $edit_post_cap, $post_id ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
841 |
&& ( post_password_required( $post_id ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
842 |
|| ! current_user_can( 'read_post', $post_id ) ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
843 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
844 |
// The user has no access to the post and thus cannot see the comments. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
845 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
846 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
847 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
848 |
$approved_comments = get_comments_number(); |
0 | 849 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
850 |
$approved_comments_number = number_format_i18n( $approved_comments ); |
9 | 851 |
$pending_comments_number = number_format_i18n( $pending_comments ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
852 |
|
16 | 853 |
$approved_only_phrase = sprintf( |
854 |
/* translators: %s: Number of comments. */ |
|
855 |
_n( '%s comment', '%s comments', $approved_comments ), |
|
856 |
$approved_comments_number |
|
857 |
); |
|
0 | 858 |
|
16 | 859 |
$approved_phrase = sprintf( |
860 |
/* translators: %s: Number of comments. */ |
|
861 |
_n( '%s approved comment', '%s approved comments', $approved_comments ), |
|
862 |
$approved_comments_number |
|
863 |
); |
|
864 |
||
865 |
$pending_phrase = sprintf( |
|
866 |
/* translators: %s: Number of comments. */ |
|
867 |
_n( '%s pending comment', '%s pending comments', $pending_comments ), |
|
868 |
$pending_comments_number |
|
869 |
); |
|
870 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
871 |
if ( ! $approved_comments && ! $pending_comments ) { |
16 | 872 |
// No comments at all. |
9 | 873 |
printf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
874 |
'<span aria-hidden="true">—</span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
875 |
'<span class="screen-reader-text">%s</span>', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
876 |
__( 'No comments' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
877 |
); |
16 | 878 |
} elseif ( $approved_comments && 'trash' === get_post_status( $post_id ) ) { |
879 |
// Don't link the comment bubble for a trashed post. |
|
880 |
printf( |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
881 |
'<span class="post-com-count post-com-count-approved">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
882 |
'<span class="comment-count-approved" aria-hidden="true">%s</span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
883 |
'<span class="screen-reader-text">%s</span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
884 |
'</span>', |
16 | 885 |
$approved_comments_number, |
886 |
$pending_comments ? $approved_phrase : $approved_only_phrase |
|
887 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
888 |
} elseif ( $approved_comments ) { |
16 | 889 |
// Link the comment bubble to approved comments. |
9 | 890 |
printf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
891 |
'<a href="%s" class="post-com-count post-com-count-approved">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
892 |
'<span class="comment-count-approved" aria-hidden="true">%s</span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
893 |
'<span class="screen-reader-text">%s</span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
894 |
'</a>', |
9 | 895 |
esc_url( |
896 |
add_query_arg( |
|
897 |
array( |
|
898 |
'p' => $post_id, |
|
899 |
'comment_status' => 'approved', |
|
900 |
), |
|
901 |
admin_url( 'edit-comments.php' ) |
|
902 |
) |
|
903 |
), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
904 |
$approved_comments_number, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
905 |
$pending_comments ? $approved_phrase : $approved_only_phrase |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
906 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
907 |
} else { |
16 | 908 |
// Don't link the comment bubble when there are no approved comments. |
9 | 909 |
printf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
910 |
'<span class="post-com-count post-com-count-no-comments">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
911 |
'<span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
912 |
'<span class="screen-reader-text">%s</span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
913 |
'</span>', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
914 |
$approved_comments_number, |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
915 |
$pending_comments ? |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
916 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
917 |
__( 'No approved comments' ) : |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
918 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
919 |
__( 'No comments' ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
920 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
921 |
} |
0 | 922 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
923 |
if ( $pending_comments ) { |
9 | 924 |
printf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
925 |
'<a href="%s" class="post-com-count post-com-count-pending">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
926 |
'<span class="comment-count-pending" aria-hidden="true">%s</span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
927 |
'<span class="screen-reader-text">%s</span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
928 |
'</a>', |
9 | 929 |
esc_url( |
930 |
add_query_arg( |
|
931 |
array( |
|
932 |
'p' => $post_id, |
|
933 |
'comment_status' => 'moderated', |
|
934 |
), |
|
935 |
admin_url( 'edit-comments.php' ) |
|
936 |
) |
|
937 |
), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
938 |
$pending_comments_number, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
939 |
$pending_phrase |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
940 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
941 |
} else { |
9 | 942 |
printf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
943 |
'<span class="post-com-count post-com-count-pending post-com-count-no-pending">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
944 |
'<span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
945 |
'<span class="screen-reader-text">%s</span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
946 |
'</span>', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
947 |
$pending_comments_number, |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
948 |
$approved_comments ? |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
949 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
950 |
__( 'No pending comments' ) : |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
951 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
952 |
__( 'No comments' ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
953 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
954 |
} |
0 | 955 |
} |
956 |
||
957 |
/** |
|
16 | 958 |
* Gets the current page number. |
0 | 959 |
* |
960 |
* @since 3.1.0 |
|
961 |
* |
|
962 |
* @return int |
|
963 |
*/ |
|
5 | 964 |
public function get_pagenum() { |
0 | 965 |
$pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0; |
966 |
||
9 | 967 |
if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) { |
0 | 968 |
$pagenum = $this->_pagination_args['total_pages']; |
9 | 969 |
} |
0 | 970 |
|
971 |
return max( 1, $pagenum ); |
|
972 |
} |
|
973 |
||
974 |
/** |
|
16 | 975 |
* Gets the number of items to display on a single page. |
0 | 976 |
* |
977 |
* @since 3.1.0 |
|
978 |
* |
|
19 | 979 |
* @param string $option User option name. |
980 |
* @param int $default_value Optional. The number of items to display. Default 20. |
|
0 | 981 |
* @return int |
982 |
*/ |
|
19 | 983 |
protected function get_items_per_page( $option, $default_value = 20 ) { |
0 | 984 |
$per_page = (int) get_user_option( $option ); |
9 | 985 |
if ( empty( $per_page ) || $per_page < 1 ) { |
19 | 986 |
$per_page = $default_value; |
9 | 987 |
} |
0 | 988 |
|
5 | 989 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
990 |
* Filters the number of items to be displayed on each page of the list table. |
5 | 991 |
* |
16 | 992 |
* The dynamic hook name, `$option`, refers to the `per_page` option depending |
993 |
* on the type of list table in use. Possible filter names include: |
|
994 |
* |
|
995 |
* - `edit_comments_per_page` |
|
996 |
* - `sites_network_per_page` |
|
997 |
* - `site_themes_network_per_page` |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
998 |
* - `themes_network_per_page` |
16 | 999 |
* - `users_network_per_page` |
1000 |
* - `edit_post_per_page` |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1001 |
* - `edit_page_per_page` |
16 | 1002 |
* - `edit_{$post_type}_per_page` |
1003 |
* - `edit_post_tag_per_page` |
|
1004 |
* - `edit_category_per_page` |
|
1005 |
* - `edit_{$taxonomy}_per_page` |
|
1006 |
* - `site_users_network_per_page` |
|
1007 |
* - `users_per_page` |
|
5 | 1008 |
* |
1009 |
* @since 2.9.0 |
|
1010 |
* |
|
1011 |
* @param int $per_page Number of items to be displayed. Default 20. |
|
1012 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1013 |
return (int) apply_filters( "{$option}", $per_page ); |
0 | 1014 |
} |
1015 |
||
1016 |
/** |
|
16 | 1017 |
* Displays the pagination. |
0 | 1018 |
* |
1019 |
* @since 3.1.0 |
|
5 | 1020 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1021 |
* @param string $which The location of the pagination: Either 'top' or 'bottom'. |
0 | 1022 |
*/ |
5 | 1023 |
protected function pagination( $which ) { |
1024 |
if ( empty( $this->_pagination_args ) ) { |
|
0 | 1025 |
return; |
5 | 1026 |
} |
0 | 1027 |
|
9 | 1028 |
$total_items = $this->_pagination_args['total_items']; |
1029 |
$total_pages = $this->_pagination_args['total_pages']; |
|
5 | 1030 |
$infinite_scroll = false; |
1031 |
if ( isset( $this->_pagination_args['infinite_scroll'] ) ) { |
|
1032 |
$infinite_scroll = $this->_pagination_args['infinite_scroll']; |
|
1033 |
} |
|
0 | 1034 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1035 |
if ( 'top' === $which && $total_pages > 1 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1036 |
$this->screen->render_screen_reader_content( 'heading_pagination' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1037 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1038 |
|
16 | 1039 |
$output = '<span class="displaying-num">' . sprintf( |
1040 |
/* translators: %s: Number of items. */ |
|
1041 |
_n( '%s item', '%s items', $total_items ), |
|
1042 |
number_format_i18n( $total_items ) |
|
1043 |
) . '</span>'; |
|
0 | 1044 |
|
9 | 1045 |
$current = $this->get_pagenum(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1046 |
$removable_query_args = wp_removable_query_args(); |
0 | 1047 |
|
1048 |
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
|
1049 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1050 |
$current_url = remove_query_arg( $removable_query_args, $current_url ); |
0 | 1051 |
|
1052 |
$page_links = array(); |
|
1053 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1054 |
$total_pages_before = '<span class="paging-input">'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1055 |
$total_pages_after = '</span></span>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1056 |
|
16 | 1057 |
$disable_first = false; |
1058 |
$disable_last = false; |
|
1059 |
$disable_prev = false; |
|
1060 |
$disable_next = false; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1061 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1062 |
if ( 1 === $current ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1063 |
$disable_first = true; |
9 | 1064 |
$disable_prev = true; |
1065 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1066 |
if ( $total_pages === $current ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1067 |
$disable_last = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1068 |
$disable_next = true; |
9 | 1069 |
} |
0 | 1070 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1071 |
if ( $disable_first ) { |
9 | 1072 |
$page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">«</span>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1073 |
} else { |
9 | 1074 |
$page_links[] = sprintf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1075 |
"<a class='first-page button' href='%s'>" . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1076 |
"<span class='screen-reader-text'>%s</span>" . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1077 |
"<span aria-hidden='true'>%s</span>" . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1078 |
'</a>', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1079 |
esc_url( remove_query_arg( 'paged', $current_url ) ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1080 |
/* translators: Hidden accessibility text. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1081 |
__( 'First page' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1082 |
'«' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1083 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1084 |
} |
0 | 1085 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1086 |
if ( $disable_prev ) { |
9 | 1087 |
$page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">‹</span>'; |
5 | 1088 |
} else { |
9 | 1089 |
$page_links[] = sprintf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1090 |
"<a class='prev-page button' href='%s'>" . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1091 |
"<span class='screen-reader-text'>%s</span>" . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1092 |
"<span aria-hidden='true'>%s</span>" . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1093 |
'</a>', |
9 | 1094 |
esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ) ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1095 |
/* translators: Hidden accessibility text. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1096 |
__( 'Previous page' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1097 |
'‹' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1098 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1099 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1100 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1101 |
if ( 'bottom' === $which ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1102 |
$html_current_page = $current; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1103 |
$total_pages_before = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1104 |
'<span class="screen-reader-text">%s</span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1105 |
'<span id="table-paging" class="paging-input">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1106 |
'<span class="tablenav-paging-text">', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1107 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1108 |
__( 'Current Page' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1109 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1110 |
} else { |
9 | 1111 |
$html_current_page = sprintf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1112 |
'<label for="current-page-selector" class="screen-reader-text">%s</label>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1113 |
"<input class='current-page' id='current-page-selector' type='text' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1114 |
name='paged' value='%s' size='%d' aria-describedby='table-paging' />" . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1115 |
"<span class='tablenav-paging-text'>", |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1116 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1117 |
__( 'Current Page' ), |
0 | 1118 |
$current, |
1119 |
strlen( $total_pages ) |
|
1120 |
); |
|
5 | 1121 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1122 |
|
0 | 1123 |
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1124 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1125 |
$page_links[] = $total_pages_before . sprintf( |
16 | 1126 |
/* translators: 1: Current page, 2: Total pages. */ |
1127 |
_x( '%1$s of %2$s', 'paging' ), |
|
1128 |
$html_current_page, |
|
1129 |
$html_total_pages |
|
1130 |
) . $total_pages_after; |
|
0 | 1131 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1132 |
if ( $disable_next ) { |
9 | 1133 |
$page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">›</span>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1134 |
} else { |
9 | 1135 |
$page_links[] = sprintf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1136 |
"<a class='next-page button' href='%s'>" . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1137 |
"<span class='screen-reader-text'>%s</span>" . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1138 |
"<span aria-hidden='true'>%s</span>" . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1139 |
'</a>', |
9 | 1140 |
esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $current_url ) ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1141 |
/* translators: Hidden accessibility text. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1142 |
__( 'Next page' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1143 |
'›' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1144 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1145 |
} |
0 | 1146 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1147 |
if ( $disable_last ) { |
9 | 1148 |
$page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">»</span>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1149 |
} else { |
9 | 1150 |
$page_links[] = sprintf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1151 |
"<a class='last-page button' href='%s'>" . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1152 |
"<span class='screen-reader-text'>%s</span>" . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1153 |
"<span aria-hidden='true'>%s</span>" . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1154 |
'</a>', |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1155 |
esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1156 |
/* translators: Hidden accessibility text. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1157 |
__( 'Last page' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1158 |
'»' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1159 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1160 |
} |
0 | 1161 |
|
1162 |
$pagination_links_class = 'pagination-links'; |
|
5 | 1163 |
if ( ! empty( $infinite_scroll ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1164 |
$pagination_links_class .= ' hide-if-js'; |
5 | 1165 |
} |
18 | 1166 |
$output .= "\n<span class='$pagination_links_class'>" . implode( "\n", $page_links ) . '</span>'; |
0 | 1167 |
|
5 | 1168 |
if ( $total_pages ) { |
0 | 1169 |
$page_class = $total_pages < 2 ? ' one-page' : ''; |
5 | 1170 |
} else { |
0 | 1171 |
$page_class = ' no-pages'; |
5 | 1172 |
} |
0 | 1173 |
$this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>"; |
1174 |
||
1175 |
echo $this->_pagination; |
|
1176 |
} |
|
1177 |
||
1178 |
/** |
|
16 | 1179 |
* Gets a list of columns. |
1180 |
* |
|
1181 |
* The format is: |
|
1182 |
* - `'internal-name' => 'Title'` |
|
0 | 1183 |
* |
1184 |
* @since 3.1.0 |
|
1185 |
* @abstract |
|
1186 |
* |
|
1187 |
* @return array |
|
1188 |
*/ |
|
5 | 1189 |
public function get_columns() { |
16 | 1190 |
die( 'function WP_List_Table::get_columns() must be overridden in a subclass.' ); |
0 | 1191 |
} |
1192 |
||
1193 |
/** |
|
16 | 1194 |
* Gets a list of sortable columns. |
0 | 1195 |
* |
16 | 1196 |
* The format is: |
1197 |
* - `'internal-name' => 'orderby'` |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1198 |
* - `'internal-name' => array( 'orderby', bool, 'abbr', 'orderby-text', 'initially-sorted-column-order' )` - |
16 | 1199 |
* - `'internal-name' => array( 'orderby', 'asc' )` - The second element sets the initial sorting order. |
1200 |
* - `'internal-name' => array( 'orderby', true )` - The second element makes the initial order descending. |
|
0 | 1201 |
* |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1202 |
* In the second format, passing true as second parameter will make the initial |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1203 |
* sorting order be descending. Following parameters add a short column name to |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1204 |
* be used as 'abbr' attribute, a translatable string for the current sorting, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1205 |
* and the initial order for the initial sorted column, 'asc' or 'desc' (default: false). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1206 |
* |
0 | 1207 |
* @since 3.1.0 |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1208 |
* @since 6.3.0 Added 'abbr', 'orderby-text' and 'initially-sorted-column-order'. |
0 | 1209 |
* |
1210 |
* @return array |
|
1211 |
*/ |
|
5 | 1212 |
protected function get_sortable_columns() { |
0 | 1213 |
return array(); |
1214 |
} |
|
1215 |
||
1216 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1217 |
* Gets the name of the default primary column. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1218 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1219 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1220 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1221 |
* @return string Name of the default primary column, in this case, an empty string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1222 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1223 |
protected function get_default_primary_column_name() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1224 |
$columns = $this->get_columns(); |
9 | 1225 |
$column = ''; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1226 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1227 |
if ( empty( $columns ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1228 |
return $column; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1229 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1230 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1231 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1232 |
* We need a primary defined so responsive views show something, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1233 |
* so let's fall back to the first non-checkbox column. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1234 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1235 |
foreach ( $columns as $col => $column_name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1236 |
if ( 'cb' === $col ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1237 |
continue; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1238 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1239 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1240 |
$column = $col; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1241 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1242 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1243 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1244 |
return $column; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1245 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1246 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1247 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1248 |
* Gets the name of the primary column. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1249 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1250 |
* Public wrapper for WP_List_Table::get_default_primary_column_name(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1251 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1252 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1253 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1254 |
* @return string Name of the default primary column. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1255 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1256 |
public function get_primary_column() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1257 |
return $this->get_primary_column_name(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1258 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1259 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1260 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1261 |
* Gets the name of the primary column. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1262 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1263 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1264 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1265 |
* @return string The name of the primary column. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1266 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1267 |
protected function get_primary_column_name() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1268 |
$columns = get_column_headers( $this->screen ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1269 |
$default = $this->get_default_primary_column_name(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1270 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1271 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1272 |
* If the primary column doesn't exist, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1273 |
* fall back to the first non-checkbox column. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1274 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1275 |
if ( ! isset( $columns[ $default ] ) ) { |
18 | 1276 |
$default = self::get_default_primary_column_name(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1277 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1278 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1279 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1280 |
* Filters the name of the primary column for the current list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1281 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1282 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1283 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1284 |
* @param string $default Column name default for the specific list table, e.g. 'name'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1285 |
* @param string $context Screen ID for specific list table, e.g. 'plugins'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1286 |
*/ |
9 | 1287 |
$column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1288 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1289 |
if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1290 |
$column = $default; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1291 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1292 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1293 |
return $column; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1294 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1295 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1296 |
/** |
18 | 1297 |
* Gets a list of all, hidden, and sortable columns, with filter applied. |
0 | 1298 |
* |
1299 |
* @since 3.1.0 |
|
1300 |
* |
|
1301 |
* @return array |
|
1302 |
*/ |
|
5 | 1303 |
protected function get_column_info() { |
16 | 1304 |
// $_column_headers is already set / cached. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1305 |
if ( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1306 |
isset( $this->_column_headers ) && |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1307 |
is_array( $this->_column_headers ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1308 |
) { |
18 | 1309 |
/* |
1310 |
* Backward compatibility for `$_column_headers` format prior to WordPress 4.3. |
|
1311 |
* |
|
1312 |
* In WordPress 4.3 the primary column name was added as a fourth item in the |
|
1313 |
* column headers property. This ensures the primary column name is included |
|
1314 |
* in plugins setting the property directly in the three item format. |
|
1315 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1316 |
if ( 4 === count( $this->_column_headers ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1317 |
return $this->_column_headers; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1318 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1319 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1320 |
$column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1321 |
foreach ( $this->_column_headers as $key => $value ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1322 |
$column_headers[ $key ] = $value; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1323 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1324 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1325 |
$this->_column_headers = $column_headers; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1326 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1327 |
return $this->_column_headers; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1328 |
} |
0 | 1329 |
|
1330 |
$columns = get_column_headers( $this->screen ); |
|
9 | 1331 |
$hidden = get_hidden_columns( $this->screen ); |
0 | 1332 |
|
5 | 1333 |
$sortable_columns = $this->get_sortable_columns(); |
1334 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1335 |
* Filters the list table sortable columns for a specific screen. |
5 | 1336 |
* |
1337 |
* The dynamic portion of the hook name, `$this->screen->id`, refers |
|
18 | 1338 |
* to the ID of the current screen. |
5 | 1339 |
* |
16 | 1340 |
* @since 3.1.0 |
5 | 1341 |
* |
1342 |
* @param array $sortable_columns An array of sortable columns. |
|
1343 |
*/ |
|
1344 |
$_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns ); |
|
0 | 1345 |
|
1346 |
$sortable = array(); |
|
1347 |
foreach ( $_sortable as $id => $data ) { |
|
9 | 1348 |
if ( empty( $data ) ) { |
0 | 1349 |
continue; |
9 | 1350 |
} |
0 | 1351 |
|
1352 |
$data = (array) $data; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1353 |
// Descending initial sorting. |
9 | 1354 |
if ( ! isset( $data[1] ) ) { |
0 | 1355 |
$data[1] = false; |
9 | 1356 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1357 |
// Current sorting translatable string. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1358 |
if ( ! isset( $data[2] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1359 |
$data[2] = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1360 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1361 |
// Initial view sorted column and asc/desc order, default: false. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1362 |
if ( ! isset( $data[3] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1363 |
$data[3] = false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1364 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1365 |
// Initial order for the initial sorted column, default: false. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1366 |
if ( ! isset( $data[4] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1367 |
$data[4] = false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1368 |
} |
0 | 1369 |
|
9 | 1370 |
$sortable[ $id ] = $data; |
0 | 1371 |
} |
1372 |
||
9 | 1373 |
$primary = $this->get_primary_column_name(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1374 |
$this->_column_headers = array( $columns, $hidden, $sortable, $primary ); |
0 | 1375 |
|
1376 |
return $this->_column_headers; |
|
1377 |
} |
|
1378 |
||
1379 |
/** |
|
16 | 1380 |
* Returns the number of visible columns. |
0 | 1381 |
* |
1382 |
* @since 3.1.0 |
|
1383 |
* |
|
1384 |
* @return int |
|
1385 |
*/ |
|
5 | 1386 |
public function get_column_count() { |
0 | 1387 |
list ( $columns, $hidden ) = $this->get_column_info(); |
9 | 1388 |
$hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) ); |
0 | 1389 |
return count( $columns ) - count( $hidden ); |
1390 |
} |
|
1391 |
||
1392 |
/** |
|
16 | 1393 |
* Prints column headers, accounting for hidden and sortable columns. |
0 | 1394 |
* |
1395 |
* @since 3.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1396 |
* |
16 | 1397 |
* @param bool $with_id Whether to set the ID attribute or not |
0 | 1398 |
*/ |
5 | 1399 |
public function print_column_headers( $with_id = true ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1400 |
list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
0 | 1401 |
|
1402 |
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); |
|
1403 |
$current_url = remove_query_arg( 'paged', $current_url ); |
|
1404 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1405 |
// When users click on a column header to sort by other columns. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1406 |
if ( isset( $_GET['orderby'] ) ) { |
0 | 1407 |
$current_orderby = $_GET['orderby']; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1408 |
// In the initial view there's no orderby parameter. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1409 |
} else { |
0 | 1410 |
$current_orderby = ''; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1411 |
} |
0 | 1412 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1413 |
// Not in the initial view and descending order. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1414 |
if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) { |
0 | 1415 |
$current_order = 'desc'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1416 |
} else { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1417 |
// The initial view is not always 'asc', we'll take care of this below. |
0 | 1418 |
$current_order = 'asc'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1419 |
} |
0 | 1420 |
|
1421 |
if ( ! empty( $columns['cb'] ) ) { |
|
1422 |
static $cb_counter = 1; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1423 |
$columns['cb'] = '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" /> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1424 |
<label for="cb-select-all-' . $cb_counter . '">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1425 |
'<span class="screen-reader-text">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1426 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1427 |
__( 'Select All' ) . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1428 |
'</span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1429 |
'</label>'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1430 |
++$cb_counter; |
0 | 1431 |
} |
1432 |
||
1433 |
foreach ( $columns as $column_key => $column_display_name ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1434 |
$class = array( 'manage-column', "column-$column_key" ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1435 |
$aria_sort_attr = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1436 |
$abbr_attr = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1437 |
$order_text = ''; |
0 | 1438 |
|
16 | 1439 |
if ( in_array( $column_key, $hidden, true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1440 |
$class[] = 'hidden'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1441 |
} |
0 | 1442 |
|
9 | 1443 |
if ( 'cb' === $column_key ) { |
0 | 1444 |
$class[] = 'check-column'; |
16 | 1445 |
} elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) { |
0 | 1446 |
$class[] = 'num'; |
9 | 1447 |
} |
0 | 1448 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1449 |
if ( $column_key === $primary ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1450 |
$class[] = 'column-primary'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1451 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1452 |
|
9 | 1453 |
if ( isset( $sortable[ $column_key ] ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1454 |
$orderby = isset( $sortable[ $column_key ][0] ) ? $sortable[ $column_key ][0] : ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1455 |
$desc_first = isset( $sortable[ $column_key ][1] ) ? $sortable[ $column_key ][1] : false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1456 |
$abbr = isset( $sortable[ $column_key ][2] ) ? $sortable[ $column_key ][2] : ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1457 |
$orderby_text = isset( $sortable[ $column_key ][3] ) ? $sortable[ $column_key ][3] : ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1458 |
$initial_order = isset( $sortable[ $column_key ][4] ) ? $sortable[ $column_key ][4] : ''; |
0 | 1459 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1460 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1461 |
* We're in the initial view and there's no $_GET['orderby'] then check if the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1462 |
* initial sorting information is set in the sortable columns and use that. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1463 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1464 |
if ( '' === $current_orderby && $initial_order ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1465 |
// Use the initially sorted column $orderby as current orderby. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1466 |
$current_orderby = $orderby; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1467 |
// Use the initially sorted column asc/desc order as initial order. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1468 |
$current_order = $initial_order; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1469 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1470 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1471 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1472 |
* True in the initial view when an initial orderby is set via get_sortable_columns() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1473 |
* and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1474 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1475 |
if ( $current_orderby === $orderby ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1476 |
// The sorted column. The `aria-sort` attribute must be set only on the sorted column. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1477 |
if ( 'asc' === $current_order ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1478 |
$order = 'desc'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1479 |
$aria_sort_attr = ' aria-sort="ascending"'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1480 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1481 |
$order = 'asc'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1482 |
$aria_sort_attr = ' aria-sort="descending"'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1483 |
} |
16 | 1484 |
|
0 | 1485 |
$class[] = 'sorted'; |
1486 |
$class[] = $current_order; |
|
1487 |
} else { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1488 |
// The other sortable columns. |
16 | 1489 |
$order = strtolower( $desc_first ); |
1490 |
||
1491 |
if ( ! in_array( $order, array( 'desc', 'asc' ), true ) ) { |
|
1492 |
$order = $desc_first ? 'desc' : 'asc'; |
|
1493 |
} |
|
1494 |
||
0 | 1495 |
$class[] = 'sortable'; |
16 | 1496 |
$class[] = 'desc' === $order ? 'asc' : 'desc'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1497 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1498 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1499 |
$asc_text = __( 'Sort ascending.' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1500 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1501 |
$desc_text = __( 'Sort descending.' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1502 |
$order_text = 'asc' === $order ? $asc_text : $desc_text; |
0 | 1503 |
} |
1504 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1505 |
if ( '' !== $order_text ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1506 |
$order_text = ' <span class="screen-reader-text">' . $order_text . '</span>'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1507 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1508 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1509 |
// Print an 'abbr' attribute if a value is provided via get_sortable_columns(). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1510 |
$abbr_attr = $abbr ? ' abbr="' . esc_attr( $abbr ) . '"' : ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1511 |
|
16 | 1512 |
$column_display_name = sprintf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1513 |
'<a href="%1$s">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1514 |
'<span>%2$s</span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1515 |
'<span class="sorting-indicators">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1516 |
'<span class="sorting-indicator asc" aria-hidden="true"></span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1517 |
'<span class="sorting-indicator desc" aria-hidden="true"></span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1518 |
'</span>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1519 |
'%3$s' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1520 |
'</a>', |
16 | 1521 |
esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1522 |
$column_display_name, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1523 |
$order_text |
16 | 1524 |
); |
0 | 1525 |
} |
1526 |
||
9 | 1527 |
$tag = ( 'cb' === $column_key ) ? 'td' : 'th'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1528 |
$scope = ( 'th' === $tag ) ? 'scope="col"' : ''; |
9 | 1529 |
$id = $with_id ? "id='$column_key'" : ''; |
0 | 1530 |
|
9 | 1531 |
if ( ! empty( $class ) ) { |
18 | 1532 |
$class = "class='" . implode( ' ', $class ) . "'"; |
9 | 1533 |
} |
0 | 1534 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1535 |
echo "<$tag $scope $id $class $aria_sort_attr $abbr_attr>$column_display_name</$tag>"; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1536 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1537 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1538 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1539 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1540 |
* Print a table description with information about current sorting and order. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1541 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1542 |
* For the table initial view, information about initial orderby and order |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1543 |
* should be provided via get_sortable_columns(). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1544 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1545 |
* @since 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1546 |
* @access public |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1547 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1548 |
public function print_table_description() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1549 |
list( $columns, $hidden, $sortable ) = $this->get_column_info(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1550 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1551 |
if ( empty( $sortable ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1552 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1553 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1554 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1555 |
// When users click on a column header to sort by other columns. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1556 |
if ( isset( $_GET['orderby'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1557 |
$current_orderby = $_GET['orderby']; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1558 |
// In the initial view there's no orderby parameter. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1559 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1560 |
$current_orderby = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1561 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1562 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1563 |
// Not in the initial view and descending order. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1564 |
if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1565 |
$current_order = 'desc'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1566 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1567 |
// The initial view is not always 'asc', we'll take care of this below. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1568 |
$current_order = 'asc'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1569 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1570 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1571 |
foreach ( array_keys( $columns ) as $column_key ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1572 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1573 |
if ( isset( $sortable[ $column_key ] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1574 |
$orderby = isset( $sortable[ $column_key ][0] ) ? $sortable[ $column_key ][0] : ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1575 |
$desc_first = isset( $sortable[ $column_key ][1] ) ? $sortable[ $column_key ][1] : false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1576 |
$abbr = isset( $sortable[ $column_key ][2] ) ? $sortable[ $column_key ][2] : ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1577 |
$orderby_text = isset( $sortable[ $column_key ][3] ) ? $sortable[ $column_key ][3] : ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1578 |
$initial_order = isset( $sortable[ $column_key ][4] ) ? $sortable[ $column_key ][4] : ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1579 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1580 |
if ( ! is_string( $orderby_text ) || '' === $orderby_text ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1581 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1582 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1583 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1584 |
* We're in the initial view and there's no $_GET['orderby'] then check if the |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1585 |
* initial sorting information is set in the sortable columns and use that. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1586 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1587 |
if ( '' === $current_orderby && $initial_order ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1588 |
// Use the initially sorted column $orderby as current orderby. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1589 |
$current_orderby = $orderby; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1590 |
// Use the initially sorted column asc/desc order as initial order. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1591 |
$current_order = $initial_order; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1592 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1593 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1594 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1595 |
* True in the initial view when an initial orderby is set via get_sortable_columns() |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1596 |
* and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1597 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1598 |
if ( $current_orderby === $orderby ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1599 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1600 |
$asc_text = __( 'Ascending.' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1601 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1602 |
$desc_text = __( 'Descending.' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1603 |
$order_text = 'asc' === $current_order ? $asc_text : $desc_text; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1604 |
echo '<caption class="screen-reader-text">' . $orderby_text . ' ' . $order_text . '</caption>'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1605 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1606 |
return; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1607 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1608 |
} |
0 | 1609 |
} |
1610 |
} |
|
1611 |
||
1612 |
/** |
|
16 | 1613 |
* Displays the table. |
0 | 1614 |
* |
1615 |
* @since 3.1.0 |
|
1616 |
*/ |
|
5 | 1617 |
public function display() { |
1618 |
$singular = $this->_args['singular']; |
|
0 | 1619 |
|
1620 |
$this->display_tablenav( 'top' ); |
|
1621 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1622 |
$this->screen->render_screen_reader_content( 'heading_list' ); |
9 | 1623 |
?> |
5 | 1624 |
<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>"> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1625 |
<?php $this->print_table_description(); ?> |
0 | 1626 |
<thead> |
1627 |
<tr> |
|
1628 |
<?php $this->print_column_headers(); ?> |
|
1629 |
</tr> |
|
1630 |
</thead> |
|
1631 |
||
9 | 1632 |
<tbody id="the-list" |
1633 |
<?php |
|
5 | 1634 |
if ( $singular ) { |
1635 |
echo " data-wp-lists='list:$singular'"; |
|
9 | 1636 |
} |
1637 |
?> |
|
1638 |
> |
|
5 | 1639 |
<?php $this->display_rows_or_placeholder(); ?> |
1640 |
</tbody> |
|
1641 |
||
0 | 1642 |
<tfoot> |
1643 |
<tr> |
|
1644 |
<?php $this->print_column_headers( false ); ?> |
|
1645 |
</tr> |
|
1646 |
</tfoot> |
|
1647 |
||
1648 |
</table> |
|
9 | 1649 |
<?php |
0 | 1650 |
$this->display_tablenav( 'bottom' ); |
1651 |
} |
|
1652 |
||
1653 |
/** |
|
16 | 1654 |
* Gets a list of CSS classes for the WP_List_Table table tag. |
0 | 1655 |
* |
1656 |
* @since 3.1.0 |
|
1657 |
* |
|
16 | 1658 |
* @return string[] Array of CSS classes for the table tag. |
0 | 1659 |
*/ |
5 | 1660 |
protected function get_table_classes() { |
16 | 1661 |
$mode = get_user_setting( 'posts_list_mode', 'list' ); |
1662 |
||
1663 |
$mode_class = esc_attr( 'table-view-' . $mode ); |
|
1664 |
||
1665 |
return array( 'widefat', 'fixed', 'striped', $mode_class, $this->_args['plural'] ); |
|
0 | 1666 |
} |
1667 |
||
1668 |
/** |
|
16 | 1669 |
* Generates the table navigation above or below the table |
0 | 1670 |
* |
1671 |
* @since 3.1.0 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1672 |
* @param string $which The location of the navigation: Either 'top' or 'bottom'. |
0 | 1673 |
*/ |
5 | 1674 |
protected function display_tablenav( $which ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1675 |
if ( 'top' === $which ) { |
0 | 1676 |
wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1677 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1678 |
?> |
0 | 1679 |
<div class="tablenav <?php echo esc_attr( $which ); ?>"> |
1680 |
||
9 | 1681 |
<?php if ( $this->has_items() ) : ?> |
0 | 1682 |
<div class="alignleft actions bulkactions"> |
5 | 1683 |
<?php $this->bulk_actions( $which ); ?> |
0 | 1684 |
</div> |
9 | 1685 |
<?php |
1686 |
endif; |
|
0 | 1687 |
$this->extra_tablenav( $which ); |
1688 |
$this->pagination( $which ); |
|
9 | 1689 |
?> |
0 | 1690 |
|
1691 |
<br class="clear" /> |
|
1692 |
</div> |
|
9 | 1693 |
<?php |
0 | 1694 |
} |
1695 |
||
1696 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1697 |
* Displays extra controls between bulk actions and pagination. |
0 | 1698 |
* |
1699 |
* @since 3.1.0 |
|
5 | 1700 |
* |
1701 |
* @param string $which |
|
0 | 1702 |
*/ |
5 | 1703 |
protected function extra_tablenav( $which ) {} |
0 | 1704 |
|
1705 |
/** |
|
16 | 1706 |
* Generates the tbody element for the list table. |
0 | 1707 |
* |
1708 |
* @since 3.1.0 |
|
1709 |
*/ |
|
5 | 1710 |
public function display_rows_or_placeholder() { |
0 | 1711 |
if ( $this->has_items() ) { |
1712 |
$this->display_rows(); |
|
1713 |
} else { |
|
1714 |
echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">'; |
|
1715 |
$this->no_items(); |
|
1716 |
echo '</td></tr>'; |
|
1717 |
} |
|
1718 |
} |
|
1719 |
||
1720 |
/** |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
1721 |
* Generates the list table rows. |
0 | 1722 |
* |
1723 |
* @since 3.1.0 |
|
1724 |
*/ |
|
5 | 1725 |
public function display_rows() { |
9 | 1726 |
foreach ( $this->items as $item ) { |
0 | 1727 |
$this->single_row( $item ); |
9 | 1728 |
} |
0 | 1729 |
} |
1730 |
||
1731 |
/** |
|
16 | 1732 |
* Generates content for a single row of the table. |
0 | 1733 |
* |
1734 |
* @since 3.1.0 |
|
1735 |
* |
|
18 | 1736 |
* @param object|array $item The current item |
0 | 1737 |
*/ |
5 | 1738 |
public function single_row( $item ) { |
1739 |
echo '<tr>'; |
|
0 | 1740 |
$this->single_row_columns( $item ); |
1741 |
echo '</tr>'; |
|
1742 |
} |
|
1743 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1744 |
/** |
18 | 1745 |
* @param object|array $item |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1746 |
* @param string $column_name |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1747 |
*/ |
5 | 1748 |
protected function column_default( $item, $column_name ) {} |
1749 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1750 |
/** |
18 | 1751 |
* @param object|array $item |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1752 |
*/ |
5 | 1753 |
protected function column_cb( $item ) {} |
1754 |
||
0 | 1755 |
/** |
16 | 1756 |
* Generates the columns for a single row of the table. |
0 | 1757 |
* |
1758 |
* @since 3.1.0 |
|
1759 |
* |
|
18 | 1760 |
* @param object|array $item The current item. |
0 | 1761 |
*/ |
5 | 1762 |
protected function single_row_columns( $item ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1763 |
list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
0 | 1764 |
|
1765 |
foreach ( $columns as $column_name => $column_display_name ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1766 |
$classes = "$column_name column-$column_name"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1767 |
if ( $primary === $column_name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1768 |
$classes .= ' has-row-actions column-primary'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1769 |
} |
0 | 1770 |
|
16 | 1771 |
if ( in_array( $column_name, $hidden, true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1772 |
$classes .= ' hidden'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1773 |
} |
0 | 1774 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1775 |
/* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1776 |
* Comments column uses HTML in the display name with screen reader text. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1777 |
* Strip tags to get closer to a user-friendly string. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1778 |
*/ |
18 | 1779 |
$data = 'data-colname="' . esc_attr( wp_strip_all_tags( $column_display_name ) ) . '"'; |
0 | 1780 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1781 |
$attributes = "class='$classes' $data"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1782 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1783 |
if ( 'cb' === $column_name ) { |
0 | 1784 |
echo '<th scope="row" class="check-column">'; |
1785 |
echo $this->column_cb( $item ); |
|
1786 |
echo '</th>'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1787 |
} elseif ( method_exists( $this, '_column_' . $column_name ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1788 |
echo call_user_func( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1789 |
array( $this, '_column_' . $column_name ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1790 |
$item, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1791 |
$classes, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1792 |
$data, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1793 |
$primary |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1794 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1795 |
} elseif ( method_exists( $this, 'column_' . $column_name ) ) { |
0 | 1796 |
echo "<td $attributes>"; |
1797 |
echo call_user_func( array( $this, 'column_' . $column_name ), $item ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1798 |
echo $this->handle_row_actions( $item, $column_name, $primary ); |
9 | 1799 |
echo '</td>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1800 |
} else { |
0 | 1801 |
echo "<td $attributes>"; |
1802 |
echo $this->column_default( $item, $column_name ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1803 |
echo $this->handle_row_actions( $item, $column_name, $primary ); |
9 | 1804 |
echo '</td>'; |
0 | 1805 |
} |
1806 |
} |
|
1807 |
} |
|
1808 |
||
1809 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1810 |
* Generates and display row actions links for the list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1811 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1812 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1813 |
* |
18 | 1814 |
* @param object|array $item The item being acted upon. |
1815 |
* @param string $column_name Current column name. |
|
1816 |
* @param string $primary Primary column name. |
|
16 | 1817 |
* @return string The row actions HTML, or an empty string |
1818 |
* if the current column is not the primary column. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1819 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1820 |
protected function handle_row_actions( $item, $column_name, $primary ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1821 |
return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1822 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1823 |
__( 'Show more details' ) . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1824 |
'</span></button>' : ''; |
9 | 1825 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1826 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1827 |
/** |
16 | 1828 |
* Handles an incoming ajax request (called from admin-ajax.php) |
0 | 1829 |
* |
1830 |
* @since 3.1.0 |
|
1831 |
*/ |
|
5 | 1832 |
public function ajax_response() { |
0 | 1833 |
$this->prepare_items(); |
1834 |
||
1835 |
ob_start(); |
|
5 | 1836 |
if ( ! empty( $_REQUEST['no_placeholder'] ) ) { |
0 | 1837 |
$this->display_rows(); |
5 | 1838 |
} else { |
0 | 1839 |
$this->display_rows_or_placeholder(); |
5 | 1840 |
} |
0 | 1841 |
|
1842 |
$rows = ob_get_clean(); |
|
1843 |
||
1844 |
$response = array( 'rows' => $rows ); |
|
1845 |
||
5 | 1846 |
if ( isset( $this->_pagination_args['total_items'] ) ) { |
1847 |
$response['total_items_i18n'] = sprintf( |
|
16 | 1848 |
/* translators: Number of items. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1849 |
_n( '%s item', '%s items', $this->_pagination_args['total_items'] ), |
5 | 1850 |
number_format_i18n( $this->_pagination_args['total_items'] ) |
1851 |
); |
|
1852 |
} |
|
1853 |
if ( isset( $this->_pagination_args['total_pages'] ) ) { |
|
9 | 1854 |
$response['total_pages'] = $this->_pagination_args['total_pages']; |
5 | 1855 |
$response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] ); |
0 | 1856 |
} |
1857 |
||
5 | 1858 |
die( wp_json_encode( $response ) ); |
0 | 1859 |
} |
1860 |
||
1861 |
/** |
|
16 | 1862 |
* Sends required variables to JavaScript land. |
1863 |
* |
|
1864 |
* @since 3.1.0 |
|
0 | 1865 |
*/ |
5 | 1866 |
public function _js_vars() { |
0 | 1867 |
$args = array( |
1868 |
'class' => get_class( $this ), |
|
1869 |
'screen' => array( |
|
1870 |
'id' => $this->screen->id, |
|
1871 |
'base' => $this->screen->base, |
|
9 | 1872 |
), |
0 | 1873 |
); |
1874 |
||
5 | 1875 |
printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) ); |
0 | 1876 |
} |
1877 |
} |