Plugin Directory

Changeset 1734156


Ignore:
Timestamp:
09/22/2017 09:09:06 AM (9 years ago)
Author:
themespond
Message:
  • Use tp_importer_get_http instead of wp_get_http
  • Disable button import when import.
Location:
tp-framework
Files:
167 added
3 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • tp-framework/trunk/addons/importer/assets/js/main.js

    r1703500 r1734156  
    7171        //Un active and add disabled for other theme
    7272        $('.theme').removeClass('active').addClass('disabled').find('.theme-name span').hide();
     73        $('.theme').find('.placeholder-image').hide();
    7374
    7475        //Add current class
    7576        $theme.addClass('current').removeClass('disabled');
     77        $theme.find('.theme-actions').hide();
    7678        $theme.find('.js-importer-progress').show();
    7779
     
    168170                        setTimeout(function () {
    169171                            $progress.find('.progress-bar').css('width', '1%');
    170 
     172                            $('.theme').find('.placeholder-image').show();
     173                            $theme.find('.theme-actions').show();
    171174                        }, 500);
    172175                    }, 1000);
     
    177180
    178181            eImport.onerror = function (e) {
    179                 console.log('Closed');
    180182                eImport.close();
    181183            }
  • tp-framework/trunk/addons/importer/includes/helper-functions.php

    r1677537 r1734156  
    397397
    398398}
     399
     400function tp_importer_get_http( $url, $file_path = false, $red = 1 ) {
     401
     402    @set_time_limit( 300 );
     403
     404    if ( $red > 5 )
     405        return false;
     406
     407    $options = array();
     408    $options['redirection'] = 5;
     409
     410    if ( false == $file_path )
     411        $options['method'] = 'HEAD';
     412    else
     413        $options['method'] = 'GET';
     414
     415    $response = wp_safe_remote_request( $url, $options );
     416
     417    if ( is_wp_error( $response ) )
     418        return false;
     419
     420    $headers = wp_remote_retrieve_headers( $response );
     421    $headers['response'] = wp_remote_retrieve_response_code( $response );
     422
     423    // WP_HTTP no longer follows redirects for HEAD requests.
     424    if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) {
     425        return tp_importer_get_http( $headers['location'], $file_path, ++$red );
     426    }
     427
     428    if ( false == $file_path )
     429        return $headers;
     430
     431    // GET request - write it to the supplied filename
     432    $out_fp = fopen($file_path, 'w');
     433    if ( !$out_fp )
     434        return $headers;
     435
     436    fwrite( $out_fp,  wp_remote_retrieve_body( $response ) );
     437    fclose($out_fp);
     438    clearstatcache();
     439
     440    return $headers;
     441}
  • tp-framework/trunk/addons/importer/wordpress-importer/wordpress-importer.php

    r1677537 r1734156  
    10791079
    10801080            // fetch the remote url and write it to the placeholder file
    1081             $headers = wp_get_http( $url, $upload[ 'file' ] );
     1081            $headers = tp_importer_get_http( $url, $upload[ 'file' ] );
    10821082
    10831083            // request failed
     
    12921292
    12931293        /**
    1294          * Added to http_request_timeout filter to force timeout at 60 seconds during import
    1295          * @return int 60
     1294         * Added to http_request_timeout filter to force timeout at 300 seconds during import
     1295         * @return int 300
    12961296         */
    12971297        function bump_request_timeout( $val )
    12981298        {
    1299             return 60;
     1299            return 300;
    13001300        }
    13011301
  • tp-framework/trunk/readme.txt

    r1703500 r1734156  
    55Requires at least: 4.5   
    66Tested up to: 4.8   
    7 Stable tag: 1.0.2   
     7Stable tag: 1.0.3   
    88License: GPLv3   
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html   
     
    5656== Changelog ==
    5757
     58= 1.0.3 (September 22, 2017): =
     59 * Use tp_importer_get_http instead of wp_get_http
     60 * Disable button import when import.
     61
    5862= 1.0.2 (June 27, 2017): =
    5963* Fix dependency in Customizer
  • tp-framework/trunk/tp-framework.php

    r1703500 r1734156  
    66  Description: TP Framework provides theme users with an advanced importer and a library including Taxonomy, Metabox, Customizer, Menu Meta, Widget Fields.   
    77  Author: themespond   
    8   Version: 1.0.2   
     8  Version: 1.0.3   
    99  Author URI: https://themespond.com   
    1010  Text Domain: tp-framework   
     
    2222     * @var string
    2323     */
    24     public $version = '1.0.2';
     24    public $version = '1.0.3';
    2525
    2626    /**
Note: See TracChangeset for help on using the changeset viewer.