Skip to content

Commit 7f58ad3

Browse files
authored
Merge pull request #772 from Freemius/hotfix/daniele/symlink-regression
Hotfix/daniele/symlink regression
2 parents f0a685b + 0964f18 commit 7f58ad3

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

includes/class-freemius.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,9 +1661,9 @@ private function register_after_settings_parse_hooks() {
16611661
if (
16621662
$this->is_user_in_admin() &&
16631663
$this->is_parallel_activation() &&
1664-
$this->_premium_plugin_basename !== $this->premium_plugin_basename_from_parallel_activation
1664+
$this->_premium_plugin_basename !== $this->_premium_plugin_basename_from_parallel_activation
16651665
) {
1666-
$this->_premium_plugin_basename = $this->premium_plugin_basename_from_parallel_activation;
1666+
$this->_premium_plugin_basename = $this->_premium_plugin_basename_from_parallel_activation;
16671667

16681668
register_activation_hook(
16691669
dirname( $this->_plugin_dir_path ) . '/' . $this->_premium_plugin_basename,
@@ -1681,7 +1681,7 @@ private function register_after_settings_parse_hooks() {
16811681
* @return bool
16821682
*/
16831683
private function is_parallel_activation() {
1684-
return ! empty( $this->premium_plugin_basename_from_parallel_activation );
1684+
return ! empty( $this->_premium_plugin_basename_from_parallel_activation );
16851685
}
16861686

16871687
/**
@@ -5205,7 +5205,7 @@ private function parse_settings( &$plugin_info ) {
52055205
throw new Exception('You need to specify the premium version basename to enable parallel version activation.');
52065206
}
52075207

5208-
$this->premium_plugin_basename_from_parallel_activation = $premium_basename;
5208+
$this->_premium_plugin_basename_from_parallel_activation = $premium_basename;
52095209

52105210
if ( is_plugin_active( $premium_basename ) ) {
52115211
$is_premium = true;

includes/entities/class-fs-site.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ static function is_playground_wp_environment_by_host( $host ) {
231231

232232
foreach ( $sandbox_wp_environment_domains as $domain) {
233233
if (
234+
( $host === $domain ) ||
234235
fs_ends_with( $host, '.' . $domain ) ||
235236
fs_ends_with( $host, '-' . $domain )
236237
) {

start.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
* @var string
1717
*/
18-
$this_sdk_version = '2.10.0.3';
18+
$this_sdk_version = '2.10.1.1';
1919

2020
#region SDK Selection Logic --------------------------------------------------------------------
2121

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

111+
$theme_name = null;
111112
if ( $is_current_sdk_from_active_theme ) {
112-
$this_sdk_relative_path = '../' . $themes_directory_name . '/' . get_stylesheet() . '/' . $theme_candidate_sdk_basename;
113+
$theme_name = get_stylesheet();
114+
$this_sdk_relative_path = '../' . $themes_directory_name . '/' . $theme_name . '/' . $theme_candidate_sdk_basename;
113115
$is_theme = true;
114116
} else if ( $is_current_sdk_from_parent_theme ) {
115-
$this_sdk_relative_path = '../' . $themes_directory_name . '/' . get_template() . '/' . $theme_candidate_sdk_basename;
117+
$theme_name = get_template();
118+
$this_sdk_relative_path = '../' . $themes_directory_name . '/' . $theme_name . '/' . $theme_candidate_sdk_basename;
116119
$is_theme = true;
117120
} else {
118121
$this_sdk_relative_path = plugin_basename( $fs_root_path );
119122
$is_theme = false;
123+
124+
/**
125+
* 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,
126+
* as the value right now will be wrong, it will only remove the directory separator from the file_path.
127+
*
128+
* The check of `fs_find_direct_caller_plugin_file` determines that this file was indeed included by a different plugin than the main plugin.
129+
*/
130+
if ( DIRECTORY_SEPARATOR . $this_sdk_relative_path === $fs_root_path && function_exists( 'fs_find_direct_caller_plugin_file' ) ) {
131+
$original_plugin_dir_name = dirname( fs_find_direct_caller_plugin_file( $file_path ) );
132+
133+
// Remove everything before the original plugin directory name.
134+
$this_sdk_relative_path = substr( $this_sdk_relative_path, strpos( $this_sdk_relative_path, $original_plugin_dir_name ) );
135+
136+
unset( $original_plugin_dir_name );
137+
}
120138
}
121139

122140
if ( ! isset( $fs_active_plugins ) ) {
@@ -202,7 +220,7 @@ function_exists( 'wp_is_json_request' ) &&
202220
) {
203221
if ( $is_theme ) {
204222
// Saving relative path and not only directory name as it could be a subfolder
205-
$plugin_path = $this_sdk_relative_path;
223+
$plugin_path = $theme_name;
206224
} else {
207225
$plugin_path = plugin_basename( fs_find_direct_caller_plugin_file( $file_path ) );
208226
}
@@ -357,7 +375,7 @@ function_exists( 'wp_is_json_request' ) &&
357375
return;
358376
}
359377

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

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

0 commit comments

Comments
 (0)