| Server IP : 37.27.51.148 / Your IP : 216.73.217.84 Web Server : nginx/1.14.1 System : Linux libra 4.18.0-553.51.1.el8_10.x86_64 #1 SMP Wed Apr 30 20:24:04 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.31 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/html/wp-content/plugins/wp-rocket/inc/Engine/Media/PreloadFonts/Admin/ |
Upload File : |
<?php
namespace WP_Rocket\Engine\Media\PreloadFonts\Admin;
use WP_Rocket\Event_Management\Subscriber_Interface;
use WP_Rocket\Engine\Media\PreloadFonts\Admin\Settings;
/**
* Preload Fonts admin subscriber
*
* @since 3.19
*/
class Subscriber implements Subscriber_Interface {
/**
* Settings instance
*
* @var Settings
*/
private $settings;
/**
* Creates an instance of the object.
*
* @param Settings $settings Settings instance.
*/
public function __construct( Settings $settings ) {
$this->settings = $settings;
}
/**
* Returns an array of events this subscriber listens to
*
* @return array[]
*/
public static function get_subscribed_events(): array {
return [
'wp_rocket_upgrade' => [ 'maybe_enable_auto_preload_fonts', 9, 2 ],
];
}
/**
* Enables the auto preload fonts option if the old preload fonts option is not empty.
*
* This function checks the value of the `preload_fonts` option.
* If it contains a non-empty value, it updates the `auto_preload_fonts` option to `true`.
* This is useful for ensuring that automatic font preloading is enabled based on legacy settings.
*
* @param string $new_version New plugin version.
* @param string $old_version Previous plugin version.
*
* @return void
*/
public function maybe_enable_auto_preload_fonts( $new_version, $old_version ): void {
if ( version_compare( $old_version, '3.19', '>' ) ) {
return;
}
$this->settings->maybe_enable_auto_preload_fonts();
}
}