From f12d3de6f331fb7a5b689cbbc297298dad45a9a8 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Wed, 18 Dec 2024 20:37:19 -0800 Subject: [PATCH] Move wpcom/v2/publicize/connections endpoint to publicize package (#40607) * Move wpcom/v2/publicize/connections endpoint to publicize package * Fix Fatals in Publicize base class on WPCOM * Now we can use v2 for proxy requests * Phan needs a fan because I am not * Update baseline.php * Use publicize for fields for now instead of a new class * Move initialization logic to Publicize_Setup * Clean up * Update phan baseline * Use null for the status field as default * Default external_handle to null * Return null in all cases for external_handle * Make get_username use get_external_handle * Rename rest-endpoints to rest-api * Clean up prepare_item_for_response * Update baseline.php * Use schema caching --- .../packages/publicize/.phan/baseline.php | 8 +- projects/packages/publicize/.phan/config.php | 1 + projects/packages/publicize/actions.php | 4 +- ...pcom-v2-publicize-connections-to-publicize | 4 + .../publicize/src/class-publicize-base.php | 40 ++- .../publicize/src/class-publicize-setup.php | 27 ++ .../src/rest-api/class-base-controller.php | 85 +++++ .../rest-api/class-connections-controller.php | 304 ++++++++++++++++++ projects/plugins/jetpack/.phan/baseline.php | 3 +- .../wpcom-endpoints/publicize-connections.php | 23 +- ...pcom-v2-publicize-connections-to-publicize | 4 + 11 files changed, 463 insertions(+), 40 deletions(-) create mode 100644 projects/packages/publicize/changelog/update-move-wpcom-v2-publicize-connections-to-publicize create mode 100644 projects/packages/publicize/src/rest-api/class-base-controller.php create mode 100644 projects/packages/publicize/src/rest-api/class-connections-controller.php create mode 100644 projects/plugins/jetpack/changelog/update-move-wpcom-v2-publicize-connections-to-publicize diff --git a/projects/packages/publicize/.phan/baseline.php b/projects/packages/publicize/.phan/baseline.php index 276871afd3219..ae1e8cfe766d4 100644 --- a/projects/packages/publicize/.phan/baseline.php +++ b/projects/packages/publicize/.phan/baseline.php @@ -9,17 +9,18 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgument : 7 occurrences // PhanPluginDuplicateConditionalNullCoalescing : 6 occurrences + // PhanTypeMismatchArgument : 6 occurrences // PhanTypeMismatchArgumentNullable : 3 occurrences // PhanDeprecatedFunction : 2 occurrences + // PhanPluginMixedKeyNoKey : 2 occurrences // PhanPossiblyUndeclaredVariable : 2 occurrences // PhanTypeMismatchReturnProbablyReal : 2 occurrences // PhanTypeMissingReturn : 2 occurrences // PhanImpossibleCondition : 1 occurrence + // PhanNoopNew : 1 occurrence // PhanParamSignatureMismatch : 1 occurrence // PhanPluginDuplicateExpressionAssignmentOperation : 1 occurrence - // PhanPluginMixedKeyNoKey : 1 occurrence // PhanPluginSimplifyExpressionBool : 1 occurrence // PhanSuspiciousMagicConstant : 1 occurrence // PhanTypeMismatchArgumentNullableInternal : 1 occurrence @@ -33,10 +34,11 @@ 'src/class-connections-post-field.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'src/class-keyring-helper.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDefault'], 'src/class-publicize-base.php' => ['PhanImpossibleCondition', 'PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginSimplifyExpressionBool', 'PhanSuspiciousMagicConstant', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchReturn'], - 'src/class-publicize-setup.php' => ['PhanTypeMismatchArgument'], + 'src/class-publicize-setup.php' => ['PhanNoopNew', 'PhanTypeMismatchArgument'], 'src/class-publicize-ui.php' => ['PhanPluginDuplicateExpressionAssignmentOperation', 'PhanTypeMismatchReturnProbablyReal'], 'src/class-publicize.php' => ['PhanParamSignatureMismatch', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgument', 'PhanTypeMissingReturn'], 'src/class-rest-controller.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeMismatchReturnProbablyReal'], + 'src/rest-api/class-connections-controller.php' => ['PhanPluginMixedKeyNoKey'], 'src/social-image-generator/class-post-settings.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], 'src/social-image-generator/class-rest-settings-controller.php' => ['PhanPluginMixedKeyNoKey'], 'src/social-image-generator/class-settings.php' => ['PhanPluginDuplicateConditionalNullCoalescing'], diff --git a/projects/packages/publicize/.phan/config.php b/projects/packages/publicize/.phan/config.php index 7030e2aa8176c..075dd16643b9e 100644 --- a/projects/packages/publicize/.phan/config.php +++ b/projects/packages/publicize/.phan/config.php @@ -24,6 +24,7 @@ __DIR__ . '/../../../plugins/jetpack/_inc/lib/admin-pages/class.jetpack-admin-page.php', // class Jetpack_Admin_Page __DIR__ . '/../../../plugins/jetpack/modules/subscriptions.php', // class Jetpack_Subscriptions __DIR__ . '/../../../plugins/jetpack/functions.global.php', // function jetpack_render_tos_blurb + __DIR__ . '/../../../plugins/jetpack/_inc/lib/core-api/load-wpcom-endpoints.php', // function wpcom_rest_api_v2_load_plugin ), ) ); diff --git a/projects/packages/publicize/actions.php b/projects/packages/publicize/actions.php index 8a1413391ae13..27748d4f9ffd0 100644 --- a/projects/packages/publicize/actions.php +++ b/projects/packages/publicize/actions.php @@ -8,12 +8,12 @@ // If WordPress's plugin API is available already, use it. If not, // drop data into `$wp_filter` for `WP_Hook::build_preinitialized_hooks()`. if ( function_exists( 'add_action' ) ) { - add_action( 'plugins_loaded', array( Automattic\Jetpack\Publicize\Publicize_Assets::class, 'configure' ), 1 ); + add_action( 'plugins_loaded', array( Automattic\Jetpack\Publicize\Publicize_Setup::class, 'pre_initialization' ), 1 ); } else { global $wp_filter; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited $wp_filter['plugins_loaded'][1][] = array( 'accepted_args' => 0, - 'function' => array( Automattic\Jetpack\Publicize\Publicize_Assets::class, 'configure' ), + 'function' => array( Automattic\Jetpack\Publicize\Publicize_Setup::class, 'pre_initialization' ), ); } diff --git a/projects/packages/publicize/changelog/update-move-wpcom-v2-publicize-connections-to-publicize b/projects/packages/publicize/changelog/update-move-wpcom-v2-publicize-connections-to-publicize new file mode 100644 index 0000000000000..9d87109f63b2c --- /dev/null +++ b/projects/packages/publicize/changelog/update-move-wpcom-v2-publicize-connections-to-publicize @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Moved wpcom/v2/publicize/connections endpoint to publicize package diff --git a/projects/packages/publicize/src/class-publicize-base.php b/projects/packages/publicize/src/class-publicize-base.php index b88bd1a6b12ca..c2e6c044cc5bf 100644 --- a/projects/packages/publicize/src/class-publicize-base.php +++ b/projects/packages/publicize/src/class-publicize-base.php @@ -497,8 +497,8 @@ public function get_profile_link( $service_name, $connection ) { return 'https://instagram.com/' . $cmeta['connection_data']['meta']['username']; } - if ( 'threads' === $service_name && isset( $connection['external_name'] ) ) { - return 'https://www.threads.net/@' . $connection['external_name']; + if ( 'threads' === $service_name && isset( $cmeta['external_name'] ) ) { + return 'https://www.threads.net/@' . $cmeta['external_name']; } if ( 'mastodon' === $service_name && isset( $cmeta['external_name'] ) ) { @@ -527,7 +527,7 @@ public function get_profile_link( $service_name, $connection ) { } $profile_url_query = wp_parse_url( $cmeta['connection_data']['meta']['profile_url'], PHP_URL_QUERY ); - $profile_url_query_args = null; + $profile_url_query_args = array(); wp_parse_str( $profile_url_query, $profile_url_query_args ); $id = null; @@ -589,17 +589,35 @@ public function get_display_name( $service_name, $connection ) { * @return string */ public function get_username( $service_name, $connection ) { + $handle = $this->get_external_handle( $service_name, $connection ); + + return $handle ?? $this->get_display_name( $service_name, $connection ); + } + + /** + * Returns the external handle for the Connection. + * + * @param string $service_name 'facebook', 'linkedin', etc. + * @param object|array $connection The Connection object (WordPress.com) or array (Jetpack). + * @return string|null + */ + public function get_external_handle( $service_name, $connection ) { $cmeta = $this->get_connection_meta( $connection ); - if ( 'mastodon' === $service_name && isset( $cmeta['external_display'] ) ) { - return $cmeta['external_display']; - } + switch ( $service_name ) { + case 'mastodon': + return $cmeta['external_display'] ?? null; - if ( isset( $cmeta['connection_data']['meta']['username'] ) ) { - return $cmeta['connection_data']['meta']['username']; - } + case 'bluesky': + case 'threads': + return $cmeta['external_name'] ?? null; - return $this->get_display_name( $service_name, $connection ); + case 'instagram-business': + return $cmeta['connection_data']['meta']['username'] ?? null; + + default: + return null; + } } /** @@ -608,7 +626,7 @@ public function get_username( $service_name, $connection ) { * @param object|array $connection The Connection object (WordPress.com) or array (Jetpack). * @return string */ - private function get_profile_picture( $connection ) { + public function get_profile_picture( $connection ) { $cmeta = $this->get_connection_meta( $connection ); if ( isset( $cmeta['profile_picture'] ) ) { diff --git a/projects/packages/publicize/src/class-publicize-setup.php b/projects/packages/publicize/src/class-publicize-setup.php index 383ef289fab5e..dc4dc5a3997c2 100644 --- a/projects/packages/publicize/src/class-publicize-setup.php +++ b/projects/packages/publicize/src/class-publicize-setup.php @@ -7,6 +7,9 @@ namespace Automattic\Jetpack\Publicize; +use Automattic\Jetpack\Publicize\REST_API\Connections_Controller; +use Automattic\Jetpack\Status\Host; + /** * The class to configure and initialize the publicize package. */ @@ -26,6 +29,30 @@ public static function configure() { add_action( 'jetpack_feature_publicize_enabled', array( __CLASS__, 'on_jetpack_feature_publicize_enabled' ) ); } + /** + * Initialization of publicize logic that should always be loaded. + */ + public static function pre_initialization() { + + $is_wpcom = ( new Host() )->is_wpcom_simple(); + + // Assets are to be loaded in all cases. + Publicize_Assets::configure(); + + $rest_controllers = array( + Connections_Controller::class, + ); + + // Load the REST controllers. + foreach ( $rest_controllers as $controller ) { + if ( $is_wpcom ) { + wpcom_rest_api_v2_load_plugin( $controller ); + } else { + new $controller(); + } + } + } + /** * To configure the publicize package, when called via the Config package. */ diff --git a/projects/packages/publicize/src/rest-api/class-base-controller.php b/projects/packages/publicize/src/rest-api/class-base-controller.php new file mode 100644 index 0000000000000..acf0aa0c78cc2 --- /dev/null +++ b/projects/packages/publicize/src/rest-api/class-base-controller.php @@ -0,0 +1,85 @@ +wpcom_is_wpcom_only_endpoint = true; + } + + /** + * Check if we are on WPCOM. + * + * @return bool + */ + public static function is_wpcom() { + return ( new Host() )->is_wpcom_simple(); + } + + /** + * Filters out data based on ?_fields= request parameter + * + * @param array $item Item to prepare. + * @param WP_REST_Request $request Full details about the request. + * + * @return WP_REST_Response filtered item + */ + public function prepare_item_for_response( $item, $request ) { + + $fields = $this->get_fields_for_response( $request ); + + $response_data = array(); + foreach ( $item as $field => $value ) { + if ( rest_is_field_included( $field, $fields ) ) { + $response_data[ $field ] = $value; + } + } + + return rest_ensure_response( $response_data ); + } + + /** + * Verify that user can access Publicize data + * + * @return true|WP_Error + */ + public function get_items_permission_check() { + global $publicize; + + if ( ! $publicize ) { + return new WP_Error( + 'publicize_not_available', + __( 'Sorry, Jetpack Social is not available on your site right now.', 'jetpack-publicize-pkg' ), + array( 'status' => rest_authorization_required_code() ) + ); + } + + if ( $publicize->current_user_can_access_publicize_data() ) { + return true; + } + + return new WP_Error( + 'invalid_user_permission_publicize', + __( 'Sorry, you are not allowed to access Jetpack Social data on this site.', 'jetpack-publicize-pkg' ), + array( 'status' => rest_authorization_required_code() ) + ); + } +} diff --git a/projects/packages/publicize/src/rest-api/class-connections-controller.php b/projects/packages/publicize/src/rest-api/class-connections-controller.php new file mode 100644 index 0000000000000..f1710bca05a93 --- /dev/null +++ b/projects/packages/publicize/src/rest-api/class-connections-controller.php @@ -0,0 +1,304 @@ +namespace = 'wpcom/v2'; + $this->rest_base = 'publicize/connections'; + + add_action( 'rest_api_init', array( $this, 'register_routes' ) ); + } + + /** + * Register the routes. + */ + public function register_routes() { + register_rest_route( + $this->namespace, + '/' . $this->rest_base, + array( + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permission_check' ), + 'args' => array( + 'test_connections' => array( + 'type' => 'boolean', + 'description' => __( 'Whether to test connections.', 'jetpack-publicize-pkg' ), + ), + ), + ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + } + + /** + * Schema for the endpoint. + * + * @return array + */ + public function get_item_schema() { + if ( $this->schema ) { + return $this->add_additional_fields_schema( $this->schema ); + } + $deprecated_fields = array( + 'id' => array( + 'type' => 'string', + 'description' => __( 'Unique identifier for the Jetpack Social connection.', 'jetpack-publicize-pkg' ) . ' ' . sprintf( + /* translators: %s is the new field name */ + __( 'Deprecated in favor of %s.', 'jetpack-publicize-pkg' ), + 'connection_id' + ), + ), + 'username' => array( + 'type' => 'string', + 'description' => __( 'Username of the connected account.', 'jetpack-publicize-pkg' ) . ' ' . sprintf( + /* translators: %s is the new field name */ + __( 'Deprecated in favor of %s.', 'jetpack-publicize-pkg' ), + 'external_handle' + ), + ), + 'profile_display_name' => array( + 'type' => 'string', + 'description' => __( 'The name to display in the profile of the connected account.', 'jetpack-publicize-pkg' ) . ' ' . sprintf( + /* translators: %s is the new field name */ + __( 'Deprecated in favor of %s.', 'jetpack-publicize-pkg' ), + 'display_name' + ), + ), + 'global' => array( + 'type' => 'boolean', + 'description' => __( 'Is this connection available to all users?', 'jetpack-publicize-pkg' ) . ' ' . sprintf( + /* translators: %s is the new field name */ + __( 'Deprecated in favor of %s.', 'jetpack-publicize-pkg' ), + 'shared' + ), + ), + ); + + $schema = array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'jetpack-publicize-connection', + 'type' => 'object', + 'properties' => array_merge( + $deprecated_fields, + array( + 'connection_id' => array( + 'type' => 'string', + 'description' => __( 'Connection ID of the connected account.', 'jetpack-publicize-pkg' ), + ), + 'display_name' => array( + 'type' => 'string', + 'description' => __( 'Display name of the connected account.', 'jetpack-publicize-pkg' ), + ), + 'external_handle' => array( + 'type' => 'string', + 'description' => __( 'The external handle or username of the connected account.', 'jetpack-publicize-pkg' ), + ), + 'external_id' => array( + 'type' => 'string', + 'description' => __( 'The external ID of the connected account.', 'jetpack-publicize-pkg' ), + ), + 'profile_link' => array( + 'type' => 'string', + 'description' => __( 'Profile link of the connected account.', 'jetpack-publicize-pkg' ), + ), + 'profile_picture' => array( + 'type' => 'string', + 'description' => __( 'URL of the profile picture of the connected account.', 'jetpack-publicize-pkg' ), + ), + 'service_label' => array( + 'type' => 'string', + 'description' => __( 'Human-readable label for the Jetpack Social service.', 'jetpack-publicize-pkg' ), + ), + 'service_name' => array( + 'type' => 'string', + 'description' => __( 'Alphanumeric identifier for the Jetpack Social service.', 'jetpack-publicize-pkg' ), + ), + 'shared' => array( + 'type' => 'boolean', + 'description' => __( 'Whether the connection is shared with other users.', 'jetpack-publicize-pkg' ), + ), + 'status' => array( + 'type' => 'string', + 'description' => __( 'The connection status.', 'jetpack-publicize-pkg' ), + 'enum' => array( + 'ok', + 'broken', + ), + ), + 'user_id' => array( + 'type' => 'integer', + 'description' => __( 'ID of the user the connection belongs to.', 'jetpack-publicize-pkg' ), + ), + ) + ), + ); + + $this->schema = $schema; + + return $this->add_additional_fields_schema( $schema ); + } + + /** + * Get all connections. Meant to be called directly only on WPCOM. + * + * @param bool $run_tests Whether to run tests on the connections. + * + * @return array + */ + protected static function get_all_connections( $run_tests = false ) { + /** + * Publicize instance. + * + * @var \Automattic\Jetpack\Publicize\Publicize $publicize + */ + global $publicize; + + $items = array(); + + $test_results = $run_tests ? self::get_connections_test_status() : array(); + + foreach ( (array) $publicize->get_services( 'connected' ) as $service_name => $connections ) { + foreach ( $connections as $connection ) { + + $connection_id = $publicize->get_connection_id( $connection ); + + $connection_meta = $publicize->get_connection_meta( $connection ); + $connection_data = $connection_meta['connection_data']; + + $items[] = array( + 'connection_id' => $connection_id, + 'display_name' => $publicize->get_display_name( $service_name, $connection ), + 'external_handle' => $publicize->get_external_handle( $service_name, $connection ), + 'external_id' => $connection_meta['external_id'] ?? '', + 'profile_link' => $publicize->get_profile_link( $service_name, $connection ), + 'profile_picture' => $publicize->get_profile_picture( $connection ), + 'service_label' => Publicize::get_service_label( $service_name ), + 'service_name' => $service_name, + 'shared' => ! $connection_data['user_id'], + 'status' => $test_results[ $connection_id ] ?? null, + 'user_id' => (int) $connection_data['user_id'], + + // Deprecated fields. + 'id' => (string) $publicize->get_connection_unique_id( $connection ), + 'username' => $publicize->get_username( $service_name, $connection ), + 'profile_display_name' => ! empty( $connection_meta['profile_display_name'] ) ? $connection_meta['profile_display_name'] : '', + // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- We expect an integer, but do loose comparison below in case some other type is stored. + 'global' => 0 == $connection_data['user_id'], + + ); + } + } + + return $items; + } + + /** + * Get a list of publicize connections. + * + * @param bool $run_tests Whether to run tests on the connections. + * + * @return array + */ + public static function get_connections( $run_tests = false ) { + if ( self::is_wpcom() ) { + return self::get_all_connections( $run_tests ); + } + + $site_id = Manager::get_site_id( true ); + if ( ! $site_id ) { + return array(); + } + + $path = add_query_arg( + array( 'test_connections' => $run_tests ), + sprintf( '/sites/%d/publicize/connections', $site_id ) + ); + + $response = Client::wpcom_json_api_request_as_user( $path, 'v2', array( 'method' => 'GET' ) ); + + if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) { + // TODO log error. + return array(); + } + + $body = wp_remote_retrieve_body( $response ); + + $items = json_decode( $body, true ); + + return $items ? $items : array(); + } + + /** + * Get list of connected Publicize connections. + * + * @param WP_REST_Request $request Full details about the request. + * + * @return WP_REST_Response suitable for 1-page collection + */ + public function get_items( $request ) { + $items = array(); + + $run_tests = $request->get_param( 'test_connections' ); + + foreach ( self::get_connections( $run_tests ) as $item ) { + $data = $this->prepare_item_for_response( $item, $request ); + + $items[] = $this->prepare_response_for_collection( $data ); + } + + $response = rest_ensure_response( $items ); + $response->header( 'X-WP-Total', (string) count( $items ) ); + $response->header( 'X-WP-TotalPages', '1' ); + + return $response; + } + + /** + * Get the connections test status. + * + * @return array + */ + protected static function get_connections_test_status() { + /** + * Publicize instance. + * + * @var \Automattic\Jetpack\Publicize\Publicize $publicize + */ + global $publicize; + + $test_results = $publicize->get_publicize_conns_test_results(); + + $test_results_map = array(); + + foreach ( $test_results as $test_result ) { + // Compare to `true` because the API returns a 'must_reauth' for LinkedIn. + $test_results_map[ $test_result['connectionID'] ] = true === $test_result['connectionTestPassed'] ? 'ok' : 'broken'; + } + + return $test_results_map; + } +} diff --git a/projects/plugins/jetpack/.phan/baseline.php b/projects/plugins/jetpack/.phan/baseline.php index d3614e00bc549..741c58a413969 100644 --- a/projects/plugins/jetpack/.phan/baseline.php +++ b/projects/plugins/jetpack/.phan/baseline.php @@ -81,7 +81,6 @@ // PhanTypeMismatchArgumentInternalProbablyReal : 2 occurrences // PhanUndeclaredClassInCallable : 2 occurrences // PhanUndeclaredClassMethod : 2 occurrences - // PhanCommentParamWithoutRealParam : 1 occurrence // PhanDeprecatedPartiallySupportedCallable : 1 occurrence // PhanEmptyForeach : 1 occurrence // PhanPluginDuplicateSwitchCase : 1 occurrence @@ -139,7 +138,7 @@ '_inc/lib/core-api/wpcom-endpoints/gutenberg-available-extensions.php' => ['PhanPluginMixedKeyNoKey'], '_inc/lib/core-api/wpcom-endpoints/memberships.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanPluginUnreachableCode', 'PhanTypeArraySuspicious'], '_inc/lib/core-api/wpcom-endpoints/publicize-connection-test-results.php' => ['PhanPluginMixedKeyNoKey', 'PhanTypeMismatchArgument'], - '_inc/lib/core-api/wpcom-endpoints/publicize-connections.php' => ['PhanParamSignatureMismatch', 'PhanPluginMixedKeyNoKey', 'PhanTypeMismatchArgument'], + '_inc/lib/core-api/wpcom-endpoints/publicize-connections.php' => ['PhanParamSignatureMismatch', 'PhanTypeMismatchArgument'], '_inc/lib/core-api/wpcom-endpoints/publicize-services.php' => ['PhanParamSignatureMismatch', 'PhanPluginMixedKeyNoKey', 'PhanTypeMismatchArgument'], '_inc/lib/core-api/wpcom-endpoints/service-api-keys.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanTypeArraySuspicious', 'PhanTypeMismatchReturnProbablyReal'], '_inc/lib/core-api/wpcom-endpoints/trait-wpcom-rest-api-proxy-request-trait.php' => ['PhanPluginDuplicateConditionalNullCoalescing', 'PhanUndeclaredProperty'], diff --git a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/publicize-connections.php b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/publicize-connections.php index 67fa5b25ced9e..35ffcbed109a9 100644 --- a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/publicize-connections.php +++ b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/publicize-connections.php @@ -29,32 +29,11 @@ class WPCOM_REST_API_V2_Endpoint_List_Publicize_Connections extends WP_REST_Cont */ public $wpcom_is_wpcom_only_endpoint = true; - /** - * Constructor. - */ - public function __construct() { - $this->namespace = 'wpcom/v2'; - $this->rest_base = 'publicize/connections'; - - add_action( 'rest_api_init', array( $this, 'register_routes' ) ); - } - /** * Called automatically on `rest_api_init()`. */ public function register_routes() { - register_rest_route( - $this->namespace, - '/' . $this->rest_base, - array( - array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => array( $this, 'get_items' ), - 'permission_callback' => array( $this, 'get_items_permission_check' ), - ), - 'schema' => array( $this, 'get_public_item_schema' ), - ) - ); + // Endpoint moved to publicize package. } /** diff --git a/projects/plugins/jetpack/changelog/update-move-wpcom-v2-publicize-connections-to-publicize b/projects/plugins/jetpack/changelog/update-move-wpcom-v2-publicize-connections-to-publicize new file mode 100644 index 0000000000000..5cb09fcc5fe9d --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-move-wpcom-v2-publicize-connections-to-publicize @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Moved wpcom/v2/publicize/connections endpoint to publicize package