Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/27/2024 09:11:27 PM (15 months ago)
Author:
espellcaste
Message:

Include the V2 of the BP REST API in BuddyPress core.

We are officially deprecating the V1 of the BP REST API. And bundling the new, default, V2 of the BP REST API inside BuddyPress core. Previously, the V1 was developed as a plugin in a separate repo (https://github.com/buddypress/BP-REST).

  • One of the main differences between the V1 and V2 is how objects are returned. Single items are no longer returned as an array;
  • We have a new BP_Test_REST_Controller_Testcase for testing the new API endpoints;
  • We changed the names of our controllers to follow our autoloader rules;
  • Removed the BP-REST plugin from wp-env and from our release script;
  • And we added notices for the deprecated V1 API (endpoints and files).

Props imath & I. ;)

Fixes #8200
See #9145
Closes https://github.com/buddypress/buddypress/pull/337

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/classes/class-bp-members-component.php

    r14011 r14026  
    121121         * bp-members/bp-members-template.php.
    122122         */
    123         $signup_allowed = apply_filters( 'bp_get_signup_allowed', (bool) bp_get_option( 'users_can_register' ) );
     123        $signup_allowed              = apply_filters( 'bp_get_signup_allowed', (bool) bp_get_option( 'users_can_register' ) );
    124124        $membership_requests_enabled = (bool) bp_get_option( 'bp-enable-membership-requests' );
    125125        if ( bp_is_active( 'members', 'membership_requests' ) && ! $signup_allowed && $membership_requests_enabled ) {
     
    166166
    167167            // Action - Delete avatar.
    168             if ( is_user_logged_in()&& bp_is_user_change_avatar() && bp_is_action_variable( 'delete-avatar', 0 ) ) {
     168            if ( is_user_logged_in() && bp_is_user_change_avatar() && bp_is_action_variable( 'delete-avatar', 0 ) ) {
    169169                require_once $this->path . 'bp-members/actions/delete-avatar.php';
    170170            }
     
    216216
    217217        // Check the parsed query is consistent with the Members navigation.
    218         add_action( 'bp_parse_query',  array( $this, 'check_parsed_query' ), 999, 0 );
     218        add_action( 'bp_parse_query', array( $this, 'check_parsed_query' ), 999, 0 );
    219219    }
    220220
     
    281281         */
    282282
    283         $bp->signup = new stdClass;
     283        $bp->signup = new stdClass();
    284284
    285285        /** Profiles Fallback ************************************************
     
    287287
    288288        if ( ! bp_is_active( 'xprofile' ) ) {
    289             $bp->profile       = new stdClass;
     289            $bp->profile       = new stdClass();
    290290            $bp->profile->slug = 'profile';
    291291            $bp->profile->id   = 'profile';
     
    295295         */
    296296
    297         $bp->members->invitations = new stdClass;
     297        $bp->members->invitations = new stdClass();
    298298    }
    299299
     
    328328        // Fetch the default directory title.
    329329        $default_directory_titles = bp_core_get_directory_page_default_titles();
    330         $default_directory_title  = $default_directory_titles[$this->id];
     330        $default_directory_title  = $default_directory_titles[ $this->id ];
    331331
    332332        // Override any passed args.
    333333        $args = array(
    334             'slug'            => $default_slug,
    335             'root_slug'       => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : $default_slug,
    336             'has_directory'   => true,
    337             'rewrite_ids'     => array(
     334            'slug'                  => $default_slug,
     335            'root_slug'             => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : $default_slug,
     336            'has_directory'         => true,
     337            'rewrite_ids'           => array(
    338338                'directory'                    => 'members',
    339339                'directory_type'               => 'members_type',
     
    346346                'member_activate_key'          => 'activate_key',
    347347            ),
    348             'directory_title' => isset( $bp->pages->members->title ) ? $bp->pages->members->title : $default_directory_title,
    349             'search_string'   => __( 'Search Members...', 'buddypress' ),
    350             'global_tables'   => array(
     348            'directory_title'       => isset( $bp->pages->members->title ) ? $bp->pages->members->title : $default_directory_title,
     349            'search_string'         => __( 'Search Members...', 'buddypress' ),
     350            'global_tables'         => array(
    351351                'table_name_invitations'   => bp_core_get_table_prefix() . 'bp_invitations',
    352352                'table_name_last_activity' => bp_core_get_table_prefix() . 'bp_activity',
     
    359359                    'widget_classnames' => array( 'widget_bp_core_members_widget', 'buddypress' ),
    360360                ),
    361                 'bp/online-members' => array(
     361                'bp/online-members'  => array(
    362362                    'widget_classnames' => array( 'widget_bp_core_whos_online_widget', 'buddypress' ),
    363363                ),
    364                 'bp/active-members' => array(
     364                'bp/active-members'  => array(
    365365                    'widget_classnames' => array( 'widget_bp_core_recently_active_widget', 'buddypress' ),
    366366                ),
     
    616616                $wp_admin_nav = array_merge( $wp_admin_nav, $this->get_avatar_cover_image_admin_navs() );
    617617
    618             /**
    619             * The xProfile is active.
    620             *
    621             * Add the Change Avatar and Change Cover Image Admin Bar items
    622             * to the xProfile Admin Bar Menu.
    623             */
     618                /**
     619                * The xProfile is active.
     620                *
     621                * Add the Change Avatar and Change Cover Image Admin Bar items
     622                * to the xProfile Admin Bar Menu.
     623                */
    624624            } else {
    625625                add_filter( 'bp_xprofile_admin_nav', array( $this, 'setup_xprofile_admin_nav' ), 2 );
     
    661661        } elseif ( bp_is_user() ) {
    662662            $bp->bp_options_title  = bp_get_displayed_user_fullname();
    663             $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    664                 'item_id' => bp_displayed_user_id(),
    665                 'type'    => 'thumb',
    666                 /* translators: %s: member name */
    667                 'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), $bp->bp_options_title )
    668             ) );
     663            $bp->bp_options_avatar = bp_core_fetch_avatar(
     664                array(
     665                    'item_id' => bp_displayed_user_id(),
     666                    'type'    => 'thumb',
     667                    /* translators: %s: member name */
     668                    'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), $bp->bp_options_title ),
     669                )
     670            );
    669671        }
    670672
     
    10621064    public function rest_api_init( $controllers = array() ) {
    10631065        $controllers = array(
    1064             'BP_REST_Members_Endpoint',
    1065             'BP_REST_Attachments_Member_Avatar_Endpoint',
     1066            'BP_Members_REST_Controller',
     1067            'BP_Members_Avatar_REST_Controller',
    10661068        );
    10671069
    10681070        if ( bp_is_active( 'members', 'cover_image' ) ) {
    1069             $controllers[] = 'BP_REST_Attachments_Member_Cover_Endpoint';
     1071            $controllers[] = 'BP_Members_Cover_REST_Controller';
    10701072        }
    10711073
    10721074        if ( bp_get_signup_allowed() ) {
    1073             $controllers[] = 'BP_REST_Signup_Endpoint';
     1075            $controllers[] = 'BP_Members_Signup_REST_Controller';
    10741076        }
    10751077
     
    10891091        parent::blocks_init(
    10901092            array(
    1091                 'bp/member' => array(
     1093                'bp/member'          => array(
    10921094                    'metadata'        => trailingslashit( buddypress()->plugin_dir ) . 'bp-members/blocks/member',
    10931095                    'render_callback' => 'bp_members_render_member_block',
    10941096                ),
    1095                 'bp/members' => array(
     1097                'bp/members'         => array(
    10961098                    'metadata'        => trailingslashit( buddypress()->plugin_dir ) . 'bp-members/blocks/members',
    10971099                    'render_callback' => 'bp_members_render_members_block',
Note: See TracChangeset for help on using the changeset viewer.