This repository has been archived by the owner on Jun 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
the-plugin-name.php
79 lines (73 loc) · 2.02 KB
/
the-plugin-name.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* {{The Plugin Name}}
*
* @package {{the-plugin-name}}
* @author {{author_name}} <{{author_email}}>
* @copyright {{author_copyright}}
* @license {{author_license}}
* @link {{author_url}}
*
* Plugin Name: {{The Plugin Name}}
* Plugin URI: {{plugin_url}}
* Description: {{plugin_description}}
* Version: {{version}}
* Author: {{author_name}}
* Author URI: {{author_url}}
* Text Domain: the-plugin-name-text-domain
* Domain Path: /languages
* Requires PHP: 7.1
* Requires WP: 5.5.0
* Namespace: ThePluginName
*/
declare( strict_types = 1 );
/**
* Define the default root file of the plugin
*
* @since 1.0.0
*/
const _THE_PLUGIN_NAME_PLUGIN_FILE = __FILE__;
/**
* Load PSR4 autoloader
*
* @since 1.0.0
*/
$the_plugin_name_autoloader = require plugin_dir_path( _THE_PLUGIN_NAME_PLUGIN_FILE ) . 'vendor/autoload.php';
/**
* Setup hooks (activation, deactivation, uninstall)
*
* @since 1.0.0
*/
register_activation_hook( __FILE__, [ 'ThePluginName\Config\Setup', 'activation' ] );
register_deactivation_hook( __FILE__, [ 'ThePluginName\Config\Setup', 'deactivation' ] );
register_uninstall_hook( __FILE__, [ 'ThePluginName\Config\Setup', 'uninstall' ] );
/**
* Bootstrap the plugin
*
* @since 1.0.0
*/
if ( ! class_exists( '\ThePluginName\Bootstrap' ) ) {
wp_die( __( '{{The Plugin Name}} is unable to find the Bootstrap class.', 'the-plugin-name-text-domain' ) );
}
add_action(
'plugins_loaded',
static function () use ( $the_plugin_name_autoloader ) {
/**
* @see \ThePluginName\Bootstrap
*/
try {
new \ThePluginName\Bootstrap( $the_plugin_name_autoloader );
} catch ( Exception $e ) {
wp_die( __( '{{The Plugin Name}} is unable to run the Bootstrap class.', 'the-plugin-name-text-domain' ) );
}
}
);
/**
* Create a main function for external uses
*
* @return \ThePluginName\Common\Functions
* @since 1.0.0
*/
function the_plugin_name(): \ThePluginName\Common\Functions {
return new \ThePluginName\Common\Functions();
}