diff --git a/projects/packages/publicize/src/rest-endpoints/class-services-controller.php b/projects/packages/publicize/src/rest-endpoints/class-services-controller.php index 942607bf1ed35..dd5324989dfb9 100644 --- a/projects/packages/publicize/src/rest-endpoints/class-services-controller.php +++ b/projects/packages/publicize/src/rest-endpoints/class-services-controller.php @@ -41,6 +41,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. */ @@ -111,12 +120,10 @@ public function get_item_schema() { /** * Get a list of Publicize supported services. * - * @param bool $is_wpcom Whether we are on WPCOM. - * * @return array */ - public static function get_supported_services( $is_wpcom = false ) { - if ( $is_wpcom ) { + public static function get_supported_services() { + if ( self::is_wpcom() ) { if ( function_exists( 'require_lib' ) ) { // @phan-suppress-next-line PhanUndeclaredFunction - phan is dumb not to see the function_exists check. require_lib( 'external-connections' ); @@ -164,7 +171,7 @@ public static function get_supported_services( $is_wpcom = false ) { public function get_items( $request ) { $items = array(); - foreach ( self::get_supported_services( $this->is_wpcom ) as $item ) { + foreach ( self::get_supported_services() as $item ) { $data = $this->prepare_item_for_response( $item, $request ); $items[] = $this->prepare_response_for_collection( $data );