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-core/classes/class-bp-component.php

    r13943 r14026  
    247247     *
    248248     * @param string $id   Unique ID. Letters, numbers, and underscores only.
    249      * @param string $name Unique name. This should be a translatable name, eg.
    250      *                     __( 'Groups', 'buddypress' ).
     249     * @param string $name Unique name. This should be a translatable name, e.g. __( 'Groups', 'buddypress' ).
    251250     * @param string $path The file path for the component's files. Used by {@link BP_Component::includes()}.
    252251     * @param array  $params {
     
    314313     *                                           if one is found, otherwise an empty string.
    315314     *     @type bool     $has_directory         Set to true if the component requires an associated WordPress page.
    316      *     @type array    $rewrite_ids           The list of rewrited IDs to use for the component.
     315     *     @type array    $rewrite_ids           The list of rewritten IDs to use for the component.
    317316     *     @type string   $directory_title       The title to use for the directory page.
    318317     *     @type callable $notification_callback The callable function that formats the component's notifications.
     
    530529
    531530                foreach ( $paths as $path ) {
     531
    532532                    if ( @is_file( $slashed_path . $path ) ) {
    533533                        require $slashed_path . $path;
     
    623623        // Register BP REST Endpoints.
    624624        if ( bp_rest_in_buddypress() && bp_rest_api_is_available() ) {
    625             add_action( 'bp_rest_api_init', array( $this, 'rest_api_init' ), 10 );
     625            add_action( 'bp_rest_api_init', array( $this, 'rest_api_init' ) );
    626626        }
    627627
     
    14161416             * @since 5.0.0
    14171417             *
    1418              * @param array $controllers The list of BP REST API controllers to load.
     1418             * @param string[] $controllers The list of BP REST API controllers to load.
    14191419             */
    14201420            $controllers = (array) apply_filters( 'bp_' . $this->id . '_rest_api_controllers', $controllers );
     
    14251425                }
    14261426
     1427                if ( ! class_exists( $controller ) ) {
     1428                    _doing_it_wrong(
     1429                        __METHOD__,
     1430                        sprintf(
     1431                            // translators: %s: REST API controller class name.
     1432                            esc_html__( 'The REST API controller class %s does not exist.', 'buddypress' ),
     1433                            esc_attr( $controller )
     1434                        ),
     1435                        '15.0.0'
     1436                    );
     1437                }
     1438
    14271439                $component_controller = new $controller();
    14281440                $component_controller->register_routes();
Note: See TracChangeset for help on using the changeset viewer.