Changeset 1335328
- Timestamp:
- 01/25/2016 07:45:34 AM (10 years ago)
- Location:
- wp-counter/trunk
- Files:
-
- 2 added
- 3 edited
-
inc/dashboard-widget.php (modified) (1 diff)
-
inc/shortcode.php (modified) (1 diff)
-
js (added)
-
js/functions.js (added)
-
wp-counter.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-counter/trunk/inc/dashboard-widget.php
r1240347 r1335328 1 <?php 2 add_action( 'wp_dashboard_setup', 'l24bd_wpcounter_dashboard_widget' ); 3 function l24bd_wpcounter_dashboard_widget() { 4 wp_add_dashboard_widget( 5 'l24bd_wpcounter_dashboard_widget', 6 '<span class="dashicons dashicons-chart-area"></span> Visitor Status', 7 'l24bd_wpcounter_dashboard_widget_display' 8 ); 9 } 10 function l24bd_wpcounter_dashboard_widget_display() 11 { ?> 12 <?php $data=l24bd_wpcounter_get_visitor_data(); ?> 13 14 <table class="widefat striped"> 15 <tr> 16 <td><span class="dashicons dashicons-calendar-alt"></span> Today (<?php echo getToday(); ?>)</td> 17 <td><?php echo $data['today'] ?></td> 18 </tr> 19 <tr> 20 <td><span class="dashicons dashicons-calendar-alt"></span> Yesterday (<?php echo getYesterday(); ?>)</td> 21 <td><?php echo $data['yesterday'] ?></td> 22 </tr> 23 <tr> 24 <td><span class="dashicons dashicons-calendar-alt"></span> This Week (<?php echo getLast('week','first').' - '.getCurrent('week','last'); ?>)</td> 25 <td><?php echo $data['thisWeek']; ?></td> 26 </tr> 27 <tr> 28 <td><span class="dashicons dashicons-calendar-alt"></span> This Month (<?php echo getCurrent('month','first').' - '.getCurrent('month','last'); ?>)</td> 29 <td><?php echo $data['thisMonth'] ?></td> 30 </tr> 31 </table> 32 <?php 33 } 1 <?php 2 add_action('wp_dashboard_setup', 'l24bd_wpcounter_dashboard_widget'); 3 function l24bd_wpcounter_dashboard_widget() 4 { 5 wp_add_dashboard_widget( 6 'l24bd_wpcounter_dashboard_widget', 7 '<span class="dashicons dashicons-chart-area"></span> Visitor Status', 8 'l24bd_wpcounter_dashboard_widget_display' 9 ); 10 } 11 12 function l24bd_wpcounter_dashboard_widget_display() 13 { ?> 14 <?php $data = l24bd_wpcounter_get_visitor_data(); ?> 15 16 <table class="widefat striped"> 17 <tr> 18 <td><span class="dashicons dashicons-calendar-alt"></span> Today (<?php echo getToday(); ?>)</td> 19 <td><?php echo $data['today'] ?></td> 20 </tr> 21 <tr> 22 <td><span class="dashicons dashicons-calendar-alt"></span> Yesterday (<?php echo getYesterday(); ?>)</td> 23 <td><?php echo $data['yesterday'] ?></td> 24 </tr> 25 <tr> 26 <td><span class="dashicons dashicons-calendar-alt"></span> This Week 27 (<?php echo getLast('week', 'first') . ' - ' . getCurrent('week', 'last'); ?>) 28 </td> 29 <td><?php echo $data['thisWeek']; ?></td> 30 </tr> 31 <tr> 32 <td><span class="dashicons dashicons-calendar-alt"></span> This Month 33 (<?php echo getCurrent('month', 'first') . ' - ' . getCurrent('month', 'last'); ?>) 34 </td> 35 <td><?php echo $data['thisMonth'] ?></td> 36 </tr> 37 <tr> 38 <td><span class="dashicons dashicons-calendar-alt"></span> Total Visitor</td> 39 <td><?php echo $data['totalVisitor'] ?></td> 40 </tr> 41 </table> 42 <?php 43 } 44 45 // visitor graph 46 add_action('wp_dashboard_setup', 'l24bd_wpcounter_dashboard_visitor_graph_widget'); 47 function l24bd_wpcounter_dashboard_visitor_graph_widget() 48 { 49 wp_add_dashboard_widget( 50 'l24bd_wpcounter_dashboard_visitor_graph_widget', 51 '<span class="dashicons dashicons-chart-area"></span> Last 7 day(s) status', 52 'l24bd_wpcounter_dashboard_visitor_graph_widget_display' 53 ); 54 } 55 56 function l24bd_wpcounter_dashboard_visitor_graph_widget_display() 57 { ?> 58 <?php 59 global $wpdb; 60 $table_name = $wpdb->prefix . 'l24bd_wpcounter_visitors'; 61 $sql = "SELECT visit_date,SUM(hits) AS total FROM $table_name GROUP BY visit_date ORDER BY visit_date DESC LIMIT 7"; 62 $vistorData = $wpdb->get_results($sql); 63 ?> 64 <div style="width: 100%"> 65 <canvas id="canvas" height="107"></canvas> 66 </div> 67 68 <script type="text/javascript"> 69 var randomScalingFactor = function () { 70 return Math.round(Math.random() * 100) 71 }; 72 var barChartData = { 73 labels: [ 74 <?php 75 foreach($vistorData as $data) 76 { 77 echo "'".$data->visit_date."'".','; 78 } 79 ?> 80 ], 81 datasets: [ 82 { 83 fillColor: "rgba(221,56,45,0.5)", 84 strokeColor: "rgba(220,220,220,0.8)", 85 highlightFill: "rgba(220,220,220,0.75)", 86 highlightStroke: "rgba(220,220,220,1)", 87 data: [ 88 <?php 89 foreach($vistorData as $data) 90 { 91 echo $data->total.','; 92 } 93 ?> 94 ] 95 } 96 ] 97 } 98 window.onload = function () { 99 var ctx = document.getElementById("canvas").getContext("2d"); 100 window.myBar = new Chart(ctx).Bar(barChartData, { 101 responsive: true 102 }); 103 } 104 105 </script> 106 <?php 107 } -
wp-counter/trunk/inc/shortcode.php
r1240347 r1335328 26 26 <td><?php echo $data['thisMonth'] ?></td> 27 27 </tr> 28 <tr> 29 <td><span class="dashicons dashicons-calendar-alt"></span> Total</td> 30 <td><?php echo $data['totalVisitor'] ?></td> 31 </tr> 28 32 </table> 29 33 <?php -
wp-counter/trunk/wp-counter.php
r1240347 r1335328 4 4 * Plugin URI: http://learn24bd.com/portfolio/wp-counter 5 5 * Description: WP Counter is a simple visitor counter of your site. You can see your unique site visitor status in different date range (Today,Yesterday,Current Week,Current Month). 6 * Version: 1. 06 * Version: 1.1 7 7 * Author: Harun 8 8 * Author URI: http://learn24bd.com … … 12 12 // date helper part 13 13 include 'inc/date-helper.php'; 14 /// Register Script 15 function l24bd_wpcounter_load_scripts() { 16 wp_enqueue_script('jquery'); 17 wp_register_script( 'l24bd_wpcounter_chart_js','https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js'); 18 wp_register_script( 'l24bd_wpcounter_functions',plugins_url('js/functions.js', __FILE__ )); 19 20 wp_enqueue_script( 'l24bd_wpcounter_chart_js' ); 21 wp_enqueue_script( 'l24bd_wpcounter_functions' ); 22 23 } 24 // Hook into the 'wp_enqueue_scripts' action 25 add_action( 'admin_enqueue_scripts', 'l24bd_wpcounter_load_scripts' ); 26 14 27 //end date helper part 15 28 include 'inc/dashboard-widget.php'; … … 77 90 $thisWeek = $wpdb->get_var($sql); 78 91 79 $sql="SELECT SUM(hits) FROM $table_name WHERE visit_date between '".getCurrent('month','first')."' and '".getCurrent('month',' first')."'";92 $sql="SELECT SUM(hits) FROM $table_name WHERE visit_date between '".getCurrent('month','first')."' and '".getCurrent('month','last')."'"; 80 93 $thisMonth = $wpdb->get_var($sql); 94 95 $sql="SELECT SUM(hits) FROM $table_name"; 96 $totalVisitor = $wpdb->get_var($sql); 81 97 82 98 $data['today']=$today; … … 84 100 $data['thisWeek']=$thisWeek; 85 101 $data['thisMonth']=$thisMonth; 102 $data['totalVisitor']=$totalVisitor; 86 103 87 104 return $data;
Note: See TracChangeset
for help on using the changeset viewer.