diff --git src/bp-activity/classes/class-bp-activity-component.php src/bp-activity/classes/class-bp-activity-component.php
index d44879fd3..93f441351 100644
|
|
|
class BP_Activity_Component extends BP_Component { |
| 502 | 502 | ) |
| 503 | 503 | ); |
| 504 | 504 | } |
| | 505 | |
| | 506 | /** |
| | 507 | * Add the Activity directory state. |
| | 508 | * |
| | 509 | * @since 8.0.0 |
| | 510 | * |
| | 511 | * @param array $states Optional. See BP_Component::admin_directory_states() for description. |
| | 512 | * @param WP_Post $post Optional. See BP_Component::admin_directory_states() for description. |
| | 513 | * @return array See BP_Component::admin_directory_states() for description. |
| | 514 | */ |
| | 515 | public function admin_directory_states( $states = array(), $post = null ) { |
| | 516 | $bp = buddypress(); |
| | 517 | |
| | 518 | if ( isset( $bp->pages->activity->id ) && (int) $bp->pages->activity->id === (int) $post->ID ) { |
| | 519 | $states['page_for_activity_directory'] = _x( 'BP Activity Page', 'page label', 'buddypress' ); |
| | 520 | } |
| | 521 | |
| | 522 | return parent::admin_directory_states( $states, $post ); |
| | 523 | } |
| 505 | 524 | } |
diff --git src/bp-blogs/classes/class-bp-blogs-component.php src/bp-blogs/classes/class-bp-blogs-component.php
index 9ad5e6d1f..749c91ef0 100644
|
|
|
class BP_Blogs_Component extends BP_Component { |
| 379 | 379 | |
| 380 | 380 | parent::rest_api_init( $controllers ); |
| 381 | 381 | } |
| | 382 | |
| | 383 | /** |
| | 384 | * Add the Sites directory states. |
| | 385 | * |
| | 386 | * @since 8.0.0 |
| | 387 | * |
| | 388 | * @param array $states Optional. See BP_Component::admin_directory_states() for description. |
| | 389 | * @param WP_Post $post Optional. See BP_Component::admin_directory_states() for description. |
| | 390 | * @return array See BP_Component::admin_directory_states() for description. |
| | 391 | */ |
| | 392 | public function admin_directory_states( $states = array(), $post = null ) { |
| | 393 | $bp = buddypress(); |
| | 394 | |
| | 395 | if ( isset( $bp->pages->blogs->id ) && (int) $bp->pages->blogs->id === (int) $post->ID ) { |
| | 396 | $states['page_for_sites_directory'] = _x( 'BP Sites Page', 'page label', 'buddypress' ); |
| | 397 | } |
| | 398 | |
| | 399 | return parent::admin_directory_states( $states, $post ); |
| | 400 | } |
| 382 | 401 | } |
diff --git src/bp-core/admin/bp-core-admin-actions.php src/bp-core/admin/bp-core-admin-actions.php
index 68e5d30b0..3c7fae966 100644
|
|
|
add_action( 'bp_admin_init', 'bp_do_activation_redirect', 1 ); |
| 59 | 59 | // Add a new separator. |
| 60 | 60 | add_action( 'bp_admin_menu', 'bp_admin_separator' ); |
| 61 | 61 | |
| | 62 | // Add a filter to include BP Components directory pages display states. |
| | 63 | add_filter( 'display_post_states', 'bp_admin_display_directory_states', 10, 2 ); |
| | 64 | |
| 62 | 65 | /** |
| 63 | 66 | * When a new site is created in a multisite installation, run the activation |
| 64 | 67 | * routine on that site. |
| … |
… |
function bp_register_admin_settings() { |
| 234 | 237 | */ |
| 235 | 238 | do_action( 'bp_register_admin_settings' ); |
| 236 | 239 | } |
| | 240 | |
| | 241 | /** |
| | 242 | * Dedicated filter to inform about BP components directory page states. |
| | 243 | * |
| | 244 | * @since 8.0.0 |
| | 245 | * |
| | 246 | * @param string[] $post_states An array of post display states. |
| | 247 | * @param WP_Post $post The current post object. |
| | 248 | */ |
| | 249 | function 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 8.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 | } |
diff --git src/bp-core/classes/class-bp-component.php src/bp-core/classes/class-bp-component.php
index ee3dfde6d..7349a6722 100644
|
|
|
class BP_Component { |
| 471 | 471 | add_action( 'bp_blocks_init', array( $this, 'blocks_init' ), 10 ); |
| 472 | 472 | } |
| 473 | 473 | |
| | 474 | // Set directory page states. |
| | 475 | add_filter( 'bp_admin_display_directory_states', array( $this, 'admin_directory_states' ), 10, 2 ); |
| | 476 | |
| 474 | 477 | /** |
| 475 | 478 | * Fires at the end of the setup_actions method inside BP_Component. |
| 476 | 479 | * |
| … |
… |
class BP_Component { |
| 946 | 949 | */ |
| 947 | 950 | do_action( 'bp_' . $this->id . '_blocks_init' ); |
| 948 | 951 | } |
| | 952 | |
| | 953 | /** |
| | 954 | * Add component's directory states. |
| | 955 | * |
| | 956 | * @since 8.0.0 |
| | 957 | * |
| | 958 | * @param string[] $states An array of post display states. |
| | 959 | * @param WP_Post $post The current post object. |
| | 960 | * @return array The component's directory states. |
| | 961 | */ |
| | 962 | public function admin_directory_states( $states = array(), $post = null ) { |
| | 963 | if ( $this->has_directory ) { |
| | 964 | /** |
| | 965 | * Filter here to edit the component's directory states. |
| | 966 | * |
| | 967 | * This is a dynamic hook that is based on the component string ID. |
| | 968 | * |
| | 969 | * @since 8.0.0 |
| | 970 | * |
| | 971 | * @param string[] $states An array of post display states. |
| | 972 | */ |
| | 973 | return apply_filters( 'bp_' . $this->id . '_admin_directory_states', $states ); |
| | 974 | } |
| | 975 | |
| | 976 | return $states; |
| | 977 | } |
| 949 | 978 | } |
| 950 | 979 | endif; // BP_Component. |
diff --git src/bp-groups/classes/class-bp-groups-component.php src/bp-groups/classes/class-bp-groups-component.php
index d15a7cb58..ea852d93d 100644
|
|
|
class BP_Groups_Component extends BP_Component { |
| 1064 | 1064 | ) |
| 1065 | 1065 | ); |
| 1066 | 1066 | } |
| | 1067 | |
| | 1068 | /** |
| | 1069 | * Add the Groups directory states. |
| | 1070 | * |
| | 1071 | * @since 8.0.0 |
| | 1072 | * |
| | 1073 | * @param array $states Optional. See BP_Component::admin_directory_states() for description. |
| | 1074 | * @param WP_Post $post Optional. See BP_Component::admin_directory_states() for description. |
| | 1075 | * @return array See BP_Component::admin_directory_states() for description. |
| | 1076 | */ |
| | 1077 | public function admin_directory_states( $states = array(), $post = null ) { |
| | 1078 | $bp = buddypress(); |
| | 1079 | |
| | 1080 | if ( isset( $bp->pages->groups->id ) && (int) $bp->pages->groups->id === (int) $post->ID ) { |
| | 1081 | $states['page_for_groups_directory'] = _x( 'BP Groups Page', 'page label', 'buddypress' ); |
| | 1082 | } |
| | 1083 | |
| | 1084 | return parent::admin_directory_states( $states, $post ); |
| | 1085 | } |
| 1067 | 1086 | } |
diff --git src/bp-members/classes/class-bp-members-component.php src/bp-members/classes/class-bp-members-component.php
index 8effd0cf0..7ce8b3752 100644
|
|
|
class BP_Members_Component extends BP_Component { |
| 835 | 835 | ) |
| 836 | 836 | ); |
| 837 | 837 | } |
| | 838 | |
| | 839 | /** |
| | 840 | * Add the Members directory states. |
| | 841 | * |
| | 842 | * @since 8.0.0 |
| | 843 | * |
| | 844 | * @param array $states Optional. See BP_Component::admin_directory_states() for description. |
| | 845 | * @param WP_Post $post Optional. See BP_Component::admin_directory_states() for description. |
| | 846 | * @return array See BP_Component::admin_directory_states() for description. |
| | 847 | */ |
| | 848 | public function admin_directory_states( $states = array(), $post = null ) { |
| | 849 | $bp = buddypress(); |
| | 850 | |
| | 851 | if ( isset( $bp->pages->members->id ) && (int) $bp->pages->members->id === (int) $post->ID ) { |
| | 852 | $states['page_for_members_directory'] = _x( 'BP Members Page', 'page label', 'buddypress' ); |
| | 853 | } |
| | 854 | |
| | 855 | if ( bp_get_signup_allowed() || bp_get_members_invitations_allowed() ) { |
| | 856 | if ( isset( $bp->pages->register->id ) && (int) $bp->pages->register->id === (int) $post->ID ) { |
| | 857 | $states['page_for_bp_registration'] = _x( 'BP Registration Page', 'page label', 'buddypress' ); |
| | 858 | } |
| | 859 | |
| | 860 | if ( isset( $bp->pages->activate->id ) && (int) $bp->pages->activate->id === (int) $post->ID ) { |
| | 861 | $states['page_for_bp_activation'] = _x( 'BP Activation Page', 'page label', 'buddypress' ); |
| | 862 | } |
| | 863 | } |
| | 864 | |
| | 865 | return parent::admin_directory_states( $states, $post ); |
| | 866 | } |
| 838 | 867 | } |