Plugin Directory

Changeset 3378933


Ignore:
Timestamp:
10/15/2025 01:47:30 PM (2 months ago)
Author:
athemes
Message:

v1.1.4

Location:
athemes-starter-sites/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • athemes-starter-sites/trunk/README.txt

    r3377550 r3378933  
    44Tested up to: 6.8.3
    55Requires PHP: 5.4
    6 Stable tag: 1.1.3
     6Stable tag: 1.1.4
    77Contributors: aThemes
    88License: GPLv2 or later
  • athemes-starter-sites/trunk/athemes-starter-sites.php

    r3377550 r3378933  
    33 * Plugin Name:       aThemes Starter Sites
    44 * Description:       Starter Sites for Sydney and Botiga
    5  * Version:           1.1.3
     5 * Version:           1.1.4
    66 * Author:            aThemes
    77 * Author URI:        https://athemes.com
  • athemes-starter-sites/trunk/v2/classes/class-customizer-importer.php

    r3059797 r3378933  
    4242        // Setup internal vars.
    4343        $template = get_template();
     44        $stylesheet = get_stylesheet();
    4445
    4546        // Data checks.
     
    5051            );
    5152        }
    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 ) {
    5362            return new WP_Error(
    5463                '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                )
    5669            );
    5770        }
  • athemes-starter-sites/trunk/v2/classes/class-importer.php

    r3377550 r3378933  
    690690        $time = microtime( true ) - $this->microtime;
    691691
    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
    694695        $should_split_by_count = false;
    695696       
    696697        if ( $this->importer && method_exists( $this->importer, 'get_attachment_count' ) ) {
    697698            $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 ) {
    699702                $should_split_by_count = true;
    700703            }
     
    702705
    703706        // 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 );
    705709        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            }
    706715
    707716            $response = array(
     
    11971206         * Process customizer.json.
    11981207         */
    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        }
    12011231
    12021232        // Abort if customizer.json response code is not successful.
    12031233        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            );
    12051240        }
    12061241
     
    12111246        $data = maybe_unserialize( wp_remote_retrieve_body( $raw ), true );
    12121247
     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
    12131253        $customizer = new ATSS_Customizer_Importer();
    12141254
     
    12171257
    12181258        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            );
    12201265        }
    12211266
  • athemes-starter-sites/trunk/v2/themes/sydney.php

    r3367146 r3378933  
    12811281}
    12821282add_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 */
     1288function 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}
     1306add_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  
    19601960        // Wrap entire download in try-catch to prevent crashes
    19611961        try {
    1962             // Increment attachment counter for AJAX splitting
    1963             $this->attachment_count++;
    1964            
    19651962            // extract the file name and extension from the url
    19661963            $file_name = basename( $url );
     
    19761973                    'url'  => $exists_url,
    19771974                );
     1975                // Don't increment counter when file already exists
    19781976                return $upload;
    19791977            }
     1978
     1979            // Increment attachment counter ONLY for actual downloads
     1980            // This prevents false positives when files are already cached
     1981            $this->attachment_count++;
    19801982
    19811983            // get placeholder file in the upload dir with a unique, sanitized filename
     
    26632665        return $this->attachment_count;
    26642666    }
     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    }
    26652676}
Note: See TracChangeset for help on using the changeset viewer.