PluginProbe ʕ •ᴥ•ʔ
WP Popular Posts / 4.1.1
WP Popular Posts v4.1.1
4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 5.0.0 5.0.1 5.0.2 5.1.0 5.2.0 5.2.1 5.2.2 5.2.3 5.2.4 5.3.0 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.4.0 5.4.1 5.4.2 5.5.0 5.5.1 6.0.0 6.0.1 6.0.2 6.0.3 6.0.4 6.0.5 6.1.0 6.1.1 6.1.2 6.1.3 6.1.4 6.2.0 6.2.1 6.3.0 6.3.1 6.3.2 6.3.3 6.3.4 6.4.0 6.4.1 6.4.2 7.0.0 7.0.1 7.1.0 7.2.0 7.3.0 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.3.6 7.3.7 7.3.8 7.4.0 trunk 2.3.7 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.2 4.0.3 4.0.5 4.0.6
wordpress-popular-posts / includes / class-wordpress-popular-posts-template.php
wordpress-popular-posts / includes Last commit date
class-wordpress-popular-posts-activator.php 8 years ago class-wordpress-popular-posts-deactivator.php 8 years ago class-wordpress-popular-posts-helper.php 8 years ago class-wordpress-popular-posts-i18n.php 8 years ago class-wordpress-popular-posts-image.php 8 years ago class-wordpress-popular-posts-loader.php 8 years ago class-wordpress-popular-posts-output.php 8 years ago class-wordpress-popular-posts-query.php 8 years ago class-wordpress-popular-posts-rest-controller.php 8 years ago class-wordpress-popular-posts-settings.php 8 years ago class-wordpress-popular-posts-template.php 8 years ago class-wordpress-popular-posts-translate.php 8 years ago class-wordpress-popular-posts-widget.php 8 years ago class-wordpress-popular-posts.php 8 years ago widget-form.php 8 years ago
class-wordpress-popular-posts-template.php
106 lines
1 <?php
2 /**
3 * WordPress Popular Posts template tags for use in themes.
4 */
5
6 /**
7 * Template tag - gets views count.
8 *
9 * @since 2.0.3
10 * @global object wpdb
11 * @param int id
12 * @param string range
13 * @param bool number_format
14 * @return string
15 */
16 function wpp_get_views($id = NULL, $range = NULL, $number_format = true) {
17
18 // have we got an id?
19 if ( empty($id) || is_null($id) || !is_numeric($id) ) {
20 return "-1";
21 } else {
22 global $wpdb;
23
24 $table_name = $wpdb->prefix . "popularposts";
25
26 if ( !$range || 'all' == $range ) {
27 $query = "SELECT pageviews FROM {$table_name}data WHERE postid = '{$id}'";
28 } else {
29 $interval = "";
30
31 switch( $range ){
32 case "last24hours":
33 case "daily":
34 $interval = "24 HOUR";
35 break;
36
37 case "last7days":
38 case "weekly":
39 $interval = "6 DAY";
40 break;
41
42 case "last30days":
43 case "monthly":
44 $interval = "29 DAY";
45 break;
46
47 default:
48 $interval = "24 HOUR";
49 break;
50 }
51
52 $now = current_time('mysql');
53
54 $query = "SELECT SUM(pageviews) FROM {$table_name}summary WHERE postid = '{$id}' AND view_datetime > DATE_SUB('{$now}', INTERVAL {$interval}) LIMIT 1;";
55 }
56
57 $result = $wpdb->get_var($query);
58
59 if ( !$result ) {
60 return "0";
61 }
62
63 return ($number_format) ? number_format_i18n( intval($result) ) : $result;
64 }
65
66 }
67
68 /**
69 * Template tag - gets popular posts.
70 *
71 * @since 2.0.3
72 * @param mixed args
73 */
74 function wpp_get_mostpopular($args = NULL) {
75
76 $shortcode = '[wpp';
77
78 if ( is_null( $args ) ) {
79 $shortcode .= ']';
80 } else {
81 if( is_array( $args ) ){
82 $atts = '';
83 foreach( $args as $key => $arg ){
84 $atts .= ' ' . $key . '="' . htmlspecialchars($arg, ENT_QUOTES, $encoding = ini_get("default_charset"), false) . '"';
85 }
86 } else {
87 $atts = trim( str_replace( "&", " ", $args ) );
88 }
89
90 $shortcode .= ' ' . $atts . ' php=true]';
91 }
92
93 echo do_shortcode( $shortcode );
94
95 }
96
97 /**
98 * Template tag - gets popular posts. Deprecated in 2.0.3, use wpp_get_mostpopular instead.
99 *
100 * @since 1.0
101 * @param mixed args
102 */
103 function get_mostpopular($args = NULL) {
104 trigger_error( 'The get_mostpopular() template tag has been deprecated since 2.0.3. Please use wpp_get_mostpopular() instead.', E_USER_WARNING );
105 }
106