Plugin Directory

Changeset 2132680


Ignore:
Timestamp:
08/02/2019 11:18:10 AM (7 years ago)
Author:
promact
Message:

progressbar changes, multisite support

Location:
wp-azure-offload/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • wp-azure-offload/trunk/assets/css/styles.css

    r1719321 r2132680  
    8787.h3-bg{
    8888    background: #ccc;
    89     padding-bottom: 15px;
    90     border-radius: 25px;
    91     height: 15px;
    92     border: 1px solid #ccc;
    93     position: relative;
    94     padding-left: 30px;
    95     padding-top: 3px;
    96     width: 80%;
     89    padding-bottom: 15px;
     90    border-radius: 25px;
     91    height: 15px;
     92    border: 1px solid #ccc;
     93    position: relative;
     94    padding-left: 30px;
     95    padding-top: 3px;
     96    width: 70%;
     97    float: left;
    9798}
    9899.container-save {
     
    380381    display: none;
    381382}
     383
     384.circle {
     385    margin: 15px 20px 26px;
     386    display: inline-block;
     387    position: relative;
     388    text-align: center;
     389    vertical-align: top;
     390}
     391.circle-status {
     392    position: absolute;
     393    top: -2px;
     394    left: 2px;
     395    width: 100%;
     396    text-align: center;
     397    line-height: 45px;
     398    font-size: 11px;
     399    font-weight: 900;
     400}
  • wp-azure-offload/trunk/assets/js/script.js

    r1719321 r2132680  
    319319            error: function(jqXHR, textStatus, errorThrown){},
    320320            success: function(data, textStatus,jqXHR){
    321                 if ( data.data > 0 ) {
    322                     $( ".copy-all-media" ).attr( "disabled", true );
    323                     $( ".progress-bar" ).css( {"display":"inline-flex"} );
    324                     $( '#status' ).html( '0%' );
    325                     processStart();
     321                if ( false === data.enable_plugin ){
     322                        alert( data.notice );
    326323                } else {
    327                     alert( "Each file has already been uploaded!" );
     324                    if ( data.data > 0 ) {
     325                        $( ".copy-all-media" ).attr( "disabled", true );
     326                        $( ".circle").show();
     327                        var progressBarOptions = {
     328                            startAngle: -1.55,
     329                            size: 40,
     330                            animation: false,
     331                            value: 0,
     332                            fill: {
     333                                color: '#006799'
     334                            }
     335                        }
     336                        $('.circle').circleProgress(progressBarOptions);
     337                        processStart();
     338                    } else {
     339                        alert( "Each file has already been uploaded!" );
     340                    }
    328341                }
    329342            },
     
    344357                if ( data.data.media_cron_running ) {
    345358                    $( ".copy-all-media" ).attr( "disabled", true );
    346                     $( ".progress-bar" ).css( {"display":"inline-flex"} );
     359                    $( ".circle" ).show();
    347360                    var total_count = data.data.total_count;
    348361                    uploadedCount( total_count );
     
    376389                    var remaining_count = initial_count - d;
    377390                    var bar_width = Math.ceil( ( ( initial_count - d ) / initial_count ) * 100 );
    378                     $( '#bar' ).css( {width: + bar_width + '%' ,"background-color":"green"} );
    379                     $( '#status' ).html( bar_width + '%' );
     391                    $( '.circle-status' ).html( ( bar_width ) + '%' );
     392                   
     393                    var progressBarOptions = {
     394                        startAngle: -1.55,
     395                        value: ( bar_width / 100 ),
     396                        animation: false,
     397                        size: 40,
     398                        fill: {
     399                            color: '#008000'
     400                        }
     401                    }
     402                    $('.circle').circleProgress(progressBarOptions);
    380403
    381404                    if ( d === 0 ) {
     
    418441            success: function( data, textStatus, jqXHR){
    419442                $( ".copy-all-media" ).attr( "disabled", false );
    420                 $( ".progress-bar" ).hide();
     443                $( ".circle").hide();
    421444            },
    422445        });
     
    424447
    425448})( jQuery );
     449
  • wp-azure-offload/trunk/classes/class-azure-plugin-base.php

    r1719321 r2132680  
    528528     */
    529529    public function get_mime_type( $file_path ) {
    530         $file_type = wp_check_filetype_and_ext( $file_path, basename( $file_path ) );
     530        $text_mime = array(
     531            'eot'   => 'application/vnd.ms-fontobject',
     532            'otf'   => 'application/x-font-opentype',
     533            'rss'   => 'application/rss+xml',
     534            'svg'   => 'image/svg+xml',
     535            'ttf'   => 'application/x-font-ttf',
     536            'woff'  => 'application/font-woff',
     537            'woff2' => 'application/font-woff2',
     538            'xml'   => 'application/xml',
     539        );
     540        $mime = wp_get_mime_types();
     541        $allowed_mime = array_merge( $mime, $text_mime );
     542        $file_type = wp_check_filetype_and_ext( $file_path, basename( $file_path ), $allowed_mime );
     543
    531544        return $file_type['type'];
    532545    }
    533546}
     547
  • wp-azure-offload/trunk/classes/class-azure-storage-and-cdn.php

    r1719321 r2132680  
    9292        add_action( 'wp_ajax_media-cron', array( $this, 'run_cron' ) );
    9393        add_action( 'wp_ajax_remove-cron-details', array( $this, 'ajax_remove_cron_details' ) );
    94     }
    95 
     94        add_filter( 'cron_schedules', array( $this, 'offload_schedule' ) );
     95    }
     96
     97    /*
     98     * custom cron schedule
     99     *
     100     * @param array $interval an array of schedule intervals
     101     */
     102    public function offload_schedule( $interval ) {
     103        $interval['media_copy'] = array(
     104            'interval' => 300,
     105            'display'  => __( 'Every Minutes', 'textdomain' ),
     106        );
     107        return $interval;
     108    }
    96109    /**
    97110     * Count of files to be uploaded for progess bar
     
    117130        $data['total_count'] = $total_count;
    118131
    119         if ( $is_cron_running ) {
     132        if(is_multisite()){
     133            switch_to_blog(1);
     134        }
     135        if ( $is_cron_running && (wp_get_schedule( 'upload_media_library' )) ) {
    120136            $data['media_cron_running'] = 1;
    121137        } else {
     138            delete_site_option( 'wp-azure-media-cron-running' );
     139            delete_site_option( 'wp-azure-media-total-count' );
    122140            $data['media_cron_running'] = 0;
    123141        }
     
    133151    function ajax_remove_cron_details() {
    134152        $out = array();
     153        wp_clear_scheduled_hook( 'upload_media_library' );
    135154        delete_site_option( 'wp-azure-media-cron-running' );
    136155        delete_site_option( 'wp-azure-media-total-count' );
     
    143162     */
    144163    public function run_cron() {
    145         $total_file_count = $this->local_files_count();
    146 
    147         if ( $total_file_count > 0 ) {
    148             if ( ! wp_next_scheduled( 'upload_media_library' ) ) {
    149                 wp_schedule_single_event( time(), 'upload_media_library' );
    150             }
    151 
    152             update_site_option( 'wp-azure-media-cron-running', true );
    153             update_site_option( 'wp-azure-media-total-count', $total_file_count );
     164        $total_file_count = 0;
     165        $copy_enable = true;
     166
     167        if ( ! $this->get_serve_from_azure_setting() ) {
     168            $copy_enable = false;
     169            $copy_enable_notice = 'Please enable setting SERVE FILES USING CDN URL' ;
     170        }
     171
     172        if ( ! $this->get_copy_to_azure_setting() ) {
     173            $copy_enable = false;
     174            $copy_enable_notice = 'Please enable setting COPY FILES TO AZURE STORAGE' ;
     175        }
     176
     177        if ( $copy_enable ) {
     178            $total_file_count = $this->local_files_count();
     179
     180            if ( $total_file_count > 0 ) {
     181                if(is_multisite()){
     182                    switch_to_blog(1);
     183                }
     184                wp_clear_scheduled_hook( 'upload_media_library' );
     185                if ( ! wp_next_scheduled( 'upload_media_library' ) ) {
     186                    wp_schedule_event( time(), 'media_copy', 'upload_media_library' );
     187                }
     188
     189                update_site_option( 'wp-azure-media-cron-running', true );
     190                update_site_option( 'wp-azure-media-total-count', $total_file_count );
     191            }
    154192        }
    155193        $out = array(
    156194            'success' => 1,
    157195            'data' => $total_file_count,
     196            'enable_plugin' => $copy_enable,
     197            'notice' => $copy_enable_notice,
    158198        );
    159199
     
    236276        wp_register_script( 'azure-validate', $src, array( 'jquery' ), $version, true );
    237277        wp_enqueue_script( 'azure-validate' );
     278
     279        $src = plugins_url( 'assets/js/circleprogress.js', $this->plugin_file_path );
     280        wp_register_script( 'azure-circleprogress', $src, array( 'jquery' ), $version, true );
     281        wp_enqueue_script( 'azure-circleprogress' );
    238282
    239283        $src = plugins_url( 'assets/js/script.js', $this->plugin_file_path );
     
    477521        }
    478522
    479         $azure_storage_object['sizes'] = $data['sizes'];
     523        $azure_storage_object['sizes'] = isset( $data['sizes'] ) ? $data['sizes'] : array();
    480524        add_post_meta( $post_id, 'azurestorage_info', $azure_storage_object );
    481525
     
    9761020            $file_names[] = $azurestorage['key'];
    9771021            // different sizes.
    978             foreach ( $azurestorage['sizes'] as $size => $file ) {
    979                 $file_names[] = $file['file'];
     1022            if ( $azurestorage ) {
     1023                foreach ( $azurestorage['sizes'] as $size => $file ) {
     1024                    $file_names[] = $file['file'];
     1025                }
    9801026            }
    9811027            $details['file_names'] = $file_names;
     
    11121158}
    11131159
     1160
  • wp-azure-offload/trunk/view/container-setting.php

    r1719321 r2132680  
    3838                        <input type="button"  class=" button azure-button button-primary copy-All copy-all-media" value="Click Now">
    3939                        </h3>
    40                         <div class="progress-bar">
    41                             <div id="progress" style=""><div id="bar"></div></div>
    42                             <div id="status"></div>
     40                        <div class="circle">
     41                            <strong class="circle-status"></strong>
    4342                        </div>
    4443                    </td>
     
    102101        </form>
    103102    </div>
     103
Note: See TracChangeset for help on using the changeset viewer.