Version Description
- Improvement: Define additional file extensions for tracking downloads
- Improvement: Added a POT file to support translators (Note: 1.0 will change a lot, so please don't spend too much time in translating the current version, e.g., by creating an all new translation. With 1.0 I will also offer a translation platform to support your work.)
- Improvement: If necessary, you can force Piwik to use HTTP or HTTPS now (e.g., to avoid redirections from http to https)
- Avoided a naming collision with Woo Theme
Download this release
Release Info
Developer | Braekling |
Plugin | WP-Matomo (WP-Piwik) |
Version | 0.9.9.18 |
Comparing to | |
See all releases |
Code changes from version 0.10.0.2 to 0.9.9.18
- bitcoin.png +0 -0
- cache/.htaccess +1 -0
- classes/WP_Piwik.php +1462 -1146
- classes/WP_Piwik/Admin.php +0 -26
- classes/WP_Piwik/Admin/Network.php +0 -25
- classes/WP_Piwik/Admin/Settings.php +0 -568
- classes/WP_Piwik/Admin/Sitebrowser.php +0 -93
- classes/WP_Piwik/Admin/Statistics.php +0 -53
- classes/WP_Piwik/Logger/Dummy.php +0 -9
- classes/WP_Piwik/Logger/Screen.php +0 -27
- classes/WP_Piwik/Request.php +0 -74
- classes/WP_Piwik/Request/Php.php +0 -42
- classes/WP_Piwik/Request/Rest.php +0 -52
- classes/WP_Piwik/Settings.php +0 -369
- classes/WP_Piwik/Shortcode.php +0 -23
- classes/WP_Piwik/Template/MetaBoxCustomVars.php +0 -63
- classes/WP_Piwik/TrackingCode.php +0 -105
- classes/WP_Piwik/Widget.php +0 -211
- classes/WP_Piwik/Widget/BrowserDetails.php +0 -63
- classes/WP_Piwik/Widget/Browsers.php +0 -63
- classes/WP_Piwik/Widget/Chart.php +0 -76
- classes/WP_Piwik/Widget/Keywords.php +0 -21
- classes/WP_Piwik/Widget/Noresult.php +0 -37
- classes/WP_Piwik/Widget/OptOut.php +0 -17
- classes/WP_Piwik/Widget/Overview.php +0 -53
- classes/WP_Piwik/Widget/Pages.php +0 -21
- classes/WP_Piwik/Widget/Plugins.php +0 -37
- classes/WP_Piwik/Widget/Post.php +0 -51
- classes/WP_Piwik/Widget/Referrers.php +0 -21
- classes/WP_Piwik/Widget/Screens.php +0 -63
- classes/WP_Piwik/Widget/Search.php +0 -37
- classes/WP_Piwik/Widget/Seo.php +0 -31
- classes/WP_Piwik/Widget/Systems.php +0 -61
- classes/WP_Piwik/Widget/Visitors.php +0 -67
- classes/{WP_Piwik/Logger.php → WP_Piwik_Logger.php} +1 -3
- classes/WP_Piwik_Logger_Dummy.php +9 -0
- classes/{WP_Piwik/Logger/File.php → WP_Piwik_Logger_File.php} +4 -4
- classes/WP_Piwik_MetaBox_PerPost_Stats.php +47 -0
- classes/WP_Piwik_Settings.php +166 -0
- classes/{WP_Piwik/Template.php → WP_Piwik_Template.php} +7 -6
- classes/index.php +2 -0
- config.php +2 -1
- css/wp-piwik.css +104 -9
- dashboard/.htaccess +1 -0
- dashboard/browserdetails.php +68 -0
- dashboard/browsers.php +69 -0
- dashboard/index.php +2 -0
- dashboard/keywords.php +30 -0
- dashboard/noresult.php +30 -0
- dashboard/overview.php +70 -0
- dashboard/pages.php +57 -0
- dashboard/plugins.php +58 -0
- dashboard/screens.php +68 -0
- dashboard/search.php +30 -0
- dashboard/seo.php +36 -0
- dashboard/systems.php +69 -0
- dashboard/visitors.php +99 -0
- dashboard/websites.php +34 -0
- js/wp-piwik.js +1 -1
- languages/wp-piwik-de_DE.mo +0 -0
- languages/wp-piwik-de_DE.po +20 -2
- languages/wp-piwik.pot +1105 -0
- piwik.php +8 -0
- proxy/config.php +7 -24
- readme.txt +1 -1
- settings/.htaccess +1 -0
- settings/credits.php +31 -0
- settings/homepage.php +11 -0
- settings/index.php +2 -0
- settings/piwik.php +128 -0
- settings/sitebrowser.php +99 -0
- settings/support.php +60 -0
- settings/tracking.php +169 -0
- settings/views.php +65 -0
- shortcodes/.htaccess +1 -0
- shortcodes/overview.php +50 -0
- shortcodes/post.php +9 -0
- uninstall.php +6 -91
- update/100000.php +0 -18
- update/80502.php +2 -0
- update/80602.php +2 -0
- update/80800.php +1 -1
- update/90001.php +7 -2
- update/90206.php +2 -0
- update/90405.php +5 -0
- update/90601.php +3 -0
- update/90700.php +2 -0
- update/90801.php +2 -0
- update/90821.php +2 -0
- update/90910.php +3 -0
- update/90920.php +2 -0
- update/90940.php +2 -0
- update/90961.php +2 -0
- update/90971.php +3 -0
- update/90980.php +6 -0
- update/91007.php +2 -0
- update/index.php +2 -0
- wp-piwik.php +1513 -35
bitcoin.png
ADDED
Binary file
|
cache/.htaccess
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
Deny from all
|
classes/WP_Piwik.php
CHANGED
@@ -1,1147 +1,1463 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
private
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
$this->
|
25 |
-
$this->
|
26 |
-
$this->
|
27 |
-
$this->
|
28 |
-
$this->
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
if (
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
$this,
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
) );
|
76 |
-
if ($this->
|
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 |
-
if ($
|
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 |
-
if (
|
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 |
-
if (
|
293 |
-
return;
|
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 |
-
if (self::$settings->getGlobalOption
|
419 |
-
|
420 |
-
|
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 |
-
|
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 |
-
|
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 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
*
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
return
|
647 |
-
}
|
648 |
-
|
649 |
-
/**
|
650 |
-
*
|
651 |
-
*
|
652 |
-
* @
|
653 |
-
*/
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
*
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
$
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
*
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
'
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
*
|
936 |
-
*
|
937 |
-
*
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
$
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
'
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
$
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
}
|
1135 |
-
|
1136 |
-
/**
|
1137 |
-
*
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1147 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class wp_piwik {
|
4 |
+
|
5 |
+
private static
|
6 |
+
$intRevisionId = 92000,
|
7 |
+
$strVersion = '0.9.9.10',
|
8 |
+
$blog_id,
|
9 |
+
$intDashboardID = 30,
|
10 |
+
$strPluginBasename = NULL,
|
11 |
+
$bolJustActivated = false,
|
12 |
+
$logger,
|
13 |
+
$settings;
|
14 |
+
|
15 |
+
private
|
16 |
+
$intStatsPage = NULL,
|
17 |
+
$bolNetwork = false,
|
18 |
+
$aryAttributes = array(),
|
19 |
+
$strResult = '';
|
20 |
+
|
21 |
+
public function __construct() {
|
22 |
+
global $blog_id;
|
23 |
+
self::$blog_id = (isset($blog_id)?$blog_id:'n/a');
|
24 |
+
$this->openLogger();
|
25 |
+
$this->openSettings();
|
26 |
+
$this->setup();
|
27 |
+
$this->addFilters();
|
28 |
+
$this->addActions();
|
29 |
+
$this->addShortcodes();
|
30 |
+
self::$settings->save();
|
31 |
+
}
|
32 |
+
|
33 |
+
public function __destruct() {
|
34 |
+
$this->closeLogger();
|
35 |
+
}
|
36 |
+
|
37 |
+
private function setup() {
|
38 |
+
self::$strPluginBasename = plugin_basename(__FILE__);
|
39 |
+
register_activation_hook(__FILE__, array($this, 'installPlugin'));
|
40 |
+
if ($this->isUpdated())
|
41 |
+
$this->upgradePlugin();
|
42 |
+
if ($this->isConfigSubmitted())
|
43 |
+
$this->applySettings();
|
44 |
+
if ($this->isPHPMode())
|
45 |
+
self::definePiwikConstants();
|
46 |
+
$this->loadLanguage();
|
47 |
+
}
|
48 |
+
|
49 |
+
private function addActions() {
|
50 |
+
add_action('admin_menu', array($this, 'buildAdminMenu'));
|
51 |
+
add_action('admin_post_save_wp-piwik_stats', array(&$this, 'onStatsPageSaveChanges'));
|
52 |
+
add_action('load-post.php', array(&$this, 'postMetaboxes'));
|
53 |
+
add_action('load-post-new.php', array(&$this, 'postMetaboxes'));
|
54 |
+
if ($this->isNetworkMode())
|
55 |
+
add_action('network_admin_menu', array($this, 'buildNetworkAdminMenu'));
|
56 |
+
if ($this->isDashboardActive())
|
57 |
+
add_action('wp_dashboard_setup', array($this, 'extendWordPressDashboard'));
|
58 |
+
if ($this->isToolbarActive()) {
|
59 |
+
add_action(is_admin()?'admin_head':'wp_head', array($this, 'loadToolbarRequirements'));
|
60 |
+
add_action('admin_bar_menu', array(&$this, 'extendWordPressToolbar'), 1000);
|
61 |
+
}
|
62 |
+
if ($this->isTrackingActive()) {
|
63 |
+
add_action(self::$settings->getGlobalOption('track_codeposition') == 'footer'?'wp_footer':'wp_head', array($this, 'addJavascriptCode'));
|
64 |
+
if ($this->isAddNoScriptCode())
|
65 |
+
add_action('wp_footer', array($this, 'addNoscriptCode'));
|
66 |
+
if ($this->isAdminTrackingActive())
|
67 |
+
add_action('admin_head', array($this, 'addAdminHeaderTracking'));
|
68 |
+
}
|
69 |
+
if (self::$settings->getGlobalOption('add_post_annotations'))
|
70 |
+
add_action('transition_post_status', array($this, 'onPostStatusTransition'));
|
71 |
+
}
|
72 |
+
|
73 |
+
private function addFilters() {
|
74 |
+
add_filter('plugin_row_meta', array($this, 'setPluginMeta'), 10, 2);
|
75 |
+
add_filter('screen_layout_columns', array(&$this, 'onScreenLayoutColumns'), 10, 2);
|
76 |
+
if ($this->isTrackingActive()) {
|
77 |
+
if ($this->isTrackFeed()) {
|
78 |
+
add_filter('the_excerpt_rss', array(&$this, 'addFeedTracking'));
|
79 |
+
add_filter('the_content', array(&$this, 'addFeedTracking'));
|
80 |
+
}
|
81 |
+
if ($this->isAddFeedCampaign())
|
82 |
+
add_filter('post_link', array(&$this, 'addFeedCampaign'));
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
private function addShortcodes() {
|
87 |
+
if ($this->isAddShortcode())
|
88 |
+
add_shortcode('wp-piwik', array(&$this, 'shortcode'));
|
89 |
+
}
|
90 |
+
|
91 |
+
private function loadLanguage() {
|
92 |
+
load_plugin_textdomain('wp-piwik', false, dirname(self::$strPluginBasename)."/../languages/");
|
93 |
+
}
|
94 |
+
|
95 |
+
function installPlugin() {
|
96 |
+
self::$logger->log('Running WP-Piwik installation');
|
97 |
+
add_action('admin_notices', array($this, 'updateMessage'));
|
98 |
+
self::$bolJustActivated = true;
|
99 |
+
self::$settings->setGlobalOption('revision', self::$intRevisionId);
|
100 |
+
self::$settings->setGlobalOption('last_settings_update', time());
|
101 |
+
}
|
102 |
+
|
103 |
+
static function uninstallPlugin() {
|
104 |
+
self::$logger->log('Running WP-Piwik uninstallation');
|
105 |
+
if (!defined('WP_UNINSTALL_PLUGIN'))
|
106 |
+
exit();
|
107 |
+
self::$settings->resetSettings(true);
|
108 |
+
}
|
109 |
+
|
110 |
+
function upgradePlugin() {
|
111 |
+
self::$logger->log('Upgrade WP-Piwik to '.self::$strVersion);
|
112 |
+
add_action('admin_notices', array($this, 'updateMessage'));
|
113 |
+
$patches = glob(dirname(__FILE__).DIRECTORY_SEPARATOR.'update'.DIRECTORY_SEPARATOR.'*.php');
|
114 |
+
if (is_array($patches)) {
|
115 |
+
sort($patches);
|
116 |
+
foreach ($patches as $patch) {
|
117 |
+
$patchVersion = (int) pathinfo($patch, PATHINFO_FILENAME);
|
118 |
+
if ($patchVersion && self::$settings->getGlobalOption('revision') < $patchVersion)
|
119 |
+
self::includeFile('update'.DIRECTORY_SEPARATOR.$patchVersion);
|
120 |
+
}
|
121 |
+
}
|
122 |
+
$this->installPlugin();
|
123 |
+
}
|
124 |
+
|
125 |
+
function updateMessage() {
|
126 |
+
$text = sprintf(__('%s %s installed.', 'wp-piwik'), self::$settings->getGlobalOption('plugin_display_name'), self::$strVersion);
|
127 |
+
$notice = (!self::isConfigured()?
|
128 |
+
__('Next you should connect to Piwik','wp-piwik'):
|
129 |
+
__('Please validate your configuration','wp-piwik')
|
130 |
+
);
|
131 |
+
$link = sprintf('<a href="'.getSettingsURL.'?page=%s">%s</a>', self::$strPluginBasename, __('Settings', 'wp-piwik'));
|
132 |
+
printf('<div class="updated fade"><p>%s<strong>%s:</strong> %s: %s</p></div>', $text, __('Important', 'wp-piwik'), $notice, $link);
|
133 |
+
}
|
134 |
+
|
135 |
+
function getSettingsURL() {
|
136 |
+
return (self::$settings->checkNetworkActivation()?'settings':'options-general').'.php';
|
137 |
+
}
|
138 |
+
|
139 |
+
private function updateTrackingCode() {
|
140 |
+
if (!self::$settings->getOption('site_id') || !self::$settings->getOption('tracking_code'))
|
141 |
+
$this->addPiwikSite();
|
142 |
+
if ($this->isCurrentTrackingCode()) {
|
143 |
+
self::$settings->setOption('tracking_code', $this->callPiwikAPI('SitesManager.getJavascriptTag'));
|
144 |
+
self::$settings->save();
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
/* -- </REFACTORED><OLD> -- */
|
149 |
+
|
150 |
+
function addJavascriptCode() {
|
151 |
+
if ($this->isHiddenUser()) {
|
152 |
+
self::$logger->log('Do not add tracking code to site header (user should not be tracked) Blog ID: '.self::$blog_id.' Site ID: '.self::$settings->getOption('site_id'));
|
153 |
+
return;
|
154 |
+
}
|
155 |
+
$this->updateTrackingCode();
|
156 |
+
|
157 |
+
// Change code if 404
|
158 |
+
if (is_404() && self::$settings->getGlobalOption('track_404')) {
|
159 |
+
self::$logger->log('Apply 404 changes. Blog ID: '.self::$blog_id.' Site ID: '.self::$settings->getOption('site_id'));
|
160 |
+
$strTrackingCode = str_replace("_paq.push(['trackPageView']);", "_paq.push(['setDocumentTitle', '404/URL = '+String(document.location.pathname+document.location.search).replace(/\//g,'%2f') + '/From = ' + String(document.referrer).replace(/\//g,'%2f')]);\n_paq.push(['trackPageView']);", self::$settings->getOption('tracking_code'));
|
161 |
+
}
|
162 |
+
// Change code if search result
|
163 |
+
elseif (is_search() && self::$settings->getGlobalOption('track_search')) {
|
164 |
+
self::$logger->log('Apply search tracking changes. Blog ID: '.self::$blog_id.' Site ID: '.self::$settings->getOption('site_id'));
|
165 |
+
$objSearch = new WP_Query("s=" . get_search_query() . '&showposts=-1');
|
166 |
+
$intResultCount = $objSearch->post_count;
|
167 |
+
$strTrackingCode = str_replace("_paq.push(['trackPageView']);", "_paq.push(['trackSiteSearch','".get_search_query()."', false, ".$intResultCount."]);\n_paq.push(['trackPageView']);", self::$settings->getOption('tracking_code'));
|
168 |
+
// Use default tracking code
|
169 |
+
} else
|
170 |
+
$strTrackingCode = self::$settings->getOption('tracking_code');
|
171 |
+
// Send tracking code
|
172 |
+
self::$logger->log('Add tracking code. Blog ID: '.self::$blog_id.' Site ID: '.self::$settings->getOption('site_id'));
|
173 |
+
// Add custom variables if set:
|
174 |
+
if (is_single()) {
|
175 |
+
$strCustomVars = '';
|
176 |
+
for ($i = 1; $i <= 5; $i++) {
|
177 |
+
// Get post ID
|
178 |
+
$intID = get_the_ID();
|
179 |
+
// Get key
|
180 |
+
$strMetaKey = get_post_meta($intID, 'wp-piwik_custom_cat'.$i, true);
|
181 |
+
// Get value
|
182 |
+
$strMetaVal = get_post_meta($intID, 'wp-piwik_custom_val'.$i, true);
|
183 |
+
if (!empty($strMetaKey) && !empty($strMetaVal))
|
184 |
+
$strCustomVars .= "_paq.push(['setCustomVariable',".$i.", '".$strMetaKey."', '".$strMetaVal."', 'page']);\n";
|
185 |
+
}
|
186 |
+
if (!empty($strCustomVars)) $strTrackingCode = str_replace("_paq.push(['trackPageView']);", $strCustomVars."_paq.push(['trackPageView']);", $strTrackingCode);
|
187 |
+
}
|
188 |
+
echo $strTrackingCode;
|
189 |
+
$strName = get_bloginfo('name');
|
190 |
+
if (self::$settings->getOption('name') != $strName)
|
191 |
+
$this->updatePiwikSite();
|
192 |
+
}
|
193 |
+
|
194 |
+
function addNoscriptCode() {
|
195 |
+
// Hotfix: Custom capability problem with WP multisite
|
196 |
+
if (is_multisite()) {
|
197 |
+
foreach (self::$settings->getGlobalOption('capability_stealth') as $strKey => $strVal)
|
198 |
+
if ($strVal && current_user_can($strKey))
|
199 |
+
return;
|
200 |
+
// Don't add tracking code?
|
201 |
+
} elseif (current_user_can('wp-piwik_stealth')) return;
|
202 |
+
// Send tracking code
|
203 |
+
self::$logger->log('Add noscript code. Blog ID: '.self::$blog_id.' Site ID: '.self::$settings->getOption('site_id'));
|
204 |
+
echo self::$settings->getOption('noscript_code')."\n";
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Shortcode function
|
209 |
+
**/
|
210 |
+
|
211 |
+
function shortcode($aryAttributes) {
|
212 |
+
$this->aryAttributes = shortcode_atts(
|
213 |
+
array(
|
214 |
+
'title' => '',
|
215 |
+
'module' => 'overview',
|
216 |
+
'period' => 'day',
|
217 |
+
'date' => 'yesterday',
|
218 |
+
'limit' => 10,
|
219 |
+
'width' => '100%',
|
220 |
+
'height' => '200px',
|
221 |
+
'language' => 'en',
|
222 |
+
'range' => false,
|
223 |
+
'key' => 'sum_daily_nb_uniq_visitors'
|
224 |
+
), $aryAttributes);
|
225 |
+
switch ($this->aryAttributes['module']) {
|
226 |
+
case 'opt-out':
|
227 |
+
$this->strResult = '<iframe frameborder="no" width="'.$this->aryAttributes['width'].'" height="'.$this->aryAttributes['height'].'" src="'.self::$settings->getGlobalOption('piwik_url').'index.php?module=CoreAdminHome&action=optOut&language='.$this->aryAttributes['language'].'"></iframe>';
|
228 |
+
break;
|
229 |
+
case 'post':
|
230 |
+
self::includeFile('shortcodes/post');
|
231 |
+
break;
|
232 |
+
case 'overview':
|
233 |
+
default:
|
234 |
+
self::includeFile('shortcodes/overview');
|
235 |
+
}
|
236 |
+
return $this->strResult;
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Add metaboxes to posts
|
241 |
+
*/
|
242 |
+
function postMetaboxes() {
|
243 |
+
if (self::$settings->getGlobalOption('add_customvars_box')) {
|
244 |
+
add_action('add_meta_boxes', array(&$this, 'postAddMetaboxes'));
|
245 |
+
add_action('save_post', array(&$this, 'postCustomvarsSave'), 10, 2);
|
246 |
+
}
|
247 |
+
// Show per post stats if enabled
|
248 |
+
if (self::$settings->getGlobalOption('perpost_stats')) {
|
249 |
+
$this->includeFile('classes/WP_Piwik_MetaBox_PerPost_Stats');
|
250 |
+
add_action('add_meta_boxes', array(new WP_Piwik_MetaBox_PerPost_Stats($this->subClassConfig()), 'addMetabox'));
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Create post meta boxes
|
256 |
+
*/
|
257 |
+
function postAddMetaboxes() {
|
258 |
+
add_meta_box(
|
259 |
+
'wp-piwik_post_customvars',
|
260 |
+
__('Piwik Custom Variables', 'wp-piwik'),
|
261 |
+
array(&$this, 'postCustomvars'),
|
262 |
+
'post',
|
263 |
+
'side',
|
264 |
+
'default'
|
265 |
+
);
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Display custom variables meta box
|
270 |
+
*/
|
271 |
+
function postCustomvars($objPost, $objBox ) {
|
272 |
+
wp_nonce_field(basename( __FILE__ ), 'wp-piwik_post_customvars_nonce'); ?>
|
273 |
+
<table>
|
274 |
+
<tr><th></th><th><?php _e('Name', 'wp-piwik'); ?></th><th><?php _e('Value', 'wp-piwik'); ?></th></tr>
|
275 |
+
<?php for($i = 1; $i <= 5; $i++) { ?>
|
276 |
+
<tr>
|
277 |
+
<th><label for="wp-piwik_customvar1"><?php echo $i; ?>: </label></th>
|
278 |
+
<td><input class="widefat" type="text" name="wp-piwik_custom_cat<?php echo $i; ?>" value="<?php echo esc_attr(get_post_meta($objPost->ID, 'wp-piwik_custom_cat'.$i, true ) ); ?>" size="200" /></td>
|
279 |
+
<td><input class="widefat" type="text" name="wp-piwik_custom_val<?php echo $i; ?>" value="<?php echo esc_attr(get_post_meta($objPost->ID, 'wp-piwik_custom_val'.$i, true ) ); ?>" size="200" /></td>
|
280 |
+
</tr>
|
281 |
+
<?php } ?>
|
282 |
+
</table>
|
283 |
+
<p><?php _e('Set custom variables for a page view', 'wp-piwik'); ?>. (<a href="http://piwik.org/docs/custom-variables/"><?php _e('More information', 'wp-piwik'); ?></a>.)</p>
|
284 |
+
<?php
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Save post custom variables
|
289 |
+
*/
|
290 |
+
function postCustomvarsSave($intID, $objPost) {
|
291 |
+
// Verify the nonce before proceeding.
|
292 |
+
if (!isset( $_POST['wp-piwik_post_customvars_nonce'] ) || !wp_verify_nonce( $_POST['wp-piwik_post_customvars_nonce'], basename( __FILE__ ) ) )
|
293 |
+
return $intID;
|
294 |
+
// Get post type object
|
295 |
+
$objPostType = get_post_type_object($objPost->post_type);
|
296 |
+
// Check if the current user has permission to edit the post.
|
297 |
+
if (!current_user_can($objPostType->cap->edit_post, $intID))
|
298 |
+
return $intID;
|
299 |
+
$aryNames = array('cat', 'val');
|
300 |
+
for ($i = 1; $i <= 5; $i++)
|
301 |
+
for ($j = 0; $j <= 1; $j++) {
|
302 |
+
// Get data
|
303 |
+
$strMetaVal = (isset($_POST['wp-piwik_custom_'.$aryNames[$j].$i])?htmlentities($_POST['wp-piwik_custom_'.$aryNames[$j].$i]):'');
|
304 |
+
// Create key
|
305 |
+
$strMetaKey = 'wp-piwik_custom_'.$aryNames[$j].$i;
|
306 |
+
// Get the meta value of the custom field key
|
307 |
+
$strCurVal = get_post_meta($intID, $strMetaKey, true);
|
308 |
+
// Add meta val:
|
309 |
+
if ($strMetaVal && '' == $strCurVal)
|
310 |
+
add_post_meta($intID, $strMetaKey, $strMetaVal, true);
|
311 |
+
// Update meta val:
|
312 |
+
elseif ($strMetaVal && $strMetaVal != $strCurVal)
|
313 |
+
update_post_meta($intID, $strMetaKey, $strMetaVal);
|
314 |
+
// Delete meta val:
|
315 |
+
elseif (''==$strMetaVal && $strCurVal)
|
316 |
+
delete_post_meta($intID, $strMetaKey, $strCurVal);
|
317 |
+
}
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Add pages to admin menu
|
322 |
+
*/
|
323 |
+
function buildAdminMenu() {
|
324 |
+
// Show stats dashboard page if WP-Piwik is configured
|
325 |
+
if (self::isConfigured()) {
|
326 |
+
// Add dashboard page
|
327 |
+
$this->intStatsPage = add_dashboard_page(
|
328 |
+
__('Piwik Statistics', 'wp-piwik'),
|
329 |
+
self::$settings->getGlobalOption('plugin_display_name'),
|
330 |
+
'wp-piwik_read_stats',
|
331 |
+
'wp-piwik_stats',
|
332 |
+
array($this, 'showStats')
|
333 |
+
);
|
334 |
+
// Add required scripts
|
335 |
+
add_action('admin_print_scripts-'.$this->intStatsPage, array($this, 'loadStatsScripts'));
|
336 |
+
// Add required styles
|
337 |
+
add_action('admin_print_styles-'.$this->intStatsPage, array($this, 'addAdminStyle'));
|
338 |
+
// Add required header tags
|
339 |
+
add_action('admin_head-'.$this->intStatsPage, array($this, 'addAdminHeaderStats'));
|
340 |
+
// Stats page onload callback
|
341 |
+
add_action('load-'.$this->intStatsPage, array(&$this, 'onloadStatsPage'));
|
342 |
+
}
|
343 |
+
if (!self::$settings->checkNetworkActivation()) {
|
344 |
+
// Add options page
|
345 |
+
$intOptionsPage = add_options_page(
|
346 |
+
self::$settings->getGlobalOption('plugin_display_name'),
|
347 |
+
self::$settings->getGlobalOption('plugin_display_name'),
|
348 |
+
'activate_plugins',
|
349 |
+
__FILE__,
|
350 |
+
array($this, 'showSettings')
|
351 |
+
);
|
352 |
+
// Add required scripts
|
353 |
+
add_action('admin_print_scripts-'.$this->intStatsPage, array($this, 'loadSettingsScripts'));
|
354 |
+
// Add required header tags
|
355 |
+
add_action('admin_head-'.$intOptionsPage, array($this, 'addAdminHeaderSettings'));
|
356 |
+
// Add styles required by options page
|
357 |
+
add_action('admin_print_styles-'.$intOptionsPage, array($this, 'addAdminStyle'));
|
358 |
+
}
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Add pages to network admin menu
|
363 |
+
*/
|
364 |
+
function buildNetworkAdminMenu() {
|
365 |
+
// Show stats dashboard page if WP-Piwik is configured
|
366 |
+
if (self::isConfigured()) {
|
367 |
+
// Add dashboard page
|
368 |
+
$this->intStatsPage = add_dashboard_page(
|
369 |
+
__('Piwik Statistics', 'wp-piwik'),
|
370 |
+
self::$settings->getGlobalOption('plugin_display_name'),
|
371 |
+
'manage_sites',
|
372 |
+
'wp-piwik_stats',
|
373 |
+
array($this, 'showStatsNetwork')
|
374 |
+
);
|
375 |
+
// Add required scripts
|
376 |
+
add_action('admin_print_scripts-'.$this->intStatsPage, array($this, 'loadStatsScripts'));
|
377 |
+
// Add required styles
|
378 |
+
add_action('admin_print_styles-'.$this->intStatsPage, array($this, 'addAdminStyle'));
|
379 |
+
// Add required header tags
|
380 |
+
add_action('admin_head-'.$this->intStatsPage, array($this, 'addAdminHeaderStats'));
|
381 |
+
// Stats page onload callback
|
382 |
+
add_action('load-'.$this->intStatsPage, array(&$this, 'onloadStatsPage'));
|
383 |
+
}
|
384 |
+
$intOptionsPage = add_submenu_page(
|
385 |
+
'settings.php',
|
386 |
+
self::$settings->getGlobalOption('plugin_display_name'),
|
387 |
+
self::$settings->getGlobalOption('plugin_display_name'),
|
388 |
+
'manage_sites',
|
389 |
+
__FILE__,
|
390 |
+
array($this, 'showSettings')
|
391 |
+
);
|
392 |
+
|
393 |
+
// Add styles required by options page
|
394 |
+
add_action('admin_print_styles-'.$intOptionsPage, array($this, 'addAdminStyle'));
|
395 |
+
add_action('admin_head-'.$intOptionsPage, array($this, 'addAdminHeaderSettings'));
|
396 |
+
}
|
397 |
+
|
398 |
+
/**
|
399 |
+
* Support two columns
|
400 |
+
* seen in Heiko Rabe's metabox demo plugin
|
401 |
+
*
|
402 |
+
* @see http://tinyurl.com/5r5vnzs
|
403 |
+
*/
|
404 |
+
function onScreenLayoutColumns($aryColumns, $strScreen) {
|
405 |
+
if ($strScreen == $this->intStatsPage)
|
406 |
+
$aryColumns[$this->intStatsPage] = 3;
|
407 |
+
return $aryColumns;
|
408 |
+
}
|
409 |
+
|
410 |
+
/**
|
411 |
+
* Add widgets to WordPress dashboard
|
412 |
+
*/
|
413 |
+
function extendWordPressDashboard() {
|
414 |
+
// Is user allowed to see stats?
|
415 |
+
if (current_user_can('wp-piwik_read_stats')) {
|
416 |
+
// TODO: Use bitmask here
|
417 |
+
// Add data widget if enabled
|
418 |
+
if (self::$settings->getGlobalOption('dashboard_widget'))
|
419 |
+
$this->addWordPressDashboardWidget();
|
420 |
+
// Add chart widget if enabled
|
421 |
+
if (self::$settings->getGlobalOption('dashboard_chart')) {
|
422 |
+
// Add required scripts
|
423 |
+
add_action('admin_print_scripts-index.php', array($this, 'loadStatsScripts'));
|
424 |
+
// Add required styles
|
425 |
+
add_action('admin_print_styles-index.php', array($this, 'addAdminStyle'));
|
426 |
+
// Add required header tags
|
427 |
+
add_action('admin_head-index.php', array($this, 'addAdminHeaderStats'));
|
428 |
+
$this->addWordPressDashboardChart();
|
429 |
+
}
|
430 |
+
// Add SEO widget if enabled
|
431 |
+
if (self::$settings->getGlobalOption('dashboard_seo'))
|
432 |
+
$this->addWordPressDashboardSEO();
|
433 |
+
}
|
434 |
+
}
|
435 |
+
|
436 |
+
/**
|
437 |
+
* Add widgets to WordPress Toolbar
|
438 |
+
*/
|
439 |
+
public function extendWordPressToolbar(&$objToolbar) {
|
440 |
+
// Is user allowed to see stats?
|
441 |
+
if (current_user_can('wp-piwik_read_stats') && is_admin_bar_showing()) {
|
442 |
+
$aryUnique = $this->callPiwikAPI('VisitsSummary.getUniqueVisitors','day','last30',null);
|
443 |
+
if (!is_array($aryUnique)) $aryUnique = array();
|
444 |
+
$strGraph = '<script type="text/javascript">';
|
445 |
+
$strGraph .= "var \$jSpark = jQuery.noConflict();\$jSpark(function() {var piwikSparkVals=[".implode(',',$aryUnique)."];\$jSpark('.wp-piwik_dynbar').sparkline(piwikSparkVals, {type: 'bar', barColor: '#ccc', barWidth:2});});";
|
446 |
+
$strGraph .= '</script>';
|
447 |
+
$strGraph .= '<span class="wp-piwik_dynbar">Loading...</span>';
|
448 |
+
$objToolbar->add_menu(array(
|
449 |
+
'id' => 'wp-piwik_stats',
|
450 |
+
'title' => $strGraph,
|
451 |
+
'href' => admin_url().'?page=wp-piwik_stats'
|
452 |
+
));
|
453 |
+
}
|
454 |
+
}
|
455 |
+
|
456 |
+
/**
|
457 |
+
* Add a data widget to the WordPress dashboard
|
458 |
+
*/
|
459 |
+
function addWordPressDashboardWidget() {
|
460 |
+
$aryConfig = array(
|
461 |
+
'params' => array('period' => 'day','date' => self::$settings->getGlobalOption('dashboard_widget'),'limit' => null),
|
462 |
+
'inline' => true,
|
463 |
+
);
|
464 |
+
$strFile = 'overview';
|
465 |
+
add_meta_box(
|
466 |
+
'wp-piwik_stats-dashboard-overview',
|
467 |
+
self::$settings->getGlobalOption('plugin_display_name').' - '.__(self::$settings->getGlobalOption('dashboard_widget'), 'wp-piwik'),
|
468 |
+
array(&$this, 'createDashboardWidget'),
|
469 |
+
'dashboard',
|
470 |
+
'side',
|
471 |
+
'high',
|
472 |
+
array('strFile' => $strFile, 'aryConfig' => $aryConfig)
|
473 |
+
);
|
474 |
+
}
|
475 |
+
|
476 |
+
/**
|
477 |
+
* Add a visitor chart to the WordPress dashboard
|
478 |
+
*/
|
479 |
+
function addWordPressDashboardChart() {
|
480 |
+
$aryConfig = array(
|
481 |
+
'params' => array('period' => 'day','date' => 'last30','limit' => null),
|
482 |
+
'inline' => true,
|
483 |
+
);
|
484 |
+
$strFile = 'visitors';
|
485 |
+
add_meta_box(
|
486 |
+
'wp-piwik_stats-dashboard-chart',
|
487 |
+
self::$settings->getGlobalOption('plugin_display_name').' - '.__('Visitors', 'wp-piwik'),
|
488 |
+
array(&$this, 'createDashboardWidget'),
|
489 |
+
'dashboard',
|
490 |
+
'side',
|
491 |
+
'high',
|
492 |
+
array('strFile' => $strFile, 'aryConfig' => $aryConfig)
|
493 |
+
);
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Add a SEO widget to the WordPress dashboard
|
498 |
+
*/
|
499 |
+
function addWordPressDashboardSEO() {
|
500 |
+
$aryConfig = array(
|
501 |
+
'params' => array('period' => 'day','date' => 'today','limit' => null),
|
502 |
+
'inline' => true,
|
503 |
+
);
|
504 |
+
$strFile = 'seo';
|
505 |
+
add_meta_box(
|
506 |
+
'wp-piwik_stats-dashboard-seo',
|
507 |
+
self::$settings->getGlobalOption('plugin_display_name').' - '.__('SEO', 'wp-piwik'),
|
508 |
+
array(&$this, 'createDashboardWidget'),
|
509 |
+
'dashboard',
|
510 |
+
'side',
|
511 |
+
'high',
|
512 |
+
array('strFile' => $strFile, 'aryConfig' => $aryConfig)
|
513 |
+
);
|
514 |
+
}
|
515 |
+
|
516 |
+
/**
|
517 |
+
* Add plugin meta links to plugin details
|
518 |
+
*
|
519 |
+
* @see http://wpengineer.com/1295/meta-links-for-wordpress-plugins/
|
520 |
+
*/
|
521 |
+
function setPluginMeta($strLinks, $strFile) {
|
522 |
+
// Get plugin basename
|
523 |
+
$strPlugin = plugin_basename(__FILE__);
|
524 |
+
// Add link just to this plugin's details
|
525 |
+
if ($strFile == self::$strPluginBasename)
|
526 |
+
return array_merge(
|
527 |
+
$strLinks,
|
528 |
+
array(
|
529 |
+
sprintf('<a href="'.(self::$settings->checkNetworkActivation()?'settings':'options-general').'.php?page=%s">%s</a>', self::$strPluginBasename, __('Settings', 'wp-piwik'))
|
530 |
+
)
|
531 |
+
);
|
532 |
+
// Don't affect other plugins details
|
533 |
+
return $strLinks;
|
534 |
+
}
|
535 |
+
|
536 |
+
/**
|
537 |
+
* Load required scripts to stats page
|
538 |
+
*/
|
539 |
+
function loadStatsScripts() {
|
540 |
+
// Load WP-Piwik script
|
541 |
+
wp_enqueue_script('wp-piwik', $this->getPluginURL().'js/wp-piwik.js', array(), self::$strVersion, true);
|
542 |
+
// Load jqPlot
|
543 |
+
wp_enqueue_script('wp-piwik-jqplot',$this->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
|
544 |
+
}
|
545 |
+
|
546 |
+
/**
|
547 |
+
* Load scripts required by Toolbar graphs
|
548 |
+
*/
|
549 |
+
function loadToolbarRequirements() {
|
550 |
+
// Only load if user is allowed to see stats
|
551 |
+
if (current_user_can('wp-piwik_read_stats') && is_admin_bar_showing()) {
|
552 |
+
// Load Sparklines
|
553 |
+
wp_enqueue_script('wp-piwik-sparkline',$this->getPluginURL().'js/sparkline/jquery.sparkline.min.js',array('jquery'),'2.1.1');
|
554 |
+
// Load CSS
|
555 |
+
wp_enqueue_style('wp-piwik', $this->getPluginURL().'css/wp-piwik-spark.css');
|
556 |
+
}
|
557 |
+
}
|
558 |
+
|
559 |
+
/**
|
560 |
+
* Load required scripts to settings page
|
561 |
+
*/
|
562 |
+
function loadSettingsScripts() {
|
563 |
+
wp_enqueue_script('jquery');
|
564 |
+
}
|
565 |
+
|
566 |
+
/**
|
567 |
+
* Load required styles to admin pages
|
568 |
+
*/
|
569 |
+
function addAdminStyle() {
|
570 |
+
// Load WP-Piwik styles
|
571 |
+
wp_enqueue_style('wp-piwik', $this->getPluginURL().'css/wp-piwik.css',array(),self::$strVersion);
|
572 |
+
}
|
573 |
+
|
574 |
+
/**
|
575 |
+
* Add tracking code to admin header
|
576 |
+
*/
|
577 |
+
function addAdminHeaderTracking() {
|
578 |
+
$this->site_header();
|
579 |
+
}
|
580 |
+
|
581 |
+
/**
|
582 |
+
* Add tracking image to feeds
|
583 |
+
**/
|
584 |
+
function addFeedTracking($content) {
|
585 |
+
global $post;
|
586 |
+
if(is_feed()) {
|
587 |
+
self::$logger->log('Add tracking image to feed entry.');
|
588 |
+
if (!self::$settings->getOption('site_id'))
|
589 |
+
self::addPiwikSite();
|
590 |
+
$title = the_title(null,null,false);
|
591 |
+
$posturl = get_permalink($post->ID);
|
592 |
+
$urlref = get_bloginfo('rss2_url');
|
593 |
+
$url = self::$settings->getGlobalOption('piwik_url');
|
594 |
+
if (substr($url, -10, 10) == '/index.php')
|
595 |
+
$url = str_replace('/index.php', '/piwik.php', $url);
|
596 |
+
else $url .= 'piwik.php';
|
597 |
+
$trackingImage = $url.'?idsite='.self::$settings->getOption('site_id').'&rec=1'.
|
598 |
+
'&url='.urlencode($posturl).
|
599 |
+
'&action_name='.urlencode($title).
|
600 |
+
'&urlref='.urlencode($urlref);
|
601 |
+
$content .= '<img src="'.$trackingImage.'" style="border:0;width:0;height:0" width="0" height="0" alt="" />';
|
602 |
+
}
|
603 |
+
return $content;
|
604 |
+
}
|
605 |
+
|
606 |
+
/**
|
607 |
+
* Add tracking image to feeds
|
608 |
+
**/
|
609 |
+
function addFeedCampaign($permalink) {
|
610 |
+
global $post;
|
611 |
+
if(is_feed()) {
|
612 |
+
self::$logger->log('Add campaign to feed permalink.');
|
613 |
+
$sep = (strpos($permalink, '?') === false?'?':'&');
|
614 |
+
$permalink .= $sep.'pk_campaign='.urlencode(self::$settings->getGlobalOption('track_feed_campaign')).'&pk_kwd='.urlencode($post->post_name);
|
615 |
+
}
|
616 |
+
return $permalink;
|
617 |
+
}
|
618 |
+
|
619 |
+
function addPiwikAnnotation($postID) {
|
620 |
+
$this->callPiwikAPI('Annotations.add', '', date('Y-m-d'), '', false, false, 'PHP', '', false, 'Published: '.get_post($postID)->post_title.' - URL: '.get_permalink($postID));
|
621 |
+
}
|
622 |
+
|
623 |
+
/**
|
624 |
+
* Add required header tags to stats page
|
625 |
+
*/
|
626 |
+
function addAdminHeaderStats() {
|
627 |
+
// Load jqPlot IE compatibility script
|
628 |
+
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.$this->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
|
629 |
+
// Load jqPlot styles
|
630 |
+
echo '<link rel="stylesheet" href="'.$this->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
|
631 |
+
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
|
632 |
+
}
|
633 |
+
|
634 |
+
/**
|
635 |
+
* Add required header tags to settings page
|
636 |
+
*/
|
637 |
+
function addAdminHeaderSettings() {
|
638 |
+
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
|
639 |
+
}
|
640 |
+
|
641 |
+
/**
|
642 |
+
* Get this plugin's URL
|
643 |
+
*/
|
644 |
+
function getPluginURL() {
|
645 |
+
// Return plugins URL + /wp-piwik/
|
646 |
+
return trailingslashit(plugins_url().'/wp-piwik/');
|
647 |
+
}
|
648 |
+
|
649 |
+
/**
|
650 |
+
* Call REST API
|
651 |
+
*
|
652 |
+
* @param $strURL Remote file URL
|
653 |
+
*/
|
654 |
+
function callREST($strURL) {
|
655 |
+
$strPiwikURL = self::$settings->getGlobalOption('piwik_url');
|
656 |
+
if (substr($strPiwikURL, -1, 1) != '/') $strPiwikURL .= '/';
|
657 |
+
$strURL = $strPiwikURL.'?module=API'.$strURL;
|
658 |
+
// Use cURL if available
|
659 |
+
if (function_exists('curl_init')) {
|
660 |
+
// Init cURL
|
661 |
+
$c = curl_init($strURL);
|
662 |
+
// Disable SSL peer verification if asked to
|
663 |
+
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, !self::$settings->getGlobalOption('disable_ssl_verify'));
|
664 |
+
// Set user agent
|
665 |
+
curl_setopt($c, CURLOPT_USERAGENT, self::$settings->getGlobalOption('piwik_useragent')=='php'?ini_get('user_agent'):self::$settings->getGlobalOption('piwik_useragent_string'));
|
666 |
+
// Configure cURL CURLOPT_RETURNTRANSFER = 1
|
667 |
+
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
|
668 |
+
// Configure cURL CURLOPT_HEADER = 0
|
669 |
+
curl_setopt($c, CURLOPT_HEADER, 0);
|
670 |
+
// Set cURL timeout
|
671 |
+
curl_setopt($c, CURLOPT_TIMEOUT, self::$settings->getGlobalOption('connection_timeout'));
|
672 |
+
$httpProxyClass = new WP_HTTP_Proxy();
|
673 |
+
if ($httpProxyClass->is_enabled() && $httpProxyClass->send_through_proxy($strURL)) {
|
674 |
+
curl_setopt($c, CURLOPT_PROXY, $httpProxyClass->host());
|
675 |
+
curl_setopt($c, CURLOPT_PROXYPORT, $httpProxyClass->port());
|
676 |
+
if ($httpProxyClass->use_authentication())
|
677 |
+
curl_setopt($c, CURLOPT_PROXYUSERPWD, $httpProxyClass->username().':'.$httpProxyClass->password());
|
678 |
+
}
|
679 |
+
// Get result
|
680 |
+
$strResult = curl_exec($c);
|
681 |
+
// Close connection
|
682 |
+
curl_close($c);
|
683 |
+
// cURL not available but url fopen allowed
|
684 |
+
} elseif (ini_get('allow_url_fopen')) {
|
685 |
+
// Set timeout
|
686 |
+
$resContext = stream_context_create(array('http'=>array('timeout' => self::$settings->getGlobalOption('connection_timeout'))));
|
687 |
+
// Get file using file_get_contents
|
688 |
+
$strResult = @file_get_contents($strURL, false, $strContext);
|
689 |
+
// Error: Not possible to get remote file
|
690 |
+
} else $strResult = serialize(array(
|
691 |
+
'result' => 'error',
|
692 |
+
'message' => 'Remote access to Piwik not possible. Enable allow_url_fopen or CURL.'
|
693 |
+
));
|
694 |
+
// Return result
|
695 |
+
return $strResult;
|
696 |
+
}
|
697 |
+
|
698 |
+
/**
|
699 |
+
* Call PHP API
|
700 |
+
*
|
701 |
+
* @param $strParams API call params
|
702 |
+
*/
|
703 |
+
function callPHP($strParams) {
|
704 |
+
if (!defined('PIWIK_INCLUDE_PATH'))
|
705 |
+
return;
|
706 |
+
if (PIWIK_INCLUDE_PATH === FALSE)
|
707 |
+
return serialize(array('result' => 'error', 'message' => __('Could not resolve','wp-piwik').' "'.htmlentities(self::$settings->getGlobalOption('piwik_path')).'": '.__('realpath() returns false','wp-piwik').'.'));
|
708 |
+
if (file_exists(PIWIK_INCLUDE_PATH . "/index.php"))
|
709 |
+
require_once PIWIK_INCLUDE_PATH . "/index.php";
|
710 |
+
if (file_exists(PIWIK_INCLUDE_PATH . "/core/API/Request.php"))
|
711 |
+
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
|
712 |
+
if (class_exists('Piwik\FrontController'))
|
713 |
+
Piwik\FrontController::getInstance()->init();
|
714 |
+
else serialize(array('result' => 'error', 'message' => __('Class Piwik\FrontController does not exists.','wp-piwik')));
|
715 |
+
if (class_exists('Piwik\API\Request'))
|
716 |
+
$objRequest = new Piwik\API\Request($strParams);
|
717 |
+
else serialize(array('result' => 'error', 'message' => __('Class Piwik\API\Request does not exists.','wp-piwik')));
|
718 |
+
return $objRequest->process();
|
719 |
+
}
|
720 |
+
|
721 |
+
/**
|
722 |
+
* Get remote file
|
723 |
+
*
|
724 |
+
* @param String $strURL Remote file URL
|
725 |
+
*/
|
726 |
+
function getRemoteFile($strURL, $blogURL = '') {
|
727 |
+
if (self::$settings->getGlobalOption('piwik_mode') == 'php')
|
728 |
+
return $this->callPHP($strURL.($blogURL?'&url='.$blogURL:''));
|
729 |
+
else
|
730 |
+
return $this->callREST($strURL.($blogURL?'&url='.urlencode($blogURL):''));
|
731 |
+
}
|
732 |
+
|
733 |
+
/**
|
734 |
+
* Add a new site to Piwik if a new blog was requested,
|
735 |
+
* or get its ID by URL
|
736 |
+
*/
|
737 |
+
function addPiwikSite() {
|
738 |
+
if (isset($_GET['wpmu_show_stats']) && self::$settings->checkNetworkActivation()) {
|
739 |
+
self::$logger->log('Switch blog ID: '.(int) $_GET['wpmu_show_stats']);
|
740 |
+
switch_to_blog((int) $_GET['wpmu_show_stats']);
|
741 |
+
}
|
742 |
+
self::$logger->log('Get the blog\'s site ID by URL: '.get_bloginfo('url'));
|
743 |
+
// Check if blog URL already known
|
744 |
+
$strURL = '&method=SitesManager.getSitesIdFromSiteUrl';
|
745 |
+
$strURL .= '&format=PHP';
|
746 |
+
$strURL .= '&token_auth='.self::$settings->getGlobalOption('piwik_token');
|
747 |
+
$aryResult = unserialize($this->getRemoteFile($strURL, get_bloginfo('url')));
|
748 |
+
if (!empty($aryResult) && isset($aryResult[0]['idsite'])) {
|
749 |
+
self::$settings->setOption('site_id', (int) $aryResult[0]['idsite']);
|
750 |
+
// Otherwise create new site
|
751 |
+
} elseif (self::isConfigured() && !empty($strURL)) {
|
752 |
+
self::$logger->log('Blog not known yet - create new site');
|
753 |
+
$strName = get_bloginfo('name');
|
754 |
+
if (empty($strName)) $strName = get_bloginfo('url');
|
755 |
+
self::$settings->setOption('name', $strName);
|
756 |
+
$strURL .= '&method=SitesManager.addSite';
|
757 |
+
$strURL .= '&siteName='.urlencode($strName).'&urls='.urlencode(get_bloginfo('url'));
|
758 |
+
$strURL .= '&format=PHP';
|
759 |
+
$strURL .= '&token_auth='.self::$settings->getGlobalOption('piwik_token');
|
760 |
+
$strResult = unserialize($this->getRemoteFile($strURL, get_bloginfo('url')));
|
761 |
+
if (!empty($strResult)) self::$settings->setOption('site_id', (int) $strResult);
|
762 |
+
}
|
763 |
+
// Store new data if site created
|
764 |
+
if (self::$settings->getOption('site_id')) {
|
765 |
+
self::$logger->log('Get the site\'s tracking code');
|
766 |
+
self::$settings->setOption('tracking_code', $this->callPiwikAPI('SitesManager.getJavascriptTag'));
|
767 |
+
} else self::$settings->getOption('tracking_code', '');
|
768 |
+
self::$settings->save();
|
769 |
+
if (isset($_GET['wpmu_show_stats']) && self::$settings->checkNetworkActivation()) {
|
770 |
+
self::$logger->log('Back to current blog');
|
771 |
+
restore_current_blog();
|
772 |
+
}
|
773 |
+
return array('js' => self::$settings->getOption('tracking_code'), 'id' => self::$settings->getOption('site_id'));
|
774 |
+
}
|
775 |
+
|
776 |
+
/**
|
777 |
+
* Update a site
|
778 |
+
*/
|
779 |
+
function updatePiwikSite() {
|
780 |
+
$strBlogURL = get_bloginfo('url');
|
781 |
+
// Check if blog URL already known
|
782 |
+
$strName = get_bloginfo('name');
|
783 |
+
if (empty($strName)) $strName = $strBlogURL;
|
784 |
+
self::$settings->setOption('name', $strName);
|
785 |
+
$strURL = '&method=SitesManager.updateSite';
|
786 |
+
$strURL .= '&idSite='.self::$settings->getOption('site_id');
|
787 |
+
$strURL .= '&siteName='.urlencode($strName).'&urls='.urlencode($strBlogURL);
|
788 |
+
$strURL .= '&format=PHP';
|
789 |
+
$strURL .= '&token_auth='.self::$settings->getGlobalOption('piwik_token');
|
790 |
+
$strResult = unserialize($this->getRemoteFile($strURL));
|
791 |
+
// Store new data
|
792 |
+
self::$settings->getOption('tracking_code', $this->callPiwikAPI('SitesManager.getJavascriptTag'));
|
793 |
+
self::$settings->save();
|
794 |
+
}
|
795 |
+
|
796 |
+
/**
|
797 |
+
* Apply configured Tracking Code changes
|
798 |
+
*/
|
799 |
+
function applyJSCodeChanges($strCode) {
|
800 |
+
self::$logger->log('Apply tracking code changes.');
|
801 |
+
self::$settings->setOption('last_tracking_code_update', time());
|
802 |
+
$strCode = html_entity_decode($strCode);
|
803 |
+
// Change code if js/index.php should be used
|
804 |
+
if (self::$settings->getGlobalOption('track_mode') == 1) {
|
805 |
+
$strCode = str_replace('piwik.js', 'js/', $strCode);
|
806 |
+
$strCode = str_replace('piwik.php', 'js/', $strCode);
|
807 |
+
} elseif (self::$settings->getGlobalOption('track_mode') == 2) {
|
808 |
+
$strCode = str_replace('piwik.js', 'piwik.php', $strCode);
|
809 |
+
$strURL = str_replace('https://', '://', self::$settings->getGlobalOption('piwik_url'));
|
810 |
+
$strURL = str_replace('http://', '://', $strURL);
|
811 |
+
$strProxy = str_replace('https://', '://', plugins_url('wp-piwik'));
|
812 |
+
$strProxy = str_replace('http://', '://', $strProxy);
|
813 |
+
$strProxy .= '/';
|
814 |
+
$strCode = str_replace($strURL, $strProxy, $strCode);
|
815 |
+
}
|
816 |
+
$strCode = str_replace('//";','/"',$strCode);
|
817 |
+
if (self::$settings->getGlobalOption('track_cdnurl')||self::$settings->getGlobalOption('track_cdnurlssl')) {
|
818 |
+
$strCode = str_replace("var d=doc", "var ucdn=(('https:' == document.location.protocol) ? 'https://".(self::$settings->getGlobalOption('track_cdnurlssl')?self::$settings->getGlobalOption('track_cdnurlssl'):self::$settings->getGlobalOption('track_cdnurl'))."/' : 'http://".(self::$settings->getGlobalOption('track_cdnurl')?self::$settings->getGlobalOption('track_cdnurl'):self::$settings->getGlobalOption('track_cdnurlssl'))."/');\nvar d=doc", $strCode);
|
819 |
+
$strCode = str_replace("g.src=u+", "g.src=ucdn+", $strCode);
|
820 |
+
}
|
821 |
+
// Change code if POST is forced to be used
|
822 |
+
if (self::$settings->getGlobalOption('track_post') && self::$settings->getGlobalOption('track_mode') != 2) $strCode = str_replace("_paq.push(['trackPageView']);", "_paq.push(['setRequestMethod', 'POST']);\n_paq.push(['trackPageView']);", $strCode);
|
823 |
+
// Change code if cookies are disabled
|
824 |
+
if (self::$settings->getGlobalOption('track_across')) {
|
825 |
+
$referrerParsed = parse_url(get_bloginfo('url'));
|
826 |
+
$strCode = str_replace("_paq.push(['trackPageView']);", "_paq.push(['setCookieDomain', '*.".$referrerParsed['host']."']);\n_paq.push(['trackPageView']);", $strCode);
|
827 |
+
}
|
828 |
+
if (self::$settings->getGlobalOption('disable_cookies')) $strCode = str_replace("_paq.push(['trackPageView']);", "_paq.push(['disableCookies']);\n_paq.push(['trackPageView']);", $strCode);
|
829 |
+
if (self::$settings->getGlobalOption('limit_cookies')) $strCode = str_replace("_paq.push(['trackPageView']);", "_paq.push(['setVisitorCookieTimeout', '".self::$settings->getGlobalOption('limit_cookies_visitor')."']);\n_paq.push(['setSessionCookieTimeout', '".self::$settings->getGlobalOption('limit_cookies_session')."']);\n_paq.push(['trackPageView']);", $strCode);
|
830 |
+
// Store <noscript> code
|
831 |
+
$aryNoscript = array();
|
832 |
+
preg_match('/<noscript>(.*)<\/noscript>/', $strCode, $aryNoscript);
|
833 |
+
if (isset($aryNoscript[0])) {
|
834 |
+
if (self::$settings->getGlobalOption('track_nojavascript'))
|
835 |
+
$aryNoscript[0] = str_replace('?idsite', '?rec=1&idsite', $aryNoscript[0]);
|
836 |
+
self::$settings->setOption('noscript_code', $aryNoscript[0]);
|
837 |
+
}
|
838 |
+
if (self::$settings->getGlobalOption('track_datacfasync'))
|
839 |
+
$strCode = str_replace('<script type', '<script data-cfasync="false" type', $strCode);
|
840 |
+
// Remove <noscript> code
|
841 |
+
$strCode = preg_replace('/<noscript>(.*)<\/noscript>/', '', $strCode);
|
842 |
+
// Return code without empty lines
|
843 |
+
return preg_replace('/\s+(\r\n|\r|\n)/', '$1', $strCode);
|
844 |
+
}
|
845 |
+
|
846 |
+
/**
|
847 |
+
* Create a WordPress dashboard widget
|
848 |
+
*/
|
849 |
+
function createDashboardWidget($objPost, $aryMetabox) {
|
850 |
+
// Create description and ID
|
851 |
+
$strDesc = $strID = '';
|
852 |
+
$aryConfig = $aryMetabox['args']['aryConfig'];
|
853 |
+
foreach ($aryConfig['params'] as $strParam)
|
854 |
+
if (!empty($strParam)) {
|
855 |
+
$strDesc .= $strParam.', ';
|
856 |
+
$strID .= '_'.$strParam;
|
857 |
+
}
|
858 |
+
// Remove dots from filename
|
859 |
+
$strFile = str_replace('.', '', $aryMetabox['args']['strFile']);
|
860 |
+
// Finalize configuration
|
861 |
+
$aryConf = array_merge($aryConfig, array(
|
862 |
+
'id' => $strFile.$strID,
|
863 |
+
'desc' => substr($strDesc, 0, -2)));
|
864 |
+
// Include widget file
|
865 |
+
if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'dashboard/'.$strFile.'.php'))
|
866 |
+
include(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'dashboard/'.$strFile.'.php');
|
867 |
+
}
|
868 |
+
|
869 |
+
/**
|
870 |
+
* Call Piwik's API
|
871 |
+
*/
|
872 |
+
function callPiwikAPI($strMethod, $strPeriod='', $strDate='', $intLimit='',$bolExpanded=false, $intId = false, $strFormat = 'PHP', $strPageURL = '', $useCache = true, $strNote = '') {
|
873 |
+
// Create unique cache key
|
874 |
+
$strKey = 'wp-piwik_'.md5($strMethod.'_'.$strPeriod.'_'.$strDate.'_'.$intLimit.'_'.self::$settings->getGlobalOption('piwik_token').'_'.self::$settings->getGlobalOption('piwik_url').'_'.$intId.'_'.$strPageURL);
|
875 |
+
// Call API if data not cached
|
876 |
+
if (self::$settings->getGlobalOption('cache') && $useCache) {
|
877 |
+
$result = get_transient($strKey);
|
878 |
+
self::$logger->log('API method: '.$strMethod.' Fetch call from cache: '.$strKey);
|
879 |
+
} else $result = false;
|
880 |
+
if ($strMethod == "SitesManager.getSitesWithAtLeastViewAccess" || false === $result) {
|
881 |
+
$strToken = self::$settings->getGlobalOption('piwik_token');
|
882 |
+
// If multisite stats are shown, maybe the super admin wants to show other blog's stats.
|
883 |
+
if (self::$settings->checkNetworkActivation() && function_exists('is_super_admin') && function_exists('wp_get_current_user') && is_super_admin() && isset($_GET['wpmu_show_stats'])) {
|
884 |
+
$aryOptions = get_blog_option((int) $_GET['wpmu_show_stats'], 'wp-piwik_settings' , array());
|
885 |
+
if (!empty($aryOptions) && isset($aryOptions['site_id']))
|
886 |
+
$intSite = $aryOptions['site_id'];
|
887 |
+
else $intSite = self::$settings->getOption('site_id');
|
888 |
+
// Otherwise use the current site's id.
|
889 |
+
} else {
|
890 |
+
if (!self::$settings->getOption('site_id'))
|
891 |
+
self::addPiwikSite();
|
892 |
+
$intSite = self::$settings->getOption('site_id');
|
893 |
+
}
|
894 |
+
//die($intSite);
|
895 |
+
// Create error message if WP-Piwik isn't configured
|
896 |
+
if (!self::isConfigured()) {
|
897 |
+
$result = array(
|
898 |
+
'result' => 'error',
|
899 |
+
'message' => 'Piwik URL/path or auth token not set.'
|
900 |
+
);
|
901 |
+
return $result;
|
902 |
+
}
|
903 |
+
// Build URL
|
904 |
+
$strURL = '&method='.$strMethod;
|
905 |
+
$strURL .= '&idSite='.(int)$intSite.'&period='.$strPeriod.'&date='.$strDate;
|
906 |
+
$strURL .= '&filter_limit='.$intLimit;
|
907 |
+
$strURL .= '&token_auth='.$strToken;
|
908 |
+
$strURL .= '&expanded='.$bolExpanded;
|
909 |
+
$strURL .= '&format='.$strFormat;
|
910 |
+
$strURL .= ($strPageURL?'&pageUrl='.urlencode($strPageURL):'');
|
911 |
+
$strURL .= ($strNote?'¬e='.urlencode($strNote):'');
|
912 |
+
// Fetch data if site exists
|
913 |
+
if (!empty($intSite) || $strMethod='SitesManager.getSitesWithAtLeastViewAccess') {
|
914 |
+
self::$logger->log('API method: '.$strMethod.' API call: '.$strURL);
|
915 |
+
$strResult = (string) $this->getRemoteFile($strURL, get_bloginfo('url'));
|
916 |
+
$result = ($strFormat == 'PHP'?unserialize($strResult):$strResult);
|
917 |
+
// Apply tracking code changes if configured
|
918 |
+
if ($strMethod == 'SitesManager.getJavascriptTag' && !empty($result)) {
|
919 |
+
$result = is_string($result)?$this->applyJSCodeChanges($result):'<!-- WP-Piwik ERROR: Tracking code not availbale -->'."\n";
|
920 |
+
}
|
921 |
+
// Otherwise return error message
|
922 |
+
} else $result = array('result' => 'error', 'message' => 'Unknown site/blog.');
|
923 |
+
if (
|
924 |
+
$strMethod != 'SitesManager.getJavascriptTag' &&
|
925 |
+
$strDate != 'today' && $strDate != date('Ymd') && substr($strDate, 0, 4) != 'last' &&
|
926 |
+
self::$settings->getGlobalOption('cache') &&
|
927 |
+
!(isset($result['result']) && $result['result'] == 'error')&&
|
928 |
+
!empty($result)
|
929 |
+
) set_transient($strKey, $result, WEEK_IN_SECONDS);
|
930 |
+
}
|
931 |
+
return $result;
|
932 |
+
}
|
933 |
+
|
934 |
+
/* TODO: Add post stats
|
935 |
+
* function display_post_unique_column($aryCols) {
|
936 |
+
* $aryCols['wp-piwik_unique'] = __('Unique');
|
937 |
+
* return $aryCols;
|
938 |
+
* }
|
939 |
+
*
|
940 |
+
* function display_post_unique_content($strCol, $intID) {
|
941 |
+
* if( $strCol == 'wp-piwik_unique' ) {
|
942 |
+
* }
|
943 |
+
* }
|
944 |
+
*/
|
945 |
+
|
946 |
+
function onloadStatsPage() {
|
947 |
+
wp_enqueue_script('common');
|
948 |
+
wp_enqueue_script('wp-lists');
|
949 |
+
wp_enqueue_script('postbox');
|
950 |
+
$strToken = self::$settings->getGlobalOption('piwik_token');
|
951 |
+
$strPiwikURL = self::$settings->getGlobalOption('piwik_url');
|
952 |
+
$aryDashboard = array();
|
953 |
+
// Set default configuration
|
954 |
+
$arySortOrder = array(
|
955 |
+
'side' => array(
|
956 |
+
'overview' => array(__('Overview', 'wp-piwik'), 'day', 'yesterday'),
|
957 |
+
'seo' => array(__('SEO', 'wp-piwik'), 'day', 'yesterday'),
|
958 |
+
'pages' => array(__('Pages', 'wp-piwik'), 'day', 'yesterday'),
|
959 |
+
'keywords' => array(__('Keywords', 'wp-piwik'), 'day', 'yesterday', 10),
|
960 |
+
'websites' => array(__('Websites', 'wp-piwik'), 'day', 'yesterday', 10),
|
961 |
+
'plugins' => array(__('Plugins', 'wp-piwik'), 'day', 'yesterday'),
|
962 |
+
'search' => array(__('Site Search Keywords', 'wp-piwik'), 'day', 'yesterday', 10),
|
963 |
+
'noresult' => array(__('Site Search without Results', 'wp-piwik'), 'day', 'yesterday', 10),
|
964 |
+
),
|
965 |
+
'normal' => array(
|
966 |
+
'visitors' => array(__('Visitors', 'wp-piwik'), 'day', 'last30'),
|
967 |
+
'browsers' => array(__('Browser', 'wp-piwik'), 'day', 'yesterday'),
|
968 |
+
'browserdetails' => array(__('Browser Details', 'wp-piwik'), 'day', 'yesterday'),
|
969 |
+
'screens' => array(__('Resolution', 'wp-piwik'), 'day', 'yesterday'),
|
970 |
+
'systems' => array(__('Operating System', 'wp-piwik'), 'day', 'yesterday')
|
971 |
+
)
|
972 |
+
);
|
973 |
+
// Don't show SEO stats if disabled
|
974 |
+
if (!self::$settings->getGlobalOption('stats_seo'))
|
975 |
+
unset($arySortOrder['side']['seo']);
|
976 |
+
|
977 |
+
foreach ($arySortOrder as $strCol => $aryWidgets) {
|
978 |
+
if (is_array($aryWidgets)) foreach ($aryWidgets as $strFile => $aryParams) {
|
979 |
+
$aryDashboard[$strCol][$strFile] = array(
|
980 |
+
'params' => array(
|
981 |
+
'title' => (isset($aryParams[0])?$aryParams[0]:$strFile),
|
982 |
+
'period' => (isset($aryParams[1])?$aryParams[1]:''),
|
983 |
+
'date' => (isset($aryParams[2])?$aryParams[2]:''),
|
984 |
+
'limit' => (isset($aryParams[3])?$aryParams[3]:'')
|
985 |
+
)
|
986 |
+
);
|
987 |
+
if (isset($_GET['date']) && preg_match('/^[0-9]{8}$/', $_GET['date']) && $strFile != 'visitors')
|
988 |
+
$aryDashboard[$strCol][$strFile]['params']['date'] = $_GET['date'];
|
989 |
+
elseif ($strFile != 'visitors')
|
990 |
+
$aryDashboard[$strCol][$strFile]['params']['date'] = self::$settings->getGlobalOption('default_date');
|
991 |
+
}
|
992 |
+
}
|
993 |
+
$intSideBoxCnt = $intContentBox = 0;
|
994 |
+
foreach ($aryDashboard['side'] as $strFile => $aryConfig) {
|
995 |
+
$intSideBoxCnt++;
|
996 |
+
if (preg_match('/(\d{4})(\d{2})(\d{2})/', $aryConfig['params']['date'], $aryResult))
|
997 |
+
$strDate = $aryResult[1]."-".$aryResult[2]."-".$aryResult[3];
|
998 |
+
else $strDate = $aryConfig['params']['date'];
|
999 |
+
add_meta_box(
|
1000 |
+
'wp-piwik_stats-sidebox-'.$intSideBoxCnt,
|
1001 |
+
$aryConfig['params']['title'].' '.($aryConfig['params']['title']!='SEO'?__($strDate, 'wp-piwik'):''),
|
1002 |
+
array(&$this, 'createDashboardWidget'),
|
1003 |
+
$this->intStatsPage,
|
1004 |
+
'side',
|
1005 |
+
'core',
|
1006 |
+
array('strFile' => $strFile, 'aryConfig' => $aryConfig)
|
1007 |
+
);
|
1008 |
+
}
|
1009 |
+
foreach ($aryDashboard['normal'] as $strFile => $aryConfig) {
|
1010 |
+
if (preg_match('/(\d{4})(\d{2})(\d{2})/', $aryConfig['params']['date'], $aryResult))
|
1011 |
+
$strDate = $aryResult[1]."-".$aryResult[2]."-".$aryResult[3];
|
1012 |
+
else $strDate = $aryConfig['params']['date'];
|
1013 |
+
$intContentBox++;
|
1014 |
+
add_meta_box(
|
1015 |
+
'wp-piwik_stats-contentbox-'.$intContentBox,
|
1016 |
+
$aryConfig['params']['title'].' '.($aryConfig['params']['title']!='SEO'?__($strDate, 'wp-piwik'):''),
|
1017 |
+
array(&$this, 'createDashboardWidget'),
|
1018 |
+
$this->intStatsPage,
|
1019 |
+
'normal',
|
1020 |
+
'core',
|
1021 |
+
array('strFile' => $strFile, 'aryConfig' => $aryConfig)
|
1022 |
+
);
|
1023 |
+
}
|
1024 |
+
}
|
1025 |
+
|
1026 |
+
// Open stats page as network admin
|
1027 |
+
function showStatsNetwork() {
|
1028 |
+
$this->bolNetwork = true;
|
1029 |
+
$this->showStats();
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
function showStats() {
|
1033 |
+
// Disabled time limit if required
|
1034 |
+
if (self::$settings->getGlobalOption('disable_timelimit') && self::$settings->getGlobalOption('disable_timelimit'))
|
1035 |
+
set_time_limit(0);
|
1036 |
+
//we need the global screen column value to be able to have a sidebar in WordPress 2.8
|
1037 |
+
global $screen_layout_columns;
|
1038 |
+
if (empty($screen_layout_columns)) $screen_layout_columns = 2;
|
1039 |
+
/***************************************************************************/ ?>
|
1040 |
+
<div id="wp-piwik-stats-general" class="wrap">
|
1041 |
+
<?php screen_icon('options-general'); ?>
|
1042 |
+
<h2><?php echo (self::$settings->getGlobalOption('plugin_display_name') == 'WP-Piwik'?'Piwik '.__('Statistics', 'wp-piwik'):self::$settings->getGlobalOption('plugin_display_name')); ?></h2>
|
1043 |
+
<?php /************************************************************************/
|
1044 |
+
if (self::$settings->checkNetworkActivation() && function_exists('is_super_admin') && is_super_admin() && $this->bolNetwork) {
|
1045 |
+
if (isset($_GET['wpmu_show_stats'])) {
|
1046 |
+
switch_to_blog((int) $_GET['wpmu_show_stats']);
|
1047 |
+
// TODO OPTIMIZE
|
1048 |
+
} else {
|
1049 |
+
$this->includeFile('settings/sitebrowser');
|
1050 |
+
return;
|
1051 |
+
}
|
1052 |
+
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>'."\n";
|
1053 |
+
echo '</form>'."\n";
|
1054 |
+
}
|
1055 |
+
/***************************************************************************/ ?>
|
1056 |
+
<form action="admin-post.php" method="post">
|
1057 |
+
<?php wp_nonce_field('wp-piwik_stats-general'); ?>
|
1058 |
+
<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?>
|
1059 |
+
<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?>
|
1060 |
+
<input type="hidden" name="action" value="save_wp-piwik_stats_general" />
|
1061 |
+
<div id="dashboard-widgets" class="metabox-holder columns-<?php echo $screen_layout_columns; ?><?php echo 2 <= $screen_layout_columns?' has-right-sidebar':''; ?>">
|
1062 |
+
<div id='postbox-container-1' class='postbox-container'>
|
1063 |
+
<?php $meta_boxes = do_meta_boxes($this->intStatsPage, 'normal', null); ?>
|
1064 |
+
</div>
|
1065 |
+
|
1066 |
+
<div id='postbox-container-2' class='postbox-container'>
|
1067 |
+
<?php do_meta_boxes($this->intStatsPage, 'side', null); ?>
|
1068 |
+
</div>
|
1069 |
+
|
1070 |
+
<div id='postbox-container-3' class='postbox-container'>
|
1071 |
+
<?php do_meta_boxes($this->intStatsPage, 'column3', null); ?>
|
1072 |
+
</div>
|
1073 |
+
|
1074 |
+
</div>
|
1075 |
+
</form>
|
1076 |
+
</div>
|
1077 |
+
<script type="text/javascript">
|
1078 |
+
//<![CDATA[
|
1079 |
+
jQuery(document).ready( function($) {
|
1080 |
+
// close postboxes that should be closed
|
1081 |
+
$('.if-js-closed').removeClass('if-js-closed').addClass('closed');
|
1082 |
+
// postboxes setup
|
1083 |
+
postboxes.add_postbox_toggles('<?php echo $this->intStatsPage; ?>');
|
1084 |
+
});
|
1085 |
+
//]]>
|
1086 |
+
</script>
|
1087 |
+
<?php /************************************************************************/
|
1088 |
+
if (self::$settings->checkNetworkActivation() && function_exists('is_super_admin') && is_super_admin()) {
|
1089 |
+
restore_current_blog();
|
1090 |
+
}
|
1091 |
+
}
|
1092 |
+
|
1093 |
+
/* Stats page changes by POST submit
|
1094 |
+
seen in Heiko Rabe's metabox demo plugin
|
1095 |
+
http://tinyurl.com/5r5vnzs */
|
1096 |
+
function onStatsPageSaveChanges() {
|
1097 |
+
//user permission check
|
1098 |
+
if ( !current_user_can('manage_options') )
|
1099 |
+
wp_die( __('Cheatin’ uh?') );
|
1100 |
+
//cross check the given referer
|
1101 |
+
check_admin_referer('wp-piwik_stats');
|
1102 |
+
//process here your on $_POST validation and / or option saving
|
1103 |
+
//lets redirect the post request into get request (you may add additional params at the url, if you need to show save results
|
1104 |
+
wp_redirect($_POST['_wp_http_referer']);
|
1105 |
+
}
|
1106 |
+
|
1107 |
+
/**
|
1108 |
+
* Add tabs to settings page
|
1109 |
+
* See http://wp.smashingmagazine.com/2011/10/20/create-tabs-wordpress-settings-pages/
|
1110 |
+
*/
|
1111 |
+
function showSettingsTabs($bolFull = true, $strCurr = 'homepage') {
|
1112 |
+
$aryTabs = ($bolFull?array(
|
1113 |
+
'homepage' => __('Home','wp-piwik'),
|
1114 |
+
'piwik' => __('Piwik Settings','wp-piwik'),
|
1115 |
+
'tracking' => __('Tracking','wp-piwik'),
|
1116 |
+
'views' => __('Statistics','wp-piwik'),
|
1117 |
+
'support' => __('Support','wp-piwik'),
|
1118 |
+
'credits' => __('Credits','wp-piwik')
|
1119 |
+
):array(
|
1120 |
+
'piwik' => __('Piwik Settings','wp-piwik'),
|
1121 |
+
'support' => __('Support','wp-piwik'),
|
1122 |
+
'credits' => __('Credits','wp-piwik')
|
1123 |
+
));
|
1124 |
+
if (empty($strCurr)) $strCurr = 'homepage';
|
1125 |
+
elseif (!isset($aryTabs[$strCurr]) && $strCurr != 'sitebrowser') $strCurr = 'piwik';
|
1126 |
+
echo '<div id="icon-themes" class="icon32"><br></div>';
|
1127 |
+
echo '<h2 class="nav-tab-wrapper">';
|
1128 |
+
foreach($aryTabs as $strTab => $strName) {
|
1129 |
+
$strClass = ($strTab == $strCurr?' nav-tab-active':'');
|
1130 |
+
echo '<a class="nav-tab'.$strClass.'" href="?page=wp-piwik/classes/WP_Piwik.php&tab='.$strTab.'">'.$strName.'</a>';
|
1131 |
+
}
|
1132 |
+
echo '</h2>';
|
1133 |
+
return $strCurr;
|
1134 |
+
}
|
1135 |
+
|
1136 |
+
/**
|
1137 |
+
* Apply & store new settings
|
1138 |
+
*/
|
1139 |
+
function applySettings() {
|
1140 |
+
$strTab = (isset($_GET['tab'])?$_GET['tab']:'homepage');
|
1141 |
+
self::$logger->log('Apply changes: '.$strTab);
|
1142 |
+
switch ($strTab) {
|
1143 |
+
case 'views':
|
1144 |
+
self::$settings->setGlobalOption('plugin_display_name', (!empty($_POST['wp-piwik_displayname'])?htmlentities($_POST['wp-piwik_displayname']):'WP-Piwk'));
|
1145 |
+
self::$settings->setGlobalOption('dashboard_widget',(isset($_POST['wp-piwik_dbwidget'])?$_POST['wp-piwik_dbwidget']:0));
|
1146 |
+
self::$settings->setGlobalOption('dashboard_chart',(isset($_POST['wp-piwik_dbchart'])?$_POST['wp-piwik_dbchart']:false));
|
1147 |
+
self::$settings->setGlobalOption('dashboard_seo',(isset($_POST['wp-piwik_dbseo'])?$_POST['wp-piwik_dbseo']:false));
|
1148 |
+
self::$settings->setGlobalOption('stats_seo',(isset($_POST['wp-piwik_statsseo'])?$_POST['wp-piwik_statsseo']:false));
|
1149 |
+
self::$settings->setGlobalOption('piwik_shortcut', (isset($_POST['wp-piwik_piwiklink'])?$_POST['wp-piwik_piwiklink']:false));
|
1150 |
+
self::$settings->setGlobalOption('default_date', (isset($_POST['wp-piwik_default_date'])?$_POST['wp-piwik_default_date']:'yesterday'));
|
1151 |
+
self::$settings->setGlobalOption('capability_read_stats', (isset($_POST['wp-piwik_displayto'])?$_POST['wp-piwik_displayto']:array()));
|
1152 |
+
self::$settings->setGlobalOption('disable_timelimit', (isset($_POST['wp-piwik_disabletimelimit'])?$_POST['wp-piwik_disabletimelimit']:false));
|
1153 |
+
self::$settings->setGlobalOption('toolbar', (isset($_POST['wp-piwik_toolbar'])?$_POST['wp-piwik_toolbar']:false));
|
1154 |
+
self::$settings->setGlobalOption('shortcodes', (isset($_POST['wp-piwik_shortcodes'])?$_POST['wp-piwik_shortcodes']:false));
|
1155 |
+
self::$settings->setGlobalOption('perpost_stats', (isset($_POST['wp-piwik_perpost'])?$_POST['wp-piwik_perpost']:false));
|
1156 |
+
break;
|
1157 |
+
case 'tracking':
|
1158 |
+
self::$settings->setGlobalOption('add_tracking_code', (isset($_POST['wp-piwik_addjs'])?$_POST['wp-piwik_addjs']:false));
|
1159 |
+
self::$settings->setGlobalOption('track_404', (isset($_POST['wp-piwik_404'])?$_POST['wp-piwik_404']:false));
|
1160 |
+
self::$settings->setGlobalOption('track_search', (isset($_POST['wp-piwik_search'])?$_POST['wp-piwik_search']:false));
|
1161 |
+
self::$settings->setGlobalOption('track_mode', (isset($_POST['wp-piwik_trackingmode'])?(int)$_POST['wp-piwik_trackingmode']:0));
|
1162 |
+
self::$settings->setGlobalOption('track_post', (isset($_POST['wp-piwik_reqpost'])?$_POST['wp-piwik_reqpost']:false));
|
1163 |
+
self::$settings->setGlobalOption('track_proxy', (isset($_POST['wp-piwik_proxy'])?$_POST['wp-piwik_proxy']:false));
|
1164 |
+
self::$settings->setGlobalOption('track_cdnurl', trim(isset($_POST['wp-piwik_cdnurl'])?$_POST['wp-piwik_cdnurl']:''));
|
1165 |
+
self::$settings->setGlobalOption('track_cdnurlssl', trim(isset($_POST['wp-piwik_cdnurlssl'])?$_POST['wp-piwik_cdnurlssl']:self::$settings->getGlobalOption('track_cdnurl')));
|
1166 |
+
self::$settings->setGlobalOption('track_noscript', (isset($_POST['wp-piwik_noscript'])?$_POST['wp-piwik_noscript']:false));
|
1167 |
+
self::$settings->setGlobalOption('track_codeposition', (isset($_POST['wp-piwik_codeposition'])?$_POST['wp-piwik_codeposition']:'footer'));
|
1168 |
+
self::$settings->setGlobalOption('track_nojavascript', (isset($_POST['wp-piwik_nojavascript'])?$_POST['wp-piwik_nojavascript']:false));
|
1169 |
+
self::$settings->setGlobalOption('track_admin', (isset($_POST['wp-piwik_trackadmin'])?$_POST['wp-piwik_trackadmin']:false));
|
1170 |
+
self::$settings->setGlobalOption('track_feed', (isset($_POST['wp-piwik_trackfeed'])?$_POST['wp-piwik_trackfeed']:false));
|
1171 |
+
self::$settings->setGlobalOption('track_feed_goal', (isset($_POST['wp-piwik_trackfeed_goal'])&&!empty($_POST['wp-piwik_trackfeed_goal'])?(int)$_POST['wp-piwik_trackfeed_goal']:''));
|
1172 |
+
self::$settings->setGlobalOption('track_feed_revenue', (isset($_POST['wp-piwik_trackfeed_revenue'])&&!empty($_POST['wp-piwik_trackfeed_revenue'])?(int)$_POST['wp-piwik_trackfeed_revenue']:''));
|
1173 |
+
self::$settings->setGlobalOption('track_feed_campaign', (isset($_POST['wp-piwik_trackfeed_campaign'])?$_POST['wp-piwik_trackfeed_campaign']:'feed'));
|
1174 |
+
self::$settings->setGlobalOption('track_feed_addcampaign', (isset($_POST['wp-piwik_trackfeed_addcampaign'])?$_POST['wp-piwik_trackfeed_addcampaign']:false));
|
1175 |
+
self::$settings->setGlobalOption('track_datacfasync', (isset($_POST['wp-piwik_datacfasync'])?$_POST['wp-piwik_datacfasync']:false));
|
1176 |
+
self::$settings->setGlobalOption('track_across', (isset($_POST['wp-piwik_track_across'])?$_POST['wp-piwik_track_across']:false));
|
1177 |
+
self::$settings->setGlobalOption('add_post_annotations', (isset($_POST['wp-piwik_annotations'])?$_POST['wp-piwik_annotations']:false));
|
1178 |
+
self::$settings->setGlobalOption('add_customvars_box', (isset($_POST['wp-piwik_customvars'])?$_POST['wp-piwik_customvars']:false));
|
1179 |
+
self::$settings->setGlobalOption('capability_stealth', (isset($_POST['wp-piwik_filter'])?$_POST['wp-piwik_filter']:array()));
|
1180 |
+
self::$settings->setGlobalOption('disable_cookies', (isset($_POST['wp-piwik_disable_cookies'])?$_POST['wp-piwik_disable_cookies']:false));
|
1181 |
+
self::$settings->setGlobalOption('limit_cookies', (isset($_POST['wp-piwik_limit_cookies'])?$_POST['wp-piwik_limit_cookies']:false));
|
1182 |
+
self::$settings->setGlobalOption('limit_cookies_visitor', (isset($_POST['wp-piwik_limit_cookies_visitor'])?(int)$_POST['wp-piwik_limit_cookies_visitor']:1209600));
|
1183 |
+
self::$settings->setGlobalOption('limit_cookies_session', (isset($_POST['wp-piwik_limit_cookies_session'])?(int)$_POST['wp-piwik_limit_cookies_session']:0));
|
1184 |
+
self::$settings->setOption('tracking_code', $this->callPiwikAPI('SitesManager.getJavascriptTag'));
|
1185 |
+
break;
|
1186 |
+
case 'piwik':
|
1187 |
+
self::$settings->setGlobalOption('piwik_token', (isset($_POST['wp-piwik_token'])?$_POST['wp-piwik_token']:''));
|
1188 |
+
self::$settings->setGlobalOption('piwik_url', self::checkURL((isset($_POST['wp-piwik_url'])?$_POST['wp-piwik_url']:'')));
|
1189 |
+
self::$settings->setGlobalOption('piwik_path', (isset($_POST['wp-piwik_path']) && !empty($_POST['wp-piwik_path'])?realpath($_POST['wp-piwik_path']):''));
|
1190 |
+
self::$settings->setGlobalOption('cache', (isset($_POST['wp-piwik_cache'])?$_POST['wp-piwik_cache']:false));
|
1191 |
+
self::$settings->setGlobalOption('piwik_mode', (isset($_POST['wp-piwik_mode'])?$_POST['wp-piwik_mode']:'http'));
|
1192 |
+
self::$settings->setGlobalOption('piwik_useragent', (isset($_POST['wp-piwik_useragent'])?$_POST['wp-piwik_useragent']:'php'));
|
1193 |
+
self::$settings->setGlobalOption('connection_timeout', (isset($_POST['wp-piwik_timeout'])?(int)$_POST['wp-piwik_timeout']:5));
|
1194 |
+
self::$settings->setGlobalOption('piwik_useragent_string', (isset($_POST['wp-piwik_useragent_string'])?$_POST['wp-piwik_useragent_string']:'WP-Piwik'));
|
1195 |
+
self::$settings->setGlobalOption('disable_ssl_verify', (isset($_POST['wp-piwik_disable_ssl_verify'])?$_POST['wp-piwik_disable_ssl_verify']:false));
|
1196 |
+
if (!self::$settings->checkNetworkActivation()) {
|
1197 |
+
self::$settings->setGlobalOption('auto_site_config', (isset($_POST['wp-piwik_auto_site_config'])?$_POST['wp-piwik_auto_site_config']:false));
|
1198 |
+
if (!self::$settings->getGlobalOption('auto_site_config'))
|
1199 |
+
self::$settings->setOption('site_id', (isset($_POST['wp-piwik_siteid'])?$_POST['wp-piwik_siteid']:self::$settings->getOption('site_id')));
|
1200 |
+
} else self::$settings->setGlobalOption('auto_site_config', true);
|
1201 |
+
break;
|
1202 |
+
}
|
1203 |
+
if (self::$settings->getGlobalOption('auto_site_config') && self::isConfigured()) {
|
1204 |
+
if (self::$settings->getGlobalOption('piwik_mode') == 'php' && !defined('PIWIK_INCLUDE_PATH'))
|
1205 |
+
self::definePiwikConstants();
|
1206 |
+
$aryReturn = $this->addPiwikSite();
|
1207 |
+
self::$settings->getOption('tracking_code', $aryReturn['js']);
|
1208 |
+
self::$settings->getOption('site_id', $aryReturn['id']);
|
1209 |
+
}
|
1210 |
+
self::$settings->setGlobalOption('last_settings_update', time());
|
1211 |
+
}
|
1212 |
+
|
1213 |
+
/**
|
1214 |
+
* Check & prepare URL
|
1215 |
+
*/
|
1216 |
+
static function checkURL($strURL) {
|
1217 |
+
if (empty($strURL)) return '';
|
1218 |
+
if (substr($strURL, -1, 1) != '/' && substr($strURL, -10, 10) != '/index.php')
|
1219 |
+
$strURL .= '/';
|
1220 |
+
return $strURL;
|
1221 |
+
}
|
1222 |
+
|
1223 |
+
/**
|
1224 |
+
* Show settings page
|
1225 |
+
*/
|
1226 |
+
function showSettings() {
|
1227 |
+
// Define globals and get request vars
|
1228 |
+
global $pagenow;
|
1229 |
+
$strTab = (isset($_GET['tab'])?$_GET['tab']:'homepage');
|
1230 |
+
// Show update message if stats saved
|
1231 |
+
if (isset($_POST['wp-piwik_settings_submit']) && $_POST['wp-piwik_settings_submit'] == 'Y')
|
1232 |
+
echo '<div id="message" class="updated fade"><p>'.__('Changes saved','wp-piwik').'</p></div>';
|
1233 |
+
// Show settings page title
|
1234 |
+
echo '<div class="wrap"><h2>'.self::$settings->getGlobalOption('plugin_display_name').' '.__('Settings', 'wp-piwik').'</h2>';
|
1235 |
+
// Show tabs
|
1236 |
+
$strTab = $this->showSettingsTabs(self::isConfigured(), $strTab);
|
1237 |
+
if ($strTab != 'sitebrowser') {
|
1238 |
+
/***************************************************************************/ ?>
|
1239 |
+
<div class="wp-piwik-donate">
|
1240 |
+
<p><strong><?php _e('Donate','wp-piwik'); ?></strong></p>
|
1241 |
+
<p><?php _e('If you like WP-Piwik, you can support its development by a donation:', 'wp-piwik'); ?></p>
|
1242 |
+
<div>
|
1243 |
+
<script type="text/javascript">
|
1244 |
+
var flattr_url = 'http://www.braekling.de/wp-piwik-wpmu-piwik-wordpress';
|
1245 |
+
</script>
|
1246 |
+
<script src="http<?php echo (self::isSSL()?'s':''); ?>://api.flattr.com/button/load.js" type="text/javascript"></script>
|
1247 |
+
</div>
|
1248 |
+
<div>Paypal
|
1249 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
1250 |
+
<input type="hidden" name="cmd" value="_s-xclick" />
|
1251 |
+
<input type="hidden" name="hosted_button_id" value="6046779" />
|
1252 |
+
<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donateCC_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online." />
|
1253 |
+
<img alt="" border="0" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1" />
|
1254 |
+
</form>
|
1255 |
+
</div>
|
1256 |
+
<div>
|
1257 |
+
<a 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>
|
1258 |
+
</div>
|
1259 |
+
<div>
|
1260 |
+
<?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>.
|
1261 |
+
</div>
|
1262 |
+
</div>
|
1263 |
+
<?php /***************************************************************************/
|
1264 |
+
}
|
1265 |
+
echo '<form class="'.($strTab != 'sitebrowser'?'wp-piwik-settings':'').'" method="post" action="'.admin_url(($pagenow == 'settings.php'?'network/':'').$pagenow.'?page=wp-piwik/classes/WP_Piwik.php&tab='.$strTab).'">';
|
1266 |
+
echo '<input type="hidden" name="action" value="save_wp-piwik_settings" />';
|
1267 |
+
wp_nonce_field('wp-piwik_settings');
|
1268 |
+
// Show settings
|
1269 |
+
if (($pagenow == 'options-general.php' || $pagenow == 'settings.php') && $_GET['page'] == 'wp-piwik/classes/WP_Piwik.php') {
|
1270 |
+
echo '<table class="wp-piwik-form-table form-table">';
|
1271 |
+
// Get tab contents
|
1272 |
+
$this->includeFile('settings/'.$strTab);
|
1273 |
+
// Show submit button
|
1274 |
+
if (!in_array($strTab, array('homepage','credits','support','sitebrowser')))
|
1275 |
+
echo '<tr><td><p class="submit" style="clear: both;padding:0;margin:0"><input type="submit" name="Submit" class="button-primary" value="'.__('Save settings', 'wp-piwik').'" /><input type="hidden" name="wp-piwik_settings_submit" value="Y" /></p></td></tr>';
|
1276 |
+
echo '</table>';
|
1277 |
+
}
|
1278 |
+
// Close form
|
1279 |
+
echo '</form></div>';
|
1280 |
+
}
|
1281 |
+
|
1282 |
+
/**
|
1283 |
+
* Check if SSL is used
|
1284 |
+
*/
|
1285 |
+
private static function isSSL() {
|
1286 |
+
return (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off');
|
1287 |
+
}
|
1288 |
+
|
1289 |
+
/**
|
1290 |
+
* Show an error message extended by a support site link
|
1291 |
+
*/
|
1292 |
+
private static function showErrorMessage($strMessage) {
|
1293 |
+
echo '<strong class="wp-piwik-error">'.__('An error occured', 'wp-piwik').':</strong> '.$strMessage.' [<a href="'.(self::$settings->checkNetworkActivation()?'network/settings':'options-general').'.php?page=wp-piwik/classes/WP_Piwik.php&tab=support">'.__('Support','wp-piwik').'</a>]';
|
1294 |
+
}
|
1295 |
+
|
1296 |
+
/**
|
1297 |
+
* Read a RSS feed
|
1298 |
+
*/
|
1299 |
+
private static function readRSSFeed($strFeedURL, $intCount = 5) {
|
1300 |
+
$aryResult = array();
|
1301 |
+
if (function_exists('simplexml_load_file') && !empty($strFeedURL)) {
|
1302 |
+
$objXML = @simplexml_load_file($strFeedURL);
|
1303 |
+
if (empty($strFeedURL) || !$objXML || !isset($objXML->channel[0]->item))
|
1304 |
+
return array(array('title' => 'Can\'t read RSS feed.','url' => $strFeedURL));
|
1305 |
+
foreach($objXML->channel[0]->item as $objItem) {
|
1306 |
+
if( $intCount-- == 0 ) break;
|
1307 |
+
$aryResult[] = array('title' => $objItem->title[0], 'url' => $objItem->link[0]);
|
1308 |
+
}
|
1309 |
+
}
|
1310 |
+
return $aryResult;
|
1311 |
+
}
|
1312 |
+
|
1313 |
+
/**
|
1314 |
+
* Execute test script
|
1315 |
+
*/
|
1316 |
+
private static function loadTestscript() {
|
1317 |
+
require_once('../debug/testscript.php');
|
1318 |
+
}
|
1319 |
+
|
1320 |
+
/**
|
1321 |
+
* Get a blog's piwik ID
|
1322 |
+
*/
|
1323 |
+
public static function getSiteID($intBlogID = null) {
|
1324 |
+
$intResult = self::$settings->getOption('site_id');
|
1325 |
+
if (self::$settings->checkNetworkActivation() && !empty($intBlogID)) {
|
1326 |
+
$aryResult = get_blog_option($intBlogID, 'wp-piwik_settings');
|
1327 |
+
$intResult = $aryResult['site_id'];
|
1328 |
+
}
|
1329 |
+
return (is_int($intResult)?$intResult:'n/a');
|
1330 |
+
}
|
1331 |
+
|
1332 |
+
public static function isConfigured() {
|
1333 |
+
return (
|
1334 |
+
self::$settings->getGlobalOption('piwik_token')
|
1335 |
+
&& (
|
1336 |
+
(
|
1337 |
+
(self::$settings->getGlobalOption('piwik_mode') == 'http') && (self::$settings->getGlobalOption('piwik_url'))
|
1338 |
+
) || (
|
1339 |
+
(self::$settings->getGlobalOption('piwik_mode') == 'php') && (self::$settings->getGlobalOption('piwik_path'))
|
1340 |
+
)
|
1341 |
+
)
|
1342 |
+
);
|
1343 |
+
}
|
1344 |
+
|
1345 |
+
private function isUpdated() {
|
1346 |
+
return self::$settings->getGlobalOption('revision') && self::$settings->getGlobalOption('revision') < self::$intRevisionId;
|
1347 |
+
}
|
1348 |
+
|
1349 |
+
private function isConfigSubmitted() {
|
1350 |
+
return isset($_POST['action']) && $_POST['action'] == 'save_wp-piwik_settings';
|
1351 |
+
}
|
1352 |
+
|
1353 |
+
private function isPHPMode() {
|
1354 |
+
return self::$settings->getGlobalOption('piwik_mode') && self::$settings->getGlobalOption('piwik_mode') == 'php';
|
1355 |
+
}
|
1356 |
+
|
1357 |
+
private function isNetworkMode() {
|
1358 |
+
return self::$settings->checkNetworkActivation();
|
1359 |
+
}
|
1360 |
+
|
1361 |
+
private function isDashboardActive() {
|
1362 |
+
return self::$settings->getGlobalOption('dashboard_widget') || self::$settings->getGlobalOption('dashboard_chart') || self::$settings->getGlobalOption('dashboard_seo');
|
1363 |
+
}
|
1364 |
+
|
1365 |
+
private function isToolbarActive() {
|
1366 |
+
return self::$settings->getGlobalOption('toolbar');
|
1367 |
+
}
|
1368 |
+
|
1369 |
+
private function isTrackingActive() {
|
1370 |
+
return self::$settings->getGlobalOption('add_tracking_code');
|
1371 |
+
}
|
1372 |
+
|
1373 |
+
private function isAdminTrackingActive() {
|
1374 |
+
return self::$settings->getGlobalOption('track_admin');
|
1375 |
+
}
|
1376 |
+
|
1377 |
+
private function isAddNoScriptCode() {
|
1378 |
+
return self::$settings->getGlobalOption('track_noscript');
|
1379 |
+
}
|
1380 |
+
|
1381 |
+
private function isTrackFeed() {
|
1382 |
+
return self::$settings->getGlobalOption('track_feed');
|
1383 |
+
}
|
1384 |
+
|
1385 |
+
private function isAddFeedCampaign() {
|
1386 |
+
return self::$settings->getGlobalOption('track_feed_addcampaign');
|
1387 |
+
}
|
1388 |
+
|
1389 |
+
private function isAddShortcode() {
|
1390 |
+
return self::$settings->getGlobalOption('shortcodes');
|
1391 |
+
}
|
1392 |
+
|
1393 |
+
private static function definePiwikConstants() {
|
1394 |
+
define('PIWIK_INCLUDE_PATH', self::$settings->getGlobalOption('piwik_path'));
|
1395 |
+
define('PIWIK_USER_PATH', self::$settings->getGlobalOption('piwik_path'));
|
1396 |
+
define('PIWIK_ENABLE_DISPATCH', false);
|
1397 |
+
define('PIWIK_ENABLE_ERROR_HANDLER', false);
|
1398 |
+
define('PIWIK_ENABLE_SESSION_START', false);
|
1399 |
+
}
|
1400 |
+
|
1401 |
+
private function openLogger() {
|
1402 |
+
switch (WP_PIWIK_ACTIVATE_LOGGER) {
|
1403 |
+
case 2:
|
1404 |
+
require_once('WP_Piwik_Logger_File.php');
|
1405 |
+
self::$logger = new WP_Piwik_Logger_File(__CLASS__);
|
1406 |
+
break;
|
1407 |
+
default:
|
1408 |
+
require_once('WP_Piwik_Logger_Dummy.php');
|
1409 |
+
self::$logger = new WP_Piwik_Logger_Dummy(__CLASS__);
|
1410 |
+
}
|
1411 |
+
}
|
1412 |
+
|
1413 |
+
private function closeLogger() {
|
1414 |
+
self::$logger = null;
|
1415 |
+
}
|
1416 |
+
|
1417 |
+
private function openSettings() {
|
1418 |
+
$this->includeFile('classes/WP_Piwik_Settings');
|
1419 |
+
self::$settings = new WP_Piwik_Settings(self::$logger);
|
1420 |
+
}
|
1421 |
+
|
1422 |
+
private function subClassConfig() {
|
1423 |
+
return array(
|
1424 |
+
'wp_piwik' => $this,
|
1425 |
+
'logger' => self::$logger,
|
1426 |
+
'settings' => self::$settings
|
1427 |
+
);
|
1428 |
+
}
|
1429 |
+
|
1430 |
+
private function includeFile($strFile) {
|
1431 |
+
self::$logger->log('Include '.$strFile.'.php');
|
1432 |
+
if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$strFile.'.php'))
|
1433 |
+
include(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$strFile.'.php');
|
1434 |
+
}
|
1435 |
+
|
1436 |
+
private function isHiddenUser() {
|
1437 |
+
if (is_multisite())
|
1438 |
+
foreach (self::$settings->getGlobalOption('capability_stealth') as $key => $val)
|
1439 |
+
if ($val && current_user_can($key)) return true;
|
1440 |
+
return current_user_can('wp-piwik_stealth');
|
1441 |
+
}
|
1442 |
+
|
1443 |
+
private function isCurrentTrackingCode() {
|
1444 |
+
return (self::$settings->getOption('last_tracking_code_update') < self::$settings->getGlobalOption('last_settings_update'));
|
1445 |
+
}
|
1446 |
+
|
1447 |
+
function site_header() {
|
1448 |
+
self::$logger->log('Using deprecated function site_header');
|
1449 |
+
$this->addJavascriptCode();
|
1450 |
+
}
|
1451 |
+
|
1452 |
+
function site_footer() {
|
1453 |
+
self::$logger->log('Using deprecated function site_footer');
|
1454 |
+
$this->addNoscriptCode();
|
1455 |
+
}
|
1456 |
+
|
1457 |
+
private function onPostStatusTransition($newStatus, $oldStatus = 'false', $post = null) {
|
1458 |
+
if ($newStatus == 'publish' && $oldStatus != 'publish' ) {
|
1459 |
+
add_action('publish_post', array($this, 'addPiwikAnnotation'));
|
1460 |
+
}
|
1461 |
+
}
|
1462 |
+
|
1463 |
}
|
classes/WP_Piwik/Admin.php
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik;
|
4 |
-
|
5 |
-
abstract class Admin {
|
6 |
-
|
7 |
-
protected static $wpPiwik, $pageID, $settings;
|
8 |
-
|
9 |
-
public function __construct($wpPiwik, $settings) {
|
10 |
-
self::$wpPiwik = $wpPiwik;
|
11 |
-
self::$settings = $settings;
|
12 |
-
}
|
13 |
-
|
14 |
-
abstract public function show();
|
15 |
-
|
16 |
-
abstract public function printAdminScripts();
|
17 |
-
|
18 |
-
abstract public function extendAdminHeader();
|
19 |
-
|
20 |
-
public function printAdminStyles() {
|
21 |
-
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css', array(), self::$wpPiwik->getPluginVersion());
|
22 |
-
}
|
23 |
-
|
24 |
-
public function onLoad() {}
|
25 |
-
|
26 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Admin/Network.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Admin;
|
4 |
-
|
5 |
-
class Network extends \WP_Piwik\Admin\Statistics {
|
6 |
-
|
7 |
-
public function show() {
|
8 |
-
parent::show(true);
|
9 |
-
}
|
10 |
-
|
11 |
-
public function printAdminScripts() {
|
12 |
-
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
13 |
-
wp_enqueue_script('wp-piwik-jqplot', self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'), self::$wpPiwik->getPluginVersion());
|
14 |
-
}
|
15 |
-
|
16 |
-
public function extendAdminHeader() {
|
17 |
-
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.(parent::$wpPiwik->getPluginURL()).'js/jqplot/excanvas.min.js"></script><![endif]-->';
|
18 |
-
echo '<link rel="stylesheet" href="'.(parent::$wpPiwik->getPluginURL()).'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
|
19 |
-
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
|
20 |
-
}
|
21 |
-
|
22 |
-
public function onLoad() {
|
23 |
-
self::$wpPiwik->onloadStatsPage(self::$pageID);
|
24 |
-
}
|
25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Admin/Settings.php
DELETED
@@ -1,568 +0,0 @@
|
|
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 |
-
if (! self::$wpPiwik->isNetworkMode() ) {
|
100 |
-
$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 . ');' : '') );
|
101 |
-
if (self::$wpPiwik->isConfigured ()) {
|
102 |
-
$piwikSiteDetails = self::$wpPiwik->getPiwikSiteDetails ();
|
103 |
-
if (($piwikSiteId == 'n/a'))
|
104 |
-
$piwikSiteDescription = 'n/a';
|
105 |
-
elseif (! self::$settings->getGlobalOption ( 'auto_site_config' ))
|
106 |
-
$piwikSiteDescription = __ ( 'Save settings to start estimation.', 'wp-piwik' );
|
107 |
-
else
|
108 |
-
$piwikSiteDescription = $piwikSiteDetails [$piwikSiteId] ['name'] . ' (' . $piwikSiteDetails [$piwikSiteId] ['main_url'] . ')';
|
109 |
-
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>';
|
110 |
-
if (is_array ( $piwikSiteDetails ))
|
111 |
-
foreach ( $piwikSiteDetails as $key => $siteData )
|
112 |
-
$siteList [$key] = $siteData ['name'] . ' (' . $siteData ['main_url'] . ')';
|
113 |
-
if (isset($siteList))
|
114 |
-
$this->showSelect ( 'site_id', __ ( 'Select site', 'wp-piwik' ), $siteList, 'TODO Choose description', '', self::$settings->getGlobalOption ( 'auto_site_config' ), 'wp-piwik-auto-option', true, false );
|
115 |
-
}
|
116 |
-
} else echo '<tr class="hidden"><td colspan="2"><input type="hidden" name="wp-piwik[auto_site_config]" value="1" /></td></tr>';
|
117 |
-
|
118 |
-
echo $submitButton;
|
119 |
-
|
120 |
-
echo '</tbody></table><table id="statistics" class="wp-piwik_menu-tab hidden"><tbody>';
|
121 |
-
// Stats configuration
|
122 |
-
$this->showSelect ( 'default_date', __ ( 'Piwik default date', 'wp-piwik' ), array (
|
123 |
-
'today' => __ ( 'Today', 'wp-piwik' ),
|
124 |
-
'yesterday' => __ ( 'Yesterday', 'wp-piwik' ),
|
125 |
-
'current_month' => __ ( 'Current month', 'wp-piwik' ),
|
126 |
-
'last_month' => __ ( 'Last month', 'wp-piwik' ),
|
127 |
-
'current_week' => __ ( 'Current week', 'wp-piwik' ),
|
128 |
-
'last_week' => __ ( 'Last week', 'wp-piwik' )
|
129 |
-
), __ ( 'Default date shown on statistics page.', 'wp-piwik' ) );
|
130 |
-
|
131 |
-
$this->showCheckbox ( 'stats_seo', __ ( 'Show SEO data', 'wp-piwik' ), __ ( 'Display SEO ranking data on statistics page.', 'wp-piwik' ) . ' (' . __ ( 'Slow!', 'wp-piwik' ) . ')' );
|
132 |
-
|
133 |
-
$this->showSelect ( 'dashboard_widget', __ ( 'Dashboard overview', 'wp-piwik' ), array (
|
134 |
-
'disabled' => __ ( 'Disabled', 'wp-piwik' ),
|
135 |
-
'yesterday' => __ ( 'Yesterday', 'wp-piwik' ),
|
136 |
-
'today' => __ ( 'Today', 'wp-piwik' ),
|
137 |
-
'last30' => __ ( 'Last 30 days', 'wp-piwik' )
|
138 |
-
), __ ( 'Enable WP-Piwik dashboard widget "Overview".', 'wp-piwik' ) );
|
139 |
-
|
140 |
-
$this->showCheckbox ( 'dashboard_chart', __ ( 'Dashboard graph', 'wp-piwik' ), __ ( 'Enable WP-Piwik dashboard widget "Graph".', 'wp-piwik' ) );
|
141 |
-
|
142 |
-
$this->showCheckbox ( 'dashboard_seo', __ ( 'Dashboard SEO', 'wp-piwik' ), __ ( 'Enable WP-Piwik dashboard widget "SEO".', 'wp-piwik' ) . ' (' . __ ( 'Slow!', 'wp-piwik' ) . ')' );
|
143 |
-
|
144 |
-
$this->showCheckbox ( 'toolbar', __ ( 'Show graph on WordPress Toolbar', 'wp-piwik' ), __ ( 'Display a last 30 days visitor graph on WordPress\' toolbar.', 'wp-piwik' ) );
|
145 |
-
|
146 |
-
echo '<tr><th scope="row"><label for="capability_read_stats">' . __ ( 'Display stats to', 'wp-piwik' ) . '</label>:</th><td>';
|
147 |
-
$filter = self::$settings->getGlobalOption ( 'capability_read_stats' );
|
148 |
-
foreach ( $wp_roles->role_names as $key => $name ) {
|
149 |
-
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);" />';
|
150 |
-
echo '<input id="capability_read_stats-' . $key . '-input" type="hidden" name="wp-piwik[capability_read_stats][' . $key . ']" value="' . ( int ) (isset ( $filter [$key] ) && $filter [$key]) . '" />';
|
151 |
-
echo $name . ' ';
|
152 |
-
}
|
153 |
-
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>';
|
154 |
-
|
155 |
-
$this->showCheckbox ( 'perpost_stats', __ ( 'Show per post stats', 'wp-piwik' ), __ ( 'Show stats about single posts at the post edit admin page.', 'wp-piwik' ) );
|
156 |
-
|
157 |
-
$this->showCheckbox ( 'piwik_shortcut', __ ( 'Piwik shortcut', 'wp-piwik' ), __ ( 'Display a shortcut to Piwik itself.', 'wp-piwik' ) );
|
158 |
-
|
159 |
-
$this->showInput ( 'plugin_display_name', __ ( 'WP-Piwik display name', 'wp-piwik' ), __ ( 'Plugin name shown in WordPress.', 'wp-piwik' ) );
|
160 |
-
|
161 |
-
$this->showCheckbox ( 'shortcodes', __ ( 'Enable shortcodes', 'wp-piwik' ), __ ( 'Enable shortcodes in post or page content.', 'wp-piwik' ) );
|
162 |
-
|
163 |
-
echo $submitButton;
|
164 |
-
|
165 |
-
echo '</tbody></table><table id="tracking" class="wp-piwik_menu-tab hidden"><tbody>';
|
166 |
-
|
167 |
-
// Tracking Configuration
|
168 |
-
$isNotTracking = self::$settings->getGlobalOption ( 'track_mode' ) == 'disabled';
|
169 |
-
$isNotGeneratedTracking = $isNotTracking || self::$settings->getGlobalOption ( 'track_mode' ) == 'manually';
|
170 |
-
$fullGeneratedTrackingGroup = 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js wp-piwik-track-option-proxy';
|
171 |
-
|
172 |
-
$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' ).( self::$wpPiwik->isNetworkMode() ? ' '.__ ( 'Use the placeholder {ID} to add the Piwik site ID.', 'wp-piwik' ) : '' ) );
|
173 |
-
$this->showSelect ( 'track_mode', __ ( 'Add tracking code', 'wp-piwik' ), array (
|
174 |
-
'disabled' => __ ( 'Disabled', 'wp-piwik' ),
|
175 |
-
'default' => __ ( 'Default tracking', 'wp-piwik' ),
|
176 |
-
'js' => __ ( 'Use js/index.php', 'wp-piwik' ),
|
177 |
-
'proxy' => __ ( 'Use proxy script', 'wp-piwik' ),
|
178 |
-
'manually' => __ ( 'Enter manually', 'wp-piwik' )
|
179 |
-
), $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\');' );
|
180 |
-
|
181 |
-
$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 );
|
182 |
-
|
183 |
-
$this->showSelect ( 'track_codeposition', __ ( 'JavaScript code position', 'wp-piwik' ), array (
|
184 |
-
'footer' => __ ( 'Footer', 'wp-piwik' ),
|
185 |
-
'header' => __ ( 'Header', 'wp-piwik' )
|
186 |
-
), __ ( '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' );
|
187 |
-
|
188 |
-
$this->showTextarea ( 'noscript_code', __ ( 'Noscript code', 'wp-piwik' ), 2, 'TODO noscript code desc', $isNotGeneratedTracking || self::$settings->getGlobalOption ( 'track_mode' ) == 'proxy', 'wp-piwik-track-option wp-piwik-track-option-default wp-piwik-track-option-js', true, '', true, false );
|
189 |
-
|
190 |
-
$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' );
|
191 |
-
|
192 |
-
$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' );
|
193 |
-
|
194 |
-
$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' );
|
195 |
-
|
196 |
-
$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' );
|
197 |
-
|
198 |
-
$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' );
|
199 |
-
|
200 |
-
$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' );
|
201 |
-
|
202 |
-
$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 );
|
203 |
-
|
204 |
-
$this->showCheckbox ( 'disable_cookies', __ ( 'Disable cookies', 'wp-piwik' ), __ ( 'Disable all tracking cookies for a visitor.', 'wp-piwik' ), $isNotGeneratedTracking, $fullGeneratedTrackingGroup );
|
205 |
-
|
206 |
-
$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\');' );
|
207 |
-
|
208 |
-
$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' );
|
209 |
-
|
210 |
-
$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' );
|
211 |
-
|
212 |
-
$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' );
|
213 |
-
|
214 |
-
echo '<tr class="' . $fullGeneratedTrackingGroup . ' wp-piwik-track-option-manually' . ($isNotTracking ? ' hidden' : '') . '">';
|
215 |
-
echo '<th scope="row"><label for="capability_stealth">' . __ ( 'Tracking filter', 'wp-piwik' ) . '</label>:</th><td>';
|
216 |
-
$filter = self::$settings->getGlobalOption ( 'capability_stealth' );
|
217 |
-
foreach ( $wp_roles->role_names as $key => $name )
|
218 |
-
echo '<input type="checkbox" ' . (isset ( $filter [$key] ) && $filter [$key] ? 'checked="checked" ' : '') . 'value="1" name="wp-piwik[capability_stealth][' . $key . ']" /> ' . $name . ' ';
|
219 |
-
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>';
|
220 |
-
|
221 |
-
$this->showCheckbox ( 'track_across', __ ( 'Track visitors across all subdomains', 'wp-piwik' ), __ ( 'Adds *.-prefix to cookie domain.', 'wp-piwik' ), $isNotGeneratedTracking, $fullGeneratedTrackingGroup );
|
222 |
-
|
223 |
-
$this->showCheckbox ( 'track_across_alias', __ ( 'Track visitors across all alias URLs', 'wp-piwik' ), __ ( 'Adds *.-prefix to tracked domain.', 'wp-piwik' ), $isNotGeneratedTracking, $fullGeneratedTrackingGroup );
|
224 |
-
|
225 |
-
$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' );
|
226 |
-
|
227 |
-
$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\');' );
|
228 |
-
|
229 |
-
$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' );
|
230 |
-
|
231 |
-
echo $submitButton;
|
232 |
-
echo '</tbody></table><table id="expert" class="wp-piwik_menu-tab hidden"><tbody>';
|
233 |
-
|
234 |
-
$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' ) );
|
235 |
-
|
236 |
-
$this->showCheckbox ( 'cache', __ ( 'Enable cache', 'wp-piwik' ), __ ( 'Cache API calls, which not contain today\'s values, for a week.', 'wp-piwik' ) );
|
237 |
-
|
238 |
-
$this->showCheckbox ( 'disable_timelimit', __ ( 'Disable time limit', 'wp-piwik' ), __ ( 'Use set_time_limit(0) if stats page causes a time out.', 'wp-piwik' ) );
|
239 |
-
|
240 |
-
$this->showInput ( 'connection_timeout', __ ( 'Connection timeout', 'wp-piwik' ), 'TODO Connection timeout description' );
|
241 |
-
|
242 |
-
$this->showCheckbox ( 'disable_ssl_verify', __ ( 'Disable SSL peer verification', 'wp-piwik' ), '(' . __ ( 'not recommended', 'wp-piwik' ) . ')' );
|
243 |
-
|
244 |
-
$this->showSelect ( 'piwik_useragent', __ ( 'User agent', 'wp-piwik' ), array (
|
245 |
-
'php' => __ ( 'Use the PHP default user agent', 'wp-piwik' ) . (ini_get ( 'user_agent' ) ? '(' . ini_get ( 'user_agent' ) . ')' : ' (' . __ ( 'empty', 'wp-piwik' ) . ')'),
|
246 |
-
'own' => __ ( 'Define a specific user agent', 'wp-piwik' )
|
247 |
-
), 'TODO User agent description', '$j(\'tr.wp-piwik-useragent-option\').toggleClass(\'hidden\');' );
|
248 |
-
$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' );
|
249 |
-
|
250 |
-
$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' ) );
|
251 |
-
|
252 |
-
$this->showInput ( 'track_cdnurl', __ ( 'CDN URL', 'wp-piwik' ), 'Enter URL if you want to load the tracking code via CDN.' );
|
253 |
-
|
254 |
-
$this->showInput ( 'track_cdnurlssl', __ ( 'CDN URL (SSL)', 'wp-piwik' ), 'Enter URL if you want to load the tracking code via a separate SSL CDN.' );
|
255 |
-
|
256 |
-
$this->showSelect ( 'force_protocol', __ ( 'Force Piwik to use a specific protocol', 'wp-piwik' ), array (
|
257 |
-
'disabled' => __ ( 'Disabled (default)', 'wp-piwik' ),
|
258 |
-
'http' => __ ( 'http', 'wp-piwik' ),
|
259 |
-
'https' => __ ( 'https (SSL)', 'wp-piwik' )
|
260 |
-
), __ ( 'Choose if you want to explicitly force Piwik to use HTTP or HTTPS. Does not work with a CDN URL.', 'wp-piwik' ) );
|
261 |
-
|
262 |
-
echo $submitButton;
|
263 |
-
?>
|
264 |
-
</tbody>
|
265 |
-
</table>
|
266 |
-
<table id="support" class="wp-piwik_menu-tab hidden">
|
267 |
-
<tbody>
|
268 |
-
<tr><td colspan="2"><?php
|
269 |
-
echo $this->showSupport();
|
270 |
-
?></td></tr>
|
271 |
-
</tbody>
|
272 |
-
</table>
|
273 |
-
<table id="credits" class="wp-piwik_menu-tab hidden">
|
274 |
-
<tbody>
|
275 |
-
<tr><td colspan="2"><?php
|
276 |
-
echo $this->showCredits();
|
277 |
-
?></td></tr>
|
278 |
-
</tbody>
|
279 |
-
</table>
|
280 |
-
<input type="hidden" name="wp-piwik[proxy_url]"
|
281 |
-
value="<?php echo self::$settings->getGlobalOption('proxy_url'); ?>" />
|
282 |
-
</form>
|
283 |
-
</div>
|
284 |
-
<?php
|
285 |
-
}
|
286 |
-
|
287 |
-
/**
|
288 |
-
* Show an option's description
|
289 |
-
*
|
290 |
-
* @param string $id option id
|
291 |
-
* @param string $description option description
|
292 |
-
* @param boolean $hideDescription set to false to show description initially (default: true)
|
293 |
-
* @return string full description HTML
|
294 |
-
*/
|
295 |
-
private function getDescription($id, $description, $hideDescription = true) {
|
296 |
-
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 );
|
297 |
-
}
|
298 |
-
|
299 |
-
/**
|
300 |
-
* Show a checkbox option
|
301 |
-
*
|
302 |
-
* @param string $id option id
|
303 |
-
* @param string $name descriptive option name
|
304 |
-
* @param string $description option description
|
305 |
-
* @param boolean $isHidden set to true to initially hide the option (default: false)
|
306 |
-
* @param string $groupName define a class name to access a group of option rows by javascript (default: empty)
|
307 |
-
* @param boolean $hideDescription $hideDescription set to false to show description initially (default: true)
|
308 |
-
* @param string $onChange javascript for onchange event (default: empty)
|
309 |
-
*/
|
310 |
-
private function showCheckbox($id, $name, $description, $isHidden = false, $groupName = '', $hideDescription = true, $onChange = '') {
|
311 |
-
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 ) );
|
312 |
-
}
|
313 |
-
|
314 |
-
/**
|
315 |
-
* Show a textarea option
|
316 |
-
*
|
317 |
-
* @param string $id option id
|
318 |
-
* @param string $name descriptive option name
|
319 |
-
* @param int $rows number of rows to show
|
320 |
-
* @param string $description option description
|
321 |
-
* @param boolean $isHidden set to true to initially hide the option (default: false)
|
322 |
-
* @param string $groupName define a class name to access a group of option rows by javascript (default: empty)
|
323 |
-
* @param boolean $hideDescription $hideDescription set to false to show description initially (default: true)
|
324 |
-
* @param string $onChange javascript for onchange event (default: empty)
|
325 |
-
* @param boolean $isReadonly set textarea to read only (default: false)
|
326 |
-
* @param boolean $global set to false if the textarea shows a site-specific option (default: true)
|
327 |
-
*/
|
328 |
-
private function showTextarea($id, $name, $rows, $description, $isHidden, $groupName, $hideDescription = true, $onChange = '', $isReadonly = false, $global = true) {
|
329 |
-
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 ) );
|
330 |
-
}
|
331 |
-
|
332 |
-
/**
|
333 |
-
* Show a simple text
|
334 |
-
*
|
335 |
-
* @param string $text Text to show
|
336 |
-
*/
|
337 |
-
private function showText($text) {
|
338 |
-
printf ( '<tr><td colspan="2"><p>%s</p></td></tr>', $text );
|
339 |
-
}
|
340 |
-
|
341 |
-
/**
|
342 |
-
* Show an input option
|
343 |
-
*
|
344 |
-
* @param string $id option id
|
345 |
-
* @param string $name descriptive option name
|
346 |
-
* @param string $description option description
|
347 |
-
* @param boolean $isHidden set to true to initially hide the option (default: false)
|
348 |
-
* @param string $groupName define a class name to access a group of option rows by javascript (default: empty)
|
349 |
-
* @param string $rowName define a class name to access the specific option row by javascript (default: empty)
|
350 |
-
* @param boolean $hideDescription $hideDescription set to false to show description initially (default: true)
|
351 |
-
*/
|
352 |
-
private function showInput($id, $name, $description, $isHidden = false, $groupName = '', $rowName = false, $hideDescription = true) {
|
353 |
-
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 ) );
|
354 |
-
}
|
355 |
-
|
356 |
-
/**
|
357 |
-
* Show a select box option
|
358 |
-
*
|
359 |
-
* @param string $id option id
|
360 |
-
* @param string $name descriptive option name
|
361 |
-
* @param array $options list of options to show array[](option id => descriptive name)
|
362 |
-
* @param string $description option description
|
363 |
-
* @param string $onChange javascript for onchange event (default: empty)
|
364 |
-
* @param boolean $isHidden set to true to initially hide the option (default: false)
|
365 |
-
* @param string $groupName define a class name to access a group of option rows by javascript (default: empty)
|
366 |
-
* @param boolean $hideDescription $hideDescription set to false to show description initially (default: true)
|
367 |
-
* @param boolean $global set to false if the textarea shows a site-specific option (default: true)
|
368 |
-
*/
|
369 |
-
private function showSelect($id, $name, $options = array(), $description = '', $onChange = '', $isHidden = false, $groupName = '', $hideDescription = true, $global = true) {
|
370 |
-
$optionList = '';
|
371 |
-
$default = $global ? self::$settings->getGlobalOption ( $id ) : self::$settings->getOption ( $id );
|
372 |
-
if (is_array ( $options ))
|
373 |
-
foreach ( $options as $key => $value )
|
374 |
-
$optionList .= sprintf ( '<option value="%s"' . ($key == $default ? ' selected="selected"' : '') . '>%s</option>', $key, $value );
|
375 |
-
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 ) );
|
376 |
-
}
|
377 |
-
|
378 |
-
/**
|
379 |
-
* Show an info box
|
380 |
-
*
|
381 |
-
* @param string $type box style (e.g., updated, error)
|
382 |
-
* @param string $icon box icon, see https://developer.wordpress.org/resource/dashicons/
|
383 |
-
* @param string $content box message
|
384 |
-
*/
|
385 |
-
private function showBox($type, $icon, $content) {
|
386 |
-
printf ( '<tr><td colspan="2"><div class="%s"><p><span class="dashicons dashicons-%s"></span> %s</p></div></td></tr>', $type, $icon, $content );
|
387 |
-
}
|
388 |
-
|
389 |
-
/**
|
390 |
-
* Show headline
|
391 |
-
* @param int $order headline order (h?-tag), set to 0 to avoid headline-tagging
|
392 |
-
* @param string $icon headline icon, see https://developer.wordpress.org/resource/dashicons/
|
393 |
-
* @param string $headline headline text
|
394 |
-
* @param string $addPluginName set to true to add the plugin name to the headline (default: false)
|
395 |
-
*/
|
396 |
-
private function showHeadline($order, $icon, $headline, $addPluginName = false) {
|
397 |
-
echo $this->getHeadline ( $order, $icon, $headline, $addPluginName = false );
|
398 |
-
}
|
399 |
-
|
400 |
-
/**
|
401 |
-
* Get headline HTML
|
402 |
-
*
|
403 |
-
* @param int $order headline order (h?-tag), set to 0 to avoid headline-tagging
|
404 |
-
* @param string $icon headline icon, see https://developer.wordpress.org/resource/dashicons/
|
405 |
-
* @param string $headline headline text
|
406 |
-
* @param string $addPluginName set to true to add the plugin name to the headline (default: false)
|
407 |
-
*/
|
408 |
-
private function getHeadline($order, $icon, $headline, $addPluginName = false) {
|
409 |
-
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>" : '');
|
410 |
-
}
|
411 |
-
|
412 |
-
/**
|
413 |
-
* Show donation info
|
414 |
-
*/
|
415 |
-
private function showDonation() {
|
416 |
-
?>
|
417 |
-
<div class="wp-piwik-donate">
|
418 |
-
<p>
|
419 |
-
<strong><?php _e('Donate','wp-piwik'); ?></strong>
|
420 |
-
</p>
|
421 |
-
<p><?php _e('If you like WP-Piwik, you can support its development by a donation:', 'wp-piwik'); ?></p>
|
422 |
-
<script type="text/javascript">
|
423 |
-
/* <![CDATA[ */
|
424 |
-
window.onload = function() {
|
425 |
-
FlattrLoader.render({
|
426 |
-
'uid': 'flattr',
|
427 |
-
'url': 'http://wp.local',
|
428 |
-
'title': 'Title of the thing',
|
429 |
-
'description': 'Description of the thing'
|
430 |
-
}, 'element_id', 'replace');
|
431 |
-
}
|
432 |
-
/* ]]> */
|
433 |
-
</script>
|
434 |
-
<div>
|
435 |
-
<a class="FlattrButton" style="display: none;"
|
436 |
-
title="WordPress Plugin WP-Piwik"
|
437 |
-
rel="flattr;uid:braekling;category:software;tags:wordpress,piwik,plugin,statistics;"
|
438 |
-
href="https://www.braekling.de/wp-piwik-wpmu-piwik-wordpress">This
|
439 |
-
WordPress plugin adds a Piwik stats site to your WordPress dashboard.
|
440 |
-
It's also able to add the Piwik tracking code to your blog using
|
441 |
-
wp_footer. You need a running Piwik installation and at least view
|
442 |
-
access to your stats.</a>
|
443 |
-
</div>
|
444 |
-
<div>
|
445 |
-
Paypal
|
446 |
-
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
447 |
-
<input type="hidden" name="cmd" value="_s-xclick" /> <input
|
448 |
-
type="hidden" name="hosted_button_id" value="6046779" /> <input
|
449 |
-
type="image"
|
450 |
-
src="https://www.paypal.com/en_GB/i/btn/btn_donateCC_LG.gif"
|
451 |
-
name="submit" alt="PayPal - The safer, easier way to pay online." />
|
452 |
-
<img alt="" border="0"
|
453 |
-
src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1"
|
454 |
-
height="1" />
|
455 |
-
</form>
|
456 |
-
</div>
|
457 |
-
<div>
|
458 |
-
<a
|
459 |
-
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>
|
460 |
-
</div>
|
461 |
-
<div>
|
462 |
-
<?php _e('Please don\'t forget to vote the compatibility at the','wp-piwik'); ?> <a
|
463 |
-
href="http://wordpress.org/extend/plugins/wp-piwik/">WordPress.org
|
464 |
-
Plugin Directory</a>.
|
465 |
-
</div>
|
466 |
-
</div><?php
|
467 |
-
}
|
468 |
-
|
469 |
-
/**
|
470 |
-
* Register admin scripts
|
471 |
-
*
|
472 |
-
* @see \WP_Piwik\Admin::printAdminScripts()
|
473 |
-
*/
|
474 |
-
public function printAdminScripts() {
|
475 |
-
wp_enqueue_script ( 'jquery' );
|
476 |
-
}
|
477 |
-
|
478 |
-
/**
|
479 |
-
* Extend admin header
|
480 |
-
*
|
481 |
-
* @see \WP_Piwik\Admin::extendAdminHeader()
|
482 |
-
*/
|
483 |
-
public function extendAdminHeader() {
|
484 |
-
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
|
485 |
-
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>';
|
486 |
-
}
|
487 |
-
|
488 |
-
/**
|
489 |
-
* Show credits
|
490 |
-
*/
|
491 |
-
public function showCredits() {
|
492 |
-
?>
|
493 |
-
<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>
|
494 |
-
<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>
|
495 |
-
<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>
|
496 |
-
<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>
|
497 |
-
<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>
|
498 |
-
<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>
|
499 |
-
<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>
|
500 |
-
<?php
|
501 |
-
}
|
502 |
-
|
503 |
-
/**
|
504 |
-
* Show support information
|
505 |
-
*/
|
506 |
-
public function showSupport() {
|
507 |
-
?><ul>
|
508 |
-
<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>
|
509 |
-
<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>
|
510 |
-
</ul>
|
511 |
-
<h3><?php _e('Debugging', 'wp-piwik'); ?></h3>
|
512 |
-
<p><?php _e('Either allow_url_fopen has to be enabled <em>or</em> cURL has to be available:', 'wp-piwik'); ?></p>
|
513 |
-
<ol>
|
514 |
-
<li><?php
|
515 |
-
_e('cURL is','wp-piwik');
|
516 |
-
echo ' <strong>'.(function_exists('curl_init')?'':__('not','wp-piwik')).' ';
|
517 |
-
_e('available','wp-piwik');
|
518 |
-
?></strong>.</li>
|
519 |
-
<li><?php
|
520 |
-
_e('allow_url_fopen is','wp-piwik');
|
521 |
-
echo ' <strong>'.(ini_get('allow_url_fopen')?'':__('not','wp-piwik')).' ';
|
522 |
-
_e('enabled','wp-piwik');
|
523 |
-
?></strong>.</li>
|
524 |
-
</ol>
|
525 |
-
<h3><?php _e('Latest support threads on WordPress.org', 'wp-piwik'); ?></h3><?php
|
526 |
-
$supportThreads = $this->readRSSFeed('http://wordpress.org/support/rss/plugin/wp-piwik');
|
527 |
-
if (!empty($supportThreads)) {
|
528 |
-
echo '<ol>';
|
529 |
-
foreach ($supportThreads as $supportThread)
|
530 |
-
echo '<li><a href="'.$supportThread['url'].'">'.$supportThread['title'].'</a></li>';
|
531 |
-
echo '</ol>';
|
532 |
-
}
|
533 |
-
}
|
534 |
-
|
535 |
-
/**
|
536 |
-
* Read RSS feed
|
537 |
-
*
|
538 |
-
* @param string $feed
|
539 |
-
* feed URL
|
540 |
-
* @param int $cnt
|
541 |
-
* item limit
|
542 |
-
* @return array feed items array[](title, url)
|
543 |
-
*
|
544 |
-
*/
|
545 |
-
private function readRSSFeed($feed, $cnt = 5) {
|
546 |
-
$result = array ();
|
547 |
-
if (function_exists ( 'simplexml_load_file' ) && ! empty ( $feed )) {
|
548 |
-
$xml = @simplexml_load_file ( $feed );
|
549 |
-
if (! $xml || ! isset ( $xml->channel [0]->item ))
|
550 |
-
return array (
|
551 |
-
array (
|
552 |
-
'title' => 'Can\'t read RSS feed.',
|
553 |
-
'url' => $xml
|
554 |
-
)
|
555 |
-
);
|
556 |
-
foreach ( $xml->channel [0]->item as $item ) {
|
557 |
-
if ($cnt -- == 0)
|
558 |
-
break;
|
559 |
-
$result [] = array (
|
560 |
-
'title' => $item->title [0],
|
561 |
-
'url' => $item->link [0]
|
562 |
-
);
|
563 |
-
}
|
564 |
-
}
|
565 |
-
return $result;
|
566 |
-
}
|
567 |
-
|
568 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Admin/Sitebrowser.php
DELETED
@@ -1,93 +0,0 @@
|
|
1 |
-
<?php
|
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'),
|
29 |
-
'siteurl' => __('URL','wp-piwik'),
|
30 |
-
'piwikid' => __('Site ID (Piwik)','wp-piwik')
|
31 |
-
);
|
32 |
-
return $columns;
|
33 |
-
}
|
34 |
-
|
35 |
-
public function prepare_items() {
|
36 |
-
$current_page = $this->get_pagenum();
|
37 |
-
$per_page = 10;
|
38 |
-
global $blog_id;
|
39 |
-
global $wpdb;
|
40 |
-
global $pagenow;
|
41 |
-
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
|
42 |
-
$total_items = $wpdb->get_var('SELECT COUNT(*) FROM '.$wpdb->blogs);
|
43 |
-
$blogs = $wpdb->get_results($wpdb->prepare('SELECT blog_id FROM '.$wpdb->blogs.' ORDER BY blog_id LIMIT %d,%d',(($current_page-1)*$per_page),$per_page));
|
44 |
-
foreach ($blogs as $blog) {
|
45 |
-
$blogDetails = get_blog_details($blog->blog_id, true);
|
46 |
-
$this->data[] = array(
|
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 {
|
54 |
-
$blogDetails = get_bloginfo();
|
55 |
-
$this->data[] = array(
|
56 |
-
'name' => get_bloginfo('name'),
|
57 |
-
'id' => '-',
|
58 |
-
'siteurl' => get_bloginfo('url'),
|
59 |
-
'piwikid' => $this->wpPiwik->getPiwikSiteId()
|
60 |
-
);
|
61 |
-
$total_items = 1;
|
62 |
-
}
|
63 |
-
$columns = $this->get_columns();
|
64 |
-
$hidden = array();
|
65 |
-
$sortable = array();
|
66 |
-
$this->_column_headers = array($columns, $hidden, $sortable);
|
67 |
-
$this->set_pagination_args(array(
|
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;
|
78 |
-
return count($this->items);
|
79 |
-
}
|
80 |
-
|
81 |
-
function column_default( $item, $column_name ) {
|
82 |
-
switch( $column_name ) {
|
83 |
-
case 'id':
|
84 |
-
case 'name':
|
85 |
-
case 'siteurl':
|
86 |
-
case 'piwikid':
|
87 |
-
return $item[$column_name];
|
88 |
-
default:
|
89 |
-
return print_r($item,true);
|
90 |
-
}
|
91 |
-
}
|
92 |
-
|
93 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Admin/Statistics.php
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Admin;
|
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>';
|
21 |
-
echo '</form>'."\n";
|
22 |
-
}
|
23 |
-
echo '<form action="admin-post.php" method="post"><input type="hidden" name="action" value="save_wp-piwik_stats_general" /><div id="dashboard-widgets" class="metabox-holder columns-'.$screen_layout_columns.(2 <= $screen_layout_columns?' has-right-sidebar':'').'">';
|
24 |
-
wp_nonce_field('wp-piwik_stats-general');
|
25 |
-
wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
|
26 |
-
wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
|
27 |
-
$columns = array('normal', 'side', 'column3');
|
28 |
-
for ($i = 0; $i < 3; $i++) {
|
29 |
-
echo '<div id="postbox-container-'.($i+1).'" class="postbox-container">';
|
30 |
-
do_meta_boxes(self::$wpPiwik->statsPageId, $columns[$i], null);
|
31 |
-
echo '</div>';
|
32 |
-
}
|
33 |
-
echo '</div></form></div>';
|
34 |
-
echo '<script type="text/javascript">//<![CDATA['."\n";
|
35 |
-
echo 'jQuery(document).ready(function($) {$(".if-js-closed").removeClass("if-js-closed").addClass("closed"); postboxes.add_postbox_toggles("'.self::$wpPiwik->statsPageId.'");});'."\n";
|
36 |
-
echo '//]]></script>'."\n";
|
37 |
-
if (self::$settings->checkNetworkActivation() && function_exists('is_super_admin') && is_super_admin()) {
|
38 |
-
restore_current_blog();
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
public function printAdminScripts() {
|
43 |
-
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
44 |
-
wp_enqueue_script('wp-piwik-jqplot', self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'), self::$wpPiwik->getPluginVersion());
|
45 |
-
}
|
46 |
-
|
47 |
-
public function extendAdminHeader() {
|
48 |
-
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.(self::$wpPiwik->getPluginURL()).'js/jqplot/excanvas.min.js"></script><![endif]-->';
|
49 |
-
echo '<link rel="stylesheet" href="'.(self::$wpPiwik->getPluginURL()).'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
|
50 |
-
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
|
51 |
-
}
|
52 |
-
|
53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Logger/Dummy.php
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Logger;
|
4 |
-
|
5 |
-
class Dummy extends \WP_Piwik\Logger {
|
6 |
-
|
7 |
-
public function loggerOutput($loggerTime, $loggerMessage) {}
|
8 |
-
|
9 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Logger/Screen.php
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Logger;
|
4 |
-
|
5 |
-
class Screen extends \WP_Piwik\Logger {
|
6 |
-
|
7 |
-
private $logs = array();
|
8 |
-
|
9 |
-
private function formatMicrotime($loggerTime) {
|
10 |
-
return sprintf('[%6s sec]',number_format($loggerTime,3));
|
11 |
-
}
|
12 |
-
|
13 |
-
public function __construct($loggerName) {
|
14 |
-
add_action(is_admin()?'admin_footer':'wp_footer', array($this, 'echoResults'));
|
15 |
-
parent::__construct($loggerName);
|
16 |
-
}
|
17 |
-
|
18 |
-
public function loggerOutput($loggerTime, $loggerMessage) {
|
19 |
-
$this->logs[] = $this->formatMicrotime($loggerTime).' '.$loggerMessage;
|
20 |
-
}
|
21 |
-
|
22 |
-
public function echoResults() {
|
23 |
-
echo '<pre>';
|
24 |
-
print_r($this->logs);
|
25 |
-
echo '</pre>';
|
26 |
-
}
|
27 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Request.php
DELETED
@@ -1,74 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik;
|
4 |
-
|
5 |
-
abstract class Request {
|
6 |
-
|
7 |
-
protected static $wpPiwik, $settings, $requests = array(), $results = array(), $isCacheable = array(), $piwikVersion;
|
8 |
-
|
9 |
-
public function __construct($wpPiwik, $settings) {
|
10 |
-
self::$wpPiwik = $wpPiwik;
|
11 |
-
self::$settings = $settings;
|
12 |
-
self::register('API.getPiwikVersion', array());
|
13 |
-
}
|
14 |
-
|
15 |
-
public static function register($method, $parameter) {
|
16 |
-
if ($method == 'API.getPiwikVersion')
|
17 |
-
$id = 'global.getPiwikVersion';
|
18 |
-
else
|
19 |
-
$id = 'method='.$method.self::parameterToString($parameter);
|
20 |
-
if (
|
21 |
-
in_array( $method, array( 'API.getPiwikVersion', 'SitesManager.getJavascriptTag', 'SitesManager.getAllSites', 'SitesManager.getSitesIdFromSiteUrl', 'SitesManager.addSite', 'SitesManager.updateSite' ) ) ||
|
22 |
-
substr($parameter['date'], 0, 4) == 'last' ||
|
23 |
-
$parameter['date'] == 'today' ||
|
24 |
-
( $parameter['period'] == 'day' && $parameter['date'] == date('Ymd') ) ||
|
25 |
-
( $parameter['period'] == 'month' && $parameter['date'] == date('Ym') ) ||
|
26 |
-
( $parameter['period'] == 'week' && $parameter['date'] == date( 'Ymd', strtotime( "last Monday" ) ) )
|
27 |
-
) self::$isCacheable[$id] = false;
|
28 |
-
else self::$isCacheable[$id] = $method.'-'.$parameter['period'].'-'.$parameter['date'];
|
29 |
-
if (!isset(self::$requests[$id]))
|
30 |
-
self::$requests[$id] = array('method' => $method, 'parameter' => $parameter);
|
31 |
-
return $id;
|
32 |
-
}
|
33 |
-
private static function parameterToString($parameter) {
|
34 |
-
$return = '';
|
35 |
-
if (is_array($parameter))
|
36 |
-
foreach ($parameter as $key => $value)
|
37 |
-
$return .= '&'.$key.'='.$value;
|
38 |
-
return $return;
|
39 |
-
}
|
40 |
-
|
41 |
-
public function perform($id) {
|
42 |
-
if ( self::$settings->getGlobalOption('cache') && false !== ( $cached = get_transient( 'wp-piwik_c_'.md5(self::$isCacheable[$id] ) ) ) ) {
|
43 |
-
self::$wpPiwik->log("Deliver cached data: ".$id);
|
44 |
-
return $cached;
|
45 |
-
}
|
46 |
-
self::$wpPiwik->log("Perform request: ".$id);
|
47 |
-
if (!isset(self::$requests[$id]))
|
48 |
-
return array('result' => 'error', 'message' => 'Request '.$id.' was not registered.');
|
49 |
-
elseif (!isset(self::$results[$id])) {
|
50 |
-
$this->request($id);
|
51 |
-
}
|
52 |
-
if ( isset ( self::$results[$id] )) {
|
53 |
-
if ( self::$settings->getGlobalOption('cache') && self::$isCacheable[$id] ) {
|
54 |
-
set_transient( 'wp-piwik_c_'.md5(self::$isCacheable[$id]) , self::$results[$id], WEEK_IN_SECONDS );
|
55 |
-
}
|
56 |
-
return self::$results[$id];
|
57 |
-
} else return false;
|
58 |
-
}
|
59 |
-
|
60 |
-
protected function buildURL($config, $urlDecode = false) {
|
61 |
-
$url = 'method='.($config['method']).'&idSite='.self::$settings->getOption('site_id');
|
62 |
-
foreach ($config['parameter'] as $key => $value)
|
63 |
-
$url .= '&'.$key.'='.($urlDecode?urldecode($value):$value);
|
64 |
-
return $url;
|
65 |
-
}
|
66 |
-
|
67 |
-
protected function unserialize($str) {
|
68 |
-
self::$wpPiwik->log("Result string: ".$str);
|
69 |
-
return ($str == serialize(false) || @unserialize($str) !== false)?unserialize($str):array();
|
70 |
-
}
|
71 |
-
|
72 |
-
abstract protected function request($id);
|
73 |
-
|
74 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Request/Php.php
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Request;
|
4 |
-
|
5 |
-
class Php extends \WP_Piwik\Request {
|
6 |
-
|
7 |
-
protected function request($id) {
|
8 |
-
$count = 0;
|
9 |
-
$url = self::$settings->getGlobalOption('piwik_url');
|
10 |
-
foreach (self::$requests as $requestID => $config) {
|
11 |
-
if (!isset(self::$results[$requestID])) {
|
12 |
-
$params = 'module=API&format=php&'.$this->buildURL($config, true);
|
13 |
-
$map[$count] = $requestID;
|
14 |
-
$result = $this->call($url, $params);
|
15 |
-
self::$results[$map[$count]] = $result;
|
16 |
-
$count++;
|
17 |
-
}
|
18 |
-
}
|
19 |
-
}
|
20 |
-
|
21 |
-
private function call($url, $params) {
|
22 |
-
if (!defined('PIWIK_INCLUDE_PATH'))
|
23 |
-
return;
|
24 |
-
if (PIWIK_INCLUDE_PATH === FALSE)
|
25 |
-
return serialize(array('result' => 'error', 'message' => __('Could not resolve','wp-piwik').' "'.htmlentities(self::$settings->getGlobalOption('piwik_path')).'": '.__('realpath() returns false','wp-piwik').'.'));
|
26 |
-
if (file_exists(PIWIK_INCLUDE_PATH . "/index.php"))
|
27 |
-
require_once PIWIK_INCLUDE_PATH . "/index.php";
|
28 |
-
if (file_exists(PIWIK_INCLUDE_PATH . "/core/API/Request.php"))
|
29 |
-
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
|
30 |
-
if (class_exists('Piwik\FrontController'))
|
31 |
-
\Piwik\FrontController::getInstance()->init();
|
32 |
-
else serialize(array('result' => 'error', 'message' => __('Class Piwik\FrontController does not exists.','wp-piwik')));
|
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);
|
41 |
-
}
|
42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Request/Rest.php
DELETED
@@ -1,52 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Request;
|
4 |
-
|
5 |
-
class Rest extends \WP_Piwik\Request {
|
6 |
-
|
7 |
-
protected function request($id) {
|
8 |
-
$count = 0;
|
9 |
-
$url = self::$settings->getGlobalOption('piwik_mode') == 'http'?
|
10 |
-
self::$settings->getGlobalOption('piwik_url'):
|
11 |
-
'https://'.self::$settings->getGlobalOption('piwik_user').'.piwik.pro/';
|
12 |
-
$params = 'module=API&method=API.getBulkRequest&format=php';
|
13 |
-
foreach (self::$requests as $requestID => $config) {
|
14 |
-
if (!isset(self::$results[$requestID])) {
|
15 |
-
$params .= '&urls['.$count.']='.urlencode($this->buildURL($config));
|
16 |
-
$map[$count] = $requestID;
|
17 |
-
$count++;
|
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) {
|
27 |
-
$c = curl_init($url);
|
28 |
-
curl_setopt($c, CURLOPT_POST, 1);
|
29 |
-
curl_setopt($c, CURLOPT_POSTFIELDS, $params.'&token_auth='.self::$settings->getGlobalOption('piwik_token'));
|
30 |
-
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, !self::$settings->getGlobalOption('disable_ssl_verify'));
|
31 |
-
curl_setopt($c, CURLOPT_USERAGENT, self::$settings->getGlobalOption('piwik_useragent')=='php'?ini_get('user_agent'):self::$settings->getGlobalOption('piwik_useragent_string'));
|
32 |
-
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
|
33 |
-
curl_setopt($c, CURLOPT_HEADER, 0);
|
34 |
-
curl_setopt($c, CURLOPT_TIMEOUT, self::$settings->getGlobalOption('connection_timeout'));
|
35 |
-
$httpProxyClass = new \WP_HTTP_Proxy();
|
36 |
-
if ($httpProxyClass->is_enabled() && $httpProxyClass->send_through_proxy($strURL)) {
|
37 |
-
curl_setopt($c, CURLOPT_PROXY, $httpProxyClass->host());
|
38 |
-
curl_setopt($c, CURLOPT_PROXYPORT, $httpProxyClass->port());
|
39 |
-
if ($httpProxyClass->use_authentication())
|
40 |
-
curl_setopt($c, CURLOPT_PROXYUSERPWD, $httpProxyClass->username().':'.$httpProxyClass->password());
|
41 |
-
}
|
42 |
-
$result = curl_exec($c);
|
43 |
-
curl_close($c);
|
44 |
-
return $this->unserialize($result);
|
45 |
-
}
|
46 |
-
|
47 |
-
private function fopen($url, $params) {
|
48 |
-
$context = stream_context_create(array('http'=>array('timeout' => self::$settings->getGlobalOption('connection_timeout'))));
|
49 |
-
$result = @file_get_contents($url.'?'.$params.'&token_auth='.self::$settings->getGlobalOption('piwik_token'), false, $context);
|
50 |
-
return unserialize($result);
|
51 |
-
}
|
52 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Settings.php
DELETED
@@ -1,369 +0,0 @@
|
|
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->settingsChanged = 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 |
-
if ( $this->checkNetworkActivation() )
|
347 |
-
add_site_option( 'wp-piwik-manually', $value );
|
348 |
-
return $value;
|
349 |
-
}
|
350 |
-
$result = self::$wpPiwik->updateTrackingCode ();
|
351 |
-
$this->setOption ( 'noscript_code', $result ['noscript'] );
|
352 |
-
return $result ['script'];
|
353 |
-
}
|
354 |
-
|
355 |
-
/**
|
356 |
-
* Prepare the nocscript code
|
357 |
-
*
|
358 |
-
* @param string $value
|
359 |
-
* noscript code
|
360 |
-
* @param array $in
|
361 |
-
* configuration set
|
362 |
-
* @return string noscript code
|
363 |
-
*/
|
364 |
-
private function prepareNocscriptCode($value, $in) {
|
365 |
-
if ($in ['track_mode'] == 'manually')
|
366 |
-
return stripslashes ( $value );
|
367 |
-
return $value;
|
368 |
-
}
|
369 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Shortcode.php
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik;
|
4 |
-
|
5 |
-
class Shortcode {
|
6 |
-
|
7 |
-
private $available = array(
|
8 |
-
'opt-out' => 'OptOut',
|
9 |
-
'post' => 'Post',
|
10 |
-
'overview' => 'Overview'
|
11 |
-
);
|
12 |
-
|
13 |
-
public function __construct($attributes, $wpPiwik, $settings) {
|
14 |
-
$wpPiwik->log('Check requested shortcode widget '.$attributes['module']);
|
15 |
-
if (isset($attributes['module']) && isset($this->available[$attributes['module']])) {
|
16 |
-
$wpPiwik->log('Add shortcode widget '.$this->available[$attributes['module']]);
|
17 |
-
$class = '\\WP_Piwik\\Widget\\'.$this->available[$attributes['module']];
|
18 |
-
$widget = new $class($wpPiwik, $settings, null, null, null, $attributes, true);
|
19 |
-
$widget->show();
|
20 |
-
}
|
21 |
-
}
|
22 |
-
|
23 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Template/MetaBoxCustomVars.php
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Template;
|
4 |
-
|
5 |
-
class MetaBoxCustomVars extends \WP_Piwik\Template {
|
6 |
-
|
7 |
-
public function addMetabox() {
|
8 |
-
add_meta_box(
|
9 |
-
'wp-piwik_post_customvars',
|
10 |
-
__('Piwik Custom Variables', 'wp-piwik'),
|
11 |
-
array(&$this, 'showCustomvars'),
|
12 |
-
'post',
|
13 |
-
'side',
|
14 |
-
'default'
|
15 |
-
);
|
16 |
-
}
|
17 |
-
|
18 |
-
public function showCustomvars($objPost, $objBox ) {
|
19 |
-
wp_nonce_field(basename( __FILE__ ), 'wp-piwik_post_customvars_nonce'); ?>
|
20 |
-
<table>
|
21 |
-
<tr><th></th><th><?php _e('Name', 'wp-piwik'); ?></th><th><?php _e('Value', 'wp-piwik'); ?></th></tr>
|
22 |
-
<?php for($i = 1; $i <= 5; $i++) { ?>
|
23 |
-
<tr>
|
24 |
-
<th><label for="wp-piwik_customvar1"><?php echo $i; ?>: </label></th>
|
25 |
-
<td><input class="widefat" type="text" name="wp-piwik_custom_cat<?php echo $i; ?>" value="<?php echo esc_attr(get_post_meta($objPost->ID, 'wp-piwik_custom_cat'.$i, true ) ); ?>" size="200" /></td>
|
26 |
-
<td><input class="widefat" type="text" name="wp-piwik_custom_val<?php echo $i; ?>" value="<?php echo esc_attr(get_post_meta($objPost->ID, 'wp-piwik_custom_val'.$i, true ) ); ?>" size="200" /></td>
|
27 |
-
</tr>
|
28 |
-
<?php } ?>
|
29 |
-
</table>
|
30 |
-
<p><?php _e('Set custom variables for a page view', 'wp-piwik'); ?>. (<a href="http://piwik.org/docs/custom-variables/"><?php _e('More information', 'wp-piwik'); ?></a>.)</p>
|
31 |
-
<?php
|
32 |
-
}
|
33 |
-
|
34 |
-
public function saveCustomVars($intID, $objPost) {
|
35 |
-
// Verify the nonce before proceeding.
|
36 |
-
if (!isset( $_POST['wp-piwik_post_customvars_nonce'] ) || !wp_verify_nonce( $_POST['wp-piwik_post_customvars_nonce'], basename( __FILE__ ) ) )
|
37 |
-
return $intID;
|
38 |
-
// Get post type object
|
39 |
-
$objPostType = get_post_type_object($objPost->post_type);
|
40 |
-
// Check if the current user has permission to edit the post.
|
41 |
-
if (!current_user_can($objPostType->cap->edit_post, $intID))
|
42 |
-
return $intID;
|
43 |
-
$aryNames = array('cat', 'val');
|
44 |
-
for ($i = 1; $i <= 5; $i++)
|
45 |
-
for ($j = 0; $j <= 1; $j++) {
|
46 |
-
// Get data
|
47 |
-
$strMetaVal = (isset($_POST['wp-piwik_custom_'.$aryNames[$j].$i])?htmlentities($_POST['wp-piwik_custom_'.$aryNames[$j].$i]):'');
|
48 |
-
// Create key
|
49 |
-
$strMetaKey = 'wp-piwik_custom_'.$aryNames[$j].$i;
|
50 |
-
// Get the meta value of the custom field key
|
51 |
-
$strCurVal = get_post_meta($intID, $strMetaKey, true);
|
52 |
-
// Add meta val:
|
53 |
-
if ($strMetaVal && '' == $strCurVal)
|
54 |
-
add_post_meta($intID, $strMetaKey, $strMetaVal, true);
|
55 |
-
// Update meta val:
|
56 |
-
elseif ($strMetaVal && $strMetaVal != $strCurVal)
|
57 |
-
update_post_meta($intID, $strMetaKey, $strMetaVal);
|
58 |
-
// Delete meta val:
|
59 |
-
elseif (''==$strMetaVal && $strCurVal)
|
60 |
-
delete_post_meta($intID, $strMetaKey, $strCurVal);
|
61 |
-
}
|
62 |
-
}
|
63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/TrackingCode.php
DELETED
@@ -1,105 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik;
|
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() || !self::$wpPiwik->getOption('tracking_code') )
|
15 |
-
self::$wpPiwik->updateTrackingCode();
|
16 |
-
$this->trackingCode = ( self::$wpPiwik->isNetworkMode() && self::$wpPiwik->getGlobalOption('track_mode') == 'manually' ) ? get_site_option( 'wp-piwik-manually' ) : self::$wpPiwik->getOption('tracking_code');
|
17 |
-
}
|
18 |
-
|
19 |
-
public function getTrackingCode() {
|
20 |
-
if ($this->is404) $this->apply404Changes();
|
21 |
-
if ($this->isSearch) $this->applySearchChanges();
|
22 |
-
if (is_single()) $this->addCustomValues();
|
23 |
-
return $this->trackingCode;
|
24 |
-
}
|
25 |
-
|
26 |
-
public static function prepareTrackingCode($code, $settings, $logger) {
|
27 |
-
$logger->log('Apply tracking code changes:');
|
28 |
-
$settings->setOption('last_tracking_code_update', time());
|
29 |
-
if ($settings->getGlobalOption('track_mode') == 'js')
|
30 |
-
$code = str_replace(array('piwik.js', 'piwik.php'), 'js/index.php', $code);
|
31 |
-
elseif ($settings->getGlobalOption('track_mode') == 'proxy') {
|
32 |
-
$code = str_replace('piwik.js', 'piwik.php', $code);
|
33 |
-
$proxy = str_replace(array('https://', 'http://'), '//', plugins_url('wp-piwik').'/proxy').'/';
|
34 |
-
if ( preg_match('/var u="([^"]*)";/', $code, $hits) ) {
|
35 |
-
$settings->setGlobalOption('proxy_url', $hits[1]);
|
36 |
-
}
|
37 |
-
$code = preg_replace('/var u="([^"]*)";/','var u="'.$proxy.'"',$code);
|
38 |
-
$code = preg_replace('/img src="([^"]*)piwik.php/','img src="'.$proxy.'piwik.php',$code);
|
39 |
-
}
|
40 |
-
if ($settings->getGlobalOption('track_cdnurl') || $settings->getGlobalOption('track_cdnurlssl'))
|
41 |
-
$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);
|
42 |
-
|
43 |
-
if ($settings->getGlobalOption('track_datacfasync'))
|
44 |
-
$code = str_replace('<script type', '<script data-cfasync="false" type', $code);
|
45 |
-
if ($settings->getGlobalOption('add_download_extensions'))
|
46 |
-
$code = str_replace("_paq.push(['trackPageView']);", "_paq.push(['addDownloadExtensions', '".($settings->getGlobalOption('add_download_extensions'))."']);\n_paq.push(['trackPageView']);", $code);
|
47 |
-
if ($settings->getGlobalOption('limit_cookies'))
|
48 |
-
$code = str_replace("_paq.push(['trackPageView']);", "_paq.push(['setVisitorCookieTimeout', '".$settings->getGlobalOption('limit_cookies_visitor')."']);\n_paq.push(['setSessionCookieTimeout', '".$settings->getGlobalOption('limit_cookies_session')."']);\n_paq.push(['trackPageView']);", $code);
|
49 |
-
if ($settings->getGlobalOption('force_protocol') != 'disabled')
|
50 |
-
$code = str_replace('"//', '"'.$settings->getGlobalOption('force_protocol').'://', $code);
|
51 |
-
|
52 |
-
if ($settings->getGlobalOption('piwik_mode') == 'pro')
|
53 |
-
$code = str_replace('.piwik.pro', '.piwikpro.com', $code);
|
54 |
-
|
55 |
-
$noScript = array();
|
56 |
-
preg_match('/<noscript>(.*)<\/noscript>/', $code, $noScript);
|
57 |
-
if (isset($noScript[0])) {
|
58 |
-
if ($settings->getGlobalOption('track_nojavascript'))
|
59 |
-
$noScript[0] = str_replace('?idsite', '?rec=1&idsite', $noScript[0]);
|
60 |
-
$noScript = $noScript[0];
|
61 |
-
} else $noScript = '';
|
62 |
-
$script = preg_replace('/<noscript>(.*)<\/noscript>/', '', $code);
|
63 |
-
$script = preg_replace('/\s+(\r\n|\r|\n)/', '$1', $script);
|
64 |
-
$logger->log('Finished tracking code: '.$script);
|
65 |
-
$logger->log('Finished noscript code: '.$noScript);
|
66 |
-
return array('script' => $script, 'noscript' => $noScript);
|
67 |
-
}
|
68 |
-
|
69 |
-
private function apply404Changes() {
|
70 |
-
self::$wpPiwik->log('Apply 404 changes. Blog ID: '.get_current_blog_id().' Site ID: '.self::$wpPiwik->getOption('site_id'));
|
71 |
-
$this->trackingCode = str_replace(
|
72 |
-
"_paq.push(['trackPageView']);",
|
73 |
-
"_paq.push(['setDocumentTitle', '404/URL = '+String(document.location.pathname+document.location.search).replace(/\//g,'%2f') + '/From = ' + String(document.referrer).replace(/\//g,'%2f')]);\n_paq.push(['trackPageView']);",
|
74 |
-
$this->trackingCode
|
75 |
-
);
|
76 |
-
}
|
77 |
-
|
78 |
-
private function applySearchChanges() {
|
79 |
-
self::$wpPiwik->log('Apply search tracking changes. Blog ID: '.get_current_blog_id().' Site ID: '.self::$wpPiwik->getOption('site_id'));
|
80 |
-
$objSearch = new \WP_Query("s=" . get_search_query() . '&showposts=-1');
|
81 |
-
$intResultCount = $objSearch->post_count;
|
82 |
-
$this->trackingCode = str_replace(
|
83 |
-
"_paq.push(['trackPageView']);",
|
84 |
-
"_paq.push(['trackSiteSearch','".get_search_query()."', false, ".$intResultCount."]);\n_paq.push(['trackPageView']);",
|
85 |
-
$this->trackingCode
|
86 |
-
);
|
87 |
-
}
|
88 |
-
|
89 |
-
private function addCustomValues() {
|
90 |
-
$customVars = '';
|
91 |
-
for ($i = 1; $i <= 5; $i++) {
|
92 |
-
$postId = get_the_ID();
|
93 |
-
$metaKey = get_post_meta($postId, 'wp-piwik_custom_cat'.$i, true);
|
94 |
-
$metaVal = get_post_meta($postId, 'wp-piwik_custom_val'.$i, true);
|
95 |
-
if (!empty($metaKey) && !empty($metaVal))
|
96 |
-
$customVars .= "_paq.push(['setCustomVariable',".$i.", '".$metaKey."', '".$metaVal."', 'page']);\n";
|
97 |
-
}
|
98 |
-
if (!empty($customVars))
|
99 |
-
$this->trackingCode = str_replace(
|
100 |
-
"_paq.push(['trackPageView']);",
|
101 |
-
$customVars."_paq.push(['trackPageView']);",
|
102 |
-
$this->trackingCode
|
103 |
-
);
|
104 |
-
}
|
105 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget.php
DELETED
@@ -1,211 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik;
|
4 |
-
|
5 |
-
abstract class Widget {
|
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;
|
13 |
-
self::$settings = $settings;
|
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);
|
25 |
-
if (is_array($this->method))
|
26 |
-
foreach ($this->method as $method) {
|
27 |
-
$this->apiID[$method] = \WP_Piwik\Request::register($method, $this->parameter);
|
28 |
-
self::$wpPiwik->log("Register request: ".$this->apiID[$method]);
|
29 |
-
}
|
30 |
-
else {
|
31 |
-
$this->apiID[$this->method] = \WP_Piwik\Request::register($this->method, $this->parameter);
|
32 |
-
self::$wpPiwik->log("Register request: ".$this->apiID[$this->method]);
|
33 |
-
}
|
34 |
-
if ($this->isShortcode)
|
35 |
-
return;
|
36 |
-
add_meta_box(
|
37 |
-
$this->getName(),
|
38 |
-
$this->title,
|
39 |
-
array($this, 'show'),
|
40 |
-
$pageId,
|
41 |
-
$this->context,
|
42 |
-
$this->priority
|
43 |
-
);
|
44 |
-
}
|
45 |
-
|
46 |
-
protected function configure($prefix = '', $params = array()) {}
|
47 |
-
|
48 |
-
public function show() {
|
49 |
-
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
50 |
-
if (!empty($response['result']) && $response['result'] ='error')
|
51 |
-
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
52 |
-
else {
|
53 |
-
if (isset($response[0]['nb_uniq_visitors'])) $unique = 'nb_uniq_visitors';
|
54 |
-
else $unique = 'sum_daily_nb_uniq_visitors';
|
55 |
-
$tableHead = array('label' => __($this->name, 'wp-piwik'));
|
56 |
-
$tableHead[$unique] = __('Unique', 'wp-piwik');
|
57 |
-
if (isset($response[0]['nb_visits']))
|
58 |
-
$tableHead['nb_visits'] = __('Visits', 'wp-piwik');
|
59 |
-
if (isset($response[0]['nb_hits']))
|
60 |
-
$tableHead['nb_hits'] = __('Hits', 'wp-piwik');
|
61 |
-
if (isset($response[0]['nb_actions']))
|
62 |
-
$tableHead['nb_actions'] = __('Actions', 'wp-piwik');
|
63 |
-
$tableBody = array();
|
64 |
-
$count = 0;
|
65 |
-
foreach ($response as $rowKey => $row) {
|
66 |
-
$count++;
|
67 |
-
$tableBody[$rowKey] = array();
|
68 |
-
foreach ($tableHead as $key => $value)
|
69 |
-
$tableBody[$rowKey][] = isset($row[$key])?$row[$key]:'-';
|
70 |
-
if ($count == 10) break;
|
71 |
-
}
|
72 |
-
$this->table($tableHead, $tableBody, null);
|
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';
|
125 |
-
$description = 'today';
|
126 |
-
break;
|
127 |
-
case 'current_month':
|
128 |
-
$period = 'month';
|
129 |
-
$date = 'today';
|
130 |
-
$description = 'current month';
|
131 |
-
break;
|
132 |
-
case 'last_month':
|
133 |
-
$period = 'month';
|
134 |
-
$date = date("Y-m-d", strtotime("last day of previous month"));
|
135 |
-
$description = 'last month';
|
136 |
-
break;
|
137 |
-
case 'current_week':
|
138 |
-
$period = 'week';
|
139 |
-
$date = 'today';
|
140 |
-
$description = 'current week';
|
141 |
-
break;
|
142 |
-
case 'last_week':
|
143 |
-
$period = 'week';
|
144 |
-
$date = date("Y-m-d", strtotime("-1 week"));
|
145 |
-
$description = 'last week';
|
146 |
-
break;
|
147 |
-
case 'yesterday':
|
148 |
-
$period = 'day';
|
149 |
-
$date = 'yesterday';
|
150 |
-
$description = 'yesterday';
|
151 |
-
break;
|
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() {
|
194 |
-
return str_replace('\\', '-', get_called_class());;
|
195 |
-
}
|
196 |
-
|
197 |
-
public function pieChart($data) {
|
198 |
-
echo '<div id="wp-piwik_stats_'.$this->getName().'_graph" style="height:310px;width:100%"></div>';
|
199 |
-
echo '<script type="text/javascript">$plotBrowsers = $j.jqplot("wp-piwik_stats_'.$this->getName().'_graph", [[';
|
200 |
-
$list = '';
|
201 |
-
foreach ($data as $dataSet)
|
202 |
-
$list .= '["'.$dataSet[0].'", '.$dataSet[1].'],';
|
203 |
-
echo substr($list, 0, -1);
|
204 |
-
echo ']], {seriesDefaults:{renderer:$j.jqplot.PieRenderer, rendererOptions:{sliceMargin:8}},legend:{show:true}});</script>';
|
205 |
-
}
|
206 |
-
|
207 |
-
protected function value($array, $key) {
|
208 |
-
return (isset($array[$key])?$array[$key]:'-');
|
209 |
-
}
|
210 |
-
|
211 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/BrowserDetails.php
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class BrowserDetails extends \WP_Piwik\Widget {
|
6 |
-
|
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 |
-
);
|
16 |
-
$this->title = $prefix.__('Browser Details', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
17 |
-
$this->method = 'UserSettings.getBrowserVersion';
|
18 |
-
$this->context = 'normal';
|
19 |
-
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
20 |
-
wp_enqueue_script('wp-piwik-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
|
21 |
-
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
|
22 |
-
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
|
23 |
-
}
|
24 |
-
|
25 |
-
public function addHeaderLines() {
|
26 |
-
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.self::$wpPiwik->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
|
27 |
-
echo '<link rel="stylesheet" href="'.self::$wpPiwik->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
|
28 |
-
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
|
29 |
-
}
|
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 {
|
37 |
-
$tableHead = array(__('Browser', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Percent', 'wp-piwik'));
|
38 |
-
if (isset($response[0]['nb_uniq_visitors'])) $unique = 'nb_uniq_visitors';
|
39 |
-
else $unique = 'sum_daily_nb_uniq_visitors';
|
40 |
-
$count = 0;
|
41 |
-
$sum = 0;
|
42 |
-
foreach ($response as $row) {
|
43 |
-
$count++;
|
44 |
-
$sum += isset($row[$unique])?$row[$unique]:0;
|
45 |
-
if ($count < $this->limit)
|
46 |
-
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
47 |
-
elseif (!isset($tableBody['Others']))
|
48 |
-
$tableBody['Others'] = array($row['label'], $row[$unique], 0);
|
49 |
-
else
|
50 |
-
$tableBody['Others'][1] += $row[$unique];
|
51 |
-
}
|
52 |
-
if ($count > $this->limit)
|
53 |
-
$tableBody['Others'][0] = __('Others', 'wp-piwik');
|
54 |
-
|
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 |
-
}
|
62 |
-
|
63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/Browsers.php
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class Browsers extends \WP_Piwik\Widget {
|
6 |
-
|
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 |
-
);
|
16 |
-
$this->title = $prefix.__('Browsers', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
17 |
-
$this->method = 'UserSettings.getBrowser';
|
18 |
-
$this->context = 'normal';
|
19 |
-
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
20 |
-
wp_enqueue_script('wp-piwik-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
|
21 |
-
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
|
22 |
-
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
|
23 |
-
}
|
24 |
-
|
25 |
-
public function addHeaderLines() {
|
26 |
-
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.self::$wpPiwik->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
|
27 |
-
echo '<link rel="stylesheet" href="'.self::$wpPiwik->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
|
28 |
-
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
|
29 |
-
}
|
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 {
|
37 |
-
$tableHead = array(__('Browser', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Percent', 'wp-piwik'));
|
38 |
-
if (isset($response[0]['nb_uniq_visitors'])) $unique = 'nb_uniq_visitors';
|
39 |
-
else $unique = 'sum_daily_nb_uniq_visitors';
|
40 |
-
$count = 0;
|
41 |
-
$sum = 0;
|
42 |
-
foreach ($response as $row) {
|
43 |
-
$count++;
|
44 |
-
$sum += isset($row[$unique])?$row[$unique]:0;
|
45 |
-
if ($count < $this->limit)
|
46 |
-
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
47 |
-
elseif (!isset($tableBody['Others']))
|
48 |
-
$tableBody['Others'] = array($row['label'], $row[$unique], 0);
|
49 |
-
else
|
50 |
-
$tableBody['Others'][1] += $row[$unique];
|
51 |
-
}
|
52 |
-
if ($count > $this->limit)
|
53 |
-
$tableBody['Others'][0] = __('Others', 'wp-piwik');
|
54 |
-
|
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 |
-
}
|
62 |
-
|
63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/Chart.php
DELETED
@@ -1,76 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class Chart extends \WP_Piwik\Widget {
|
6 |
-
|
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);
|
21 |
-
wp_enqueue_script('wp-piwik-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
|
22 |
-
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
|
23 |
-
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
|
24 |
-
}
|
25 |
-
|
26 |
-
public function addHeaderLines() {
|
27 |
-
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.self::$wpPiwik->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
|
28 |
-
echo '<link rel="stylesheet" href="'.self::$wpPiwik->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
|
29 |
-
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
|
30 |
-
}
|
31 |
-
|
32 |
-
public function show() {
|
33 |
-
$response = array();
|
34 |
-
$success = true;
|
35 |
-
foreach ($this->method as $method) {
|
36 |
-
$response[$method] = self::$wpPiwik->request($this->apiID[$method]);
|
37 |
-
if (!empty($response[$method]['result']) && $response[$method]['result'] ='error')
|
38 |
-
$success = false;
|
39 |
-
}
|
40 |
-
if (!$success)
|
41 |
-
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response[$method]['message'], ENT_QUOTES, 'utf-8');
|
42 |
-
else {
|
43 |
-
$values = $labels = $bounced = $unique = '';
|
44 |
-
$count = $uniqueSum = 0;
|
45 |
-
if (is_array($response['VisitsSummary.getVisits']))
|
46 |
-
foreach ($response['VisitsSummary.getVisits'] as $date => $value) {
|
47 |
-
$count++;
|
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 {
|
59 |
-
$values = '0,';
|
60 |
-
$labels = '[0,"-"],';
|
61 |
-
$unique = '0,';
|
62 |
-
$bounced = '0,';
|
63 |
-
}
|
64 |
-
$average = round($uniqueSum/30,0);
|
65 |
-
$values = substr($values, 0, -1);
|
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>';
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/Keywords.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class Keywords extends \WP_Piwik\Widget {
|
6 |
-
|
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 |
-
);
|
16 |
-
$this->title = $prefix.__('Keywords', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
17 |
-
$this->method = 'Referrers.getKeywords';
|
18 |
-
$this->name = 'Keyword';
|
19 |
-
}
|
20 |
-
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/Noresult.php
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class Noresult extends \WP_Piwik\Widget {
|
6 |
-
|
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 |
-
);
|
16 |
-
$this->title = $prefix.__('Site Search', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
17 |
-
$this->method = 'Actions.getSiteSearchNoResultKeywords';
|
18 |
-
}
|
19 |
-
|
20 |
-
public function show() {
|
21 |
-
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
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 |
-
$tableHead = array(__('Keyword', 'wp-piwik'), __('Requests', 'wp-piwik'), __('Bounced', 'wp-piwik'));
|
26 |
-
$tableBody = array();
|
27 |
-
$count = 0;
|
28 |
-
foreach ($response as $row) {
|
29 |
-
$count++;
|
30 |
-
$tableBody[] = array($row['label'], $row['nb_visits'], $row['bounce_rate']);
|
31 |
-
if ($count == 10) break;
|
32 |
-
}
|
33 |
-
$this->table($tableHead, $tableBody, null);
|
34 |
-
}
|
35 |
-
}
|
36 |
-
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/OptOut.php
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class OptOut extends \WP_Piwik\Widget {
|
6 |
-
|
7 |
-
public $className = __CLASS__;
|
8 |
-
|
9 |
-
protected function configure($prefix = '', $params = array()) {
|
10 |
-
$this->parameter = $params;
|
11 |
-
}
|
12 |
-
|
13 |
-
public function show() {
|
14 |
-
echo '<iframe frameborder="no" width="'.(isset($this->parameter['width'])?$this->parameter['width']:'').'" height="'.(isset($this->parameter['height'])?$this->parameter['height']:'').'" src="'.self::$settings->getGlobalOption('piwik_url').'index.php?module=CoreAdminHome&action=optOut&language='.(isset($this->parameter['language'])?$this->parameter['language']:'en').'"></iframe>';
|
15 |
-
}
|
16 |
-
|
17 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/Overview.php
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class Overview extends \WP_Piwik\Widget {
|
6 |
-
|
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 |
-
|
21 |
-
public function show() {
|
22 |
-
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
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;
|
39 |
-
$tableBody = array(
|
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 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/Pages.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class Pages extends \WP_Piwik\Widget {
|
6 |
-
|
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 |
-
);
|
16 |
-
$this->title = $prefix.__('Pages', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
17 |
-
$this->method = 'Actions.getPageTitles';
|
18 |
-
$this->name = 'Page';
|
19 |
-
}
|
20 |
-
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/Plugins.php
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class Plugins extends \WP_Piwik\Widget {
|
6 |
-
|
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 |
-
);
|
16 |
-
$this->title = $prefix.__('Plugins', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
17 |
-
$this->method = 'UserSettings.getPlugin';
|
18 |
-
}
|
19 |
-
|
20 |
-
public function show() {
|
21 |
-
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
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 |
-
$tableHead = array(__('Plugin', 'wp-piwik'), __('Visits', 'wp-piwik'), __('Percent', 'wp-piwik'));
|
26 |
-
$tableBody = array();
|
27 |
-
$count = 0;
|
28 |
-
foreach ($response as $row) {
|
29 |
-
$count++;
|
30 |
-
$tableBody[] = array($row['label'], $row['nb_visits'], $row['nb_visits_percentage']);
|
31 |
-
if ($count == 10) break;
|
32 |
-
}
|
33 |
-
$this->table($tableHead, $tableBody, null);
|
34 |
-
}
|
35 |
-
}
|
36 |
-
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/Post.php
DELETED
@@ -1,51 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class Post extends \WP_Piwik\Widget {
|
6 |
-
|
7 |
-
public $className = __CLASS__;
|
8 |
-
|
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,
|
16 |
-
'pageUrl' => isset($params['url'])?$params['url']:urlencode(get_permalink($post->ID)),
|
17 |
-
);
|
18 |
-
$this->title = $prefix.__('Overview', 'wp-piwik').' ('.__($this->parameter['date'],'wp-piwik').')';
|
19 |
-
$this->method = 'Actions.getPageUrl';
|
20 |
-
}
|
21 |
-
|
22 |
-
public function show() {
|
23 |
-
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
24 |
-
if (!empty($response['result']) && $response['result'] ='error')
|
25 |
-
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
26 |
-
else {
|
27 |
-
if (isset($response[0]))
|
28 |
-
$response = $response[0];
|
29 |
-
if ($this->parameter['key']) {
|
30 |
-
echo isset($response[$this->parameter['key']])?$response[$this->parameter['key']]:'<em>not defined</em>';
|
31 |
-
return;
|
32 |
-
}
|
33 |
-
$time = isset($response['entry_sum_visit_length'])?$this->timeFormat($response['entry_sum_visit_length']):'-';
|
34 |
-
$avgTime = isset($response['avg_time_on_page'])?$this->timeFormat($response['avg_time_on_page']):'-';
|
35 |
-
$tableHead = null;
|
36 |
-
$tableBody = array(
|
37 |
-
array(__('Visitors', 'wp-piwik').':', $this->value($response, 'nb_visits')),
|
38 |
-
array(__('Unique visitors', 'wp-piwik').':', $this->value($response, 'sum_daily_nb_uniq_visitors')),
|
39 |
-
array(__('Page views', 'wp-piwik').':', $this->value($response, 'nb_hits').' (Ø '.$this->value($response, 'entry_nb_actions').')'),
|
40 |
-
array(__('Total time spent', 'wp-piwik').':', $time),
|
41 |
-
array(__('Time/visit', 'wp-piwik').':', $avgTime),
|
42 |
-
array(__('Bounce count', 'wp-piwik').':', $this->value($response, 'entry_bounce_count').' ('.$this->value($response, 'bounce_rate').')'),
|
43 |
-
array(__('Min. generation time', 'wp-piwik').':', $this->value($response, 'min_time_generation')),
|
44 |
-
array(__('Max. generation time', 'wp-piwik').':', $this->value($response, 'max_time_generation'))
|
45 |
-
);
|
46 |
-
$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);
|
47 |
-
$this->table($tableHead, $tableBody, $tableFoot);
|
48 |
-
}
|
49 |
-
}
|
50 |
-
|
51 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/Referrers.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class Referrers extends \WP_Piwik\Widget {
|
6 |
-
|
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 |
-
);
|
16 |
-
$this->title = $prefix.__('Referrers', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
17 |
-
$this->method = 'Referrers.getWebsites';
|
18 |
-
$this->name = 'Referrer';
|
19 |
-
}
|
20 |
-
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/Screens.php
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class Screens extends \WP_Piwik\Widget {
|
6 |
-
|
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 |
-
);
|
16 |
-
$this->title = $prefix.__('Resolutions', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
17 |
-
$this->method = 'UserSettings.getResolution';
|
18 |
-
$this->context = 'normal';
|
19 |
-
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
20 |
-
wp_enqueue_script('wp-piwik-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
|
21 |
-
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
|
22 |
-
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
|
23 |
-
}
|
24 |
-
|
25 |
-
public function addHeaderLines() {
|
26 |
-
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.self::$wpPiwik->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
|
27 |
-
echo '<link rel="stylesheet" href="'.self::$wpPiwik->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
|
28 |
-
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
|
29 |
-
}
|
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 {
|
37 |
-
$tableHead = array(__('Resolution', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Percent', 'wp-piwik'));
|
38 |
-
if (isset($response[0]['nb_uniq_visitors'])) $unique = 'nb_uniq_visitors';
|
39 |
-
else $unique = 'sum_daily_nb_uniq_visitors';
|
40 |
-
$count = 0;
|
41 |
-
$sum = 0;
|
42 |
-
foreach ($response as $row) {
|
43 |
-
$count++;
|
44 |
-
$sum += isset($row[$unique])?$row[$unique]:0;
|
45 |
-
if ($count < $this->limit)
|
46 |
-
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
47 |
-
elseif (!isset($tableBody['Others']))
|
48 |
-
$tableBody['Others'] = array($row['label'], $row[$unique], 0);
|
49 |
-
else
|
50 |
-
$tableBody['Others'][1] += $row[$unique];
|
51 |
-
}
|
52 |
-
if ($count > $this->limit)
|
53 |
-
$tableBody['Others'][0] = __('Others', 'wp-piwik');
|
54 |
-
|
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 |
-
}
|
62 |
-
|
63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/Search.php
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class Search extends \WP_Piwik\Widget {
|
6 |
-
|
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 |
-
);
|
16 |
-
$this->title = $prefix.__('Site Search', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
17 |
-
$this->method = 'Actions.getSiteSearchKeywords';
|
18 |
-
}
|
19 |
-
|
20 |
-
public function show() {
|
21 |
-
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
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 |
-
$tableHead = array(__('Keyword', 'wp-piwik'), __('Requests', 'wp-piwik'), __('Bounced', 'wp-piwik'));
|
26 |
-
$tableBody = array();
|
27 |
-
$count = 0;
|
28 |
-
foreach ($response as $row) {
|
29 |
-
$count++;
|
30 |
-
$tableBody[] = array($row['label'], $row['nb_visits'], $row['bounce_rate']);
|
31 |
-
if ($count == 10) break;
|
32 |
-
}
|
33 |
-
$this->table($tableHead, $tableBody, null);
|
34 |
-
}
|
35 |
-
}
|
36 |
-
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/Seo.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class Seo extends \WP_Piwik\Widget {
|
6 |
-
|
7 |
-
public $className = __CLASS__;
|
8 |
-
|
9 |
-
protected function configure($prefix = '', $params = array()) {
|
10 |
-
$this->parameter = array(
|
11 |
-
'url' => get_bloginfo('url')
|
12 |
-
);
|
13 |
-
$this->title = $prefix.__('SEO', 'wp-piwik');
|
14 |
-
$this->method = 'SEO.getRank';
|
15 |
-
}
|
16 |
-
|
17 |
-
public function show() {
|
18 |
-
$response = null; //self::$wpPiwik->request($this->apiID[$this->method]);
|
19 |
-
if (!empty($response['result']) && $response['result'] ='error')
|
20 |
-
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
21 |
-
else {
|
22 |
-
echo '<div class="table"><table class="widefat"><tbody>';
|
23 |
-
if (is_array($response))
|
24 |
-
foreach ($response as $val)
|
25 |
-
echo '<tr><td>'.$val[0].'</td><td>'.$val[1].'</td></tr>';
|
26 |
-
else echo '<tr><td>SEO module currently not available.</td></tr>';
|
27 |
-
echo '</tbody></table></div>';
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/Systems.php
DELETED
@@ -1,61 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class Systems extends \WP_Piwik\Widget {
|
6 |
-
|
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 |
-
);
|
14 |
-
$this->title = $prefix.__('Operation Systems', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
15 |
-
$this->method = 'UserSettings.getOS';
|
16 |
-
$this->context = 'normal';
|
17 |
-
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
18 |
-
wp_enqueue_script('wp-piwik-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
|
19 |
-
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
|
20 |
-
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
|
21 |
-
}
|
22 |
-
|
23 |
-
public function addHeaderLines() {
|
24 |
-
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.self::$wpPiwik->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
|
25 |
-
echo '<link rel="stylesheet" href="'.self::$wpPiwik->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
|
26 |
-
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
|
27 |
-
}
|
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 {
|
35 |
-
$tableHead = array(__('Operation System', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Percent', 'wp-piwik'));
|
36 |
-
if (isset($response[0]['nb_uniq_visitors'])) $unique = 'nb_uniq_visitors';
|
37 |
-
else $unique = 'sum_daily_nb_uniq_visitors';
|
38 |
-
$count = 0;
|
39 |
-
$sum = 0;
|
40 |
-
foreach ($response as $row) {
|
41 |
-
$count++;
|
42 |
-
$sum += isset($row[$unique])?$row[$unique]:0;
|
43 |
-
if ($count < $this->limit)
|
44 |
-
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
45 |
-
elseif (!isset($tableBody['Others']))
|
46 |
-
$tableBody['Others'] = array($row['label'], $row[$unique], 0);
|
47 |
-
else
|
48 |
-
$tableBody['Others'][1] += $row[$unique];
|
49 |
-
}
|
50 |
-
if ($count > $this->limit)
|
51 |
-
$tableBody['Others'][0] = __('Others', 'wp-piwik');
|
52 |
-
|
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 |
-
}
|
60 |
-
|
61 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/WP_Piwik/Widget/Visitors.php
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace WP_Piwik\Widget;
|
4 |
-
|
5 |
-
class Visitors extends \WP_Piwik\Widget {
|
6 |
-
|
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);
|
21 |
-
wp_enqueue_script('wp-piwik-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
|
22 |
-
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
|
23 |
-
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
|
24 |
-
}
|
25 |
-
|
26 |
-
public function show() {
|
27 |
-
$response = array();
|
28 |
-
$success = true;
|
29 |
-
foreach ($this->method as $method) {
|
30 |
-
$response[$method] = self::$wpPiwik->request($this->apiID[$method]);
|
31 |
-
if (!empty($response[$method]['result']) && $response[$method]['result'] ='error')
|
32 |
-
$success = false;
|
33 |
-
}
|
34 |
-
if (!$success)
|
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 |
-
|
65 |
-
}
|
66 |
-
|
67 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/{WP_Piwik/Logger.php → WP_Piwik_Logger.php}
RENAMED
@@ -1,8 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
abstract class Logger {
|
6 |
|
7 |
private $loggerName = 'unnamed';
|
8 |
private $loggerContent = array();
|
1 |
<?php
|
2 |
|
3 |
+
abstract class WP_Piwik_Logger {
|
|
|
|
|
4 |
|
5 |
private $loggerName = 'unnamed';
|
6 |
private $loggerContent = array();
|
classes/WP_Piwik_Logger_Dummy.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once('WP_Piwik_Logger.php');
|
4 |
+
|
5 |
+
class WP_Piwik_Logger_Dummy extends WP_Piwik_Logger {
|
6 |
+
|
7 |
+
public function loggerOutput($loggerTime, $loggerMessage) {}
|
8 |
+
|
9 |
+
}
|
classes/{WP_Piwik/Logger/File.php → WP_Piwik_Logger_File.php}
RENAMED
@@ -1,8 +1,8 @@
|
|
1 |
<?php
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
class File extends \WP_Piwik\Logger {
|
6 |
|
7 |
private $loggerFile = null;
|
8 |
|
@@ -13,7 +13,7 @@
|
|
13 |
}
|
14 |
|
15 |
private function setFilename() {
|
16 |
-
$this->loggerFile =
|
17 |
date('Ymd').'_'.$this->encodeFilename($this->getName()).'.log';
|
18 |
}
|
19 |
|
1 |
<?php
|
2 |
+
|
3 |
+
require_once('WP_Piwik_Logger.php');
|
4 |
|
5 |
+
class WP_Piwik_Logger_File extends WP_Piwik_Logger {
|
|
|
|
|
6 |
|
7 |
private $loggerFile = null;
|
8 |
|
13 |
}
|
14 |
|
15 |
private function setFilename() {
|
16 |
+
$this->loggerFile = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'logs'.DIRECTORY_SEPARATOR.
|
17 |
date('Ymd').'_'.$this->encodeFilename($this->getName()).'.log';
|
18 |
}
|
19 |
|
classes/WP_Piwik_MetaBox_PerPost_Stats.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once('WP_Piwik_Template.php');
|
4 |
+
|
5 |
+
class WP_Piwik_MetaBox_PerPost_Stats extends WP_Piwik_Template {
|
6 |
+
|
7 |
+
function addMetabox() {
|
8 |
+
add_meta_box(
|
9 |
+
'wp-piwik_post_perpoststats',
|
10 |
+
__('Piwik Statistics (last 30 days)', 'wp-piwik'),
|
11 |
+
array(&$this, 'showStats'),
|
12 |
+
'post',
|
13 |
+
'side',
|
14 |
+
'default'
|
15 |
+
);
|
16 |
+
}
|
17 |
+
|
18 |
+
private function getStats($range = false) {
|
19 |
+
global $post;
|
20 |
+
$postURL = get_permalink($post->ID);
|
21 |
+
$range = ($range?$range:$this->getRangeLast30());
|
22 |
+
self::$logger->log('Load per post statistics: '.$postURL);
|
23 |
+
return self::$wpPiwik->callPiwikAPI('Actions.getPageUrl', 'range', $range, null, false, false, 'PHP', $postURL, false);
|
24 |
+
}
|
25 |
+
|
26 |
+
function showStats() {
|
27 |
+
$data = $this->getStats();
|
28 |
+
if (!isset($data[0])) return;
|
29 |
+
echo '<table>';
|
30 |
+
$this->tabRow(__('Visitors', 'wp-piwik').':',$data[0]['nb_visits']);
|
31 |
+
$this->tabRow(__('Unique visitors', 'wp-piwik').':', $data[0]['sum_daily_nb_uniq_visitors']);
|
32 |
+
$this->tabRow(__('Page views', 'wp-piwik').':', $data[0]['nb_hits']);
|
33 |
+
$this->tabRow(__('Time/visit', 'wp-piwik').':', $data[0]['avg_time_on_page']);
|
34 |
+
$this->tabRow(__('Bounce count', 'wp-piwik').':', $this->output($data[0], 'entry_bounce_count', 0).' ('.$data[0]['bounce_rate'].')');
|
35 |
+
$this->tabRow(__('Exit count', 'wp-piwik').':', $this->output($data[0], 'exit_nb_visits', 0).' ('.$data[0]['exit_rate'].')');
|
36 |
+
if (isset($data[0]['avg_time_generation']))
|
37 |
+
$this->tabRow(__('Avg. generation time', 'wp-piwik').':', $data[0]['avg_time_generation']);
|
38 |
+
echo '</table>';
|
39 |
+
}
|
40 |
+
|
41 |
+
function getValue($range, $key) {
|
42 |
+
$data = $this->getStats($range);
|
43 |
+
if (!isset($data[0]) || !isset($data[0][$key])) return '-';
|
44 |
+
else return $data[0][$key];
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
classes/WP_Piwik_Settings.php
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WP_Piwik_Settings {
|
4 |
+
|
5 |
+
private static $logger, $defaultSettings;
|
6 |
+
|
7 |
+
private $globalSettings = array(
|
8 |
+
'revision' => 90921,
|
9 |
+
'plugin_display_name' => 'WP-Piwik',
|
10 |
+
'add_tracking_code' => false,
|
11 |
+
'last_settings_update' => 0,
|
12 |
+
'piwik_token' => '',
|
13 |
+
'piwik_url' => '',
|
14 |
+
'piwik_path' => '',
|
15 |
+
'piwik_mode' => 'http',
|
16 |
+
'piwik_useragent' => 'php',
|
17 |
+
'piwik_useragent_string' => 'WP-Piwik',
|
18 |
+
'connection_timeout' => 5,
|
19 |
+
'dashboard_widget' => false,
|
20 |
+
'dashboard_chart' => false,
|
21 |
+
'dashboard_seo' => false,
|
22 |
+
'stats_seo' => false,
|
23 |
+
'capability_stealth' => array(),
|
24 |
+
'capability_read_stats' => array('administrator' => true),
|
25 |
+
'piwik_shortcut' => false,
|
26 |
+
'default_date' => 'yesterday',
|
27 |
+
'auto_site_config' => true,
|
28 |
+
'track_404' => false,
|
29 |
+
'track_search' => false,
|
30 |
+
'track_mode' => 0,
|
31 |
+
'track_post' => false,
|
32 |
+
'track_proxy' => false,
|
33 |
+
'track_admin' => false,
|
34 |
+
'track_feed' => false,
|
35 |
+
'track_feed_goal' => '',
|
36 |
+
'track_feed_revenue' => '',
|
37 |
+
'track_feed_campaign' => 'feed',
|
38 |
+
'track_feed_addcampaign' => 'false',
|
39 |
+
'track_cdnurl' => '',
|
40 |
+
'track_cdnurlssl' => '',
|
41 |
+
'track_noscript' => false,
|
42 |
+
'track_nojavascript' => false,
|
43 |
+
'track_codeposition' => 'footer',
|
44 |
+
'track_datacfasync' => false,
|
45 |
+
'track_across' => false,
|
46 |
+
'track_across_alias' => false,
|
47 |
+
'limit_cookies' => false,
|
48 |
+
'limit_cookies_visitor' => 1209600,
|
49 |
+
'limit_cookies_session' => 0,
|
50 |
+
'add_post_annotations' => false,
|
51 |
+
'add_customvars_box' => true,
|
52 |
+
'disable_timelimit' => false,
|
53 |
+
'disable_ssl_verify' => false,
|
54 |
+
'disable_cookies' => false,
|
55 |
+
'add_download_extensions' => '',
|
56 |
+
'force_protocol' => '',
|
57 |
+
'toolbar' => false,
|
58 |
+
'shortcodes' => false,
|
59 |
+
'cache' => true,
|
60 |
+
'perpost_stats' => false
|
61 |
+
),
|
62 |
+
$settings = array(
|
63 |
+
'name' => '',
|
64 |
+
'tracking_code' => '',
|
65 |
+
'site_id' => NULL,
|
66 |
+
'last_tracking_code_update' => 0,
|
67 |
+
'dashboard_revision' => 0,
|
68 |
+
'noscript_code' => ''
|
69 |
+
),
|
70 |
+
$settingsChanged = false;
|
71 |
+
|
72 |
+
public function __construct($objLogger) {
|
73 |
+
self::$logger = $objLogger;
|
74 |
+
self::$logger->log('Store default settings');
|
75 |
+
self::$defaultSettings = array('globalSettings' => $this->globalSettings, 'settings' => $this->settings);
|
76 |
+
self::$logger->log('Load settings');
|
77 |
+
$this->globalSettings = ($this->checkNetworkActivation()?
|
78 |
+
get_site_option('wp-piwik_global-settings', $this->globalSettings):
|
79 |
+
get_option('wp-piwik_global-settings', $this->globalSettings)
|
80 |
+
);
|
81 |
+
$this->settings = get_option('wp-piwik_settings',$this->settings);
|
82 |
+
}
|
83 |
+
|
84 |
+
public function save() {
|
85 |
+
if (!$this->settingsChanged) {
|
86 |
+
self::$logger->log('No settings changed yet');
|
87 |
+
return;
|
88 |
+
}
|
89 |
+
self::$logger->log('Save settings');
|
90 |
+
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php'))
|
91 |
+
update_site_option('wp-piwik_global-settings', $this->globalSettings);
|
92 |
+
else
|
93 |
+
update_option('wp-piwik_global-settings', $this->globalSettings);
|
94 |
+
update_option('wp-piwik_settings', $this->settings);
|
95 |
+
global $wp_roles;
|
96 |
+
if (!is_object($wp_roles))
|
97 |
+
$wp_roles = new WP_Roles();
|
98 |
+
if (!is_object($wp_roles)) die("STILL NO OBJECT");
|
99 |
+
foreach($wp_roles->role_names as $strKey => $strName) {
|
100 |
+
$objRole = get_role($strKey);
|
101 |
+
foreach (array('stealth', 'read_stats') as $strCap) {
|
102 |
+
$aryCaps = $this->getGlobalOption('capability_'.$strCap);
|
103 |
+
if (isset($aryCaps[$strKey]) && $aryCaps[$strKey])
|
104 |
+
$objRole->add_cap('wp-piwik_'.$strCap);
|
105 |
+
else $objRole->remove_cap('wp-piwik_'.$strCap);
|
106 |
+
}
|
107 |
+
}
|
108 |
+
$this->settingsChanges = false;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function getGlobalOption($key) {
|
112 |
+
return isset($this->globalSettings[$key])?$this->globalSettings[$key]:self::$defaultSettings['globalSettings'][$key];
|
113 |
+
}
|
114 |
+
|
115 |
+
public function getOption($key) {
|
116 |
+
return isset($this->settings[$key])?$this->settings[$key]:self::$defaultSettings['settings'][$key];
|
117 |
+
}
|
118 |
+
|
119 |
+
public function setGlobalOption($key, $value) {
|
120 |
+
$this->settingsChanged = true;
|
121 |
+
self::$logger->log('Changed global option '.$key.': '.(is_array($value)?serialize($value):$value));
|
122 |
+
$this->globalSettings[$key] = $value;
|
123 |
+
}
|
124 |
+
|
125 |
+
public function setOption($key, $value) {
|
126 |
+
$this->settingsChanged = true;
|
127 |
+
self::$logger->log('Changed option '.$key.': '.$value);
|
128 |
+
$this->settings[$key] = $value;
|
129 |
+
}
|
130 |
+
|
131 |
+
public function resetSettings($bolFull = false) {
|
132 |
+
self::$logger->log('Reset WP-Piwik settings');
|
133 |
+
global $wpdb;
|
134 |
+
$keepSettings = array(
|
135 |
+
'piwik_token' => $this->getGlobalOption('piwik_token'),
|
136 |
+
'piwik_url' => $this->getGlobalOption('piwik_url'),
|
137 |
+
'piwik_path' => $this->getGlobalOption('piwik_path'),
|
138 |
+
'piwik_mode' => $this->getGlobalOption('piwik_mode')
|
139 |
+
);
|
140 |
+
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
|
141 |
+
delete_site_option('wp-piwik_global-settings');
|
142 |
+
$aryBlogs = $wpdb->get_results('SELECT blog_id FROM '.$wpdb->blogs.' ORDER BY blog_id');
|
143 |
+
foreach ($aryBlogs as $aryBlog)
|
144 |
+
delete_blog_option($aryBlog->blog_id, 'wp-piwik_settings');
|
145 |
+
if (!$bolFull) update_site_option('wp-piwik_global-settings', $keepSettings);
|
146 |
+
} else {
|
147 |
+
delete_option('wp-piwik_global-settings');
|
148 |
+
delete_option('wp-piwik_settings');
|
149 |
+
}
|
150 |
+
$this->globalSettings = self::$defaultSettings['globalSettings'];
|
151 |
+
$this->settings = self::$defaultSettings['settings'];
|
152 |
+
if (!$bolFull) {
|
153 |
+
self::$logger->log('Restore connection settings');
|
154 |
+
foreach ($keepSettings as $key => $value)
|
155 |
+
$this->setGlobalOption($key, $value);
|
156 |
+
}
|
157 |
+
$this->save();
|
158 |
+
}
|
159 |
+
|
160 |
+
public function checkNetworkActivation() {
|
161 |
+
if (!function_exists("is_plugin_active_for_network")) {
|
162 |
+
require_once(ABSPATH.'wp-admin/includes/plugin.php');
|
163 |
+
}
|
164 |
+
return is_plugin_active_for_network('wp-piwik/wp-piwik.php');
|
165 |
+
}
|
166 |
+
}
|
classes/{WP_Piwik/Template.php → WP_Piwik_Template.php}
RENAMED
@@ -1,14 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
class Template {
|
6 |
|
7 |
public static $logger, $settings, $wpPiwik;
|
8 |
|
9 |
-
public function __construct($
|
10 |
-
self::$
|
11 |
-
self::$
|
|
|
12 |
}
|
13 |
|
14 |
public function output($array, $key, $default = '') {
|
@@ -27,5 +26,7 @@
|
|
27 |
$end = time() + $diff;
|
28 |
$start = time() - 2592000 + $diff;
|
29 |
return date('Y-m-d', $start).','.date('Y-m-d', $end);
|
|
|
30 |
}
|
|
|
31 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class WP_Piwik_Template {
|
|
|
|
|
4 |
|
5 |
public static $logger, $settings, $wpPiwik;
|
6 |
|
7 |
+
public function __construct($config) {
|
8 |
+
self::$logger = $config['logger'];
|
9 |
+
self::$settings = $config['settings'];
|
10 |
+
self::$wpPiwik = $config['wp_piwik'];
|
11 |
}
|
12 |
|
13 |
public function output($array, $key, $default = '') {
|
26 |
$end = time() + $diff;
|
27 |
$start = time() - 2592000 + $diff;
|
28 |
return date('Y-m-d', $start).','.date('Y-m-d', $end);
|
29 |
+
|
30 |
}
|
31 |
+
|
32 |
}
|
classes/index.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Nothing to see...
|
config.php
CHANGED
@@ -6,4 +6,5 @@
|
|
6 |
1: Log to screen
|
7 |
2: Log to file (logs/YYYYMMDD_wp-piwik.log)
|
8 |
*/
|
9 |
-
|
|
6 |
1: Log to screen
|
7 |
2: Log to file (logs/YYYYMMDD_wp-piwik.log)
|
8 |
*/
|
9 |
+
if (!defined('WP_PIWIK_ACTIVATE_LOGGER'))
|
10 |
+
define('WP_PIWIK_ACTIVATE_LOGGER', 0);
|
css/wp-piwik.css
CHANGED
@@ -1,8 +1,17 @@
|
|
1 |
-
.wp-piwik-
|
2 |
-
|
|
|
3 |
}
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
text-align: right;
|
7 |
}
|
8 |
|
@@ -10,14 +19,100 @@ table.wp-piwik-table tr:hover {
|
|
10 |
background-color:#ccc;
|
11 |
}
|
12 |
|
13 |
-
|
14 |
-
|
15 |
}
|
16 |
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
|
21 |
-
.wp-
|
22 |
-
padding-top:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
1 |
+
span.wp-piwik-details {
|
2 |
+
font-size:0.8em;
|
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.n, td.n {
|
15 |
text-align: right;
|
16 |
}
|
17 |
|
19 |
background-color:#ccc;
|
20 |
}
|
21 |
|
22 |
+
form.wp-piwik-settings {
|
23 |
+
margin-right:270px;
|
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 |
+
.wp-piwik-graph-wide {
|
117 |
+
overflow:hidden;
|
118 |
}
|
dashboard/.htaccess
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
Deny from all
|
dashboard/browserdetails.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Stats:BrowserDetails
|
4 |
+
**********************************/
|
5 |
+
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
+
'UserSettings.getBrowserVersion',
|
8 |
+
$aryConf['params']['period'],
|
9 |
+
$aryConf['params']['date'],
|
10 |
+
$aryConf['params']['limit']
|
11 |
+
);
|
12 |
+
$aryConf['title'] = __('Browser Details', 'wp-piwik');
|
13 |
+
$strValues = '';
|
14 |
+
$intCount = 0; $intMore = 0; $intSum = 0;
|
15 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] ='error')
|
16 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
17 |
+
else {
|
18 |
+
if (is_array($aryConf['data']))
|
19 |
+
foreach ($aryConf['data'] as $key => $aryValues) {
|
20 |
+
$intCount++;
|
21 |
+
if ($intCount <= 9) $strValues .= '["'.$aryValues['label'].'",'.$aryValues['nb_uniq_visitors'].'],';
|
22 |
+
else $intMore += $aryValues['nb_uniq_visitors'];
|
23 |
+
$intSum += $aryValues['nb_uniq_visitors'];
|
24 |
+
}
|
25 |
+
if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
|
26 |
+
$strValues = substr($strValues, 0, -1);
|
27 |
+
if ($intSum) {
|
28 |
+
/***************************************************************************/ ?>
|
29 |
+
<div class="wp-piwik-graph-wide">
|
30 |
+
<div id="wp-piwik_stats_browserdetails_graph" style="height:310px;width:100%"></div>
|
31 |
+
</div>
|
32 |
+
<?php /************************************************************************/
|
33 |
+
}
|
34 |
+
/***************************************************************************/ ?>
|
35 |
+
<div class="table">
|
36 |
+
<table class="widefat wp-piwik-table">
|
37 |
+
<thead>
|
38 |
+
<tr>
|
39 |
+
<th><?php _e('Browser', 'wp-piwik'); ?></th>
|
40 |
+
<th class="n"><?php _e('Unique', 'wp-piwik'); ?></th>
|
41 |
+
<th class="n"><?php _e('Percent', 'wp-piwik'); ?></th>
|
42 |
+
</tr>
|
43 |
+
</thead>
|
44 |
+
<tbody>
|
45 |
+
<?php /************************************************************************/
|
46 |
+
if ($intSum)
|
47 |
+
foreach ($aryConf['data'] as $aryValues)
|
48 |
+
echo '<tr><td>'.
|
49 |
+
$aryValues['label'].
|
50 |
+
'</td><td class="n">'.
|
51 |
+
$aryValues['nb_uniq_visitors'].
|
52 |
+
'</td><td class="n">'.
|
53 |
+
number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
|
54 |
+
'%</td></tr>';
|
55 |
+
else echo '<tr><td colspan="3">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
56 |
+
unset($aryTmp);
|
57 |
+
/***************************************************************************/ ?>
|
58 |
+
</tbody>
|
59 |
+
</table>
|
60 |
+
</div>
|
61 |
+
<script type="text/javascript">
|
62 |
+
$plotBrowsers = $j.jqplot('wp-piwik_stats_browserdetails_graph', [[<?php echo $strValues; ?>]], {
|
63 |
+
seriesDefaults:{renderer:$j.jqplot.PieRenderer, rendererOptions:{sliceMargin:8}},
|
64 |
+
legend:{show:true}
|
65 |
+
});
|
66 |
+
</script>
|
67 |
+
<?php
|
68 |
+
}
|
dashboard/browsers.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Stats:Browser
|
4 |
+
**********************************/
|
5 |
+
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
+
'UserSettings.getBrowser',
|
8 |
+
$aryConf['params']['period'],
|
9 |
+
$aryConf['params']['date'],
|
10 |
+
$aryConf['params']['limit']
|
11 |
+
);
|
12 |
+
|
13 |
+
$aryConf['title'] = __('Browser', 'wp-piwik');
|
14 |
+
$strValues = '';
|
15 |
+
$intCount = 0; $intMore = 0; $intSum = 0;
|
16 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] ='error')
|
17 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
18 |
+
else {
|
19 |
+
if (is_array($aryConf['data']))
|
20 |
+
foreach ($aryConf['data'] as $key => $aryValues) {
|
21 |
+
$intCount++;
|
22 |
+
if ($intCount <= 9) $strValues .= '["'.$aryValues['label'].'",'.$aryValues['nb_uniq_visitors'].'],';
|
23 |
+
else $intMore += $aryValues['nb_uniq_visitors'];
|
24 |
+
$intSum += $aryValues['nb_uniq_visitors'];
|
25 |
+
}
|
26 |
+
if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
|
27 |
+
$strValues = substr($strValues, 0, -1);
|
28 |
+
if ($intSum) {
|
29 |
+
/***************************************************************************/ ?>
|
30 |
+
<div class="wp-piwik-graph-wide">
|
31 |
+
<div id="wp-piwik_stats_browsers_graph" style="height:310px;width:100%"></div>
|
32 |
+
</div>
|
33 |
+
<?php /************************************************************************/
|
34 |
+
}
|
35 |
+
/***************************************************************************/ ?>
|
36 |
+
<div class="table">
|
37 |
+
<table class="widefat wp-piwik-table">
|
38 |
+
<thead>
|
39 |
+
<tr>
|
40 |
+
<th><?php _e('Browser', 'wp-piwik'); ?></th>
|
41 |
+
<th class="n"><?php _e('Unique', 'wp-piwik'); ?></th>
|
42 |
+
<th class="n"><?php _e('Percent', 'wp-piwik'); ?></th>
|
43 |
+
</tr>
|
44 |
+
</thead>
|
45 |
+
<tbody>
|
46 |
+
<?php /************************************************************************/
|
47 |
+
if ($intSum)
|
48 |
+
foreach ($aryConf['data'] as $aryValues)
|
49 |
+
echo '<tr><td>'.
|
50 |
+
$aryValues['label'].
|
51 |
+
'</td><td class="n">'.
|
52 |
+
$aryValues['nb_uniq_visitors'].
|
53 |
+
'</td><td class="n">'.
|
54 |
+
number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
|
55 |
+
'%</td></tr>';
|
56 |
+
else echo '<tr><td colspan="3">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
57 |
+
unset($aryTmp);
|
58 |
+
/***************************************************************************/ ?>
|
59 |
+
</tbody>
|
60 |
+
</table>
|
61 |
+
</div>
|
62 |
+
<script type="text/javascript">
|
63 |
+
$plotBrowsers = $j.jqplot('wp-piwik_stats_browsers_graph', [[<?php echo $strValues; ?>]], {
|
64 |
+
seriesDefaults:{renderer:$j.jqplot.PieRenderer, rendererOptions:{sliceMargin:8}},
|
65 |
+
legend:{show:true}
|
66 |
+
});
|
67 |
+
</script>
|
68 |
+
<?php
|
69 |
+
}
|
dashboard/index.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Nothing to see...
|
dashboard/keywords.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Stats:Keywords
|
4 |
+
**********************************/
|
5 |
+
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
+
'Referers.getKeywords',
|
8 |
+
$aryConf['params']['period'],
|
9 |
+
$aryConf['params']['date'],
|
10 |
+
$aryConf['params']['limit']
|
11 |
+
);
|
12 |
+
$aryConf['title'] = __('Keywords', 'wp-piwik');
|
13 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] = 'error')
|
14 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
15 |
+
else {
|
16 |
+
/***************************************************************************/ ?>
|
17 |
+
<table class="widefat">
|
18 |
+
<thead>
|
19 |
+
<tr><th><?php _e('Keyword', 'wp-piwik'); ?></th><th><?php _e('Unique', 'wp-piwik'); ?></th></tr>
|
20 |
+
</thead>
|
21 |
+
<tbody>
|
22 |
+
<?php /************************************************************************/
|
23 |
+
if (is_array($aryConf['data'])) foreach ($aryConf['data'] as $aryValues)
|
24 |
+
echo '<tr><td>'.$aryValues['label'].'</td><td>'.$aryValues['nb_uniq_visitors'].'</td></tr>';
|
25 |
+
else echo '<tr><td colspan="2">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
26 |
+
/***************************************************************************/ ?>
|
27 |
+
</tbody>
|
28 |
+
</table>
|
29 |
+
<?php /************************************************************************/
|
30 |
+
}
|
dashboard/noresult.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Stats:SiteSearchNoResults
|
4 |
+
**********************************/
|
5 |
+
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
+
'Actions.getSiteSearchNoResultKeywords',
|
8 |
+
$aryConf['params']['period'],
|
9 |
+
$aryConf['params']['date'],
|
10 |
+
$aryConf['params']['limit']
|
11 |
+
);
|
12 |
+
$aryConf['title'] = __('Site Search without Results', 'wp-piwik');
|
13 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] = 'error')
|
14 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
15 |
+
else {
|
16 |
+
/***************************************************************************/ ?>
|
17 |
+
<table class="widefat">
|
18 |
+
<thead>
|
19 |
+
<tr><th><?php _e('Keyword', 'wp-piwik'); ?></th><th><?php _e('Requests', 'wp-piwik'); ?></th><th><?php _e('Bounced', 'wp-piwik'); ?></th></tr>
|
20 |
+
</thead>
|
21 |
+
<tbody>
|
22 |
+
<?php /************************************************************************/
|
23 |
+
if (is_array($aryConf['data'])) foreach ($aryConf['data'] as $aryValues)
|
24 |
+
echo '<tr><td>'.$aryValues['label'].'</td><td>'.$aryValues['nb_visits'].'</td><td>'.$aryValues['bounce_rate'].'</td></tr>';
|
25 |
+
else echo '<tr><td colspan="2">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
26 |
+
/***************************************************************************/ ?>
|
27 |
+
</tbody>
|
28 |
+
</table>
|
29 |
+
<?php /************************************************************************/
|
30 |
+
}
|
dashboard/overview.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Stats:Overview
|
4 |
+
**********************************/
|
5 |
+
$aryTmp = array(
|
6 |
+
'bounce_count' => 0,
|
7 |
+
'max_actions' => 0,
|
8 |
+
'nb_actions' => 0,
|
9 |
+
'nb_uniq_visitors' => 0,
|
10 |
+
'nb_visits' => 0,
|
11 |
+
'nb_visits_converted' => 0,
|
12 |
+
'sum_visit_length' => 0,
|
13 |
+
'bounce_rate' => 0,
|
14 |
+
'nb_actions_per_visit' => 0,
|
15 |
+
'avg_time_on_site' => 0
|
16 |
+
);
|
17 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
18 |
+
'VisitsSummary.get',
|
19 |
+
$aryConf['params']['period'],
|
20 |
+
$aryConf['params']['date'],
|
21 |
+
$aryConf['params']['limit']
|
22 |
+
);
|
23 |
+
$aryConf['title'] = __('Overview', 'wp-piwik');
|
24 |
+
|
25 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] ='error')
|
26 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
27 |
+
else {
|
28 |
+
if ($aryConf['params']['date'] == 'last30') {
|
29 |
+
$intValCnt = 0;
|
30 |
+
if (is_array($aryConf['data']))
|
31 |
+
foreach ($aryConf['data'] as $aryDay)
|
32 |
+
foreach ($aryDay as $strKey => $strValue) {
|
33 |
+
$intValCnt++;
|
34 |
+
if (!in_array($strKey, array('max_actions','bounce_rate','nb_actions_per_visit','avg_time_on_site')))
|
35 |
+
{ if (isset($aryTmp[$strKey])) $aryTmp[$strKey] += $strValue; }
|
36 |
+
elseif ($aryTmp[$strKey] < $strValue)
|
37 |
+
$aryTmp[$strKey] = $strValue;
|
38 |
+
}
|
39 |
+
$aryConf['data'] = $aryTmp;
|
40 |
+
if ($intValCnt > 1 && $aryConf['data']['nb_visits'] >0) $aryConf['data']['bounce_rate'] = round($aryConf['data']['bounce_count']/$aryConf['data']['nb_visits']*100).'%';
|
41 |
+
}
|
42 |
+
if (empty($aryConf['data'])) $aryConf['data'] = $aryTmp;
|
43 |
+
/***************************************************************************/ ?>
|
44 |
+
<div class="table">
|
45 |
+
<table class="widefat">
|
46 |
+
<tbody>
|
47 |
+
<?php /************************************************************************/
|
48 |
+
$strTime =
|
49 |
+
floor($aryConf['data']['sum_visit_length']/3600).'h '.
|
50 |
+
floor(($aryConf['data']['sum_visit_length'] % 3600)/60).'m '.
|
51 |
+
floor(($aryConf['data']['sum_visit_length'] % 3600) % 60).'s';
|
52 |
+
$strAvgTime =
|
53 |
+
floor($aryConf['data']['avg_time_on_site']/3600).'h '.
|
54 |
+
floor(($aryConf['data']['avg_time_on_site'] % 3600)/60).'m '.
|
55 |
+
floor(($aryConf['data']['avg_time_on_site'] % 3600) % 60).'s';
|
56 |
+
echo '<tr><td>'.__('Visitors', 'wp-piwik').':</td><td>'.$aryConf['data']['nb_visits'].'</td></tr>';
|
57 |
+
echo '<tr><td>'.__('Unique visitors', 'wp-piwik').':</td><td>'.$aryConf['data']['nb_uniq_visitors'].'</td></tr>';
|
58 |
+
echo '<tr><td>'.__('Page views', 'wp-piwik').':</td><td>'.$aryConf['data']['nb_actions'].' (Ø '.$aryConf['data']['nb_actions_per_visit'].')</td></tr>';
|
59 |
+
echo '<tr><td>'.__('Max. page views in one visit', 'wp-piwik').':</td><td>'.$aryConf['data']['max_actions'].'</td></tr>';
|
60 |
+
echo '<tr><td>'.__('Total time spent', 'wp-piwik').':</td><td>'.$strTime.'</td></tr>';
|
61 |
+
echo '<tr><td>'.__('Time/visit', 'wp-piwik').':</td><td>'.$strAvgTime.'</td></tr>';
|
62 |
+
echo '<tr><td>'.__('Bounce count', 'wp-piwik').':</td><td>'.$aryConf['data']['bounce_count'].' ('.$aryConf['data']['bounce_rate'].')</td></tr>';
|
63 |
+
if (self::$settings->getGlobalOption('piwik_shortcut'))
|
64 |
+
echo '<tr><td>'.__('Shortcut', 'wp-piwik').':</td><td><a href="'.self::$settings->getGlobalOption('piwik_url').'">Piwik</a>'.(isset($aryConf['inline']) && $aryConf['inline']?' - <a href="?page=wp-piwik_stats">WP-Piwik</a>':'').'</td></tr>';
|
65 |
+
/***************************************************************************/ ?>
|
66 |
+
</tbody>
|
67 |
+
</table>
|
68 |
+
</div>
|
69 |
+
<?php /************************************************************************/
|
70 |
+
}
|
dashboard/pages.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Stats:Pages
|
4 |
+
**********************************/
|
5 |
+
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
+
'Actions.getPageTitles',
|
8 |
+
$aryConf['params']['period'],
|
9 |
+
$aryConf['params']['date'],
|
10 |
+
$aryConf['params']['limit']
|
11 |
+
);
|
12 |
+
$intMax = 9;
|
13 |
+
$aryConf['title'] = __('Pages', 'wp-piwik');
|
14 |
+
|
15 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] = 'error')
|
16 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
17 |
+
else {
|
18 |
+
/***************************************************************************/ ?>
|
19 |
+
<div class="table">
|
20 |
+
<table class="widefat wp-piwik-table">
|
21 |
+
<thead>
|
22 |
+
<tr>
|
23 |
+
<th><?php _e('Page', 'wp-piwik'); ?></th>
|
24 |
+
<th class="n"><?php _e('Unique', 'wp-piwik'); ?></th>
|
25 |
+
<th class="n"><?php _e('Visits', 'wp-piwik'); ?></th>
|
26 |
+
</tr>
|
27 |
+
</thead>
|
28 |
+
<tbody>
|
29 |
+
<?php /************************************************************************/
|
30 |
+
$intCount = 0; $aryOthers = array('u' => 0, 'v' => 0);
|
31 |
+
if (is_array($aryConf['data'])) foreach ($aryConf['data'] as $aryValues) {
|
32 |
+
$intCount++;
|
33 |
+
if ($intCount > $intMax) {
|
34 |
+
$aryOthers['u'] += (isset($aryValues['nb_uniq_visitors'])?$aryValues['nb_uniq_visitors']:0);
|
35 |
+
$aryOthers['v'] += (isset($aryValues['nb_visits'])?$aryValues['nb_visits']:0);
|
36 |
+
} else echo '<tr><td>'.
|
37 |
+
$aryValues['label'].
|
38 |
+
'</td><td class="n">'.
|
39 |
+
$aryValues['nb_uniq_visitors'].
|
40 |
+
'</td><td class="n">'.
|
41 |
+
$aryValues['nb_visits'].
|
42 |
+
'</td></tr>';
|
43 |
+
} else echo '<tr><td colspan="3">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
44 |
+
if (!empty($aryOthers['v'])) echo '<tr><td>'.
|
45 |
+
__('Others', 'wp-piwik').
|
46 |
+
'</td><td class="n">'.
|
47 |
+
$aryOthers['u'].
|
48 |
+
'</td><td class="n">'.
|
49 |
+
$aryOthers['v'].
|
50 |
+
'</td></tr>';
|
51 |
+
|
52 |
+
/***************************************************************************/ ?>
|
53 |
+
</tbody>
|
54 |
+
</table>
|
55 |
+
</div>
|
56 |
+
<?php /************************************************************************/
|
57 |
+
}
|
dashboard/plugins.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Stats:Plugins
|
4 |
+
**********************************/
|
5 |
+
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
+
'UserSettings.getPlugin',
|
8 |
+
$aryConf['params']['period'],
|
9 |
+
$aryConf['params']['date'],
|
10 |
+
$aryConf['params']['limit']
|
11 |
+
);
|
12 |
+
$aryConf['title'] = __('Plugins', 'wp-piwik');
|
13 |
+
|
14 |
+
$aryOverview = $this->callPiwikAPI(
|
15 |
+
'VisitsSummary.get',
|
16 |
+
$aryConf['params']['period'],
|
17 |
+
$aryConf['params']['date'],
|
18 |
+
$aryConf['params']['limit']
|
19 |
+
);
|
20 |
+
|
21 |
+
$intTotalVisits = (isset($aryOverview['nb_visits'])?$aryOverview['nb_visits']:0);
|
22 |
+
|
23 |
+
unset($aryOverview);
|
24 |
+
|
25 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] = 'error')
|
26 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
27 |
+
else {
|
28 |
+
/***************************************************************************/ ?>
|
29 |
+
<div class="table">
|
30 |
+
<table class="widefat wp-piwik-table">
|
31 |
+
<thead>
|
32 |
+
<tr>
|
33 |
+
<th><?php _e('Plugins', 'wp-piwik'); ?></th>
|
34 |
+
<th class="n"><?php _e('Visits', 'wp-piwik'); ?></th>
|
35 |
+
<th class="n"><?php _e('Percent', 'wp-piwik'); ?></th>
|
36 |
+
</tr>
|
37 |
+
</thead>
|
38 |
+
<tbody>
|
39 |
+
<?php /************************************************************************/
|
40 |
+
if (is_array($aryConf['data'])) foreach ($aryConf['data'] as $aryValues)
|
41 |
+
echo '<tr><td>'.
|
42 |
+
$aryValues['label'].
|
43 |
+
'</td><td class="n">'.
|
44 |
+
$aryValues['nb_visits'].
|
45 |
+
'</td><td class="n">'.
|
46 |
+
($intTotalVisits != 0?
|
47 |
+
number_format(($aryValues['nb_visits']/$intTotalVisits*100),2):
|
48 |
+
'0.00%'
|
49 |
+
).
|
50 |
+
'%</td></tr>';
|
51 |
+
else echo '<tr><td colspan="3">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
52 |
+
unset($aryTmp);
|
53 |
+
/***************************************************************************/ ?>
|
54 |
+
</tbody>
|
55 |
+
</table>
|
56 |
+
</div>
|
57 |
+
<?php /************************************************************************/
|
58 |
+
}
|
dashboard/screens.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Stats:Screens
|
4 |
+
**********************************/
|
5 |
+
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
+
'UserSettings.getResolution',
|
8 |
+
$aryConf['params']['period'],
|
9 |
+
$aryConf['params']['date'],
|
10 |
+
$aryConf['params']['limit']
|
11 |
+
);
|
12 |
+
$aryConf['title'] = __('Resolution', 'wp-piwik');
|
13 |
+
$strValues = '';
|
14 |
+
$intCount = 0; $intMore = 0; $intSum = 0;
|
15 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] ='error')
|
16 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
17 |
+
else {
|
18 |
+
if (is_array($aryConf['data']))
|
19 |
+
foreach ($aryConf['data'] as $key => $aryValues) {
|
20 |
+
$intCount++;
|
21 |
+
if ($intCount <= 9) $strValues .= '["'.$aryValues['label'].'",'.$aryValues['nb_uniq_visitors'].'],';
|
22 |
+
else $intMore += $aryValues['nb_uniq_visitors'];
|
23 |
+
$intSum += $aryValues['nb_uniq_visitors'];
|
24 |
+
}
|
25 |
+
if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
|
26 |
+
$strValues = substr($strValues, 0, -1);
|
27 |
+
if ($intSum) {
|
28 |
+
/***************************************************************************/ ?>
|
29 |
+
<div class="wp-piwik-graph-wide">
|
30 |
+
<div id="wp-piwik_stats_screens_graph" style="height:310px;width:100%"></div>
|
31 |
+
</div>
|
32 |
+
<?php /************************************************************************/
|
33 |
+
}
|
34 |
+
/***************************************************************************/ ?>
|
35 |
+
<div class="table">
|
36 |
+
<table class="widefat wp-piwik-table">
|
37 |
+
<thead>
|
38 |
+
<tr>
|
39 |
+
<th><?php _e('Resolution', 'wp-piwik'); ?></th>
|
40 |
+
<th class="n"><?php _e('Unique', 'wp-piwik'); ?></th>
|
41 |
+
<th class="n"><?php _e('Percent', 'wp-piwik'); ?></th>
|
42 |
+
</tr>
|
43 |
+
</thead>
|
44 |
+
<tbody>
|
45 |
+
<?php /************************************************************************/
|
46 |
+
if ($intSum)
|
47 |
+
foreach ($aryConf['data'] as $aryValues)
|
48 |
+
echo '<tr><td>'.
|
49 |
+
$aryValues['label'].
|
50 |
+
'</td><td class="n">'.
|
51 |
+
$aryValues['nb_uniq_visitors'].
|
52 |
+
'</td><td class="n">'.
|
53 |
+
number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
|
54 |
+
'%</td></tr>';
|
55 |
+
else echo '<tr><td colspan="3">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
56 |
+
unset($aryTmp);
|
57 |
+
/***************************************************************************/ ?>
|
58 |
+
</tbody>
|
59 |
+
</table>
|
60 |
+
</div>
|
61 |
+
<script type="text/javascript">
|
62 |
+
$plotScreens = $j.jqplot('wp-piwik_stats_screens_graph', [[<?php echo $strValues; ?>]], {
|
63 |
+
seriesDefaults:{renderer:$j.jqplot.PieRenderer, rendererOptions:{sliceMargin:8}},
|
64 |
+
legend:{show:true}
|
65 |
+
});
|
66 |
+
</script>
|
67 |
+
<?php
|
68 |
+
}
|
dashboard/search.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Stats:SiteSearch
|
4 |
+
**********************************/
|
5 |
+
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
+
'Actions.getSiteSearchKeywords',
|
8 |
+
$aryConf['params']['period'],
|
9 |
+
$aryConf['params']['date'],
|
10 |
+
$aryConf['params']['limit']
|
11 |
+
);
|
12 |
+
$aryConf['title'] = __('Site Search Keywords', 'wp-piwik');
|
13 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] = 'error')
|
14 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
15 |
+
else {
|
16 |
+
/***************************************************************************/ ?>
|
17 |
+
<table class="widefat">
|
18 |
+
<thead>
|
19 |
+
<tr><th><?php _e('Keyword', 'wp-piwik'); ?></th><th><?php _e('Requests', 'wp-piwik'); ?></th><th><?php _e('Bounced', 'wp-piwik'); ?></th></tr>
|
20 |
+
</thead>
|
21 |
+
<tbody>
|
22 |
+
<?php /************************************************************************/
|
23 |
+
if (is_array($aryConf['data'])) foreach ($aryConf['data'] as $aryValues)
|
24 |
+
echo '<tr><td>'.$aryValues['label'].'</td><td>'.$aryValues['nb_visits'].'</td><td>'.$aryValues['bounce_rate'].'</td></tr>';
|
25 |
+
else echo '<tr><td colspan="2">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
26 |
+
/***************************************************************************/ ?>
|
27 |
+
</tbody>
|
28 |
+
</table>
|
29 |
+
<?php /************************************************************************/
|
30 |
+
}
|
dashboard/seo.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Stats:SEO
|
4 |
+
**********************************/
|
5 |
+
$aryConf['data'] = $GLOBALS['wp_piwik']->callPiwikAPI(
|
6 |
+
'SEO.getRank',
|
7 |
+
$aryConf['params']['period'],
|
8 |
+
$aryConf['params']['date'],
|
9 |
+
$aryConf['params']['limit'],
|
10 |
+
false,
|
11 |
+
false,
|
12 |
+
'csv'
|
13 |
+
);
|
14 |
+
|
15 |
+
if (substr($aryConf['data'], 0, 6) == 'Error:') {
|
16 |
+
$strMessage = str_replace('Error:', '', $aryConf['data']);
|
17 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($strMessage, ENT_QUOTES, 'utf-8');
|
18 |
+
} else {
|
19 |
+
|
20 |
+
$aryConf['title'] = __('SEO', 'wp-piwik');
|
21 |
+
$aryLines = explode("\n", $aryConf['data']);
|
22 |
+
foreach ($aryLines as $strLine)
|
23 |
+
$aryData[] = explode(',', $strLine);
|
24 |
+
unset($aryData[0]);
|
25 |
+
/***************************************************************************/ ?>
|
26 |
+
<div class="table">
|
27 |
+
<table class="widefat">
|
28 |
+
<tbody>
|
29 |
+
<?php foreach ($aryData as $aryVal) { ?>
|
30 |
+
<tr><td><?php echo $aryVal[0]; ?></td><td><?php echo $aryVal[1]; ?></td></tr>
|
31 |
+
<?php } ?>
|
32 |
+
</tbody>
|
33 |
+
</table>
|
34 |
+
</div>
|
35 |
+
<?php /************************************************************************/
|
36 |
+
}
|
dashboard/systems.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Stats:Systems
|
4 |
+
**********************************/
|
5 |
+
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
+
'UserSettings.getOS',
|
8 |
+
$aryConf['params']['period'],
|
9 |
+
$aryConf['params']['date'],
|
10 |
+
$aryConf['params']['limit']
|
11 |
+
);
|
12 |
+
$aryConf['title'] = __('Operating System', 'wp-piwik');
|
13 |
+
$strValues = '';
|
14 |
+
$intCount = 0; $intMore = 0; $intSum = 0;
|
15 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] ='error')
|
16 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
17 |
+
else {
|
18 |
+
if (is_array($aryConf['data']))
|
19 |
+
foreach ($aryConf['data'] as $key => $aryValues) {
|
20 |
+
$intCount++;
|
21 |
+
if ($intCount <= 9) $strValues .= '["'.$aryValues['label'].'",'.$aryValues['nb_uniq_visitors'].'],';
|
22 |
+
else $intMore += $aryValues['nb_uniq_visitors'];
|
23 |
+
$intSum += $aryValues['nb_uniq_visitors'];
|
24 |
+
}
|
25 |
+
if ($intMore) $strValues .= '["'.__('Others', 'wp-piwik').'",'.$intMore.'],';
|
26 |
+
$strValues = substr($strValues, 0, -1);
|
27 |
+
|
28 |
+
if ($intSum) {
|
29 |
+
/***************************************************************************/ ?>
|
30 |
+
<div class="wp-piwik-graph-wide">
|
31 |
+
<div id="wp-piwik_stats_systems_graph" style="height:310px;width:100%"></div>
|
32 |
+
</div>
|
33 |
+
<?php /************************************************************************/
|
34 |
+
}
|
35 |
+
/***************************************************************************/ ?>
|
36 |
+
<div class="table">
|
37 |
+
<table class="widefat wp-piwik-table">
|
38 |
+
<thead>
|
39 |
+
<tr>
|
40 |
+
<th><?php _e('Operating System', 'wp-piwik'); ?></th>
|
41 |
+
<th class="n"><?php _e('Unique', 'wp-piwik'); ?></th>
|
42 |
+
<th class="n"><?php _e('Percent', 'wp-piwik'); ?></th>
|
43 |
+
</tr>
|
44 |
+
</thead>
|
45 |
+
<tbody>
|
46 |
+
<?php /************************************************************************/
|
47 |
+
if ($intSum)
|
48 |
+
foreach ($aryConf['data'] as $aryValues)
|
49 |
+
echo '<tr><td>'.
|
50 |
+
$aryValues['label'].
|
51 |
+
'</td><td class="n">'.
|
52 |
+
$aryValues['nb_uniq_visitors'].
|
53 |
+
'</td><td class="n">'.
|
54 |
+
number_format($aryValues['nb_uniq_visitors']/$intSum*100, 2).
|
55 |
+
'%</td></tr>';
|
56 |
+
else echo '<tr><td colspan="3">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
57 |
+
unset($aryTmp);
|
58 |
+
/***************************************************************************/ ?>
|
59 |
+
</tbody>
|
60 |
+
</table>
|
61 |
+
</div>
|
62 |
+
<script type="text/javascript">
|
63 |
+
$plotSystems = $j.jqplot('wp-piwik_stats_systems_graph', [[<?php echo $strValues; ?>]], {
|
64 |
+
seriesDefaults:{renderer:$j.jqplot.PieRenderer, rendererOptions:{sliceMargin:8}},
|
65 |
+
legend:{show:true}
|
66 |
+
});
|
67 |
+
</script>
|
68 |
+
<?php
|
69 |
+
}
|
dashboard/visitors.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Stats:Vistors
|
4 |
+
**********************************/
|
5 |
+
|
6 |
+
$aryConf['data']['Visitors'] = $this->callPiwikAPI(
|
7 |
+
'VisitsSummary.getVisits',
|
8 |
+
$aryConf['params']['period'],
|
9 |
+
$aryConf['params']['date'],
|
10 |
+
$aryConf['params']['limit']
|
11 |
+
);
|
12 |
+
$aryConf['data']['Unique'] = $this->callPiwikAPI(
|
13 |
+
'VisitsSummary.getUniqueVisitors',
|
14 |
+
$aryConf['params']['period'],
|
15 |
+
$aryConf['params']['date'],
|
16 |
+
$aryConf['params']['limit']
|
17 |
+
);
|
18 |
+
$aryConf['data']['Bounced'] = $this->callPiwikAPI(
|
19 |
+
'VisitsSummary.getBounceCount',
|
20 |
+
$aryConf['params']['period'],
|
21 |
+
$aryConf['params']['date'],
|
22 |
+
$aryConf['params']['limit']
|
23 |
+
);
|
24 |
+
$aryConf['data']['Actions'] = $this->callPiwikAPI(
|
25 |
+
'VisitsSummary.getActions',
|
26 |
+
$aryConf['params']['period'],
|
27 |
+
$aryConf['params']['date'],
|
28 |
+
$aryConf['params']['limit']
|
29 |
+
);
|
30 |
+
|
31 |
+
if (isset($aryConf['data']['Visitors']['result']) && $aryConf['data']['Visitors']['result'] ='error')
|
32 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['Visitors']['message'], ENT_QUOTES, 'utf-8');
|
33 |
+
else {
|
34 |
+
$strValues = $strLabels = $strBounced = $strValuesU = $strCounter = '';
|
35 |
+
$intUSum = $intCount = 0;
|
36 |
+
if (is_array($aryConf['data']['Visitors']))
|
37 |
+
foreach ($aryConf['data']['Visitors'] as $strDate => $intValue) {
|
38 |
+
$intCount++;
|
39 |
+
$strValues .= $intValue.',';
|
40 |
+
$strValuesU .= $aryConf['data']['Unique'][$strDate].',';
|
41 |
+
$strBounced .= $aryConf['data']['Bounced'][$strDate].',';
|
42 |
+
$strLabels .= '['.$intCount.',"'.substr($strDate,-2).'"],';
|
43 |
+
$intUSum += $aryConf['data']['Unique'][$strDate];
|
44 |
+
}
|
45 |
+
else {$strValues = '0,'; $strLabels = '[0,"-"],'; $strValuesU = '0,'; $strBounced = '0,'; }
|
46 |
+
$intAvg = round($intUSum/30,0);
|
47 |
+
$strValues = substr($strValues, 0, -1);
|
48 |
+
$strValuesU = substr($strValuesU, 0, -1);
|
49 |
+
$strLabels = substr($strLabels, 0, -1);
|
50 |
+
$strBounced = substr($strBounced, 0, -1);
|
51 |
+
$strCounter = substr($strCounter, 0, -1);
|
52 |
+
|
53 |
+
/***************************************************************************/ ?>
|
54 |
+
<div class="wp-piwik-graph-wide" title="<?php _e('The graph contains the values shown in the table below (visitors / unique / bounces). The red line show a linear trendline (unique).', 'wp-piwik'); ?>">
|
55 |
+
<div id="wp-piwik_stats_vistors_graph" style="height:220px;<?php if (!isset($aryConf['inline']) || $aryConf['inline'] != true) { ?>width:100%<?php } ?>"></div>
|
56 |
+
</div>
|
57 |
+
<?php if (!isset($aryConf['inline']) || $aryConf['inline'] != true) { ?>
|
58 |
+
<div class="table">
|
59 |
+
<table class="widefat wp-piwik-table">
|
60 |
+
<thead>
|
61 |
+
<tr>
|
62 |
+
<th><?php _e('Date', 'wp-piwik'); ?></th>
|
63 |
+
<th class="n"><?php _e('Visits', 'wp-piwik'); ?></th>
|
64 |
+
<th class="n"><?php _e('Unique', 'wp-piwik'); ?></th>
|
65 |
+
<th class="n"><?php _e('Bounced', 'wp-piwik'); ?></th>
|
66 |
+
<th class="n"><?php _e('Page Views', 'wp-piwik'); ?></th>
|
67 |
+
</tr>
|
68 |
+
</thead>
|
69 |
+
<tbody style="cursor:pointer;">
|
70 |
+
<?php /************************************************************************/
|
71 |
+
if (is_array($aryConf['data']['Visitors'])) {
|
72 |
+
$aryTmp = array_reverse($aryConf['data']['Visitors']);
|
73 |
+
foreach ($aryTmp as $strDate => $intValue)
|
74 |
+
echo '<tr onclick="javascript:datelink(\''.urlencode('wp-piwik_stats').'\',\''.str_replace('-', '', $strDate).'\',\''.(isset($_GET['wpmu_show_stats'])?(int) $_GET['wpmu_show_stats']:'').'\');"><td>'.$strDate.'</td><td class="n">'.
|
75 |
+
$intValue.'</td><td class="n">'.
|
76 |
+
$aryConf['data']['Unique'][$strDate].
|
77 |
+
'</td><td class="n">'.
|
78 |
+
$aryConf['data']['Bounced'][$strDate].
|
79 |
+
'</td><td class="n">'.
|
80 |
+
$aryConf['data']['Actions'][$strDate].
|
81 |
+
'</td></tr>'."\n";
|
82 |
+
}
|
83 |
+
echo '<tr><td class="n" colspan="4"><strong>'.__('Unique TOTAL', 'wp-piwik').'</strong> '.__('Sum', 'wp-piwik').': '.$intUSum.' '.__('Avg', 'wp-piwik').': '.$intAvg.'</td></tr>';
|
84 |
+
unset($aryTmp);
|
85 |
+
/***************************************************************************/ ?>
|
86 |
+
</tbody>
|
87 |
+
</table>
|
88 |
+
</div>
|
89 |
+
<?php } ?>
|
90 |
+
<script type="text/javascript">
|
91 |
+
$plotVisitors = $j.jqplot('wp-piwik_stats_vistors_graph', [[<?php echo $strValues; ?>],[<?php echo $strValuesU; ?>],[<?php echo $strBounced;?>]],
|
92 |
+
{
|
93 |
+
axes:{yaxis:{min:0, tickOptions:{formatString:'%.0f'}},xaxis:{min:1,max:30,ticks:[<?php echo $strLabels; ?>]}},
|
94 |
+
seriesDefaults:{showMarker:false,lineWidth:1,fill:true,fillAndStroke:true,fillAlpha:0.9,trendline:{show:false,color:'#C00',lineWidth:1.5,type:'exp'}},
|
95 |
+
series:[{color:'#90AAD9',fillColor:'#D4E2ED'},{color:'#A3BCEA',fillColor:'#E4F2FD',trendline:{show:true,label:'Unique visitor trend'}},{color:'#E9A0BA',fillColor:'#FDE4F2'}],
|
96 |
+
});
|
97 |
+
</script>
|
98 |
+
<?php
|
99 |
+
}
|
dashboard/websites.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Stats:Websites
|
4 |
+
**********************************/
|
5 |
+
|
6 |
+
$aryConf['data'] = $this->callPiwikAPI(
|
7 |
+
'Referers.getWebsites',
|
8 |
+
$aryConf['params']['period'],
|
9 |
+
$aryConf['params']['date'],
|
10 |
+
$aryConf['params']['limit']
|
11 |
+
);
|
12 |
+
$aryConf['title'] = __('Websites', 'wp-piwik');
|
13 |
+
|
14 |
+
if (isset($aryConf['data']['result']) && $aryConf['data']['result'] = 'error')
|
15 |
+
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($aryConf['data']['message'], ENT_QUOTES, 'utf-8');
|
16 |
+
else {
|
17 |
+
/***************************************************************************/ ?>
|
18 |
+
<table class="widefat">
|
19 |
+
<thead>
|
20 |
+
<tr>
|
21 |
+
<th><?php _e('Website', 'wp-piwik'); ?></th>
|
22 |
+
<th><?php _e('Unique', 'wp-piwik'); ?></th>
|
23 |
+
</tr>
|
24 |
+
</thead>
|
25 |
+
<tbody>
|
26 |
+
<?php /************************************************************************/
|
27 |
+
if (is_array($aryConf['data'])) foreach ($aryConf['data'] as $aryValues)
|
28 |
+
echo '<tr><td>'.$aryValues['label'].'</td><td>'.$aryValues['nb_uniq_visitors'].'</td></tr>';
|
29 |
+
else echo '<tr><td colspan="2">'.__('No data available.', 'wp-piwik').'</td></tr>';
|
30 |
+
/***************************************************************************/ ?>
|
31 |
+
</tbody>
|
32 |
+
</table>
|
33 |
+
<?php /************************************************************************/
|
34 |
+
}
|
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 datelink(strPage,strDate,intSite) {
|
2 |
window.location.href='index.php?page='+strPage+'&date='+strDate+'&wpmu_show_stats='+intSite;
|
3 |
}
|
languages/wp-piwik-de_DE.mo
CHANGED
Binary file
|
languages/wp-piwik-de_DE.po
CHANGED
@@ -698,7 +698,7 @@ msgid "Keyword: post name."
|
|
698 |
msgstr "Schlüsselwort: Name des Beitrags."
|
699 |
|
700 |
msgid "Enable to track posts in feeds via tracking pixel."
|
701 |
-
msgstr "Aktivieren, um
|
702 |
|
703 |
msgid "Enable to track users on admin pages (remember to configure the tracking filter appropriately)."
|
704 |
msgstr "Aktivieren, um Nutzer auf Admin-Seiten zu zählen (bitte den Tracking Filter entsprechend konfigurieren)."
|
@@ -764,4 +764,22 @@ msgid "Track visitors across all alias URLs"
|
|
764 |
msgstr "Besucher über alle alternative URLs aufzeichnen"
|
765 |
|
766 |
msgid "Adds *.-prefix to tracked domain."
|
767 |
-
msgstr "Fügt ein *.-Präfix zur getrackten Domain hinzu."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
698 |
msgstr "Schlüsselwort: Name des Beitrags."
|
699 |
|
700 |
msgid "Enable to track posts in feeds via tracking pixel."
|
701 |
+
msgstr "Aktivieren, um Beiträge im Feed via Tracking-Pixel zu zählen."
|
702 |
|
703 |
msgid "Enable to track users on admin pages (remember to configure the tracking filter appropriately)."
|
704 |
msgstr "Aktivieren, um Nutzer auf Admin-Seiten zu zählen (bitte den Tracking Filter entsprechend konfigurieren)."
|
764 |
msgstr "Besucher über alle alternative URLs aufzeichnen"
|
765 |
|
766 |
msgid "Adds *.-prefix to tracked domain."
|
767 |
+
msgstr "Fügt ein *.-Präfix zur getrackten Domain hinzu."
|
768 |
+
|
769 |
+
msgid "Add new file types for download tracking"
|
770 |
+
msgstr "Neue Dateitypen für das Download-Tracking hinzufügen"
|
771 |
+
|
772 |
+
msgid "Add file extensions for download tracking, divided by a vertical bar (|), see"
|
773 |
+
msgstr "Füge weitere Dateiendungen getrennt durch einen senkrechten Strich (|) für das Download-Tracking hinzu, siehe"
|
774 |
+
|
775 |
+
msgid "Force Piwik to use a specific protocol"
|
776 |
+
msgstr "Zwinge Piwik ein konkretes Protokoll zu verwenden"
|
777 |
+
|
778 |
+
msgid "Disabled (default)"
|
779 |
+
msgstr "Deaktiviert (Standard)"
|
780 |
+
|
781 |
+
msgid "Choose if you want to explicitly force Piwik to use HTTP or HTTPS. Does not work with a CDN URL."
|
782 |
+
msgstr "Auswählen, um Piwik ausdrücklich dazu zu zwingen, HTTP oder HTTPS zu verwenden. Funktioniert nicht mit einer CDN URL."
|
783 |
+
|
784 |
+
msgid "To use this plugin you will need your own Piwik instance. If you do not already have a Piwik setup, you have two simple options: use either <a href='%s'>Self-hosted</a> or <a href='%s'>Cloud-hosted</a>."
|
785 |
+
msgstr "Um dieses Plugin zu nutzen, wird eine Piwik-Instanz benötigt. Sofern Du über keine verfügst, hast Du zwei einfache Möglichkeiten: entweder Du <a href='%s'>hostest Piwik selbst</a> oder Du <a href='%s'>verwendest die Cloud</a>."
|
languages/wp-piwik.pot
ADDED
@@ -0,0 +1,1105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: WP-Piwik\n"
|
4 |
+
"POT-Creation-Date: 2015-04-08 23:28+0100\n"
|
5 |
+
"PO-Revision-Date: 2015-04-08 23:28+0100\n"
|
6 |
+
"Last-Translator: \n"
|
7 |
+
"Language-Team: \n"
|
8 |
+
"Language: en\n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
|
13 |
+
#: wp-piwik/classes/WP_Piwik.php:126
|
14 |
+
#: wp-piwik/wp-piwik.php:174
|
15 |
+
#, php-format
|
16 |
+
msgid "%s %s installed."
|
17 |
+
msgstr ""
|
18 |
+
|
19 |
+
#: wp-piwik/classes/WP_Piwik.php:128
|
20 |
+
#: wp-piwik/wp-piwik.php:176
|
21 |
+
msgid "Next you should connect to Piwik"
|
22 |
+
msgstr ""
|
23 |
+
|
24 |
+
#: wp-piwik/classes/WP_Piwik.php:129
|
25 |
+
#: wp-piwik/wp-piwik.php:177
|
26 |
+
msgid "Please validate your configuration"
|
27 |
+
msgstr ""
|
28 |
+
|
29 |
+
#: wp-piwik/classes/WP_Piwik.php:131
|
30 |
+
#: wp-piwik/classes/WP_Piwik.php:529
|
31 |
+
#: wp-piwik/classes/WP_Piwik.php:1234
|
32 |
+
#: wp-piwik/wp-piwik.php:179
|
33 |
+
#: wp-piwik/wp-piwik.php:577
|
34 |
+
#: wp-piwik/wp-piwik.php:1300
|
35 |
+
msgid "Settings"
|
36 |
+
msgstr ""
|
37 |
+
|
38 |
+
#: wp-piwik/classes/WP_Piwik.php:132
|
39 |
+
#: wp-piwik/wp-piwik.php:180
|
40 |
+
msgid "Important"
|
41 |
+
msgstr ""
|
42 |
+
|
43 |
+
#: wp-piwik/classes/WP_Piwik.php:260
|
44 |
+
#: wp-piwik/wp-piwik.php:308
|
45 |
+
msgid "Piwik Custom Variables"
|
46 |
+
msgstr ""
|
47 |
+
|
48 |
+
#: wp-piwik/classes/WP_Piwik.php:274
|
49 |
+
#: wp-piwik/wp-piwik.php:322
|
50 |
+
msgid "Name"
|
51 |
+
msgstr ""
|
52 |
+
|
53 |
+
#: wp-piwik/classes/WP_Piwik.php:274
|
54 |
+
#: wp-piwik/wp-piwik.php:322
|
55 |
+
msgid "Value"
|
56 |
+
msgstr ""
|
57 |
+
|
58 |
+
#: wp-piwik/classes/WP_Piwik.php:283
|
59 |
+
#: wp-piwik/wp-piwik.php:331
|
60 |
+
msgid "Set custom variables for a page view"
|
61 |
+
msgstr ""
|
62 |
+
|
63 |
+
#: wp-piwik/classes/WP_Piwik.php:283
|
64 |
+
#: wp-piwik/wp-piwik.php:331
|
65 |
+
msgid "More information"
|
66 |
+
msgstr ""
|
67 |
+
|
68 |
+
#: wp-piwik/classes/WP_Piwik.php:328
|
69 |
+
#: wp-piwik/classes/WP_Piwik.php:369
|
70 |
+
#: wp-piwik/wp-piwik.php:376
|
71 |
+
#: wp-piwik/wp-piwik.php:417
|
72 |
+
msgid "Piwik Statistics"
|
73 |
+
msgstr ""
|
74 |
+
|
75 |
+
#: wp-piwik/classes/WP_Piwik.php:487
|
76 |
+
#: wp-piwik/classes/WP_Piwik.php:966
|
77 |
+
#: wp-piwik/classes/WP_Piwik_MetaBox_PerPost_Stats.php:30
|
78 |
+
#: wp-piwik/dashboard/overview.php:56
|
79 |
+
#: wp-piwik/shortcodes/overview.php:40
|
80 |
+
#: wp-piwik/wp-piwik.php:535
|
81 |
+
#: wp-piwik/wp-piwik.php:1028
|
82 |
+
msgid "Visitors"
|
83 |
+
msgstr ""
|
84 |
+
|
85 |
+
#: wp-piwik/classes/WP_Piwik.php:507
|
86 |
+
#: wp-piwik/classes/WP_Piwik.php:957
|
87 |
+
#: wp-piwik/dashboard/seo.php:20
|
88 |
+
#: wp-piwik/wp-piwik.php:555
|
89 |
+
#: wp-piwik/wp-piwik.php:1019
|
90 |
+
msgid "SEO"
|
91 |
+
msgstr ""
|
92 |
+
|
93 |
+
#: wp-piwik/classes/WP_Piwik.php:707
|
94 |
+
#: wp-piwik/wp-piwik.php:756
|
95 |
+
msgid "Could not resolve"
|
96 |
+
msgstr ""
|
97 |
+
|
98 |
+
#: wp-piwik/classes/WP_Piwik.php:707
|
99 |
+
#: wp-piwik/wp-piwik.php:756
|
100 |
+
msgid "realpath() returns false"
|
101 |
+
msgstr ""
|
102 |
+
|
103 |
+
#: wp-piwik/classes/WP_Piwik.php:714
|
104 |
+
#: wp-piwik/wp-piwik.php:763
|
105 |
+
msgid "Class Piwik\\FrontController does not exists."
|
106 |
+
msgstr ""
|
107 |
+
|
108 |
+
#: wp-piwik/classes/WP_Piwik.php:717
|
109 |
+
#: wp-piwik/wp-piwik.php:766
|
110 |
+
msgid "Class Piwik\\API\\Request does not exists."
|
111 |
+
msgstr ""
|
112 |
+
|
113 |
+
#: wp-piwik/classes/WP_Piwik.php:956
|
114 |
+
#: wp-piwik/dashboard/overview.php:23
|
115 |
+
#: wp-piwik/shortcodes/overview.php:11
|
116 |
+
#: wp-piwik/wp-piwik.php:1018
|
117 |
+
msgid "Overview"
|
118 |
+
msgstr ""
|
119 |
+
|
120 |
+
#: wp-piwik/classes/WP_Piwik.php:958
|
121 |
+
#: wp-piwik/dashboard/pages.php:13
|
122 |
+
#: wp-piwik/wp-piwik.php:1020
|
123 |
+
msgid "Pages"
|
124 |
+
msgstr ""
|
125 |
+
|
126 |
+
#: wp-piwik/classes/WP_Piwik.php:959
|
127 |
+
#: wp-piwik/dashboard/keywords.php:12
|
128 |
+
#: wp-piwik/wp-piwik.php:1021
|
129 |
+
msgid "Keywords"
|
130 |
+
msgstr ""
|
131 |
+
|
132 |
+
#: wp-piwik/classes/WP_Piwik.php:960
|
133 |
+
#: wp-piwik/dashboard/websites.php:12
|
134 |
+
#: wp-piwik/wp-piwik.php:1022
|
135 |
+
msgid "Websites"
|
136 |
+
msgstr ""
|
137 |
+
|
138 |
+
#: wp-piwik/classes/WP_Piwik.php:961
|
139 |
+
#: wp-piwik/dashboard/plugins.php:12
|
140 |
+
#: wp-piwik/dashboard/plugins.php:33
|
141 |
+
#: wp-piwik/wp-piwik.php:1023
|
142 |
+
msgid "Plugins"
|
143 |
+
msgstr ""
|
144 |
+
|
145 |
+
#: wp-piwik/classes/WP_Piwik.php:962
|
146 |
+
#: wp-piwik/dashboard/search.php:12
|
147 |
+
#: wp-piwik/wp-piwik.php:1024
|
148 |
+
msgid "Site Search Keywords"
|
149 |
+
msgstr ""
|
150 |
+
|
151 |
+
#: wp-piwik/classes/WP_Piwik.php:963
|
152 |
+
#: wp-piwik/dashboard/noresult.php:12
|
153 |
+
#: wp-piwik/wp-piwik.php:1025
|
154 |
+
msgid "Site Search without Results"
|
155 |
+
msgstr ""
|
156 |
+
|
157 |
+
#: wp-piwik/classes/WP_Piwik.php:967
|
158 |
+
#: wp-piwik/dashboard/browserdetails.php:39
|
159 |
+
#: wp-piwik/dashboard/browsers.php:13
|
160 |
+
#: wp-piwik/dashboard/browsers.php:40
|
161 |
+
#: wp-piwik/wp-piwik.php:1029
|
162 |
+
msgid "Browser"
|
163 |
+
msgstr ""
|
164 |
+
|
165 |
+
#: wp-piwik/classes/WP_Piwik.php:968
|
166 |
+
#: wp-piwik/dashboard/browserdetails.php:12
|
167 |
+
#: wp-piwik/wp-piwik.php:1030
|
168 |
+
msgid "Browser Details"
|
169 |
+
msgstr ""
|
170 |
+
|
171 |
+
#: wp-piwik/classes/WP_Piwik.php:969
|
172 |
+
#: wp-piwik/dashboard/screens.php:12
|
173 |
+
#: wp-piwik/dashboard/screens.php:39
|
174 |
+
#: wp-piwik/wp-piwik.php:1031
|
175 |
+
msgid "Resolution"
|
176 |
+
msgstr ""
|
177 |
+
|
178 |
+
#: wp-piwik/classes/WP_Piwik.php:970
|
179 |
+
#: wp-piwik/dashboard/systems.php:12
|
180 |
+
#: wp-piwik/dashboard/systems.php:40
|
181 |
+
#: wp-piwik/wp-piwik.php:1032
|
182 |
+
msgid "Operating System"
|
183 |
+
msgstr ""
|
184 |
+
|
185 |
+
#: wp-piwik/classes/WP_Piwik.php:1042
|
186 |
+
#: wp-piwik/classes/WP_Piwik.php:1116
|
187 |
+
#: wp-piwik/wp-piwik.php:1104
|
188 |
+
#: wp-piwik/wp-piwik.php:1178
|
189 |
+
msgid "Statistics"
|
190 |
+
msgstr ""
|
191 |
+
|
192 |
+
#: wp-piwik/classes/WP_Piwik.php:1052
|
193 |
+
#: wp-piwik/wp-piwik.php:1114
|
194 |
+
msgid "Currently shown stats:"
|
195 |
+
msgstr ""
|
196 |
+
|
197 |
+
#: wp-piwik/classes/WP_Piwik.php:1099
|
198 |
+
#: wp-piwik/wp-piwik.php:1161
|
199 |
+
msgid "Cheatin’ uh?"
|
200 |
+
msgstr ""
|
201 |
+
|
202 |
+
#: wp-piwik/classes/WP_Piwik.php:1113
|
203 |
+
#: wp-piwik/wp-piwik.php:1175
|
204 |
+
msgid "Home"
|
205 |
+
msgstr ""
|
206 |
+
|
207 |
+
#: wp-piwik/classes/WP_Piwik.php:1114
|
208 |
+
#: wp-piwik/classes/WP_Piwik.php:1120
|
209 |
+
#: wp-piwik/wp-piwik.php:1176
|
210 |
+
#: wp-piwik/wp-piwik.php:1182
|
211 |
+
msgid "Piwik Settings"
|
212 |
+
msgstr ""
|
213 |
+
|
214 |
+
#: wp-piwik/classes/WP_Piwik.php:1115
|
215 |
+
#: wp-piwik/wp-piwik.php:1177
|
216 |
+
msgid "Tracking"
|
217 |
+
msgstr ""
|
218 |
+
|
219 |
+
#: wp-piwik/classes/WP_Piwik.php:1117
|
220 |
+
#: wp-piwik/classes/WP_Piwik.php:1121
|
221 |
+
#: wp-piwik/classes/WP_Piwik.php:1293
|
222 |
+
#: wp-piwik/wp-piwik.php:1179
|
223 |
+
#: wp-piwik/wp-piwik.php:1183
|
224 |
+
#: wp-piwik/wp-piwik.php:1372
|
225 |
+
msgid "Support"
|
226 |
+
msgstr ""
|
227 |
+
|
228 |
+
#: wp-piwik/classes/WP_Piwik.php:1118
|
229 |
+
#: wp-piwik/classes/WP_Piwik.php:1122
|
230 |
+
#: wp-piwik/wp-piwik.php:1180
|
231 |
+
#: wp-piwik/wp-piwik.php:1184
|
232 |
+
msgid "Credits"
|
233 |
+
msgstr ""
|
234 |
+
|
235 |
+
#: wp-piwik/classes/WP_Piwik.php:1232
|
236 |
+
#: wp-piwik/wp-piwik.php:1298
|
237 |
+
msgid "Changes saved"
|
238 |
+
msgstr ""
|
239 |
+
|
240 |
+
#: wp-piwik/classes/WP_Piwik.php:1240
|
241 |
+
#: wp-piwik/wp-piwik.php:1306
|
242 |
+
msgid "Donate"
|
243 |
+
msgstr ""
|
244 |
+
|
245 |
+
#: wp-piwik/classes/WP_Piwik.php:1241
|
246 |
+
#: wp-piwik/wp-piwik.php:1307
|
247 |
+
msgid "If you like WP-Piwik, you can support its development by a donation:"
|
248 |
+
msgstr ""
|
249 |
+
|
250 |
+
#: wp-piwik/classes/WP_Piwik.php:1257
|
251 |
+
#: wp-piwik/wp-piwik.php:1336
|
252 |
+
msgid "My Amazon.de wishlist"
|
253 |
+
msgstr ""
|
254 |
+
|
255 |
+
#: wp-piwik/classes/WP_Piwik.php:1260
|
256 |
+
#: wp-piwik/settings/support.php:5
|
257 |
+
#: wp-piwik/wp-piwik.php:1339
|
258 |
+
msgid "Please don't forget to vote the compatibility at the"
|
259 |
+
msgstr ""
|
260 |
+
|
261 |
+
#: wp-piwik/classes/WP_Piwik.php:1275
|
262 |
+
#: wp-piwik/wp-piwik.php:1354
|
263 |
+
msgid "Save settings"
|
264 |
+
msgstr ""
|
265 |
+
|
266 |
+
#: wp-piwik/classes/WP_Piwik.php:1293
|
267 |
+
#: wp-piwik/wp-piwik.php:1372
|
268 |
+
msgid "An error occured"
|
269 |
+
msgstr ""
|
270 |
+
|
271 |
+
#: wp-piwik/classes/WP_Piwik_MetaBox_PerPost_Stats.php:10
|
272 |
+
msgid "Piwik Statistics (last 30 days)"
|
273 |
+
msgstr ""
|
274 |
+
|
275 |
+
#: wp-piwik/classes/WP_Piwik_MetaBox_PerPost_Stats.php:31
|
276 |
+
#: wp-piwik/dashboard/overview.php:57
|
277 |
+
#: wp-piwik/shortcodes/overview.php:41
|
278 |
+
msgid "Unique visitors"
|
279 |
+
msgstr ""
|
280 |
+
|
281 |
+
#: wp-piwik/classes/WP_Piwik_MetaBox_PerPost_Stats.php:32
|
282 |
+
#: wp-piwik/dashboard/overview.php:58
|
283 |
+
#: wp-piwik/shortcodes/overview.php:42
|
284 |
+
msgid "Page views"
|
285 |
+
msgstr ""
|
286 |
+
|
287 |
+
#: wp-piwik/classes/WP_Piwik_MetaBox_PerPost_Stats.php:33
|
288 |
+
#: wp-piwik/dashboard/overview.php:61
|
289 |
+
#: wp-piwik/shortcodes/overview.php:45
|
290 |
+
msgid "Time/visit"
|
291 |
+
msgstr ""
|
292 |
+
|
293 |
+
#: wp-piwik/classes/WP_Piwik_MetaBox_PerPost_Stats.php:34
|
294 |
+
#: wp-piwik/dashboard/overview.php:62
|
295 |
+
#: wp-piwik/shortcodes/overview.php:46
|
296 |
+
msgid "Bounce count"
|
297 |
+
msgstr ""
|
298 |
+
|
299 |
+
#: wp-piwik/classes/WP_Piwik_MetaBox_PerPost_Stats.php:35
|
300 |
+
msgid "Exit count"
|
301 |
+
msgstr ""
|
302 |
+
|
303 |
+
#: wp-piwik/classes/WP_Piwik_MetaBox_PerPost_Stats.php:37
|
304 |
+
msgid "Avg. generation time"
|
305 |
+
msgstr ""
|
306 |
+
|
307 |
+
#: wp-piwik/dashboard/browserdetails.php:16
|
308 |
+
#: wp-piwik/dashboard/browsers.php:17
|
309 |
+
#: wp-piwik/dashboard/keywords.php:14
|
310 |
+
#: wp-piwik/dashboard/noresult.php:14
|
311 |
+
#: wp-piwik/dashboard/overview.php:26
|
312 |
+
#: wp-piwik/dashboard/pages.php:16
|
313 |
+
#: wp-piwik/dashboard/plugins.php:26
|
314 |
+
#: wp-piwik/dashboard/screens.php:16
|
315 |
+
#: wp-piwik/dashboard/search.php:14
|
316 |
+
#: wp-piwik/dashboard/seo.php:17
|
317 |
+
#: wp-piwik/dashboard/systems.php:16
|
318 |
+
#: wp-piwik/dashboard/visitors.php:32
|
319 |
+
#: wp-piwik/dashboard/websites.php:15
|
320 |
+
msgid "Piwik error"
|
321 |
+
msgstr ""
|
322 |
+
|
323 |
+
#: wp-piwik/dashboard/browserdetails.php:25
|
324 |
+
#: wp-piwik/dashboard/browsers.php:26
|
325 |
+
#: wp-piwik/dashboard/pages.php:45
|
326 |
+
#: wp-piwik/dashboard/screens.php:25
|
327 |
+
#: wp-piwik/dashboard/systems.php:25
|
328 |
+
msgid "Others"
|
329 |
+
msgstr ""
|
330 |
+
|
331 |
+
#: wp-piwik/dashboard/browserdetails.php:40
|
332 |
+
#: wp-piwik/dashboard/browsers.php:41
|
333 |
+
#: wp-piwik/dashboard/keywords.php:19
|
334 |
+
#: wp-piwik/dashboard/pages.php:24
|
335 |
+
#: wp-piwik/dashboard/screens.php:40
|
336 |
+
#: wp-piwik/dashboard/systems.php:41
|
337 |
+
#: wp-piwik/dashboard/visitors.php:64
|
338 |
+
#: wp-piwik/dashboard/websites.php:22
|
339 |
+
msgid "Unique"
|
340 |
+
msgstr ""
|
341 |
+
|
342 |
+
#: wp-piwik/dashboard/browserdetails.php:41
|
343 |
+
#: wp-piwik/dashboard/browsers.php:42
|
344 |
+
#: wp-piwik/dashboard/plugins.php:35
|
345 |
+
#: wp-piwik/dashboard/screens.php:41
|
346 |
+
#: wp-piwik/dashboard/systems.php:42
|
347 |
+
msgid "Percent"
|
348 |
+
msgstr ""
|
349 |
+
|
350 |
+
#: wp-piwik/dashboard/browserdetails.php:55
|
351 |
+
#: wp-piwik/dashboard/browsers.php:56
|
352 |
+
#: wp-piwik/dashboard/keywords.php:25
|
353 |
+
#: wp-piwik/dashboard/noresult.php:25
|
354 |
+
#: wp-piwik/dashboard/pages.php:43
|
355 |
+
#: wp-piwik/dashboard/plugins.php:51
|
356 |
+
#: wp-piwik/dashboard/screens.php:55
|
357 |
+
#: wp-piwik/dashboard/search.php:25
|
358 |
+
#: wp-piwik/dashboard/systems.php:56
|
359 |
+
#: wp-piwik/dashboard/websites.php:29
|
360 |
+
msgid "No data available."
|
361 |
+
msgstr ""
|
362 |
+
|
363 |
+
#: wp-piwik/dashboard/keywords.php:19
|
364 |
+
#: wp-piwik/dashboard/noresult.php:19
|
365 |
+
#: wp-piwik/dashboard/search.php:19
|
366 |
+
msgid "Keyword"
|
367 |
+
msgstr ""
|
368 |
+
|
369 |
+
#: wp-piwik/dashboard/noresult.php:19
|
370 |
+
#: wp-piwik/dashboard/search.php:19
|
371 |
+
msgid "Requests"
|
372 |
+
msgstr ""
|
373 |
+
|
374 |
+
#: wp-piwik/dashboard/noresult.php:19
|
375 |
+
#: wp-piwik/dashboard/search.php:19
|
376 |
+
#: wp-piwik/dashboard/visitors.php:65
|
377 |
+
msgid "Bounced"
|
378 |
+
msgstr ""
|
379 |
+
|
380 |
+
#: wp-piwik/dashboard/overview.php:59
|
381 |
+
#: wp-piwik/shortcodes/overview.php:43
|
382 |
+
msgid "Max. page views in one visit"
|
383 |
+
msgstr ""
|
384 |
+
|
385 |
+
#: wp-piwik/dashboard/overview.php:60
|
386 |
+
#: wp-piwik/shortcodes/overview.php:44
|
387 |
+
msgid "Total time spent"
|
388 |
+
msgstr ""
|
389 |
+
|
390 |
+
#: wp-piwik/dashboard/overview.php:64
|
391 |
+
#: wp-piwik/settings/views.php:40
|
392 |
+
msgid "Shortcut"
|
393 |
+
msgstr ""
|
394 |
+
|
395 |
+
#: wp-piwik/dashboard/pages.php:23
|
396 |
+
msgid "Page"
|
397 |
+
msgstr ""
|
398 |
+
|
399 |
+
#: wp-piwik/dashboard/pages.php:25
|
400 |
+
#: wp-piwik/dashboard/plugins.php:34
|
401 |
+
#: wp-piwik/dashboard/visitors.php:63
|
402 |
+
msgid "Visits"
|
403 |
+
msgstr ""
|
404 |
+
|
405 |
+
#: wp-piwik/dashboard/visitors.php:54
|
406 |
+
msgid ""
|
407 |
+
"The graph contains the values shown in the table below (visitors / unique / "
|
408 |
+
"bounces). The red line show a linear trendline (unique)."
|
409 |
+
msgstr ""
|
410 |
+
|
411 |
+
#: wp-piwik/dashboard/visitors.php:62
|
412 |
+
msgid "Date"
|
413 |
+
msgstr ""
|
414 |
+
|
415 |
+
#: wp-piwik/dashboard/visitors.php:66
|
416 |
+
msgid "Page Views"
|
417 |
+
msgstr ""
|
418 |
+
|
419 |
+
#: wp-piwik/dashboard/visitors.php:83
|
420 |
+
msgid "Unique TOTAL"
|
421 |
+
msgstr ""
|
422 |
+
|
423 |
+
#: wp-piwik/dashboard/visitors.php:83
|
424 |
+
msgid "Sum"
|
425 |
+
msgstr ""
|
426 |
+
|
427 |
+
#: wp-piwik/dashboard/visitors.php:83
|
428 |
+
msgid "Avg"
|
429 |
+
msgstr ""
|
430 |
+
|
431 |
+
#: wp-piwik/dashboard/websites.php:21
|
432 |
+
msgid "Website"
|
433 |
+
msgstr ""
|
434 |
+
|
435 |
+
#: wp-piwik/settings/credits.php:3
|
436 |
+
msgid "Thank you very much for your donation"
|
437 |
+
msgstr ""
|
438 |
+
|
439 |
+
#: wp-piwik/settings/credits.php:3
|
440 |
+
msgid "the Piwik team itself"
|
441 |
+
msgstr ""
|
442 |
+
|
443 |
+
#: wp-piwik/settings/credits.php:3
|
444 |
+
msgid ", and all people flattering this"
|
445 |
+
msgstr ""
|
446 |
+
|
447 |
+
#: wp-piwik/settings/credits.php:8
|
448 |
+
msgid ""
|
449 |
+
"Graphs powered by <a href=\"http://www.jqplot.com/\">jqPlot</a> (License: "
|
450 |
+
"GPL 2.0 and MIT) and <a href=\"http://omnipotent.net/jquery.sparkline/"
|
451 |
+
"\">jQuery Sparklines</a> (License: New BSD License)."
|
452 |
+
msgstr ""
|
453 |
+
|
454 |
+
#: wp-piwik/settings/credits.php:13
|
455 |
+
msgid "Metabox support inspired by"
|
456 |
+
msgstr ""
|
457 |
+
|
458 |
+
#: wp-piwik/settings/credits.php:14
|
459 |
+
msgid "Tabbed settings page suggested by the"
|
460 |
+
msgstr ""
|
461 |
+
|
462 |
+
#: wp-piwik/settings/credits.php:19
|
463 |
+
msgid "Thank you very much"
|
464 |
+
msgstr ""
|
465 |
+
|
466 |
+
#: wp-piwik/settings/credits.php:19
|
467 |
+
msgid ", and"
|
468 |
+
msgstr ""
|
469 |
+
|
470 |
+
#: wp-piwik/settings/credits.php:19
|
471 |
+
msgid "for your translation work"
|
472 |
+
msgstr ""
|
473 |
+
|
474 |
+
#: wp-piwik/settings/credits.php:24
|
475 |
+
msgid ""
|
476 |
+
"Thank you very much, all users who send me mails containing criticism, "
|
477 |
+
"commendation, feature requests and bug reports! You help me to make WP-Piwik "
|
478 |
+
"much better."
|
479 |
+
msgstr ""
|
480 |
+
|
481 |
+
#: wp-piwik/settings/credits.php:29
|
482 |
+
msgid ""
|
483 |
+
"Thank <strong>you</strong> for using my plugin. It is the best commendation "
|
484 |
+
"if my piece of code is really used!"
|
485 |
+
msgstr ""
|
486 |
+
|
487 |
+
#: wp-piwik/settings/homepage.php:4
|
488 |
+
msgid "Thanks for using WP-Piwik!"
|
489 |
+
msgstr ""
|
490 |
+
|
491 |
+
#: wp-piwik/settings/homepage.php:8
|
492 |
+
msgid "You are using Piwik"
|
493 |
+
msgstr ""
|
494 |
+
|
495 |
+
#: wp-piwik/settings/homepage.php:8
|
496 |
+
msgid "and"
|
497 |
+
msgstr ""
|
498 |
+
|
499 |
+
#: wp-piwik/settings/homepage.php:8
|
500 |
+
msgid "in network mode"
|
501 |
+
msgstr ""
|
502 |
+
|
503 |
+
#: wp-piwik/settings/homepage.php:10
|
504 |
+
msgid "Auto site configuration is"
|
505 |
+
msgstr ""
|
506 |
+
|
507 |
+
#: wp-piwik/settings/homepage.php:10
|
508 |
+
#: wp-piwik/settings/homepage.php:11
|
509 |
+
#: wp-piwik/settings/support.php:20
|
510 |
+
msgid "enabled"
|
511 |
+
msgstr ""
|
512 |
+
|
513 |
+
#: wp-piwik/settings/homepage.php:10
|
514 |
+
#: wp-piwik/settings/homepage.php:11
|
515 |
+
msgid "disabled"
|
516 |
+
msgstr ""
|
517 |
+
|
518 |
+
#: wp-piwik/settings/homepage.php:11
|
519 |
+
msgid "Tracking code insertion is"
|
520 |
+
msgstr ""
|
521 |
+
|
522 |
+
#: wp-piwik/settings/piwik.php:7
|
523 |
+
#: wp-piwik/settings/sitebrowser.php:7
|
524 |
+
#: wp-piwik/settings/tracking.php:7
|
525 |
+
#: wp-piwik/settings/views.php:7
|
526 |
+
msgid ""
|
527 |
+
"Error: cURL is not enabled and fopen is not allowed to open URLs. WP-Piwik "
|
528 |
+
"won't be able to connect to Piwik."
|
529 |
+
msgstr ""
|
530 |
+
|
531 |
+
#: wp-piwik/settings/piwik.php:11
|
532 |
+
#, php-format
|
533 |
+
msgid ""
|
534 |
+
"To use this plugin you will need your own Piwik instance. If you do not "
|
535 |
+
"already have a Piwik setup, you have two simple options: use either <a "
|
536 |
+
"href='%s'>Self-hosted</a> or <a href='%s'>Cloud-hosted</a>."
|
537 |
+
msgstr ""
|
538 |
+
|
539 |
+
#: wp-piwik/settings/piwik.php:16
|
540 |
+
msgid "To enable Piwik statistics, please enter"
|
541 |
+
msgstr ""
|
542 |
+
|
543 |
+
#: wp-piwik/settings/piwik.php:18
|
544 |
+
msgid ""
|
545 |
+
"your Piwik base URL (like http://mydomain.com/piwik) or your Piwik server "
|
546 |
+
"path (like /var/www/mydomain.com/httpdocs/piwik/)"
|
547 |
+
msgstr ""
|
548 |
+
|
549 |
+
#: wp-piwik/settings/piwik.php:19
|
550 |
+
msgid ""
|
551 |
+
"your personal Piwik authentification token. You can get the token on the API "
|
552 |
+
"page inside your Piwik interface. It looks like "
|
553 |
+
""1234a5cd6789e0a12345b678cd9012ef"."
|
554 |
+
msgstr ""
|
555 |
+
|
556 |
+
#: wp-piwik/settings/piwik.php:21
|
557 |
+
msgid "No idea what I'm talking about?"
|
558 |
+
msgstr ""
|
559 |
+
|
560 |
+
#: wp-piwik/settings/piwik.php:21
|
561 |
+
msgid "Get help."
|
562 |
+
msgstr ""
|
563 |
+
|
564 |
+
#: wp-piwik/settings/piwik.php:23
|
565 |
+
msgid ""
|
566 |
+
"<strong>Important note:</strong> If you do not host this blog on your own, "
|
567 |
+
"your site admin is able to get your auth token from the database."
|
568 |
+
msgstr ""
|
569 |
+
|
570 |
+
#: wp-piwik/settings/piwik.php:27
|
571 |
+
msgid "Piwik URL"
|
572 |
+
msgstr ""
|
573 |
+
|
574 |
+
#: wp-piwik/settings/piwik.php:33
|
575 |
+
msgid "Piwik path"
|
576 |
+
msgstr ""
|
577 |
+
|
578 |
+
#: wp-piwik/settings/piwik.php:39
|
579 |
+
msgid "Invalid path. Please enter the file path to Piwik."
|
580 |
+
msgstr ""
|
581 |
+
|
582 |
+
#: wp-piwik/settings/piwik.php:43
|
583 |
+
msgid "Auth token"
|
584 |
+
msgstr ""
|
585 |
+
|
586 |
+
#: wp-piwik/settings/piwik.php:48
|
587 |
+
msgid "Enable cache"
|
588 |
+
msgstr ""
|
589 |
+
|
590 |
+
#: wp-piwik/settings/piwik.php:50
|
591 |
+
msgid "Cache API calls, which not contain today's values, for a week"
|
592 |
+
msgstr ""
|
593 |
+
|
594 |
+
#: wp-piwik/settings/piwik.php:54
|
595 |
+
msgid "Auto config"
|
596 |
+
msgstr ""
|
597 |
+
|
598 |
+
#: wp-piwik/settings/piwik.php:57
|
599 |
+
msgid ""
|
600 |
+
"Check this to automatically choose your blog from your Piwik sites by URL. "
|
601 |
+
"If your blog is not added to Piwik yet, WP-Piwik will add a new site."
|
602 |
+
msgstr ""
|
603 |
+
|
604 |
+
#: wp-piwik/settings/piwik.php:65
|
605 |
+
msgid ""
|
606 |
+
"Please check URL and auth token. You need at least view access to one site."
|
607 |
+
msgstr ""
|
608 |
+
|
609 |
+
#: wp-piwik/settings/piwik.php:73
|
610 |
+
msgid "Choose site"
|
611 |
+
msgstr ""
|
612 |
+
|
613 |
+
#: wp-piwik/settings/piwik.php:87
|
614 |
+
msgid "Determined site"
|
615 |
+
msgstr ""
|
616 |
+
|
617 |
+
#: wp-piwik/settings/piwik.php:100
|
618 |
+
msgid "Expert Settings"
|
619 |
+
msgstr ""
|
620 |
+
|
621 |
+
#: wp-piwik/settings/piwik.php:102
|
622 |
+
msgid "Connection timeout"
|
623 |
+
msgstr ""
|
624 |
+
|
625 |
+
#: wp-piwik/settings/piwik.php:109
|
626 |
+
msgid "Disable SSL peer verification"
|
627 |
+
msgstr ""
|
628 |
+
|
629 |
+
#: wp-piwik/settings/piwik.php:111
|
630 |
+
msgid "not recommended"
|
631 |
+
msgstr ""
|
632 |
+
|
633 |
+
#: wp-piwik/settings/piwik.php:114
|
634 |
+
msgid "User agent"
|
635 |
+
msgstr ""
|
636 |
+
|
637 |
+
#: wp-piwik/settings/piwik.php:126
|
638 |
+
msgid ""
|
639 |
+
"Further expert settings require cURL. See <a href=\"http://www.php.net/"
|
640 |
+
"manual/curl.setup.php\">PHP manual</a>"
|
641 |
+
msgstr ""
|
642 |
+
|
643 |
+
#: wp-piwik/settings/sitebrowser.php:26
|
644 |
+
msgid "ID"
|
645 |
+
msgstr ""
|
646 |
+
|
647 |
+
#: wp-piwik/settings/sitebrowser.php:27
|
648 |
+
msgid "Title"
|
649 |
+
msgstr ""
|
650 |
+
|
651 |
+
#: wp-piwik/settings/sitebrowser.php:28
|
652 |
+
msgid "URL"
|
653 |
+
msgstr ""
|
654 |
+
|
655 |
+
#: wp-piwik/settings/sitebrowser.php:29
|
656 |
+
msgid "Site ID (Piwik)"
|
657 |
+
msgstr ""
|
658 |
+
|
659 |
+
#: wp-piwik/settings/support.php:2
|
660 |
+
msgid "WordPress.org forum about WP-Piwik"
|
661 |
+
msgstr ""
|
662 |
+
|
663 |
+
#: wp-piwik/settings/support.php:9
|
664 |
+
msgid "Debugging"
|
665 |
+
msgstr ""
|
666 |
+
|
667 |
+
#: wp-piwik/settings/support.php:10
|
668 |
+
msgid ""
|
669 |
+
"Either allow_url_fopen has to be enabled <em>or</em> cURL has to be "
|
670 |
+
"available:"
|
671 |
+
msgstr ""
|
672 |
+
|
673 |
+
#: wp-piwik/settings/support.php:13
|
674 |
+
msgid "cURL is"
|
675 |
+
msgstr ""
|
676 |
+
|
677 |
+
#: wp-piwik/settings/support.php:14
|
678 |
+
#: wp-piwik/settings/support.php:19
|
679 |
+
msgid "not"
|
680 |
+
msgstr ""
|
681 |
+
|
682 |
+
#: wp-piwik/settings/support.php:15
|
683 |
+
msgid "available"
|
684 |
+
msgstr ""
|
685 |
+
|
686 |
+
#: wp-piwik/settings/support.php:18
|
687 |
+
msgid "allow_url_fopen is"
|
688 |
+
msgstr ""
|
689 |
+
|
690 |
+
#: wp-piwik/settings/support.php:28
|
691 |
+
msgid "Test script result"
|
692 |
+
msgstr ""
|
693 |
+
|
694 |
+
#: wp-piwik/settings/support.php:32
|
695 |
+
msgid "Please confirm your reset request"
|
696 |
+
msgstr ""
|
697 |
+
|
698 |
+
#: wp-piwik/settings/support.php:32
|
699 |
+
msgid ""
|
700 |
+
"YES, please reset <strong>all</strong> WP-Piwik settings <strong>except</"
|
701 |
+
"strong> auth token and Piwi URL."
|
702 |
+
msgstr ""
|
703 |
+
|
704 |
+
#: wp-piwik/settings/support.php:38
|
705 |
+
msgid "WP-Piwik reset done"
|
706 |
+
msgstr ""
|
707 |
+
|
708 |
+
#: wp-piwik/settings/support.php:43
|
709 |
+
msgid "Get more debug information"
|
710 |
+
msgstr ""
|
711 |
+
|
712 |
+
#: wp-piwik/settings/support.php:45
|
713 |
+
msgid "Run test script"
|
714 |
+
msgstr ""
|
715 |
+
|
716 |
+
#: wp-piwik/settings/support.php:46
|
717 |
+
msgid "Get site configuration details"
|
718 |
+
msgstr ""
|
719 |
+
|
720 |
+
#: wp-piwik/settings/support.php:47
|
721 |
+
msgid "Reset WP-Piwik settings except auth token and Piwik URL"
|
722 |
+
msgstr ""
|
723 |
+
|
724 |
+
#: wp-piwik/settings/support.php:47
|
725 |
+
msgid ""
|
726 |
+
"This will not affect Piwik itself. Resetting large networks may take some "
|
727 |
+
"minutes."
|
728 |
+
msgstr ""
|
729 |
+
|
730 |
+
#: wp-piwik/settings/support.php:49
|
731 |
+
msgid ""
|
732 |
+
"You have to enter your auth token and the Piwik URL before you can access "
|
733 |
+
"more debug functions."
|
734 |
+
msgstr ""
|
735 |
+
|
736 |
+
#: wp-piwik/settings/support.php:52
|
737 |
+
msgid "Latest support threads on WordPress.org"
|
738 |
+
msgstr ""
|
739 |
+
|
740 |
+
#: wp-piwik/settings/tracking.php:10
|
741 |
+
msgid "Add tracking code"
|
742 |
+
msgstr ""
|
743 |
+
|
744 |
+
#: wp-piwik/settings/tracking.php:14
|
745 |
+
msgid ""
|
746 |
+
"If your template uses wp_footer(), WP-Piwik can automatically add the Piwik "
|
747 |
+
"javascript code to your blog."
|
748 |
+
msgstr ""
|
749 |
+
|
750 |
+
#: wp-piwik/settings/tracking.php:31
|
751 |
+
msgid "Tracking code preview"
|
752 |
+
msgstr ""
|
753 |
+
|
754 |
+
#: wp-piwik/settings/tracking.php:37
|
755 |
+
msgid "<noscript> code preview"
|
756 |
+
msgstr ""
|
757 |
+
|
758 |
+
#: wp-piwik/settings/tracking.php:43
|
759 |
+
msgid "Default tracking"
|
760 |
+
msgstr ""
|
761 |
+
|
762 |
+
#: wp-piwik/settings/tracking.php:45
|
763 |
+
msgid "WP-Piwik uses the Piwik default tracking code."
|
764 |
+
msgstr ""
|
765 |
+
|
766 |
+
#: wp-piwik/settings/tracking.php:48
|
767 |
+
msgid "Use js/index.php"
|
768 |
+
msgstr ""
|
769 |
+
|
770 |
+
#: wp-piwik/settings/tracking.php:50
|
771 |
+
msgid ""
|
772 |
+
"WP-Piwik can automatically use js/index.php instead of piwik.js and piwik."
|
773 |
+
"php. See"
|
774 |
+
msgstr ""
|
775 |
+
|
776 |
+
#: wp-piwik/settings/tracking.php:53
|
777 |
+
msgid "Use proxy script"
|
778 |
+
msgstr ""
|
779 |
+
|
780 |
+
#: wp-piwik/settings/tracking.php:55
|
781 |
+
msgid "WP-Piwik will use the piwik.php proxy script. See"
|
782 |
+
msgstr ""
|
783 |
+
|
784 |
+
#: wp-piwik/settings/tracking.php:58
|
785 |
+
msgid "JavaScript code position"
|
786 |
+
msgstr ""
|
787 |
+
|
788 |
+
#: wp-piwik/settings/tracking.php:60
|
789 |
+
msgid "Footer"
|
790 |
+
msgstr ""
|
791 |
+
|
792 |
+
#: wp-piwik/settings/tracking.php:61
|
793 |
+
msgid "Header"
|
794 |
+
msgstr ""
|
795 |
+
|
796 |
+
#: wp-piwik/settings/tracking.php:63
|
797 |
+
msgid ""
|
798 |
+
"Choose whether the JavaScript code is added to the footer or the header."
|
799 |
+
msgstr ""
|
800 |
+
|
801 |
+
#: wp-piwik/settings/tracking.php:66
|
802 |
+
msgid "Add <noscript>"
|
803 |
+
msgstr ""
|
804 |
+
|
805 |
+
#: wp-piwik/settings/tracking.php:68
|
806 |
+
msgid "Adds the <noscript> code to your footer."
|
807 |
+
msgstr ""
|
808 |
+
|
809 |
+
#: wp-piwik/settings/tracking.php:68
|
810 |
+
#: wp-piwik/settings/tracking.php:73
|
811 |
+
#: wp-piwik/settings/tracking.php:123
|
812 |
+
msgid "Disabled in proxy mode."
|
813 |
+
msgstr ""
|
814 |
+
|
815 |
+
#: wp-piwik/settings/tracking.php:71
|
816 |
+
msgid "Add rec parameter to noscript code"
|
817 |
+
msgstr ""
|
818 |
+
|
819 |
+
#: wp-piwik/settings/tracking.php:73
|
820 |
+
msgid "Enable tracking for visitors without JavaScript (not recommended). See"
|
821 |
+
msgstr ""
|
822 |
+
|
823 |
+
#: wp-piwik/settings/tracking.php:76
|
824 |
+
msgid "Disable cookies"
|
825 |
+
msgstr ""
|
826 |
+
|
827 |
+
#: wp-piwik/settings/tracking.php:78
|
828 |
+
msgid "Disable all tracking cookies for a visitor."
|
829 |
+
msgstr ""
|
830 |
+
|
831 |
+
#: wp-piwik/settings/tracking.php:81
|
832 |
+
msgid "Limit cookie lifetime"
|
833 |
+
msgstr ""
|
834 |
+
|
835 |
+
#: wp-piwik/settings/tracking.php:83
|
836 |
+
msgid "Limit cookie lifetime as follows"
|
837 |
+
msgstr ""
|
838 |
+
|
839 |
+
#: wp-piwik/settings/tracking.php:84
|
840 |
+
msgid "Visitor timeout (seconds)"
|
841 |
+
msgstr ""
|
842 |
+
|
843 |
+
#: wp-piwik/settings/tracking.php:84
|
844 |
+
msgid "Session timeout (seconds)"
|
845 |
+
msgstr ""
|
846 |
+
|
847 |
+
#: wp-piwik/settings/tracking.php:86
|
848 |
+
msgid "Track visitors across all subdomains"
|
849 |
+
msgstr ""
|
850 |
+
|
851 |
+
#: wp-piwik/settings/tracking.php:88
|
852 |
+
msgid "Adds *.-prefix to cookie domain."
|
853 |
+
msgstr ""
|
854 |
+
|
855 |
+
#: wp-piwik/settings/tracking.php:91
|
856 |
+
msgid "Track visitors across all alias URLs"
|
857 |
+
msgstr ""
|
858 |
+
|
859 |
+
#: wp-piwik/settings/tracking.php:93
|
860 |
+
msgid "Adds *.-prefix to tracked domain."
|
861 |
+
msgstr ""
|
862 |
+
|
863 |
+
#: wp-piwik/settings/tracking.php:96
|
864 |
+
msgid "Track search"
|
865 |
+
msgstr ""
|
866 |
+
|
867 |
+
#: wp-piwik/settings/tracking.php:98
|
868 |
+
msgid "Use Piwik's advanced Site Search Analytics feature. See"
|
869 |
+
msgstr ""
|
870 |
+
|
871 |
+
#: wp-piwik/settings/tracking.php:101
|
872 |
+
msgid "Track 404"
|
873 |
+
msgstr ""
|
874 |
+
|
875 |
+
#: wp-piwik/settings/tracking.php:103
|
876 |
+
msgid "WP-Piwik can automatically add a 404-category to track 404-page-visits."
|
877 |
+
msgstr ""
|
878 |
+
|
879 |
+
#: wp-piwik/settings/tracking.php:106
|
880 |
+
msgid "Add annotation on new post"
|
881 |
+
msgstr ""
|
882 |
+
|
883 |
+
#: wp-piwik/settings/tracking.php:108
|
884 |
+
msgid "Add a Piwik annotation on each new post, see"
|
885 |
+
msgstr ""
|
886 |
+
|
887 |
+
#: wp-piwik/settings/tracking.php:111
|
888 |
+
msgid "Add new file types for download tracking"
|
889 |
+
msgstr ""
|
890 |
+
|
891 |
+
#: wp-piwik/settings/tracking.php:113
|
892 |
+
msgid ""
|
893 |
+
"Add file extensions for download tracking, divided by a vertical bar "
|
894 |
+
"(|), see"
|
895 |
+
msgstr ""
|
896 |
+
|
897 |
+
#: wp-piwik/settings/tracking.php:116
|
898 |
+
msgid "Show custom variables box"
|
899 |
+
msgstr ""
|
900 |
+
|
901 |
+
#: wp-piwik/settings/tracking.php:118
|
902 |
+
msgid "Show a custom vars edit box on post edit page."
|
903 |
+
msgstr ""
|
904 |
+
|
905 |
+
#: wp-piwik/settings/tracking.php:121
|
906 |
+
msgid "Avoid mod_security"
|
907 |
+
msgstr ""
|
908 |
+
|
909 |
+
#: wp-piwik/settings/tracking.php:123
|
910 |
+
msgid ""
|
911 |
+
"WP-Piwik can automatically force the Tracking Code to sent data in POST. See"
|
912 |
+
msgstr ""
|
913 |
+
|
914 |
+
#: wp-piwik/settings/tracking.php:126
|
915 |
+
msgid "Add data-cfasync=false"
|
916 |
+
msgstr ""
|
917 |
+
|
918 |
+
#: wp-piwik/settings/tracking.php:128
|
919 |
+
msgid ""
|
920 |
+
"Adds data-cfasync=false to the script tag, e.g., to ask Rocket Loader to "
|
921 |
+
"ignore the script."
|
922 |
+
msgstr ""
|
923 |
+
|
924 |
+
#: wp-piwik/settings/tracking.php:131
|
925 |
+
msgid "CDN URL"
|
926 |
+
msgstr ""
|
927 |
+
|
928 |
+
#: wp-piwik/settings/tracking.php:133
|
929 |
+
msgid ""
|
930 |
+
"Leave blank if you do not want to define a CDN URL or you do not know what "
|
931 |
+
"this is."
|
932 |
+
msgstr ""
|
933 |
+
|
934 |
+
#: wp-piwik/settings/tracking.php:136
|
935 |
+
msgid "Force Piwik to use a specific protocol"
|
936 |
+
msgstr ""
|
937 |
+
|
938 |
+
#: wp-piwik/settings/tracking.php:137
|
939 |
+
msgid "Disabled (default)"
|
940 |
+
msgstr ""
|
941 |
+
|
942 |
+
#: wp-piwik/settings/tracking.php:140
|
943 |
+
msgid ""
|
944 |
+
"Choose if you want to explicitly force Piwik to use HTTP or HTTPS. Does not "
|
945 |
+
"work with a CDN URL."
|
946 |
+
msgstr ""
|
947 |
+
|
948 |
+
#: wp-piwik/settings/tracking.php:143
|
949 |
+
msgid "Track admin pages"
|
950 |
+
msgstr ""
|
951 |
+
|
952 |
+
#: wp-piwik/settings/tracking.php:145
|
953 |
+
msgid ""
|
954 |
+
"Enable to track users on admin pages (remember to configure the tracking "
|
955 |
+
"filter appropriately)."
|
956 |
+
msgstr ""
|
957 |
+
|
958 |
+
#: wp-piwik/settings/tracking.php:148
|
959 |
+
msgid "Track RSS feeds"
|
960 |
+
msgstr ""
|
961 |
+
|
962 |
+
#: wp-piwik/settings/tracking.php:150
|
963 |
+
msgid "Enable to track posts in feeds via tracking pixel."
|
964 |
+
msgstr ""
|
965 |
+
|
966 |
+
#: wp-piwik/settings/tracking.php:153
|
967 |
+
msgid "Track RSS feed links as campaign"
|
968 |
+
msgstr ""
|
969 |
+
|
970 |
+
#: wp-piwik/settings/tracking.php:155
|
971 |
+
msgid "This will add Piwik campaign parameters to the RSS feed links."
|
972 |
+
msgstr ""
|
973 |
+
|
974 |
+
#: wp-piwik/settings/tracking.php:156
|
975 |
+
msgid "Campaign"
|
976 |
+
msgstr ""
|
977 |
+
|
978 |
+
#: wp-piwik/settings/tracking.php:156
|
979 |
+
msgid "Keyword: post name."
|
980 |
+
msgstr ""
|
981 |
+
|
982 |
+
#: wp-piwik/settings/tracking.php:159
|
983 |
+
msgid "Tracking filter"
|
984 |
+
msgstr ""
|
985 |
+
|
986 |
+
#: wp-piwik/settings/tracking.php:166
|
987 |
+
msgid "Choose users by user role you do <strong>not</strong> want to track."
|
988 |
+
msgstr ""
|
989 |
+
|
990 |
+
#: wp-piwik/settings/views.php:10
|
991 |
+
msgid "WP-Piwik display name"
|
992 |
+
msgstr ""
|
993 |
+
|
994 |
+
#: wp-piwik/settings/views.php:12
|
995 |
+
msgid "Plugin name shown in WordPress."
|
996 |
+
msgstr ""
|
997 |
+
|
998 |
+
#: wp-piwik/settings/views.php:14
|
999 |
+
msgid "Default date"
|
1000 |
+
msgstr ""
|
1001 |
+
|
1002 |
+
#: wp-piwik/settings/views.php:16
|
1003 |
+
#: wp-piwik/settings/views.php:24
|
1004 |
+
msgid "yesterday"
|
1005 |
+
msgstr ""
|
1006 |
+
|
1007 |
+
#: wp-piwik/settings/views.php:17
|
1008 |
+
#: wp-piwik/settings/views.php:25
|
1009 |
+
msgid "today"
|
1010 |
+
msgstr ""
|
1011 |
+
|
1012 |
+
#: wp-piwik/settings/views.php:19
|
1013 |
+
msgid "Default date shown on statistics page."
|
1014 |
+
msgstr ""
|
1015 |
+
|
1016 |
+
#: wp-piwik/settings/views.php:21
|
1017 |
+
msgid "Home Dashboard"
|
1018 |
+
msgstr ""
|
1019 |
+
|
1020 |
+
#: wp-piwik/settings/views.php:23
|
1021 |
+
msgid "Hide overview"
|
1022 |
+
msgstr ""
|
1023 |
+
|
1024 |
+
#: wp-piwik/settings/views.php:24
|
1025 |
+
#: wp-piwik/settings/views.php:25
|
1026 |
+
#: wp-piwik/settings/views.php:26
|
1027 |
+
msgid "Show overview"
|
1028 |
+
msgstr ""
|
1029 |
+
|
1030 |
+
#: wp-piwik/settings/views.php:26
|
1031 |
+
msgid "last 30 days"
|
1032 |
+
msgstr ""
|
1033 |
+
|
1034 |
+
#: wp-piwik/settings/views.php:28
|
1035 |
+
msgid "Chart"
|
1036 |
+
msgstr ""
|
1037 |
+
|
1038 |
+
#: wp-piwik/settings/views.php:29
|
1039 |
+
msgid "SEO <em>(slow!)</em>"
|
1040 |
+
msgstr ""
|
1041 |
+
|
1042 |
+
#: wp-piwik/settings/views.php:30
|
1043 |
+
msgid ""
|
1044 |
+
"Configure WP-Piwik widgets to be shown on your WordPress Home Dashboard."
|
1045 |
+
msgstr ""
|
1046 |
+
|
1047 |
+
#: wp-piwik/settings/views.php:32
|
1048 |
+
msgid "Show graph on WordPress Toolbar"
|
1049 |
+
msgstr ""
|
1050 |
+
|
1051 |
+
#: wp-piwik/settings/views.php:34
|
1052 |
+
msgid "Display the last 30 days visitor stats on WordPress Toolbar."
|
1053 |
+
msgstr ""
|
1054 |
+
|
1055 |
+
#: wp-piwik/settings/views.php:36
|
1056 |
+
msgid "SEO data"
|
1057 |
+
msgstr ""
|
1058 |
+
|
1059 |
+
#: wp-piwik/settings/views.php:38
|
1060 |
+
msgid "Display SEO ranking data on statistics page. <em>(Slow!)</em>"
|
1061 |
+
msgstr ""
|
1062 |
+
|
1063 |
+
#: wp-piwik/settings/views.php:42
|
1064 |
+
msgid "Display a shortcut to Piwik itself."
|
1065 |
+
msgstr ""
|
1066 |
+
|
1067 |
+
#: wp-piwik/settings/views.php:44
|
1068 |
+
msgid "Display to"
|
1069 |
+
msgstr ""
|
1070 |
+
|
1071 |
+
#: wp-piwik/settings/views.php:51
|
1072 |
+
msgid "Choose user roles allowed to see the statistics page."
|
1073 |
+
msgstr ""
|
1074 |
+
|
1075 |
+
#: wp-piwik/settings/views.php:53
|
1076 |
+
msgid "Disable time limit"
|
1077 |
+
msgstr ""
|
1078 |
+
|
1079 |
+
#: wp-piwik/settings/views.php:55
|
1080 |
+
msgid "Use set_time_limit(0) if stats page causes a time out."
|
1081 |
+
msgstr ""
|
1082 |
+
|
1083 |
+
#: wp-piwik/settings/views.php:57
|
1084 |
+
msgid "Show per post stats"
|
1085 |
+
msgstr ""
|
1086 |
+
|
1087 |
+
#: wp-piwik/settings/views.php:59
|
1088 |
+
msgid "Show stats about single posts at the post edit admin page."
|
1089 |
+
msgstr ""
|
1090 |
+
|
1091 |
+
#: wp-piwik/settings/views.php:61
|
1092 |
+
msgid "Enable shortcodes"
|
1093 |
+
msgstr ""
|
1094 |
+
|
1095 |
+
#: wp-piwik/settings/views.php:63
|
1096 |
+
msgid "Enable shortcodes in post or page content."
|
1097 |
+
msgstr ""
|
1098 |
+
|
1099 |
+
#: wp-piwik/shortcodes/overview.php:28
|
1100 |
+
msgid "Error"
|
1101 |
+
msgstr ""
|
1102 |
+
|
1103 |
+
#: wp-piwik/shortcodes/overview.php:48
|
1104 |
+
msgid "No data available"
|
1105 |
+
msgstr ""
|
piwik.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* [!] Deprecated proxy script. Use proxy/piwik.php instead.
|
5 |
+
*/
|
6 |
+
|
7 |
+
header("Location: proxy/piwik.php");
|
8 |
+
die();
|
proxy/config.php
CHANGED
@@ -1,30 +1,13 @@
|
|
1 |
<?php
|
|
|
2 |
require('../../../../wp-load.php');
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
|
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 |
-
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')?'https':'http';
|
12 |
-
|
13 |
-
switch ( $settings->getGlobalOption('piwik_mode') ) {
|
14 |
-
case 'php':
|
15 |
-
$PIWIK_URL = $protocol.':'.$settings->getGlobalOption('proxy_url');
|
16 |
-
break;
|
17 |
-
case 'pro':
|
18 |
-
$PIWIK_URL = 'https://'.$settings->getGlobalOption('piwik_user').'.piwik.pro/';
|
19 |
-
break;
|
20 |
-
default:
|
21 |
-
$PIWIK_URL = $settings->getGlobalOption('piwik_url');
|
22 |
-
}
|
23 |
-
|
24 |
-
if (substr($PIWIK_URL, 0, 2) == '//')
|
25 |
-
$PIWIK_URL = (isset($_SERVER['HTTPS'])?'https:':'http:').$PIWIK_URL;
|
26 |
-
|
27 |
$TOKEN_AUTH = $settings->getGlobalOption('piwik_token');
|
28 |
$timeout = $settings->getGlobalOption('connection_timeout');
|
29 |
-
|
30 |
ini_set('display_errors',0);
|
1 |
<?php
|
2 |
+
|
3 |
require('../../../../wp-load.php');
|
4 |
+
require_once('../classes/WP_Piwik_Settings.php');
|
5 |
+
require_once('../classes/WP_Piwik_Logger_Dummy.php');
|
6 |
+
|
7 |
+
$logger = new WP_Piwik_Logger_Dummy(__CLASS__);
|
8 |
+
$settings = new WP_Piwik_Settings($logger);
|
9 |
|
10 |
+
$PIWIK_URL = $settings->getGlobalOption('piwik_url');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
$TOKEN_AUTH = $settings->getGlobalOption('piwik_token');
|
12 |
$timeout = $settings->getGlobalOption('connection_timeout');
|
|
|
13 |
ini_set('display_errors',0);
|
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.,
|
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., 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/.htaccess
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
Deny from all
|
settings/credits.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/homepage.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$strVersion = $this->callPiwikAPI('API.getPiwikVersion');
|
3 |
+
// http://wordpress.org/support/rss/tags/wp-piwik
|
4 |
+
?><tr><td><strong><?php _e('Thanks for using WP-Piwik!', 'wp-piwik'); ?></strong></td></tr>
|
5 |
+
<tr><td><?php
|
6 |
+
if (is_array($strVersion) && $strVersion['result'] == 'error') self::showErrorMessage($strVersion['message']);
|
7 |
+
elseif (empty($strVersion)) self::showErrorMessage('Piwik did not answer. Please check your entered Piwik URL.');
|
8 |
+
else echo __('You are using Piwik','wp-piwik').' '.$strVersion.' '.__('and', 'wp-piwik').' WP-Piwik '.self::$strVersion.(is_plugin_active_for_network('wp-piwik/wp-piwik.php')?' '.__('in network mode', 'wp-piwik'):'').'.';
|
9 |
+
?></td></tr>
|
10 |
+
<tr><td><?php _e('Auto site configuration is','wp-piwik'); ?> <strong><?php echo (self::$settings->getGlobalOption('auto_site_config')?__('enabled','wp-piwik'):__('disabled','wp-piwik')); ?>.</strong></td></tr>
|
11 |
+
<tr><td><?php _e('Tracking code insertion is','wp-piwik'); ?> <strong><?php echo (self::$settings->getGlobalOption('add_tracking_code')?__('enabled','wp-piwik'):__('disabled','wp-piwik')); ?>.</strong></td></tr>
|
settings/index.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Nothing to see...
|
settings/piwik.php
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.', 'wp-piwik'); ?></strong>
|
8 |
+
</td>
|
9 |
+
</tr><?php } else { ?><tr>
|
10 |
+
<td colspan="2">
|
11 |
+
<?php printf(__("To use this plugin you will need your own Piwik instance. If you do not already have a Piwik setup, you have two simple options: use either <a href='%s'>Self-hosted</a> or <a href='%s'>Cloud-hosted</a>.", 'wp-piwik'), 'http://piwik.org/', 'http://piwik.org/hosting/'); ?>
|
12 |
+
</td>
|
13 |
+
</tr>
|
14 |
+
<tr>
|
15 |
+
<td colspan="2">
|
16 |
+
<?php _e('To enable Piwik statistics, please enter', 'wp-piwik'); ?>:
|
17 |
+
<ol>
|
18 |
+
<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>
|
19 |
+
<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>
|
20 |
+
</ol>
|
21 |
+
<?php _e('No idea what I\'m talking about?', 'wp-piwik'); ?> <a href="https://wordpress.org/plugins/wp-piwik/faq/"><?php _e('Get help.', 'wp-piwik'); ?></a>
|
22 |
+
<?php if (!is_plugin_active_for_network('wp-piwik/wp-piwik.php')) { ?>
|
23 |
+
<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>
|
24 |
+
<?php } ?>
|
25 |
+
</td>
|
26 |
+
</tr><tr>
|
27 |
+
<th><?php _e('Piwik URL', 'wp-piwik'); ?> (REST API):</th>
|
28 |
+
<td>
|
29 |
+
<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" ':''); ?>/>
|
30 |
+
<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'); ?>" />
|
31 |
+
</td>
|
32 |
+
</tr><tr>
|
33 |
+
<th><?php _e('Piwik path', 'wp-piwik'); ?> (PHP API, beta):</th>
|
34 |
+
<td>
|
35 |
+
<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" ':''); ?>/>
|
36 |
+
<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'); ?>" />
|
37 |
+
<?php
|
38 |
+
if (isset($_POST['wp-piwik_path']) && !empty($_POST['wp-piwik_path']) && realpath($_POST['wp-piwik_path']) === false)
|
39 |
+
echo '<p class="wp-piwik-eyecatcher">'.__('Invalid path. Please enter the file path to Piwik.', 'wp-piwik').'</p>';
|
40 |
+
?>
|
41 |
+
</td>
|
42 |
+
</tr><tr>
|
43 |
+
<th><?php _e('Auth token', 'wp-piwik'); ?>:</th>
|
44 |
+
<td>
|
45 |
+
<input name="wp-piwik_token" id="wp-piwik_token" type="text" value="<?php echo self::$settings->getGlobalOption('piwik_token'); ?>" />
|
46 |
+
<label for="wp-piwik_token"></label>
|
47 |
+
</td>
|
48 |
+
</tr><tr><th><?php _e('Enable cache', 'wp-piwik'); ?>:</th><td>
|
49 |
+
<input type="checkbox" value="1" id="wp-piwik_cache" name="wp-piwik_cache"<?php echo (self::$settings->getGlobalOption('cache')?' checked="checked"':''); ?> />
|
50 |
+
<label for="wp-piwik_cache"><?php _e('Cache API calls, which not contain today\'s values, for a week', 'wp-piwik'); ?>.</label>
|
51 |
+
</td></tr>
|
52 |
+
|
53 |
+
<?php if (!is_plugin_active_for_network('wp-piwik/wp-piwik.php')) { ?><tr>
|
54 |
+
<th><?php _e('Auto config', 'wp-piwik'); ?>:</th>
|
55 |
+
<td>
|
56 |
+
<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"':'') ?>/>
|
57 |
+
<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>
|
58 |
+
</td>
|
59 |
+
</tr>
|
60 |
+
<?php
|
61 |
+
if (self::$settings->getGlobalOption('piwik_url') && self::$settings->getGlobalOption('piwik_token')) {
|
62 |
+
$aryData = $this->callPiwikAPI('SitesManager.getSitesWithAtLeastViewAccess');
|
63 |
+
if (empty($aryData)) {
|
64 |
+
echo '<tr><td colspan="2">';
|
65 |
+
self::showErrorMessage(__('Please check URL and auth token. You need at least view access to one site.', 'wp-piwik'));
|
66 |
+
echo '</td></tr>';
|
67 |
+
}
|
68 |
+
elseif (isset($aryData['result']) && $aryData['result'] == 'error') {
|
69 |
+
echo '<tr><td colspan="2">';
|
70 |
+
self::showErrorMessage($aryData['message']);
|
71 |
+
echo '</td></tr>';
|
72 |
+
} elseif (!self::$settings->getGlobalOption('auto_site_config')) {
|
73 |
+
echo '<tr><th>'.__('Choose site', 'wp-piwik').':</th><td>';
|
74 |
+
echo '<select name="wp-piwik_siteid" id="wp-piwik_siteid">';
|
75 |
+
$aryOptions = array();
|
76 |
+
foreach ($aryData as $arySite)
|
77 |
+
$aryOptions[$arySite['name'].'#'.$arySite['idsite']] = '<option value="'.$arySite['idsite'].
|
78 |
+
'"'.($arySite['idsite']==self::$settings->getOption('site_id')?' selected="selected"':'').
|
79 |
+
'>'.htmlentities($arySite['name'], ENT_QUOTES, 'utf-8').
|
80 |
+
'</option>';
|
81 |
+
ksort($aryOptions);
|
82 |
+
foreach ($aryOptions as $strOption) echo $strOption;
|
83 |
+
echo '</select></td></tr>';
|
84 |
+
} else {
|
85 |
+
if (!self::$settings->getOption('site_id'))
|
86 |
+
$this->addPiwikSite();
|
87 |
+
echo '<tr><th>'.__('Determined site', 'wp-piwik').':</th><td>';
|
88 |
+
echo '<div class="input-text-wrap">';
|
89 |
+
$siteId = self::$settings->getOption('site_id');
|
90 |
+
if (is_array($siteId) && $siteId['result'] == 'error')
|
91 |
+
self::showErrorMessage($siteId['message']);
|
92 |
+
else foreach ($aryData as $arySite)
|
93 |
+
if ($arySite['idsite'] == $siteId) {echo '<em>'.htmlentities($arySite['name'], ENT_QUOTES, 'utf-8').'</em>'; break;}
|
94 |
+
echo '<input type="hidden" name="wp-piwik_siteid" id="wp-piwik_siteid" value="'.(int)$siteId.'" /></td></tr>';
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}}
|
98 |
+
// Expert settings (cURL only)
|
99 |
+
?><tr>
|
100 |
+
<th colspan="2"><strong><?php _e('Expert Settings', 'wp-piwik'); ?>:</strong></th>
|
101 |
+
</tr><tr>
|
102 |
+
<th><label><?php _e('Connection timeout', 'wp-piwik'); ?>:</label></th>
|
103 |
+
<td>
|
104 |
+
<input style="width:50px;" type="text" name="wp-piwik_timeout" value="<?php echo self::$settings->getGlobalOption('connection_timeout'); ?>" />
|
105 |
+
</td>
|
106 |
+
</tr>
|
107 |
+
<?php if (function_exists('curl_init')) { ?>
|
108 |
+
<tr>
|
109 |
+
<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>
|
110 |
+
<td>
|
111 |
+
<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'); ?>)
|
112 |
+
</td>
|
113 |
+
</tr><tr>
|
114 |
+
<th><label><?php _e('User agent', 'wp-piwik'); ?>:</label></th>
|
115 |
+
<td>
|
116 |
+
<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'); ?>)
|
117 |
+
</td>
|
118 |
+
</tr><tr>
|
119 |
+
<th></th>
|
120 |
+
<td>
|
121 |
+
<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'); ?>" />
|
122 |
+
</td>
|
123 |
+
</tr>
|
124 |
+
<?php } else { ?>
|
125 |
+
<tr>
|
126 |
+
<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>
|
127 |
+
</tr>
|
128 |
+
<?php }
|
settings/sitebrowser.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
</table>
|
11 |
+
<?php
|
12 |
+
if (!class_exists('WP_List_Table'))
|
13 |
+
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
14 |
+
|
15 |
+
if (isset($_GET['wpmu_show_stats']) && ($_GET['wpmu_show_stats'] == (int) $_GET['wpmu_show_stats'])) {
|
16 |
+
$this->addPiwikSite();
|
17 |
+
}
|
18 |
+
|
19 |
+
// See wpengineer.com/2426/wp_list_table-a-step-by-step-guide/
|
20 |
+
class SiteBrowser extends WP_List_Table {
|
21 |
+
|
22 |
+
var $aryData = array();
|
23 |
+
|
24 |
+
function get_columns(){
|
25 |
+
$columns = array(
|
26 |
+
'id' => __('ID','wp-piwik'),
|
27 |
+
'name' => __('Title','wp-piwik'),
|
28 |
+
'siteurl' => __('URL','wp-piwik'),
|
29 |
+
'piwikid' => __('Site ID (Piwik)','wp-piwik')
|
30 |
+
);
|
31 |
+
return $columns;
|
32 |
+
}
|
33 |
+
|
34 |
+
function prepare_items($bolNetwork = false) {
|
35 |
+
$current_page = $this->get_pagenum();
|
36 |
+
$per_page = 10;
|
37 |
+
global $blog_id;
|
38 |
+
global $wpdb;
|
39 |
+
global $pagenow;
|
40 |
+
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php')) {
|
41 |
+
$total_items = $wpdb->get_var('SELECT COUNT(*) FROM '.$wpdb->blogs);
|
42 |
+
$aryBlogs = $wpdb->get_results($wpdb->prepare('SELECT blog_id FROM '.$wpdb->blogs.' ORDER BY blog_id LIMIT %d,%d',(($current_page-1)*$per_page),$per_page));
|
43 |
+
foreach ($aryBlogs as $aryBlog) {
|
44 |
+
$objBlog = get_blog_details($aryBlog->blog_id, true);
|
45 |
+
$this->aryData[] = array(
|
46 |
+
'name' => $objBlog->blogname,
|
47 |
+
'id' => $objBlog->blog_id,
|
48 |
+
'siteurl' => $objBlog->siteurl,
|
49 |
+
'piwikid' => WP_Piwik::getSiteID($objBlog->blog_id)
|
50 |
+
);
|
51 |
+
}
|
52 |
+
} else {
|
53 |
+
$objBlog = get_bloginfo();
|
54 |
+
$this->aryData[] = array(
|
55 |
+
'name' => get_bloginfo('name'),
|
56 |
+
'id' => '-',
|
57 |
+
'siteurl' => get_bloginfo('url'),
|
58 |
+
'piwikid' => WP_Piwik::getSiteID()
|
59 |
+
);
|
60 |
+
$total_items = 1;
|
61 |
+
}
|
62 |
+
$columns = $this->get_columns();
|
63 |
+
$hidden = array();
|
64 |
+
$sortable = array();
|
65 |
+
$this->_column_headers = array($columns, $hidden, $sortable);
|
66 |
+
$this->set_pagination_args(array(
|
67 |
+
'total_items' => $total_items,
|
68 |
+
'per_page' => $per_page
|
69 |
+
));
|
70 |
+
if ($bolNetwork) $pagenow = 'settings.php';
|
71 |
+
foreach ($this->aryData as $intKey => $aryDataset) {
|
72 |
+
if (empty($aryDataset['piwikid']) || !is_int($aryDataset['piwikid']))
|
73 |
+
$this->aryData[$intKey]['piwikid'] = '<a href="'.admin_url(($pagenow == 'settings.php'?'network/':'')).$pagenow.'?page=wp-piwik/wp-piwik.php&tab=sitebrowser'.($aryDataset['id'] != '-'?'&wpmu_show_stats='.$aryDataset['id']:'').'">Create Piwik site</a>';
|
74 |
+
if ($bolNetwork)
|
75 |
+
$this->aryData[$intKey]['name'] = '<a href="?page=wp-piwik_stats&wpmu_show_stats='.$aryDataset['id'].'">'.$aryDataset['name'].'</a>';
|
76 |
+
}
|
77 |
+
$this->items = $this->aryData;
|
78 |
+
return count($this->items);
|
79 |
+
}
|
80 |
+
|
81 |
+
function column_default( $item, $column_name ) {
|
82 |
+
switch( $column_name ) {
|
83 |
+
case 'id':
|
84 |
+
case 'name':
|
85 |
+
case 'siteurl':
|
86 |
+
case 'piwikid':
|
87 |
+
return $item[$column_name];
|
88 |
+
default:
|
89 |
+
return print_r($item,true);
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
$objSiteBrowser = new SiteBrowser();
|
94 |
+
$intCnt = $objSiteBrowser->prepare_items($this->bolNetwork);
|
95 |
+
if ($intCnt > 0) $objSiteBrowser->display();
|
96 |
+
else echo '<p>No site configured yet.</p>'
|
97 |
+
?>
|
98 |
+
<table>
|
99 |
+
<?php } ?>
|
settings/support.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<tr>
|
2 |
+
<td><a href="http://wordpress.org/tags/wp-piwik?forum_id=10"><?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/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/wp-piwik.php&tab=support&mode=testscript"><?php _e('Run test script','wp-piwik'); ?></a></li>
|
46 |
+
<li><a href="?page=wp-piwik/wp-piwik.php&tab=sitebrowser"><?php _e('Get site configuration details','wp-piwik'); ?></a></li>
|
47 |
+
<li><a href="?page=wp-piwik/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
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_proxy"><?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('Add new file types for download tracking', 'wp-piwik'); ?>:</th><td>
|
112 |
+
<input type="text" name="wp-piwik_add_download_extensions" value="<?php echo self::$settings->getGlobalOption('add_download_extensions'); ?>" />
|
113 |
+
<label for="wp-piwik_annotations"><?php echo _e('Add file extensions for download tracking, divided by a vertical bar (|), see', 'wp-piwik'); ?> <a href="https://developer.piwik.org/guides/tracking-javascript-guide#file-extensions-for-tracking-downloads">Piwik Docs</a>.</label>
|
114 |
+
</td></tr>
|
115 |
+
|
116 |
+
<tr><th><?php _e('Show custom variables box', 'wp-piwik'); ?>:</th><td>
|
117 |
+
<input type="checkbox" value="1" id="wp-piwik_customvars" name="wp-piwik_customvars"<?php echo (self::$settings->getGlobalOption('add_customvars_box')?' checked="checked"':''); ?> />
|
118 |
+
<label for="wp-piwik_customvars"><?php echo _e('Show a custom vars edit box on post edit page.', 'wp-piwik'); ?></label>
|
119 |
+
</td></tr>
|
120 |
+
|
121 |
+
<tr><th><?php _e('Avoid mod_security', 'wp-piwik'); ?>:</th><td>
|
122 |
+
<input type="checkbox" value="1" id="wp-piwik_reqpost" name="wp-piwik_reqpost"<?php echo (self::$settings->getGlobalOption('track_post')?' checked="checked"':''); ?> />
|
123 |
+
<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>
|
124 |
+
</td></tr>
|
125 |
+
|
126 |
+
<tr><th><?php _e('Add data-cfasync=false', 'wp-piwik'); ?>:</th><td>
|
127 |
+
<input type="checkbox" value="1" id="wp-piwik_datacfasync" name="wp-piwik_datacfasync"<?php echo (self::$settings->getGlobalOption('track_datacfasync')?' checked="checked"':''); ?> />
|
128 |
+
<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'); ?>
|
129 |
+
</td></tr>
|
130 |
+
|
131 |
+
<tr><th><?php _e('CDN URL', 'wp-piwik'); ?>:</th><td>
|
132 |
+
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 />
|
133 |
+
<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>
|
134 |
+
</td></tr>
|
135 |
+
|
136 |
+
<tr><th><?php _e('Force Piwik to use a specific protocol', 'wp-piwik'); ?>:</th><td>
|
137 |
+
<input type="radio" value="" id="wp-piwik_force_protocol_none" name="wp-piwik_force_protocol"<?php echo (!self::$settings->getGlobalOption('force_protocol')?' checked="checked"':''); ?> /> <?php _e('Disabled (default)', 'wp-piwik'); ?>
|
138 |
+
<input type="radio" value="http" id="wp-piwik_force_protocol_http" name="wp-piwik_force_protocol"<?php echo (self::$settings->getGlobalOption('force_protocol')=="http"?' checked="checked"':''); ?> /> HTTP
|
139 |
+
<input type="radio" value="https" id="wp-piwik_force_protocol_https" name="wp-piwik_force_protocol"<?php echo (self::$settings->getGlobalOption('force_protocol')=="https"?' checked="checked"':''); ?> /> HTTPS (SSL) <br />
|
140 |
+
<label for="wp-piwik_force_protocol_none"><?php _e('Choose if you want to explicitly force Piwik to use HTTP or HTTPS. Does not work with a CDN URL.', 'wp-piwik'); ?></label>
|
141 |
+
</td></tr>
|
142 |
+
|
143 |
+
<tr><th><?php _e('Track admin pages', 'wp-piwik'); ?>:</th><td>
|
144 |
+
<input type="checkbox" value="1" id="wp-piwik_trackadmin" name="wp-piwik_trackadmin"<?php echo (self::$settings->getGlobalOption('track_admin')?' checked="checked"':''); ?> />
|
145 |
+
<label for="wp-piwik_trackadmin"><?php _e('Enable to track users on admin pages (remember to configure the tracking filter appropriately).', 'wp-piwik'); ?></label>
|
146 |
+
</td></tr>
|
147 |
+
|
148 |
+
<tr><th><?php _e('Track RSS feeds', 'wp-piwik'); ?>:</th><td>
|
149 |
+
<input type="checkbox" value="1" id="wp-piwik_trackfeed" name="wp-piwik_trackfeed"<?php echo (self::$settings->getGlobalOption('track_feed')?' checked="checked"':''); ?> />
|
150 |
+
<label for="wp-piwik_trackfeed"><?php _e('Enable to track posts in feeds via tracking pixel.', 'wp-piwik'); ?></label>
|
151 |
+
</td></tr>
|
152 |
+
|
153 |
+
<tr><th><?php _e('Track RSS feed links as campaign', 'wp-piwik'); ?>:</th><td>
|
154 |
+
<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"':''); ?> />
|
155 |
+
<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 />
|
156 |
+
<?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'); ?>
|
157 |
+
</td></tr>
|
158 |
+
|
159 |
+
<tr><th><?php _e('Tracking filter', 'wp-piwik'); ?>:</th><td>
|
160 |
+
<?php
|
161 |
+
global $wp_roles;
|
162 |
+
$aryFilter = self::$settings->getGlobalOption('capability_stealth');
|
163 |
+
foreach($wp_roles->role_names as $strKey => $strName) {
|
164 |
+
echo '<input type="checkbox" '.(isset($aryFilter[$strKey]) && $aryFilter[$strKey]?'checked="checked" ':'').'value="1" name="wp-piwik_filter['.$strKey.']" /> '.$strName.' ';
|
165 |
+
}
|
166 |
+
?><br><?php _e('Choose users by user role you do <strong>not</strong> want to track.','wp-piwik'); ?></td></tr>
|
167 |
+
</table>
|
168 |
+
<table class="wp-piwik-form-table form-table">
|
169 |
+
<?php } ?>
|
settings/views.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 } ?>
|
shortcodes/.htaccess
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
Deny from all
|
shortcodes/overview.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Short:Overview
|
4 |
+
**********************************/
|
5 |
+
$aryData = $this->callPiwikAPI('VisitsSummary.get',
|
6 |
+
$this->aryAttributes['period'],
|
7 |
+
$this->aryAttributes['date'],
|
8 |
+
$this->aryAttributes['limit']
|
9 |
+
);
|
10 |
+
|
11 |
+
$this->strResult = '<table><tr><th colspan="2">'.__('Overview', 'wp-piwik').($this->aryAttributes['title']?' '.$this->aryAttributes['title']:'').'</th></tr>';
|
12 |
+
|
13 |
+
if (!function_exists('summize')) {
|
14 |
+
function summize($aryData) {
|
15 |
+
$aryTmp = array();
|
16 |
+
foreach ($aryData as $aryValues)
|
17 |
+
foreach($aryValues as $strKey => $intValue)
|
18 |
+
if (isset($aryTmp[$strKey])) $aryTmp[$strKey] += $intValue;
|
19 |
+
else $aryTmp[$strKey] = $intValue;
|
20 |
+
$aryTmp['bounce_rate'] = ($aryTmp['nb_uniq_visitors']==0?0:round($aryTmp['bounce_count']/$aryTmp['nb_visits']*100,2)).'%';
|
21 |
+
|
22 |
+
return $aryTmp;
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
if (is_array($aryData)) {
|
27 |
+
if (isset($aryData['result']) && $aryData['result'] == 'error')
|
28 |
+
$this->strResult .= '<tr><td>'.__('Error', 'wp-piwik').':'.'</td><td>'.$aryData['message'].'</td></tr>';
|
29 |
+
else {
|
30 |
+
if (is_array(current($aryData)))
|
31 |
+
$aryData = summize($aryData);
|
32 |
+
$strTime =
|
33 |
+
floor($aryData['sum_visit_length']/3600).'h '.
|
34 |
+
floor(($aryData['sum_visit_length'] % 3600)/60).'m '.
|
35 |
+
floor(($aryData['sum_visit_length'] % 3600) % 60).'s';
|
36 |
+
$strAvgTime =
|
37 |
+
floor($aryData['avg_time_on_site']/3600).'h '.
|
38 |
+
floor(($aryData['avg_time_on_site'] % 3600)/60).'m '.
|
39 |
+
floor(($aryData['avg_time_on_site'] % 3600) % 60).'s';
|
40 |
+
$this->strResult .= '<tr><td>'.__('Visitors', 'wp-piwik').':'.'</td><td>'.$aryData['nb_visits'].'</td></tr>';
|
41 |
+
$this->strResult .= '<tr><td>'.__('Unique visitors', 'wp-piwik').':'.'</td><td>'.$aryData['nb_uniq_visitors'].'</td></tr>';
|
42 |
+
$this->strResult .= '<tr><td>'.__('Page views', 'wp-piwik').':'.'</td><td>'.$aryData['nb_actions'].' (Ø '.$aryData['nb_actions_per_visit'].')</td></tr>';
|
43 |
+
$this->strResult .= '<tr><td>'.__('Max. page views in one visit', 'wp-piwik').':'.'</td><td>'.$aryData['max_actions'].'</td></tr>';
|
44 |
+
$this->strResult .= '<tr><td>'.__('Total time spent', 'wp-piwik').':'.'</td><td>'.$strTime.'</td></tr>';
|
45 |
+
$this->strResult .= '<tr><td>'.__('Time/visit', 'wp-piwik').':'.'</td><td>'.$strAvgTime.'</td></tr>';
|
46 |
+
$this->strResult .= '<tr><td>'.__('Bounce count', 'wp-piwik').':'.'</td><td>'.$aryData['bounce_count'].' ('.$aryData['bounce_rate'].')</td></tr>';
|
47 |
+
}
|
48 |
+
} else $this->strResult .= '<tr><td>'.__('No data available', 'wp-piwik').'</td></tr>';
|
49 |
+
|
50 |
+
$this->strResult .= '</table>';
|
shortcodes/post.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*********************************
|
3 |
+
WP-Piwik::Short:Post
|
4 |
+
**********************************/
|
5 |
+
if (!class_exists('WP_Piwik_MetaBox_PerPost_Stats'))
|
6 |
+
$this->includeFile('classes/WP_Piwik_MetaBox_PerPost_Stats');
|
7 |
+
|
8 |
+
$perPostClass = new WP_Piwik_MetaBox_PerPost_Stats($this->subClassConfig());
|
9 |
+
$this->strResult = $perPostClass->getValue($this->aryAttributes['range'], $this->aryAttributes['key']);
|
uninstall.php
CHANGED
@@ -1,102 +1,17 @@
|
|
1 |
<?php
|
2 |
|
3 |
// Check if uninstall call is valid
|
4 |
-
if (
|
5 |
-
exit();
|
6 |
-
|
7 |
-
$globalSettings = array(
|
8 |
-
'revision',
|
9 |
-
'last_settings_update',
|
10 |
-
'piwik_mode',
|
11 |
-
'piwik_url',
|
12 |
-
'piwik_path',
|
13 |
-
'piwik_user',
|
14 |
-
'piwik_token',
|
15 |
-
'auto_site_config',
|
16 |
-
'default_date',
|
17 |
-
'stats_seo',
|
18 |
-
'dashboard_widget',
|
19 |
-
'dashboard_chart',
|
20 |
-
'dashboard_seo',
|
21 |
-
'toolbar',
|
22 |
-
'capability_read_stats',
|
23 |
-
'perpost_stats',
|
24 |
-
'plugin_display_name',
|
25 |
-
'piwik_shortcut',
|
26 |
-
'shortcodes',
|
27 |
-
'track_mode',
|
28 |
-
'track_codeposition',
|
29 |
-
'track_noscript',
|
30 |
-
'track_nojavascript',
|
31 |
-
'proxy_url',
|
32 |
-
'track_search',
|
33 |
-
'track_404',
|
34 |
-
'add_post_annotations',
|
35 |
-
'add_customvars_box',
|
36 |
-
'add_download_extensions',
|
37 |
-
'disable_cookies',
|
38 |
-
'limit_cookies',
|
39 |
-
'limit_cookies_visitor',
|
40 |
-
'limit_cookies_session',
|
41 |
-
'track_admin',
|
42 |
-
'capability_stealth',
|
43 |
-
'track_across',
|
44 |
-
'track_across_alias',
|
45 |
-
'track_feed',
|
46 |
-
'track_feed_addcampaign',
|
47 |
-
'track_feed_campaign',
|
48 |
-
'cache',
|
49 |
-
'disable_timelimit',
|
50 |
-
'connection_timeout',
|
51 |
-
'disable_ssl_verify',
|
52 |
-
'piwik_useragent',
|
53 |
-
'piwik_useragent_string',
|
54 |
-
'track_datacfasync',
|
55 |
-
'track_cdnurl',
|
56 |
-
'track_cdnurlssl',
|
57 |
-
'force_protocol'
|
58 |
-
);
|
59 |
-
|
60 |
-
$settings = array (
|
61 |
-
'name',
|
62 |
-
'site_id',
|
63 |
-
'noscript_code',
|
64 |
-
'tracking_code',
|
65 |
-
'last_tracking_code_update',
|
66 |
-
'dashboard_revision'
|
67 |
-
);
|
68 |
|
69 |
global $wpdb;
|
70 |
|
71 |
if (function_exists('is_multisite') && is_multisite()) {
|
|
|
72 |
$aryBlogs = $wpdb->get_results('SELECT blog_id FROM '.$wpdb->blogs.' ORDER BY blog_id');
|
73 |
if (is_array($aryBlogs))
|
74 |
-
foreach ($aryBlogs as $aryBlog)
|
75 |
-
|
76 |
-
delete_blog_option($aryBlog->blog_id, 'wp-piwik-'.$key);
|
77 |
-
}
|
78 |
-
switch_to_blog($aryBlog->blog_id);
|
79 |
-
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key LIKE 'wp-piwik_%'");
|
80 |
-
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_wp-piwik_%'");
|
81 |
-
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_timeout_wp-piwik_%'");
|
82 |
-
restore_current_blog();
|
83 |
-
|
84 |
-
}
|
85 |
-
foreach ($globalSettings as $key)
|
86 |
-
delete_site_option('wp-piwik_global-'.$key);
|
87 |
-
delete_site_option('wp-piwik-manually');
|
88 |
-
delete_site_option('wp-piwik-notices');
|
89 |
}
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
foreach ($globalSettings as $key)
|
95 |
-
delete_option('wp-piwik_global-'.$key);
|
96 |
-
|
97 |
-
delete_option('wp-piwik-manually');
|
98 |
-
delete_option('wp-piwik-notices');
|
99 |
-
|
100 |
-
$wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key LIKE 'wp-piwik-%'");
|
101 |
-
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_wp-piwik_%'");
|
102 |
-
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_timeout_wp-piwik_%'");
|
1 |
<?php
|
2 |
|
3 |
// Check if uninstall call is valid
|
4 |
+
if (!defined('WP_UNINSTALL_PLUGIN')) exit();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
global $wpdb;
|
7 |
|
8 |
if (function_exists('is_multisite') && is_multisite()) {
|
9 |
+
delete_site_option('wp-piwik_global-settings');
|
10 |
$aryBlogs = $wpdb->get_results('SELECT blog_id FROM '.$wpdb->blogs.' ORDER BY blog_id');
|
11 |
if (is_array($aryBlogs))
|
12 |
+
foreach ($aryBlogs as $aryBlog)
|
13 |
+
delete_blog_option($aryBlog->blog_id, 'wp-piwik_settings');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
15 |
|
16 |
+
delete_option('wp-piwik_global-settings');
|
17 |
+
delete_option('wp-piwik_settings');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update/100000.php
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// Get & delete old version's options
|
3 |
-
if (self::$settings->checkNetworkActivation()) {
|
4 |
-
$oldGlobalOptions = get_site_option('wp-piwik_global-settings', array());
|
5 |
-
delete_site_option('wp-piwik_global-settings');
|
6 |
-
} else {
|
7 |
-
$oldGlobalOptions = get_option('wp-piwik_global-settings', array());
|
8 |
-
delete_option('wp-piwik_global-settings');
|
9 |
-
}
|
10 |
-
$oldOptions = get_option('wp-piwik_settings', array());
|
11 |
-
delete_option('wp-piwik_settings');
|
12 |
-
|
13 |
-
// Store old values in new settings
|
14 |
-
foreach ($oldGlobalOptions as $key => $value)
|
15 |
-
self::$settings->setGlobalOption($key, $value);
|
16 |
-
foreach ($oldOptions as $key => $value)
|
17 |
-
self::$settings->setOption($key, $value);
|
18 |
-
self::$settings->save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update/80502.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$settings->setGlobalOption('default_date', 'yesterday');
|
update/80602.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$settings->setGlobalOption('dashboard_chart', false);
|
update/80800.php
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
<?php
|
2 |
-
self::$settings->setGlobalOption('piwik_url', self::$settings->getGlobalOption('piwik_url')
|
1 |
<?php
|
2 |
+
self::$settings->setGlobalOption('piwik_url', self::checkURL(self::$settings->getGlobalOption('piwik_url')));
|
update/90001.php
CHANGED
@@ -1,8 +1,13 @@
|
|
1 |
<?php
|
2 |
$aryWPMUConfig = get_site_option('wpmu-piwik_global-settings',false);
|
3 |
-
if (
|
4 |
foreach ($aryWPMUConfig as $key => $value)
|
5 |
self::$settings->setGlobalOption($key, $value);
|
6 |
delete_site_option('wpmu-piwik_global-settings');
|
7 |
self::$settings->setGlobalOption('auto_site_config', true);
|
8 |
-
} else self::$settings->setGlobalOption('auto_site_config', false);
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
$aryWPMUConfig = get_site_option('wpmu-piwik_global-settings',false);
|
3 |
+
if (is_plugin_active_for_network('wp-piwik/wp-piwik.php') && $aryWPMUConfig) {
|
4 |
foreach ($aryWPMUConfig as $key => $value)
|
5 |
self::$settings->setGlobalOption($key, $value);
|
6 |
delete_site_option('wpmu-piwik_global-settings');
|
7 |
self::$settings->setGlobalOption('auto_site_config', true);
|
8 |
+
} else self::$settings->setGlobalOption('auto_site_config', false);
|
9 |
+
self::$settings->setGlobalOption('dashboard_seo', false);
|
10 |
+
self::$settings->setGlobalOption('stats_seo', false);
|
11 |
+
self::$settings->setGlobalOption('track_404', self::$settings->getOption('track_404'));
|
12 |
+
self::$settings->setGlobalOption('track_compress', false);
|
13 |
+
self::$settings->setGlobalOption('track_post', false);
|
update/90206.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$settings->setGlobalOption('disable_timelimit', false);
|
update/90405.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$settings->setGlobalOption('piwik_mode', 'http');
|
3 |
+
self::$settings->setGlobalOption('piwik_path', '');
|
4 |
+
self::$settings->setGlobalOption('toolbar', false);
|
5 |
+
self::$settings->setGlobalOption('disable_cookies', false);
|
update/90601.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$settings->setGlobalOption('piwik_useragent', 'php');
|
3 |
+
self::$settings->setGlobalOption('piwik_useragent_string', 'WP-Piwik');
|
update/90700.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$settings->setGlobalOption('shortcodes', false);
|
update/90801.php
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
<?php
|
|
|
|
|
2 |
if (self::$settings->getGlobalOption('track_compress'))
|
3 |
self::$settings->setGlobalOption('track_mode', 1);
|
4 |
else
|
1 |
<?php
|
2 |
+
self::$settings->setGlobalOption('track_search', false);
|
3 |
+
self::$settings->setGlobalOption('connection_timeout', 5);
|
4 |
if (self::$settings->getGlobalOption('track_compress'))
|
5 |
self::$settings->setGlobalOption('track_mode', 1);
|
6 |
else
|
update/90821.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$settings->setGlobalOption('track_cdnurl', '');
|
update/90910.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$settings->setGlobalOption('track_cdnurlssl', self::$settings->getGlobalOption('track_cdnurl'));
|
3 |
+
self::$settings->setGlobalOption('track_noscript', false);
|
update/90920.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$settings->setGlobalOption('plugin_display_name', 'WP-Piwik');
|
update/90940.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$settings->setGlobalOption('track_nojavascript', false);
|
update/90961.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$settings->setGlobalOption('cache', true);
|
update/90971.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$settings->setGlobalOption('track_admin', false);
|
3 |
+
self::$settings->setGlobalOption('perpost_stats', false);
|
update/90980.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$settings->setGlobalOption('track_feed', false);
|
3 |
+
self::$settings->setGlobalOption('track_feed_goal', false);
|
4 |
+
self::$settings->setGlobalOption('track_feed_revenue', false);
|
5 |
+
self::$settings->setGlobalOption('track_feed_campaign', 'feed');
|
6 |
+
self::$settings->setGlobalOption('track_feed_addcampaign', false);
|
update/91007.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
self::$settings->setGlobalOption('track_codeposition', 'footer');
|
update/index.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Nothing to see...
|
wp-piwik.php
CHANGED
@@ -6,12 +6,9 @@ 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 |
Author: André Bräkling
|
11 |
Author URI: http://www.braekling.de
|
12 |
-
Text Domain: wp-piwik
|
13 |
-
Domain Path: /languages/
|
14 |
-
License: GPL3
|
15 |
|
16 |
******************************************************************************************
|
17 |
Copyright (C) 2009-2015 Andre Braekling (email: webmaster@braekling.de)
|
@@ -36,39 +33,1520 @@ if (!function_exists ('add_action')) {
|
|
36 |
exit();
|
37 |
}
|
38 |
|
39 |
-
|
40 |
-
define('NAMESPACE_SEPARATOR', '\\');
|
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 |
-
if (
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
require_once(WP_PIWIK_PATH.'config.php');
|
70 |
-
require_once(WP_PIWIK_PATH.'classes'.DIRECTORY_SEPARATOR.'WP_Piwik.php');
|
71 |
-
spl_autoload_register('wp_piwik_autoloader');
|
72 |
-
if (class_exists('WP_Piwik'))
|
73 |
-
$GLOBALS['wp-piwik'] = new WP_Piwik();
|
74 |
-
}
|
6 |
|
7 |
Description: Adds Piwik stats to your dashboard menu and Piwik code to your wordpress header.
|
8 |
|
9 |
+
Version: 0.9.9.18
|
10 |
Author: André Bräkling
|
11 |
Author URI: http://www.braekling.de
|
|
|
|
|
|
|
12 |
|
13 |
******************************************************************************************
|
14 |
Copyright (C) 2009-2015 Andre Braekling (email: webmaster@braekling.de)
|
33 |
exit();
|
34 |
}
|
35 |
|
36 |
+
//require_once(ABSPATH.'wp-includes/pluggable.php');
|
|
|
37 |
|
38 |
+
if (!class_exists('wp_piwik')) {
|
39 |
+
class wp_piwik {
|
40 |
+
|
41 |
+
private static
|
42 |
+
$intRevisionId = 98004,
|
43 |
+
$strVersion = '0.9.9.18',
|
44 |
+
$blog_id,
|
45 |
+
$intDashboardID = 30,
|
46 |
+
$strPluginBasename = NULL,
|
47 |
+
$bolJustActivated = false,
|
48 |
+
$logger,
|
49 |
+
$settings;
|
50 |
+
|
51 |
+
private
|
52 |
+
$intStatsPage = NULL,
|
53 |
+
$bolNetwork = false,
|
54 |
+
$aryAttributes = array(),
|
55 |
+
$strResult = '';
|
56 |
+
|
57 |
+
public function __construct() {
|
58 |
+
global $blog_id;
|
59 |
+
self::$blog_id = (isset($blog_id)?$blog_id:'n/a');
|
60 |
+
$this->openLogger();
|
61 |
+
$this->openSettings();
|
62 |
+
$this->setup();
|
63 |
+
$this->addFilters();
|
64 |
+
$this->addActions();
|
65 |
+
$this->addShortcodes();
|
66 |
+
self::$settings->save();
|
67 |
+
}
|
68 |
+
|
69 |
+
public function __destruct() {
|
70 |
+
$this->closeLogger();
|
71 |
+
}
|
72 |
+
|
73 |
+
private function setup() {
|
74 |
+
self::$strPluginBasename = plugin_basename(__FILE__);
|
75 |
+
register_activation_hook(__FILE__, array($this, 'installPlugin'));
|
76 |
+
if ($this->isUpdated())
|
77 |
+
$this->upgradePlugin();
|
78 |
+
if ($this->isConfigSubmitted())
|
79 |
+
$this->applySettings();
|
80 |
+
if ($this->isPHPMode())
|
81 |
+
self::definePiwikConstants();
|
82 |
+
if (is_admin() || $this->isAddShortcode())
|
83 |
+
$this->loadLanguage();
|
84 |
+
}
|
85 |
+
|
86 |
+
private function addActions() {
|
87 |
+
if (is_admin()) {
|
88 |
+
add_action('admin_menu', array($this, 'buildAdminMenu'));
|
89 |
+
add_action('admin_post_save_wp-piwik_stats', array(&$this, 'onStatsPageSaveChanges'));
|
90 |
+
add_action('load-post.php', array(&$this, 'postMetaboxes'));
|
91 |
+
add_action('load-post-new.php', array(&$this, 'postMetaboxes'));
|
92 |
+
if ($this->isNetworkMode())
|
93 |
+
add_action('network_admin_menu', array($this, 'buildNetworkAdminMenu'));
|
94 |
+
if ($this->isDashboardActive())
|
95 |
+
add_action('wp_dashboard_setup', array($this, 'extendWordPressDashboard'));
|
96 |
+
if (self::$settings->getGlobalOption('add_post_annotations'))
|
97 |
+
add_action('transition_post_status', array($this, 'onPostStatusTransition'),10,3);
|
98 |
+
}
|
99 |
+
if ($this->isToolbarActive()) {
|
100 |
+
// is_admin_bar_showing() would be great to use, but it will break P3 Plugin Performance Profiler (https://wordpress.org/plugins/p3-profiler/)
|
101 |
+
add_action(is_admin()?'admin_head':'wp_head', array($this, 'loadToolbarRequirements'));
|
102 |
+
add_action('admin_bar_menu', array(&$this, 'extendWordPressToolbar'), 1000);
|
103 |
+
}
|
104 |
+
if ($this->isTrackingActive()) {
|
105 |
+
if (!is_admin()) {
|
106 |
+
add_action(self::$settings->getGlobalOption('track_codeposition') == 'footer'?'wp_footer':'wp_head', array($this, 'addJavascriptCode'));
|
107 |
+
if ($this->isAddNoScriptCode())
|
108 |
+
add_action('wp_footer', array($this, 'addNoscriptCode'));
|
109 |
+
}
|
110 |
+
else {
|
111 |
+
if ($this->isAdminTrackingActive())
|
112 |
+
add_action('admin_head', array($this, 'addAdminHeaderTracking'));
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
private function addFilters() {
|
118 |
+
if (is_admin()) {
|
119 |
+
add_filter('plugin_row_meta', array($this, 'setPluginMeta'), 10, 2);
|
120 |
+
add_filter('screen_layout_columns', array(&$this, 'onScreenLayoutColumns'), 10, 2);
|
121 |
+
}
|
122 |
+
else {
|
123 |
+
if ($this->isTrackingActive()) {
|
124 |
+
if ($this->isTrackFeed()) {
|
125 |
+
add_filter('the_excerpt_rss', array(&$this, 'addFeedTracking'));
|
126 |
+
add_filter('the_content', array(&$this, 'addFeedTracking'));
|
127 |
+
}
|
128 |
+
if ($this->isAddFeedCampaign())
|
129 |
+
add_filter('post_link', array(&$this, 'addFeedCampaign'));
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
private function addShortcodes() {
|
135 |
+
if ($this->isAddShortcode())
|
136 |
+
add_shortcode('wp-piwik', array(&$this, 'shortcode'));
|
137 |
+
}
|
138 |
+
|
139 |
+
private function loadLanguage() {
|
140 |
+
load_plugin_textdomain('wp-piwik', false, dirname(self::$strPluginBasename)."/languages/");
|
141 |
+
}
|
142 |
+
|
143 |
+
function installPlugin() {
|
144 |
+
self::$logger->log('Running WP-Piwik installation');
|
145 |
+
add_action('admin_notices', array($this, 'updateMessage'));
|
146 |
+
self::$bolJustActivated = true;
|
147 |
+
self::$settings->setGlobalOption('revision', self::$intRevisionId);
|
148 |
+
self::$settings->setGlobalOption('last_settings_update', time());
|
149 |
+
}
|
150 |
+
|
151 |
+
static function uninstallPlugin() {
|
152 |
+
self::$logger->log('Running WP-Piwik uninstallation');
|
153 |
+
if (!defined('WP_UNINSTALL_PLUGIN'))
|
154 |
+
exit();
|
155 |
+
self::$settings->resetSettings(true);
|
156 |
+
}
|
157 |
+
|
158 |
+
function upgradePlugin() {
|
159 |
+
self::$logger->log('Upgrade WP-Piwik to '.self::$strVersion);
|
160 |
+
add_action('admin_notices', array($this, 'updateMessage'));
|
161 |
+
$patches = glob(dirname(__FILE__).DIRECTORY_SEPARATOR.'update'.DIRECTORY_SEPARATOR.'*.php');
|
162 |
+
if (is_array($patches)) {
|
163 |
+
sort($patches);
|
164 |
+
foreach ($patches as $patch) {
|
165 |
+
$patchVersion = (int) pathinfo($patch, PATHINFO_FILENAME);
|
166 |
+
if ($patchVersion && self::$settings->getGlobalOption('revision') < $patchVersion)
|
167 |
+
self::includeFile('update'.DIRECTORY_SEPARATOR.$patchVersion);
|
168 |
+
}
|
169 |
+
}
|
170 |
+
$this->installPlugin();
|
171 |
+
}
|
172 |
+
|
173 |
+
function updateMessage() {
|
174 |
+
$text = sprintf(__('%s %s installed.', 'wp-piwik'), self::$settings->getGlobalOption('plugin_display_name'), self::$strVersion);
|
175 |
+
$notice = (!self::isConfigured()?
|
176 |
+
__('Next you should connect to Piwik','wp-piwik'):
|
177 |
+
__('Please validate your configuration','wp-piwik')
|
178 |
+
);
|
179 |
+
$link = sprintf('<a href="'.$this->getSettingsURL().'?page=%s">%s</a>', self::$strPluginBasename, __('Settings', 'wp-piwik'));
|
180 |
+
printf('<div class="updated fade"><p>%s<strong>%s:</strong> %s: %s</p></div>', $text, __('Important', 'wp-piwik'), $notice, $link);
|
181 |
+
}
|
182 |
+
|
183 |
+
function getSettingsURL() {
|
184 |
+
return (self::$settings->checkNetworkActivation()?'settings':'options-general').'.php';
|
185 |
+
}
|
186 |
+
|
187 |
+
private function updateTrackingCode() {
|
188 |
+
if (!self::$settings->getOption('site_id') || !self::$settings->getOption('tracking_code'))
|
189 |
+
$this->addPiwikSite();
|
190 |
+
if ($this->isCurrentTrackingCode()) {
|
191 |
+
self::$settings->setOption('tracking_code', $this->callPiwikAPI('SitesManager.getJavascriptTag'));
|
192 |
+
self::$settings->save();
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
/* -- </REFACTORED><OLD> -- */
|
197 |
+
|
198 |
+
function addJavascriptCode() {
|
199 |
+
if ($this->isHiddenUser()) {
|
200 |
+
self::$logger->log('Do not add tracking code to site header (user should not be tracked) Blog ID: '.self::$blog_id.' Site ID: '.self::$settings->getOption('site_id'));
|
201 |
+
return;
|
202 |
+
}
|
203 |
+
$this->updateTrackingCode();
|
204 |
+
|
205 |
+
// Change code if 404
|
206 |
+
if (is_404() && self::$settings->getGlobalOption('track_404')) {
|
207 |
+
self::$logger->log('Apply 404 changes. Blog ID: '.self::$blog_id.' Site ID: '.self::$settings->getOption('site_id'));
|
208 |
+
$strTrackingCode = str_replace("_paq.push(['trackPageView']);", "_paq.push(['setDocumentTitle', '404/URL = '+String(document.location.pathname+document.location.search).replace(/\//g,'%2f') + '/From = ' + String(document.referrer).replace(/\//g,'%2f')]);\n_paq.push(['trackPageView']);", self::$settings->getOption('tracking_code'));
|
209 |
+
}
|
210 |
+
// Change code if search result
|
211 |
+
elseif (is_search() && self::$settings->getGlobalOption('track_search')) {
|
212 |
+
self::$logger->log('Apply search tracking changes. Blog ID: '.self::$blog_id.' Site ID: '.self::$settings->getOption('site_id'));
|
213 |
+
$objSearch = new WP_Query("s=" . get_search_query() . '&showposts=-1');
|
214 |
+
$intResultCount = $objSearch->post_count;
|
215 |
+
$strTrackingCode = str_replace("_paq.push(['trackPageView']);", "_paq.push(['trackSiteSearch','".get_search_query()."', false, ".$intResultCount."]);\n_paq.push(['trackPageView']);", self::$settings->getOption('tracking_code'));
|
216 |
+
// Use default tracking code
|
217 |
+
} else
|
218 |
+
$strTrackingCode = self::$settings->getOption('tracking_code');
|
219 |
+
// Send tracking code
|
220 |
+
self::$logger->log('Add tracking code. Blog ID: '.self::$blog_id.' Site ID: '.self::$settings->getOption('site_id'));
|
221 |
+
// Add custom variables if set:
|
222 |
+
if (is_single()) {
|
223 |
+
$strCustomVars = '';
|
224 |
+
for ($i = 1; $i <= 5; $i++) {
|
225 |
+
// Get post ID
|
226 |
+
$intID = get_the_ID();
|
227 |
+
// Get key
|
228 |
+
$strMetaKey = get_post_meta($intID, 'wp-piwik_custom_cat'.$i, true);
|
229 |
+
// Get value
|
230 |
+
$strMetaVal = get_post_meta($intID, 'wp-piwik_custom_val'.$i, true);
|
231 |
+
if (!empty($strMetaKey) && !empty($strMetaVal))
|
232 |
+
$strCustomVars .= "_paq.push(['setCustomVariable',".$i.", '".$strMetaKey."', '".$strMetaVal."', 'page']);\n";
|
233 |
+
}
|
234 |
+
if (!empty($strCustomVars)) $strTrackingCode = str_replace("_paq.push(['trackPageView']);", $strCustomVars."_paq.push(['trackPageView']);", $strTrackingCode);
|
235 |
+
}
|
236 |
+
echo $strTrackingCode;
|
237 |
+
$strName = get_bloginfo('name');
|
238 |
+
if (self::$settings->getOption('name') != $strName)
|
239 |
+
$this->updatePiwikSite();
|
240 |
+
}
|
241 |
+
|
242 |
+
function addNoscriptCode() {
|
243 |
+
// Hotfix: Custom capability problem with WP multisite
|
244 |
+
if (is_multisite()) {
|
245 |
+
foreach (self::$settings->getGlobalOption('capability_stealth') as $strKey => $strVal)
|
246 |
+
if ($strVal && current_user_can($strKey))
|
247 |
+
return;
|
248 |
+
// Don't add tracking code?
|
249 |
+
} elseif (current_user_can('wp-piwik_stealth')) return;
|
250 |
+
// Send tracking code
|
251 |
+
self::$logger->log('Add noscript code. Blog ID: '.self::$blog_id.' Site ID: '.self::$settings->getOption('site_id'));
|
252 |
+
echo self::$settings->getOption('noscript_code')."\n";
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Shortcode function
|
257 |
+
**/
|
258 |
+
|
259 |
+
function shortcode($aryAttributes) {
|
260 |
+
$this->aryAttributes = shortcode_atts(
|
261 |
+
array(
|
262 |
+
'title' => '',
|
263 |
+
'module' => 'overview',
|
264 |
+
'period' => 'day',
|
265 |
+
'date' => 'yesterday',
|
266 |
+
'limit' => 10,
|
267 |
+
'width' => '100%',
|
268 |
+
'height' => '200px',
|
269 |
+
'language' => 'en',
|
270 |
+
'range' => false,
|
271 |
+
'key' => 'sum_daily_nb_uniq_visitors'
|
272 |
+
), $aryAttributes);
|
273 |
+
switch ($this->aryAttributes['module']) {
|
274 |
+
case 'opt-out':
|
275 |
+
$this->strResult = '<iframe frameborder="no" width="'.$this->aryAttributes['width'].'" height="'.$this->aryAttributes['height'].'" src="'.self::$settings->getGlobalOption('piwik_url').'index.php?module=CoreAdminHome&action=optOut&language='.$this->aryAttributes['language'].'"></iframe>';
|
276 |
+
break;
|
277 |
+
case 'post':
|
278 |
+
self::includeFile('shortcodes/post');
|
279 |
+
break;
|
280 |
+
case 'overview':
|
281 |
+
default:
|
282 |
+
self::includeFile('shortcodes/overview');
|
283 |
+
}
|
284 |
+
return $this->strResult;
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Add metaboxes to posts
|
289 |
+
*/
|
290 |
+
function postMetaboxes() {
|
291 |
+
if (self::$settings->getGlobalOption('add_customvars_box')) {
|
292 |
+
add_action('add_meta_boxes', array(&$this, 'postAddMetaboxes'));
|
293 |
+
add_action('save_post', array(&$this, 'postCustomvarsSave'), 10, 2);
|
294 |
+
}
|
295 |
+
// Show per post stats if enabled
|
296 |
+
if (self::$settings->getGlobalOption('perpost_stats')) {
|
297 |
+
$this->includeFile('classes/WP_Piwik_MetaBox_PerPost_Stats');
|
298 |
+
add_action('add_meta_boxes', array(new WP_Piwik_MetaBox_PerPost_Stats($this->subClassConfig()), 'addMetabox'));
|
299 |
+
}
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Create post meta boxes
|
304 |
+
*/
|
305 |
+
function postAddMetaboxes() {
|
306 |
+
add_meta_box(
|
307 |
+
'wp-piwik_post_customvars',
|
308 |
+
__('Piwik Custom Variables', 'wp-piwik'),
|
309 |
+
array(&$this, 'postCustomvars'),
|
310 |
+
'post',
|
311 |
+
'side',
|
312 |
+
'default'
|
313 |
+
);
|
314 |
+
}
|
315 |
+
|
316 |
+
/**
|
317 |
+
* Display custom variables meta box
|
318 |
+
*/
|
319 |
+
function postCustomvars($objPost, $objBox ) {
|
320 |
+
wp_nonce_field(basename( __FILE__ ), 'wp-piwik_post_customvars_nonce'); ?>
|
321 |
+
<table>
|
322 |
+
<tr><th></th><th><?php _e('Name', 'wp-piwik'); ?></th><th><?php _e('Value', 'wp-piwik'); ?></th></tr>
|
323 |
+
<?php for($i = 1; $i <= 5; $i++) { ?>
|
324 |
+
<tr>
|
325 |
+
<th><label for="wp-piwik_customvar1"><?php echo $i; ?>: </label></th>
|
326 |
+
<td><input class="widefat" type="text" name="wp-piwik_custom_cat<?php echo $i; ?>" value="<?php echo esc_attr(get_post_meta($objPost->ID, 'wp-piwik_custom_cat'.$i, true ) ); ?>" size="200" /></td>
|
327 |
+
<td><input class="widefat" type="text" name="wp-piwik_custom_val<?php echo $i; ?>" value="<?php echo esc_attr(get_post_meta($objPost->ID, 'wp-piwik_custom_val'.$i, true ) ); ?>" size="200" /></td>
|
328 |
+
</tr>
|
329 |
+
<?php } ?>
|
330 |
+
</table>
|
331 |
+
<p><?php _e('Set custom variables for a page view', 'wp-piwik'); ?>. (<a href="http://piwik.org/docs/custom-variables/"><?php _e('More information', 'wp-piwik'); ?></a>.)</p>
|
332 |
+
<?php
|
333 |
+
}
|
334 |
+
|
335 |
+
/**
|
336 |
+
* Save post custom variables
|
337 |
+
*/
|
338 |
+
function postCustomvarsSave($intID, $objPost) {
|
339 |
+
// Verify the nonce before proceeding.
|
340 |
+
if (!isset( $_POST['wp-piwik_post_customvars_nonce'] ) || !wp_verify_nonce( $_POST['wp-piwik_post_customvars_nonce'], basename( __FILE__ ) ) )
|
341 |
+
return $intID;
|
342 |
+
// Get post type object
|
343 |
+
$objPostType = get_post_type_object($objPost->post_type);
|
344 |
+
// Check if the current user has permission to edit the post.
|
345 |
+
if (!current_user_can($objPostType->cap->edit_post, $intID))
|
346 |
+
return $intID;
|
347 |
+
$aryNames = array('cat', 'val');
|
348 |
+
for ($i = 1; $i <= 5; $i++)
|
349 |
+
for ($j = 0; $j <= 1; $j++) {
|
350 |
+
// Get data
|
351 |
+
$strMetaVal = (isset($_POST['wp-piwik_custom_'.$aryNames[$j].$i])?htmlentities($_POST['wp-piwik_custom_'.$aryNames[$j].$i]):'');
|
352 |
+
// Create key
|
353 |
+
$strMetaKey = 'wp-piwik_custom_'.$aryNames[$j].$i;
|
354 |
+
// Get the meta value of the custom field key
|
355 |
+
$strCurVal = get_post_meta($intID, $strMetaKey, true);
|
356 |
+
// Add meta val:
|
357 |
+
if ($strMetaVal && '' == $strCurVal)
|
358 |
+
add_post_meta($intID, $strMetaKey, $strMetaVal, true);
|
359 |
+
// Update meta val:
|
360 |
+
elseif ($strMetaVal && $strMetaVal != $strCurVal)
|
361 |
+
update_post_meta($intID, $strMetaKey, $strMetaVal);
|
362 |
+
// Delete meta val:
|
363 |
+
elseif (''==$strMetaVal && $strCurVal)
|
364 |
+
delete_post_meta($intID, $strMetaKey, $strCurVal);
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Add pages to admin menu
|
370 |
+
*/
|
371 |
+
function buildAdminMenu() {
|
372 |
+
// Show stats dashboard page if WP-Piwik is configured
|
373 |
+
if (self::isConfigured()) {
|
374 |
+
// Add dashboard page
|
375 |
+
$this->intStatsPage = add_dashboard_page(
|
376 |
+
__('Piwik Statistics', 'wp-piwik'),
|
377 |
+
self::$settings->getGlobalOption('plugin_display_name'),
|
378 |
+
'wp-piwik_read_stats',
|
379 |
+
'wp-piwik_stats',
|
380 |
+
array($this, 'showStats')
|
381 |
+
);
|
382 |
+
// Add required scripts
|
383 |
+
add_action('admin_print_scripts-'.$this->intStatsPage, array($this, 'loadStatsScripts'));
|
384 |
+
// Add required styles
|
385 |
+
add_action('admin_print_styles-'.$this->intStatsPage, array($this, 'addAdminStyle'));
|
386 |
+
// Add required header tags
|
387 |
+
add_action('admin_head-'.$this->intStatsPage, array($this, 'addAdminHeaderStats'));
|
388 |
+
// Stats page onload callback
|
389 |
+
add_action('load-'.$this->intStatsPage, array(&$this, 'onloadStatsPage'));
|
390 |
+
}
|
391 |
+
if (!self::$settings->checkNetworkActivation()) {
|
392 |
+
// Add options page
|
393 |
+
$intOptionsPage = add_options_page(
|
394 |
+
self::$settings->getGlobalOption('plugin_display_name'),
|
395 |
+
self::$settings->getGlobalOption('plugin_display_name'),
|
396 |
+
'activate_plugins',
|
397 |
+
__FILE__,
|
398 |
+
array($this, 'showSettings')
|
399 |
+
);
|
400 |
+
// Add required scripts
|
401 |
+
add_action('admin_print_scripts-'.$this->intStatsPage, array($this, 'loadSettingsScripts'));
|
402 |
+
// Add required header tags
|
403 |
+
add_action('admin_head-'.$intOptionsPage, array($this, 'addAdminHeaderSettings'));
|
404 |
+
// Add styles required by options page
|
405 |
+
add_action('admin_print_styles-'.$intOptionsPage, array($this, 'addAdminStyle'));
|
406 |
+
}
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Add pages to network admin menu
|
411 |
+
*/
|
412 |
+
function buildNetworkAdminMenu() {
|
413 |
+
// Show stats dashboard page if WP-Piwik is configured
|
414 |
+
if (self::isConfigured()) {
|
415 |
+
// Add dashboard page
|
416 |
+
$this->intStatsPage = add_dashboard_page(
|
417 |
+
__('Piwik Statistics', 'wp-piwik'),
|
418 |
+
self::$settings->getGlobalOption('plugin_display_name'),
|
419 |
+
'manage_sites',
|
420 |
+
'wp-piwik_stats',
|
421 |
+
array($this, 'showStatsNetwork')
|
422 |
+
);
|
423 |
+
// Add required scripts
|
424 |
+
add_action('admin_print_scripts-'.$this->intStatsPage, array($this, 'loadStatsScripts'));
|
425 |
+
// Add required styles
|
426 |
+
add_action('admin_print_styles-'.$this->intStatsPage, array($this, 'addAdminStyle'));
|
427 |
+
// Add required header tags
|
428 |
+
add_action('admin_head-'.$this->intStatsPage, array($this, 'addAdminHeaderStats'));
|
429 |
+
// Stats page onload callback
|
430 |
+
add_action('load-'.$this->intStatsPage, array(&$this, 'onloadStatsPage'));
|
431 |
+
}
|
432 |
+
$intOptionsPage = add_submenu_page(
|
433 |
+
'settings.php',
|
434 |
+
self::$settings->getGlobalOption('plugin_display_name'),
|
435 |
+
self::$settings->getGlobalOption('plugin_display_name'),
|
436 |
+
'manage_sites',
|
437 |
+
__FILE__,
|
438 |
+
array($this, 'showSettings')
|
439 |
+
);
|
440 |
+
|
441 |
+
// Add styles required by options page
|
442 |
+
add_action('admin_print_styles-'.$intOptionsPage, array($this, 'addAdminStyle'));
|
443 |
+
add_action('admin_head-'.$intOptionsPage, array($this, 'addAdminHeaderSettings'));
|
444 |
+
}
|
445 |
+
|
446 |
+
/**
|
447 |
+
* Support two columns
|
448 |
+
* seen in Heiko Rabe's metabox demo plugin
|
449 |
+
*
|
450 |
+
* @see http://tinyurl.com/5r5vnzs
|
451 |
+
*/
|
452 |
+
function onScreenLayoutColumns($aryColumns, $strScreen) {
|
453 |
+
if ($strScreen == $this->intStatsPage)
|
454 |
+
$aryColumns[$this->intStatsPage] = 3;
|
455 |
+
return $aryColumns;
|
456 |
+
}
|
457 |
+
|
458 |
+
/**
|
459 |
+
* Add widgets to WordPress dashboard
|
460 |
+
*/
|
461 |
+
function extendWordPressDashboard() {
|
462 |
+
// Is user allowed to see stats?
|
463 |
+
if (current_user_can('wp-piwik_read_stats')) {
|
464 |
+
// TODO: Use bitmask here
|
465 |
+
// Add data widget if enabled
|
466 |
+
if (self::$settings->getGlobalOption('dashboard_widget'))
|
467 |
+
$this->addWordPressDashboardWidget();
|
468 |
+
// Add chart widget if enabled
|
469 |
+
if (self::$settings->getGlobalOption('dashboard_chart')) {
|
470 |
+
// Add required scripts
|
471 |
+
add_action('admin_print_scripts-index.php', array($this, 'loadStatsScripts'));
|
472 |
+
// Add required styles
|
473 |
+
add_action('admin_print_styles-index.php', array($this, 'addAdminStyle'));
|
474 |
+
// Add required header tags
|
475 |
+
add_action('admin_head-index.php', array($this, 'addAdminHeaderStats'));
|
476 |
+
$this->addWordPressDashboardChart();
|
477 |
+
}
|
478 |
+
// Add SEO widget if enabled
|
479 |
+
if (self::$settings->getGlobalOption('dashboard_seo'))
|
480 |
+
$this->addWordPressDashboardSEO();
|
481 |
+
}
|
482 |
+
}
|
483 |
+
|
484 |
+
/**
|
485 |
+
* Add widgets to WordPress Toolbar
|
486 |
+
*/
|
487 |
+
public function extendWordPressToolbar(&$objToolbar) {
|
488 |
+
// Is user allowed to see stats?
|
489 |
+
if (current_user_can('wp-piwik_read_stats') && is_admin_bar_showing()) {
|
490 |
+
$aryUnique = $this->callPiwikAPI('VisitsSummary.getUniqueVisitors','day','last30',null);
|
491 |
+
if (!is_array($aryUnique)) $aryUnique = array();
|
492 |
+
$strGraph = '<script type="text/javascript">';
|
493 |
+
$strGraph .= "var \$jSpark = jQuery.noConflict();\$jSpark(function() {var piwikSparkVals=[".implode(',',$aryUnique)."];\$jSpark('.wp-piwik_dynbar').sparkline(piwikSparkVals, {type: 'bar', barColor: '#ccc', barWidth:2});});";
|
494 |
+
$strGraph .= '</script>';
|
495 |
+
$strGraph .= '<span class="wp-piwik_dynbar">Loading...</span>';
|
496 |
+
$objToolbar->add_menu(array(
|
497 |
+
'id' => 'wp-piwik_stats',
|
498 |
+
'title' => $strGraph,
|
499 |
+
'href' => admin_url().'?page=wp-piwik_stats'
|
500 |
+
));
|
501 |
+
}
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Add a data widget to the WordPress dashboard
|
506 |
+
*/
|
507 |
+
function addWordPressDashboardWidget() {
|
508 |
+
$aryConfig = array(
|
509 |
+
'params' => array('period' => 'day','date' => self::$settings->getGlobalOption('dashboard_widget'),'limit' => null),
|
510 |
+
'inline' => true,
|
511 |
+
);
|
512 |
+
$strFile = 'overview';
|
513 |
+
add_meta_box(
|
514 |
+
'wp-piwik_stats-dashboard-overview',
|
515 |
+
self::$settings->getGlobalOption('plugin_display_name').' - '.__(self::$settings->getGlobalOption('dashboard_widget'), 'wp-piwik'),
|
516 |
+
array(&$this, 'createDashboardWidget'),
|
517 |
+
'dashboard',
|
518 |
+
'side',
|
519 |
+
'high',
|
520 |
+
array('strFile' => $strFile, 'aryConfig' => $aryConfig)
|
521 |
+
);
|
522 |
+
}
|
523 |
+
|
524 |
+
/**
|
525 |
+
* Add a visitor chart to the WordPress dashboard
|
526 |
+
*/
|
527 |
+
function addWordPressDashboardChart() {
|
528 |
+
$aryConfig = array(
|
529 |
+
'params' => array('period' => 'day','date' => 'last30','limit' => null),
|
530 |
+
'inline' => true,
|
531 |
+
);
|
532 |
+
$strFile = 'visitors';
|
533 |
+
add_meta_box(
|
534 |
+
'wp-piwik_stats-dashboard-chart',
|
535 |
+
self::$settings->getGlobalOption('plugin_display_name').' - '.__('Visitors', 'wp-piwik'),
|
536 |
+
array(&$this, 'createDashboardWidget'),
|
537 |
+
'dashboard',
|
538 |
+
'side',
|
539 |
+
'high',
|
540 |
+
array('strFile' => $strFile, 'aryConfig' => $aryConfig)
|
541 |
+
);
|
542 |
+
}
|
543 |
+
|
544 |
+
/**
|
545 |
+
* Add a SEO widget to the WordPress dashboard
|
546 |
+
*/
|
547 |
+
function addWordPressDashboardSEO() {
|
548 |
+
$aryConfig = array(
|
549 |
+
'params' => array('period' => 'day','date' => 'today','limit' => null),
|
550 |
+
'inline' => true,
|
551 |
+
);
|
552 |
+
$strFile = 'seo';
|
553 |
+
add_meta_box(
|
554 |
+
'wp-piwik_stats-dashboard-seo',
|
555 |
+
self::$settings->getGlobalOption('plugin_display_name').' - '.__('SEO', 'wp-piwik'),
|
556 |
+
array(&$this, 'createDashboardWidget'),
|
557 |
+
'dashboard',
|
558 |
+
'side',
|
559 |
+
'high',
|
560 |
+
array('strFile' => $strFile, 'aryConfig' => $aryConfig)
|
561 |
+
);
|
562 |
+
}
|
563 |
+
|
564 |
+
/**
|
565 |
+
* Add plugin meta links to plugin details
|
566 |
+
*
|
567 |
+
* @see http://wpengineer.com/1295/meta-links-for-wordpress-plugins/
|
568 |
+
*/
|
569 |
+
function setPluginMeta($strLinks, $strFile) {
|
570 |
+
// Get plugin basename
|
571 |
+
$strPlugin = plugin_basename(__FILE__);
|
572 |
+
// Add link just to this plugin's details
|
573 |
+
if ($strFile == self::$strPluginBasename)
|
574 |
+
return array_merge(
|
575 |
+
$strLinks,
|
576 |
+
array(
|
577 |
+
sprintf('<a href="'.(self::$settings->checkNetworkActivation()?'settings':'options-general').'.php?page=%s">%s</a>', self::$strPluginBasename, __('Settings', 'wp-piwik'))
|
578 |
+
)
|
579 |
+
);
|
580 |
+
// Don't affect other plugins details
|
581 |
+
return $strLinks;
|
582 |
+
}
|
583 |
+
|
584 |
+
/**
|
585 |
+
* Load required scripts to stats page
|
586 |
+
*/
|
587 |
+
function loadStatsScripts() {
|
588 |
+
// Load WP-Piwik script
|
589 |
+
wp_enqueue_script('wp-piwik', $this->getPluginURL().'js/wp-piwik.js', array(), self::$strVersion, true);
|
590 |
+
// Load jqPlot
|
591 |
+
wp_enqueue_script('wp-piwik-jqplot',$this->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
|
592 |
+
}
|
593 |
+
|
594 |
+
/**
|
595 |
+
* Load scripts required by Toolbar graphs
|
596 |
+
*/
|
597 |
+
function loadToolbarRequirements() {
|
598 |
+
// Only load if user is allowed to see stats
|
599 |
+
if (current_user_can('wp-piwik_read_stats') && is_admin_bar_showing()) {
|
600 |
+
// Load Sparklines
|
601 |
+
wp_enqueue_script('wp-piwik-sparkline',$this->getPluginURL().'js/sparkline/jquery.sparkline.min.js',array('jquery'),'2.1.1');
|
602 |
+
// Load CSS
|
603 |
+
wp_enqueue_style('wp-piwik', $this->getPluginURL().'css/wp-piwik-spark.css');
|
604 |
+
}
|
605 |
+
}
|
606 |
+
|
607 |
+
/**
|
608 |
+
* Load required scripts to settings page
|
609 |
+
*/
|
610 |
+
function loadSettingsScripts() {
|
611 |
+
wp_enqueue_script('jquery');
|
612 |
+
}
|
613 |
+
|
614 |
+
/**
|
615 |
+
* Load required styles to admin pages
|
616 |
+
*/
|
617 |
+
function addAdminStyle() {
|
618 |
+
// Load WP-Piwik styles
|
619 |
+
wp_enqueue_style('wp-piwik', $this->getPluginURL().'css/wp-piwik.css',array(),self::$strVersion);
|
620 |
+
}
|
621 |
+
|
622 |
+
/**
|
623 |
+
* Add tracking code to admin header
|
624 |
+
*/
|
625 |
+
function addAdminHeaderTracking() {
|
626 |
+
$this->site_header();
|
627 |
+
}
|
628 |
+
|
629 |
+
/**
|
630 |
+
* Add tracking image to feeds
|
631 |
+
**/
|
632 |
+
function addFeedTracking($content) {
|
633 |
+
global $post;
|
634 |
+
if(is_feed()) {
|
635 |
+
self::$logger->log('Add tracking image to feed entry.');
|
636 |
+
if (!self::$settings->getOption('site_id'))
|
637 |
+
self::addPiwikSite();
|
638 |
+
$title = the_title(null,null,false);
|
639 |
+
$posturl = get_permalink($post->ID);
|
640 |
+
$urlref = get_bloginfo('rss2_url');
|
641 |
+
$url = self::$settings->getGlobalOption('piwik_url');
|
642 |
+
if (substr($url, -10, 10) == '/index.php')
|
643 |
+
$url = str_replace('/index.php', '/piwik.php', $url);
|
644 |
+
else $url .= 'piwik.php';
|
645 |
+
$trackingImage = $url.'?idsite='.self::$settings->getOption('site_id').'&rec=1'.
|
646 |
+
'&url='.urlencode($posturl).
|
647 |
+
'&action_name='.urlencode($title).
|
648 |
+
'&urlref='.urlencode($urlref);
|
649 |
+
$content .= '<img src="'.$trackingImage.'" style="border:0;width:0;height:0" width="0" height="0" alt="" />';
|
650 |
+
}
|
651 |
+
return $content;
|
652 |
+
}
|
653 |
+
|
654 |
+
/**
|
655 |
+
* Add tracking image to feeds
|
656 |
+
**/
|
657 |
+
function addFeedCampaign($permalink) {
|
658 |
+
global $post;
|
659 |
+
if(is_feed()) {
|
660 |
+
self::$logger->log('Add campaign to feed permalink.');
|
661 |
+
$sep = (strpos($permalink, '?') === false?'?':'&');
|
662 |
+
$permalink .= $sep.'pk_campaign='.urlencode(self::$settings->getGlobalOption('track_feed_campaign')).'&pk_kwd='.urlencode($post->post_name);
|
663 |
+
}
|
664 |
+
return $permalink;
|
665 |
+
}
|
666 |
+
|
667 |
+
function addPiwikAnnotation($postID) {
|
668 |
+
$this->callPiwikAPI('Annotations.add', '', date('Y-m-d'), '', false, false, 'PHP', '', false, 'Published: '.get_post($postID)->post_title.' - URL: '.get_permalink($postID));
|
669 |
+
}
|
670 |
+
|
671 |
+
/**
|
672 |
+
* Add required header tags to stats page
|
673 |
+
*/
|
674 |
+
function addAdminHeaderStats() {
|
675 |
+
// Load jqPlot IE compatibility script
|
676 |
+
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.$this->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
|
677 |
+
// Load jqPlot styles
|
678 |
+
echo '<link rel="stylesheet" href="'.$this->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
|
679 |
+
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
|
680 |
+
}
|
681 |
+
|
682 |
+
/**
|
683 |
+
* Add required header tags to settings page
|
684 |
+
*/
|
685 |
+
function addAdminHeaderSettings() {
|
686 |
+
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
|
687 |
+
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>';
|
688 |
+
}
|
689 |
+
|
690 |
+
/**
|
691 |
+
* Get this plugin's URL
|
692 |
+
*/
|
693 |
+
function getPluginURL() {
|
694 |
+
// Return plugins URL + /wp-piwik/
|
695 |
+
return trailingslashit(plugins_url().'/wp-piwik/');
|
696 |
+
}
|
697 |
+
|
698 |
+
/**
|
699 |
+
* Call REST API
|
700 |
+
*
|
701 |
+
* @param $strURL Remote file URL
|
702 |
+
*/
|
703 |
+
function callREST($strURL) {
|
704 |
+
$strPiwikURL = self::$settings->getGlobalOption('piwik_url');
|
705 |
+
if (substr($strPiwikURL, -1, 1) != '/') $strPiwikURL .= '/';
|
706 |
+
$strURL = $strPiwikURL.'?module=API'.$strURL;
|
707 |
+
// Use cURL if available
|
708 |
+
if (function_exists('curl_init')) {
|
709 |
+
// Init cURL
|
710 |
+
$c = curl_init($strURL);
|
711 |
+
// Disable SSL peer verification if asked to
|
712 |
+
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, !self::$settings->getGlobalOption('disable_ssl_verify'));
|
713 |
+
// Set user agent
|
714 |
+
curl_setopt($c, CURLOPT_USERAGENT, self::$settings->getGlobalOption('piwik_useragent')=='php'?ini_get('user_agent'):self::$settings->getGlobalOption('piwik_useragent_string'));
|
715 |
+
// Configure cURL CURLOPT_RETURNTRANSFER = 1
|
716 |
+
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
|
717 |
+
// Configure cURL CURLOPT_HEADER = 0
|
718 |
+
curl_setopt($c, CURLOPT_HEADER, 0);
|
719 |
+
// Set cURL timeout
|
720 |
+
curl_setopt($c, CURLOPT_TIMEOUT, self::$settings->getGlobalOption('connection_timeout'));
|
721 |
+
$httpProxyClass = new WP_HTTP_Proxy();
|
722 |
+
if ($httpProxyClass->is_enabled() && $httpProxyClass->send_through_proxy($strURL)) {
|
723 |
+
curl_setopt($c, CURLOPT_PROXY, $httpProxyClass->host());
|
724 |
+
curl_setopt($c, CURLOPT_PROXYPORT, $httpProxyClass->port());
|
725 |
+
if ($httpProxyClass->use_authentication())
|
726 |
+
curl_setopt($c, CURLOPT_PROXYUSERPWD, $httpProxyClass->username().':'.$httpProxyClass->password());
|
727 |
+
}
|
728 |
+
// Get result
|
729 |
+
$strResult = curl_exec($c);
|
730 |
+
// Close connection
|
731 |
+
curl_close($c);
|
732 |
+
// cURL not available but url fopen allowed
|
733 |
+
} elseif (ini_get('allow_url_fopen')) {
|
734 |
+
// Set timeout
|
735 |
+
$resContext = stream_context_create(array('http'=>array('timeout' => self::$settings->getGlobalOption('connection_timeout'))));
|
736 |
+
// Get file using file_get_contents
|
737 |
+
$strResult = @file_get_contents($strURL, false, $strContext);
|
738 |
+
// Error: Not possible to get remote file
|
739 |
+
} else $strResult = serialize(array(
|
740 |
+
'result' => 'error',
|
741 |
+
'message' => 'Remote access to Piwik not possible. Enable allow_url_fopen or CURL.'
|
742 |
+
));
|
743 |
+
// Return result
|
744 |
+
return $strResult;
|
745 |
+
}
|
746 |
+
|
747 |
+
/**
|
748 |
+
* Call PHP API
|
749 |
+
*
|
750 |
+
* @param $strParams API call params
|
751 |
+
*/
|
752 |
+
function callPHP($strParams) {
|
753 |
+
if (!defined('PIWIK_INCLUDE_PATH'))
|
754 |
+
return;
|
755 |
+
if (PIWIK_INCLUDE_PATH === FALSE)
|
756 |
+
return serialize(array('result' => 'error', 'message' => __('Could not resolve','wp-piwik').' "'.htmlentities(self::$settings->getGlobalOption('piwik_path')).'": '.__('realpath() returns false','wp-piwik').'.'));
|
757 |
+
if (file_exists(PIWIK_INCLUDE_PATH . "/index.php"))
|
758 |
+
require_once PIWIK_INCLUDE_PATH . "/index.php";
|
759 |
+
if (file_exists(PIWIK_INCLUDE_PATH . "/core/API/Request.php"))
|
760 |
+
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
|
761 |
+
if (class_exists('Piwik\FrontController'))
|
762 |
+
Piwik\FrontController::getInstance()->init();
|
763 |
+
else serialize(array('result' => 'error', 'message' => __('Class Piwik\FrontController does not exists.','wp-piwik')));
|
764 |
+
if (class_exists('Piwik\API\Request'))
|
765 |
+
$objRequest = new Piwik\API\Request($strParams);
|
766 |
+
else serialize(array('result' => 'error', 'message' => __('Class Piwik\API\Request does not exists.','wp-piwik')));
|
767 |
+
$result = $objRequest->process();
|
768 |
+
if (!headers_sent()) {
|
769 |
+
header("Content-Type: text/html", true);
|
770 |
+
}
|
771 |
+
return $result;
|
772 |
+
}
|
773 |
+
|
774 |
+
/**
|
775 |
+
* Get remote file
|
776 |
+
*
|
777 |
+
* @param String $strURL Remote file URL
|
778 |
+
*/
|
779 |
+
function getRemoteFile($strURL, $blogURL = '') {
|
780 |
+
if (self::$settings->getGlobalOption('piwik_mode') == 'php')
|
781 |
+
return $this->callPHP($strURL.($blogURL?'&url='.$blogURL:''));
|
782 |
+
else
|
783 |
+
return $this->callREST($strURL.($blogURL?'&url='.urlencode($blogURL):''));
|
784 |
+
}
|
785 |
+
|
786 |
+
/**
|
787 |
+
* Add a new site to Piwik if a new blog was requested,
|
788 |
+
* or get its ID by URL
|
789 |
+
*/
|
790 |
+
function addPiwikSite() {
|
791 |
+
if (isset($_GET['wpmu_show_stats']) && self::$settings->checkNetworkActivation()) {
|
792 |
+
self::$logger->log('Switch blog ID: '.(int) $_GET['wpmu_show_stats']);
|
793 |
+
switch_to_blog((int) $_GET['wpmu_show_stats']);
|
794 |
+
}
|
795 |
+
self::$logger->log('Get the blog\'s site ID by URL: '.get_bloginfo('url'));
|
796 |
+
// Check if blog URL already known
|
797 |
+
$strURL = '&method=SitesManager.getSitesIdFromSiteUrl';
|
798 |
+
$strURL .= '&format=PHP';
|
799 |
+
$strURL .= '&token_auth='.self::$settings->getGlobalOption('piwik_token');
|
800 |
+
$aryResult = unserialize($this->getRemoteFile($strURL, get_bloginfo('url')));
|
801 |
+
if (!empty($aryResult) && isset($aryResult[0]['idsite'])) {
|
802 |
+
self::$settings->setOption('site_id', (int) $aryResult[0]['idsite']);
|
803 |
+
// Otherwise create new site
|
804 |
+
} elseif (self::isConfigured() && !empty($strURL)) {
|
805 |
+
self::$logger->log('Blog not known yet - create new site');
|
806 |
+
$strName = get_bloginfo('name');
|
807 |
+
if (empty($strName)) $strName = get_bloginfo('url');
|
808 |
+
self::$settings->setOption('name', $strName);
|
809 |
+
$strURL .= '&method=SitesManager.addSite';
|
810 |
+
$strURL .= '&siteName='.urlencode($strName).'&urls='.urlencode(get_bloginfo('url'));
|
811 |
+
$strURL .= '&format=PHP';
|
812 |
+
$strURL .= '&token_auth='.self::$settings->getGlobalOption('piwik_token');
|
813 |
+
$strResult = unserialize($this->getRemoteFile($strURL, get_bloginfo('url')));
|
814 |
+
if (!empty($strResult)) self::$settings->setOption('site_id', (int) $strResult);
|
815 |
+
}
|
816 |
+
// Store new data if site created
|
817 |
+
if (self::$settings->getOption('site_id')) {
|
818 |
+
self::$logger->log('Get the site\'s tracking code');
|
819 |
+
self::$settings->setOption('tracking_code', $this->callPiwikAPI('SitesManager.getJavascriptTag'));
|
820 |
+
} else self::$settings->getOption('tracking_code', '');
|
821 |
+
self::$settings->save();
|
822 |
+
if (isset($_GET['wpmu_show_stats']) && self::$settings->checkNetworkActivation()) {
|
823 |
+
self::$logger->log('Back to current blog');
|
824 |
+
restore_current_blog();
|
825 |
+
}
|
826 |
+
return array('js' => self::$settings->getOption('tracking_code'), 'id' => self::$settings->getOption('site_id'));
|
827 |
+
}
|
828 |
+
|
829 |
+
/**
|
830 |
+
* Update a site
|
831 |
+
*/
|
832 |
+
function updatePiwikSite() {
|
833 |
+
$strBlogURL = get_bloginfo('url');
|
834 |
+
// Check if blog URL already known
|
835 |
+
$strName = get_bloginfo('name');
|
836 |
+
if (empty($strName)) $strName = $strBlogURL;
|
837 |
+
self::$settings->setOption('name', $strName);
|
838 |
+
$strURL = '&method=SitesManager.updateSite';
|
839 |
+
$strURL .= '&idSite='.self::$settings->getOption('site_id');
|
840 |
+
$strURL .= '&siteName='.urlencode($strName).'&urls='.urlencode($strBlogURL);
|
841 |
+
$strURL .= '&format=PHP';
|
842 |
+
$strURL .= '&token_auth='.self::$settings->getGlobalOption('piwik_token');
|
843 |
+
$strResult = unserialize($this->getRemoteFile($strURL));
|
844 |
+
// Store new data
|
845 |
+
self::$settings->getOption('tracking_code', $this->callPiwikAPI('SitesManager.getJavascriptTag'));
|
846 |
+
self::$settings->save();
|
847 |
+
}
|
848 |
+
|
849 |
+
/**
|
850 |
+
* Apply configured Tracking Code changes
|
851 |
+
*/
|
852 |
+
function applyJSCodeChanges($strCode) {
|
853 |
+
self::$logger->log('Apply tracking code changes.');
|
854 |
+
self::$settings->setOption('last_tracking_code_update', time());
|
855 |
+
$strCode = html_entity_decode($strCode);
|
856 |
+
// Change code if js/index.php should be used
|
857 |
+
if (self::$settings->getGlobalOption('track_mode') == 1) {
|
858 |
+
$strCode = str_replace('piwik.js', 'js/index.php', $strCode);
|
859 |
+
$strCode = str_replace('piwik.php', 'js/index.php', $strCode);
|
860 |
+
} elseif (self::$settings->getGlobalOption('track_mode') == 2) {
|
861 |
+
$strCode = str_replace('piwik.js', 'piwik.php', $strCode);
|
862 |
+
$strURL = str_replace('https://', '//', self::$settings->getGlobalOption('piwik_url'));
|
863 |
+
$strURL = str_replace('http://', '//', $strURL);
|
864 |
+
$strProxy = str_replace('https://', '//', plugins_url('wp-piwik').'/proxy');
|
865 |
+
$strProxy = str_replace('http://', '//', $strProxy);
|
866 |
+
$strProxy .= '/';
|
867 |
+
$strCode = str_replace($strURL, $strProxy, $strCode);
|
868 |
+
}
|
869 |
+
$strCode = str_replace('//";','/"',$strCode);
|
870 |
+
if (self::$settings->getGlobalOption('force_protocol')) {
|
871 |
+
$strCode = str_replace('"//', '"'.self::$settings->getGlobalOption('force_protocol').'://',$strCode);
|
872 |
+
}
|
873 |
+
if (self::$settings->getGlobalOption('track_cdnurl')||self::$settings->getGlobalOption('track_cdnurlssl')) {
|
874 |
+
$strCode = str_replace("var d=doc", "var ucdn=(('https:' == document.location.protocol) ? 'https://".(self::$settings->getGlobalOption('track_cdnurlssl')?self::$settings->getGlobalOption('track_cdnurlssl'):self::$settings->getGlobalOption('track_cdnurl'))."/' : 'http://".(self::$settings->getGlobalOption('track_cdnurl')?self::$settings->getGlobalOption('track_cdnurl'):self::$settings->getGlobalOption('track_cdnurlssl'))."/');\nvar d=doc", $strCode);
|
875 |
+
$strCode = str_replace("g.src=u+", "g.src=ucdn+", $strCode);
|
876 |
+
}
|
877 |
+
// Change code if file extensions for download tracking are added
|
878 |
+
if (self::$settings->getGlobalOption('add_download_extensions')) {
|
879 |
+
$strCode = str_replace("_paq.push(['trackPageView']);", "_paq.push(['addDownloadExtensions', '".(self::$settings->getGlobalOption('add_download_extensions'))."']);\n_paq.push(['trackPageView']);", $strCode);
|
880 |
+
}
|
881 |
+
// Change code if POST is forced to be used
|
882 |
+
if (self::$settings->getGlobalOption('track_post') && self::$settings->getGlobalOption('track_mode') != 2) $strCode = str_replace("_paq.push(['trackPageView']);", "_paq.push(['setRequestMethod', 'POST']);\n_paq.push(['trackPageView']);", $strCode);
|
883 |
+
// Change code if cookies are disabled
|
884 |
+
if (self::$settings->getGlobalOption('disable_cookies')) $strCode = str_replace("_paq.push(['trackPageView']);", "_paq.push(['disableCookies']);\n_paq.push(['trackPageView']);", $strCode);
|
885 |
+
if (self::$settings->getGlobalOption('limit_cookies')) $strCode = str_replace("_paq.push(['trackPageView']);", "_paq.push(['setVisitorCookieTimeout', '".self::$settings->getGlobalOption('limit_cookies_visitor')."']);\n_paq.push(['setSessionCookieTimeout', '".self::$settings->getGlobalOption('limit_cookies_session')."']);\n_paq.push(['trackPageView']);", $strCode);
|
886 |
+
// Store <noscript> code
|
887 |
+
$aryNoscript = array();
|
888 |
+
preg_match('/<noscript>(.*)<\/noscript>/', $strCode, $aryNoscript);
|
889 |
+
if (isset($aryNoscript[0])) {
|
890 |
+
if (self::$settings->getGlobalOption('track_nojavascript'))
|
891 |
+
$aryNoscript[0] = str_replace('?idsite', '?rec=1&idsite', $aryNoscript[0]);
|
892 |
+
self::$settings->setOption('noscript_code', $aryNoscript[0]);
|
893 |
+
}
|
894 |
+
if (self::$settings->getGlobalOption('track_datacfasync'))
|
895 |
+
$strCode = str_replace('<script type', '<script data-cfasync="false" type', $strCode);
|
896 |
+
// Remove <noscript> code
|
897 |
+
$strCode = preg_replace('/<noscript>(.*)<\/noscript>/', '', $strCode);
|
898 |
+
// Return code without empty lines
|
899 |
+
return preg_replace('/\s+(\r\n|\r|\n)/', '$1', $strCode);
|
900 |
+
}
|
901 |
+
|
902 |
+
/**
|
903 |
+
* Create a WordPress dashboard widget
|
904 |
+
*/
|
905 |
+
function createDashboardWidget($objPost, $aryMetabox) {
|
906 |
+
// Create description and ID
|
907 |
+
$strDesc = $strID = '';
|
908 |
+
$aryConfig = $aryMetabox['args']['aryConfig'];
|
909 |
+
foreach ($aryConfig['params'] as $strParam)
|
910 |
+
if (!empty($strParam)) {
|
911 |
+
$strDesc .= $strParam.', ';
|
912 |
+
$strID .= '_'.$strParam;
|
913 |
+
}
|
914 |
+
// Remove dots from filename
|
915 |
+
$strFile = str_replace('.', '', $aryMetabox['args']['strFile']);
|
916 |
+
// Finalize configuration
|
917 |
+
$aryConf = array_merge($aryConfig, array(
|
918 |
+
'id' => $strFile.$strID,
|
919 |
+
'desc' => substr($strDesc, 0, -2)));
|
920 |
+
// Include widget file
|
921 |
+
if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'dashboard/'.$strFile.'.php'))
|
922 |
+
include(dirname(__FILE__).DIRECTORY_SEPARATOR.'dashboard/'.$strFile.'.php');
|
923 |
+
}
|
924 |
+
|
925 |
+
/**
|
926 |
+
* Call Piwik's API
|
927 |
+
*/
|
928 |
+
function callPiwikAPI($strMethod, $strPeriod='', $strDate='', $intLimit='',$bolExpanded=false, $intId = false, $strFormat = 'PHP', $strPageURL = '', $useCache = true, $strNote = '') {
|
929 |
+
// Create unique cache key
|
930 |
+
$strKey = 'wp-piwik_'.md5($strMethod.'_'.$strPeriod.'_'.$strDate.'_'.$intLimit.'_'.self::$settings->getGlobalOption('piwik_token').'_'.self::$settings->getGlobalOption('piwik_url').'_'.$intId.'_'.$strPageURL);
|
931 |
+
// Call API if data not cached
|
932 |
+
if (self::$settings->getGlobalOption('cache') && $useCache) {
|
933 |
+
$result = get_transient($strKey);
|
934 |
+
self::$logger->log('API method: '.$strMethod.' Fetch call from cache: '.$strKey);
|
935 |
+
} else $result = false;
|
936 |
+
if ($strMethod == "SitesManager.getSitesWithAtLeastViewAccess" || false === $result) {
|
937 |
+
$strToken = self::$settings->getGlobalOption('piwik_token');
|
938 |
+
// If multisite stats are shown, maybe the super admin wants to show other blog's stats.
|
939 |
+
if (self::$settings->checkNetworkActivation() && function_exists('is_super_admin') && function_exists('wp_get_current_user') && is_super_admin() && isset($_GET['wpmu_show_stats'])) {
|
940 |
+
$aryOptions = get_blog_option((int) $_GET['wpmu_show_stats'], 'wp-piwik_settings' , array());
|
941 |
+
if (!empty($aryOptions) && isset($aryOptions['site_id']))
|
942 |
+
$intSite = $aryOptions['site_id'];
|
943 |
+
else $intSite = self::$settings->getOption('site_id');
|
944 |
+
// Otherwise use the current site's id.
|
945 |
+
} else {
|
946 |
+
if (!self::$settings->getOption('site_id'))
|
947 |
+
self::addPiwikSite();
|
948 |
+
$intSite = self::$settings->getOption('site_id');
|
949 |
+
}
|
950 |
+
//die($intSite);
|
951 |
+
// Create error message if WP-Piwik isn't configured
|
952 |
+
if (!self::isConfigured()) {
|
953 |
+
$result = array(
|
954 |
+
'result' => 'error',
|
955 |
+
'message' => 'Piwik URL/path or auth token not set.'
|
956 |
+
);
|
957 |
+
return $result;
|
958 |
+
}
|
959 |
+
// Build URL
|
960 |
+
$strURL = '&method='.$strMethod;
|
961 |
+
$strURL .= '&idSite='.(int)$intSite.'&period='.$strPeriod.'&date='.$strDate;
|
962 |
+
$strURL .= '&filter_limit='.$intLimit;
|
963 |
+
$strURL .= '&token_auth='.$strToken;
|
964 |
+
$strURL .= '&expanded='.$bolExpanded;
|
965 |
+
$strURL .= '&format='.$strFormat;
|
966 |
+
$strURL .= ($strPageURL?'&pageUrl='.urlencode($strPageURL):'');
|
967 |
+
$strURL .= ($strNote?'¬e='.urlencode($strNote):'');
|
968 |
+
if (self::$settings->getGlobalOption('track_across') && $strMethod == 'SitesManager.getJavascriptTag') {
|
969 |
+
$strURL .= '&mergeSubdomains=1';
|
970 |
+
}
|
971 |
+
if (self::$settings->getGlobalOption('track_across_alias') && $strMethod == 'SitesManager.getJavascriptTag') {
|
972 |
+
$strURL .= '&mergeAliasUrls=1';
|
973 |
+
}
|
974 |
+
// Fetch data if site exists
|
975 |
+
if (!empty($intSite) || $strMethod=='SitesManager.getSitesWithAtLeastViewAccess') {
|
976 |
+
self::$logger->log('API method: '.$strMethod.' API call: '.$strURL);
|
977 |
+
$strResult = (string) $this->getRemoteFile($strURL, get_bloginfo('url'));
|
978 |
+
$result = ($strFormat == 'PHP'?unserialize($strResult):$strResult);
|
979 |
+
// Apply tracking code changes if configured
|
980 |
+
if ($strMethod == 'SitesManager.getJavascriptTag' && !empty($result)) {
|
981 |
+
$result = is_string($result)?$this->applyJSCodeChanges($result):'<!-- WP-Piwik ERROR: Tracking code not availbale -->'."\n";
|
982 |
+
}
|
983 |
+
// Otherwise return error message
|
984 |
+
} else $result = array('result' => 'error', 'message' => 'Unknown site/blog.');
|
985 |
+
if (
|
986 |
+
$strMethod != 'SitesManager.getJavascriptTag' &&
|
987 |
+
$strDate != 'today' && $strDate != date('Ymd') && substr($strDate, 0, 4) != 'last' &&
|
988 |
+
self::$settings->getGlobalOption('cache') &&
|
989 |
+
!(isset($result['result']) && $result['result'] == 'error')&&
|
990 |
+
!empty($result)
|
991 |
+
) set_transient($strKey, $result, WEEK_IN_SECONDS);
|
992 |
+
}
|
993 |
+
return $result;
|
994 |
+
}
|
995 |
+
|
996 |
+
/* TODO: Add post stats
|
997 |
+
* function display_post_unique_column($aryCols) {
|
998 |
+
* $aryCols['wp-piwik_unique'] = __('Unique');
|
999 |
+
* return $aryCols;
|
1000 |
+
* }
|
1001 |
+
*
|
1002 |
+
* function display_post_unique_content($strCol, $intID) {
|
1003 |
+
* if( $strCol == 'wp-piwik_unique' ) {
|
1004 |
+
* }
|
1005 |
+
* }
|
1006 |
+
*/
|
1007 |
+
|
1008 |
+
function onloadStatsPage() {
|
1009 |
+
wp_enqueue_script('common');
|
1010 |
+
wp_enqueue_script('wp-lists');
|
1011 |
+
wp_enqueue_script('postbox');
|
1012 |
+
$strToken = self::$settings->getGlobalOption('piwik_token');
|
1013 |
+
$strPiwikURL = self::$settings->getGlobalOption('piwik_url');
|
1014 |
+
$aryDashboard = array();
|
1015 |
+
// Set default configuration
|
1016 |
+
$arySortOrder = array(
|
1017 |
+
'side' => array(
|
1018 |
+
'overview' => array(__('Overview', 'wp-piwik'), 'day', 'yesterday'),
|
1019 |
+
'seo' => array(__('SEO', 'wp-piwik'), 'day', 'yesterday'),
|
1020 |
+
'pages' => array(__('Pages', 'wp-piwik'), 'day', 'yesterday'),
|
1021 |
+
'keywords' => array(__('Keywords', 'wp-piwik'), 'day', 'yesterday', 10),
|
1022 |
+
'websites' => array(__('Websites', 'wp-piwik'), 'day', 'yesterday', 10),
|
1023 |
+
'plugins' => array(__('Plugins', 'wp-piwik'), 'day', 'yesterday'),
|
1024 |
+
'search' => array(__('Site Search Keywords', 'wp-piwik'), 'day', 'yesterday', 10),
|
1025 |
+
'noresult' => array(__('Site Search without Results', 'wp-piwik'), 'day', 'yesterday', 10),
|
1026 |
+
),
|
1027 |
+
'normal' => array(
|
1028 |
+
'visitors' => array(__('Visitors', 'wp-piwik'), 'day', 'last30'),
|
1029 |
+
'browsers' => array(__('Browser', 'wp-piwik'), 'day', 'yesterday'),
|
1030 |
+
'browserdetails' => array(__('Browser Details', 'wp-piwik'), 'day', 'yesterday'),
|
1031 |
+
'screens' => array(__('Resolution', 'wp-piwik'), 'day', 'yesterday'),
|
1032 |
+
'systems' => array(__('Operating System', 'wp-piwik'), 'day', 'yesterday')
|
1033 |
+
)
|
1034 |
+
);
|
1035 |
+
// Don't show SEO stats if disabled
|
1036 |
+
if (!self::$settings->getGlobalOption('stats_seo'))
|
1037 |
+
unset($arySortOrder['side']['seo']);
|
1038 |
+
|
1039 |
+
foreach ($arySortOrder as $strCol => $aryWidgets) {
|
1040 |
+
if (is_array($aryWidgets)) foreach ($aryWidgets as $strFile => $aryParams) {
|
1041 |
+
$aryDashboard[$strCol][$strFile] = array(
|
1042 |
+
'params' => array(
|
1043 |
+
'title' => (isset($aryParams[0])?$aryParams[0]:$strFile),
|
1044 |
+
'period' => (isset($aryParams[1])?$aryParams[1]:''),
|
1045 |
+
'date' => (isset($aryParams[2])?$aryParams[2]:''),
|
1046 |
+
'limit' => (isset($aryParams[3])?$aryParams[3]:'')
|
1047 |
+
)
|
1048 |
+
);
|
1049 |
+
if (isset($_GET['date']) && preg_match('/^[0-9]{8}$/', $_GET['date']) && $strFile != 'visitors')
|
1050 |
+
$aryDashboard[$strCol][$strFile]['params']['date'] = $_GET['date'];
|
1051 |
+
elseif ($strFile != 'visitors')
|
1052 |
+
$aryDashboard[$strCol][$strFile]['params']['date'] = self::$settings->getGlobalOption('default_date');
|
1053 |
+
}
|
1054 |
+
}
|
1055 |
+
$intSideBoxCnt = $intContentBox = 0;
|
1056 |
+
foreach ($aryDashboard['side'] as $strFile => $aryConfig) {
|
1057 |
+
$intSideBoxCnt++;
|
1058 |
+
if (preg_match('/(\d{4})(\d{2})(\d{2})/', $aryConfig['params']['date'], $aryResult))
|
1059 |
+
$strDate = $aryResult[1]."-".$aryResult[2]."-".$aryResult[3];
|
1060 |
+
else $strDate = $aryConfig['params']['date'];
|
1061 |
+
add_meta_box(
|
1062 |
+
'wp-piwik_stats-sidebox-'.$intSideBoxCnt,
|
1063 |
+
$aryConfig['params']['title'].' '.($aryConfig['params']['title']!='SEO'?__($strDate, 'wp-piwik'):''),
|
1064 |
+
array(&$this, 'createDashboardWidget'),
|
1065 |
+
$this->intStatsPage,
|
1066 |
+
'side',
|
1067 |
+
'core',
|
1068 |
+
array('strFile' => $strFile, 'aryConfig' => $aryConfig)
|
1069 |
+
);
|
1070 |
+
}
|
1071 |
+
foreach ($aryDashboard['normal'] as $strFile => $aryConfig) {
|
1072 |
+
if (preg_match('/(\d{4})(\d{2})(\d{2})/', $aryConfig['params']['date'], $aryResult))
|
1073 |
+
$strDate = $aryResult[1]."-".$aryResult[2]."-".$aryResult[3];
|
1074 |
+
else $strDate = $aryConfig['params']['date'];
|
1075 |
+
$intContentBox++;
|
1076 |
+
add_meta_box(
|
1077 |
+
'wp-piwik_stats-contentbox-'.$intContentBox,
|
1078 |
+
$aryConfig['params']['title'].' '.($aryConfig['params']['title']!='SEO'?__($strDate, 'wp-piwik'):''),
|
1079 |
+
array(&$this, 'createDashboardWidget'),
|
1080 |
+
$this->intStatsPage,
|
1081 |
+
'normal',
|
1082 |
+
'core',
|
1083 |
+
array('strFile' => $strFile, 'aryConfig' => $aryConfig)
|
1084 |
+
);
|
1085 |
+
}
|
1086 |
+
}
|
1087 |
+
|
1088 |
+
// Open stats page as network admin
|
1089 |
+
function showStatsNetwork() {
|
1090 |
+
$this->bolNetwork = true;
|
1091 |
+
$this->showStats();
|
1092 |
+
}
|
1093 |
+
|
1094 |
+
function showStats() {
|
1095 |
+
// Disabled time limit if required
|
1096 |
+
if (self::$settings->getGlobalOption('disable_timelimit') && self::$settings->getGlobalOption('disable_timelimit'))
|
1097 |
+
set_time_limit(0);
|
1098 |
+
//we need the global screen column value to be able to have a sidebar in WordPress 2.8
|
1099 |
+
global $screen_layout_columns;
|
1100 |
+
if (empty($screen_layout_columns)) $screen_layout_columns = 2;
|
1101 |
+
/***************************************************************************/ ?>
|
1102 |
+
<div id="wp-piwik-stats-general" class="wrap">
|
1103 |
+
<?php screen_icon('options-general'); ?>
|
1104 |
+
<h2><?php echo (self::$settings->getGlobalOption('plugin_display_name') == 'WP-Piwik'?'Piwik '.__('Statistics', 'wp-piwik'):self::$settings->getGlobalOption('plugin_display_name')); ?></h2>
|
1105 |
+
<?php /************************************************************************/
|
1106 |
+
if (self::$settings->checkNetworkActivation() && function_exists('is_super_admin') && is_super_admin() && $this->bolNetwork) {
|
1107 |
+
if (isset($_GET['wpmu_show_stats'])) {
|
1108 |
+
switch_to_blog((int) $_GET['wpmu_show_stats']);
|
1109 |
+
// TODO OPTIMIZE
|
1110 |
+
} else {
|
1111 |
+
$this->includeFile('settings/sitebrowser');
|
1112 |
+
return;
|
1113 |
+
}
|
1114 |
+
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>'."\n";
|
1115 |
+
echo '</form>'."\n";
|
1116 |
+
}
|
1117 |
+
/***************************************************************************/ ?>
|
1118 |
+
<form action="admin-post.php" method="post">
|
1119 |
+
<?php wp_nonce_field('wp-piwik_stats-general'); ?>
|
1120 |
+
<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?>
|
1121 |
+
<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?>
|
1122 |
+
<input type="hidden" name="action" value="save_wp-piwik_stats_general" />
|
1123 |
+
<div id="dashboard-widgets" class="metabox-holder columns-<?php echo $screen_layout_columns; ?><?php echo 2 <= $screen_layout_columns?' has-right-sidebar':''; ?>">
|
1124 |
+
<div id='postbox-container-1' class='postbox-container'>
|
1125 |
+
<?php $meta_boxes = do_meta_boxes($this->intStatsPage, 'normal', null); ?>
|
1126 |
+
</div>
|
1127 |
+
|
1128 |
+
<div id='postbox-container-2' class='postbox-container'>
|
1129 |
+
<?php do_meta_boxes($this->intStatsPage, 'side', null); ?>
|
1130 |
+
</div>
|
1131 |
+
|
1132 |
+
<div id='postbox-container-3' class='postbox-container'>
|
1133 |
+
<?php do_meta_boxes($this->intStatsPage, 'column3', null); ?>
|
1134 |
+
</div>
|
1135 |
+
|
1136 |
+
</div>
|
1137 |
+
</form>
|
1138 |
+
</div>
|
1139 |
+
<script type="text/javascript">
|
1140 |
+
//<![CDATA[
|
1141 |
+
jQuery(document).ready( function($) {
|
1142 |
+
// close postboxes that should be closed
|
1143 |
+
$('.if-js-closed').removeClass('if-js-closed').addClass('closed');
|
1144 |
+
// postboxes setup
|
1145 |
+
postboxes.add_postbox_toggles('<?php echo $this->intStatsPage; ?>');
|
1146 |
+
});
|
1147 |
+
//]]>
|
1148 |
+
</script>
|
1149 |
+
<?php /************************************************************************/
|
1150 |
+
if (self::$settings->checkNetworkActivation() && function_exists('is_super_admin') && is_super_admin()) {
|
1151 |
+
restore_current_blog();
|
1152 |
+
}
|
1153 |
+
}
|
1154 |
+
|
1155 |
+
/* Stats page changes by POST submit
|
1156 |
+
seen in Heiko Rabe's metabox demo plugin
|
1157 |
+
http://tinyurl.com/5r5vnzs */
|
1158 |
+
function onStatsPageSaveChanges() {
|
1159 |
+
//user permission check
|
1160 |
+
if ( !current_user_can('manage_options') )
|
1161 |
+
wp_die( __('Cheatin’ uh?') );
|
1162 |
+
//cross check the given referer
|
1163 |
+
check_admin_referer('wp-piwik_stats');
|
1164 |
+
//process here your on $_POST validation and / or option saving
|
1165 |
+
//lets redirect the post request into get request (you may add additional params at the url, if you need to show save results
|
1166 |
+
wp_redirect($_POST['_wp_http_referer']);
|
1167 |
+
}
|
1168 |
+
|
1169 |
+
/**
|
1170 |
+
* Add tabs to settings page
|
1171 |
+
* See http://wp.smashingmagazine.com/2011/10/20/create-tabs-wordpress-settings-pages/
|
1172 |
+
*/
|
1173 |
+
function showSettingsTabs($bolFull = true, $strCurr = 'homepage') {
|
1174 |
+
$aryTabs = ($bolFull?array(
|
1175 |
+
'homepage' => __('Home','wp-piwik'),
|
1176 |
+
'piwik' => __('Piwik Settings','wp-piwik'),
|
1177 |
+
'tracking' => __('Tracking','wp-piwik'),
|
1178 |
+
'views' => __('Statistics','wp-piwik'),
|
1179 |
+
'support' => __('Support','wp-piwik'),
|
1180 |
+
'credits' => __('Credits','wp-piwik')
|
1181 |
+
):array(
|
1182 |
+
'piwik' => __('Piwik Settings','wp-piwik'),
|
1183 |
+
'support' => __('Support','wp-piwik'),
|
1184 |
+
'credits' => __('Credits','wp-piwik')
|
1185 |
+
));
|
1186 |
+
if (empty($strCurr)) $strCurr = 'homepage';
|
1187 |
+
elseif (!isset($aryTabs[$strCurr]) && $strCurr != 'sitebrowser') $strCurr = 'piwik';
|
1188 |
+
echo '<div id="icon-themes" class="icon32"><br></div>';
|
1189 |
+
echo '<h2 class="nav-tab-wrapper">';
|
1190 |
+
foreach($aryTabs as $strTab => $strName) {
|
1191 |
+
$strClass = ($strTab == $strCurr?' nav-tab-active':'');
|
1192 |
+
echo '<a class="nav-tab'.$strClass.'" href="?page=wp-piwik/wp-piwik.php&tab='.$strTab.'">'.$strName.'</a>';
|
1193 |
+
}
|
1194 |
+
echo '</h2>';
|
1195 |
+
return $strCurr;
|
1196 |
+
}
|
1197 |
+
|
1198 |
+
/**
|
1199 |
+
* Apply & store new settings
|
1200 |
+
*/
|
1201 |
+
function applySettings() {
|
1202 |
+
$strTab = (isset($_GET['tab'])?$_GET['tab']:'homepage');
|
1203 |
+
self::$logger->log('Apply changes: '.$strTab);
|
1204 |
+
switch ($strTab) {
|
1205 |
+
case 'views':
|
1206 |
+
self::$settings->setGlobalOption('plugin_display_name', (!empty($_POST['wp-piwik_displayname'])?htmlentities($_POST['wp-piwik_displayname']):'WP-Piwk'));
|
1207 |
+
self::$settings->setGlobalOption('dashboard_widget',(isset($_POST['wp-piwik_dbwidget'])?$_POST['wp-piwik_dbwidget']:0));
|
1208 |
+
self::$settings->setGlobalOption('dashboard_chart',(isset($_POST['wp-piwik_dbchart'])?$_POST['wp-piwik_dbchart']:false));
|
1209 |
+
self::$settings->setGlobalOption('dashboard_seo',(isset($_POST['wp-piwik_dbseo'])?$_POST['wp-piwik_dbseo']:false));
|
1210 |
+
self::$settings->setGlobalOption('stats_seo',(isset($_POST['wp-piwik_statsseo'])?$_POST['wp-piwik_statsseo']:false));
|
1211 |
+
self::$settings->setGlobalOption('piwik_shortcut', (isset($_POST['wp-piwik_piwiklink'])?$_POST['wp-piwik_piwiklink']:false));
|
1212 |
+
self::$settings->setGlobalOption('default_date', (isset($_POST['wp-piwik_default_date'])?$_POST['wp-piwik_default_date']:'yesterday'));
|
1213 |
+
self::$settings->setGlobalOption('capability_read_stats', (isset($_POST['wp-piwik_displayto'])?$_POST['wp-piwik_displayto']:array()));
|
1214 |
+
self::$settings->setGlobalOption('disable_timelimit', (isset($_POST['wp-piwik_disabletimelimit'])?$_POST['wp-piwik_disabletimelimit']:false));
|
1215 |
+
self::$settings->setGlobalOption('toolbar', (isset($_POST['wp-piwik_toolbar'])?$_POST['wp-piwik_toolbar']:false));
|
1216 |
+
self::$settings->setGlobalOption('shortcodes', (isset($_POST['wp-piwik_shortcodes'])?$_POST['wp-piwik_shortcodes']:false));
|
1217 |
+
self::$settings->setGlobalOption('perpost_stats', (isset($_POST['wp-piwik_perpost'])?$_POST['wp-piwik_perpost']:false));
|
1218 |
+
break;
|
1219 |
+
case 'tracking':
|
1220 |
+
self::$settings->setGlobalOption('add_tracking_code', (isset($_POST['wp-piwik_addjs'])?$_POST['wp-piwik_addjs']:false));
|
1221 |
+
self::$settings->setGlobalOption('track_404', (isset($_POST['wp-piwik_404'])?$_POST['wp-piwik_404']:false));
|
1222 |
+
self::$settings->setGlobalOption('track_search', (isset($_POST['wp-piwik_search'])?$_POST['wp-piwik_search']:false));
|
1223 |
+
self::$settings->setGlobalOption('track_mode', (isset($_POST['wp-piwik_trackingmode'])?(int)$_POST['wp-piwik_trackingmode']:0));
|
1224 |
+
self::$settings->setGlobalOption('track_post', (isset($_POST['wp-piwik_reqpost'])?$_POST['wp-piwik_reqpost']:false));
|
1225 |
+
self::$settings->setGlobalOption('track_proxy', (isset($_POST['wp-piwik_proxy'])?$_POST['wp-piwik_proxy']:false));
|
1226 |
+
self::$settings->setGlobalOption('track_cdnurl', trim(isset($_POST['wp-piwik_cdnurl'])?$_POST['wp-piwik_cdnurl']:''));
|
1227 |
+
self::$settings->setGlobalOption('track_cdnurlssl', trim(isset($_POST['wp-piwik_cdnurlssl'])?$_POST['wp-piwik_cdnurlssl']:self::$settings->getGlobalOption('track_cdnurl')));
|
1228 |
+
self::$settings->setGlobalOption('track_noscript', (isset($_POST['wp-piwik_noscript'])?$_POST['wp-piwik_noscript']:false));
|
1229 |
+
self::$settings->setGlobalOption('track_codeposition', (isset($_POST['wp-piwik_codeposition'])?$_POST['wp-piwik_codeposition']:'footer'));
|
1230 |
+
self::$settings->setGlobalOption('track_nojavascript', (isset($_POST['wp-piwik_nojavascript'])?$_POST['wp-piwik_nojavascript']:false));
|
1231 |
+
self::$settings->setGlobalOption('track_admin', (isset($_POST['wp-piwik_trackadmin'])?$_POST['wp-piwik_trackadmin']:false));
|
1232 |
+
self::$settings->setGlobalOption('track_feed', (isset($_POST['wp-piwik_trackfeed'])?$_POST['wp-piwik_trackfeed']:false));
|
1233 |
+
self::$settings->setGlobalOption('track_feed_goal', (isset($_POST['wp-piwik_trackfeed_goal'])&&!empty($_POST['wp-piwik_trackfeed_goal'])?(int)$_POST['wp-piwik_trackfeed_goal']:''));
|
1234 |
+
self::$settings->setGlobalOption('track_feed_revenue', (isset($_POST['wp-piwik_trackfeed_revenue'])&&!empty($_POST['wp-piwik_trackfeed_revenue'])?(int)$_POST['wp-piwik_trackfeed_revenue']:''));
|
1235 |
+
self::$settings->setGlobalOption('track_feed_campaign', (isset($_POST['wp-piwik_trackfeed_campaign'])?$_POST['wp-piwik_trackfeed_campaign']:'feed'));
|
1236 |
+
self::$settings->setGlobalOption('track_feed_addcampaign', (isset($_POST['wp-piwik_trackfeed_addcampaign'])?$_POST['wp-piwik_trackfeed_addcampaign']:false));
|
1237 |
+
self::$settings->setGlobalOption('track_datacfasync', (isset($_POST['wp-piwik_datacfasync'])?$_POST['wp-piwik_datacfasync']:false));
|
1238 |
+
self::$settings->setGlobalOption('track_across', (isset($_POST['wp-piwik_track_across'])?$_POST['wp-piwik_track_across']:false));
|
1239 |
+
self::$settings->setGlobalOption('track_across_alias', (isset($_POST['wp-piwik_track_across_alias'])?$_POST['wp-piwik_track_across_alias']:false));
|
1240 |
+
self::$settings->setGlobalOption('add_post_annotations', (isset($_POST['wp-piwik_annotations'])?$_POST['wp-piwik_annotations']:false));
|
1241 |
+
self::$settings->setGlobalOption('add_customvars_box', (isset($_POST['wp-piwik_customvars'])?$_POST['wp-piwik_customvars']:false));
|
1242 |
+
self::$settings->setGlobalOption('capability_stealth', (isset($_POST['wp-piwik_filter'])?$_POST['wp-piwik_filter']:array()));
|
1243 |
+
self::$settings->setGlobalOption('disable_cookies', (isset($_POST['wp-piwik_disable_cookies'])?$_POST['wp-piwik_disable_cookies']:false));
|
1244 |
+
self::$settings->setGlobalOption('limit_cookies', (isset($_POST['wp-piwik_limit_cookies'])?$_POST['wp-piwik_limit_cookies']:false));
|
1245 |
+
self::$settings->setGlobalOption('limit_cookies_visitor', (isset($_POST['wp-piwik_limit_cookies_visitor'])?(int)$_POST['wp-piwik_limit_cookies_visitor']:1209600));
|
1246 |
+
self::$settings->setGlobalOption('limit_cookies_session', (isset($_POST['wp-piwik_limit_cookies_session'])?(int)$_POST['wp-piwik_limit_cookies_session']:0));
|
1247 |
+
self::$settings->setGlobalOption('add_download_extensions', (isset($_POST['wp-piwik_add_download_extensions'])?trim($_POST['wp-piwik_add_download_extensions']):''));
|
1248 |
+
self::$settings->setGlobalOption('force_protocol', (isset($_POST['wp-piwik_force_protocol'])?trim($_POST['wp-piwik_force_protocol']):''));
|
1249 |
+
self::$settings->setOption('tracking_code', $this->callPiwikAPI('SitesManager.getJavascriptTag'));
|
1250 |
+
break;
|
1251 |
+
case 'homepage':
|
1252 |
+
case 'piwik':
|
1253 |
+
self::$settings->setGlobalOption('piwik_token', (isset($_POST['wp-piwik_token'])?$_POST['wp-piwik_token']:''));
|
1254 |
+
self::$settings->setGlobalOption('piwik_url', self::checkURL((isset($_POST['wp-piwik_url'])?$_POST['wp-piwik_url']:'')));
|
1255 |
+
self::$settings->setGlobalOption('piwik_path', (isset($_POST['wp-piwik_path']) && !empty($_POST['wp-piwik_path'])?realpath($_POST['wp-piwik_path']):''));
|
1256 |
+
self::$settings->setGlobalOption('cache', (isset($_POST['wp-piwik_cache'])?$_POST['wp-piwik_cache']:false));
|
1257 |
+
self::$settings->setGlobalOption('piwik_mode', (isset($_POST['wp-piwik_mode'])?$_POST['wp-piwik_mode']:'http'));
|
1258 |
+
self::$settings->setGlobalOption('piwik_useragent', (isset($_POST['wp-piwik_useragent'])?$_POST['wp-piwik_useragent']:'php'));
|
1259 |
+
self::$settings->setGlobalOption('connection_timeout', (isset($_POST['wp-piwik_timeout'])?(int)$_POST['wp-piwik_timeout']:5));
|
1260 |
+
self::$settings->setGlobalOption('piwik_useragent_string', (isset($_POST['wp-piwik_useragent_string'])?$_POST['wp-piwik_useragent_string']:'WP-Piwik'));
|
1261 |
+
self::$settings->setGlobalOption('disable_ssl_verify', (isset($_POST['wp-piwik_disable_ssl_verify'])?$_POST['wp-piwik_disable_ssl_verify']:false));
|
1262 |
+
if (!self::$settings->checkNetworkActivation()) {
|
1263 |
+
self::$settings->setGlobalOption('auto_site_config', (isset($_POST['wp-piwik_auto_site_config'])?$_POST['wp-piwik_auto_site_config']:false));
|
1264 |
+
if (!self::$settings->getGlobalOption('auto_site_config'))
|
1265 |
+
self::$settings->setOption('site_id', (isset($_POST['wp-piwik_siteid'])?$_POST['wp-piwik_siteid']:self::$settings->getOption('site_id')));
|
1266 |
+
} else self::$settings->setGlobalOption('auto_site_config', true);
|
1267 |
+
break;
|
1268 |
+
}
|
1269 |
+
if (self::$settings->getGlobalOption('auto_site_config') && self::isConfigured()) {
|
1270 |
+
if (self::$settings->getGlobalOption('piwik_mode') == 'php' && !defined('PIWIK_INCLUDE_PATH'))
|
1271 |
+
self::definePiwikConstants();
|
1272 |
+
$aryReturn = $this->addPiwikSite();
|
1273 |
+
self::$settings->getOption('tracking_code', $aryReturn['js']);
|
1274 |
+
self::$settings->getOption('site_id', $aryReturn['id']);
|
1275 |
+
}
|
1276 |
+
self::$settings->setGlobalOption('last_settings_update', time());
|
1277 |
+
}
|
1278 |
+
|
1279 |
+
/**
|
1280 |
+
* Check & prepare URL
|
1281 |
+
*/
|
1282 |
+
static function checkURL($strURL) {
|
1283 |
+
if (empty($strURL)) return '';
|
1284 |
+
if (substr($strURL, -1, 1) != '/' && substr($strURL, -10, 10) != '/index.php')
|
1285 |
+
$strURL .= '/';
|
1286 |
+
return $strURL;
|
1287 |
+
}
|
1288 |
+
|
1289 |
+
/**
|
1290 |
+
* Show settings page
|
1291 |
+
*/
|
1292 |
+
function showSettings() {
|
1293 |
+
// Define globals and get request vars
|
1294 |
+
global $pagenow;
|
1295 |
+
$strTab = (isset($_GET['tab'])?$_GET['tab']:'homepage');
|
1296 |
+
// Show update message if stats saved
|
1297 |
+
if (isset($_POST['wp-piwik_settings_submit']) && $_POST['wp-piwik_settings_submit'] == 'Y')
|
1298 |
+
echo '<div id="message" class="updated fade"><p>'.__('Changes saved','wp-piwik').'</p></div>';
|
1299 |
+
// Show settings page title
|
1300 |
+
echo '<div class="wrap"><h2>'.self::$settings->getGlobalOption('plugin_display_name').' '.__('Settings', 'wp-piwik').'</h2>';
|
1301 |
+
// Show tabs
|
1302 |
+
$strTab = $this->showSettingsTabs(self::isConfigured(), $strTab);
|
1303 |
+
if ($strTab != 'sitebrowser') {
|
1304 |
+
/***************************************************************************/ ?>
|
1305 |
+
<div class="wp-piwik-donate">
|
1306 |
+
<p><strong><?php _e('Donate','wp-piwik'); ?></strong></p>
|
1307 |
+
<p><?php _e('If you like WP-Piwik, you can support its development by a donation:', 'wp-piwik'); ?></p>
|
1308 |
+
<script type="text/javascript">
|
1309 |
+
/* <![CDATA[ */
|
1310 |
+
window.onload = function() {
|
1311 |
+
FlattrLoader.render({
|
1312 |
+
'uid': 'flattr',
|
1313 |
+
'url': 'http://wp.local',
|
1314 |
+
'title': 'Title of the thing',
|
1315 |
+
'description': 'Description of the thing'
|
1316 |
+
}, 'element_id', 'replace');
|
1317 |
+
}
|
1318 |
+
/* ]]> */
|
1319 |
+
</script>
|
1320 |
+
<div>
|
1321 |
+
<a class="FlattrButton" style="display:none;" title="WordPress Plugin WP-Piwik" rel="flattr;uid:braekling;category:software;tags:wordpress,piwik,plugin,statistics;" href="https://www.braekling.de/wp-piwik-wpmu-piwik-wordpress">This WordPress plugin adds a Piwik stats site to your WordPress dashboard. It's also able to add the Piwik tracking code to your blog using wp_footer. You need a running Piwik installation and at least view access to your stats.</a>
|
1322 |
+
</div>
|
1323 |
+
<div>Paypal
|
1324 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
1325 |
+
<input type="hidden" name="cmd" value="_s-xclick" />
|
1326 |
+
<input type="hidden" name="hosted_button_id" value="6046779" />
|
1327 |
+
<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donateCC_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online." />
|
1328 |
+
<img alt="" border="0" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1" />
|
1329 |
+
</form>
|
1330 |
+
</div>
|
1331 |
+
<div>
|
1332 |
+
<a href="bitcoin:3N8od4UQA3jDpP5KodkxSqENaRSMWEaTHp">Bitcoin<br />
|
1333 |
+
<img style="border:none;" src="<?php echo $this->getPluginURL(); ?>bitcoin.png" width="100" height="100" alt="Bitcoin Address" title="3N8od4UQA3jDpP5KodkxSqENaRSMWEaTHp" /></a>
|
1334 |
+
</div>
|
1335 |
+
<div>
|
1336 |
+
<a 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>
|
1337 |
+
</div>
|
1338 |
+
<div>
|
1339 |
+
<?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>.
|
1340 |
+
</div>
|
1341 |
+
</div>
|
1342 |
+
<?php /***************************************************************************/
|
1343 |
+
}
|
1344 |
+
echo '<form class="'.($strTab != 'sitebrowser'?'wp-piwik-settings':'').'" method="post">';
|
1345 |
+
echo '<input type="hidden" name="action" value="save_wp-piwik_settings" />';
|
1346 |
+
wp_nonce_field('wp-piwik_settings');
|
1347 |
+
// Show settings
|
1348 |
+
if (($pagenow == 'options-general.php' || $pagenow == 'settings.php') && $_GET['page'] == 'wp-piwik/wp-piwik.php') {
|
1349 |
+
echo '<table class="wp-piwik-form-table form-table">';
|
1350 |
+
// Get tab contents
|
1351 |
+
require_once('settings/'.$strTab.'.php');
|
1352 |
+
// Show submit button
|
1353 |
+
if (!in_array($strTab, array('homepage','credits','support','sitebrowser')))
|
1354 |
+
echo '<tr><td><p class="submit" style="clear: both;padding:0;margin:0"><input type="submit" name="Submit" class="button-primary" value="'.__('Save settings', 'wp-piwik').'" /><input type="hidden" name="wp-piwik_settings_submit" value="Y" /></p></td></tr>';
|
1355 |
+
echo '</table>';
|
1356 |
+
}
|
1357 |
+
// Close form
|
1358 |
+
echo '</form></div>';
|
1359 |
+
}
|
1360 |
+
|
1361 |
+
/**
|
1362 |
+
* Check if SSL is used
|
1363 |
+
*/
|
1364 |
+
private static function isSSL() {
|
1365 |
+
return (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off');
|
1366 |
+
}
|
1367 |
+
|
1368 |
+
/**
|
1369 |
+
* Show an error message extended by a support site link
|
1370 |
+
*/
|
1371 |
+
private static function showErrorMessage($strMessage) {
|
1372 |
+
echo '<strong class="wp-piwik-error">'.__('An error occured', 'wp-piwik').':</strong> '.$strMessage.' [<a href="'.(self::$settings->checkNetworkActivation()?'network/settings':'options-general').'.php?page=wp-piwik/wp-piwik.php&tab=support">'.__('Support','wp-piwik').'</a>]';
|
1373 |
+
}
|
1374 |
+
|
1375 |
+
/**
|
1376 |
+
* Read a RSS feed
|
1377 |
+
*/
|
1378 |
+
private static function readRSSFeed($strFeedURL, $intCount = 5) {
|
1379 |
+
$aryResult = array();
|
1380 |
+
if (function_exists('simplexml_load_file') && !empty($strFeedURL)) {
|
1381 |
+
$objXML = @simplexml_load_file($strFeedURL);
|
1382 |
+
if (empty($strFeedURL) || !$objXML || !isset($objXML->channel[0]->item))
|
1383 |
+
return array(array('title' => 'Can\'t read RSS feed.','url' => $strFeedURL));
|
1384 |
+
foreach($objXML->channel[0]->item as $objItem) {
|
1385 |
+
if( $intCount-- == 0 ) break;
|
1386 |
+
$aryResult[] = array('title' => $objItem->title[0], 'url' => $objItem->link[0]);
|
1387 |
+
}
|
1388 |
+
}
|
1389 |
+
return $aryResult;
|
1390 |
+
}
|
1391 |
+
|
1392 |
+
/**
|
1393 |
+
* Execute test script
|
1394 |
+
*/
|
1395 |
+
private static function loadTestscript() {
|
1396 |
+
require_once('debug/testscript.php');
|
1397 |
+
}
|
1398 |
+
|
1399 |
+
/**
|
1400 |
+
* Get a blog's piwik ID
|
1401 |
+
*/
|
1402 |
+
public static function getSiteID($intBlogID = null) {
|
1403 |
+
$intResult = self::$settings->getOption('site_id');
|
1404 |
+
if (self::$settings->checkNetworkActivation() && !empty($intBlogID)) {
|
1405 |
+
$aryResult = get_blog_option($intBlogID, 'wp-piwik_settings');
|
1406 |
+
$intResult = $aryResult['site_id'];
|
1407 |
+
}
|
1408 |
+
return (is_int($intResult)?$intResult:'n/a');
|
1409 |
}
|
|
|
1410 |
|
1411 |
+
public static function isConfigured() {
|
1412 |
+
return (
|
1413 |
+
self::$settings->getGlobalOption('piwik_token')
|
1414 |
+
&& (
|
1415 |
+
(
|
1416 |
+
(self::$settings->getGlobalOption('piwik_mode') == 'http') && (self::$settings->getGlobalOption('piwik_url'))
|
1417 |
+
) || (
|
1418 |
+
(self::$settings->getGlobalOption('piwik_mode') == 'php') && (self::$settings->getGlobalOption('piwik_path'))
|
1419 |
+
)
|
1420 |
+
)
|
1421 |
+
);
|
1422 |
+
}
|
1423 |
+
|
1424 |
+
private function isUpdated() {
|
1425 |
+
return self::$settings->getGlobalOption('revision') && self::$settings->getGlobalOption('revision') < self::$intRevisionId;
|
1426 |
+
}
|
1427 |
+
|
1428 |
+
private function isConfigSubmitted() {
|
1429 |
+
return isset($_POST['action']) && $_POST['action'] == 'save_wp-piwik_settings';
|
1430 |
+
}
|
1431 |
+
|
1432 |
+
private function isPHPMode() {
|
1433 |
+
return self::$settings->getGlobalOption('piwik_mode') && self::$settings->getGlobalOption('piwik_mode') == 'php';
|
1434 |
+
}
|
1435 |
+
|
1436 |
+
private function isNetworkMode() {
|
1437 |
+
return self::$settings->checkNetworkActivation();
|
1438 |
+
}
|
1439 |
+
|
1440 |
+
private function isDashboardActive() {
|
1441 |
+
return self::$settings->getGlobalOption('dashboard_widget') || self::$settings->getGlobalOption('dashboard_chart') || self::$settings->getGlobalOption('dashboard_seo');
|
1442 |
+
}
|
1443 |
+
|
1444 |
+
private function isToolbarActive() {
|
1445 |
+
return self::$settings->getGlobalOption('toolbar');
|
1446 |
+
}
|
1447 |
+
|
1448 |
+
private function isTrackingActive() {
|
1449 |
+
return self::$settings->getGlobalOption('add_tracking_code');
|
1450 |
+
}
|
1451 |
+
|
1452 |
+
private function isAdminTrackingActive() {
|
1453 |
+
return self::$settings->getGlobalOption('track_admin');
|
1454 |
+
}
|
1455 |
+
|
1456 |
+
private function isAddNoScriptCode() {
|
1457 |
+
return self::$settings->getGlobalOption('track_noscript');
|
1458 |
+
}
|
1459 |
+
|
1460 |
+
private function isTrackFeed() {
|
1461 |
+
return self::$settings->getGlobalOption('track_feed');
|
1462 |
+
}
|
1463 |
+
|
1464 |
+
private function isAddFeedCampaign() {
|
1465 |
+
return self::$settings->getGlobalOption('track_feed_addcampaign');
|
1466 |
+
}
|
1467 |
+
|
1468 |
+
private function isAddShortcode() {
|
1469 |
+
return self::$settings->getGlobalOption('shortcodes');
|
1470 |
+
}
|
1471 |
+
|
1472 |
+
private static function definePiwikConstants() {
|
1473 |
+
if (!defined('PIWIK_INCLUDE_PATH')) {
|
1474 |
+
define('PIWIK_INCLUDE_PATH', self::$settings->getGlobalOption('piwik_path'));
|
1475 |
+
define('PIWIK_USER_PATH', self::$settings->getGlobalOption('piwik_path'));
|
1476 |
+
define('PIWIK_ENABLE_DISPATCH', false);
|
1477 |
+
define('PIWIK_ENABLE_ERROR_HANDLER', false);
|
1478 |
+
define('PIWIK_ENABLE_SESSION_START', false);
|
1479 |
+
}
|
1480 |
+
}
|
1481 |
+
|
1482 |
+
private function openLogger() {
|
1483 |
+
switch (WP_PIWIK_ACTIVATE_LOGGER) {
|
1484 |
+
case 2:
|
1485 |
+
require_once('classes/WP_Piwik_Logger_File.php');
|
1486 |
+
self::$logger = new WP_Piwik_Logger_File(__CLASS__);
|
1487 |
+
break;
|
1488 |
+
default:
|
1489 |
+
require_once('classes/WP_Piwik_Logger_Dummy.php');
|
1490 |
+
self::$logger = new WP_Piwik_Logger_Dummy(__CLASS__);
|
1491 |
+
}
|
1492 |
+
}
|
1493 |
+
|
1494 |
+
private function closeLogger() {
|
1495 |
+
self::$logger = null;
|
1496 |
+
}
|
1497 |
+
|
1498 |
+
private function openSettings() {
|
1499 |
+
$this->includeFile('classes/WP_Piwik_Settings');
|
1500 |
+
self::$settings = new WP_Piwik_Settings(self::$logger);
|
1501 |
+
}
|
1502 |
+
|
1503 |
+
private function subClassConfig() {
|
1504 |
+
return array(
|
1505 |
+
'wp_piwik' => $this,
|
1506 |
+
'logger' => self::$logger,
|
1507 |
+
'settings' => self::$settings
|
1508 |
+
);
|
1509 |
+
}
|
1510 |
+
|
1511 |
+
private function includeFile($strFile) {
|
1512 |
+
self::$logger->log('Include '.$strFile.'.php');
|
1513 |
+
if (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.$strFile.'.php'))
|
1514 |
+
include(dirname(__FILE__).DIRECTORY_SEPARATOR.$strFile.'.php');
|
1515 |
+
}
|
1516 |
+
|
1517 |
+
private function isHiddenUser() {
|
1518 |
+
if (is_multisite())
|
1519 |
+
foreach (self::$settings->getGlobalOption('capability_stealth') as $key => $val)
|
1520 |
+
if ($val && current_user_can($key)) return true;
|
1521 |
+
return current_user_can('wp-piwik_stealth');
|
1522 |
+
}
|
1523 |
+
|
1524 |
+
private function isCurrentTrackingCode() {
|
1525 |
+
return (self::$settings->getOption('last_tracking_code_update') < self::$settings->getGlobalOption('last_settings_update'));
|
1526 |
+
}
|
1527 |
+
|
1528 |
+
function site_header() {
|
1529 |
+
self::$logger->log('Using deprecated function site_header');
|
1530 |
+
$this->addJavascriptCode();
|
1531 |
+
}
|
1532 |
+
|
1533 |
+
function site_footer() {
|
1534 |
+
self::$logger->log('Using deprecated function site_footer');
|
1535 |
+
$this->addNoscriptCode();
|
1536 |
+
}
|
1537 |
+
|
1538 |
+
public function onPostStatusTransition($newStatus, $oldStatus, $post) {
|
1539 |
+
if ($newStatus == 'publish' && $oldStatus != 'publish' ) {
|
1540 |
+
add_action('publish_post', array($this, 'addPiwikAnnotation'));
|
1541 |
+
}
|
1542 |
+
}
|
1543 |
+
|
1544 |
+
}
|
1545 |
}
|
1546 |
|
1547 |
+
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'config.php');
|
1548 |
+
|
1549 |
+
if (class_exists('wp_piwik'))
|
1550 |
+
$GLOBALS['wp_piwik'] = new wp_piwik();
|
1551 |
+
|
1552 |
+
/* EOF */
|
|
|
|
|
|
|
|
|
|
|
|