diff --git a/Tests/Fixtures/classes/ThirdParty/Hostings/Extendify/HidePluginFamilyTest.php b/Tests/Fixtures/classes/ThirdParty/Hostings/Extendify/HidePluginFamilyTest.php new file mode 100644 index 00000000..4c2036fe --- /dev/null +++ b/Tests/Fixtures/classes/ThirdParty/Hostings/Extendify/HidePluginFamilyTest.php @@ -0,0 +1,13 @@ + [ + 'value' => false, + 'option' => false, + 'expected' => false, + ], + 'testShouldReturnTrueWhenOptionPresent' => [ + 'value' => false, + 'option' => 'some_site_id', + 'expected' => true, + ], +]; diff --git a/Tests/Fixtures/inc/functions/Partners/ImagifySavePartnerHideOurPluginsTest.php b/Tests/Fixtures/inc/functions/Partners/ImagifySavePartnerHideOurPluginsTest.php deleted file mode 100644 index 00f2c12c..00000000 --- a/Tests/Fixtures/inc/functions/Partners/ImagifySavePartnerHideOurPluginsTest.php +++ /dev/null @@ -1,11 +0,0 @@ - [ - 'partner' => 'unknown_partner', - 'expected' => false, - ], - 'testShouldSaveWhenPartnerIsInList' => [ - 'partner' => 'extendify', - 'expected' => 'extendify', - ], -]; diff --git a/Tests/Unit/classes/ThirdParty/Hostings/Extendify/HidePluginFamilyTest.php b/Tests/Unit/classes/ThirdParty/Hostings/Extendify/HidePluginFamilyTest.php new file mode 100644 index 00000000..82a92f7d --- /dev/null +++ b/Tests/Unit/classes/ThirdParty/Hostings/Extendify/HidePluginFamilyTest.php @@ -0,0 +1,25 @@ +justReturn( $option ); + + $this->assertSame( + $expected, + $extendify->hide_plugin_family( $value ) + ); + } +} diff --git a/Tests/Unit/inc/functions/Partners/ImagifySavePartnerHideOurPluginsTest.php b/Tests/Unit/inc/functions/Partners/ImagifySavePartnerHideOurPluginsTest.php deleted file mode 100644 index 9c060db9..00000000 --- a/Tests/Unit/inc/functions/Partners/ImagifySavePartnerHideOurPluginsTest.php +++ /dev/null @@ -1,35 +0,0 @@ -never(); - } else { - Functions\expect( 'update_option' ) - ->once() - ->with( 'imagify_partner_hide_our_plugins', $expected ); - } - - imagify_save_partner_hide_our_plugins( $partner ); - } -} diff --git a/classes/ThirdParty/Hostings/Extendify.php b/classes/ThirdParty/Hostings/Extendify.php new file mode 100644 index 00000000..18929135 --- /dev/null +++ b/classes/ThirdParty/Hostings/Extendify.php @@ -0,0 +1,39 @@ + 'hide_plugin_family', + ]; + } + + /** + * Hide the plugin family if the Extendify site ID option is present. + * + * @param bool $hide Current value. + * + * @return bool + */ + public function hide_plugin_family( $hide ) { + $option = get_option( 'extendify_site_id', false ); + + if ( false === $option ) { + return $hide; + } + + return true; + } +} diff --git a/classes/ThirdParty/ServiceProvider.php b/classes/ThirdParty/ServiceProvider.php index bbd22496..5aed2b16 100644 --- a/classes/ThirdParty/ServiceProvider.php +++ b/classes/ThirdParty/ServiceProvider.php @@ -4,6 +4,7 @@ namespace Imagify\ThirdParty; use Imagify\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider; +use Imagify\ThirdParty\Hostings\Extendify; use Imagify\ThirdParty\Plugins\GravityForms; /** @@ -17,6 +18,7 @@ class ServiceProvider extends AbstractServiceProvider { */ protected $provides = [ 'gravity_from_subscriber', + Extendify::class, ]; /** @@ -26,6 +28,7 @@ class ServiceProvider extends AbstractServiceProvider { */ public $subscribers = [ 'gravity_from_subscriber', + Extendify::class, ]; /** @@ -55,5 +58,6 @@ public function get_subscribers() { */ public function register(): void { $this->getContainer()->addShared( 'gravity_from_subscriber', GravityForms::class ); + $this->getContainer()->addShared( Extendify::class ); } } diff --git a/inc/classes/class-imagify-views.php b/inc/classes/class-imagify-views.php index d83d6781..c47d0b89 100644 --- a/inc/classes/class-imagify-views.php +++ b/inc/classes/class-imagify-views.php @@ -204,7 +204,7 @@ public function display_settings_page() { $plugins_array = $plugin_family->get_filtered_plugins( 'imagify/imagify' ); $data = [ - 'hide_plugin_family' => (bool) get_option( 'imagify_partner_hide_our_plugins' ), + 'hide_plugin_family' => wpm_apply_filters_typed( 'boolean', 'imagify_hide_plugin_family', false ), 'plugin_family' => $plugins_array['uncategorized'], ]; diff --git a/inc/classes/class-imagify.php b/inc/classes/class-imagify.php index cf3a5cc3..3bab7a6f 100644 --- a/inc/classes/class-imagify.php +++ b/inc/classes/class-imagify.php @@ -158,8 +158,6 @@ public function create_user( $data ) { ); if ( ! is_wp_error( $response ) && isset( $data['partner'] ) ) { - imagify_save_partner_hide_our_plugins( $data['partner'] ); - imagify_delete_partner(); } diff --git a/inc/common/partners.php b/inc/common/partners.php index 5c8646f2..7c17a16e 100755 --- a/inc/common/partners.php +++ b/inc/common/partners.php @@ -13,14 +13,6 @@ */ function imagify_maybe_delete_partner_on_option_update( $old_value, $new_value ) { if ( empty( $old_value['api_key'] ) && ! empty( $new_value['api_key'] ) ) { - $partner = imagify_get_partner(); - - if ( false === $partner ) { - return; - } - - imagify_save_partner_hide_our_plugins( $partner ); - imagify_delete_partner(); } } diff --git a/inc/functions/partners.php b/inc/functions/partners.php index 884194f1..da3ac1c4 100755 --- a/inc/functions/partners.php +++ b/inc/functions/partners.php @@ -34,24 +34,3 @@ function imagify_delete_partner() { delete_option( 'imagifyp_id' ); } } - -/** - * Save the partner ID to hide our other plugins if needed - * - * @since 2.2.7 - * - * @param string|bool $partner Partner ID. - * - * @return void - */ -function imagify_save_partner_hide_our_plugins( $partner ) { - $partners = [ - 'extendify', - ]; - - if ( ! in_array( $partner, $partners, true ) ) { - return; - } - - update_option( 'imagify_partner_hide_our_plugins', $partner ); -} diff --git a/uninstall.php b/uninstall.php index b53be1d8..d5942541 100755 --- a/uninstall.php +++ b/uninstall.php @@ -11,7 +11,6 @@ delete_option( 'imagify_data' ); delete_option( 'ngg_imagify_data_db_version' ); delete_option( $wpdb->prefix . 'ngg_imagify_data_db_version' ); -delete_option( 'imagify_partner_hide_our_plugins' ); // Delete all transients. delete_site_transient( 'imagify_activation' );