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 |
/** |
|
3 |
* Edit Posts Administration Screen. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7 |
*/ |
|
8 |
||
9 |
/** WordPress Administration Bootstrap */ |
|
16 | 10 |
require_once __DIR__ . '/admin.php'; |
0 | 11 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
12 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
13 |
* @global string $typenow The post type of the current screen. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
14 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
15 |
global $typenow; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
16 |
|
9 | 17 |
if ( ! $typenow ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
18 |
wp_die( __( 'Invalid post type.' ) ); |
9 | 19 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
20 |
|
16 | 21 |
if ( ! in_array( $typenow, get_post_types( array( 'show_ui' => true ) ), true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
22 |
wp_die( __( 'Sorry, you are not allowed to edit posts in this post type.' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
23 |
} |
0 | 24 |
|
5 | 25 |
if ( 'attachment' === $typenow ) { |
26 |
if ( wp_redirect( admin_url( 'upload.php' ) ) ) { |
|
27 |
exit; |
|
28 |
} |
|
29 |
} |
|
30 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
31 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
32 |
* @global string $post_type Global post type. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
33 |
* @global WP_Post_Type $post_type_object Global post type object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
34 |
*/ |
5 | 35 |
global $post_type, $post_type_object; |
36 |
||
9 | 37 |
$post_type = $typenow; |
0 | 38 |
$post_type_object = get_post_type_object( $post_type ); |
39 |
||
9 | 40 |
if ( ! $post_type_object ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
41 |
wp_die( __( 'Invalid post type.' ) ); |
9 | 42 |
} |
0 | 43 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
44 |
if ( ! current_user_can( $post_type_object->cap->edit_posts ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
45 |
wp_die( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
46 |
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
'<p>' . __( 'Sorry, you are not allowed to edit posts in this post type.' ) . '</p>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
403 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
50 |
} |
0 | 51 |
|
9 | 52 |
$wp_list_table = _get_list_table( 'WP_Posts_List_Table' ); |
53 |
$pagenum = $wp_list_table->get_pagenum(); |
|
0 | 54 |
|
16 | 55 |
// Back-compat for viewing comments of an entry. |
0 | 56 |
foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) { |
57 |
if ( ! empty( $_REQUEST[ $_redirect ] ) ) { |
|
58 |
wp_redirect( admin_url( 'edit-comments.php?p=' . absint( $_REQUEST[ $_redirect ] ) ) ); |
|
59 |
exit; |
|
60 |
} |
|
61 |
} |
|
62 |
unset( $_redirect ); |
|
63 |
||
16 | 64 |
if ( 'post' !== $post_type ) { |
9 | 65 |
$parent_file = "edit.php?post_type=$post_type"; |
66 |
$submenu_file = "edit.php?post_type=$post_type"; |
|
0 | 67 |
$post_new_file = "post-new.php?post_type=$post_type"; |
68 |
} else { |
|
9 | 69 |
$parent_file = 'edit.php'; |
70 |
$submenu_file = 'edit.php'; |
|
0 | 71 |
$post_new_file = 'post-new.php'; |
72 |
} |
|
73 |
||
74 |
$doaction = $wp_list_table->current_action(); |
|
75 |
||
76 |
if ( $doaction ) { |
|
9 | 77 |
check_admin_referer( 'bulk-posts' ); |
0 | 78 |
|
9 | 79 |
$sendback = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'locked', 'ids' ), wp_get_referer() ); |
80 |
if ( ! $sendback ) { |
|
0 | 81 |
$sendback = admin_url( $parent_file ); |
9 | 82 |
} |
0 | 83 |
$sendback = add_query_arg( 'paged', $pagenum, $sendback ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
84 |
if ( str_contains( $sendback, 'post.php' ) ) { |
9 | 85 |
$sendback = admin_url( $post_new_file ); |
86 |
} |
|
0 | 87 |
|
18 | 88 |
$post_ids = array(); |
89 |
||
16 | 90 |
if ( 'delete_all' === $doaction ) { |
91 |
// Prepare for deletion of all posts with a specified post status (i.e. Empty Trash). |
|
9 | 92 |
$post_status = preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['post_status'] ); |
5 | 93 |
// Validate the post status exists. |
94 |
if ( get_post_status_object( $post_status ) ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
95 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
96 |
* @global wpdb $wpdb WordPress database abstraction object. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
97 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
98 |
global $wpdb; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
99 |
|
0 | 100 |
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) ); |
5 | 101 |
} |
0 | 102 |
$doaction = 'delete'; |
103 |
} elseif ( isset( $_REQUEST['media'] ) ) { |
|
104 |
$post_ids = $_REQUEST['media']; |
|
105 |
} elseif ( isset( $_REQUEST['ids'] ) ) { |
|
106 |
$post_ids = explode( ',', $_REQUEST['ids'] ); |
|
9 | 107 |
} elseif ( ! empty( $_REQUEST['post'] ) ) { |
108 |
$post_ids = array_map( 'intval', $_REQUEST['post'] ); |
|
0 | 109 |
} |
110 |
||
18 | 111 |
if ( empty( $post_ids ) ) { |
0 | 112 |
wp_redirect( $sendback ); |
113 |
exit; |
|
114 |
} |
|
115 |
||
116 |
switch ( $doaction ) { |
|
117 |
case 'trash': |
|
16 | 118 |
$trashed = 0; |
119 |
$locked = 0; |
|
0 | 120 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
121 |
foreach ( (array) $post_ids as $post_id ) { |
9 | 122 |
if ( ! current_user_can( 'delete_post', $post_id ) ) { |
123 |
wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) ); |
|
124 |
} |
|
0 | 125 |
|
126 |
if ( wp_check_post_lock( $post_id ) ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
127 |
++$locked; |
0 | 128 |
continue; |
129 |
} |
|
130 |
||
9 | 131 |
if ( ! wp_trash_post( $post_id ) ) { |
16 | 132 |
wp_die( __( 'Error in moving the item to Trash.' ) ); |
9 | 133 |
} |
0 | 134 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
135 |
++$trashed; |
0 | 136 |
} |
137 |
||
9 | 138 |
$sendback = add_query_arg( |
139 |
array( |
|
140 |
'trashed' => $trashed, |
|
18 | 141 |
'ids' => implode( ',', $post_ids ), |
9 | 142 |
'locked' => $locked, |
143 |
), |
|
144 |
$sendback |
|
145 |
); |
|
0 | 146 |
break; |
147 |
case 'untrash': |
|
148 |
$untrashed = 0; |
|
18 | 149 |
|
150 |
if ( isset( $_GET['doaction'] ) && ( 'undo' === $_GET['doaction'] ) ) { |
|
151 |
add_filter( 'wp_untrash_post_status', 'wp_untrash_post_set_previous_status', 10, 3 ); |
|
152 |
} |
|
153 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
154 |
foreach ( (array) $post_ids as $post_id ) { |
9 | 155 |
if ( ! current_user_can( 'delete_post', $post_id ) ) { |
156 |
wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) ); |
|
157 |
} |
|
0 | 158 |
|
9 | 159 |
if ( ! wp_untrash_post( $post_id ) ) { |
16 | 160 |
wp_die( __( 'Error in restoring the item from Trash.' ) ); |
9 | 161 |
} |
0 | 162 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
163 |
++$untrashed; |
0 | 164 |
} |
9 | 165 |
$sendback = add_query_arg( 'untrashed', $untrashed, $sendback ); |
18 | 166 |
|
19 | 167 |
remove_filter( 'wp_untrash_post_status', 'wp_untrash_post_set_previous_status', 10 ); |
18 | 168 |
|
0 | 169 |
break; |
170 |
case 'delete': |
|
171 |
$deleted = 0; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
172 |
foreach ( (array) $post_ids as $post_id ) { |
9 | 173 |
$post_del = get_post( $post_id ); |
0 | 174 |
|
9 | 175 |
if ( ! current_user_can( 'delete_post', $post_id ) ) { |
176 |
wp_die( __( 'Sorry, you are not allowed to delete this item.' ) ); |
|
177 |
} |
|
0 | 178 |
|
16 | 179 |
if ( 'attachment' === $post_del->post_type ) { |
9 | 180 |
if ( ! wp_delete_attachment( $post_id ) ) { |
16 | 181 |
wp_die( __( 'Error in deleting the attachment.' ) ); |
9 | 182 |
} |
0 | 183 |
} else { |
9 | 184 |
if ( ! wp_delete_post( $post_id ) ) { |
16 | 185 |
wp_die( __( 'Error in deleting the item.' ) ); |
9 | 186 |
} |
0 | 187 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
188 |
++$deleted; |
0 | 189 |
} |
9 | 190 |
$sendback = add_query_arg( 'deleted', $deleted, $sendback ); |
0 | 191 |
break; |
192 |
case 'edit': |
|
9 | 193 |
if ( isset( $_REQUEST['bulk_edit'] ) ) { |
194 |
$done = bulk_edit_posts( $_REQUEST ); |
|
0 | 195 |
|
9 | 196 |
if ( is_array( $done ) ) { |
0 | 197 |
$done['updated'] = count( $done['updated'] ); |
198 |
$done['skipped'] = count( $done['skipped'] ); |
|
9 | 199 |
$done['locked'] = count( $done['locked'] ); |
200 |
$sendback = add_query_arg( $done, $sendback ); |
|
0 | 201 |
} |
202 |
} |
|
203 |
break; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
204 |
default: |
16 | 205 |
$screen = get_current_screen()->id; |
206 |
||
207 |
/** |
|
208 |
* Fires when a custom bulk action should be handled. |
|
209 |
* |
|
210 |
* The redirect link should be modified with success or failure feedback |
|
211 |
* from the action to be used to display feedback to the user. |
|
212 |
* |
|
213 |
* The dynamic portion of the hook name, `$screen`, refers to the current screen ID. |
|
214 |
* |
|
215 |
* @since 4.7.0 |
|
216 |
* |
|
217 |
* @param string $sendback The redirect URL. |
|
218 |
* @param string $doaction The action being taken. |
|
219 |
* @param array $items The items to take the action on. Accepts an array of IDs of posts, |
|
220 |
* comments, terms, links, plugins, attachments, or users. |
|
221 |
*/ |
|
222 |
$sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $doaction, $post_ids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
223 |
break; |
0 | 224 |
} |
225 |
||
9 | 226 |
$sendback = remove_query_arg( array( 'action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view' ), $sendback ); |
0 | 227 |
|
9 | 228 |
wp_redirect( $sendback ); |
16 | 229 |
exit; |
9 | 230 |
} elseif ( ! empty( $_REQUEST['_wp_http_referer'] ) ) { |
231 |
wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
|
232 |
exit; |
|
0 | 233 |
} |
234 |
||
235 |
$wp_list_table->prepare_items(); |
|
236 |
||
9 | 237 |
wp_enqueue_script( 'inline-edit-post' ); |
238 |
wp_enqueue_script( 'heartbeat' ); |
|
239 |
||
240 |
if ( 'wp_block' === $post_type ) { |
|
241 |
wp_enqueue_script( 'wp-list-reusable-blocks' ); |
|
242 |
wp_enqueue_style( 'wp-list-reusable-blocks' ); |
|
243 |
} |
|
0 | 244 |
|
19 | 245 |
// Used in the HTML title tag. |
0 | 246 |
$title = $post_type_object->labels->name; |
247 |
||
16 | 248 |
if ( 'post' === $post_type ) { |
9 | 249 |
get_current_screen()->add_help_tab( |
250 |
array( |
|
251 |
'id' => 'overview', |
|
252 |
'title' => __( 'Overview' ), |
|
253 |
'content' => |
|
16 | 254 |
'<p>' . __( 'This screen provides access to all of your posts. You can customize the display of this screen to suit your workflow.' ) . '</p>', |
9 | 255 |
) |
256 |
); |
|
257 |
get_current_screen()->add_help_tab( |
|
258 |
array( |
|
259 |
'id' => 'screen-content', |
|
260 |
'title' => __( 'Screen Content' ), |
|
261 |
'content' => |
|
16 | 262 |
'<p>' . __( 'You can customize the display of this screen’s contents in a number of ways:' ) . '</p>' . |
263 |
'<ul>' . |
|
264 |
'<li>' . __( 'You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.' ) . '</li>' . |
|
265 |
'<li>' . __( 'You can filter the list of posts by post status using the text links above the posts list to only show posts with that status. The default view is to show all posts.' ) . '</li>' . |
|
266 |
'<li>' . __( 'You can view posts in a simple title list or with an excerpt using the Screen Options tab.' ) . '</li>' . |
|
267 |
'<li>' . __( 'You can refine the list to show only posts in a specific category or from a specific month by using the dropdown menus above the posts list. Click the Filter button after making your selection. You also can refine the list by clicking on the post author, category or tag in the posts list.' ) . '</li>' . |
|
268 |
'</ul>', |
|
9 | 269 |
) |
270 |
); |
|
271 |
get_current_screen()->add_help_tab( |
|
272 |
array( |
|
273 |
'id' => 'action-links', |
|
274 |
'title' => __( 'Available Actions' ), |
|
275 |
'content' => |
|
16 | 276 |
'<p>' . __( 'Hovering over a row in the posts list will display action links that allow you to manage your post. You can perform the following actions:' ) . '</p>' . |
277 |
'<ul>' . |
|
278 |
'<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that post. You can also reach that screen by clicking on the post title.' ) . '</li>' . |
|
279 |
'<li>' . __( '<strong>Quick Edit</strong> provides inline access to the metadata of your post, allowing you to update post details without leaving this screen.' ) . '</li>' . |
|
280 |
'<li>' . __( '<strong>Trash</strong> removes your post from this list and places it in the Trash, from which you can permanently delete it.' ) . '</li>' . |
|
281 |
'<li>' . __( '<strong>Preview</strong> will show you what your draft post will look like if you publish it. View will take you to your live site to view the post. Which link is available depends on your post’s status.' ) . '</li>' . |
|
282 |
'</ul>', |
|
9 | 283 |
) |
284 |
); |
|
285 |
get_current_screen()->add_help_tab( |
|
286 |
array( |
|
287 |
'id' => 'bulk-actions', |
|
16 | 288 |
'title' => __( 'Bulk actions' ), |
9 | 289 |
'content' => |
16 | 290 |
'<p>' . __( 'You can also edit or move multiple posts to the Trash at once. Select the posts you want to act on using the checkboxes, then select the action you want to take from the Bulk actions menu and click Apply.' ) . '</p>' . |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
291 |
'<p>' . sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
292 |
/* translators: %s: The dismiss dashicon used for buttons that dismiss or remove. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
293 |
__( 'When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected posts at once. To remove a post from the grouping, just click the %s<span class="screen-reader-text">remove</span> button next to its name in the Bulk Edit area that appears.' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
294 |
'<span class="dashicons dashicons-dismiss" aria-hidden="true" style="font-size: 16px; width: 16px; vertical-align: middle;"></span>' |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
295 |
) . '</p>', |
9 | 296 |
) |
297 |
); |
|
0 | 298 |
|
299 |
get_current_screen()->set_help_sidebar( |
|
9 | 300 |
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
301 |
'<p>' . __( '<a href="https://wordpress.org/documentation/article/posts-screen/">Documentation on Managing Posts</a>' ) . '</p>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
302 |
'<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>' |
0 | 303 |
); |
304 |
||
16 | 305 |
} elseif ( 'page' === $post_type ) { |
9 | 306 |
get_current_screen()->add_help_tab( |
307 |
array( |
|
308 |
'id' => 'overview', |
|
309 |
'title' => __( 'Overview' ), |
|
310 |
'content' => |
|
16 | 311 |
'<p>' . __( 'Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the “Parent” of the other, creating a group of pages.' ) . '</p>', |
9 | 312 |
) |
313 |
); |
|
314 |
get_current_screen()->add_help_tab( |
|
315 |
array( |
|
316 |
'id' => 'managing-pages', |
|
317 |
'title' => __( 'Managing Pages' ), |
|
318 |
'content' => |
|
16 | 319 |
'<p>' . __( 'Managing pages is very similar to managing posts, and the screens can be customized in the same way.' ) . '</p>' . |
320 |
'<p>' . __( 'You can also perform the same types of actions, including narrowing the list by using the filters, acting on a page using the action links that appear when you hover over a row, or using the Bulk actions menu to edit the metadata for multiple pages at once.' ) . '</p>', |
|
9 | 321 |
) |
322 |
); |
|
0 | 323 |
|
324 |
get_current_screen()->set_help_sidebar( |
|
9 | 325 |
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
326 |
'<p>' . __( '<a href="https://wordpress.org/documentation/article/pages-screen/">Documentation on Managing Pages</a>' ) . '</p>' . |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
327 |
'<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>' |
0 | 328 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
329 |
|
0 | 330 |
} |
331 |
||
9 | 332 |
get_current_screen()->set_screen_reader_content( |
333 |
array( |
|
334 |
'heading_views' => $post_type_object->labels->filter_items_list, |
|
335 |
'heading_pagination' => $post_type_object->labels->items_list_navigation, |
|
336 |
'heading_list' => $post_type_object->labels->items_list, |
|
337 |
) |
|
338 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
|
9 | 340 |
add_screen_option( |
341 |
'per_page', |
|
342 |
array( |
|
343 |
'default' => 20, |
|
344 |
'option' => 'edit_' . $post_type . '_per_page', |
|
345 |
) |
|
346 |
); |
|
0 | 347 |
|
348 |
$bulk_counts = array( |
|
9 | 349 |
'updated' => isset( $_REQUEST['updated'] ) ? absint( $_REQUEST['updated'] ) : 0, |
350 |
'locked' => isset( $_REQUEST['locked'] ) ? absint( $_REQUEST['locked'] ) : 0, |
|
351 |
'deleted' => isset( $_REQUEST['deleted'] ) ? absint( $_REQUEST['deleted'] ) : 0, |
|
352 |
'trashed' => isset( $_REQUEST['trashed'] ) ? absint( $_REQUEST['trashed'] ) : 0, |
|
0 | 353 |
'untrashed' => isset( $_REQUEST['untrashed'] ) ? absint( $_REQUEST['untrashed'] ) : 0, |
354 |
); |
|
355 |
||
9 | 356 |
$bulk_messages = array(); |
357 |
$bulk_messages['post'] = array( |
|
16 | 358 |
/* translators: %s: Number of posts. */ |
0 | 359 |
'updated' => _n( '%s post updated.', '%s posts updated.', $bulk_counts['updated'] ), |
16 | 360 |
'locked' => ( 1 === $bulk_counts['locked'] ) ? __( '1 post not updated, somebody is editing it.' ) : |
361 |
/* translators: %s: Number of posts. */ |
|
9 | 362 |
_n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $bulk_counts['locked'] ), |
16 | 363 |
/* translators: %s: Number of posts. */ |
0 | 364 |
'deleted' => _n( '%s post permanently deleted.', '%s posts permanently deleted.', $bulk_counts['deleted'] ), |
16 | 365 |
/* translators: %s: Number of posts. */ |
0 | 366 |
'trashed' => _n( '%s post moved to the Trash.', '%s posts moved to the Trash.', $bulk_counts['trashed'] ), |
16 | 367 |
/* translators: %s: Number of posts. */ |
0 | 368 |
'untrashed' => _n( '%s post restored from the Trash.', '%s posts restored from the Trash.', $bulk_counts['untrashed'] ), |
369 |
); |
|
9 | 370 |
$bulk_messages['page'] = array( |
16 | 371 |
/* translators: %s: Number of pages. */ |
0 | 372 |
'updated' => _n( '%s page updated.', '%s pages updated.', $bulk_counts['updated'] ), |
16 | 373 |
'locked' => ( 1 === $bulk_counts['locked'] ) ? __( '1 page not updated, somebody is editing it.' ) : |
374 |
/* translators: %s: Number of pages. */ |
|
9 | 375 |
_n( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $bulk_counts['locked'] ), |
16 | 376 |
/* translators: %s: Number of pages. */ |
0 | 377 |
'deleted' => _n( '%s page permanently deleted.', '%s pages permanently deleted.', $bulk_counts['deleted'] ), |
16 | 378 |
/* translators: %s: Number of pages. */ |
0 | 379 |
'trashed' => _n( '%s page moved to the Trash.', '%s pages moved to the Trash.', $bulk_counts['trashed'] ), |
16 | 380 |
/* translators: %s: Number of pages. */ |
0 | 381 |
'untrashed' => _n( '%s page restored from the Trash.', '%s pages restored from the Trash.', $bulk_counts['untrashed'] ), |
382 |
); |
|
9 | 383 |
$bulk_messages['wp_block'] = array( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
384 |
/* translators: %s: Number of patterns. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
385 |
'updated' => _n( '%s pattern updated.', '%s patterns updated.', $bulk_counts['updated'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
386 |
'locked' => ( 1 === $bulk_counts['locked'] ) ? __( '1 pattern not updated, somebody is editing it.' ) : |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
387 |
/* translators: %s: Number of patterns. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
388 |
_n( '%s pattern not updated, somebody is editing it.', '%s patterns not updated, somebody is editing them.', $bulk_counts['locked'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
389 |
/* translators: %s: Number of patterns. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
390 |
'deleted' => _n( '%s pattern permanently deleted.', '%s patterns permanently deleted.', $bulk_counts['deleted'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
391 |
/* translators: %s: Number of patterns. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
392 |
'trashed' => _n( '%s pattern moved to the Trash.', '%s patterns moved to the Trash.', $bulk_counts['trashed'] ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
393 |
/* translators: %s: Number of patterns. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
394 |
'untrashed' => _n( '%s pattern restored from the Trash.', '%s patterns restored from the Trash.', $bulk_counts['untrashed'] ), |
9 | 395 |
); |
0 | 396 |
|
397 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
398 |
* Filters the bulk action updated messages. |
0 | 399 |
* |
400 |
* By default, custom post types use the messages for the 'post' post type. |
|
401 |
* |
|
402 |
* @since 3.7.0 |
|
403 |
* |
|
9 | 404 |
* @param array[] $bulk_messages Arrays of messages, each keyed by the corresponding post type. Messages are |
405 |
* keyed with 'updated', 'locked', 'deleted', 'trashed', and 'untrashed'. |
|
406 |
* @param int[] $bulk_counts Array of item counts for each message, used to build internationalized strings. |
|
0 | 407 |
*/ |
408 |
$bulk_messages = apply_filters( 'bulk_post_updated_messages', $bulk_messages, $bulk_counts ); |
|
9 | 409 |
$bulk_counts = array_filter( $bulk_counts ); |
0 | 410 |
|
16 | 411 |
require_once ABSPATH . 'wp-admin/admin-header.php'; |
0 | 412 |
?> |
413 |
<div class="wrap"> |
|
9 | 414 |
<h1 class="wp-heading-inline"> |
415 |
<?php |
|
0 | 416 |
echo esc_html( $post_type_object->labels->name ); |
9 | 417 |
?> |
418 |
</h1> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
420 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
421 |
if ( current_user_can( $post_type_object->cap->create_posts ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
422 |
echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_type_object->labels->add_new ) . '</a>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
423 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
424 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
18 | 426 |
echo '<span class="subtitle">'; |
427 |
printf( |
|
428 |
/* translators: %s: Search query. */ |
|
429 |
__( 'Search results for: %s' ), |
|
430 |
'<strong>' . get_search_query() . '</strong>' |
|
431 |
); |
|
432 |
echo '</span>'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
433 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
434 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
435 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
436 |
<hr class="wp-header-end"> |
0 | 437 |
|
438 |
<?php |
|
439 |
// If we have a bulk message to issue: |
|
440 |
$messages = array(); |
|
441 |
foreach ( $bulk_counts as $message => $count ) { |
|
9 | 442 |
if ( isset( $bulk_messages[ $post_type ][ $message ] ) ) { |
0 | 443 |
$messages[] = sprintf( $bulk_messages[ $post_type ][ $message ], number_format_i18n( $count ) ); |
9 | 444 |
} elseif ( isset( $bulk_messages['post'][ $message ] ) ) { |
0 | 445 |
$messages[] = sprintf( $bulk_messages['post'][ $message ], number_format_i18n( $count ) ); |
9 | 446 |
} |
0 | 447 |
|
16 | 448 |
if ( 'trashed' === $message && isset( $_REQUEST['ids'] ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
449 |
$ids = preg_replace( '/[^0-9,]/', '', $_REQUEST['ids'] ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
450 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
451 |
$messages[] = sprintf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
452 |
'<a href="%1$s">%2$s</a>', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
453 |
esc_url( wp_nonce_url( "edit.php?post_type=$post_type&doaction=undo&action=untrash&ids=$ids", 'bulk-posts' ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
454 |
__( 'Undo' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
455 |
); |
0 | 456 |
} |
18 | 457 |
|
458 |
if ( 'untrashed' === $message && isset( $_REQUEST['ids'] ) ) { |
|
459 |
$ids = explode( ',', $_REQUEST['ids'] ); |
|
460 |
||
461 |
if ( 1 === count( $ids ) && current_user_can( 'edit_post', $ids[0] ) ) { |
|
462 |
$messages[] = sprintf( |
|
463 |
'<a href="%1$s">%2$s</a>', |
|
464 |
esc_url( get_edit_post_link( $ids[0] ) ), |
|
465 |
esc_html( get_post_type_object( get_post_type( $ids[0] ) )->labels->edit_item ) |
|
466 |
); |
|
467 |
} |
|
468 |
} |
|
0 | 469 |
} |
470 |
||
9 | 471 |
if ( $messages ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
472 |
wp_admin_notice( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
473 |
implode( ' ', $messages ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
474 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
475 |
'id' => 'message', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
476 |
'additional_classes' => array( 'updated' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
477 |
'dismissible' => true, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
478 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
479 |
); |
9 | 480 |
} |
0 | 481 |
unset( $messages ); |
482 |
||
483 |
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed' ), $_SERVER['REQUEST_URI'] ); |
|
484 |
?> |
|
485 |
||
486 |
<?php $wp_list_table->views(); ?> |
|
487 |
||
5 | 488 |
<form id="posts-filter" method="get"> |
0 | 489 |
|
490 |
<?php $wp_list_table->search_box( $post_type_object->labels->search_items, 'post' ); ?> |
|
491 |
||
9 | 492 |
<input type="hidden" name="post_status" class="post_status_page" value="<?php echo ! empty( $_REQUEST['post_status'] ) ? esc_attr( $_REQUEST['post_status'] ) : 'all'; ?>" /> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
493 |
<input type="hidden" name="post_type" class="post_type_page" value="<?php echo esc_attr( $post_type ); ?>" /> |
7
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 |
<?php if ( ! empty( $_REQUEST['author'] ) ) { ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
496 |
<input type="hidden" name="author" value="<?php echo esc_attr( $_REQUEST['author'] ); ?>" /> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
497 |
<?php } ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
498 |
|
0 | 499 |
<?php if ( ! empty( $_REQUEST['show_sticky'] ) ) { ?> |
500 |
<input type="hidden" name="show_sticky" value="1" /> |
|
501 |
<?php } ?> |
|
502 |
||
503 |
<?php $wp_list_table->display(); ?> |
|
504 |
||
505 |
</form> |
|
506 |
||
507 |
<?php |
|
9 | 508 |
if ( $wp_list_table->has_items() ) { |
0 | 509 |
$wp_list_table->inline_edit(); |
9 | 510 |
} |
0 | 511 |
?> |
512 |
||
513 |
<div id="ajax-response"></div> |
|
18 | 514 |
<div class="clear"></div> |
0 | 515 |
</div> |
516 |
||
517 |
<?php |
|
16 | 518 |
require_once ABSPATH . 'wp-admin/admin-footer.php'; |