Skip to:
Content

BuddyPress.org

Changeset 10579


Ignore:
Timestamp:
02/12/2016 06:22:37 AM (10 years ago)
Author:
imath
Message:

Signups Administration: improve the screen management

r10547 introduced some regressions by setting the screen ID to users or users-network :

  • It was not possible anymore to manage the displayed column inside the Screen options.
  • All costum columns added to the Users List Table using the filter manage_users_columns or manage_users-network_columns were also added to the Signups List Table.

To fix these and also make sure it is still possible to add custom views before and after the pending view, we are now using the Signups screen ID and introducing a new function to temporarly set the screen ID to users or users-network when needed.

Fixes #6872

Location:
trunk/src/bp-members/classes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/classes/class-bp-members-admin.php

    r10521 r10579  
    13251325     */
    13261326    public function signup_filter_view( $views = array() ) {
     1327        global $role;
    13271328
    13281329        // Remove the 'current' class from All if we're on the signups view.
    1329         if ( $this->signups_page == get_current_screen()->id ) {
     1330        if ( 'registered' === $role ) {
    13301331            $views['all'] = str_replace( 'class="current"', '', $views['all'] );
    13311332            $class        = 'current';
  • trunk/src/bp-members/classes/class-bp-members-list-table.php

    r10547 r10579  
    3838            'plural'   => 'signups',
    3939            'singular' => 'signup',
    40             'screen'   => buddypress()->members->admin->users_screen,
     40            'screen'   => get_current_screen()->id,
    4141        ) );
    4242    }
     
    8585
    8686    /**
    87      * Get the views (the links above the WP List Table).
    88      *
    89      * @since 2.0.0
    90      *
    91      * @uses WP_Users_List_Table::get_views() to get the users views.
    92      */
    93     public function get_views() {
    94         return parent::get_views();
     87     * Display the users screen views
     88     *
     89     * @since 2.5.0
     90     *
     91     * @global string $role The name of role the users screens is filtered by
     92     */
     93    public function views() {
     94        global $role;
     95
     96        // Used to reset the role
     97        $reset_role = $role;
     98
     99        // Temporarly set the role to registered
     100        $role = 'registered';
     101
     102        // Used to reset the screen id once views are displayed
     103        $reset_screen_id = $this->screen->id;
     104
     105        // Temporarly set the screen id to the users one
     106        $this->screen->id = 'users';
     107
     108        // Use the parent function so that other plugins can safely add views
     109        parent::views();
     110
     111        // Reset the role
     112        $role = $reset_role;
     113
     114        // Reset the screen id
     115        $this->screen->id = $reset_screen_id;
    95116    }
    96117
  • trunk/src/bp-members/classes/class-bp-members-ms-list-table.php

    r10547 r10579  
    3838            'plural'   => 'signups',
    3939            'singular' => 'signup',
    40             'screen'   => buddypress()->members->admin->users_screen,
     40            'screen'   => get_current_screen()->id,
    4141        ) );
    4242    }
     
    8686
    8787    /**
    88      * Get the views : the links above the WP List Table.
    89      *
    90      * @since 2.0.0
    91      *
    92      * @uses WP_MS_Users_List_Table::get_views() to get the users views.
    93      */
    94     public function get_views() {
    95         return parent::get_views();
     88     * Display the users screen views
     89     *
     90     * @since 2.5.0
     91     *
     92     * @global string $role The name of role the users screens is filtered by
     93     */
     94    public function views() {
     95        global $role;
     96
     97        // Used to reset the role
     98        $reset_role = $role;
     99
     100        // Temporarly set the role to registered
     101        $role = 'registered';
     102
     103        // Used to reset the screen id once views are displayed
     104        $reset_screen_id = $this->screen->id;
     105
     106        // Temporarly set the screen id to the users one
     107        $this->screen->id = 'users-network';
     108
     109        // Use the parent function so that other plugins can safely add views
     110        parent::views();
     111
     112        // Reset the role
     113        $role = $reset_role;
     114
     115        // Reset the screen id
     116        $this->screen->id = $reset_screen_id;
    96117    }
    97118
Note: See TracChangeset for help on using the changeset viewer.