-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
173 lines (141 loc) · 5.13 KB
/
index.php
File metadata and controls
173 lines (141 loc) · 5.13 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
/**
* Check if the class does not exits then only allow the file to add
*/
if ( ! class_exists( 'WPBoilerplate_Plugins_Dependency' ) ) {
abstract class WPBoilerplate_Plugins_Dependency {
/**
* The slug of this plugin name.
*
* @since 1.0.0
* @access private
* @var string $plugin_name The ID of this plugin.
*/
public $plugin_name;
/**
* The plugin file directory.
*
* @since 1.0.0
* @access private
* @var string $plugin_name The ID of this plugin.
*/
public $plugin_files;
function __construct() {
add_filter( $this->plugin_name . '-load', array( $this, 'boilerplate_load' ) );
}
/**
* Get the currnet plugin paths
*/
public function get_plugin_name() {
$plugin_data = get_plugin_data( $this->plugin_files );
return $plugin_data['Name'];
}
/**
* Load this function on plugin load hook
*/
public function boilerplate_load( $load ) {
if ( empty( $this->constant_define() ) ) {
$load = false;
$this->constant_not_define_hook();
} elseif ( $this->constant_define() && empty( $this->constant_mini_version() ) ) {
$load = false;
$this->constant_mini_version_hook();
}
return $load;
}
/**
* Load this function on plugin load hook
*/
public function constant_define() {
$string = (string) $this->constant_name();
if ( defined( $string ) ) {
return true;
}
return false;
}
/**
* Load this function on plugin load hook
*/
function constant_version( $constant_name = false ) {
if ( empty( $constant_name ) ) {
$constant_name = $this->constant_name();
}
if ( defined( $constant_name ) ) {
return constant( $constant_name );
}
return false;
}
/**
* Load this function on plugin load hook
*/
public function constant_mini_version() {
if ( version_compare( $this->constant_version(), $this->mini_version() , '>=' ) ) {
return true;
}
return false;
}
/**
* Load this function on plugin load hook
*/
public function error_message_hooks( $call ) {
if ( defined( 'WP_CLI' ) ) {
WP_CLI::warning( $this->$call() );
} else {
add_action( 'admin_notices', array( $this, $call ) );
add_action( 'network_admin_notices', array( $this, $call ) );
}
}
/**
* Load this function on plugin load hook
*/
public function constant_not_define_hook() {
$this->error_message_hooks( 'constant_not_define_message' );
}
/**
* Load this function on plugin load hook
*/
public function constant_mini_version_hook() {
$this->error_message_hooks( 'constant_mini_version_message' );
}
/**
* Load this function on plugin load hook
*/
public function error_message( $call ) {
echo '<div class="error fade"><p>';
$this->$call();
echo '</p></div>';
}
/**
* Load this function on plugin load hook
*/
public function constant_not_define_message() {
$this->error_message( 'constant_not_define_text' );
}
/**
* Load this function on plugin load hook
*/
public function constant_mini_version_message() {
$this->error_message( 'constant_mini_version_text' );
}
/**
* Load this function on plugin load hook
* Example: _e('<strong>BuddyBoss Sorting Option In Network Search</strong></a> requires the BuddyBoss Platform plugin to work. Please <a href="https://buddyboss.com/platform/" target="_blank">install BuddyBoss Platform</a> first.', 'buddyboss-sorting-option-in-network-search');
*/
abstract function constant_not_define_text();
/**
* Load this function on plugin load hook
* Example: printf( __('<strong>BuddyBoss Sorting Option In Network Search</strong></a> requires BuddyBoss Platform plugin version %s or higher to work. Please update BuddyBoss Platform.', 'buddyboss-sorting-option-in-network-search'), BP_PLATFORM_VERSION_MINI_VERSION );
*/
abstract function constant_mini_version_text();
/**
* Load this function on plugin load hook
*/
abstract function constant_name();
/**
* Load this function on plugin load hook
*/
abstract function mini_version();
}
}