Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Social: Use WPCOM plan feature for connections management #37425

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Changed the connections management feature flag check to include the WPCOM plan feature
9 changes: 9 additions & 0 deletions projects/packages/publicize/src/class-publicize-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,15 @@ public function has_connection_feature( $connection ) {
return Current_Plan::supports( "social-$connection-connection" );
}

/**
* Check if the new connections management is enabled is enabled.
*
* @return bool
*/
public function has_connections_management_feature() {
return Current_Plan::supports( 'social-connections-management' );
}

/**
* Get a list of additional connections that are supported by the current plan.
*
Expand Down
9 changes: 5 additions & 4 deletions projects/packages/publicize/src/class-publicize.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,16 @@ public function add_disconnect_notice() {
/**
* Whether to use the v1 admin UI.
*/
public static function use_admin_ui_v1(): bool {
public function use_admin_ui_v1(): bool {

// If the option is set, use it.
if ( get_option( 'jetpack_social_use_admin_ui_v1', false ) ) {
return true;
}

// Otherwise, use the constant.
return defined( 'JETPACK_SOCIAL_USE_ADMIN_UI_V1' ) && JETPACK_SOCIAL_USE_ADMIN_UI_V1;
// Otherwise, check the constant and the plan feature.
return ( defined( 'JETPACK_SOCIAL_USE_ADMIN_UI_V1' ) && JETPACK_SOCIAL_USE_ADMIN_UI_V1 )
|| $this->has_connections_management_feature();
}

/**
Expand Down Expand Up @@ -253,7 +254,7 @@ public function get_all_connections_for_user() {
$user_id = (int) $connection['connection_data']['user_id'];
// phpcs:ignore WordPress.PHP.YodaConditions.NotYoda
if ( $user_id === 0 || $this->user_id() === $user_id ) {
if ( self::use_admin_ui_v1() ) {
if ( $this->use_admin_ui_v1() ) {
$connections_to_return[] = array_merge(
$connection,
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Automattic\Jetpack\Connection\Client;
use Automattic\Jetpack\Connection\Manager;
use Automattic\Jetpack\Modules;
use Automattic\Jetpack\Publicize\Publicize;
use Automattic\Jetpack\Publicize\Social_Image_Generator\Templates;

/**
Expand Down Expand Up @@ -183,13 +182,14 @@ public function get_initial_state() {

$settings = $this->get_settings( true );

$settings['useAdminUiV1'] = Publicize::use_admin_ui_v1();
$settings['useAdminUiV1'] = false;

$settings['is_publicize_enabled'] = false;

$connection = new Manager();

if ( ( new Modules() )->is_active( 'publicize' ) && $connection->has_connected_user() ) {
$settings['useAdminUiV1'] = $publicize->use_admin_ui_v1();
$settings['connectionData'] = array(
'connections' => $publicize->get_all_connections_for_user(),
'adminUrl' => esc_url_raw( $publicize->publicize_connections_url( 'jetpack-social-connections-admin-page' ) ),
Expand Down
Loading