示例#1
0
 public function send_urgent_notice($source, $id, $subject, $message, $data = array())
 {
     require_once $GLOBALS['ithemes_sync_path'] . '/server.php';
     require_once $GLOBALS['ithemes_sync_path'] . '/settings.php';
     $timestamp = time();
     $notice = compact('source', 'id', 'subject', 'message', 'data', 'timestamp');
     $notices = $this->get_urgent_notices();
     $notices[] = $notice;
     $options = $GLOBALS['ithemes-sync-settings']->get_options();
     $errors = false;
     foreach ($options['authentications'] as $user_id => $user) {
         $result = Ithemes_Sync_Server::send_urgent_notices($user_id, $user['username'], $user['key'], $notices);
         if (!is_wp_error($result) && is_array($result) && !empty($result['success'])) {
             continue;
         } else {
             $errors = true;
             $this->set_urgent_notices($notices);
             break;
         }
     }
     if (!empty($errors)) {
         return $result;
     } else {
         $this->clear_urgent_notices();
         return true;
     }
     return new WP_Error('unknown-response', __('The Sync server returned an unknown response.', 'it-l10n-ithemes-sync'));
 }