Skip to content

Commit

Permalink
Use the computed is_wpcom
Browse files Browse the repository at this point in the history
  • Loading branch information
manzoorwanijk committed Dec 11, 2024
1 parent bb4b1a2 commit 646a5d4
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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' );
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 646a5d4

Please sign in to comment.