X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/9e77185fafaf4e60e2b73821e0e4b9b1a11fb85f..7f1521bf193b382565eb753043c161f4cb3fcda7:/wp-admin/includes/class-wp-media-list-table.php diff --git a/wp-admin/includes/class-wp-media-list-table.php b/wp-admin/includes/class-wp-media-list-table.php index 237c99d1..9ebd5c0c 100644 --- a/wp-admin/includes/class-wp-media-list-table.php +++ b/wp-admin/includes/class-wp-media-list-table.php @@ -9,6 +9,10 @@ */ class WP_Media_List_Table extends WP_List_Table { + private $detached; + + private $is_trash; + /** * Constructor. * @@ -22,6 +26,11 @@ class WP_Media_List_Table extends WP_List_Table { public function __construct( $args = array() ) { $this->detached = ( isset( $_REQUEST['attachment-filter'] ) && 'detached' === $_REQUEST['attachment-filter'] ); + $this->modes = array( + 'list' => __( 'List View' ), + 'grid' => __( 'Grid View' ) + ); + parent::__construct( array( 'plural' => 'media', 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, @@ -70,7 +79,7 @@ class WP_Media_List_Table extends WP_List_Table { if ( !empty( $_GET['attachment-filter'] ) && strpos( $_GET['attachment-filter'], 'post_mime_type:' ) === 0 && wp_match_mime_types( $mime_type, str_replace( 'post_mime_type:', '', $_GET['attachment-filter'] ) ) ) $selected = ' selected="selected"'; if ( !empty( $num_posts[$mime_type] ) ) - $type_links[$mime_type] = ''; + $type_links[$mime_type] = ''; } $type_links['detached'] = ''; @@ -82,13 +91,26 @@ class WP_Media_List_Table extends WP_List_Table { protected function get_bulk_actions() { $actions = array(); - $actions['delete'] = __( 'Delete Permanently' ); + if ( MEDIA_TRASH ) { + if ( $this->is_trash ) { + $actions['untrash'] = __( 'Restore' ); + $actions['delete'] = __( 'Delete Permanently' ); + } else { + $actions['trash'] = __( 'Trash' ); + } + } else { + $actions['delete'] = __( 'Delete Permanently' ); + } + if ( $this->detached ) $actions['attach'] = __( 'Attach to a post' ); return $actions; } + /** + * @param string $which + */ protected function extra_tablenav( $which ) { if ( 'bar' !== $which ) { return; @@ -117,6 +139,9 @@ class WP_Media_List_Table extends WP_List_Table { if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) return 'attach'; + if ( isset( $_REQUEST['parent_post_id'] ) && isset( $_REQUEST['media'] ) ) + return 'detach'; + if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) return 'delete_all'; @@ -131,44 +156,6 @@ class WP_Media_List_Table extends WP_List_Table { _e( 'No media attachments found.' ); } - protected function pagination( $which ) { - global $mode; - - parent::pagination( $which ); - } - - /** - * Display a view switcher - * - * @since 3.1.0 - * @access protected - */ - protected function view_switcher( $current_mode ) { - $modes = array( - 'list' => __( 'List View' ), - 'grid' => __( 'Grid View' ) - ); - -?> - -
- $title ) { - $classes = array( 'view-' . $mode ); - if ( $current_mode == $mode ) - $classes[] = 'current'; - printf( - "%s\n", - esc_url( add_query_arg( 'mode', $mode ) ), - implode( ' ', $classes ), - $title - ); - } - ?> -
-get_views(); ?>
- view_switcher( $mode ); ?> +
+ view_switcher( $mode ); ?> - + $view ) { + echo "\t$view\n"; + } } - } - ?> - + ?> + extra_tablenav( 'bar' ); + $this->extra_tablenav( 'bar' ); - /** This filter is documented in wp-admin/inclues/class-wp-list-table.php */ - $views = apply_filters( "views_{$this->screen->id}", array() ); + /** This filter is documented in wp-admin/inclues/class-wp-list-table.php */ + $views = apply_filters( "views_{$this->screen->id}", array() ); - // Back compat for pre-4.0 view links. - if ( ! empty( $views ) ) { - echo ''; - } ?> +
@@ -282,7 +272,6 @@ class WP_Media_List_Table extends WP_List_Table { global $post; add_filter( 'the_title','esc_html' ); - $alt = ''; while ( have_posts() ) : the_post(); $user_can_edit = current_user_can( 'edit_post', $post->ID ); @@ -291,11 +280,10 @@ class WP_Media_List_Table extends WP_List_Table { || !$this->is_trash && $post->post_status == 'trash' ) continue; - $alt = ( 'alternate' == $alt ) ? '' : 'alternate'; $post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other'; $att_title = _draft_or_post_title(); ?> - + get_column_info(); @@ -331,7 +319,7 @@ foreach ( $columns as $column_name => $column_display_name ) { echo $thumb; } else { ?> - + @@ -348,19 +336,12 @@ foreach ( $columns as $column_name => $column_display_name ) { is_trash || ! $user_can_edit ) { echo $att_title; } else { ?> - -

-ID ), $matches ) ) - echo esc_html( strtoupper( $matches[1] ) ); - else - echo strtoupper( str_replace( 'image/', '', get_post_mime_type() ) ); -?> -

+

guid ); ?>

row_actions( $this->_get_row_actions( $post, $att_title ) ); ?> @@ -422,7 +403,16 @@ foreach ( $columns as $column_name => $column_display_name ) { } else { echo $title; } ?>, - +
+ $post->post_parent, + 'media[]' => $post->ID, + '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] ) + ), 'upload.php' ); ?> + + $column_display_name ) { break; } ?> - > - - ID ); ?> - + >ID ); + ?> $column_display_name ) { detached ) { if ( current_user_can( 'edit_post', $post->ID ) ) - $actions['edit'] = '' . __( 'Edit' ) . ''; + $actions['edit'] = '' . __( 'Edit' ) . ''; if ( current_user_can( 'delete_post', $post->ID ) ) if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { $actions['trash'] = "ID ) . "'>" . __( 'Trash' ) . ""; @@ -529,7 +521,7 @@ foreach ( $columns as $column_name => $column_display_name ) { } else { if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash ) - $actions['edit'] = '' . __( 'Edit' ) . ''; + $actions['edit'] = '' . __( 'Edit' ) . ''; if ( current_user_can( 'delete_post', $post->ID ) ) { if ( $this->is_trash ) $actions['untrash'] = "ID ) . "'>" . __( 'Restore' ) . "";