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