Tuesday, January 28, 2020

WordPress Check Dependent Plugin Is Installed ?

register_activation_hook( __FILE__, 'pkLm_plugin_activate' );
function pkLm_plugin_activate(){
    // Require parent plugin
    if ( ! is_plugin_active( `'plugin_folder/plugin_file'` ) and current_user_can( 'activate_plugins' ) ) {
        // Deactivate the plugin
        deactivate_plugins(__FILE__);
    
        // Throw an error in the wordpress admin console
        $error_message = __('This plugin requires <a href="#">`Dependent Plugin Name`</a> plugin to be active!');
        die($error_message);
    }

No comments:

Post a Comment