PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.4.5
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.4.5
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 +199 -276 4.2.25 → 3.2.4.5 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<[email protected]>
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,93 @@
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">%2$s</a> <br>
69 + Powered by <a target="_blank" href="%3$s">WordPress</a>', 'adminify'),
70 + esc_url('https://wpadminify.com/'),
71 + __('WP Adminify', 'adminify'),
72 + esc_url( 'https://wordpress.org/' )
73 + );
74 + ?>
75 + </div>
139 76 </div>
140 77 <?php
141 78 }
142 79
143 80
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
81 + public function jltwp_adminify_change_admin_footer_text() {
82 + $this->options = (array) AdminSettings::get_instance()->get();
83 + if ( ! empty( $this->options['footer_text'] ) ) {
84 + echo wp_kses_post( $this->options['footer_text'] );
162 85 return;
163 86 }
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 87 // Change the content of the left admin footer text.
174 - apply_filters('pxlbsadminify_footer_credits', $this->footer_credits());
88 + apply_filters( 'jltwp_adminify_footer_credits', $this->jltwp_adminify_footer_credits() );
175 89 }
176 90
177 91
178 -
179 92 /**
180 93 * IP Address
181 94 */
182 - public function ip_address() { ?>
183 - <div class="adminify-system-info">
184 - <?php
185 - if (is_rtl()) {
95 + public function adminify_ip_address() {
96 + if ( ! empty( $this->options['admin_footer_ip_address'] ) ) {
97 + ?>
98 + <div class="column has-text-right">
99 + <?php
100 + if ( is_rtl() ) {
186 101 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())
102 + wp_kses_post( '<span class="info-details">%2$s</span><span class="info-id is-uppercase">%1$s</span>' ),
103 + esc_html__( 'IP: ', 'adminify' ),
104 + esc_html( $this->server_info->get_ip_address() )
190 105 );
191 106 } else {
192 107 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())
108 + wp_kses_post( '<span class="info-id is-uppercase">%1$s</span><span class="info-details">%2$s</span>' ),
109 + esc_html__( 'IP: ', 'adminify' ),
110 + esc_html( $this->server_info->get_ip_address() )
196 111 );
197 112 }
198 - ?>
199 - </div>
200 - <?php
113 + ?>
114 + </div>
115 + <?php
116 + }
201 117 }
202 118
203 119
204 120 /**
@@ -203,123 +119,134 @@
203 119
204 120 /**
205 121 * PHP Version
206 122 */
207 - public function php_version() { ?>
208 - <div class="adminify-system-info">
209 - <?php
210 - if (is_rtl()) {
123 + public function adminify_php_version() {
124 + if ( ! empty( $this->options['admin_footer_php_version'] ) ) {
125 + ?>
126 + <div class="column has-text-right">
127 + <?php
128 + if ( is_rtl() ) {
211 129 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())
130 + '<span class="info-details">%2$s</span><span class="info-id">%1$s</span>',
131 + esc_html__( 'PHP: ', 'adminify' ),
132 + esc_html( $this->server_info->get_php_version_lite() )
215 133 );
216 134 } else {
217 135 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())
136 + '<span class="info-id">%1$s</span><span class="info-details">%2$s</span>',
137 + esc_html__( 'PHP: ', 'adminify' ),
138 + esc_html( $this->server_info->get_php_version_lite() )
221 139 );
222 140 }
223 - ?>
224 - </div>
225 - <?php
141 + ?>
142 + </div>
143 + <?php
144 + }
226 145 }
227 146
228 147 /**
229 148 * WordPress Version
230 149 */
231 - public function default_wp_version() { ?>
232 - <div class="adminify-system-info">
233 - <?php
234 - if (is_rtl()) {
150 + public function adminify_wp_version() {
151 + if ( ! empty( $this->options['admin_footer_wp_version'] ) ) {
152 + ?>
153 + <div class="column has-text-right">
154 + <?php
155 + if ( is_rtl() ) {
235 156 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())
157 + '<span class="info-details">%2$s</span><span class="info-id">%1$s</span>',
158 + esc_html__( 'WordPress: v', 'adminify' ),
159 + esc_html( $this->server_info->get_wp_version() )
239 160 );
240 161 } else {
241 162 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())
163 + '<span class="info-id">%1$s</span><span class="info-details">%2$s</span>',
164 + esc_html__( 'WordPress: v', 'adminify' ),
165 + esc_html( $this->server_info->get_wp_version() )
245 166 );
246 167 }
247 - ?>
248 - </div>
249 - <?php
168 + ?>
169 + </div>
170 + <?php
171 + }
250 172 }
251 173
252 174 /**
253 175 * Memory Usage
254 176 */
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();
177 + public function adminify_memory_usage() {
178 + if ( ! empty( $this->options['admin_footer_memory_usage'] ) ) {
179 + $memory_usage = $this->server_info->get_wp_memory_usage();
180 + $memory_limit = $memory_usage['MemLimitFormat'];
181 + $memory_usage_format = $memory_usage['MemUsageFormat'];
182 + // $memory_usage_percentage = $memory_usage['MemUsageCalc'];
183 + $memory_usage_percentage = ServerInfo::wp_memory_usage_percentage();
261 184
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()) {
185 + if ( $memory_usage_percentage <= 65 ) {
186 + $memory_status = '#00BA88';
187 + } elseif ( $memory_usage_percentage > 65 && $memory_usage_percentage < 85 ) {
188 + $memory_status = '#ffe08a';
189 + } elseif ( $memory_usage_percentage > 85 ) {
190 + $memory_status = '#f14668';
191 + }
192 + ?>
193 + <div class="column has-text-right">
194 +
195 + <?php
196 + if ( is_rtl() ) {
272 197 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) . '%'
198 + 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>' ),
199 + esc_html__( 'WP Memory Usage: ', 'adminify' ),
200 + esc_html( $memory_usage_format ),
201 + esc_html( $memory_limit ),
202 + esc_html( $memory_status ),
203 + esc_html( $memory_usage_percentage ) . '%'
279 204 );
280 205 } else {
281 206 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) . '%'
207 + 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>' ),
208 + esc_html__( 'WP Memory Usage: ', 'adminify' ),
209 + esc_html( $memory_usage_format ),
210 + esc_html( $memory_limit ),
211 + esc_html( $memory_status ),
212 + esc_html( $memory_usage_percentage ) . '%'
288 213 );
289 214 }
290 - ?>
291 - </span>
292 - </div>
293 - <?php
215 + ?>
216 + </span>
217 + </div>
218 + <?php
219 + }
294 220 }
295 221
296 222 /**
297 223 * Memory Limit
298 224 */
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">
225 + public function adminify_memory_limit() {
226 + if ( ! empty( $this->options['admin_footer_memory_limit'] ) ) {
227 + $memory_limit = $this->server_info->get_wp_memory_usage();
228 + $memory_limit = $memory_limit['MemLimitFormat'];
229 + ?>
230 + <div class="column has-text-right">
231 + <?php
232 + if ( is_rtl() ) {
233 + echo sprintf(
234 + '<span class="info-details">%2$s</span><span class="info-id">%1$s</span>',
235 + esc_html__( 'WP Memory Limit: ', 'adminify' ),
236 + esc_html( $memory_limit )
237 + );
238 + } else {
239 + echo sprintf(
240 + '<span class="info-id">%1$s</span><span class="info-details">%2$s</span>',
241 + esc_html__( 'WP Memory Limit: ', 'adminify' ),
242 + esc_html( $memory_limit )
243 + );
244 + }
245 + ?>
246 + </div>
305 247 <?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
248 + }
322 249 }
323 250
324 251
325 252 /**
@@ -324,76 +251,72 @@
324 251
325 252 /**
326 253 * Memory Limit
327 254 */
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">
255 + public function adminify_memory_available() {
256 + if ( ! empty( $this->options['admin_footer_memory_available'] ) ) {
257 + $memory_available = $this->server_info->get_wp_memory_usage();
258 + $memory_available = $memory_available['MemLimitGet'];
259 + ?>
260 + <div class="column has-text-right">
261 + <?php
262 + if ( is_rtl() ) {
263 + echo sprintf(
264 + '<span class="info-details is-uppercase">%2$s</span><span class="info-id">%1$s</span>',
265 + esc_html__( 'WP Memory Available: ', 'adminify' ),
266 + esc_html( $memory_available )
267 + );
268 + } else {
269 + echo sprintf(
270 + '<span class="info-id">%1$s</span><span class="info-details is-uppercase">%2$s</span>',
271 + esc_html__( 'WP Memory Available: ', 'adminify' ),
272 + esc_html( $memory_available )
273 + );
274 + }
275 + ?>
276 + </div>
333 277 <?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
278 + }
350 279 }
351 280
352 -
353 281 /** Admin Footer Text **/
354 - public function change_admin_footer($footer_text) { ?>
282 + public function jltwp_adminify_change_admin_footer( $footer_text ) {
283 + if (
284 + ! empty( $this->options['admin_footer_memory_usage'] ) ||
285 + ! empty( $this->options['admin_footer_memory_limit'] ) ||
286 + ! empty( $this->options['admin_footer_memory_available'] ) ||
287 + ! empty( $this->options['admin_footer_ip_address'] ) ||
288 + ! empty( $this->options['admin_footer_php_version'] ) ||
289 + ! empty( $this->options['admin_footer_wp_version'] )
290 + ) {
291 + ?>
292 + <div class="wp-adminify adminify-last-child">
355 293
356 - <div class="adminify--footer">
357 - <?php $this->change_admin_footer_text();
358 - if ( !empty($this->options) ) { ?>
294 + <div class="system-info has-text-right">
295 + <div class="info-line-1">
359 296
360 - <div class="adminify-footer-right">
361 - <div class="adminify-system-info-col">
362 297 <?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 - }
298 + $this->adminify_ip_address();
299 + $this->adminify_php_version();
300 + $this->adminify_wp_version();
374 301 ?>
375 302 </div>
376 - <div class="adminify-system-info-col">
303 +
304 + <div class="info-line-2">
377 305 <?php
378 - if ( in_array('memory_usage', $this->options ) ) {
379 - $this->memory_usage();
380 - }
306 + $this->adminify_memory_usage();
307 + $this->adminify_memory_limit();
308 + $this->adminify_memory_available();
309 + ?>
381 310
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 311 </div>
391 312 </div>
392 - <?php return $footer_text;
393 - } ?>
394 - </div>
395 - <?php
313 +
314 + </div>
315 + <?php
316 + return $footer_text;
317 + }
318 +
396 319 // Nothing, return blank
397 320 return '';
398 321 }
399 322 }