Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/27/2024 09:11:27 PM (2 years 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-xprofile/classes/class-bp-xprofile-component.php

    r13503 r14026  
    174174                // Register the visibility levels. See bp_xprofile_get_visibility_levels() to filter.
    175175                $this->visibility_levels = array(
    176                         'public' => array(
    177                                 'id'      => 'public',
     176                        'public'     => array(
     177                                'id'    => 'public',
    178178                                'label' => _x( 'Everyone', 'Visibility level setting', 'buddypress' ),
    179179                        ),
    180180                        'adminsonly' => array(
    181                                 'id'      => 'adminsonly',
     181                                'id'    => 'adminsonly',
    182182                                'label' => _x( 'Only Me', 'Visibility level setting', 'buddypress' ),
    183183                        ),
    184                         'loggedin' => array(
    185                                 'id'      => 'loggedin',
     184                        'loggedin'   => array(
     185                                'id'    => 'loggedin',
    186186                                'label' => _x( 'All Members', 'Visibility level setting', 'buddypress' ),
    187187                        ),
     
    190190                if ( bp_is_active( 'friends' ) ) {
    191191                        $this->visibility_levels['friends'] = array(
    192                                 'id'    => 'friends',
    193                                 'label' => _x( 'My Friends', 'Visibility level setting', 'buddypress' ),
     192                                'id'    => 'friends',
     193                                'label' => _x( 'My Friends', 'Visibility level setting', 'buddypress' ),
    194194                        );
    195195                }
     
    252252                // Edit Profile.
    253253                $sub_nav[] = array(
    254                         'name'                     => _x( 'Edit','Profile header sub menu', 'buddypress' ),
     254                        'name'                     => _x( 'Edit', 'Profile header sub menu', 'buddypress' ),
    255255                        'slug'                     => 'edit',
    256256                        'parent_slug'              => $slug,
     
    342342                                $bp->bp_options_title = _x( 'My Profile', 'Page title', 'buddypress' );
    343343                        } else {
    344                                 $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    345                                         'item_id' => bp_displayed_user_id(),
    346                                         'type'    => 'thumb',
    347 
    348                                         /* translators: %s: member name */
    349                                         'alt'     => sprintf( _x( 'Profile picture of %s', 'Avatar alt', 'buddypress' ), bp_get_displayed_user_fullname() ),
    350                                 ) );
    351                                 $bp->bp_options_title = bp_get_displayed_user_fullname();
     344                                $bp->bp_options_avatar = bp_core_fetch_avatar(
     345                                        array(
     346                                                'item_id' => bp_displayed_user_id(),
     347                                                'type'    => 'thumb',
     348
     349                                                /* translators: %s: member name */
     350                                                'alt'     => sprintf( _x( 'Profile picture of %s', 'Avatar alt', 'buddypress' ), bp_get_displayed_user_fullname() ),
     351                                        )
     352                                );
     353                                $bp->bp_options_title  = bp_get_displayed_user_fullname();
    352354                        }
    353355                }
     
    364366
    365367                // Global groups.
    366                 wp_cache_add_global_groups( array(
    367                         'bp_xprofile',
    368                         'bp_xprofile_data',
    369                         'bp_xprofile_fields',
    370                         'bp_xprofile_groups',
    371                         'xprofile_meta',
    372                         'bp_user_mid',
    373                 ) );
     368                wp_cache_add_global_groups(
     369                        array(
     370                                'bp_xprofile',
     371                                'bp_xprofile_data',
     372                                'bp_xprofile_fields',
     373                                'bp_xprofile_groups',
     374                                'xprofile_meta',
     375                                'bp_user_mid',
     376                        )
     377                );
    374378
    375379                parent::setup_cache_groups();
     
    405409         */
    406410        public function rest_api_init( $controllers = array() ) {
    407                 parent::rest_api_init( array(
    408                         'BP_REST_XProfile_Fields_Endpoint',
    409                         'BP_REST_XProfile_Field_Groups_Endpoint',
    410                         'BP_REST_XProfile_Data_Endpoint',
    411                 ) );
     411                parent::rest_api_init(
     412                        array(
     413                                'BP_XProfile_Fields_REST_Controller',
     414                                'BP_XProfile_Field_Groups_REST_Controller',
     415                                'BP_XProfile_Data_REST_Controller',
     416                        )
     417                );
    412418        }
    413419
Note: See TracChangeset for help on using the changeset viewer.