Admin.php
1 year ago
admin-page.php
1 year ago
screen-debug.php
1 year ago
screen-stats.php
1 year ago
screen-tools.php
1 year ago
screen-stats.php
134 lines
| 1 | <?php |
| 2 | if ( 'stats' == $current ) { |
| 3 | $chart_data = json_decode( |
| 4 | $this->get_chart_data( |
| 5 | $this->config['stats']['range'], |
| 6 | strtoupper($this->config['stats']['time_unit']), |
| 7 | $this->config['stats']['time_quantity'] |
| 8 | ), |
| 9 | true |
| 10 | ); |
| 11 | ?> |
| 12 | |
| 13 | <?php if ( current_user_can('edit_others_posts') ) : ?> |
| 14 | <a href="#" id="wpp-stats-config-btn" class="dashicons dashicons-admin-generic"></a> |
| 15 | |
| 16 | <div id="wpp-stats-config" class="wpp-lightbox"> |
| 17 | <form action="" method="post" id="wpp_stats_options" name="wpp_stats_options"> |
| 18 | <label for="stats_type"><?php esc_html_e('Post type', 'wordpress-popular-posts'); ?>:</label> |
| 19 | <input type="text" name="stats_type" value="<?php echo esc_attr($this->config['stats']['post_type']); ?>" size="15"> |
| 20 | |
| 21 | <label for="stats_limits"><?php esc_html_e('Limit', 'wordpress-popular-posts'); ?>:</label> |
| 22 | <input type="text" name="stats_limit" value="<?php echo esc_attr($this->config['stats']['limit']); ?>" size="5"> |
| 23 | |
| 24 | <label for="stats_freshness"> |
| 25 | <input type="checkbox" class="checkbox" <?php echo ($this->config['stats']['freshness']) ? 'checked="checked"' : ''; ?> id="stats_freshness" name="stats_freshness"> <small><?php esc_html_e('Display only posts published within the selected Time Range', 'wordpress-popular-posts'); ?></small> |
| 26 | </label> |
| 27 | |
| 28 | <div class="clear"></div> |
| 29 | <br /><br /> |
| 30 | |
| 31 | <input type="hidden" name="section" value="stats"> |
| 32 | <button type="submit" class="button-primary action"><?php esc_html_e('Apply', 'wordpress-popular-posts'); ?></button> |
| 33 | <button class="button-secondary action right"><?php esc_html_e('Cancel'); ?></button> |
| 34 | |
| 35 | <?php wp_nonce_field('wpp-update-stats-options', 'wpp-update-stats-options-token'); ?> |
| 36 | </form> |
| 37 | </div> |
| 38 | <?php endif; ?> |
| 39 | |
| 40 | <div id="wpp-stats-range" class="wpp-lightbox"> |
| 41 | <form action="" method="post"> |
| 42 | <ul class="wpp-lightbox-tabs"> |
| 43 | <li class="active"><a href="#"><?php esc_html_e('Custom Time Range', 'wordpress-popular-posts'); ?></a></li> |
| 44 | <li><a href="#"><?php esc_html_e('Date Range', 'wordpress-popular-posts'); ?></a></li> |
| 45 | </ul> |
| 46 | |
| 47 | <div class="wpp-lightbox-tab-content wpp-lightbox-tab-content-active" id="custom-time-range"> |
| 48 | <input type="text" id="stats_range_time_quantity" name="stats_range_time_quantity" value="<?php echo esc_attr($this->config['stats']['time_quantity']); ?>"> |
| 49 | |
| 50 | <select id="stats_range_time_unit" name="stats_range_time_unit"> |
| 51 | <option <?php if ($this->config['stats']['time_unit'] == 'minute') { ?>selected="selected"<?php } ?> value="minute"><?php esc_html_e('Minute(s)', 'wordpress-popular-posts'); ?></option> |
| 52 | <option <?php if ($this->config['stats']['time_unit'] == 'hour') { ?>selected="selected"<?php } ?> value="hour"><?php esc_html_e('Hour(s)', 'wordpress-popular-posts'); ?></option> |
| 53 | <option <?php if ($this->config['stats']['time_unit'] == 'day') { ?>selected="selected"<?php } ?> value="day"><?php esc_html_e('Day(s)', 'wordpress-popular-posts'); ?></option> |
| 54 | </select> |
| 55 | </div> |
| 56 | |
| 57 | <div class="wpp-lightbox-tab-content" id="custom-date-range"> |
| 58 | <input type="text" id="stats_range_date" name="stats_range_date" value="" placeholder="<?php esc_attr_e('Select a date...', 'wordpress-popular-posts'); ?>" readonly> |
| 59 | </div> |
| 60 | |
| 61 | <div class="clear"></div> |
| 62 | <br /> |
| 63 | |
| 64 | <button type="submit" class="button-primary action"> |
| 65 | <?php esc_html_e('Apply', 'wordpress-popular-posts'); ?> |
| 66 | </button> |
| 67 | <button class="button-secondary action right"> |
| 68 | <?php esc_html_e('Cancel'); ?> |
| 69 | </button> |
| 70 | </form> |
| 71 | </div> |
| 72 | |
| 73 | <div id="wpp-chart-wrapper"> |
| 74 | <h4><?php echo wp_kses_post($chart_data['totals']['label_summary']); ?></h4> |
| 75 | <h5><?php echo esc_html($chart_data['totals']['label_date_range']); ?></h5> |
| 76 | |
| 77 | <ul class="wpp-header-nav" id="wpp-time-ranges"> |
| 78 | <li <?php echo ('daily' == $this->config['stats']['range'] || 'today' == $this->config['stats']['range'] ) ? ' class="current"' : ''; ?>><a href="#" data-range="today" title="<?php esc_attr_e('Today', 'wordpress-popular-posts'); ?>"><?php esc_html_e('Today', 'wordpress-popular-posts'); ?></a></li> |
| 79 | <li <?php echo ('daily' == $this->config['stats']['range'] || 'last24hours' == $this->config['stats']['range'] ) ? ' class="current"' : ''; ?>><a href="#" data-range="last24hours" title="<?php esc_attr_e('Last 24 hours', 'wordpress-popular-posts'); ?>">24h</a></li> |
| 80 | <li <?php echo ('weekly' == $this->config['stats']['range'] || 'last7days' == $this->config['stats']['range'] ) ? ' class="current"' : ''; ?>><a href="#" data-range="last7days" title="<?php esc_attr_e('Last 7 days', 'wordpress-popular-posts'); ?>">7d</a></li> |
| 81 | <li <?php echo ('monthly' == $this->config['stats']['range'] || 'last30days' == $this->config['stats']['range'] ) ? ' class="current"' : ''; ?>><a href="#" data-range="last30days" title="<?php esc_attr_e('Last 30 days', 'wordpress-popular-posts'); ?>">30d</a></li> |
| 82 | <li <?php echo ('custom' == $this->config['stats']['range'] ) ? ' class="current"' : ''; ?>><a href="#" data-range="custom" title="<?php esc_attr_e('Custom', 'wordpress-popular-posts'); ?>"><?php esc_html_e('Custom', 'wordpress-popular-posts'); ?></a></li> |
| 83 | </ul> |
| 84 | |
| 85 | <div id="wpp-chart"> |
| 86 | <p><?php echo sprintf( __('Err... A nice little chart is supposed to be here, instead you are seeing this because your browser is too old. <br /> Please <a href="%s" target="_blank">get a better browser</a>.', 'wordpress-popular-posts'), 'https://browsehappy.com/'); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p> |
| 87 | </div> |
| 88 | </div> |
| 89 | |
| 90 | <div id="wpp-listing" class="wpp-content"> |
| 91 | <ul class="wpp-tabbed-nav"> |
| 92 | <li class="active"><a href="#" title="<?php esc_attr_e('See your most viewed posts within the selected time range', 'wordpress-popular-posts'); ?>"><span class="wpp-icon-eye"></span><span><?php esc_html_e('Most viewed', 'wordpress-popular-posts'); ?></span></a></li> |
| 93 | <li><a href="#" title="<?php esc_attr_e('See your most commented posts within the selected time range', 'wordpress-popular-posts'); ?>"><span class="wpp-icon-comment"></span><span><?php esc_html_e('Most commented', 'wordpress-popular-posts'); ?></span></a></li> |
| 94 | <li><a href="#" title="<?php esc_attr_e('See your most viewed posts within the last hour', 'wordpress-popular-posts'); ?>"><span class="wpp-icon-rocket"></span><span><?php esc_html_e('Trending now', 'wordpress-popular-posts'); ?></span></a></li> |
| 95 | <li><a href="#" title="<?php esc_attr_e('See your most viewed posts of all time', 'wordpress-popular-posts'); ?>"><span class="wpp-icon-award"></span><span><?php esc_html_e('Hall of Fame', 'wordpress-popular-posts'); ?></span></a></li> |
| 96 | </ul> |
| 97 | |
| 98 | <div class="wpp-tab-content wpp-tab-content-active"> |
| 99 | <span class="spinner"></span> |
| 100 | </div> |
| 101 | |
| 102 | <div class="wpp-tab-content"> |
| 103 | <span class="spinner"></span> |
| 104 | </div> |
| 105 | |
| 106 | <div class="wpp-tab-content"> |
| 107 | <span class="spinner"></span> |
| 108 | </div> |
| 109 | |
| 110 | <div class="wpp-tab-content"> |
| 111 | <?php |
| 112 | $args = [ |
| 113 | 'range' => 'all', |
| 114 | 'post_type' => $this->config['stats']['post_type'], |
| 115 | 'order_by' => 'views', |
| 116 | 'limit' => $this->config['stats']['limit'], |
| 117 | 'stats_tag' => [ |
| 118 | 'comment_count' => 1, |
| 119 | 'views' => 1, |
| 120 | 'date' => [ |
| 121 | 'active' => 1 |
| 122 | ] |
| 123 | ] |
| 124 | ]; |
| 125 | $query = new \WordPressPopularPosts\Query($args); |
| 126 | $popular_posts = $query->get_posts(); |
| 127 | |
| 128 | $this->render_list($popular_posts, 'hof'); |
| 129 | ?> |
| 130 | </div> |
| 131 | </div> |
| 132 | <?php |
| 133 | } |
| 134 |