Changeset 2132680
- Timestamp:
- 08/02/2019 11:18:10 AM (7 years ago)
- Location:
- wp-azure-offload/trunk
- Files:
-
- 5 edited
-
assets/css/styles.css (modified) (2 diffs)
-
assets/js/script.js (modified) (5 diffs)
-
classes/class-azure-plugin-base.php (modified) (1 diff)
-
classes/class-azure-storage-and-cdn.php (modified) (8 diffs)
-
view/container-setting.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-azure-offload/trunk/assets/css/styles.css
r1719321 r2132680 87 87 .h3-bg{ 88 88 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; 97 98 } 98 99 .container-save { … … 380 381 display: none; 381 382 } 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 319 319 error: function(jqXHR, textStatus, errorThrown){}, 320 320 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 ); 326 323 } 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 } 328 341 } 329 342 }, … … 344 357 if ( data.data.media_cron_running ) { 345 358 $( ".copy-all-media" ).attr( "disabled", true ); 346 $( ". progress-bar" ).css( {"display":"inline-flex"});359 $( ".circle" ).show(); 347 360 var total_count = data.data.total_count; 348 361 uploadedCount( total_count ); … … 376 389 var remaining_count = initial_count - d; 377 390 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); 380 403 381 404 if ( d === 0 ) { … … 418 441 success: function( data, textStatus, jqXHR){ 419 442 $( ".copy-all-media" ).attr( "disabled", false ); 420 $( ". progress-bar").hide();443 $( ".circle").hide(); 421 444 }, 422 445 }); … … 424 447 425 448 })( jQuery ); 449 -
wp-azure-offload/trunk/classes/class-azure-plugin-base.php
r1719321 r2132680 528 528 */ 529 529 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 531 544 return $file_type['type']; 532 545 } 533 546 } 547 -
wp-azure-offload/trunk/classes/class-azure-storage-and-cdn.php
r1719321 r2132680 92 92 add_action( 'wp_ajax_media-cron', array( $this, 'run_cron' ) ); 93 93 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 } 96 109 /** 97 110 * Count of files to be uploaded for progess bar … … 117 130 $data['total_count'] = $total_count; 118 131 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' )) ) { 120 136 $data['media_cron_running'] = 1; 121 137 } else { 138 delete_site_option( 'wp-azure-media-cron-running' ); 139 delete_site_option( 'wp-azure-media-total-count' ); 122 140 $data['media_cron_running'] = 0; 123 141 } … … 133 151 function ajax_remove_cron_details() { 134 152 $out = array(); 153 wp_clear_scheduled_hook( 'upload_media_library' ); 135 154 delete_site_option( 'wp-azure-media-cron-running' ); 136 155 delete_site_option( 'wp-azure-media-total-count' ); … … 143 162 */ 144 163 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 } 154 192 } 155 193 $out = array( 156 194 'success' => 1, 157 195 'data' => $total_file_count, 196 'enable_plugin' => $copy_enable, 197 'notice' => $copy_enable_notice, 158 198 ); 159 199 … … 236 276 wp_register_script( 'azure-validate', $src, array( 'jquery' ), $version, true ); 237 277 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' ); 238 282 239 283 $src = plugins_url( 'assets/js/script.js', $this->plugin_file_path ); … … 477 521 } 478 522 479 $azure_storage_object['sizes'] = $data['sizes'];523 $azure_storage_object['sizes'] = isset( $data['sizes'] ) ? $data['sizes'] : array(); 480 524 add_post_meta( $post_id, 'azurestorage_info', $azure_storage_object ); 481 525 … … 976 1020 $file_names[] = $azurestorage['key']; 977 1021 // 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 } 980 1026 } 981 1027 $details['file_names'] = $file_names; … … 1112 1158 } 1113 1159 1160 -
wp-azure-offload/trunk/view/container-setting.php
r1719321 r2132680 38 38 <input type="button" class=" button azure-button button-primary copy-All copy-all-media" value="Click Now"> 39 39 </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> 43 42 </div> 44 43 </td> … … 102 101 </form> 103 102 </div> 103
Note: See TracChangeset
for help on using the changeset viewer.