| @@ -1,11 +1,12 @@ | ||
| 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 | 12 | if (!defined('ABSPATH')) { |
| @@ -27,20 +28,8 @@ | ||
| 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 | 34 | public function __construct() |
| 46 | 35 | { |
| @@ -52,18 +41,13 @@ | ||
| 52 | 41 | if (!empty($this->options) && in_array('wp_version', $this->options)) { |
| 53 | 42 | add_action('admin_menu', [$this, 'remove_admin_footer_version']); |
| 54 | 43 | } |
| 55 | 44 | |
| 56 | - add_action('admin_menu', [$this, 'footer_version_remove']); | |
| 57 | - add_action('network_admin_menu', [$this, 'footer_version_remove']); | |
| 45 | + add_action('admin_menu', [$this, 'jltwp_adminify_footer_version_remove']); | |
| 46 | + add_action('network_admin_menu', [$this, 'jltwp_adminify_footer_version_remove']); | |
| 58 | 47 | /** Admin Footer */ |
| 59 | - add_filter('update_footer', [$this, 'change_admin_footer'], 10, 3); | |
| 48 | + add_filter('update_footer', [$this, 'jltwp_adminify_change_admin_footer'], 10, 3); | |
| 60 | 49 | |
| 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); | |
| 65 | - | |
| 66 | 50 | add_filter( 'admin_footer_text', '__return_false', 999 ); |
| 67 | 51 | add_filter( 'update_footer', '__return_false', 999 ); |
| 68 | 52 | |
| 69 | 53 | $this->server_info = new ServerInfo(); |
| @@ -68,25 +52,10 @@ | ||
| 68 | 52 | |
| 69 | 53 | $this->server_info = new ServerInfo(); |
| 70 | 54 | } |
| 71 | 55 | |
| 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; | |
| 85 | - } | |
| 86 | 56 | |
| 87 | 57 | |
| 88 | - | |
| 89 | 58 | /** |
| 90 | 59 | * Remove WordPress version |
| 91 | 60 | * |
| 92 | 61 | * @return void |
| @@ -99,44 +68,30 @@ | ||
| 99 | 68 | } |
| 100 | 69 | } |
| 101 | 70 | |
| 102 | 71 | |
| 103 | - // function footer_get_options() | |
| 72 | + // function jltwp_adminify_footer_get_options() | |
| 104 | 73 | // { |
| 105 | 74 | // $objects = isset($this->options) && is_array($this->options) ? $this->options : []; |
| 106 | 75 | // return $objects; |
| 107 | 76 | // } |
| 108 | 77 | |
| 109 | - public function footer_version_remove() | |
| 78 | + public function jltwp_adminify_footer_version_remove() | |
| 110 | 79 | { |
| 111 | 80 | remove_filter('update_footer', 'core_update_footer'); |
| 112 | 81 | } |
| 113 | 82 | |
| 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 | 83 | /** Footer Credits */ |
| 135 | - public function footer_credits() | |
| 136 | - { ?> | |
| 84 | + public function jltwp_adminify_footer_credits() | |
| 85 | + { ?> | |
| 137 | 86 | <div class="adminify-copyright"> |
| 138 | - <?php echo wp_kses_post(self::get_default_footer_credit()); ?> | |
| 87 | + <?php | |
| 88 | + echo sprintf( __('<p>Developed by <a href="%1$s" target="_blank" title="WP Adminify by Jewel Theme" target="_blank">%2$s</a></p> <p>Powered by <a target="_blank" href="%3$s">WordPress</a></p>', 'adminify'), | |
| 89 | + esc_url('https://wpadminify.com/'), | |
| 90 | + __('WP Adminify', 'adminify'), | |
| 91 | + esc_url( 'https://wordpress.org/' ) | |
| 92 | + ); | |
| 93 | + ?> | |
| 139 | 94 | </div> |
| 140 | 95 | <?php |
| 141 | 96 | } |
| 142 | 97 | |
| @@ -144,25 +99,8 @@ | ||
| 144 | 99 | public function change_admin_footer_text() |
| 145 | 100 | { |
| 146 | 101 | $footer_text = (array) AdminSettings::get_instance()->get(); |
| 147 | 102 | |
| 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 | |
| 162 | - return; | |
| 163 | - } | |
| 164 | - | |
| 165 | 103 | if (!empty($footer_text['white_label']['wordpress']['footer_text'])) { ?> |
| 166 | 104 | <div class="adminify-footer-left"> |
| 167 | 105 | <?php echo wp_kses_post($footer_text['white_label']['wordpress']['footer_text']); ?> |
| 168 | 106 | </div> |
| @@ -168,19 +106,17 @@ | ||
| 168 | 106 | </div> |
| 169 | 107 | <?php |
| 170 | 108 | return; |
| 171 | 109 | } |
| 172 | - | |
| 173 | 110 | // Change the content of the left admin footer text. |
| 174 | - apply_filters('pxlbsadminify_footer_credits', $this->footer_credits()); | |
| 111 | + apply_filters('jltwp_adminify_footer_credits', $this->jltwp_adminify_footer_credits()); | |
| 175 | 112 | } |
| 176 | 113 | |
| 177 | 114 | |
| 178 | - | |
| 179 | 115 | /** |
| 180 | 116 | * IP Address |
| 181 | 117 | */ |
| 182 | - public function ip_address() { ?> | |
| 118 | + public function adminify_ip_address() { ?> | |
| 183 | 119 | <div class="adminify-system-info"> |
| 184 | 120 | <?php |
| 185 | 121 | if (is_rtl()) { |
| 186 | 122 | echo sprintf( |
| @@ -203,9 +139,9 @@ | ||
| 203 | 139 | |
| 204 | 140 | /** |
| 205 | 141 | * PHP Version |
| 206 | 142 | */ |
| 207 | - public function php_version() { ?> | |
| 143 | + public function adminify_php_version() { ?> | |
| 208 | 144 | <div class="adminify-system-info"> |
| 209 | 145 | <?php |
| 210 | 146 | if (is_rtl()) { |
| 211 | 147 | echo sprintf( |
| @@ -227,9 +163,9 @@ | ||
| 227 | 163 | |
| 228 | 164 | /** |
| 229 | 165 | * WordPress Version |
| 230 | 166 | */ |
| 231 | - public function default_wp_version() { ?> | |
| 167 | + public function adminify_wp_version() { ?> | |
| 232 | 168 | <div class="adminify-system-info"> |
| 233 | 169 | <?php |
| 234 | 170 | if (is_rtl()) { |
| 235 | 171 | echo sprintf( |
| @@ -251,14 +187,14 @@ | ||
| 251 | 187 | |
| 252 | 188 | /** |
| 253 | 189 | * Memory Usage |
| 254 | 190 | */ |
| 255 | - public function memory_usage() { | |
| 191 | + public function adminify_memory_usage() { | |
| 256 | 192 | $memory_usage = $this->server_info->get_wp_memory_usage(); |
| 257 | 193 | $memory_limit = $memory_usage['MemLimitFormat']; |
| 258 | 194 | $memory_usage_format = $memory_usage['MemUsageFormat']; |
| 259 | 195 | // $memory_usage_percentage = $memory_usage['MemUsageCalc']; |
| 260 | - $memory_usage_percentage = ServerInfo::memory_usage_percentage(); | |
| 196 | + $memory_usage_percentage = ServerInfo::wp_memory_usage_percentage(); | |
| 261 | 197 | |
| 262 | 198 | if ($memory_usage_percentage <= 65) { |
| 263 | 199 | $memory_status = '#00BA88'; |
| 264 | 200 | } elseif ($memory_usage_percentage > 65 && $memory_usage_percentage < 85) { |
| @@ -295,9 +231,9 @@ | ||
| 295 | 231 | |
| 296 | 232 | /** |
| 297 | 233 | * Memory Limit |
| 298 | 234 | */ |
| 299 | - public function memory_limit() { | |
| 235 | + public function adminify_memory_limit() { | |
| 300 | 236 | $memory_limit = $this->server_info->get_wp_memory_usage(); |
| 301 | 237 | |
| 302 | 238 | $memory_limit = $memory_limit['MemLimitFormat']; ?> |
| 303 | 239 | |
| @@ -324,9 +260,9 @@ | ||
| 324 | 260 | |
| 325 | 261 | /** |
| 326 | 262 | * Memory Limit |
| 327 | 263 | */ |
| 328 | - public function memory_available() { | |
| 264 | + public function adminify_memory_available() { | |
| 329 | 265 | $memory_available = $this->server_info->get_wp_memory_usage(); |
| 330 | 266 | $memory_available = rtrim($memory_available['MemLimitGet'], 'MB') - rtrim($memory_available['MemUsageFormat'], 'MB'); ?> |
| 331 | 267 | |
| 332 | 268 | <div class="adminify-system-info"> |
| @@ -350,12 +286,12 @@ | ||
| 350 | 286 | } |
| 351 | 287 | |
| 352 | 288 | |
| 353 | 289 | /** Admin Footer Text **/ |
| 354 | - public function change_admin_footer($footer_text) { ?> | |
| 290 | + public function jltwp_adminify_change_admin_footer($footer_text) { ?> | |
| 355 | 291 | |
| 356 | 292 | <div class="adminify--footer"> |
| 357 | - <?php $this->change_admin_footer_text(); | |
| 293 | + <?php echo $this->change_admin_footer_text(); | |
| 358 | 294 | if ( !empty($this->options) ) { ?> |
| 359 | 295 | |
| 360 | 296 | <div class="adminify-footer-right"> |
| 361 | 297 | <div class="adminify-system-info-col"> |
| @@ -360,17 +296,17 @@ | ||
| 360 | 296 | <div class="adminify-footer-right"> |
| 361 | 297 | <div class="adminify-system-info-col"> |
| 362 | 298 | <?php |
| 363 | 299 | if ( in_array('ip_address', $this->options ) ) { |
| 364 | - $this->ip_address(); | |
| 300 | + $this->adminify_ip_address(); | |
| 365 | 301 | } |
| 366 | 302 | |
| 367 | 303 | if ( in_array('php_version', $this->options ) ) { |
| 368 | - $this->php_version(); | |
| 304 | + $this->adminify_php_version(); | |
| 369 | 305 | } |
| 370 | 306 | |
| 371 | 307 | if ( in_array('wp_version', $this->options ) ) { |
| 372 | - $this->default_wp_version(); | |
| 308 | + $this->adminify_wp_version(); | |
| 373 | 309 | } |
| 374 | 310 | ?> |
| 375 | 311 | </div> |
| 376 | 312 | <div class="adminify-system-info-col"> |
| @@ -375,21 +311,22 @@ | ||
| 375 | 311 | </div> |
| 376 | 312 | <div class="adminify-system-info-col"> |
| 377 | 313 | <?php |
| 378 | 314 | if ( in_array('memory_usage', $this->options ) ) { |
| 379 | - $this->memory_usage(); | |
| 315 | + $this->adminify_memory_usage(); | |
| 380 | 316 | } |
| 381 | 317 | |
| 382 | 318 | if ( in_array('memory_limit', $this->options ) ) { |
| 383 | - $this->memory_limit(); | |
| 319 | + $this->adminify_memory_limit(); | |
| 384 | 320 | } |
| 385 | 321 | |
| 386 | 322 | if ( in_array('memory_available', $this->options ) ) { |
| 387 | - $this->memory_available(); | |
| 323 | + $this->adminify_memory_available(); | |
| 388 | 324 | } |
| 389 | 325 | ?> |
| 390 | 326 | </div> |
| 391 | 327 | </div> |
| 328 | + | |
| 392 | 329 | <?php return $footer_text; |
| 393 | 330 | } ?> |
| 394 | 331 | </div> |
| 395 | 332 | <?php |