Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/09/2021 06:10:51 PM (4 years ago)
Author:
imath
Message:

Admin: improve information about WP pages being used as BP directories

We are now using BuddyPress specific post states to inform a WordPress page is used as the BP Component's directory page. This information is displayed into the WP Admin Pages edit screen, for menu items linking to a BP Directory into the WP Admin Menu screen as well as into the Customizer Menu section.

Fixes #8470

File:
1 edited

Legend:

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

    r12606 r13123  
    6060add_action( 'bp_admin_menu', 'bp_admin_separator' );
    6161
     62// Add a filter to include BP Components directory pages display states.
     63add_filter( 'display_post_states', 'bp_admin_display_directory_states', 10, 2 );
     64
    6265/**
    6366 * When a new site is created in a multisite installation, run the activation
     
    235238    do_action( 'bp_register_admin_settings' );
    236239}
     240
     241/**
     242 * Dedicated filter to inform about BP components directory page states.
     243 *
     244 * @since 10.0.0
     245 *
     246 * @param string[] $post_states An array of post display states.
     247 * @param WP_Post  $post        The current post object.
     248 */
     249function bp_admin_display_directory_states( $post_states = array(), $post = null ) {
     250    /**
     251     * Filter here to add BP Directory pages.
     252     *
     253     * Used internaly by BP_Component->admin_directory_states(). Please use the dynamic
     254     * filter in BP_Component->admin_directory_states() to edit the directory state
     255     * according to the component's ID.
     256     *
     257     * @since 10.0.0
     258     *
     259     * @param array    $value An empty array.
     260     * @param WP_Post  $post  The current post object.
     261     */
     262    $directory_page_states = apply_filters( 'bp_admin_display_directory_states', array(), $post );
     263
     264    if ( $directory_page_states ) {
     265        $post_states = array_merge( $post_states, $directory_page_states );
     266    }
     267
     268    return $post_states;
     269}
Note: See TracChangeset for help on using the changeset viewer.