Skip to content

Instantly share code, notes, and snippets.

@collinprice
Created July 17, 2014 18:27
Show Gist options
  • Save collinprice/d903be180944459ae35a to your computer and use it in GitHub Desktop.
Save collinprice/d903be180944459ae35a to your computer and use it in GitHub Desktop.
Wordpress Plugin Dependancy
add_action( 'admin_init', 'check_wpjobboard_activate' );
function check_wpjobboard_activate() {
if ( is_admin() && current_user_can( 'activate_plugins' ) && !is_plugin_active( 'wpjobboard/index.php' ) ) {
add_action( 'admin_notices', 'wpjobboard_timesheets_plugin_notice' );
deactivate_plugins( plugin_basename( __FILE__ ) );
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
}
}
function wpjobboard_timesheets_plugin_notice(){
?><div class="error"><p>Sorry, but Child Plugin requires the Parent plugin to be installed and active.</p></div><?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment