| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace PXLBSAdminify\Inc\Classes; | |
| 3 | +namespace WPAdminify\Inc\Classes; | |
| 4 | 4 | |
| 5 | 5 | // no direct access allowed |
| 6 | 6 | if (!defined('ABSPATH')) { |
| 7 | 7 | exit; |
| @@ -47,9 +47,9 @@ | ||
| 47 | 47 | */ |
| 48 | 48 | private function __construct() |
| 49 | 49 | { |
| 50 | 50 | // Hook into framework's save filter (most reliable) |
| 51 | - add_filter('pxlbsadminify_adminify_saved_before', [$this, 'on_settings_save'], 10, 1); | |
| 51 | + add_filter('adminify__wpadminify_saved_before', [$this, 'on_settings_save'], 10, 1); | |
| 52 | 52 | |
| 53 | 53 | // Enqueue local fonts |
| 54 | 54 | add_action('admin_enqueue_scripts', [$this, 'enqueue_local_fonts'], 99); |
| 55 | 55 | } |
| @@ -71,12 +71,14 @@ | ||
| 71 | 71 | if (!is_array($data)) { |
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - // Body Font (admin_general_google_font) is a Pro-only feature. | |
| 76 | - // Pro/Classes/Assets_Pro.php hooks | |
| 77 | - // pxlbsadminify_adminify_saved_before to download that font on | |
| 78 | - // save. Free leaves it alone. | |
| 75 | + // Process Body Font | |
| 76 | + if (!empty($data['admin_general_google_font']['font-family'])) { | |
| 77 | + $font_family = $data['admin_general_google_font']['font-family']; | |
| 78 | + $font_weights = !empty($data['admin_general_google_font']['font-weight']) ? $data['admin_general_google_font']['font-weight'] : '400'; | |
| 79 | + $result = $this->download_font($font_family, $font_weights); | |
| 80 | + } | |
| 79 | 81 | |
| 80 | 82 | // Process Light Mode Logo Typography |
| 81 | 83 | if (!empty($data['light_dark_mode']['admin_ui_light_mode']['admin_ui_light_logo_text_typo']['font-family'])) { |
| 82 | 84 | $typo = $data['light_dark_mode']['admin_ui_light_mode']['admin_ui_light_logo_text_typo']; |
| @@ -214,9 +216,9 @@ | ||
| 214 | 216 | } |
| 215 | 217 | |
| 216 | 218 | // Generate local filename |
| 217 | 219 | $url_hash = substr(md5($font_url), 0, 8); |
| 218 | - $extension = pathinfo(wp_parse_url($font_url, PHP_URL_PATH), PATHINFO_EXTENSION); | |
| 220 | + $extension = pathinfo(parse_url($font_url, PHP_URL_PATH), PATHINFO_EXTENSION); | |
| 219 | 221 | if (empty($extension)) { |
| 220 | 222 | $extension = 'woff2'; |
| 221 | 223 | } |
| 222 | 224 | $local_filename = $font_slug . '-' . $url_hash . '.' . $extension; |
| @@ -245,9 +247,9 @@ | ||
| 245 | 247 | |
| 246 | 248 | // Save local CSS file |
| 247 | 249 | $css_file = $folder . '/' . $font_slug . '.css'; |
| 248 | 250 | $header = "/* Local Google Font: {$font_family} */\n"; |
| 249 | - $header .= "/* Generated by Adminify - " . gmdate('Y-m-d H:i:s') . " */\n\n"; | |
| 251 | + $header .= "/* Generated by WP Adminify - " . date('Y-m-d H:i:s') . " */\n\n"; | |
| 250 | 252 | file_put_contents($css_file, $header . $css_content); |
| 251 | 253 | |
| 252 | 254 | return true; |
| 253 | 255 | } |
| @@ -290,18 +292,24 @@ | ||
| 290 | 292 | * Enqueue local fonts for admin |
| 291 | 293 | */ |
| 292 | 294 | public function enqueue_local_fonts() |
| 293 | 295 | { |
| 294 | - $options = get_option('pxlbsadminify_settings'); | |
| 296 | + $options = get_option('_wpadminify'); | |
| 295 | 297 | |
| 296 | 298 | if (empty($options) || !is_array($options)) { |
| 297 | 299 | return; |
| 298 | 300 | } |
| 299 | 301 | |
| 300 | - // Body Font (admin_general_google_font) is a Pro-only feature. | |
| 301 | - // Pro/Classes/Assets_Pro.php enqueues that font via its own | |
| 302 | - // admin_enqueue_scripts callback. Free leaves it alone. | |
| 302 | + // Body Font | |
| 303 | + if (!empty($options['admin_general_google_font']['font-family'])) { | |
| 304 | + $font_family = $options['admin_general_google_font']['font-family']; | |
| 305 | + $local_url = $this->get_local_font_url($font_family); | |
| 303 | 306 | |
| 307 | + if ($local_url) { | |
| 308 | + wp_enqueue_style('adminify-local-body-font', $local_url, [], null); | |
| 309 | + } | |
| 310 | + } | |
| 311 | + | |
| 304 | 312 | // Light Mode Logo Typography |
| 305 | 313 | if (!empty($options['light_dark_mode']['admin_ui_light_mode']['admin_ui_light_logo_text_typo']['font-family'])) { |
| 306 | 314 | $font_family = $options['light_dark_mode']['admin_ui_light_mode']['admin_ui_light_logo_text_typo']['font-family']; |
| 307 | 315 | $local_url = $this->get_local_font_url($font_family); |
| @@ -306,9 +314,9 @@ | ||
| 306 | 314 | $font_family = $options['light_dark_mode']['admin_ui_light_mode']['admin_ui_light_logo_text_typo']['font-family']; |
| 307 | 315 | $local_url = $this->get_local_font_url($font_family); |
| 308 | 316 | |
| 309 | 317 | if ($local_url) { |
| 310 | - wp_enqueue_style('adminify-local-logo-light-font', $local_url, [], PXLBSADMINIFY_VER); | |
| 318 | + wp_enqueue_style('adminify-local-logo-light-font', $local_url, [], null); | |
| 311 | 319 | } |
| 312 | 320 | } |
| 313 | 321 | |
| 314 | 322 | // Dark Mode Logo Typography |
| @@ -316,9 +324,9 @@ | ||
| 316 | 324 | $font_family = $options['light_dark_mode']['admin_ui_dark_mode']['admin_ui_dark_logo_text_typo']['font-family']; |
| 317 | 325 | $local_url = $this->get_local_font_url($font_family); |
| 318 | 326 | |
| 319 | 327 | if ($local_url) { |
| 320 | - wp_enqueue_style('adminify-local-logo-dark-font', $local_url, [], PXLBSADMINIFY_VER); | |
| 328 | + wp_enqueue_style('adminify-local-logo-dark-font', $local_url, [], null); | |
| 321 | 329 | } |
| 322 | 330 | } |
| 323 | 331 | } |
| 324 | 332 | |