| @@ 11-36 (lines=26) @@ | ||
| 8 | /** |
|
| 9 | * THIS CODE WOULD NEED TO BE DUPLICATED IN EACH PLUGIN... |
|
| 10 | */ |
|
| 11 | if ( ! function_exists( 'jetpack_enqueue_library' ) ) { |
|
| 12 | global $jetpack_libraries; |
|
| 13 | if ( ! is_array( $jetpack_libraries ) ) { |
|
| 14 | $jetpack_libraries = array(); |
|
| 15 | } |
|
| 16 | ||
| 17 | function jetpack_enqueue_library( $class_name, $version, $path ) { |
|
| 18 | global $jetpack_libraries; |
|
| 19 | if ( ! isset( $jetpack_libraries[ $class_name ] ) |
|
| 20 | || version_compare( $jetpack_libraries[ $class_name ] ['version'], $version, '>' ) |
|
| 21 | ) { |
|
| 22 | $jetpack_libraries[ $class_name ] = array( 'version' => $version, 'path' => $path ); |
|
| 23 | } |
|
| 24 | } |
|
| 25 | ||
| 26 | // add the autoloader |
|
| 27 | spl_autoload_register( function ( $class_name ) { |
|
| 28 | global $jetpack_libraries; |
|
| 29 | if ( isset( $jetpack_libraries[ $class_name ] ) ) { |
|
| 30 | if ( ! did_action( 'plugins_loaded' ) ) { |
|
| 31 | _doing_it_wrong( $class_name, 'Not all plugins have loaded yet!', '1' ); |
|
| 32 | } |
|
| 33 | require_once $jetpack_libraries[ $class_name ]['path']; |
|
| 34 | } |
|
| 35 | } ); |
|
| 36 | } |
|
| 37 | /** |
|
| 38 | * END OF DUPLICATE CODE |
|
| 39 | */ |
|
| @@ 62-86 (lines=25) @@ | ||
| 59 | /** |
|
| 60 | * THIS CODE WOULD NEED TO BE DUPLICATED IN EACH PLUGIN... |
|
| 61 | */ |
|
| 62 | if ( ! function_exists( 'jetpack_enqueue_library' ) ) { |
|
| 63 | global $jetpack_libraries; |
|
| 64 | if ( ! is_array( $jetpack_libraries ) ) { |
|
| 65 | $jetpack_libraries = array(); |
|
| 66 | } |
|
| 67 | function jetpack_enqueue_library( $class_name, $version, $path ) { |
|
| 68 | global $jetpack_libraries; |
|
| 69 | if ( ! isset( $jetpack_libraries[ $class_name ] ) |
|
| 70 | || version_compare( $jetpack_libraries[ $class_name ] ['version'], $version, '>' ) |
|
| 71 | ) { |
|
| 72 | $jetpack_libraries[ $class_name ] = array( 'version' => $version, 'path' => $path ); |
|
| 73 | } |
|
| 74 | } |
|
| 75 | ||
| 76 | // add the autoloader |
|
| 77 | spl_autoload_register( function ( $class_name ) { |
|
| 78 | global $jetpack_libraries; |
|
| 79 | if ( isset( $jetpack_libraries[ $class_name ] ) ) { |
|
| 80 | if ( ! did_action( 'plugins_loaded' ) ) { |
|
| 81 | _doing_it_wrong( $class_name, 'Jetpack Class Autoloader, not all plugins have loaded yet!', JETPACK__VERSION ); |
|
| 82 | } |
|
| 83 | require_once $jetpack_libraries[ $class_name ]['path']; |
|
| 84 | } |
|
| 85 | } ); |
|
| 86 | } |
|
| 87 | /** |
|
| 88 | * END OF DUPLICATE CODE |
|
| 89 | */ |
|