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

    r13551 r14026  
    4242            array(
    4343                'adminbar_myaccount_order' => 50,
    44                 'features'                 => array( 'star' )
     44                'features'                 => array( 'star' ),
    4545            )
    4646        );
     
    178178        // All globals for messaging component.
    179179        // Note that global_tables is included in this array.
    180         parent::setup_globals( array(
    181             'slug'                  => $default_slug,
    182             'has_directory'         => false,
    183             'notification_callback' => 'messages_format_notifications',
    184             'search_string'         => __( 'Search Messages...', 'buddypress' ),
    185             'global_tables'         => $global_tables,
    186             'meta_tables'           => $meta_tables
    187         ) );
     180        parent::setup_globals(
     181            array(
     182                'slug'                  => $default_slug,
     183                'has_directory'         => false,
     184                'notification_callback' => 'messages_format_notifications',
     185                'search_string'         => __( 'Search Messages...', 'buddypress' ),
     186                'global_tables'         => $global_tables,
     187                'meta_tables'           => $meta_tables,
     188            )
     189        );
    188190    }
    189191
     
    224226        if ( bp_is_active( $this->id, 'star' ) ) {
    225227            $sub_nav[] = array(
    226                 'name'                      => __( 'Starred', 'buddypress' ),
     228                'name'                     => __( 'Starred', 'buddypress' ),
    227229                'slug'                     => bp_get_messages_starred_slug(),
    228230                'parent_slug'              => $slug,
     
    325327            // Unread message count.
    326328            $count = messages_get_unread_count( bp_loggedin_user_id() );
    327             if ( !empty( $count ) ) {
     329            if ( ! empty( $count ) ) {
    328330                $title = sprintf(
    329331                    /* translators: %s: Unread message count for the current user */
     
    338340            } else {
    339341                $title = __( 'Messages', 'buddypress' );
    340                 $inbox = __( 'Inbox',    'buddypress' );
     342                $inbox = __( 'Inbox', 'buddypress' );
    341343            }
    342344
     
    413415                $bp->bp_options_title = __( 'My Messages', 'buddypress' );
    414416            } else {
    415                 $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    416                     'item_id' => bp_displayed_user_id(),
    417                     'type'    => 'thumb',
    418                     /* translators: %s: member name */
    419                     'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() )
    420                 ) );
    421                 $bp->bp_options_title = bp_get_displayed_user_fullname();
     417                $bp->bp_options_avatar = bp_core_fetch_avatar(
     418                    array(
     419                        'item_id' => bp_displayed_user_id(),
     420                        'type'    => 'thumb',
     421                        /* translators: %s: member name */
     422                        'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() ),
     423                    )
     424                );
     425                $bp->bp_options_title  = bp_get_displayed_user_fullname();
    422426            }
    423427        }
     
    434438
    435439        // Global groups.
    436         wp_cache_add_global_groups( array(
    437             'bp_messages',
    438             'bp_messages_threads',
    439             'bp_messages_unread_count',
    440             'message_meta'
    441         ) );
     440        wp_cache_add_global_groups(
     441            array(
     442                'bp_messages',
     443                'bp_messages_threads',
     444                'bp_messages_unread_count',
     445                'message_meta',
     446            )
     447        );
    442448
    443449        parent::setup_cache_groups();
     
    455461        parent::rest_api_init(
    456462            array(
    457                 'BP_REST_Messages_Endpoint',
    458                 'BP_REST_Sitewide_Notices_Endpoint',
     463                'BP_Messages_REST_Controller',
     464                'BP_Messages_Sitewide_Notices_REST_Controller',
    459465            )
    460466        );
Note: See TracChangeset for help on using the changeset viewer.