Created
June 7, 2015 18:45
-
-
Save abachuk/24bb83bc6c9a677b6c3c to your computer and use it in GitHub Desktop.
WordPress plugin extending CMB2 metaboxes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: NDM metaboxes | |
Description: portfolio metaboxes for NDM | |
Version: 0.11 | |
Author: Alex Bachuk | |
Author URI: http://alexbachuk.com | |
License: GPL2 | |
*/ | |
?> | |
<?php | |
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( 'cmb2/init.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 NDM metaboxes requires the CMB2 plugin to be installed and active.</p></div><?php | |
} | |
include( plugin_dir_path( __FILE__ ) . 'post-metabox.php'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment