本文整理汇总了PHP中Sharing_Service::get_global_options方法的典型用法代码示例。如果您正苦于以下问题:PHP Sharing_Service::get_global_options方法的具体用法?PHP Sharing_Service::get_global_options怎么用?PHP Sharing_Service::get_global_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sharing_Service
的用法示例。
在下文中一共展示了Sharing_Service::get_global_options方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output
public function output()
{
global $post;
if (!function_exists('sharing_display')) {
return;
}
$buttons = sharing_display('');
if ('' == $buttons) {
return;
}
$sharer = new Sharing_Service();
$global = $sharer->get_global_options();
$sharing = '';
$sharing .= sprintf('<a href="#share-%d" class="popup-trigger"><i class="ion-share"></i> %s</a>', $post->ID, __('Share', 'listify'));
$sharing .= sprintf('<div class="popup share-popup" id="share-%1$d">
<h3 class="popup-title">%2$s</h3>
%3$s
</div>', $post->ID, $global['sharing_label'], $buttons);
echo $sharing;
}
示例2: sharing_display
function sharing_display($text = '', $echo = false)
{
global $post, $wp_current_filter;
if (empty($post)) {
return $text;
}
if ((is_preview() || is_admin()) && !(defined('DOING_AJAX') && DOING_AJAX)) {
return $text;
}
// Don't output flair on excerpts
if (in_array('get_the_excerpt', (array) $wp_current_filter)) {
return $text;
}
// Don't allow flair to be added to the_content more than once (prevent infinite loops)
$done = false;
foreach ($wp_current_filter as $filter) {
if ('the_content' == $filter) {
if ($done) {
return $text;
} else {
$done = true;
}
}
}
// check whether we are viewing the front page and whether the front page option is checked
$options = get_option('sharing-options');
$display_options = $options['global']['show'];
if (is_front_page() && (is_array($display_options) && !in_array('index', $display_options))) {
return $text;
}
if (is_attachment() && in_array('the_excerpt', (array) $wp_current_filter)) {
// Many themes run the_excerpt() conditionally on an attachment page, then run the_content().
// We only want to output the sharing buttons once. Let's stick with the_content().
return $text;
}
$sharer = new Sharing_Service();
$global = $sharer->get_global_options();
$show = false;
if (!is_feed()) {
if (is_singular() && in_array(get_post_type(), $global['show'])) {
$show = true;
} elseif (in_array('index', $global['show']) && (is_home() || is_front_page() || is_archive() || is_search() || in_array(get_post_type(), $global['show']))) {
$show = true;
}
}
/**
* Filter to decide if sharing buttons should be displayed.
*
* @module sharedaddy
*
* @since 1.1.0
*
* @param bool $show Should the sharing buttons be displayed.
* @param WP_Post $post The post to share.
*/
$show = apply_filters('sharing_show', $show, $post);
// Disabled for this post?
$switched_status = get_post_meta($post->ID, 'sharing_disabled', false);
if (!empty($switched_status)) {
$show = false;
}
// Private post?
$post_status = get_post_status($post->ID);
if ('private' === $post_status) {
$show = false;
}
// Allow to be used on P2 ajax requests for latest posts.
if (defined('DOING_AJAX') && DOING_AJAX && isset($_REQUEST['action']) && 'get_latest_posts' == $_REQUEST['action']) {
$show = true;
}
$sharing_content = '';
if ($show) {
/**
* Filters the list of enabled Sharing Services.
*
* @module sharedaddy
*
* @since 2.2.3
*
* @param array $sharer->get_blog_services() Array of Sharing Services currently enabled.
*/
$enabled = apply_filters('sharing_enabled', $sharer->get_blog_services());
if (count($enabled['all']) > 0) {
global $post;
$dir = get_option('text_direction');
// Wrapper
$sharing_content .= '<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-' . $global['button_style'] . ' sd-sharing">';
if ($global['sharing_label'] != '') {
$sharing_content .= '<h3 class="sd-title">' . $global['sharing_label'] . '</h3>';
}
$sharing_content .= '<div class="sd-content"><ul>';
// Visible items
$visible = '';
foreach ($enabled['visible'] as $id => $service) {
// Individual HTML for sharing service
$visible .= '<li class="share-' . $service->get_class() . '">' . $service->get_display($post) . '</li>';
}
$parts = array();
$parts[] = $visible;
if (count($enabled['hidden']) > 0) {
//.........这里部分代码省略.........
示例3: update_settings
//.........这里部分代码省略.........
// settings are stored as on|off
$coerce_value = $value ? 'on' : 'off';
if (update_option($key, $coerce_value)) {
$updated[$key] = $value;
}
break;
case 'wga':
if (!isset($value['code']) || !preg_match('/^$|^UA-[\\d-]+$/i', $value['code'])) {
return new WP_Error('invalid_code', 'Invalid UA ID');
}
$wga = get_option('wga', array());
$wga['code'] = $value['code'];
// maintain compatibility with wp-google-analytics
if (update_option('wga', $wga)) {
$updated[$key] = $value;
}
$enabled_or_disabled = $wga['code'] ? 'enabled' : 'disabled';
do_action('jetpack_bump_stats_extras', 'google-analytics', $enabled_or_disabled);
$business_plugins = WPCOM_Business_Plugins::instance();
$business_plugins->activate_plugin('wp-google-analytics');
break;
case 'jetpack_comment_likes_enabled':
// settings are stored as 1|0
$coerce_value = (int) $value;
if (update_option($key, $coerce_value)) {
$updated[$key] = $value;
}
break;
// Sharing options
// Sharing options
case 'sharing_button_style':
case 'sharing_show':
case 'sharing_open_links':
$sharing_options[preg_replace('/^sharing_/', '', $key)] = $value;
break;
case 'sharing_label':
$sharing_options[$key] = $value;
break;
// Keyring token option
// Keyring token option
case 'eventbrite_api_token':
// These options can only be updated for sites hosted on WordPress.com
if (defined('IS_WPCOM') && IS_WPCOM) {
if (empty($value) || WPCOM_JSON_API::is_falsy($value)) {
if (delete_option($key)) {
$updated[$key] = null;
}
} else {
if (update_option($key, $value)) {
$updated[$key] = (int) $value;
}
}
}
break;
// no worries, we've already whitelisted and casted arguments above
// no worries, we've already whitelisted and casted arguments above
default:
if (update_option($key, $value)) {
$updated[$key] = $value;
}
}
}
if (count($jetpack_relatedposts_options)) {
// track new jetpack_relatedposts options against old
$old_relatedposts_options = Jetpack_Options::get_option('relatedposts');
if (Jetpack_Options::update_option('relatedposts', $jetpack_relatedposts_options)) {
foreach ($jetpack_relatedposts_options as $key => $value) {
if ($value !== $old_relatedposts_options[$key]) {
$updated['jetpack_relatedposts_' . $key] = $value;
}
}
}
}
if (!empty($sharing_options) && class_exists('Sharing_Service')) {
$ss = new Sharing_Service();
// Merge current values with updated, since Sharing_Service expects
// all values to be included when updating
$current_sharing_options = $ss->get_global_options();
foreach ($current_sharing_options as $key => $val) {
if (!isset($sharing_options[$key])) {
$sharing_options[$key] = $val;
}
}
$updated_social_options = $ss->set_global_options($sharing_options);
if (isset($input['sharing_button_style'])) {
$updated['sharing_button_style'] = (string) $updated_social_options['button_style'];
}
if (isset($input['sharing_label'])) {
// Sharing_Service won't report label as updated if set to default
$updated['sharing_label'] = (string) $sharing_options['sharing_label'];
}
if (isset($input['sharing_show'])) {
$updated['sharing_show'] = (array) $updated_social_options['show'];
}
if (isset($input['sharing_open_links'])) {
$updated['sharing_open_links'] = (string) $updated_social_options['open_links'];
}
}
return array('updated' => $updated);
}
开发者ID:annbransom,项目名称:techishowl_prod_backup,代码行数:101,代码来源:class.wpcom-json-api-site-settings-endpoint.php
示例4: management_page
public function management_page()
{
$sharer = new Sharing_Service();
$enabled = $sharer->get_blog_services();
$global = $sharer->get_global_options();
$shows = array_values(get_post_types(array('public' => true)));
array_unshift($shows, 'index');
if (false == function_exists('mb_stripos')) {
echo '<div id="message" class="updated fade"><h3>' . __('Warning! Multibyte support missing!', 'jetpack') . '</h3>';
echo "<p>" . sprintf(__('This plugin will work without it, but multibyte support is used <a href="%s">if available</a>. You may see minor problems with Tweets and other sharing services.', 'jetpack'), "http://www.php.net/manual/en/mbstring.installation.php") . '</p></div>';
}
if (isset($_GET['update']) && $_GET['update'] == 'saved') {
echo '<div class="updated"><p>' . __('Settings have been saved', 'jetpack') . '</p></div>';
}
?>
<div class="wrap">
<div class="icon32" id="icon-options-general"><br /></div>
<h2><?php
_e('Sharing Settings', 'jetpack');
?>
</h2>
<div id="services-config">
<table id="available-services">
<tr>
<td class="description">
<h3><?php
_e('Available Services', 'jetpack');
?>
</h3>
<p><?php
_e("Drag and drop the services you'd like to enable into the box below.", 'jetpack');
?>
</p>
<p><a href="#TB_inline?height=395&width=600&inlineId=new-service" title="<?php
echo esc_attr(__('Add a new service', 'jetpack'));
?>
" class="thickbox"><?php
_e('Add a new service', 'jetpack');
?>
</a></p>
</td>
<td class="services">
<ul class="services-available" style="height: 100px;">
<?php
foreach ($sharer->get_all_services_blog() as $id => $service) {
?>
<?php
if (!isset($enabled['all'][$id])) {
$this->output_service($id, $service);
}
?>
<?php
}
?>
</ul>
<br class="clearing" />
</td>
</tr>
</table>
<table id="enabled-services">
<tr>
<td class="description">
<h3>
<?php
_e('Enabled Services', 'jetpack');
?>
<img src="<?php
echo admin_url('images/loading.gif');
?>
" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
</h3>
<p><?php
_e('Services dragged here will appear individually.', 'jetpack');
?>
</p>
</td>
<td class="services" id="share-drop-target">
<h2 id="drag-instructions" <?php
if (count($enabled['visible']) > 0) {
echo ' style="display: none"';
}
?>
><?php
_e('Drag and drop available services here', 'jetpack');
?>
</h2>
<ul class="services-enabled">
<?php
foreach ($enabled['visible'] as $id => $service) {
?>
<?php
$this->output_service($id, $service, true);
?>
<?php
}
?>
//.........这里部分代码省略.........
示例5: management_page
public function management_page()
{
$sharer = new Sharing_Service();
$enabled = $sharer->get_blog_services();
$global = $sharer->get_global_options();
$shows = array_values(get_post_types(array('public' => true)));
array_unshift($shows, 'index');
if (false == function_exists('mb_stripos')) {
echo '<div id="message" class="updated fade"><h3>' . __('Warning! Multibyte support missing!', 'jetpack') . '</h3>';
echo "<p>" . sprintf(__('This plugin will work without it, but multibyte support is used <a href="%s">if available</a>. You may see minor problems with Tweets and other sharing services.', 'jetpack'), "http://www.php.net/manual/en/mbstring.installation.php") . '</p></div>';
}
if (isset($_GET['update']) && $_GET['update'] == 'saved') {
echo '<div class="updated"><p>' . __('Settings have been saved', 'jetpack') . '</p></div>';
}
if (!isset($global['sharing_label'])) {
$global['sharing_label'] = __('Share this:', 'jetpack');
}
?>
<div class="wrap">
<div class="icon32" id="icon-options-general"><br /></div>
<h2><?php
_e('Sharing Settings', 'jetpack');
?>
</h2>
<?php
/**
* Fires at the top of the admin sharing settings screen.
*
* @since 1.6.0
*/
do_action('pre_admin_screen_sharing');
?>
<?php
if (current_user_can('manage_options')) {
?>
<div class="share_manage_options">
<h3><?php
_e('Sharing Buttons', 'jetpack');
?>
</h3>
<p><?php
_e('Add sharing buttons to your blog and allow your visitors to share posts with their friends.', 'jetpack');
?>
</p>
<div id="services-config">
<table id="available-services">
<tr>
<td class="description">
<h3><?php
_e('Available Services', 'jetpack');
?>
</h3>
<p><?php
_e("Drag and drop the services you'd like to enable into the box below.", 'jetpack');
?>
</p>
<p><a href="#TB_inline?height=395&width=600&inlineId=new-service" class="thickbox" id="add-a-new-service"><?php
_e('Add a new service', 'jetpack');
?>
</a></p>
</td>
<td class="services">
<ul class="services-available" style="height: 100px;">
<?php
foreach ($sharer->get_all_services_blog() as $id => $service) {
?>
<?php
if (!isset($enabled['all'][$id])) {
$this->output_service($id, $service);
}
?>
<?php
}
?>
</ul>
<?php
if (-1 == get_option('blog_public')) {
echo '<p><strong>' . __('Please note that your services have been restricted because your site is private.', 'jetpack') . '</strong></p>';
}
?>
<br class="clearing" />
</td>
</tr>
</table>
<table id="enabled-services">
<tr>
<td class="description">
<h3>
<?php
_e('Enabled Services', 'jetpack');
?>
<img src="<?php
echo admin_url('images/loading.gif');
?>
//.........这里部分代码省略.........
示例6: prepare_options_for_response
/**
* Remove 'validate_callback' item from options available for module.
* Fetch current option value and add to array of module options.
* Prepare values of module options that need special handling, like those saved in wpcom.
*
* @since 4.3.0
*
* @param string $module Module slug.
* @return array
*/
public static function prepare_options_for_response($module = '')
{
$options = self::get_module_available_options($module);
if (!is_array($options) || empty($options)) {
return $options;
}
foreach ($options as $key => $value) {
if (isset($options[$key]['validate_callback'])) {
unset($options[$key]['validate_callback']);
}
$default_value = isset($options[$key]['default']) ? $options[$key]['default'] : '';
$current_value = get_option($key, $default_value);
$options[$key]['current_value'] = self::cast_value($current_value, $options[$key]);
}
// Some modules need special treatment.
switch ($module) {
case 'monitor':
// Status of user notifications
$options['monitor_receive_notifications']['current_value'] = self::cast_value(self::get_remote_value('monitor', 'monitor_receive_notifications'), $options['monitor_receive_notifications']);
break;
case 'post-by-email':
// Email address
$options['post_by_email_address']['current_value'] = self::cast_value(self::get_remote_value('post-by-email', 'post_by_email_address'), $options['post_by_email_address']);
break;
case 'protect':
// Protect
$options['jetpack_protect_key']['current_value'] = get_site_option('jetpack_protect_key', false);
if (!function_exists('jetpack_protect_format_whitelist')) {
@(include JETPACK__PLUGIN_DIR . 'modules/protect/shared-functions.php');
}
$options['jetpack_protect_global_whitelist']['current_value'] = jetpack_protect_format_whitelist();
break;
case 'related-posts':
// It's local, but it must be broken apart since it's saved as an array.
$options = self::split_options($options, Jetpack_Options::get_option('relatedposts'));
break;
case 'verification-tools':
// It's local, but it must be broken apart since it's saved as an array.
$options = self::split_options($options, get_option('verification_services_codes'));
break;
case 'sharedaddy':
// It's local, but it must be broken apart since it's saved as an array.
if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
break;
}
$sharer = new Sharing_Service();
$options = self::split_options($options, $sharer->get_global_options());
$options['sharing_services']['current_value'] = $sharer->get_blog_services();
break;
case 'site-icon':
// Return site icon ID and URL to make it more complete.
$options['site_icon_id']['current_value'] = Jetpack_Options::get_option('site_icon_id');
if (!function_exists('jetpack_site_icon_url')) {
@(include JETPACK__PLUGIN_DIR . 'modules/site-icon/site-icon-functions.php');
}
$options['site_icon_url']['current_value'] = jetpack_site_icon_url();
break;
case 'after-the-deadline':
if (!function_exists('AtD_get_options')) {
@(include JETPACK__PLUGIN_DIR . 'modules/after-the-deadline.php');
}
$atd_options = array_merge(AtD_get_options(get_current_user_id(), 'AtD_options'), AtD_get_options(get_current_user_id(), 'AtD_check_when'));
unset($atd_options['name']);
foreach ($atd_options as $key => $value) {
$options[$key]['current_value'] = self::cast_value($value, $options[$key]);
}
$atd_options = AtD_get_options(get_current_user_id(), 'AtD_guess_lang');
$options['guess_lang']['current_value'] = self::cast_value(isset($atd_options['true']), $options['guess_lang']);
$options['ignored_phrases']['current_value'] = AtD_get_setting(get_current_user_id(), 'AtD_ignored_phrases');
unset($options['unignore_phrase']);
break;
case 'minileven':
$options['wp_mobile_excerpt']['current_value'] = 1 === intval($options['wp_mobile_excerpt']['current_value']) ? 'enabled' : 'disabled';
$options['wp_mobile_featured_images']['current_value'] = 1 === intval($options['wp_mobile_featured_images']['current_value']) ? 'enabled' : 'disabled';
break;
case 'stats':
// It's local, but it must be broken apart since it's saved as an array.
if (!function_exists('stats_get_options')) {
@(include JETPACK__PLUGIN_DIR . 'modules/stats.php');
}
$options = self::split_options($options, stats_get_options());
break;
}
return $options;
}
示例7: update_data
//.........这里部分代码省略.........
}
break;
case 'show_headline':
case 'show_thumbnails':
$grouped_options = $grouped_options_current = (array) Jetpack_Options::get_option('relatedposts');
$grouped_options[$option] = $value;
// If option value was the same, consider it done.
$updated = $grouped_options_current != $grouped_options ? Jetpack_Options::update_option('relatedposts', $grouped_options) : true;
break;
case 'google':
case 'bing':
case 'pinterest':
case 'yandex':
$grouped_options = $grouped_options_current = (array) get_option('verification_services_codes');
$grouped_options[$option] = $value;
// If option value was the same, consider it done.
$updated = $grouped_options_current != $grouped_options ? update_option('verification_services_codes', $grouped_options) : true;
break;
case 'sharing_services':
if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
break;
}
$sharer = new Sharing_Service();
// If option value was the same, consider it done.
$updated = $value != $sharer->get_blog_services() ? $sharer->set_blog_services($value['visible'], $value['hidden']) : true;
break;
case 'button_style':
case 'sharing_label':
case 'show':
if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
break;
}
$sharer = new Sharing_Service();
$grouped_options = $sharer->get_global_options();
$grouped_options[$option] = $value;
$updated = $sharer->set_global_options($grouped_options);
break;
case 'custom':
if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
break;
}
$sharer = new Sharing_Service();
$updated = $sharer->new_service(stripslashes($value['sharing_name']), stripslashes($value['sharing_url']), stripslashes($value['sharing_icon']));
// Return new custom service
$response[$option] = $updated;
break;
case 'sharing_delete_service':
if (!class_exists('Sharing_Service') && !@(include JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php')) {
break;
}
$sharer = new Sharing_Service();
$updated = $sharer->delete_service($value);
break;
case 'jetpack-twitter-cards-site-tag':
$value = trim(ltrim(strip_tags($value), '@'));
$updated = get_option($option) !== $value ? update_option($option, $value) : true;
break;
case 'onpublish':
case 'onupdate':
case 'Bias Language':
case 'Cliches':
case 'Complex Expression':
case 'Diacritical Marks':
case 'Double Negative':
case 'Hidden Verbs':
case 'Jargon Language':
示例8: sharing_display
function sharing_display($text = '')
{
static $shared_with_posts = array();
global $post;
$sharer = new Sharing_Service();
$global = $sharer->get_global_options();
$show = false;
if (!is_feed()) {
if ($global['show'] == 'posts' && (is_single() || is_page())) {
$show = true;
} elseif ($global['show'] == 'index' && (is_home() || is_archive() || is_search())) {
$show = true;
} elseif ($global['show'] == 'posts-index' && (is_single() || is_page() || is_home() || is_search() || is_archive())) {
$show = true;
}
}
// Pass through a filter for final say so
$show = apply_filters('sharing_show', $show, $post);
// Disabled for this post?
$switched_status = get_post_meta($post->ID, 'sharing_disabled', false);
if (!empty($switched_status)) {
$show = false;
}
// Only show once
if (isset($shared_with_posts[$post->ID])) {
$show = false;
}
$shared_with_posts[$post->ID] = true;
$sharing_content = '';
if ($show) {
$enabled = $sharer->get_blog_services();
if (count($enabled['all']) > 0) {
global $post;
$dir = get_option('text_direction');
// Wrapper
$sharing_content .= '<div class="snap_nopreview sharing robots-nocontent">';
$sharing_content .= '<ul>';
// Visible items
$visible = '';
foreach ($enabled['visible'] as $id => $service) {
// Individual HTML for sharing service
$visible .= '<li class="share-' . $service->get_class() . ' share-regular">';
$visible .= $service->get_display($post);
$visible .= '</li>';
}
$parts = array();
if ($global['sharing_label'] != '') {
$parts[] = '<li class="sharing_label">' . $global['sharing_label'] . '</li>';
}
$parts[] = $visible;
if (count($enabled['hidden']) > 0) {
$parts[] = '<li class="share-custom"><a href="#" class="sharing-anchor">' . _x('Share', 'dropdown button', 'jetpack') . '</a></li>';
}
if ($dir == 'rtl') {
$parts = array_reverse($parts);
}
$sharing_content .= implode('', $parts);
$sharing_content .= '<li class="share-end"></li></ul>';
if (count($enabled['hidden']) > 0) {
$sharing_content .= '<div class="sharing-hidden"><div class="inner" style="display: none;';
if (count($enabled['hidden']) == 1) {
$sharing_content .= 'width:150px;';
}
$sharing_content .= '">';
if (count($enabled['hidden']) == 1) {
$sharing_content .= '<ul style="background-image:none;">';
} else {
$sharing_content .= '<ul>';
}
$count = 1;
foreach ($enabled['hidden'] as $id => $service) {
// Individual HTML for sharing service
$sharing_content .= '<li class="share-' . $service->get_class() . '">';
$sharing_content .= $service->get_display($post);
$sharing_content .= '</li>';
if ($count % 2 == 0) {
$sharing_content .= '<li class="share-end"></li>';
}
$count++;
}
// End of wrapper
$sharing_content .= '<li class="share-end"></li></ul></div></div>';
}
$sharing_content .= '<div class="sharing-clear"></div></div>';
// Register our JS
wp_register_script('sharing-js', plugin_dir_url(__FILE__) . 'sharing.js', array('jquery'), '0.1');
add_action('wp_footer', 'sharing_add_footer');
}
}
return $text . $sharing_content;
}
示例9: sharing_display
function sharing_display( $text = '' ) {
global $post, $wp_current_filter;
if ( is_preview() ) {
return $text;
}
// Don't output flair on excerpts
if ( in_array( 'get_the_excerpt', (array) $wp_current_filter ) ) {
return $text;
}
// Don't allow flair to be added to the_content more than once (prevent infinite loops)
$done = false;
foreach ( $wp_current_filter as $filter ) {
if ( 'the_content' == $filter ) {
if ( $done )
return $text;
else
$done = true;
}
}
// check whether we are viewing the front page and whether the front page option is checked
$options = get_option( 'sharing-options' );
$display_options = $options['global']['show'];
if ( is_front_page() && ( is_array( $display_options ) && ! in_array( 'index', $display_options ) ) )
return $text;
if ( is_attachment() && in_array( 'the_excerpt', (array) $wp_current_filter ) ) {
// Many themes run the_excerpt() conditionally on an attachment page, then run the_content().
// We only want to output the sharing buttons once. Let's stick with the_content().
return $text;
}
$sharer = new Sharing_Service();
$global = $sharer->get_global_options();
$show = false;
if ( !is_feed() ) {
if ( is_singular() && in_array( get_post_type(), $global['show'] ) ) {
$show = true;
} elseif ( in_array( 'index', $global['show'] ) && ( is_home() || is_archive() || is_search() ) ) {
$show = true;
}
}
// Pass through a filter for final say so
$show = apply_filters( 'sharing_show', $show, $post );
// Disabled for this post?
$switched_status = get_post_meta( $post->ID, 'sharing_disabled', false );
if ( !empty( $switched_status ) )
$show = false;
// Allow to be used on P2 ajax requests for latest posts.
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['action'] ) && 'get_latest_posts' == $_REQUEST['action'] )
$show = true;
$sharing_content = '';
if ( $show ) {
$enabled = $sharer->get_blog_services();
if ( count( $enabled['all'] ) > 0 ) {
global $post;
$dir = get_option( 'text_direction' );
// Wrapper
$sharing_content .= '<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-' . $global['button_style'] . ' sd-sharing">';
if ( $global['sharing_label'] != '' )
$sharing_content .= '<h3 class="sd-title">' . $global['sharing_label'] . '</h3>';
$sharing_content .= '<div class="sd-content"><ul>';
// Visible items
$visible = '';
foreach ( $enabled['visible'] as $id => $service ) {
// Individual HTML for sharing service
$visible .= '<li class="share-' . $service->get_class() . '">' . $service->get_display( $post ) . '</li>';
}
$parts = array();
$parts[] = $visible;
if ( count( $enabled['hidden'] ) > 0 ) {
if ( count( $enabled['visible'] ) > 0 )
$expand = __( 'More', 'jetpack' );
else
$expand = __( 'Share', 'jetpack' );
$parts[] = '<li><a href="#" class="sharing-anchor sd-button share-more"><span>'.$expand.'</span></a></li>';
}
if ( $dir == 'rtl' )
$parts = array_reverse( $parts );
$sharing_content .= implode( '', $parts );
$sharing_content .= '<li class="share-end"></li></ul>';
//.........这里部分代码省略.........
示例10: update_settings
//.........这里部分代码省略.........
break;
}
if ('jetpack_relatedposts_enabled' === $key && method_exists('Jetpack', 'is_module_active') && $this->jetpack_relatedposts_supported()) {
$before_action = Jetpack::is_module_active('related-posts');
if ($value) {
Jetpack::activate_module('related-posts', false, false);
} else {
Jetpack::deactivate_module('related-posts');
}
$after_action = Jetpack::is_module_active('related-posts');
if ($after_action == $before_action) {
break;
}
}
$just_the_key = substr($key, 21);
$jetpack_relatedposts_options[$just_the_key] = $value;
break;
case 'social_notifications_like':
case 'social_notifications_reblog':
case 'social_notifications_subscribe':
// settings are stored as on|off
$coerce_value = $value ? 'on' : 'off';
if (update_option($key, $coerce_value)) {
$updated[$key] = $value;
}
break;
case 'wga':
if (!isset($value['code']) || !preg_match('/^UA-[\\d-]+$/', $value['code'])) {
return new WP_Error('invalid_code', 'Invalid UA ID');
}
$wga = get_option('wga', array());
$wga['code'] = $value['code'];
// maintain compatibility with wp-google-analytics
if (update_option('wga', $wga)) {
$updated[$key] = $value;
}
break;
case 'jetpack_comment_likes_enabled':
// settings are stored as 1|0
$coerce_value = (int) $value;
if (update_option($key, $coerce_value)) {
$updated[$key] = $value;
}
break;
// Sharing options
// Sharing options
case 'sharing_button_style':
case 'sharing_show':
case 'sharing_open_links':
$sharing_options[preg_replace('/^sharing_/', '', $key)] = $value;
break;
case 'sharing_label':
$sharing_options[$key] = $value;
break;
// no worries, we've already whitelisted and casted arguments above
// no worries, we've already whitelisted and casted arguments above
default:
if (update_option($key, $value)) {
$updated[$key] = $value;
}
}
}
if (count($jetpack_relatedposts_options)) {
// track new jetpack_relatedposts options against old
$old_relatedposts_options = Jetpack_Options::get_option('relatedposts');
if (Jetpack_Options::update_option('relatedposts', $jetpack_relatedposts_options)) {
foreach ($jetpack_relatedposts_options as $key => $value) {
if ($value !== $old_relatedposts_options[$key]) {
$updated['jetpack_relatedposts_' . $key] = $value;
}
}
}
}
if (!empty($sharing_options) && class_exists('Sharing_Service')) {
$ss = new Sharing_Service();
// Merge current values with updated, since Sharing_Service expects
// all values to be included when updating
$current_sharing_options = $ss->get_global_options();
foreach ($current_sharing_options as $key => $val) {
if (!isset($sharing_options[$key])) {
$sharing_options[$key] = $val;
}
}
$updated_social_options = $ss->set_global_options($sharing_options);
if (isset($input['sharing_button_style'])) {
$updated['sharing_button_style'] = (string) $updated_social_options['button_style'];
}
if (isset($input['sharing_label'])) {
// Sharing_Service won't report label as updated if set to default
$updated['sharing_label'] = (string) $sharing_options['sharing_label'];
}
if (isset($input['sharing_show'])) {
$updated['sharing_show'] = (array) $updated_social_options['show'];
}
if (isset($input['sharing_open_links'])) {
$updated['sharing_open_links'] = (string) $updated_social_options['open_links'];
}
}
return array('updated' => $updated);
}
开发者ID:moushegh,项目名称:blog-source-configs,代码行数:101,代码来源:class.wpcom-json-api-site-settings-endpoint.php
示例11: update_settings
//.........这里部分代码省略.........
// These options can only be updated for sites hosted on WordPress.com
if (defined('IS_WPCOM') && IS_WPCOM) {
if (empty($value) || WPCOM_JSON_API::is_falsy($value)) {
if (delete_option($key)) {
$updated[$key] = null;
}
} else {
if (update_option($key, $value)) {
$updated[$key] = (int) $value;
}
}
}
break;
case 'holidaysnow':
if (empty($value) || WPCOM_JSON_API::is_falsy($value)) {
if (function_exists('jetpack_holiday_snow_option_name') && delete_option(jetpack_holiday_snow_option_name())) {
$updated[$key] = false;
}
} else {
if (function_exists('jetpack_holiday_snow_option_name') && update_option(jetpack_holiday_snow_option_name(), 'letitsnow')) {
$updated[$key] = true;
}
}
break;
case 'timezone_string':
// Map UTC+- timezones to gmt_offsets and set timezone_string to empty
// https://github.com/WordPress/WordPress/blob/4.4.2/wp-admin/options.php#L175
if (!empty($value) && preg_match('/^UTC[+-]/', $value)) {
$gmt_offset = preg_replace('/UTC\\+?/', '', $value);
if (update_option('gmt_offset', $gmt_offset)) {
$updated['gmt_offset'] = $gmt_offset;
}
$value = '';
}
// Always set timezone_string either with the given value or with an
// empty string
if (update_option($key, $value)) {
$updated[$key] = $value;
}
break;
default:
//allow future versions of this endpoint to support additional settings keys
if (has_filter('site_settings_endpoint_update_' . $key)) {
/**
* Filter current site setting value to be updated.
*
* @module json-api
*
* @since 3.9.3
*
* @param mixed $response_item A single site setting value.
*/
$value = apply_filters('site_settings_endpoint_update_' . $key, $value);
$updated[$key] = $value;
continue;
}
// no worries, we've already whitelisted and casted arguments above
if (update_option($key, $value)) {
$updated[$key] = $value;
}
}
}
if (count($jetpack_relatedposts_options)) {
// track new jetpack_relatedposts options against old
$old_relatedposts_options = Jetpack_Options::get_option('relatedposts');
if (Jetpack_Options::update_option('relatedposts', $jetpack_relatedposts_options)) {
foreach ($jetpack_relatedposts_options as $key => $value) {
if ($value !== $old_relatedposts_options[$key]) {
$updated['jetpack_relatedposts_' . $key] = $value;
}
}
}
}
if (!empty($sharing_options) && class_exists('Sharing_Service')) {
$ss = new Sharing_Service();
// Merge current values with updated, since Sharing_Service expects
// all values to be included when updating
$current_sharing_options = $ss->get_global_options();
foreach ($current_sharing_options as $key => $val) {
if (!isset($sharing_options[$key])) {
$sharing_options[$key] = $val;
}
}
$updated_social_options = $ss->set_global_options($sharing_options);
if (isset($input['sharing_button_style'])) {
$updated['sharing_button_style'] = (string) $updated_social_options['button_style'];
}
if (isset($input['sharing_label'])) {
// Sharing_Service won't report label as updated if set to default
$updated['sharing_label'] = (string) $sharing_options['sharing_label'];
}
if (isset($input['sharing_show'])) {
$updated['sharing_show'] = (array) $updated_social_options['show'];
}
if (isset($input['sharing_open_links'])) {
$updated['sharing_open_links'] = (string) $updated_social_options['open_links'];
}
}
return array('updated' => $updated);
}