本文整理汇总了PHP中sharing_register_post_for_share_counts函数的典型用法代码示例。如果您正苦于以下问题:PHP sharing_register_post_for_share_counts函数的具体用法?PHP sharing_register_post_for_share_counts怎么用?PHP sharing_register_post_for_share_counts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sharing_register_post_for_share_counts函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: query
/**
* Runs the query and returns the results via JSON.
* Triggered by an AJAX request.
*
* @global $wp_query
* @global $wp_the_query
* @uses current_theme_supports, get_option, self::wp_query, self::set_last_post_time, current_user_can, apply_filters, self::get_settings, add_filter, WP_Query, remove_filter, have_posts, wp_head, do_action, add_action, this::render, this::has_wrapper, esc_attr, wp_footer, sharing_register_post_for_share_counts, get_the_id
* @return string or null
*/
function query()
{
if (!isset($_GET['page']) || !current_theme_supports('infinite-scroll')) {
die;
}
$page = (int) $_GET['page'];
$sticky = get_option('sticky_posts');
$post__not_in = self::wp_query()->get('post__not_in');
if (!empty($post__not_in)) {
$sticky = array_unique(array_merge($sticky, $post__not_in));
}
if (!empty($_GET['date'])) {
self::set_last_post_time($_GET['date']);
}
$post_status = array('publish');
if (current_user_can('read_private_posts')) {
array_push($post_status, 'private');
}
$order = in_array($_GET['order'], array('ASC', 'DESC')) ? $_GET['order'] : 'DESC';
$query_args = array_merge(self::wp_query()->query_vars, array('paged' => $page, 'post_status' => $post_status, 'posts_per_page' => self::get_settings()->posts_per_page, 'post__not_in' => (array) $sticky, 'order' => $order));
// By default, don't query for a specific page of a paged post object.
// This argument can come from merging self::wp_query() into $query_args above.
// Since IS is only used on archives, we should always display the first page of any paged content.
unset($query_args['page']);
$query_args = apply_filters('infinite_scroll_query_args', $query_args);
// Add query filter that checks for posts below the date
add_filter('posts_where', array($this, 'query_time_filter'), 10, 2);
$GLOBALS['wp_the_query'] = $GLOBALS['wp_query'] = new WP_Query($query_args);
remove_filter('posts_where', array($this, 'query_time_filter'), 10, 2);
$results = array();
if (have_posts()) {
// Fire wp_head to ensure that all necessary scripts are enqueued. Output isn't used, but scripts are extracted in self::action_wp_footer.
ob_start();
wp_head();
ob_end_clean();
$results['type'] = 'success';
// First, try theme's specified rendering handler, either specified via `add_theme_support` or by hooking to this action directly.
ob_start();
do_action('infinite_scroll_render');
$results['html'] = ob_get_clean();
// Fall back if a theme doesn't specify a rendering function. Because themes may hook additional functions to the `infinite_scroll_render` action, `has_action()` is ineffective here.
if (empty($results['html'])) {
add_action('infinite_scroll_render', array($this, 'render'));
rewind_posts();
ob_start();
do_action('infinite_scroll_render');
$results['html'] = ob_get_clean();
}
// If primary and fallback rendering methods fail, prevent further IS rendering attempts. Otherwise, wrap the output if requested.
if (empty($results['html'])) {
unset($results['html']);
do_action('infinite_scroll_empty');
$results['type'] = 'empty';
} elseif ($this->has_wrapper()) {
$wrapper_classes = is_string(self::get_settings()->wrapper) ? self::get_settings()->wrapper : 'infinite-wrap';
$wrapper_classes .= ' infinite-view-' . $page;
$wrapper_classes = trim($wrapper_classes);
$results['html'] = '<div class="' . esc_attr($wrapper_classes) . '" id="infinite-view-' . $page . '" data-page-num="' . $page . '">' . $results['html'] . '</div>';
}
// Fire wp_footer to ensure that all necessary scripts are enqueued. Output isn't used, but scripts are extracted in self::action_wp_footer.
ob_start();
wp_footer();
ob_end_clean();
// Loop through posts to capture sharing data for new posts loaded via Infinite Scroll
if ('success' == $results['type'] && function_exists('sharing_register_post_for_share_counts')) {
global $jetpack_sharing_counts;
while (have_posts()) {
the_post();
sharing_register_post_for_share_counts(get_the_ID());
}
$results['postflair'] = array_flip($jetpack_sharing_counts);
}
} else {
do_action('infinite_scroll_empty');
$results['type'] = 'empty';
}
echo json_encode(apply_filters('infinite_scroll_results', $results, $query_args, self::wp_query()));
die;
}
开发者ID:cs-team,项目名称:jsdelivr,代码行数:88,代码来源:infinity.php
示例2: get_display
public function get_display($post)
{
if ($this->smart) {
$skype_share_html = sprintf('<div class="skype-share" data-href="%1$s" data-lang="%2$s" data-style="small" data-source="jetpack" ></div>', esc_attr($this->get_share_url($post->ID)), 'en-US');
return $skype_share_html;
}
/** This filter is already documented in modules/sharedaddy/sharing-sources.php */
if (apply_filters('jetpack_register_post_for_share_counts', true, $post->ID, 'skype')) {
sharing_register_post_for_share_counts($post->ID);
}
return $this->get_link($this->get_process_request_url($post->ID), _x('Skype', 'share to', 'jetpack'), __('Share on Skype', 'jetpack'), 'share=skype', 'sharing-skype-' . $post->ID);
}
开发者ID:pacificano,项目名称:pacificano,代码行数:12,代码来源:sharing-sources.php
示例3: get_display
public function get_display($post)
{
$share_url = $this->get_share_url($post->ID);
if ($this->smart) {
$url = $this->http() . '://www.facebook.com/plugins/like.php?href=' . rawurlencode($share_url) . '&layout=button_count&show_faces=false&action=like&colorscheme=light&height=21';
// Default widths to suit English
$inner_w = 90;
// Locale-specific widths/overrides
$widths = array('bg_BG' => 120, 'bn_IN' => 100, 'cs_CZ' => 135, 'de_DE' => 120, 'da_DK' => 120, 'es_ES' => 122, 'es_LA' => 110, 'fi_FI' => 100, 'it_IT' => 100, 'ja_JP' => 100, 'pl_PL' => 100, 'nl_NL' => 130, 'ro_RO' => 100, 'ru_RU' => 128);
$widths = apply_filters('sharing_facebook_like_widths', $widths);
$locale = $this->guess_locale_from_lang(get_locale());
if ($locale) {
$url .= '&locale=' . $locale;
if (isset($widths[$locale])) {
$inner_w = $widths[$locale];
}
}
$url .= '&width=' . $inner_w;
return '<div class="like_button"><iframe src="' . $url . '" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:' . ($inner_w + 6) . 'px; height:21px;" allowTransparency="true"></iframe></div>';
}
if (apply_filters('jetpack_register_post_for_share_counts', true, $post->ID, 'facebook')) {
sharing_register_post_for_share_counts($post->ID);
}
return $this->get_link(get_permalink($post->ID), _x('Facebook', 'share to', 'jetpack'), __('Share on Facebook', 'jetpack'), 'share=facebook', 'sharing-facebook-' . $post->ID);
}
开发者ID:lokenxo,项目名称:familygenerator,代码行数:25,代码来源:sharing-sources.php
示例4: get_display
public function get_display($post)
{
$display = '';
if ($this->smart) {
$display = sprintf('<div class="pinterest_button"><a href="%s" data-pin-do="%s" data-pin-config="beside"><img src="//assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png" /></a></div>', esc_url($this->get_external_url($post)), esc_attr($this->get_widget_type()));
} else {
$display = $this->get_link($this->get_process_request_url($post->ID), _x('Pinterest', 'share to', 'jetpack'), __('Click to share on Pinterest', 'jetpack'), 'share=pinterest', 'sharing-pinterest-' . $post->ID);
}
/** This filter is already documented in modules/sharedaddy/sharing-sources.php */
if (apply_filters('jetpack_register_post_for_share_counts', true, $post->ID, 'linkedin')) {
sharing_register_post_for_share_counts($post->ID);
}
return $display;
}
开发者ID:jfbelisle,项目名称:magexpress,代码行数:14,代码来源:sharing-sources.php
示例5: query
//.........这里部分代码省略.........
}
$order = in_array($_REQUEST['order'], array('ASC', 'DESC')) ? $_REQUEST['order'] : 'DESC';
$query_args = array_merge(self::wp_query()->query_vars, array('paged' => $page, 'post_status' => $post_status, 'posts_per_page' => self::get_settings()->posts_per_page, 'post__not_in' => (array) $sticky, 'order' => $order));
// 4.0 ?s= compatibility, see https://core.trac.wordpress.org/ticket/11330#comment:50
if (empty($query_args['s']) && !isset(self::wp_query()->query['s'])) {
unset($query_args['s']);
}
// By default, don't query for a specific page of a paged post object.
// This argument can come from merging self::wp_query() into $query_args above.
// Since IS is only used on archives, we should always display the first page of any paged content.
unset($query_args['page']);
/**
* Filter the array of main query arguments.
*
* @module infinite-scroll
*
* @since 2.0.1
*
* @param array $query_args Array of Query arguments.
*/
$query_args = apply_filters('infinite_scroll_query_args', $query_args);
// Add query filter that checks for posts below the date
add_filter('posts_where', array($this, 'query_time_filter'), 10, 2);
$GLOBALS['wp_the_query'] = $GLOBALS['wp_query'] = new WP_Query($query_args);
remove_filter('posts_where', array($this, 'query_time_filter'), 10, 2);
$results = array();
if (have_posts()) {
// Fire wp_head to ensure that all necessary scripts are enqueued. Output isn't used, but scripts are extracted in self::action_wp_footer.
ob_start();
wp_head();
while (ob_get_length()) {
ob_end_clean();
}
$results['type'] = 'success';
// First, try theme's specified rendering handler, either specified via `add_theme_support` or by hooking to this action directly.
ob_start();
/**
* Fires when rendering Infinite Scroll posts.
*
* @module infinite-scroll
*
* @since 2.0.0
*/
do_action('infinite_scroll_render');
$results['html'] = ob_get_clean();
// Fall back if a theme doesn't specify a rendering function. Because themes may hook additional functions to the `infinite_scroll_render` action, `has_action()` is ineffective here.
if (empty($results['html'])) {
add_action('infinite_scroll_render', array($this, 'render'));
rewind_posts();
ob_start();
/** This action is already documented in modules/infinite-scroll/infinity.php */
do_action('infinite_scroll_render');
$results['html'] = ob_get_clean();
}
// If primary and fallback rendering methods fail, prevent further IS rendering attempts. Otherwise, wrap the output if requested.
if (empty($results['html'])) {
unset($results['html']);
/**
* Fires when Infinite Scoll doesn't render any posts.
*
* @module infinite-scroll
*
* @since 2.0.0
*/
do_action('infinite_scroll_empty');
$results['type'] = 'empty';
} elseif ($this->has_wrapper()) {
$wrapper_classes = is_string(self::get_settings()->wrapper) ? self::get_settings()->wrapper : 'infinite-wrap';
$wrapper_classes .= ' infinite-view-' . $page;
$wrapper_classes = trim($wrapper_classes);
$results['html'] = '<div class="' . esc_attr($wrapper_classes) . '" id="infinite-view-' . $page . '" data-page-num="' . $page . '">' . $results['html'] . '</div>';
}
// Fire wp_footer to ensure that all necessary scripts are enqueued. Output isn't used, but scripts are extracted in self::action_wp_footer.
ob_start();
wp_footer();
while (ob_get_length()) {
ob_end_clean();
}
if ('success' == $results['type']) {
global $currentday;
$results['lastbatch'] = self::is_last_batch();
$results['currentday'] = $currentday;
}
// Loop through posts to capture sharing data for new posts loaded via Infinite Scroll
if ('success' == $results['type'] && function_exists('sharing_register_post_for_share_counts')) {
global $jetpack_sharing_counts;
while (have_posts()) {
the_post();
sharing_register_post_for_share_counts(get_the_ID());
}
$results['postflair'] = array_flip($jetpack_sharing_counts);
}
} else {
/** This action is already documented in modules/infinite-scroll/infinity.php */
do_action('infinite_scroll_empty');
$results['type'] = 'empty';
}
echo wp_json_encode(apply_filters('infinite_scroll_results', $results, $query_args, self::wp_query()));
die;
}
开发者ID:andrewkhunn,项目名称:lancero,代码行数:101,代码来源:infinity.php
示例6: get_display
public function get_display($post)
{
$display = '';
if ($this->smart) {
$share_url = 'http://pinterest.com/pin/create/button/?url=' . rawurlencode($this->get_share_url($post->ID)) . '&description=' . rawurlencode($post->post_title);
$display .= sprintf('<div class="pinterest_button"><a href="%s" data-pin-do="buttonBookmark" data-pin-config="beside"><img src="//assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png" /></a></div>', esc_url($share_url));
} else {
$display = $this->get_link(get_permalink($post->ID), _x('Pinterest', 'share to', 'jetpack'), __('Click to share on Pinterest', 'jetpack'), 'share=pinterest', 'sharing-pinterest-' . $post->ID);
}
if (apply_filters('jetpack_register_post_for_share_counts', true, $post->ID, 'linkedin')) {
sharing_register_post_for_share_counts($post->ID);
}
return $display;
}
开发者ID:dtekcth,项目名称:datateknologer.se,代码行数:14,代码来源:sharing-sources.php
注:本文中的sharing_register_post_for_share_counts函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论