|
@@ 23-56 (lines=34) @@
|
| 20 |
|
* @param string $version Version of the class. |
| 21 |
|
* @param string $path Absolute path to the class so that we can load it. |
| 22 |
|
*/ |
| 23 |
|
function enqueue_package_class( $class_name, $version, $path ) { |
| 24 |
|
global $jetpack_packages_classmap; |
| 25 |
|
|
| 26 |
|
if ( ! isset( $jetpack_packages_classmap[ $class_name ] ) ) { |
| 27 |
|
$jetpack_packages_classmap[ $class_name ] = array( |
| 28 |
|
'version' => $version, |
| 29 |
|
'path' => $path, |
| 30 |
|
); |
| 31 |
|
|
| 32 |
|
return; |
| 33 |
|
} |
| 34 |
|
// If we have a @dev version set always use that one! |
| 35 |
|
if ( 'dev-' === substr( $jetpack_packages_classmap[ $class_name ]['version'], 0, 4 ) ) { |
| 36 |
|
return; |
| 37 |
|
} |
| 38 |
|
|
| 39 |
|
// Always favour the @dev version. Since that version is the same as bleeding edge. |
| 40 |
|
// We need to make sure that we don't do this in production! |
| 41 |
|
if ( 'dev-' === substr( $version, 0, 4 ) ) { |
| 42 |
|
$jetpack_packages_classmap[ $class_name ] = array( |
| 43 |
|
'version' => $version, |
| 44 |
|
'path' => $path, |
| 45 |
|
); |
| 46 |
|
|
| 47 |
|
return; |
| 48 |
|
} |
| 49 |
|
// Set the latest version! |
| 50 |
|
if ( version_compare( $jetpack_packages_classmap[ $class_name ]['version'], $version, '<' ) ) { |
| 51 |
|
$jetpack_packages_classmap[ $class_name ] = array( |
| 52 |
|
'version' => $version, |
| 53 |
|
'path' => $path, |
| 54 |
|
); |
| 55 |
|
} |
| 56 |
|
} |
| 57 |
|
|
| 58 |
|
/** |
| 59 |
|
* Adds the version of a package file to the $jetpack_packages_filemap global array so that |
|
@@ 66-99 (lines=34) @@
|
| 63 |
|
* @param string $version Version of the file. |
| 64 |
|
* @param string $path Absolute path to the file so that we can load it. |
| 65 |
|
*/ |
| 66 |
|
function enqueue_package_file( $file_identifier, $version, $path ) { |
| 67 |
|
global $jetpack_packages_filemap; |
| 68 |
|
|
| 69 |
|
if ( ! isset( $jetpack_packages_filemap[ $file_identifier ] ) ) { |
| 70 |
|
$jetpack_packages_filemap[ $file_identifier ] = array( |
| 71 |
|
'version' => $version, |
| 72 |
|
'path' => $path, |
| 73 |
|
); |
| 74 |
|
|
| 75 |
|
return; |
| 76 |
|
} |
| 77 |
|
// If we have a @dev version set always use that one! |
| 78 |
|
if ( 'dev-' === substr( $jetpack_packages_filemap[ $file_identifier ]['version'], 0, 4 ) ) { |
| 79 |
|
return; |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
// Always favour the @dev version. Since that version is the same as bleeding edge. |
| 83 |
|
// We need to make sure that we don't do this in production! |
| 84 |
|
if ( 'dev-' === substr( $version, 0, 4 ) ) { |
| 85 |
|
$jetpack_packages_filemap[ $file_identifier ] = array( |
| 86 |
|
'version' => $version, |
| 87 |
|
'path' => $path, |
| 88 |
|
); |
| 89 |
|
|
| 90 |
|
return; |
| 91 |
|
} |
| 92 |
|
// Set the latest version! |
| 93 |
|
if ( version_compare( $jetpack_packages_filemap[ $file_identifier ]['version'], $version, '<' ) ) { |
| 94 |
|
$jetpack_packages_filemap[ $file_identifier ] = array( |
| 95 |
|
'version' => $version, |
| 96 |
|
'path' => $path, |
| 97 |
|
); |
| 98 |
|
} |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
/** |
| 102 |
|
* Include latest version of all enqueued files. Should be called after all plugins are loaded. |