wp/wp-admin/upload.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    85 		<h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
    85 		<h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
    86 
    86 
    87 		<?php
    87 		<?php
    88 		if ( current_user_can( 'upload_files' ) ) {
    88 		if ( current_user_can( 'upload_files' ) ) {
    89 			?>
    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>
    90 			<a href="<?php echo esc_url( admin_url( 'media-new.php' ) ); ?>" class="page-title-action aria-button-if-js"><?php echo esc_html_x( 'Add New', 'file' ); ?></a>
    91 								<?php
    91 			<?php
    92 		}
    92 		}
    93 		?>
    93 		?>
    94 
    94 
    95 		<hr class="wp-header-end">
    95 		<hr class="wp-header-end">
    96 
    96 
   118 $doaction = $wp_list_table->current_action();
   118 $doaction = $wp_list_table->current_action();
   119 
   119 
   120 if ( $doaction ) {
   120 if ( $doaction ) {
   121 	check_admin_referer( 'bulk-media' );
   121 	check_admin_referer( 'bulk-media' );
   122 
   122 
       
   123 	$post_ids = array();
       
   124 
   123 	if ( 'delete_all' === $doaction ) {
   125 	if ( 'delete_all' === $doaction ) {
   124 		$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
   126 		$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
   125 		$doaction = 'delete';
   127 		$doaction = 'delete';
   126 	} elseif ( isset( $_REQUEST['media'] ) ) {
   128 	} elseif ( isset( $_REQUEST['media'] ) ) {
   127 		$post_ids = $_REQUEST['media'];
   129 		$post_ids = $_REQUEST['media'];
   145 		case 'attach':
   147 		case 'attach':
   146 			wp_media_attach_action( $_REQUEST['found_post_id'] );
   148 			wp_media_attach_action( $_REQUEST['found_post_id'] );
   147 			break;
   149 			break;
   148 
   150 
   149 		case 'trash':
   151 		case 'trash':
   150 			if ( ! isset( $post_ids ) ) {
   152 			if ( empty( $post_ids ) ) {
   151 				break;
   153 				break;
   152 			}
   154 			}
   153 			foreach ( (array) $post_ids as $post_id ) {
   155 			foreach ( (array) $post_ids as $post_id ) {
   154 				if ( ! current_user_can( 'delete_post', $post_id ) ) {
   156 				if ( ! current_user_can( 'delete_post', $post_id ) ) {
   155 					wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) );
   157 					wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) );
   160 				}
   162 				}
   161 			}
   163 			}
   162 			$location = add_query_arg(
   164 			$location = add_query_arg(
   163 				array(
   165 				array(
   164 					'trashed' => count( $post_ids ),
   166 					'trashed' => count( $post_ids ),
   165 					'ids'     => join( ',', $post_ids ),
   167 					'ids'     => implode( ',', $post_ids ),
   166 				),
   168 				),
   167 				$location
   169 				$location
   168 			);
   170 			);
   169 			break;
   171 			break;
   170 		case 'untrash':
   172 		case 'untrash':
   171 			if ( ! isset( $post_ids ) ) {
   173 			if ( empty( $post_ids ) ) {
   172 				break;
   174 				break;
   173 			}
   175 			}
   174 			foreach ( (array) $post_ids as $post_id ) {
   176 			foreach ( (array) $post_ids as $post_id ) {
   175 				if ( ! current_user_can( 'delete_post', $post_id ) ) {
   177 				if ( ! current_user_can( 'delete_post', $post_id ) ) {
   176 					wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) );
   178 					wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) );
   181 				}
   183 				}
   182 			}
   184 			}
   183 			$location = add_query_arg( 'untrashed', count( $post_ids ), $location );
   185 			$location = add_query_arg( 'untrashed', count( $post_ids ), $location );
   184 			break;
   186 			break;
   185 		case 'delete':
   187 		case 'delete':
   186 			if ( ! isset( $post_ids ) ) {
   188 			if ( empty( $post_ids ) ) {
   187 				break;
   189 				break;
   188 			}
   190 			}
   189 			foreach ( (array) $post_ids as $post_id_del ) {
   191 			foreach ( (array) $post_ids as $post_id_del ) {
   190 				if ( ! current_user_can( 'delete_post', $post_id_del ) ) {
   192 				if ( ! current_user_can( 'delete_post', $post_id_del ) ) {
   191 					wp_die( __( 'Sorry, you are not allowed to delete this item.' ) );
   193 					wp_die( __( 'Sorry, you are not allowed to delete this item.' ) );
   268 <h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
   270 <h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
   269 
   271 
   270 <?php
   272 <?php
   271 if ( current_user_can( 'upload_files' ) ) {
   273 if ( current_user_can( 'upload_files' ) ) {
   272 	?>
   274 	?>
   273 	<a href="<?php echo admin_url( 'media-new.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'file' ); ?></a>
   275 	<a href="<?php echo esc_url( admin_url( 'media-new.php' ) ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'file' ); ?></a>
   274 						<?php
   276 						<?php
   275 }
   277 }
   276 
   278 
   277 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
   279 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
   278 	/* translators: %s: Search query. */
   280 	echo '<span class="subtitle">';
   279 	printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', get_search_query() );
   281 	printf(
       
   282 		/* translators: %s: Search query. */
       
   283 		__( 'Search results for: %s' ),
       
   284 		'<strong>' . get_search_query() . '</strong>'
       
   285 	);
       
   286 	echo '</span>';
   280 }
   287 }
   281 ?>
   288 ?>
   282 
   289 
   283 <hr class="wp-header-end">
   290 <hr class="wp-header-end">
   284 
   291