Skip to content
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,13 @@
<?php
return [
'testShouldReturnSameWhenOptionNotPresent' => [
'value' => false,
'option' => false,
'expected' => false,
],
'testShouldReturnTrueWhenOptionPresent' => [
'value' => false,
'option' => 'some_site_id',
'expected' => true,
],
];

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
declare( strict_types=1 );

namespace Imagify\Tests\Unit\classes\ThirdParty\Hostings\Extendify;

use Brain\Monkey\Functions;
use Imagify\Tests\Unit\TestCase;
use Imagify\ThirdParty\Hostings\Extendify;

class HidePluginFamilyTest extends TestCase {
/**
* @dataProvider configTestData
*/
public function testShouldReturnExpected( $value, $option, $expected ) {
$extendify = new Extendify();

Functions\when( 'get_option' )
->justReturn( $option );

$this->assertSame(
$expected,
$extendify->hide_plugin_family( $value )
);
}
}

This file was deleted.

39 changes: 39 additions & 0 deletions classes/ThirdParty/Hostings/Extendify.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
declare( strict_types=1 );

namespace Imagify\ThirdParty\Hostings;

use Imagify\EventManagement\SubscriberInterface;

/**
* Extendify compatibility class
*/
class Extendify implements SubscriberInterface {
/**
* Returns an array of events that this subscriber wants to listen to.
*
* @return array
*/
public static function get_subscribed_events(): array {
return [
'imagify_hide_plugin_family' => '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;
}
}
4 changes: 4 additions & 0 deletions classes/ThirdParty/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Imagify\ThirdParty;

use Imagify\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider;
use Imagify\ThirdParty\Hostings\Extendify;
use Imagify\ThirdParty\Plugins\GravityForms;

/**
Expand All @@ -17,6 +18,7 @@ class ServiceProvider extends AbstractServiceProvider {
*/
protected $provides = [
'gravity_from_subscriber',
Extendify::class,
];

/**
Expand All @@ -26,6 +28,7 @@ class ServiceProvider extends AbstractServiceProvider {
*/
public $subscribers = [
'gravity_from_subscriber',
Extendify::class,
];

/**
Expand Down Expand Up @@ -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 );
}
}
2 changes: 1 addition & 1 deletion inc/classes/class-imagify-views.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
];

Expand Down
2 changes: 0 additions & 2 deletions inc/classes/class-imagify.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
8 changes: 0 additions & 8 deletions inc/common/partners.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
21 changes: 0 additions & 21 deletions inc/functions/partners.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
1 change: 0 additions & 1 deletion uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
Loading