Better WordPress Minify - Version 1.3.3

Version Description

  • Fixed an issue with wrong min/config.php file.
Download this release

Release Info

Developer OddOneOut
Plugin Icon wp plugin Better WordPress Minify
Version 1.3.3
Comparing to
See all releases

Code changes from version 1.3.0 to 1.3.3

bwp-minify.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Better WordPress Minify
4
  Plugin URI: http://betterwp.net/wordpress-plugins/bwp-minify/
5
  Description: Allows you to minify your CSS and JS files for faster page loading for visitors. This plugin uses the PHP library <a href="http://code.google.com/p/minify/">Minify</a> and relies on WordPress's enqueueing system rather than the output buffer (will not break your website in most cases). This plugin is very customizable and easy to use.
6
- Version: 1.3.0
7
  Text Domain: bwp-minify
8
  Domain Path: /languages/
9
  Author: Khang Minh
3
  Plugin Name: Better WordPress Minify
4
  Plugin URI: http://betterwp.net/wordpress-plugins/bwp-minify/
5
  Description: Allows you to minify your CSS and JS files for faster page loading for visitors. This plugin uses the PHP library <a href="http://code.google.com/p/minify/">Minify</a> and relies on WordPress's enqueueing system rather than the output buffer (will not break your website in most cases). This plugin is very customizable and easy to use.
6
+ Version: 1.3.3
7
  Text Domain: bwp-minify
8
  Domain Path: /languages/
9
  Author: Khang Minh
bwp-minify.pot CHANGED
@@ -2,8 +2,8 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: BWP Minify\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2014-07-15 15:23+0700\n"
6
- "PO-Revision-Date: 2014-07-15 15:24+0700\n"
7
  "Last-Translator: Khang Minh <contact@betterwp.net>\n"
8
  "Language-Team: \n"
9
  "Language: en_US\n"
@@ -20,65 +20,65 @@ msgstr ""
20
  msgid "Plugin Configurations"
21
  msgstr ""
22
 
23
- #: includes/bwp-option-page/includes/class-bwp-option-page.php:428
24
  msgid "Save Changes"
25
  msgstr ""
26
 
27
- #: includes/class-bwp-enqueued-detector.php:221
28
- #: includes/class-bwp-enqueued-detector.php:234
29
  msgid "Handle"
30
  msgstr ""
31
 
32
- #: includes/class-bwp-enqueued-detector.php:222
33
- #: includes/class-bwp-enqueued-detector.php:235
34
  msgid "Position"
35
  msgstr ""
36
 
37
- #: includes/class-bwp-enqueued-detector.php:223
38
  msgid "Script src"
39
  msgstr ""
40
 
41
- #: includes/class-bwp-enqueued-detector.php:224
42
- #: includes/class-bwp-enqueued-detector.php:238
43
  msgid "Actions"
44
  msgstr ""
45
 
46
- #: includes/class-bwp-enqueued-detector.php:236
47
  msgid "Media"
48
  msgstr ""
49
 
50
- #: includes/class-bwp-enqueued-detector.php:237
51
  msgid "Style src"
52
  msgstr ""
53
 
54
- #: includes/class-bwp-enqueued-detector.php:348
55
- msgid "move to header"
56
- msgstr ""
57
-
58
  #: includes/class-bwp-enqueued-detector.php:349
59
- msgid "move to footer"
60
  msgstr ""
61
 
62
  #: includes/class-bwp-enqueued-detector.php:350
63
- #: includes/class-bwp-enqueued-detector.php:353
64
- msgid "print separately"
65
  msgstr ""
66
 
67
  #: includes/class-bwp-enqueued-detector.php:351
68
  #: includes/class-bwp-enqueued-detector.php:354
69
- msgid "ignore"
70
  msgstr ""
71
 
72
  #: includes/class-bwp-enqueued-detector.php:352
73
  #: includes/class-bwp-enqueued-detector.php:355
74
- msgid "forget"
75
  msgstr ""
76
 
77
- #: includes/class-bwp-enqueued-detector.php:380
 
 
 
 
 
78
  msgid "select"
79
  msgstr ""
80
 
81
- #: includes/class-bwp-enqueued-detector.php:400
82
  msgid ""
83
  "No enqueued files detected.<br /><br />Please try visiting a few pages on "
84
  "your site and then refresh this page.<br /><br />You should clear this list "
@@ -86,29 +86,40 @@ msgid ""
86
  "not done automatically."
87
  msgstr ""
88
 
89
- #: includes/class-bwp-enqueued-detector.php:435
 
 
 
 
 
 
 
 
90
  msgid "header"
91
  msgstr ""
92
 
93
- #: includes/class-bwp-enqueued-detector.php:436
94
  msgid "footer"
95
  msgstr ""
96
 
97
- #: includes/class-bwp-enqueued-detector.php:446
98
- #, php-format
99
- msgid "separated in %s"
100
  msgstr ""
101
 
102
- #: includes/class-bwp-enqueued-detector.php:447
103
  #, php-format
104
  msgid "minified in %s"
105
  msgstr ""
106
 
107
- #: includes/class-bwp-enqueued-detector.php:453
108
- msgid "forgotten"
109
  msgstr ""
110
 
111
- #: includes/class-bwp-enqueued-detector.php:454
 
 
 
 
112
  #, php-format
113
  msgid "ignored in %s"
114
  msgstr ""
@@ -117,78 +128,78 @@ msgstr ""
117
  #, php-format
118
  msgid ""
119
  "%s requires WordPress <strong>%s</strong> or higher and PHP <strong>%s</"
120
- "strong> or higher. The plugin will not protected function until you update "
121
- "your software. Please deactivate this plugin."
122
  msgstr ""
123
 
124
- #: includes/class-bwp-framework-improved.php:228
125
  msgid "Development Log"
126
  msgstr ""
127
 
128
- #: includes/class-bwp-framework-improved.php:228
129
  msgid "Frequently Asked Questions"
130
  msgstr ""
131
 
132
- #: includes/class-bwp-framework-improved.php:228
133
  msgid "FAQ"
134
  msgstr ""
135
 
136
- #: includes/class-bwp-framework-improved.php:228
137
  msgid "Got a problem? Send me a feedback!"
138
  msgstr ""
139
 
140
- #: includes/class-bwp-framework-improved.php:228
141
  msgid "Contact"
142
  msgstr ""
143
 
144
- #: includes/class-bwp-framework-improved.php:235
145
  msgid ""
146
  "You can buy me some special coffees if you appreciate my work, thank you!"
147
  msgstr ""
148
 
149
- #: includes/class-bwp-framework-improved.php:249
150
  #, php-format
151
  msgid "Donate to %s"
152
  msgstr ""
153
 
154
- #: includes/class-bwp-framework-improved.php:251
155
  msgid "One cup $5.00"
156
  msgstr ""
157
 
158
- #: includes/class-bwp-framework-improved.php:252
159
  msgid "Two cups $10.00"
160
  msgstr ""
161
 
162
- #: includes/class-bwp-framework-improved.php:253
163
  msgid "Five cups! $25.00"
164
  msgstr ""
165
 
166
- #: includes/class-bwp-framework-improved.php:254
167
  msgid "One LL-cup!!! $50.00"
168
  msgstr ""
169
 
170
- #: includes/class-bwp-framework-improved.php:255
171
  msgid "... or any amount!"
172
  msgstr ""
173
 
174
- #: includes/class-bwp-framework-improved.php:270
175
  msgid "Latest updates from BetterWP.net!"
176
  msgstr ""
177
 
178
- #: includes/class-bwp-framework-improved.php:271
179
  msgid "Follow me on Twitter!"
180
  msgstr ""
181
 
182
- #: includes/class-bwp-framework-improved.php:281
183
  msgid "This Plugin is Proudly Sponsored By"
184
  msgstr ""
185
 
186
- #: includes/class-bwp-framework-improved.php:300
187
  #, php-format
188
  msgid "You are using version %s!"
189
  msgstr ""
190
 
191
- #: includes/class-bwp-framework-improved.php:541
192
  msgid "Settings"
193
  msgstr ""
194
 
@@ -197,167 +208,187 @@ msgstr ""
197
  msgid "Minify group %s not found."
198
  msgstr ""
199
 
200
- #: includes/class-bwp-minify-fetcher.php:121
201
  msgid "Invalid Minify directory, please check Minify settings."
202
  msgstr ""
203
 
204
- #: includes/class-bwp-minify.php:211 includes/class-bwp-minify.php:939
205
- #: includes/class-bwp-minify.php:940
206
  msgid "General Options"
207
  msgstr ""
208
 
209
- #: includes/class-bwp-minify.php:214 includes/class-bwp-minify.php:947
210
- #: includes/class-bwp-minify.php:948
211
  msgid "Advanced Options"
212
  msgstr ""
213
 
214
- #: includes/class-bwp-minify.php:217 includes/class-bwp-minify.php:955
215
  msgid "Manage enqueued Files"
216
  msgstr ""
217
 
218
- #: includes/class-bwp-minify.php:929
 
 
 
 
 
 
 
 
 
219
  msgid "Better WordPress Minify"
220
  msgstr ""
221
 
222
- #: includes/class-bwp-minify.php:956
223
  msgid "Enqueued Files"
224
  msgstr ""
225
 
226
- #: includes/class-bwp-minify.php:971
227
  msgid "You do not have sufficient permissions to access this page."
228
  msgstr ""
229
 
230
- #: includes/class-bwp-minify.php:1061
231
  msgid "Plugin Functionality"
232
  msgstr ""
233
 
234
- #: includes/class-bwp-minify.php:1062
235
  msgid "Minify JS files automatically?"
236
  msgstr ""
237
 
238
- #: includes/class-bwp-minify.php:1063
239
  msgid "Minify CSS files automatically?"
240
  msgstr ""
241
 
242
- #: includes/class-bwp-minify.php:1064
243
  msgid "Minify <code>bloginfo()</code> stylesheets?"
244
  msgstr ""
245
 
246
- #: includes/class-bwp-minify.php:1065
 
 
 
 
247
  msgid "URL path to Minify library (relative to domain root)"
248
  msgstr ""
249
 
250
- #: includes/class-bwp-minify.php:1066
251
  msgid "One minify string will contain"
252
  msgstr ""
253
 
254
- #: includes/class-bwp-minify.php:1067
255
  msgid "For cache buster, use"
256
  msgstr ""
257
 
258
- #: includes/class-bwp-minify.php:1068
259
  msgid "Minify Library Settings"
260
  msgstr ""
261
 
262
- #: includes/class-bwp-minify.php:1069
263
  msgid "WordPress document root"
264
  msgstr ""
265
 
266
- #: includes/class-bwp-minify.php:1070
267
  msgid "Cache directory"
268
  msgstr ""
269
 
270
- #: includes/class-bwp-minify.php:1071
271
  msgid "Cache age"
272
  msgstr ""
273
 
274
- #: includes/class-bwp-minify.php:1072
275
  msgid "Enable bubble CSS import?"
276
  msgstr ""
277
 
278
- #: includes/class-bwp-minify.php:1073
279
  msgid "Enable cache file locking?"
280
  msgstr ""
281
 
282
- #: includes/class-bwp-minify.php:1074
283
  msgid "Enable debugging?"
284
  msgstr ""
285
 
286
- #: includes/class-bwp-minify.php:1095
287
  #, php-format
288
  msgid ""
289
  "<em>These options will let you control how the actual <a href=\"%s\" target="
290
  "\"_blank\">Minify</a> library works.</em>"
291
  msgstr ""
292
 
293
- #: includes/class-bwp-minify.php:1102
294
  msgid "second(s)"
295
  msgstr ""
296
 
297
- #: includes/class-bwp-minify.php:1103
298
  msgid "minute(s)"
299
  msgstr ""
300
 
301
- #: includes/class-bwp-minify.php:1104
302
  msgid "hour(s)"
303
  msgstr ""
304
 
305
- #: includes/class-bwp-minify.php:1105
306
  msgid "day(s)"
307
  msgstr ""
308
 
309
- #: includes/class-bwp-minify.php:1108
310
  msgid "No cache buster"
311
  msgstr ""
312
 
313
- #: includes/class-bwp-minify.php:1109
314
  msgid "Cache folder&#8217;s last modified time"
315
  msgstr ""
316
 
317
- #: includes/class-bwp-minify.php:1110
318
  msgid "Your WordPress&#8217;s current version"
319
  msgstr ""
320
 
321
- #: includes/class-bwp-minify.php:1111
322
  msgid "Your theme&#8217;s current version"
323
  msgstr ""
324
 
325
- #: includes/class-bwp-minify.php:1112
326
  msgid "A custom number"
327
  msgstr ""
328
 
329
- #: includes/class-bwp-minify.php:1116 includes/class-bwp-minify.php:1117
330
  msgid ""
331
  "you can still use <code>bwp_minify()</code> helper function if you disable "
332
  "this."
333
  msgstr ""
334
 
335
- #: includes/class-bwp-minify.php:1118
336
  msgid ""
337
  "enable this for themes that use <code>bloginfo()</code> to print the main "
338
  "stylesheet (i.e. <code>style.css</code>). If you want to minify <code>style."
339
  "css</code> with the rest of your css files, you must enqueue it."
340
  msgstr ""
341
 
342
- #: includes/class-bwp-minify.php:1119
 
 
 
 
 
 
 
343
  #, php-format
344
  msgid ""
345
  "move all <code>@import</code> rules in CSS files to the top. More info <a "
346
  "href=\"%s\" target=\"_blank\">here</a>."
347
  msgstr ""
348
 
349
- #: includes/class-bwp-minify.php:1120
350
  msgid "disable this if filesystem is NFS."
351
  msgstr ""
352
 
353
- #: includes/class-bwp-minify.php:1121
354
  #, php-format
355
  msgid ""
356
  "only enable this when minification does not work as expected. More info <a "
357
  "href=\"%s\" target=\"_blank\">here</a>."
358
  msgstr ""
359
 
360
- #: includes/class-bwp-minify.php:1127
361
  #, php-format
362
  msgid ""
363
  "Leave empty to use default value, which is <code>%s</code>.<br />Please read "
@@ -365,7 +396,7 @@ msgid ""
365
  "to properly modify this."
366
  msgstr ""
367
 
368
- #: includes/class-bwp-minify.php:1139
369
  #, php-format
370
  msgid ""
371
  "Expect a full path to a publicly accessible directory (i.e. can be served "
@@ -375,133 +406,133 @@ msgid ""
375
  "\"_blank\">here</a>. "
376
  msgstr ""
377
 
378
- #: includes/class-bwp-minify.php:1150
379
  msgid "file(s) at most."
380
  msgstr ""
381
 
382
- #: includes/class-bwp-minify.php:1154
383
  msgid "&mdash;"
384
  msgstr ""
385
 
386
- #: includes/class-bwp-minify.php:1170
387
  msgid "Note"
388
  msgstr ""
389
 
390
- #: includes/class-bwp-minify.php:1171
391
  msgid ""
392
  "Whenever a new cache buster is used, you are telling browsers to refresh "
393
  "cached JS and CSS files. This is particularly useful when source files have "
394
  "been changed, use this feature wisely."
395
  msgstr ""
396
 
397
- #: includes/class-bwp-minify.php:1214 includes/class-bwp-minify.php:1223
398
- #: includes/class-bwp-minify.php:1564 includes/class-bwp-minify.php:1786
399
- #: includes/class-bwp-minify.php:1884
400
  msgid "Notice"
401
  msgstr ""
402
 
403
- #: includes/class-bwp-minify.php:1216
404
  #, php-format
405
  msgid "<strong>%d</strong> cached files have been deleted successfully!"
406
  msgstr ""
407
 
408
- #: includes/class-bwp-minify.php:1224
409
  msgid ""
410
  "Could not delete any cached files. Please manually flush the cache directory."
411
  msgstr ""
412
 
413
- #: includes/class-bwp-minify.php:1251
414
  msgid "Friendly Minify Urls"
415
  msgstr ""
416
 
417
- #: includes/class-bwp-minify.php:1252
418
  msgid "Enable friendly Minify urls"
419
  msgstr ""
420
 
421
- #: includes/class-bwp-minify.php:1254
422
  #, php-format
423
  msgid ""
424
  "Friendly Minify url path (relative to your Site/Network Address). More info "
425
  "<a href=\"%s#friendly_minify_urls\" target=\"_blank\">here</a>."
426
  msgstr ""
427
 
428
- #: includes/class-bwp-minify.php:1259
429
  msgid "Path to Nginx config file"
430
  msgstr ""
431
 
432
- #: includes/class-bwp-minify.php:1260
433
  msgid "Content Delivery Network (CDN)"
434
  msgstr ""
435
 
436
- #: includes/class-bwp-minify.php:1261
437
  msgid "Enable CDN support"
438
  msgstr ""
439
 
440
- #: includes/class-bwp-minify.php:1262
441
  msgid "SSL support for CDN"
442
  msgstr ""
443
 
444
- #: includes/class-bwp-minify.php:1263
445
  msgid "CDN hostname (primary)"
446
  msgstr ""
447
 
448
- #: includes/class-bwp-minify.php:1264
449
  msgid "CDN hostname for JS files"
450
  msgstr ""
451
 
452
- #: includes/class-bwp-minify.php:1265
453
  msgid "CDN hostname for CSS files"
454
  msgstr ""
455
 
456
- #: includes/class-bwp-minify.php:1266
457
  msgid "Additional HTTP headers used with CDN"
458
  msgstr ""
459
 
460
- #: includes/class-bwp-minify.php:1282
461
  #, php-format
462
  msgid ""
463
  "Turn long and ugly Minify urls with query variables (such as <code>%s</"
464
  "code>), into more friendly ones (e.g. <code>%s</code>). "
465
  msgstr ""
466
 
467
- #: includes/class-bwp-minify.php:1291
468
  #, php-format
469
  msgid ""
470
  "Serve minified contents using a <a href=\"%s\" target=\"_blank\">CDN</a> to "
471
  "improve performance."
472
  msgstr ""
473
 
474
- #: includes/class-bwp-minify.php:1298
475
  msgid "WordPress"
476
  msgstr ""
477
 
478
- #: includes/class-bwp-minify.php:1299
479
  msgid "Server rewrite rules"
480
  msgstr ""
481
 
482
- #: includes/class-bwp-minify.php:1302
483
  msgid "Do not use SSL for CDN"
484
  msgstr ""
485
 
486
- #: includes/class-bwp-minify.php:1303
487
  msgid "Use SSL when suitable"
488
  msgstr ""
489
 
490
- #: includes/class-bwp-minify.php:1304
491
  msgid "Use protocol-relative URL"
492
  msgstr ""
493
 
494
- #: includes/class-bwp-minify.php:1309
495
  msgid "for CDN support it is highly recommended that you enable this feature."
496
  msgstr ""
497
 
498
- #: includes/class-bwp-minify.php:1312
499
  msgid ""
500
  "please make sure that your CDN is property setup before enabling this "
501
  "feature."
502
  msgstr ""
503
 
504
- #: includes/class-bwp-minify.php:1323
505
  #, php-format
506
  msgid ""
507
  "Expect a full path to your Nginx configuration file (e.g. <code>%s</code>). "
@@ -511,7 +542,7 @@ msgid ""
511
  "blank and BWP Minify will use that config file."
512
  msgstr ""
513
 
514
- #: includes/class-bwp-minify.php:1337
515
  #, php-format
516
  msgid ""
517
  "Use either hostnames provided by your CDN or custom ones. Please do NOT "
@@ -519,79 +550,79 @@ msgid ""
519
  "Good examples are: <code>%s</code>, <code>%s</code>, etc."
520
  msgstr ""
521
 
522
- #: includes/class-bwp-minify.php:1346 includes/class-bwp-minify.php:1350
523
  msgid "used when not empty."
524
  msgstr ""
525
 
526
- #: includes/class-bwp-minify.php:1360
527
  msgid ""
528
  "If you're looking for a CDN, I highly recommend <strong>MaxCDN</strong>. "
529
  "They provide the most reliable CDN service for WordPress sites. Support is "
530
  "exceptional and you got a 30-day Money Back Guarantee, too."
531
  msgstr ""
532
 
533
- #: includes/class-bwp-minify.php:1367
534
  msgid "Create a MaxCDN account today and save 25%</a>"
535
  msgstr ""
536
 
537
- #: includes/class-bwp-minify.php:1391
538
  msgid ""
539
  "Enqueued file lists have been cleared successfully. Try refreshing this page "
540
  "to see updated file lists."
541
  msgstr ""
542
 
543
- #: includes/class-bwp-minify.php:1402
544
- msgid "Move enqueued JS files to appropriate positions"
545
  msgstr ""
546
 
547
- #: includes/class-bwp-minify.php:1403
548
- msgid "Move enqueued CSS files to appropriate positions"
549
  msgstr ""
550
 
551
- #: includes/class-bwp-minify.php:1411
552
  #, php-format
553
  msgid ""
554
  "Below you can find a list of enqueued JS files detected by this plugin. "
555
- "Press <strong>select</strong> and then choose an appropriate position for "
556
- "selected JS file. You can also directly type in one script handle "
557
  "(<strong>NOT filename/script src</strong>) per line in the input field if "
558
- "you want. More info <a href=\"%s#positioning_your_files\" target=\"_blank"
559
  "\">here</a>."
560
  msgstr ""
561
 
562
- #: includes/class-bwp-minify.php:1420
563
  #, php-format
564
  msgid ""
565
  "Below you can find a list of enqueued CSS files detected by this plugin. "
566
- "Press <strong>select</strong> and then choose an appropriate position for "
567
- "selected CSS file. You can also directly type in one style handle "
568
  "(<strong>NOT filename/style src</strong>) per line in the input field if you "
569
- "want. More info <a href=\"%s#positioning_your_files\" target=\"_blank"
570
- "\">here</a>."
571
  msgstr ""
572
 
573
- #: includes/class-bwp-minify.php:1514
574
  msgid ""
575
  "All positions have been saved. Try refreshing this page for updated file "
576
  "lists."
577
  msgstr ""
578
 
579
- #: includes/class-bwp-minify.php:1518
580
  msgid "All options have been saved."
581
  msgstr ""
582
 
583
- #: includes/class-bwp-minify.php:1530
584
  #, php-format
585
  msgid "Minify config file <code>%s</code> has been updated successfully."
586
  msgstr ""
587
 
588
- #: includes/class-bwp-minify.php:1539 includes/class-bwp-minify.php:1553
589
- #: includes/class-bwp-minify.php:1978 includes/class-bwp-minify.php:1984
590
- #: includes/class-bwp-minify.php:1994 includes/class-bwp-minify.php:2006
591
  msgid "Error"
592
  msgstr ""
593
 
594
- #: includes/class-bwp-minify.php:1541
595
  #, php-format
596
  msgid ""
597
  "Minify config file <code>config.php</code> could not be found. The auto-"
@@ -600,25 +631,25 @@ msgid ""
600
  "file."
601
  msgstr ""
602
 
603
- #: includes/class-bwp-minify.php:1554
604
  #, php-format
605
  msgid ""
606
  "There was an error writing to Minify config file <code>%s</code>. Please try "
607
  "again."
608
  msgstr ""
609
 
610
- #: includes/class-bwp-minify.php:1565
611
  #, php-format
612
  msgid ""
613
  "Minify config file <code>%s</code> is not writable. See <a href=\"#minify."
614
  "config.php\">below</a> for details."
615
  msgstr ""
616
 
617
- #: includes/class-bwp-minify.php:1608 includes/class-bwp-minify.php:1620
618
  msgid "Warning"
619
  msgstr ""
620
 
621
- #: includes/class-bwp-minify.php:1610
622
  #, php-format
623
  msgid ""
624
  "Cache directory <code>%s</code> does not exist and can not be created "
@@ -626,72 +657,72 @@ msgid ""
626
  "is writable for Minify to perform more efficiently."
627
  msgstr ""
628
 
629
- #: includes/class-bwp-minify.php:1622
630
  #, php-format
631
  msgid ""
632
  "Cache directory <code>%s</code> is not writable. Please try CHMOD your cache "
633
  "directory to 755. If you still see this warning, try CHMOD to 777."
634
  msgstr ""
635
 
636
- #: includes/class-bwp-minify.php:1660
637
- msgid "Styles to be ignored (not minified)"
638
  msgstr ""
639
 
640
- #: includes/class-bwp-minify.php:1661
641
- msgid "Styles to be minified and then printed separately"
642
  msgstr ""
643
 
644
- #: includes/class-bwp-minify.php:1662
645
- msgid "Styles to be forgotten (to remove duplicate styles)"
646
  msgstr ""
647
 
648
- #: includes/class-bwp-minify.php:1671
649
- msgid "Scripts to be ignored (not minified)"
650
  msgstr ""
651
 
652
- #: includes/class-bwp-minify.php:1672
653
- msgid "Scripts to be minified and then printed separately"
654
  msgstr ""
655
 
656
- #: includes/class-bwp-minify.php:1673
657
- msgid "Scripts to be minified in header"
658
  msgstr ""
659
 
660
- #: includes/class-bwp-minify.php:1674
661
- msgid "Scripts to be minified in footer"
662
  msgstr ""
663
 
664
- #: includes/class-bwp-minify.php:1675
665
- msgid "Scripts to be forgotten (to remove duplicate scripts)"
666
  msgstr ""
667
 
668
- #: includes/class-bwp-minify.php:1733
669
  msgid "Save Changes and Flush Cache"
670
  msgstr ""
671
 
672
- #: includes/class-bwp-minify.php:1736
673
  msgid "Flush Cache"
674
  msgstr ""
675
 
676
- #: includes/class-bwp-minify.php:1748
677
  msgid "Clear File Lists"
678
  msgstr ""
679
 
680
- #: includes/class-bwp-minify.php:1762
681
  #, php-format
682
  msgid ""
683
  "BWP Minify was not able to auto-detect friendly url based on Minify's "
684
  "current cache directory (<code>%s</code>)."
685
  msgstr ""
686
 
687
- #: includes/class-bwp-minify.php:1768
688
  msgid ""
689
  "You must manually set this setting for this feature to work.<br />Please "
690
  "make sure that the entered URL path correctly links to Minify's current "
691
  "cache directory."
692
  msgstr ""
693
 
694
- #: includes/class-bwp-minify.php:1776
695
  #, php-format
696
  msgid ""
697
  "Leave empty to use <code>%s</code>, which is auto-detected based on Minify's "
@@ -700,14 +731,14 @@ msgid ""
700
  "directory."
701
  msgstr ""
702
 
703
- #: includes/class-bwp-minify.php:1787
704
  #, php-format
705
  msgid ""
706
  "In a sub-directory multisite environment, a blog path will be added before "
707
  "the URL path (e.g. <code>%s</code>) when friendly Minify urls are served."
708
  msgstr ""
709
 
710
- #: includes/class-bwp-minify.php:1807
711
  #, php-format
712
  msgid ""
713
  "Leave empty to use parent directory of WordPress's <code>index.php</code>, "
@@ -719,7 +750,7 @@ msgid ""
719
  "\"%s#minify_document_root\" target=\"_blank\">here</a>."
720
  msgstr ""
721
 
722
- #: includes/class-bwp-minify.php:1824
723
  #, php-format
724
  msgid ""
725
  "Leave empty to use <code>$_SERVER['DOCUMENT_ROOT']</code>, which is <code>"
@@ -731,49 +762,50 @@ msgid ""
731
  "\"%s#minify_document_root\" target=\"_blank\">here</a>."
732
  msgstr ""
733
 
734
- #: includes/class-bwp-minify.php:1885
 
735
  msgid ""
736
- "Friendly minify url feature has been turned off automatically to prevent "
737
- "your site from breaking. "
 
 
 
738
  msgstr ""
739
 
740
- #: includes/class-bwp-minify.php:1904
741
- #, php-format
742
- msgid ""
743
- "Could not write Minify library settings to <code>%s</code>. Please update "
744
- "the config file manually by <em>replacing</em> its current contents with "
745
- "auto-generated contents as shown below:"
746
  msgstr ""
747
 
748
- #: includes/class-bwp-minify.php:1922
 
 
 
 
749
  #, php-format
 
 
 
 
750
  msgid ""
751
- "Please update the Nginx config file manually using auto-generated contents "
752
- "as shown below. It is highly recommended that you create a separate config "
753
- "file for BWP Minify (e.g. <code>bwp-minify.conf</code>) and include it "
754
- "directly above where you include your cache plugins' config files, as shown "
755
- "<a href=\"%s\" target=\"_blank\">here</a>. "
756
  msgstr ""
757
 
758
- #: includes/class-bwp-minify.php:1935
759
- #, php-format
760
  msgid ""
