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