|
15 | 15 | * |
16 | 16 | * @var string |
17 | 17 | */ |
18 | | - $this_sdk_version = '2.10.0.3'; |
| 18 | + $this_sdk_version = '2.10.1.1'; |
19 | 19 |
|
20 | 20 | #region SDK Selection Logic -------------------------------------------------------------------- |
21 | 21 |
|
@@ -108,15 +108,33 @@ function_exists( 'wp_is_json_request' ) && |
108 | 108 | $is_current_sdk_from_parent_theme = $file_path == $themes_directory . '/' . get_template() . '/' . $theme_candidate_sdk_basename . '/' . basename( $file_path ); |
109 | 109 | } |
110 | 110 |
|
| 111 | + $theme_name = null; |
111 | 112 | 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; |
113 | 115 | $is_theme = true; |
114 | 116 | } 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; |
116 | 119 | $is_theme = true; |
117 | 120 | } else { |
118 | 121 | $this_sdk_relative_path = plugin_basename( $fs_root_path ); |
119 | 122 | $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 | + } |
120 | 138 | } |
121 | 139 |
|
122 | 140 | if ( ! isset( $fs_active_plugins ) ) { |
@@ -202,7 +220,7 @@ function_exists( 'wp_is_json_request' ) && |
202 | 220 | ) { |
203 | 221 | if ( $is_theme ) { |
204 | 222 | // 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; |
206 | 224 | } else { |
207 | 225 | $plugin_path = plugin_basename( fs_find_direct_caller_plugin_file( $file_path ) ); |
208 | 226 | } |
@@ -357,7 +375,7 @@ function_exists( 'wp_is_json_request' ) && |
357 | 375 | return; |
358 | 376 | } |
359 | 377 |
|
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, '<' ) ) { |
361 | 379 | $newest_sdk = $fs_active_plugins->plugins[ $fs_active_plugins->newest->sdk_path ]; |
362 | 380 |
|
363 | 381 | $plugins_or_theme_dir_path = ( ! isset( $newest_sdk->type ) || 'theme' !== $newest_sdk->type ) ? |
|
0 commit comments