Version Description
- September 24th, 2015 =
- Added: Admin notice to warn about the upcoming release (major re-write)
Download this release
Release Info
Developer | eherman24 |
Plugin | Easy Forms for MailChimp |
Version | 5.4.4 |
Comparing to | |
See all releases |
Code changes from version 5.4.3 to 5.4.4
- classes/class.yksemeBase.php +3969 -3923
- composer.json +0 -8
- readme.txt +8 -2
- yikes-inc-easy-mailchimp-extender.php +2 -2
classes/class.yksemeBase.php
CHANGED
@@ -1,3924 +1,3970 @@
|
|
1 |
-
<?php
|
2 |
-
if(!class_exists("yksemeBase")) {
|
3 |
-
class yksemeBase {
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Variables
|
7 |
-
*/
|
8 |
-
private $error = false;
|
9 |
-
private $errorMsg = '';
|
10 |
-
public $sessName = 'ykseme';
|
11 |
-
public $optionVal = false;
|
12 |
-
public $currentLists = false;
|
13 |
-
public $currentListsCt = false;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Construct
|
17 |
-
*/
|
18 |
-
public function __construct() {
|
19 |
-
yksemeBase::initialize();
|
20 |
-
add_action('init', array(&$this, 'ykes_mc_apply_filters'));
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
public function
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
public function
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
}
|
97 |
-
|
98 |
-
//
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
'
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
$this->optionVal
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
function
|
152 |
-
return
|
153 |
-
}
|
154 |
-
|
155 |
-
|
156 |
-
public function
|
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 |
-
if(
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
$
|
252 |
-
$
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
$
|
286 |
-
}
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
'
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
)
|
418 |
-
|
419 |
-
|
420 |
-
|
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 |
-
public function
|
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 |
-
|
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 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
} // end
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
//
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
public function
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
//
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
$
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
}
|
1471 |
-
$
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
);
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
$
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
//
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
}
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
$
|
1675 |
-
|
1676 |
-
try
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
} catch( Exception $e ) {
|
1682 |
-
echo '<strong>'.$e->getMessage().'</strong>';
|
1683 |
-
// write our error to the error log,
|
1684 |
-
// when advanced debug is enabled
|
1685 |
-
if ( $this->optionVal['debug'] == 1 ) {
|
1686 |
-
$this->writeErrorToErrorLog( $e );
|
1687 |
-
}
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
//
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
//
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
</
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
//
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
</
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
|
2154 |
-
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
|
2176 |
-
|
2177 |
-
|
2178 |
-
|
2179 |
-
|
2180 |
-
|
2181 |
-
|
2182 |
-
|
2183 |
-
|
2184 |
-
|
2185 |
-
//
|
2186 |
-
|
2187 |
-
|
2188 |
-
|
2189 |
-
|
2190 |
-
|
2191 |
-
|
2192 |
-
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
-
|
2197 |
-
|
2198 |
-
|
2199 |
-
|
2200 |
-
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
|
2207 |
-
|
2208 |
-
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
|
2223 |
-
|
2224 |
-
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
|
2232 |
-
|
2233 |
-
|
2234 |
-
|
2235 |
-
|
2236 |
-
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
|
2245 |
-
|
2246 |
-
|
2247 |
-
|
2248 |
-
|
2249 |
-
|
2250 |
-
|
2251 |
-
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
|
2257 |
-
|
2258 |
-
|
2259 |
-
|
2260 |
-
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
|
2292 |
-
|
2293 |
-
|
2294 |
-
//
|
2295 |
-
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
2316 |
-
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
|
2322 |
-
|
2323 |
-
|
2324 |
-
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
|
2329 |
-
|
2330 |
-
|
2331 |
-
|
2332 |
-
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
|
2337 |
-
|
2338 |
-
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
|
2398 |
-
|
2399 |
-
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
//
|
2418 |
-
|
2419 |
-
|
2420 |
-
|
2421 |
-
//
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
|
2428 |
-
|
2429 |
-
|
2430 |
-
|
2431 |
-
|
2432 |
-
|
2433 |
-
|
2434 |
-
|
2435 |
-
|
2436 |
-
|
2437 |
-
|
2438 |
-
|
2439 |
-
|
2440 |
-
|
2441 |
-
|
2442 |
-
|
2443 |
-
|
2444 |
-
|
2445 |
-
|
2446 |
-
'
|
2447 |
-
|
2448 |
-
|
2449 |
-
|
2450 |
-
|
2451 |
-
|
2452 |
-
|
2453 |
-
|
2454 |
-
|
2455 |
-
|
2456 |
-
|
2457 |
-
|
2458 |
-
|
2459 |
-
|
2460 |
-
|
2461 |
-
|
2462 |
-
|
2463 |
-
|
2464 |
-
|
2465 |
-
|
2466 |
-
|
2467 |
-
|
2468 |
-
|
2469 |
-
|
2470 |
-
|
2471 |
-
|
2472 |
-
|
2473 |
-
//
|
2474 |
-
|
2475 |
-
|
2476 |
-
|
2477 |
-
|
2478 |
-
|
2479 |
-
|
2480 |
-
|
2481 |
-
|
2482 |
-
|
2483 |
-
|
2484 |
-
|
2485 |
-
|
2486 |
-
|
2487 |
-
|
2488 |
-
|
2489 |
-
|
2490 |
-
|
2491 |
-
|
2492 |
-
|
2493 |
-
|
2494 |
-
|
2495 |
-
|
2496 |
-
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
-
|
2501 |
-
|
2502 |
-
|
2503 |
-
|
2504 |
-
|
2505 |
-
|
2506 |
-
|
2507 |
-
|
2508 |
-
|
2509 |
-
|
2510 |
-
|
2511 |
-
|
2512 |
-
|
2513 |
-
|
2514 |
-
|
2515 |
-
|
2516 |
-
|
2517 |
-
|
2518 |
-
|
2519 |
-
|
2520 |
-
|
2521 |
-
|
2522 |
-
|
2523 |
-
|
2524 |
-
|
2525 |
-
|
2526 |
-
|
2527 |
-
|
2528 |
-
|
2529 |
-
|
2530 |
-
|
2531 |
-
|
2532 |
-
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
|
2543 |
-
|
2544 |
-
|
2545 |
-
|
2546 |
-
|
2547 |
-
|
2548 |
-
|
2549 |
-
|
2550 |
-
|
2551 |
-
|
2552 |
-
|
2553 |
-
|
2554 |
-
|
2555 |
-
|
2556 |
-
|
2557 |
-
|
2558 |
-
|
2559 |
-
|
2560 |
-
|
2561 |
-
|
2562 |
-
|
2563 |
-
|
2564 |
-
|
2565 |
-
|
2566 |
-
|
2567 |
-
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
|
2573 |
-
|
2574 |
-
|
2575 |
-
|
2576 |
-
|
2577 |
-
|
2578 |
-
|
2579 |
-
|
2580 |
-
|
2581 |
-
|
2582 |
-
|
2583 |
-
|
2584 |
-
|
2585 |
-
|
2586 |
-
|
2587 |
-
|
2588 |
-
|
2589 |
-
|
2590 |
-
|
2591 |
-
|
2592 |
-
|
2593 |
-
|
2594 |
-
|
2595 |
-
|
2596 |
-
|
2597 |
-
|
2598 |
-
|
2599 |
-
|
2600 |
-
|
2601 |
-
|
2602 |
-
|
2603 |
-
|
2604 |
-
|
2605 |
-
|
2606 |
-
|
2607 |
-
|
2608 |
-
|
2609 |
-
|
2610 |
-
|
2611 |
-
|
2612 |
-
|
2613 |
-
|
2614 |
-
|
2615 |
-
|
2616 |
-
|
2617 |
-
|
2618 |
-
|
2619 |
-
|
2620 |
-
|
2621 |
-
|
2622 |
-
|
2623 |
-
|
2624 |
-
|
2625 |
-
|
2626 |
-
|
2627 |
-
|
2628 |
-
|
2629 |
-
|
2630 |
-
|
2631 |
-
|
2632 |
-
|
2633 |
-
|
2634 |
-
|
2635 |
-
|
2636 |
-
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
|
2641 |
-
|
2642 |
-
|
2643 |
-
|
2644 |
-
|
2645 |
-
|
2646 |
-
|
2647 |
-
$".$prefixa."(
|
2648 |
-
|
2649 |
-
|
2650 |
-
|
2651 |
-
|
2652 |
-
|
2653 |
-
|
2654 |
-
|
2655 |
-
|
2656 |
-
|
2657 |
-
|
2658 |
-
|
2659 |
-
|
2660 |
-
|
2661 |
-
|
2662 |
-
|
2663 |
-
|
2664 |
-
|
2665 |
-
|
2666 |
-
|
2667 |
-
|
2668 |
-
|
2669 |
-
|
2670 |
-
|
2671 |
-
|
2672 |
-
|
2673 |
-
|
2674 |
-
|
2675 |
-
|
2676 |
-
|
2677 |
-
|
2678 |
-
|
2679 |
-
|
2680 |
-
|
2681 |
-
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
-
|
2686 |
-
|
2687 |
-
|
2688 |
-
|
2689 |
-
|
2690 |
-
|
2691 |
-
|
2692 |
-
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
|
2698 |
-
|
2699 |
-
|
2700 |
-
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
|
2706 |
-
|
2707 |
-
|
2708 |
-
|
2709 |
-
|
2710 |
-
|
2711 |
-
|
2712 |
-
|
2713 |
-
|
2714 |
-
|
2715 |
-
|
2716 |
-
|
2717 |
-
|
2718 |
-
|
2719 |
-
|
2720 |
-
|
2721 |
-
|
2722 |
-
|
2723 |
-
|
2724 |
-
|
2725 |
-
|
2726 |
-
|
2727 |
-
|
2728 |
-
|
2729 |
-
|
2730 |
-
|
2731 |
-
|
2732 |
-
|
2733 |
-
|
2734 |
-
|
2735 |
-
|
2736 |
-
|
2737 |
-
|
2738 |
-
|
2739 |
-
|
2740 |
-
|
2741 |
-
|
2742 |
-
|
2743 |
-
|
2744 |
-
|
2745 |
-
|
2746 |
-
|
2747 |
-
|
2748 |
-
|
2749 |
-
|
2750 |
-
|
2751 |
-
|
2752 |
-
|
2753 |
-
|
2754 |
-
|
2755 |
-
|
2756 |
-
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
-
|
2762 |
-
|
2763 |
-
|
2764 |
-
|
2765 |
-
|
2766 |
-
|
2767 |
-
|
2768 |
-
|
2769 |
-
|
2770 |
-
|
2771 |
-
|
2772 |
-
|
2773 |
-
|
2774 |
-
|
2775 |
-
|
2776 |
-
|
2777 |
-
|
2778 |
-
|
2779 |
-
|
2780 |
-
|
2781 |
-
|
2782 |
-
|
2783 |
-
|
2784 |
-
|
2785 |
-
|
2786 |
-
|
2787 |
-
|
2788 |
-
|
2789 |
-
|
2790 |
-
|
2791 |
-
|
2792 |
-
|
2793 |
-
|
2794 |
-
|
2795 |
-
|
2796 |
-
|
2797 |
-
|
2798 |
-
|
2799 |
-
|
2800 |
-
|
2801 |
-
|
2802 |
-
|
2803 |
-
|
2804 |
-
|
2805 |
-
|
2806 |
-
|
2807 |
-
|
2808 |
-
|
2809 |
-
|
2810 |
-
|
2811 |
-
|
2812 |
-
|
2813 |
-
|
2814 |
-
|
2815 |
-
|
2816 |
-
|
2817 |
-
|
2818 |
-
|
2819 |
-
|
2820 |
-
|
2821 |
-
|
2822 |
-
|
2823 |
-
|
2824 |
-
|
2825 |
-
|
2826 |
-
|
2827 |
-
|
2828 |
-
$
|
2829 |
-
|
2830 |
-
|
2831 |
-
|
2832 |
-
|
2833 |
-
|
2834 |
-
|
2835 |
-
|
2836 |
-
|
2837 |
-
|
2838 |
-
|
2839 |
-
|
2840 |
-
|
2841 |
-
|
2842 |
-
|
2843 |
-
|
2844 |
-
|
2845 |
-
|
2846 |
-
|
2847 |
-
|
2848 |
-
|
2849 |
-
|
2850 |
-
|
2851 |
-
|
2852 |
-
|
2853 |
-
|
2854 |
-
}
|
2855 |
-
|
2856 |
-
|
2857 |
-
}
|
2858 |
-
|
2859 |
-
|
2860 |
-
|
2861 |
-
|
2862 |
-
|
2863 |
-
|
2864 |
-
|
2865 |
-
|
2866 |
-
|
2867 |
-
|
2868 |
-
|
2869 |
-
|
2870 |
-
|
2871 |
-
|
2872 |
-
|
2873 |
-
|
2874 |
-
|
2875 |
-
|
2876 |
-
|
2877 |
-
|
2878 |
-
|
2879 |
-
|
2880 |
-
|
2881 |
-
|
2882 |
-
|
2883 |
-
|
2884 |
-
|
2885 |
-
|
2886 |
-
|
2887 |
-
|
2888 |
-
|
2889 |
-
|
2890 |
-
|
2891 |
-
|
2892 |
-
|
2893 |
-
|
2894 |
-
|
2895 |
-
|
2896 |
-
|
2897 |
-
|
2898 |
-
|
2899 |
-
|
2900 |
-
|
2901 |
-
|
2902 |
-
|
2903 |
-
|
2904 |
-
|
2905 |
-
|
2906 |
-
|
2907 |
-
|
2908 |
-
|
2909 |
-
|
2910 |
-
|
2911 |
-
|
2912 |
-
|
2913 |
-
|
2914 |
-
|
2915 |
-
|
2916 |
-
|
2917 |
-
|
2918 |
-
|
2919 |
-
|
2920 |
-
|
2921 |
-
|
2922 |
-
|
2923 |
-
|
2924 |
-
|
2925 |
-
|
2926 |
-
|
2927 |
-
|
2928 |
-
|
2929 |
-
|
2930 |
-
|
2931 |
-
|
2932 |
-
|
2933 |
-
|
2934 |
-
|
2935 |
-
|
2936 |
-
|
2937 |
-
|
2938 |
-
|
2939 |
-
|
2940 |
-
|
2941 |
-
|
2942 |
-
|
2943 |
-
|
2944 |
-
|
2945 |
-
|
2946 |
-
|
2947 |
-
|
2948 |
-
|
2949 |
-
|
2950 |
-
|
2951 |
-
function
|
2952 |
-
|
2953 |
-
|
2954 |
-
|
2955 |
-
|
2956 |
-
|
2957 |
-
|
2958 |
-
|
2959 |
-
|
2960 |
-
|
2961 |
-
|
2962 |
-
|
2963 |
-
|
2964 |
-
|
2965 |
-
|
2966 |
-
|
2967 |
-
|
2968 |
-
|
2969 |
-
|
2970 |
-
|
2971 |
-
|
2972 |
-
|
2973 |
-
|
2974 |
-
|
2975 |
-
|
2976 |
-
|
2977 |
-
|
2978 |
-
|
2979 |
-
|
2980 |
-
|
2981 |
-
|
2982 |
-
|
2983 |
-
|
2984 |
-
|
2985 |
-
|
2986 |
-
|
2987 |
-
|
2988 |
-
|
2989 |
-
|
2990 |
-
|
2991 |
-
|
2992 |
-
|
2993 |
-
|
2994 |
-
|
2995 |
-
|
2996 |
-
|
2997 |
-
|
2998 |
-
|
2999 |
-
|
3000 |
-
|
3001 |
-
|
3002 |
-
|
3003 |
-
|
3004 |
-
|
3005 |
-
|
3006 |
-
|
3007 |
-
|
3008 |
-
|
3009 |
-
|
3010 |
-
|
3011 |
-
|
3012 |
-
|
3013 |
-
|
3014 |
-
|
3015 |
-
|
3016 |
-
|
3017 |
-
|
3018 |
-
|
3019 |
-
|
3020 |
-
|
3021 |
-
|
3022 |
-
|
3023 |
-
|
3024 |
-
|
3025 |
-
|
3026 |
-
|
3027 |
-
|
3028 |
-
|
3029 |
-
|
3030 |
-
|
3031 |
-
|
3032 |
-
|
3033 |
-
|
3034 |
-
|
3035 |
-
|
3036 |
-
|
3037 |
-
|
3038 |
-
|
3039 |
-
|
3040 |
-
|
3041 |
-
|
3042 |
-
|
3043 |
-
|
3044 |
-
|
3045 |
-
|
3046 |
-
|
3047 |
-
|
3048 |
-
|
3049 |
-
|
3050 |
-
|
3051 |
-
|
3052 |
-
|
3053 |
-
|
3054 |
-
|
3055 |
-
|
3056 |
-
|
3057 |
-
|
3058 |
-
|
3059 |
-
|
3060 |
-
|
3061 |
-
|
3062 |
-
|
3063 |
-
|
3064 |
-
|
3065 |
-
|
3066 |
-
|
3067 |
-
|
3068 |
-
|
3069 |
-
|
3070 |
-
|
3071 |
-
|
3072 |
-
|
3073 |
-
|
3074 |
-
|
3075 |
-
|
3076 |
-
|
3077 |
-
|
3078 |
-
|
3079 |
-
|
3080 |
-
|
3081 |
-
|
3082 |
-
|
3083 |
-
|
3084 |
-
|
3085 |
-
|
3086 |
-
|
3087 |
-
|
3088 |
-
|
3089 |
-
|
3090 |
-
|
3091 |
-
|
3092 |
-
|
3093 |
-
|
3094 |
-
|
3095 |
-
|
3096 |
-
|
3097 |
-
}
|
3098 |
-
|
3099 |
-
|
3100 |
-
|
3101 |
-
|
3102 |
-
|
3103 |
-
|
3104 |
-
|
3105 |
-
|
3106 |
-
|
3107 |
-
|
3108 |
-
$
|
3109 |
-
|
3110 |
-
|
3111 |
-
|
3112 |
-
|
3113 |
-
|
3114 |
-
|
3115 |
-
|
3116 |
-
|
3117 |
-
|
3118 |
-
|
3119 |
-
|
3120 |
-
|
3121 |
-
|
3122 |
-
|
3123 |
-
|
3124 |
-
|
3125 |
-
|
3126 |
-
|
3127 |
-
$
|
3128 |
-
|
3129 |
-
|
3130 |
-
|
3131 |
-
|
3132 |
-
|
3133 |
-
|
3134 |
-
|
3135 |
-
|
3136 |
-
|
3137 |
-
|
3138 |
-
|
3139 |
-
|
3140 |
-
|
3141 |
-
|
3142 |
-
|
3143 |
-
|
3144 |
-
|
3145 |
-
|
3146 |
-
|
3147 |
-
|
3148 |
-
|
3149 |
-
|
3150 |
-
|
3151 |
-
|
3152 |
-
|
3153 |
-
|
3154 |
-
|
3155 |
-
|
3156 |
-
|
3157 |
-
|
3158 |
-
|
3159 |
-
|
3160 |
-
|
3161 |
-
|
3162 |
-
|
3163 |
-
|
3164 |
-
|
3165 |
-
|
3166 |
-
|
3167 |
-
|
3168 |
-
|
3169 |
-
|
3170 |
-
|
3171 |
-
|
3172 |
-
|
3173 |
-
|
3174 |
-
|
3175 |
-
|
3176 |
-
|
3177 |
-
|
3178 |
-
|
3179 |
-
|
3180 |
-
|
3181 |
-
|
3182 |
-
|
3183 |
-
|
3184 |
-
|
3185 |
-
|
3186 |
-
|
3187 |
-
|
3188 |
-
|
3189 |
-
|
3190 |
-
|
3191 |
-
|
3192 |
-
|
3193 |
-
|
3194 |
-
|
3195 |
-
|
3196 |
-
|
3197 |
-
|
3198 |
-
|
3199 |
-
|
3200 |
-
|
3201 |
-
|
3202 |
-
|
3203 |
-
|
3204 |
-
|
3205 |
-
|
3206 |
-
|
3207 |
-
|
3208 |
-
|
3209 |
-
|
3210 |
-
|
3211 |
-
|
3212 |
-
|
3213 |
-
|
3214 |
-
|
3215 |
-
|
3216 |
-
|
3217 |
-
|
3218 |
-
|
3219 |
-
|
3220 |
-
|
3221 |
-
|
3222 |
-
|
3223 |
-
|
3224 |
-
|
3225 |
-
|
3226 |
-
|
3227 |
-
|
3228 |
-
|
3229 |
-
|
3230 |
-
|
3231 |
-
|
3232 |
-
|
3233 |
-
|
3234 |
-
|
3235 |
-
|
3236 |
-
|
3237 |
-
|
3238 |
-
|
3239 |
-
|
3240 |
-
|
3241 |
-
|
3242 |
-
|
3243 |
-
|
3244 |
-
|
3245 |
-
|
3246 |
-
|
3247 |
-
|
3248 |
-
|
3249 |
-
|
3250 |
-
|
3251 |
-
|
3252 |
-
|
3253 |
-
|
3254 |
-
|
3255 |
-
|
3256 |
-
|
3257 |
-
|
3258 |
-
|
3259 |
-
|
3260 |
-
|
3261 |
-
|
3262 |
-
|
3263 |
-
|
3264 |
-
|
3265 |
-
|
3266 |
-
|
3267 |
-
|
3268 |
-
|
3269 |
-
|
3270 |
-
|
3271 |
-
|
3272 |
-
|
3273 |
-
|
3274 |
-
|
3275 |
-
|
3276 |
-
|
3277 |
-
|
3278 |
-
|
3279 |
-
|
3280 |
-
|
3281 |
-
|
3282 |
-
|
3283 |
-
|
3284 |
-
|
3285 |
-
|
3286 |
-
|
3287 |
-
|
3288 |
-
|
3289 |
-
|
3290 |
-
|
3291 |
-
|
3292 |
-
|
3293 |
-
|
3294 |
-
|
3295 |
-
|
3296 |
-
|
3297 |
-
|
3298 |
-
|
3299 |
-
|
3300 |
-
|
3301 |
-
|
3302 |
-
|
3303 |
-
|
3304 |
-
|
3305 |
-
|
3306 |
-
|
3307 |
-
|
3308 |
-
|
3309 |
-
|
3310 |
-
|
3311 |
-
|
3312 |
-
|
3313 |
-
|
3314 |
-
|
3315 |
-
|
3316 |
-
|
3317 |
-
|
3318 |
-
|
3319 |
-
|
3320 |
-
|
3321 |
-
|
3322 |
-
|
3323 |
-
|
3324 |
-
|
3325 |
-
|
3326 |
-
|
3327 |
-
|
3328 |
-
|
3329 |
-
|
3330 |
-
|
3331 |
-
|
3332 |
-
|
3333 |
-
|
3334 |
-
|
3335 |
-
|
3336 |
-
|
3337 |
-
|
3338 |
-
|
3339 |
-
|
3340 |
-
|
3341 |
-
|
3342 |
-
|
3343 |
-
|
3344 |
-
|
3345 |
-
|
3346 |
-
|
3347 |
-
|
3348 |
-
|
3349 |
-
|
3350 |
-
|
3351 |
-
|
3352 |
-
|
3353 |
-
|
3354 |
-
|
3355 |
-
|
3356 |
-
|
3357 |
-
|
3358 |
-
|
3359 |
-
|
3360 |
-
|
3361 |
-
|
3362 |
-
|
3363 |
-
|
3364 |
-
|
3365 |
-
|
3366 |
-
|
3367 |
-
|
3368 |
-
|
3369 |
-
|
3370 |
-
|
3371 |
-
|
3372 |
-
|
3373 |
-
|
3374 |
-
|
3375 |
-
|
3376 |
-
|
3377 |
-
|
3378 |
-
|
3379 |
-
|
3380 |
-
|
3381 |
-
|
3382 |
-
|
3383 |
-
|
3384 |
-
|
3385 |
-
|
3386 |
-
|
3387 |
-
|
3388 |
-
|
3389 |
-
|
3390 |
-
|
3391 |
-
|
3392 |
-
|
3393 |
-
|
3394 |
-
|
3395 |
-
|
3396 |
-
|
3397 |
-
|
3398 |
-
|
3399 |
-
|
3400 |
-
|
3401 |
-
|
3402 |
-
|
3403 |
-
|
3404 |
-
|
3405 |
-
|
3406 |
-
|
3407 |
-
|
3408 |
-
|
3409 |
-
|
3410 |
-
|
3411 |
-
|
3412 |
-
|
3413 |
-
|
3414 |
-
|
3415 |
-
|
3416 |
-
|
3417 |
-
|
3418 |
-
|
3419 |
-
|
3420 |
-
|
3421 |
-
|
3422 |
-
|
3423 |
-
|
3424 |
-
|
3425 |
-
|
3426 |
-
|
3427 |
-
|
3428 |
-
|
3429 |
-
|
3430 |
-
|
3431 |
-
|
3432 |
-
|
3433 |
-
|
3434 |
-
|
3435 |
-
|
3436 |
-
'
|
3437 |
-
|
3438 |
-
|
3439 |
-
|
3440 |
-
|
3441 |
-
|
3442 |
-
|
3443 |
-
|
3444 |
-
|
3445 |
-
|
3446 |
-
|
3447 |
-
|
3448 |
-
|
3449 |
-
|
3450 |
-
|
3451 |
-
|
3452 |
-
|
3453 |
-
|
3454 |
-
|
3455 |
-
|
3456 |
-
|
3457 |
-
|
3458 |
-
|
3459 |
-
|
3460 |
-
|
3461 |
-
|
3462 |
-
|
3463 |
-
|
3464 |
-
|
3465 |
-
|
3466 |
-
|
3467 |
-
|
3468 |
-
|
3469 |
-
|
3470 |
-
|
3471 |
-
|
3472 |
-
|
3473 |
-
|
3474 |
-
|
3475 |
-
|
3476 |
-
|
3477 |
-
|
3478 |
-
|
3479 |
-
|
3480 |
-
|
3481 |
-
|
3482 |
-
|
3483 |
-
|
3484 |
-
|
3485 |
-
|
3486 |
-
|
3487 |
-
|
3488 |
-
|
3489 |
-
|
3490 |
-
|
3491 |
-
|
3492 |
-
|
3493 |
-
|
3494 |
-
|
3495 |
-
|
3496 |
-
|
3497 |
-
|
3498 |
-
|
3499 |
-
|
3500 |
-
|
3501 |
-
|
3502 |
-
|
3503 |
-
|
3504 |
-
|
3505 |
-
|
3506 |
-
|
3507 |
-
|
3508 |
-
|
3509 |
-
|
3510 |
-
|
3511 |
-
|
3512 |
-
|
3513 |
-
|
3514 |
-
|
3515 |
-
|
3516 |
-
|
3517 |
-
|
3518 |
-
|
3519 |
-
|
3520 |
-
|
3521 |
-
|
3522 |
-
|
3523 |
-
|
3524 |
-
|
3525 |
-
|
3526 |
-
|
3527 |
-
|
3528 |
-
|
3529 |
-
|
3530 |
-
|
3531 |
-
|
3532 |
-
|
3533 |
-
|
3534 |
-
|
3535 |
-
|
3536 |
-
|
3537 |
-
|
3538 |
-
|
3539 |
-
|
3540 |
-
|
3541 |
-
|
3542 |
-
|
3543 |
-
|
3544 |
-
|
3545 |
-
|
3546 |
-
|
3547 |
-
|
3548 |
-
|
3549 |
-
|
3550 |
-
|
3551 |
-
|
3552 |
-
|
3553 |
-
|
3554 |
-
|
3555 |
-
|
3556 |
-
|
3557 |
-
|
3558 |
-
|
3559 |
-
|
3560 |
-
|
3561 |
-
|
3562 |
-
|
3563 |
-
|
3564 |
-
|
3565 |
-
|
3566 |
-
|
3567 |
-
|
3568 |
-
|
3569 |
-
|
3570 |
-
|
3571 |
-
|
3572 |
-
|
3573 |
-
|
3574 |
-
|
3575 |
-
|
3576 |
-
|
3577 |
-
|
3578 |
-
|
3579 |
-
|
3580 |
-
|
3581 |
-
|
3582 |
-
|
3583 |
-
|
3584 |
-
|
3585 |
-
|
3586 |
-
|
3587 |
-
|
3588 |
-
|
3589 |
-
|
3590 |
-
|
3591 |
-
|
3592 |
-
|
3593 |
-
|
3594 |
-
|
3595 |
-
|
3596 |
-
|
3597 |
-
|
3598 |
-
|
3599 |
-
|
3600 |
-
|
3601 |
-
|
3602 |
-
|
3603 |
-
|
3604 |
-
|
3605 |
-
|
3606 |
-
|
3607 |
-
|
3608 |
-
|
3609 |
-
|
3610 |
-
|
3611 |
-
|
3612 |
-
|
3613 |
-
|
3614 |
-
|
3615 |
-
|
3616 |
-
|
3617 |
-
|
3618 |
-
|
3619 |
-
|
3620 |
-
|
3621 |
-
|
3622 |
-
|
3623 |
-
|
3624 |
-
|
3625 |
-
|
3626 |
-
|
3627 |
-
|
3628 |
-
|
3629 |
-
|
3630 |
-
|
3631 |
-
|
3632 |
-
//
|
3633 |
-
|
3634 |
-
|
3635 |
-
|
3636 |
-
|
3637 |
-
|
3638 |
-
|
3639 |
-
|
3640 |
-
|
3641 |
-
|
3642 |
-
|
3643 |
-
|
3644 |
-
}
|
3645 |
-
|
3646 |
-
//
|
3647 |
-
function
|
3648 |
-
|
3649 |
-
//
|
3650 |
-
|
3651 |
-
|
3652 |
-
|
3653 |
-
|
3654 |
-
|
3655 |
-
|
3656 |
-
|
3657 |
-
|
3658 |
-
|
3659 |
-
|
3660 |
-
|
3661 |
-
|
3662 |
-
|
3663 |
-
|
3664 |
-
|
3665 |
-
|
3666 |
-
|
3667 |
-
|
3668 |
-
|
3669 |
-
|
3670 |
-
|
3671 |
-
|
3672 |
-
|
3673 |
-
|
3674 |
-
|
3675 |
-
|
3676 |
-
|
3677 |
-
|
3678 |
-
|
3679 |
-
|
3680 |
-
|
3681 |
-
|
3682 |
-
|
3683 |
-
|
3684 |
-
|
3685 |
-
|
3686 |
-
|
3687 |
-
|
3688 |
-
|
3689 |
-
|
3690 |
-
|
3691 |
-
|
3692 |
-
|
3693 |
-
|
3694 |
-
|
3695 |
-
|
3696 |
-
|
3697 |
-
|
3698 |
-
|
3699 |
-
|
3700 |
-
|
3701 |
-
|
3702 |
-
|
3703 |
-
|
3704 |
-
|
3705 |
-
|
3706 |
-
|
3707 |
-
|
3708 |
-
|
3709 |
-
|
3710 |
-
|
3711 |
-
|
3712 |
-
|
3713 |
-
|
3714 |
-
|
3715 |
-
|
3716 |
-
|
3717 |
-
|
3718 |
-
|
3719 |
-
|
3720 |
-
|
3721 |
-
|
3722 |
-
|
3723 |
-
|
3724 |
-
|
3725 |
-
|
3726 |
-
|
3727 |
-
|
3728 |
-
|
3729 |
-
|
3730 |
-
|
3731 |
-
|
3732 |
-
|
3733 |
-
|
3734 |
-
}
|
3735 |
-
|
3736 |
-
|
3737 |
-
|
3738 |
-
|
3739 |
-
|
3740 |
-
|
3741 |
-
*
|
3742 |
-
|
3743 |
-
|
3744 |
-
|
3745 |
-
|
3746 |
-
|
3747 |
-
echo '<
|
3748 |
-
|
3749 |
-
|
3750 |
-
|
3751 |
-
|
3752 |
-
|
3753 |
-
|
3754 |
-
|
3755 |
-
|
3756 |
-
|
3757 |
-
|
3758 |
-
|
3759 |
-
|
3760 |
-
|
3761 |
-
|
3762 |
-
|
3763 |
-
|
3764 |
-
|
3765 |
-
|
3766 |
-
|
3767 |
-
|
3768 |
-
|
3769 |
-
|
3770 |
-
|
3771 |
-
|
3772 |
-
|
3773 |
-
|
3774 |
-
|
3775 |
-
|
3776 |
-
|
3777 |
-
|
3778 |
-
|
3779 |
-
|
3780 |
-
|
3781 |
-
|
3782 |
-
|
3783 |
-
|
3784 |
-
|
3785 |
-
|
3786 |
-
|
3787 |
-
|
3788 |
-
|
3789 |
-
|
3790 |
-
|
3791 |
-
|
3792 |
-
|
3793 |
-
|
3794 |
-
|
3795 |
-
|
3796 |
-
|
3797 |
-
|
3798 |
-
|
3799 |
-
|
3800 |
-
|
3801 |
-
|
3802 |
-
|
3803 |
-
|
3804 |
-
|
3805 |
-
|
3806 |
-
|
3807 |
-
|
3808 |
-
|
3809 |
-
|
3810 |
-
|
3811 |
-
|
3812 |
-
|
3813 |
-
|
3814 |
-
|
3815 |
-
|
3816 |
-
|
3817 |
-
|
3818 |
-
|
3819 |
-
|
3820 |
-
|
3821 |
-
|
3822 |
-
|
3823 |
-
|
3824 |
-
|
3825 |
-
|
3826 |
-
|
3827 |
-
|
3828 |
-
|
3829 |
-
|
3830 |
-
|
3831 |
-
|
3832 |
-
|
3833 |
-
|
3834 |
-
|
3835 |
-
|
3836 |
-
|
3837 |
-
|
3838 |
-
|
3839 |
-
|
3840 |
-
|
3841 |
-
|
3842 |
-
|
3843 |
-
|
3844 |
-
|
3845 |
-
|
3846 |
-
|
3847 |
-
|
3848 |
-
|
3849 |
-
|
3850 |
-
|
3851 |
-
|
3852 |
-
|
3853 |
-
|
3854 |
-
|
3855 |
-
|
3856 |
-
|
3857 |
-
|
3858 |
-
|
3859 |
-
|
3860 |
-
|
3861 |
-
|
3862 |
-
|
3863 |
-
|
3864 |
-
|
3865 |
-
|
3866 |
-
|
3867 |
-
|
3868 |
-
|
3869 |
-
|
3870 |
-
|
3871 |
-
|
3872 |
-
|
3873 |
-
|
3874 |
-
|
3875 |
-
|
3876 |
-
|
3877 |
-
|
3878 |
-
|
3879 |
-
|
3880 |
-
|
3881 |
-
|
3882 |
-
|
3883 |
-
|
3884 |
-
|
3885 |
-
|
3886 |
-
<
|
3887 |
-
|
3888 |
-
|
3889 |
-
|
3890 |
-
|
3891 |
-
|
3892 |
-
|
3893 |
-
|
3894 |
-
|
3895 |
-
|
3896 |
-
|
3897 |
-
|
3898 |
-
|
3899 |
-
|
3900 |
-
|
3901 |
-
|
3902 |
-
|
3903 |
-
|
3904 |
-
|
3905 |
-
|
3906 |
-
|
3907 |
-
|
3908 |
-
*
|
3909 |
-
*
|
3910 |
-
*
|
3911 |
-
|
3912 |
-
|
3913 |
-
|
3914 |
-
|
3915 |
-
|
3916 |
-
|
3917 |
-
|
3918 |
-
$
|
3919 |
-
|
3920 |
-
|
3921 |
-
|
3922 |
-
|
3923 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3924 |
?>
|
1 |
+
<?php
|
2 |
+
if(!class_exists("yksemeBase")) {
|
3 |
+
class yksemeBase {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Variables
|
7 |
+
*/
|
8 |
+
private $error = false;
|
9 |
+
private $errorMsg = '';
|
10 |
+
public $sessName = 'ykseme';
|
11 |
+
public $optionVal = false;
|
12 |
+
public $currentLists = false;
|
13 |
+
public $currentListsCt = false;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Construct
|
17 |
+
*/
|
18 |
+
public function __construct() {
|
19 |
+
yksemeBase::initialize();
|
20 |
+
add_action('init', array(&$this, 'ykes_mc_apply_filters'));
|
21 |
+
/* Display a notice that can be dismissed */
|
22 |
+
add_action('admin_notices', array( $this, 'yikes_mailchimp_update_admin_notice' ) );
|
23 |
+
add_action('admin_init', array( $this, 'yikes_mailchimp_update_nag_ignore' ) );
|
24 |
+
}
|
25 |
+
|
26 |
+
public function yikes_mailchimp_update_admin_notice() {
|
27 |
+
global $current_user ;
|
28 |
+
$user_id = $current_user->ID;
|
29 |
+
if( current_user_can( 'activate_plugins' ) ) {
|
30 |
+
/* Check that the user hasn't already clicked to ignore the message */
|
31 |
+
if ( ! get_option( 'yikes_mailchimp_upgrade_notice', '0' ) ) {
|
32 |
+
?>
|
33 |
+
<style>
|
34 |
+
#yikes_mailchimp_mailing_list_form {
|
35 |
+
display: inline-block;
|
36 |
+
width: 100%;
|
37 |
+
}
|
38 |
+
#yikes_mailchimp_mailing_list_form label {
|
39 |
+
float: left;
|
40 |
+
margin-right: .5em;
|
41 |
+
}
|
42 |
+
#yikes_mailchimp_mailing_list_form .submit {
|
43 |
+
float: left;
|
44 |
+
margin-top: 33px;.
|
45 |
+
margin-bottom: 0;
|
46 |
+
}
|
47 |
+
</style>
|
48 |
+
<?php
|
49 |
+
$upgrade_notice = __( '<strong>Notice: The next release of YIKES Easy Forms for MailChimp is a major update.</strong> The entire plugin has been re-written from the ground up to iron out reoccurring bugs and make the plugin better than ever!', 'yikes-inc-easy-mailchimp-extender' );
|
50 |
+
$upgrade_notice .= '<p>' . __( '<a href="http://www.yikesinc.com/services/yikes-inc-easy-mailchimp-extender/" target="_blank" title="YIKES Plugins Mailing List">' . __( 'Sign up for our Plugins mailing list', 'yikes-inc-easy-mailchimp-extender' ) . '</a>, ' . 'and before launch, we will send you <strong>a Guide to Upgrading</strong> as well as <strong>a coupon code</strong> for great new add-ons we built for the new version of the plugin.', 'yikes-inc-easy-mailchimp-extender' ) . '</p>';
|
51 |
+
$jQuery = "jQuery( '#yikes_mailchimp_mailing_list_form' ).fadeIn();return false;";
|
52 |
+
$links = '<a href="?yikes_mailchimp_upgrade_notice=1">' . __( 'Thanks, I got it!', 'yikes-inc-easy-mailchimp-extender' ) . '</a> | <a href="http://www.yikesinc.com/services/yikes-inc-easy-mailchimp-extender/" target="_blank" title="YIKES Plugins Mailing List">' . __( 'Sign up for our Mailing List', 'yikes-inc-easy-mailchimp-extender' ) . '</a>';
|
53 |
+
echo '<div class="updated"><p>';
|
54 |
+
echo $upgrade_notice;
|
55 |
+
echo '<p>' . $links . '</p>';
|
56 |
+
echo "</p></div>";
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
public function yikes_mailchimp_update_nag_ignore() {
|
62 |
+
/* If user clicks to ignore the notice, add that to their user meta */
|
63 |
+
if ( isset($_GET['yikes_mailchimp_upgrade_notice']) && '1' == $_GET['yikes_mailchimp_upgrade_notice'] ) {
|
64 |
+
update_option( 'yikes_mailchimp_upgrade_notice', '1' );
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Destruct
|
70 |
+
*/
|
71 |
+
public function __destruct() {
|
72 |
+
unset($this);
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Actions
|
77 |
+
* These are called when the plug in is initialized/deactivated/un-installed
|
78 |
+
*/
|
79 |
+
public function activate() {
|
80 |
+
// redirect the user on plugin activation
|
81 |
+
// to our MailChimp settings page
|
82 |
+
add_option('yks_easy_mc_plugin_do_activation_redirect', true);
|
83 |
+
|
84 |
+
// check if our option is already set
|
85 |
+
// if it exists, return
|
86 |
+
if( get_option( 'api_validation' ) ) {
|
87 |
+
return;
|
88 |
+
} else { // else create it
|
89 |
+
add_option('api_validation' , 'invalid_api_key');
|
90 |
+
}
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
public function deactivate() {
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
public function uninstall() { // delete options on plugin uninstall
|
99 |
+
delete_option (YKSEME_OPTION );
|
100 |
+
delete_option( 'api_validation' );
|
101 |
+
delete_option( 'imported_lists' );
|
102 |
+
delete_option( 'yikes_mailchimp_upgrade_notice' );
|
103 |
+
}
|
104 |
+
|
105 |
+
/***** INITIAL SETUP
|
106 |
+
****************************************************************************************************/
|
107 |
+
public function initialize() {
|
108 |
+
// include our initialization file
|
109 |
+
include YKSEME_PATH . 'lib/inc/yks-mc-init.php';
|
110 |
+
|
111 |
+
/*
|
112 |
+
Conditionally Include the MailChimp Class File
|
113 |
+
*/
|
114 |
+
if( !class_exists("Mailchimp") ) {
|
115 |
+
if ( $this->optionVal['ssl_verify_peer'] == 'true' ) {
|
116 |
+
require_once YKSEME_PATH.'classes/MCAPI_2.0.class.php';
|
117 |
+
} else {
|
118 |
+
require_once YKSEME_PATH.'classes/MCAPI_2.0.class.verify_false.php';
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
/*
|
123 |
+
* add our new ssl_verify_peer debug option, if it doesn't already exist
|
124 |
+
* @since v5.2
|
125 |
+
*/
|
126 |
+
if ( !isset( $this->optionVal['ssl_verify_peer'] ) ) {
|
127 |
+
$options = get_option( YKSEME_OPTION );
|
128 |
+
$options['ssl_verify_peer'] = 'true';
|
129 |
+
update_option( YKSEME_OPTION , $options );
|
130 |
+
}
|
131 |
+
|
132 |
+
/*
|
133 |
+
* add our new hide 'required text' option, if it doesn't already exist
|
134 |
+
* @since v5.3
|
135 |
+
*/
|
136 |
+
if ( !isset( $this->optionVal['yks-mailchimp-required-text'] ) ) {
|
137 |
+
$options = get_option( YKSEME_OPTION );
|
138 |
+
$options['yks-mailchimp-required-text'] = '0';
|
139 |
+
update_option( YKSEME_OPTION , $options );
|
140 |
+
}
|
141 |
+
|
142 |
+
}
|
143 |
+
|
144 |
+
// register and add our shortcodes
|
145 |
+
public function createShortcodes() {
|
146 |
+
add_shortcode( 'yks-mailchimp-list' , array( &$this, 'processShortcode' ) );
|
147 |
+
add_shortcode( 'yks-mailchimp-subscriber-count' , array( &$this, 'displaySubscriberCount') );
|
148 |
+
}
|
149 |
+
|
150 |
+
/** Custom Filter To Alter User Submitted Data **/
|
151 |
+
public function yikes_mc_get_form_data_filter( $mv ) {
|
152 |
+
return $mv;
|
153 |
+
}
|
154 |
+
|
155 |
+
/** Custom Filter To Alter User Already Subscribed Error Message **/
|
156 |
+
public function yikes_mc_user_already_subscribed_error_message_filter( $errorMessage , $email ) {
|
157 |
+
return $errorMessage;
|
158 |
+
}
|
159 |
+
|
160 |
+
// Create and store our initial plugin options
|
161 |
+
public function getOptionValue() {
|
162 |
+
$blog_title = get_bloginfo( 'name' );
|
163 |
+
$defaultVals = array(
|
164 |
+
'version' => YKSEME_VERSION_CURRENT,
|
165 |
+
'api-key' => '',
|
166 |
+
'flavor' => '1',
|
167 |
+
'debug' => '0',
|
168 |
+
'optin' => 'true',
|
169 |
+
'single-optin-message' => __('Thank You for subscribing!', 'yikes-inc-easy-mailchimp-extender'),
|
170 |
+
'double-optin-message' => __('Thank You for subscribing! Check your email for the confirmation message.', 'yikes-inc-easy-mailchimp-extender'),
|
171 |
+
'optIn-checkbox' => 'hide',
|
172 |
+
'yks-mailchimp-optIn-default-list' => 'select_list',
|
173 |
+
'yks-mailchimp-optin-checkbox-text' => 'Add me to the ' . $blog_title . ' mailing list',
|
174 |
+
'recaptcha-setting' => '0',
|
175 |
+
'yks-mailchimp-required-text' => '0',
|
176 |
+
'recaptcha-api-key' => '',
|
177 |
+
'recaptcha-private-api-key' => '',
|
178 |
+
'ssl_verify_peer' => 'true',
|
179 |
+
'lists' => array()
|
180 |
+
);
|
181 |
+
$ov = get_option(YKSEME_OPTION, $defaultVals);
|
182 |
+
$this->optionVal = $ov;
|
183 |
+
return $ov;
|
184 |
+
}
|
185 |
+
|
186 |
+
// run our update check to make sure the user is up to date
|
187 |
+
private function runUpdateCheck() {
|
188 |
+
if( ! isset( $this->optionVal['version'] ) || $this->optionVal['version'] < YKSEME_VERSION_CURRENT ) {
|
189 |
+
$this->runUpdateTasks();
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
|
194 |
+
/***** FUNCTIONS
|
195 |
+
****************************************************************************************************/
|
196 |
+
// check if were on the login page
|
197 |
+
function is_login_page() {
|
198 |
+
return in_array( $GLOBALS['pagenow'] , array( 'wp-login.php', 'wp-register.php' ) );
|
199 |
+
}
|
200 |
+
|
201 |
+
// create a slug like string, given some text (ie: this-is-the-name)
|
202 |
+
public function slugify( $text ) {
|
203 |
+
// replace non letter or digits by -
|
204 |
+
$text = preg_replace( '~[^\\pL\d]+~u', '-', $text );
|
205 |
+
// trim
|
206 |
+
$text = trim( $text, '-' );
|
207 |
+
// transliterate
|
208 |
+
$text = iconv( 'utf-8' , 'us-ascii//TRANSLIT' , $text );
|
209 |
+
// lowercase
|
210 |
+
$text = strtolower( $text);
|
211 |
+
// remove unwanted characters
|
212 |
+
$text = preg_replace( '~[^-\w]+~' , '' , $text );
|
213 |
+
if(empty($text))
|
214 |
+
{
|
215 |
+
return 'n-a';
|
216 |
+
}
|
217 |
+
return $text;
|
218 |
+
}
|
219 |
+
|
220 |
+
// create an array for any fields left blank
|
221 |
+
// not sure if still needed (CHECK)
|
222 |
+
public function getBlankFieldsArray( $lid='' ) {
|
223 |
+
$fields = array();
|
224 |
+
// Add Field
|
225 |
+
$name = $this->slugify('Email Address'.'-'.'EMAIL');
|
226 |
+
$addField = array(
|
227 |
+
'id' => $lid.'-'.$name,
|
228 |
+
'name' => $lid.'-'.$name,
|
229 |
+
'merge' => 'EMAIL',
|
230 |
+
'label' => 'Email Address',
|
231 |
+
'require' => '1',
|
232 |
+
'active' => '1',
|
233 |
+
'locked' => '1',
|
234 |
+
'sort' => '1',
|
235 |
+
'type' => 'email',
|
236 |
+
'help' => '',
|
237 |
+
'defalt' => '',
|
238 |
+
'choices' => ''
|
239 |
+
);
|
240 |
+
$fields[$addField['id']] = $addField;
|
241 |
+
// return our fields
|
242 |
+
return $fields;
|
243 |
+
}
|
244 |
+
|
245 |
+
// Create an array of data for imported fields based on the Merge Varaibles passed back from MailChimp
|
246 |
+
public function getImportedFieldsArray( $lid, $mv ) {
|
247 |
+
if( empty( $mv ) ) {
|
248 |
+
return false;
|
249 |
+
} else {
|
250 |
+
$fields = array();
|
251 |
+
$num = 1;
|
252 |
+
foreach($mv['data'][0]['merge_vars'] as $field) {
|
253 |
+
// Add Field
|
254 |
+
$name = $this->slugify(isset($field['label']).'-'.$field['tag']);
|
255 |
+
$addField = array(
|
256 |
+
'id' => $lid.'-'.$name,
|
257 |
+
'name' => $lid.$field['tag'],
|
258 |
+
'merge' => $field['tag'],
|
259 |
+
'label' => $field['name'],
|
260 |
+
'require' => $field['req'],
|
261 |
+
'active' => '1',
|
262 |
+
'locked' => '1',
|
263 |
+
'sort' => $field['order'],
|
264 |
+
'type' => $field['field_type'],
|
265 |
+
'help' => $field['helptext'],
|
266 |
+
'default' => $field['default'],
|
267 |
+
'choices' => (isset($field['choices']) ? $field['choices'] : '')
|
268 |
+
);
|
269 |
+
$fields[$addField['id']] = $addField;
|
270 |
+
$num++;
|
271 |
+
}
|
272 |
+
return $fields;
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
// Get the current users browser information
|
277 |
+
// Used specifically on the lists page
|
278 |
+
public function getBrowser() {
|
279 |
+
$u_agent = $_SERVER['HTTP_USER_AGENT'];
|
280 |
+
$bname = 'Unknown';
|
281 |
+
$platform = 'Unknown';
|
282 |
+
$version = "";
|
283 |
+
//First get the platform?
|
284 |
+
if( preg_match( '/linux/i', $u_agent ) ) {
|
285 |
+
$platform = 'Linux';
|
286 |
+
} elseif( preg_match( '/macintosh|mac os x/i', $u_agent ) ) {
|
287 |
+
$platform = 'Mac';
|
288 |
+
} elseif( preg_match( '/windows|win32/i' , $u_agent ) ) {
|
289 |
+
$platform = 'Windows';
|
290 |
+
}
|
291 |
+
|
292 |
+
// Next get the name of the useragent yes seperately and for good reason
|
293 |
+
if( preg_match( '/MSIE/i' , $u_agent ) && ! preg_match( '/Opera/i' , $u_agent ) ) {
|
294 |
+
$bname = 'Internet Explorer';
|
295 |
+
$ub = "MSIE";
|
296 |
+
} elseif( preg_match( '/Firefox/i' , $u_agent ) ) {
|
297 |
+
$bname = 'Mozilla Firefox';
|
298 |
+
$ub = "Firefox";
|
299 |
+
} elseif( preg_match( '/Chrome/i' , $u_agent ) ) {
|
300 |
+
$bname = 'Google Chrome';
|
301 |
+
$ub = "Chrome";
|
302 |
+
} elseif( preg_match( '/Safari/i' , $u_agent ) ) {
|
303 |
+
$bname = 'Apple Safari';
|
304 |
+
$ub = "Safari";
|
305 |
+
} elseif( preg_match( '/Opera/i' , $u_agent ) ) {
|
306 |
+
$bname = 'Opera';
|
307 |
+
$ub = "Opera";
|
308 |
+
} elseif( preg_match( '/Netscape/i' , $u_agent ) ) {
|
309 |
+
$bname = 'Netscape';
|
310 |
+
$ub = "Netscape";
|
311 |
+
}
|
312 |
+
|
313 |
+
// finally get the correct version number
|
314 |
+
$known = array('Version', $ub, 'other');
|
315 |
+
$pattern = '#(?<browser>' . join( '|' , $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
|
316 |
+
if( ! preg_match_all( $pattern, $u_agent, $matches) ) {
|
317 |
+
// we have no matching number just continue
|
318 |
+
}
|
319 |
+
|
320 |
+
// see how many we have
|
321 |
+
$i = count($matches['browser']);
|
322 |
+
if( $i != 1 ) {
|
323 |
+
//we will have two since we are not using 'other' argument yet
|
324 |
+
//see if version is before or after the name
|
325 |
+
if( strripos( $u_agent ,"Version" ) < strripos( $u_agent , $ub ) ) {
|
326 |
+
$version= $matches['version'][0];
|
327 |
+
} else {
|
328 |
+
$version= $matches['version'][1];
|
329 |
+
}
|
330 |
+
} else {
|
331 |
+
$version= $matches['version'][0];
|
332 |
+
}
|
333 |
+
|
334 |
+
// check if we have a number
|
335 |
+
if( $version==null || $version=="" ) { $version="?"; }
|
336 |
+
|
337 |
+
return array(
|
338 |
+
'userAgent' => $u_agent,
|
339 |
+
'name' => $bname,
|
340 |
+
'version' => $version,
|
341 |
+
'platform' => $platform,
|
342 |
+
'pattern' => $pattern
|
343 |
+
);
|
344 |
+
}
|
345 |
+
|
346 |
+
/***** Encryption/Decryption
|
347 |
+
****** API Keys (MailChimp and reCaptcha)
|
348 |
+
*****************************************************************************************************/
|
349 |
+
function yikes_mc_encryptIt( $q ) {
|
350 |
+
$cryptKey = 'qJB0rGtIn5UB1xG03efyCp';
|
351 |
+
$qEncoded = base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), $q, MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ) );
|
352 |
+
return( $qEncoded );
|
353 |
+
}
|
354 |
+
|
355 |
+
function yikes_mc_decryptIt( $q ) {
|
356 |
+
$cryptKey = 'qJB0rGtIn5UB1xG03efyCp';
|
357 |
+
$qDecoded = rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), base64_decode( $q ), MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ), "\0");
|
358 |
+
return( $qDecoded );
|
359 |
+
}
|
360 |
+
|
361 |
+
|
362 |
+
/***** CONFIGURATION
|
363 |
+
****************************************************************************************************/
|
364 |
+
// Update our plug in options
|
365 |
+
// Runs when the user updates the settings page with new values
|
366 |
+
public function updateOptions( $p ) {
|
367 |
+
if( ! empty( $p['form_data'] ) ) {
|
368 |
+
parse_str( $p['form_data'] , $fd );
|
369 |
+
// checking if the entered API key has copied out of the value field?
|
370 |
+
if ( strlen( $fd['yks-mailchimp-api-key'] ) > 45 ) {
|
371 |
+
$apiKey = $this->yikes_mc_decryptIt($fd['yks-mailchimp-api-key']);
|
372 |
+
} else {
|
373 |
+
$apiKey = $fd['yks-mailchimp-api-key'];
|
374 |
+
}
|
375 |
+
// check if the newly input API key differs from the previously stored one
|
376 |
+
if ( $apiKey == $this->optionVal['api-key'] ) {
|
377 |
+
$this->optionVal['api-key'] = $apiKey;
|
378 |
+
$this->optionVal['flavor'] = $fd['yks-mailchimp-flavor'];
|
379 |
+
$this->optionVal['optin'] = $fd['yks-mailchimp-optin'];
|
380 |
+
$this->optionVal['single-optin-message'] = stripslashes($fd['single-optin-message']);
|
381 |
+
$this->optionVal['double-optin-message'] = stripslashes($fd['double-optin-message']);
|
382 |
+
$this->optionVal['optIn-checkbox'] = $fd['yks-mailchimp-optIn-checkbox'];
|
383 |
+
$this->optionVal['yks-mailchimp-optIn-default-list'] = isset($fd['yks-mailchimp-optIn-default-list']) ? $fd['yks-mailchimp-optIn-default-list'] : null; // if its set, else set to null <- fixes save form settings bug
|
384 |
+
$this->optionVal['yks-mailchimp-optin-checkbox-text'] = stripslashes($fd['yks-mailchimp-optin-checkbox-text']);
|
385 |
+
$this->optionVal['yks-mailchimp-jquery-datepicker'] = isset( $fd['yks-mailchimp-jquery-datepicker'] ) ? '1' : '';
|
386 |
+
$this->optionVal['yks-mailchimp-required-text'] = $fd['yks-mailchimp-required-text'];
|
387 |
+
update_option('api_validation', 'valid_api_key');
|
388 |
+
return update_option( YKSEME_OPTION , $this->optionVal );
|
389 |
+
} else {
|
390 |
+
$this->optionVal['api-key'] = $apiKey;
|
391 |
+
$this->optionVal['flavor'] = $fd['yks-mailchimp-flavor'];
|
392 |
+
$this->optionVal['optin'] = $fd['yks-mailchimp-optin'];
|
393 |
+
$this->optionVal['single-optin-message'] = stripslashes($fd['single-optin-message']);
|
394 |
+
$this->optionVal['double-optin-message'] = stripslashes($fd['double-optin-message']);
|
395 |
+
$this->optionVal['optIn-checkbox'] = $fd['yks-mailchimp-optIn-checkbox'];
|
396 |
+
$this->optionVal['yks-mailchimp-optIn-default-list'] = isset($fd['yks-mailchimp-optIn-default-list']) ? $fd['yks-mailchimp-optIn-default-list'] : null; // if its set, else set to null <- fixes save form settings bug
|
397 |
+
$this->optionVal['yks-mailchimp-optin-checkbox-text'] = stripslashes($fd['yks-mailchimp-optin-checkbox-text']);
|
398 |
+
$this->optionVal['yks-mailchimp-jquery-datepicker'] = isset( $fd['yks-mailchimp-jquery-datepicker'] ) ? '1' : '';
|
399 |
+
$this->optionVal['yks-mailchimp-required-text'] = $fd['yks-mailchimp-required-text'];
|
400 |
+
update_option('api_validation', 'valid_api_key');
|
401 |
+
// if the new API key differs from the old one
|
402 |
+
// we need to unset the previously set up widgets
|
403 |
+
// 1 - empty the lists array of imported lists
|
404 |
+
$this->optionVal['lists'] = array();
|
405 |
+
// 2 - unset our previously set up widgets
|
406 |
+
update_option( 'widget_yikes_mc_widget' , '' );
|
407 |
+
return update_option( YKSEME_OPTION , $this->optionVal );
|
408 |
+
}
|
409 |
+
}
|
410 |
+
return false;
|
411 |
+
}
|
412 |
+
|
413 |
+
// Update our recaptcha options
|
414 |
+
// Runs when the user updates the recaptcha settings page with new values
|
415 |
+
public function updateRecaptchaOptions( $p ) {
|
416 |
+
if( !empty( $p['form_data'] ) ) {
|
417 |
+
parse_str($p['form_data'], $fd);
|
418 |
+
$this->optionVal['recaptcha-setting'] = isset($fd['yks-mailchimp-recaptcha-setting']) ? $fd['yks-mailchimp-recaptcha-setting'] : '0';
|
419 |
+
$this->optionVal['recaptcha-api-key'] = isset($fd['yks-mailchimp-recaptcha-api-key']) ? $fd['yks-mailchimp-recaptcha-api-key'] : '';
|
420 |
+
$this->optionVal['recaptcha-private-api-key'] = isset($fd['yks-mailchimp-recaptcha-private-api-key']) ? $fd['yks-mailchimp-recaptcha-private-api-key'] : '';
|
421 |
+
return update_option( YKSEME_OPTION , $this->optionVal );
|
422 |
+
}
|
423 |
+
return false;
|
424 |
+
}
|
425 |
+
|
426 |
+
// Update our debug plugin options
|
427 |
+
// Runs when the user updates the debug settings page with new values
|
428 |
+
public function updateDebugOptions( $p ) {
|
429 |
+
if( !empty( $p['form_data'] ) ) {
|
430 |
+
parse_str($p['form_data'], $fd);
|
431 |
+
$this->optionVal['debug'] = $fd['yks-mailchimp-debug'];
|
432 |
+
$this->optionVal['ssl_verify_peer'] = $fd['yks-mailchimp-ssl-verify-peer'];
|
433 |
+
return update_option(YKSEME_OPTION, $this->optionVal);
|
434 |
+
}
|
435 |
+
return false;
|
436 |
+
}
|
437 |
+
|
438 |
+
// Update the API Key
|
439 |
+
public function updateApiKey( $k ) {
|
440 |
+
$this->optionVal['api-key'] = $k;
|
441 |
+
return update_option( YKSEME_OPTION , $this->optionVal );
|
442 |
+
}
|
443 |
+
|
444 |
+
// Update the version number
|
445 |
+
public function updateVersion( $k ) {
|
446 |
+
$this->optionVal['version'] = $k;
|
447 |
+
return update_option( YKSEME_OPTION , $this->optionVal );
|
448 |
+
}
|
449 |
+
|
450 |
+
/***** LIST ACTIONS
|
451 |
+
****************************************************************************************************/
|
452 |
+
// Import a list from MailChimp and add it to the lists page
|
453 |
+
// Runs when user adds a list from the drop down on the list page
|
454 |
+
// Sends a call to MailChimp api to retrieve list data
|
455 |
+
public function addList( $lid='' , $name='' ) {
|
456 |
+
|
457 |
+
if( $lid == '' || isset( $this->optionVal['lists'][$lid] ) ) return false;
|
458 |
+
|
459 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
460 |
+
|
461 |
+
$mv = $api->call('lists/merge-vars', array(
|
462 |
+
'id' => array($lid)
|
463 |
+
)
|
464 |
+
);
|
465 |
+
|
466 |
+
// if merge variables are found
|
467 |
+
if( $mv) {
|
468 |
+
$list = array(
|
469 |
+
'id' => $lid,
|
470 |
+
'list-id' => $lid,
|
471 |
+
'name' => $name,
|
472 |
+
'fields' => $this->getImportedFieldsArray( $lid , $mv )
|
473 |
+
);
|
474 |
+
|
475 |
+
$this->optionVal['lists'][$list['id']] = $list;
|
476 |
+
|
477 |
+
// store newly retreived list array in imported_list global option
|
478 |
+
update_option( 'imported_lists' , $this->optionVal['lists'] );
|
479 |
+
|
480 |
+
if( update_option( YKSEME_OPTION, $this->optionVal ) ) {
|
481 |
+
return $this->generateListContainers( array( $list ) );
|
482 |
+
}
|
483 |
+
}
|
484 |
+
|
485 |
+
return false;
|
486 |
+
}
|
487 |
+
|
488 |
+
|
489 |
+
/* Get Interest Groups */
|
490 |
+
// Send request to MailChimp API to retreive interest groups associated to a specific list
|
491 |
+
public function getInterestGroups( $list_id ) {
|
492 |
+
// store our API key
|
493 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
494 |
+
|
495 |
+
// setup switch for div/table
|
496 |
+
$yikes_mc_flavor = $this->optionVal['flavor'];
|
497 |
+
|
498 |
+
// try the request, and catch any errors
|
499 |
+
try {
|
500 |
+
|
501 |
+
$interest_groups = $api->call('lists/interest-groupings', array( 'id' => $list_id ));
|
502 |
+
|
503 |
+
// if the list has an interest group
|
504 |
+
if ($interest_groups) {
|
505 |
+
// json_encode the data, and store it in optionVal['interest-groups']
|
506 |
+
$this->optionVal['interest-groups'] = json_encode($interest_groups);
|
507 |
+
|
508 |
+
$num = 0;
|
509 |
+
|
510 |
+
switch( $yikes_mc_flavor ) {
|
511 |
+
|
512 |
+
// table flavor
|
513 |
+
case '0':
|
514 |
+
|
515 |
+
// loop over each interest group returned
|
516 |
+
foreach($interest_groups as $interest_group) {
|
517 |
+
|
518 |
+
?> <!-- pass interest group data in a hidden form field , required to pass the data back to the correct interest-group -->
|
519 |
+
<input type='hidden' name='interest-group-data' value='<?php echo $this->optionVal["interest-groups"]; ?>' /> <?php
|
520 |
+
|
521 |
+
// get form type
|
522 |
+
$list_form_type = $interest_group['form_field'];
|
523 |
+
$interestGroupID = $interest_group['id'];
|
524 |
+
|
525 |
+
switch( $list_form_type ) {
|
526 |
+
|
527 |
+
// checkbox interest groups
|
528 |
+
case 'checkboxes':
|
529 |
+
echo '<tr class="yks_mc_table_interest_group_holder yks_mc_table_checkbox_holder">';
|
530 |
+
echo '<td class="yks_mc_table_td">';
|
531 |
+
// display the label
|
532 |
+
echo '<label class="prompt yks_table_label yks-mailchimpFormTableRowLabel yks-mailchimpFormTableRowLabel-required font-secondary label-text">'.stripslashes( $interest_group['name'] ).'</label>'; // display the interest group name from MailChimp
|
533 |
+
foreach ($interest_group['groups'] as $singleGrouping) {
|
534 |
+
$checkboxValue = $interest_group['name'];
|
535 |
+
echo '<label class="yks_mc_interest_group_label" for="'.$singleGrouping['name'].'"><input type="checkbox" id="'.$singleGrouping['name'].'" class="yikes_mc_interest_group_checkbox" name="'.$interest_group['form_field'].'-'.$interest_group['id'].'[]" value="'.$singleGrouping['name'].'"><span>'.$singleGrouping['name'].'</span></label>';
|
536 |
+
}
|
537 |
+
echo '</td>';
|
538 |
+
echo '</tr>';
|
539 |
+
break;
|
540 |
+
|
541 |
+
// radiobuttons interest groups
|
542 |
+
case 'radio':
|
543 |
+
echo '<tr class="yks_mc_table_interest_group_holder yks_mc_table_radio_holder">';
|
544 |
+
echo '<td class="yks_mc_interest_radio_button_holder yks_mc_table_td">';
|
545 |
+
// display the label
|
546 |
+
echo stripslashes($user_set_interest_group_label);
|
547 |
+
foreach ($interest_group['groups'] as $singleGrouping) {
|
548 |
+
$radioValue = $interest_group['name'];
|
549 |
+
echo '<label class="yks_mc_interest_group_label" for="'.$singleGrouping['name'].'"><input type="radio" id="'.$singleGrouping['name'].'" class="yikes_mc_interest_group_radio" name="'.$interest_group['form_field'].'-'.$interest_group['id'].'" value="'.$singleGrouping['name'].'"><span>'.stripslashes($singleGrouping['name']).'</span></label>';
|
550 |
+
}
|
551 |
+
echo '</td>';
|
552 |
+
echo '</tr>';
|
553 |
+
break;
|
554 |
+
|
555 |
+
// drop down interest groups
|
556 |
+
case 'dropdown':
|
557 |
+
echo '<tr class="yks_mc_table_interest_group_holder yks_mc_table_dropdown_holder">';
|
558 |
+
echo '<td class="yks_mc_table_dropdown_interest_group_holder yks_mc_table_td">';
|
559 |
+
// display the label
|
560 |
+
echo stripslashes($user_set_interest_group_label);
|
561 |
+
echo '<select id="yks_mc_interest_dropdown" name="'.$interest_group['form_field'].'-'.$interest_group['id'].'" class="yks_mc_interest_group_select">';
|
562 |
+
foreach ($interest_group['groups'] as $singleGrouping) {
|
563 |
+
$dropDownValue = $interest_group['name'];
|
564 |
+
echo '<option value="'.$singleGrouping['name'].'" name="'.$dropDownValue.'">'.$singleGrouping['name'].'</option>';
|
565 |
+
}
|
566 |
+
echo '</select>';
|
567 |
+
echo '</td>';
|
568 |
+
echo '</tr>';
|
569 |
+
break;
|
570 |
+
|
571 |
+
// hidden dropdown interest groups
|
572 |
+
case 'hidden':
|
573 |
+
echo '<div class="yks_mc_interest_group_holder" style="display:none;">';
|
574 |
+
echo '<select id="yks_mc_interest_dropdown" name="'.$interest_group['form_field'].'-'.$interest_group['id'].'" class="yks_mc_interest_group_select">';
|
575 |
+
foreach ($interest_group['groups'] as $singleGrouping) {
|
576 |
+
$dropDownValue = $interest_group['name'];
|
577 |
+
echo '<option value="'.$singleGrouping['name'].'" name="'.$dropDownValue.'">'.$singleGrouping['name'].'</option>';
|
578 |
+
}
|
579 |
+
echo '</select>';
|
580 |
+
echo '</div>';
|
581 |
+
break; //break dropdown interest group type
|
582 |
+
|
583 |
+
}
|
584 |
+
|
585 |
+
$num++;
|
586 |
+
}
|
587 |
+
|
588 |
+
break; // break case: 0;
|
589 |
+
|
590 |
+
// div flavor
|
591 |
+
case '1':
|
592 |
+
// loop over each interest group returned
|
593 |
+
foreach($interest_groups as $interest_group) {
|
594 |
+
|
595 |
+
// get form type
|
596 |
+
$list_form_type = $interest_group['form_field'];
|
597 |
+
$interestGroupID = $interest_group['id'];
|
598 |
+
if ( $list_form_type == 'hidden' ) { $hidden = 'style="display:none;"'; } else { $hidden = ''; }
|
599 |
+
|
600 |
+
echo '<b class="yks_mc_interest_group_text" ' . $hidden . '>'.$interest_group['name'].'</b>';
|
601 |
+
?>
|
602 |
+
|
603 |
+
<input type='hidden' name='interest-group-data' value='<?php echo $this->optionVal["interest-groups"]; ?>' />
|
604 |
+
|
605 |
+
<?php
|
606 |
+
|
607 |
+
switch($list_form_type) {
|
608 |
+
|
609 |
+
// checkbox interest groups
|
610 |
+
case 'checkboxes':
|
611 |
+
echo '<div class="yks_mc_interest_group_holder">';
|
612 |
+
foreach ($interest_group['groups'] as $singleGrouping) {
|
613 |
+
$checkboxValue = $interest_group['name'];
|
614 |
+
echo '<label class="yks_mc_interest_group_label" for="'.$singleGrouping['name'].'"><input type="checkbox" id="'.$singleGrouping['name'].'" class="yikes_mc_interest_group_checkbox" name="'.$interest_group['form_field'].'-'.$interest_group['id'].'[]" value="'.$singleGrouping['name'].'"><span></span>'.stripslashes($singleGrouping['name']).'</label>';
|
615 |
+
}
|
616 |
+
echo '</div>';
|
617 |
+
break; // break checkbox interest group type
|
618 |
+
|
619 |
+
// radiobuttons interest groups
|
620 |
+
case 'radio':
|
621 |
+
echo '<div class="yks_mc_interest_group_holder">';
|
622 |
+
echo '<div class="yks_mc_interest_radio_button_holder">';
|
623 |
+
echo stripslashes($user_set_interest_group_label);
|
624 |
+
foreach ($interest_group['groups'] as $singleGrouping) {
|
625 |
+
$radioValue = $interest_group['name'];
|
626 |
+
echo '<label class="yks_mc_interest_group_label" for="'.$singleGrouping['name'].'"><input type="radio" id="'.$singleGrouping['name'].'" class="yikes_mc_interest_group_radio" name="'.$interest_group['form_field'].'-'.$interest_group['id'].'" value="'.$singleGrouping['name'].'"><span></span>'.stripslashes($singleGrouping['name']).'</label>';
|
627 |
+
}
|
628 |
+
echo '</div>';
|
629 |
+
echo '</div>';
|
630 |
+
break; //break radio buttons interest group type
|
631 |
+
|
632 |
+
// drop down interest groups
|
633 |
+
case 'dropdown':
|
634 |
+
echo '<div class="yks_mc_interest_group_holder">';
|
635 |
+
echo '<select id="yks_mc_interest_dropdown" name="'.$interest_group['form_field'].'-'.$interest_group['id'].'" class="yks_mc_interest_group_select">';
|
636 |
+
foreach ($interest_group['groups'] as $singleGrouping) {
|
637 |
+
$dropDownValue = $interest_group['name'];
|
638 |
+
echo '<option value="'.$singleGrouping['name'].'" name="'.$dropDownValue.'">'.$singleGrouping['name'].'</option>';
|
639 |
+
}
|
640 |
+
echo '</select>';
|
641 |
+
echo '</div>';
|
642 |
+
break; //break dropdown interest group type
|
643 |
+
|
644 |
+
// hidden dropdown interest groups
|
645 |
+
case 'hidden':
|
646 |
+
echo '<div class="yks_mc_interest_group_holder" style="display:none;">';
|
647 |
+
// display the label
|
648 |
+
echo stripslashes($user_set_interest_group_label);
|
649 |
+
echo '<select id="yks_mc_interest_dropdown" name="'.$interest_group['form_field'].'-'.$interest_group['id'].'" class="yks_mc_interest_group_select">';
|
650 |
+
foreach ($interest_group['groups'] as $singleGrouping) {
|
651 |
+
$dropDownValue = $interest_group['name'];
|
652 |
+
echo '<option value="'.$singleGrouping['name'].'" name="'.$dropDownValue.'">'.$singleGrouping['name'].'</option>';
|
653 |
+
}
|
654 |
+
echo '</select>';
|
655 |
+
echo '</div>';
|
656 |
+
break; //break dropdown interest group type
|
657 |
+
|
658 |
+
}
|
659 |
+
$num++;
|
660 |
+
}
|
661 |
+
break; //break case: 1;
|
662 |
+
|
663 |
+
}
|
664 |
+
}
|
665 |
+
// catch any errors if thrown
|
666 |
+
} catch( Exception $e ) {
|
667 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
668 |
+
$this->writeErrorToErrorLog( $e );
|
669 |
+
}
|
670 |
+
return;
|
671 |
+
}
|
672 |
+
return false;
|
673 |
+
} // end getInterestGroups();
|
674 |
+
|
675 |
+
// Send a call to the MailChimp API to retreive all lists on the account
|
676 |
+
public function getLists() {
|
677 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
678 |
+
$lists = $this->getListsData();
|
679 |
+
$listArr = (!isset($listArr) ? $this->optionVal['lists'] : $listArr);
|
680 |
+
$theusedlist = array();
|
681 |
+
if( count( $listArr ) > 0 ) {
|
682 |
+
foreach( $listArr as $list ) {
|
683 |
+
$theusedlist[] = $list['id'];
|
684 |
+
}
|
685 |
+
}
|
686 |
+
if( $lists ) { // if list data is returned
|
687 |
+
echo "<select id='yks-list-select' name='yks-list-select'>";
|
688 |
+
echo "<option value=''> Select List</option>";
|
689 |
+
|
690 |
+
foreach ( $lists as $lkey => $lvalue ) {
|
691 |
+
if ( !in_array( $lkey , $theusedlist ) ) {
|
692 |
+
echo "<option value='".$lkey."'>".$lvalue."</option>";
|
693 |
+
}
|
694 |
+
}
|
695 |
+
|
696 |
+
echo "</select>";
|
697 |
+
echo '<input type="submit" name="submit" class="button-primary" id="yks-submit-list-add" value="' .__ ("Create a Form For This List" , "yikes-inc-easy-mailchimp-extender" ) .'" >';
|
698 |
+
|
699 |
+
// not currently possible to create new lists via API
|
700 |
+
// echo ' <a href="#" onclick="return false;" class="button-secondary"><span class="dashicons dashicons-plus" style="line-height:1.3"></span> Create New List</a>';
|
701 |
+
|
702 |
+
} else {
|
703 |
+
echo '<strong>' . __('Error - No Lists Found On Your Account. Please create at least one list on your MailChimp account.' , 'yikes-inc-easy-mailchimp-extender' ) . '</strong>';
|
704 |
+
}
|
705 |
+
return false;
|
706 |
+
} // end getLists();
|
707 |
+
|
708 |
+
// Get lists for the settings page
|
709 |
+
// Used for default subscription list
|
710 |
+
public function getOptionsLists() {
|
711 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
712 |
+
$lists = $this->getListsData();
|
713 |
+
$listArr = (!isset($listArr) ? $this->optionVal['lists'] : $listArr);
|
714 |
+
if( $lists ) {
|
715 |
+
echo "<select id='yks-mailchimp-optIn-default-list' name='yks-mailchimp-optIn-default-list'>";
|
716 |
+
echo "<option value='select_list'> Select List</option>";
|
717 |
+
foreach ( $lists as $lkey => $list_name) {
|
718 |
+
echo "<option ".selected( isset($this->optionVal['yks-mailchimp-optIn-default-list']) ? $this->optionVal['yks-mailchimp-optIn-default-list'] : "select_list", $lkey )." value='".$lkey."'>".$list_name."</option>";
|
719 |
+
}
|
720 |
+
echo "</select>";
|
721 |
+
}
|
722 |
+
return false;
|
723 |
+
} // end getOptionsLists()
|
724 |
+
|
725 |
+
// Send a call to MailChimp API to get the data associated with a specific list (in this instance: the fields, and the subscriber count)
|
726 |
+
public function getListsData() {
|
727 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
728 |
+
$lists = $api->call('lists/list', array( 'limit' => 100 ));
|
729 |
+
if( $lists ) {
|
730 |
+
foreach ( $lists['data'] as $list ) {
|
731 |
+
$theListItems[$list['id']] = $list['name'];
|
732 |
+
$theListItems['subscriber-count']['subscriber-count-'.$list['id']] = $list['stats']['member_count'];
|
733 |
+
}
|
734 |
+
}
|
735 |
+
|
736 |
+
if ( isset ( $theListItems ) ) {
|
737 |
+
return $theListItems;
|
738 |
+
}
|
739 |
+
} // end getListsData();
|
740 |
+
|
741 |
+
/*
|
742 |
+
Send a call to MailChimp API to get the data associated with a specific list (in this instance: the fields, and the subscriber count)
|
743 |
+
@since v5.2
|
744 |
+
*/
|
745 |
+
public function getInterstGroupInfo( $list_id ) {
|
746 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
747 |
+
try {
|
748 |
+
$interest_groups = $api->call('lists/interest-groupings', array( 'id' => $list_id ));
|
749 |
+
return $interest_groups;
|
750 |
+
} catch( Exception $e ) { // catch any errors returned from MailChimp
|
751 |
+
return $e->getMessage();
|
752 |
+
// write our error to the error log, when advanced debug is enabled
|
753 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
754 |
+
$this->writeErrorToErrorLog( $e );
|
755 |
+
}
|
756 |
+
die();
|
757 |
+
}
|
758 |
+
}
|
759 |
+
|
760 |
+
/*
|
761 |
+
Get Interest Group Response
|
762 |
+
@sinve v5.2
|
763 |
+
*/
|
764 |
+
public function getListInterestGroups( $list_id ) {
|
765 |
+
$interest_groups = $this->getInterstGroupInfo( $list_id );
|
766 |
+
if ( is_array( $interest_groups ) ) {
|
767 |
+
foreach ( $interest_groups as $interest_group ) {
|
768 |
+
$interest_group_id = $interest_group['id'];
|
769 |
+
$interest_group_type = $interest_group['form_field'];
|
770 |
+
$interest_group_name = $interest_group['name'];
|
771 |
+
echo '<div class="yks-mailchimp-fields-list-row" alt="' . $interest_group_id . '">
|
772 |
+
|
773 |
+
<span class="yks-mc-interest-group-delete" title="Delete ' . $interest_group_name . '">
|
774 |
+
<span class="dashicons dashicons-no-alt"></span>
|
775 |
+
</span>
|
776 |
+
|
777 |
+
<span class="yks-mc-interest-group-edit" title="Edit ' . $interest_group_name . '">
|
778 |
+
<span class="dashicons dashicons-edit"></span>
|
779 |
+
</span>
|
780 |
+
|
781 |
+
<span class="yks-mc-interest-group-name">' . $interest_group_name . '</span>
|
782 |
+
|
783 |
+
<span class="yks-mc-interest-group-type">' . $interest_group_type . '</span>
|
784 |
+
|
785 |
+
</div>';
|
786 |
+
}
|
787 |
+
} else {
|
788 |
+
?>
|
789 |
+
<style>
|
790 |
+
#yks-mailchimp-interest-groups-container_<?php echo $list_id; ?> {
|
791 |
+
background-color: transparent !important;
|
792 |
+
border: none !important;
|
793 |
+
}
|
794 |
+
</style>
|
795 |
+
<span class="no-interest-groups-found"><em><?php echo __( 'No interest groups have been setup for this form yet' , 'yikes-inc-easy-mailchimp-extender' ); ?></em></span>
|
796 |
+
<?php
|
797 |
+
}
|
798 |
+
} // end getListInterestGroups();
|
799 |
+
|
800 |
+
/*
|
801 |
+
Get Specific Interest Group Response
|
802 |
+
@since v5.2
|
803 |
+
*/
|
804 |
+
public function getSpecificInterestGroupData( $list_id , $mc_interest_group_id ) {
|
805 |
+
// get interest group info,
|
806 |
+
$interest_groups = $this->getInterstGroupInfo( $list_id );
|
807 |
+
if ( $interest_groups ) {
|
808 |
+
foreach ( $interest_groups as $key ) {
|
809 |
+
if ( $key['id'] == $mc_interest_group_id ) {
|
810 |
+
echo json_encode( $key );
|
811 |
+
}
|
812 |
+
}
|
813 |
+
} else {
|
814 |
+
echo 'error retreiving group information...please try again';
|
815 |
+
}
|
816 |
+
}
|
817 |
+
|
818 |
+
// Send a call to MailChimp API to get the data associated with a specific list (in this instance: the fields, and the subscriber count)
|
819 |
+
public function getListsForStats() {
|
820 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
821 |
+
$lists = $this->getListsData();
|
822 |
+
$listArr = (!isset($listArr) ? $this->optionVal['lists'] : $listArr);
|
823 |
+
$theusedlist = array();
|
824 |
+
if( count( $listArr ) > 0 ) {
|
825 |
+
foreach( $listArr as $list ) {
|
826 |
+
$theusedlist[] = $list['id'];
|
827 |
+
}
|
828 |
+
}
|
829 |
+
if( $lists ) {
|
830 |
+
// Drop Down to switch form stats
|
831 |
+
echo '<h3>Select list to view stats</h3>';
|
832 |
+
echo '<div class="list_container_for_stats">';
|
833 |
+
echo "<a alt='' href='#' class='stats_list_name' onclick='return false;'><input type='button' class='asbestos-flat-button active_button' value='".__( 'All Lists' , 'yikes-inc-easy-mailchimp-extender')."'></a>";
|
834 |
+
foreach ($lists as $lkey => $lvalue) {
|
835 |
+
if ( is_array($lvalue) ) {
|
836 |
+
continue;
|
837 |
+
} else {
|
838 |
+
// if ( is_array( $lvalue ) ) { $lvalue = '<em style="color:rgba(245, 79, 79, 0.74);">Error</em>'; } else { $lvalue = $lvalue; }
|
839 |
+
echo "<a alt='".$lkey."' href='#' class='stats_list_name' onclick='return false;'><input type='button' class='asbestos-flat-button' value='".$lvalue."'></a>";
|
840 |
+
}
|
841 |
+
}
|
842 |
+
echo '</div>';
|
843 |
+
}
|
844 |
+
return false;
|
845 |
+
} // end getListsForStats()
|
846 |
+
|
847 |
+
// Sort through the returned data
|
848 |
+
public function sortList( $p ) {
|
849 |
+
if( empty( $p['update_string'] ) || empty( $p['list_id'] ) ) {
|
850 |
+
return false;
|
851 |
+
} else {
|
852 |
+
// Setup fields
|
853 |
+
$a = explode( ';' , $p['update_string'] );
|
854 |
+
if( $a !== false ) {
|
855 |
+
foreach( $a as $f ) {
|
856 |
+
$d = explode( ':' , $f );
|
857 |
+
$this->optionVal['lists'][$p['list_id']]['fields'][$d[0]]['sort'] = $d[1];
|
858 |
+
}
|
859 |
+
}
|
860 |
+
uasort($this->optionVal['lists'][$p['list_id']]['fields'], array(&$this, 'sortListFields'));
|
861 |
+
return update_option(YKSEME_OPTION, $this->optionVal);
|
862 |
+
}
|
863 |
+
return false;
|
864 |
+
} // end sortList();
|
865 |
+
|
866 |
+
private function sortListfields( $a , $b ) {
|
867 |
+
$a = $a['sort'];
|
868 |
+
$b = $b['sort'];
|
869 |
+
if( $a == $b ) {
|
870 |
+
return 0;
|
871 |
+
}
|
872 |
+
return ( $a < $b ) ? -1 : 1;
|
873 |
+
} // end sortListfields();
|
874 |
+
|
875 |
+
// Update a single list on the lists page
|
876 |
+
// This function fires when the user clicks 'save settings' for a specific form on the lists page
|
877 |
+
public function updateList( $p ) {
|
878 |
+
if( !empty( $p['form_data'] ) ) {
|
879 |
+
parse_str($p['form_data'], $fd);
|
880 |
+
if( !empty( $fd['yks-mailchimp-unique-id'] ) ) {
|
881 |
+
$num = 1;
|
882 |
+
foreach( $this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['fields'] as $k => $v ) {
|
883 |
+
// Only proceed if the field is not locked
|
884 |
+
if( $v['require'] == 0 ) {
|
885 |
+
// Make sure this field was included in the update
|
886 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['fields'][$k]['active'] = (isset($fd[$v['name']]) ? '1' : '0');
|
887 |
+
}
|
888 |
+
|
889 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['fields'][$k]['placeholder-'.$fd['yks-mailchimp-unique-id'].'-'.$num] = $fd['placeholder-'.$fd['yks-mailchimp-unique-id'].'-'.$num];
|
890 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['fields'][$k]['custom-field-class-'.$fd['yks-mailchimp-unique-id'].'-'.$num] = $fd['custom-field-class-'.$fd['yks-mailchimp-unique-id'].'-'.$num];
|
891 |
+
$num++;
|
892 |
+
|
893 |
+
// redirect checkbox
|
894 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['fields'][$k]['yks_mailchimp_redirect_'.$fd['yks-mailchimp-unique-id']] = (isset($fd['yks_mailchimp_redirect_'.$fd['yks-mailchimp-unique-id']]) ? '1' : '');
|
895 |
+
|
896 |
+
// send welcome checkbox
|
897 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['fields'][$k]['yks_mailchimp_send_welcome_'.$fd['yks-mailchimp-unique-id']] = (isset($fd['yks_mailchimp_send_welcome_'.$fd['yks-mailchimp-unique-id']]) ? '1' : '');
|
898 |
+
|
899 |
+
if(isset($fd['yks_mailchimp_redirect_'.$fd['yks-mailchimp-unique-id']])) {
|
900 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['fields'][$k]['page_id_'.$fd['yks-mailchimp-unique-id']] = $fd['page_id_'.$fd['yks-mailchimp-unique-id']];
|
901 |
+
}
|
902 |
+
|
903 |
+
// custom style setting
|
904 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_styles']['active'] = (isset($fd['yks_mailchimp_custom_styles_'.$fd['yks-mailchimp-unique-id']]) ? '1' : '0');
|
905 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_template']['active'] = (isset($fd['yks_mailchimp_custom_template_'.$fd['yks-mailchimp-unique-id']]) ? '1' : '0');
|
906 |
+
}
|
907 |
+
|
908 |
+
// save the selected form template, if custom template was set
|
909 |
+
if ( $this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_template']['active'] == 1 ) {
|
910 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_template']['template_file'] = $fd['yks-mc-template-file-selection'];
|
911 |
+
}
|
912 |
+
|
913 |
+
// save the color styles
|
914 |
+
if ( $this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_styles']['active'] == 1 ) {
|
915 |
+
|
916 |
+
// save the custom styles colors here!
|
917 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_styles']['yks_mc_submit_button_color'] = $fd['yks-mc-submit-button-color'];
|
918 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_styles']['yks_mc_submit_button_text_color'] = $fd['yks-mc-submit-button-text-color'];
|
919 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_styles']['yks_mc_form_background_color'] = $fd['yks-mc-background-color'];
|
920 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_styles']['yks_mc_form_text_color'] = $fd['yks-mc-text-color'];
|
921 |
+
|
922 |
+
// if the form width is left blank,
|
923 |
+
// we'll just set it to 100%
|
924 |
+
if ( $fd['yks-mc-form-width'] != '' ) {
|
925 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_styles']['yks_mc_form_width'] = $fd['yks-mc-form-width'];
|
926 |
+
} else {
|
927 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_styles']['yks_mc_form_width'] = '100%';
|
928 |
+
}
|
929 |
+
|
930 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_styles']['yks_mc_form_alignment'] = $fd['yks-mc-form-alignment'];
|
931 |
+
|
932 |
+
$padding_matches = array();
|
933 |
+
$matching_array = array( 'px' , 'em' , 'rem' , '%' );
|
934 |
+
|
935 |
+
if ( preg_match( '/([0-9.]+)([^0-9]+)/', $fd['yks-mc-form-padding'], $padding_matches ) ) {
|
936 |
+
// $padding_explosion = preg_split( '/[a-zA-Z]/' , $fd['yks-mc-form-padding'] );
|
937 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_styles']['yks_mc_form_padding'] = $padding_matches[1];
|
938 |
+
if ( in_array( $padding_matches[2] , $matching_array ) ) {
|
939 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_styles']['yks_mc_form_padding_measurement'] = $padding_matches[2];
|
940 |
+
} else {
|
941 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_styles']['yks_mc_form_padding_measurement'] = 'px';
|
942 |
+
}
|
943 |
+
} else {
|
944 |
+
if ( trim( $fd['yks-mc-form-padding'] ) != '' ) {
|
945 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_styles']['yks_mc_form_padding'] = $fd['yks-mc-form-padding'];
|
946 |
+
} else {
|
947 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_styles']['yks_mc_form_padding'] = '0';
|
948 |
+
}
|
949 |
+
$this->optionVal['lists'][$fd['yks-mailchimp-unique-id']]['custom_styles']['yks_mc_form_padding_measurement'] = 'px';
|
950 |
+
}
|
951 |
+
}
|
952 |
+
|
953 |
+
return update_option(YKSEME_OPTION, $this->optionVal);
|
954 |
+
}
|
955 |
+
}
|
956 |
+
return false;
|
957 |
+
} // end updateList();
|
958 |
+
|
959 |
+
// Remove a list from the lists page
|
960 |
+
// Runs when a user clicks 'delete list' on the lists page
|
961 |
+
public function deleteList( $i=false ) {
|
962 |
+
if( $i == false ) {
|
963 |
+
return false;
|
964 |
+
} else {
|
965 |
+
unset( $this->optionVal['lists'][$i] );
|
966 |
+
update_option( 'imported_lists' , $this->optionVal['lists'] );
|
967 |
+
return update_option( YKSEME_OPTION , $this->optionVal );
|
968 |
+
}
|
969 |
+
} // end deleteList();
|
970 |
+
|
971 |
+
// Import a list to the lists page
|
972 |
+
// Runs when a user adds a list from the drop down on the lists page
|
973 |
+
public function importList( $i = false ) {
|
974 |
+
if( $i == false ) {
|
975 |
+
return false;
|
976 |
+
} else {
|
977 |
+
// create our variables
|
978 |
+
$lid = $this->optionVal['lists'][$i]['list-id'];
|
979 |
+
$name = $this->optionVal['lists'][$i]['name'];
|
980 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
981 |
+
$mv = $api->call('lists/merge-vars', array(
|
982 |
+
'id' => array( $lid )
|
983 |
+
)
|
984 |
+
);
|
985 |
+
// if merge variables are returned
|
986 |
+
$mv = $this->getImportedFieldsArray($lid, $mv);
|
987 |
+
if( $mv ) {
|
988 |
+
// Save the new list
|
989 |
+
$this->optionVal['lists'][$i]['fields'] = $mv;
|
990 |
+
if( update_option( YKSEME_OPTION , $this->optionVal ) ) {
|
991 |
+
return $this->generateListContainers(array($this->optionVal['lists'][$i]));
|
992 |
+
}
|
993 |
+
}
|
994 |
+
}
|
995 |
+
return false;
|
996 |
+
} // end importList();
|
997 |
+
|
998 |
+
// reImport a list to the lists page
|
999 |
+
// Runs when a user adds a list from the drop down on the lists page
|
1000 |
+
public function reImportMergeVariables( $i = false ) {
|
1001 |
+
if( $i == false ) {
|
1002 |
+
return false;
|
1003 |
+
} else {
|
1004 |
+
// create our variables
|
1005 |
+
$lid = $this->optionVal['lists'][$i]['list-id'];
|
1006 |
+
$name = $this->optionVal['lists'][$i]['name'];
|
1007 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
1008 |
+
$mv = $api->call('lists/merge-vars', array(
|
1009 |
+
'id' => array( $lid )
|
1010 |
+
)
|
1011 |
+
);
|
1012 |
+
// if merge variables are returned
|
1013 |
+
$mv = $this->getImportedFieldsArray($lid, $mv);
|
1014 |
+
if( $mv ) {
|
1015 |
+
// Save the new list
|
1016 |
+
$this->optionVal['lists'][$i]['fields'] = $mv;
|
1017 |
+
// update the list with the new fields
|
1018 |
+
if( update_option( YKSEME_OPTION , $this->optionVal ) ) {
|
1019 |
+
return $this->generateMergeVariableContainers(array($this->optionVal['lists'][$i]));
|
1020 |
+
}
|
1021 |
+
}
|
1022 |
+
}
|
1023 |
+
return false;
|
1024 |
+
} // end reImportMergeVariables();
|
1025 |
+
|
1026 |
+
// Make a call to the MailChimp API to retrieve all subscribers to a given list
|
1027 |
+
// Runs when the user clicks 'view' next to the subscriber count on the list page
|
1028 |
+
public function listAllSubscribers( $lid, $list_name ) {
|
1029 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
1030 |
+
$subscribers_list = $api->call('lists/members',
|
1031 |
+
array(
|
1032 |
+
'id' => $lid,
|
1033 |
+
'opts' => array(
|
1034 |
+
'limit' => '100',
|
1035 |
+
'sort_field' => 'optin_time',
|
1036 |
+
'sort_dir' => 'DESC'
|
1037 |
+
)
|
1038 |
+
)
|
1039 |
+
);
|
1040 |
+
// if the subscriber count is greater than 0
|
1041 |
+
// display all subscribers in a table
|
1042 |
+
if( $subscribers_list['total'] > 0 ) { ?>
|
1043 |
+
<h2><?php echo $list_name; echo ' <span class="subscriber-count" style="font-size:11px;">(<span class="number">'.$subscribers_list['total'].'</span> '.__(" subscribers" , "yikes-inc-easy-mailchimp-extender").')</span>'; ?></h2>
|
1044 |
+
<p><?php _e( 'Click on a subscriber to see further information' , 'yikes-inc-easy-mailchimp-extender' ); ?></p>
|
1045 |
+
|
1046 |
+
<table id="yikes-mailchimp-subscribers-table" class="yks-mailchimp-fields-list" style="width:100%;">
|
1047 |
+
<thead class="yikes-mailchimp-subscribers-table-head">
|
1048 |
+
<tr>
|
1049 |
+
<th width="50%"><?php _e( 'E-Mail' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
1050 |
+
<th width="50%"><?php _e( 'Date Subscribed' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
1051 |
+
</tr>
|
1052 |
+
</thead>
|
1053 |
+
<?php foreach ( $subscribers_list['data'] as $subscriber ) {
|
1054 |
+
$timeStamp = explode(' ', $subscriber['timestamp_opt'] );
|
1055 |
+
echo '<tr class="yks-mailchimp-subscribers-list-row" id="yks-mailchimp-subscribers-list-row">';
|
1056 |
+
echo '<td><a class="subscriber-mail-link" rel="'.$subscriber["email"].'" class="subscriberEmailAddress">'.$subscriber['email'].'</a></td>';
|
1057 |
+
// echo '<td>'.str_replace('-', ' ', date("M-jS-Y", strtotime($subscriber['timestamp_opt']))).'</td>';
|
1058 |
+
echo '<td>'.str_replace('-', ' ', date("M-jS-Y", strtotime($timeStamp[0]))).'</td></tr>';
|
1059 |
+
} ?>
|
1060 |
+
</table>
|
1061 |
+
|
1062 |
+
<!-- display a single user profile in this div -->
|
1063 |
+
<div id="individual_subscriber_information" style="display:none;"></div>
|
1064 |
+
<?php
|
1065 |
+
} else { // else display an error of sorts
|
1066 |
+
?>
|
1067 |
+
<h2><?php echo $list_name; echo ' <span class="subscriber-count" style="font-size:11px;">(<span class="number">0</span> '.__(" subscribers" , "yikes-inc-easy-mailchimp-extender").')</span>'; ?></h2>
|
1068 |
+
<?php
|
1069 |
+
_e( "Sorry You Don't Currently Have Any Subscribers In This List!" , "yikes-inc-easy-mailchimp-extender" );
|
1070 |
+
}
|
1071 |
+
wp_die();
|
1072 |
+
} // end listAllSubscribers();
|
1073 |
+
|
1074 |
+
// Make a call to the MailChimp API to retrieve information about a specific user
|
1075 |
+
// Runs when the user clicks a subscribers email address
|
1076 |
+
public function getSubscriberInfo($lid, $email) {
|
1077 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
1078 |
+
$subscriber_info = $api->call('lists/member-info',
|
1079 |
+
array(
|
1080 |
+
'id' => $lid,
|
1081 |
+
'emails' => array(
|
1082 |
+
0 => array(
|
1083 |
+
'email' => $email,
|
1084 |
+
),
|
1085 |
+
)
|
1086 |
+
)
|
1087 |
+
);
|
1088 |
+
// if the subscriber count is greater than 0
|
1089 |
+
// display all subscribers in a table
|
1090 |
+
if($subscriber_info) {
|
1091 |
+
// store user data into variables
|
1092 |
+
$subscriber_data = $subscriber_info['data'][0];
|
1093 |
+
$member_rating = $subscriber_data['member_rating'];
|
1094 |
+
// firstname/lastname data inside of new array
|
1095 |
+
$subscriber_data_merges = $subscriber_data['merges'];
|
1096 |
+
// seperate date+time
|
1097 |
+
$subscriber_data_info_changed = explode(' ' , $subscriber_data['info_changed']);
|
1098 |
+
$subscriber_data_timestamp_opt = explode (' ', $subscriber_data['timestamp_opt']);
|
1099 |
+
// store date+time in seperate variables
|
1100 |
+
$subscriber_data_info_changed_date = $subscriber_data_info_changed[0];
|
1101 |
+
$subscriber_data_info_changed_time = $subscriber_data_info_changed[1];
|
1102 |
+
// store optin-time+date in seperate variables
|
1103 |
+
$subscriber_data_info_optin_date = $subscriber_data_timestamp_opt[0];
|
1104 |
+
$subscriber_data_info_optin_time = $subscriber_data_timestamp_opt[1];
|
1105 |
+
// create our language variable dependent on what is set in MailChimp
|
1106 |
+
include_once('set_language.php');
|
1107 |
+
|
1108 |
+
// create star rating variable, based on returned member_rating value
|
1109 |
+
if(isset($member_rating)) {
|
1110 |
+
if ($member_rating == 1) {
|
1111 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
1112 |
+
} else if ($member_rating == 2) {
|
1113 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
1114 |
+
} else if ($member_rating == 3) {
|
1115 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
1116 |
+
} else if ($member_rating == 4) {
|
1117 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
1118 |
+
} else if ($member_rating == 5) {
|
1119 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span></div>';
|
1120 |
+
}
|
1121 |
+
} ?>
|
1122 |
+
|
1123 |
+
<div class="yks-mc-subscriber-top">
|
1124 |
+
<span class="button-primary dashicons dashicons-arrow-left-alt2 yks-mc-subscriber-go-back"><?php _e( 'Back to Subscriber List' , 'yikes-inc-easy-mailchimp-extender' ); ?></span>
|
1125 |
+
<h2 class="yks-mc-subscriber-header"><?php _e( 'Subscriber Details' , 'yikes-inc-easy-mailchimp-extender' ); ?> </h2>
|
1126 |
+
<!-- display users email address -->
|
1127 |
+
<h3 id="yks-subscriber-info-email-address"><?php echo $subscriber_data['email']; ?></h3>
|
1128 |
+
<!-- display member star rating pulled from MailChimp -->
|
1129 |
+
<?php echo $member_rating_stars; ?>
|
1130 |
+
<!-- user optin time and date -->
|
1131 |
+
<span class="yks-subscriber-info-optin-data">
|
1132 |
+
<?php echo 'Subscribed on : '.date('m/d/Y',strtotime($subscriber_data_info_optin_date)); ?><?php echo ' at '.date('g:i A',strtotime($subscriber_data_info_optin_time)); ?>
|
1133 |
+
</span>
|
1134 |
+
</div>
|
1135 |
+
|
1136 |
+
<h2 class="yks-mc-subscriber-header"><?php _e( 'Overview' , 'yikes-inc-easy-mailchimp-extender' ); ?></h2>
|
1137 |
+
<div class="yks-mc-subscriber-overview">
|
1138 |
+
|
1139 |
+
<div class="yks-mc-subscriber-left-container">
|
1140 |
+
|
1141 |
+
<label class="yks-mc-overview-title"><?php _e( 'First Name' , 'yikes-inc-easy-mailchimp-extender' ); ?></label>
|
1142 |
+
<p class="yks-mc-overview-info-value yks-mc-subscriber-firstName"><?php if(!empty($subscriber_data_merges['FNAME'])) { echo $subscriber_data_merges['FNAME']; } else { echo 'not provided'; } ?></p>
|
1143 |
+
|
1144 |
+
<label class="yks-mc-overview-title"><?php _e( 'Last Updated' , 'yikes-inc-easy-mailchimp-extender' ); ?></label>
|
1145 |
+
<p class="yks-mc-overview-info-value"><?php echo date('m/d/Y',strtotime($subscriber_data_info_changed_date)); ?><?php echo ' at '.date('g:i A',strtotime($subscriber_data_info_changed_time)); ?></p>
|
1146 |
+
|
1147 |
+
<label class="yks-mc-overview-title"><?php _e( 'Preferred Email Type' , 'yikes-inc-easy-mailchimp-extender' ); ?></label>
|
1148 |
+
<p class="yks-mc-overview-info-value"><?php if(!empty($subscriber_data['email_type'])) { echo $subscriber_data['email_type']; } else { echo 'No Preference.'; } ?></p>
|
1149 |
+
|
1150 |
+
</div>
|
1151 |
+
|
1152 |
+
<div class="yks-mc-subscriber-right-container">
|
1153 |
+
|
1154 |
+
<label class="yks-mc-overview-title"><?php _e( 'Last Name' , 'yikes-inc-easy-mailchimp-extender' ); ?></label>
|
1155 |
+
<p class="yks-mc-overview-info-value yks-mc-subscriber-lastName"><?php if(!empty($subscriber_data_merges['LNAME'])) { echo $subscriber_data_merges['LNAME']; } else { echo 'not provided'; } ?></p>
|
1156 |
+
|
1157 |
+
<label class="yks-mc-overview-title"><?php _e( 'Language' , 'yikes-inc-easy-mailchimp-extender' ); ?></label>
|
1158 |
+
<p class="yks-mc-overview-info-value"><?php echo $subscriber_data_language; ?></p>
|
1159 |
+
|
1160 |
+
</div>
|
1161 |
+
|
1162 |
+
</div>
|
1163 |
+
|
1164 |
+
<?php
|
1165 |
+
// build our segment array to determine if the user is subscribed to any segments
|
1166 |
+
$segment_count = array();
|
1167 |
+
// check if groupings data is set (for segment and interest groups)
|
1168 |
+
// this avoids an error being thrown when no segment/interest groups have been selected
|
1169 |
+
if ( isset( $subscriber_data_merges['GROUPINGS'] ) ) {
|
1170 |
+
foreach ($subscriber_data_merges['GROUPINGS'] as $group1) {
|
1171 |
+
foreach ($group1['groups'] as $group2) {
|
1172 |
+
if ($group2['interested'] == 1) {
|
1173 |
+
array_push($segment_count, $group2['name']);
|
1174 |
+
}
|
1175 |
+
}
|
1176 |
+
}
|
1177 |
+
}
|
1178 |
+
?>
|
1179 |
+
|
1180 |
+
<h2 class="yks-mc-subscriber-header"><?php _e( 'Groups Subscribed To' , 'yikes-inc-easy-mailchimp-extender' ); ?></h2>
|
1181 |
+
<!-- display what groups/segments the subscriber is subscribed too -->
|
1182 |
+
<?php
|
1183 |
+
// if the user is subscribed to some segment
|
1184 |
+
if(!empty($segment_count)) {
|
1185 |
+
$groups_array = array(
|
1186 |
+
'group_name' => '',
|
1187 |
+
'segments' => array()
|
1188 |
+
);
|
1189 |
+
$num = 0;
|
1190 |
+
foreach ($subscriber_data_merges['GROUPINGS'] as $group_name) {
|
1191 |
+
$groups_array[$num]['group_name'] = $group_name['name'];
|
1192 |
+
foreach ($group_name['groups'] as $groupData ) {
|
1193 |
+
if ($groupData['interested'] == 1) {
|
1194 |
+
$groups_array[$num]['segments'] = $groupData['name'];
|
1195 |
+
}
|
1196 |
+
}
|
1197 |
+
$num++;
|
1198 |
+
}
|
1199 |
+
// build up the segments array that the user is subscribed too
|
1200 |
+
foreach ( $groups_array as $group_data ) {
|
1201 |
+
if(!empty($group_data['segments'])) { ?>
|
1202 |
+
<ul>
|
1203 |
+
<?php
|
1204 |
+
echo '<li style="font-size:16px; color:#333;">'.$group_data['group_name'].'</li>';
|
1205 |
+
if(!empty($group_data['group_name']) && isset($group_data['segments'])) {
|
1206 |
+
echo 'Segments : '; echo implode(' ,', array($group_data['segments']));
|
1207 |
+
} elseif (count($group_data['segments']) == 0) {
|
1208 |
+
echo 'n/a';
|
1209 |
+
}
|
1210 |
+
?>
|
1211 |
+
</ul>
|
1212 |
+
<?php
|
1213 |
+
}
|
1214 |
+
}
|
1215 |
+
} else {
|
1216 |
+
// if there are no segments subscribed too
|
1217 |
+
// just print a message none specified
|
1218 |
+
echo 'none specified';
|
1219 |
+
}
|
1220 |
+
|
1221 |
+
// display the notes associated with a user if there are any returned
|
1222 |
+
if(!empty($subscriber_data['notes'])) { ?>
|
1223 |
+
<div class="yks-mc-subscriber-bottom">
|
1224 |
+
<h2 class="yks-mc-subscriber-header"><?php _e( 'Subscriber Notes' , 'yikes-inc-easy-mailchimp-extender' ); ?></h2>
|
1225 |
+
<?php
|
1226 |
+
foreach ( $subscriber_data['notes'] as $note ) {
|
1227 |
+
?>
|
1228 |
+
<textarea style="width:100%; height:100px; resize:none;" id="yks-mc-subscriber-notes" disabled><?php echo $note['note']; ?></textarea>
|
1229 |
+
<span style="font-size:11px; opacity:.75;"><?php _e( 'Written by' , 'yikes-inc-easy-mailchimp-extender' ); ?>: <?php echo $note['created_by_name']; ?> // <?php _e( 'Created on' , 'yikes-inc-easy-mailchimp-extender' ); ?>: <?php echo date('m/d/Y',strtotime($note['created'])); ?></span>
|
1230 |
+
<?php
|
1231 |
+
}
|
1232 |
+
?>
|
1233 |
+
</div>
|
1234 |
+
<?php
|
1235 |
+
}
|
1236 |
+
}
|
1237 |
+
wp_die();
|
1238 |
+
} // end getSubscriberInfo();
|
1239 |
+
|
1240 |
+
// Make a call to the MailChimp API to remove a specified user from a given list
|
1241 |
+
// Runs when the user clicks the 'X' next to a subscriber when viewing all subscribers on the lists page
|
1242 |
+
public function yks_removeSubscriber($lid, $user_email) {
|
1243 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
1244 |
+
$subscribers_list = $api->call('lists/unsubscribe', array(
|
1245 |
+
'id' => $lid,
|
1246 |
+
'email' => array(
|
1247 |
+
'email' => $user_email
|
1248 |
+
)
|
1249 |
+
));
|
1250 |
+
} // end yks_removeSubscriber();
|
1251 |
+
|
1252 |
+
/***** SCRIPTS/STYLES
|
1253 |
+
****************************************************************************************************/
|
1254 |
+
|
1255 |
+
// enqueue dashboard styles
|
1256 |
+
public function addStyles() {
|
1257 |
+
include YKSEME_PATH . 'lib/inc/yks-mc-dashboard-styles.php';
|
1258 |
+
} // end addStyles();
|
1259 |
+
|
1260 |
+
// enqueue dashboard scripts
|
1261 |
+
public function addScripts() {
|
1262 |
+
include YKSEME_PATH . 'lib/inc/yks-mc-dashboard-scripts.php';
|
1263 |
+
} // end addScripts();
|
1264 |
+
|
1265 |
+
// enqueue our styles on the front end
|
1266 |
+
public function addStyles_frontend() {
|
1267 |
+
include YKSEME_PATH . 'lib/inc/yks-mc-frontend-styles.php';
|
1268 |
+
} // end addStyles_frontend();
|
1269 |
+
|
1270 |
+
// enqueue front end scripts
|
1271 |
+
public function addScripts_frontend() {
|
1272 |
+
// enqueue jQuery datepicker only when the user has specified to do so
|
1273 |
+
if( isset( $this->optionVal['yks-mailchimp-jquery-datepicker'] ) && $this->optionVal['yks-mailchimp-jquery-datepicker'] == '1' ) {
|
1274 |
+
wp_enqueue_script('jquery-ui-datepicker');
|
1275 |
+
}
|
1276 |
+
} // addScripts_frontend();
|
1277 |
+
|
1278 |
+
// redirect the user to the settings page on initial activation
|
1279 |
+
function yks_easy_mc_plugin_activation_redirect() {
|
1280 |
+
if (get_option('yks_easy_mc_plugin_do_activation_redirect', false)) {
|
1281 |
+
delete_option('yks_easy_mc_plugin_do_activation_redirect');
|
1282 |
+
// redirect to settings page
|
1283 |
+
wp_redirect(admin_url('/admin.php?page=yks-mailchimp-welcome'));
|
1284 |
+
}
|
1285 |
+
} // end yks_easy_mc_plugin_activation_redirect();
|
1286 |
+
|
1287 |
+
|
1288 |
+
/***** SHORTCODES
|
1289 |
+
****************************************************************************************************/
|
1290 |
+
// Function to process the shortcode provided by the plugin
|
1291 |
+
// $p is the data associated with the shortcode (ie: form id and submit button text)
|
1292 |
+
public function processShortcode( $p ) {
|
1293 |
+
ob_start();
|
1294 |
+
// check if the list is set, to prevent errors from being thrown
|
1295 |
+
if ( isset( $this->optionVal['lists'][$p['id']] ) ) {
|
1296 |
+
|
1297 |
+
if( $this->optionVal['api-key'] != '' && ( is_array( $this->optionVal['lists'][$p['id']] ) && !empty( $this->optionVal['lists'][$p['id']] ) ) ) {
|
1298 |
+
// Setup this list
|
1299 |
+
$list = $this->optionVal['lists'][$p['id']];
|
1300 |
+
$submit_text = $p['submit_text'];
|
1301 |
+
// Which form are we on?
|
1302 |
+
if( !isset( $this->currentLists[$p['id']] ) ) {
|
1303 |
+
$this->currentLists[$p['id']] = 0;
|
1304 |
+
} else {
|
1305 |
+
$this->currentLists[$p['id']]++;
|
1306 |
+
}
|
1307 |
+
$listCt = $this->currentLists[$p['id']];
|
1308 |
+
// Add the count to the list vars
|
1309 |
+
$list['id'] = $listCt.'-'.$list['id'];
|
1310 |
+
if( count( $list['fields'] ) ) {
|
1311 |
+
foreach( $list['fields'] as $fieldId => $field ) {
|
1312 |
+
$list['fields'][$fieldId]['id'] = $listCt.'-'.$field['id'];
|
1313 |
+
}
|
1314 |
+
}
|
1315 |
+
// List form
|
1316 |
+
include YKSEME_PATH.'templates/shortcode_form.php';
|
1317 |
+
}
|
1318 |
+
|
1319 |
+
// if there is no api key entered, or it's an invalid api key
|
1320 |
+
} else if ( $this->optionVal['api-key'] == '' || get_option( 'api_validation' ) == 'invalid_api_key' ) {
|
1321 |
+
include YKSEME_PATH.'templates/shortcode_error_no_API_key.php';
|
1322 |
+
// else if the form was removed from the lists page
|
1323 |
+
} else {
|
1324 |
+
include YKSEME_PATH.'templates/shortcode_error_data.php';
|
1325 |
+
}
|
1326 |
+
$shortcode = ob_get_contents();
|
1327 |
+
ob_end_clean();
|
1328 |
+
return $shortcode;
|
1329 |
+
} // end processShortcode();
|
1330 |
+
|
1331 |
+
/* New Function to Display Subscriber Count for a given list */
|
1332 |
+
public function displaySubscriberCount( $p ) {
|
1333 |
+
ob_start();
|
1334 |
+
if( $this->optionVal['api-key'] != '' && ( is_array( $this->optionVal['lists'][$p['id']] ) && !empty( $this->optionVal['lists'][$p['id']] ) ) ) {
|
1335 |
+
// Setup this list
|
1336 |
+
$list = $this->optionVal['lists'][$p['id']];
|
1337 |
+
$mailChimp = new yksemeBase();
|
1338 |
+
$list = $mailChimp->getListsData();
|
1339 |
+
$list_id = key($list);
|
1340 |
+
// return just the subscriber count so the user can easily customize it!
|
1341 |
+
echo $list['subscriber-count']['subscriber-count-'.$list_id];
|
1342 |
+
} else if ( $this->optionVal['api-key'] == '' || get_option( 'api_validation' ) == 'invalid_api_key' ) {
|
1343 |
+
include YKSEME_PATH.'templates/shortcode_error_no_API_key.php';
|
1344 |
+
// else if the form was removed from the lists page
|
1345 |
+
} else {
|
1346 |
+
include YKSEME_PATH.'templates/shortcode_error_data.php';
|
1347 |
+
}
|
1348 |
+
$shortcode = ob_get_contents();
|
1349 |
+
ob_end_clean();
|
1350 |
+
return $shortcode;
|
1351 |
+
} // end displaySubscriberCount();
|
1352 |
+
|
1353 |
+
// Function to process the PHP snippet provided by the plugin
|
1354 |
+
// Again the data passed in, is the shortcode/php snippet paramaters (form id, submit button text)
|
1355 |
+
public function processSnippet($list=false, $submit_text) {
|
1356 |
+
$p = array(
|
1357 |
+
'id' => $list,
|
1358 |
+
'submit_text' => $submit_text
|
1359 |
+
);
|
1360 |
+
return $this->processShortcode($p);
|
1361 |
+
} // end processSnippet();
|
1362 |
+
|
1363 |
+
|
1364 |
+
/***** ADMINISTRATION MENUS => Continue Editing Downward!
|
1365 |
+
****************************************************************************************************/
|
1366 |
+
public function addAdministrationMenu() {
|
1367 |
+
// Top Level Menu
|
1368 |
+
add_menu_page( __('MailChimp Forms','yikes-inc-easy-mailchimp-extender'), 'MailChimp Forms', apply_filters( 'yks_mailchimp_user_role' , 'manage_options' ), 'yks-mailchimp-form', array(&$this, 'generatePageOptions'), 'dashicons-welcome-write-blog', 400);
|
1369 |
+
// Sub Items
|
1370 |
+
add_submenu_page('yks-mailchimp-form', __('MailChimp Forms','yikes-inc-easy-mailchimp-extender'), __('MailChimp Settings','yikes-inc-easy-mailchimp-extender'), apply_filters( 'yks_mailchimp_user_role' , 'manage_options' ), 'yks-mailchimp-form', array(&$this, 'generatePageOptions'));
|
1371 |
+
// if the user has entered a VALID API key
|
1372 |
+
if ( get_option('api_validation') == 'valid_api_key') {
|
1373 |
+
add_submenu_page('yks-mailchimp-form', __('My MailChimp','yikes-inc-easy-mailchimp-extender'), __('My MailChimp','yikes-inc-easy-mailchimp-extender'), apply_filters( 'yks_mailchimp_user_role' , 'manage_options' ), 'yks-mailchimp-my-mailchimp', array(&$this, 'generateUserMailChimpPage'));
|
1374 |
+
}
|
1375 |
+
add_submenu_page('yks-mailchimp-form', __('Manage List Forms','yikes-inc-easy-mailchimp-extender'), __('Manage List Forms','yikes-inc-easy-mailchimp-extender'), apply_filters( 'yks_mailchimp_user_role' , 'manage_options' ), 'yks-mailchimp-form-lists', array(&$this, 'generatePageLists'));
|
1376 |
+
add_submenu_page('yks-mailchimp-form', __('About YIKES, Inc.','yikes-inc-easy-mailchimp-extender'), __('About YIKES, Inc.','yikes-inc-easy-mailchimp-extender'), apply_filters( 'yks_mailchimp_user_role' , 'manage_options' ), 'yks-mailchimp-about-yikes', array(&$this, 'generatePageAboutYikes'));
|
1377 |
+
add_submenu_page('options.php', __('Welcome','yikes-inc-easy-mailchimp-extender'), __('Welcome','yikes-inc-easy-mailchimp-extender'), apply_filters( 'yks_mailchimp_user_role' , 'manage_options' ), 'yks-mailchimp-welcome', array(&$this, 'generateWelcomePage'));
|
1378 |
+
} // end addAdministrationMenu();
|
1379 |
+
|
1380 |
+
|
1381 |
+
/***** ADMINISTRATION PAGES
|
1382 |
+
****************************************************************************************************/
|
1383 |
+
public function generatePageOptions() {
|
1384 |
+
require_once YKSEME_PATH.'pages/options.php'; // include our options page
|
1385 |
+
} // end generatePageOptions();
|
1386 |
+
|
1387 |
+
public function generatePageLists() {
|
1388 |
+
require_once YKSEME_PATH.'pages/lists.php'; // include our lists page
|
1389 |
+
} // end generatePageLists();
|
1390 |
+
|
1391 |
+
public function generatePageAboutYikes() {
|
1392 |
+
require_once YKSEME_PATH.'pages/about.php'; // include our about page
|
1393 |
+
} // end generatePageAboutYikes();
|
1394 |
+
|
1395 |
+
public function registerMailChimpWidget() {
|
1396 |
+
require_once YKSEME_PATH.'templates/yikes-mailchimp-widget.php'; // include our widget
|
1397 |
+
} // end registerMailChimpWidget();
|
1398 |
+
|
1399 |
+
public function includeRECAPTCHAlib() {
|
1400 |
+
require_once YKSEME_PATH.'lib/recaptchalib.php'; // include our widget
|
1401 |
+
} // end includeRECAPTCHAlib();
|
1402 |
+
|
1403 |
+
public function generateUserMailChimpPage() {
|
1404 |
+
require_once YKSEME_PATH.'pages/myMailChimp.php'; // include our widget
|
1405 |
+
} // end generateUserMailChimpPage();
|
1406 |
+
|
1407 |
+
public function generateWelcomePage() {
|
1408 |
+
require_once YKSEME_PATH.'pages/welcome.php'; // include our widget
|
1409 |
+
} // end generateWelcomePage();
|
1410 |
+
|
1411 |
+
/***** FORM DATA
|
1412 |
+
****************************************************************************************************/
|
1413 |
+
public function yks_resetPluginSettings() {
|
1414 |
+
$blog_title = get_bloginfo( 'name' );
|
1415 |
+
// reset the plugin settings back to defaults
|
1416 |
+
$this->optionVal['api-key'] = '';
|
1417 |
+
$this->optionVal['flavor'] = '1';
|
1418 |
+
$this->optionVal['debug'] = '0';
|
1419 |
+
$this->optionVal['optin'] = 'true';
|
1420 |
+
$this->optionVal['single-optin-message'] = __('Thank You for subscribing!', 'yikes-inc-easy-mailchimp-extender');
|
1421 |
+
$this->optionVal['double-optin-message'] = __('Thank You for subscribing! Check your email for the confirmation message.', 'yikes-inc-easy-mailchimp-extender');
|
1422 |
+
$this->optionVal['optIn-checkbox'] = 'hide';
|
1423 |
+
$this->optionVal['yks-mailchimp-optIn-default-list'] = 'select_list';
|
1424 |
+
$this->optionVal['yks-mailchimp-optin-checkbox-text'] = 'Add me to the ' . $blog_title . ' mailing list';
|
1425 |
+
$this->optionVal['recaptcha-setting'] = '0';
|
1426 |
+
$this->optionVal['recaptcha-api-key'] = '';
|
1427 |
+
$this->optionVal['recaptcha-private-api-key'] = '';
|
1428 |
+
$this->optionVal['yks-mailchimp-jquery-datepicker'] = '';
|
1429 |
+
$this->optionVal['yks-mailchimp-required-text'] = '';
|
1430 |
+
$this->optionVal['version'] = YKSEME_VERSION_CURRENT;
|
1431 |
+
$this->optionVal['ssl_verify_peer'] = 'true';
|
1432 |
+
update_option('api_validation' , 'invalid_api_key');
|
1433 |
+
// we need to unset the previously set up widgets
|
1434 |
+
// and set up new erros if the API key doesn't exist
|
1435 |
+
|
1436 |
+
// 1 - empty the lists array of imported lists
|
1437 |
+
$this->optionVal['lists'] = array();
|
1438 |
+
// 2 - unset our previously set up widgets
|
1439 |
+
update_option( 'widget_yikes_mc_widget' , '' );
|
1440 |
+
// update our options
|
1441 |
+
return update_option( YKSEME_OPTION, $this->optionVal );
|
1442 |
+
} // end yks_resetPluginSettings();
|
1443 |
+
|
1444 |
+
// Make a call to MailChimp API to validate the provided API key - send request to helper/ping, returns a boolean
|
1445 |
+
public function validateAPIkeySettings() {
|
1446 |
+
|
1447 |
+
// right now we just check the length of the API key being passed in
|
1448 |
+
// mailchimp api keys are around 30-40 characters
|
1449 |
+
// we check if the string length is greater than 45...
|
1450 |
+
if ( strlen($_POST['api_key']) > 45 ) {
|
1451 |
+
// Create and store our variables to pass to MailChimp
|
1452 |
+
$apiKey = $this->yikes_mc_decryptIt($_POST['api_key']); // api key
|
1453 |
+
$apiKey_explosion = explode( "-" , $apiKey);
|
1454 |
+
$dataCenter = $apiKey_explosion[0]; // data center (ie: us3)
|
1455 |
+
$api = new Mailchimp($apiKey);
|
1456 |
+
// try the call, catch any errors that may be thrown
|
1457 |
+
try {
|
1458 |
+
$resp = $api->call('helper/ping', array('apikey' => $apiKey));
|
1459 |
+
echo $resp['msg'];
|
1460 |
+
$this->getOptionsLists();
|
1461 |
+
} catch( Exception $e ) {
|
1462 |
+
$errorMessage = str_replace('API call to helper/ping failed:', '', $e->getMessage());
|
1463 |
+
echo $errorMessage;
|
1464 |
+
// log our error message for display back to the user
|
1465 |
+
$this->writeErrorToErrorLog( $e );
|
1466 |
+
}
|
1467 |
+
return $apiKey;
|
1468 |
+
// always die or it will always return 1
|
1469 |
+
wp_die();
|
1470 |
+
} else {
|
1471 |
+
$apiKey = $this->yikes_mc_encryptIt($_POST['api_key']);
|
1472 |
+
// Create and store our variables to pass to MailChimp
|
1473 |
+
$decryped_api_key = $this->yikes_mc_decryptIt($apiKey); // api key
|
1474 |
+
$apiKey_explosion = explode( "-" , $decryped_api_key);
|
1475 |
+
$dataCenter = $apiKey_explosion[0]; // data center (ie: us3)
|
1476 |
+
$api = new Mailchimp($decryped_api_key);
|
1477 |
+
// try the call, catch any errors that may be thrown
|
1478 |
+
try {
|
1479 |
+
$resp = $api->call('helper/ping', array('apikey' => $decryped_api_key));
|
1480 |
+
echo $resp['msg'];
|
1481 |
+
} catch( Exception $e ) {
|
1482 |
+
$errorMessage = str_replace('API call to helper/ping failed:', '', $e->getMessage());
|
1483 |
+
echo $errorMessage;
|
1484 |
+
// log our error message for display back to the user
|
1485 |
+
$this->writeErrorToErrorLog( $e );
|
1486 |
+
}
|
1487 |
+
// always die or it will always return 1
|
1488 |
+
return $apiKey;
|
1489 |
+
wp_die();
|
1490 |
+
}
|
1491 |
+
} // end validateAPIkeySettings();
|
1492 |
+
|
1493 |
+
// Make a call to MailChimp API to get the current users PROFILE
|
1494 |
+
public function getUserProfileDetails() {
|
1495 |
+
// Create and store our variables to pass to MailChimp
|
1496 |
+
$apiKey = $_POST['api_key']; // api key
|
1497 |
+
$api = new Mailchimp($apiKey);
|
1498 |
+
// try the call, catch any errors that may be thrown
|
1499 |
+
try {
|
1500 |
+
$profile_response = $api->call('users/profile', array('apikey' => $apiKey));
|
1501 |
+
include_once YKSEME_PATH.'templates/mailChimp-profile-template.php';
|
1502 |
+
} catch( Exception $e ) {
|
1503 |
+
$errorMessage = str_replace('API call to helper/ping failed:', '', $e->getMessage());
|
1504 |
+
echo $errorMessage;
|
1505 |
+
// write our error to the error log,
|
1506 |
+
// when advanced debug is enabled
|
1507 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
1508 |
+
$this->writeErrorToErrorLog( $e );
|
1509 |
+
}
|
1510 |
+
}
|
1511 |
+
|
1512 |
+
// try the call, catch any errors that may be thrown
|
1513 |
+
try {
|
1514 |
+
$account_details = $api->call('helper/account-details', array('apikey' => $apiKey));
|
1515 |
+
include_once YKSEME_PATH.'templates/mailChimp-account-overview.php';
|
1516 |
+
} catch( Exception $e ) {
|
1517 |
+
$errorMessage = str_replace('API call to helper/ping failed:', '', $e->getMessage());
|
1518 |
+
echo $errorMessage;
|
1519 |
+
// write our error to the error log,
|
1520 |
+
// when advanced debug is enabled
|
1521 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
1522 |
+
$this->writeErrorToErrorLog( $e );
|
1523 |
+
}
|
1524 |
+
}
|
1525 |
+
// always die or it will always return 1
|
1526 |
+
wp_die();
|
1527 |
+
} // end getUserProfileDetails();
|
1528 |
+
|
1529 |
+
/*
|
1530 |
+
Send Update Profile Email
|
1531 |
+
@since v5.2
|
1532 |
+
*/
|
1533 |
+
public function sendUpdateProfileEmail( $user_email , $list_id ) {
|
1534 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
1535 |
+
$explode_key = explode( '-' , $this->optionVal['api-key'] );
|
1536 |
+
$data_center = $explode_key[1];
|
1537 |
+
$full_site_url = get_bloginfo('url');
|
1538 |
+
$extracted_url = str_replace( 'https://' , '' , str_replace( 'www.' , '' , str_replace( 'http://' , '' , $full_site_url ) ) );
|
1539 |
+
$site_name = str_replace( ' ' , '' , get_bloginfo('name') ) ;
|
1540 |
+
try {
|
1541 |
+
// get the site URL
|
1542 |
+
// not sure this needs its own API call
|
1543 |
+
$account_details = $api->call( 'helper/account-details', array('apikey' => $this->optionVal['api-key'] ) );
|
1544 |
+
// get the list details (default from name, default from email)
|
1545 |
+
$list_details = $api->call( 'lists/list',
|
1546 |
+
array(
|
1547 |
+
'apikey' => $this->optionVal['api-key'],
|
1548 |
+
'filters' => array(
|
1549 |
+
'list_id' => $list_id
|
1550 |
+
)
|
1551 |
+
)
|
1552 |
+
);
|
1553 |
+
// get the subscribers info
|
1554 |
+
$subscriber_account_details = $api->call('lists/member-info',
|
1555 |
+
array(
|
1556 |
+
'id' => $list_id,
|
1557 |
+
'emails' => array(
|
1558 |
+
0 => array(
|
1559 |
+
'email' => $user_email,
|
1560 |
+
),
|
1561 |
+
)
|
1562 |
+
)
|
1563 |
+
);
|
1564 |
+
$subscriber_id = $subscriber_account_details['data'][0]['id'];
|
1565 |
+
$explode_url = explode( '.' , $account_details['contact']['url'] );
|
1566 |
+
$subject = 'MailChimp Profile Update';
|
1567 |
+
$headers = 'From: ' . $list_details['data'][0]['default_from_name'] . ' <' . $list_details['data'][0]['default_from_email'] . '>' . "\r\n";
|
1568 |
+
$headers .= 'Content-type: text/html';
|
1569 |
+
$email_content = '<p>Dear user,</p> <p>A request has been made to update your account information. To do so use the following link: <a href="http://' . $explode_url[1] . '.' . $data_center . '.list-manage1.com/profile?u=' . $account_details['user_id'] . '&id=' . $list_id .'&e=' . $subscriber_id . '" title="Update MailChimp Profile">Update Profile Info.</a>';
|
1570 |
+
$email_content .= "<p>If you didn't request this update, please disregard this email.</p>";
|
1571 |
+
$email_content .= '<p> </p>';
|
1572 |
+
$email_content .= '<p>This email was sent from : ' . $full_site_url . '</p>';
|
1573 |
+
$email_content .= '<p> </p>';
|
1574 |
+
$email_content .= '<p> </p>';
|
1575 |
+
$email_content .= '<p style="font-size:13px;margin-top:5em;float:right;"><em>this email was generated by the <a href="http://www.wordpress.org/plugins/yikes-inc-easy-mailchimp-extender/" target="_blank">YIKES Inc. Easy MailChimp Extender</a> plugin, created by <a href="http://www.yikesinc.com" target="_blank">YIKES Inc.</a></em></p>';
|
1576 |
+
if ( wp_mail( $user_email, $subject, $email_content, $headers ) ) {
|
1577 |
+
echo '<span class="preloader-confirmation-box success">' . __( 'Update email successfully sent. Please check your inbox for the message.' , 'yikes-inc-easy-mailchimp-extender' ) . '</span>';
|
1578 |
+
} else {
|
1579 |
+
echo '<span class="preloader-confirmation-box error">' . __( 'Email failed to send. Please contact the site administrator.' , 'yikes-inc-easy-mailchimp-extender' ) . '</span>';
|
1580 |
+
}
|
1581 |
+
// print_r($account_details);
|
1582 |
+
} catch( Exception $e ) {
|
1583 |
+
$errorMessage = '<span class="error">' . __( 'Error sending update profile email. Please contact the site administrator.' , 'yikes-inc-easy-mailchimp-extender' ) . '</span>';
|
1584 |
+
echo $errorMessage;
|
1585 |
+
// write our error to the error log,
|
1586 |
+
// when advanced debug is enabled
|
1587 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
1588 |
+
$this->writeErrorToErrorLog( $e );
|
1589 |
+
}
|
1590 |
+
}
|
1591 |
+
} // end sendUpdateProfileEmail();
|
1592 |
+
|
1593 |
+
|
1594 |
+
// Make a call to MailChimp API to validate the provided API key - api request to helper/chimp-chatter, returns Account Activity
|
1595 |
+
public function getMailChimpChatter() {
|
1596 |
+
// Create and store our variables to pass to MailChimp
|
1597 |
+
$apiKey = $this->optionVal['api-key']; // api key
|
1598 |
+
$api = new Mailchimp($apiKey);
|
1599 |
+
// try the call, catch any errors that may be thrown
|
1600 |
+
try {
|
1601 |
+
$resp = $api->call('helper/chimp-chatter', array('apikey' => $apiKey));
|
1602 |
+
include_once YKSEME_PATH.'templates/mailChimpChatter-template.php';
|
1603 |
+
} catch( Exception $e ) {
|
1604 |
+
echo '<strong>'.$e->getMessage().'</strong>';
|
1605 |
+
// write our error to the error log,
|
1606 |
+
// when advanced debug is enabled
|
1607 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
1608 |
+
$this->writeErrorToErrorLog( $e );
|
1609 |
+
}
|
1610 |
+
|
1611 |
+
}
|
1612 |
+
// always die or it will always return 1
|
1613 |
+
wp_die();
|
1614 |
+
} // end getMailChimpChatter();
|
1615 |
+
|
1616 |
+
|
1617 |
+
// Make a call to MailChimp API to validate the provided API key
|
1618 |
+
// calls the helper/chimp-chatter method, and returns Account Activity
|
1619 |
+
public function getMailChimpChatterForWidget() {
|
1620 |
+
// Create and store our variables to pass to MailChimp
|
1621 |
+
$apiKey = $this->optionVal['api-key']; // api key
|
1622 |
+
$api = new Mailchimp($apiKey);
|
1623 |
+
// try the call, catch any errors that may be thrown
|
1624 |
+
try {
|
1625 |
+
$resp = $api->call('helper/chimp-chatter', array('apikey' => $apiKey));
|
1626 |
+
include_once YKSEME_PATH.'templates/mailChimpChatter-widget-template.php';
|
1627 |
+
} catch( Exception $e ) {
|
1628 |
+
echo '<strong>'.$e->getMessage().'</strong>';
|
1629 |
+
// write our error to the error log,
|
1630 |
+
// when advanced debug is enabled
|
1631 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
1632 |
+
$this->writeErrorToErrorLog( $e );
|
1633 |
+
}
|
1634 |
+
|
1635 |
+
}
|
1636 |
+
// always die or it will always return 1
|
1637 |
+
wp_die();
|
1638 |
+
} // end getMailChimpChatterForWidget();
|
1639 |
+
|
1640 |
+
|
1641 |
+
// Make a call to MailChimp API to lists/growth history
|
1642 |
+
public function getListGrowthHistory() {
|
1643 |
+
// Create and store our variables to pass to MailChimp
|
1644 |
+
$apiKey = $_POST['api_key']; // api key
|
1645 |
+
if ( isset($_POST['list_id']) ) { $listID = $_POST['list_id']; } else { $listID = NULL; }
|
1646 |
+
$api = new Mailchimp($apiKey);
|
1647 |
+
// try the call, catch any errors that may be thrown
|
1648 |
+
try {
|
1649 |
+
$resp = $api->call('lists/growth-history', array( 'apikey' => $apiKey , 'id' => $listID ));
|
1650 |
+
// include our Stats Template
|
1651 |
+
include_once YKSEME_PATH.'templates/mailChimp-list-growth-template.php';
|
1652 |
+
// Working File
|
1653 |
+
// date is returned out of order tho...
|
1654 |
+
// include_once YKSEME_PATH.'templates/mailChimp-list-growth-template.php';
|
1655 |
+
} catch( Exception $e ) {
|
1656 |
+
echo '<strong>'.$e->getMessage().'</strong>';
|
1657 |
+
// write our error to the error log,
|
1658 |
+
// when advanced debug is enabled
|
1659 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
1660 |
+
$this->writeErrorToErrorLog( $e );
|
1661 |
+
}
|
1662 |
+
|
1663 |
+
}
|
1664 |
+
// always die or it will always return 1
|
1665 |
+
wp_die();
|
1666 |
+
} // end getListGrowthHistory();
|
1667 |
+
|
1668 |
+
|
1669 |
+
// Make a call to MailChimp API to
|
1670 |
+
// get a specified all campaigns or specified list campaign data
|
1671 |
+
// used for both overall aggregate stats AND single list stats
|
1672 |
+
public function getCapmpaignData() {
|
1673 |
+
// Create and store our variables to pass to MailChimp
|
1674 |
+
$apiKey = $_POST['api_key']; // api key
|
1675 |
+
$api = new Mailchimp($apiKey);
|
1676 |
+
// try the call, catch any errors that may be thrown
|
1677 |
+
try {
|
1678 |
+
$resp = $api->call('campaigns/list', array( 'apikey' => $apiKey , 'limit' => 1000 ));
|
1679 |
+
// include our Stats Template
|
1680 |
+
include_once YKSEME_PATH.'templates/mailChimp-campaign-stats-template.php';
|
1681 |
+
} catch( Exception $e ) {
|
1682 |
+
echo '<strong>'.$e->getMessage().'</strong>';
|
1683 |
+
// write our error to the error log,
|
1684 |
+
// when advanced debug is enabled
|
1685 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
1686 |
+
$this->writeErrorToErrorLog( $e );
|
1687 |
+
}
|
1688 |
+
|
1689 |
+
}
|
1690 |
+
// always die or it will always return 1
|
1691 |
+
wp_die();
|
1692 |
+
} // end getCapmpaignData();
|
1693 |
+
|
1694 |
+
|
1695 |
+
// Make a call to MailChimp API to
|
1696 |
+
// To get our piechart for the link stats page
|
1697 |
+
public function getPieChart() {
|
1698 |
+
// Create and store our variables to pass to MailChimp
|
1699 |
+
$pie_chart_link_data_array = $_POST['pie_chart_data_array']; // link data
|
1700 |
+
// include our Stats Template
|
1701 |
+
include YKSEME_PATH.'templates/mailChimp-campaign-clicks-pie-chart.php';
|
1702 |
+
|
1703 |
+
// always die or it will always return 1
|
1704 |
+
wp_die();
|
1705 |
+
}
|
1706 |
+
|
1707 |
+
// Make a call to MailChimp API to
|
1708 |
+
// get a specified all campaigns or specified list campaign data
|
1709 |
+
// used for both overall aggregate stats AND single list stats
|
1710 |
+
public function getSpecificCapmpaignData() {
|
1711 |
+
// Create and store our variables to pass to MailChimp
|
1712 |
+
$apiKey = $_POST['api_key']; // api key
|
1713 |
+
$api = new Mailchimp($apiKey);
|
1714 |
+
$campaign_id = $_POST['campaign_id'];
|
1715 |
+
$campaign_title = $_POST['campaign_title'];
|
1716 |
+
$campaign_email_subject = $_POST['campaign_subject'];
|
1717 |
+
$campaign_send_date = $_POST['campaign_send_date'];
|
1718 |
+
$campaign_send_time = $_POST['campaign_send_time'];
|
1719 |
+
$campaign_view_email_link = $_POST['campaign_view_email_link'];
|
1720 |
+
$campaign_web_Id = $_POST['campaign_web_Id'];
|
1721 |
+
// try the call, catch any errors that may be thrown
|
1722 |
+
try {
|
1723 |
+
$resp = $api->call('reports/summary', array( 'apikey' => $apiKey , 'cid' => $campaign_id ));
|
1724 |
+
// include our Stats Template
|
1725 |
+
include_once YKSEME_PATH.'templates/mailChimp-campaign-report.php';
|
1726 |
+
// print_r($resp);
|
1727 |
+
} catch( Exception $e ) {
|
1728 |
+
echo '<strong>'.$e->getMessage().'</strong>';
|
1729 |
+
// write our error to the error log,
|
1730 |
+
// when advanced debug is enabled
|
1731 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
1732 |
+
$this->writeErrorToErrorLog( $e );
|
1733 |
+
}
|
1734 |
+
}
|
1735 |
+
// always die or it will always return 1
|
1736 |
+
wp_die();
|
1737 |
+
} // end getSpecificCapmpaignData();
|
1738 |
+
|
1739 |
+
// Send a call to MailChimp API to get the email recipients of a specific campaign
|
1740 |
+
public function getCampaignEmailToTable() {
|
1741 |
+
// Create and store our variables to pass to MailChimp
|
1742 |
+
$apiKey = $_POST['api_key']; // api key
|
1743 |
+
$api = new Mailchimp($apiKey);
|
1744 |
+
$campaign_id = $_POST['campaign_id'];
|
1745 |
+
// try the call, catch any errors that may be thrown
|
1746 |
+
try {
|
1747 |
+
$resp = $api->call('reports/sent-to', array( 'apikey' => $apiKey , 'cid' => $campaign_id , 'opts' => array('limit' => '100') ));
|
1748 |
+
// include our Stats Template
|
1749 |
+
// include_once YKSEME_PATH.'templates/mailChimp-campaign-report.php';
|
1750 |
+
// print_r($resp);
|
1751 |
+
if ( $resp ) {
|
1752 |
+
?>
|
1753 |
+
<script type="text/javascript">
|
1754 |
+
jQuery(document).ready(function() {
|
1755 |
+
jQuery('#yikes-mailchimp-emailed-subscribers').dataTable();
|
1756 |
+
});
|
1757 |
+
</script>
|
1758 |
+
|
1759 |
+
<style>
|
1760 |
+
.subscriber_rating_star { font-size:15px; }
|
1761 |
+
</style>
|
1762 |
+
|
1763 |
+
<table id="yikes-mailchimp-emailed-subscribers" class="yks-mailchimp-fields-list" style="width:100%;">
|
1764 |
+
<thead class="yikes-mailchimp-subscribers-table-head">
|
1765 |
+
<tr>
|
1766 |
+
<th style="width:20%;"><?php _e( 'E-Mail' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
1767 |
+
<th style="width:19%;"><?php _e( 'First Name' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
1768 |
+
<th style="width:18%;"><?php _e( 'Last Name' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
1769 |
+
<th style="width:25%;"><?php _e( 'Member Rating' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
1770 |
+
<th style="width:18%;"><?php _e( 'Last Changed' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
1771 |
+
</tr>
|
1772 |
+
</thead>
|
1773 |
+
<?php
|
1774 |
+
foreach ( $resp['data'] as $recipient ) {
|
1775 |
+
|
1776 |
+
// create the name variable, dependant on first and last name being stored
|
1777 |
+
if ( isset ( $recipient['member']['merges']['FNAME'] ) && $recipient['member']['merges']['FNAME'] != '' ) {
|
1778 |
+
$user_first_name = $recipient['member']['merges']['FNAME'];
|
1779 |
+
} else {
|
1780 |
+
$user_first_name = '';
|
1781 |
+
}
|
1782 |
+
if ( isset ( $recipient['member']['merges']['LNAME'] ) && $recipient['member']['merges']['LNAME'] != '' ) {
|
1783 |
+
$user_last_name = $recipient['member']['merges']['LNAME'];
|
1784 |
+
} else {
|
1785 |
+
$user_last_name = '';
|
1786 |
+
}
|
1787 |
+
|
1788 |
+
$user_email = $recipient['member']['email'];
|
1789 |
+
$user_id = $recipient['member']['id'];
|
1790 |
+
$email_type = $recipient['member']['email_type'];
|
1791 |
+
$user_rating = $recipient['member']['member_rating'];
|
1792 |
+
$user_last_changed = $recipient['member']['info_changed'];
|
1793 |
+
$exploded_change = explode( ' ' , $user_last_changed);
|
1794 |
+
$user_last_changed_date = date( 'm/d/Y' , strtotime( $exploded_change[0] ) );
|
1795 |
+
$user_last_changed_time = date( 'g:i a' , strtotime( $exploded_change[1] ) );
|
1796 |
+
|
1797 |
+
if(isset($user_rating)) {
|
1798 |
+
if ($user_rating == 1) {
|
1799 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
1800 |
+
} else if ($user_rating == 2) {
|
1801 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
1802 |
+
} else if ($user_rating == 3) {
|
1803 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
1804 |
+
} else if ($user_rating == 4) {
|
1805 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
1806 |
+
} else if ($user_rating == 5) {
|
1807 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span></div>';
|
1808 |
+
}
|
1809 |
+
}
|
1810 |
+
|
1811 |
+
// $timeStamp = explode(' ', $subscriber['timestamp_opt'] );
|
1812 |
+
echo '<tr class="yks-mailchimp-subscribers-list-row" id="yks-mailchimp-subscribers-list-row">';
|
1813 |
+
echo '<td><a class="subscriber-mail-link" rel="'.$user_email.'" class="subscriberEmailAddress">'.$user_email.'</a></td>';
|
1814 |
+
echo '<td>'.ucfirst(strtolower($user_first_name)).'</td>';
|
1815 |
+
echo '<td>'.ucfirst(strtolower($user_last_name)).'</td>';
|
1816 |
+
echo '<td><span style="display:none;">'.$user_rating.'</span>'.$member_rating_stars.'</td>';
|
1817 |
+
echo '<td>'.$user_last_changed_date . ' at ' . $user_last_changed_time .'</td>';
|
1818 |
+
echo '</tr>';
|
1819 |
+
|
1820 |
+
}
|
1821 |
+
?>
|
1822 |
+
</table>
|
1823 |
+
<?php
|
1824 |
+
}
|
1825 |
+
} catch( Exception $e ) {
|
1826 |
+
echo '<strong>'.$e->getMessage().'</strong>';
|
1827 |
+
// write our error to the error log,
|
1828 |
+
// when advanced debug is enabled
|
1829 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
1830 |
+
$this->writeErrorToErrorLog( $e );
|
1831 |
+
}
|
1832 |
+
|
1833 |
+
}
|
1834 |
+
// always die or it will always return 1
|
1835 |
+
wp_die();
|
1836 |
+
} // end getCampaignEmailToTable();
|
1837 |
+
|
1838 |
+
|
1839 |
+
// Send a call to MailChimp API to get the geo location of users who opened links
|
1840 |
+
public function getGeoDataForCampaignOpenLinks() {
|
1841 |
+
// Create and store our variables to pass to MailChimp
|
1842 |
+
$apiKey = $_POST['api_key']; // api key
|
1843 |
+
$api = new Mailchimp($apiKey);
|
1844 |
+
$campaign_id = $_POST['campaign_id'];
|
1845 |
+
// try the call, catch any errors that may be thrown
|
1846 |
+
try {
|
1847 |
+
$resp = $api->call('reports/geo-opens', array( 'apikey' => $apiKey , 'cid' => $campaign_id ) );
|
1848 |
+
// include our Stats Template
|
1849 |
+
// include_once YKSEME_PATH.'templates/mailChimp-campaign-report.php';
|
1850 |
+
// print_r($resp);
|
1851 |
+
if ( $resp ) {
|
1852 |
+
include_once YKSEME_PATH.'templates/mailChimp-campaign-click-geo-map.php';
|
1853 |
+
}
|
1854 |
+
} catch( Exception $e ) {
|
1855 |
+
// write our error to the error log,
|
1856 |
+
// when advanced debug is enabled
|
1857 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
1858 |
+
$this->writeErrorToErrorLog( $e );
|
1859 |
+
}
|
1860 |
+
?>
|
1861 |
+
<script>
|
1862 |
+
jQuery(document).ready(function() {
|
1863 |
+
setTimeout(function() {
|
1864 |
+
var mailChimpError = '<?php echo "<strong class=yks-mc-report-error>".$e->getMessage()."</strong>"; ?>';
|
1865 |
+
jQuery('#open_tracking_disabled_warning').fadeIn();
|
1866 |
+
jQuery('#geo_map_no_data').append('<p class="geo_map_no_data_error">'+mailChimpError+'</p>');
|
1867 |
+
}, 600);
|
1868 |
+
});
|
1869 |
+
</script>
|
1870 |
+
|
1871 |
+
<section class="overview_information_section">
|
1872 |
+
|
1873 |
+
<div class="overview_information">
|
1874 |
+
|
1875 |
+
<h2>Campaign Activity Geo Map</h2>
|
1876 |
+
|
1877 |
+
<div id="geo_map_no_data" style="max-width: 100%;min-width: 100%; background:#fff;">
|
1878 |
+
<div id="geo_map_no_data_overlay"></div>
|
1879 |
+
<img src="<?php echo plugins_url( '/../images/highcharts-worldmap-disabled.png' , __FILE__ ); ?>" alt="World Map Disabled" title="World Map Disabled">
|
1880 |
+
</div>
|
1881 |
+
</div>
|
1882 |
+
|
1883 |
+
</section>
|
1884 |
+
|
1885 |
+
<?php
|
1886 |
+
}
|
1887 |
+
// always die or it will always return 1
|
1888 |
+
wp_die();
|
1889 |
+
} // end getGeoDataForCampaignOpenLinks();
|
1890 |
+
|
1891 |
+
|
1892 |
+
// Make a call to MailChimp API to
|
1893 |
+
// get link tracking information for a specified campaign
|
1894 |
+
// used in the world map on the campaign stats page
|
1895 |
+
public function getCampaignLinkStats() {
|
1896 |
+
// Create and store our variables to pass to MailChimp
|
1897 |
+
$apiKey = $_POST['api_key']; // api key
|
1898 |
+
$api = new Mailchimp($apiKey);
|
1899 |
+
$campaign_id = $_POST['campaign_id'];
|
1900 |
+
// try the call, catch any errors that may be thrown
|
1901 |
+
try {
|
1902 |
+
$campaign_click_stats = $api->call( '/reports/clicks' , array( 'apikey' => $apiKey , 'cid' => $campaign_id ) );
|
1903 |
+
// include our Stats Template
|
1904 |
+
include_once YKSEME_PATH.'templates/mailChimp-campaign-click-report.php';
|
1905 |
+
} catch( Exception $e ) {
|
1906 |
+
echo '<strong>'.$e->getMessage().'</strong>';
|
1907 |
+
// write our error to the error log,
|
1908 |
+
// when advanced debug is enabled
|
1909 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
1910 |
+
$this->writeErrorToErrorLog( $e );
|
1911 |
+
}
|
1912 |
+
}
|
1913 |
+
// always die or it will always return 1
|
1914 |
+
wp_die();
|
1915 |
+
} // end getCampaignLinkStats();
|
1916 |
+
|
1917 |
+
|
1918 |
+
// Make a call to MailChimp API to
|
1919 |
+
// get users who opened a specific campaign
|
1920 |
+
// used in the stats page modal
|
1921 |
+
public function getCampaignOpenedData() {
|
1922 |
+
// Create and store our variables to pass to MailChimp
|
1923 |
+
$apiKey = $_POST['api_key']; // api key
|
1924 |
+
$api = new Mailchimp($apiKey);
|
1925 |
+
$campaign_id = $_POST['campaign_id'];
|
1926 |
+
// try the call, catch any errors that may be thrown
|
1927 |
+
try {
|
1928 |
+
// create our interactive data table
|
1929 |
+
// and initialize it here...
|
1930 |
+
|
1931 |
+
$campaign_open_stats = $api->call( '/reports/opened' , array( 'apikey' => $apiKey , 'cid' => $campaign_id , 'opts' => array( 'sort_field' => 'opens' , 'sort_dir' => 'DESC' ) ) );
|
1932 |
+
|
1933 |
+
// create an empty array
|
1934 |
+
$total_opens_array = array();
|
1935 |
+
// build our total opens array
|
1936 |
+
foreach ( $campaign_open_stats['data'] as $opened_data ) {
|
1937 |
+
$total_opens_array[] = $opened_data['opens'];
|
1938 |
+
}
|
1939 |
+
|
1940 |
+
// display total unique opens
|
1941 |
+
echo '<h2 style="float:left;">' . __( 'Unique Opens' , 'yikes-inc-easy-mailchimp-extender' ) . ' - ' . $campaign_open_stats["total"] . '</h2>';
|
1942 |
+
// display total opens
|
1943 |
+
echo '<h2 style="float:right;">' . __( 'Total Opens' , 'yikes-inc-easy-mailchimp-extender' ) . ' - ' . array_sum($total_opens_array) . '</h2>';
|
1944 |
+
|
1945 |
+
// echo '<h2>' . __( 'Total Opens' 'yikes-inc-easy-mailchimp-extender' ) . $campaign_open_stats["total"] . '</h2>';
|
1946 |
+
|
1947 |
+
?>
|
1948 |
+
<!-- initialize o ur data table -->
|
1949 |
+
<script type="text/javascript">
|
1950 |
+
jQuery(document).ready(function() {
|
1951 |
+
jQuery('#yikes-mailchimp-subscribers-opens').dataTable({
|
1952 |
+
"aaSorting": [[ 1, "desc" ]]
|
1953 |
+
});
|
1954 |
+
});
|
1955 |
+
</script>
|
1956 |
+
|
1957 |
+
<style>
|
1958 |
+
.subscriber_rating_star { font-size:15px; }
|
1959 |
+
</style>
|
1960 |
+
|
1961 |
+
<!-- build our opened user table -->
|
1962 |
+
<table id="yikes-mailchimp-subscribers-opens" class="yks-mailchimp-fields-list" style="width:100%;">
|
1963 |
+
<thead class="yikes-mailchimp-subscribers-table-head">
|
1964 |
+
<tr>
|
1965 |
+
<th style="width:31%;"><?php _e( 'E-Mail' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
1966 |
+
<th style="width:14%;"><?php _e( 'Opens' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
1967 |
+
<th style="width:20%;"><?php _e( 'First Name' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
1968 |
+
<th style="width:20%;"><?php _e( 'Last Name' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
1969 |
+
<th style="width:15%;"><?php _e( 'Member Rating' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
1970 |
+
</tr>
|
1971 |
+
</thead>
|
1972 |
+
<?php
|
1973 |
+
// loop over to build create and store our user variables returned by mailchimp
|
1974 |
+
foreach ( $campaign_open_stats['data'] as $opened_data ) {
|
1975 |
+
|
1976 |
+
// checking if FNAME is set as a merge variable
|
1977 |
+
// if not, we'll just make it an empty string
|
1978 |
+
if ( isset ( $opened_data['member']['merges']['LNAME'] ) ) {
|
1979 |
+
$opened_data['member']['merges']['LNAME'] = $opened_data['member']['merges']['LNAME'];
|
1980 |
+
} else {
|
1981 |
+
$opened_data['member']['merges']['LNAME'] = '';
|
1982 |
+
}
|
1983 |
+
|
1984 |
+
// checking if LNAME is set as a merge variable
|
1985 |
+
// if not, we'll just make it an empty string
|
1986 |
+
if ( isset ( $opened_data['member']['merges']['FNAME'] ) ) {
|
1987 |
+
$opened_data['member']['merges']['FNAME'] = $opened_data['member']['merges']['FNAME'];
|
1988 |
+
} else {
|
1989 |
+
$opened_data['member']['merges']['FNAME'] = '';
|
1990 |
+
}
|
1991 |
+
|
1992 |
+
|
1993 |
+
if(isset($opened_data['member']['member_rating'])) {
|
1994 |
+
if ($opened_data['member']['member_rating'] == 1) {
|
1995 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
1996 |
+
} else if ($opened_data['member']['member_rating'] == 2) {
|
1997 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
1998 |
+
} else if ($opened_data['member']['member_rating'] == 3) {
|
1999 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
2000 |
+
} else if ($opened_data['member']['member_rating'] == 4) {
|
2001 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
2002 |
+
} else if ($opened_data['member']['member_rating'] == 5) {
|
2003 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span></div>';
|
2004 |
+
}
|
2005 |
+
}
|
2006 |
+
// build our table inside the loop
|
2007 |
+
echo '<tr>';
|
2008 |
+
echo '<td><a href="mailto:'.$opened_data['member']['email'].'">'.$opened_data['member']['email'].'</a></td>';
|
2009 |
+
echo '<td>'.$opened_data['opens'].'</td>';
|
2010 |
+
echo '<td>'.ucfirst(strtolower($opened_data['member']['merges']['FNAME'])).'</td>';
|
2011 |
+
echo '<td>'.ucfirst(strtolower($opened_data['member']['merges']['LNAME'])).'</td>';
|
2012 |
+
echo '<td><span style="display:none;">'.$opened_data['member']['member_rating'].'</span>'.$member_rating_stars.'</td>';
|
2013 |
+
echo '</tr>';
|
2014 |
+
}
|
2015 |
+
|
2016 |
+
} catch( Exception $e ) {
|
2017 |
+
// if there is some error, lets return it
|
2018 |
+
echo '<strong>'.$e->getMessage().'</strong>';
|
2019 |
+
// write our error to the error log,
|
2020 |
+
// when advanced debug is enabled
|
2021 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
2022 |
+
$this->writeErrorToErrorLog( $e );
|
2023 |
+
}
|
2024 |
+
}
|
2025 |
+
// always die or it will always return 1
|
2026 |
+
wp_die();
|
2027 |
+
} // end getCampaignOpenedData();
|
2028 |
+
|
2029 |
+
|
2030 |
+
// Make a call to MailChimp API to
|
2031 |
+
// get bounced email addressed for this campaign
|
2032 |
+
// used in the stats page modal
|
2033 |
+
public function getCampaignBouncedEmailData() {
|
2034 |
+
// Create and store our variables to pass to MailChimp
|
2035 |
+
$apiKey = $_POST['api_key']; // api key
|
2036 |
+
$api = new Mailchimp($apiKey);
|
2037 |
+
$campaign_id = $_POST['campaign_id'];
|
2038 |
+
// try the call, catch any errors that may be thrown
|
2039 |
+
try {
|
2040 |
+
// create our interactive data table
|
2041 |
+
// and initialize it here...
|
2042 |
+
|
2043 |
+
$campaign_bounce_stats = $api->call( '/reports/bounce-messages' , array( 'apikey' => $apiKey , 'cid' => $campaign_id , 'opts' => array( 'limit' => '100' ) ) );
|
2044 |
+
|
2045 |
+
// print_r($campaign_bounce_stats);
|
2046 |
+
|
2047 |
+
// display total unique opens
|
2048 |
+
echo '<h2 style="float:left;">' . __( 'Total Bounced Emails' , 'yikes-inc-easy-mailchimp-extender' ) . ' - ' . $campaign_bounce_stats["total"] . '</h2>';
|
2049 |
+
|
2050 |
+
// echo '<h2>' . __( 'Total Opens' 'yikes-inc-easy-mailchimp-extender' ) . $campaign_open_stats["total"] . '</h2>';
|
2051 |
+
|
2052 |
+
?>
|
2053 |
+
<!-- initialize o ur data table -->
|
2054 |
+
<script type="text/javascript">
|
2055 |
+
jQuery(document).ready(function() {
|
2056 |
+
jQuery('#yikes-mailchimp-subscribers-bounced').dataTable({
|
2057 |
+
"aaSorting": [[ 1, "desc" ]]
|
2058 |
+
});
|
2059 |
+
});
|
2060 |
+
</script>
|
2061 |
+
|
2062 |
+
<style>
|
2063 |
+
.subscriber_rating_star { font-size:15px; }
|
2064 |
+
</style>
|
2065 |
+
|
2066 |
+
<!-- build our opened user table -->
|
2067 |
+
<table id="yikes-mailchimp-subscribers-bounced" class="yks-mailchimp-fields-list" style="width:100%;">
|
2068 |
+
<thead class="yikes-mailchimp-subscribers-table-head">
|
2069 |
+
<tr>
|
2070 |
+
<th style="width:31%;"><?php _e( 'E-Mail' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
2071 |
+
<th style="width:20%;"><?php _e( 'First Name' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
2072 |
+
<th style="width:20%;"><?php _e( 'Last Name' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
2073 |
+
<th style="width:15%;"><?php _e( 'Member Rating' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
2074 |
+
</tr>
|
2075 |
+
</thead>
|
2076 |
+
<?php
|
2077 |
+
// loop over to build create and store our user variables
|
2078 |
+
// returned by mailchimp
|
2079 |
+
foreach ( $campaign_bounce_stats['data'] as $opened_data ) {
|
2080 |
+
|
2081 |
+
// checking if FNAME is set as a merge variable
|
2082 |
+
// if not, we'll just make it an empty string
|
2083 |
+
if ( isset ( $opened_data['member']['merges']['LNAME'] ) ) {
|
2084 |
+
$opened_data['member']['merges']['LNAME'] = $opened_data['member']['merges']['LNAME'];
|
2085 |
+
} else {
|
2086 |
+
$opened_data['member']['merges']['LNAME'] = '';
|
2087 |
+
}
|
2088 |
+
|
2089 |
+
// checking if LNAME is set as a merge variable
|
2090 |
+
// if not, we'll just make it an empty string
|
2091 |
+
if ( isset ( $opened_data['member']['merges']['FNAME'] ) ) {
|
2092 |
+
$opened_data['member']['merges']['FNAME'] = $opened_data['member']['merges']['FNAME'];
|
2093 |
+
} else {
|
2094 |
+
$opened_data['member']['merges']['FNAME'] = '';
|
2095 |
+
}
|
2096 |
+
|
2097 |
+
|
2098 |
+
if(isset($opened_data['member']['member_rating'])) {
|
2099 |
+
if ($opened_data['member']['member_rating'] == 1) {
|
2100 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
2101 |
+
} else if ($opened_data['member']['member_rating'] == 2) {
|
2102 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
2103 |
+
} else if ($opened_data['member']['member_rating'] == 3) {
|
2104 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
2105 |
+
} else if ($opened_data['member']['member_rating'] == 4) {
|
2106 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
2107 |
+
} else if ($opened_data['member']['member_rating'] == 5) {
|
2108 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span></div>';
|
2109 |
+
}
|
2110 |
+
}
|
2111 |
+
// build our table inside the loop
|
2112 |
+
echo '<tr>';
|
2113 |
+
echo '<td><a href="mailto:'.$opened_data['member']['email'].'">'.$opened_data['member']['email'].'</a></td>';
|
2114 |
+
echo '<td>'.ucfirst(strtolower($opened_data['member']['merges']['FNAME'])).'</td>';
|
2115 |
+
echo '<td>'.ucfirst(strtolower($opened_data['member']['merges']['LNAME'])).'</td>';
|
2116 |
+
echo '<td><span style="display:none;">'.$opened_data['member']['member_rating'].'</span>'.$member_rating_stars.'</td>';
|
2117 |
+
echo '</tr>';
|
2118 |
+
}
|
2119 |
+
|
2120 |
+
// print_r($campaign_open_stats);
|
2121 |
+
|
2122 |
+
} catch( Exception $e ) {
|
2123 |
+
// if there is some error, lets return it
|
2124 |
+
echo '<strong>'.$e->getMessage().'</strong>';
|
2125 |
+
// write our error to the error log,
|
2126 |
+
// when advanced debug is enabled
|
2127 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
2128 |
+
$this->writeErrorToErrorLog( $e );
|
2129 |
+
}
|
2130 |
+
}
|
2131 |
+
// always die or it will always return 1
|
2132 |
+
wp_die();
|
2133 |
+
} // end getCampaignBouncedEmailData();
|
2134 |
+
|
2135 |
+
|
2136 |
+
// Make a call to MailChimp API to
|
2137 |
+
// get unsubscribed email addressed for this campaign
|
2138 |
+
// used in the stats page modal
|
2139 |
+
public function getCampaignUnsubscribeData() {
|
2140 |
+
// Create and store our variables to pass to MailChimp
|
2141 |
+
$apiKey = $_POST['api_key']; // api key
|
2142 |
+
$api = new Mailchimp($apiKey);
|
2143 |
+
$campaign_id = $_POST['campaign_id'];
|
2144 |
+
// try the call, catch any errors that may be thrown
|
2145 |
+
try {
|
2146 |
+
// create our interactive data table
|
2147 |
+
// and initialize it here...
|
2148 |
+
|
2149 |
+
$campaign_unsubscribe_stats = $api->call( '/reports/unsubscribes' , array( 'apikey' => $apiKey , 'cid' => $campaign_id , 'opts' => array( 'limit' => '100' ) ) );
|
2150 |
+
|
2151 |
+
// print_r($campaign_bounce_stats);
|
2152 |
+
|
2153 |
+
// display total unique opens
|
2154 |
+
echo '<h2 style="float:left;">' . __( 'Total Unsubscribes' , 'yikes-inc-easy-mailchimp-extender' ) . ' - ' . $campaign_unsubscribe_stats["total"] . '</h2>';
|
2155 |
+
|
2156 |
+
// echo '<h2>' . __( 'Total Opens' 'yikes-inc-easy-mailchimp-extender' ) . $campaign_open_stats["total"] . '</h2>';
|
2157 |
+
|
2158 |
+
?>
|
2159 |
+
<!-- initialize o ur data table -->
|
2160 |
+
<script type="text/javascript">
|
2161 |
+
jQuery(document).ready(function() {
|
2162 |
+
jQuery('#yikes-mailchimp-unsubscribe-table').dataTable({
|
2163 |
+
"aaSorting": [[ 0, "desc" ]]
|
2164 |
+
});
|
2165 |
+
});
|
2166 |
+
</script>
|
2167 |
+
|
2168 |
+
<style>
|
2169 |
+
.subscriber_rating_star { font-size:15px; }
|
2170 |
+
</style>
|
2171 |
+
|
2172 |
+
<!-- build our opened user table -->
|
2173 |
+
<table id="yikes-mailchimp-unsubscribe-table" class="yks-mailchimp-fields-list" style="width:100%;">
|
2174 |
+
<thead class="yikes-mailchimp-subscribers-table-head">
|
2175 |
+
<tr>
|
2176 |
+
<th style="width:31%;"><?php _e( 'E-Mail' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
2177 |
+
<th style="width:20%;"><?php _e( 'First Name' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
2178 |
+
<th style="width:20%;"><?php _e( 'Last Name' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
2179 |
+
<th style="width:15%;"><?php _e( 'Member Rating' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
2180 |
+
<th style="width:15%;"><?php _e( 'Reason' , 'yikes-inc-easy-mailchimp-extender' ); ?></th>
|
2181 |
+
</tr>
|
2182 |
+
</thead>
|
2183 |
+
<?php
|
2184 |
+
// loop over to build create and store our user variables
|
2185 |
+
// returned by mailchimp
|
2186 |
+
foreach ( $campaign_unsubscribe_stats['data'] as $opened_data ) {
|
2187 |
+
|
2188 |
+
// checking if FNAME is set as a merge variable
|
2189 |
+
// if not, we'll just make it an empty string
|
2190 |
+
if ( isset ( $opened_data['member']['merges']['LNAME'] ) ) {
|
2191 |
+
$opened_data['member']['merges']['LNAME'] = $opened_data['member']['merges']['LNAME'];
|
2192 |
+
} else {
|
2193 |
+
$opened_data['member']['merges']['LNAME'] = '';
|
2194 |
+
}
|
2195 |
+
|
2196 |
+
// checking if LNAME is set as a merge variable
|
2197 |
+
// if not, we'll just make it an empty string
|
2198 |
+
if ( isset ( $opened_data['member']['merges']['FNAME'] ) ) {
|
2199 |
+
$opened_data['member']['merges']['FNAME'] = $opened_data['member']['merges']['FNAME'];
|
2200 |
+
} else {
|
2201 |
+
$opened_data['member']['merges']['FNAME'] = '';
|
2202 |
+
}
|
2203 |
+
|
2204 |
+
|
2205 |
+
if(isset($opened_data['member']['member_rating'])) {
|
2206 |
+
if ($opened_data['member']['member_rating'] == 1) {
|
2207 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
2208 |
+
} else if ($opened_data['member']['member_rating'] == 2) {
|
2209 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
2210 |
+
} else if ($opened_data['member']['member_rating'] == 3) {
|
2211 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
2212 |
+
} else if ($opened_data['member']['member_rating'] == 4) {
|
2213 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-empty"></span></div>';
|
2214 |
+
} else if ($opened_data['member']['member_rating'] == 5) {
|
2215 |
+
$member_rating_stars = '<div class="yks-mc-subscriber-rating"><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span><span class="subscriber_rating_star dashicons dashicons-star-filled"></span></div>';
|
2216 |
+
}
|
2217 |
+
}
|
2218 |
+
// build our table inside the loop
|
2219 |
+
echo '<tr>';
|
2220 |
+
echo '<td><a href="mailto:'.$opened_data['member']['email'].'">'.$opened_data['member']['email'].'</a></td>';
|
2221 |
+
echo '<td>'.ucfirst(strtolower($opened_data['member']['merges']['FNAME'])).'</td>';
|
2222 |
+
echo '<td>'.ucfirst(strtolower($opened_data['member']['merges']['LNAME'])).'</td>';
|
2223 |
+
echo '<td><span style="display:none;">'.$opened_data['member']['member_rating'].'</span>'.$member_rating_stars.'</td>';
|
2224 |
+
echo '<td>'.strtolower($opened_data['reason']).'</td>';
|
2225 |
+
echo '</tr>';
|
2226 |
+
}
|
2227 |
+
|
2228 |
+
} catch( Exception $e ) {
|
2229 |
+
// if there is some error, lets return it
|
2230 |
+
echo '<strong>'.$e->getMessage().'</strong>';
|
2231 |
+
// write our error to the error log,
|
2232 |
+
// when advanced debug is enabled
|
2233 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
2234 |
+
$this->writeErrorToErrorLog( $e );
|
2235 |
+
}
|
2236 |
+
}
|
2237 |
+
// always die or it will always return 1
|
2238 |
+
wp_die();
|
2239 |
+
} // end getCampaignUnsubscribeData();
|
2240 |
+
|
2241 |
+
|
2242 |
+
// Make a call to MailChimp API to add a new subscriber to a specified list
|
2243 |
+
// Runs when a user fills out the form on the frontend of the site
|
2244 |
+
public function addUserToMailchimp( $p , $update_existing ) {
|
2245 |
+
|
2246 |
+
if( !empty( $p['form_data'] ) ) {
|
2247 |
+
|
2248 |
+
parse_str($p['form_data'], $fd);
|
2249 |
+
|
2250 |
+
// grab and store our nonce field
|
2251 |
+
// for security purposes
|
2252 |
+
$yks_mc_form_submission_nonce = $fd['_wpnonce'];
|
2253 |
+
|
2254 |
+
// cross check our nonce
|
2255 |
+
// passing in the action used when we created the nonce field
|
2256 |
+
// if the nonce does not match, we need to die()
|
2257 |
+
if ( !wp_verify_nonce( $yks_mc_form_submission_nonce , 'yks_mc_front_end_form_'.$fd['yks-mailchimp-list-id'] ) ) {
|
2258 |
+
die( __( 'Failed nonce security check. Please reload the page and submit this form again.' , 'yikes-inc-easy-mailchimp-extender' ) );
|
2259 |
+
}
|
2260 |
+
|
2261 |
+
|
2262 |
+
if( !empty( $fd['yks-mailchimp-list-id'] ) ) {
|
2263 |
+
|
2264 |
+
// if reCAPTCHA is enabled
|
2265 |
+
if ( $this->optionVal['recaptcha-setting'] == '1' ) {
|
2266 |
+
|
2267 |
+
if ( isset( $fd['g-recaptcha-response'] ) && $fd['g-recaptcha-response'] == '' ) {
|
2268 |
+
die( __( 'Please check off that you are not a robot.' , 'yikes-inc-easy-mailchimp-extender' ) );
|
2269 |
+
}
|
2270 |
+
|
2271 |
+
$privatekey = $this->optionVal['recaptcha-private-api-key'];
|
2272 |
+
$response = $fd['g-recaptcha-response'];
|
2273 |
+
|
2274 |
+
// if the CAPTCHA was entered properly
|
2275 |
+
if ( $fd['g-recaptcha-response'] == '' ) {
|
2276 |
+
// if the response returns invalid,
|
2277 |
+
// lets add the animated shake and error fields
|
2278 |
+
// to the captcha fields
|
2279 |
+
?>
|
2280 |
+
<script>
|
2281 |
+
jQuery(document).ready(function() {
|
2282 |
+
jQuery('.g-recaptcha').addClass('yks_error_field_required shake animated').delay(800).queue(function(next){
|
2283 |
+
jQuery(this).removeClass('shake animated');
|
2284 |
+
next();
|
2285 |
+
});
|
2286 |
+
});
|
2287 |
+
</script>
|
2288 |
+
<?php
|
2289 |
+
|
2290 |
+
// if it returns valid...
|
2291 |
+
// continue sending data to MailChimp
|
2292 |
+
} else {
|
2293 |
+
|
2294 |
+
// Create and store the variables needed to add a new subscriber
|
2295 |
+
$email = false;
|
2296 |
+
$lid = $fd['yks-mailchimp-list-id'];
|
2297 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
2298 |
+
$mv = array();
|
2299 |
+
$optin = $this->optionVal['optin'];
|
2300 |
+
|
2301 |
+
foreach($this->optionVal['lists'][$lid]['fields'] as $field) : if($field['active'] == '1') :
|
2302 |
+
|
2303 |
+
// Check to see if the field is in the post
|
2304 |
+
if(isset($fd[$field['name']])) :
|
2305 |
+
|
2306 |
+
// Grab the primary email
|
2307 |
+
if(strtolower($field['merge']) == 'email')
|
2308 |
+
$email = $fd[$field['name']];
|
2309 |
+
|
2310 |
+
// It exists, set the merge var that we send to mailchimp
|
2311 |
+
switch($field['type'])
|
2312 |
+
{
|
2313 |
+
default:
|
2314 |
+
$mv[$field['merge']] = $fd[$field['name']];
|
2315 |
+
break;
|
2316 |
+
|
2317 |
+
case 'address':
|
2318 |
+
$mv[$field['merge']] = array(
|
2319 |
+
'addr1' => $fd[$field['name']],
|
2320 |
+
'addr2' => $fd[$field['name'].'-add2'],
|
2321 |
+
'city' => $fd[$field['name'].'-city'],
|
2322 |
+
'state' => $fd[$field['name'].'-state'],
|
2323 |
+
'zip' => $fd[$field['name'].'-zip'],
|
2324 |
+
'country' => 'US'
|
2325 |
+
);
|
2326 |
+
break;
|
2327 |
+
|
2328 |
+
}
|
2329 |
+
|
2330 |
+
|
2331 |
+
|
2332 |
+
endif;
|
2333 |
+
endif; endforeach;
|
2334 |
+
|
2335 |
+
// Interest group loop to build the GROUPINGS array
|
2336 |
+
// The GROUPINGS array passes our interest group, and values back to the specific form
|
2337 |
+
if ( isset($fd['interest-group-data']) ) {
|
2338 |
+
$interest_group_option = json_decode($fd['interest-group-data'], true);
|
2339 |
+
}
|
2340 |
+
// if interest groups exist, continue and form an array
|
2341 |
+
if ( isset($interest_group_option) ) {
|
2342 |
+
|
2343 |
+
// print_r($interest_group_option);
|
2344 |
+
$mv['GROUPINGS'] = array();
|
2345 |
+
|
2346 |
+
// loop over each interest group
|
2347 |
+
foreach ($interest_group_option as $group ) :
|
2348 |
+
|
2349 |
+
switch($group['form_field'])
|
2350 |
+
{
|
2351 |
+
case 'radio':
|
2352 |
+
case 'dropdown':
|
2353 |
+
array_push($mv['GROUPINGS'], array(
|
2354 |
+
'id' => $group['id'],
|
2355 |
+
// 'groups' => array($fd['interest-group'])
|
2356 |
+
'groups' => array(isset($fd[$group['form_field'].'-'.$group['id']]) ? $fd[$group['form_field'].'-'.$group['id']] : '')
|
2357 |
+
)
|
2358 |
+
);
|
2359 |
+
break;
|
2360 |
+
|
2361 |
+
case 'checkboxes':
|
2362 |
+
array_push($mv['GROUPINGS'], array(
|
2363 |
+
'id' => $group['id'],
|
2364 |
+
// 'groups' => array($fd['interest-group'])
|
2365 |
+
'groups' => (isset($fd[$group['form_field'].'-'.$group['id']]) ? $fd[$group['form_field'].'-'.$group['id']] : '')
|
2366 |
+
// $fd[$group['form_field'].'-'.$group['id']]
|
2367 |
+
|
2368 |
+
)
|
2369 |
+
);
|
2370 |
+
break;
|
2371 |
+
}
|
2372 |
+
endforeach; // end loop
|
2373 |
+
|
2374 |
+
}
|
2375 |
+
|
2376 |
+
// If no email provided, fail
|
2377 |
+
$noemail = "The email address is blank";
|
2378 |
+
if($email === false) return $noemail;
|
2379 |
+
|
2380 |
+
// Add custom filter here, to capture user submitted
|
2381 |
+
// data before it's sent off to MailChimp
|
2382 |
+
$form_data = apply_filters( 'yikes_mc_get_form_data' , $mv );
|
2383 |
+
|
2384 |
+
$form_data = apply_filters( 'yikes_mc_get_form_data_'.$lid, $mv );
|
2385 |
+
|
2386 |
+
// setup our welcome email variable
|
2387 |
+
if( isset( $this->optionVal['lists'][$lid]['fields'][$lid.'-email']['yks_mailchimp_send_welcome_'.$lid] ) && $this->optionVal['lists'][$lid]['fields'][$lid.'-email']['yks_mailchimp_send_welcome_'.$lid] == '1' ) {
|
2388 |
+
$welcome = false;
|
2389 |
+
} else {
|
2390 |
+
$welcome = true;
|
2391 |
+
}
|
2392 |
+
|
2393 |
+
// try adding subscriber, catch any error thrown
|
2394 |
+
try {
|
2395 |
+
$retval = $api->call('lists/subscribe', array(
|
2396 |
+
'id' => $lid, // form id
|
2397 |
+
'email' => array( 'email' => $email ), // user email
|
2398 |
+
'merge_vars' => $form_data, // merge variables (ie: fields and interest groups)
|
2399 |
+
'double_optin' => $optin, // double optin value (retreived from the settings page)
|
2400 |
+
'send_welcome' => $welcome,
|
2401 |
+
'update_existing' => $update_existing
|
2402 |
+
));
|
2403 |
+
return "done";
|
2404 |
+
} catch( Exception $e ) { // catch any errors returned from MailChimp
|
2405 |
+
$errorCode = $e->getCode();
|
2406 |
+
if ( $errorCode = '214' ) {
|
2407 |
+
$errorMessage = $e->getMessage();
|
2408 |
+
return json_encode( array( 'errorCode' => $errorCode , 'errorResponse' => apply_filters( 'yikes_mc_user_already_subscribed' , $errorMessage , $email ) ) );
|
2409 |
+
die();
|
2410 |
+
} else {
|
2411 |
+
echo '<strong>'.$e->getMessage().'</strong>';
|
2412 |
+
die();
|
2413 |
+
}
|
2414 |
+
}
|
2415 |
+
}
|
2416 |
+
|
2417 |
+
// if reCAPTCHA is not active, we will just send the request
|
2418 |
+
// without further verification
|
2419 |
+
} else {
|
2420 |
+
|
2421 |
+
// Create and store the variables needed to add a new subscriber
|
2422 |
+
$email = false;
|
2423 |
+
$lid = $fd['yks-mailchimp-list-id'];
|
2424 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
2425 |
+
$mv = array();
|
2426 |
+
$optin = $this->optionVal['optin'];
|
2427 |
+
|
2428 |
+
foreach($this->optionVal['lists'][$lid]['fields'] as $field) : if($field['active'] == '1') :
|
2429 |
+
|
2430 |
+
// Check to see if the field is in the post
|
2431 |
+
if(isset($fd[$field['name']])) :
|
2432 |
+
|
2433 |
+
// Grab the primary email
|
2434 |
+
if(strtolower($field['merge']) == 'email')
|
2435 |
+
$email = $fd[$field['name']];
|
2436 |
+
|
2437 |
+
// It exists, set the merge var that we send to mailchimp
|
2438 |
+
switch($field['type'])
|
2439 |
+
{
|
2440 |
+
default:
|
2441 |
+
$mv[$field['merge']] = $fd[$field['name']];
|
2442 |
+
break;
|
2443 |
+
|
2444 |
+
case 'address':
|
2445 |
+
$mv[$field['merge']] = array(
|
2446 |
+
'addr1' => $fd[$field['name']],
|
2447 |
+
'addr2' => $fd[$field['name'].'-add2'],
|
2448 |
+
'city' => $fd[$field['name'].'-city'],
|
2449 |
+
'state' => $fd[$field['name'].'-state'],
|
2450 |
+
'zip' => $fd[$field['name'].'-zip'],
|
2451 |
+
'country' => 'US'
|
2452 |
+
);
|
2453 |
+
break;
|
2454 |
+
|
2455 |
+
}
|
2456 |
+
|
2457 |
+
|
2458 |
+
|
2459 |
+
endif;
|
2460 |
+
endif; endforeach;
|
2461 |
+
|
2462 |
+
// Interest group loop to build the GROUPINGS array
|
2463 |
+
// The GROUPINGS array passes our interest group, and values back to the specific form
|
2464 |
+
if ( isset($fd['interest-group-data']) ) {
|
2465 |
+
$interest_group_option = json_decode($fd['interest-group-data'], true);
|
2466 |
+
}
|
2467 |
+
// if interest groups exist, continue and form an array
|
2468 |
+
if ( isset($interest_group_option) ) {
|
2469 |
+
|
2470 |
+
// print_r($interest_group_option);
|
2471 |
+
$mv['GROUPINGS'] = array();
|
2472 |
+
|
2473 |
+
// loop over each interest group
|
2474 |
+
foreach ($interest_group_option as $group ) :
|
2475 |
+
|
2476 |
+
switch($group['form_field'])
|
2477 |
+
{
|
2478 |
+
case 'radio':
|
2479 |
+
case 'dropdown':
|
2480 |
+
array_push($mv['GROUPINGS'], array(
|
2481 |
+
'id' => $group['id'],
|
2482 |
+
// 'groups' => array($fd['interest-group'])
|
2483 |
+
'groups' => array(isset($fd[$group['form_field'].'-'.$group['id']]) ? $fd[$group['form_field'].'-'.$group['id']] : '')
|
2484 |
+
)
|
2485 |
+
);
|
2486 |
+
break;
|
2487 |
+
|
2488 |
+
case 'checkboxes':
|
2489 |
+
array_push($mv['GROUPINGS'], array(
|
2490 |
+
'id' => $group['id'],
|
2491 |
+
// 'groups' => array($fd['interest-group'])
|
2492 |
+
'groups' => (isset($fd[$group['form_field'].'-'.$group['id']]) ? $fd[$group['form_field'].'-'.$group['id']] : '')
|
2493 |
+
// $fd[$group['form_field'].'-'.$group['id']]
|
2494 |
+
|
2495 |
+
)
|
2496 |
+
);
|
2497 |
+
break;
|
2498 |
+
}
|
2499 |
+
endforeach; // end loop
|
2500 |
+
|
2501 |
+
}
|
2502 |
+
|
2503 |
+
// If no email provided, fail
|
2504 |
+
$noemail = "The email address is blank";
|
2505 |
+
if($email === false) return $noemail;
|
2506 |
+
|
2507 |
+
// Add custom filter here, to capture user submitted
|
2508 |
+
// data before it's sent off to MailChimp
|
2509 |
+
$form_data = apply_filters( 'yikes_mc_get_form_data' , $mv );
|
2510 |
+
$specific_form_data = apply_filters( 'yikes_mc_get_form_data_'.$lid, $lid, $mv );
|
2511 |
+
|
2512 |
+
// setup our welcome email variable
|
2513 |
+
if( isset( $this->optionVal['lists'][$lid]['fields'][$lid.'-email']['yks_mailchimp_send_welcome_'.$lid] ) && $this->optionVal['lists'][$lid]['fields'][$lid.'-email']['yks_mailchimp_send_welcome_'.$lid] == '1' ) {
|
2514 |
+
$welcome = false;
|
2515 |
+
} else {
|
2516 |
+
$welcome = true;
|
2517 |
+
}
|
2518 |
+
|
2519 |
+
// try adding subscriber, catch any error thrown
|
2520 |
+
try {
|
2521 |
+
$retval = $api->call('lists/subscribe', array(
|
2522 |
+
'id' => $lid, // form id
|
2523 |
+
'email' => array( 'email' => $email ), // user email
|
2524 |
+
'merge_vars' => $form_data, // merge variables (ie: fields and interest groups)
|
2525 |
+
'double_optin' => $optin, // double optin value (retreived from the settings page)
|
2526 |
+
'send_welcome' => $welcome,
|
2527 |
+
'update_existing' => $update_existing
|
2528 |
+
));
|
2529 |
+
return "done";
|
2530 |
+
} catch( Exception $e ) { // catch any errors returned from MailChimp
|
2531 |
+
$errorCode = $e->getCode();
|
2532 |
+
if ( $errorCode = '214' ) {
|
2533 |
+
$errorMessage = $e->getMessage();
|
2534 |
+
return json_encode( array( 'errorCode' => $errorCode , 'errorResponse' => apply_filters( 'yikes_mc_user_already_subscribed' , $errorMessage , $email ) ) );
|
2535 |
+
die();
|
2536 |
+
} else {
|
2537 |
+
echo '<strong>'.$e->getMessage().'</strong>';
|
2538 |
+
die();
|
2539 |
+
}
|
2540 |
+
}
|
2541 |
+
}
|
2542 |
+
|
2543 |
+
}
|
2544 |
+
} else {
|
2545 |
+
return __('One or more fields are empty','yikes-inc-easy-mailchimp-extender'); // return an error if your leaving any necessary fields empty
|
2546 |
+
}
|
2547 |
+
} // end addUserToMailchimp();
|
2548 |
+
|
2549 |
+
|
2550 |
+
// Generate the lists containers on the lists page
|
2551 |
+
// This function gets any imported lists, and builds up the lists page
|
2552 |
+
public function generateListContainers($listArr=false) {
|
2553 |
+
$listArr = ($listArr == false ? $this->optionVal['lists'] : $listArr);
|
2554 |
+
$thelistdata = $this->getListsData(); //Get list names from API
|
2555 |
+
// if there are any imported lists in the array
|
2556 |
+
if( count( $listArr ) > 0) {
|
2557 |
+
include YKSEME_PATH . 'lib/inc/yks-mc-manage-list-form-table.php';
|
2558 |
+
}
|
2559 |
+
$output = ob_get_contents();
|
2560 |
+
ob_end_clean();
|
2561 |
+
return $output;
|
2562 |
+
} // end generateListContainers();
|
2563 |
+
|
2564 |
+
|
2565 |
+
// Generate the Merge Variable containers on the lists page
|
2566 |
+
// we use this function to re-import merge variables from mailchimp
|
2567 |
+
public function generateMergeVariableContainers($listArr=false) {
|
2568 |
+
$listArr = ($listArr == false ? $this->optionVal['lists'] : $listArr);
|
2569 |
+
$thelistdata = $this->getListsData(); //Get list names from API
|
2570 |
+
// if there are any imported lists in the array
|
2571 |
+
if(count($listArr) > 0) {
|
2572 |
+
ob_start();
|
2573 |
+
// loop over each lists and build the page
|
2574 |
+
$i = 1;
|
2575 |
+
foreach($listArr as $list) {
|
2576 |
+
$get_list_data = $this->getListsData();
|
2577 |
+
?>
|
2578 |
+
<td class="yks-mailchimp-fields-td" id="yks-mailchimp-fields-td_<?php echo $list['id']; ?>">
|
2579 |
+
<fieldset class="yks-mailchimp-fields-container" id="yks-mailchimp-fields-container_<?php echo $list['id']; ?>">
|
2580 |
+
<legend class="screen-reader-text"><span><?php _e( 'Active Fields' , 'yikes-inc-easy-mailchimp-extender' ); ?></span></legend>
|
2581 |
+
<div class="yks-mailchimp-fields-list" id="yks-mailchimp-fields-list_<?php echo $list['id']; ?>" rel="<?php echo $list['id']; ?>">
|
2582 |
+
<!-- create sortable rows populated with mailchimp data -->
|
2583 |
+
<?php
|
2584 |
+
$num = 1;
|
2585 |
+
foreach($list['fields'] as $field) { ?>
|
2586 |
+
<div class="yks-mailchimp-fields-list-row" alt="<?php echo $field['merge']; ?>" rel="<?php echo $field['id']; ?>">
|
2587 |
+
<!-- update labels on initial creation as well! to do-->
|
2588 |
+
<label title="Delete <?php echo $field['label']; ?> Field">
|
2589 |
+
<span class="yks-mc-delete-merge-var"><span class="dashicons dashicons-no-alt"></span></span>
|
2590 |
+
</label>
|
2591 |
+
<label title="Edit <?php echo $field['label']; ?> Field">
|
2592 |
+
<span class="yks-mc-merge-var-change"><span class="dashicons dashicons-edit"></span></span>
|
2593 |
+
</label>
|
2594 |
+
<label title="Reorder <?php echo $field['label']; ?>">
|
2595 |
+
<span class="yks-mailchimp-sorthandle"><?php _e( 'Drag' , 'yikes-inc-easy-mailchimp-extender' ); ?> & <?php _e( 'drop' , 'yikes-inc-easy-mailchimp-extender' ); ?></span>
|
2596 |
+
</label>
|
2597 |
+
<label title="Toggle Visibility of <?php echo $field['label']; ?>">
|
2598 |
+
<input type="checkbox" name="<?php echo $field['name']; ?>" id="<?php echo $field['id']; ?>" value="1" <?php echo ($field['active'] == 1 ? 'checked="checked"' : ''); ?><?php echo ($field['require'] == 1 ? 'disabled="disabled"' : ''); ?> />
|
2599 |
+
</label>
|
2600 |
+
|
2601 |
+
<label>
|
2602 |
+
<div class="yks-mailchimp-field-name"><?php echo $field['label']; ?></div>
|
2603 |
+
</label>
|
2604 |
+
|
2605 |
+
<!-- <span class="yks-mailchimp-field-merge"><span class="description"><?php _e( 'Merge field' , 'yikes-inc-easy-mailchimp-extender' ); ?>:</span> <input type="text" class="merge_field_input" name="<?php echo $field['name']; ?>-merge" id="<?php echo $field['id']; ?>-merge" value="<?php echo $field['merge']; ?>"<?php echo (($field['locked'] == 1 || $field['merge'] == false) ? ' disabled="disabled"' : ''); ?> /></span> -->
|
2606 |
+
<span class="yks-mailchimp-field-placeholder"><span class="description"><?php _e( 'Placeholder' , 'yikes-inc-easy-mailchimp-extender' ); ?>:</span> <input type="text" class="custom-placeholder-field" name="placeholder-<?php echo $list['id'].'-'.$num; ?>" id="<?php echo $field['id']; ?>-placeholder" placeholder="<?php echo $field['label']; ?>" value="<?php if(isset($field['placeholder-'.$list['id'].'-'.$num])) { echo $field['placeholder-'.$list['id'].'-'.$num]; } ?>" /></span>
|
2607 |
+
<span class="yks-mailchimp-field-custom-field-class"><span class="description"><?php _e( 'Custom Class' , 'yikes-inc-easy-mailchimp-extender' ); ?>:</span> <input type="text" name="custom-field-class-<?php echo $list['id'].'-'.$num; ?>" id="<?php echo $field['id']; ?>-custom-field-class" value="<?php if(isset($field['custom-field-class-'.$list['id'].'-'.$num])) { echo $field['custom-field-class-'.$list['id'].'-'.$num]; } ?>" /></span>
|
2608 |
+
</div>
|
2609 |
+
<?php
|
2610 |
+
$num++;
|
2611 |
+
} ?>
|
2612 |
+
</div>
|
2613 |
+
</fieldset>
|
2614 |
+
</td>
|
2615 |
+
<?php
|
2616 |
+
$i++;
|
2617 |
+
}
|
2618 |
+
}
|
2619 |
+
$output = ob_get_contents();
|
2620 |
+
ob_end_clean();
|
2621 |
+
return $output;
|
2622 |
+
} // end generateMergeVariableContainers();
|
2623 |
+
|
2624 |
+
// Get list data
|
2625 |
+
public function getListDataRightMeow() {
|
2626 |
+
echo json_encode( $this->optionVal['lists'] );
|
2627 |
+
} // end getListDataRightMeow();
|
2628 |
+
|
2629 |
+
// Generate our front end JavaScript , used to submit forms
|
2630 |
+
public function getFrontendFormJavascript($list='') {
|
2631 |
+
if($list === '') return false;
|
2632 |
+
$js = false;
|
2633 |
+
foreach($list['fields'] as $field) : if($field['active'] == 1) :
|
2634 |
+
// Setup JavaScript
|
2635 |
+
if($field['require'] == '1') :
|
2636 |
+
$prefix = "ymce";
|
2637 |
+
$js .= "\n";
|
2638 |
+
switch($field['type']) {
|
2639 |
+
|
2640 |
+
// default
|
2641 |
+
default:
|
2642 |
+
$prefixa = "ymce";
|
2643 |
+
$js .= "if ($".$prefixa."('#".$field['id']."').val() == '')";
|
2644 |
+
$js .= "{
|
2645 |
+
msg += '<li>".$field['label']."'+'\\n</li>';
|
2646 |
+
err++;
|
2647 |
+
$".$prefixa."('#".$field['id']."').addClass('yks_error_field_required shake animated').delay(1200).queue(function(next){
|
2648 |
+
$".$prefixa."(this).removeClass('shake animated');
|
2649 |
+
next();
|
2650 |
+
});
|
2651 |
+
} else {
|
2652 |
+
$".$prefixa."('#".$field['id']."').removeClass('yks_error_field_required');
|
2653 |
+
}";
|
2654 |
+
break;
|
2655 |
+
|
2656 |
+
// address
|
2657 |
+
case 'address':
|
2658 |
+
$js .= "if($".$prefix."('#".$field['id']."').val() == '') {
|
2659 |
+
msg += '<li>Street Address'+'\\n</li>';
|
2660 |
+
err++;
|
2661 |
+
$".$prefixa."('#".$field['id']."').addClass('yks_error_field_required shake animated').delay(800).queue(function(next){
|
2662 |
+
$".$prefixa."(this).removeClass('shake animated');
|
2663 |
+
next();
|
2664 |
+
});
|
2665 |
+
} else {
|
2666 |
+
$".$prefixa."('#".$field['id']."').removeClass('yks_error_field_required')
|
2667 |
+
}
|
2668 |
+
|
2669 |
+
if($".$prefix."('#".$field['id']."-city').val() == '') {
|
2670 |
+
msg += '<li>City'+'\\n</li>';
|
2671 |
+
err++;
|
2672 |
+
$".$prefixa."('#".$field['id']."-city').addClass('yks_error_field_required shake animated').delay(800).queue(function(next){
|
2673 |
+
$".$prefixa."(this).removeClass('shake animated');
|
2674 |
+
next();
|
2675 |
+
});
|
2676 |
+
} else {
|
2677 |
+
$".$prefixa."('#".$field['id']."-city').removeClass('yks_error_field_required')
|
2678 |
+
}
|
2679 |
+
if($".$prefix."('#".$field['id']."-state').val() == '') {
|
2680 |
+
msg += '<li>State'+'\\n</li>';
|
2681 |
+
err++;
|
2682 |
+
$".$prefixa."('#".$field['id']."-state').addClass('yks_error_field_required shake animated').delay(800).queue(function(next){
|
2683 |
+
$".$prefixa."(this).removeClass('shake animated');
|
2684 |
+
next();
|
2685 |
+
});
|
2686 |
+
} else {
|
2687 |
+
$".$prefixa."('#".$field['id']."-state').removeClass('yks_error_field_required')
|
2688 |
+
}
|
2689 |
+
if($".$prefix."('#".$field['id']."-zip').val() == '') {
|
2690 |
+
msg += '<li>Zip Code'+'\\n</li>';
|
2691 |
+
err++;
|
2692 |
+
$".$prefixa."('#".$field['id']."-zip').addClass('yks_error_field_required shake animated').delay(800).queue(function(next){
|
2693 |
+
$".$prefixa."(this).removeClass('shake animated');
|
2694 |
+
next();
|
2695 |
+
});
|
2696 |
+
} else {
|
2697 |
+
$".$prefixa."('#".$field['id']."-zip').removeClass('yks_error_field_required')
|
2698 |
+
}";
|
2699 |
+
break;
|
2700 |
+
|
2701 |
+
// radio
|
2702 |
+
case 'radio':
|
2703 |
+
$js .= "if($".$prefix."('.".$field['name'].":checked').length <= 0) {
|
2704 |
+
msg += '<li>".$field['label']."\\n</li>';
|
2705 |
+
err++;
|
2706 |
+
$".$prefixa."('label[for=".$field['id']."]').next().find('input').addClass('yks_error_field_required shake animated').delay(800).queue(function(next){
|
2707 |
+
$".$prefixa."(this).removeClass('shake animated');
|
2708 |
+
next();
|
2709 |
+
});
|
2710 |
+
} else {
|
2711 |
+
$".$prefixa."('#".$field['id']."').removeClass('yks_error_field_required')
|
2712 |
+
}";
|
2713 |
+
break;
|
2714 |
+
}
|
2715 |
+
|
2716 |
+
$js .= "\n";
|
2717 |
+
endif;
|
2718 |
+
endif; endforeach;
|
2719 |
+
return $js;
|
2720 |
+
} // end getFrontendFormJavascript();
|
2721 |
+
|
2722 |
+
// Generate the form on the front end of the site
|
2723 |
+
// this is what the user will see, and interact with
|
2724 |
+
public function getFrontendFormDisplay($list='', $submit_text) {
|
2725 |
+
if($list === '') return false;
|
2726 |
+
ob_start();
|
2727 |
+
include YKSEME_PATH . 'lib/inc/yks-mc-frontend-form-display.php';
|
2728 |
+
$output = ob_get_contents();
|
2729 |
+
ob_end_clean();
|
2730 |
+
return $output;
|
2731 |
+
}
|
2732 |
+
|
2733 |
+
// Generate the input fields for the form on the front end of the site
|
2734 |
+
// based on the $field['type'] that is returned from MailChimp
|
2735 |
+
private function getFrontendFormDisplay_field( $field = false , $num ) {
|
2736 |
+
if($field === false) return false;
|
2737 |
+
$o = '';
|
2738 |
+
$fieldID = $field['id'];
|
2739 |
+
$exploded_field_id = explode( '-' , $fieldID );
|
2740 |
+
$form_id = $exploded_field_id[1];
|
2741 |
+
// print_r($field);
|
2742 |
+
|
2743 |
+
$class_title = 'yks-mc-input-' . sanitize_title( $field['label'] );
|
2744 |
+
|
2745 |
+
// check to see if the custom class has been set up...
|
2746 |
+
if ( isset( $field['custom-field-class-'.$form_id.'-'.$num] ) ) {
|
2747 |
+
$custom_class = $field['custom-field-class-'.$form_id.'-'.$num];
|
2748 |
+
} else {
|
2749 |
+
$custom_class = '';
|
2750 |
+
}
|
2751 |
+
|
2752 |
+
// check to see if the placeholder value has been stored
|
2753 |
+
// setup the placeholder field
|
2754 |
+
if ( isset( $field['placeholder-'.$form_id.'-'.$num] ) ) {
|
2755 |
+
$placeholder = $field['placeholder-'.$form_id.'-'.$num];
|
2756 |
+
} else {
|
2757 |
+
$placeholder = '';
|
2758 |
+
}
|
2759 |
+
|
2760 |
+
switch( $field['type'] ) {
|
2761 |
+
default:
|
2762 |
+
case 'email':
|
2763 |
+
case 'number':
|
2764 |
+
case 'zipcode':
|
2765 |
+
case 'phone':
|
2766 |
+
case 'website':
|
2767 |
+
case 'imageurl':
|
2768 |
+
// custom placeholder value goes here
|
2769 |
+
$o .= '<input type="text" name="'.$field['name'].'" placeholder="'.$placeholder.'" class="'.$field['name'].($field['require'] == 1 ? ' yks-require' : '') . ' ' . $custom_class . ' ' . $class_title .'" id="'.$field['id'].'" value="" />';
|
2770 |
+
break;
|
2771 |
+
|
2772 |
+
case 'text':
|
2773 |
+
if ( $field['default'] ) {
|
2774 |
+
|
2775 |
+
$custom_tag_array = apply_filters( 'yikes_mailchimp_default_value_tag' , $custom_tag_array=array() );
|
2776 |
+
|
2777 |
+
/*
|
2778 |
+
Lets Setup The Default Merge Variables Here
|
2779 |
+
example : {post_title} , {post_id} , {page_url} , {user_logged_in}, {blog_name}
|
2780 |
+
*/
|
2781 |
+
global $post;
|
2782 |
+
|
2783 |
+
switch ( $field['default'] ) {
|
2784 |
+
|
2785 |
+
case '{post_title}' :
|
2786 |
+
$field['default'] = get_the_title( $post->ID );
|
2787 |
+
break;
|
2788 |
+
|
2789 |
+
case '{post_id}' :
|
2790 |
+
$field['default'] = $post->ID;
|
2791 |
+
break;
|
2792 |
+
|
2793 |
+
case '{page_url}' :
|
2794 |
+
$field['default'] = get_bloginfo( 'url' ) . $_SERVER['REQUEST_URI'];
|
2795 |
+
break;
|
2796 |
+
|
2797 |
+
case '{blog_name}' :
|
2798 |
+
$field['default'] = get_bloginfo( 'name' );
|
2799 |
+
break;
|
2800 |
+
|
2801 |
+
case '{user_logged_in}' :
|
2802 |
+
if ( is_user_logged_in() ) {
|
2803 |
+
$field['default'] = 'Registered User';
|
2804 |
+
} else {
|
2805 |
+
$field['default'] = 'Guest';
|
2806 |
+
}
|
2807 |
+
break;
|
2808 |
+
|
2809 |
+
case in_array( $field['default'] , $custom_tag_array ) :
|
2810 |
+
$field['default'] = apply_filters( 'yikes_mailchimp_process_default_value_tag' , $field );
|
2811 |
+
break;
|
2812 |
+
|
2813 |
+
default:
|
2814 |
+
$field['default'] = $field['default'];
|
2815 |
+
break;
|
2816 |
+
|
2817 |
+
}
|
2818 |
+
|
2819 |
+
}
|
2820 |
+
$o .= '<input type="text" placeholder="'.$placeholder.'" name="'.$field['name'].'" class="'.$field['name'].($field['require'] == 1 ? ' yks-require' : '') . ' ' . $custom_class . ' ' . $class_title .'" id="'.$field['id'].'" value="'.$field['default'].'" />';
|
2821 |
+
break;
|
2822 |
+
|
2823 |
+
case 'dropdown':
|
2824 |
+
$o .= '<select name="'.$field['name'].'" class="'.$field['name'].($field['require'] == 1 ? ' yks-require' : ''). ' ' . $custom_class . ' ' . $class_title .'" id="'.$field['id'].'">';
|
2825 |
+
if(count($field['choices']) > 0) : foreach($field['choices'] as $ok => $ov) :
|
2826 |
+
$o .= '<option value="'.htmlentities($ov, ENT_QUOTES).'">'.$ov.'</option>';
|
2827 |
+
endforeach; endif;
|
2828 |
+
$o .= '</select>';
|
2829 |
+
break;
|
2830 |
+
|
2831 |
+
case 'address':
|
2832 |
+
$o .= '<input type="text" placeholder="'.$placeholder.'" name="'.$field['name'].'" class="'.$field['name'].($field['require'] == 1 ? ' yks-require' : ''). ' ' . $custom_class . ' ' . $class_title .'" id="'.$field['id'].'" value="" /><span class="yks-mailchimp-form-tooltip">Street Address</span>';
|
2833 |
+
$o .= '<input type="text" name="'.$field['name'].'-add2" class="'.$field['name'].'-add2'.($field['require'] == 1 ? ' yks-require' : ''). ' ' . $custom_class . ' ' . $class_title .'" id="'.$field['id'].'-add2" value="" /><span class="yks-mailchimp-form-tooltip">Apt/Suite</span>';
|
2834 |
+
$o .= '<input type="text" name="'.$field['name'].'-city" class="'.$field['name'].'-city'.($field['require'] == 1 ? ' yks-require' : ''). ' ' . $custom_class . ' ' . $class_title .'" id="'.$field['id'].'-city" value="" /><span class="yks-mailchimp-form-tooltip">City</span>';
|
2835 |
+
$o .= '<input type="text" name="'.$field['name'].'-state" class="'.$field['name'].'-state'.($field['require'] == 1 ? ' yks-require' : ''). ' ' . $custom_class . ' ' . $class_title .'" id="'.$field['id'].'-state" value="" /><span class="yks-mailchimp-form-tooltip">State</span>';
|
2836 |
+
$o .= '<input type="text" name="'.$field['name'].'-zip" class="'.$field['name'].'-zip'.($field['require'] == 1 ? ' yks-require' : ''). ' ' . $custom_class . ' ' . $class_title .'" id="'.$field['id'].'-zip" value="" /><span class="yks-mailchimp-form-tooltip">Zip</span>';
|
2837 |
+
break;
|
2838 |
+
|
2839 |
+
case 'radio':
|
2840 |
+
if(count($field['choices']) > 0) : $ct=0; foreach($field['choices'] as $ok => $ov) :
|
2841 |
+
$ct++;
|
2842 |
+
$o .= '<label class="yks_mc_interest_group_label" for="'.$field['id'].'-'.$ok.'">
|
2843 |
+
<input type="radio" name="'.$field['name'].'" class="'.$field['name'].($field['require'] == 1 ? ' yks-require' : ''). ' ' . $custom_class . ' ' . $class_title .' yikes_mc_interest_group_checkbox" id="'.$field['id'].'-'.$ok.'" value="'.htmlentities($ov, ENT_QUOTES).'" />
|
2844 |
+
<span>'.$ov.'</span>
|
2845 |
+
</label>';;
|
2846 |
+
endforeach; endif;
|
2847 |
+
break;
|
2848 |
+
|
2849 |
+
case 'date':
|
2850 |
+
case 'birthday':
|
2851 |
+
$o .= '<input placeholder="'.$placeholder.'" type="text" name="'.$field['name'].'" class="'.$field['name'].' yks-field-type-date'.($field['require'] == 1 ? ' yks-require' : ''). ' ' . $custom_class . ' ' . $class_title .'" id="'.$field['id'].'" value="" />';
|
2852 |
+
break;
|
2853 |
+
|
2854 |
+
}
|
2855 |
+
|
2856 |
+
return $o;
|
2857 |
+
}
|
2858 |
+
|
2859 |
+
|
2860 |
+
/***** UPDATES
|
2861 |
+
****************************************************************************************************/
|
2862 |
+
public function runUpdateTasks() {
|
2863 |
+
$currentVersion = (!isset($this->optionVal['version']) || empty($this->optionVal['version']) ? '5.0.3' : $this->optionVal['version']);
|
2864 |
+
$latestVersion = YKSEME_VERSION_CURRENT;
|
2865 |
+
if($currentVersion < $latestVersion)
|
2866 |
+
{
|
2867 |
+
$updateFunction = 'runUpdateTasks_'.str_replace('.', '_', $currentVersion);
|
2868 |
+
if(!method_exists($this, $updateFunction)) return false;
|
2869 |
+
else
|
2870 |
+
{
|
2871 |
+
if(call_user_func(array(&$this, $updateFunction)))
|
2872 |
+
{
|
2873 |
+
update_option( YKSEME_OPTION, YKSEME_VERSION_CURRENT );
|
2874 |
+
$this->runUpdateTasks();
|
2875 |
+
}
|
2876 |
+
}
|
2877 |
+
}
|
2878 |
+
else return false;
|
2879 |
+
}
|
2880 |
+
|
2881 |
+
/**
|
2882 |
+
* This update makes the first name and last name optional
|
2883 |
+
* To do this we need to loop through the existing fields and
|
2884 |
+
* change the 'require' key to 0
|
2885 |
+
*
|
2886 |
+
* 1.1.0 => 1.2.0
|
2887 |
+
*/
|
2888 |
+
private function runUpdateTasks_1_1_0() {
|
2889 |
+
if($this->optionVal['lists']) {
|
2890 |
+
foreach($this->optionVal['lists'] as $lid => $list) {
|
2891 |
+
foreach($list['fields'] as $fid => $field) {
|
2892 |
+
switch($field['name']) {
|
2893 |
+
case 'yks-mailchimp-field-name-first':
|
2894 |
+
case 'yks-mailchimp-field-name-last':
|
2895 |
+
$this->optionVal['lists'][$lid]['fields'][$fid]['locked'] = 0;
|
2896 |
+
break;
|
2897 |
+
}
|
2898 |
+
}
|
2899 |
+
}
|
2900 |
+
}
|
2901 |
+
$this->optionVal['version'] = '1.2.0';
|
2902 |
+
return true;
|
2903 |
+
}
|
2904 |
+
|
2905 |
+
/**
|
2906 |
+
* This update adds a merge_vars key to each
|
2907 |
+
* field array so that users can specify their
|
2908 |
+
* own merge_var names
|
2909 |
+
*
|
2910 |
+
* 1.2.0 => 1.3.0
|
2911 |
+
*/
|
2912 |
+
private function runUpdateTasks_1_2_0() {
|
2913 |
+
if($this->optionVal['lists']) {
|
2914 |
+
foreach($this->optionVal['lists'] as $lid => $list) {
|
2915 |
+
$fct = 1;
|
2916 |
+
foreach($list['fields'] as $fid => $field) {
|
2917 |
+
switch($field['name']) {
|
2918 |
+
|
2919 |
+
case 'yks-mailchimp-field-email':
|
2920 |
+
$this->optionVal['lists'][$lid]['fields'][$fid]['merge'] = 'EMAIL';
|
2921 |
+
break;
|
2922 |
+
|
2923 |
+
case 'yks-mailchimp-field-apt-suite':
|
2924 |
+
case 'yks-mailchimp-field-city':
|
2925 |
+
case 'yks-mailchimp-field-state':
|
2926 |
+
case 'yks-mailchimp-field-zip':
|
2927 |
+
$this->optionVal['lists'][$lid]['fields'][$fid]['merge'] = false;
|
2928 |
+
break;
|
2929 |
+
|
2930 |
+
default:
|
2931 |
+
if(empty($this->optionVal['lists'][$lid]['fields'][$fid]['merge']) || !isset($this->optionVal['lists'][$lid]['fields'][$fid]['merge']))
|
2932 |
+
$this->optionVal['lists'][$lid]['fields'][$fid]['merge'] = 'MERGE'.$fct;
|
2933 |
+
$fct++;
|
2934 |
+
break;
|
2935 |
+
}
|
2936 |
+
}
|
2937 |
+
}
|
2938 |
+
}
|
2939 |
+
$this->optionVal['version'] = '1.3.0';
|
2940 |
+
return true;
|
2941 |
+
}
|
2942 |
+
|
2943 |
+
/**
|
2944 |
+
* This update needs to pull in all of the custom form
|
2945 |
+
* data for each of the lists, unfortunately it has to replace
|
2946 |
+
* just about all of the data with the new schema. We also
|
2947 |
+
* add in the flavor key (for table/div usage)
|
2948 |
+
*
|
2949 |
+
* 4.3 => 5.0.4
|
2950 |
+
*/
|
2951 |
+
private function runUpdateTasks_4_3() {
|
2952 |
+
if ( !isset( $this->optionVal['recaptcha-setting'] ) ) {
|
2953 |
+
$this->optionVal['recaptcha-setting'] = '0';
|
2954 |
+
}
|
2955 |
+
if ( !isset( $this->optionVal['recaptcha-api-key'] ) ) {
|
2956 |
+
$this->optionVal['recaptcha-api-key'] = '';
|
2957 |
+
}
|
2958 |
+
if ( !isset( $this->optionVal['recaptcha-private-api-key'] ) ) {
|
2959 |
+
$this->optionVal['recaptcha-private-api-key'] = '';
|
2960 |
+
}
|
2961 |
+
$this->optionVal['version'] = '5.0.4';
|
2962 |
+
return true;
|
2963 |
+
}
|
2964 |
+
|
2965 |
+
/** Update/Add New Merge Variables and Interest Group Containers */
|
2966 |
+
|
2967 |
+
// generate a container to allow for creating new merge variables (form fields)
|
2968 |
+
function generateNewMergeVariableContainer() {
|
2969 |
+
include YKSEME_PATH . 'lib/inc/yks-mc-new-merge-variable-container.php';
|
2970 |
+
}
|
2971 |
+
|
2972 |
+
// generate a container to allow for editing merge variables
|
2973 |
+
function generateMergeVariableUpdateContainer() {
|
2974 |
+
$delete_icon = '<span class="dashicons dashicons-no-alt remove-radio-dropdown-option"></span>';
|
2975 |
+
include YKSEME_PATH . 'lib/inc/yks-mc-update-merge-variable-container.php';
|
2976 |
+
}
|
2977 |
+
|
2978 |
+
// generate a container to allow for creating new interest groups
|
2979 |
+
public function generateCreateInterestGroupContainer() {
|
2980 |
+
include YKSEME_PATH . 'lib/inc/yks-mc-create-interest-group-container.php';
|
2981 |
+
}
|
2982 |
+
|
2983 |
+
// end merge variable and interest group containers
|
2984 |
+
|
2985 |
+
// generate a thickbox container
|
2986 |
+
// to display a preview of the form
|
2987 |
+
function generateFormPreviewContainer() {
|
2988 |
+
?>
|
2989 |
+
<div id="formPreviewContainer" style="display:none;">
|
2990 |
+
<?php echo '<img src="' . admin_url() . '/images/wpspin_light.gif" alt="preloader" style="margin-left: 50%; margin-top: 25%;">'; ?>
|
2991 |
+
</div>
|
2992 |
+
<?php
|
2993 |
+
}
|
2994 |
+
|
2995 |
+
// generate a thickbox container
|
2996 |
+
// to display a how to in using custom template files
|
2997 |
+
function generateUserTemplateHowTo() {
|
2998 |
+
?>
|
2999 |
+
<div id="user_template_how_to" style="display:none;">
|
3000 |
+
<a href="http://www.yikesinc.com" title="YIKES, Inc." target="_blank"><img style="float:left;margin-bottom:0;width:75px;" src="<?php echo YKSEME_URL; ?>/images/yikes_logo.png" alt="YIKES, Inc." id="yksme-yikes-logo" /></a>
|
3001 |
+
<h4 class="user_template_how_to_title"><?php _e( 'Custom User Template Files' , 'yikes-inc-easy-mailchimp-extender' ); ?></h4>
|
3002 |
+
|
3003 |
+
<p style="margin-top: 2.5em;" ><?php _e( 'With the latest version of YIKES Inc. Easy MailChimp Extender you can now extend the plugin beyond what it can do out of the box. Now you can create your own MailChimp sign up template files and use them with any list , anywhere on your site. We have provided you with a few bundled templates, as well as two boilerplate template files for easy customization.' , 'yikes-inc-easy-mailchimp-extender' ); ?></p>
|
3004 |
+
|
3005 |
+
<p><?php _e( 'You can create your own templates in two ways.' , 'yikes-inc-easy-mailchimp-extender' ); ?></p>
|
3006 |
+
<hr />
|
3007 |
+
<ul>
|
3008 |
+
<li><h4><?php _e( 'Automatic Method :' , 'yikes-inc-easy-mailchimp-extender' ); ?></h4><p><?php _e( "The easiest way is to import the template files from the plugin automatically. You can do this by clicking on the 'import boilerplate files' button. This will copy over the necessary files right into your theme. From there you can start editing the template files found in your theme root inside of the newly created 'yikes-inc-easy-mailchimp-extender' directory." , "yikes-inc-easy-mailchimp-extender" ); ?></p></li>
|
3009 |
+
<a href="#" onclick="return false;" class="button-secondary import_template_boilerplates" style="width:148px;display:block;margin:0 auto;"><?php _e( "import boilerplate files" , "yikes-inc-easy-mailchimp-extender" ); ?></a>
|
3010 |
+
<hr />
|
3011 |
+
<li><h4><?php _e( 'Manual Method' , 'yikes-inc-easy-mailchimp-extender' ); ?> :</h4><p><?php _e( "If the automatic method doesn't work for you, you can manually copy over the necessary files." , 'yikes-inc-easy-mailchimp-extender' ); ?></p> <p><?php _e( "Copy the following directory" , "yikes-inc-easy-mailchimp-extender" ); ?> :<br /> <em class="yks-mc-file-path"><?php echo YKSEME_PATH . 'templates/yikes-mailchimp-user-templates'; ?></em> <br /><?php _e( " into your theme root, found at " , "yikes-inc-easy-mailchimp-extender" ); ?><br /> <em class="yks-mc-file-path"><?php echo get_stylesheet_directory_uri(); ?></em></p></li>
|
3012 |
+
<hr />
|
3013 |
+
<li><h5><?php _e( "Notes" , "yikes-inc-easy-mailchimp-extender" ); ?></h5></li>
|
3014 |
+
<ul>
|
3015 |
+
<li><p><?php _e( "You can also copy over any of the default bundled themes into the 'yikes-mailchimp-user-templates' directory to customize the look and feel of a default bundled template file." , "yikes-inc-easy-mailchimp-extender" ); ?></p></li>
|
3016 |
+
<li><p><?php _e( "If you are having any difficulties copying over the template files, or need help using them please open a support ticket on our" , "yikes-inc-easy-mailchimp-extender" ); ?> <a href="https://github.com/yikesinc/yikes-inc-easy-mailchimp-extender/issues" target="_blank"><?php _e( "github issue tracker" , "yikes-inc-easy-mailchimp-extender" ); ?></a>.</p></li>
|
3017 |
+
</ul>
|
3018 |
+
</div>
|
3019 |
+
<?php
|
3020 |
+
}
|
3021 |
+
|
3022 |
+
// generate a thickbox container
|
3023 |
+
// to display a preview of the form
|
3024 |
+
function getFormPreview($shortcode,$form_title,$form_bg_color,$form_text_color,$form_submit_button_color,$form_submit_button_text_color,$form_padding,$form_width,$form_alignment) {
|
3025 |
+
?>
|
3026 |
+
<h4 style="width:100%;text-align:center;">"<?php echo trim( $form_title ); ?>" Form Preview</h4>
|
3027 |
+
<div class="yks_mc_preview_form_container"><?php echo do_shortcode( stripslashes( $shortcode ) ); ?></div>
|
3028 |
+
<!-- override the styles for our preview container -->
|
3029 |
+
<style>
|
3030 |
+
.yks-mailchimpFormContainer {
|
3031 |
+
background: <?php echo $form_bg_color; ?> !important;
|
3032 |
+
padding: <?php echo $form_padding; ?> !important;
|
3033 |
+
color: <?php echo $form_text_color; ?> !important;
|
3034 |
+
width: <?php echo $form_width; ?> !important;
|
3035 |
+
<?php
|
3036 |
+
if ( $form_alignment == 'left' ) {
|
3037 |
+
?>
|
3038 |
+
display: block;
|
3039 |
+
float: left;
|
3040 |
+
<?php
|
3041 |
+
} elseif ( $form_alignment == 'center' ) {
|
3042 |
+
?>
|
3043 |
+
display: block;
|
3044 |
+
margin: 0 auto;
|
3045 |
+
<?php
|
3046 |
+
} elseif ( $form_alignment == 'right' ) {
|
3047 |
+
?>
|
3048 |
+
display: block;
|
3049 |
+
float: right;
|
3050 |
+
<?php
|
3051 |
+
}
|
3052 |
+
?>
|
3053 |
+
}
|
3054 |
+
.yks-mailchimpFormDivRowLabel, .yks_mc_interest_group_label, .yks-mailchimp-form-tooltip {
|
3055 |
+
color: <?php echo $form_text_color; ?> !important;
|
3056 |
+
}
|
3057 |
+
.ykfmc-submit {
|
3058 |
+
background: <?php echo $form_submit_button_color; ?> !important;
|
3059 |
+
color: <?php echo $form_submit_button_text_color; ?> !important;
|
3060 |
+
}
|
3061 |
+
.yks_mc_interest_group_holder input[type=radio], .yks_mc_interest_group_holder input[type=checkbox] {
|
3062 |
+
margin:0 5px 0 0 !important;
|
3063 |
+
}
|
3064 |
+
body.mailchimp-forms_page_yks-mailchimp-form-lists form[name="yks-mailchimp-form"] {
|
3065 |
+
padding: 0 !important;
|
3066 |
+
}
|
3067 |
+
</style>
|
3068 |
+
<?php
|
3069 |
+
}
|
3070 |
+
|
3071 |
+
// Get the selected form template screenshot
|
3072 |
+
function getTemplateScreenshot( $template_name , $template_screenshot , $template_path ) {
|
3073 |
+
|
3074 |
+
$default_headers = array(
|
3075 |
+
'YIKES Inc. MailChimp Template',
|
3076 |
+
'YIKES Inc. MailChimp Template Author',
|
3077 |
+
'YIKES Inc. MailChimp Template Description'
|
3078 |
+
);
|
3079 |
+
// end pre-packaged templates
|
3080 |
+
$template_file_data = get_file_data( $template_path , $default_headers );
|
3081 |
+
|
3082 |
+
?>
|
3083 |
+
<div id="selected_template_preview_container">
|
3084 |
+
<span class="selected_template_preview_header">
|
3085 |
+
<h3 class="template_name"><?php echo $template_name; ?></h3>
|
3086 |
+
|
3087 |
+
<p class="template_author"><strong><?php _e( "Author " , "yikes-inc-easy-mailchimp-extender" ); ?> :</strong> <em> <?php echo $template_file_data[1]; ?></em></p>
|
3088 |
+
</span>
|
3089 |
+
|
3090 |
+
<p><strong><?php _e( "Description" , "yikes-inc-easy-mailchimp-extender" ); ?> :</strong> <?php echo $template_file_data[2]; ?></p>
|
3091 |
+
|
3092 |
+
<hr />
|
3093 |
+
|
3094 |
+
<img class="template_screenshot preview_template_screenshot" style="max-width:100%;" src="<?php echo YKSEME_URL . 'templates/yikes-mailchimp-bundled-templates/' . str_replace( ' ' , '_' , $template_name ) . '/' . $template_screenshot; ?>">
|
3095 |
+
</div>
|
3096 |
+
<?php
|
3097 |
+
}
|
3098 |
+
|
3099 |
+
/**
|
3100 |
+
* This update needs to pull in all of the custom form
|
3101 |
+
* data for each of the lists, unfortunately it has to replace
|
3102 |
+
* just about all of the data with the new schema. We also
|
3103 |
+
* add in the flavor key (for table/div usage)
|
3104 |
+
*
|
3105 |
+
* 1.3.0 => 2.0.0
|
3106 |
+
*/
|
3107 |
+
private function runUpdateTasks_1_3_0() {
|
3108 |
+
$this->optionVal['flavor'] = '0';
|
3109 |
+
$this->optionVal['debug'] = '0';
|
3110 |
+
if( $this->optionVal['lists'] ) {
|
3111 |
+
foreach($this->optionVal['lists'] as $uid => $list) {
|
3112 |
+
unset($this->optionVal['lists'][$uid]);
|
3113 |
+
$this->addList($list['list-id']);
|
3114 |
+
}
|
3115 |
+
}
|
3116 |
+
$this->optionVal['version'] = '2.2.1';
|
3117 |
+
return true;
|
3118 |
+
}
|
3119 |
+
|
3120 |
+
// Copy the user template file from within the plugin
|
3121 |
+
// into the users theme root
|
3122 |
+
public function copyUserTemplatesToUserTheme() {
|
3123 |
+
$src = YKSEME_PATH . 'templates/yikes-mailchimp-user-templates';
|
3124 |
+
$dst = get_stylesheet_directory() . '/yikes-mailchimp-user-templates';
|
3125 |
+
|
3126 |
+
function recurse_copy($src,$dst) {
|
3127 |
+
$dir = opendir($src);
|
3128 |
+
// mkdir( $dst . '/yiks-mailchimp-user-templates/' );
|
3129 |
+
mkdir( $dst );
|
3130 |
+
while(false !== ( $file = readdir($dir)) ) {
|
3131 |
+
if (( $file != '.' ) && ( $file != '..' )) {
|
3132 |
+
if ( is_dir($src . '/' . $file) ) {
|
3133 |
+
recurse_copy($src . '/' . $file,$dst . '/' . $file);
|
3134 |
+
}
|
3135 |
+
else {
|
3136 |
+
copy($src . '/' . $file,$dst . '/' . $file);
|
3137 |
+
}
|
3138 |
+
}
|
3139 |
+
}
|
3140 |
+
closedir($dir);
|
3141 |
+
}
|
3142 |
+
recurse_copy( $src , $dst );
|
3143 |
+
}
|
3144 |
+
|
3145 |
+
/*
|
3146 |
+
generateRandomString();
|
3147 |
+
@since v5.2
|
3148 |
+
Generate a random string of text and numbers for merge variable creation
|
3149 |
+
*/
|
3150 |
+
public function randomMergeVarString($length = 5) {
|
3151 |
+
$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
3152 |
+
$randomString = '';
|
3153 |
+
for ($i = 0; $i < $length; $i++) {
|
3154 |
+
$randomString .= $characters[rand(0, strlen($characters) - 1)];
|
3155 |
+
}
|
3156 |
+
echo $randomString;
|
3157 |
+
}
|
3158 |
+
|
3159 |
+
/*
|
3160 |
+
deleteInterestGroupFromList();
|
3161 |
+
@since v5.2
|
3162 |
+
Delete an interest group from a given list
|
3163 |
+
*/
|
3164 |
+
public function deleteInterestGroupFromList($mc_list_id,$interest_group_id) {
|
3165 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
3166 |
+
try {
|
3167 |
+
$retval = $api->call('lists/interest-grouping-del', array(
|
3168 |
+
'id' => $mc_list_id,
|
3169 |
+
'grouping_id' => $interest_group_id
|
3170 |
+
));
|
3171 |
+
return "done";
|
3172 |
+
} catch( Exception $e ) { // catch any errors returned from MailChimp
|
3173 |
+
$errorMessage = $e->getMessage();
|
3174 |
+
echo $errorMessage;
|
3175 |
+
// write our error to the error log,
|
3176 |
+
// when advanced debug is enabled
|
3177 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
3178 |
+
$this->writeErrorToErrorLog( $e );
|
3179 |
+
}
|
3180 |
+
die();
|
3181 |
+
}
|
3182 |
+
}
|
3183 |
+
|
3184 |
+
/*
|
3185 |
+
createNewInterestGroup();
|
3186 |
+
@since v5.2
|
3187 |
+
Delete an interest group from a given list
|
3188 |
+
*/
|
3189 |
+
public function createNewInterestGroup($p) {
|
3190 |
+
|
3191 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
3192 |
+
parse_str( $p['form_data'], $formData );
|
3193 |
+
$list_id = $formData['mc-list-id'];
|
3194 |
+
$grouping_name = $formData['add-interest-group-name'];
|
3195 |
+
$grouping_type = $formData['add-interest-group-type'];
|
3196 |
+
$grouping_groups = $formData['radio-dropdown-option'];
|
3197 |
+
|
3198 |
+
try {
|
3199 |
+
$retval = $api->call('lists/interest-grouping-add', array(
|
3200 |
+
'id' => $list_id,
|
3201 |
+
'name' => $grouping_name,
|
3202 |
+
'type' => $grouping_type,
|
3203 |
+
'groups' => $grouping_groups
|
3204 |
+
));
|
3205 |
+
return "done";
|
3206 |
+
} catch( Exception $e ) { // catch any errors returned from MailChimp
|
3207 |
+
$errorMessage = $e->getMessage();
|
3208 |
+
echo $errorMessage;
|
3209 |
+
// write our error to the error log,
|
3210 |
+
// when advanced debug is enabled
|
3211 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
3212 |
+
$this->writeErrorToErrorLog( $e );
|
3213 |
+
}
|
3214 |
+
die();
|
3215 |
+
}
|
3216 |
+
}
|
3217 |
+
|
3218 |
+
/*
|
3219 |
+
updateInterestGroup();
|
3220 |
+
@since v5.2
|
3221 |
+
Update an interest group from a given list
|
3222 |
+
*/
|
3223 |
+
public function updateInterestGroup( $mailchimp_list_id , $grouping_id , $previous_value , $new_value ) {
|
3224 |
+
|
3225 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
3226 |
+
|
3227 |
+
try {
|
3228 |
+
$retval = $api->call('lists/interest-group-update', array(
|
3229 |
+
'id' => $mailchimp_list_id,
|
3230 |
+
'old_name' => $previous_value,
|
3231 |
+
'new_name' => $new_value,
|
3232 |
+
'grouping_id' => $grouping_id
|
3233 |
+
));
|
3234 |
+
return "done";
|
3235 |
+
} catch( Exception $e ) { // catch any errors returned from MailChimp
|
3236 |
+
if ( $e->getCode() == 211 ) {
|
3237 |
+
return "done";
|
3238 |
+
} else {
|
3239 |
+
$errorMessage = $e->getMessage();
|
3240 |
+
echo $errorMessage;
|
3241 |
+
// write our error to the error log,
|
3242 |
+
// when advanced debug is enabled
|
3243 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
3244 |
+
$this->writeErrorToErrorLog( $e );
|
3245 |
+
}
|
3246 |
+
}
|
3247 |
+
die();
|
3248 |
+
}
|
3249 |
+
}
|
3250 |
+
|
3251 |
+
/*
|
3252 |
+
updateInterestGroupingTitle();
|
3253 |
+
@since v5.2
|
3254 |
+
Update an interest group from a given list
|
3255 |
+
*/
|
3256 |
+
public function updateInterestGroupingTitle( $mailchimp_list_id , $grouping_id , $value ) {
|
3257 |
+
|
3258 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
3259 |
+
|
3260 |
+
try {
|
3261 |
+
$retval = $api->call('lists/interest-grouping-update', array(
|
3262 |
+
'grouping_id' => $grouping_id,
|
3263 |
+
'name' => 'name',
|
3264 |
+
'value' => $value
|
3265 |
+
));
|
3266 |
+
return "done";
|
3267 |
+
} catch( Exception $e ) { // catch any errors returned from MailChimp
|
3268 |
+
$errorMessage = $e->getMessage();
|
3269 |
+
$errorCode = $e->getCode();
|
3270 |
+
echo $errorMessage;
|
3271 |
+
// write our error to the error log,
|
3272 |
+
// when advanced debug is enabled
|
3273 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
3274 |
+
$this->writeErrorToErrorLog( $e );
|
3275 |
+
}
|
3276 |
+
die();
|
3277 |
+
}
|
3278 |
+
}
|
3279 |
+
|
3280 |
+
/*
|
3281 |
+
addInterestGroupOption();
|
3282 |
+
@since v5.2
|
3283 |
+
Update an interest group from a given list
|
3284 |
+
*/
|
3285 |
+
public function addInterestGroupOption( $mailchimp_list_id , $group_name , $grouping_id ) {
|
3286 |
+
|
3287 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
3288 |
+
|
3289 |
+
try {
|
3290 |
+
$retval = $api->call('lists/interest-group-add', array(
|
3291 |
+
'id' => $mailchimp_list_id,
|
3292 |
+
'group_name' => $group_name,
|
3293 |
+
'grouping_id' => $grouping_id
|
3294 |
+
));
|
3295 |
+
return "done";
|
3296 |
+
} catch( Exception $e ) { // catch any errors returned from MailChimp
|
3297 |
+
$errorMessage = $e->getMessage();
|
3298 |
+
echo $errorMessage;
|
3299 |
+
// write our error to the error log,
|
3300 |
+
// when advanced debug is enabled
|
3301 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
3302 |
+
$this->writeErrorToErrorLog( $e );
|
3303 |
+
}
|
3304 |
+
die();
|
3305 |
+
}
|
3306 |
+
|
3307 |
+
}
|
3308 |
+
|
3309 |
+
/*
|
3310 |
+
deleteInterestGroupOption();
|
3311 |
+
@since v5.2
|
3312 |
+
Update an interest group from a given list
|
3313 |
+
*/
|
3314 |
+
public function deleteInterestGroupOption( $mailchimp_list_id , $group_name , $grouping_id ) {
|
3315 |
+
|
3316 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
3317 |
+
|
3318 |
+
try {
|
3319 |
+
$retval = $api->call('lists/interest-group-del', array(
|
3320 |
+
'id' => $mailchimp_list_id,
|
3321 |
+
'group_name' => $group_name,
|
3322 |
+
'grouping_id' => $grouping_id
|
3323 |
+
));
|
3324 |
+
return "done";
|
3325 |
+
} catch( Exception $e ) { // catch any errors returned from MailChimp
|
3326 |
+
$errorMessage = $e->getMessage();
|
3327 |
+
echo $errorMessage;
|
3328 |
+
// write our error to the error log,
|
3329 |
+
// when advanced debug is enabled
|
3330 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
3331 |
+
$this->writeErrorToErrorLog( $e );
|
3332 |
+
}
|
3333 |
+
die();
|
3334 |
+
}
|
3335 |
+
}
|
3336 |
+
|
3337 |
+
/*
|
3338 |
+
addNewFieldToList();
|
3339 |
+
@since v5.2
|
3340 |
+
MailChimp API Request to Add new field to a list
|
3341 |
+
*/
|
3342 |
+
public function addNewFieldToList( $p ) {
|
3343 |
+
include YKSEME_PATH . 'lib/inc/yks-mc-add-new-field-to-list.php';
|
3344 |
+
}
|
3345 |
+
|
3346 |
+
/*
|
3347 |
+
@since v5.2
|
3348 |
+
MailChimp API Request to Add new field to a list
|
3349 |
+
*/
|
3350 |
+
public function deleteFieldFromList( $mailchimp_list_id , $merge_tag ) {
|
3351 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
3352 |
+
try {
|
3353 |
+
$retval = $api->call('lists/merge-var-del', array(
|
3354 |
+
'id' => $mailchimp_list_id, // list id to delete merge tag from
|
3355 |
+
'tag' => $merge_tag // merge tag to be delete
|
3356 |
+
));
|
3357 |
+
return "done";
|
3358 |
+
} catch( Exception $e ) { // catch any errors returned from MailChimp
|
3359 |
+
$errorMessage = $e->getMessage();
|
3360 |
+
echo $errorMessage;
|
3361 |
+
// write our error to the error log,
|
3362 |
+
// when advanced debug is enabled
|
3363 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
3364 |
+
$this->writeErrorToErrorLog( $e );
|
3365 |
+
}
|
3366 |
+
die();
|
3367 |
+
}
|
3368 |
+
}
|
3369 |
+
|
3370 |
+
/*
|
3371 |
+
@since v5.2
|
3372 |
+
Change the interest group type
|
3373 |
+
*/
|
3374 |
+
public function changeListInterestGroupType( $grouping_id , $value ) {
|
3375 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
3376 |
+
try {
|
3377 |
+
$retval = $api->call('lists/interest-grouping-update', array(
|
3378 |
+
'grouping_id' => $grouping_id, // list id to delete merge tag from
|
3379 |
+
'name' => 'type', // merge tag to be delete
|
3380 |
+
'value' => $value
|
3381 |
+
));
|
3382 |
+
return "done";
|
3383 |
+
} catch( Exception $e ) { // catch any errors returned from MailChimp
|
3384 |
+
$errorMessage = $e->getMessage();
|
3385 |
+
echo $errorMessage;
|
3386 |
+
// write our error to the error log,
|
3387 |
+
// when advanced debug is enabled
|
3388 |
+
if ( $this->optionVal['debug'] == 1 ) {
|
3389 |
+
$this->writeErrorToErrorLog( $e );
|
3390 |
+
}
|
3391 |
+
die();
|
3392 |
+
}
|
3393 |
+
}
|
3394 |
+
|
3395 |
+
/*
|
3396 |
+
@since v5.2
|
3397 |
+
MailChimp API Request to Update an existing field on a given list
|
3398 |
+
*/
|
3399 |
+
public function updateListField( $p ) {
|
3400 |
+
include YKSEME_PATH . 'lib/inc/yks-mc-update-list-field.php';
|
3401 |
+
}
|
3402 |
+
|
3403 |
+
// recursive directory scanning
|
3404 |
+
// used to retreive template files from bundled+user template directories
|
3405 |
+
function buildCustomTemplateDropdown($list) {
|
3406 |
+
|
3407 |
+
$bundled_template_directory = YKSEME_PATH . 'templates/yikes-mailchimp-bundled-templates/';
|
3408 |
+
$bundled_template_scan = scandir($bundled_template_directory);
|
3409 |
+
$custom_template_directory = get_stylesheet_directory() . '/yikes-mailchimp-user-templates/';
|
3410 |
+
|
3411 |
+
// only scan the directory when files DO exist
|
3412 |
+
if( is_dir( $custom_template_directory ) ) {
|
3413 |
+
$custom_template_scan = scandir($custom_template_directory);
|
3414 |
+
}
|
3415 |
+
|
3416 |
+
echo '<select class="template-selection-dropdown" name="yks-mc-template-file-selection" >';
|
3417 |
+
|
3418 |
+
/* Bundled Template Dropdown Loop */
|
3419 |
+
echo '<optgroup label="Bundled Templates">';
|
3420 |
+
foreach( $bundled_template_scan as $bundled_template ) {
|
3421 |
+
if( $bundled_template != '.' && $bundled_template != '..' ) {
|
3422 |
+
|
3423 |
+
if( is_dir( $bundled_template_directory . $bundled_template ) ) {
|
3424 |
+
$template_path = $this->getTemplateFilePath($bundled_template_directory.$bundled_template);
|
3425 |
+
}
|
3426 |
+
|
3427 |
+
// set the selected option
|
3428 |
+
if ( $list['custom_template']['template_file'] == $template_path ) {
|
3429 |
+
echo '<option value="' . $template_path . '" selected="selected" >' . str_replace( '_' , ' ' , $bundled_template ) . '</option>';
|
3430 |
+
} else {
|
3431 |
+
echo '<option value="' . $template_path . '">' . str_replace( '_' , ' ' , $bundled_template ) . '</option>';
|
3432 |
+
}
|
3433 |
+
|
3434 |
+
}
|
3435 |
+
}
|
3436 |
+
echo '</optgroup>';
|
3437 |
+
|
3438 |
+
echo '<optgroup label="Custom Templates">';
|
3439 |
+
/* Custom Template Dropdown Loop */
|
3440 |
+
if( is_dir( get_stylesheet_directory() . '/yikes-mailchimp-user-templates' ) && count( $custom_template_scan ) >= 1 ) {
|
3441 |
+
foreach( $custom_template_scan as $custom_template ) {
|
3442 |
+
if( $custom_template != '.' && $custom_template != '..' ) {
|
3443 |
+
if( is_dir( $custom_template_directory . $custom_template ) ) {
|
3444 |
+
$custom_template_path = $this->getTemplateFilePath($custom_template_directory.$custom_template);
|
3445 |
+
}
|
3446 |
+
// set the selected option
|
3447 |
+
if ( $list['custom_template']['template_file'] == $custom_template_path ) {
|
3448 |
+
echo '<option value="' . $custom_template_path . '" selected="selected" >' . str_replace( '_' , ' ' , $custom_template ) . '</option>';
|
3449 |
+
} else {
|
3450 |
+
echo '<option value="' . $custom_template_path . '">' . str_replace( '_' , ' ' , $custom_template ) . '</option>';
|
3451 |
+
}
|
3452 |
+
}
|
3453 |
+
}
|
3454 |
+
} else {
|
3455 |
+
echo '<option value="" disabled="disabled">None Found</option>';
|
3456 |
+
}
|
3457 |
+
echo '</optgroup>';
|
3458 |
+
echo '</select>';
|
3459 |
+
}
|
3460 |
+
|
3461 |
+
// function to return our form template path
|
3462 |
+
function getTemplateFilePath($directory) {
|
3463 |
+
$get_files = scandir($directory);
|
3464 |
+
$sub_files = array();
|
3465 |
+
foreach( $get_files as $file ) {
|
3466 |
+
if($file != '.' && $file != '..') {
|
3467 |
+
$explode_file = explode( '.' , $file );
|
3468 |
+
$file_extension = $explode_file[1];
|
3469 |
+
if ( $file_extension == 'php' ) {
|
3470 |
+
$file_extension_path = $directory . '/' . $file;
|
3471 |
+
}
|
3472 |
+
}
|
3473 |
+
}
|
3474 |
+
return $file_extension_path;
|
3475 |
+
}
|
3476 |
+
|
3477 |
+
// Adding Opt-In Checkbox to comment forms
|
3478 |
+
// submit the user to mailchimp on a successful comment submission
|
3479 |
+
function ymc_add_meta_settings($comment_id) {
|
3480 |
+
add_comment_meta(
|
3481 |
+
$comment_id,
|
3482 |
+
'mailchimp_subscribe',
|
3483 |
+
$_POST['mailchimp_subscribe'],
|
3484 |
+
true
|
3485 |
+
);
|
3486 |
+
}
|
3487 |
+
|
3488 |
+
// add the checkbox after the comment form
|
3489 |
+
function add_after_comment_form($arg) {
|
3490 |
+
$custom_text = trim($this->optionVal['yks-mailchimp-optin-checkbox-text']);
|
3491 |
+
if ( $custom_text == '' ) {
|
3492 |
+
$custom_text = __("Sign Me Up For MAILCHIMP-REPLACE-THIS-TEXT's Newsletter", "gettext");
|
3493 |
+
} else {
|
3494 |
+
$custom_text = $custom_text;
|
3495 |
+
}
|
3496 |
+
// set the default checked state here...
|
3497 |
+
$arg['comment_notes_after'] = '<label for="yikes_mailchimp_comment_subscribe">
|
3498 |
+
<input type="checkbox" name="mailchimp_subscribe" id="yikes_mailchimp_comment_subscribe" checked="checked" />
|
3499 |
+
'.$custom_text.'
|
3500 |
+
</label>';
|
3501 |
+
return $arg;
|
3502 |
+
}
|
3503 |
+
|
3504 |
+
// Replacing 'MAILCHIMP-REPLACE-THIS-TEXT' text with sitename
|
3505 |
+
function yikes_mc_replace_this_text( $text ) {
|
3506 |
+
$newtext = get_bloginfo('name');
|
3507 |
+
$text = str_replace( 'MAILCHIMP-REPLACE-THIS-TEXT', $newtext, $text );
|
3508 |
+
return $text;
|
3509 |
+
}
|
3510 |
+
|
3511 |
+
// Add our commenter to the list, when comment is submitted
|
3512 |
+
function ymc_subscription_add( $cid, $comment='' ) {
|
3513 |
+
$cid = (int) $cid;
|
3514 |
+
$yikes_api_key = $this->optionVal['api-key'];
|
3515 |
+
$exploded_api_key = explode('-',$yikes_api_key);
|
3516 |
+
$yikes_data_center = $exploded_api_key[1];
|
3517 |
+
|
3518 |
+
if ( !is_object($comment) )
|
3519 |
+
$comment = get_comment($cid);
|
3520 |
+
|
3521 |
+
if ( $comment->comment_karma == 0 ) {
|
3522 |
+
$subscribe = get_comment_meta($cid, 'mailchimp_subscribe', true);
|
3523 |
+
if ( $subscribe == 'on' ) {
|
3524 |
+
global $current_user;
|
3525 |
+
get_currentuserinfo();
|
3526 |
+
$commenter_first_name = trim($current_user->user_firstname);
|
3527 |
+
$commenter_last_name = trim($current_user->user_lastname);
|
3528 |
+
|
3529 |
+
if( isset( $commenter_first_name ) && $commenter_first_name != '' ) {
|
3530 |
+
$commenter_first_name = $commenter_first_name; // use the users first name set in the profile
|
3531 |
+
} else {
|
3532 |
+
$commenter_first_name = $comment->comment_author; // if no first name is set in the user profile, we will use the account name
|
3533 |
+
}
|
3534 |
+
|
3535 |
+
if( isset( $commenter_last_name ) && $commenter_last_name != '' ) {
|
3536 |
+
$commenter_last_name = $commenter_last_name; // use the users last name set in the profile
|
3537 |
+
} else {
|
3538 |
+
$commenter_last_name = 'n/a'; // if the user has not set a last name in their profile, we set it to n/a
|
3539 |
+
}
|
3540 |
+
|
3541 |
+
// store our API key
|
3542 |
+
// on the settings page, if they have chosen to display the checkbox
|
3543 |
+
$api = new Mailchimp($this->optionVal['api-key']);
|
3544 |
+
|
3545 |
+
$apikey = $yikes_api_key;
|
3546 |
+
$listid = $this->optionVal['yks-mailchimp-optIn-default-list']; // Need to set up a default list to subscribe all users to
|
3547 |
+
$endpoint = 'https://api.mailchimp.com';
|
3548 |
+
$optin = $this->optionVal['optin'];
|
3549 |
+
|
3550 |
+
// setup our welcome email variable
|
3551 |
+
if( isset( $this->optionVal['lists'][$listid]['fields'][$listid.'-email']['yks_mailchimp_send_welcome_'.$listid] ) && $this->optionVal['lists'][$listid]['fields'][$listid.'-email']['yks_mailchimp_send_welcome_'.$listid] == '1' ) {
|
3552 |
+
$welcome = false;
|
3553 |
+
} else {
|
3554 |
+
$welcome = true;
|
3555 |
+
}
|
3556 |
+
|
3557 |
+
// try adding subscriber, catch any error thrown
|
3558 |
+
try {
|
3559 |
+
$retval = $api->call('lists/subscribe', array(
|
3560 |
+
'id' => $listid, // form id
|
3561 |
+
'email' => array(
|
3562 |
+
'email' => $comment->comment_author_email
|
3563 |
+
),
|
3564 |
+
'merge_vars' => array(
|
3565 |
+
'FNAME' => $commenter_first_name,
|
3566 |
+
'LNAME' => $commenter_last_name,
|
3567 |
+
'NAME' => $commenter_first_name
|
3568 |
+
),
|
3569 |
+
'double_optin' => $optin, // double optin value (retreived from the settings page)
|
3570 |
+
'send_welcome' => $welcome
|
3571 |
+
));
|
3572 |
+
return "done";
|
3573 |
+
} catch( Exception $e ) { // catch any errors returned from MailChimp
|
3574 |
+
$error_message = $e->getMessage();
|
3575 |
+
if (strpos($error_message,'Click here to update your profile.') !== false) {
|
3576 |
+
$errorMessage = str_replace('Click here to update your profile.', '', $e->getMessage());
|
3577 |
+
$errorMessage_explode = explode('to list', $errorMessage);
|
3578 |
+
echo $errorMessage_explode[0].'.';
|
3579 |
+
die();
|
3580 |
+
}
|
3581 |
+
if (strpos($error_message,'Invalid') !== false) {
|
3582 |
+
$display_errorMessage = str_replace('Invalid MailChimp List ID:', "Oops! The Webmaster hasn't set up the default MailChimp list to subscribe you too. Please contact them and let them know of this error. In the meantime, un-check the subscription checkbox in the comment form when submitting comments.", $error_message);
|
3583 |
+
echo $display_errorMessage;
|
3584 |
+
die();
|
3585 |
+
} else {
|
3586 |
+
// str_replace('Invalid MailChimp List ID: .', 'The Webmaster hasn\t set up the default MailChimp list to subscribe you too. Please contact them and let them know of this error. In the meantime, un-check the subscription checkbox in the comment form when submitting comments.', $e->getMessage());
|
3587 |
+
echo $errorMessage;
|
3588 |
+
die();
|
3589 |
+
}
|
3590 |
+
}
|
3591 |
+
}
|
3592 |
+
}
|
3593 |
+
}
|
3594 |
+
|
3595 |
+
// add our actions on initialize
|
3596 |
+
// inside of __construct()
|
3597 |
+
public function ykes_mc_apply_filters() {
|
3598 |
+
// if the optin checkbox setting is set to show
|
3599 |
+
// we wiill display the checkbox on the front end
|
3600 |
+
if ( $this->optionVal['optIn-checkbox'] == 1 ) {
|
3601 |
+
add_action('comment_post', array(&$this, 'ymc_add_meta_settings'), 10, 2);
|
3602 |
+
add_action('comment_approved_', array(&$this, 'ymc_subscription_add'), 60, 2);
|
3603 |
+
add_action('comment_post', array(&$this, 'ymc_subscription_add'));
|
3604 |
+
add_filter('gettext', array(&$this, 'yikes_mc_replace_this_text'));
|
3605 |
+
// only display the checkbox if the user is logged in, and the default list is set
|
3606 |
+
if( is_user_logged_in() && isset( $this->optionVal['yks-mailchimp-optIn-default-list'] ) && $this->optionVal['yks-mailchimp-optIn-default-list'] != 'select_value' ) {
|
3607 |
+
add_filter('comment_form_defaults', array(&$this, 'add_after_comment_form'));
|
3608 |
+
}
|
3609 |
+
}
|
3610 |
+
}
|
3611 |
+
|
3612 |
+
|
3613 |
+
/****
|
3614 |
+
**
|
3615 |
+
** Custom The_Content filter
|
3616 |
+
** used to prevent other plugins from hooking here
|
3617 |
+
**
|
3618 |
+
****/
|
3619 |
+
function yks_mc_content() {
|
3620 |
+
//Create our own version of the_content so that others can't accidentally loop into our output - Taken from default-filters.php, shortcodes.php, and media.php
|
3621 |
+
if ( !has_filter( 'yks_mc_content', 'wptexturize' ) ) {
|
3622 |
+
add_filter( 'yks_mc_content', 'wptexturize' );
|
3623 |
+
add_filter( 'yks_mc_content', 'convert_smilies' );
|
3624 |
+
add_filter( 'yks_mc_content', 'convert_chars' );
|
3625 |
+
add_filter( 'yks_mc_content', 'wpautop' );
|
3626 |
+
add_filter( 'yks_mc_content', 'shortcode_unautop' );
|
3627 |
+
add_filter( 'yks_mc_content', 'prepend_attachment' );
|
3628 |
+
$vidembed = new WP_Embed();
|
3629 |
+
add_filter( 'yks_mc_content', array( &$vidembed, 'run_shortcode'), 8 );
|
3630 |
+
add_filter( 'yks_mc_content', array( &$vidembed, 'autoembed'), 8 );
|
3631 |
+
add_filter( 'yks_mc_content', 'do_shortcode', 11);
|
3632 |
+
} //end has_filter
|
3633 |
+
} //end yks_mc_content
|
3634 |
+
|
3635 |
+
|
3636 |
+
// Check if cURL is enabled at the server level
|
3637 |
+
// used on the options.php page
|
3638 |
+
public function yikes_curl_check() {
|
3639 |
+
if (in_array ('curl', get_loaded_extensions())) {
|
3640 |
+
return true;
|
3641 |
+
} else {
|
3642 |
+
return false;
|
3643 |
+
}
|
3644 |
+
}
|
3645 |
+
|
3646 |
+
// check if php.ini exists in the site root
|
3647 |
+
function yks_check_if_php_ini_exists() {
|
3648 |
+
|
3649 |
+
// get php ini path from the actively loaded php ini file
|
3650 |
+
$wordpress_site_root = str_replace('php.ini','',php_ini_loaded_file());
|
3651 |
+
// file name
|
3652 |
+
$filename = '/php.ini';
|
3653 |
+
|
3654 |
+
$php_ini_location = php_ini_loaded_file();
|
3655 |
+
|
3656 |
+
if (file_exists($wordpress_site_root.$filename)) {
|
3657 |
+
echo "<span class='yks_mc_no_phpini_success'>Good News </span>: We have located your <strong>".str_replace('/','',$filename)."</strong> file inside the directory <strong>".$wordpress_site_root."</strong>";
|
3658 |
+
$filename = '/php.ini';
|
3659 |
+
} else {
|
3660 |
+
echo "<span class='yks_mc_no_phpini_alert'>Alert </span>: No <strong>".str_replace('/','',$filename)."</strong> was located in <strong>".$wordpress_site_root.'/'."</strong>.";
|
3661 |
+
$filename = '/php.ini';
|
3662 |
+
}
|
3663 |
+
|
3664 |
+
}
|
3665 |
+
|
3666 |
+
// display the php.ini location to the user
|
3667 |
+
function yks_display_php_ini_location() {
|
3668 |
+
echo php_ini_loaded_file();
|
3669 |
+
}
|
3670 |
+
|
3671 |
+
|
3672 |
+
// Add TinyMCE Buttons to the TinyMCE Editor
|
3673 |
+
// We'll use the button to place form shortcodes!
|
3674 |
+
// NOTE: This only runs on 3.9 or greater -> due to tinyMCE 4.0
|
3675 |
+
// Custom TinyMCE Button to insert form shortcodes onto pages and posts
|
3676 |
+
function yks_mc_add_tinyMCE() {
|
3677 |
+
global $typenow;
|
3678 |
+
// only on Post Type: post and page
|
3679 |
+
if( ! in_array( $typenow, array( 'post', 'page' ) ) ) {
|
3680 |
+
return ;
|
3681 |
+
}
|
3682 |
+
}
|
3683 |
+
|
3684 |
+
// inlcude the js for tinymce
|
3685 |
+
function yks_mc_add_tinymce_plugin( $plugin_array ) {
|
3686 |
+
$plugin_array['yks_mc_tinymce_button'] = plugins_url( '/../js/yks_mc_tinymce_button.js', __FILE__ );
|
3687 |
+
// Print all plugin js path
|
3688 |
+
// var_dump( $plugin_array );
|
3689 |
+
return $plugin_array;
|
3690 |
+
}
|
3691 |
+
|
3692 |
+
// Add the button key for address via JS
|
3693 |
+
function yks_mc_add_tinymce_button( $buttons ) {
|
3694 |
+
array_push( $buttons, 'yks_mc_tinymce_button_key' );
|
3695 |
+
// Print all buttons
|
3696 |
+
return $buttons;
|
3697 |
+
}
|
3698 |
+
|
3699 |
+
/**
|
3700 |
+
* Localize Script
|
3701 |
+
* Pass our imported list data, to the JS file
|
3702 |
+
* to build the dropdown list in the modal
|
3703 |
+
*/
|
3704 |
+
function yks_mc_js_admin_head() {
|
3705 |
+
$yks_mc_imported_list_data = $this->optionVal['lists'];
|
3706 |
+
// our list data array, we will pass to the js file
|
3707 |
+
$list_value_array = array();
|
3708 |
+
$i = 0;
|
3709 |
+
// loop over the list data
|
3710 |
+
foreach ( $yks_mc_imported_list_data as $single_list ) {
|
3711 |
+
// store it temporarily and push it back to our array
|
3712 |
+
$list_value_array[$i]['text'] = $single_list['name'];
|
3713 |
+
$list_value_array[$i]['value'] = $single_list['id'];
|
3714 |
+
$i++;
|
3715 |
+
}
|
3716 |
+
?>
|
3717 |
+
<!-- TinyMCE Shortcode Plugin -->
|
3718 |
+
<script type='text/javascript'>
|
3719 |
+
var yks_mc_lists_data = {
|
3720 |
+
'lists': <?php echo json_encode($list_value_array); ?>
|
3721 |
+
};
|
3722 |
+
</script>
|
3723 |
+
<!-- TinyMCE Shortcode Plugin -->
|
3724 |
+
<?php
|
3725 |
+
}
|
3726 |
+
|
3727 |
+
|
3728 |
+
/* Checking if the user is on localhost */
|
3729 |
+
/* If they are we want to display a warning about SSL on localhost */
|
3730 |
+
function yks_mc_is_user_localhost() {
|
3731 |
+
$whitelist = array( '127.0.0.1', '::1' );
|
3732 |
+
if( in_array( $_SERVER['REMOTE_ADDR'], $whitelist) ) {
|
3733 |
+
return true;
|
3734 |
+
}
|
3735 |
+
}
|
3736 |
+
|
3737 |
+
/*******************************************************/
|
3738 |
+
/* Helper Functions */
|
3739 |
+
/******************************************************/
|
3740 |
+
/*
|
3741 |
+
*
|
3742 |
+
* Helper function when testing user submitted data
|
3743 |
+
* to be used inside of the yikes_mc_get_form_data filter
|
3744 |
+
*
|
3745 |
+
*/
|
3746 |
+
function yks_mc_print_user_data( $form_ID, $merge_variables ) {
|
3747 |
+
echo '<h3>The Data Returned From This Form</h3>';
|
3748 |
+
echo '<strong>MailChimp List ID : </strong> '.$form_ID.' <br />';
|
3749 |
+
echo '<hr />';
|
3750 |
+
if ( isset( $merge_variables['FNAME'] ) && $merge_variables['FNAME'] != '' ) {
|
3751 |
+
echo '<strong>User\'s Name : </strong> '.$merge_variables['FNAME'].' <br />';
|
3752 |
+
echo '<hr />';
|
3753 |
+
}
|
3754 |
+
if ( isset( $merge_variables['LNAME'] ) && $merge_variables['LNAME'] != '' ) {
|
3755 |
+
echo '<strong>User\'s Name : </strong> '.$merge_variables['LNAME'].' <br />';
|
3756 |
+
echo '<hr />';
|
3757 |
+
}
|
3758 |
+
echo '<strong>Users Email : </strong>'.$merge_variables['EMAIL'].' <br />';
|
3759 |
+
if ( isset( $merge_variables['GROUPINGS'] ) ) {
|
3760 |
+
echo '<hr />';
|
3761 |
+
echo '<strong>Interest Group Data : </strong><br /><br />';
|
3762 |
+
foreach ( $merge_variables['GROUPINGS'] as $grouping_variable ) {
|
3763 |
+
echo '<ol style="list-style:none;">Interest Group : '.$grouping_variable['id'].'</ol>';
|
3764 |
+
if ( !isset($grouping_variable['groups'][0]) || $grouping_variable['groups'][0] == '' ) {
|
3765 |
+
echo '<li style="list-style:none;">No interest groups selected</li><br />';
|
3766 |
+
} else {
|
3767 |
+
// loop over interest groups to build array
|
3768 |
+
$interest_group_array = array();
|
3769 |
+
foreach ( $grouping_variable['groups'] as $interest_group ) {
|
3770 |
+
array_push( $interest_group_array , $interest_group );
|
3771 |
+
}
|
3772 |
+
if ( count($interest_group_array) > 0 ) {
|
3773 |
+
foreach ( $interest_group_array as $interest_group_label ) {
|
3774 |
+
echo '<li style="list-style:none;">'.$interest_group_label.'</li>';
|
3775 |
+
}
|
3776 |
+
echo '<br />';
|
3777 |
+
}
|
3778 |
+
}
|
3779 |
+
}
|
3780 |
+
}
|
3781 |
+
echo '<em style="color:rgb(238, 93, 93);">Form data has not been sent to MailChimp</em><br />';
|
3782 |
+
die(); // die to prevent data being sent over to MailChimp
|
3783 |
+
}
|
3784 |
+
|
3785 |
+
/*
|
3786 |
+
* Helper function when testing user submitted data
|
3787 |
+
* print_r($merge_variables) is returned
|
3788 |
+
*/
|
3789 |
+
function yks_mc_dump_user_data( $form_ID, $merge_variables ) {
|
3790 |
+
echo '<strong>Form ID :</strong> '.$form_ID. '<br />';
|
3791 |
+
echo '<strong>Merge Variables :</strong><br />';
|
3792 |
+
print_r($merge_variables);
|
3793 |
+
echo '<br /><em style="color:rgb(238, 93, 93);">Form data has not been sent to MailChimp</em>';
|
3794 |
+
die(); // die to prevent data being sent over to MailChimp
|
3795 |
+
}
|
3796 |
+
|
3797 |
+
/****************************************************************************************
|
3798 |
+
* Begin Heartbeat API Code
|
3799 |
+
* - Used on the Account Activity page for lilve updates
|
3800 |
+
****************************************************************************************/
|
3801 |
+
|
3802 |
+
/*
|
3803 |
+
Client-side code. First we enqueue the Heartbeat API and our Javascript.
|
3804 |
+
Our Javascript is then setup to always send the message 'marco' to the server.
|
3805 |
+
If a message comes back, the Javascript logs it (polo) to console.
|
3806 |
+
*/
|
3807 |
+
|
3808 |
+
//enqueue heartbeat.js and our Javascript
|
3809 |
+
function yks_mc_heartbeat_init() {
|
3810 |
+
//enqueue the Heartbeat API
|
3811 |
+
wp_enqueue_script('heartbeat');
|
3812 |
+
|
3813 |
+
//load our Javascript in the footer
|
3814 |
+
add_action("admin_print_footer_scripts", array( &$this ,"yks_mc_heartbeat_admin_footer" ) );
|
3815 |
+
}
|
3816 |
+
|
3817 |
+
|
3818 |
+
//our Javascript to send/process from the client side
|
3819 |
+
function yks_mc_heartbeat_admin_footer() {
|
3820 |
+
include YKSEME_PATH . 'lib/inc/yks-mc-heartbeat-api.php';
|
3821 |
+
}
|
3822 |
+
|
3823 |
+
/*
|
3824 |
+
Our server-side code.
|
3825 |
+
------------------------------
|
3826 |
+
This hooks into the heartbeat_received filter.
|
3827 |
+
It checks for a key 'client' in the data array. If it is set to 'get_chimp_chatter_data',
|
3828 |
+
a key 'server' is set to 'Get MailChimp Chatter Data' in the response array.
|
3829 |
+
*/
|
3830 |
+
function yks_mc_heartbeat_received($response, $data) {
|
3831 |
+
// if the client returns get chimp chatter data, popluate
|
3832 |
+
// the response with some data
|
3833 |
+
if( $data['yks_mc_chimp_chatter_heartbeat'] == 'get_chimp_chatter_data' ) {
|
3834 |
+
// populate the response with something
|
3835 |
+
$response['yks_mc_chimp_chatter_data'] = 'Get MailChimp Chatter Data';
|
3836 |
+
} else if ( $data['yks_mc_chimp_chatter_heartbeat'] == 'get_chimp_chatter_widget_data' ) {
|
3837 |
+
$response['yks_mc_chimp_chatter_data'] = 'Get MailChimp Chatter Widget Data';
|
3838 |
+
}
|
3839 |
+
return $response;
|
3840 |
+
}
|
3841 |
+
|
3842 |
+
/** Change Default HeartBeat API Pulse Time */
|
3843 |
+
function yks_mc_tweak_heartbeat_settings( $settings ) {
|
3844 |
+
$settings['interval'] = 45; //Anything between 15-60
|
3845 |
+
return $settings;
|
3846 |
+
}
|
3847 |
+
|
3848 |
+
/*******************************************************
|
3849 |
+
Custom Dashboard MailChimp Account Activity Widget
|
3850 |
+
********************************************************/
|
3851 |
+
/**
|
3852 |
+
* Add a widget to the dashboard.
|
3853 |
+
*
|
3854 |
+
* This function is hooked into the 'wp_dashboard_setup' action below.
|
3855 |
+
*/
|
3856 |
+
function yks_mc_add_chimp_chatter_dashboard_widget() {
|
3857 |
+
wp_add_dashboard_widget(
|
3858 |
+
'yks_mc_account_activity_widget', // Widget slug.
|
3859 |
+
'MailChimp Account Activity', // Title.
|
3860 |
+
array( &$this , 'yks_mc_chimp_chatter_dashboard_widget_function' ) // Display function.
|
3861 |
+
);
|
3862 |
+
}
|
3863 |
+
|
3864 |
+
/**
|
3865 |
+
* Create the function to output the contents of our Dashboard Widget.
|
3866 |
+
*/
|
3867 |
+
function yks_mc_chimp_chatter_dashboard_widget_function() {
|
3868 |
+
include YKSEME_PATH . 'lib/inc/yks-mc-heartbeat-widget-functions.php';
|
3869 |
+
}
|
3870 |
+
|
3871 |
+
|
3872 |
+
// help , review container
|
3873 |
+
public function help_review_container() {
|
3874 |
+
?>
|
3875 |
+
<div id="yks_mc_review_this_plugin_container">
|
3876 |
+
<a href="https://github.com/yikesinc/yikes-inc-easy-mailchimp-extender/issues?state=open" target="_blank">
|
3877 |
+
<span class="yks_mc_need_support">
|
3878 |
+
<strong>
|
3879 |
+
<?php _e( 'Need Help?', 'yikes-inc-easy-mailchimp-extender' ); ?> <br />
|
3880 |
+
<?php _e( 'Get In Contact!', 'yikes-inc-easy-mailchimp-extender' ); ?> <br />
|
3881 |
+
<div class="dashicons dashicons-plus-alt"></div>
|
3882 |
+
</strong>
|
3883 |
+
</span>
|
3884 |
+
</a>
|
3885 |
+
<a href="http://wordpress.org/support/view/plugin-reviews/yikes-inc-easy-mailchimp-extender" target="_blank">
|
3886 |
+
<span class="yks_mc_leave_us_a_review">
|
3887 |
+
<strong>
|
3888 |
+
<?php _e( 'Loving the plugin?', 'yikes-inc-easy-mailchimp-extender' ); ?> <br />
|
3889 |
+
<?php _e( 'Leave us a nice review', 'yikes-inc-easy-mailchimp-extender' ); ?> <br />
|
3890 |
+
<div class="dashicons dashicons-star-filled"></div><div class="dashicons dashicons-star-filled"></div><div class="dashicons dashicons-star-filled"></div><div class="dashicons dashicons-star-filled"></div><div class="dashicons dashicons-star-filled"></div>
|
3891 |
+
</strong>
|
3892 |
+
</span>
|
3893 |
+
</a>
|
3894 |
+
<a href="http://www.yikesinc.com" target="_blank" class="yks_header_logo">
|
3895 |
+
<img src="<?php echo plugins_url().'/yikes-inc-easy-mailchimp-extender/images/yikes_logo.png'; ?>" alt="YIKES Inc. Logo" width=85 title="YIKES Inc. Logo" />
|
3896 |
+
</a>
|
3897 |
+
</div>
|
3898 |
+
<?php
|
3899 |
+
}
|
3900 |
+
|
3901 |
+
|
3902 |
+
/**
|
3903 |
+
Write our errors to an error log for display to the user
|
3904 |
+
- should help minimize number of requests we receive, or at least help us diagnose user issues better
|
3905 |
+
**/
|
3906 |
+
|
3907 |
+
/*
|
3908 |
+
* writeErrorToErrorLog()
|
3909 |
+
* parameters: $errorResponse
|
3910 |
+
* writes a returned API error to our log for display
|
3911 |
+
*
|
3912 |
+
* @since 5.2
|
3913 |
+
*/
|
3914 |
+
public function writeErrorToErrorLog( $errorResponse ) {
|
3915 |
+
// make sure file_get_contents and file_put_contents are available
|
3916 |
+
if ( function_exists( 'file_get_contents' ) && function_exists( 'file_put_contents' ) ) {
|
3917 |
+
$error_occurance_time = current_time( 'M' ) . '. ' . current_time( 'jS' ) . ', ' . current_time( 'Y' ) . ' - ' . current_time( 'g:i:sa' );
|
3918 |
+
$error_log_location = YKSEME_PATH . 'lib/error_log/yks_mc_error_log.php';
|
3919 |
+
$current_contents = file_get_contents( $error_log_location );
|
3920 |
+
// get total count of errors, we only want to limit to 8 latest errors
|
3921 |
+
$total_errors = explode( '<tr>' , $current_contents );
|
3922 |
+
$error_array = array();
|
3923 |
+
$i = 0;
|
3924 |
+
foreach( $total_errors as $error ) {
|
3925 |
+
$error_array[] = $error;
|
3926 |
+
// limit the error log to the latest 10 errors
|
3927 |
+
if ( ++$i == 11 ) {
|
3928 |
+
break;
|
3929 |
+
}
|
3930 |
+
}
|
3931 |
+
$new_content = '<tr>
|
3932 |
+
<td>' . $errorResponse->getMessage() . '</td>
|
3933 |
+
<td>' . $error_occurance_time . '</td>
|
3934 |
+
</tr>' . implode( '<tr>' , $error_array );
|
3935 |
+
file_put_contents( $error_log_location , $new_content );
|
3936 |
+
}
|
3937 |
+
}
|
3938 |
+
|
3939 |
+
/*
|
3940 |
+
* ytks_mc_generate_error_log_table()
|
3941 |
+
* generate our erorr log table on the options settings page
|
3942 |
+
*
|
3943 |
+
* @since 5.2
|
3944 |
+
*/
|
3945 |
+
public function yks_mc_generate_error_log_table() {
|
3946 |
+
$error_log_contents = file_get_contents( YKSEME_PATH . 'lib/error_log/yks_mc_error_log.php' , true );
|
3947 |
+
if ( $error_log_contents != '' ) {
|
3948 |
+
return $error_log_contents;
|
3949 |
+
}
|
3950 |
+
}
|
3951 |
+
|
3952 |
+
/*
|
3953 |
+
* clearYksMCErrorLog()
|
3954 |
+
* clear the error log of all errors
|
3955 |
+
*
|
3956 |
+
* @since 5.2
|
3957 |
+
*/
|
3958 |
+
public function clearYksMCErrorLog() {
|
3959 |
+
echo 'running';
|
3960 |
+
try {
|
3961 |
+
$clear_contents = file_put_contents( YKSEME_PATH . 'lib/error_log/yks_mc_error_log.php' , '' );
|
3962 |
+
} catch ( Exception $e ) {
|
3963 |
+
return $e->getMessage();
|
3964 |
+
$this->writeErrorToErrorLog( $e );
|
3965 |
+
}
|
3966 |
+
}
|
3967 |
+
|
3968 |
+
} // end class
|
3969 |
+
} // end class check
|
3970 |
?>
|
composer.json
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"require": {
|
3 |
-
"facebook/webdriver": "dev-master"
|
4 |
-
},
|
5 |
-
"require-dev": {
|
6 |
-
"phpunit/phpunit": "3.7.*"
|
7 |
-
}
|
8 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: yikesinc, hiwhatsup, liljimmi, eherman24, seriouslysean
|
|
3 |
Donate link: http://yikesinc.com
|
4 |
Tags: mailchimp, marketing, email, mailing lists, newsletter, sign up, forms, sign up form
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to: 4.3
|
7 |
-
Stable tag: 5.4.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Easy MailChimp Forms allows you to painlessly add MailChimp sign up forms to your WordPress site and track user activity with interactive reports.
|
@@ -835,6 +835,9 @@ These functions should be used in conjunction with the `yikes_mc_get_form_data`
|
|
835 |
|
836 |
== Changelog ==
|
837 |
|
|
|
|
|
|
|
838 |
= 5.4.3 - March 17th, 2015 =
|
839 |
|
840 |
* Fixed: Re-import form fields function not properly refreshing the page
|
@@ -1136,6 +1139,9 @@ These functions should be used in conjunction with the `yikes_mc_get_form_data`
|
|
1136 |
|
1137 |
== Upgrade Notice ==
|
1138 |
|
|
|
|
|
|
|
1139 |
= 5.4.3 - March 17th, 2015 =
|
1140 |
* Fixed: Re-import form fields function not properly refreshing the page
|
1141 |
* Fixed: Updating a MailChimp list field no longer throws an empty error
|
3 |
Donate link: http://yikesinc.com
|
4 |
Tags: mailchimp, marketing, email, mailing lists, newsletter, sign up, forms, sign up form
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 4.3.1
|
7 |
+
Stable tag: 5.4.4
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
Easy MailChimp Forms allows you to painlessly add MailChimp sign up forms to your WordPress site and track user activity with interactive reports.
|
835 |
|
836 |
== Changelog ==
|
837 |
|
838 |
+
= 5.4.4 - September 24th, 2015 =
|
839 |
+
* Added: Admin notice to warn about the upcoming release (major re-write)
|
840 |
+
|
841 |
= 5.4.3 - March 17th, 2015 =
|
842 |
|
843 |
* Fixed: Re-import form fields function not properly refreshing the page
|
1139 |
|
1140 |
== Upgrade Notice ==
|
1141 |
|
1142 |
+
= 5.4.4 - September 24th, 2015 =
|
1143 |
+
* Added: Admin notice to warn about the upcoming release (major re-write)
|
1144 |
+
|
1145 |
= 5.4.3 - March 17th, 2015 =
|
1146 |
* Fixed: Re-import form fields function not properly refreshing the page
|
1147 |
* Fixed: Updating a MailChimp list field no longer throws an empty error
|
yikes-inc-easy-mailchimp-extender.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Easy MailChimp Forms
|
5 |
Plugin URI: http://www.yikesinc.com/services/yikes-inc-easy-mailchimp-extender/
|
6 |
Description: Mailchimp integration in the form of a shortcode, php snippet or widget. Now track account status, campaign stats, view subscribers and so much more!
|
7 |
-
Version: 5.4.
|
8 |
Author: YIKES Inc
|
9 |
Author URI: http://yikesinc.com
|
10 |
License: GPL3
|
@@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
30 |
|
31 |
/** Configuration **/
|
32 |
if(!defined('YKSEME_DEBUG')) define('YKSEME_DEBUG', false);
|
33 |
-
if(!defined('YKSEME_VERSION_CURRENT')) define('YKSEME_VERSION_CURRENT', '5.4.
|
34 |
if(!defined('YKSEME_REQ_PHP')) define('YKSEME_REQ_PHP', '5.0');
|
35 |
if(!defined('YKSEME_AUTHOR')) define('YKSEME_AUTHOR', 'YIKES Inc');
|
36 |
if(!defined('YKSEME_SITE')) define('YKSEME_SITE', site_url().'/');
|
4 |
Plugin Name: Easy MailChimp Forms
|
5 |
Plugin URI: http://www.yikesinc.com/services/yikes-inc-easy-mailchimp-extender/
|
6 |
Description: Mailchimp integration in the form of a shortcode, php snippet or widget. Now track account status, campaign stats, view subscribers and so much more!
|
7 |
+
Version: 5.4.4
|
8 |
Author: YIKES Inc
|
9 |
Author URI: http://yikesinc.com
|
10 |
License: GPL3
|
30 |
|
31 |
/** Configuration **/
|
32 |
if(!defined('YKSEME_DEBUG')) define('YKSEME_DEBUG', false);
|
33 |
+
if(!defined('YKSEME_VERSION_CURRENT')) define('YKSEME_VERSION_CURRENT', '5.4.4');
|
34 |
if(!defined('YKSEME_REQ_PHP')) define('YKSEME_REQ_PHP', '5.0');
|
35 |
if(!defined('YKSEME_AUTHOR')) define('YKSEME_AUTHOR', 'YIKES Inc');
|
36 |
if(!defined('YKSEME_SITE')) define('YKSEME_SITE', site_url().'/');
|