author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:40:08 +0200 | |
changeset 21 | 48c4eec2b7e6 |
parent 19 | 3d72ae0968f4 |
child 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 |
* List Table API: WP_Posts_List_Table class |
0 | 4 |
* |
5 |
* @package WordPress |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6 |
* @subpackage Administration |
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 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
11 |
* Core class used to implement displaying posts in a list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
12 |
* |
0 | 13 |
* @since 3.1.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
14 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
15 |
* @see WP_List_Table |
0 | 16 |
*/ |
17 |
class WP_Posts_List_Table extends WP_List_Table { |
|
18 |
||
19 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
20 |
* Whether the items should be displayed hierarchically or linearly. |
0 | 21 |
* |
22 |
* @since 3.1.0 |
|
23 |
* @var bool |
|
24 |
*/ |
|
5 | 25 |
protected $hierarchical_display; |
0 | 26 |
|
27 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
* Holds the number of pending comments for each post. |
0 | 29 |
* |
30 |
* @since 3.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
31 |
* @var array |
0 | 32 |
*/ |
5 | 33 |
protected $comment_pending_count; |
0 | 34 |
|
35 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
36 |
* Holds the number of posts for this user. |
0 | 37 |
* |
38 |
* @since 3.1.0 |
|
39 |
* @var int |
|
40 |
*/ |
|
5 | 41 |
private $user_posts_count; |
0 | 42 |
|
43 |
/** |
|
44 |
* Holds the number of posts which are sticky. |
|
45 |
* |
|
46 |
* @since 3.1.0 |
|
47 |
* @var int |
|
48 |
*/ |
|
5 | 49 |
private $sticky_posts_count = 0; |
50 |
||
51 |
private $is_trash; |
|
0 | 52 |
|
5 | 53 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
54 |
* Current level for output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
55 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
57 |
* @var int |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
58 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
59 |
protected $current_level = 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
60 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
61 |
/** |
5 | 62 |
* Constructor. |
63 |
* |
|
64 |
* @since 3.1.0 |
|
65 |
* |
|
66 |
* @see WP_List_Table::__construct() for more information on default arguments. |
|
67 |
* |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
68 |
* @global WP_Post_Type $post_type_object Global post type object. |
16 | 69 |
* @global wpdb $wpdb WordPress database abstraction object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
70 |
* |
5 | 71 |
* @param array $args An associative array of arguments. |
72 |
*/ |
|
73 |
public function __construct( $args = array() ) { |
|
0 | 74 |
global $post_type_object, $wpdb; |
75 |
||
9 | 76 |
parent::__construct( |
77 |
array( |
|
78 |
'plural' => 'posts', |
|
79 |
'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
80 |
) |
|
81 |
); |
|
0 | 82 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
83 |
$post_type = $this->screen->post_type; |
0 | 84 |
$post_type_object = get_post_type_object( $post_type ); |
85 |
||
18 | 86 |
$exclude_states = get_post_stati( |
9 | 87 |
array( |
88 |
'show_in_admin_all_list' => false, |
|
89 |
) |
|
90 |
); |
|
18 | 91 |
|
92 |
$this->user_posts_count = (int) $wpdb->get_var( |
|
93 |
$wpdb->prepare( |
|
94 |
"SELECT COUNT( 1 ) |
|
95 |
FROM $wpdb->posts |
|
96 |
WHERE post_type = %s |
|
97 |
AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) |
|
98 |
AND post_author = %d", |
|
99 |
$post_type, |
|
100 |
get_current_user_id() |
|
9 | 101 |
) |
102 |
); |
|
0 | 103 |
|
18 | 104 |
if ( $this->user_posts_count |
105 |
&& ! current_user_can( $post_type_object->cap->edit_others_posts ) |
|
106 |
&& empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) |
|
107 |
&& empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) |
|
108 |
) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
109 |
$_GET['author'] = get_current_user_id(); |
0 | 110 |
} |
111 |
||
16 | 112 |
$sticky_posts = get_option( 'sticky_posts' ); |
18 | 113 |
|
16 | 114 |
if ( 'post' === $post_type && $sticky_posts ) { |
18 | 115 |
$sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); |
116 |
||
117 |
$this->sticky_posts_count = (int) $wpdb->get_var( |
|
118 |
$wpdb->prepare( |
|
119 |
"SELECT COUNT( 1 ) |
|
120 |
FROM $wpdb->posts |
|
121 |
WHERE post_type = %s |
|
122 |
AND post_status NOT IN ('trash', 'auto-draft') |
|
123 |
AND ID IN ($sticky_posts)", |
|
124 |
$post_type |
|
125 |
) |
|
126 |
); |
|
0 | 127 |
} |
128 |
} |
|
129 |
||
5 | 130 |
/** |
131 |
* Sets whether the table layout should be hierarchical or not. |
|
132 |
* |
|
133 |
* @since 4.2.0 |
|
134 |
* |
|
135 |
* @param bool $display Whether the table layout should be hierarchical. |
|
136 |
*/ |
|
137 |
public function set_hierarchical_display( $display ) { |
|
138 |
$this->hierarchical_display = $display; |
|
139 |
} |
|
140 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
141 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
* @return bool |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
*/ |
5 | 144 |
public function ajax_user_can() { |
0 | 145 |
return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts ); |
146 |
} |
|
147 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
148 |
/** |
16 | 149 |
* @global string $mode List table view mode. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
150 |
* @global array $avail_post_stati |
16 | 151 |
* @global WP_Query $wp_query WordPress Query object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
152 |
* @global int $per_page |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
153 |
*/ |
5 | 154 |
public function prepare_items() { |
16 | 155 |
global $mode, $avail_post_stati, $wp_query, $per_page; |
0 | 156 |
|
16 | 157 |
if ( ! empty( $_REQUEST['mode'] ) ) { |
158 |
$mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list'; |
|
159 |
set_user_setting( 'posts_list_mode', $mode ); |
|
160 |
} else { |
|
161 |
$mode = get_user_setting( 'posts_list_mode', 'list' ); |
|
162 |
} |
|
163 |
||
164 |
// Is going to call wp(). |
|
0 | 165 |
$avail_post_stati = wp_edit_posts_query(); |
166 |
||
18 | 167 |
$this->set_hierarchical_display( |
168 |
is_post_type_hierarchical( $this->screen->post_type ) |
|
169 |
&& 'menu_order title' === $wp_query->query['orderby'] |
|
170 |
); |
|
0 | 171 |
|
172 |
$post_type = $this->screen->post_type; |
|
9 | 173 |
$per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); |
5 | 174 |
|
175 |
/** This filter is documented in wp-admin/includes/post.php */ |
|
9 | 176 |
$per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); |
0 | 177 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
178 |
if ( $this->hierarchical_display ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
179 |
$total_items = $wp_query->post_count; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
180 |
} elseif ( $wp_query->found_posts || $this->get_pagenum() === 1 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
181 |
$total_items = $wp_query->found_posts; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
182 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
183 |
$post_counts = (array) wp_count_posts( $post_type, 'readable' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
184 |
|
16 | 185 |
if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'], $avail_post_stati, true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
186 |
$total_items = $post_counts[ $_REQUEST['post_status'] ]; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
187 |
} elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
188 |
$total_items = $this->sticky_posts_count; |
18 | 189 |
} elseif ( isset( $_GET['author'] ) && get_current_user_id() === (int) $_GET['author'] ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
190 |
$total_items = $this->user_posts_count; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
191 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
192 |
$total_items = array_sum( $post_counts ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
193 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
194 |
// Subtract post types that are not included in the admin all list. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
$total_items -= $post_counts[ $state ]; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
198 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
199 |
} |
0 | 200 |
|
16 | 201 |
$this->is_trash = isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status']; |
0 | 202 |
|
9 | 203 |
$this->set_pagination_args( |
204 |
array( |
|
205 |
'total_items' => $total_items, |
|
206 |
'per_page' => $per_page, |
|
207 |
) |
|
208 |
); |
|
0 | 209 |
} |
210 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
211 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
212 |
* @return bool |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
213 |
*/ |
5 | 214 |
public function has_items() { |
0 | 215 |
return have_posts(); |
216 |
} |
|
217 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
218 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
219 |
*/ |
5 | 220 |
public function no_items() { |
9 | 221 |
if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) { |
0 | 222 |
echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; |
9 | 223 |
} else { |
0 | 224 |
echo get_post_type_object( $this->screen->post_type )->labels->not_found; |
9 | 225 |
} |
0 | 226 |
} |
227 |
||
5 | 228 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
229 |
* Determines if the current view is the "All" view. |
5 | 230 |
* |
231 |
* @since 4.2.0 |
|
232 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
233 |
* @return bool Whether the current view is the "All" view. |
5 | 234 |
*/ |
235 |
protected function is_base_request() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
236 |
$vars = $_GET; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
237 |
unset( $vars['paged'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
238 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
239 |
if ( empty( $vars ) ) { |
5 | 240 |
return true; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
241 |
} elseif ( 1 === count( $vars ) && ! empty( $vars['post_type'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
242 |
return $this->screen->post_type === $vars['post_type']; |
5 | 243 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
244 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
245 |
return 1 === count( $vars ) && ! empty( $vars['mode'] ); |
5 | 246 |
} |
247 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
248 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
249 |
* Creates a link to edit.php with params. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
250 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
251 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
252 |
* |
19 | 253 |
* @param string[] $args Associative array of URL parameters for the link. |
254 |
* @param string $link_text Link text. |
|
255 |
* @param string $css_class Optional. Class attribute. Default empty string. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
256 |
* @return string The formatted link string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
257 |
*/ |
19 | 258 |
protected function get_edit_link( $args, $link_text, $css_class = '' ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
259 |
$url = add_query_arg( $args, 'edit.php' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
260 |
|
16 | 261 |
$class_html = ''; |
262 |
$aria_current = ''; |
|
18 | 263 |
|
19 | 264 |
if ( ! empty( $css_class ) ) { |
9 | 265 |
$class_html = sprintf( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
266 |
' class="%s"', |
19 | 267 |
esc_attr( $css_class ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
268 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
269 |
|
19 | 270 |
if ( 'current' === $css_class ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
271 |
$aria_current = ' aria-current="page"'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
272 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
273 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
274 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
return sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
276 |
'<a href="%s"%s%s>%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
277 |
esc_url( $url ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
278 |
$class_html, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
279 |
$aria_current, |
19 | 280 |
$link_text |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
281 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
282 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
283 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
284 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
285 |
* @global array $locked_post_status This seems to be deprecated. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
286 |
* @global array $avail_post_stati |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
287 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
288 |
*/ |
5 | 289 |
protected function get_views() { |
0 | 290 |
global $locked_post_status, $avail_post_stati; |
291 |
||
292 |
$post_type = $this->screen->post_type; |
|
293 |
||
9 | 294 |
if ( ! empty( $locked_post_status ) ) { |
0 | 295 |
return array(); |
9 | 296 |
} |
0 | 297 |
|
298 |
$status_links = array(); |
|
9 | 299 |
$num_posts = wp_count_posts( $post_type, 'readable' ); |
300 |
$total_posts = array_sum( (array) $num_posts ); |
|
301 |
$class = ''; |
|
0 | 302 |
|
303 |
$current_user_id = get_current_user_id(); |
|
9 | 304 |
$all_args = array( 'post_type' => $post_type ); |
305 |
$mine = ''; |
|
0 | 306 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
307 |
// Subtract post types that are not included in the admin all list. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
308 |
foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
309 |
$total_posts -= $num_posts->$state; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
310 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
312 |
if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) { |
18 | 313 |
if ( isset( $_GET['author'] ) && ( $current_user_id === (int) $_GET['author'] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
314 |
$class = 'current'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
317 |
$mine_args = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
'post_type' => $post_type, |
9 | 319 |
'author' => $current_user_id, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
320 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
322 |
$mine_inner_html = sprintf( |
16 | 323 |
/* translators: %s: Number of posts. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
324 |
_nx( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
'Mine <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
326 |
'Mine <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
327 |
$this->user_posts_count, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
'posts' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
329 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
330 |
number_format_i18n( $this->user_posts_count ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
331 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
332 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
333 |
$mine = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
334 |
'url' => esc_url( add_query_arg( $mine_args, 'edit.php' ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
335 |
'label' => $mine_inner_html, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
336 |
'current' => isset( $_GET['author'] ) && ( $current_user_id === (int) $_GET['author'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
337 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
$all_args['all_posts'] = 1; |
9 | 340 |
$class = ''; |
0 | 341 |
} |
342 |
||
5 | 343 |
$all_inner_html = sprintf( |
16 | 344 |
/* translators: %s: Number of posts. */ |
5 | 345 |
_nx( |
346 |
'All <span class="count">(%s)</span>', |
|
347 |
'All <span class="count">(%s)</span>', |
|
348 |
$total_posts, |
|
349 |
'posts' |
|
350 |
), |
|
351 |
number_format_i18n( $total_posts ) |
|
352 |
); |
|
353 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
354 |
$status_links['all'] = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
355 |
'url' => esc_url( add_query_arg( $all_args, 'edit.php' ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
356 |
'label' => $all_inner_html, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
357 |
'current' => empty( $class ) && ( $this->is_base_request() || isset( $_REQUEST['all_posts'] ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
358 |
); |
18 | 359 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
360 |
if ( $mine ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
361 |
$status_links['mine'] = $mine; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
362 |
} |
0 | 363 |
|
9 | 364 |
foreach ( get_post_stati( array( 'show_in_admin_status_list' => true ), 'objects' ) as $status ) { |
0 | 365 |
$class = ''; |
366 |
||
367 |
$status_name = $status->name; |
|
368 |
||
16 | 369 |
if ( ! in_array( $status_name, $avail_post_stati, true ) || empty( $num_posts->$status_name ) ) { |
0 | 370 |
continue; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
371 |
} |
0 | 372 |
|
9 | 373 |
if ( isset( $_REQUEST['post_status'] ) && $status_name === $_REQUEST['post_status'] ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
374 |
$class = 'current'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
375 |
} |
0 | 376 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
377 |
$status_args = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
378 |
'post_status' => $status_name, |
9 | 379 |
'post_type' => $post_type, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
380 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
$status_label = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
translate_nooped_plural( $status->label_count, $num_posts->$status_name ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
number_format_i18n( $num_posts->$status_name ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
385 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
386 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
387 |
$status_links[ $status_name ] = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
388 |
'url' => esc_url( add_query_arg( $status_args, 'edit.php' ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
389 |
'label' => $status_label, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
390 |
'current' => isset( $_REQUEST['post_status'] ) && $status_name === $_REQUEST['post_status'], |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
391 |
); |
0 | 392 |
} |
393 |
||
394 |
if ( ! empty( $this->sticky_posts_count ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
395 |
$class = ! empty( $_REQUEST['show_sticky'] ) ? 'current' : ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
396 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
397 |
$sticky_args = array( |
9 | 398 |
'post_type' => $post_type, |
399 |
'show_sticky' => 1, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
400 |
); |
0 | 401 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
402 |
$sticky_inner_html = sprintf( |
16 | 403 |
/* translators: %s: Number of posts. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
404 |
_nx( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
'Sticky <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
406 |
'Sticky <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
407 |
$this->sticky_posts_count, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
408 |
'posts' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
409 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
410 |
number_format_i18n( $this->sticky_posts_count ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
411 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
412 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
413 |
$sticky_link = array( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
414 |
'sticky' => array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
415 |
'url' => esc_url( add_query_arg( $sticky_args, 'edit.php' ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
416 |
'label' => $sticky_inner_html, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
417 |
'current' => ! empty( $_REQUEST['show_sticky'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
418 |
), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
); |
0 | 420 |
|
421 |
// Sticky comes after Publish, or if not listed, after All. |
|
16 | 422 |
$split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ), true ); |
0 | 423 |
$status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) ); |
424 |
} |
|
425 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
426 |
return $this->get_views_links( $status_links ); |
0 | 427 |
} |
428 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
429 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
430 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
431 |
*/ |
5 | 432 |
protected function get_bulk_actions() { |
9 | 433 |
$actions = array(); |
5 | 434 |
$post_type_obj = get_post_type_object( $this->screen->post_type ); |
0 | 435 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
436 |
if ( current_user_can( $post_type_obj->cap->edit_posts ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
437 |
if ( $this->is_trash ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
438 |
$actions['untrash'] = __( 'Restore' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
439 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
440 |
$actions['edit'] = __( 'Edit' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
441 |
} |
5 | 442 |
} |
0 | 443 |
|
5 | 444 |
if ( current_user_can( $post_type_obj->cap->delete_posts ) ) { |
445 |
if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) { |
|
16 | 446 |
$actions['delete'] = __( 'Delete permanently' ); |
5 | 447 |
} else { |
448 |
$actions['trash'] = __( 'Move to Trash' ); |
|
449 |
} |
|
450 |
} |
|
0 | 451 |
|
452 |
return $actions; |
|
453 |
} |
|
454 |
||
5 | 455 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
456 |
* Displays a categories drop-down for filtering on the Posts list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
457 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
459 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
* @global int $cat Currently selected category. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
461 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
462 |
* @param string $post_type Post type slug. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
463 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
464 |
protected function categories_dropdown( $post_type ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
465 |
global $cat; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
466 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
467 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
468 |
* Filters whether to remove the 'Categories' drop-down from the post list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
469 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
470 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
471 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
472 |
* @param bool $disable Whether to disable the categories drop-down. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
473 |
* @param string $post_type Post type slug. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
474 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
475 |
if ( false !== apply_filters( 'disable_categories_dropdown', false, $post_type ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
476 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
477 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
478 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
479 |
if ( is_object_in_taxonomy( $post_type, 'category' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
480 |
$dropdown_options = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
481 |
'show_option_all' => get_taxonomy( 'category' )->labels->all_items, |
9 | 482 |
'hide_empty' => 0, |
483 |
'hierarchical' => 1, |
|
484 |
'show_count' => 0, |
|
485 |
'orderby' => 'name', |
|
486 |
'selected' => $cat, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
487 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
488 |
|
18 | 489 |
echo '<label class="screen-reader-text" for="cat">' . get_taxonomy( 'category' )->labels->filter_by_item . '</label>'; |
490 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
491 |
wp_dropdown_categories( $dropdown_options ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
492 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
493 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
494 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
495 |
/** |
9 | 496 |
* Displays a formats drop-down for filtering items. |
497 |
* |
|
498 |
* @since 5.2.0 |
|
499 |
* @access protected |
|
500 |
* |
|
16 | 501 |
* @param string $post_type Post type slug. |
9 | 502 |
*/ |
503 |
protected function formats_dropdown( $post_type ) { |
|
504 |
/** |
|
505 |
* Filters whether to remove the 'Formats' drop-down from the post list table. |
|
506 |
* |
|
507 |
* @since 5.2.0 |
|
16 | 508 |
* @since 5.5.0 The `$post_type` parameter was added. |
9 | 509 |
* |
16 | 510 |
* @param bool $disable Whether to disable the drop-down. Default false. |
511 |
* @param string $post_type Post type slug. |
|
9 | 512 |
*/ |
16 | 513 |
if ( apply_filters( 'disable_formats_dropdown', false, $post_type ) ) { |
514 |
return; |
|
515 |
} |
|
516 |
||
517 |
// Return if the post type doesn't have post formats or if we're in the Trash. |
|
518 |
if ( ! is_object_in_taxonomy( $post_type, 'post_format' ) || $this->is_trash ) { |
|
9 | 519 |
return; |
520 |
} |
|
521 |
||
522 |
// Make sure the dropdown shows only formats with a post count greater than 0. |
|
523 |
$used_post_formats = get_terms( |
|
524 |
array( |
|
525 |
'taxonomy' => 'post_format', |
|
526 |
'hide_empty' => true, |
|
527 |
) |
|
528 |
); |
|
529 |
||
16 | 530 |
// Return if there are no posts using formats. |
531 |
if ( ! $used_post_formats ) { |
|
9 | 532 |
return; |
533 |
} |
|
534 |
||
535 |
$displayed_post_format = isset( $_GET['post_format'] ) ? $_GET['post_format'] : ''; |
|
536 |
?> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
537 |
<label for="filter-by-format" class="screen-reader-text"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
538 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
539 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
540 |
_e( 'Filter by post format' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
541 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
542 |
</label> |
9 | 543 |
<select name="post_format" id="filter-by-format"> |
544 |
<option<?php selected( $displayed_post_format, '' ); ?> value=""><?php _e( 'All formats' ); ?></option> |
|
545 |
<?php |
|
546 |
foreach ( $used_post_formats as $used_post_format ) { |
|
547 |
// Post format slug. |
|
548 |
$slug = str_replace( 'post-format-', '', $used_post_format->slug ); |
|
549 |
// Pretty, translated version of the post format slug. |
|
550 |
$pretty_name = get_post_format_string( $slug ); |
|
18 | 551 |
|
9 | 552 |
// Skip the standard post format. |
553 |
if ( 'standard' === $slug ) { |
|
554 |
continue; |
|
555 |
} |
|
556 |
?> |
|
557 |
<option<?php selected( $displayed_post_format, $slug ); ?> value="<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $pretty_name ); ?></option> |
|
558 |
<?php |
|
559 |
} |
|
560 |
?> |
|
561 |
</select> |
|
562 |
<?php |
|
563 |
} |
|
564 |
||
565 |
/** |
|
5 | 566 |
* @param string $which |
567 |
*/ |
|
568 |
protected function extra_tablenav( $which ) { |
|
9 | 569 |
?> |
0 | 570 |
<div class="alignleft actions"> |
9 | 571 |
<?php |
16 | 572 |
if ( 'top' === $which ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
573 |
ob_start(); |
0 | 574 |
|
575 |
$this->months_dropdown( $this->screen->post_type ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
576 |
$this->categories_dropdown( $this->screen->post_type ); |
9 | 577 |
$this->formats_dropdown( $this->screen->post_type ); |
5 | 578 |
|
579 |
/** |
|
580 |
* Fires before the Filter button on the Posts and Pages list tables. |
|
581 |
* |
|
582 |
* The Filter button allows sorting by date and/or category on the |
|
583 |
* Posts list table, and sorting by date on the Pages list table. |
|
584 |
* |
|
585 |
* @since 2.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
586 |
* @since 4.4.0 The `$post_type` parameter was added. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
587 |
* @since 4.6.0 The `$which` parameter was added. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
588 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
589 |
* @param string $post_type The post type slug. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
590 |
* @param string $which The location of the extra table nav markup: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
591 |
* 'top' or 'bottom' for WP_Posts_List_Table, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
592 |
* 'bar' for WP_Media_List_Table. |
5 | 593 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
594 |
do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
595 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
596 |
$output = ob_get_clean(); |
5 | 597 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
598 |
if ( ! empty( $output ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
599 |
echo $output; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
600 |
submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
601 |
} |
0 | 602 |
} |
603 |
||
18 | 604 |
if ( $this->is_trash && $this->has_items() |
605 |
&& current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) |
|
606 |
) { |
|
0 | 607 |
submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
608 |
} |
|
9 | 609 |
?> |
0 | 610 |
</div> |
9 | 611 |
<?php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
612 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
613 |
* Fires immediately following the closing "actions" div in the tablenav for the posts |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
* list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
615 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
616 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
617 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
618 |
* @param string $which The location of the extra table nav markup: 'top' or 'bottom'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
619 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
620 |
do_action( 'manage_posts_extra_tablenav', $which ); |
0 | 621 |
} |
622 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
623 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
624 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
625 |
*/ |
5 | 626 |
public function current_action() { |
9 | 627 |
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) { |
0 | 628 |
return 'delete_all'; |
9 | 629 |
} |
0 | 630 |
|
631 |
return parent::current_action(); |
|
632 |
} |
|
633 |
||
5 | 634 |
/** |
16 | 635 |
* @global string $mode List table view mode. |
636 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
637 |
* @return array |
5 | 638 |
*/ |
639 |
protected function get_table_classes() { |
|
16 | 640 |
global $mode; |
641 |
||
642 |
$mode_class = esc_attr( 'table-view-' . $mode ); |
|
643 |
||
18 | 644 |
return array( |
645 |
'widefat', |
|
646 |
'fixed', |
|
647 |
'striped', |
|
648 |
$mode_class, |
|
649 |
is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts', |
|
650 |
); |
|
0 | 651 |
} |
652 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
653 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
654 |
* @return string[] Array of column titles keyed by their column name. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
655 |
*/ |
5 | 656 |
public function get_columns() { |
0 | 657 |
$post_type = $this->screen->post_type; |
658 |
||
659 |
$posts_columns = array(); |
|
660 |
||
661 |
$posts_columns['cb'] = '<input type="checkbox" />'; |
|
662 |
||
16 | 663 |
/* translators: Posts screen column name. */ |
0 | 664 |
$posts_columns['title'] = _x( 'Title', 'column name' ); |
665 |
||
5 | 666 |
if ( post_type_supports( $post_type, 'author' ) ) { |
0 | 667 |
$posts_columns['author'] = __( 'Author' ); |
5 | 668 |
} |
0 | 669 |
|
670 |
$taxonomies = get_object_taxonomies( $post_type, 'objects' ); |
|
671 |
$taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); |
|
672 |
||
5 | 673 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
674 |
* Filters the taxonomy columns in the Posts list table. |
5 | 675 |
* |
676 |
* The dynamic portion of the hook name, `$post_type`, refers to the post |
|
677 |
* type slug. |
|
678 |
* |
|
18 | 679 |
* Possible hook names include: |
680 |
* |
|
681 |
* - `manage_taxonomies_for_post_columns` |
|
682 |
* - `manage_taxonomies_for_page_columns` |
|
683 |
* |
|
5 | 684 |
* @since 3.5.0 |
685 |
* |
|
9 | 686 |
* @param string[] $taxonomies Array of taxonomy names to show columns for. |
687 |
* @param string $post_type The post type. |
|
5 | 688 |
*/ |
0 | 689 |
$taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type ); |
690 |
$taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
|
691 |
||
692 |
foreach ( $taxonomies as $taxonomy ) { |
|
9 | 693 |
if ( 'category' === $taxonomy ) { |
0 | 694 |
$column_key = 'categories'; |
9 | 695 |
} elseif ( 'post_tag' === $taxonomy ) { |
0 | 696 |
$column_key = 'tags'; |
9 | 697 |
} else { |
0 | 698 |
$column_key = 'taxonomy-' . $taxonomy; |
9 | 699 |
} |
0 | 700 |
|
701 |
$posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
|
702 |
} |
|
703 |
||
9 | 704 |
$post_status = ! empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; |
18 | 705 |
|
706 |
if ( post_type_supports( $post_type, 'comments' ) |
|
707 |
&& ! in_array( $post_status, array( 'pending', 'draft', 'future' ), true ) |
|
708 |
) { |
|
709 |
$posts_columns['comments'] = sprintf( |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
710 |
'<span class="vers comment-grey-bubble" title="%1$s" aria-hidden="true"></span><span class="screen-reader-text">%2$s</span>', |
18 | 711 |
esc_attr__( 'Comments' ), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
712 |
/* translators: Hidden accessibility text. */ |
18 | 713 |
__( 'Comments' ) |
714 |
); |
|
9 | 715 |
} |
0 | 716 |
|
717 |
$posts_columns['date'] = __( 'Date' ); |
|
718 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
719 |
if ( 'page' === $post_type ) { |
5 | 720 |
|
721 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
722 |
* Filters the columns displayed in the Pages list table. |
5 | 723 |
* |
724 |
* @since 2.5.0 |
|
725 |
* |
|
9 | 726 |
* @param string[] $post_columns An associative array of column headings. |
5 | 727 |
*/ |
0 | 728 |
$posts_columns = apply_filters( 'manage_pages_columns', $posts_columns ); |
5 | 729 |
} else { |
730 |
||
731 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
732 |
* Filters the columns displayed in the Posts list table. |
5 | 733 |
* |
734 |
* @since 1.5.0 |
|
735 |
* |
|
9 | 736 |
* @param string[] $post_columns An associative array of column headings. |
737 |
* @param string $post_type The post type slug. |
|
5 | 738 |
*/ |
0 | 739 |
$posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type ); |
5 | 740 |
} |
741 |
||
742 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
743 |
* Filters the columns displayed in the Posts list table for a specific post type. |
5 | 744 |
* |
745 |
* The dynamic portion of the hook name, `$post_type`, refers to the post type slug. |
|
746 |
* |
|
18 | 747 |
* Possible hook names include: |
748 |
* |
|
749 |
* - `manage_post_posts_columns` |
|
750 |
* - `manage_page_posts_columns` |
|
751 |
* |
|
5 | 752 |
* @since 3.0.0 |
753 |
* |
|
9 | 754 |
* @param string[] $post_columns An associative array of column headings. |
5 | 755 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
756 |
return apply_filters( "manage_{$post_type}_posts_columns", $posts_columns ); |
0 | 757 |
} |
758 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
759 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
760 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
761 |
*/ |
5 | 762 |
protected function get_sortable_columns() { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
763 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
764 |
$post_type = $this->screen->post_type; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
765 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
766 |
if ( 'page' === $post_type ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
767 |
if ( isset( $_GET['orderby'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
768 |
$title_orderby_text = __( 'Table ordered by Title.' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
769 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
770 |
$title_orderby_text = __( 'Table ordered by Hierarchical Menu Order and Title.' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
771 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
772 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
773 |
$sortables = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
774 |
'title' => array( 'title', false, __( 'Title' ), $title_orderby_text, 'asc' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
775 |
'parent' => array( 'parent', false ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
776 |
'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
777 |
'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
778 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
779 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
780 |
$sortables = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
781 |
'title' => array( 'title', false, __( 'Title' ), __( 'Table ordered by Title.' ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
782 |
'parent' => array( 'parent', false ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
783 |
'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
784 |
'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ), 'desc' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
785 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
786 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
787 |
// Custom Post Types: there's a filter for that, see get_column_info(). |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
788 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
789 |
return $sortables; |
0 | 790 |
} |
791 |
||
5 | 792 |
/** |
16 | 793 |
* @global WP_Query $wp_query WordPress Query object. |
5 | 794 |
* @global int $per_page |
795 |
* @param array $posts |
|
16 | 796 |
* @param int $level |
5 | 797 |
*/ |
798 |
public function display_rows( $posts = array(), $level = 0 ) { |
|
0 | 799 |
global $wp_query, $per_page; |
800 |
||
9 | 801 |
if ( empty( $posts ) ) { |
0 | 802 |
$posts = $wp_query->posts; |
9 | 803 |
} |
0 | 804 |
|
805 |
add_filter( 'the_title', 'esc_html' ); |
|
806 |
||
807 |
if ( $this->hierarchical_display ) { |
|
808 |
$this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page ); |
|
809 |
} else { |
|
810 |
$this->_display_rows( $posts, $level ); |
|
811 |
} |
|
812 |
} |
|
813 |
||
5 | 814 |
/** |
815 |
* @param array $posts |
|
16 | 816 |
* @param int $level |
5 | 817 |
*/ |
818 |
private function _display_rows( $posts, $level = 0 ) { |
|
9 | 819 |
$post_type = $this->screen->post_type; |
820 |
||
0 | 821 |
// Create array of post IDs. |
822 |
$post_ids = array(); |
|
823 |
||
9 | 824 |
foreach ( $posts as $a_post ) { |
0 | 825 |
$post_ids[] = $a_post->ID; |
9 | 826 |
} |
0 | 827 |
|
9 | 828 |
if ( post_type_supports( $post_type, 'comments' ) ) { |
829 |
$this->comment_pending_count = get_pending_comments_num( $post_ids ); |
|
830 |
} |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
831 |
update_post_author_caches( $posts ); |
0 | 832 |
|
9 | 833 |
foreach ( $posts as $post ) { |
0 | 834 |
$this->single_row( $post, $level ); |
9 | 835 |
} |
0 | 836 |
} |
837 |
||
5 | 838 |
/** |
16 | 839 |
* @global wpdb $wpdb WordPress database abstraction object. |
840 |
* @global WP_Post $post Global post object. |
|
5 | 841 |
* @param array $pages |
16 | 842 |
* @param int $pagenum |
843 |
* @param int $per_page |
|
5 | 844 |
*/ |
845 |
private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) { |
|
0 | 846 |
global $wpdb; |
847 |
||
848 |
$level = 0; |
|
849 |
||
850 |
if ( ! $pages ) { |
|
851 |
$pages = get_pages( array( 'sort_column' => 'menu_order' ) ); |
|
852 |
||
9 | 853 |
if ( ! $pages ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
854 |
return; |
9 | 855 |
} |
0 | 856 |
} |
857 |
||
858 |
/* |
|
19 | 859 |
* Arrange pages into two parts: top level pages and children_pages. |
860 |
* children_pages is two dimensional array. Example: |
|
0 | 861 |
* children_pages[10][] contains all sub-pages whose parent is 10. |
862 |
* It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations |
|
863 |
* If searching, ignore hierarchy and treat everything as top level |
|
864 |
*/ |
|
865 |
if ( empty( $_REQUEST['s'] ) ) { |
|
866 |
$top_level_pages = array(); |
|
9 | 867 |
$children_pages = array(); |
0 | 868 |
|
869 |
foreach ( $pages as $page ) { |
|
5 | 870 |
// Catch and repair bad pages. |
18 | 871 |
if ( $page->post_parent === $page->ID ) { |
0 | 872 |
$page->post_parent = 0; |
873 |
$wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) ); |
|
874 |
clean_post_cache( $page ); |
|
875 |
} |
|
876 |
||
18 | 877 |
if ( $page->post_parent > 0 ) { |
878 |
$children_pages[ $page->post_parent ][] = $page; |
|
879 |
} else { |
|
0 | 880 |
$top_level_pages[] = $page; |
9 | 881 |
} |
0 | 882 |
} |
883 |
||
884 |
$pages = &$top_level_pages; |
|
885 |
} |
|
886 |
||
9 | 887 |
$count = 0; |
888 |
$start = ( $pagenum - 1 ) * $per_page; |
|
889 |
$end = $start + $per_page; |
|
5 | 890 |
$to_display = array(); |
0 | 891 |
|
892 |
foreach ( $pages as $page ) { |
|
9 | 893 |
if ( $count >= $end ) { |
0 | 894 |
break; |
9 | 895 |
} |
0 | 896 |
|
897 |
if ( $count >= $start ) { |
|
9 | 898 |
$to_display[ $page->ID ] = $level; |
0 | 899 |
} |
900 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
901 |
++$count; |
0 | 902 |
|
9 | 903 |
if ( isset( $children_pages ) ) { |
5 | 904 |
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
9 | 905 |
} |
0 | 906 |
} |
907 |
||
5 | 908 |
// If it is the last pagenum and there are orphaned pages, display them with paging as well. |
9 | 909 |
if ( isset( $children_pages ) && $count < $end ) { |
910 |
foreach ( $children_pages as $orphans ) { |
|
0 | 911 |
foreach ( $orphans as $op ) { |
9 | 912 |
if ( $count >= $end ) { |
0 | 913 |
break; |
9 | 914 |
} |
0 | 915 |
|
916 |
if ( $count >= $start ) { |
|
9 | 917 |
$to_display[ $op->ID ] = 0; |
0 | 918 |
} |
919 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
920 |
++$count; |
0 | 921 |
} |
922 |
} |
|
923 |
} |
|
5 | 924 |
|
925 |
$ids = array_keys( $to_display ); |
|
926 |
_prime_post_caches( $ids ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
927 |
$_posts = array_map( 'get_post', $ids ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
928 |
update_post_author_caches( $_posts ); |
5 | 929 |
|
930 |
if ( ! isset( $GLOBALS['post'] ) ) { |
|
931 |
$GLOBALS['post'] = reset( $ids ); |
|
932 |
} |
|
933 |
||
934 |
foreach ( $to_display as $page_id => $level ) { |
|
935 |
echo "\t"; |
|
936 |
$this->single_row( $page_id, $level ); |
|
937 |
} |
|
0 | 938 |
} |
939 |
||
940 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
941 |
* Displays the nested hierarchy of sub-pages together with paging |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
942 |
* support, based on a top level page ID. |
0 | 943 |
* |
944 |
* @since 3.1.0 (Standalone function exists since 2.6.0) |
|
5 | 945 |
* @since 4.2.0 Added the `$to_display` parameter. |
0 | 946 |
* |
947 |
* @param array $children_pages |
|
16 | 948 |
* @param int $count |
19 | 949 |
* @param int $parent_page |
16 | 950 |
* @param int $level |
951 |
* @param int $pagenum |
|
952 |
* @param int $per_page |
|
5 | 953 |
* @param array $to_display List of pages to be displayed. Passed by reference. |
0 | 954 |
*/ |
19 | 955 |
private function _page_rows( &$children_pages, &$count, $parent_page, $level, $pagenum, $per_page, &$to_display ) { |
956 |
if ( ! isset( $children_pages[ $parent_page ] ) ) { |
|
0 | 957 |
return; |
9 | 958 |
} |
0 | 959 |
|
960 |
$start = ( $pagenum - 1 ) * $per_page; |
|
9 | 961 |
$end = $start + $per_page; |
0 | 962 |
|
19 | 963 |
foreach ( $children_pages[ $parent_page ] as $page ) { |
9 | 964 |
if ( $count >= $end ) { |
0 | 965 |
break; |
9 | 966 |
} |
0 | 967 |
|
968 |
// If the page starts in a subtree, print the parents. |
|
18 | 969 |
if ( $count === $start && $page->post_parent > 0 ) { |
0 | 970 |
$my_parents = array(); |
9 | 971 |
$my_parent = $page->post_parent; |
18 | 972 |
|
0 | 973 |
while ( $my_parent ) { |
16 | 974 |
// Get the ID from the list or the attribute if my_parent is an object. |
5 | 975 |
$parent_id = $my_parent; |
18 | 976 |
|
5 | 977 |
if ( is_object( $my_parent ) ) { |
978 |
$parent_id = $my_parent->ID; |
|
979 |
} |
|
980 |
||
9 | 981 |
$my_parent = get_post( $parent_id ); |
0 | 982 |
$my_parents[] = $my_parent; |
18 | 983 |
|
9 | 984 |
if ( ! $my_parent->post_parent ) { |
0 | 985 |
break; |
9 | 986 |
} |
18 | 987 |
|
0 | 988 |
$my_parent = $my_parent->post_parent; |
989 |
} |
|
18 | 990 |
|
0 | 991 |
$num_parents = count( $my_parents ); |
18 | 992 |
|
0 | 993 |
while ( $my_parent = array_pop( $my_parents ) ) { |
9 | 994 |
$to_display[ $my_parent->ID ] = $level - $num_parents; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
995 |
--$num_parents; |
0 | 996 |
} |
997 |
} |
|
998 |
||
999 |
if ( $count >= $start ) { |
|
9 | 1000 |
$to_display[ $page->ID ] = $level; |
0 | 1001 |
} |
1002 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1003 |
++$count; |
0 | 1004 |
|
5 | 1005 |
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
0 | 1006 |
} |
1007 |
||
19 | 1008 |
unset( $children_pages[ $parent_page ] ); // Required in order to keep track of orphans. |
0 | 1009 |
} |
1010 |
||
5 | 1011 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1012 |
* Handles the checkbox column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1013 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1014 |
* @since 4.3.0 |
19 | 1015 |
* @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1016 |
* |
19 | 1017 |
* @param WP_Post $item The current WP_Post object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1018 |
*/ |
19 | 1019 |
public function column_cb( $item ) { |
1020 |
// Restores the more descriptive, specific name for use within this method. |
|
1021 |
$post = $item; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1022 |
|
18 | 1023 |
$show = current_user_can( 'edit_post', $post->ID ); |
1024 |
||
1025 |
/** |
|
1026 |
* Filters whether to show the bulk edit checkbox for a post in its list table. |
|
1027 |
* |
|
1028 |
* By default the checkbox is only shown if the current user can edit the post. |
|
1029 |
* |
|
1030 |
* @since 5.7.0 |
|
1031 |
* |
|
1032 |
* @param bool $show Whether to show the checkbox. |
|
1033 |
* @param WP_Post $post The current WP_Post object. |
|
1034 |
*/ |
|
1035 |
if ( apply_filters( 'wp_list_table_show_post_checkbox', $show, $post ) ) : |
|
9 | 1036 |
?> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1037 |
<input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" /> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1038 |
<label for="cb-select-<?php the_ID(); ?>"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1039 |
<span class="screen-reader-text"> |
16 | 1040 |
<?php |
1041 |
/* translators: %s: Post title. */ |
|
1042 |
printf( __( 'Select %s' ), _draft_or_post_title() ); |
|
1043 |
?> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1044 |
</span> |
9 | 1045 |
</label> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1046 |
<div class="locked-indicator"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1047 |
<span class="locked-indicator-icon" aria-hidden="true"></span> |
9 | 1048 |
<span class="screen-reader-text"> |
1049 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1050 |
printf( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1051 |
/* translators: Hidden accessibility text. %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1052 |
__( '“%s” is locked' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1053 |
_draft_or_post_title() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1054 |
); |
9 | 1055 |
?> |
1056 |
</span> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1057 |
</div> |
9 | 1058 |
<?php |
1059 |
endif; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1060 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1061 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1062 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1063 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1064 |
* |
5 | 1065 |
* @param WP_Post $post |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1066 |
* @param string $classes |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1067 |
* @param string $data |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1068 |
* @param string $primary |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1069 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1070 |
protected function _column_title( $post, $classes, $data, $primary ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1071 |
echo '<td class="' . $classes . ' page-title" ', $data, '>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1072 |
echo $this->column_title( $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1073 |
echo $this->handle_row_actions( $post, 'title', $primary ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1074 |
echo '</td>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1075 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1076 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1077 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1078 |
* Handles the title column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1079 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1080 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1081 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1082 |
* @global string $mode List table view mode. |
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 |
* @param WP_Post $post The current WP_Post object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1085 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1086 |
public function column_title( $post ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1087 |
global $mode; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1088 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1089 |
if ( $this->hierarchical_display ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1090 |
if ( 0 === $this->current_level && (int) $post->post_parent > 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1091 |
// Sent level 0 by accident, by default, or because we don't know the actual level. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1092 |
$find_main_page = (int) $post->post_parent; |
18 | 1093 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1094 |
while ( $find_main_page > 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1095 |
$parent = get_post( $find_main_page ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1096 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1097 |
if ( is_null( $parent ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1098 |
break; |
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 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1101 |
++$this->current_level; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1102 |
$find_main_page = (int) $parent->post_parent; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1103 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1104 |
if ( ! isset( $parent_name ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1105 |
/** This filter is documented in wp-includes/post-template.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1106 |
$parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1107 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1108 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1109 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1110 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1111 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1112 |
$can_edit_post = current_user_can( 'edit_post', $post->ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1113 |
|
16 | 1114 |
if ( $can_edit_post && 'trash' !== $post->post_status ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1115 |
$lock_holder = wp_check_post_lock( $post->ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1116 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1117 |
if ( $lock_holder ) { |
9 | 1118 |
$lock_holder = get_userdata( $lock_holder ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1119 |
$locked_avatar = get_avatar( $lock_holder->ID, 18 ); |
16 | 1120 |
/* translators: %s: User's display name. */ |
1121 |
$locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1122 |
} else { |
16 | 1123 |
$locked_avatar = ''; |
1124 |
$locked_text = ''; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1125 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1126 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1127 |
echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1128 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1129 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1130 |
$pad = str_repeat( '— ', $this->current_level ); |
9 | 1131 |
echo '<strong>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1132 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1133 |
$title = _draft_or_post_title(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1134 |
|
16 | 1135 |
if ( $can_edit_post && 'trash' !== $post->post_status ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1136 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1137 |
'<a class="row-title" href="%s" aria-label="%s">%s%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1138 |
get_edit_post_link( $post->ID ), |
16 | 1139 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1140 |
esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1141 |
$pad, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1142 |
$title |
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 |
} else { |
9 | 1145 |
printf( |
1146 |
'<span>%s%s</span>', |
|
1147 |
$pad, |
|
1148 |
$title |
|
1149 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1150 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1151 |
_post_states( $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1152 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1153 |
if ( isset( $parent_name ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1154 |
$post_type_object = get_post_type_object( $post->post_type ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1155 |
echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1156 |
} |
18 | 1157 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1158 |
echo "</strong>\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1159 |
|
16 | 1160 |
if ( 'excerpt' === $mode |
1161 |
&& ! is_post_type_hierarchical( $this->screen->post_type ) |
|
1162 |
&& current_user_can( 'read_post', $post->ID ) |
|
1163 |
) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1164 |
if ( post_password_required( $post ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1165 |
echo '<span class="protected-post-excerpt">' . esc_html( get_the_excerpt() ) . '</span>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1166 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1167 |
echo esc_html( get_the_excerpt() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1168 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1169 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1170 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1171 |
/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1172 |
$quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_post_type', true, $post->post_type ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1173 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1174 |
if ( $quick_edit_enabled ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1175 |
get_inline_data( $post ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1176 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1177 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1178 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1179 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1180 |
* Handles the post date column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1181 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1182 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1183 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1184 |
* @global string $mode List table view mode. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1185 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1186 |
* @param WP_Post $post The current WP_Post object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1187 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1188 |
public function column_date( $post ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1189 |
global $mode; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1190 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1191 |
if ( '0000-00-00 00:00:00' === $post->post_date ) { |
16 | 1192 |
$t_time = __( 'Unpublished' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1193 |
$time_diff = 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1194 |
} else { |
16 | 1195 |
$t_time = sprintf( |
1196 |
/* translators: 1: Post date, 2: Post time. */ |
|
1197 |
__( '%1$s at %2$s' ), |
|
18 | 1198 |
/* translators: Post date format. See https://www.php.net/manual/datetime.format.php */ |
16 | 1199 |
get_the_time( __( 'Y/m/d' ), $post ), |
18 | 1200 |
/* translators: Post time format. See https://www.php.net/manual/datetime.format.php */ |
16 | 1201 |
get_the_time( __( 'g:i a' ), $post ) |
1202 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1203 |
|
16 | 1204 |
$time = get_post_timestamp( $post ); |
1205 |
$time_diff = time() - $time; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1206 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1207 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1208 |
if ( 'publish' === $post->post_status ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1209 |
$status = __( 'Published' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1210 |
} elseif ( 'future' === $post->post_status ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1211 |
if ( $time_diff > 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1212 |
$status = '<strong class="error-message">' . __( 'Missed schedule' ) . '</strong>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1213 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1214 |
$status = __( 'Scheduled' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1215 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1216 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1217 |
$status = __( 'Last Modified' ); |
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 |
|
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 |
* Filters the status text of the post. |
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 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1224 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1225 |
* @param string $status The status text. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1226 |
* @param WP_Post $post Post object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1227 |
* @param string $column_name The column name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1228 |
* @param string $mode The list display mode ('excerpt' or 'list'). |
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 |
$status = apply_filters( 'post_date_column_status', $status, $post, 'date', $mode ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1231 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1232 |
if ( $status ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1233 |
echo $status . '<br />'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1234 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1235 |
|
16 | 1236 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1237 |
* Filters the published, scheduled, or unpublished time of the post. |
16 | 1238 |
* |
1239 |
* @since 2.5.1 |
|
1240 |
* @since 5.5.0 Removed the difference between 'excerpt' and 'list' modes. |
|
1241 |
* The published time and date are both displayed now, |
|
1242 |
* which is equivalent to the previous 'excerpt' mode. |
|
1243 |
* |
|
1244 |
* @param string $t_time The published time. |
|
1245 |
* @param WP_Post $post Post object. |
|
1246 |
* @param string $column_name The column name. |
|
1247 |
* @param string $mode The list display mode ('excerpt' or 'list'). |
|
1248 |
*/ |
|
1249 |
echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1250 |
} |
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 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1253 |
* Handles the comments column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1254 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1255 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1256 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1257 |
* @param WP_Post $post The current WP_Post object. |
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 |
public function column_comments( $post ) { |
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 |
<div class="post-com-count-wrapper"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1262 |
<?php |
9 | 1263 |
$pending_comments = isset( $this->comment_pending_count[ $post->ID ] ) ? $this->comment_pending_count[ $post->ID ] : 0; |
7
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 |
$this->comments_bubble( $post->ID, $pending_comments ); |
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 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1268 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1269 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1270 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1271 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1272 |
* Handles the post author column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1273 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1274 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1275 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1276 |
* @param WP_Post $post The current WP_Post object. |
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 |
public function column_author( $post ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1279 |
$args = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1280 |
'post_type' => $post->post_type, |
9 | 1281 |
'author' => get_the_author_meta( 'ID' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1282 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1283 |
echo $this->get_edit_link( $args, get_the_author() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1284 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1285 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1286 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1287 |
* Handles the default column output. |
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 |
* @since 4.3.0 |
19 | 1290 |
* @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1291 |
* |
19 | 1292 |
* @param WP_Post $item The current WP_Post object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1293 |
* @param string $column_name The current column name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1294 |
*/ |
19 | 1295 |
public function column_default( $item, $column_name ) { |
1296 |
// Restores the more descriptive, specific name for use within this method. |
|
1297 |
$post = $item; |
|
1298 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1299 |
if ( 'categories' === $column_name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1300 |
$taxonomy = 'category'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1301 |
} elseif ( 'tags' === $column_name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1302 |
$taxonomy = 'post_tag'; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1303 |
} elseif ( str_starts_with( $column_name, 'taxonomy-' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1304 |
$taxonomy = substr( $column_name, 9 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1305 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1306 |
$taxonomy = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1307 |
} |
18 | 1308 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1309 |
if ( $taxonomy ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1310 |
$taxonomy_object = get_taxonomy( $taxonomy ); |
9 | 1311 |
$terms = get_the_terms( $post->ID, $taxonomy ); |
18 | 1312 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1313 |
if ( is_array( $terms ) ) { |
9 | 1314 |
$term_links = array(); |
18 | 1315 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1316 |
foreach ( $terms as $t ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1317 |
$posts_in_term_qv = array(); |
18 | 1318 |
|
16 | 1319 |
if ( 'post' !== $post->post_type ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1320 |
$posts_in_term_qv['post_type'] = $post->post_type; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1321 |
} |
18 | 1322 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1323 |
if ( $taxonomy_object->query_var ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1324 |
$posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1325 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1326 |
$posts_in_term_qv['taxonomy'] = $taxonomy; |
9 | 1327 |
$posts_in_term_qv['term'] = $t->slug; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1328 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1329 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1330 |
$label = esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ); |
9 | 1331 |
|
1332 |
$term_links[] = $this->get_edit_link( $posts_in_term_qv, $label ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1333 |
} |
9 | 1334 |
|
1335 |
/** |
|
1336 |
* Filters the links in `$taxonomy` column of edit.php. |
|
1337 |
* |
|
1338 |
* @since 5.2.0 |
|
1339 |
* |
|
16 | 1340 |
* @param string[] $term_links Array of term editing links. |
1341 |
* @param string $taxonomy Taxonomy name. |
|
1342 |
* @param WP_Term[] $terms Array of term objects appearing in the post row. |
|
9 | 1343 |
*/ |
1344 |
$term_links = apply_filters( 'post_column_taxonomy_links', $term_links, $taxonomy, $terms ); |
|
1345 |
||
19 | 1346 |
echo implode( wp_get_list_item_separator(), $term_links ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1347 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1348 |
echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1349 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1350 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1351 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1352 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1353 |
if ( is_post_type_hierarchical( $post->post_type ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1354 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1355 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1356 |
* Fires in each custom column on the Posts list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1357 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1358 |
* This hook only fires if the current post type is hierarchical, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1359 |
* such as pages. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1360 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1361 |
* @since 2.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1362 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1363 |
* @param string $column_name The name of the column to display. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1364 |
* @param int $post_id The current post ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1365 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1366 |
do_action( 'manage_pages_custom_column', $column_name, $post->ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1367 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1368 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1369 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1370 |
* Fires in each custom column in the Posts list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1371 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1372 |
* This hook only fires if the current post type is non-hierarchical, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1373 |
* such as posts. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1374 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1375 |
* @since 1.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1376 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1377 |
* @param string $column_name The name of the column to display. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1378 |
* @param int $post_id The current post ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1379 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1380 |
do_action( 'manage_posts_custom_column', $column_name, $post->ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1381 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1382 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1383 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1384 |
* Fires for each custom column of a specific post type in the Posts list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1385 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1386 |
* The dynamic portion of the hook name, `$post->post_type`, refers to the post type. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1387 |
* |
18 | 1388 |
* Possible hook names include: |
1389 |
* |
|
1390 |
* - `manage_post_posts_custom_column` |
|
1391 |
* - `manage_page_posts_custom_column` |
|
1392 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1393 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1394 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1395 |
* @param string $column_name The name of the column to display. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1396 |
* @param int $post_id The current post ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1397 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1398 |
do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1399 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1400 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1401 |
/** |
16 | 1402 |
* @global WP_Post $post Global post object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1403 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1404 |
* @param int|WP_Post $post |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1405 |
* @param int $level |
5 | 1406 |
*/ |
1407 |
public function single_row( $post, $level = 0 ) { |
|
0 | 1408 |
$global_post = get_post(); |
5 | 1409 |
|
9 | 1410 |
$post = get_post( $post ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1411 |
$this->current_level = $level; |
5 | 1412 |
|
0 | 1413 |
$GLOBALS['post'] = $post; |
1414 |
setup_postdata( $post ); |
|
1415 |
||
18 | 1416 |
$classes = 'iedit author-' . ( get_current_user_id() === (int) $post->post_author ? 'self' : 'other' ); |
0 | 1417 |
|
1418 |
$lock_holder = wp_check_post_lock( $post->ID ); |
|
18 | 1419 |
|
0 | 1420 |
if ( $lock_holder ) { |
1421 |
$classes .= ' wp-locked'; |
|
1422 |
} |
|
5 | 1423 |
|
1424 |
if ( $post->post_parent ) { |
|
9 | 1425 |
$count = count( get_post_ancestors( $post->ID ) ); |
1426 |
$classes .= ' level-' . $count; |
|
5 | 1427 |
} else { |
9 | 1428 |
$classes .= ' level-0'; |
5 | 1429 |
} |
9 | 1430 |
?> |
5 | 1431 |
<tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1432 |
<?php $this->single_row_columns( $post ); ?> |
0 | 1433 |
</tr> |
9 | 1434 |
<?php |
0 | 1435 |
$GLOBALS['post'] = $global_post; |
1436 |
} |
|
1437 |
||
1438 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1439 |
* Gets the name of the default primary column. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1440 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1441 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1442 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1443 |
* @return string Name of the default primary column, in this case, 'title'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1444 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1445 |
protected function get_default_primary_column_name() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1446 |
return 'title'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1447 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1448 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1449 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1450 |
* Generates and displays row action links. |
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 |
* @since 4.3.0 |
19 | 1453 |
* @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1454 |
* |
19 | 1455 |
* @param WP_Post $item Post being acted upon. |
18 | 1456 |
* @param string $column_name Current column name. |
1457 |
* @param string $primary Primary column name. |
|
16 | 1458 |
* @return string Row actions output for posts, or an empty string |
1459 |
* 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
|
1460 |
*/ |
19 | 1461 |
protected function handle_row_actions( $item, $column_name, $primary ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1462 |
if ( $primary !== $column_name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1463 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1464 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1465 |
|
19 | 1466 |
// Restores the more descriptive, specific name for use within this method. |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1467 |
$post = $item; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1468 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1469 |
$post_type_object = get_post_type_object( $post->post_type ); |
9 | 1470 |
$can_edit_post = current_user_can( 'edit_post', $post->ID ); |
1471 |
$actions = array(); |
|
1472 |
$title = _draft_or_post_title(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1473 |
|
16 | 1474 |
if ( $can_edit_post && 'trash' !== $post->post_status ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1475 |
$actions['edit'] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1476 |
'<a href="%s" aria-label="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1477 |
get_edit_post_link( $post->ID ), |
16 | 1478 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1479 |
esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1480 |
__( 'Edit' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1481 |
); |
9 | 1482 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1483 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1484 |
* Filters whether Quick Edit should be enabled for the given post type. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1485 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1486 |
* @since 6.4.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1487 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1488 |
* @param bool $enable Whether to enable the Quick Edit functionality. Default true. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1489 |
* @param string $post_type Post type name. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1490 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1491 |
$quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_post_type', true, $post->post_type ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1492 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1493 |
if ( $quick_edit_enabled && 'wp_block' !== $post->post_type ) { |
9 | 1494 |
$actions['inline hide-if-no-js'] = sprintf( |
1495 |
'<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>', |
|
16 | 1496 |
/* translators: %s: Post title. */ |
9 | 1497 |
esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $title ) ), |
1498 |
__( 'Quick Edit' ) |
|
1499 |
); |
|
1500 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1501 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1502 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1503 |
if ( current_user_can( 'delete_post', $post->ID ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1504 |
if ( 'trash' === $post->post_status ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1505 |
$actions['untrash'] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1506 |
'<a href="%s" aria-label="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1507 |
wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ), |
16 | 1508 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1509 |
esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1510 |
__( 'Restore' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1511 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1512 |
} elseif ( EMPTY_TRASH_DAYS ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1513 |
$actions['trash'] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1514 |
'<a href="%s" class="submitdelete" aria-label="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1515 |
get_delete_post_link( $post->ID ), |
16 | 1516 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1517 |
esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1518 |
_x( 'Trash', 'verb' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1519 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1520 |
} |
18 | 1521 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1522 |
if ( 'trash' === $post->post_status || ! EMPTY_TRASH_DAYS ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1523 |
$actions['delete'] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1524 |
'<a href="%s" class="submitdelete" aria-label="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1525 |
get_delete_post_link( $post->ID, '', true ), |
16 | 1526 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1527 |
esc_attr( sprintf( __( 'Delete “%s” permanently' ), $title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1528 |
__( 'Delete Permanently' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1529 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1530 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1531 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1532 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1533 |
if ( is_post_type_viewable( $post_type_object ) ) { |
16 | 1534 |
if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ), true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1535 |
if ( $can_edit_post ) { |
9 | 1536 |
$preview_link = get_preview_post_link( $post ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1537 |
$actions['view'] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1538 |
'<a href="%s" rel="bookmark" aria-label="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1539 |
esc_url( $preview_link ), |
16 | 1540 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1541 |
esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1542 |
__( 'Preview' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1543 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1544 |
} |
16 | 1545 |
} elseif ( 'trash' !== $post->post_status ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1546 |
$actions['view'] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1547 |
'<a href="%s" rel="bookmark" aria-label="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1548 |
get_permalink( $post->ID ), |
16 | 1549 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1550 |
esc_attr( sprintf( __( 'View “%s”' ), $title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1551 |
__( 'View' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1552 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1553 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1554 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1555 |
|
9 | 1556 |
if ( 'wp_block' === $post->post_type ) { |
1557 |
$actions['export'] = sprintf( |
|
1558 |
'<button type="button" class="wp-list-reusable-blocks__export button-link" data-id="%s" aria-label="%s">%s</button>', |
|
1559 |
$post->ID, |
|
16 | 1560 |
/* translators: %s: Post title. */ |
9 | 1561 |
esc_attr( sprintf( __( 'Export “%s” as JSON' ), $title ) ), |
1562 |
__( 'Export as JSON' ) |
|
1563 |
); |
|
1564 |
} |
|
1565 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1566 |
if ( is_post_type_hierarchical( $post->post_type ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1567 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1568 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1569 |
* Filters the array of row action links on the Pages list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1570 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1571 |
* The filter is evaluated only for hierarchical post types. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1572 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1573 |
* @since 2.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1574 |
* |
9 | 1575 |
* @param string[] $actions An array of row action links. Defaults are |
1576 |
* 'Edit', 'Quick Edit', 'Restore', 'Trash', |
|
1577 |
* 'Delete Permanently', 'Preview', and 'View'. |
|
1578 |
* @param WP_Post $post The post object. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1579 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1580 |
$actions = apply_filters( 'page_row_actions', $actions, $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1581 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1582 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1583 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1584 |
* Filters the array of row action links on the Posts list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1585 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1586 |
* The filter is evaluated only for non-hierarchical post types. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1587 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1588 |
* @since 2.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1589 |
* |
9 | 1590 |
* @param string[] $actions An array of row action links. Defaults are |
1591 |
* 'Edit', 'Quick Edit', 'Restore', 'Trash', |
|
1592 |
* 'Delete Permanently', 'Preview', and 'View'. |
|
1593 |
* @param WP_Post $post The post object. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1594 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1595 |
$actions = apply_filters( 'post_row_actions', $actions, $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1596 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1597 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1598 |
return $this->row_actions( $actions ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1599 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1600 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1601 |
/** |
0 | 1602 |
* Outputs the hidden row displayed when inline editing |
1603 |
* |
|
1604 |
* @since 3.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1605 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1606 |
* @global string $mode List table view mode. |
0 | 1607 |
*/ |
5 | 1608 |
public function inline_edit() { |
0 | 1609 |
global $mode; |
1610 |
||
1611 |
$screen = $this->screen; |
|
1612 |
||
9 | 1613 |
$post = get_default_post_to_edit( $screen->post_type ); |
0 | 1614 |
$post_type_object = get_post_type_object( $screen->post_type ); |
1615 |
||
9 | 1616 |
$taxonomy_names = get_object_taxonomies( $screen->post_type ); |
0 | 1617 |
$hierarchical_taxonomies = array(); |
9 | 1618 |
$flat_taxonomies = array(); |
16 | 1619 |
|
0 | 1620 |
foreach ( $taxonomy_names as $taxonomy_name ) { |
1621 |
$taxonomy = get_taxonomy( $taxonomy_name ); |
|
1622 |
||
5 | 1623 |
$show_in_quick_edit = $taxonomy->show_in_quick_edit; |
1624 |
||
1625 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1626 |
* Filters whether the current taxonomy should be shown in the Quick Edit panel. |
5 | 1627 |
* |
1628 |
* @since 4.2.0 |
|
1629 |
* |
|
1630 |
* @param bool $show_in_quick_edit Whether to show the current taxonomy in Quick Edit. |
|
1631 |
* @param string $taxonomy_name Taxonomy name. |
|
1632 |
* @param string $post_type Post type of current Quick Edit post. |
|
1633 |
*/ |
|
1634 |
if ( ! apply_filters( 'quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type ) ) { |
|
0 | 1635 |
continue; |
5 | 1636 |
} |
0 | 1637 |
|
9 | 1638 |
if ( $taxonomy->hierarchical ) { |
0 | 1639 |
$hierarchical_taxonomies[] = $taxonomy; |
9 | 1640 |
} else { |
0 | 1641 |
$flat_taxonomies[] = $taxonomy; |
9 | 1642 |
} |
0 | 1643 |
} |
1644 |
||
9 | 1645 |
$m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list'; |
1646 |
$can_publish = current_user_can( $post_type_object->cap->publish_posts ); |
|
1647 |
$core_columns = array( |
|
1648 |
'cb' => true, |
|
1649 |
'date' => true, |
|
1650 |
'title' => true, |
|
1651 |
'categories' => true, |
|
1652 |
'tags' => true, |
|
1653 |
'comments' => true, |
|
1654 |
'author' => true, |
|
1655 |
); |
|
1656 |
?> |
|
0 | 1657 |
|
16 | 1658 |
<form method="get"> |
1659 |
<table style="display: none"><tbody id="inlineedit"> |
|
0 | 1660 |
<?php |
9 | 1661 |
$hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1662 |
$inline_edit_classes = "inline-edit-row inline-edit-row-$hclass"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1663 |
$bulk_edit_classes = "bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1664 |
$quick_edit_classes = "quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1665 |
|
0 | 1666 |
$bulk = 0; |
18 | 1667 |
|
16 | 1668 |
while ( $bulk < 2 ) : |
1669 |
$classes = $inline_edit_classes . ' '; |
|
1670 |
$classes .= $bulk ? $bulk_edit_classes : $quick_edit_classes; |
|
9 | 1671 |
?> |
16 | 1672 |
<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="<?php echo $classes; ?>" style="display: none"> |
1673 |
<td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
|
19 | 1674 |
<div class="inline-edit-wrapper" role="region" aria-labelledby="<?php echo $bulk ? 'bulk' : 'quick'; ?>-edit-legend"> |
16 | 1675 |
<fieldset class="inline-edit-col-left"> |
19 | 1676 |
<legend class="inline-edit-legend" id="<?php echo $bulk ? 'bulk' : 'quick'; ?>-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend> |
16 | 1677 |
<div class="inline-edit-col"> |
1678 |
||
1679 |
<?php if ( post_type_supports( $screen->post_type, 'title' ) ) : ?> |
|
1680 |
||
1681 |
<?php if ( $bulk ) : ?> |
|
1682 |
||
1683 |
<div id="bulk-title-div"> |
|
1684 |
<div id="bulk-titles"></div> |
|
1685 |
</div> |
|
1686 |
||
1687 |
<?php else : // $bulk ?> |
|
1688 |
||
1689 |
<label> |
|
1690 |
<span class="title"><?php _e( 'Title' ); ?></span> |
|
1691 |
<span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> |
|
1692 |
</label> |
|
1693 |
||
1694 |
<?php if ( is_post_type_viewable( $screen->post_type ) ) : ?> |
|
1695 |
||
1696 |
<label> |
|
1697 |
<span class="title"><?php _e( 'Slug' ); ?></span> |
|
19 | 1698 |
<span class="input-text-wrap"><input type="text" name="post_name" value="" autocomplete="off" spellcheck="false" /></span> |
16 | 1699 |
</label> |
1700 |
||
1701 |
<?php endif; // is_post_type_viewable() ?> |
|
1702 |
||
1703 |
<?php endif; // $bulk ?> |
|
0 | 1704 |
|
16 | 1705 |
<?php endif; // post_type_supports( ... 'title' ) ?> |
1706 |
||
1707 |
<?php if ( ! $bulk ) : ?> |
|
1708 |
<fieldset class="inline-edit-date"> |
|
1709 |
<legend><span class="title"><?php _e( 'Date' ); ?></span></legend> |
|
1710 |
<?php touch_time( 1, 1, 0, 1 ); ?> |
|
1711 |
</fieldset> |
|
1712 |
<br class="clear" /> |
|
1713 |
<?php endif; // $bulk ?> |
|
1714 |
||
1715 |
<?php |
|
18 | 1716 |
if ( post_type_supports( $screen->post_type, 'author' ) ) { |
16 | 1717 |
$authors_dropdown = ''; |
0 | 1718 |
|
18 | 1719 |
if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) { |
19 | 1720 |
$dropdown_name = 'post_author'; |
1721 |
$dropdown_class = 'authors'; |
|
1722 |
if ( wp_is_large_user_count() ) { |
|
1723 |
$authors_dropdown = sprintf( '<select name="%s" class="%s hidden"></select>', esc_attr( $dropdown_name ), esc_attr( $dropdown_class ) ); |
|
1724 |
} else { |
|
1725 |
$users_opt = array( |
|
1726 |
'hide_if_only_one_author' => false, |
|
1727 |
'capability' => array( $post_type_object->cap->edit_posts ), |
|
1728 |
'name' => $dropdown_name, |
|
1729 |
'class' => $dropdown_class, |
|
1730 |
'multi' => 1, |
|
1731 |
'echo' => 0, |
|
1732 |
'show' => 'display_name_with_login', |
|
1733 |
); |
|
0 | 1734 |
|
19 | 1735 |
if ( $bulk ) { |
1736 |
$users_opt['show_option_none'] = __( '— No Change —' ); |
|
1737 |
} |
|
16 | 1738 |
|
19 | 1739 |
/** |
1740 |
* Filters the arguments used to generate the Quick Edit authors drop-down. |
|
1741 |
* |
|
1742 |
* @since 5.6.0 |
|
1743 |
* |
|
1744 |
* @see wp_dropdown_users() |
|
1745 |
* |
|
1746 |
* @param array $users_opt An array of arguments passed to wp_dropdown_users(). |
|
1747 |
* @param bool $bulk A flag to denote if it's a bulk action. |
|
1748 |
*/ |
|
1749 |
$users_opt = apply_filters( 'quick_edit_dropdown_authors_args', $users_opt, $bulk ); |
|
18 | 1750 |
|
19 | 1751 |
$authors = wp_dropdown_users( $users_opt ); |
18 | 1752 |
|
19 | 1753 |
if ( $authors ) { |
1754 |
$authors_dropdown = '<label class="inline-edit-author">'; |
|
1755 |
$authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; |
|
1756 |
$authors_dropdown .= $authors; |
|
1757 |
$authors_dropdown .= '</label>'; |
|
1758 |
} |
|
18 | 1759 |
} |
1760 |
} // current_user_can( 'edit_others_posts' ) |
|
0 | 1761 |
|
16 | 1762 |
if ( ! $bulk ) { |
1763 |
echo $authors_dropdown; |
|
9 | 1764 |
} |
18 | 1765 |
} // post_type_supports( ... 'author' ) |
9 | 1766 |
?> |
0 | 1767 |
|
16 | 1768 |
<?php if ( ! $bulk && $can_publish ) : ?> |
0 | 1769 |
|
16 | 1770 |
<div class="inline-edit-group wp-clearfix"> |
1771 |
<label class="alignleft"> |
|
1772 |
<span class="title"><?php _e( 'Password' ); ?></span> |
|
1773 |
<span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> |
|
1774 |
</label> |
|
0 | 1775 |
|
16 | 1776 |
<span class="alignleft inline-edit-or"> |
1777 |
<?php |
|
1778 |
/* translators: Between password field and private checkbox on post quick edit interface. */ |
|
1779 |
_e( '–OR–' ); |
|
1780 |
?> |
|
1781 |
</span> |
|
1782 |
<label class="alignleft inline-edit-private"> |
|
1783 |
<input type="checkbox" name="keep_private" value="private" /> |
|
1784 |
<span class="checkbox-title"><?php _e( 'Private' ); ?></span> |
|
1785 |
</label> |
|
1786 |
</div> |
|
0 | 1787 |
|
9 | 1788 |
<?php endif; ?> |
0 | 1789 |
|
16 | 1790 |
</div> |
1791 |
</fieldset> |
|
0 | 1792 |
|
9 | 1793 |
<?php if ( count( $hierarchical_taxonomies ) && ! $bulk ) : ?> |
0 | 1794 |
|
16 | 1795 |
<fieldset class="inline-edit-col-center inline-edit-categories"> |
1796 |
<div class="inline-edit-col"> |
|
0 | 1797 |
|
16 | 1798 |
<?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> |
0 | 1799 |
|
16 | 1800 |
<span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ); ?></span> |
1801 |
<input type="hidden" name="<?php echo ( 'category' === $taxonomy->name ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" /> |
|
1802 |
<ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist"> |
|
19 | 1803 |
<?php wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name ) ); ?> |
16 | 1804 |
</ul> |
0 | 1805 |
|
16 | 1806 |
<?php endforeach; // $hierarchical_taxonomies as $taxonomy ?> |
0 | 1807 |
|
16 | 1808 |
</div> |
1809 |
</fieldset> |
|
0 | 1810 |
|
16 | 1811 |
<?php endif; // count( $hierarchical_taxonomies ) && ! $bulk ?> |
0 | 1812 |
|
16 | 1813 |
<fieldset class="inline-edit-col-right"> |
1814 |
<div class="inline-edit-col"> |
|
0 | 1815 |
|
9 | 1816 |
<?php |
16 | 1817 |
if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) { |
1818 |
echo $authors_dropdown; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1819 |
} |
9 | 1820 |
?> |
16 | 1821 |
|
1822 |
<?php if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) : ?> |
|
1823 |
||
1824 |
<?php if ( $post_type_object->hierarchical ) : ?> |
|
1825 |
||
1826 |
<label> |
|
1827 |
<span class="title"><?php _e( 'Parent' ); ?></span> |
|
1828 |
<?php |
|
1829 |
$dropdown_args = array( |
|
1830 |
'post_type' => $post_type_object->name, |
|
1831 |
'selected' => $post->post_parent, |
|
1832 |
'name' => 'post_parent', |
|
1833 |
'show_option_none' => __( 'Main Page (no parent)' ), |
|
1834 |
'option_none_value' => 0, |
|
1835 |
'sort_column' => 'menu_order, post_title', |
|
1836 |
); |
|
1837 |
||
1838 |
if ( $bulk ) { |
|
1839 |
$dropdown_args['show_option_no_change'] = __( '— No Change —' ); |
|
1840 |
} |
|
1841 |
||
1842 |
/** |
|
1843 |
* Filters the arguments used to generate the Quick Edit page-parent drop-down. |
|
1844 |
* |
|
1845 |
* @since 2.7.0 |
|
18 | 1846 |
* @since 5.6.0 The `$bulk` parameter was added. |
16 | 1847 |
* |
1848 |
* @see wp_dropdown_pages() |
|
1849 |
* |
|
18 | 1850 |
* @param array $dropdown_args An array of arguments passed to wp_dropdown_pages(). |
1851 |
* @param bool $bulk A flag to denote if it's a bulk action. |
|
16 | 1852 |
*/ |
18 | 1853 |
$dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args, $bulk ); |
16 | 1854 |
|
1855 |
wp_dropdown_pages( $dropdown_args ); |
|
1856 |
?> |
|
1857 |
</label> |
|
1858 |
||
1859 |
<?php endif; // hierarchical ?> |
|
1860 |
||
1861 |
<?php if ( ! $bulk ) : ?> |
|
1862 |
||
1863 |
<label> |
|
1864 |
<span class="title"><?php _e( 'Order' ); ?></span> |
|
1865 |
<span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order; ?>" /></span> |
|
1866 |
</label> |
|
1867 |
||
1868 |
<?php endif; // ! $bulk ?> |
|
1869 |
||
1870 |
<?php endif; // post_type_supports( ... 'page-attributes' ) ?> |
|
1871 |
||
1872 |
<?php if ( 0 < count( get_page_templates( null, $screen->post_type ) ) ) : ?> |
|
1873 |
||
1874 |
<label> |
|
1875 |
<span class="title"><?php _e( 'Template' ); ?></span> |
|
1876 |
<select name="page_template"> |
|
1877 |
<?php if ( $bulk ) : ?> |
|
1878 |
<option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
1879 |
<?php endif; // $bulk ?> |
|
1880 |
<?php |
|
1881 |
/** This filter is documented in wp-admin/includes/meta-boxes.php */ |
|
1882 |
$default_title = apply_filters( 'default_page_template_title', __( 'Default template' ), 'quick-edit' ); |
|
1883 |
?> |
|
1884 |
<option value="default"><?php echo esc_html( $default_title ); ?></option> |
|
1885 |
<?php page_template_dropdown( '', $screen->post_type ); ?> |
|
1886 |
</select> |
|
1887 |
</label> |
|
1888 |
||
1889 |
<?php endif; ?> |
|
1890 |
||
1891 |
<?php if ( count( $flat_taxonomies ) && ! $bulk ) : ?> |
|
1892 |
||
1893 |
<?php foreach ( $flat_taxonomies as $taxonomy ) : ?> |
|
1894 |
||
1895 |
<?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?> |
|
1896 |
<?php $taxonomy_name = esc_attr( $taxonomy->name ); ?> |
|
19 | 1897 |
<div class="inline-edit-tags-wrap"> |
16 | 1898 |
<label class="inline-edit-tags"> |
1899 |
<span class="title"><?php echo esc_html( $taxonomy->labels->name ); ?></span> |
|
19 | 1900 |
<textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name ); ?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name ); ?>" aria-describedby="inline-edit-<?php echo esc_attr( $taxonomy->name ); ?>-desc"></textarea> |
16 | 1901 |
</label> |
19 | 1902 |
<p class="howto" id="inline-edit-<?php echo esc_attr( $taxonomy->name ); ?>-desc"><?php echo esc_html( $taxonomy->labels->separate_items_with_commas ); ?></p> |
1903 |
</div> |
|
16 | 1904 |
<?php endif; // current_user_can( 'assign_terms' ) ?> |
1905 |
||
1906 |
<?php endforeach; // $flat_taxonomies as $taxonomy ?> |
|
1907 |
||
1908 |
<?php endif; // count( $flat_taxonomies ) && ! $bulk ?> |
|
1909 |
||
1910 |
<?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> |
|
1911 |
||
1912 |
<?php if ( $bulk ) : ?> |
|
1913 |
||
1914 |
<div class="inline-edit-group wp-clearfix"> |
|
1915 |
||
1916 |
<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
|
1917 |
||
1918 |
<label class="alignleft"> |
|
1919 |
<span class="title"><?php _e( 'Comments' ); ?></span> |
|
1920 |
<select name="comment_status"> |
|
1921 |
<option value=""><?php _e( '— No Change —' ); ?></option> |
|
1922 |
<option value="open"><?php _e( 'Allow' ); ?></option> |
|
1923 |
<option value="closed"><?php _e( 'Do not allow' ); ?></option> |
|
1924 |
</select> |
|
1925 |
</label> |
|
1926 |
||
1927 |
<?php endif; ?> |
|
1928 |
||
1929 |
<?php if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> |
|
9 | 1930 |
|
16 | 1931 |
<label class="alignright"> |
1932 |
<span class="title"><?php _e( 'Pings' ); ?></span> |
|
1933 |
<select name="ping_status"> |
|
1934 |
<option value=""><?php _e( '— No Change —' ); ?></option> |
|
1935 |
<option value="open"><?php _e( 'Allow' ); ?></option> |
|
1936 |
<option value="closed"><?php _e( 'Do not allow' ); ?></option> |
|
1937 |
</select> |
|
1938 |
</label> |
|
1939 |
||
1940 |
<?php endif; ?> |
|
1941 |
||
1942 |
</div> |
|
1943 |
||
1944 |
<?php else : // $bulk ?> |
|
1945 |
||
1946 |
<div class="inline-edit-group wp-clearfix"> |
|
1947 |
||
1948 |
<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
|
1949 |
||
1950 |
<label class="alignleft"> |
|
1951 |
<input type="checkbox" name="comment_status" value="open" /> |
|
1952 |
<span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> |
|
1953 |
</label> |
|
1954 |
||
1955 |
<?php endif; ?> |
|
1956 |
||
1957 |
<?php if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> |
|
1958 |
||
1959 |
<label class="alignleft"> |
|
1960 |
<input type="checkbox" name="ping_status" value="open" /> |
|
1961 |
<span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span> |
|
1962 |
</label> |
|
1963 |
||
1964 |
<?php endif; ?> |
|
1965 |
||
1966 |
</div> |
|
1967 |
||
1968 |
<?php endif; // $bulk ?> |
|
1969 |
||
1970 |
<?php endif; // post_type_supports( ... comments or pings ) ?> |
|
1971 |
||
1972 |
<div class="inline-edit-group wp-clearfix"> |
|
1973 |
||
1974 |
<label class="inline-edit-status alignleft"> |
|
1975 |
<span class="title"><?php _e( 'Status' ); ?></span> |
|
1976 |
<select name="_status"> |
|
1977 |
<?php if ( $bulk ) : ?> |
|
1978 |
<option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
1979 |
<?php endif; // $bulk ?> |
|
9 | 1980 |
|
16 | 1981 |
<?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review". ?> |
1982 |
<option value="publish"><?php _e( 'Published' ); ?></option> |
|
1983 |
<option value="future"><?php _e( 'Scheduled' ); ?></option> |
|
1984 |
<?php if ( $bulk ) : ?> |
|
1985 |
<option value="private"><?php _e( 'Private' ); ?></option> |
|
1986 |
<?php endif; // $bulk ?> |
|
1987 |
<?php endif; ?> |
|
1988 |
||
1989 |
<option value="pending"><?php _e( 'Pending Review' ); ?></option> |
|
1990 |
<option value="draft"><?php _e( 'Draft' ); ?></option> |
|
1991 |
</select> |
|
1992 |
</label> |
|
1993 |
||
1994 |
<?php if ( 'post' === $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> |
|
1995 |
||
1996 |
<?php if ( $bulk ) : ?> |
|
1997 |
||
1998 |
<label class="alignright"> |
|
1999 |
<span class="title"><?php _e( 'Sticky' ); ?></span> |
|
2000 |
<select name="sticky"> |
|
2001 |
<option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
2002 |
<option value="sticky"><?php _e( 'Sticky' ); ?></option> |
|
2003 |
<option value="unsticky"><?php _e( 'Not Sticky' ); ?></option> |
|
2004 |
</select> |
|
2005 |
</label> |
|
2006 |
||
2007 |
<?php else : // $bulk ?> |
|
0 | 2008 |
|
16 | 2009 |
<label class="alignleft"> |
2010 |
<input type="checkbox" name="sticky" value="sticky" /> |
|
2011 |
<span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span> |
|
2012 |
</label> |
|
2013 |
||
2014 |
<?php endif; // $bulk ?> |
|
2015 |
||
2016 |
<?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_posts' ) ?> |
|
2017 |
||
2018 |
</div> |
|
2019 |
||
2020 |
<?php if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) : ?> |
|
2021 |
<?php $post_formats = get_theme_support( 'post-formats' ); ?> |
|
2022 |
||
2023 |
<label class="alignleft"> |
|
2024 |
<span class="title"><?php _ex( 'Format', 'post format' ); ?></span> |
|
2025 |
<select name="post_format"> |
|
2026 |
<option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
2027 |
<option value="0"><?php echo get_post_format_string( 'standard' ); ?></option> |
|
2028 |
<?php if ( is_array( $post_formats[0] ) ) : ?> |
|
2029 |
<?php foreach ( $post_formats[0] as $format ) : ?> |
|
2030 |
<option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option> |
|
2031 |
<?php endforeach; ?> |
|
2032 |
<?php endif; ?> |
|
2033 |
</select> |
|
2034 |
</label> |
|
2035 |
||
2036 |
<?php endif; ?> |
|
2037 |
||
2038 |
</div> |
|
2039 |
</fieldset> |
|
0 | 2040 |
|
9 | 2041 |
<?php |
2042 |
list( $columns ) = $this->get_column_info(); |
|
0 | 2043 |
|
9 | 2044 |
foreach ( $columns as $column_name => $column_display_name ) { |
2045 |
if ( isset( $core_columns[ $column_name ] ) ) { |
|
2046 |
continue; |
|
2047 |
} |
|
5 | 2048 |
|
9 | 2049 |
if ( $bulk ) { |
5 | 2050 |
|
9 | 2051 |
/** |
2052 |
* Fires once for each column in Bulk Edit mode. |
|
2053 |
* |
|
2054 |
* @since 2.7.0 |
|
2055 |
* |
|
16 | 2056 |
* @param string $column_name Name of the column to edit. |
2057 |
* @param string $post_type The post type slug. |
|
9 | 2058 |
*/ |
2059 |
do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type ); |
|
2060 |
} else { |
|
5 | 2061 |
|
9 | 2062 |
/** |
2063 |
* Fires once for each column in Quick Edit mode. |
|
2064 |
* |
|
2065 |
* @since 2.7.0 |
|
2066 |
* |
|
2067 |
* @param string $column_name Name of the column to edit. |
|
2068 |
* @param string $post_type The post type slug, or current screen name if this is a taxonomy list table. |
|
16 | 2069 |
* @param string $taxonomy The taxonomy name, if any. |
9 | 2070 |
*/ |
2071 |
do_action( 'quick_edit_custom_box', $column_name, $screen->post_type, '' ); |
|
2072 |
} |
|
5 | 2073 |
} |
9 | 2074 |
?> |
16 | 2075 |
|
2076 |
<div class="submit inline-edit-save"> |
|
2077 |
<?php if ( ! $bulk ) : ?> |
|
2078 |
<?php wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); ?> |
|
19 | 2079 |
<button type="button" class="button button-primary save"><?php _e( 'Update' ); ?></button> |
2080 |
<?php else : ?> |
|
2081 |
<?php submit_button( __( 'Update' ), 'primary', 'bulk_edit', false ); ?> |
|
2082 |
<?php endif; ?> |
|
2083 |
||
2084 |
<button type="button" class="button cancel"><?php _e( 'Cancel' ); ?></button> |
|
2085 |
||
2086 |
<?php if ( ! $bulk ) : ?> |
|
16 | 2087 |
<span class="spinner"></span> |
2088 |
<?php endif; ?> |
|
2089 |
||
2090 |
<input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> |
|
2091 |
<input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> |
|
2092 |
<?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) : ?> |
|
2093 |
<input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> |
|
2094 |
<?php endif; ?> |
|
2095 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2096 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2097 |
wp_admin_notice( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2098 |
'<p class="error"></p>', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2099 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2100 |
'type' => 'error', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2101 |
'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2102 |
'paragraph_wrap' => false, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2103 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2104 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2105 |
?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2106 |
</div> |
19 | 2107 |
</div> <!-- end of .inline-edit-wrapper --> |
16 | 2108 |
|
2109 |
</td></tr> |
|
2110 |
||
9 | 2111 |
<?php |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2112 |
++$bulk; |
16 | 2113 |
endwhile; |
9 | 2114 |
?> |
16 | 2115 |
</tbody></table> |
2116 |
</form> |
|
9 | 2117 |
<?php |
0 | 2118 |
} |
2119 |
} |