761
- "Please update the server config file <code>%s</code> manually using auto-"
762
- "generated contents as shown below. It is highly recommended that you paste "
763
- "the contents at the top of the server config file. If config file does not "
764
- "exist, you must first create it."
765
  msgstr ""
766
 
767
- #: includes/class-bwp-minify.php:1954
768
  #, php-format
769
  msgid ""
770
- "Please update the cache directory config file <code>%s</code> manually using "
771
- "auto-generated contents as shown below. It is highly recommended that you "
772
- "paste the contents at the top of the server config file. If config file does "
773
- "not exist, you must first create it."
774
  msgstr ""
775
 
776
- #: includes/class-bwp-minify.php:1979
777
  #, php-format
778
  msgid ""
779
  "There was an error writing to server config file <code>%s</code>. Please "
@@ -781,21 +813,21 @@ msgid ""
781
  "config file using auto-generated contents as shown below."
782
  msgstr ""
783
 
784
- #: includes/class-bwp-minify.php:1985
785
  msgid ""
786
  "There was an error writing to your Nginx config file. Please make sure that "
787
  "it is writable and try again, or you can manually update the config file "
788
  "using auto-generated contents as shown below."
789
  msgstr ""
790
 
791
- #: includes/class-bwp-minify.php:1995
792
  #, php-format
793
  msgid ""
794
  "The server config file <code>%s</code> is not writable, please manually "
795
  "update it using auto-generated contents as shown below."
796
  msgstr ""
797
 
798
- #: includes/class-bwp-minify.php:2007
799
  #, php-format
800
  msgid ""
801
  "The server config file <code>%s</code> does not exist and could not be "
@@ -803,6 +835,6 @@ msgid ""
803
  "contents as shown below."
804
  msgstr ""
805
 
806
- #: includes/class-bwp-minify.php:2313
807
  msgid "empty"
808
  msgstr ""
2
  msgstr ""
3
  "Project-Id-Version: BWP Minify\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2014-09-22 15:45+0700\n"
6
+ "PO-Revision-Date: 2014-09-22 15:50+0700\n"
7
  "Last-Translator: Khang Minh <contact@betterwp.net>\n"
8
  "Language-Team: \n"
9
  "Language: en_US\n"
20
  msgid "Plugin Configurations"
21
  msgstr ""
22
 
23
+ #: includes/bwp-option-page/includes/class-bwp-option-page.php:623
24
  msgid "Save Changes"
25
  msgstr ""
26
 
27
+ #: includes/class-bwp-enqueued-detector.php:222
28
+ #: includes/class-bwp-enqueued-detector.php:235
29
  msgid "Handle"
30
  msgstr ""
31
 
32
+ #: includes/class-bwp-enqueued-detector.php:223
33
+ #: includes/class-bwp-enqueued-detector.php:236
34
  msgid "Position"
35
  msgstr ""
36
 
37
+ #: includes/class-bwp-enqueued-detector.php:224
38
  msgid "Script src"
39
  msgstr ""
40
 
41
+ #: includes/class-bwp-enqueued-detector.php:225
42
+ #: includes/class-bwp-enqueued-detector.php:239
43
  msgid "Actions"
44
  msgstr ""
45
 
46
+ #: includes/class-bwp-enqueued-detector.php:237
47
  msgid "Media"
48
  msgstr ""
49
 
50
+ #: includes/class-bwp-enqueued-detector.php:238
51
  msgid "Style src"
52
  msgstr ""
53
 
 
 
 
 
54
  #: includes/class-bwp-enqueued-detector.php:349
55
+ msgid "move to header"
56
  msgstr ""
57
 
58
  #: includes/class-bwp-enqueued-detector.php:350
59
+ msgid "move to footer"
 
60
  msgstr ""
61
 
62
  #: includes/class-bwp-enqueued-detector.php:351
63
  #: includes/class-bwp-enqueued-detector.php:354
64
+ msgid "stay at position"
65
  msgstr ""
66
 
67
  #: includes/class-bwp-enqueued-detector.php:352
68
  #: includes/class-bwp-enqueued-detector.php:355
69
+ msgid "not minify"
70
  msgstr ""
71
 
72
+ #: includes/class-bwp-enqueued-detector.php:353
73
+ #: includes/class-bwp-enqueued-detector.php:356
74
+ msgid "remove"
75
+ msgstr ""
76
+
77
+ #: includes/class-bwp-enqueued-detector.php:381
78
  msgid "select"
79
  msgstr ""
80
 
81
+ #: includes/class-bwp-enqueued-detector.php:402
82
  msgid ""
83
  "No enqueued files detected.<br /><br />Please try visiting a few pages on "
84
  "your site and then refresh this page.<br /><br />You should clear this list "
86
  "not done automatically."
87
  msgstr ""
88
 
89
+ #: includes/class-bwp-enqueued-detector.php:410
90
+ msgid "JS minification is currently disabled."
91
+ msgstr ""
92
+
93
+ #: includes/class-bwp-enqueued-detector.php:412
94
+ msgid "CSS minification is currently disabled."
95
+ msgstr ""
96
+
97
+ #: includes/class-bwp-enqueued-detector.php:445
98
  msgid "header"
99
  msgstr ""
100
 
101
+ #: includes/class-bwp-enqueued-detector.php:446
102
  msgid "footer"
103
  msgstr ""
104
 
105
+ #: includes/class-bwp-enqueued-detector.php:456
106
+ msgid "minified at original"
 
107
  msgstr ""
108
 
109
+ #: includes/class-bwp-enqueued-detector.php:457
110
  #, php-format
111
  msgid "minified in %s"
112
  msgstr ""
113
 
114
+ #: includes/class-bwp-enqueued-detector.php:463
115
+ msgid "ignored at original"
116
  msgstr ""
117
 
118
+ #: includes/class-bwp-enqueued-detector.php:466
119
+ msgid "removed"
120
+ msgstr ""
121
+
122
+ #: includes/class-bwp-enqueued-detector.php:467
123
  #, php-format
124
  msgid "ignored in %s"
125
  msgstr ""
128
  #, php-format
129
  msgid ""
130
  "%s requires WordPress <strong>%s</strong> or higher and PHP <strong>%s</"
131
+ "strong> or higher. The plugin will not function until you update your "
132
+ "software. Please deactivate this plugin."
133
  msgstr ""
134
 
135
+ #: includes/class-bwp-framework-improved.php:232
136
  msgid "Development Log"
137
  msgstr ""
138
 
139
+ #: includes/class-bwp-framework-improved.php:232
140
  msgid "Frequently Asked Questions"
141
  msgstr ""
142
 
143
+ #: includes/class-bwp-framework-improved.php:232
144
  msgid "FAQ"
145
  msgstr ""
146
 
147
+ #: includes/class-bwp-framework-improved.php:232
148
  msgid "Got a problem? Send me a feedback!"
149
  msgstr ""
150
 
151
+ #: includes/class-bwp-framework-improved.php:232
152
  msgid "Contact"
153
  msgstr ""
154
 
155
+ #: includes/class-bwp-framework-improved.php:239
156
  msgid ""
157
  "You can buy me some special coffees if you appreciate my work, thank you!"
158
  msgstr ""
159
 
160
+ #: includes/class-bwp-framework-improved.php:253
161
  #, php-format
162
  msgid "Donate to %s"
163
  msgstr ""
164
 
165
+ #: includes/class-bwp-framework-improved.php:255
166
  msgid "One cup $5.00"
167
  msgstr ""
168
 
169
+ #: includes/class-bwp-framework-improved.php:256
170
  msgid "Two cups $10.00"
171
  msgstr ""
172
 
173
+ #: includes/class-bwp-framework-improved.php:257
174
  msgid "Five cups! $25.00"
175
  msgstr ""
176
 
177
+ #: includes/class-bwp-framework-improved.php:258
178
  msgid "One LL-cup!!! $50.00"
179
  msgstr ""
180
 
181
+ #: includes/class-bwp-framework-improved.php:259
182
  msgid "... or any amount!"
183
  msgstr ""
184
 
185
+ #: includes/class-bwp-framework-improved.php:274
186
  msgid "Latest updates from BetterWP.net!"
187
  msgstr ""
188
 
189
+ #: includes/class-bwp-framework-improved.php:275
190
  msgid "Follow me on Twitter!"
191
  msgstr ""
192
 
193
+ #: includes/class-bwp-framework-improved.php:285
194
  msgid "This Plugin is Proudly Sponsored By"
195
  msgstr ""
196
 
197
+ #: includes/class-bwp-framework-improved.php:305
198
  #, php-format
199
  msgid "You are using version %s!"
200
  msgstr ""
201
 
202
+ #: includes/class-bwp-framework-improved.php:546
203
  msgid "Settings"
204
  msgstr ""
205
 
208
  msgid "Minify group %s not found."
209
  msgstr ""
210
 
211
+ #: includes/class-bwp-minify-fetcher.php:122
212
  msgid "Invalid Minify directory, please check Minify settings."
213
  msgstr ""
214
 
215
+ #: includes/class-bwp-minify.php:213 includes/class-bwp-minify.php:1004
216
+ #: includes/class-bwp-minify.php:1005
217
  msgid "General Options"
218
  msgstr ""
219
 
220
+ #: includes/class-bwp-minify.php:216 includes/class-bwp-minify.php:1012
221
+ #: includes/class-bwp-minify.php:1013
222
  msgid "Advanced Options"
223
  msgstr ""
224
 
225
+ #: includes/class-bwp-minify.php:219 includes/class-bwp-minify.php:1020
226
  msgid "Manage enqueued Files"
227
  msgstr ""
228
 
229
+ #: includes/class-bwp-minify.php:958
230
+ #, php-format
231
+ msgid ""
232
+ "<strong>Better WordPress Minify</strong> &ndash; Required rewrite rules for "
233
+ "friendly minify url feature could not be found and could not be added "
234
+ "automatically. Friendly minify url feature has been turned off to prevent "
235
+ "your site from breaking. You can turn it on again by navigating to %s."
236
+ msgstr ""
237
+
238
+ #: includes/class-bwp-minify.php:994
239
  msgid "Better WordPress Minify"
240
  msgstr ""
241
 
242
+ #: includes/class-bwp-minify.php:1021
243
  msgid "Enqueued Files"
244
  msgstr ""
245
 
246
+ #: includes/class-bwp-minify.php:1036
247
  msgid "You do not have sufficient permissions to access this page."
248
  msgstr ""
249
 
250
+ #: includes/class-bwp-minify.php:1129
251
  msgid "Plugin Functionality"
252
  msgstr ""
253
 
254
+ #: includes/class-bwp-minify.php:1130
255
  msgid "Minify JS files automatically?"
256
  msgstr ""
257
 
258
+ #: includes/class-bwp-minify.php:1131
259
  msgid "Minify CSS files automatically?"
260
  msgstr ""
261
 
262
+ #: includes/class-bwp-minify.php:1132
263
  msgid "Minify <code>bloginfo()</code> stylesheets?"
264
  msgstr ""
265
 
266
+ #: includes/class-bwp-minify.php:1133
267
+ msgid "Leave external files at their original positions?"
268
+ msgstr ""
269
+
270
+ #: includes/class-bwp-minify.php:1134
271
  msgid "URL path to Minify library (relative to domain root)"
272
  msgstr ""
273
 
274
+ #: includes/class-bwp-minify.php:1135
275
  msgid "One minify string will contain"
276
  msgstr ""
277
 
278
+ #: includes/class-bwp-minify.php:1136
279
  msgid "For cache buster, use"
280
  msgstr ""
281
 
282
+ #: includes/class-bwp-minify.php:1137
283
  msgid "Minify Library Settings"
284
  msgstr ""
285
 
286
+ #: includes/class-bwp-minify.php:1138
287
  msgid "WordPress document root"
288
  msgstr ""
289
 
290
+ #: includes/class-bwp-minify.php:1139
291
  msgid "Cache directory"
292
  msgstr ""
293
 
294
+ #: includes/class-bwp-minify.php:1140
295
  msgid "Cache age"
296
  msgstr ""
297
 
298
+ #: includes/class-bwp-minify.php:1141
299
  msgid "Enable bubble CSS import?"
300
  msgstr ""
301
 
302
+ #: includes/class-bwp-minify.php:1142
303
  msgid "Enable cache file locking?"
304
  msgstr ""
305
 
306
+ #: includes/class-bwp-minify.php:1143
307
  msgid "Enable debugging?"
308
  msgstr ""
309
 
310
+ #: includes/class-bwp-minify.php:1165
311
  #, php-format
312
  msgid ""
313
  "<em>These options will let you control how the actual <a href=\"%s\" target="
314
  "\"_blank\">Minify</a> library works.</em>"
315
  msgstr ""
316
 
317
+ #: includes/class-bwp-minify.php:1172
318
  msgid "second(s)"
319
  msgstr ""
320
 
321
+ #: includes/class-bwp-minify.php:1173
322
  msgid "minute(s)"
323
  msgstr ""
324
 
325
+ #: includes/class-bwp-minify.php:1174
326
  msgid "hour(s)"
327
  msgstr ""
328
 
329
+ #: includes/class-bwp-minify.php:1175
330
  msgid "day(s)"
331
  msgstr ""
332
 
333
+ #: includes/class-bwp-minify.php:1178
334
  msgid "No cache buster"
335
  msgstr ""
336
 
337
+ #: includes/class-bwp-minify.php:1179
338
  msgid "Cache folder&#8217;s last modified time"
339
  msgstr ""
340
 
341
+ #: includes/class-bwp-minify.php:1180
342
  msgid "Your WordPress&#8217;s current version"
343
  msgstr ""
344
 
345
+ #: includes/class-bwp-minify.php:1181
346
  msgid "Your theme&#8217;s current version"
347
  msgstr ""
348
 
349
+ #: includes/class-bwp-minify.php:1182
350
  msgid "A custom number"
351
  msgstr ""
352
 
353
+ #: includes/class-bwp-minify.php:1186 includes/class-bwp-minify.php:1187
354
  msgid ""
355
  "you can still use <code>bwp_minify()</code> helper function if you disable "
356
  "this."
357
  msgstr ""
358
 
359
+ #: includes/class-bwp-minify.php:1188
360
  msgid ""
361
  "enable this for themes that use <code>bloginfo()</code> to print the main "
362
  "stylesheet (i.e. <code>style.css</code>). If you want to minify <code>style."
363
  "css</code> with the rest of your css files, you must enqueue it."
364
  msgstr ""
365
 
366
+ #: includes/class-bwp-minify.php:1189
367
+ msgid ""
368
+ "enable this to improve compatibility with plugins/themes that print external "
369
+ "JS/CSS files directly, for e.g. <code>Simple Google Maps Short Code</code> "
370
+ "plugin or <code>Avada</code> theme."
371
+ msgstr ""
372
+
373
+ #: includes/class-bwp-minify.php:1190
374
  #, php-format
375
  msgid ""
376
  "move all <code>@import</code> rules in CSS files to the top. More info <a "
377
  "href=\"%s\" target=\"_blank\">here</a>."
378
  msgstr ""
379
 
380
+ #: includes/class-bwp-minify.php:1191
381
  msgid "disable this if filesystem is NFS."
382
  msgstr ""
383
 
384
+ #: includes/class-bwp-minify.php:1192
385
  #, php-format
386
  msgid ""
387
  "only enable this when minification does not work as expected. More info <a "
388
  "href=\"%s\" target=\"_blank\">here</a>."
389
  msgstr ""
390
 
391
+ #: includes/class-bwp-minify.php:1198
392
  #, php-format
393
  msgid ""
394
  "Leave empty to use default value, which is <code>%s</code>.<br />Please read "
396
  "to properly modify this."
397
  msgstr ""
398
 
399
+ #: includes/class-bwp-minify.php:1210
400
  #, php-format
401
  msgid ""
402
  "Expect a full path to a publicly accessible directory (i.e. can be served "
406
  "\"_blank\">here</a>. "
407
  msgstr ""
408
 
409
+ #: includes/class-bwp-minify.php:1221
410
  msgid "file(s) at most."
411
  msgstr ""
412
 
413
+ #: includes/class-bwp-minify.php:1225
414
  msgid "&mdash;"
415
  msgstr ""
416
 
417
+ #: includes/class-bwp-minify.php:1241
418
  msgid "Note"
419
  msgstr ""
420
 
421
+ #: includes/class-bwp-minify.php:1242
422
  msgid ""
423
  "Whenever a new cache buster is used, you are telling browsers to refresh "
424
  "cached JS and CSS files. This is particularly useful when source files have "
425
  "been changed, use this feature wisely."
426
  msgstr ""
427
 
428
+ #: includes/class-bwp-minify.php:1296 includes/class-bwp-minify.php:1305
429
+ #: includes/class-bwp-minify.php:1658 includes/class-bwp-minify.php:1881
430
+ #: includes/class-bwp-minify.php:2048
431
  msgid "Notice"
432
  msgstr ""
433
 
434
+ #: includes/class-bwp-minify.php:1298
435
  #, php-format
436
  msgid "<strong>%d</strong> cached files have been deleted successfully!"
437
  msgstr ""
438
 
439
+ #: includes/class-bwp-minify.php:1306
440
  msgid ""
441
  "Could not delete any cached files. Please manually flush the cache directory."
442
  msgstr ""
443
 
444
+ #: includes/class-bwp-minify.php:1333
445
  msgid "Friendly Minify Urls"
446
  msgstr ""
447
 
448
+ #: includes/class-bwp-minify.php:1334
449
  msgid "Enable friendly Minify urls"
450
  msgstr ""
451
 
452
+ #: includes/class-bwp-minify.php:1336
453
  #, php-format
454
  msgid ""
455
  "Friendly Minify url path (relative to your Site/Network Address). More info "
456
  "<a href=\"%s#friendly_minify_urls\" target=\"_blank\">here</a>."
457
  msgstr ""
458
 
459
+ #: includes/class-bwp-minify.php:1341
460
  msgid "Path to Nginx config file"
461
  msgstr ""
462
 
463
+ #: includes/class-bwp-minify.php:1342
464
  msgid "Content Delivery Network (CDN)"
465
  msgstr ""
466
 
467
+ #: includes/class-bwp-minify.php:1343
468
  msgid "Enable CDN support"
469
  msgstr ""
470
 
471
+ #: includes/class-bwp-minify.php:1344
472
  msgid "SSL support for CDN"
473
  msgstr ""
474
 
475
+ #: includes/class-bwp-minify.php:1345
476
  msgid "CDN hostname (primary)"
477
  msgstr ""
478
 
479
+ #: includes/class-bwp-minify.php:1346
480
  msgid "CDN hostname for JS files"
481
  msgstr ""
482
 
483
+ #: includes/class-bwp-minify.php:1347
484
  msgid "CDN hostname for CSS files"
485
  msgstr ""
486
 
487
+ #: includes/class-bwp-minify.php:1348
488
  msgid "Additional HTTP headers used with CDN"
489
  msgstr ""
490
 
491
+ #: includes/class-bwp-minify.php:1364
492
  #, php-format
493
  msgid ""
494
  "Turn long and ugly Minify urls with query variables (such as <code>%s</"
495
  "code>), into more friendly ones (e.g. <code>%s</code>). "
496
  msgstr ""
497
 
498
+ #: includes/class-bwp-minify.php:1373
499
  #, php-format
500
  msgid ""
501
  "Serve minified contents using a <a href=\"%s\" target=\"_blank\">CDN</a> to "
502
  "improve performance."
503
  msgstr ""
504
 
505
+ #: includes/class-bwp-minify.php:1380
506
  msgid "WordPress"
507
  msgstr ""
508
 
509
+ #: includes/class-bwp-minify.php:1381
510
  msgid "Server rewrite rules"
511
  msgstr ""
512
 
513
+ #: includes/class-bwp-minify.php:1384
514
  msgid "Do not use SSL for CDN"
515
  msgstr ""
516
 
517
+ #: includes/class-bwp-minify.php:1385
518
  msgid "Use SSL when suitable"
519
  msgstr ""
520
 
521
+ #: includes/class-bwp-minify.php:1386
522
  msgid "Use protocol-relative URL"
523
  msgstr ""
524
 
525
+ #: includes/class-bwp-minify.php:1391
526
  msgid "for CDN support it is highly recommended that you enable this feature."
527
  msgstr ""
528
 
529
+ #: includes/class-bwp-minify.php:1394
530
  msgid ""
531
  "please make sure that your CDN is property setup before enabling this "
532
  "feature."
533
  msgstr ""
534
 
535
+ #: includes/class-bwp-minify.php:1405
536
  #, php-format
537
  msgid ""
538
  "Expect a full path to your Nginx configuration file (e.g. <code>%s</code>). "
542
  "blank and BWP Minify will use that config file."
543
  msgstr ""
544
 
545
+ #: includes/class-bwp-minify.php:1419
546
  #, php-format
547
  msgid ""
548
  "Use either hostnames provided by your CDN or custom ones. Please do NOT "
550
  "Good examples are: <code>%s</code>, <code>%s</code>, etc."
551
  msgstr ""
552
 
553
+ #: includes/class-bwp-minify.php:1428 includes/class-bwp-minify.php:1432
554
  msgid "used when not empty."
555
  msgstr ""
556
 
557
+ #: includes/class-bwp-minify.php:1442
558
  msgid ""
559
  "If you're looking for a CDN, I highly recommend <strong>MaxCDN</strong>. "
560
  "They provide the most reliable CDN service for WordPress sites. Support is "
561
  "exceptional and you got a 30-day Money Back Guarantee, too."
562
  msgstr ""
563
 
564
+ #: includes/class-bwp-minify.php:1449
565
  msgid "Create a MaxCDN account today and save 25%</a>"
566
  msgstr ""
567
 
568
+ #: includes/class-bwp-minify.php:1473
569
  msgid ""
570
  "Enqueued file lists have been cleared successfully. Try refreshing this page "
571
  "to see updated file lists."
572
  msgstr ""
573
 
574
+ #: includes/class-bwp-minify.php:1484
575
+ msgid "Manage enqueued JS files"
576
  msgstr ""
577
 
578
+ #: includes/class-bwp-minify.php:1485
579
+ msgid "Manage enqueued CSS files"
580
  msgstr ""
581
 
582
+ #: includes/class-bwp-minify.php:1493
583
  #, php-format
584
  msgid ""
585
  "Below you can find a list of enqueued JS files detected by this plugin. "
586
+ "Press <strong>select</strong> and then choose to perform an appropriate "
587
+ "action on selected JS file. You can also directly type in one script handle "
588
  "(<strong>NOT filename/script src</strong>) per line in the input field if "
589
+ "you want. More info <a href=\"%s#manage_enqueued_files\" target=\"_blank"
590
  "\">here</a>."
591
  msgstr ""
592
 
593
+ #: includes/class-bwp-minify.php:1502
594
  #, php-format
595
  msgid ""
596
  "Below you can find a list of enqueued CSS files detected by this plugin. "
597
+ "Press <strong>select</strong> and then choose to perform an appropriate "
598
+ "action on selected CSS file. You can also directly type in one style handle "
599
  "(<strong>NOT filename/style src</strong>) per line in the input field if you "
600
+ "want. More info <a href=\"%s#manage_enqueued_files\" target=\"_blank\">here</"
601
+ "a>."
602
  msgstr ""
603
 
604
+ #: includes/class-bwp-minify.php:1597
605
  msgid ""
606
  "All positions have been saved. Try refreshing this page for updated file "
607
  "lists."
608
  msgstr ""
609
 
610
+ #: includes/class-bwp-minify.php:1601
611
  msgid "All options have been saved."
612
  msgstr ""
613
 
614
+ #: includes/class-bwp-minify.php:1624
615
  #, php-format
616
  msgid "Minify config file <code>%s</code> has been updated successfully."
617
  msgstr ""
618
 
619
+ #: includes/class-bwp-minify.php:1633 includes/class-bwp-minify.php:1647
620
+ #: includes/class-bwp-minify.php:2144 includes/class-bwp-minify.php:2150
621
+ #: includes/class-bwp-minify.php:2160 includes/class-bwp-minify.php:2172
622
  msgid "Error"
623
  msgstr ""
624
 
625
+ #: includes/class-bwp-minify.php:1635
626
  #, php-format
627
  msgid ""
628
  "Minify config file <code>config.php</code> could not be found. The auto-"
631
  "file."
632
  msgstr ""
633
 
634
+ #: includes/class-bwp-minify.php:1648
635
  #, php-format
636
  msgid ""
637
  "There was an error writing to Minify config file <code>%s</code>. Please try "
638
  "again."
639
  msgstr ""
640
 
641
+ #: includes/class-bwp-minify.php:1659
642
  #, php-format
643
  msgid ""
644
  "Minify config file <code>%s</code> is not writable. See <a href=\"#minify."
645
  "config.php\">below</a> for details."
646
  msgstr ""
647
 
648
+ #: includes/class-bwp-minify.php:1703 includes/class-bwp-minify.php:1715
649
  msgid "Warning"
650
  msgstr ""
651
 
652
+ #: includes/class-bwp-minify.php:1705
653
  #, php-format
654
  msgid ""
655
  "Cache directory <code>%s</code> does not exist and can not be created "
657
  "is writable for Minify to perform more efficiently."
658
  msgstr ""
659
 
660
+ #: includes/class-bwp-minify.php:1717
661
  #, php-format
662
  msgid ""
663
  "Cache directory <code>%s</code> is not writable. Please try CHMOD your cache "
664
  "directory to 755. If you still see this warning, try CHMOD to 777."
665
  msgstr ""
666
 
667
+ #: includes/class-bwp-minify.php:1755
668
+ msgid "Styles to stay at original positions"
669
  msgstr ""
670
 
671
+ #: includes/class-bwp-minify.php:1756
672
+ msgid "Styles to NOT minify"
673
  msgstr ""
674
 
675
+ #: includes/class-bwp-minify.php:1757
676
+ msgid "Styles to remove"
677
  msgstr ""
678
 
679
+ #: includes/class-bwp-minify.php:1766
680
+ msgid "Scripts to move to header"
681
  msgstr ""
682
 
683
+ #: includes/class-bwp-minify.php:1767
684
+ msgid "Scripts to move to footer"
685
  msgstr ""
686
 
687
+ #: includes/class-bwp-minify.php:1768
688
+ msgid "Scripts to stay at original positions"
689
  msgstr ""
690
 
691
+ #: includes/class-bwp-minify.php:1769
692
+ msgid "Scripts to NOT minify"
693
  msgstr ""
694
 
695
+ #: includes/class-bwp-minify.php:1770
696
+ msgid "Scripts to remove"
697
  msgstr ""
698
 
699
+ #: includes/class-bwp-minify.php:1828
700
  msgid "Save Changes and Flush Cache"
701
  msgstr ""
702
 
703
+ #: includes/class-bwp-minify.php:1831
704
  msgid "Flush Cache"
705
  msgstr ""
706
 
707
+ #: includes/class-bwp-minify.php:1843
708
  msgid "Clear File Lists"
709
  msgstr ""
710
 
711
+ #: includes/class-bwp-minify.php:1857
712
  #, php-format
713
  msgid ""
714
  "BWP Minify was not able to auto-detect friendly url based on Minify's "
715
  "current cache directory (<code>%s</code>)."
716
  msgstr ""
717
 
718
+ #: includes/class-bwp-minify.php:1863
719
  msgid ""
720
  "You must manually set this setting for this feature to work.<br />Please "
721
  "make sure that the entered URL path correctly links to Minify's current "
722
  "cache directory."
723
  msgstr ""
724
 
725
+ #: includes/class-bwp-minify.php:1871
726
  #, php-format
727
  msgid ""
728
  "Leave empty to use <code>%s</code>, which is auto-detected based on Minify's "
731
  "directory."
732
  msgstr ""
733
 
734
+ #: includes/class-bwp-minify.php:1882
735
  #, php-format
736
  msgid ""
737
  "In a sub-directory multisite environment, a blog path will be added before "
738
  "the URL path (e.g. <code>%s</code>) when friendly Minify urls are served."
739
  msgstr ""
740
 
741
+ #: includes/class-bwp-minify.php:1902
742
  #, php-format
743
  msgid ""
744
  "Leave empty to use parent directory of WordPress's <code>index.php</code>, "
750
  "\"%s#minify_document_root\" target=\"_blank\">here</a>."
751
  msgstr ""
752
 
753
+ #: includes/class-bwp-minify.php:1919
754
  #, php-format
755
  msgid ""
756
  "Leave empty to use <code>$_SERVER['DOCUMENT_ROOT']</code>, which is <code>"
762
  "\"%s#minify_document_root\" target=\"_blank\">here</a>."
763
  msgstr ""
764
 
765
+ #: includes/class-bwp-minify.php:1940
766
+ #, php-format
767
  msgid ""
