| @@ -13,9 +13,8 @@ | ||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | use CartflowsAdmin\AdminCore\Ajax\AjaxBase; |
| 16 | 16 | use CartflowsAdmin\AdminCore\Inc\LogStatus; |
| 17 | -use CartflowsAdmin\AdminCore\Inc\AdminHelper; | |
| 18 | 17 | |
| 19 | 18 | /** |
| 20 | 19 | * Class Steps. |
| 21 | 20 | */ |
| @@ -84,10 +83,12 @@ | ||
| 84 | 83 | |
| 85 | 84 | check_ajax_referer( 'cartflows_sync_kb_docs', 'security' ); |
| 86 | 85 | |
| 87 | 86 | $docs_json = json_decode( wp_remote_retrieve_body( wp_remote_get( 'https://cartflows.com//wp-json/powerful-docs/v1/get-docs' ) ) ); |
| 88 | - AdminHelper::update_admin_settings_option( 'cartflows_docs_data', $docs_json ); | |
| 89 | 87 | |
| 88 | + // Never autoload — this payload runs to hundreds of KB and only the Knowledge Base screen reads it. | |
| 89 | + update_option( 'cartflows_docs_data', $docs_json, false ); | |
| 90 | + | |
| 90 | 91 | $response_data = array( |
| 91 | 92 | 'message' => __( 'Sync Success.', 'cartflows' ), |
| 92 | 93 | 'status' => true, |
| 93 | 94 | ); |
| @@ -169,16 +170,30 @@ | ||
| 169 | 170 | $real_log_dir = realpath( CARTFLOWS_LOG_DIR ); |
| 170 | 171 | |
| 171 | 172 | if ( $real_path && $real_log_dir && 0 === strpos( $real_path, $real_log_dir ) && file_exists( $real_path ) ) { |
| 172 | 173 | wp_delete_file( $real_path ); |
| 173 | - self::$file_deleted = true; | |
| 174 | + | |
| 175 | + // Clear the stat cache so the re-check reflects the actual deletion. | |
| 176 | + clearstatcache( true, $real_path ); | |
| 177 | + | |
| 178 | + // Confirm the file is actually gone before reporting success. | |
| 179 | + if ( ! file_exists( $real_path ) ) { | |
| 180 | + self::$file_deleted = true; | |
| 181 | + | |
| 182 | + wp_send_json_success( | |
| 183 | + array( | |
| 184 | + 'message' => esc_html__( 'Log file deleted successfully.', 'cartflows' ), | |
| 185 | + ) | |
| 186 | + ); | |
| 187 | + } | |
| 174 | 188 | } |
| 175 | 189 | |
| 176 | - // Return a success response to the client. | |
| 177 | - $response_data = array( | |
| 178 | - 'message' => esc_html__( 'Log file deleted successfully.', 'cartflows' ), | |
| 190 | + // Reaching here means the file was not deleted. | |
| 191 | + wp_send_json_error( | |
| 192 | + array( | |
| 193 | + 'message' => esc_html__( 'Log file could not be deleted. Please try again.', 'cartflows' ), | |
| 194 | + ) | |
| 179 | 195 | ); |
| 180 | - wp_send_json_success( $response_data ); | |
| 181 | 196 | } |
| 182 | 197 | |
| 183 | 198 | /** |
| 184 | 199 | * Download the selected log file. |