Making WordPress.org


Ignore:
Timestamp:
03/24/2016 10:38:23 PM (9 years ago)
Author:
obenland
Message:

Plugin Directory: Handle list view links in Plugin_Posts class.

Overwrites WP_Posts_List_Table's get_views() method, taking plugins into
account that the current user might not have authored, but has commit access to.

See #1570, #1571.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-customizations.php

    r2792 r2798  
    3131        add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
    3232        add_action( 'save_post_plugin', array( $this, 'save_plugin_post' ), 10, 2 );
    33         add_filter( 'views_edit-plugin', array( $this, 'list_table_views' ) );
    3433
    3534        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
     
    163162        $where = preg_replace( "!\s(\S+\.post_name IN .+?)\s*AND\s*(\s\S+\.post_author.+?)AND!i", ' ( $1 OR $2 ) AND', $where );
    164163        return $where;
    165     }
    166 
    167     public function list_table_views( $views ) {
    168         global $wp_query;
    169         if ( current_user_can( 'plugin_edit_others' ) ) {
    170             return $views;
    171         }
    172         // The only view the user needs, is their own.
    173         return array(
    174             sprintf(
    175                 '<a href="#" class="current">%s</a>',
    176                 sprintf(
    177                     _nx(
    178                         'Mine <span class="count">(%s)</span>',
    179                         'Mine <span class="count">(%s)</span>',
    180                         $wp_query->found_posts,
    181                         'posts',
    182                         'wporg-posts'
    183                     ),
    184                     number_format_i18n( $wp_query->found_posts )
    185                 )
    186             )
    187         );
    188164    }
    189165
Note: See TracChangeset for help on using the changeset viewer.