@@ -98,9 +98,13 @@ public function purge( $zone_id, $args = 'all' ) {
9898
9999 $ endpoint = $ this ->end_point . '/zones/ ' . $ zone_id . '/purge_cache ' ;
100100
101- $ result = $ this ->remote_request ( $ endpoint , 'DELETE ' , $ data );
101+ $ result = $ this ->remote_request ( $ endpoint , 'POST ' , $ data );
102102
103- return $ result ;
103+ if ( ! empty ( $ result ['success ' ] ) ) {
104+ return boolval ( $ result ['success ' ] );
105+ }
106+
107+ return false ;
104108 }
105109
106110 /**
@@ -110,7 +114,7 @@ public function purge( $zone_id, $args = 'all' ) {
110114 * @param string $type req type
111115 * @param array $data data
112116 *
113- * @return mixed|string
117+ * @return mixed|array
114118 */
115119 private function remote_request ( $ url , $ type = 'GET ' , $ data = array () ) {
116120 $ args = array (
@@ -135,11 +139,9 @@ private function remote_request( $url, $type = 'GET', $data = array() ) {
135139
136140 $ response = wp_remote_request ( $ url , $ args );
137141
138- if ( is_wp_error ( $ response ) ) {
139- return $ response ->get_error_message ();
140- } else {
141- return json_decode ( wp_remote_retrieve_body ( $ response ) );
142- }
142+ \PoweredCache \Utils \log ( sprintf ( 'Cloudflare API Response: %s ' , print_r ( wp_remote_retrieve_body ( $ response ), true ) ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
143+
144+ return json_decode ( wp_remote_retrieve_body ( $ response ), true );
143145 }
144146
145147 /**
0 commit comments