当前位置: 首页>>代码示例>>PHP>>正文


PHP Social::instance方法代码示例

本文整理汇总了PHP中Social::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Social::instance方法的具体用法?PHP Social::instance怎么用?PHP Social::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Social的用法示例。


在下文中一共展示了Social::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getInstance

 /**
  * returns the instance created by its first invoke.
  *
  * @return Social
  */
 public static function getInstance()
 {
     if (null === self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
开发者ID:Stephan123,项目名称:markdown_blog,代码行数:12,代码来源:Social.php

示例2: __construct

 function __construct($acct = null)
 {
     // Set our ID
     $this->id = $acct->id();
     // Set the account (Social_Service_Twitter_Account)
     $this->social_acct = $acct;
     // For convenience, set a reference to the service which has all the account methods
     $this->service =& Social::instance()->service('twitter');
 }
开发者ID:ruanyf,项目名称:wp-twitter-tools,代码行数:9,代码来源:aktt_account.php

示例3: add_links_from_social

 public static function add_links_from_social()
 {
     $Social = new Social();
     $ids = get_post_meta(get_the_ID(), '_social_broadcasted_ids', true);
     $services = $Social->instance()->services();
     $broadcasts = array();
     $see_on_social = '';
     if (is_array($ids) and count($ids)) {
         foreach ($services as $key => $service) {
             if (isset($ids[$key]) and count($ids[$key])) {
                 $broadcasted = true;
                 foreach ($ids[$key] as $user_id => $broadcasted) {
                     $account = $service->account($user_id);
                     foreach ($broadcasted as $broadcasted_id => $data) {
                         if (false === $account) {
                             $class = 'Social_Service_' . $key . '_Account';
                             $account = new $class($data['account']);
                             if (!$account->has_user() and 'twitter' == $key) {
                                 $recovered = $service->recover_broadcasted_tweet_data($broadcasted_id, $post->ID);
                                 if (isset($recovered->user)) {
                                     $data['account']->user = $recovered->user;
                                     $account = new $class($data['account']);
                                 }
                             }
                         }
                         $broadcasted = esc_html($service->title());
                         if (isset($broadcasted_id)) {
                             if ($account->has_user() or 'twitter' !== $service->key()) {
                                 $url = $service->status_url($account->username(), $broadcasted_id);
                                 if (!empty($url)) {
                                     $broadcasts[] = esc_url($url);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $broadcasts;
 }
开发者ID:dshanske,项目名称:syndication-links,代码行数:41,代码来源:class-social-plugins.php

示例4: language_attributes

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php 
language_attributes();
?>
>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php 
_e('Social Broadcasts', 'social');
?>
</title>
<?php 
wp_admin_css('install', true);
wp_admin_css('buttons', true);
$social = Social::instance();
$social->admin_enqueue_assets();
?>
	<link rel="stylesheet" id="social-css" href="<?php 
echo esc_url(SOCIAL_ADMIN_CSS);
?>
" type="text/css" media="all" />
</head>
<body class="<?php 
echo esc_attr($clean);
?>
">
<h1 id="logo"><?php 
_e('Social Broadcasts', 'social');
?>
</h1>
<form id="setup" method="post" class="broadcast-interstitial" action="<?php 
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:31,代码来源:options.php

示例5: social_settings_save

 /**
  * Saves the Facebook pages.
  *
  * @wp-action social_settings_save
  * @static
  * @param  bool $is_personal
  */
 public static function social_settings_save($is_personal = false)
 {
     $service = Social::instance()->service('facebook');
     if ($service !== false) {
         $accounts = $service->accounts();
         if (count($accounts)) {
             foreach ($accounts as $account_id => $account) {
                 if (isset($_POST['social_facebook_pages_' . $account->id()])) {
                     $pages = $service->get_pages($account);
                     $account->pages(array());
                     if (count($pages)) {
                         foreach ($_POST['social_facebook_pages_' . $account->id()] as $page_id) {
                             if (isset($pages[$page_id])) {
                                 $accounts[$account_id] = $account->page($pages[$page_id]);
                             }
                         }
                     }
                 }
                 if (defined('IS_PROFILE_PAGE')) {
                     $accounts[$account_id]->universal(false);
                     $accounts[$account_id]->use_pages(false, false);
                     $accounts[$account_id]->pages(array(), false);
                 } else {
                     $accounts[$account_id]->personal(false);
                     $accounts[$account_id]->use_pages(true, false);
                     $accounts[$account_id]->pages(array(), true);
                 }
                 $accounts[$account_id] = $accounts[$account_id]->as_object();
             }
             $service->accounts($accounts)->save($is_personal);
         }
     }
 }
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:40,代码来源:social-facebook.php

示例6: get_pages

 /**
  * Loads the pages for the account.
  *
  * @param  Social_Service_Account  $account
  * @param  bool                    $is_profile
  * @param  bool                    $save
  * @return array
  */
 public function get_pages(Social_Service_Account $account, $is_profile = false, $save = true)
 {
     $pages = array();
     if ($account->use_pages() or $account->use_pages(true)) {
         $response = $this->request($account, $account->id() . '/accounts');
         if ($response !== false and isset($response->body()->response)) {
             if (isset($response->body()->response->data)) {
                 foreach ($response->body()->response->data as $item) {
                     if ($item->category != 'Application') {
                         $pages[$item->id] = $item;
                     }
                 }
             } else {
                 if ($response->body()->response == 'incorrect method') {
                     // Account no longer has page permissions.
                     $service = Social::instance()->service('facebook');
                     $accounts = $service->accounts();
                     foreach ($accounts as $account_id => $_account) {
                         if ($account_id == $account->id()) {
                             $_account->use_pages(false, false);
                             $_account->use_pages(true, false);
                             $_account->pages(array(), $is_profile);
                         }
                         $accounts[$account_id] = $account->as_object();
                     }
                     if ($save) {
                         $service->accounts($accounts)->save($is_profile);
                     }
                 }
             }
         }
     }
     return $pages;
 }
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:42,代码来源:facebook.php

示例7: action_retrieve_twitter_content

 /**
  * Retrieves missing Twitter content.
  *
  * @return void
  */
 public function action_retrieve_twitter_content()
 {
     $this->verify_nonce();
     $broadcasted_id = $this->request->query('broadcasted_id');
     if ($broadcasted_id === null) {
         exit;
     }
     $post_id = $this->request->query('post_id');
     if ($post_id !== null) {
         $recovered = false;
         $run = get_post_meta('_social_run_twitter_retrieval', true);
         if (empty($run) or (int) $run <= current_time('timestamp', 1)) {
             Social::log('Running Twitter retrieval on post #:post_id for broadcasted #:broadcasted_id.', array('post_id' => $post_id, 'broadcasted_id' => $broadcasted_id));
             // Do we have accounts to use?
             $service = Social::instance()->service('twitter');
             if ($service !== false) {
                 $accounts = $service->accounts();
                 if (count($accounts)) {
                     foreach ($accounts as $account) {
                         Social::log('Using account #:account_id.', array('account_id' => $account->id()));
                         // Run the request to the find Tweet
                         $response = $service->request($account, 'statuses/show/' . $broadcasted_id);
                         if ($response !== false and $response->body()->result != 'error') {
                             $recovered = $service->recovered_meta($post_id, $broadcasted_id, $response->body()->response);
                         }
                         Social::log('Response: :response', array('response' => print_r($response, true)));
                     }
                 } else {
                     Social::log('Using public API, no accounts found.');
                     $response = wp_remote_get('http://api.twitter.com/1/statuses/show/' . $broadcasted_id . '.json');
                     if (!is_wp_error($response) and !isset($response->error)) {
                         $recovered = $service->recovered_meta($post_id, $broadcasted_id, $response);
                     }
                     Social::log('Response: :response', array('response' => print_r($response, true)));
                 }
             } else {
                 Social::log('Failed, Twitter class not found.');
             }
         }
         if (!$recovered) {
             Social::log('Failed to recover the data, try again in 15 minutes.');
             // Something went wrong, retry again in 15 minutes.
             update_post_meta($post_id, '_social_run_twitter_retrieval', current_time('timestamp', 1) + 54000);
         } else {
             if (!empty($run)) {
                 Social::log('Content found, cya!');
                 delete_post_meta($post_id, '_social_run_twitter_retrieval');
             }
         }
     }
 }
开发者ID:nick5a1,项目名称:wp-social,代码行数:56,代码来源:aggregation.php

示例8: comments_feed_exclusions

 /**
  * Filter the where clause for pulling comments for feeds (to exclude meta comments).
  *
  * @param  string  $where
  * @return string
  */
 public static function comments_feed_exclusions($where)
 {
     global $wpdb;
     $meta_types = array();
     // get services
     $services = Social::instance()->services();
     // ask each service for it's "meta" comment types
     foreach ($services as $service) {
         $meta_types = array_merge($meta_types, $service->comment_types_meta());
     }
     $meta_types = array_unique($meta_types);
     if (count($meta_types)) {
         $where .= " AND comment_type NOT IN ('" . implode("', '", array_map('social_wpdb_escape', $meta_types)) . "') ";
     }
     return $where;
 }
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:22,代码来源:social.php

示例9: foreach

     $results = $wpdb->get_results("\n\t\t\tSELECT ID\n\t\t\t  FROM {$wpdb->users}\n\t\t");
     if (is_array($results)) {
         foreach ($results as $result) {
             update_user_meta($result->ID, 'social_2.0_upgrade', true);
         }
     }
 }
 // Upgrade system_cron to fetch_comments
 $fetch = $wpdb->get_var("\n\t\tSELECT option_value\n\t\t  FROM {$wpdb->options}\n\t\t WHERE option_name = 'social_system_crons'\n\t");
 if (empty($fetch)) {
     $fetch = '1';
 }
 $wpdb->query("\n\t\tINSERT\n\t\t  INTO {$wpdb->options} (option_name, option_value)\n\t\tVALUES('social_fetch_comments', '{$fetch}')\n\t\t    ON DUPLICATE KEY UPDATE option_id = option_id\n    ");
 // Update all comment types
 $keys = array();
 foreach (Social::instance()->services() as $service) {
     $keys[] = $service->key();
     if ($service->key() == 'facebook') {
         $keys[] = 'facebook-like';
     }
 }
 foreach ($keys as $key) {
     $query = $wpdb->query("\n\t\t\tUPDATE {$wpdb->comments}\n\t\t\t   SET comment_type = 'social-{$key}'\n\t\t\t WHERE comment_type = '{$key}'\n\t\t");
 }
 // Make sure all commenter accounts have the commenter flag
 $results = $wpdb->get_results("\n\t\tSELECT m.user_id\n\t\t  FROM {$wpdb->users} AS u\n\t\t  JOIN {$wpdb->usermeta} AS m\n\t\t    ON m.user_id = u.ID\n\t\t WHERE m.meta_key = 'social_accounts'\n\t\t   AND u.user_email LIKE '%@example.com'\n    ");
 if (count($results)) {
     foreach ($results as $result) {
         update_user_meta($result->user_id, 'social_commenter', 'true');
     }
 }
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:31,代码来源:2.0.php

示例10: create_blog_post

 /**
  * Create blog post from tweet
  *
  * @param array $args 
  * @return bool
  */
 function create_blog_post($args = array())
 {
     extract($args);
     // Add a space if we have a prefix
     $title_prefix = empty($title_prefix) ? '' : trim($title_prefix) . ' ';
     $post_content = $this->link_entities(false);
     // Append image to post if there is one, can't set it as a featured image until after save
     if (!empty($this->featured_image_id)) {
         $size = apply_filters('aktt_featured_image_size', 'medium');
         $post_content .= "\n\n" . wp_get_attachment_image($this->featured_image_id, $size);
     }
     $gmt_time = self::twdate_to_time($this->date());
     // Build the post data
     $data = array('post_title' => $title_prefix . $this->title(), 'post_content' => $post_content, 'post_author' => $post_author, 'post_status' => $post_status, 'post_type' => 'post', 'post_date' => date('Y-m-d H:i:s', AKTT::gmt_to_wp_time($gmt_time)), 'post_date_gmt' => date('Y-m-d H:i:s', $gmt_time), 'guid' => $this->guid() . '-post');
     $data = apply_filters('aktt_tweet_create_blog_post_data', $data);
     // hook in here if you want to conditionally skip blog post creation
     if (!apply_filters('aktt_tweet_create_blog_post', true, $data, $this)) {
         return false;
     }
     $this->blog_post_id = wp_insert_post($data, true);
     if (is_wp_error($this->blog_post_id)) {
         AKTT::log('WP_Error:: ' . $this->blog_post_id->get_error_message());
         return false;
     }
     // have to set up taxonomies after the insert in case we are in a context without
     // a 'current user' - see: http://core.trac.wordpress.org/ticket/19373
     wp_set_object_terms($this->blog_post_id, intval($post_category), 'category');
     wp_set_object_terms($this->blog_post_id, array_map('trim', explode(',', $post_tags)), 'post_tag');
     // hook in here and return false to not set the format to "status",
     // or return another format to use that format instead of status
     if ($post_format = apply_filters('aktt_tweet_create_blog_post_format', 'status', $data, $this)) {
         set_post_format($this->blog_post_id, $post_format);
     }
     if (!empty($this->featured_image_id)) {
         update_post_meta($this->blog_post_id, '_thumbnail_id', $this->featured_image_id);
     }
     update_post_meta($this->blog_post_id, '_aktt_tweet_id', $this->id());
     // twitter's tweet ID
     update_post_meta($this->blog_post_id, '_aktt_tweet_post_id', $this->post_id);
     // twitter's post ID
     // Add it to the tweet's post_meta as well
     update_post_meta($this->post_id, '_aktt_tweet_blog_post_id', $this->blog_post_id);
     // Let Social know to aggregate info about this post
     $account = false;
     foreach (AKTT::$accounts as $aktt_account) {
         if ($aktt_account->social_acct->id() == $this->data->user->id_str) {
             $account = $aktt_account->social_acct;
             break;
         }
     }
     if ($account) {
         Social::instance()->add_broadcasted_id($this->blog_post_id, 'twitter', $this->id(), $this->content(), $account, null);
     }
     // Let the account know we were successful
     return true;
 }
开发者ID:kreapress,项目名称:wp-twitter-tools,代码行数:62,代码来源:aktt_tweet.php

示例11: apply_filters

                $service = Social::instance()->service($group);
                if ($service !== false and count($items)) {
                    $avatar_size = apply_filters('social_items_avatar_size', array('width' => 24, 'height' => 24));
                    echo Social_View::factory('comment/social_item', compact('items', 'service', 'avatar_size'));
                }
            }
            echo '</div>';
        }
        if ($last_reply_time or count($social_items)) {
            echo '<div class="cf-clearfix"></div>';
        }
        if (count($comments)) {
            ?>
				<ol class="social-commentlist">
				<?php 
            wp_list_comments(array('callback' => array(Social::instance(), 'comment'), 'walker' => new Social_Walker_Comment()), $comments);
            ?>
				</ol>
				<?php 
        }
        if (get_comment_pages_count() > 1 and get_option('page_comments')) {
            ?>
				<nav id="comment-nav-below">
					<h1 class="assistive-text"><?php 
            _e('Comment navigation', 'social');
            ?>
</h1>
					<div class="nav-previous"><?php 
            previous_comments_link(__('&larr; Older Comments', 'social'));
            ?>
</div>
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:31,代码来源:comments.php

示例12: download_tweet

 static function download_tweet($status_id, $username = null)
 {
     if (empty(AKTT::$accounts)) {
         return false;
     }
     $account_found = $tweet = false;
     if (!empty($username)) {
         AKTT::get_social_accounts();
         foreach (AKTT::$accounts as $id => $account) {
             if ($username == $account->social_acct->name()) {
                 // proper account stored as $account
                 $account_found = true;
                 break;
             }
         }
         if (!$account_found) {
             $account = AKTT::$accounts[0];
             // use any account
         }
         $response = Social::instance()->service('twitter')->request($account->social_acct, '1.1/statuses/show/' . urlencode($t->id) . '.json', array('include_entities' => 1, 'include_rts' => 1));
         $content = $response->body();
         if ($content->result == 'success') {
             $tweets = $content->response;
             if (!$tweets || !is_array($tweets) || count($tweets) != 1) {
                 $tweet = $tweet[0];
             }
         }
     }
     return $tweet;
 }
开发者ID:kreapress,项目名称:wp-twitter-tools,代码行数:30,代码来源:aktt.php

示例13: logged_in_as

 /**
  * Hook for 'comment_form_logged_in' action.
  *
  * @return string
  */
 public function logged_in_as()
 {
     $services = Social::instance()->services();
     $accounts = array();
     foreach ($services as $key => $service) {
         if (count($service->accounts())) {
             $accounts[$key] = $service->accounts();
         }
     }
     return Social_View::factory('comment/logged_in_as', array('services' => $services, 'accounts' => $accounts, 'current_user' => $this->current_user))->render();
 }
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:16,代码来源:form.php

示例14: render

 /**
  * Renders the log to HTML.
  *
  * @return Social_View
  */
 public function render()
 {
     return Social_View::factory('wp-admin/post/meta/log/output', array('log' => $this->_log, 'services' => Social::instance()->services()))->render();
 }
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:9,代码来源:log.php

示例15: checked

								</li>
								<li>
									<label for="social_disable_broadcasting">
										<input type="checkbox" name="social_disable_broadcasting" id="social_disable_broadcasting" value="1" <?php 
checked(Social::option('disable_broadcasting'), '1');
?>
 />
										<?php 
_e("Disable Social's broadcasting feature.", 'social');
?>
									</label>
								</li>
								<li>&nbsp;</li>
								<li>
									<?php 
$twitter_accounts = Social::instance()->service('twitter')->accounts();
$social_api_accounts = Social::option('social_api_accounts');
$selected_id = $social_api_accounts['twitter'];
?>
									<div class="twitter-api-account">
										<label>Twitter Default API Account</label>
										<select id="social_api_accounts-twitter" name="social_api_accounts[twitter]">
											<?php 
foreach ($twitter_accounts as $account) {
    $acct_id = $account->id();
    ?>
												<?php 
    if ($account->personal()) {
        continue;
    }
    ?>
开发者ID:Blueprint-Marketing,项目名称:interoccupy.net,代码行数:31,代码来源:options.php


注:本文中的Social::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。