本文整理汇总了PHP中Social::option方法的典型用法代码示例。如果您正苦于以下问题:PHP Social::option方法的具体用法?PHP Social::option怎么用?PHP Social::option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Social
的用法示例。
在下文中一共展示了Social::option方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
/**
* Add a message to the log.
*
* @static
* @param string $message message to add to the log
* @param array $args arguments to pass to the writer
* @param string $context context of the log message
* @param bool $backtrace show the backtrace
* @return void
*/
public function write($message, array $args = null, $context = null, $backtrace = false)
{
if (!Social::option('debug') and !in_array($context, apply_filters('social_log_contexts', array()))) {
return;
}
if ($args !== null) {
foreach ($args as $key => $value) {
$message = str_replace(':' . $key, $value, $message);
}
}
if ($context !== null) {
$context = '[' . strtoupper(str_replace('-', ' ', $context)) . '] ';
}
$error_str = $context . '[SOCIAL - ' . current_time('mysql', 1) . ' - ' . $_SERVER['REMOTE_ADDR'] . '] ' . $message;
if ($backtrace) {
ob_start();
debug_print_backtrace();
$trace = ob_get_contents();
ob_end_clean();
$error_str .= "\n\n" . $trace . "\n\n";
}
if (is_writable($this->_file)) {
error_log($error_str . "\n", 3, $this->_file);
} else {
error_log($error_str);
}
}
示例2: action_check_crons
/**
* Makes sure Social CRONs are not scheduled more than once.
*
* @return void
*/
public function action_check_crons()
{
// this is an internal only call, so manually calling URL decode
if (urldecode($this->request->query('social_api_key')) != Social::option('system_cron_api_key')) {
Social::log('API key failed');
wp_die('Oops, invalid API key.');
}
$crons = _get_cron_array();
$social_crons = array('15' => false);
foreach ($crons as $timestamp => $_crons) {
foreach ($_crons as $key => $cron) {
foreach ($social_crons as $cron_key => $status) {
$event_key = 'social_cron_' . $cron_key . '_core';
if ($key == $event_key and $social_crons[$cron_key]) {
wp_unschedule_event($timestamp, $event_key);
Social::log('Unscheduled extra event: ' . $event_key);
} else {
$social_crons[$cron_key] = true;
}
}
}
}
}
示例3: action_run
//.........这里部分代码省略.........
Social::log('Broadcasting to :username, account #:id. (:service)', array('id' => $account->id(), 'username' => $account->name(), 'service' => $service->title()));
$response = $service->broadcast($account, $message, $args, $post->ID);
if ($response !== false) {
if ($response->limit_reached()) {
if (!isset($errored_accounts[$key])) {
$errored_accounts[$key] = array();
}
$reason = __('Rate limit reached', 'social');
$errored_accounts[$key][] = (object) array('account' => $account, 'reason' => $reason, 'type' => 'limit_reached');
Social::log('Broadcasting to :username, account #:id FAILED. Reason: :reason', array('id' => $account->id(), 'username' => $account->name(), 'reason' => $reason));
} else {
if ($response->duplicate_status()) {
if (!isset($errored_accounts[$key])) {
$errored_accounts[$key] = array();
}
$reason = __('Duplicate status', 'social');
$errored_accounts[$key][] = (object) array('account' => $account, 'reason' => $reason, 'type' => 'duplicate_status');
Social::log('Broadcasting to :username, account #:id FAILED. Reason: :reason', array('id' => $account->id(), 'username' => $account->name(), 'reason' => $reason));
} else {
if ($response->deauthorized() or $response->deauthorized(true)) {
if (!isset($errored_accounts[$key])) {
$errored_accounts[$key] = array();
}
$reason = __('Account deauthorized', 'social');
$errored_accounts[$key][] = (object) array('account' => $account, 'reason' => $reason, 'deauthed' => true);
Social::log('Broadcasting to :username, account #:id FAILED. Reason: :reason', array('id' => $account->id(), 'username' => $account->name(), 'reason' => $reason));
} else {
if ($response->general_error()) {
if (!isset($errored_accounts[$key])) {
$errored_accounts[$key] = array();
}
$reason = $response->body()->response;
$errored_accounts[$key][] = (object) array('account' => $account, 'reason' => $reason, 'type' => 'general');
Social::log('Broadcasting to :username, account #:id FAILED. Reason: :reason' . "\n\n" . 'Response:' . "\n\n" . ':response', array('id' => $account->id(), 'username' => $account->name(), 'reason' => $reason, 'response' => print_r($response, true)));
} else {
if (!isset($broadcasted_ids[$key])) {
$broadcasted_ids[$key] = array();
}
$this->social->add_broadcasted_id($post->ID, $key, $response->id(), $response->message($message), $account, $response);
do_action('social_broadcast_response', $response, $key, $post);
Social::log('Broadcasting to :username, account #:id COMPLETE. (:service)', array('id' => $account->id(), 'username' => $account->name(), 'service' => $service->title()));
}
}
}
}
}
}
}
}
}
}
// Errored accounts?
if ($errored_accounts !== false) {
$deauthed_accounts = false;
$_broadcast_accounts = array();
foreach ($errored_accounts as $key => $accounts) {
foreach ($accounts as $account) {
if (isset($account->deauthed)) {
if (!isset($deauthed_accounts[$key])) {
$deauthed_accounts[$key] = array();
}
$deauthed_accounts[$key][] = $account;
}
if (isset($broadcasted_ids[$key]) and isset($broadcast_accounts[$key][$account->id])) {
if (!isset($_broadcast_accounts[$key])) {
$_broadcast_accounts[$key] = array();
}
$service = $this->social->service($key);
if ($service !== false) {
$account = $service->account($account->id);
if ($account !== false) {
$_broadcast_accounts[$key][$account->id] = (object) array('id' => $account->id, 'universal' => $account->universal());
}
}
}
}
}
update_post_meta($post->ID, '_social_broadcast_error', $errored_accounts);
if (count($_broadcast_accounts)) {
update_post_meta($post->ID, '_social_broadcast_accounts', $_broadcast_accounts);
} else {
delete_post_meta($post->ID, '_social_broadcast_accounts');
}
// Retry?
$retry = Social::option('retry_broadcast');
if (is_array($retry) and !in_array($post->ID, $retry)) {
$retry[] = $post->ID;
Social::option('retry_broadcast', $retry);
}
// Deauthed accounts?
if ($deauthed_accounts !== false or defined('XMLRPC_REQUEST')) {
if (defined('XMLRPC_REQUEST')) {
$deauthed_accounts = $errored_accounts;
}
$this->send_publish_error($post, $deauthed_accounts);
}
} else {
delete_post_meta($post->ID, '_social_broadcast_accounts');
}
}
示例4: social_key_auth
/**
* Check for auth against Social's api key
*
* @return book
*/
static function social_key_auth()
{
return (bool) (!empty($_GET['social_api_key']) && stripslashes($_GET['social_api_key']) == Social::option('system_cron_api_key'));
}
示例5: disconnect
/**
* Disconnects an account from the user's account.
*
* @param int $id
* @return void
*/
public function disconnect($id)
{
if (!is_admin() or defined('IS_PROFILE_PAGE')) {
$accounts = get_user_meta(get_current_user_id(), 'social_accounts', true);
if (isset($accounts[$this->_key][$id])) {
if (defined('IS_PROFILE_PAGE')) {
unset($accounts[$this->_key][$id]);
} else {
unset($accounts[$this->_key][$id]->user);
}
if (!count($accounts[$this->_key])) {
unset($accounts[$this->_key]);
}
update_user_meta(get_current_user_id(), 'social_accounts', $accounts);
}
} else {
$accounts = Social::option('accounts');
if (isset($accounts[$this->_key][$id])) {
unset($accounts[$this->_key][$id]);
if (!count($accounts[$this->_key])) {
unset($accounts[$this->_key]);
}
Social::option('accounts', $accounts);
}
}
do_action('social_account_disconnected', $this->_key, $id);
}
示例6: _e
?>
" id="import_from_url" class="button"><?php
_e('Import Tweet', 'social');
?>
</a>
</span>
<img src="<?php
echo esc_url(admin_url('images/wpspin_light.gif'));
?>
" style="position:relative;top:4px;left:0;display:none" id="import_from_url_loader" />
<span id="social-import-error"></span>
</p>
</div><!-- .social-meta-box-block -->
<?php
if (in_array(Social::option('fetch_comments'), array('1', '2'))) {
?>
<div class="social-meta-box-block cf-clearfix">
<h4>
<?php
_e('Manual Refresh', 'social');
?>
<span id="social-next-run">(<?php
echo sprintf(__('Next automatic run <span>%s</span>', 'social'), $next_run);
?>
)</span>
</h4>
<p class="submit" style="clear:both;float:none;padding:0;">
<a href="<?php
echo esc_url(wp_nonce_url(admin_url('index.php?social_controller=aggregation&social_action=run&post_id=' . $post->ID), 'run'));
示例7: _e
?>
" id="import_from_url" class="button"><?php
_e('Import Tweet', 'social');
?>
</a>
</span>
<img src="<?php
echo esc_url(admin_url('images/wpspin_light.gif'));
?>
" style="position:relative;top:4px;left:0;display:none" id="import_from_url_loader" />
<span id="social-import-error"></span>
</p>
</div><!-- .social-meta-box-block -->
<?php
if (Social::option('aggregate_comments')) {
?>
<div class="social-meta-box-block cf-clearfix">
<h4>
<?php
_e('Manual Refresh', 'social');
?>
<span id="social-next-run">(<?php
echo sprintf(__('Next automatic run <span>%s</span>', 'social'), $next_run);
?>
)</span>
</h4>
<p class="submit" style="clear:both;float:none;padding:0;">
<a href="<?php
echo esc_url(wp_nonce_url(admin_url('options-general.php?social_controller=aggregation&social_action=run&post_id=' . $post->ID), 'run'));
示例8: action_run
/**
* Runs the aggregation for the requested post ID.
*
* @return void
*/
public function action_run()
{
$this->verify_nonce();
$fetch = Social::option('fetch_comments');
if (empty($fetch)) {
Social::log('Aggregation has been disabled, exiting.');
return;
}
$post = get_post($this->request->query('post_id'));
if ($post === null) {
return;
}
Social::log('Begin aggregation for post #:post_id.', array('post_id' => $post->ID));
// Get URLs to query
$default_urls = array(home_url('?p=' . $post->ID));
$url = wp_get_shortlink($post->ID);
if (strpos($url, '?p=') === false) {
$default_urls[] = $url;
}
// Add the permalink?
$permalink = get_permalink($post->ID);
if ($default_urls[0] != $permalink) {
$default_urls[] = $permalink;
}
$broadcasted_ids = get_post_meta($post->ID, '_social_broadcasted_ids', true);
if (empty($broadcasted_ids)) {
$broadcasted_ids = array();
}
$aggregated_ids = get_post_meta($post->ID, '_social_aggregated_ids', true);
if (empty($aggregated_ids)) {
$aggregated_ids = array();
}
$post->broadcasted_ids = $broadcasted_ids;
$post->aggregated_ids = $aggregated_ids;
$post->results = array();
foreach ($this->social->services() as $key => $service) {
$urls = $default_urls;
$post->results[$key] = array();
if (!isset($post->aggregated_ids[$key])) {
$post->aggregated_ids[$key] = array();
}
if (isset($broadcasted_ids[$key]) and count($broadcasted_ids[$key])) {
$service->aggregate_by_api($post);
foreach ($broadcasted_ids[$key] as $broadcasted) {
foreach ($broadcasted as $data) {
if (isset($data['urls']) and is_array($data['urls'])) {
foreach ($data['urls'] as $url) {
$urls[] = $url;
}
}
}
}
}
// URL Search
$urls = apply_filters('social_search_urls', $urls, $key);
$urls = array_unique($urls);
if (count($urls)) {
foreach ($urls as $key => $url) {
$urls[$key] = urlencode($url);
}
$service->aggregate_by_url($post, $urls);
}
}
if (count($post->results)) {
foreach ($post->results as $key => $results) {
if (count($results)) {
$this->social->service($key)->save_aggregated_comments($post);
}
}
update_post_meta($post->ID, '_social_aggregated_ids', $post->aggregated_ids);
}
Social::log('Aggregation for post #:post_id complete.', array('post_id' => $post->ID));
// Some cleanup...
unset($post->broadcasted_ids);
unset($post->aggregated_ids);
unset($post->results);
if ($this->request->is_ajax()) {
// Re-add to the queue?
$queue = Social_Aggregation_Queue::factory();
if (!$queue->find($post->ID)) {
$queue->add($post->ID, '24hr')->save();
}
$log = Social_Aggregation_Log::instance($post->ID);
$log->save(true);
if (isset($_GET['render']) and $_GET['render'] == 'false') {
$total = 0;
$log = $log->current();
if (isset($log->items)) {
foreach ($log->items as $service => $items) {
foreach ($items as $item) {
if (!$item->ignored) {
++$total;
}
}
}
//.........这里部分代码省略.........
示例9: enqueue_assets
/**
* Enqueues the @Anywhere script.
*
* @static
* @return void
*/
public static function enqueue_assets()
{
$api_key = Social::option('twitter_anywhere_api_key');
if (!empty($api_key)) {
wp_enqueue_script('twitter_anywhere', 'http://platform.twitter.com/anywhere.js?id=' . $api_key, array('social_js'), Social::$version, true);
}
}
示例10: action_regenerate_api_key
/**
* Regenerates the API key.
*
* @return void
*/
public function action_regenerate_api_key()
{
$this->verify_nonce();
if (!$this->request->is_ajax()) {
wp_die('Oops, this method can only be accessed via an AJAX request.');
}
$key = wp_generate_password(16, false);
Social::option('system_cron_api_key', $key, true);
echo $key;
exit;
}
示例11: save
/**
* Saves the queue.
*
* @return void
*/
public function save()
{
Social::option('aggregation_queue', $this->_queue);
}
示例12: _e
<ul>
<li>
<label for="debug_mode_no">
<input type="radio" name="social_debug" id="debug_mode_no" value="0"<?php
echo Social::option('debug') != '1' ? ' checked="checked"' : '';
?>
/>
<?php
_e('Off <span class="description">(recommended)</span>', 'social');
?>
</label>
</li>
<li>
<label for="debug_mode_yes">
<input type="radio" name="social_debug" id="debug_mode_yes" value="1"<?php
echo Social::option('debug') == '1' ? ' checked="checked"' : '';
?>
/>
<?php
_e('On <span class="description">(for troubleshooting)</span>', 'social');
?>
</label>
</li>
</ul>
<strong><?php
_e('Debug log location:', 'social');
?>
</strong> <code><?php
echo Social::$plugins_path . 'debug_log.txt';
?>
示例13: get_comment_author_link
/**
* Adds the account ID to the rel for the author link.
*
* @static
* @param string $url
* @return string
*/
public static function get_comment_author_link($url)
{
if (Social::option('use_standard_comments') == '1') {
return $url;
}
global $comment;
if (in_array($comment->comment_type, self::comment_types())) {
$status_id = get_comment_meta($comment->comment_ID, 'social_status_id', true);
$output = str_replace("rel='", "rel='" . $status_id . " ", $url);
$api_key = Social::option('twitter_anywhere_api_key');
if (!empty($api_key)) {
$output = str_replace("'>", "' style='display:none'>@", $output);
$output .= '@' . get_comment_author($comment->comment_ID);
} else {
$output = str_replace("'>", "'>@", $output);
}
return $output;
}
return $url;
}
示例14: broadcast
/**
* Broadcasts the message to the specified account. Returns the broadcasted ID.
*
* @param Social_Service_Facebook_Account|object $account account to broadcast to
* @param string $message message to broadcast
* @param array $args extra arguments to pass to the request
* @param int $post_id post ID being broadcasted
* @param int $comment_id comment ID being broadcasted
*
* @return Social_Response
*/
public function broadcast($account, $message, array $args = array(), $post_id = null, $comment_id = null)
{
global $post;
// if post ID is set, this is a broadcast of a post,
// if the comment ID is set it is a broadcast of a comment
// TODO - add wrapper functions that abstract these actions out to separate methods
// check comment being replied to, if it is a facebook comment on a post then
// send the comment as a reply on the same post.
// If that fails, then send as posting a link with a comment.
$args = $args + array('message' => $message);
// first try to send comment to an existing Fb post
if (!is_null($comment_id)) {
$comment = get_comment($comment_id);
if (!empty($comment->comment_parent)) {
$parent_comment = get_comment($comment->comment_parent);
if (!is_null($parent_comment) && in_array($parent_comment->comment_type, self::comment_types())) {
$status_id = get_comment_meta($parent_comment->comment_ID, 'social_status_id', true);
if (!empty($status_id)) {
// we have a Facebook post to reply to
$parts = explode('_', $status_id);
if (count($parts) == 3) {
$status_id = $parts[0] . '_' . $parts[1];
}
$args = apply_filters($this->key() . '_broadcast_args', $args, $post_id, $comment_id);
$response = $this->request($account, $status_id . '/comments', $args, 'POST');
if ($response !== false && $response->id() !== '0') {
// post succeeded, return response
return $response;
}
// ...broadcast failed, continue and send as post to feed
}
}
}
// posting with a link, do not include URL in comment.
$format = trim(str_replace('{url}', '', Social::option('comment_broadcast_format')));
$message = $this->format_comment_content($comment, $format);
$args['message'] = $message;
// prep data
$post = get_post($comment->comment_post_ID);
setup_postdata($post);
$link_args = array('link' => get_post_permalink($post->ID), 'title' => get_the_title($post->ID), 'description' => get_the_excerpt());
if (function_exists('has_post_thumbnail') and has_post_thumbnail($post->ID)) {
$image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail');
$link_args = $link_args + array('picture' => $image[0]);
}
wp_reset_postdata();
$args = $args + $link_args;
}
// Set access token?
$broadcast_account = $account->broadcast_page();
if ($broadcast_account !== null) {
$args = $args + array('access_token' => $broadcast_account->access_token, 'page_id' => $broadcast_account->id);
}
$args = apply_filters($this->key() . '_broadcast_args', $args, $post_id, $comment_id);
return $this->request($account, 'me/feed', $args, 'POST');
}
示例15: array
}
}
} else {
$_meta_value[$service_key][$account_id][$broadcasted] = array('message' => '');
}
}
}
if (!empty($_meta_value)) {
update_post_meta($result->post_id, '_social_broadcasted_ids', $_meta_value);
}
Social::log('New meta value for post #:post_id: :meta_value', array('post_id' => $result->post_id, 'meta_value' => print_r($_meta_value, true)));
}
}
}
// Add broadcast by default
Social::option('broadcast_by_default', '0');
// Reschedule posts for aggregation
$results = $wpdb->get_results("\n\t\tSELECT post_id\n\t\tFROM {$wpdb->postmeta}\n\t\tWHERE meta_key = '_social_broadcasted_ids'\n\t\tORDER BY post_id DESC\n\t\tLIMIT 50\n\t");
if ($results !== null) {
$queue = Social_Aggregation_Queue::factory();
foreach ($results as $result) {
if (!$queue->find($result->post_id)) {
$queue->add($result->post_id);
}
}
$queue->save();
}
// Fix comment author urls for Facebook comments...
$results = $wpdb->get_results("\n\t\tSELECT comment_ID, comment_author_url\n\t\tFROM {$wpdb->comments}\n\t\tWHERE comment_type = 'social-facebook'\n\t\tAND comment_author_url LIKE 'http://graph.facebook.com/%'\n\t");
foreach ($results as $result) {
$url = explode('http://graph.facebook.com/', $result->comment_author_url);