PluginProbe
FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel / 1.0
FlyWP Helper – Page Cache, Page Optimization, Emails for FlyWP Server Control Panel v1.0
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
← All changes | includes/Admin.php +56 -5 0.3.41.0 View file →
@@ -28,8 +28,9 @@
28 28
29 29 new Admin\Adminbar();
30 30 new Admin\Opcache();
31 31 new Admin\Plugins();
32 + new Admin\Email();
32 33 }
33 34
34 35 /**
35 36 * Register admin page.
@@ -39,14 +40,14 @@
39 40 __( 'FlyWP', 'flywp' ),
40 41 __( 'FlyWP', 'flywp' ),
41 42 'manage_options',
42 43 self::PAGE_SLUG,
43 - [ $this, 'render_admin_page' ]
44 + [$this, 'render_admin_page']
44 45 );
45 46
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' ] );
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'] );
49 50 }
50 51
51 52 /**
52 53 * Get admin page url.
@@ -84,9 +85,9 @@
84 85 */
85 86 public function enqueue_js() {
86 87 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
87 88
88 - 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 );
89 90 }
90 91
91 92 /**
92 93 * Render admin page.
@@ -91,7 +92,57 @@
91 92 /**
92 93 * Render admin page.
93 94 */
94 95 public function render_admin_page() {
96 + $tabs = [
97 + 'cache' => __( 'Caching', 'flywp' ),
98 + 'email' => __( 'Email', 'flywp' ),
99 + ];
100 +
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 );
104 +
95 105 include FLYWP_PLUGIN_DIR . '/views/admin.php';
106 + }
107 +
108 + /**
109 + * Fetch site info.
110 + *
111 + * @return array|false
112 + */
113 + private function fetch_site_info() {
114 + $transient_key = 'flywp_site_info';
115 + $site_info = get_transient( $transient_key );
116 +
117 + if ( false === $site_info ) {
118 + $site_info = flywp()->flyapi->site_info();
119 +
120 + if ( isset( $site_info['error'] ) ) {
121 + return false;
122 + }
123 +
124 + set_transient( $transient_key, $site_info, DAY_IN_SECONDS );
125 + }
126 +
127 + return $site_info;
128 + }
129 +
130 + /**
131 + * Get site URL.
132 + *
133 + * @param array|false $info
134 + *
135 + * @return string
136 + */
137 + private function get_site_url( $info ) {
138 + if ( false === $info ) {
139 + return 'https://app.flywp.com';
140 + }
141 +
142 + return sprintf(
143 + 'https://app.flywp.com/servers/%d/sites/%d',
144 + $info['server_id'],
145 + $info['id']
146 + );
96 147 }
97 148 }