| 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 |
require_once dirname( __DIR__ ) . '/vendor/autoload.php'; |
| 48 |
|
| 49 |
/** |
| 50 |
* Retrieve the instance of the main plugin class. |
| 51 |
* |
| 52 |
* @return Plugin |
| 53 |
* @since 2.6.0 |
| 54 |
*/ |
| 55 |
function code_snippets(): Plugin { |
| 56 |
static $plugin; |
| 57 |
|
| 58 |
if ( is_null( $plugin ) ) { |
| 59 |
$plugin = new Plugin( PLUGIN_VERSION, PLUGIN_FILE ); |
| 60 |
} |
| 61 |
|
| 62 |
return $plugin; |
| 63 |
} |
| 64 |
|
| 65 |
code_snippets()->load_plugin(); |
| 66 |
|