Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/daniele/symlink regression #769

Merged
merged 5 commits into from
Dec 11, 2024
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
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
Loading