Skip to content

Commit

Permalink
Update script data to use connections from the REST endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
manzoorwanijk committed Dec 19, 2024
1 parent 33936fa commit 6a63224
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions projects/packages/publicize/src/class-publicize-script-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
*/
class Publicize_Script_Data {

const SERVICES_TRANSIENT = 'jetpack_social_services_list';

/**
* Get the publicize instance - properly typed
*
Expand Down Expand Up @@ -160,8 +158,7 @@ public static function get_store_initial_state() {

return array(
'connectionData' => array(
// We do not have this method on WPCOM Publicize class yet.
'connections' => ! $is_wpcom ? self::publicize()->get_all_connections_for_user() : array(),
'connections' => Connections::get_all(),
),
'shareStatus' => $share_status,
);
Expand Down Expand Up @@ -238,17 +235,24 @@ public static function get_api_paths() {

$is_simple_site = ( new Host() )->is_wpcom_simple();

$commom_paths = array(
'refreshConnections' => '/wpcom/v2/publicize/connections?test_connections=1',
);

$specific_paths = array();

if ( $is_simple_site ) {
return array(
'refreshConnections' => '/wpcom/v2/publicize/connection-test-results',
'resharePost' => '/wpcom/v2/posts/{postId}/publicize',

$specific_paths = array(
'resharePost' => '/wpcom/v2/posts/{postId}/publicize',
);
} else {
$specific_paths = array(
'resharePost' => '/jetpack/v4/publicize/{postId}',
);
}

return array(
'refreshConnections' => '/jetpack/v4/publicize/connections?test_connections=1',
'resharePost' => '/jetpack/v4/publicize/{postId}',
);
return array_merge( $commom_paths, $specific_paths );
}

/**
Expand Down

0 comments on commit 6a63224

Please sign in to comment.