Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/paid-memberships-pro/includes/compatibility.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
3
+
/**
4
+
* Check if certain plugins or themes are installed and activated
5
+
* and if found dynamically load the relevant /includes/compatibility/ files.
6
+
*/
7
+
function pmpro_compatibility_checker() {
8
+
$compat_checks = [
9
+
[
10
+
'file' => 'siteorigin.php',
11
+
'check_type' => 'constant',
12
+
'check_value' => 'SITEORIGIN_PANELS_VERSION',
13
+
],
14
+
[
15
+
'file' => 'elementor.php',
16
+
'check_type' => 'constant',
17
+
'check_value' => 'ELEMENTOR_VERSION',
18
+
],
19
+
[
20
+
'file' => 'beaver-builder.php',
21
+
'check_type' => 'constant',
22
+
'check_value' => 'FL_BUILDER_VERSION',
23
+
],
24
+
[
25
+
'file' => 'theme-my-login.php',
26
+
'check_type' => 'class',
27
+
'check_value' => 'Theme_My_Login',
28
+
],
29
+
[
30
+
'file' => 'woocommerce.php',
31
+
'check_type' => 'constant',
32
+
'check_value' => 'WC_PLUGIN_FILE',
33
+
],
34
+
[
35
+
'file' => 'wp-engine.php',
36
+
'check_type' => 'function',
37
+
'check_value' => 'wpe_filter_site_url',
38
+
],
39
+
[
40
+
'file' => 'divi.php',
41
+
'check_type' => 'constant',
42
+
'check_value' => 'ET_BUILDER_PLUGIN_DIR',
43
+
],
44
+
[
45
+
'file' => 'jetpack.php',
46
+
'check_type' => 'class',
47
+
'check_value' => 'Jetpack',
48
+
],
49
+
[
50
+
'file' => 'avada.php',
51
+
'check_type' => 'constant',
52
+
'check_value' => 'FUSION_BUILDER_VERSION'
53
+
],
54
+
[
55
+
'file' => 'oxygen-builder.php',
56
+
'check_type' => 'class',
57
+
'check_value' => 'OxyEl'
58
+
],
59
+
[
60
+
'file' => 'lifterlms.php',
61
+
'check_type' => 'function',
62
+
'check_value' => 'llms'
63
+
],
64
+
[
65
+
'file' => 'buddypress.php',
66
+
'check_type' => 'class',
67
+
'check_value' => 'BuddyPress' //BuddyBoss uses this class, too.
68
+
],
69
+
[
70
+
'file' => 'bluehost-wordpress-plugin.php',
71
+
'check_type' => 'constant',
72
+
'check_value' => 'BLUEHOST_PLUGIN_VERSION',
73
+
],
74
+
[
75
+
'file' => 'wp-fusion-lite.php',
76
+
'check_type' => 'class',
77
+
'check_value' => 'WP_Fusion_Lite',
78
+
],
79
+
[
80
+
'file' => 'pantheon.php',
81
+
'check_type' => 'function',
82
+
'check_value' => 'pantheon_wp_env',
83
+
],
84
+
];
85
+
86
+
foreach ( $compat_checks as $value ) {
87
+
if ( pmpro_compatibility_checker_is_requirement_met( $value ) ) {
88
+
include_once( PMPRO_DIR . '/includes/compatibility/' . $value['file'] ) ;
89
+
}
90
+
}
91
+
}
92
+
add_action( 'plugins_loaded', 'pmpro_compatibility_checker' );
93
+
94
+
/**
95
+
* Check whether the requirement is met.
96
+
*
97
+
* @since 2.6.4
98
+
*
99
+
* @param array $requirement The requirement config (check_type, check_value, check_constant_true).
100
+
*
101
+
* @return bool Whether the requirement is met.
102
+
*/
103
+
function pmpro_compatibility_checker_is_requirement_met( $requirement ) {
104
+
// Make sure we have the keys that we expect.
105
+
if ( ! isset( $requirement['check_type'], $requirement['check_value'] ) ) {
106
+
return false;
107
+
}
108
+
109
+
// Check for a constant and maybe check if the constant is true-ish.
110
+
if ( 'constant' === $requirement['check_type'] ) {
111
+
return (
112
+
defined( $requirement['check_value'] )
113
+
&& (
114
+
empty( $requirement['check_constant_true'] )
115
+
|| constant( $requirement['check_value'] )
116
+
)
117
+
);
118
+
}
119
+
120
+
// Check for a function.
121
+
if ( 'function' === $requirement['check_type'] ) {
122
+
return function_exists( $requirement['check_value'] );
123
+
}
124
+
125
+
// Check for a class.
126
+
if ( 'class' === $requirement['check_type'] ) {
127
+
return class_exists( $requirement['check_value'] );
128
+
}
129
+
130
+
return false;
131
+
}
132
+
133
+
function pmpro_compatibility_checker_themes(){
134
+
135
+
$compat_checks = array(
136
+
array(
137
+
'file' => 'divi.php',
138
+
'check_type' => 'constant',
139
+
'check_value' => 'ET_BUILDER_THEME' //Adds support for the Divi theme.
140
+
),
141
+
array(
142
+
'file' => 'bricks.php',
143
+
'check_type' => 'class',
144
+
'check_value' => 'Bricks\Conditions'
145
+
)
146
+
);
147
+
148
+
foreach ( $compat_checks as $key => $value ) {
149
+
if ( pmpro_compatibility_checker_is_requirement_met( $value ) ) {
150
+
include_once( PMPRO_DIR . '/includes/compatibility/' . $value['file'] ) ;
151
+
}
152
+
}
153
+
154
+
155
+
}
156
+
add_action( 'after_setup_theme', 'pmpro_compatibility_checker_themes' );
157
+
158
+
/**
159
+
* Keep track of plugins that load libraries before PMPro loads its version.
160
+
*
161
+
* @param string $name The name of the library.
162
+
* @param string $path The path of the loaded library.
163
+
* @param string $version The version of the loaded library.
164
+
*
165
+
* @since 2.8
166
+
*/
167
+
function pmpro_track_library_conflict( $name, $path, $version ) {
168
+
// Ignore when PMPro is trying to load.
169
+
if ( strpos( $path, '/plugins/paid-memberships-pro/' ) !== false ) {
170
+
return;
171
+
}
172
+
173
+
// Use a static var for timestamp so we can avoid multiple updates per pageload.
174
+
static $now = null;
175
+
if ( empty( $now ) ) {
176
+
$now = current_time( 'Y-m-d H:i:s' );
177
+
}
178
+
179
+
// Get the current list of library conflicts.
180
+
$library_conflicts = get_option( 'pmpro_library_conflicts', array() );
181
+
182
+
// Make sure we have an entry for this library.
183
+
if ( ! isset( $library_conflicts[ $name ] ) ) {
184
+
$library_conflicts[ $name ] = array();
185
+
}
186
+
187
+
// Make sure we have an entry for this path.
188
+
if ( ! isset( $library_conflicts[ $name ][ $path ] ) ) {
189
+
$library_conflicts[ $name ][ $path ] = array();
190
+
}
191
+
192
+
// Don't save conflict if no time has passed.
193
+
if ( ! empty( $library_conflicts[ $name ][ $path ]['timestamp'] ) && $library_conflicts[ $name ][ $path ]['timestamp'] === $now ) {
194
+
return;
195
+
}
196
+
197
+
// Update the library conflict information.
198
+
$library_conflicts[ $name ][ $path ]['version'] = $version;
199
+
$library_conflicts[ $name ][ $path ]['timestamp'] = $now;
200
+
update_option( 'pmpro_library_conflicts', $library_conflicts, false );
201
+
}