first commit
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/* * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* ██████╗ ███╗ ███╗ ██████╗ ███████╗
|
||||
* ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
|
||||
* ██║ ██║██╔████╔██║██║ ███╗█████╗
|
||||
* ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
|
||||
* ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
|
||||
* ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
|
||||
*
|
||||
* @package : OMGF
|
||||
* @author : Daan van den Bergh
|
||||
* @copyright: (c) 2021 Daan van den Bergh
|
||||
* @url : https://daan.dev
|
||||
* * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class OMGF_Admin_Settings_Advanced extends OMGF_Admin_Settings_Builder
|
||||
{
|
||||
/**
|
||||
* OMGF_Admin_Settings_Advanced constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->title = __('Advanced Settings', $this->plugin_text_domain);
|
||||
|
||||
// Open
|
||||
add_filter('omgf_advanced_settings_content', [$this, 'do_title'], 10);
|
||||
add_filter('omgf_advanced_settings_content', [$this, 'do_description'], 15);
|
||||
add_filter('omgf_advanced_settings_content', [$this, 'do_before'], 20);
|
||||
|
||||
// Settings
|
||||
add_filter('omgf_advanced_settings_content', [$this, 'do_promo_amp_handling'], 40);
|
||||
add_filter('omgf_advanced_settings_content', [$this, 'do_promo_exclude_posts'], 50);
|
||||
add_filter('omgf_advanced_settings_content', [$this, 'do_cache_dir'], 70);
|
||||
add_filter('omgf_advanced_settings_content', [$this, 'do_promo_fonts_source_url'], 80);
|
||||
add_filter('omgf_advanced_settings_content', [$this, 'do_uninstall'], 110);
|
||||
|
||||
// Close
|
||||
add_filter('omgf_advanced_settings_content', [$this, 'do_after'], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Description
|
||||
*/
|
||||
public function do_description()
|
||||
{
|
||||
?>
|
||||
<p>
|
||||
<?= __('If you require the downloaded/generated files to be saved in a different location or served from a different resource (e.g. a CDN) or path, use these settings to make OMGF work with your configuration.', $this->plugin_text_domain); ?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function do_promo_amp_handling()
|
||||
{
|
||||
$this->do_select(
|
||||
__('AMP handling (Pro)', $this->plugin_text_domain),
|
||||
'omgf_pro_amp_handling',
|
||||
OMGF_Admin_Settings::OMGF_AMP_HANDLING_OPTIONS,
|
||||
defined('OMGF_PRO_AMP_HANDLING') ? OMGF_PRO_AMP_HANDLING : '',
|
||||
sprintf(__("Decide how OMGF Pro should behave on AMP pages. Only select <strong>enable</strong> if the custom CSS limit of 75kb is not already reached by your theme and/or other plugins and no other <code>amp-custom</code> tag is present on your pages.", $this->plugin_text_domain), OMGF_Admin_Settings::FFWP_WORDPRESS_PLUGINS_OMGF_PRO) . ' ' . $this->promo,
|
||||
false,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Excluded Post/Page IDs (Pro)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function do_promo_exclude_posts()
|
||||
{
|
||||
$this->do_text(
|
||||
__('Excluded Post/Page IDs (Pro)', $this->plugin_text_domain),
|
||||
'omgf_pro_excluded_ids',
|
||||
__('e.g. 1,2,5,21,443'),
|
||||
defined('OMGF_PRO_EXCLUDED_IDS') ? OMGF_PRO_EXCLUDED_IDS : '',
|
||||
__('A comma separated list of post/page IDs where OMGF Pro shouldn\'t run. Only works when Advanced Proccessing is enabled under Detection Settings.', $this->plugin_text_domain) . ' ' . $this->promo,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_cache_dir()
|
||||
{
|
||||
$this->do_text(
|
||||
__('Fonts Cache Directory', $this->plugin_text_domain),
|
||||
OMGF_Admin_Settings::OMGF_ADV_SETTING_CACHE_PATH,
|
||||
__('e.g. /uploads/omgf', $this->plugin_text_domain),
|
||||
OMGF_CACHE_PATH,
|
||||
__("The directory (inside <code>wp-content</code>) where font files should be stored. Give each site a unique value if you're using Multisite. Defaults to <code>/uploads/omgf</code>. After changing this setting, the directory will be created if it doesn't exist and existing files will be moved automatically.", $this->plugin_text_domain)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_promo_fonts_source_url()
|
||||
{
|
||||
$this->do_text(
|
||||
__('Fonts Source URL (Pro)', $this->plugin_text_domain),
|
||||
'omgf_pro_source_url',
|
||||
__('e.g. https://cdn.mydomain.com/alternate/relative-path', $this->plugin_text_domain),
|
||||
defined('OMGF_PRO_SOURCE_URL') ? OMGF_PRO_SOURCE_URL : '',
|
||||
sprintf(
|
||||
__("Modify the <code>src</code> URL for each font file in the stylesheet. This can be anything, like an absolute URL (e.g. <code>%s</code>) to an alternate relative URL (e.g. <code>/renamed-wp-content-dir/alternate/path/to/font-files</code>). Make sure you include the full path to where OMGF's files are stored and/or served from. Defaults to <code>%s</code>.", $this->plugin_text_domain),
|
||||
str_replace(home_url(), 'https://your-cdn.com', WP_CONTENT_URL . OMGF_CACHE_PATH),
|
||||
WP_CONTENT_URL . OMGF_CACHE_PATH
|
||||
) . ' ' . $this->promo,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_uninstall()
|
||||
{
|
||||
$this->do_checkbox(
|
||||
__('Remove Settings/Files At Uninstall', $this->plugin_text_domain),
|
||||
OMGF_Admin_Settings::OMGF_ADV_SETTING_UNINSTALL,
|
||||
OMGF_UNINSTALL,
|
||||
__('Warning! This will remove all settings and cached fonts upon plugin deletion.', $this->plugin_text_domain)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
/* * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* ██████╗ ███╗ ███╗ ██████╗ ███████╗
|
||||
* ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
|
||||
* ██║ ██║██╔████╔██║██║ ███╗█████╗
|
||||
* ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
|
||||
* ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
|
||||
* ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
|
||||
*
|
||||
* @package : OMGF
|
||||
* @author : Daan van den Bergh
|
||||
* @copyright: (c) 2021 Daan van den Bergh
|
||||
* @url : https://daan.dev
|
||||
* * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class OMGF_Admin_Settings_Builder
|
||||
{
|
||||
/** @var string $plugin_text_domain */
|
||||
protected $plugin_text_domain = 'host-webfonts-local';
|
||||
|
||||
/** @var $title */
|
||||
protected $title;
|
||||
|
||||
/** @var $promo string */
|
||||
protected $promo;
|
||||
|
||||
/**
|
||||
* Only sets the promo string on settings load.
|
||||
*
|
||||
* OMGF_Admin_Settings_Builder constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_promo']);
|
||||
add_filter('omgf_detection_settings_content', [$this, 'do_promo']);
|
||||
add_filter('omgf_advanced_settings_content', [$this, 'do_promo']);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_promo()
|
||||
{
|
||||
if (apply_filters('apply_omgf_pro_promo', true)) {
|
||||
$this->promo = apply_filters('omgf_pro_promo', sprintf(__('<a href="%s" target="_blank">Upgrade to Pro</a> to enable this option.', $this->plugin_text_domain), OMGF_Admin_Settings::FFWP_WORDPRESS_PLUGINS_OMGF_PRO));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_before()
|
||||
{
|
||||
?>
|
||||
<table class="form-table">
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_after()
|
||||
{
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_title()
|
||||
{
|
||||
?>
|
||||
<h3><?= $this->title ?></h3>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate radio setting
|
||||
*
|
||||
* @param $label
|
||||
* @param $inputs
|
||||
* @param $name
|
||||
* @param $checked
|
||||
* @param $description
|
||||
*/
|
||||
public function do_radio($label, $inputs, $name, $checked, $description)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<th scope="row"><?= $label; ?></th>
|
||||
<td>
|
||||
<?php foreach ($inputs as $option => $option_label) : ?>
|
||||
<label>
|
||||
<input type="radio" <?= strpos($option_label, '(Pro)') !== false ? apply_filters($name . '_' . $option . '_setting_disabled', 'disabled') : ''; ?> class="<?= str_replace('_', '-', $name . '_' . $option); ?>" name="<?= $name; ?>" value="<?= $option; ?>" <?= $option == $checked ? 'checked="checked"' : ''; ?> />
|
||||
<?= $option_label; ?>
|
||||
</label>
|
||||
<br />
|
||||
<?php endforeach; ?>
|
||||
<p class="description">
|
||||
<?= $description . ' ' . $this->promo; ?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate select setting
|
||||
*
|
||||
* @param $label
|
||||
* @param $name
|
||||
* @param $options
|
||||
* @param $selected
|
||||
* @param $description
|
||||
* @param bool $update_required
|
||||
*/
|
||||
public function do_select($label, $name, $options, $selected, $description, $is_multiselect = false, $disabled = false)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<?= apply_filters($name . '_setting_label', $label); ?>
|
||||
</th>
|
||||
<td>
|
||||
<select name="<?= $name; ?><?= $is_multiselect ? '[]' : ''; ?>" class="<?= str_replace('_', '-', $name); ?>" <?= $is_multiselect ? 'size="8" multiple="multiple"' : ''; ?> <?= apply_filters($name . '_setting_disabled', $disabled) ? 'disabled' : ''; ?>>
|
||||
<?php
|
||||
$options = apply_filters($name . '_setting_options', $options);
|
||||
?>
|
||||
<?php foreach ($options as $option => $option_label) : ?>
|
||||
<?php
|
||||
if (is_array($selected)) {
|
||||
$is_selected = in_array($option, $selected);
|
||||
} else {
|
||||
$is_selected = $selected == $option;
|
||||
}
|
||||
?>
|
||||
<option value="<?= $option; ?>" <?= $is_selected ? 'selected="selected"' : ''; ?>><?= $option_label; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<p class="description">
|
||||
<?= apply_filters($name . '_setting_description', $description); ?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate number setting.
|
||||
*
|
||||
* @param $label
|
||||
* @param $name
|
||||
* @param $value
|
||||
* @param $description
|
||||
*/
|
||||
public function do_number($label, $name, $value, $description, $min = 0, $visible = true)
|
||||
{
|
||||
?>
|
||||
<tr valign="top" <?= $visible ? '' : 'style="display: none;"'; ?>>
|
||||
<th scope="row"><?= apply_filters($name . '_setting_label', $label); ?></th>
|
||||
<td>
|
||||
<input class="<?= str_replace('_', '-', $name); ?>" type="number" name="<?= $name; ?>" min="<?= $min; ?>" value="<?= $value; ?>" />
|
||||
<p class="description">
|
||||
<?= apply_filters($name . '_setting_description', $description); ?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate text setting.
|
||||
*
|
||||
* @param $label
|
||||
* @param $name
|
||||
* @param $placeholder
|
||||
* @param $value
|
||||
* @param string $description
|
||||
* @param bool $update_required
|
||||
*/
|
||||
public function do_text($label, $name, $placeholder, $value, $description = '', $disabled = false)
|
||||
{
|
||||
?>
|
||||
<tr class="<?= str_replace('_', '-', $name); ?>-row">
|
||||
<th scope="row"><?= apply_filters($name . '_setting_label', $label); ?></th>
|
||||
<td>
|
||||
<input <?= apply_filters($name . '_setting_disabled', $disabled) ? 'disabled' : ''; ?> class="<?= str_replace('_', '-', $name); ?>" type="text" name="<?= $name; ?>" placeholder="<?= $placeholder; ?>" value="<?= $value; ?>" />
|
||||
<p class="description">
|
||||
<?= apply_filters($name . 'setting_description', $description); ?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate checkbox setting.
|
||||
*
|
||||
* @param $label
|
||||
* @param $name
|
||||
* @param $checked
|
||||
* @param $description
|
||||
*/
|
||||
public function do_checkbox($label, $name, $checked, $description, $disabled = false)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<th scope="row"><?= apply_filters($name . '_setting_label', $label); ?></th>
|
||||
<td>
|
||||
<label for="<?= $name; ?>">
|
||||
<input id="<?= $name; ?>" type="checkbox" <?= apply_filters($name . '_setting_disabled', $disabled) ? 'disabled' : ''; ?> class="<?= str_replace('_', '-', $name); ?>" name="<?= $name; ?>" <?= $checked == "on" ? 'checked = "checked"' : ''; ?> />
|
||||
<?= apply_filters($name . '_setting_description', $description); ?>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
/* * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* ██████╗ ███╗ ███╗ ██████╗ ███████╗
|
||||
* ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
|
||||
* ██║ ██║██╔████╔██║██║ ███╗█████╗
|
||||
* ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
|
||||
* ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
|
||||
* ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
|
||||
*
|
||||
* @package : OMGF
|
||||
* @author : Daan van den Bergh
|
||||
* @copyright: (c) 2021 Daan van den Bergh
|
||||
* @url : https://daan.dev
|
||||
* * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class OMGF_Admin_Settings_Detection extends OMGF_Admin_Settings_Builder
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->title = __('Google Fonts Detection Settings', $this->plugin_text_domain);
|
||||
|
||||
// Open
|
||||
add_filter('omgf_detection_settings_content', [$this, 'do_title'], 10);
|
||||
add_filter('omgf_detection_settings_content', [$this, 'do_description'], 15);
|
||||
add_filter('omgf_detection_settings_content', [$this, 'do_before'], 20);
|
||||
|
||||
// Settings
|
||||
add_filter('omgf_detection_settings_content', [$this, 'do_process_google_fonts'], 30);
|
||||
add_filter('omgf_detection_settings_content', [$this, 'do_promo_advanced_processing'], 40);
|
||||
add_filter('omgf_detection_settings_content', [$this, 'do_promo_safe_mode'], 50);
|
||||
add_filter('omgf_detection_settings_content', [$this, 'do_promo_fonts_processing'], 60);
|
||||
add_filter('omgf_detection_settings_content', [$this, 'do_promo_process_resource_hints'], 70);
|
||||
|
||||
// Close
|
||||
add_filter('omgf_detection_settings_content', [$this, 'do_after'], 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Description
|
||||
*/
|
||||
public function do_description()
|
||||
{
|
||||
?>
|
||||
<p>
|
||||
<?= __('These settings affect OMGF\'s automatic detection mechanism and how it treats the Google Fonts your theme and plugins use. If you want to use OMGF to remove the Google Fonts your WordPress configuration currently uses, set <strong>Google Fonts Processing</strong> to Remove.', $this->plugin_text_domain); ?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_promo_fonts_processing()
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<th scope="row"><?= __('Google Fonts Processing (Pro)', $this->plugin_text_domain); ?></th>
|
||||
<td>
|
||||
<fieldset id="" class="scheme-list">
|
||||
<?php foreach ($this->fonts_processing_pro_options() as $name => $data) : ?>
|
||||
<?php
|
||||
$checked = defined(strtoupper($name)) ? constant(strtoupper($name)) : false;
|
||||
$disabled = apply_filters($name . '_setting_disabled', true) ? 'disabled' : '';
|
||||
?>
|
||||
<label for="<?= $name; ?>">
|
||||
<input type="checkbox" name="<?= $name; ?>" id="<?= $name; ?>" <?= $checked ? 'checked="checked"' : ''; ?> <?= $disabled; ?> /><?= $data['label']; ?>
|
||||
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</fieldset>
|
||||
<p class="description">
|
||||
<?= $this->promo; ?>
|
||||
</p>
|
||||
<ul>
|
||||
<?php foreach ($this->fonts_processing_pro_options() as $name => $data) : ?>
|
||||
<li><strong><?= $data['label']; ?></strong>: <?= $data['description']; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function fonts_processing_pro_options()
|
||||
{
|
||||
return [
|
||||
'omgf_pro_process_stylesheets' => [
|
||||
'label' => __('Process External Stylesheets', $this->plugin_text_domain),
|
||||
'description' => __('Process stylesheets loaded from <code>fonts.googleapis.com</code> or <code>fonts.gstatic.com</code>.', $this->plugin_text_domain)
|
||||
],
|
||||
'omgf_pro_process_stylesheet_imports' => [
|
||||
'label' => __('Process Stylesheet Imports', $this->plugin_text_domain),
|
||||
'description' => __('Scan stylesheets loaded by your theme and plugins for <code>@import</code> statements loading Google Fonts and process them.', $this->plugin_text_domain)
|
||||
],
|
||||
'omgf_pro_process_stylesheet_font_faces' => [
|
||||
'label' => __('Process Stylesheet Font Faces', $this->plugin_text_domain),
|
||||
'description' => __('Scan stylesheets loaded by your theme and plugins for <code>@font-face</code> statements loading Google Fonts and process them.', $this->plugin_text_domain)
|
||||
],
|
||||
'omgf_pro_process_inline_styles' => [
|
||||
'label' => __('Process Inline Styles', $this->plugin_text_domain),
|
||||
'description' => __('Process all inline <code>@font-face</code> and <code>@import</code> rules loading Google Fonts.', $this->plugin_text_domain)
|
||||
],
|
||||
'omgf_pro_process_webfont_loader' => [
|
||||
'label' => __('Process Webfont Loader', $this->plugin_text_domain),
|
||||
'description' => __('Process <code>webfont.js</code> libraries and the corresponding configuration defining which Google Fonts to load.', $this->plugin_text_domain)
|
||||
],
|
||||
'omgf_pro_process_early_access' => [
|
||||
'label' => __('Process Early Access', $this->plugin_text_domain),
|
||||
'description' => __('Process stylesheets loaded from <code>fonts.googleapis.com/earlyaccess</code> or <code>fonts.gstatic.com/ea</code>.', $this->plugin_text_domain)
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_promo_advanced_processing()
|
||||
{
|
||||
$this->do_checkbox(
|
||||
__('Advanced Processing (Pro)', $this->plugin_text_domain),
|
||||
'omgf_pro_advanced_processing',
|
||||
defined('OMGF_PRO_ADVANCED_PROCESSING') ? OMGF_PRO_ADVANCED_PROCESSING : false,
|
||||
__('By default, OMGF scans for Google Fonts which are registered/enqueued using the <code>wp_enqueue_scripts()</code> action in WordPress\' header (<code>wp_head()</code>). Enabling this option will process all Google Fonts throughout the entire document. This setting can be fine-tuned using the settings below.', $this->plugin_text_domain) . ' ' . $this->promo,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option for Safe Mode (Pro)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function do_promo_safe_mode()
|
||||
{
|
||||
$this->do_checkbox(
|
||||
__('Safe Mode (Pro)', $this->plugin_text_domain),
|
||||
'omgf_pro_safe_mode',
|
||||
defined('OMGF_PRO_SAFE_MODE') ? OMGF_PRO_SAFE_MODE : false,
|
||||
__('Enable Safe Mode if Advanced Processing (Pro) breaks styling of certain pages.', $this->plugin_text_domain) . ' ' . $this->promo,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add promo options for Process Resource Hints
|
||||
*/
|
||||
public function do_promo_process_resource_hints()
|
||||
{
|
||||
$this->do_checkbox(
|
||||
__('Remove Resource Hints (Pro)', $this->plugin_text_domain),
|
||||
'omgf_pro_process_resource_hints',
|
||||
defined('OMGF_PRO_PROCESS_RESOURCE_HINTS') ? OMGF_PRO_PROCESS_RESOURCE_HINTS : false,
|
||||
__('Remove all <code>link</code> elements with a <code>rel</code> attribute value of <code>dns-prefetch</code>, <code>preload</code> or <code>preconnect</code> pointing to <code>fonts.googleapis.com</code> or <code>fonts.gstatic.com</code>.', $this->plugin_text_domain) . ' ' . $this->promo,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_process_google_fonts()
|
||||
{
|
||||
$this->do_select(
|
||||
__('Google Fonts Processing', $this->plugin_text_domain),
|
||||
OMGF_Admin_Settings::OMGF_DETECTION_SETTING_FONT_PROCESSING,
|
||||
OMGF_Admin_Settings::OMGF_FONT_PROCESSING_OPTIONS,
|
||||
OMGF_FONT_PROCESSING,
|
||||
sprintf(__("Choose whether OMGF should (find, download and) <strong>replace</strong> all Google Fonts, or just <strong>remove</strong> them. Choosing Remove will force WordPress to fallback to system fonts.", $this->plugin_text_domain), OMGF_Admin_Settings::FFWP_WORDPRESS_PLUGINS_OMGF_PRO)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/* * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* ██████╗ ███╗ ███╗ ██████╗ ███████╗
|
||||
* ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
|
||||
* ██║ ██║██╔████╔██║██║ ███╗█████╗
|
||||
* ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
|
||||
* ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
|
||||
* ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
|
||||
*
|
||||
* @package : OMGF
|
||||
* @author : Daan van den Bergh
|
||||
* @copyright: (c) 2021 Daan van den Bergh
|
||||
* @url : https://daan.dev
|
||||
* * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class OMGF_Admin_Settings_Help extends OMGF_Admin_Settings_Builder
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->title = __('Help & Documentation', $this->plugin_text_domain);
|
||||
|
||||
// Title
|
||||
add_filter('omgf_help_content', [$this, 'do_title'], 10);
|
||||
|
||||
// Content
|
||||
add_filter('omgf_help_content', [$this, 'do_content'], 20);
|
||||
}
|
||||
|
||||
public function do_content()
|
||||
{
|
||||
$utmTags = '?utm_source=omgf&utm_medium=plugin&utm_campaign=support_tab';
|
||||
$tweetUrl = sprintf("https://twitter.com/intent/tweet?text=I+am+using+%s+to+speed+up+Google+Fonts+for+@WordPress!+Try+it+for+yourself:&via=Dan0sz&hashtags=GoogleFonts,WordPress,Pagespeed,Insights&url=%s", str_replace(' ', '+', apply_filters('omgf_settings_page_title', 'OMGF')), apply_filters('omgf_help_tab_plugin_url', 'https://wordpress.org/plugins/host-webfonts-local/'));
|
||||
?>
|
||||
<div class="welcome-panel">
|
||||
<div class="welcome-panel-content">
|
||||
<h2><?= sprintf(__('Thank you for using %s!', $this->plugin_text_domain), apply_filters('omgf_settings_page_title', 'OMGF')); ?></h2>
|
||||
<p class="about-description">
|
||||
<?= sprintf(__('Need help configuring %s? Please refer to the links below to get you started.', $this->plugin_text_domain), apply_filters('omgf_settings_page_title', 'OMGF')); ?>
|
||||
</p>
|
||||
<div class="welcome-panel-column-container">
|
||||
<div class="welcome-panel-column">
|
||||
<h3>
|
||||
<?php _e('Need Help?', $this->plugin_text_domain); ?>
|
||||
</h3>
|
||||
<ul>
|
||||
<li><a class="welcome-icon dashicons-controls-forward" target="_blank" href="<?= apply_filters('omgf_settings_help_quick_start', 'https://docs.ffw.press/article/7-quick-start'); ?>"><?= __('Quick Start Guide', $this->plugin_text_domain); ?></a></li>
|
||||
<li><a class="welcome-icon dashicons-text-page" target="_blank" href="<?= apply_filters('omgf_settings_help_user_manual', 'https://docs.ffw.press/category/4-omgf-pro'); ?>"><?= __('User Manual', $this->plugin_text_domain); ?></a></li>
|
||||
<li><a class="welcome-icon dashicons-editor-help" target="_blank" href="<?= apply_filters('omgf_settings_help_faq_link', 'https://docs.ffw.press/article/9-frequently-asked-question-faq'); ?>"><?= __('FAQ', $this->plugin_text_domain); ?></a></li>
|
||||
<li><a class="welcome-icon dashicons-sos" target="_blank" href="<?= apply_filters('omgf_settings_help_troubleshooting_link', 'https://docs.ffw.press/category/37-omgf-pro---troubleshooting'); ?>"><?= __('Troubleshooting Guide', $this->plugin_text_domain); ?></a></li>
|
||||
<li><a class="welcome-icon dashicons-email" target="_blank" href="<?= apply_filters('omgf_settings_help_support_link', 'https://docs.ffw.press/contact'); ?>"><?= __('Get Support', $this->plugin_text_domain); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="welcome-panel-column">
|
||||
<h3><?= sprintf(__('Support %s & Spread the Word!', $this->plugin_text_domain), apply_filters('omgf_settings_page_title', 'OMGF')); ?></h3>
|
||||
<ul>
|
||||
<li><a class="welcome-icon dashicons-star-filled" target="_blank" href="<?= apply_filters('omgf_help_tab_review_link', 'https://wordpress.org/support/plugin/host-webfonts-local/reviews/?rate=5#new-post'); ?>"><?= __('Write a 5-star Review or,', $this->plugin_text_domain); ?></a></li>
|
||||
<li><a class="welcome-icon dashicons-twitter" target="_blank" href="<?= $tweetUrl; ?>"><?= __('Tweet about it!', $this->plugin_text_domain); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="welcome-panel-column welcome-panel-last">
|
||||
<h3 class="signature"><?= __('Check out my other plugins', $this->plugin_text_domain); ?> @</h3>
|
||||
<p class="signature">
|
||||
<a target="_blank" title="<?= __('Visit FFW Press', $this->plugin_text_domain); ?>" href="https://ffw.press/wordpress-plugins/"><img class="signature-image" alt="<?= __('Visit FFW Press', $this->plugin_text_domain); ?>" src="https://ffw.press/wp-content/uploads/2021/01/logo-color-full@05x.png" /></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,387 @@
|
||||
<?php
|
||||
/* * * * * * * * * * * * * * * * * * * * *
|
||||
*
|
||||
* ██████╗ ███╗ ███╗ ██████╗ ███████╗
|
||||
* ██╔═══██╗████╗ ████║██╔════╝ ██╔════╝
|
||||
* ██║ ██║██╔████╔██║██║ ███╗█████╗
|
||||
* ██║ ██║██║╚██╔╝██║██║ ██║██╔══╝
|
||||
* ╚██████╔╝██║ ╚═╝ ██║╚██████╔╝██║
|
||||
* ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝
|
||||
*
|
||||
* @package : OMGF
|
||||
* @author : Daan van den Bergh
|
||||
* @copyright: (c) 2021 Daan van den Bergh
|
||||
* @url : https://daan.dev
|
||||
* * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class OMGF_Admin_Settings_Optimize extends OMGF_Admin_Settings_Builder
|
||||
{
|
||||
const FFW_PRESS_OMGF_AF_URL = 'https://ffw.press/wordpress/omgf-additional-fonts/';
|
||||
|
||||
/** @var array $optimized_fonts */
|
||||
private $optimized_fonts;
|
||||
|
||||
/**
|
||||
* OMGF_Admin_Settings_Optimize constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->title = __('Optimize Google Fonts', $this->plugin_text_domain);
|
||||
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_title'], 10);
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_description'], 15);
|
||||
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_before'], 20);
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_optimization_mode'], 30);
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_promo_combine_requests'], 40);
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_display_option'], 50);
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_promo_force_font_display'], 60);
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_promo_include_file_types'], 70);
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_promo_force_subsets'], 80);
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_after'], 100);
|
||||
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_optimize_fonts_container'], 200);
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_optimize_fonts_contents'], 250);
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'close_optimize_fonts_container'], 300);
|
||||
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_before'], 350);
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_optimize_edit_roles'], 375);
|
||||
add_filter('omgf_optimize_settings_content', [$this, 'do_after'], 400);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_description()
|
||||
{
|
||||
?>
|
||||
<p>
|
||||
<?= __('These settings affect the fonts OMGF downloads and the stylesheet it generates. If you\'re simply looking to replace your Google Fonts for locally hosted copies, the default settings should suffice.', $this->plugin_text_domain); ?>
|
||||
</p>
|
||||
<p>
|
||||
<?= sprintf(__('To install additional Google Fonts, an add-on is required, which can be downloaded <a href="%s" target="blank">here</a>.', $this->plugin_text_domain), self::FFW_PRESS_OMGF_AF_URL); ?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function do_optimization_mode()
|
||||
{
|
||||
$this->do_radio(
|
||||
__('Optimization Mode', $this->plugin_text_domain),
|
||||
OMGF_Admin_Settings::OMGF_OPTIMIZATION_MODE,
|
||||
OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_OPTIMIZATION_MODE,
|
||||
OMGF_OPTIMIZATION_MODE,
|
||||
__('<strong>Manual</strong> processing mode is best suited for configurations, which use a fixed number of fonts across the entire site. When in manual mode, the generated stylesheet is forced throughout the entire site. <strong>Automatic</strong> processing mode is best suited for configurations using e.g. page builders, which load different fonts on certain pages.', $this->plugin_text_domain)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_promo_combine_requests()
|
||||
{
|
||||
$this->do_checkbox(
|
||||
__('Combine & Dedupe (Pro)', $this->plugin_text_domain),
|
||||
'omgf_pro_combine_requests',
|
||||
defined('OMGF_PRO_COMBINE_REQUESTS') ? true : false,
|
||||
__('Combine and deduplicate multiple Google Fonts stylesheets into one stylesheet. This feature is always on in OMGF Pro.', $this->plugin_text_domain) . ' ' . $this->promo,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_display_option()
|
||||
{
|
||||
$this->do_select(
|
||||
__('Font-Display Option', $this->plugin_text_domain),
|
||||
OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_DISPLAY_OPTION,
|
||||
OMGF_Admin_Settings::OMGF_FONT_DISPLAY_OPTIONS,
|
||||
OMGF_DISPLAY_OPTION,
|
||||
__('Select which value to set the font-display attribute to. Defaults to Swap (recommended).', $this->plugin_text_domain)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force Font-Display Option Site Wide
|
||||
*/
|
||||
public function do_promo_force_font_display()
|
||||
{
|
||||
$this->do_checkbox(
|
||||
__('Force Font-Display Option Site Wide (Pro)', $this->plugin_text_domain),
|
||||
'omgf_pro_force_font_display',
|
||||
defined('OMGF_PRO_FORCE_FONT_DISPLAY') ? OMGF_PRO_FORCE_FONT_DISPLAY : false,
|
||||
__('Force the above <code>font-display</code> attribute on all <code>@font-face</code> statements to ensure all text is user-visible while webfonts and icon sets are loading.', $this->plugin_text_domain),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display WOFF2 Only
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function do_promo_include_file_types()
|
||||
{
|
||||
$this->do_select(
|
||||
__('Include File Types (Pro)', $this->plugin_text_domain),
|
||||
'omgf_pro_file_types',
|
||||
OMGF_Admin_Settings::OMGF_FILE_TYPES_OPTIONS,
|
||||
defined('OMGF_PRO_FILE_TYPES') ? OMGF_PRO_FILE_TYPES : [],
|
||||
__('Select which file types should be included in the stylesheet. Loading <strong>WOFF2</strong> files only will result in a smaller stylesheet, but will make the stylesheet slightly less Cross Browser compatible. Using <strong>WOFF</strong> and <strong>WOFF2</strong> together (default) accounts for +98% of browsers. Add <strong>EOT</strong> for IE 6-10 and <strong>TTF</strong> and <strong>SVG</strong> for legacy Android/iOS browsers. <em>Use CTRL + click to select multiple values</em>.', $this->plugin_text_domain) . ' ' . $this->promo,
|
||||
true,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_promo_force_subsets()
|
||||
{
|
||||
$this->do_select(
|
||||
__('Force Subsets (Pro)', $this->plugin_text_domain),
|
||||
'omgf_pro_force_subsets',
|
||||
OMGF_Admin_Settings::OMGF_FORCE_SUBSETS_OPTIONS,
|
||||
defined('OMGF_PRO_FORCE_SUBSETS') ? OMGF_PRO_FORCE_SUBSETS : [],
|
||||
__('If a theme or plugin loads subsets you don\'t need, use this option to force all Google Fonts to be loaded in the selected subsets. You can also use this option to force the loading of additional subsets, if a theme/plugin doesn\'t allow you to configure the loaded subsets. <em>Use CTRL + click to select multiple values</em>.', $this->plugin_text_domain) . ' ' . $this->promo,
|
||||
true,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_optimize_fonts_container()
|
||||
{
|
||||
?>
|
||||
<div class="omgf-optimize-fonts-container welcome-panel">
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_optimize_fonts_contents()
|
||||
{
|
||||
$this->optimized_fonts = OMGF::optimized_fonts();
|
||||
?>
|
||||
<span class="option-title"><?= __('Manage Optimized Fonts', $this->plugin_text_domain); ?></span>
|
||||
<?php if ($this->optimized_fonts) : ?>
|
||||
<?= $this->do_optimized_fonts_manager(); ?>
|
||||
<?php else : ?>
|
||||
<div class="omgf-optimize-fonts-description">
|
||||
<?php
|
||||
$this->do_manual_template();
|
||||
$this->do_automatic_template();
|
||||
?>
|
||||
</div>
|
||||
<?php endif;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function do_optimized_fonts_manager()
|
||||
{
|
||||
?>
|
||||
<div class="omgf-optimize-fonts-manage">
|
||||
<p>
|
||||
|
||||
</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<th><?= __('Style', $this->plugin_text_domain); ?></th>
|
||||
<th><?= __('Weight', $this->plugin_text_domain); ?></th>
|
||||
<th><?= __('Preload', $this->plugin_text_domain); ?><span class="dashicons dashicons-info tooltip"><span class="tooltip-text"><span class="inline-text"><?= __('Preload font files (before everything else) so they will be available as soon as they are required for the rendering of the page. Only use preload for font files that are used above the fold.', $this->plugin_text_domain); ?></span><img width="230" class="illustration" src="<?= plugin_dir_url(OMGF_PLUGIN_FILE) . 'assets/images/above-the-fold.png'; ?>" /></span></span></th>
|
||||
<th><?= __('Do not load', $this->plugin_text_domain); ?></th>
|
||||
<th><?= __('Fallback Font Stack (Pro)', $this->plugin_text_domain); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php
|
||||
$cache_handles = OMGF::cache_keys();
|
||||
?>
|
||||
<?php foreach ($this->optimized_fonts as $handle => $fonts) : ?>
|
||||
<?php
|
||||
if (!OMGF::get_cache_key($handle)) {
|
||||
$cache_handles[] = $handle;
|
||||
}
|
||||
?>
|
||||
<tbody class="stylesheet" id="<?= $handle; ?>">
|
||||
<tr>
|
||||
<th colspan="6"><?= sprintf(__('Stylesheet handle: %s', $this->plugin_text_domain), $handle); ?></th>
|
||||
</tr>
|
||||
<?php foreach ($fonts as $font) : ?>
|
||||
<?php if (!is_object($font) || count((array) $font->variants) <= 0) continue; ?>
|
||||
<?php
|
||||
$aka = in_array($font->id, OMGF_API_Download::OMGF_RENAMED_GOOGLE_FONTS) ? array_search($font->id, OMGF_API_Download::OMGF_RENAMED_GOOGLE_FONTS) : '';
|
||||
?>
|
||||
<tr class="font-family" data-id="<?= $handle . '-' . $font->id; ?>">
|
||||
<td colspan="5">
|
||||
<span class="family"><em><?= rawurldecode($font->family); ?><?= $aka ? ' (' . sprintf(__('formerly known as <strong>%s</strong>', $this->plugin_text_domain) . ')', ucfirst($aka)) : ''; ?></em></span> <span class="unload-mass-action">(<a href="#" class="unload-italics"><?= __('Unload italics', $this->plugin_text_domain); ?></a> <span class="dashicons dashicons-info tooltip"><span class="tooltip-text"><?= __('In most situations you can safely unload all Italic font styles. Modern browsers are capable of mimicking Italic font styles.', $this->plugin_text_domain); ?></span></span> | <a href="#" class="unload-all"><?= __('Unload all', $this->plugin_text_domain); ?></a> | <a href="#" class="load-all"><?= __('Load all', $this->plugin_text_domain); ?></a>)</span>
|
||||
</td>
|
||||
<td class="fallback-font-stack">
|
||||
<select data-handle="<?= $handle; ?>" <?= apply_filters('omgf_pro_fallback_font_stack_setting_disabled', true) ? 'disabled' : ''; ?> name="omgf_pro_fallback_font_stack[<?= $handle; ?>][<?= $font->id; ?>]">
|
||||
<option value=''><?= __('None (default)', $this->plugin_text_domain); ?></option>
|
||||
<?php foreach (OMGF_Admin_Settings::OMGF_FALLBACK_FONT_STACKS_OPTIONS as $value => $label) : ?>
|
||||
<option <?= defined('OMGF_PRO_FALLBACK_FONT_STACK') && isset(OMGF_PRO_FALLBACK_FONT_STACK[$handle][$font->id]) && OMGF_PRO_FALLBACK_FONT_STACK[$handle][$font->id] == $value ? 'selected' : ''; ?> value="<?= $value; ?>"><?= $label; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php foreach ($font->variants as $variant) : ?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<?php
|
||||
$preload = OMGF::preloaded_fonts()[$handle][$font->id][$variant->id] ?? '';
|
||||
$unload = OMGF::unloaded_fonts()[$handle][$font->id][$variant->id] ?? '';
|
||||
$class = $handle . '-' . $font->id . '-' . $variant->id;
|
||||
?>
|
||||
<td><?= $variant->fontStyle; ?></td>
|
||||
<td><?= $variant->fontWeight; ?></td>
|
||||
<td class="preload-<?= $class; ?>">
|
||||
<input data-handle="<?= $handle; ?>" data-font-id="<?= $handle . '-' . $font->id; ?>" autocomplete="off" type="checkbox" class="preload" name="<?= OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_PRELOAD_FONTS; ?>[<?= $handle; ?>][<?= $font->id; ?>][<?= $variant->id; ?>]" value="<?= $variant->id; ?>" <?= $preload ? 'checked="checked"' : ''; ?> <?= $unload ? 'disabled' : ''; ?> />
|
||||
</td>
|
||||
<td class="unload-<?= $class; ?>">
|
||||
<input data-handle="<?= $handle; ?>" data-font-id="<?= $handle . '-' . $font->id; ?>" autocomplete="off" type="checkbox" class="unload" name="<?= OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_UNLOAD_FONTS; ?>[<?= $handle; ?>][<?= $font->id; ?>][<?= $variant->id; ?>]" value="<?= $variant->id; ?>" <?= $unload ? 'checked="checked"' : ''; ?> <?= $preload ? 'disabled' : ''; ?> />
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<div class="omgf-optimize-fonts-tooltip">
|
||||
<p>
|
||||
<span class="dashicons-before dashicons-info-outline"></span>
|
||||
<?php if (OMGF_OPTIMIZATION_MODE == 'manual') : ?>
|
||||
<em><?= sprintf(__("This list is populated with all Google Fonts captured and downloaded from <strong>%s</strong>. Optimizations will be applied on every page using these fonts. If you want to optimize additional Google Fonts from other pages, switch to <strong>Automatic (Pro)</strong> and visit the pages containing the stylesheets you'd like to optimize. This list will automatically be populated with the captured fonts.", $this->plugin_text_domain), OMGF_MANUAL_OPTIMIZE_URL); ?></em>
|
||||
<?php else : ?>
|
||||
<?php $no_cache_param = '?omgf_optimize=' . substr(md5(microtime()), rand(0, 26), 5); ?>
|
||||
<em><?= sprintf(__("This list is automatically populated with Google Fonts captured throughout your entire site. Optimizations will be applied on every page using these fonts. <strong>Automatic</strong> mode might not work when a Full Page Cache plugin is activated. If this list is not being populated with Google Fonts, you could try to visit your frontend and append the following parameter to the URL: <strong>%s</strong>", $this->plugin_text_domain), $no_cache_param); ?></em>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
</div>
|
||||
<input type="hidden" name="<?= OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_OPTIMIZED_FONTS; ?>" value='<?= serialize($this->optimized_fonts); ?>' />
|
||||
<input type="hidden" name="<?= OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_MANUAL_OPTIMIZE_URL; ?>" value="<?= OMGF_MANUAL_OPTIMIZE_URL; ?>" />
|
||||
<input id="<?= OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_UNLOAD_STYLESHEETS; ?>" type="hidden" name="<?= OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_UNLOAD_STYLESHEETS; ?>" value="<?= OMGF_UNLOAD_STYLESHEETS; ?>" />
|
||||
<input id="<?= OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_CACHE_KEYS; ?>" type="hidden" name="<?= OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_CACHE_KEYS; ?>" value="<?= implode(',', $cache_handles); ?>" />
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_manual_template()
|
||||
{
|
||||
?>
|
||||
<div class="omgf-optimize-fonts-manual" <?= OMGF_OPTIMIZATION_MODE == 'manual' ? '' : 'style="display: none;"'; ?>>
|
||||
<p>
|
||||
<?= sprintf(__("You've chosen to <strong>optimize your Google Fonts manually</strong>. OMGF will <u>not</u> run automatically and will <strong>%s</strong> the requested Google Fonts throughout your website that were captured on the post/page you defined. A Cross-Browser compatible stylesheet will be generated for all requested Google Fonts.", $this->plugin_text_domain), OMGF_FONT_PROCESSING); ?>
|
||||
</p>
|
||||
<div class="omgf-optimize-fonts-pros">
|
||||
<h3>
|
||||
<span class="dashicons-before dashicons-yes"></span> <?= __('Pros:', $this->plugin_text_domain); ?>
|
||||
</h3>
|
||||
<ul>
|
||||
<li><?= __('A small initial performance boost, because no calls to OMGF\'s Download API are made in the frontend.', $this->plugin_text_domain); ?></li>
|
||||
<li><?= __('Force one stylesheet to be used throughout the site.', $this->plugin_text_domain); ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="omgf-optimize-fonts-cons">
|
||||
<h3>
|
||||
<span class="dashicons-before dashicons-no"></span> <?= __('Cons', $this->plugin_text_domain); ?>
|
||||
</h3>
|
||||
<ul>
|
||||
<li><?= __('A font that is only used on a few pages might be lost if one of those URLs isn\'t scanned for fonts.', $this->plugin_text_domain); ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
<p>
|
||||
<?= __('Enter the URL of the post/page you\'d like to scan for Google Fonts. The detected and optimized stylesheets will be applied on all pages where they\'re used.', $this->plugin_text_domain); ?>
|
||||
</p>
|
||||
<label for="<?= OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_MANUAL_OPTIMIZE_URL; ?>">
|
||||
<?= __('URL to Scan', $this->plugin_text_domain); ?>
|
||||
<input id="<?= OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_MANUAL_OPTIMIZE_URL; ?>" type="text" name="<?= OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_MANUAL_OPTIMIZE_URL; ?>" value="<?= OMGF_MANUAL_OPTIMIZE_URL; ?>" />
|
||||
</label>
|
||||
<div class="omgf-optimize-fonts-tooltip">
|
||||
<p>
|
||||
<span class="dashicons-before dashicons-info-outline"></span>
|
||||
<em><?= __('This section will be populated with all captured fonts, font styles and available options after saving changes.', $this->plugin_text_domain); ?></em>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_automatic_template()
|
||||
{
|
||||
?>
|
||||
<div class="omgf-optimize-fonts-automatic" <?= OMGF_OPTIMIZATION_MODE == 'auto' ? '' : 'style="display: none;"'; ?>>
|
||||
<p>
|
||||
<?= sprintf(__("You've chosen to <strong>optimize your Google Fonts automatically</strong>. OMGF will run silently in the background and <strong>%s</strong> all requested Google Fonts. If the captured stylesheet doesn't exist yet, a call is sent to OMGF's Download API to download the font files and generate a Cross-Browser compatible stylesheet.", $this->plugin_text_domain), OMGF_FONT_PROCESSING); ?>
|
||||
</p>
|
||||
<div class="omgf-optimize-fonts-pros">
|
||||
<h3>
|
||||
<span class="dashicons-before dashicons-yes"></span> <?= __('Pros:', $this->plugin_text_domain); ?>
|
||||
</h3>
|
||||
<ul>
|
||||
<li><?= __('No maintenance.', $this->plugin_text_domain); ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="omgf-optimize-fonts-cons">
|
||||
<h3>
|
||||
<span class="dashicons-before dashicons-no"></span> <?= __('Cons', $this->plugin_text_domain); ?>
|
||||
</h3>
|
||||
<ul>
|
||||
<li><?= __("The first time an unoptimized Google Fonts stylesheet is found, the API will be triggered in the frontend, which might cause the page to load slower than usual. All subsequent pageviews for that page (and all pages using that same stylesheet will load just as fast as when Manual mode is used.", $this->plugin_text_domain); ?></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="omgf-optimize-fonts-tooltip">
|
||||
<p>
|
||||
<span class="dashicons-before dashicons-info-outline"></span>
|
||||
<em><?= __("After saving your changes, this section will be populated with all captured fonts, font styles and available options as your site's frontend is visited by you or others. You will be able to manage your fonts at a later point.", $this->plugin_text_domain); ?></em>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function close_optimize_fonts_container()
|
||||
{
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function do_optimize_edit_roles()
|
||||
{
|
||||
$this->do_checkbox(
|
||||
__('Optimize Fonts For Editors/Administrators?', $this->plugin_text_domain),
|
||||
OMGF_Admin_Settings::OMGF_OPTIMIZE_SETTING_OPTIMIZE_EDIT_ROLES,
|
||||
OMGF_OPTIMIZE_EDIT_ROLES,
|
||||
__('Should only be disabled while debugging/testing, e.g. using a page builder or switching themes.', $this->plugin_text_domain)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user