Version Description
Please update Piwik if not done yet (Piwik 2.7 or higher is recommended).
Download this release
Release Info
Developer | Braekling |
Plugin | WP-Matomo (WP-Piwik) |
Version | 0.10.0.1 |
Comparing to | |
See all releases |
Code changes from version 0.10.0.0 to 0.10.0.1
- classes/WP_Piwik.php +1128 -630
- classes/WP_Piwik/Admin/Settings.php +567 -354
- classes/WP_Piwik/Admin/Sitebrowser.php +24 -27
- classes/WP_Piwik/Admin/Statistics.php +3 -3
- classes/WP_Piwik/Request/Php.php +2 -1
- classes/WP_Piwik/Request/Rest.php +3 -2
- classes/WP_Piwik/Settings.php +367 -258
- classes/WP_Piwik/TrackingCode.php +7 -9
- classes/WP_Piwik/Widget.php +63 -24
- classes/WP_Piwik/Widget/BrowserDetails.php +3 -2
- classes/WP_Piwik/Widget/Browsers.php +4 -3
- classes/WP_Piwik/Widget/Chart.php +11 -6
- classes/WP_Piwik/Widget/Keywords.php +1 -1
- classes/WP_Piwik/Widget/Noresult.php +1 -1
- classes/WP_Piwik/Widget/Overview.php +17 -6
- classes/WP_Piwik/Widget/Pages.php +1 -1
- classes/WP_Piwik/Widget/Plugins.php +1 -1
- classes/WP_Piwik/Widget/Post.php +1 -1
- classes/WP_Piwik/Widget/Referrers.php +1 -1
- classes/WP_Piwik/Widget/Screens.php +3 -2
- classes/WP_Piwik/Widget/Search.php +1 -1
- classes/WP_Piwik/Widget/Systems.php +3 -2
- classes/WP_Piwik/Widget/Visitors.php +21 -7
- css/wp-piwik.css +6 -105
- js/wp-piwik.js +1 -1
- proxy/config.php +9 -4
- readme.txt +1 -1
- settings/credits.php +0 -31
- settings/piwik.php +0 -123
- settings/support.php +0 -60
- settings/tracking.php +0 -157
- settings/views.php +0 -65
- wp-piwik.php +10 -2
classes/WP_Piwik.php
CHANGED
@@ -1,631 +1,1129 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
$
|
22 |
-
$
|
23 |
-
$this->
|
24 |
-
$this->
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
}
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
));
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
self::$settings->getOption('
|
290 |
-
|
291 |
-
}
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
}
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
}
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
public function
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
}
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
'
|
494 |
-
'
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
return $
|
514 |
-
}
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
return
|
579 |
-
}
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
631 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The main WP-Piwik class configures, registers and manages the plugin
|
5 |
+
*
|
6 |
+
* @author André Bräkling <webmaster@braekling.de>
|
7 |
+
* @package WP_Piwik
|
8 |
+
*/
|
9 |
+
class WP_Piwik {
|
10 |
+
|
11 |
+
/**
|
12 |
+
*
|
13 |
+
* @var Runtime environment variables
|
14 |
+
*/
|
15 |
+
private static $intRevisionId = 99914, $strVersion = '0.10.0.1', $blog_id, $intDashboardID = 30, $strPluginBasename = NULL, $bolJustActivated = false, $logger, $settings, $request;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Constructor class to configure and register all WP-Piwik components
|
19 |
+
*/
|
20 |
+
public function __construct() {
|
21 |
+
global $blog_id;
|
22 |
+
self::$blog_id = (isset ( $blog_id ) ? $blog_id : 'n/a');
|
23 |
+
$this->openLogger ();
|
24 |
+
$this->openSettings ();
|
25 |
+
$this->setup ();
|
26 |
+
$this->addFilters ();
|
27 |
+
$this->addActions ();
|
28 |
+
$this->addShortcodes ();
|
29 |
+
self::$settings->save ();
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Destructor class to finish logging
|
34 |
+
*/
|
35 |
+
public function __destruct() {
|
36 |
+
$this->closeLogger ();
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Setup class to prepare settings and check for installation and update
|
41 |
+
*/
|
42 |
+
private function setup() {
|
43 |
+
self::$strPluginBasename = plugin_basename ( __FILE__ );
|
44 |
+
if (! $this->isInstalled ())
|
45 |
+
$this->installPlugin ();
|
46 |
+
elseif ($this->isUpdated ())
|
47 |
+
$this->updatePlugin ();
|
48 |
+
if ($this->isConfigSubmitted ())
|
49 |
+
$this->applySettings ();
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Register WordPress actions
|
54 |
+
*/
|
55 |
+
private function addActions() {
|
56 |
+
add_action ( 'admin_notices', array (
|
57 |
+
$this,
|
58 |
+
'showNotices'
|
59 |
+
) );
|
60 |
+
add_action ( 'admin_menu', array (
|
61 |
+
$this,
|
62 |
+
'buildAdminMenu'
|
63 |
+
) );
|
64 |
+
add_action ( 'admin_post_save_wp-piwik_stats', array (
|
65 |
+
$this,
|
66 |
+
'onStatsPageSaveChanges'
|
67 |
+
) );
|
68 |
+
add_action ( 'load-post.php', array (
|
69 |
+
$this,
|
70 |
+
'addPostMetaboxes'
|
71 |
+
) );
|
72 |
+
add_action ( 'load-post-new.php', array (
|
73 |
+
$this,
|
74 |
+
'addPostMetaboxes'
|
75 |
+
) );
|
76 |
+
if ($this->isNetworkMode ()) {
|
77 |
+
add_action ( 'network_admin_menu', array (
|
78 |
+
$this,
|
79 |
+
'buildNetworkAdminMenu'
|
80 |
+
) );
|
81 |
+
add_action ( 'update_site_option_blogname', array (
|
82 |
+
$this,
|
83 |
+
'onBlogNameChange'
|
84 |
+
) );
|
85 |
+
add_action ( 'update_site_option_siteurl', array (
|
86 |
+
$this,
|
87 |
+
'onSiteUrlChange'
|
88 |
+
) );
|
89 |
+
} else {
|
90 |
+
add_action ( 'update_option_blogname', array (
|
91 |
+
$this,
|
92 |
+
'onBlogNameChange'
|
93 |
+
) );
|
94 |
+
add_action ( 'update_option_siteurl', array (
|
95 |
+
$this,
|
96 |
+
'onSiteUrlChange'
|
97 |
+
) );
|
98 |
+
}
|
99 |
+
if ($this->isDashboardActive ())
|
100 |
+
add_action ( 'wp_dashboard_setup', array (
|
101 |
+
$this,
|
102 |
+
'extendWordPressDashboard'
|
103 |
+
) );
|
104 |
+
if ($this->isToolbarActive ()) {
|
105 |
+
add_action ( is_admin () ? 'admin_head' : 'wp_head', array (
|
106 |
+
$this,
|
107 |
+
'loadToolbarRequirements'
|
108 |
+
) );
|
109 |
+
add_action ( 'admin_bar_menu', array (
|
110 |
+
$this,
|
111 |
+
'extendWordPressToolbar'
|
112 |
+
), 1000 );
|
113 |
+
}
|
114 |
+
if ($this->isTrackingActive ()) {
|
115 |
+
add_action ( self::$settings->getGlobalOption ( 'track_codeposition' ) == 'footer' ? 'wp_footer' : 'wp_head', array (
|
116 |
+
$this,
|
117 |
+
'addJavascriptCode'
|
118 |
+
) );
|
119 |
+
if ($this->isAddNoScriptCode ())
|
120 |
+
add_action ( 'wp_footer', array (
|
121 |
+
$this,
|
122 |
+
'addNoscriptCode'
|
123 |
+
) );
|
124 |
+
if ($this->isAdminTrackingActive ())
|
125 |
+
add_action ( self::$settings->getGlobalOption ( 'track_codeposition' ) == 'footer' ? 'admin_footer' : 'admin_head', array (
|
126 |
+
$this,
|
127 |
+
'addJavascriptCode'
|
128 |
+
) );
|
129 |
+
}
|
130 |
+
if (self::$settings->getGlobalOption ( 'add_post_annotations' ))
|
131 |
+
add_action ( 'transition_post_status', array (
|
132 |
+
$this,
|
133 |
+
'onPostStatusTransition'
|
134 |
+
), 10, 3 );
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Register WordPress filters
|
139 |
+
*/
|
140 |
+
private function addFilters() {
|
141 |
+
add_filter ( 'plugin_row_meta', array (
|
142 |
+
$this,
|
143 |
+
'setPluginMeta'
|
144 |
+
), 10, 2 );
|
145 |
+
add_filter ( 'screen_layout_columns', array (
|
146 |
+
$this,
|
147 |
+
'onScreenLayoutColumns'
|
148 |
+
), 10, 2 );
|
149 |
+
if ($this->isTrackingActive ()) {
|
150 |
+
if ($this->isTrackFeed ()) {
|
151 |
+
add_filter ( 'the_excerpt_rss', array (
|
152 |
+
$this,
|
153 |
+
'addFeedTracking'
|
154 |
+
) );
|
155 |
+
add_filter ( 'the_content', array (
|
156 |
+
$this,
|
157 |
+
'addFeedTracking'
|
158 |
+
) );
|
159 |
+
}
|
160 |
+
if ($this->isAddFeedCampaign ())
|
161 |
+
add_filter ( 'post_link', array (
|
162 |
+
$this,
|
163 |
+
'addFeedCampaign'
|
164 |
+
) );
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Register WordPress shortcodes
|
170 |
+
*/
|
171 |
+
private function addShortcodes() {
|
172 |
+
if ($this->isAddShortcode ())
|
173 |
+
add_shortcode ( 'wp-piwik', array (
|
174 |
+
$this,
|
175 |
+
'shortcode'
|
176 |
+
) );
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Install WP-Piwik for the first time
|
181 |
+
*/
|
182 |
+
private function installPlugin($isUpdate = false) {
|
183 |
+
self::$logger->log ( 'Running WP-Piwik installation' );
|
184 |
+
if (! $isUpdate)
|
185 |
+
$this->addNotice ( 'install', sprintf ( __ ( '%s %s installed.', 'wp-piwik' ), self::$settings->getGlobalOption ( 'plugin_display_name' ), self::$strVersion ), __ ( 'Next you should connect to Piwik', 'wp-piwik' ) );
|
186 |
+
self::$settings->setGlobalOption ( 'revision', self::$intRevisionId );
|
187 |
+
self::$settings->setGlobalOption ( 'last_settings_update', time () );
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Uninstall WP-Piwik
|
192 |
+
*/
|
193 |
+
public static function uninstallPlugin() {
|
194 |
+
self::$logger->log ( 'Running WP-Piwik uninstallation' );
|
195 |
+
if (! defined ( 'WP_UNINSTALL_PLUGIN' ))
|
196 |
+
exit ();
|
197 |
+
delete_option ( 'wp-piwik_notices' );
|
198 |
+
self::$settings->resetSettings ( true );
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Update WP-Piwik
|
203 |
+
*/
|
204 |
+
private function updatePlugin() {
|
205 |
+
self::$logger->log ( 'Upgrade WP-Piwik to ' . self::$strVersion );
|
206 |
+
$patches = glob ( dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'update' . DIRECTORY_SEPARATOR . '*.php' );
|
207 |
+
if (is_array ( $patches )) {
|
208 |
+
sort ( $patches );
|
209 |
+
foreach ( $patches as $patch ) {
|
210 |
+
$patchVersion = ( int ) pathinfo ( $patch, PATHINFO_FILENAME );
|
211 |
+
if ($patchVersion && self::$settings->getGlobalOption ( 'revision' ) < $patchVersion)
|
212 |
+
self::includeFile ( 'update' . DIRECTORY_SEPARATOR . $patchVersion );
|
213 |
+
}
|
214 |
+
}
|
215 |
+
$this->addNotice ( 'update', sprintf ( __ ( '%s updated to %s.', 'wp-piwik' ), self::$settings->getGlobalOption ( 'plugin_display_name' ), self::$strVersion ), __ ( 'Please validate your configuration', 'wp-piwik' ) );
|
216 |
+
$this->installPlugin ( true );
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Define a notice
|
221 |
+
*
|
222 |
+
* @param string $type
|
223 |
+
* identifier
|
224 |
+
* @param string $subject
|
225 |
+
* notice headline
|
226 |
+
* @param string $text
|
227 |
+
* notice content
|
228 |
+
* @param boolean $stay
|
229 |
+
* set to true if the message should persist (default: false)
|
230 |
+
*/
|
231 |
+
private function addNotice($type, $subject, $text, $stay = false) {
|
232 |
+
$notices = get_option ( 'wp-piwik_notices', array () );
|
233 |
+
$notices [$type] = array (
|
234 |
+
'subject' => $subject,
|
235 |
+
'text' => $text,
|
236 |
+
'stay' => $stay
|
237 |
+
);
|
238 |
+
update_option ( 'wp-piwik_notices', $notices );
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Show all notices defined previously
|
243 |
+
*
|
244 |
+
* @see addNotice()
|
245 |
+
*/
|
246 |
+
public function showNotices() {
|
247 |
+
$link = sprintf ( '<a href="' . $this->getSettingsURL () . '">%s</a>', __ ( 'Settings', 'wp-piwik' ) );
|
248 |
+
if ($notices = get_option ( 'wp-piwik_notices' )) {
|
249 |
+
foreach ( $notices as $type => $notice ) {
|
250 |
+
printf ( '<div class="updated fade"><p>%s <strong>%s:</strong> %s: %s</p></div>', $notice ['subject'], __ ( 'Important', 'wp-piwik' ), $notice ['text'], $link );
|
251 |
+
if (! $notice ['stay'])
|
252 |
+
unset ( $notices [$type] );
|
253 |
+
}
|
254 |
+
}
|
255 |
+
update_option ( 'wp-piwik_notices', $notices );
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Get the settings page URL
|
260 |
+
*
|
261 |
+
* @return string settings page URL
|
262 |
+
*/
|
263 |
+
private function getSettingsURL() {
|
264 |
+
return (self::$settings->checkNetworkActivation () ? 'settings' : 'options-general') . '.php?page=' . self::$strPluginBasename;
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Echo javascript tracking code
|
269 |
+
*/
|
270 |
+
public function addJavascriptCode() {
|
271 |
+
if ($this->isHiddenUser ()) {
|
272 |
+
self::$logger->log ( 'Do not add tracking code to site (user should not be tracked) Blog ID: ' . self::$blog_id . ' Site ID: ' . self::$settings->getOption ( 'site_id' ) );
|
273 |
+
return;
|
274 |
+
}
|
275 |
+
$trackingCode = new WP_Piwik\TrackingCode ( $this );
|
276 |
+
$trackingCode->is404 = (is_404 () && self::$settings->getGlobalOption ( 'track_404' ));
|
277 |
+
$trackingCode->isSearch = (is_search () && self::$settings->getGlobalOption ( 'track_search' ));
|
278 |
+
self::$logger->log ( 'Add tracking code. Blog ID: ' . self::$blog_id . ' Site ID: ' . self::$settings->getOption ( 'site_id' ) );
|
279 |
+
echo $trackingCode->getTrackingCode ();
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* Echo noscript tracking code
|
284 |
+
*/
|
285 |
+
public function addNoscriptCode() {
|
286 |
+
if (self::$settings->getGlobalOption ( 'track_mode' ) == 'proxy')
|
287 |
+
return;
|
288 |
+
if ($this->isHiddenUser ()) {
|
289 |
+
self::$logger->log ( 'Do not add noscript code to site (user should not be tracked) Blog ID: ' . self::$blog_id . ' Site ID: ' . self::$settings->getOption ( 'site_id' ) );
|
290 |
+
return;
|
291 |
+
}
|
292 |
+
self::$logger->log ( 'Add noscript code. Blog ID: ' . self::$blog_id . ' Site ID: ' . self::$settings->getOption ( 'site_id' ) );
|
293 |
+
echo self::$settings->getOption ( 'noscript_code' ) . "\n";
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Register post view meta boxes
|
298 |
+
*/
|
299 |
+
public function addPostMetaboxes() {
|
300 |
+
if (self::$settings->getGlobalOption ( 'add_customvars_box' )) {
|
301 |
+
add_action ( 'add_meta_boxes', array (
|
302 |
+
new WP_Piwik\Template\MetaBoxCustomVars ( $this, self::$settings ),
|
303 |
+
'addMetabox'
|
304 |
+
) );
|
305 |
+
add_action ( 'save_post', array (
|
306 |
+
new WP_Piwik\Template\MetaBoxCustomVars ( $this, self::$settings ),
|
307 |
+
'saveCustomVars'
|
308 |
+
), 10, 2 );
|
309 |
+
}
|
310 |
+
if (self::$settings->getGlobalOption ( 'perpost_stats' )) {
|
311 |
+
add_action ( 'add_meta_boxes', array (
|
312 |
+
$this,
|
313 |
+
'onloadPostPage'
|
314 |
+
) );
|
315 |
+
}
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Register admin menu components
|
320 |
+
*/
|
321 |
+
public function buildAdminMenu() {
|
322 |
+
if (self::isConfigured ()) {
|
323 |
+
$statsPage = new WP_Piwik\Admin\Statistics ( $this, self::$settings );
|
324 |
+
$this->statsPageId = add_dashboard_page ( __ ( 'Piwik Statistics', 'wp-piwik' ), self::$settings->getGlobalOption ( 'plugin_display_name' ), 'wp-piwik_read_stats', 'wp-piwik_stats', array (
|
325 |
+
$statsPage,
|
326 |
+
'show'
|
327 |
+
) );
|
328 |
+
$this->loadAdminStatsHeader($this->statsPageId, $statsPage);
|
329 |
+
}
|
330 |
+
if (! self::$settings->checkNetworkActivation ()) {
|
331 |
+
$optionsPage = new WP_Piwik\Admin\Settings ( $this, self::$settings );
|
332 |
+
$optionsPageId = add_options_page ( self::$settings->getGlobalOption ( 'plugin_display_name' ), self::$settings->getGlobalOption ( 'plugin_display_name' ), 'activate_plugins', __FILE__, array (
|
333 |
+
$optionsPage,
|
334 |
+
'show'
|
335 |
+
) );
|
336 |
+
$this->loadAdminSettingsHeader($optionsPageId, $optionsPage);
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Register network admin menu components
|
342 |
+
*/
|
343 |
+
public function buildNetworkAdminMenu() {
|
344 |
+
if (self::isConfigured ()) {
|
345 |
+
$statsPage = new WP_Piwik\Admin\Network ( $this, self::$settings );
|
346 |
+
$this->statsPageId = add_dashboard_page ( __ ( 'Piwik Statistics', 'wp-piwik' ), self::$settings->getGlobalOption ( 'plugin_display_name' ), 'manage_sites', 'wp-piwik_stats', array (
|
347 |
+
$statsPage,
|
348 |
+
'show'
|
349 |
+
) );
|
350 |
+
$this->loadAdminStatsHeader($this->statsPageId, $statsPage);
|
351 |
+
}
|
352 |
+
$optionsPage = new WP_Piwik\Admin\Settings ( $this, self::$settings );
|
353 |
+
$optionsPageId = add_submenu_page ( 'settings.php', self::$settings->getGlobalOption ( 'plugin_display_name' ), self::$settings->getGlobalOption ( 'plugin_display_name' ), 'manage_sites', __FILE__, array (
|
354 |
+
$optionsPage,
|
355 |
+
'show'
|
356 |
+
) );
|
357 |
+
$this->loadAdminSettingsHeader($optionsPageId, $optionsPage);
|
358 |
+
}
|
359 |
+
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Register admin header extensions for stats page
|
363 |
+
*
|
364 |
+
* @param $optionsPageId options page id
|
365 |
+
* @param $optionsPage options page object
|
366 |
+
*/
|
367 |
+
public function loadAdminStatsHeader($statsPageId, $statsPage) {
|
368 |
+
add_action ( 'admin_print_scripts-' . $statsPageId, array (
|
369 |
+
$statsPage,
|
370 |
+
'printAdminScripts'
|
371 |
+
) );
|
372 |
+
add_action ( 'admin_print_styles-' . $statsPageId, array (
|
373 |
+
$statsPage,
|
374 |
+
'printAdminStyles'
|
375 |
+
) );
|
376 |
+
add_action ( 'admin_head-' . $statsPageId, array (
|
377 |
+
$statsPage,
|
378 |
+
'extendAdminHeader'
|
379 |
+
) );
|
380 |
+
add_action ( 'load-' . $statsPageId, array (
|
381 |
+
$this,
|
382 |
+
'onloadStatsPage'
|
383 |
+
) );
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Register admin header extensions for settings page
|
388 |
+
*
|
389 |
+
* @param $optionsPageId options page id
|
390 |
+
* @param $optionsPage options page object
|
391 |
+
*/
|
392 |
+
public function loadAdminSettingsHeader($optionsPageId, $optionsPage) {
|
393 |
+
add_action ( 'admin_head-' . $optionsPageId, array (
|
394 |
+
$optionsPage,
|
395 |
+
'extendAdminHeader'
|
396 |
+
) );
|
397 |
+
add_action ( 'admin_print_styles-' . $optionsPageId, array (
|
398 |
+
$optionsPage,
|
399 |
+
'printAdminStyles'
|
400 |
+
) );
|
401 |
+
}
|
402 |
+
|
403 |
+
/**
|
404 |
+
* Register WordPress dashboard widgets
|
405 |
+
*/
|
406 |
+
public function extendWordPressDashboard() {
|
407 |
+
if (current_user_can ( 'wp-piwik_read_stats' )) {
|
408 |
+
if (self::$settings->getGlobalOption ( 'dashboard_widget' ) != 'disabled')
|
409 |
+
new WP_Piwik\Widget\Overview ( $this, self::$settings, 'dashboard', 'side', 'default', array('date' => self::$settings->getGlobalOption('dashboard_widget'), 'period' => 'day') );
|
410 |
+
if (self::$settings->getGlobalOption ( 'dashboard_chart' ))
|
411 |
+
new WP_Piwik\Widget\Chart ( $this, self::$settings );
|
412 |
+
if (self::$settings->getGlobalOption ( 'dashboard_seo' ))
|
413 |
+
new WP_Piwik\Widget\Seo ( $this, self::$settings );
|
414 |
+
}
|
415 |
+
}
|
416 |
+
|
417 |
+
/**
|
418 |
+
* Register WordPress toolbar components
|
419 |
+
*/
|
420 |
+
public function extendWordPressToolbar($toolbar) {
|
421 |
+
if (current_user_can ( 'wp-piwik_read_stats' ) && is_admin_bar_showing ()) {
|
422 |
+
$id = WP_Piwik\Request::register ( 'VisitsSummary.getUniqueVisitors', array (
|
423 |
+
'period' => 'day',
|
424 |
+
'date' => 'last30'
|
425 |
+
) );
|
426 |
+
$unique = $this->request ( $id );
|
427 |
+
if (is_array ( $unique )) {
|
428 |
+
$graph = "<script type='text/javascript'>var \$jSpark = jQuery.noConflict();\$jSpark(function() {var piwikSparkVals=[" . implode ( ',', $unique ) . "];\$jSpark('.wp-piwik_dynbar').sparkline(piwikSparkVals, {type: 'bar', barColor: '#ccc', barWidth:2});});</script><span class='wp-piwik_dynbar'>Loading...</span>";
|
429 |
+
$toolbar->add_menu ( array (
|
430 |
+
'id' => 'wp-piwik_stats',
|
431 |
+
'title' => $graph,
|
432 |
+
'href' => $this->getStatsURL ()
|
433 |
+
) );
|
434 |
+
}
|
435 |
+
}
|
436 |
+
}
|
437 |
+
|
438 |
+
/**
|
439 |
+
* Add plugin meta data
|
440 |
+
*
|
441 |
+
* @param array $links
|
442 |
+
* list of already defined plugin meta data
|
443 |
+
* @param string $file
|
444 |
+
* handled file
|
445 |
+
* @return array complete list of plugin meta data
|
446 |
+
*/
|
447 |
+
public function setPluginMeta($links, $file) {
|
448 |
+
if ($file == 'wp-piwik/wp-piwik.php')
|
449 |
+
return array_merge ( $links, array (
|
450 |
+
sprintf ( '<a href="%s">%s</a>', self::getSettingsURL (), __ ( 'Settings', 'wp-piwik' ) )
|
451 |
+
) );
|
452 |
+
return $links;
|
453 |
+
}
|
454 |
+
|
455 |
+
/**
|
456 |
+
* Prepare toolbar widget requirements
|
457 |
+
*/
|
458 |
+
public function loadToolbarRequirements() {
|
459 |
+
if (current_user_can ( 'wp-piwik_read_stats' ) && is_admin_bar_showing ()) {
|
460 |
+
wp_enqueue_script ( 'wp-piwik-sparkline', $this->getPluginURL () . 'js/sparkline/jquery.sparkline.min.js', array (
|
461 |
+
'jquery'
|
462 |
+
), self::$strVersion );
|
463 |
+
wp_enqueue_style ( 'wp-piwik', $this->getPluginURL () . 'css/wp-piwik-spark.css', array (), self::$strVersion );
|
464 |
+
}
|
465 |
+
}
|
466 |
+
|
467 |
+
/**
|
468 |
+
* Add tracking pixels to feed content
|
469 |
+
*
|
470 |
+
* @param string $content
|
471 |
+
* post content
|
472 |
+
* @return string post content extended by tracking pixel
|
473 |
+
*/
|
474 |
+
public function addFeedTracking($content) {
|
475 |
+
global $post;
|
476 |
+
if (is_feed ()) {
|
477 |
+
self::$logger->log ( 'Add tracking image to feed entry.' );
|
478 |
+
if (! self::$settings->getOption ( 'site_id' )) {
|
479 |
+
$siteId = $this->requestPiwikSiteId();
|
480 |
+
if ($siteId != 'n/a')
|
481 |
+
self::$settings->setOption( 'site_id', $siteId);
|
482 |
+
else
|
483 |
+
return;
|
484 |
+
}
|
485 |
+
$title = the_title ( null, null, false );
|
486 |
+
$posturl = get_permalink ( $post->ID );
|
487 |
+
$urlref = get_bloginfo ( 'rss2_url' );
|
488 |
+
$url = self::$settings->getGlobalOption ( 'piwik_url' );
|
489 |
+
if (substr ( $url, - 10, 10 ) == '/index.php')
|
490 |
+
$url = str_replace ( '/index.php', '/piwik.php', $url );
|
491 |
+
else
|
492 |
+
$url .= 'piwik.php';
|
493 |
+
$trackingImage = $url . '?idsite=' . self::$settings->getOption ( 'site_id' ) . '&rec=1&url=' . urlencode ( $posturl ) . '&action_name=' . urlencode ( $title ) . '&urlref=' . urlencode ( $urlref );
|
494 |
+
$content .= '<img src="' . $trackingImage . '" style="border:0;width:0;height:0" width="0" height="0" alt="" />';
|
495 |
+
}
|
496 |
+
return $content;
|
497 |
+
}
|
498 |
+
|
499 |
+
/**
|
500 |
+
* Add a campaign parameter to feed permalink
|
501 |
+
*
|
502 |
+
* @param string $permalink
|
503 |
+
* permalink
|
504 |
+
* @return string permalink extended by campaign parameter
|
505 |
+
*/
|
506 |
+
public function addFeedCampaign($permalink) {
|
507 |
+
global $post;
|
508 |
+
if (is_feed ()) {
|
509 |
+
self::$logger->log ( 'Add campaign to feed permalink.' );
|
510 |
+
$sep = (strpos ( $permalink, '?' ) === false ? '?' : '&');
|
511 |
+
$permalink .= $sep . 'pk_campaign=' . urlencode ( self::$settings->getGlobalOption ( 'track_feed_campaign' ) ) . '&pk_kwd=' . urlencode ( $post->post_name );
|
512 |
+
}
|
513 |
+
return $permalink;
|
514 |
+
}
|
515 |
+
|
516 |
+
/**
|
517 |
+
* Add a new post annotation in Piwik
|
518 |
+
*
|
519 |
+
* @param int $postID
|
520 |
+
* The new post's ID
|
521 |
+
*/
|
522 |
+
public function addPiwikAnnotation($postID) {
|
523 |
+
$note = 'Published: ' . get_post ( $postID )->post_title . ' - URL: ' . get_permalink ( $postID );
|
524 |
+
$id = WP_Piwik\Request::register ( 'Annotations.add', array (
|
525 |
+
'idSite' => $this->getPiwikSiteId (),
|
526 |
+
'date' => date ( 'Y-m-d' ),
|
527 |
+
'note' => $note
|
528 |
+
) );
|
529 |
+
$result = $this->request ( $id );
|
530 |
+
self::$logger->log ( 'Add post annotation. ' . $note . ' - ' . serialize ( $result ) );
|
531 |
+
}
|
532 |
+
|
533 |
+
/**
|
534 |
+
* Apply settings update
|
535 |
+
*
|
536 |
+
* @return boolean settings update applied
|
537 |
+
*/
|
538 |
+
private function applySettings() {
|
539 |
+
if (isset ( $_POST ) && isset ( $_POST ['wp-piwik'] )) {
|
540 |
+
self::$settings->applyChanges ( $_POST ['wp-piwik'] );
|
541 |
+
if (self::$settings->getGlobalOption ( 'auto_site_config' ) && self::isConfigured ()) {
|
542 |
+
if ($this->isPHPMode () && ! defined ( 'PIWIK_INCLUDE_PATH' ))
|
543 |
+
self::definePiwikConstants ();
|
544 |
+
$siteId = $this->requestPiwikSiteId ();
|
545 |
+
$trackingCode = $this->updateTrackingCode( $siteId );
|
546 |
+
self::$settings->getOption ( 'tracking_code', $trackingCode );
|
547 |
+
self::$settings->getOption ( 'site_id', $siteId );
|
548 |
+
}
|
549 |
+
return true;
|
550 |
+
}
|
551 |
+
return false;
|
552 |
+
}
|
553 |
+
|
554 |
+
/**
|
555 |
+
* Check if WP-Piwik is configured
|
556 |
+
*
|
557 |
+
* @return boolean Is WP-Piwik configured?
|
558 |
+
*/
|
559 |
+
public static function isConfigured() {
|
560 |
+
return (self::$settings->getGlobalOption ( 'piwik_token' ) && (self::$settings->getGlobalOption ( 'piwik_mode' ) != 'disabled') && (((self::$settings->getGlobalOption ( 'piwik_mode' ) == 'http') && (self::$settings->getGlobalOption ( 'piwik_url' ))) || ((self::$settings->getGlobalOption ( 'piwik_mode' ) == 'php') && (self::$settings->getGlobalOption ( 'piwik_path' ))) || ((self::$settings->getGlobalOption ( 'piwik_mode' ) == 'pro') && (self::$settings->getGlobalOption ( 'piwik_user' )))));
|
561 |
+
}
|
562 |
+
|
563 |
+
/**
|
564 |
+
* Check if WP-Piwik was updated
|
565 |
+
*
|
566 |
+
* @return boolean Was WP-Piwik updated?
|
567 |
+
*/
|
568 |
+
private function isUpdated() {
|
569 |
+
return self::$settings->getGlobalOption ( 'revision' ) && self::$settings->getGlobalOption ( 'revision' ) < self::$intRevisionId;
|
570 |
+
}
|
571 |
+
|
572 |
+
/**
|
573 |
+
* Check if WP-Piwik is already installed
|
574 |
+
*
|
575 |
+
* @return boolean Is WP-Piwik installed?
|
576 |
+
*/
|
577 |
+
private function isInstalled() {
|
578 |
+
return self::$settings->getGlobalOption ( 'revision' );
|
579 |
+
}
|
580 |
+
|
581 |
+
/**
|
582 |
+
* Check if new settings were submitted
|
583 |
+
*
|
584 |
+
* @return boolean Are new settings submitted?
|
585 |
+
*/
|
586 |
+
private function isConfigSubmitted() {
|
587 |
+
return isset ( $_POST ['action'] ) && $_POST ['action'] == 'save_wp-piwik_settings';
|
588 |
+
}
|
589 |
+
|
590 |
+
/**
|
591 |
+
* Check if PHP mode is chosen
|
592 |
+
*
|
593 |
+
* @return Is PHP mode chosen?
|
594 |
+
*/
|
595 |
+
public function isPHPMode() {
|
596 |
+
return self::$settings->getGlobalOption ( 'piwik_mode' ) && self::$settings->getGlobalOption ( 'piwik_mode' ) == 'php';
|
597 |
+
}
|
598 |
+
|
599 |
+
/**
|
600 |
+
* Check if WordPress is running in network mode
|
601 |
+
*
|
602 |
+
* @return boolean Is WordPress running in network mode?
|
603 |
+
*/
|
604 |
+
public function isNetworkMode() {
|
605 |
+
return self::$settings->checkNetworkActivation ();
|
606 |
+
}
|
607 |
+
|
608 |
+
/**
|
609 |
+
* Check if a WP-Piwik dashboard widget is enabled
|
610 |
+
*
|
611 |
+
* @return boolean Is a dashboard widget enabled?
|
612 |
+
*/
|
613 |
+
private function isDashboardActive() {
|
614 |
+
return self::$settings->getGlobalOption ( 'dashboard_widget' ) || self::$settings->getGlobalOption ( 'dashboard_chart' ) || self::$settings->getGlobalOption ( 'dashboard_seo' );
|
615 |
+
}
|
616 |
+
|
617 |
+
/**
|
618 |
+
* Check if a WP-Piwik toolbar widget is enabled
|
619 |
+
*
|
620 |
+
* @return boolean Is a toolbar widget enabled?
|
621 |
+
*/
|
622 |
+
private function isToolbarActive() {
|
623 |
+
return self::$settings->getGlobalOption ( 'toolbar' );
|
624 |
+
}
|
625 |
+
|
626 |
+
/**
|
627 |
+
* Check if WP-Piwik tracking code insertion is enabled
|
628 |
+
*
|
629 |
+
* @return boolean Insert tracking code?
|
630 |
+
*/
|
631 |
+
private function isTrackingActive() {
|
632 |
+
return self::$settings->getGlobalOption ( 'track_mode' ) != 'disabled';
|
633 |
+
}
|
634 |
+
|
635 |
+
/**
|
636 |
+
* Check if admin tracking is enabled
|
637 |
+
*
|
638 |
+
* @return boolean Is admin tracking enabled?
|
639 |
+
*/
|
640 |
+
private function isAdminTrackingActive() {
|
641 |
+
return self::$settings->getGlobalOption ( 'track_admin' ) && is_admin ();
|
642 |
+
}
|
643 |
+
|
644 |
+
/**
|
645 |
+
* Check if WP-Piwik noscript code insertion is enabled
|
646 |
+
*
|
647 |
+
* @return boolean Insert noscript code?
|
648 |
+
*/
|
649 |
+
private function isAddNoScriptCode() {
|
650 |
+
return self::$settings->getGlobalOption ( 'track_noscript' );
|
651 |
+
}
|
652 |
+
|
653 |
+
/**
|
654 |
+
* Check if feed tracking is enabled
|
655 |
+
*
|
656 |
+
* @return boolean Is feed tracking enabled?
|
657 |
+
*/
|
658 |
+
private function isTrackFeed() {
|
659 |
+
return self::$settings->getGlobalOption ( 'track_feed' );
|
660 |
+
}
|
661 |
+
|
662 |
+
/**
|
663 |
+
* Check if feed permalinks get a campaign parameter
|
664 |
+
*
|
665 |
+
* @return boolean Add campaign parameter to feed permalinks?
|
666 |
+
*/
|
667 |
+
private function isAddFeedCampaign() {
|
668 |
+
return self::$settings->getGlobalOption ( 'track_feed_addcampaign' );
|
669 |
+
}
|
670 |
+
|
671 |
+
/**
|
672 |
+
* Check if WP-Piwik shortcodes are enabled
|
673 |
+
*
|
674 |
+
* @return boolean Are shortcodes enabled?
|
675 |
+
*/
|
676 |
+
private function isAddShortcode() {
|
677 |
+
return self::$settings->getGlobalOption ( 'shortcodes' );
|
678 |
+
}
|
679 |
+
|
680 |
+
/**
|
681 |
+
* Define Piwik constants for PHP reporting API
|
682 |
+
*/
|
683 |
+
public static function definePiwikConstants() {
|
684 |
+
if (! defined ( 'PIWIK_INCLUDE_PATH' )) {
|
685 |
+
@header ( 'Content-type: text/xml' );
|
686 |
+
define ( 'PIWIK_INCLUDE_PATH', self::$settings->getGlobalOption ( 'piwik_path' ) );
|
687 |
+
define ( 'PIWIK_USER_PATH', self::$settings->getGlobalOption ( 'piwik_path' ) );
|
688 |
+
define ( 'PIWIK_ENABLE_DISPATCH', false );
|
689 |
+
define ( 'PIWIK_ENABLE_ERROR_HANDLER', false );
|
690 |
+
define ( 'PIWIK_ENABLE_SESSION_START', false );
|
691 |
+
}
|
692 |
+
}
|
693 |
+
|
694 |
+
/**
|
695 |
+
* Start chosen logging method
|
696 |
+
*/
|
697 |
+
private function openLogger() {
|
698 |
+
switch (WP_PIWIK_ACTIVATE_LOGGER) {
|
699 |
+
case 1 :
|
700 |
+
self::$logger = new WP_Piwik\Logger\Screen ( __CLASS__ );
|
701 |
+
break;
|
702 |
+
case 2 :
|
703 |
+
self::$logger = new WP_Piwik\Logger\File ( __CLASS__ );
|
704 |
+
break;
|
705 |
+
default :
|
706 |
+
self::$logger = new WP_Piwik\Logger\Dummy ( __CLASS__ );
|
707 |
+
}
|
708 |
+
}
|
709 |
+
|
710 |
+
/**
|
711 |
+
* Log a message
|
712 |
+
*
|
713 |
+
* @param string $message
|
714 |
+
* logger message
|
715 |
+
*/
|
716 |
+
public static function log($message) {
|
717 |
+
self::$logger->log ( $message );
|
718 |
+
}
|
719 |
+
|
720 |
+
/**
|
721 |
+
* End logging
|
722 |
+
*/
|
723 |
+
private function closeLogger() {
|
724 |
+
self::$logger = null;
|
725 |
+
}
|
726 |
+
|
727 |
+
/**
|
728 |
+
* Load WP-Piwik settings
|
729 |
+
*/
|
730 |
+
private function openSettings() {
|
731 |
+
self::$settings = new WP_Piwik\Settings ( $this, self::$logger );
|
732 |
+
if (! $this->applySettings() && $this->isPHPMode () && ! defined ( 'PIWIK_INCLUDE_PATH' ))
|
733 |
+
self::definePiwikConstants ();
|
734 |
+
}
|
735 |
+
|
736 |
+
/**
|
737 |
+
* Include a WP-Piwik file
|
738 |
+
*/
|
739 |
+
private function includeFile($strFile) {
|
740 |
+
self::$logger->log ( 'Include ' . $strFile . '.php' );
|
741 |
+
if (WP_PIWIK_PATH . $strFile . '.php')
|
742 |
+
include (WP_PIWIK_PATH . $strFile . '.php');
|
743 |
+
}
|
744 |
+
|
745 |
+
/**
|
746 |
+
* Check if user should not be tracked
|
747 |
+
*
|
748 |
+
* @return boolean Do not track user?
|
749 |
+
*/
|
750 |
+
private function isHiddenUser() {
|
751 |
+
if (is_multisite ())
|
752 |
+
foreach ( self::$settings->getGlobalOption ( 'capability_stealth' ) as $key => $val )
|
753 |
+
if ($val && current_user_can ( $key ))
|
754 |
+
return true;
|
755 |
+
return current_user_can ( 'wp-piwik_stealth' );
|
756 |
+
}
|
757 |
+
|
758 |
+
/**
|
759 |
+
* Check if tracking code is up to date
|
760 |
+
*
|
761 |
+
* @return boolean Is tracking code up to date?
|
762 |
+
*/
|
763 |
+
public function isCurrentTrackingCode() {
|
764 |
+
return (self::$settings->getOption ( 'last_tracking_code_update' ) && self::$settings->getOption ( 'last_tracking_code_update' ) > self::$settings->getGlobalOption ( 'last_settings_update' ));
|
765 |
+
}
|
766 |
+
|
767 |
+
/**
|
768 |
+
* DEPRECTAED Add javascript code to site header
|
769 |
+
*
|
770 |
+
* @deprecated
|
771 |
+
*
|
772 |
+
*/
|
773 |
+
public function site_header() {
|
774 |
+
self::$logger->log ( 'Using deprecated function site_header' );
|
775 |
+
$this->addJavascriptCode ();
|
776 |
+
}
|
777 |
+
|
778 |
+
/**
|
779 |
+
* DEPRECTAED Add javascript code to site footer
|
780 |
+
*
|
781 |
+
* @deprecated
|
782 |
+
*
|
783 |
+
*/
|
784 |
+
public function site_footer() {
|
785 |
+
self::$logger->log ( 'Using deprecated function site_footer' );
|
786 |
+
$this->addNoscriptCode ();
|
787 |
+
}
|
788 |
+
|
789 |
+
/**
|
790 |
+
* Identify new posts if an annotation is required
|
791 |
+
*
|
792 |
+
* @param string $newStatus
|
793 |
+
* new post status
|
794 |
+
* @param strint $oldStatus
|
795 |
+
* new post status
|
796 |
+
* @param object $post
|
797 |
+
* current post object
|
798 |
+
*/
|
799 |
+
public function onPostStatusTransition($newStatus, $oldStatus, $post) {
|
800 |
+
if ($newStatus == 'publish' && $oldStatus != 'publish') {
|
801 |
+
add_action ( 'publish_post', array (
|
802 |
+
$this,
|
803 |
+
'addPiwikAnnotation'
|
804 |
+
) );
|
805 |
+
}
|
806 |
+
}
|
807 |
+
|
808 |
+
/**
|
809 |
+
* Get WP-Piwik's URL
|
810 |
+
*/
|
811 |
+
public function getPluginURL() {
|
812 |
+
return trailingslashit ( plugins_url () . '/wp-piwik/' );
|
813 |
+
}
|
814 |
+
|
815 |
+
/**
|
816 |
+
* Get WP-Piwik's version
|
817 |
+
*/
|
818 |
+
public function getPluginVersion() {
|
819 |
+
return self::$strVersion;
|
820 |
+
}
|
821 |
+
|
822 |
+
/**
|
823 |
+
* Enable three columns for WP-Piwik stats screen
|
824 |
+
*
|
825 |
+
* @param
|
826 |
+
* array full list of column settings
|
827 |
+
* @param
|
828 |
+
* mixed current screen id
|
829 |
+
* @return array updated list of column settings
|
830 |
+
*/
|
831 |
+
public function onScreenLayoutColumns($columns, $screen) {
|
832 |
+
if ($screen == $this->statsPageId)
|
833 |
+
$columns [$this->statsPageId] = 3;
|
834 |
+
return $columns;
|
835 |
+
}
|
836 |
+
|
837 |
+
/**
|
838 |
+
* Add tracking code to admin header
|
839 |
+
*/
|
840 |
+
function addAdminHeaderTracking() {
|
841 |
+
$this->addJavascriptCode ();
|
842 |
+
}
|
843 |
+
|
844 |
+
/**
|
845 |
+
* Get option value
|
846 |
+
*
|
847 |
+
* @param string $key
|
848 |
+
* option key
|
849 |
+
* @return mixed option value
|
850 |
+
*/
|
851 |
+
public function getOption($key) {
|
852 |
+
return self::$settings->getOption ( $key );
|
853 |
+
}
|
854 |
+
|
855 |
+
/**
|
856 |
+
* Get stats page URL
|
857 |
+
*
|
858 |
+
* @return string stats page URL
|
859 |
+
*/
|
860 |
+
public function getStatsURL() {
|
861 |
+
return admin_url () . '?page=wp-piwik_stats';
|
862 |
+
}
|
863 |
+
|
864 |
+
/**
|
865 |
+
* Execute WP-Piwik test script
|
866 |
+
*/
|
867 |
+
private function loadTestscript() {
|
868 |
+
$this->includeFile ( 'debug' . DIRECTORY_SEPARATOR . 'testscript' );
|
869 |
+
}
|
870 |
+
|
871 |
+
/**
|
872 |
+
* Echo an error message
|
873 |
+
*
|
874 |
+
* @param string $message
|
875 |
+
* message content
|
876 |
+
*/
|
877 |
+
private static function showErrorMessage($message) {
|
878 |
+
echo '<strong class="wp-piwik-error">' . __ ( 'An error occured', 'wp-piwik' ) . ':</strong> ' . $message . ' [<a href="' . (self::$settings->checkNetworkActivation () ? 'network/settings' : 'options-general') . '.php?page=wp-piwik/classes/WP_Piwik.php&tab=support">' . __ ( 'Support', 'wp-piwik' ) . '</a>]';
|
879 |
+
}
|
880 |
+
|
881 |
+
/**
|
882 |
+
* Perform a Piwik request
|
883 |
+
*
|
884 |
+
* @param string $id
|
885 |
+
* request ID
|
886 |
+
* @return mixed request result
|
887 |
+
*/
|
888 |
+
public function request($id) {
|
889 |
+
if (! isset ( self::$request ))
|
890 |
+
self::$request = (self::$settings->getGlobalOption ( 'piwik_mode' ) == 'http' || self::$settings->getGlobalOption ( 'piwik_mode' ) == 'pro' ? new WP_Piwik\Request\Rest ( $this, self::$settings ) : new WP_Piwik\Request\Php ( $this, self::$settings ));
|
891 |
+
return self::$request->perform ( $id );
|
892 |
+
}
|
893 |
+
|
894 |
+
/**
|
895 |
+
* Execute WP-Piwik shortcode
|
896 |
+
*
|
897 |
+
* @param array $attributes
|
898 |
+
* attribute list
|
899 |
+
*/
|
900 |
+
public function shortcode($attributes) {
|
901 |
+
shortcode_atts ( array (
|
902 |
+
'title' => '',
|
903 |
+
'module' => 'overview',
|
904 |
+
'period' => 'day',
|
905 |
+
'date' => 'yesterday',
|
906 |
+
'limit' => 10,
|
907 |
+
'width' => '100%',
|
908 |
+
'height' => '200px',
|
909 |
+
'language' => 'en',
|
910 |
+
'range' => false,
|
911 |
+
'key' => 'sum_daily_nb_uniq_visitors'
|
912 |
+
), $attributes );
|
913 |
+
new \WP_Piwik\Shortcode ( $attributes, $this, self::$settings );
|
914 |
+
}
|
915 |
+
|
916 |
+
/**
|
917 |
+
* Get Piwik site ID by blog ID
|
918 |
+
*
|
919 |
+
* @param int $blogId
|
920 |
+
* which blog's Piwik site ID to get, default is the current blog
|
921 |
+
* @return mixed Piwik site ID or n/a
|
922 |
+
*/
|
923 |
+
public function getPiwikSiteId($blogId = null) {
|
924 |
+
if ( !$blogId && $this->isNetworkMode() )
|
925 |
+
$blogId = get_current_blog_id();
|
926 |
+
$result = self::$settings->getOption ( 'site_id', $blogId );
|
927 |
+
return (! empty ( $result ) ? $result : $this->requestPiwikSiteId ( $blogId ));
|
928 |
+
}
|
929 |
+
|
930 |
+
/**
|
931 |
+
* Get a detailed list of all Piwik sites
|
932 |
+
*
|
933 |
+
* @return array Piwik sites
|
934 |
+
*/
|
935 |
+
public function getPiwikSiteDetails() {
|
936 |
+
$id = WP_Piwik\Request::register ( 'SitesManager.getAllSites', array () );
|
937 |
+
$piwikSiteDetails = $this->request ( $id );
|
938 |
+
return $piwikSiteDetails;
|
939 |
+
}
|
940 |
+
|
941 |
+
/**
|
942 |
+
* Estimate a Piwik site ID by blog ID
|
943 |
+
*
|
944 |
+
* @param int $blogId
|
945 |
+
* which blog's Piwik site ID to estimate, default is the current blog
|
946 |
+
* @return mixed Piwik site ID or n/a
|
947 |
+
*/
|
948 |
+
private function requestPiwikSiteId($blogId = null) {
|
949 |
+
$isCurrent = ! self::$settings->checkNetworkActivation () || empty ( $blogId );
|
950 |
+
if (self::$settings->getGlobalOption ( 'auto_site_config' )) {
|
951 |
+
$id = WP_Piwik\Request::register ( 'SitesManager.getSitesIdFromSiteUrl', array (
|
952 |
+
'url' => $isCurrent ? get_bloginfo ( 'url' ) : get_blog_details ( $blogId )->siteurl
|
953 |
+
) );
|
954 |
+
$result = $this->request ( $id );
|
955 |
+
$this->log( 'Tried to identify current site, result: '.serialize( $result ) );
|
956 |
+
if (empty ( $result ) || ! isset ( $result [0] ))
|
957 |
+
$result = $this->addPiwikSite( $blogId );
|
958 |
+
else
|
959 |
+
$result = $result [0] ['idsite'];
|
960 |
+
} else
|
961 |
+
$result = null;
|
962 |
+
self::$logger->log ( 'Get Piwik ID: WordPress site ' . ($isCurrent ? get_bloginfo ( 'url' ) : get_blog_details ( $blogId )->siteurl) . ' = Piwik ID ' . $result );
|
963 |
+
if ($result !== null) {
|
964 |
+
self::$settings->setOption ( 'site_id', $result, $blogId );
|
965 |
+
if (self::$settings->getGlobalOption ( 'track_mode' ) != 'disabled' && self::$settings->getGlobalOption ( 'track_mode' ) != 'manually') {
|
966 |
+
$code = $this->updateTrackingCode ( $result, $blogId );
|
967 |
+
self::$settings->setOption ( 'tracking_code', $code ['script'], $blogId );
|
968 |
+
self::$settings->setOption ( 'noscript_code', $code ['noscript'], $blogId );
|
969 |
+
}
|
970 |
+
$this::$settings->save ();
|
971 |
+
return $result;
|
972 |
+
}
|
973 |
+
return 'n/a';
|
974 |
+
}
|
975 |
+
|
976 |
+
/**
|
977 |
+
* Add a new Piwik
|
978 |
+
*
|
979 |
+
* @param int $blogId
|
980 |
+
* which blog's Piwik site to create, default is the current blog
|
981 |
+
* @return int Piwik site ID
|
982 |
+
*/
|
983 |
+
public function addPiwikSite($blogId = null) {
|
984 |
+
$isCurrent = ! self::$settings->checkNetworkActivation () || empty ( $blogId );
|
985 |
+
// Do not add site if Piwik connection is unreliable
|
986 |
+
if (!$this->request ( 'global.getPiwikVersion' ))
|
987 |
+
return null;
|
988 |
+
$id = WP_Piwik\Request::register ( 'SitesManager.addSite', array (
|
989 |
+
'urls' => $isCurrent ? get_bloginfo ( 'url' ) : get_blog_details ( $blogId )->siteurl,
|
990 |
+
'siteName' => $isCurrent ? get_bloginfo ( 'name' ) : get_blog_details ( $blogId )->blogname
|
991 |
+
) );
|
992 |
+
$result = $this->request ( $id );
|
993 |
+
self::$logger->log ( 'Get Piwik ID: WordPress site ' . ($isCurrent ? get_bloginfo ( 'url' ) : get_blog_details ( $blogId )->siteurl) . ' = Piwik ID ' . (int) $result );
|
994 |
+
if (empty ( $result ) || ! isset ( $result [0] ))
|
995 |
+
return null;
|
996 |
+
else
|
997 |
+
return $result [0] ['idsite'];
|
998 |
+
}
|
999 |
+
|
1000 |
+
/**
|
1001 |
+
* Update a Piwik site's detail information
|
1002 |
+
*
|
1003 |
+
* @param int $siteId
|
1004 |
+
* which Piwik site to updated
|
1005 |
+
* @param int $blogId
|
1006 |
+
* which blog's Piwik site ID to get, default is the current blog
|
1007 |
+
*/
|
1008 |
+
private function updatePiwikSite($siteId, $blogId = null) {
|
1009 |
+
$isCurrent = ! self::$settings->checkNetworkActivation () || empty ( $blogId );
|
1010 |
+
$id = WP_Piwik\Request::register ( 'SitesManager.updateSite', array (
|
1011 |
+
'idSite' => $siteId,
|
1012 |
+
'urls' => $isCurrent ? get_bloginfo ( 'url' ) : get_blog_details ( $blogId )->$siteurl,
|
1013 |
+
'siteName' => $isCurrent ? get_bloginfo ( 'name' ) : get_blog_details ( $blogId )->$blogname
|
1014 |
+
) );
|
1015 |
+
$result = $this->request ( $id );
|
1016 |
+
self::$logger->log ( 'Update Piwik site: WordPress site ' . ($isCurrent ? get_bloginfo ( 'url' ) : get_blog_details ( $blogId )->$siteurl) );
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
/**
|
1020 |
+
* Update a site's tracking code
|
1021 |
+
*
|
1022 |
+
* @param int $siteId
|
1023 |
+
* which Piwik site to updated
|
1024 |
+
* @param int $blogId
|
1025 |
+
* which blog's Piwik site ID to get, default is the current blog
|
1026 |
+
* @return string tracking code
|
1027 |
+
*/
|
1028 |
+
public function updateTrackingCode($siteId = false, $blogId = null) {
|
1029 |
+
if (! $siteId)
|
1030 |
+
$siteId = $this->getPiwikSiteId ();
|
1031 |
+
$id = WP_Piwik\Request::register ( 'SitesManager.getJavascriptTag', array (
|
1032 |
+
'idSite' => $siteId,
|
1033 |
+
'mergeSubdomains' => self::$settings->getGlobalOption ( 'track_across' ) ? 1 : 0,
|
1034 |
+
'mergeAliasUrls' => self::$settings->getGlobalOption ( 'track_across_alias' ) ? 1 : 0,
|
1035 |
+
'disableCookies' => self::$settings->getGlobalOption ( 'disable_cookies' ) ? 1 : 0
|
1036 |
+
) );
|
1037 |
+
$result = html_entity_decode ( $this->request ( $id ) );
|
1038 |
+
self::$logger->log ( 'Delivered tracking code: ' . $result );
|
1039 |
+
$result = WP_Piwik\TrackingCode::prepareTrackingCode ( $result, self::$settings, self::$logger );
|
1040 |
+
return $result;
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
/**
|
1044 |
+
* Update Piwik site if blog name changes
|
1045 |
+
*
|
1046 |
+
* @param string $oldValue
|
1047 |
+
* old blog name
|
1048 |
+
* @param string $newValue
|
1049 |
+
* new blog name
|
1050 |
+
*/
|
1051 |
+
public function onBlogNameChange($oldValue, $newValue) {
|
1052 |
+
$this->updatePiwikSite ( self::$settings->getOption ( 'site_id' ) );
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
/**
|
1056 |
+
* Update Piwik site if blog URL changes
|
1057 |
+
*
|
1058 |
+
* @param string $oldValue
|
1059 |
+
* old blog URL
|
1060 |
+
* @param string $newValue
|
1061 |
+
* new blog URL
|
1062 |
+
*/
|
1063 |
+
public function onSiteUrlChange($oldValue, $newValue) {
|
1064 |
+
$this->updatePiwikSite ( self::$settings->getOption ( 'site_id' ) );
|
1065 |
+
}
|
1066 |
+
|
1067 |
+
/**
|
1068 |
+
* Register stats page meta boxes
|
1069 |
+
*
|
1070 |
+
* @param mixed $statsPageId
|
1071 |
+
* WordPress stats page ID
|
1072 |
+
*/
|
1073 |
+
public function onloadStatsPage($statsPageId) {
|
1074 |
+
if (self::$settings->getGlobalOption ( 'disable_timelimit' ))
|
1075 |
+
set_time_limit ( 0 );
|
1076 |
+
wp_enqueue_script ( 'common' );
|
1077 |
+
wp_enqueue_script ( 'wp-lists' );
|
1078 |
+
wp_enqueue_script ( 'postbox' );
|
1079 |
+
wp_enqueue_script ( 'wp-piwik', $this->getPluginURL () . 'js/wp-piwik.js', array (), self::$strVersion, true );
|
1080 |
+
wp_enqueue_script ( 'wp-piwik-jqplot', $this->getPluginURL () . 'js/jqplot/wp-piwik.jqplot.js', array (
|
1081 |
+
'jquery'
|
1082 |
+
), self::$strVersion );
|
1083 |
+
new \WP_Piwik\Widget\Chart ( $this, self::$settings, $this->statsPageId );
|
1084 |
+
new \WP_Piwik\Widget\Visitors ( $this, self::$settings, $this->statsPageId );
|
1085 |
+
new \WP_Piwik\Widget\Overview ( $this, self::$settings, $this->statsPageId );
|
1086 |
+
if (self::$settings->getGlobalOption ( 'stats_seo' ))
|
1087 |
+
new \WP_Piwik\Widget\Seo ( $this, self::$settings, $this->statsPageId );
|
1088 |
+
new \WP_Piwik\Widget\Pages ( $this, self::$settings, $this->statsPageId );
|
1089 |
+
new \WP_Piwik\Widget\Keywords ( $this, self::$settings, $this->statsPageId );
|
1090 |
+
new \WP_Piwik\Widget\Referrers ( $this, self::$settings, $this->statsPageId );
|
1091 |
+
new \WP_Piwik\Widget\Plugins ( $this, self::$settings, $this->statsPageId );
|
1092 |
+
new \WP_Piwik\Widget\Search ( $this, self::$settings, $this->statsPageId );
|
1093 |
+
new \WP_Piwik\Widget\Noresult ( $this, self::$settings, $this->statsPageId );
|
1094 |
+
new \WP_Piwik\Widget\Browsers ( $this, self::$settings, $this->statsPageId );
|
1095 |
+
new \WP_Piwik\Widget\BrowserDetails ( $this, self::$settings, $this->statsPageId );
|
1096 |
+
new \WP_Piwik\Widget\Screens ( $this, self::$settings, $this->statsPageId );
|
1097 |
+
new \WP_Piwik\Widget\Systems ( $this, self::$settings, $this->statsPageId );
|
1098 |
+
}
|
1099 |
+
|
1100 |
+
/**
|
1101 |
+
* Add per post statistics to a post's page
|
1102 |
+
*
|
1103 |
+
* @param mixed $postPageId
|
1104 |
+
* WordPress post page ID
|
1105 |
+
*/
|
1106 |
+
public function onloadPostPage($postPageId) {
|
1107 |
+
global $post;
|
1108 |
+
$postUrl = get_permalink ( $post->ID );
|
1109 |
+
$this->log ( 'Load per post statistics: ' . $postUrl );
|
1110 |
+
array (
|
1111 |
+
new \WP_Piwik\Widget\Post ( $this, self::$settings, 'post', 'side', 'default', array (
|
1112 |
+
'url' => $postUrl
|
1113 |
+
) ),
|
1114 |
+
'show'
|
1115 |
+
);
|
1116 |
+
}
|
1117 |
+
|
1118 |
+
/**
|
1119 |
+
* Stats page changes by POST submit
|
1120 |
+
*
|
1121 |
+
* @see http://tinyurl.com/5r5vnzs
|
1122 |
+
*/
|
1123 |
+
function onStatsPageSaveChanges() {
|
1124 |
+
if (! current_user_can ( 'manage_options' ))
|
1125 |
+
wp_die ( __ ( 'Cheatin’ uh?' ) );
|
1126 |
+
check_admin_referer ( 'wp-piwik_stats' );
|
1127 |
+
wp_redirect ( $_POST ['_wp_http_referer'] );
|
1128 |
+
}
|
1129 |
}
|
classes/WP_Piwik/Admin/Settings.php
CHANGED
@@ -1,354 +1,567 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
)
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WP_Piwik\Admin;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* WordPress Admin settings page
|
7 |
+
*
|
8 |
+
* @package WP_Piwik\Admin
|
9 |
+
* @author André Bräkling <webmaster@braekling.de>
|
10 |
+
*/
|
11 |
+
class Settings extends \WP_Piwik\Admin {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Builds and displays the settings page
|
15 |
+
*/
|
16 |
+
public function show() {
|
17 |
+
global $wp_roles;
|
18 |
+
if (isset ( $_POST ) && isset ( $_POST ['wp-piwik'] ))
|
19 |
+
$this->showBox ( 'updated', 'yes', __ ( 'Changes saved.' ) );
|
20 |
+
?>
|
21 |
+
<div id="plugin-options-wrap" class="widefat">
|
22 |
+
<?php echo $this->getHeadline ( 1, 'admin-generic', 'Settings', true ); ?>
|
23 |
+
<form method="post">
|
24 |
+
<input type="hidden" name="wp-piwik[revision]" value="<?php echo self::$settings->getGlobalOption('revision'); ?>" />
|
25 |
+
<?php wp_nonce_field('wp-piwik_settings'); ?>
|
26 |
+
<table class="wp-piwik-form">
|
27 |
+
<tbody>
|
28 |
+
<?php
|
29 |
+
$submitButton = '<tr><td colspan="2"><p class="submit"><input name="Submit" type="submit" class="button-primary" value="' . esc_attr__ ( 'Save Changes' ) . '" /></p></td></tr>';
|
30 |
+
printf ( '<tr><td colspan="2">%s</td></tr>', __ ( 'Thanks for using WP-Piwik!', 'wp-piwik' ) );
|
31 |
+
// $this->showDonation();
|
32 |
+
if (self::$wpPiwik->isConfigured ()) {
|
33 |
+
$piwikVersion = self::$wpPiwik->request ( 'global.getPiwikVersion' );
|
34 |
+
if (! empty ( $piwikVersion ) && ! is_array ( $piwikVersion ))
|
35 |
+
$this->showText ( sprintf ( __ ( 'WP-Piwik %s is successfully connected to Piwik %s.', 'wp-piwik' ), self::$wpPiwik->getPluginVersion (), $piwikVersion ) . ' ' . (! self::$wpPiwik->isNetworkMode () ? sprintf ( __ ( 'You are running WordPress %s.', 'wp-piwik' ), get_bloginfo ( 'version' ) ) : sprintf ( __ ( 'You are running a WordPress %s blog network (WPMU). WP-Piwik will handle your sites as different websites.', 'wp-piwik' ), get_bloginfo ( 'version' ) )) );
|
36 |
+
else {
|
37 |
+
$this->showBox ( 'error', 'no', sprintf ( __ ( 'WP-Piwik %s was not able to connect to Piwik using your configuration. Check the »Connect to Piwik« section below.', 'wp-piwik' ), self::$wpPiwik->getPluginVersion () ) );
|
38 |
+
}
|
39 |
+
} else
|
40 |
+
$this->showBox ( 'error', 'no', sprintf ( __ ( 'WP-Piwik %s has to be connected to Piwik first. Check the »Connect to Piwik« section below.', 'wp-piwik' ), self::$wpPiwik->getPluginVersion () ) );
|
41 |
+
|
42 |
+
$tabs ['connect'] = array (
|
43 |
+
'icon' => 'admin-plugins',
|
44 |
+
'name' => 'Connect to Piwik'
|
45 |
+
);
|
46 |
+
if (self::$wpPiwik->isConfigured ()) {
|
47 |
+
$tabs ['statistics'] = array (
|
48 |
+
'icon' => 'chart-pie',
|
49 |
+
'name' => 'Show Statistics'
|
50 |
+
);
|
51 |
+
$tabs ['tracking'] = array (
|
52 |
+
'icon' => 'location-alt',
|
53 |
+
'name' => 'Enable Tracking'
|
54 |
+
);
|
55 |
+
}
|
56 |
+
$tabs ['expert'] = array (
|
57 |
+
'icon' => 'shield',
|
58 |
+
'name' => 'Expert Settings'
|
59 |
+
);
|
60 |
+
$tabs ['support'] = array (
|
61 |
+
'icon' => 'lightbulb',
|
62 |
+
'name' => 'Support'
|
63 |
+
);
|
64 |
+
$tabs ['credits'] = array (
|
65 |
+
'icon' => 'groups',
|
66 |
+
'name' => 'Credits'
|
67 |
+
);
|
68 |
+
|
69 |
+
echo '<tr><td colspan="2"><h2 class="nav-tab-wrapper">';
|
70 |
+
foreach ( $tabs as $tab => $details ) {
|
71 |
+
$class = ($tab == 'connect') ? ' nav-tab-active' : '';
|
72 |
+
echo '<a style="cursor:pointer;" id="tab-' . $tab . '" class="nav-tab' . $class . '" onclick="javascript:$j(\'table.wp-piwik_menu-tab\').addClass(\'hidden\');$j(\'#' . $tab . '\').removeClass(\'hidden\');$j(\'a.nav-tab\').removeClass(\'nav-tab-active\');$j(\'#tab-' . $tab . '\').addClass(\'nav-tab-active\');">';
|
73 |
+
$this->showHeadline ( 0, $details ['icon'], $details ['name'] );
|
74 |
+
echo "</a>";
|
75 |
+
}
|
76 |
+
echo '</h2></td></tr></tbody></table><table id="connect" class="wp-piwik_menu-tab"><tbody>';
|
77 |
+
|
78 |
+
if (! self::$wpPiwik->isConfigured ())
|
79 |
+
$this->showBox ( 'updated', 'info', sprintf ( '%s <a href="%s">%s</a> %s <a href="%s">%s</a>.', __ ( 'WP-Piwik is a WordPress plugin to show a selection of Piwik stats in your WordPress admin dashboard and to add and configure your Piwik tracking code. To use this you will need your own Piwik instance. If you do not already have a Piwik setup, you have two simple options: use either', 'wp-piwik' ), 'http://piwik.org/', __ ( 'Self-hosted', 'wp-piwik' ), __ ( 'or', 'wp-piwik' ), 'http://piwik.org/hosting/', __ ( 'Cloud-hosted', 'wp-piwik' ) ) );
|
80 |
+
|
81 |
+
if (! function_exists ( 'curl_init' ) && ! ini_get ( 'allow_url_fopen' ))
|
82 |
+
$this->showBox ( 'error', 'no', __ ( 'Neither cURL nor fopen are available. So WP-Piwik can not use the HTTP API and not connect to Piwik Pro.' ) . ' ' . sprintf ( '<a href="%s">%s.</a>', 'https://wordpress.org/plugins/wp-piwik/faq/', __ ( 'More information', 'wp-piwik' ) ) );
|
83 |
+
|
84 |
+
$description = sprintf ( '%s<br /><strong>%s:</strong> %s<br /><strong>%s:</strong> %s<br /><strong>%s:</strong> %s', __ ( 'You can choose between three connection methods:', 'wp-piwik' ), __ ( 'Self-hosted (HTTP API, default)', 'wp-piwik' ), __ ( 'This is the default option for a self-hosted Piwik and should work for most configurations. WP-Piwik will connect to Piwk using http(s).', 'wp-piwik' ), __ ( 'Self-hosted (PHP API)', 'wp-piwik' ), __ ( 'Choose this, if your self-hosted Piwik and WordPress are running on the same machine and you know the full server path to your Piwik instance.', 'wp-piwik' ), __ ( 'Cloud-hosted (Piwik Pro)', 'wp-piwik' ), __ ( 'If you are using a cloud-hosted Piwik by Piwik Pro, you can simply use this option.', 'wp-piwik' ) );
|
85 |
+
$this->showSelect ( 'piwik_mode', __ ( 'Piwik Mode', 'wp-piwik' ), array (
|
86 |
+
'disabled' => __ ( 'Disabled (WP-Piwik will not connect to Piwik)', 'wp-piwik' ),
|
87 |
+
'http' => __ ( 'Self-hosted (HTTP API, default)', 'wp-piwik' ),
|
88 |
+
'php' => __ ( 'Self-hosted (PHP API)', 'wp-piwik' ),
|
89 |
+
'pro' => __ ( 'Cloud-hosted (Piwik Pro)', 'wp-piwik' )
|
90 |
+
), $description, '$j(\'tr.wp-piwik-mode-option\').addClass(\'hidden\'); $j(\'#wp-piwik-mode-option-\' + $j(\'#piwik_mode\').val()).removeClass(\'hidden\');', false, '', self::$wpPiwik->isConfigured () );
|
91 |
+
|
92 |
+
$this->showInput ( 'piwik_url', __ ( 'Piwik URL', 'wp-piwik' ), 'TODO URL description', self::$settings->getGlobalOption ( 'piwik_mode' ) != 'http', 'wp-piwik-mode-option', 'http', self::$wpPiwik->isConfigured () );
|
93 |
+
$this->showInput ( 'piwik_path', __ ( 'Piwik path', 'wp-piwik' ), 'TODO Path description', self::$settings->getGlobalOption ( 'piwik_mode' ) != 'php', 'wp-piwik-mode-option', 'php', self::$wpPiwik->isConfigured () );
|
94 |
+
$this->showInput ( 'piwik_user', __ ( 'Piwik user', 'wp-piwik' ), 'TODO User description', self::$settings->getGlobalOption ( 'piwik_mode' ) != 'pro', 'wp-piwik-mode-option', 'pro', self::$wpPiwik->isConfigured () );
|
95 |
+
$this->showInput ( 'piwik_token', __ ( 'Auth token', 'wp-piwik' ), 'TODO Token description', false, '', '', self::$wpPiwik->isConfigured () );
|
96 |
+
|
97 |
+
// Site configuration
|
98 |
+
$piwikSiteId = self::$wpPiwik->isConfigured () ? self::$wpPiwik->getPiwikSiteId () : false;
|
99 |
+
$this->showCheckbox ( 'auto_site_config', __ ( 'Auto config', 'wp-piwik' ), __ ( 'Check this to automatically choose your blog from your Piwik sites by URL. If your blog is not added to Piwik yet, WP-Piwik will add a new site.', 'wp-piwik' ), false, '$j(\'tr.wp-piwik-auto-option\').toggle(\'hidden\');' . ($piwikSiteId ? '$j(\'#site_id\').val(' . $piwikSiteId . ');' : '') );
|
100 |
+
if (self::$wpPiwik->isConfigured ()) {
|
101 |
+
$piwikSiteDetails = self::$wpPiwik->getPiwikSiteDetails ();
|
102 |
+
if (($piwikSiteId == 'n/a'))
|
103 |
+
$piwikSiteDescription = 'n/a';
|
104 |
+
elseif (! self::$settings->getGlobalOption ( 'auto_site_config' ))
|
105 |
+
$piwikSiteDescription = __ ( 'Save settings to start estimation.', 'wp-piwik' );
|
106 |
+
else
|
107 |
+
$piwikSiteDescription = $piwikSiteDetails [$piwikSiteId] ['name'] . ' (' . $piwikSiteDetails [$piwikSiteId] ['main_url'] . ')';
|
108 |
+
echo '<tr class="wp-piwik-auto-option' . (! self::$settings->getGlobalOption ( 'auto_site_config' ) ? ' hidden' : '') . '"><th scope="row">' . __ ( 'Determined site', 'wp-piwik' ) . ':</th><td>' . $piwikSiteDescription . '</td></tr>';
|
109 |
+
if (is_array ( $piwikSiteDetails ))
|
110 |
+
foreach ( $piwikSiteDetails as $key => $siteData )
|
111 |
+
$siteList [$key] = $siteData ['name'] . ' (' . $siteData ['main_url'] . ')';
|
112 |
+
if (isset($siteList))
|
113 |
+
$this->showSelect ( 'site_id', __ ( 'Select site', 'wp-piwik' ), $siteList, 'TODO Choose description', '', self::$settings->getGlobalOption ( 'auto_site_config' ), 'wp-piwik-auto-option', true, false );
|
114 |
+
// else $this->showBox('error', 'no', __('Piwik did not deliver a site list. Is at least one site configured?', 'wp-piwik'));
|
115 |
+
}
|
116 |
+
|
117 |
+
echo $submitButton;
|
118 |
+
|
119 |
+
echo '</tbody></table><table id="statistics" class="wp-piwik_menu-tab hidden"><tbody>';
|
120 |
+
// Stats configuration
|
121 |
+
$this->showSelect ( 'default_date', __ ( 'Piwik default date', 'wp-piwik' ), array (
|
122 |
+
'today' => __ ( 'Today', 'wp-piwik' ),
|
123 |
+
'yesterday' => __ ( 'Yesterday', 'wp-piwik' ),
|
124 |
+
'current_month' => __ ( 'Current month', 'wp-piwik' ),
|
125 |
+
'last_month' => __ ( 'Last month', 'wp-piwik' ),
|
126 |
+
'current_week' => __ ( 'Current week', 'wp-piwik' ),
|
127 |
+
'last_week' => __ ( 'Last week', 'wp-piwik' )
|
128 |
+
), __ ( 'Default date shown on statistics page.', 'wp-piwik' ) );
|
129 |
+
|
130 |
+
$this->showCheckbox ( 'stats_seo', __ ( 'Show SEO data', 'wp-piwik' ), __ ( 'Display SEO ranking data on statistics page.', 'wp-piwik' ) . ' (' . __ ( 'Slow!', 'wp-piwik' ) . ')' );
|
131 |
+
|
132 |
+
$this->showSelect ( 'dashboard_widget', __ ( 'Dashboard overview', 'wp-piwik' ), array (
|
133 |
+
'disabled' => __ ( 'Disabled', 'wp-piwik' ),
|
134 |
+
'yesterday' => __ ( 'Yesterday', 'wp-piwik' ),
|
135 |
+
'today' => __ ( 'Today', 'wp-piwik' ),
|
136 |
+
'last30' => __ ( 'Last 30 days', 'wp-piwik' )
|
137 |
+
), __ ( 'Enable WP-Piwik dashboard widget "Overview".', 'wp-piwik' ) );
|
138 |
+
|
139 |
+
$this->showCheckbox ( 'dashboard_chart', __ ( 'Dashboard graph', 'wp-piwik' ), __ ( 'Enable WP-Piwik dashboard widget "Graph".', 'wp-piwik' ) );
|
140 |
+
|
141 |
+
$this->showCheckbox ( 'dashboard_seo', __ ( 'Dashboard SEO', 'wp-piwik' ), __ ( 'Enable WP-Piwik dashboard widget "SEO".', 'wp-piwik' ) . ' (' . __ ( 'Slow!', 'wp-piwik' ) . ')' );
|
142 |
+
|
143 |
+
$this->showCheckbox ( 'toolbar', __ ( 'Show graph on WordPress Toolbar', 'wp-piwik' ), __ ( 'Display a last 30 days visitor graph on WordPress\' toolbar.', 'wp-piwik' ) );
|
144 |
+
|
145 |
+
echo '<tr><th scope="row"><label for="capability_read_stats">' . __ ( 'Display stats to', 'wp-piwik' ) . '</label>:</th><td>';
|
146 |
+
$filter = self::$settings->getGlobalOption ( 'capability_read_stats' );
|
147 |
+
foreach ( $wp_roles->role_names as $key => $name ) {
|
148 |
+
echo '<input type="checkbox" ' . (isset ( $filter [$key] ) && $filter [$key] ? 'checked="checked" ' : '') . 'value="1" onchange="$j(\'#capability_read_stats-' . $key . '-input\').val(this.checked?1:0);" />';
|
149 |
+
echo '<input id="capability_read_stats-' . $key . '-input" type="hidden" name="wp-piwik[capability_read_stats][' . $key . ']" value="' . ( int ) (isset ( $filter [$key] ) && $filter [$key]) . '" />';
|
150 |
+
echo $name . ' ';
|
151 |
+
}
|
152 |
+
echo '<span class="dashicons dashicons-editor-help" onclick="$j(\'#capability_read_stats-desc\').toggleClass(\'hidden\');"></span> <p class="description hidden" id="capability_read_stats-desc">' . __ ( 'Choose user roles allowed to see the statistics page.', 'wp-piwik' ) . '</p></td></tr>';
|
153 |
+
|
154 |
+
$this->showCheckbox ( 'perpost_stats', __ ( 'Show per post stats', 'wp-piwik' ), __ ( 'Show stats about single posts at the post edit admin page.', 'wp-piwik' ) );
|
155 |
+
|
156 |
+
$this->showCheckbox ( 'piwik_shortcut', __ ( 'Piwik shortcut', 'wp-piwik' ), __ ( 'Display a shortcut to Piwik itself.', 'wp-piwik' ) );
|
157 |
+
|
158 |
+
$this->showInput ( 'plugin_display_name', __ ( 'WP-Piwik display name', 'wp-piwik' ), __ ( 'Plugin name shown in WordPress.', 'wp-piwik' ) );
|
159 |
+
|
160 |
+
$this->showCheckbox ( 'shortcodes', __ ( 'Enable shortcodes', 'wp-piwik' ), __ ( 'Enable shortcodes in post or page content.', 'wp-piwik' ) );
|
161 |
+
|
162 |
+
echo $submitButton;
|
163 |
+
|
164 |
+
echo '</tbody></table><table id="tracking" class="wp-piwik_menu-tab hidden"><tbody>';
|
165 |
+
|
166 |
+
// Tracking Configuration
|
167 |
+
$isNotTracking = self::$settings->getGlobalOption ( 'track_mode' ) == 'disabled';
|
168 |
+
$isNotGeneratedTracking = $isNotTracking || self::$settings->getGlobalOption ( 'track_mode' ) == 'manually';
|
169 |
+
$fullGeneratedTrackingGroup = 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js wp-piwik-track-option-proxy';
|
170 |
+
|
171 |
+
$description = sprintf ( '%s<br /><strong>%s:</strong> %s<br /><strong>%s:</strong> %s<br /><strong>%s:</strong> %s<br /><strong>%s:</strong> %s<br /><strong>%s:</strong> %s', __ ( 'You can choose between four tracking code modes:', 'wp-piwik' ), __ ( 'Disabled', 'wp-piwik' ), __ ( 'WP-Piwik will not add the tracking code. Use this, if you want to add the tracking code to your template files or you use another plugin to add the tracking code.', 'wp-piwik' ), __ ( 'Default tracking', 'wp-piwik' ), __ ( 'TODO', 'wp-piwik' ), __ ( 'Use js/index.php', 'wp-piwik' ), __ ( 'TODO', 'wp-piwik' ), __ ( 'Use proxy script', 'wp-piwik' ), __ ( 'TODO', 'wp-piwik' ), __ ( 'Enter manually', 'wp-piwik' ), __ ( 'TODO', 'wp-piwik' ) );
|
172 |
+
$this->showSelect ( 'track_mode', __ ( 'Add tracking code', 'wp-piwik' ), array (
|
173 |
+
'disabled' => __ ( 'Disabled', 'wp-piwik' ),
|
174 |
+
'default' => __ ( 'Default tracking', 'wp-piwik' ),
|
175 |
+
'js' => __ ( 'Use js/index.php', 'wp-piwik' ),
|
176 |
+
'proxy' => __ ( 'Use proxy script', 'wp-piwik' ),
|
177 |
+
'manually' => __ ( 'Enter manually', 'wp-piwik' )
|
178 |
+
), $description, '$j(\'tr.wp-piwik-track-option\').addClass(\'hidden\'); $j(\'tr.wp-piwik-track-option-\' + $j(\'#track_mode\').val()).removeClass(\'hidden\'); $j(\'#tracking_code, #noscript_code\').prop(\'readonly\', $j(\'#track_mode\').val() != \'manually\');' );
|
179 |
+
|
180 |
+
$this->showTextarea ( 'tracking_code', __ ( 'Tracking code', 'wp-piwik' ), 15, 'TODO tracking code desc', $isNotTracking, 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js wp-piwik-track-option-proxy wp-piwik-track-option-manually', true, '', (self::$settings->getGlobalOption ( 'track_mode' ) != 'manually'), false );
|
181 |
+
|
182 |
+
$this->showSelect ( 'track_codeposition', __ ( 'JavaScript code position', 'wp-piwik' ), array (
|
183 |
+
'footer' => __ ( 'Footer', 'wp-piwik' ),
|
184 |
+
'header' => __ ( 'Header', 'wp-piwik' )
|
185 |
+
), __ ( 'Choose whether the JavaScript code is added to the footer or the header.', 'wp-piwik' ), '', $isNotTracking, 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js wp-piwik-track-option-proxy wp-piwik-track-option-manually' );
|
186 |
+
|
187 |
+
$this->showTextarea ( 'noscript_code', __ ( 'Noscript code', 'wp-piwik' ), 2, 'TODO noscript code desc', $isNotTracking, 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js wp-piwik-track-option-proxy wp-piwik-track-option-manually', true, '', (self::$settings->getGlobalOption ( 'track_mode' ) != 'manually'), false );
|
188 |
+
|
189 |
+
$this->showCheckbox ( 'track_noscript', __ ( 'Add <noscript>', 'wp-piwik' ), __ ( 'Adds the <noscript> code to your footer.', 'wp-piwik' ) . ' ' . __ ( 'Disabled in proxy mode.', 'wp-piwik' ), $isNotGeneratedTracking || self::$settings->getGlobalOption ( 'track_mode' ) == 'proxy', 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js wp-piwik-track-option-manually' );
|
190 |
+
|
191 |
+
$this->showCheckbox ( 'track_nojavascript', __ ( 'Add rec parameter to noscript code', 'wp-piwik' ), __ ( 'Enable tracking for visitors without JavaScript (not recommended).', 'wp-piwik' ) . ' ' . sprintf ( __ ( 'See %sPiwik FAQ%s.', 'wp-piwik' ), '<a href="http://piwik.org/faq/how-to/#faq_176">', '</a>' ) . ' ' . __ ( 'Disabled in proxy mode.', 'wp-piwik' ), $isNotGeneratedTracking || self::$settings->getGlobalOption ( 'track_mode' ) == 'proxy', 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js' );
|
192 |
+
|
193 |
+
$this->showCheckbox ( 'track_search', __ ( 'Track search', 'wp-piwik' ), __ ( 'Use Piwik\'s advanced Site Search Analytics feature.' ) . ' ' . sprintf ( __ ( 'See %sPiwik documentation%s.', 'wp-piwik' ), '<a href="http://piwik.org/docs/site-search/#track-site-search-using-the-tracking-api-advanced-users-only">', '</a>' ), $isNotTracking, $fullGeneratedTrackingGroup . ' wp-piwik-track-option-manually' );
|
194 |
+
|
195 |
+
$this->showCheckbox ( 'track_404', __ ( 'Track 404', 'wp-piwik' ), __ ( 'WP-Piwik can automatically add a 404-category to track 404-page-visits.', 'wp-piwik' ), $isNotTracking, $fullGeneratedTrackingGroup . ' wp-piwik-track-option-manually' );
|
196 |
+
|
197 |
+
$this->showCheckbox ( 'add_post_annotations', __ ( 'Add annotation on new post', 'wp-piwik' ), __ ( 'Add a Piwik annotation on each new post.', 'wp-piwik' ) . ' ' . sprintf ( __ ( 'See %sPiwik documentation%s.', 'wp-piwik' ), '<a href="http://piwik.org/docs/annotations/">', '</a>' ), $isNotTracking, $fullGeneratedTrackingGroup . ' wp-piwik-track-option-manually' );
|
198 |
+
|
199 |
+
$this->showCheckbox ( 'add_customvars_box', __ ( 'Show custom variables box', 'wp-piwik' ), __ ( ' Show a "custom variables" edit box on post edit page.', 'wp-piwik' ) . ' ' . sprintf ( __ ( 'See %sPiwik documentation%s.', 'wp-piwik' ), '<a href="http://piwik.org/docs/custom-variables/">', '</a>' ), $isNotGeneratedTracking, $fullGeneratedTrackingGroup . ' wp-piwik-track-option-manually' );
|
200 |
+
|
201 |
+
$this->showInput ( 'add_download_extensions', __ ( 'Add new file types for download tracking', 'wp-piwik' ), __ ( 'Add file extensions for download tracking, divided by a vertical bar (|).', 'wp-piwik' ) . ' ' . sprintf ( __ ( 'See %sPiwik documentation%s.', 'wp-piwik' ), '<a href="https://developer.piwik.org/guides/tracking-javascript-guide#file-extensions-for-tracking-downloads">', '</a>' ), $isNotGeneratedTracking, $fullGeneratedTrackingGroup );
|
202 |
+
|
203 |
+
$this->showCheckbox ( 'disable_cookies', __ ( 'Disable cookies', 'wp-piwik' ), __ ( 'Disable all tracking cookies for a visitor.', 'wp-piwik' ), $isNotGeneratedTracking, $fullGeneratedTrackingGroup );
|
204 |
+
|
205 |
+
$this->showCheckbox ( 'limit_cookies', __ ( 'Limit cookie lifetime', 'wp-piwik' ), __ ( 'TODO cookie lifetime desc', 'wp-piwik' ), $isNotGeneratedTracking, $fullGeneratedTrackingGroup, true, '$j(\'tr.wp-piwik-cookielifetime-option\').toggle(\'wp-piwik-hidden\');' );
|
206 |
+
|
207 |
+
$this->showInput ( 'limit_cookies_visitor', __ ( 'Visitor timeout (seconds)', 'wp-piwik' ), false, $isNotGeneratedTracking || ! self::$settings->getGlobalOption ( 'limit_cookies' ), $fullGeneratedTrackingGroup.' wp-piwik-hidden wp-piwik-cookielifetime-option' );
|
208 |
+
|
209 |
+
$this->showInput ( 'limit_cookies_session', __ ( 'Session timeout (seconds)', 'wp-piwik' ), false, $isNotGeneratedTracking || ! self::$settings->getGlobalOption ( 'limit_cookies' ), $fullGeneratedTrackingGroup . ' wp-piwik-hidden wp-piwik-cookielifetime-option' );
|
210 |
+
|
211 |
+
$this->showCheckbox ( 'track_admin', __ ( 'Track admin pages', 'wp-piwik' ), __ ( 'Enable to track users on admin pages (remember to configure the tracking filter appropriately).', 'wp-piwik' ), $isNotTracking, $fullGeneratedTrackingGroup . ' wp-piwik-track-option-manually' );
|
212 |
+
|
213 |
+
echo '<tr class="' . $fullGeneratedTrackingGroup . ' wp-piwik-track-option-manually' . ($isNotTracking ? ' hidden' : '') . '">';
|
214 |
+
echo '<th scope="row"><label for="capability_stealth">' . __ ( 'Tracking filter', 'wp-piwik' ) . '</label>:</th><td>';
|
215 |
+
$filter = self::$settings->getGlobalOption ( 'capability_stealth' );
|
216 |
+
foreach ( $wp_roles->role_names as $key => $name )
|
217 |
+
echo '<input type="checkbox" ' . (isset ( $filter [$key] ) && $filter [$key] ? 'checked="checked" ' : '') . 'value="1" name="wp-piwik[capability_stealth][' . $key . ']" /> ' . $name . ' ';
|
218 |
+
echo '<span class="dashicons dashicons-editor-help" onclick="$j(\'#capability_stealth-desc\').toggleClass(\'hidden\');"></span> <p class="description hidden" id="capability_stealth-desc">' . __ ( 'Choose users by user role you do <strong>not</strong> want to track.', 'wp-piwik' ) . '</p></td></tr>';
|
219 |
+
|
220 |
+
$this->showCheckbox ( 'track_across', __ ( 'Track visitors across all subdomains', 'wp-piwik' ), __ ( 'Adds *.-prefix to cookie domain.', 'wp-piwik' ), $isNotGeneratedTracking, $fullGeneratedTrackingGroup );
|
221 |
+
|
222 |
+
$this->showCheckbox ( 'track_across_alias', __ ( 'Track visitors across all alias URLs', 'wp-piwik' ), __ ( 'Adds *.-prefix to tracked domain.', 'wp-piwik' ), $isNotGeneratedTracking, $fullGeneratedTrackingGroup );
|
223 |
+
|
224 |
+
$this->showCheckbox ( 'track_feed', __ ( 'Track RSS feeds', 'wp-piwik' ), __ ( 'Enable to track posts in feeds via tracking pixel.', 'wp-piwik' ), $isNotTracking, $fullGeneratedTrackingGroup . ' wp-piwik-track-option-manually' );
|
225 |
+
|
226 |
+
$this->showCheckbox ( 'track_feed_addcampaign', __ ( 'Track RSS feed links as campaign', 'wp-piwik' ), __ ( 'This will add Piwik campaign parameters to the RSS feed links.' . ' ' . sprintf ( __ ( 'See %sPiwik documentation%s.', 'wp-piwik' ), '<a href="http://piwik.org/docs/tracking-campaigns/">', '</a>' ), 'wp-piwik' ), $isNotTracking, $fullGeneratedTrackingGroup . ' wp-piwik-track-option-manually', true, '$j(\'tr.wp-piwik-feed_campaign-option\').toggle(\'hidden\');' );
|
227 |
+
|
228 |
+
$this->showInput ( 'track_feed_campaign', __ ( 'RSS feed campaign', 'wp-piwik' ), __ ( 'Keyword: post name.', 'wp-piwik' ), $isNotGeneratedTracking || ! self::$settings->getGlobalOption ( 'track_feed_addcampaign' ), $fullGeneratedTrackingGroup . ' wp-piwik-feed_campaign-option' );
|
229 |
+
|
230 |
+
echo $submitButton;
|
231 |
+
echo '</tbody></table><table id="expert" class="wp-piwik_menu-tab hidden"><tbody>';
|
232 |
+
|
233 |
+
$this->showText ( __ ( 'Usually, you do not need to change these settings. If you want to do so, you should know what you do or you got an expert\'s advice.', 'wp-piwik' ) );
|
234 |
+
|
235 |
+
$this->showCheckbox ( 'cache', __ ( 'Enable cache', 'wp-piwik' ), __ ( 'Cache API calls, which not contain today\'s values, for a week.', 'wp-piwik' ) );
|
236 |
+
|
237 |
+
$this->showCheckbox ( 'disable_timelimit', __ ( 'Disable time limit', 'wp-piwik' ), __ ( 'Use set_time_limit(0) if stats page causes a time out.', 'wp-piwik' ) );
|
238 |
+
|
239 |
+
$this->showInput ( 'connection_timeout', __ ( 'Connection timeout', 'wp-piwik' ), 'TODO Connection timeout description' );
|
240 |
+
|
241 |
+
$this->showCheckbox ( 'disable_ssl_verify', __ ( 'Disable SSL peer verification', 'wp-piwik' ), '(' . __ ( 'not recommended', 'wp-piwik' ) . ')' );
|
242 |
+
|
243 |
+
$this->showSelect ( 'piwik_useragent', __ ( 'User agent', 'wp-piwik' ), array (
|
244 |
+
'php' => __ ( 'Use the PHP default user agent', 'wp-piwik' ) . (ini_get ( 'user_agent' ) ? '(' . ini_get ( 'user_agent' ) . ')' : ' (' . __ ( 'empty', 'wp-piwik' ) . ')'),
|
245 |
+
'own' => __ ( 'Define a specific user agent', 'wp-piwik' )
|
246 |
+
), 'TODO User agent description', '$j(\'tr.wp-piwik-useragent-option\').toggleClass(\'hidden\');' );
|
247 |
+
$this->showInput ( 'piwik_useragent_string', __ ( 'Specific user agent', 'wp-piwik' ), 'TODO Specific user agent description', self::$settings->getGlobalOption ( 'piwik_useragent' ) != 'own', 'wp-piwik-useragent-option' );
|
248 |
+
|
249 |
+
$this->showCheckbox ( 'track_datacfasync', __ ( 'Add data-cfasync=false', 'wp-piwik' ), __ ( 'Adds data-cfasync=false to the script tag, e.g., to ask Rocket Loader to ignore the script.' . ' ' . sprintf ( __ ( 'See %sCloudFlare Knowledge Base%s.', 'wp-piwik' ), '<a href="https://support.cloudflare.com/hc/en-us/articles/200169436-How-can-I-have-Rocket-Loader-ignore-my-script-s-in-Automatic-Mode-">', '</a>' ), 'wp-piwik' ) );
|
250 |
+
|
251 |
+
$this->showInput ( 'track_cdnurl', __ ( 'CDN URL', 'wp-piwik' ), 'Enter URL if you want to load the tracking code via CDN.' );
|
252 |
+
|
253 |
+
$this->showInput ( 'track_cdnurlssl', __ ( 'CDN URL (SSL)', 'wp-piwik' ), 'Enter URL if you want to load the tracking code via a separate SSL CDN.' );
|
254 |
+
|
255 |
+
$this->showSelect ( 'force_protocol', __ ( 'Force Piwik to use a specific protocol', 'wp-piwik' ), array (
|
256 |
+
'disabled' => __ ( 'Disabled (default)', 'wp-piwik' ),
|
257 |
+
'http' => __ ( 'http', 'wp-piwik' ),
|
258 |
+
'https' => __ ( 'https (SSL)', 'wp-piwik' )
|
259 |
+
), __ ( 'Choose if you want to explicitly force Piwik to use HTTP or HTTPS. Does not work with a CDN URL.', 'wp-piwik' ) );
|
260 |
+
|
261 |
+
echo $submitButton;
|
262 |
+
?>
|
263 |
+
</tbody>
|
264 |
+
</table>
|
265 |
+
<table id="support" class="wp-piwik_menu-tab hidden">
|
266 |
+
<tbody>
|
267 |
+
<tr><td colspan="2"><?php
|
268 |
+
echo $this->showSupport();
|
269 |
+
?></td></tr>
|
270 |
+
</tbody>
|
271 |
+
</table>
|
272 |
+
<table id="credits" class="wp-piwik_menu-tab hidden">
|
273 |
+
<tbody>
|
274 |
+
<tr><td colspan="2"><?php
|
275 |
+
echo $this->showCredits();
|
276 |
+
?></td></tr>
|
277 |
+
</tbody>
|
278 |
+
</table>
|
279 |
+
<input type="hidden" name="wp-piwik[proxy_url]"
|
280 |
+
value="<?php echo self::$settings->getGlobalOption('proxy_url'); ?>" />
|
281 |
+
</form>
|
282 |
+
</div>
|
283 |
+
<?php
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Show an option's description
|
288 |
+
*
|
289 |
+
* @param string $id option id
|
290 |
+
* @param string $description option description
|
291 |
+
* @param boolean $hideDescription set to false to show description initially (default: true)
|
292 |
+
* @return string full description HTML
|
293 |
+
*/
|
294 |
+
private function getDescription($id, $description, $hideDescription = true) {
|
295 |
+
return sprintf ( '<span class="dashicons dashicons-editor-help" onclick="$j(\'#%s-desc\').toggleClass(\'hidden\');"></span> <p class="description' . ($hideDescription ? ' hidden' : '') . '" id="%1$s-desc">%s</p>', $id, $description );
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Show a checkbox option
|
300 |
+
*
|
301 |
+
* @param string $id option id
|
302 |
+
* @param string $name descriptive option name
|
303 |
+
* @param string $description option description
|
304 |
+
* @param boolean $isHidden set to true to initially hide the option (default: false)
|
305 |
+
* @param string $groupName define a class name to access a group of option rows by javascript (default: empty)
|
306 |
+
* @param boolean $hideDescription $hideDescription set to false to show description initially (default: true)
|
307 |
+
* @param string $onChange javascript for onchange event (default: empty)
|
308 |
+
*/
|
309 |
+
private function showCheckbox($id, $name, $description, $isHidden = false, $groupName = '', $hideDescription = true, $onChange = '') {
|
310 |
+
printf ( '<tr class="' . $groupName . ($isHidden ? ' hidden' : '') . '"><th scope="row"><label for="%2$s">%s</label>:</th><td><input type="checkbox" value="1"' . (self::$settings->getGlobalOption ( $id ) ? ' checked="checked"' : '') . ' onchange="$j(\'#%s\').val(this.checked?1:0);%s" /><input id="%2$s" type="hidden" name="wp-piwik[%2$s]" value="' . ( int ) self::$settings->getGlobalOption ( $id ) . '" /> %s</td></tr>', $name, $id, $onChange, $this->getDescription ( $id, $description, $hideDescription ) );
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Show a textarea option
|
315 |
+
*
|
316 |
+
* @param string $id option id
|
317 |
+
* @param string $name descriptive option name
|
318 |
+
* @param int $rows number of rows to show
|
319 |
+
* @param string $description option description
|
320 |
+
* @param boolean $isHidden set to true to initially hide the option (default: false)
|
321 |
+
* @param string $groupName define a class name to access a group of option rows by javascript (default: empty)
|
322 |
+
* @param boolean $hideDescription $hideDescription set to false to show description initially (default: true)
|
323 |
+
* @param string $onChange javascript for onchange event (default: empty)
|
324 |
+
* @param boolean $isReadonly set textarea to read only (default: false)
|
325 |
+
* @param boolean $global set to false if the textarea shows a site-specific option (default: true)
|
326 |
+
*/
|
327 |
+
private function showTextarea($id, $name, $rows, $description, $isHidden, $groupName, $hideDescription = true, $onChange = '', $isReadonly = false, $global = true) {
|
328 |
+
printf ( '<tr class="' . $groupName . ($isHidden ? ' hidden' : '') . '"><th scope="row"><label for="%2$s">%s</label>:</th><td><textarea cols="80" rows="' . $rows . '" id="%s" name="wp-piwik[%2$s]" onchange="%s"' . ($isReadonly ? ' readonly="readonly"' : '') . '>' . ($global ? self::$settings->getGlobalOption ( $id ) : self::$settings->getOption ( $id )) . '</textarea> %s</td></tr>', $name, $id, $onChange, $this->getDescription ( $id, $description, $hideDescription ) );
|
329 |
+
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
* Show a simple text
|
333 |
+
*
|
334 |
+
* @param string $text Text to show
|
335 |
+
*/
|
336 |
+
private function showText($text) {
|
337 |
+
printf ( '<tr><td colspan="2"><p>%s</p></td></tr>', $text );
|
338 |
+
}
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Show an input option
|
342 |
+
*
|
343 |
+
* @param string $id option id
|
344 |
+
* @param string $name descriptive option name
|
345 |
+
* @param string $description option description
|
346 |
+
* @param boolean $isHidden set to true to initially hide the option (default: false)
|
347 |
+
* @param string $groupName define a class name to access a group of option rows by javascript (default: empty)
|
348 |
+
* @param string $rowName define a class name to access the specific option row by javascript (default: empty)
|
349 |
+
* @param boolean $hideDescription $hideDescription set to false to show description initially (default: true)
|
350 |
+
*/
|
351 |
+
private function showInput($id, $name, $description, $isHidden = false, $groupName = '', $rowName = false, $hideDescription = true) {
|
352 |
+
printf ( '<tr class="%s%s"%s><th scope="row"><label for="%5$s">%s:</label></th><td><input name="wp-piwik[%s]" id="%5$s" value="%s" /> %s</td></tr>', $isHidden ? 'hidden ' : '', $groupName ? $groupName : '', $rowName ? ' id="' . $groupName . '-' . $rowName . '"' : '', $name, $id, self::$settings->getGlobalOption ( $id ), $this->getDescription ( $id, $description, $hideDescription ) );
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Show a select box option
|
357 |
+
*
|
358 |
+
* @param string $id option id
|
359 |
+
* @param string $name descriptive option name
|
360 |
+
* @param array $options list of options to show array[](option id => descriptive name)
|
361 |
+
* @param string $description option description
|
362 |
+
* @param string $onChange javascript for onchange event (default: empty)
|
363 |
+
* @param boolean $isHidden set to true to initially hide the option (default: false)
|
364 |
+
* @param string $groupName define a class name to access a group of option rows by javascript (default: empty)
|
365 |
+
* @param boolean $hideDescription $hideDescription set to false to show description initially (default: true)
|
366 |
+
* @param boolean $global set to false if the textarea shows a site-specific option (default: true)
|
367 |
+
*/
|
368 |
+
private function showSelect($id, $name, $options = array(), $description = '', $onChange = '', $isHidden = false, $groupName = '', $hideDescription = true, $global = true) {
|
369 |
+
$optionList = '';
|
370 |
+
$default = $global ? self::$settings->getGlobalOption ( $id ) : self::$settings->getOption ( $id );
|
371 |
+
if (is_array ( $options ))
|
372 |
+
foreach ( $options as $key => $value )
|
373 |
+
$optionList .= sprintf ( '<option value="%s"' . ($key == $default ? ' selected="selected"' : '') . '>%s</option>', $key, $value );
|
374 |
+
printf ( '<tr class="' . $groupName . ($isHidden ? ' hidden' : '') . '"><th scope="row"><label for="%2$s">%s:</label></th><td><select name="wp-piwik[%s]" id="%2$s" onchange="%s">%s</select> %s</td></tr>', $name, $id, $onChange, $optionList, $this->getDescription ( $id, $description, $hideDescription ) );
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Show an info box
|
379 |
+
*
|
380 |
+
* @param string $type box style (e.g., updated, error)
|
381 |
+
* @param string $icon box icon, see https://developer.wordpress.org/resource/dashicons/
|
382 |
+
* @param string $content box message
|
383 |
+
*/
|
384 |
+
private function showBox($type, $icon, $content) {
|
385 |
+
printf ( '<tr><td colspan="2"><div class="%s"><p><span class="dashicons dashicons-%s"></span> %s</p></div></td></tr>', $type, $icon, $content );
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Show headline
|
390 |
+
* @param int $order headline order (h?-tag), set to 0 to avoid headline-tagging
|
391 |
+
* @param string $icon headline icon, see https://developer.wordpress.org/resource/dashicons/
|
392 |
+
* @param string $headline headline text
|
393 |
+
* @param string $addPluginName set to true to add the plugin name to the headline (default: false)
|
394 |
+
*/
|
395 |
+
private function showHeadline($order, $icon, $headline, $addPluginName = false) {
|
396 |
+
echo $this->getHeadline ( $order, $icon, $headline, $addPluginName = false );
|
397 |
+
}
|
398 |
+
|
399 |
+
/**
|
400 |
+
* Get headline HTML
|
401 |
+
*
|
402 |
+
* @param int $order headline order (h?-tag), set to 0 to avoid headline-tagging
|
403 |
+
* @param string $icon headline icon, see https://developer.wordpress.org/resource/dashicons/
|
404 |
+
* @param string $headline headline text
|
405 |
+
* @param string $addPluginName set to true to add the plugin name to the headline (default: false)
|
406 |
+
*/
|
407 |
+
private function getHeadline($order, $icon, $headline, $addPluginName = false) {
|
408 |
+
echo ($order > 0 ? "<h$order>" : '') . sprintf ( '<span class="dashicons dashicons-%s"></span> %s%s', $icon, ($addPluginName ? self::$settings->getGlobalOption ( 'plugin_display_name' ) . ' ' : ''), __ ( $headline, 'wp-piwik' ) ) . ($order > 0 ? "</h$order>" : '');
|
409 |
+
}
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Show donation info
|
413 |
+
*/
|
414 |
+
private function showDonation() {
|
415 |
+
?>
|
416 |
+
<div class="wp-piwik-donate">
|
417 |
+
<p>
|
418 |
+
<strong><?php _e('Donate','wp-piwik'); ?></strong>
|
419 |
+
</p>
|
420 |
+
<p><?php _e('If you like WP-Piwik, you can support its development by a donation:', 'wp-piwik'); ?></p>
|
421 |
+
<script type="text/javascript">
|
422 |
+
/* <![CDATA[ */
|
423 |
+
window.onload = function() {
|
424 |
+
FlattrLoader.render({
|
425 |
+
'uid': 'flattr',
|
426 |
+
'url': 'http://wp.local',
|
427 |
+
'title': 'Title of the thing',
|
428 |
+
'description': 'Description of the thing'
|
429 |
+
}, 'element_id', 'replace');
|
430 |
+
}
|
431 |
+
/* ]]> */
|
432 |
+
</script>
|
433 |
+
<div>
|
434 |
+
<a class="FlattrButton" style="display: none;"
|
435 |
+
title="WordPress Plugin WP-Piwik"
|
436 |
+
rel="flattr;uid:braekling;category:software;tags:wordpress,piwik,plugin,statistics;"
|
437 |
+
href="https://www.braekling.de/wp-piwik-wpmu-piwik-wordpress">This
|
438 |
+
WordPress plugin adds a Piwik stats site to your WordPress dashboard.
|
439 |
+
It's also able to add the Piwik tracking code to your blog using
|
440 |
+
wp_footer. You need a running Piwik installation and at least view
|
441 |
+
access to your stats.</a>
|
442 |
+
</div>
|
443 |
+
<div>
|
444 |
+
Paypal
|
445 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
446 |
+
<input type="hidden" name="cmd" value="_s-xclick" /> <input
|
447 |
+
type="hidden" name="hosted_button_id" value="6046779" /> <input
|
448 |
+
type="image"
|
449 |
+
src="https://www.paypal.com/en_GB/i/btn/btn_donateCC_LG.gif"
|
450 |
+
name="submit" alt="PayPal - The safer, easier way to pay online." />
|
451 |
+
<img alt="" border="0"
|
452 |
+
src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1"
|
453 |
+
height="1" />
|
454 |
+
</form>
|
455 |
+
</div>
|
456 |
+
<div>
|
457 |
+
<a
|
458 |
+
href="http://www.amazon.de/gp/registry/wishlist/111VUJT4HP1RA?reveal=unpurchased&filter=all&sort=priority&layout=standard&x=12&y=14"><?php _e('My Amazon.de wishlist', 'wp-piwik'); ?></a>
|
459 |
+
</div>
|
460 |
+
<div>
|
461 |
+
<?php _e('Please don\'t forget to vote the compatibility at the','wp-piwik'); ?> <a
|
462 |
+
href="http://wordpress.org/extend/plugins/wp-piwik/">WordPress.org
|
463 |
+
Plugin Directory</a>.
|
464 |
+
</div>
|
465 |
+
</div><?php
|
466 |
+
}
|
467 |
+
|
468 |
+
/**
|
469 |
+
* Register admin scripts
|
470 |
+
*
|
471 |
+
* @see \WP_Piwik\Admin::printAdminScripts()
|
472 |
+
*/
|
473 |
+
public function printAdminScripts() {
|
474 |
+
wp_enqueue_script ( 'jquery' );
|
475 |
+
}
|
476 |
+
|
477 |
+
/**
|
478 |
+
* Extend admin header
|
479 |
+
*
|
480 |
+
* @see \WP_Piwik\Admin::extendAdminHeader()
|
481 |
+
*/
|
482 |
+
public function extendAdminHeader() {
|
483 |
+
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
|
484 |
+
echo '<script type="text/javascript">/* <![CDATA[ */(function() {var s = document.createElement(\'script\');var t = document.getElementsByTagName(\'script\')[0];s.type = \'text/javascript\';s.async = true;s.src = \'//api.flattr.com/js/0.6/load.js?mode=auto\';t.parentNode.insertBefore(s, t);})();/* ]]> */</script>';
|
485 |
+
}
|
486 |
+
|
487 |
+
/**
|
488 |
+
* Show credits
|
489 |
+
*/
|
490 |
+
public function showCredits() {
|
491 |
+
?>
|
492 |
+
<p><strong><?php _e('Thank you very much for your donation', 'wp-piwik'); ?>:</strong> Marco L., Rolf W., Tobias U., Lars K., Donna F., Kevin D., Ramos S., Thomas M., John C., Andreas G., Ben M., Myra R. I., Carlos U. R.-S., Oleg I., M. N., Daniel K., James L., Jochen K., Cyril P., Thomas K., <?php _e('the Piwik team itself','wp-piwik');?><?php _e(', and all people flattering this','wp-piwik'); ?>!</p>
|
493 |
+
<p><?php _e('Graphs powered by <a href="http://www.jqplot.com/">jqPlot</a> (License: GPL 2.0 and MIT) and <a href="http://omnipotent.net/jquery.sparkline/">jQuery Sparklines</a> (License: New BSD License).','wp-piwik'); ?></p>
|
494 |
+
<p><?php _e('Metabox support inspired by', 'wp-piwik'); echo ' <a href="http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins">Heiko Rabe\'s metabox demo plugin</a>.';?></p>
|
495 |
+
<p><?php _e('Tabbed settings page suggested by the', 'wp-piwik'); echo' <a href="http://wp.smashingmagazine.com/2011/10/20/create-tabs-wordpress-settings-pages/">Smashing Magazine</a>.';?></p>
|
496 |
+
<p><?php _e('Thank you very much','wp-piwik'); ?>, Besnik Bleta, FatCow, Rene, Fab, EzBizNiz, Gormer, Natalya, AggelioPolis, Web Hosting Geeks, Web Hosting Rating, Nata Strazda (Web Hosting Hub), Hossein (LibreOffice localization team), Ste & Chris <?php _e('for your translation work','wp-piwik'); ?>!</p>
|
497 |
+
<p><?php _e('Thank you very much, all users who send me mails containing criticism, commendation, feature requests and bug reports! You help me to make WP-Piwik much better.','wp-piwik'); ?></p>
|
498 |
+
<p><?php _e('Thank <strong>you</strong> for using my plugin. It is the best commendation if my piece of code is really used!','wp-piwik'); ?></p>
|
499 |
+
<?php
|
500 |
+
}
|
501 |
+
|
502 |
+
/**
|
503 |
+
* Show support information
|
504 |
+
*/
|
505 |
+
public function showSupport() {
|
506 |
+
?><ul>
|
507 |
+
<li>The best place to get help: <a href="https://wordpress.org/support/plugin/wp-piwik"><?php _e('WP-Piwik support forum','wp-piwik'); ?></a></li>
|
508 |
+
<li><?php _e('Please don\'t forget to vote the compatibility at the','wp-piwik'); ?> <a href="http://wordpress.org/extend/plugins/wp-piwik/">WordPress.org Plugin Directory</a>.</li>
|
509 |
+
</ul>
|
510 |
+
<h3><?php _e('Debugging', 'wp-piwik'); ?></h3>
|
511 |
+
<p><?php _e('Either allow_url_fopen has to be enabled <em>or</em> cURL has to be available:', 'wp-piwik'); ?></p>
|
512 |
+
<ol>
|
513 |
+
<li><?php
|
514 |
+
_e('cURL is','wp-piwik');
|
515 |
+
echo ' <strong>'.(function_exists('curl_init')?'':__('not','wp-piwik')).' ';
|
516 |
+
_e('available','wp-piwik');
|
517 |
+
?></strong>.</li>
|
518 |
+
<li><?php
|
519 |
+
_e('allow_url_fopen is','wp-piwik');
|
520 |
+
echo ' <strong>'.(ini_get('allow_url_fopen')?'':__('not','wp-piwik')).' ';
|
521 |
+
_e('enabled','wp-piwik');
|
522 |
+
?></strong>.</li>
|
523 |
+
</ol>
|
524 |
+
<h3><?php _e('Latest support threads on WordPress.org', 'wp-piwik'); ?></h3><?php
|
525 |
+
$supportThreads = $this->readRSSFeed('http://wordpress.org/support/rss/plugin/wp-piwik');
|
526 |
+
if (!empty($supportThreads)) {
|
527 |
+
echo '<ol>';
|
528 |
+
foreach ($supportThreads as $supportThread)
|
529 |
+
echo '<li><a href="'.$supportThread['url'].'">'.$supportThread['title'].'</a></li>';
|
530 |
+
echo '</ol>';
|
531 |
+
}
|
532 |
+
}
|
533 |
+
|
534 |
+
/**
|
535 |
+
* Read RSS feed
|
536 |
+
*
|
537 |
+
* @param string $feed
|
538 |
+
* feed URL
|
539 |
+
* @param int $cnt
|
540 |
+
* item limit
|
541 |
+
* @return array feed items array[](title, url)
|
542 |
+
*
|
543 |
+
*/
|
544 |
+
private function readRSSFeed($feed, $cnt = 5) {
|
545 |
+
$result = array ();
|
546 |
+
if (function_exists ( 'simplexml_load_file' ) && ! empty ( $feed )) {
|
547 |
+
$xml = @simplexml_load_file ( $feed );
|
548 |
+
if (! $xml || ! isset ( $xml->channel [0]->item ))
|
549 |
+
return array (
|
550 |
+
array (
|
551 |
+
'title' => 'Can\'t read RSS feed.',
|
552 |
+
'url' => $xml
|
553 |
+
)
|
554 |
+
);
|
555 |
+
foreach ( $xml->channel [0]->item as $item ) {
|
556 |
+
if ($cnt -- == 0)
|
557 |
+
break;
|
558 |
+
$result [] = array (
|
559 |
+
'title' => $item->title [0],
|
560 |
+
'url' => $item->link [0]
|
561 |
+
);
|
562 |
+
}
|
563 |
+
}
|
564 |
+
return $result;
|
565 |
+
}
|
566 |
+
|
567 |
+
}
|
classes/WP_Piwik/Admin/Sitebrowser.php
CHANGED
@@ -2,30 +2,27 @@
|
|
2 |
|
3 |
namespace WP_Piwik\Admin;
|
4 |
|
5 |
-
|
|
|
|
|
|
|
6 |
|
7 |
-
private $data = array();
|
8 |
|
9 |
-
public function __construct($wpPiwik
|
10 |
-
$
|
11 |
-
$
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
$this->addPiwikSite();
|
21 |
-
}
|
22 |
-
$cnt = $this->prepare_items($isNetwork);
|
23 |
-
if ($cnt > 0) $this->display();
|
24 |
-
else echo '<p>No site configured yet.</p>';
|
25 |
-
}
|
26 |
}
|
27 |
|
28 |
-
|
29 |
$columns = array(
|
30 |
'id' => __('ID','wp-piwik'),
|
31 |
'name' => __('Title','wp-piwik'),
|
@@ -35,7 +32,7 @@
|
|
35 |
return $columns;
|
36 |
}
|
37 |
|
38 |
-
|
39 |
$current_page = $this->get_pagenum();
|
40 |
$per_page = 10;
|
41 |
global $blog_id;
|
@@ -50,7 +47,7 @@
|
|
50 |
'name' => $blogDetails->blogname,
|
51 |
'id' => $blogDetails->blog_id,
|
52 |
'siteurl' => $blogDetails->siteurl,
|
53 |
-
'piwikid' =>
|
54 |
);
|
55 |
}
|
56 |
} else {
|
@@ -59,7 +56,7 @@
|
|
59 |
'name' => get_bloginfo('name'),
|
60 |
'id' => '-',
|
61 |
'siteurl' => get_bloginfo('url'),
|
62 |
-
'piwikid' =>
|
63 |
);
|
64 |
$total_items = 1;
|
65 |
}
|
@@ -71,11 +68,10 @@
|
|
71 |
'total_items' => $total_items,
|
72 |
'per_page' => $per_page
|
73 |
));
|
74 |
-
if ($isNetwork) $pagenow = 'settings.php';
|
75 |
foreach ($this->data as $key => $dataset) {
|
76 |
-
if (empty($dataset['piwikid']) ||
|
77 |
-
$this->data[$key]['piwikid'] = '
|
78 |
-
if ($
|
79 |
$this->data[$key]['name'] = '<a href="?page=wp-piwik_stats&wpmu_show_stats='.$dataset['id'].'">'.$dataset['name'].'</a>';
|
80 |
}
|
81 |
$this->items = $this->data;
|
@@ -93,4 +89,5 @@
|
|
93 |
return print_r($item,true);
|
94 |
}
|
95 |
}
|
|
|
96 |
}
|
2 |
|
3 |
namespace WP_Piwik\Admin;
|
4 |
|
5 |
+
if (!class_exists('WP_List_Table'))
|
6 |
+
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
7 |
+
|
8 |
+
class Sitebrowser extends \WP_List_Table {
|
9 |
|
10 |
+
private $data = array(), $wpPiwik;
|
11 |
|
12 |
+
public function __construct($wpPiwik) {
|
13 |
+
$this->wpPiwik = $wpPiwik;
|
14 |
+
$cnt = $this->prepare_items();
|
15 |
+
global $status, $page;
|
16 |
+
parent::__construct( array(
|
17 |
+
'singular' => __('site', 'wp-piwik'),
|
18 |
+
'plural' => __('sites', 'wp-piwik'),
|
19 |
+
'ajax' => false
|
20 |
+
) );
|
21 |
+
if ($cnt > 0) $this->display();
|
22 |
+
else echo '<p>'.__('No site configured yet.', 'wp-piwik').'</p>';
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
|
25 |
+
public function get_columns(){
|
26 |
$columns = array(
|
27 |
'id' => __('ID','wp-piwik'),
|
28 |
'name' => __('Title','wp-piwik'),
|
32 |
return $columns;
|
33 |
}
|
34 |
|
35 |
+
public function prepare_items() {
|
36 |
$current_page = $this->get_pagenum();
|
37 |
$per_page = 10;
|
38 |
global $blog_id;
|
47 |
'name' => $blogDetails->blogname,
|
48 |
'id' => $blogDetails->blog_id,
|
49 |
'siteurl' => $blogDetails->siteurl,
|
50 |
+
'piwikid' => $this->wpPiwik->getPiwikSiteId($blogDetails->blog_id)
|
51 |
);
|
52 |
}
|
53 |
} else {
|
56 |
'name' => get_bloginfo('name'),
|
57 |
'id' => '-',
|
58 |
'siteurl' => get_bloginfo('url'),
|
59 |
+
'piwikid' => $this->wpPiwik->getPiwikSiteId()
|
60 |
);
|
61 |
$total_items = 1;
|
62 |
}
|
68 |
'total_items' => $total_items,
|
69 |
'per_page' => $per_page
|
70 |
));
|
|
|
71 |
foreach ($this->data as $key => $dataset) {
|
72 |
+
if (empty($dataset['piwikid']) || $dataset['piwikid'] == 'n/a')
|
73 |
+
$this->data[$key]['piwikid'] = __('Site not created yet.', 'wp-piwik');
|
74 |
+
if ($this->wpPiwik->isNetworkMode())
|
75 |
$this->data[$key]['name'] = '<a href="?page=wp-piwik_stats&wpmu_show_stats='.$dataset['id'].'">'.$dataset['name'].'</a>';
|
76 |
}
|
77 |
$this->items = $this->data;
|
89 |
return print_r($item,true);
|
90 |
}
|
91 |
}
|
92 |
+
|
93 |
}
|
classes/WP_Piwik/Admin/Statistics.php
CHANGED
@@ -4,17 +4,17 @@
|
|
4 |
|
5 |
class Statistics extends \WP_Piwik\Admin {
|
6 |
|
7 |
-
public function show(
|
8 |
global $screen_layout_columns;
|
9 |
if (empty($screen_layout_columns)) $screen_layout_columns = 2;
|
10 |
if (self::$settings->getGlobalOption('disable_timelimit')) set_time_limit(0);
|
11 |
echo '<div id="wp-piwik-stats-general" class="wrap">';
|
12 |
echo '<h2>'.(self::$settings->getGlobalOption('plugin_display_name') == 'WP-Piwik'?'Piwik '.__('Statistics', 'wp-piwik'):self::$settings->getGlobalOption('plugin_display_name')).'</h2>';
|
13 |
-
if (self::$settings->checkNetworkActivation() && function_exists('is_super_admin') && is_super_admin()
|
14 |
if (isset($_GET['wpmu_show_stats'])) {
|
15 |
switch_to_blog((int) $_GET['wpmu_show_stats']);
|
16 |
} else {
|
17 |
-
new WP_Piwik\Admin\Sitebrowser(self::$wpPiwik
|
18 |
return;
|
19 |
}
|
20 |
echo '<p>'.__('Currently shown stats:').' <a href="'.get_bloginfo('url').'">'.(int) $_GET['wpmu_show_stats'].' - '.get_bloginfo('name').'</a>.'.' <a href="?page=wp-piwik_stats">Show site overview</a>.</p>';
|
4 |
|
5 |
class Statistics extends \WP_Piwik\Admin {
|
6 |
|
7 |
+
public function show() {
|
8 |
global $screen_layout_columns;
|
9 |
if (empty($screen_layout_columns)) $screen_layout_columns = 2;
|
10 |
if (self::$settings->getGlobalOption('disable_timelimit')) set_time_limit(0);
|
11 |
echo '<div id="wp-piwik-stats-general" class="wrap">';
|
12 |
echo '<h2>'.(self::$settings->getGlobalOption('plugin_display_name') == 'WP-Piwik'?'Piwik '.__('Statistics', 'wp-piwik'):self::$settings->getGlobalOption('plugin_display_name')).'</h2>';
|
13 |
+
if (self::$settings->checkNetworkActivation() && function_exists('is_super_admin') && is_super_admin()) {
|
14 |
if (isset($_GET['wpmu_show_stats'])) {
|
15 |
switch_to_blog((int) $_GET['wpmu_show_stats']);
|
16 |
} else {
|
17 |
+
new \WP_Piwik\Admin\Sitebrowser(self::$wpPiwik);
|
18 |
return;
|
19 |
}
|
20 |
echo '<p>'.__('Currently shown stats:').' <a href="'.get_bloginfo('url').'">'.(int) $_GET['wpmu_show_stats'].' - '.get_bloginfo('name').'</a>.'.' <a href="?page=wp-piwik_stats">Show site overview</a>.</p>';
|
classes/WP_Piwik/Request/Php.php
CHANGED
@@ -33,7 +33,8 @@
|
|
33 |
if (class_exists('Piwik\API\Request'))
|
34 |
$request = new \Piwik\API\Request($params.'&token_auth='.self::$settings->getGlobalOption('piwik_token'));
|
35 |
else serialize(array('result' => 'error', 'message' => __('Class Piwik\API\Request does not exists.','wp-piwik')));
|
36 |
-
|
|
|
37 |
if (!headers_sent())
|
38 |
header("Content-Type: text/html", true);
|
39 |
return $this->unserialize($result);
|
33 |
if (class_exists('Piwik\API\Request'))
|
34 |
$request = new \Piwik\API\Request($params.'&token_auth='.self::$settings->getGlobalOption('piwik_token'));
|
35 |
else serialize(array('result' => 'error', 'message' => __('Class Piwik\API\Request does not exists.','wp-piwik')));
|
36 |
+
if (isset($request))
|
37 |
+
$result = $request->process();
|
38 |
if (!headers_sent())
|
39 |
header("Content-Type: text/html", true);
|
40 |
return $this->unserialize($result);
|
classes/WP_Piwik/Request/Rest.php
CHANGED
@@ -18,8 +18,9 @@
|
|
18 |
}
|
19 |
}
|
20 |
$results = (function_exists('curl_init')?$this->curl($url, $params):$this->fopen($url, $params));
|
21 |
-
|
22 |
-
|
|
|
23 |
}
|
24 |
|
25 |
private function curl($url, $params) {
|
18 |
}
|
19 |
}
|
20 |
$results = (function_exists('curl_init')?$this->curl($url, $params):$this->fopen($url, $params));
|
21 |
+
if (is_array($results))
|
22 |
+
foreach ($results as $num => $result)
|
23 |
+
self::$results[$map[$num]] = $result;
|
24 |
}
|
25 |
|
26 |
private function curl($url, $params) {
|
classes/WP_Piwik/Settings.php
CHANGED
@@ -1,258 +1,367 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
'
|
25 |
-
'piwik_token' => '',
|
26 |
-
'
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
'
|
37 |
-
'
|
38 |
-
|
39 |
-
|
40 |
-
'
|
41 |
-
'
|
42 |
-
'
|
43 |
-
'
|
44 |
-
'
|
45 |
-
|
46 |
-
'
|
47 |
-
'
|
48 |
-
'
|
49 |
-
'
|
50 |
-
'
|
51 |
-
'
|
52 |
-
'
|
53 |
-
|
54 |
-
|
55 |
-
'
|
56 |
-
'
|
57 |
-
'
|
58 |
-
'
|
59 |
-
|
60 |
-
|
61 |
-
'
|
62 |
-
'
|
63 |
-
'
|
64 |
-
'
|
65 |
-
'
|
66 |
-
'
|
67 |
-
'
|
68 |
-
'
|
69 |
-
'
|
70 |
-
'
|
71 |
-
|
72 |
-
|
73 |
-
'
|
74 |
-
'
|
75 |
-
'
|
76 |
-
'
|
77 |
-
'
|
78 |
-
'
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
$
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
$
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
}
|
257 |
-
|
258 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WP_Piwik;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Manage WP-Piwik settings
|
7 |
+
*
|
8 |
+
* @author André Bräkling
|
9 |
+
* @package WP_Piwik
|
10 |
+
*/
|
11 |
+
class Settings {
|
12 |
+
|
13 |
+
/**
|
14 |
+
*
|
15 |
+
* @var Environment variables and default settings container
|
16 |
+
*/
|
17 |
+
private static $wpPiwik, $defaultSettings;
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
* @var Define callback functions for changed settings
|
22 |
+
*/
|
23 |
+
private $checkSettings = array (
|
24 |
+
'piwik_url' => 'checkPiwikUrl',
|
25 |
+
'piwik_token' => 'checkPiwikToken',
|
26 |
+
'tracking_code' => 'prepareTrackingCode',
|
27 |
+
'noscript_code' => 'prepareNocscriptCode'
|
28 |
+
);
|
29 |
+
|
30 |
+
/**
|
31 |
+
*
|
32 |
+
* @var Register default configuration set
|
33 |
+
*/
|
34 |
+
private $globalSettings = array (
|
35 |
+
// Plugin settings
|
36 |
+
'revision' => 0,
|
37 |
+
'last_settings_update' => 0,
|
38 |
+
// User settings: Piwik configuration
|
39 |
+
'piwik_mode' => 'http',
|
40 |
+
'piwik_url' => '',
|
41 |
+
'piwik_path' => '',
|
42 |
+
'piwik_user' => '',
|
43 |
+
'piwik_token' => '',
|
44 |
+
'auto_site_config' => true,
|
45 |
+
// User settings: Stats configuration
|
46 |
+
'default_date' => 'yesterday',
|
47 |
+
'stats_seo' => false,
|
48 |
+
'dashboard_widget' => false,
|
49 |
+
'dashboard_chart' => false,
|
50 |
+
'dashboard_seo' => false,
|
51 |
+
'toolbar' => false,
|
52 |
+
'capability_read_stats' => array (
|
53 |
+
'administrator' => true
|
54 |
+
),
|
55 |
+
'perpost_stats' => false,
|
56 |
+
'plugin_display_name' => 'WP-Piwik',
|
57 |
+
'piwik_shortcut' => false,
|
58 |
+
'shortcodes' => false,
|
59 |
+
// User settings: Tracking configuration
|
60 |
+
'track_mode' => 'disabled',
|
61 |
+
'track_codeposition' => 'footer',
|
62 |
+
'track_noscript' => false,
|
63 |
+
'track_nojavascript' => false,
|
64 |
+
'proxy_url' => '',
|
65 |
+
'track_search' => false,
|
66 |
+
'track_404' => false,
|
67 |
+
'add_post_annotations' => false,
|
68 |
+
'add_customvars_box' => false,
|
69 |
+
'add_download_extensions' => '',
|
70 |
+
'disable_cookies' => false,
|
71 |
+
'limit_cookies' => false,
|
72 |
+
'limit_cookies_visitor' => 1209600,
|
73 |
+
'limit_cookies_session' => 0,
|
74 |
+
'track_admin' => false,
|
75 |
+
'capability_stealth' => array (),
|
76 |
+
'track_across' => false,
|
77 |
+
'track_across_alias' => false,
|
78 |
+
'track_feed' => false,
|
79 |
+
'track_feed_addcampaign' => false,
|
80 |
+
'track_feed_campaign' => 'feed',
|
81 |
+
// User settings: Expert configuration
|
82 |
+
'cache' => true,
|
83 |
+
'disable_timelimit' => false,
|
84 |
+
'connection_timeout' => 5,
|
85 |
+
'disable_ssl_verify' => false,
|
86 |
+
'piwik_useragent' => 'php',
|
87 |
+
'piwik_useragent_string' => 'WP-Piwik',
|
88 |
+
'track_datacfasync' => false,
|
89 |
+
'track_cdnurl' => '',
|
90 |
+
'track_cdnurlssl' => '',
|
91 |
+
'force_protocol' => 'disabled'
|
92 |
+
), $settings = array (
|
93 |
+
'name' => '',
|
94 |
+
'site_id' => NULL,
|
95 |
+
'noscript_code' => '',
|
96 |
+
'tracking_code' => '',
|
97 |
+
'last_tracking_code_update' => 0,
|
98 |
+
'dashboard_revision' => 0
|
99 |
+
), $settingsChanged = false;
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Constructor class to prepare settings manager
|
103 |
+
*
|
104 |
+
* @param WP_Piwik $wpPiwik
|
105 |
+
* active WP-Piwik instance
|
106 |
+
*/
|
107 |
+
public function __construct($wpPiwik) {
|
108 |
+
self::$wpPiwik = $wpPiwik;
|
109 |
+
self::$wpPiwik->log ( 'Store default settings' );
|
110 |
+
self::$defaultSettings = array (
|
111 |
+
'globalSettings' => $this->globalSettings,
|
112 |
+
'settings' => $this->settings
|
113 |
+
);
|
114 |
+
self::$wpPiwik->log ( 'Load settings' );
|
115 |
+
foreach ( $this->globalSettings as $key => $default ) {
|
116 |
+
$this->globalSettings [$key] = ($this->checkNetworkActivation () ? get_site_option ( 'wp-piwik_global-' . $key, $default ) : get_option ( 'wp-piwik_global-' . $key, $default ));
|
117 |
+
}
|
118 |
+
foreach ( $this->settings as $key => $default )
|
119 |
+
$this->settings [$key] = get_option ( 'wp-piwik-' . $key, $default );
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Save all settings as WordPress options
|
124 |
+
*/
|
125 |
+
public function save() {
|
126 |
+
if (! $this->settingsChanged) {
|
127 |
+
self::$wpPiwik->log ( 'No settings changed yet' );
|
128 |
+
return;
|
129 |
+
}
|
130 |
+
self::$wpPiwik->log ( 'Save settings' );
|
131 |
+
foreach ( $this->globalSettings as $key => $value ) {
|
132 |
+
if (is_plugin_active_for_network ( 'wp-piwik/wp-piwik.php' ))
|
133 |
+
update_site_option ( 'wp-piwik_global-' . $key, $value );
|
134 |
+
else
|
135 |
+
update_option ( 'wp-piwik_global-' . $key, $value );
|
136 |
+
}
|
137 |
+
foreach ( $this->settings as $key => $value ) {
|
138 |
+
update_option ( 'wp-piwik-' . $key, $value );
|
139 |
+
}
|
140 |
+
global $wp_roles;
|
141 |
+
if (! is_object ( $wp_roles ))
|
142 |
+
$wp_roles = new \WP_Roles ();
|
143 |
+
if (! is_object ( $wp_roles ))
|
144 |
+
die ( "STILL NO OBJECT" );
|
145 |
+
foreach ( $wp_roles->role_names as $strKey => $strName ) {
|
146 |
+
$objRole = get_role ( $strKey );
|
147 |
+
foreach ( array (
|
148 |
+
'stealth',
|
149 |
+
'read_stats'
|
150 |
+
) as $strCap ) {
|
151 |
+
$aryCaps = $this->getGlobalOption ( 'capability_' . $strCap );
|
152 |
+
if (isset ( $aryCaps [$strKey] ) && $aryCaps [$strKey])
|
153 |
+
$objRole->add_cap ( 'wp-piwik_' . $strCap );
|
154 |
+
else
|
155 |
+
$objRole->remove_cap ( 'wp-piwik_' . $strCap );
|
156 |
+
}
|
157 |
+
}
|
158 |
+
$this->settingsChanges = false;
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Get a global option's value
|
163 |
+
*
|
164 |
+
* @param string $key
|
165 |
+
* option key
|
166 |
+
* @return string option value
|
167 |
+
*/
|
168 |
+
public function getGlobalOption($key) {
|
169 |
+
return isset ( $this->globalSettings [$key] ) ? $this->globalSettings [$key] : self::$defaultSettings ['globalSettings'] [$key];
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Get an option's value related to a specific blog
|
174 |
+
*
|
175 |
+
* @param string $key
|
176 |
+
* option key
|
177 |
+
* @param int $blogID
|
178 |
+
* blog ID (default: current blog)
|
179 |
+
* @return \WP_Piwik\Register
|
180 |
+
*/
|
181 |
+
public function getOption($key, $blogID = null) {
|
182 |
+
if ($this->checkNetworkActivation () && ! empty ( $blogID )) {
|
183 |
+
return get_blog_option ( $blogID, $key );
|
184 |
+
}
|
185 |
+
return isset ( $this->settings [$key] ) ? $this->settings [$key] : self::$defaultSettings ['settings'] [$key];
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Set a global option's value
|
190 |
+
*
|
191 |
+
* @param string $key
|
192 |
+
* option key
|
193 |
+
* @param string $value
|
194 |
+
* new option value
|
195 |
+
*/
|
196 |
+
public function setGlobalOption($key, $value) {
|
197 |
+
$this->settingsChanged = true;
|
198 |
+
self::$wpPiwik->log ( 'Changed global option ' . $key . ': ' . (is_array ( $value ) ? serialize ( $value ) : $value) );
|
199 |
+
$this->globalSettings [$key] = $value;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Set an option's value related to a specific blog
|
204 |
+
*
|
205 |
+
* @param string $key
|
206 |
+
* option key
|
207 |
+
* @param int $blogID
|
208 |
+
* blog ID (default: current blog)
|
209 |
+
* @param string $value
|
210 |
+
* new option value
|
211 |
+
*/
|
212 |
+
public function setOption($key, $value, $blogID = null) {
|
213 |
+
$this->settingsChanged = true;
|
214 |
+
self::$wpPiwik->log ( 'Changed option ' . $key . ': ' . $value );
|
215 |
+
if ($this->checkNetworkActivation () && ! empty ( $blogID )) {
|
216 |
+
add_blog_option ( $blogID, $key, $value );
|
217 |
+
} else
|
218 |
+
$this->settings [$key] = $value;
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Reset settings to default
|
223 |
+
*
|
224 |
+
* @param bool $resetAll
|
225 |
+
* set to true to clear authentification settings, too
|
226 |
+
*/
|
227 |
+
public function resetSettings($resetAll = false) {
|
228 |
+
self::$wpPiwik->log ( 'Reset WP-Piwik settings' );
|
229 |
+
global $wpdb;
|
230 |
+
$keepSettings = array (
|
231 |
+
'piwik_token' => $this->getGlobalOption ( 'piwik_token' ),
|
232 |
+
'piwik_url' => $this->getGlobalOption ( 'piwik_url' ),
|
233 |
+
'piwik_path' => $this->getGlobalOption ( 'piwik_path' ),
|
234 |
+
'piwik_mode' => $this->getGlobalOption ( 'piwik_mode' )
|
235 |
+
);
|
236 |
+
if (is_plugin_active_for_network ( 'wp-piwik/wp-piwik.php' )) {
|
237 |
+
delete_site_option ( 'wp-piwik_global-settings' );
|
238 |
+
$blogs = $wpdb->get_results ( 'SELECT blog_id FROM ' . $wpdb->blogs . ' ORDER BY blog_id' );
|
239 |
+
foreach ( $blogs as $blog )
|
240 |
+
foreach ( $this->settings as $key => $value )
|
241 |
+
delete_blog_option ( $blog->blog_id, 'wp-piwik-' . $key );
|
242 |
+
if (! $resetAll)
|
243 |
+
update_site_option ( 'wp-piwik_global-settings', $keepSettings );
|
244 |
+
} else {
|
245 |
+
foreach ( $this->globalSettings as $key => $value )
|
246 |
+
delete_option ( 'wp-piwik_global-' . $key );
|
247 |
+
foreach ( $this->settings as $key => $value )
|
248 |
+
delete_option ( 'wp-piwik-' . $key );
|
249 |
+
}
|
250 |
+
$this->globalSettings = self::$defaultSettings ['globalSettings'];
|
251 |
+
$this->settings = self::$defaultSettings ['settings'];
|
252 |
+
if (! $resetAll) {
|
253 |
+
self::$wpPiwik->log ( 'Restore connection settings' );
|
254 |
+
foreach ( $keepSettings as $key => $value )
|
255 |
+
$this->setGlobalOption ( $key, $value );
|
256 |
+
}
|
257 |
+
$this->save ();
|
258 |
+
}
|
259 |
+
|
260 |
+
/**
|
261 |
+
* Check if plugin is network activated
|
262 |
+
*
|
263 |
+
* @return boolean Is network activated?
|
264 |
+
*/
|
265 |
+
public function checkNetworkActivation() {
|
266 |
+
if (! function_exists ( "is_plugin_active_for_network" ))
|
267 |
+
require_once (ABSPATH . 'wp-admin/includes/plugin.php');
|
268 |
+
return is_plugin_active_for_network ( 'wp-piwik/wp-piwik.php' );
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Apply new configuration
|
273 |
+
*
|
274 |
+
* @param array $in
|
275 |
+
* new configuration set
|
276 |
+
*/
|
277 |
+
public function applyChanges($in) {
|
278 |
+
$in = $this->checkSettings ( $in );
|
279 |
+
self::$wpPiwik->log ( 'Apply changed settings:' );
|
280 |
+
foreach ( self::$defaultSettings ['globalSettings'] as $key => $val )
|
281 |
+
$this->setGlobalOption ( $key, isset ( $in [$key] ) ? $in [$key] : $val );
|
282 |
+
foreach ( self::$defaultSettings ['settings'] as $key => $val )
|
283 |
+
$this->setOption ( $key, isset ( $in [$key] ) ? $in [$key] : $val );
|
284 |
+
$this->setGlobalOption ( 'last_settings_update', time () );
|
285 |
+
$this->save ();
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Apply callback function on new settings
|
290 |
+
*
|
291 |
+
* @param array $in
|
292 |
+
* new configuration set
|
293 |
+
* @return array configuration set after callback functions were applied
|
294 |
+
*/
|
295 |
+
private function checkSettings($in) {
|
296 |
+
foreach ( $this->checkSettings as $key => $value )
|
297 |
+
if (isset ( $in [$key] ) )
|
298 |
+
$in [$key] = call_user_func_array ( array (
|
299 |
+
$this,
|
300 |
+
$value
|
301 |
+
), array (
|
302 |
+
$in [$key],
|
303 |
+
$in
|
304 |
+
) );
|
305 |
+
return $in;
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* Add slash to Piwik URL if necessary
|
310 |
+
*
|
311 |
+
* @param string $value
|
312 |
+
* Piwik URL
|
313 |
+
* @param array $in
|
314 |
+
* configuration set
|
315 |
+
* @return string Piwik URL
|
316 |
+
*/
|
317 |
+
private function checkPiwikUrl($value, $in) {
|
318 |
+
return substr ( $value, - 1, 1 ) != '/' ? $value . '/' : $value;
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Remove &token_auth= from auth token
|
323 |
+
*
|
324 |
+
* @param string $value
|
325 |
+
* Piwik auth token
|
326 |
+
* @param array $in
|
327 |
+
* configuration set
|
328 |
+
* @return string Piwik auth token
|
329 |
+
*/
|
330 |
+
private function checkPiwikToken($value, $in) {
|
331 |
+
return str_replace ( '&token_auth=', '', $value );
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Prepare the tracking code
|
336 |
+
*
|
337 |
+
* @param string $value
|
338 |
+
* tracking code
|
339 |
+
* @param array $in
|
340 |
+
* configuration set
|
341 |
+
* @return string tracking code
|
342 |
+
*/
|
343 |
+
private function prepareTrackingCode($value, $in) {
|
344 |
+
if ($in ['track_mode'] == 'manually' || $in ['track_mode'] == 'disabled') {
|
345 |
+
$value = stripslashes ( $value );
|
346 |
+
return $value;
|
347 |
+
}
|
348 |
+
$result = self::$wpPiwik->updateTrackingCode ();
|
349 |
+
$this->setOption ( 'noscript_code', $result ['noscript'] );
|
350 |
+
return $result ['script'];
|
351 |
+
}
|
352 |
+
|
353 |
+
/**
|
354 |
+
* Prepare the nocscript code
|
355 |
+
*
|
356 |
+
* @param string $value
|
357 |
+
* noscript code
|
358 |
+
* @param array $in
|
359 |
+
* configuration set
|
360 |
+
* @return string noscript code
|
361 |
+
*/
|
362 |
+
private function prepareNocscriptCode($value, $in) {
|
363 |
+
if ($in ['track_mode'] == 'manually')
|
364 |
+
return stripslashes ( $value );
|
365 |
+
return $value;
|
366 |
+
}
|
367 |
+
}
|
classes/WP_Piwik/TrackingCode.php
CHANGED
@@ -4,16 +4,15 @@
|
|
4 |
|
5 |
class TrackingCode {
|
6 |
|
7 |
-
private static $wpPiwik;
|
8 |
private $trackingCode;
|
9 |
|
10 |
public $is404 = false, $isSearch = false;
|
11 |
|
12 |
public function __construct($wpPiwik) {
|
13 |
self::$wpPiwik = $wpPiwik;
|
14 |
-
if (!self::$wpPiwik->getOption('site_id') || !self::$wpPiwik->getOption('tracking_code'))
|
15 |
-
self::$wpPiwik->addPiwikSite();
|
16 |
if (!self::$wpPiwik->isCurrentTrackingCode()) {
|
|
|
17 |
self::$wpPiwik->updateTrackingCode();
|
18 |
}
|
19 |
$this->trackingCode = self::$wpPiwik->getOption('tracking_code');
|
@@ -29,18 +28,17 @@
|
|
29 |
public static function prepareTrackingCode($code, $settings, $logger) {
|
30 |
$logger->log('Apply tracking code changes:');
|
31 |
$settings->setOption('last_tracking_code_update', time());
|
32 |
-
|
33 |
if ($settings->getGlobalOption('track_mode') == 'js')
|
34 |
$code = str_replace(array('piwik.js', 'piwik.php'), 'js/index.php', $code);
|
35 |
elseif ($settings->getGlobalOption('track_mode') == 'proxy') {
|
36 |
$code = str_replace('piwik.js', 'piwik.php', $code);
|
37 |
-
$url = str_replace(array('https://', 'http://'), '//', $settings->getGlobalOption('piwik_url'));
|
38 |
$proxy = str_replace(array('https://', 'http://'), '//', plugins_url('wp-piwik').'/proxy').'/';
|
39 |
-
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
-
|
42 |
-
/*$strCode = str_replace('//";','/"',$strCode);*/
|
43 |
-
|
44 |
if ($settings->getGlobalOption('track_cdnurl') || $settings->getGlobalOption('track_cdnurlssl'))
|
45 |
$code = str_replace(array("var d=doc","g.src=u+"), array("var ucdn=(('https:' == document.location.protocol) ? 'https://".($settings->getGlobalOption('track_cdnurlssl')?$settings->getGlobalOption('track_cdnurlssl'):$settings->getGlobalOption('track_cdnurl'))."/' : 'http://".($settings->getGlobalOption('track_cdnurl')?$settings->getGlobalOption('track_cdnurl'):$settings->getGlobalOption('track_cdnurlssl'))."/');\nvar d=doc", "g.src=ucdn+"), $code);
|
46 |
|
4 |
|
5 |
class TrackingCode {
|
6 |
|
7 |
+
private static $wpPiwik, $piwikUrl = false;
|
8 |
private $trackingCode;
|
9 |
|
10 |
public $is404 = false, $isSearch = false;
|
11 |
|
12 |
public function __construct($wpPiwik) {
|
13 |
self::$wpPiwik = $wpPiwik;
|
|
|
|
|
14 |
if (!self::$wpPiwik->isCurrentTrackingCode()) {
|
15 |
+
self::$wpPiwik->getPiwikSiteId();
|
16 |
self::$wpPiwik->updateTrackingCode();
|
17 |
}
|
18 |
$this->trackingCode = self::$wpPiwik->getOption('tracking_code');
|
28 |
public static function prepareTrackingCode($code, $settings, $logger) {
|
29 |
$logger->log('Apply tracking code changes:');
|
30 |
$settings->setOption('last_tracking_code_update', time());
|
|
|
31 |
if ($settings->getGlobalOption('track_mode') == 'js')
|
32 |
$code = str_replace(array('piwik.js', 'piwik.php'), 'js/index.php', $code);
|
33 |
elseif ($settings->getGlobalOption('track_mode') == 'proxy') {
|
34 |
$code = str_replace('piwik.js', 'piwik.php', $code);
|
|
|
35 |
$proxy = str_replace(array('https://', 'http://'), '//', plugins_url('wp-piwik').'/proxy').'/';
|
36 |
+
if ( preg_match('/var u="([^"]*)";/', $code, $hits) ) {
|
37 |
+
$settings->setGlobalOption('proxy_url', $hits[1]);
|
38 |
+
}
|
39 |
+
$code = preg_replace('/var u="([^"]*)";/','var u="'.$proxy.'"',$code);
|
40 |
+
$code = preg_replace('/img src="([^"]*)piwik.php/','img src="'.$proxy.'piwik.php',$code);
|
41 |
}
|
|
|
|
|
|
|
42 |
if ($settings->getGlobalOption('track_cdnurl') || $settings->getGlobalOption('track_cdnurlssl'))
|
43 |
$code = str_replace(array("var d=doc","g.src=u+"), array("var ucdn=(('https:' == document.location.protocol) ? 'https://".($settings->getGlobalOption('track_cdnurlssl')?$settings->getGlobalOption('track_cdnurlssl'):$settings->getGlobalOption('track_cdnurl'))."/' : 'http://".($settings->getGlobalOption('track_cdnurl')?$settings->getGlobalOption('track_cdnurl'):$settings->getGlobalOption('track_cdnurlssl'))."/');\nvar d=doc", "g.src=ucdn+"), $code);
|
44 |
|
classes/WP_Piwik/Widget.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
|
7 |
protected static $wpPiwik, $settings;
|
8 |
|
9 |
-
protected $isShortcode = false, $method = '', $title = '', $context = 'side', $priority = 'core', $parameter = array(), $apiID = array(), $pageId = 'dashboard', $name = 'Value', $limit = 10;
|
10 |
|
11 |
public function __construct($wpPiwik, $settings, $pageId = 'dashboard', $context = 'side', $priority = 'default', $params = array(), $isShortcode = false) {
|
12 |
self::$wpPiwik = $wpPiwik;
|
@@ -14,6 +14,11 @@
|
|
14 |
$this->pageId = $pageId;
|
15 |
$this->context = $context;
|
16 |
$this->priority = $priority;
|
|
|
|
|
|
|
|
|
|
|
17 |
$this->isShortcode = $isShortcode;
|
18 |
$prefix = ($this->pageId=='dashboard'?self::$settings->getGlobalOption('plugin_display_name').' - ':'');
|
19 |
$this->configure($prefix, $params);
|
@@ -68,53 +73,52 @@
|
|
68 |
}
|
69 |
}
|
70 |
|
71 |
-
protected function
|
72 |
-
return floor($time/3600).'h '.floor(($time % 3600)/60).'m '.floor(($time % 3600)%60).'s';
|
73 |
-
}
|
74 |
-
|
75 |
-
protected function table($thead, $tbody = array(), $tfoot = array()) {
|
76 |
echo '<div class="table"><table class="widefat wp-piwik-table">';
|
77 |
if ($this->isShortcode && $this->title)
|
78 |
echo '<tr><th colspan="10">'.$this->title.'</th></tr>';
|
79 |
-
if (!empty($thead)) $this->tabHead($thead);
|
80 |
-
if (!empty($tbody))
|
81 |
-
|
|
|
|
|
|
|
82 |
echo '</table></div>';
|
83 |
}
|
84 |
|
85 |
-
private function tabHead($thead) {
|
86 |
-
echo '<thead><tr>';
|
87 |
$count = 0;
|
88 |
foreach ($thead as $value)
|
89 |
-
echo '<th'.($count++?'
|
90 |
echo '</tr></thead>';
|
91 |
}
|
92 |
|
93 |
-
private function tabBody($tbody) {
|
94 |
-
echo '<tbody>';
|
95 |
-
foreach ($tbody as $trow)
|
96 |
-
$this->tabRow($trow);
|
97 |
echo '</tbody>';
|
98 |
}
|
99 |
|
100 |
-
private function tabFoot($tfoot) {
|
101 |
-
echo '<tfoot><tr>';
|
102 |
$count = 0;
|
103 |
foreach ($tfoot as $value)
|
104 |
-
echo '<td'.($count++?'
|
105 |
echo '</tr></tfoot>';
|
106 |
}
|
107 |
|
108 |
-
private function tabRow($trow) {
|
109 |
-
echo '<tr>';
|
110 |
$count = 0;
|
111 |
foreach ($trow as $tcell)
|
112 |
-
echo '<td'.($count++?'
|
113 |
echo '</tr>';
|
114 |
}
|
115 |
|
116 |
protected function getTimeSettings() {
|
117 |
-
switch (self::$settings->getGlobalOption('default_date')) {
|
118 |
case 'today':
|
119 |
$period = 'day';
|
120 |
$date = 'today';
|
@@ -148,7 +152,42 @@
|
|
148 |
default:
|
149 |
break;
|
150 |
}
|
151 |
-
return array('period' => $period, 'date' => $date, 'description' => $description);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
}
|
153 |
|
154 |
public function getName() {
|
6 |
|
7 |
protected static $wpPiwik, $settings;
|
8 |
|
9 |
+
protected $isShortcode = false, $method = '', $title = '', $context = 'side', $priority = 'core', $parameter = array(), $apiID = array(), $pageId = 'dashboard', $blogId = null, $name = 'Value', $limit = 10;
|
10 |
|
11 |
public function __construct($wpPiwik, $settings, $pageId = 'dashboard', $context = 'side', $priority = 'default', $params = array(), $isShortcode = false) {
|
12 |
self::$wpPiwik = $wpPiwik;
|
14 |
$this->pageId = $pageId;
|
15 |
$this->context = $context;
|
16 |
$this->priority = $priority;
|
17 |
+
if (self::$settings->checkNetworkActivation() && function_exists('is_super_admin') && is_super_admin() && isset($_GET['wpmu_show_stats'])) {
|
18 |
+
switch_to_blog((int) $_GET['wpmu_show_stats']);
|
19 |
+
$this->blogId = get_current_blog_id();
|
20 |
+
restore_current_blog();
|
21 |
+
}
|
22 |
$this->isShortcode = $isShortcode;
|
23 |
$prefix = ($this->pageId=='dashboard'?self::$settings->getGlobalOption('plugin_display_name').' - ':'');
|
24 |
$this->configure($prefix, $params);
|
73 |
}
|
74 |
}
|
75 |
|
76 |
+
protected function table($thead, $tbody = array(), $tfoot = array(), $class = false, $javaScript = array()) {
|
|
|
|
|
|
|
|
|
77 |
echo '<div class="table"><table class="widefat wp-piwik-table">';
|
78 |
if ($this->isShortcode && $this->title)
|
79 |
echo '<tr><th colspan="10">'.$this->title.'</th></tr>';
|
80 |
+
if (!empty($thead)) $this->tabHead($thead, $class);
|
81 |
+
if (!empty($tbody))
|
82 |
+
$this->tabBody($tbody, $class, $javaScript);
|
83 |
+
else
|
84 |
+
echo '<tr><td colspan="10">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
85 |
+
if (!empty($tfoot)) $this->tabFoot($tfoot, $class);
|
86 |
echo '</table></div>';
|
87 |
}
|
88 |
|
89 |
+
private function tabHead($thead, $class = false) {
|
90 |
+
echo '<thead'.($class?' class="'.$class.'"':'').'><tr>';
|
91 |
$count = 0;
|
92 |
foreach ($thead as $value)
|
93 |
+
echo '<th'.($count++?' class="right"':'').'>'.$value.'</th>';
|
94 |
echo '</tr></thead>';
|
95 |
}
|
96 |
|
97 |
+
private function tabBody($tbody, $class = false, $javaScript = array()) {
|
98 |
+
echo '<tbody'.($class?' class="'.$class.'"':'').'>';
|
99 |
+
foreach ($tbody as $key => $trow)
|
100 |
+
$this->tabRow($trow, $key, $javaScript);
|
101 |
echo '</tbody>';
|
102 |
}
|
103 |
|
104 |
+
private function tabFoot($tfoot, $class = false) {
|
105 |
+
echo '<tfoot'.($class?' class="'.$class.'"':'').'><tr>';
|
106 |
$count = 0;
|
107 |
foreach ($tfoot as $value)
|
108 |
+
echo '<td'.($count++?' class="right"':'').'>'.$value.'</td>';
|
109 |
echo '</tr></tfoot>';
|
110 |
}
|
111 |
|
112 |
+
private function tabRow($trow, $key = 0, $javaScript = array()) {
|
113 |
+
echo '<tr'.(isset($javaScript[$key])?' onclick="'.$javaScript[$key].'"':'').'>';
|
114 |
$count = 0;
|
115 |
foreach ($trow as $tcell)
|
116 |
+
echo '<td'.($count++?' class="right"':'').'>'.$tcell.'</td>';
|
117 |
echo '</tr>';
|
118 |
}
|
119 |
|
120 |
protected function getTimeSettings() {
|
121 |
+
switch (self::$settings->getGlobalOption('default_date')) {
|
122 |
case 'today':
|
123 |
$period = 'day';
|
124 |
$date = 'today';
|
152 |
default:
|
153 |
break;
|
154 |
}
|
155 |
+
return array('period' => $period, 'date' => isset($_GET['date'])?(int)$_GET['date']:$date, 'description' => isset($_GET['date'])?$this->dateFormat($_GET['date'], $period):$description);
|
156 |
+
}
|
157 |
+
|
158 |
+
protected function dateFormat($date, $period = 'day') {
|
159 |
+
$prefix = '';
|
160 |
+
switch ($period) {
|
161 |
+
case 'week':
|
162 |
+
$prefix = __('week', 'wp-piwik').' ';
|
163 |
+
$format = 'W/Y';
|
164 |
+
break;
|
165 |
+
case 'short_week':
|
166 |
+
$format = 'W';
|
167 |
+
break;
|
168 |
+
case 'month':
|
169 |
+
$format = 'F Y';
|
170 |
+
$date = date('Y-m-d', strtotime($date));
|
171 |
+
break;
|
172 |
+
default:
|
173 |
+
$format = get_option( 'date_format' );
|
174 |
+
}
|
175 |
+
return $prefix.date_i18n( $format, strtotime( $date ) );
|
176 |
+
}
|
177 |
+
|
178 |
+
protected function timeFormat($time) {
|
179 |
+
return floor($time/3600).'h '.floor(($time % 3600)/60).'m '.floor(($time % 3600)%60).'s';
|
180 |
+
}
|
181 |
+
|
182 |
+
public function rangeName() {
|
183 |
+
switch ($this->parameter['date']) {
|
184 |
+
case 'last30':
|
185 |
+
return 'last 30 days';
|
186 |
+
case 'last12':
|
187 |
+
return 'last 12 '.$this->parameter['period'].'s';
|
188 |
+
default:
|
189 |
+
return $this->parameter['date'];
|
190 |
+
}
|
191 |
}
|
192 |
|
193 |
public function getName() {
|
classes/WP_Piwik/Widget/BrowserDetails.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
-
'idSite' => self::$
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
@@ -30,6 +30,7 @@
|
|
30 |
|
31 |
public function show() {
|
32 |
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
|
|
33 |
if (!empty($response['result']) && $response['result'] ='error')
|
34 |
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
35 |
else {
|
@@ -54,7 +55,7 @@
|
|
54 |
foreach ($tableBody as $key => $row)
|
55 |
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
56 |
|
57 |
-
$this->pieChart($tableBody);
|
58 |
$this->table($tableHead, $tableBody, null);
|
59 |
}
|
60 |
}
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
+
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
30 |
|
31 |
public function show() {
|
32 |
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
33 |
+
$tableBody = array();
|
34 |
if (!empty($response['result']) && $response['result'] ='error')
|
35 |
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
36 |
else {
|
55 |
foreach ($tableBody as $key => $row)
|
56 |
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
57 |
|
58 |
+
if (!empty($tableBody)) $this->pieChart($tableBody);
|
59 |
$this->table($tableHead, $tableBody, null);
|
60 |
}
|
61 |
}
|
classes/WP_Piwik/Widget/Browsers.php
CHANGED
@@ -7,9 +7,9 @@
|
|
7 |
public $className = __CLASS__;
|
8 |
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
-
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
-
'idSite' => self::$
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
@@ -30,6 +30,7 @@
|
|
30 |
|
31 |
public function show() {
|
32 |
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
|
|
33 |
if (!empty($response['result']) && $response['result'] ='error')
|
34 |
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
35 |
else {
|
@@ -54,7 +55,7 @@
|
|
54 |
foreach ($tableBody as $key => $row)
|
55 |
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
56 |
|
57 |
-
$this->pieChart($tableBody);
|
58 |
$this->table($tableHead, $tableBody, null);
|
59 |
}
|
60 |
}
|
7 |
public $className = __CLASS__;
|
8 |
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
+
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
+
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
30 |
|
31 |
public function show() {
|
32 |
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
33 |
+
$tableBody = array();
|
34 |
if (!empty($response['result']) && $response['result'] ='error')
|
35 |
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
36 |
else {
|
55 |
foreach ($tableBody as $key => $row)
|
56 |
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
57 |
|
58 |
+
if (!empty($tableBody)) $this->pieChart($tableBody);
|
59 |
$this->table($tableHead, $tableBody, null);
|
60 |
}
|
61 |
}
|
classes/WP_Piwik/Widget/Chart.php
CHANGED
@@ -7,13 +7,14 @@
|
|
7 |
public $className = __CLASS__;
|
8 |
|
9 |
protected function configure($prefix = '', $params = array()) {
|
|
|
10 |
$this->parameter = array(
|
11 |
-
'idSite' => self::$
|
12 |
-
'period' => '
|
13 |
-
'date' => '
|
14 |
'limit' => null
|
15 |
);
|
16 |
-
$this->title = $prefix.__('
|
17 |
$this->method = array('VisitsSummary.getVisits', 'VisitsSummary.getUniqueVisitors', 'VisitsSummary.getBounceCount', 'VisitsSummary.getActions');
|
18 |
$this->context = 'normal';
|
19 |
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
@@ -47,7 +48,11 @@
|
|
47 |
$values .= $value.',';
|
48 |
$unique .= $response['VisitsSummary.getUniqueVisitors'][$date].',';
|
49 |
$bounced .= $response['VisitsSummary.getBounceCount'][$date].',';
|
50 |
-
$
|
|
|
|
|
|
|
|
|
51 |
$uniqueSum += $response['VisitsSummary.getActions'][$date];
|
52 |
}
|
53 |
else {
|
@@ -61,7 +66,7 @@
|
|
61 |
$unique = substr($unique, 0, -1);
|
62 |
$labels = substr($labels, 0, -1);
|
63 |
$bounced = substr($bounced, 0, -1);
|
64 |
-
echo '<div id="wp-piwik_stats_vistors_graph" style="height:220px;"></div>';
|
65 |
echo '<script type="text/javascript">';
|
66 |
echo '$j.jqplot("wp-piwik_stats_vistors_graph", [['.$values.'],['.$unique.'],['.$bounced.']],{axes:{yaxis:{min:0, tickOptions:{formatString:"%.0f"}},xaxis:{min:1,max:30,ticks:['.$labels.']}},seriesDefaults:{showMarker:false,lineWidth:1,fill:true,fillAndStroke:true,fillAlpha:0.9,trendline:{show:false,color:"#C00",lineWidth:1.5,type:"exp"}},series:[{color:"#90AAD9",fillColor:"#D4E2ED"},{color:"#A3BCEA",fillColor:"#E4F2FD",trendline:{show:true,label:"Unique visitor trend"}},{color:"#E9A0BA",fillColor:"#FDE4F2"}],});';
|
67 |
echo '</script>';
|
7 |
public $className = __CLASS__;
|
8 |
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
+
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
+
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
13 |
+
'period' => isset($params['period'])?$params['period']:$timeSettings['period'],
|
14 |
+
'date' => 'last'.($timeSettings['period']=='day'?'30':'12'),
|
15 |
'limit' => null
|
16 |
);
|
17 |
+
$this->title = $prefix.__('Visitors', 'wp-piwik').' ('.__($this->rangeName(),'wp-piwik').')';
|
18 |
$this->method = array('VisitsSummary.getVisits', 'VisitsSummary.getUniqueVisitors', 'VisitsSummary.getBounceCount', 'VisitsSummary.getActions');
|
19 |
$this->context = 'normal';
|
20 |
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
48 |
$values .= $value.',';
|
49 |
$unique .= $response['VisitsSummary.getUniqueVisitors'][$date].',';
|
50 |
$bounced .= $response['VisitsSummary.getBounceCount'][$date].',';
|
51 |
+
if ($this->parameter['period'] == 'week') {
|
52 |
+
preg_match("/[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/", $date, $dateList);
|
53 |
+
$textKey = $this->dateFormat($dateList[0], 'short_week');
|
54 |
+
} else $textKey = substr($date, -2);
|
55 |
+
$labels .= '['.$count.',"'.$textKey.'"],';
|
56 |
$uniqueSum += $response['VisitsSummary.getActions'][$date];
|
57 |
}
|
58 |
else {
|
66 |
$unique = substr($unique, 0, -1);
|
67 |
$labels = substr($labels, 0, -1);
|
68 |
$bounced = substr($bounced, 0, -1);
|
69 |
+
echo '<div id="wp-piwik_stats_vistors_graph" style="height:220px;" title="'.__('The graph contains the values shown in the table below (visitors / unique / bounces). The red line show a linear trendline (unique).', 'wp-piwik').'"></div>';
|
70 |
echo '<script type="text/javascript">';
|
71 |
echo '$j.jqplot("wp-piwik_stats_vistors_graph", [['.$values.'],['.$unique.'],['.$bounced.']],{axes:{yaxis:{min:0, tickOptions:{formatString:"%.0f"}},xaxis:{min:1,max:30,ticks:['.$labels.']}},seriesDefaults:{showMarker:false,lineWidth:1,fill:true,fillAndStroke:true,fillAlpha:0.9,trendline:{show:false,color:"#C00",lineWidth:1.5,type:"exp"}},series:[{color:"#90AAD9",fillColor:"#D4E2ED"},{color:"#A3BCEA",fillColor:"#E4F2FD",trendline:{show:true,label:"Unique visitor trend"}},{color:"#E9A0BA",fillColor:"#FDE4F2"}],});';
|
72 |
echo '</script>';
|
classes/WP_Piwik/Widget/Keywords.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
-
'idSite' => self::$
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
+
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
classes/WP_Piwik/Widget/Noresult.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
-
'idSite' => self::$
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
+
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
classes/WP_Piwik/Widget/Overview.php
CHANGED
@@ -7,13 +7,14 @@
|
|
7 |
public $className = __CLASS__;
|
8 |
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
-
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
-
'idSite' => self::$
|
13 |
'period' => isset($params['period'])?$params['period']:$timeSettings['period'],
|
14 |
'date' => isset($params['date'])?$params['date']: $timeSettings['date'],
|
|
|
15 |
);
|
16 |
-
$this->title = !$this->isShortcode?$prefix.__('Overview', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')':($params['title']?$params['title']:'');
|
17 |
$this->method = 'VisitsSummary.get';
|
18 |
}
|
19 |
|
@@ -22,6 +23,16 @@
|
|
22 |
if (!empty($response['result']) && $response['result'] ='error')
|
23 |
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
24 |
else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
$time = isset($response['sum_visit_length'])?$this->timeFormat($response['sum_visit_length']):'-';
|
26 |
$avgTime = isset($response['avg_time_on_site'])?$this->timeFormat($response['avg_time_on_site']):'-';
|
27 |
$tableHead = null;
|
@@ -29,11 +40,11 @@
|
|
29 |
array(__('Visitors', 'wp-piwik').':', $this->value($response, 'nb_visits')),
|
30 |
array(__('Unique visitors', 'wp-piwik').':', $this->value($response, 'nb_uniq_visitors')),
|
31 |
array(__('Page views', 'wp-piwik').':', $this->value($response, 'nb_actions').' (Ø '.$this->value($response, 'nb_actions_per_visit').')'),
|
32 |
-
array(__('Max. page views in one visit', 'wp-piwik').':', $this->value($response, 'max_actions')),
|
33 |
array(__('Total time spent', 'wp-piwik').':', $time),
|
34 |
-
array(__('Time/visit', 'wp-piwik').':', $avgTime),
|
35 |
array(__('Bounce count', 'wp-piwik').':', $this->value($response, 'bounce_count').' ('.$this->value($response, 'bounce_rate').')')
|
36 |
-
);
|
|
|
|
|
37 |
$tableFoot = (self::$settings->getGlobalOption('piwik_shortcut')?array(__('Shortcut', 'wp-piwik').':', '<a href="'.self::$settings->getGlobalOption('piwik_url').'">Piwik</a>'.(isset($aryConf['inline']) && $aryConf['inline']?' - <a href="?page=wp-piwik_stats">WP-Piwik</a>':'')):null);
|
38 |
$this->table($tableHead, $tableBody, $tableFoot);
|
39 |
}
|
7 |
public $className = __CLASS__;
|
8 |
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
+
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
+
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
13 |
'period' => isset($params['period'])?$params['period']:$timeSettings['period'],
|
14 |
'date' => isset($params['date'])?$params['date']: $timeSettings['date'],
|
15 |
+
'description' => $timeSettings['description']
|
16 |
);
|
17 |
+
$this->title = !$this->isShortcode?$prefix.__('Overview', 'wp-piwik').' ('.__($this->pageId == 'dashboard'?$this->rangeName():$timeSettings['description'],'wp-piwik').')':($params['title']?$params['title']:'');
|
18 |
$this->method = 'VisitsSummary.get';
|
19 |
}
|
20 |
|
23 |
if (!empty($response['result']) && $response['result'] ='error')
|
24 |
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
25 |
else {
|
26 |
+
if ($this->parameter['date'] == 'last30') {
|
27 |
+
$result = array();
|
28 |
+
foreach ($response as $data)
|
29 |
+
foreach ($data as $key => $value)
|
30 |
+
if (isset($result[$key]))
|
31 |
+
$result[$key] += $value;
|
32 |
+
else
|
33 |
+
$result[$key] = $value;
|
34 |
+
$response = $result;
|
35 |
+
}
|
36 |
$time = isset($response['sum_visit_length'])?$this->timeFormat($response['sum_visit_length']):'-';
|
37 |
$avgTime = isset($response['avg_time_on_site'])?$this->timeFormat($response['avg_time_on_site']):'-';
|
38 |
$tableHead = null;
|
40 |
array(__('Visitors', 'wp-piwik').':', $this->value($response, 'nb_visits')),
|
41 |
array(__('Unique visitors', 'wp-piwik').':', $this->value($response, 'nb_uniq_visitors')),
|
42 |
array(__('Page views', 'wp-piwik').':', $this->value($response, 'nb_actions').' (Ø '.$this->value($response, 'nb_actions_per_visit').')'),
|
|
|
43 |
array(__('Total time spent', 'wp-piwik').':', $time),
|
|
|
44 |
array(__('Bounce count', 'wp-piwik').':', $this->value($response, 'bounce_count').' ('.$this->value($response, 'bounce_rate').')')
|
45 |
+
);
|
46 |
+
if ($this->parameter['date'] != 'last30')
|
47 |
+
array_push($tableBody, array(__('Time/visit', 'wp-piwik').':', $avgTime), array(__('Max. page views in one visit', 'wp-piwik').':', $this->value($response, 'max_actions')));
|
48 |
$tableFoot = (self::$settings->getGlobalOption('piwik_shortcut')?array(__('Shortcut', 'wp-piwik').':', '<a href="'.self::$settings->getGlobalOption('piwik_url').'">Piwik</a>'.(isset($aryConf['inline']) && $aryConf['inline']?' - <a href="?page=wp-piwik_stats">WP-Piwik</a>':'')):null);
|
49 |
$this->table($tableHead, $tableBody, $tableFoot);
|
50 |
}
|
classes/WP_Piwik/Widget/Pages.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
-
'idSite' => self::$
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
+
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
classes/WP_Piwik/Widget/Plugins.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
-
'idSite' => self::$
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
+
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
classes/WP_Piwik/Widget/Post.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
global $post;
|
11 |
$this->parameter = array(
|
12 |
-
'idSite' => self::$
|
13 |
'period' => 'range',
|
14 |
'date' => isset($params['range'])?$params['range']:'last30',
|
15 |
'key' => isset($params['key'])?$params['key']:null,
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
global $post;
|
11 |
$this->parameter = array(
|
12 |
+
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
13 |
'period' => 'range',
|
14 |
'date' => isset($params['range'])?$params['range']:'last30',
|
15 |
'key' => isset($params['key'])?$params['key']:null,
|
classes/WP_Piwik/Widget/Referrers.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
-
'idSite' => self::$
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
+
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
classes/WP_Piwik/Widget/Screens.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
-
'idSite' => self::$
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
@@ -30,6 +30,7 @@
|
|
30 |
|
31 |
public function show() {
|
32 |
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
|
|
33 |
if (!empty($response['result']) && $response['result'] ='error')
|
34 |
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
35 |
else {
|
@@ -54,7 +55,7 @@
|
|
54 |
foreach ($tableBody as $key => $row)
|
55 |
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
56 |
|
57 |
-
$this->pieChart($tableBody);
|
58 |
$this->table($tableHead, $tableBody, null);
|
59 |
}
|
60 |
}
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
+
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
30 |
|
31 |
public function show() {
|
32 |
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
33 |
+
$tableBody = array();
|
34 |
if (!empty($response['result']) && $response['result'] ='error')
|
35 |
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
36 |
else {
|
55 |
foreach ($tableBody as $key => $row)
|
56 |
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
57 |
|
58 |
+
if (!empty($tableBody)) $this->pieChart($tableBody);
|
59 |
$this->table($tableHead, $tableBody, null);
|
60 |
}
|
61 |
}
|
classes/WP_Piwik/Widget/Search.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
-
'idSite' => self::$
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
+
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
13 |
'period' => $timeSettings['period'],
|
14 |
'date' => $timeSettings['date']
|
15 |
);
|
classes/WP_Piwik/Widget/Systems.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
protected function configure($prefix = '', $params = array()) {
|
8 |
$timeSettings = $this->getTimeSettings();
|
9 |
$this->parameter = array(
|
10 |
-
'idSite' => self::$
|
11 |
'period' => $timeSettings['period'],
|
12 |
'date' => $timeSettings['date']
|
13 |
);
|
@@ -28,6 +28,7 @@
|
|
28 |
|
29 |
public function show() {
|
30 |
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
|
|
31 |
if (!empty($response['result']) && $response['result'] ='error')
|
32 |
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
33 |
else {
|
@@ -52,7 +53,7 @@
|
|
52 |
foreach ($tableBody as $key => $row)
|
53 |
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
54 |
|
55 |
-
$this->pieChart($tableBody);
|
56 |
$this->table($tableHead, $tableBody, null);
|
57 |
}
|
58 |
}
|
7 |
protected function configure($prefix = '', $params = array()) {
|
8 |
$timeSettings = $this->getTimeSettings();
|
9 |
$this->parameter = array(
|
10 |
+
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
11 |
'period' => $timeSettings['period'],
|
12 |
'date' => $timeSettings['date']
|
13 |
);
|
28 |
|
29 |
public function show() {
|
30 |
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
31 |
+
$tableBody = array();
|
32 |
if (!empty($response['result']) && $response['result'] ='error')
|
33 |
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
34 |
else {
|
53 |
foreach ($tableBody as $key => $row)
|
54 |
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
55 |
|
56 |
+
if (!empty($tableBody)) $this->pieChart($tableBody);
|
57 |
$this->table($tableHead, $tableBody, null);
|
58 |
}
|
59 |
}
|
classes/WP_Piwik/Widget/Visitors.php
CHANGED
@@ -7,13 +7,14 @@
|
|
7 |
public $className = __CLASS__;
|
8 |
|
9 |
protected function configure($prefix = '', $params = array()) {
|
|
|
10 |
$this->parameter = array(
|
11 |
-
'idSite' => self::$
|
12 |
-
'period' => '
|
13 |
-
'date' => '
|
14 |
'limit' => null
|
15 |
);
|
16 |
-
$this->title = $prefix.__('Visitors', 'wp-piwik').' ('.__($this->
|
17 |
$this->method = array('VisitsSummary.getVisits', 'VisitsSummary.getUniqueVisitors', 'VisitsSummary.getBounceCount', 'VisitsSummary.getActions');
|
18 |
$this->context = 'normal';
|
19 |
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
@@ -34,17 +35,30 @@
|
|
34 |
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response[$method]['message'], ENT_QUOTES, 'utf-8');
|
35 |
else {
|
36 |
$data = array();
|
37 |
-
foreach ($response['VisitsSummary.getVisits'] as $key => $value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
$data[] = array(
|
39 |
-
$
|
40 |
$value,
|
41 |
$response['VisitsSummary.getUniqueVisitors'][$key]?$response['VisitsSummary.getUniqueVisitors'][$key]:'-',
|
42 |
$response['VisitsSummary.getBounceCount'][$key]?$response['VisitsSummary.getBounceCount'][$key]:'-',
|
43 |
$response['VisitsSummary.getActions'][$key]?$response['VisitsSummary.getActions'][$key]:'-'
|
44 |
);
|
|
|
|
|
45 |
$this->table(
|
46 |
array(__('Date', 'wp-piwik'), __('Visits', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Bounced', 'wp-piwik'), __('Page Views', 'wp-piwik')),
|
47 |
-
array_reverse($data)
|
|
|
|
|
|
|
48 |
);
|
49 |
}
|
50 |
|
7 |
public $className = __CLASS__;
|
8 |
|
9 |
protected function configure($prefix = '', $params = array()) {
|
10 |
+
$timeSettings = $this->getTimeSettings();
|
11 |
$this->parameter = array(
|
12 |
+
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
13 |
+
'period' => isset($params['period'])?$params['period']:$timeSettings['period'],
|
14 |
+
'date' => 'last'.($timeSettings['period']=='day'?'30':'12'),
|
15 |
'limit' => null
|
16 |
);
|
17 |
+
$this->title = $prefix.__('Visitors', 'wp-piwik').' ('.__($this->rangeName(),'wp-piwik').')';
|
18 |
$this->method = array('VisitsSummary.getVisits', 'VisitsSummary.getUniqueVisitors', 'VisitsSummary.getBounceCount', 'VisitsSummary.getActions');
|
19 |
$this->context = 'normal';
|
20 |
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
35 |
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response[$method]['message'], ENT_QUOTES, 'utf-8');
|
36 |
else {
|
37 |
$data = array();
|
38 |
+
foreach ($response['VisitsSummary.getVisits'] as $key => $value) {
|
39 |
+
if ($this->parameter['period'] == 'week') {
|
40 |
+
preg_match("/[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/", $key, $dateList);
|
41 |
+
$jsKey = $dateList[0];
|
42 |
+
$textKey = $this->dateFormat($jsKey, 'week');
|
43 |
+
} elseif ($this->parameter['period'] == 'month') {
|
44 |
+
$jsKey = $key.'-01';
|
45 |
+
$textKey = $key;
|
46 |
+
} else $jsKey = $textKey = $key;
|
47 |
$data[] = array(
|
48 |
+
$textKey,
|
49 |
$value,
|
50 |
$response['VisitsSummary.getUniqueVisitors'][$key]?$response['VisitsSummary.getUniqueVisitors'][$key]:'-',
|
51 |
$response['VisitsSummary.getBounceCount'][$key]?$response['VisitsSummary.getBounceCount'][$key]:'-',
|
52 |
$response['VisitsSummary.getActions'][$key]?$response['VisitsSummary.getActions'][$key]:'-'
|
53 |
);
|
54 |
+
$javaScript[] = 'javascript:wp_piwik_datelink(\''.urlencode('wp-piwik_stats').'\',\''.str_replace('-', '', $jsKey).'\',\''.(isset($_GET['wpmu_show_stats'])?(int) $_GET['wpmu_show_stats']:'').'\');';
|
55 |
+
}
|
56 |
$this->table(
|
57 |
array(__('Date', 'wp-piwik'), __('Visits', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Bounced', 'wp-piwik'), __('Page Views', 'wp-piwik')),
|
58 |
+
array_reverse($data),
|
59 |
+
array(),
|
60 |
+
'clickable',
|
61 |
+
array_reverse($javaScript)
|
62 |
);
|
63 |
}
|
64 |
|
css/wp-piwik.css
CHANGED
@@ -1,17 +1,8 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
font-weight:normal;
|
4 |
-
}
|
5 |
-
|
6 |
-
#wp-piwik_stats_vistors_graph{margin: 0 0 0 0}
|
7 |
-
|
8 |
-
p.wp-piwik-eyecatcher {
|
9 |
-
border:1px solid #c00;
|
10 |
-
background:#ff0;
|
11 |
-
padding:5px;
|
12 |
}
|
13 |
|
14 |
-
table.wp-piwik-table th.
|
15 |
text-align: right;
|
16 |
}
|
17 |
|
@@ -19,100 +10,10 @@ table.wp-piwik-table tr:hover {
|
|
19 |
background-color:#ccc;
|
20 |
}
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
}
|
25 |
-
|
26 |
-
table.wp-piwik-form-table {
|
27 |
-
clear:none !important;
|
28 |
-
}
|
29 |
-
table.wp-piwik-form-table-hide, label.wp-piwik-input-hide {
|
30 |
-
display:none;
|
31 |
-
}
|
32 |
-
|
33 |
-
input.wp-piwik-input-hide {
|
34 |
-
visibility:hidden;
|
35 |
-
}
|
36 |
-
|
37 |
-
div.wp-piwik-donate {
|
38 |
-
float:right;
|
39 |
-
width:220px;
|
40 |
-
background:#ffc;
|
41 |
-
padding:10px;
|
42 |
-
border:1px solid black;
|
43 |
-
margin-bottom:10px;
|
44 |
-
margin-top:10px;
|
45 |
-
}
|
46 |
-
|
47 |
-
div.wp-piwik-donate div {
|
48 |
-
width:190px;
|
49 |
-
text-align:center;
|
50 |
-
border:solid black;
|
51 |
-
border-width:1px 0 0 0 ;
|
52 |
-
padding:5px
|
53 |
-
}
|
54 |
-
|
55 |
-
div.wp-piwik-settings h4 {
|
56 |
-
float:left;
|
57 |
-
font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif !important;
|
58 |
-
font-size:12px !important;
|
59 |
-
font-weight:normal;
|
60 |
-
padding-top:0px !important;
|
61 |
-
text-align:right;
|
62 |
-
width:160px;
|
63 |
-
}
|
64 |
-
div.wp-piwik-settings h4 label {
|
65 |
-
margin-right:10px;
|
66 |
-
vertical-align:middle;
|
67 |
-
}
|
68 |
-
div.wp-piwik-settings .input-text-wrap input,
|
69 |
-
div.wp-piwik-settings .input-text-wrap select,
|
70 |
-
div.wp-piwik-settings .input-text-wrap textarea {
|
71 |
-
border:0 none;
|
72 |
-
color:#333333;
|
73 |
-
outline:medium none;
|
74 |
-
padding:0;
|
75 |
-
width:99%;
|
76 |
-
}
|
77 |
-
|
78 |
-
div.wp-piwik-settings .input-wrap {
|
79 |
-
padding-top:0px;
|
80 |
-
}
|
81 |
-
|
82 |
-
div.wp-piwik-settings .input-wrap input {
|
83 |
-
border:0 none;
|
84 |
-
color:#333333;
|
85 |
-
padding:0;
|
86 |
-
}
|
87 |
-
|
88 |
-
div.wp-piwik-settings .input-text-wrap {
|
89 |
-
margin:0 0 1em 160px;
|
90 |
-
border:1px solid #CCCCCC;
|
91 |
-
}
|
92 |
-
|
93 |
-
div.wp-piwik_desc {
|
94 |
-
font-size:11px;
|
95 |
-
margin:0 0 10px 160px;
|
96 |
-
padding:0;
|
97 |
-
}
|
98 |
-
|
99 |
-
div.wp-piwik_desc strong {
|
100 |
-
color:#f00;
|
101 |
-
}
|
102 |
-
|
103 |
-
strong.wp-piwik-error {color:#f00}
|
104 |
-
|
105 |
-
.wp-list-table .column-id {width:20%}
|
106 |
-
.wp-list-table .column-name {width:30%}
|
107 |
-
.wp-list-table .column-siteurl {width:30%}
|
108 |
-
.wp-list-table .column-piwikid {width:20%}
|
109 |
-
|
110 |
-
.wp-piwik_dynbar canvas {padding-top:5px !important}
|
111 |
-
|
112 |
-
.wp-piwik-wide-content {
|
113 |
-
width:512px !important;
|
114 |
}
|
115 |
|
116 |
-
|
117 |
overflow:hidden;
|
118 |
}
|
1 |
+
.wp-piwik-hidden {
|
2 |
+
display:none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
}
|
4 |
|
5 |
+
table.wp-piwik-table th.right, td.right {
|
6 |
text-align: right;
|
7 |
}
|
8 |
|
10 |
background-color:#ccc;
|
11 |
}
|
12 |
|
13 |
+
table.wp-piwik-table tbody.clickable {
|
14 |
+
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
|
17 |
+
#wp-piwik_stats_vistors_graph {
|
18 |
overflow:hidden;
|
19 |
}
|
js/wp-piwik.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-
function
|
2 |
window.location.href='index.php?page='+strPage+'&date='+strDate+'&wpmu_show_stats='+intSite;
|
3 |
}
|
1 |
+
function wp_piwik_datelink(strPage,strDate,intSite) {
|
2 |
window.location.href='index.php?page='+strPage+'&date='+strDate+'&wpmu_show_stats='+intSite;
|
3 |
}
|
proxy/config.php
CHANGED
@@ -1,14 +1,19 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
require('../../../../wp-load.php');
|
|
|
4 |
require_once('../classes/WP_Piwik/Settings.php');
|
5 |
require_once('../classes/WP_Piwik/Logger.php');
|
6 |
require_once('../classes/WP_Piwik/Logger/Dummy.php');
|
7 |
|
8 |
$logger = new WP_Piwik\Logger\Dummy(__CLASS__);
|
9 |
-
$settings = new WP_Piwik\Settings(
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
$PIWIK_URL = $settings->getGlobalOption('piwik_url');
|
12 |
$TOKEN_AUTH = $settings->getGlobalOption('piwik_token');
|
13 |
$timeout = $settings->getGlobalOption('connection_timeout');
|
14 |
-
|
|
1 |
<?php
|
|
|
2 |
require('../../../../wp-load.php');
|
3 |
+
|
4 |
require_once('../classes/WP_Piwik/Settings.php');
|
5 |
require_once('../classes/WP_Piwik/Logger.php');
|
6 |
require_once('../classes/WP_Piwik/Logger/Dummy.php');
|
7 |
|
8 |
$logger = new WP_Piwik\Logger\Dummy(__CLASS__);
|
9 |
+
$settings = new WP_Piwik\Settings($logger);
|
10 |
+
|
11 |
+
$PIWIK_URL = $settings->getGlobalOption('piwik_mode') == 'php'?$settings->getGlobalOption('proxy_url'):$settings->getGlobalOption('piwik_url');
|
12 |
+
|
13 |
+
if (substr($PIWIK_URL, 0, 2) == '//')
|
14 |
+
$PIWIK_URL = (isset($_SERVER['HTTPS'])?'https:':'http:').$PIWIK_URL;
|
15 |
|
|
|
16 |
$TOKEN_AUTH = $settings->getGlobalOption('piwik_token');
|
17 |
$timeout = $settings->getGlobalOption('connection_timeout');
|
18 |
+
|
19 |
+
ini_set('display_errors',1);
|
readme.txt
CHANGED
@@ -49,7 +49,7 @@ See section "Installation".
|
|
49 |
* Graphs powered by [jqPlot](http://www.jqplot.com/) (GPL 2.0 and MIT) and and [jQuery Sparklines](http://omnipotent.net/jquery.sparkline/) (New BSD License).
|
50 |
* Metabox support inspired by [Heiko Rabe's metabox demo plugin](http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins).
|
51 |
* Translation credits see plugin settings
|
52 |
-
* Donations: Marco L., Rolf W., Tobias U., Lars K., Donna F., Kevin D., Ramos S., Thomas M., John C., Andreas G., Ben M., Myra R. I., Carlos U. R.-S., Oleg I., M. N., Daniel K., James L., Jochen K., the Piwik team itself, and all people flattering this.
|
53 |
* All users who send me mails containing criticism, commendation, feature requests and bug reports - you help me to make WP-Piwik much better!
|
54 |
|
55 |
Thank you all!
|
49 |
* Graphs powered by [jqPlot](http://www.jqplot.com/) (GPL 2.0 and MIT) and and [jQuery Sparklines](http://omnipotent.net/jquery.sparkline/) (New BSD License).
|
50 |
* Metabox support inspired by [Heiko Rabe's metabox demo plugin](http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins).
|
51 |
* Translation credits see plugin settings
|
52 |
+
* Donations: Marco L., Rolf W., Tobias U., Lars K., Donna F., Kevin D., Ramos S., Thomas M., John C., Andreas G., Ben M., Myra R. I., Carlos U. R.-S., Oleg I., M. N., Daniel K., James L., Jochen K., Cyril P., Thomas K., the Piwik team itself, and all people flattering this.
|
53 |
* All users who send me mails containing criticism, commendation, feature requests and bug reports - you help me to make WP-Piwik much better!
|
54 |
|
55 |
Thank you all!
|
settings/credits.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<tr>
|
2 |
-
<td>
|
3 |
-
<strong><?php _e('Thank you very much for your donation', 'wp-piwik'); ?>:</strong> Marco L., Rolf W., Tobias U., Lars K., Donna F., Kevin D., Ramos S., Thomas M., John C., Andreas G., Ben M., Myra R. I., Carlos U. R.-S., Oleg I., M. N., Daniel K., James L., Jochen K., <?php _e('the Piwik team itself','wp-piwik');?><?php _e(', and all people flattering this','wp-piwik'); ?>!
|
4 |
-
</td>
|
5 |
-
</tr>
|
6 |
-
<tr>
|
7 |
-
<td>
|
8 |
-
<?php _e('Graphs powered by <a href="http://www.jqplot.com/">jqPlot</a> (License: GPL 2.0 and MIT) and <a href="http://omnipotent.net/jquery.sparkline/">jQuery Sparklines</a> (License: New BSD License).','wp-piwik'); ?>
|
9 |
-
</td>
|
10 |
-
</tr>
|
11 |
-
<tr>
|
12 |
-
<td>
|
13 |
-
<?php _e('Metabox support inspired by', 'wp-piwik'); echo ' <a href="http://www.code-styling.de/english/how-to-use-wordpress-metaboxes-at-own-plugins">Heiko Rabe\'s metabox demo plugin</a>.';?>
|
14 |
-
<?php _e('Tabbed settings page suggested by the', 'wp-piwik'); echo' <a href="http://wp.smashingmagazine.com/2011/10/20/create-tabs-wordpress-settings-pages/">Smashing Magazine</a>.';?>
|
15 |
-
</td>
|
16 |
-
</tr>
|
17 |
-
<tr>
|
18 |
-
<td>
|
19 |
-
<?php _e('Thank you very much','wp-piwik'); ?>, <a href="http://blogu.programeshqip.org/">Besnik Bleta</a>, <a href="http://www.fatcow.com/">FatCow</a>, <a href="http://www.pamukkaleturkey.com/">Rene</a>, Fab, <a href="http://ezbizniz.com/">EzBizNiz</a>, Gormer, Natalya, <a href="www.aggeliopolis.gr">AggelioPolis</a><?php _e(', and', 'wp-piwik'); ?> <a href="http://wwww.webhostinggeeks.com">Web Hosting Geeks</a>, <a href="http://www.webhostingrating.com">Web Hosting Rating</a>, <a href="http://www.webhostinghub.com">Nata Strazda (Web Hosting Hub)</a>, <a href="http://www.libreoffice.ir">Hossein, LibreOffice localization team</a>, <a href="http://www.vogliaditerra.com">Ste</a> & Chris <?php _e('for your translation work','wp-piwik'); ?>!
|
20 |
-
</td>
|
21 |
-
</tr>
|
22 |
-
<tr>
|
23 |
-
<td>
|
24 |
-
<?php _e('Thank you very much, all users who send me mails containing criticism, commendation, feature requests and bug reports! You help me to make WP-Piwik much better.','wp-piwik'); ?>
|
25 |
-
</td>
|
26 |
-
</tr>
|
27 |
-
<tr>
|
28 |
-
<td>
|
29 |
-
<?php _e('Thank <strong>you</strong> for using my plugin. It is the best commendation if my piece of code is really used!','wp-piwik'); ?>
|
30 |
-
</td>
|
31 |
-
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
settings/piwik.php
DELETED
@@ -1,123 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
$bolCURL = function_exists('curl_init');
|
3 |
-
$bolFOpen = ini_get('allow_url_fopen');
|
4 |
-
if (!$bolFOpen && !$bolCURL) {
|
5 |
-
?><tr>
|
6 |
-
<td colspan="2">
|
7 |
-
<strong><?php _e('Error: cURL is not enabled and fopen is not allowed to open URLs. WP-Piwik won\'t be able to connect to Piwik.'); ?></strong>
|
8 |
-
</td>
|
9 |
-
</tr><?php } else { ?><tr>
|
10 |
-
<td colspan="2">
|
11 |
-
<?php _e('To enable Piwik statistics, please enter', 'wp-piwik'); ?>:
|
12 |
-
<ol>
|
13 |
-
<li><?php _e('your Piwik base URL (like http://mydomain.com/piwik) or your Piwik server path (like /var/www/mydomain.com/httpdocs/piwik/)', 'wp-piwik'); ?></li>
|
14 |
-
<li><?php _e('your personal Piwik authentification token. You can get the token on the API page inside your Piwik interface. It looks like "1234a5cd6789e0a12345b678cd9012ef".', 'wp-piwik'); ?></li>
|
15 |
-
</ol>
|
16 |
-
<?php _e('No idea what I\'m talking about?', 'wp-piwik'); ?> <a href="http://peepbo.de/board/viewtopic.php?f=5&t=10"><?php _e('Get help.', 'wp-piwik'); ?></a>
|
17 |
-
<?php if (!is_plugin_active_for_network('wp-piwik/wp-piwik.php')) { ?>
|
18 |
-
<p><?php _e('<strong>Important note:</strong> If you do not host this blog on your own, your site admin is able to get your auth token from the database.', 'wp-piwik'); ?></p>
|
19 |
-
<?php } ?>
|
20 |
-
</td>
|
21 |
-
</tr><tr>
|
22 |
-
<th><?php _e('Piwik URL', 'wp-piwik'); ?> (REST API):</th>
|
23 |
-
<td>
|
24 |
-
<input type="radio" name="wp-piwik_mode" onchange="javascript:$j('#wp-piwik_path,#wp-piwik_url').toggleClass('wp-piwik-input-hide');" value="http" <?php echo (self::$settings->getGlobalOption('piwik_mode')=='http'?'checked="checked" ':''); ?>/>
|
25 |
-
<input <?php echo (self::$settings->getGlobalOption('piwik_mode')=='php'?'class="wp-piwik-input-hide" ':''); ?>id="wp-piwik_url" name="wp-piwik_url" type="text" value="<?php echo self::$settings->getGlobalOption('piwik_url'); ?>" />
|
26 |
-
</td>
|
27 |
-
</tr><tr>
|
28 |
-
<th><?php _e('Piwik path', 'wp-piwik'); ?> (PHP API, beta):</th>
|
29 |
-
<td>
|
30 |
-
<input type="radio" name="wp-piwik_mode" onchange="javascript:$j('#wp-piwik_path,#wp-piwik_url').toggleClass('wp-piwik-input-hide');" value="php" <?php echo (self::$settings->getGlobalOption('piwik_mode')=='php'?'checked="checked" ':''); ?>/>
|
31 |
-
<input <?php echo (self::$settings->getGlobalOption('piwik_mode')!='php'?'class="wp-piwik-input-hide" ':''); ?>id="wp-piwik_path" name="wp-piwik_path" type="text" value="<?php echo self::$settings->getGlobalOption('piwik_path'); ?>" />
|
32 |
-
<?php
|
33 |
-
if (isset($_POST['wp-piwik_path']) && !empty($_POST['wp-piwik_path']) && realpath($_POST['wp-piwik_path']) === false)
|
34 |
-
echo '<p class="wp-piwik-eyecatcher">'.__('Invalid path. Please enter the file path to Piwik.', 'wp-piwik').'</p>';
|
35 |
-
?>
|
36 |
-
</td>
|
37 |
-
</tr><tr>
|
38 |
-
<th><?php _e('Auth token', 'wp-piwik'); ?>:</th>
|
39 |
-
<td>
|
40 |
-
<input name="wp-piwik_token" id="wp-piwik_token" type="text" value="<?php echo self::$settings->getGlobalOption('piwik_token'); ?>" />
|
41 |
-
<label for="wp-piwik_token"></label>
|
42 |
-
</td>
|
43 |
-
</tr><tr><th><?php _e('Enable cache', 'wp-piwik'); ?>:</th><td>
|
44 |
-
<input type="checkbox" value="1" id="wp-piwik_cache" name="wp-piwik_cache"<?php echo (self::$settings->getGlobalOption('cache')?' checked="checked"':''); ?> />
|
45 |
-
<label for="wp-piwik_cache"><?php _e('Cache API calls, which not contain today\'s values, for a week', 'wp-piwik'); ?>.</label>
|
46 |
-
</td></tr>
|
47 |
-
|
48 |
-
<?php if (!is_plugin_active_for_network('wp-piwik/wp-piwik.php')) { ?><tr>
|
49 |
-
<th><?php _e('Auto config', 'wp-piwik'); ?>:</th>
|
50 |
-
<td>
|
51 |
-
<input name="wp-piwik_auto_site_config" id="wp-piwik_auto_site_config" value="1" type="checkbox"<?php echo (self::$settings->getGlobalOption('auto_site_config')?' checked="checked"':'') ?>/>
|
52 |
-
<label for="wp-piwik_auto_site_config"><?php _e('Check this to automatically choose your blog from your Piwik sites by URL. If your blog is not added to Piwik yet, WP-Piwik will add a new site.', 'wp-piwik') ?></label>
|
53 |
-
</td>
|
54 |
-
</tr>
|
55 |
-
<?php
|
56 |
-
if (self::$settings->getGlobalOption('piwik_url') && self::$settings->getGlobalOption('piwik_token')) {
|
57 |
-
$aryData = $this->callPiwikAPI('SitesManager.getSitesWithAtLeastViewAccess');
|
58 |
-
if (empty($aryData)) {
|
59 |
-
echo '<tr><td colspan="2">';
|
60 |
-
self::showErrorMessage(__('Please check URL and auth token. You need at least view access to one site.', 'wp-piwik'));
|
61 |
-
echo '</td></tr>';
|
62 |
-
}
|
63 |
-
elseif (isset($aryData['result']) && $aryData['result'] == 'error') {
|
64 |
-
echo '<tr><td colspan="2">';
|
65 |
-
self::showErrorMessage($aryData['message']);
|
66 |
-
echo '</td></tr>';
|
67 |
-
} elseif (!self::$settings->getGlobalOption('auto_site_config')) {
|
68 |
-
echo '<tr><th>'.__('Choose site', 'wp-piwik').':</th><td>';
|
69 |
-
echo '<select name="wp-piwik_siteid" id="wp-piwik_siteid">';
|
70 |
-
$aryOptions = array();
|
71 |
-
foreach ($aryData as $arySite)
|
72 |
-
$aryOptions[$arySite['name'].'#'.$arySite['idsite']] = '<option value="'.$arySite['idsite'].
|
73 |
-
'"'.($arySite['idsite']==self::$settings->getOption('site_id')?' selected="selected"':'').
|
74 |
-
'>'.htmlentities($arySite['name'], ENT_QUOTES, 'utf-8').
|
75 |
-
'</option>';
|
76 |
-
ksort($aryOptions);
|
77 |
-
foreach ($aryOptions as $strOption) echo $strOption;
|
78 |
-
echo '</select></td></tr>';
|
79 |
-
} else {
|
80 |
-
if (!self::$settings->getOption('site_id'))
|
81 |
-
$this->addPiwikSite();
|
82 |
-
echo '<tr><th>'.__('Determined site', 'wp-piwik').':</th><td>';
|
83 |
-
echo '<div class="input-text-wrap">';
|
84 |
-
$siteId = self::$settings->getOption('site_id');
|
85 |
-
if (is_array($siteId) && $siteId['result'] == 'error')
|
86 |
-
self::showErrorMessage($siteId['message']);
|
87 |
-
else foreach ($aryData as $arySite)
|
88 |
-
if ($arySite['idsite'] == $siteId) {echo '<em>'.htmlentities($arySite['name'], ENT_QUOTES, 'utf-8').'</em>'; break;}
|
89 |
-
echo '<input type="hidden" name="wp-piwik_siteid" id="wp-piwik_siteid" value="'.(int)$siteId.'" /></td></tr>';
|
90 |
-
}
|
91 |
-
}
|
92 |
-
}}
|
93 |
-
// Expert settings (cURL only)
|
94 |
-
?><tr>
|
95 |
-
<th colspan="2"><strong><?php _e('Expert Settings', 'wp-piwik'); ?>:</strong></th>
|
96 |
-
</tr><tr>
|
97 |
-
<th><label><?php _e('Connection timeout', 'wp-piwik'); ?>:</label></th>
|
98 |
-
<td>
|
99 |
-
<input style="width:50px;" type="text" name="wp-piwik_timeout" value="<?php echo self::$settings->getGlobalOption('connection_timeout'); ?>" />
|
100 |
-
</td>
|
101 |
-
</tr>
|
102 |
-
<?php if (function_exists('curl_init')) { ?>
|
103 |
-
<tr>
|
104 |
-
<th><label <?php echo (self::$settings->getGlobalOption('piwik_mode')=='php'?'class="wp-piwik-input-hide" ':''); ?>id="wp-piwik_disable_ssl_verify-label"><?php _e('Disable SSL peer verification', 'wp-piwik'); ?>:</label></th>
|
105 |
-
<td>
|
106 |
-
<input <?php echo (self::$settings->getGlobalOption('piwik_mode')=='php'?'class="wp-piwik-input-hide" ':''); ?>id="wp-piwik_disable_ssl_verify" name="wp-piwik_disable_ssl_verify" type="checkbox"<?php echo (self::$settings->getGlobalOption('disable_ssl_verify')?'checked="checked"':''); ?> /> (<?php _e('not recommended','wp-piwik'); ?>)
|
107 |
-
</td>
|
108 |
-
</tr><tr>
|
109 |
-
<th><label><?php _e('User agent', 'wp-piwik'); ?>:</label></th>
|
110 |
-
<td>
|
111 |
-
<input type="radio" onchange="javascript:$j('#wp-piwik-useragent').toggleClass('readonly="readonly"');" name="wp-piwik_useragent" value="php" <?php echo (self::$settings->getGlobalOption('piwik_useragent')=='php'?'checked="checked" ':''); ?>/> PHP default (<?php echo ini_get('user_agent'); ?>)
|
112 |
-
</td>
|
113 |
-
</tr><tr>
|
114 |
-
<th></th>
|
115 |
-
<td>
|
116 |
-
<input type="radio" onchange="javascript:$j('#wp-piwik-useragent').toggleClass('wp-piwik-useragent-disable');" name="wp-piwik_useragent" value="own" <?php echo (self::$settings->getGlobalOption('piwik_useragent')=='own'?'checked="checked" ':''); ?>/> <input type="text" id="wp-piwik-useragent" name="wp-piwik_useragent_string" value="<?php echo self::$settings->getGlobalOption('piwik_useragent_string'); ?>" />
|
117 |
-
</td>
|
118 |
-
</tr>
|
119 |
-
<?php } else { ?>
|
120 |
-
<tr>
|
121 |
-
<td colspan="2"><?php _e('Further expert settings require cURL. See <a href="http://www.php.net/manual/curl.setup.php">PHP manual</a>', 'wp-piwik'); ?>.</td>
|
122 |
-
</tr>
|
123 |
-
<?php }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
settings/support.php
DELETED
@@ -1,60 +0,0 @@
|
|
1 |
-
<tr>
|
2 |
-
<td><a href="http://wordpress.org/support/plugin/wp-piwik"><?php _e('WordPress.org forum about WP-Piwik','wp-piwik'); ?></a></td>
|
3 |
-
</tr>
|
4 |
-
<tr>
|
5 |
-
<td><?php _e('Please don\'t forget to vote the compatibility at the','wp-piwik'); ?> <a href="http://wordpress.org/extend/plugins/wp-piwik/">WordPress.org Plugin Directory</a>.</td>
|
6 |
-
</tr>
|
7 |
-
<tr>
|
8 |
-
<td>
|
9 |
-
<h3><?php _e('Debugging', 'wp-piwik'); ?></h3>
|
10 |
-
<p><?php _e('Either allow_url_fopen has to be enabled <em>or</em> cURL has to be available:', 'wp-piwik'); ?></p>
|
11 |
-
<ol>
|
12 |
-
<li><?php
|
13 |
-
_e('cURL is','wp-piwik');
|
14 |
-
echo ' <strong>'.(function_exists('curl_init')?'':__('not','wp-piwik')).' ';
|
15 |
-
_e('available','wp-piwik');
|
16 |
-
?></strong>.</li>
|
17 |
-
<li><?php
|
18 |
-
_e('allow_url_fopen is','wp-piwik');
|
19 |
-
echo ' <strong>'.(ini_get('allow_url_fopen')?'':__('not','wp-piwik')).' ';
|
20 |
-
_e('enabled','wp-piwik');
|
21 |
-
?></strong>.</li>
|
22 |
-
</ol>
|
23 |
-
<?php if (self::$settings->getGlobalOption('piwik_token') && self::$settings->getGlobalOption('piwik_url')) { ?>
|
24 |
-
<?php
|
25 |
-
if (isset($_GET['mode'])) {
|
26 |
-
switch ($_GET['mode']) {
|
27 |
-
case 'testscript':
|
28 |
-
echo '<p><strong>'.__('Test script result','wp-piwik').'</strong></p>';
|
29 |
-
self::loadTestscript();
|
30 |
-
break;
|
31 |
-
case 'reset':
|
32 |
-
echo '<p class="wp-piwik-eyecatcher"><strong class="wp-piwik-error">'.__('Please confirm your reset request','wp-piwik').':</strong> <a href="?page=wp-piwik/classes/WP-Piwik.php&tab=support&mode=resetconfirmed">'.__('YES, please reset <strong>all</strong> WP-Piwik settings <strong>except</strong> auth token and Piwi URL.', 'wp-piwik').'</a></p>';
|
33 |
-
break;
|
34 |
-
case 'resetconfirmed':
|
35 |
-
// Increase time limit before resetting
|
36 |
-
set_time_limit(0);
|
37 |
-
self::$settings->resetSettings((isset($_GET['full']) && $_GET['full']));
|
38 |
-
echo '<p class="wp-piwik-eyecatcher"><strong>'.__('WP-Piwik reset done','wp-piwik').'</strong></p>';
|
39 |
-
default:
|
40 |
-
}
|
41 |
-
}
|
42 |
-
?>
|
43 |
-
<p><strong><?php _e('Get more debug information', 'wp-piwik'); ?>:</strong></p>
|
44 |
-
<ol>
|
45 |
-
<li><a href="?page=wp-piwik/classes/WP-Piwik.php&tab=support&mode=testscript"><?php _e('Run test script','wp-piwik'); ?></a></li>
|
46 |
-
<li><a href="?page=wp-piwik/classes/WP-Piwik.php&tab=sitebrowser"><?php _e('Get site configuration details','wp-piwik'); ?></a></li>
|
47 |
-
<li><a href="?page=wp-piwik/classes/WP-Piwik.php&tab=support&mode=reset"><?php _e('Reset WP-Piwik settings except auth token and Piwik URL','wp-piwik'); ?></a> (<?php _e('This will not affect Piwik itself. Resetting large networks may take some minutes.', 'wp-piwik'); ?>)</li>
|
48 |
-
</ol>
|
49 |
-
<?php } else echo '<p>'.__('You have to enter your auth token and the Piwik URL before you can access more debug functions.', 'wp-piwik').'</p>'; ?>
|
50 |
-
</td>
|
51 |
-
</tr>
|
52 |
-
<tr><td><h3><?php _e('Latest support threads on WordPress.org', 'wp-piwik'); ?></h3>
|
53 |
-
<?php
|
54 |
-
$arySupportThreads = self::readRSSFeed('http://wordpress.org/support/rss/plugin/wp-piwik');
|
55 |
-
if (!empty($arySupportThreads)) {
|
56 |
-
echo '<ol>';
|
57 |
-
foreach ($arySupportThreads as $arySupportThread) echo '<li><a href="'.$arySupportThread['url'].'">'.$arySupportThread['title'].'</a></li>';
|
58 |
-
echo '</ol>';
|
59 |
-
}
|
60 |
-
?></td></tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
settings/tracking.php
DELETED
@@ -1,157 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
$bolCURL = function_exists('curl_init');
|
3 |
-
$bolFOpen = ini_get('allow_url_fopen');
|
4 |
-
if (!$bolFOpen && !$bolCURL) {
|
5 |
-
?><tr>
|
6 |
-
<td colspan="2">
|
7 |
-
<strong><?php _e('Error: cURL is not enabled and fopen is not allowed to open URLs. WP-Piwik won\'t be able to connect to Piwik.'); ?></strong>
|
8 |
-
</td>
|
9 |
-
</tr><?php } else { ?>
|
10 |
-
<tr><td colspan="2"><?php _e('Add tracking code', 'wp-piwik'); ?>:
|
11 |
-
<input
|
12 |
-
onchange="javascript:$j('#wp-piwik-tracking-settings').toggleClass('wp-piwik-form-table-hide');"
|
13 |
-
type="checkbox" value="1" id="wp-piwik_addjs" name="wp-piwik_addjs"<?php echo (self::$settings->getGlobalOption('add_tracking_code')?' checked="checked"':''); ?> />
|
14 |
-
<label for="wp-piwik_addjs"><?php _e('If your template uses wp_footer(), WP-Piwik can automatically add the Piwik javascript code to your blog.', 'wp-piwik'); ?></label>
|
15 |
-
</td></tr>
|
16 |
-
</table>
|
17 |
-
<?php
|
18 |
-
if (self::$settings->getGlobalOption('add_tracking_code')) {
|
19 |
-
$strJavaScript = $this->callPiwikAPI('SitesManager.getJavascriptTag');
|
20 |
-
if (is_array($strJavaScript)) {
|
21 |
-
if (isset($strJavaScript['result']) && $strJavaScript['result'] == 'error')
|
22 |
-
self::showErrorMessage(__($strJavaScript['message'],'wp-piwik'));
|
23 |
-
} else {
|
24 |
-
// Save javascript code
|
25 |
-
self::$settings->setOption('tracking_code', $strJavaScript);
|
26 |
-
}
|
27 |
-
self::$settings->save();
|
28 |
-
}
|
29 |
-
?>
|
30 |
-
<table id="wp-piwik-tracking-settings" class="wp-piwik-form-table form-table<?php echo (!self::$settings->getGlobalOption('add_tracking_code')?' wp-piwik-form-table-hide':''); ?>">
|
31 |
-
<tr><th><?php _e('Tracking code preview', 'wp-piwik'); ?>:</th><td>
|
32 |
-
<textarea id="wp-piwik_jscode" name="wp-piwik_jscode" readonly="readonly" rows="13" cols="80">
|
33 |
-
<?php echo (is_plugin_active_for_network('wp-piwik/wp-piwik.php')?'*** SITE SPECIFIC EXAMPLE CODE ***'."\n":'').htmlentities(self::$settings->getOption('tracking_code')); ?>
|
34 |
-
</textarea>
|
35 |
-
</td></tr>
|
36 |
-
|
37 |
-
<tr><th><?php _e('<noscript> code preview', 'wp-piwik'); ?>:</th><td>
|
38 |
-
<textarea id="wp-piwik_nocode" name="wp-piwik_nocode" readonly="readonly" rows="2" cols="80">
|
39 |
-
<?php echo (is_plugin_active_for_network('wp-piwik/wp-piwik.php')?'*** SITE SPECIFIC EXAMPLE CODE ***'."\n":'').htmlentities(self::$settings->getOption('noscript_code')); ?>
|
40 |
-
</textarea>
|
41 |
-
</td></tr>
|
42 |
-
|
43 |
-
<tr><th><?php _e('Default tracking', 'wp-piwik'); ?>:</th><td>
|
44 |
-
<input type="radio" value="0" id="wp-piwik_default" name="wp-piwik_trackingmode"<?php echo (self::$settings->getGlobalOption('track_mode')==0?' checked="checked"':''); ?> />
|
45 |
-
<label for="wp-piwik_compress"><?php _e('WP-Piwik uses the Piwik default tracking code.', 'wp-piwik'); ?> <a href="http://demo.piwik.org/js/README">js/README</a>.</label>
|
46 |
-
</td></tr>
|
47 |
-
|
48 |
-
<tr><th><?php _e('Use js/index.php', 'wp-piwik'); ?>:</th><td>
|
49 |
-
<input type="radio" value="1" id="wp-piwik_compress" name="wp-piwik_trackingmode"<?php echo (self::$settings->getGlobalOption('track_mode')==1?' checked="checked"':''); ?> />
|
50 |
-
<label for="wp-piwik_compress"><?php _e('WP-Piwik can automatically use js/index.php instead of piwik.js and piwik.php. See', 'wp-piwik'); ?> <a href="http://demo.piwik.org/js/README">js/README</a>.</label>
|
51 |
-
</td></tr>
|
52 |
-
|
53 |
-
<tr><th><?php _e('Use proxy script', 'wp-piwik'); ?>:</th><td>
|
54 |
-
<input type="radio" value="2" id="wp-piwik_proxy" name="wp-piwik_trackingmode"<?php echo (self::$settings->getGlobalOption('track_mode')==2?' checked="checked"':''); ?> />
|
55 |
-
<label for="wp-piwik_compress"><?php _e('WP-Piwik will use the piwik.php proxy script. See', 'wp-piwik'); ?> <a href="http://piwik.org/faq/how-to/#faq_132">Piwik FAQ</a>.</label>
|
56 |
-
</td></tr>
|
57 |
-
|
58 |
-
<tr><th><?php _e('JavaScript code position', 'wp-piwik'); ?>:</th><td>
|
59 |
-
<select id="wp-piwik_codeposition" name="wp-piwik_codeposition"<?php echo (self::$settings->getGlobalOption('track_codeposition')?' checked="checked"':''); ?>>
|
60 |
-
<option value="footer"<?php echo (self::$settings->getGlobalOption('track_codeposition') == 'footer'?' selected="selected"':''); ?>><?php _e('Footer', 'wp-piwik'); ?></option>
|
61 |
-
<option value="header"<?php echo (self::$settings->getGlobalOption('track_codeposition') == 'header'?' selected="selected"':''); ?>><?php _e('Header', 'wp-piwik'); ?></option>
|
62 |
-
</select>
|
63 |
-
<label for="wp-piwik_codeposition"><?php echo _e('Choose whether the JavaScript code is added to the footer or the header.', 'wp-piwik'); ?></label>
|
64 |
-
</td></tr>
|
65 |
-
|
66 |
-
<tr><th><?php _e('Add <noscript>', 'wp-piwik'); ?>:</th><td>
|
67 |
-
<input type="checkbox" value="1" id="wp-piwik_noscript" name="wp-piwik_noscript"<?php echo (self::$settings->getGlobalOption('track_noscript')?' checked="checked"':''); ?> />
|
68 |
-
<label for="wp-piwik_noscript"><?php echo _e('Adds the <noscript> code to your footer.', 'wp-piwik'); ?> <?php _e('Disabled in proxy mode.', 'wp-piwik'); ?></label>
|
69 |
-
</td></tr>
|
70 |
-
|
71 |
-
<tr><th><?php _e('Add rec parameter to noscript code', 'wp-piwik'); ?>:</th><td>
|
72 |
-
<input type="checkbox" value="1" id="wp-piwik_nojavascript" name="wp-piwik_nojavascript"<?php echo (self::$settings->getGlobalOption('track_nojavascript')?' checked="checked"':''); ?> />
|
73 |
-
<label for="wp-piwik_nojavascript"><?php echo _e('Enable tracking for visitors without JavaScript (not recommended). See', 'wp-piwik'); ?> <a href="http://piwik.org/faq/how-to/#faq_176">Piwik FAQ</a>. <?php _e('Disabled in proxy mode.', 'wp-piwik'); ?></label>
|
74 |
-
</td></tr>
|
75 |
-
|
76 |
-
<tr><th><?php _e('Disable cookies', 'wp-piwik'); ?>:</th><td>
|
77 |
-
<input type="checkbox" value="1" id="wp-piwik_disable_cookies" name="wp-piwik_disable_cookies"<?php echo (self::$settings->getGlobalOption('disable_cookies')?' checked="checked"':''); ?> />
|
78 |
-
<label for="wp-piwik_disable_cookies"><?php echo _e('Disable all tracking cookies for a visitor.', 'wp-piwik'); ?></label>
|
79 |
-
</td></tr>
|
80 |
-
|
81 |
-
<tr><th><?php _e('Limit cookie lifetime', 'wp-piwik'); ?>:</th><td>
|
82 |
-
<input type="checkbox" value="1" id="wp-piwik_limit_cookies" name="wp-piwik_limit_cookies"<?php echo (self::$settings->getGlobalOption('limit_cookies')?' checked="checked"':''); ?> />
|
83 |
-
<label for="wp-piwik_limit_cookies"><?php echo _e('Limit cookie lifetime as follows', 'wp-piwik'); ?>:</label><br />
|
84 |
-
<?php echo _e('Visitor timeout (seconds)', 'wp-piwik'); ?>: <input type="text" name="wp-piwik_limit_cookies_visitor" value="<?php echo self::$settings->getGlobalOption('limit_cookies_visitor'); ?>"><br /><?php echo _e('Session timeout (seconds)', 'wp-piwik'); ?>: <input type="text" name="wp-piwik_limit_cookies_session" value="<?php echo self::$settings->getGlobalOption('limit_cookies_session'); ?>"></td></tr>
|
85 |
-
|
86 |
-
<tr><th><?php _e('Track visitors across all subdomains', 'wp-piwik'); ?>:</th><td>
|
87 |
-
<input type="checkbox" value="1" id="wp-piwik_track_across" name="wp-piwik_track_across"<?php echo (self::$settings->getGlobalOption('track_across')?' checked="checked"':''); ?> />
|
88 |
-
<label for="wp-piwik_track_across"><?php echo _e('Adds *.-prefix to cookie domain.', 'wp-piwik'); ?></label>
|
89 |
-
</td></tr>
|
90 |
-
|
91 |
-
<tr><th><?php _e('Track visitors across all alias URLs', 'wp-piwik'); ?>:</th><td>
|
92 |
-
<input type="checkbox" value="1" id="wp-piwik_track_across_alias" name="wp-piwik_track_across_alias"<?php echo (self::$settings->getGlobalOption('track_across_alias')?' checked="checked"':''); ?> />
|
93 |
-
<label for="wp-piwik_track_across_alias"><?php echo _e('Adds *.-prefix to tracked domain.', 'wp-piwik'); ?></label>
|
94 |
-
</td></tr>
|
95 |
-
|
96 |
-
<tr><th><?php _e('Track search', 'wp-piwik'); ?>:</th><td>
|
97 |
-
<input type="checkbox" value="1" id="wp-piwik_search" name="wp-piwik_search"<?php echo (self::$settings->getGlobalOption('track_search')?' checked="checked"':''); ?> />
|
98 |
-
<label for="wp-piwik_search"><?php echo _e('Use Piwik\'s advanced Site Search Analytics feature. See', 'wp-piwik'); ?> <a href="http://piwik.org/docs/javascript-tracking/#toc-tracking-internal-search-keywords-categories-and-no-result-search-keywords">Piwik Docs</a>.</label>
|
99 |
-
</td></tr>
|
100 |
-
|
101 |
-
<tr><th><?php _e('Track 404', 'wp-piwik'); ?>:</th><td>
|
102 |
-
<input type="checkbox" value="1" id="wp-piwik_404" name="wp-piwik_404"<?php echo (self::$settings->getGlobalOption('track_404')?' checked="checked"':''); ?> />
|
103 |
-
<label for="wp-piwik_404"><?php echo _e('WP-Piwik can automatically add a 404-category to track 404-page-visits.', 'wp-piwik'); ?></label>
|
104 |
-
</td></tr>
|
105 |
-
|
106 |
-
<tr><th><?php _e('Add annotation on new post', 'wp-piwik'); ?>:</th><td>
|
107 |
-
<input type="checkbox" value="1" id="wp-piwik_annotations" name="wp-piwik_annotations"<?php echo (self::$settings->getGlobalOption('add_post_annotations')?' checked="checked"':''); ?> />
|
108 |
-
<label for="wp-piwik_annotations"><?php echo _e('Add a Piwik annotation on each new post, see', 'wp-piwik'); ?> <a href="http://piwik.org/docs/annotations/">Piwik Docs</a>.</label>
|
109 |
-
</td></tr>
|
110 |
-
|
111 |
-
<tr><th><?php _e('Show custom variables box', 'wp-piwik'); ?>:</th><td>
|
112 |
-
<input type="checkbox" value="1" id="wp-piwik_customvars" name="wp-piwik_customvars"<?php echo (self::$settings->getGlobalOption('add_customvars_box')?' checked="checked"':''); ?> />
|
113 |
-
<label for="wp-piwik_customvars"><?php echo _e('Show a custom vars edit box on post edit page.', 'wp-piwik'); ?></label>
|
114 |
-
</td></tr>
|
115 |
-
|
116 |
-
<tr><th><?php _e('Avoid mod_security', 'wp-piwik'); ?>:</th><td>
|
117 |
-
<input type="checkbox" value="1" id="wp-piwik_reqpost" name="wp-piwik_reqpost"<?php echo (self::$settings->getGlobalOption('track_post')?' checked="checked"':''); ?> />
|
118 |
-
<label for="wp-piwik_reqpost"><?php _e('WP-Piwik can automatically force the Tracking Code to sent data in POST. See', 'wp-piwik'); ?> <a href="http://piwik.org/faq/troubleshooting/#faq_100">Piwik FAQ</a>. <?php _e('Disabled in proxy mode.', 'wp-piwik'); ?></label>
|
119 |
-
</td></tr>
|
120 |
-
|
121 |
-
<tr><th><?php _e('Add data-cfasync=false', 'wp-piwik'); ?>:</th><td>
|
122 |
-
<input type="checkbox" value="1" id="wp-piwik_datacfasync" name="wp-piwik_datacfasync"<?php echo (self::$settings->getGlobalOption('track_datacfasync')?' checked="checked"':''); ?> />
|
123 |
-
<label for="wp-piwik_datacfasync"><?php _e('Adds data-cfasync=false to the script tag, e.g., to ask Rocket Loader to ignore the script.', 'wp-piwik'); ?>
|
124 |
-
</td></tr>
|
125 |
-
|
126 |
-
<tr><th><?php _e('CDN URL', 'wp-piwik'); ?>:</th><td>
|
127 |
-
http://<input type="text" value="<?php echo self::$settings->getGlobalOption('track_cdnurl'); ?>" id="wp-piwik_cdnurl" name="wp-piwik_cdnurl" /> https://<input type="text" value="<?php echo self::$settings->getGlobalOption('track_cdnurlssl'); ?>" id="wp-piwik_cdnurlssl" name="wp-piwik_cdnurlssl" /><br />
|
128 |
-
<label for="wp-piwik_reqpost"><?php _e('Leave blank if you do not want to define a CDN URL or you do not know what this is.', 'wp-piwik'); ?></label>
|
129 |
-
</td></tr>
|
130 |
-
|
131 |
-
<tr><th><?php _e('Track admin pages', 'wp-piwik'); ?>:</th><td>
|
132 |
-
<input type="checkbox" value="1" id="wp-piwik_trackadmin" name="wp-piwik_trackadmin"<?php echo (self::$settings->getGlobalOption('track_admin')?' checked="checked"':''); ?> />
|
133 |
-
<label for="wp-piwik_trackadmin"><?php _e('Enable to track users on admin pages (remember to configure the tracking filter appropriately).', 'wp-piwik'); ?></label>
|
134 |
-
</td></tr>
|
135 |
-
|
136 |
-
<tr><th><?php _e('Track RSS feeds', 'wp-piwik'); ?>:</th><td>
|
137 |
-
<input type="checkbox" value="1" id="wp-piwik_trackfeed" name="wp-piwik_trackfeed"<?php echo (self::$settings->getGlobalOption('track_feed')?' checked="checked"':''); ?> />
|
138 |
-
<label for="wp-piwik_trackfeed"><?php _e('Enable to track posts in feeds via tracking pixel.', 'wp-piwik'); ?></label>
|
139 |
-
</td></tr>
|
140 |
-
|
141 |
-
<tr><th><?php _e('Track RSS feed links as campaign', 'wp-piwik'); ?>:</th><td>
|
142 |
-
<input type="checkbox" value="1" id="wp-piwik_trackfeed_addcampaign" name="wp-piwik_trackfeed_addcampaign"<?php echo (self::$settings->getGlobalOption('track_feed_addcampaign')?' checked="checked"':''); ?> />
|
143 |
-
<label for="wp-piwik_trackfeed_addcampaign"><?php _e('This will add Piwik campaign parameters to the RSS feed links.', 'wp-piwik'); ?> (<a href="https://piwik.org/docs/tracking-campaigns/">Piwik: Tracking campaign</a>)</label><br />
|
144 |
-
<?php _e('Campaign', 'wp-piwik'); ?>: <input type="text" value="<?php echo self::$settings->getGlobalOption('track_feed_campaign'); ?>" id="wp-piwik_trackfeed_campaign" name="wp-piwik_trackfeed_campaign"> <?php _e('Keyword: post name.', 'wp-piwik'); ?>
|
145 |
-
</td></tr>
|
146 |
-
|
147 |
-
<tr><th><?php _e('Tracking filter', 'wp-piwik'); ?>:</th><td>
|
148 |
-
<?php
|
149 |
-
global $wp_roles;
|
150 |
-
$aryFilter = self::$settings->getGlobalOption('capability_stealth');
|
151 |
-
foreach($wp_roles->role_names as $strKey => $strName) {
|
152 |
-
echo '<input type="checkbox" '.(isset($aryFilter[$strKey]) && $aryFilter[$strKey]?'checked="checked" ':'').'value="1" name="wp-piwik_filter['.$strKey.']" /> '.$strName.' ';
|
153 |
-
}
|
154 |
-
?><br><?php _e('Choose users by user role you do <strong>not</strong> want to track.','wp-piwik'); ?></td></tr>
|
155 |
-
</table>
|
156 |
-
<table class="wp-piwik-form-table form-table">
|
157 |
-
<?php } ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
settings/views.php
DELETED
@@ -1,65 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
$bolCURL = function_exists('curl_init');
|
3 |
-
$bolFOpen = ini_get('allow_url_fopen');
|
4 |
-
if (!$bolFOpen && !$bolCURL) {
|
5 |
-
?><tr>
|
6 |
-
<td colspan="2">
|
7 |
-
<strong><?php _e('Error: cURL is not enabled and fopen is not allowed to open URLs. WP-Piwik won\'t be able to connect to Piwik.'); ?></strong>
|
8 |
-
</td>
|
9 |
-
</tr><?php } else { ?>
|
10 |
-
<tr><th><?php _e('WP-Piwik display name', 'wp-piwik'); ?>:</th><td>
|
11 |
-
<input type="text" id="wp-piwik_displayname" name="wp-piwik_displayname" value="<?php echo self::$settings->getGlobalOption('plugin_display_name'); ?>" />
|
12 |
-
<label for="wp-piwik_displayname"><?php echo _e('Plugin name shown in WordPress.', 'wp-piwik'); ?></label>
|
13 |
-
</td></tr>
|
14 |
-
<tr><th>Piwik <?php _e('Default date', 'wp-piwik'); ?>:</th><td>
|
15 |
-
<select id="wp-piwik_default_date" name="wp-piwik_default_date">
|
16 |
-
<option value="yesterday"<?php echo (self::$settings->getGlobalOption('default_date') == 'yesterday'?' selected="selected"':'');?>> <?php _e('yesterday', 'wp-piwik');?></option>
|
17 |
-
<option value="today"<?php echo (self::$settings->getGlobalOption('default_date') == 'today'?' selected="selected"':'');?>> <?php _e('today', 'wp-piwik');?></option>
|
18 |
-
</select>
|
19 |
-
<label for="wp-piwik_default_date"><?php echo _e('Default date shown on statistics page.', 'wp-piwik'); ?></label>
|
20 |
-
</td></tr>
|
21 |
-
<tr><th><?php _e('Home Dashboard', 'wp-piwik'); ?>:</th><td>
|
22 |
-
<select id="wp-piwik_dbwidget" name="wp-piwik_dbwidget">
|
23 |
-
<option value="0"'<?php echo (!self::$settings->getGlobalOption('dashboard_widget')?' selected="selected"':''); ?>><?php _e('Hide overview', 'wp-piwik'); ?></option>
|
24 |
-
<option value="yesterday"<?php echo (self::$settings->getGlobalOption('dashboard_widget') == 'yesterday'?' selected="selected"':''); ?>><?php echo __('Show overview','wp-piwik').' ('.__('yesterday', 'wp-piwik').')'; ?></option>
|
25 |
-
<option value="today"<?php echo (self::$settings->getGlobalOption('dashboard_widget') == 'today'?' selected="selected"':''); ?>><?php echo __('Show overview','wp-piwik').' ('.__('today', 'wp-piwik').')'; ?></option>
|
26 |
-
<option value="last30"<?php echo (self::$settings->getGlobalOption('dashboard_widget') == 'last30'?' selected="selected"':''); ?>><?php echo __('Show overview','wp-piwik').' ('.__('last 30 days','wp-piwik').')'; ?></option>
|
27 |
-
</select>
|
28 |
-
<input type="checkbox" value="1" name="wp-piwik_dbchart" id="wp-piwik_dbchart"<?php echo (self::$settings->getGlobalOption('dashboard_chart')?' checked="checked"':""); ?>/> <?php _e('Chart', 'wp-piwik'); ?>
|
29 |
-
<input type="checkbox" value="1" name="wp-piwik_dbseo" id="wp-piwik_dbseo"<?php echo (self::$settings->getGlobalOption('dashboard_seo')?' checked="checked"':""); ?>/> <?php _e('SEO <em>(slow!)</em>', 'wp-piwik'); ?>
|
30 |
-
<br><?php _e('Configure WP-Piwik widgets to be shown on your WordPress Home Dashboard.', 'wp-piwik'); ?>
|
31 |
-
</td></tr>
|
32 |
-
<tr><th><?php _e('Show graph on WordPress Toolbar', 'wp-piwik'); ?>:</th><td>
|
33 |
-
<input type="checkbox" value="1" id="wp-piwik_toolbar" name="wp-piwik_toolbar"<?php echo (self::$settings->getGlobalOption('toolbar')?' checked="checked"':''); ?> />
|
34 |
-
<label for="wp-piwik_toolbar"><?php echo _e('Display the last 30 days visitor stats on WordPress Toolbar.', 'wp-piwik'); ?></label>
|
35 |
-
</td></tr>
|
36 |
-
<tr><th><?php _e('SEO data', 'wp-piwik'); ?>:</th><td>
|
37 |
-
<input type="checkbox" value="1" id="wp-piwik_statsseo" name="wp-piwik_statsseo"<?php echo (self::$settings->getGlobalOption('stats_seo')?' checked="checked"':''); ?> />
|
38 |
-
<label for="wp-piwik_statsseo"><?php echo _e('Display SEO ranking data on statistics page. <em>(Slow!)</em>', 'wp-piwik'); ?></label>
|
39 |
-
</td></tr>
|
40 |
-
<tr><th>Piwik <?php _e('Shortcut', 'wp-piwik'); ?>:</th><td>
|
41 |
-
<input type="checkbox" value="1" id="wp-piwik_piwiklink" name="wp-piwik_piwiklink"<?php echo (self::$settings->getGlobalOption('piwik_shortcut')?' checked="checked"':''); ?> />
|
42 |
-
<label for="wp-piwik_piwiklink"><?php echo _e('Display a shortcut to Piwik itself.', 'wp-piwik'); ?></label>
|
43 |
-
</td></tr>
|
44 |
-
<tr><th>Piwik <?php _e('Display to', 'wp-piwik'); ?>:</th><td>
|
45 |
-
<?php
|
46 |
-
global $wp_roles;
|
47 |
-
$aryCapability = self::$settings->getGlobalOption('capability_read_stats');
|
48 |
-
foreach($wp_roles->role_names as $strKey => $strName)
|
49 |
-
echo '<input name="wp-piwik_displayto['.$strKey.']" type="checkbox" value="1"'.(isset($aryCapability[$strKey]) && $aryCapability[$strKey]?' checked="checked"':'').'/> '.$strName.' ';
|
50 |
-
?>
|
51 |
-
<br><?php echo _e('Choose user roles allowed to see the statistics page.', 'wp-piwik'); ?>
|
52 |
-
</td></tr>
|
53 |
-
<tr><th><?php _e('Disable time limit', 'wp-piwik'); ?>:</th><td>
|
54 |
-
<input type="checkbox" value="1" id="wp-piwik_disabletimelimit" name="wp-piwik_disabletimelimit"<?php echo (self::$settings->getGlobalOption('disable_timelimit')?' checked="checked"':''); ?> />
|
55 |
-
<label for="wp-piwik_disabletimelimit"><?php echo _e('Use set_time_limit(0) if stats page causes a time out.', 'wp-piwik'); ?></label>
|
56 |
-
</td></tr>
|
57 |
-
<tr><th><?php _e('Show per post stats', 'wp-piwik'); ?>:</th><td>
|
58 |
-
<input type="checkbox" value="1" id="wp-piwik_perpost" name="wp-piwik_perpost"<?php echo (self::$settings->getGlobalOption('perpost_stats')?' checked="checked"':''); ?> />
|
59 |
-
<label for="wp-piwik_perpost"><?php echo _e('Show stats about single posts at the post edit admin page.', 'wp-piwik'); ?></label>
|
60 |
-
</td></tr>
|
61 |
-
<tr><th><?php _e('Enable shortcodes', 'wp-piwik'); ?>:</th><td>
|
62 |
-
<input type="checkbox" value="1" id="wp-piwik_shortcodes" name="wp-piwik_shortcodes"<?php echo (self::$settings->getGlobalOption('shortcodes')?' checked="checked"':''); ?> />
|
63 |
-
<label for="wp-piwik_shortcodes"><?php echo _e('Enable shortcodes in post or page content.', 'wp-piwik'); ?></label>
|
64 |
-
</td></tr>
|
65 |
-
<?php } ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wp-piwik.php
CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://wordpress.org/extend/plugins/wp-piwik/
|
|
6 |
|
7 |
Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress header.
|
8 |
|
9 |
-
Version: 0.10.0.
|
10 |
Author: André Bräkling
|
11 |
Author URI: http://www.braekling.de
|
12 |
Text Domain: wp-piwik
|
@@ -39,6 +39,11 @@ if (!function_exists ('add_action')) {
|
|
39 |
if (!defined('NAMESPACE_SEPARATOR'))
|
40 |
define('NAMESPACE_SEPARATOR', '\\');
|
41 |
|
|
|
|
|
|
|
|
|
|
|
42 |
function wp_piwik_autoloader($class) {
|
43 |
if (substr($class, 0, 9) == 'WP_Piwik'.NAMESPACE_SEPARATOR) {
|
44 |
$class = str_replace('.', '', str_replace(NAMESPACE_SEPARATOR, DIRECTORY_SEPARATOR, substr($class, 9)));
|
@@ -46,7 +51,10 @@ function wp_piwik_autoloader($class) {
|
|
46 |
}
|
47 |
}
|
48 |
|
49 |
-
|
|
|
|
|
|
|
50 |
echo '<div class="error"><p>';
|
51 |
printf(__('WP-Piwik requires at least PHP 5.3. You are using the deprecated version %s. Please update PHP to use WP-Piwik.', 'wp-piwik'), PHP_VERSION);
|
52 |
echo '</p></div>';
|
6 |
|
7 |
Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress header.
|
8 |
|
9 |
+
Version: 0.10.0.1
|
10 |
Author: André Bräkling
|
11 |
Author URI: http://www.braekling.de
|
12 |
Text Domain: wp-piwik
|
39 |
if (!defined('NAMESPACE_SEPARATOR'))
|
40 |
define('NAMESPACE_SEPARATOR', '\\');
|
41 |
|
42 |
+
/**
|
43 |
+
* Define WP-Piwik autoloader
|
44 |
+
*
|
45 |
+
* @param string $class class name
|
46 |
+
*/
|
47 |
function wp_piwik_autoloader($class) {
|
48 |
if (substr($class, 0, 9) == 'WP_Piwik'.NAMESPACE_SEPARATOR) {
|
49 |
$class = str_replace('.', '', str_replace(NAMESPACE_SEPARATOR, DIRECTORY_SEPARATOR, substr($class, 9)));
|
51 |
}
|
52 |
}
|
53 |
|
54 |
+
/**
|
55 |
+
* Show notice about outdated PHP version
|
56 |
+
*/
|
57 |
+
function wp_piwik_phperror() {
|
58 |
echo '<div class="error"><p>';
|
59 |
printf(__('WP-Piwik requires at least PHP 5.3. You are using the deprecated version %s. Please update PHP to use WP-Piwik.', 'wp-piwik'), PHP_VERSION);
|
60 |
echo '</p></div>';
|