Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/24/2024 05:29:42 PM (10 months ago)
Author:
imath
Message:

Manage BP specific WP List Tables pagination from a central function

  • Introduces bp_admin_set_screen_options() to deal with WP List Table pagination

for Activity, Groups, Opt-outs & Site Invitations.

  • Deprecates bp_activity_admin_screen_options() & bp_groups_admin_screen_options().

Props emaralive

Fixes #9195
Closes https://github.com/buddypress/buddypress/pull/320

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-admin.php

    r13890 r13937  
    1717if ( ! class_exists( 'WP_List_Table' ) ) {
    1818    require ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
    19 }
    20 
    21 // The per_page screen option. Has to be hooked in extremely early.
    22 if ( is_admin() && ! empty( $_REQUEST['page'] ) && 'bp-groups' == $_REQUEST['page'] ) {
    23     add_filter( 'set-screen-option', 'bp_groups_admin_screen_options', 10, 3 );
    2419}
    2520
     
    525520
    526521/**
    527  * Handle save/update of screen options for the Groups component admin screen.
    528  *
    529  * @since 1.7.0
    530  *
    531  * @param string $value     Will always be false unless another plugin filters it first.
    532  * @param string $option    Screen option name.
    533  * @param string $new_value Screen option form value.
    534  * @return string|int Option value. False to abandon update.
    535  */
    536 function bp_groups_admin_screen_options( $value, $option, $new_value ) {
    537     if ( 'toplevel_page_bp_groups_per_page' != $option && 'toplevel_page_bp_groups_network_per_page' != $option ) {
    538         return $value;
    539     }
    540 
    541     // Per page.
    542     $new_value = (int) $new_value;
    543     if ( $new_value < 1 || $new_value > 999 ) {
    544         return $value;
    545     }
    546 
    547     return $new_value;
    548 }
    549 
    550 /**
    551522 * Select the appropriate Groups admin screen, and output it.
    552523 *
Note: See TracChangeset for help on using the changeset viewer.