PHP code example of varunsridharan / wp-dependencies
1. Go to this page and download the library: Download varunsridharan/wp-dependencies library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
varunsridharan / wp-dependencies example snippets
/**
* You Need To Pass Main Plugin File To Check If Its Active.
*/
$is_wc_active = wp_is_plugin_active( 'woocommerce/woocommerce.php' );
$is_gutenberg_active = wp_is_plugin_active( 'gutenberg/gutenberg.php' );
/**
* You Need To Pass Main Plugin File To Check If Its Active.
*/
$is_wc_active = wp_is_plugin_network_active( 'woocommerce/woocommerce.php' );
$is_gutenberg_active = wp_is_plugin_network_active( 'gutenberg/gutenberg.php' );
/**
* You Need To Pass Main Plugin File To Check If Its Active.
*/
$is_wc_active = wp_is_site_plugin_active( 'woocommerce/woocommerce.php' );
$is_gutenberg_active = wp_is_site_plugin_active( 'gutenberg/gutenberg.php' );
/**
* You Need To Pass Main Plugin File To Check If Its InActive.
*/
$is_wc_inactive = wp_is_plugin_inactive( 'woocommerce/woocommerce.php' );
$is_gutenberg_inactive = wp_is_plugin_inactive( 'gutenberg/gutenberg.php' );
$wc_version = plugin_version( 'woocommerce/woocommerce.php' );
if($wc_version === '3.0.1'){
// Do your stuff.
}
$wc_version = plugin_version_gt( 'woocommerce/woocommerce.php', '3.0.1' );
if( true === $wc_version ){
// Do your stuff.
}
$wc_version = plugin_version_gte( 'woocommerce/woocommerce.php', '3.0.1' );
if( true === $wc_version ){
// Do your stuff.
}
$wc_version = plugin_version_lt( 'woocommerce/woocommerce.php', '3.0.1' );
if( true === $wc_version ){
// Do your stuff.
}
$wc_version = plugin_version_lte( 'woocommerce/woocommerce.php', '3.0.1' );
if( true === $wc_version ){
// Do your stuff.
}