当前位置: 首页>>代码示例>>PHP>>正文


PHP stats_get_csv函数代码示例

本文整理汇总了PHP中stats_get_csv函数的典型用法代码示例。如果您正苦于以下问题:PHP stats_get_csv函数的具体用法?PHP stats_get_csv怎么用?PHP stats_get_csv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了stats_get_csv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: jp_get_post_views

/**
 * Get post views from Jetpack.
 */
function jp_get_post_views($postID)
{
    if (function_exists('stats_get_csv')) {
        $post_stats = stats_get_csv('postviews', array('days' => 365, 'limit' => -1));
        foreach ($post_stats as $p) {
            if ($p['post_id'] == $postID) {
                ?>
				<span class='post-views'><?php 
                echo '<i class="fa fa-eye"></i>' . number_format_i18n($p['views']);
                ?>
</span>
			<?php 
            }
        }
    }
}
开发者ID:samuelwidjaya,项目名称:wordpressPortfolio,代码行数:19,代码来源:jetpack.php

示例2: widget

 function widget($args, $instance)
 {
     global $post;
     /* PRINT THE WIDGET */
     extract($args, EXTR_SKIP);
     $instance = wp_parse_args((array) $instance, array('title' => ''));
     $title = esc_attr($instance['title']);
     if (!is_single()) {
         return;
     }
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title;
         echo apply_filters('widget_title', $title, $instance, $this->id_base);
         echo $after_title;
     }
     $name = get_the_author_meta('display_name', $post->post_author);
     echo '<div class="large-icons">';
     echo '<ul>';
     edit_post_link('<i class="icon-pencil"></i>' . __('Edit', 'myThemes'), '<li>', '</li>');
     echo '<li><a href="' . get_day_link(get_post_time('Y', false, $post->ID), get_post_time('m', false, $post->ID), get_post_time('d', false, $post->ID)) . '">';
     echo '<time datetime="' . get_post_time('Y-m-d', false, $post->ID) . '"><i class="icon-calendar"></i>' . get_post_time(get_option('date_format'), false, $post->ID) . '</time></a></li>';
     echo '<li><a href="' . get_author_posts_url($post->post_author) . '" title="' . __('Writed by ', 'myThemes') . ' ' . $name . '"><i class="icon-user-5"></i>' . $name . '</a></li>';
     if ($post->comment_status == 'open') {
         $nr = get_comments_number($post->ID);
         if ($nr == 1) {
             $comments = $nr . ' ' . __('Comment', 'myThemes');
         } else {
             $comments = $nr . ' ' . __('Comments', 'myThemes');
         }
         echo '<li><a href="' . get_comments_link($post->ID) . '"><i class="icon-comment"></i>' . $comments . '</a></li>';
     }
     if (function_exists('stats_get_csv')) {
         $args = array('days' => -1, 'post_id' => $post->ID);
         $result = stats_get_csv('postviews', $args);
         $views = $result[0]['views'];
         $nr_views = number_format_i18n($views);
         $label_views = __('views', 'myThemes');
         if ($nr_views == 1) {
             $label_views = __('view', 'myThemes');
         }
         echo '<li><i class="icon-eye-2"></i> ' . $nr_views . ' ' . $label_views . '</li>';
     }
     echo '</ul>';
     echo '</div>';
     echo $after_widget;
 }
开发者ID:serpentinegalleries,项目名称:marathon-transformation,代码行数:47,代码来源:my_wdg_meta.php

示例3: widget

 function widget($args, $instance)
 {
     global $post;
     /* PRINT THE WIDGET */
     extract($args, EXTR_SKIP);
     $instance = wp_parse_args((array) $instance, array('title' => ''));
     $title = $instance['title'];
     if (!is_single()) {
         return;
     }
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title;
         echo apply_filters('widget_title', esc_attr($title), $instance, $this->id_base);
         echo $after_title;
     }
     $y = esc_attr(get_post_time('Y', false, $post->ID));
     $m = esc_attr(get_post_time('m', false, $post->ID));
     $d = esc_attr(get_post_time('d', false, $post->ID));
     $name = get_the_author_meta('display_name', $post->post_author);
     $dtime = get_post_time('Y-m-d', false, $post->ID);
     $ptime = get_post_time(esc_attr(get_option('date_format')), false, $post->ID, true);
     echo '<div class="large-icons">';
     echo '<ul>';
     edit_post_link('<i class="icon-pencil"></i>' . __('Edit', 'treeson'), '<li>', '</li>');
     echo '<li><a href="' . esc_url(get_day_link($y, $m, $d)) . '">';
     echo '<time datetime="' . esc_attr($dtime) . '"><i class="icon-calendar"></i>' . esc_html($ptime) . '</time></a></li>';
     echo '<li><a href="' . esc_url(get_author_posts_url($post->post_author)) . '" title="' . sprintf(__('Writed by %s', 'treeson'), esc_attr($name)) . '"><i class="icon-user-5"></i>' . esc_html($name) . '</a></li>';
     if ($post->comment_status == 'open') {
         $nr = get_comments_number($post->ID);
         echo '<li>';
         echo '<a href="' . esc_url(get_comments_link($post->ID)) . '">';
         echo '<i class="icon-comment"></i>';
         echo sprintf(_nx('%s Comment', '%s Comments', absint($nr), 'Number of comment(s) from widget "myThemes: Meta Details"', 'treeson'), number_format_i18n(absint($nr)));
         echo '</a></li>';
     }
     if (function_exists('stats_get_csv')) {
         $args = array('days' => -1, 'post_id' => $post->ID);
         $result = stats_get_csv('postviews', $args);
         $views = $result[0]['views'];
         echo '<li><i class="icon-eye-2"></i> ' . sprintf(_n('%s view', '%s views', absint($views), 'treeson'), number_format_i18n(absint($views))) . '</li>';
     }
     echo '</ul>';
     echo '</div>';
     echo $after_widget;
 }
