| @@ -6,9 +6,9 @@ | ||
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | 8 | * Admin page slug. |
| 9 | 9 | */ |
| 10 | - const PAGE_SLUG = 'flywp'; | |
| 10 | + public const PAGE_SLUG = 'flywp'; | |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | 13 | * Screen name. |
| 14 | 14 | * |
| @@ -13,11 +13,12 @@ | ||
| 13 | 13 | * Screen name. |
| 14 | 14 | * |
| 15 | 15 | * @var string |
| 16 | 16 | */ |
| 17 | - const SCREEN_NAME = 'dashboard_page_flywp'; | |
| 17 | + public const SCREEN_NAME = 'dashboard_page_flywp'; | |
| 18 | 18 | |
| 19 | 19 | public $fastcgi = null; |
| 20 | + public $litespeed = null; | |
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Admin constructor. |
| 23 | 24 | */ |
| @@ -23,14 +24,16 @@ | ||
| 23 | 24 | */ |
| 24 | 25 | public function __construct() { |
| 25 | 26 | add_action( 'admin_menu', [ $this, 'register_admin_page' ] ); |
| 26 | 27 | |
| 27 | - $this->fastcgi = new Admin\Fastcgi_Cache(); | |
| 28 | + $this->fastcgi = new Admin\Fastcgi_Cache(); | |
| 29 | + $this->litespeed = new Admin\Litespeed(); | |
| 28 | 30 | |
| 29 | 31 | new Admin\Adminbar(); |
| 30 | 32 | new Admin\Opcache(); |
| 31 | 33 | new Admin\Plugins(); |
| 32 | 34 | new Admin\Email(); |
| 35 | + new Admin\Optimizations(); | |
| 33 | 36 | } |
| 34 | 37 | |
| 35 | 38 | /** |
| 36 | 39 | * Register admin page. |
| @@ -40,14 +43,14 @@ | ||
| 40 | 43 | __( 'FlyWP', 'flywp' ), |
| 41 | 44 | __( 'FlyWP', 'flywp' ), |
| 42 | 45 | 'manage_options', |
| 43 | 46 | self::PAGE_SLUG, |
| 44 | - [$this, 'render_admin_page'] | |
| 47 | + [ $this, 'render_admin_page' ] | |
| 45 | 48 | ); |
| 46 | 49 | |
| 47 | - add_action( "admin_print_styles-{$hook}", [$this, 'enqueue_styles'] ); | |
| 48 | - add_action( "admin_print_scripts-{$hook}", [$this, 'enqueue_js'] ); | |
| 49 | - add_filter( 'removable_query_args', [$this, 'removable_query_args'] ); | |
| 50 | + add_action( "admin_print_styles-{$hook}", [ $this, 'enqueue_styles' ] ); | |
| 51 | + add_action( "admin_print_scripts-{$hook}", [ $this, 'enqueue_js' ] ); | |
| 52 | + add_filter( 'removable_query_args', [ $this, 'removable_query_args' ] ); | |
| 50 | 53 | } |
| 51 | 54 | |
| 52 | 55 | /** |
| 53 | 56 | * Get admin page url. |
| @@ -85,9 +88,9 @@ | ||
| 85 | 88 | */ |
| 86 | 89 | public function enqueue_js() { |
| 87 | 90 | $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 88 | 91 | |
| 89 | - wp_enqueue_script( 'flywp-admin-js', FLYWP_PLUGIN_URL . '/assets/js/admin' . $min . '.js', ['jquery'], FLYWP_VERSION, true ); | |
| 92 | + wp_enqueue_script( 'flywp-admin-js', FLYWP_PLUGIN_URL . '/assets/js/admin' . $min . '.js', [ 'jquery' ], FLYWP_VERSION, true ); | |
| 90 | 93 | } |
| 91 | 94 | |
| 92 | 95 | /** |
| 93 | 96 | * Render admin page. |
| @@ -93,15 +96,18 @@ | ||
| 93 | 96 | * Render admin page. |
| 94 | 97 | */ |
| 95 | 98 | public function render_admin_page() { |
| 96 | 99 | $tabs = [ |
| 97 | - 'cache' => __( 'Caching', 'flywp' ), | |
| 98 | - 'email' => __( 'Email', 'flywp' ), | |
| 100 | + 'cache' => __( 'Caching', 'flywp' ), | |
| 101 | + 'email' => __( 'Email', 'flywp' ), | |
| 102 | + 'optimizations' => __( 'Optimizations', 'flywp' ), | |
| 99 | 103 | ]; |
| 100 | 104 | |
| 101 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $tabs ) ? $_GET['tab'] : 'cache'; | |
| 102 | - $site_info = $this->fetch_site_info(); | |
| 103 | - $app_site_url = $this->get_site_url( $site_info ); | |
| 105 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 106 | + $tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : ''; | |
| 107 | + $active_tab = array_key_exists( $tab, $tabs ) ? $tab : 'cache'; | |
| 108 | + $site_info = $this->fetch_site_info(); | |
| 109 | + $app_site_url = $this->get_site_url( $site_info ); | |
| 104 | 110 | |
| 105 | 111 | include FLYWP_PLUGIN_DIR . '/views/admin.php'; |
| 106 | 112 | } |
| 107 | 113 | |
| @@ -113,9 +119,9 @@ | ||
| 113 | 119 | private function fetch_site_info() { |
| 114 | 120 | $transient_key = 'flywp_site_info'; |
| 115 | 121 | $site_info = get_transient( $transient_key ); |
| 116 | 122 | |
| 117 | - if ( false === $site_info ) { | |
| 123 | + if ( ! $site_info ) { | |
| 118 | 124 | $site_info = flywp()->flyapi->site_info(); |
| 119 | 125 | |
| 120 | 126 | if ( isset( $site_info['error'] ) ) { |
| 121 | 127 | return false; |
| @@ -134,15 +140,14 @@ | ||
| 134 | 140 | * |
| 135 | 141 | * @return string |
| 136 | 142 | */ |
| 137 | 143 | private function get_site_url( $info ) { |
| 138 | - if ( false === $info ) { | |
| 144 | + if ( ! $info ) { | |
| 139 | 145 | return 'https://app.flywp.com'; |
| 140 | 146 | } |
| 141 | 147 | |
| 142 | 148 | return sprintf( |
| 143 | - 'https://app.flywp.com/servers/%d/sites/%d', | |
| 144 | - $info['server_id'], | |
| 149 | + 'https://app.flywp.com/site/%d', | |
| 145 | 150 | $info['id'] |
| 146 | 151 | ); |
| 147 | 152 | } |
| 148 | 153 | } |