本文整理汇总了PHP中bump_stats_extras函数的典型用法代码示例。如果您正苦于以下问题:PHP bump_stats_extras函数的具体用法?PHP bump_stats_extras怎么用?PHP bump_stats_extras使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bump_stats_extras函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write_post
//.........这里部分代码省略.........
}
} else {
if (true === $likes) {
update_post_meta($post_id, 'switch_like_status', 1);
} else {
delete_post_meta($post_id, 'switch_like_status');
}
}
}
}
// Set sharing status of the post
if ($new) {
$sharing_enabled = isset($sharing) ? (bool) $sharing : true;
if (false === $sharing_enabled) {
update_post_meta($post_id, 'sharing_disabled', 1);
}
} else {
if (isset($sharing) && true === $sharing) {
delete_post_meta($post_id, 'sharing_disabled');
} else {
if (isset($sharing) && false == $sharing) {
update_post_meta($post_id, 'sharing_disabled', 1);
}
}
}
if (true === $sticky) {
stick_post($post_id);
} else {
unstick_post($post_id);
}
// WPCOM Specific (Jetpack's will get bumped elsewhere
// Tracks how many posts are published and sets meta so we can track some other cool stats (like likes & comments on posts published)
if ($new && 'publish' == $input['status'] || !$new && isset($last_status) && 'publish' != $last_status && isset($new_status) && 'publish' == $new_status) {
if (function_exists('bump_stats_extras')) {
bump_stats_extras('api-insights-posts', $this->api->token_details['client_id']);
update_post_meta($post_id, '_rest_api_published', 1);
update_post_meta($post_id, '_rest_api_client_id', $this->api->token_details['client_id']);
}
}
// We ask the user/dev to pass Publicize services he/she wants activated for the post, but Publicize expects us
// to instead flag the ones we don't want to be skipped. proceed with said logic.
// any posts coming from Path (client ID 25952) should also not publicize
if ($publicize === false || isset($this->api->token_details['client_id']) && 25952 == $this->api->token_details['client_id']) {
// No publicize at all, skip all by ID
foreach ($GLOBALS['publicize_ui']->publicize->get_services('all') as $name => $service) {
delete_post_meta($post_id, $GLOBALS['publicize_ui']->publicize->POST_SKIP . $name);
$service_connections = $GLOBALS['publicize_ui']->publicize->get_connections($name);
if (!$service_connections) {
continue;
}
foreach ($service_connections as $service_connection) {
update_post_meta($post_id, $GLOBALS['publicize_ui']->publicize->POST_SKIP . $service_connection->unique_id, 1);
}
}
} else {
if (is_array($publicize) && count($publicize) > 0) {
foreach ($GLOBALS['publicize_ui']->publicize->get_services('all') as $name => $service) {
/*
* We support both indexed and associative arrays:
* * indexed are to pass entire services
* * associative are to pass specific connections per service
*
* We do support mixed arrays: mixed integer and string keys (see 3rd example below).
*
* EG: array( 'twitter', 'facebook') will only publicize to those, ignoring the other available services
* Form data: publicize[]=twitter&publicize[]=facebook
示例2: create_post
/**
* Create new post on target P2-themed site
* Uses the permalink of the source post for the content and title of the new post
*
* @param int $_blog_id
* @param object $post
* @param array $tags
* @return int $new_id
*/
function create_post($_blog_id, $post, $tags = array(), $post_parent_id = 0)
{
$this_blog = get_blog_details(get_current_blog_id());
$new_id = null;
// @todo Make this more wp.com-agnostic
$origin_subdomain = str_replace('.wordpress.com', '', $this_blog->domain);
$origin_blog_id = $this_blog->blog_id;
$target_details = get_blog_details($_blog_id);
$target_subdomain = str_replace('.wordpress.com', '', $target_details->domain);
// Set up the new post's content. For ex:
// X-post from #socialp2: <a href="permalink">Post Title</a>
// X-comment from #socialp2: <a href="permalink">Comment on Post Title</a>
if (isset($post->comment_ID)) {
// It's really a comment
$comment = $post;
$post = get_post($post->comment_post_ID);
$x_permalink = get_comment_link($comment->comment_ID);
$format = __('X-comment from %1$s: Comment on %2$s');
$author = $comment->user_id;
} else {
// It's a post
$format = __('X-post from %1$s: %2$s');
$x_permalink = get_permalink($post->ID);
$author = $post->post_author;
}
$post_title = wp_kses($post->post_title, array());
// Used as anchor text for display back to original post
$post_long_content = trim(wp_html_excerpt($post->post_content, 800)) . '…';
// Add short preview to the original post's full content
// Avoid triggering display re-filters for mentions and xposts
$post_title = str_replace(array('#', '@', '+'), array('#', '@', '+'), $post_title);
$post_long_content = str_replace(array('#', '@', '+'), array('#', '@', '+'), $post_long_content);
// Strip any shortcodes out of the tooltip as they can generate invalid html
$post_long_content = strip_shortcodes($post_long_content);
$origin_link = sprintf('<a href="%1$s" title="%2$s">%3$s</a>', trailingslashit(esc_url($this_blog->siteurl)), esc_attr($this_blog->blogname), "+{$origin_subdomain}");
$post_content = sprintf($format, $origin_link, sprintf('<a href="%1$s" title="%2$s">%3$s</a>', $x_permalink, esc_html($post_long_content), esc_html($post_title)));
array_push($tags, $origin_subdomain);
switch_to_blog($_blog_id);
if ($post_parent_id) {
// Create comment on original xpost
$args = array('comment_post_ID' => $post_parent_id, 'user_id' => get_current_user_id(), 'comment_content' => $post_content);
$new_id = wp_insert_comment($args);
// Prevent senting x-post *back* to origin when this comment is edited
update_comment_meta($new_id, 'xcomment-' . $origin_blog_id, $new_id);
// Log the original comment permalink for filtering permalinks later
update_comment_meta($new_id, 'xcomment_original_permalink', $x_permalink);
} else {
// Create new xpost
if (!current_user_can('edit_posts')) {
return;
}
$args = array('post_name' => 'xpost-' . $post->post_name, 'post_content' => $post_content, 'post_status' => 'publish', 'post_title' => "X-post: {$post_title}", 'post_author' => $author);
// @todo make sure notifications dont go out for xposts when we build the network features out properly
do_action('xpost_notify_before', $args);
$new_id = wp_insert_post($args);
do_action('xpost_notify_after', $args);
// Prevent senting x-post *back* to origin when this post is edited
update_post_meta($new_id, 'xpost-' . $origin_blog_id, $new_id);
// Log the original post permalink so we can redirect to it
update_post_meta($new_id, '_xpost_original_permalink', $x_permalink);
wp_set_object_terms($new_id, array('status'), 'category');
if (!empty($tags)) {
wp_set_object_terms($new_id, $tags, 'post_tag');
}
clean_post_cache($new_id);
}
// @todo extract into an action
bump_stats_extras('a8c-p2-xpost-received', $target_subdomain);
bump_stats_extras('a8c-p2-xpost-sent', $origin_subdomain);
restore_current_blog();
return $new_id;
}
示例3: bump_stats_extras_publicize_url
function bump_stats_extras_publicize_url($bin, $post_id)
{
static $done = array();
if (isset($done[$post_id])) {
return;
}
$done[$post_id] = true;
if (function_exists('bump_stats_extras')) {
bump_stats_extras('publicize_url', $bin);
}
}
示例4: write_post
//.........这里部分代码省略.........
}
} else {
if (isset($gplus) && true === $gplus) {
delete_post_meta($post_id, 'gplus_authorship_disabled');
} else {
if (isset($gplus) && false == $gplus) {
update_post_meta($post_id, 'gplus_authorship_disabled', 1);
}
}
}
// Set sharing status of the post
if ($new) {
$sharing_enabled = isset($sharing) ? (bool) $sharing : true;
if (false === $sharing_enabled) {
update_post_meta($post_id, 'sharing_disabled', 1);
}
} else {
if (isset($sharing) && true === $sharing) {
delete_post_meta($post_id, 'sharing_disabled');
} else {
if (isset($sharing) && false == $sharing) {
update_post_meta($post_id, 'sharing_disabled', 1);
}
}
}
if (true === $sticky) {
stick_post($post_id);
} else {
unstick_post($post_id);
}
// WPCOM Specific (Jetpack's will get bumped elsewhere
// Tracks how many posts are published and sets meta so we can track some other cool stats (like likes & comments on posts published)
if ($new && 'publish' == $input['status'] || !$new && isset($last_status) && 'publish' != $last_status && isset($new_status) && 'publish' == $new_status) {
if (function_exists('bump_stats_extras')) {
bump_stats_extras('api-insights-posts', $this->api->token_details['client_id']);
update_post_meta($post_id, '_rest_api_published', 1);
update_post_meta($post_id, '_rest_api_client_id', $this->api->token_details['client_id']);
}
}
// We ask the user/dev to pass Publicize services he/she wants activated for the post, but Publicize expects us
// to instead flag the ones we don't want to be skipped. proceed with said logic.
// any posts coming from Path (client ID 25952) should also not publicize
if ($publicize === false || 25952 == $this->api->token_details['client_id']) {
// No publicize at all, skipp all by full service
foreach ($GLOBALS['publicize_ui']->publicize->get_services('all') as $name => $service) {
update_post_meta($post_id, $GLOBALS['publicize_ui']->publicize->POST_SKIP . $name, 1);
}
} else {
if (is_array($publicize) && count($publicize) > 0) {
foreach ($GLOBALS['publicize_ui']->publicize->get_services('all') as $name => $service) {
/*
* We support both indexed and associative arrays:
* * indexed are to pass entire services
* * associative are to pass specific connections per service
*
* We do support mixed arrays: mixed integer and string keys (see 3rd example below).
*
* EG: array( 'twitter', 'facebook') will only publicize to those, ignoring the other available services
* Form data: publicize[]=twitter&publicize[]=facebook
* EG: array( 'twitter' => '(int) $pub_conn_id_0, (int) $pub_conn_id_3', 'facebook' => (int) $pub_conn_id_7 ) will publicize to two Twitter accounts, and one Facebook connection, of potentially many.
* Form data: publicize[twitter]=$pub_conn_id_0,$pub_conn_id_3&publicize[facebook]=$pub_conn_id_7
* EG: array( 'twitter', 'facebook' => '(int) $pub_conn_id_0, (int) $pub_conn_id_3' ) will publicize to all available Twitter accounts, but only 2 of potentially many Facebook connections
* Form data: publicize[]=twitter&publicize[facebook]=$pub_conn_id_0,$pub_conn_id_3
*/
if (!in_array($name, $publicize) && !array_key_exists($name, $publicize)) {
// Skip the whole service
示例5: AtD_http_post_error_action
function AtD_http_post_error_action($code)
{
bump_stats_extras('atd-remote-error', $code);
}
示例6: panel
/**
* Renders the plugin options page. Pretty simple stuff right now.
*
* @return void
* @author Armando Sosa
*/
function panel()
{
if (isset($_POST['padpressed_general']['enable'])) {
if ($_POST['padpressed_general']['enable'] === 'enable') {
update_option('padpressed_is_disabled', 0);
if (function_exists('bump_stats_extras')) {
bump_stats_extras('onswipe', 'enabled');
}
} else {
update_option('padpressed_is_disabled', 1);
if (function_exists('bump_stats_extras')) {
bump_stats_extras('onswipe', 'disabled');
}
}
} elseif (false === get_option('padpressed_is_disabled')) {
// Set the option so a user won't be confused if they
// change mobile and onswipe ends up changing as well
if (1 == get_option('wp_mobile_disable')) {
update_option('padpressed_is_disabled', 1);
} else {
update_option('padpressed_is_disabled', 0);
}
}
$is_disabled = is_padpressed_disabled();
include_once PADPRESS_PLUGIN_DIR . '/framework/panel.php';
}
示例7: write_post
//.........这里部分代码省略.........
// No images - do nothing.
break;
case 1:
// 1 image - make it big
$insert['post_content'] = $input['content'] = "[gallery size=full columns=1]\n\n" . $input['content'];
break;
default:
// Several images - 3 column gallery
$insert['post_content'] = $input['content'] = "[gallery]\n\n" . $input['content'];
break;
}
}
$post_id = wp_insert_post(add_magic_quotes($insert), true);
if ($has_media) {
$this->api->trap_wp_die('upload_error');
foreach ($input['media'] as $media_item) {
$_FILES['.api.media.item.'] = $media_item;
// check for WP_Error if we ever actually need $media_id
$media_id = media_handle_upload('.api.media.item.', $post_id);
}
$this->api->trap_wp_die(null);
unset($_FILES['.api.media.item.']);
}
} else {
$insert['ID'] = $post->ID;
$post_id = wp_update_post((object) $insert);
}
if (!$post_id || is_wp_error($post_id)) {
return $post_id;
}
// WPCOM Specific (Jetpack's will get bumped elsewhere
// Tracks how many posts are published and sets meta so we can track some other cool stats (like likes & comments on posts published)
if ($new && 'publish' == $input['status'] || !$new && isset($last_status) && 'publish' != $last_status && isset($new_status) && 'publish' == $new_status) {
if (function_exists('bump_stats_extras')) {
bump_stats_extras('api-insights-posts', $this->api->token_details['client_id']);
update_post_meta($post_id, '_rest_api_published', 1);
update_post_meta($post_id, '_rest_api_client_id', $this->api->token_details['client_id']);
}
}
if ($publicize === false) {
foreach ($GLOBALS['publicize_ui']->publicize->get_services('all') as $name => $service) {
update_post_meta($post_id, $GLOBALS['publicize_ui']->publicize->POST_SKIP . $name, 1);
}
} else {
if (is_array($publicize) && count($publicize) > 0) {
foreach ($GLOBALS['publicize_ui']->publicize->get_services('all') as $name => $service) {
if (!in_array($name, $publicize)) {
update_post_meta($post_id, $GLOBALS['publicize_ui']->publicize->POST_SKIP . $name, 1);
}
}
}
}
if (!empty($publicize_custom_message)) {
update_post_meta($post_id, $GLOBALS['publicize_ui']->publicize->POST_MESS, trim($publicize_custom_message));
}
set_post_format($post_id, $insert['post_format']);
if (!empty($metadata)) {
foreach ((array) $metadata as $meta) {
$meta = (object) $meta;
$existing_meta_item = new stdClass();
if (empty($meta->operation)) {
$meta->operation = 'update';
}
if (!empty($meta->value)) {
if ('true' == $meta->value) {
$meta->value = true;
示例8: update_settings
/**
* Updates site settings for authorized users
*
* @return (array)
*/
public function update_settings()
{
// $this->input() retrieves posted arguments whitelisted and casted to the $request_format
// specs that get passed in when this class is instantiated
/**
* Filters the settings to be updated on the site.
*
* @since 3.6
*
* @param array $input Associative array of site settings to be updated.
*/
$input = apply_filters('rest_api_update_site_settings', $this->input());
$jetpack_relatedposts_options = array();
$sharing_options = array();
$updated = array();
foreach ($input as $key => $value) {
if (!is_array($value)) {
$value = trim($value);
}
$value = wp_unslash($value);
switch ($key) {
case 'default_ping_status':
case 'default_comment_status':
// settings are stored as closed|open
$coerce_value = $value ? 'open' : 'closed';
if (update_option($key, $coerce_value)) {
$updated[$key] = $value;
}
break;
case 'jetpack_protect_whitelist':
if (function_exists('jetpack_protect_save_whitelist')) {
$result = jetpack_protect_save_whitelist($value);
if (is_wp_error($result)) {
return $result;
}
$updated[$key] = jetpack_protect_format_whitelist();
}
break;
case 'jetpack_sync_non_public_post_stati':
Jetpack_Options::update_option('sync_non_public_post_stati', $value);
break;
case 'jetpack_relatedposts_enabled':
case 'jetpack_relatedposts_show_thumbnails':
case 'jetpack_relatedposts_show_headline':
if (!$this->jetpack_relatedposts_supported()) {
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-]+$/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';
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
//.........这里部分代码省略.........
示例9: wpcom_push_syndication_stats
function wpcom_push_syndication_stats($stat, $action)
{
if (function_exists('bump_stats_extras')) {
bump_stats_extras($stat, $action);
}
}
示例10: add_action
<?php
add_action('wpcom_geo_uniques_locate_user', function ($location) {
if (function_exists('bump_stats_extras')) {
bump_stats_extras('wpcom-geo-uniques-locate-user-by-theme', str_replace('/', '-', get_stylesheet()));
}
});
示例11: new_testimonial_stat_bump
/**
* Bump Testimonial > Published Testimonials stat when testimonials are published
*/
function new_testimonial_stat_bump()
{
bump_stats_extras('testimonials', 'published-testimonials');
}
示例12: validate
function validate($name, $data)
{
$files = array();
if (isset($_FILES[$name . '_opts'])) {
define('ONSWIPE_SETTINGS', true);
$files = array_insideout($_FILES[$name . '_opts']);
}
foreach ($files as $key => $file) {
$key = str_replace('__file', '', $key);
if (empty($file['tmp_name'])) {
continue;
}
$override = array('test_form' => false);
$uploaded_file = wp_handle_upload($file, $override);
if (!empty($uploaded_file['error'])) {
return new WP_Error('broke', __("Upload Error : ", 'nube') . " " . $uploaded_file['error']);
}
$data[$key] = $uploaded_file['url'];
}
if (isset($_POST['padpressed_general']['enable'])) {
if ($_POST['padpressed_general']['enable'] === 'enable') {
update_option('padpressed_is_disabled', 0);
if (function_exists('bump_stats_extras')) {
bump_stats_extras('onswipe', 'enabled');
}
} else {
update_option('padpressed_is_disabled', 1);
if (function_exists('bump_stats_extras')) {
bump_stats_extras('onswipe', 'disabled');
}
}
} elseif (false === get_option('padpressed_is_disabled')) {
// Set the option so a user won't be confused if they
// change mobile and onswipe ends up changing as well
if (1 == get_option('wp_mobile_disable')) {
update_option('padpressed_is_disabled', 1);
} else {
update_option('padpressed_is_disabled', 0);
}
}
return $data;
}