Changeset 3378933
- Timestamp:
- 10/15/2025 01:47:30 PM (2 months ago)
- Location:
- athemes-starter-sites/trunk
- Files:
-
- 6 edited
-
README.txt (modified) (1 diff)
-
athemes-starter-sites.php (modified) (1 diff)
-
v2/classes/class-customizer-importer.php (modified) (2 diffs)
-
v2/classes/class-importer.php (modified) (5 diffs)
-
v2/themes/sydney.php (modified) (1 diff)
-
v2/vendor/wp-content-importer-v2/WXRImporter.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
athemes-starter-sites/trunk/README.txt
r3377550 r3378933 4 4 Tested up to: 6.8.3 5 5 Requires PHP: 5.4 6 Stable tag: 1.1. 36 Stable tag: 1.1.4 7 7 Contributors: aThemes 8 8 License: GPLv2 or later -
athemes-starter-sites/trunk/athemes-starter-sites.php
r3377550 r3378933 3 3 * Plugin Name: aThemes Starter Sites 4 4 * Description: Starter Sites for Sydney and Botiga 5 * Version: 1.1. 35 * Version: 1.1.4 6 6 * Author: aThemes 7 7 * Author URI: https://athemes.com -
athemes-starter-sites/trunk/v2/classes/class-customizer-importer.php
r3059797 r3378933 42 42 // Setup internal vars. 43 43 $template = get_template(); 44 $stylesheet = get_stylesheet(); 44 45 45 46 // Data checks. … … 50 51 ); 51 52 } 52 if ( $data['template'] !== $template ) { 53 54 // Allow import if the template matches either: 55 // 1. The parent theme (template) 56 // 2. The current theme/child theme (stylesheet) 57 // 3. Apply filter to allow custom theme matching logic 58 $theme_matches = ( $data['template'] === $template || $data['template'] === $stylesheet ); 59 $theme_matches = apply_filters( 'atss_customizer_import_theme_match', $theme_matches, $data['template'], $template, $stylesheet ); 60 61 if ( ! $theme_matches ) { 53 62 return new WP_Error( 54 63 'customizer_import_wrong_theme', 55 esc_html__( 'Error: The customizer import file is not suitable for current theme. You can only import customizer settings for the same theme or a child theme.', 'athemes-starter-sites' ) 64 sprintf( 65 esc_html__( 'Error: The customizer import file is for "%s" theme but current theme is "%s". You can only import customizer settings for the same theme or a child theme.', 'athemes-starter-sites' ), 66 $data['template'], 67 $stylesheet 68 ) 56 69 ); 57 70 } -
athemes-starter-sites/trunk/v2/classes/class-importer.php
r3377550 r3378933 690 690 $time = microtime( true ) - $this->microtime; 691 691 692 // Check attachment count for splitting (Option 2: split every X attachments) 693 $split_after_attachments = apply_filters( 'atss_split_after_attachments', 10 ); 692 // Check attachment count for splitting - only split if significant time has also passed 693 // This prevents infinite split loops and ensures we only split when actually needed 694 $split_after_attachments = apply_filters( 'atss_split_after_attachments', 10 ); // Increased from 10 to 20 694 695 $should_split_by_count = false; 695 696 696 697 if ( $this->importer && method_exists( $this->importer, 'get_attachment_count' ) ) { 697 698 $attachment_count = $this->importer->get_attachment_count(); 698 if ( $attachment_count >= $split_after_attachments ) { 699 // Only split if we've processed enough attachments AND some time has passed (at least 15 seconds) 700 // This prevents splits when all files already exist (instant processing) 701 if ( $attachment_count >= $split_after_attachments && $time > 15 ) { 699 702 $should_split_by_count = true; 700 703 } … … 702 705 703 706 // We should make a new ajax call, if the time is right OR attachment count is reached. 704 $time_limit = apply_filters( 'atss_time_for_one_ajax_call', 300 ); 707 // Reduced from 300 to 120 to align better with JS timeout of 120 seconds 708 $time_limit = apply_filters( 'atss_time_for_one_ajax_call', 120 ); 705 709 if ( $time > $time_limit || $should_split_by_count ) { 710 711 // Reset the attachment counter for the next AJAX call 712 if ( $this->importer && method_exists( $this->importer, 'reset_attachment_count' ) ) { 713 $this->importer->reset_attachment_count(); 714 } 706 715 707 716 $response = array( … … 1197 1206 * Process customizer.json. 1198 1207 */ 1199 // Get JSON data from customizer.json. 1200 $raw = wp_remote_get( wp_unslash( $file_url ) ); 1208 // Increase time limit for customizer import to prevent timeout 1209 if ( ! ini_get( 'safe_mode' ) ) { 1210 @set_time_limit( 120 ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged 1211 } 1212 1213 // Get JSON data from customizer.json with extended timeout. 1214 $raw = wp_remote_get( 1215 wp_unslash( $file_url ), 1216 array( 1217 'timeout' => 30, // Extended timeout for larger customizer files 1218 'sslverify' => false, 1219 ) 1220 ); 1221 1222 // Check if fetch failed. 1223 if ( is_wp_error( $raw ) ) { 1224 wp_send_json_error( 1225 sprintf( 1226 esc_html__( 'Failed to fetch customizer file: %s', 'athemes-starter-sites' ), 1227 $raw->get_error_message() 1228 ) 1229 ); 1230 } 1201 1231 1202 1232 // Abort if customizer.json response code is not successful. 1203 1233 if ( 200 != wp_remote_retrieve_response_code( $raw ) ) { 1204 wp_send_json_error( esc_html__( 'Failed to load customizer demo file.', 'athemes-starter-sites' ) ); 1234 wp_send_json_error( 1235 sprintf( 1236 esc_html__( 'Failed to load customizer demo file. HTTP %d', 'athemes-starter-sites' ), 1237 wp_remote_retrieve_response_code( $raw ) 1238 ) 1239 ); 1205 1240 } 1206 1241 … … 1211 1246 $data = maybe_unserialize( wp_remote_retrieve_body( $raw ), true ); 1212 1247 1248 // Check if data was properly unserialized 1249 if ( empty( $data ) || ! is_array( $data ) ) { 1250 wp_send_json_error( esc_html__( 'Failed to parse customizer data. File may be corrupted.', 'athemes-starter-sites' ) ); 1251 } 1252 1213 1253 $customizer = new ATSS_Customizer_Importer(); 1214 1254 … … 1217 1257 1218 1258 if ( is_wp_error( $results ) ) { 1219 wp_send_json_error( esc_html__( 'An error occurred while importing customizer.', 'athemes-starter-sites' ) ); 1259 wp_send_json_error( 1260 sprintf( 1261 esc_html__( 'Customizer import error: %s', 'athemes-starter-sites' ), 1262 $results->get_error_message() 1263 ) 1264 ); 1220 1265 } 1221 1266 -
athemes-starter-sites/trunk/v2/themes/sydney.php
r3367146 r3378933 1281 1281 } 1282 1282 add_filter( 'atss_register_customize_tooltips', 'sydney_atss_color_scheme_tooltips' ); 1283 1284 /** 1285 * Allow Sydney and Sydney Pro to share customizer files 1286 * This ensures cross-compatibility between Sydney (free) and Sydney Pro themes 1287 */ 1288 function sydney_atss_customizer_import_theme_match( $theme_matches, $import_template, $current_template, $current_stylesheet ) { 1289 // If already matched, return true 1290 if ( $theme_matches ) { 1291 return true; 1292 } 1293 1294 $sydney_themes = array( 'sydney', 'sydney-pro', 'sydney-pro-ii' ); 1295 1296 if ( in_array( $import_template, $sydney_themes, true ) && in_array( $current_template, $sydney_themes, true ) ) { 1297 return true; 1298 } 1299 1300 if ( in_array( $import_template, $sydney_themes, true ) && in_array( $current_stylesheet, $sydney_themes, true ) ) { 1301 return true; 1302 } 1303 1304 return $theme_matches; 1305 } 1306 add_filter( 'atss_customizer_import_theme_match', 'sydney_atss_customizer_import_theme_match', 10, 4 ); -
athemes-starter-sites/trunk/v2/vendor/wp-content-importer-v2/WXRImporter.php
r3377550 r3378933 1960 1960 // Wrap entire download in try-catch to prevent crashes 1961 1961 try { 1962 // Increment attachment counter for AJAX splitting1963 $this->attachment_count++;1964 1965 1962 // extract the file name and extension from the url 1966 1963 $file_name = basename( $url ); … … 1976 1973 'url' => $exists_url, 1977 1974 ); 1975 // Don't increment counter when file already exists 1978 1976 return $upload; 1979 1977 } 1978 1979 // Increment attachment counter ONLY for actual downloads 1980 // This prevents false positives when files are already cached 1981 $this->attachment_count++; 1980 1982 1981 1983 // get placeholder file in the upload dir with a unique, sanitized filename … … 2663 2665 return $this->attachment_count; 2664 2666 } 2667 2668 /** 2669 * Reset attachment count (called when starting a new AJAX request) 2670 * 2671 * @return void 2672 */ 2673 public function reset_attachment_count() { 2674 $this->attachment_count = 0; 2675 } 2665 2676 }
Note: See TracChangeset
for help on using the changeset viewer.