Example #1
0
/**
 * Executes a query for attachments. An array of WP_Query arguments
 * can be passed in, which will override the arguments set by this function.
 *
 * @since 2.5.0
 *
 * @param array|false $q Array of query variables to use to build the query or false to use $_GET superglobal.
 * @return array
 */
function wp_edit_attachments_query($q = false)
{
    wp(wp_edit_attachments_query_vars($q));
    $post_mime_types = get_post_mime_types();
    $avail_post_mime_types = get_available_post_mime_types('attachment');
    return array($post_mime_types, $avail_post_mime_types);
}
Example #2
0
    wp_die(__('You do not have permission to upload files.'));
}
$mode = get_user_option('media_library_mode', get_current_user_id()) ? get_user_option('media_library_mode', get_current_user_id()) : 'grid';
$modes = array('grid', 'list');
if (isset($_GET['mode']) && in_array($_GET['mode'], $modes)) {
    $mode = $_GET['mode'];
    update_user_option(get_current_user_id(), 'media_library_mode', $mode);
}
if ('grid' === $mode) {
    wp_enqueue_media();
    wp_enqueue_script('media-grid');
    wp_enqueue_script('media');
    $q = $_GET;
    // let JS handle this
    unset($q['s']);
    $vars = wp_edit_attachments_query_vars($q);
    $ignore = array('mode', 'post_type', 'post_status', 'posts_per_page');
    foreach ($vars as $key => $value) {
        if (!$value || in_array($key, $ignore)) {
            unset($vars[$key]);
        }
    }
    wp_localize_script('media-grid', '_wpMediaGridSettings', array('adminUrl' => parse_url(self_admin_url(), PHP_URL_PATH), 'queryVars' => (object) $vars));
    get_current_screen()->add_help_tab(array('id' => 'overview', 'title' => __('Overview'), 'content' => '<p>' . __('All the files you&#8217;ve uploaded are listed in the Media Library, with the most recent uploads listed first.') . '</p>' . '<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>' . '<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>'));
    get_current_screen()->add_help_tab(array('id' => 'attachment-details', 'title' => __('Attachment Details'), 'content' => '<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>' . '<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>' . '<p>' . __('You can also delete individual items and access the extended edit screen from the details dialog.') . '</p>'));
    get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:') . '</strong></p>' . '<p>' . __('<a href="https://codex.wordpress.org/Media_Library_Screen" target="_blank">Documentation on Media Library</a>') . '</p>' . '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>');
    $title = __('Media Library');
    $parent_file = 'upload.php';
    require_once ABSPATH . 'wp-admin/admin-header.php';
    ?>
	<div class="wrap" id="wp-media-grid" data-search="<?php