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
144 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 | <button type="button" id="wpp-stats-config-btn" class="button-secondary action right"><span class="dashicons dashicons-admin-generic"></span><span class="screen-reader-text"><?php esc_html_e('Open Settings', 'wordpress-popular-posts'); ?></span></button> |
| 15 | |
| 16 | <div id="wpp-stats-config" class="wpp-lightbox" role="dialog" aria-label="<?php esc_attr_e('Stats Settings', 'wordpress-popular-posts'); ?>"> |
| 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" id="stats_type" name="stats_type" value="<?php echo esc_attr($this->config['stats']['post_type']); ?>" size="15" required> |
| 20 | |
| 21 | <label for="stats_limits"><?php esc_html_e('Limit', 'wordpress-popular-posts'); ?>:</label> |
| 22 | <input type="text" id="stats_type" name="stats_limit" value="<?php echo esc_attr($this->config['stats']['limit']); ?>" size="5" required> |
| 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 type="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 wpp-tabs" role="dialog" aria-label="<?php esc_attr_e('Custom Time Range Settings', 'wordpress-popular-posts'); ?>"> |
| 41 | <form action="" method="post"> |
| 42 | <div class="wpp-lightbox-tabs wpp-tabs-container" role="tablist"> |
| 43 | <button type="button" role="tab" aria-selected="true" aria-controls="custom-time-range" id="tab-1" tabindex="0"><?php esc_html_e('Custom Time Range', 'wordpress-popular-posts'); ?></button> |
| 44 | <button type="button" role="tab" aria-selected="false" aria-controls="custom-date-range" id="tab-2" tabindex="-1"><?php esc_html_e('Date Range', 'wordpress-popular-posts'); ?></button> |
| 45 | </div> |
| 46 | |
| 47 | <div class="wpp-lightbox-tab-content active wpp-tabs-panel" id="custom-time-range" role="tabpanel" tabindex="0" aria-labelledby="tab-1"> |
| 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 wpp-tabs-panel" id="custom-date-range" role="tabpanel" tabindex="0" aria-labelledby="tab-2"> |
| 58 | <input type="text" id="stats_range_date" name="stats_range_date" value="" placeholder="<?php esc_attr_e('Select a date...', 'wordpress-popular-posts'); ?>" /> |
| 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 type="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 ('today' == $this->config['stats']['range']) ? ' class="current"' : ''; ?>> |
| 79 | <button type="button" class="<?php echo ('today' == $this->config['stats']['range']) ? 'button-primary' : 'button-secondary'; ?>" data-range="today"><?php esc_html_e('Today', 'wordpress-popular-posts'); ?></button> |
| 80 | </li> |
| 81 | <li <?php echo ('last24hours' == $this->config['stats']['range']) ? ' class="current"' : ''; ?>> |
| 82 | <button type="button" class="<?php echo ('last24hours' == $this->config['stats']['range'] ) ? 'button-primary' : 'button-secondary'; ?>" data-range="last24hours" title="<?php esc_attr_e('Last 24 hours', 'wordpress-popular-posts'); ?>">24h</button> |
| 83 | </li> |
| 84 | <li <?php echo ('last7days' == $this->config['stats']['range']) ? ' class="current"' : ''; ?>> |
| 85 | <button type="button" class="<?php echo ('last7days' == $this->config['stats']['range'] ) ? 'button-primary' : 'button-secondary'; ?>" data-range="last7days" title="<?php esc_attr_e('Last 7 days', 'wordpress-popular-posts'); ?>">7d</button> |
| 86 | </li> |
| 87 | <li <?php echo ('last30days' == $this->config['stats']['range']) ? ' class="current"' : ''; ?>> |
| 88 | <button type="button" class="<?php echo ('last30days' == $this->config['stats']['range']) ? 'button-primary' : 'button-secondary'; ?>" data-range="last30days" title="<?php esc_attr_e('Last 30 days', 'wordpress-popular-posts'); ?>">30d</button> |
| 89 | </li> |
| 90 | <li <?php echo ('custom' == $this->config['stats']['range']) ? ' class="current"' : ''; ?>> |
| 91 | <button type="button" class="<?php echo ('custom' == $this->config['stats']['range']) ? 'button-primary' : 'button-secondary'; ?>" data-range="custom"><?php esc_html_e('Custom', 'wordpress-popular-posts'); ?></button> |
| 92 | </li> |
| 93 | </ul> |
| 94 | |
| 95 | <div id="wpp-chart"> |
| 96 | <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> |
| 97 | </div> |
| 98 | </div> |
| 99 | |
| 100 | <div id="wpp-listing" class="wpp-content wpp-tabs"> |
| 101 | <div class="wpp-tabs-container" role="tablist"> |
| 102 | <button type="button" role="tab" aria-selected="true" aria-controls="most-viewed-list" id="tab-list-1" tabindex="0" 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></button> |
| 103 | <button type="button" role="tab" aria-selected="false" aria-controls="most-commented-list" id="tab-list-2" tabindex="-1" 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></button> |
| 104 | <button type="button" role="tab" aria-selected="false" aria-controls="trending-list" id="tab-list-3" tabindex="-1" 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></button> |
| 105 | <button type="button" role="tab" aria-selected="false" aria-controls="hof-list" id="tab-list-4" tabindex="-1" 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></button> |
| 106 | </div> |
| 107 | |
| 108 | <div class="wpp-tabs-panel active" id="most-viewed-list" role="tabpanel" tabindex="0" aria-labelledby="tab-list-1"> |
| 109 | <span class="spinner"></span> |
| 110 | </div> |
| 111 | |
| 112 | <div class="wpp-tabs-panel" id="most-commented-list" role="tabpanel" tabindex="0" aria-labelledby="tab-list-2"> |
| 113 | <span class="spinner"></span> |
| 114 | </div> |
| 115 | |
| 116 | <div class="wpp-tabs-panel" id="trending-list" role="tabpanel" tabindex="0" aria-labelledby="tab-list-3"> |
| 117 | <span class="spinner"></span> |
| 118 | </div> |
| 119 | |
| 120 | <div class="wpp-tabs-panel" id="hof-list" role="tabpanel" tabindex="0" aria-labelledby="tab-list-4"> |
| 121 | <?php |
| 122 | $args = [ |
| 123 | 'range' => 'all', |
| 124 | 'post_type' => $this->config['stats']['post_type'], |
| 125 | 'order_by' => 'views', |
| 126 | 'limit' => $this->config['stats']['limit'], |
| 127 | 'stats_tag' => [ |
| 128 | 'comment_count' => 1, |
| 129 | 'views' => 1, |
| 130 | 'date' => [ |
| 131 | 'active' => 1 |
| 132 | ] |
| 133 | ] |
| 134 | ]; |
| 135 | $query = new \WordPressPopularPosts\Query($args); |
| 136 | $popular_posts = $query->get_posts(); |
| 137 | |
| 138 | $this->render_list($popular_posts, 'hof'); |
| 139 | ?> |
| 140 | </div> |
| 141 | </div> |
| 142 | <?php |
| 143 | } |
| 144 |