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
← All changes | includes/Admin/Fastcgi_Cache.php +23 -11 0.3.40.3 View file →
@@ -2,8 +2,9 @@
2 2
3 3 namespace FlyWP\Admin;
4 4
5 5 use FlyWP\Admin;
6 +use FlyWP\Helper;
6 7
7 8 class Fastcgi_Cache {
8 9
9 10 /**
@@ -15,8 +16,23 @@
15 16 add_action( 'load-' . Admin::SCREEN_NAME, [ $this, 'handle_enable_disable' ] );
16 17 }
17 18
18 19 /**
20 + * FastCGI cache purge url.
21 + *
22 + * @return string
23 + */
24 + public function purge_cache_url() {
25 + return wp_nonce_url(
26 + add_query_arg(
27 + [ 'flywp-action' => 'purge-fastcgi-cache' ],
28 + flywp()->admin->page_url()
29 + ),
30 + 'fly-fastcgi-purge-cache'
31 + );
32 + }
33 +
34 + /**
19 35 * Get enable/disable url.
20 36 *
21 37 * @param string $action
22 38 *
@@ -52,17 +68,11 @@
52 68 if ( ! current_user_can( 'manage_options' ) ) {
53 69 return;
54 70 }
55 71
56 - $page_id = isset( $_GET['page_id'] ) ? absint( $_GET['page_id'] ) : 0;
72 + flywp()->fastcgi->clear_cache();
57 73
58 - if ( $page_id ) {
59 - flywp()->fastcgi->purge_cache_by_url( get_permalink( $page_id ) );
60 - } else {
61 - flywp()->fastcgi->clear_cache();
62 - }
63 -
64 - wp_safe_redirect( admin_url( 'index.php?page=flywp&fly-notice=fastcgi-purged' ) );
74 + wp_safe_redirect( admin_url( 'tools.php?page=flywp&fly-notice=fastcgi-purged' ) );
65 75 exit;
66 76 }
67 77
68 78 /**
@@ -99,9 +109,9 @@
99 109 $settings = array_merge( $old_settings, $settings );
100 110
101 111 update_option( flywp()->fastcgi::SETTINGS_KEY, $settings );
102 112
103 - wp_safe_redirect( admin_url( 'index.php?page=flywp&fly-notice=fastcgi-saved' ) );
113 + wp_safe_redirect( admin_url( 'tools.php?page=flywp&fly-notice=fastcgi-saved' ) );
104 114 exit;
105 115 }
106 116
107 117 /**
@@ -128,12 +138,14 @@
128 138 $settings = flywp()->fastcgi->settings();
129 139 $settings['enabled'] = $type === 'enable' ? true : false;
130 140 $notice = $type === 'enable' ? 'fastcgi-enabled' : 'fastcgi-disabled';
131 141
132 - flywp()->flyapi->cache_toggle( $type );
142 + // Toggle cache in the API
143 + $reponse = flywp()->flyapi->cache_toggle( $type );
144 + // Helper::dd( $reponse );
133 145
134 146 update_option( flywp()->fastcgi::SETTINGS_KEY, $settings );
135 147
136 - wp_safe_redirect( admin_url( 'index.php?page=flywp&fly-notice=' . $notice ) );
148 + wp_safe_redirect( admin_url( 'tools.php?page=flywp&fly-notice=' . $notice ) );
137 149 exit;
138 150 }
139 151 }