-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathplugin-name.php
96 lines (84 loc) · 2.1 KB
/
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* Bootstrap file
*
* Plugin Name: Plugin Name
* Description: The plugin adds information about the games to the site posts.
* Version: {VERSION}
* Requires at least: 4.9
* Requires PHP: 5.5
* Author: {AUTHOR}
* Author URI: {AUTHOR_URL}
* License: MIT
* Text Domain: plugin-name
*
* @package PluginName
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use PluginName\Plugin;
use PluginName\Vendor\Auryn\Injector;
if ( version_compare( phpversion(), '7.2.5', '<' ) ) {
/**
* Display the notice after deactivation.
*
* @since {VERSION}
*/
function plugin_name_php_notice() {
?>
<div class="notice notice-error">
<p>
<?php
echo wp_kses(
__( 'The minimum version of PHP is <strong>7.2.5</strong>. Please update the PHP on your server and try again.', 'plugin_name' ),
[
'strong' => [],
]
);
?>
</p>
</div>
<?php
// In case this is on plugin activation.
if ( isset( $_GET['activate'] ) ) { //phpcs:ignore
unset( $_GET['activate'] ); //phpcs:ignore
}
}
add_action( 'admin_notices', 'plugin_name_php_notice' );
// Don't process the plugin code further.
return;
}
if ( ! defined( 'PLUGIN_NAME_DEBUG' ) ) {
/**
* Enable plugin debug mod.
*/
define( 'PLUGIN_NAME_DEBUG', false );
}
/**
* Path to the plugin root directory.
*/
define( 'PLUGIN_NAME_PATH', plugin_dir_path( __FILE__ ) );
/**
* Url to the plugin root directory.
*/
define( 'PLUGIN_NAME_URL', plugin_dir_url( __FILE__ ) );
/**
* Run plugin function.
*
* @since {VERSION}
*
* @throws Exception If something went wrong.
*/
function run_plugin_name() {
require_once PLUGIN_NAME_PATH . 'vendor/autoload.php';
$injector = new Injector();
( $injector->make( Plugin::class ) )->run();
/**
* You can use the $injector->make( PluginName\Some\Class::class ) for get any plugin class.
* More detail: https://github.com/wppunk/WPPlugin#dependency-injection-container
*/
do_action( 'plugin_name_init', $injector );
}
add_action( 'plugins_loaded', 'run_plugin_name' );