wp-admin/upload.php


Lines:

201 to 300 of 468
	<div class="wrap" id="wp-media-grid" data-search="<?php _admin_search_query(); ?>">
		<h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>

		<?php
    if ( current_user_can( 'upload_files' ) ) {
      ?>
			<a href="<?php echo esc_url( admin_url( 'media-new.php' ) ); ?>" class="page-title-action aria-button-if-js"><?php echo esc_html__( 'Add New Media File' ); ?></a>
			<?php
    }
    ?>

		<hr class="wp-header-end">

		<?php
    if ( ! empty( $message ) ) {
      wp_admin_notice(
        $message,
        array(
          'id'                 => 'message',
          'additional_classes' => array( 'updated' ),
          'dismissible'        => true,
        )
      );
    }

    $js_required_message = sprintf(
      /* translators: %s: List view URL. */
      __( 'The grid view for the Media Library requires JavaScript. <a href="%s">Switch to the list view</a>.' ),
      'upload.php?mode=list'
    );
    wp_admin_notice(
      $js_required_message,
      array(
        'additional_classes' => array( 'error', 'hide-if-js' ),
      )
    );
    ?>
	</div>
	<?php
  require_once ABSPATH . 'wp-admin/admin-footer.php';
  exit;
}

$wp_list_table = _get_list_table( 'WP_Media_List_Table' );
$pagenum       = $wp_list_table->get_pagenum();

// Handle bulk actions.
$doaction = $wp_list_table->current_action();

if ( $doaction ) {
  check_admin_referer( 'bulk-media' );

  $post_ids = array();

  if ( 'delete_all' === $doaction ) {
    $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
    $doaction = 'delete';
  } elseif ( isset( $_REQUEST['media'] ) ) {
    $post_ids = $_REQUEST['media'];
  } elseif ( isset( $_REQUEST['ids'] ) ) {
    $post_ids = explode( ',', $_REQUEST['ids'] );
  }
  $post_ids = array_map( 'intval', (array) $post_ids );

  $location = 'upload.php';
  $referer  = wp_get_referer();
  if ( $referer ) {
    if ( str_contains( $referer, 'upload.php' ) ) {
      $location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer );
    }
  }

  switch ( $doaction ) {
    case 'detach':
      wp_media_attach_action( $_REQUEST['parent_post_id'], 'detach' );
      break;

    case 'attach':
      wp_media_attach_action( $_REQUEST['found_post_id'] );
      break;

    case 'trash':
      if ( empty( $post_ids ) ) {
        break;
      }
      foreach ( $post_ids as $post_id ) {
        if ( ! current_user_can( 'delete_post', $post_id ) ) {
          wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) );
        }

        if ( ! wp_trash_post( $post_id ) ) {

 View on GitHub View on Trac

Called by

    Invoked by

      API Letters: ,,,