PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 1.0.7
Adminify – White Label, Admin Menu Editor, Login Customizer v1.0.7
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 4.1.17 All 164 releases
adminify / Inc / Classes / AdminFooterText.php

AdminFooterText.php in Adminify – White Label, Admin Menu Editor, Login Customizer 1.0.7, at Inc/Classes/AdminFooterText.php

315 lines 10.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPAdminify\Inc\Classes;
4
5 use WPAdminify\Inc\Utils;
6 use WPAdminify\Inc\Classes\ServerInfo;
7 use WPAdminify\Inc\Admin\AdminSettings;
8 use WPAdminify\Inc\Admin\AdminSettingsModel;
9
10
11 // no direct access allowed
12 if (!defined('ABSPATH')) exit;
13
14 /**
15 * @package WP Adminify
16 * @author: Jewel Theme<support@jeweltheme.com>
17 */
18
19 class AdminFooterText extends AdminSettingsModel
20 {
21 public $server_info;
22
23 public function __construct()
24 {
25 $this->options = (array) AdminSettings::get_instance()->get();
26
27 $restrict_for = !empty($this->options['admin_footer_user_roles']) ? $this->options['admin_footer_user_roles'] : '';
28 if ($restrict_for) {
29 add_filter('admin_footer_text', [$this, 'jltwp_adminify_change_admin_footer_text']);
30 return;
31 }
32
33
34 add_action('admin_menu', [$this, 'jltwp_adminify_footer_version_remove']);
35 add_action('network_admin_menu', [$this, 'jltwp_adminify_footer_version_remove']);
36
37 $this->adminify_footer_text_init();
38
39 $this->server_info = new ServerInfo();
40 }
41
42 public function jltwp_adminify_footer_version_remove()
43 {
44 remove_filter('update_footer', 'core_update_footer');
45 }
46
47 public function adminify_footer_text_init()
48 {
49 /** Admin Footer Text **/
50 if (!empty($this->options['footer_text'])) {
51 add_filter('admin_footer_text', [$this, 'jltwp_adminify_change_admin_footer_text']);
52 } else {
53 add_filter('update_footer', [$this, 'jltwp_adminify_change_admin_footer'], 10, 3);
54 add_filter('admin_footer_text', [$this, 'jltwp_adminify_change_admin_footer_text']);
55 }
56 }
57
58 /** Footer Credits */
59 public function jltwp_adminify_footer_credits()
60 { ?>
61 <div class="wp-adminify adminify-first-child">
62 <div class="wp-adminify--copyright">
63 <?php
64 echo sprintf(
65 __('Developed by <a href="%s" target="_blank" title="WP Adminify by Jewel Theme" target="_blank">WP Adminify</a> <br>
66 Powered by <a target="_blank" href="%s">WordPress</a>', WP_ADMINIFY_TD),
67 esc_url('https://wpadminify.com/'),
68 esc_url('https://wordpress.org/')
69 );
70 ?>
71 </div>
72 </div>
73 <?php
74 }
75
76
77 public function jltwp_adminify_change_admin_footer_text()
78 {
79
80 if (!empty($this->options['footer_text'])) {
81 return $this->options['footer_text'];
82 }
83 // Change the content of the left admin footer text.
84 apply_filters('jltwp_adminify_footer_credits', $this->jltwp_adminify_footer_credits());
85 }
86
87
88 /**
89 * IP Address
90 */
91 public function adminify_ip_address()
92 {
93 if (!empty($this->options['admin_footer_ip_address'])) {
94 ?>
95 <div class="column has-text-right">
96 <?php if (is_rtl()) {
97 echo sprintf(
98 '<span class="info-details">%2$s</span><span class="info-id is-uppercase">%1$s</span>',
99 esc_html__('IP: ', WP_ADMINIFY_TD),
100 $this->server_info->get_ip_address()
101 );
102 } else {
103 echo sprintf(
104 '<span class="info-id is-uppercase">%1$s</span><span class="info-details">%2$s</span>',
105 esc_html__('IP: ', WP_ADMINIFY_TD),
106 $this->server_info->get_ip_address()
107 );
108 } ?>
109 </div>
110 <?php
111 }
112 }
113
114
115 /**
116 * PHP Version
117 */
118 public function adminify_php_version()
119 {
120 if (!empty($this->options['admin_footer_php_version'])) {
121 ?>
122 <div class="column has-text-right">
123 <?php if (is_rtl()) {
124 echo sprintf(
125 '<span class="info-details">%2$s</span><span class="info-id">%1$s</span>',
126 esc_html__('PHP: ', WP_ADMINIFY_TD),
127 $this->server_info->get_php_version_lite()
128 );
129 } else {
130 echo sprintf(
131 '<span class="info-id">%1$s</span><span class="info-details">%2$s</span>',
132 esc_html__('PHP: ', WP_ADMINIFY_TD),
133 $this->server_info->get_php_version_lite()
134 );
135 } ?>
136 </div>
137 <?php
138 }
139 }
140
141 /**
142 * WordPress Version
143 */
144 public function adminify_wp_version()
145 {
146 if (!empty($this->options['admin_footer_wp_version'])) {
147 ?>
148 <div class="column has-text-right">
149 <?php if (is_rtl()) {
150 echo sprintf(
151 '<span class="info-details">%2$s</span><span class="info-id">%1$s</span>',
152 esc_html__('WordPress: v', WP_ADMINIFY_TD),
153 $this->server_info->get_wp_version()
154 );
155 } else {
156 echo sprintf(
157 '<span class="info-id">%1$s</span><span class="info-details">%2$s</span>',
158 esc_html__('WordPress: v', WP_ADMINIFY_TD),
159 $this->server_info->get_wp_version()
160 );
161 } ?>
162 </div>
163 <?php
164 }
165 }
166
167 /**
168 * Memory Usage
169 */
170 public function adminify_memory_usage()
171 {
172 if (!empty($this->options['admin_footer_memory_usage'])) {
173 $memory_usage = $this->server_info->get_wp_memory_usage();
174 $memory_limit = $memory_usage['MemLimitFormat'];
175 $memory_usage_format = $memory_usage['MemUsageFormat'];
176 // $memory_usage_percentage = $memory_usage['MemUsageCalc'];
177 $memory_usage_percentage = ServerInfo::wp_memory_usage_percentage();
178
179 if ($memory_usage_percentage <= 65) {
180 $memory_status = '#00BA88';
181 } elseif ($memory_usage_percentage > 65 && $memory_usage_percentage < 85) {
182 $memory_status = '#ffe08a';
183 } elseif ($memory_usage_percentage > 85) {
184 $memory_status = '#f14668';
185 }
186 ?>
187 <div class="column has-text-right">
188
189 <?php if (is_rtl()) {
190 echo sprintf(
191 __('<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>', WP_ADMINIFY_TD),
192
193 esc_html__('WP Memory Usage: ', WP_ADMINIFY_TD),
194 $memory_usage_format,
195 $memory_limit,
196 esc_html($memory_status),
197 $memory_usage_percentage . '%'
198 );
199 } else {
200 echo sprintf(
201 __('<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>', WP_ADMINIFY_TD),
202 esc_html__('WP Memory Usage: ', WP_ADMINIFY_TD),
203 $memory_usage_format,
204 $memory_limit,
205 esc_html($memory_status),
206 $memory_usage_percentage . '%'
207 );
208 } ?>
209 </span>
210 </div>
211 <?php
212 }
213 }
214
215 /**
216 * Memory Limit
217 */
218 public function adminify_memory_limit()
219 {
220 if (!empty($this->options['admin_footer_memory_limit'])) {
221 $memory_limit = $this->server_info->get_wp_memory_usage();
222 $memory_limit = $memory_limit['MemLimitFormat'];
223 ?>
224 <div class="column has-text-right">
225 <?php if (is_rtl()) {
226 echo sprintf(
227 '<span class="info-details">%2$s</span><span class="info-id">%1$s</span>',
228 esc_html__('WP Memory Limit: ', WP_ADMINIFY_TD),
229 $memory_limit
230 );
231 } else {
232 echo sprintf(
233 '<span class="info-id">%1$s</span><span class="info-details">%2$s</span>',
234 esc_html__('WP Memory Limit: ', WP_ADMINIFY_TD),
235 $memory_limit
236 );
237 } ?>
238 </div>
239 <?php
240 }
241 }
242
243
244 /**
245 * Memory Limit
246 */
247 public function adminify_memory_available()
248 {
249 if (!empty($this->options['admin_footer_memory_available'])) {
250 $memory_available = $this->server_info->get_wp_memory_usage();
251 $memory_available = $memory_available['MemLimitGet'];
252 ?>
253 <div class="column has-text-right">
254 <?php if (is_rtl()) {
255 echo sprintf(
256 '<span class="info-details is-uppercase">%2$s</span><span class="info-id">%1$s</span>',
257 esc_html__('WP Memory Available: ', WP_ADMINIFY_TD),
258 $memory_available
259 );
260 } else {
261 echo sprintf(
262 '<span class="info-id">%1$s</span><span class="info-details is-uppercase">%2$s</span>',
263 esc_html__('WP Memory Available: ', WP_ADMINIFY_TD),
264 $memory_available
265 );
266 } ?>
267 </div>
268 <?php
269 }
270 }
271
272 /** Admin Footer Text **/
273 public function jltwp_adminify_change_admin_footer($footer_text)
274 {
275 if (
276 !empty($this->options['admin_footer_memory_usage']) ||
277 !empty($this->options['admin_footer_memory_limit']) ||
278 !empty($this->options['admin_footer_memory_available']) ||
279 !empty($this->options['admin_footer_ip_address']) ||
280 !empty($this->options['admin_footer_php_version']) ||
281 !empty($this->options['admin_footer_wp_version'])
282 ) {
283 ?>
284 <div class="wp-adminify adminify-last-child">
285
286 <div class="system-info has-text-right">
287 <div class="info-line-1">
288
289 <?php
290 $this->adminify_ip_address();
291 $this->adminify_php_version();
292 $this->adminify_wp_version();
293 ?>
294 </div>
295
296 <div class="info-line-2">
297 <?php
298 $this->adminify_memory_usage();
299 $this->adminify_memory_limit();
300 $this->adminify_memory_available();
301 ?>
302
303 </div>
304 </div>
305
306 </div>
307 <?php
308 return $footer_text;
309 }
310
311 // Nothing, return blank
312 return '';
313 }
314 }
315