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/admin/bp-core-admin-slugs.php src/bp-core/admin/bp-core-admin-slugs.php
index 52ef6e36c..432b6f409 100644
|
|
|
function bp_core_admin_slugs_options() { |
| 117 | 117 | // Set up an array of components (along with component names) that have directory pages. |
| 118 | 118 | $directory_pages = bp_core_admin_get_directory_pages(); |
| 119 | 119 | |
| 120 | | if ( !empty( $directory_pages ) ) : ?> |
| | 120 | if ( ! empty( $directory_pages ) ) : ?> |
| 121 | 121 | |
| 122 | | <h3><?php _e( 'Directories', 'buddypress' ); ?></h3> |
| | 122 | <h3><?php esc_html_e( 'Directories', 'buddypress' ); ?></h3> |
| 123 | 123 | |
| 124 | | <p><?php _e( 'Associate a WordPress Page with each BuddyPress component directory.', 'buddypress' ); ?></p> |
| | 124 | <p><?php esc_html_e( 'Associate a WordPress Page with each BuddyPress component directory.', 'buddypress' ); ?></p> |
| 125 | 125 | |
| 126 | 126 | <table class="form-table"> |
| 127 | 127 | <tbody> |
| … |
… |
function bp_core_admin_slugs_options() { |
| 141 | 141 | 'name' => 'bp_pages[' . esc_attr( $name ) . ']', |
| 142 | 142 | 'echo' => false, |
| 143 | 143 | 'show_option_none' => __( '- None -', 'buddypress' ), |
| 144 | | 'selected' => !empty( $existing_pages[$name] ) ? $existing_pages[$name] : false |
| | 144 | 'selected' => ! empty( $existing_pages[$name] ) ? $existing_pages[$name] : false |
| 145 | 145 | ) ); ?> |
| 146 | 146 | |
| 147 | 147 | <?php if ( ! empty( $existing_pages[ $name ] ) && get_post( $existing_pages[ $name ] ) ) : ?> |
| 148 | 148 | |
| 149 | 149 | <a href="<?php echo esc_url( get_permalink( $existing_pages[$name] ) ); ?>" class="button-secondary" target="_bp"> |
| 150 | | <?php _e( 'View', 'buddypress' ); ?> <span class="dashicons dashicons-external" aria-hidden="true"></span> |
| | 150 | <?php esc_html_e( 'View', 'buddypress' ); ?> <span class="dashicons dashicons-external" aria-hidden="true"></span> |
| 151 | 151 | <span class="screen-reader-text"><?php esc_html_e( '(opens in a new tab)', 'buddypress' ); ?></span> |
| 152 | 152 | </a> |
| 153 | 153 | |
| … |
… |
function bp_core_admin_slugs_options() { |
| 185 | 185 | |
| 186 | 186 | if ( !empty( $static_pages ) ) : ?> |
| 187 | 187 | |
| 188 | | <h3><?php _e( 'Registration', 'buddypress' ); ?></h3> |
| | 188 | <h3><?php esc_html_e( 'Registration', 'buddypress' ); ?></h3> |
| 189 | 189 | |
| 190 | 190 | <?php if ( bp_get_signup_allowed() || bp_get_members_invitations_allowed() ) : ?> |
| 191 | | <p><?php _e( 'Associate WordPress Pages with the following BuddyPress Registration pages.', 'buddypress' ); ?></p> |
| | 191 | <p> |
| | 192 | <?php esc_html_e( 'Associate WordPress Pages with the following BuddyPress Registration pages.', 'buddypress' ); ?> |
| | 193 | <?php esc_html_e( 'These pages will only be reachable by users who are not logged in.', 'buddypress' ); ?> |
| | 194 | </p> |
| 192 | 195 | <?php else : ?> |
| 193 | 196 | <?php if ( is_multisite() ) : ?> |
| 194 | 197 | <p> |
| 195 | 198 | <?php |
| 196 | | /* translators: %s: the link to the Network settings page */ |
| 197 | | printf( __( 'Registration is currently disabled. Before associating a page is allowed, please enable registration by selecting either the "User accounts may be registered" or "Both sites and user accounts can be registered" option on <a href="%s">this page</a>.', 'buddypress' ), network_admin_url( 'settings.php' ) ); |
| | 199 | printf( |
| | 200 | /* translators: %s: the link to the Network settings page */ |
| | 201 | esc_html_x( 'Registration is currently disabled. Before associating a page is allowed, please enable registration by selecting either the "User accounts may be registered" or "Both sites and user accounts can be registered" option on %s.', 'Disabled registration message for multisite config', 'buddypress' ), |
| | 202 | sprintf( |
| | 203 | '<a href="%1$s">%2$s</a>', |
| | 204 | esc_url( network_admin_url( 'settings.php' ) ), |
| | 205 | esc_html_x( 'this page', 'Link text for the Multisite’s network settings page', 'buddypress' ) |
| | 206 | ) |
| | 207 | ); |
| 198 | 208 | ?> |
| 199 | 209 | </p> |
| 200 | 210 | <?php else : ?> |
| 201 | 211 | <p> |
| 202 | 212 | <?php |
| 203 | | /* translators: %s: the link to the Site settings page */ |
| 204 | | printf( __( 'Registration is currently disabled. Before associating a page is allowed, please enable registration by clicking on the "Anyone can register" checkbox on <a href="%s">this page</a>.', 'buddypress' ), admin_url( 'options-general.php' ) ); |
| | 213 | printf( |
| | 214 | /* translators: %s: the link to the Site general options page */ |
| | 215 | esc_html_x( 'Registration is currently disabled. Before associating a page is allowed, please enable registration by clicking on the "Anyone can register" checkbox on %s.', 'Disabled registration message for regular site config', 'buddypress' ), |
| | 216 | sprintf( |
| | 217 | '<a href="%1$s">%2$s</a>', |
| | 218 | esc_url( admin_url( 'options-general.php' ) ), |
| | 219 | esc_html_x( 'this page', 'Link text for the Site’s general options page', 'buddypress' ) |
| | 220 | ) |
| | 221 | ); |
| 205 | 222 | ?> |
| 206 | 223 | </p> |
| 207 | 224 | <?php endif; ?> |
| … |
… |
function bp_core_admin_slugs_options() { |
| 228 | 245 | 'selected' => !empty( $existing_pages[$name] ) ? $existing_pages[$name] : false |
| 229 | 246 | ) ) ?> |
| 230 | 247 | |
| 231 | | <?php if ( ! empty( $existing_pages[ $name ] ) && get_post( $existing_pages[ $name ] ) ) : ?> |
| 232 | | |
| 233 | | <a href="<?php echo get_permalink( $existing_pages[$name] ); ?>" class="button-secondary" target="_bp"><?php _e( 'View', 'buddypress' ); ?></a> |
| 234 | | |
| 235 | | <?php endif; ?> |
| 236 | | |
| 237 | 248 | <?php if ( ! bp_is_root_blog() ) restore_current_blog(); ?> |
| 238 | 249 | |
| 239 | 250 | </td> |
| … |
… |
function bp_core_admin_slugs_options() { |
| 266 | 277 | function bp_core_admin_slugs_setup_handler() { |
| 267 | 278 | |
| 268 | 279 | if ( isset( $_POST['bp-admin-pages-submit'] ) ) { |
| 269 | | if ( !check_admin_referer( 'bp-admin-pages-setup' ) ) |
| | 280 | if ( ! check_admin_referer( 'bp-admin-pages-setup' ) ) { |
| 270 | 281 | return false; |
| | 282 | } |
| 271 | 283 | |
| 272 | 284 | // Then, update the directory pages. |
| 273 | 285 | if ( isset( $_POST['bp_pages'] ) ) { |
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 | } |