|
2 | 2 | /* |
3 | 3 | Plugin Name: EngineScript: Simple Site Exporter |
4 | 4 | Description: Exports the site files and database as a zip archive. |
5 | | -Version: 1.6.0 |
| 5 | +Version: 1.6.1 |
6 | 6 | Author: EngineScript |
7 | 7 | License: GPL v3 or later |
8 | 8 | Text Domain: Simple-Site-Exporter |
|
15 | 15 |
|
16 | 16 | // Define plugin version |
17 | 17 | if (!defined('ES_SITE_EXPORTER_VERSION')) { |
18 | | - define('ES_SITE_EXPORTER_VERSION', '1.6.0'); |
| 18 | + define('ES_SITE_EXPORTER_VERSION', '1.6.1'); |
19 | 19 | } |
20 | 20 |
|
21 | 21 | /** |
|
27 | 27 | function sse_log($message, $level = 'info') { |
28 | 28 | // Check if WP_DEBUG is enabled |
29 | 29 | if (defined('WP_DEBUG') && WP_DEBUG) { |
30 | | - // Format the message with a timestamp |
| 30 | + // Format the message with a timestamp (using GMT to avoid timezone issues) |
31 | 31 | $formatted_message = sprintf( |
32 | 32 | '[%s] [%s] %s: %s', |
33 | | - date('Y-m-d H:i:s'), |
| 33 | + gmdate('Y-m-d H:i:s'), |
34 | 34 | 'Simple Site Exporter', |
35 | 35 | strtoupper($level), |
36 | 36 | $message |
37 | 37 | ); |
38 | 38 |
|
39 | 39 | // Log to the WordPress debug log if enabled |
40 | 40 | if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) { |
41 | | - error_log($formatted_message); |
| 41 | + // Use WordPress logging when available, fallback to standard logging |
| 42 | + if (function_exists('wp_debug_log')) { |
| 43 | + wp_debug_log($formatted_message); |
| 44 | + } else { |
| 45 | + // Fallback for older WordPress versions that don't have wp_debug_log() |
| 46 | + // Only log during development/debug mode as controlled by WP_DEBUG |
| 47 | + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log |
| 48 | + error_log($formatted_message); |
| 49 | + } |
42 | 50 | } |
43 | 51 |
|
44 | 52 | // Store logs in the database (limit to errors only to prevent bloat) |
@@ -104,7 +112,7 @@ function sse_exporter_page_html() { |
104 | 112 | $display_path = str_replace( ABSPATH, '', $export_dir_path ); |
105 | 113 | ?> |
106 | 114 | <div class="wrap"> |
107 | | - <h1><?php esc_html_e( get_admin_page_title(), 'Simple-Site-Exporter' ); // Use esc_html_e for translatable titles ?></h1> |
| 115 | + <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
108 | 116 | <p><?php esc_html_e( 'Click the button below to generate a zip archive containing your WordPress files and a database dump (.sql file).', 'Simple-Site-Exporter' ); ?></p> |
109 | 117 | <p><strong><?php esc_html_e( 'Warning:', 'Simple-Site-Exporter' ); ?></strong> <?php esc_html_e( 'This can take a long time and consume significant server resources, especially on large sites. Ensure your server has sufficient disk space and execution time.', 'Simple-Site-Exporter' ); ?></p> |
110 | 118 | <p style="margin-top: 15px;"> |
@@ -176,7 +184,11 @@ function sse_handle_export() { |
176 | 184 | // Only try to increase if current limit is lower than our target |
177 | 185 | if ($max_execution_time > 0 && $max_execution_time < $target_execution_time) { |
178 | 186 | // Try to set a reasonable execution time instead of unlimited (0) |
| 187 | + // Note: set_time_limit() is necessary for export operations that may take longer |
| 188 | + // than the default PHP execution time. This is only used when the current limit |
| 189 | + // is insufficient for the export process. |
179 | 190 | if (function_exists('set_time_limit') && !ini_get('safe_mode')) { |
| 191 | + // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_set_time_limit |
180 | 192 | @set_time_limit($target_execution_time); |
181 | 193 | sse_log("Increased execution time limit to {$target_execution_time} seconds", 'info'); |
182 | 194 | } else { |
@@ -222,7 +234,7 @@ function sse_handle_export() { |
222 | 234 | } |
223 | 235 |
|
224 | 236 | $site_name = sanitize_file_name( get_bloginfo( 'name' ) ); |
225 | | - $timestamp = date( 'Y-m-d_H-i-s' ); |
| 237 | + $timestamp = gmdate( 'Y-m-d_H-i-s' ); |
226 | 238 | $random_str = substr( bin2hex( random_bytes(4) ), 0, 7 ); |
227 | 239 | $db_filename = "db_dump_{$site_name}_{$timestamp}.sql"; |
228 | 240 | $zip_filename = "site_export_sse_{$random_str}_{$site_name}_{$timestamp}.zip"; |
|
0 commit comments