Skip to content

Commit

Permalink
apparent issues with 2.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
afragen committed Dec 5, 2024
1 parent cd3703c commit 6eda2c2
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 237 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"afragen/wordpress-plugin-readme-parser": "dev-master",
"afragen/singleton": "dev-master",
"afragen/wp-dependency-installer": "^4",
"freemius/wordpress-sdk": "^2.6"
"freemius/wordpress-sdk": "~2.9.0"
},
"require-dev": {
"wp-coding-standards/wpcs": "^3.0.0",
Expand Down
19 changes: 7 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 7 additions & 12 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,17 +344,17 @@
},
{
"name": "freemius/wordpress-sdk",
"version": "2.10.0",
"version_normalized": "2.10.0.0",
"version": "2.9.0",
"version_normalized": "2.9.0.0",
"source": {
"type": "git",
"url": "https://github.com/Freemius/wordpress-sdk.git",
"reference": "d3c35b9bd430ba335600ef979b8f7f742504ed3a"
"reference": "56696717c5f0b7fb395618e88e1b592d1893e5dc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Freemius/wordpress-sdk/zipball/d3c35b9bd430ba335600ef979b8f7f742504ed3a",
"reference": "d3c35b9bd430ba335600ef979b8f7f742504ed3a",
"url": "https://api.github.com/repos/Freemius/wordpress-sdk/zipball/56696717c5f0b7fb395618e88e1b592d1893e5dc",
"reference": "56696717c5f0b7fb395618e88e1b592d1893e5dc",
"shasum": ""
},
"require": {
Expand All @@ -369,14 +369,9 @@
"szepeviktor/phpstan-wordpress": "^1.3",
"wp-coding-standards/wpcs": "^2.3"
},
"time": "2024-12-03T09:04:58+00:00",
"time": "2024-10-21T10:21:58+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"files": [
"start.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-3.0-only"
Expand All @@ -394,7 +389,7 @@
],
"support": {
"issues": "https://github.com/Freemius/wordpress-sdk/issues",
"source": "https://github.com/Freemius/wordpress-sdk/tree/2.10.0"
"source": "https://github.com/Freemius/wordpress-sdk/tree/2.9.0"
},
"install-path": "../freemius/wordpress-sdk"
},
Expand Down
10 changes: 5 additions & 5 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => 'afragen/git-updater',
'pretty_version' => 'dev-develop',
'version' => 'dev-develop',
'reference' => 'd1e4ba552be5a69ffb631a45602852af073b9d3b',
'reference' => 'cd3703c5cac3364957778591d2c6b1c5feae2881',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -13,7 +13,7 @@
'afragen/git-updater' => array(
'pretty_version' => 'dev-develop',
'version' => 'dev-develop',
'reference' => 'd1e4ba552be5a69ffb631a45602852af073b9d3b',
'reference' => 'cd3703c5cac3364957778591d2c6b1c5feae2881',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down Expand Up @@ -78,9 +78,9 @@
'dev_requirement' => false,
),
'freemius/wordpress-sdk' => array(
'pretty_version' => '2.10.0',
'version' => '2.10.0.0',
'reference' => 'd3c35b9bd430ba335600ef979b8f7f742504ed3a',
'pretty_version' => '2.9.0',
'version' => '2.9.0.0',
'reference' => '56696717c5f0b7fb395618e88e1b592d1893e5dc',
'type' => 'library',
'install_path' => __DIR__ . '/../freemius/wordpress-sdk',
'aliases' => array(),
Expand Down

Large diffs are not rendered by default.

121 changes: 24 additions & 97 deletions vendor/freemius/wordpress-sdk/includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,6 @@ class Freemius extends Freemius_Abstract {
*/
private $_enable_anonymous = true;

/**
* @since 2.9.1
* @var string|null Hints the SDK whether the plugin supports parallel activation mode, preventing the auto-deactivation of the free version when the premium version is activated, and vice versa.
*/
private $_premium_plugin_basename_from_parallel_activation;

/**
* @since 1.1.7.5
* @var bool Hints the SDK if plugin should run in anonymous mode (only adds feedback form).
Expand Down Expand Up @@ -1657,31 +1651,6 @@ private function register_after_settings_parse_hooks() {
);
}
}

if (
$this->is_user_in_admin() &&
$this->is_parallel_activation() &&
$this->_premium_plugin_basename !== $this->premium_plugin_basename_from_parallel_activation
) {
$this->_premium_plugin_basename = $this->premium_plugin_basename_from_parallel_activation;

register_activation_hook(
dirname( $this->_plugin_dir_path ) . '/' . $this->_premium_plugin_basename,
array( &$this, '_activate_plugin_event_hook' )
);
}
}

/**
* Determines if a plugin is running in parallel activation mode.
*
* @author Leo Fajardo (@leorw)
* @since 2.9.1
*
* @return bool
*/
private function is_parallel_activation() {
return ! empty( $this->premium_plugin_basename_from_parallel_activation );
}

/**
Expand Down Expand Up @@ -5186,43 +5155,19 @@ private function parse_settings( &$plugin_info ) {
$this->_plugin :
new FS_Plugin();

$is_premium = $this->get_bool_option( $plugin_info, 'is_premium', true );
$premium_suffix = $this->get_option( $plugin_info, 'premium_suffix', '(Premium)' );

$module_type = $this->get_option( $plugin_info, 'type', $this->_module_type );

$parallel_activation = $this->get_option( $plugin_info, 'parallel_activation' );

if (
! $is_premium &&
is_array( $parallel_activation ) &&
( WP_FS__MODULE_TYPE_PLUGIN === $module_type ) &&
$this->get_bool_option( $parallel_activation, 'enabled' )
) {
$premium_basename = $this->get_option( $parallel_activation, 'premium_version_basename' );

if ( empty( $premium_basename ) ) {
throw new Exception('You need to specify the premium version basename to enable parallel version activation.');
}

$this->premium_plugin_basename_from_parallel_activation = $premium_basename;

if ( is_plugin_active( $premium_basename ) ) {
$is_premium = true;
}
}

$plugin->update( array(
'id' => $id,
'type' => $module_type,
'type' => $this->get_option( $plugin_info, 'type', $this->_module_type ),
'public_key' => $public_key,
'slug' => $this->_slug,
'premium_slug' => $this->get_option( $plugin_info, 'premium_slug', "{$this->_slug}-premium" ),
'parent_plugin_id' => $parent_id,
'version' => $this->get_plugin_version(),
'title' => $this->get_plugin_name( $premium_suffix ),
'file' => $this->_plugin_basename,
'is_premium' => $is_premium,
'is_premium' => $this->get_bool_option( $plugin_info, 'is_premium', true ),
'premium_suffix' => $premium_suffix,
'is_live' => $this->get_bool_option( $plugin_info, 'is_live', true ),
'affiliate_moderation' => $this->get_option( $plugin_info, 'has_affiliation' ),
Expand Down Expand Up @@ -5291,14 +5236,7 @@ private function parse_settings( &$plugin_info ) {
$this->_anonymous_mode = false;
} else {
$this->_enable_anonymous = $this->get_bool_option( $plugin_info, 'enable_anonymous', true );
$this->_anonymous_mode = (
$this->get_bool_option( $plugin_info, 'anonymous_mode', false ) ||
(
$this->apply_filters( 'playground_anonymous_mode', true ) &&
! empty( $_SERVER['HTTP_HOST'] ) &&
FS_Site::is_playground_wp_environment_by_host( $_SERVER['HTTP_HOST'] )
)
);
$this->_anonymous_mode = $this->get_bool_option( $plugin_info, 'anonymous_mode', false );
}
$this->_permissions = $this->get_option( $plugin_info, 'permissions', array() );
$this->_is_bundle_license_auto_activation_enabled = $this->get_option( $plugin_info, 'bundle_license_auto_activation', false );
Expand Down Expand Up @@ -5506,7 +5444,7 @@ function _plugin_code_type_changed() {

if ( $this->is_registered() ) {
// Schedule code type changes event.
$this->maybe_schedule_install_sync_cron();
$this->schedule_install_sync();
}

/**
Expand Down Expand Up @@ -6569,33 +6507,6 @@ private function maybe_schedule_sync_cron() {
$this->schedule_sync_cron();
}

/**
* Instead of running blocking install sync event, execute non blocking scheduled cron job.
*
* @param int $except_blog_id Since 2.0.0 when running in a multisite network environment, the cron execution is consolidated. This param allows excluding specified blog ID from being the cron job executor.
*
* @author Leo Fajardo (@leorw)
* @since 2.9.1
*/
private function maybe_schedule_install_sync_cron( $except_blog_id = 0 ) {
if ( ! $this->is_user_in_admin() ) {
return;
}

if ( $this->is_clone() ) {
return;
}

if (
// The event has been properly scheduled, so no need to reschedule it.
is_numeric( $this->next_install_sync() )
) {
return;
}

$this->schedule_cron( 'install_sync', 'install_sync', 'single', WP_FS__SCRIPT_START_TIME, false, $except_blog_id );
}

/**
* @author Vova Feldman (@svovaf)
* @since 1.1.7.3
Expand Down Expand Up @@ -6693,6 +6604,22 @@ private function get_install_sync_cron_blog_id() {
return $this->get_cron_blog_id( 'install_sync' );
}

/**
* Instead of running blocking install sync event, execute non blocking scheduled wp-cron.
*
* @author Vova Feldman (@svovaf)
* @since 1.1.7.3
*
* @param int $except_blog_id Since 2.0.0 when running in a multisite network environment, the cron execution is consolidated. This param allows excluding excluded specified blog ID from being the cron executor.
*/
private function schedule_install_sync( $except_blog_id = 0 ) {
if ( $this->is_clone() ) {
return;
}

$this->schedule_cron( 'install_sync', 'install_sync', 'single', WP_FS__SCRIPT_START_TIME, false, $except_blog_id );
}

/**
* Unix timestamp for previous install sync cron execution or false if never executed.
*
Expand Down Expand Up @@ -7484,7 +7411,7 @@ function _activate_plugin_event_hook() {
*/
if (
is_plugin_active( $other_version_basename ) &&
$this->apply_filters( 'deactivate_on_activation', ! $this->is_parallel_activation() )
$this->apply_filters( 'deactivate_on_activation', true )
) {
deactivate_plugins( $other_version_basename );
}
Expand All @@ -7498,7 +7425,7 @@ function _activate_plugin_event_hook() {

// Schedule re-activation event and sync.
// $this->sync_install( array(), true );
$this->maybe_schedule_install_sync_cron();
$this->schedule_install_sync();

// If activating the premium module version, add an admin notice to congratulate for an upgrade completion.
if ( $is_premium_version_activation ) {
Expand Down Expand Up @@ -8689,7 +8616,7 @@ private function update_plugin_version_event() {
return;
}

$this->maybe_schedule_install_sync_cron();
$this->schedule_install_sync();
// $this->sync_install( array(), true );
}

Expand Down Expand Up @@ -16047,7 +15974,7 @@ private function update_multisite_data_after_site_deactivation( $context_blog_id
if ( $this->is_install_sync_scheduled() &&
$context_blog_id == $this->get_install_sync_cron_blog_id()
) {
$this->maybe_schedule_install_sync_cron( $context_blog_id );
$this->schedule_install_sync( $context_blog_id );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ static function is_localhost_by_address( $url ) {
fs_ends_with( $subdomain, '.cloudwaysapps.com' ) ||
// Kinsta
(
( fs_starts_with( $subdomain, 'stg-' ) || fs_starts_with( $subdomain, 'staging-' ) || fs_starts_with( $subdomain, 'env-' ) ) &&
( fs_starts_with( $subdomain, 'staging-' ) || fs_starts_with( $subdomain, 'env-' ) ) &&
( fs_ends_with( $subdomain, '.kinsta.com' ) || fs_ends_with( $subdomain, '.kinsta.cloud' ) )
) ||
// DesktopServer
Expand All @@ -208,39 +208,6 @@ static function is_localhost_by_address( $url ) {
);
}

/**
* @author Leo Fajardo (@leorw)
* @since 2.9.1
*
* @param string $host
*
* @return bool
*/
static function is_playground_wp_environment_by_host( $host ) {
// Services aimed at providing a WordPress sandbox environment.
$sandbox_wp_environment_domains = array(
// InstaWP
'instawp.xyz',

// TasteWP
'tastewp.com',

// WordPress Playground
'playground.wordpress.net',
);

foreach ( $sandbox_wp_environment_domains as $domain) {
if (
fs_ends_with( $host, '.' . $domain ) ||
fs_ends_with( $host, '-' . $domain )
) {
return true;
}
}

return false;
}

function is_localhost() {
return ( WP_FS__IS_LOCALHOST_FOR_SERVER || self::is_localhost_by_address( $this->url ) );
}
Expand Down
Loading

0 comments on commit 6eda2c2

Please sign in to comment.