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-activity/bp-activity-admin.php

    r13871 r13937  
    1515
    1616// Include WP's list table class.
    17 if ( ! class_exists( 'WP_List_Table' ) ) require( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
    18 
    19 // Per_page screen option. Has to be hooked in extremely early.
    20 if ( is_admin() && ! empty( $_REQUEST['page'] ) && 'bp-activity' == $_REQUEST['page'] ) {
    21     add_filter( 'set-screen-option', 'bp_activity_admin_screen_options', 10, 3 );
     17if ( ! class_exists( 'WP_List_Table' ) ) {
     18    require ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
    2219}
    2320
     
    139136}
    140137add_action( 'wp_ajax_bp-activity-admin-reply', 'bp_activity_admin_reply' );
    141 
    142 /**
    143  * Handle save/update of screen options for the Activity component admin screen.
    144  *
    145  * @since 1.6.0
    146  *
    147  * @param string $value     Will always be false unless another plugin filters it first.
    148  * @param string $option    Screen option name.
    149  * @param string $new_value Screen option form value.
    150  * @return string|int Option value. False to abandon update.
    151  */
    152 function bp_activity_admin_screen_options( $value, $option, $new_value ) {
    153     if ( 'toplevel_page_bp_activity_per_page' != $option && 'toplevel_page_bp_activity_network_per_page' != $option )
    154         return $value;
    155 
    156     // Per page.
    157     $new_value = (int) $new_value;
    158     if ( $new_value < 1 || $new_value > 999 )
    159         return $value;
    160 
    161     return $new_value;
    162 }
    163138
    164139/**
Note: See TracChangeset for help on using the changeset viewer.