From 460db14b57038c048c335e291f24027c53f1b672 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Wed, 11 Dec 2024 12:42:33 +0530 Subject: [PATCH] Don't force to pass $is_wpcom --- .../class-connections-controller.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/projects/packages/publicize/src/rest-endpoints/class-connections-controller.php b/projects/packages/publicize/src/rest-endpoints/class-connections-controller.php index b2f71bd582944..a30ffd0885d0c 100644 --- a/projects/packages/publicize/src/rest-endpoints/class-connections-controller.php +++ b/projects/packages/publicize/src/rest-endpoints/class-connections-controller.php @@ -42,6 +42,15 @@ public function __construct() { $this->wpcom_is_wpcom_only_endpoint = true; } + /** + * Check if we are on WPCOM. + * + * @return bool + */ + protected static function is_wpcom() { + return defined( 'IS_WPCOM' ) && IS_WPCOM; + } + /** * Register the routes. */ @@ -177,13 +186,12 @@ protected static function get_all_connections( $run_tests = false ) { /** * Get a list of publicize connections. * - * @param bool $is_wpcom Whether we are on WPCOM. * @param bool $run_tests Whether to run tests on the connections. * * @return array */ - public static function get_connections( $is_wpcom, $run_tests = false ) { - if ( $is_wpcom ) { + public static function get_connections( $run_tests = false ) { + if ( self::is_wpcom() ) { return self::get_all_connections( $run_tests ); } @@ -223,7 +231,7 @@ public function get_items( $request ) { $run_tests = $request->get_param( 'test_connections' ); - foreach ( self::get_connections( $this->is_wpcom, $run_tests ) as $item ) { + foreach ( self::get_connections( $run_tests ) as $item ) { $data = $this->prepare_item_for_response( $item, $request ); $items[] = $this->prepare_response_for_collection( $data );