Plugin Directory

Changeset 2105829


Ignore:
Timestamp:
06/13/2019 07:33:14 PM (7 years ago)
Author:
rmanaf
Message:

'1.3.0'

Location:
heimdall/trunk
Files:
19 added
3 edited

Legend:

Unmodified
Added
Removed
  • heimdall/trunk/heimdall.php

    r2072236 r2105829  
    11<?php
    2 
    32/**
    43 * Apache License, Version 2.0
     
    2322    Plugin URI: https://wordpress.org/plugins/heimdall
    2423    Description: A simple way to tracking clients activities.
    25     Version: 1.2.0
     24    Version: 1.3.0
    2625    Author: Arman Afzal
    2726    Author URI: https://github.com/Rmanaf
     
    3534require_once __DIR__ . "/includes/commons.php";
    3635require_once __DIR__ . "/includes/query-builder.php";
    37 require_once __DIR__ . "/includes/access.php";
    3836
    3937if (!class_exists('WP_Heimdall_Plugin')) {
     
    4240    {
    4341
    44         private static $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';
    4745
    4846        private static $content_type = [
     
    6159
    6260        private static $hit_hooks = [ 'wp_footer' ];
    63 
    64        
    6561   
    6662        function __construct()
    6763        {
    6864
    69 
    7065            $this->check_db();
    71 
    72            
    73             //new WP_Access_Plugin();
    74 
    7566
    7667            add_shortcode('statistics', [$this, 'statistics_shortcode']);
     
    254245
    255246        /**
    256          * add statistics shortcode to the content
     247         * adds the statistics shortcode to the content
    257248         * @since 1.0.0
    258249         */
     
    288279
    289280        /**
    290          * add statistics dashboard widget
     281         * adds the statistics widget to the dashboard
    291282         * @since 1.0.0
    292283         */
     
    303294       
    304295
     296
    305297        /**
    306298         * report widget
     
    310302        {
    311303
    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");
    400305
    401306        }
     
    598503
    599504            $sql = "CREATE TABLE $table_name (
    600                 id mediumint(9) NOT NULL AUTO_INCREMENT,
    601                 blog smallint NOT NULL,
     505                id bigint(20) NOT NULL AUTO_INCREMENT,
     506                blog bigint(20) NOT NULL,
    602507                time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
    603508                ip tinytext,
    604                 page smallint,
     509                page bigint(20),
    605510                type smallint,
    606511                user smallint,
     
    636541            {
    637542
    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());
    650548               
     549
    651550                wp_enqueue_script( 'dcp-chart-js-bundle', plugins_url( '/assets/chart.bundle.min.js', __FILE__ ), [], $ver, false);
    652551                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                ]));
    660556
    661557                echo $wpdb->last_error;
     
    699595             * type 4 is search
    700596             */
    701             if(is_home()){
     597            if(is_home() || is_front_page())
     598            {
    702599
    703600                $type = 1;
    704601
    705             } else if (is_page()) {
     602            } else if (is_page() && !is_front_page()) {
    706603
    707604                $page = $post->ID;
     
    778675
    779676
     677        public static function addon_url($addon , $path)
     678        {
     679            return plugins_url("/addons/$addon/$path" , __FILE__);
     680        }
     681
    780682        /**
    781683         * returns plugin version
     
    794696
    795697$HEIMDALL_PLUGIN_INSTANCE = new WP_Heimdall_Plugin();
     698
     699require_once __DIR__ . "/addons/access/access.php";
     700require_once __DIR__ . "/addons/most-used-keywords/most-used-keywords.php";
     701require_once __DIR__ . "/addons/weekly-report/weekly-report.php";
  • heimdall/trunk/includes/query-builder.php

    r2070772 r2105829  
    119119        }
    120120
    121         public function get_most_used_keywords_query($start , $end)
    122         {
    123             // convert dates to mysql format
    124             $start = $start->format('Y-m-d H:i:s');
    125             $end   = $end->format('Y-m-d H:i:s');
    126121
    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       
    157123
    158124        public function get_query()
  • heimdall/trunk/readme.txt

    r2072236 r2105829  
    33Tags: statistics, stat, heimdall
    44Requires at least: 4.5.0
    5 Tested up to: 5.1.1
     5Tested up to: 5.2.1
    66Requires PHP: 5.2.4
    7 Stable tag: 1.2.0
     7Stable tag: 1.3.0
    88License: Apache License, Version 2.0
    99License URI: https://github.com/Rmanaf/wp-heimdall/blob/master/LICENSE
Note: See TracChangeset for help on using the changeset viewer.