Пример #1
0
 /**
  * Do the sync process for a site/blog call remotely only.
  * 
  * @return array|bool
  */
 public static function do_site_sync()
 {
     // Do not log into New Relic, because this function is slow and we know why
     if (extension_loaded('newrelic')) {
         newrelic_ignore_transaction();
     }
     // Do not let the sync happen on the network blog
     if (BLOG_ID_CURRENT_SITE == get_current_blog_id()) {
         header('Content-type: application/json');
         echo json_encode(false);
         exit;
     }
     set_error_handler(array('Kigo_Network_Cron', 'php_error_handler'));
     // Add our custom handler for wp_die() because some functions die on error, and we don't want the script to die !
     add_filter('wp_die_ajax_handler', array('Kigo_Network_Cron', 'kigo_cron_wp_die_handler_filter'));
     $site_cron = new Kigo_Site_Cron(isset($_GET[self::GET_PARAM_FORCED_SYNC]) && $_GET[self::GET_PARAM_FORCED_SYNC] == 1);
     $ret = $site_cron->sync_entities() ? true : $site_cron->_errors;
     restore_error_handler();
     header('Content-type: application/json');
     echo json_encode($ret);
     exit;
 }