Skip to content

Commit

Permalink
Merge pull request #769 from Freemius/hotfix/daniele/symlink-regression
Browse files Browse the repository at this point in the history
Hotfix/daniele/symlink regression
  • Loading branch information
DanieleAlessandra authored Dec 11, 2024
2 parents d3c35b9 + dc387f8 commit 5f57de9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
8 changes: 4 additions & 4 deletions includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -1661,9 +1661,9 @@ 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
) {
$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,
Expand All @@ -1681,7 +1681,7 @@ private function register_after_settings_parse_hooks() {
* @return bool
*/
private function is_parallel_activation() {
return ! empty( $this->premium_plugin_basename_from_parallel_activation );
return ! empty( $this->_premium_plugin_basename_from_parallel_activation );
}

/**
Expand Down Expand Up @@ -5205,7 +5205,7 @@ private function parse_settings( &$plugin_info ) {
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;
$this->_premium_plugin_basename_from_parallel_activation = $premium_basename;

if ( is_plugin_active( $premium_basename ) ) {
$is_premium = true;
Expand Down
1 change: 1 addition & 0 deletions includes/entities/class-fs-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ static function is_playground_wp_environment_by_host( $host ) {

foreach ( $sandbox_wp_environment_domains as $domain) {
if (
( $host === $domain ) ||
fs_ends_with( $host, '.' . $domain ) ||
fs_ends_with( $host, '-' . $domain )
) {
Expand Down
28 changes: 23 additions & 5 deletions start.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* @var string
*/
$this_sdk_version = '2.10.0';
$this_sdk_version = '2.10.1';

#region SDK Selection Logic --------------------------------------------------------------------

Expand Down Expand Up @@ -108,15 +108,33 @@ function_exists( 'wp_is_json_request' ) &&
$is_current_sdk_from_parent_theme = $file_path == $themes_directory . '/' . get_template() . '/' . $theme_candidate_sdk_basename . '/' . basename( $file_path );
}

$theme_name = null;
if ( $is_current_sdk_from_active_theme ) {
$this_sdk_relative_path = '../' . $themes_directory_name . '/' . get_stylesheet() . '/' . $theme_candidate_sdk_basename;
$theme_name = get_stylesheet();
$this_sdk_relative_path = '../' . $themes_directory_name . '/' . $theme_name . '/' . $theme_candidate_sdk_basename;
$is_theme = true;
} else if ( $is_current_sdk_from_parent_theme ) {
$this_sdk_relative_path = '../' . $themes_directory_name . '/' . get_template() . '/' . $theme_candidate_sdk_basename;
$theme_name = get_template();
$this_sdk_relative_path = '../' . $themes_directory_name . '/' . $theme_name . '/' . $theme_candidate_sdk_basename;
$is_theme = true;
} else {
$this_sdk_relative_path = plugin_basename( $fs_root_path );
$is_theme = false;

/**
* If this file was included from another plugin with lower SDK version, and if this plugin is symlinked, then we need to get the actual plugin path,
* as the value right now will be wrong, it will only remove the directory separator from the file_path.
*
* The check of `fs_find_direct_caller_plugin_file` determines that this file was indeed included by a different plugin than the main plugin.
*/
if ( DIRECTORY_SEPARATOR . $this_sdk_relative_path === $fs_root_path && function_exists( 'fs_find_direct_caller_plugin_file' ) ) {
$original_plugin_dir_name = dirname( fs_find_direct_caller_plugin_file( $file_path ) );

// Remove everything before the original plugin directory name.
$this_sdk_relative_path = substr( $this_sdk_relative_path, strpos( $this_sdk_relative_path, $original_plugin_dir_name ) );

unset( $original_plugin_dir_name );
}
}

if ( ! isset( $fs_active_plugins ) ) {
Expand Down Expand Up @@ -202,7 +220,7 @@ function_exists( 'wp_is_json_request' ) &&
) {
if ( $is_theme ) {
// Saving relative path and not only directory name as it could be a subfolder
$plugin_path = $this_sdk_relative_path;
$plugin_path = $theme_name;
} else {
$plugin_path = plugin_basename( fs_find_direct_caller_plugin_file( $file_path ) );
}
Expand Down Expand Up @@ -357,7 +375,7 @@ function_exists( 'wp_is_json_request' ) &&
return;
}

if ( version_compare( $this_sdk_version, $fs_active_plugins->newest->version, '<' ) ) {
if ( isset( $fs_active_plugins->newest ) && version_compare( $this_sdk_version, $fs_active_plugins->newest->version, '<' ) ) {
$newest_sdk = $fs_active_plugins->plugins[ $fs_active_plugins->newest->sdk_path ];

$plugins_or_theme_dir_path = ( ! isset( $newest_sdk->type ) || 'theme' !== $newest_sdk->type ) ?
Expand Down

0 comments on commit 5f57de9

Please sign in to comment.