PluginProbe
Gianism / 3.0.1
Gianism v3.0.1
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 3.0.1, at templates/analytics.php

294 lines 9.3 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"
42 href="<?php echo $analytics->token_url( $this->setting_url( 'analytics' ) ) ?>"><?php echo $label; ?></a>
43 <?php if ( $analytics->ga_token ) : ?>
44 <a class="button"
45 href="<?php echo $analytics->token_url( $this->setting_url( 'analytics' ), true ) ?>"><?php $this->e( 'Delete' ) ?></a>
46 <?php endif; ?>
47 </p>
48
49
50
51 <?php if ( $analytics->ga_token ) : ?>
52 <h3><i class="lsf lsf-dashboard"></i> <?php $this->e( 'Account, Profile, View' ) ?></h3>
53 <form id="ga-connection"
54 action="<?php echo $analytics->token_save_url() ?>" method="post"
55 data-endpoint="<?php echo admin_url( 'admin-ajax.php?action=wpg_ga_account' ) ?>">
56 <?php wp_nonce_field( 'wp_gianism_google_save-analytics' ) ?>
57 <input type="hidden" name="redirect_to" value="<?php echo esc_url( $this->setting_url( 'analytics' ) ) ?>" />
58 <table class="form-table">
59 <tbody>
60 <tr>
61 <th><label for="ga-account"><?php $this->e( 'Account' ) ?></label></th>
62 <td>
63 <select class="ga-profile-select" name="ga-account" id="ga-account"
64 data-ga-account-id="<?php echo $analytics->ga_profile['account'] ?>"
65 data-child="ga-profile" data-clear-target="1">
66 <option
67 value="0"<?php selected( ! $analytics->ga_profile['account'] ) ?>><?php $this->e( 'Please select' ) ?></option>
68 <?php foreach ( $analytics->ga_accounts as $account ) : ?>
69 <option
70 value="<?php echo esc_attr( $account->id ) ?>"<?php selected( $account->id == $analytics->ga_profile['account'] ) ?>><?php echo esc_html( $account->name ) ?></option>
71 <?php endforeach; ?>
72 </select>
73 <i class="dashicons dashicons-yes"></i>
74 <i class="dashicons dashicons-update"></i>
75 <?php if ( ! $analytics->ga_accounts ) : ?>
76 <p class="description">
77 <?php $this->e( 'Mmh, can\'t get Analytics accounts. Your token might be wrong.' ) ?>
78 </p>
79 <?php endif; ?>
80 </td>
81 </tr>
82 <tr>
83 <th><label for="ga-profile"><?php $this->e( 'Profile' ) ?></label></th>
84 <td>
85 <select class="ga-profile-select" name="ga-profile" id="ga-profile"
86 data-ga-profile-id="<?php echo $analytics->ga_profile['profile'] ?>" data-child="ga-view"
87 data-clear-target="2">
88 <option
89 value="0"<?php selected( ! $analytics->ga_profile['profile'] ) ?>><?php $this->e( 'Please select' ) ?></option>
90 </select>
91 <i class="dashicons dashicons-yes"></i>
92 <i class="dashicons dashicons-update"></i>
93 </td>
94 </tr>
95 <tr>
96 <th><label for="ga-view"><?php $this->e( 'View' ) ?></label></th>
97 <td>
98 <select name="ga-view" id="ga-view" data-ga-view-id="<?php echo $analytics->ga_profile['view'] ?>">
99 <option
100 value="0"<?php selected( ! $analytics->ga_profile['view'] ) ?>><?php $this->e( 'Please select' ) ?></option>
101 </select>
102 <i class="dashicons dashicons-yes"></i>
103 <i class="dashicons dashicons-update"></i>
104 </td>
105 </tr>
106 </tbody>
107 </table>
108 <?php submit_button() ?>
109 </form>
110 <?php endif; ?>
111
112 <h3>
113 <i class="lsf lsf-server"></i> <?php $this->e( 'Create Database' ) ?>
114 </h3>
115 <p>
116 <?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.' ) ?>
117 </p>
118
119 <table class="mysql-table">
120 <caption><?php $this->e( 'Ranking table structure' ) ?></caption>
121 <thead>
122 <tr>
123 <th><?php $this->e( 'Column' ) ?></th>
124 <th><?php $this->e( 'Type' ) ?></th>
125 <th><?php $this->e( 'Length' ) ?></th>
126 <th><?php $this->e( 'Misc' ) ?></th>
127 </tr>
128 </thead>
129 <tbody>
130 <tr>
131 <th scope="row">ID</th>
132 <td>BIGINT</td>
133 <td>20</td>
134 <td>PK, <code>auto_increment</code></td>
135 </tr>
136 <tr>
137 <th scope="row">category</th>
138 <td>VARCHAR</td>
139 <td>64</td>
140 <td>&nbsp;</td>
141 </tr>
142 <tr>
143 <th scope="row">object_id</th>
144 <td>BIGINT</td>
145 <td>20</td>
146 <td>&nbsp;</td>
147 </tr>
148 <tr>
149 <th scope="row">object_value</th>
150 <td>BIGINT</td>
151 <td>20</td>
152 <td>&nbsp;</td>
153 </tr>
154 <tr>
155 <th scope="row">calc_date</th>
156 <td>DATE</td>
157 <td>&nbsp;</td>
158 <td>&nbsp;</td>
159 </tr>
160 <tr>
161 <th scope="row">created</th>
162 <td>TIMESTAMP</td>
163 <td>&nbsp;</td>
164 <td>Default CURRENT_TIMESTAMP</td>
165 </tr>
166 </tbody>
167 </table>
168
169 <?php if ( $analytics->table_exists() ) : ?>
170 <p class="success">
171 <i class="dashicons dashicons-yes"></i> <?php $this->e( 'Table exits.' ) ?>
172 </p>
173 <?php else : ?>
174 <form id="ga-table-create"
175 action="<?php echo $analytics->table_create_url( $this->setting_url( 'analytics' ) ) ?>"
176 method="post">
177 <?php wp_nonce_field( 'wp_gianism_google_create-table' ) ?>
178
179 <?php submit_button( $this->_( 'Create Table' ) ) ?>
180 </form>
181 <?php endif; ?>
182
183 <h3>
184 <i class="lsf lsf-time"></i> <?php $this->e( 'Installed cron files' ) ?>
185 </h3>
186
187 <p class="description">
188 <?php $this->e( 'To install cron, please visit our information site <a href="https://gianism.info/">gianism.info</a>.' ) ?>
189 </p>
190
191 <?php if ( empty( $analytics->crons ) ) : ?>
192 <p><?php $this->e( 'Nothing is installed.' ) ?></p>
193 <?php else : ?>
194 <form class="gianism-admin-form" id="cron-checker" method="post"
195 action="<?php echo admin_url( 'admin-ajax.php' ) ?>">
196 <input type="hidden" name="action" value="<?php echo $analytics::AJAX_CRON ?>"/>
197 <?php wp_nonce_field( $analytics::AJAX_CRON ) ?>
198 <table class="mysql-table">
199 <thead>
200 <tr>
201 <th><?php $this->e( 'Class Name' ) ?></th>
202 <th><?php $this->e( 'Category' ) ?></th>
203 <th><?php $this->e( 'Interval' ) ?></th>
204 <th><?php $this->e( 'Available' ) ?></th>
205 </tr>
206 </thead>
207 <tbody>
208 <?php $counter = 0;
209 foreach ( $analytics->crons as $class_name ) : ?>
210 <tr>
211 <th scope="row">
212 <label>
213 <input type="radio" name="cron" value="<?php echo $counter ?>"/>
214 <?php echo $class_name ?>
215 </label>
216 </th>
217 <td><?php echo $class_name::CATEGORY ?></td>
218 <td><?php echo $class_name::INTERVAL ?></td>
219 <td>
220 <?php if ( $class_name::SKIP_CRON ) : ?>
221 <span class="description"><i class="lsf lsf-ban"></i> No</span>
222 <?php else : ?>
223 <span class="success"><i class="lsf lsf-check"></i> Yes</span>
224 <?php endif; ?>
225 </td>
226 </tr>
227 <?php $counter ++; endforeach; ?>
228 </tbody>
229 </table>
230 <?php submit_button( $this->_( 'Check Data' ) ) ?>
231 <pre></pre>
232 </form>
233 <?php endif; ?>
234
235 <p class="description">
236 <?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/' ) ?>
237 </p>
238
239 <h3>
240 <i class="lsf lsf-upload"></i> <?php $this->e( 'Installed Ajax files' ) ?>
241 </h3>
242
243 <p class="description">
244 <?php $this->e( 'To install Ajax actions, please visit our information site <a href="https://gianism.info/">gianism.info</a>.' ) ?>
245 </p>
246
247
248 <?php if ( empty( $analytics->ajaxes ) ) : ?>
249 <p><?php $this->e( 'Nothing is installed.' ) ?></p>
250 <?php else : ?>
251 <form class="gianism-admin-form" id="ajax-checker" method="get"
252 action="<?php echo admin_url( 'admin-ajax.php' ) ?>">
253 <input type="hidden" name="_wpnonce" value=""/>
254 <table class="mysql-table">
255 <thead>
256 <tr>
257 <th><?php $this->e( 'Class Name' ) ?></th>
258 <th><?php $this->e( 'Endpoint' ) ?></th>
259 </tr>
260 </thead>
261 <tbody>
262 <?php foreach ( $analytics->ajaxes as $ajax ) : ?>
263 <tr>
264 <td>
265 <label>
266 <input type="radio" name="action" value="<?php echo esc_attr( $ajax::ACTION ) ?>"
267 data-nonce="<?php echo esc_attr( $ajax::get_nonce() ) ?>" data-action=""/>
268 <?php echo esc_html( $ajax ) ?>
269 </label>
270 </td>
271 <td><?php printf( '<a href="%1$s">%1$s</a>', esc_url( $ajax::endpoint() ) ) ?></td>
272 </tr>
273 <?php endforeach; ?>
274 </tbody>
275 </table>
276 <table class="form-table">
277 <tr>
278 <th><label for="from"><?php $this->e( 'From' ) ?></label></th>
279 <td><input type="text" class="datepicker" id="from" name="from"
280 value="<?php echo date_i18n( 'Y-m-d', strtotime( '1 month ago', current_time( 'timestamp' ) ) ) ?>"
281 placeholder="YYYY-MM-DD"/></td>
282 </tr>
283 <tr>
284 <th><label for="to"><?php $this->e( 'To' ) ?></label></th>
285 <td><input type="text" class="datepicker" id="to" name="to"
286 value="<?php echo date_i18n( 'Y-m-d' ) ?>" placeholder="YYYY-MM-DD"/></td>
287 </tr>
288 </table>
289 <p class="descritpion"></p>
290 <?php submit_button( $this->_( 'Check Data' ) ) ?>
291 <pre></pre>
292 </form>
293 <?php endif; ?>
294