PluginProbe
Code Snippets / 4.0.0-beta.2
Code Snippets v4.0.0-beta.2
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
← All changes | php/Core/load.php +15 -5 3.10.14.0.0-beta.2 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 - * Initialise and load the plugin under the proper namespace.
3 + * Initialize and load the plugin under the proper namespace.
4 4 *
5 5 * @package Code_Snippets
6 6 */
7 7
@@ -31,13 +31,22 @@
31 31 */
32 32 const PLUGIN_FILE = CODE_SNIPPETS_FILE;
33 33
34 34 /**
35 + * Base name of the group used for caching data.
36 + *
37 + * @var string
38 + */
39 +const CACHE_GROUP_BASE = 'code_snippets';
40 +
41 +/**
35 42 * Name of the group used for caching data.
36 43 *
44 + * Scoped to the plugin version, so data cached by one version is never read by another.
45 + *
37 46 * @var string
38 47 */
39 -const CACHE_GROUP = 'code_snippets';
48 +const CACHE_GROUP = CACHE_GROUP_BASE . '_' . PLUGIN_VERSION;
40 49
41 50 /**
42 51 * Namespace used for REST API endpoints.
43 52 *
@@ -48,10 +57,9 @@
48 57 /**
49 58 * Load the Composer autoloader.
50 59 *
51 60 * After loading, remove any PSR-4 namespace mappings that do not start with our vendor prefix but have a corresponding
52 - * prefixed version, as these are not removed by Imposter and would cause collisions with other plugins that use the same
53 - * libraries.
61 + * prefixed version. These are not removed by Imposter and would cause collisions with other plugins that use the same libraries.
54 62 *
55 63 * @var ClassLoader $autoloader Composer autoloader instance.
56 64 */
57 65 $autoloader = require dirname( __DIR__, 2 ) . '/vendor/autoload.php';
@@ -58,9 +66,11 @@
58 66
59 67 if ( $autoloader instanceof ClassLoader ) {
60 68 $vendor_prefix = __NAMESPACE__ . '\\Vendor\\';
61 69
62 - foreach ( $autoloader->getPrefixesPsr4() as $namespace => $paths ) {
70 + $prefixes = $autoloader->getPrefixesPsr4();
71 +
72 + foreach ( $prefixes as $namespace => $paths ) {
63 73 // Remove any non-Code_Snippets namespace that has a corresponding prefixed version.
64 74 if ( false === strpos( $namespace, $vendor_prefix ) ) {
65 75 if ( isset( $prefixes[ $vendor_prefix . $namespace ] ) ) {
66 76 $autoloader->setPsr4( $namespace, [] );