Skip to content

Commit

Permalink
Improved SSP dependencies check #92
Browse files Browse the repository at this point in the history
  • Loading branch information
zahardev committed Jul 27, 2022
1 parent 368d984 commit 2824cc4
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions ssp-includes/class-ssp-dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,39 @@ public static function init() {
}
}

/**
* @param $minimum_version
*
* @return bool
*/
public static function ssp_active_check( $minimum_version = '' ) {

if (! self::is_ssp_plugin_enabled() ) {
return false;
}

if ( ! $minimum_version ) {
return true;
}


$ssp_version = get_option( 'ssp_version', '1.0' );

return version_compare( $ssp_version, $minimum_version, '>=' );
}

/**
* @return bool
*/
protected static function is_ssp_plugin_enabled() {
$ssp_file_name = 'seriously-simple-podcasting.php';

if ( ! self::$active_plugins ) {
self::init();
}

if ( in_array( 'seriously-simple-podcasting/seriously-simple-podcasting.php', self::$active_plugins, true ) || array_key_exists( 'seriously-simple-podcasting/seriously-simple-podcasting.php', self::$active_plugins ) ) {
if ( $minimum_version ) {
$ssp_version = get_option( 'ssp_version', '1.0' );
if ( version_compare( $ssp_version, $minimum_version, '>=' ) ) {
return true;
}
} else {
foreach ( self::$active_plugins as $active_plugin ) {
if ( false !== strpos( $active_plugin, $ssp_file_name ) ) {
return true;
}
}
Expand Down

0 comments on commit 2824cc4

Please sign in to comment.