PluginProbe ʕ •ᴥ•ʔ
Code Snippets / 3.9.2
Code Snippets v3.9.2
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 3.0.1 3.1.0 3.1.1 3.2.1 3.2.2 3.3.0 3.4.0 3.4.1 3.4.2 3.5.0 3.5.0-beta.1 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.5.1 3.6.6 3.6.6.1 3.6.7 3.6.8 3.7.0 3.7.0-beta 3.7.0-beta.5 3.7.0-beta.7 3.7.1-beta.1 3.7.1-beta.2 3.7.1-beta.3 3.8.0 3.8.1 3.8.2 3.9.0 3.9.0-beta.1 3.9.0-beta.2 3.9.1 3.9.2 3.9.3 3.9.4 3.9.5
code-snippets / php / load.php
code-snippets / php Last commit date
admin-menus 6 months ago cloud 6 months ago evaluation 7 months ago export 9 months ago flat-files 7 months ago front-end 6 months ago rest-api 6 months ago settings 6 months ago views 7 months ago class-admin.php 6 months ago class-contextual-help.php 9 months ago class-data-item.php 9 months ago class-db.php 9 months ago class-licensing.php 1 year ago class-list-table.php 6 months ago class-plugin.php 6 months ago class-snippet.php 7 months ago class-upgrade.php 1 year ago class-validator.php 9 months ago class-welcome-api.php 1 year ago deactivation-notice.php 1 year ago editor.php 7 months ago load.php 6 months ago snippet-ops.php 6 months ago strings.php 9 months ago uninstall.php 7 months ago
load.php
84 lines
1 <?php
2 /**
3 * Initialise and load the plugin under the proper namespace.
4 *
5 * @package Code_Snippets
6 */
7
8 namespace Code_Snippets;
9
10 /**
11 * The version number for this release of the plugin.
12 * This will later be used for upgrades and enqueuing files.
13 *
14 * This should be set to the 'Plugin Version' value defined
15 * in the plugin header.
16 *
17 * @var string A PHP-standardized version number string.
18 */
19 const PLUGIN_VERSION = CODE_SNIPPETS_VERSION;
20
21 /**
22 * The full path to the main file of this plugin.
23 *
24 * This can later be used with functions such as
25 * plugin_dir_path(), plugins_url() and plugin_basename()
26 * to retrieve information about plugin paths.
27 *
28 * @var string
29 */
30 const PLUGIN_FILE = CODE_SNIPPETS_FILE;
31
32 /**
33 * Name of the group used for caching data.
34 *
35 * @var string
36 */
37 const CACHE_GROUP = 'code_snippets';
38
39 /**
40 * Namespace used for REST API endpoints.
41 *
42 * @var string
43 */
44 const REST_API_NAMESPACE = 'code-snippets/v';
45
46 // Load dependencies with Composer.
47 $code_snippets_autoloader = require dirname( __DIR__ ) . '/vendor/autoload.php';
48
49 // Remove all original (non-prefixed) vendor namespace mappings to prevent collisions with other plugins.
50 // Since Imposter rewrites namespaces to Code_Snippets\Vendor\*, we need to remove the original PSR-4
51 // mappings that Composer generates so other plugins can load their own copies of these libraries.
52 if ( $code_snippets_autoloader instanceof \Composer\Autoload\ClassLoader ) {
53 $prefixes = $code_snippets_autoloader->getPrefixesPsr4();
54 $our_prefix = 'Code_Snippets\\Vendor\\';
55
56 foreach ( $prefixes as $namespace => $paths ) {
57 // Remove any non-Code_Snippets namespace that has a corresponding prefixed version
58 if ( strpos( $namespace, $our_prefix ) === false ) {
59 $prefixed_namespace = $our_prefix . $namespace;
60 if ( isset( $prefixes[ $prefixed_namespace ] ) ) {
61 $code_snippets_autoloader->setPsr4( $namespace, [] );
62 }
63 }
64 }
65 }
66
67 /**
68 * Retrieve the instance of the main plugin class.
69 *
70 * @return Plugin
71 * @since 2.6.0
72 */
73 function code_snippets(): Plugin {
74 static $plugin;
75
76 if ( is_null( $plugin ) ) {
77 $plugin = new Plugin( PLUGIN_VERSION, PLUGIN_FILE );
78 }
79
80 return $plugin;
81 }
82
83 code_snippets()->load_plugin();
84