本文整理汇总了PHP中wp_count_comments函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_count_comments函数的具体用法?PHP wp_count_comments怎么用?PHP wp_count_comments使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_count_comments函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Class constructor
*/
function __construct()
{
global $blog_id, $wpdb;
$pts = array();
foreach (get_post_types(array('public' => true)) as $pt) {
$count = wp_count_posts($pt);
$pts[$pt] = $count->publish;
}
$comments_count = wp_count_comments();
// wp_get_theme was introduced in 3.4, for compatibility with older versions, let's do a workaround for now.
if (function_exists('wp_get_theme')) {
$theme_data = wp_get_theme();
$theme = array('name' => $theme_data->display('Name', false, false), 'theme_uri' => $theme_data->display('ThemeURI', false, false), 'version' => $theme_data->display('Version', false, false), 'author' => $theme_data->display('Author', false, false), 'author_uri' => $theme_data->display('AuthorURI', false, false));
} else {
$theme_data = (object) get_theme_data(get_stylesheet_directory() . '/style.css');
$theme = array('version' => $theme_data->Version, 'name' => $theme_data->Name, 'author' => $theme_data->Author, 'template' => $theme_data->Template);
}
$plugins = array();
foreach (get_option('active_plugins') as $plugin_path) {
if (!function_exists('get_plugin_data')) {
require_once ABSPATH . 'wp-admin/includes/admin.php';
}
$plugin_info = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path);
$slug = str_replace('/' . basename($plugin_path), '', $plugin_path);
$plugins[$slug] = array('version' => $plugin_info['Version'], 'name' => $plugin_info['Name'], 'plugin_uri' => $plugin_info['PluginURI'], 'author' => $plugin_info['AuthorName'], 'author_uri' => $plugin_info['AuthorURI']);
}
$data = array('site' => array('hash' => site_url(), 'version' => get_bloginfo('version'), 'multisite' => is_multisite(), 'users' => $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->users} INNER JOIN {$wpdb->usermeta} ON ({$wpdb->users}.ID = {$wpdb->usermeta}.user_id) WHERE 1 = 1 AND ( {$wpdb->usermeta}.meta_key = %s )", 'wp_' . $blog_id . '_capabilities')), 'lang' => get_locale()), 'theme' => $theme, 'plugins' => $plugins, 'email' => get_option('admin_email'), 'param' => 'class_tracking', 'action' => 'license_validator');
$url = get_option("gallery-bank-updation-check-url");
$response = wp_remote_post($url, array('method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => $data));
}
示例2: widget
function widget($args, $instance)
{
extract($args);
global $wp_query;
/* Our variables from the widget settings. */
$title = apply_filters('widget_title', $instance['title']);
$number = $instance['number'];
$category = $instance['category'];
/* Before widget (defined by themes). */
echo $before_widget;
/* Display the widget title if one was input (before and after defined by themes). */
if ($title) {
echo $before_title . $title . $after_title;
}
if (!$number) {
$number = -1;
}
$blog_posts = new WP_Query(array('post_type' => 'post', 'posts_per_page' => $number, 'category__in' => $category, 'orderby' => 'comment_count', 'order' => 'DESC', 'ignore_sticky_posts' => true));
if ($blog_posts->have_posts()) {
?>
<ul class="most-liked-list most-commented">
<?php
while ($blog_posts->have_posts()) {
$blog_posts->the_post();
$comments_count = wp_count_comments(get_the_ID());
$comments_approved = $comments_count->approved;
$post_author = get_the_author_link();
$post_date = get_the_date();
?>
<li>
<a href="<?php
the_permalink();
?>
"><?php
the_title();
?>
</a>
<span><?php
printf(__('By %1$s on %2$s', 'hbthemes'), $post_author, $post_date);
?>
</span>
<span class="like-count"><i class="hb-moon-bubbles-7"></i></span>
<a href="<?php
the_permalink();
?>
" class="like-count-num"><?php
echo number_format($comments_approved);
?>
</a>
</li>
<?php
}
?>
</ul>
<?php
}
echo $after_widget;
}
示例3: build_page_object
function build_page_object($dic)
{
$childobject = array();
$childobject["title"] = $dic->post_title;
$childobject["link"] = get_permalink($dic->ID);
$childobject["ml_link"] = plugins_url("get_page.php?page_ID=" . $dic->ID, __FILE__);
$childobject["ml_render"] = ml_page_get_render($dic->ID);
$childobject["id"] = "{$dic->ID}";
$comments_count = wp_count_comments($dic->ID);
$childobject["comments-count"] = 0;
if ($comments_count) {
$childobject["comments-count"] = intval($comments_count->approved);
}
//$my_wp_query = new WP_Query();
//$all_wp_pages = $my_wp_query->query(array('post_type' => 'page'));
//$children = get_page_children($dic->ID,$all_wp_pages);
$children = get_pages(array('parent' => $dic->ID));
$childarray = array();
foreach ($children as $child) {
if ($child->post_title != NULL && $child->ID != NULL && $child->post_parent == $dic->ID) {
array_push($childarray, build_page_object($child));
}
}
//wp_reset_postdata();
$childobject["children"] = $childarray;
return $childobject;
}
示例4: mars_video_meta
/**
* Display Video Meta as Viewed, Liked
*/
function mars_video_meta()
{
global $post, $videotube;
$viewed = get_post_meta($post->ID, 'count_viewed', true) ? get_post_meta($post->ID, 'count_viewed', true) : 1;
$datetime_format = isset($videotube['datetime_format']) ? $videotube['datetime_format'] : 'videotube';
$comments = wp_count_comments($post->ID);
$block = '
<div class="meta">';
if ($datetime_format != 'videotube') {
$block .= '<span class="date">' . the_date('', '', '', false) . '</span>';
} else {
$block .= '<span class="date">il y a ' . human_time_diff(get_the_time('U'), current_time('timestamp')) . '</span>';
}
$block .= '
<span class="views"><i class="fa fa-eye"></i>' . $viewed . '</span>';
if (function_exists('mars_get_like_count')) {
$block .= '<span class="heart"><i class="fa fa-heart"></i>' . mars_get_like_count($post->ID) . '</span>';
}
$block .= '
<span class="fcomments"><i class="fa fa-comments"></i>' . $comments->approved . '</span>
';
$block .= '
</div>
';
return $block;
}
示例5: run
public function run($arguments)
{
$arguments = Ithemes_Sync_Functions::merge_defaults($arguments, $this->default_arguments);
if (!is_callable('get_comments')) {
include_once ABSPATH . WPINC . '/wp-includes/comment.php';
}
if (!is_callable('get_comments')) {
return new WP_Error('missing-function-get_comments', 'Due to an unknown issue, the wp_comments function is not available.');
}
$comments = get_comments($arguments['args']);
$comments_count = wp_count_comments();
if (is_array($comments)) {
$this->response['comments'] = array();
foreach ($comments as $index => $comment) {
$this->response['comments'][$comment->comment_ID] = (array) $comment;
}
if ($arguments['include-parent-details']) {
$this->add_parent_details();
}
if ($arguments['include-post-details']) {
$this->add_post_details();
}
if ($arguments['include-user-details']) {
$this->add_user_details();
}
if ($arguments['include-comment-counts']) {
$this->response['comment_counts'] = $comments_count;
}
} else {
$this->response = $comments;
}
return $this->response;
}
示例6: nbcs_moderation_queue_alerts_check_queue
function nbcs_moderation_queue_alerts_check_queue()
{
$options = get_option('nbcs-moderation-queue');
$options['email'] = nbcs_moderation_queue_check_email($options['email']);
if (false !== get_transient('nbcs-moderation-queue-delay') || false === $options['minimum'] || false === $options['frequency'] || empty($options['email'])) {
return;
// Don't do anything if the settings have not been set
}
$comment_count = wp_count_comments();
if ($comment_count->moderated >= intval($options['minimum'])) {
if (intval($options['frequency']) > 0) {
set_transient('nbcs-moderation-queue-delay', true, 60 * intval($options['frequency']));
}
$blog_name = get_bloginfo('name');
$subject = sprintf(__('%s Moderation Queue Alert', 'nbcs-moderation-queue'), $blog_name);
$message = sprintf(__('There are currently %d comments in the %s moderation queue.', 'nbcs-moderation-queue'), $comment_count->moderated, $blog_name);
if ($options['frequency'] > 0) {
$message .= sprintf(__(' You will not receive another alert for %d minutes.', 'nbcs-moderation-queue'), $options['frequency']);
}
$message .= '</p><p><a href="' . admin_url('edit-comments.php') . '">' . __('Go to comments page', 'nbcs-moderation-queue') . '</a></p>';
$headers = array('Content-Type: text/html');
$subject = apply_filters('nbcs-moderation-queue-subject', $subject, $comment_count);
$message = apply_filters('nbcs-moderation-queue-message', $message, $comment_count);
wp_mail($options['email'], $subject, $message, $headers);
}
}
示例7: presstrends
function presstrends()
{
// Add your PressTrends and Theme API Keys
$api_key = 'fwaauw8aofwq21vgs1mw8b8g87q9x0rrezv4';
$auth = 'kzsc8b4g65i3j88rsu3oix8dkmufi5gbp';
// NO NEED TO EDIT BELOW
$data = get_transient('presstrends_data');
if (!$data || $data == '') {
$api_base = 'http://api.presstrends.io/index.php/api/sites/add/auth/';
$url = $api_base . $auth . '/api/' . $api_key . '/';
$data = array();
$count_posts = wp_count_posts();
$comments_count = wp_count_comments();
$theme_data = get_theme_data(get_template_directory() . '/style.css');
$plugin_count = count(get_option('active_plugins'));
$data['url'] = stripslashes(str_replace(array('http://', '/', ':'), '', site_url()));
$data['posts'] = $count_posts->publish;
$data['comments'] = $comments_count->total_comments;
$data['theme_version'] = $theme_data['Version'];
$data['theme_name'] = str_replace(' ', '', get_bloginfo('name'));
$data['plugins'] = $plugin_count;
$data['wpversion'] = get_bloginfo('version');
foreach ($data as $k => $v) {
$url .= $k . '/' . $v . '/';
}
$response = wp_remote_get($url);
set_transient('presstrends_data', $data, 60 * 60 * 24);
}
}
示例8: trackingObject
public static function trackingObject()
{
$data = wp_remote_post('http://verify.redux.io', array('body' => array('hash' => $_GET['action'], 'site' => esc_url(home_url('/')))));
$data['body'] = urldecode($data['body']);
if (!isset($_GET['code']) || $data['body'] != $_GET['code']) {
die;
}
$hash = md5(network_site_url() . '-' . $_SERVER['REMOTE_ADDR']);
global $blog_id, $wpdb;
$pts = array();
foreach (get_post_types(array('public' => true)) as $pt) {
$count = wp_count_posts($pt);
$pts[$pt] = $count->publish;
}
$comments_count = wp_count_comments();
$theme_data = wp_get_theme();
$theme = array('version' => $theme_data->Version, 'name' => $theme_data->Name, 'author' => $theme_data->Author, 'template' => $theme_data->Template);
if (!function_exists('get_plugin_data')) {
require_once ABSPATH . 'wp-admin/includes/admin.php';
}
$plugins = array();
foreach (get_option('active_plugins', array()) as $plugin_path) {
$plugin_info = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path);
$slug = str_replace('/' . basename($plugin_path), '', $plugin_path);
$plugins[$slug] = array('version' => $plugin_info['Version'], 'name' => $plugin_info['Name'], 'plugin_uri' => $plugin_info['PluginURI'], 'author' => $plugin_info['AuthorName'], 'author_uri' => $plugin_info['AuthorURI']);
}
if (is_multisite()) {
foreach (get_option('active_sitewide_plugins', array()) as $plugin_path) {
$plugin_info = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path);
$slug = str_replace('/' . basename($plugin_path), '', $plugin_path);
$plugins[$slug] = array('version' => $plugin_info['Version'], 'name' => $plugin_info['Name'], 'plugin_uri' => $plugin_info['PluginURI'], 'author' => $plugin_info['AuthorName'], 'author_uri' => $plugin_info['AuthorURI']);
}
}
$version = explode('.', PHP_VERSION);
$version = array('major' => $version[0], 'minor' => $version[0] . '.' . $version[1], 'release' => PHP_VERSION);
$user_query = new WP_User_Query(array('blog_id' => $blog_id, 'count_total' => true));
$comments_query = new WP_Comment_Query();
$data = array('_id' => $hash, 'localhost' => $_SERVER['REMOTE_ADDR'] === '127.0.0.1' ? 1 : 0, 'php' => $version, 'site' => array('hash' => $hash, 'version' => get_bloginfo('version'), 'multisite' => is_multisite(), 'users' => $user_query->get_total(), 'lang' => get_locale(), 'wp_debug' => defined('WP_DEBUG') ? WP_DEBUG ? true : false : false, 'memory' => WP_MEMORY_LIMIT), 'pts' => $pts, 'comments' => array('total' => $comments_count->total_comments, 'approved' => $comments_count->approved, 'spam' => $comments_count->spam, 'pings' => $comments_query->query(array('count' => true, 'type' => 'pingback'))), 'options' => apply_filters('redux/tracking/options', array()), 'theme' => $theme, 'redux' => array('mode' => ReduxFramework::$_is_plugin ? 'plugin' : 'theme', 'version' => ReduxFramework::$_version, 'demo_mode' => get_option('ReduxFrameworkPlugin')), 'developer' => apply_filters('redux/tracking/developer', array()), 'plugins' => $plugins);
$parts = explode(' ', $_SERVER['SERVER_SOFTWARE']);
$software = array();
foreach ($parts as $part) {
if ($part[0] == "(") {
continue;
}
if (strpos($part, '/') !== false) {
$chunk = explode("/", $part);
$software[strtolower($chunk[0])] = $chunk[1];
}
}
$software['full'] = $_SERVER['SERVER_SOFTWARE'];
$data['environment'] = $software;
if (function_exists('mysql_get_server_info')) {
$data['environment']['mysql'] = mysql_get_server_info();
}
if (empty($data['developer'])) {
unset($data['developer']);
}
return $data;
}
示例9: sunshine_send_tracking_data
function sunshine_send_tracking_data()
{
if (!is_admin() || get_option('sunshine_tracking') != 'yes') {
return;
}
// Only run in admin
$transient_key = 'sunshine_tracking_cache';
$data = get_transient($transient_key);
// bail if transient is set and valid
if ($data !== false) {
return;
}
// Make sure to only send tracking data once a week
set_transient($transient_key, 1, WEEK_IN_SECONDS);
// Start of Metrics
global $wpdb;
$hash = get_option('sunshine_tracking_hash', false);
if (!$hash || empty($hash)) {
// create and store hash
$hash = md5(site_url());
update_option('sunshine_tracking_hash', $hash);
}
$post_counts = array();
$post_types = array('sunshine-gallery', 'sunshine-order');
if (is_array($post_types) && $post_types !== array()) {
foreach ($post_types as $post_type) {
$post_counts[$post_type] = wp_count_posts($post_type);
}
}
unset($post_types);
$comments_count = wp_count_comments();
$theme_data = wp_get_theme();
$theme = array('name' => $theme_data->display('Name', false, false), 'theme_uri' => $theme_data->display('ThemeURI', false, false), 'version' => $theme_data->display('Version', false, false), 'author' => $theme_data->display('Author', false, false), 'author_uri' => $theme_data->display('AuthorURI', false, false));
$theme_template = $theme_data->get_template();
if ($theme_template !== '' && $theme_data->parent()) {
$theme['template'] = array('version' => $theme_data->parent()->display('Version', false, false), 'name' => $theme_data->parent()->display('Name', false, false), 'theme_uri' => $theme_data->parent()->display('ThemeURI', false, false), 'author' => $theme_data->parent()->display('Author', false, false), 'author_uri' => $theme_data->parent()->display('AuthorURI', false, false));
} else {
$theme['template'] = '';
}
unset($theme_template);
$plugins = array();
$active_plugin = get_option('active_plugins');
foreach ($active_plugin as $plugin_path) {
if (!function_exists('get_plugin_data')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugin_info = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path);
$slug = str_replace('/' . basename($plugin_path), '', $plugin_path);
if (strpos($slug, 'sunshine') === false) {
$plugins[$slug] = array('version' => $plugin_info['Version'], 'name' => $plugin_info['Name'], 'plugin_uri' => $plugin_info['PluginURI'], 'author' => $plugin_info['AuthorName'], 'author_uri' => $plugin_info['AuthorURI']);
}
}
unset($active_plugins, $plugin_path);
$data = array('hash' => $hash, 'url' => get_bloginfo('url'), 'name' => get_bloginfo('name'), 'wp_version' => get_bloginfo('version'), 'sunshine_version' => SUNSHINE_VERSION, 'lang' => get_locale(), 'php_version' => phpversion(), 'theme' => $theme, 'plugins' => $plugins, 'post_counts' => $post_counts);
$args = array('body' => $data, 'blocking' => false, 'sslverify' => false);
wp_remote_post('http://www.sunshinephotocart.com/?tracking=1', $args);
}
示例10: lgItemPostTemp
function lgItemPostTemp($atts)
{
$output = '';
// $grid = lgGetLayoutLemonGridPerPage( get_the_ID(), $atts['element_id'], count( $atts['posts']->posts ) );
$grid = lbGetLemonGridLayouts($atts['element_id'], count($atts['posts']->posts));
/* v1.1 */
$posts = $atts['posts'];
$k = 0;
while ($posts->have_posts()) {
$posts->the_post();
if (has_post_thumbnail()) {
$thumbnail_data = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'full');
$thumbnail = $thumbnail_data[0];
} else {
$thumbnail = '';
}
$style = implode(';', array("background: url({$thumbnail}) no-repeat center center / cover, #333"));
/**
* Title
*/
$_title = '<h2 class=\'title\' title=\'' . get_the_title() . '\'>' . get_the_title() . '</h2>';
/**
* Data
*/
$_date = '<p class=\'date\'>' . get_the_date('M d Y') . '</p>';
/**
* Icon Comment & Author
*/
$comments_count = wp_count_comments(get_the_ID());
$_comment_author = '
<div class=\'comment-author\'>
<span class=\'comment\'><i class=\'ion-android-chat\'></i> ' . $comments_count->total_comments . '</span>
<span class=\'author\'><i class=\'ion-person\'></i> ' . get_the_author() . '</span>
</div>';
$info = '
<div class=\'lemongrid-info\'>
<div class=\'lemongrid-icon\'>
<a title=\'' . get_the_title() . '\' href=\'' . get_permalink() . '\'><i class=\'fa fa-link\'></i></a>
</div>
<div class=\'info-text\'>
' . $_title . '
' . $_date . '
' . $_comment_author . '
</div>
</div>';
$output .= '
<div class=\'lemongrid-item lg-animate-fadein grid-stack-item\' data-gs-x=\'' . esc_attr($grid[$k]['x']) . '\' data-gs-y=\'' . esc_attr($grid[$k]['y']) . '\' data-gs-width=\'' . esc_attr($grid[$k]['w']) . '\' data-gs-height=\'' . esc_attr($grid[$k]['h']) . '\'>
<div class=\'grid-stack-item-content\' style=\'' . esc_attr($style) . '\'>
' . $info . '
</div>
</div>';
$k += 1;
}
wp_reset_postdata();
return $output;
}
示例11: get_raw_value
/**
* @see CPAC_Column::get_raw_value()
* @since 2.0.3
*/
function get_raw_value($post_id)
{
$value = '';
$status = $this->options->comment_status;
$count = wp_count_comments($post_id);
if (isset($count->{$status})) {
$value = $count->{$status};
}
return $value;
}
示例12: ubik_related_score_comments
function ubik_related_score_comments($related)
{
foreach ($related as $id => $count) {
$comments = wp_count_comments($id);
if ($comments->approved >= apply_filters('ubik_related_score_comments_threshold', 3)) {
$related[$id] = $related[$id] + apply_filters('ubik_related_score_comments_factor', 1, $comments->approved);
}
}
return $related;
}
示例13: niche_entry_meta
/**
* Set up post entry meta.
* Meta information for current post: categories, tags, permalink, author, and date.
* */
function niche_entry_meta()
{
$niche_categories_list = get_the_category_list(', ', '');
$niche_tag_list = get_the_tag_list('', ', ');
$niche_author = ucfirst(get_the_author());
$niche_author_url = esc_url(get_author_posts_url(get_the_author_meta('ID')));
$niche_comments = wp_count_comments(get_the_ID());
$niche_date = sprintf('<time datetime="%1$s">%2$s</time>', esc_attr(get_the_date('c')), esc_html(get_the_date('F d , Y')));
?>
<ul>
<li><?php
printf(__('%s', 'niche'), $niche_date);
?>
</li>
<li><?php
_e('By : ', 'niche');
?>
<a href="<?php
echo $niche_author_url;
?>
" rel="tag"><?php
echo $niche_author;
?>
</a></li>
<?php
if (!is_page_template('page-template/front-page.php')) {
?>
<li><?php
if (!empty($niche_categories_list)) {
_e('Category : ', 'niche');
echo $niche_categories_list;
?>
</li><?php
}
?>
<?php
if (!empty($niche_tag_list)) {
?>
<li><?php
_e('Tags : ', 'niche');
echo $niche_tag_list;
?>
</li><?php
}
}
?>
<li><?php
$niche_comment = comments_number(__('Comment : 0', 'niche'), __('Comment : 1', 'niche'), __('Comments : %', 'niche'));
?>
</li>
</ul>
<?php
}
示例14: tracking
/**
* Main tracking function.
*/
function tracking()
{
$transient_key = 'wpec_tracking_cache';
$data = get_transient($transient_key);
// bail if transient is set and valid
if ($data !== false) {
return;
}
// Make sure to only send tracking data once a week
set_transient($transient_key, 1, WEEK_IN_SECONDS);
// Start of Metrics
global $blog_id, $wpdb;
$hash = get_option('WPEC_Tracking_Hash', false);
if (!$hash || empty($hash)) {
// create and store hash
$hash = md5(site_url());
update_option('WPEC_Tracking_Hash', $hash);
}
$pts = array();
$post_types = get_post_types(array('public' => true));
if (is_array($post_types) && $post_types !== array()) {
foreach ($post_types as $post_type) {
$count = wp_count_posts($post_type);
$pts[$post_type] = $count->publish;
}
}
unset($post_types);
$comments_count = wp_count_comments();
$theme_data = wp_get_theme();
$theme = array('name' => $theme_data->display('Name', false, false), 'theme_uri' => $theme_data->display('ThemeURI', false, false), 'version' => $theme_data->display('Version', false, false), 'author' => $theme_data->display('Author', false, false), 'author_uri' => $theme_data->display('AuthorURI', false, false));
$theme_template = $theme_data->get_template();
if ($theme_template !== '' && $theme_data->parent()) {
$theme['template'] = array('version' => $theme_data->parent()->display('Version', false, false), 'name' => $theme_data->parent()->display('Name', false, false), 'theme_uri' => $theme_data->parent()->display('ThemeURI', false, false), 'author' => $theme_data->parent()->display('Author', false, false), 'author_uri' => $theme_data->parent()->display('AuthorURI', false, false));
} else {
$theme['template'] = '';
}
unset($theme_template);
$plugins = array();
$active_plugin = get_option('active_plugins');
foreach ($active_plugin as $plugin_path) {
if (!function_exists('get_plugin_data')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugin_info = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path);
$slug = str_replace('/' . basename($plugin_path), '', $plugin_path);
$plugins[$slug] = array('version' => $plugin_info['Version'], 'name' => $plugin_info['Name'], 'plugin_uri' => $plugin_info['PluginURI'], 'author' => $plugin_info['AuthorName'], 'author_uri' => $plugin_info['AuthorURI']);
}
unset($active_plugins, $plugin_path);
$data = array('site' => array('hash' => $hash, 'version' => get_bloginfo('version'), 'multisite' => is_multisite(), 'users' => $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->users} INNER JOIN {$wpdb->usermeta} ON ({$wpdb->users}.ID = {$wpdb->usermeta}.user_id) WHERE 1 = 1 AND ( {$wpdb->usermeta}.meta_key = %s )", 'wp_' . $blog_id . '_capabilities')), 'lang' => get_locale()), 'pts' => $pts, 'comments' => array('total' => $comments_count->total_comments, 'approved' => $comments_count->approved, 'spam' => $comments_count->spam, 'pings' => $wpdb->get_var("SELECT COUNT(comment_ID) FROM {$wpdb->comments} WHERE comment_type = 'pingback'")), 'options' => apply_filters('wpec_tracking_filters', array()), 'theme' => $theme, 'plugins' => $plugins);
$args = array('body' => $data, 'blocking' => false, 'sslverify' => false);
//wp_die(print_r($data));
wp_remote_post('http://tracking.winwar.co.uk/', $args);
}
示例15: data
static function data()
{
$transient_key = 'sendpress_tracking_cache';
$data = get_transient($transient_key);
// bail if transient is set and valid
if ($data !== false) {
return;
}
// Make sure to only send tracking data once a week
set_transient($transient_key, 1, WEEK_IN_SECONDS);
// Start of Metrics
global $blog_id, $wpdb;
$hash = get_option('SendPress_Tracking_Hash', false);
if (!$hash || empty($hash)) {
// create and store hash
$hash = md5(site_url());
update_option('SendPress_Tracking_Hash', $hash);
}
$pts = array();
$post_types = get_post_types(array('public' => true));
if (is_array($post_types) && $post_types !== array()) {
foreach ($post_types as $post_type) {
$count = wp_count_posts($post_type);
$pts[$post_type] = $count->publish;
}
}
unset($post_types);
$comments_count = wp_count_comments();
$theme_data = wp_get_theme();
$theme = array('name' => $theme_data->display('Name', false, false), 'theme_uri' => $theme_data->display('ThemeURI', false, false), 'version' => $theme_data->display('Version', false, false), 'author' => $theme_data->display('Author', false, false), 'author_uri' => $theme_data->display('AuthorURI', false, false));
$theme_template = $theme_data->get_template();
if ($theme_template !== '' && $theme_data->parent()) {
$theme['template'] = array('version' => $theme_data->parent()->display('Version', false, false), 'name' => $theme_data->parent()->display('Name', false, false), 'theme_uri' => $theme_data->parent()->display('ThemeURI', false, false), 'author' => $theme_data->parent()->display('Author', false, false), 'author_uri' => $theme_data->parent()->display('AuthorURI', false, false));
} else {
$theme['template'] = '';
}
unset($theme_template);
$plugins = array();
$active_plugin = get_option('active_plugins');
foreach ($active_plugin as $plugin_path) {
if (!function_exists('get_plugin_data')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugin_info = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_path);
$slug = str_replace('/' . basename($plugin_path), '', $plugin_path);
$plugins[$slug] = array('version' => $plugin_info['Version'], 'name' => $plugin_info['Name'], 'plugin_uri' => $plugin_info['PluginURI'], 'author' => $plugin_info['AuthorName'], 'author_uri' => $plugin_info['AuthorURI']);
}
unset($active_plugins, $plugin_path);
$lists = SendPress_Data::get_lists();
$data = array('site' => array('hash' => $hash, 'wp_version' => get_bloginfo('version'), 'sp' => SENDPRESS_VERSION, 'pro' => defined('SENDPRESS_PRO_VERSION') ? SENDPRESS_PRO_VERSION : 0, 'lists' => count($lists->posts), 'subscribers' => SendPress_Data::get_total_subscribers(), 'multisite' => is_multisite(), 'lang' => get_locale()), 'pts' => $pts, 'options' => apply_filters('sp_tracking_filters', array()), 'theme' => $theme, 'plugins' => $plugins);
$args = array('body' => $data, 'blocking' => false, 'sslverify' => false);
wp_remote_post('http://api.sendpress.com/api/v1/track/add', $args);
}