File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,3 +56,8 @@ Make a GET request to your site's URL with the query parameter `?wpe-cache-flush
5656```
5757GET http://example.com/?wpe-cache-flush=$private_key
5858```
59+
60+ You can also call the flush function directly from your code via
61+ ``` php
62+ \A7\WPE_Cache_Flush\cache_flush()
63+ ```
Original file line number Diff line number Diff line change 33 "description" : " Programmatically flush the WP Engine Cache" ,
44 "type" : " library" ,
55 "license" : " UNLICENSE" ,
6- "version" : " 0.2.3 " ,
6+ "version" : " 0.3.0 " ,
77 "authors" : [
88 {
99 "name" : " A7" ,
Original file line number Diff line number Diff line change @@ -42,9 +42,26 @@ function get_flush_token() {
4242 return ;
4343 }
4444
45+ $ error = cache_flush ();
46+
47+ header ( "Content-Type: text/plain " );
48+ header ( "X-WPE-Host: " . gethostname () . " " . $ _SERVER ['SERVER_ADDR ' ] );
49+
50+ echo "All Caches were purged! " ;
51+ echo $ error ;
52+
53+ exit ( 0 );
54+ } );
55+
56+ /**
57+ * Allow cache flushing to be called independently of web hook
58+ *
59+ * @return string|bool
60+ */
61+ function cache_flush () {
4562 // Don't cause a fatal if there is no WpeCommon class
4663 if ( ! class_exists ( 'WpeCommon ' ) ) {
47- return ;
64+ return false ;
4865 }
4966
5067 if ( function_exists ( 'WpeCommon::purge_memcached ' ) ) {
@@ -72,11 +89,5 @@ function get_flush_token() {
7289 }
7390 }
7491
75- header ( "Content-Type: text/plain " );
76- header ( "X-WPE-Host: " . gethostname () . " " . $ _SERVER ['SERVER_ADDR ' ] );
77-
78- echo "All Caches were purged! " ;
79- echo $ error ;
80-
81- exit ( 0 );
82- } );
92+ return $ error ;
93+ }
You can’t perform that action at this time.
0 commit comments