| @@ -3,95 +3,8 @@ | ||
| 3 | 3 | namespace FlyWP; |
| 4 | 4 | |
| 5 | 5 | class Admin { |
| 6 | 6 | |
| 7 | - /** | |
| 8 | - * Admin page slug. | |
| 9 | - */ | |
| 10 | - const PAGE_SLUG = 'flywp'; | |
| 11 | - | |
| 12 | - /** | |
| 13 | - * Screen name. | |
| 14 | - * | |
| 15 | - * @var string | |
| 16 | - */ | |
| 17 | - const SCREEN_NAME = 'dashboard_page_flywp'; | |
| 18 | - | |
| 19 | - public $fastcgi = null; | |
| 20 | - | |
| 21 | - /** | |
| 22 | - * Admin constructor. | |
| 23 | - */ | |
| 24 | 7 | public function __construct() { |
| 25 | - add_action( 'admin_menu', [ $this, 'register_admin_page' ] ); | |
| 26 | - | |
| 27 | - $this->fastcgi = new Admin\Fastcgi_Cache(); | |
| 28 | - | |
| 29 | - new Admin\Adminbar(); | |
| 30 | - new Admin\Opcache(); | |
| 31 | - new Admin\Plugins(); | |
| 32 | - } | |
| 33 | - | |
| 34 | - /** | |
| 35 | - * Register admin page. | |
| 36 | - */ | |
| 37 | - public function register_admin_page() { | |
| 38 | - $hook = add_dashboard_page( | |
| 39 | - __( 'FlyWP', 'flywp' ), | |
| 40 | - __( 'FlyWP', 'flywp' ), | |
| 41 | - 'manage_options', | |
| 42 | - self::PAGE_SLUG, | |
| 43 | - [ $this, 'render_admin_page' ] | |
| 44 | - ); | |
| 45 | - | |
| 46 | - add_action( "admin_print_styles-{$hook}", [ $this, 'enqueue_styles' ] ); | |
| 47 | - add_action( "admin_print_scripts-{$hook}", [ $this, 'enqueue_js' ] ); | |
| 48 | - add_filter( 'removable_query_args', [ $this, 'removable_query_args' ] ); | |
| 49 | - } | |
| 50 | - | |
| 51 | - /** | |
| 52 | - * Get admin page url. | |
| 53 | - * | |
| 54 | - * @return string | |
| 55 | - */ | |
| 56 | - public function page_url() { | |
| 57 | - return admin_url( 'index.php?page=' . self::PAGE_SLUG ); | |
| 58 | - } | |
| 59 | - | |
| 60 | - /** | |
| 61 | - * Add query args to removable query args. | |
| 62 | - * | |
| 63 | - * @param array $args | |
| 64 | - * | |
| 65 | - * @return array | |
| 66 | - */ | |
| 67 | - public function removable_query_args( $args ) { | |
| 68 | - $args[] = 'fly-notice'; | |
| 69 | - | |
| 70 | - return $args; | |
| 71 | - } | |
| 72 | - | |
| 73 | - /** | |
| 74 | - * Enqueue admin styles. | |
| 75 | - */ | |
| 76 | - public function enqueue_styles() { | |
| 77 | - $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 78 | - | |
| 79 | - wp_enqueue_style( 'flywp-admin-styles', FLYWP_PLUGIN_URL . '/assets/css/app' . $min . '.css', [], FLYWP_VERSION ); | |
| 80 | - } | |
| 81 | - | |
| 82 | - /** | |
| 83 | - * Enqueue admin scripts. | |
| 84 | - */ | |
| 85 | - public function enqueue_js() { | |
| 86 | - $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 87 | - | |
| 88 | - wp_enqueue_script( 'flywp-admin-js', FLYWP_PLUGIN_URL . '/assets/js/admin' . $min . '.js', [ 'jquery' ], FLYWP_VERSION, true ); | |
| 89 | - } | |
| 90 | - | |
| 91 | - /** | |
| 92 | - * Render admin page. | |
| 93 | - */ | |
| 94 | - public function render_admin_page() { | |
| 95 | - include FLYWP_PLUGIN_DIR . '/views/admin.php'; | |
| 8 | + // code | |
| 96 | 9 | } |
| 97 | 10 | } |