-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwordpress-plugin-starter.php
87 lines (80 loc) · 2.47 KB
/
wordpress-plugin-starter.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
<?php
/**
* PLUGIN_NAME
*
* @package PLUGIN_PACKAGE
* @subpackage WordPress
* @since 1.0.0
* @author PLUGIN_AUTHOR
* @copyright 2022 PLUGIN_AUTHOR
* @license PLUGIN_LICENSE
*
* @wordpress-plugin
* Plugin Name: PLUGIN_NAME
* Plugin URI: PLUGIN_URI
* Description: PLUGIN_DESCRIPTION
* Version: 1.0.0
* Requires at least: 5.2
* Requires PHP: 7.3
* Author: PLUGIN_AUTHOR
* Author URI: PLUGIN_AUTHOR_URI
* Text Domain: PLUGIN_TEXT_DOMAIN
* Domain Path: /languages
* License: PLUGIN_LICENSE
* License URI: PLUGIN_LICENSE_URL
*/
// Security Note: Blocks direct access to the plugin PHP files.
defined( 'ABSPATH' ) || die();
// Define plugin constants.
define( 'PLUGIN_CONSTANT', __FILE__ );
define( 'PLUGIN_CONSTANT_PATH', plugin_dir_path( PLUGIN_CONSTANT ) );
define( 'PLUGIN_CONSTANT_PLUGIN_BASE', plugin_basename( PLUGIN_CONSTANT ) );
define( 'PLUGIN_CONSTANT_VERSION', '1.0.0' );
add_action( 'plugins_loaded', 'FUNCTION_PREFIX_load_plugin_textdomain' );
if ( ! version_compare( PHP_VERSION, '7.3', '>=' ) ) {
add_action( 'admin_notices', 'FUNCTION_PREFIX_fail_php_version' );
} elseif ( ! version_compare( get_bloginfo( 'version' ), '5', '>=' ) ) {
add_action( 'admin_notices', 'FUNCTION_PREFIX_fail_wp_version' );
} else {
require_once PLUGIN_CONSTANT_PATH . 'includes/class-plugin.php';
}
/**
* Load plugin textdomain
*/
function FUNCTION_PREFIX_load_plugin_textdomain() {
load_plugin_textdomain( 'PLUGIN_TEXT_DOMAIN' );
}
/**
* Admin notice for minimum PHP version
*/
function FUNCTION_PREFIX_fail_php_version() {
$message = sprintf(
/* translators: %s: replaced with the PHP version number */
esc_html__(
'PLUGIN_NAME requires PHP version %s+, plugin is currently NOT RUNNING.',
'PLUGIN_TEXT_DOMAIN'
),
'7.3'
);
$html_message = sprintf(
/* translators: %s: replaced with the error message */
'<div class="error">%s</div>',
wpautop( $message )
);
echo wp_kses_post( $html_message );
}
/**
* Admin notice for minimum WordPress version
*/
function FUNCTION_PREFIX_fail_wp_version() {
$message = sprintf(
/* translators: %s: replaced with the WordPress version number */
esc_html__(
'PLUGIN_NAME requires WordPress version %s+. Because you are using an earlier version, the plugin is currently NOT RUNNING.',
'PLUGIN_TEXT_DOMAIN'
),
'5'
);
$html_message = sprintf( '<div class="error">%s</div>', wpautop( $message ) );
echo wp_kses_post( $html_message );
}