Changeset 1947298
- Timestamp:
- 09/26/2018 11:37:43 AM (8 years ago)
- Location:
- spotim-comments
- Files:
-
- 47 added
- 8 edited
-
tags/4.3.7 (added)
-
tags/4.3.7/.gitignore (added)
-
tags/4.3.7/assets (added)
-
tags/4.3.7/assets/images (added)
-
tags/4.3.7/assets/images/ajax-loader.gif (added)
-
tags/4.3.7/assets/javascripts (added)
-
tags/4.3.7/assets/javascripts/admin.js (added)
-
tags/4.3.7/assets/stylesheets (added)
-
tags/4.3.7/assets/stylesheets/admin.css (added)
-
tags/4.3.7/assets/stylesheets/comments-number.css (added)
-
tags/4.3.7/gulpfile.js (added)
-
tags/4.3.7/inc (added)
-
tags/4.3.7/inc/class-spotim-admin.php (added)
-
tags/4.3.7/inc/class-spotim-cron.php (added)
-
tags/4.3.7/inc/class-spotim-feed.php (added)
-
tags/4.3.7/inc/class-spotim-frontend.php (added)
-
tags/4.3.7/inc/class-spotim-i18n.php (added)
-
tags/4.3.7/inc/class-spotim-import.php (added)
-
tags/4.3.7/inc/class-spotim-metabox.php (added)
-
tags/4.3.7/inc/class-spotim-options.php (added)
-
tags/4.3.7/inc/class-spotim-settings-fields.php (added)
-
tags/4.3.7/inc/helpers (added)
-
tags/4.3.7/inc/helpers/class-spotim-comment.php (added)
-
tags/4.3.7/inc/helpers/class-spotim-form.php (added)
-
tags/4.3.7/inc/helpers/class-spotim-json-feed.php (added)
-
tags/4.3.7/inc/helpers/class-spotim-message.php (added)
-
tags/4.3.7/inc/helpers/index.php (added)
-
tags/4.3.7/inc/index.php (added)
-
tags/4.3.7/inc/spotim-shortcodes.php (added)
-
tags/4.3.7/inc/spotim-widgets.php (added)
-
tags/4.3.7/index.php (added)
-
tags/4.3.7/language (added)
-
tags/4.3.7/language/index.php (added)
-
tags/4.3.7/language/spotim-comments.pot (added)
-
tags/4.3.7/license.txt (added)
-
tags/4.3.7/package.json (added)
-
tags/4.3.7/readme.txt (added)
-
tags/4.3.7/spotim-comments.php (added)
-
tags/4.3.7/templates (added)
-
tags/4.3.7/templates/admin-template.php (added)
-
tags/4.3.7/templates/comments-number-template.php (added)
-
tags/4.3.7/templates/comments-template-empty.php (added)
-
tags/4.3.7/templates/comments-template.php (added)
-
tags/4.3.7/templates/index.php (added)
-
tags/4.3.7/templates/newsfeed-template.php (added)
-
tags/4.3.7/templates/recirculation-template.php (added)
-
tags/4.3.7/templates/siderail-template.php (added)
-
trunk/assets/javascripts/admin.js (modified) (4 diffs)
-
trunk/assets/stylesheets/admin.css (modified) (1 diff)
-
trunk/inc/class-spotim-admin.php (modified) (3 diffs)
-
trunk/inc/class-spotim-import.php (modified) (11 diffs)
-
trunk/inc/class-spotim-settings-fields.php (modified) (1 diff)
-
trunk/inc/helpers/class-spotim-form.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/spotim-comments.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
spotim-comments/trunk/assets/javascripts/admin.js
r1786408 r1947298 5 5 6 6 // Import 7 $( ' #import_button' ).on( 'click', function( event ) {7 $( '.sync-button' ).on( 'click', function( event ) { 8 8 var $importButton = $(this), 9 9 $parentElement = $importButton.parent(), … … 22 22 23 23 // Disable the import button 24 $ importButton.attr( 'disabled', true );24 $( '.sync-button' ).attr( 'disabled', true ); 25 25 26 26 var data = { … … 35 35 }; 36 36 37 importCommentsToWP( data, $importButton, $messageField, $errorsField ); 37 if($importButton.hasClass('force')) 38 data.force = true; 39 40 importCommentsToWP( data, $( '.sync-button' ), $messageField, $errorsField ); 38 41 39 42 event.preventDefault(); … … 80 83 } 81 84 85 delete params.force; 86 82 87 switch( response.status ) { 88 case 'refresh': 89 importCommentsToWP( params, $importButton, $messageField, $errorsField ); 90 break; 83 91 case 'continue': 84 92 params.spotim_page_number = params.spotim_page_number + 1; 85 86 93 importCommentsToWP( params, $importButton, $messageField, $errorsField ); 87 94 break; -
spotim-comments/trunk/assets/stylesheets/admin.css
r1734915 r1947298 42 42 display: none; 43 43 } 44 .spotim-page-wrap #import_button[disabled] { 44 .spotim-page-wrap #force_import_button{ 45 margin:0 10px; 46 color:black; 47 background-color: #EDEDED; 48 text-shadow: none; 49 border:none; 50 box-shadow: none; 51 } 52 .spotim-page-wrap #force_import_button[disabled] { 45 53 position: relative; 46 54 } 47 .spotim-page-wrap # import_button[disabled]:after {55 .spotim-page-wrap #force_import_button[disabled]:after { 48 56 background-image: url('../images/ajax-loader.gif'); 49 57 background-position: 0 0; -
spotim-comments/trunk/inc/class-spotim-admin.php
r1944095 r1947298 214 214 $import_token = sanitize_text_field( $_POST['spotim_import_token'] ); 215 215 $page_number = isset( $_POST['spotim_page_number'] ) ? absint( $_POST['spotim_page_number'] ) : 0; 216 217 if($page_number === 0) 218 update_option("wp-spotim-settings_total_changed_posts", null); 216 $force = isset( $_POST['force'] ) ? true : false; 219 217 220 218 if ( isset( $_POST['spotim_posts_per_request'] ) ) { … … 225 223 } 226 224 227 $import->start( $spot_id, $import_token, $page_number, $posts_per_request );225 $import->start( $spot_id, $import_token, $page_number, $posts_per_request, $force ); 228 226 } 229 227 } … … 245 243 update_option("wp-spotim-settings_total_changed_posts", null); 246 244 self::$options->update( 'page_number', $page_number ); 245 self::$options->reset('is_force_sync'); 247 246 248 247 $import->response( array( -
spotim-comments/trunk/inc/class-spotim-import.php
r1944128 r1947298 34 34 private $needto_load_more_changed_posts = 0; 35 35 36 private $is_force_sync = false; 36 37 /** 37 38 * Posts Per Request … … 107 108 * @return void 108 109 */ 109 public function start( $spot_id, $import_token, $page_number = 0, $posts_per_request = 1 ) {110 public function start( $spot_id, $import_token, $page_number = 0, $posts_per_request = 1, $force = false ) { 110 111 111 112 // If not run in return mode, update these options … … 119 120 'page_number', absint( $page_number ) 120 121 ); 121 122 122 123 $this->posts_per_request = $this->options->update( 123 124 'posts_per_request', absint( $posts_per_request ) 124 125 ); 125 126 $this->is_force_sync = $this->options->get( 127 'is_force_sync', false 128 ); 126 129 $this->total_changed_posts = get_option("wp-spotim-settings_total_changed_posts", []); 127 130 $this->needto_load_more_changed_posts = $this->options->get('needto_load_more_changed_posts',0); … … 131 134 } 132 135 136 if($force){ 137 $this->reset_params(); 138 $this->is_force_sync = $this->options->update( 139 'is_force_sync', true 140 ); 141 } 142 133 143 // $post_ids = $this->get_post_ids( $this->posts_per_request, $this->page_number ); 134 144 if(!is_array($this->total_changed_posts) || empty($this->total_changed_posts) || $this->needto_load_more_changed_posts > 0) … … 142 152 } 143 153 154 155 private function reset_params(){ 156 $this->total_changed_posts = []; 157 $this->page_number = $this->options->update('page_number', 0); 158 $this->needto_load_more_changed_posts = $this->options->update("needto_load_more_changed_posts", 0); 159 $this->options->update("spotim_last_sync_timestamp", null); 160 } 144 161 /** 145 162 * Pull Comments … … 187 204 188 205 $post_id = $post_ids[$i]; 189 $post_etag = get_post_meta( $post_id, 'spotim_etag', true );206 $post_etag = $this->is_force_sync ? 0 : get_post_meta( $post_id, 'spotim_etag', true ); 190 207 191 208 $stream = $this->request( array( … … 287 304 288 305 if ( 0 === $total_posts_count ) { 306 $this->options->reset('is_force_sync', false ); 289 307 $response_args['status'] = 'success'; 290 308 $response_args['message'] = esc_html__("Your website doesn't have any posts to sync.", 'spotim-comments'); … … 295 313 ); 296 314 297 $response_args['status'] = ' continue';315 $response_args['status'] = 'refresh'; 298 316 $response_args['message'] = $parsed_message; 299 317 … … 319 337 320 338 $this->options->update("spotim_last_sync_timestamp", time()); 339 $this->options->reset('is_force_sync', false ); 321 340 322 341 if ( ! $this->return ) { … … 396 415 $offset += $limit; 397 416 398 if(count($body) > = 1){417 if(count($body) > 0){ 399 418 $this->needto_load_more_changed_posts = $this->options->update('needto_load_more_changed_posts', $offset); 400 419 $this->finish(); … … 521 540 */ 522 541 public function response( $args = array() ) { 523 $statuses_list = array( 'continue', ' success', 'cancel', 'error' );542 $statuses_list = array( 'continue', 'refresh', 'success', 'cancel', 'error' ); 524 543 525 544 $defaults = array( -
spotim-comments/trunk/inc/class-spotim-settings-fields.php
r1942443 r1947298 397 397 'text' => esc_html__( 'Sync Now', 'spotim-comments' ) 398 398 ), 399 'force_import_button' => array( 400 'id' => 'force_import_button', 401 'text' => esc_html__( 'Reset + Sync Now', 'spotim-comments' ), 402 'description' => esc_html__( 'Use Sync Now to sync data starting from the last sync time.', 'spotim-comments' )."<br />".esc_html__('Use Reset + Sync Now to clear any old synced data and start a fresh sync.', 'spotim-comments') 403 ), 399 404 'cancel_import_link' => array( 400 405 'id' => 'cancel_import_link', -
spotim-comments/trunk/inc/helpers/class-spotim-form.php
r1734915 r1947298 281 281 // Import button 282 282 $template = sprintf( 283 '<button id="%1$s" class="button button-primary " data-import-token="%2$s" data-spot-id="%3$s" data-posts-per-request="%4$s">%5$s</button>',283 '<button id="%1$s" class="button button-primary sync-button" data-import-token="%2$s" data-spot-id="%3$s" data-posts-per-request="%4$s">%5$s</button>', 284 284 esc_attr( $args['import_button']['id'] ), // Button's id. 285 285 esc_attr( $spotim->options->get( 'import_token' ) ), // Import token … … 289 289 ); 290 290 291 // Force re-import (Delete import cache) 292 $template .= sprintf( 293 '<button id="%1$s" style="margin:0 10px;" class="button button-primary sync-button force" data-import-token="%2$s" data-spot-id="%3$s" data-posts-per-request="%4$s" data-force="true">%5$s</button>', 294 esc_attr( $args['force_import_button']['id'] ), // Button's id. 295 esc_attr( $spotim->options->get( 'import_token' ) ), // Import token 296 esc_attr( $spotim->options->get( 'spot_id' ) ), // Spot ID 297 esc_attr( $spotim->options->get( 'posts_per_request' ) ), // Posts per request 298 esc_attr( $args['force_import_button']['text'] ) // Button's text. 299 ); 300 301 $template .= "<br />".$args['force_import_button']['description']; 302 291 303 // Cancel import 292 304 $template .= sprintf( -
spotim-comments/trunk/readme.txt
r1944110 r1947298 204 204 == Changelog == 205 205 206 = 4.3. 6=207 * Improve sync mechanism206 = 4.3.7 = 207 * Added force sync button 208 208 209 209 = 4.3.0 = … … 220 220 * Adding comments number feature 221 221 * Under the hood features 222 * Improve sync mechanism 222 223 223 224 = 4.2.0 = -
spotim-comments/trunk/spotim-comments.php
r1944110 r1947298 4 4 * Plugin URI: https://wordpress.org/plugins/spotim-comments/ 5 5 * Description: Real-time comments widget turns your site into its own content-circulating ecosystem. 6 * Version: 4.3. 66 * Version: 4.3.7 7 7 * Author: Spot.IM 8 8 * Author URI: https://github.com/SpotIM
Note: See TracChangeset
for help on using the changeset viewer.