开发者ID:roundtopdog,项目名称:wordpress,代码行数:46,代码来源:mythemes.post_meta.class.php

示例4: trendy

    function trendy()
    {
        /* The Code ----------------- */
        if (function_exists('stats_get_csv')) {
            $top_posts = stats_get_csv('postviews', 'days=7&limit=5');
            if (count($top_posts) > 0) {
                echo '<ul>';
                foreach ($top_posts as $p) {
                    ?>
				<li><a href="<?php 
                    echo $p['post_permalink'];
                    ?>
"><?php 
                    echo $p['post_title'];
                    ?>
</a></li>
<?php 
                }
                echo '</ul>';
            }
        }
        /* End of The Code ---------- */
    }
开发者ID:boogah,项目名称:Trendy,代码行数:23,代码来源:wp-trendy.php

示例5: wpcom_vip_get_post_pageviews

/**
 * Get the number of pageviews for a given post ID (defaults to the current post)
 *
 * Note that it is not currently possible to retrieve the post views for
 * the homepage using this function
 *
 * @param int          $post_id   Optional. The post ID to fetch stats for. Defaults to the $post global's value.
 * @param int          $num_days  Optional. How many days to go back to include in the stats. Default is 1. Maximum 90 days.
 * @param string|bool  $end_data  Optional. The last day of the desired time frame. Format is 'Y-m-d' (e.g. 2007-05-01) and default is today's UTC date.
 * @return int|false Number of pageviews or false on error.
 */
function wpcom_vip_get_post_pageviews($post_id = null, $num_days = 1, $end_date = false)
{
    // Check Jetpack is present and active
    if (class_exists('Jetpack') && Jetpack::is_active()) {
        $args = array('post_id' => $post_id, 'num_days' => $num_days, 'end_date' => $end_date);
        // Default post_id to the current post ID, and check it's an int
        if (is_null($args['post_id'])) {
            $args['post_id'] = get_the_ID();
        }
        $args['post_id'] = absint($args['post_id']);
        if (empty($args['post_id'])) {
            return false;
        }
        // Ensure num_days is least 1, but no more than 90
        $args['num_days'] = max(1, min(90, absint($args['num_days'])));
        $posts = stats_get_csv('postviews', $args);
        $views = $posts[0];
    } else {
        // If Jetpack is not present or not active, fake the data returned
        $views = mt_rand(0, 20000);
    }
    return absint($views);
}
开发者ID:humanmade,项目名称:vip-mu-plugins-public,代码行数:34,代码来源:vip-stats.php

示例6: sgwindow_posted_on

    /**
     * Print HTML with meta information for the current post-date/time and author.
     *
     * @since SG Window 1.0.0
     */
    function sgwindow_posted_on()
    {
        $is_author = is_singular() ? '1' == sgwindow_get_theme_mod('is_author') ? true : false : ('1' == sgwindow_get_theme_mod('blog_is_author') ? true : false);
        $is_date = is_singular() ? '1' == sgwindow_get_theme_mod('is_date') ? true : false : ('1' == sgwindow_get_theme_mod('blog_is_date') ? true : false);
        $is_comments = is_singular() ? '1' == sgwindow_get_theme_mod('is_comments') ? true : false : ('1' == sgwindow_get_theme_mod('blog_is_comments') ? true : false);
        $is_views = is_singular() ? '1' == sgwindow_get_theme_mod('is_views') ? true : false : ('1' == sgwindow_get_theme_mod('blog_is_views') ? true : false);
        $rez = '';
        // Set up and print post meta information.
        if ($is_date) {
            echo '<span class="entry-date">
					<a href="' . esc_url(get_permalink()) . '" title="' . esc_attr(get_the_date('')) . '" rel="bookmark">
						<span class="entry-date" datetime="' . esc_attr(get_the_date('')) . '">' . esc_html(get_the_date()) . '</span>
					</a>
			 </span>';
        }
        if ($is_author) {
            echo '<span class="byline">
				<span title="' . get_the_author() . '" class="author vcard">
					<a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '" rel="author">' . get_the_author() . '</a>
				</span>
			</span>';
        }
        if ($is_views) {
            if (class_exists('Jetpack') && Jetpack::is_module_active('stats') && function_exists('stats_get_csv')) {
                $result = $result = stats_get_csv('postviews', 'post_id=' . get_the_ID() . '&days=-1&limit=-1&summarize');
                echo '<span class="post-views" title="' . number_format_i18n($result[0]['views']) . '">' . number_format_i18n($result[0]['views']) . '</span>';
            }
        }
        if ($is_comments) {
            if (!is_single() && !post_password_required() && (comments_open() || get_comments_number())) {
                echo '<span class="comments-link">';
                comments_popup_link(__('Leave a comment', 'sg-window'), __('1 Comment', 'sg-window'), __('% Comments', 'sg-window'));
                echo '</span>';
            }
        }
    }