768
+ "Rewrite rules are required for this feature to work properly. Most of the "
769
+ "time this is taken care of automatically by the plugin, but if you notice an "
770
+ "error or you're using Nginx as a reverse proxy, you must manually update "
771
+ "your server config files. More info <a href=\"%sfaq#rewrite-rules\" target="
772
+ "\"blank\">here</a>."
773
  msgstr ""
774
 
775
+ #: includes/class-bwp-minify.php:1950
776
+ msgid "Show rewrite rules for Apache"
 
 
 
 
777
  msgstr ""
778
 
779
+ #: includes/class-bwp-minify.php:1952
780
+ msgid "Show rewrite rules for Nginx"
781
+ msgstr ""
782
+
783
+ #: includes/class-bwp-minify.php:1961 includes/class-bwp-minify.php:1972
784
  #, php-format
785
+ msgid "Below rules should present at the top of <code>%s</code>:"
786
+ msgstr ""
787
+
788
+ #: includes/class-bwp-minify.php:1988
789
  msgid ""
790
+ "Below rules should present in an appropriate position within your Nginx "
791
+ "configuration file."
 
 
 
792
  msgstr ""
793
 
794
+ #: includes/class-bwp-minify.php:2049
 
795
  msgid ""
796
+ "Friendly minify url feature has been turned off automatically to prevent "
797
+ "your site from breaking. "
 
 
798
  msgstr ""
799
 
800
+ #: includes/class-bwp-minify.php:2068
801
  #, php-format
802
  msgid ""
803
+ "Could not write Minify library settings to <code>%s</code>. Please update "
804
+ "the config file manually by <em>replacing</em> its current contents with "
805
+ "auto-generated rewrite rules as shown below:"
 
806
  msgstr ""
807
 
808
+ #: includes/class-bwp-minify.php:2145
809
  #, php-format
810
  msgid ""
811
  "There was an error writing to server config file <code>%s</code>. Please "
813
  "config file using auto-generated contents as shown below."
814
  msgstr ""
815
 
816
+ #: includes/class-bwp-minify.php:2151
817
  msgid ""
818
  "There was an error writing to your Nginx config file. Please make sure that "
819
  "it is writable and try again, or you can manually update the config file "
820
  "using auto-generated contents as shown below."
821
  msgstr ""
822
 
823
+ #: includes/class-bwp-minify.php:2161
824
  #, php-format
825
  msgid ""
826
  "The server config file <code>%s</code> is not writable, please manually "
827
  "update it using auto-generated contents as shown below."
828
  msgstr ""
829
 
830
+ #: includes/class-bwp-minify.php:2173
831
  #, php-format
832
  msgid ""
833
  "The server config file <code>%s</code> does not exist and could not be "
835
  "contents as shown below."
836
  msgstr ""
837
 
838
+ #: includes/class-bwp-minify.php:2479
839
  msgid "empty"
840
  msgstr ""
css/bwp-minify.css CHANGED
@@ -1,7 +1,7 @@
1
  .bwp-minify-table-wrapper {
2
  position: relative;
3
  float: left;
4
- width: 65%;
5
  background-color: #ffffff;
6
  border: 1px solid #cccccc;
7
  /* padding: 5px; */
@@ -35,7 +35,7 @@
35
  padding: 4px 5px;
36
  }
37
  .bwp-minify-detector-table td input, .bwp-minify-detector-table td input:focus {
38
- width: 300px;
39
  border: none;
40
  background: none;
41
  box-shadow: none;
@@ -60,7 +60,7 @@
60
  overflow: auto;
61
  }
62
  .bwp-sidebar textarea {
63
- width: 90%;
64
  margin-top: 10px;
65
  display: none;
66
  }
1
  .bwp-minify-table-wrapper {
2
  position: relative;
3
  float: left;
4
+ width: 70%;
5
  background-color: #ffffff;
6
  border: 1px solid #cccccc;
7
  /* padding: 5px; */
35
  padding: 4px 5px;
36
  }
37
  .bwp-minify-detector-table td input, .bwp-minify-detector-table td input:focus {
38
+ width: 350px;
39
  border: none;
40
  background: none;
41
  box-shadow: none;
60
  overflow: auto;
61
  }
62
  .bwp-sidebar textarea {
63
+ width: 95%;
64
  margin-top: 10px;
65
  display: none;
66
  }
includes/bwp-option-page/bwp-option-page.php CHANGED
@@ -1,3 +1,3 @@
1
  <?php
2
  if (!is_admin()) return;
3
- require_once(dirname(__FILE__) . '/includes/class-bwp-option-page.php');
1
  <?php
2
  if (!is_admin()) return;
3
+ require_once dirname(__FILE__) . '/includes/class-bwp-option-page.php';
includes/bwp-option-page/includes/class-bwp-option-page.php CHANGED
@@ -4,8 +4,8 @@
4
  * @license http://www.gnu.org/licenses/gpl.html GNU GENERAL PUBLIC LICENSE VERSION 3.0 OR LATER
5
  */
6
 
