'Manual (default)', 'auto' => 'Automatic (Pro)' ]; const OMGF_FONT_PROCESSING_OPTIONS = [ 'replace' => 'Replace (default)', 'remove' => 'Remove only' ]; const OMGF_FONT_DISPLAY_OPTIONS = [ 'swap' => 'Swap (recommended)', 'auto' => 'Auto', 'block' => 'Block', 'fallback' => 'Fallback', 'optional' => 'Optional' ]; const OMGF_FILE_TYPES_OPTIONS = [ 'woff2' => 'Web Open Font Format 2.0 (WOFF2)', 'woff' => 'Web Open Font Format (WOFF)', 'eot' => 'Embedded OpenType (EOT)', 'ttf' => 'TrueType Font (TTF)', 'svg' => 'Scalable Vector Graphics (SVG)' ]; const OMGF_FORCE_SUBSETS_OPTIONS = [ 'arabic' => 'Arabic', 'bengali' => 'Bengali', 'chinese-hongkong' => 'Chinese (Hong Kong)', 'chinese-simplified' => 'Chinese (Simplified)', 'chinese-traditional' => 'Chinese (Traditional)', 'cyrillic' => 'Cyrillic', 'cyrillic-ext' => 'Cyrillic Extended', 'devanagari' => 'Devanagari', 'greek' => 'Greek', 'greek-ext' => 'Greek Extended', 'gujarati' => 'Gujarati', 'gurmukhi' => 'Gurmukhi', 'hebrew' => 'Hebrew', 'japanese' => 'Japanese', 'kannada' => 'Kannada', 'khmer' => 'Khmer', 'korean' => 'Korean', 'latin' => 'Latin', 'latin-ext' => 'Latin Extended', 'malayalam' => 'Malayalam', 'myanmar' => 'Myanmar', 'oriya' => 'Oriya', 'sinhala' => 'Sinhala', 'tamil' => 'Tamil', 'telugu' => 'Telugu', 'thai' => 'Thai', 'tibetan' => 'Tibetan', 'vietnamese' => 'Vietnamese' ]; const OMGF_FALLBACK_FONT_STACKS_OPTIONS = [ 'arial' => 'Arial', 'baskerville' => 'Baskerville', 'bodoni-mt' => 'Bodoni MT', 'calibri' => 'Calibri', 'calisto-mt' => 'Calisto MT', 'cambria' => 'Cambria', 'candara' => 'Candara', 'century-gothic' => 'Century Gothic', 'consolas' => 'Consolas', 'copperplate-gothic' => 'Copperplate Gothic', 'courier-new' => 'Courier New', 'dejavu-sans' => 'Dejavu Sans', 'didot' => 'Didot', 'franklin-gothic' => 'Franklin Gothic', 'garamond' => 'Garamond', 'georgia' => 'Georgia', 'gill-sans' => 'Gill Sans', 'goudy-old-style' => 'Goudy Old Style', 'helvetica' => 'Helvetica', 'impact' => 'Impact', 'lucida-bright' => 'Lucida Bright', 'lucida-sans' => 'Lucida Sans', 'ms-sans-serif' => 'Microsoft Sans Serif', 'optima' => 'Optima', 'palatino' => 'Palatino', 'perpetua' => 'Perpetua', 'rockwell' => 'Rockwell', 'segoe-ui' => 'Segoe UI', 'tahoma' => 'Tahoma', 'trebuchet-ms' => 'Trebuchet MS', 'verdana' => 'Verdana' ]; const OMGF_AMP_HANDLING_OPTIONS = [ 'fallback' => 'Fallback (default)', 'disable' => 'Disable' ]; /** * Optimize Fonts */ const OMGF_OPTIMIZE_SETTING_DISPLAY_OPTION = 'omgf_display_option'; const OMGF_OPTIMIZE_SETTING_MANUAL_OPTIMIZE_URL = 'omgf_manual_optimize_url'; const OMGF_OPTIMIZE_SETTING_OPTIMIZATION_MODE = 'omgf_optimization_mode'; const OMGF_OPTIMIZE_SETTING_OPTIMIZED_FONTS = 'omgf_optimized_fonts'; const OMGF_OPTIMIZE_SETTING_OPTIMIZE_EDIT_ROLES = 'omgf_optimize_edit_roles'; const OMGF_OPTIMIZE_SETTING_PRELOAD_FONTS = 'omgf_preload_fonts'; const OMGF_OPTIMIZE_SETTING_UNLOAD_FONTS = 'omgf_unload_fonts'; const OMGF_OPTIMIZE_SETTING_UNLOAD_STYLESHEETS = 'omgf_unload_stylesheets'; const OMGF_OPTIMIZE_SETTING_CACHE_KEYS = 'omgf_cache_keys'; /** * Detection Settings */ const OMGF_DETECTION_SETTING_FONT_PROCESSING = 'omgf_font_processing'; /** * Advanced Settings */ const OMGF_ADV_SETTING_AMP_HANDLING = 'omgf_amp_handling'; const OMGF_ADV_SETTING_CACHE_PATH = 'omgf_cache_dir'; const OMGF_ADV_SETTING_SOURCE_URL = 'omgf_fonts_url'; const OMGF_ADV_SETTING_UNINSTALL = 'omgf_uninstall'; /** * Miscellaneous */ const OMGF_OPTIONS_GENERAL_PAGE_OPTIMIZE_WEBFONTS = 'options-general.php?page=optimize-webfonts'; const OMGF_PLUGINS_INSTALL_CHANGELOG_SECTION = 'plugin-install.php?tab=plugin-information&plugin=host-webfonts-local&TB_iframe=true&width=772&height=1015§ion=changelog'; const FFWP_WORDPRESS_PLUGINS_OMGF_PRO = 'https://ffw.press/wordpress/omgf-pro/'; /** @var string $active_tab */ private $active_tab; /** @var string $page */ private $page; /** @var string $plugin_text_domain */ private $plugin_text_domain = 'host-webfonts-local'; /** @var string|null */ private $submit_button_text = null; /** * OMGF_Admin_Settings constructor. */ public function __construct() { parent::__construct(); $this->active_tab = isset($_GET['tab']) ? $_GET['tab'] : self::OMGF_SETTINGS_FIELD_OPTIMIZE; $this->page = isset($_GET['page']) ? $_GET['page'] : ''; add_action('admin_menu', [$this, 'create_menu']); add_filter('plugin_action_links_' . plugin_basename(OMGF_PLUGIN_FILE), [$this, 'create_settings_link']); if ($this->page !== self::OMGF_ADMIN_PAGE) { return; } if ($this->active_tab == self::OMGF_SETTINGS_FIELD_OPTIMIZE) { $this->submit_button_text = __('Save & Optimize', $this->plugin_text_domain); } // Footer Text add_filter('admin_footer_text', [$this, 'footer_text_left'], 99); add_filter('update_footer', [$this, 'footer_text_right'], 11); // Tabs add_action('omgf_settings_tab', [$this, 'optimize_fonts_tab'], 0); add_action('omgf_settings_tab', [$this, 'detection_settings_tab'], 1); add_action('omgf_settings_tab', [$this, 'advanced_settings_tab'], 2); add_action('omgf_settings_tab', [$this, 'help_tab'], 3); // Content add_action('omgf_settings_content', [$this, 'optimize_fonts_content'], 0); add_action('omgf_settings_content', [$this, 'detection_settings_content'], 1); add_action('omgf_settings_content', [$this, 'advanced_settings_content'], 2); add_action('omgf_settings_content', [$this, 'help_content'], 3); } /** * Creates the menu item. */ public function create_menu() { add_options_page( 'OMGF', 'Optimize Google Fonts', 'manage_options', self::OMGF_ADMIN_PAGE, [$this, 'create_settings_page'] ); add_action('admin_init', [$this, 'register_settings']); } /** * Display the settings page. */ public function create_settings_page() { if (!current_user_can('manage_options')) { wp_die(__("You're not cool enough to access this page.", $this->plugin_text_domain)); } ?>
= get_plugin_data(OMGF_PLUGIN_FILE)['Description']; ?>