-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-plugin-template.php
54 lines (45 loc) · 1.57 KB
/
wp-plugin-template.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
<?php
/**
* @package WP_Plugin_Template
* @author {{AUTHOR}}
* @copyright 2021 {{AUTHOR}}
* @license GPLv3-or-later
* @link {{URI}}
*
* @wordpress-plugin
* Plugin Name: {{NAME}}
* Plugin URI: {{URI}}
* Description: {{SHORT_DESCRIPTION}}
* Version: {{VERSION}}
* Author: {{AUTHOR}}
* Author URI: {{AUTHOR_URI}}
* License: GPLv3 or later
* License URI: https://www.gnu.org/licenses/gpl-3.0.txt
* Text Domain: {{TEXT_DOMAIN}}
*/
// Cannot `declare( strict_types=1 );` to avoid fatal if prior to PHP 7.0.0, since we did not yet verify the PHP version.
namespace WP_Plugin_Template;
// Abort if this file is called directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
const VERSION = '{{VERSION}}';
// Composer autoloader.
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require_once( __DIR__ . '/vendor/autoload.php' );
}
// Display a notice and bail if dependencies are missing.
if ( ! class_exists( __NAMESPACE__ . '\Bootstrap' ) ) {
require_once(__DIR__ . '/includes/functions.php');
add_action( 'admin_notices', __NAMESPACE__ . '\display_missing_dependencies_notice' );
return;
}
// Register activation hook.
register_activation_hook( __FILE__, [ __NAMESPACE__ . '\Activator', 'activate' ] );
// Register deactivation hook.
register_deactivation_hook( __FILE__, [ __NAMESPACE__ . '\Deactivator', 'deactivate' ] );
// Initialize the plugin.
if ( function_exists( 'wp_installing' ) && ! wp_installing() ) {
$plugin = new Bootstrap( __FILE__ );
add_action( 'plugins_loaded', [ $plugin, 'init' ] );
}