diff --git src/bp-core/bp-core-community-visibility.php src/bp-core/bp-core-community-visibility.php
index 93c5e49ef..2e57be85f 100644
|
|
|
function bp_community_visibility_rss_feed_access_protection( $feed_enabled, $fee |
| 126 | 126 | add_filter( 'bp_activity_enable_feeds', 'bp_community_visibility_rss_feed_access_protection', 10, 2 ); |
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | | * Get the community visibility value calculated from the |
| | 129 | * Get the community visibility value calculated from the |
| 130 | 130 | * saved visibility setting. |
| 131 | 131 | * |
| 132 | 132 | * @since 12.0.0 |
| 133 | 133 | * |
| 134 | | * @param string $component Whether we want the visibility for a component |
| | 134 | * @param string $component Whether we want the visibility for a component |
| 135 | 135 | * or for all components. |
| 136 | | * |
| | 136 | * |
| 137 | 137 | * @return arrary|string $retval The calculated visbility settings for the site. |
| 138 | 138 | */ |
| 139 | 139 | function bp_community_visibility_get_visibility( $component = 'all' ) { |
| 140 | 140 | $retval = 'anyone'; |
| 141 | | $saved_value = get_option( '_bp_community_visibility' ); |
| | 141 | $saved_value = (array) get_option( '_bp_community_visibility', array() ); |
| 142 | 142 | |
| 143 | 143 | // If the global value has not been set, we assume that the site is open. |
| 144 | 144 | if ( ! isset( $saved_value['global'] ) ) { |
| … |
… |
function bp_community_visibility_get_visibility( $component = 'all' ) { |
| 147 | 147 | |
| 148 | 148 | if ( 'all' === $component ) { |
| 149 | 149 | // Build the component list. |
| 150 | | $retval = array( |
| 151 | | 'global' => $saved_value['global'] |
| | 150 | $retval = array( |
| | 151 | 'global' => $saved_value['global'] |
| 152 | 152 | ); |
| 153 | 153 | $directory_pages = bp_core_get_directory_pages(); |
| 154 | 154 | foreach ( $directory_pages as $component_id => $component_page ) { |
| … |
… |
function bp_community_visibility_get_visibility( $component = 'all' ) { |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
| 167 | | * Filter the community visibility value calculated from the |
| | 167 | * Filter the community visibility value calculated from the |
| 168 | 168 | * saved visibility setting. |
| 169 | 169 | * |
| 170 | 170 | * @since 12.0.0 |
| … |
… |
function bp_community_visibility_get_visibility( $component = 'all' ) { |
| 177 | 177 | |
| 178 | 178 | /** |
| 179 | 179 | * Sanitize the visibility setting when it is saved. |
| 180 | | * |
| | 180 | * |
| 181 | 181 | * @since 12.0.0 |
| 182 | | * |
| | 182 | * |
| 183 | 183 | * @param mixed $saved_value The value passed to the save function. |
| 184 | 184 | */ |
| 185 | 185 | function bp_community_visibility_sanitize_setting( $saved_value ) { |
diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php
index 68adf0672..253ebf51e 100644
|
|
|
function bp_core_set_unique_directory_page_slug( $slug = '', $post_ID = 0, $post |
| 991 | 991 | $pages = get_posts( |
| 992 | 992 | array( |
| 993 | 993 | 'post__not_in' => array( $post_ID ), |
| 994 | | 'post_status' => array( 'publish', 'bp_restricted' ), |
| | 994 | 'post_status' => bp_core_get_directory_pages_stati(), |
| 995 | 995 | 'post_type' => array( 'buddypress', 'page' ), |
| 996 | 996 | ) |
| 997 | 997 | ); |
diff --git src/bp-core/classes/class-bp-component.php src/bp-core/classes/class-bp-component.php
index 1f810a213..524a27142 100644
|
|
|
class BP_Component { |
| 1257 | 1257 | * |
| 1258 | 1258 | * @since 12.0.0 |
| 1259 | 1259 | * |
| 1260 | | * @param null $retval A null value to use the regular WP Query. |
| 1261 | | * @param WP_Query $query The WP Query object. |
| | 1260 | * @param null $posts A null value to use the regular WP Query. |
| | 1261 | * @param WP_Query $query The WP Query object. |
| 1262 | 1262 | * @return null|array Null if not displaying a BuddyPress page. |
| 1263 | | * An array containing the BuddyPress directory post otherwise. |
| | 1263 | * An array containing the BuddyPress directory page otherwise. |
| 1264 | 1264 | */ |
| 1265 | | public function pre_query( $retval = null, $query = null ) { |
| | 1265 | public function pre_query( $posts = null, $query = null ) { |
| 1266 | 1266 | remove_filter( 'posts_pre_query', array( $this, 'pre_query' ), 10 ); |
| 1267 | 1267 | |
| 1268 | 1268 | $queried_object = $query->get_queried_object(); |
| … |
… |
class BP_Component { |
| 1271 | 1271 | $component = bp_core_get_component_from_directory_page_id( $queried_object->ID ); |
| 1272 | 1272 | if ( $component && bp_current_user_can( 'bp_read', array( 'bp_component' => $component ) ) ) { |
| 1273 | 1273 | // Only include the queried directory post into returned posts. |
| 1274 | | $retval = array( $queried_object ); |
| | 1274 | $posts = array( $queried_object ); |
| 1275 | 1275 | |
| 1276 | 1276 | // Reset some query flags. |
| 1277 | 1277 | $query->is_home = false; |
| … |
… |
class BP_Component { |
| 1304 | 1304 | 'ID' => 0, |
| 1305 | 1305 | 'post_type' => 'buddypress', |
| 1306 | 1306 | 'post_name' => 'restricted', |
| 1307 | | 'post_title' => __( 'Members-only area', 'bp-rewrites' ), |
| | 1307 | 'post_title' => __( 'Members-only area', 'buddypress' ), |
| 1308 | 1308 | 'post_content' => bp_buffer_template_part( 'assets/utils/restricted-access-message', null, false ), |
| 1309 | 1309 | 'comment_status' => 'closed', |
| 1310 | 1310 | 'comment_count' => 0, |
| … |
… |
class BP_Component { |
| 1315 | 1315 | $query->queried_object_id = $query->queried_object->ID; |
| 1316 | 1316 | |
| 1317 | 1317 | // Reset the posts. |
| 1318 | | $retval = array( $query->queried_object ); |
| | 1318 | $posts = array( $query->queried_object ); |
| 1319 | 1319 | |
| 1320 | 1320 | // Reset some WP Query properties. |
| 1321 | 1321 | $query->found_posts = 1; |
| … |
… |
class BP_Component { |
| 1332 | 1332 | |
| 1333 | 1333 | // Make sure no comments are displayed for this page. |
| 1334 | 1334 | add_filter( 'comments_pre_query', 'bp_comments_pre_query', 10, 2 ); |
| 1335 | | |
| 1336 | | // @TODO: From bp-rewrites, meant to improve the button coloration. |
| 1337 | | // if ( function_exists( 'wp_get_global_styles' ) ) { |
| 1338 | | // add_action( 'bp_enqueue_community_scripts', __NAMESPACE__ . '\add_bp_login_block_inline_style' ); |
| 1339 | | // } |
| 1340 | 1335 | } |
| 1341 | 1336 | |
| 1342 | | return $retval; |
| | 1337 | return $posts; |
| 1343 | 1338 | } |
| 1344 | 1339 | } |
| 1345 | 1340 | |
diff --git src/bp-core/classes/class-bp-core.php src/bp-core/classes/class-bp-core.php
index 6c04ad080..396d39459 100644
|
|
|
class BP_Core extends BP_Component { |
| 397 | 397 | parent::register_post_types(); |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | | /** |
| 401 | | * Set up the component post statuses. |
| 402 | | * |
| 403 | | * @since 12.0.0 |
| 404 | | */ |
| 405 | | public function register_post_statuses() { |
| 406 | | register_post_status( |
| 407 | | 'bp_restricted', |
| 408 | | array( |
| 409 | | 'label' => _x( 'Restricted to members', '`buddypress` post type post status', 'buddypress' ), |
| 410 | | 'public' => false, |
| 411 | | 'internal' => true, |
| 412 | | ) |
| 413 | | ); |
| 414 | | |
| 415 | | parent::register_post_statuses(); |
| 416 | | } |
| 417 | | |
| 418 | 400 | /** |
| 419 | 401 | * Parse the WP_Query and eventually set the BP Search mechanism. |
| 420 | 402 | * |
diff --git src/bp-templates/bp-legacy/buddypress/assets/utils/restricted-access-message.php src/bp-templates/bp-legacy/buddypress/assets/utils/restricted-access-message.php
index aaf58ccc3..554f71e36 100644
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
| 14 | 14 | } |
| 15 | 15 | ?> |
| 16 | 16 | <!-- wp:paragraph {"align":"center"} --> |
| 17 | | <p class="has-text-align-center"><?php esc_html_e( 'This community area is accessible to logged-in members only.', 'bp-rewrites' ); ?></p> |
| | 17 | <p class="has-text-align-center"><?php esc_html_e( 'This community area is accessible to logged-in members only.', 'buddypress' ); ?></p> |
| 18 | 18 | <!-- /wp:paragraph --> |
| 19 | 19 | |
| 20 | 20 | <!-- wp:columns --> |
diff --git src/bp-templates/bp-nouveau/buddypress/assets/utils/restricted-access-message.php src/bp-templates/bp-nouveau/buddypress/assets/utils/restricted-access-message.php
index fc7ff8553..a995fe119 100644
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
| 14 | 14 | } |
| 15 | 15 | ?> |
| 16 | 16 | <!-- wp:paragraph {"align":"center"} --> |
| 17 | | <p class="has-text-align-center"><?php esc_html_e( 'This community area is accessible to logged-in members only.', 'bp-rewrites' ); ?></p> |
| | 17 | <p class="has-text-align-center"><?php esc_html_e( 'This community area is accessible to logged-in members only.', 'buddypress' ); ?></p> |
| 18 | 18 | <!-- /wp:paragraph --> |
| 19 | 19 | |
| 20 | 20 | <!-- wp:columns --> |