Check WordPress Plugin Dependencies

Today, We want to share with you Check WordPress Plugin Dependencies.In this post we will show you wordpress plugin require another plugin, hear for how to check a plugin is activated or not in wordpress we will give you demo and example for implement.In this post, we will learn about How to check if certain plugin exists and in expected version with an example.

Check WordPress Plugin Dependencies

There are the Following The simple About Check WordPress Plugin Dependencies Full Information With Example and source code.

As I will cover this Post with live Working example to develop wordpress check if plugin is used, so the How to check WordPress plugin dependencies for this example is following below.

WordPress check if plugin is active

Check in Admin Area

if (is_plugin_active('woocommerce/woocommerce.php')) { 
	// plugin is active
}

Check on front-end

include_once(ABSPATH .'wp-admin/includes/plugin.php');

if (is_plugin_active('woocommerce/woocommerce.php')) { 
	// plugin is active
}

Checking for a Plugin Dependency on Activation

function to run on activation

function your_custom_plugin_addon_activate() {
  
    if( !class_exists( 'WooCommerce' ) ) {
        deactivate_plugins( plugin_basename( __FILE__ ) );
        wp_die( __( 'Please install and Activate WooCommerce.', 'http://wordpress.org/extend/plugins/woocommerce/' ), 'Plugin dependency check', array( 'back_link' => true ) );
    }
}

sets up activation hook

register_activation_hook(__FILE__, 'your_custom_plugin_addon_activate');

Check if WooCommerce is active

if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
    // Put your plugin code here
}
Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Check Word Press Plugin Dependencies.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment