PluginProbe
WebberZone Top 10 — Popular Posts / 1.3
WebberZone Top 10 — Popular Posts v1.3
4.5.1 4.5.0 4.4.3 4.4.2 4.4.1 4.4.0 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 trunk 1.0 1.0.1 1.1 1.2 1.3 1.4 1.4.1 1.5 1.5.1 1.5.2 1.5.3 1.6 1.6.1 All 117 releases
top-10 / top-10-daily.js.php

top-10-daily.js.php in WebberZone Top 10 — Popular Posts 1.3, at top-10-daily.js.php

53 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 //"top-10-daily.js.php" Display Daily Popular Lists.
3 Header("content-type: application/x-javascript");
4
5 if (!function_exists('add_action')) {
6 $wp_root = '../../..';
7 if (file_exists($wp_root.'/wp-load.php')) {
8 require_once($wp_root.'/wp-load.php');
9 } else {
10 require_once($wp_root.'/wp-config.php');
11 }
12 }
13
14 // Display counter using Ajax
15 function tptn_daily_lists() {
16 global $wpdb, $siteurl, $tableposts, $id;
17 $table_name = $wpdb->prefix . "top_ten_daily";
18
19 $is_widget = intval($_GET['widget']);
20
21 $tptn_settings = tptn_read_options();
22 $limit = $tptn_settings['limit'];
23 $daily_range = $tptn_settings[daily_range]. ' DAY';
24 $current_date = $wpdb->get_var("SELECT DATE_ADD(DATE_SUB(CURDATE(), INTERVAL $daily_range), INTERVAL 1 DAY) ");
25
26 $sql = "SELECT postnumber, SUM(cntaccess) as sumCount, dp_date, ID, post_type, post_status ";
27 $sql .= "FROM $table_name INNER JOIN ". $wpdb->posts ." ON postnumber=ID " ;
28 if ($tptn_settings['exclude_pages']) $sql .= "AND post_type = 'post' ";
29 $sql .= "AND post_status = 'publish' AND dp_date >= '$current_date' ";
30 $sql .= "GROUP BY postnumber ";
31 $sql .= "ORDER BY sumCount DESC LIMIT $limit";
32
33 $results = $wpdb->get_results($sql);
34
35 $output = '<div id="crp_related">';
36 if(!$is_widget) $output .= $tptn_settings['title_daily'];
37 $output .= '<ul>';
38 if ($results) {
39 foreach ($results as $result) {
40 $output .= '<li><a href="'.get_permalink($result->postnumber).'">'.get_the_title($result->postnumber).'</a>';
41 if ($tptn_settings['disp_list_count']) $output .= ' ('.$result->sumCount.')';
42 $output .= '</li>';
43 }
44 }
45 if ($tptn_settings['show_credit']) $output .= '<li>Popular posts by <a href="http://ajaydsouza.com/wordpress/plugins/top-10/">Top 10 plugin</a></li>';
46 $output .= '</ul>';
47 $output .= '</div>';
48
49 echo "document.write('".$output."')";
50 }
51 tptn_daily_lists();
52 ?>
53