PluginProbe
Statify / trunk
Statify vtrunk
2.0.2 2.0.1 trunk 0.7 0.8 0.9 1.0 1.2.8 1.3.0 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 All 32 releases
statify / views / view-content.php

view-content.php in Statify trunk, at views/view-content.php

181 lines 7.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The dashboard page.
4 *
5 * @package Statify
6 * @since 2.0.0
7 */
8
9 // Exit if accessed directly.
10 defined( 'ABSPATH' ) || exit;
11
12 // phpcs:disable Universal.WhiteSpace.PrecisionAlignment.Found
13 // phpcs:disable WordPress.Security.NonceVerification.Recommended -- we use $_GET parameters in various places
14
15 $post_types = Statify_Evaluation::get_post_types();
16 if ( isset( $_GET['type'] ) && in_array( wp_unslash( $_GET['type'] ), $post_types, true ) ) {
17 $selected_type = sanitize_text_field( wp_unslash( $_GET['type'] ) );
18 } else {
19 $selected_type = 'popular'; // popular = show most popular content.
20 }
21
22 if ( isset( $_GET['range'] ) ) {
23 $date_range = sanitize_text_field( wp_unslash( $_GET['range'] ) );
24 } else {
25 $date_range = '';
26 }
27 if ( isset( $_GET['start'] ) ) {
28 $date_start = sanitize_text_field( wp_unslash( $_GET['start'] ) );
29 } else {
30 $date_start = '';
31 }
32 if ( isset( $_GET['end'] ) ) {
33 $date_end = sanitize_text_field( wp_unslash( $_GET['end'] ) );
34 } else {
35 $date_end = '';
36 }
37
38 if ( 'popular' === $selected_type ) {
39 $section_title = __( 'Most Popular Content', 'statify' );
40 } else {
41 $section_title = get_post_type_object( $selected_type )->labels->name;
42 }
43 if ( ! empty( $date_start ) && ! empty( $date_end ) && $date_start !== $date_end ) {
44 $section_title = sprintf(
45 /* translators: 1: content type (plural), 2: start date, 3: end date */
46 __( '%1$s from %2$s to %3$s', 'statify' ),
47 $section_title,
48 Statify::parse_date( $date_start ),
49 Statify::parse_date( $date_end )
50 );
51 } elseif ( ! empty( $date_start ) && $date_start === $date_end ) {
52 $section_title = sprintf(
53 /* translators: Parameters: 1: content type (plural), 2: date */
54 __( '%1$s from %2$s', 'statify' ),
55 $section_title,
56 Statify::parse_date( $date_start )
57 );
58 }
59 ?>
60 <div class="wrap">
61 <h1><?php esc_html_e( 'Statify', 'statify' ); ?> - <?php esc_html_e( 'Content', 'statify' ); ?></h1>
62
63 <?php
64 Statify_Evaluation::show_navigation( 'content' );
65
66 $subnav_items = array(
67 array(
68 'url' => admin_url( 'index.php?page=statify_dashboard&view=content' ),
69 'label' => __( 'Most Popular Content', 'statify' ),
70 'current' => ( 'popular' === $selected_type ),
71 ),
72 );
73 foreach ( $post_types as $pt ) {
74 $subnav_items[] = array(
75 'url' => admin_url( 'index.php?page=statify_dashboard&view=content&type=' . $pt ),
76 'label' => get_post_type_object( $pt )->labels->name,
77 'current' => ( $selected_type === $pt ),
78 );
79 }
80 Statify_Evaluation::show_subnavigation( $subnav_items, __( 'Popular Content and Post Types', 'statify' ) );
81 ?>
82
83 <form id="statify-dashboard-controls">
84 <input type="hidden" name="page" value="statify_dashboard">
85 <input type="hidden" name="view" value="content">
86 <?php
87 if ( 'popular' !== $selected_type ) {
88 echo '<input type="hidden" name="type" value="' . esc_attr( $selected_type ) . '">';
89 }
90 ?>
91 <label for="statify-content-daterange"><?php esc_html_e( 'Date range', 'statify' ); ?></label>
92 <select id="statify-content-daterange" name="range">
93 <option value=""><?php esc_html_e( 'default (all the time)', 'statify' ); ?></option>
94 <option value="lastYear" <?php selected( $date_range, 'lastYear' ); ?>><?php esc_html_e( 'last year', 'statify' ); ?></option>
95 <option value="lastWeek" <?php selected( $date_range, 'lastWeek' ); ?>><?php esc_html_e( 'last week', 'statify' ); ?></option>
96 <option value="yesterday" <?php selected( $date_range, 'yesterday' ); ?>><?php esc_html_e( 'yesterday', 'statify' ); ?></option>
97 <option value="today" <?php selected( $date_range, 'today' ); ?>><?php esc_html_e( 'today', 'statify' ); ?></option>
98 <option value="thisWeek" <?php selected( $date_range, 'thisWeek' ); ?>><?php esc_html_e( 'this week', 'statify' ); ?></option>
99 <option value="last28days" <?php selected( $date_range, 'last28days' ); ?>><?php esc_html_e( 'last 28 days', 'statify' ); ?></option>
100 <option value="lastMonth" <?php selected( $date_range, 'lastMonth' ); ?>><?php esc_html_e( 'last month', 'statify' ); ?></option>
101 <option value="thisMonth" <?php selected( $date_range, 'thisMonth' ); ?>><?php esc_html_e( 'this month', 'statify' ); ?></option>
102 <option value="thisYear" <?php selected( $date_range, 'thisYear' ); ?>><?php esc_html_e( 'this year', 'statify' ); ?></option>
103 <option value="1stQuarter" <?php selected( $date_range, '1stQuarter' ); ?>><?php esc_html_e( '1st quarter', 'statify' ); ?></option>
104 <option value="2ndQuarter" <?php selected( $date_range, '2ndQuarter' ); ?>><?php esc_html_e( '2nd quarter', 'statify' ); ?></option>
105 <option value="3rdQuarter" <?php selected( $date_range, '3rdQuarter' ); ?>><?php esc_html_e( '3rd quarter', 'statify' ); ?></option>
106 <option value="4thQuarter" <?php selected( $date_range, '4thQuarter' ); ?>><?php esc_html_e( '4th quarter', 'statify' ); ?></option>
107 <option value="custom" <?php selected( $date_range, 'custom' ); ?>><?php esc_html_e( 'custom', 'statify' ); ?></option>
108 </select>
109 <label for="statify-content-datestart">Start date</label>
110 <input id="statify-content-datestart" name="start" type="date" value="<?php echo esc_attr( $date_start ); ?>">
111 <label for="statify-content-dateend">End date</label>
112 <input id="statify-content-dateend" name="end" type="date" value="<?php echo esc_attr( $date_end ); ?>">
113 <button type="submit" class="button-secondary"><?php esc_html_e( 'Select date period', 'statify' ); ?></button>
114 </form>
115
116 <?php if ( 'popular' === $selected_type ) : ?>
117
118 <section>
119 <h2><?php esc_html_e( 'Most Popular Content', 'statify' ); ?></h2>
120 <div class="statify-chart-container">
121 <div id="statify_chart_content" class="statify-chart">
122 <span class="spinner is-active" title="<?php esc_html_e( 'loading', 'statify' ); ?>"></span>
123 </div>
124 </div>
125 </section>
126 <?php endif; ?>
127
128 <section>
129 <h2><?php echo esc_html( $section_title ); ?></h2>
130
131 <table id="statify-table-posts" class="wp-list-table widefat striped statify-table">
132 <caption class="screen-reader-text">
133 <?php esc_html_e( 'Views per page/post', 'statify' ); ?>
134 </caption>
135 <thead>
136 <tr>
137 <th scope="col">
138 <?php
139 if ( 'popular' === $selected_type ) {
140 esc_html_e( 'Post/Page', 'statify' );
141 } else {
142 echo esc_html( get_post_type_object( $selected_type )->labels->name );
143 }
144 ?>
145 </th>
146 <th scope="col"><?php esc_html_e( 'URL', 'statify' ); ?></th>
147 <?php if ( 'popular' === $selected_type ) : ?>
148 <th scope="col"><?php esc_html_e( 'Post Type', 'statify' ); ?></th>
149 <?php endif; ?>
150 <th scope="col"><?php esc_html_e( 'Views', 'statify' ); ?></th>
151 <th scope="col"><?php esc_html_e( 'Proportion', 'statify' ); ?></th>
152 </tr>
153 </thead>
154 <tbody>
155 <?php for ( $d = 1; $d <= 3; $d++ ) : ?>
156 <tr class="placeholder">
157 <td><span>&nbsp;</span></td>
158 <td><span>&nbsp;</span></td>
159 <?php if ( 'popular' === $selected_type ) : ?>
160 <td><span>&nbsp;</span></td>
161 <?php endif; ?>
162 <td><span>&nbsp;</span></td>
163 <td><span>&nbsp;</span></td>
164 </tr>
165 <?php endfor; ?>
166 </tbody>
167 <tfoot>
168 <tr>
169 <th scope="row"><?php esc_html_e( 'Sum', 'statify' ); ?></th>
170 <td></td>
171 <?php if ( 'popular' === $selected_type ) : ?>
172 <td></td>
173 <?php endif; ?>
174 <td class="right"></td>
175 <td class="right"></td>
176 </tr>
177 </tfoot>
178 </table>
179 </section>
180 </div>
181