Boxzilla - Version 3.2.16

Version Description

Download this release

Release Info

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

Code changes from version 3.2.15 to 3.2.16

Files changed (56) hide show
  1. CHANGELOG.md +9 -0
  2. bootstrap.php +4 -0
  3. boxzilla.php +2 -2
  4. languages/boxzilla-cs_CZ.mo +0 -0
  5. languages/boxzilla-cs_CZ.po +0 -491
  6. languages/boxzilla-es_ES.mo +0 -0
  7. languages/boxzilla-es_ES.po +0 -212
  8. languages/boxzilla-fr_FR.mo +0 -0
  9. languages/boxzilla-fr_FR.po +0 -211
  10. languages/boxzilla-nl_NL.mo +0 -0
  11. languages/boxzilla-nl_NL.po +0 -209
  12. languages/boxzilla-ro_RO.mo +0 -0
  13. languages/boxzilla-ro_RO.po +0 -468
  14. languages/boxzilla.pot +131 -83
  15. languages/index.php +7 -0
  16. phpcs.xml +46 -0
  17. readme.txt +11 -2
  18. src/admin/class-admin.php +775 -799
  19. src/admin/class-autocomplete.php +107 -96
  20. src/admin/class-installer.php +88 -92
  21. src/admin/class-menu.php +109 -110
  22. src/admin/class-migrations.php +86 -90
  23. src/admin/class-notices.php +38 -41
  24. src/admin/class-review-notice.php +67 -71
  25. src/admin/migrations/3.1-cookie-option.php +16 -16
  26. src/admin/migrations/3.1.11-screen-width-condition.php +19 -19
  27. src/admin/views/extensions.php +17 -15
  28. src/admin/views/metaboxes/box-appearance-controls.php +24 -24
  29. src/admin/views/metaboxes/box-option-controls.php +243 -231
  30. src/admin/views/metaboxes/email-optin.php +4 -4
  31. src/admin/views/metaboxes/need-help.php +5 -5
  32. src/admin/views/metaboxes/our-other-plugins.php +1 -1
  33. src/admin/views/settings.php +15 -15
  34. src/class-bootstrapper.php +105 -0
  35. src/class-box.php +254 -262
  36. src/class-boxzilla-service-provider.php +52 -51
  37. src/class-boxzilla.php +2 -3
  38. src/class-loader.php +332 -338
  39. src/class-php-fallback.php +55 -58
  40. src/class-plugin.php +105 -113
  41. src/default-actions.php +66 -61
  42. src/default-filters.php +23 -19
  43. src/di/class-container-with-property-access.php +42 -47
  44. src/di/class-container.php +237 -248
  45. src/di/interface-service-provider.php +11 -11
  46. src/functions.php +6 -7
  47. src/licensing/class-api-exception.php +26 -28
  48. src/licensing/class-api.php +166 -174
  49. src/licensing/class-license-manager.php +171 -179
  50. src/licensing/class-license-service-provider.php +30 -31
  51. src/licensing/class-license.php +101 -108
  52. src/licensing/class-poller.php +53 -56
  53. src/licensing/class-update-manager.php +251 -247
  54. src/licensing/views/license-form.php +42 -32
  55. vendor/composer/autoload_classmap.php +1 -0
  56. vendor/composer/autoload_static.php +1 -0
CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
  Changelog
2
  ==========
3
 
 
 
 
 
 
 
 
 
 
4
  #### 3.2.15 - Nov 6, 2019
5
 
6
  **Improvements**
1
  Changelog
2
  ==========
3
 
4
+ #### 3.2.16 - Nov 15, 2019
5
+
6
+ **Improvements**
7
+
8
+ Roll-back a change in version 3.2.15 that caused an issue with Boxzilla Theme Pack and Boxzilla WooCommerce.
9
+
10
+ Please make sure your [Boxzilla plugin license](https://my.boxzillaplugin.com/) is activated and then update Boxzilla Theme Pack and Boxzilla WooCommerce to the latest version.
11
+
12
+
13
  #### 3.2.15 - Nov 6, 2019
14
 
15
  **Improvements**
bootstrap.php CHANGED
@@ -43,4 +43,8 @@ add_action( 'plugins_loaded', function() use( $boxzilla ) {
43
  $boxzilla['update_manager']->init();
44
  }
45
  }
 
 
 
 
46
  }, 90 );
43
  $boxzilla['update_manager']->init();
44
  }
45
  }
46
+
47
+ // for legacy reasons: Boxzilla Theme Pack & Boxzilla WooCommerce used this
48
+ // we will be removing this in future versions
49
+ $boxzilla['bootstrapper']->run();
50
  }, 90 );
boxzilla.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Boxzilla
4
- Version: 3.2.15
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
@@ -41,7 +41,7 @@ if ( ! defined( 'ABSPATH' ) ) {
41
  function _load_boxzilla() {
42
 
43
  define( 'BOXZILLA_FILE', __FILE__ );
44
- define('BOXZILLA_VERSION', '3.2.15');
45
 
46
  require __DIR__ . '/bootstrap.php';
47
  }
1
  <?php
2
  /*
3
  Plugin Name: Boxzilla
4
+ Version: 3.2.16
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
41
  function _load_boxzilla() {
42
 
43
  define( 'BOXZILLA_FILE', __FILE__ );
44
+ define('BOXZILLA_VERSION', '3.2.16');
45
 
46
  require __DIR__ . '/bootstrap.php';
47
  }
languages/boxzilla-cs_CZ.mo DELETED
Binary file
languages/boxzilla-cs_CZ.po DELETED
@@ -1,491 +0,0 @@
1
- # Copyright (C) 2018 boxzilla
2
- # This file is distributed under the same license as the boxzilla package.
3
- msgid ""
4
- msgstr ""
5
- "Project-Id-Version: boxzilla\n"
6
- "MIME-Version: 1.0\n"
7
- "Content-Type: text/plain; charset=UTF-8\n"
8
- "Content-Transfer-Encoding: 8bit\n"
9
- "X-Poedit-Basepath: ..\n"
10
- "X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;"
11
- "_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;"
12
- "esc_html_e;esc_html_x:1,2c\n"
13
- "X-Poedit-SourceCharset: UTF-8\n"
14
- "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
15
- "POT-Creation-Date: \n"
16
- "PO-Revision-Date: \n"
17
- "Language-Team: Webstudio <webstudio@petrbok.cz>\n"
18
- "X-Generator: Poedit 1.8.9\n"
19
- "Last-Translator: Webstudio Petrbok <webstudio@petrbok.cz>\n"
20
- "Language: cs_CZ\n"
21
- "X-Poedit-SearchPath-0: .\n"
22
- "X-Poedit-SearchPathExcluded-0: *.js\n"
23
-
24
- #: src/default-actions.php:12, src/default-actions.php:24
25
- msgid "Boxzilla"
26
- msgstr "Boxzilla"
27
-
28
- #: src/default-actions.php:13
29
- msgid "Box"
30
- msgstr "Box"
31
-
32
- #: src/default-actions.php:14
33
- msgid "Add New"
34
- msgstr "Přidat nový"
35
-
36
- #: src/default-actions.php:15
37
- msgid "Add New Box"
38
- msgstr "Přidat nový box"
39
-
40
- #: src/default-actions.php:16
41
- msgid "Edit Box"
42
- msgstr "Upravit box"
43
-
44
- #: src/default-actions.php:17
45
- msgid "New Box"
46
- msgstr "Nový box"
47
-
48
- #: src/default-actions.php:18
49
- msgid "All Boxes"
50
- msgstr "Všechny boxy"
51
-
52
- #: src/default-actions.php:19
53
- msgid "View Box"
54
- msgstr "Zobrazit box"
55
-
56
- #: src/default-actions.php:20
57
- msgid "Search Boxes"
58
- msgstr "Hledat box"
59
-
60
- #: src/default-actions.php:21
61
- msgid "No Boxes found"
62
- msgstr "Nenalezen žádný box"
63
-
64
- #: src/default-actions.php:22
65
- msgid "No Boxes found in Trash"
66
- msgstr "V koši nenalezen žádný box"
67
-
68
- #: src/admin/class-admin.php:104
69
- msgid ""
70
- "Awesome, you are using Boxzilla! You can now safely <a href=\"%s"
71
- "\">deactivate the Scroll Triggered Boxes plugin</a>."
72
- msgstr ""
73
- "Skvělé, používáte Boxzilla! Nyní můžete bezpečně <a href=\"%s\">deaktivovat "
74
- "plugin Scroll Triggered Boxes"
75
-
76
- #: src/admin/class-admin.php:172
77
- msgid "Box ID"
78
- msgstr "Box ID"
79
-
80
- #: src/admin/class-admin.php:175
81
- msgid "Box Title"
82
- msgstr "Název boxu"
83
-
84
- #: src/admin/class-admin.php:209, src/admin/class-admin.php:210,
85
- #: src/admin/views/settings.php:7
86
- msgid "Settings"
87
- msgstr "Nastavení"
88
-
89
- #: src/admin/class-admin.php:215, src/admin/class-admin.php:216
90
- msgid "Extensions"
91
- msgstr "Rozšíření"
92
-
93
- #: src/admin/class-admin.php:308
94
- msgid "Enter a comma-separated list of values."
95
- msgstr "Zadejte seznam hodnot oddělených čárkami."
96
-
97
- #: src/admin/class-admin.php:309
98
- msgid "Enter a comma-separated list of post slugs or post ID's.."
99
- msgstr "Zadejte seznam příspěvků nebo ID příspěvků oddělených čárkami.."
100
-
101
- #: src/admin/class-admin.php:310
102
- msgid "Enter a comma-separated list of page slugs or page ID's.."
103
- msgstr "Zadejte seznam stránek nebo ID stránek, oddělených čárkami.."
104
-
105
- #: src/admin/class-admin.php:311
106
- msgid "Enter a comma-separated list of post types.."
107
- msgstr "Zadejte seznam typů příspěvků oddělených čárkami.."
108
-
109
- #: src/admin/class-admin.php:312
110
- msgid "Enter a comma-separated list of relative URL's, eg /contact/"
111
- msgstr ""
112
- "Zadejte seznam relativních adres URL oddělených čárkami, např. / kontakt /"
113
-
114
- #: src/admin/class-admin.php:344
115
- msgid "Box Appearance"
116
- msgstr "Vzhled boxu"
117
-
118
- #: src/admin/class-admin.php:353
119
- msgid "Box Options"
120
- msgstr "Možnosti boxu"
121
-
122
- #: src/admin/class-admin.php:362
123
- msgid "Looking for help?"
124
- msgstr "Hledáte pomoc?"
125
-
126
- #: src/admin/class-admin.php:370
127
- msgid "Subscribe to our newsletter"
128
- msgstr "Přihlásit se k odběru novinek"
129
-
130
- #: src/admin/class-review-notice.php:74
131
- msgid "You've been using Boxzilla for some time now; we hope you love it!"
132
- msgstr "Používáte Boxzilla už nějakou dobu; Doufáme, že ji milujete!"
133
-
134
- #: src/admin/class-review-notice.php:75
135
- msgid ""
136
- "If you do, please <a href=\"%s\">leave us a 5★ rating on WordPress.org</a>. "
137
- "It would be of great help to us."
138
- msgstr ""
139
- "Pokud můžete, prosím <a href=\"%s\">ohodnoťte nás 5★ na WordPress.org</a>. "
140
- "Byl by pro nás velkou pomocí."
141
-
142
- #: src/admin/class-review-notice.php:77
143
- msgid "Dismiss this notice."
144
- msgstr "Zrušit toto oznámení."
145
-
146
- #: src/licensing/class-api.php:165
147
- msgid "The Boxzilla server returned an invalid response."
148
- msgstr "Server Boxzilla vrátil neplatnou odpověď."
149
-
150
- #: src/admin/views/extensions.php:4
151
- msgid "Available Add-On Plugins"
152
- msgstr "Dostupné doplňky pro pluginy"
153
-
154
- #: src/admin/views/extensions.php:6
155
- msgid ""
156
- "There are various add-ons available for Boxzilla which further enhance the "
157
- "functionality of the core plugin."
158
- msgstr ""
159
- "K dispozici jsou různé doplňky pro Boxzilla, které dále zvyšují funkčnost "
160
- "hlavního pluginu."
161
-
162
- #: src/admin/views/extensions.php:9
163
- msgid ""
164
- "To gain instant access the premium add-on plugins listed here, <a href=\"%s"
165
- "\">have a look at our pricing</a>."
166
- msgstr ""
167
- "Chcete-li získat okamžitý přístup k přídavným modulům plug-in Premium "
168
- "uvedených zde, <a href=\"%s\"> podívejte se na naše ceny</a>."
169
-
170
- #: src/admin/views/extensions.php:18
171
- msgid "You will be redirected to the Boxzilla site in a few seconds.."
172
- msgstr "Budete přesměrováni na stránku Boxzilla během několika sekund .."
173
-
174
- #: src/admin/views/extensions.php:19
175
- msgid "If not, please click here: %s."
176
- msgstr "Pokud ne, klikněte zde: %s."
177
-
178
- #: src/admin/views/settings.php:20,
179
- #: src/admin/views/metaboxes/box-option-controls.php:196
180
- msgid "Enable test mode?"
181
- msgstr "Povolit testovací režim?"
182
-
183
- #: src/admin/views/settings.php:24,
184
- #: src/admin/views/metaboxes/box-option-controls.php:200
185
- msgid ""
186
- "If test mode is enabled, all boxes will show up regardless of whether a "
187
- "cookie has been set."
188
- msgstr ""
189
- "Je-li testovací režim zapnutý, zobrazí se všechna pole bez ohledu na to, zda "
190
- "byl nastaven soubor cookie."
191
-
192
- #: src/licensing/views/license-form.php:8
193
- msgid "License & Plugin Updates"
194
- msgstr "Licence & aktualizace pluginu"
195
-
196
- #: src/licensing/views/license-form.php:13
197
- msgid ""
198
- "Warning! You are <u>not</u> receiving plugin updates for the following "
199
- "plugin(s):"
200
- msgstr ""
201
- "Varování! Nemůžete <u> obdržet </ u> aktualizace pluginů pro následující "
202
- "zásuvný modul(y):"
203
-
204
- #: src/licensing/views/license-form.php:33
205
- msgid "License Key"
206
- msgstr "Licenční klíč"
207
-
208
- #: src/licensing/views/license-form.php:35
209
- msgid "Enter your license key.."
210
- msgstr "Zadejte váš licenční klíč.."
211
-
212
- #: src/licensing/views/license-form.php:38
213
- msgid ""
214
- "The license key received when purchasing your premium Boxzilla plan. <a href="
215
- "\"%s\">You can find it here</a>."
216
- msgstr ""
217
- "Licenční klíč byl přijat při nákupu vašeho prémium Boxzilla planu. <a href="
218
- "\"%s\">Naleznete ho zde</a>."
219
-
220
- #: src/licensing/views/license-form.php:43
221
- msgid "License Status"
222
- msgstr "Stav licence"
223
-
224
- #: src/licensing/views/license-form.php:47
225
- msgid "ACTIVE"
226
- msgstr "AKTIVNÍ"
227
-
228
- #: src/licensing/views/license-form.php:47
229
- msgid "you are receiving plugin updates"
230
- msgstr "obdržíte aktualizace pluginu"
231
-
232
- #: src/licensing/views/license-form.php:49
233
- msgid "INACTIVE"
234
- msgstr "NEAKTIVNÍ"
235
-
236
- #: src/licensing/views/license-form.php:49
237
- msgid "you are <strong>not</strong> receiving plugin updates"
238
- msgstr "Vy <strong>neobdržíte</strong> aktualizace pluginů"
239
-
240
- #: src/admin/views/metaboxes/box-appearance-controls.php:2
241
- msgid ""
242
- "For the best experience when styling your box, please use the default "
243
- "WordPress visual editor."
244
- msgstr ""
245
- "Pro nejlepší zážitek při úpravě stylu vašeho boxu použijte výchozí vizuální "
246
- "editor WordPress."
247
-
248
- #: src/admin/views/metaboxes/box-appearance-controls.php:8
249
- msgid "Background color"
250
- msgstr "Barva pozadí"
251
-
252
- #: src/admin/views/metaboxes/box-appearance-controls.php:12
253
- msgid "Text color"
254
- msgstr "Barva textu"
255
-
256
- #: src/admin/views/metaboxes/box-appearance-controls.php:16
257
- msgid "Box width"
258
- msgstr "Box šířka"
259
-
260
- #: src/admin/views/metaboxes/box-appearance-controls.php:18,
261
- #: src/admin/views/metaboxes/box-appearance-controls.php:29
262
- msgid "Width in px"
263
- msgstr "Šířka v px"
264
-
265
- #: src/admin/views/metaboxes/box-appearance-controls.php:23
266
- msgid "Border color"
267
- msgstr "Barva ohraničení"
268
-
269
- #: src/admin/views/metaboxes/box-appearance-controls.php:27
270
- msgid "Border width"
271
- msgstr "Šířka ohraničení"
272
-
273
- #: src/admin/views/metaboxes/box-appearance-controls.php:32,
274
- #: src/admin/views/metaboxes/box-appearance-controls.php:40
275
- msgid "Border style"
276
- msgstr "Styl ohraničení"
277
-
278
- #: src/admin/views/metaboxes/box-appearance-controls.php:46
279
- msgid "<a href=\"%s\">Click here to reset all styling settings</a>."
280
- msgstr ""
281
- "<a href=\"%s\">Chcete-li obnovit všechna nastavení stylů klikněte zde</a>."
282
-
283
- #: src/admin/views/metaboxes/box-option-controls.php:11
284
- msgid "everywhere"
285
- msgstr "všude"
286
-
287
- #: src/admin/views/metaboxes/box-option-controls.php:12
288
- msgid "if page"
289
- msgstr "pokud stránka"
290
-
291
- #: src/admin/views/metaboxes/box-option-controls.php:13
292
- msgid "if post"
293
- msgstr "pokud příspěvek"
294
-
295
- #: src/admin/views/metaboxes/box-option-controls.php:14
296
- msgid "if post tag"
297
- msgstr "pokud tag příspěvku"
298
-
299
- #: src/admin/views/metaboxes/box-option-controls.php:15
300
- msgid "if post category"
301
- msgstr "pokud kategorie"
302
-
303
- #: src/admin/views/metaboxes/box-option-controls.php:16
304
- msgid "if post type"
305
- msgstr "pokud typ příspěvku"
306
-
307
- #: src/admin/views/metaboxes/box-option-controls.php:17
308
- msgid "if URL"
309
- msgstr "pokud URL"
310
-
311
- #: src/admin/views/metaboxes/box-option-controls.php:18
312
- msgid "if referer"
313
- msgstr "pokud referer"
314
-
315
- #: src/admin/views/metaboxes/box-option-controls.php:19
316
- msgid "if user"
317
- msgstr "pokud uživatel"
318
-
319
- #: src/admin/views/metaboxes/box-option-controls.php:38
320
- msgid "Load this box if"
321
- msgstr "Načíst tento box pokud"
322
-
323
- #: src/admin/views/metaboxes/box-option-controls.php:41
324
- msgid "Request matches"
325
- msgstr "Požádat o shodu"
326
-
327
- #: src/admin/views/metaboxes/box-option-controls.php:43
328
- msgid "any"
329
- msgstr "žádný"
330
-
331
- #: src/admin/views/metaboxes/box-option-controls.php:44
332
- msgid "all"
333
- msgstr "vše"
334
-
335
- #: src/admin/views/metaboxes/box-option-controls.php:46
336
- msgid "of the following conditions."
337
- msgstr "za následujících podmínek."
338
-
339
- #: src/admin/views/metaboxes/box-option-controls.php:56,
340
- #: src/admin/views/metaboxes/box-option-controls.php:216
341
- msgid "Remove rule"
342
- msgstr "Odstranit pravidlo"
343
-
344
- #: src/admin/views/metaboxes/box-option-controls.php:66,
345
- #: src/admin/views/metaboxes/box-option-controls.php:225
346
- msgid "is"
347
- msgstr "je"
348
-
349
- #: src/admin/views/metaboxes/box-option-controls.php:67,
350
- #: src/admin/views/metaboxes/box-option-controls.php:226
351
- msgid "is not"
352
- msgstr "není"
353
-
354
- #: src/admin/views/metaboxes/box-option-controls.php:70,
355
- #: src/admin/views/metaboxes/box-option-controls.php:229
356
- msgid "Leave empty for any or enter (comma-separated) names or ID's"
357
- msgstr ""
358
- "Ponechte prázdné pro všechny nebo zadejte (oddělené čárkami) jména nebo ID"
359
-
360
- #: src/admin/views/metaboxes/box-option-controls.php:78
361
- msgid "Add rule"
362
- msgstr "Přidat pravidlo"
363
-
364
- #: src/admin/views/metaboxes/box-option-controls.php:81
365
- msgid "Box Position"
366
- msgstr "Umístění boxu"
367
-
368
- #: src/admin/views/metaboxes/box-option-controls.php:87
369
- msgid "Top Left"
370
- msgstr "Vlevo nahoře"
371
-
372
- #: src/admin/views/metaboxes/box-option-controls.php:94
373
- msgid "Top Right"
374
- msgstr "Vpravo nahoře"
375
-
376
- #: src/admin/views/metaboxes/box-option-controls.php:103
377
- msgid "Center"
378
- msgstr "Střed"
379
-
380
- #: src/admin/views/metaboxes/box-option-controls.php:112
381
- msgid "Bottom Left"
382
- msgstr "Vlevo dole"
383
-
384
- #: src/admin/views/metaboxes/box-option-controls.php:119
385
- msgid "Bottom Right"
386
- msgstr "Vpravo dole"
387
-
388
- #: src/admin/views/metaboxes/box-option-controls.php:128
389
- msgid "Animation"
390
- msgstr "Animace"
391
-
392
- #: src/admin/views/metaboxes/box-option-controls.php:130
393
- msgid "Fade In"
394
- msgstr "pozvolna sílit"
395
-
396
- #: src/admin/views/metaboxes/box-option-controls.php:131
397
- msgid "Slide In"
398
- msgstr "zasunout"
399
-
400
- #: src/admin/views/metaboxes/box-option-controls.php:132
401
- msgid "Which animation type should be used to show the box when triggered?"
402
- msgstr "Který typ animace by měl být použit při zobrazení spouštěcího boxu?"
403
-
404
- #: src/admin/views/metaboxes/box-option-controls.php:136
405
- msgid "Auto-show box?"
406
- msgstr "Automatické zobrazení boxu?"
407
-
408
- #: src/admin/views/metaboxes/box-option-controls.php:138
409
- msgid "Never"
410
- msgstr "Nikdy"
411
-
412
- #: src/admin/views/metaboxes/box-option-controls.php:139
413
- msgid "Yes, after %s seconds on the page."
414
- msgstr "Ano, po %s sekundách na stránce."
415
-
416
- #: src/admin/views/metaboxes/box-option-controls.php:140
417
- msgid "Yes, when at %s of page height"
418
- msgstr "Ano, při %s výšky stránky"
419
-
420
- #: src/admin/views/metaboxes/box-option-controls.php:141
421
- msgid "Yes, when at element %s"
422
- msgstr "Ano, když na prvku %s"
423
-
424
- #: src/admin/views/metaboxes/box-option-controls.php:141
425
- msgid "Example: #comments"
426
- msgstr "Příklad: #comentáře"
427
-
428
- #: src/admin/views/metaboxes/box-option-controls.php:147
429
- msgid "Cookie expiration"
430
- msgstr "Vypršení platnosti cookie"
431
-
432
- #: src/admin/views/metaboxes/box-option-controls.php:152,
433
- #: src/admin/views/metaboxes/box-option-controls.php:157
434
- msgid "hours"
435
- msgstr "hodin"
436
-
437
- #: src/admin/views/metaboxes/box-option-controls.php:161
438
- msgid ""
439
- "After this box is triggered or dismissed, how many hours should it stay "
440
- "hidden?"
441
- msgstr ""
442
- "Po spuštění nebo odmítnutí tohoto boxu, kolik hodin by mělo zůstat skryto?"
443
-
444
- #: src/admin/views/metaboxes/box-option-controls.php:165
445
- msgid "Screen width"
446
- msgstr "Šířka obrazovky"
447
-
448
- #: src/admin/views/metaboxes/box-option-controls.php:170
449
- msgid "larger"
450
- msgstr "větší"
451
-
452
- #: src/admin/views/metaboxes/box-option-controls.php:170
453
- msgid "smaller"
454
- msgstr "menší"
455
-
456
- #: src/admin/views/metaboxes/box-option-controls.php:171
457
- msgid "Only show on screens %s than %s."
458
- msgstr "Zobrazovat se pouze na obrazovkách %s než %s."
459
-
460
- #: src/admin/views/metaboxes/box-option-controls.php:172
461
- msgid "Leave empty if you want to show the box on all screen sizes."
462
- msgstr ""
463
- "Ponechte prázdné, chcete-li zobrazit pole na všech velikostech obrazovky."
464
-
465
- #: src/admin/views/metaboxes/box-option-controls.php:177
466
- msgid "Auto-hide?"
467
- msgstr "Auto-skrývání?"
468
-
469
- #: src/admin/views/metaboxes/box-option-controls.php:181
470
- msgid "Hide box again when visitors scroll back up?"
471
- msgstr "Skrýt box znovu, když se návštěvníci posouvají zpět?"
472
-
473
- #: src/admin/views/metaboxes/box-option-controls.php:185
474
- msgid "Show close icon?"
475
- msgstr "Zobrazit ikonu zavřít?"
476
-
477
- #: src/admin/views/metaboxes/box-option-controls.php:190
478
- msgid ""
479
- "If you decide to hide the close icon, make sure to offer an alternative way "
480
- "to close the box."
481
- msgstr ""
482
- "Pokud se rozhodnete skrýt ikonu zavření, ujistěte se, že nabízíte "
483
- "alternativní způsob uzavření boxu."
484
-
485
- #: src/admin/views/metaboxes/box-option-controls.php:191
486
- msgid "Example: "
487
- msgstr "Příklad: "
488
-
489
- #: src/admin/views/metaboxes/need-help.php:2
490
- msgid "Please make sure to look at the following available resources."
491
- msgstr "Nezapomeňte se podívat na následující dostupné zdroje."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/boxzilla-es_ES.mo DELETED
Binary file
languages/boxzilla-es_ES.po DELETED
@@ -1,212 +0,0 @@
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/boxzilla-fr_FR.mo DELETED
Binary file
languages/boxzilla-fr_FR.po DELETED
@@ -1,211 +0,0 @@
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: 2016-06-09 11:58+0100\n"
6
- "Last-Translator: \n"
7
- "Language-Team: \n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "X-Generator: Poedit 1.5.5\n"
12
- "X-Poedit-Basepath: .\n"
13
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
14
- "X-Poedit-KeywordsList: __;_e\n"
15
- "X-Poedit-SearchPath-0: ..\n"
16
-
17
- #: ../includes/class-admin.php:58
18
- msgid "Box Options"
19
- msgstr "Options de boîte"
20
-
21
- #: ../includes/class-admin.php:67
22
- msgid "Need support?"
23
- msgstr "Besoin de support ?"
24
-
25
- #: ../includes/class-admin.php:75
26
- msgid "Donate $10, $20 or $50"
27
- msgstr "Donner 10 $, 20 $ ou 50 $"
28
-
29
- #: ../includes/class-admin.php:83
30
- msgid "About the developer"
31
- msgstr "A propos du développeur"
32
-
33
- #: ../includes/views/metabox-options.php:7
34
- msgid "Scroll Triggered Box Options"
35
- msgstr "Options de Scroll Triggered Box"
36
-
37
- #: ../includes/views/metabox-options.php:9
38
- msgid "Display Options"
39
- msgstr "Options d'affichage"
40
-
41
- #: ../includes/views/metabox-options.php:15
42
- msgid "Show this box"
43
- msgstr "Afficher cette boîte"
44
-
45
- #: ../includes/views/metabox-options.php:18
46
- msgid "Basic"
47
- msgstr "Basique"
48
-
49
- #: ../includes/views/metabox-options.php:19
50
- msgid "Everywhere"
51
- msgstr "Partout sur le site"
52
-
53
- #: ../includes/views/metabox-options.php:20
54
- msgid "if Post Type is"
55
- msgstr "Si le Post Type est"
56
-
57
- #: ../includes/views/metabox-options.php:21
58
- msgid "if Page is"
59
- msgstr "Si la page est"
60
-
61
- #: ../includes/views/metabox-options.php:22
62
- msgid "if Page is not"
63
- msgstr "Si la page n'est pas"
64
-
65
- #: ../includes/views/metabox-options.php:23
66
- msgid "if Post is"
67
- msgstr "Si l'article est"
68
-
69
- #: ../includes/views/metabox-options.php:25
70
- msgid "Advanced"
71
- msgstr "Avancé"
72
-
73
- #: ../includes/views/metabox-options.php:26
74
- msgid "Manual conditon"
75
- msgstr "Condition manuelle"
76
-
77
- #: ../includes/views/metabox-options.php:31
78
- msgid "Leave empty for any or enter (comma-separated) names or ID's"
79
- msgstr ""
80
- "Laisser vide pour tous ou une liste de noms ou d'ID séparés par des virgules"
81
-
82
- #: ../includes/views/metabox-options.php:39
83
- msgid "Add rule"
84
- msgstr "Ajouter une règle"
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
- "Pour des régles manuelles avancées, voir %sthe WordPress Conditional Tags "
93
- "Codex page%s."
94
-
95
- #: ../includes/views/metabox-options.php:45
96
- msgid "Box Position"
97
- msgstr "Position de la boîte"
98
-
99
- #: ../includes/views/metabox-options.php:48
100
- msgid "Top Left"
101
- msgstr "En haut à gauche"
102
-
103
- #: ../includes/views/metabox-options.php:49
104
- msgid "Top Right"
105
- msgstr "En haut à droite"
106
-
107
- #: ../includes/views/metabox-options.php:50
108
- msgid "Bottom Left"
109
- msgstr "En bas à gauche"
110
-
111
- #: ../includes/views/metabox-options.php:51
112
- msgid "Bottom Right"
113
- msgstr "En bas à droite"
114
-
115
- #: ../includes/views/metabox-options.php:57
116
- msgid "Trigger Point"
117
- msgstr "Seuil de déclenchement"
118
-
119
- #: ../includes/views/metabox-options.php:61
120
- msgid "of page height"
121
- msgstr "de la hauteur de la page"
122
-
123
- #: ../includes/views/metabox-options.php:64
124
- msgid "Element Selector"
125
- msgstr "Un élément précis dans la page"
126
-
127
- #: ../includes/views/metabox-options.php:70
128
- msgid "Example: #comments (element must exist or box won't be shown)"
129
- msgstr ""
130
- "Exemple: #comments (l'élément doit exister sinon la boîte n'apparaîtra pas)"
131
-
132
- #: ../includes/views/metabox-options.php:74
133
- msgid "Animation"
134
- msgstr "Animation"
135
-
136
- #: ../includes/views/metabox-options.php:76
137
- msgid "Fade In"
138
- msgstr "Fondu enchaîné"
139
-
140
- #: ../includes/views/metabox-options.php:77
141
- msgid "Slide In"
142
- msgstr "Glissement"
143
-
144
- #: ../includes/views/metabox-options.php:78
145
- msgid "Which animation type should be used to show the box when triggered?"
146
- msgstr "Quelle type d'animation lors de l'apparition de le boîte ?"
147
-
148
- #: ../includes/views/metabox-options.php:82
149
- msgid "Cookie expiration days"
150
- msgstr "Nombre de jours avant expiration du cookie"
151
-
152
- #: ../includes/views/metabox-options.php:85
153
- msgid "After closing the box, how many days should it stay hidden?"
154
- msgstr ""
155
- "Après la fermeture de la boîte, combien de jours avant qu'elle ne s'affiche "
156
- "à nouveau ?"
157
-
158
- #: ../includes/views/metabox-options.php:90
159
- msgid "Auto-hide?"
160
- msgstr "Masquage automatique ?"
161
-
162
- #: ../includes/views/metabox-options.php:92
163
- #: ../includes/views/metabox-options.php:101
164
- msgid "Yes"
165
- msgstr "Oui"
166
-
167
- #: ../includes/views/metabox-options.php:93
168
- #: ../includes/views/metabox-options.php:102
169
- msgid "No"
170
- msgstr "Non"
171
-
172
- #: ../includes/views/metabox-options.php:94
173
- msgid "Hide box again when visitors scroll back up?"
174
- msgstr ""
175
- "Masque la boîte à nouveau lorsque le visiteur revient en haut de page ?"
176
-
177
- #: ../includes/views/metabox-options.php:99
178
- msgid "Enable test mode?"
179
- msgstr "Activer le mode test ?"
180
-
181
- #: ../includes/views/metabox-options.php:103
182
- msgid ""
183
- "If test mode is enabled, the box will show up regardless of whether a cookie "
184
- "has been set."
185
- msgstr ""
186
- "Si le mode test est activé, la boîte va s'afficher indépendamment des "
187
- "cookies."
188
-
189
- #: ../includes/views/metabox-options.php:108
190
- msgid "Appearance"
191
- msgstr "Apparence"
192
-
193
- #: ../includes/views/metabox-options.php:112
194
- msgid "Background color"
195
- msgstr "Couleur de fond"
196
-
197
- #: ../includes/views/metabox-options.php:116
198
- msgid "Text color"
199
- msgstr "Couleur du texte"
200
-
201
- #: ../includes/views/metabox-options.php:120
202
- msgid "Box width"
203
- msgstr "Largeur de bordure"
204
-
205
- #: ../includes/views/metabox-options.php:126
206
- msgid "Border color"
207
- msgstr "Couleur de bordure"
208
-
209
- #: ../includes/views/metabox-options.php:130
210
- msgid "Border width"
211
- msgstr "Largeur de bordure"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/boxzilla-nl_NL.mo DELETED
Binary file
languages/boxzilla-nl_NL.po DELETED
@@ -1,209 +0,0 @@
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/boxzilla-ro_RO.mo DELETED
Binary file
languages/boxzilla-ro_RO.po DELETED
@@ -1,468 +0,0 @@
1
- # Copyright (C) 2016 boxzilla
2
- # This file is distributed under the same license as the boxzilla package.
3
- msgid ""
4
- msgstr ""
5
- "Project-Id-Version: boxzilla\n"
6
- "MIME-Version: 1.0\n"
7
- "Content-Type: text/plain; charset=UTF-8\n"
8
- "Content-Transfer-Encoding: 8bit\n"
9
- "PO-Revision-Date: 2017-02-22 19:48+0200\n"
10
- "X-Poedit-Basepath: ..\n"
11
- "X-Poedit-SourceCharset: UTF-8\n"
12
- "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
13
- "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
14
- "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
15
- "Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?"
16
- "2:1));\n"
17
- "POT-Creation-Date: \n"
18
- "Language-Team: \n"
19
- "X-Generator: Poedit 1.8.12\n"
20
- "Last-Translator: \n"
21
- "Language: ro\n"
22
- "X-Poedit-SearchPath-0: .\n"
23
- "X-Poedit-SearchPathExcluded-0: *.js\n"
24
-
25
- #: src/admin/class-admin.php:207
26
- msgid ""
27
- "Awesome, you are using Boxzilla! You can now safely <a href=\"%s"
28
- "\">deactivate the Scroll Triggered Boxes plugin</a>."
29
- msgstr ""
30
- "Super, folosești Boxzilla! Acum poți <a href=\"%s\">dezactiva în siguranță "
31
- "modulul Scroll Triggered Boxes</a>."
32
-
33
- #: src/admin/class-admin.php:341
34
- msgid "Box ID"
35
- msgstr "ID Casetă"
36
-
37
- #: src/admin/class-admin.php:347
38
- msgid "Box Title"
39
- msgstr "Titlu Casetă"
40
-
41
- #: src/admin/class-admin.php:415, src/admin/class-admin.php:417,
42
- #: src/admin/views/settings.php:7
43
- msgid "Settings"
44
- msgstr "Setări"
45
-
46
- #: src/admin/class-admin.php:427, src/admin/class-admin.php:429
47
- msgid "Extensions"
48
- msgstr "Extensii"
49
-
50
- #: src/admin/class-admin.php:615
51
- msgid "Enter a comma-separated list of values."
52
- msgstr "Introdu o listă de valori separate prin virgule."
53
-
54
- #: src/admin/class-admin.php:617
55
- msgid "Enter a comma-separated list of post slugs or post ID's.."
56
- msgstr ""
57
- "Introdu o listă de post slugs sau ID-uri ale postărilor separate prin "
58
- "virgule.."
59
-
60
- #: src/admin/class-admin.php:619
61
- msgid "Enter a comma-separated list of page slugs or page ID's.."
62
- msgstr ""
63
- "Introdu o listă de page slugs sau ID-uri ale paginilior separate prin "
64
- "virgule.."
65
-
66
- #: src/admin/class-admin.php:621
67
- msgid "Enter a comma-separated list of post types.."
68
- msgstr "Introdu o listă de tipuri de postări separate prin virgule.."
69
-
70
- #: src/admin/class-admin.php:623
71
- msgid "Enter a comma-separated list of relative URL's, eg /contact/"
72
- msgstr ""
73
- "Introdu o listă de link-uri relative, cum ar fi /contact/ separate prin "
74
- "virgule."
75
-
76
- #: src/admin/class-admin.php:689
77
- msgid "Box Appearance"
78
- msgstr "Aspect casetă"
79
-
80
- #: src/admin/class-admin.php:707
81
- msgid "Box Options"
82
- msgstr "Opțiuni casetă"
83
-
84
- #: src/admin/class-admin.php:725
85
- msgid "Looking for help?"
86
- msgstr "Cauți ajutor?"
87
-
88
- #: src/admin/class-admin.php:741
89
- msgid "Subscribe to our newsletter"
90
- msgstr "Abonează-te la noutăți"
91
-
92
- #: src/admin/class-review-notice.php:74
93
- msgid "You've been using Boxzilla for some time now; we hope you love it!"
94
- msgstr "Folosești Boxzilla de ceva timp; sperăm că îți place!"
95
-
96
- #: src/admin/class-review-notice.php:75
97
- msgid ""
98
- "If you do, please <a href=\"%s\">leave us a 5★ rating on WordPress.org</a>. "
99
- "It would be of great help to us."
100
- msgstr ""
101
- "Dacă da, te rugăm <a href=\"%s\">lasă-ne 5★ pe WordPress.org</a>. Ne-ar fi "
102
- "de mare ajutor."
103
-
104
- #: src/admin/class-review-notice.php:77
105
- msgid "Dismiss this notice."
106
- msgstr "Înlătură această notificare."
107
-
108
- #: src/admin/views/extensions.php:4
109
- msgid "Available Add-On Plugins"
110
- msgstr "Module Add-On disponibile"
111
-
112
- #: src/admin/views/extensions.php:6
113
- msgid ""
114
- "There are various add-ons available for Boxzilla which further enhance the "
115
- "functionality of the core plugin."
116
- msgstr ""
117
- "Sunt disponibile diferite add-on-uri disponibile pentru Boxzilla care vor "
118
- "îmbunătăți funcționalitatea modulului de bază."
119
-
120
- #: src/admin/views/extensions.php:9
121
- msgid ""
122
- "To gain instant access the premium add-on plugins listed here, <a href=\"%s"
123
- "\">have a look at our pricing</a>."
124
- msgstr ""
125
- "Pentru a primi acces instant la lista de module add-on premium listate aici, "
126
- "<a href=\"%s\">uită-te la prețurile noastre</a>."
127
-
128
- #: src/admin/views/extensions.php:18
129
- msgid "You will be redirected to the Boxzilla site in a few seconds.."
130
- msgstr "Vei fi redirecționat la site-ul Boxzilla în câteva secunde.."
131
-
132
- #: src/admin/views/extensions.php:19
133
- msgid "If not, please click here: %s."
134
- msgstr "Dacă nu, te rugam dă click aici: %s."
135
-
136
- #: src/admin/views/metaboxes/box-appearance-controls.php:2
137
- msgid ""
138
- "For the best experience when styling your box, please use the default "
139
- "WordPress visual editor."
140
- msgstr ""
141
- "Pentru cea mai bună experiență când iți stilizezi caseta, te rugăm folosește "
142
- "editorul vizual implicit al WordPress."
143
-
144
- #: src/admin/views/metaboxes/box-appearance-controls.php:8
145
- msgid "Background color"
146
- msgstr "Culoare de fundal"
147
-
148
- #: src/admin/views/metaboxes/box-appearance-controls.php:12
149
- msgid "Text color"
150
- msgstr "Culoare text"
151
-
152
- #: src/admin/views/metaboxes/box-appearance-controls.php:16
153
- msgid "Box width"
154
- msgstr "Lățime casetă"
155
-
156
- #: src/admin/views/metaboxes/box-appearance-controls.php:18,
157
- #: src/admin/views/metaboxes/box-appearance-controls.php:29
158
- msgid "Width in px"
159
- msgstr "Lățime în px"
160
-
161
- #: src/admin/views/metaboxes/box-appearance-controls.php:23
162
- msgid "Border color"
163
- msgstr "Culoare bordură"
164
-
165
- #: src/admin/views/metaboxes/box-appearance-controls.php:27
166
- msgid "Border width"
167
- msgstr "Lățime bordură"
168
-
169
- #: src/admin/views/metaboxes/box-appearance-controls.php:32,
170
- #: src/admin/views/metaboxes/box-appearance-controls.php:40
171
- msgid "Border style"
172
- msgstr "Stil bordură"
173
-
174
- #: src/admin/views/metaboxes/box-appearance-controls.php:46
175
- msgid "<a href=\"%s\">Click here to reset all styling settings</a>."
176
- msgstr ""
177
- "<a href=\"%s\">Apasă aici pentru a reseta toate setările de stilizare</a>."
178
-
179
- #: src/admin/views/metaboxes/box-option-controls.php:21
180
- msgid "Select a condition"
181
- msgstr "Alege o condiție"
182
-
183
- #: src/admin/views/metaboxes/box-option-controls.php:23
184
- msgid "everywhere"
185
- msgstr "peste tot"
186
-
187
- #: src/admin/views/metaboxes/box-option-controls.php:25
188
- msgid "if page"
189
- msgstr "dacă pagina"
190
-
191
- #: src/admin/views/metaboxes/box-option-controls.php:27
192
- msgid "if post"
193
- msgstr "dacă postarea"
194
-
195
- #: src/admin/views/metaboxes/box-option-controls.php:29
196
- msgid "if post tag"
197
- msgstr "dacă eticheta postării"
198
-
199
- #: src/admin/views/metaboxes/box-option-controls.php:31
200
- msgid "if post category"
201
- msgstr "dacă categoria postării"
202
-
203
- #: src/admin/views/metaboxes/box-option-controls.php:33
204
- msgid "if post type"
205
- msgstr "dacă tipul postării"
206
-
207
- #: src/admin/views/metaboxes/box-option-controls.php:35
208
- msgid "if URL"
209
- msgstr "dacă URL-ul"
210
-
211
- #: src/admin/views/metaboxes/box-option-controls.php:37
212
- msgid "if referer"
213
- msgstr "dacă referer-ul"
214
-
215
- #: src/admin/views/metaboxes/box-option-controls.php:75
216
- msgid "Load this box if"
217
- msgstr "Încarcă această casetă dacă"
218
-
219
- #: src/admin/views/metaboxes/box-option-controls.php:81
220
- msgid "Request matches"
221
- msgstr "Necesită potriviri"
222
-
223
- #: src/admin/views/metaboxes/box-option-controls.php:85
224
- msgid "any"
225
- msgstr "oricare"
226
-
227
- #: src/admin/views/metaboxes/box-option-controls.php:87
228
- msgid "all"
229
- msgstr "toate"
230
-
231
- #: src/admin/views/metaboxes/box-option-controls.php:91
232
- msgid "of the following conditions."
233
- msgstr "dintre următoarele condiții"
234
-
235
- #: src/admin/views/metaboxes/box-option-controls.php:133,
236
- #: src/admin/views/metaboxes/box-option-controls.php:421
237
- msgid "is"
238
- msgstr "este"
239
-
240
- #: src/admin/views/metaboxes/box-option-controls.php:135,
241
- #: src/admin/views/metaboxes/box-option-controls.php:423
242
- msgid "is not"
243
- msgstr "nu este"
244
-
245
- #: src/admin/views/metaboxes/box-option-controls.php:141,
246
- #: src/admin/views/metaboxes/box-option-controls.php:429
247
- msgid "Leave empty for any or enter (comma-separated) names or ID's"
248
- msgstr ""
249
- "Lăsați gol pentru oricare sau introdu (separate prin virgule) nume sau ID-uri"
250
-
251
- #: src/admin/views/metaboxes/box-option-controls.php:157
252
- msgid "Add rule"
253
- msgstr "Adaugă regulă"
254
-
255
- #: src/admin/views/metaboxes/box-option-controls.php:163
256
- msgid "Box Position"
257
- msgstr "Poziția casetei"
258
-
259
- #: src/admin/views/metaboxes/box-option-controls.php:175
260
- msgid "Top Left"
261
- msgstr "Stânga sus"
262
-
263
- #: src/admin/views/metaboxes/box-option-controls.php:189
264
- msgid "Top Right"
265
- msgstr "Dreapta sus"
266
-
267
- #: src/admin/views/metaboxes/box-option-controls.php:207
268
- msgid "Center"
269
- msgstr "Centru"
270
-
271
- #: src/admin/views/metaboxes/box-option-controls.php:225
272
- msgid "Bottom Left"
273
- msgstr "Stânga jos"
274
-
275
- #: src/admin/views/metaboxes/box-option-controls.php:239
276
- msgid "Bottom Right"
277
- msgstr "Dreapta jos"
278
-
279
- #: src/admin/views/metaboxes/box-option-controls.php:257
280
- msgid "Animation"
281
- msgstr "Animatie"
282
-
283
- #: src/admin/views/metaboxes/box-option-controls.php:261
284
- msgid "Fade In"
285
- msgstr "Decolorare"
286
-
287
- #: src/admin/views/metaboxes/box-option-controls.php:263
288
- msgid "Slide In"
289
- msgstr "Glisare"
290
-
291
- #: src/admin/views/metaboxes/box-option-controls.php:265
292
- msgid "Which animation type should be used to show the box when triggered?"
293
- msgstr "Cu ce animație ar trebui să apară caseta când este activată?"
294
-
295
- #: src/admin/views/metaboxes/box-option-controls.php:273
296
- msgid "Auto-show box?"
297
- msgstr "Arată automat caseta?"
298
-
299
- #: src/admin/views/metaboxes/box-option-controls.php:277
300
- msgid "Never"
301
- msgstr "Niciodată."
302
-
303
- #: src/admin/views/metaboxes/box-option-controls.php:279
304
- msgid "Yes, after %s seconds on the page."
305
- msgstr "Da, după %s secunde pe pagină."
306
-
307
- #: src/admin/views/metaboxes/box-option-controls.php:281
308
- msgid "Yes, when at %s of page height"
309
- msgstr "Da, când este la %s din înălțimea paginii"
310
-
311
- #: src/admin/views/metaboxes/box-option-controls.php:283
312
- msgid "Yes, when at element %s"
313
- msgstr "Da, când este la elementul %s"
314
-
315
- #: src/admin/views/metaboxes/box-option-controls.php:283
316
- msgid "Example: #comments"
317
- msgstr "Exemplu: #comments"
318
-
319
- #: src/admin/views/metaboxes/box-option-controls.php:295
320
- msgid "Cookie expiration"
321
- msgstr "Expirare cookie"
322
-
323
- #: src/admin/views/metaboxes/box-option-controls.php:305,
324
- #: src/admin/views/metaboxes/box-option-controls.php:315
325
- msgid "hours"
326
- msgstr "ore"
327
-
328
- #: src/admin/views/metaboxes/box-option-controls.php:323
329
- msgid ""
330
- "After this box is triggered or dismissed, how many hours should it stay "
331
- "hidden?"
332
- msgstr ""
333
- "După ce caseta este activată sau înlăturată, câte ore trebuie să fie ascunsă?"
334
-
335
- #: src/admin/views/metaboxes/box-option-controls.php:331
336
- msgid "Do not auto-show box on small screens?"
337
- msgstr "Nu arăta automat casetele pe ecranele mici?"
338
-
339
- #: src/admin/views/metaboxes/box-option-controls.php:335
340
- msgid "Do not auto-show on screens smaller than %s."
341
- msgstr "Nu arăta automat pe ecrane mai mici de %s."
342
-
343
- #: src/admin/views/metaboxes/box-option-controls.php:337
344
- msgid ""
345
- "Leave empty if you <strong>do</strong> want to auto-show the box on small "
346
- "screens."
347
- msgstr ""
348
- "Lasă gol dacă <strong>vrei</strong>să apară automat caseta pe ecranele mici."
349
-
350
- #: src/admin/views/metaboxes/box-option-controls.php:347
351
- msgid "Auto-hide?"
352
- msgstr "Ascunde automat?"
353
-
354
- #: src/admin/views/metaboxes/box-option-controls.php:355
355
- msgid "Hide box again when visitors scroll back up?"
356
- msgstr "Ascunde caseta când utilizatorii derulează sus?"
357
-
358
- #: src/admin/views/metaboxes/box-option-controls.php:363,
359
- #: src/admin/views/settings.php:20
360
- msgid "Enable test mode?"
361
- msgstr "Activează modul de test?"
362
-
363
- #: src/admin/views/metaboxes/box-option-controls.php:371,
364
- #: src/admin/views/settings.php:24
365
- msgid ""
366
- "If test mode is enabled, all boxes will show up regardless of whether a "
367
- "cookie has been set."
368
- msgstr ""
369
- "Dacă modul de test este activat, toate castele vor apărea chiar dacă un "
370
- "fișier cookie a fost setat."
371
-
372
- #: src/admin/views/metaboxes/need-help.php:2
373
- msgid "Please make sure to look at the following available resources."
374
- msgstr "Te rugăm să te uiți la următoarele resurse disponibile."
375
-
376
- #: src/default-actions.php:12, src/default-actions.php:24
377
- msgid "Boxzilla"
378
- msgstr "Boxzilla"
379
-
380
- #: src/default-actions.php:13
381
- msgid "Box"
382
- msgstr "Casetă"
383
-
384
- #: src/default-actions.php:14
385
- msgid "Add New"
386
- msgstr "Adaugă"
387
-
388
- #: src/default-actions.php:15
389
- msgid "Add New Box"
390
- msgstr "Adaugă o casetă noua"
391
-
392
- #: src/default-actions.php:16
393
- msgid "Edit Box"
394
- msgstr "Editează o casetă"
395
-
396
- #: src/default-actions.php:17
397
- msgid "New Box"
398
- msgstr "Casetă nouă"
399
-
400
- #: src/default-actions.php:18
401
- msgid "All Boxes"
402
- msgstr "Toate casetele"
403
-
404
- #: src/default-actions.php:19
405
- msgid "View Box"
406
- msgstr "Vezi caseta"
407
-
408
- #: src/default-actions.php:20
409
- msgid "Search Boxes"
410
- msgstr "Caută casete"
411
-
412
- #: src/default-actions.php:21
413
- msgid "No Boxes found"
414
- msgstr "Nicio casetă găsită"
415
-
416
- #: src/default-actions.php:22
417
- msgid "No Boxes found in Trash"
418
- msgstr "Nicio casetă găsită la gunoi"
419
-
420
- #: src/licensing/class-api.php:162
421
- msgid "The Boxzilla server returned an invalid response."
422
- msgstr "Serverul Boxzilla a întors un răspuns invalid."
423
-
424
- #: src/licensing/views/license-form.php:8
425
- msgid "License & Plugin Updates"
426
- msgstr "Licență & actualizări modul."
427
-
428
- #: src/licensing/views/license-form.php:13
429
- msgid ""
430
- "Warning! You are <u>not</u> receiving plugin updates for the following "
431
- "plugin(s):"
432
- msgstr "Atenție! <u>Nu</u> primești actualizări pentru următoarele module:"
433
-
434
- #: src/licensing/views/license-form.php:27
435
- msgid "License Key"
436
- msgstr "Licență"
437
-
438
- #: src/licensing/views/license-form.php:29
439
- msgid "Enter your license key.."
440
- msgstr "Introdu codul.."
441
-
442
- #: src/licensing/views/license-form.php:32
443
- msgid ""
444
- "The license key received when purchasing your premium Boxzilla plan. <a href="
445
- "\"%s\">You can find it here</a>."
446
- msgstr ""
447
- "Licența este primită când achiziționezi varianta premium a BoxZilla. <a href="
448
- "\"%s\">Îl poți găsi aici</a>."
449
-
450
- #: src/licensing/views/license-form.php:37
451
- msgid "License Status"
452
- msgstr "Status licență"
453
-
454
- #: src/licensing/views/license-form.php:41
455
- msgid "ACTIVE"
456
- msgstr "ACTIVĂ"
457
-
458
- #: src/licensing/views/license-form.php:41
459
- msgid "you are receiving plugin updates"
460
- msgstr "primești actualizări"
461
-
462
- #: src/licensing/views/license-form.php:43
463
- msgid "INACTIVE"
464
- msgstr "INACTIVĂ"
465
-
466
- #: src/licensing/views/license-form.php:43
467
- msgid "you are <strong>not</strong> receiving plugin updates"
468
- msgstr "<strong>nu</strong> primești acutalizări"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/boxzilla.pot CHANGED
@@ -13,123 +13,127 @@ msgstr ""
13
  "X-Poedit-SourceCharset: UTF-8\n"
14
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
 
16
- #: src/default-actions.php:12, src/default-actions.php:24
17
  msgid "Boxzilla"
18
  msgstr ""
19
 
20
- #: src/default-actions.php:13
21
  msgid "Box"
22
  msgstr ""
23
 
24
- #: src/default-actions.php:14
25
  msgid "Add New"
26
  msgstr ""
27
 
28
- #: src/default-actions.php:15
29
  msgid "Add New Box"
30
  msgstr ""
31
 
32
- #: src/default-actions.php:16
33
  msgid "Edit Box"
34
  msgstr ""
35
 
36
- #: src/default-actions.php:17
37
  msgid "New Box"
38
  msgstr ""
39
 
40
- #: src/default-actions.php:18
41
  msgid "All Boxes"
42
  msgstr ""
43
 
44
- #: src/default-actions.php:19
45
  msgid "View Box"
46
  msgstr ""
47
 
48
- #: src/default-actions.php:20
49
  msgid "Search Boxes"
50
  msgstr ""
51
 
52
- #: src/default-actions.php:21
53
  msgid "No Boxes found"
54
  msgstr ""
55
 
56
- #: src/default-actions.php:22
57
  msgid "No Boxes found in Trash"
58
  msgstr ""
59
 
60
- #: src/admin/class-admin.php:97
61
  msgid "Duplicate box"
62
  msgstr ""
63
 
64
- #: src/admin/class-admin.php:141
65
  msgid "Awesome, you are using Boxzilla! You can now safely <a href=\"%s\">deactivate the Scroll Triggered Boxes plugin</a>."
66
  msgstr ""
67
 
68
- #: src/admin/class-admin.php:213
69
  msgid "Box ID"
70
  msgstr ""
71
 
72
- #: src/admin/class-admin.php:216
73
  msgid "Box Title"
74
  msgstr ""
75
 
76
- #: src/admin/class-admin.php:251, src/admin/class-admin.php:252, src/admin/views/settings.php:7
77
  msgid "Settings"
78
  msgstr ""
79
 
80
- #: src/admin/class-admin.php:257, src/admin/class-admin.php:258
81
  msgid "Extensions"
82
  msgstr ""
83
 
84
- #: src/admin/class-admin.php:354, src/admin/views/metaboxes/box-option-controls.php:62
85
  msgid "and"
86
  msgstr ""
87
 
88
- #: src/admin/class-admin.php:355, src/admin/views/metaboxes/box-option-controls.php:61
89
  msgid "or"
90
  msgstr ""
91
 
92
- #: src/admin/class-admin.php:356
93
  msgid "Enter a comma-separated list of values."
94
  msgstr ""
95
 
96
- #: src/admin/class-admin.php:357
97
  msgid "Enter a comma-separated list of post slugs or post ID's.."
98
  msgstr ""
99
 
100
- #: src/admin/class-admin.php:358
101
  msgid "Enter a comma-separated list of page slugs or page ID's.."
102
  msgstr ""
103
 
104
- #: src/admin/class-admin.php:359
105
  msgid "Enter a comma-separated list of post types.."
106
  msgstr ""
107
 
108
- #: src/admin/class-admin.php:360
109
  msgid "Enter a comma-separated list of relative URL's, eg /contact/"
110
  msgstr ""
111
 
112
- #: src/admin/class-admin.php:391
113
  msgid "Box Appearance"
114
  msgstr ""
115
 
116
- #: src/admin/class-admin.php:400
117
  msgid "Box Options"
118
  msgstr ""
119
 
120
- #: src/admin/class-admin.php:409, src/admin/views/settings.php:40
121
  msgid "Looking for help?"
122
  msgstr ""
123
 
124
- #: src/admin/class-admin.php:417, src/admin/views/settings.php:45
125
  msgid "Our other plugins"
126
  msgstr ""
127
 
128
- #: src/admin/class-admin.php:425, src/admin/views/settings.php:50
129
  msgid "Subscribe to our newsletter"
130
  msgstr ""
131
 
132
- #: src/admin/class-menu.php:26, src/admin/class-menu.php:92, src/admin/class-menu.php:93
 
 
 
 
133
  msgid "Boxzilla Pop-ups"
134
  msgstr ""
135
 
@@ -137,23 +141,23 @@ msgstr ""
137
  msgid "Add to menu"
138
  msgstr ""
139
 
140
- #: src/admin/class-menu.php:127
141
  msgid "Custom Link"
142
  msgstr ""
143
 
144
- #: src/admin/class-review-notice.php:71
145
  msgid "You've been using Boxzilla for some time now; we hope you love it!"
146
  msgstr ""
147
 
148
- #: src/admin/class-review-notice.php:72
149
  msgid "If you do, please <a href=\"%s\">leave us a 5★ rating on WordPress.org</a>. It would be of great help to us."
150
  msgstr ""
151
 
152
- #: src/admin/class-review-notice.php:74
153
  msgid "Dismiss this notice."
154
  msgstr ""
155
 
156
- #: src/licensing/class-api.php:172
157
  msgid "The Boxzilla server returned an invalid response."
158
  msgstr ""
159
 
@@ -177,11 +181,19 @@ msgstr ""
177
  msgid "If not, please click here: %s."
178
  msgstr ""
179
 
180
- #: src/admin/views/settings.php:20, src/admin/views/metaboxes/box-option-controls.php:216
181
  msgid "Enable test mode?"
182
  msgstr ""
183
 
184
- #: src/admin/views/settings.php:24, src/admin/views/metaboxes/box-option-controls.php:220
 
 
 
 
 
 
 
 
185
  msgid "If test mode is enabled, all boxes will show up regardless of whether a cookie has been set."
186
  msgstr ""
187
 
@@ -189,42 +201,50 @@ msgstr ""
189
  msgid "License & Plugin Updates"
190
  msgstr ""
191
 
192
- #: src/licensing/views/license-form.php:14
193
  msgid "Warning! You are <u>not</u> receiving plugin updates for the following plugin(s):"
194
  msgstr ""
195
 
196
- #: src/licensing/views/license-form.php:40
 
 
 
 
197
  msgid "License Key"
198
  msgstr ""
199
 
200
- #: src/licensing/views/license-form.php:42
201
  msgid "Enter your license key.."
202
  msgstr ""
203
 
204
- #: src/licensing/views/license-form.php:47
205
  msgid "The license key received when purchasing your premium Boxzilla plan. <a href=\"%s\">You can find it here</a>."
206
  msgstr ""
207
 
208
- #: src/licensing/views/license-form.php:52
209
  msgid "License Status"
210
  msgstr ""
211
 
212
- #: src/licensing/views/license-form.php:57
213
  msgid "ACTIVE"
214
  msgstr ""
215
 
216
- #: src/licensing/views/license-form.php:57
217
  msgid "you are receiving plugin updates"
218
  msgstr ""
219
 
220
- #: src/licensing/views/license-form.php:61
221
  msgid "INACTIVE"
222
  msgstr ""
223
 
224
- #: src/licensing/views/license-form.php:61
225
  msgid "you are <strong>not</strong> receiving plugin updates"
226
  msgstr ""
227
 
 
 
 
 
228
  #: src/admin/views/metaboxes/box-appearance-controls.php:2
229
  msgid "For the best experience when styling your box, please use the default WordPress visual editor."
230
  msgstr ""
@@ -257,6 +277,26 @@ msgstr ""
257
  msgid "Border style"
258
  msgstr ""
259
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  #: src/admin/views/metaboxes/box-appearance-controls.php:46
261
  msgid "<a href=\"%s\">Click here to reset all styling settings</a>."
262
  msgstr ""
@@ -317,147 +357,155 @@ msgstr ""
317
  msgid "of the following conditions."
318
  msgstr ""
319
 
320
- #: src/admin/views/metaboxes/box-option-controls.php:72, src/admin/views/metaboxes/box-option-controls.php:240
321
  msgid "Remove rule"
322
  msgstr ""
323
 
324
- #: src/admin/views/metaboxes/box-option-controls.php:82, src/admin/views/metaboxes/box-option-controls.php:249
325
  msgid "is"
326
  msgstr ""
327
 
328
- #: src/admin/views/metaboxes/box-option-controls.php:83, src/admin/views/metaboxes/box-option-controls.php:250
329
  msgid "is not"
330
  msgstr ""
331
 
332
- #: src/admin/views/metaboxes/box-option-controls.php:84, src/admin/views/metaboxes/box-option-controls.php:251
333
  msgid "contains"
334
  msgstr ""
335
 
336
- #: src/admin/views/metaboxes/box-option-controls.php:85, src/admin/views/metaboxes/box-option-controls.php:252
337
  msgid "does not contain"
338
  msgstr ""
339
 
340
- #: src/admin/views/metaboxes/box-option-controls.php:88, src/admin/views/metaboxes/box-option-controls.php:255
341
  msgid "Leave empty for any or enter (comma-separated) names or ID's"
342
  msgstr ""
343
 
344
- #: src/admin/views/metaboxes/box-option-controls.php:98
345
  msgid "Add another rule"
346
  msgstr ""
347
 
348
- #: src/admin/views/metaboxes/box-option-controls.php:101
349
  msgid "Box Position"
350
  msgstr ""
351
 
352
- #: src/admin/views/metaboxes/box-option-controls.php:107
353
  msgid "Top Left"
354
  msgstr ""
355
 
356
- #: src/admin/views/metaboxes/box-option-controls.php:114
357
  msgid "Top Right"
358
  msgstr ""
359
 
360
- #: src/admin/views/metaboxes/box-option-controls.php:123
361
  msgid "Center"
362
  msgstr ""
363
 
364
- #: src/admin/views/metaboxes/box-option-controls.php:132
365
  msgid "Bottom Left"
366
  msgstr ""
367
 
368
- #: src/admin/views/metaboxes/box-option-controls.php:139
369
  msgid "Bottom Right"
370
  msgstr ""
371
 
372
- #: src/admin/views/metaboxes/box-option-controls.php:148
373
  msgid "Animation"
374
  msgstr ""
375
 
376
- #: src/admin/views/metaboxes/box-option-controls.php:150
377
  msgid "Fade In"
378
  msgstr ""
379
 
380
- #: src/admin/views/metaboxes/box-option-controls.php:151
381
  msgid "Slide In"
382
  msgstr ""
383
 
384
- #: src/admin/views/metaboxes/box-option-controls.php:152
385
  msgid "Which animation type should be used to show the box when triggered?"
386
  msgstr ""
387
 
388
- #: src/admin/views/metaboxes/box-option-controls.php:156
389
  msgid "Auto-show box?"
390
  msgstr ""
391
 
392
- #: src/admin/views/metaboxes/box-option-controls.php:158
393
  msgid "Never"
394
  msgstr ""
395
 
396
- #: src/admin/views/metaboxes/box-option-controls.php:159
397
  msgid "Yes, after %s seconds on the page."
398
  msgstr ""
399
 
400
- #: src/admin/views/metaboxes/box-option-controls.php:160
401
  msgid "Yes, when at %s of page height"
402
  msgstr ""
403
 
404
- #: src/admin/views/metaboxes/box-option-controls.php:161
405
  msgid "Yes, when at element %s"
406
  msgstr ""
407
 
408
- #: src/admin/views/metaboxes/box-option-controls.php:161
409
  msgid "Example: #comments"
410
  msgstr ""
411
 
412
- #: src/admin/views/metaboxes/box-option-controls.php:167
413
  msgid "Cookie expiration"
414
  msgstr ""
415
 
416
- #: src/admin/views/metaboxes/box-option-controls.php:172, src/admin/views/metaboxes/box-option-controls.php:177
 
 
 
 
417
  msgid "hours"
418
  msgstr ""
419
 
420
- #: src/admin/views/metaboxes/box-option-controls.php:181
 
 
 
 
421
  msgid "After this box is triggered or dismissed, how many hours should it stay hidden?"
422
  msgstr ""
423
 
424
- #: src/admin/views/metaboxes/box-option-controls.php:185
425
  msgid "Screen width"
426
  msgstr ""
427
 
428
- #: src/admin/views/metaboxes/box-option-controls.php:190
429
  msgid "larger"
430
  msgstr ""
431
 
432
- #: src/admin/views/metaboxes/box-option-controls.php:190
433
  msgid "smaller"
434
  msgstr ""
435
 
436
- #: src/admin/views/metaboxes/box-option-controls.php:191
437
- msgid "Only show on screens %s than %s."
438
  msgstr ""
439
 
440
- #: src/admin/views/metaboxes/box-option-controls.php:192
441
  msgid "Leave empty if you want to show the box on all screen sizes."
442
  msgstr ""
443
 
444
- #: src/admin/views/metaboxes/box-option-controls.php:197
445
  msgid "Auto-hide?"
446
  msgstr ""
447
 
448
- #: src/admin/views/metaboxes/box-option-controls.php:201
449
  msgid "Hide box again when visitors scroll back up?"
450
  msgstr ""
451
 
452
- #: src/admin/views/metaboxes/box-option-controls.php:205
453
  msgid "Show close icon?"
454
  msgstr ""
455
 
456
- #: src/admin/views/metaboxes/box-option-controls.php:210
457
  msgid "If you decide to hide the close icon, make sure to offer an alternative way to close the box."
458
  msgstr ""
459
 
460
- #: src/admin/views/metaboxes/box-option-controls.php:211
461
  msgid "Example: "
462
  msgstr ""
463
 
13
  "X-Poedit-SourceCharset: UTF-8\n"
14
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
 
16
+ #: src/default-actions.php:14, src/default-actions.php:26
17
  msgid "Boxzilla"
18
  msgstr ""
19
 
20
+ #: src/default-actions.php:15
21
  msgid "Box"
22
  msgstr ""
23
 
24
+ #: src/default-actions.php:16
25
  msgid "Add New"
26
  msgstr ""
27
 
28
+ #: src/default-actions.php:17
29
  msgid "Add New Box"
30
  msgstr ""
31
 
32
+ #: src/default-actions.php:18
33
  msgid "Edit Box"
34
  msgstr ""
35
 
36
+ #: src/default-actions.php:19
37
  msgid "New Box"
38
  msgstr ""
39
 
40
+ #: src/default-actions.php:20
41
  msgid "All Boxes"
42
  msgstr ""
43
 
44
+ #: src/default-actions.php:21
45
  msgid "View Box"
46
  msgstr ""
47
 
48
+ #: src/default-actions.php:22
49
  msgid "Search Boxes"
50
  msgstr ""
51
 
52
+ #: src/default-actions.php:23
53
  msgid "No Boxes found"
54
  msgstr ""
55
 
56
+ #: src/default-actions.php:24
57
  msgid "No Boxes found in Trash"
58
  msgstr ""
59
 
60
+ #: src/admin/class-admin.php:88
61
  msgid "Duplicate box"
62
  msgstr ""
63
 
64
+ #: src/admin/class-admin.php:133
65
  msgid "Awesome, you are using Boxzilla! You can now safely <a href=\"%s\">deactivate the Scroll Triggered Boxes plugin</a>."
66
  msgstr ""
67
 
68
+ #: src/admin/class-admin.php:202
69
  msgid "Box ID"
70
  msgstr ""
71
 
72
+ #: src/admin/class-admin.php:207
73
  msgid "Box Title"
74
  msgstr ""
75
 
76
+ #: src/admin/class-admin.php:246, src/admin/class-admin.php:247, src/admin/views/settings.php:7
77
  msgid "Settings"
78
  msgstr ""
79
 
80
+ #: src/admin/class-admin.php:252, src/admin/class-admin.php:253
81
  msgid "Extensions"
82
  msgstr ""
83
 
84
+ #: src/admin/class-admin.php:344, src/admin/views/metaboxes/box-option-controls.php:62
85
  msgid "and"
86
  msgstr ""
87
 
88
+ #: src/admin/class-admin.php:345, src/admin/views/metaboxes/box-option-controls.php:61
89
  msgid "or"
90
  msgstr ""
91
 
92
+ #: src/admin/class-admin.php:346
93
  msgid "Enter a comma-separated list of values."
94
  msgstr ""
95
 
96
+ #: src/admin/class-admin.php:347
97
  msgid "Enter a comma-separated list of post slugs or post ID's.."
98
  msgstr ""
99
 
100
+ #: src/admin/class-admin.php:348
101
  msgid "Enter a comma-separated list of page slugs or page ID's.."
102
  msgstr ""
103
 
104
+ #: src/admin/class-admin.php:349
105
  msgid "Enter a comma-separated list of post types.."
106
  msgstr ""
107
 
108
+ #: src/admin/class-admin.php:350
109
  msgid "Enter a comma-separated list of relative URL's, eg /contact/"
110
  msgstr ""
111
 
112
+ #: src/admin/class-admin.php:380
113
  msgid "Box Appearance"
114
  msgstr ""
115
 
116
+ #: src/admin/class-admin.php:389
117
  msgid "Box Options"
118
  msgstr ""
119
 
120
+ #: src/admin/class-admin.php:398, src/admin/views/settings.php:40
121
  msgid "Looking for help?"
122
  msgstr ""
123
 
124
+ #: src/admin/class-admin.php:406, src/admin/views/settings.php:45
125
  msgid "Our other plugins"
126
  msgstr ""
127
 
128
+ #: src/admin/class-admin.php:414, src/admin/views/settings.php:50
129
  msgid "Subscribe to our newsletter"
130
  msgstr ""
131
 
132
+ #: src/admin/class-admin.php:675
133
+ msgid "Boxes"
134
+ msgstr ""
135
+
136
+ #: src/admin/class-menu.php:25, src/admin/class-menu.php:92, src/admin/class-menu.php:93
137
  msgid "Boxzilla Pop-ups"
138
  msgstr ""
139
 
141
  msgid "Add to menu"
142
  msgstr ""
143
 
144
+ #: src/admin/class-menu.php:126
145
  msgid "Custom Link"
146
  msgstr ""
147
 
148
+ #: src/admin/class-review-notice.php:68
149
  msgid "You've been using Boxzilla for some time now; we hope you love it!"
150
  msgstr ""
151
 
152
+ #: src/admin/class-review-notice.php:69
153
  msgid "If you do, please <a href=\"%s\">leave us a 5★ rating on WordPress.org</a>. It would be of great help to us."
154
  msgstr ""
155
 
156
+ #: src/admin/class-review-notice.php:71
157
  msgid "Dismiss this notice."
158
  msgstr ""
159
 
160
+ #: src/licensing/class-api.php:164
161
  msgid "The Boxzilla server returned an invalid response."
162
  msgstr ""
163
 
181
  msgid "If not, please click here: %s."
182
  msgstr ""
183
 
184
+ #: src/admin/views/settings.php:20, src/admin/views/metaboxes/box-option-controls.php:225
185
  msgid "Enable test mode?"
186
  msgstr ""
187
 
188
+ #: src/admin/views/settings.php:22, src/admin/views/metaboxes/box-option-controls.php:208, src/admin/views/metaboxes/box-option-controls.php:216, src/admin/views/metaboxes/box-option-controls.php:227
189
+ msgid "Yes"
190
+ msgstr ""
191
+
192
+ #: src/admin/views/settings.php:23, src/admin/views/metaboxes/box-option-controls.php:209, src/admin/views/metaboxes/box-option-controls.php:217, src/admin/views/metaboxes/box-option-controls.php:228
193
+ msgid "No"
194
+ msgstr ""
195
+
196
+ #: src/admin/views/settings.php:24, src/admin/views/metaboxes/box-option-controls.php:229
197
  msgid "If test mode is enabled, all boxes will show up regardless of whether a cookie has been set."
198
  msgstr ""
199
 
201
  msgid "License & Plugin Updates"
202
  msgstr ""
203
 
204
+ #: src/licensing/views/license-form.php:15
205
  msgid "Warning! You are <u>not</u> receiving plugin updates for the following plugin(s):"
206
  msgstr ""
207
 
208
+ #: src/licensing/views/license-form.php:25
209
+ msgid "To fix this, please activate your license using the form below."
210
+ msgstr ""
211
+
212
+ #: src/licensing/views/license-form.php:45
213
  msgid "License Key"
214
  msgstr ""
215
 
216
+ #: src/licensing/views/license-form.php:47
217
  msgid "Enter your license key.."
218
  msgstr ""
219
 
220
+ #: src/licensing/views/license-form.php:56
221
  msgid "The license key received when purchasing your premium Boxzilla plan. <a href=\"%s\">You can find it here</a>."
222
  msgstr ""
223
 
224
+ #: src/licensing/views/license-form.php:61
225
  msgid "License Status"
226
  msgstr ""
227
 
228
+ #: src/licensing/views/license-form.php:66
229
  msgid "ACTIVE"
230
  msgstr ""
231
 
232
+ #: src/licensing/views/license-form.php:66
233
  msgid "you are receiving plugin updates"
234
  msgstr ""
235
 
236
+ #: src/licensing/views/license-form.php:70
237
  msgid "INACTIVE"
238
  msgstr ""
239
 
240
+ #: src/licensing/views/license-form.php:70
241
  msgid "you are <strong>not</strong> receiving plugin updates"
242
  msgstr ""
243
 
244
+ #: src/licensing/views/license-form.php:82
245
+ msgid "Save Changes"
246
+ msgstr ""
247
+
248
  #: src/admin/views/metaboxes/box-appearance-controls.php:2
249
  msgid "For the best experience when styling your box, please use the default WordPress visual editor."
250
  msgstr ""
277
  msgid "Border style"
278
  msgstr ""
279
 
280
+ #: src/admin/views/metaboxes/box-appearance-controls.php:34
281
+ msgid "Default"
282
+ msgstr ""
283
+
284
+ #: src/admin/views/metaboxes/box-appearance-controls.php:35
285
+ msgid "Solid"
286
+ msgstr ""
287
+
288
+ #: src/admin/views/metaboxes/box-appearance-controls.php:36
289
+ msgid "Dashed"
290
+ msgstr ""
291
+
292
+ #: src/admin/views/metaboxes/box-appearance-controls.php:37
293
+ msgid "Dotted"
294
+ msgstr ""
295
+
296
+ #: src/admin/views/metaboxes/box-appearance-controls.php:38
297
+ msgid "Double"
298
+ msgstr ""
299
+
300
  #: src/admin/views/metaboxes/box-appearance-controls.php:46
301
  msgid "<a href=\"%s\">Click here to reset all styling settings</a>."
302
  msgstr ""
357
  msgid "of the following conditions."
358
  msgstr ""
359
 
360
+ #: src/admin/views/metaboxes/box-option-controls.php:73, src/admin/views/metaboxes/box-option-controls.php:250
361
  msgid "Remove rule"
362
  msgstr ""
363
 
364
+ #: src/admin/views/metaboxes/box-option-controls.php:85, src/admin/views/metaboxes/box-option-controls.php:261
365
  msgid "is"
366
  msgstr ""
367
 
368
+ #: src/admin/views/metaboxes/box-option-controls.php:86, src/admin/views/metaboxes/box-option-controls.php:262
369
  msgid "is not"
370
  msgstr ""
371
 
372
+ #: src/admin/views/metaboxes/box-option-controls.php:87, src/admin/views/metaboxes/box-option-controls.php:263
373
  msgid "contains"
374
  msgstr ""
375
 
376
+ #: src/admin/views/metaboxes/box-option-controls.php:88, src/admin/views/metaboxes/box-option-controls.php:264
377
  msgid "does not contain"
378
  msgstr ""
379
 
380
+ #: src/admin/views/metaboxes/box-option-controls.php:91, src/admin/views/metaboxes/box-option-controls.php:267
381
  msgid "Leave empty for any or enter (comma-separated) names or ID's"
382
  msgstr ""
383
 
384
+ #: src/admin/views/metaboxes/box-option-controls.php:101
385
  msgid "Add another rule"
386
  msgstr ""
387
 
388
+ #: src/admin/views/metaboxes/box-option-controls.php:104
389
  msgid "Box Position"
390
  msgstr ""
391
 
392
+ #: src/admin/views/metaboxes/box-option-controls.php:111
393
  msgid "Top Left"
394
  msgstr ""
395
 
396
+ #: src/admin/views/metaboxes/box-option-controls.php:119
397
  msgid "Top Right"
398
  msgstr ""
399
 
400
+ #: src/admin/views/metaboxes/box-option-controls.php:129
401
  msgid "Center"
402
  msgstr ""
403
 
404
+ #: src/admin/views/metaboxes/box-option-controls.php:139
405
  msgid "Bottom Left"
406
  msgstr ""
407
 
408
+ #: src/admin/views/metaboxes/box-option-controls.php:147
409
  msgid "Bottom Right"
410
  msgstr ""
411
 
412
+ #: src/admin/views/metaboxes/box-option-controls.php:156
413
  msgid "Animation"
414
  msgstr ""
415
 
416
+ #: src/admin/views/metaboxes/box-option-controls.php:158
417
  msgid "Fade In"
418
  msgstr ""
419
 
420
+ #: src/admin/views/metaboxes/box-option-controls.php:159
421
  msgid "Slide In"
422
  msgstr ""
423
 
424
+ #: src/admin/views/metaboxes/box-option-controls.php:160
425
  msgid "Which animation type should be used to show the box when triggered?"
426
  msgstr ""
427
 
428
+ #: src/admin/views/metaboxes/box-option-controls.php:164
429
  msgid "Auto-show box?"
430
  msgstr ""
431
 
432
+ #: src/admin/views/metaboxes/box-option-controls.php:166
433
  msgid "Never"
434
  msgstr ""
435
 
436
+ #: src/admin/views/metaboxes/box-option-controls.php:167
437
  msgid "Yes, after %s seconds on the page."
438
  msgstr ""
439
 
440
+ #: src/admin/views/metaboxes/box-option-controls.php:168
441
  msgid "Yes, when at %s of page height"
442
  msgstr ""
443
 
444
+ #: src/admin/views/metaboxes/box-option-controls.php:169
445
  msgid "Yes, when at element %s"
446
  msgstr ""
447
 
448
+ #: src/admin/views/metaboxes/box-option-controls.php:169
449
  msgid "Example: #comments"
450
  msgstr ""
451
 
452
+ #: src/admin/views/metaboxes/box-option-controls.php:175
453
  msgid "Cookie expiration"
454
  msgstr ""
455
 
456
+ #: src/admin/views/metaboxes/box-option-controls.php:178
457
+ msgid "Triggered"
458
+ msgstr ""
459
+
460
+ #: src/admin/views/metaboxes/box-option-controls.php:180, src/admin/views/metaboxes/box-option-controls.php:185
461
  msgid "hours"
462
  msgstr ""
463
 
464
+ #: src/admin/views/metaboxes/box-option-controls.php:183
465
+ msgid "Dismissed"
466
+ msgstr ""
467
+
468
+ #: src/admin/views/metaboxes/box-option-controls.php:189
469
  msgid "After this box is triggered or dismissed, how many hours should it stay hidden?"
470
  msgstr ""
471
 
472
+ #: src/admin/views/metaboxes/box-option-controls.php:193
473
  msgid "Screen width"
474
  msgstr ""
475
 
476
+ #: src/admin/views/metaboxes/box-option-controls.php:198
477
  msgid "larger"
478
  msgstr ""
479
 
480
+ #: src/admin/views/metaboxes/box-option-controls.php:198
481
  msgid "smaller"
482
  msgstr ""
483
 
484
+ #: src/admin/views/metaboxes/box-option-controls.php:200
485
+ msgid "Only show on screens %1$s than %2$s."
486
  msgstr ""
487
 
488
+ #: src/admin/views/metaboxes/box-option-controls.php:201
489
  msgid "Leave empty if you want to show the box on all screen sizes."
490
  msgstr ""
491
 
492
+ #: src/admin/views/metaboxes/box-option-controls.php:206
493
  msgid "Auto-hide?"
494
  msgstr ""
495
 
496
+ #: src/admin/views/metaboxes/box-option-controls.php:210
497
  msgid "Hide box again when visitors scroll back up?"
498
  msgstr ""
499
 
500
+ #: src/admin/views/metaboxes/box-option-controls.php:214
501
  msgid "Show close icon?"
502
  msgstr ""
503
 
504
+ #: src/admin/views/metaboxes/box-option-controls.php:219
505
  msgid "If you decide to hide the close icon, make sure to offer an alternative way to close the box."
506
  msgstr ""
507
 
508
+ #: src/admin/views/metaboxes/box-option-controls.php:220
509
  msgid "Example: "
510
  msgstr ""
511
 
languages/index.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Do not put custom translations here as they will be overwritten during plugin updates.
5
+ *
6
+ * @see https://translate.wordpress.org/projects/wp-plugins/boxzilla/stable/
7
+ */
phpcs.xml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <ruleset name="rules">
3
+ <description>rules</description>
4
+ <file>src/</file>
5
+ <rule ref="WordPress-Core">
6
+ <exclude name="WordPress.PHP.YodaConditions" />
7
+ <exclude name="WordPress.DB.PreparedSQL.InterpolatedNotPrepared" />
8
+ <exclude name="WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare" />
9
+ <exclude name="WordPress.DB.PreparedSQL.NotPrepared" />
10
+ <exclude name="WordPress.WP.DeprecatedFunctions.get_settingsFound" />
11
+ </rule>
12
+
13
+ <rule ref="WordPress.WP.I18n">
14
+ <properties>
15
+ <property name="text_domain" type="array">
16
+ <element value="boxzilla" />
17
+ </property>
18
+ </properties>
19
+ </rule>
20
+
21
+ <rule ref="WordPress.WP.DeprecatedFunctions">
22
+ <properties>
23
+ <property name="minimum_supported_version" value="4.6"/>
24
+ </properties>
25
+ </rule>
26
+
27
+ <rule ref="WordPress.Files.FileName">
28
+ <properties>
29
+ <property name="strict_class_file_names" value="false"/>
30
+ </properties>
31
+ </rule>
32
+
33
+ <rule ref="WordPress.NamingConventions.ValidHookName">
34
+ <properties>
35
+ <property name="additionalWordDelimiters" value="-"/>
36
+ </properties>
37
+ </rule>
38
+
39
+ <rule ref="WordPress.WP.CronInterval">
40
+ <properties>
41
+ <property name="min_interval" value="60"/>
42
+ </properties>
43
+ </rule>
44
+
45
+ <arg name="colors" />
46
+ </ruleset>
readme.txt CHANGED
@@ -2,9 +2,9 @@
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, ibericode
5
- Requires at least: 4.1
6
  Tested up to: 5.3
7
- Stable tag: 3.2.15
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Requires PHP: 5.3
@@ -130,6 +130,15 @@ Have a look at the [frequently asked questions](https://wordpress.org/plugins/bo
130
  == Changelog ==
131
 
132
 
 
 
 
 
 
 
 
 
 
133
  #### 3.2.15 - Nov 6, 2019
134
 
135
  **Improvements**
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, ibericode
5
+ Requires at least: 4.6
6
  Tested up to: 5.3
7
+ Stable tag: 3.2.16
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Requires PHP: 5.3
130
  == Changelog ==
131
 
132
 
133
+ #### 3.2.16 - Nov 15, 2019
134
+
135
+ **Improvements**
136
+
137
+ Roll-back a change in version 3.2.15 that caused an issue with Boxzilla Theme Pack and Boxzilla WooCommerce.
138
+
139
+ Please make sure your [Boxzilla plugin license](https://my.boxzillaplugin.com/) is activated and then update Boxzilla Theme Pack and Boxzilla WooCommerce to the latest version.
140
+
141
+
142
  #### 3.2.15 - Nov 6, 2019
143
 
144
  **Improvements**
src/admin/class-admin.php CHANGED
@@ -8,832 +8,808 @@ use Boxzilla\Boxzilla;
8
  use WP_Post;
9
  use WP_Screen;
10
 
11
- class Admin
12
- {
13
-
14
- /**
15
- * @var Plugin $plugin
16
- */
17
- private $plugin;
18
-
19
- /**
20
- * @var Boxzilla
21
- */
22
- protected $boxzilla;
23
-
24
- /**
25
- * @var ReviewNotice
26
- */
27
- protected $review_notice;
28
-
29
- /**
30
- * @param Plugin $plugin
31
- * @param Boxzilla $boxzilla
32
- */
33
- public function __construct(Plugin $plugin, Boxzilla $boxzilla)
34
- {
35
- $this->plugin = $plugin;
36
- $this->boxzilla = $boxzilla;
37
- $this->review_notice = new ReviewNotice();
38
- }
39
-
40
- /**
41
- * Initialise the all admin related stuff
42
- */
43
- public function init()
44
- {
45
- // Load the plugin textdomain
46
- load_plugin_textdomain('boxzilla', null, basename($this->plugin->dir()) . '/languages');
47
-
48
- // action hooks
49
- $this->add_hooks();
50
- $this->run_migrations();
51
- $this->review_notice->init();
52
- }
53
-
54
- /**
55
- * Add necessary hooks
56
- */
57
- protected function add_hooks()
58
- {
59
- add_action('admin_init', array( $this, 'lazy_add_hooks' ));
60
- add_action('admin_init', array( $this, 'register' ));
61
- add_action('init', array( $this, 'listen_for_actions' ));
62
- add_action('admin_menu', array( $this, 'menu' ));
63
- add_action('admin_notices', array( $this, 'notices' ));
64
- add_action('save_post_boxzilla-box', array( $this, 'save_box_options' ), 20, 2);
65
- add_action('trashed_post', array( $this, 'flush_rules' ));
66
- add_action('untrashed_post', array( $this, 'flush_rules' ));
67
- add_filter( 'bulk_actions-edit-boxzilla-box', array( $this, 'bulk_action_add') );
68
- add_filter( 'handle_bulk_actions-edit-boxzilla-box', array( $this, 'bulk_action_handle' ), 10, 3 );
69
-
70
-
71
- }
72
-
73
- /**
74
- * Listen for admin actions.
75
- */
76
- public function listen_for_actions()
77
- {
78
- // triggered?
79
- $vars = array_merge($_POST, $_GET);
80
- if (empty($vars['_boxzilla_admin_action'])) {
81
- return false;
82
- }
83
-
84
- // authorized?
85
- if (! current_user_can('edit_posts')) {
86
- return false;
87
- }
88
-
89
- // fire action
90
- $action = $vars['_boxzilla_admin_action'];
91
- do_action('boxzilla_admin_' . $action);
92
-
93
- return true;
94
- }
95
-
96
- public function bulk_action_add( $bulk_actions ) {
97
- $bulk_actions['boxzilla_duplicate_box'] = __( 'Duplicate box', 'boxzilla');
98
- return $bulk_actions;
99
- }
100
-
101
- public function bulk_action_handle( $redirect_to, $doaction, $post_ids ) {
102
- if ( $doaction !== 'boxzilla_duplicate_box' || empty( $post_ids )) {
103
- return $redirect_to;
104
- }
105
-
106
- foreach ($post_ids as $post_id) {
107
- $post = get_post($post_id);
108
- if ( $post->post_type !== 'boxzilla-box' ) {
109
- continue;
110
- }
111
-
112
- $new_post_id = wp_insert_post(array(
113
- 'post_type' => $post->post_type,
114
- 'post_title' => $post->post_title,
115
- 'post_content' => $post->post_content,
116
- 'post_status' => 'draft',
117
- ));
118
-
119
- $options = get_post_meta($post_id, 'boxzilla_options', true);
120
- add_post_meta($new_post_id, 'boxzilla_options', $options);
121
-
122
- $this->flush_rules($new_post_id);
123
- }
124
-
125
- return $redirect_to;
126
- }
127
-
128
- /**
129
- * All logic for admin notices lives here.
130
- */
131
- public function notices()
132
- {
133
- global $pagenow,
134
- $current_screen;
135
-
136
- if (($pagenow === 'plugins.php' || ($current_screen && $current_screen->post_type === 'boxzilla-box'))
137
- && current_user_can('install_plugins')
138
- && is_plugin_active('scroll-triggered-boxes/index.php')) {
139
- $url = wp_nonce_url('plugins.php?action=deactivate&plugin=scroll-triggered-boxes/index.php', 'deactivate-plugin_' . 'scroll-triggered-boxes/index.php'); ?>
140
  <div class="notice notice-info">
141
- <p><?php printf(__('Awesome, you are using Boxzilla! You can now safely <a href="%s">deactivate the Scroll Triggered Boxes plugin</a>.', 'boxzilla'), $url); ?></p>
142
  </div>
143
  <?php
144
- }
145
- }
146
-
147
- /**
148
- * Checks current version against stored version & runs necessary update routines.
149
- *
150
- * @return bool
151
- */
152
- protected function run_migrations()
153
- {
154
-
155
- // Only run if db option is at older version than code constant
156
- $previous_version = get_option('boxzilla_version', '0');
157
- $current_version = $this->plugin->version();
158
-
159
- if (version_compare($current_version, $previous_version, '<=')) {
160
- return false;
161
- }
162
-
163
- $upgrade_routines = new Migrations($previous_version, $current_version, __DIR__ . '/migrations');
164
- $upgrade_routines->run();
165
- update_option('boxzilla_version', $current_version);
166
- }
167
-
168
- public function lazy_add_hooks()
169
- {
170
- global $pagenow;
171
-
172
- add_action('admin_enqueue_scripts', array( $this, 'load_assets' ));
173
- add_action('add_meta_boxes', array( $this, 'add_meta_boxes' ));
174
- add_filter('tiny_mce_before_init', array( $this, 'tinymce_init' ));
175
- add_filter('manage_edit-boxzilla-box_columns', array( $this, 'post_type_column_titles' ));
176
- add_action('manage_boxzilla-box_posts_custom_column', array( $this, 'post_type_column_content' ), 10, 2);
177
- add_filter('admin_footer_text', array( $this, 'admin_footer_text' ));
178
-
179
- if ($pagenow === 'plugins.php') {
180
- add_filter('plugin_action_links', array( $this, 'add_plugin_settings_link' ), 10, 2);
181
- add_filter('plugin_row_meta', array( $this, 'add_plugin_meta_links' ), 10, 2);
182
- }
183
- }
184
-
185
- /**
186
- * @param $post_id
187
- */
188
- public function post_type_column_box_id_content($post_id)
189
- {
190
- echo $post_id;
191
- }
192
-
193
- /**
194
- * @param $column
195
- * @param $post_id
196
- */
197
- public function post_type_column_content($column, $post_id)
198
- {
199
- $method_name = 'post_type_column_' . $column . '_content';
200
- if (method_exists($this, $method_name)) {
201
- call_user_func(array( $this, $method_name ), $post_id);
202
- }
203
- }
204
-
205
- /**
206
- * @param $columns
207
- *
208
- * @return mixed
209
- */
210
- public function post_type_column_titles($columns)
211
- {
212
- $columns = self::array_insert($columns, array(
213
- 'box_id' => __('Box ID', 'boxzilla')
214
- ), 1);
215
-
216
- $columns['title'] = __('Box Title', 'boxzilla');
217
-
218
- return $columns;
219
- }
220
-
221
- /**
222
- * Register stuffs
223
- */
224
- public function register()
225
- {
226
-
227
- // register settings
228
- register_setting('boxzilla_settings', 'boxzilla_settings', array( $this, 'sanitize_settings' ));
229
-
230
- // register scripts
231
- $pre_suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
232
-
233
- wp_register_script('boxzilla-admin', $this->plugin->url('/assets/js/admin-script' . $pre_suffix . '.js'), array(
234
- 'jquery',
235
- 'wp-util',
236
- 'wp-color-picker',
237
- 'suggest'
238
- ), $this->plugin->version(), true);
239
-
240
- // load stylesheets
241
- wp_register_style('boxzilla-admin', $this->plugin->url('/assets/css/admin-styles' . $pre_suffix . '.css'), array(), $this->plugin->version());
242
- }
243
-
244
- /**
245
- * Renders the STB Menu items
246
- */
247
- public function menu()
248
- {
249
- $menu_items = array(
250
- array(
251
- __('Settings', 'boxzilla'),
252
- __('Settings', 'boxzilla'),
253
- 'boxzilla-settings',
254
- array( $this, 'show_settings_page' )
255
- ),
256
- array(
257
- __('Extensions', 'boxzilla'),
258
- '<span style="color: orange">' . __('Extensions', 'boxzilla') . '</span>',
259
- 'boxzilla-extensions',
260
- array( $this, 'show_extensions_page' )
261
- )
262
- );
263
-
264
- $menu_items = apply_filters('boxzilla_admin_menu_items', $menu_items);
265
-
266
- foreach ($menu_items as $item) {
267
- add_submenu_page('edit.php?post_type=boxzilla-box', $item[0] . '- Boxzilla', $item[1], 'manage_options', $item[2], $item[3]);
268
- }
269
- }
270
-
271
- /**
272
- * Shows the settings page
273
- */
274
- public function show_settings_page()
275
- {
276
- $opts = $this->boxzilla->options;
277
- require __DIR__ . '/views/settings.php';
278
- }
279
-
280
- /**
281
- * Shows the extensions page
282
- */
283
- public function show_extensions_page()
284
- {
285
- $extensions = $this->fetch_extensions();
286
- require __DIR__ . '/views/extensions.php';
287
- }
288
-
289
- /**
290
- * Are we currently editing a box?
291
- *
292
- * @return bool
293
- */
294
- protected function on_edit_box_page()
295
- {
296
- global $pagenow;
297
-
298
- if (! in_array($pagenow, array( 'post-new.php', 'post.php' ))) {
299
- return false;
300
- }
301
-
302
- if (isset($_GET['post_type']) && $_GET['post_type'] === 'boxzilla-box') {
303
- return true;
304
- }
305
-
306
- if (get_post_type() === 'boxzilla-box') {
307
- return true;
308
- }
309
-
310
- return false;
311
- }
312
-
313
- /**
314
- * @param $args
315
- *
316
- * @return mixed
317
- */
318
- public function tinymce_init($args)
319
- {
320
-
321
- // only act on our post type
322
- if (get_post_type() !== 'boxzilla-box') {
323
- return $args;
324
- }
325
-
326
- $args['setup'] = 'function( editor ) { if(typeof(window.Boxzilla_Admin) === \'undefined\') { return; } editor.on("PreInit", window.Boxzilla_Admin.Designer.init ); }';
327
-
328
- return $args;
329
- }
330
-
331
- /**
332
- * Load plugin assets
333
- */
334
- public function load_assets()
335
- {
336
- $screen = get_current_screen();
337
-
338
- if (! $screen instanceof WP_Screen) {
339
- return false;
340
- }
341
-
342
- if ($screen->base === 'edit' && $screen->post_type === 'boxzilla-box') {
343
- wp_enqueue_style('boxzilla-admin');
344
- }
345
-
346
- if ($screen->base === 'post' && $screen->post_type === 'boxzilla-box') {
347
- // color picker
348
- wp_enqueue_style('wp-color-picker');
349
-
350
- // load scripts
351
- wp_enqueue_script('boxzilla-admin');
352
-
353
- $data = array(
354
- 'and' => __('and', 'boxzilla'),
355
- 'or' => __('or', 'boxzilla'),
356
- 'enterCommaSeparatedValues' => __('Enter a comma-separated list of values.', 'boxzilla'),
357
- 'enterCommaSeparatedPosts' => __("Enter a comma-separated list of post slugs or post ID's..", 'boxzilla'),
358
- 'enterCommaSeparatedPages' => __("Enter a comma-separated list of page slugs or page ID's..", 'boxzilla'),
359
- 'enterCommaSeparatedPostTypes' => __("Enter a comma-separated list of post types..", 'boxzilla'),
360
- 'enterCommaSeparatedRelativeUrls' => __("Enter a comma-separated list of relative URL's, eg /contact/", 'boxzilla'),
361
- );
362
- wp_localize_script('boxzilla-admin', 'boxzilla_i18n', $data);
363
-
364
- // load stylesheets
365
- wp_enqueue_style('boxzilla-admin');
366
-
367
- // allow add-ons to easily load their own scripts or stylesheets
368
- do_action('boxzilla_load_admin_assets');
369
- }
370
-
371
- if (isset($_GET['page']) && $_GET['page'] === 'boxzilla-settings') {
372
- wp_enqueue_style('boxzilla-admin');
373
- }
374
- }
375
-
376
- /**
377
- * Register meta boxes
378
- *
379
- * @param string $post_type
380
- *
381
- * @return bool
382
- */
383
- public function add_meta_boxes($post_type)
384
- {
385
- if ($post_type !== 'boxzilla-box') {
386
- return false;
387
- }
388
-
389
- add_meta_box(
390
- 'boxzilla-box-appearance-controls',
391
- __('Box Appearance', 'boxzilla'),
392
- array( $this, 'metabox_box_appearance_controls' ),
393
- 'boxzilla-box',
394
- 'normal',
395
- 'core'
396
- );
397
-
398
- add_meta_box(
399
- 'boxzilla-box-options-controls',
400
- __('Box Options', 'boxzilla'),
401
- array( $this, 'metabox_box_option_controls' ),
402
- 'boxzilla-box',
403
- 'normal',
404
- 'core'
405
- );
406
-
407
- add_meta_box(
408
- 'boxzilla-support',
409
- __('Looking for help?', 'boxzilla'),
410
- array( $this, 'metabox_support' ),
411
- 'boxzilla-box',
412
- 'side'
413
- );
414
 
415
  add_meta_box(
416
  'boxzilla-our-other-plugins',
417
- __('Our other plugins', 'boxzilla'),
418
  array( $this, 'metabox_our_other_plugins' ),
419
  'boxzilla-box',
420
  'side'
421
  );
422
 
423
- add_meta_box(
424
- 'boxzilla-email-optin',
425
- __('Subscribe to our newsletter', 'boxzilla'),
426
- array( $this, 'metabox_email_optin' ),
427
- 'boxzilla-box',
428
- 'side'
429
- );
430
 
 
 
431
 
 
 
 
 
 
432
 
433
- return true;
434
- }
 
435
 
436
- /**
437
- * @param \WP_Post $post
438
- * @param $metabox
439
- */
440
- public function metabox_box_appearance_controls(\WP_Post $post, $metabox)
441
- {
442
 
443
- // get box options
444
- $box = new Box($post);
445
- $opts = $box->get_options();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
 
447
- // include view
448
- include __DIR__ . '/views/metaboxes/box-appearance-controls.php';
449
- }
 
 
 
 
450
 
451
- /**
452
- * @param \WP_Post $post
453
- * @param $metabox
454
- */
455
- public function metabox_box_option_controls(\WP_Post $post, $metabox)
456
- {
 
457
 
458
- // get box options
459
- $box = new Box($post);
460
- $opts = $box->get_options();
461
- $global_opts = $this->boxzilla->options;
 
 
 
462
 
463
- if (empty($opts['rules'])) {
464
- $opts['rules'][] = array( 'condition' => '', 'qualifier' => 1, 'value' => '' );
465
- }
466
 
467
- // include view
468
- include __DIR__ . '/views/metaboxes/box-option-controls.php';
469
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
470
 
471
- /**
472
- * @param \WP_Post $post
473
- * @param $metabox
474
- */
475
- public function metabox_email_optin(\WP_Post $post, $metabox)
476
- {
477
- include __DIR__ . '/views/metaboxes/email-optin.php';
478
- }
479
 
480
  /**
481
- * @param \WP_Post $post
482
- * @param $metabox
 
483
  */
484
- public function metabox_our_other_plugins(\WP_Post $post, $metabox)
485
- {
486
- include __DIR__ . '/views/metaboxes/our-other-plugins.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
  }
488
 
489
- /**
490
- * @param \WP_Post $post
491
- * @param $metabox
492
- */
493
- public function metabox_support(\WP_Post $post, $metabox)
494
- {
495
- include __DIR__ . '/views/metaboxes/need-help.php';
496
- }
497
-
498
-
499
- /**
500
- * Saves box options and rules
501
- *
502
- * @param int $box_id
503
- *
504
- * @return bool
505
- */
506
- public function save_box_options($box_id, $post)
507
- {
508
-
509
- // Only act on our own post type
510
- if ($post->post_type !== 'boxzilla-box') {
511
- return false;
512
- }
513
-
514
- // is this a revision save?
515
- if (wp_is_post_revision($box_id) || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
516
- return false;
517
- }
518
-
519
- // can user edit this post?
520
- if (! current_user_can('edit_post', $box_id)) {
521
- return false;
522
- }
523
-
524
- // make sure options array is set
525
- if (! isset($_POST['boxzilla_box']) || ! is_array($_POST['boxzilla_box'])) {
526
- return false;
527
- }
528
-
529
- // get new options from $_POST
530
- $opts = $this->sanitize_box_options($_POST['boxzilla_box']);
531
-
532
- // allow extensions to filter the saved options
533
- $opts = apply_filters('boxzilla_saved_options', $opts, $box_id);
534
-
535
- // save individual box settings
536
- update_post_meta($box_id, 'boxzilla_options', $opts);
537
-
538
- // update global settings if given
539
- if (! empty($_POST['boxzilla_global_settings'])) {
540
- $global_settings = get_option('boxzilla_settings', array());
541
- if (! is_array($global_settings)) {
542
- $global_settings = array();
543
- }
544
- $global_settings = array_merge($global_settings, $_POST['boxzilla_global_settings']);
545
- update_option('boxzilla_settings', $global_settings);
546
- }
547
-
548
- $this->flush_rules($box_id);
549
-
550
- return true;
551
- }
552
-
553
- /**
554
- * @param array $opts
555
- *
556
- * @return array
557
- */
558
- public function sanitize_settings($opts)
559
- {
560
- return $opts;
561
- }
562
-
563
- /**
564
- * @param string $url_string
565
- *
566
- * @return string
567
- */
568
- public function sanitize_url($url_string)
569
- {
570
-
571
- // if empty, just return a slash
572
- if (empty($url_string)) {
573
- return '/';
574
- }
575
-
576
- // if string looks like an absolute URL, extract just the path
577
- if (preg_match('/^((https|http)?\:\/\/)?(\w+\.)?\w+\.\w+\.*/i', $url_string)) {
578
-
579
- // make sure URL has scheme prepended, to make parse_url() understand..
580
- $url_string = 'https://' . str_replace(array( 'http://', 'https://' ), '', $url_string);
581
-
582
- // get just the path
583
- $url_string = parse_url($url_string, PHP_URL_PATH);
584
- }
585
-
586
- // leading slash it
587
- return $url_string;
588
- }
589
-
590
- /**
591
- * @param array $rule
592
- * @return array The sanitized rule array
593
- */
594
- public function sanitize_box_rule($rule)
595
- {
596
- $rule['value'] = trim($rule['value']);
597
-
598
- // convert to array
599
- $rule['value'] = explode(',', trim($rule['value'], ','));
600
-
601
- // trim all whitespace in value field
602
- $rule['value'] = array_map('trim', $rule['value']);
603
-
604
- // Make sure "is_url" values have a leading slash
605
- if ($rule['condition'] === 'is_url') {
606
- $rule['value'] = array_map(array( $this, 'sanitize_url' ), $rule['value']);
607
- }
608
-
609
- // (re)set value to 0 when condition is everywhere
610
- if ($rule['condition'] === 'everywhere') {
611
- $rule['value'] = '';
612
- }
613
-
614
- // convert back to string before saving
615
- if (is_array($rule['value'])) {
616
- $rule['value'] = join(',', $rule['value']);
617
- }
618
-
619
- return $rule;
620
- }
621
-
622
- /**
623
- * @param array $css
624
- * @return array
625
- */
626
- public function sanitize_box_css($css)
627
- {
628
-
629
- // sanitize settings
630
- if ('' !== $css['width']) {
631
- $css['width'] = absint($css['width']);
632
- }
633
-
634
- if ('' !== $css['border_width']) {
635
- $css['border_width'] = absint($css['border_width']);
636
- }
637
-
638
- // make sure colors start with `#`
639
- $color_keys = array( 'color', 'background_color', 'border_color' );
640
- foreach ($color_keys as $key) {
641
- $value = $css[ $key ];
642
- $color = sanitize_text_field($value);
643
-
644
- // make sure color starts with `#`
645
- if ('' !== $color && $color[0] !== '#') {
646
- $color = '#' . $color;
647
- }
648
- $css[ $key ] = $color;
649
- }
650
-
651
- return $css;
652
- }
653
-
654
- /**
655
- * Sanitize the options for this box.
656
- *
657
- * @param array $opts
658
- *
659
- * @return array
660
- */
661
- protected function sanitize_box_options($opts)
662
- {
663
- $defaults = array(
664
- 'rules' => array(),
665
- 'css' => array()
666
- );
667
-
668
- $opts = array_replace_recursive($defaults, $opts);
669
-
670
- $opts['rules'] = array_map(array( $this, 'sanitize_box_rule' ), $opts['rules']);
671
- $opts['css'] = $this->sanitize_box_css($opts['css']);
672
- $opts['cookie']['triggered'] = absint($opts['cookie']['triggered']);
673
- $opts['cookie']['dismissed'] = absint($opts['cookie']['dismissed']);
674
- $opts['trigger'] = sanitize_text_field($opts['trigger']);
675
- $opts['trigger_percentage'] = absint($opts['trigger_percentage']);
676
- $opts['trigger_element'] = sanitize_text_field($opts['trigger_element']);
677
- $opts['screen_size_condition']['value'] = intval($opts['screen_size_condition']['value']);
678
-
679
- return $opts;
680
- }
681
-
682
- /**
683
- * Add the settings link to the Plugins overview
684
- *
685
- * @param array $links
686
- * @param string $slug
687
- *
688
- * @return array
689
- */
690
- public function add_plugin_settings_link($links, $slug)
691
- {
692
- if ($slug !== $this->plugin->slug() || ! is_array($links)) {
693
- return $links;
694
- }
695
-
696
- $settings_link = '<a href="' . admin_url('edit.php?post_type=boxzilla-box') . '">' . __('Boxes') . '</a>';
697
- array_unshift($links, $settings_link);
698
-
699
- return $links;
700
- }
701
-
702
- /**
703
- * Adds meta links to the plugin in the WP Admin > Plugins screen
704
- *
705
- * @param array $links
706
- * @param string $slug
707
- *
708
- * @return array
709
- */
710
- public function add_plugin_meta_links($links, $slug)
711
- {
712
- if ($slug !== $this->plugin->slug()) {
713
- return $links;
714
- }
715
-
716
- $links[] = '<a href="https://kb.boxzillaplugin.com/#utm_source=wp-plugin&utm_medium=boxzilla&utm_campaign=plugins-page">Documentation</a>';
717
- $links[] = '<a href="https://boxzillaplugin.com/add-ons/#utm_source=wp-plugin&utm_medium=boxzilla&utm_campaign=plugins-page">Add-ons</a>';
718
-
719
- return $links;
720
- }
721
-
722
- /**
723
- * Flush all box rules
724
- *
725
- * Loops through all published boxes and fills the rules option
726
- *
727
- * @param int $post_id
728
- */
729
- public function flush_rules($post_id)
730
- {
731
-
732
- // only act on our own post type
733
- $post = get_post($post_id);
734
- if (! $post instanceof WP_Post || $post->post_type !== 'boxzilla-box') {
735
- return;
736
- }
737
-
738
- // get all published boxes
739
- $query = new \WP_Query;
740
- $boxes = $query->query(array(
741
- 'post_type' => 'boxzilla-box',
742
- 'post_status' => 'publish',
743
- 'posts_per_page' => - 1,
744
- 'ignore_sticky_posts' => true,
745
- 'no_found_rows' => true,
746
- ));
747
-
748
- // setup empty array of rules
749
- $rules = array();
750
-
751
- // fill rules array
752
- if (is_array($boxes)) {
753
- foreach ($boxes as $box) {
754
- // get box meta data
755
- $box_meta = get_post_meta($box->ID, 'boxzilla_options', true);
756
-
757
- // add box rules to all rules
758
- $rules[ $box->ID ] = (array) $box_meta['rules'];
759
- $rules[ $box->ID ]['comparision'] = isset($box_meta['rules_comparision']) ? $box_meta['rules_comparision'] : 'any';
760
- }
761
- }
762
-
763
- update_option('boxzilla_rules', $rules);
764
- }
765
-
766
- /**
767
- * Fetches a list of available add-on plugins
768
- *
769
- * @return array
770
- */
771
- protected function fetch_extensions()
772
- {
773
- $extensions = get_transient('boxzilla_remote_extensions');
774
- if ($extensions) {
775
- return $extensions;
776
- }
777
-
778
- $response = wp_remote_get('https://my.boxzillaplugin.com/api/v2/plugins');
779
- if (is_wp_error($response) || wp_remote_retrieve_response_code($response) >= 400) {
780
- return array();
781
- }
782
-
783
- $body = wp_remote_retrieve_body($response);
784
- $data = json_decode($body);
785
- if (is_array($data)) {
786
- set_transient('boxzilla_remote_extensions', $data, 24 * HOUR_IN_SECONDS);
787
- return $data;
788
- }
789
-
790
- return array();
791
- }
792
-
793
- /**
794
- * @param $arr
795
- * @param $insert
796
- * @param $position
797
- *
798
- * @return array
799
- */
800
- public static function array_insert($arr, $insert, $position)
801
- {
802
- $i = 0;
803
- $ret = array();
804
- foreach ($arr as $key => $value) {
805
- if ($i == $position) {
806
- foreach ($insert as $ikey => $ivalue) {
807
- $ret[ $ikey ] = $ivalue;
808
- }
809
- }
810
- $ret[ $key ] = $value;
811
- $i ++;
812
- }
813
-
814
- return $ret;
815
- }
816
-
817
- /**
818
- * @param string $text
819
- *
820
- * @return string
821
- */
822
- public function admin_footer_text($text)
823
- {
824
- $screen = get_current_screen();
825
-
826
- if (! $screen instanceof WP_Screen) {
827
- return $text;
828
- }
829
-
830
- $on_edit_page = $screen->parent_base === 'edit' && $screen->post_type === 'boxzilla-box';
831
- if ($on_edit_page) {
832
- 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');
833
- }
834
-
835
- return $text;
836
- }
837
 
838
 
839
  }
8
  use WP_Post;
9
  use WP_Screen;
10
 
11
+ class Admin {
12
+
13
+
14
+ /**
15
+ * @var Plugin $plugin
16
+ */
17
+ private $plugin;
18
+
19
+ /**
20
+ * @var Boxzilla
21
+ */
22
+ protected $boxzilla;
23
+
24
+ /**
25
+ * @var ReviewNotice
26
+ */
27
+ protected $review_notice;
28
+
29
+ /**
30
+ * @param Plugin $plugin
31
+ * @param Boxzilla $boxzilla
32
+ */
33
+ public function __construct( Plugin $plugin, Boxzilla $boxzilla ) {
34
+ $this->plugin = $plugin;
35
+ $this->boxzilla = $boxzilla;
36
+ $this->review_notice = new ReviewNotice();
37
+ }
38
+
39
+ /**
40
+ * Initialise the all admin related stuff
41
+ */
42
+ public function init() {
43
+ $this->add_hooks();
44
+ $this->run_migrations();
45
+ $this->review_notice->init();
46
+ }
47
+
48
+ /**
49
+ * Add necessary hooks
50
+ */
51
+ protected function add_hooks() {
52
+ add_action( 'admin_init', array( $this, 'lazy_add_hooks' ) );
53
+ add_action( 'admin_init', array( $this, 'register' ) );
54
+ add_action( 'init', array( $this, 'listen_for_actions' ) );
55
+ add_action( 'admin_menu', array( $this, 'menu' ) );
56
+ add_action( 'admin_notices', array( $this, 'notices' ) );
57
+ add_action( 'save_post_boxzilla-box', array( $this, 'save_box_options' ), 20, 2 );
58
+ add_action( 'trashed_post', array( $this, 'flush_rules' ) );
59
+ add_action( 'untrashed_post', array( $this, 'flush_rules' ) );
60
+ add_filter( 'bulk_actions-edit-boxzilla-box', array( $this, 'bulk_action_add' ) );
61
+ add_filter( 'handle_bulk_actions-edit-boxzilla-box', array( $this, 'bulk_action_handle' ), 10, 3 );
62
+
63
+ }
64
+
65
+ /**
66
+ * Listen for admin actions.
67
+ */
68
+ public function listen_for_actions() {
69
+ // triggered?
70
+ $vars = array_merge( $_POST, $_GET );
71
+ if ( empty( $vars['_boxzilla_admin_action'] ) ) {
72
+ return false;
73
+ }
74
+
75
+ // authorized?
76
+ if ( ! current_user_can( 'edit_posts' ) ) {
77
+ return false;
78
+ }
79
+
80
+ // fire action
81
+ $action = $vars['_boxzilla_admin_action'];
82
+ do_action( 'boxzilla_admin_' . $action );
83
+
84
+ return true;
85
+ }
86
+
87
+ public function bulk_action_add( $bulk_actions ) {
88
+ $bulk_actions['boxzilla_duplicate_box'] = __( 'Duplicate box', 'boxzilla' );
89
+ return $bulk_actions;
90
+ }
91
+
92
+ public function bulk_action_handle( $redirect_to, $doaction, $post_ids ) {
93
+ if ( $doaction !== 'boxzilla_duplicate_box' || empty( $post_ids ) ) {
94
+ return $redirect_to;
95
+ }
96
+
97
+ foreach ( $post_ids as $post_id ) {
98
+ $post = get_post( $post_id );
99
+ if ( $post->post_type !== 'boxzilla-box' ) {
100
+ continue;
101
+ }
102
+
103
+ $new_post_id = wp_insert_post(
104
+ array(
105
+ 'post_type' => $post->post_type,
106
+ 'post_title' => $post->post_title,
107
+ 'post_content' => $post->post_content,
108
+ 'post_status' => 'draft',
109
+ )
110
+ );
111
+
112
+ $options = get_post_meta( $post_id, 'boxzilla_options', true );
113
+ add_post_meta( $new_post_id, 'boxzilla_options', $options );
114
+
115
+ $this->flush_rules( $new_post_id );
116
+ }
117
+
118
+ return $redirect_to;
119
+ }
120
+
121
+ /**
122
+ * All logic for admin notices lives here.
123
+ */
124
+ public function notices() {
125
+ global $pagenow,
126
+ $current_screen;
127
+
128
+ if ( ( $pagenow === 'plugins.php' || ( $current_screen && $current_screen->post_type === 'boxzilla-box' ) )
129
+ && current_user_can( 'install_plugins' )
130
+ && is_plugin_active( 'scroll-triggered-boxes/index.php' ) ) {
131
+ $url = wp_nonce_url( 'plugins.php?action=deactivate&plugin=scroll-triggered-boxes/index.php', 'deactivate-plugin_' . 'scroll-triggered-boxes/index.php' ); ?>
 
 
 
 
 
 
 
 
132
  <div class="notice notice-info">
133
+ <p><?php printf( __( 'Awesome, you are using Boxzilla! You can now safely <a href="%s">deactivate the Scroll Triggered Boxes plugin</a>.', 'boxzilla' ), $url ); ?></p>
134
  </div>
135
  <?php
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Checks current version against stored version & runs necessary update routines.
141
+ *
142
+ * @return bool
143
+ */
144
+ protected function run_migrations() {
145
+
146
+ // Only run if db option is at older version than code constant
147
+ $previous_version = get_option( 'boxzilla_version', '0' );
148
+ $current_version = $this->plugin->version();
149
+
150
+ if ( version_compare( $current_version, $previous_version, '<=' ) ) {
151
+ return false;
152
+ }
153
+
154
+ $upgrade_routines = new Migrations( $previous_version, $current_version, __DIR__ . '/migrations' );
155
+ $upgrade_routines->run();
156
+ update_option( 'boxzilla_version', $current_version );
157
+ }
158
+
159
+ public function lazy_add_hooks() {
160
+ global $pagenow;
161
+
162
+ add_action( 'admin_enqueue_scripts', array( $this, 'load_assets' ) );
163
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
164
+ add_filter( 'tiny_mce_before_init', array( $this, 'tinymce_init' ) );
165
+ add_filter( 'manage_edit-boxzilla-box_columns', array( $this, 'post_type_column_titles' ) );
166
+ add_action( 'manage_boxzilla-box_posts_custom_column', array( $this, 'post_type_column_content' ), 10, 2 );
167
+ add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
168
+
169
+ if ( $pagenow === 'plugins.php' ) {
170
+ add_filter( 'plugin_action_links', array( $this, 'add_plugin_settings_link' ), 10, 2 );
171
+ add_filter( 'plugin_row_meta', array( $this, 'add_plugin_meta_links' ), 10, 2 );
172
+ }
173
+ }
174
+
175
+ /**
176
+ * @param $post_id
177
+ */
178
+ public function post_type_column_box_id_content( $post_id ) {
179
+ echo $post_id;
180
+ }
181
+
182
+ /**
183
+ * @param $column
184
+ * @param $post_id
185
+ */
186
+ public function post_type_column_content( $column, $post_id ) {
187
+ $method_name = 'post_type_column_' . $column . '_content';
188
+ if ( method_exists( $this, $method_name ) ) {
189
+ call_user_func( array( $this, $method_name ), $post_id );
190
+ }
191
+ }
192
+
193
+ /**
194
+ * @param $columns
195
+ *
196
+ * @return mixed
197
+ */
198
+ public function post_type_column_titles( $columns ) {
199
+ $columns = self::array_insert(
200
+ $columns,
201
+ array(
202
+ 'box_id' => __( 'Box ID', 'boxzilla' ),
203
+ ),
204
+ 1
205
+ );
206
+
207
+ $columns['title'] = __( 'Box Title', 'boxzilla' );
208
+
209
+ return $columns;
210
+ }
211
+
212
+ /**
213
+ * Register stuffs
214
+ */
215
+ public function register() {
216
+
217
+ // register settings
218
+ register_setting( 'boxzilla_settings', 'boxzilla_settings', array( $this, 'sanitize_settings' ) );
219
+
220
+ // register scripts
221
+ $pre_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
222
+
223
+ wp_register_script(
224
+ 'boxzilla-admin',
225
+ $this->plugin->url( '/assets/js/admin-script' . $pre_suffix . '.js' ),
226
+ array(
227
+ 'jquery',
228
+ 'wp-util',
229
+ 'wp-color-picker',
230
+ 'suggest',
231
+ ),
232
+ $this->plugin->version(),
233
+ true
234
+ );
235
+
236
+ // load stylesheets
237
+ wp_register_style( 'boxzilla-admin', $this->plugin->url( '/assets/css/admin-styles' . $pre_suffix . '.css' ), array(), $this->plugin->version() );
238
+ }
239
+
240
+ /**
241
+ * Renders the STB Menu items
242
+ */
243
+ public function menu() {
244
+ $menu_items = array(
245
+ array(
246
+ __( 'Settings', 'boxzilla' ),
247
+ __( 'Settings', 'boxzilla' ),
248
+ 'boxzilla-settings',
249
+ array( $this, 'show_settings_page' ),
250
+ ),
251
+ array(
252
+ __( 'Extensions', 'boxzilla' ),
253
+ '<span style="color: orange">' . __( 'Extensions', 'boxzilla' ) . '</span>',
254
+ 'boxzilla-extensions',
255
+ array( $this, 'show_extensions_page' ),
256
+ ),
257
+ );
258
+
259
+ $menu_items = apply_filters( 'boxzilla_admin_menu_items', $menu_items );
260
+
261
+ foreach ( $menu_items as $item ) {
262
+ add_submenu_page( 'edit.php?post_type=boxzilla-box', $item[0] . '- Boxzilla', $item[1], 'manage_options', $item[2], $item[3] );
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Shows the settings page
268
+ */
269
+ public function show_settings_page() {
270
+ $opts = $this->boxzilla->options;
271
+ require __DIR__ . '/views/settings.php';
272
+ }
273
+
274
+ /**
275
+ * Shows the extensions page
276
+ */
277
+ public function show_extensions_page() {
278
+ $extensions = $this->fetch_extensions();
279
+ require __DIR__ . '/views/extensions.php';
280
+ }
281
+
282
+ /**
283
+ * Are we currently editing a box?
284
+ *
285
+ * @return bool
286
+ */
287
+ protected function on_edit_box_page() {
288
+ global $pagenow;
289
+
290
+ if ( ! in_array( $pagenow, array( 'post-new.php', 'post.php' ), true ) ) {
291
+ return false;
292
+ }
293
+
294
+ if ( isset( $_GET['post_type'] ) && $_GET['post_type'] === 'boxzilla-box' ) {
295
+ return true;
296
+ }
297
+
298
+ if ( get_post_type() === 'boxzilla-box' ) {
299
+ return true;
300
+ }
301
+
302
+ return false;
303
+ }
304
+
305
+ /**
306
+ * @param $args
307
+ *
308
+ * @return mixed
309
+ */
310
+ public function tinymce_init( $args ) {
311
+
312
+ // only act on our post type
313
+ if ( get_post_type() !== 'boxzilla-box' ) {
314
+ return $args;
315
+ }
316
+
317
+ $args['setup'] = 'function( editor ) { if(typeof(window.Boxzilla_Admin) === \'undefined\') { return; } editor.on("PreInit", window.Boxzilla_Admin.Designer.init ); }';
318
+
319
+ return $args;
320
+ }
321
+
322
+ /**
323
+ * Load plugin assets
324
+ */
325
+ public function load_assets() {
326
+ $screen = get_current_screen();
327
+
328
+ if ( ! $screen instanceof WP_Screen ) {
329
+ return false;
330
+ }
331
+
332
+ if ( $screen->base === 'edit' && $screen->post_type === 'boxzilla-box' ) {
333
+ wp_enqueue_style( 'boxzilla-admin' );
334
+ }
335
+
336
+ if ( $screen->base === 'post' && $screen->post_type === 'boxzilla-box' ) {
337
+ // color picker
338
+ wp_enqueue_style( 'wp-color-picker' );
339
+
340
+ // load scripts
341
+ wp_enqueue_script( 'boxzilla-admin' );
342
+
343
+ $data = array(
344
+ 'and' => __( 'and', 'boxzilla' ),
345
+ 'or' => __( 'or', 'boxzilla' ),
346
+ 'enterCommaSeparatedValues' => __( 'Enter a comma-separated list of values.', 'boxzilla' ),
347
+ 'enterCommaSeparatedPosts' => __( "Enter a comma-separated list of post slugs or post ID's..", 'boxzilla' ),
348
+ 'enterCommaSeparatedPages' => __( "Enter a comma-separated list of page slugs or page ID's..", 'boxzilla' ),
349
+ 'enterCommaSeparatedPostTypes' => __( 'Enter a comma-separated list of post types..', 'boxzilla' ),
350
+ 'enterCommaSeparatedRelativeUrls' => __( "Enter a comma-separated list of relative URL's, eg /contact/", 'boxzilla' ),
351
+ );
352
+ wp_localize_script( 'boxzilla-admin', 'boxzilla_i18n', $data );
353
+
354
+ // load stylesheets
355
+ wp_enqueue_style( 'boxzilla-admin' );
356
+
357
+ // allow add-ons to easily load their own scripts or stylesheets
358
+ do_action( 'boxzilla_load_admin_assets' );
359
+ }
360
+
361
+ if ( isset( $_GET['page'] ) && $_GET['page'] === 'boxzilla-settings' ) {
362
+ wp_enqueue_style( 'boxzilla-admin' );
363
+ }
364
+ }
365
+
366
+ /**
367
+ * Register meta boxes
368
+ *
369
+ * @param string $post_type
370
+ *
371
+ * @return bool
372
+ */
373
+ public function add_meta_boxes( $post_type ) {
374
+ if ( $post_type !== 'boxzilla-box' ) {
375
+ return false;
376
+ }
377
+
378
+ add_meta_box(
379
+ 'boxzilla-box-appearance-controls',
380
+ __( 'Box Appearance', 'boxzilla' ),
381
+ array( $this, 'metabox_box_appearance_controls' ),
382
+ 'boxzilla-box',
383
+ 'normal',
384
+ 'core'
385
+ );
386
+
387
+ add_meta_box(
388
+ 'boxzilla-box-options-controls',
389
+ __( 'Box Options', 'boxzilla' ),
390
+ array( $this, 'metabox_box_option_controls' ),
391
+ 'boxzilla-box',
392
+ 'normal',
393
+ 'core'
394
+ );
395
+
396
+ add_meta_box(
397
+ 'boxzilla-support',
398
+ __( 'Looking for help?', 'boxzilla' ),
399
+ array( $this, 'metabox_support' ),
400
+ 'boxzilla-box',
401
+ 'side'
402
+ );
 
 
 
403
 
404
  add_meta_box(
405
  'boxzilla-our-other-plugins',
406
+ __( 'Our other plugins', 'boxzilla' ),
407
  array( $this, 'metabox_our_other_plugins' ),
408
  'boxzilla-box',
409
  'side'
410
  );
411
 
412
+ add_meta_box(
413
+ 'boxzilla-email-optin',
414
+ __( 'Subscribe to our newsletter', 'boxzilla' ),
415
+ array( $this, 'metabox_email_optin' ),
416
+ 'boxzilla-box',
417
+ 'side'
418
+ );
419
 
420
+ return true;
421
+ }
422
 
423
+ /**
424
+ * @param \WP_Post $post
425
+ * @param $metabox
426
+ */
427
+ public function metabox_box_appearance_controls( \WP_Post $post, $metabox ) {
428
 
429
+ // get box options
430
+ $box = new Box( $post );
431
+ $opts = $box->get_options();
432
 
433
+ // include view
434
+ include __DIR__ . '/views/metaboxes/box-appearance-controls.php';
435
+ }
 
 
 
436
 
437
+ /**
438
+ * @param \WP_Post $post
439
+ * @param $metabox
440
+ */
441
+ public function metabox_box_option_controls( \WP_Post $post, $metabox ) {
442
+
443
+ // get box options
444
+ $box = new Box( $post );
445
+ $opts = $box->get_options();
446
+ $global_opts = $this->boxzilla->options;
447
+
448
+ if ( empty( $opts['rules'] ) ) {
449
+ $opts['rules'][] = array(
450
+ 'condition' => '',
451
+ 'qualifier' => 1,
452
+ 'value' => '',
453
+ );
454
+ }
455
+
456
+ // include view
457
+ include __DIR__ . '/views/metaboxes/box-option-controls.php';
458
+ }
459
 
460
+ /**
461
+ * @param \WP_Post $post
462
+ * @param $metabox
463
+ */
464
+ public function metabox_email_optin( \WP_Post $post, $metabox ) {
465
+ include __DIR__ . '/views/metaboxes/email-optin.php';
466
+ }
467
 
468
+ /**
469
+ * @param \WP_Post $post
470
+ * @param $metabox
471
+ */
472
+ public function metabox_our_other_plugins( \WP_Post $post, $metabox ) {
473
+ include __DIR__ . '/views/metaboxes/our-other-plugins.php';
474
+ }
475
 
476
+ /**
477
+ * @param \WP_Post $post
478
+ * @param $metabox
479
+ */
480
+ public function metabox_support( \WP_Post $post, $metabox ) {
481
+ include __DIR__ . '/views/metaboxes/need-help.php';
482
+ }
483
 
 
 
 
484
 
485
+ /**
486
+ * Saves box options and rules
487
+ *
488
+ * @param int $box_id
489
+ *
490
+ * @return bool
491
+ */
492
+ public function save_box_options( $box_id, $post ) {
493
+
494
+ // Only act on our own post type
495
+ if ( $post->post_type !== 'boxzilla-box' ) {
496
+ return false;
497
+ }
498
+
499
+ // is this a revision save?
500
+ if ( wp_is_post_revision( $box_id ) || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) ) {
501
+ return false;
502
+ }
503
+
504
+ // can user edit this post?
505
+ if ( ! current_user_can( 'edit_post', $box_id ) ) {
506
+ return false;
507
+ }
508
+
509
+ // make sure options array is set
510
+ if ( ! isset( $_POST['boxzilla_box'] ) || ! is_array( $_POST['boxzilla_box'] ) ) {
511
+ return false;
512
+ }
513
+
514
+ // get new options from $_POST
515
+ $opts = $this->sanitize_box_options( $_POST['boxzilla_box'] );
516
+
517
+ // allow extensions to filter the saved options
518
+ $opts = apply_filters( 'boxzilla_saved_options', $opts, $box_id );
519
+
520
+ // save individual box settings
521
+ update_post_meta( $box_id, 'boxzilla_options', $opts );
522
+
523
+ // update global settings if given
524
+ if ( ! empty( $_POST['boxzilla_global_settings'] ) ) {
525
+ $global_settings = get_option( 'boxzilla_settings', array() );
526
+ if ( ! is_array( $global_settings ) ) {
527
+ $global_settings = array();
528
+ }
529
+ $global_settings = array_merge( $global_settings, $_POST['boxzilla_global_settings'] );
530
+ update_option( 'boxzilla_settings', $global_settings );
531
+ }
532
+
533
+ $this->flush_rules( $box_id );
534
+
535
+ return true;
536
+ }
537
 
538
+ /**
539
+ * @param array $opts
540
+ *
541
+ * @return array
542
+ */
543
+ public function sanitize_settings( $opts ) {
544
+ return $opts;
545
+ }
546
 
547
  /**
548
+ * @param string $url_string
549
+ *
550
+ * @return string
551
  */
552
+ public function sanitize_url( $url_string ) {
553
+
554
+ // if empty, just return a slash
555
+ if ( empty( $url_string ) ) {
556
+ return '/';
557
+ }
558
+
559
+ // if string looks like an absolute URL, extract just the path
560
+ if ( preg_match( '/^((https|http)?\:\/\/)?(\w+\.)?\w+\.\w+\.*/i', $url_string ) ) {
561
+
562
+ // make sure URL has scheme prepended, to make parse_url() understand..
563
+ $url_string = 'https://' . str_replace( array( 'http://', 'https://' ), '', $url_string );
564
+
565
+ // get just the path
566
+ $url_string = parse_url( $url_string, PHP_URL_PATH );
567
+ }
568
+
569
+ // leading slash it
570
+ return $url_string;
571
  }
572
 
573
+ /**
574
+ * @param array $rule
575
+ * @return array The sanitized rule array
576
+ */
577
+ public function sanitize_box_rule( $rule ) {
578
+ $rule['value'] = trim( $rule['value'] );
579
+
580
+ // convert to array
581
+ $rule['value'] = explode( ',', trim( $rule['value'], ',' ) );
582
+
583
+ // trim all whitespace in value field
584
+ $rule['value'] = array_map( 'trim', $rule['value'] );
585
+
586
+ // Make sure "is_url" values have a leading slash
587
+ if ( $rule['condition'] === 'is_url' ) {
588
+ $rule['value'] = array_map( array( $this, 'sanitize_url' ), $rule['value'] );
589
+ }
590
+
591
+ // (re)set value to 0 when condition is everywhere
592
+ if ( $rule['condition'] === 'everywhere' ) {
593
+ $rule['value'] = '';
594
+ }
595
+
596
+ // convert back to string before saving
597
+ if ( is_array( $rule['value'] ) ) {
598
+ $rule['value'] = join( ',', $rule['value'] );
599
+ }
600
+
601
+ return $rule;
602
+ }
603
+
604
+ /**
605
+ * @param array $css
606
+ * @return array
607
+ */
608
+ public function sanitize_box_css( $css ) {
609
+
610
+ // sanitize settings
611
+ if ( '' !== $css['width'] ) {
612
+ $css['width'] = absint( $css['width'] );
613
+ }
614
+
615
+ if ( '' !== $css['border_width'] ) {
616
+ $css['border_width'] = absint( $css['border_width'] );
617
+ }
618
+
619
+ // make sure colors start with `#`
620
+ $color_keys = array( 'color', 'background_color', 'border_color' );
621
+ foreach ( $color_keys as $key ) {
622
+ $value = $css[ $key ];
623
+ $color = sanitize_text_field( $value );
624
+
625
+ // make sure color starts with `#`
626
+ if ( '' !== $color && $color[0] !== '#' ) {
627
+ $color = '#' . $color;
628
+ }
629
+ $css[ $key ] = $color;
630
+ }
631
+
632
+ return $css;
633
+ }
634
+
635
+ /**
636
+ * Sanitize the options for this box.
637
+ *
638
+ * @param array $opts
639
+ *
640
+ * @return array
641
+ */
642
+ protected function sanitize_box_options( $opts ) {
643
+ $defaults = array(
644
+ 'rules' => array(),
645
+ 'css' => array(),
646
+ );
647
+
648
+ $opts = array_replace_recursive( $defaults, $opts );
649
+
650
+ $opts['rules'] = array_map( array( $this, 'sanitize_box_rule' ), $opts['rules'] );
651
+ $opts['css'] = $this->sanitize_box_css( $opts['css'] );
652
+ $opts['cookie']['triggered'] = absint( $opts['cookie']['triggered'] );
653
+ $opts['cookie']['dismissed'] = absint( $opts['cookie']['dismissed'] );
654
+ $opts['trigger'] = sanitize_text_field( $opts['trigger'] );
655
+ $opts['trigger_percentage'] = absint( $opts['trigger_percentage'] );
656
+ $opts['trigger_element'] = sanitize_text_field( $opts['trigger_element'] );
657
+ $opts['screen_size_condition']['value'] = intval( $opts['screen_size_condition']['value'] );
658
+
659
+ return $opts;
660
+ }
661
+
662
+ /**
663
+ * Add the settings link to the Plugins overview
664
+ *
665
+ * @param array $links
666
+ * @param string $slug
667
+ *
668
+ * @return array
669
+ */
670
+ public function add_plugin_settings_link( $links, $slug ) {
671
+ if ( $slug !== $this->plugin->slug() || ! is_array( $links ) ) {
672
+ return $links;
673
+ }
674
+
675
+ $settings_link = '<a href="' . admin_url( 'edit.php?post_type=boxzilla-box' ) . '">' . __( 'Boxes', 'boxzilla' ) . '</a>';
676
+ array_unshift( $links, $settings_link );
677
+
678
+ return $links;
679
+ }
680
+
681
+ /**
682
+ * Adds meta links to the plugin in the WP Admin > Plugins screen
683
+ *
684
+ * @param array $links
685
+ * @param string $slug
686
+ *
687
+ * @return array
688
+ */
689
+ public function add_plugin_meta_links( $links, $slug ) {
690
+ if ( $slug !== $this->plugin->slug() ) {
691
+ return $links;
692
+ }
693
+
694
+ $links[] = '<a href="https://kb.boxzillaplugin.com/#utm_source=wp-plugin&utm_medium=boxzilla&utm_campaign=plugins-page">Documentation</a>';
695
+ $links[] = '<a href="https://boxzillaplugin.com/add-ons/#utm_source=wp-plugin&utm_medium=boxzilla&utm_campaign=plugins-page">Add-ons</a>';
696
+
697
+ return $links;
698
+ }
699
+
700
+ /**
701
+ * Flush all box rules
702
+ *
703
+ * Loops through all published boxes and fills the rules option
704
+ *
705
+ * @param int $post_id
706
+ */
707
+ public function flush_rules( $post_id ) {
708
+
709
+ // only act on our own post type
710
+ $post = get_post( $post_id );
711
+ if ( ! $post instanceof WP_Post || $post->post_type !== 'boxzilla-box' ) {
712
+ return;
713
+ }
714
+
715
+ // get all published boxes
716
+ $query = new \WP_Query;
717
+ $boxes = $query->query(
718
+ array(
719
+ 'post_type' => 'boxzilla-box',
720
+ 'post_status' => 'publish',
721
+ 'posts_per_page' => - 1,
722
+ 'ignore_sticky_posts' => true,
723
+ 'no_found_rows' => true,
724
+ )
725
+ );
726
+
727
+ // setup empty array of rules
728
+ $rules = array();
729
+
730
+ // fill rules array
731
+ if ( is_array( $boxes ) ) {
732
+ foreach ( $boxes as $box ) {
733
+ // get box meta data
734
+ $box_meta = get_post_meta( $box->ID, 'boxzilla_options', true );
735
+
736
+ // add box rules to all rules
737
+ $rules[ $box->ID ] = (array) $box_meta['rules'];
738
+ $rules[ $box->ID ]['comparision'] = isset( $box_meta['rules_comparision'] ) ? $box_meta['rules_comparision'] : 'any';
739
+ }
740
+ }
741
+
742
+ update_option( 'boxzilla_rules', $rules );
743
+ }
744
+
745
+ /**
746
+ * Fetches a list of available add-on plugins
747
+ *
748
+ * @return array
749
+ */
750
+ protected function fetch_extensions() {
751
+ $extensions = get_transient( 'boxzilla_remote_extensions' );
752
+ if ( $extensions ) {
753
+ return $extensions;
754
+ }
755
+
756
+ $response = wp_remote_get( 'https://my.boxzillaplugin.com/api/v2/plugins' );
757
+ if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) >= 400 ) {
758
+ return array();
759
+ }
760
+
761
+ $body = wp_remote_retrieve_body( $response );
762
+ $data = json_decode( $body );
763
+ if ( is_array( $data ) ) {
764
+ set_transient( 'boxzilla_remote_extensions', $data, 24 * HOUR_IN_SECONDS );
765
+ return $data;
766
+ }
767
+
768
+ return array();
769
+ }
770
+
771
+ /**
772
+ * @param $arr
773
+ * @param $insert
774
+ * @param $position
775
+ *
776
+ * @return array
777
+ */
778
+ public static function array_insert( $arr, $insert, $position ) {
779
+ $i = 0;
780
+ $ret = array();
781
+ foreach ( $arr as $key => $value ) {
782
+ if ( $i == $position ) {
783
+ foreach ( $insert as $ikey => $ivalue ) {
784
+ $ret[ $ikey ] = $ivalue;
785
+ }
786
+ }
787
+ $ret[ $key ] = $value;
788
+ $i ++;
789
+ }
790
+
791
+ return $ret;
792
+ }
793
+
794
+ /**
795
+ * @param string $text
796
+ *
797
+ * @return string
798
+ */
799
+ public function admin_footer_text( $text ) {
800
+ $screen = get_current_screen();
801
+
802
+ if ( ! $screen instanceof WP_Screen ) {
803
+ return $text;
804
+ }
805
+
806
+ $on_edit_page = $screen->parent_base === 'edit' && $screen->post_type === 'boxzilla-box';
807
+ if ( $on_edit_page ) {
808
+ 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' );
809
+ }
810
+
811
+ return $text;
812
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
813
 
814
 
815
  }
src/admin/class-autocomplete.php CHANGED
@@ -2,100 +2,111 @@
2
 
3
  namespace Boxzilla\Filter;
4
 
5
- class Autocomplete
6
- {
7
- public function init()
8
- {
9
- add_action('wp_ajax_boxzilla_autocomplete', array( $this, 'ajax' ));
10
- }
11
-
12
- /**
13
- * AJAX listener for autocomplete
14
- */
15
- public function ajax()
16
- {
17
- $q = (isset($_GET['q'])) ? sanitize_text_field($_GET['q']) : '';
18
- $type = (isset($_GET['type']) && in_array($_GET['type'], array( 'page', 'post', 'category', 'post_type', 'post_tag' ))) ? $_GET['type'] : 'post';
19
-
20
- // do nothing if supplied 'q' parameter is omitted or empty
21
- // or less than 2 characters long
22
- if (empty($q) || strlen($q) < 2) {
23
- die();
24
- }
25
-
26
- switch ($type) {
27
-
28
- default:
29
- case 'post':
30
- case 'page':
31
- echo $this->list_posts($q, $type);
32
- break;
33
-
34
- case 'category':
35
- echo $this->list_categories($q);
36
- break;
37
-
38
- case 'post_type':
39
- echo $this->list_post_types($q);
40
- break;
41
-
42
- case 'post_tag':
43
- echo $this->list_tags($q);
44
- break;
45
- }
46
-
47
- die();
48
- }
49
-
50
- /**
51
- * @param string $query
52
- * @param string $post_type
53
- *
54
- * @return string
55
- */
56
- protected function list_posts($query, $post_type = 'post')
57
- {
58
- global $wpdb;
59
- $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 . '%%');
60
- $post_slugs = $wpdb->get_col($sql);
61
- return join($post_slugs, PHP_EOL);
62
- }
63
-
64
- /**
65
- * @param string $query
66
- *
67
- * @return string
68
- */
69
- protected function list_categories($query)
70
- {
71
- $terms = get_terms('category', array( 'name__like' => $query, 'fields' => 'names', 'hide_empty' => false ));
72
- return join($terms, PHP_EOL);
73
- }
74
-
75
- /**
76
- * @param string $query
77
- *
78
- * @return string
79
- */
80
- protected function list_tags($query)
81
- {
82
- $terms = get_terms('post_tag', array( 'name__like' => $query, 'fields' => 'names', 'hide_empty' => false ));
83
- return join($terms, PHP_EOL);
84
- }
85
-
86
-
87
- /**
88
- * @param string $query
89
- *
90
- * @return string
91
- */
92
- protected function list_post_types($query)
93
- {
94
- $post_types = get_post_types(array( 'public' => true ), 'names');
95
- $matched_post_types = array_filter($post_types, function ($name) use ($query) {
96
- return strpos($name, $query) === 0;
97
- });
98
-
99
- return join($matched_post_types, PHP_EOL);
100
- }
 
 
 
 
 
 
 
 
 
 
 
101
  }
2
 
3
  namespace Boxzilla\Filter;
4
 
5
+ class Autocomplete {
6
+
7
+ public function init() {
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', 'post_tag' ), true ) ) ? $_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
+ case 'post_tag':
41
+ echo $this->list_tags( $q );
42
+ break;
43
+ }
44
+
45
+ die();
46
+ }
47
+
48
+ /**
49
+ * @param string $query
50
+ * @param string $post_type
51
+ *
52
+ * @return string
53
+ */
54
+ protected function list_posts( $query, $post_type = 'post' ) {
55
+ global $wpdb;
56
+ $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 . '%%' );
57
+ $post_slugs = $wpdb->get_col( $sql );
58
+ return join( $post_slugs, PHP_EOL );
59
+ }
60
+
61
+ /**
62
+ * @param string $query
63
+ *
64
+ * @return string
65
+ */
66
+ protected function list_categories( $query ) {
67
+ $terms = get_terms(
68
+ 'category',
69
+ array(
70
+ 'name__like' => $query,
71
+ 'fields' => 'names',
72
+ 'hide_empty' => false,
73
+ )
74
+ );
75
+ return join( $terms, PHP_EOL );
76
+ }
77
+
78
+ /**
79
+ * @param string $query
80
+ *
81
+ * @return string
82
+ */
83
+ protected function list_tags( $query ) {
84
+ $terms = get_terms(
85
+ 'post_tag',
86
+ array(
87
+ 'name__like' => $query,
88
+ 'fields' => 'names',
89
+ 'hide_empty' => false,
90
+ )
91
+ );
92
+ return join( $terms, PHP_EOL );
93
+ }
94
+
95
+
96
+ /**
97
+ * @param string $query
98
+ *
99
+ * @return string
100
+ */
101
+ protected function list_post_types( $query ) {
102
+ $post_types = get_post_types( array( 'public' => true ), 'names' );
103
+ $matched_post_types = array_filter(
104
+ $post_types,
105
+ function ( $name ) use ( $query ) {
106
+ return strpos( $name, $query ) === 0;
107
+ }
108
+ );
109
+
110
+ return join( $matched_post_types, PHP_EOL );
111
+ }
112
  }
src/admin/class-installer.php CHANGED
@@ -3,96 +3,92 @@
3
 
4
  namespace Boxzilla\Admin;
5
 
6
- class Installer
7
- {
8
-
9
- /**
10
- * Run the installer
11
- */
12
- public static function run()
13
- {
14
- $installer = new self;
15
- $installer->install();
16
- }
17
-
18
- /**
19
- * The main install method
20
- */
21
- public function install()
22
- {
23
-
24
- // don't install sample boxes on multisite
25
- if (is_multisite()) {
26
- return;
27
- }
28
-
29
- $this->transfer_from_stb();
30
- $this->create_sample_box();
31
- }
32
-
33
- /**
34
- *
35
- */
36
- public function transfer_from_stb()
37
- {
38
- global $wpdb;
39
-
40
- // transfer post types
41
- $query = $wpdb->prepare("UPDATE {$wpdb->posts} SET post_type = %s WHERE post_type = %s", 'boxzilla-box', 'scroll-triggered-box');
42
- $wpdb->query($query);
43
-
44
- // transfer post meta
45
- $query = $wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_key = %s WHERE meta_key = %s", 'boxzilla_options', 'stb_options');
46
- $wpdb->query($query);
47
-
48
- // transfer rules
49
- $query = $wpdb->prepare("UPDATE {$wpdb->options} SET option_name = %s WHERE option_name = %s", 'boxzilla_rules', 'stb_rules');
50
- $wpdb->query($query);
51
- }
52
-
53
- /**
54
- * @return bool
55
- */
56
- protected function create_sample_box()
57
- {
58
-
59
- // only create sample box if no boxes were found
60
- $boxes = get_posts(
61
- array(
62
- 'post_type' => 'boxzilla-box',
63
- 'post_status' => array( 'publish', 'draft' )
64
- )
65
- );
66
-
67
- if (! empty($boxes)) {
68
- return false;
69
- }
70
-
71
- $box_id = wp_insert_post(
72
- array(
73
- 'post_type' => 'boxzilla-box',
74
- 'post_title' => "Sample Box",
75
- 'post_content' => "<h4>Hello world.</h4><p>This is a sample box, with some sample content in it.</p>",
76
- 'post_status' => 'draft',
77
- )
78
- );
79
-
80
- // set box settings
81
- $settings = array(
82
- 'css' => array(
83
- 'background_color' => '#edf9ff',
84
- 'color' => '',
85
- 'width' => '340',
86
- 'border_color' => '#dd7575',
87
- 'border_width' => '4',
88
- 'border_style' => 'dashed',
89
- 'position' => 'bottom-right',
90
- 'manual' => ''
91
- )
92
- );
93
-
94
- update_post_meta($box_id, 'boxzilla_options', $settings);
95
-
96
- return true;
97
- }
98
  }
3
 
4
  namespace Boxzilla\Admin;
5
 
6
+ class Installer {
7
+
8
+
9
+ /**
10
+ * Run the installer
11
+ */
12
+ public static function run() {
13
+ $installer = new self;
14
+ $installer->install();
15
+ }
16
+
17
+ /**
18
+ * The main install method
19
+ */
20
+ public function install() {
21
+
22
+ // don't install sample boxes on multisite
23
+ if ( is_multisite() ) {
24
+ return;
25
+ }
26
+
27
+ $this->transfer_from_stb();
28
+ $this->create_sample_box();
29
+ }
30
+
31
+ /**
32
+ *
33
+ */
34
+ public function transfer_from_stb() {
35
+ global $wpdb;
36
+
37
+ // transfer post types
38
+ $query = $wpdb->prepare( "UPDATE {$wpdb->posts} SET post_type = %s WHERE post_type = %s", 'boxzilla-box', 'scroll-triggered-box' );
39
+ $wpdb->query( $query );
40
+
41
+ // transfer post meta
42
+ $query = $wpdb->prepare( "UPDATE {$wpdb->postmeta} SET meta_key = %s WHERE meta_key = %s", 'boxzilla_options', 'stb_options' );
43
+ $wpdb->query( $query );
44
+
45
+ // transfer rules
46
+ $query = $wpdb->prepare( "UPDATE {$wpdb->options} SET option_name = %s WHERE option_name = %s", 'boxzilla_rules', 'stb_rules' );
47
+ $wpdb->query( $query );
48
+ }
49
+
50
+ /**
51
+ * @return bool
52
+ */
53
+ protected function create_sample_box() {
54
+
55
+ // only create sample box if no boxes were found
56
+ $boxes = get_posts(
57
+ array(
58
+ 'post_type' => 'boxzilla-box',
59
+ 'post_status' => array( 'publish', 'draft' ),
60
+ )
61
+ );
62
+
63
+ if ( ! empty( $boxes ) ) {
64
+ return false;
65
+ }
66
+
67
+ $box_id = wp_insert_post(
68
+ array(
69
+ 'post_type' => 'boxzilla-box',
70
+ 'post_title' => 'Sample Box',
71
+ 'post_content' => '<h4>Hello world.</h4><p>This is a sample box, with some sample content in it.</p>',
72
+ 'post_status' => 'draft',
73
+ )
74
+ );
75
+
76
+ // set box settings
77
+ $settings = array(
78
+ 'css' => array(
79
+ 'background_color' => '#edf9ff',
80
+ 'color' => '',
81
+ 'width' => '340',
82
+ 'border_color' => '#dd7575',
83
+ 'border_width' => '4',
84
+ 'border_style' => 'dashed',
85
+ 'position' => 'bottom-right',
86
+ 'manual' => '',
87
+ ),
88
+ );
89
+
90
+ update_post_meta( $box_id, 'boxzilla_options', $settings );
91
+
92
+ return true;
93
+ }
 
 
 
 
94
  }
src/admin/class-menu.php CHANGED
@@ -6,129 +6,128 @@ use Boxzilla\Plugin;
6
  use Boxzilla\Box;
7
  use Boxzilla\Boxzilla;
8
 
9
- class Menu
10
- {
11
- public function init()
12
- {
13
- add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
14
 
15
- // Include custom items to customizer nav menu settings.
16
- add_filter( 'customize_nav_menu_available_item_types', array( $this, 'register_customize_nav_menu_item_types' ) );
17
- add_filter( 'customize_nav_menu_available_items', array( $this, 'register_customize_nav_menu_items' ), 10, 4 );
18
- }
19
 
20
- /**
21
- * Add custom nav meta box.
22
- *
23
- * Adapted from http://www.johnmorrisonline.com/how-to-add-a-fully-functional-custom-meta-box-to-wordpress-navigation-menus/.
24
- */
25
- public function add_nav_menu_meta_boxes() {
26
- add_meta_box( 'boxzilla_nav_link', __( 'Boxzilla Pop-ups', 'boxzilla' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' );
27
- }
28
 
29
- private function get_boxes()
30
- {
31
- $q = new \WP_Query;
32
- $posts = $q->query(array(
33
- 'post_type' => 'boxzilla-box',
34
- 'post_status' => 'publish',
35
- 'posts_per_page' => -1,
36
- 'ignore_sticky_posts' => true,
37
- 'no_found_rows' => true,
38
- ));
39
- return $posts;
40
- }
41
 
42
- /**
43
- * Output menu links.
44
- */
45
- public function nav_menu_links() {
46
- $posts = $this->get_boxes();
 
 
 
 
 
 
 
 
47
 
48
- ?>
49
- <div id="posttype-boxzilla-boxes" class="posttypediv">
50
- <div id="tabs-panel-boxzilla-boxes" class="tabs-panel tabs-panel-active">
51
- <ul id="boxzilla-boxes-checklist" class="categorychecklist form-no-clear">
52
- <?php
53
- $i = -1;
54
- foreach ( $posts as $key => $post ) :
55
- ?>
56
- <li>
57
- <label class="menu-item-title">
58
- <input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-object-id]" value="<?php echo esc_attr( $i ); ?>" /> <?php echo esc_html( $post->post_title ); ?>
59
- </label>
60
- <input type="hidden" class="menu-item-type" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-type]" value="custom" />
61
- <input type="hidden" class="menu-item-title" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-title]" value="<?php echo esc_html( $post->post_title ); ?>" />
62
- <input type="hidden" class="menu-item-url" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-url]" value="<?php echo sprintf('#boxzilla-%d', $post->ID); ?>" />
63
- <input type="hidden" class="menu-item-classes" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-classes]" />
64
- </li>
65
- <?php
66
- $i--;
67
- endforeach;
68
- ?>
69
- </ul>
70
- </div>
71
- <p class="button-controls">
 
 
 
 
 
 
72
  <span class="list-controls">
73
  </span>
74
- <span class="add-to-menu">
75
  <button type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'boxzilla' ); ?>" name="add-post-type-menu-item" id="submit-posttype-boxzilla-boxes"><?php esc_html_e( 'Add to menu', 'boxzilla' ); ?></button>
76
  <span class="spinner"></span>
77
  </span>
78
- </p>
79
- </div>
80
- <?php
81
- }
82
-
83
- /**
84
- * Register customize new nav menu item types.
85
- *
86
- * @since 3.1.0
87
- * @param array $item_types Menu item types.
88
- * @return array
89
- */
90
- public function register_customize_nav_menu_item_types( $item_types ) {
91
- $item_types[] = array(
92
- 'title' => __( 'Boxzilla Pop-ups', 'boxzilla' ),
93
- 'type_label' => __( 'Boxzilla Pop-ups', 'boxzilla' ),
94
- 'type' => 'boxzilla_nav',
95
- 'object' => 'boxzilla_box',
96
- );
97
 
98
- return $item_types;
99
- }
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
- /**
102
- * Register account endpoints to customize nav menu items.
103
- *
104
- * @since 3.1.0
105
- * @param array $items List of nav menu items.
106
- * @param string $type Nav menu type.
107
- * @param string $object Nav menu object.
108
- * @param integer $page Page number.
109
- * @return array
110
- */
111
- public function register_customize_nav_menu_items( $items = array(), $type = '', $object = '', $page = 0 ) {
112
- if ( 'boxzilla_box' !== $object ) {
113
- return $items;
114
- }
115
 
116
- // Don't allow pagination since all items are loaded at once.
117
- if ( 0 < $page ) {
118
- return $items;
119
- }
 
 
 
 
 
 
 
 
 
 
120
 
 
 
 
 
121
 
122
- $boxes = $this->get_boxes();
123
- foreach ( $boxes as $i => $post ) {
124
- $items[] = array(
125
- 'id' => $i,
126
- 'title' => $post->post_title,
127
- 'type_label' => __( 'Custom Link', 'boxzilla' ),
128
- 'url' => sprintf('#boxzilla-%d', $post->ID),
129
- );
130
- }
131
 
132
- return $items;
133
- }
134
- }
6
  use Boxzilla\Box;
7
  use Boxzilla\Boxzilla;
8
 
9
+ class Menu {
 
 
 
 
10
 
11
+ public function init() {
12
+ add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
 
 
13
 
14
+ // Include custom items to customizer nav menu settings.
15
+ add_filter( 'customize_nav_menu_available_item_types', array( $this, 'register_customize_nav_menu_item_types' ) );
16
+ add_filter( 'customize_nav_menu_available_items', array( $this, 'register_customize_nav_menu_items' ), 10, 4 );
17
+ }
 
 
 
 
18
 
19
+ /**
20
+ * Add custom nav meta box.
21
+ *
22
+ * Adapted from http://www.johnmorrisonline.com/how-to-add-a-fully-functional-custom-meta-box-to-wordpress-navigation-menus/.
23
+ */
24
+ public function add_nav_menu_meta_boxes() {
25
+ add_meta_box( 'boxzilla_nav_link', __( 'Boxzilla Pop-ups', 'boxzilla' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' );
26
+ }
 
 
 
 
27
 
28
+ private function get_boxes() {
29
+ $q = new \WP_Query;
30
+ $posts = $q->query(
31
+ array(
32
+ 'post_type' => 'boxzilla-box',
33
+ 'post_status' => 'publish',
34
+ 'posts_per_page' => -1,
35
+ 'ignore_sticky_posts' => true,
36
+ 'no_found_rows' => true,
37
+ )
38
+ );
39
+ return $posts;
40
+ }
41
 
42
+ /**
43
+ * Output menu links.
44
+ */
45
+ public function nav_menu_links() {
46
+ $posts = $this->get_boxes();
47
+
48
+ ?>
49
+ <div id="posttype-boxzilla-boxes" class="posttypediv">
50
+ <div id="tabs-panel-boxzilla-boxes" class="tabs-panel tabs-panel-active">
51
+ <ul id="boxzilla-boxes-checklist" class="categorychecklist form-no-clear">
52
+ <?php
53
+ $i = -1;
54
+ foreach ( $posts as $key => $post ) :
55
+ ?>
56
+ <li>
57
+ <label class="menu-item-title">
58
+ <input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-object-id]" value="<?php echo esc_attr( $i ); ?>" /> <?php echo esc_html( $post->post_title ); ?>
59
+ </label>
60
+ <input type="hidden" class="menu-item-type" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-type]" value="custom" />
61
+ <input type="hidden" class="menu-item-title" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-title]" value="<?php echo esc_html( $post->post_title ); ?>" />
62
+ <input type="hidden" class="menu-item-url" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-url]" value="<?php echo sprintf( '#boxzilla-%d', $post->ID ); ?>" />
63
+ <input type="hidden" class="menu-item-classes" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-classes]" />
64
+ </li>
65
+ <?php
66
+ $i--;
67
+ endforeach;
68
+ ?>
69
+ </ul>
70
+ </div>
71
+ <p class="button-controls">
72
  <span class="list-controls">
73
  </span>
74
+ <span class="add-to-menu">
75
  <button type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'boxzilla' ); ?>" name="add-post-type-menu-item" id="submit-posttype-boxzilla-boxes"><?php esc_html_e( 'Add to menu', 'boxzilla' ); ?></button>
76
  <span class="spinner"></span>
77
  </span>
78
+ </p>
79
+ </div>
80
+ <?php
81
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
+ /**
84
+ * Register customize new nav menu item types.
85
+ *
86
+ * @since 3.1.0
87
+ * @param array $item_types Menu item types.
88
+ * @return array
89
+ */
90
+ public function register_customize_nav_menu_item_types( $item_types ) {
91
+ $item_types[] = array(
92
+ 'title' => __( 'Boxzilla Pop-ups', 'boxzilla' ),
93
+ 'type_label' => __( 'Boxzilla Pop-ups', 'boxzilla' ),
94
+ 'type' => 'boxzilla_nav',
95
+ 'object' => 'boxzilla_box',
96
+ );
97
 
98
+ return $item_types;
99
+ }
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
+ /**
102
+ * Register account endpoints to customize nav menu items.
103
+ *
104
+ * @since 3.1.0
105
+ * @param array $items List of nav menu items.
106
+ * @param string $type Nav menu type.
107
+ * @param string $object Nav menu object.
108
+ * @param integer $page Page number.
109
+ * @return array
110
+ */
111
+ public function register_customize_nav_menu_items( $items = array(), $type = '', $object = '', $page = 0 ) {
112
+ if ( 'boxzilla_box' !== $object ) {
113
+ return $items;
114
+ }
115
 
116
+ // Don't allow pagination since all items are loaded at once.
117
+ if ( 0 < $page ) {
118
+ return $items;
119
+ }
120
 
121
+ $boxes = $this->get_boxes();
122
+ foreach ( $boxes as $i => $post ) {
123
+ $items[] = array(
124
+ 'id' => $i,
125
+ 'title' => $post->post_title,
126
+ 'type_label' => __( 'Custom Link', 'boxzilla' ),
127
+ 'url' => sprintf( '#boxzilla-%d', $post->ID ),
128
+ );
129
+ }
130
 
131
+ return $items;
132
+ }
133
+ }
src/admin/class-migrations.php CHANGED
@@ -7,94 +7,90 @@ use Exception;
7
  /**
8
  *
9
  */
10
- class Migrations
11
- {
12
-
13
- /**
14
- * @var float
15
- */
16
- protected $version_from = 0;
17
-
18
- /**
19
- * @var float
20
- */
21
- protected $version_to = 0;
22
-
23
- /**
24
- * @var string
25
- */
26
- protected $migrations_dir = '';
27
-
28
- /**
29
- * @param float $from
30
- * @param float $to
31
- * @param string $migrations_dir
32
- */
33
- public function __construct($from, $to, $migrations_dir)
34
- {
35
- $this->version_from = $from;
36
- $this->version_to = $to;
37
- $this->migrations_dir = $migrations_dir;
38
- }
39
-
40
- /**
41
- * Run the various upgrade routines, all the way up to the latest version
42
- */
43
- public function run()
44
- {
45
- $migrations = $this->find_migrations();
46
- // run in sub-function for scope
47
- array_map(array( $this, 'run_migration' ), $migrations);
48
- }
49
-
50
- /**
51
- * @return array
52
- */
53
- public function find_migrations()
54
- {
55
- $files = glob(rtrim($this->migrations_dir, '/') . '/*.php');
56
- $migrations = array();
57
-
58
- // return empty array when glob returns non-array value.
59
- if (! is_array($files)) {
60
- return $migrations;
61
- }
62
-
63
- foreach ($files as $file) {
64
- $migration = basename($file);
65
- $parts = explode('-', $migration);
66
- $version = $parts[0];
67
-
68
- // check if migration file is not for an even higher version
69
- if (version_compare($version, $this->version_to, '>')) {
70
- continue;
71
- }
72
-
73
- // check if we ran migration file before.
74
- if (version_compare($this->version_from, $version, '>=')) {
75
- continue;
76
- }
77
-
78
- // schedule migration file for running
79
- $migrations[] = $file;
80
- }
81
-
82
- return $migrations;
83
- }
84
-
85
- /**
86
- * Include a migration file and runs it.
87
- *
88
- * @param string $file
89
- *
90
- * @throws Exception
91
- */
92
- protected function run_migration($file)
93
- {
94
- if (! file_exists($file)) {
95
- throw new Exception("Migration file $file does not exist.");
96
- }
97
-
98
- include $file;
99
- }
100
  }
7
  /**
8
  *
9
  */
10
+ class Migrations {
11
+
12
+
13
+ /**
14
+ * @var float
15
+ */
16
+ protected $version_from = 0;
17
+
18
+ /**
19
+ * @var float
20
+ */
21
+ protected $version_to = 0;
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ protected $migrations_dir = '';
27
+
28
+ /**
29
+ * @param float $from
30
+ * @param float $to
31
+ * @param string $migrations_dir
32
+ */
33
+ public function __construct( $from, $to, $migrations_dir ) {
34
+ $this->version_from = $from;
35
+ $this->version_to = $to;
36
+ $this->migrations_dir = $migrations_dir;
37
+ }
38
+
39
+ /**
40
+ * Run the various upgrade routines, all the way up to the latest version
41
+ */
42
+ public function run() {
43
+ $migrations = $this->find_migrations();
44
+ // run in sub-function for scope
45
+ array_map( array( $this, 'run_migration' ), $migrations );
46
+ }
47
+
48
+ /**
49
+ * @return array
50
+ */
51
+ public function find_migrations() {
52
+ $files = glob( rtrim( $this->migrations_dir, '/' ) . '/*.php' );
53
+ $migrations = array();
54
+
55
+ // return empty array when glob returns non-array value.
56
+ if ( ! is_array( $files ) ) {
57
+ return $migrations;
58
+ }
59
+
60
+ foreach ( $files as $file ) {
61
+ $migration = basename( $file );
62
+ $parts = explode( '-', $migration );
63
+ $version = $parts[0];
64
+
65
+ // check if migration file is not for an even higher version
66
+ if ( version_compare( $version, $this->version_to, '>' ) ) {
67
+ continue;
68
+ }
69
+
70
+ // check if we ran migration file before.
71
+ if ( version_compare( $this->version_from, $version, '>=' ) ) {
72
+ continue;
73
+ }
74
+
75
+ // schedule migration file for running
76
+ $migrations[] = $file;
77
+ }
78
+
79
+ return $migrations;
80
+ }
81
+
82
+ /**
83
+ * Include a migration file and runs it.
84
+ *
85
+ * @param string $file
86
+ *
87
+ * @throws Exception
88
+ */
89
+ protected function run_migration( $file ) {
90
+ if ( ! file_exists( $file ) ) {
91
+ throw new Exception( "Migration file $file does not exist." );
92
+ }
93
+
94
+ include $file;
95
+ }
 
 
 
 
96
  }
src/admin/class-notices.php CHANGED
@@ -2,45 +2,42 @@
2
 
3
  namespace Boxzilla\Admin;
4
 
5
- class Notices
6
- {
7
-
8
- /**
9
- * @var array
10
- */
11
- protected $notices = array();
12
-
13
- /**
14
- * Constructor
15
- */
16
- public function __construct()
17
- {
18
- add_action('admin_notices', array( $this, 'show' ));
19
- }
20
-
21
- /**
22
- * @param $message
23
- * @param $type
24
- *
25
- * @return $this
26
- */
27
- public function add($message, $type = 'updated')
28
- {
29
- $this->notices[] = array(
30
- 'message' => $message,
31
- 'type' => $type,
32
- );
33
-
34
- return $this;
35
- }
36
-
37
- /**
38
- * Output the registered notices
39
- */
40
- public function show()
41
- {
42
- foreach ($this->notices as $notice) {
43
- echo sprintf('<div class="notice notice-%s"><p>%s</p></div>', $notice['type'], $notice['message']);
44
- }
45
- }
46
  }
2
 
3
  namespace Boxzilla\Admin;
4
 
5
+ class Notices {
6
+
7
+
8
+ /**
9
+ * @var array
10
+ */
11
+ protected $notices = array();
12
+
13
+ /**
14
+ * Constructor
15
+ */
16
+ public function __construct() {
17
+ add_action( 'admin_notices', array( $this, 'show' ) );
18
+ }
19
+
20
+ /**
21
+ * @param $message
22
+ * @param $type
23
+ *
24
+ * @return $this
25
+ */
26
+ public function add( $message, $type = 'updated' ) {
27
+ $this->notices[] = array(
28
+ 'message' => $message,
29
+ 'type' => $type,
30
+ );
31
+
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * Output the registered notices
37
+ */
38
+ public function show() {
39
+ foreach ( $this->notices as $notice ) {
40
+ echo sprintf( '<div class="notice notice-%s"><p>%s</p></div>', $notice['type'], $notice['message'] );
41
+ }
42
+ }
 
 
 
43
  }
src/admin/class-review-notice.php CHANGED
@@ -9,86 +9,82 @@ use WP_Screen;
9
  *
10
  * @ignore
11
  */
12
- class ReviewNotice
13
- {
14
- /**
15
- * @var string
16
- */
17
- protected $meta_key_dismissed = '_boxzilla_review_notice_dismissed';
18
 
19
- /**
20
- * Add action & filter hooks.
21
- */
22
- public function init()
23
- {
24
- add_action('admin_notices', array( $this, 'show' ));
25
- add_action('boxzilla_admin_dismiss_review_notice', array( $this, 'dismiss' ));
26
- }
27
 
28
- /**
29
- * Set flag in user meta so notice won't be shown.
30
- */
31
- public function dismiss()
32
- {
33
- $user = wp_get_current_user();
34
- update_user_meta($user->ID, $this->meta_key_dismissed, 1);
35
- }
36
 
37
- /**
38
- * @return bool
39
- */
40
- public function show()
41
- {
42
- $screen = get_current_screen();
43
- if (! $screen instanceof WP_Screen) {
44
- return false;
45
- }
46
 
47
- // on some boxzilla screen?
48
- if ($screen->post_type !== 'boxzilla-box') {
49
- return false;
50
- }
 
 
 
 
51
 
52
- // authorized?
53
- if (! current_user_can('edit_posts')) {
54
- return false;
55
- }
56
 
57
- // only show if 2 weeks have passed since first use.
58
- $two_weeks_in_seconds = (60 * 60 * 24 * 14);
59
- if ($this->time_since_first_use() <= $two_weeks_in_seconds) {
60
- return false;
61
- }
62
 
63
- // only show if user did not dismiss before
64
- $user = wp_get_current_user();
65
- if (get_user_meta($user->ID, $this->meta_key_dismissed, true)) {
66
- return false;
67
- }
68
 
69
- echo '<div class="notice notice-info boxzilla-is-dismissible">';
70
- echo '<p>';
71
- echo __('You\'ve been using Boxzilla for some time now; we hope you love it!', 'boxzilla') . ' <br />';
72
- echo sprintf(__('If you do, please <a href="%s">leave us a 5★ rating on WordPress.org</a>. It would be of great help to us.', 'boxzilla'), 'https://wordpress.org/support/view/plugin-reviews/boxzilla?rate=5#new-post');
73
- echo '</p>';
74
- echo '<form method="POST"><button type="submit" class="notice-dismiss"><span class="screen-reader-text">'. __('Dismiss this notice.', 'boxzilla') .'</span></button><input type="hidden" name="_boxzilla_admin_action" value="dismiss_review_notice"/></form>';
75
- echo '</div>';
76
- return true;
77
- }
78
 
79
- /**
80
- * @return int
81
- */
82
- private function time_since_first_use()
83
- {
84
- $options = get_option('boxzilla_settings');
 
 
 
85
 
86
- // option was never added before, do it now.
87
- if (empty($options['first_activated_on'])) {
88
- $options['first_activated_on'] = time();
89
- update_option('boxzilla_settings', $options);
90
- }
91
 
92
- return time() - $options['first_activated_on'];
93
- }
 
 
 
 
 
 
94
  }
9
  *
10
  * @ignore
11
  */
12
+ class ReviewNotice {
 
 
 
 
 
13
 
14
+ /**
15
+ * @var string
16
+ */
17
+ protected $meta_key_dismissed = '_boxzilla_review_notice_dismissed';
 
 
 
 
18
 
19
+ /**
20
+ * Add action & filter hooks.
21
+ */
22
+ public function init() {
23
+ add_action( 'admin_notices', array( $this, 'show' ) );
24
+ add_action( 'boxzilla_admin_dismiss_review_notice', array( $this, 'dismiss' ) );
25
+ }
 
26
 
27
+ /**
28
+ * Set flag in user meta so notice won't be shown.
29
+ */
30
+ public function dismiss() {
31
+ $user = wp_get_current_user();
32
+ update_user_meta( $user->ID, $this->meta_key_dismissed, 1 );
33
+ }
 
 
34
 
35
+ /**
36
+ * @return bool
37
+ */
38
+ public function show() {
39
+ $screen = get_current_screen();
40
+ if ( ! $screen instanceof WP_Screen ) {
41
+ return false;
42
+ }
43
 
44
+ // on some boxzilla screen?
45
+ if ( $screen->post_type !== 'boxzilla-box' ) {
46
+ return false;
47
+ }
48
 
49
+ // authorized?
50
+ if ( ! current_user_can( 'edit_posts' ) ) {
51
+ return false;
52
+ }
 
53
 
54
+ // only show if 2 weeks have passed since first use.
55
+ $two_weeks_in_seconds = ( 60 * 60 * 24 * 14 );
56
+ if ( $this->time_since_first_use() <= $two_weeks_in_seconds ) {
57
+ return false;
58
+ }
59
 
60
+ // only show if user did not dismiss before
61
+ $user = wp_get_current_user();
62
+ if ( get_user_meta( $user->ID, $this->meta_key_dismissed, true ) ) {
63
+ return false;
64
+ }
 
 
 
 
65
 
66
+ echo '<div class="notice notice-info boxzilla-is-dismissible">';
67
+ echo '<p>';
68
+ echo __( 'You\'ve been using Boxzilla for some time now; we hope you love it!', 'boxzilla' ) . ' <br />';
69
+ echo sprintf( __( 'If you do, please <a href="%s">leave us a 5★ rating on WordPress.org</a>. It would be of great help to us.', 'boxzilla' ), 'https://wordpress.org/support/view/plugin-reviews/boxzilla?rate=5#new-post' );
70
+ echo '</p>';
71
+ echo '<form method="POST"><button type="submit" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'boxzilla' ) . '</span></button><input type="hidden" name="_boxzilla_admin_action" value="dismiss_review_notice"/></form>';
72
+ echo '</div>';
73
+ return true;
74
+ }
75
 
76
+ /**
77
+ * @return int
78
+ */
79
+ private function time_since_first_use() {
80
+ $options = get_option( 'boxzilla_settings' );
81
 
82
+ // option was never added before, do it now.
83
+ if ( empty( $options['first_activated_on'] ) ) {
84
+ $options['first_activated_on'] = time();
85
+ update_option( 'boxzilla_settings', $options );
86
+ }
87
+
88
+ return time() - $options['first_activated_on'];
89
+ }
90
  }
src/admin/migrations/3.1-cookie-option.php CHANGED
@@ -1,24 +1,24 @@
1
  <?php
2
 
3
- defined('ABSPATH') or exit;
4
 
5
- $posts = get_posts(array( 'post_type' => 'boxzilla-box' ));
6
 
7
- if (! empty($posts)) {
8
- foreach ($posts as $post) {
9
- $settings = get_post_meta($post->ID, 'boxzilla_options', true);
10
 
11
- if (! is_array($settings)) {
12
- continue;
13
- }
14
 
15
- // translate from days to hours
16
- $new_value = intval($settings['cookie']) * 24;
17
 
18
- // store in new location
19
- $settings['cookie'] = array(
20
- 'dismissed' => $new_value
21
- );
22
- update_post_meta($post->ID, 'boxzilla_options', $settings);
23
- }
24
  }
1
  <?php
2
 
3
+ defined( 'ABSPATH' ) or exit;
4
 
5
+ $posts = get_posts( array( 'post_type' => 'boxzilla-box' ) );
6
 
7
+ if ( ! empty( $posts ) ) {
8
+ foreach ( $posts as $post ) {
9
+ $settings = get_post_meta( $post->ID, 'boxzilla_options', true );
10
 
11
+ if ( ! is_array( $settings ) ) {
12
+ continue;
13
+ }
14
 
15
+ // translate from days to hours
16
+ $new_value = intval( $settings['cookie'] ) * 24;
17
 
18
+ // store in new location
19
+ $settings['cookie'] = array(
20
+ 'dismissed' => $new_value,
21
+ );
22
+ update_post_meta( $post->ID, 'boxzilla_options', $settings );
23
+ }
24
  }
src/admin/migrations/3.1.11-screen-width-condition.php CHANGED
@@ -1,29 +1,29 @@
1
  <?php
2
 
3
- defined('ABSPATH') or exit;
4
 
5
- $posts = get_posts(array( 'post_type' => 'boxzilla-box' ));
6
 
7
- if (! empty($posts)) {
8
- foreach ($posts as $post) {
9
- $settings = get_post_meta($post->ID, 'boxzilla_options', true);
10
 
11
- if (! is_array($settings)) {
12
- continue;
13
- }
14
 
15
- if (empty($settings['hide_on_screen_size'])) {
16
- continue;
17
- }
18
 
19
- // set updated option
20
- $settings['screen_size_condition'] = array(
21
- 'condition' => 'larger',
22
- 'value' => intval($settings['hide_on_screen_size']),
23
- );
24
 
25
- unset($settings['hide_on_screen_size']);
26
 
27
- update_post_meta($post->ID, 'boxzilla_options', $settings);
28
- }
29
  }
1
  <?php
2
 
3
+ defined( 'ABSPATH' ) or exit;
4
 
5
+ $posts = get_posts( array( 'post_type' => 'boxzilla-box' ) );
6
 
7
+ if ( ! empty( $posts ) ) {
8
+ foreach ( $posts as $post ) {
9
+ $settings = get_post_meta( $post->ID, 'boxzilla_options', true );
10
 
11
+ if ( ! is_array( $settings ) ) {
12
+ continue;
13
+ }
14
 
15
+ if ( empty( $settings['hide_on_screen_size'] ) ) {
16
+ continue;
17
+ }
18
 
19
+ // set updated option
20
+ $settings['screen_size_condition'] = array(
21
+ 'condition' => 'larger',
22
+ 'value' => intval( $settings['hide_on_screen_size'] ),
23
+ );
24
 
25
+ unset( $settings['hide_on_screen_size'] );
26
 
27
+ update_post_meta( $post->ID, 'boxzilla_options', $settings );
28
+ }
29
  }
src/admin/views/extensions.php CHANGED
@@ -1,39 +1,41 @@
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://boxzillaplugin.com/add-ons/#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 $i => $plugin) : ?>
23
  <div class="plugin">
24
- <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>
25
  <div class="caption">
26
- <h3><a href="<?php echo esc_url($plugin->page_url); ?>" class="unstyled"><?php echo esc_html($plugin->name); ?></a></h3>
27
- <p><?php echo esc_html($plugin->description); ?></p>
28
  <p>
29
- <a class="button" href="<?php echo esc_url($plugin->page_url); ?>" title="More about <?php echo esc_attr($plugin->name); ?>">Read More</a>
30
  <span class="type">Premium</span>
31
  </p>
32
  </div>
33
  </div>
34
- <?php if (($i+1) % 4 === 0) {
35
- echo '<div style="clear: both;"></div>';
36
- } ?>
 
 
37
  <?php endforeach; ?>
38
 
39
  <br style="clear: both;" />
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://boxzillaplugin.com/add-ons/#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 $i => $plugin ) : ?>
23
  <div class="plugin">
24
+ <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>
25
  <div class="caption">
26
+ <h3><a href="<?php echo esc_url( $plugin->page_url ); ?>" class="unstyled"><?php echo esc_html( $plugin->name ); ?></a></h3>
27
+ <p><?php echo esc_html( $plugin->description ); ?></p>
28
  <p>
29
+ <a class="button" href="<?php echo esc_url( $plugin->page_url ); ?>" title="More about <?php echo esc_attr( $plugin->name ); ?>">Read More</a>
30
  <span class="type">Premium</span>
31
  </p>
32
  </div>
33
  </div>
34
+ <?php
35
+ if ( ( $i + 1 ) % 4 === 0 ) {
36
+ echo '<div style="clear: both;"></div>';
37
+ }
38
+ ?>
39
  <?php endforeach; ?>
40
 
41
  <br style="clear: both;" />
src/admin/views/metaboxes/box-appearance-controls.php CHANGED
@@ -1,46 +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>
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' ); ?></option>
35
+ <option value="solid" <?php selected( $opts['css']['border_style'], 'solid' ); ?>><?php _e( 'Solid', 'boxzilla' ); ?></option>
36
+ <option value="dashed" <?php selected( $opts['css']['border_style'], 'dashed' ); ?>><?php _e( 'Dashed', 'boxzilla' ); ?></option>
37
+ <option value="dotted" <?php selected( $opts['css']['border_style'], 'dotted' ); ?>><?php _e( 'Dotted', 'boxzilla' ); ?></option>
38
+ <option value="double" <?php selected( $opts['css']['border_style'], 'double' ); ?>><?php _e( 'Double', 'boxzilla' ); ?></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 CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- defined('ABSPATH') or exit;
4
 
5
  /** @var \Boxzilla\Box $box */
6
  /** @var array $opts */
@@ -8,251 +8,263 @@ defined('ABSPATH') or exit;
8
 
9
  /** @var array $rule_options */
10
  $rule_options = array(
11
- 'everywhere' => __('everywhere', 'boxzilla'),
12
- 'is_page' => __('if page', 'boxzilla'),
13
- 'is_single' => __('if post', 'boxzilla'),
14
- 'is_post_with_tag' => __('if post tag', '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
- 'is_user_logged_in' => __('if user', 'boxzilla'),
20
  );
21
 
22
  /**
23
  * @ignore
24
  */
25
- $rule_options = apply_filters('boxzilla_rules_options', $rule_options);
26
 
27
- ?>
28
- <table class="form-table">
29
  <?php
30
 
31
- /**
32
- * @ignore
33
- */
34
- do_action('boxzilla_before_box_option_controls', $box, $opts);
35
 
36
- ?>
37
- <tr>
38
- <th><?php _e('Load this box if', 'boxzilla'); ?></th>
39
- <td>
40
- <label>
41
- <?php _e('Request matches', 'boxzilla'); ?>
42
- <select name="boxzilla_box[rules_comparision]" id="boxzilla-rule-comparison">
43
- <option value="any" <?php selected($opts['rules_comparision'], 'any'); ?>><?php _e('any', 'boxzilla'); ?></option>
44
- <option value="all" <?php selected($opts['rules_comparision'], 'all'); ?>><?php _e('all', 'boxzilla'); ?></option>
45
- </select>
46
- <?php _e('of the following conditions.', 'boxzilla'); ?>
47
- </label>
48
- </td>
49
- </tr>
50
- <tbody id="boxzilla-box-rules">
51
  <?php
52
- $key = 0;
53
- foreach ($opts['rules'] as $rule) {
54
- // skip invalid looking rules
55
- if (! array_key_exists('condition', $rule)) {
56
- continue;
57
- }
58
 
59
- // output row showing "and" or "or" between rules
60
- if ($key > 0) {
61
- $or = __('or', 'boxzilla');
62
- $and = __('and', 'boxzilla');
63
- $text = $opts['rules_comparision'] === 'any' ? $or : $and;
64
-
65
- echo '<tr>';
66
- echo '<th class="boxzilla-no-vpadding"></th>';
67
- echo '<td class="boxzilla-no-vpadding"><span class="boxzilla-andor boxzilla-muted">' . $text . '</span></td>';
68
- echo '</tr>';
69
- } ?>
70
- <tr valign="top" class="boxzilla-rule-row boxzilla-rule-row-<?php echo $key; ?>">
71
- <th style="text-align: right; font-weight: normal;">
72
- <span class="boxzilla-close boxzilla-remove-rule" title="<?php esc_attr_e('Remove rule', 'boxzilla'); ?>"><span class="dashicons dashicons-dismiss"></span></span>
73
- </th>
74
- <td>
75
- <select class="boxzilla-rule-condition" name="boxzilla_box[rules][<?php echo $key; ?>][condition]">
76
- <?php foreach ($rule_options as $value => $label) {
77
- printf('<option value="%s" %s>%s</option>', $value, selected($rule['condition'], $value), $label);
78
- } ?>
79
- </select>
80
-
81
- <select class="boxzilla-rule-qualifier" name="boxzilla_box[rules][<?php echo $key; ?>][qualifier]" style="min-width: 135px;">
82
- <option value="1" <?php selected(! isset($rule['qualifier']) || $rule['qualifier']); ?>><?php _e('is', 'boxzilla'); ?></option>
83
- <option value="0" <?php selected(isset($rule['qualifier']) && !$rule['qualifier']); ?>><?php _e('is not', 'boxzilla'); ?></option>
84
- <option value="contains" <?php selected(isset($rule['qualifier']) && $rule['qualifier'] === 'contains'); ?> style="display: none;"><?php _e('contains', 'boxzilla'); ?>
85
- <option value="not_contains" <?php selected(isset($rule['qualifier']) && $rule['qualifier'] === 'not_contains'); ?> style="display: none;"><?php _e('does not contain', 'boxzilla'); ?></option>
86
- </select>
87
-
88
- <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' ))) {
89
- echo 'display: none;';
90
- } ?>" />
91
- </td>
92
- </tr>
93
- <?php $key++;
94
- } ?>
95
- </tbody>
96
- <tr>
97
- <th></th>
98
- <td><button type="button" class="button boxzilla-add-rule"><?php _e('Add another rule', 'boxzilla'); ?></button></td>
99
- </tr>
100
- <tr valign="top">
101
- <th><label for="boxzilla_position"><?php _e('Box Position', 'boxzilla'); ?></label></th>
102
- <td>
103
- <table class="window-positions">
104
- <tr>
105
- <td>
 
 
 
106
  <?php
107
- $value = 'top-left'; $label = __('Top Left', 'boxzilla');
108
- printf('<label><input type="radio" name="boxzilla_box[css][position]" value="%s" %s> &nbsp; %s</label>', $value, checked($opts['css']['position'], $value, false), $label);
109
- ?>
110
- </td>
111
- <td></td>
112
- <td>
 
113
  <?php
114
- $value = 'top-right'; $label = __('Top Right', 'boxzilla');
115
- printf('<label><input type="radio" name="boxzilla_box[css][position]" value="%s" %s> &nbsp; %s</label>', $value, checked($opts['css']['position'], $value, false), $label);
116
- ?>
117
- </td>
118
- </tr>
119
- <tr>
120
- <td></td>
121
- <td>
 
122
  <?php
123
- $value = 'center'; $label = __('Center', 'boxzilla');
124
- printf('<label><input type="radio" name="boxzilla_box[css][position]" value="%s" %s> &nbsp; %s</label>', $value, checked($opts['css']['position'], $value, false), $label);
125
- ?>
126
- </td>
127
- <td></td>
128
- </tr>
129
- <tr>
130
- <td>
 
131
  <?php
132
- $value = 'bottom-left'; $label = __('Bottom Left', 'boxzilla');
133
- printf('<label><input type="radio" name="boxzilla_box[css][position]" value="%s" %s> &nbsp; %s</label>', $value, checked($opts['css']['position'], $value, false), $label);
134
- ?>
135
- </td>
136
- <td></td>
137
- <td>
 
138
  <?php
139
- $value = 'bottom-right'; $label = __('Bottom Right', 'boxzilla');
140
- printf('<label><input type="radio" name="boxzilla_box[css][position]" value="%s" %s> &nbsp; %s</label>', $value, checked($opts['css']['position'], $value, false), $label);
141
- ?>
142
- </td>
143
- </tr>
144
- </table>
145
- </td>
146
- </tr>
147
- <tr valign="top">
148
- <th><label><?php _e('Animation', 'boxzilla'); ?></label></th>
149
- <td>
150
- <label><input type="radio" name="boxzilla_box[animation]" value="fade" <?php checked($opts['animation'], 'fade'); ?> /> <?php _e('Fade In', 'boxzilla'); ?></label> &nbsp;
151
- <label><input type="radio" name="boxzilla_box[animation]" value="slide" <?php checked($opts['animation'], 'slide'); ?> /> <?php _e('Slide In', 'boxzilla'); ?></label>
152
- <p class="help"><?php _e('Which animation type should be used to show the box when triggered?', 'boxzilla'); ?></p>
153
- </td>
154
- </tr>
155
- <tr valign="top">
156
- <th><label for="boxzilla_trigger"><?php _e('Auto-show box?', 'boxzilla'); ?></label></th>
157
- <td>
158
- <label><input type="radio" class="boxzilla-auto-show-trigger" name="boxzilla_box[trigger]" value="" <?php checked($opts['trigger'], ''); ?> /> <?php _e('Never', 'boxzilla'); ?></label><br />
159
- <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 />
160
- <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 />
161
- <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 />
162
- <?php do_action('boxzilla_output_auto_show_trigger_options', $opts); ?>
163
- </td>
164
- </tr>
165
- <tbody class="boxzilla-trigger-options" style="display: <?php echo ($opts['trigger'] === '') ? 'none' : 'table-row-group'; ?>;">
166
- <tr valign="top">
167
- <th><label for="boxzilla_cookie"><?php _e('Cookie expiration', 'boxzilla'); ?></label></th>
168
- <td>
169
- <div style="display: inline-block; margin-right: 20px;">
170
- <label for="boxzilla_cookie_triggered" style="font-weight: bold; display: block;"><?php esc_html_e('Triggered', 'mailchimp-for-wp'); ?></label>
171
- <input type="number" id="boxzilla_cookie_triggered" name="boxzilla_box[cookie][triggered]" min="0" step="1" value="<?php echo esc_attr($opts['cookie']['triggered']); ?>" />
172
- <small><?php _e('hours', 'boxzilla'); ?></small>
173
- </div>
174
- <div style="display: inline-block;">
175
- <label for="boxzilla_cookie_dismissed" style="font-weight: bold; display: block;"><?php esc_html_e('Dismissed', 'mailchimp-for-wp'); ?></label>
176
- <input type="number" id="boxzilla_cookie_dismissed" name="boxzilla_box[cookie][dismissed]" min="0" step="1" value="<?php echo esc_attr($opts['cookie']['dismissed']); ?>" />
177
- <small><?php _e('hours', 'boxzilla'); ?></small>
178
- </div>
179
- <br />
180
-
181
- <p class="help"><?php _e('After this box is triggered or dismissed, how many hours should it stay hidden?', 'boxzilla'); ?></p>
182
- </td>
183
- </tr>
184
- <tr valign="top">
185
- <th><label><?php _e('Screen width', 'boxzilla'); ?></label></th>
186
- <td>
187
- <?php
188
- $condition_type = $opts['screen_size_condition']['condition'];
189
- $condition_value = $opts['screen_size_condition']['value'];
190
- $condition_select = '<select name="boxzilla_box[screen_size_condition][condition]"><option value="larger" '. ($condition_type === 'larger' ? 'selected' : '') .'>' . __('larger', 'boxzilla') . '</option><option value="smaller" '. ($condition_type === 'smaller' ? 'selected' : '') .'>' . __('smaller', 'boxzilla') . '</option></select>'; ?>
191
- <p><?php printf(__('Only show on screens %s than %s.', 'boxzilla'), $condition_select, '<input type="number" min="0" name="boxzilla_box[screen_size_condition][value]" value="' . esc_attr($condition_value) . '" style="max-width: 70px;" />px'); ?></p>
192
- <p class="help"><?php _e('Leave empty if you want to show the box on all screen sizes.', 'boxzilla'); ?></p>
193
- </td>
194
-
195
- </tr>
196
- <tr valign="top">
197
- <th><label for="boxzilla_auto_hide"><?php _e('Auto-hide?', 'boxzilla'); ?></label></th>
198
- <td>
199
- <label><input type="radio" name="boxzilla_box[auto_hide]" value="1" <?php checked($opts['auto_hide'], 1); ?> /> <?php _e('Yes'); ?></label> &nbsp;
200
- <label><input type="radio" name="boxzilla_box[auto_hide]" value="0" <?php checked($opts['auto_hide'], 0); ?> /> <?php _e('No'); ?></label> &nbsp;
201
- <p class="help"><?php _e('Hide box again when visitors scroll back up?', 'boxzilla'); ?></p>
202
- </td>
203
- </tr>
204
- <tr valign="top">
205
- <th><label for="boxzilla_closable"><?php _e('Show close icon?', 'boxzilla'); ?></label></th>
206
- <td>
207
- <label><input type="radio" id="boxzilla_closable_1" name="boxzilla_box[show_close_icon]" value="1" <?php checked($opts['show_close_icon'], 1); ?> /> <?php _e('Yes'); ?></label> &nbsp;
208
- <label><input type="radio" id="boxzilla_closable_0" name="boxzilla_box[show_close_icon]" value="0" <?php checked($opts['show_close_icon'], 0); ?> /> <?php _e('No'); ?></label> &nbsp;
209
- <p class="help">
210
- <?php _e('If you decide to hide the close icon, make sure to offer an alternative way to close the box.', 'boxzilla'); ?><br />
211
- <?php _e('Example: ', 'boxzilla'); ?> <code>[boxzilla-close]No, thanks![/boxzilla-close]</code>
212
- </p>
213
- </td>
214
- </tr>
215
- <tr valign="top">
216
- <th><label for="boxzilla_test_mode"><?php _e('Enable test mode?', 'boxzilla'); ?></label></th>
217
- <td>
218
- <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;
219
- <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;
220
- <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>
221
- </td>
222
- </tr>
 
 
223
  <?php
224
 
225
- /**
226
- * @ignore
227
- */
228
- do_action('boxzilla_after_box_option_controls', $box, $opts); ?>
229
- </tbody>
230
- </table>
231
-
232
-
233
- <script type="text/html" id="tmpl-rule-row-template">
234
- <tr>
235
- <th class="boxzilla-no-vpadding"></th>
236
- <td class="boxzilla-no-vpadding"><span class="boxzilla-andor boxzilla-muted">{{data.andor}}</span></td>
237
- </tr>
238
- <tr valign="top" class="boxzilla-rule-row boxzilla-rule-row-{{{data.key}}}">
239
- <th style="text-align: right; font-weight: normal;">
240
- <span class="boxzilla-close boxzilla-remove-rule" title="<?php esc_attr_e('Remove rule', 'boxzilla'); ?>"><span class="dashicons dashicons-dismiss"></span></span>
241
- </th>
242
- <td class="boxzilla-sm">
243
- <select class="boxzilla-rule-condition" name="boxzilla_box[rules][{{{data.key}}}][condition]">
244
- <?php foreach ($rule_options as $value => $label) {
245
- printf('<option value="%s" %s %s>%s</option>', $value, disabled($value, '', false), '', $label);
246
- } ?>
247
- </select>
248
- <select class="boxzilla-rule-qualifier" name="boxzilla_box[rules][{{{data.key}}}][qualifier]" style="display: none; min-width: 135px;" >
249
- <option value="1" selected><?php _e('is', 'boxzilla'); ?></option>
250
- <option value="0"><?php _e('is not', 'boxzilla'); ?></option>
251
- <option value="contains" style="display: none;"><?php _e('contains', 'boxzilla'); ?></option>
252
- <option value="not_contains" style="display: none;"><?php _e('does not contain', 'boxzilla'); ?></option>
253
- </select>
254
-
255
- <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;" />
256
- </td>
257
- </tr>
258
- </script>
 
 
 
1
  <?php
2
 
3
+ defined( 'ABSPATH' ) or exit;
4
 
5
  /** @var \Boxzilla\Box $box */
6
  /** @var array $opts */
8
 
9
  /** @var array $rule_options */
10
  $rule_options = array(
11
+ 'everywhere' => __( 'everywhere', 'boxzilla' ),
12
+ 'is_page' => __( 'if page', 'boxzilla' ),
13
+ 'is_single' => __( 'if post', 'boxzilla' ),
14
+ 'is_post_with_tag' => __( 'if post tag', '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
+ 'is_user_logged_in' => __( 'if user', 'boxzilla' ),
20
  );
21
 
22
  /**
23
  * @ignore
24
  */
25
+ $rule_options = apply_filters( 'boxzilla_rules_options', $rule_options );
26
 
27
+ ?>
28
+ <table class="form-table">
29
  <?php
30
 
31
+ /**
32
+ * @ignore
33
+ */
34
+ do_action( 'boxzilla_before_box_option_controls', $box, $opts );
35
 
36
+ ?>
37
+ <tr>
38
+ <th><?php _e( 'Load this box if', 'boxzilla' ); ?></th>
39
+ <td>
40
+ <label>
41
+ <?php _e( 'Request matches', 'boxzilla' ); ?>
42
+ <select name="boxzilla_box[rules_comparision]" id="boxzilla-rule-comparison">
43
+ <option value="any" <?php selected( $opts['rules_comparision'], 'any' ); ?>><?php _e( 'any', 'boxzilla' ); ?></option>
44
+ <option value="all" <?php selected( $opts['rules_comparision'], 'all' ); ?>><?php _e( 'all', 'boxzilla' ); ?></option>
45
+ </select>
46
+ <?php _e( 'of the following conditions.', 'boxzilla' ); ?>
47
+ </label>
48
+ </td>
49
+ </tr>
50
+ <tbody id="boxzilla-box-rules">
51
  <?php
52
+ $key = 0;
53
+ foreach ( $opts['rules'] as $rule ) {
54
+ // skip invalid looking rules
55
+ if ( ! array_key_exists( 'condition', $rule ) ) {
56
+ continue;
57
+ }
58
 
59
+ // output row showing "and" or "or" between rules
60
+ if ( $key > 0 ) {
61
+ $or = __( 'or', 'boxzilla' );
62
+ $and = __( 'and', 'boxzilla' );
63
+ $text = $opts['rules_comparision'] === 'any' ? $or : $and;
64
+
65
+ echo '<tr>';
66
+ echo '<th class="boxzilla-no-vpadding"></th>';
67
+ echo '<td class="boxzilla-no-vpadding"><span class="boxzilla-andor boxzilla-muted">' . $text . '</span></td>';
68
+ echo '</tr>';
69
+ }
70
+ ?>
71
+ <tr valign="top" class="boxzilla-rule-row boxzilla-rule-row-<?php echo $key; ?>">
72
+ <th style="text-align: right; font-weight: normal;">
73
+ <span class="boxzilla-close boxzilla-remove-rule" title="<?php esc_attr_e( 'Remove rule', 'boxzilla' ); ?>"><span class="dashicons dashicons-dismiss"></span></span>
74
+ </th>
75
+ <td>
76
+ <select class="boxzilla-rule-condition" name="boxzilla_box[rules][<?php echo $key; ?>][condition]">
77
+ <?php
78
+ foreach ( $rule_options as $value => $label ) {
79
+ printf( '<option value="%s" %s>%s</option>', $value, selected( $rule['condition'], $value ), $label );
80
+ }
81
+ ?>
82
+ </select>
83
+
84
+ <select class="boxzilla-rule-qualifier" name="boxzilla_box[rules][<?php echo $key; ?>][qualifier]" style="min-width: 135px;">
85
+ <option value="1" <?php selected( ! isset( $rule['qualifier'] ) || $rule['qualifier'] ); ?>><?php _e( 'is', 'boxzilla' ); ?></option>
86
+ <option value="0" <?php selected( isset( $rule['qualifier'] ) && ! $rule['qualifier'] ); ?>><?php _e( 'is not', 'boxzilla' ); ?></option>
87
+ <option value="contains" <?php selected( isset( $rule['qualifier'] ) && $rule['qualifier'] === 'contains' ); ?> style="display: none;"><?php _e( 'contains', 'boxzilla' ); ?>
88
+ <option value="not_contains" <?php selected( isset( $rule['qualifier'] ) && $rule['qualifier'] === 'not_contains' ); ?> style="display: none;"><?php _e( 'does not contain', 'boxzilla' ); ?></option>
89
+ </select>
90
+
91
+ <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 echo in_array( $rule['condition'], array( '', 'everywhere' ), true ) ? 'display: none;' : ''; ?>" />
92
+ </td>
93
+ </tr>
94
+ <?php
95
+ $key++;
96
+ }
97
+ ?>
98
+ </tbody>
99
+ <tr>
100
+ <th></th>
101
+ <td><button type="button" class="button boxzilla-add-rule"><?php _e( 'Add another rule', 'boxzilla' ); ?></button></td>
102
+ </tr>
103
+ <tr valign="top">
104
+ <th><label for="boxzilla_position"><?php _e( 'Box Position', 'boxzilla' ); ?></label></th>
105
+ <td>
106
+ <table class="window-positions">
107
+ <tr>
108
+ <td>
109
  <?php
110
+ $value = 'top-left';
111
+ $label = __( 'Top Left', 'boxzilla' );
112
+ printf( '<label><input type="radio" name="boxzilla_box[css][position]" value="%s" %s> &nbsp; %s</label>', $value, checked( $opts['css']['position'], $value, false ), $label );
113
+ ?>
114
+ </td>
115
+ <td></td>
116
+ <td>
117
  <?php
118
+ $value = 'top-right';
119
+ $label = __( 'Top Right', 'boxzilla' );
120
+ printf( '<label><input type="radio" name="boxzilla_box[css][position]" value="%s" %s> &nbsp; %s</label>', $value, checked( $opts['css']['position'], $value, false ), $label );
121
+ ?>
122
+ </td>
123
+ </tr>
124
+ <tr>
125
+ <td></td>
126
+ <td>
127
  <?php
128
+ $value = 'center';
129
+ $label = __( 'Center', 'boxzilla' );
130
+ printf( '<label><input type="radio" name="boxzilla_box[css][position]" value="%s" %s> &nbsp; %s</label>', $value, checked( $opts['css']['position'], $value, false ), $label );
131
+ ?>
132
+ </td>
133
+ <td></td>
134
+ </tr>
135
+ <tr>
136
+ <td>
137
  <?php
138
+ $value = 'bottom-left';
139
+ $label = __( 'Bottom Left', 'boxzilla' );
140
+ printf( '<label><input type="radio" name="boxzilla_box[css][position]" value="%s" %s> &nbsp; %s</label>', $value, checked( $opts['css']['position'], $value, false ), $label );
141
+ ?>
142
+ </td>
143
+ <td></td>
144
+ <td>
145
  <?php
146
+ $value = 'bottom-right';
147
+ $label = __( 'Bottom Right', 'boxzilla' );
148
+ printf( '<label><input type="radio" name="boxzilla_box[css][position]" value="%s" %s> &nbsp; %s</label>', $value, checked( $opts['css']['position'], $value, false ), $label );
149
+ ?>
150
+ </td>
151
+ </tr>
152
+ </table>
153
+ </td>
154
+ </tr>
155
+ <tr valign="top">
156
+ <th><label><?php _e( 'Animation', 'boxzilla' ); ?></label></th>
157
+ <td>
158
+ <label><input type="radio" name="boxzilla_box[animation]" value="fade" <?php checked( $opts['animation'], 'fade' ); ?> /> <?php _e( 'Fade In', 'boxzilla' ); ?></label> &nbsp;
159
+ <label><input type="radio" name="boxzilla_box[animation]" value="slide" <?php checked( $opts['animation'], 'slide' ); ?> /> <?php _e( 'Slide In', 'boxzilla' ); ?></label>
160
+ <p class="help"><?php _e( 'Which animation type should be used to show the box when triggered?', 'boxzilla' ); ?></p>
161
+ </td>
162
+ </tr>
163
+ <tr valign="top">
164
+ <th><label for="boxzilla_trigger"><?php _e( 'Auto-show box?', 'boxzilla' ); ?></label></th>
165
+ <td>
166
+ <label><input type="radio" class="boxzilla-auto-show-trigger" name="boxzilla_box[trigger]" value="" <?php checked( $opts['trigger'], '' ); ?> /> <?php _e( 'Never', 'boxzilla' ); ?></label><br />
167
+ <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 />
168
+ <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 />
169
+ <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 />
170
+ <?php do_action( 'boxzilla_output_auto_show_trigger_options', $opts ); ?>
171
+ </td>
172
+ </tr>
173
+ <tbody class="boxzilla-trigger-options" style="display: <?php echo ( $opts['trigger'] === '' ) ? 'none' : 'table-row-group'; ?>;">
174
+ <tr valign="top">
175
+ <th><label for="boxzilla_cookie"><?php _e( 'Cookie expiration', 'boxzilla' ); ?></label></th>
176
+ <td>
177
+ <div style="display: inline-block; margin-right: 20px;">
178
+ <label for="boxzilla_cookie_triggered" style="font-weight: bold; display: block;"><?php esc_html_e( 'Triggered', 'boxzilla' ); ?></label>
179
+ <input type="number" id="boxzilla_cookie_triggered" name="boxzilla_box[cookie][triggered]" min="0" step="1" value="<?php echo esc_attr( $opts['cookie']['triggered'] ); ?>" />
180
+ <small><?php _e( 'hours', 'boxzilla' ); ?></small>
181
+ </div>
182
+ <div style="display: inline-block;">
183
+ <label for="boxzilla_cookie_dismissed" style="font-weight: bold; display: block;"><?php esc_html_e( 'Dismissed', 'boxzilla' ); ?></label>
184
+ <input type="number" id="boxzilla_cookie_dismissed" name="boxzilla_box[cookie][dismissed]" min="0" step="1" value="<?php echo esc_attr( $opts['cookie']['dismissed'] ); ?>" />
185
+ <small><?php _e( 'hours', 'boxzilla' ); ?></small>
186
+ </div>
187
+ <br />
188
+
189
+ <p class="help"><?php _e( 'After this box is triggered or dismissed, how many hours should it stay hidden?', 'boxzilla' ); ?></p>
190
+ </td>
191
+ </tr>
192
+ <tr valign="top">
193
+ <th><label><?php _e( 'Screen width', 'boxzilla' ); ?></label></th>
194
+ <td>
195
+ <?php
196
+ $condition_type = $opts['screen_size_condition']['condition'];
197
+ $condition_value = $opts['screen_size_condition']['value'];
198
+ $condition_select = '<select name="boxzilla_box[screen_size_condition][condition]"><option value="larger" ' . ( $condition_type === 'larger' ? 'selected' : '' ) . '>' . __( 'larger', 'boxzilla' ) . '</option><option value="smaller" ' . ( $condition_type === 'smaller' ? 'selected' : '' ) . '>' . __( 'smaller', 'boxzilla' ) . '</option></select>';
199
+ ?>
200
+ <p><?php printf( __( 'Only show on screens %1$s than %2$s.', 'boxzilla' ), $condition_select, '<input type="number" min="0" name="boxzilla_box[screen_size_condition][value]" value="' . esc_attr( $condition_value ) . '" style="max-width: 70px;" />px' ); ?></p>
201
+ <p class="help"><?php _e( 'Leave empty if you want to show the box on all screen sizes.', 'boxzilla' ); ?></p>
202
+ </td>
203
+
204
+ </tr>
205
+ <tr valign="top">
206
+ <th><label for="boxzilla_auto_hide"><?php _e( 'Auto-hide?', 'boxzilla' ); ?></label></th>
207
+ <td>
208
+ <label><input type="radio" name="boxzilla_box[auto_hide]" value="1" <?php checked( $opts['auto_hide'], 1 ); ?> /> <?php _e( 'Yes', 'boxzilla' ); ?></label> &nbsp;
209
+ <label><input type="radio" name="boxzilla_box[auto_hide]" value="0" <?php checked( $opts['auto_hide'], 0 ); ?> /> <?php _e( 'No', 'boxzilla' ); ?></label> &nbsp;
210
+ <p class="help"><?php _e( 'Hide box again when visitors scroll back up?', 'boxzilla' ); ?></p>
211
+ </td>
212
+ </tr>
213
+ <tr valign="top">
214
+ <th><label for="boxzilla_closable"><?php _e( 'Show close icon?', 'boxzilla' ); ?></label></th>
215
+ <td>
216
+ <label><input type="radio" id="boxzilla_closable_1" name="boxzilla_box[show_close_icon]" value="1" <?php checked( $opts['show_close_icon'], 1 ); ?> /> <?php _e( 'Yes', 'boxzilla' ); ?></label> &nbsp;
217
+ <label><input type="radio" id="boxzilla_closable_0" name="boxzilla_box[show_close_icon]" value="0" <?php checked( $opts['show_close_icon'], 0 ); ?> /> <?php _e( 'No', 'boxzilla' ); ?></label> &nbsp;
218
+ <p class="help">
219
+ <?php _e( 'If you decide to hide the close icon, make sure to offer an alternative way to close the box.', 'boxzilla' ); ?><br />
220
+ <?php _e( 'Example: ', 'boxzilla' ); ?> <code>[boxzilla-close]No, thanks![/boxzilla-close]</code>
221
+ </p>
222
+ </td>
223
+ </tr>
224
+ <tr valign="top">
225
+ <th><label for="boxzilla_test_mode"><?php _e( 'Enable test mode?', 'boxzilla' ); ?></label></th>
226
+ <td>
227
+ <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', 'boxzilla' ); ?></label> &nbsp;
228
+ <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', 'boxzilla' ); ?></label> &nbsp;
229
+ <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>
230
+ </td>
231
+ </tr>
232
  <?php
233
 
234
+ /**
235
+ * @ignore
236
+ */
237
+ do_action( 'boxzilla_after_box_option_controls', $box, $opts );
238
+ ?>
239
+ </tbody>
240
+ </table>
241
+
242
+
243
+ <script type="text/html" id="tmpl-rule-row-template">
244
+ <tr>
245
+ <th class="boxzilla-no-vpadding"></th>
246
+ <td class="boxzilla-no-vpadding"><span class="boxzilla-andor boxzilla-muted">{{data.andor}}</span></td>
247
+ </tr>
248
+ <tr valign="top" class="boxzilla-rule-row boxzilla-rule-row-{{{data.key}}}">
249
+ <th style="text-align: right; font-weight: normal;">
250
+ <span class="boxzilla-close boxzilla-remove-rule" title="<?php esc_attr_e( 'Remove rule', 'boxzilla' ); ?>"><span class="dashicons dashicons-dismiss"></span></span>
251
+ </th>
252
+ <td class="boxzilla-sm">
253
+ <select class="boxzilla-rule-condition" name="boxzilla_box[rules][{{{data.key}}}][condition]">
254
+ <?php
255
+ foreach ( $rule_options as $value => $label ) {
256
+ printf( '<option value="%s" %s %s>%s</option>', $value, disabled( $value, '', false ), '', $label );
257
+ }
258
+ ?>
259
+ </select>
260
+ <select class="boxzilla-rule-qualifier" name="boxzilla_box[rules][{{{data.key}}}][qualifier]" style="display: none; min-width: 135px;" >
261
+ <option value="1" selected><?php _e( 'is', 'boxzilla' ); ?></option>
262
+ <option value="0"><?php _e( 'is not', 'boxzilla' ); ?></option>
263
+ <option value="contains" style="display: none;"><?php _e( 'contains', 'boxzilla' ); ?></option>
264
+ <option value="not_contains" style="display: none;"><?php _e( 'does not contain', 'boxzilla' ); ?></option>
265
+ </select>
266
+
267
+ <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;" />
268
+ </td>
269
+ </tr>
270
+ </script>
src/admin/views/metaboxes/email-optin.php CHANGED
@@ -1,16 +1,16 @@
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 the Boxzilla plugin by subscribing to our newsletter filled with tips & tricks.</p>
6
 
7
  <p class="mc-field-group">
8
  <label for="mce-EMAIL" style="margin-bottom: 0;">Email Address &nbsp;<span style="color: red;">*</span></label>
9
- <input type="email" value="<?php echo esc_attr($user->user_email); ?>" name="EMAIL" class="widefat" id="mce-EMAIL">
10
  </p>
11
  <p class="mc-field-group">
12
  <label for="mce-FNAME" style="margin-bottom: 0;">First Name &nbsp;<small style="font-weight: normal;">(optional)</small></label>
13
- <input type="text" value="<?php echo esc_attr($user->first_name); ?>" name="FNAME" class="widefat" id="mce-FNAME">
14
  </p>
15
  <div id="mce-responses" class="clear">
16
  <div class="response" id="mce-error-response" style="display:none"></div>
@@ -20,4 +20,4 @@ $user = wp_get_current_user(); ?>
20
  <div class="clear"><input type="submit" value="Subscribe" name="subscribe" class="button button-primary"></div>
21
 
22
  <p class="help" style="margin-bottom: 0;"><small>No spam, unsubscribe at any time, max once a month.</small></p>
23
- </form>
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 the Boxzilla plugin by subscribing to our newsletter filled with tips & tricks.</p>
6
 
7
  <p class="mc-field-group">
8
  <label for="mce-EMAIL" style="margin-bottom: 0;">Email Address &nbsp;<span style="color: red;">*</span></label>
9
+ <input type="email" value="<?php echo esc_attr( $user->user_email ); ?>" name="EMAIL" class="widefat" id="mce-EMAIL">
10
  </p>
11
  <p class="mc-field-group">
12
  <label for="mce-FNAME" style="margin-bottom: 0;">First Name &nbsp;<small style="font-weight: normal;">(optional)</small></label>
13
+ <input type="text" value="<?php echo esc_attr( $user->first_name ); ?>" name="FNAME" class="widefat" id="mce-FNAME">
14
  </p>
15
  <div id="mce-responses" class="clear">
16
  <div class="response" id="mce-error-response" style="display:none"></div>
20
  <div class="clear"><input type="submit" value="Subscribe" name="subscribe" class="button button-primary"></div>
21
 
22
  <p class="help" style="margin-bottom: 0;"><small>No spam, unsubscribe at any time, max once a month.</small></p>
23
+ </form>
src/admin/views/metaboxes/need-help.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php defined('ABSPATH') or exit; ?>
2
- <p><?php _e('Please make sure to look at the following available resources.', 'boxzilla'); ?></p>
3
  <ul class="ul-square">
4
- <li><a href="https://kb.boxzillaplugin.com/">Knowledge Base</a></li>
5
- <li><a href="https://wordpress.org/plugins/boxzilla/faq/">Frequently Asked Questions</a></li>
6
- <li><a href="https://wordpress.org/support/plugin/boxzilla">Support forums on WordPress.org</a></li>
7
  </ul>
8
 
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
+ <p><?php _e( 'Please make sure to look at the following available resources.', 'boxzilla' ); ?></p>
3
  <ul class="ul-square">
4
+ <li><a href="https://kb.boxzillaplugin.com/">Knowledge Base</a></li>
5
+ <li><a href="https://wordpress.org/plugins/boxzilla/faq/">Frequently Asked Questions</a></li>
6
+ <li><a href="https://wordpress.org/support/plugin/boxzilla">Support forums on WordPress.org</a></li>
7
  </ul>
8
 
src/admin/views/metaboxes/our-other-plugins.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php defined('ABSPATH') or exit; ?>
2
 
3
  <div style="margin: 12px 0;">
4
  <p>
1
+ <?php defined( 'ABSPATH' ) or exit; ?>
2
 
3
  <div style="margin: 12px 0;">
4
  <p>
src/admin/views/settings.php CHANGED
@@ -1,53 +1,53 @@
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
  <div class="boxzilla-box">
40
- <h3><?php echo __('Looking for help?', 'boxzilla'); ?></h3>
41
  <?php include __DIR__ . '/metaboxes/need-help.php'; ?>
42
  </div>
43
 
44
  <div class="boxzilla-box">
45
- <h3><?php echo __('Our other plugins', 'boxzilla'); ?></h3>
46
  <?php include __DIR__ . '/metaboxes/our-other-plugins.php'; ?>
47
  </div>
48
 
49
  <div class="boxzilla-box">
50
- <h3><?php echo __('Subscribe to our newsletter', 'boxzilla'); ?></h3>
51
  <?php include __DIR__ . '/metaboxes/email-optin.php'; ?>
52
  </div>
53
  </div>
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', 'boxzilla' ); ?></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', 'boxzilla' ); ?></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
  <div class="boxzilla-box">
40
+ <h3><?php echo __( 'Looking for help?', 'boxzilla' ); ?></h3>
41
  <?php include __DIR__ . '/metaboxes/need-help.php'; ?>
42
  </div>
43
 
44
  <div class="boxzilla-box">
45
+ <h3><?php echo __( 'Our other plugins', 'boxzilla' ); ?></h3>
46
  <?php include __DIR__ . '/metaboxes/our-other-plugins.php'; ?>
47
  </div>
48
 
49
  <div class="boxzilla-box">
50
+ <h3><?php echo __( 'Subscribe to our newsletter', 'boxzilla' ); ?></h3>
51
  <?php include __DIR__ . '/metaboxes/email-optin.php'; ?>
52
  </div>
53
  </div>
src/class-bootstrapper.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Boxzilla;
4
+
5
+ use InvalidArgumentException;
6
+
7
+ /**
8
+ * Class Bootstrapper
9
+ * @package Boxzilla
10
+ *
11
+ * @method void admin( callable $callback )
12
+ * @method void cron( callable $callback )
13
+ * @method void front( callable $callback )
14
+ * @method void ajax( callable $callback )
15
+ * @method void cli( callable $callback )
16
+ */
17
+ class Bootstrapper
18
+ {
19
+
20
+ /**
21
+ * @var array
22
+ */
23
+ private $bootstrappers = array(
24
+ 'admin' => array(),
25
+ 'ajax' => array(),
26
+ 'cli' => array(),
27
+ 'cron' => array(),
28
+ 'front' => array(),
29
+ 'global' => array(),
30
+ );
31
+
32
+ /**
33
+ * @param string $section
34
+ * @param callable $callable
35
+ */
36
+ public function register($section, $callable)
37
+ {
38
+ if (! isset($this->bootstrappers[ $section ])) {
39
+ throw new InvalidArgumentException("Section $section is invalid.");
40
+ }
41
+
42
+ if (! is_callable($callable)) {
43
+ throw new InvalidArgumentException('Callable argument is not callable.');
44
+ }
45
+
46
+ $this->bootstrappers[ $section ][] = $callable;
47
+ }
48
+
49
+ /**
50
+ * @param string $name
51
+ * @param array $arguments
52
+ */
53
+ public function __call($name, $arguments)
54
+ {
55
+ if (isset($this->bootstrappers[ $name ])) {
56
+ $this->register($name, $arguments[0]);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Run registered bootstrappers
62
+ *
63
+ * @param string $section
64
+ */
65
+ public function run($section = '')
66
+ {
67
+ if (! $section) {
68
+ $section = $this->section();
69
+ }
70
+
71
+ // call all global callbacks
72
+ foreach ($this->bootstrappers['global'] as $callback) {
73
+ $callback();
74
+ }
75
+
76
+ // call section specific callbacks
77
+ foreach ($this->bootstrappers[ $section ] as $callback) {
78
+ $callback();
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Get currently active section.
84
+ *
85
+ * @return string
86
+ */
87
+ public function section()
88
+ {
89
+ if (is_admin()) {
90
+ if (defined('DOING_AJAX') && DOING_AJAX) {
91
+ return 'ajax';
92
+ } else {
93
+ return 'admin';
94
+ }
95
+ } else {
96
+ if (defined('DOING_CRON') && DOING_CRON) {
97
+ return 'cron';
98
+ } elseif (defined('WP_CLI') && WP_CLI) {
99
+ return 'cli';
100
+ } else {
101
+ return 'front';
102
+ }
103
+ }
104
+ }
105
+ }
src/class-box.php CHANGED
@@ -4,266 +4,258 @@ namespace Boxzilla;
4
 
5
  use WP_Post;
6
 
7
- class Box
8
- {
9
-
10
- /**
11
- * @var int
12
- */
13
- public $ID;
14
-
15
- /**
16
- * @var array
17
- */
18
- public $options = array();
19
-
20
- /**
21
- * @var string
22
- */
23
- public $title = '';
24
-
25
- /**
26
- * @var string
27
- */
28
- protected $content = '';
29
-
30
- /**
31
- * @var bool
32
- */
33
- public $enabled = false;
34
-
35
- /**
36
- * @var WP_Post
37
- */
38
- private $post;
39
-
40
- /**
41
- * @param WP_Post|int $post
42
- */
43
- public function __construct($post)
44
- {
45
-
46
- // fetch post if it hasn't been fetched yet
47
- if (! $post instanceof WP_Post) {
48
- $post = get_post($post);
49
- }
50
-
51
- // store ref to post
52
- $this->post = $post;
53
-
54
- // store ID in property for quick access
55
- $this->ID = $post->ID;
56
-
57
- // store title in property
58
- $this->title = $post->post_title;
59
-
60
- // store content in property
61
- $this->content = $post->post_content;
62
-
63
- // is this box enabled?
64
- $this->enabled = ($post->post_status === 'publish');
65
-
66
- // load and store options in property
67
- $this->options = $this->load_options();
68
- }
69
-
70
- /**
71
- * Get the options for this box.
72
- **
73
- * @return array Array of box options
74
- */
75
- protected function load_options()
76
- {
77
- $defaults = array(
78
- 'css' => array(
79
- 'background_color' => '',
80
- 'color' => '',
81
- 'width' => '',
82
- 'border_color' => '',
83
- 'border_width' => '',
84
- 'border_style' => '',
85
- 'position' => 'bottom-right',
86
- ),
87
- 'rules' => array(
88
- 0 => array(
89
- 'condition' => '',
90
- 'value' => '',
91
- ),
92
- ),
93
- 'rules_comparision' => 'any',
94
- 'cookie' => array(
95
- 'triggered' => 0,
96
- 'dismissed' => 0,
97
- ),
98
- 'trigger' => 'percentage',
99
- 'trigger_percentage' => 65,
100
- 'trigger_element' => '',
101
- 'trigger_time_on_site' => 0,
102
- 'trigger_time_on_page' => 0,
103
- 'animation' => 'fade',
104
- 'auto_hide' => 0,
105
- 'screen_size_condition' => array(
106
- 'condition' => 'larger',
107
- 'value' => 0,
108
- ),
109
- 'closable' => 1,
110
- 'show_close_icon' => 1,
111
- );
112
- $box = $this;
113
-
114
- $options = get_post_meta($this->ID, 'boxzilla_options', true);
115
- $options = is_array($options) ? $options : array();
116
-
117
-
118
- // merge options with default options
119
- $options = array_replace_recursive($defaults, $options);
120
-
121
- // allow others to filter the final array of options
122
- /**
123
- * Filter the options for a given box
124
- *
125
- * @param array $options
126
- * @param Box $box
127
- */
128
- $options = apply_filters('boxzilla_box_options', $options, $box);
129
-
130
- return $options;
131
- }
132
-
133
- /**
134
- * @return bool
135
- */
136
- public function is_enabled()
137
- {
138
- return $this->enabled;
139
- }
140
-
141
- /**
142
- * Get the options for this box
143
- *
144
- * @return array
145
- */
146
- public function get_options()
147
- {
148
- return $this->options;
149
- }
150
-
151
- /**
152
- * Get the close / hide icon for this box
153
- *
154
- * @return string
155
- */
156
- public function get_close_icon()
157
- {
158
- if (! $this->options['show_close_icon']) {
159
- return '';
160
- }
161
-
162
- $box = $this;
163
- $html = '&times;';
164
-
165
- /**
166
- * Filters the HTML for the close icon.
167
- *
168
- * @param string $html
169
- * @param Box $box
170
- */
171
- $close_icon = (string) apply_filters('boxzilla_box_close_icon', $html, $box);
172
-
173
- return $close_icon;
174
- }
175
-
176
- /**
177
- * Get the content of this box
178
- *
179
- * @return string
180
- */
181
- public function get_content()
182
- {
183
- $content = $this->content;
184
- $box = $this;
185
-
186
- // replace boxzilla specific shortcodes
187
- $close_link = sprintf('<a href="javascript:Boxzilla.dismiss(%d);">', $this->ID);
188
-
189
- $replacements = array(
190
- '[boxzilla_close]' => $close_link, // accept underscore and dash here for consistency with other shortcode
191
- '[boxzilla-close]' => $close_link,
192
- '[/boxzilla_close]' => '</a>',
193
- '[/boxzilla-close]' => '</a>',
194
- );
195
-
196
- $content = str_replace(array_keys($replacements), array_values($replacements), $content);
197
-
198
- /**
199
- * Filters the HTML for the box content
200
- *
201
- * @param string $content
202
- * @param Box $box
203
- */
204
- $content = apply_filters('boxzilla_box_content', $content, $box);
205
- return $content;
206
- }
207
-
208
- /**
209
- * Get options object for JS script.
210
- *
211
- * @return array
212
- */
213
- public function get_client_options()
214
- {
215
- $box = $this;
216
-
217
- $trigger = false;
218
- if ($box->options['trigger']) {
219
- $trigger = array(
220
- 'method' => $this->options['trigger']
221
- );
222
-
223
- if (isset($this->options[ 'trigger_' . $this->options['trigger'] ])) {
224
- $trigger['value'] = $this->options[ 'trigger_' . $this->options['trigger'] ];
225
- }
226
- }
227
-
228
- // build screenWidthCondition object (or null)
229
- $screen_width_condition = null;
230
- if ($box->options['screen_size_condition']['value'] > 0) {
231
- $screen_width_condition = array(
232
- 'condition' => $box->options['screen_size_condition']['condition'],
233
- 'value' => intval($box->options['screen_size_condition']['value']),
234
- );
235
- }
236
-
237
- $client_options = array(
238
- 'id' => $box->ID,
239
- 'icon' => $box->get_close_icon(),
240
- 'content' => '', // we grab this later from an HTML element
241
- 'css' => array_filter($box->options['css']),
242
- 'trigger' => $trigger,
243
- 'animation' => $box->options['animation'],
244
- 'cookie' => array(
245
- 'triggered' => absint($box->options['cookie']['triggered']),
246
- 'dismissed' => absint($box->options['cookie']['dismissed']),
247
- ),
248
- 'rehide' => (bool) $box->options['auto_hide'],
249
- 'position' => $box->options['css']['position'],
250
- 'screenWidthCondition' => $screen_width_condition,
251
- 'closable' => !!$box->options['closable'],
252
- 'post' => array(
253
- 'id' => $this->post->ID,
254
- 'title' => $this->post->post_title,
255
- 'slug' => $this->post->post_name,
256
- ),
257
- );
258
-
259
- /**
260
- * Filter the final options for the JS Boxzilla client.
261
- *
262
- * @param array $client_options
263
- * @param Box $box
264
- */
265
- $client_options = apply_filters('boxzilla_box_client_options', $client_options, $box);
266
-
267
- return $client_options;
268
- }
269
  }
4
 
5
  use WP_Post;
6
 
7
+ class Box {
8
+
9
+
10
+ /**
11
+ * @var int
12
+ */
13
+ public $ID;
14
+
15
+ /**
16
+ * @var array
17
+ */
18
+ public $options = array();
19
+
20
+ /**
21
+ * @var string
22
+ */
23
+ public $title = '';
24
+
25
+ /**
26
+ * @var string
27
+ */
28
+ protected $content = '';
29
+
30
+ /**
31
+ * @var bool
32
+ */
33
+ public $enabled = false;
34
+
35
+ /**
36
+ * @var WP_Post
37
+ */
38
+ private $post;
39
+
40
+ /**
41
+ * @param WP_Post|int $post
42
+ */
43
+ public function __construct( $post ) {
44
+
45
+ // fetch post if it hasn't been fetched yet
46
+ if ( ! $post instanceof WP_Post ) {
47
+ $post = get_post( $post );
48
+ }
49
+
50
+ // store ref to post
51
+ $this->post = $post;
52
+
53
+ // store ID in property for quick access
54
+ $this->ID = $post->ID;
55
+
56
+ // store title in property
57
+ $this->title = $post->post_title;
58
+
59
+ // store content in property
60
+ $this->content = $post->post_content;
61
+
62
+ // is this box enabled?
63
+ $this->enabled = ( $post->post_status === 'publish' );
64
+
65
+ // load and store options in property
66
+ $this->options = $this->load_options();
67
+ }
68
+
69
+ /**
70
+ * Get the options for this box.
71
+ **
72
+ * @return array Array of box options
73
+ */
74
+ protected function load_options() {
75
+ $defaults = array(
76
+ 'css' => array(
77
+ 'background_color' => '',
78
+ 'color' => '',
79
+ 'width' => '',
80
+ 'border_color' => '',
81
+ 'border_width' => '',
82
+ 'border_style' => '',
83
+ 'position' => 'bottom-right',
84
+ ),
85
+ 'rules' => array(
86
+ 0 => array(
87
+ 'condition' => '',
88
+ 'value' => '',
89
+ ),
90
+ ),
91
+ 'rules_comparision' => 'any',
92
+ 'cookie' => array(
93
+ 'triggered' => 0,
94
+ 'dismissed' => 0,
95
+ ),
96
+ 'trigger' => 'percentage',
97
+ 'trigger_percentage' => 65,
98
+ 'trigger_element' => '',
99
+ 'trigger_time_on_site' => 0,
100
+ 'trigger_time_on_page' => 0,
101
+ 'animation' => 'fade',
102
+ 'auto_hide' => 0,
103
+ 'screen_size_condition' => array(
104
+ 'condition' => 'larger',
105
+ 'value' => 0,
106
+ ),
107
+ 'closable' => 1,
108
+ 'show_close_icon' => 1,
109
+ );
110
+ $box = $this;
111
+
112
+ $options = get_post_meta( $this->ID, 'boxzilla_options', true );
113
+ $options = is_array( $options ) ? $options : array();
114
+
115
+ // merge options with default options
116
+ $options = array_replace_recursive( $defaults, $options );
117
+
118
+ // allow others to filter the final array of options
119
+ /**
120
+ * Filter the options for a given box
121
+ *
122
+ * @param array $options
123
+ * @param Box $box
124
+ */
125
+ $options = apply_filters( 'boxzilla_box_options', $options, $box );
126
+
127
+ return $options;
128
+ }
129
+
130
+ /**
131
+ * @return bool
132
+ */
133
+ public function is_enabled() {
134
+ return $this->enabled;
135
+ }
136
+
137
+ /**
138
+ * Get the options for this box
139
+ *
140
+ * @return array
141
+ */
142
+ public function get_options() {
143
+ return $this->options;
144
+ }
145
+
146
+ /**
147
+ * Get the close / hide icon for this box
148
+ *
149
+ * @return string
150
+ */
151
+ public function get_close_icon() {
152
+ if ( ! $this->options['show_close_icon'] ) {
153
+ return '';
154
+ }
155
+
156
+ $box = $this;
157
+ $html = '&times;';
158
+
159
+ /**
160
+ * Filters the HTML for the close icon.
161
+ *
162
+ * @param string $html
163
+ * @param Box $box
164
+ */
165
+ $close_icon = (string) apply_filters( 'boxzilla_box_close_icon', $html, $box );
166
+
167
+ return $close_icon;
168
+ }
169
+
170
+ /**
171
+ * Get the content of this box
172
+ *
173
+ * @return string
174
+ */
175
+ public function get_content() {
176
+ $content = $this->content;
177
+ $box = $this;
178
+
179
+ // replace boxzilla specific shortcodes
180
+ $close_link = sprintf( '<a href="javascript:Boxzilla.dismiss(%d);">', $this->ID );
181
+
182
+ $replacements = array(
183
+ '[boxzilla_close]' => $close_link, // accept underscore and dash here for consistency with other shortcode
184
+ '[boxzilla-close]' => $close_link,
185
+ '[/boxzilla_close]' => '</a>',
186
+ '[/boxzilla-close]' => '</a>',
187
+ );
188
+
189
+ $content = str_replace( array_keys( $replacements ), array_values( $replacements ), $content );
190
+
191
+ /**
192
+ * Filters the HTML for the box content
193
+ *
194
+ * @param string $content
195
+ * @param Box $box
196
+ */
197
+ $content = apply_filters( 'boxzilla_box_content', $content, $box );
198
+ return $content;
199
+ }
200
+
201
+ /**
202
+ * Get options object for JS script.
203
+ *
204
+ * @return array
205
+ */
206
+ public function get_client_options() {
207
+ $box = $this;
208
+
209
+ $trigger = false;
210
+ if ( $box->options['trigger'] ) {
211
+ $trigger = array(
212
+ 'method' => $this->options['trigger'],
213
+ );
214
+
215
+ if ( isset( $this->options[ 'trigger_' . $this->options['trigger'] ] ) ) {
216
+ $trigger['value'] = $this->options[ 'trigger_' . $this->options['trigger'] ];
217
+ }
218
+ }
219
+
220
+ // build screenWidthCondition object (or null)
221
+ $screen_width_condition = null;
222
+ if ( $box->options['screen_size_condition']['value'] > 0 ) {
223
+ $screen_width_condition = array(
224
+ 'condition' => $box->options['screen_size_condition']['condition'],
225
+ 'value' => intval( $box->options['screen_size_condition']['value'] ),
226
+ );
227
+ }
228
+
229
+ $client_options = array(
230
+ 'id' => $box->ID,
231
+ 'icon' => $box->get_close_icon(),
232
+ 'content' => '', // we grab this later from an HTML element
233
+ 'css' => array_filter( $box->options['css'] ),
234
+ 'trigger' => $trigger,
235
+ 'animation' => $box->options['animation'],
236
+ 'cookie' => array(
237
+ 'triggered' => absint( $box->options['cookie']['triggered'] ),
238
+ 'dismissed' => absint( $box->options['cookie']['dismissed'] ),
239
+ ),
240
+ 'rehide' => (bool) $box->options['auto_hide'],
241
+ 'position' => $box->options['css']['position'],
242
+ 'screenWidthCondition' => $screen_width_condition,
243
+ 'closable' => ! ! $box->options['closable'],
244
+ 'post' => array(
245
+ 'id' => $this->post->ID,
246
+ 'title' => $this->post->post_title,
247
+ 'slug' => $this->post->post_name,
248
+ ),
249
+ );
250
+
251
+ /**
252
+ * Filter the final options for the JS Boxzilla client.
253
+ *
254
+ * @param array $client_options
255
+ * @param Box $box
256
+ */
257
+ $client_options = apply_filters( 'boxzilla_box_client_options', $client_options, $box );
258
+
259
+ return $client_options;
260
+ }
 
 
 
 
 
 
 
 
261
  }
src/class-boxzilla-service-provider.php CHANGED
@@ -8,65 +8,66 @@ use Boxzilla\Admin\Notices;
8
  use Boxzilla\DI\Container;
9
  use Boxzilla\DI\ServiceProviderInterface;
10
 
11
- class BoxzillaServiceProvider implements ServiceProviderInterface
12
- {
13
 
14
- /**
15
- * Registers services on the given container.
16
- *
17
- * This method should only be used to configure services and parameters.
18
- * It should not get services.
19
- *
20
- * @param Container $container An Container instance
21
- */
22
- public function register(Container $container)
23
- {
24
- $container['admin'] = function ($container) {
25
- return new Admin($container->plugin, $container);
26
- };
27
 
28
- $container['admin.menu'] = function($container) {
29
- return new Menu();
30
- };
 
 
 
 
 
 
 
 
 
31
 
32
- $container['box_loader'] = function ($container) {
33
- return new BoxLoader($container->plugin, $container->options);
34
- };
35
 
36
- $container['filter.autocomplete'] = function ($container) {
37
- return new Filter\Autocomplete();
38
- };
39
 
40
- $container['notices'] = function ($container) {
41
- return new Notices();
42
- };
43
 
44
- $container['options'] = function ($container) {
45
- $defaults = array(
46
- 'test_mode' => 0
47
- );
48
 
49
- $options = (array) get_option('boxzilla_settings', $defaults);
50
- $options = array_merge($defaults, $options);
51
- return $options;
52
- };
53
 
54
- $container['plugin'] = new Plugin(
55
- 'boxzilla',
56
- 'Boxzilla',
57
- BOXZILLA_VERSION,
58
- BOXZILLA_FILE,
59
- dirname(BOXZILLA_FILE)
60
- );
61
 
62
- $container['plugins'] = function ($container) {
63
- $raw = (array) apply_filters('boxzilla_extensions', array());
 
 
64
 
65
- $plugins = array();
66
- foreach ($raw as $p) {
67
- $plugins[ $p->id() ] = $p;
68
- }
69
- return $plugins;
70
- };
71
- }
 
 
 
 
 
 
 
 
 
 
 
72
  }
8
  use Boxzilla\DI\Container;
9
  use Boxzilla\DI\ServiceProviderInterface;
10
 
11
+ class BoxzillaServiceProvider implements ServiceProviderInterface {
 
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
+ /**
15
+ * Registers services on the given container.
16
+ *
17
+ * This method should only be used to configure services and parameters.
18
+ * It should not get services.
19
+ *
20
+ * @param Container $container An Container instance
21
+ */
22
+ public function register( Container $container ) {
23
+ $container['admin'] = function ( $container ) {
24
+ return new Admin( $container->plugin, $container );
25
+ };
26
 
27
+ $container['admin.menu'] = function( $container ) {
28
+ return new Menu();
29
+ };
30
 
31
+ $container['bootstrapper'] = new Bootstrapper();
 
 
32
 
33
+ $container['box_loader'] = function ( $container ) {
34
+ return new BoxLoader( $container->plugin, $container->options );
35
+ };
36
 
37
+ $container['filter.autocomplete'] = function ( $container ) {
38
+ return new Filter\Autocomplete();
39
+ };
 
40
 
41
+ $container['notices'] = function ( $container ) {
42
+ return new Notices();
43
+ };
 
44
 
45
+ $container['options'] = function ( $container ) {
46
+ $defaults = array(
47
+ 'test_mode' => 0,
48
+ );
 
 
 
49
 
50
+ $options = (array) get_option( 'boxzilla_settings', $defaults );
51
+ $options = array_merge( $defaults, $options );
52
+ return $options;
53
+ };
54
 
55
+ $container['plugin'] = new Plugin(
56
+ 'boxzilla',
57
+ 'Boxzilla',
58
+ BOXZILLA_VERSION,
59
+ BOXZILLA_FILE,
60
+ dirname( BOXZILLA_FILE )
61
+ );
62
+
63
+ $container['plugins'] = function ( $container ) {
64
+ $raw = (array) apply_filters( 'boxzilla_extensions', array() );
65
+
66
+ $plugins = array();
67
+ foreach ( $raw as $p ) {
68
+ $plugins[ $p->id() ] = $p;
69
+ }
70
+ return $plugins;
71
+ };
72
+ }
73
  }
src/class-boxzilla.php CHANGED
@@ -14,9 +14,8 @@ use Boxzilla\Licensing\License;
14
  * @property Plugin $plugin
15
  * @property Plugin[] $plugins
16
  * @property License $license
17
- * @property Bootstrapper $bootstrapper
18
  *
19
  */
20
- class Boxzilla extends ContainerWithPropertyAccess
21
- {
22
  }
14
  * @property Plugin $plugin
15
  * @property Plugin[] $plugins
16
  * @property License $license
 
17
  *
18
  */
19
+ class Boxzilla extends ContainerWithPropertyAccess {
20
+
21
  }
src/class-loader.php CHANGED
@@ -2,342 +2,336 @@
2
 
3
  namespace Boxzilla;
4
 
5
- class BoxLoader
6
- {
7
-
8
- /**
9
- * @var Plugin
10
- */
11
- private $plugin;
12
-
13
- /**
14
- * @var array
15
- */
16
- private $box_ids_to_load = array();
17
-
18
- /**
19
- * @var array
20
- */
21
- protected $options;
22
-
23
- /**
24
- * Constructor
25
- *
26
- * @param Plugin $plugin
27
- * @param array $options
28
- */
29
- public function __construct(Plugin $plugin, array $options)
30
- {
31
- $this->plugin = $plugin;
32
- $this->options = $options;
33
- }
34
-
35
- /**
36
- * Initializes the plugin, runs on `wp` hook.
37
- */
38
- public function init()
39
- {
40
- $this->box_ids_to_load = $this->filter_boxes();
41
-
42
- // Only add other hooks if necessary
43
- if (count($this->box_ids_to_load) > 0) {
44
- add_action('wp_footer', array( $this, 'print_boxes_content' ), 1);
45
- add_action('wp_enqueue_scripts', array( $this, 'load_assets' ), 90);
46
- }
47
- }
48
-
49
- /**
50
- * Get global rules for all boxes
51
- *
52
- * @return array
53
- */
54
- protected function get_filter_rules()
55
- {
56
- $rules = get_option('boxzilla_rules', array());
57
-
58
- if (! is_array($rules)) {
59
- return array();
60
- }
61
-
62
- return $rules;
63
- }
64
-
65
-
66
- /**
67
- * Match a string against an array of patterns, glob-style.
68
- *
69
- * @param string $string
70
- * @param array $patterns
71
- *
72
- * @return boolean
73
- */
74
- protected function match_patterns($string, $patterns, $contains = false)
75
- {
76
- $string = strtolower($string);
77
-
78
- foreach ($patterns as $pattern) {
79
- $pattern = rtrim($pattern, '/');
80
- $pattern = strtolower($pattern);
81
-
82
- // contains means we should do a simple occurrence check
83
- // does not support wildcards
84
- if ($contains) {
85
- return strpos($string, $pattern) !== false;
86
- }
87
-
88
- if (function_exists('fnmatch')) {
89
- $match = fnmatch($pattern, $string);
90
- } else {
91
- $match = ($pattern === $string);
92
- }
93
-
94
- if ($match) {
95
- return true;
96
- }
97
- }
98
-
99
- return false;
100
- }
101
-
102
- /**
103
- * @return string
104
- */
105
- protected function get_request_url()
106
- {
107
- // strip trailing slashes
108
- $request_uri = rtrim($_SERVER['REQUEST_URI'], '/');
109
- return $request_uri;
110
- }
111
-
112
- /**
113
- * Check if this rule passes (conditional matches expected value)
114
- *
115
- * @param string $condition
116
- * @param string $value
117
- * @param boolean $qualifier
118
- *
119
- * @return bool
120
- */
121
- protected function match_rule($condition, $value, $qualifier = true)
122
- {
123
- $matched = false;
124
-
125
- // cast value to array & trim whitespace or excess comma's
126
- $value = array_map('trim', explode(',', rtrim(trim($value), ',')));
127
-
128
- switch ($condition) {
129
- case 'everywhere':
130
- $matched = true;
131
- break;
132
-
133
- case 'is_url':
134
- $url = $this->get_request_url();
135
- $matched = $this->match_patterns($url, $value, $qualifier === 'contains' || $qualifier === 'not_contains');
136
- break;
137
-
138
- case 'is_referer':
139
- if (! empty($_SERVER['HTTP_REFERER'])) {
140
- $referer = $_SERVER['HTTP_REFERER'];
141
- $matched = $this->match_patterns($referer, $value, $qualifier === 'contains' || $qualifier === 'not_contains');
142
- }
143
- break;
144
-
145
- case 'is_post_type':
146
- $post_type = (string) get_post_type();
147
- $matched = in_array($post_type, (array) $value);
148
- break;
149
-
150
- case 'is_single':
151
- case 'is_post':
152
- // convert to empty string if array with just empty string in it
153
- $value = ($value === array( '' )) ? '' : $value;
154
- $matched = is_single($value);
155
- break;
156
-
157
- case 'is_post_in_category':
158
- $matched = is_singular('post') && has_category($value);
159
- break;
160
-
161
-
162
- case 'is_page':
163
- $matched = is_page($value);
164
- break;
165
-
166
- case 'is_post_with_tag':
167
- $matched = is_singular('post') && has_tag($value);
168
- break;
169
-
170
- case 'is_user_logged_in':
171
- $matched = is_user_logged_in();
172
- break;
173
- }
174
-
175
- /**
176
- * Filters whether a given box rule matches the condition and expected value.
177
- *
178
- * The dynamic portion of the hook, `$condition`, refers to the condition being matched.
179
- *
180
- * @param boolean $matched
181
- * @param array $value
182
- */
183
- $matched = apply_filters('boxzilla_box_rule_matches_' . $condition, $matched, $value);
184
-
185
- // if qualifier is set to false, we need to reverse this value here.
186
- if (! $qualifier || $qualifier === 'not_contains') {
187
- $matched = ! $matched;
188
- }
189
-
190
- return $matched;
191
- }
192
-
193
- /**
194
- * Checks which boxes should be loaded for this request.
195
- *
196
- * @return array
197
- */
198
- private function filter_boxes()
199
- {
200
- $box_ids_to_load = array();
201
- $rules = $this->get_filter_rules();
202
-
203
- foreach ($rules as $box_id => $box_rules) {
204
- $matched = false;
205
- $comparision = isset($box_rules['comparision']) ? $box_rules['comparision'] : 'any';
206
-
207
- // loop through all rules for all boxes
208
- foreach ($box_rules as $rule) {
209
-
210
- // skip faulty values (and comparision rule)
211
- if (empty($rule['condition'])) {
212
- continue;
213
- }
214
-
215
- $qualifier = isset($rule['qualifier']) ? $rule['qualifier'] : true;
216
- $matched = $this->match_rule($rule['condition'], $rule['value'], $qualifier);
217
-
218
- // break out of loop if we've already matched
219
- if ($comparision === 'any' && $matched) {
220
- break;
221
- }
222
-
223
- // no need to continue if this rule didn't match
224
- if ($comparision === 'all' && ! $matched) {
225
- break;
226
- }
227
- }
228
-
229
- // value of $matched at this point determines whether box should be loaded
230
- $load_box = $matched;
231
-
232
- /**
233
- * Filters whether a box should be loaded into the page HTML.
234
- *
235
- * The dynamic portion of the hook, `$box_id`, refers to the ID of the box. Return true if you want to output the box.
236
- *
237
- * @param boolean $load_box
238
- */
239
- $load_box = apply_filters('boxzilla_load_box_' . $box_id, $load_box);
240
-
241
- /**
242
- * Filters whether a box should be loaded into the page HTML.
243
- *
244
- * @param boolean $load_box
245
- * @param int $box_id
246
- */
247
- $load_box = apply_filters('boxzilla_load_box', $load_box, $box_id);
248
-
249
- // if matched, box should be loaded on this page
250
- if ($load_box) {
251
- $box_ids_to_load[] = $box_id;
252
- }
253
- }
254
-
255
- /**
256
- * Filters which boxes should be loaded on this page, expects an array of post ID's.
257
- *
258
- * @param array $box_ids_to_load
259
- */
260
- return apply_filters('boxzilla_load_boxes', $box_ids_to_load);
261
- }
262
-
263
- /**
264
- * Load plugin styles
265
- */
266
- public function load_assets()
267
- {
268
- $pre_suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
269
- wp_enqueue_script('boxzilla', $this->plugin->url('/assets/js/script' . $pre_suffix . '.js'), array(), $this->plugin->version(), true);
270
-
271
- // create boxzilla_Global_Options object
272
- $plugin_options = $this->options;
273
- $boxes = $this->get_matched_boxes();
274
-
275
- $data = array(
276
- 'testMode' => (bool) $plugin_options['test_mode'],
277
- 'boxes' => (array) array_map(function (Box $box) {
278
- return $box->get_client_options();
279
- }, $boxes),
280
- );
281
-
282
- wp_localize_script('boxzilla', 'boxzilla_options', $data);
283
-
284
- do_action('boxzilla_load_assets', $this);
285
- }
286
-
287
- public function print_boxes_content()
288
- {
289
- $boxes = $this->get_matched_boxes();
290
- if (empty($boxes)) {
291
- return;
292
- }
293
-
294
- echo '<div style="display: none;">';
295
- foreach ($boxes as $box) {
296
- echo sprintf('<div id="boxzilla-box-%d-content">', $box->ID) . $box->get_content() . '</div>';
297
- }
298
- echo '</div>';
299
- }
300
-
301
- /**
302
- * Get an array of Box objects. These are the boxes that will be loaded for the current request.
303
- *
304
- * @return Box[]
305
- */
306
- public function get_matched_boxes()
307
- {
308
- static $boxes;
309
-
310
- if (is_null($boxes)) {
311
- if (count($this->box_ids_to_load) === 0) {
312
- $boxes = array();
313
- return $boxes;
314
- }
315
-
316
- // query Box posts
317
- $q = new \WP_Query();
318
- $posts = $q->query(array(
319
- 'post_type' => 'boxzilla-box',
320
- 'post_status' => 'publish',
321
- 'post__in' => $this->box_ids_to_load,
322
- 'posts_per_page' => count($this->box_ids_to_load),
323
- 'ignore_sticky_posts' => true,
324
- 'no_found_rows' => true,
325
- ));
326
-
327
- // create `Box` instances out of \WP_Post instances
328
- $boxes = array();
329
- foreach ($posts as $key => $post) {
330
- $box = new Box($post);
331
-
332
- // skip boxes without any content
333
- if ($box->get_content() === '') {
334
- continue;
335
- }
336
-
337
- $boxes[ $key ] = $box;
338
- }
339
- }
340
-
341
- return $boxes;
342
- }
343
  }
2
 
3
  namespace Boxzilla;
4
 
5
+ class BoxLoader {
6
+
7
+
8
+ /**
9
+ * @var Plugin
10
+ */
11
+ private $plugin;
12
+
13
+ /**
14
+ * @var array
15
+ */
16
+ private $box_ids_to_load = array();
17
+
18
+ /**
19
+ * @var array
20
+ */
21
+ protected $options;
22
+
23
+ /**
24
+ * Constructor
25
+ *
26
+ * @param Plugin $plugin
27
+ * @param array $options
28
+ */
29
+ public function __construct( Plugin $plugin, array $options ) {
30
+ $this->plugin = $plugin;
31
+ $this->options = $options;
32
+ }
33
+
34
+ /**
35
+ * Initializes the plugin, runs on `wp` hook.
36
+ */
37
+ public function init() {
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_footer', array( $this, 'print_boxes_content' ), 1 );
43
+ add_action( 'wp_enqueue_scripts', array( $this, 'load_assets' ), 90 );
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Get global rules for all boxes
49
+ *
50
+ * @return array
51
+ */
52
+ protected function get_filter_rules() {
53
+ $rules = get_option( 'boxzilla_rules', array() );
54
+
55
+ if ( ! is_array( $rules ) ) {
56
+ return array();
57
+ }
58
+
59
+ return $rules;
60
+ }
61
+
62
+
63
+ /**
64
+ * Match a string against an array of patterns, glob-style.
65
+ *
66
+ * @param string $string
67
+ * @param array $patterns
68
+ *
69
+ * @return boolean
70
+ */
71
+ protected function match_patterns( $string, $patterns, $contains = false ) {
72
+ $string = strtolower( $string );
73
+
74
+ foreach ( $patterns as $pattern ) {
75
+ $pattern = rtrim( $pattern, '/' );
76
+ $pattern = strtolower( $pattern );
77
+
78
+ // contains means we should do a simple occurrence check
79
+ // does not support wildcards
80
+ if ( $contains ) {
81
+ return strpos( $string, $pattern ) !== false;
82
+ }
83
+
84
+ if ( function_exists( 'fnmatch' ) ) {
85
+ $match = fnmatch( $pattern, $string );
86
+ } else {
87
+ $match = ( $pattern === $string );
88
+ }
89
+
90
+ if ( $match ) {
91
+ return true;
92
+ }
93
+ }
94
+
95
+ return false;
96
+ }
97
+
98
+ /**
99
+ * @return string
100
+ */
101
+ protected function get_request_url() {
102
+ // strip trailing slashes
103
+ $request_uri = rtrim( $_SERVER['REQUEST_URI'], '/' );
104
+ return $request_uri;
105
+ }
106
+
107
+ /**
108
+ * Check if this rule passes (conditional matches expected value)
109
+ *
110
+ * @param string $condition
111
+ * @param string $value
112
+ * @param boolean $qualifier
113
+ *
114
+ * @return bool
115
+ */
116
+ protected function match_rule( $condition, $value, $qualifier = true ) {
117
+ $matched = false;
118
+
119
+ // cast value to array & trim whitespace or excess comma's
120
+ $value = array_map( 'trim', explode( ',', rtrim( trim( $value ), ',' ) ) );
121
+
122
+ switch ( $condition ) {
123
+ case 'everywhere':
124
+ $matched = true;
125
+ break;
126
+
127
+ case 'is_url':
128
+ $url = $this->get_request_url();
129
+ $matched = $this->match_patterns( $url, $value, $qualifier === 'contains' || $qualifier === 'not_contains' );
130
+ break;
131
+
132
+ case 'is_referer':
133
+ if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
134
+ $referer = $_SERVER['HTTP_REFERER'];
135
+ $matched = $this->match_patterns( $referer, $value, $qualifier === 'contains' || $qualifier === 'not_contains' );
136
+ }
137
+ break;
138
+
139
+ case 'is_post_type':
140
+ $post_type = (string) get_post_type();
141
+ $matched = in_array( $post_type, (array) $value, true );
142
+ break;
143
+
144
+ case 'is_single':
145
+ case 'is_post':
146
+ // convert to empty string if array with just empty string in it
147
+ $value = ( $value === array( '' ) ) ? '' : $value;
148
+ $matched = is_single( $value );
149
+ break;
150
+
151
+ case 'is_post_in_category':
152
+ $matched = is_singular( 'post' ) && has_category( $value );
153
+ break;
154
+
155
+ case 'is_page':
156
+ $matched = is_page( $value );
157
+ break;
158
+
159
+ case 'is_post_with_tag':
160
+ $matched = is_singular( 'post' ) && has_tag( $value );
161
+ break;
162
+
163
+ case 'is_user_logged_in':
164
+ $matched = is_user_logged_in();
165
+ break;
166
+ }
167
+
168
+ /**
169
+ * Filters whether a given box rule matches the condition and expected value.
170
+ *
171
+ * The dynamic portion of the hook, `$condition`, refers to the condition being matched.
172
+ *
173
+ * @param boolean $matched
174
+ * @param array $value
175
+ */
176
+ $matched = apply_filters( 'boxzilla_box_rule_matches_' . $condition, $matched, $value );
177
+
178
+ // if qualifier is set to false, we need to reverse this value here.
179
+ if ( ! $qualifier || $qualifier === 'not_contains' ) {
180
+ $matched = ! $matched;
181
+ }
182
+
183
+ return $matched;
184
+ }
185
+
186
+ /**
187
+ * Checks which boxes should be loaded for this request.
188
+ *
189
+ * @return array
190
+ */
191
+ private function filter_boxes() {
192
+ $box_ids_to_load = array();
193
+ $rules = $this->get_filter_rules();
194
+
195
+ foreach ( $rules as $box_id => $box_rules ) {
196
+ $matched = false;
197
+ $comparision = isset( $box_rules['comparision'] ) ? $box_rules['comparision'] : 'any';
198
+
199
+ // loop through all rules for all boxes
200
+ foreach ( $box_rules as $rule ) {
201
+
202
+ // skip faulty values (and comparision rule)
203
+ if ( empty( $rule['condition'] ) ) {
204
+ continue;
205
+ }
206
+
207
+ $qualifier = isset( $rule['qualifier'] ) ? $rule['qualifier'] : true;
208
+ $matched = $this->match_rule( $rule['condition'], $rule['value'], $qualifier );
209
+
210
+ // break out of loop if we've already matched
211
+ if ( $comparision === 'any' && $matched ) {
212
+ break;
213
+ }
214
+
215
+ // no need to continue if this rule didn't match
216
+ if ( $comparision === 'all' && ! $matched ) {
217
+ break;
218
+ }
219
+ }
220
+
221
+ // value of $matched at this point determines whether box should be loaded
222
+ $load_box = $matched;
223
+
224
+ /**
225
+ * Filters whether a box should be loaded into the page HTML.
226
+ *
227
+ * The dynamic portion of the hook, `$box_id`, refers to the ID of the box. Return true if you want to output the box.
228
+ *
229
+ * @param boolean $load_box
230
+ */
231
+ $load_box = apply_filters( 'boxzilla_load_box_' . $box_id, $load_box );
232
+
233
+ /**
234
+ * Filters whether a box should be loaded into the page HTML.
235
+ *
236
+ * @param boolean $load_box
237
+ * @param int $box_id
238
+ */
239
+ $load_box = apply_filters( 'boxzilla_load_box', $load_box, $box_id );
240
+
241
+ // if matched, box should be loaded on this page
242
+ if ( $load_box ) {
243
+ $box_ids_to_load[] = $box_id;
244
+ }
245
+ }
246
+
247
+ /**
248
+ * Filters which boxes should be loaded on this page, expects an array of post ID's.
249
+ *
250
+ * @param array $box_ids_to_load
251
+ */
252
+ return apply_filters( 'boxzilla_load_boxes', $box_ids_to_load );
253
+ }
254
+
255
+ /**
256
+ * Load plugin styles
257
+ */
258
+ public function load_assets() {
259
+ $pre_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
260
+ wp_enqueue_script( 'boxzilla', $this->plugin->url( '/assets/js/script' . $pre_suffix . '.js' ), array(), $this->plugin->version(), true );
261
+
262
+ // create boxzilla_Global_Options object
263
+ $plugin_options = $this->options;
264
+ $boxes = $this->get_matched_boxes();
265
+
266
+ $data = array(
267
+ 'testMode' => (bool) $plugin_options['test_mode'],
268
+ 'boxes' => (array) array_map(
269
+ function ( Box $box ) {
270
+ return $box->get_client_options();
271
+ },
272
+ $boxes
273
+ ),
274
+ );
275
+
276
+ wp_localize_script( 'boxzilla', 'boxzilla_options', $data );
277
+
278
+ do_action( 'boxzilla_load_assets', $this );
279
+ }
280
+
281
+ public function print_boxes_content() {
282
+ $boxes = $this->get_matched_boxes();
283
+ if ( empty( $boxes ) ) {
284
+ return;
285
+ }
286
+
287
+ echo '<div style="display: none;">';
288
+ foreach ( $boxes as $box ) {
289
+ echo sprintf( '<div id="boxzilla-box-%d-content">', $box->ID ) . $box->get_content() . '</div>';
290
+ }
291
+ echo '</div>';
292
+ }
293
+
294
+ /**
295
+ * Get an array of Box objects. These are the boxes that will be loaded for the current request.
296
+ *
297
+ * @return Box[]
298
+ */
299
+ public function get_matched_boxes() {
300
+ static $boxes;
301
+
302
+ if ( is_null( $boxes ) ) {
303
+ if ( count( $this->box_ids_to_load ) === 0 ) {
304
+ $boxes = array();
305
+ return $boxes;
306
+ }
307
+
308
+ // query Box posts
309
+ $q = new \WP_Query();
310
+ $posts = $q->query(
311
+ array(
312
+ 'post_type' => 'boxzilla-box',
313
+ 'post_status' => 'publish',
314
+ 'post__in' => $this->box_ids_to_load,
315
+ 'posts_per_page' => count( $this->box_ids_to_load ),
316
+ 'ignore_sticky_posts' => true,
317
+ 'no_found_rows' => true,
318
+ )
319
+ );
320
+
321
+ // create `Box` instances out of \WP_Post instances
322
+ $boxes = array();
323
+ foreach ( $posts as $key => $post ) {
324
+ $box = new Box( $post );
325
+
326
+ // skip boxes without any content
327
+ if ( $box->get_content() === '' ) {
328
+ continue;
329
+ }
330
+
331
+ $boxes[ $key ] = $box;
332
+ }
333
+ }
334
+
335
+ return $boxes;
336
+ }
 
 
 
 
 
 
337
  }
src/class-php-fallback.php CHANGED
@@ -1,64 +1,61 @@
1
  <?php
2
 
3
- class Boxzilla_PHP_Fallback
4
- {
5
-
6
- /**
7
- * @var string
8
- */
9
- private $plugin_name = '';
10
-
11
- /**
12
- * @var string
13
- */
14
- private $plugin_file = '';
15
-
16
- /**
17
- * @param $plugin_name
18
- * @param $plugin_file
19
- */
20
- public function __construct($plugin_name, $plugin_file)
21
- {
22
- $this->plugin_name = $plugin_name;
23
- $this->plugin_file = $plugin_file;
24
-
25
- // deactivate plugin straight away
26
- add_action('admin_init', array( $this, 'deactivate_self' ));
27
- }
28
-
29
- /**
30
- * @return bool
31
- */
32
- public function deactivate_self()
33
- {
34
- if (! current_user_can('activate_plugins')) {
35
- return false;
36
- }
37
-
38
- // deactivate self
39
- deactivate_plugins($this->plugin_file);
40
-
41
- // get rid of "Plugin activated" notice
42
- if (isset($_GET['activate'])) {
43
- unset($_GET['activate']);
44
- }
45
-
46
- // show notice to user
47
- add_action('admin_notices', array( $this, 'show_notice' ));
48
-
49
- return true;
50
- }
51
-
52
- /**
53
- * @return void
54
- */
55
- public function show_notice()
56
- {
57
- ?>
58
  <div class="updated">
59
- <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); ?>
60
- <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>
61
  </div>
62
  <?php
63
- }
64
  }
1
  <?php
2
 
3
+ class Boxzilla_PHP_Fallback {
4
+
5
+
6
+ /**
7
+ * @var string
8
+ */
9
+ private $plugin_name = '';
10
+
11
+ /**
12
+ * @var string
13
+ */
14
+ private $plugin_file = '';
15
+
16
+ /**
17
+ * @param $plugin_name
18
+ * @param $plugin_file
19
+ */
20
+ public function __construct( $plugin_name, $plugin_file ) {
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
  }
src/class-plugin.php CHANGED
@@ -2,117 +2,109 @@
2
 
3
  namespace Boxzilla;
4
 
5
- class Plugin
6
- {
7
-
8
- /**
9
- * @var string The current version of the plugin
10
- */
11
- protected $version = '1.0';
12
-
13
- /**
14
- * @var string
15
- */
16
- protected $file = '';
17
-
18
- /**
19
- * @var string
20
- */
21
- protected $dir = '';
22
-
23
- /**
24
- * @var string
25
- */
26
- protected $name = '';
27
-
28
- /**
29
- * @var string
30
- */
31
- protected $slug = '';
32
-
33
- /**
34
- * @var int
35
- */
36
- protected $id = 0;
37
-
38
- /**
39
- * Constructor
40
- *
41
- * @param int $id
42
- * @param string $name
43
- * @param string $version
44
- * @param string $file
45
- * @param string $dir (optional)
46
- */
47
- public function __construct($id, $name, $version, $file, $dir = '')
48
- {
49
- $this->id = $id;
50
- $this->name = $name;
51
- $this->version = $version;
52
- $this->file = $file;
53
- $this->dir = $dir;
54
- $this->slug = plugin_basename($file);
55
-
56
- if (empty($dir)) {
57
- $this->dir = dirname($file);
58
- }
59
- }
60
-
61
- /**
62
- * @return int
63
- */
64
- public function id()
65
- {
66
- return $this->id;
67
- }
68
-
69
- /**
70
- * @return string
71
- */
72
- public function slug()
73
- {
74
- return $this->slug;
75
- }
76
-
77
- /**
78
- * @return string
79
- */
80
- public function name()
81
- {
82
- return $this->name;
83
- }
84
-
85
- /**
86
- * @return string
87
- */
88
- public function version()
89
- {
90
- return $this->version;
91
- }
92
-
93
- /**
94
- * @return string
95
- */
96
- public function file()
97
- {
98
- return $this->file;
99
- }
100
-
101
- /**
102
- * @return string
103
- */
104
- public function dir()
105
- {
106
- return $this->dir;
107
- }
108
-
109
- /**
110
- * @param string $path
111
- *
112
- * @return mixed
113
- */
114
- public function url($path = '')
115
- {
116
- return plugins_url($path, $this->file());
117
- }
118
  }
2
 
3
  namespace Boxzilla;
4
 
5
+ class Plugin {
6
+
7
+
8
+ /**
9
+ * @var string The current version of the plugin
10
+ */
11
+ protected $version = '1.0';
12
+
13
+ /**
14
+ * @var string
15
+ */
16
+ protected $file = '';
17
+
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $dir = '';
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ protected $name = '';
27
+
28
+ /**
29
+ * @var string
30
+ */
31
+ protected $slug = '';
32
+
33
+ /**
34
+ * @var int
35
+ */
36
+ protected $id = 0;
37
+
38
+ /**
39
+ * Constructor
40
+ *
41
+ * @param int $id
42
+ * @param string $name
43
+ * @param string $version
44
+ * @param string $file
45
+ * @param string $dir (optional)
46
+ */
47
+ public function __construct( $id, $name, $version, $file, $dir = '' ) {
48
+ $this->id = $id;
49
+ $this->name = $name;
50
+ $this->version = $version;
51
+ $this->file = $file;
52
+ $this->dir = $dir;
53
+ $this->slug = plugin_basename( $file );
54
+
55
+ if ( empty( $dir ) ) {
56
+ $this->dir = dirname( $file );
57
+ }
58
+ }
59
+
60
+ /**
61
+ * @return int
62
+ */
63
+ public function id() {
64
+ return $this->id;
65
+ }
66
+
67
+ /**
68
+ * @return string
69
+ */
70
+ public function slug() {
71
+ return $this->slug;
72
+ }
73
+
74
+ /**
75
+ * @return string
76
+ */
77
+ public function name() {
78
+ return $this->name;
79
+ }
80
+
81
+ /**
82
+ * @return string
83
+ */
84
+ public function version() {
85
+ return $this->version;
86
+ }
87
+
88
+ /**
89
+ * @return string
90
+ */
91
+ public function file() {
92
+ return $this->file;
93
+ }
94
+
95
+ /**
96
+ * @return string
97
+ */
98
+ public function dir() {
99
+ return $this->dir;
100
+ }
101
+
102
+ /**
103
+ * @param string $path
104
+ *
105
+ * @return mixed
106
+ */
107
+ public function url( $path = '' ) {
108
+ return plugins_url( $path, $this->file() );
109
+ }
 
 
 
 
 
 
 
 
110
  }
src/default-actions.php CHANGED
@@ -1,73 +1,78 @@
1
  <?php
2
 
3
- defined('ABSPATH') or exit;
4
 
5
  $boxzilla = boxzilla();
6
 
7
  // Register custom post type
8
- add_action('init', function () use ($boxzilla) {
9
- $args = array(
10
- 'public' => false,
11
- 'labels' => array(
12
- 'name' => __('Boxzilla', 'boxzilla'),
13
- 'singular_name' => __('Box', 'boxzilla'),
14
- 'add_new' => __('Add New', 'boxzilla'),
15
- 'add_new_item' => __('Add New Box', 'boxzilla'),
16
- 'edit_item' => __('Edit Box', 'boxzilla'),
17
- 'new_item' => __('New Box', 'boxzilla'),
18
- 'all_items' => __('All Boxes', 'boxzilla'),
19
- 'view_item' => __('View Box', 'boxzilla'),
20
- 'search_items' => __('Search Boxes', 'boxzilla'),
21
- 'not_found' => __('No Boxes found', 'boxzilla'),
22
- 'not_found_in_trash' => __('No Boxes found in Trash', 'boxzilla'),
23
- 'parent_item_colon' => '',
24
- 'menu_name' => __('Boxzilla', 'boxzilla')
25
- ),
26
- 'show_ui' => true,
27
- 'menu_position' => '108.1337133',
28
- 'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode('<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid meet" viewBox="0 0 16 16" width="16" height="16"><defs><path d="M0 0L16 0L16 16L0 16L0 16L0 0ZM6.72 13.59L6.72 12.47L7.71 13.28L8.94 13.59L10.17 13.28L11.17 12.46L11.85 11.25L12.1 9.76L11.85 8.27L11.17 7.05L10.17 6.23L8.94 5.93L7.71 6.23L6.72 7.04L6.72 2.27L4.16 2.27L4.16 13.59L4.16 13.59L6.72 13.59ZM9.93 9.03L10.06 9.76L9.93 10.49L9.56 11.08L9.01 11.48L8.35 11.63L7.68 11.48L7.13 11.08L6.76 10.49L6.72 10.26L6.72 9.25L6.76 9.03L7.13 8.43L7.68 8.03L8.35 7.88L9.01 8.03L9.56 8.43L9.56 8.43L9.93 9.03Z" id="c1kAiZqIlD"></path></defs><g><g><g><use xlink:href="#c1kAiZqIlD" opacity="1" fill="#a0a5aa" fill-opacity="1"></use></g></g></g></svg>'),
29
- 'query_var' => false,
30
- 'capability_type' => 'box',
31
- 'capabilities' => array(
32
- 'edit_post' => 'edit_box',
33
- 'edit_posts' => 'edit_boxes',
34
- 'edit_others_posts' => 'edit_other_boxes',
35
- 'publish_posts' => 'publish_boxes',
36
- 'read_post' => 'read_box',
37
- 'read_private_posts' => 'read_private_box',
38
- 'delete_posts' => 'delete_box',
39
- ),
40
- );
 
 
41
 
42
- register_post_type('boxzilla-box', $args);
43
 
44
- add_shortcode('boxzilla_link', 'boxzilla_get_link_html');
45
- });
 
46
 
47
- add_action('admin_init', function () {
48
- $admins = get_role('administrator');
 
 
49
 
50
- if (! $admins->has_cap('edit_box')) {
51
- $admins->add_cap('edit_box');
52
- $admins->add_cap('edit_boxes');
53
- $admins->add_cap('edit_other_boxes');
54
- $admins->add_cap('publish_boxes');
55
- $admins->add_cap('read_box');
56
- $admins->add_cap('read_private_box');
57
- $admins->add_cap('delete_box');
58
- }
59
- });
 
60
 
61
- function boxzilla_get_link_html($args = array(), $content = '')
62
- {
63
- $valid_actions = array(
64
- 'show',
65
- 'toggle',
66
- 'hide',
67
- 'dismiss'
68
- );
69
- $box_id = empty($args['box']) ? '' : absint($args['box']);
70
- $class_attr = empty($args['class']) ? '' : esc_attr($args['class']);
71
- $action = empty($args['action']) || ! in_array($args['action'], $valid_actions) ? 'show' : $args['action'];
72
- return sprintf('<a href="javascript:Boxzilla.%s(%s)" class="%s">', $action, $box_id, $class_attr) . $content . '</a>';
73
  }
1
  <?php
2
 
3
+ defined( 'ABSPATH' ) or exit;
4
 
5
  $boxzilla = boxzilla();
6
 
7
  // Register custom post type
8
+ add_action(
9
+ 'init',
10
+ function () use ( $boxzilla ) {
11
+ $args = array(
12
+ 'public' => false,
13
+ 'labels' => array(
14
+ 'name' => __( 'Boxzilla', 'boxzilla' ),
15
+ 'singular_name' => __( 'Box', 'boxzilla' ),
16
+ 'add_new' => __( 'Add New', 'boxzilla' ),
17
+ 'add_new_item' => __( 'Add New Box', 'boxzilla' ),
18
+ 'edit_item' => __( 'Edit Box', 'boxzilla' ),
19
+ 'new_item' => __( 'New Box', 'boxzilla' ),
20
+ 'all_items' => __( 'All Boxes', 'boxzilla' ),
21
+ 'view_item' => __( 'View Box', 'boxzilla' ),
22
+ 'search_items' => __( 'Search Boxes', 'boxzilla' ),
23
+ 'not_found' => __( 'No Boxes found', 'boxzilla' ),
24
+ 'not_found_in_trash' => __( 'No Boxes found in Trash', 'boxzilla' ),
25
+ 'parent_item_colon' => '',
26
+ 'menu_name' => __( 'Boxzilla', 'boxzilla' ),
27
+ ),
28
+ 'show_ui' => true,
29
+ 'menu_position' => '108.1337133',
30
+ 'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode( '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid meet" viewBox="0 0 16 16" width="16" height="16"><defs><path d="M0 0L16 0L16 16L0 16L0 16L0 0ZM6.72 13.59L6.72 12.47L7.71 13.28L8.94 13.59L10.17 13.28L11.17 12.46L11.85 11.25L12.1 9.76L11.85 8.27L11.17 7.05L10.17 6.23L8.94 5.93L7.71 6.23L6.72 7.04L6.72 2.27L4.16 2.27L4.16 13.59L4.16 13.59L6.72 13.59ZM9.93 9.03L10.06 9.76L9.93 10.49L9.56 11.08L9.01 11.48L8.35 11.63L7.68 11.48L7.13 11.08L6.76 10.49L6.72 10.26L6.72 9.25L6.76 9.03L7.13 8.43L7.68 8.03L8.35 7.88L9.01 8.03L9.56 8.43L9.56 8.43L9.93 9.03Z" id="c1kAiZqIlD"></path></defs><g><g><g><use xlink:href="#c1kAiZqIlD" opacity="1" fill="#a0a5aa" fill-opacity="1"></use></g></g></g></svg>' ),
31
+ 'query_var' => false,
32
+ 'capability_type' => 'box',
33
+ 'capabilities' => array(
34
+ 'edit_post' => 'edit_box',
35
+ 'edit_posts' => 'edit_boxes',
36
+ 'edit_others_posts' => 'edit_other_boxes',
37
+ 'publish_posts' => 'publish_boxes',
38
+ 'read_post' => 'read_box',
39
+ 'read_private_posts' => 'read_private_box',
40
+ 'delete_posts' => 'delete_box',
41
+ ),
42
+ );
43
 
44
+ register_post_type( 'boxzilla-box', $args );
45
 
46
+ add_shortcode( 'boxzilla_link', 'boxzilla_get_link_html' );
47
+ }
48
+ );
49
 
50
+ add_action(
51
+ 'admin_init',
52
+ function () {
53
+ $admins = get_role( 'administrator' );
54
 
55
+ if ( ! $admins->has_cap( 'edit_box' ) ) {
56
+ $admins->add_cap( 'edit_box' );
57
+ $admins->add_cap( 'edit_boxes' );
58
+ $admins->add_cap( 'edit_other_boxes' );
59
+ $admins->add_cap( 'publish_boxes' );
60
+ $admins->add_cap( 'read_box' );
61
+ $admins->add_cap( 'read_private_box' );
62
+ $admins->add_cap( 'delete_box' );
63
+ }
64
+ }
65
+ );
66
 
67
+ function boxzilla_get_link_html( $args = array(), $content = '' ) {
68
+ $valid_actions = array(
69
+ 'show',
70
+ 'toggle',
71
+ 'hide',
72
+ 'dismiss',
73
+ );
74
+ $box_id = empty( $args['box'] ) ? '' : absint( $args['box'] );
75
+ $class_attr = empty( $args['class'] ) ? '' : esc_attr( $args['class'] );
76
+ $action = empty( $args['action'] ) || ! in_array( $args['action'], $valid_actions, true ) ? 'show' : $args['action'];
77
+ return sprintf( '<a href="javascript:Boxzilla.%s(%s)" class="%s">', $action, $box_id, $class_attr ) . $content . '</a>';
 
78
  }
src/default-filters.php CHANGED
@@ -1,19 +1,19 @@
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);
11
 
12
  /**
13
  * Allow Jetpack Photon to filter on Boxzilla box content.
14
  */
15
- if (class_exists('Jetpack') && class_exists('Jetpack_Photon') && Jetpack::is_module_active('photon')) {
16
- add_filter('boxzilla_box_content', array( 'Jetpack_Photon', 'filter_the_content' ), 999999);
17
  }
18
 
19
  /**
@@ -21,14 +21,18 @@ if (class_exists('Jetpack') && class_exists('Jetpack_Photon') && Jetpack::is_mod
21
  *
22
  * TODO: Move this to JavaScript instead?
23
  */
24
- add_filter('nav_menu_link_attributes', function($atts)
25
- {
26
- if (strpos($atts['href'], '#boxzilla-') !== 0) {
27
- return $atts;
28
- }
 
29
 
30
- $id = substr($atts['href'], strlen('#boxzilla-'));
31
- $atts['onclick'] = sprintf('Boxzilla.show(%d); return false;', $id);
32
- $atts['href'] = '';
33
- return $atts;
34
- }, 10, 1);
 
 
 
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 );
11
 
12
  /**
13
  * Allow Jetpack Photon to filter on Boxzilla box content.
14
  */
15
+ if ( class_exists( 'Jetpack' ) && class_exists( 'Jetpack_Photon' ) && Jetpack::is_module_active( 'photon' ) ) {
16
+ add_filter( 'boxzilla_box_content', array( 'Jetpack_Photon', 'filter_the_content' ), 999999 );
17
  }
18
 
19
  /**
21
  *
22
  * TODO: Move this to JavaScript instead?
23
  */
24
+ add_filter(
25
+ 'nav_menu_link_attributes',
26
+ function( $atts ) {
27
+ if ( strpos( $atts['href'], '#boxzilla-' ) !== 0 ) {
28
+ return $atts;
29
+ }
30
 
31
+ $id = substr( $atts['href'], strlen( '#boxzilla-' ) );
32
+ $atts['onclick'] = sprintf( 'Boxzilla.show(%d); return false;', $id );
33
+ $atts['href'] = '';
34
+ return $atts;
35
+ },
36
+ 10,
37
+ 1
38
+ );
src/di/class-container-with-property-access.php CHANGED
@@ -9,51 +9,46 @@ namespace Boxzilla\DI;
9
  *
10
  * @package Boxzilla\DI
11
  */
12
- class ContainerWithPropertyAccess extends Container
13
- {
14
-
15
- /**
16
- * @param string $name
17
- * @return mixed
18
- */
19
- public function __get($name)
20
- {
21
- return $this->offsetGet($name);
22
- }
23
-
24
- /**
25
- * @param string $name
26
- * @param mixed $value
27
- */
28
- public function __set($name, $value)
29
- {
30
- $this[ $name ] = $value;
31
- }
32
-
33
- /**
34
- * @param string $name
35
- * @return bool
36
- */
37
- public function __isset($name)
38
- {
39
- return $this->offsetExists($name);
40
- }
41
-
42
- /**
43
- * @param string $name
44
- * @return bool
45
- */
46
- public function has($name)
47
- {
48
- return $this->offsetExists($name);
49
- }
50
-
51
- /**
52
- * @param string $name
53
- * @return mixed
54
- */
55
- public function get($name)
56
- {
57
- return $this->offsetGet($name);
58
- }
59
  }
9
  *
10
  * @package Boxzilla\DI
11
  */
12
+ class ContainerWithPropertyAccess extends Container {
13
+
14
+
15
+ /**
16
+ * @param string $name
17
+ * @return mixed
18
+ */
19
+ public function __get( $name ) {
20
+ return $this->offsetGet( $name );
21
+ }
22
+
23
+ /**
24
+ * @param string $name
25
+ * @param mixed $value
26
+ */
27
+ public function __set( $name, $value ) {
28
+ $this[ $name ] = $value;
29
+ }
30
+
31
+ /**
32
+ * @param string $name
33
+ * @return bool
34
+ */
35
+ public function __isset( $name ) {
36
+ return $this->offsetExists( $name );
37
+ }
38
+
39
+ /**
40
+ * @param string $name
41
+ * @return bool
42
+ */
43
+ public function has( $name ) {
44
+ return $this->offsetExists( $name );
45
+ }
46
+
47
+ /**
48
+ * @param string $name
49
+ * @return mixed
50
+ */
51
+ public function get( $name ) {
52
+ return $this->offsetGet( $name );
53
+ }
 
 
 
 
 
54
  }
src/di/class-container.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
-
3
  /*
4
  * This file is part of Pimple.
5
  *
@@ -31,251 +31,240 @@ namespace Boxzilla\DI;
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
  }
1
  <?php
2
+ // phpcs:ignoreFile
3
  /*
4
  * This file is part of Pimple.
5
  *
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
+ $this->factories = new \SplObjectStorage();
52
+ $this->protected = new \SplObjectStorage();
53
+
54
+ foreach ( $values as $key => $value ) {
55
+ $this->offsetSet( $key, $value );
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Sets a parameter or an object.
61
+ *
62
+ * Objects must be defined as Closures.
63
+ *
64
+ * Allowing any PHP callable leads to difficult to debug problems
65
+ * as function names (strings) are callable (creating a function with
66
+ * the same name as an existing parameter would break your container).
67
+ *
68
+ * @param string $id The unique identifier for the parameter or object
69
+ * @param mixed $value The value of the parameter or a closure to define an object
70
+ * @throws \RuntimeException Prevent override of a frozen service
71
+ */
72
+ public function offsetSet( $id, $value ) {
73
+ if ( isset( $this->frozen[ $id ] ) ) {
74
+ throw new \RuntimeException( sprintf( 'Cannot override frozen service "%s".', $id ) );
75
+ }
76
+
77
+ $this->values[ $id ] = $value;
78
+ $this->keys[ $id ] = true;
79
+ }
80
+
81
+ /**
82
+ * Gets a parameter or an object.
83
+ *
84
+ * @param string $id The unique identifier for the parameter or object
85
+ *
86
+ * @return mixed The value of the parameter or an object
87
+ *
88
+ * @throws \InvalidArgumentException if the identifier is not defined
89
+ */
90
+ public function offsetGet( $id ) {
91
+ if ( ! isset( $this->keys[ $id ] ) ) {
92
+ throw new \InvalidArgumentException( sprintf( 'Identifier "%s" is not defined.', $id ) );
93
+ }
94
+
95
+ if (
96
+ isset( $this->raw[ $id ] )
97
+ || ! is_object( $this->values[ $id ] )
98
+ || isset( $this->protected[ $this->values[ $id ] ] )
99
+ || ! method_exists( $this->values[ $id ], '__invoke' )
100
+ ) {
101
+ return $this->values[ $id ];
102
+ }
103
+
104
+ if ( isset( $this->factories[ $this->values[ $id ] ] ) ) {
105
+ return $this->values[ $id ]($this);
106
+ }
107
+
108
+ $raw = $this->values[ $id ];
109
+ $val = $this->values[ $id ] = $raw( $this );
110
+ $this->raw[ $id ] = $raw;
111
+
112
+ $this->frozen[ $id ] = true;
113
+
114
+ return $val;
115
+ }
116
+
117
+ /**
118
+ * Checks if a parameter or an object is set.
119
+ *
120
+ * @param string $id The unique identifier for the parameter or object
121
+ *
122
+ * @return bool
123
+ */
124
+ public function offsetExists( $id ) {
125
+ return isset( $this->keys[ $id ] );
126
+ }
127
+
128
+ /**
129
+ * Unsets a parameter or an object.
130
+ *
131
+ * @param string $id The unique identifier for the parameter or object
132
+ */
133
+ public function offsetUnset( $id ) {
134
+ if ( isset( $this->keys[ $id ] ) ) {
135
+ if ( is_object( $this->values[ $id ] ) ) {
136
+ unset( $this->factories[ $this->values[ $id ] ], $this->protected[ $this->values[ $id ] ] );
137
+ }
138
+
139
+ unset( $this->values[ $id ], $this->frozen[ $id ], $this->raw[ $id ], $this->keys[ $id ] );
140
+ }
141
+ }
142
+
143
+ /**
144
+ * Marks a callable as being a factory service.
145
+ *
146
+ * @param callable $callable A service definition to be used as a factory
147
+ *
148
+ * @return callable The passed callable
149
+ *
150
+ * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object
151
+ */
152
+ public function factory( $callable ) {
153
+ if ( ! is_object( $callable ) || ! method_exists( $callable, '__invoke' ) ) {
154
+ throw new \InvalidArgumentException( 'Service definition is not a Closure or invokable object.' );
155
+ }
156
+
157
+ $this->factories->attach( $callable );
158
+
159
+ return $callable;
160
+ }
161
+
162
+ /**
163
+ * Protects a callable from being interpreted as a service.
164
+ *
165
+ * This is useful when you want to store a callable as a parameter.
166
+ *
167
+ * @param callable $callable A callable to protect from being evaluated
168
+ *
169
+ * @return callable The passed callable
170
+ *
171
+ * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object
172
+ */
173
+ public function protect( $callable ) {
174
+ if ( ! is_object( $callable ) || ! method_exists( $callable, '__invoke' ) ) {
175
+ throw new \InvalidArgumentException( 'Callable is not a Closure or invokable object.' );
176
+ }
177
+
178
+ $this->protected->attach( $callable );
179
+
180
+ return $callable;
181
+ }
182
+
183
+ /**
184
+ * Gets a parameter or the closure defining an object.
185
+ *
186
+ * @param string $id The unique identifier for the parameter or object
187
+ *
188
+ * @return mixed The value of the parameter or the closure defining an object
189
+ *
190
+ * @throws \InvalidArgumentException if the identifier is not defined
191
+ */
192
+ public function raw( $id ) {
193
+ if ( ! isset( $this->keys[ $id ] ) ) {
194
+ throw new \InvalidArgumentException( sprintf( 'Identifier "%s" is not defined.', $id ) );
195
+ }
196
+
197
+ if ( isset( $this->raw[ $id ] ) ) {
198
+ return $this->raw[ $id ];
199
+ }
200
+
201
+ return $this->values[ $id ];
202
+ }
203
+
204
+ /**
205
+ * Extends an object definition.
206
+ *
207
+ * Useful when you want to extend an existing object definition,
208
+ * without necessarily loading that object.
209
+ *
210
+ * @param string $id The unique identifier for the object
211
+ * @param callable $callable A service definition to extend the original
212
+ *
213
+ * @return callable The wrapped callable
214
+ *
215
+ * @throws \InvalidArgumentException if the identifier is not defined or not a service definition
216
+ */
217
+ public function extend( $id, $callable ) {
218
+ if ( ! isset( $this->keys[ $id ] ) ) {
219
+ throw new \InvalidArgumentException( sprintf( 'Identifier "%s" is not defined.', $id ) );
220
+ }
221
+
222
+ if ( ! is_object( $this->values[ $id ] ) || ! method_exists( $this->values[ $id ], '__invoke' ) ) {
223
+ throw new \InvalidArgumentException( sprintf( 'Identifier "%s" does not contain an object definition.', $id ) );
224
+ }
225
+
226
+ if ( ! is_object( $callable ) || ! method_exists( $callable, '__invoke' ) ) {
227
+ throw new \InvalidArgumentException( 'Extension service definition is not a Closure or invokable object.' );
228
+ }
229
+
230
+ $factory = $this->values[ $id ];
231
+
232
+ $extended = function ( $c ) use ( $callable, $factory ) {
233
+ return $callable( $factory( $c ), $c );
234
+ };
235
+
236
+ if ( isset( $this->factories[ $factory ] ) ) {
237
+ $this->factories->detach( $factory );
238
+ $this->factories->attach( $extended );
239
+ }
240
+
241
+ return $this[ $id ] = $extended;
242
+ }
243
+
244
+ /**
245
+ * Returns all defined value names.
246
+ *
247
+ * @return array An array of value names
248
+ */
249
+ public function keys() {
250
+ return array_keys( $this->values );
251
+ }
252
+
253
+ /**
254
+ * Registers a service provider.
255
+ *
256
+ * @param ServiceProviderInterface $provider A ServiceProviderInterface instance
257
+ * @param array $values An array of values that customizes the provider
258
+ *
259
+ * @return static
260
+ */
261
+ public function register( ServiceProviderInterface $provider, array $values = array() ) {
262
+ $provider->register( $this );
263
+
264
+ foreach ( $values as $key => $value ) {
265
+ $this[ $key ] = $value;
266
+ }
267
+
268
+ return $this;
269
+ }
 
 
 
 
 
 
 
 
 
 
 
270
  }
src/di/interface-service-provider.php CHANGED
@@ -32,15 +32,15 @@ namespace Boxzilla\DI;
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
  }
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 CHANGED
@@ -5,13 +5,12 @@ use Boxzilla\Boxzilla;
5
  /**
6
  * @return Boxzilla
7
  */
8
- function boxzilla()
9
- {
10
- static $instance;
11
 
12
- if (is_null($instance)) {
13
- $instance = new Boxzilla();
14
- }
15
 
16
- return $instance;
17
  }
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-exception.php CHANGED
@@ -4,32 +4,30 @@ namespace Boxzilla\Licensing;
4
 
5
  use Exception;
6
 
7
- class API_Exception extends Exception
8
- {
9
-
10
- /**
11
- * @var string
12
- */
13
- protected $apiCode;
14
-
15
- /**
16
- * API_Exception constructor.
17
- *
18
- * @param string $message
19
- * @param string $apiCode (optional)
20
- */
21
- public function __construct($message, $apiCode = '')
22
- {
23
- parent::__construct($message);
24
-
25
- $this->apiCode = $apiCode;
26
- }
27
-
28
- /**
29
- * @return string
30
- */
31
- public function getApiCode()
32
- {
33
- return $this->apiCode;
34
- }
35
  }
4
 
5
  use Exception;
6
 
7
+ class API_Exception extends Exception {
8
+
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ protected $api_code;
14
+
15
+ /**
16
+ * API_Exception constructor.
17
+ *
18
+ * @param string $message
19
+ * @param string $api_code (optional)
20
+ */
21
+ public function __construct( $message, $api_code = '' ) {
22
+ parent::__construct( $message );
23
+
24
+ $this->api_code = $api_code;
25
+ }
26
+
27
+ /**
28
+ * @return string
29
+ */
30
+ public function getApiCode() {
31
+ return $this->api_code;
32
+ }
 
 
33
  }
src/licensing/class-api.php CHANGED
@@ -6,178 +6,170 @@ use Boxzilla\Plugin;
6
  use Exception;
7
  use WP_Error;
8
 
9
- class API
10
- {
11
-
12
- /**
13
- * @var License
14
- */
15
- protected $license;
16
-
17
- /**
18
- * The API url
19
- *
20
- * @var string
21
- */
22
- public $url = '';
23
-
24
- /**
25
- * @var int
26
- */
27
- protected $error_code = 0;
28
-
29
- /**
30
- * @var string
31
- */
32
- protected $error_message = '';
33
-
34
- /**
35
- * @var
36
- */
37
- protected $last_response;
38
-
39
- /**
40
- * @param string $url
41
- * @param License $license
42
- */
43
- public function __construct($url, License $license)
44
- {
45
- $this->url = $url;
46
- $this->license = $license;
47
- }
48
-
49
- /**
50
- * Gets license status
51
- *
52
- * @return object
53
- */
54
- public function get_license()
55
- {
56
- $endpoint = '/license';
57
- $response = $this->request('GET', $endpoint);
58
- return $response;
59
- }
60
-
61
-
62
- /**
63
- * Logs the current site in to the remote API
64
- *
65
- * @return object
66
- */
67
- public function activate_license()
68
- {
69
- $endpoint = '/license/activations';
70
- $args = array(
71
- 'site_url' => get_option('siteurl')
72
- );
73
- $response = $this->request('POST', $endpoint, $args);
74
- return $response;
75
- }
76
-
77
- /**
78
- * Logs the current site out of the remote API
79
- *
80
- * @return object
81
- */
82
- public function deactivate_license()
83
- {
84
- $endpoint = sprintf('/license/activations/%s', $this->license->activation_key);
85
- $response = $this->request('DELETE', $endpoint);
86
- return $response;
87
- }
88
-
89
- /**
90
- * @param Plugin $plugin
91
- * @return object
92
- */
93
- public function get_plugin(Plugin $plugin)
94
- {
95
- $endpoint = sprintf('/plugins/%s?format=wp', $plugin->id());
96
- $response = $this->request('GET', $endpoint);
97
- return $response;
98
- }
99
-
100
- /**
101
- * @param Plugin[] $plugins (optional)
102
- * @return object
103
- */
104
- public function get_plugins($plugins = null)
105
- {
106
- $args = array(
107
- 'format' => 'wp',
108
- );
109
-
110
- $endpoint = add_query_arg($args, '/plugins');
111
- $response = $this->request('GET', $endpoint);
112
- return $response;
113
- }
114
-
115
- /**
116
- * @param string $method
117
- * @param string $endpoint
118
- * @param array $data
119
- *
120
- * @return object|array
121
- */
122
- public function request($method, $endpoint, $data = array())
123
- {
124
- $url = $this->url . $endpoint;
125
- $args = array(
126
- 'method' => $method,
127
- 'headers' => array(
128
- 'Content-Type' => 'application/json',
129
- 'Accepts' => 'application/json',
130
- ),
131
- );
132
-
133
- // add license key to headers if set
134
- if (! empty($this->license->key)) {
135
- $args['headers']['Authorization'] = 'Bearer ' . urlencode($this->license->key);
136
- }
137
-
138
- if (! empty($data)) {
139
- if (in_array($method, array( 'GET', 'DELETE' ))) {
140
- $url = add_query_arg($data, $url);
141
- } else {
142
- $args['body'] = json_encode($data);
143
- }
144
- }
145
-
146
- $response = wp_remote_request($url, $args);
147
- return $this->parse_response($response);
148
- }
149
-
150
- /**
151
- * @param mixed $response
152
- *
153
- * @return object|null
154
- *
155
- * @throws API_Exception
156
- */
157
- public function parse_response($response)
158
- {
159
- // test for wp errors (request failures)
160
- if ($response instanceof WP_Error) {
161
- throw new API_Exception($response->get_error_message());
162
- }
163
-
164
- // retrieve response body
165
- $body = wp_remote_retrieve_body($response);
166
- if (empty($body)) {
167
- return null;
168
- }
169
-
170
- $json = json_decode($body, false);
171
- if (is_null($json)) {
172
- throw new API_Exception(__("The Boxzilla server returned an invalid response.", 'boxzilla'));
173
- }
174
-
175
- // did request return an error response?
176
- if (wp_remote_retrieve_response_code($response) >= 400) {
177
- throw new API_Exception($json->message, $json->code);
178
- }
179
-
180
- // return actual response data
181
- return $json;
182
- }
183
  }
6
  use Exception;
7
  use WP_Error;
8
 
9
+ class API {
10
+
11
+
12
+ /**
13
+ * @var License
14
+ */
15
+ protected $license;
16
+
17
+ /**
18
+ * The API url
19
+ *
20
+ * @var string
21
+ */
22
+ public $url = '';
23
+
24
+ /**
25
+ * @var int
26
+ */
27
+ protected $error_code = 0;
28
+
29
+ /**
30
+ * @var string
31
+ */
32
+ protected $error_message = '';
33
+
34
+ /**
35
+ * @var
36
+ */
37
+ protected $last_response;
38
+
39
+ /**
40
+ * @param string $url
41
+ * @param License $license
42
+ */
43
+ public function __construct( $url, License $license ) {
44
+ $this->url = $url;
45
+ $this->license = $license;
46
+ }
47
+
48
+ /**
49
+ * Gets license status
50
+ *
51
+ * @return object
52
+ */
53
+ public function get_license() {
54
+ $endpoint = '/license';
55
+ $response = $this->request( 'GET', $endpoint );
56
+ return $response;
57
+ }
58
+
59
+
60
+ /**
61
+ * Logs the current site in to the remote API
62
+ *
63
+ * @return object
64
+ */
65
+ public function activate_license() {
66
+ $endpoint = '/license/activations';
67
+ $args = array(
68
+ 'site_url' => get_option( 'siteurl' ),
69
+ );
70
+ $response = $this->request( 'POST', $endpoint, $args );
71
+ return $response;
72
+ }
73
+
74
+ /**
75
+ * Logs the current site out of the remote API
76
+ *
77
+ * @return object
78
+ */
79
+ public function deactivate_license() {
80
+ $endpoint = sprintf( '/license/activations/%s', $this->license->activation_key );
81
+ $response = $this->request( 'DELETE', $endpoint );
82
+ return $response;
83
+ }
84
+
85
+ /**
86
+ * @param Plugin $plugin
87
+ * @return object
88
+ */
89
+ public function get_plugin( Plugin $plugin ) {
90
+ $endpoint = sprintf( '/plugins/%s?format=wp', $plugin->id() );
91
+ $response = $this->request( 'GET', $endpoint );
92
+ return $response;
93
+ }
94
+
95
+ /**
96
+ * @param Plugin[] $plugins (optional)
97
+ * @return object
98
+ */
99
+ public function get_plugins( $plugins = null ) {
100
+ $args = array(
101
+ 'format' => 'wp',
102
+ );
103
+
104
+ $endpoint = add_query_arg( $args, '/plugins' );
105
+ $response = $this->request( 'GET', $endpoint );
106
+ return $response;
107
+ }
108
+
109
+ /**
110
+ * @param string $method
111
+ * @param string $endpoint
112
+ * @param array $data
113
+ *
114
+ * @return object|array
115
+ */
116
+ public function request( $method, $endpoint, $data = array() ) {
117
+ $url = $this->url . $endpoint;
118
+ $args = array(
119
+ 'method' => $method,
120
+ 'headers' => array(
121
+ 'Content-Type' => 'application/json',
122
+ 'Accepts' => 'application/json',
123
+ ),
124
+ );
125
+
126
+ // add license key to headers if set
127
+ if ( ! empty( $this->license->key ) ) {
128
+ $args['headers']['Authorization'] = 'Bearer ' . urlencode( $this->license->key );
129
+ }
130
+
131
+ if ( ! empty( $data ) ) {
132
+ if ( in_array( $method, array( 'GET', 'DELETE' ), true ) ) {
133
+ $url = add_query_arg( $data, $url );
134
+ } else {
135
+ $args['body'] = json_encode( $data );
136
+ }
137
+ }
138
+
139
+ $response = wp_remote_request( $url, $args );
140
+ return $this->parse_response( $response );
141
+ }
142
+
143
+ /**
144
+ * @param mixed $response
145
+ *
146
+ * @return object|null
147
+ *
148
+ * @throws API_Exception
149
+ */
150
+ public function parse_response( $response ) {
151
+ // test for wp errors (request failures)
152
+ if ( $response instanceof WP_Error ) {
153
+ throw new API_Exception( $response->get_error_message() );
154
+ }
155
+
156
+ // retrieve response body
157
+ $body = wp_remote_retrieve_body( $response );
158
+ if ( empty( $body ) ) {
159
+ return null;
160
+ }
161
+
162
+ $json = json_decode( $body, false );
163
+ if ( is_null( $json ) ) {
164
+ throw new API_Exception( __( 'The Boxzilla server returned an invalid response.', 'boxzilla' ) );
165
+ }
166
+
167
+ // did request return an error response?
168
+ if ( wp_remote_retrieve_response_code( $response ) >= 400 ) {
169
+ throw new API_Exception( $json->message, $json->code );
170
+ }
171
+
172
+ // return actual response data
173
+ return $json;
174
+ }
 
 
 
 
 
 
 
 
175
  }
src/licensing/class-license-manager.php CHANGED
@@ -6,183 +6,175 @@ use Boxzilla\Admin\Notices;
6
  use Boxzilla\Collection;
7
  use Exception;
8
 
9
- class LicenseManager
10
- {
11
-
12
- /**
13
- * @var array
14
- */
15
- protected $extensions = array();
16
-
17
- /**
18
- * @var License
19
- */
20
- protected $license;
21
-
22
- /**
23
- * @var API
24
- */
25
- protected $api;
26
-
27
- /**
28
- * @var array
29
- */
30
- protected $notices = array();
31
-
32
- /**
33
- * @param array $extensions
34
- * @param API $api
35
- * @param License $license
36
- */
37
- public function __construct(array $extensions, API $api, License $license)
38
- {
39
- $this->extensions = $extensions;
40
- $this->license = $license;
41
- $this->api = $api;
42
- }
43
-
44
- /**
45
- * @param mixed $object
46
- * @param string $property
47
- * @param string $default
48
- *
49
- * @return string
50
- */
51
- protected function get_object_property($object, $property, $default = '')
52
- {
53
- return isset($object->$property) ? $object->$property : $default;
54
- }
55
-
56
- /**
57
- * @return void
58
- */
59
- public function init()
60
- {
61
- // do nothing if no extensions are registered at this point
62
- if (empty($this->extensions)) {
63
- return;
64
- }
65
-
66
- // hooks
67
- add_action('boxzilla_after_settings', array( $this, 'show_license_form' ));
68
- add_action('admin_notices', array( $this, 'show_notice' ), 1);
69
-
70
- // listen for activation / deactivation requests
71
- $this->listen();
72
- }
73
-
74
- /**
75
- * Maybe show notice to activate license.
76
- */
77
- public function show_notice()
78
- {
79
- global $current_screen;
80
-
81
- if ($this->license->activated) {
82
- return;
83
- }
84
-
85
- if ($this->get_object_property($current_screen, 'post_type') !== 'boxzilla-box') {
86
- return;
87
- }
88
-
89
- $plugin = $this->extensions[ array_rand($this->extensions) ];
90
- $message = sprintf('Please <a href="%s">activate your Boxzilla license</a> to use %s.', admin_url('edit.php?post_type=boxzilla-box&page=boxzilla-settings'), '<strong>' . $plugin->name() . '</strong>');
91
- echo sprintf('<div class="notice notice-%s"><p>%s</p></div>', 'warning', $message);
92
- }
93
-
94
- /**
95
- * @return void
96
- */
97
- protected function listen()
98
- {
99
-
100
- // do nothing if not authenticated
101
- if (! current_user_can('manage_options')) {
102
- return;
103
- }
104
-
105
- // nothing to do
106
- if (! isset($_POST['boxzilla_license_form'])) {
107
- return;
108
- }
109
-
110
- $action = isset($_POST['action']) ? $_POST['action'] : 'activate';
111
- $key_changed = false;
112
-
113
- // did key change or was "activate" button pressed?
114
- $new_license_key = sanitize_text_field($_POST['boxzilla_license_key']);
115
- if ($new_license_key !== $this->license->key) {
116
- $this->license->key = $new_license_key;
117
- $key_changed = true;
118
- }
119
-
120
- // run actions
121
- if ($action === 'deactivate') {
122
- $this->deactivate_license();
123
- } elseif ($action === 'activate' || $key_changed) {
124
- $this->activate_license();
125
- }
126
-
127
- $this->license->save();
128
- }
129
-
130
- /**
131
- * Deactivate the license
132
- */
133
- protected function deactivate_license()
134
- {
135
- try {
136
- $this->api->deactivate_license();
137
- $this->notices[] = array(
138
- 'type' => 'info',
139
- 'message' => 'Your license was successfully deactivated!',
140
- );
141
- } catch (API_Exception $e) {
142
- $this->notices[] = array(
143
- 'type' => 'warning',
144
- 'message' => $e->getMessage(),
145
- );
146
- }
147
-
148
- $this->license->activated = false;
149
- $this->license->activation_key = '';
150
- }
151
-
152
- /**
153
- * Activate the license
154
- */
155
- protected function activate_license()
156
- {
157
- try {
158
- $activation = $this->api->activate_license();
159
- } catch (API_Exception $e) {
160
- $message = $e->getMessage();
161
- if ($e->getApiCode() == 'license_at_limit') {
162
- $message .= ' You can <a href="https://platform.boxzillaplugin.com/licenses">manage your site activations here</a>.';
163
- }
164
- $this->notices[] = array(
165
- 'type' => 'warning',
166
- 'message' => $message,
167
- );
168
- return;
169
- }
170
-
171
- $this->license->activation_key = $activation->token;
172
- $this->license->activated = true;
173
-
174
- $this->notices[] = array(
175
- 'type' => 'info',
176
- 'message' => 'Your license was successfully activated!',
177
- );
178
- }
179
-
180
- /**
181
- * Shows the license form
182
- */
183
- public function show_license_form()
184
- {
185
- $license = $this->license;
186
- require __DIR__ . '/views/license-form.php';
187
- }
188
  }
6
  use Boxzilla\Collection;
7
  use Exception;
8
 
9
+ class LicenseManager {
10
+
11
+
12
+ /**
13
+ * @var array
14
+ */
15
+ protected $extensions = array();
16
+
17
+ /**
18
+ * @var License
19
+ */
20
+ protected $license;
21
+
22
+ /**
23
+ * @var API
24
+ */
25
+ protected $api;
26
+
27
+ /**
28
+ * @var array
29
+ */
30
+ protected $notices = array();
31
+
32
+ /**
33
+ * @param array $extensions
34
+ * @param API $api
35
+ * @param License $license
36
+ */
37
+ public function __construct( array $extensions, API $api, License $license ) {
38
+ $this->extensions = $extensions;
39
+ $this->license = $license;
40
+ $this->api = $api;
41
+ }
42
+
43
+ /**
44
+ * @param mixed $object
45
+ * @param string $property
46
+ * @param string $default
47
+ *
48
+ * @return string
49
+ */
50
+ protected function get_object_property( $object, $property, $default = '' ) {
51
+ return isset( $object->$property ) ? $object->$property : $default;
52
+ }
53
+
54
+ /**
55
+ * @return void
56
+ */
57
+ public function init() {
58
+ // do nothing if no extensions are registered at this point
59
+ if ( empty( $this->extensions ) ) {
60
+ return;
61
+ }
62
+
63
+ // hooks
64
+ add_action( 'boxzilla_after_settings', array( $this, 'show_license_form' ) );
65
+ add_action( 'admin_notices', array( $this, 'show_notice' ), 1 );
66
+
67
+ // listen for activation / deactivation requests
68
+ $this->listen();
69
+ }
70
+
71
+ /**
72
+ * Maybe show notice to activate license.
73
+ */
74
+ public function show_notice() {
75
+ global $current_screen;
76
+
77
+ if ( $this->license->activated ) {
78
+ return;
79
+ }
80
+
81
+ if ( $this->get_object_property( $current_screen, 'post_type' ) !== 'boxzilla-box' ) {
82
+ return;
83
+ }
84
+
85
+ $plugin = $this->extensions[ array_rand( $this->extensions ) ];
86
+ $message = sprintf( 'Please <a href="%s">activate your Boxzilla license</a> to use %s.', admin_url( 'edit.php?post_type=boxzilla-box&page=boxzilla-settings' ), '<strong>' . $plugin->name() . '</strong>' );
87
+ echo sprintf( '<div class="notice notice-%s"><p>%s</p></div>', 'warning', $message );
88
+ }
89
+
90
+ /**
91
+ * @return void
92
+ */
93
+ protected function listen() {
94
+
95
+ // do nothing if not authenticated
96
+ if ( ! current_user_can( 'manage_options' ) ) {
97
+ return;
98
+ }
99
+
100
+ // nothing to do
101
+ if ( ! isset( $_POST['boxzilla_license_form'] ) ) {
102
+ return;
103
+ }
104
+
105
+ $action = isset( $_POST['action'] ) ? $_POST['action'] : 'activate';
106
+ $key_changed = false;
107
+
108
+ // did key change or was "activate" button pressed?
109
+ $new_license_key = sanitize_text_field( $_POST['boxzilla_license_key'] );
110
+ if ( $new_license_key !== $this->license->key ) {
111
+ $this->license->key = $new_license_key;
112
+ $key_changed = true;
113
+ }
114
+
115
+ // run actions
116
+ if ( $action === 'deactivate' ) {
117
+ $this->deactivate_license();
118
+ } elseif ( $action === 'activate' || $key_changed ) {
119
+ $this->activate_license();
120
+ }
121
+
122
+ $this->license->save();
123
+ }
124
+
125
+ /**
126
+ * Deactivate the license
127
+ */
128
+ protected function deactivate_license() {
129
+ try {
130
+ $this->api->deactivate_license();
131
+ $this->notices[] = array(
132
+ 'type' => 'info',
133
+ 'message' => 'Your license was successfully deactivated!',
134
+ );
135
+ } catch ( API_Exception $e ) {
136
+ $this->notices[] = array(
137
+ 'type' => 'warning',
138
+ 'message' => $e->getMessage(),
139
+ );
140
+ }
141
+
142
+ $this->license->activated = false;
143
+ $this->license->activation_key = '';
144
+ }
145
+
146
+ /**
147
+ * Activate the license
148
+ */
149
+ protected function activate_license() {
150
+ try {
151
+ $activation = $this->api->activate_license();
152
+ } catch ( API_Exception $e ) {
153
+ $message = $e->getMessage();
154
+ if ( $e->getApiCode() == 'license_at_limit' ) {
155
+ $message .= ' You can <a href="https://platform.boxzillaplugin.com/licenses">manage your site activations here</a>.';
156
+ }
157
+ $this->notices[] = array(
158
+ 'type' => 'warning',
159
+ 'message' => $message,
160
+ );
161
+ return;
162
+ }
163
+
164
+ $this->license->activation_key = $activation->token;
165
+ $this->license->activated = true;
166
+
167
+ $this->notices[] = array(
168
+ 'type' => 'info',
169
+ 'message' => 'Your license was successfully activated!',
170
+ );
171
+ }
172
+
173
+ /**
174
+ * Shows the license form
175
+ */
176
+ public function show_license_form() {
177
+ $license = $this->license;
178
+ require __DIR__ . '/views/license-form.php';
179
+ }
 
 
 
 
 
 
 
 
180
  }
src/licensing/class-license-service-provider.php CHANGED
@@ -5,35 +5,34 @@ namespace Boxzilla\Licensing;
5
  use Boxzilla\DI\Container;
6
  use Boxzilla\DI\ServiceProviderInterface;
7
 
8
- class LicenseServiceProvider implements ServiceProviderInterface
9
- {
10
-
11
- /**
12
- * Registers all licensing related services
13
- *
14
- * @param Container $container
15
- */
16
- public function register(Container $container)
17
- {
18
- $container['license'] = function ($container) {
19
- return new License('boxzilla_license');
20
- };
21
-
22
- $container['license_api'] = function ($container) {
23
- $api_url = 'https://my.boxzillaplugin.com/api/v2';
24
- return new API($api_url, $container['license']);
25
- };
26
-
27
- $container['license_manager'] = function ($container) {
28
- return new LicenseManager($container['plugins'], $container['license_api'], $container['license']);
29
- };
30
-
31
- $container['update_manager'] = function ($container) {
32
- return new UpdateManager($container['plugins'], $container['license_api'], $container['license']);
33
- };
34
-
35
- $container['license_poller'] = function ($container) {
36
- return new Poller($container['license_api'], $container['license']);
37
- };
38
- }
39
  }
5
  use Boxzilla\DI\Container;
6
  use Boxzilla\DI\ServiceProviderInterface;
7
 
8
+ class LicenseServiceProvider implements ServiceProviderInterface {
9
+
10
+
11
+ /**
12
+ * Registers all licensing related services
13
+ *
14
+ * @param Container $container
15
+ */
16
+ public function register( Container $container ) {
17
+ $container['license'] = function ( $container ) {
18
+ return new License( 'boxzilla_license' );
19
+ };
20
+
21
+ $container['license_api'] = function ( $container ) {
22
+ $api_url = 'https://my.boxzillaplugin.com/api/v2';
23
+ return new API( $api_url, $container['license'] );
24
+ };
25
+
26
+ $container['license_manager'] = function ( $container ) {
27
+ return new LicenseManager( $container['plugins'], $container['license_api'], $container['license'] );
28
+ };
29
+
30
+ $container['update_manager'] = function ( $container ) {
31
+ return new UpdateManager( $container['plugins'], $container['license_api'], $container['license'] );
32
+ };
33
+
34
+ $container['license_poller'] = function ( $container ) {
35
+ return new Poller( $container['license_api'], $container['license'] );
36
+ };
37
+ }
 
38
  }
src/licensing/class-license.php CHANGED
@@ -14,112 +14,105 @@ namespace Boxzilla\Licensing;
14
  *
15
  * @package Boxzilla\Licensing
16
  */
17
- class License
18
- {
19
-
20
- /**
21
- * @var string The name of the option that holds the License data
22
- */
23
- protected $option_key = '';
24
-
25
- /**
26
- * @var bool Loaded?
27
- */
28
- protected $loaded = false;
29
-
30
- /**
31
- * @var bool Any changes?
32
- */
33
- protected $dirty = false;
34
-
35
- /**
36
- * @var array
37
- */
38
- protected $data;
39
-
40
- /**
41
- * @param string $option_key
42
- */
43
- public function __construct($option_key)
44
- {
45
- $this->option_key = $option_key;
46
- }
47
-
48
- /**
49
- * @param string $name
50
- * @param mixed $value
51
- */
52
- public function __set($name, $value)
53
- {
54
- $this->load();
55
- $this->data[ $name ] = $value;
56
- $this->dirty = true;
57
- }
58
-
59
- /**
60
- * @param string $name
61
- *
62
- * @return mixed
63
- */
64
- public function __get($name)
65
- {
66
- $this->load();
67
- return $this->data[ $name ];
68
- }
69
-
70
- /**
71
- * @param $name
72
- *
73
- * @return bool
74
- */
75
- public function __isset($name)
76
- {
77
- $this->load();
78
- return isset($this->data[ $name ]);
79
- }
80
-
81
- /**
82
- * Load the license data from the database
83
- */
84
- protected function load()
85
- {
86
- if ($this->loaded) {
87
- return;
88
- }
89
-
90
- $defaults = array(
91
- 'key' => '',
92
- 'activation_key' => '',
93
- 'activated' => false,
94
- 'expires_at' => ''
95
- );
96
-
97
- $data = (array) get_option($this->option_key, array());
98
- $this->data = array_replace($defaults, $data);
99
- $this->loaded = true;
100
- }
101
-
102
- /**
103
- * Reload the license data from DB
104
- */
105
- public function reload()
106
- {
107
- $this->loaded = false;
108
- $this->load();
109
- }
110
-
111
- /**
112
- * Save the license in the database
113
- *
114
- * @return License
115
- */
116
- public function save()
117
- {
118
- if (! $this->dirty) {
119
- return;
120
- }
121
-
122
- update_option($this->option_key, $this->data);
123
- $this->dirty = false;
124
- }
125
  }
14
  *
15
  * @package Boxzilla\Licensing
16
  */
17
+ class License {
18
+
19
+
20
+ /**
21
+ * @var string The name of the option that holds the License data
22
+ */
23
+ protected $option_key = '';
24
+
25
+ /**
26
+ * @var bool Loaded?
27
+ */
28
+ protected $loaded = false;
29
+
30
+ /**
31
+ * @var bool Any changes?
32
+ */
33
+ protected $dirty = false;
34
+
35
+ /**
36
+ * @var array
37
+ */
38
+ protected $data;
39
+
40
+ /**
41
+ * @param string $option_key
42
+ */
43
+ public function __construct( $option_key ) {
44
+ $this->option_key = $option_key;
45
+ }
46
+
47
+ /**
48
+ * @param string $name
49
+ * @param mixed $value
50
+ */
51
+ public function __set( $name, $value ) {
52
+ $this->load();
53
+ $this->data[ $name ] = $value;
54
+ $this->dirty = true;
55
+ }
56
+
57
+ /**
58
+ * @param string $name
59
+ *
60
+ * @return mixed
61
+ */
62
+ public function __get( $name ) {
63
+ $this->load();
64
+ return $this->data[ $name ];
65
+ }
66
+
67
+ /**
68
+ * @param $name
69
+ *
70
+ * @return bool
71
+ */
72
+ public function __isset( $name ) {
73
+ $this->load();
74
+ return isset( $this->data[ $name ] );
75
+ }
76
+
77
+ /**
78
+ * Load the license data from the database
79
+ */
80
+ protected function load() {
81
+ if ( $this->loaded ) {
82
+ return;
83
+ }
84
+
85
+ $defaults = array(
86
+ 'key' => '',
87
+ 'activation_key' => '',
88
+ 'activated' => false,
89
+ 'expires_at' => '',
90
+ );
91
+
92
+ $data = (array) get_option( $this->option_key, array() );
93
+ $this->data = array_replace( $defaults, $data );
94
+ $this->loaded = true;
95
+ }
96
+
97
+ /**
98
+ * Reload the license data from DB
99
+ */
100
+ public function reload() {
101
+ $this->loaded = false;
102
+ $this->load();
103
+ }
104
+
105
+ /**
106
+ * Save the license in the database
107
+ *
108
+ * @return License
109
+ */
110
+ public function save() {
111
+ if ( ! $this->dirty ) {
112
+ return;
113
+ }
114
+
115
+ update_option( $this->option_key, $this->data );
116
+ $this->dirty = false;
117
+ }
 
 
 
 
 
 
 
118
  }
src/licensing/class-poller.php CHANGED
@@ -2,69 +2,66 @@
2
 
3
  namespace Boxzilla\Licensing;
4
 
5
- class Poller
6
- {
7
 
8
- /**
9
- * @var API
10
- */
11
- protected $api;
12
 
13
- /**
14
- * @var License
15
- */
16
- protected $license;
17
 
18
- /**
19
- * Poller constructor.
20
- *
21
- * @param API $api
22
- * @param License $license
23
- */
24
- public function __construct(API $api, License $license)
25
- {
26
- $this->api = $api;
27
- $this->license = $license;
28
- }
29
 
30
- /**
31
- * Add hooks.
32
- */
33
- public function init()
34
- {
35
- if (! wp_next_scheduled('boxzilla_check_license_status')) {
36
- wp_schedule_event(time(), 'daily', 'boxzilla_check_license_status');
37
- }
 
 
38
 
39
- add_action('boxzilla_check_license_status', array( $this, 'run' ));
40
- }
 
 
 
 
 
41
 
42
- /**
43
- * Run!
44
- */
45
- public function run()
46
- {
47
- // don't run if license not active
48
- if (! $this->license->activated) {
49
- return;
50
- }
51
 
52
- // assume valid by default, in case of server errors on our side.
53
- $license_still_valid = true;
 
 
 
 
 
 
54
 
55
- try {
56
- $remote_license = $this->api->get_license();
57
- $license_still_valid = $remote_license->valid;
58
- } catch (API_Exception $e) {
59
- // license key wasn't found or expired
60
- if (in_array($e->getApiCode(), array( 'license_invalid', 'license_expired' ))) {
61
- $license_still_valid = false;
62
- }
63
- }
64
 
65
- if (! $license_still_valid) {
66
- $this->license->activated = false;
67
- $this->license->save();
68
- }
69
- }
 
 
 
 
 
 
 
 
 
 
70
  }
2
 
3
  namespace Boxzilla\Licensing;
4
 
5
+ class Poller {
 
6
 
 
 
 
 
7
 
8
+ /**
9
+ * @var API
10
+ */
11
+ protected $api;
12
 
13
+ /**
14
+ * @var License
15
+ */
16
+ protected $license;
 
 
 
 
 
 
 
17
 
18
+ /**
19
+ * Poller constructor.
20
+ *
21
+ * @param API $api
22
+ * @param License $license
23
+ */
24
+ public function __construct( API $api, License $license ) {
25
+ $this->api = $api;
26
+ $this->license = $license;
27
+ }
28
 
29
+ /**
30
+ * Add hooks.
31
+ */
32
+ public function init() {
33
+ if ( ! wp_next_scheduled( 'boxzilla_check_license_status' ) ) {
34
+ wp_schedule_event( time(), 'daily', 'boxzilla_check_license_status' );
35
+ }
36
 
37
+ add_action( 'boxzilla_check_license_status', array( $this, 'run' ) );
38
+ }
 
 
 
 
 
 
 
39
 
40
+ /**
41
+ * Run!
42
+ */
43
+ public function run() {
44
+ // don't run if license not active
45
+ if ( ! $this->license->activated ) {
46
+ return;
47
+ }
48
 
49
+ // assume valid by default, in case of server errors on our side.
50
+ $license_still_valid = true;
 
 
 
 
 
 
 
51
 
52
+ try {
53
+ $remote_license = $this->api->get_license();
54
+ $license_still_valid = $remote_license->valid;
55
+ } catch ( API_Exception $e ) {
56
+ // license key wasn't found or expired
57
+ if ( in_array( $e->getApiCode(), array( 'license_invalid', 'license_expired' ), true ) ) {
58
+ $license_still_valid = false;
59
+ }
60
+ }
61
+
62
+ if ( ! $license_still_valid ) {
63
+ $this->license->activated = false;
64
+ $this->license->save();
65
+ }
66
+ }
67
  }
src/licensing/class-update-manager.php CHANGED
@@ -4,251 +4,255 @@ namespace Boxzilla\Licensing;
4
 
5
  use Boxzilla\Plugin;
6
 
7
- class UpdateManager
8
- {
9
-
10
- /**
11
- * @var array
12
- */
13
- protected $extensions = array();
14
-
15
- /**
16
- * @var API
17
- */
18
- protected $api;
19
-
20
- /**
21
- * @var License
22
- */
23
- protected $license;
24
-
25
- /**
26
- * @var
27
- */
28
- protected $available_updates;
29
-
30
- /**
31
- * @param array $extensions
32
- * @param API $api
33
- * @param License $license
34
- */
35
- public function __construct(array $extensions, API $api, License $license)
36
- {
37
- $this->extensions = $extensions;
38
- $this->license = $license;
39
- $this->api = $api;
40
- }
41
-
42
- /**
43
- * Add hooks
44
- */
45
- public function init()
46
- {
47
- add_filter('pre_set_site_transient_update_plugins', array( $this, 'add_updates' ));
48
- add_filter('plugins_api', array( $this, 'get_plugin_info' ), 20, 3);
49
- add_filter('http_request_args', array( $this, 'add_auth_headers' ), 10, 2);
50
- }
51
-
52
- /**
53
- * This adds the license key header to download package requests.
54
- *
55
- * @param array $args
56
- * @param string $url
57
- *
58
- * @return mixed
59
- */
60
- public function add_auth_headers($args, $url)
61
- {
62
- // only act on download request's to the Boxzilla update API
63
- if (strpos($url, $this->api->url) !== 0 || strpos($url, '/download') === false) {
64
- return $args;
65
- }
66
-
67
- // only add if activation key not empty
68
- if (empty($this->license->activation_key)) {
69
- return $args;
70
- }
71
-
72
- if (! isset($args['headers'])) {
73
- $args['headers'] = array();
74
- }
75
-
76
- $args['headers']['Authorization'] = sprintf('Bearer %s', $this->license->activation_key);
77
- return $args;
78
- }
79
-
80
- private function get_plugin_by_slug($slug)
81
- {
82
- foreach ($this->extensions as $p) {
83
- // find plugin by slug
84
- if (dirname($p->slug()) === $slug) {
85
- return $p;
86
- }
87
- }
88
-
89
- return null;
90
- }
91
-
92
- /**
93
- * @param $result
94
- * @param string $action
95
- * @param null $args
96
- *
97
- * @return object
98
- */
99
- public function get_plugin_info($result, $action = '', $args = null)
100
- {
101
- // do nothing for unrelated requests
102
- if ($action !== 'plugin_information' || ! isset($args->slug)) {
103
- return $result;
104
- }
105
-
106
- // only act on our own plugins
107
- $plugin = $this->get_plugin_by_slug($args->slug);
108
- if ($plugin === null) {
109
- return $result;
110
- }
111
-
112
- return $this->get_update_info($plugin);
113
- }
114
-
115
- /**
116
- * @param object $updates
117
- * @return object
118
- */
119
- public function add_updates($updates)
120
- {
121
-
122
- // do nothing if no plugins registered
123
- if (empty($this->extensions)) {
124
- return $updates;
125
- }
126
-
127
- // failsafe WP bug
128
- if (empty($updates) || ! isset($updates->response) || ! is_array($updates->response)) {
129
- return $updates;
130
- }
131
-
132
- // fetch available updates
133
- $available_updates = $this->fetch_updates();
134
-
135
- // merge with other updates
136
- $updates->response = array_merge($updates->response, $available_updates);
137
-
138
- return $updates;
139
- }
140
-
141
- /**
142
- * Fetch array of available updates from remote server
143
- *
144
- * @return array
145
- */
146
- protected function fetch_updates()
147
- {
148
- if (is_array($this->available_updates)) {
149
- return $this->available_updates;
150
- }
151
-
152
- // don't try if we failed a request recently.
153
- $failed_at = get_transient('boxzilla_request_failed');
154
- if (! empty($failed_at) && ((strtotime('now') - 300) < $failed_at)) {
155
- return array();
156
- }
157
-
158
- // fetch remote info
159
- try {
160
- $remote_plugins = $this->api->get_plugins();
161
- } catch (API_Exception $e) {
162
- // set flag for 5 minutes
163
- set_transient('boxzilla_request_failed', strtotime('now'), 300);
164
- return array();
165
- }
166
-
167
- // filter remote plugins, we only want the ones with an update available
168
- $this->available_updates = $this->filter_remote_plugins($remote_plugins);
169
-
170
- return $this->available_updates;
171
- }
172
-
173
- /**
174
- * @param $remote_plugins
175
- * @return array
176
- */
177
- protected function filter_remote_plugins($remote_plugins)
178
- {
179
- $available_updates = array();
180
-
181
- // find new versions
182
- foreach ($remote_plugins as $remote_plugin) {
183
-
184
- // only act on update info of our own plugins
185
- if (! isset($this->extensions[ $remote_plugin->sid ])) {
186
- continue;
187
- }
188
-
189
- // sanity check
190
- if (! isset($remote_plugin->new_version)) {
191
- continue;
192
- }
193
-
194
- // find corresponding local plugin
195
- /** @var Plugin $local_plugin */
196
- $local_plugin = $this->extensions[ $remote_plugin->sid ];
197
-
198
- // plugin found and local plugin version not same as remote version?
199
- if (! $local_plugin || version_compare($local_plugin->version(), $remote_plugin->new_version, '>=')) {
200
- continue;
201
- }
202
-
203
- // add some dynamic data
204
- $available_updates[ $local_plugin->slug() ] = $this->format_response($local_plugin, $remote_plugin);
205
- }
206
-
207
- return $available_updates;
208
- }
209
-
210
- /**
211
- * @param Plugin $plugin
212
- *
213
- * @return null
214
- */
215
- public function get_update_info(Plugin $plugin)
216
- {
217
- $available_updates = $this->fetch_updates();
218
-
219
- if (isset($available_updates[ $plugin->slug() ])) {
220
- return $available_updates[ $plugin->slug() ];
221
- }
222
-
223
- return null;
224
- }
225
-
226
- /**
227
- * @param Plugin $plugin
228
- * @param $response
229
- *
230
- * @return mixed
231
- */
232
- protected function format_response(Plugin $plugin, $response)
233
- {
234
- $response->slug = dirname($plugin->slug());
235
- $response->plugin = $plugin->slug();
236
-
237
- // add some notices if license is inactive
238
- if (! $this->license->activated) {
239
- $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'));
240
- $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;
241
- $response->package = null;
242
- }
243
-
244
- // cast subkey objects to array as that is what WP expects
245
- $response->sections = get_object_vars($response->sections);
246
- $response->banners = get_object_vars($response->banners);
247
- $response->contributors = get_object_vars($response->contributors);
248
- $response->contributors = array_map(function ($v) {
249
- return get_object_vars($v);
250
- }, $response->contributors);
251
-
252
- return $response;
253
- }
 
 
 
 
254
  }
4
 
5
  use Boxzilla\Plugin;
6
 
7
+ class UpdateManager {
8
+
9
+
10
+ /**
11
+ * @var array
12
+ */
13
+ protected $extensions = array();
14
+
15
+ /**
16
+ * @var API
17
+ */
18
+ protected $api;
19
+
20
+ /**
21
+ * @var License
22
+ */
23
+ protected $license;
24
+
25
+ /**
26
+ * @var
27
+ */
28
+ protected $available_updates;
29
+
30
+ /**
31
+ * @param array $extensions
32
+ * @param API $api
33
+ * @param License $license
34
+ */
35
+ public function __construct( array $extensions, API $api, License $license ) {
36
+ $this->extensions = $extensions;
37
+ $this->license = $license;
38
+ $this->api = $api;
39
+ }
40
+
41
+ /**
42
+ * Add hooks
43
+ */
44
+ public function init() {
45
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'add_updates' ) );
46
+ add_filter( 'plugins_api', array( $this, 'get_plugin_info' ), 20, 3 );
47
+ add_filter( 'http_request_args', array( $this, 'add_auth_headers' ), 10, 2 );
48
+ }
49
+
50
+ /**
51
+ * This adds the license key header to download package requests.
52
+ *
53
+ * @param array $args
54
+ * @param string $url
55
+ *
56
+ * @return mixed
57
+ */
58
+ public function add_auth_headers( $args, $url ) {
59
+ // only act on download request's to the Boxzilla update API
60
+ if ( strpos( $url, $this->api->url ) !== 0 || strpos( $url, '/download' ) === false ) {
61
+ return $args;
62
+ }
63
+
64
+ // only add if activation key not empty
65
+ if ( empty( $this->license->activation_key ) ) {
66
+ return $args;
67
+ }
68
+
69
+ if ( ! isset( $args['headers'] ) ) {
70
+ $args['headers'] = array();
71
+ }
72
+
73
+ $args['headers']['Authorization'] = sprintf( 'Bearer %s', $this->license->activation_key );
74
+ return $args;
75
+ }
76
+
77
+ private function get_plugin_by_slug( $slug ) {
78
+ foreach ( $this->extensions as $p ) {
79
+ // find plugin by slug
80
+ if ( dirname( $p->slug() ) === $slug ) {
81
+ return $p;
82
+ }
83
+ }
84
+
85
+ return null;
86
+ }
87
+
88
+ /**
89
+ * @param $result
90
+ * @param string $action
91
+ * @param null $args
92
+ *
93
+ * @return object
94
+ */
95
+ public function get_plugin_info( $result, $action = '', $args = null ) {
96
+ // do nothing for unrelated requests
97
+ if ( $action !== 'plugin_information' || ! isset( $args->slug ) ) {
98
+ return $result;
99
+ }
100
+
101
+ // only act on our plugins
102
+ if ( strpos( $args->slug, 'boxzilla-' ) !== 0 ) {
103
+ return $result;
104
+ }
105
+
106
+ return $this->get_update_info( $args->slug );
107
+ }
108
+
109
+ /**
110
+ * @param object $updates
111
+ * @return object
112
+ */
113
+ public function add_updates( $updates ) {
114
+
115
+ // do nothing if no plugins registered
116
+ if ( empty( $this->extensions ) ) {
117
+ return $updates;
118
+ }
119
+
120
+ // failsafe WP bug
121
+ if ( empty( $updates ) || ! isset( $updates->response ) || ! is_array( $updates->response ) ) {
122
+ return $updates;
123
+ }
124
+
125
+ // fetch available updates
126
+ $available_updates = $this->fetch_updates();
127
+
128
+ // merge with other updates
129
+ $updates->response = array_merge( $updates->response, $available_updates );
130
+
131
+ return $updates;
132
+ }
133
+
134
+ /**
135
+ * Fetch array of available updates from remote server
136
+ *
137
+ * @return array
138
+ */
139
+ protected function fetch_updates() {
140
+ if ( is_array( $this->available_updates ) ) {
141
+ return $this->available_updates;
142
+ }
143
+
144
+ // don't try if we failed a request recently.
145
+ $failed_at = get_transient( 'boxzilla_request_failed' );
146
+ if ( ! empty( $failed_at ) && ( ( strtotime( 'now' ) - 300 ) < $failed_at ) ) {
147
+ return array();
148
+ }
149
+
150
+ // fetch remote info
151
+ try {
152
+ $remote_plugins = $this->api->get_plugins();
153
+ } catch ( API_Exception $e ) {
154
+ // set flag for 5 minutes
155
+ set_transient( 'boxzilla_request_failed', strtotime( 'now' ), 300 );
156
+ return array();
157
+ }
158
+
159
+ // filter remote plugins, we only want the ones with an update available
160
+ $this->available_updates = $this->filter_remote_plugins( $remote_plugins );
161
+
162
+ return $this->available_updates;
163
+ }
164
+
165
+ /**
166
+ * @param $remote_plugins
167
+ * @return array
168
+ */
169
+ protected function filter_remote_plugins( $remote_plugins ) {
170
+ $available_updates = array();
171
+
172
+ // find new versions
173
+ foreach ( $remote_plugins as $remote_plugin ) {
174
+
175
+ // sanity check
176
+ if ( ! isset( $remote_plugin->new_version ) ) {
177
+ continue;
178
+ }
179
+
180
+ // if plugin is activated, we can access it here
181
+ if ( isset( $this->extensions[ $remote_plugin->sid ] ) ) {
182
+
183
+ /** @var Plugin $local_plugin */
184
+ $local_plugin = $this->extensions[ $remote_plugin->sid ];
185
+
186
+ // plugin found and local plugin version not same as remote version?
187
+ if ( !$local_plugin || version_compare( $local_plugin->version(), $remote_plugin->new_version, '>=' ) ) {
188
+ continue;
189
+ }
190
+
191
+ // add some dynamic data
192
+ $available_updates[ $local_plugin->slug() ] = $this->format_response( $local_plugin->slug(), $remote_plugin );
193
+ } else {
194
+ // if plugin is not active, use get_plugin_data for fetching version
195
+ $plugin_file = WP_PLUGIN_DIR . "/{$remote_plugin->slug}/{$remote_plugin->slug}.php";
196
+ $plugin_data = get_plugin_data( $plugin_file );
197
+
198
+ if ( !$plugin_data || version_compare( $plugin_data['Version'], $remote_plugin->new_version, '>=' ) ) {
199
+ continue;
200
+ }
201
+
202
+ // add some dynamic data
203
+ $slug = plugin_basename( $plugin_file );
204
+ $available_updates[ $slug ] = $this->format_response( $slug, $remote_plugin );
205
+ }
206
+ }
207
+
208
+ return $available_updates;
209
+ }
210
+
211
+ /**
212
+ * @param string $slug
213
+ *
214
+ * @return null
215
+ */
216
+ public function get_update_info( $slug ) {
217
+ $available_updates = $this->fetch_updates();
218
+
219
+ foreach ( $available_updates as $plugin_file => $update_info ) {
220
+ if ( $slug === $update_info->slug ) {
221
+ return $update_info;
222
+ }
223
+ }
224
+
225
+ return null;
226
+ }
227
+
228
+ /**
229
+ * @param $slug
230
+ * @param $response
231
+ *
232
+ * @return mixed
233
+ */
234
+ protected function format_response( $slug, $response ) {
235
+ $response->slug = dirname($slug);
236
+ $response->plugin = $slug;
237
+
238
+ // add some notices if license is inactive
239
+ if ( ! $this->license->activated ) {
240
+ $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' ) );
241
+ $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;
242
+ $response->package = null;
243
+ }
244
+
245
+ // cast subkey objects to array as that is what WP expects
246
+ $response->sections = get_object_vars( $response->sections );
247
+ $response->banners = get_object_vars( $response->banners );
248
+ $response->contributors = get_object_vars( $response->contributors );
249
+ $response->contributors = array_map(
250
+ function ( $v ) {
251
+ return get_object_vars( $v );
252
+ },
253
+ $response->contributors
254
+ );
255
+
256
+ return $response;
257
+ }
258
  }
src/licensing/views/license-form.php CHANGED
@@ -1,66 +1,76 @@
1
  <?php
2
  // prevent direct file access
3
- defined('ABSPATH') or exit;
4
 
5
  /** @var Boxzilla\Licensing\License $license */
6
  ?>
7
 
8
- <h2><?php _e('License & Plugin Updates', 'boxzilla'); ?></h2>
9
 
10
- <?php if (! $license->activated) {
11
- ?>
 
12
  <div class="error inline">
13
  <p>
14
- <strong><?php _e('Warning! You are <u>not</u> receiving plugin updates for the following plugin(s):', 'boxzilla'); ?></strong>
15
  </p>
16
  <ul class="ul-square">
17
  <?php
18
- foreach ($this->extensions as $p) {
19
- echo '<li>' . esc_html($p->name()) . '</li>';
20
- } ?>
 
21
  </ul>
22
  <p>
23
- To fix this, please activate your license using the form below.
24
  </p>
25
  </div>
26
- <?php
27
- } ?>
 
28
 
29
- <?php foreach ($this->notices as $notice) {
30
- ?>
 
31
  <div class="notice notice-<?php echo $notice['type']; ?> inline">
32
  <p><?php echo $notice['message']; ?></p>
33
  </div>
34
- <?php
35
- } ?>
 
36
 
37
  <form method="post">
38
  <table class="form-table">
39
  <tr valign="top">
40
- <th><?php _e('License Key', 'boxzilla'); ?></th>
41
  <td>
42
- <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) {
43
- echo 'readonly';
44
- } ?> />
45
- <input class="button" type="submit" name="action" value="<?php echo ($this->license->activated) ? 'deactivate' : 'activate'; ?>" />
 
 
 
 
46
  <p class="help">
47
- <?php echo sprintf(__('The license key received when purchasing your premium Boxzilla plan. <a href="%s">You can find it here</a>.', 'boxzilla'), 'https://platform.boxzillaplugin.com/'); ?>
48
  </p>
49
  </td>
50
  </tr>
51
  <tr valign="top">
52
- <th><?php _e('License Status', 'boxzilla'); ?></th>
53
  <td>
54
  <?php
55
- if ($license->activated) {
56
- ?>
57
- <p><span class="status positive"><?php _e('ACTIVE', 'boxzilla'); ?></span> - <?php _e('you are receiving plugin updates', 'boxzilla'); ?></p>
58
- <?php
59
- } else {
60
- ?>
61
- <p><span class="status negative"><?php _e('INACTIVE', 'boxzilla'); ?></span> - <?php _e('you are <strong>not</strong> receiving plugin updates', 'boxzilla'); ?></p>
62
- <?php
63
- } ?>
 
64
  </td>
65
  </tr>
66
  </table>
@@ -69,7 +79,7 @@ defined('ABSPATH') or exit;
69
 
70
 
71
  <p>
72
- <input type="submit" class="button button-primary" name="action" value="<?php _e('Save Changes'); ?>" />
73
  </p>
74
 
75
  <input type="hidden" name="boxzilla_license_form" value="1" />
1
  <?php
2
  // prevent direct file access
3
+ defined( 'ABSPATH' ) or exit;
4
 
5
  /** @var Boxzilla\Licensing\License $license */
6
  ?>
7
 
8
+ <h2><?php _e( 'License & Plugin Updates', 'boxzilla' ); ?></h2>
9
 
10
+ <?php
11
+ if ( ! $license->activated ) {
12
+ ?>
13
  <div class="error inline">
14
  <p>
15
+ <strong><?php _e( 'Warning! You are <u>not</u> receiving plugin updates for the following plugin(s):', 'boxzilla' ); ?></strong>
16
  </p>
17
  <ul class="ul-square">
18
  <?php
19
+ foreach ( $this->extensions as $p ) {
20
+ echo '<li>' . esc_html( $p->name() ) . '</li>';
21
+ }
22
+ ?>
23
  </ul>
24
  <p>
25
+ <?php _e( 'To fix this, please activate your license using the form below.', 'boxzilla' ); ?>
26
  </p>
27
  </div>
28
+ <?php
29
+ }
30
+ ?>
31
 
32
+ <?php
33
+ foreach ( $this->notices as $notice ) {
34
+ ?>
35
  <div class="notice notice-<?php echo $notice['type']; ?> inline">
36
  <p><?php echo $notice['message']; ?></p>
37
  </div>
38
+ <?php
39
+ }
40
+ ?>
41
 
42
  <form method="post">
43
  <table class="form-table">
44
  <tr valign="top">
45
+ <th><?php _e( 'License Key', 'boxzilla' ); ?></th>
46
  <td>
47
+ <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 ); ?>"
48
+ <?php
49
+ if ( $this->license->activated ) {
50
+ echo 'readonly';
51
+ }
52
+ ?>
53
+ />
54
+ <input class="button" type="submit" name="action" value="<?php echo ( $this->license->activated ) ? 'deactivate' : 'activate'; ?>" />
55
  <p class="help">
56
+ <?php echo sprintf( __( 'The license key received when purchasing your premium Boxzilla plan. <a href="%s">You can find it here</a>.', 'boxzilla' ), 'https://platform.boxzillaplugin.com/' ); ?>
57
  </p>
58
  </td>
59
  </tr>
60
  <tr valign="top">
61
+ <th><?php _e( 'License Status', 'boxzilla' ); ?></th>
62
  <td>
63
  <?php
64
+ if ( $license->activated ) {
65
+ ?>
66
+ <p><span class="status positive"><?php _e( 'ACTIVE', 'boxzilla' ); ?></span> - <?php _e( 'you are receiving plugin updates', 'boxzilla' ); ?></p>
67
+ <?php
68
+ } else {
69
+ ?>
70
+ <p><span class="status negative"><?php _e( 'INACTIVE', 'boxzilla' ); ?></span> - <?php _e( 'you are <strong>not</strong> receiving plugin updates', 'boxzilla' ); ?></p>
71
+ <?php
72
+ }
73
+ ?>
74
  </td>
75
  </tr>
76
  </table>
79
 
80
 
81
  <p>
82
+ <input type="submit" class="button button-primary" name="action" value="<?php _e( 'Save Changes', 'boxzilla' ); ?>" />
83
  </p>
84
 
85
  <input type="hidden" name="boxzilla_license_form" value="1" />
vendor/composer/autoload_classmap.php CHANGED
@@ -12,6 +12,7 @@ return array(
12
  'Boxzilla\\Admin\\Migrations' => $baseDir . '/src/admin/class-migrations.php',
13
  'Boxzilla\\Admin\\Notices' => $baseDir . '/src/admin/class-notices.php',
14
  'Boxzilla\\Admin\\ReviewNotice' => $baseDir . '/src/admin/class-review-notice.php',
 
15
  'Boxzilla\\Box' => $baseDir . '/src/class-box.php',
16
  'Boxzilla\\BoxLoader' => $baseDir . '/src/class-loader.php',
17
  'Boxzilla\\Boxzilla' => $baseDir . '/src/class-boxzilla.php',
12
  'Boxzilla\\Admin\\Migrations' => $baseDir . '/src/admin/class-migrations.php',
13
  'Boxzilla\\Admin\\Notices' => $baseDir . '/src/admin/class-notices.php',
14
  'Boxzilla\\Admin\\ReviewNotice' => $baseDir . '/src/admin/class-review-notice.php',
15
+ 'Boxzilla\\Bootstrapper' => $baseDir . '/src/class-bootstrapper.php',
16
  'Boxzilla\\Box' => $baseDir . '/src/class-box.php',
17
  'Boxzilla\\BoxLoader' => $baseDir . '/src/class-loader.php',
18
  'Boxzilla\\Boxzilla' => $baseDir . '/src/class-boxzilla.php',
vendor/composer/autoload_static.php CHANGED
@@ -17,6 +17,7 @@ class ComposerStaticInit38e5bd5c00bdfd9a6ae58e314c6ae5ae
17
  'Boxzilla\\Admin\\Migrations' => __DIR__ . '/../..' . '/src/admin/class-migrations.php',
18
  'Boxzilla\\Admin\\Notices' => __DIR__ . '/../..' . '/src/admin/class-notices.php',
19
  'Boxzilla\\Admin\\ReviewNotice' => __DIR__ . '/../..' . '/src/admin/class-review-notice.php',
 
20
  'Boxzilla\\Box' => __DIR__ . '/../..' . '/src/class-box.php',
21
  'Boxzilla\\BoxLoader' => __DIR__ . '/../..' . '/src/class-loader.php',
22
  'Boxzilla\\Boxzilla' => __DIR__ . '/../..' . '/src/class-boxzilla.php',
17
  'Boxzilla\\Admin\\Migrations' => __DIR__ . '/../..' . '/src/admin/class-migrations.php',
18
  'Boxzilla\\Admin\\Notices' => __DIR__ . '/../..' . '/src/admin/class-notices.php',
19
  'Boxzilla\\Admin\\ReviewNotice' => __DIR__ . '/../..' . '/src/admin/class-review-notice.php',
20
+ 'Boxzilla\\Bootstrapper' => __DIR__ . '/../..' . '/src/class-bootstrapper.php',
21
  'Boxzilla\\Box' => __DIR__ . '/../..' . '/src/class-box.php',
22
  'Boxzilla\\BoxLoader' => __DIR__ . '/../..' . '/src/class-loader.php',
23
  'Boxzilla\\Boxzilla' => __DIR__ . '/../..' . '/src/class-boxzilla.php',