-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin_name.php
More file actions
102 lines (74 loc) · 2.69 KB
/
Copy pathplugin_name.php
File metadata and controls
102 lines (74 loc) · 2.69 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
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
97
98
99
100
101
102
<?php
/**
* Plugin Name: Plugin Name
* Description: Elementor sample plugin.
* Plugin URI: https://elementor.com/
* Version: 1.0.0
* Author: Author Name
* Author URI: https://elementor.com/
* Text Domain: text_domain
*/
if ( ! defined( 'ABSPATH' ) ) exit;
final class Plugin_Name {
const VERSION = '1.0.0';
const MINIMUM_ELEMENTOR_VERSION = '2.0.0';
const MINIMUM_PHP_VERSION = '7.0';
public function __construct() {
add_action( 'init', array( $this, 'i18n' ) );
add_action( 'plugins_loaded', array( $this, 'init' ) );
}
public function i18n() {
load_plugin_textdomain( 'text_domain' );
}
public function init() {
if ( ! did_action( 'elementor/loaded' ) ) {
add_action( 'admin_notices', array( $this, 'admin_notice_missing_main_plugin' ) );
return;
}
if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) {
add_action( 'admin_notices', array( $this, 'admin_notice_minimum_elementor_version' ) );
return;
}
if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
add_action( 'admin_notices', array( $this, 'admin_notice_minimum_php_version' ) );
return;
}
require_once( 'plugin.php' );
}
public function admin_notice_missing_main_plugin() {
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
$message = sprintf(
esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'text_domain' ),
'<strong>' . esc_html__( 'Plugin Name', 'text_domain' ) . '</strong>',
'<strong>' . esc_html__( 'Elementor', 'text_domain' ) . '</strong>'
);
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
}
public function admin_notice_minimum_elementor_version() {
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
$message = sprintf(
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'text_domain' ),
'<strong>' . esc_html__( 'Plugin Name', 'text_domain' ) . '</strong>',
'<strong>' . esc_html__( 'Elementor', 'text_domain' ) . '</strong>',
self::MINIMUM_ELEMENTOR_VERSION
);
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
}
public function admin_notice_minimum_php_version() {
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
$message = sprintf(
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'text_domain' ),
'<strong>' . esc_html__( 'Plugin Name', 'text_domain' ) . '</strong>',
'<strong>' . esc_html__( 'PHP', 'text_domain' ) . '</strong>',
self::MINIMUM_PHP_VERSION
);
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
}
}
new Plugin_Name();