= 15) { $admin_custom_font_main_css .= PHP_EOL . '#adminmenu span.awaiting-mod > span.plugin-count, #adminmenu span.update-plugins > span.plugin-count{line-height:normal; vertical-align:inherit;}'; } } if( (!empty($admin_custom_font_family) && $admin_custom_font_family !== 'default') || (!empty($admin_custom_font_size) && $admin_custom_font_size !== 'default') || (!empty($admin_custom_font_weight) && $admin_custom_font_weight !== 'default') ) { $admin_custom_font_login_css = 'body*:not([class="dashicons"]),.wp-core-ui *:not([class="dashicons"]){' . $font_family . $font_size . $font_weight . '}'; $admin_custom_font_toolbar_css = '#wpadminbar *:not([class="ab-icon"]){' . $font_family . $font_size . $font_weight . '}'; } // compile default css files @ install admin_custom_font_compile_css($admin_custom_font_main_css_path, $admin_custom_font_main_css); admin_custom_font_compile_css($admin_custom_font_login_css_path, $admin_custom_font_login_css); admin_custom_font_compile_css($admin_custom_font_toolbar_css_path, $admin_custom_font_toolbar_css); // set plugin version if(empty($admin_custom_font_version)) { add_option('admin_custom_font_version', ADMIN_CUSTOM_FONT_PLUGIN_VER); } else { update_option('admin_custom_font_version', ADMIN_CUSTOM_FONT_PLUGIN_VER); } } register_activation_hook(__FILE__, 'admin_custom_font_activate'); ## UNINSTALL function admin_custom_font_uninstall() { delete_option('admin_custom_font_version'); delete_option('admin_custom_font_family'); delete_option('admin_custom_font_size'); delete_option('admin_custom_font_weight'); } register_uninstall_hook(__FILE__, 'admin_custom_font_uninstall'); ## LANGUAGE TRANSLATIONS function admin_custom_font_language_init() { $lang_dir = basename(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'lang'; load_plugin_textdomain('admin-custom-font', false, $lang_dir); } add_action('plugins_loaded', 'admin_custom_font_language_init'); ## ADMIN SECTION // create admin page function admin_custom_font_settings_menu() { add_options_page('Admin Custom Font Menu', 'Admin Font', 'manage_options', 'admin-custom-font-settings', 'admin_custom_font_options'); } add_action('admin_menu', 'admin_custom_font_settings_menu'); // admin page options function admin_custom_font_options() { // user privileges check if(!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } // set variables $admin_custom_font_family = ''; $admin_custom_font_size = ''; $admin_custom_font_weight = ''; # UPDATE SETTINGS if(isset($_POST) && !empty($_POST)) { $admin_custom_font_nonce = $_POST['admin_custom_font_nonce_input_txt']; if(!wp_verify_nonce($admin_custom_font_nonce, 'admin_custom_font_nonce')) { wp_die(__('Security Check Failed. Please log out and log in back into WordPress.', 'admin-custom-font')); } $admin_custom_font_family = ((isset($_POST['admin_custom_font_family_option']) && !empty($_POST['admin_custom_font_family_option'])) ? $_POST['admin_custom_font_family_option'] : ''); $admin_custom_font_size = ((isset($_POST['admin_custom_font_size_option']) && !empty($_POST['admin_custom_font_size_option']) ) ? $_POST['admin_custom_font_size_option'] : ''); $admin_custom_font_weight = ((isset($_POST['admin_custom_font_weight_option']) && !empty($_POST['admin_custom_font_weight_option'])) ? $_POST['admin_custom_font_weight_option'] : ''); // update font family if(isset($admin_custom_font_family) && !empty($admin_custom_font_family)) { update_option('admin_custom_font_family', (string) $admin_custom_font_family); } // update font size if(isset($admin_custom_font_size) && !empty($admin_custom_font_size)) { update_option('admin_custom_font_size', (string) $admin_custom_font_size); } // update font weight if(isset($admin_custom_font_weight) && !empty($admin_custom_font_weight)) { update_option('admin_custom_font_weight', (string) $admin_custom_font_weight); } # COMPILE CSS FILES // construct css options, files & paths $font_family = ''; $font_size = ''; $font_weight = ''; $admin_custom_font_main_css = ''; $admin_custom_font_login_css = ''; $admin_custom_font_toolbar_css = ''; $admin_custom_font_main_css_path = ADMIN_CUSTOM_FONT_PLUGIN_CSS_DIR . 'admin-custom-font.css'; $admin_custom_font_login_css_path = ADMIN_CUSTOM_FONT_PLUGIN_CSS_DIR . 'admin-custom-font-login.css'; $admin_custom_font_toolbar_css_path = ADMIN_CUSTOM_FONT_PLUGIN_CSS_DIR . 'admin-custom-font-toolbar.css'; // construct css options if(!empty($admin_custom_font_family) && $admin_custom_font_family !== 'default') { $font_family = 'font-family:' . '"' . $admin_custom_font_family . '"' . ',' . 'sans-serif' . ' ' . '!important' . ';'; } if(!empty($admin_custom_font_size) && $admin_custom_font_size !== 'default') { $font_size = 'font-size:' . $admin_custom_font_size . 'px' . ' ' . '!important' . ';'; } if(!empty($admin_custom_font_weight) && $admin_custom_font_weight !== 'default') { $font_weight = 'font-weight:' . $admin_custom_font_weight . ' ' . '!important' . ';'; } // construct templates if(!empty($admin_custom_font_family) && $admin_custom_font_family !== 'default') { $admin_custom_font_main_css = 'body,#wpadminbar *:not([class="ab-icon"]),.wp-core-ui,.media-menu,.media-frame *,.media-modal *,.code, code, input, select, textarea *:not([class="wp-editor-area"]), button.button,button.primary{' . $font_family . '}'; } if(!empty($font_size) || !empty($font_weight)) { $admin_custom_font_main_css .= 'body, div, a, span, td, button, input *:not([id="titlediv"]), select, p, li, strong, .form-table *{' . $font_size . $font_weight . '}'; $admin_custom_font_main_css .= PHP_EOL . 'select{line-height:initial !important; height:initial !important;' . '}'; if ($admin_custom_font_size >= 15) { $admin_custom_font_main_css .= PHP_EOL . '#adminmenu span.awaiting-mod > span.plugin-count, #adminmenu span.update-plugins > span.plugin-count{line-height:normal; vertical-align:inherit;}'; } } if( (!empty($admin_custom_font_family) && $admin_custom_font_family !== 'default') || (!empty($admin_custom_font_size) && $admin_custom_font_size !== 'default') || (!empty($admin_custom_font_weight) && $admin_custom_font_weight !== 'default') ) { $admin_custom_font_login_css = 'body*:not([class="dashicons"]),.wp-core-ui *:not([class="dashicons"]){' . $font_family . $font_size . $font_weight . '}'; $admin_custom_font_toolbar_css = '#wpadminbar *:not([class="ab-icon"]){' . $font_family . $font_size . $font_weight . '}'; } // compile css files admin_custom_font_compile_css($admin_custom_font_main_css_path, $admin_custom_font_main_css); admin_custom_font_compile_css($admin_custom_font_login_css_path, $admin_custom_font_login_css); admin_custom_font_compile_css($admin_custom_font_toolbar_css_path, $admin_custom_font_toolbar_css); } ?>

Admin Custom Font