-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmb2-expansion.php
62 lines (46 loc) · 1.67 KB
/
cmb2-expansion.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Plugin Name: CMB2 Expansion
* Description: Expansion plugin for CMB2
* Version: 1.3
* Author: Mike Estrada
* Author URI: https://bleucellar.com/
*/
if ( !defined('ABSPATH') )
die ( 'YOU SHALL NOT PASS!' );
define( 'CMB2_EXP_DIR', plugin_dir_path(__FILE__) );
define( 'CMB2_EXP_URL', plugin_dir_url(__FILE__) );
define( 'CMB2_EXP_BASE', plugin_basename( __FILE__ ) );
define( 'CMB2_EXP_VERSION', '1.3' );
// check if CMB2 class is defined (possibly use the PRE ACTIVATION hook)
function cmb2_expansion_plugin_init() {
//check if CMB2 is loaded
if ( defined( 'CMB2_LOADED' ) ) {
// include class files
if ( file_exists( CMB2_EXP_DIR .'/includes/cmb2-expansions.php' ) ){
require_once CMB2_EXP_DIR .'/includes/cmb2-expansions.php';
CMB2_Expansions::singleton();
}
if ( file_exists( CMB2_EXP_DIR .'/includes/cmb2-tabs.php' ) ){
require_once CMB2_EXP_DIR .'/includes/cmb2-tabs.php';
CMB2_Tabs::singleton();
}
if ( file_exists( CMB2_EXP_DIR .'/includes/cmb2-repeat-limit.php' ) ){
require_once CMB2_EXP_DIR .'/includes/cmb2-repeat-limit.php';
CMB2_Repeat_Limit::singleton();
}
} else {
// IF CMB2 NOT LOADED, SHOW ALERT AND DEACTIVATE
require_once ABSPATH . 'wp-admin/includes/plugin.php';
deactivate_plugins( CMB2_EXP_BASE );
add_action( 'admin_notices', 'cmb2_not_active' );
function cmb2_not_active(){ ?>
<div class="notice error cgi-cmb2-notice is-dismissible" >
<p><?php _e( 'CGI CMB2 Expansion depends on CMB2. CMB2 is either not installed or disabled. Therefore, CGI CMB2 Expansion has been disabled', 'cgi-cmb2-exp' ); ?></p>
</div>
<?php
}
}
}
add_action( 'plugins_loaded', 'cmb2_expansion_plugin_init' );
?>