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

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