author | ymh <ymh.work@gmail.com> |
Tue, 15 Oct 2019 15:48:13 +0200 | |
changeset 13 | d255fe9cd479 |
parent 9 | 177826044cd9 |
child 16 | a86126ab1dd4 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Media Library administration panel. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7 |
*/ |
|
8 |
||
9 |
/** WordPress Administration Bootstrap */ |
|
10 |
require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
11 |
||
9 | 12 |
if ( ! current_user_can( 'upload_files' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
13 |
wp_die( __( 'Sorry, you are not allowed to upload files.' ) ); |
9 | 14 |
} |
0 | 15 |
|
9 | 16 |
$mode = get_user_option( 'media_library_mode', get_current_user_id() ) ? get_user_option( 'media_library_mode', get_current_user_id() ) : 'grid'; |
5 | 17 |
$modes = array( 'grid', 'list' ); |
18 |
||
19 |
if ( isset( $_GET['mode'] ) && in_array( $_GET['mode'], $modes ) ) { |
|
20 |
$mode = $_GET['mode']; |
|
21 |
update_user_option( get_current_user_id(), 'media_library_mode', $mode ); |
|
22 |
} |
|
23 |
||
24 |
if ( 'grid' === $mode ) { |
|
25 |
wp_enqueue_media(); |
|
26 |
wp_enqueue_script( 'media-grid' ); |
|
27 |
wp_enqueue_script( 'media' ); |
|
28 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
remove_action( 'admin_head', 'wp_admin_canonical_url' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
30 |
|
5 | 31 |
$q = $_GET; |
32 |
// let JS handle this |
|
33 |
unset( $q['s'] ); |
|
9 | 34 |
$vars = wp_edit_attachments_query_vars( $q ); |
5 | 35 |
$ignore = array( 'mode', 'post_type', 'post_status', 'posts_per_page' ); |
36 |
foreach ( $vars as $key => $value ) { |
|
37 |
if ( ! $value || in_array( $key, $ignore ) ) { |
|
38 |
unset( $vars[ $key ] ); |
|
39 |
} |
|
40 |
} |
|
41 |
||
9 | 42 |
wp_localize_script( |
43 |
'media-grid', |
|
44 |
'_wpMediaGridSettings', |
|
45 |
array( |
|
46 |
'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ), |
|
47 |
'queryVars' => (object) $vars, |
|
48 |
) |
|
49 |
); |
|
5 | 50 |
|
9 | 51 |
get_current_screen()->add_help_tab( |
52 |
array( |
|
53 |
'id' => 'overview', |
|
54 |
'title' => __( 'Overview' ), |
|
55 |
'content' => |
|
56 |
'<p>' . __( 'All the files you’ve uploaded are listed in the Media Library, with the most recent uploads listed first.' ) . '</p>' . |
|
57 |
'<p>' . __( 'You can view your media in a simple visual grid or a list with columns. Switch between these views using the icons to the left above the media.' ) . '</p>' . |
|
58 |
'<p>' . __( 'To delete media items, click the Bulk Select button at the top of the screen. Select any items you wish to delete, then click the Delete Selected button. Clicking the Cancel Selection button takes you back to viewing your media.' ) . '</p>', |
|
59 |
) |
|
60 |
); |
|
5 | 61 |
|
9 | 62 |
get_current_screen()->add_help_tab( |
63 |
array( |
|
64 |
'id' => 'attachment-details', |
|
65 |
'title' => __( 'Attachment Details' ), |
|
66 |
'content' => |
|
67 |
'<p>' . __( 'Clicking an item will display an Attachment Details dialog, which allows you to preview media and make quick edits. Any changes you make to the attachment details will be automatically saved.' ) . '</p>' . |
|
68 |
'<p>' . __( 'Use the arrow buttons at the top of the dialog, or the left and right arrow keys on your keyboard, to navigate between media items quickly.' ) . '</p>' . |
|
69 |
'<p>' . __( 'You can also delete individual items and access the extended edit screen from the details dialog.' ) . '</p>', |
|
70 |
) |
|
71 |
); |
|
5 | 72 |
|
73 |
get_current_screen()->set_help_sidebar( |
|
74 |
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
'<p>' . __( '<a href="https://codex.wordpress.org/Media_Library_Screen">Documentation on Media Library</a>' ) . '</p>' . |
9 | 76 |
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
5 | 77 |
); |
78 |
||
9 | 79 |
$title = __( 'Media Library' ); |
5 | 80 |
$parent_file = 'upload.php'; |
81 |
||
82 |
require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
83 |
?> |
|
9 | 84 |
<div class="wrap" id="wp-media-grid" data-search="<?php _admin_search_query(); ?>"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
<h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
|
5 | 87 |
<?php |
9 | 88 |
if ( current_user_can( 'upload_files' ) ) { |
89 |
?> |
|
90 |
<a href="<?php echo admin_url( 'media-new.php' ); ?>" class="page-title-action aria-button-if-js"><?php echo esc_html_x( 'Add New', 'file' ); ?></a> |
|
91 |
<?php |
|
5 | 92 |
} |
93 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
<hr class="wp-header-end"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
96 |
|
5 | 97 |
<div class="error hide-if-js"> |
9 | 98 |
<p> |
99 |
<?php |
|
100 |
printf( |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
101 |
/* translators: %s: list view URL */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
102 |
__( 'The grid view for the Media Library requires JavaScript. <a href="%s">Switch to the list view</a>.' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
103 |
'upload.php?mode=list' |
9 | 104 |
); |
105 |
?> |
|
106 |
</p> |
|
5 | 107 |
</div> |
108 |
</div> |
|
109 |
<?php |
|
110 |
include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
111 |
exit; |
|
112 |
} |
|
113 |
||
9 | 114 |
$wp_list_table = _get_list_table( 'WP_Media_List_Table' ); |
115 |
$pagenum = $wp_list_table->get_pagenum(); |
|
0 | 116 |
|
117 |
// Handle bulk actions |
|
118 |
$doaction = $wp_list_table->current_action(); |
|
119 |
||
120 |
if ( $doaction ) { |
|
9 | 121 |
check_admin_referer( 'bulk-media' ); |
0 | 122 |
|
123 |
if ( 'delete_all' == $doaction ) { |
|
124 |
$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" ); |
|
125 |
$doaction = 'delete'; |
|
126 |
} elseif ( isset( $_REQUEST['media'] ) ) { |
|
127 |
$post_ids = $_REQUEST['media']; |
|
128 |
} elseif ( isset( $_REQUEST['ids'] ) ) { |
|
129 |
$post_ids = explode( ',', $_REQUEST['ids'] ); |
|
130 |
} |
|
131 |
||
132 |
$location = 'upload.php'; |
|
133 |
if ( $referer = wp_get_referer() ) { |
|
9 | 134 |
if ( false !== strpos( $referer, 'upload.php' ) ) { |
0 | 135 |
$location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer ); |
9 | 136 |
} |
0 | 137 |
} |
138 |
||
139 |
switch ( $doaction ) { |
|
5 | 140 |
case 'detach': |
141 |
wp_media_attach_action( $_REQUEST['parent_post_id'], 'detach' ); |
|
0 | 142 |
break; |
143 |
||
5 | 144 |
case 'attach': |
145 |
wp_media_attach_action( $_REQUEST['found_post_id'] ); |
|
146 |
break; |
|
0 | 147 |
|
148 |
case 'trash': |
|
9 | 149 |
if ( ! isset( $post_ids ) ) { |
0 | 150 |
break; |
9 | 151 |
} |
0 | 152 |
foreach ( (array) $post_ids as $post_id ) { |
9 | 153 |
if ( ! current_user_can( 'delete_post', $post_id ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
154 |
wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) ); |
9 | 155 |
} |
0 | 156 |
|
9 | 157 |
if ( ! wp_trash_post( $post_id ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
158 |
wp_die( __( 'Error in moving to Trash.' ) ); |
9 | 159 |
} |
0 | 160 |
} |
9 | 161 |
$location = add_query_arg( |
162 |
array( |
|
163 |
'trashed' => count( $post_ids ), |
|
164 |
'ids' => join( ',', $post_ids ), |
|
165 |
), |
|
166 |
$location |
|
167 |
); |
|
0 | 168 |
break; |
169 |
case 'untrash': |
|
9 | 170 |
if ( ! isset( $post_ids ) ) { |
0 | 171 |
break; |
9 | 172 |
} |
0 | 173 |
foreach ( (array) $post_ids as $post_id ) { |
9 | 174 |
if ( ! current_user_can( 'delete_post', $post_id ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
175 |
wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) ); |
9 | 176 |
} |
0 | 177 |
|
9 | 178 |
if ( ! wp_untrash_post( $post_id ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
179 |
wp_die( __( 'Error in restoring from Trash.' ) ); |
9 | 180 |
} |
0 | 181 |
} |
182 |
$location = add_query_arg( 'untrashed', count( $post_ids ), $location ); |
|
183 |
break; |
|
184 |
case 'delete': |
|
9 | 185 |
if ( ! isset( $post_ids ) ) { |
0 | 186 |
break; |
9 | 187 |
} |
0 | 188 |
foreach ( (array) $post_ids as $post_id_del ) { |
9 | 189 |
if ( ! current_user_can( 'delete_post', $post_id_del ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
190 |
wp_die( __( 'Sorry, you are not allowed to delete this item.' ) ); |
9 | 191 |
} |
0 | 192 |
|
9 | 193 |
if ( ! wp_delete_attachment( $post_id_del ) ) { |
0 | 194 |
wp_die( __( 'Error in deleting.' ) ); |
9 | 195 |
} |
0 | 196 |
} |
197 |
$location = add_query_arg( 'deleted', count( $post_ids ), $location ); |
|
198 |
break; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
199 |
default: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
200 |
/** This action is documented in wp-admin/edit-comments.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
201 |
$location = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $location, $doaction, $post_ids ); |
0 | 202 |
} |
203 |
||
204 |
wp_redirect( $location ); |
|
205 |
exit; |
|
206 |
} elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { |
|
9 | 207 |
wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
208 |
exit; |
|
0 | 209 |
} |
210 |
||
211 |
$wp_list_table->prepare_items(); |
|
212 |
||
9 | 213 |
$title = __( 'Media Library' ); |
0 | 214 |
$parent_file = 'upload.php'; |
215 |
||
216 |
wp_enqueue_script( 'media' ); |
|
217 |
||
5 | 218 |
add_screen_option( 'per_page' ); |
0 | 219 |
|
9 | 220 |
get_current_screen()->add_help_tab( |
221 |
array( |
|
222 |
'id' => 'overview', |
|
223 |
'title' => __( 'Overview' ), |
|
224 |
'content' => |
|
225 |
'<p>' . __( 'All the files you’ve uploaded are listed in the Media Library, with the most recent uploads listed first. You can use the Screen Options tab to customize the display of this screen.' ) . '</p>' . |
|
226 |
'<p>' . __( 'You can narrow the list by file type/status or by date using the dropdown menus above the media table.' ) . '</p>' . |
|
227 |
'<p>' . __( 'You can view your media in a simple visual grid or a list with columns. Switch between these views using the icons to the left above the media.' ) . '</p>', |
|
228 |
) |
|
229 |
); |
|
230 |
get_current_screen()->add_help_tab( |
|
231 |
array( |
|
232 |
'id' => 'actions-links', |
|
233 |
'title' => __( 'Available Actions' ), |
|
234 |
'content' => |
|
235 |
'<p>' . __( 'Hovering over a row reveals action links: Edit, Delete Permanently, and View. Clicking Edit or on the media file’s name displays a simple screen to edit that individual file’s metadata. Clicking Delete Permanently will delete the file from the media library (as well as from any posts to which it is currently attached). View will take you to the display page for that file.' ) . '</p>', |
|
236 |
) |
|
237 |
); |
|
238 |
get_current_screen()->add_help_tab( |
|
239 |
array( |
|
240 |
'id' => 'attaching-files', |
|
241 |
'title' => __( 'Attaching Files' ), |
|
242 |
'content' => |
|
243 |
'<p>' . __( 'If a media file has not been attached to any content, you will see that in the Uploaded To column, and can click on Attach to launch a small popup that will allow you to search for existing content and attach the file.' ) . '</p>', |
|
244 |
) |
|
245 |
); |
|
0 | 246 |
|
247 |
get_current_screen()->set_help_sidebar( |
|
248 |
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
249 |
'<p>' . __( '<a href="https://codex.wordpress.org/Media_Library_Screen">Documentation on Media Library</a>' ) . '</p>' . |
9 | 250 |
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
0 | 251 |
); |
252 |
||
9 | 253 |
get_current_screen()->set_screen_reader_content( |
254 |
array( |
|
255 |
'heading_views' => __( 'Filter media items list' ), |
|
256 |
'heading_pagination' => __( 'Media items list navigation' ), |
|
257 |
'heading_list' => __( 'Media items list' ), |
|
258 |
) |
|
259 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
260 |
|
0 | 261 |
require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
262 |
?> |
|
263 |
||
264 |
<div class="wrap"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
265 |
<h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
266 |
|
0 | 267 |
<?php |
9 | 268 |
if ( current_user_can( 'upload_files' ) ) { |
269 |
?> |
|
270 |
<a href="<?php echo admin_url( 'media-new.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'file' ); ?></a> |
|
271 |
<?php |
|
0 | 272 |
} |
7
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 |
if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
/* translators: %s: search keywords */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
276 |
printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', get_search_query() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
277 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
278 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
279 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
280 |
<hr class="wp-header-end"> |
0 | 281 |
|
282 |
<?php |
|
283 |
$message = ''; |
|
284 |
if ( ! empty( $_GET['posted'] ) ) { |
|
9 | 285 |
$message = __( 'Media file updated.' ); |
286 |
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'posted' ), $_SERVER['REQUEST_URI'] ); |
|
0 | 287 |
} |
288 |
||
289 |
if ( ! empty( $_GET['attached'] ) && $attached = absint( $_GET['attached'] ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
290 |
if ( 1 == $attached ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
291 |
$message = __( 'Media file attached.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
/* translators: %s: number of media files */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
294 |
$message = _n( '%s media file attached.', '%s media files attached.', $attached ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
295 |
} |
9 | 296 |
$message = sprintf( $message, number_format_i18n( $attached ) ); |
5 | 297 |
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] ); |
298 |
} |
|
299 |
||
300 |
if ( ! empty( $_GET['detach'] ) && $detached = absint( $_GET['detach'] ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
301 |
if ( 1 == $detached ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
302 |
$message = __( 'Media file detached.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
303 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
304 |
/* translators: %s: number of media files */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
305 |
$message = _n( '%s media file detached.', '%s media files detached.', $detached ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
306 |
} |
9 | 307 |
$message = sprintf( $message, number_format_i18n( $detached ) ); |
5 | 308 |
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] ); |
0 | 309 |
} |
310 |
||
311 |
if ( ! empty( $_GET['deleted'] ) && $deleted = absint( $_GET['deleted'] ) ) { |
|
5 | 312 |
if ( 1 == $deleted ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
313 |
$message = __( 'Media file permanently deleted.' ); |
5 | 314 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
/* translators: %s: number of media files */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
$message = _n( '%s media file permanently deleted.', '%s media files permanently deleted.', $deleted ); |
5 | 317 |
} |
9 | 318 |
$message = sprintf( $message, number_format_i18n( $deleted ) ); |
319 |
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'deleted' ), $_SERVER['REQUEST_URI'] ); |
|
0 | 320 |
} |
321 |
||
322 |
if ( ! empty( $_GET['trashed'] ) && $trashed = absint( $_GET['trashed'] ) ) { |
|
5 | 323 |
if ( 1 == $trashed ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
324 |
$message = __( 'Media file moved to the trash.' ); |
5 | 325 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
326 |
/* translators: %s: number of media files */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
327 |
$message = _n( '%s media file moved to the trash.', '%s media files moved to the trash.', $trashed ); |
5 | 328 |
} |
9 | 329 |
$message = sprintf( $message, number_format_i18n( $trashed ) ); |
330 |
$message .= ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ) . '">' . __( 'Undo' ) . '</a>'; |
|
331 |
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'trashed' ), $_SERVER['REQUEST_URI'] ); |
|
0 | 332 |
} |
333 |
||
334 |
if ( ! empty( $_GET['untrashed'] ) && $untrashed = absint( $_GET['untrashed'] ) ) { |
|
5 | 335 |
if ( 1 == $untrashed ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
336 |
$message = __( 'Media file restored from the trash.' ); |
5 | 337 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
/* translators: %s: number of media files */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
$message = _n( '%s media file restored from the trash.', '%s media files restored from the trash.', $untrashed ); |
5 | 340 |
} |
9 | 341 |
$message = sprintf( $message, number_format_i18n( $untrashed ) ); |
342 |
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'untrashed' ), $_SERVER['REQUEST_URI'] ); |
|
0 | 343 |
} |
344 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
345 |
$messages[1] = __( 'Media file updated.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
$messages[2] = __( 'Media file permanently deleted.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
$messages[3] = __( 'Error saving media file.' ); |
9 | 348 |
$messages[4] = __( 'Media file moved to the trash.' ) . ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ) . '">' . __( 'Undo' ) . '</a>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
$messages[5] = __( 'Media file restored from the trash.' ); |
0 | 350 |
|
351 |
if ( ! empty( $_GET['message'] ) && isset( $messages[ $_GET['message'] ] ) ) { |
|
9 | 352 |
$message = $messages[ $_GET['message'] ]; |
353 |
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message' ), $_SERVER['REQUEST_URI'] ); |
|
0 | 354 |
} |
355 |
||
9 | 356 |
if ( ! empty( $message ) ) { |
357 |
?> |
|
5 | 358 |
<div id="message" class="updated notice is-dismissible"><p><?php echo $message; ?></p></div> |
0 | 359 |
<?php } ?> |
360 |
||
5 | 361 |
<form id="posts-filter" method="get"> |
362 |
||
0 | 363 |
<?php $wp_list_table->views(); ?> |
364 |
||
365 |
<?php $wp_list_table->display(); ?> |
|
366 |
||
367 |
<div id="ajax-response"></div> |
|
368 |
<?php find_posts_div(); ?> |
|
369 |
</form> |
|
370 |
</div> |
|
371 |
||
372 |
<?php |
|
373 |
include( ABSPATH . 'wp-admin/admin-footer.php' ); |