/** * Run a complete sync of all data. Download new stats for every single post in the DB. * * This should only be run when the plugin is first installed, or if data syncing was interrupted. * */ public static function scheduleFullDataSync() { // We are going to stagger the updates so we do not overload the Wordpress cron. $nextTime = time(); $interval = 5; // in seconds $post_types = EasySocialMetricsUpdater::get_post_types_static(); $options = get_option(EasySocialShareButtons::$plugin_settings_name); $nextTime = time(); $interval = 5; // in seconds // In case the function does not finish, we want to start with posts that have NO data yet. $querydata = query_posts(array('order' => 'DESC', 'orderby' => 'post_date', 'posts_per_page' => -1, 'post_status' => 'publish', 'post_type' => $post_types)); foreach ($querydata as $querydatum) { wp_schedule_single_event($nextTime, 'easy_social_metrics_update_single_post', array($querydatum->ID)); $nextTime = $nextTime + $interval; } return; }
/** * Run a complete sync of all data. Download new stats for every single post in the DB. * * This should only be run when the plugin is first installed, or if data syncing was interrupted. * */ public static function scheduleFullDataSync() { global $essb_options; // We are going to stagger the updates so we do not overload the Wordpress cron. $nextTime = time(); $interval = 5; // in seconds $post_types = EasySocialMetricsUpdater::get_post_types_static(); $options = $essb_options; $nextTime = time(); $interval = 5; // in seconds // In case the function does not finish, we want to start with posts that have NO data yet. /*$querydata = query_posts(array( 'order' =>'DESC', 'orderby' =>'post_date', 'posts_per_page'=>-1, 'post_status' => 'publish', 'post_type' => $post_types ));*/ $querydata1 = new WP_Query(array('posts_per_page' => -1, 'post_status' => 'publish', 'post_type' => $post_types)); //print_r($querydata); if ($querydata1->have_posts()) { while ($querydata1->have_posts()) { $querydata1->the_post(); global $post; wp_schedule_single_event($nextTime, 'easy_social_metrics_update_single_post', array($post->ID)); $nextTime = $nextTime + $interval; } } //foreach ($querydata as $querydatum ) { // wp_schedule_single_event( $nextTime, 'easy_social_metrics_update_single_post', array( $querydatum->ID ) ); // $nextTime = $nextTime + $interval; //} wp_reset_postdata(); return; }