Changeset 2105829
- Timestamp:
- 06/13/2019 07:33:14 PM (7 years ago)
- Location:
- heimdall/trunk
- Files:
-
- 19 added
- 3 edited
-
LICENSE (added)
-
addons (added)
-
addons/access (added)
-
addons/access/access.php (added)
-
addons/index.php (added)
-
addons/most-used-keywords (added)
-
addons/most-used-keywords/assets (added)
-
addons/most-used-keywords/assets/css (added)
-
addons/most-used-keywords/assets/css/muk-styles.css (added)
-
addons/most-used-keywords/assets/js (added)
-
addons/most-used-keywords/assets/js/muk-scripts.js (added)
-
addons/most-used-keywords/index.php (added)
-
addons/most-used-keywords/most-used-keywords.php (added)
-
addons/weekly-report (added)
-
addons/weekly-report/assets (added)
-
addons/weekly-report/assets/js (added)
-
addons/weekly-report/assets/js/statistics-admin.js (added)
-
addons/weekly-report/index.php (added)
-
addons/weekly-report/weekly-report.php (added)
-
heimdall.php (modified) (14 diffs)
-
includes/query-builder.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
heimdall/trunk/heimdall.php
r2072236 r2105829 1 1 <?php 2 3 2 /** 4 3 * Apache License, Version 2.0 … … 23 22 Plugin URI: https://wordpress.org/plugins/heimdall 24 23 Description: A simple way to tracking clients activities. 25 Version: 1. 2.024 Version: 1.3.0 26 25 Author: Arman Afzal 27 26 Author URI: https://github.com/Rmanaf … … 35 34 require_once __DIR__ . "/includes/commons.php"; 36 35 require_once __DIR__ . "/includes/query-builder.php"; 37 require_once __DIR__ . "/includes/access.php";38 36 39 37 if (!class_exists('WP_Heimdall_Plugin')) { … … 42 40 { 43 41 44 p rivatestatic $text_domain = 'heimdall';45 46 private static $db_version = '1.0. 0';42 public static $text_domain = 'heimdall'; 43 44 private static $db_version = '1.0.1'; 47 45 48 46 private static $content_type = [ … … 61 59 62 60 private static $hit_hooks = [ 'wp_footer' ]; 63 64 65 61 66 62 function __construct() 67 63 { 68 64 69 70 65 $this->check_db(); 71 72 73 //new WP_Access_Plugin();74 75 66 76 67 add_shortcode('statistics', [$this, 'statistics_shortcode']); … … 254 245 255 246 /** 256 * add statistics shortcode to the content247 * adds the statistics shortcode to the content 257 248 * @since 1.0.0 258 249 */ … … 288 279 289 280 /** 290 * add statistics dashboard widget281 * adds the statistics widget to the dashboard 291 282 * @since 1.0.0 292 283 */ … … 303 294 304 295 296 305 297 /** 306 298 * report widget … … 310 302 { 311 303 312 ?> 313 314 <style> 315 .tags { 316 list-style: none; 317 margin: 0; 318 padding: 0; 319 overflow: hidden; 320 } 321 322 .tags li { 323 float: left; 324 } 325 326 .tag { 327 background: #eee; 328 border-radius: 3px 0 0 3px; 329 color: #999; 330 display: inline-block; 331 height: 26px; 332 line-height: 26px; 333 padding: 0 20px 0 23px; 334 position: relative; 335 margin: 0 10px 10px 0; 336 text-decoration: none; 337 -webkit-transition: color 0.2s; 338 } 339 340 .tag::before { 341 background: #fff; 342 border-radius: 10px; 343 box-shadow: inset 0 1px rgba(0, 0, 0, 0.25); 344 content: ''; 345 height: 6px; 346 left: 10px; 347 position: absolute; 348 width: 6px; 349 top: 10px; 350 } 351 352 .tag::after { 353 background: #fff; 354 border-bottom: 13px solid transparent; 355 border-left: 10px solid #eee; 356 border-top: 13px solid transparent; 357 content: ''; 358 position: absolute; 359 right: 0; 360 top: 0; 361 } 362 363 .tag:hover { 364 background-color: #2196f3; 365 color: white; 366 } 367 368 .tag:hover::after { 369 border-left-color: #2196f3; 370 } 371 372 .tag i { 373 padding: 2px; 374 padding-left: 5px; 375 padding-right: 5px; 376 background: #607d8b; 377 color: white; 378 margin-left: 8px; 379 margin-right: 4px; 380 font-size: 10px; 381 border-radius: 4px; 382 text-align: center; 383 text-decoration: none; 384 font-weight: bold; 385 font-style: normal; 386 } 387 388 </style> 389 390 <h2><?php _e("Most used keywords" , self::$text_domain); ?></h2> 391 <ul id="most-used-keywords" class="tags"></ul> 392 <hr /> 393 394 <h2><?php _e("Weekly report" , self::$text_domain); ?></h2> 395 <div class="chart-container" style="position: relative; width:100%; height:300px;"> 396 <canvas id="statisticsChart"></canvas> 397 </div> 398 399 <?php 304 do_action("dcp-heimdall--dashboad-statistic-widget"); 400 305 401 306 } … … 598 503 599 504 $sql = "CREATE TABLE $table_name ( 600 id mediumint(9) NOT NULL AUTO_INCREMENT,601 blog smallintNOT NULL,505 id bigint(20) NOT NULL AUTO_INCREMENT, 506 blog bigint(20) NOT NULL, 602 507 time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, 603 508 ip tinytext, 604 page smallint,509 page bigint(20), 605 510 type smallint, 606 511 user smallint, … … 636 541 { 637 542 638 $query_builder = new WP_Heimdall_Query_Builder(self::table_name()); 639 640 // get GMT 641 $cdate = current_time( 'mysql' , 1 ); 642 643 // start from 6 days ago 644 $start = new DateTime($cdate); 645 $start->sub(new DateInterval('P6D')); 646 647 // today 648 $end = new DateTime($cdate); 649 543 wp_register_script('heimdall-admin-script', '', [], false); 544 545 wp_enqueue_script( 'dcp-chart-js', plugins_url( '/assets/chart.min.js', __FILE__ ), [], $ver, false); 546 547 new WP_Heimdall_Query_Builder(self::table_name()); 650 548 549 651 550 wp_enqueue_script( 'dcp-chart-js-bundle', plugins_url( '/assets/chart.bundle.min.js', __FILE__ ), [], $ver, false); 652 551 wp_enqueue_script( 'dcp-chart-js', plugins_url( '/assets/chart.min.js', __FILE__ ), [], $ver, false); 653 wp_enqueue_script( 'statistics-admin', plugins_url( '/assets/statistics-admin.js', __FILE__ ), ['jquery'], $ver, true); 654 655 wp_localize_script( 'statistics-admin', 'statistics_data', [ 656 'is_multisite' => is_multisite(), 657 'visitors' => $wpdb->get_results($query_builder->get_chart_query($start , $end), ARRAY_A ), 658 'keywords' => $wpdb->get_results($query_builder->get_most_used_keywords_query($start , $end), ARRAY_A) 659 ]); 552 wp_enqueue_script( 'heimdall-admin-script' ); 553 wp_localize_script( 'heimdall-admin-script', 'statistics_data', apply_filters("dcp-heimdall--localized-data" , [ 554 'is_multisite' => is_multisite() 555 ])); 660 556 661 557 echo $wpdb->last_error; … … 699 595 * type 4 is search 700 596 */ 701 if(is_home()){ 597 if(is_home() || is_front_page()) 598 { 702 599 703 600 $type = 1; 704 601 705 } else if (is_page() ) {602 } else if (is_page() && !is_front_page()) { 706 603 707 604 $page = $post->ID; … … 778 675 779 676 677 public static function addon_url($addon , $path) 678 { 679 return plugins_url("/addons/$addon/$path" , __FILE__); 680 } 681 780 682 /** 781 683 * returns plugin version … … 794 696 795 697 $HEIMDALL_PLUGIN_INSTANCE = new WP_Heimdall_Plugin(); 698 699 require_once __DIR__ . "/addons/access/access.php"; 700 require_once __DIR__ . "/addons/most-used-keywords/most-used-keywords.php"; 701 require_once __DIR__ . "/addons/weekly-report/weekly-report.php"; -
heimdall/trunk/includes/query-builder.php
r2070772 r2105829 119 119 } 120 120 121 public function get_most_used_keywords_query($start , $end)122 {123 // convert dates to mysql format124 $start = $start->format('Y-m-d H:i:s');125 $end = $end->format('Y-m-d H:i:s');126 121 127 $blog_id = get_current_blog_id(); 128 129 return "SELECT COUNT(*) count, meta 130 FROM $this->table_name 131 WHERE type='4' AND blog='$blog_id' AND (time BETWEEN '$start' AND '$end') 132 GROUP BY meta 133 ORDER BY count DESC 134 LIMIT 30" ; 135 136 } 137 138 public function get_chart_query($start , $end){ 139 140 // convert dates to mysql format 141 $start = $start->format('Y-m-d H:i:s'); 142 $end = $end->format('Y-m-d H:i:s'); 143 144 $blog_id = get_current_blog_id(); 145 $extra_field = is_multisite() ? ", SUM(case when blog='$blog_id' then 1 else 0 end) w" : ""; 146 147 return "SELECT WEEKDAY(time) x, 148 COUNT(DISTINCT ip) y, 149 COUNT(*) z, 150 SUM(case when type='1' then 1 else 0 end) p 151 $extra_field 152 FROM $this->table_name 153 WHERE (time BETWEEN '$start' AND '$end') 154 GROUP BY x"; 155 156 } 122 157 123 158 124 public function get_query() -
heimdall/trunk/readme.txt
r2072236 r2105829 3 3 Tags: statistics, stat, heimdall 4 4 Requires at least: 4.5.0 5 Tested up to: 5. 1.15 Tested up to: 5.2.1 6 6 Requires PHP: 5.2.4 7 Stable tag: 1. 2.07 Stable tag: 1.3.0 8 8 License: Apache License, Version 2.0 9 9 License URI: https://github.com/Rmanaf/wp-heimdall/blob/master/LICENSE
Note: See TracChangeset
for help on using the changeset viewer.