Skip to content

Commit

Permalink
CodeClean up done.
Browse files Browse the repository at this point in the history
  • Loading branch information
varunsridharan committed Jun 28, 2019
1 parent 4bfe9bd commit b151452
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 51 deletions.
15 changes: 5 additions & 10 deletions src/dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,23 @@ public static function plugin_data( $file, $markup = true, $translate = true ) {
* @return string|bool
*/
public static function version( $plugin_file ) {
$return = false;
switch ( strtolower( $plugin_file ) ) {
case 'wordpress':
global $wp_version;
$return = $wp_version;
return $wp_version;
break;
case 'php':
$return = PHP_VERSION;
return PHP_VERSION;
break;
case 'mysql':
global $wpdb;
$return = $wpdb->db_version();
return $wpdb->db_version();
break;
default:
$data = self::plugin_data( $plugin_file, true, false );
if ( isset( $data['Version'] ) ) {
$return = $data['Version'];
}
return ( isset( $data['Version'] ) ) ? $data['Version'] : false;
break;
}
return $return;
}

/**
Expand Down Expand Up @@ -208,5 +204,4 @@ public static function version_lt( $plugin_file, $version ) {
return ( false !== self::version( $plugin_file ) && version_compare( self::version( $plugin_file ), $version, '<' ) );
}
}

}
}
57 changes: 16 additions & 41 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
* @license GPLV3 Or Greater (https://www.gnu.org/licenses/gpl-3.0.txt)
*/

use Varunsridharan\WordPress\Dependencies;

if ( ! function_exists( 'wp_is_plugin_active' ) ) {
/**
* Checks if Plugin is active.
*
* @param $plugin_file
*
* @return bool
* @uses \Varunsridharan\WordPress\Dependencies::is_active()
*
*/
function wp_is_plugin_active( $plugin_file ) {
return \Varunsridharan\WordPress\Dependencies::is_active( $plugin_file );
return Dependencies::is_active( $plugin_file );
}
}

Expand All @@ -31,10 +31,9 @@ function wp_is_plugin_active( $plugin_file ) {
* @param $plugin_file
*
* @return bool
* @uses \Varunsridharan\WordPress\Dependencies::is_active()
*/
function wp_is_plugin_installed( $plugin_file ) {
return \Varunsridharan\WordPress\Dependencies::is_installed( $plugin_file );
return Dependencies::is_installed( $plugin_file );
}
}

Expand All @@ -45,11 +44,9 @@ function wp_is_plugin_installed( $plugin_file ) {
* @param $plugin_file
*
* @return bool
* @uses \Varunsridharan\WordPress\Dependencies::is_network_active()
*
*/
function wp_is_plugin_network_active( $plugin_file ) {
return \Varunsridharan\WordPress\Dependencies::is_network_active( $plugin_file );
return Dependencies::is_network_active( $plugin_file );
}
}

Expand All @@ -60,11 +57,9 @@ function wp_is_plugin_network_active( $plugin_file ) {
* @param $plugin_file
*
* @return bool
* @uses \Varunsridharan\WordPress\Dependencies::is_site_active()
*
*/
function wp_is_site_plugin_active( $plugin_file ) {
return \Varunsridharan\WordPress\Dependencies::is_site_active( $plugin_file );
return Dependencies::is_site_active( $plugin_file );
}
}

Expand All @@ -75,11 +70,9 @@ function wp_is_site_plugin_active( $plugin_file ) {
* @param $plugin_file
*
* @return bool
* @uses \Varunsridharan\WordPress\Dependencies::is_inactive()
*
*/
function wp_is_plugin_inactive( $plugin_file ) {
return \Varunsridharan\WordPress\Dependencies::is_inactive( $plugin_file );
return Dependencies::is_inactive( $plugin_file );
}
}

Expand All @@ -90,11 +83,9 @@ function wp_is_plugin_inactive( $plugin_file ) {
* @param $plugin
*
* @return string|bool
* @uses \Varunsridharan\WordPress\Dependencies::version()
*
*/
function plugin_version( $plugin ) {
return \Varunsridharan\WordPress\Dependencies::version( $plugin );
return Dependencies::version( $plugin );
}
}

Expand All @@ -106,11 +97,9 @@ function plugin_version( $plugin ) {
* @param $compare_version
*
* @return bool
* @uses \Varunsridharan\WordPress\Dependencies::version_gt()
*
*/
function plugin_version_gt( $plugin, $compare_version ) {
return \Varunsridharan\WordPress\Dependencies::version_gt( $plugin, $compare_version );
return Dependencies::version_gt( $plugin, $compare_version );
}
}

Expand All @@ -122,11 +111,9 @@ function plugin_version_gt( $plugin, $compare_version ) {
* @param $compare_version
*
* @return bool
* @uses \Varunsridharan\WordPress\Dependencies::version_gte()
*
*/
function plugin_version_gte( $plugin, $compare_version ) {
return \Varunsridharan\WordPress\Dependencies::version_gte( $plugin, $compare_version );
return Dependencies::version_gte( $plugin, $compare_version );
}
}

Expand All @@ -138,11 +125,9 @@ function plugin_version_gte( $plugin, $compare_version ) {
* @param $compare_version
*
* @return bool
* @uses \Varunsridharan\WordPress\Dependencies::version_lte()
*
*/
function plugin_version_lte( $plugin, $compare_version ) {
return \Varunsridharan\WordPress\Dependencies::version_lte( $plugin, $compare_version );
return Dependencies::version_lte( $plugin, $compare_version );
}
}

Expand All @@ -154,11 +139,9 @@ function plugin_version_lte( $plugin, $compare_version ) {
* @param $compare_version
*
* @return bool
* @uses \Varunsridharan\WordPress\Dependencies::version_lt()
*
*/
function plugin_version_lt( $plugin, $compare_version ) {
return \Varunsridharan\WordPress\Dependencies::version_lt( $plugin, $compare_version );
return Dependencies::version_lt( $plugin, $compare_version );
}
}

Expand All @@ -170,11 +153,9 @@ function plugin_version_lt( $plugin, $compare_version ) {
* @param $compare_version
*
* @return bool
* @uses \Varunsridharan\WordPress\Dependencies::version_gt()
*
*/
function is_version_gt( $plugin, $compare_version ) {
return \Varunsridharan\WordPress\Dependencies::version_gt( $plugin, $compare_version );
return Dependencies::version_gt( $plugin, $compare_version );
}
}

Expand All @@ -186,11 +167,9 @@ function is_version_gt( $plugin, $compare_version ) {
* @param $compare_version
*
* @return bool
* @uses \Varunsridharan\WordPress\Dependencies::version_gte()
*
*/
function is_version_gte( $plugin, $compare_version ) {
return \Varunsridharan\WordPress\Dependencies::version_gte( $plugin, $compare_version );
return Dependencies::version_gte( $plugin, $compare_version );
}
}

Expand All @@ -202,11 +181,9 @@ function is_version_gte( $plugin, $compare_version ) {
* @param $compare_version
*
* @return bool
* @uses \Varunsridharan\WordPress\Dependencies::version_lte()
*
*/
function is_version_lte( $plugin, $compare_version ) {
return \Varunsridharan\WordPress\Dependencies::version_lte( $plugin, $compare_version );
return Dependencies::version_lte( $plugin, $compare_version );
}
}

Expand All @@ -218,10 +195,8 @@ function is_version_lte( $plugin, $compare_version ) {
* @param $compare_version
*
* @return bool
* @uses \Varunsridharan\WordPress\Dependencies::version_lt()
*
*/
function is_version_lt( $plugin, $compare_version ) {
return \Varunsridharan\WordPress\Dependencies::version_lt( $plugin, $compare_version );
return Dependencies::version_lt( $plugin, $compare_version );
}
}

0 comments on commit b151452

Please sign in to comment.