-
Notifications
You must be signed in to change notification settings - Fork 0
/
leighton-quito.php
229 lines (207 loc) · 5.65 KB
/
leighton-quito.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<?php
/**
* Version: 1.0.0
* Requires PHP: 7.2
* Plugin Name: Leighton Quito
* Plugin URI: https://github.com/iamleigh/leighton-quito-amp
* Description: Awesome Motive Developer Applicant Challenge, Part 1.
* Author: Leighton Quito (iamleigh)
* Author URI: https://github.com/iamleigh
* Text Domain: leighton-quito
* Domain Path: /languages/
*
* @package Leighton_Quito
*/
/**
* @author Leighton Quito
* @copyright Leighton Quito (iamleigh.com), 2023. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU license version 3 or later, available here
* https://www.gnu.org/licenses/gpl.txt
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
if ( ! defined('ABSPATH') ) {
die();
}
if ( ! defined( 'LQ_NAME' ) ) {
define( 'LQ_NAME', 'Leighton Quito' );
}
if ( ! defined( 'LQ_VERSION' ) ) {
define( 'LQ_VERSION', '1.0.0' );
}
if ( ! defined( 'LQ_PHP_VERSION' ) ) {
define( 'LQ_PHP_VERSION', '7.2' );
}
if ( ! defined( 'LQ_WP_VERSION' ) ) {
define( 'LQ_WP_VERSION', '5.2' );
}
if ( ! defined( 'LEIGHTON_QUITO_PLUGIN_BASENAME' ) ) {
define( 'LEIGHTON_QUITO_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
}
if ( function_exists( 'leighton_quito' ) ) {
/**
* Deactivates the plugin and stops loading the plugin instance
*
* @since 1.0.0
*/
if ( ! function_exists( 'leighton_quito_deactivate' ) ) {
function leighton_quito_deactivate() {
deactivate_plugins( LEIGHTON_QUITO_PLUGIN_BASENAME );
}
}
add_action( 'admin_init', 'leighton_quito_deactivate' );
// Stop processing the plugin code
return;
}
if ( ! function_exists( 'leighton_quito_notice_php' ) ) {
/**
* PHP Notice
*
* Check if the server is using an old/insecure PHP version
* and display a notification if true.
*
* @since 1.0.0
*/
function leighton_quito_notice_php() {
?>
<div class="notice notice-error">
<p>
<?php
printf(
wp_kses( /* translators: %1$s - Site PHP version.; %2$s - Recommended PHP version.; %3$s WPBeginner URL for recommended WordPress hosting. */
__( 'Your site is running PHP %1$s, an <strong>insecure version</strong> that is no longer supported by this plugin. Please, contact your web hosting provider to update your site to PHP %2$s or later version, or switch to a <a href="%3$s" target="_blank" rel="noopener noreferrer">recommended WordPress hosting company</a>.', 'leighton-quito' ),
array(
'a' => array(
'href' => array(),
'target' => array(),
'rel' => array(),
),
'strong' => array(),
)
),
phpversion(),
LQ_PHP_VERSION,
esc_url( 'https://www.wpbeginner.com/wordpress-hosting/' )
);
?>
</p>
<p>
<?php
printf(
wp_kses( /* translators: %s - Plugin name. */
__( '<strong>%s plugin is disabled</strong> on your site until you fix the issue.', 'leighton-quito' ),
array(
'strong' => array(),
)
),
LQ_NAME
);
?>
</p>
</div>
<?php
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
}
}
if ( ! function_exists( 'leighton_quito_notice_wp' ) ) {
/**
* WP Notice
*
* Check if the site is using an unsupported WordPress version
* and display a notification if true.
*
* @since 1.0.0
*/
function leighton_quito_notice_wp() {
?>
<div class="notice notice-error">
<p>
<?php
printf(
wp_kses( /* translators: %s - Recommended WordPress version. */
__( 'Your site is running an <strong>old version</strong> of WordPress that is no longer supported by this plugin. Please update your WordPress site to WordPress %s or later version.', 'leighton-quito' ),
array(
'strong' => array(),
)
),
LQ_WP_VERSION
);
?>
</p>
<p>
<?php
printf(
wp_kses( /* translators: %s - Plugin name. */
__( '<strong>%s plugin is disabled</strong> on your site until WordPress is updated to the required version.', 'leighton-quito' ),
array(
'strong' => array(),
)
),
LQ_NAME
);
?>
</p>
</div>
<?php
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
}
}
if ( ! function_exists( 'leighton_quito_plugin_url' ) ) {
/**
* Return plugin URL
*
* @since 1.0.0
* @return string
*/
function leighton_quito_plugin_url() {
return trailingslashit( plugin_dir_url( __FILE__ ) );
}
}
if ( ! function_exists( 'leighton_quito_plugin_dir' ) ) {
/**
* Return plugin path
*
* @since 1.0.0
* @return string
*/
function leighton_quito_plugin_dir() {
return trailingslashit( plugin_dir_path( __FILE__ ) );
}
}
/**
* PHP Notice
*
* Prevent code execution if the server is using an old PHP version and
* display an admin notice to notify user.
*
* @version 1.0.0
*/
if ( version_compare( phpversion(), LQ_PHP_VERSION, '<=' ) ) {
add_action( 'admin_notices', 'leighton_quito_notice_php' );
return;
}
/**
* WordPres Notice
*
* Prevent code execution if the server is using an old WordPress version
* and display an admin notice to notify user.
*
* @version 1.0.0
*/
if ( version_compare( get_bloginfo( 'version' ), LQ_WP_VERSION, '<' ) ) {
add_action( 'admin_notices', 'leighton_quito_notice_wp' );
return;
}
require_once dirname( __FILE__ ) . '/leighton-quito-loader.php';