Subscriber.php
1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace WP_Rocket\Engine\Optimization\GoogleFonts\Admin;
use WP_Rocket\Event_Management\Subscriber_Interface;
class Subscriber implements Subscriber_Interface {
/**
* Google Fonts Settings instance
*
* @var Settings
*/
private $settings;
/**
* Instantiate the class
*
* @param Settings $settings Google Fonts Settings instance.
*/
public function __construct( Settings $settings ) {
$this->settings = $settings;
}
/**
* Return an array of events that this subscriber wants to listen to.
*
* @since 3.7
*
* @return array
*/
public static function get_subscribed_events() {
return [
'rocket_settings_tools_content' => 'display_google_fonts_enabler',
'wp_ajax_rocket_enable_google_fonts' => 'enable_google_fonts',
];
}
/**
* Displays the Google Fonts Optimization section in the tools tab
*
* @since 3.7
*
* @return void
*/
public function display_google_fonts_enabler() {
$this->settings->display_google_fonts_enabler();
}
/**
* Callback method for the AJAX request to enable Google Fonts Optimization
*
* @since 3.7
*
* @return void
*/
public function enable_google_fonts() {
$this->settings->enable_google_fonts();
}
}