PluginProbe
FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel / 0.3
FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel v0.3
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 / Admin.php

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

100 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 Admin {
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 = 'tools_page_flywp';
18
19 public $fastcgi = null;
20
21 /**
22 * Admin constructor.
23 */
24 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_submenu_page(
39 'tools.php',
40 __( 'FlyWP', 'flywp' ),
41 __( 'FlyWP', 'flywp' ),
42 'manage_options',
43 self::PAGE_SLUG,
44 [ $this, 'render_admin_page' ]
45 );
46
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 }
51
52 /**
53 * Get admin page url.
54 *
55 * @return string
56 */
57 public function page_url() {
58 return admin_url( 'tools.php?page=' . self::PAGE_SLUG );
59 }
60
61 /**
62 * Add query args to removable query args.
63 *
64 * @param array $args
65 *
66 * @return array
67 */
68 public function removable_query_args( $args ) {
69 $args[] = 'fly-notice';
70
71 return $args;
72 }
73
74 /**
75 * Enqueue admin styles.
76 */
77 public function enqueue_styles() {
78 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
79
80 wp_enqueue_style( 'flywp-admin-styles', FLYWP_PLUGIN_URL . '/assets/css/app' . $min . '.css', [], FLYWP_VERSION );
81 }
82
83 /**
84 * Enqueue admin scripts.
85 */
86 public function enqueue_js() {
87 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
88
89 wp_enqueue_script( 'flywp-chart', FLYWP_PLUGIN_URL . '/assets/js/chart.min.js', [], FLYWP_VERSION, true );
90 wp_enqueue_script( 'flywp-admin-js', FLYWP_PLUGIN_URL . '/assets/js/admin' . $min . '.js', [ 'jquery', 'flywp-chart' ], FLYWP_VERSION, true );
91 }
92
93 /**
94 * Render admin page.
95 */
96 public function render_admin_page() {
97 include FLYWP_PLUGIN_DIR . '/views/admin.php';
98 }
99 }
100