-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path{{slug}}.php
More file actions
70 lines (64 loc) · 2.03 KB
/
{{slug}}.php
File metadata and controls
70 lines (64 loc) · 2.03 KB
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
<?php
/**
* Plugin Name: {{name}}
* Plugin URI: {{plugin_uri}}
* Description: {{description}}
* Version: {{version}}
* Requires at least: {{requires_wp}}
* Requires PHP: {{requires_php}}
* Requires Plugins: secure-custom-fields
* Author: {{author}}
* Author URI: {{author_uri}}
* License: {{license}}
* License URI: {{license_uri}}
* Text Domain: {{textdomain}}
* Domain Path: /languages
*
* @package {{namespace}}
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Plugin constants.
define( '{{namespace|upper}}_VERSION', '{{version}}' );
define( '{{namespace|upper}}_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( '{{namespace|upper}}_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( '{{namespace|upper}}_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
/**
* Defensive coding: Check for SCF/ACF functions before using them.
*
* While Plugin Dependencies ensures SCF is active, defensive coding is still
* recommended for:
* - Edge cases (FTP deletion, deployment issues)
* - Loading order variations
* - Future compatibility
*
* @see https://make.wordpress.org/core/2024/03/05/introducing-plugin-dependencies-in-wordpress-6-5/
*/
if ( ! function_exists( 'acf_add_local_field_group' ) ) {
add_action(
'admin_notices',
function () {
echo '<div class="error"><p>' .
esc_html__( '{{name}} requires Secure Custom Fields to be active.', '{{textdomain}}' ) .
'</p></div>';
}
);
return;
}
// Include the Core class.
require_once {{namespace|upper}}_PLUGIN_DIR . 'inc/class-core.php';
/**
* Initialise the plugin and return the main instance.
*
* @return \{{namespace|lowerCase}}\classes\Core Main plugin instance.
*/
function {{namespace|lowerCase}}_plugin() {
global ${{namespace|lowerCase}}_plugin;
if ( null === ${{namespace|lowerCase}}_plugin ) {
${{namespace|lowerCase}}_plugin = new \{{namespace|lowerCase}}\classes\Core();
}
return ${{namespace|lowerCase}}_plugin;
}
// Initialize the plugin.
{{namespace|lowerCase}}_plugin();