1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Plugin Name: Conflicting Plugin |
5
|
|
|
* License: GPL2+ |
6
|
|
|
*/ |
7
|
|
|
error_log( 'loading conflicting plugin' ); |
8
|
|
|
/** |
9
|
|
|
* THIS CODE WOULD NEED TO BE DUPLICATED IN EACH PLUGIN... |
10
|
|
|
*/ |
11
|
|
View Code Duplication |
if ( ! function_exists( 'jetpack_enqueue_library' ) ) { |
12
|
|
|
function jetpack_enqueue_library( $class_name, $version, $path ) { |
13
|
|
|
global $jetpack_libraries; |
14
|
|
|
if ( ! is_array( $jetpack_libraries ) ) { |
15
|
|
|
$jetpack_libraries = array(); |
16
|
|
|
} |
17
|
|
|
if ( ! isset( $jetpack_libraries[ $class_name ] ) ) { |
18
|
|
|
$jetpack_libraries[ $class_name ] = array(); |
19
|
|
|
} |
20
|
|
|
$jetpack_libraries[ $class_name ][] = array( 'version' => $version, 'path' => $path ); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
// add the autoloader |
24
|
|
|
spl_autoload_register( function ($class_name) { |
25
|
|
|
global $jetpack_libraries; |
26
|
|
|
if ( ! isset( $jetpack_libraries[ $class_name ] ) ) { |
27
|
|
|
// the library is not registered try a different autoloader |
28
|
|
|
return; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
if ( ! did_action( 'plugin_loaded' ) ) { |
32
|
|
|
_doing_it_wrong( $class_name , 'Not all plugins have loaded yet!' ); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
$initial = array_shift($jetpack_libraries[ $class_name ] ); |
36
|
|
|
$max_version_info = array_reduce( $jetpack_libraries[ $class_name ], function( $carry_class_info, $class_info ) { |
37
|
|
|
if ( version_compare( $class_info['version'], $carry_class_info['version'], '>' ) ) { |
38
|
|
|
return $class_info; |
39
|
|
|
} |
40
|
|
|
return $carry_class_info; |
41
|
|
|
}, $initial ); |
42
|
|
|
|
43
|
|
|
require_once $max_version_info['path']; |
44
|
|
|
} ); |
45
|
|
|
} |
46
|
|
|
/** |
47
|
|
|
* END OF DUPLICATE CODE |
48
|
|
|
*/ |
49
|
|
|
|
50
|
|
|
jetpack_enqueue_library( 'Jetpack', '1', plugin_dir_path( __FILE__ ) . 'conflicting-plugin/class.jetpack.php' ); |
51
|
|
|
jetpack_enqueue_library( 'Jetpack_Constants', '7.4', plugin_dir_path( __FILE__ ) . 'conflicting-plugin/class.jetpack-constants.php' ); |
52
|
|
|
|
53
|
|
|
add_action( 'plugins_loaded', function() { |
54
|
|
|
// This method only exits in the VERSION 7.4 of the library. |
55
|
|
|
Jetpack_Constants::log_constant( 'JETPACK__VERSION' ); |
|
|
|
|
56
|
|
|
} ); |
57
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.