Skip to:
Content

BuddyPress.org

Ticket #8734: 8734.02.feedback.patch

File 8734.02.feedback.patch, 7.8 KB (added by imath, 3 years ago)
  • src/bp-core/bp-core-community-visibility.php

    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 
    126126add_filter( 'bp_activity_enable_feeds', 'bp_community_visibility_rss_feed_access_protection', 10, 2 );
    127127
    128128/**
    129  * Get the community visibility value calculated from the 
     129 * Get the community visibility value calculated from the
    130130 * saved visibility setting.
    131131 *
    132132 * @since 12.0.0
    133133 *
    134  * @param string $component Whether we want the visibility for a component 
     134 * @param string $component Whether we want the visibility for a component
    135135 *                          or for all components.
    136  * 
     136 *
    137137 * @return arrary|string $retval The calculated visbility settings for the site.
    138138 */
    139139function bp_community_visibility_get_visibility( $component = 'all' ) {
    140140        $retval      = 'anyone';
    141         $saved_value = get_option( '_bp_community_visibility' );
     141        $saved_value = (array) get_option( '_bp_community_visibility', array() );
    142142
    143143        // If the global value has not been set, we assume that the site is open.
    144144        if ( ! isset( $saved_value['global'] ) ) {
    function bp_community_visibility_get_visibility( $component = 'all' ) { 
    147147
    148148        if ( 'all' === $component ) {
    149149                // Build the component list.
    150                 $retval = array( 
    151                         'global' => $saved_value['global'] 
     150                $retval = array(
     151                        'global' => $saved_value['global']
    152152                );
    153153                $directory_pages = bp_core_get_directory_pages();
    154154                foreach ( $directory_pages as $component_id => $component_page ) {
    function bp_community_visibility_get_visibility( $component = 'all' ) { 
    164164        }
    165165
    166166        /**
    167          * Filter the community visibility value calculated from the 
     167         * Filter the community visibility value calculated from the
    168168         * saved visibility setting.
    169169         *
    170170         * @since 12.0.0
    function bp_community_visibility_get_visibility( $component = 'all' ) { 
    177177
    178178/**
    179179 * Sanitize the visibility setting when it is saved.
    180  * 
     180 *
    181181 * @since 12.0.0
    182  * 
     182 *
    183183 * @param mixed $saved_value The value passed to the save function.
    184184 */
    185185function bp_community_visibility_sanitize_setting( $saved_value ) {
  • src/bp-core/bp-core-functions.php

    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 
    991991                $pages = get_posts(
    992992                        array(
    993993                                'post__not_in' => array( $post_ID ),
    994                                 'post_status'  => array( 'publish', 'bp_restricted' ),
     994                                'post_status'  => bp_core_get_directory_pages_stati(),
    995995                                'post_type'    => array( 'buddypress', 'page' ),
    996996                        )
    997997                );
  • src/bp-core/classes/class-bp-component.php

    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 { 
    12571257         *
    12581258         * @since 12.0.0
    12591259         *
    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.
    12621262         * @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.
    12641264         */
    1265         public function pre_query( $retval = null, $query = null ) {
     1265        public function pre_query( $posts = null, $query = null ) {
    12661266                remove_filter( 'posts_pre_query', array( $this, 'pre_query' ), 10 );
    12671267
    12681268                $queried_object = $query->get_queried_object();
    class BP_Component { 
    12711271                        $component = bp_core_get_component_from_directory_page_id( $queried_object->ID );
    12721272                        if ( $component && bp_current_user_can( 'bp_read', array( 'bp_component' => $component ) ) ) {
    12731273                                // Only include the queried directory post into returned posts.
    1274                                 $retval = array( $queried_object );
     1274                                $posts = array( $queried_object );
    12751275
    12761276                                // Reset some query flags.
    12771277                                $query->is_home       = false;
    class BP_Component { 
    13041304                                        'ID'             => 0,
    13051305                                        'post_type'      => 'buddypress',
    13061306                                        'post_name'      => 'restricted',
    1307                                         'post_title'     => __( 'Members-only area', 'bp-rewrites' ),
     1307                                        'post_title'     => __( 'Members-only area', 'buddypress' ),
    13081308                                        'post_content'   => bp_buffer_template_part( 'assets/utils/restricted-access-message', null, false ),
    13091309                                        'comment_status' => 'closed',
    13101310                                        'comment_count'  => 0,
    class BP_Component { 
    13151315                                $query->queried_object_id = $query->queried_object->ID;
    13161316
    13171317                                // Reset the posts.
    1318                                 $retval = array( $query->queried_object );
     1318                                $posts = array( $query->queried_object );
    13191319
    13201320                                // Reset some WP Query properties.
    13211321                                $query->found_posts   = 1;
    class BP_Component { 
    13321332
    13331333                                // Make sure no comments are displayed for this page.
    13341334                                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                                 // }
    13401335                        }
    13411336
    1342                         return $retval;
     1337                        return $posts;
    13431338                }
    13441339        }
    13451340
  • src/bp-core/classes/class-bp-core.php

    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 { 
    397397                parent::register_post_types();
    398398        }
    399399
    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 
    418400        /**
    419401         * Parse the WP_Query and eventually set the BP Search mechanism.
    420402         *
  • src/bp-templates/bp-legacy/buddypress/assets/utils/restricted-access-message.php

    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' ) ) { 
    1414}
    1515?>
    1616<!-- 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>
    1818<!-- /wp:paragraph -->
    1919
    2020<!-- wp:columns -->
  • src/bp-templates/bp-nouveau/buddypress/assets/utils/restricted-access-message.php

    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' ) ) { 
    1414}
    1515?>
    1616<!-- 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>
    1818<!-- /wp:paragraph -->
    1919
    2020<!-- wp:columns -->