Plugin Directory

Changeset 1944110


Ignore:
Timestamp:
09/20/2018 08:55:45 AM (8 years ago)
Author:
spotim
Message:

Added sync message

Location:
spotim-comments
Files:
47 added
3 edited

Legend:

Unmodified
Added
Removed
  • spotim-comments/trunk/inc/class-spotim-import.php

    r1944095 r1944110  
    3131
    3232    private $total_changed_posts = [];
     33
     34    private $needto_load_more_changed_posts = 0;
    3335
    3436    /**
     
    123125
    124126            $this->total_changed_posts = get_option("wp-spotim-settings_total_changed_posts", []);
     127            $this->needto_load_more_changed_posts = $this->options->get('needto_load_more_changed_posts',0);
    125128        } else {
    126129            $this->page_number = $page_number;
     
    129132
    130133//        $post_ids = $this->get_post_ids( $this->posts_per_request, $this->page_number );
    131         if(!is_array($this->total_changed_posts) || empty($this->total_changed_posts))
     134        if(!is_array($this->total_changed_posts) || empty($this->total_changed_posts) || $this->needto_load_more_changed_posts > 0)
    132135            $this->get_changed_post_ids();
    133136
     
    285288        if ( 0 === $total_posts_count ) {
    286289            $response_args['status'] = 'success';
    287             $response_args['message'] = esc_html__( "Your website doesn't have any posts to sync.", 'spotim-comments' );
     290            $response_args['message'] = esc_html__("Your website doesn't have any posts to sync.", 'spotim-comments');
     291        }else if($this->needto_load_more_changed_posts > 0){
     292            $parsed_message = sprintf(
     293                esc_html__( 'Loading %d total posts to sync.', 'spotim-comments' ),
     294                $total_posts_count
     295            );
     296
     297            $response_args['status'] = 'continue';
     298            $response_args['message'] = $parsed_message;
     299
    288300        } else if ( $current_posts_count < $total_posts_count ) {
    289301            $parsed_message = sprintf(
     
    348360     * @return array
    349361     */
    350     private function get_changed_post_ids($offset = 0){
    351         ini_set('display_errors', 1);
    352         ini_set('display_startup_errors', 1);
    353         error_reporting(E_ALL);
     362    private function get_changed_post_ids(){
     363
     364        $offset = $this->needto_load_more_changed_posts;
     365        $limit = 5000;
     366
    354367        $spot_id = $this->options->get( 'spot_id' );
    355368        $sec_ago = $this->options->get("spotim_last_sync_timestamp", null);
     
    363376            'spot_id' => $spot_id,
    364377            'sec_ago' => $sec_ago,
    365             'limit' => 5000,
     378            'limit' => $limit,
    366379            'offset' => $offset
    367380        ), self::SPOTIM_LAST_MODIFIED_API_URL );
     
    381394            update_option("wp-spotim-settings_total_changed_posts", $this->total_changed_posts);
    382395
    383             $offset += 5000;
    384 
    385             if(count($body) >= 5000)
    386                 $this->get_changed_post_ids($offset);
     396            $offset += $limit;
     397
     398            if(count($body) >= 1){
     399                $this->needto_load_more_changed_posts = $this->options->update('needto_load_more_changed_posts', $offset);
     400                $this->finish();
     401            }else
     402                $this->needto_load_more_changed_posts = $this->options->update('needto_load_more_changed_posts', 0);
    387403        }
    388404    }
  • spotim-comments/trunk/readme.txt

    r1944095 r1944110  
    55Tested up to: 4.9
    66Requires PHP: 5.2
    7 Stable tag: 4.3.5
     7Stable tag: 4.3.6
    88License: GPLv2 or later
    99License URI: license.txt
     
    204204== Changelog ==
    205205
    206 = 4.3.5 =
     206= 4.3.6 =
    207207* Improve sync mechanism
    208 
    209208
    210209= 4.3.0 =
  • spotim-comments/trunk/spotim-comments.php

    r1944095 r1944110  
    44 * Plugin URI:          https://wordpress.org/plugins/spotim-comments/
    55 * Description:         Real-time comments widget turns your site into its own content-circulating ecosystem.
    6  * Version:             4.3.5
     6 * Version:             4.3.6
    77 * Author:              Spot.IM
    88 * Author URI:          https://github.com/SpotIM
Note: See TracChangeset for help on using the changeset viewer.