PluginProbe
FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel / 1.2
FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel v1.2
1.7.1 1.7.0 1.6.0 1.5.2 trunk 0.1 0.2.0 0.2.1 0.3 0.3.1 0.3.2 0.3.3 0.3.4 0.4 0.4.1 0.4.2 0.4.3 1.0 1.1 1.2 1.3.1 1.4.0 1.4.1 1.5.0 1.5.1 All 26 releases
flywp / includes / Optimizations.php

Optimizations.php in FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel 1.2, at includes/Optimizations.php

97 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FlyWP;
4
5 class Optimizations {
6
7 const OPTION_KEY = 'flywp_optimizations';
8
9 /**
10 * Class constructor
11 *
12 * @return void
13 */
14 public function __construct() {
15 if ( ! $this->enabled() ) {
16 return;
17 }
18
19 new Optimizations\Admin( $this );
20 new Optimizations\Header( $this );
21 new Optimizations\General( $this );
22 }
23
24 /**
25 * Check if optimizations are enabled.
26 *
27 * @return bool
28 */
29 public function enabled() {
30 return $this->get_option( 'enabled' ) === true;
31 }
32
33 /**
34 * Check if a feature is enabled.
35 *
36 * @param string $feature feature name
37 * @param string $group group name
38 *
39 * @return bool
40 */
41 public function feature_enabled( $feature, $group ) {
42 $value = $this->get_option( $group );
43
44 return $value[ $feature ] ?? false;
45 }
46
47 /**
48 * Get option.
49 *
50 * @param string $key option key
51 * @param mixed $default default value
52 *
53 * @return mixed
54 */
55 public function get_option( $key, $default = null ) {
56 $options = $this->get_options();
57
58 return $options[ $key ] ?? $default;
59 }
60
61 /**
62 * Get options.
63 *
64 * @return array
65 */
66 public function get_options() {
67 $options = get_option( self::OPTION_KEY, [
68 'enabled' => true,
69 'general' => [
70 'emoji' => true,
71 'oembed' => true,
72 'self_ping' => true,
73 'comments' => false,
74 'jquery_migrate' => true,
75 'clean_nav_menu' => true,
76 'rss_feed' => false,
77 'xmlrpc' => true,
78 ],
79 'admin' => [
80 'wp_logo' => true,
81 'login_logo' => true,
82 'dashboard_widgets' => true,
83 ],
84 'header' => [
85 'generator' => true,
86 'rsd_link' => true,
87 'feed_links' => true,
88 'rest_api' => true,
89 'shortlink' => true,
90 'oembed' => true,
91 ],
92 ] );
93
94 return apply_filters( 'fly_helper_optimizations_options', $options );
95 }
96 }
97