Beispiel #1
0
 /**
  * Sets the broadcasted IDs for the post.
  *
  * @param  int  $post_id  post id
  * @param  string  $service  service key
  * @param  string  $broadcasted_id  broadcasted id
  * @param  string  $message  broadcasted message
  * @param  Social_Service_Account  $account  account
  * @param  Social_Response  $response  response object
  * @return void
  */
 public function add_broadcasted_id($post_id, $service, $broadcasted_id, $message, $account, Social_Response $response = null)
 {
     $broadcasted_ids = get_post_meta($post_id, '_social_broadcasted_ids', true);
     if (empty($broadcasted_ids)) {
         $broadcasted_ids = array();
     }
     if (!isset($broadcasted_ids[$service])) {
         $broadcasted_ids[$service] = array();
     }
     if (!isset($broadcasted_ids[$service][$account->id()])) {
         $broadcasted_ids[$service][$account->id()] = array();
     }
     if (!isset($broadcasted_ids[$service][$account->id()][$broadcasted_id])) {
         $urls = array(get_permalink($post_id));
         $shortlink = social_get_shortlink($post_id);
         if (!in_array($shortlink, $urls)) {
             $urls[] = $shortlink;
         }
         $home_url = home_url('?p=' . $post_id);
         if (!in_array($home_url, $urls)) {
             $urls[] = $home_url;
         }
         $data = array('message' => $message, 'urls' => $urls);
         $data = apply_filters('social_save_broadcasted_ids_data', $data, $account, $service, $post_id, $response);
         $broadcasted_ids[$service][$account->id()][$broadcasted_id] = $data;
         update_post_meta($post_id, '_social_broadcasted_ids', $broadcasted_ids);
     }
 }
Beispiel #2
0
 /**
  * Gets the requested account.
  *
  * @param  int|Social_Service_Account  $account  account id/object
  * @return Social_Service_Account|Social_Service|bool
  */
 public function account($account)
 {
     if ($account instanceof Social_Service_Account) {
         $this->_accounts[$account->id()] = $account;
         return $this;
     }
     if ($this->account_exists($account)) {
         return $this->_accounts[$account];
     }
     return false;
 }