| @@ -3,17 +3,18 @@ | ||
| 3 | 3 | |
| 4 | 4 | $status = sanitize_text_field($request->get_param('status')); |
| 5 | 5 | $key = sanitize_text_field($request->get_param('key')); |
| 6 | 6 | $html = base64_decode($request->get_param('html')); |
| 7 | -$slug = sanitize_text_field($request->get_param('page_slug')); | |
| 7 | +$slug = $request->get_param('page_slug'); | |
| 8 | 8 | |
| 9 | 9 | if ($status == 'success' && !empty($request->get_param('html'))) { |
| 10 | + global $berq_log; | |
| 10 | 11 | |
| 11 | 12 | // Allow other plugins to modify cache html |
| 12 | 13 | $html = apply_filters( 'berqwp_cache_buffer', $html ); |
| 13 | 14 | |
| 14 | 15 | // Define the cache directory |
| 15 | - $cache_directory = optifer_cache . '/html/'; | |
| 16 | + $cache_directory = bwp_get_cache_dir(); | |
| 16 | 17 | |
| 17 | 18 | // Create the cache directory if it doesn't exist |
| 18 | 19 | if (!file_exists($cache_directory)) { |
| 19 | 20 | mkdir($cache_directory, 0755, true); |
| @@ -19,8 +20,13 @@ | ||
| 19 | 20 | mkdir($cache_directory, 0755, true); |
| 20 | 21 | } |
| 21 | 22 | |
| 22 | 23 | $cache_file = $cache_directory . md5($slug) . '.html'; |
| 24 | + | |
| 25 | + if ($html) { | |
| 26 | + $berq_log->info("Empty html cache: $page_url"); | |
| 27 | + exit; | |
| 28 | + } | |
| 23 | 29 | |
| 24 | 30 | // update_option( md5($slug), $key ); |
| 25 | 31 | file_put_contents($cache_file, $html); |
| 26 | 32 | |
| @@ -32,10 +38,16 @@ | ||
| 32 | 38 | |
| 33 | 39 | |
| 34 | 40 | do_action('berqwp_stored_page_cache', $slug); |
| 35 | 41 | |
| 36 | - global $berq_log; | |
| 37 | 42 | $berq_log->info("Stored cache for $slug"); |
| 43 | + | |
| 44 | + // Cache is stored which means connection is stable | |
| 45 | + // Delete connection test error transient | |
| 46 | + $check_connection = bwp_check_connection(); | |
| 47 | + if ( $check_connection['status'] == 'error' ) { | |
| 48 | + delete_transient('berqwp_connection_status'); | |
| 49 | + } | |
| 38 | 50 | |
| 39 | 51 | |
| 40 | 52 | } |
| 41 | 53 | unset($html); // release memory |