Skip to content

Commit

Permalink
fix: compatibility with lower PHP versions
Browse files Browse the repository at this point in the history
  • Loading branch information
selul committed Jul 16, 2019
1 parent b706ca7 commit 065ac8e
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions load.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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' ) ) :
/**
Expand Down

0 comments on commit 065ac8e

Please sign in to comment.