Skip to:
Content

BuddyPress.org


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

    r13689 r14026  
    3333                        array(
    3434                                'adminbar_myaccount_order' => 10,
    35                                 'search_query_arg' => 'activity_search',
    36                                 'features' => array( 'embeds' )
     35                                'search_query_arg'         => 'activity_search',
     36                                'features'                 => array( 'embeds' ),
    3737                        )
    3838                );
     
    152152
    153153                        if ( bp_is_active( 'friends' ) ) {
    154                                 $filenames[bp_get_friends_slug()] = 'friends';
     154                                $filenames[ bp_get_friends_slug() ] = 'friends';
    155155                        }
    156156
    157157                        if ( bp_is_active( 'groups' ) ) {
    158                                 $filenames[bp_get_groups_slug()] = 'groups';
     158                                $filenames[ bp_get_groups_slug() ] = 'groups';
    159159                        }
    160160
     
    210210                // Fetch the default directory title.
    211211                $default_directory_titles = bp_core_get_directory_page_default_titles();
    212                 $default_directory_title  = $default_directory_titles[$this->id];
     212                $default_directory_title  = $default_directory_titles[ $this->id ];
    213213
    214214                // All globals for activity component.
     
    231231                                'bp/latest-activities' => array(
    232232                                        'widget_classnames' => array( 'wp-block-bp-latest-activities', 'buddypress' ),
    233                                 )
     233                                ),
    234234                        ),
    235235                );
     
    258258                        'screen_function'     => 'bp_activity_screen_my_activity',
    259259                        'default_subnav_slug' => 'just-me',
    260                         'item_css_id'         => $this->id
     260                        'item_css_id'         => $this->id,
    261261                );
    262262
     
    267267                        'parent_slug'     => $slug,
    268268                        'screen_function' => 'bp_activity_screen_my_activity',
    269                         'position'        => 10
     269                        'position'        => 10,
    270270                );
    271271
     
    312312                                'screen_function' => 'bp_activity_screen_groups',
    313313                                'position'        => 50,
    314                                 'item_css_id'     => 'activity-groups'
     314                                'item_css_id'     => 'activity-groups',
    315315                        );
    316316                }
     
    409409                                        'title'    => _x( 'Groups', 'My Account Activity sub nav', 'buddypress' ),
    410410                                        'href'     => bp_loggedin_user_url( bp_members_get_path_chunks( array( $activity_slug, bp_get_groups_slug() ) ) ),
    411                                         'position' => 50
     411                                        'position' => 50,
    412412                                );
    413413                        }
     
    421421         *
    422422         * @since 1.5.0
    423          *
    424423         */
    425424        public function setup_title() {
     
    432431                                $bp->bp_options_title = _x( 'My Activity', 'Page and <title>', 'buddypress' );
    433432                        } else {
    434                                 $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    435                                         'item_id' => bp_displayed_user_id(),
    436                                         'type'    => 'thumb',
    437                                         'alt'     => sprintf(
     433                                $bp->bp_options_avatar = bp_core_fetch_avatar(
     434                                        array(
     435                                                'item_id' => bp_displayed_user_id(),
     436                                                'type'    => 'thumb',
     437                                                'alt'     => sprintf(
    438438                                                /* translators: %s: member name */
    439                                                 __( 'Profile picture of %s', 'buddypress' ),
    440                                                 bp_get_displayed_user_fullname()
    441                                         ),
    442                                 ) );
     439                                                        __( 'Profile picture of %s', 'buddypress' ),
     440                                                        bp_get_displayed_user_fullname()
     441                                                ),
     442                                        )
     443                                );
    443444                                $bp->bp_options_title  = bp_get_displayed_user_fullname();
    444445                        }
     
    456457
    457458                // Global groups.
    458                 wp_cache_add_global_groups( array(
    459                         'bp_activity',
    460                         'bp_activity_comments',
    461                         'activity_meta'
    462                 ) );
     459                wp_cache_add_global_groups(
     460                        array(
     461                                'bp_activity',
     462                                'bp_activity_comments',
     463                                'activity_meta',
     464                        )
     465                );
    463466
    464467                parent::setup_cache_groups();
     
    525528         */
    526529        public function rest_api_init( $controllers = array() ) {
    527                 parent::rest_api_init( array( 'BP_REST_Activity_Endpoint' ) );
     530                parent::rest_api_init( array( 'BP_Activity_REST_Controller' ) );
    528531        }
    529532
     
    548551                        $blocks['bp/embed-activity'] = array(
    549552                                'metadata' => trailingslashit( buddypress()->plugin_dir ) . 'bp-activity/blocks/embed-activity',
    550 
    551553                        );
    552554                }
Note: See TracChangeset for help on using the changeset viewer.