Boxzilla - Version 3.0

Version Description

Download this release

Release Info

Developer DvanKooten
Plugin Icon 128x128 Boxzilla
Version 3.0
Comparing to
See all releases

Version 3.0

Files changed (70) hide show
  1. LICENSE +339 -0
  2. assets/browserify/admin-script.js +1 -0
  3. assets/browserify/admin/_admin.js +117 -0
  4. assets/browserify/admin/_designer.js +109 -0
  5. assets/browserify/admin/_option.js +56 -0
  6. assets/browserify/script.js +54 -0
  7. assets/css/admin-styles.css +154 -0
  8. assets/css/admin-styles.min.css +1 -0
  9. assets/css/index.php +7 -0
  10. assets/css/styles.css +99 -0
  11. assets/css/styles.min.css +1 -0
  12. assets/img/index.php +6 -0
  13. assets/img/menu-icon.jpg +0 -0
  14. assets/img/menu-icon.png +0 -0
  15. assets/index.php +6 -0
  16. assets/js/admin-script.js +766 -0
  17. assets/js/admin-script.min.js +2 -0
  18. assets/js/admin-script.min.js.map +1 -0
  19. assets/js/index.php +6 -0
  20. assets/js/script.js +1065 -0
  21. assets/js/script.min.js +2 -0
  22. assets/js/script.min.js.map +1 -0
  23. bootstrap.php +67 -0
  24. boxzilla.php +64 -0
  25. languages/scroll-triggered-boxes-es_ES.mo +0 -0
  26. languages/scroll-triggered-boxes-es_ES.po +212 -0
  27. languages/scroll-triggered-boxes-nl_NL.mo +0 -0
  28. languages/scroll-triggered-boxes-nl_NL.po +209 -0
  29. languages/scroll-triggered-boxes.mo +0 -0
  30. languages/scroll-triggered-boxes.po +203 -0
  31. readme.txt +162 -0
  32. src/admin/class-admin.php +720 -0
  33. src/admin/class-autocomplete.php +80 -0
  34. src/admin/class-installer.php +93 -0
  35. src/admin/class-migrations.php +82 -0
  36. src/admin/class-notices.php +42 -0
  37. src/admin/views/extensions.php +60 -0
  38. src/admin/views/metaboxes/box-appearance-controls.php +46 -0
  39. src/admin/views/metaboxes/box-option-controls.php +162 -0
  40. src/admin/views/metaboxes/email-optin.php +22 -0
  41. src/admin/views/metaboxes/need-help.php +3 -0
  42. src/admin/views/settings.php +56 -0
  43. src/class-box.php +222 -0
  44. src/class-boxzilla-service-provider.php +61 -0
  45. src/class-boxzilla.php +16 -0
  46. src/class-collection.php +81 -0
  47. src/class-loader.php +293 -0
  48. src/class-php-fallback.php +62 -0
  49. src/class-plugin.php +109 -0
  50. src/default-filters.php +10 -0
  51. src/di/class-container-with-property-access.php +23 -0
  52. src/di/class-container.php +281 -0
  53. src/di/interface-service-provider.php +46 -0
  54. src/functions.php +16 -0
  55. src/licensing/class-api.php +166 -0
  56. src/licensing/class-authenticator.php +56 -0
  57. src/licensing/class-license-manager.php +111 -0
  58. src/licensing/class-license-service-provider.php +43 -0
  59. src/licensing/class-license.php +188 -0
  60. src/licensing/class-update-manager.php +200 -0
  61. src/licensing/views/license-form.php +52 -0
  62. vendor/autoload.php +7 -0
  63. vendor/composer/ClassLoader.php +413 -0
  64. vendor/composer/LICENSE +21 -0
  65. vendor/composer/autoload_classmap.php +30 -0
  66. vendor/composer/autoload_files.php +10 -0
  67. vendor/composer/autoload_namespaces.php +9 -0
  68. vendor/composer/autoload_psr4.php +10 -0
  69. vendor/composer/autoload_real.php +59 -0
  70. vendor/composer/installed.json +104 -0
LICENSE ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ {description}
294
+ Copyright (C) {year} {fullname}
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ {signature of Ty Coon}, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
assets/browserify/admin-script.js ADDED
@@ -0,0 +1 @@
 
1
+ window.Boxzilla_Admin = require('./admin/_admin.js');
assets/browserify/admin/_admin.js ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ var $ = window.jQuery;
4
+ var Option = require('./_option.js');
5
+ var optionControls = document.getElementById('boxzilla-box-options-controls');
6
+ var $optionControls = $(optionControls);
7
+
8
+ // sanity check, are we on the correct page?
9
+ if( $optionControls.length === 0 ) {
10
+ return;
11
+ }
12
+
13
+ var EventEmitter = require('wolfy87-eventemitter');
14
+ var events = new EventEmitter();
15
+ var Designer = require('./_designer.js')($, Option, events);
16
+ var rowTemplate = wp.template('rule-row-template');
17
+ var i18n = boxzilla_i18n;
18
+
19
+ // events
20
+ $optionControls.on('click', ".boxzilla-add-rule", addRuleFields);
21
+ $optionControls.on('click', ".boxzilla-remove-rule", removeRule);
22
+ $optionControls.on('change', ".boxzilla-rule-condition", setContextualHelpers);
23
+ $optionControls.find('.boxzilla-auto-show-trigger').on('change', toggleTriggerOptions );
24
+
25
+ $(window).load(function() {
26
+ if( typeof(window.tinyMCE) === "undefined" ) {
27
+ document.getElementById('notice-notinymce').style.display = '';
28
+ }
29
+ });
30
+
31
+ // call contextual helper method for each row
32
+ $('.boxzilla-rule-row').each(setContextualHelpers);
33
+
34
+ function toggleTriggerOptions() {
35
+ $optionControls.find('.boxzilla-trigger-options').toggle( this.value !== '' );
36
+ }
37
+
38
+ function removeRule() {
39
+ $(this).parents('tr').remove();
40
+ }
41
+
42
+ function setContextualHelpers() {
43
+
44
+ var context = ( this.tagName.toLowerCase() === "tr" ) ? this : $(this).parents('tr').get(0);
45
+ var condition = context.querySelector('.boxzilla-rule-condition').value;
46
+ var valueInput = context.querySelector('.boxzilla-rule-value');
47
+ var qualifierInput = context.querySelector('.boxzilla-rule-qualifier');
48
+ var betterInput = valueInput.cloneNode(true);
49
+ var $betterInput = $(betterInput);
50
+
51
+ // remove previously added helpers
52
+ $(context.querySelectorAll('.boxzilla-helper')).remove();
53
+
54
+ // prepare better input
55
+ betterInput.removeAttribute('name');
56
+ betterInput.className = betterInput.className + ' boxzilla-helper';
57
+ valueInput.parentNode.insertBefore(betterInput, valueInput.nextSibling);
58
+ $betterInput.change(function() { valueInput.value = this.value; });
59
+
60
+ betterInput.style.display = '';
61
+ valueInput.style.display = 'none';
62
+ qualifierInput.style.display = '';
63
+
64
+ // change placeholder for textual help
65
+ switch(condition) {
66
+ default:
67
+ betterInput.placeholder = i18n.enterCommaSeparatedValues;
68
+ break;
69
+
70
+ case '':
71
+ case 'everywhere':
72
+ qualifierInput.value = '';
73
+ valueInput.value = '';
74
+ betterInput.style.display = 'none';
75
+ qualifierInput.style.display = 'none';
76
+ break;
77
+
78
+ case 'is_single':
79
+ case 'is_post':
80
+ betterInput.placeholder = i18n.enterCommaSeparatedPosts;
81
+ $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post", {multiple:true, multipleSep: ","});
82
+ break;
83
+
84
+ case 'is_page':
85
+ betterInput.placeholder = i18n.enterCommaSeparatedPages;
86
+ $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=page", {multiple:true, multipleSep: ","});
87
+ break;
88
+
89
+ case 'is_post_type':
90
+ betterInput.placeholder = i18n.enterCommaSeparatedPostTypes;
91
+ $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post_type", {multiple:true, multipleSep: ","});
92
+ break;
93
+
94
+ case 'is_url':
95
+ betterInput.placeholder = i18n.enterCommaSeparatedRelativeUrls;
96
+ break;
97
+
98
+ case 'is_post_in_category':
99
+ $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=category", {multiple:true, multipleSep: ","});
100
+ break;
101
+ }
102
+ }
103
+
104
+ function addRuleFields() {
105
+ var data = {
106
+ 'key': optionControls.querySelectorAll('.boxzilla-rule-row').length
107
+ };
108
+ var html = rowTemplate(data);
109
+ $(document.getElementById('boxzilla-box-rules')).after(html);
110
+ return false;
111
+ }
112
+
113
+ module.exports = {
114
+ 'Designer': Designer,
115
+ 'Option': Option,
116
+ 'events': events
117
+ };
assets/browserify/admin/_designer.js ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var Designer = function($, Option, events) {
2
+
3
+ // vars
4
+ var boxId = document.getElementById('post_ID').value || 0,
5
+ $editor, $editorFrame,
6
+ $innerEditor,
7
+ options = {},
8
+ visualEditorInitialised = false;
9
+
10
+ var $appearanceControls = $("#boxzilla-box-appearance-controls");
11
+
12
+ // create Option objects
13
+ options.borderColor = new Option('border-color');
14
+ options.borderWidth = new Option('border-width');
15
+ options.borderStyle = new Option('border-style');
16
+ options.backgroundColor = new Option('background-color');
17
+ options.width = new Option('width');
18
+ options.color = new Option('color');
19
+
20
+ // functions
21
+ function init() {
22
+
23
+ // Only run if TinyMCE has actually inited
24
+ if( typeof( window.tinyMCE ) !== "object" || tinyMCE.get('content') === null ) {
25
+ return;
26
+ }
27
+
28
+ // add classes to TinyMCE <html>
29
+ $editorFrame = $("#content_ifr");
30
+ $editor = $editorFrame.contents().find('html');
31
+ $editor.css({
32
+ 'background': 'white'
33
+ });
34
+
35
+ // add content class and padding to TinyMCE <body>
36
+ $innerEditor = $editor.find('#tinymce');
37
+ $innerEditor.addClass('boxzilla boxzilla-' + boxId);
38
+ $innerEditor.css({
39
+ 'margin': 0,
40
+ 'background': 'white',
41
+ 'display': 'inline-block',
42
+ 'width': 'auto',
43
+ 'min-width': '240px',
44
+ 'position': 'relative'
45
+ });
46
+ $innerEditor.get(0).style.cssText += ';padding: 25px !important;';
47
+
48
+ visualEditorInitialised = true;
49
+
50
+ /* @since 2.0.3 */
51
+ events.trigger('editor.init');
52
+ }
53
+
54
+ /**
55
+ * Applies the styles from the options to the TinyMCE Editor
56
+ *
57
+ * @return bool
58
+ */
59
+ function applyStyles() {
60
+
61
+ if( ! visualEditorInitialised ) {
62
+ return false;
63
+ }
64
+
65
+ // apply styles from CSS editor
66
+ $innerEditor.css({
67
+ 'border-color': options.borderColor.getColorValue(), //getColorValue( 'borderColor', '' ),
68
+ 'border-width': options.borderWidth.getPxValue(), //getPxValue( 'borderWidth', '' ),
69
+ 'border-style': options.borderStyle.getValue(), //getValue('borderStyle', '' ),
70
+ 'background-color': options.backgroundColor.getColorValue(), //getColorValue( 'backgroundColor', ''),
71
+ 'width': options.width.getPxValue(), //getPxValue( 'width', 'auto' ),
72
+ 'color': options.color.getColorValue() // getColorValue( 'color', '' )
73
+ });
74
+
75
+ /* @since 2.0.3 */
76
+ events.trigger('editor.styles.apply');
77
+
78
+ return true;
79
+ }
80
+
81
+ function resetStyles() {
82
+ for( var key in options ) {
83
+ if( key.substring(0,5) === 'theme' ) {
84
+ continue;
85
+ }
86
+
87
+ options[key].clear();
88
+ }
89
+ applyStyles();
90
+
91
+ /* @since 2.0.3 */
92
+ events.trigger('editor.styles.reset');
93
+ }
94
+
95
+ // event binders
96
+ $appearanceControls.find('input.boxzilla-color-field').wpColorPicker({ change: applyStyles, clear: applyStyles });
97
+ $appearanceControls.find(":input").not(".boxzilla-color-field").change(applyStyles);
98
+ events.on('editor.init', applyStyles);
99
+
100
+ // public methods
101
+ return {
102
+ 'init': init,
103
+ 'resetStyles': resetStyles,
104
+ 'options': options
105
+ };
106
+
107
+ };
108
+
109
+ module.exports = Designer;
assets/browserify/admin/_option.js ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ var $ = window.jQuery;
4
+
5
+ var Option = function( element ) {
6
+
7
+ // find corresponding element
8
+ if( typeof(element) == "string" ) {
9
+ element = document.getElementById('boxzilla-' + element);
10
+ }
11
+
12
+ if( ! element ) {
13
+ console.error("Unable to find option element.");
14
+ }
15
+
16
+ this.element = element;
17
+ };
18
+
19
+ Option.prototype.getColorValue = function() {
20
+ if( this.element.value.length > 0 ) {
21
+ if( $(this.element).hasClass('wp-color-field')) {
22
+ return $(this.element).wpColorPicker('color');
23
+ } else {
24
+ return this.element.value;
25
+ }
26
+ }
27
+
28
+ return '';
29
+ };
30
+
31
+ Option.prototype.getPxValue = function( fallbackValue ) {
32
+ if( this.element.value.length > 0 ) {
33
+ return parseInt( this.element.value ) + "px";
34
+ }
35
+
36
+ return fallbackValue || '';
37
+ };
38
+
39
+ Option.prototype.getValue = function( fallbackValue ) {
40
+
41
+ if( this.element.value.length > 0 ) {
42
+ return this.element.value;
43
+ }
44
+
45
+ return fallbackValue || '';
46
+ };
47
+
48
+ Option.prototype.clear = function() {
49
+ this.element.value = '';
50
+ };
51
+
52
+ Option.prototype.setValue = function(value) {
53
+ this.element.value = value;
54
+ };
55
+
56
+ module.exports = Option;
assets/browserify/script.js ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ var Boxzilla = require('boxzilla');
4
+ var options = window.boxzilla_options;
5
+ var isLoggedIn = document.body.className.indexOf('logged-in') > -1;
6
+
7
+ // print message when test mode is enabled
8
+ if( isLoggedIn && options.testMode ) {
9
+ console.log( 'Boxzilla: Test mode is enabled. Please disable test mode if you\'re done testing.' );
10
+ }
11
+
12
+ // init boxzilla
13
+ Boxzilla.init();
14
+
15
+ // create boxes from options
16
+ for( var i=0; i < options.boxes.length; i++ ) {
17
+ // get opts
18
+ var boxOpts = options.boxes[i];
19
+ boxOpts.testMode = isLoggedIn && options.testMode;
20
+
21
+ // create box
22
+ var box = Boxzilla.create( boxOpts.id, boxOpts);
23
+
24
+ // add custom css to box
25
+ css(box.element, boxOpts.css);
26
+ }
27
+
28
+ function css(element, styles) {
29
+ if( styles.background_color ) {
30
+ element.style.background = styles.background_color;
31
+ }
32
+
33
+ if( styles.color ) {
34
+ element.style.color = styles.color;
35
+ }
36
+
37
+ if( styles.border_color ) {
38
+ element.style.borderColor = styles.border_color;
39
+ }
40
+
41
+ if( styles.border_width ) {
42
+ element.style.borderWidth = parseInt(styles.border_width) + "px";
43
+ }
44
+
45
+ if( styles.border_style ) {
46
+ element.style.borderStyle = styles.border_style;
47
+ }
48
+
49
+ if( styles.width ) {
50
+ element.style.maxWidth = parseInt(styles.width) + "px";
51
+ }
52
+ }
53
+
54
+ window.Boxzilla = Boxzilla;
assets/css/admin-styles.css ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* first row can't be deleted */
2
+ .boxzilla-rule-row-0 .boxzilla-close{
3
+ visibility: hidden;
4
+ }
5
+
6
+ .column-box_id {
7
+ width: 80px;
8
+ }
9
+
10
+ .boxzilla-sm {
11
+ width:150px;
12
+ }
13
+
14
+ .boxzilla-xsm {
15
+ width: 15px;
16
+ }
17
+
18
+ .boxzilla-title{
19
+ margin-top:2em !important;
20
+ }
21
+
22
+ .boxzilla-label{
23
+ display:block;
24
+ font-weight: bold;
25
+ margin-bottom:6px;
26
+ }
27
+
28
+ .boxzilla-close{
29
+ padding: 0;
30
+ cursor: pointer;
31
+ background: transparent;
32
+ border: 0;
33
+ -webkit-appearance: none;
34
+ font-size: 21px;
35
+ font-weight: bold;
36
+ line-height: 26px;
37
+ text-shadow: 0 1px 0 #fff;
38
+ opacity: .3;
39
+ filter: alpha(opacity=30);
40
+ }
41
+
42
+ .boxzilla-close:hover, .boxzilla-close:focus {
43
+ color: #000;
44
+ text-decoration: none;
45
+ cursor: pointer;
46
+ opacity: .6;
47
+ filter: alpha(opacity=60);
48
+ }
49
+
50
+ .post-type-boxzilla-box .form-table{
51
+ table-layout:fixed;
52
+ }
53
+
54
+ .post-type-boxzilla-box .wp-picker-container{
55
+ white-space: nowrap;
56
+ }
57
+
58
+ .post-type-boxzilla-box .wp-picker-clear,
59
+ .post-type-boxzilla-box .wp-picker-holder,
60
+ .post-type-boxzilla-box .wp-picker-input-wrap {
61
+ background:white;
62
+ z-index: 999 !important;
63
+ position: absolute !important;
64
+ }
65
+
66
+ #boxzilla-admin .status {
67
+ display: inline-block;
68
+ padding: 3px 6px;
69
+ color: white;
70
+ text-transform: uppercase;
71
+ font-weight: bold;
72
+ }
73
+
74
+ #boxzilla-admin .status.positive {
75
+ background-color: limeGreen;
76
+ }
77
+
78
+ #boxzilla-admin .status.negative {
79
+ background: #c3c3c3;
80
+ }
81
+
82
+ /* Radio Switches */
83
+ .radio-label {
84
+ font-weight: normal;
85
+ }
86
+
87
+ .radio-label > input {
88
+ margin-top: 0 !important;
89
+ }
90
+
91
+ /** Grid */
92
+ .boxzilla-row{
93
+ margin: 0 -20px;
94
+ }
95
+
96
+ .boxzilla-col-one-third,
97
+ .boxzilla-col-two-third {
98
+ float: left;
99
+ -webkit-box-sizing: border-box;
100
+ box-sizing: border-box;
101
+ padding: 0 20px;
102
+ }
103
+
104
+ .boxzilla-col-two-third {
105
+ width: 66.66%;
106
+ }
107
+
108
+ .boxzilla-col-one-third{
109
+ width: 33.33%;
110
+ }
111
+
112
+
113
+ /* admin sidebar */
114
+ .boxzilla-sidebar{
115
+ margin-top: 10px;
116
+ }
117
+
118
+ .boxzilla-box {
119
+ background: white;
120
+ padding: 20px;
121
+ margin-bottom: 20px;
122
+ border: 1px solid #ccc;
123
+ }
124
+
125
+ .boxzilla-box h3,
126
+ .boxzilla-box:first-child {
127
+ margin-top: 0;
128
+ }
129
+
130
+ .boxzilla-box:last-child {
131
+ margin-bottom: 0;
132
+ }
133
+
134
+ .boxzilla-sidebar form label {
135
+ display: block;
136
+ font-weight: bold;
137
+ margin-bottom: 6px;
138
+ }
139
+
140
+ @media( max-width: 920px ) {
141
+ .boxzilla-row {
142
+ margin: 0;
143
+ }
144
+ .boxzilla-col-one-third,
145
+ .boxzilla-col-two-third {
146
+ float: none;
147
+ padding: 0;
148
+ width: auto;
149
+ }
150
+
151
+ .boxzilla-sidebar {
152
+ margin-top: 40px;
153
+ }
154
+ }
assets/css/admin-styles.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .boxzilla-rule-row-0 .boxzilla-close{visibility:hidden}.column-box_id{width:80px}.boxzilla-sm{width:150px}.boxzilla-xsm{width:15px}.boxzilla-title{margin-top:2em!important}.boxzilla-label{display:block;font-weight:700;margin-bottom:6px}.boxzilla-close{padding:0;cursor:pointer;background:0 0;border:0;-webkit-appearance:none;font-size:21px;font-weight:700;line-height:26px;text-shadow:0 1px 0 #fff;opacity:.3;filter:alpha(opacity=30)}.boxzilla-close:focus,.boxzilla-close:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.6;filter:alpha(opacity=60)}.post-type-boxzilla-box .form-table{table-layout:fixed}.post-type-boxzilla-box .wp-picker-container{white-space:nowrap}.post-type-boxzilla-box .wp-picker-clear,.post-type-boxzilla-box .wp-picker-holder,.post-type-boxzilla-box .wp-picker-input-wrap{background:#fff;z-index:999!important;position:absolute!important}#boxzilla-admin .status{display:inline-block;padding:3px 6px;color:#fff;text-transform:uppercase;font-weight:700}#boxzilla-admin .status.positive{background-color:#32cd32}#boxzilla-admin .status.negative{background:#c3c3c3}.radio-label{font-weight:400}.radio-label>input{margin-top:0!important}.boxzilla-row{margin:0 -20px}.boxzilla-col-one-third,.boxzilla-col-two-third{float:left;-webkit-box-sizing:border-box;box-sizing:border-box;padding:0 20px}.boxzilla-col-two-third{width:66.66%}.boxzilla-col-one-third{width:33.33%}.boxzilla-sidebar{margin-top:10px}.boxzilla-box{background:#fff;padding:20px;margin-bottom:20px;border:1px solid #ccc}.boxzilla-box h3,.boxzilla-box:first-child{margin-top:0}.boxzilla-box:last-child{margin-bottom:0}.boxzilla-sidebar form label{display:block;font-weight:700;margin-bottom:6px}@media(max-width:920px){.boxzilla-row{margin:0}.boxzilla-col-one-third,.boxzilla-col-two-third{float:none;padding:0;width:auto}.boxzilla-sidebar{margin-top:40px}}
assets/css/index.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if( ! defined( 'STB::VERSION' ) ) {
4
+ header( 'Status: 403 Forbidden' );
5
+ header( 'HTTP/1.1 403 Forbidden' );
6
+ exit;
7
+ }
assets/css/styles.css ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ html,
2
+ body {
3
+ min-height: 100%;
4
+ height: auto;
5
+ }
6
+
7
+ .boxzilla-center-container {
8
+ position: fixed;
9
+ top: 0;
10
+ left: 0;
11
+ right: 0;
12
+ height: 0;
13
+ text-align: center;
14
+ z-index: 999999;
15
+ line-height: 0;
16
+ }
17
+
18
+ .boxzilla-center-container .boxzilla{
19
+ display: inline-block;
20
+ text-align: left;
21
+ position: relative;
22
+ }
23
+
24
+ .boxzilla {
25
+ position: fixed;
26
+ z-index: 999999;
27
+ margin: 0;
28
+ -webkit-box-sizing: border-box;
29
+ -moz-box-sizing: border-box;
30
+ box-sizing: border-box;
31
+ background: white;
32
+
33
+ /* reset line-height because of container line-height hack */
34
+ line-height: normal;
35
+ padding: 25px;
36
+ }
37
+
38
+ .boxzilla.boxzilla-top-left{
39
+ top: 0; left: 0; bottom: auto; right: auto;
40
+ }
41
+
42
+ .boxzilla.boxzilla-top-right{
43
+ top: 0; right: 0; bottom: auto; left: auto;
44
+ }
45
+
46
+ .boxzilla.boxzilla-bottom-left{
47
+ bottom: 0; left: 0; top: auto; right: auto;
48
+ }
49
+
50
+ .boxzilla.boxzilla-bottom-right{
51
+ bottom: 0; right: 0; top: auto; left: auto;
52
+ }
53
+
54
+ /* remove top & bottom margin from last child element */
55
+ .boxzilla-content > *:first-child {
56
+ margin-top: 0;
57
+ padding-top: 0;
58
+ }
59
+ .boxzilla-content > *:last-child {
60
+ margin-bottom: 0;
61
+ padding-bottom: 0;
62
+ }
63
+
64
+ .boxzilla-close-icon {
65
+ position:absolute;
66
+ right :0;
67
+ top: 0;
68
+ text-align:center;
69
+ padding: 6px;
70
+ cursor: pointer;
71
+ background: transparent;
72
+ border: 0;
73
+ -webkit-appearance: none;
74
+ font-size: 36px;
75
+ font-weight: bold;
76
+ line-height: 20px;
77
+ color: #000;
78
+ opacity: .5;
79
+ filter: alpha(opacity=50);
80
+ }
81
+
82
+ .boxzilla-close-icon:hover, .boxzilla-close-icon:focus {
83
+ color: #000;
84
+ text-decoration: none;
85
+ cursor: pointer;
86
+ opacity: .8;
87
+ filter: alpha(opacity=80);
88
+ }
89
+
90
+ #boxzilla-overlay {
91
+ position: fixed;
92
+ background: rgba(0,0,0,0.65);
93
+ width: 100%;
94
+ height: 100%;
95
+ z-index: 99999;
96
+ display: none;
97
+ top: 0;
98
+ left: 0;
99
+ }
assets/css/styles.min.css ADDED
@@ -0,0 +1 @@
 
1
+ body,html{min-height:100%;height:auto}.boxzilla-center-container{position:fixed;top:0;left:0;right:0;height:0;text-align:center;z-index:999999;line-height:0}.boxzilla-center-container .boxzilla{display:inline-block;text-align:left;position:relative}.boxzilla{position:fixed;z-index:999999;margin:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;background:#fff;line-height:normal;padding:25px}.boxzilla.boxzilla-top-left{top:0;left:0;bottom:auto;right:auto}.boxzilla.boxzilla-top-right{top:0;right:0;bottom:auto;left:auto}.boxzilla.boxzilla-bottom-left{bottom:0;left:0;top:auto;right:auto}.boxzilla.boxzilla-bottom-right{bottom:0;right:0;top:auto;left:auto}.boxzilla-content>:first-child{margin-top:0;padding-top:0}.boxzilla-content>:last-child{margin-bottom:0;padding-bottom:0}.boxzilla-close-icon{position:absolute;right:0;top:0;text-align:center;padding:6px;cursor:pointer;background:0 0;border:0;-webkit-appearance:none;font-size:36px;font-weight:700;line-height:20px;color:#000;opacity:.5;filter:alpha(opacity=50)}.boxzilla-close-icon:focus,.boxzilla-close-icon:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.8;filter:alpha(opacity=80)}#boxzilla-overlay{position:fixed;background:rgba(0,0,0,.65);width:100%;height:100%;z-index:99999;display:none;top:0;left:0}
assets/img/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ if( ! defined( 'STB::VERSION' ) ) {
3
+ header( 'Status: 403 Forbidden' );
4
+ header( 'HTTP/1.1 403 Forbidden' );
5
+ exit;
6
+ }
assets/img/menu-icon.jpg ADDED
Binary file
assets/img/menu-icon.png ADDED
Binary file
assets/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ if( ! defined( 'STB::VERSION' ) ) {
3
+ header( 'Status: 403 Forbidden' );
4
+ header( 'HTTP/1.1 403 Forbidden' );
5
+ exit;
6
+ }
assets/js/admin-script.js ADDED
@@ -0,0 +1,766 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function () { var require = undefined; var define = undefined; (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+ window.Boxzilla_Admin = require('./admin/_admin.js');
3
+ },{"./admin/_admin.js":2}],2:[function(require,module,exports){
4
+ 'use strict';
5
+
6
+ var $ = window.jQuery;
7
+ var Option = require('./_option.js');
8
+ var optionControls = document.getElementById('boxzilla-box-options-controls');
9
+ var $optionControls = $(optionControls);
10
+
11
+ // sanity check, are we on the correct page?
12
+ if( $optionControls.length === 0 ) {
13
+ return;
14
+ }
15
+
16
+ var EventEmitter = require('wolfy87-eventemitter');
17
+ var events = new EventEmitter();
18
+ var Designer = require('./_designer.js')($, Option, events);
19
+ var rowTemplate = wp.template('rule-row-template');
20
+ var i18n = boxzilla_i18n;
21
+
22
+ // events
23
+ $optionControls.on('click', ".boxzilla-add-rule", addRuleFields);
24
+ $optionControls.on('click', ".boxzilla-remove-rule", removeRule);
25
+ $optionControls.on('change', ".boxzilla-rule-condition", setContextualHelpers);
26
+ $optionControls.find('.boxzilla-auto-show-trigger').on('change', toggleTriggerOptions );
27
+
28
+ $(window).load(function() {
29
+ if( typeof(window.tinyMCE) === "undefined" ) {
30
+ document.getElementById('notice-notinymce').style.display = '';
31
+ }
32
+ });
33
+
34
+ // call contextual helper method for each row
35
+ $('.boxzilla-rule-row').each(setContextualHelpers);
36
+
37
+ function toggleTriggerOptions() {
38
+ $optionControls.find('.boxzilla-trigger-options').toggle( this.value !== '' );
39
+ }
40
+
41
+ function removeRule() {
42
+ $(this).parents('tr').remove();
43
+ }
44
+
45
+ function setContextualHelpers() {
46
+
47
+ var context = ( this.tagName.toLowerCase() === "tr" ) ? this : $(this).parents('tr').get(0);
48
+ var condition = context.querySelector('.boxzilla-rule-condition').value;
49
+ var valueInput = context.querySelector('.boxzilla-rule-value');
50
+ var qualifierInput = context.querySelector('.boxzilla-rule-qualifier');
51
+ var betterInput = valueInput.cloneNode(true);
52
+ var $betterInput = $(betterInput);
53
+
54
+ // remove previously added helpers
55
+ $(context.querySelectorAll('.boxzilla-helper')).remove();
56
+
57
+ // prepare better input
58
+ betterInput.removeAttribute('name');
59
+ betterInput.className = betterInput.className + ' boxzilla-helper';
60
+ valueInput.parentNode.insertBefore(betterInput, valueInput.nextSibling);
61
+ $betterInput.change(function() { valueInput.value = this.value; });
62
+
63
+ betterInput.style.display = '';
64
+ valueInput.style.display = 'none';
65
+ qualifierInput.style.display = '';
66
+
67
+ // change placeholder for textual help
68
+ switch(condition) {
69
+ default:
70
+ betterInput.placeholder = i18n.enterCommaSeparatedValues;
71
+ break;
72
+
73
+ case '':
74
+ case 'everywhere':
75
+ qualifierInput.value = '';
76
+ valueInput.value = '';
77
+ betterInput.style.display = 'none';
78
+ qualifierInput.style.display = 'none';
79
+ break;
80
+
81
+ case 'is_single':
82
+ case 'is_post':
83
+ betterInput.placeholder = i18n.enterCommaSeparatedPosts;
84
+ $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post", {multiple:true, multipleSep: ","});
85
+ break;
86
+
87
+ case 'is_page':
88
+ betterInput.placeholder = i18n.enterCommaSeparatedPages;
89
+ $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=page", {multiple:true, multipleSep: ","});
90
+ break;
91
+
92
+ case 'is_post_type':
93
+ betterInput.placeholder = i18n.enterCommaSeparatedPostTypes;
94
+ $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post_type", {multiple:true, multipleSep: ","});
95
+ break;
96
+
97
+ case 'is_url':
98
+ betterInput.placeholder = i18n.enterCommaSeparatedRelativeUrls;
99
+ break;
100
+
101
+ case 'is_post_in_category':
102
+ $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=category", {multiple:true, multipleSep: ","});
103
+ break;
104
+ }
105
+ }
106
+
107
+ function addRuleFields() {
108
+ var data = {
109
+ 'key': optionControls.querySelectorAll('.boxzilla-rule-row').length
110
+ };
111
+ var html = rowTemplate(data);
112
+ $(document.getElementById('boxzilla-box-rules')).after(html);
113
+ return false;
114
+ }
115
+
116
+ module.exports = {
117
+ 'Designer': Designer,
118
+ 'Option': Option,
119
+ 'events': events
120
+ };
121
+
122
+ },{"./_designer.js":3,"./_option.js":4,"wolfy87-eventemitter":5}],3:[function(require,module,exports){
123
+ var Designer = function($, Option, events) {
124
+
125
+ // vars
126
+ var boxId = document.getElementById('post_ID').value || 0,
127
+ $editor, $editorFrame,
128
+ $innerEditor,
129
+ options = {},
130
+ visualEditorInitialised = false;
131
+
132
+ var $appearanceControls = $("#boxzilla-box-appearance-controls");
133
+
134
+ // create Option objects
135
+ options.borderColor = new Option('border-color');
136
+ options.borderWidth = new Option('border-width');
137
+ options.borderStyle = new Option('border-style');
138
+ options.backgroundColor = new Option('background-color');
139
+ options.width = new Option('width');
140
+ options.color = new Option('color');
141
+
142
+ // functions
143
+ function init() {
144
+
145
+ // Only run if TinyMCE has actually inited
146
+ if( typeof( window.tinyMCE ) !== "object" || tinyMCE.get('content') === null ) {
147
+ return;
148
+ }
149
+
150
+ // add classes to TinyMCE <html>
151
+ $editorFrame = $("#content_ifr");
152
+ $editor = $editorFrame.contents().find('html');
153
+ $editor.css({
154
+ 'background': 'white'
155
+ });
156
+
157
+ // add content class and padding to TinyMCE <body>
158
+ $innerEditor = $editor.find('#tinymce');
159
+ $innerEditor.addClass('boxzilla boxzilla-' + boxId);
160
+ $innerEditor.css({
161
+ 'margin': 0,
162
+ 'background': 'white',
163
+ 'display': 'inline-block',
164
+ 'width': 'auto',
165
+ 'min-width': '240px',
166
+ 'position': 'relative'
167
+ });
168
+ $innerEditor.get(0).style.cssText += ';padding: 25px !important;';
169
+
170
+ visualEditorInitialised = true;
171
+
172
+ /* @since 2.0.3 */
173
+ events.trigger('editor.init');
174
+ }
175
+
176
+ /**
177
+ * Applies the styles from the options to the TinyMCE Editor
178
+ *
179
+ * @return bool
180
+ */
181
+ function applyStyles() {
182
+
183
+ if( ! visualEditorInitialised ) {
184
+ return false;
185
+ }
186
+
187
+ // apply styles from CSS editor
188
+ $innerEditor.css({
189
+ 'border-color': options.borderColor.getColorValue(), //getColorValue( 'borderColor', '' ),
190
+ 'border-width': options.borderWidth.getPxValue(), //getPxValue( 'borderWidth', '' ),
191
+ 'border-style': options.borderStyle.getValue(), //getValue('borderStyle', '' ),
192
+ 'background-color': options.backgroundColor.getColorValue(), //getColorValue( 'backgroundColor', ''),
193
+ 'width': options.width.getPxValue(), //getPxValue( 'width', 'auto' ),
194
+ 'color': options.color.getColorValue() // getColorValue( 'color', '' )
195
+ });
196
+
197
+ /* @since 2.0.3 */
198
+ events.trigger('editor.styles.apply');
199
+
200
+ return true;
201
+ }
202
+
203
+ function resetStyles() {
204
+ for( var key in options ) {
205
+ if( key.substring(0,5) === 'theme' ) {
206
+ continue;
207
+ }
208
+
209
+ options[key].clear();
210
+ }
211
+ applyStyles();
212
+
213
+ /* @since 2.0.3 */
214
+ events.trigger('editor.styles.reset');
215
+ }
216
+
217
+ // event binders
218
+ $appearanceControls.find('input.boxzilla-color-field').wpColorPicker({ change: applyStyles, clear: applyStyles });
219
+ $appearanceControls.find(":input").not(".boxzilla-color-field").change(applyStyles);
220
+ events.on('editor.init', applyStyles);
221
+
222
+ // public methods
223
+ return {
224
+ 'init': init,
225
+ 'resetStyles': resetStyles,
226
+ 'options': options
227
+ };
228
+
229
+ };
230
+
231
+ module.exports = Designer;
232
+ },{}],4:[function(require,module,exports){
233
+ 'use strict';
234
+
235
+ var $ = window.jQuery;
236
+
237
+ var Option = function( element ) {
238
+
239
+ // find corresponding element
240
+ if( typeof(element) == "string" ) {
241
+ element = document.getElementById('boxzilla-' + element);
242
+ }
243
+
244
+ if( ! element ) {
245
+ console.error("Unable to find option element.");
246
+ }
247
+
248
+ this.element = element;
249
+ };
250
+
251
+ Option.prototype.getColorValue = function() {
252
+ if( this.element.value.length > 0 ) {
253
+ if( $(this.element).hasClass('wp-color-field')) {
254
+ return $(this.element).wpColorPicker('color');
255
+ } else {
256
+ return this.element.value;
257
+ }
258
+ }
259
+
260
+ return '';
261
+ };
262
+
263
+ Option.prototype.getPxValue = function( fallbackValue ) {
264
+ if( this.element.value.length > 0 ) {
265
+ return parseInt( this.element.value ) + "px";
266
+ }
267
+
268
+ return fallbackValue || '';
269
+ };
270
+
271
+ Option.prototype.getValue = function( fallbackValue ) {
272
+
273
+ if( this.element.value.length > 0 ) {
274
+ return this.element.value;
275
+ }
276
+
277
+ return fallbackValue || '';
278
+ };
279
+
280
+ Option.prototype.clear = function() {
281
+ this.element.value = '';
282
+ };
283
+
284
+ Option.prototype.setValue = function(value) {
285
+ this.element.value = value;
286
+ };
287
+
288
+ module.exports = Option;
289
+ },{}],5:[function(require,module,exports){
290
+ /*!
291
+ * EventEmitter v4.2.11 - git.io/ee
292
+ * Unlicense - http://unlicense.org/
293
+ * Oliver Caldwell - http://oli.me.uk/
294
+ * @preserve
295
+ */
296
+
297
+ ;(function () {
298
+ 'use strict';
299
+
300
+ /**
301
+ * Class for managing events.
302
+ * Can be extended to provide event functionality in other classes.
303
+ *
304
+ * @class EventEmitter Manages event registering and emitting.
305
+ */
306
+ function EventEmitter() {}
307
+
308
+ // Shortcuts to improve speed and size
309
+ var proto = EventEmitter.prototype;
310
+ var exports = this;
311
+ var originalGlobalValue = exports.EventEmitter;
312
+
313
+ /**
314
+ * Finds the index of the listener for the event in its storage array.
315
+ *
316
+ * @param {Function[]} listeners Array of listeners to search through.
317
+ * @param {Function} listener Method to look for.
318
+ * @return {Number} Index of the specified listener, -1 if not found
319
+ * @api private
320
+ */
321
+ function indexOfListener(listeners, listener) {
322
+ var i = listeners.length;
323
+ while (i--) {
324
+ if (listeners[i].listener === listener) {
325
+ return i;
326
+ }
327
+ }
328
+
329
+ return -1;
330
+ }
331
+
332
+ /**
333
+ * Alias a method while keeping the context correct, to allow for overwriting of target method.
334
+ *
335
+ * @param {String} name The name of the target method.
336
+ * @return {Function} The aliased method
337
+ * @api private
338
+ */
339
+ function alias(name) {
340
+ return function aliasClosure() {
341
+ return this[name].apply(this, arguments);
342
+ };
343
+ }
344
+
345
+ /**
346
+ * Returns the listener array for the specified event.
347
+ * Will initialise the event object and listener arrays if required.
348
+ * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
349
+ * Each property in the object response is an array of listener functions.
350
+ *
351
+ * @param {String|RegExp} evt Name of the event to return the listeners from.
352
+ * @return {Function[]|Object} All listener functions for the event.
353
+ */
354
+ proto.getListeners = function getListeners(evt) {
355
+ var events = this._getEvents();
356
+ var response;
357
+ var key;
358
+
359
+ // Return a concatenated array of all matching events if
360
+ // the selector is a regular expression.
361
+ if (evt instanceof RegExp) {
362
+ response = {};
363
+ for (key in events) {
364
+ if (events.hasOwnProperty(key) && evt.test(key)) {
365
+ response[key] = events[key];
366
+ }
367
+ }
368
+ }
369
+ else {
370
+ response = events[evt] || (events[evt] = []);
371
+ }
372
+
373
+ return response;
374
+ };
375
+
376
+ /**
377
+ * Takes a list of listener objects and flattens it into a list of listener functions.
378
+ *
379
+ * @param {Object[]} listeners Raw listener objects.
380
+ * @return {Function[]} Just the listener functions.
381
+ */
382
+ proto.flattenListeners = function flattenListeners(listeners) {
383
+ var flatListeners = [];
384
+ var i;
385
+
386
+ for (i = 0; i < listeners.length; i += 1) {
387
+ flatListeners.push(listeners[i].listener);
388
+ }
389
+
390
+ return flatListeners;
391
+ };
392
+
393
+ /**
394
+ * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
395
+ *
396
+ * @param {String|RegExp} evt Name of the event to return the listeners from.
397
+ * @return {Object} All listener functions for an event in an object.
398
+ */
399
+ proto.getListenersAsObject = function getListenersAsObject(evt) {
400
+ var listeners = this.getListeners(evt);
401
+ var response;
402
+
403
+ if (listeners instanceof Array) {
404
+ response = {};
405
+ response[evt] = listeners;
406
+ }
407
+
408
+ return response || listeners;
409
+ };
410
+
411
+ /**
412
+ * Adds a listener function to the specified event.
413
+ * The listener will not be added if it is a duplicate.
414
+ * If the listener returns true then it will be removed after it is called.
415
+ * If you pass a regular expression as the event name then the listener will be added to all events that match it.
416
+ *
417
+ * @param {String|RegExp} evt Name of the event to attach the listener to.
418
+ * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
419
+ * @return {Object} Current instance of EventEmitter for chaining.
420
+ */
421
+ proto.addListener = function addListener(evt, listener) {
422
+ var listeners = this.getListenersAsObject(evt);
423
+ var listenerIsWrapped = typeof listener === 'object';
424
+ var key;
425
+
426
+ for (key in listeners) {
427
+ if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
428
+ listeners[key].push(listenerIsWrapped ? listener : {
429
+ listener: listener,
430
+ once: false
431
+ });
432
+ }
433
+ }
434
+
435
+ return this;
436
+ };
437
+
438
+ /**
439
+ * Alias of addListener
440
+ */
441
+ proto.on = alias('addListener');
442
+
443
+ /**
444
+ * Semi-alias of addListener. It will add a listener that will be
445
+ * automatically removed after its first execution.
446
+ *
447
+ * @param {String|RegExp} evt Name of the event to attach the listener to.
448
+ * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
449
+ * @return {Object} Current instance of EventEmitter for chaining.
450
+ */
451
+ proto.addOnceListener = function addOnceListener(evt, listener) {
452
+ return this.addListener(evt, {
453
+ listener: listener,
454
+ once: true
455
+ });
456
+ };
457
+
458
+ /**
459
+ * Alias of addOnceListener.
460
+ */
461
+ proto.once = alias('addOnceListener');
462
+
463
+ /**
464
+ * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
465
+ * You need to tell it what event names should be matched by a regex.
466
+ *
467
+ * @param {String} evt Name of the event to create.
468
+ * @return {Object} Current instance of EventEmitter for chaining.
469
+ */
470
+ proto.defineEvent = function defineEvent(evt) {
471
+ this.getListeners(evt);
472
+ return this;
473
+ };
474
+
475
+ /**
476
+ * Uses defineEvent to define multiple events.
477
+ *
478
+ * @param {String[]} evts An array of event names to define.
479
+ * @return {Object} Current instance of EventEmitter for chaining.
480
+ */
481
+ proto.defineEvents = function defineEvents(evts) {
482
+ for (var i = 0; i < evts.length; i += 1) {
483
+ this.defineEvent(evts[i]);
484
+ }
485
+ return this;
486
+ };
487
+
488
+ /**
489
+ * Removes a listener function from the specified event.
490
+ * When passed a regular expression as the event name, it will remove the listener from all events that match it.
491
+ *
492
+ * @param {String|RegExp} evt Name of the event to remove the listener from.
493
+ * @param {Function} listener Method to remove from the event.
494
+ * @return {Object} Current instance of EventEmitter for chaining.
495
+ */
496
+ proto.removeListener = function removeListener(evt, listener) {
497
+ var listeners = this.getListenersAsObject(evt);
498
+ var index;
499
+ var key;
500
+
501
+ for (key in listeners) {
502
+ if (listeners.hasOwnProperty(key)) {
503
+ index = indexOfListener(listeners[key], listener);
504
+
505
+ if (index !== -1) {
506
+ listeners[key].splice(index, 1);
507
+ }
508
+ }
509
+ }
510
+
511
+ return this;
512
+ };
513
+
514
+ /**
515
+ * Alias of removeListener
516
+ */
517
+ proto.off = alias('removeListener');
518
+
519
+ /**
520
+ * Adds listeners in bulk using the manipulateListeners method.
521
+ * If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
522
+ * You can also pass it a regular expression to add the array of listeners to all events that match it.
523
+ * Yeah, this function does quite a bit. That's probably a bad thing.
524
+ *
525
+ * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
526
+ * @param {Function[]} [listeners] An optional array of listener functions to add.
527
+ * @return {Object} Current instance of EventEmitter for chaining.
528
+ */
529
+ proto.addListeners = function addListeners(evt, listeners) {
530
+ // Pass through to manipulateListeners
531
+ return this.manipulateListeners(false, evt, listeners);
532
+ };
533
+
534
+ /**
535
+ * Removes listeners in bulk using the manipulateListeners method.
536
+ * If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
537
+ * You can also pass it an event name and an array of listeners to be removed.
538
+ * You can also pass it a regular expression to remove the listeners from all events that match it.
539
+ *
540
+ * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
541
+ * @param {Function[]} [listeners] An optional array of listener functions to remove.
542
+ * @return {Object} Current instance of EventEmitter for chaining.
543
+ */
544
+ proto.removeListeners = function removeListeners(evt, listeners) {
545
+ // Pass through to manipulateListeners
546
+ return this.manipulateListeners(true, evt, listeners);
547
+ };
548
+
549
+ /**
550
+ * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
551
+ * The first argument will determine if the listeners are removed (true) or added (false).
552
+ * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
553
+ * You can also pass it an event name and an array of listeners to be added/removed.
554
+ * You can also pass it a regular expression to manipulate the listeners of all events that match it.
555
+ *
556
+ * @param {Boolean} remove True if you want to remove listeners, false if you want to add.
557
+ * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
558
+ * @param {Function[]} [listeners] An optional array of listener functions to add/remove.
559
+ * @return {Object} Current instance of EventEmitter for chaining.
560
+ */
561
+ proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
562
+ var i;
563
+ var value;
564
+ var single = remove ? this.removeListener : this.addListener;
565
+ var multiple = remove ? this.removeListeners : this.addListeners;
566
+
567
+ // If evt is an object then pass each of its properties to this method
568
+ if (typeof evt === 'object' && !(evt instanceof RegExp)) {
569
+ for (i in evt) {
570
+ if (evt.hasOwnProperty(i) && (value = evt[i])) {
571
+ // Pass the single listener straight through to the singular method
572
+ if (typeof value === 'function') {
573
+ single.call(this, i, value);
574
+ }
575
+ else {
576
+ // Otherwise pass back to the multiple function
577
+ multiple.call(this, i, value);
578
+ }
579
+ }
580
+ }
581
+ }
582
+ else {
583
+ // So evt must be a string
584
+ // And listeners must be an array of listeners
585
+ // Loop over it and pass each one to the multiple method
586
+ i = listeners.length;
587
+ while (i--) {
588
+ single.call(this, evt, listeners[i]);
589
+ }
590
+ }
591
+
592
+ return this;
593
+ };
594
+
595
+ /**
596
+ * Removes all listeners from a specified event.
597
+ * If you do not specify an event then all listeners will be removed.
598
+ * That means every event will be emptied.
599
+ * You can also pass a regex to remove all events that match it.
600
+ *
601
+ * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
602
+ * @return {Object} Current instance of EventEmitter for chaining.
603
+ */
604
+ proto.removeEvent = function removeEvent(evt) {
605
+ var type = typeof evt;
606
+ var events = this._getEvents();
607
+ var key;
608
+
609
+ // Remove different things depending on the state of evt
610
+ if (type === 'string') {
611
+ // Remove all listeners for the specified event
612
+ delete events[evt];
613
+ }
614
+ else if (evt instanceof RegExp) {
615
+ // Remove all events matching the regex.
616
+ for (key in events) {
617
+ if (events.hasOwnProperty(key) && evt.test(key)) {
618
+ delete events[key];
619
+ }
620
+ }
621
+ }
622
+ else {
623
+ // Remove all listeners in all events
624
+ delete this._events;
625
+ }
626
+
627
+ return this;
628
+ };
629
+
630
+ /**
631
+ * Alias of removeEvent.
632
+ *
633
+ * Added to mirror the node API.
634
+ */
635
+ proto.removeAllListeners = alias('removeEvent');
636
+
637
+ /**
638
+ * Emits an event of your choice.
639
+ * When emitted, every listener attached to that event will be executed.
640
+ * If you pass the optional argument array then those arguments will be passed to every listener upon execution.
641
+ * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
642
+ * So they will not arrive within the array on the other side, they will be separate.
643
+ * You can also pass a regular expression to emit to all events that match it.
644
+ *
645
+ * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
646
+ * @param {Array} [args] Optional array of arguments to be passed to each listener.
647
+ * @return {Object} Current instance of EventEmitter for chaining.
648
+ */
649
+ proto.emitEvent = function emitEvent(evt, args) {
650
+ var listenersMap = this.getListenersAsObject(evt);
651
+ var listeners;
652
+ var listener;
653
+ var i;
654
+ var key;
655
+ var response;
656
+
657
+ for (key in listenersMap) {
658
+ if (listenersMap.hasOwnProperty(key)) {
659
+ listeners = listenersMap[key].slice(0);
660
+ i = listeners.length;
661
+
662
+ while (i--) {
663
+ // If the listener returns true then it shall be removed from the event
664
+ // The function is executed either with a basic call or an apply if there is an args array
665
+ listener = listeners[i];
666
+
667
+ if (listener.once === true) {
668
+ this.removeListener(evt, listener.listener);
669
+ }
670
+
671
+ response = listener.listener.apply(this, args || []);
672
+
673
+ if (response === this._getOnceReturnValue()) {
674
+ this.removeListener(evt, listener.listener);
675
+ }
676
+ }
677
+ }
678
+ }
679
+
680
+ return this;
681
+ };
682
+
683
+ /**
684
+ * Alias of emitEvent
685
+ */
686
+ proto.trigger = alias('emitEvent');
687
+
688
+ /**
689
+ * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
690
+ * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
691
+ *
692
+ * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
693
+ * @param {...*} Optional additional arguments to be passed to each listener.
694
+ * @return {Object} Current instance of EventEmitter for chaining.
695
+ */
696
+ proto.emit = function emit(evt) {
697
+ var args = Array.prototype.slice.call(arguments, 1);
698
+ return this.emitEvent(evt, args);
699
+ };
700
+
701
+ /**
702
+ * Sets the current value to check against when executing listeners. If a
703
+ * listeners return value matches the one set here then it will be removed
704
+ * after execution. This value defaults to true.
705
+ *
706
+ * @param {*} value The new value to check for when executing listeners.
707
+ * @return {Object} Current instance of EventEmitter for chaining.
708
+ */
709
+ proto.setOnceReturnValue = function setOnceReturnValue(value) {
710
+ this._onceReturnValue = value;
711
+ return this;
712
+ };
713
+
714
+ /**
715
+ * Fetches the current value to check against when executing listeners. If
716
+ * the listeners return value matches this one then it should be removed
717
+ * automatically. It will return true by default.
718
+ *
719
+ * @return {*|Boolean} The current value to check for or the default, true.
720
+ * @api private
721
+ */
722
+ proto._getOnceReturnValue = function _getOnceReturnValue() {
723
+ if (this.hasOwnProperty('_onceReturnValue')) {
724
+ return this._onceReturnValue;
725
+ }
726
+ else {
727
+ return true;
728
+ }
729
+ };
730
+
731
+ /**
732
+ * Fetches the events object and creates one if required.
733
+ *
734
+ * @return {Object} The events storage object.
735
+ * @api private
736
+ */
737
+ proto._getEvents = function _getEvents() {
738
+ return this._events || (this._events = {});
739
+ };
740
+
741
+ /**
742
+ * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
743
+ *
744
+ * @return {Function} Non conflicting EventEmitter class.
745
+ */
746
+ EventEmitter.noConflict = function noConflict() {
747
+ exports.EventEmitter = originalGlobalValue;
748
+ return EventEmitter;
749
+ };
750
+
751
+ // Expose the class either via AMD, CommonJS or the global object
752
+ if (typeof define === 'function' && define.amd) {
753
+ define(function () {
754
+ return EventEmitter;
755
+ });
756
+ }
757
+ else if (typeof module === 'object' && module.exports){
758
+ module.exports = EventEmitter;
759
+ }
760
+ else {
761
+ exports.EventEmitter = EventEmitter;
762
+ }
763
+ }.call(this));
764
+
765
+ },{}]},{},[1]);
766
+ })();
assets/js/admin-script.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ !function(){var e=void 0,t=void 0;!function n(t,r,o){function i(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof e&&e;if(!a&&u)return u(s,!0);if(l)return l(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var p=r[s]={exports:{}};t[s][0].call(p.exports,function(e){var n=t[s][1][e];return i(n?n:e)},p,p.exports,n,t,r,o)}return r[s].exports}for(var l="function"==typeof e&&e,s=0;s<o.length;s++)i(o[s]);return i}({1:[function(e,t,n){window.Boxzilla_Admin=e("./admin/_admin.js")},{"./admin/_admin.js":2}],2:[function(e,t,n){"use strict";function r(){c.find(".boxzilla-trigger-options").toggle(""!==this.value)}function o(){s(this).parents("tr").remove()}function i(){var e="tr"===this.tagName.toLowerCase()?this:s(this).parents("tr").get(0),t=e.querySelector(".boxzilla-rule-condition").value,n=e.querySelector(".boxzilla-rule-value"),r=e.querySelector(".boxzilla-rule-qualifier"),o=n.cloneNode(!0),i=s(o);switch(s(e.querySelectorAll(".boxzilla-helper")).remove(),o.removeAttribute("name"),o.className=o.className+" boxzilla-helper",n.parentNode.insertBefore(o,n.nextSibling),i.change(function(){n.value=this.value}),o.style.display="",n.style.display="none",r.style.display="",t){default:o.placeholder=g.enterCommaSeparatedValues;break;case"":case"everywhere":r.value="",n.value="",o.style.display="none",r.style.display="none";break;case"is_single":case"is_post":o.placeholder=g.enterCommaSeparatedPosts,i.suggest(ajaxurl+"?action=boxzilla_autocomplete&type=post",{multiple:!0,multipleSep:","});break;case"is_page":o.placeholder=g.enterCommaSeparatedPages,i.suggest(ajaxurl+"?action=boxzilla_autocomplete&type=page",{multiple:!0,multipleSep:","});break;case"is_post_type":o.placeholder=g.enterCommaSeparatedPostTypes,i.suggest(ajaxurl+"?action=boxzilla_autocomplete&type=post_type",{multiple:!0,multipleSep:","});break;case"is_url":o.placeholder=g.enterCommaSeparatedRelativeUrls;break;case"is_post_in_category":i.suggest(ajaxurl+"?action=boxzilla_autocomplete&type=category",{multiple:!0,multipleSep:","})}}function l(){var e={key:u.querySelectorAll(".boxzilla-rule-row").length},t=h(e);return s(document.getElementById("boxzilla-box-rules")).after(t),!1}var s=window.jQuery,a=e("./_option.js"),u=document.getElementById("boxzilla-box-options-controls"),c=s(u);if(0!==c.length){var p=e("wolfy87-eventemitter"),d=new p,f=e("./_designer.js")(s,a,d),h=wp.template("rule-row-template"),g=boxzilla_i18n;c.on("click",".boxzilla-add-rule",l),c.on("click",".boxzilla-remove-rule",o),c.on("change",".boxzilla-rule-condition",i),c.find(".boxzilla-auto-show-trigger").on("change",r),s(window).load(function(){"undefined"==typeof window.tinyMCE&&(document.getElementById("notice-notinymce").style.display="")}),s(".boxzilla-rule-row").each(i),t.exports={Designer:f,Option:a,events:d}}},{"./_designer.js":3,"./_option.js":4,"wolfy87-eventemitter":5}],3:[function(e,t,n){var r=function(e,t,n){function r(){"object"==typeof window.tinyMCE&&null!==tinyMCE.get("content")&&(s=e("#content_ifr"),l=s.contents().find("html"),l.css({background:"white"}),a=l.find("#tinymce"),a.addClass("boxzilla boxzilla-"+u),a.css({margin:0,background:"white",display:"inline-block",width:"auto","min-width":"240px",position:"relative"}),a.get(0).style.cssText+=";padding: 25px !important;",p=!0,n.trigger("editor.init"))}function o(){return p?(a.css({"border-color":c.borderColor.getColorValue(),"border-width":c.borderWidth.getPxValue(),"border-style":c.borderStyle.getValue(),"background-color":c.backgroundColor.getColorValue(),width:c.width.getPxValue(),color:c.color.getColorValue()}),n.trigger("editor.styles.apply"),!0):!1}function i(){for(var e in c)"theme"!==e.substring(0,5)&&c[e].clear();o(),n.trigger("editor.styles.reset")}var l,s,a,u=document.getElementById("post_ID").value||0,c={},p=!1,d=e("#boxzilla-box-appearance-controls");return c.borderColor=new t("border-color"),c.borderWidth=new t("border-width"),c.borderStyle=new t("border-style"),c.backgroundColor=new t("background-color"),c.width=new t("width"),c.color=new t("color"),d.find("input.boxzilla-color-field").wpColorPicker({change:o,clear:o}),d.find(":input").not(".boxzilla-color-field").change(o),n.on("editor.init",o),{init:r,resetStyles:i,options:c}};t.exports=r},{}],4:[function(e,t,n){"use strict";var r=window.jQuery,o=function(e){"string"==typeof e&&(e=document.getElementById("boxzilla-"+e)),e||console.error("Unable to find option element."),this.element=e};o.prototype.getColorValue=function(){return this.element.value.length>0?r(this.element).hasClass("wp-color-field")?r(this.element).wpColorPicker("color"):this.element.value:""},o.prototype.getPxValue=function(e){return this.element.value.length>0?parseInt(this.element.value)+"px":e||""},o.prototype.getValue=function(e){return this.element.value.length>0?this.element.value:e||""},o.prototype.clear=function(){this.element.value=""},o.prototype.setValue=function(e){this.element.value=e},t.exports=o},{}],5:[function(e,n,r){(function(){"use strict";function e(){}function r(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function o(e){return function(){return this[e].apply(this,arguments)}}var i=e.prototype,l=this,s=l.EventEmitter;i.getListeners=function(e){var t,n,r=this._getEvents();if(e instanceof RegExp){t={};for(n in r)r.hasOwnProperty(n)&&e.test(n)&&(t[n]=r[n])}else t=r[e]||(r[e]=[]);return t},i.flattenListeners=function(e){var t,n=[];for(t=0;t<e.length;t+=1)n.push(e[t].listener);return n},i.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},i.addListener=function(e,t){var n,o=this.getListenersAsObject(e),i="object"==typeof t;for(n in o)o.hasOwnProperty(n)&&-1===r(o[n],t)&&o[n].push(i?t:{listener:t,once:!1});return this},i.on=o("addListener"),i.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},i.once=o("addOnceListener"),i.defineEvent=function(e){return this.getListeners(e),this},i.defineEvents=function(e){for(var t=0;t<e.length;t+=1)this.defineEvent(e[t]);return this},i.removeListener=function(e,t){var n,o,i=this.getListenersAsObject(e);for(o in i)i.hasOwnProperty(o)&&(n=r(i[o],t),-1!==n&&i[o].splice(n,1));return this},i.off=o("removeListener"),i.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},i.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},i.manipulateListeners=function(e,t,n){var r,o,i=e?this.removeListener:this.addListener,l=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(r=n.length;r--;)i.call(this,t,n[r]);else for(r in t)t.hasOwnProperty(r)&&(o=t[r])&&("function"==typeof o?i.call(this,r,o):l.call(this,r,o));return this},i.removeEvent=function(e){var t,n=typeof e,r=this._getEvents();if("string"===n)delete r[e];else if(e instanceof RegExp)for(t in r)r.hasOwnProperty(t)&&e.test(t)&&delete r[t];else delete this._events;return this},i.removeAllListeners=o("removeEvent"),i.emitEvent=function(e,t){var n,r,o,i,l,s=this.getListenersAsObject(e);for(i in s)if(s.hasOwnProperty(i))for(n=s[i].slice(0),o=n.length;o--;)r=n[o],r.once===!0&&this.removeListener(e,r.listener),l=r.listener.apply(this,t||[]),l===this._getOnceReturnValue()&&this.removeListener(e,r.listener);return this},i.trigger=o("emitEvent"),i.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},i.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},i._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},i._getEvents=function(){return this._events||(this._events={})},e.noConflict=function(){return l.EventEmitter=s,e},"function"==typeof t&&t.amd?t(function(){return e}):"object"==typeof n&&n.exports?n.exports=e:l.EventEmitter=e}).call(this)},{}]},{},[1])}();
2
+ //# sourceMappingURL=admin-script.min.js.map
assets/js/admin-script.min.js.map ADDED
@@ -0,0 +1 @@
 
1
+ {"version":3,"sources":["admin-script.js"],"names":["require","undefined","define","e","t","n","r","s","o","u","a","i","f","Error","code","l","exports","call","length","1","module","window","Boxzilla_Admin","./admin/_admin.js","2","toggleTriggerOptions","$optionControls","find","toggle","this","value","removeRule","$","parents","remove","setContextualHelpers","context","tagName","toLowerCase","get","condition","querySelector","valueInput","qualifierInput","betterInput","cloneNode","$betterInput","querySelectorAll","removeAttribute","className","parentNode","insertBefore","nextSibling","change","style","display","placeholder","i18n","enterCommaSeparatedValues","enterCommaSeparatedPosts","suggest","ajaxurl","multiple","multipleSep","enterCommaSeparatedPages","enterCommaSeparatedPostTypes","enterCommaSeparatedRelativeUrls","addRuleFields","data","key","optionControls","html","rowTemplate","document","getElementById","after","jQuery","Option","EventEmitter","events","Designer","wp","template","boxzilla_i18n","on","load","each","./_designer.js","./_option.js","wolfy87-eventemitter","3","init","tinyMCE","$editorFrame","$editor","contents","css","background","$innerEditor","addClass","boxId","margin","width","min-width","position","cssText","visualEditorInitialised","trigger","applyStyles","border-color","options","borderColor","getColorValue","border-width","borderWidth","getPxValue","border-style","borderStyle","getValue","background-color","backgroundColor","color","resetStyles","substring","clear","$appearanceControls","wpColorPicker","not","4","element","console","error","prototype","hasClass","fallbackValue","parseInt","setValue","5","indexOfListener","listeners","listener","alias","name","apply","arguments","proto","originalGlobalValue","getListeners","evt","response","_getEvents","RegExp","hasOwnProperty","test","flattenListeners","flatListeners","push","getListenersAsObject","Array","addListener","listenerIsWrapped","once","addOnceListener","defineEvent","defineEvents","evts","removeListener","index","splice","off","addListeners","manipulateListeners","removeListeners","single","removeEvent","type","_events","removeAllListeners","emitEvent","args","listenersMap","slice","_getOnceReturnValue","emit","setOnceReturnValue","_onceReturnValue","noConflict","amd"],"mappings":"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","file":"admin-script.min.js","sourcesContent":["(function () { var require = undefined; var define = undefined; (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){\nwindow.Boxzilla_Admin = require('./admin/_admin.js');\n},{\"./admin/_admin.js\":2}],2:[function(require,module,exports){\n'use strict';\n\nvar $ = window.jQuery;\nvar Option = require('./_option.js');\nvar optionControls = document.getElementById('boxzilla-box-options-controls');\nvar $optionControls = $(optionControls);\n\n// sanity check, are we on the correct page?\nif( $optionControls.length === 0 ) {\n\treturn;\n}\n\nvar EventEmitter = require('wolfy87-eventemitter');\nvar events = new EventEmitter();\nvar Designer = require('./_designer.js')($, Option, events);\nvar rowTemplate = wp.template('rule-row-template');\nvar i18n = boxzilla_i18n;\n\n// events\n$optionControls.on('click', \".boxzilla-add-rule\", addRuleFields);\n$optionControls.on('click', \".boxzilla-remove-rule\", removeRule);\n$optionControls.on('change', \".boxzilla-rule-condition\", setContextualHelpers);\n$optionControls.find('.boxzilla-auto-show-trigger').on('change', toggleTriggerOptions );\n\n$(window).load(function() {\n\tif( typeof(window.tinyMCE) === \"undefined\" ) {\n\t\tdocument.getElementById('notice-notinymce').style.display = '';\n\t}\n});\n\n// call contextual helper method for each row\n$('.boxzilla-rule-row').each(setContextualHelpers);\n\nfunction toggleTriggerOptions() {\n\t$optionControls.find('.boxzilla-trigger-options').toggle( this.value !== '' );\n}\n\nfunction removeRule() {\n\t$(this).parents('tr').remove();\n}\n\nfunction setContextualHelpers() {\n\n\tvar context = ( this.tagName.toLowerCase() === \"tr\" ) ? this : $(this).parents('tr').get(0);\n\tvar condition = context.querySelector('.boxzilla-rule-condition').value;\n\tvar valueInput = context.querySelector('.boxzilla-rule-value');\n\tvar qualifierInput = context.querySelector('.boxzilla-rule-qualifier');\n\tvar betterInput = valueInput.cloneNode(true);\n\tvar $betterInput = $(betterInput);\n\n\t// remove previously added helpers\n\t$(context.querySelectorAll('.boxzilla-helper')).remove();\n\n\t// prepare better input\n\tbetterInput.removeAttribute('name');\n\tbetterInput.className = betterInput.className + ' boxzilla-helper';\n\tvalueInput.parentNode.insertBefore(betterInput, valueInput.nextSibling);\n\t$betterInput.change(function() { valueInput.value = this.value; });\n\n\tbetterInput.style.display = '';\n\tvalueInput.style.display = 'none';\n\tqualifierInput.style.display = '';\n\n\t// change placeholder for textual help\n\tswitch(condition) {\n\t\tdefault:\n\t\t\tbetterInput.placeholder = i18n.enterCommaSeparatedValues;\n\t\t\tbreak;\n\n\t\tcase '':\n\t\tcase 'everywhere':\n\t\t\tqualifierInput.value = '';\n\t\t\tvalueInput.value = '';\n\t\t\tbetterInput.style.display = 'none';\n\t\t\tqualifierInput.style.display = 'none';\n\t\t\tbreak;\n\n\t\tcase 'is_single':\n\t\tcase 'is_post':\n\t\t\tbetterInput.placeholder = i18n.enterCommaSeparatedPosts;\n\t\t\t$betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=post\", {multiple:true, multipleSep: \",\"});\n\t\t\tbreak;\n\n\t\tcase 'is_page':\n\t\t\tbetterInput.placeholder = i18n.enterCommaSeparatedPages;\n\t\t\t$betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=page\", {multiple:true, multipleSep: \",\"});\n\t\t\tbreak;\n\n\t\tcase 'is_post_type':\n\t\t\tbetterInput.placeholder = i18n.enterCommaSeparatedPostTypes;\n\t\t\t$betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=post_type\", {multiple:true, multipleSep: \",\"});\n\t\t\tbreak;\n\n\t\tcase 'is_url':\n\t\t\tbetterInput.placeholder = i18n.enterCommaSeparatedRelativeUrls;\n\t\t\tbreak;\n\n\t\tcase 'is_post_in_category':\n\t\t\t$betterInput.suggest(ajaxurl + \"?action=boxzilla_autocomplete&type=category\", {multiple:true, multipleSep: \",\"});\n\t\t\tbreak;\n\t}\n}\n\nfunction addRuleFields() {\n\tvar data = {\n\t\t'key': optionControls.querySelectorAll('.boxzilla-rule-row').length\n\t};\n\tvar html = rowTemplate(data);\n\t$(document.getElementById('boxzilla-box-rules')).after(html);\n\treturn false;\n}\n\nmodule.exports = {\n\t'Designer': Designer,\n\t'Option': Option,\n\t'events': events\n};\n\n},{\"./_designer.js\":3,\"./_option.js\":4,\"wolfy87-eventemitter\":5}],3:[function(require,module,exports){\nvar Designer = function($, Option, events) {\n\n\t// vars\n\tvar boxId = document.getElementById('post_ID').value || 0,\n\t\t$editor, $editorFrame,\n\t\t$innerEditor,\n\t\toptions = {},\n\t\tvisualEditorInitialised = false;\n\n\tvar $appearanceControls = $(\"#boxzilla-box-appearance-controls\");\n\n\t// create Option objects\n\toptions.borderColor = new Option('border-color');\n\toptions.borderWidth = new Option('border-width');\n\toptions.borderStyle = new Option('border-style');\n\toptions.backgroundColor = new Option('background-color');\n\toptions.width = new Option('width');\n\toptions.color = new Option('color');\n\n\t// functions\n\tfunction init() {\n\n\t\t// Only run if TinyMCE has actually inited\n\t\tif( typeof( window.tinyMCE ) !== \"object\" || tinyMCE.get('content') === null ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// add classes to TinyMCE <html>\n\t\t$editorFrame = $(\"#content_ifr\");\n\t\t$editor = $editorFrame.contents().find('html');\n\t\t$editor.css({\n\t\t\t'background': 'white'\n\t\t});\n\n\t\t// add content class and padding to TinyMCE <body>\n\t\t$innerEditor = $editor.find('#tinymce');\n\t\t$innerEditor.addClass('boxzilla boxzilla-' + boxId);\n\t\t$innerEditor.css({\n\t\t\t'margin': 0,\n\t\t\t'background': 'white',\n\t\t\t'display': 'inline-block',\n\t\t\t'width': 'auto',\n\t\t\t'min-width': '240px',\n\t\t\t'position': 'relative'\n\t\t});\n\t\t$innerEditor.get(0).style.cssText += ';padding: 25px !important;';\n\n\t\tvisualEditorInitialised = true;\n\n\t\t/* @since 2.0.3 */\n\t\tevents.trigger('editor.init');\n\t}\n\n\t/**\n\t * Applies the styles from the options to the TinyMCE Editor\n\t *\n\t * @return bool\n\t */\n\tfunction applyStyles() {\n\n\t\tif( ! visualEditorInitialised ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// apply styles from CSS editor\n\t\t$innerEditor.css({\n\t\t\t'border-color': options.borderColor.getColorValue(), //getColorValue( 'borderColor', '' ),\n\t\t\t'border-width': options.borderWidth.getPxValue(), //getPxValue( 'borderWidth', '' ),\n\t\t\t'border-style': options.borderStyle.getValue(), //getValue('borderStyle', '' ),\n\t\t\t'background-color': options.backgroundColor.getColorValue(), //getColorValue( 'backgroundColor', ''),\n\t\t\t'width': options.width.getPxValue(), //getPxValue( 'width', 'auto' ),\n\t\t\t'color': options.color.getColorValue() // getColorValue( 'color', '' )\n\t\t});\n\n\t\t/* @since 2.0.3 */\n\t\tevents.trigger('editor.styles.apply');\n\n\t\treturn true;\n\t}\n\n\tfunction resetStyles() {\n\t\tfor( var key in options ) {\n\t\t\tif( key.substring(0,5) === 'theme' ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\toptions[key].clear();\n\t\t}\n\t\tapplyStyles();\n\n\t\t/* @since 2.0.3 */\n\t\tevents.trigger('editor.styles.reset');\n\t}\n\n\t// event binders\n\t$appearanceControls.find('input.boxzilla-color-field').wpColorPicker({ change: applyStyles, clear: applyStyles });\n\t$appearanceControls.find(\":input\").not(\".boxzilla-color-field\").change(applyStyles);\n\tevents.on('editor.init', applyStyles);\n\n\t// public methods\n\treturn {\n\t\t'init': init,\n\t\t'resetStyles': resetStyles,\n\t\t'options': options\n\t};\n\n};\n\nmodule.exports = Designer;\n},{}],4:[function(require,module,exports){\n'use strict';\n\nvar $ = window.jQuery;\n\nvar Option = function( element ) {\n\n\t// find corresponding element\n\tif( typeof(element) == \"string\" ) {\n\t\telement = document.getElementById('boxzilla-' + element);\n\t}\n\n\tif( ! element ) {\n\t\tconsole.error(\"Unable to find option element.\");\n\t}\n\n\tthis.element = element;\n};\n\nOption.prototype.getColorValue = function() {\n\tif( this.element.value.length > 0 ) {\n\t\tif( $(this.element).hasClass('wp-color-field')) {\n\t\t\treturn $(this.element).wpColorPicker('color');\n\t\t} else {\n\t\t\treturn this.element.value;\n\t\t}\n\t}\n\n\treturn '';\n};\n\nOption.prototype.getPxValue = function( fallbackValue ) {\n\tif( this.element.value.length > 0 ) {\n\t\treturn parseInt( this.element.value ) + \"px\";\n\t}\n\n\treturn fallbackValue || '';\n};\n\nOption.prototype.getValue = function( fallbackValue ) {\n\n\tif( this.element.value.length > 0 ) {\n\t\treturn this.element.value;\n\t}\n\n\treturn fallbackValue || '';\n};\n\nOption.prototype.clear = function() {\n\tthis.element.value = '';\n};\n\nOption.prototype.setValue = function(value) {\n\tthis.element.value = value;\n};\n\nmodule.exports = Option;\n},{}],5:[function(require,module,exports){\n/*!\n * EventEmitter v4.2.11 - git.io/ee\n * Unlicense - http://unlicense.org/\n * Oliver Caldwell - http://oli.me.uk/\n * @preserve\n */\n\n;(function () {\n 'use strict';\n\n /**\n * Class for managing events.\n * Can be extended to provide event functionality in other classes.\n *\n * @class EventEmitter Manages event registering and emitting.\n */\n function EventEmitter() {}\n\n // Shortcuts to improve speed and size\n var proto = EventEmitter.prototype;\n var exports = this;\n var originalGlobalValue = exports.EventEmitter;\n\n /**\n * Finds the index of the listener for the event in its storage array.\n *\n * @param {Function[]} listeners Array of listeners to search through.\n * @param {Function} listener Method to look for.\n * @return {Number} Index of the specified listener, -1 if not found\n * @api private\n */\n function indexOfListener(listeners, listener) {\n var i = listeners.length;\n while (i--) {\n if (listeners[i].listener === listener) {\n return i;\n }\n }\n\n return -1;\n }\n\n /**\n * Alias a method while keeping the context correct, to allow for overwriting of target method.\n *\n * @param {String} name The name of the target method.\n * @return {Function} The aliased method\n * @api private\n */\n function alias(name) {\n return function aliasClosure() {\n return this[name].apply(this, arguments);\n };\n }\n\n /**\n * Returns the listener array for the specified event.\n * Will initialise the event object and listener arrays if required.\n * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.\n * Each property in the object response is an array of listener functions.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Function[]|Object} All listener functions for the event.\n */\n proto.getListeners = function getListeners(evt) {\n var events = this._getEvents();\n var response;\n var key;\n\n // Return a concatenated array of all matching events if\n // the selector is a regular expression.\n if (evt instanceof RegExp) {\n response = {};\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n response[key] = events[key];\n }\n }\n }\n else {\n response = events[evt] || (events[evt] = []);\n }\n\n return response;\n };\n\n /**\n * Takes a list of listener objects and flattens it into a list of listener functions.\n *\n * @param {Object[]} listeners Raw listener objects.\n * @return {Function[]} Just the listener functions.\n */\n proto.flattenListeners = function flattenListeners(listeners) {\n var flatListeners = [];\n var i;\n\n for (i = 0; i < listeners.length; i += 1) {\n flatListeners.push(listeners[i].listener);\n }\n\n return flatListeners;\n };\n\n /**\n * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Object} All listener functions for an event in an object.\n */\n proto.getListenersAsObject = function getListenersAsObject(evt) {\n var listeners = this.getListeners(evt);\n var response;\n\n if (listeners instanceof Array) {\n response = {};\n response[evt] = listeners;\n }\n\n return response || listeners;\n };\n\n /**\n * Adds a listener function to the specified event.\n * The listener will not be added if it is a duplicate.\n * If the listener returns true then it will be removed after it is called.\n * If you pass a regular expression as the event name then the listener will be added to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListener = function addListener(evt, listener) {\n var listeners = this.getListenersAsObject(evt);\n var listenerIsWrapped = typeof listener === 'object';\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {\n listeners[key].push(listenerIsWrapped ? listener : {\n listener: listener,\n once: false\n });\n }\n }\n\n return this;\n };\n\n /**\n * Alias of addListener\n */\n proto.on = alias('addListener');\n\n /**\n * Semi-alias of addListener. It will add a listener that will be\n * automatically removed after its first execution.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addOnceListener = function addOnceListener(evt, listener) {\n return this.addListener(evt, {\n listener: listener,\n once: true\n });\n };\n\n /**\n * Alias of addOnceListener.\n */\n proto.once = alias('addOnceListener');\n\n /**\n * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.\n * You need to tell it what event names should be matched by a regex.\n *\n * @param {String} evt Name of the event to create.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvent = function defineEvent(evt) {\n this.getListeners(evt);\n return this;\n };\n\n /**\n * Uses defineEvent to define multiple events.\n *\n * @param {String[]} evts An array of event names to define.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvents = function defineEvents(evts) {\n for (var i = 0; i < evts.length; i += 1) {\n this.defineEvent(evts[i]);\n }\n return this;\n };\n\n /**\n * Removes a listener function from the specified event.\n * When passed a regular expression as the event name, it will remove the listener from all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to remove the listener from.\n * @param {Function} listener Method to remove from the event.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListener = function removeListener(evt, listener) {\n var listeners = this.getListenersAsObject(evt);\n var index;\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key)) {\n index = indexOfListener(listeners[key], listener);\n\n if (index !== -1) {\n listeners[key].splice(index, 1);\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of removeListener\n */\n proto.off = alias('removeListener');\n\n /**\n * Adds listeners in bulk using the manipulateListeners method.\n * If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.\n * You can also pass it a regular expression to add the array of listeners to all events that match it.\n * Yeah, this function does quite a bit. That's probably a bad thing.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListeners = function addListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(false, evt, listeners);\n };\n\n /**\n * Removes listeners in bulk using the manipulateListeners method.\n * If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be removed.\n * You can also pass it a regular expression to remove the listeners from all events that match it.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListeners = function removeListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(true, evt, listeners);\n };\n\n /**\n * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.\n * The first argument will determine if the listeners are removed (true) or added (false).\n * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be added/removed.\n * You can also pass it a regular expression to manipulate the listeners of all events that match it.\n *\n * @param {Boolean} remove True if you want to remove listeners, false if you want to add.\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add/remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {\n var i;\n var value;\n var single = remove ? this.removeListener : this.addListener;\n var multiple = remove ? this.removeListeners : this.addListeners;\n\n // If evt is an object then pass each of its properties to this method\n if (typeof evt === 'object' && !(evt instanceof RegExp)) {\n for (i in evt) {\n if (evt.hasOwnProperty(i) && (value = evt[i])) {\n // Pass the single listener straight through to the singular method\n if (typeof value === 'function') {\n single.call(this, i, value);\n }\n else {\n // Otherwise pass back to the multiple function\n multiple.call(this, i, value);\n }\n }\n }\n }\n else {\n // So evt must be a string\n // And listeners must be an array of listeners\n // Loop over it and pass each one to the multiple method\n i = listeners.length;\n while (i--) {\n single.call(this, evt, listeners[i]);\n }\n }\n\n return this;\n };\n\n /**\n * Removes all listeners from a specified event.\n * If you do not specify an event then all listeners will be removed.\n * That means every event will be emptied.\n * You can also pass a regex to remove all events that match it.\n *\n * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeEvent = function removeEvent(evt) {\n var type = typeof evt;\n var events = this._getEvents();\n var key;\n\n // Remove different things depending on the state of evt\n if (type === 'string') {\n // Remove all listeners for the specified event\n delete events[evt];\n }\n else if (evt instanceof RegExp) {\n // Remove all events matching the regex.\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n delete events[key];\n }\n }\n }\n else {\n // Remove all listeners in all events\n delete this._events;\n }\n\n return this;\n };\n\n /**\n * Alias of removeEvent.\n *\n * Added to mirror the node API.\n */\n proto.removeAllListeners = alias('removeEvent');\n\n /**\n * Emits an event of your choice.\n * When emitted, every listener attached to that event will be executed.\n * If you pass the optional argument array then those arguments will be passed to every listener upon execution.\n * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.\n * So they will not arrive within the array on the other side, they will be separate.\n * You can also pass a regular expression to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {Array} [args] Optional array of arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emitEvent = function emitEvent(evt, args) {\n var listenersMap = this.getListenersAsObject(evt);\n var listeners;\n var listener;\n var i;\n var key;\n var response;\n\n for (key in listenersMap) {\n if (listenersMap.hasOwnProperty(key)) {\n listeners = listenersMap[key].slice(0);\n i = listeners.length;\n\n while (i--) {\n // If the listener returns true then it shall be removed from the event\n // The function is executed either with a basic call or an apply if there is an args array\n listener = listeners[i];\n\n if (listener.once === true) {\n this.removeListener(evt, listener.listener);\n }\n\n response = listener.listener.apply(this, args || []);\n\n if (response === this._getOnceReturnValue()) {\n this.removeListener(evt, listener.listener);\n }\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of emitEvent\n */\n proto.trigger = alias('emitEvent');\n\n /**\n * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.\n * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {...*} Optional additional arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emit = function emit(evt) {\n var args = Array.prototype.slice.call(arguments, 1);\n return this.emitEvent(evt, args);\n };\n\n /**\n * Sets the current value to check against when executing listeners. If a\n * listeners return value matches the one set here then it will be removed\n * after execution. This value defaults to true.\n *\n * @param {*} value The new value to check for when executing listeners.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.setOnceReturnValue = function setOnceReturnValue(value) {\n this._onceReturnValue = value;\n return this;\n };\n\n /**\n * Fetches the current value to check against when executing listeners. If\n * the listeners return value matches this one then it should be removed\n * automatically. It will return true by default.\n *\n * @return {*|Boolean} The current value to check for or the default, true.\n * @api private\n */\n proto._getOnceReturnValue = function _getOnceReturnValue() {\n if (this.hasOwnProperty('_onceReturnValue')) {\n return this._onceReturnValue;\n }\n else {\n return true;\n }\n };\n\n /**\n * Fetches the events object and creates one if required.\n *\n * @return {Object} The events storage object.\n * @api private\n */\n proto._getEvents = function _getEvents() {\n return this._events || (this._events = {});\n };\n\n /**\n * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.\n *\n * @return {Function} Non conflicting EventEmitter class.\n */\n EventEmitter.noConflict = function noConflict() {\n exports.EventEmitter = originalGlobalValue;\n return EventEmitter;\n };\n\n // Expose the class either via AMD, CommonJS or the global object\n if (typeof define === 'function' && define.amd) {\n define(function () {\n return EventEmitter;\n });\n }\n else if (typeof module === 'object' && module.exports){\n module.exports = EventEmitter;\n }\n else {\n exports.EventEmitter = EventEmitter;\n }\n}.call(this));\n\n},{}]},{},[1]);\n })();"],"sourceRoot":"/source/"}
assets/js/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ if( ! defined( 'STB::VERSION' ) ) {
3
+ header( 'Status: 403 Forbidden' );
4
+ header( 'HTTP/1.1 403 Forbidden' );
5
+ exit;
6
+ }
assets/js/script.js ADDED
@@ -0,0 +1,1065 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function () { var require = undefined; var define = undefined; (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+ 'use strict';
3
+
4
+ var Boxzilla = require('boxzilla');
5
+ var options = window.boxzilla_options;
6
+ var isLoggedIn = document.body.className.indexOf('logged-in') > -1;
7
+
8
+ // print message when test mode is enabled
9
+ if( isLoggedIn && options.testMode ) {
10
+ console.log( 'Boxzilla: Test mode is enabled. Please disable test mode if you\'re done testing.' );
11
+ }
12
+
13
+ // init boxzilla
14
+ Boxzilla.init();
15
+
16
+ // create boxes from options
17
+ for( var i=0; i < options.boxes.length; i++ ) {
18
+ // get opts
19
+ var boxOpts = options.boxes[i];
20
+ boxOpts.testMode = isLoggedIn && options.testMode;
21
+
22
+ // create box
23
+ var box = Boxzilla.create( boxOpts.id, boxOpts);
24
+
25
+ // add custom css to box
26
+ css(box.element, boxOpts.css);
27
+ }
28
+
29
+ function css(element, styles) {
30
+ if( styles.background_color ) {
31
+ element.style.background = styles.background_color;
32
+ }
33
+
34
+ if( styles.color ) {
35
+ element.style.color = styles.color;
36
+ }
37
+
38
+ if( styles.border_color ) {
39
+ element.style.borderColor = styles.border_color;
40
+ }
41
+
42
+ if( styles.border_width ) {
43
+ element.style.borderWidth = parseInt(styles.border_width) + "px";
44
+ }
45
+
46
+ if( styles.border_style ) {
47
+ element.style.borderStyle = styles.border_style;
48
+ }
49
+
50
+ if( styles.width ) {
51
+ element.style.maxWidth = parseInt(styles.width) + "px";
52
+ }
53
+ }
54
+
55
+ window.Boxzilla = Boxzilla;
56
+ },{"boxzilla":3}],2:[function(require,module,exports){
57
+ 'use strict';
58
+
59
+ var $ = window.jQuery,
60
+ defaults = {
61
+ 'animation': 'fade',
62
+ 'rehide': false,
63
+ 'content': '',
64
+ 'cookieTime': 0,
65
+ 'icon': '&times',
66
+ 'minimumScreenWidth': 0,
67
+ 'position': 'center',
68
+ 'testMode': false,
69
+ 'trigger': false,
70
+ 'closable': true
71
+ }, Boxzilla;
72
+
73
+ /**
74
+ * Merge 2 objects, values of the latter overwriting the former.
75
+ *
76
+ * @param obj1
77
+ * @param obj2
78
+ * @returns {*}
79
+ */
80
+ function merge( obj1, obj2 ) {
81
+ var obj3 = {};
82
+ for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
83
+ for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
84
+ return obj3;
85
+ }
86
+
87
+ // Box Object
88
+ var Box = function( id, config ) {
89
+ this.id = id;
90
+
91
+ // store config values
92
+ this.config = merge(defaults, config);
93
+
94
+ // store ref to overlay
95
+ this.overlay = document.getElementById('boxzilla-overlay');
96
+
97
+ // state
98
+ this.visible = false;
99
+ this.closed = false;
100
+ this.triggered = false;
101
+ this.triggerHeight = 0;
102
+ this.cookieSet = false;
103
+
104
+ // if a trigger was given, calculate values once and store
105
+ if( this.config.trigger ) {
106
+ if( this.config.trigger.method === 'percentage' || this.config.trigger.method === 'element' ) {
107
+ this.triggerHeight = this.calculateTriggerHeight();
108
+ }
109
+
110
+ this.cookieSet = this.isCookieSet();
111
+ }
112
+
113
+ // create dom element for this box
114
+ this.element = this.dom();
115
+ this.$element = $(this.element);
116
+
117
+ // further initialise the box
118
+ this.events();
119
+ };
120
+
121
+ // initialise the box
122
+ Box.prototype.events = function() {
123
+ var box = this;
124
+
125
+ // attach event to "close" icon inside box
126
+ this.$element.find('.boxzilla-close-icon').click(box.dismiss.bind(this));
127
+
128
+ this.$element.on('click', 'a', function(e) {
129
+ Boxzilla.trigger('box.interactions.link', [ box, e.target ] );
130
+ });
131
+
132
+ this.$element.on('submit', 'form', function(e) {
133
+ box.setCookie();
134
+ Boxzilla.trigger('box.interactions.form', [ box, e.target ]);
135
+ });
136
+
137
+ // attach event to all links referring #boxzilla-{box_id}
138
+ $(document.body).on('click', 'a[href="#boxzilla-' + box.id + '"]', function() {
139
+ box.toggle();
140
+ return false;
141
+ });
142
+
143
+ // maybe show box right away
144
+ if( this.config.trigger.method === "time_on_page" && this.mayAutoShow() ) {
145
+ window.setTimeout(this.trigger.bind(this), this.config.trigger.value * 1000 );
146
+ // auto-show the box if box is referenced from URL
147
+ } else if( this.fits() && this.locationHashRefersBox() ) {
148
+ $(window).load(this.show.bind(this));
149
+ }
150
+
151
+ };
152
+
153
+ // generate dom elements for this box
154
+ Box.prototype.dom = function() {
155
+
156
+ var wrapper = document.createElement('div');
157
+ wrapper.className = 'boxzilla-container boxzilla-' + this.config.position + '-container';
158
+
159
+ var box = document.createElement('div');
160
+ box.className = 'boxzilla boxzilla-' + this.id + ' boxzilla-' + this.config.position;
161
+ box.style.display = 'none';
162
+ wrapper.appendChild(box);
163
+
164
+ var content = document.createElement('div');
165
+ content.className = 'boxzilla-content';
166
+ content.innerHTML = this.config.content;
167
+ box.appendChild(content);
168
+
169
+ if( this.config.closable && this.config.icon ) {
170
+ var icon = document.createElement('span');
171
+ icon.className = "boxzilla-close-icon";
172
+ icon.innerHTML = this.config.icon;
173
+ box.appendChild(icon);
174
+ }
175
+
176
+ document.body.appendChild(wrapper);
177
+
178
+ return box;
179
+ };
180
+
181
+ // set (calculate) custom box styling depending on box options
182
+ Box.prototype.setCustomBoxStyling = function() {
183
+
184
+ // reset element to its initial state
185
+ this.element.style.overflowY = 'auto';
186
+ this.element.style.maxHeight = 'none';
187
+
188
+ // get new dimensions
189
+ var windowHeight = window.innerHeight;
190
+ var boxHeight = this.$element.outerHeight();
191
+
192
+ // add scrollbar to box and limit height
193
+ if( boxHeight > windowHeight ) {
194
+ this.element.style.maxHeight = windowHeight + "px";
195
+ this.element.style.overflowY = 'scroll';
196
+ }
197
+
198
+ // set new top margin for boxes which are centered
199
+ if( this.config.position === 'center' ) {
200
+ var newTopMargin = ( ( windowHeight - boxHeight ) / 2 );
201
+ newTopMargin = newTopMargin >= 0 ? newTopMargin : 0;
202
+ this.element.style.marginTop = newTopMargin + "px";
203
+ }
204
+
205
+ };
206
+
207
+ // toggle visibility of the box
208
+ Box.prototype.toggle = function(show) {
209
+
210
+ // revert visibility if no explicit argument is given
211
+ if( typeof( show ) === "undefined" ) {
212
+ show = ! this.visible;
213
+ }
214
+
215
+ // do nothing if element is being animated
216
+ if( this.$element.is(':animated') ) {
217
+ return false;
218
+ }
219
+
220
+ // is box already at desired visibility?
221
+ if( show === this.visible ) {
222
+ return false;
223
+ }
224
+
225
+ // if box should be hidden but is not closable, bail.
226
+ if( ! show && ! this.config.closable ) {
227
+ return false;
228
+ }
229
+
230
+ // set new visibility status
231
+ this.visible = show;
232
+
233
+ // calculate custom styling for which CSS is "too stupid"
234
+ this.setCustomBoxStyling();
235
+
236
+ // fadein / fadeout the overlay if position is "center"
237
+ if( this.config.position === 'center' ) {
238
+ $(this.overlay).fadeToggle('slow');
239
+ }
240
+
241
+ // trigger event
242
+ Boxzilla.trigger('box.' + ( show ? 'show' : 'hide' ), [ this ] );
243
+
244
+ // show or hide box using selected animation
245
+ if( this.config.animation === 'fade' ) {
246
+ this.$element.fadeToggle( 'slow' );
247
+ } else {
248
+ this.$element.slideToggle( 'slow' );
249
+ }
250
+
251
+ // // focus on first input field in box
252
+ // this.$element.find('input').first().focus();
253
+
254
+ return true;
255
+ };
256
+
257
+ // show the box
258
+ Box.prototype.show = function() {
259
+ return this.toggle(true);
260
+ };
261
+
262
+ // hide the box
263
+ Box.prototype.hide = function() {
264
+ return this.toggle(false);
265
+ };
266
+
267
+ // calculate trigger height
268
+ Box.prototype.calculateTriggerHeight = function() {
269
+ var triggerHeight = 0;
270
+
271
+ if( this.config.trigger.method === 'element' ) {
272
+ var $triggerElement = $(this.config.trigger.value).first();
273
+ triggerHeight = ( $triggerElement.length > 0 ) ? $triggerElement.offset().top : 0;
274
+ } else if( this.config.trigger.method === 'percentage' ) {
275
+ triggerHeight = ( this.config.trigger.value / 100 * $(document).height() );
276
+ }
277
+
278
+ return triggerHeight;
279
+ };
280
+
281
+ // set cookie that disables automatically showing the box
282
+ Box.prototype.setCookie = function() {
283
+ // do nothing if cookieTime evaluates to false
284
+ if(! this.config.cookieTime) {
285
+ return;
286
+ }
287
+
288
+ var expiryDate = new Date();
289
+ expiryDate.setDate( expiryDate.getDate() + this.config.cookieTime );
290
+ document.cookie = 'boxzilla_box_'+ this.id + '=true; expires='+ expiryDate.toUTCString() +'; path=/';
291
+ };
292
+
293
+ // checks whether window.location.hash equals the box element ID or that of any element inside the box
294
+ Box.prototype.locationHashRefersBox = function() {
295
+
296
+ if( ! window.location.hash || 0 === window.location.hash.length ) {
297
+ return false;
298
+ }
299
+
300
+ var elementId = window.location.hash.substring(1);
301
+ if( elementId === this.element.id ) {
302
+ return true;
303
+ } else if( this.element.querySelector('#' + elementId) ) {
304
+ return true;
305
+ }
306
+
307
+ return false;
308
+ };
309
+
310
+ Box.prototype.fits = function() {
311
+ if( this.config.minimumScreenWidth <= 0 ) {
312
+ return true;
313
+ }
314
+
315
+ return window.innerWidth > this.config.minimumScreenWidth
316
+ };
317
+
318
+ // is this box enabled?
319
+ Box.prototype.mayAutoShow = function() {
320
+
321
+ // don't show if box was closed (dismissed) before
322
+ if( this.closed ) {
323
+ return false;
324
+ }
325
+
326
+ // check if box fits on given minimum screen width
327
+ if( ! this.fits() ) {
328
+ return false;
329
+ }
330
+
331
+ // if trigger empty or error in calculating triggerHeight, return false
332
+ if( ! this.config.trigger ) {
333
+ return false;
334
+ }
335
+
336
+ // rely on cookie value (show if not set, don't show if set)
337
+ return ! this.cookieSet;
338
+ };
339
+
340
+ Box.prototype.mayRehide = function() {
341
+ return this.config.rehide && this.triggered;
342
+ };
343
+
344
+ Box.prototype.isCookieSet = function() {
345
+ // always show on test mode
346
+ if( this.config.testMode ) {
347
+ return false;
348
+ }
349
+
350
+ // check for cookie
351
+ if( ! this.config.cookieTime ) {
352
+ return false;
353
+ }
354
+
355
+ var cookieSet = document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + 'boxzilla_box_' + this.id + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1") === "true";
356
+ return cookieSet;
357
+
358
+ };
359
+
360
+ Box.prototype.trigger = function() {
361
+ var shown = this.show();
362
+ if( shown ) {
363
+ this.triggered = true;
364
+ }
365
+ };
366
+
367
+ Box.prototype.dismiss = function() {
368
+ this.hide();
369
+ this.setCookie();
370
+ this.closed = true;
371
+ Boxzilla.trigger('box.dismiss', [ this ]);
372
+ };
373
+
374
+ module.exports = function(_Boxzilla) {
375
+ Boxzilla = _Boxzilla;
376
+ return Box;
377
+ };
378
+ },{}],3:[function(require,module,exports){
379
+ 'use strict';
380
+
381
+ var $ = window.jQuery,
382
+ EventEmitter = require('wolfy87-eventemitter'),
383
+ Boxzilla = Object.create(EventEmitter.prototype),
384
+ Box = require('./Box.js')(Boxzilla),
385
+ boxes = {},
386
+ windowHeight = window.innerHeight,
387
+ overlay = document.createElement('div'),
388
+ exitIntentDelayTimer,
389
+ exitIntentTriggered;
390
+
391
+ function each( obj, callback ) {
392
+ for( var key in obj ) {
393
+ if(! obj.hasOwnProperty(key)) continue;
394
+ callback(obj[key]);
395
+ }
396
+ }
397
+
398
+ function throttle(fn, threshhold, scope) {
399
+ threshhold || (threshhold = 250);
400
+ var last,
401
+ deferTimer;
402
+ return function () {
403
+ var context = scope || this;
404
+
405
+ var now = +new Date,
406
+ args = arguments;
407
+ if (last && now < last + threshhold) {
408
+ // hold on to it
409
+ clearTimeout(deferTimer);
410
+ deferTimer = setTimeout(function () {
411
+ last = now;
412
+ fn.apply(context, args);
413
+ }, threshhold);
414
+ } else {
415
+ last = now;
416
+ fn.apply(context, args);
417
+ }
418
+ };
419
+ }
420
+
421
+ // "keyup" listener
422
+ function onKeyUp(e) {
423
+ if (e.keyCode == 27) {
424
+ Boxzilla.dismiss();
425
+ }
426
+ }
427
+
428
+ function checkTimeCriteria() {
429
+ var start = sessionStorage.getItem('boxzilla_start_time');
430
+ var now = Date.now();
431
+ var timeOnSite = ( now - start ) / 1000;
432
+
433
+ each(boxes, function(box) {
434
+ if( ! box.mayAutoShow() || box.config.trigger.method !== 'time_on_site' ) {
435
+ return;
436
+ }
437
+
438
+ if( timeOnSite > box.config.trigger.value ) {
439
+ box.trigger();
440
+ }
441
+ });
442
+ }
443
+
444
+ // check triggerHeight criteria for all boxes
445
+ function checkHeightCriteria() {
446
+ var scrollY = window.scrollY;
447
+ var scrollHeight = scrollY + ( windowHeight * 0.9 );
448
+
449
+ each(boxes, function(box) {
450
+ if( ! box.mayAutoShow() || box.triggerHeight <= 0 ) {
451
+ return;
452
+ }
453
+
454
+ if( scrollHeight > box.triggerHeight ) {
455
+ box.trigger();
456
+ } else if( box.mayRehide() ) {
457
+ box.hide();
458
+ }
459
+ });
460
+ }
461
+
462
+ // recalculate heights and variables based on height
463
+ function recalculateHeights() {
464
+ windowHeight = window.innerHeight;
465
+
466
+ each(boxes, function(box) {
467
+ box.setCustomBoxStyling();
468
+ });
469
+ }
470
+
471
+ function onOverlayClick(e) {
472
+ var x = e.offsetX;
473
+ var y = e.offsetY;
474
+
475
+ // calculate if click was near a box to avoid closing it (click error margin)
476
+ each(boxes, function(box) {
477
+ var rect = box.element.getBoundingClientRect();
478
+ var margin = 100 + ( window.innerWidth * 0.05 );
479
+
480
+ // if click was not anywhere near box, dismiss it.
481
+ if( x < ( rect.left - margin ) || x > ( rect.right + margin ) || y < ( rect.top - margin ) || y > ( rect.bottom + margin ) ) {
482
+ box.dismiss();
483
+ }
484
+ });
485
+ }
486
+
487
+ function triggerExitIntent() {
488
+ if(exitIntentTriggered) return;
489
+
490
+ each(boxes, function(box) {
491
+ if(box.mayAutoShow() && box.config.trigger.method === 'exit_intent' ) {
492
+ box.trigger();
493
+ }
494
+ });
495
+
496
+ exitIntentTriggered = true;
497
+ }
498
+
499
+ function onMouseLeave(e) {
500
+ // did mouse leave at top of window?
501
+ if( e.clientY < 0 ) {
502
+ exitIntentDelayTimer = window.setTimeout(triggerExitIntent, 1000);
503
+ }
504
+ }
505
+
506
+ function onMouseEnter() {
507
+ if( exitIntentDelayTimer ) {
508
+ window.clearInterval(exitIntentDelayTimer);
509
+ exitIntentDelayTimer = null;
510
+ }
511
+ }
512
+
513
+ // initialise & add event listeners
514
+ Boxzilla.init = function() {
515
+ // add overlay element to dom
516
+ overlay.id = 'boxzilla-overlay';
517
+ document.body.appendChild(overlay);
518
+
519
+ // event binds
520
+ $(window).on('scroll', throttle(checkHeightCriteria));
521
+ $(window).on('resize', throttle(recalculateHeights));
522
+ $(window).on('load', recalculateHeights );
523
+ $(document).on('mouseleave', onMouseLeave);
524
+ $(document).on('mouseenter', onMouseEnter);
525
+ $(document).on('keyup', onKeyUp);
526
+ $(overlay).click(onOverlayClick);
527
+ window.setInterval(checkTimeCriteria, 1000);
528
+
529
+ if(! sessionStorage.getItem('boxzilla_start_time')) {
530
+ sessionStorage.setItem('boxzilla_start_time', Date.now());
531
+ }
532
+
533
+ Boxzilla.trigger('ready');
534
+ };
535
+
536
+ /**
537
+ * Create a new Box
538
+ *
539
+ * @param string id
540
+ * @param object opts
541
+ *
542
+ * @returns Box
543
+ */
544
+ Boxzilla.create = function(id, opts) {
545
+ boxes[id] = new Box(id, opts);
546
+ return boxes[id];
547
+ };
548
+
549
+ // dismiss a single box (or all by omitting id param)
550
+ Boxzilla.dismiss = function(id) {
551
+ // if no id given, dismiss all current open boxes
552
+ if( typeof(id) === "undefined" ) {
553
+ each(boxes, function(box) { box.dismiss(); });
554
+ } else if( typeof( boxes[id] ) === "object" ) {
555
+ boxes[id].dismiss();
556
+ }
557
+ };
558
+
559
+ Boxzilla.hide = function(id) {
560
+ if( typeof(id) === "undefined" ) {
561
+ each(boxes, function(box) { box.hide(); });
562
+ } else if( typeof( boxes[id] ) === "object" ) {
563
+ boxes[id].hide();
564
+ }
565
+ };
566
+
567
+ Boxzilla.show = function(id) {
568
+ if( typeof(id) === "undefined" ) {
569
+ each(boxes, function(box) { box.show(); });
570
+ } else if( typeof( boxes[id] ) === "object" ) {
571
+ boxes[id].show();
572
+ }
573
+ };
574
+
575
+ Boxzilla.toggle = function(id) {
576
+ if( typeof(id) === "undefined" ) {
577
+ each(boxes, function(box) { box.toggle(); });
578
+ } else if( typeof( boxes[id] ) === "object" ) {
579
+ boxes[id].toggle();
580
+ }
581
+ };
582
+
583
+ if ( typeof module !== 'undefined' && module.exports ) {
584
+ module.exports = Boxzilla;
585
+ } else {
586
+ this.Boxzilla = Boxzilla;
587
+ }
588
+ },{"./Box.js":2,"wolfy87-eventemitter":4}],4:[function(require,module,exports){
589
+ /*!
590
+ * EventEmitter v4.2.11 - git.io/ee
591
+ * Unlicense - http://unlicense.org/
592
+ * Oliver Caldwell - http://oli.me.uk/
593
+ * @preserve
594
+ */
595
+
596
+ ;(function () {
597
+ 'use strict';
598
+
599
+ /**
600
+ * Class for managing events.
601
+ * Can be extended to provide event functionality in other classes.
602
+ *
603
+ * @class EventEmitter Manages event registering and emitting.
604
+ */
605
+ function EventEmitter() {}
606
+
607
+ // Shortcuts to improve speed and size
608
+ var proto = EventEmitter.prototype;
609
+ var exports = this;
610
+ var originalGlobalValue = exports.EventEmitter;
611
+
612
+ /**
613
+ * Finds the index of the listener for the event in its storage array.
614
+ *
615
+ * @param {Function[]} listeners Array of listeners to search through.
616
+ * @param {Function} listener Method to look for.
617
+ * @return {Number} Index of the specified listener, -1 if not found
618
+ * @api private
619
+ */
620
+ function indexOfListener(listeners, listener) {
621
+ var i = listeners.length;
622
+ while (i--) {
623
+ if (listeners[i].listener === listener) {
624
+ return i;
625
+ }
626
+ }
627
+
628
+ return -1;
629
+ }
630
+
631
+ /**
632
+ * Alias a method while keeping the context correct, to allow for overwriting of target method.
633
+ *
634
+ * @param {String} name The name of the target method.
635
+ * @return {Function} The aliased method
636
+ * @api private
637
+ */
638
+ function alias(name) {
639
+ return function aliasClosure() {
640
+ return this[name].apply(this, arguments);
641
+ };
642
+ }
643
+
644
+ /**
645
+ * Returns the listener array for the specified event.
646
+ * Will initialise the event object and listener arrays if required.
647
+ * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
648
+ * Each property in the object response is an array of listener functions.
649
+ *
650
+ * @param {String|RegExp} evt Name of the event to return the listeners from.
651
+ * @return {Function[]|Object} All listener functions for the event.
652
+ */
653
+ proto.getListeners = function getListeners(evt) {
654
+ var events = this._getEvents();
655
+ var response;
656
+ var key;
657
+
658
+ // Return a concatenated array of all matching events if
659
+ // the selector is a regular expression.
660
+ if (evt instanceof RegExp) {
661
+ response = {};
662
+ for (key in events) {
663
+ if (events.hasOwnProperty(key) && evt.test(key)) {
664
+ response[key] = events[key];
665
+ }
666
+ }
667
+ }
668
+ else {
669
+ response = events[evt] || (events[evt] = []);
670
+ }
671
+
672
+ return response;
673
+ };
674
+
675
+ /**
676
+ * Takes a list of listener objects and flattens it into a list of listener functions.
677
+ *
678
+ * @param {Object[]} listeners Raw listener objects.
679
+ * @return {Function[]} Just the listener functions.
680
+ */
681
+ proto.flattenListeners = function flattenListeners(listeners) {
682
+ var flatListeners = [];
683
+ var i;
684
+
685
+ for (i = 0; i < listeners.length; i += 1) {
686
+ flatListeners.push(listeners[i].listener);
687
+ }
688
+
689
+ return flatListeners;
690
+ };
691
+
692
+ /**
693
+ * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
694
+ *
695
+ * @param {String|RegExp} evt Name of the event to return the listeners from.
696
+ * @return {Object} All listener functions for an event in an object.
697
+ */
698
+ proto.getListenersAsObject = function getListenersAsObject(evt) {
699
+ var listeners = this.getListeners(evt);
700
+ var response;
701
+
702
+ if (listeners instanceof Array) {
703
+ response = {};
704
+ response[evt] = listeners;
705
+ }
706
+
707
+ return response || listeners;
708
+ };
709
+
710
+ /**
711
+ * Adds a listener function to the specified event.
712
+ * The listener will not be added if it is a duplicate.
713
+ * If the listener returns true then it will be removed after it is called.
714
+ * If you pass a regular expression as the event name then the listener will be added to all events that match it.
715
+ *
716
+ * @param {String|RegExp} evt Name of the event to attach the listener to.
717
+ * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
718
+ * @return {Object} Current instance of EventEmitter for chaining.
719
+ */
720
+ proto.addListener = function addListener(evt, listener) {
721
+ var listeners = this.getListenersAsObject(evt);
722
+ var listenerIsWrapped = typeof listener === 'object';
723
+ var key;
724
+
725
+ for (key in listeners) {
726
+ if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
727
+ listeners[key].push(listenerIsWrapped ? listener : {
728
+ listener: listener,
729
+ once: false
730
+ });
731
+ }
732
+ }
733
+
734
+ return this;
735
+ };
736
+
737
+ /**
738
+ * Alias of addListener
739
+ */
740
+ proto.on = alias('addListener');
741
+
742
+ /**
743
+ * Semi-alias of addListener. It will add a listener that will be
744
+ * automatically removed after its first execution.
745
+ *
746
+ * @param {String|RegExp} evt Name of the event to attach the listener to.
747
+ * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
748
+ * @return {Object} Current instance of EventEmitter for chaining.
749
+ */
750
+ proto.addOnceListener = function addOnceListener(evt, listener) {
751
+ return this.addListener(evt, {
752
+ listener: listener,
753
+ once: true
754
+ });
755
+ };
756
+
757
+ /**
758
+ * Alias of addOnceListener.
759
+ */
760
+ proto.once = alias('addOnceListener');
761
+
762
+ /**
763
+ * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
764
+ * You need to tell it what event names should be matched by a regex.
765
+ *
766
+ * @param {String} evt Name of the event to create.
767
+ * @return {Object} Current instance of EventEmitter for chaining.
768
+ */
769
+ proto.defineEvent = function defineEvent(evt) {
770
+ this.getListeners(evt);
771
+ return this;
772
+ };
773
+
774
+ /**
775
+ * Uses defineEvent to define multiple events.
776
+ *
777
+ * @param {String[]} evts An array of event names to define.
778
+ * @return {Object} Current instance of EventEmitter for chaining.
779
+ */
780
+ proto.defineEvents = function defineEvents(evts) {
781
+ for (var i = 0; i < evts.length; i += 1) {
782
+ this.defineEvent(evts[i]);
783
+ }
784
+ return this;
785
+ };
786
+
787
+ /**
788
+ * Removes a listener function from the specified event.
789
+ * When passed a regular expression as the event name, it will remove the listener from all events that match it.
790
+ *
791
+ * @param {String|RegExp} evt Name of the event to remove the listener from.
792
+ * @param {Function} listener Method to remove from the event.
793
+ * @return {Object} Current instance of EventEmitter for chaining.
794
+ */
795
+ proto.removeListener = function removeListener(evt, listener) {
796
+ var listeners = this.getListenersAsObject(evt);
797
+ var index;
798
+ var key;
799
+
800
+ for (key in listeners) {
801
+ if (listeners.hasOwnProperty(key)) {
802
+ index = indexOfListener(listeners[key], listener);
803
+
804
+ if (index !== -1) {
805
+ listeners[key].splice(index, 1);
806
+ }
807
+ }
808
+ }
809
+
810
+ return this;
811
+ };
812
+
813
+ /**
814
+ * Alias of removeListener
815
+ */
816
+ proto.off = alias('removeListener');
817
+
818
+ /**
819
+ * Adds listeners in bulk using the manipulateListeners method.
820
+ * If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
821
+ * You can also pass it a regular expression to add the array of listeners to all events that match it.
822
+ * Yeah, this function does quite a bit. That's probably a bad thing.
823
+ *
824
+ * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
825
+ * @param {Function[]} [listeners] An optional array of listener functions to add.
826
+ * @return {Object} Current instance of EventEmitter for chaining.
827
+ */
828
+ proto.addListeners = function addListeners(evt, listeners) {
829
+ // Pass through to manipulateListeners
830
+ return this.manipulateListeners(false, evt, listeners);
831
+ };
832
+
833
+ /**
834
+ * Removes listeners in bulk using the manipulateListeners method.
835
+ * If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
836
+ * You can also pass it an event name and an array of listeners to be removed.
837
+ * You can also pass it a regular expression to remove the listeners from all events that match it.
838
+ *
839
+ * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
840
+ * @param {Function[]} [listeners] An optional array of listener functions to remove.
841
+ * @return {Object} Current instance of EventEmitter for chaining.
842
+ */
843
+ proto.removeListeners = function removeListeners(evt, listeners) {
844
+ // Pass through to manipulateListeners
845
+ return this.manipulateListeners(true, evt, listeners);
846
+ };
847
+
848
+ /**
849
+ * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
850
+ * The first argument will determine if the listeners are removed (true) or added (false).
851
+ * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
852
+ * You can also pass it an event name and an array of listeners to be added/removed.
853
+ * You can also pass it a regular expression to manipulate the listeners of all events that match it.
854
+ *
855
+ * @param {Boolean} remove True if you want to remove listeners, false if you want to add.
856
+ * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
857
+ * @param {Function[]} [listeners] An optional array of listener functions to add/remove.
858
+ * @return {Object} Current instance of EventEmitter for chaining.
859
+ */
860
+ proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
861
+ var i;
862
+ var value;
863
+ var single = remove ? this.removeListener : this.addListener;
864
+ var multiple = remove ? this.removeListeners : this.addListeners;
865
+
866
+ // If evt is an object then pass each of its properties to this method
867
+ if (typeof evt === 'object' && !(evt instanceof RegExp)) {
868
+ for (i in evt) {
869
+ if (evt.hasOwnProperty(i) && (value = evt[i])) {
870
+ // Pass the single listener straight through to the singular method
871
+ if (typeof value === 'function') {
872
+ single.call(this, i, value);
873
+ }
874
+ else {
875
+ // Otherwise pass back to the multiple function
876
+ multiple.call(this, i, value);
877
+ }
878
+ }
879
+ }
880
+ }
881
+ else {
882
+ // So evt must be a string
883
+ // And listeners must be an array of listeners
884
+ // Loop over it and pass each one to the multiple method
885
+ i = listeners.length;
886
+ while (i--) {
887
+ single.call(this, evt, listeners[i]);
888
+ }
889
+ }
890
+
891
+ return this;
892
+ };
893
+
894
+ /**
895
+ * Removes all listeners from a specified event.
896
+ * If you do not specify an event then all listeners will be removed.
897
+ * That means every event will be emptied.
898
+ * You can also pass a regex to remove all events that match it.
899
+ *
900
+ * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
901
+ * @return {Object} Current instance of EventEmitter for chaining.
902
+ */
903
+ proto.removeEvent = function removeEvent(evt) {
904
+ var type = typeof evt;
905
+ var events = this._getEvents();
906
+ var key;
907
+
908
+ // Remove different things depending on the state of evt
909
+ if (type === 'string') {
910
+ // Remove all listeners for the specified event
911
+ delete events[evt];
912
+ }
913
+ else if (evt instanceof RegExp) {
914
+ // Remove all events matching the regex.
915
+ for (key in events) {
916
+ if (events.hasOwnProperty(key) && evt.test(key)) {
917
+ delete events[key];
918
+ }
919
+ }
920
+ }
921
+ else {
922
+ // Remove all listeners in all events
923
+ delete this._events;
924
+ }
925
+
926
+ return this;
927
+ };
928
+
929
+ /**
930
+ * Alias of removeEvent.
931
+ *
932
+ * Added to mirror the node API.
933
+ */
934
+ proto.removeAllListeners = alias('removeEvent');
935
+
936
+ /**
937
+ * Emits an event of your choice.
938
+ * When emitted, every listener attached to that event will be executed.
939
+ * If you pass the optional argument array then those arguments will be passed to every listener upon execution.
940
+ * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
941
+ * So they will not arrive within the array on the other side, they will be separate.
942
+ * You can also pass a regular expression to emit to all events that match it.
943
+ *
944
+ * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
945
+ * @param {Array} [args] Optional array of arguments to be passed to each listener.
946
+ * @return {Object} Current instance of EventEmitter for chaining.
947
+ */
948
+ proto.emitEvent = function emitEvent(evt, args) {
949
+ var listenersMap = this.getListenersAsObject(evt);
950
+ var listeners;
951
+ var listener;
952
+ var i;
953
+ var key;
954
+ var response;
955
+
956
+ for (key in listenersMap) {
957
+ if (listenersMap.hasOwnProperty(key)) {
958
+ listeners = listenersMap[key].slice(0);
959
+ i = listeners.length;
960
+
961
+ while (i--) {
962
+ // If the listener returns true then it shall be removed from the event
963
+ // The function is executed either with a basic call or an apply if there is an args array
964
+ listener = listeners[i];
965
+
966
+ if (listener.once === true) {
967
+ this.removeListener(evt, listener.listener);
968
+ }
969
+
970
+ response = listener.listener.apply(this, args || []);
971
+
972
+ if (response === this._getOnceReturnValue()) {
973
+ this.removeListener(evt, listener.listener);
974
+ }
975
+ }
976
+ }
977
+ }
978
+
979
+ return this;
980
+ };
981
+
982
+ /**
983
+ * Alias of emitEvent
984
+ */
985
+ proto.trigger = alias('emitEvent');
986
+
987
+ /**
988
+ * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
989
+ * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
990
+ *
991
+ * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
992
+ * @param {...*} Optional additional arguments to be passed to each listener.
993
+ * @return {Object} Current instance of EventEmitter for chaining.
994
+ */
995
+ proto.emit = function emit(evt) {
996
+ var args = Array.prototype.slice.call(arguments, 1);
997
+ return this.emitEvent(evt, args);
998
+ };
999
+
1000
+ /**
1001
+ * Sets the current value to check against when executing listeners. If a
1002
+ * listeners return value matches the one set here then it will be removed
1003
+ * after execution. This value defaults to true.
1004
+ *
1005
+ * @param {*} value The new value to check for when executing listeners.
1006
+ * @return {Object} Current instance of EventEmitter for chaining.
1007
+ */
1008
+ proto.setOnceReturnValue = function setOnceReturnValue(value) {
1009
+ this._onceReturnValue = value;
1010
+ return this;
1011
+ };
1012
+
1013
+ /**
1014
+ * Fetches the current value to check against when executing listeners. If
1015
+ * the listeners return value matches this one then it should be removed
1016
+ * automatically. It will return true by default.
1017
+ *
1018
+ * @return {*|Boolean} The current value to check for or the default, true.
1019
+ * @api private
1020
+ */
1021
+ proto._getOnceReturnValue = function _getOnceReturnValue() {
1022
+ if (this.hasOwnProperty('_onceReturnValue')) {
1023
+ return this._onceReturnValue;
1024
+ }
1025
+ else {
1026
+ return true;
1027
+ }
1028
+ };
1029
+
1030
+ /**
1031
+ * Fetches the events object and creates one if required.
1032
+ *
1033
+ * @return {Object} The events storage object.
1034
+ * @api private
1035
+ */
1036
+ proto._getEvents = function _getEvents() {
1037
+ return this._events || (this._events = {});
1038
+ };
1039
+
1040
+ /**
1041
+ * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
1042
+ *
1043
+ * @return {Function} Non conflicting EventEmitter class.
1044
+ */
1045
+ EventEmitter.noConflict = function noConflict() {
1046
+ exports.EventEmitter = originalGlobalValue;
1047
+ return EventEmitter;
1048
+ };
1049
+
1050
+ // Expose the class either via AMD, CommonJS or the global object
1051
+ if (typeof define === 'function' && define.amd) {
1052
+ define(function () {
1053
+ return EventEmitter;
1054
+ });
1055
+ }
1056
+ else if (typeof module === 'object' && module.exports){
1057
+ module.exports = EventEmitter;
1058
+ }
1059
+ else {
1060
+ exports.EventEmitter = EventEmitter;
1061
+ }
1062
+ }.call(this));
1063
+
1064
+ },{}]},{},[1]);
1065
+ })();
assets/js/script.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ !function(){var e=void 0,t=void 0;!function i(t,n,o){function r(c,l){if(!n[c]){if(!t[c]){var a="function"==typeof e&&e;if(!l&&a)return a(c,!0);if(s)return s(c,!0);var h=new Error("Cannot find module '"+c+"'");throw h.code="MODULE_NOT_FOUND",h}var u=n[c]={exports:{}};t[c][0].call(u.exports,function(e){var i=t[c][1][e];return r(i?i:e)},u,u.exports,i,t,n,o)}return n[c].exports}for(var s="function"==typeof e&&e,c=0;c<o.length;c++)r(o[c]);return r}({1:[function(e,t,i){"use strict";function n(e,t){t.background_color&&(e.style.background=t.background_color),t.color&&(e.style.color=t.color),t.border_color&&(e.style.borderColor=t.border_color),t.border_width&&(e.style.borderWidth=parseInt(t.border_width)+"px"),t.border_style&&(e.style.borderStyle=t.border_style),t.width&&(e.style.maxWidth=parseInt(t.width)+"px")}var o=e("boxzilla"),r=window.boxzilla_options,s=document.body.className.indexOf("logged-in")>-1;s&&r.testMode&&console.log("Boxzilla: Test mode is enabled. Please disable test mode if you're done testing."),o.init();for(var c=0;c<r.boxes.length;c++){var l=r.boxes[c];l.testMode=s&&r.testMode;var a=o.create(l.id,l);n(a.element,l.css)}window.Boxzilla=o},{boxzilla:3}],2:[function(e,t,i){"use strict";function n(e,t){var i={};for(var n in e)i[n]=e[n];for(var n in t)i[n]=t[n];return i}var o,r=window.jQuery,s={animation:"fade",rehide:!1,content:"",cookieTime:0,icon:"&times",minimumScreenWidth:0,position:"center",testMode:!1,trigger:!1,closable:!0},c=function(e,t){this.id=e,this.config=n(s,t),this.overlay=document.getElementById("boxzilla-overlay"),this.visible=!1,this.closed=!1,this.triggered=!1,this.triggerHeight=0,this.cookieSet=!1,this.config.trigger&&("percentage"!==this.config.trigger.method&&"element"!==this.config.trigger.method||(this.triggerHeight=this.calculateTriggerHeight()),this.cookieSet=this.isCookieSet()),this.element=this.dom(),this.$element=r(this.element),this.events()};c.prototype.events=function(){var e=this;this.$element.find(".boxzilla-close-icon").click(e.dismiss.bind(this)),this.$element.on("click","a",function(t){o.trigger("box.interactions.link",[e,t.target])}),this.$element.on("submit","form",function(t){e.setCookie(),o.trigger("box.interactions.form",[e,t.target])}),r(document.body).on("click",'a[href="#boxzilla-'+e.id+'"]',function(){return e.toggle(),!1}),"time_on_page"===this.config.trigger.method&&this.mayAutoShow()?window.setTimeout(this.trigger.bind(this),1e3*this.config.trigger.value):this.fits()&&this.locationHashRefersBox()&&r(window).load(this.show.bind(this))},c.prototype.dom=function(){var e=document.createElement("div");e.className="boxzilla-container boxzilla-"+this.config.position+"-container";var t=document.createElement("div");t.className="boxzilla boxzilla-"+this.id+" boxzilla-"+this.config.position,t.style.display="none",e.appendChild(t);var i=document.createElement("div");if(i.className="boxzilla-content",i.innerHTML=this.config.content,t.appendChild(i),this.config.closable&&this.config.icon){var n=document.createElement("span");n.className="boxzilla-close-icon",n.innerHTML=this.config.icon,t.appendChild(n)}return document.body.appendChild(e),t},c.prototype.setCustomBoxStyling=function(){this.element.style.overflowY="auto",this.element.style.maxHeight="none";var e=window.innerHeight,t=this.$element.outerHeight();if(t>e&&(this.element.style.maxHeight=e+"px",this.element.style.overflowY="scroll"),"center"===this.config.position){var i=(e-t)/2;i=i>=0?i:0,this.element.style.marginTop=i+"px"}},c.prototype.toggle=function(e){return"undefined"==typeof e&&(e=!this.visible),this.$element.is(":animated")?!1:e===this.visible?!1:e||this.config.closable?(this.visible=e,this.setCustomBoxStyling(),"center"===this.config.position&&r(this.overlay).fadeToggle("slow"),o.trigger("box."+(e?"show":"hide"),[this]),"fade"===this.config.animation?this.$element.fadeToggle("slow"):this.$element.slideToggle("slow"),!0):!1},c.prototype.show=function(){return this.toggle(!0)},c.prototype.hide=function(){return this.toggle(!1)},c.prototype.calculateTriggerHeight=function(){var e=0;if("element"===this.config.trigger.method){var t=r(this.config.trigger.value).first();e=t.length>0?t.offset().top:0}else"percentage"===this.config.trigger.method&&(e=this.config.trigger.value/100*r(document).height());return e},c.prototype.setCookie=function(){if(this.config.cookieTime){var e=new Date;e.setDate(e.getDate()+this.config.cookieTime),document.cookie="boxzilla_box_"+this.id+"=true; expires="+e.toUTCString()+"; path=/"}},c.prototype.locationHashRefersBox=function(){if(!window.location.hash||0===window.location.hash.length)return!1;var e=window.location.hash.substring(1);return e===this.element.id?!0:!!this.element.querySelector("#"+e)},c.prototype.fits=function(){return this.config.minimumScreenWidth<=0?!0:window.innerWidth>this.config.minimumScreenWidth},c.prototype.mayAutoShow=function(){return this.closed?!1:this.fits()&&this.config.trigger?!this.cookieSet:!1},c.prototype.mayRehide=function(){return this.config.rehide&&this.triggered},c.prototype.isCookieSet=function(){if(this.config.testMode)return!1;if(!this.config.cookieTime)return!1;var e="true"===document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*boxzilla_box_"+this.id+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1");return e},c.prototype.trigger=function(){var e=this.show();e&&(this.triggered=!0)},c.prototype.dismiss=function(){this.hide(),this.setCookie(),this.closed=!0,o.trigger("box.dismiss",[this])},t.exports=function(e){return o=e,c}},{}],3:[function(e,t,i){"use strict";function n(e,t){for(var i in e)e.hasOwnProperty(i)&&t(e[i])}function o(e,t,i){t||(t=250);var n,o;return function(){var r=i||this,s=+new Date,c=arguments;n&&n+t>s?(clearTimeout(o),o=setTimeout(function(){n=s,e.apply(r,c)},t)):(n=s,e.apply(r,c))}}function r(e){27==e.keyCode&&v.dismiss()}function s(){var e=sessionStorage.getItem("boxzilla_start_time"),t=Date.now(),i=(t-e)/1e3;n(w,function(e){e.mayAutoShow()&&"time_on_site"===e.config.trigger.method&&i>e.config.trigger.value&&e.trigger()})}function c(){var e=window.scrollY,t=e+.9*b;n(w,function(e){!e.mayAutoShow()||e.triggerHeight<=0||(t>e.triggerHeight?e.trigger():e.mayRehide()&&e.hide())})}function l(){b=window.innerHeight,n(w,function(e){e.setCustomBoxStyling()})}function a(e){var t=e.offsetX,i=e.offsetY;n(w,function(e){var n=e.element.getBoundingClientRect(),o=100+.05*window.innerWidth;(t<n.left-o||t>n.right+o||i<n.top-o||i>n.bottom+o)&&e.dismiss()})}function h(){g||(n(w,function(e){e.mayAutoShow()&&"exit_intent"===e.config.trigger.method&&e.trigger()}),g=!0)}function u(e){e.clientY<0&&(d=window.setTimeout(h,1e3))}function f(){d&&(window.clearInterval(d),d=null)}var d,g,m=window.jQuery,p=e("wolfy87-eventemitter"),v=Object.create(p.prototype),y=e("./Box.js")(v),w={},b=window.innerHeight,x=document.createElement("div");v.init=function(){x.id="boxzilla-overlay",document.body.appendChild(x),m(window).on("scroll",o(c)),m(window).on("resize",o(l)),m(window).on("load",l),m(document).on("mouseleave",u),m(document).on("mouseenter",f),m(document).on("keyup",r),m(x).click(a),window.setInterval(s,1e3),sessionStorage.getItem("boxzilla_start_time")||sessionStorage.setItem("boxzilla_start_time",Date.now()),v.trigger("ready")},v.create=function(e,t){return w[e]=new y(e,t),w[e]},v.dismiss=function(e){"undefined"==typeof e?n(w,function(e){e.dismiss()}):"object"==typeof w[e]&&w[e].dismiss()},v.hide=function(e){"undefined"==typeof e?n(w,function(e){e.hide()}):"object"==typeof w[e]&&w[e].hide()},v.show=function(e){"undefined"==typeof e?n(w,function(e){e.show()}):"object"==typeof w[e]&&w[e].show()},v.toggle=function(e){"undefined"==typeof e?n(w,function(e){e.toggle()}):"object"==typeof w[e]&&w[e].toggle()},"undefined"!=typeof t&&t.exports?t.exports=v:this.Boxzilla=v},{"./Box.js":2,"wolfy87-eventemitter":4}],4:[function(e,i,n){(function(){"use strict";function e(){}function n(e,t){for(var i=e.length;i--;)if(e[i].listener===t)return i;return-1}function o(e){return function(){return this[e].apply(this,arguments)}}var r=e.prototype,s=this,c=s.EventEmitter;r.getListeners=function(e){var t,i,n=this._getEvents();if(e instanceof RegExp){t={};for(i in n)n.hasOwnProperty(i)&&e.test(i)&&(t[i]=n[i])}else t=n[e]||(n[e]=[]);return t},r.flattenListeners=function(e){var t,i=[];for(t=0;t<e.length;t+=1)i.push(e[t].listener);return i},r.getListenersAsObject=function(e){var t,i=this.getListeners(e);return i instanceof Array&&(t={},t[e]=i),t||i},r.addListener=function(e,t){var i,o=this.getListenersAsObject(e),r="object"==typeof t;for(i in o)o.hasOwnProperty(i)&&-1===n(o[i],t)&&o[i].push(r?t:{listener:t,once:!1});return this},r.on=o("addListener"),r.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},r.once=o("addOnceListener"),r.defineEvent=function(e){return this.getListeners(e),this},r.defineEvents=function(e){for(var t=0;t<e.length;t+=1)this.defineEvent(e[t]);return this},r.removeListener=function(e,t){var i,o,r=this.getListenersAsObject(e);for(o in r)r.hasOwnProperty(o)&&(i=n(r[o],t),-1!==i&&r[o].splice(i,1));return this},r.off=o("removeListener"),r.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},r.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},r.manipulateListeners=function(e,t,i){var n,o,r=e?this.removeListener:this.addListener,s=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(n=i.length;n--;)r.call(this,t,i[n]);else for(n in t)t.hasOwnProperty(n)&&(o=t[n])&&("function"==typeof o?r.call(this,n,o):s.call(this,n,o));return this},r.removeEvent=function(e){var t,i=typeof e,n=this._getEvents();if("string"===i)delete n[e];else if(e instanceof RegExp)for(t in n)n.hasOwnProperty(t)&&e.test(t)&&delete n[t];else delete this._events;return this},r.removeAllListeners=o("removeEvent"),r.emitEvent=function(e,t){var i,n,o,r,s,c=this.getListenersAsObject(e);for(r in c)if(c.hasOwnProperty(r))for(i=c[r].slice(0),o=i.length;o--;)n=i[o],n.once===!0&&this.removeListener(e,n.listener),s=n.listener.apply(this,t||[]),s===this._getOnceReturnValue()&&this.removeListener(e,n.listener);return this},r.trigger=o("emitEvent"),r.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},r.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},r._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},r._getEvents=function(){return this._events||(this._events={})},e.noConflict=function(){return s.EventEmitter=c,e},"function"==typeof t&&t.amd?t(function(){return e}):"object"==typeof i&&i.exports?i.exports=e:s.EventEmitter=e}).call(this)},{}]},{},[1])}();
2
+ //# sourceMappingURL=script.min.js.map
assets/js/script.min.js.map ADDED
@@ -0,0 +1 @@
 
1
+ {"version":3,"sources":["script.js"],"names":["require","undefined","define","e","t","n","r","s","o","u","a","i","f","Error","code","l","exports","call","length","1","module","css","element","styles","background_color","style","background","color","border_color","borderColor","border_width","borderWidth","parseInt","border_style","borderStyle","width","maxWidth","Boxzilla","options","window","boxzilla_options","isLoggedIn","document","body","className","indexOf","testMode","console","log","init","boxes","boxOpts","box","create","id","boxzilla","2","merge","obj1","obj2","obj3","attrname","$","jQuery","defaults","animation","rehide","content","cookieTime","icon","minimumScreenWidth","position","trigger","closable","Box","config","this","overlay","getElementById","visible","closed","triggered","triggerHeight","cookieSet","method","calculateTriggerHeight","isCookieSet","dom","$element","events","prototype","find","click","dismiss","bind","on","target","setCookie","toggle","mayAutoShow","setTimeout","value","fits","locationHashRefersBox","load","show","wrapper","createElement","display","appendChild","innerHTML","setCustomBoxStyling","overflowY","maxHeight","windowHeight","innerHeight","boxHeight","outerHeight","newTopMargin","marginTop","is","fadeToggle","slideToggle","hide","$triggerElement","first","offset","top","height","expiryDate","Date","setDate","getDate","cookie","toUTCString","location","hash","elementId","substring","querySelector","innerWidth","mayRehide","replace","RegExp","shown","_Boxzilla","3","each","obj","callback","key","hasOwnProperty","throttle","fn","threshhold","scope","last","deferTimer","context","now","args","arguments","clearTimeout","apply","onKeyUp","keyCode","checkTimeCriteria","start","sessionStorage","getItem","timeOnSite","checkHeightCriteria","scrollY","scrollHeight","recalculateHeights","onOverlayClick","x","offsetX","y","offsetY","rect","getBoundingClientRect","margin","left","right","bottom","triggerExitIntent","exitIntentTriggered","onMouseLeave","clientY","exitIntentDelayTimer","onMouseEnter","clearInterval","EventEmitter","Object","setInterval","setItem","opts","./Box.js","wolfy87-eventemitter","4","indexOfListener","listeners","listener","alias","name","proto","originalGlobalValue","getListeners","evt","response","_getEvents","test","flattenListeners","flatListeners","push","getListenersAsObject","Array","addListener","listenerIsWrapped","once","addOnceListener","defineEvent","defineEvents","evts","removeListener","index","splice","off","addListeners","manipulateListeners","removeListeners","remove","single","multiple","removeEvent","type","_events","removeAllListeners","emitEvent","listenersMap","slice","_getOnceReturnValue","emit","setOnceReturnValue","_onceReturnValue","noConflict","amd"],"mappings":"CAAA,WAAe,GAAIA,GAAUC,OAAeC,EAASD,QAAW,QAAUE,GAAEC,EAAEC,EAAEC,GAAG,QAASC,GAAEC,EAAEC,GAAG,IAAIJ,EAAEG,GAAG,CAAC,IAAIJ,EAAEI,GAAG,CAAC,GAAIE,GAAkB,kBAATV,IAAqBA,CAAQ,KAAIS,GAAGC,EAAE,MAAOA,GAAEF,GAAE,EAAI,IAAGG,EAAE,MAAOA,GAAEH,GAAE,EAAI,IAAII,GAAE,GAAIC,OAAM,uBAAuBL,EAAE,IAAK,MAAMI,GAAEE,KAAK,mBAAmBF,EAAE,GAAIG,GAAEV,EAAEG,IAAIQ,WAAYZ,GAAEI,GAAG,GAAGS,KAAKF,EAAEC,QAAQ,SAASb,GAAG,GAAIE,GAAED,EAAEI,GAAG,GAAGL,EAAG,OAAOI,GAAEF,EAAEA,EAAEF,IAAIY,EAAEA,EAAEC,QAAQb,EAAEC,EAAEC,EAAEC,GAAG,MAAOD,GAAEG,GAAGQ,QAAkD,IAAI,GAA1CL,GAAkB,kBAATX,IAAqBA,EAAgBQ,EAAE,EAAEA,EAAEF,EAAEY,OAAOV,IAAID,EAAED,EAAEE,GAAI,OAAOD,KAAKY,GAAG,SAASnB,EAAQoB,EAAOJ,GACvhB,YA2BA,SAASK,GAAIC,EAASC,GACdA,EAAOC,mBACPF,EAAQG,MAAMC,WAAaH,EAAOC,kBAGlCD,EAAOI,QACPL,EAAQG,MAAME,MAAQJ,EAAOI,OAG7BJ,EAAOK,eACPN,EAAQG,MAAMI,YAAcN,EAAOK,cAGnCL,EAAOO,eACPR,EAAQG,MAAMM,YAAcC,SAAST,EAAOO,cAAgB,MAG5DP,EAAOU,eACPX,EAAQG,MAAMS,YAAcX,EAAOU,cAGnCV,EAAOY,QACPb,EAAQG,MAAMW,SAAWJ,SAAST,EAAOY,OAAS,MA/C1D,GAAIE,GAAWrC,EAAQ,YACnBsC,EAAUC,OAAOC,iBACjBC,EAAaC,SAASC,KAAKC,UAAUC,QAAQ,aAAe,EAG5DJ,IAAcH,EAAQQ,UACtBC,QAAQC,IAAK,oFAIjBX,EAASY,MAGT,KAAK,GAAItC,GAAE,EAAGA,EAAI2B,EAAQY,MAAMhC,OAAQP,IAAM,CAE1C,GAAIwC,GAAUb,EAAQY,MAAMvC,EAC5BwC,GAAQL,SAAWL,GAAcH,EAAQQ,QAGzC,IAAIM,GAAMf,EAASgB,OAAQF,EAAQG,GAAIH,EAGvC9B,GAAI+B,EAAI9B,QAAS6B,EAAQ9B,KA6B7BkB,OAAOF,SAAWA,IACfkB,SAAW,IAAIC,GAAG,SAASxD,EAAQoB,EAAOJ,GAC7C,YAuBA,SAASyC,GAAOC,EAAMC,GAClB,GAAIC,KACJ,KAAK,GAAIC,KAAYH,GAAQE,EAAKC,GAAYH,EAAKG,EACnD,KAAK,GAAIA,KAAYF,GAAQC,EAAKC,GAAYF,EAAKE,EACnD,OAAOD,GAzBX,GAYOvB,GAZHyB,EAAIvB,OAAOwB,OACXC,GACIC,UAAa,OACbC,QAAU,EACVC,QAAW,GACXC,WAAc,EACdC,KAAQ,SACRC,mBAAsB,EACtBC,SAAY,SACZzB,UAAY,EACZ0B,SAAW,EACXC,UAAY,GAkBhBC,EAAM,SAAUpB,EAAIqB,GACpBC,KAAKtB,GAAOA,EAGZsB,KAAKD,OAASlB,EAAMO,EAAUW,GAG9BC,KAAKC,QAAUnC,SAASoC,eAAe,oBAGvCF,KAAKG,SAAW,EAChBH,KAAKI,QAAU,EACfJ,KAAKK,WAAa,EAClBL,KAAKM,cAAgB,EACrBN,KAAKO,WAAY,EAGbP,KAAKD,OAAOH,UACuB,eAA/BI,KAAKD,OAAOH,QAAQY,QAA0D,YAA/BR,KAAKD,OAAOH,QAAQY,SACnER,KAAKM,cAAgBN,KAAKS,0BAG9BT,KAAKO,UAAYP,KAAKU,eAI1BV,KAAKtD,QAAUsD,KAAKW,MACpBX,KAAKY,SAAW1B,EAAEc,KAAKtD,SAGvBsD,KAAKa,SAITf,GAAIgB,UAAUD,OAAS,WACnB,GAAIrC,GAAMwB,IAGVA,MAAKY,SAASG,KAAK,wBAAwBC,MAAMxC,EAAIyC,QAAQC,KAAKlB,OAElEA,KAAKY,SAASO,GAAG,QAAS,IAAK,SAAS5F,GACpCkC,EAASmC,QAAQ,yBAA2BpB,EAAKjD,EAAE6F,WAGvDpB,KAAKY,SAASO,GAAG,SAAU,OAAQ,SAAS5F,GACxCiD,EAAI6C,YACJ5D,EAASmC,QAAQ,yBAA2BpB,EAAKjD,EAAE6F,WAIvDlC,EAAEpB,SAASC,MAAMoD,GAAG,QAAS,qBAAuB3C,EAAIE,GAAK,KAAM,WAE/D,MADAF,GAAI8C,UACG,IAIwB,iBAA/BtB,KAAKD,OAAOH,QAAQY,QAA6BR,KAAKuB,cACtD5D,OAAO6D,WAAWxB,KAAKJ,QAAQsB,KAAKlB,MAAmC,IAA5BA,KAAKD,OAAOH,QAAQ6B,OAExDzB,KAAK0B,QAAU1B,KAAK2B,yBAC3BzC,EAAEvB,QAAQiE,KAAK5B,KAAK6B,KAAKX,KAAKlB,QAMtCF,EAAIgB,UAAUH,IAAM,WAEhB,GAAImB,GAAUhE,SAASiE,cAAc,MACrCD,GAAQ9D,UAAY,+BAAiCgC,KAAKD,OAAOJ,SAAW,YAE5E,IAAInB,GAAMV,SAASiE,cAAc,MACjCvD,GAAIR,UAAY,qBAAuBgC,KAAKtB,GAAK,aAAesB,KAAKD,OAAOJ,SAC5EnB,EAAI3B,MAAMmF,QAAU,OACpBF,EAAQG,YAAYzD,EAEpB,IAAIe,GAAUzB,SAASiE,cAAc,MAKrC,IAJAxC,EAAQvB,UAAY,mBACpBuB,EAAQ2C,UAAYlC,KAAKD,OAAOR,QAChCf,EAAIyD,YAAY1C,GAEZS,KAAKD,OAAOF,UAAYG,KAAKD,OAAON,KAAO,CAC3C,GAAIA,GAAO3B,SAASiE,cAAc,OAClCtC,GAAKzB,UAAY,sBACjByB,EAAKyC,UAAYlC,KAAKD,OAAON,KAC7BjB,EAAIyD,YAAYxC,GAKpB,MAFA3B,UAASC,KAAKkE,YAAYH,GAEnBtD,GAIXsB,EAAIgB,UAAUqB,oBAAsB,WAGhCnC,KAAKtD,QAAQG,MAAMuF,UAAY,OAC/BpC,KAAKtD,QAAQG,MAAMwF,UAAY,MAG/B,IAAIC,GAAe3E,OAAO4E,YACtBC,EAAYxC,KAAKY,SAAS6B,aAS9B,IANID,EAAYF,IACZtC,KAAKtD,QAAQG,MAAMwF,UAAYC,EAAe,KAC9CtC,KAAKtD,QAAQG,MAAMuF,UAAY,UAIN,WAAzBpC,KAAKD,OAAOJ,SAAwB,CACpC,GAAI+C,IAAmBJ,EAAeE,GAAc,CACpDE,GAAeA,GAAgB,EAAIA,EAAe,EAClD1C,KAAKtD,QAAQG,MAAM8F,UAAYD,EAAe,OAMtD5C,EAAIgB,UAAUQ,OAAS,SAASO,GAQ5B,MALuB,mBAAb,KACNA,GAAS7B,KAAKG,SAIdH,KAAKY,SAASgC,GAAG,cACV,EAIPf,IAAS7B,KAAKG,SACP,EAIL0B,GAAU7B,KAAKD,OAAOF,UAK5BG,KAAKG,QAAU0B,EAGf7B,KAAKmC,sBAGwB,WAAzBnC,KAAKD,OAAOJ,UACZT,EAAEc,KAAKC,SAAS4C,WAAW,QAI/BpF,EAASmC,QAAQ,QAAWiC,EAAO,OAAS,SAAY7B,OAG1B,SAA1BA,KAAKD,OAAOV,UACZW,KAAKY,SAASiC,WAAY,QAE1B7C,KAAKY,SAASkC,YAAa,SAMxB,IA3BI,GA+BfhD,EAAIgB,UAAUe,KAAO,WACjB,MAAO7B,MAAKsB,QAAO,IAIvBxB,EAAIgB,UAAUiC,KAAO,WACjB,MAAO/C,MAAKsB,QAAO,IAIvBxB,EAAIgB,UAAUL,uBAAyB,WACnC,GAAIH,GAAgB,CAEpB,IAAmC,YAA/BN,KAAKD,OAAOH,QAAQY,OAAuB,CAC3C,GAAIwC,GAAkB9D,EAAEc,KAAKD,OAAOH,QAAQ6B,OAAOwB,OACnD3C,GAAkB0C,EAAgB1G,OAAS,EAAM0G,EAAgBE,SAASC,IAAM,MAC1C,eAA/BnD,KAAKD,OAAOH,QAAQY,SAC3BF,EAAkBN,KAAKD,OAAOH,QAAQ6B,MAAQ,IAAMvC,EAAEpB,UAAUsF,SAGpE,OAAO9C,IAIXR,EAAIgB,UAAUO,UAAY,WAEtB,GAAKrB,KAAKD,OAAOP,WAAjB,CAIA,GAAI6D,GAAa,GAAIC,KACrBD,GAAWE,QAASF,EAAWG,UAAYxD,KAAKD,OAAOP,YACvD1B,SAAS2F,OAAS,gBAAiBzD,KAAKtB,GAAK,kBAAmB2E,EAAWK,cAAe,aAI9F5D,EAAIgB,UAAUa,sBAAwB,WAElC,IAAMhE,OAAOgG,SAASC,MAAQ,IAAMjG,OAAOgG,SAASC,KAAKtH,OACrD,OAAO,CAGX,IAAIuH,GAAYlG,OAAOgG,SAASC,KAAKE,UAAU,EAC/C,OAAID,KAAc7D,KAAKtD,QAAQgC,IACpB,IACAsB,KAAKtD,QAAQqH,cAAc,IAAMF,IAOhD/D,EAAIgB,UAAUY,KAAO,WACjB,MAAI1B,MAAKD,OAAOL,oBAAsB,GAC3B,EAGJ/B,OAAOqG,WAAahE,KAAKD,OAAOL,oBAI3CI,EAAIgB,UAAUS,YAAc,WAGxB,MAAIvB,MAAKI,QACE,EAILJ,KAAK0B,QAKL1B,KAAKD,OAAOH,SAKTI,KAAKO,WATH,GAYfT,EAAIgB,UAAUmD,UAAY,WACtB,MAAOjE,MAAKD,OAAOT,QAAUU,KAAKK,WAGtCP,EAAIgB,UAAUJ,YAAc,WAExB,GAAIV,KAAKD,OAAO7B,SACZ,OAAO,CAIX,KAAM8B,KAAKD,OAAOP,WACd,OAAO,CAGX,IAAIe,GAA0I,SAA9HzC,SAAS2F,OAAOS,QAAQ,GAAIC,QAAO,gCAAuCnE,KAAKtB,GAAK,+BAAgC,KACpI,OAAO6B,IAIXT,EAAIgB,UAAUlB,QAAU,WACpB,GAAIwE,GAAQpE,KAAK6B,MACbuC,KACApE,KAAKK,WAAY,IAIzBP,EAAIgB,UAAUG,QAAU,WACpBjB,KAAK+C,OACL/C,KAAKqB,YACLrB,KAAKI,QAAS,EACd3C,EAASmC,QAAQ,eAAiBI,QAGtCxD,EAAOJ,QAAU,SAASiI,GAEtB,MADA5G,GAAW4G,EACJvE,QAELwE,GAAG,SAASlJ,EAAQoB,EAAOJ,GACjC,YAYA,SAASmI,GAAMC,EAAKC,GAChB,IAAK,GAAIC,KAAOF,GACPA,EAAIG,eAAeD,IACxBD,EAASD,EAAIE,IAIrB,QAASE,GAASC,EAAIC,EAAYC,GAC9BD,IAAeA,EAAa,IAC5B,IAAIE,GACAC,CACJ,OAAO,YACH,GAAIC,GAAUH,GAAS/E,KAEnBmF,GAAO,GAAI7B,MACX8B,EAAOC,SACPL,IAAcA,EAAOF,EAAbK,GAERG,aAAaL,GACbA,EAAazD,WAAW,WACpBwD,EAAOG,EACPN,EAAGU,MAAML,EAASE,IACnBN,KAEHE,EAAOG,EACPN,EAAGU,MAAML,EAASE,KAM9B,QAASI,GAAQjK,GACI,IAAbA,EAAEkK,SACFhI,EAASwD,UAIjB,QAASyE,KACL,GAAIC,GAAQC,eAAeC,QAAQ,uBAC/BV,EAAM7B,KAAK6B,MACXW,GAAeX,EAAMQ,GAAU,GAEnCpB,GAAKjG,EAAO,SAASE,GACXA,EAAI+C,eAA+C,iBAA9B/C,EAAIuB,OAAOH,QAAQY,QAI1CsF,EAAatH,EAAIuB,OAAOH,QAAQ6B,OAChCjD,EAAIoB,YAMhB,QAASmG,KACL,GAAIC,GAAUrI,OAAOqI,QACjBC,EAAeD,EAA2B,GAAf1D,CAE/BiC,GAAKjG,EAAO,SAASE,IACXA,EAAI+C,eAAiB/C,EAAI8B,eAAiB,IAI5C2F,EAAezH,EAAI8B,cACnB9B,EAAIoB,UACGpB,EAAIyF,aACXzF,EAAIuE,UAMhB,QAASmD,KACL5D,EAAe3E,OAAO4E,YAEtBgC,EAAKjG,EAAO,SAASE,GACjBA,EAAI2D,wBAIZ,QAASgE,GAAe5K,GACpB,GAAI6K,GAAI7K,EAAE8K,QACNC,EAAI/K,EAAEgL,OAGVhC,GAAKjG,EAAO,SAASE,GACjB,GAAIgI,GAAOhI,EAAI9B,QAAQ+J,wBACnBC,EAAS,IAA4B,IAApB/I,OAAOqG,YAGxBoC,EAAMI,EAAKG,KAAOD,GAAYN,EAAMI,EAAKI,MAAQF,GAAYJ,EAAME,EAAKrD,IAAMuD,GAAYJ,EAAME,EAAKK,OAASH,IAC9GlI,EAAIyC,YAKhB,QAAS6F,KACFC,IAEHxC,EAAKjG,EAAO,SAASE,GACdA,EAAI+C,eAA+C,gBAA9B/C,EAAIuB,OAAOH,QAAQY,QACvChC,EAAIoB,YAIZmH,GAAsB,GAG1B,QAASC,GAAazL,GAEdA,EAAE0L,QAAU,IACZC,EAAuBvJ,OAAO6D,WAAWsF,EAAmB,MAIpE,QAASK,KACDD,IACAvJ,OAAOyJ,cAAcF,GACrBA,EAAuB,MAhI/B,GAOIA,GACAH,EARA7H,EAAIvB,OAAOwB,OACXkI,EAAejM,EAAQ,wBACvBqC,EAAW6J,OAAO7I,OAAO4I,EAAavG,WACtChB,EAAM1E,EAAQ,YAAYqC,GAC1Ba,KACAgE,EAAe3E,OAAO4E,YACtBtC,EAAUnC,SAASiE,cAAc,MA+HrCtE,GAASY,KAAO,WAEZ4B,EAAQvB,GAAK,mBACbZ,SAASC,KAAKkE,YAAYhC,GAG1Bf,EAAEvB,QAAQwD,GAAG,SAAUyD,EAASmB,IAChC7G,EAAEvB,QAAQwD,GAAG,SAAUyD,EAASsB,IAChChH,EAAEvB,QAAQwD,GAAG,OAAQ+E,GACrBhH,EAAEpB,UAAUqD,GAAG,aAAc6F,GAC7B9H,EAAEpB,UAAUqD,GAAG,aAAcgG,GAC7BjI,EAAEpB,UAAUqD,GAAG,QAASqE,GACxBtG,EAAEe,GAASe,MAAMmF,GACjBxI,OAAO4J,YAAY7B,EAAmB,KAEjCE,eAAeC,QAAQ,wBACxBD,eAAe4B,QAAQ,sBAAuBlE,KAAK6B,OAGvD1H,EAASmC,QAAQ,UAWrBnC,EAASgB,OAAS,SAASC,EAAI+I,GAE3B,MADAnJ,GAAMI,GAAM,GAAIoB,GAAIpB,EAAI+I,GACjBnJ,EAAMI,IAIjBjB,EAASwD,QAAU,SAASvC,GAEL,mBAAT,GACN6F,EAAKjG,EAAO,SAASE,GAAOA,EAAIyC,YACD,gBAAhB3C,GAAMI,IACrBJ,EAAMI,GAAIuC,WAIlBxD,EAASsF,KAAO,SAASrE,GACF,mBAAT,GACN6F,EAAKjG,EAAO,SAASE,GAAOA,EAAIuE,SACD,gBAAhBzE,GAAMI,IACrBJ,EAAMI,GAAIqE,QAIlBtF,EAASoE,KAAO,SAASnD,GACF,mBAAT,GACN6F,EAAKjG,EAAO,SAASE,GAAOA,EAAIqD,SACD,gBAAhBvD,GAAMI,IACrBJ,EAAMI,GAAImD,QAIlBpE,EAAS6D,OAAS,SAAS5C,GACJ,mBAAT,GACN6F,EAAKjG,EAAO,SAASE,GAAOA,EAAI8C,WACD,gBAAhBhD,GAAMI,IACrBJ,EAAMI,GAAI4C,UAIK,mBAAX9E,IAA0BA,EAAOJ,QACzCI,EAAOJ,QAAUqB,EAEjBuC,KAAKvC,SAAWA,IAEjBiK,WAAW,EAAEC,uBAAuB,IAAIC,GAAG,SAASxM,EAAQoB,EAAOJ,IAQpE,WACE,YAQA,SAASiL,MAeT,QAASQ,GAAgBC,EAAWC,GAEhC,IADA,GAAIhM,GAAI+L,EAAUxL,OACXP,KACH,GAAI+L,EAAU/L,GAAGgM,WAAaA,EAC1B,MAAOhM,EAIf,OAAO,GAUX,QAASiM,GAAMC,GACX,MAAO,YACH,MAAOjI,MAAKiI,GAAM1C,MAAMvF,KAAMqF,YAhCtC,GAAI6C,GAAQb,EAAavG,UACrB1E,EAAU4D,KACVmI,EAAsB/L,EAAQiL,YA2ClCa,GAAME,aAAe,SAAsBC,GACvC,GACIC,GACA5D,EAFA7D,EAASb,KAAKuI,YAMlB,IAAIF,YAAelE,QAAQ,CACvBmE,IACA,KAAK5D,IAAO7D,GACJA,EAAO8D,eAAeD,IAAQ2D,EAAIG,KAAK9D,KACvC4D,EAAS5D,GAAO7D,EAAO6D,QAK/B4D,GAAWzH,EAAOwH,KAASxH,EAAOwH,MAGtC,OAAOC,IASXJ,EAAMO,iBAAmB,SAA0BX,GAC/C,GACI/L,GADA2M,IAGJ,KAAK3M,EAAI,EAAGA,EAAI+L,EAAUxL,OAAQP,GAAK,EACnC2M,EAAcC,KAAKb,EAAU/L,GAAGgM,SAGpC,OAAOW,IASXR,EAAMU,qBAAuB,SAA8BP,GACvD,GACIC,GADAR,EAAY9H,KAAKoI,aAAaC,EAQlC,OALIP,aAAqBe,SACrBP,KACAA,EAASD,GAAOP,GAGbQ,GAAYR,GAavBI,EAAMY,YAAc,SAAqBT,EAAKN,GAC1C,GAEIrD,GAFAoD,EAAY9H,KAAK4I,qBAAqBP,GACtCU,EAAwC,gBAAbhB,EAG/B,KAAKrD,IAAOoD,GACJA,EAAUnD,eAAeD,IAAsD,KAA9CmD,EAAgBC,EAAUpD,GAAMqD,IACjED,EAAUpD,GAAKiE,KAAKI,EAAoBhB,GACpCA,SAAUA,EACViB,MAAM,GAKlB,OAAOhJ,OAMXkI,EAAM/G,GAAK6G,EAAM,eAUjBE,EAAMe,gBAAkB,SAAyBZ,EAAKN,GAClD,MAAO/H,MAAK8I,YAAYT,GACpBN,SAAUA,EACViB,MAAM,KAOdd,EAAMc,KAAOhB,EAAM,mBASnBE,EAAMgB,YAAc,SAAqBb,GAErC,MADArI,MAAKoI,aAAaC,GACXrI,MASXkI,EAAMiB,aAAe,SAAsBC,GACvC,IAAK,GAAIrN,GAAI,EAAGA,EAAIqN,EAAK9M,OAAQP,GAAK,EAClCiE,KAAKkJ,YAAYE,EAAKrN,GAE1B,OAAOiE,OAWXkI,EAAMmB,eAAiB,SAAwBhB,EAAKN,GAChD,GACIuB,GACA5E,EAFAoD,EAAY9H,KAAK4I,qBAAqBP,EAI1C,KAAK3D,IAAOoD,GACJA,EAAUnD,eAAeD,KACzB4E,EAAQzB,EAAgBC,EAAUpD,GAAMqD,GAE1B,KAAVuB,GACAxB,EAAUpD,GAAK6E,OAAOD,EAAO,GAKzC,OAAOtJ,OAMXkI,EAAMsB,IAAMxB,EAAM,kBAYlBE,EAAMuB,aAAe,SAAsBpB,EAAKP,GAE5C,MAAO9H,MAAK0J,qBAAoB,EAAOrB,EAAKP,IAahDI,EAAMyB,gBAAkB,SAAyBtB,EAAKP,GAElD,MAAO9H,MAAK0J,qBAAoB,EAAMrB,EAAKP,IAe/CI,EAAMwB,oBAAsB,SAA6BE,EAAQvB,EAAKP,GAClE,GAAI/L,GACA0F,EACAoI,EAASD,EAAS5J,KAAKqJ,eAAiBrJ,KAAK8I,YAC7CgB,EAAWF,EAAS5J,KAAK2J,gBAAkB3J,KAAKyJ,YAGpD,IAAmB,gBAARpB,IAAsBA,YAAelE,QAmB5C,IADApI,EAAI+L,EAAUxL,OACPP,KACH8N,EAAOxN,KAAK2D,KAAMqI,EAAKP,EAAU/L,QAnBrC,KAAKA,IAAKsM,GACFA,EAAI1D,eAAe5I,KAAO0F,EAAQ4G,EAAItM,MAEjB,kBAAV0F,GACPoI,EAAOxN,KAAK2D,KAAMjE,EAAG0F,GAIrBqI,EAASzN,KAAK2D,KAAMjE,EAAG0F,GAevC,OAAOzB,OAYXkI,EAAM6B,YAAc,SAAqB1B,GACrC,GAEI3D,GAFAsF,QAAc3B,GACdxH,EAASb,KAAKuI,YAIlB,IAAa,WAATyB,QAEOnJ,GAAOwH,OAEb,IAAIA,YAAelE,QAEpB,IAAKO,IAAO7D,GACJA,EAAO8D,eAAeD,IAAQ2D,EAAIG,KAAK9D,UAChC7D,GAAO6D,cAMf1E,MAAKiK,OAGhB,OAAOjK,OAQXkI,EAAMgC,mBAAqBlC,EAAM,eAcjCE,EAAMiC,UAAY,SAAmB9B,EAAKjD,GACtC,GACI0C,GACAC,EACAhM,EACA2I,EACA4D,EALA8B,EAAepK,KAAK4I,qBAAqBP,EAO7C,KAAK3D,IAAO0F,GACR,GAAIA,EAAazF,eAAeD,GAI5B,IAHAoD,EAAYsC,EAAa1F,GAAK2F,MAAM,GACpCtO,EAAI+L,EAAUxL,OAEPP,KAGHgM,EAAWD,EAAU/L,GAEjBgM,EAASiB,QAAS,GAClBhJ,KAAKqJ,eAAehB,EAAKN,EAASA,UAGtCO,EAAWP,EAASA,SAASxC,MAAMvF,KAAMoF,OAErCkD,IAAatI,KAAKsK,uBAClBtK,KAAKqJ,eAAehB,EAAKN,EAASA,SAMlD,OAAO/H,OAMXkI,EAAMtI,QAAUoI,EAAM,aAUtBE,EAAMqC,KAAO,SAAclC,GACvB,GAAIjD,GAAOyD,MAAM/H,UAAUuJ,MAAMhO,KAAKgJ,UAAW,EACjD,OAAOrF,MAAKmK,UAAU9B,EAAKjD,IAW/B8C,EAAMsC,mBAAqB,SAA4B/I,GAEnD,MADAzB,MAAKyK,iBAAmBhJ,EACjBzB,MAWXkI,EAAMoC,oBAAsB,WACxB,MAAItK,MAAK2E,eAAe,oBACb3E,KAAKyK,kBAGL,GAUfvC,EAAMK,WAAa,WACf,MAAOvI,MAAKiK,UAAYjK,KAAKiK,aAQjC5C,EAAaqD,WAAa,WAEtB,MADAtO,GAAQiL,aAAec,EAChBd,GAIW,kBAAX/L,IAAyBA,EAAOqP,IACvCrP,EAAO,WACH,MAAO+L,KAGY,gBAAX7K,IAAuBA,EAAOJ,QAC1CI,EAAOJ,QAAUiL,EAGjBjL,EAAQiL,aAAeA,IAE7BhL,KAAK2D,gBAEI","file":"script.min.js","sourcesContent":["(function () { var require = undefined; var define = undefined; (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){\n'use strict';\n\nvar Boxzilla = require('boxzilla');\nvar options = window.boxzilla_options;\nvar isLoggedIn = document.body.className.indexOf('logged-in') > -1;\n\n// print message when test mode is enabled\nif( isLoggedIn && options.testMode ) {\n console.log( 'Boxzilla: Test mode is enabled. Please disable test mode if you\\'re done testing.' );\n}\n\n// init boxzilla\nBoxzilla.init();\n\n// create boxes from options\nfor( var i=0; i < options.boxes.length; i++ ) {\n // get opts\n var boxOpts = options.boxes[i];\n boxOpts.testMode = isLoggedIn && options.testMode;\n\n // create box\n var box = Boxzilla.create( boxOpts.id, boxOpts);\n \n // add custom css to box\n css(box.element, boxOpts.css);\n}\n\nfunction css(element, styles) {\n if( styles.background_color ) {\n element.style.background = styles.background_color;\n }\n\n if( styles.color ) {\n element.style.color = styles.color;\n }\n\n if( styles.border_color ) {\n element.style.borderColor = styles.border_color;\n }\n\n if( styles.border_width ) {\n element.style.borderWidth = parseInt(styles.border_width) + \"px\";\n }\n\n if( styles.border_style ) {\n element.style.borderStyle = styles.border_style;\n }\n\n if( styles.width ) {\n element.style.maxWidth = parseInt(styles.width) + \"px\";\n }\n}\n\nwindow.Boxzilla = Boxzilla;\n},{\"boxzilla\":3}],2:[function(require,module,exports){\n'use strict';\n\nvar $ = window.jQuery,\n defaults = {\n 'animation': 'fade',\n 'rehide': false,\n 'content': '',\n 'cookieTime': 0,\n 'icon': '&times',\n 'minimumScreenWidth': 0,\n 'position': 'center',\n 'testMode': false,\n 'trigger': false,\n 'closable': true\n }, Boxzilla;\n\n/**\n * Merge 2 objects, values of the latter overwriting the former.\n *\n * @param obj1\n * @param obj2\n * @returns {*}\n */\nfunction merge( obj1, obj2 ) {\n var obj3 = {};\n for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }\n for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }\n return obj3;\n}\n\n// Box Object\nvar Box = function( id, config ) {\n this.id \t\t= id;\n\n // store config values\n this.config = merge(defaults, config);\n\n // store ref to overlay\n this.overlay = document.getElementById('boxzilla-overlay');\n\n // state\n this.visible \t= false;\n this.closed \t= false;\n this.triggered \t= false;\n this.triggerHeight = 0;\n this.cookieSet = false;\n\n // if a trigger was given, calculate values once and store\n if( this.config.trigger ) {\n if( this.config.trigger.method === 'percentage' || this.config.trigger.method === 'element' ) {\n this.triggerHeight = this.calculateTriggerHeight();\n }\n\n this.cookieSet = this.isCookieSet();\n }\n\n // create dom element for this box\n this.element = this.dom();\n this.$element = $(this.element);\n\n // further initialise the box\n this.events();\n};\n\n// initialise the box\nBox.prototype.events = function() {\n var box = this;\n\n // attach event to \"close\" icon inside box\n this.$element.find('.boxzilla-close-icon').click(box.dismiss.bind(this));\n\n this.$element.on('click', 'a', function(e) {\n Boxzilla.trigger('box.interactions.link', [ box, e.target ] );\n });\n\n this.$element.on('submit', 'form', function(e) {\n box.setCookie();\n Boxzilla.trigger('box.interactions.form', [ box, e.target ]);\n });\n\n // attach event to all links referring #boxzilla-{box_id}\n $(document.body).on('click', 'a[href=\"#boxzilla-' + box.id + '\"]', function() {\n box.toggle();\n return false;\n });\n\n // maybe show box right away\n if( this.config.trigger.method === \"time_on_page\" && this.mayAutoShow() ) {\n window.setTimeout(this.trigger.bind(this), this.config.trigger.value * 1000 );\n // auto-show the box if box is referenced from URL\n } else if( this.fits() && this.locationHashRefersBox() ) {\n $(window).load(this.show.bind(this));\n }\n\n};\n\n// generate dom elements for this box\nBox.prototype.dom = function() {\n\n var wrapper = document.createElement('div');\n wrapper.className = 'boxzilla-container boxzilla-' + this.config.position + '-container';\n\n var box = document.createElement('div');\n box.className = 'boxzilla boxzilla-' + this.id + ' boxzilla-' + this.config.position;\n box.style.display = 'none';\n wrapper.appendChild(box);\n\n var content = document.createElement('div');\n content.className = 'boxzilla-content';\n content.innerHTML = this.config.content;\n box.appendChild(content);\n\n if( this.config.closable && this.config.icon ) {\n var icon = document.createElement('span');\n icon.className = \"boxzilla-close-icon\";\n icon.innerHTML = this.config.icon;\n box.appendChild(icon);\n }\n\n document.body.appendChild(wrapper);\n\n return box;\n};\n\n// set (calculate) custom box styling depending on box options\nBox.prototype.setCustomBoxStyling = function() {\n\n // reset element to its initial state\n this.element.style.overflowY = 'auto';\n this.element.style.maxHeight = 'none';\n\n // get new dimensions\n var windowHeight = window.innerHeight;\n var boxHeight = this.$element.outerHeight();\n\n // add scrollbar to box and limit height\n if( boxHeight > windowHeight ) {\n this.element.style.maxHeight = windowHeight + \"px\";\n this.element.style.overflowY = 'scroll';\n }\n\n // set new top margin for boxes which are centered\n if( this.config.position === 'center' ) {\n var newTopMargin = ( ( windowHeight - boxHeight ) / 2 );\n newTopMargin = newTopMargin >= 0 ? newTopMargin : 0;\n this.element.style.marginTop = newTopMargin + \"px\";\n }\n\n};\n\n// toggle visibility of the box\nBox.prototype.toggle = function(show) {\n\n // revert visibility if no explicit argument is given\n if( typeof( show ) === \"undefined\" ) {\n show = ! this.visible;\n }\n\n // do nothing if element is being animated\n if( this.$element.is(':animated') ) {\n return false;\n }\n\n // is box already at desired visibility?\n if( show === this.visible ) {\n return false;\n }\n\n // if box should be hidden but is not closable, bail.\n if( ! show && ! this.config.closable ) {\n return false;\n }\n\n // set new visibility status\n this.visible = show;\n\n // calculate custom styling for which CSS is \"too stupid\"\n this.setCustomBoxStyling();\n\n // fadein / fadeout the overlay if position is \"center\"\n if( this.config.position === 'center' ) {\n $(this.overlay).fadeToggle('slow');\n }\n\n // trigger event\n Boxzilla.trigger('box.' + ( show ? 'show' : 'hide' ), [ this ] );\n\n // show or hide box using selected animation\n if( this.config.animation === 'fade' ) {\n this.$element.fadeToggle( 'slow' );\n } else {\n this.$element.slideToggle( 'slow' );\n }\n\n // // focus on first input field in box\n // this.$element.find('input').first().focus();\n\n return true;\n};\n\n// show the box\nBox.prototype.show = function() {\n return this.toggle(true);\n};\n\n// hide the box\nBox.prototype.hide = function() {\n return this.toggle(false);\n};\n\n// calculate trigger height\nBox.prototype.calculateTriggerHeight = function() {\n var triggerHeight = 0;\n\n if( this.config.trigger.method === 'element' ) {\n var $triggerElement = $(this.config.trigger.value).first();\n triggerHeight = ( $triggerElement.length > 0 ) ? $triggerElement.offset().top : 0;\n } else if( this.config.trigger.method === 'percentage' ) {\n triggerHeight = ( this.config.trigger.value / 100 * $(document).height() );\n }\n\n return triggerHeight;\n};\n\n// set cookie that disables automatically showing the box\nBox.prototype.setCookie = function() {\n // do nothing if cookieTime evaluates to false\n if(! this.config.cookieTime) {\n return;\n }\n\n var expiryDate = new Date();\n expiryDate.setDate( expiryDate.getDate() + this.config.cookieTime );\n document.cookie = 'boxzilla_box_'+ this.id + '=true; expires='+ expiryDate.toUTCString() +'; path=/';\n};\n\n// checks whether window.location.hash equals the box element ID or that of any element inside the box\nBox.prototype.locationHashRefersBox = function() {\n\n if( ! window.location.hash || 0 === window.location.hash.length ) {\n return false;\n }\n\n var elementId = window.location.hash.substring(1);\n if( elementId === this.element.id ) {\n return true;\n } else if( this.element.querySelector('#' + elementId) ) {\n return true;\n }\n\n return false;\n};\n\nBox.prototype.fits = function() {\n if( this.config.minimumScreenWidth <= 0 ) {\n return true;\n }\n\n return window.innerWidth > this.config.minimumScreenWidth\n};\n\n// is this box enabled?\nBox.prototype.mayAutoShow = function() {\n\n // don't show if box was closed (dismissed) before\n if( this.closed ) {\n return false;\n }\n\n // check if box fits on given minimum screen width\n if( ! this.fits() ) {\n return false;\n }\n\n // if trigger empty or error in calculating triggerHeight, return false\n if( ! this.config.trigger ) {\n return false;\n }\n\n // rely on cookie value (show if not set, don't show if set)\n return ! this.cookieSet;\n};\n\nBox.prototype.mayRehide = function() {\n return this.config.rehide && this.triggered;\n};\n\nBox.prototype.isCookieSet = function() {\n // always show on test mode\n if( this.config.testMode ) {\n return false;\n }\n\n // check for cookie\n if( ! this.config.cookieTime ) {\n return false;\n }\n\n var cookieSet = document.cookie.replace(new RegExp(\"(?:(?:^|.*;)\\\\s*\" + 'boxzilla_box_' + this.id + \"\\\\s*\\\\=\\\\s*([^;]*).*$)|^.*$\"), \"$1\") === \"true\";\n return cookieSet;\n\n};\n\nBox.prototype.trigger = function() {\n var shown = this.show();\n if( shown ) {\n this.triggered = true;\n }\n};\n\nBox.prototype.dismiss = function() {\n this.hide();\n this.setCookie();\n this.closed = true;\n Boxzilla.trigger('box.dismiss', [ this ]);\n};\n\nmodule.exports = function(_Boxzilla) {\n Boxzilla = _Boxzilla;\n return Box;\n};\n},{}],3:[function(require,module,exports){\n'use strict';\n\nvar $ = window.jQuery,\n EventEmitter = require('wolfy87-eventemitter'),\n Boxzilla = Object.create(EventEmitter.prototype),\n Box = require('./Box.js')(Boxzilla),\n boxes = {},\n windowHeight = window.innerHeight,\n overlay = document.createElement('div'),\n exitIntentDelayTimer,\n exitIntentTriggered;\n\nfunction each( obj, callback ) {\n for( var key in obj ) {\n if(! obj.hasOwnProperty(key)) continue;\n callback(obj[key]);\n }\n}\n\nfunction throttle(fn, threshhold, scope) {\n threshhold || (threshhold = 250);\n var last,\n deferTimer;\n return function () {\n var context = scope || this;\n\n var now = +new Date,\n args = arguments;\n if (last && now < last + threshhold) {\n // hold on to it\n clearTimeout(deferTimer);\n deferTimer = setTimeout(function () {\n last = now;\n fn.apply(context, args);\n }, threshhold);\n } else {\n last = now;\n fn.apply(context, args);\n }\n };\n}\n\n// \"keyup\" listener\nfunction onKeyUp(e) {\n if (e.keyCode == 27) {\n Boxzilla.dismiss();\n }\n}\n\nfunction checkTimeCriteria() {\n var start = sessionStorage.getItem('boxzilla_start_time');\n var now = Date.now();\n var timeOnSite = ( now - start ) / 1000;\n\n each(boxes, function(box) {\n if( ! box.mayAutoShow() || box.config.trigger.method !== 'time_on_site' ) {\n return;\n }\n\n if( timeOnSite > box.config.trigger.value ) {\n box.trigger();\n }\n });\n}\n\n// check triggerHeight criteria for all boxes\nfunction checkHeightCriteria() {\n var scrollY = window.scrollY;\n var scrollHeight = scrollY + ( windowHeight * 0.9 );\n\n each(boxes, function(box) {\n if( ! box.mayAutoShow() || box.triggerHeight <= 0 ) {\n return;\n }\n\n if( scrollHeight > box.triggerHeight ) {\n box.trigger();\n } else if( box.mayRehide() ) {\n box.hide();\n }\n });\n}\n\n// recalculate heights and variables based on height\nfunction recalculateHeights() {\n windowHeight = window.innerHeight;\n\n each(boxes, function(box) {\n box.setCustomBoxStyling();\n });\n}\n\nfunction onOverlayClick(e) {\n var x = e.offsetX;\n var y = e.offsetY;\n\n // calculate if click was near a box to avoid closing it (click error margin)\n each(boxes, function(box) {\n var rect = box.element.getBoundingClientRect();\n var margin = 100 + ( window.innerWidth * 0.05 );\n\n // if click was not anywhere near box, dismiss it.\n if( x < ( rect.left - margin ) || x > ( rect.right + margin ) || y < ( rect.top - margin ) || y > ( rect.bottom + margin ) ) {\n box.dismiss();\n }\n });\n}\n\nfunction triggerExitIntent() {\n if(exitIntentTriggered) return;\n\n each(boxes, function(box) {\n if(box.mayAutoShow() && box.config.trigger.method === 'exit_intent' ) {\n box.trigger();\n }\n });\n\n exitIntentTriggered = true;\n}\n\nfunction onMouseLeave(e) {\n // did mouse leave at top of window?\n if( e.clientY < 0 ) {\n exitIntentDelayTimer = window.setTimeout(triggerExitIntent, 1000);\n }\n}\n\nfunction onMouseEnter() {\n if( exitIntentDelayTimer ) {\n window.clearInterval(exitIntentDelayTimer);\n exitIntentDelayTimer = null;\n }\n}\n\n// initialise & add event listeners\nBoxzilla.init = function() {\n // add overlay element to dom\n overlay.id = 'boxzilla-overlay';\n document.body.appendChild(overlay);\n\n // event binds\n $(window).on('scroll', throttle(checkHeightCriteria));\n $(window).on('resize', throttle(recalculateHeights));\n $(window).on('load', recalculateHeights );\n $(document).on('mouseleave', onMouseLeave);\n $(document).on('mouseenter', onMouseEnter);\n $(document).on('keyup', onKeyUp);\n $(overlay).click(onOverlayClick);\n window.setInterval(checkTimeCriteria, 1000);\n\n if(! sessionStorage.getItem('boxzilla_start_time')) {\n sessionStorage.setItem('boxzilla_start_time', Date.now());\n }\n\n Boxzilla.trigger('ready');\n};\n\n/**\n * Create a new Box\n *\n * @param string id\n * @param object opts\n *\n * @returns Box\n */\nBoxzilla.create = function(id, opts) {\n boxes[id] = new Box(id, opts);\n return boxes[id];\n};\n\n// dismiss a single box (or all by omitting id param)\nBoxzilla.dismiss = function(id) {\n // if no id given, dismiss all current open boxes\n if( typeof(id) === \"undefined\" ) {\n each(boxes, function(box) { box.dismiss(); });\n } else if( typeof( boxes[id] ) === \"object\" ) {\n boxes[id].dismiss();\n }\n};\n\nBoxzilla.hide = function(id) {\n if( typeof(id) === \"undefined\" ) {\n each(boxes, function(box) { box.hide(); });\n } else if( typeof( boxes[id] ) === \"object\" ) {\n boxes[id].hide();\n }\n};\n\nBoxzilla.show = function(id) {\n if( typeof(id) === \"undefined\" ) {\n each(boxes, function(box) { box.show(); });\n } else if( typeof( boxes[id] ) === \"object\" ) {\n boxes[id].show();\n }\n};\n\nBoxzilla.toggle = function(id) {\n if( typeof(id) === \"undefined\" ) {\n each(boxes, function(box) { box.toggle(); });\n } else if( typeof( boxes[id] ) === \"object\" ) {\n boxes[id].toggle();\n }\n};\n\nif ( typeof module !== 'undefined' && module.exports ) {\n module.exports = Boxzilla;\n} else {\n this.Boxzilla = Boxzilla;\n}\n},{\"./Box.js\":2,\"wolfy87-eventemitter\":4}],4:[function(require,module,exports){\n/*!\n * EventEmitter v4.2.11 - git.io/ee\n * Unlicense - http://unlicense.org/\n * Oliver Caldwell - http://oli.me.uk/\n * @preserve\n */\n\n;(function () {\n 'use strict';\n\n /**\n * Class for managing events.\n * Can be extended to provide event functionality in other classes.\n *\n * @class EventEmitter Manages event registering and emitting.\n */\n function EventEmitter() {}\n\n // Shortcuts to improve speed and size\n var proto = EventEmitter.prototype;\n var exports = this;\n var originalGlobalValue = exports.EventEmitter;\n\n /**\n * Finds the index of the listener for the event in its storage array.\n *\n * @param {Function[]} listeners Array of listeners to search through.\n * @param {Function} listener Method to look for.\n * @return {Number} Index of the specified listener, -1 if not found\n * @api private\n */\n function indexOfListener(listeners, listener) {\n var i = listeners.length;\n while (i--) {\n if (listeners[i].listener === listener) {\n return i;\n }\n }\n\n return -1;\n }\n\n /**\n * Alias a method while keeping the context correct, to allow for overwriting of target method.\n *\n * @param {String} name The name of the target method.\n * @return {Function} The aliased method\n * @api private\n */\n function alias(name) {\n return function aliasClosure() {\n return this[name].apply(this, arguments);\n };\n }\n\n /**\n * Returns the listener array for the specified event.\n * Will initialise the event object and listener arrays if required.\n * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.\n * Each property in the object response is an array of listener functions.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Function[]|Object} All listener functions for the event.\n */\n proto.getListeners = function getListeners(evt) {\n var events = this._getEvents();\n var response;\n var key;\n\n // Return a concatenated array of all matching events if\n // the selector is a regular expression.\n if (evt instanceof RegExp) {\n response = {};\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n response[key] = events[key];\n }\n }\n }\n else {\n response = events[evt] || (events[evt] = []);\n }\n\n return response;\n };\n\n /**\n * Takes a list of listener objects and flattens it into a list of listener functions.\n *\n * @param {Object[]} listeners Raw listener objects.\n * @return {Function[]} Just the listener functions.\n */\n proto.flattenListeners = function flattenListeners(listeners) {\n var flatListeners = [];\n var i;\n\n for (i = 0; i < listeners.length; i += 1) {\n flatListeners.push(listeners[i].listener);\n }\n\n return flatListeners;\n };\n\n /**\n * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.\n *\n * @param {String|RegExp} evt Name of the event to return the listeners from.\n * @return {Object} All listener functions for an event in an object.\n */\n proto.getListenersAsObject = function getListenersAsObject(evt) {\n var listeners = this.getListeners(evt);\n var response;\n\n if (listeners instanceof Array) {\n response = {};\n response[evt] = listeners;\n }\n\n return response || listeners;\n };\n\n /**\n * Adds a listener function to the specified event.\n * The listener will not be added if it is a duplicate.\n * If the listener returns true then it will be removed after it is called.\n * If you pass a regular expression as the event name then the listener will be added to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListener = function addListener(evt, listener) {\n var listeners = this.getListenersAsObject(evt);\n var listenerIsWrapped = typeof listener === 'object';\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {\n listeners[key].push(listenerIsWrapped ? listener : {\n listener: listener,\n once: false\n });\n }\n }\n\n return this;\n };\n\n /**\n * Alias of addListener\n */\n proto.on = alias('addListener');\n\n /**\n * Semi-alias of addListener. It will add a listener that will be\n * automatically removed after its first execution.\n *\n * @param {String|RegExp} evt Name of the event to attach the listener to.\n * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addOnceListener = function addOnceListener(evt, listener) {\n return this.addListener(evt, {\n listener: listener,\n once: true\n });\n };\n\n /**\n * Alias of addOnceListener.\n */\n proto.once = alias('addOnceListener');\n\n /**\n * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.\n * You need to tell it what event names should be matched by a regex.\n *\n * @param {String} evt Name of the event to create.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvent = function defineEvent(evt) {\n this.getListeners(evt);\n return this;\n };\n\n /**\n * Uses defineEvent to define multiple events.\n *\n * @param {String[]} evts An array of event names to define.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.defineEvents = function defineEvents(evts) {\n for (var i = 0; i < evts.length; i += 1) {\n this.defineEvent(evts[i]);\n }\n return this;\n };\n\n /**\n * Removes a listener function from the specified event.\n * When passed a regular expression as the event name, it will remove the listener from all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to remove the listener from.\n * @param {Function} listener Method to remove from the event.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListener = function removeListener(evt, listener) {\n var listeners = this.getListenersAsObject(evt);\n var index;\n var key;\n\n for (key in listeners) {\n if (listeners.hasOwnProperty(key)) {\n index = indexOfListener(listeners[key], listener);\n\n if (index !== -1) {\n listeners[key].splice(index, 1);\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of removeListener\n */\n proto.off = alias('removeListener');\n\n /**\n * Adds listeners in bulk using the manipulateListeners method.\n * If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.\n * You can also pass it a regular expression to add the array of listeners to all events that match it.\n * Yeah, this function does quite a bit. That's probably a bad thing.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.addListeners = function addListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(false, evt, listeners);\n };\n\n /**\n * Removes listeners in bulk using the manipulateListeners method.\n * If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be removed.\n * You can also pass it a regular expression to remove the listeners from all events that match it.\n *\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeListeners = function removeListeners(evt, listeners) {\n // Pass through to manipulateListeners\n return this.manipulateListeners(true, evt, listeners);\n };\n\n /**\n * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.\n * The first argument will determine if the listeners are removed (true) or added (false).\n * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.\n * You can also pass it an event name and an array of listeners to be added/removed.\n * You can also pass it a regular expression to manipulate the listeners of all events that match it.\n *\n * @param {Boolean} remove True if you want to remove listeners, false if you want to add.\n * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.\n * @param {Function[]} [listeners] An optional array of listener functions to add/remove.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {\n var i;\n var value;\n var single = remove ? this.removeListener : this.addListener;\n var multiple = remove ? this.removeListeners : this.addListeners;\n\n // If evt is an object then pass each of its properties to this method\n if (typeof evt === 'object' && !(evt instanceof RegExp)) {\n for (i in evt) {\n if (evt.hasOwnProperty(i) && (value = evt[i])) {\n // Pass the single listener straight through to the singular method\n if (typeof value === 'function') {\n single.call(this, i, value);\n }\n else {\n // Otherwise pass back to the multiple function\n multiple.call(this, i, value);\n }\n }\n }\n }\n else {\n // So evt must be a string\n // And listeners must be an array of listeners\n // Loop over it and pass each one to the multiple method\n i = listeners.length;\n while (i--) {\n single.call(this, evt, listeners[i]);\n }\n }\n\n return this;\n };\n\n /**\n * Removes all listeners from a specified event.\n * If you do not specify an event then all listeners will be removed.\n * That means every event will be emptied.\n * You can also pass a regex to remove all events that match it.\n *\n * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.removeEvent = function removeEvent(evt) {\n var type = typeof evt;\n var events = this._getEvents();\n var key;\n\n // Remove different things depending on the state of evt\n if (type === 'string') {\n // Remove all listeners for the specified event\n delete events[evt];\n }\n else if (evt instanceof RegExp) {\n // Remove all events matching the regex.\n for (key in events) {\n if (events.hasOwnProperty(key) && evt.test(key)) {\n delete events[key];\n }\n }\n }\n else {\n // Remove all listeners in all events\n delete this._events;\n }\n\n return this;\n };\n\n /**\n * Alias of removeEvent.\n *\n * Added to mirror the node API.\n */\n proto.removeAllListeners = alias('removeEvent');\n\n /**\n * Emits an event of your choice.\n * When emitted, every listener attached to that event will be executed.\n * If you pass the optional argument array then those arguments will be passed to every listener upon execution.\n * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.\n * So they will not arrive within the array on the other side, they will be separate.\n * You can also pass a regular expression to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {Array} [args] Optional array of arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emitEvent = function emitEvent(evt, args) {\n var listenersMap = this.getListenersAsObject(evt);\n var listeners;\n var listener;\n var i;\n var key;\n var response;\n\n for (key in listenersMap) {\n if (listenersMap.hasOwnProperty(key)) {\n listeners = listenersMap[key].slice(0);\n i = listeners.length;\n\n while (i--) {\n // If the listener returns true then it shall be removed from the event\n // The function is executed either with a basic call or an apply if there is an args array\n listener = listeners[i];\n\n if (listener.once === true) {\n this.removeListener(evt, listener.listener);\n }\n\n response = listener.listener.apply(this, args || []);\n\n if (response === this._getOnceReturnValue()) {\n this.removeListener(evt, listener.listener);\n }\n }\n }\n }\n\n return this;\n };\n\n /**\n * Alias of emitEvent\n */\n proto.trigger = alias('emitEvent');\n\n /**\n * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.\n * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.\n *\n * @param {String|RegExp} evt Name of the event to emit and execute listeners for.\n * @param {...*} Optional additional arguments to be passed to each listener.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.emit = function emit(evt) {\n var args = Array.prototype.slice.call(arguments, 1);\n return this.emitEvent(evt, args);\n };\n\n /**\n * Sets the current value to check against when executing listeners. If a\n * listeners return value matches the one set here then it will be removed\n * after execution. This value defaults to true.\n *\n * @param {*} value The new value to check for when executing listeners.\n * @return {Object} Current instance of EventEmitter for chaining.\n */\n proto.setOnceReturnValue = function setOnceReturnValue(value) {\n this._onceReturnValue = value;\n return this;\n };\n\n /**\n * Fetches the current value to check against when executing listeners. If\n * the listeners return value matches this one then it should be removed\n * automatically. It will return true by default.\n *\n * @return {*|Boolean} The current value to check for or the default, true.\n * @api private\n */\n proto._getOnceReturnValue = function _getOnceReturnValue() {\n if (this.hasOwnProperty('_onceReturnValue')) {\n return this._onceReturnValue;\n }\n else {\n return true;\n }\n };\n\n /**\n * Fetches the events object and creates one if required.\n *\n * @return {Object} The events storage object.\n * @api private\n */\n proto._getEvents = function _getEvents() {\n return this._events || (this._events = {});\n };\n\n /**\n * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.\n *\n * @return {Function} Non conflicting EventEmitter class.\n */\n EventEmitter.noConflict = function noConflict() {\n exports.EventEmitter = originalGlobalValue;\n return EventEmitter;\n };\n\n // Expose the class either via AMD, CommonJS or the global object\n if (typeof define === 'function' && define.amd) {\n define(function () {\n return EventEmitter;\n });\n }\n else if (typeof module === 'object' && module.exports){\n module.exports = EventEmitter;\n }\n else {\n exports.EventEmitter = EventEmitter;\n }\n}.call(this));\n\n},{}]},{},[1]);\n })();"],"sourceRoot":"/source/"}
bootstrap.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla;
4
+
5
+ defined( 'ABSPATH' ) or exit;
6
+
7
+ /** @var Boxzilla $boxzilla */
8
+ $boxzilla = boxzilla();
9
+
10
+ // register services
11
+ $provider = new BoxzillaServiceProvider();
12
+ $provider->register( $boxzilla );
13
+
14
+ // load default filters
15
+ require __DIR__ . '/src/default-filters.php';
16
+
17
+ add_action( 'init', function() use( $boxzilla ){
18
+ // Register custom post type
19
+ $args = array(
20
+ 'public' => false,
21
+ 'labels' => array(
22
+ 'name' => __( 'Boxzilla', 'boxzilla' ),
23
+ 'singular_name' => __( 'Box', 'boxzilla' ),
24
+ 'add_new' => __( 'Add New', 'boxzilla' ),
25
+ 'add_new_item' => __( 'Add New Box', 'boxzilla' ),
26
+ 'edit_item' => __( 'Edit Box', 'boxzilla' ),
27
+ 'new_item' => __( 'New Box', 'boxzilla' ),
28
+ 'all_items' => __( 'All Boxes', 'boxzilla' ),
29
+ 'view_item' => __( 'View Box', 'boxzilla' ),
30
+ 'search_items' => __( 'Search Boxes', 'boxzilla' ),
31
+ 'not_found' => __( 'No Boxes found', 'boxzilla' ),
32
+ 'not_found_in_trash' => __( 'No Boxes found in Trash', 'boxzilla' ),
33
+ 'parent_item_colon' => '',
34
+ 'menu_name' => __( 'Boxzilla', 'boxzilla' )
35
+ ),
36
+ 'show_ui' => true,
37
+ 'menu_position' => '108.1337133',
38
+ 'menu_icon' => $boxzilla->plugin->url( '/assets/img/menu-icon.png' ),
39
+ 'query_var' => false
40
+ );
41
+
42
+ register_post_type( 'boxzilla-box', $args );
43
+ });
44
+
45
+ if( ! is_admin() ) {
46
+
47
+ // PUBLIC
48
+ add_action( 'template_redirect', function() use( $boxzilla ) {
49
+ $boxzilla['box_loader']->init();
50
+ });
51
+
52
+ } else {
53
+
54
+ // ADMIN (and AJAX)
55
+ $provider = new Licensing\LicenseServiceProvider();
56
+ $provider->register( $boxzilla );
57
+
58
+ if( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
59
+ add_action('init', function() use( $boxzilla ) {
60
+ $boxzilla['admin']->init();
61
+ });
62
+ } else {
63
+ $boxzilla['filter.autocomplete']->add_hooks();
64
+ }
65
+
66
+ }
67
+
boxzilla.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Boxzilla
4
+ Version: 3.0
5
+ Plugin URI: https://boxzillaplugin.com/#utm_source=wp-plugin&utm_medium=boxzilla&utm_campaign=plugins-page
6
+ Description: Call-To-Action Boxes that display after visitors scroll down far enough. Unobtrusive, but highly conversing!
7
+ Author: ibericode
8
+ Author URI: https://ibericode.com/#utm_source=wp-plugin&utm_medium=boxzilla&utm_campaign=plugins-page
9
+ Text Domain: boxzilla
10
+ Domain Path: /languages/
11
+ License: GPL v3
12
+
13
+ Boxzilla Plugin
14
+ Copyright (C) 2013-2016, Danny van Kooten, hi@dannyvankooten.com
15
+
16
+ This program is free software: you can redistribute it and/or modify
17
+ it under the terms of the GNU General Public License as published by
18
+ the Free Software Foundation, either version 3 of the License, or
19
+ (at your option) any later version.
20
+
21
+ This program is distributed in the hope that it will be useful,
22
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ GNU General Public License for more details.
25
+
26
+ You should have received a copy of the GNU General Public License
27
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
28
+ */
29
+
30
+ if ( ! defined( 'ABSPATH' ) ) {
31
+ header( 'Status: 403 Forbidden' );
32
+ header( 'HTTP/1.1 403 Forbidden' );
33
+ exit;
34
+ }
35
+
36
+
37
+ /**
38
+ * @ignore
39
+ * @internal
40
+ */
41
+ function __load_boxzilla() {
42
+
43
+ // Load PHP 5.2 fallback
44
+ if( version_compare( PHP_VERSION, '5.3', '<' ) ) {
45
+ require dirname( __FILE__ ) . '/src/class-php-fallback.php';
46
+ new Boxzilla_PHP_Fallback( 'Boxzilla', plugin_basename( __FILE__ ) );
47
+ return;
48
+ }
49
+
50
+ define( 'BOXZILLA_FILE', __FILE__ );
51
+ define( 'BOXZILLA_VERSION', '3.0' );
52
+
53
+ require __DIR__ . '/bootstrap.php';
54
+ }
55
+
56
+ // load autoloader but only if not loaded already (for compat with sitewide autoloader)
57
+ if( ! function_exists( 'boxzilla' ) ) {
58
+ require dirname( __FILE__ ) . '/vendor/autoload.php';
59
+ }
60
+
61
+ // register activation hook
62
+ register_activation_hook( __FILE__, array( 'Boxzilla\\Admin\\Installer', 'run' ) );
63
+
64
+ add_action( 'plugins_loaded', '__load_boxzilla', 8 );
languages/scroll-triggered-boxes-es_ES.mo ADDED
Binary file
languages/scroll-triggered-boxes-es_ES.po ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Scroll Triggered Boxes\n"
4
+ "POT-Creation-Date: 2014-04-18 12:14+0100\n"
5
+ "PO-Revision-Date: 2014-06-23 01:46+0100\n"
6
+ "Last-Translator: Danny <hi@dannyvankooten.com>\n"
7
+ "Language-Team: Danny van Kooten <hi@dannyvankooten.com>\n"
8
+ "Language: en_US\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.5.5\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
+ "X-Poedit-KeywordsList: __;_e\n"
16
+ "X-Poedit-SearchPath-0: ..\n"
17
+
18
+ #: ../includes/class-admin.php:58
19
+ msgid "Box Options"
20
+ msgstr "Opciones de caja"
21
+
22
+ #: ../includes/class-admin.php:67
23
+ msgid "Need support?"
24
+ msgstr "¿Necesitas soporte?"
25
+
26
+ #: ../includes/class-admin.php:75
27
+ msgid "Donate $10, $20 or $50"
28
+ msgstr "Dona 10, 20 o 50 dólares"
29
+
30
+ #: ../includes/class-admin.php:83
31
+ msgid "About the developer"
32
+ msgstr "Sobre el desarrollador"
33
+
34
+ #: ../includes/views/metabox-options.php:7
35
+ msgid "Scroll Triggered Box Options"
36
+ msgstr "Opciones de Scroll Triggered Box"
37
+
38
+ #: ../includes/views/metabox-options.php:9
39
+ msgid "Display Options"
40
+ msgstr "Opciones de visualización"
41
+
42
+ #: ../includes/views/metabox-options.php:15
43
+ msgid "Show this box"
44
+ msgstr "Mostrar esta caja"
45
+
46
+ #: ../includes/views/metabox-options.php:18
47
+ msgid "Basic"
48
+ msgstr "Básico"
49
+
50
+ #: ../includes/views/metabox-options.php:19
51
+ msgid "Everywhere"
52
+ msgstr "En todas partes"
53
+
54
+ #: ../includes/views/metabox-options.php:20
55
+ msgid "if Post Type is"
56
+ msgstr "Si la entrada es de tipo"
57
+
58
+ #: ../includes/views/metabox-options.php:21
59
+ msgid "if Page is"
60
+ msgstr "Si la página es"
61
+
62
+ #: ../includes/views/metabox-options.php:22
63
+ msgid "if Page is not"
64
+ msgstr "Si la página no es"
65
+
66
+ #: ../includes/views/metabox-options.php:23
67
+ msgid "if Post is"
68
+ msgstr "Si la entrada es"
69
+
70
+ #: ../includes/views/metabox-options.php:25
71
+ msgid "Advanced"
72
+ msgstr "Avanzado"
73
+
74
+ #: ../includes/views/metabox-options.php:26
75
+ msgid "Manual conditon"
76
+ msgstr "Condicion manual"
77
+
78
+ #: ../includes/views/metabox-options.php:31
79
+ msgid "Leave empty for any or enter (comma-separated) names or ID's"
80
+ msgstr ""
81
+ "Dejar en blanco para cualquiera o introduzca (separado por comas) nombres o "
82
+ "IDs"
83
+
84
+ #: ../includes/views/metabox-options.php:39
85
+ msgid "Add rule"
86
+ msgstr "Añadir regla"
87
+
88
+ #: ../includes/views/metabox-options.php:42
89
+ #, php-format
90
+ msgid ""
91
+ "For using advanced (manual) rules, have a look at %sthe WordPress "
92
+ "Conditional Tags Codex page%s."
93
+ msgstr ""
94
+ "Para el uso de reglas avanzadas (manuales) echar un vistazo a las "
95
+ "%setiquetas condicionales de WordPress en el Codex%s"
96
+
97
+ #: ../includes/views/metabox-options.php:45
98
+ msgid "Box Position"
99
+ msgstr "Posición de la caja"
100
+
101
+ #: ../includes/views/metabox-options.php:48
102
+ msgid "Top Left"
103
+ msgstr "Arriba a la izquierda"
104
+
105
+ #: ../includes/views/metabox-options.php:49
106
+ msgid "Top Right"
107
+ msgstr "Arriba a la derecha"
108
+
109
+ #: ../includes/views/metabox-options.php:50
110
+ msgid "Bottom Left"
111
+ msgstr "Abajo a la izquierda"
112
+
113
+ #: ../includes/views/metabox-options.php:51
114
+ msgid "Bottom Right"
115
+ msgstr "Abajo a la derecha"
116
+
117
+ #: ../includes/views/metabox-options.php:57
118
+ msgid "Trigger Point"
119
+ msgstr "Punto de disparo"
120
+
121
+ #: ../includes/views/metabox-options.php:61
122
+ msgid "of page height"
123
+ msgstr "de altura de la página"
124
+
125
+ #: ../includes/views/metabox-options.php:64
126
+ msgid "Element Selector"
127
+ msgstr "Selecto de elementos"
128
+
129
+ #: ../includes/views/metabox-options.php:70
130
+ msgid "Example: #comments (element must exist or box won't be shown)"
131
+ msgstr ""
132
+ "Ejemplo: #Comentarios (el elemento debe existir o la caja no será mostrada)"
133
+
134
+ #: ../includes/views/metabox-options.php:74
135
+ msgid "Animation"
136
+ msgstr "Animación"
137
+
138
+ #: ../includes/views/metabox-options.php:76
139
+ msgid "Fade In"
140
+ msgstr "Fade In"
141
+
142
+ #: ../includes/views/metabox-options.php:77
143
+ msgid "Slide In"
144
+ msgstr "Slide in"
145
+
146
+ #: ../includes/views/metabox-options.php:78
147
+ msgid "Which animation type should be used to show the box when triggered?"
148
+ msgstr ""
149
+ "¿Qué tipo de animación se debe utilizar cuando se activa el desencadenador "
150
+ "de la caja?"
151
+
152
+ #: ../includes/views/metabox-options.php:82
153
+ msgid "Cookie expiration days"
154
+ msgstr "Dias de vencimiento de la cookie"
155
+
156
+ #: ../includes/views/metabox-options.php:85
157
+ msgid "After closing the box, how many days should it stay hidden?"
158
+ msgstr "Después de cerrar la caja, ¿cuantos días debería permanecer oculta?"
159
+
160
+ #: ../includes/views/metabox-options.php:90
161
+ msgid "Auto-hide?"
162
+ msgstr "¿Auto-ocultar?"
163
+
164
+ #: ../includes/views/metabox-options.php:92
165
+ #: ../includes/views/metabox-options.php:101
166
+ msgid "Yes"
167
+ msgstr "Si"
168
+
169
+ #: ../includes/views/metabox-options.php:93
170
+ #: ../includes/views/metabox-options.php:102
171
+ msgid "No"
172
+ msgstr "No"
173
+
174
+ #: ../includes/views/metabox-options.php:94
175
+ msgid "Hide box again when visitors scroll back up?"
176
+ msgstr "¿Ocultar la caja cuando los visitantes se desplacen hacia arriba?"
177
+
178
+ #: ../includes/views/metabox-options.php:99
179
+ msgid "Enable test mode?"
180
+ msgstr "¿Activar el modo de prueba?"
181
+
182
+ #: ../includes/views/metabox-options.php:103
183
+ msgid ""
184
+ "If test mode is enabled, the box will show up regardless of whether a cookie "
185
+ "has been set."
186
+ msgstr ""
187
+ "Si el modo de pruebas está activo, la caja se mostrará independientemente de "
188
+ "la configuración de cookie establecida."
189
+
190
+ #: ../includes/views/metabox-options.php:108
191
+ msgid "Appearance"
192
+ msgstr "Apariencia"
193
+
194
+ #: ../includes/views/metabox-options.php:112
195
+ msgid "Background color"
196
+ msgstr "Color de fondo"
197
+
198
+ #: ../includes/views/metabox-options.php:116
199
+ msgid "Text color"
200
+ msgstr "Color del texto"
201
+
202
+ #: ../includes/views/metabox-options.php:120
203
+ msgid "Box width"
204
+ msgstr "Ancho de la caja"
205
+
206
+ #: ../includes/views/metabox-options.php:126
207
+ msgid "Border color"
208
+ msgstr "Color del borde"
209
+
210
+ #: ../includes/views/metabox-options.php:130
211
+ msgid "Border width"
212
+ msgstr "Ancho del borde"
languages/scroll-triggered-boxes-nl_NL.mo ADDED
Binary file
languages/scroll-triggered-boxes-nl_NL.po ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Scroll Triggered Boxes\n"
4
+ "POT-Creation-Date: 2014-04-18 12:14+0100\n"
5
+ "PO-Revision-Date: 2014-04-18 12:16+0100\n"
6
+ "Last-Translator: Danny <hi@dannyvankooten.com>\n"
7
+ "Language-Team: Danny van Kooten <hi@dannyvankooten.com>\n"
8
+ "Language: en_US\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.6.4\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
+ "X-Poedit-KeywordsList: __;_e\n"
16
+ "X-Poedit-SearchPath-0: ..\n"
17
+
18
+ #: ../includes/class-admin.php:58
19
+ msgid "Box Options"
20
+ msgstr "Box Opties"
21
+
22
+ #: ../includes/class-admin.php:67
23
+ msgid "Need support?"
24
+ msgstr "Support nodig?"
25
+
26
+ #: ../includes/class-admin.php:75
27
+ msgid "Donate $10, $20 or $50"
28
+ msgstr "Doneer $10, $20 of $50"
29
+
30
+ #: ../includes/class-admin.php:83
31
+ msgid "About the developer"
32
+ msgstr "Over de ontwikkelaar"
33
+
34
+ #: ../includes/views/metabox-options.php:7
35
+ msgid "Scroll Triggered Box Options"
36
+ msgstr "Scroll Triggered Box Opties"
37
+
38
+ #: ../includes/views/metabox-options.php:9
39
+ msgid "Display Options"
40
+ msgstr "Weergave Opties"
41
+
42
+ #: ../includes/views/metabox-options.php:15
43
+ msgid "Show this box"
44
+ msgstr "Toon deze box"
45
+
46
+ #: ../includes/views/metabox-options.php:18
47
+ msgid "Basic"
48
+ msgstr "Standaard"
49
+
50
+ #: ../includes/views/metabox-options.php:19
51
+ msgid "Everywhere"
52
+ msgstr "Overal"
53
+
54
+ #: ../includes/views/metabox-options.php:20
55
+ msgid "if Post Type is"
56
+ msgstr "Als \"post type\" ... is"
57
+
58
+ #: ../includes/views/metabox-options.php:21
59
+ msgid "if Page is"
60
+ msgstr "Als \"page\" niet ... is"
61
+
62
+ #: ../includes/views/metabox-options.php:22
63
+ msgid "if Page is not"
64
+ msgstr "Als \"page\" niet ... is"
65
+
66
+ #: ../includes/views/metabox-options.php:23
67
+ msgid "if Post is"
68
+ msgstr "Als \"post\" niet ... is"
69
+
70
+ #: ../includes/views/metabox-options.php:25
71
+ msgid "Advanced"
72
+ msgstr "Geavanceerd"
73
+
74
+ #: ../includes/views/metabox-options.php:26
75
+ msgid "Manual conditon"
76
+ msgstr "Manuele Voorwaarde"
77
+
78
+ #: ../includes/views/metabox-options.php:31
79
+ msgid "Leave empty for any or enter (comma-separated) names or ID's"
80
+ msgstr ""
81
+ "Laat leeg voor alles of voer de namen of ID's in, gescheiden door een komma."
82
+
83
+ #: ../includes/views/metabox-options.php:39
84
+ msgid "Add rule"
85
+ msgstr "Regel toevoegen"
86
+
87
+ #: ../includes/views/metabox-options.php:42
88
+ #, php-format
89
+ msgid ""
90
+ "For using advanced (manual) rules, have a look at %sthe WordPress "
91
+ "Conditional Tags Codex page%s."
92
+ msgstr ""
93
+ "Voor het gebruken van geavanceerde manuele voorwaardes, bekijk de "
94
+ "%sWordPress Conditional Tags Codex pagina%s"
95
+
96
+ #: ../includes/views/metabox-options.php:45
97
+ msgid "Box Position"
98
+ msgstr "Box Positie"
99
+
100
+ #: ../includes/views/metabox-options.php:48
101
+ msgid "Top Left"
102
+ msgstr "Linksboven"
103
+
104
+ #: ../includes/views/metabox-options.php:49
105
+ msgid "Top Right"
106
+ msgstr "Rechtsboven"
107
+
108
+ #: ../includes/views/metabox-options.php:50
109
+ msgid "Bottom Left"
110
+ msgstr "Linksonder"
111
+
112
+ #: ../includes/views/metabox-options.php:51
113
+ msgid "Bottom Right"
114
+ msgstr "Rechtsonder"
115
+
116
+ #: ../includes/views/metabox-options.php:57
117
+ msgid "Trigger Point"
118
+ msgstr "Triggerpunt"
119
+
120
+ #: ../includes/views/metabox-options.php:61
121
+ msgid "of page height"
122
+ msgstr "van pagina hoogte"
123
+
124
+ #: ../includes/views/metabox-options.php:64
125
+ msgid "Element Selector"
126
+ msgstr "Element selector"
127
+
128
+ #: ../includes/views/metabox-options.php:70
129
+ msgid "Example: #comments (element must exist or box won't be shown)"
130
+ msgstr "Voorbeeld: #comments (element moet bestaan of de box blijft verborgen)"
131
+
132
+ #: ../includes/views/metabox-options.php:74
133
+ msgid "Animation"
134
+ msgstr "Animatie"
135
+
136
+ #: ../includes/views/metabox-options.php:76
137
+ msgid "Fade In"
138
+ msgstr "Fade In"
139
+
140
+ #: ../includes/views/metabox-options.php:77
141
+ msgid "Slide In"
142
+ msgstr "Slide In"
143
+
144
+ #: ../includes/views/metabox-options.php:78
145
+ msgid "Which animation type should be used to show the box when triggered?"
146
+ msgstr ""
147
+ "Welk animatietype moet worden gebruikt wanneer de box wordt getriggert?"
148
+
149
+ #: ../includes/views/metabox-options.php:82
150
+ msgid "Cookie expiration days"
151
+ msgstr "Cookie verloopt in ... dagen"
152
+
153
+ #: ../includes/views/metabox-options.php:85
154
+ msgid "After closing the box, how many days should it stay hidden?"
155
+ msgstr "Hoelang moet de box verborgen blijven nadat iemand de box sluit?"
156
+
157
+ #: ../includes/views/metabox-options.php:90
158
+ msgid "Auto-hide?"
159
+ msgstr "Automatisch verbergen?"
160
+
161
+ #: ../includes/views/metabox-options.php:92
162
+ #: ../includes/views/metabox-options.php:101
163
+ msgid "Yes"
164
+ msgstr "Ja"
165
+
166
+ #: ../includes/views/metabox-options.php:93
167
+ #: ../includes/views/metabox-options.php:102
168
+ msgid "No"
169
+ msgstr "Nee"
170
+
171
+ #: ../includes/views/metabox-options.php:94
172
+ msgid "Hide box again when visitors scroll back up?"
173
+ msgstr "Verberg box wanneer bezoekers terug omhoog scrollen?"
174
+
175
+ #: ../includes/views/metabox-options.php:99
176
+ msgid "Enable test mode?"
177
+ msgstr "Test modus activeren?"
178
+
179
+ #: ../includes/views/metabox-options.php:103
180
+ msgid ""
181
+ "If test mode is enabled, the box will show up regardless of whether a cookie "
182
+ "has been set."
183
+ msgstr ""
184
+ "Als test modus actief is zal de box altijd getoond worden, zelfs als er een "
185
+ "cookie geplaatst is."
186
+
187
+ #: ../includes/views/metabox-options.php:108
188
+ msgid "Appearance"
189
+ msgstr "Weergave"
190
+
191
+ #: ../includes/views/metabox-options.php:112
192
+ msgid "Background color"
193
+ msgstr "Achtergrondkleur"
194
+
195
+ #: ../includes/views/metabox-options.php:116
196
+ msgid "Text color"
197
+ msgstr "Tekstkleur"
198
+
199
+ #: ../includes/views/metabox-options.php:120
200
+ msgid "Box width"
201
+ msgstr "Box breedte"
202
+
203
+ #: ../includes/views/metabox-options.php:126
204
+ msgid "Border color"
205
+ msgstr "Border kleur"
206
+
207
+ #: ../includes/views/metabox-options.php:130
208
+ msgid "Border width"
209
+ msgstr "Border breedte"
languages/scroll-triggered-boxes.mo ADDED
Binary file
languages/scroll-triggered-boxes.po ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Scroll Triggered Boxes\n"
4
+ "POT-Creation-Date: 2014-04-18 12:14+0100\n"
5
+ "PO-Revision-Date: 2014-04-18 12:14+0100\n"
6
+ "Last-Translator: Danny <hi@dannyvankooten.com>\n"
7
+ "Language-Team: Danny van Kooten <hi@dannyvankooten.com>\n"
8
+ "Language: en_US\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.6.4\n"
13
+ "X-Poedit-Basepath: .\n"
14
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
+ "X-Poedit-KeywordsList: __;_e\n"
16
+ "X-Poedit-SearchPath-0: ..\n"
17
+
18
+ #: ../includes/class-admin.php:58
19
+ msgid "Box Options"
20
+ msgstr ""
21
+
22
+ #: ../includes/class-admin.php:67
23
+ msgid "Need support?"
24
+ msgstr ""
25
+
26
+ #: ../includes/class-admin.php:75
27
+ msgid "Donate $10, $20 or $50"
28
+ msgstr ""
29
+
30
+ #: ../includes/class-admin.php:83
31
+ msgid "About the developer"
32
+ msgstr ""
33
+
34
+ #: ../includes/views/metabox-options.php:7
35
+ msgid "Scroll Triggered Box Options"
36
+ msgstr ""
37
+
38
+ #: ../includes/views/metabox-options.php:9
39
+ msgid "Display Options"
40
+ msgstr ""
41
+
42
+ #: ../includes/views/metabox-options.php:15
43
+ msgid "Show this box"
44
+ msgstr ""
45
+
46
+ #: ../includes/views/metabox-options.php:18
47
+ msgid "Basic"
48
+ msgstr ""
49
+
50
+ #: ../includes/views/metabox-options.php:19
51
+ msgid "Everywhere"
52
+ msgstr ""
53
+
54
+ #: ../includes/views/metabox-options.php:20
55
+ msgid "if Post Type is"
56
+ msgstr ""
57
+
58
+ #: ../includes/views/metabox-options.php:21
59
+ msgid "if Page is"
60
+ msgstr ""
61
+
62
+ #: ../includes/views/metabox-options.php:22
63
+ msgid "if Page is not"
64
+ msgstr ""
65
+
66
+ #: ../includes/views/metabox-options.php:23
67
+ msgid "if Post is"
68
+ msgstr ""
69
+
70
+ #: ../includes/views/metabox-options.php:25
71
+ msgid "Advanced"
72
+ msgstr ""
73
+
74
+ #: ../includes/views/metabox-options.php:26
75
+ msgid "Manual conditon"
76
+ msgstr ""
77
+
78
+ #: ../includes/views/metabox-options.php:31
79
+ msgid "Leave empty for any or enter (comma-separated) names or ID's"
80
+ msgstr ""
81
+
82
+ #: ../includes/views/metabox-options.php:39
83
+ msgid "Add rule"
84
+ msgstr ""
85
+
86
+ #: ../includes/views/metabox-options.php:42
87
+ #, php-format
88
+ msgid ""
89
+ "For using advanced (manual) rules, have a look at %sthe WordPress "
90
+ "Conditional Tags Codex page%s."
91
+ msgstr ""
92
+
93
+ #: ../includes/views/metabox-options.php:45
94
+ msgid "Box Position"
95
+ msgstr ""
96
+
97
+ #: ../includes/views/metabox-options.php:48
98
+ msgid "Top Left"
99
+ msgstr ""
100
+
101
+ #: ../includes/views/metabox-options.php:49
102
+ msgid "Top Right"
103
+ msgstr ""
104
+
105
+ #: ../includes/views/metabox-options.php:50
106
+ msgid "Bottom Left"
107
+ msgstr ""
108
+
109
+ #: ../includes/views/metabox-options.php:51
110
+ msgid "Bottom Right"
111
+ msgstr ""
112
+
113
+ #: ../includes/views/metabox-options.php:57
114
+ msgid "Trigger Point"
115
+ msgstr ""
116
+
117
+ #: ../includes/views/metabox-options.php:61
118
+ msgid "of page height"
119
+ msgstr ""
120
+
121
+ #: ../includes/views/metabox-options.php:64
122
+ msgid "Element Selector"
123
+ msgstr ""
124
+
125
+ #: ../includes/views/metabox-options.php:70
126
+ msgid "Example: #comments (element must exist or box won't be shown)"
127
+ msgstr ""
128
+
129
+ #: ../includes/views/metabox-options.php:74
130
+ msgid "Animation"
131
+ msgstr ""
132
+
133
+ #: ../includes/views/metabox-options.php:76
134
+ msgid "Fade In"
135
+ msgstr ""
136
+
137
+ #: ../includes/views/metabox-options.php:77
138
+ msgid "Slide In"
139
+ msgstr ""
140
+
141
+ #: ../includes/views/metabox-options.php:78
142
+ msgid "Which animation type should be used to show the box when triggered?"
143
+ msgstr ""
144
+
145
+ #: ../includes/views/metabox-options.php:82
146
+ msgid "Cookie expiration days"
147
+ msgstr ""
148
+
149
+ #: ../includes/views/metabox-options.php:85
150
+ msgid "After closing the box, how many days should it stay hidden?"
151
+ msgstr ""
152
+
153
+ #: ../includes/views/metabox-options.php:90
154
+ msgid "Auto-hide?"
155
+ msgstr ""
156
+
157
+ #: ../includes/views/metabox-options.php:92
158
+ #: ../includes/views/metabox-options.php:101
159
+ msgid "Yes"
160
+ msgstr ""
161
+
162
+ #: ../includes/views/metabox-options.php:93
163
+ #: ../includes/views/metabox-options.php:102
164
+ msgid "No"
165
+ msgstr ""
166
+
167
+ #: ../includes/views/metabox-options.php:94
168
+ msgid "Hide box again when visitors scroll back up?"
169
+ msgstr ""
170
+
171
+ #: ../includes/views/metabox-options.php:99
172
+ msgid "Enable test mode?"
173
+ msgstr ""
174
+
175
+ #: ../includes/views/metabox-options.php:103
176
+ msgid ""
177
+ "If test mode is enabled, the box will show up regardless of whether a cookie "
178
+ "has been set."
179
+ msgstr ""
180
+
181
+ #: ../includes/views/metabox-options.php:108
182
+ msgid "Appearance"
183
+ msgstr ""
184
+
185
+ #: ../includes/views/metabox-options.php:112
186
+ msgid "Background color"
187
+ msgstr ""
188
+
189
+ #: ../includes/views/metabox-options.php:116
190
+ msgid "Text color"
191
+ msgstr ""
192
+
193
+ #: ../includes/views/metabox-options.php:120
194
+ msgid "Box width"
195
+ msgstr ""
196
+
197
+ #: ../includes/views/metabox-options.php:126
198
+ msgid "Border color"
199
+ msgstr ""
200
+
201
+ #: ../includes/views/metabox-options.php:130
202
+ msgid "Border width"
203
+ msgstr ""
readme.txt ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Boxzilla ===
2
+ Contributors: Ibericode, DvanKooten, hchouhan, lapzor
3
+ Donate link: https://boxzillaplugin.com/#utm_source=wp-plugin-repo&utm_medium=boxzilla&utm_campaign=donate-link
4
+ Tags: scroll triggered box, cta, social, pop-up, newsletter, call to action, mailchimp, contact form 7, social media,mc4wp
5
+ Requires at least: 3.8
6
+ Tested up to: 4.5.2
7
+ Stable tag: 3.0
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Flexible call to action boxes, popping up or sliding in at just the right time.
12
+
13
+ == Description ==
14
+
15
+ ### Boxzilla for WordPress
16
+
17
+ Boxzilla is a *lightweight* plugin for adding flexible call-to-actions to your WordPress site. Boxes can slide or fade in at any point and can contain whatever content you like.
18
+
19
+ > This is the successor of the old [Scroll Triggered Boxes](https://wordpress.org/plugins/scroll-triggered-boxes/) plugin.
20
+
21
+ #### Some of Boxzilla's features
22
+
23
+ - Boxes can contain _any_ content you like.
24
+ - Various box triggers:
25
+ - Scroll percentage
26
+ - Reaching a certain page element
27
+ - X amount of time on the page
28
+ - Exit Intent (premium)
29
+ - Time on Site (premium)
30
+ - Manually by clicking a link or button
31
+ - Customizable box position on the screen.
32
+ - Various visibility animations.
33
+ - Advanced page targeting.
34
+ - Full control over how long (and whether) boxes should stay hidden.
35
+ - Customizable box appearance using a simple & intuitive interface.
36
+ - Mobile optimized.
37
+
38
+ [Read more about Boxzilla](https://boxzillaplugin.com/#utm_source=wp-plugin-repo&utm_medium=boxzilla&utm_campaign=description).
39
+
40
+ #### Documentation
41
+
42
+ Please have a look at the [Boxzilla KB](https://kb.boxzillaplugin.com/).
43
+
44
+ #### Demo
45
+
46
+ There's a [Boxzilla demo](https://demo.boxzillaplugin.com#utm_source=wp-plugin-repo&utm_medium=boxzilla&utm_campaign=description) with some examples.
47
+
48
+ #### Add-on plugins
49
+
50
+ The core Boxzilla plugin is and always will be free. Additional advanced functionality is available through several add-ons. Not only do they extend the core functionality of the plugin, they also help to fund further development of the core (free) plugin.
51
+
52
+ [Browse available add-ons for Boxzilla](https://boxzillaplugin.com/add-ons/#utm_source=wp-plugin-repo&utm_medium=boxzilla&utm_campaign=description).
53
+
54
+ #### Contributing and reporting bugs=
55
+
56
+ You can contribute to [Boxzilla on GitHub](https://github.com/ibericode/boxzilla).
57
+
58
+ #### Support
59
+
60
+ Please use the [WordPress.org plugin support forums](https://wordpress.org/support/plugin/boxzilla) for community support where we try to help all users.
61
+
62
+ If you think you've found a bug, please [report it on GitHub](https://github.com/ibericode/boxzilla/issues).
63
+
64
+ If you're on [one of the available premium plans](https://boxzillaplugin.com/pricing#utm_source=wp-plugin-repo&utm_medium=boxzilla&utm_campaign=description), please use the support email for a faster reply.
65
+
66
+ == Frequently Asked Questions ==
67
+
68
+ = What does this plugin do? =
69
+
70
+ Have a look at the [Boxzilla demo site](https://demo.boxzillaplugin.com/#utm_source=wp-plugin-repo&utm_medium=boxzilla&utm_campaign=description).
71
+
72
+ = How to display a form in the box? =
73
+
74
+ Boxzilla will work with any plugin that offers shortcodes, like [MailChimp for WordPress](https://wordpress.org/plugins/mailchimp-for-wp/).
75
+
76
+ = Can I have a box open after clicking a certain link or button? =
77
+
78
+ Sure, by linking to the box element.
79
+
80
+ *Example (box ID is 94 in this example)*
81
+ `
82
+ <a href="#boxzilla-94">Open Box</a>
83
+ `
84
+
85
+ = Can I have a box to open right after opening a page? =
86
+
87
+ Sure, just include `boxzilla-` followed by the box ID in the URL.
88
+
89
+ *Example (box ID is 94 in this example)*
90
+ `
91
+ http://your-wordpress-site.com/some-page/#boxzilla-94
92
+ `
93
+
94
+ = Can I customize the appearance of a box =
95
+
96
+ Boxzilla comes with a simple interface for customizing most colors & borders of the box, but you're in no way limited to apply your own CSS rules.
97
+
98
+ `
99
+ .boxzilla-{id} { } /* 1 particular box */
100
+ .boxzilla { } /* all boxes */
101
+ `
102
+
103
+ = I want to disable auto-paragraphs in the box content =
104
+
105
+ All default WordPress filters are added to the `stb_content` filter hook. If you want to remove any of them, add the respectable line to your theme its `functions.php` file.
106
+
107
+ `
108
+ remove_filter( 'boxzilla_box_content', 'wptexturize') ;
109
+ remove_filter( 'boxzilla_box_content', 'convert_smilies' );
110
+ remove_filter( 'boxzilla_box_content', 'convert_chars' );
111
+ remove_filter( 'boxzilla_box_content', 'wpautop' );
112
+ remove_filter( 'boxzilla_box_content', 'do_shortcode' );
113
+ remove_filter( 'boxzilla_box_content', 'shortcode_unautop' );
114
+ `
115
+
116
+ = I want to make it impossible to close a box =
117
+ `
118
+ add_filter( 'boxzilla_box_options', function( $opts, $box ) {
119
+ $opts['closable'] = false;
120
+ return $opts;
121
+ }, 10, 2 );
122
+ `
123
+
124
+ == Installation ==
125
+
126
+ = Installing the plugin =
127
+
128
+ 1. In your WordPress admin panel, go to *Plugins > New Plugin*, search for *Boxzilla* and click "Install now"
129
+ 1. Alternatively, download the plugin and upload the contents of `boxzilla.zip` to your plugins directory, which usually is `/wp-content/plugins/`.
130
+ 1. Activate the plugin.
131
+
132
+ = Creating a Boxzilla box =
133
+
134
+ 1. Go to *Boxzilla > Add New*
135
+ 1. Add some content to the box
136
+ 1. (Optional) customize the appearance of the box by changing the *Appearance Settings*
137
+
138
+ = Additional Customization =
139
+
140
+ Have a look at the [frequently asked questions](https://wordpress.org/plugins/boxzilla/faq/) section for some examples of additional customization.
141
+
142
+ == Screenshots ==
143
+
144
+ 1. A scroll triggered box with a newsletter sign-up form.
145
+ 2. Another scroll triggered box, this time with social media sharing options.
146
+ 3. A differently styled social triggered box.
147
+ 4. Configuring and customizing your boxes is easy.
148
+
149
+ == Changelog ==
150
+
151
+
152
+ #### 3.0 - May 11, 2016
153
+
154
+ Initial release of [Boxzilla](https://boxzillaplugin.com/), formerly known as [Scroll Triggered Boxes](https://wordpress.org/plugins/scroll-triggered-boxes/).
155
+
156
+ If you're upgrading from the old plugin, please check [updating to Boxzilla from Scroll Triggered Boxes](https://kb.boxzillaplugin.com/updating-from-scroll-triggered-boxes/) for a list of changes you should be aware of.
157
+
158
+
159
+ == Upgrade Notice ==
160
+
161
+ = 2.1 =
162
+ Added autocomplete to box filters & minor bux fixes for filter rules.
src/admin/class-admin.php ADDED
@@ -0,0 +1,720 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla\Admin;
4
+
5
+ use Boxzilla\Plugin,
6
+ Boxzilla\Box,
7
+ Boxzilla\Boxzilla;
8
+ use WP_Post;
9
+ use WP_Screen;
10
+
11
+ class Admin {
12
+
13
+ /**
14
+ * @var Plugin $plugin
15
+ */
16
+ private $plugin;
17
+
18
+ /**
19
+ * @var Boxzilla
20
+ */
21
+ protected $boxzilla;
22
+
23
+ /**
24
+ * @param Plugin $plugin
25
+ * @param Boxzilla $boxzilla
26
+ */
27
+ public function __construct( Plugin $plugin, Boxzilla $boxzilla ) {
28
+ $this->plugin = $plugin;
29
+ $this->boxzilla = $boxzilla;
30
+ }
31
+
32
+ /**
33
+ * Initialise the all admin related stuff
34
+ */
35
+ public function init() {
36
+ // Load the plugin textdomain
37
+ load_plugin_textdomain( 'boxzilla', null, $this->plugin->dir() . '/languages' );
38
+
39
+ // action hooks
40
+ $this->add_hooks();
41
+ $this->run_migrations();
42
+ }
43
+
44
+ /**
45
+ * Add necessary hooks
46
+ */
47
+ protected function add_hooks() {
48
+
49
+ add_action( 'admin_init', array( $this, 'lazy_add_hooks' ) );
50
+ add_action( 'admin_init', array( $this, 'register' ) );
51
+ add_action( 'admin_menu', array( $this, 'menu' ) );
52
+
53
+ add_action( 'save_post_boxzilla-box', array( $this, 'save_box_options' ), 20, 2 );
54
+ add_action( 'trashed_post', array( $this, 'flush_rules' ) );
55
+ add_action( 'untrashed_post', array( $this, 'flush_rules' ) );
56
+
57
+ // if a premium add-on is installed, instantiate dependencies
58
+ if ( count( $this->boxzilla['plugins'] ) > 0 ) {
59
+ $this->boxzilla['license_manager']->add_hooks();
60
+ $this->boxzilla['update_manager']->add_hooks();
61
+ $this->boxzilla['api_authenticator']->add_hooks();
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Checks current version against stored version & runs necessary update routines.
67
+ *
68
+ * @return bool
69
+ */
70
+ protected function run_migrations() {
71
+
72
+ // Only run if db option is at older version than code constant
73
+ $previous_version = get_option( 'boxzilla_version', '0' );
74
+ $current_version = $this->plugin->version();
75
+
76
+ if( version_compare( $current_version, $previous_version, '<=' ) ) {
77
+ return false;
78
+ }
79
+
80
+ $upgrade_routines = new Migrations( $previous_version, $current_version, __DIR__ . '/migrations' );
81
+ $upgrade_routines->run();
82
+ update_option( 'boxzilla_version', $current_version );
83
+ }
84
+
85
+ public function lazy_add_hooks() {
86
+ global $pagenow;
87
+
88
+ add_action( 'admin_enqueue_scripts', array( $this, 'load_assets' ) );
89
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
90
+ add_filter( 'tiny_mce_before_init', array( $this, 'tinymce_init' ) );
91
+ add_filter( 'manage_edit-boxzilla-box_columns', array( $this, 'post_type_column_titles' ) );
92
+ add_action( 'manage_boxzilla-box_posts_custom_column', array(
93
+ $this,
94
+ 'post_type_column_content'
95
+ ), 10, 2 );
96
+ add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
97
+
98
+
99
+ if ( $pagenow === 'plugins.php' ) {
100
+ add_filter( 'plugin_action_links', array( $this, 'add_plugin_settings_link' ), 10, 2 );
101
+ add_filter( 'plugin_row_meta', array( $this, 'add_plugin_meta_links' ), 10, 2 );
102
+ }
103
+ }
104
+
105
+ /**
106
+ * @param $post_id
107
+ */
108
+ public function post_type_column_box_id_content( $post_id ) {
109
+ echo $post_id;
110
+ }
111
+
112
+ /**
113
+ * @param $column
114
+ * @param $post_id
115
+ */
116
+ public function post_type_column_content( $column, $post_id ) {
117
+ if ( method_exists( $this, 'post_type_column_' . $column . '_content' ) ) {
118
+ call_user_func( array( $this, 'post_type_column_' . $column . '_content' ), $post_id );
119
+ }
120
+ }
121
+
122
+ /**
123
+ * @param $columns
124
+ *
125
+ * @return mixed
126
+ */
127
+ public function post_type_column_titles( $columns ) {
128
+ $columns = self::array_insert( $columns, array(
129
+ 'box_id' => __( 'Box ID', 'boxzilla' )
130
+ ), 1 );
131
+
132
+ $columns['title'] = __( 'Box Title', 'boxzilla' );
133
+
134
+ return $columns;
135
+ }
136
+
137
+ /**
138
+ * Register stuffs
139
+ */
140
+ public function register() {
141
+
142
+ // register settings
143
+ register_setting( 'boxzilla_settings', 'boxzilla_settings', array( $this, 'sanitize_settings' ) );
144
+
145
+ // register scripts
146
+ $pre_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
147
+
148
+ wp_register_script( 'boxzilla-admin', $this->plugin->url( '/assets/js/admin-script' . $pre_suffix . '.js' ), array(
149
+ 'jquery',
150
+ 'wp-util',
151
+ 'wp-color-picker',
152
+ 'suggest'
153
+ ), $this->plugin->version(), true );
154
+
155
+ // load stylesheets
156
+ wp_register_style( 'boxzilla-admin', $this->plugin->url( '/assets/css/admin-styles' . $pre_suffix . '.css' ), array(), $this->plugin->version() );
157
+ }
158
+
159
+ /**
160
+ * Renders the STB Menu items
161
+ */
162
+ public function menu() {
163
+
164
+ $menu_items = array(
165
+ array(
166
+ __( 'Settings', 'boxzilla' ),
167
+ __( 'Settings', 'boxzilla' ),
168
+ 'boxzilla-settings',
169
+ array( $this, 'show_settings_page' )
170
+ ),
171
+ array(
172
+ __( 'Extensions', 'boxzilla' ),
173
+ '<span style="color: orange">' . __( 'Extensions', 'boxzilla' ) . '</span>',
174
+ 'boxzilla-extensions',
175
+ array( $this, 'show_extensions_page' )
176
+ )
177
+ );
178
+
179
+ $menu_items = apply_filters( 'boxzilla_admin_menu_items', $menu_items );
180
+
181
+ foreach ( $menu_items as $item ) {
182
+ add_submenu_page( 'edit.php?post_type=boxzilla-box', $item[0] . '- Boxzilla', $item[1], 'manage_options', $item[2], $item[3] );
183
+ }
184
+ }
185
+
186
+ /**
187
+ * Shows the settings page
188
+ */
189
+ public function show_settings_page() {
190
+ $opts = $this->boxzilla->options;
191
+ require __DIR__ . '/views/settings.php';
192
+ }
193
+
194
+ /**
195
+ * Shows the extensions page
196
+ */
197
+ public function show_extensions_page() {
198
+ $extensions = $this->fetch_extensions();
199
+ require __DIR__ . '/views/extensions.php';
200
+ }
201
+
202
+ /**
203
+ * Are we currently editing a box?
204
+ *
205
+ * @return bool
206
+ */
207
+ protected function on_edit_box_page() {
208
+ global $pagenow;
209
+
210
+ if ( ! in_array( $pagenow, array( 'post-new.php', 'post.php' ) ) ) {
211
+ return false;
212
+ }
213
+
214
+ if ( isset( $_GET['post_type'] ) && $_GET['post_type'] === 'boxzilla-box' ) {
215
+ return true;
216
+ }
217
+
218
+ if ( get_post_type() === 'boxzilla-box' ) {
219
+ return true;
220
+ }
221
+
222
+ return false;
223
+ }
224
+
225
+ /**
226
+ * @param $args
227
+ *
228
+ * @return mixed
229
+ */
230
+ public function tinymce_init( $args ) {
231
+
232
+ // only act on our post type
233
+ if ( get_post_type() !== 'boxzilla-box' ) {
234
+ return $args;
235
+ }
236
+
237
+ $args['setup'] = 'function( editor ) { if(typeof(window.Boxzilla_Admin) === \'undefined\') { return; } editor.on("PreInit", window.Boxzilla_Admin.Designer.init ); }';
238
+
239
+ return $args;
240
+ }
241
+
242
+ /**
243
+ * Load plugin assets
244
+ */
245
+ public function load_assets() {
246
+
247
+ $screen = get_current_screen();
248
+
249
+ if ( ! $screen instanceof WP_Screen ) {
250
+ return false;
251
+ }
252
+
253
+ if ( $screen->base === 'edit' && $screen->post_type === 'boxzilla-box' ) {
254
+ // load stylesheets
255
+ wp_enqueue_style( 'boxzilla-admin' );
256
+ }
257
+
258
+ if ( $screen->base === 'post' && $screen->post_type === 'boxzilla-box' ) {
259
+ // color picker
260
+ wp_enqueue_style( 'wp-color-picker' );
261
+
262
+ // load scripts
263
+ wp_enqueue_script( 'boxzilla-admin' );
264
+
265
+ wp_localize_script( 'boxzilla-admin' ,'boxzilla_i18n', array(
266
+ 'enterCommaSeparatedValues' => __( 'Enter a comma-separated list of values.', 'boxzilla' ),
267
+ 'enterCommaSeparatedPosts' => __( "Enter a comma-separated list of post slugs or post ID's..", 'boxzilla' ),
268
+ 'enterCommaSeparatedPages' => __( "Enter a comma-separated list of page slugs or page ID's..", 'boxzilla' ),
269
+ 'enterCommaSeparatedPostTypes' => __( "Enter a comma-separated list of post types..", 'boxzilla' ),
270
+ 'enterCommaSeparatedRelativeUrls' => __( "Enter a comma-separated list of relative URL's, eg /contact/", 'boxzilla' ),
271
+ )
272
+ );
273
+
274
+ // load stylesheets
275
+ wp_enqueue_style( 'boxzilla-admin' );
276
+
277
+ // allow add-ons to easily load their own scripts or stylesheets
278
+ do_action( 'boxzilla_load_admin_assets' );
279
+ }
280
+
281
+ if ( isset( $_GET['page'] ) && $_GET['page'] === 'boxzilla-settings' ) {
282
+ // load stylesheets
283
+ wp_enqueue_style( 'boxzilla-admin' );
284
+ }
285
+
286
+ }
287
+
288
+ /**
289
+ * Register meta boxes
290
+ *
291
+ * @param string $post_type
292
+ *
293
+ * @return bool
294
+ */
295
+ public function add_meta_boxes( $post_type ) {
296
+
297
+ if ( $post_type !== 'boxzilla-box' ) {
298
+ return false;
299
+ }
300
+
301
+ add_meta_box(
302
+ 'boxzilla-box-appearance-controls',
303
+ __( 'Box Appearance', 'boxzilla' ),
304
+ array( $this, 'metabox_box_appearance_controls' ),
305
+ 'boxzilla-box',
306
+ 'normal',
307
+ 'core'
308
+ );
309
+
310
+ add_meta_box(
311
+ 'boxzilla-box-options-controls',
312
+ __( 'Box Options', 'boxzilla' ),
313
+ array( $this, 'metabox_box_option_controls' ),
314
+ 'boxzilla-box',
315
+ 'normal',
316
+ 'core'
317
+ );
318
+
319
+ add_meta_box(
320
+ 'boxzilla-support',
321
+ __( 'Looking for help?', 'boxzilla' ),
322
+ array( $this, 'metabox_support' ),
323
+ 'boxzilla-box',
324
+ 'side'
325
+ );
326
+
327
+ add_meta_box(
328
+ 'boxzilla-email-optin',
329
+ __( 'Subscribe to our newsletter', 'boxzilla' ),
330
+ array( $this, 'metabox_email_optin' ),
331
+ 'boxzilla-box',
332
+ 'side'
333
+ );
334
+
335
+ return true;
336
+ }
337
+
338
+ /**
339
+ * @param \WP_Post $post
340
+ * @param $metabox
341
+ */
342
+ public function metabox_box_appearance_controls( \WP_Post $post, $metabox ) {
343
+
344
+ // get box options
345
+ $box = new Box( $post );
346
+ $opts = $box->get_options();
347
+
348
+ // include view
349
+ include __DIR__ . '/views/metaboxes/box-appearance-controls.php';
350
+ }
351
+
352
+ /**
353
+ * @param \WP_Post $post
354
+ * @param $metabox
355
+ */
356
+ public function metabox_box_option_controls( \WP_Post $post, $metabox ) {
357
+
358
+ // get box options
359
+ $box = new Box( $post );
360
+ $opts = $box->get_options();
361
+ $global_opts = $this->boxzilla->options;
362
+
363
+ if ( empty( $opts['rules'] ) ) {
364
+ $opts['rules'][] = array( 'condition' => '', 'qualifier' => 1, 'value' => '' );
365
+ }
366
+
367
+ // include view
368
+ include __DIR__ . '/views/metaboxes/box-option-controls.php';
369
+ }
370
+
371
+ /**
372
+ * @param \WP_Post $post
373
+ * @param $metabox
374
+ */
375
+ public function metabox_email_optin( \WP_Post $post, $metabox ) {
376
+ include __DIR__ . '/views/metaboxes/email-optin.php';
377
+ }
378
+
379
+ /**
380
+ * @param \WP_Post $post
381
+ * @param $metabox
382
+ */
383
+ public function metabox_support( \WP_Post $post, $metabox ) {
384
+ include __DIR__ . '/views/metaboxes/need-help.php';
385
+ }
386
+
387
+
388
+ /**
389
+ * Saves box options and rules
390
+ *
391
+ * @param int $box_id
392
+ *
393
+ * @return bool
394
+ */
395
+ public function save_box_options( $box_id, $post ) {
396
+
397
+ // Only act on our own post type
398
+ if ( $post->post_type !== 'boxzilla-box' ) {
399
+ return false;
400
+ }
401
+
402
+ // is this a revision save?
403
+ if ( wp_is_post_revision( $box_id ) || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) ) {
404
+ return false;
405
+ }
406
+
407
+ // can user edit this post?
408
+ if ( ! current_user_can( 'edit_post', $box_id ) ) {
409
+ return false;
410
+ }
411
+
412
+ // make sure options array is set
413
+ if ( ! isset( $_POST['boxzilla_box'] ) || ! is_array( $_POST['boxzilla_box'] ) ) {
414
+ return false;
415
+ }
416
+
417
+ // get new options from $_POST
418
+ $opts = $this->sanitize_box_options( $_POST['boxzilla_box'] );
419
+
420
+ // allow extensions to filter the saved options
421
+ $opts = apply_filters( 'boxzilla_saved_options', $opts, $box_id );
422
+
423
+ // save individual box settings
424
+ update_post_meta( $box_id, 'boxzilla_options', $opts );
425
+
426
+ // update global settings if given
427
+ if( ! empty( $_POST['boxzilla_global_settings'] ) ) {
428
+ $global_settings = get_option( 'boxzilla_settings', array() );
429
+ if( ! is_array( $global_settings ) ) { $global_settings = array(); }
430
+ $global_settings = array_merge( $global_settings, $_POST['boxzilla_global_settings'] );
431
+ update_option( 'boxzilla_settings', $global_settings );
432
+ }
433
+
434
+ $this->flush_rules( $box_id );
435
+
436
+ return true;
437
+ }
438
+
439
+ /**
440
+ * @param array $opts
441
+ *
442
+ * @return array
443
+ */
444
+ public function sanitize_settings( $opts ) {
445
+ return $opts;
446
+ }
447
+
448
+ /**
449
+ * @param string $url_string
450
+ *
451
+ * @return string
452
+ */
453
+ public function sanitize_url( $url_string ) {
454
+
455
+ // if empty, just return a slash
456
+ if( empty( $url_string ) ) {
457
+ return '/';
458
+ }
459
+
460
+ // if string looks like an absolute URL, extract just the path
461
+ if( preg_match( '/^((https|http)?\:\/\/)?(\w+\.)?\w+\.\w+\.*/i', $url_string ) ) {
462
+
463
+ // make sure URL has scheme prepended, to make parse_url() understand..
464
+ $url_string = 'https://' . str_replace( array( 'http://', 'https://' ), '', $url_string );
465
+
466
+ // get just the path
467
+ $url_string = parse_url( $url_string, PHP_URL_PATH );
468
+ }
469
+
470
+ // leading slash it
471
+ return '/' . ltrim( $url_string, '/' );
472
+ }
473
+
474
+ /**
475
+ * @param array $rule
476
+ * @return array The sanitized rule array
477
+ */
478
+ public function sanitize_box_rule( $rule) {
479
+ $rule['value'] = trim( $rule['value'] );
480
+
481
+ // convert to array
482
+ $rule['value'] = explode( ',', trim( $rule['value'], ',' ) );
483
+
484
+ // trim all whitespace in value field
485
+ $rule['value'] = array_map( 'trim', $rule['value'] );
486
+
487
+ // Make sure "is_url" values have a leading slash
488
+ if ( $rule['condition'] === 'is_url' ) {
489
+ $rule['value'] = array_map( array( $this, 'sanitize_url' ), $rule['value'] );
490
+ }
491
+
492
+ // (re)set value to 0 when condition is everywhere
493
+ if ( $rule['condition'] === 'everywhere' ) {
494
+ $rule['value'] = '';
495
+ }
496
+
497
+ // convert back to string before saving
498
+ if ( is_array( $rule['value'] ) ) {
499
+ $rule['value'] = join( ',', $rule['value'] );
500
+ }
501
+
502
+ $rule['qualifier'] = isset( $rule['qualifier'] ) && ! $rule['qualifier'] ? 0 : 1;
503
+
504
+ return $rule;
505
+ }
506
+
507
+ /**
508
+ * @param array $css
509
+ * @return array
510
+ */
511
+ public function sanitize_box_css( $css ) {
512
+
513
+ // sanitize settings
514
+ if ( '' !== $css['width'] ) {
515
+ $css['width'] = absint( $css['width'] );
516
+ }
517
+
518
+ if ( '' !== $css['border_width'] ) {
519
+ $css['border_width'] = absint( $css['border_width'] );
520
+ }
521
+
522
+ // make sure colors start with `#`
523
+ $color_keys = array( 'color', 'background_color', 'border_color' );
524
+ foreach ( $color_keys as $key ) {
525
+ $value = $css[ $key ];
526
+ $color = sanitize_text_field( $value );
527
+
528
+ // make sure color starts with `#`
529
+ if ( '' !== $color && $color[0] !== '#' ) {
530
+ $color = '#' . $color;
531
+ }
532
+ $css[ $key ] = $color;
533
+ }
534
+
535
+ return $css;
536
+ }
537
+
538
+ /**
539
+ * Sanitize the options for this box.
540
+ *
541
+ * @param array $opts
542
+ *
543
+ * @return array
544
+ */
545
+ protected function sanitize_box_options( $opts ) {
546
+
547
+ static $defaults = array(
548
+ 'rules' => array(),
549
+ 'css' => array()
550
+ );
551
+
552
+ $opts = array_replace_recursive( $defaults, $opts );
553
+
554
+ $opts['rules'] = array_map( array( $this, 'sanitize_box_rule' ), $opts['rules'] );
555
+ $opts['css'] = $this->sanitize_box_css( $opts['css'] );
556
+ $opts['cookie'] = absint( $opts['cookie'] );
557
+ $opts['trigger'] = sanitize_text_field( $opts['trigger'] );
558
+ $opts['trigger_percentage'] = absint( $opts['trigger_percentage'] );
559
+ $opts['trigger_element'] = sanitize_text_field( $opts['trigger_element'] );
560
+
561
+ return $opts;
562
+ }
563
+
564
+ /**
565
+ * Add the settings link to the Plugins overview
566
+ *
567
+ * @param array $links
568
+ * @param string $slug
569
+ *
570
+ * @return array
571
+ */
572
+ public function add_plugin_settings_link( $links, $slug ) {
573
+ if ( $slug !== $this->plugin->slug() ) {
574
+ return $links;
575
+ }
576
+
577
+ $settings_link = '<a href="' . admin_url( 'edit.php?post_type=boxzilla-box' ) . '">' . __( 'Boxes' ) . '</a>';
578
+ array_unshift( $links, $settings_link );
579
+
580
+ return $links;
581
+ }
582
+
583
+ /**
584
+ * Adds meta links to the plugin in the WP Admin > Plugins screen
585
+ *
586
+ * @param array $links
587
+ * @param string $slug
588
+ *
589
+ * @return array
590
+ */
591
+ public function add_plugin_meta_links( $links, $slug ) {
592
+ if ( $slug !== $this->plugin->slug() ) {
593
+ return $links;
594
+ }
595
+
596
+ $links[] = '<a href="https://kb.boxzillaplugin.com/#utm_source=wp-plugin&utm_medium=boxzilla&utm_campaign=plugins-page">Documentation</a>';
597
+ $links[] = '<a href="https://boxzillaplugin.com/add-ons/#utm_source=wp-plugin&utm_medium=boxzilla&utm_campaign=plugins-page">Add-ons</a>';
598
+
599
+ return $links;
600
+ }
601
+
602
+ /**
603
+ * Flush all box rules
604
+ *
605
+ * Loops through all published boxes and fills the rules option
606
+ *
607
+ * @param int $post_id
608
+ */
609
+ public function flush_rules( $post_id ) {
610
+
611
+ // only act on our own post type
612
+ $post = get_post( $post_id );
613
+ if ( $post instanceof WP_Post && $post->post_type !== 'boxzilla-box' ) {
614
+ return;
615
+ }
616
+
617
+ // get all published boxes
618
+ $boxes = get_posts(
619
+ array(
620
+ 'post_type' => 'boxzilla-box',
621
+ 'post_status' => 'publish',
622
+ 'numberposts' => - 1
623
+ )
624
+ );
625
+
626
+ // setup empty array of rules
627
+ $rules = array();
628
+
629
+ // fill rules array
630
+ if ( is_array( $boxes ) ) {
631
+
632
+ foreach ( $boxes as $box ) {
633
+ // get box meta data
634
+ $box_meta = get_post_meta( $box->ID, 'boxzilla_options', true );
635
+
636
+ // add box rules to all rules
637
+ $rules[ $box->ID ] = $box_meta['rules'];
638
+ $rules[ $box->ID ]['comparision'] = $box_meta['rules_comparision'];
639
+
640
+ }
641
+
642
+ }
643
+
644
+ update_option( 'boxzilla_rules', $rules );
645
+ }
646
+
647
+ /**
648
+ * Fetches a list of available add-on plugins
649
+ *
650
+ * @return array
651
+ */
652
+ protected function fetch_extensions() {
653
+
654
+ $extensions = get_transient( 'boxzilla_remote_extensions' );
655
+ if ( $extensions ) {
656
+ return $extensions;
657
+ }
658
+
659
+ $request = wp_remote_get( 'https://api.boxzillaplugin.com/v1/plugins' );
660
+
661
+ if ( is_wp_error( $request ) ) {
662
+ return array();
663
+ }
664
+
665
+ $response = wp_remote_retrieve_body( $request );
666
+ $response = json_decode( $response );
667
+
668
+ if ( is_array( $response->data ) ) {
669
+ set_transient( 'boxzilla_remote_extensions', $response->data, HOUR_IN_SECONDS );
670
+
671
+ return $response->data;
672
+ }
673
+
674
+ return array();
675
+ }
676
+
677
+ /**
678
+ * @param $arr
679
+ * @param $insert
680
+ * @param $position
681
+ *
682
+ * @return array
683
+ */
684
+ public static function array_insert( $arr, $insert, $position ) {
685
+ $i = 0;
686
+ $ret = array();
687
+ foreach ( $arr as $key => $value ) {
688
+ if ( $i == $position ) {
689
+ foreach ( $insert as $ikey => $ivalue ) {
690
+ $ret[ $ikey ] = $ivalue;
691
+ }
692
+ }
693
+ $ret[ $key ] = $value;
694
+ $i ++;
695
+ }
696
+
697
+ return $ret;
698
+ }
699
+
700
+ /**
701
+ * @param string $text
702
+ *
703
+ * @return string
704
+ */
705
+ public function admin_footer_text( $text ) {
706
+ $screen = get_current_screen();
707
+
708
+ if ( ! $screen instanceof WP_Screen ) {
709
+ return $text;
710
+ }
711
+
712
+ $on_edit_page = $screen->parent_base === 'edit' && $screen->post_type === 'boxzilla-box';
713
+ if ( $on_edit_page ) {
714
+ return sprintf( 'If you enjoy using <strong>Boxzilla</strong>, please <a href="%s" target="_blank">leave us a ★★★★★ rating</a>. A <strong style="text-decoration: underline;">huge</strong> thank you in advance!', 'https://wordpress.org/support/view/plugin-reviews/boxzilla?rate=5#postform' );
715
+ }
716
+
717
+ return $text;
718
+ }
719
+
720
+ }
src/admin/class-autocomplete.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla\Filter;
4
+
5
+ class Autocomplete {
6
+
7
+ public function add_hooks() {
8
+ add_action( 'wp_ajax_boxzilla_autocomplete', array( $this, 'ajax' ) );
9
+ }
10
+
11
+ /**
12
+ * AJAX listener for autocomplete
13
+ */
14
+ public function ajax() {
15
+ $q = ( isset( $_GET['q'] ) ) ? sanitize_text_field( $_GET['q'] ) : '';
16
+ $type = ( isset( $_GET['type'] ) && in_array( $_GET['type'], array( 'page', 'post', 'category', 'post_type' ) ) ) ? $_GET['type'] : 'post';
17
+
18
+ // do nothing if supplied 'q' parameter is omitted or empty
19
+ // or less than 2 characters long
20
+ if( empty( $q ) || strlen( $q ) < 2 ) {
21
+ die();
22
+ }
23
+
24
+ switch( $type ) {
25
+
26
+ default:
27
+ case 'post':
28
+ case 'page':
29
+ echo $this->list_posts( $q, $type );
30
+ break;
31
+
32
+ case 'category':
33
+ echo $this->list_categories( $q );
34
+ break;
35
+
36
+ case 'post_type':
37
+ echo $this->list_post_types( $q );
38
+ break;
39
+ }
40
+
41
+ die();
42
+ }
43
+
44
+ /**
45
+ * @param string $query
46
+ * @param string $post_type
47
+ *
48
+ * @return string
49
+ */
50
+ protected function list_posts( $query, $post_type = 'post' ) {
51
+ global $wpdb;
52
+ $sql = $wpdb->prepare( "SELECT p.post_name FROM $wpdb->posts p WHERE p.post_type = '%s' AND p.post_status = 'publish' AND ( p.post_title LIKE '%s' OR p.post_name LIKE '%s' ) GROUP BY p.post_name", $post_type, $query . '%%', $query . '%%' );
53
+ $post_slugs = $wpdb->get_col( $sql );
54
+ return join( $post_slugs, PHP_EOL );
55
+ }
56
+
57
+ /**
58
+ * @param string $query
59
+ *
60
+ * @return string
61
+ */
62
+ protected function list_categories( $query ) {
63
+ $categories = get_terms( 'category', array( 'name__like' => $query, 'fields' => 'names', 'hide_empty' => false ) );
64
+ return join( $categories, PHP_EOL );
65
+ }
66
+
67
+ /**
68
+ * @param string $query
69
+ *
70
+ * @return string
71
+ */
72
+ protected function list_post_types( $query ) {
73
+ $post_types = get_post_types( array( 'public' => true ), 'names' );
74
+ $matched_post_types = array_filter( $post_types, function( $name ) use( $query ) {
75
+ return strpos( $name, $query ) === 0;
76
+ });
77
+
78
+ return join( $matched_post_types, PHP_EOL );
79
+ }
80
+ }
src/admin/class-installer.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ namespace Boxzilla\Admin;
5
+
6
+ class Installer {
7
+
8
+ /**
9
+ * Run the installer
10
+ */
11
+ public static function run() {
12
+ $installer = new self;
13
+ $installer->install();
14
+ }
15
+
16
+ /**
17
+ * The main install method
18
+ */
19
+ public function install() {
20
+
21
+ // don't install sample boxes on multisite
22
+ if( is_multisite() ) {
23
+ return;
24
+ }
25
+
26
+ $this->transfer_from_stb();
27
+ $this->create_sample_box();
28
+ }
29
+
30
+ /**
31
+ *
32
+ */
33
+ public function transfer_from_stb() {
34
+ global $wpdb;
35
+
36
+ // transfer post types
37
+ $query = $wpdb->prepare( "UPDATE {$wpdb->posts} SET post_type = %s WHERE post_type = %s", 'boxzilla-box', 'scroll-triggered-box' );
38
+ $wpdb->query( $query );
39
+
40
+ // transfer post meta
41
+ $query = $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_key = %s WHERE meta_key = %s", 'boxzilla_options', 'stb_options' );
42
+ $wpdb->query( $query );
43
+
44
+ // transfer rules
45
+ $query = $wpdb->prepare( "UPDATE {$wpdb->options} SET option_name = %s WHERE option_name = %s", 'boxzilla_rules', 'stb_rules' );
46
+ $wpdb->query( $query );
47
+ }
48
+
49
+ /**
50
+ * @return bool
51
+ */
52
+ protected function create_sample_box() {
53
+
54
+ // only create sample box if no boxes were found
55
+ $boxes = get_posts(
56
+ array(
57
+ 'post_type' => 'boxzilla-box',
58
+ 'post_status' => array( 'publish', 'draft' )
59
+ )
60
+ );
61
+
62
+ if( ! empty( $boxes ) ) {
63
+ return false;
64
+ }
65
+
66
+ $box_id = wp_insert_post(
67
+ array(
68
+ 'post_type' => 'boxzilla-box',
69
+ 'post_title' => "Sample Box",
70
+ 'post_content' => "<h4>Hello world.</h4><p>This is a sample box, with some sample content in it.</p>",
71
+ 'post_status' => 'draft',
72
+ )
73
+ );
74
+
75
+ // set box settings
76
+ $settings = array(
77
+ 'css' => array(
78
+ 'background_color' => '#edf9ff',
79
+ 'color' => '',
80
+ 'width' => '340',
81
+ 'border_color' => '#dd7575',
82
+ 'border_width' => '4',
83
+ 'border_style' => 'dashed',
84
+ 'position' => 'bottom-right',
85
+ 'manual' => ''
86
+ )
87
+ );
88
+
89
+ update_post_meta( $box_id, 'boxzilla_options', $settings );
90
+
91
+ return true;
92
+ }
93
+ }
src/admin/class-migrations.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla\Admin;
4
+
5
+ use Exception;
6
+
7
+ /**
8
+ *
9
+ */
10
+ class Migrations {
11
+
12
+ /**
13
+ * @var float
14
+ */
15
+ protected $version_from = 0;
16
+
17
+ /**
18
+ * @var float
19
+ */
20
+ protected $version_to = 0;
21
+
22
+ /**
23
+ * @var string
24
+ */
25
+ protected $migrations_dir = '';
26
+
27
+ /**
28
+ * @param float $from
29
+ * @param float $to
30
+ * @param string $migrations_dir
31
+ */
32
+ public function __construct( $from, $to, $migrations_dir ) {
33
+ $this->version_from = $from;
34
+ $this->version_to = $to;
35
+ $this->migrations_dir = $migrations_dir;
36
+ }
37
+
38
+ /**
39
+ * Run the various upgrade routines, all the way up to the latest version
40
+ */
41
+ public function run() {
42
+ $migrations = $this->find_migrations();
43
+ // run in sub-function for scope
44
+ array_map( array( $this, 'run_migration' ), $migrations );
45
+ }
46
+
47
+ /**
48
+ * @return array
49
+ */
50
+ public function find_migrations() {
51
+ $files = glob( rtrim( $this->migrations_dir, '/' ) . '/*.php' );
52
+ $migrations = array();
53
+
54
+ foreach( $files as $file ) {
55
+ $migration = basename( $file );
56
+ $parts = explode( '-', $migration );
57
+ $version = $parts[0];
58
+
59
+ if( version_compare( $this->version_from, $version, '<' ) ) {
60
+ $migrations[] = $file;
61
+ }
62
+ }
63
+
64
+ return $migrations;
65
+ }
66
+
67
+ /**
68
+ * Include a migration file and runs it.
69
+ *
70
+ * @param string $file
71
+ *
72
+ * @throws Exception
73
+ */
74
+ protected function run_migration( $file ) {
75
+
76
+ if( ! file_exists( $file ) ) {
77
+ throw new Exception( "Migration file $file does not exist.");
78
+ }
79
+
80
+ include $file;
81
+ }
82
+ }
src/admin/class-notices.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla\Admin;
4
+
5
+ class Notices {
6
+
7
+ /**
8
+ * @var array
9
+ */
10
+ protected $notices = array();
11
+
12
+ /**
13
+ * Constructor
14
+ */
15
+ public function __construct() {
16
+ add_action( 'admin_notices', array( $this, 'show' ) );
17
+ }
18
+
19
+ /**
20
+ * @param $message
21
+ * @param $type
22
+ *
23
+ * @return $this
24
+ */
25
+ public function add( $message, $type = 'updated' ) {
26
+ $this->notices[] = array(
27
+ 'message' => $message,
28
+ 'type' => $type,
29
+ );
30
+
31
+ return $this;
32
+ }
33
+
34
+ /**
35
+ * Output the registered notices
36
+ */
37
+ public function show() {
38
+ foreach( $this->notices as $notice ) {
39
+ echo sprintf( '<div class="notice notice-%s"><p>%s</p></div>', $notice['type'], $notice['message'] );
40
+ }
41
+ }
42
+ }
src/admin/views/extensions.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <div class="wrap" id="boxzilla-admin" class="boxzilla-extensions">
3
+
4
+ <h2><?php _e( 'Available Add-On Plugins', 'boxzilla' ); ?></h2>
5
+ <p>
6
+ <?php _e( "There are various add-ons available for Boxzilla which further enhance the functionality of the core plugin.", 'boxzilla' ); ?>
7
+ </p>
8
+ <p>
9
+ <?php printf( __( 'To gain instant access the premium add-on plugins listed here, <a href="%s">have a look at our pricing</a>.', 'boxzilla' ), 'https://boxzillaplugin.com/pricing#utm_source=wp-plugin&utm_medium=boxzilla&utm_campaign=extensions-page' ); ?>
10
+ </p>
11
+
12
+ <?php if( empty( $extensions ) ) : ?>
13
+ <script>
14
+ window.setTimeout( function() {
15
+ window.location.href = 'https://Boxzilla.com/plugins#utm_source=wp-plugin&utm_medium=boxzilla&utm_campaign=extensions-page';
16
+ }, 2000 );
17
+ </script>
18
+ <p><?php _e( 'You will be redirected to the Boxzilla site in a few seconds..', 'boxzilla' ); ?></p>
19
+ <p><?php printf( __( 'If not, please click here: %s.', 'boxzilla' ), '<a href="https://boxzillaplugin.com/add-ons#utm_source=wp-plugin&utm_medium=boxzilla&utm_campaign=extensions-page" target="_blank">View add-on plugins</a>' ); ?></p>
20
+ <?php else : ?>
21
+
22
+ <?php foreach( $extensions as $plugin ) : ?>
23
+
24
+ <div class="plugin">
25
+ <a href="<?php echo esc_url( $plugin->page_url ); ?>" class="unstyled"><img src="<?php echo esc_url( $plugin->image_url ); ?>" alt="<?php echo $plugin->name; ?>" width="280" height="220"></a>
26
+ <div class="caption">
27
+ <h3><a href="<?php echo esc_url( $plugin->page_url ); ?>" class="unstyled"><?php echo $plugin->name; ?></a></h3>
28
+ <p><?php echo esc_html( $plugin->short_description ); ?></p>
29
+ <p>
30
+ <a class="button" href="<?php echo esc_url( $plugin->page_url ); ?>" title="More about <?php echo esc_attr( $plugin->name ); ?>">Read More</a>
31
+ <span class="type"><?php echo esc_html( $plugin->type ); ?></span>
32
+ </p>
33
+ </div>
34
+ </div>
35
+
36
+ <?php endforeach; ?>
37
+
38
+ <br style="clear: both;" />
39
+
40
+ <?php endif; ?>
41
+ </div>
42
+
43
+ <style type="text/css">
44
+ .plugin {
45
+ width: 280px;
46
+ border: 1px solid #ccc;
47
+ margin: 0 20px 20px 0;
48
+ float: left;
49
+ }
50
+
51
+ .plugin .caption {
52
+ padding: 0 20px;
53
+ }
54
+
55
+ .plugin .type {
56
+ float: right;
57
+ text-transform: uppercase;
58
+ font-weight: bold;
59
+ }
60
+ </style>
src/admin/views/metaboxes/box-appearance-controls.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <div id="notice-notinymce" class="error" style="display: none;"><p><?php _e( 'For the best experience when styling your box, please use the default WordPress visual editor.', 'boxzilla' ); ?></p></div>
3
+
4
+ <table class="form-table">
5
+ <?php do_action( 'boxzilla_before_box_appearance_controls', $box, $opts ); ?>
6
+ <tr valign="top">
7
+ <td>
8
+ <label class="boxzilla-label" for="boxzilla-background-color"><?php _e( 'Background color', 'boxzilla' ); ?></label>
9
+ <input id="boxzilla-background-color" name="boxzilla_box[css][background_color]" type="text" class="boxzilla-color-field" value="<?php echo esc_attr($opts['css']['background_color']); ?>" />
10
+ </td>
11
+ <td>
12
+ <label class="boxzilla-label" for="boxzilla-color"><?php _e( 'Text color', 'boxzilla' ); ?></label>
13
+ <input id="boxzilla-color" name="boxzilla_box[css][color]" type="text" class="boxzilla-color-field" value="<?php echo esc_attr($opts['css']['color']); ?>" />
14
+ </td>
15
+ <td>
16
+ <label class="boxzilla-label" for="boxzilla-width"><?php _e( 'Box width', 'boxzilla' ); ?></label>
17
+ <input id="boxzilla-width" name="boxzilla_box[css][width]" id="boxzilla-box-width" min="0" max="3200" type="number" step="1" value="<?php echo esc_attr($opts['css']['width']); ?>" />
18
+ <p class="help"><?php _e( 'Width in px', 'boxzilla' ); ?></p>
19
+ </td>
20
+ </tr>
21
+ <tr valign="top">
22
+ <td>
23
+ <label class="boxzilla-label" for="boxzilla-border-color"><?php _e( 'Border color', 'boxzilla' ); ?></label>
24
+ <input name="boxzilla_box[css][border_color]" id="boxzilla-border-color" type="text" class="boxzilla-color-field" value="<?php echo esc_attr($opts['css']['border_color']); ?>" />
25
+ </td>
26
+ <td>
27
+ <label class="boxzilla-label" for="boxzilla-border-width"><?php _e( 'Border width', 'boxzilla' ); ?></label>
28
+ <input name="boxzilla_box[css][border_width]" id="boxzilla-border-width" type="number" min="0" max="25" step="1" value="<?php echo esc_attr($opts['css']['border_width']); ?>" />
29
+ <p class="help"><?php _e( 'Width in px', 'boxzilla' ); ?></p>
30
+ </td>
31
+ <td>
32
+ <label class="boxzilla-label" for="boxzilla-border-style"><?php _e( 'Border style', 'boxzilla' ); ?></label>
33
+ <select name="boxzilla_box[css][border_style]" id="boxzilla-border-style">
34
+ <option value="" <?php selected( $opts['css']['border_style'], '' ); ?>><?php _e( 'Default', 'boxzilla-theme-pack' ); ?></option>
35
+ <option value="solid" <?php selected( $opts['css']['border_style'], 'solid' ); ?>><?php _e( 'Solid', 'boxzilla-theme-pack' ); ?></option>
36
+ <option value="dashed" <?php selected( $opts['css']['border_style'], 'dashed' ); ?>><?php _e( 'Dashed', 'boxzilla-theme-pack' ); ?></option>
37
+ <option value="dotted" <?php selected( $opts['css']['border_style'], 'dotted' ); ?>><?php _e( 'Dotted', 'boxzilla-theme-pack' ); ?></option>
38
+ <option value="double" <?php selected( $opts['css']['border_style'], 'double' ); ?>><?php _e( 'Double', 'boxzilla-theme-pack' ); ?></option>
39
+ </select>
40
+ <p class="help"><?php _e( 'Border style', 'boxzilla' ); ?></p>
41
+ </td>
42
+ </tr>
43
+ <?php do_action( 'boxzilla_after_box_appearance_controls', $box, $opts ); ?>
44
+ </table>
45
+
46
+ <p><?php printf( __( '<a href="%s">Click here to reset all styling settings</a>.', 'boxzilla' ), 'javascript:Boxzilla_Admin.Designer.resetStyles();' ); ?></p>
src/admin/views/metaboxes/box-option-controls.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ defined( 'ABSPATH' ) or exit;
4
+
5
+ /** @var \Boxzilla\Box $box */
6
+ /** @var array $opts */
7
+ /** @var array $global_opts */
8
+
9
+ /** @var array $rule_options */
10
+ $rule_options = array(
11
+ '' => __( "Select a condition", 'boxzilla' ),
12
+ 'everywhere' => __( 'everywhere', 'boxzilla' ),
13
+ 'is_page' => __( 'if page', 'boxzilla' ),
14
+ 'is_single' => __( 'if post', 'boxzilla' ),
15
+ 'is_post_in_category' => __( 'if post category', 'boxzilla' ),
16
+ 'is_post_type' => __( 'if post type', 'boxzilla' ),
17
+ 'is_url' => __( 'if URL', 'boxzilla' ),
18
+ 'is_referer' => __( 'if referer', 'boxzilla' ),
19
+ );
20
+
21
+ $box_positions = array(
22
+ 'bottom-left' => __( 'Bottom Left', 'boxzilla' ),
23
+ 'bottom-right' => __( 'Bottom Right', 'boxzilla' ),
24
+ 'center' => __( 'Center', 'boxzilla' ),
25
+ 'top-left' => __( 'Top Left', 'boxzilla' ),
26
+ 'top-right' => __( 'Top Right', 'boxzilla' ),
27
+ );
28
+
29
+ ?>
30
+ <table class="form-table">
31
+ <?php
32
+ do_action( 'boxzilla_before_box_option_controls', $box, $opts );
33
+
34
+ ?>
35
+ <tr>
36
+ <th><?php _e( 'Load this box if', 'boxzilla' ); ?></th>
37
+ <td>
38
+ <label>
39
+ <?php _e( 'Request matches', 'boxzilla' ); ?>
40
+ <select name="boxzilla_box[rules_comparision]">
41
+ <option value="any" <?php selected( $opts['rules_comparision'], 'any' ); ?>><?php _e( 'any', 'boxzilla' ); ?></option>
42
+ <option value="all" <?php selected( $opts['rules_comparision'], 'all' ); ?>><?php _e( 'all', 'boxzilla' ); ?></option>
43
+ </select>
44
+ <?php _e( 'of the following conditions.', 'boxzilla' ); ?>
45
+ </label>
46
+ </td>
47
+ </tr>
48
+ <tbody id="boxzilla-box-rules">
49
+ <?php
50
+ $key = 0;
51
+ foreach( $opts['rules'] as $rule ) { if( ! array_key_exists( 'condition', $rule ) ) { continue; } ?>
52
+ <tr valign="top" class="boxzilla-rule-row boxzilla-rule-row-<?php echo $key; ?>">
53
+ <th style="text-align: right; font-weight: normal;">
54
+ <span class="boxzilla-close boxzilla-remove-rule"><span class="dashicons dashicons-dismiss"></span></span>
55
+ </th>
56
+ <td>
57
+ <select class="boxzilla-rule-condition" name="boxzilla_box[rules][<?php echo $key; ?>][condition]">
58
+ <?php foreach( $rule_options as $value => $label ) {
59
+ printf( '<option value="%s" %s %s>%s</option>', $value, disabled( $value, '', false ), selected( $rule['condition'], $value ), $label );
60
+ } ?>
61
+ </select>
62
+
63
+ <select class="boxzilla-rule-qualifier" name="boxzilla_box[rules][<?php echo $key; ?>][qualifier]">
64
+ <option value="1" <?php selected( ! isset( $rule['qualifier'] ) || $rule['qualifier'] ); ?>><?php _e( 'is', 'boxzilla' ); ?></option>
65
+ <option value="0" <?php selected( isset( $rule['qualifier'] ) && !$rule['qualifier'] ); ?>><?php _e( 'is not', 'boxzilla' ); ?></option>
66
+ </select>
67
+
68
+ <input class="boxzilla-rule-value regular-text" name="boxzilla_box[rules][<?php echo $key; ?>][value]" type="text" value="<?php echo esc_attr( $rule['value'] ); ?>" placeholder="<?php _e( 'Leave empty for any or enter (comma-separated) names or ID\'s', 'boxzilla' ); ?>" style="<?php if( in_array( $rule['condition'], array( '', 'everywhere' ) ) ) { echo 'display: none;'; } ?>" />
69
+ </td>
70
+ </tr>
71
+ <?php $key++;
72
+ } ?>
73
+ </tbody>
74
+ <tr>
75
+ <th></th>
76
+ <td><button type="button" class="button boxzilla-add-rule"><?php _e( 'Add rule', 'boxzilla' ); ?></button></td>
77
+ </tr>
78
+ <tr valign="top">
79
+ <th><label for="boxzilla_position"><?php _e( 'Box Position', 'boxzilla' ); ?></label></th>
80
+ <td>
81
+ <select id="boxzilla_position" name="boxzilla_box[css][position]">
82
+ <?php foreach( $box_positions as $value => $label ) {
83
+ printf( '<option value="%s" %s>%s</option>', $value, selected( $opts['css']['position'], $value ), $label );
84
+ } ?>
85
+ </select>
86
+ </td>
87
+ </tr>
88
+ <tr valign="top">
89
+ <th><label><?php _e( 'Animation', 'boxzilla' ); ?></label></th>
90
+ <td>
91
+ <label><input type="radio" name="boxzilla_box[animation]" value="fade" <?php checked($opts['animation'], 'fade'); ?> /> <?php _e( 'Fade In', 'boxzilla' ); ?></label> &nbsp;
92
+ <label><input type="radio" name="boxzilla_box[animation]" value="slide" <?php checked($opts['animation'], 'slide'); ?> /> <?php _e( 'Slide In', 'boxzilla' ); ?></label>
93
+ <p class="help"><?php _e( 'Which animation type should be used to show the box when triggered?', 'boxzilla' ); ?></p>
94
+ </td>
95
+ </tr>
96
+ <tr valign="top">
97
+ <th><label for="boxzilla_trigger"><?php _e( 'Auto-show box?', 'boxzilla' ); ?></label></th>
98
+ <td>
99
+ <label><input type="radio" class="boxzilla-auto-show-trigger" name="boxzilla_box[trigger]" value="" <?php checked( $opts['trigger'], '' ); ?> /> <?php _e( 'Never', 'boxzilla' ); ?></label><br />
100
+ <label><input type="radio" class="boxzilla-auto-show-trigger" name="boxzilla_box[trigger]" value="time_on_page" <?php checked( $opts['trigger'], 'time_on_page' ); ?> /> <?php printf( __( 'Yes, after %s seconds on the page.', 'boxzilla' ), '<input type="number" name="boxzilla_box[trigger_time_on_page]" min="0" value="' . esc_attr( $opts['trigger_time_on_page'] ) . '" />' ); ?></label><br />
101
+ <label><input type="radio" class="boxzilla-auto-show-trigger" name="boxzilla_box[trigger]" value="percentage" <?php checked( $opts['trigger'], 'percentage' ); ?> /> <?php printf( __( 'Yes, when at %s of page height', 'boxzilla' ), '<input type="number" name="boxzilla_box[trigger_percentage]" min="0" max="100" value="' . esc_attr( $opts['trigger_percentage'] ) . '" />%' ); ?></label><br />
102
+ <label><input type="radio" class="boxzilla-auto-show-trigger" name="boxzilla_box[trigger]" value="element" <?php checked( $opts['trigger'], 'element' ); ?> /> <?php printf( __( 'Yes, when at element %s', 'boxzilla' ), '<input type="text" name="boxzilla_box[trigger_element]" value="' . esc_attr( $opts['trigger_element'] ) . '" placeholder="' . __( 'Example: #comments', 'boxzilla') .'" />' ); ?></label><br />
103
+ <?php do_action( 'boxzilla_output_auto_show_trigger_options', $opts ); ?>
104
+ </td>
105
+ </tr>
106
+ <tbody class="boxzilla-trigger-options" style="display: <?php echo ( $opts['trigger'] === '' ) ? 'none' : 'table-row-group'; ?>;">
107
+ <tr valign="top">
108
+ <th><label for="boxzilla_cookie"><?php _e( 'Cookie expiration days', 'boxzilla' ); ?></label></th>
109
+ <td>
110
+ <input type="number" id="boxzilla_cookie" name="boxzilla_box[cookie]" min="0" step="1" value="<?php echo esc_attr($opts['cookie']); ?>" />
111
+ <p class="help"><?php _e( 'After closing the box, how many days should it stay hidden?', 'boxzilla' ); ?></p>
112
+ </td>
113
+ </tr>
114
+ <tr valign="top">
115
+ <th><label for="boxzilla_hide_on_screen_size"><?php _e( 'Do not auto-show box on small screens?', 'boxzilla' ); ?></label></th>
116
+ <td>
117
+ <p><?php printf( __( 'Do not auto-show on screens smaller than %s.', 'boxzilla' ), '<input type="number" min="0" name="boxzilla_box[hide_on_screen_size]" value="' . esc_attr( $opts['hide_on_screen_size'] ) . '" style="max-width: 70px;" />px' ); ?></p>
118
+ <p class="help"><?php _e( 'Leave empty if you <strong>do</strong> want to auto-show the box on small screens.', 'boxzilla' ); ?></p>
119
+ </td>
120
+
121
+ </tr>
122
+ <tr valign="top">
123
+ <th><label for="boxzilla_auto_hide"><?php _e( 'Auto-hide?', 'boxzilla' ); ?></label></th>
124
+ <td>
125
+ <label><input type="radio" name="boxzilla_box[auto_hide]" value="1" <?php checked( $opts['auto_hide'], 1 ); ?> /> <?php _e( 'Yes' ); ?></label> &nbsp;
126
+ <label><input type="radio" name="boxzilla_box[auto_hide]" value="0" <?php checked( $opts['auto_hide'], 0 ); ?> /> <?php _e( 'No' ); ?></label> &nbsp;
127
+ <p class="help"><?php _e( 'Hide box again when visitors scroll back up?', 'boxzilla' ); ?></p>
128
+ </td>
129
+ </tr>
130
+ <tr valign="top">
131
+ <th><label for="boxzilla_test_mode"><?php _e( 'Enable test mode?', 'boxzilla' ); ?></label></th>
132
+ <td>
133
+ <label><input type="radio" id="boxzilla_test_mode_1" name="boxzilla_global_settings[test_mode]" value="1" <?php checked( $global_opts['test_mode'], 1 ); ?> /> <?php _e( 'Yes' ); ?></label> &nbsp;
134
+ <label><input type="radio" id="boxzilla_test_mode_0" name="boxzilla_global_settings[test_mode]" value="0" <?php checked( $global_opts['test_mode'], 0 ); ?> /> <?php _e( 'No' ); ?></label> &nbsp;
135
+ <p class="help"><?php _e( 'If test mode is enabled, all boxes will show up regardless of whether a cookie has been set.', 'boxzilla' ); ?></p>
136
+ </td>
137
+ </tr>
138
+ <?php do_action( 'boxzilla_after_box_option_controls', $box, $opts ); ?>
139
+ </tbody>
140
+ </table>
141
+
142
+
143
+ <script type="text/html" id="tmpl-rule-row-template">
144
+ <tr valign="top" class="boxzilla-rule-row boxzilla-rule-row-{{{data.key}}}">
145
+ <th style="text-align: right; font-weight: normal;">
146
+ <span class="boxzilla-close boxzilla-remove-rule"><span class="dashicons dashicons-dismiss"></span></span>
147
+ </th>
148
+ <td class="boxzilla-sm">
149
+ <select class="boxzilla-rule-condition" name="boxzilla_box[rules][{{{data.key}}}][condition]">
150
+ <?php foreach( $rule_options as $value => $label ) {
151
+ printf( '<option value="%s" %s %s>%s</option>', $value, disabled( $value, '', false ), '', $label );
152
+ } ?>
153
+ </select>
154
+ <select class="boxzilla-rule-qualifier" name="boxzilla_box[rules][{{{data.key}}}][qualifier]" style="display: none;" >
155
+ <option><?php _e( 'is', 'boxzilla' ); ?></option>
156
+ <option><?php _e( 'is not', 'boxzilla' ); ?></option>
157
+ </select>
158
+
159
+ <input class="boxzilla-rule-value regular-text" name="boxzilla_box[rules][{{{data.key}}}][value]" type="text" value="" placeholder="<?php _e( 'Leave empty for any or enter (comma-separated) names or ID\'s', 'boxzilla' ); ?>" style="display: none;" />
160
+ </td>
161
+ </tr>
162
+ </script>
src/admin/views/metaboxes/email-optin.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ defined( 'ABSPATH' ) or exit;
3
+ $user = wp_get_current_user(); ?>
4
+ <form action="//dannyvankooten.us1.list-manage.com/subscribe/post?u=a2d08947dcd3683512ce174c5&amp;id=e3e1e0f8d8" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
5
+ <p>Get the most out of this plugin by subscribing to our monthly tips on how to increase your conversion rate.</p>
6
+ <p class="mc-field-group">
7
+ <label for="mce-EMAIL">Email Address <span style="color: red;">*</span></label>
8
+ <input type="email" value="<?php echo esc_attr( $user->user_email ); ?>" name="EMAIL" class="widefat" id="mce-EMAIL">
9
+ </p>
10
+ <p class="mc-field-group">
11
+ <label for="mce-FNAME">First Name </label>
12
+ <input type="text" value="<?php echo esc_attr( $user->user_firstname ); ?>" name="FNAME" class="widefat" id="mce-FNAME">
13
+ </p>
14
+ <div id="mce-responses" class="clear">
15
+ <div class="response" id="mce-error-response" style="display:none"></div>
16
+ <div class="response" id="mce-success-response" style="display:none"></div>
17
+ </div> <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
18
+ <div style="position: absolute; left: -5000px;"><input type="text" name="b_a2d08947dcd3683512ce174c5_e3e1e0f8d8" tabindex="-1" value=""></div>
19
+ <div class="clear"><input type="submit" value="Subscribe" name="subscribe" class="button button-primary"></div>
20
+
21
+ <p class="help" style="margin-bottom: 0;"><small>No spam, unsubscribe at any time.</small></p>
22
+ </form>
src/admin/views/metaboxes/need-help.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <p>Make sure to look at the <a href="https://kb.boxzillaplugin.com/">online documentation</a>, the <a href="https://wordpress.org/plugins/boxzilla/faq/">frequently asked questions</a> or <a href="https://wordpress.org/support/plugin/boxzilla">use the support forums on WordPress.org</a>.</p>
3
+
src/admin/views/settings.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <div class="wrap" id="boxzilla-admin" class="boxzilla-settings">
3
+
4
+ <div class="boxzilla-row">
5
+ <div class="boxzilla-col-two-third">
6
+
7
+ <h2><?php _e( 'Settings', 'boxzilla' ); ?></h2>
8
+
9
+ <?php do_action( 'boxzilla_before_settings' ); ?>
10
+
11
+ <form action="<?php echo admin_url( 'options.php' ); ?>" method="post">
12
+
13
+ <?php settings_fields( 'boxzilla_settings' ); ?>
14
+
15
+ <table class="form-table">
16
+
17
+ <?php do_action( 'boxzilla_before_settings_rows' ); ?>
18
+
19
+ <tr valign="top">
20
+ <th><label for="boxzilla_test_mode"><?php _e( 'Enable test mode?', 'boxzilla' ); ?></label></th>
21
+ <td>
22
+ <label><input type="radio" id="boxzilla_test_mode_1" name="boxzilla_settings[test_mode]" value="1" <?php checked( $opts['test_mode'], 1 ); ?> /> <?php _e( 'Yes' ); ?></label> &nbsp;
23
+ <label><input type="radio" id="boxzilla_test_mode_0" name="boxzilla_settings[test_mode]" value="0" <?php checked( $opts['test_mode'], 0 ); ?> /> <?php _e( 'No' ); ?></label> &nbsp;
24
+ <p class="help"><?php _e( 'If test mode is enabled, all boxes will show up regardless of whether a cookie has been set.', 'boxzilla' ); ?></p>
25
+ </td>
26
+ </tr>
27
+
28
+ <?php do_action( 'boxzilla_after_settings_rows' ); ?>
29
+ </table>
30
+
31
+ <?php submit_button(); ?>
32
+ </form>
33
+
34
+ <?php do_action( 'boxzilla_after_settings' ); ?>
35
+ </div>
36
+
37
+ <div class="boxzilla-sidebar boxzilla-col-one-third">
38
+
39
+ <!-- Begin MailChimp Signup Form -->
40
+ <div class="boxzilla-box">
41
+ <h3>Subscribe to our mailing list</h3>
42
+ <?php include __DIR__ . '/metaboxes/email-optin.php'; ?>
43
+ </div>
44
+ <!--End mc_embed_signup-->
45
+
46
+ <div class="boxzilla-box">
47
+ <h3>Looking for help?</h3>
48
+ <?php include __DIR__ . '/metaboxes/need-help.php'; ?>
49
+ </div>
50
+
51
+ </div>
52
+ </div>
53
+
54
+ <br style="clear: both;" />
55
+
56
+ </div>
src/class-box.php ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla;
4
+
5
+ use WP_Post;
6
+
7
+ class Box {
8
+
9
+ /**
10
+ * @var int
11
+ */
12
+ public $ID;
13
+
14
+ /**
15
+ * @var array
16
+ */
17
+ public $options = array();
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ public $title = '';
23
+
24
+ /**
25
+ * @var string
26
+ */
27
+ protected $content = '';
28
+
29
+ /**
30
+ * @var bool
31
+ */
32
+ public $enabled = false;
33
+
34
+ /**
35
+ * @param WP_Post|int $post
36
+ */
37
+ public function __construct( $post ) {
38
+
39
+ // fetch post if it hasn't been fetched yet
40
+ if( ! $post instanceof WP_Post ) {
41
+ $post = get_post( $post );
42
+ }
43
+
44
+ // store ID in property for quick access
45
+ $this->ID = $post->ID;
46
+
47
+ // store title in property
48
+ $this->title = $post->post_title;
49
+
50
+ // store content in property
51
+ $this->content = $post->post_content;
52
+
53
+ // is this box enabled?
54
+ $this->enabled = ( $post->post_status === 'publish' );
55
+
56
+ // load and store options in property
57
+ $this->options = $this->load_options();
58
+ }
59
+
60
+ /**
61
+ * Get the options for this box.
62
+ **
63
+ * @return array Array of box options
64
+ */
65
+ protected function load_options() {
66
+
67
+ static $defaults = array(
68
+ 'css' => array(
69
+ 'background_color' => '',
70
+ 'color' => '',
71
+ 'width' => '',
72
+ 'border_color' => '',
73
+ 'border_width' => '',
74
+ 'border_style' => '',
75
+ 'position' => 'bottom-right',
76
+ ),
77
+ 'rules' => array(
78
+ 0 => array('condition' => '', 'value' => '')
79
+ ),
80
+ 'rules_comparision' => 'any',
81
+ 'cookie' => 0,
82
+ 'trigger' => 'percentage',
83
+ 'trigger_percentage' => 65,
84
+ 'trigger_element' => '',
85
+ 'trigger_time_on_site' => 0,
86
+ 'trigger_time_on_page' => 0,
87
+ 'animation' => 'fade',
88
+ 'auto_hide' => 0,
89
+ 'hide_on_screen_size' => '',
90
+ 'closable' => true,
91
+ );
92
+ $box = $this;
93
+
94
+ $options = get_post_meta( $this->ID, 'boxzilla_options', true );
95
+ $options = is_array( $options ) ? $options : array();
96
+
97
+ // merge options with default options
98
+ $options = array_replace_recursive( $defaults, $options );
99
+
100
+ // allow others to filter the final array of options
101
+ /**
102
+ * Filter the options for a given box
103
+ *
104
+ * @param array $options
105
+ * @param Box $box
106
+ */
107
+ $options = apply_filters( 'boxzilla_box_options', $options, $box );
108
+
109
+ return $options;
110
+ }
111
+
112
+ /**
113
+ * @return bool
114
+ */
115
+ public function is_enabled() {
116
+ return $this->enabled;
117
+ }
118
+
119
+ /**
120
+ * Get the options for this box
121
+ *
122
+ * @return array
123
+ */
124
+ public function get_options() {
125
+ return $this->options;
126
+ }
127
+
128
+ /**
129
+ * Get the close / hide icon for this box
130
+ *
131
+ * @return string
132
+ */
133
+ public function get_close_icon() {
134
+
135
+ $box = $this;
136
+ $html = '&times;';
137
+
138
+ /**
139
+ * Filters the HTML for the close icon.
140
+ *
141
+ * @param string $html
142
+ * @param Box $box
143
+ */
144
+ $close_icon = (string) apply_filters( 'boxzilla_box_close_icon', $html, $box );
145
+
146
+ return $close_icon;
147
+ }
148
+
149
+ /**
150
+ * Get the content of this box
151
+ *
152
+ * @return mixed|void
153
+ */
154
+ public function get_content() {
155
+ $content = $this->content;
156
+ $box = $this;
157
+
158
+ /**
159
+ * Filters the HTML for the box content
160
+ *
161
+ * @param string $content
162
+ * @param Box $box
163
+ */
164
+ $content = apply_filters( 'boxzilla_box_content', $content, $box );
165
+ return $content;
166
+ }
167
+
168
+ /**
169
+ * Get the minimum allowed screen size for this box
170
+ *
171
+ * @return int
172
+ */
173
+ public function get_minimum_screen_size() {
174
+
175
+ if( $this->options['hide_on_screen_size'] > 0 ) {
176
+ $minimum_screen_size = absint( $this->options['hide_on_screen_size'] );
177
+ } else {
178
+ $minimum_screen_size = 0;
179
+ }
180
+
181
+ return $minimum_screen_size;
182
+ }
183
+
184
+ public function get_client_options() {
185
+ $box = $this;
186
+
187
+ $trigger = false;
188
+ if( $box->options['trigger'] ) {
189
+
190
+ $trigger = array( 'method' => $this->options['trigger'] );
191
+
192
+ if( isset( $this->options[ 'trigger_' . $this->options['trigger'] ] ) ) {
193
+ $trigger['value'] = $this->options[ 'trigger_' . $this->options['trigger'] ];
194
+ }
195
+ }
196
+
197
+ $client_options = array(
198
+ 'id' => $box->ID,
199
+ 'icon' => $box->get_close_icon(),
200
+ 'content' => $box->get_content(),
201
+ 'css' => array_filter( $box->options['css'] ),
202
+ 'trigger' => $trigger,
203
+ 'animation' => $box->options['animation'],
204
+ 'cookieTime' => absint( $box->options['cookie'] ),
205
+ 'rehide' => (bool) $box->options['auto_hide'],
206
+ 'position' => $box->options['css']['position'],
207
+ 'minimumScreenWidth' => $box->get_minimum_screen_size(),
208
+ 'closable' => $box->options['closable'],
209
+ );
210
+
211
+ /**
212
+ * Filter the final options for the JS Boxzilla client.
213
+ *
214
+ * @param array $client_options
215
+ * @param Box $box
216
+ */
217
+ $client_options = apply_filters( 'boxzilla_box_client_options', $client_options, $box );
218
+
219
+ return $client_options;
220
+ }
221
+
222
+ }
src/class-boxzilla-service-provider.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla;
4
+
5
+ use Boxzilla\Admin\Admin;
6
+ use Boxzilla\Admin\Notices;
7
+ use Boxzilla\DI\Container;
8
+ use Boxzilla\DI\ServiceProviderInterface;
9
+
10
+ class BoxzillaServiceProvider implements ServiceProviderInterface {
11
+
12
+ /**
13
+ * Registers services on the given container.
14
+ *
15
+ * This method should only be used to configure services and parameters.
16
+ * It should not get services.
17
+ *
18
+ * @param Container $container An Container instance
19
+ */
20
+ public function register( Container $container ) {
21
+
22
+ $container['plugin'] = new Plugin(
23
+ 0,
24
+ 'Boxzilla',
25
+ BOXZILLA_VERSION,
26
+ BOXZILLA_FILE,
27
+ dirname( BOXZILLA_FILE )
28
+ );
29
+
30
+ $container['options'] = function( $container ) {
31
+ $defaults = array(
32
+ 'test_mode' => 0
33
+ );
34
+
35
+ $options = (array) get_option( 'boxzilla_settings', $defaults );
36
+ $options = array_merge( $defaults, $options );
37
+ return $options;
38
+ };
39
+
40
+ $container['plugins'] = function( $container ) {
41
+ $plugins = (array) apply_filters( 'boxzilla_extensions', array() );
42
+ return new Collection( $plugins );
43
+ };
44
+
45
+ $container['box_loader'] = function( $container ) {
46
+ return new BoxLoader( $container->plugin, $container->options );
47
+ };
48
+
49
+ $container['admin'] = function( $container ) {
50
+ return new Admin( $container->plugin, $container );
51
+ };
52
+
53
+ $container['filter.autocomplete'] = function( $container ) {
54
+ return new Filter\Autocomplete();
55
+ };
56
+
57
+ $container['notices'] = function( $container ) {
58
+ return new Notices();
59
+ };
60
+ }
61
+ }
src/class-boxzilla.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla;
4
+
5
+ use Boxzilla\DI\ContainerWithPropertyAccess;
6
+
7
+ /**
8
+ * Class Boxzilla
9
+ *
10
+ * @package Boxzilla
11
+ *
12
+ * @property array $options
13
+ * @property Plugin $plugin
14
+ * @property Plugin[] $plugins
15
+ */
16
+ class Boxzilla extends ContainerWithPropertyAccess {}
src/class-collection.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla;
4
+
5
+ use Iterator;
6
+ use Countable;
7
+
8
+ class Collection implements Iterator, Countable {
9
+
10
+ protected $elements = array();
11
+ private $position = 0;
12
+
13
+ public function __construct( array $elements ) {
14
+ $this->elements = $elements;
15
+ $this->position = 0;
16
+ }
17
+
18
+ function rewind() {
19
+ $this->position = 0;
20
+ }
21
+
22
+ function current() {
23
+ return $this->elements[ $this->position ];
24
+ }
25
+
26
+ function key() {
27
+ return $this->position;
28
+ }
29
+
30
+ function next() {
31
+ ++$this->position;
32
+ }
33
+
34
+ function valid() {
35
+ return isset( $this->elements[ $this->position ] );
36
+ }
37
+
38
+ /**
39
+ * @param $callback
40
+ *
41
+ * @return array
42
+ */
43
+ function map($callback) {
44
+ $result = array();
45
+
46
+ foreach( $this->elements as $element ) {
47
+ $result[] = $callback( $element );
48
+ }
49
+
50
+ return $result;
51
+ }
52
+
53
+ /**
54
+ * @param $callback
55
+ *
56
+ * @return null
57
+ */
58
+ function find($callback) {
59
+
60
+ foreach( $this->elements as $element ) {
61
+ if( $callback( $element ) ) {
62
+ return $element;
63
+ }
64
+ }
65
+
66
+ return null;
67
+ }
68
+
69
+ /**
70
+ * (PHP 5 &gt;= 5.1.0)<br/>
71
+ * Count elements of an object
72
+ * @link http://php.net/manual/en/countable.count.php
73
+ * @return int The custom count as an integer.
74
+ * </p>
75
+ * <p>
76
+ * The return value is cast to an integer.
77
+ */
78
+ public function count() {
79
+ return count( $this->elements );
80
+ }
81
+ }
src/class-loader.php ADDED
@@ -0,0 +1,293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla;
4
+
5
+ class BoxLoader {
6
+
7
+ /**
8
+ * @var Plugin
9
+ */
10
+ private $plugin;
11
+
12
+ /**
13
+ * @var array
14
+ */
15
+ private $box_ids_to_load = array();
16
+
17
+ /**
18
+ * @var array
19
+ */
20
+ protected $options;
21
+
22
+ /**
23
+ * Constructor
24
+ *
25
+ * @param Plugin $plugin
26
+ * @param array $options
27
+ */
28
+ public function __construct( Plugin $plugin, array $options ) {
29
+ $this->plugin = $plugin;
30
+ $this->options = $options;
31
+ }
32
+
33
+ /**
34
+ * Initializes the plugin, runs on `wp` hook.
35
+ */
36
+ public function init() {
37
+
38
+ $this->box_ids_to_load = $this->filter_boxes();
39
+
40
+ // Only add other hooks if necessary
41
+ if( count( $this->box_ids_to_load ) > 0 ) {
42
+ add_action( 'wp_enqueue_scripts', array( $this, 'load_assets' ), 90 );
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Get global rules for all boxes
48
+ *
49
+ * @return array
50
+ */
51
+ protected function get_filter_rules() {
52
+ $rules = get_option( 'boxzilla_rules', array() );
53
+
54
+ if( ! is_array( $rules ) ) {
55
+ return array();
56
+ }
57
+
58
+ return $rules;
59
+ }
60
+
61
+
62
+ /**
63
+ * Match a string against an array of patterns, glob-style.
64
+ *
65
+ * @param string $string
66
+ * @param array $patterns
67
+ *
68
+ * @return boolean
69
+ */
70
+ protected function match_patterns( $string, $patterns ) {
71
+ $string = strtolower( $string );
72
+
73
+ foreach( $patterns as $pattern ) {
74
+
75
+ $pattern = strtolower( $pattern );
76
+
77
+ if( function_exists( 'fnmatch' ) ) {
78
+ $match = fnmatch( $pattern, $string );
79
+ } else {
80
+ $match = ( $pattern === $string );
81
+ }
82
+
83
+ if( $match ) {
84
+ return true;
85
+ }
86
+ }
87
+
88
+ return false;
89
+ }
90
+
91
+ /**
92
+ * Check if this rule passes (conditional matches expected value)
93
+ *
94
+ * @param string $condition
95
+ * @param string $value
96
+ * @param boolean $qualifier
97
+ *
98
+ * @return bool
99
+ */
100
+ protected function match_rule( $condition, $value, $qualifier = true ) {
101
+
102
+ $matched = false;
103
+
104
+ // cast value to array & trim whitespace or excess comma's
105
+ $value = array_map( 'trim', explode( ',', rtrim( trim( $value ), ',' ) ) );
106
+
107
+ switch ( $condition ) {
108
+ case 'everywhere';
109
+ $matched = true;
110
+ break;
111
+
112
+ case 'is_url':
113
+ $matched = $this->match_patterns( $_SERVER['REQUEST_URI'], $value );
114
+ break;
115
+
116
+ case 'is_referer':
117
+ if( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
118
+ $referer = $_SERVER['HTTP_REFERER'];
119
+ $matched = $this->match_patterns( $referer, $value );
120
+ }
121
+ break;
122
+
123
+ case 'is_post_type':
124
+ $post_type = (string) get_post_type();
125
+ $matched = in_array( $post_type, (array) $value );
126
+ break;
127
+
128
+ case 'is_single':
129
+ case 'is_post':
130
+ $matched = is_single( $value );
131
+ break;
132
+
133
+ case 'is_post_in_category':
134
+ $matched = is_singular( 'post' ) && has_category( $value );
135
+ break;
136
+
137
+
138
+ case 'is_page':
139
+ $matched = is_page( $value );
140
+ break;
141
+
142
+ }
143
+
144
+ // if qualifier is set to false, we need to reverse this value here.
145
+ if( ! $qualifier ) {
146
+ $matched = ! $matched;
147
+ }
148
+
149
+ return $matched;
150
+ }
151
+
152
+ /**
153
+ * Checks which boxes should be loaded for this request.
154
+ *
155
+ * @return array
156
+ */
157
+ private function filter_boxes() {
158
+
159
+ $box_ids_to_load = array();
160
+ $rules = $this->get_filter_rules();
161
+
162
+ foreach( $rules as $box_id => $box_rules ) {
163
+
164
+ $matched = false;
165
+ $comparision = isset( $box_rules['comparision'] ) ? $box_rules['comparision'] : 'any';
166
+
167
+ // loop through all rules for all boxes
168
+ foreach ( $box_rules as $rule ) {
169
+
170
+ // skip faulty values (and comparision rule)
171
+ if( empty( $rule['condition'] ) ) {
172
+ continue;
173
+ }
174
+
175
+ $qualifier = isset( $rule['qualifier'] ) ? $rule['qualifier'] : true;
176
+ $matched = $this->match_rule( $rule['condition'], $rule['value'], $qualifier );
177
+
178
+ // break out of loop if we've already matched
179
+ if( $comparision === 'any' && $matched ) {
180
+ break;
181
+ }
182
+
183
+ // no need to continue if this rule didn't match
184
+ if( $comparision === 'all' && ! $matched ) {
185
+ break;
186
+ }
187
+ }
188
+
189
+ // value of $matched at this point determines whether box should be loaded
190
+ $load_box = $matched;
191
+
192
+ /**
193
+ * Filters whether a box should be loaded into the page HTML.
194
+ *
195
+ * The dynamic portion of the hook, `$box_id`, refers to the ID of the box. Return true if you want to output the box.
196
+ *
197
+ * @param boolean $load_box
198
+ */
199
+ $load_box = apply_filters( 'boxzilla_load_box_' . $box_id, $load_box );
200
+
201
+ /**
202
+ * Filters whether a box should be loaded into the page HTML.
203
+ *
204
+ * @param boolean $load_box
205
+ * @param int $box_id
206
+ */
207
+ $load_box = apply_filters( 'boxzilla_load_box', $load_box, $box_id );
208
+
209
+ // if matched, box should be loaded on this page
210
+ if ( $load_box ) {
211
+ $box_ids_to_load[] = $box_id;
212
+ }
213
+
214
+ }
215
+
216
+ return $box_ids_to_load;
217
+ }
218
+
219
+ /**
220
+ * Load plugin styles
221
+ */
222
+ public function load_assets() {
223
+ $pre_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
224
+
225
+ // stylesheets
226
+ wp_register_style( 'boxzilla', $this->plugin->url( '/assets/css/styles' . $pre_suffix . '.css' ), array(), $this->plugin->version() );
227
+
228
+ // scripts
229
+ wp_register_script( 'boxzilla',$this->plugin->url( '/assets/js/script' . $pre_suffix . '.js' ), array( 'jquery' ), $this->plugin->version(), true );
230
+
231
+ // Finally, enqueue style.
232
+ wp_enqueue_style( 'boxzilla' );
233
+ wp_enqueue_script( 'boxzilla' );
234
+
235
+ $this->pass_box_options();
236
+
237
+ do_action( 'boxzilla_load_assets', $this );
238
+ }
239
+
240
+ /**
241
+ * Get an array of Box objects. These are the boxes that will be loaded for the current request.
242
+ *
243
+ * @return Box[]
244
+ */
245
+ public function get_matched_boxes() {
246
+ static $boxes;
247
+
248
+ if( is_null( $boxes ) ) {
249
+
250
+ if( count( $this->box_ids_to_load ) === 0 ) {
251
+ $boxes = array();
252
+ return $boxes;
253
+ }
254
+
255
+ // query Box posts
256
+ $boxes = get_posts(
257
+ array(
258
+ 'post_type' => 'boxzilla-box',
259
+ 'post_status' => 'publish',
260
+ 'post__in' => $this->box_ids_to_load,
261
+ 'numberposts' => -1
262
+ )
263
+ );
264
+
265
+ // create `Box` instances out of \WP_Post instances
266
+ foreach ( $boxes as $key => $box ) {
267
+ $boxes[ $key ] = new Box( $box );
268
+ }
269
+ }
270
+
271
+ return $boxes;
272
+ }
273
+
274
+ /**
275
+ * Create array of Box options and pass it to JavaScript script.
276
+ */
277
+ public function pass_box_options() {
278
+
279
+ // create boxzilla_Global_Options object
280
+ $plugin_options = $this->options;
281
+ $boxes = $this->get_matched_boxes();
282
+
283
+ $data = array(
284
+ 'testMode' => (boolean) $plugin_options['test_mode'],
285
+ 'boxes' => array_map( function(Box $box) { return $box->get_client_options(); }, $boxes ),
286
+ );
287
+
288
+ wp_localize_script( 'boxzilla', 'boxzilla_options', $data );
289
+ }
290
+
291
+ }
292
+
293
+
src/class-php-fallback.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Boxzilla_PHP_Fallback {
4
+
5
+ /**
6
+ * @var string
7
+ */
8
+ private $plugin_name = '';
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $plugin_file = '';
14
+
15
+ /**
16
+ * @param $plugin_name
17
+ * @param $plugin_file
18
+ */
19
+ public function __construct( $plugin_name, $plugin_file ) {
20
+
21
+ $this->plugin_name = $plugin_name;
22
+ $this->plugin_file = $plugin_file;
23
+
24
+ // deactivate plugin straight away
25
+ add_action( 'admin_init', array( $this, 'deactivate_self' ) );
26
+ }
27
+
28
+ /**
29
+ * @return bool
30
+ */
31
+ public function deactivate_self() {
32
+ if( ! current_user_can( 'activate_plugins' ) ) {
33
+ return false;
34
+ }
35
+
36
+ // deactivate self
37
+ deactivate_plugins( $this->plugin_file );
38
+
39
+ // get rid of "Plugin activated" notice
40
+ if( isset( $_GET['activate'] ) ) {
41
+ unset( $_GET['activate'] );
42
+ }
43
+
44
+ // show notice to user
45
+ add_action( 'admin_notices', array( $this, 'show_notice' ) );
46
+
47
+ return true;
48
+ }
49
+
50
+ /**
51
+ * @return void
52
+ */
53
+ public function show_notice() {
54
+ ?>
55
+ <div class="updated">
56
+ <p><?php printf( '<strong>%s</strong> did not activate because it requires <strong>PHP v5.3</strong> or higher, while your server is running <strong>PHP v%s</strong>.', $this->plugin_name, PHP_VERSION ); ?>
57
+ <p><?php printf( '<a href="%s">Updating your PHP version</a> makes your site faster, more secure and should be easy for your host.', 'http://www.wpupdatephp.com/update/#utm_source=wp-plugin&utm_medium=boxzillas&utm_campaign=activation-notice' ); ?></p>
58
+ </div>
59
+ <?php
60
+ }
61
+
62
+ }
src/class-plugin.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla;
4
+
5
+ class Plugin {
6
+
7
+ /**
8
+ * @var string The current version of the plugin
9
+ */
10
+ protected $version = '1.0';
11
+
12
+ /**
13
+ * @var string
14
+ */
15
+ protected $file = '';
16
+
17
+ /**
18
+ * @var string
19
+ */
20
+ protected $dir = '';
21
+
22
+ /**
23
+ * @var string
24
+ */
25
+ protected $name = '';
26
+
27
+ /**
28
+ * @var string
29
+ */
30
+ protected $slug = '';
31
+
32
+ /**
33
+ * @var int
34
+ */
35
+ protected $id = 0;
36
+
37
+ /**
38
+ * Constructor
39
+ *
40
+ * @param int $id
41
+ * @param string $name
42
+ * @param string $version
43
+ * @param string $file
44
+ * @param string $dir (optional)
45
+ */
46
+ public function __construct( $id, $name, $version, $file, $dir = '' ) {
47
+ $this->id = $id;
48
+ $this->name = $name;
49
+ $this->version = $version;
50
+ $this->file = $file;
51
+ $this->dir = $dir;
52
+ $this->slug = plugin_basename( $file );
53
+
54
+ if( empty( $dir ) ) {
55
+ $this->dir = dirname( $file );
56
+ }
57
+ }
58
+
59
+ /**
60
+ * @return int
61
+ */
62
+ public function id() {
63
+ return $this->id;
64
+ }
65
+
66
+ /**
67
+ * @return string
68
+ */
69
+ public function slug() {
70
+ return $this->slug;
71
+ }
72
+
73
+ /**
74
+ * @return string
75
+ */
76
+ public function name() {
77
+ return $this->name;
78
+ }
79
+
80
+ /**
81
+ * @return string
82
+ */
83
+ public function version() {
84
+ return $this->version;
85
+ }
86
+
87
+ /**
88
+ * @return string
89
+ */
90
+ public function file() {
91
+ return $this->file;
92
+ }
93
+
94
+ /**
95
+ * @return string
96
+ */
97
+ public function dir() {
98
+ return $this->dir;
99
+ }
100
+
101
+ /**
102
+ * @param string $path
103
+ *
104
+ * @return mixed
105
+ */
106
+ public function url( $path = '' ) {
107
+ return plugins_url( $path, $this->file() );
108
+ }
109
+ }
src/default-filters.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ defined( 'ABSPATH' ) or exit;
4
+
5
+ add_filter( 'boxzilla_box_content', 'wptexturize') ;
6
+ add_filter( 'boxzilla_box_content', 'convert_smilies' );
7
+ add_filter( 'boxzilla_box_content', 'convert_chars' );
8
+ add_filter( 'boxzilla_box_content', 'wpautop' );
9
+ add_filter( 'boxzilla_box_content', 'shortcode_unautop' );
10
+ add_filter( 'boxzilla_box_content', 'do_shortcode', 11 );
src/di/class-container-with-property-access.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla\DI;
4
+
5
+ class ContainerWithPropertyAccess extends Container {
6
+
7
+ /**
8
+ * @param string $name
9
+ * @return mixed
10
+ */
11
+ public function __get( $name ) {
12
+ return $this[ $name ];
13
+ }
14
+
15
+ /**
16
+ * @param string $name
17
+ * @param mixed $value
18
+ */
19
+ public function __set( $name, $value ) {
20
+ $this[ $name ] = $value;
21
+ }
22
+
23
+ }
src/di/class-container.php ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Pimple.
5
+ *
6
+ * Copyright (c) 2009 Fabien Potencier
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is furnished
13
+ * to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ * THE SOFTWARE.
25
+ */
26
+
27
+ namespace Boxzilla\DI;
28
+
29
+ /**
30
+ * Container main class.
31
+ *
32
+ * @author Fabien Potencier
33
+ */
34
+ class Container implements \ArrayAccess
35
+ {
36
+ private $values = array();
37
+ private $factories;
38
+ private $protected;
39
+ private $frozen = array();
40
+ private $raw = array();
41
+ private $keys = array();
42
+
43
+ /**
44
+ * Instantiate the container.
45
+ *
46
+ * Objects and parameters can be passed as argument to the constructor.
47
+ *
48
+ * @param array $values The parameters or objects.
49
+ */
50
+ public function __construct(array $values = array())
51
+ {
52
+ $this->factories = new \SplObjectStorage();
53
+ $this->protected = new \SplObjectStorage();
54
+
55
+ foreach ($values as $key => $value) {
56
+ $this->offsetSet($key, $value);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Sets a parameter or an object.
62
+ *
63
+ * Objects must be defined as Closures.
64
+ *
65
+ * Allowing any PHP callable leads to difficult to debug problems
66
+ * as function names (strings) are callable (creating a function with
67
+ * the same name as an existing parameter would break your container).
68
+ *
69
+ * @param string $id The unique identifier for the parameter or object
70
+ * @param mixed $value The value of the parameter or a closure to define an object
71
+ * @throws \RuntimeException Prevent override of a frozen service
72
+ */
73
+ public function offsetSet($id, $value)
74
+ {
75
+ if (isset($this->frozen[$id])) {
76
+ throw new \RuntimeException(sprintf('Cannot override frozen service "%s".', $id));
77
+ }
78
+
79
+ $this->values[$id] = $value;
80
+ $this->keys[$id] = true;
81
+ }
82
+
83
+ /**
84
+ * Gets a parameter or an object.
85
+ *
86
+ * @param string $id The unique identifier for the parameter or object
87
+ *
88
+ * @return mixed The value of the parameter or an object
89
+ *
90
+ * @throws \InvalidArgumentException if the identifier is not defined
91
+ */
92
+ public function offsetGet($id)
93
+ {
94
+ if (!isset($this->keys[$id])) {
95
+ throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
96
+ }
97
+
98
+ if (
99
+ isset($this->raw[$id])
100
+ || !is_object($this->values[$id])
101
+ || isset($this->protected[$this->values[$id]])
102
+ || !method_exists($this->values[$id], '__invoke')
103
+ ) {
104
+ return $this->values[$id];
105
+ }
106
+
107
+ if (isset($this->factories[$this->values[$id]])) {
108
+ return $this->values[$id]($this);
109
+ }
110
+
111
+ $raw = $this->values[$id];
112
+ $val = $this->values[$id] = $raw($this);
113
+ $this->raw[$id] = $raw;
114
+
115
+ $this->frozen[$id] = true;
116
+
117
+ return $val;
118
+ }
119
+
120
+ /**
121
+ * Checks if a parameter or an object is set.
122
+ *
123
+ * @param string $id The unique identifier for the parameter or object
124
+ *
125
+ * @return bool
126
+ */
127
+ public function offsetExists($id)
128
+ {
129
+ return isset($this->keys[$id]);
130
+ }
131
+
132
+ /**
133
+ * Unsets a parameter or an object.
134
+ *
135
+ * @param string $id The unique identifier for the parameter or object
136
+ */
137
+ public function offsetUnset($id)
138
+ {
139
+ if (isset($this->keys[$id])) {
140
+ if (is_object($this->values[$id])) {
141
+ unset($this->factories[$this->values[$id]], $this->protected[$this->values[$id]]);
142
+ }
143
+
144
+ unset($this->values[$id], $this->frozen[$id], $this->raw[$id], $this->keys[$id]);
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Marks a callable as being a factory service.
150
+ *
151
+ * @param callable $callable A service definition to be used as a factory
152
+ *
153
+ * @return callable The passed callable
154
+ *
155
+ * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object
156
+ */
157
+ public function factory($callable)
158
+ {
159
+ if (!is_object($callable) || !method_exists($callable, '__invoke')) {
160
+ throw new \InvalidArgumentException('Service definition is not a Closure or invokable object.');
161
+ }
162
+
163
+ $this->factories->attach($callable);
164
+
165
+ return $callable;
166
+ }
167
+
168
+ /**
169
+ * Protects a callable from being interpreted as a service.
170
+ *
171
+ * This is useful when you want to store a callable as a parameter.
172
+ *
173
+ * @param callable $callable A callable to protect from being evaluated
174
+ *
175
+ * @return callable The passed callable
176
+ *
177
+ * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object
178
+ */
179
+ public function protect($callable)
180
+ {
181
+ if (!is_object($callable) || !method_exists($callable, '__invoke')) {
182
+ throw new \InvalidArgumentException('Callable is not a Closure or invokable object.');
183
+ }
184
+
185
+ $this->protected->attach($callable);
186
+
187
+ return $callable;
188
+ }
189
+
190
+ /**
191
+ * Gets a parameter or the closure defining an object.
192
+ *
193
+ * @param string $id The unique identifier for the parameter or object
194
+ *
195
+ * @return mixed The value of the parameter or the closure defining an object
196
+ *
197
+ * @throws \InvalidArgumentException if the identifier is not defined
198
+ */
199
+ public function raw($id)
200
+ {
201
+ if (!isset($this->keys[$id])) {
202
+ throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
203
+ }
204
+
205
+ if (isset($this->raw[$id])) {
206
+ return $this->raw[$id];
207
+ }
208
+
209
+ return $this->values[$id];
210
+ }
211
+
212
+ /**
213
+ * Extends an object definition.
214
+ *
215
+ * Useful when you want to extend an existing object definition,
216
+ * without necessarily loading that object.
217
+ *
218
+ * @param string $id The unique identifier for the object
219
+ * @param callable $callable A service definition to extend the original
220
+ *
221
+ * @return callable The wrapped callable
222
+ *
223
+ * @throws \InvalidArgumentException if the identifier is not defined or not a service definition
224
+ */
225
+ public function extend($id, $callable)
226
+ {
227
+ if (!isset($this->keys[$id])) {
228
+ throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
229
+ }
230
+
231
+ if (!is_object($this->values[$id]) || !method_exists($this->values[$id], '__invoke')) {
232
+ throw new \InvalidArgumentException(sprintf('Identifier "%s" does not contain an object definition.', $id));
233
+ }
234
+
235
+ if (!is_object($callable) || !method_exists($callable, '__invoke')) {
236
+ throw new \InvalidArgumentException('Extension service definition is not a Closure or invokable object.');
237
+ }
238
+
239
+ $factory = $this->values[$id];
240
+
241
+ $extended = function ($c) use ($callable, $factory) {
242
+ return $callable($factory($c), $c);
243
+ };
244
+
245
+ if (isset($this->factories[$factory])) {
246
+ $this->factories->detach($factory);
247
+ $this->factories->attach($extended);
248
+ }
249
+
250
+ return $this[$id] = $extended;
251
+ }
252
+
253
+ /**
254
+ * Returns all defined value names.
255
+ *
256
+ * @return array An array of value names
257
+ */
258
+ public function keys()
259
+ {
260
+ return array_keys($this->values);
261
+ }
262
+
263
+ /**
264
+ * Registers a service provider.
265
+ *
266
+ * @param ServiceProviderInterface $provider A ServiceProviderInterface instance
267
+ * @param array $values An array of values that customizes the provider
268
+ *
269
+ * @return static
270
+ */
271
+ public function register(ServiceProviderInterface $provider, array $values = array())
272
+ {
273
+ $provider->register($this);
274
+
275
+ foreach ($values as $key => $value) {
276
+ $this[$key] = $value;
277
+ }
278
+
279
+ return $this;
280
+ }
281
+ }
src/di/interface-service-provider.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Pimple.
5
+ *
6
+ * Copyright (c) 2009 Fabien Potencier
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is furnished
13
+ * to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ * THE SOFTWARE.
25
+ */
26
+
27
+ namespace Boxzilla\DI;
28
+
29
+ /**
30
+ * Pimple service provider interface.
31
+ *
32
+ * @author Fabien Potencier
33
+ * @author Dominik Zogg
34
+ */
35
+ interface ServiceProviderInterface
36
+ {
37
+ /**
38
+ * Registers services on the given container.
39
+ *
40
+ * This method should only be used to configure services and parameters.
41
+ * It should not get services.
42
+ *
43
+ * @param Container $container A Container instance
44
+ */
45
+ public function register(Container $container);
46
+ }
src/functions.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use Boxzilla\Boxzilla;
4
+
5
+ /**
6
+ * @return Boxzilla
7
+ */
8
+ function boxzilla() {
9
+ static $instance;
10
+
11
+ if( is_null( $instance ) ) {
12
+ $instance = new Boxzilla();
13
+ }
14
+
15
+ return $instance;
16
+ }
src/licensing/class-api.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla\Licensing;
4
+
5
+ use Boxzilla\Admin\Notices;
6
+ use Boxzilla\Plugin;
7
+ use WP_Error;
8
+
9
+ class API {
10
+
11
+ /**
12
+ * @var License
13
+ */
14
+ protected $license;
15
+
16
+ /**
17
+ * @var Notices
18
+ */
19
+ protected $notices;
20
+
21
+ /**
22
+ * @var string
23
+ */
24
+ protected $api_url = '';
25
+
26
+ /**
27
+ * @var int
28
+ */
29
+ protected $error_code = 0;
30
+
31
+ /**
32
+ * @var string
33
+ */
34
+ protected $error_message = '';
35
+
36
+ /**
37
+ * @var
38
+ */
39
+ protected $last_response;
40
+
41
+ /**
42
+ * @param string $api_url
43
+ * @param Notices $notices
44
+ */
45
+ public function __construct( $api_url, Notices $notices ) {
46
+ $this->api_url = $api_url;
47
+ $this->notices = $notices;
48
+ }
49
+
50
+ /**
51
+ * Logs the current site in to the remote API
52
+ *
53
+ * @param License $license
54
+ * @return bool
55
+ */
56
+ public function create_license_activation( License $license ) {
57
+ $endpoint = '/license/activations';
58
+ $data = array(
59
+ 'site_url' => $license->site
60
+ );
61
+ $result = $this->request( 'POST', $endpoint, $data );
62
+ if( $result ) {
63
+ $this->notices->add( $result->message, 'info' );
64
+ return true;
65
+ }
66
+
67
+ return false;
68
+ }
69
+
70
+ /**
71
+ * Logs the current site out of the remote API
72
+ *
73
+ * @param License $license
74
+ * @return bool
75
+ */
76
+ public function delete_license_activation( License $license ) {
77
+ $endpoint = '/license/activations';
78
+ $data = array(
79
+ 'site_url' => $license->site
80
+ );
81
+ $result = $this->request( 'DELETE', $endpoint, $data );
82
+
83
+ if( $result ) {
84
+ $this->notices->add( $result->message, 'info' );
85
+ return true;
86
+ }
87
+
88
+ return false;
89
+ }
90
+
91
+ /**
92
+ * @param Plugin $plugin
93
+ * @return object
94
+ */
95
+ public function get_plugin( Plugin $plugin ) {
96
+ $endpoint = sprintf( '/plugins/%s?format=wp', $plugin->id() );
97
+ return $this->request( 'GET', $endpoint );
98
+ }
99
+
100
+ /**
101
+ * @param Plugin[] $plugins
102
+ * @return object
103
+ */
104
+ public function get_plugins( $plugins ) {
105
+ // create array of plugin ID's
106
+ $plugin_slugs = $plugins->map(function( $p ) { return $p->id(); });
107
+ $endpoint = add_query_arg( array( 'sids' => implode(',', $plugin_slugs ), 'format' => 'wp' ), '/plugins' );
108
+ return $this->request( 'GET', $endpoint );
109
+ }
110
+
111
+ /**
112
+ * @param string $method
113
+ * @param string $endpoint
114
+ * @param array $data
115
+ * @return object
116
+ */
117
+ public function request( $method, $endpoint, $data = array() ) {
118
+
119
+ $url = $this->api_url . $endpoint;
120
+ $args = array(
121
+ 'method' => $method
122
+ );
123
+
124
+ if( in_array( $method, array( 'GET', 'DELETE' ) ) ) {
125
+ $url = add_query_arg( $data, $url );
126
+ } else {
127
+ $args['body'] = $data;
128
+ }
129
+
130
+ $request = wp_remote_request( $url, $args );
131
+
132
+ // test for wp errors
133
+ if( $request instanceof WP_Error) {
134
+ $this->notices->add( $request->get_error_message(), 'error' ); ;
135
+ return false;
136
+ }
137
+
138
+ // retrieve response body
139
+ $body = wp_remote_retrieve_body( $request );
140
+ $response = json_decode( $body );
141
+ if( ! is_object( $response ) ) {
142
+ $this->notices->add( __( "The Boxzilla server returned an invalid response.", 'boxzilla' ), 'error' );
143
+ return false;
144
+ }
145
+
146
+ // store response
147
+ $this->last_response = $response;
148
+
149
+ // did request return an error response?
150
+ if( isset( $response->error ) ) {
151
+ $this->notices->add( $response->error->message, 'error' );
152
+ return null;
153
+ }
154
+
155
+ // return actual response data
156
+ return $response->data;
157
+ }
158
+
159
+ /**
160
+ * @return object|null
161
+ */
162
+ public function get_last_response() {
163
+ return $this->last_response;
164
+ }
165
+
166
+ }
src/licensing/class-authenticator.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla\Licensing;
4
+
5
+ class Authenticator {
6
+
7
+ /**
8
+ * @var string
9
+ */
10
+ protected $api_url;
11
+
12
+ /**
13
+ * @var License
14
+ */
15
+ protected $license;
16
+
17
+ /**
18
+ * Add the necessary Auth headers to all requests to our API
19
+ *
20
+ * @param $api_url
21
+ * @param License $license
22
+ */
23
+ public function __construct( $api_url, License $license ) {
24
+ $this->license = $license;
25
+ $this->api_url = $api_url;
26
+ }
27
+
28
+ /**
29
+ * Initialise the awesome
30
+ */
31
+ public function add_hooks() {
32
+ add_filter( 'http_request_args', array( $this, 'add_auth_headers' ), 10, 2 );
33
+ }
34
+
35
+ /**
36
+ * @param $args
37
+ * @param $url
38
+ *
39
+ * @return mixed
40
+ */
41
+ public function add_auth_headers( $args, $url ) {
42
+
43
+ if( strpos( $url, $this->api_url ) !== 0 ) {
44
+ return $args;
45
+ }
46
+
47
+ $this->license->load();
48
+
49
+ if( empty( $args['headers'] ) ) {
50
+ $args['headers'] = array();
51
+ }
52
+
53
+ $args['headers']['Authorization'] = 'Bearer ' . urlencode( $this->license->key );
54
+ return $args;
55
+ }
56
+ }
src/licensing/class-license-manager.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla\Licensing;
4
+
5
+ use Boxzilla\Collection;
6
+
7
+ class LicenseManager {
8
+
9
+ /**
10
+ * @var array
11
+ */
12
+ protected $extensions = array();
13
+
14
+ /**
15
+ * @var License
16
+ */
17
+ protected $license;
18
+
19
+ /**
20
+ * @var API
21
+ */
22
+ protected $api;
23
+
24
+ /**
25
+ * @param Collection $extensions
26
+ * @param API $api
27
+ * @param License $license
28
+ */
29
+ public function __construct( Collection $extensions, API $api, License $license ) {
30
+ $this->extensions = $extensions;
31
+ $this->license = $license;
32
+ $this->api = $api;
33
+ }
34
+
35
+ /**
36
+ * Initialise the awesome
37
+ */
38
+ public function add_hooks() {
39
+ // register license activation form
40
+ add_action( 'admin_init', array( $this, 'init' ) );
41
+ }
42
+
43
+
44
+ /**
45
+ * @return bool
46
+ */
47
+ public function init() {
48
+
49
+ // do nothing if not authenticated
50
+ if( ! current_user_can( 'manage_options' ) ) {
51
+ return false;
52
+ }
53
+
54
+ // load license
55
+ $this->license->load();
56
+
57
+ // register license key form
58
+ add_action( 'boxzilla_after_settings', array( $this, 'show_license_form' ) );
59
+
60
+ // listen for activation / deactivation requests
61
+ $this->listen();
62
+
63
+ return true;
64
+ }
65
+
66
+ /**
67
+ * @return bool
68
+ */
69
+ protected function listen() {
70
+
71
+ // nothing to do
72
+ if( ! isset( $_POST['boxzilla_license_form'] ) ) {
73
+ return false;
74
+ }
75
+
76
+ $key_changed = false;
77
+
78
+ // the form was submitted, let's see..
79
+ if( $_POST['action'] === 'deactivate' ) {
80
+ $this->license->deactivate();
81
+ $this->api->delete_license_activation( $this->license );
82
+ }
83
+
84
+ // did key change or was "activate" button pressed?
85
+ $new_license_key = sanitize_text_field( $_POST['boxzilla_license_key'] );
86
+ if( $new_license_key !== $this->license->key ) {
87
+ $this->license->key = $new_license_key;
88
+ $key_changed = true;
89
+ }
90
+
91
+ if( ! empty( $new_license_key )
92
+ && ! $this->license->activated
93
+ && ( $_POST['action'] === 'activate' || $key_changed ) ) {
94
+ // let's try to activate it
95
+ if( $this->api->create_license_activation( $this->license ) ) {
96
+ $this->license->activate();
97
+ }
98
+ }
99
+
100
+ $this->license->save();
101
+ return false;
102
+ }
103
+
104
+ /**
105
+ * Shows the license form
106
+ */
107
+ public function show_license_form() {
108
+ require __DIR__ . '/views/license-form.php';
109
+ }
110
+
111
+ }
src/licensing/class-license-service-provider.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla\Licensing;
4
+
5
+ use Boxzilla\DI\Container,
6
+ Boxzilla\DI\ServiceProviderInterface;
7
+
8
+ class LicenseServiceProvider implements ServiceProviderInterface {
9
+
10
+ /**
11
+ * Registers all licensing related services
12
+ *
13
+ * @param Container $container
14
+ */
15
+ public function register( Container $container ) {
16
+
17
+ $container['api_url'] = function( $container ) {
18
+ return 'https://api.boxzillaplugin.com/v1';
19
+ };
20
+
21
+ $container['license'] = function( $container ) {
22
+ return new License( 'boxzilla_license' );
23
+ };
24
+
25
+ $container['api'] = function( $container ) {
26
+ return new API( $container['api_url'], $container['notices'] );
27
+ };
28
+
29
+ $container['license_manager'] = function( $container ) {
30
+ return new LicenseManager( $container['plugins'], $container['api'], $container['license'] );
31
+ };
32
+
33
+ $container['update_manager'] = function( $container ) {
34
+ return new UpdateManager( $container['plugins'], $container['api'], $container['license'] );
35
+ };
36
+
37
+ $container['api_authenticator'] = function( $container ) {
38
+ return new Authenticator( $container['api_url'], $container['license'] );
39
+ };
40
+
41
+ }
42
+
43
+ }
src/licensing/class-license.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla\Licensing;
4
+
5
+ /**
6
+ * Class License
7
+ *
8
+ *
9
+ * @property string $key
10
+ * @property string $site
11
+ * @property boolean $activated
12
+ *
13
+ * @package Boxzilla\Licensing
14
+ */
15
+ class License {
16
+
17
+ /**
18
+ * @var string The license key
19
+ */
20
+ protected $key = '';
21
+
22
+ /**
23
+ * When this license is set to expire
24
+ *
25
+ * @var \DateTime
26
+ */
27
+ protected $expires_at;
28
+
29
+ /**
30
+ * Is license activated?
31
+ *
32
+ * @var bool
33
+ */
34
+ protected $activated = false;
35
+
36
+ /**
37
+ * The site this license is used on
38
+ *
39
+ * @var string
40
+ */
41
+ protected $site = '';
42
+
43
+ /**
44
+ * @var string The name of the option that holds the License data
45
+ */
46
+ protected $option_name = '';
47
+
48
+
49
+ /**
50
+ * @var array
51
+ */
52
+ protected $default_data = array(
53
+ 'key' => '',
54
+ 'activated' => false,
55
+ 'expires_at' => ''
56
+ );
57
+
58
+ /**
59
+ * @var bool Loaded?
60
+ */
61
+ protected $loaded = false;
62
+
63
+ /**
64
+ * @var bool Any changes?
65
+ */
66
+ protected $dirty = false;
67
+
68
+ /**
69
+ * @param string $option_key
70
+ */
71
+ public function __construct( $option_key ) {
72
+ $this->option_key = $option_key;
73
+ }
74
+
75
+ /**
76
+ * @param $name
77
+ * @param $value
78
+ */
79
+ public function __set($name, $value) {
80
+ $this->$name = $value;
81
+ $this->dirty = true;
82
+ }
83
+
84
+ /**
85
+ * @param $name
86
+ *
87
+ * @return null
88
+ */
89
+ public function __get($name) {
90
+ if( property_exists( $this, $name ) ) {
91
+ return $this->$name;
92
+ }
93
+
94
+ return null;
95
+ }
96
+
97
+ /**
98
+ * @param $name
99
+ *
100
+ * @return bool
101
+ */
102
+ public function __isset( $name ) {
103
+ return isset( $this->$name );
104
+ }
105
+
106
+ /**
107
+ * (Re)load the license from the database
108
+ *
109
+ * @return License
110
+ */
111
+ public function load() {
112
+
113
+ if( ! $this->loaded ) {
114
+ $data = (array) get_option( $this->option_key, array() );
115
+
116
+ if( ! empty( $data ) ) {
117
+ $data = array_merge( $this->default_data, $data );
118
+ $this->key = (string) $data['key'];
119
+ $this->activated = (bool) $data['activated'];
120
+ $this->expires_at = (string) $data['expires_at'];
121
+ }
122
+
123
+ // always fill site
124
+ $this->site = get_option( 'siteurl' );
125
+ $this->loaded = true;
126
+ }
127
+
128
+ return $this;
129
+ }
130
+
131
+ /**
132
+ * Reload the license data from DB
133
+ *
134
+ * @return License
135
+ */
136
+ public function reload() {
137
+ $this->loaded = false;
138
+ return $this->load();
139
+ }
140
+
141
+ /**
142
+ * Save the license in the database
143
+ *
144
+ * @return License
145
+ */
146
+ public function save() {
147
+
148
+ if( $this->dirty ) {
149
+ $data = $this->toArray();
150
+ update_option( $this->option_key, $data );
151
+ $this->dirty = false;
152
+ }
153
+
154
+ return $this;
155
+ }
156
+
157
+ /**
158
+ * Create an array from this License object
159
+ *
160
+ * @return array
161
+ */
162
+ public function toArray() {
163
+ $data = array(
164
+ 'key' => $this->key,
165
+ 'expires_at' => $this->expires_at,
166
+ 'activated' => $this->activated
167
+ );
168
+
169
+ return $data;
170
+ }
171
+
172
+ /**
173
+ * @return void
174
+ */
175
+ public function activate() {
176
+ $this->activated = true;
177
+ $this->dirty = true;
178
+ }
179
+
180
+ /**
181
+ * @return void
182
+ */
183
+ public function deactivate() {
184
+ $this->activated = false;
185
+ $this->dirty = true;
186
+ }
187
+
188
+ }
src/licensing/class-update-manager.php ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla\Licensing;
4
+
5
+ use Boxzilla\Collection,
6
+ Boxzilla\Plugin,
7
+ Boxzilla\Admin\Notices;
8
+
9
+ class UpdateManager {
10
+
11
+ /**
12
+ * @var Collection
13
+ */
14
+ protected $extensions;
15
+
16
+ /**
17
+ * @var API
18
+ */
19
+ protected $api;
20
+
21
+ /**
22
+ * @var License
23
+ */
24
+ protected $license;
25
+
26
+ /**
27
+ * @var
28
+ */
29
+ protected $available_updates;
30
+
31
+ /**
32
+ * @param Collection $extensions
33
+ * @param API $api
34
+ * @param License $license
35
+ */
36
+ public function __construct( Collection $extensions, API $api, License $license ) {
37
+ $this->extensions = $extensions;
38
+ $this->license = $license;
39
+ $this->api = $api;
40
+ }
41
+
42
+ /**
43
+ * Add hooks
44
+ */
45
+ public function add_hooks() {
46
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'add_updates' ) );
47
+ add_filter( 'plugins_api', array( $this, 'get_plugin_info' ), 20, 3 );
48
+ }
49
+
50
+ /**
51
+ * @param $result
52
+ * @param string $action
53
+ * @param null $args
54
+ *
55
+ * @return object
56
+ */
57
+ public function get_plugin_info( $result, $action = '', $args = null ) {
58
+
59
+ // do nothing for unrelated requests
60
+ if( $action !== 'plugin_information' || ! isset( $args->slug ) ) {
61
+ return $result;
62
+ }
63
+
64
+ // only act on our plugins
65
+ $plugin = $this->extensions->find( function( $p ) use($args) {
66
+ return dirname( $p->slug() ) == $args->slug;
67
+ });
68
+
69
+ // was it a plugin of ours?
70
+ if( $plugin ) {
71
+ return $this->get_update_info( $plugin );
72
+ }
73
+
74
+ return $result;
75
+ }
76
+
77
+ /**
78
+ * @param object $updates
79
+ * @return object
80
+ */
81
+ public function add_updates( $updates ) {
82
+
83
+ if( empty( $updates )
84
+ || ! isset( $updates->response )
85
+ || ! is_array( $updates->response ) ) {
86
+ return $updates;
87
+ }
88
+
89
+ // fetch available updates
90
+ $available_updates = $this->fetch_updates();
91
+
92
+ // merge with other updates
93
+ $updates->response = array_merge( $updates->response, $available_updates );
94
+
95
+ return $updates;
96
+ }
97
+
98
+ /**
99
+ * Fetch array of available updates from remote server
100
+ *
101
+ * @return array
102
+ */
103
+ protected function fetch_updates() {
104
+
105
+ if( is_array( $this->available_updates ) ) {
106
+ return $this->available_updates;
107
+ }
108
+
109
+ // fetch remote info
110
+ $remote_plugins = $this->api->get_plugins( $this->extensions );
111
+
112
+ // start with an empty array
113
+ $this->available_updates = array();
114
+
115
+ // did we get a valid response?
116
+ if( ! is_array( $remote_plugins ) ) {
117
+ return $this->available_updates;
118
+ }
119
+
120
+ // filter remote plugins, we only want the ones with an update available
121
+ $this->available_updates = $this->filter_remote_plugins( $remote_plugins );
122
+
123
+ return $this->available_updates;
124
+
125
+ }
126
+
127
+ /**
128
+ * @param $remote_plugins
129
+ * @return array
130
+ */
131
+ protected function filter_remote_plugins( $remote_plugins ) {
132
+
133
+ $available_updates = array();
134
+
135
+ // find new versions
136
+ foreach( $remote_plugins as $remote_plugin ) {
137
+
138
+ // find corresponding local plugin
139
+ $plugin = $this->extensions->find(
140
+ function( $p ) use( $remote_plugin ){
141
+ return $p->id() == $remote_plugin->id;
142
+ }
143
+ );
144
+
145
+ // plugin found and local plugin version not same as remote version?
146
+ if( ! $plugin || version_compare( $plugin->version(), $remote_plugin->version, '>=' ) ) {
147
+ continue;
148
+ }
149
+
150
+ // add some dynamic data
151
+ $available_updates[ $plugin->slug() ] = $this->format_response( $plugin, $remote_plugin );
152
+ }
153
+
154
+ return $available_updates;
155
+ }
156
+
157
+ /**
158
+ * @param Plugin $plugin
159
+ *
160
+ * @return null
161
+ */
162
+ public function get_update_info( Plugin $plugin ) {
163
+ $available_updates = $this->fetch_updates();
164
+
165
+ if( isset( $available_updates[ $plugin->slug() ] ) ) {
166
+ return $available_updates[ $plugin->slug() ];
167
+ }
168
+
169
+ return null;
170
+ }
171
+
172
+ /**
173
+ * @param Plugin $plugin
174
+ * @param $response
175
+ *
176
+ * @return mixed
177
+ */
178
+ protected function format_response( Plugin $plugin, $response ) {
179
+ $response->new_version = $response->version;
180
+ $response->slug = dirname( $plugin->slug() );
181
+ $response->plugin = $plugin->slug();
182
+
183
+ // load license
184
+ $this->license->load();
185
+
186
+ // add some notices if license is inactive
187
+ if( ! $this->license->activated ) {
188
+ $response->upgrade_notice = sprintf( 'You will need to <a href="%s">activate your license</a> to install this plugin update.', admin_url( 'edit.php?post_type=boxzilla-box&page=boxzilla-settings' ) );
189
+ $response->sections->changelog = '<p>' . sprintf( 'You will need to <a href="%s" target="_top">activate your license</a> to install this plugin update.', admin_url( 'edit.php?post_type=boxzilla-box&page=boxzilla-settings' ) ) . '</p>' . $response->sections->changelog;
190
+ $response->package = null;
191
+ }
192
+
193
+ // cast subkey objects to array as that is what WP expects
194
+ $response->sections = get_object_vars( $response->sections );
195
+ $response->banners = get_object_vars( $response->banners );
196
+
197
+ return $response;
198
+ }
199
+
200
+ }
src/licensing/views/license-form.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+
3
+ <h2><?php _e( 'License & Plugin Updates', 'boxzilla' ); ?></h2>
4
+
5
+ <?php if( ! $this->license->activated ) { ?>
6
+ <div class="error inline">
7
+ <p>
8
+ <strong><?php _e( 'Warning! You are <u>not</u> receiving plugin updates for the following plugin(s):', 'boxzilla' ); ?></strong>
9
+ </p>
10
+ <ul class="ul-square">
11
+ <li><?php echo join( '</li><li>', $this->extensions->map(function($p) { return $p->name(); }) ); ?></li>
12
+ </ul>
13
+ <p>
14
+ To fix this, please activate your license using the form below.
15
+ </p>
16
+ </div>
17
+ <?php } ?>
18
+
19
+ <form method="post">
20
+ <table class="form-table">
21
+ <tr valign="top">
22
+ <th><?php _e( 'License Key', 'boxzilla' ); ?></th>
23
+ <td>
24
+ <input size="40" name="boxzilla_license_key" placeholder="<?php esc_attr_e( 'Enter your license key..', 'boxzilla' ); ?>" value="<?php echo esc_attr( $this->license->key ); ?>" <?php if( $this->license->activated ) { echo 'readonly'; } ?> />
25
+ <input class="button" type="submit" name="action" value="<?php echo ( $this->license->activated ) ? 'deactivate' : 'activate'; ?>" />
26
+ <p class="help">
27
+ <?php echo sprintf( __( 'The license key received when purchasing your premium plan. <a href="%s">You can find it here</a>.', 'boxzilla' ), 'https://Boxzilla.com/account' ); ?>
28
+ </p>
29
+ </td>
30
+ </tr>
31
+ <tr valign="top">
32
+ <th><?php _e( 'License Status', 'boxzilla' ); ?></th>
33
+ <td>
34
+ <?php
35
+ if( $this->license->activated ) { ?>
36
+ <p><span class="status positive"><?php _e( 'ACTIVE', 'boxzilla' ); ?></span> - <?php _e( 'you are receiving plugin updates', 'boxzilla' ); ?></p>
37
+ <?php } else { ?>
38
+ <p><span class="status negative"><?php _e( 'INACTIVE', 'boxzilla' ); ?></span> - <?php _e( 'you are <strong>not</strong> receiving plugin updates', 'boxzilla' ); ?></p>
39
+ <?php } ?>
40
+ </td>
41
+ </tr>
42
+ </table>
43
+
44
+
45
+
46
+
47
+ <p>
48
+ <input type="submit" class="button button-primary" name="action" value="<?php _e( 'Save Changes' ); ?>" />
49
+ </p>
50
+
51
+ <input type="hidden" name="boxzilla_license_form" value="1" />
52
+ </form>
vendor/autoload.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload.php @generated by Composer
4
+
5
+ require_once __DIR__ . '/composer' . '/autoload_real.php';
6
+
7
+ return ComposerAutoloaderInit38e5bd5c00bdfd9a6ae58e314c6ae5ae::getLoader();
vendor/composer/ClassLoader.php ADDED
@@ -0,0 +1,413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Composer.
5
+ *
6
+ * (c) Nils Adermann <naderman@naderman.de>
7
+ * Jordi Boggiano <j.boggiano@seld.be>
8
+ *
9
+ * For the full copyright and license information, please view the LICENSE
10
+ * file that was distributed with this source code.
11
+ */
12
+
13
+ namespace Composer\Autoload;
14
+
15
+ /**
16
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17
+ *
18
+ * $loader = new \Composer\Autoload\ClassLoader();
19
+ *
20
+ * // register classes with namespaces
21
+ * $loader->add('Symfony\Component', __DIR__.'/component');
22
+ * $loader->add('Symfony', __DIR__.'/framework');
23
+ *
24
+ * // activate the autoloader
25
+ * $loader->register();
26
+ *
27
+ * // to enable searching the include path (eg. for PEAR packages)
28
+ * $loader->setUseIncludePath(true);
29
+ *
30
+ * In this example, if you try to use a class in the Symfony\Component
31
+ * namespace or one of its children (Symfony\Component\Console for instance),
32
+ * the autoloader will first look for the class under the component/
33
+ * directory, and it will then fallback to the framework/ directory if not
34
+ * found before giving up.
35
+ *
36
+ * This class is loosely based on the Symfony UniversalClassLoader.
37
+ *
38
+ * @author Fabien Potencier <fabien@symfony.com>
39
+ * @author Jordi Boggiano <j.boggiano@seld.be>
40
+ * @see http://www.php-fig.org/psr/psr-0/
41
+ * @see http://www.php-fig.org/psr/psr-4/
42
+ */
43
+ class ClassLoader
44
+ {
45
+ // PSR-4
46
+ private $prefixLengthsPsr4 = array();
47
+ private $prefixDirsPsr4 = array();
48
+ private $fallbackDirsPsr4 = array();
49
+
50
+ // PSR-0
51
+ private $prefixesPsr0 = array();
52
+ private $fallbackDirsPsr0 = array();
53
+
54
+ private $useIncludePath = false;
55
+ private $classMap = array();
56
+
57
+ private $classMapAuthoritative = false;
58
+
59
+ public function getPrefixes()
60
+ {
61
+ if (!empty($this->prefixesPsr0)) {
62
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
63
+ }
64
+
65
+ return array();
66
+ }
67
+
68
+ public function getPrefixesPsr4()
69
+ {
70
+ return $this->prefixDirsPsr4;
71
+ }
72
+
73
+ public function getFallbackDirs()
74
+ {
75
+ return $this->fallbackDirsPsr0;
76
+ }
77
+
78
+ public function getFallbackDirsPsr4()
79
+ {
80
+ return $this->fallbackDirsPsr4;
81
+ }
82
+
83
+ public function getClassMap()
84
+ {
85
+ return $this->classMap;
86
+ }
87
+
88
+ /**
89
+ * @param array $classMap Class to filename map
90
+ */
91
+ public function addClassMap(array $classMap)
92
+ {
93
+ if ($this->classMap) {
94
+ $this->classMap = array_merge($this->classMap, $classMap);
95
+ } else {
96
+ $this->classMap = $classMap;
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Registers a set of PSR-0 directories for a given prefix, either
102
+ * appending or prepending to the ones previously set for this prefix.
103
+ *
104
+ * @param string $prefix The prefix
105
+ * @param array|string $paths The PSR-0 root directories
106
+ * @param bool $prepend Whether to prepend the directories
107
+ */
108
+ public function add($prefix, $paths, $prepend = false)
109
+ {
110
+ if (!$prefix) {
111
+ if ($prepend) {
112
+ $this->fallbackDirsPsr0 = array_merge(
113
+ (array) $paths,
114
+ $this->fallbackDirsPsr0
115
+ );
116
+ } else {
117
+ $this->fallbackDirsPsr0 = array_merge(
118
+ $this->fallbackDirsPsr0,
119
+ (array) $paths
120
+ );
121
+ }
122
+
123
+ return;
124
+ }
125
+
126
+ $first = $prefix[0];
127
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
128
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
129
+
130
+ return;
131
+ }
132
+ if ($prepend) {
133
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
134
+ (array) $paths,
135
+ $this->prefixesPsr0[$first][$prefix]
136
+ );
137
+ } else {
138
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
139
+ $this->prefixesPsr0[$first][$prefix],
140
+ (array) $paths
141
+ );
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Registers a set of PSR-4 directories for a given namespace, either
147
+ * appending or prepending to the ones previously set for this namespace.
148
+ *
149
+ * @param string $prefix The prefix/namespace, with trailing '\\'
150
+ * @param array|string $paths The PSR-4 base directories
151
+ * @param bool $prepend Whether to prepend the directories
152
+ *
153
+ * @throws \InvalidArgumentException
154
+ */
155
+ public function addPsr4($prefix, $paths, $prepend = false)
156
+ {
157
+ if (!$prefix) {
158
+ // Register directories for the root namespace.
159
+ if ($prepend) {
160
+ $this->fallbackDirsPsr4 = array_merge(
161
+ (array) $paths,
162
+ $this->fallbackDirsPsr4
163
+ );
164
+ } else {
165
+ $this->fallbackDirsPsr4 = array_merge(
166
+ $this->fallbackDirsPsr4,
167
+ (array) $paths
168
+ );
169
+ }
170
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
171
+ // Register directories for a new namespace.
172
+ $length = strlen($prefix);
173
+ if ('\\' !== $prefix[$length - 1]) {
174
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
175
+ }
176
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
177
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
178
+ } elseif ($prepend) {
179
+ // Prepend directories for an already registered namespace.
180
+ $this->prefixDirsPsr4[$prefix] = array_merge(
181
+ (array) $paths,
182
+ $this->prefixDirsPsr4[$prefix]
183
+ );
184
+ } else {
185
+ // Append directories for an already registered namespace.
186
+ $this->prefixDirsPsr4[$prefix] = array_merge(
187
+ $this->prefixDirsPsr4[$prefix],
188
+ (array) $paths
189
+ );
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Registers a set of PSR-0 directories for a given prefix,
195
+ * replacing any others previously set for this prefix.
196
+ *
197
+ * @param string $prefix The prefix
198
+ * @param array|string $paths The PSR-0 base directories
199
+ */
200
+ public function set($prefix, $paths)
201
+ {
202
+ if (!$prefix) {
203
+ $this->fallbackDirsPsr0 = (array) $paths;
204
+ } else {
205
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
206
+ }
207
+ }
208
+
209
+ /**
210
+ * Registers a set of PSR-4 directories for a given namespace,
211
+ * replacing any others previously set for this namespace.
212
+ *
213
+ * @param string $prefix The prefix/namespace, with trailing '\\'
214
+ * @param array|string $paths The PSR-4 base directories
215
+ *
216
+ * @throws \InvalidArgumentException
217
+ */
218
+ public function setPsr4($prefix, $paths)
219
+ {
220
+ if (!$prefix) {
221
+ $this->fallbackDirsPsr4 = (array) $paths;
222
+ } else {
223
+ $length = strlen($prefix);
224
+ if ('\\' !== $prefix[$length - 1]) {
225
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
226
+ }
227
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
228
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
229
+ }
230
+ }
231
+
232
+ /**
233
+ * Turns on searching the include path for class files.
234
+ *
235
+ * @param bool $useIncludePath
236
+ */
237
+ public function setUseIncludePath($useIncludePath)
238
+ {
239
+ $this->useIncludePath = $useIncludePath;
240
+ }
241
+
242
+ /**
243
+ * Can be used to check if the autoloader uses the include path to check
244
+ * for classes.
245
+ *
246
+ * @return bool
247
+ */
248
+ public function getUseIncludePath()
249
+ {
250
+ return $this->useIncludePath;
251
+ }
252
+
253
+ /**
254
+ * Turns off searching the prefix and fallback directories for classes
255
+ * that have not been registered with the class map.
256
+ *
257
+ * @param bool $classMapAuthoritative
258
+ */
259
+ public function setClassMapAuthoritative($classMapAuthoritative)
260
+ {
261
+ $this->classMapAuthoritative = $classMapAuthoritative;
262
+ }
263
+
264
+ /**
265
+ * Should class lookup fail if not found in the current class map?
266
+ *
267
+ * @return bool
268
+ */
269
+ public function isClassMapAuthoritative()
270
+ {
271
+ return $this->classMapAuthoritative;
272
+ }
273
+
274
+ /**
275
+ * Registers this instance as an autoloader.
276
+ *
277
+ * @param bool $prepend Whether to prepend the autoloader or not
278
+ */
279
+ public function register($prepend = false)
280
+ {
281
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
282
+ }
283
+
284
+ /**
285
+ * Unregisters this instance as an autoloader.
286
+ */
287
+ public function unregister()
288
+ {
289
+ spl_autoload_unregister(array($this, 'loadClass'));
290
+ }
291
+
292
+ /**
293
+ * Loads the given class or interface.
294
+ *
295
+ * @param string $class The name of the class
296
+ * @return bool|null True if loaded, null otherwise
297
+ */
298
+ public function loadClass($class)
299
+ {
300
+ if ($file = $this->findFile($class)) {
301
+ includeFile($file);
302
+
303
+ return true;
304
+ }
305
+ }
306
+
307
+ /**
308
+ * Finds the path to the file where the class is defined.
309
+ *
310
+ * @param string $class The name of the class
311
+ *
312
+ * @return string|false The path if found, false otherwise
313
+ */
314
+ public function findFile($class)
315
+ {
316
+ // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
317
+ if ('\\' == $class[0]) {
318
+ $class = substr($class, 1);
319
+ }
320
+
321
+ // class map lookup
322
+ if (isset($this->classMap[$class])) {
323
+ return $this->classMap[$class];
324
+ }
325
+ if ($this->classMapAuthoritative) {
326
+ return false;
327
+ }
328
+
329
+ $file = $this->findFileWithExtension($class, '.php');
330
+
331
+ // Search for Hack files if we are running on HHVM
332
+ if ($file === null && defined('HHVM_VERSION')) {
333
+ $file = $this->findFileWithExtension($class, '.hh');
334
+ }
335
+
336
+ if ($file === null) {
337
+ // Remember that this class does not exist.
338
+ return $this->classMap[$class] = false;
339
+ }
340
+
341
+ return $file;
342
+ }
343
+
344
+ private function findFileWithExtension($class, $ext)
345
+ {
346
+ // PSR-4 lookup
347
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
348
+
349
+ $first = $class[0];
350
+ if (isset($this->prefixLengthsPsr4[$first])) {
351
+ foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
352
+ if (0 === strpos($class, $prefix)) {
353
+ foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
354
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
355
+ return $file;
356
+ }
357
+ }
358
+ }
359
+ }
360
+ }
361
+
362
+ // PSR-4 fallback dirs
363
+ foreach ($this->fallbackDirsPsr4 as $dir) {
364
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
365
+ return $file;
366
+ }
367
+ }
368
+
369
+ // PSR-0 lookup
370
+ if (false !== $pos = strrpos($class, '\\')) {
371
+ // namespaced class name
372
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
373
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
374
+ } else {
375
+ // PEAR-like class name
376
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
377
+ }
378
+
379
+ if (isset($this->prefixesPsr0[$first])) {
380
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
381
+ if (0 === strpos($class, $prefix)) {
382
+ foreach ($dirs as $dir) {
383
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
384
+ return $file;
385
+ }
386
+ }
387
+ }
388
+ }
389
+ }
390
+
391
+ // PSR-0 fallback dirs
392
+ foreach ($this->fallbackDirsPsr0 as $dir) {
393
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
394
+ return $file;
395
+ }
396
+ }
397
+
398
+ // PSR-0 include paths.
399
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
400
+ return $file;
401
+ }
402
+ }
403
+ }
404
+
405
+ /**
406
+ * Scope isolated include.
407
+ *
408
+ * Prevents access to $this/self from included files.
409
+ */
410
+ function includeFile($file)
411
+ {
412
+ include $file;
413
+ }
vendor/composer/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Copyright (c) 2016 Nils Adermann, Jordi Boggiano
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished
9
+ to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+
vendor/composer/autoload_classmap.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_classmap.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'Boxzilla\\Admin\\Admin' => $baseDir . '/src/admin/class-admin.php',
10
+ 'Boxzilla\\Admin\\Installer' => $baseDir . '/src/admin/class-installer.php',
11
+ 'Boxzilla\\Admin\\Migrations' => $baseDir . '/src/admin/class-migrations.php',
12
+ 'Boxzilla\\Admin\\Notices' => $baseDir . '/src/admin/class-notices.php',
13
+ 'Boxzilla\\Box' => $baseDir . '/src/class-box.php',
14
+ 'Boxzilla\\BoxLoader' => $baseDir . '/src/class-loader.php',
15
+ 'Boxzilla\\Boxzilla' => $baseDir . '/src/class-boxzilla.php',
16
+ 'Boxzilla\\BoxzillaServiceProvider' => $baseDir . '/src/class-boxzilla-service-provider.php',
17
+ 'Boxzilla\\Collection' => $baseDir . '/src/class-collection.php',
18
+ 'Boxzilla\\DI\\Container' => $baseDir . '/src/di/class-container.php',
19
+ 'Boxzilla\\DI\\ContainerWithPropertyAccess' => $baseDir . '/src/di/class-container-with-property-access.php',
20
+ 'Boxzilla\\DI\\ServiceProviderInterface' => $baseDir . '/src/di/interface-service-provider.php',
21
+ 'Boxzilla\\Filter\\Autocomplete' => $baseDir . '/src/admin/class-autocomplete.php',
22
+ 'Boxzilla\\Licensing\\API' => $baseDir . '/src/licensing/class-api.php',
23
+ 'Boxzilla\\Licensing\\Authenticator' => $baseDir . '/src/licensing/class-authenticator.php',
24
+ 'Boxzilla\\Licensing\\License' => $baseDir . '/src/licensing/class-license.php',
25
+ 'Boxzilla\\Licensing\\LicenseManager' => $baseDir . '/src/licensing/class-license-manager.php',
26
+ 'Boxzilla\\Licensing\\LicenseServiceProvider' => $baseDir . '/src/licensing/class-license-service-provider.php',
27
+ 'Boxzilla\\Licensing\\UpdateManager' => $baseDir . '/src/licensing/class-update-manager.php',
28
+ 'Boxzilla\\Plugin' => $baseDir . '/src/class-plugin.php',
29
+ 'Boxzilla_PHP_Fallback' => $baseDir . '/src/class-php-fallback.php',
30
+ );
vendor/composer/autoload_files.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_files.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ '94cc07ee52e9ca5ddcd07a46efdfe8cc' => $baseDir . '/src/functions.php',
10
+ );
vendor/composer/autoload_namespaces.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_namespaces.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_psr4.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_psr4.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src/Composer/Installers'),
10
+ );
vendor/composer/autoload_real.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_real.php @generated by Composer
4
+
5
+ class ComposerAutoloaderInit38e5bd5c00bdfd9a6ae58e314c6ae5ae
6
+ {
7
+ private static $loader;
8
+
9
+ public static function loadClassLoader($class)
10
+ {
11
+ if ('Composer\Autoload\ClassLoader' === $class) {
12
+ require __DIR__ . '/ClassLoader.php';
13
+ }
14
+ }
15
+
16
+ public static function getLoader()
17
+ {
18
+ if (null !== self::$loader) {
19
+ return self::$loader;
20
+ }
21
+
22
+ spl_autoload_register(array('ComposerAutoloaderInit38e5bd5c00bdfd9a6ae58e314c6ae5ae', 'loadClassLoader'), true, true);
23
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit38e5bd5c00bdfd9a6ae58e314c6ae5ae', 'loadClassLoader'));
25
+
26
+ $map = require __DIR__ . '/autoload_namespaces.php';
27
+ foreach ($map as $namespace => $path) {
28
+ $loader->set($namespace, $path);
29
+ }
30
+
31
+ $map = require __DIR__ . '/autoload_psr4.php';
32
+ foreach ($map as $namespace => $path) {
33
+ $loader->setPsr4($namespace, $path);
34
+ }
35
+
36
+ $classMap = require __DIR__ . '/autoload_classmap.php';
37
+ if ($classMap) {
38
+ $loader->addClassMap($classMap);
39
+ }
40
+
41
+ $loader->register(true);
42
+
43
+ $includeFiles = require __DIR__ . '/autoload_files.php';
44
+ foreach ($includeFiles as $fileIdentifier => $file) {
45
+ composerRequire38e5bd5c00bdfd9a6ae58e314c6ae5ae($fileIdentifier, $file);
46
+ }
47
+
48
+ return $loader;
49
+ }
50
+ }
51
+
52
+ function composerRequire38e5bd5c00bdfd9a6ae58e314c6ae5ae($fileIdentifier, $file)
53
+ {
54
+ if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
55
+ require $file;
56
+
57
+ $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
58
+ }
59
+ }
vendor/composer/installed.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "name": "composer/installers",
4
+ "version": "v1.0.25",
5
+ "version_normalized": "1.0.25.0",
6
+ "source": {
7
+ "type": "git",
8
+ "url": "https://github.com/composer/installers.git",
9
+ "reference": "36e5b5843203d7f1cf6ffb0305a97e014387bd8e"
10
+ },
11
+ "dist": {
12
+ "type": "zip",
13
+ "url": "https://api.github.com/repos/composer/installers/zipball/36e5b5843203d7f1cf6ffb0305a97e014387bd8e",
14
+ "reference": "36e5b5843203d7f1cf6ffb0305a97e014387bd8e",
15
+ "shasum": ""
16
+ },
17
+ "require": {
18
+ "composer-plugin-api": "^1.0"
19
+ },
20
+ "replace": {
21
+ "roundcube/plugin-installer": "*",
22
+ "shama/baton": "*"
23
+ },
24
+ "require-dev": {
25
+ "composer/composer": "1.0.*@dev",
26
+ "phpunit/phpunit": "4.1.*"
27
+ },
28
+ "time": "2016-04-13 19:46:30",
29
+ "type": "composer-plugin",
30
+ "extra": {
31
+ "class": "Composer\\Installers\\Plugin",
32
+ "branch-alias": {
33
+ "dev-master": "1.0-dev"
34
+ }
35
+ },
36
+ "installation-source": "dist",
37
+ "autoload": {
38
+ "psr-4": {
39
+ "Composer\\Installers\\": "src/Composer/Installers"
40
+ }
41
+ },
42
+ "notification-url": "https://packagist.org/downloads/",
43
+ "license": [
44
+ "MIT"
45
+ ],
46
+ "authors": [
47
+ {
48
+ "name": "Kyle Robinson Young",
49
+ "email": "kyle@dontkry.com",
50
+ "homepage": "https://github.com/shama"
51
+ }
52
+ ],
53
+ "description": "A multi-framework Composer library installer",
54
+ "homepage": "https://composer.github.io/installers/",
55
+ "keywords": [
56
+ "Craft",
57
+ "Dolibarr",
58
+ "Hurad",
59
+ "ImageCMS",
60
+ "MODX Evo",
61
+ "Mautic",
62
+ "OXID",
63
+ "SMF",
64
+ "Thelia",
65
+ "WolfCMS",
66
+ "agl",
67
+ "aimeos",
68
+ "annotatecms",
69
+ "bitrix",
70
+ "cakephp",
71
+ "chef",
72
+ "codeigniter",
73
+ "concrete5",
74
+ "croogo",
75
+ "dokuwiki",
76
+ "drupal",
77
+ "elgg",
78
+ "fuelphp",
79
+ "grav",
80
+ "installer",
81
+ "joomla",
82
+ "kohana",
83
+ "laravel",
84
+ "lithium",
85
+ "magento",
86
+ "mako",
87
+ "mediawiki",
88
+ "modulework",
89
+ "moodle",
90
+ "phpbb",
91
+ "piwik",
92
+ "ppi",
93
+ "puppet",
94
+ "roundcube",
95
+ "shopware",
96
+ "silverstripe",
97
+ "symfony",
98
+ "typo3",
99
+ "wordpress",
100
+ "zend",
101
+ "zikula"
102
+ ]
103
+ }
104
+ ]