77 } |
77 } |
78 $sendback = add_query_arg( 'paged', $pagenum, $sendback ); |
78 $sendback = add_query_arg( 'paged', $pagenum, $sendback ); |
79 if ( strpos( $sendback, 'post.php' ) !== false ) { |
79 if ( strpos( $sendback, 'post.php' ) !== false ) { |
80 $sendback = admin_url( $post_new_file ); |
80 $sendback = admin_url( $post_new_file ); |
81 } |
81 } |
|
82 |
|
83 $post_ids = array(); |
82 |
84 |
83 if ( 'delete_all' === $doaction ) { |
85 if ( 'delete_all' === $doaction ) { |
84 // Prepare for deletion of all posts with a specified post status (i.e. Empty Trash). |
86 // Prepare for deletion of all posts with a specified post status (i.e. Empty Trash). |
85 $post_status = preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['post_status'] ); |
87 $post_status = preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['post_status'] ); |
86 // Validate the post status exists. |
88 // Validate the post status exists. |
94 $post_ids = explode( ',', $_REQUEST['ids'] ); |
96 $post_ids = explode( ',', $_REQUEST['ids'] ); |
95 } elseif ( ! empty( $_REQUEST['post'] ) ) { |
97 } elseif ( ! empty( $_REQUEST['post'] ) ) { |
96 $post_ids = array_map( 'intval', $_REQUEST['post'] ); |
98 $post_ids = array_map( 'intval', $_REQUEST['post'] ); |
97 } |
99 } |
98 |
100 |
99 if ( ! isset( $post_ids ) ) { |
101 if ( empty( $post_ids ) ) { |
100 wp_redirect( $sendback ); |
102 wp_redirect( $sendback ); |
101 exit; |
103 exit; |
102 } |
104 } |
103 |
105 |
104 switch ( $doaction ) { |
106 switch ( $doaction ) { |
124 } |
126 } |
125 |
127 |
126 $sendback = add_query_arg( |
128 $sendback = add_query_arg( |
127 array( |
129 array( |
128 'trashed' => $trashed, |
130 'trashed' => $trashed, |
129 'ids' => join( ',', $post_ids ), |
131 'ids' => implode( ',', $post_ids ), |
130 'locked' => $locked, |
132 'locked' => $locked, |
131 ), |
133 ), |
132 $sendback |
134 $sendback |
133 ); |
135 ); |
134 break; |
136 break; |
135 case 'untrash': |
137 case 'untrash': |
136 $untrashed = 0; |
138 $untrashed = 0; |
|
139 |
|
140 if ( isset( $_GET['doaction'] ) && ( 'undo' === $_GET['doaction'] ) ) { |
|
141 add_filter( 'wp_untrash_post_status', 'wp_untrash_post_set_previous_status', 10, 3 ); |
|
142 } |
|
143 |
137 foreach ( (array) $post_ids as $post_id ) { |
144 foreach ( (array) $post_ids as $post_id ) { |
138 if ( ! current_user_can( 'delete_post', $post_id ) ) { |
145 if ( ! current_user_can( 'delete_post', $post_id ) ) { |
139 wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) ); |
146 wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) ); |
140 } |
147 } |
141 |
148 |
144 } |
151 } |
145 |
152 |
146 $untrashed++; |
153 $untrashed++; |
147 } |
154 } |
148 $sendback = add_query_arg( 'untrashed', $untrashed, $sendback ); |
155 $sendback = add_query_arg( 'untrashed', $untrashed, $sendback ); |
|
156 |
|
157 remove_filter( 'wp_untrash_post_status', 'wp_untrash_post_set_previous_status', 10, 3 ); |
|
158 |
149 break; |
159 break; |
150 case 'delete': |
160 case 'delete': |
151 $deleted = 0; |
161 $deleted = 0; |
152 foreach ( (array) $post_ids as $post_id ) { |
162 foreach ( (array) $post_ids as $post_id ) { |
153 $post_del = get_post( $post_id ); |
163 $post_del = get_post( $post_id ); |
396 if ( current_user_can( $post_type_object->cap->create_posts ) ) { |
406 if ( current_user_can( $post_type_object->cap->create_posts ) ) { |
397 echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_type_object->labels->add_new ) . '</a>'; |
407 echo ' <a href="' . esc_url( admin_url( $post_new_file ) ) . '" class="page-title-action">' . esc_html( $post_type_object->labels->add_new ) . '</a>'; |
398 } |
408 } |
399 |
409 |
400 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
410 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
401 /* translators: %s: Search query. */ |
411 echo '<span class="subtitle">'; |
402 printf( ' <span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', get_search_query() ); |
412 printf( |
|
413 /* translators: %s: Search query. */ |
|
414 __( 'Search results for: %s' ), |
|
415 '<strong>' . get_search_query() . '</strong>' |
|
416 ); |
|
417 echo '</span>'; |
403 } |
418 } |
404 ?> |
419 ?> |
405 |
420 |
406 <hr class="wp-header-end"> |
421 <hr class="wp-header-end"> |
407 |
422 |
417 |
432 |
418 if ( 'trashed' === $message && isset( $_REQUEST['ids'] ) ) { |
433 if ( 'trashed' === $message && isset( $_REQUEST['ids'] ) ) { |
419 $ids = preg_replace( '/[^0-9,]/', '', $_REQUEST['ids'] ); |
434 $ids = preg_replace( '/[^0-9,]/', '', $_REQUEST['ids'] ); |
420 $messages[] = '<a href="' . esc_url( wp_nonce_url( "edit.php?post_type=$post_type&doaction=undo&action=untrash&ids=$ids", 'bulk-posts' ) ) . '">' . __( 'Undo' ) . '</a>'; |
435 $messages[] = '<a href="' . esc_url( wp_nonce_url( "edit.php?post_type=$post_type&doaction=undo&action=untrash&ids=$ids", 'bulk-posts' ) ) . '">' . __( 'Undo' ) . '</a>'; |
421 } |
436 } |
|
437 |
|
438 if ( 'untrashed' === $message && isset( $_REQUEST['ids'] ) ) { |
|
439 $ids = explode( ',', $_REQUEST['ids'] ); |
|
440 |
|
441 if ( 1 === count( $ids ) && current_user_can( 'edit_post', $ids[0] ) ) { |
|
442 $messages[] = sprintf( |
|
443 '<a href="%1$s">%2$s</a>', |
|
444 esc_url( get_edit_post_link( $ids[0] ) ), |
|
445 esc_html( get_post_type_object( get_post_type( $ids[0] ) )->labels->edit_item ) |
|
446 ); |
|
447 } |
|
448 } |
422 } |
449 } |
423 |
450 |
424 if ( $messages ) { |
451 if ( $messages ) { |
425 echo '<div id="message" class="updated notice is-dismissible"><p>' . join( ' ', $messages ) . '</p></div>'; |
452 echo '<div id="message" class="updated notice is-dismissible"><p>' . implode( ' ', $messages ) . '</p></div>'; |
426 } |
453 } |
427 unset( $messages ); |
454 unset( $messages ); |
428 |
455 |
429 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed' ), $_SERVER['REQUEST_URI'] ); |
456 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed' ), $_SERVER['REQUEST_URI'] ); |
430 ?> |
457 ?> |