diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index 4ecc65141b..a13cc269d3 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -194,54 +194,9 @@ if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQU } ?> +views(); ?> +
- - +views(); ?> + - - -
  • " . sprintf( _nx( 'Mine (%s)', 'Mine (%s)', $user_posts_count, 'posts' ), number_format_i18n( $user_posts_count ) ) . ''; + $allposts = '&all_posts=1'; + } + + $total_posts = array_sum( (array) $num_posts ); + + // Subtract post types that are not included in the admin all list. + foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state ) + $total_posts -= $num_posts->$state; + + $class = empty($class) && empty($_REQUEST['post_status']) ? ' class="current"' : ''; + $status_links['all'] = "
  • " . sprintf( _nx( 'All (%s)', 'All (%s)', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . ''; + + foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) { + $class = ''; + + $status_name = $status->name; + + if ( !in_array( $status_name, $avail_post_stati ) ) + continue; + + if ( empty( $num_posts->$status_name ) ) + continue; + + if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] ) + $class = ' class="current"'; + + $status_links[$status_name] = "
  • " . sprintf( _n( $status->label_count[0], $status->label_count[1], $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . ''; + } + + return $status_links; + } + function get_bulk_actions() { $actions = array(); @@ -943,6 +1004,40 @@ class WP_Media_Table extends WP_List_Table { ) ); } + function get_views() { + global $wpdb, $post_mime_types, $detached, $avail_post_mime_types; + + $type_links = array(); + $_num_posts = (array) wp_count_attachments(); + $_total_posts = array_sum($_num_posts) - $_num_posts['trash']; + if ( !isset( $total_orphans ) ) + $total_orphans = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1" ); + $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); + foreach ( $matches as $type => $reals ) + foreach ( $reals as $real ) + $num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real]; + + $class = ( empty($_GET['post_mime_type']) && !$detached && !isset($_GET['status']) ) ? ' class="current"' : ''; + $type_links['all'] = "
  • " . sprintf( _nx( 'All (%s)', 'All (%s)', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . ''; + foreach ( $post_mime_types as $mime_type => $label ) { + $class = ''; + + if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) ) + continue; + + if ( !empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) + $class = ' class="current"'; + if ( !empty( $num_posts[$mime_type] ) ) + $type_links[$mime_type] = "
  • " . sprintf( _n( $label[2][0], $label[2][1], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . ''; + } + $type_links['detached'] = '
  • ' . sprintf( _nx( 'Unattached (%s)', 'Unattached (%s)', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . ''; + + if ( !empty($_num_posts['trash']) ) + $type_links['trash'] = '
  • ' . sprintf( _nx( 'Trash (%s)', 'Trash (%s)', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . ''; + + return $type_links; + } + function get_bulk_actions() { global $detached; @@ -1651,8 +1746,6 @@ class WP_Terms_Table extends WP_List_Table { class WP_Users_Table extends WP_List_Table { function WP_Users_Table() { - global $role, $usersearch; - parent::WP_List_Table( array( 'screen' => 'users', 'plural' => 'users' @@ -1665,6 +1758,8 @@ class WP_Users_Table extends WP_List_Table { } function prepare_items() { + global $role, $usersearch; + $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : ''; @@ -1701,6 +1796,38 @@ class WP_Users_Table extends WP_List_Table { _e( 'No matching users were found.' ); } + function get_views() { + global $wp_roles, $role; + + $users_of_blog = count_users(); + $total_users = $users_of_blog['total_users']; + $avail_roles =& $users_of_blog['avail_roles']; + unset($users_of_blog); + + $current_role = false; + $class = empty($role) ? ' class="current"' : ''; + $role_links = array(); + $role_links['all'] = "
  • " . sprintf( _nx( 'All (%s)', 'All (%s)', $total_users, 'users' ), number_format_i18n( $total_users ) ) . ''; + foreach ( $wp_roles->get_names() as $this_role => $name ) { + if ( !isset($avail_roles[$this_role]) ) + continue; + + $class = ''; + + if ( $this_role == $role ) { + $current_role = $role; + $class = ' class="current"'; + } + + $name = translate_user_role( $name ); + /* translators: User role name with count */ + $name = sprintf( __('%1$s (%2$s)'), $name, $avail_roles[$this_role] ); + $role_links[$this_role] = "
  • $name"; + } + + return $role_links; + } + function get_bulk_actions() { $actions = array(); @@ -1957,6 +2084,51 @@ class WP_Comments_Table extends WP_List_Table { ) ); } + function get_views() { + global $post_id, $comment_status; + + $status_links = array(); + $num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments(); + //, number_format_i18n($num_comments->moderated) ), "" . number_format_i18n($num_comments->moderated) . ""), + //, number_format_i18n($num_comments->spam) ), "" . number_format_i18n($num_comments->spam) . "") + $stati = array( + 'all' => _nx_noop('All', 'All', 'comments'), // singular not used + 'moderated' => _n_noop('Pending (%s)', 'Pending (%s)'), + 'approved' => _n_noop('Approved', 'Approved'), // singular not used + 'spam' => _n_noop('Spam (%s)', 'Spam (%s)'), + 'trash' => _n_noop('Trash (%s)', 'Trash (%s)') + ); + + if ( !EMPTY_TRASH_DAYS ) + unset($stati['trash']); + + $link = 'edit-comments.php'; + if ( !empty($comment_type) && 'all' != $comment_type ) + $link = add_query_arg( 'comment_type', $comment_type, $link ); + + foreach ( $stati as $status => $label ) { + $class = ( $status == $comment_status ) ? ' class="current"' : ''; + + if ( !isset( $num_comments->$status ) ) + $num_comments->$status = 10; + $link = add_query_arg( 'comment_status', $status, $link ); + if ( $post_id ) + $link = add_query_arg( 'p', absint( $post_id ), $link ); + /* + // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark + if ( !empty( $_REQUEST['s'] ) ) + $link = add_query_arg( 's', esc_attr( stripslashes( $_REQUEST['s'] ) ), $link ); + */ + $status_links[$status] = "
  • " . sprintf( + _n( $label[0], $label[1], $num_comments->$status ), + number_format_i18n( $num_comments->$status ) + ) . ''; + } + + $status_links = apply_filters( 'comment_status_links', $status_links ); + return $status_links; + } + function get_bulk_actions() { global $comment_status; @@ -3169,6 +3341,54 @@ class WP_Plugins_Table extends WP_List_Table { parent::display_tablenav( $which ); } + function get_views() { + global $totals, $status; + + $status_links = array(); + foreach ( $totals as $type => $count ) { + if ( !$count ) + continue; + + switch ( $type ) { + case 'all': + $text = _nx( 'All (%s)', 'All (%s)', $count, 'plugins' ); + break; + case 'active': + $text = _n( 'Active (%s)', 'Active (%s)', $count ); + break; + case 'recently_activated': + $text = _n( 'Recently Active (%s)', 'Recently Active (%s)', $count ); + break; + case 'inactive': + $text = _n( 'Inactive (%s)', 'Inactive (%s)', $count ); + break; + case 'network': + $text = _n( 'Network (%s)', 'Network (%s)', $count ); + break; + case 'mustuse': + $text = _n( 'Must-Use (%s)', 'Must-Use (%s)', $count ); + break; + case 'dropins': + $text = _n( 'Drop-ins (%s)', 'Drop-ins (%s)', $count ); + break; + case 'upgrade': + $text = _n( 'Upgrade Available (%s)', 'Upgrade Available (%s)', $count ); + break; + case 'search': + $text = _n( 'Search Results (%s)', 'Search Results (%s)', $count ); + break; + } + + $status_links[$type] = sprintf( "
  • %s", + add_query_arg('plugin_status', $type, 'plugins.php'), + ( $type == $status ) ? ' class="current"' : '', + sprintf( $text, number_format_i18n( $count ) ) + ); + } + + return $status_links; + } + function get_bulk_actions() { global $status; @@ -3427,6 +3647,19 @@ class WP_Plugin_Install_Table extends WP_List_Table { _e( 'No plugins match your request.' ); } + function get_views() { + global $tabs, $tab; + + $display_tabs = array(); + foreach ( (array) $tabs as $action => $text ) { + $class = ( $action == $tab ) ? ' class="current"' : ''; + $href = admin_url('plugin-install.php?tab=' . $action); + $display_tabs[$action] = "$text"; + } + + return $display_tabs; + } + function display_tablenav( $which ) { if ( 'top' == $which ) { ?>
    @@ -3799,7 +4032,20 @@ class WP_Theme_Install_Table extends WP_List_Table { function no_items() { _e( 'No themes match your request.' ); } - + + function get_views() { + global $tabs, $tab; + + $display_tabs = array(); + foreach ( (array) $tabs as $action => $text ) { + $class = ( $action == $tab ) ? ' class="current"' : ''; + $href = admin_url('theme-install.php?tab=' . $action); + $display_tabs[$action] = "$text"; + } + + return $display_tabs; + } + function get_columns() { return array(); } diff --git a/wp-admin/includes/list-table.php b/wp-admin/includes/list-table.php index 564c36c573..7551686d43 100644 --- a/wp-admin/includes/list-table.php +++ b/wp-admin/includes/list-table.php @@ -173,6 +173,37 @@ class WP_List_Table { _e( 'No items found.' ); } + /** + * Get an associative array ( id => link ) with the list + * of views available on this table. + * + * @since 3.1.0 + * @access protected + * + * @return array + */ + function get_views() { + return array(); + } + + /** + * Display the bulk actions dropdown. + * + * @since 3.1.0 + * @access public + */ + function views() { + $views = $this->get_views(); + $views = apply_filters( 'views_' . $this->_screen->base, $views ); + + if ( empty( $views ) ) + return; + + echo "
      \n"; + echo implode( " |\n", $views ) . "\n"; + echo "
    "; + } + /** * Get an associative array ( option_name => option_title ) with the list * of bulk actions available on this table. diff --git a/wp-admin/plugin-install.php b/wp-admin/plugin-install.php index 53bf99033c..f5483c315c 100644 --- a/wp-admin/plugin-install.php +++ b/wp-admin/plugin-install.php @@ -41,19 +41,11 @@ include('./admin-header.php');

    -
      - $text ) { - $sep = ( end($tabs) != $text ) ? ' | ' : ''; - $class = ( $action == $tab ) ? ' class="current"' : ''; - $href = admin_url('plugin-install.php?tab=' . $action); - echo "\t\t
    • $text$sep
    • \n"; -} -?> -
    -
    - +views(); ?> + +
    +
    +views(); ?> + - -

    ' . __( 'Files in the /wp-content/mu-plugins directory are executed automatically.' ) . '

    '; diff --git a/wp-admin/theme-install.php b/wp-admin/theme-install.php index 2ab0892f9b..fe17ab1e59 100644 --- a/wp-admin/theme-install.php +++ b/wp-admin/theme-install.php @@ -41,19 +41,10 @@ include('./admin-header.php');

    - -
    - +views(); ?> + +
    +

    - +views(); ?>
    - -
      -" . sprintf( _nx( 'All (%s)', 'All (%s)', $total_users, 'users' ), number_format_i18n( $total_users ) ) . ''; -foreach ( $wp_roles->get_names() as $this_role => $name ) { - if ( !isset($avail_roles[$this_role]) ) - continue; - - $class = ''; - - if ( $this_role == $role ) { - $current_role = $role; - $class = ' class="current"'; - } - - $name = translate_user_role( $name ); - /* translators: User role name with count */ - $name = sprintf( __('%1$s (%2$s)'), $name, $avail_roles[$this_role] ); - $role_links[] = "
    • $name"; -} -echo implode( " |
    • \n", $role_links) . ''; -unset($role_links); -?> -
    - -
    +views(); ?>