7
- class BWP_OPTION_PAGE {
8
-
9
  /**
10
  * The form
11
  */
@@ -56,9 +56,9 @@ class BWP_OPTION_PAGE {
56
  */
57
  function __construct($form_name = 'bwp_option_page', $site_options = array(), $domain = '')
58
  {
59
- $this->form_name = $form_name;
60
- $this->site_options = $site_options;
61
- $this->domain = $domain;
62
  }
63
 
64
  /**
@@ -78,7 +78,7 @@ class BWP_OPTION_PAGE {
78
  $this->form_tabs = $form_tabs;
79
 
80
  if (sizeof($this->form_tabs) == 0)
81
- $this->form_tabs = array(__('Plugin Configurations', 'bwp-option-page'));
82
  }
83
 
84
  function get_form_name()
@@ -98,26 +98,33 @@ class BWP_OPTION_PAGE {
98
  if (!in_array($key, $options))
99
  unset($options_default[$key]);
100
  }
 
101
  return $options_default;
102
  }
103
 
104
  function get_db_options($name = '', $options = array())
105
  {
106
  $db_options = get_option($name);
 
107
  if (!$db_options)
 
108
  update_option($name, $options);
 
109
  else if (array_keys($options) != array_keys($db_options))
110
  {
111
  foreach ($db_options as $key => $data)
112
  if (isset($options[$key]) && !in_array($key, $this->site_options))
113
  $options[$key] = $data;
 
114
  update_option($name, $options);
115
  }
116
  else
117
  {
118
  foreach ($db_options as $key => $data)
 
119
  if (!in_array($key, $this->site_options))
120
  $options[$key] = $data;
 
121
  }
122
 
123
  return $options;
@@ -138,10 +145,23 @@ class BWP_OPTION_PAGE {
138
  $_POST[$key] = strip_tags($_POST[$key]);
139
  }
140
 
141
- function kill_html_fields(&$form = array(), $ids)
142
  {
143
- $ids = (array) $ids;
144
- $in_keys = array('items', 'item_labels', 'item_names');
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  foreach ($ids as $id)
146
  {
147
  foreach ($in_keys as $key)
@@ -151,41 +171,63 @@ class BWP_OPTION_PAGE {
151
 
152
  /**
153
  * Generate HTML field
154
- *
155
- * @params they explain themselves
156
  */
157
  function generate_html_field($type = '', $data = array(), $name = '', $in_section = false)
158
  {
159
- $pre_html_field = '';
160
- $post_html_field = '';
161
- $checked = 'checked="checked" ';
162
- $selected = 'selected="selected" ';
 
163
 
164
- $value = isset($this->form_options[$name])
165
  ? $this->form_options[$name]
166
  : '';
167
 
168
- $value = !empty($this->domain)
 
 
169
  && ('textarea' == $type || 'input' == $type)
170
  ? __($value, $this->domain)
171
  : $value;
172
 
173
- $value = 'textarea' == $type
174
- ? esc_html($value)
175
- : esc_attr($value);
176
-
177
- $array_replace = array();
178
- $array_search = array('size', 'name', 'value', 'cols',
179
- 'rows', 'label', 'disabled', 'pre', 'post');
180
- $return_html = '';
 
 
 
181
 
182
- $br = isset($this->form['inline_fields'][$name])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  && is_array($this->form['inline_fields'][$name])
184
  ? ''
185
  : "<br />\n";
186
 
187
- $pre = !empty($data['pre']) ? $data['pre'] : '';
188
- $post = !empty($data['post']) ? $data['post'] : '';
 
 
 
189
 
190
  switch ($type)
191
  {
@@ -194,25 +236,48 @@ class BWP_OPTION_PAGE {
194
  break;
195
 
196
  case 'input':
197
- $html_field = (!$in_section) ? '%pre%<input%disabled% size="%size%" type="text" id="' . $name . '" name="' . $name . '" value="' . $value . '" /> <em>%label%</em>' : '<label for="' . $name . '">%pre%<input%disabled% size="%size%" type="text" id="' . $name . '" name="' . $name . '" value="' . $value . '" /> <em>%label%</em></label>';
 
 
 
 
 
 
 
 
198
  break;
199
 
200
  case 'select':
201
- $pre_html_field = '%pre%<select id="' . $name . '" name="' . $name . '">' . "\n";
202
- $html_field = '<option %selected%value="%value%" />%option%</option>';
 
 
 
 
 
203
  $post_html_field = '</select>%post%' . $br;
204
  break;
205
 
206
  case 'checkbox':
207
- $html_field = '<label for="%name%">' . '<input %checked%type="checkbox" id="%name%" name="%name%" value="yes" /> %label%</label>';
 
 
 
 
 
 
208
  break;
209
 
210
  case 'radio':
211
- $html_field = '<label>' . '<input %checked%type="radio" name="' . $name . '" value="%value%" /> %label%</label>';
 
212
  break;
213
 
214
  case 'textarea':
215
- $html_field = '%pre%<textarea%disabled% id="' . $name . '" name="' . $name . '" cols="%cols%" rows="%rows%">' . $value . '</textarea>%post%';
 
 
 
216
  break;
217
  }
218
 
@@ -223,22 +288,91 @@ class BWP_OPTION_PAGE {
223
  {
224
  $return_html .= sprintf($html_field, $data) . $br;
225
  }
226
- else if ($type == 'radio' || $type == 'checkbox' || $type == 'select')
227
- {
 
 
228
  foreach ($data as $key => $value)
229
  {
230
- // handle checkbox a little bit differently
231
  if ($type == 'checkbox')
232
  {
 
233
  if ($this->form_options[$value] == 'yes')
234
- $return_html .= str_replace(array('%value%', '%name%', '%label%', '%checked%'), array($value, $value, $key, $checked), $html_field) . $br;
 
 
 
 
 
 
 
 
 
235
  else
236
- $return_html .= str_replace(array('%value%', '%name%', '%label%', '%checked%'), array($value, $value, $key, ''), $html_field) . $br;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  }
238
- else if (isset($this->form_options[$name]) && $this->form_options[$name] == $value)
239
- $return_html .= str_replace(array('%value%', '%name%', '%label%', '%option%', '%checked%', '%selected%', '%pre%', '%post%'), array($value, $value, $key, $key, $checked, $selected, $pre, $post), $html_field) . $br;
240
  else
241
- $return_html .= str_replace(array('%value%', '%name%', '%label%', '%option%', '%checked%', '%selected%', '%pre%', '%post%'), array($value, $value, $key, $key, '', '', $pre, $post), $html_field) . $br;
 
 
 
 
 
 
 
 
242
  }
243
  }
244
  else
@@ -246,12 +380,15 @@ class BWP_OPTION_PAGE {
246
  foreach ($array_search as &$keyword)
247
  {
248
  $array_replace[$keyword] = '';
 
249
  if (!empty($data[$keyword]))
250
  {
251
  $array_replace[$keyword] = $data[$keyword];
252
  }
 
253
  $keyword = '%' . $keyword . '%';
254
  }
 
255
  $return_html = str_replace($array_search, $array_replace, $html_field) . $br;
256
  }
257
 
@@ -266,8 +403,10 @@ class BWP_OPTION_PAGE {
266
  }
267
  }
268
 
269
- // Post
270
- $post = (!empty($this->form['post'][$name])) ? ' ' . $this->form['post'][$name] : $post;
 
 
271
 
272
  return str_replace('%pre%', $pre, $pre_html_field) . $return_html . str_replace('%post%', $post, $post_html_field) . $inline_html;
273
  }
@@ -288,24 +427,28 @@ class BWP_OPTION_PAGE {
288
  ? 'bwp-option-page-heading-desc'
289
  : 'bwp-option-page-inputs';
290
 
291
- // An inline item can hold any HTML markup
292
- // An example is to display some kinds of button right be low the label
293
  $inline = '';
 
294
  if (isset($this->form['inline']) && is_array($this->form['inline'])
295
  && array_key_exists($name, $this->form['inline'])
296
  ) {
297
- $inline = (empty($this->form['inline'][$name])) ? '' : $this->form['inline'][$name];
298
  }
 
299
  $inline .= "\n";
300
 
301
  switch ($type)
302
  {
303
  case 'section':
304
-
305
  if (!isset($this->form[$name]) || !is_array($this->form[$name]))
306
- return;
307
 
308
- $item_label = '<span class="bwp-opton-page-label">' . $this->form_item_labels[$item_key[0]] . $inline . '</span>';
 
 
 
309
 
310
  foreach ($this->form[$name] as $section_field)
311
  {
@@ -320,17 +463,17 @@ class BWP_OPTION_PAGE {
320
  break;
321
 
322
  default:
323
-
324
  if (!isset($this->form[$type][$name])
325
- || ($type != 'heading' && !is_array($this->form[$type][$name]))
326
- ) {
327
  return;
328
- }
329
 
330
- /*$item_label = (empty($this->form[$type][$name]['label'])) ? '<label class="bwp-opton-page-label" for="' . $name . '">' . $this->form_item_labels[$item_key[0]] . '</label>' : '<span class="bwp-opton-page-label">' . $this->form_item_labels[$item_key[0]] . '</span>';*/
331
- $item_label = $type != 'checkbox' && $type != 'radio'
332
- ? '<label class="bwp-opton-page-label" for="' . $name . '">' . $this->form_item_labels[$item_key[0]] . $inline . '</label>'
333
- : '<span class="bwp-opton-page-label type-' . $type . '">' . $this->form_item_labels[$item_key[0]] . $inline . '</span>';
 
 
 
334
 
335
  $item_label = $type == 'heading'
336
  ? '<h3>' . $this->form_item_labels[$item_key[0]] . '</h3>' . $inline
@@ -341,13 +484,16 @@ class BWP_OPTION_PAGE {
341
  break;
342
  }
343
 
344
- // A container can hold some result executed by customized script,
345
  // such as displaying something when user press the submit button
346
  $containers = '';
347
- if (isset($this->form['container']) && is_array($this->form['container'])
 
 
348
  && array_key_exists($name, $this->form['container'])
349
  ) {
350
  $container_array = (array) $this->form['container'][$name];
 
351
  foreach ($container_array as $container)
352
  {
353
  $containers .= empty($container)
@@ -357,10 +503,17 @@ class BWP_OPTION_PAGE {
357
  }
358
 
359
  $pure_return = trim(strip_tags($return_html));
 
360
  if (empty($pure_return) && $type == 'heading')
 
361
  return $item_label . $containers;
 
362
  else
363
- return $item_label . '<p class="' . $input_class . '">' . $return_html . '</p>' . $containers;
 
 
 
 
364
  }
365
 
366
  /**
@@ -371,6 +524,7 @@ class BWP_OPTION_PAGE {
371
  function generate_html_form()
372
  {
373
  $return_str = '<div class="wrap" style="padding-bottom: 20px;">' . "\n";
 
374
  if (sizeof($this->form_tabs) >= 2)
375
  $return_str .= apply_filters('bwp-admin-form-icon', '<div class="icon32" id="icon-options-general"><br></div>' . "\n");
376
  else
@@ -379,19 +533,23 @@ class BWP_OPTION_PAGE {
379
  if (sizeof($this->form_tabs) >= 2)
380
  {
381
  $count = 0;
 
382
  $return_str .= '<h2 class="bwp-option-page-tabs">' . "\n";
383
  $return_str .= apply_filters('bwp-admin-plugin-version', '') . "\n";
 
384
  foreach ($this->form_tabs as $title => $link)
385
  {
386
  $count++;
387
- $active = ($count == $this->current_tab) ? ' nav-tab-active' : '';
 
388
  $return_str .= '<a class="nav-tab' . $active . '" href="' . $link . '">' . $title . '</a>' . "\n";
389
  }
 
390
  $return_str .= '</h2>' . "\n";
391
  }
392
  else if (!isset($this->form_tabs[0]))
393
  {
394
- $title = array_keys($this->form_tabs);
395
  $return_str .= '<h2>' . $title[0] . '</h2>' . "\n";
396
  }
397
  else
@@ -399,37 +557,74 @@ class BWP_OPTION_PAGE {
399
 
400
  $return_str .= apply_filters('bwp_option_before_form', '');
401
  echo $return_str;
 
402
  do_action('bwp_option_action_before_form');
403
- $return_str = '';
 
404
  $return_str .= '<form class="bwp-option-page" name="' . $this->form_name . '" method="post" action="">' . "\n";
 
405
  if (function_exists('wp_nonce_field'))
406
  {
407
  echo $return_str;
 
408
  wp_nonce_field($this->form_name);
 
409
  $return_str = '';
410
  }
 
411
  $return_str .= '<ul>' . "\n";
412
 
413
  // generate filled form
414
  if (isset($this->form_items) && is_array($this->form_items))
415
- foreach ($this->form_items as $key => $type)
416
  {
417
- if (!empty($this->form_item_names[$key]) && !empty($this->form_item_labels[$key]))
418
  {
419
- $return_str .= '<li class="bwp-clear">' . $this->generate_html_fields($type, $this->form_item_names[$key]) . '</li>' . "\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
420
  }
421
  }
422
 
423
  $return_str .= '</ul>' . "\n";
424
  $return_str .= apply_filters('bwp_option_before_submit_button', '');
 
425
  echo $return_str;
426
  do_action('bwp_option_action_before_submit_button');
427
- $return_str = '';
428
- $return_str .= apply_filters('bwp_option_submit_button', '<p class="submit"><input type="submit" class="button-primary" name="submit_' . $this->form_name . '" value="' . __('Save Changes') . '" /></p>') . "\n";
 
 
 
 
429
  $return_str .= '</form>' . "\n";
430
  $return_str .= '</div>' . "\n";
431
 
432
  echo $return_str;
433
  }
434
-
435
  }
4
  * @license http://www.gnu.org/licenses/gpl.html GNU GENERAL PUBLIC LICENSE VERSION 3.0 OR LATER
5
  */
6
 
7
+ class BWP_OPTION_PAGE
8
+ {
9
  /**
10
  * The form
11
  */
56
  */
57
  function __construct($form_name = 'bwp_option_page', $site_options = array(), $domain = '')
58
  {
59
+ $this->form_name = $form_name;
60
+ $this->site_options = $site_options;
61
+ $this->domain = $domain;
62
  }
63
 
64
  /**
78
  $this->form_tabs = $form_tabs;
79
 
80
  if (sizeof($this->form_tabs) == 0)
81
+ $this->form_tabs = array(__('Plugin Configurations', 'bwp-option-page'));
82
  }
83
 
84
  function get_form_name()
98
  if (!in_array($key, $options))
99
  unset($options_default[$key]);
100
  }
101
+
102
  return $options_default;
103
  }
104
 
105
  function get_db_options($name = '', $options = array())
106
  {
107
  $db_options = get_option($name);
108
+
109
  if (!$db_options)
110
+ {
111
  update_option($name, $options);
112
+ }
113
  else if (array_keys($options) != array_keys($db_options))
114
  {
115
  foreach ($db_options as $key => $data)
116
  if (isset($options[$key]) && !in_array($key, $this->site_options))
117
  $options[$key] = $data;
118
+
119
  update_option($name, $options);
120
  }
121
  else
122
  {
123
  foreach ($db_options as $key => $data)
124
+ {
125
  if (!in_array($key, $this->site_options))
126
  $options[$key] = $data;
127
+ }
128
  }
129
 
130
  return $options;
145
  $_POST[$key] = strip_tags($_POST[$key]);
146
  }
147
 
148
+ function kill_html_fields(&$form, $names)
149
  {
150
+ $ids = array();
151
+ $names = (array) $names;
152
+
153
+ foreach ($form['item_names'] as $key => $name)
154
+ {
155
+ if (in_array($name, $names))
156
+ $ids[] = $key;
157
+ }
158
+
159
+ $in_keys = array(
160
+ 'items',
161
+ 'item_labels',
162
+ 'item_names'
163
+ );
164
+
165
  foreach ($ids as $id)
166
  {
167
  foreach ($in_keys as $key)
171
 
172
  /**
173
  * Generate HTML field
 
 
174
  */
175
  function generate_html_field($type = '', $data = array(), $name = '', $in_section = false)
176
  {
177
+ $pre_html_field = '';
178
+ $post_html_field = '';
179
+
180
+ $checked = 'checked="checked" ';
181
+ $selected = 'selected="selected" ';
182
 
183
+ $value = isset($this->form_options[$name])
184
  ? $this->form_options[$name]
185
  : '';
186
 
187
+ $value = isset($data['value']) ? $data['value'] : $value;
188
+
189
+ $value = !empty($this->domain)
190
  && ('textarea' == $type || 'input' == $type)
191
  ? __($value, $this->domain)
192
  : $value;
193
 
194
+ if (is_array($value))
195
+ {
196
+ foreach ($value as &$v)
197
+ $v = is_array($v) ? array_map('esc_attr', $v) : esc_attr($v);
198
+ }
199
+ else
200
+ {
201
+ $value = 'textarea' == $type
202
+ ? esc_html($value)
203
+ : esc_attr($value);
204
+ }
205
 
206
+ $array_replace = array();
207
+ $array_search = array(
208
+ 'size',
209
+ 'name',
210
+ 'value',
211
+ 'cols',
212
+ 'rows',
213
+ 'label',
214
+ 'disabled',
215
+ 'pre',
216
+ 'post'
217
+ );
218
+
219
+ $return_html = '';
220
+
221
+ $br = isset($this->form['inline_fields'][$name])
222
  && is_array($this->form['inline_fields'][$name])
223
  ? ''
224
  : "<br />\n";
225
 
226
+ $pre = !empty($data['pre']) ? $data['pre'] : '';
227
+ $post = !empty($data['post']) ? $data['post'] : '';
228
+
229
+ $param = empty($this->form['params'][$name])
230
+ ? false : $this->form['params'][$name];
231
 
232
  switch ($type)
233
  {
236
  break;
237
 
238
  case 'input':
239
+ $html_field = !$in_section
240
+ ? '%pre%<input%disabled% size="%size%" type="text" '
241
+ . 'id="' . $name . '" '
242
+ . 'name="' . $name . '" '
243
+ . 'value="' . $value . '" /> <em>%label%</em>'
244
+ : '<label for="' . $name . '">%pre%<input%disabled% size="%size%" type="text" '
245
+ . 'id="' . $name . '" '
246
+ . 'name="' . $name . '" '
247
+ . 'value="' . $value . '" /> <em>%label%</em></label>';
248
  break;
249
 
250
  case 'select':
251
+ case 'select_multi':
252
+ $pre_html_field = 'select_multi' == $type
253
+ ? '%pre%<select id="' . $name . '" name="' . $name . '[]" multiple>' . "\n"
254
+ : '%pre%<select id="' . $name . '" name="' . $name . '">' . "\n";
255
+
256
+ $html_field = '<option %selected%value="%value%">%option%</option>';
257
+
258
  $post_html_field = '</select>%post%' . $br;
259
  break;
260
 
261
  case 'checkbox':
262
+ $html_field = '<label for="%name%">'
263
+ . '<input %checked%type="checkbox" id="%name%" name="%name%" value="yes" /> %label%</label>';
264
+ break;
265
+
266
+ case 'checkbox_multi':
267
+ $html_field = '<label for="%name%-%value%">'
268
+ . '<input %checked%type="checkbox" id="%name%-%value%" name="%name%[]" value="%value%" /> %label%</label>';
269
  break;
270
 
271
  case 'radio':
272
+ $html_field = '<label>' . '<input %checked%type="radio" '
273
+ . 'name="' . $name . '" value="%value%" /> %label%</label>';
274
  break;
275
 
276
  case 'textarea':
277
+ $html_field = '%pre%<textarea%disabled% '
278
+ . 'id="' . $name . '" '
279
+ . 'name="' . $name . '" cols="%cols%" rows="%rows%">'
280
+ . $value . '</textarea>%post%';
281
  break;
282
  }
283
 
288
  {
289
  $return_html .= sprintf($html_field, $data) . $br;
290
  }
291
+ else if ($type == 'radio'
292
+ || $type == 'checkbox' || $type == 'checkbox_multi'
293
+ || $type == 'select' || $type == 'select_multi'
294
+ ) {
295
  foreach ($data as $key => $value)
296
  {
 
297
  if ($type == 'checkbox')
298
  {
299
+ // handle checkbox a little bit differently
300
  if ($this->form_options[$value] == 'yes')
301
+ {
302
+ $return_html .= str_replace(
303
+ array('%value%', '%name%', '%label%', '%checked%'),
304
+ array($value, $value, $key, $checked),
305
+ $html_field
306
+ );
307
+
308
+ $return_html .= apply_filters('bwp_option_after_' . $type . '_' . $name . '_checked', '', $value, $param);
309
+ $return_html .= $br;
310
+ }
311
  else
312
+ {
313
+ $return_html .= str_replace(
314
+ array('%value%', '%name%', '%label%', '%checked%'),
315
+ array($value, $value, $key, ''),
316
+ $html_field
317
+ );
318
+
319
+ $return_html .= apply_filters('bwp_option_after_' . $type . '_' . $name, '', $value, $param);
320
+ $return_html .= $br;
321
+ }
322
+ }
323
+ else if ($type == 'checkbox_multi')
324
+ {
325
+ // handle a multi checkbox differently
326
+ if (isset($this->form_options[$name])
327
+ && is_array($this->form_options[$name])
328
+ && (in_array($value, $this->form_options[$name])
329
+ || array_key_exists($value, $this->form_options[$name]))
330
+ ) {
331
+ $return_html .= str_replace(
332
+ array('%value%', '%name%', '%label%', '%checked%'),
333
+ array($value, $name, $key, $checked),
334
+ $html_field
335
+ );
336
+
337
+ $return_html .= apply_filters('bwp_option_after_' . $type . '_' . $name . '_checked', '', $value, $param);
338
+ $return_html .= $br;
339
+ }
340
+ else
341
+ {
342
+ $return_html .= str_replace(
343
+ array('%value%', '%name%', '%label%', '%checked%'),
344
+ array($value, $name, $key, ''),
345
+ $html_field
346
+ );
347
+
348
+ $return_html .= apply_filters('bwp_option_after_' . $type . '_' . $name, '', $value, $param);
349
+ $return_html .= $br;
350
+ }
351
+ }
352
+ else if (isset($this->form_options[$name])
353
+ && ($this->form_options[$name] == $value
354
+ || (is_array($this->form_options[$name])
355
+ && (in_array($value, $this->form_options[$name])
356
+ || array_key_exists($value, $this->form_options[$name]))))
357
+ ) {
358
+ $item_br = $type == 'select' || $type == 'select_multi' ? "\n" : $br;
359
+
360
+ $return_html .= str_replace(
361
+ array('%value%', '%name%', '%label%', '%option%', '%checked%', '%selected%', '%pre%', '%post%'),
362
+ array($value, $value, $key, $key, $checked, $selected, $pre, $post),
363
+ $html_field
364
+ ) . $item_br;
365
  }
 
 
366
  else
367
+ {
368
+ $item_br = $type == 'select' || $type == 'select_multi' ? "\n" : $br;
369
+
370
+ $return_html .= str_replace(
371
+ array('%value%', '%name%', '%label%', '%option%', '%checked%', '%selected%', '%pre%', '%post%'),
372
+ array($value, $value, $key, $key, '', '', $pre, $post),
373
+ $html_field
374
+ ) . $item_br;
375
+ }
376
  }
377
  }
378
  else
380
  foreach ($array_search as &$keyword)
381
  {
382
  $array_replace[$keyword] = '';
383
+
384
  if (!empty($data[$keyword]))
385
  {
386
  $array_replace[$keyword] = $data[$keyword];
387
  }
388
+
389
  $keyword = '%' . $keyword . '%';
390
  }
391
+
392
  $return_html = str_replace($array_search, $array_replace, $html_field) . $br;
393
  }
394
 
403
  }
404
  }
405
 
406
+ // html after field
407
+ $post = !empty($this->form['post'][$name])
408
+ ? ' ' . $this->form['post'][$name]
409
+ : $post;
410
 
411
  return str_replace('%pre%', $pre, $pre_html_field) . $return_html . str_replace('%post%', $post, $post_html_field) . $inline_html;
412
  }
427
  ? 'bwp-option-page-heading-desc'
428
  : 'bwp-option-page-inputs';
429
 
430
+ // an inline item can hold any HTML markup, example is to display some
431
+ // kinds of button right be low the label
432
  $inline = '';
433
+
434
  if (isset($this->form['inline']) && is_array($this->form['inline'])
435
  && array_key_exists($name, $this->form['inline'])
436
  ) {
437
+ $inline = empty($this->form['inline'][$name]) ? '' : $this->form['inline'][$name];
438
  }
439
+
440
  $inline .= "\n";
441
 
442
  switch ($type)
443
  {
444
  case 'section':
 
445
  if (!isset($this->form[$name]) || !is_array($this->form[$name]))
446
+ return;
447
 
448
+ $item_label = '<span class="bwp-opton-page-label">'
449
+ . $this->form_item_labels[$item_key[0]]
450
+ . $inline
451
+ . '</span>';
452
 
453
  foreach ($this->form[$name] as $section_field)
454
  {
463
  break;
464
 
465
  default:
 
466
  if (!isset($this->form[$type][$name])
467
+ || ($type != 'heading' && !is_array($this->form[$type][$name])))
 
468
  return;
 
469
 
470
+ $item_label = $type != 'checkbox' && $type != 'checkbox_multi' && $type != 'radio'
471
+ ? '<label class="bwp-opton-page-label" for="' . $name . '">'
472
+ . $this->form_item_labels[$item_key[0]] . $inline
473
+ . '</label>'
474
+ : '<span class="bwp-opton-page-label type-' . $type . '">'
475
+ . $this->form_item_labels[$item_key[0]] . $inline
476
+ . '</span>';
477
 
478
  $item_label = $type == 'heading'
479
  ? '<h3>' . $this->form_item_labels[$item_key[0]] . '</h3>' . $inline
484
  break;
485
  }
486
 
487
+ // a container can hold some result executed by customized script,
488
  // such as displaying something when user press the submit button
489
  $containers = '';
490
+
491
+ if (isset($this->form['container'])
492
+ && is_array($this->form['container'])
493
  && array_key_exists($name, $this->form['container'])
494
  ) {
495
  $container_array = (array) $this->form['container'][$name];
496
+
497
  foreach ($container_array as $container)
498
  {
499
  $containers .= empty($container)
503
  }
504
 
505
  $pure_return = trim(strip_tags($return_html));
506
+
507
  if (empty($pure_return) && $type == 'heading')
508
+ {
509
  return $item_label . $containers;
510
+ }
511
  else
512
+ {
513
+ return $item_label . '<p class="' . $input_class . '">'
514
+ . $return_html . '</p>'
515
+ . $containers;
516
+ }
517
  }
518
 
519
  /**
524
  function generate_html_form()
525
  {
526
  $return_str = '<div class="wrap" style="padding-bottom: 20px;">' . "\n";
527
+
528
  if (sizeof($this->form_tabs) >= 2)
529
  $return_str .= apply_filters('bwp-admin-form-icon', '<div class="icon32" id="icon-options-general"><br></div>' . "\n");
530
  else
533
  if (sizeof($this->form_tabs) >= 2)
534
  {
535
  $count = 0;
536
+
537
  $return_str .= '<h2 class="bwp-option-page-tabs">' . "\n";
538
  $return_str .= apply_filters('bwp-admin-plugin-version', '') . "\n";
539
+
540
  foreach ($this->form_tabs as $title => $link)
541
  {
542
  $count++;
543
+
544
+ $active = $count == $this->current_tab ? ' nav-tab-active' : '';
545
  $return_str .= '<a class="nav-tab' . $active . '" href="' . $link . '">' . $title . '</a>' . "\n";
546
  }
547
+
548
  $return_str .= '</h2>' . "\n";
549
  }
550
  else if (!isset($this->form_tabs[0]))
551
  {
552
+ $title = array_keys($this->form_tabs);
553
  $return_str .= '<h2>' . $title[0] . '</h2>' . "\n";
554
  }
555
  else
557
 
558
  $return_str .= apply_filters('bwp_option_before_form', '');
559
  echo $return_str;
560
+
561
  do_action('bwp_option_action_before_form');
562
+
563
+ $return_str = '';
564
  $return_str .= '<form class="bwp-option-page" name="' . $this->form_name . '" method="post" action="">' . "\n";
565
+
566
  if (function_exists('wp_nonce_field'))
567
  {
568
  echo $return_str;
569
+
570
  wp_nonce_field($this->form_name);
571
+
572
  $return_str = '';
573
  }
574
+
575
  $return_str .= '<ul>' . "\n";
576
 
577
  // generate filled form
578
  if (isset($this->form_items) && is_array($this->form_items))
 
579
  {
580
+ foreach ($this->form_items as $key => $type)
581
  {
582
+ $name = !empty($this->form_item_names[$key])
583
+ ? $this->form_item_names[$key]
584
+ : '';
585
+
586
+ if (isset($this->form['env'])
587
+ && !BWP_FRAMEWORK_IMPROVED::is_multisite()
588
+ && array_key_exists($name, $this->form['env'])
589
+ && $this->form['env'][$name] == 'multisite')
590
+ {
591
+ // hide multisite field if not in multisite environment
592
+ continue;
593
+ }
594
+
595
+ if (isset($this->form['role'])
596
+ && BWP_FRAMEWORK_IMPROVED::is_normal_admin()
597
+ && array_key_exists($name, $this->form['role'])
598
+ && $this->form['role'][$name] == 'superadmin')
599
+ {
600
+ // hide superadmin-only fields if user is normal admin
601
+ continue;
602
+ }
603
+
604
+ if (!empty($name) && !empty($this->form_item_labels[$key])
605
+ ) {
606
+ $return_str .= '<li class="bwp-clear">'
607
+ . $this->generate_html_fields($type, $name)
608
+ . '</li>'
609
+ . "\n";
610
+ }
611
  }
612
  }
613
 
614
  $return_str .= '</ul>' . "\n";
615
  $return_str .= apply_filters('bwp_option_before_submit_button', '');
616
+
617
  echo $return_str;
618
  do_action('bwp_option_action_before_submit_button');
619
+
620
+ $return_str = '';
621
+ $return_str .= apply_filters('bwp_option_submit_button',
622
+ '<p class="submit"><input type="submit" class="button-primary" name="submit_'
623
+ . $this->form_name . '" value="' . __('Save Changes') . '" /></p>') . "\n";
624
+
625
  $return_str .= '</form>' . "\n";
626
  $return_str .= '</div>' . "\n";
627
 
628
  echo $return_str;
629
  }
 
630
  }
includes/class-bwp-enqueued-detector.php CHANGED
@@ -70,6 +70,7 @@ class BWP_Enqueued_Detector
70
  'sslverify' => apply_filters('https_local_ssl_verify', true)
71
  )
72
  );
 
73
  wp_remote_get($request['url'], $request['args']);
74
  }
75
  }
@@ -304,7 +305,7 @@ class BWP_Enqueued_Detector
304
  $logs = get_option($key);
305
 
306
  $this->_log_key = $key;
307
- $this->_logs = !empty($logs) ? (array) $logs : array();
308
  $this->_db_logs = $this->_logs;
309
 
310
  $this->_prepare_logs();
@@ -347,12 +348,12 @@ class BWP_Enqueued_Detector
347
  $actions = 'script' == $type
348
  ? array('header' => __('move to header', $this->_domain),
349
  'footer' => __('move to footer', $this->_domain),
350
- 'direct' => __('print separately', $this->_domain),
351
- 'ignore' => __('ignore', $this->_domain),
352
- 'oblivion' => __('forget', $this->_domain))
353
- : array('style_direct' => __('print separately', $this->_domain),
354
- 'style_ignore' => __('ignore', $this->_domain),
355
- 'style_oblivion' => __('forget', $this->_domain));
356
 
357
  if (0 < sizeof($log)) :
358
  foreach ($log as $item) :
@@ -384,7 +385,7 @@ class BWP_Enqueued_Detector
384
  foreach ($actions as $position => $action) :
385
  ?>
386
  | <a href="#" class="action-handle"
387
- data-position="<?php echo $position; ?>"><?php echo $action; ?></a>
388
  <?php
389
  endforeach;
390
  ?>
@@ -397,12 +398,21 @@ class BWP_Enqueued_Detector
397
  ?>
398
  <tr>
399
  <td colspan="5">
400
- <?php _e('No enqueued files detected.<br /><br />'
401
- . 'Please try visiting a few pages on your site '
402
- . 'and then refresh this page.<br /><br />'
403
- . 'You should clear this list once in a while '
404
- . 'to get rid of files that are no longer being used '
405
- . 'as this is not done automatically.', $this->_domain); ?>
 
 
 
 
 
 
 
 
 
406
  </td>
407
  </tr>
408
  <?php
@@ -437,45 +447,46 @@ class BWP_Enqueued_Detector
437
  }
438
 
439
  $min = $item['min']; // minify needed
440
- $wp = $item['wp']; // minify but print separately
441
 
442
  if ($min)
443
  {
444
- // separated or combined and minified
445
  return $wp
446
- ? sprintf(__('separated in %s', $this->_domain), $position)
447
  : sprintf(__('minified in %s', $this->_domain), $position);
448
  }
449
  else
450
  {
451
- // ignored or forgotten
452
- return 'oblivion' == $position
453
- ? __('forgotten', $this->_domain)
454
- : sprintf(__('ignored in %s', $this->_domain), $position);
 
 
 
455
  }
456
  }
457
 
458
  private function _get_position_order($item)
459
  {
460
- // order of positions: header, separate in header, ignore in header,
461
- // footer{n}, separate in footer{n}, ignore in footer{n}, oblivion
462
  $orders = array(
463
- '1_0_header' => 0,
464
- '1_1_header' => 1,
465
- '0_0_header' => 2,
466
- '0_1_header' => 2,
467
- '1_0_footer' => 3,
468
- '1_1_footer' => 4,
469
- '0_0_footer' => 5,
470
- '0_1_footer' => 5,
471
- '1_1_oblivion' => 6,
472
  '1_0_oblivion' => 6,
473
- '0_1_oblivion' => 6,
474
  '0_0_oblivion' => 6
475
  );
476
- $order = 0;
477
 
478
- $order = (int) $item['min'] . '_' . (int) $item['wp'] . '_' . $item['position'];
 
 
 
 
479
  $order = $orders[$order];
480
 
481
  return $order;
70
  'sslverify' => apply_filters('https_local_ssl_verify', true)
71
  )
72
  );
73
+
74
  wp_remote_get($request['url'], $request['args']);
75
  }
76
  }
305
  $logs = get_option($key);
306
 
307
  $this->_log_key = $key;
308
+ $this->_logs = !empty($logs) ? (array) $logs : array();
309
  $this->_db_logs = $this->_logs;
310
 
311
  $this->_prepare_logs();
348
  $actions = 'script' == $type
349
  ? array('header' => __('move to header', $this->_domain),
350
  'footer' => __('move to footer', $this->_domain),
351
+ 'direct' => __('stay at position', $this->_domain),
352
+ 'ignore' => __('not minify', $this->_domain),
353
+ 'oblivion' => __('remove', $this->_domain))
354
+ : array('style_direct' => __('stay at position', $this->_domain),
355
+ 'style_ignore' => __('not minify', $this->_domain),
356
+ 'style_oblivion' => __('remove', $this->_domain));
357
 
358
  if (0 < sizeof($log)) :
359
  foreach ($log as $item) :
385
  foreach ($actions as $position => $action) :
386
  ?>
387
  | <a href="#" class="action-handle"
388
+ data-action="<?php echo $position; ?>"><?php echo $action; ?></a>
389
  <?php
390
  endforeach;
391
  ?>
398
  ?>
399
  <tr>
400
  <td colspan="5">
401
+ <?php
402
+ $message = __('No enqueued files detected.<br /><br />'
403
+ . 'Please try visiting a few pages on your site '
404
+ . 'and then refresh this page.<br /><br />'
405
+ . 'You should clear this list once in a while '
406
+ . 'to get rid of files that are no longer being used '
407
+ . 'as this is not done automatically.', $this->_domain);
408
+
409
+ if ($type == 'script' && $this->_options['enable_min_js'] != 'yes')
410
+ $message = __('JS minification is currently disabled.', $this->_domain);
411
+ else if ($type == 'style' && $this->_options['enable_min_css'] != 'yes')
412
+ $message = __('CSS minification is currently disabled.', $this->_domain);
413
+
414
+ echo $message;
415
+ ?>
416
  </td>
417
  </tr>
418
  <?php
447
  }
448
 
449
  $min = $item['min']; // minify needed
450
+ $wp = $item['wp']; // printed at original position
451
 
452
  if ($min)
453
  {
454
+ // combined and minified or minified at original position
455
  return $wp
456
+ ? __('minified at original', $this->_domain)
457
  : sprintf(__('minified in %s', $this->_domain), $position);
458
  }
459
  else
460
  {
461
+ // ignored or removed
462
+ if ($wp)
463
+ return __('ignored at original', $this->_domain);
464
+ else
465
+ return 'oblivion' == $position
466
+ ? __('removed', $this->_domain)
467
+ : sprintf(__('ignored in %s', $this->_domain), $position);
468
  }
469
  }
470
 
471
  private function _get_position_order($item)
472
  {
473
+ // order of positions: original, header, footer{n}, oblivion
 
474
  $orders = array(
475
+ '1_1_original' => 0,
476
+ '0_1_original' => 1,
477
+ '1_0_header' => 2,
478
+ '0_0_header' => 3,
479
+ '1_0_footer' => 4,
480
+ '0_0_footer' => 5,
 
 
 
481
  '1_0_oblivion' => 6,
 
482
  '0_0_oblivion' => 6
483
  );
 
484
 
485
+ // remove the number part for footer{n}
486
+ $position = preg_replace('/\d$/', '', $item['position']);
487
+
488
+ $order = 0;
489
+ $order = (int) $item['min'] . '_' . (int) $item['wp'] . '_' . $position;
490
  $order = $orders[$order];
491
 
492
  return $order;
includes/class-bwp-framework-improved.php CHANGED
@@ -4,8 +4,8 @@
4
  * @license http://www.gnu.org/licenses/gpl.html GNU GENERAL PUBLIC LICENSE VERSION 3.0 OR LATER
5
  */
6
 
7
- class BWP_FRAMEWORK_IMPROVED {
8
-
9
  /**
10
  * Database related data
11
  */
@@ -210,7 +210,7 @@ class BWP_FRAMEWORK_IMPROVED {
210
  echo '<div class="error"><p>' . sprintf(
211
  __('%s requires WordPress <strong>%s</strong> or higher '
212
  . 'and PHP <strong>%s</strong> or higher. '
213
- . 'The plugin will not protected function until you update your software. '
214
  . 'Please deactivate this plugin.', $this->plugin_dkey),
215
  $this->plugin_title, $this->wp_ver, $this->php_ver)
216
  . '</p></div>';
@@ -218,8 +218,12 @@ class BWP_FRAMEWORK_IMPROVED {
218
 
219
  public function show_donation()
220
  {
221
- $showable = apply_filters('bwp_donation_showable', true);
222
- $ad_showable = apply_filters('bwp_ad_showable', true);
 
 
 
 
223
  ?>
224
  <div id="bwp-info-place">
225
  <div id="bwp-donation" style="margin-bottom: 0px;">
@@ -229,7 +233,7 @@ class BWP_FRAMEWORK_IMPROVED {
229
  </small>
230
  <br />
231
  <?php
232
- if (true == $showable || ($this->is_multisite() && is_super_admin()))
233
  {
234
  ?>
235
  <small><?php _e('You can buy me some special coffees if you appreciate my work, thank you!', $this->plugin_dkey); ?></small>
@@ -290,6 +294,7 @@ class BWP_FRAMEWORK_IMPROVED {
290
  ?>
291
  </div>
292
  <?php
 
293
  }
294
 
295
  public function show_version()
@@ -421,7 +426,7 @@ class BWP_FRAMEWORK_IMPROVED {
421
  $options = array_merge($options, $db_option);
422
  unset($db_option);
423
  // Also check for global options if in Multi-site
424
- if ($this->is_multisite())
425
  {
426
  $db_option = get_site_option($option);
427
  if ($db_option && is_array($db_option))
@@ -698,7 +703,7 @@ class BWP_FRAMEWORK_IMPROVED {
698
  return false;
699
  }
700
 
701
- protected static function is_normal_admin()
702
  {
703
  if (self::is_multisite() && !is_super_admin())
704
  return true;
@@ -722,6 +727,7 @@ class BWP_FRAMEWORK_IMPROVED {
722
  ) {
723
  return true;
724
  }
 
725
  return false;
726
  }
727
  }
4
  * @license http://www.gnu.org/licenses/gpl.html GNU GENERAL PUBLIC LICENSE VERSION 3.0 OR LATER
5
  */
6
 
7
+ class BWP_FRAMEWORK_IMPROVED
8
+ {
9
  /**
10
  * Database related data
11
  */
210
  echo '<div class="error"><p>' . sprintf(
211
  __('%s requires WordPress <strong>%s</strong> or higher '
212
  . 'and PHP <strong>%s</strong> or higher. '
213
+ . 'The plugin will not function until you update your software. '
214
  . 'Please deactivate this plugin.', $this->plugin_dkey),
215
  $this->plugin_title, $this->wp_ver, $this->php_ver)
216
  . '</p></div>';
218
 
219
  public function show_donation()
220
  {
221
+ $info_showable = apply_filters('bwp_info_showable', true);
222
+ $donation_showable = apply_filters('bwp_donation_showable', true);
223
+ $ad_showable = apply_filters('bwp_ad_showable', true);
224
+
225
+ if (true == $info_showable || (self::is_multisite() && is_super_admin()))
226
+ {
227
  ?>
228
  <div id="bwp-info-place">
229
  <div id="bwp-donation" style="margin-bottom: 0px;">
233
  </small>
234
  <br />
235
  <?php
236
+ if (true == $donation_showable || (self::is_multisite() && is_super_admin()))
237
  {
238
  ?>
239
  <small><?php _e('You can buy me some special coffees if you appreciate my work, thank you!', $this->plugin_dkey); ?></small>
294
  ?>
295
  </div>
296
  <?php
297
+ }
298
  }
299
 
300
  public function show_version()
426
  $options = array_merge($options, $db_option);
427
  unset($db_option);
428
  // Also check for global options if in Multi-site
429
+ if (self::is_multisite())
430
  {
431
  $db_option = get_site_option($option);
432
  if ($db_option && is_array($db_option))
703
  return false;
704
  }
705
 
706
+ public static function is_normal_admin()
707
  {
708
  if (self::is_multisite() && !is_super_admin())
709
  return true;
727
  ) {
728
  return true;
729
  }
730
+
731
  return false;
732
  }
733
  }
includes/class-bwp-minify-cdn.php CHANGED
@@ -36,12 +36,13 @@ class BWP_Minify_CDN
36
  if (empty($cdn_host))
37
  return $string;
38
 
39
-
40
  // force SSL when WordPress is on SSL, or use scheme-less URL
41
  $ssl_type = $this->_options['select_cdn_ssl_type'];
 
42
  $scheme = is_ssl() ? 'https://' : 'http://';
43
  $scheme = 'less' == $ssl_type ? '//' : $scheme;
44
  $scheme = 'off' == $ssl_type ? 'http://' : $scheme;
 
45
  $string = preg_replace('#https?://[^/]+#ui',
46
  $scheme . $cdn_host,
47
  $string
@@ -75,7 +76,7 @@ class BWP_Minify_CDN
75
  {
76
  // priority 11 to make sure that this filter is applied after the
77
  // fetcher class has finished friendlifying the Minify string
78
- add_filter('bwp_get_minify_src', array($this, 'replace_host'), 11, 2);
79
  }
80
 
81
  private function _init()
36
  if (empty($cdn_host))
37
  return $string;
38
 
 
39
  // force SSL when WordPress is on SSL, or use scheme-less URL
40
  $ssl_type = $this->_options['select_cdn_ssl_type'];
41
+
42
  $scheme = is_ssl() ? 'https://' : 'http://';
43
  $scheme = 'less' == $ssl_type ? '//' : $scheme;
44
  $scheme = 'off' == $ssl_type ? 'http://' : $scheme;
45
+
46
  $string = preg_replace('#https?://[^/]+#ui',
47
  $scheme . $cdn_host,
48
  $string
76
  {
77
  // priority 11 to make sure that this filter is applied after the
78
  // fetcher class has finished friendlifying the Minify string
79
+ add_filter('bwp_minify_get_src', array($this, 'replace_host'), 11, 2);
80
  }
81
 
82
  private function _init()
includes/class-bwp-minify-fetcher.php CHANGED
@@ -108,6 +108,7 @@ class BWP_Minify_Fetcher
108
  __('Minify group %s not found.', $this->_domain),
109
  $group_handle
110
  );
 
111
  exit;
112
  }
113
 
@@ -158,7 +159,7 @@ class BWP_Minify_Fetcher
158
  if ($min_documentRoot)
159
  {
160
  $_SERVER['DOCUMENT_ROOT'] = $min_documentRoot;
161
- Minify::$isDocRootSet = true;
162
  }
163
 
164
  // set serve options for each file type if needed
@@ -220,14 +221,14 @@ class BWP_Minify_Fetcher
220
  if (empty($ext))
221
  return $string;
222
 
223
- // if this group has not been detected we serve the regular Minify url,
224
- // and detect this group as well so it can be served using friendly url
225
- // next time
226
  $detector_version = $this->_detector->get_version();
227
  $group_hash = md5($original_string . $detector_version);
228
 
229
  if (false == $this->_is_group_detected($group_hash))
230
  {
 
 
 
231
  $group_type = 'js' == $ext ? 'script' : 'style';
232
 
233
  $this->_detector->detect_group(
@@ -235,12 +236,11 @@ class BWP_Minify_Fetcher
235
  $original_string,
236
  $group_type
237
  );
238
-
239
- return $string;
240
  }
241
 
242
  // build the friendly url for this minify url
243
  global $blog_id;
 
244
  $fly_url = $this->_min_fly_url . 'minify-'
245
  . 'b' . $blog_id . '-' . $group_handle
246
  . '-' . $group_hash
@@ -260,8 +260,7 @@ class BWP_Minify_Fetcher
260
  */
261
  private function _is_group_detected($group_hash)
262
  {
263
- // get detected groups from db to make sure that they are persistently stored
264
- $detected = $this->_detector->get_detected_groups(true);
265
 
266
  if (0 == sizeof($detected))
267
  return false;
108
  __('Minify group %s not found.', $this->_domain),
109
  $group_handle
110
  );
111
+
112
  exit;
113
  }
114
 
159
  if ($min_documentRoot)
160
  {
161
  $_SERVER['DOCUMENT_ROOT'] = $min_documentRoot;
162
+ Minify::$isDocRootSet = true;
163
  }
164
 
165
  // set serve options for each file type if needed
221
  if (empty($ext))
222
  return $string;
223
 
 
 
 
224
  $detector_version = $this->_detector->get_version();
225
  $group_hash = md5($original_string . $detector_version);
226
 
227
  if (false == $this->_is_group_detected($group_hash))
228
  {
229
+ // if this group has not been detected, do so. When this friendly
230
+ // url is served it should use data from the just-detected group
231
+ // because this group has not been persistently stored.
232
  $group_type = 'js' == $ext ? 'script' : 'style';
233
 
234
  $this->_detector->detect_group(
236
  $original_string,
237
  $group_type
238
  );
 
 
239
  }
240
 
241
  // build the friendly url for this minify url
242
  global $blog_id;
243
+
244
  $fly_url = $this->_min_fly_url . 'minify-'
245
  . 'b' . $blog_id . '-' . $group_handle
246
  . '-' . $group_hash
260
  */
261
  private function _is_group_detected($group_hash)
262
  {
263
+ $detected = $this->_detector->get_detected_groups();
 
264
 
265
  if (0 == sizeof($detected))
266
  return false;
includes/class-bwp-minify.php CHANGED
@@ -72,7 +72,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
72
  /**
73
  * Other options
74
  */
75
- var $wp_ver = '', $base = '', $remove_from_base = '', $buster = '', $cache_age = 86400;
76
  var $min_url = '', $min_dir = '', $min_path = '', $min_cache_dir = '';
77
  var $fly_min_path = '', $fly_min_url = '';
78
  var $doc_root = '', $blog_path = false;
@@ -138,17 +138,18 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
138
  * @since 1.3.0
139
  * @var BWP_Minify_AbstractRewriter
140
  */
141
- var $rewriter;
142
 
143
  /**
144
  * Constructor
145
  */
146
- function __construct($version = '1.3.0')
147
  {
148
  // Plugin's title
149
  $this->plugin_title = 'Better WordPress Minify';
150
  // Plugin's version
151
  $this->set_version($version);
 
152
  $this->set_version('5.1.6', 'php');
153
  // Plugin's language domain
154
  $this->domain = 'bwp-minify';
@@ -182,10 +183,12 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
182
  'enable_min_js' => 'yes',
183
  'enable_min_css' => 'yes',
184
  'enable_bloginfo' => '',
 
185
  'enable_css_bubble' => 'yes', // @since 1.3.0 super admin, Minify
186
  'enable_cache_file_lock' => 'yes', // @since 1.3.0 super admin, Minify
187
  'enable_debug' => '', // @since 1.3.0 super admin
188
  'enable_fly_min' => '', // @since 1.3.0
 
189
  'enable_cdn' => '', // @since 1.3.0
190
  'select_buster_type' => 'none',
191
  'select_time_type' => 86400, // super admin, Minify
@@ -226,21 +229,21 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
226
  );
227
  }
228
 
229
- function install()
230
  {
231
  // if friendly minify url is enabled we need to flush rewrite rules
232
  if ('yes' == $this->options['enable_fly_min'])
233
  $this->_add_rewrite_rules();
234
  }
235
 
236
- function uninstall()
237
  {
238
  $this->_remove_rewrite_rules();
239
  }
240
 
241
- function upgrade_plugin($from, $to)
242
  {
243
- if ($to == '1.3.0')
244
  {
245
  // @since 1.3.0 default values of min path and cache dir is empty,
246
  // also look for 'Better-WordPress-Minify-1.3.0' string for users
@@ -250,13 +253,18 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
250
  $this->_reset_cache_dir($options);
251
  update_option(BWP_MINIFY_OPTION_GENERAL, $options);
252
  }
 
 
 
 
 
253
  }
254
 
255
  protected function pre_init_properties()
256
  {
257
  $this->parse_positions();
258
 
259
- $this->wp_ver = get_bloginfo('version');
260
 
261
  // define a few urls that are used throughout the plugin
262
  $this->add_url('min_debug',
@@ -294,17 +302,16 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
294
  {
295
  // load and init appropriate rewriter class based on server type
296
  require_once dirname(__FILE__) . '/rewriter/rewriter.php';
297
- if (self::is_nginx())
298
- {
299
- require_once dirname(__FILE__) . '/rewriter/nginx.php';
300
- $this->rewriter = new BWP_Minify_Rewriter_Nginx($this);
301
- }
302
- else
303
- {
304
- // if not nginx, assume it's apache
305
- require_once dirname(__FILE__) . '/rewriter/apache.php';
306
- $this->rewriter = new BWP_Minify_Rewriter_Apache($this);
307
- }
308
  }
309
 
310
  protected function load_libraries()
@@ -315,6 +322,11 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
315
  require_once dirname(__FILE__) . '/class-bwp-minify-cdn.php';
316
 
317
  $this->_load_rewriter_class();
 
 
 
 
 
318
  }
319
 
320
  private function _reset_min_path(&$options = false)
@@ -404,6 +416,14 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
404
  : $http_host;
405
  }
406
 
 
 
 
 
 
 
 
 
407
  return $http_host;
408
  }
409
 
@@ -465,7 +485,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
465
  * @since 1.3.0
466
  * @return string
467
  */
468
- function get_min_path()
469
  {
470
  $min_path = empty($this->options['input_minpath'])
471
  ? $this->get_default_min_path()
@@ -487,7 +507,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
487
  * @since 1.3.0
488
  * @return string
489
  */
490
- function get_default_min_dir()
491
  {
492
  $plugin_wp_dir = trailingslashit(plugin_dir_path($this->plugin_file));
493
  return $plugin_wp_dir . 'min/';
@@ -499,7 +519,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
499
  * @since 1.3.0
500
  * @return string|bool false if no directory can be found
501
  */
502
- function get_min_dir()
503
  {
504
  if (!empty($this->min_dir))
505
  return $this->min_dir;
@@ -562,15 +582,20 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
562
  }
563
  }
564
 
565
- function get_wp_doc_root()
566
  {
567
  $wp_doc_root = !empty($_SERVER['SCRIPT_FILENAME'])
568
  && $_SERVER['SCRIPT_FILENAME'] != $_SERVER['PHP_SELF']
569
  ? dirname(str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']))
570
  : ABSPATH;
571
 
572
- // script filename contains `wp-admin` when in admin so we need to remove it
573
- return is_admin() ? str_replace('/wp-admin', '', $wp_doc_root) : $wp_doc_root;
 
 
 
 
 
574
  }
575
 
576
  /**
@@ -579,7 +604,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
579
  * @since 1.3.0
580
  * @return string
581
  */
582
- function get_doc_root($path = '')
583
  {
584
  $server_doc_root = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
585
  $wp_doc_root = $this->get_wp_doc_root();
@@ -602,7 +627,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
602
  * @since 1.3.0
603
  * @return string
604
  */
605
- function get_default_cache_dir()
606
  {
607
  $plugin_wp_dir = plugin_dir_path($this->plugin_file);
608
  $cache_dir = trailingslashit($plugin_wp_dir) . 'cache/';
@@ -617,7 +642,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
617
  * The default cache directory is `/min/cache/` which can be changed inside
618
  * admin area if `/min/config.php` file is writable (@since 1.3.0).
619
  */
620
- function get_cache_dir()
621
  {
622
  // return the cache dir as entered by admin
623
  // or if cache dir is empty, get cache directory from plugin
@@ -650,7 +675,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
650
  * qualify URL to minified contents, when false the url path will
651
  * be returned for further use (such as writing rewrite rules)
652
  */
653
- function get_fly_min_path($need_host = false, $from_cache_dir = false)
654
  {
655
  // blog path needs to be removed from the fly min path when shown in
656
  // setting page but needs to be added when used to contruct the fly url
@@ -717,7 +742,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
717
  return $fly_min_path;
718
  }
719
 
720
- function get_fly_min_url()
721
  {
722
  if (!empty($this->fly_min_url))
723
  return $this->fly_min_url;
@@ -725,7 +750,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
725
  return $this->get_fly_min_path(true);
726
  }
727
 
728
- function init_properties()
729
  {
730
  $this->get_base();
731
 
@@ -740,11 +765,6 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
740
  $this->fly_min_path = $this->get_fly_min_path();
741
  $this->fly_min_url = $this->get_fly_min_url();
742
 
743
- // init the detector class, responsible for detecting and logging
744
- // enqueued files
745
- $this->detector = new BWP_Enqueued_Detector($this->options, $this->domain);
746
- $this->detector->set_log(BWP_MINIFY_DETECTOR_LOG);
747
-
748
  // init fetcher class if needed, responsible for serving friendly minify urls
749
  if ('yes' == $this->options['enable_fly_min'])
750
  {
@@ -768,7 +788,23 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
768
  */
769
  private function _add_rewrite_rules($suppress = true)
770
  {
771
- return $this->rewriter->add_rewrite_rules($suppress);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
772
  }
773
 
774
  private function _remove_rewrite_rules()
@@ -814,10 +850,16 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
814
  return false;
815
  }
816
 
 
 
 
 
 
 
817
  return true;
818
  }
819
 
820
- function add_conditional_hooks()
821
  {
822
  // Certain plugins use a single file to show contents, which doesn't
823
  // make use of wp_head and wp_footer action and certain plugins should
@@ -849,7 +891,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
849
  }
850
  }
851
 
852
- function pre_init_hooks()
853
  {
854
  // check and update Minify config file whenever this plugin is updated
855
  add_action('upgrader_process_complete', array($this, 'check_config_file'), 10, 2);
@@ -903,14 +945,43 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
903
  add_action('template_redirect', array($this, 'add_conditional_hooks'), 8);
904
  else
905
  $this->add_conditional_hooks();
 
 
 
 
 
 
 
 
 
 
 
906
  }
907
 
908
- function enqueue_media()
909
  {
910
- if ($this->is_admin_page(BWP_MINIFY_MANAGE))
911
- {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
912
  wp_enqueue_script('bwp-minify', BWP_MINIFY_JS . '/bwp-minify.js',
913
  array('jquery'), false, true);
 
 
 
 
914
  wp_enqueue_style('bwp-minify', BWP_MINIFY_CSS . '/bwp-minify.css');
915
  }
916
  }
@@ -918,10 +989,10 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
918
  /**
919
  * Build the Menus
920
  */
921
- function build_menus()
922
  {
923
  // use fancy dashicons if WP version is 3.8+
924
- $menu_icon = version_compare($this->wp_ver, '3.8.0', '>=')
925
  ? 'dashicons-performance'
926
  : BWP_MINIFY_IMAGES . '/icon_menu.png';
927
 
@@ -965,15 +1036,16 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
965
  *
966
  * Utilizes BWP Option Page Builder (@see BWP_OPTION_PAGE)
967
  */
968
- function build_option_pages()
969
  {
970
  if (!current_user_can(BWP_MINIFY_CAPABILITY))
971
  wp_die(__('You do not have sufficient permissions to access this page.'));
972
 
973
- $page = $_GET['page'];
974
  $active_page = '';
 
975
  $original_options = $this->options;
976
- $bwp_option_page = new BWP_OPTION_PAGE($page, $this->site_options);
977
 
978
  // Get option from the database, general options are used for both
979
  // 'General Options' page and 'Manage enqueued' page
@@ -992,6 +1064,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
992
  'input_custom_buster',
993
  'enable_min_js',
994
  'enable_min_css',
 
995
  'enable_bloginfo',
996
  'enable_css_bubble',
997
  'enable_cache_file_lock',
@@ -1045,6 +1118,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1045
  'checkbox',
1046
  'checkbox',
1047
  'checkbox',
 
1048
  'input',
1049
  'input',
1050
  'select',
@@ -1062,6 +1136,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1062
  __('Minify JS files automatically?', $this->domain),
1063
  __('Minify CSS files automatically?', $this->domain),
1064
  __('Minify <code>bloginfo()</code> stylesheets?', $this->domain),
 
1065
  __('URL path to Minify library (relative to domain root)', $this->domain),
1066
  __('One minify string will contain', $this->domain),
1067
  __('For cache buster, use', $this->domain),
@@ -1078,6 +1153,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1078
  'cb1',
1079
  'cb3',
1080
  'cb2',
 
1081
  'input_minpath',
1082
  'input_maxfiles',
1083
  'select_buster_type',
@@ -1113,12 +1189,13 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1113
  )
1114
  ),
1115
  'checkbox' => array(
1116
- 'cb1' => array(__('you can still use <code>bwp_minify()</code> helper function if you disable this.', $this->domain) => 'enable_min_js'),
1117
- 'cb3' => array(__('you can still use <code>bwp_minify()</code> helper function if you disable this.', $this->domain) => 'enable_min_css'),
1118
- 'cb2' => array(__('enable this for themes that use <code>bloginfo()</code> to print the main stylesheet (i.e. <code>style.css</code>). If you want to minify <code>style.css</code> with the rest of your css files, you must enqueue it.', $this->domain) => 'enable_bloginfo'),
1119
- 'cb4' => array(sprintf(__('move all <code>@import</code> rules in CSS files to the top. More info <a href="%s" target="_blank">here</a>.', $this->domain), $this->get_url('min_css_bubble')) => 'enable_css_bubble'),
1120
- 'cb5' => array(__('disable this if filesystem is NFS.', $this->domain) => 'enable_cache_file_lock'),
1121
- 'cb6' => array(sprintf(__('only enable this when minification does not work as expected. More info <a href="%s" target="_blank">here</a>.', $this->domain), $this->get_url('min_debug')) => 'enable_debug')
 
1122
  ),
1123
  'input' => array(
1124
  'input_minpath' => array(
@@ -1180,6 +1257,17 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1180
  'select_buster_type' => array(
1181
  'input_custom_buster' => 'input'
1182
  )
 
 
 
 
 
 
 
 
 
 
 
1183
  )
1184
  );
1185
 
@@ -1194,6 +1282,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1194
  'input_custom_buster',
1195
  'enable_min_js',
1196
  'enable_min_css',
 
1197
  'enable_bloginfo',
1198
  'enable_css_bubble',
1199
  'enable_cache_file_lock',
@@ -1368,6 +1457,9 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1368
  . '</p>'
1369
  ),
1370
  'post' => array(
 
 
 
1371
  )
1372
  );
1373
 
@@ -1399,8 +1491,8 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1399
  'heading'
1400
  ),
1401
  'item_labels' => array (
1402
- __('Move enqueued JS files to appropriate positions', $this->domain),
1403
- __('Move enqueued CSS files to appropriate positions', $this->domain)
1404
  ),
1405
  'item_names' => array(
1406
  'h1',
@@ -1410,19 +1502,19 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1410
  'h1' => '<em>' . sprintf(
1411
  __('Below you can find a list of enqueued JS files '
1412
  . 'detected by this plugin. Press <strong>select</strong> and '
1413
- . 'then choose an appropriate position for selected JS file. '
1414
  . 'You can also directly type in one script handle (<strong>NOT '
1415
  . 'filename/script src</strong>) per line in the input field if '
1416
- . 'you want. More info <a href="%s#positioning_your_files" target="_blank">here</a>.', $this->domain),
1417
  $this->plugin_url
1418
  ) . '</em>',
1419
  'h2' => '<em>' . sprintf(
1420
  __('Below you can find a list of enqueued CSS files '
1421
  . 'detected by this plugin. Press <strong>select</strong> and '
1422
- . 'then choose an appropriate position for selected CSS file. '
1423
  . 'You can also directly type in one style handle (<strong>NOT '
1424
  . 'filename/style src</strong>) per line in the input field if '
1425
- . 'you want. More info <a href="%s#positioning_your_files" target="_blank">here</a>.', $this->domain),
1426
  $this->plugin_url
1427
  ) . '</em>'
1428
  ),
@@ -1447,8 +1539,8 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1447
  }
1448
 
1449
  $option_formats = array(
1450
- 'input_maxfiles' => 'int',
1451
- 'input_maxage' => 'int',
1452
  'select_time_type' => 'int'
1453
  );
1454
 
@@ -1476,6 +1568,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1476
  {
1477
  if (isset($_POST[$key]))
1478
  {
 
1479
  $bwp_option_page->format_field($key, $option_formats);
1480
  $option = trim(stripslashes($_POST[$key]));
1481
  }
@@ -1518,67 +1611,79 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1518
  $this->add_notice(__('All options have been saved.', $this->domain));
1519
  }
1520
 
1521
- // take care of some custom POST actions when form is submitted
1522
- if ($page == BWP_MINIFY_OPTION_GENERAL && !self::is_normal_admin())
 
1523
  {
1524
- // try to save the Minify config file
1525
- $result = $this->create_minify_config_file();
1526
- if (true === $result)
1527
- {
1528
- // config file was successfully written
1529
- $this->add_notice(sprintf(
1530
- __('Minify config file <code>%s</code> '
1531
- . 'has been updated successfully.', $this->domain),
1532
- $this->min_dir . 'config.php'
1533
- ));
1534
- }
1535
- else if ('config' === $result)
1536
- {
1537
- // config file is missing
1538
- $this->add_error(
1539
- '<strong style="color:red">' . __('Error') . ':</strong> '
1540
- . sprintf(
1541
- __('Minify config file <code>config.php</code> could not be found. '
1542
- . 'The auto-detected directory to look for the config file is <code>%s</code>. '
1543
- . 'Please manually check if that directory actually exists '
1544
- . 'and contains the config file.', $this->domain),
1545
- $this->get_doc_root($this->get_min_path())
1546
- )
1547
- );
1548
- }
1549
- else if ('put' === $result)
1550
- {
1551
- // the write process failed for some reasons
1552
- $this->add_error(sprintf(
1553
- '<strong style="color:red">' . __('Error') . ':</strong> '
1554
- . __('There was an error writing to Minify config file <code>%s</code>. '
1555
- . 'Please try again.', $this->domain),
1556
- $this->min_dir . 'config.php'
1557
- ));
1558
  }
1559
- else
 
1560
  {
1561
- // config file is not writable, show the auto-generated
1562
- // contents to admin for manual update
1563
- $this->add_notice(sprintf(
1564
- '<strong>' . __('Notice', $this->domain) . ':</strong> '
1565
- . __('Minify config file <code>%s</code> '
1566
- . 'is not writable. See '
1567
- . '<a href="#minify.config.php">below</a> '
1568
- . 'for details.', $this->domain),
1569
- $this->min_dir . 'config.php'
1570
- ));
1571
- $form['container']['h2'] = $this->_show_generated_config($result);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1572
  }
1573
  }
1574
  else if ($page == BWP_MINIFY_OPTION_ADVANCED)
1575
  {
 
 
 
1576
  if ('yes' != $original_options['enable_fly_min']
1577
  && 'yes' == $this->options['enable_fly_min']
1578
  ) {
1579
- // friendly minify url is turned on, add rewrite rules to
1580
- // server directory config file (e.g. `.htaccess`). This should
1581
- // not require WordPress's pretty permalink to be turned on
1582
  $this->_toggle_rewrite_rules($options, $form);
1583
  } else if ('yes' == $original_options['enable_fly_min']
1584
  && 'yes' != $this->options['enable_fly_min']
@@ -1626,26 +1731,22 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1626
  )
1627
  );
1628
  }
1629
-
1630
- // Remove all Minify library-related settings if we're in multisite
1631
- // and this is not super-admin
1632
- if (self::is_normal_admin())
1633
- $bwp_option_page->kill_html_fields($form, array(7,8,9,10,11,12,13));
1634
  }
1635
  else if ($page == BWP_MINIFY_OPTION_ADVANCED)
1636
  {
1637
- // Remove all super admin only settings if we're in multisite
1638
- // and this is not super-admin, also remove nginx config path if
1639
- // not on nginx server
1640
- if (self::is_normal_admin())
1641
- $bwp_option_page->kill_html_fields($form, array(2));
1642
  if (!self::is_nginx() || self::is_normal_admin())
1643
- $bwp_option_page->kill_html_fields($form, array(3));
 
 
 
 
 
1644
  }
1645
 
1646
- // check for rewrite rules if needed, suppress error
1647
- if ('yes' == $this->options['enable_fly_min'])
1648
- $this->_add_rewrite_rules();
1649
 
1650
  // Assign the form and option array
1651
  $bwp_option_page->init($form, $options, $this->form_tabs);
@@ -1657,9 +1758,9 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1657
  private function _show_enqueued_styles()
1658
  {
1659
  $fields = array(
1660
- 'input_style_ignore' => __('Styles to be ignored (not minified)', $this->domain),
1661
- 'input_style_direct' => __('Styles to be minified and then printed separately', $this->domain),
1662
- 'input_style_oblivion' => __('Styles to be forgotten (to remove duplicate styles)', $this->domain)
1663
  );
1664
 
1665
  return $this->_show_enqueued('style', $fields);
@@ -1668,11 +1769,11 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1668
  private function _show_enqueued_scripts()
1669
  {
1670
  $fields = array(
1671
- 'input_ignore' => __('Scripts to be ignored (not minified)', $this->domain),
1672
- 'input_direct' => __('Scripts to be minified and then printed separately', $this->domain),
1673
- 'input_header' => __('Scripts to be minified in header', $this->domain),
1674
- 'input_footer' => __('Scripts to be minified in footer', $this->domain),
1675
- 'input_oblivion' => __('Scripts to be forgotten (to remove duplicate scripts)', $this->domain)
1676
  );
1677
 
1678
  return $this->_show_enqueued('script', $fields);
@@ -1705,7 +1806,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1705
  : $this->options[$field];
1706
  ?>
1707
  <li>
1708
- <a class="position-handle" data-position="<?php echo $field; ?>"
1709
  href="#"><span class="bwp-sign">+</span> <?php echo $label ?></a>
1710
  <textarea name="<?php echo $field ?>"
1711
  cols="20" rows="5"><?php esc_html_e($value); ?></textarea>
@@ -1836,6 +1937,73 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1836
  }
1837
  }
1838
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1839
  /**
1840
  * Writes rewrite rules to server config file when needed
1841
  *
@@ -1845,25 +2013,27 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1845
  * @since 1.3.0
1846
  * @return void
1847
  */
1848
- private function _toggle_rewrite_rules(&$options, &$form)
1849
  {
1850
- // add rewrite rules to WP root, used by all servers
1851
- $form['container']['h1'] = array();
1852
  $this->rewriter->no_suppress();
 
 
1853
  $result = $this->rewriter->add_wp_rewrite_rules();
1854
 
 
1855
  if (true !== $result && 'written' !== $result)
1856
  {
1857
- // get appropriate error messages and show it to admin
1858
  $config_file = $this->rewriter->get_wp_config_file();
1859
  $error = $this->_get_rewrite_rules_error($result, $config_file);
 
1860
  $this->add_error($error);
1861
- $form['container']['h1'][] = $this->_show_generated_wp_rewrite_rules();
1862
  }
1863
 
 
1864
  if (false == self::is_nginx())
1865
  {
1866
- // asumming apache, need to add rules to cache directory too
1867
  $result = $this->rewriter->add_cache_rewrite_rules();
1868
  $config_file = $this->rewriter->get_cache_config_file();
1869
 
@@ -1886,7 +2056,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1886
  . 'automatically to prevent your site from breaking. ', $this->domain)
1887
  );
1888
 
1889
- $form['container']['h1'][] = $this->_show_generated_cache_rewrite_rules();
1890
  }
1891
  else if (true === $result)
1892
  {
@@ -1903,7 +2073,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1903
  $output = '<strong>'
1904
  . __('Could not write Minify library settings to <code>%s</code>. '
1905
  . 'Please update the config file manually by <em>replacing</em> its current contents '
1906
- . 'with auto-generated contents as shown below:', $this->domain)
1907
  . '</strong>';
1908
  $output = sprintf($output, $this->min_dir . 'config.php');
1909
  $output .= '<br /><br />';
@@ -1915,55 +2085,57 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
1915
 
1916
  private function _show_generated_wp_rewrite_rules()
1917
  {
1918
- if (self::is_nginx())
1919
- {
1920
- // nginx server only needs rewrite rules in a central config file
1921
- $rules = $this->rewriter->get_generated_wp_rewrite_rules();
1922
- $output = '<strong>' . __('Please update the Nginx config file '
1923
- . 'manually using auto-generated contents as shown below. '
1924
- . 'It is highly recommended that you create a separate config file '
1925
- . 'for BWP Minify (e.g. <code>bwp-minify.conf</code>) and include it '
1926
- . 'directly above where you include your cache plugins\' config files, '
1927
- . 'as shown <a href="%s" target="_blank">here</a>. ', $this->domain) . '</strong>';
1928
- $output = sprintf($output, $this->get_url('wp_codex_nginx_rewrite_rules'));
1929
- }
1930
- else
1931
- {
1932
- // Apache server needs rewrite rules for root WP rewrite rules when
1933
- // sub-directory multisite is set up
1934
- $rules = $this->rewriter->get_generated_wp_rewrite_rules();
1935
- $output = '<strong>' . __('Please update the server config file <code>%s</code> '
1936
- . 'manually using auto-generated contents as shown below. '
1937
- . 'It is highly recommended that you paste the contents '
1938
- . 'at the top of the server config file. '
1939
- . 'If config file does not exist, you must first create it.', $this->domain) . '</strong>';
1940
- $output = sprintf($output, $this->rewriter->get_wp_config_file());
1941
- }
1942
-
1943
- $output .= '<br /><br />';
1944
- $output .= '<textarea class="code" rows="8" cols="90" readonly="readonly">'
1945
- . $rules . '</textarea>';
1946
-
1947
- return $output;
1948
  }
1949
 
1950
  private function _show_generated_cache_rewrite_rules()
1951
  {
1952
- $rules = $this->rewriter->get_generated_cache_rewrite_rules();
1953
- $output = '<strong>'
1954
- . __('Please update the cache directory config file <code>%s</code> '
1955
- . 'manually using auto-generated contents as shown below. '
1956
- . 'It is highly recommended that you paste the contents '
1957
- . 'at the top of the server config file. '
1958
- . 'If config file does not exist, you must first create it.', $this->domain)
1959
- . '</strong>';
1960
- $output = sprintf($output, $this->rewriter->get_cache_config_file());
1961
 
1962
- $output .= '<br /><br />';
1963
- $output .= '<textarea class="code" rows="8" cols="90" readonly="readonly">'
1964
- . $rules . '</textarea>';
 
 
 
 
1965
 
1966
- return $output;
 
 
 
 
 
 
1967
  }
1968
 
1969
  private function _get_rewrite_rules_error($result, $config_file)
@@ -2168,7 +2340,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2168
  $result = $this->create_minify_config_file();
2169
 
2170
  // if friendly minify url is enabled, add rewrite rules to server
2171
- // config file if needed, suppress any error message
2172
  if ('yes' == $this->options['enable_fly_min'])
2173
  $this->_add_rewrite_rules();
2174
  }
@@ -2281,7 +2453,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2281
  break;
2282
 
2283
  case 'wpver':
2284
- $buster = $this->wp_ver;
2285
  break;
2286
 
2287
  case 'tver':
@@ -2318,11 +2490,12 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2318
  }
2319
 
2320
  /**
2321
- * Checks whether the media files have been included in Minify string or not
2322
  *
2323
  * @return bool
 
2324
  */
2325
- function is_in($handle, $position = 'header')
2326
  {
2327
  if (!isset($this->print_positions[$position])
2328
  || !is_array($this->print_positions[$position])
@@ -2334,6 +2507,28 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2334
  return true;
2335
  }
2336
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2337
  /**
2338
  * Checks if a style has inline styles to print
2339
  *
@@ -2567,7 +2762,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2567
  return $src;
2568
  }
2569
 
2570
- function init_todo_item($handle, $type = 'script')
2571
  {
2572
  global $wp_scripts, $wp_styles;
2573
 
@@ -2581,7 +2776,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2581
  $src = trim($item->src);
2582
 
2583
  $todo_item = array(
2584
- 'position' => 'dummy', // 'dummy', 'header', 'footer', or 'footer{n}'
2585
  'min' => true, // expect to be minified
2586
  'wp' => false, // expect to be handled by WP
2587
  'forget' => false, // put into oblivion or not
@@ -2591,43 +2786,141 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2591
 
2592
  // look for dependencies of this item
2593
  $deps = $item->deps;
2594
- if ($deps && is_array($deps) && 0 < sizeof($deps)) {
2595
  $todo_item['depend'] = $deps;
2596
- }
2597
 
2598
  if (empty($src))
2599
  return $todo_item;
2600
 
2601
- if ($this->is_in($handle, $prefix . 'oblivion'))
2602
  {
2603
- // this item is put into oblivion (forget)
2604
  $todo_item['min'] = false;
2605
- $todo_item['forget'] = true;
2606
- $todo_item['position'] = 'oblivion';
2607
- $todo_item['src'] = $src;
 
 
 
 
 
 
 
 
 
 
 
 
2608
  }
2609
- else if (('all' != $this->print_positions[$prefix . 'allowed']
2610
- && !$this->is_in($handle, $prefix . 'allowed'))
2611
- || !$this->is_source_static($src) || !$this->is_local($src)
 
 
2612
  ) {
2613
- // If this item is specifically disallowed to be minified
2614
- // OR if this item is dynamic or external, no minify
2615
  $todo_item['min'] = false;
2616
  }
2617
- else if ($this->is_in($handle, $prefix . 'ignore')
2618
- || $this->is_in($handle, $prefix . 'direct')
2619
- ) {
2620
- // if this item belongs to 'ignore', no minify is needed
2621
- if ($this->is_in($handle, $prefix . 'ignore'))
2622
- $todo_item['min'] = false;
2623
 
2624
- // let WordPress handle the output
2625
- $todo_item['wp'] = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2626
  }
2627
 
2628
  return $todo_item;
2629
  }
2630
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2631
  /**
2632
  * Checks if a group is a dependency of some groups
2633
  *
@@ -2682,8 +2975,8 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2682
  *
2683
  * A group can be one of the following types:
2684
  * 1. A Minify group: files are minified and combined, printed together
2685
- * 2. A WP Minify group: files are minified but separately printed
2686
- * 3. A WP group: files are NOT minified and separately printed
2687
  *
2688
  * Apply to a Minify group: If the number of files per group reaches a
2689
  * limit (by default the limit is 10) this plugin will split the minify
@@ -2709,6 +3002,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2709
  // current item's group
2710
  $group_deps[$item['group']] = 1;
2711
  }
 
2712
  continue;
2713
  }
2714
 
@@ -2746,6 +3040,60 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2746
  return $group_deps;
2747
  }
2748
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2749
  /**
2750
  * Builds a list of internal $todo_styles from WP's $todo
2751
  *
@@ -2758,24 +3106,26 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2758
  // @since 1.3.0 add 'dashicons' to default ignore list
2759
  $this->print_positions['style_allowed'] = apply_filters('bwp_minify_allowed_styles', 'all');
2760
 
 
 
 
 
2761
  foreach ($todo as $handle)
2762
  {
2763
- $style = $wp_styles->registered[$handle];
2764
- $todo_style = $this->init_todo_item($handle, 'style');
2765
 
2766
  if (empty($style->src))
2767
  {
2768
  if ($todo_styles['depend'])
2769
- {
2770
  $this->todo_styles[$handle] = $todo_style;
2771
- $wp_styles->done[] = $handle;
2772
- }
2773
  continue;
2774
  }
2775
 
2776
  $todo_style['media'] = 'all'; // can be 'all', 'print', etc.
2777
- $todo_style['if'] = '';
2778
- $todo_style['alt'] = '';
2779
 
2780
  // if this style has different media type, set it
2781
  if (!empty($style->args) && 'all' != $style->args)
@@ -2807,7 +3157,9 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2807
  $suffix = isset($style->extra['suffix'])
2808
  ? $style->extra['suffix']
2809
  : '';
 
2810
  $rtl_src = str_replace("{$suffix}.css", "-rtl{$suffix}.css", $style->src);
 
2811
  $todo_style['src'] = $rtl_src;
2812
  }
2813
  else
@@ -2815,24 +3167,19 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2815
  // add a new todo_rtl as a clone of current todo_style and
2816
  // make todo_style its dependency
2817
  $rtl_src = trim($style->extra['rtl']);
2818
- $todo_rtl = $todo_style;
2819
- $todo_rtl['src'] = $rtl_src;
 
2820
  $todo_rtl['depend'] = array($handle);
2821
- $todo_rtl['min'] = $this->is_source_static($rtl_src) && $this->is_local($rtl_src);
2822
  }
2823
  }
2824
 
2825
- if (true === $todo_style['forget'])
2826
  {
2827
- // this style is forgotten, we don't process it, and tell
2828
- // WordPress to forget it as well. We also need to detect this
2829
- // style as forgotten, the same goes for script
2830
- do_action('bwp_minify_processed_style', $handle, $todo_style);
2831
- $wp_styles->done[] = $handle;
2832
- continue;
2833
  }
2834
-
2835
- if (did_action('bwp_minify_after_header_styles'))
2836
  {
2837
  // if this style is registered after the styles are printed, it is
2838
  // expected in footer
@@ -2854,8 +3201,6 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2854
  $this->todo_styles[$handle . '_rtl'] = $todo_rtl;
2855
  $todo_rtl = false;
2856
  }
2857
-
2858
- $wp_styles->done[] = $handle;
2859
  }
2860
 
2861
  // start minifying
@@ -2869,8 +3214,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2869
  $this->late_style_order++;
2870
  }
2871
 
2872
- // no more $todo for WordPress because we have done it all
2873
- return array();
2874
  }
2875
 
2876
  /**
@@ -2890,15 +3234,13 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2890
  global $wp_styles;
2891
 
2892
  $style = $wp_styles->registered[$handle];
2893
- $src = !empty($item['src']) ? $item['src'] : $style->src;
2894
 
2895
  if ($item['min'])
2896
  {
2897
  // minify is needed
2898
  $src = $this->process_media_source($src);
2899
 
2900
- // if WordPress handles this item make sure the $src is
2901
- // processed and version is not set
2902
  if ($item['wp'])
2903
  {
2904
  // because WordPress needs original $src, we process the
@@ -2907,18 +3249,21 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2907
  $this->process_media_source($style->src),
2908
  $group_handle
2909
  );
 
2910
  $style->ver = NULL;
2911
- // add a new group to hold this item
2912
  $this->min_styles[$group_handle] = array(
2913
- 'depend' => $group_deps,
2914
- 'handle' => $handle,
2915
  'position' => $item['position']
2916
  );
 
2917
  $item['group'] = $group_handle;
2918
  }
2919
  else
2920
  {
2921
  $group_handle = false;
 
2922
  foreach ($this->min_styles as $_group_handle => $_group)
2923
  {
2924
  // pick the first available group that is:
@@ -2926,7 +3271,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2926
  // 2. has the same media type
2927
  // 3. same conditional type, if is a condiional style
2928
  // 4. same alternate title, if is an alternate style
2929
- // 5. still has room for more scripts
2930
  // but do not take into account group that is
2931
  // dependency of this item's own dependencies.
2932
  if (isset($_group['string']) && $_group['position'] == $item['position']
@@ -2934,8 +3279,9 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2934
  && !$this->is_a_dependency($_group_handle, $group_deps, 'style')
2935
  ) {
2936
  $is_same_media = $_group['media'] == $item['media'];
2937
- $is_same_if = $_group['if'] == $item['if'];
2938
- $is_same_alt = $_group['alt'] == $item['alt'];
 
2939
  if ($is_same_media && $is_same_if && $is_same_alt)
2940
  {
2941
  $group_handle = $_group_handle;
@@ -2949,6 +3295,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2949
  // append to selected group's minify string, only if
2950
  // this $src has not been added before
2951
  $group = &$this->min_styles[$group_handle];
 
2952
  if (!in_array($src, $group['string']))
2953
  {
2954
  $group['string'][] = $src;
@@ -2961,21 +3308,23 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2961
  // merge this item's dependencies with the selected
2962
  // group's deps.
2963
  $group['depend'] = array_merge($group['depend'], $group_deps);
2964
- $item['group'] = $group_handle;
2965
  }
2966
  }
2967
  else
2968
  {
2969
  // otherwise make a new group
2970
  $group_handle = $this->_sanitize_handle($handle);
 
2971
  $this->min_styles[$group_handle] = array(
2972
- 'depend' => $group_deps,
2973
- 'string' => array($src),
2974
  'position' => $item['position'],
2975
- 'media' => $item['media'],
2976
- 'alt' => $item['alt'],
2977
- 'if' => $item['if']
2978
  );
 
2979
  $item['group'] = $group_handle;
2980
  }
2981
  }
@@ -2984,19 +3333,27 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
2984
  {
2985
  // no minify is needed, add new group to hold this item
2986
  $this->min_styles[$group_handle] = array(
2987
- 'depend' => $group_deps,
2988
- 'handle' => $handle,
2989
  'position' => $item['position']
2990
  );
 
2991
  $item['group'] = $group_handle;
2992
  }
2993
 
2994
- // if this item has inline styles, mark it to process later
2995
- if (self::has_inline($handle))
 
 
 
 
 
2996
  $this->todo_inline_styles[$group_handle][] = $handle;
 
2997
 
2998
- // update the internal _Todo_ list
2999
  $item['src'] = $src;
 
 
3000
  $this->todo_styles[$handle] = $item;
3001
 
3002
  do_action('bwp_minify_processed_style', $handle, $item);
@@ -3020,7 +3377,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3020
  if (!$recursive)
3021
  do_action('bwp_minify_before_' . $position . '_styles');
3022
 
3023
- $groups = !$groups ? $this->min_styles : $groups;
3024
  $group_position = $position;
3025
 
3026
  foreach ($groups as $group_handle => $group)
@@ -3029,14 +3386,24 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3029
  if (!empty($this->min_styles[$group_handle]['done']))
3030
  continue;
3031
 
 
 
 
 
 
 
 
 
3032
  // if this is not the correct position for the group, halt the
3033
  // entire loop but return the correct position so the offending group
3034
  // can update itself
3035
  if ($group['position'] != $position)
 
3036
  if ($recursive)
3037
  return $group['position'];
3038
  else
3039
  continue;
 
3040
 
3041
  // print dependencies first
3042
  $deps = array();
@@ -3047,6 +3414,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3047
  if (isset($this->min_styles[$dep]))
3048
  $deps[$dep] = $this->min_styles[$dep];
3049
  }
 
3050
  $group_position = $this->print_styles($position, $deps, true);
3051
  }
3052
 
@@ -3059,7 +3427,9 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3059
  $group_handle,
3060
  $group_position
3061
  );
 
3062
  $this->min_styles[$group_handle]['position'] = $group_position;
 
3063
  continue;
3064
  }
3065
 
@@ -3067,13 +3437,14 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3067
  {
3068
  // if this is a minify string
3069
  echo $this->get_minify_tag('style', $group, $group_handle);
 
3070
  // print inline style after if this group has any
3071
  if (isset($this->todo_inline_styles[$group_handle]))
3072
  $this->print_inline_styles($this->todo_inline_styles[$group_handle]);
3073
  }
3074
  else if (!empty($group['handle']))
3075
  {
3076
- // if this should be handled by WordPress
3077
  $wp_styles->do_item($group['handle']);
3078
  }
3079
 
@@ -3083,8 +3454,9 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3083
  if (!$recursive)
3084
  {
3085
  do_action('bwp_minify_after_' . $position . '_styles');
 
3086
  // save detector's log whenever we finish printing a footer{n} batch
3087
- if (false !== strpos($position, 'footer' . $this->late_style_order))
3088
  $this->detector->commit_logs();
3089
  }
3090
 
@@ -3112,7 +3484,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3112
  global $wp_styles;
3113
 
3114
  // this feature is only available on WP 3.3 or higher
3115
- if (version_compare($this->wp_ver, '3.3', '<'))
3116
  return;
3117
 
3118
  foreach ($handles as $handle)
@@ -3159,10 +3531,14 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3159
  // @since 1.0.5 - 1.0.6
3160
  $this->print_positions['allowed'] = apply_filters('bwp_minify_allowed_scripts', 'all');
3161
 
 
 
 
 
3162
  foreach ($todo as $handle)
3163
  {
3164
- $script = $wp_scripts->registered[$handle];
3165
- $todo_script = $this->init_todo_item($handle);
3166
 
3167
  if (empty($script->src))
3168
  {
@@ -3171,12 +3547,13 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3171
  // script's src is empty/invalid but it has dependencies so
3172
  // it's probably a dummy script used to load other scripts
3173
  $this->todo_scripts[$handle] = $todo_script;
3174
- $wp_scripts->done[] = $handle;
3175
  }
 
3176
  continue;
3177
  }
3178
 
3179
- if ('jquery-migrate' == $handle) {
 
3180
  // jquery-migrate and jquery-core might get separated so we
3181
  // force jquery-migrate to have jquery-core as its dependecy
3182
  $todo_script['depend'] = false == $todo_script['depend']
@@ -3184,13 +3561,6 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3184
  $todo_script['depend'][] = 'jquery-core';
3185
  }
3186
 
3187
- if (true === $todo_script['forget'])
3188
- {
3189
- do_action('bwp_minify_processed_script', $handle, $todo_script);
3190
- $wp_scripts->done[] = $handle;
3191
- continue;
3192
- }
3193
-
3194
  // if this script is registered in footer, or it is registered
3195
  // after the header scripts are printed, it is expected in footer
3196
  $expected_in_footer = isset($wp_scripts->groups[$handle])
@@ -3198,9 +3568,11 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3198
  || did_action('bwp_minify_after_header_scripts')
3199
  ? true : false;
3200
 
3201
- // determine the position of the script
3202
- if (!$this->is_in($handle, 'header')
3203
- && ($this->is_in($handle, 'footer') || $expected_in_footer)
 
 
3204
  ) {
3205
  // if this script belongs to footer (logically or
3206
  // 'intentionally') and is not 'forced' to be in header
@@ -3215,7 +3587,6 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3215
  }
3216
 
3217
  $this->todo_scripts[$handle] = $todo_script;
3218
- $wp_scripts->done[] = $handle;
3219
  }
3220
 
3221
  // start minifying
@@ -3229,8 +3600,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3229
  $this->late_script_order++;
3230
  }
3231
 
3232
- // no more $todo for WordPress because we have done it all
3233
- return array();
3234
  }
3235
 
3236
  /**
@@ -3250,7 +3620,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3250
  global $wp_scripts;
3251
 
3252
  $script = $wp_scripts->registered[$handle];
3253
- $src = $script->src;
3254
 
3255
  if ($item['min'])
3256
  {
@@ -3263,17 +3633,20 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3263
  // processed and version is not set
3264
  $script->src = $this->get_minify_src($src, $group_handle);
3265
  $script->ver = NULL;
 
3266
  // add a new group to hold this item
3267
  $this->min_scripts[$group_handle] = array(
3268
- 'depend' => $group_deps,
3269
- 'handle' => $handle,
3270
  'position' => $item['position']
3271
  );
 
3272
  $item['group'] = $group_handle;
3273
  }
3274
  else
3275
  {
3276
  $group_handle = false;
 
3277
  foreach ($this->min_scripts as $_group_handle => $_group)
3278
  {
3279
  // pick the first available group in the same position
@@ -3306,18 +3679,20 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3306
  // merge this item's dependencies with the selected
3307
  // group's deps.
3308
  $group['depend'] = array_merge($group['depend'], $group_deps);
3309
- $item['group'] = $group_handle;
3310
  }
3311
  }
3312
  else
3313
  {
3314
  // otherwise make a new group
3315
  $group_handle = $this->_sanitize_handle($handle);
 
3316
  $this->min_scripts[$group_handle] = array(
3317
- 'depend' => $group_deps,
3318
- 'string' => array($src),
3319
  'position' => $item['position']
3320
  );
 
3321
  $item['group'] = $group_handle;
3322
  }
3323
  }
@@ -3326,19 +3701,25 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3326
  {
3327
  // no minify is needed, add new group to hold this item
3328
  $this->min_scripts[$group_handle] = array(
3329
- 'depend' => $group_deps,
3330
- 'handle' => $handle,
3331
  'position' => $item['position']
3332
  );
 
3333
  $item['group'] = $group_handle;
3334
  }
3335
 
3336
- // if this item has l10n data, mark it to process later
3337
- if (self::is_l10n($handle))
 
 
 
 
3338
  $this->todo_l10n[$group_handle][] = $handle;
3339
 
3340
- // update the internal _Todo_ list
3341
  $item['src'] = $src;
 
 
3342
  $this->todo_scripts[$handle] = $item;
3343
 
3344
  do_action('bwp_minify_processed_script', $handle, $item);
@@ -3362,7 +3743,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3362
  if (!$recursive)
3363
  do_action('bwp_minify_before_' . $position . '_scripts');
3364
 
3365
- $groups = !$groups ? $this->min_scripts : $groups;
3366
  $group_position = $position;
3367
 
3368
  foreach ($groups as $group_handle => $group)
@@ -3371,12 +3752,22 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3371
  if (!empty($this->min_scripts[$group_handle]['done']))
3372
  continue;
3373
 
 
 
 
 
 
 
 
 
3374
  // if this is not the correct position for the group
3375
  if ($group['position'] != $position)
 
3376
  if ($recursive)
3377
  return $group['position'];
3378
  else
3379
  continue;
 
3380
 
3381
  // print dependencies first
3382
  $deps = array();
@@ -3387,6 +3778,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3387
  if (isset($this->min_scripts[$dep]))
3388
  $deps[$dep] = $this->min_scripts[$dep];
3389
  }
 
3390
  $group_position = $this->print_scripts($position, $deps, true);
3391
  }
3392
 
@@ -3398,22 +3790,25 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3398
  $group_handle,
3399
  $group_position
3400
  );
 
3401
  $this->min_scripts[$group_handle]['position'] = $group_position;
 
3402
  continue;
3403
  }
3404
 
3405
- // print this group using minify tag or $wp_scripts->do_item
3406
  if (isset($group['string']) && 0 < sizeof($group['string']))
3407
  {
3408
  // print l10n data first if this group has any
3409
  if (isset($this->todo_l10n[$group_handle]))
3410
  $this->print_scripts_l10n($this->todo_l10n[$group_handle]);
 
3411
  // if this is a minify string
3412
  echo $this->get_minify_tag('script', $group, $group_handle);
3413
  }
3414
  else if (!empty($group['handle']))
3415
  {
3416
- // if this should be handled by WordPress
3417
  $wp_scripts->do_item($group['handle']);
3418
  }
3419
 
@@ -3423,6 +3818,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3423
  if (!$recursive)
3424
  {
3425
  do_action('bwp_minify_after_' . $position . '_scripts');
 
3426
  // save detector's log whenever we finish printing a footer batch
3427
  if (false !== strpos($position, 'footer'))
3428
  $this->detector->commit_logs();
@@ -3455,7 +3851,7 @@ class BWP_MINIFY extends BWP_FRAMEWORK_IMPROVED
3455
  {
3456
  // since WordPress version 3.3: uses
3457
  // $wp_scripts->print_extra_script instead to print l10n info
3458
- if (version_compare($this->wp_ver, '3.3', '>='))
3459
  $wp_scripts->print_extra_script($handle);
3460
  else
3461
  $wp_scripts->print_scripts_l10n($handle);
72
  /**
73
  * Other options
74
  */
75
+ var $wp_version = '', $base = '', $remove_from_base = '', $buster = '', $cache_age = 86400;
76
  var $min_url = '', $min_dir = '', $min_path = '', $min_cache_dir = '';
77
  var $fly_min_path = '', $fly_min_url = '';
78
  var $doc_root = '', $blog_path = false;
138
  * @since 1.3.0
139
  * @var BWP_Minify_AbstractRewriter
140
  */
141
+ var $rewriter, $rewriter_apache, $rewriter_nginx;
142
 
143
  /**
144
  * Constructor
145
  */
146
+ function __construct($version = '1.3.3')
147
  {
148
  // Plugin's title
149
  $this->plugin_title = 'Better WordPress Minify';
150
  // Plugin's version
151
  $this->set_version($version);
152
+ $this->set_version('3.1', 'wp');
153
  $this->set_version('5.1.6', 'php');
154
  // Plugin's language domain
155
  $this->domain = 'bwp-minify';
183
  'enable_min_js' => 'yes',
184
  'enable_min_css' => 'yes',
185
  'enable_bloginfo' => '',
186
+ 'enable_external_origin' => '', // @since 1.3.1
187
  'enable_css_bubble' => 'yes', // @since 1.3.0 super admin, Minify
188
  'enable_cache_file_lock' => 'yes', // @since 1.3.0 super admin, Minify
189
  'enable_debug' => '', // @since 1.3.0 super admin
190
  'enable_fly_min' => '', // @since 1.3.0
191
+ 'enable_fly_min_nag' => '', // @since 1.3.2
192
  'enable_cdn' => '', // @since 1.3.0
193
  'select_buster_type' => 'none',
194
  'select_time_type' => 86400, // super admin, Minify
229
  );
230
  }
231
 
232
+ public function install()
233
  {
234
  // if friendly minify url is enabled we need to flush rewrite rules
235
  if ('yes' == $this->options['enable_fly_min'])
236
  $this->_add_rewrite_rules();
237
  }
238
 
239
+ public function uninstall()
240
  {
241
  $this->_remove_rewrite_rules();
242
  }
243
 
244
+ public function upgrade_plugin($from, $to)
245
  {
246
+ if (version_compare($from, '1.3.0', '<'))
247
  {
248
  // @since 1.3.0 default values of min path and cache dir is empty,
249
  // also look for 'Better-WordPress-Minify-1.3.0' string for users
253
  $this->_reset_cache_dir($options);
254
  update_option(BWP_MINIFY_OPTION_GENERAL, $options);
255
  }
256
+
257
+ if (version_compare($from, '1.3.1', '<'))
258
+ {
259
+ $this->detector->clear_logs('enqueue');
260
+ }
261
  }
262
 
263
  protected function pre_init_properties()
264
  {
265
  $this->parse_positions();
266
 
267
+ $this->wp_version = get_bloginfo('version');
268
 
269
  // define a few urls that are used throughout the plugin
270
  $this->add_url('min_debug',
302
  {
303
  // load and init appropriate rewriter class based on server type
304
  require_once dirname(__FILE__) . '/rewriter/rewriter.php';
305
+ require_once dirname(__FILE__) . '/rewriter/nginx.php';
306
+ require_once dirname(__FILE__) . '/rewriter/apache.php';
307
+
308
+ // @since 1.3.2 we initiate both rewriter classes to support special
309
+ // setups such as nginx is used as a reverse proxy for apache
310
+ $this->rewriter_apache = new BWP_Minify_Rewriter_Apache($this);
311
+ $this->rewriter_nginx = new BWP_Minify_Rewriter_Nginx($this);
312
+
313
+ // assume apache if not nginx
314
+ $this->rewriter = self::is_nginx() ? $this->rewriter_nginx : $this->rewriter_apache;
 
315
  }
316
 
317
  protected function load_libraries()
322
  require_once dirname(__FILE__) . '/class-bwp-minify-cdn.php';
323
 
324
  $this->_load_rewriter_class();
325
+
326
+ // init the detector class, responsible for detecting and logging
327
+ // enqueued files
328
+ $this->detector = new BWP_Enqueued_Detector($this->options, $this->domain);
329
+ $this->detector->set_log(BWP_MINIFY_DETECTOR_LOG);
330
  }
331
 
332
  private function _reset_min_path(&$options = false)
416
  : $http_host;
417
  }
418
 
419
+ // @since 1.3.1 ensure that we use consistent protocol
420
+ if (is_ssl() && 0 !== strpos('https', $http_host))
421
+ {
422
+ // if SSL is on and our detected http host is still using `http`
423
+ // protocol, replace it with the `https` protocol
424
+ $http_host = str_replace('http://', 'https://', $http_host);
425
+ }
426
+
427
  return $http_host;
428
  }
429
 
485
  * @since 1.3.0
486
  * @return string
487
  */
488
+ public function get_min_path()
489
  {
490
  $min_path = empty($this->options['input_minpath'])
491
  ? $this->get_default_min_path()
507
  * @since 1.3.0
508
  * @return string
509
  */
510
+ public function get_default_min_dir()
511
  {
512
  $plugin_wp_dir = trailingslashit(plugin_dir_path($this->plugin_file));
513
  return $plugin_wp_dir . 'min/';
519
  * @since 1.3.0
520
  * @return string|bool false if no directory can be found
521
  */
522
+ public function get_min_dir()
523
  {
524
  if (!empty($this->min_dir))
525
  return $this->min_dir;
582
  }
583
  }
584
 
585
+ public function get_wp_doc_root()
586
  {
587
  $wp_doc_root = !empty($_SERVER['SCRIPT_FILENAME'])
588
  && $_SERVER['SCRIPT_FILENAME'] != $_SERVER['PHP_SELF']
589
  ? dirname(str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']))
590
  : ABSPATH;
591
 
592
+ // doc root might contain 'network' if on multisite, remove it
593
+ $wp_doc_root = is_network_admin() ? str_replace('/network', '', $wp_doc_root) : $wp_doc_root;
594
+
595
+ // doc root might contain `wp-admin` when in admin, remove it
596
+ $wp_doc_root = is_admin() ? str_replace('/wp-admin', '', $wp_doc_root) : $wp_doc_root;
597
+
598
+ return $wp_doc_root;
599
  }
600
 
601
  /**
604
  * @since 1.3.0
605
  * @return string
606
  */
607
+ public function get_doc_root($path = '')
608
  {
609
  $server_doc_root = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
610
  $wp_doc_root = $this->get_wp_doc_root();
627
  * @since 1.3.0
628
  * @return string
629
  */
630
+ public function get_default_cache_dir()
631
  {
632
  $plugin_wp_dir = plugin_dir_path($this->plugin_file);
633
  $cache_dir = trailingslashit($plugin_wp_dir) . 'cache/';
642
  * The default cache directory is `/min/cache/` which can be changed inside
643
  * admin area if `/min/config.php` file is writable (@since 1.3.0).
644
  */
645
+ public function get_cache_dir()
646
  {
647
  // return the cache dir as entered by admin
648
  // or if cache dir is empty, get cache directory from plugin
675
  * qualify URL to minified contents, when false the url path will
676
  * be returned for further use (such as writing rewrite rules)
677
  */
678
+ public function get_fly_min_path($need_host = false, $from_cache_dir = false)
679
  {
680
  // blog path needs to be removed from the fly min path when shown in
681
  // setting page but needs to be added when used to contruct the fly url
742
  return $fly_min_path;
743
  }
744
 
745
+ public function get_fly_min_url()
746
  {
747
  if (!empty($this->fly_min_url))
748
  return $this->fly_min_url;
750
  return $this->get_fly_min_path(true);
751
  }
752
 
753
+ public function init_properties()
754
  {
755
  $this->get_base();
756
 
765
  $this->fly_min_path = $this->get_fly_min_path();
766
  $this->fly_min_url = $this->get_fly_min_url();
767
 
 
 
 
 
 
768
  // init fetcher class if needed, responsible for serving friendly minify urls
769
  if ('yes' == $this->options['enable_fly_min'])
770
  {
788
  */
789
  private function _add_rewrite_rules($suppress = true)
790
  {
791
+ $result = $this->rewriter->add_rewrite_rules($suppress);
792
+
793
+ // failed to add rewrite rules, and required rewrite rules are not
794
+ // there yet, and errors are suppressed
795
+ if ($suppress && $result !== true && $result !== 'written')
796
+ {
797
+ // turn off friendly minify url feature and set a nag to notify
798
+ // owner in next refresh
799
+ $options = get_option(BWP_MINIFY_OPTION_ADVANCED);
800
+
801
+ $options['enable_fly_min'] = '';
802
+ $options['enable_fly_min_nag'] = 'yes';
803
+
804
+ update_option(BWP_MINIFY_OPTION_ADVANCED, $options);
805
+ }
806
+
807
+ return $result;
808
  }
809
 
810
  private function _remove_rewrite_rules()
850
  return false;
851
  }
852
 
853
+ // @since 1.3.1 ignore Maintenance plugin
854
+ if (bwp_is_maintenance_on())
855
+ {
856
+ return false;
857
+ }
858
+
859
  return true;
860
  }
861
 
862
+ public function add_conditional_hooks()
863
  {
864
  // Certain plugins use a single file to show contents, which doesn't
865
  // make use of wp_head and wp_footer action and certain plugins should
891
  }
892
  }
893
 
894
+ public function pre_init_hooks()
895
  {
896
  // check and update Minify config file whenever this plugin is updated
897
  add_action('upgrader_process_complete', array($this, 'check_config_file'), 10, 2);
945
  add_action('template_redirect', array($this, 'add_conditional_hooks'), 8);
946
  else
947
  $this->add_conditional_hooks();
948
+
949
+ // if some errors are needed to be shown, show it now
950
+ if ($this->options['enable_fly_min_nag'] == 'yes')
951
+ {
952
+ add_action('admin_notices', array($this, 'show_fly_min_errors'));
953
+ add_action('network_admin_notices', array($this, 'show_fly_min_errors'));
954
+
955
+ $options = get_option(BWP_MINIFY_OPTION_ADVANCED);
956
+ $options['enable_fly_min_nag'] = '';
957
+ update_option(BWP_MINIFY_OPTION_ADVANCED, $options);
958
+ }
959
  }
960
 
961
+ public function show_fly_min_errors()
962
  {
963
+ echo '<div class="error"><p>' . sprintf(
964
+ __('<strong>Better WordPress Minify</strong> &ndash; '
965
+ . 'Required rewrite rules for friendly minify url '
966
+ . 'feature could not be found and could not be added automatically. '
967
+ . 'Friendly minify url feature has been turned off '
968
+ . 'to prevent your site from breaking. '
969
+ . 'You can turn it on again by navigating to %s.', $this->domain),
970
+ '<em>BWP Minify >> Advanced Options</em>')
971
+ . '</p></div>';
972
+ }
973
+
974
+ public function enqueue_media()
975
+ {
976
+ if ($this->is_admin_page(BWP_MINIFY_OPTION_ADVANCED)
977
+ || $this->is_admin_page(BWP_MINIFY_MANAGE)
978
+ ) {
979
  wp_enqueue_script('bwp-minify', BWP_MINIFY_JS . '/bwp-minify.js',
980
  array('jquery'), false, true);
981
+ }
982
+
983
+ if ($this->is_admin_page(BWP_MINIFY_MANAGE))
984
+ {
985
  wp_enqueue_style('bwp-minify', BWP_MINIFY_CSS . '/bwp-minify.css');
986
  }
987
  }
989
  /**
990
  * Build the Menus
991
  */
992
+ public function build_menus()
993
  {
994
  // use fancy dashicons if WP version is 3.8+
995
+ $menu_icon = version_compare($this->wp_version, '3.8.0', '>=')
996
  ? 'dashicons-performance'
997
  : BWP_MINIFY_IMAGES . '/icon_menu.png';
998
 
1036
  *
1037
  * Utilizes BWP Option Page Builder (@see BWP_OPTION_PAGE)
1038
  */
1039
+ public function build_option_pages()
1040
  {
1041
  if (!current_user_can(BWP_MINIFY_CAPABILITY))
1042
  wp_die(__('You do not have sufficient permissions to access this page.'));
1043
 
1044
+ $page = $_GET['page'];
1045
  $active_page = '';
1046
+
1047
  $original_options = $this->options;
1048
+ $bwp_option_page = new BWP_OPTION_PAGE($page, $this->site_options);
1049
 
1050
  // Get option from the database, general options are used for both
1051
  // 'General Options' page and 'Manage enqueued' page
1064
  'input_custom_buster',
1065
  'enable_min_js',
1066
  'enable_min_css',
1067
+ 'enable_external_origin',
1068
  'enable_bloginfo',
1069
  'enable_css_bubble',
1070
  'enable_cache_file_lock',
1118
  'checkbox',
1119
  'checkbox',
1120
  'checkbox',
1121
+ 'checkbox',
1122
  'input',
1123
  'input',
1124
  'select',
1136
  __('Minify JS files automatically?', $this->domain),
1137
  __('Minify CSS files automatically?', $this->domain),
1138
  __('Minify <code>bloginfo()</code> stylesheets?', $this->domain),
1139
+ __('Leave external files at their original positions?', $this->domain),
1140
  __('URL path to Minify library (relative to domain root)', $this->domain),
1141
  __('One minify string will contain', $this->domain),
1142
  __('For cache buster, use', $this->domain),
1153
  'cb1',
1154
  'cb3',
1155
  'cb2',
1156
+ 'ext_origin',
1157
  'input_minpath',
1158
  'input_maxfiles',
1159
  'select_buster_type',
1189
  )
1190
  ),
1191
  'checkbox' => array(
1192
+ 'cb1' => array(__('you can still use <code>bwp_minify()</code> helper function if you disable this.', $this->domain) => 'enable_min_js'),
1193
+ 'cb3' => array(__('you can still use <code>bwp_minify()</code> helper function if you disable this.', $this->domain) => 'enable_min_css'),
1194
+ 'cb2' => array(__('enable this for themes that use <code>bloginfo()</code> to print the main stylesheet (i.e. <code>style.css</code>). If you want to minify <code>style.css</code> with the rest of your css files, you must enqueue it.', $this->domain) => 'enable_bloginfo'),
1195
+ 'ext_origin' => array(__('enable this to improve compatibility with plugins/themes that print external JS/CSS files directly, for e.g. <code>Simple Google Maps Short Code</code> plugin or <code>Avada</code> theme.', $this->domain) => 'enable_external_origin'),
1196
+ 'cb4' => array(sprintf(__('move all <code>@import</code> rules in CSS files to the top. More info <a href="%s" target="_blank">here</a>.', $this->domain), $this->get_url('min_css_bubble')) => 'enable_css_bubble'),
1197
+ 'cb5' => array(__('disable this if filesystem is NFS.', $this->domain) => 'enable_cache_file_lock'),
1198
+ 'cb6' => array(sprintf(__('only enable this when minification does not work as expected. More info <a href="%s" target="_blank">here</a>.', $this->domain), $this->get_url('min_debug')) => 'enable_debug')
1199
  ),
1200
  'input' => array(
1201
  'input_minpath' => array(
1257
  'select_buster_type' => array(
1258
  'input_custom_buster' => 'input'
1259
  )
1260
+ ),
1261
+ 'role' => array(
1262
+ 'input_minpath' => 'superadmin',
1263
+ 'h2' => 'superadmin',
1264
+ 'input_doc_root' => 'superadmin',
1265
+ 'input_cache_dir' => 'superadmin',
1266
+ 'input_maxage' => 'superadmin',
1267
+ 'select_time_type' => 'superadmin',
1268
+ 'cb4' => 'superadmin',
1269
+ 'cb5' => 'superadmin',
1270
+ 'cb6' => 'superadmin'
1271
  )
1272
  );
1273
 
1282
  'input_custom_buster',
1283
  'enable_min_js',
1284
  'enable_min_css',
1285
+ 'enable_external_origin',
1286
  'enable_bloginfo',
1287
  'enable_css_bubble',
1288
  'enable_cache_file_lock',
1457
  . '</p>'
1458
  ),
1459
  'post' => array(
1460
+ ),
1461
+ 'role' => array(
1462
+ 'input_fly_minpath' => 'superadmin'
1463
  )
1464
  );
1465
 
1491
  'heading'
1492
  ),
1493
  'item_labels' => array (
1494
+ __('Manage enqueued JS files', $this->domain),
1495
+ __('Manage enqueued CSS files', $this->domain)
1496
  ),
1497
  'item_names' => array(
1498
  'h1',
1502
  'h1' => '<em>' . sprintf(
1503
  __('Below you can find a list of enqueued JS files '
1504
  . 'detected by this plugin. Press <strong>select</strong> and '
1505
+ . 'then choose to perform an appropriate action on selected JS file. '
1506
  . 'You can also directly type in one script handle (<strong>NOT '
1507
  . 'filename/script src</strong>) per line in the input field if '
1508
+ . 'you want. More info <a href="%s#manage_enqueued_files" target="_blank">here</a>.', $this->domain),
1509
  $this->plugin_url
1510
  ) . '</em>',
1511
  'h2' => '<em>' . sprintf(
1512
  __('Below you can find a list of enqueued CSS files '
1513
  . 'detected by this plugin. Press <strong>select</strong> and '
1514
+ . 'then choose to perform an appropriate action on selected CSS file. '
1515
  . 'You can also directly type in one style handle (<strong>NOT '
1516
  . 'filename/style src</strong>) per line in the input field if '
1517
+ . 'you want. More info <a href="%s#manage_enqueued_files" target="_blank">here</a>.', $this->domain),
1518
  $this->plugin_url
1519
  ) . '</em>'
1520
  ),
1539
  }
1540
 
1541
  $option_formats = array(
1542
+ 'input_maxfiles' => 'int',
1543
+ 'input_maxage' => 'int',
1544
  'select_time_type' => 'int'
1545
  );
1546
 
1568
  {
1569
  if (isset($_POST[$key]))
1570
  {
1571
+ // make sure inputs are in expected format
1572
  $bwp_option_page->format_field($key, $option_formats);
1573
  $option = trim(stripslashes($_POST[$key]));
1574
  }
1611
  $this->add_notice(__('All options have been saved.', $this->domain));
1612
  }
1613
 
1614
+ // take care of some custom POST actions when form is submitted,
1615
+ // when multisite is active, only do this when the user is a superadmin
1616
+ if ($page == BWP_MINIFY_OPTION_GENERAL)
1617
  {
1618
+ // other actions for the general option page
1619
+ if ($original_options['enable_min_js'] != $this->options['enable_min_js']
1620
+ || $original_options['enable_min_css'] != $this->options['enable_min_css']
1621
+ ) {
1622
+ // @since 1.3.2 changed plugin functionality, clear the log
1623
+ $this->detector->clear_logs();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1624
  }
1625
+
1626
+ if (!self::is_normal_admin())
1627
  {
1628
+ // try to save the Minify config file
1629
+ $result = $this->create_minify_config_file();
1630
+ if (true === $result)
1631
+ {
1632
+ // config file was successfully written
1633
+ $this->add_notice(sprintf(
1634
+ __('Minify config file <code>%s</code> '
1635
+ . 'has been updated successfully.', $this->domain),
1636
+ $this->min_dir . 'config.php'
1637
+ ));
1638
+ }
1639
+ else if ('config' === $result)
1640
+ {
1641
+ // config file is missing
1642
+ $this->add_error(
1643
+ '<strong style="color:red">' . __('Error') . ':</strong> '
1644
+ . sprintf(
1645
+ __('Minify config file <code>config.php</code> could not be found. '
1646
+ . 'The auto-detected directory to look for the config file is <code>%s</code>. '
1647
+ . 'Please manually check if that directory actually exists '
1648
+ . 'and contains the config file.', $this->domain),
1649
+ $this->get_doc_root($this->get_min_path())
1650
+ )
1651
+ );
1652
+ }
1653
+ else if ('put' === $result)
1654
+ {
1655
+ // the write process failed for some reasons
1656
+ $this->add_error(sprintf(
1657
+ '<strong style="color:red">' . __('Error') . ':</strong> '
1658
+ . __('There was an error writing to Minify config file <code>%s</code>. '
1659
+ . 'Please try again.', $this->domain),
1660
+ $this->min_dir . 'config.php'
1661
+ ));
1662
+ }
1663
+ else
1664
+ {
1665
+ // config file is not writable, show the auto-generated
1666
+ // contents to admin for manual update
1667
+ $this->add_notice(sprintf(
1668
+ '<strong>' . __('Notice', $this->domain) . ':</strong> '
1669
+ . __('Minify config file <code>%s</code> '
1670
+ . 'is not writable. See '
1671
+ . '<a href="#minify.config.php">below</a> '
1672
+ . 'for details.', $this->domain),
1673
+ $this->min_dir . 'config.php'
1674
+ ));
1675
+ $form['container']['h2'] = $this->_show_generated_config($result);
1676
+ }
1677
  }
1678
  }
1679
  else if ($page == BWP_MINIFY_OPTION_ADVANCED)
1680
  {
1681
+ // friendly minify url is turned on, add rewrite rules to
1682
+ // server directory config file (e.g. `.htaccess`). This should
1683
+ // not require WordPress's pretty permalink to be turned on
1684
  if ('yes' != $original_options['enable_fly_min']
1685
  && 'yes' == $this->options['enable_fly_min']
1686
  ) {
 
 
 
1687
  $this->_toggle_rewrite_rules($options, $form);
1688
  } else if ('yes' == $original_options['enable_fly_min']
1689
  && 'yes' != $this->options['enable_fly_min']
1731
  )
1732
  );
1733
  }
 
 
 
 
 
1734
  }
1735
  else if ($page == BWP_MINIFY_OPTION_ADVANCED)
1736
  {
1737
+ // Also remove nginx config path if not on nginx server
 
 
 
 
1738
  if (!self::is_nginx() || self::is_normal_admin())
1739
+ $bwp_option_page->kill_html_fields($form, array('input_nginx_config_file'));
1740
+
1741
+ // Append rewrite rules to the form when fly min is enabled, only
1742
+ // for superadmin
1743
+ if ($this->options['enable_fly_min'] == 'yes' && !self::is_normal_admin())
1744
+ $this->_append_fly_rewrite_rules_to_form($form);
1745
  }
1746
 
1747
+ /* // check for rewrite rules if needed, suppress error */
1748
+ /* if ('yes' == $this->options['enable_fly_min']) */
1749
+ /* $this->_add_rewrite_rules(); */
1750
 
1751
  // Assign the form and option array
1752
  $bwp_option_page->init($form, $options, $this->form_tabs);
1758
  private function _show_enqueued_styles()
1759
  {
1760
  $fields = array(
1761
+ 'input_style_direct' => __('Styles to stay at original positions', $this->domain),
1762
+ 'input_style_ignore' => __('Styles to NOT minify', $this->domain),
1763
+ 'input_style_oblivion' => __('Styles to remove', $this->domain)
1764
  );
1765
 
1766
  return $this->_show_enqueued('style', $fields);
1769
  private function _show_enqueued_scripts()
1770
  {
1771
  $fields = array(
1772
+ 'input_header' => __('Scripts to move to header', $this->domain),
1773
+ 'input_footer' => __('Scripts to move to footer', $this->domain),
1774
+ 'input_direct' => __('Scripts to stay at original positions', $this->domain),
1775
+ 'input_ignore' => __('Scripts to NOT minify', $this->domain),
1776
+ 'input_oblivion' => __('Scripts to remove', $this->domain)
1777
  );
1778
 
1779
  return $this->_show_enqueued('script', $fields);
1806
  : $this->options[$field];
1807
  ?>
1808
  <li>
1809
+ <a class="input-handle" data-field="<?php echo $field; ?>"
1810
  href="#"><span class="bwp-sign">+</span> <?php echo $label ?></a>
1811
  <textarea name="<?php echo $field ?>"
1812
  cols="20" rows="5"><?php esc_html_e($value); ?></textarea>
1937
  }
1938
  }
1939
 
1940
+ private function _append_fly_rewrite_rules_to_form(&$form)
1941
+ {
1942
+ // add rewrite rules to WP root, used by all servers
1943
+ $form['container']['h1'] = array();
1944
+
1945
+ $form['container']['h1'][] = '<strong>' . sprintf(
1946
+ __('Rewrite rules are required for this feature to work properly. '
1947
+ . 'Most of the time this is taken care of automatically by the plugin, '
1948
+ . 'but if you notice an error or you\'re using Nginx as a reverse proxy, '
1949
+ . 'you must manually update your server config files. '
1950
+ . 'More info <a href="%sfaq#rewrite-rules" target="blank">here</a>.', $this->domain),
1951
+ $this->plugin_url)
1952
+ . '</strong>';
1953
+
1954
+ // show a handle to toggle apache rewrite rules
1955
+ $form['container']['h1'][] = '<a href="#" class="fly-show-rules-handle" data-server="apache">'
1956
+ . __('Show rewrite rules for Apache', $this->domain)
1957
+ . '</a>' . ' | <a href="#" class="fly-show-rules-handle" data-server="nginx">'
1958
+ . __('Show rewrite rules for Nginx', $this->domain)
1959
+ . '</a>';
1960
+
1961
+ // show appropriate apache rewrite rules
1962
+ $apache_rules = '<div class="fly-apache-rules fly-min-rules" style="display: none">';
1963
+
1964
+ if ($this->rewriter_apache->is_wp_rewrite_rules_needed())
1965
+ {
1966
+ $apache_rules .= sprintf(
1967
+ __('Below rules should present at the top of <code>%s</code>:'),
1968
+ $this->rewriter_apache->get_wp_config_file()
1969
+ );
1970
+
1971
+ $apache_rules .= '<br />'
1972
+ . '<textarea class="code" style="margin: 10px 0" rows="8" cols="90" readonly="readonly">'
1973
+ . $this->rewriter_apache->get_generated_wp_rewrite_rules()
1974
+ . '</textarea><br />';
1975
+ }
1976
+
1977
+ $apache_rules .= sprintf(
1978
+ __('Below rules should present at the top of <code>%s</code>:'),
1979
+ $this->rewriter_apache->get_cache_config_file()
1980
+ );
1981
+
1982
+ $apache_rules .= '<br />'
1983
+ . '<textarea class="code" style="margin: 10px 0;" rows="8" cols="90" readonly="readonly">'
1984
+ . $this->rewriter_apache->get_generated_cache_rewrite_rules()
1985
+ . '</textarea>';
1986
+
1987
+ $apache_rules .= '</div>';
1988
+
1989
+ $form['container']['h1'][] = $apache_rules;
1990
+
1991
+ // show appropriate nginx rewrite rules
1992
+ $nginx_rules = '<div class="fly-nginx-rules fly-min-rules" style="display: none">';
1993
+
1994
+ $nginx_rules .= __('Below rules should present in an appropriate position '
1995
+ . 'within your Nginx configuration file.', $this->domain);
1996
+
1997
+ $nginx_rules .= '<br />'
1998
+ . '<textarea class="code" style="margin: 10px 0" rows="8" cols="90" readonly="readonly">'
1999
+ . $this->rewriter_nginx->get_generated_wp_rewrite_rules()
2000
+ . '</textarea>';
2001
+
2002
+ $nginx_rules .= '</div>';
2003
+
2004
+ $form['container']['h1'][] = $nginx_rules;
2005
+ }
2006
+
2007
  /**
2008
  * Writes rewrite rules to server config file when needed
2009
  *
2013
  * @since 1.3.0
2014
  * @return void
2015
  */
2016
+ private function _toggle_rewrite_rules(&$options)
2017
  {
2018
+ // do not suppress error
 
2019
  $this->rewriter->no_suppress();
2020
+
2021
+ // try to add required rewrite rules to wp's main .htaccess file
2022
  $result = $this->rewriter->add_wp_rewrite_rules();
2023
 
2024
+ // could not write rewrite rules to wp's main .htaccess file
2025
  if (true !== $result && 'written' !== $result)
2026
  {
 
2027
  $config_file = $this->rewriter->get_wp_config_file();
2028
  $error = $this->_get_rewrite_rules_error($result, $config_file);
2029
+
2030
  $this->add_error($error);
2031
+ /* $form['container']['h1'][] = $this->_show_generated_wp_rewrite_rules(); */
2032
  }
2033
 
2034
+ // asumming apache, need to add rules to cache directory too
2035
  if (false == self::is_nginx())
2036
  {
 
2037
  $result = $this->rewriter->add_cache_rewrite_rules();
2038
  $config_file = $this->rewriter->get_cache_config_file();
2039
 
2056
  . 'automatically to prevent your site from breaking. ', $this->domain)
2057
  );
2058
 
2059
+ /* $form['container']['h1'][] = $this->_show_generated_cache_rewrite_rules(); */
2060
  }
2061
  else if (true === $result)
2062
  {
2073
  $output = '<strong>'
2074
  . __('Could not write Minify library settings to <code>%s</code>. '
2075
  . 'Please update the config file manually by <em>replacing</em> its current contents '
2076
+ . 'with auto-generated rewrite rules as shown below:', $this->domain)
2077
  . '</strong>';
2078
  $output = sprintf($output, $this->min_dir . 'config.php');
2079
  $output .= '<br /><br />';
2085
 
2086
  private function _show_generated_wp_rewrite_rules()
2087
  {
2088
+ /* if (self::is_nginx()) */
2089
+ /* { */
2090
+ /* // nginx server only needs rewrite rules in a central config file */
2091
+ /* $rules = $this->rewriter->get_generated_wp_rewrite_rules(); */
2092
+ /* $output = '<strong>' . __('Please update the Nginx config file ' */
2093
+ /* . 'manually using auto-generated contents as shown below. ' */
2094
+ /* . 'It is highly recommended that you create a separate config file ' */
2095
+ /* . 'for BWP Minify (e.g. <code>bwp-minify.conf</code>) and include it ' */
2096
+ /* . 'directly above where you include your cache plugins\' config files, ' */
2097
+ /* . 'as shown <a href="%s" target="_blank">here</a>. ', $this->domain) . '</strong>'; */
2098
+ /* $output = sprintf($output, $this->get_url('wp_codex_nginx_rewrite_rules')); */
2099
+ /* } */
2100
+ /* else */
2101
+ /* { */
2102
+ /* // Apache server needs rewrite rules for root WP rewrite rules when */
2103
+ /* // sub-directory multisite is set up */
2104
+ /* $rules = $this->rewriter->get_generated_wp_rewrite_rules(); */
2105
+ /* $output = '<strong>' . __('Please update the server config file <code>%s</code> ' */
2106
+ /* . 'manually using auto-generated contents as shown below. ' */
2107
+ /* . 'It is highly recommended that you paste the contents ' */
2108
+ /* . 'at the top of the server config file. ' */
2109
+ /* . 'If config file does not exist, you must first create it.', $this->domain) . '</strong>'; */
2110
+ /* $output = sprintf($output, $this->rewriter->get_wp_config_file()); */
2111
+ /* } */
2112
+
2113
+ /* $output .= '<br /><br />'; */
2114
+ /* $output .= '<textarea class="code" rows="8" cols="90" readonly="readonly">' */
2115
+ /* . $rules . '</textarea>'; */
2116
+
2117
+ /* return $output; */
2118
  }
2119
 
2120
  private function _show_generated_cache_rewrite_rules()
2121
  {
2122
+ /* $rules = $this->rewriter->get_generated_cache_rewrite_rules(); */
 
 
 
 
 
 
 
 
2123
 
2124
+ /* $output = '<strong>' */
2125
+ /* . __('Please update the cache directory config file <code>%s</code> ' */
2126
+ /* . 'manually using auto-generated contents as shown below. ' */
2127
+ /* . 'It is highly recommended that you paste the contents ' */
2128
+ /* . 'at the top of the server config file. ' */
2129
+ /* . 'If config file does not exist, you must first create it.', $this->domain) */
2130
+ /* . '</strong>'; */
2131
 
2132
+ /* $output = sprintf($output, $this->rewriter->get_cache_config_file()); */
2133
+
2134
+ /* $output .= '<br /><br />'; */
2135
+ /* $output .= '<textarea class="code" rows="8" cols="90" readonly="readonly">' */
2136
+ /* . $rules . '</textarea>'; */
2137
+
2138
+ /* return $output; */
2139
  }
2140
 
2141
  private function _get_rewrite_rules_error($result, $config_file)
2340
  $result = $this->create_minify_config_file();
2341
 
2342
  // if friendly minify url is enabled, add rewrite rules to server
2343
+ // config file if needed
2344
  if ('yes' == $this->options['enable_fly_min'])
2345
  $this->_add_rewrite_rules();
2346
  }
2453
  break;
2454
 
2455
  case 'wpver':
2456
+ $buster = $this->wp_version;
2457
  break;
2458
 
2459
  case 'tver':
2490
  }
2491
 
2492
  /**
2493
+ * Checks whether the media files have been put into a particular position
2494
  *
2495
  * @return bool
2496
+ * @access private
2497
  */
2498
+ private function _is_in($handle, $position = 'header')
2499
  {
2500
  if (!isset($this->print_positions[$position])
2501
  || !is_array($this->print_positions[$position])
2507
  return true;
2508
  }
2509
 
2510
+ /**
2511
+ * Puts media files into a particular position
2512
+ *
2513
+ * @param $position string
2514
+ * @param $handles array|string
2515
+ * @param $order string 'append' or 'prepend', either add to the end or the
2516
+ * beginning of the position array
2517
+ *
2518
+ * @return void
2519
+ * @access private
2520
+ */
2521
+ private function _put_in($position, $handles)
2522
+ {
2523
+ $handles = (array) $handles;
2524
+
2525
+ foreach ($handles as $handle)
2526
+ {
2527
+ if (!in_array($handle, $this->print_positions[$position]))
2528
+ $this->print_positions[$position][] = $handle;
2529
+ }
2530
+ }
2531
+
2532
  /**
2533
  * Checks if a style has inline styles to print
2534
  *
2762
  return $src;
2763
  }
2764
 
2765
+ private function _init_todo_item($handle, $type)
2766
  {
2767
  global $wp_scripts, $wp_styles;
2768
 
2776
  $src = trim($item->src);
2777
 
2778
  $todo_item = array(
2779
+ 'position' => 'dummy', // 'dummy', 'original', 'header', 'footer', or 'footer{n}'
2780
  'min' => true, // expect to be minified
2781
  'wp' => false, // expect to be handled by WP
2782
  'forget' => false, // put into oblivion or not
2786
 
2787
  // look for dependencies of this item
2788
  $deps = $item->deps;
2789
+ if ($deps && is_array($deps) && 0 < sizeof($deps))
2790
  $todo_item['depend'] = $deps;
 
2791
 
2792
  if (empty($src))
2793
  return $todo_item;
2794
 
2795
+ if (!$this->is_local($src))
2796
  {
2797
+ // if this item is external, do not minify
2798
  $todo_item['min'] = false;
2799
+
2800
+ $is_external_origin = $this->options['enable_external_origin'] == 'yes'
2801
+ || (defined('BWP_MINIFY_ENABLE_EXTERNAL_ORIGIN') && BWP_MINIFY_ENABLE_EXTERNAL_ORIGIN)
2802
+ ? true : false;
2803
+
2804
+ if ($type == 'script'
2805
+ && $is_external_origin
2806
+ && !$this->_is_in($handle, 'header')
2807
+ && !$this->_is_in($handle, 'footer')
2808
+ ) {
2809
+ // if this item is script, and is not forced to header/footer,
2810
+ // let WordPress handles it
2811
+ $todo_item['wp'] = true;
2812
+ $todo_item['position'] = 'original';
2813
+ }
2814
  }
2815
+
2816
+ if (('all' != $this->print_positions[$prefix . 'allowed']
2817
+ && !$this->_is_in($handle, $prefix . 'allowed'))
2818
+ || $this->_is_in($handle, $prefix . 'ignore')
2819
+ || !$this->is_source_static($src)
2820
  ) {
2821
+ // If this item is not allowed to be minified, or is ignored
2822
+ // OR if this item is dynamic, no minify
2823
  $todo_item['min'] = false;
2824
  }
 
 
 
 
 
 
2825
 
2826
+ if ($this->_is_in($handle, $prefix . 'oblivion'))
2827
+ {
2828
+ // this item is put into oblivion (forget)
2829
+ $todo_item['min'] = false;
2830
+ $todo_item['wp'] = false;
2831
+ $todo_item['forget'] = true;
2832
+ $todo_item['position'] = 'oblivion';
2833
+ $todo_item['src'] = $src;
2834
+ }
2835
+ else if ($this->_is_in($handle, $prefix . 'direct'))
2836
+ {
2837
+ // if this item should stay at original position, let WordPress
2838
+ // handles the output. This was originally known as 'minified but
2839
+ // printed separately', but @since 1.3.1 is known as 'stay at original
2840
+ // position', the item will now truly stay at exactly where it is
2841
+ // printed.
2842
+ $todo_item['position'] = 'original';
2843
+ $todo_item['wp'] = true;
2844
+ }
2845
+
2846
+ if ($todo_item['wp'])
2847
+ {
2848
+ // if this item is handled by WP, put it into the internal WP-todo list
2849
+ $this->_put_in('_' . $prefix . 'wp', $handle);
2850
+
2851
+ if ($todo_item['depend'])
2852
+ {
2853
+ // if this item has dependencies, we need to let WordPress
2854
+ // handles those dependencies as well by putting their handles
2855
+ // in the internal WP-todo list and updating their data
2856
+ $items_to_move = $this->_update_todo_items($todo_item['depend'], array(
2857
+ 'position' => 'original',
2858
+ 'wp' => true,
2859
+ ), $type);
2860
+
2861
+ // put all dependencies including those at the very top
2862
+ $this->_put_in('_' . $prefix . 'wp', $items_to_move);
2863
+ }
2864
  }
2865
 
2866
  return $todo_item;
2867
  }
2868
 
2869
+ /**
2870
+ * Updates todo items' data
2871
+ *
2872
+ * This should be done interactively when initializing enqueued item and
2873
+ * prior to minifying to avoid dependency issues. This function will also
2874
+ * traverse the dependency tree to update all dependencies.
2875
+ *
2876
+ * @param $handles string|array handle name or a list of handles to update data
2877
+ * @param $new_data array new data to use, only update what is provided
2878
+ * @param $type string either 'script' or 'style'
2879
+ *
2880
+ * @since 1.3.1
2881
+ * @return array a list of handles that have been updated
2882
+ * @access private
2883
+ */
2884
+ private function _update_todo_items($handles, $new_data, $type, $recursive = false)
2885
+ {
2886
+ $handles = (array) $handles;
2887
+ $updated_handles = array();
2888
+
2889
+ if ($type == 'script')
2890
+ $todo_items = &$this->todo_scripts;
2891
+ else
2892
+ $todo_items = &$this->todo_styles;
2893
+
2894
+ foreach ($handles as $handle)
2895
+ {
2896
+ if (!isset($todo_items[$handle])
2897
+ || $todo_items[$handle]['forget'])
2898
+ {
2899
+ // if no item found or it was forgotten no need to update anything
2900
+ continue;
2901
+ }
2902
+
2903
+ foreach ($new_data as $k => $v)
2904
+ {
2905
+ if (isset($todo_items[$handle][$k]))
2906
+ $todo_items[$handle][$k] = $v;
2907
+ }
2908
+
2909
+ $updated_handles[] = $handle;
2910
+
2911
+ // traverse up the dependency tree if needed
2912
+ if ($todo_items[$handle]['depend'])
2913
+ {
2914
+ $updated_handles = array_merge(
2915
+ $updated_handles,
2916
+ $this->_update_todo_items($todo_items[$handle]['depend'], $new_data, $type, true)
2917
+ );
2918
+ }
2919
+ }
2920
+
2921
+ return $updated_handles;
2922
+ }
2923
+
2924
  /**
2925
  * Checks if a group is a dependency of some groups
2926
  *
2975
  *
2976
  * A group can be one of the following types:
2977
  * 1. A Minify group: files are minified and combined, printed together
2978
+ * 2. A WP Minify group: files are minified and printed separately at original location
2979
+ * 3. A WP group: files are NOT minified and printed separately at original location
2980
  *
2981
  * Apply to a Minify group: If the number of files per group reaches a
2982
  * limit (by default the limit is 10) this plugin will split the minify
3002
  // current item's group
3003
  $group_deps[$item['group']] = 1;
3004
  }
3005
+
3006
  continue;
3007
  }
3008
 
3040
  return $group_deps;
3041
  }
3042
 
3043
+ /**
3044
+ * Marks an enqueued item as done so WordPress doesn't process it later on
3045
+ *
3046
+ * @since 1.3.1
3047
+ * @access private
3048
+ */
3049
+ private function _mark_as_done($handle, $type)
3050
+ {
3051
+ global $wp_scripts, $wp_styles;
3052
+
3053
+ $media = 'script' == $type ? $wp_scripts : $wp_styles;
3054
+
3055
+ $media->done[] = $handle;
3056
+ }
3057
+
3058
+ /**
3059
+ * Checks whether an enqueued item has been processed by WordPress
3060
+ *
3061
+ * @since 1.3.1
3062
+ * @access private
3063
+ */
3064
+ private function _is_done_by_wp($handle, $type)
3065
+ {
3066
+ global $wp_scripts, $wp_styles;
3067
+
3068
+ $media = 'script' == $type ? $wp_scripts : $wp_styles;
3069
+
3070
+ if (in_array($handle, $media->done))
3071
+ return true;
3072
+
3073
+ return false;
3074
+ }
3075
+
3076
+ /**
3077
+ * Gets a list of items that are handled by WP with the original enqueueing order
3078
+ *
3079
+ * @since 1.3.1
3080
+ * @access private
3081
+ */
3082
+ private function _get_wp_todo($original_todo, $type)
3083
+ {
3084
+ $temp = $original_todo;
3085
+ $wp_todo = $type == 'script' ? $this->print_positions['_wp']
3086
+ : $this->print_positions['_style_wp'];
3087
+
3088
+ foreach ($original_todo as $key => $handle)
3089
+ {
3090
+ if (!in_array($handle, $wp_todo))
3091
+ unset($temp[$key]);
3092
+ }
3093
+
3094
+ return array_values($temp);
3095
+ }
3096
+
3097
  /**
3098
  * Builds a list of internal $todo_styles from WP's $todo
3099
  *
3106
  // @since 1.3.0 add 'dashicons' to default ignore list
3107
  $this->print_positions['style_allowed'] = apply_filters('bwp_minify_allowed_styles', 'all');
3108
 
3109
+ // @since 1.3.1 add an internal list to control items that must be
3110
+ // handled by WordPress, this is reset every time this function runs
3111
+ $this->print_positions['_style_wp'] = array();
3112
+
3113
  foreach ($todo as $handle)
3114
  {
3115
+ $style = $wp_styles->registered[$handle];
3116
+ $todo_style = $this->_init_todo_item($handle, 'style');
3117
 
3118
  if (empty($style->src))
3119
  {
3120
  if ($todo_styles['depend'])
 
3121
  $this->todo_styles[$handle] = $todo_style;
3122
+
 
3123
  continue;
3124
  }
3125
 
3126
  $todo_style['media'] = 'all'; // can be 'all', 'print', etc.
3127
+ $todo_style['if'] = '';
3128
+ $todo_style['alt'] = '';
3129
 
3130
  // if this style has different media type, set it
3131
  if (!empty($style->args) && 'all' != $style->args)
3157
  $suffix = isset($style->extra['suffix'])
3158
  ? $style->extra['suffix']
3159
  : '';
3160
+
3161
  $rtl_src = str_replace("{$suffix}.css", "-rtl{$suffix}.css", $style->src);
3162
+
3163
  $todo_style['src'] = $rtl_src;
3164
  }
3165
  else
3167
  // add a new todo_rtl as a clone of current todo_style and
3168
  // make todo_style its dependency
3169
  $rtl_src = trim($style->extra['rtl']);
3170
+
3171
+ $todo_rtl = $todo_style;
3172
+ $todo_rtl['src'] = $rtl_src;
3173
  $todo_rtl['depend'] = array($handle);
3174
+ $todo_rtl['min'] = $this->is_source_static($rtl_src) && $this->is_local($rtl_src);
3175
  }
3176
  }
3177
 
3178
+ if ($todo_style['wp'] || $todo_style['forget'])
3179
  {
3180
+ // this item is handled by WP or forgotten
 
 
 
 
 
3181
  }
3182
+ elseif (did_action('bwp_minify_after_header_styles'))
 
3183
  {
3184
  // if this style is registered after the styles are printed, it is
3185
  // expected in footer
3201
  $this->todo_styles[$handle . '_rtl'] = $todo_rtl;
3202
  $todo_rtl = false;
3203
  }
 
 
3204
  }
3205
 
3206
  // start minifying
3214
  $this->late_style_order++;
3215
  }
3216
 
3217
+ return $this->_get_wp_todo($todo, 'style');
 
3218
  }
3219
 
3220
  /**
3234
  global $wp_styles;
3235
 
3236
  $style = $wp_styles->registered[$handle];
3237
+ $src = !empty($item['src']) ? $item['src'] : $style->src;
3238
 
3239
  if ($item['min'])
3240
  {
3241
  // minify is needed
3242
  $src = $this->process_media_source($src);
3243
 
 
 
3244
  if ($item['wp'])
3245
  {
3246
  // because WordPress needs original $src, we process the
3249
  $this->process_media_source($style->src),
3250
  $group_handle
3251
  );
3252
+
3253
  $style->ver = NULL;
3254
+
3255
  $this->min_styles[$group_handle] = array(
3256
+ 'depend' => $group_deps,
3257
+ 'handle' => $handle,
3258
  'position' => $item['position']
3259
  );
3260
+
3261
  $item['group'] = $group_handle;
3262
  }
3263
  else
3264
  {
3265
  $group_handle = false;
3266
+
3267
  foreach ($this->min_styles as $_group_handle => $_group)
3268
  {
3269
  // pick the first available group that is:
3271
  // 2. has the same media type
3272
  // 3. same conditional type, if is a condiional style
3273
  // 4. same alternate title, if is an alternate style
3274
+ // 5. still has room for more styles
3275
  // but do not take into account group that is
3276
  // dependency of this item's own dependencies.
3277
  if (isset($_group['string']) && $_group['position'] == $item['position']
3279
  && !$this->is_a_dependency($_group_handle, $group_deps, 'style')
3280
  ) {
3281
  $is_same_media = $_group['media'] == $item['media'];
3282
+ $is_same_if = $_group['if'] == $item['if'];
3283
+ $is_same_alt = $_group['alt'] == $item['alt'];
3284
+
3285
  if ($is_same_media && $is_same_if && $is_same_alt)
3286
  {
3287
  $group_handle = $_group_handle;
3295
  // append to selected group's minify string, only if
3296
  // this $src has not been added before
3297
  $group = &$this->min_styles[$group_handle];
3298
+
3299
  if (!in_array($src, $group['string']))
3300
  {
3301
  $group['string'][] = $src;
3308
  // merge this item's dependencies with the selected
3309
  // group's deps.
3310
  $group['depend'] = array_merge($group['depend'], $group_deps);
3311
+ $item['group'] = $group_handle;
3312
  }
3313
  }
3314
  else
3315
  {
3316
  // otherwise make a new group
3317
  $group_handle = $this->_sanitize_handle($handle);
3318
+
3319
  $this->min_styles[$group_handle] = array(
3320
+ 'depend' => $group_deps,
3321
+ 'string' => array($src),
3322
  'position' => $item['position'],
3323
+ 'media' => $item['media'],
3324
+ 'alt' => $item['alt'],
3325
+ 'if' => $item['if']
3326
  );
3327
+
3328
  $item['group'] = $group_handle;
3329
  }
3330
  }
3333
  {
3334
  // no minify is needed, add new group to hold this item
3335
  $this->min_styles[$group_handle] = array(
3336
+ 'depend' => $group_deps,
3337
+ 'handle' => $handle,
3338
  'position' => $item['position']
3339
  );
3340
+
3341
  $item['group'] = $group_handle;
3342
  }
3343
 
3344
+ if (!$item['wp'])
3345
+ $this->_mark_as_done($handle, 'style');
3346
+
3347
+ if (!$item['wp'] && self::has_inline($handle))
3348
+ {
3349
+ // if this item has inline styles and WP does not handle it, mark
3350
+ // it to process later
3351
  $this->todo_inline_styles[$group_handle][] = $handle;
3352
+ }
3353
 
 
3354
  $item['src'] = $src;
3355
+
3356
+ // update the internal _Todo_ list
3357
  $this->todo_styles[$handle] = $item;
3358
 
3359
  do_action('bwp_minify_processed_style', $handle, $item);
3377
  if (!$recursive)
3378
  do_action('bwp_minify_before_' . $position . '_styles');
3379
 
3380
+ $groups = !$groups ? $this->min_styles : $groups;
3381
  $group_position = $position;
3382
 
3383
  foreach ($groups as $group_handle => $group)
3386
  if (!empty($this->min_styles[$group_handle]['done']))
3387
  continue;
3388
 
3389
+ if ($group['position'] == 'original' || $group['position'] == 'oblivion')
3390
+ {
3391
+ // @since 1.3.1 if this group is handled by WordPress or forgotten,
3392
+ // do not procceed and mark as done
3393
+ $this->min_styles[$group_handle]['done'] = true;
3394
+ continue;
3395
+ }
3396
+
3397
  // if this is not the correct position for the group, halt the
3398
  // entire loop but return the correct position so the offending group
3399
  // can update itself
3400
  if ($group['position'] != $position)
3401
+ {
3402
  if ($recursive)
3403
  return $group['position'];
3404
  else
3405
  continue;
3406
+ }
3407
 
3408
  // print dependencies first
3409
  $deps = array();
3414
  if (isset($this->min_styles[$dep]))
3415
  $deps[$dep] = $this->min_styles[$dep];
3416
  }
3417
+
3418
  $group_position = $this->print_styles($position, $deps, true);
3419
  }
3420
 
3427
  $group_handle,
3428
  $group_position
3429
  );
3430
+
3431
  $this->min_styles[$group_handle]['position'] = $group_position;
3432
+
3433
  continue;
3434
  }
3435
 
3437
  {
3438
  // if this is a minify string
3439
  echo $this->get_minify_tag('style', $group, $group_handle);
3440
+
3441
  // print inline style after if this group has any
3442
  if (isset($this->todo_inline_styles[$group_handle]))
3443
  $this->print_inline_styles($this->todo_inline_styles[$group_handle]);
3444
  }
3445
  else if (!empty($group['handle']))
3446
  {
3447
+ // we control the position but not the output
3448
  $wp_styles->do_item($group['handle']);
3449
  }
3450
 
3454
  if (!$recursive)
3455
  {
3456
  do_action('bwp_minify_after_' . $position . '_styles');
3457
+
3458
  // save detector's log whenever we finish printing a footer{n} batch
3459
+ if (false !== strpos($position, 'footer'))
3460
  $this->detector->commit_logs();
3461
  }
3462
 
3484
  global $wp_styles;
3485
 
3486
  // this feature is only available on WP 3.3 or higher
3487
+ if (version_compare($this->wp_version, '3.3', '<'))
3488
  return;
3489
 
3490
  foreach ($handles as $handle)
3531
  // @since 1.0.5 - 1.0.6
3532
  $this->print_positions['allowed'] = apply_filters('bwp_minify_allowed_scripts', 'all');
3533
 
3534
+ // @since 1.3.1 add an internal list to control items that must be
3535
+ // handled by WordPress, this is reset every time this function runs
3536
+ $this->print_positions['_wp'] = array();
3537
+
3538
  foreach ($todo as $handle)
3539
  {
3540
+ $script = $wp_scripts->registered[$handle];
3541
+ $todo_script = $this->_init_todo_item($handle, 'script');
3542
 
3543
  if (empty($script->src))
3544
  {
3547
  // script's src is empty/invalid but it has dependencies so
3548
  // it's probably a dummy script used to load other scripts
3549
  $this->todo_scripts[$handle] = $todo_script;
 
3550
  }
3551
+
3552
  continue;
3553
  }
3554
 
3555
+ if ('jquery-migrate' == $handle)
3556
+ {
3557
  // jquery-migrate and jquery-core might get separated so we
3558
  // force jquery-migrate to have jquery-core as its dependecy
3559
  $todo_script['depend'] = false == $todo_script['depend']
3561
  $todo_script['depend'][] = 'jquery-core';
3562
  }
3563
 
 
 
 
 
 
 
 
3564
  // if this script is registered in footer, or it is registered
3565
  // after the header scripts are printed, it is expected in footer
3566
  $expected_in_footer = isset($wp_scripts->groups[$handle])
3568
  || did_action('bwp_minify_after_header_scripts')
3569
  ? true : false;
3570
 
3571
+ if ($todo_script['wp'] || $todo_script['forget'])
3572
+ {
3573
+ // this item is handled by WP or is forgotten
3574
+ } elseif (!$this->_is_in($handle, 'header')
3575
+ && ($this->_is_in($handle, 'footer') || $expected_in_footer)
3576
  ) {
3577
  // if this script belongs to footer (logically or
3578
  // 'intentionally') and is not 'forced' to be in header
3587
  }
3588
 
3589
  $this->todo_scripts[$handle] = $todo_script;
 
3590
  }
3591
 
3592
  // start minifying
3600
  $this->late_script_order++;
3601
  }
3602
 
3603
+ return $this->_get_wp_todo($todo, 'script');
 
3604
  }
3605
 
3606
  /**
3620
  global $wp_scripts;
3621
 
3622
  $script = $wp_scripts->registered[$handle];
3623
+ $src = $script->src;
3624
 
3625
  if ($item['min'])
3626
  {
3633
  // processed and version is not set
3634
  $script->src = $this->get_minify_src($src, $group_handle);
3635
  $script->ver = NULL;
3636
+
3637
  // add a new group to hold this item
3638
  $this->min_scripts[$group_handle] = array(
3639
+ 'depend' => $group_deps,
3640
+ 'handle' => $handle,
3641
  'position' => $item['position']
3642
  );
3643
+
3644
  $item['group'] = $group_handle;
3645
  }
3646
  else
3647
  {
3648
  $group_handle = false;
3649
+
3650
  foreach ($this->min_scripts as $_group_handle => $_group)
3651
  {
3652
  // pick the first available group in the same position
3679
  // merge this item's dependencies with the selected
3680
  // group's deps.
3681
  $group['depend'] = array_merge($group['depend'], $group_deps);
3682
+ $item['group'] = $group_handle;
3683
  }
3684
  }
3685
  else
3686
  {
3687
  // otherwise make a new group
3688
  $group_handle = $this->_sanitize_handle($handle);
3689
+
3690
  $this->min_scripts[$group_handle] = array(
3691
+ 'depend' => $group_deps,
3692
+ 'string' => array($src),
3693
  'position' => $item['position']
3694
  );
3695
+
3696
  $item['group'] = $group_handle;
3697
  }
3698
  }
3701
  {
3702
  // no minify is needed, add new group to hold this item
3703
  $this->min_scripts[$group_handle] = array(
3704
+ 'depend' => $group_deps,
3705
+ 'handle' => $handle,
3706
  'position' => $item['position']
3707
  );
3708
+
3709
  $item['group'] = $group_handle;
3710
  }
3711
 
3712
+ if (!$item['wp'])
3713
+ $this->_mark_as_done($handle, 'script');
3714
+
3715
+ // if this item has l10n data and WP does not handle it, mark it to
3716
+ // process later
3717
+ if (!$item['wp'] && self::is_l10n($handle))
3718
  $this->todo_l10n[$group_handle][] = $handle;
3719
 
 
3720
  $item['src'] = $src;
3721
+
3722
+ // update the internal _Todo_ list
3723
  $this->todo_scripts[$handle] = $item;
3724
 
3725
  do_action('bwp_minify_processed_script', $handle, $item);
3743
  if (!$recursive)
3744
  do_action('bwp_minify_before_' . $position . '_scripts');
3745
 
3746
+ $groups = !$groups ? $this->min_scripts : $groups;
3747
  $group_position = $position;
3748
 
3749
  foreach ($groups as $group_handle => $group)
3752
  if (!empty($this->min_scripts[$group_handle]['done']))
3753
  continue;
3754
 
3755
+ if ($group['position'] == 'original' || $group['position'] == 'oblivion')
3756
+ {
3757
+ // @since 1.3.1 if this group is handled by WordPress or is
3758
+ // forgotten, do not procceed and mark as done
3759
+ $this->min_scripts[$group_handle]['done'] = true;
3760
+ continue;
3761
+ }
3762
+
3763
  // if this is not the correct position for the group
3764
  if ($group['position'] != $position)
3765
+ {
3766
  if ($recursive)
3767
  return $group['position'];
3768
  else
3769
  continue;
3770
+ }
3771
 
3772
  // print dependencies first
3773
  $deps = array();
3778
  if (isset($this->min_scripts[$dep]))
3779
  $deps[$dep] = $this->min_scripts[$dep];
3780
  }
3781
+
3782
  $group_position = $this->print_scripts($position, $deps, true);
3783
  }
3784
 
3790
  $group_handle,
3791
  $group_position
3792
  );
3793
+
3794
  $this->min_scripts[$group_handle]['position'] = $group_position;
3795
+
3796
  continue;
3797
  }
3798
 
3799
+ // print this group using minify tag
3800
  if (isset($group['string']) && 0 < sizeof($group['string']))
3801
  {
3802
  // print l10n data first if this group has any
3803
  if (isset($this->todo_l10n[$group_handle]))
3804
  $this->print_scripts_l10n($this->todo_l10n[$group_handle]);
3805
+
3806
  // if this is a minify string
3807
  echo $this->get_minify_tag('script', $group, $group_handle);
3808
  }
3809
  else if (!empty($group['handle']))
3810
  {
3811
+ // we control the position but not the output
3812
  $wp_scripts->do_item($group['handle']);
3813
  }
3814
 
3818
  if (!$recursive)
3819
  {
3820
  do_action('bwp_minify_after_' . $position . '_scripts');
3821
+
3822
  // save detector's log whenever we finish printing a footer batch
3823
  if (false !== strpos($position, 'footer'))
3824
  $this->detector->commit_logs();
3851
  {
3852
  // since WordPress version 3.3: uses
3853
  // $wp_scripts->print_extra_script instead to print l10n info
3854
+ if (version_compare($this->wp_version, '3.3', '>='))
3855
  $wp_scripts->print_extra_script($handle);
3856
  else
3857
  $wp_scripts->print_scripts_l10n($handle);
includes/common-functions.php CHANGED
@@ -13,4 +13,32 @@ function bwp_get_home_path() {
13
  return get_home_path();
14
  }
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  endif;
13
  return get_home_path();
14
  }
15
 
16
+ function bwp_is_maintenance_on() {
17
+ // this is from the Maintenance plugin, function `load_maintenance_page` in
18
+ // `load/functions.php`
19
+ if (function_exists('mt_get_plugin_options') && !is_user_logged_in())
20
+ {
21
+ $mt_options = mt_get_plugin_options(true);
22
+
23
+ if ($mt_options['state'])
24
+ {
25
+ if (!empty($mt_options['expiry_date_start'])
26
+ && !empty($mt_options['expiry_date_end'])
27
+ ) {
28
+ $current_time = strtotime(current_time('mysql', 1));
29
+ $start = strtotime($mt_options['expiry_date_start']);
30
+ $end = strtotime($mt_options['expiry_date_end']);
31
+
32
+ if ($current_time < $start
33
+ || ($current_time >= $end && !empty($mt_options['is_down']))
34
+ ) {
35
+ return false;
36
+ }
37
+ }
38
+
39
+ return true;
40
+ }
41
+ }
42
+ }
43
+
44
  endif;
includes/rewriter/apache.php CHANGED
@@ -21,8 +21,10 @@ class BWP_Minify_Rewriter_Apache extends BWP_Minify_AbstractRewriter
21
  {
22
  default:
23
  case '':
24
- $this->add_wp_rewrite_rules();
25
- $result = $this->add_cache_rewrite_rules();
 
 
26
  break;
27
 
28
  case 'wp':
@@ -110,31 +112,44 @@ class BWP_Minify_Rewriter_Apache extends BWP_Minify_AbstractRewriter
110
  $this->remove_rewrite_rules();
111
  }
112
 
113
- public function add_wp_rewrite_rules()
114
  {
115
  if (!BWP_MINIFY::is_multisite() || BWP_MINIFY::is_subdomain_install())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  return true;
117
 
118
  $this->prepare_wp_rewrite_rules();
119
 
120
- // only add these rules if `wp-content` is not already in fly min path
121
- $fly_min_path = $this->main->get_fly_min_path();
122
- if (false === strpos($fly_min_path, 'wp-content')
123
- && file_exists($this->config_file)
124
- ) {
125
- return $this->write_rewrite_rules($this->rules);
126
- }
127
  }
128
 
129
  public function add_cache_rewrite_rules()
130
  {
131
  $this->prepare_cache_rewrite_rules();
132
 
 
 
133
  if (file_exists($this->config_file) || is_writable($this->config_dir))
134
  {
135
- // server config file exists, OR doesn't exist but
136
- // directory is writable, attempt to create a new file, and
137
- // write rewrite rules to it
138
  return $this->write_rewrite_rules($this->rules);
139
  }
140
 
@@ -148,6 +163,7 @@ class BWP_Minify_Rewriter_Apache extends BWP_Minify_AbstractRewriter
148
  // update the rewrite rules, but provide different error messages
149
  if (!file_exists($this->config_dir))
150
  return 'exists_dir';
 
151
  if (!file_exists($this->config_file) && !is_writable($this->config_dir))
152
  return 'write_dir';
153
 
21
  {
22
  default:
23
  case '':
24
+ $result = $this->add_wp_rewrite_rules();
25
+
26
+ if ($result === true || $result === 'written')
27
+ $result = $this->add_cache_rewrite_rules();
28
  break;
29
 
30
  case 'wp':
112
  $this->remove_rewrite_rules();
113
  }
114
 
115
+ public function is_wp_rewrite_rules_needed()
116
  {
117
  if (!BWP_MINIFY::is_multisite() || BWP_MINIFY::is_subdomain_install())
118
+ return false;
119
+
120
+ $fly_min_path = $this->main->get_fly_min_path();
121
+
122
+ // only add these rules if `wp-content` is not already in fly min path
123
+ if (false !== strpos($fly_min_path, 'wp-content'))
124
+ return false;
125
+
126
+ return true;
127
+ }
128
+
129
+ public function add_wp_rewrite_rules()
130
+ {
131
+ if (!$this->is_wp_rewrite_rules_needed())
132
  return true;
133
 
134
  $this->prepare_wp_rewrite_rules();
135
 
136
+ // main wp htaccess files doesn't exist AND wp's root is not writable,
137
+ // nothing more we can do
138
+ if (!file_exists($this->config_file) && !is_writable($this->config_dir))
139
+ return false;
140
+
141
+ // this should create a new .htaccess file if it is not already there
142
+ return $this->write_rewrite_rules($this->rules);
143
  }
144
 
145
  public function add_cache_rewrite_rules()
146
  {
147
  $this->prepare_cache_rewrite_rules();
148
 
149
+ // server config file exists, OR doesn't exist but directory is
150
+ // writable, attempt to create a new file, and write rewrite rules to it
151
  if (file_exists($this->config_file) || is_writable($this->config_dir))
152
  {
 
 
 
153
  return $this->write_rewrite_rules($this->rules);
154
  }
155
 
163
  // update the rewrite rules, but provide different error messages
164
  if (!file_exists($this->config_dir))
165
  return 'exists_dir';
166
+
167
  if (!file_exists($this->config_file) && !is_writable($this->config_dir))
168
  return 'write_dir';
169
 
includes/rewriter/nginx.php CHANGED
@@ -43,6 +43,11 @@ class BWP_Minify_Rewriter_Nginx extends BWP_Minify_AbstractRewriter
43
  return $this->get_wp_config_dir();
44
  }
45
 
 
 
 
 
 
46
  public function get_wp_rewrite_rules()
47
  {
48
  // make use of WordPress's base, with blog path removed if any
43
  return $this->get_wp_config_dir();
44
  }
45
 
46
+ public function is_wp_rewrite_rules_needed()
47
+ {
48
+ return true;
49
+ }
50
+
51
  public function get_wp_rewrite_rules()
52
  {
53
  // make use of WordPress's base, with blog path removed if any
includes/rewriter/rewriter.php CHANGED
@@ -60,9 +60,15 @@ abstract class BWP_Minify_AbstractRewriter
60
  return $this;
61
  }
62
 
 
 
 
 
 
63
  abstract protected function add_rewrite_rules($suppress = true);
64
  abstract protected function add_wp_rewrite_rules();
65
  abstract protected function add_cache_rewrite_rules();
 
66
  abstract protected function remove_wp_rewrite_rules();
67
  abstract protected function remove_cache_rewrite_rules();
68
  abstract protected function get_wp_config_file();
60
  return $this;
61
  }
62
 
63
+ public function get_config_file()
64
+ {
65
+ return $this->config_file;
66
+ }
67
+
68
  abstract protected function add_rewrite_rules($suppress = true);
69
  abstract protected function add_wp_rewrite_rules();
70
  abstract protected function add_cache_rewrite_rules();
71
+ abstract protected function is_wp_rewrite_rules_needed();
72
  abstract protected function remove_wp_rewrite_rules();
73
  abstract protected function remove_cache_rewrite_rules();
74
  abstract protected function get_wp_config_file();
js/bwp-minify.js CHANGED
@@ -1,19 +1,34 @@
1
  jQuery(function($) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  function toggle_input(t, toggle) {
3
- var $t = $(t);
4
- var position = $t.data('position');
5
- var $w = $t.parents('.bwp-sidebar');
6
- var $s = $t.find('.bwp-sign');
 
7
  toggle = typeof toggle !== 'undefined' ? toggle : true;
8
 
9
- $w.find('.position-handle').not(t).find('.bwp-sign').html('+');
10
- $w.find(':input[name!="' + position + '"]').hide();
11
 
12
  if (false === toggle && '+' != $s.html()) {
13
  return false;
14
  }
15
 
16
- $w.find(':input[name="' + position + '"]').toggle();
17
  if ('+' == $s.html()) {
18
  $s.html('>>');
19
  } else {
@@ -21,7 +36,7 @@ jQuery(function($) {
21
  }
22
  }
23
 
24
- $('.bwp-sidebar').on('click', '.position-handle', function(e) {
25
  e.preventDefault();
26
  toggle_input(this);
27
  });
@@ -41,13 +56,14 @@ jQuery(function($) {
41
  $('.bwp-minify-detector-table').on('click', '.action-handle', function(e) {
42
  e.preventDefault();
43
 
44
- var $t = $(this);
45
- var position = $t.data('position');
46
  var handle = $t.parent().find('.data-handle').text();
47
- var input = 'input_' + position;
48
- var $i = $('.bwp-sidebar :input[name="' + input + '"]');
49
- var input_handle = $i.parent().find('.position-handle')[0];
50
- var input_val = '' == $i.val() ? '' : $i.val() + "\r\n";
 
51
 
52
  $i.val(input_val + handle);
53
  $t.parent().hide();
1
  jQuery(function($) {
2
+ // toggle server rewrite rules
3
+ $('.fly-show-rules-handle').on('click', function(e) {
4
+ e.preventDefault();
5
+
6
+ // hide all current rules
7
+ $('.fly-min-rules').hide();
8
+
9
+ var server = $(this).data('server');
10
+ var divClass = 'fly-' + server + '-rules';
11
+
12
+ $('.' + divClass).show();
13
+ })
14
+
15
+ // manage enqueued files
16
  function toggle_input(t, toggle) {
17
+ var $t = $(t);
18
+ var field = $t.data('field');
19
+ var $w = $t.parents('.bwp-sidebar');
20
+ var $s = $t.find('.bwp-sign');
21
+
22
  toggle = typeof toggle !== 'undefined' ? toggle : true;
23
 
24
+ $w.find('.input-handle').not(t).find('.bwp-sign').html('+');
25
+ $w.find(':input[name!="' + field + '"]').hide();
26
 
27
  if (false === toggle && '+' != $s.html()) {
28
  return false;
29
  }
30
 
31
+ $w.find(':input[name="' + field + '"]').toggle();
32
  if ('+' == $s.html()) {
33
  $s.html('>>');
34
  } else {
36
  }
37
  }
38
 
39
+ $('.bwp-sidebar').on('click', '.input-handle', function(e) {
40
  e.preventDefault();
41
  toggle_input(this);
42
  });
56
  $('.bwp-minify-detector-table').on('click', '.action-handle', function(e) {
57
  e.preventDefault();
58
 
59
+ var $t = $(this);
60
+ var action = $t.data('action');
61
  var handle = $t.parent().find('.data-handle').text();
62
+
63
+ var input = 'input_' + action;
64
+ var $i = $('.bwp-sidebar :input[name="' + input + '"]');
65
+ var input_handle = $i.parent().find('.input-handle')[0];
66
+ var input_val = '' == $i.val() ? '' : $i.val() + "\r\n";
67
 
68
  $i.val(input_val + handle);
69
  $t.parent().hide();
min/config.php CHANGED
@@ -13,4 +13,4 @@ $min_symlinks = array();
13
  $min_uploaderHoursBehind = 0;
14
  $min_libPath = dirname(__FILE__) . '/lib';
15
  ini_set('zlib.output_compression', '0');
16
- // auto-generated on 2014-07-15 08:00:19
13
  $min_uploaderHoursBehind = 0;
14
  $min_libPath = dirname(__FILE__) . '/lib';
15
  ini_set('zlib.output_compression', '0');
16
+ // auto-generated on 2014-09-24 00:33:26
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: OddOneOut
3
  Donate link: http://betterwp.net/wordpress-plugins/bwp-minify/
4
  Tags: minify, minify js, minify css, minify javascript, minify stylesheet, minification, optimization, optimize, stylesheet, css, javascript, js
5
- Requires at least: 3.0
6
- Tested up to: 3.9
7
- Stable tag: 1.3.0
8
  License: GPLv3 or later
9
 
10
  Allows you to combine and minify your CSS and JS files to improve page load time.
@@ -83,6 +83,29 @@ Please [help translate](http://betterwp.net/wordpress-tips/create-pot-file-using
83
 
84
  == Changelog ==
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  = 1.3.0 =
87
  * **New Features**
88
  * Added support for Friendly Minify strings, e.g. `http://example.com/path/to/script.js` (best used with CDN). This feature should work well on **nginx** server.
2
  Contributors: OddOneOut
3
  Donate link: http://betterwp.net/wordpress-plugins/bwp-minify/
4
  Tags: minify, minify js, minify css, minify javascript, minify stylesheet, minification, optimization, optimize, stylesheet, css, javascript, js
5
+ Requires at least: 3.1
6
+ Tested up to: 4.0
7
+ Stable tag: 1.3.3
8
  License: GPLv3 or later
9
 
10
  Allows you to combine and minify your CSS and JS files to improve page load time.
83
 
84
  == Changelog ==
85
 
86
+ = 1.3.3 =
87
+ * Fixed an issue with wrong `min/config.php` file.
88
+
89
+ = 1.3.2 =
90
+ * Marked as WordPress 4.0 compatible
91
+ * When updating BWP Minify, friendly minify url should be turned off automatically if required rewrite rules are not found. An appropriate error message will be shown once to notify owners of the site so that they can take appropriate actions.
92
+ * When friendly minify url is enabled, rewrite rules for both Apache and Nginx will be shown. This is to add support for Nginx as a reverse proxy.
93
+ * Fixed a bug that makes the detector fail to commit logs, which results in empty enqueued file lists.
94
+ * Other minor fixes and enhancements.
95
+ * BWP Minify now requires WordPress 3.1.0 or later.
96
+
97
+ = 1.3.1 =
98
+ * **Enhancements**
99
+ * Added an option to leave external enqueued files at their original positions.
100
+ * Added compatibility for Maintenance plugin (BWP Minify will be inactive when Maintenance mode is on).
101
+ * Improved settings on `Manage enqueued files` admin page to allow better control over enqueued files. Take a look at [this updated section](http://betterwp.net/wordpress-plugins/bwp-minify/#manage_enqueued_files) of official documentation for more details.
102
+ * Improved friendly minify url feature to work better with cache plugins: friendly urls should show up on first load.
103
+ * **Bugs fixed**
104
+ * Fixed an issue where CDN hosts don't replace the original host properly
105
+ * Fixed an issue with SSL on `wp-login.php` page
106
+
107
+ **Important Note**: After updating to 1.3.1, users of `Simple Google Maps Short Code` plugin (or similar ones) and `Avada` theme should go to *BWP Minify > General Options* and turn on `Leave external files at their original positions?` setting to make map shortcodes work.
108
+
109
  = 1.3.0 =
110
  * **New Features**
111
  * Added support for Friendly Minify strings, e.g. `http://example.com/path/to/script.js` (best used with CDN). This feature should work well on **nginx** server.
screenshot-3.png CHANGED
Binary file