WordPress Plugin Dependancy


//Check if Parent/Parent Plugin is Installed
add_action( 'admin_init', 'child_plugin_has_parent_plugin' );

function child_plugin_has_parent_plugin() {
	if ( is_admin() && current_user_can( 'activate_plugins' ) &&  !is_plugin_active( 'plugin-folder-name/plugin-filename.php' ) ) {
		add_action( 'admin_notices', 'child_plugin_notice' );

		deactivate_plugins( plugin_basename( __FILE__ ) ); 

		if ( isset( $_GET['activate'] ) ) {
			unset( $_GET['activate'] );
		}
	}
}

function child_plugin_notice(){
	?><div class="error"><p>Sorry, but CHILD PLUGIN NAME requires PARENT PLUGIN NAME to be installed and active.</p></div><?php
}
[instagram-feed feed=1]
© 2022 BenaDigital Limited | All Rights Reserved
magnifiercrosschevron-down