PluginProbe
Gianism / trunk
Gianism vtrunk
4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.4.0 5.0.0 5.0.1 5.0.2 5.1.0 5.2.1 5.2.2 5.3.0 6.0.0 6.0.1 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 All 65 releases
gianism / templates / analytics.php

analytics.php in Gianism trunk, at templates/analytics.php

301 lines 9.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined( 'ABSPATH' ) or die();
4
5 /** @var \Gianism\UI\SettingScreen $this */
6 /** @var \Gianism\Service\Google $google */
7 $google = $this->service->get( 'google' );
8
9 if ( ! $google->enabled ) :
10 ?>
11 <div class="error">
12 <p><?php printf( $this->_( 'Google connect is not available. Go to <a href="%s">setting page</a> and turn it on.' ), admin_url( 'options-general.php?page=gianism' ) ); ?></p>
13 </div>
14 <?php
15 return;
16 endif;
17
18 $analytics = \Gianism\Plugins\Analytics::get_instance();
19
20 ?>
21
22 <h3><i class="lsf lsf-key"></i> <?php $this->e( 'Analytics Token' ); ?></h3>
23
24 <?php if ( $analytics->ga_token ) : ?>
25 <p class="success">
26 <i class="lsf lsf-ok"></i> <?php $this->e( 'O.K. You have token.' ); ?>
27 </p>
28 <code><?php print_r( $analytics->ga_token ); ?></code>
29 <?php
30 $label = $this->_( 'Restore' );
31 ?>
32 <?php else : ?>
33 <p class="description">
34 <i class="lsf lsf-ban"></i> <?php $this->e( 'You don\'t have token. Token is required to contact with Google Analytics API.' ); ?>
35 </p>
36 <?php
37 $label = $this->_( 'Get' );
38 ?>
39 <?php endif; ?>
40 <p class="submit">
41 <a class="button-primary" href="<?php echo $analytics->token_url( $this->setting_url( 'analytics' ) ); ?>">
42 <?php echo $label; ?>
43 </a>
44 <?php if ( $analytics->ga_token ) : ?>
45 <a class="button" href="<?php echo $analytics->token_url( $this->setting_url( 'analytics' ), true ); ?>">
46 <?php $this->e( 'Delete' ); ?>
47 </a>
48 <?php endif; ?>
49 </p>
50
51
52
53 <?php if ( $analytics->ga_token ) : ?>
54 <h3><i class="lsf lsf-dashboard"></i> <?php $this->e( 'Account, Profile, View' ); ?></h3>
55 <form id="ga-connection"
56 action="<?php echo $analytics->token_save_url(); ?>" method="post"
57 data-endpoint="<?php echo admin_url( 'admin-ajax.php?action=wpg_ga_account' ); ?>">
58 <?php wp_nonce_field( 'wp_gianism_google_save-analytics' ); ?>
59 <input type="hidden" name="redirect_to" value="<?php echo esc_url( $this->setting_url( 'analytics' ) ); ?>" />
60 <table class="form-table">
61 <tbody>
62 <tr>
63 <th><label for="ga-account"><?php $this->e( 'Account' ); ?></label></th>
64 <td>
65 <select class="ga-profile-select" name="ga-account" id="ga-account"
66 data-ga-account-id="<?php echo $analytics->ga_profile['account']; ?>"
67 data-child="ga-profile" data-clear-target="1">
68 <option
69 value="0"<?php selected( ! $analytics->ga_profile['account'] ); ?>><?php $this->e( 'Please select' ); ?></option>
70 <?php foreach ( $analytics->ga_accounts as $account ) : ?>
71 <option
72 value="<?php echo esc_attr( $account->id ); ?>"<?php selected( $account->id, $analytics->ga_profile['account'] ); ?>><?php echo esc_html( $account->name ); ?></option>
73 <?php endforeach; ?>
74 </select>
75 <i class="dashicons dashicons-yes"></i>
76 <i class="dashicons dashicons-update"></i>
77 <?php if ( ! $analytics->ga_accounts ) : ?>
78 <p class="description">
79 <?php $this->e( 'Mmh, can\'t get Analytics accounts. Your token might be wrong.' ); ?>
80 </p>
81 <?php endif; ?>
82 </td>
83 </tr>
84 <tr>
85 <th><label for="ga-profile"><?php $this->e( 'Profile' ); ?></label></th>
86 <td>
87 <select class="ga-profile-select" name="ga-profile" id="ga-profile"
88 data-ga-profile-id="<?php echo $analytics->ga_profile['profile']; ?>" data-child="ga-view"
89 data-clear-target="2">
90 <option
91 value="0"<?php selected( ! $analytics->ga_profile['profile'] ); ?>><?php $this->e( 'Please select' ); ?></option>
92 </select>
93 <i class="dashicons dashicons-yes"></i>
94 <i class="dashicons dashicons-update"></i>
95 </td>
96 </tr>
97 <tr>
98 <th><label for="ga-view"><?php $this->e( 'View' ); ?></label></th>
99 <td>
100 <select name="ga-view" id="ga-view" data-ga-view-id="<?php echo $analytics->ga_profile['view']; ?>">
101 <option
102 value="0"<?php selected( ! $analytics->ga_profile['view'] ); ?>><?php $this->e( 'Please select' ); ?></option>
103 </select>
104 <i class="dashicons dashicons-yes"></i>
105 <i class="dashicons dashicons-update"></i>
106 </td>
107 </tr>
108 </tbody>
109 </table>
110 <?php submit_button(); ?>
111 </form>
112 <?php endif; ?>
113
114 <h3>
115 <i class="lsf lsf-server"></i> <?php $this->e( 'Create Database' ); ?>
116 </h3>
117 <p>
118 <?php $this->e( 'Gianism can create a typical table for Google Analytics Ranking. If you need customized one, forget about it and create your own.' ); ?>
119 </p>
120
121 <table class="mysql-table">
122 <caption><?php $this->e( 'Ranking table structure' ); ?></caption>
123 <thead>
124 <tr>
125 <th><?php $this->e( 'Column' ); ?></th>
126 <th><?php $this->e( 'Type' ); ?></th>
127 <th><?php $this->e( 'Length' ); ?></th>
128 <th><?php $this->e( 'Misc' ); ?></th>
129 </tr>
130 </thead>
131 <tbody>
132 <tr>
133 <th scope="row">ID</th>
134 <td>BIGINT</td>
135 <td>20</td>
136 <td>PK, <code>auto_increment</code></td>
137 </tr>
138 <tr>
139 <th scope="row">category</th>
140 <td>VARCHAR</td>
141 <td>64</td>
142 <td>&nbsp;</td>
143 </tr>
144 <tr>
145 <th scope="row">object_id</th>
146 <td>BIGINT</td>
147 <td>20</td>
148 <td>&nbsp;</td>
149 </tr>
150 <tr>
151 <th scope="row">object_value</th>
152 <td>BIGINT</td>
153 <td>20</td>
154 <td>&nbsp;</td>
155 </tr>
156 <tr>
157 <th scope="row">calc_date</th>
158 <td>DATE</td>
159 <td>&nbsp;</td>
160 <td>&nbsp;</td>
161 </tr>
162 <tr>
163 <th scope="row">created</th>
164 <td>TIMESTAMP</td>
165 <td>&nbsp;</td>
166 <td>Default CURRENT_TIMESTAMP</td>
167 </tr>
168 </tbody>
169 </table>
170
171 <?php if ( $analytics->table_exists() ) : ?>
172 <p class="success">
173 <i class="dashicons dashicons-yes"></i> <?php $this->e( 'Table exits.' ); ?>
174 </p>
175 <?php else : ?>
176 <form id="ga-table-create"
177 action="<?php echo $analytics->table_create_url( $this->setting_url( 'analytics' ) ); ?>"
178 method="post">
179 <?php wp_nonce_field( 'wp_gianism_google_create-table' ); ?>
180
181 <?php submit_button( $this->_( 'Create Table' ) ); ?>
182 </form>
183 <?php endif; ?>
184
185 <h3>
186 <i class="lsf lsf-time"></i> <?php $this->e( 'Installed cron files' ); ?>
187 </h3>
188
189 <p class="description">
190 <?php $this->e( 'To install cron, please visit our information site <a href="https://gianism.info/">gianism.info</a>.' ); ?>
191 </p>
192
193 <?php if ( empty( $analytics->crons ) ) : ?>
194 <p><?php $this->e( 'Nothing is installed.' ); ?></p>
195 <?php else : ?>
196 <form class="gianism-admin-form" id="cron-checker" method="post"
197 action="<?php echo admin_url( 'admin-ajax.php' ); ?>">
198 <input type="hidden" name="action" value="<?php echo $analytics::AJAX_CRON; ?>"/>
199 <?php wp_nonce_field( $analytics::AJAX_CRON ); ?>
200 <table class="mysql-table">
201 <thead>
202 <tr>
203 <th><?php $this->e( 'Class Name' ); ?></th>
204 <th><?php $this->e( 'Category' ); ?></th>
205 <th><?php $this->e( 'Interval' ); ?></th>
206 <th><?php $this->e( 'Available' ); ?></th>
207 </tr>
208 </thead>
209 <tbody>
210 <?php
211 $counter = 0;
212 foreach ( $analytics->crons as $class_name ) :
213 ?>
214 <tr>
215 <th scope="row">
216 <label>
217 <input type="radio" name="cron" value="<?php echo $counter; ?>"/>
218 <?php echo $class_name; ?>
219 </label>
220 </th>
221 <td><?php echo $class_name::CATEGORY; ?></td>
222 <td><?php echo $class_name::INTERVAL; ?></td>
223 <td>
224 <?php if ( $class_name::SKIP_CRON ) : ?>
225 <span class="description"><i class="lsf lsf-ban"></i> No</span>
226 <?php else : ?>
227 <span class="success"><i class="lsf lsf-check"></i> Yes</span>
228 <?php endif; ?>
229 </td>
230 </tr>
231 <?php
232 ++$counter;
233 endforeach;
234 ?>
235 </tbody>
236 </table>
237 <?php submit_button( $this->_( 'Check Data' ) ); ?>
238 <pre></pre>
239 </form>
240 <?php endif; ?>
241
242 <p class="description">
243 <?php printf( $this->_( 'Do you want to know how to install files? Here is <a href="%s">blog post</a> about it.' ), 'http://takahashifumiki.com/web/programing/3184/' ); ?>
244 </p>
245
246 <h3>
247 <i class="lsf lsf-upload"></i> <?php $this->e( 'Installed Ajax files' ); ?>
248 </h3>
249
250 <p class="description">
251 <?php $this->e( 'To install Ajax actions, please visit our information site <a href="https://gianism.info/">gianism.info</a>.' ); ?>
252 </p>
253
254
255 <?php if ( empty( $analytics->ajaxes ) ) : ?>
256 <p><?php $this->e( 'Nothing is installed.' ); ?></p>
257 <?php else : ?>
258 <form class="gianism-admin-form" id="ajax-checker" method="get"
259 action="<?php echo admin_url( 'admin-ajax.php' ); ?>">
260 <input type="hidden" name="_wpnonce" value=""/>
261 <table class="mysql-table">
262 <thead>
263 <tr>
264 <th><?php $this->e( 'Class Name' ); ?></th>
265 <th><?php $this->e( 'Endpoint' ); ?></th>
266 </tr>
267 </thead>
268 <tbody>
269 <?php foreach ( $analytics->ajaxes as $ajax ) : ?>
270 <tr>
271 <td>
272 <label>
273 <input type="radio" name="action" value="<?php echo esc_attr( $ajax::ACTION ); ?>"
274 data-nonce="<?php echo esc_attr( $ajax::get_nonce() ); ?>" data-action=""/>
275 <?php echo esc_html( $ajax ); ?>
276 </label>
277 </td>
278 <td><?php printf( '<a href="%1$s">%1$s</a>', esc_url( $ajax::endpoint() ) ); ?></td>
279 </tr>
280 <?php endforeach; ?>
281 </tbody>
282 </table>
283 <table class="form-table">
284 <tr>
285 <th><label for="from"><?php $this->e( 'From' ); ?></label></th>
286 <td><input type="text" class="datepicker" id="from" name="from"
287 value="<?php echo date_i18n( 'Y-m-d', strtotime( '1 month ago', time() ) ); ?>"
288 placeholder="YYYY-MM-DD"/></td>
289 </tr>
290 <tr>
291 <th><label for="to"><?php $this->e( 'To' ); ?></label></th>
292 <td><input type="text" class="datepicker" id="to" name="to"
293 value="<?php echo date_i18n( 'Y-m-d' ); ?>" placeholder="YYYY-MM-DD"/></td>
294 </tr>
295 </table>
296 <p class="descritpion"></p>
297 <?php submit_button( $this->_( 'Check Data' ) ); ?>
298 <pre></pre>
299 </form>
300 <?php endif; ?>
301