From b706ca70d8ae0f4b515a716f353bb5d9aaa7a17c Mon Sep 17 00:00:00 2001 From: Andrei Baicus Date: Tue, 16 Jul 2019 18:33:10 +0300 Subject: [PATCH 1/3] fix: not loading licenser when SDK comes from theme [#62] --- load.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/load.php b/load.php index 9ee4367a..b7b4183c 100644 --- a/load.php +++ b/load.php @@ -20,6 +20,17 @@ global $themeisle_sdk_max_version; global $themeisle_sdk_max_path; +// If this is the latest SDK and it comes from a theme, we should load licenser separately. +$licenser_path = '/src/Modules/Licenser.php'; + +if ( ! file_exists( $themeisle_sdk_path . $licenser_path ) && file_exists( $themeisle_sdk_max_path . $licenser_path ) ) { + add_filter( 'themeisle_sdk_required_files', function ( $to_load ) use ( $themeisle_sdk_max_path, $licenser_path ) { + $to_load[] = $themeisle_sdk_max_path . $licenser_path; + + return $to_load; + } ); +} + if ( version_compare( $themeisle_sdk_version, $themeisle_sdk_max_path ) == 0 && apply_filters( 'themeisle_sdk_should_overwrite_path', false, $themeisle_sdk_path, $themeisle_sdk_max_path ) ) { $themeisle_sdk_max_path = $themeisle_sdk_path; From 065ac8ec6caa06d10d42690f10c1dc8f0b7bc04e Mon Sep 17 00:00:00 2001 From: selul Date: Tue, 16 Jul 2019 19:33:31 +0300 Subject: [PATCH 2/3] fix: compatibility with lower PHP versions --- load.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/load.php b/load.php index b7b4183c..e22da6fc 100644 --- a/load.php +++ b/load.php @@ -21,18 +21,15 @@ global $themeisle_sdk_max_path; // If this is the latest SDK and it comes from a theme, we should load licenser separately. -$licenser_path = '/src/Modules/Licenser.php'; +$themeisle_sdk_relative_licenser_path = '/src/Modules/Licenser.php'; -if ( ! file_exists( $themeisle_sdk_path . $licenser_path ) && file_exists( $themeisle_sdk_max_path . $licenser_path ) ) { - add_filter( 'themeisle_sdk_required_files', function ( $to_load ) use ( $themeisle_sdk_max_path, $licenser_path ) { - $to_load[] = $themeisle_sdk_max_path . $licenser_path; - - return $to_load; - } ); +global $themeisle_sdk_abs_licenser_path; +if ( ! file_exists( $themeisle_sdk_path . $themeisle_sdk_relative_licenser_path ) && file_exists( $themeisle_sdk_max_path . $themeisle_sdk_relative_licenser_path ) ) { + $themeisle_sdk_abs_licenser_path = $themeisle_sdk_max_path . $themeisle_sdk_relative_licenser_path; + add_filter( 'themeisle_sdk_required_files', 'themeisle_sdk_load_licenser_if_present' ); } - if ( version_compare( $themeisle_sdk_version, $themeisle_sdk_max_path ) == 0 && - apply_filters( 'themeisle_sdk_should_overwrite_path', false, $themeisle_sdk_path, $themeisle_sdk_max_path ) ) { + apply_filters( 'themeisle_sdk_should_overwrite_path', false, $themeisle_sdk_path, $themeisle_sdk_max_path ) ) { $themeisle_sdk_max_path = $themeisle_sdk_path; } @@ -41,6 +38,19 @@ $themeisle_sdk_max_path = $themeisle_sdk_path; } +// load the latest sdk version from the active Themeisle products. +if ( ! function_exists( 'themeisle_sdk_load_licenser_if_present' ) ) : + /** + * Always load the licenser, if present. + */ + function themeisle_sdk_load_licenser_if_present() { + global $themeisle_sdk_abs_licenser_path; + $to_load[] = $themeisle_sdk_abs_licenser_path; + + return $to_load; + } +endif; + // load the latest sdk version from the active Themeisle products. if ( ! function_exists( 'themeisle_sdk_load_latest' ) ) : /** From cd50434742c0d0010787b66b42dc5fd3893f9694 Mon Sep 17 00:00:00 2001 From: selul Date: Tue, 16 Jul 2019 19:38:44 +0300 Subject: [PATCH 3/3] fix: preserve loaded when adding the licenser one --- load.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/load.php b/load.php index e22da6fc..3c94bc69 100644 --- a/load.php +++ b/load.php @@ -42,8 +42,10 @@ if ( ! function_exists( 'themeisle_sdk_load_licenser_if_present' ) ) : /** * Always load the licenser, if present. + * + * @param array $to_load Previously files to load. */ - function themeisle_sdk_load_licenser_if_present() { + function themeisle_sdk_load_licenser_if_present( $to_load ) { global $themeisle_sdk_abs_licenser_path; $to_load[] = $themeisle_sdk_abs_licenser_path;