Skip to content

Commit

Permalink
Don't force to pass $is_wpcom
Browse files Browse the repository at this point in the history
  • Loading branch information
manzoorwanijk committed Dec 12, 2024
1 parent a8835c2 commit 460db14
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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 );
}

Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 460db14

Please sign in to comment.