开发者ID:a-i-ko93,项目名称:ipl-foodblog,代码行数:41,代码来源:functions.php

示例7: shortcode_to_args

 /**
  * converts a pagebuilde array to a wordpress query args array
  * creates the $args array from shortcodes - used by the pagebuilde + widgets + by the metabox_to_args
  * @param string $atts : the shortcode string
  * @param string $paged : page number  /1  or  /2
  * @return array
  */
 static function shortcode_to_args($atts = '', $paged = '')
 {
     //print_r($atts);
     extract(shortcode_atts(array('category_ids' => '', 'category_id' => '', 'tag_slug' => '', 'sort' => '', 'limit' => '', 'autors_id' => '', 'installed_post_types' => '', 'posts_per_page' => '', 'offset' => '', 'live_filter' => '', 'live_filter_cur_post_id' => '', 'live_filter_cur_post_author' => ''), $atts));
     //init the array
     $wp_query_args = array('ignore_sticky_posts' => 1, 'post_status' => 'publish');
     /*  ----------------------------------------------------------------------
             jetpack sorting - this will return here if that's the case because it dosn't work with other filters (it's site wide, no category + this or other combinations)
         */
     if ($sort == 'jetpack_popular_2') {
         if (function_exists('stats_get_csv')) {
             // the damn jetpack api cannot return only posts so it may return pages. That's why we query with a bigger + 5 limit
             // so that if the api returns also 5 pages mixed with the post we will still have the desired number of posts
             $jetpack_api_posts = stats_get_csv('postviews', array('days' => 2, 'limit' => $limit + 5));
             if (!empty($jetpack_api_posts) and is_array($jetpack_api_posts)) {
                 $wp_query_args['post__in'] = wp_list_pluck($jetpack_api_posts, 'post_id');
                 $wp_query_args['posts_per_page'] = $limit;
                 return $wp_query_args;
             }
         }
         return array();
         // empty array makes WP_Query not run
     }
     //the query goes only via $category_ids - for both options ($category_ids and $category_id) also $category_ids overwrites $category_id
     if (!empty($category_id) and empty($category_ids)) {
         $category_ids = $category_id;
     }
     if (!empty($category_ids)) {
         $wp_query_args['cat'] = $category_ids;
     }
     if (!empty($tag_slug)) {
         $wp_query_args['tag'] = str_replace(' ', '-', $tag_slug);
     }
     switch ($sort) {
         case 'featured':
             if (!empty($category_ids)) {
                 //for each category, get the object and compose the slug
                 $cat_id_array = explode(',', $category_ids);
                 foreach ($cat_id_array as &$cat_id) {
                     $cat_id = trim($cat_id);
                     //get the category object
                     $td_tmp_cat_obj = get_category($cat_id);
                     //make the $args
                     if (empty($wp_query_args['category_name'])) {
                         $wp_query_args['category_name'] = $td_tmp_cat_obj->slug;
                         //get by slug (we get the children categories too)
                     } else {
                         $wp_query_args['category_name'] .= ',' . $td_tmp_cat_obj->slug;
                         //get by slug (we get the children categories too)
                     }
                     unset($td_tmp_cat_obj);
                 }
             }
             $wp_query_args['cat'] = get_cat_ID(TD_FEATURED_CAT);
             //add the fetured cat
             break;
         case 'popular':
             $wp_query_args['meta_key'] = td_page_views::$post_view_counter_key;
             $wp_query_args['orderby'] = 'meta_value_num';
             $wp_query_args['order'] = 'DESC';
             break;
         case 'popular7':
             $wp_query_args['meta_key'] = td_page_views::$post_view_counter_7_day_total;
             $wp_query_args['orderby'] = 'meta_value_num';
             $wp_query_args['order'] = 'DESC';
             break;
         case 'review_high':
             $wp_query_args['meta_key'] = td_review::$td_review_key;
             $wp_query_args['orderby'] = 'meta_value_num';
             $wp_query_args['order'] = 'DESC';
             break;
         case 'random_posts':
             $wp_query_args['orderby'] = 'rand';
             break;
         case 'alphabetical_order':
             $wp_query_args['orderby'] = 'title';
             $wp_query_args['order'] = 'ASC';
             break;
         case 'comment_count':
             $wp_query_args['orderby'] = 'comment_count';
             $wp_query_args['order'] = 'DESC';
             break;
         case 'random_today':
             $wp_query_args['orderby'] = 'rand';
             $wp_query_args['year'] = date('Y');
             $wp_query_args['monthnum'] = date('n');
             $wp_query_args['day'] = date('j');
             break;
         case 'random_7_day':
             $wp_query_args['orderby'] = 'rand';
             $wp_query_args['date_query'] = array('column' => 'post_date_gmt', 'after' => '1 week ago');
             break;
     }
//.........这里部分代码省略.........
开发者ID:weerapat,项目名称:wp-daily,代码行数:101,代码来源:td_data_source.php

示例8: stats_dashboard_widget_content

function stats_dashboard_widget_content()
{
    $blog_id = stats_get_option('blog_id');
    if (!($width = (int) ($_GET['width'] / 2)) || $width < 250) {
        $width = 370;
    }
    if (!($height = (int) $_GET['height'] - 36) || $height < 230) {
        $height = 230;
    }
    $_width = $width - 5;
    $_height = $height - ($GLOBALS['is_winIE'] ? 16 : 5);
    // hack!
    $options = stats_dashboard_widget_options();
    $http = !empty($_SERVER['HTTPS']) ? 'https' : 'http';
    $src = clean_url("{$http}://dashboard.wordpress.com/wp-admin/index.php?page=estats&blog={$blog_id}&noheader=true&chart&unit={$options['chart']}&width={$_width}&height={$_height}");
    echo "<iframe id='stats-graph' class='stats-section' frameborder='0' style='width: {$width}px; height: {$height}px; overflow: hidden' src='{$src}'></iframe>";
    $post_ids = array();
    if (version_compare('2.7-z', $GLOBALS['wp_version'], '<=')) {
        $csv_args = array('top' => '&limit=8', 'active' => '&limit=5', 'search' => '&limit=5');
        $printf = __('%s %s Views');
    } else {
        $csv_args = array('top' => '', 'active' => '', 'search' => '');
        $printf = __('%s, %s views');
    }
    foreach ($top_posts = stats_get_csv('postviews', "days={$options['top']}{$csv_args['top']}") as $post) {
        $post_ids[] = $post['post_id'];
    }
    foreach ($active_posts = stats_get_csv('postviews', "days={$options['active']}{$csv_args['active']}") as $post) {
        $post_ids[] = $post['post_id'];
    }
    // cache
    get_posts(array('include' => join(',', array_unique($post_ids))));
    $searches = array();
    foreach ($search_terms = stats_get_csv('searchterms', "days={$options['search']}{$csv_args['search']}") as $search_term) {
        $searches[] = $search_term['searchterm'];
    }
    ?>
<div id="stats-info">
	<div id="top-posts" class='stats-section'>
		<div class="stats-section-inner">
		<h4 class="heading"><?php 
    _e('Top Posts');
    ?>
</h4>
		<?php 
    foreach ($top_posts as $post) {
        if (!get_post($post['post_id'])) {
            continue;
        }
        ?>
		<p><?php 
        printf($printf, '<a href="' . get_permalink($post['post_id']) . '">' . get_the_title($post['post_id']) . '</a>', number_format_i18n($post['views']));
        ?>
</p>
		<?php 
    }
    ?>
		</div>
	</div>
	<div id="top-search" class='stats-section'>
		<div class="stats-section-inner">
		<h4 class="heading"><?php 
    _e('Top Searches');
    ?>
</h4>
		<p><?php 
    echo join(',&nbsp; ', $searches);
    ?>
</p>
		</div>
	</div>
	<div id="active" class='stats-section'>
		<div class="stats-section-inner">
		<h4 class="heading"><?php 
    _e('Most Active');
    ?>
</h4>
		<?php 
    foreach ($active_posts as $post) {
        if (!get_post($post['post_id'])) {
            continue;
        }
        ?>
		<p><?php 
        printf($printf, '<a href="' . get_permalink($post['post_id']) . '">' . get_the_title($post['post_id']) . '</a>', number_format_i18n($post['views']));
        ?>
</p>
		<?php 
    }
    ?>
		</div>
	</div>
</div>
<br class="clear" />
<p class="textright">
	<a class="button" href="index.php?page=stats"><?php 
    _e('View All');
    ?>
</a>
</p>
//.........这里部分代码省略.........
开发者ID:SymbiSoft,项目名称:litprojects,代码行数:101,代码来源:stats.php

示例9: bloginfo

    <li><a href="<?php 
bloginfo('rss2_url');
?>
" title="<?php 
_e('RSS 2.0');
?>
">
    <img src="/wp-content/themes/goshen/img/feed-icon.png" alt="RSS 2.0" title="RSS 2.0" /> RSS 2.0</a></li>
</ul>
<?php 
if (function_exists('stats_get_csv')) {
    ?>
	<h2>Most-viewed</h2>
	<ul id="popularposts">
	<?php 
    $top_posts = stats_get_csv('postviews', 'days=60&limit=13');
    $i = 0;
    foreach ($top_posts as $post) {
        if (!get_post($post['post_id']) || empty($post['post_id']) || in_array($post['post_id'], array(2, 9, 85, 526))) {
            continue;
        }
        echo '<li><a href="' . get_permalink($post['post_id']) . '">' . get_the_title($post['post_id']) . '</a><div class="commentsnumber">' . get_comments_number($post['post_id']) . ' comments</div></li>';
        $i++;
        if ($i >= 5) {
            break;
        }
    }
    ?>
	</ul>
<?php 
}
开发者ID:ShovanDhara,项目名称:goshen-wordpress-theme,代码行数:31,代码来源:sidebar.php

示例10: edit_post_link

 echo '<ul>';
 edit_post_link('<i class="icon-pencil"></i>' . __('Edit', 'materialize'), '<li>', '</li>');
 echo '<li><a href="' . esc_url(get_day_link($y, $m, $d)) . '">';
 echo '<time datetime="' . esc_attr($dtime) . '"><i class="icon-calendar"></i>' . esc_html($ptime) . '</time></a></li>';
 echo '<li><a href="' . esc_url(get_author_posts_url($post->post_author)) . '" title="' . sprintf(__('Writed by %s', 'materialize'), esc_attr($name)) . '"><i class="icon-user-5"></i>' . esc_html($name) . '</a></li>';
 if ($post->comment_status == 'open') {
     $nr = get_comments_number($post->ID);
     echo '<li>';
     echo '<a href="' . esc_url(get_comments_link($post->ID)) . '">';
     echo '<i class="icon-comment-5"></i>';
     echo sprintf(_nx('%s Comment', '%s Comments', absint($nr), 'Number of comment(s) from widget "myThemes: Meta Details"', 'materialize'), number_format_i18n(absint($nr)));
     echo '</a></li>';
 }
 if (function_exists('stats_get_csv')) {
     $args = array('days' => -1, 'post_id' => $post->ID);
     $result = stats_get_csv('postviews', $args);
     $views = $result[0]['views'];
     echo '<li><i class="icon-eye-2"></i> ' . sprintf(_n('%s view', '%s views', absint($views), 'materialize'), number_format_i18n(absint($views))) . '</li>';
 }
 echo '</ul>';
 echo '</div>';
 echo '</div>';
 /* ARTICLE CATEGORIES */
 if (has_category()) {
     echo '<div class="widget widget_post_categories mythemes-default-content ' . esc_attr($default_class) . '">';
     echo '<h4 class="widget-title">' . __('Article Categories', 'materialize') . '</h4>';
     echo '<div>';
     echo '<ul>';
     echo '<li>';
     the_category('</li><li>');
     echo '</li>';
开发者ID:AWD-Development,项目名称:tornado_zahid,代码行数:31,代码来源:sidebar-post.php

示例11: widget

    /**
     * Widget output
     *
     * @since SG Window 1.1.0
     *
     */
    function widget($args, $instance)
    {
        // Widget output
        extract($args);
        // Set up some default widget settings.
        $instance = wp_parse_args((array) $instance, $this->defaults($instance));
        $curr_query = null;
        $popular_posts = null;
        if (1 == $instance['content_type']) {
            global $post;
            $not_in = array();
            if (is_singular()) {
                $not_in[] = $post->ID;
            }
            $not_in = array_merge($not_in, get_option('sticky_posts'));
            $args = array();
            $tax = 'category';
            if ('0' != $instance['category']) {
                $args = array(array('taxonomy' => $tax, 'terms' => array($instance['category']), 'field' => 'term_id', 'operator' => 'IN'));
            }
            $query = new WP_Query(array('order' => 'DESC', 'orderby' => $instance['order'], 'posts_per_page' => $instance['count'], 'no_found_rows' => true, 'post_status' => 'publish', 'has_password' => false, 'post__not_in' => $not_in, 'post_type' => array('post'), 'tax_query' => $args));
            $curr_query = $query;
        } elseif (3 == $instance['content_type']) {
            //from current query
            global $wp_query;
            $curr_query = $wp_query;
        } elseif (4 == $instance['content_type']) {
            //featured posts
            global $post;
            $not_in = array();
            if (is_singular()) {
                $not_in[] = $post->ID;
            }
            $sticky = get_option('sticky_posts');
            $args = array();
            $tax = 'category';
            if ('0' != $instance['category']) {
                $args = array(array('taxonomy' => $tax, 'terms' => array($instance['category']), 'field' => 'term_id', 'operator' => 'IN'));
            }
            $query = new WP_Query(array('order' => 'DESC', 'orderby' => $instance['order'], 'posts_per_page' => $instance['count'], 'no_found_rows' => true, 'post_status' => 'publish', 'has_password' => false, 'post__in' => $sticky, 'post__not_in' => $not_in, 'post_type' => array('post'), 'tax_query' => $args));
            $curr_query = $query;
        } elseif (2 == $instance['content_type']) {
            //portfolio
            global $post;
            $not_in = array();
            if (is_singular()) {
                $not_in[] = $post->ID;
            }
            $not_in = array_merge($not_in, get_option('sticky_posts'));
            $args = array();
            $tax = 'jetpack-portfolio-type';
            if ('0' != $instance['jetpack-portfolio-type']) {
                $args = array(array('taxonomy' => $tax, 'terms' => array($instance['jetpack-portfolio-type']), 'field' => 'term_id', 'operator' => 'IN'));
            }
            $query = new WP_Query(array('order' => 'DESC', 'posts_per_page' => $instance['count'], 'no_found_rows' => true, 'post_status' => 'publish', 'has_password' => false, 'post__not_in' => $not_in, 'post_type' => 'jetpack-portfolio', 'tax_query' => $args));
            $curr_query = $query;
        } elseif (6 == $instance['content_type']) {
            //popular posts
            if (class_exists('Jetpack') && Jetpack::is_module_active('stats') && function_exists('stats_get_csv')) {
                $popular_posts = stats_get_csv('postviews', 'days=-1&limit=-1');
            }
        } elseif (5 == $instance['content_type']) {
            //related posts
            global $post;
            $not_in = array();
            if (is_singular()) {
                $not_in[] = $post->ID;
            }
            $not_in = array_merge($not_in, get_option('sticky_posts'));
            $args = array();
            $args = array('relation' => 'OR', array('taxonomy' => 'category', 'terms' => wp_get_post_categories($post->ID), 'field' => 'term_id', 'operator' => 'IN'), array('taxonomy' => 'post_tag', 'terms' => wp_get_post_tags($post->ID, array('fields' => 'ids')), 'field' => 'term_id', 'operator' => 'IN'));
            $query = new WP_Query(array('order' => 'DESC', 'orderby' => $instance['order'], 'posts_per_page' => $instance['count'], 'no_found_rows' => true, 'post_status' => 'publish', 'has_password' => false, 'post__not_in' => $not_in, 'post_type' => array('post'), 'tax_query' => $args));
            $curr_query = $query;
        }
        //print the widget for the sidebar
        if (0 == $instance['content_type'] || isset($curr_query) && $curr_query->have_posts() || isset($popular_posts)) {
            echo $before_widget;
            $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
            if ('' !== trim($instance['title'])) {
                echo $before_title . esc_html($instance['title']) . $after_title;
            }
            if (0 == $instance['content_type']) {
                for ($i = 0; $i < $instance['count']; $i++) {
                    if (!isset($instance['is_link_' . $i]) || empty($instance['is_link_' . $i])) {
                        $instance['is_link_' . $i] = $instance['is_link'];
                    }
                    if (!isset($instance['link_' . $i]) || empty($instance['link_' . $i])) {
                        $instance['link_' . $i] = '#';
                    }
                    if (!isset($instance['img_' . $i]) || empty($instance['img_' . $i]) || '' == $instance['img_' . $i]) {
                        $instance['img_' . $i] = $instance['empty'];
                    }
                    if (!isset($instance['title_' . $i]) || empty($instance['title_' . $i])) {
                        $instance['title_' . $i] = __('Slide Title', 'sg-window') . ' ' . ($i + 1);
//.........这里部分代码省略.........
开发者ID:a-i-ko93,项目名称:ipl-foodblog,代码行数:101,代码来源:widget-slider.php

示例12: stats_dashboard_widget_content

function stats_dashboard_widget_content()
{
    $blog_id = stats_get_option('blog_id');
    if (!($width = (int) ($_GET['width'] / 2)) || $width < 250) {
        $width = 370;
    }
    if (!($height = (int) $_GET['height'] - 36) || $height < 230) {
        $height = 230;
    }
    $_width = $width - 5;
    $_height = $height - ($GLOBALS['is_winIE'] ? 16 : 5);
    // hack!
    $options = stats_dashboard_widget_options();
    $q = array('noheader' => 'true', 'proxy' => '', 'page' => 'stats', 'blog' => $blog_id, 'key' => stats_get_api_key(), 'chart' => '', 'unit' => $options['chart'], 'width' => $_width, 'height' => $_height);
    $url = 'http://dashboard.wordpress.com/wp-admin/index.php';
    $url = add_query_arg($q, $url);
    $get = wp_remote_get($url, array('timeout' => 300));
    if (is_wp_error($get) || empty($get['body'])) {
        $http = $_SERVER['HTTPS'] ? 'https' : 'http';
        $src = clean_url("{$http}://dashboard.wordpress.com/wp-admin/index.php?page=estats&blog={$blog_id}&noheader=true&chart&unit={$options['chart']}&width={$_width}&height={$_height}");
        echo "<iframe id='stats-graph' class='stats-section' frameborder='0' style='width: {$width}px; height: {$height}px; overflow: hidden' src='{$src}'></iframe>";
    } else {
        $body = stats_convert_post_titles($get['body']);
        $body = stats_convert_swf_urls($body);
        $body = stats_convert_chart_urls($body);
        $body = stats_convert_image_urls($body);
        echo $body;
    }
    $post_ids = array();
    if (version_compare('2.7-z', $GLOBALS['wp_version'], '<=')) {
        $csv_args = array('top' => '&limit=8', 'active' => '&limit=5', 'search' => '&limit=5');
        /* translators: Stats dashboard widget postviews list: "$post_title $views Views" */
        $printf = __('%1$s %2$s Views', 'stats');
    } else {
        $csv_args = array('top' => '', 'active' => '', 'search' => '');
        /* translators: Stats dashboard widget postviews list: "$post_title, $views Views" */
        $printf = __('%1$s, %2$s views', 'stats');
    }
    foreach ($top_posts = stats_get_csv('postviews', "days={$options['top']}{$csv_args['top']}") as $post) {
        $post_ids[] = $post['post_id'];
    }
    foreach ($active_posts = stats_get_csv('postviews', "days={$options['active']}{$csv_args['active']}") as $post) {
        $post_ids[] = $post['post_id'];
    }
    // cache
    get_posts(array('include' => join(',', array_unique($post_ids))));
    $searches = array();
    foreach ($search_terms = stats_get_csv('searchterms', "days={$options['search']}{$csv_args['search']}") as $search_term) {
        $searches[] = esc_html($search_term['searchterm']);
    }
    ?>
<div id="stats-info">
	<div id="top-posts" class='stats-section'>
		<div class="stats-section-inner">
		<h4 class="heading"><?php 
    _e('Top Posts', 'stats');
    ?>
</h4>
		<?php 
    foreach ($top_posts as $post) {
        if (!get_post($post['post_id'])) {
            continue;
        }
        ?>
		<p><?php 
        printf($printf, '<a href="' . get_permalink($post['post_id']) . '">' . get_the_title($post['post_id']) . '</a>', number_format_i18n($post['views']));
        ?>
</p>
		<?php 
    }
    ?>
		</div>
	</div>
	<div id="top-search" class='stats-section'>
		<div class="stats-section-inner">
		<h4 class="heading"><?php 
    _e('Top Searches', 'stats');
    ?>
</h4>
		<p><?php 
    echo join(',&nbsp; ', $searches);
    ?>
</p>
		</div>
	</div>
	<div id="active" class='stats-section'>
		<div class="stats-section-inner">
		<h4 class="heading"><?php 
    _e('Most Active', 'stats');
    ?>
</h4>
		<?php 
    foreach ($active_posts as $post) {
        if (!get_post($post['post_id'])) {
            continue;
        }
        ?>
		<p><?php 
        printf($printf, '<a href="' . get_permalink($post['post_id']) . '">' . get_the_title($post['post_id']) . '</a>', number_format_i18n($post['views']));
        ?>
//.........这里部分代码省略.........
开发者ID:hypenotic,项目名称:slowfood,代码行数:101,代码来源:stats.php

示例13: getPopularIDs

 /**
  * Lecture des stats Jetpack afin d'y récupérer les articles/pages populaires.
  * 
  * @param int $days Période concernée.
  * 
  * @return array Tableau d'ID.
  */
 private function getPopularIDs($days)
 {
     //Lecture des articles populaires sur la période demandée.
     $post_view_posts = stats_get_csv('postviews', array('days' => $days, 'limit' => 100));
     if (!$post_view_posts) {
         return array();
     }
     //On récupère les ID.
     $post_view_ids = array_filter(wp_list_pluck($post_view_posts, 'post_id'));
     if (!$post_view_ids) {
         return array();
     }
     return $post_view_ids;
 }
开发者ID:luqman74,项目名称:lemur2013,代码行数:21,代码来源:jetpack-popular-posts.php

示例14: widget

    function widget($args, $instance)
    {
        extract($args);
        /* Our variables from the widget settings. */
        $number = $instance['number'];
        echo $before_widget;
        ?>

		<div class="tabbed-widget">
			<ul class="nav nav-tabs role="tablist"">
				<li role="presentation" class="active"><a href="#popular" aria-controls="popular" role="tab" data-toggle="tab"><i class="fa fa-fire"></i><?php 
        _e('Popular', 'ta-portfolio');
        ?>
</a></li>
				<li role="presentation"><a href="#recent" aria-controls="recent" role="tab" data-toggle="tab"><i class="fa fa-clock-o"></i><?php 
        _e('Recent', 'ta-portfolio');
        ?>
</a></li>
				<li role="presentation"><a href="#message" aria-controls="message" role="tab" data-toggle="tab"><i class="fa fa-comments"></i></a></li>
			</ul>

			<div class="tab-content">
				<div role="tabpanel" id="popular" class="tab-pane active">
					<?php 
        if (function_exists('stats_get_csv')) {
            // get popular posts by WordPress.com states if Jetpack plugin installed.
            $count = 0;
            $popular_posts = stats_get_csv('postviews', array('days' => 30, 'limit' => -1));
            ?>
						<div class="post-content">
							<?php 
            foreach ($popular_posts as $p) {
                if ($count >= $number) {
                    break;
                }
                if ('post' == get_post_type($p['post_id']) && 'publish' == get_post_status($p['post_id']) && false == post_password_required($p['post_id']) && 0 != $p['post_id']) {
                    ?>
									<div class="post-content">
										<div class="tab-image">
											<?php 
                    if (has_post_thumbnail($p['post_id'])) {
                        ?>
												<a href="<?php 
                        echo $p['post_permalink'];
                        ?>
" title="<?php 
                        echo $p['post_title'];
                        ?>
">
													<?php 
                        echo get_the_post_thumbnail($p['post_id'], 'tab-image');
                        ?>
												</a>
											<?php 
                    }
                    ?>
										</div>

										<div class="post-title">
											<i class="fa fa-eye"></i><i><?php 
                    echo $p['views'] . ' ' . __('Monthly Views', 'ta-portfolio');
                    ?>
</i>
											<p><a href="<?php 
                    echo $p['post_permalink'];
                    ?>
" rel="bookmark" title="<?php 
                    echo $p['post_title'];
                    ?>
"><?php 
                    echo $p['post_title'];
                    ?>
</a></p>
										</div>
									</div>
								<?php 
                    $count++;
                }
            }
            ?>
						</div>
					<?php 
        } else {
            // get popular posts by comment count.
            $popular_posts = new WP_Query(array('showposts' => $number, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'has_password' => false, 'orderby' => 'comment_count', 'order' => 'DESC'));
            while ($popular_posts->have_posts()) {
                $popular_posts->the_post();
                ?>

							<div class="post-content">
								<div class="tab-image">
									<?php 
                if (has_post_thumbnail()) {
                    ?>
										<a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    the_title_attribute();
                    ?>
//.........这里部分代码省略.........
开发者ID:samuelwidjaya,项目名称:wordpressPortfolio,代码行数:101,代码来源:widget-post-tabs.php

示例15: db_popular_post_aggregator

function db_popular_post_aggregator()
{
    if (function_exists('stats_get_csv')) {
        global $wpdb;
        $table_name = $wpdb->base_prefix . 'db_stats';
        $blogID = get_current_blog_id();
        // get any row with blog ID for date comparison
        $result = $wpdb->get_row("SELECT * FROM {$table_name} WHERE blog_id = {$blogID} ORDER BY date_added ASC LIMIT 1", ARRAY_A);
        if (!$result || strtotime($result['date_added']) + 0 < time()) {
            // supposedly grabbing post views from past 60 months...
            $top_posts = stats_get_csv('postviews', 'period=month&days=60&limit=-1');
            if ($top_posts) {
                $wpdb->delete($table_name, array('blog_id' => $blogID), array('%d'));
                $accepted_post_types = array('post', 'premiere');
                foreach ($top_posts as $post) {
                    $postID = absint($post['post_id']);
                    $post_views = $post['views'];
                    if ($postID <= 0) {
                        continue;
                    }
                    if (!in_array(get_post_type($postID), $accepted_post_types)) {
                        continue;
                    }
                    $arr = array('blog_id' => $blogID, 'post_id' => $postID, 'views' => $post_views, 'date_added' => date('Y-m-d H:i:s', time()));
                    $wpdb->insert($table_name, $arr, array('%d', '%d', '%d', '%s'));
                    update_post_meta($postID, 'db_weekly_views', $post_views);
                }
            }
        }
    }
    die;
}
开发者ID:jacobraccuia,项目名称:dailybeatmedia,代码行数:32,代码来源:functions.php


注:本文中的stats_get_csv函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。