Skip to content
Closed
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
2 changes: 1 addition & 1 deletion includes/managers/class-fs-checkout-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function get_query_params( Freemius $fs, $plugin_id, $plan_id, $licenses
// Allowlist only allowed query params.
$filtered_params = array_intersect_key($filtered_params, $this->_allowed_custom_params);

return array_merge( $context_params, $filtered_params, $_GET, array(
return array_merge( $_GET, $context_params, $filtered_params, array(
// Current plugin version.
'plugin_version' => $fs->get_plugin_version(),
'sdk_version' => WP_FS__SDK_VERSION,
Expand Down
49 changes: 36 additions & 13 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.13.2';
$this_sdk_version = '2.13.2.1';

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

Expand Down Expand Up @@ -93,20 +93,43 @@ function_exists( 'wp_is_json_request' ) &&
$themes_directory = fs_normalize_path( get_theme_root( get_stylesheet() ) );
$themes_directory_name = basename( $themes_directory );

// This change ensures that the condition works even if the SDK is located in a subdirectory (e.g., vendor)
$theme_candidate_sdk_basename = str_replace( $themes_directory . '/' . get_stylesheet() . '/', '', $fs_root_path );
$active_theme_directory = fs_normalize_path( $themes_directory . '/' . get_stylesheet() );
$active_theme_realpath = fs_normalize_path( realpath( $active_theme_directory ) );
if ( ! $active_theme_realpath ) {
$active_theme_realpath = $active_theme_directory;
}

// Check if the current file is part of the active theme.
$is_current_sdk_from_active_theme = $file_path == $themes_directory . '/' . get_stylesheet() . '/' . $theme_candidate_sdk_basename . '/' . basename( $file_path );
$is_current_sdk_from_parent_theme = false;
$parent_theme_directory = fs_normalize_path( $themes_directory . '/' . get_template() );
$parent_theme_realpath = fs_normalize_path( realpath( $parent_theme_directory ) );
if ( ! $parent_theme_realpath ) {
$parent_theme_realpath = $parent_theme_directory;
}

// Check if the current file is part of the parent theme.
if ( ! $is_current_sdk_from_active_theme ) {
$theme_candidate_sdk_basename = str_replace( $themes_directory . '/' . get_template() . '/',
'',
$fs_root_path );
$is_current_sdk_from_parent_theme = $file_path == $themes_directory . '/' . get_template() . '/' . $theme_candidate_sdk_basename . '/' . basename( $file_path );
}
$file_path_real = fs_normalize_path( realpath( $file_path ) );
if ( ! $file_path_real ) {
$file_path_real = $file_path;
}

$fs_root_path_real = fs_normalize_path( realpath( $fs_root_path ) );
if ( ! $fs_root_path_real ) {
$fs_root_path_real = $fs_root_path;
}

$theme_candidate_sdk_basename = '';
$is_current_sdk_from_active_theme = false;
$is_current_sdk_from_parent_theme = false;

// Check if the current file is part of the active theme.
if ( 0 === strpos( $fs_root_path_real, $active_theme_realpath . '/' ) ) {
$theme_candidate_sdk_basename = substr( $fs_root_path_real, strlen( $active_theme_realpath ) + 1 );
$is_current_sdk_from_active_theme = ( $file_path_real === $active_theme_realpath . '/' . $theme_candidate_sdk_basename . '/' . basename( $file_path ) );
}

// Check if the current file is part of the parent theme.
if ( ! $is_current_sdk_from_active_theme && 0 === strpos( $fs_root_path_real, $parent_theme_realpath . '/' ) ) {
$theme_candidate_sdk_basename = substr( $fs_root_path_real, strlen( $parent_theme_realpath ) + 1 );
$is_current_sdk_from_parent_theme = ( $file_path_real === $parent_theme_realpath . '/' . $theme_candidate_sdk_basename . '/' . basename( $file_path ) );
}

$theme_name = null;
if ( $is_current_sdk_from_active_theme ) {
Expand Down
Loading