PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.4.1
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.4.1
4.3.3 4.3.2 4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 All 166 releases
← All changes | Inc/Classes/AdminFooterText.php +190 -269 4.1.17 → 3.2.4.1 View file →
@@ -8,9 +8,9 @@
8 8 use WPAdminify\Inc\Admin\AdminSettingsModel;
9 9
10 10
11 11 // no direct access allowed.
12 -if (!defined('ABSPATH')) {
12 +if ( ! defined( 'ABSPATH' ) ) {
13 13 exit;
14 14 }
15 15
16 16 /**
@@ -18,10 +18,10 @@
18 18 *
19 19 * @package WP Adminify
20 20 * @author: Jewel Theme<[email protected]>
21 21 */
22 -class AdminFooterText extends AdminSettingsModel
23 -{
22 +class AdminFooterText extends AdminSettingsModel {
23 +
24 24 /**
25 25 * Server Info
26 26 *
27 27 * @var $server_info
@@ -28,178 +28,92 @@
28 28 */
29 29 public $server_info;
30 30
31 31 /**
32 - * Default admin_footer_text value supplied by WordPress core.
33 - *
34 - * Captured via the admin_footer_text filter at an early priority before
35 - * the plugin overrides it, so the standard "Thank you for creating with
36 - * WordPress." string can be rendered when the credit option is disabled
37 - * without hardcoding a copy of that string in the plugin.
38 - *
39 - * @var string
40 - */
41 - protected static $wp_default_footer_text = '';
42 -
43 - /**
44 32 * Constructor
45 33 */
46 - public function __construct()
47 - {
34 + public function __construct() {
35 + $this->options = (array) AdminSettings::get_instance()->get();
48 36
49 - $this->options = (array) AdminSettings::get_instance()->get();
50 - $this->options = !empty($this->options['white_label']['wordpress']['admin_footer']) ? $this->options['white_label']['wordpress']['admin_footer'] : '';
51 -
52 - // Remove Admin Footer Version Number
53 - if (!empty($this->options) && in_array('wp_version', $this->options)) {
54 - add_action('admin_menu', [$this, 'remove_admin_footer_version']);
37 + $restrict_for = ! empty( $this->options['admin_footer_user_roles'] ) ? $this->options['admin_footer_user_roles'] : '';
38 + if ( $restrict_for ) {
39 + add_filter( 'admin_footer_text', [ $this, 'jltwp_adminify_change_admin_footer_text' ] );
40 + return;
55 41 }
56 42
57 - add_action('admin_menu', [$this, 'jltwp_adminify_footer_version_remove']);
58 - add_action('network_admin_menu', [$this, 'jltwp_adminify_footer_version_remove']);
59 - /** Admin Footer */
60 - add_filter('update_footer', [$this, 'jltwp_adminify_change_admin_footer'], 10, 3);
43 + add_action( 'admin_menu', [ $this, 'jltwp_adminify_footer_version_remove' ] );
44 + add_action( 'network_admin_menu', [ $this, 'jltwp_adminify_footer_version_remove' ] );
61 45
62 - // Capture WordPress core's default admin_footer_text before
63 - // suppressing it, so we can re-render it when the plugin's
64 - // "Show Footer Credit" option is disabled.
65 - add_filter('admin_footer_text', [$this, 'capture_wp_default_footer_text'], 1);
46 + $this->adminify_footer_text_init();
66 47
67 - add_filter( 'admin_footer_text', '__return_false', 999 );
68 - add_filter( 'update_footer', '__return_false', 999 );
69 -
70 48 $this->server_info = new ServerInfo();
71 49 }
72 50
73 - /**
74 - * Capture the default admin footer text WordPress passes into the
75 - * admin_footer_text filter, then return it unchanged.
76 - *
77 - * @param string $text
78 - * @return string
79 - */
80 - public function capture_wp_default_footer_text($text)
81 - {
82 - if (is_string($text) && $text !== '') {
83 - self::$wp_default_footer_text = $text;
84 - }
85 - return $text;
51 + public function jltwp_adminify_footer_version_remove() {
52 + remove_filter( 'update_footer', 'core_update_footer' );
86 53 }
87 54
55 + public function adminify_footer_text_init() {
56 + /** Admin Footer Credits Text */
57 + add_filter( 'update_footer', [ $this, 'jltwp_adminify_change_admin_footer' ], 10, 3 );
88 58
89 -
90 - /**
91 - * Remove WordPress version
92 - *
93 - * @return void
94 - */
95 - public function remove_admin_footer_version()
96 - {
97 - // Remove WordPress Version except Admin
98 - if (!current_user_can('manage_options')) {
99 - remove_filter('update_footer', 'core_update_footer');
100 - }
59 + // Footer Right Info
60 + add_filter( 'admin_footer_text', [ $this, 'jltwp_adminify_change_admin_footer_text' ] );
101 61 }
102 62
103 -
104 - // function jltwp_adminify_footer_get_options()
105 - // {
106 - // $objects = isset($this->options) && is_array($this->options) ? $this->options : [];
107 - // return $objects;
108 - // }
109 -
110 - public function jltwp_adminify_footer_version_remove()
111 - {
112 - remove_filter('update_footer', 'core_update_footer');
113 - }
114 -
115 - /**
116 - * Default footer credit markup.
117 - *
118 - * Single source of truth for the "Developed by / Powered by" string,
119 - * used both as the default value of the white-label footer text option
120 - * and as the rendered fallback when the option is empty.
121 - *
122 - * @return string
123 - */
124 - public static function get_default_footer_credit()
125 - {
126 - return sprintf(
127 - /* translators: 1: WP Adminify website URL, 2: Plugin label, 3: WordPress.org URL */
128 - __('<p>Developed by <a href="%1$s" target="_blank" title="Adminify by Jewel Theme">%2$s</a></p> <p>Powered by <a target="_blank" href="%3$s">WordPress</a></p>', 'adminify'),
129 - esc_url('https://wpadminify.com/'),
130 - AdminSettings::get_pro_label(),
131 - esc_url('https://wordpress.org/')
132 - );
133 - }
134 -
135 63 /** Footer Credits */
136 - public function jltwp_adminify_footer_credits()
137 - { ?>
138 - <div class="adminify-copyright">
139 - <?php echo wp_kses_post(self::get_default_footer_credit()); ?>
64 + public function jltwp_adminify_footer_credits() { ?>
65 + <div class="wp-adminify adminify-first-child">
66 + <div class="wp-adminify--copyright">
67 + <?php
68 + echo sprintf( __('Developed by <a href="%1$s" target="_blank" title="WP Adminify by Jewel Theme" target="_blank">WP Adminify</a> <br>
69 + Powered by <a target="_blank" href="%2$s">WordPress</a>', 'adminify'),
70 + esc_url( 'https:// wpadminify.com/' ),
71 + esc_url( 'https://wordpress.org/' )
72 + );
73 + ?>
74 + </div>
140 75 </div>
141 76 <?php
142 77 }
143 78
144 79
145 - public function change_admin_footer_text()
146 - {
147 - $footer_text = (array) AdminSettings::get_instance()->get();
148 -
149 - // Attribution is opt-in only. When the site admin has not enabled
150 - // the "Show Footer Credit" option, fall back to the standard
151 - // WordPress admin footer text instead of plugin credits.
152 - $show_credit = !empty($footer_text['white_label']['wordpress']['show_footer_credit']);
153 - if (!$show_credit) {
154 - $wp_default = self::$wp_default_footer_text;
155 - if ($wp_default === '') {
156 - return;
157 - }
158 - ?>
159 - <div class="adminify-footer-left">
160 - <?php echo wp_kses_post($wp_default); ?>
161 - </div>
162 - <?php
80 + public function jltwp_adminify_change_admin_footer_text() {
81 + $this->options = (array) AdminSettings::get_instance()->get();
82 + if ( ! empty( $this->options['footer_text'] ) ) {
83 + echo wp_kses_post( $this->options['footer_text'] );
163 84 return;
164 85 }
165 -
166 - if (!empty($footer_text['white_label']['wordpress']['footer_text'])) { ?>
167 - <div class="adminify-footer-left">
168 - <?php echo wp_kses_post($footer_text['white_label']['wordpress']['footer_text']); ?>
169 - </div>
170 - <?php
171 - return;
172 - }
173 -
174 86 // Change the content of the left admin footer text.
175 - apply_filters('jltwp_adminify_footer_credits', $this->jltwp_adminify_footer_credits());
87 + apply_filters( 'jltwp_adminify_footer_credits', $this->jltwp_adminify_footer_credits() );
176 88 }
177 89
178 90
179 -
180 91 /**
181 92 * IP Address
182 93 */
183 - public function adminify_ip_address() { ?>
184 - <div class="adminify-system-info">
185 - <?php
186 - if (is_rtl()) {
94 + public function adminify_ip_address() {
95 + if ( ! empty( $this->options['admin_footer_ip_address'] ) ) {
96 + ?>
97 + <div class="column has-text-right">
98 + <?php
99 + if ( is_rtl() ) {
187 100 echo sprintf(
188 - wp_kses_post('<span>%2$s</span><span>%1$s</span>'),
189 - esc_html__('IP: ', 'adminify'),
190 - esc_html($this->server_info->get_ip_address())
101 + wp_kses_post( '<span class="info-details">%2$s</span><span class="info-id is-uppercase">%1$s</span>' ),
102 + esc_html__( 'IP: ', 'adminify' ),
103 + esc_html( $this->server_info->get_ip_address() )
191 104 );
192 105 } else {
193 106 echo sprintf(
194 - wp_kses_post('<span>%1$s</span><span>%2$s</span>'),
195 - esc_html__('IP: ', 'adminify'),
196 - esc_html($this->server_info->get_ip_address())
107 + wp_kses_post( '<span class="info-id is-uppercase">%1$s</span><span class="info-details">%2$s</span>' ),
108 + esc_html__( 'IP: ', 'adminify' ),
109 + esc_html( $this->server_info->get_ip_address() )
197 110 );
198 111 }
199 - ?>
200 - </div>
201 - <?php
112 + ?>
113 + </div>
114 + <?php
115 + }
202 116 }
203 117
204 118
205 119 /**
@@ -204,51 +118,57 @@
204 118
205 119 /**
206 120 * PHP Version
207 121 */
208 - public function adminify_php_version() { ?>
209 - <div class="adminify-system-info">
210 - <?php
211 - if (is_rtl()) {
122 + public function adminify_php_version() {
123 + if ( ! empty( $this->options['admin_footer_php_version'] ) ) {
124 + ?>
125 + <div class="column has-text-right">
126 + <?php
127 + if ( is_rtl() ) {
212 128 echo sprintf(
213 - '<span>%2$s</span><span>%1$s</span>',
214 - esc_html__('PHP: ', 'adminify'),
215 - esc_html($this->server_info->get_php_version_lite())
129 + '<span class="info-details">%2$s</span><span class="info-id">%1$s</span>',
130 + esc_html__( 'PHP: ', 'adminify' ),
131 + esc_html( $this->server_info->get_php_version_lite() )
216 132 );
217 133 } else {
218 134 echo sprintf(
219 - '<span>%1$s</span><span>%2$s</span>',
220 - esc_html__('PHP: ', 'adminify'),
221 - esc_html($this->server_info->get_php_version_lite())
135 + '<span class="info-id">%1$s</span><span class="info-details">%2$s</span>',
136 + esc_html__( 'PHP: ', 'adminify' ),
137 + esc_html( $this->server_info->get_php_version_lite() )
222 138 );
223 139 }
224 - ?>
225 - </div>
226 - <?php
140 + ?>
141 + </div>
142 + <?php
143 + }
227 144 }
228 145
229 146 /**
230 147 * WordPress Version
231 148 */
232 - public function adminify_wp_version() { ?>
233 - <div class="adminify-system-info">
234 - <?php
235 - if (is_rtl()) {
149 + public function adminify_wp_version() {
150 + if ( ! empty( $this->options['admin_footer_wp_version'] ) ) {
151 + ?>
152 + <div class="column has-text-right">
153 + <?php
154 + if ( is_rtl() ) {
236 155 echo sprintf(
237 - '<span>%2$s</span><span>%1$s</span>',
238 - esc_html__('WordPress: v', 'adminify'),
239 - esc_html($this->server_info->get_wp_version())
156 + '<span class="info-details">%2$s</span><span class="info-id">%1$s</span>',
157 + esc_html__( 'WordPress: v', 'adminify' ),
158 + esc_html( $this->server_info->get_wp_version() )
240 159 );
241 160 } else {
242 161 echo sprintf(
243 - '<span>%1$s</span><span>%2$s</span>',
244 - esc_html__('WordPress: v', 'adminify'),
245 - esc_html($this->server_info->get_wp_version())
162 + '<span class="info-id">%1$s</span><span class="info-details">%2$s</span>',
163 + esc_html__( 'WordPress: v', 'adminify' ),
164 + esc_html( $this->server_info->get_wp_version() )
246 165 );
247 166 }
248 - ?>
249 - </div>
250 - <?php
167 + ?>
168 + </div>
169 + <?php
170 + }
251 171 }
252 172
253 173 /**
254 174 * Memory Usage
@@ -253,46 +173,50 @@
253 173 /**
254 174 * Memory Usage
255 175 */
256 176 public function adminify_memory_usage() {
257 - $memory_usage = $this->server_info->get_wp_memory_usage();
258 - $memory_limit = $memory_usage['MemLimitFormat'];
259 - $memory_usage_format = $memory_usage['MemUsageFormat'];
260 - // $memory_usage_percentage = $memory_usage['MemUsageCalc'];
261 - $memory_usage_percentage = ServerInfo::wp_memory_usage_percentage();
177 + if ( ! empty( $this->options['admin_footer_memory_usage'] ) ) {
178 + $memory_usage = $this->server_info->get_wp_memory_usage();
179 + $memory_limit = $memory_usage['MemLimitFormat'];
180 + $memory_usage_format = $memory_usage['MemUsageFormat'];
181 + // $memory_usage_percentage = $memory_usage['MemUsageCalc'];
182 + $memory_usage_percentage = ServerInfo::wp_memory_usage_percentage();
262 183
263 - if ($memory_usage_percentage <= 65) {
264 - $memory_status = '#00BA88';
265 - } elseif ($memory_usage_percentage > 65 && $memory_usage_percentage < 85) {
266 - $memory_status = '#ffe08a';
267 - } elseif ($memory_usage_percentage > 85) {
268 - $memory_status = '#f14668';
269 - } ?>
270 - <div class="adminify-system-info">
271 - <?php
272 - if (is_rtl()) {
184 + if ( $memory_usage_percentage <= 65 ) {
185 + $memory_status = '#00BA88';
186 + } elseif ( $memory_usage_percentage > 65 && $memory_usage_percentage < 85 ) {
187 + $memory_status = '#ffe08a';
188 + } elseif ( $memory_usage_percentage > 85 ) {
189 + $memory_status = '#f14668';
190 + }
191 + ?>
192 + <div class="column has-text-right">
193 +
194 + <?php
195 + if ( is_rtl() ) {
273 196 echo sprintf(
274 - wp_kses_post('<span>%2$s of %3$s <span class="adminify-info-status" style="background:%4$s">%5$s</span></span><span>%1$s</span>'),
275 - esc_html__('WP Memory Usage: ', 'adminify'),
276 - esc_html($memory_usage_format),
277 - esc_html($memory_limit),
278 - esc_html($memory_status),
279 - esc_html($memory_usage_percentage) . '%'
197 + wp_kses_post( '<span class="info-details">%2$s of %3$s <span class="percentage tag has-text-white is-rounded" style="background:%4$s">%5$s</span></span><span class="info-id">%1$s</span>' ),
198 + esc_html__( 'WP Memory Usage: ', 'adminify' ),
199 + esc_html( $memory_usage_format ),
200 + esc_html( $memory_limit ),
201 + esc_html( $memory_status ),
202 + esc_html( $memory_usage_percentage ) . '%'
280 203 );
281 204 } else {
282 205 echo sprintf(
283 - wp_kses_post('<span>%1$s</span><span>%2$s of %3$s <span class="adminify-info-status" style="background:%4$s">%5$s</span></span>'),
284 - esc_html__('WP Memory Usage: ', 'adminify'),
285 - esc_html($memory_usage_format),
286 - esc_html($memory_limit),
287 - esc_html($memory_status),
288 - esc_html($memory_usage_percentage) . '%'
206 + wp_kses_post( '<span class="info-id">%1$s</span><span class="info-details">%2$s of %3$s <span class="percentage tag has-text-white is-rounded" style="background:%4$s">%5$s</span></span>' ),
207 + esc_html__( 'WP Memory Usage: ', 'adminify' ),
208 + esc_html( $memory_usage_format ),
209 + esc_html( $memory_limit ),
210 + esc_html( $memory_status ),
211 + esc_html( $memory_usage_percentage ) . '%'
289 212 );
290 213 }
291 - ?>
292 - </span>
293 - </div>
294 - <?php
214 + ?>
215 + </span>
216 + </div>
217 + <?php
218 + }
295 219 }
296 220
297 221 /**
298 222 * Memory Limit
@@ -297,30 +221,31 @@
297 221 /**
298 222 * Memory Limit
299 223 */
300 224 public function adminify_memory_limit() {
301 - $memory_limit = $this->server_info->get_wp_memory_usage();
302 -
303 - $memory_limit = $memory_limit['MemLimitFormat']; ?>
304 -
305 - <div class="adminify-system-info">
225 + if ( ! empty( $this->options['admin_footer_memory_limit'] ) ) {
226 + $memory_limit = $this->server_info->get_wp_memory_usage();
227 + $memory_limit = $memory_limit['MemLimitFormat'];
228 + ?>
229 + <div class="column has-text-right">
230 + <?php
231 + if ( is_rtl() ) {
232 + echo sprintf(
233 + '<span class="info-details">%2$s</span><span class="info-id">%1$s</span>',
234 + esc_html__( 'WP Memory Limit: ', 'adminify' ),
235 + esc_html( $memory_limit )
236 + );
237 + } else {
238 + echo sprintf(
239 + '<span class="info-id">%1$s</span><span class="info-details">%2$s</span>',
240 + esc_html__( 'WP Memory Limit: ', 'adminify' ),
241 + esc_html( $memory_limit )
242 + );
243 + }
244 + ?>
245 + </div>
306 246 <?php
307 - if (is_rtl()) {
308 - echo sprintf(
309 - '<span>%2$s</span><span>%1$s</span>',
310 - esc_html__('WP Memory Limit: ', 'adminify'),
311 - esc_html($memory_limit)
312 - );
313 - } else {
314 - echo sprintf(
315 - '<span>%1$s</span><span>%2$s</span>',
316 - esc_html__('WP Memory Limit: ', 'adminify'),
317 - esc_html($memory_limit)
318 - );
319 - }
320 - ?>
321 - </div>
322 - <?php
247 + }
323 248 }
324 249
325 250
326 251 /**
@@ -326,75 +251,71 @@
326 251 /**
327 252 * Memory Limit
328 253 */
329 254 public function adminify_memory_available() {
330 - $memory_available = $this->server_info->get_wp_memory_usage();
331 - $memory_available = rtrim($memory_available['MemLimitGet'], 'MB') - rtrim($memory_available['MemUsageFormat'], 'MB'); ?>
332 -
333 - <div class="adminify-system-info">
255 + if ( ! empty( $this->options['admin_footer_memory_available'] ) ) {
256 + $memory_available = $this->server_info->get_wp_memory_usage();
257 + $memory_available = $memory_available['MemLimitGet'];
258 + ?>
259 + <div class="column has-text-right">
260 + <?php
261 + if ( is_rtl() ) {
262 + echo sprintf(
263 + '<span class="info-details is-uppercase">%2$s</span><span class="info-id">%1$s</span>',
264 + esc_html__( 'WP Memory Available: ', 'adminify' ),
265 + esc_html( $memory_available )
266 + );
267 + } else {
268 + echo sprintf(
269 + '<span class="info-id">%1$s</span><span class="info-details is-uppercase">%2$s</span>',
270 + esc_html__( 'WP Memory Available: ', 'adminify' ),
271 + esc_html( $memory_available )
272 + );
273 + }
274 + ?>
275 + </div>
334 276 <?php
335 - if (is_rtl()) {
336 - echo sprintf(
337 - '<span>%2$s</span><span>%1$s</span>',
338 - esc_html__('WP Memory Available: ', 'adminify'),
339 - esc_html($memory_available)
340 - );
341 - } else {
342 - echo sprintf(
343 - '<span>%1$s</span><span>%2$s</span>',
344 - esc_html__('WP Memory Available: ', 'adminify'),
345 - esc_html($memory_available)
346 - );
347 - }
348 - ?>MB
349 - </div>
350 - <?php
277 + }
351 278 }
352 279
353 -
354 280 /** Admin Footer Text **/
355 - public function jltwp_adminify_change_admin_footer($footer_text) { ?>
281 + public function jltwp_adminify_change_admin_footer( $footer_text ) {
282 + if (
283 + ! empty( $this->options['admin_footer_memory_usage'] ) ||
284 + ! empty( $this->options['admin_footer_memory_limit'] ) ||
285 + ! empty( $this->options['admin_footer_memory_available'] ) ||
286 + ! empty( $this->options['admin_footer_ip_address'] ) ||
287 + ! empty( $this->options['admin_footer_php_version'] ) ||
288 + ! empty( $this->options['admin_footer_wp_version'] )
289 + ) {
290 + ?>
291 + <div class="wp-adminify adminify-last-child">
356 292
357 - <div class="adminify--footer">
358 - <?php $this->change_admin_footer_text();
359 - if ( !empty($this->options) ) { ?>
293 + <div class="system-info has-text-right">
294 + <div class="info-line-1">
360 295
361 - <div class="adminify-footer-right">
362 - <div class="adminify-system-info-col">
363 296 <?php
364 - if ( in_array('ip_address', $this->options ) ) {
365 - $this->adminify_ip_address();
366 - }
367 -
368 - if ( in_array('php_version', $this->options ) ) {
369 - $this->adminify_php_version();
370 - }
371 -
372 - if ( in_array('wp_version', $this->options ) ) {
373 - $this->adminify_wp_version();
374 - }
297 + $this->adminify_ip_address();
298 + $this->adminify_php_version();
299 + $this->adminify_wp_version();
375 300 ?>
376 301 </div>
377 - <div class="adminify-system-info-col">
302 +
303 + <div class="info-line-2">
378 304 <?php
379 - if ( in_array('memory_usage', $this->options ) ) {
380 - $this->adminify_memory_usage();
381 - }
305 + $this->adminify_memory_usage();
306 + $this->adminify_memory_limit();
307 + $this->adminify_memory_available();
308 + ?>
382 309
383 - if ( in_array('memory_limit', $this->options ) ) {
384 - $this->adminify_memory_limit();
385 - }
386 -
387 - if ( in_array('memory_available', $this->options ) ) {
388 - $this->adminify_memory_available();
389 - }
390 - ?>
391 310 </div>
392 311 </div>
393 - <?php return $footer_text;
394 - } ?>
395 - </div>
396 - <?php
312 +
313 + </div>
314 + <?php
315 + return $footer_text;
316 + }
317 +
397 318 // Nothing, return blank
398 319 return '';
399 320 }
400 321 }