Smush Image Compression and Optimization - Version 2.4

Version Description

  • Compatibility:

    • WPML Media Add-on compatibility, you can smush all the images for all the languages at once from Bulk Smush page
  • Features:

    • Added PNG to JPG - Lossy Conversion for higher savings ( Pro Feature )

*Fixed: * EXIF: Device details were left out for some images, even when opted for stripping it

  • Updated:
    • Minor Tweaks on WP Smush Page ( Bulk Smush )
    • Stats calculation
    • Show current image size and image size dimensions in media library after image has been smushed
    • JPEG optimisation - higher savings for JPEGs lossy optimisation ( Pro Feature )
Download this release

Release Info

Developer UmeshSingla
Plugin Icon 128x128 Smush Image Compression and Optimization
Version 2.4
Comparing to
See all releases

Code changes from version 2.3.1 to 2.4

assets/css/wp-smushit-admin.css CHANGED
@@ -289,7 +289,7 @@ input#wp-smush-save-settings {
289
  }
290
 
291
  .wpmud .wp-smushit-container-right .smush-stats-wrapper .wp-smush-container-header {
292
- margin-bottom: 20px;
293
  }
294
 
295
  .smush-stats-wrapper td, .smush-stats-wrapper th {
@@ -301,6 +301,51 @@ input#wp-smush-save-settings {
301
  margin: 7px 8px 0;
302
  }
303
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  table.wp-smush-stats-holder {
305
  border: 1px solid lightgray;
306
  border-collapse: collapse;
@@ -495,7 +540,7 @@ table.wp-smush-stats-holder tr td:first-child {
495
  float: right;
496
  font-size: 15px;
497
  line-height: 1.7;
498
- margin: 1em auto;
499
  }
500
 
501
  .wp-smush-auto-disabled {
@@ -508,7 +553,6 @@ table.wp-smush-stats-holder tr td:first-child {
508
 
509
  .wp-smush-page-header {
510
  overflow: hidden;
511
- padding: 10px 0 0;
512
  margin: 0 0 20px;
513
  width: 100%;
514
  }
@@ -538,7 +582,6 @@ table.wp-smush-stats-holder tr td:first-child {
538
  .wp-smush-premium .smush-container-subheading {
539
  border: solid 1px #ff6d6d;
540
  border-radius: 4px;
541
- float: none;
542
  font-size: 12px;
543
  line-height: 1.4;
544
  margin: 1.3em 10px;
@@ -546,6 +589,14 @@ table.wp-smush-stats-holder tr td:first-child {
546
  vertical-align: top;
547
  }
548
 
 
 
 
 
 
 
 
 
549
  .wpmud .wp-smush-premium .smush-container-subheading a {
550
  color: #ff6d6d;
551
  }
@@ -555,9 +606,8 @@ table.wp-smush-stats-holder tr td:first-child {
555
  max-width: 90%;
556
  }
557
 
558
- .wpmud .row .col-two-third.wp-smushit-container-left {
559
  padding-left: 0;
560
- width: 62%;
561
  }
562
 
563
  .wp-smush-premium .box-content {
@@ -700,10 +750,6 @@ table.wp-smush-stats-holder tr td:first-child {
700
  width: 14px;
701
  }
702
 
703
- .wpmud .dev-box.bulk-smush-wrapper:not(.wp-smush-pro-install) {
704
- padding-bottom: 0;
705
- }
706
-
707
  .wpmud .bulk-smush-wrapper .dev-icon {
708
  margin-right: 10px;
709
  vertical-align: top;
@@ -715,11 +761,11 @@ table.wp-smush-stats-holder tr td:first-child {
715
 
716
  .bulk-smush-wrapper .wp-smush-notice-text {
717
  display: inline-block;
718
- max-width: 90%;
719
  }
720
 
721
  .bulk-smush-wrapper .wp-smush-all {
722
- margin: 20px 0;
723
  }
724
 
725
  .bulk-smush-wrapper .wp-smush-remaining .wp-smush-skip-resmush {
@@ -823,6 +869,7 @@ table.wp-smush-stats-holder tr td:first-child {
823
  .wpmud .wp-smush-enable-lossy {
824
  color: #adadad;
825
  font-size: 13px;
 
826
  }
827
 
828
  /** Settings Styling **/
@@ -840,12 +887,16 @@ small.smush-setting-description {
840
 
841
  /** Stats Container **/
842
  .wpmud .smush-stats-wrapper {
843
- color: #777771;
844
  font-size: 15px;
845
  font-family: 'Roboto Condensed', sans-serif;
846
  font-weight: 700;
847
  }
848
 
 
 
 
 
849
  .wp-smush-lossy-disabled {
850
  color: #adadad;
851
  background: #fafafa;
@@ -854,27 +905,36 @@ small.smush-setting-description {
854
  padding: 10px;
855
  }
856
 
857
- .wpmud .wp-smush-stats .button-small.wp-smush-lossy-enable {
858
  border-radius: 3px;
859
  font: 500 11px/20px 'Roboto';
860
  padding: 5px 8px;
861
  vertical-align: top;
862
  }
863
 
864
- .wp-smush-lossy-enable:hover, .wp-smush-lossy-enable:active, .wp-smush-lossy-enable:focus {
 
865
  background-color: #0093B1;
866
  color: #FFF;
867
  box-shadow: none;
 
 
868
  }
869
 
870
  .wpmud .wp-smush-stats, .wp-smush-stats-wrap {
871
  color: #555555;
872
  font-family: 'Roboto Condensed', sans-serif;
873
  font-size: 25px;
 
874
  line-height: 1;
875
  padding: 5px 0;
876
  }
877
 
 
 
 
 
 
878
  .wpmud .wp-smush-lossy-disabled-wrap {
879
  padding: 0;
880
  }
@@ -885,21 +945,46 @@ small.smush-setting-description {
885
  }
886
 
887
  .wpmud .wp-smush-stats-label {
888
- padding-top: 7px;
889
  }
890
 
891
  .wp-smush-stats-label .wdv-icon.wdv-icon-question-sign {
892
  margin-left: 3px;
893
  }
894
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
895
  .wp-smush-total-thumbnails .dashicons-editor-help {
 
896
  margin-top: -2px;
897
  }
898
 
899
  /** For Smush Pro Promo and Humming Bird promo **/
900
- .wpmud .wp-smushit-container-right .wp-smush-pro-adv {
 
 
 
 
 
 
901
  overflow: hidden;
902
- padding: 30px 0 0;
903
  }
904
 
905
  .wpmud .dev-box.wp-smush-pro-adv .wp-smush-container-header {
@@ -916,16 +1001,19 @@ small.smush-setting-description {
916
  display: block;
917
  }
918
 
919
- .wp-smush-pro-cta, .wp-smush-hb-cta {
920
  overflow: hidden;
921
  display: block;
922
  padding: 20px;
923
  }
924
 
925
  .wp-smush-hb-cta {
 
 
 
926
  padding-bottom: 0;
927
  padding-top: 30px;
928
- width: 100%;
929
  }
930
 
931
  .wp-smush-hummingbird-image {
@@ -938,7 +1026,6 @@ small.smush-setting-description {
938
  color: #555555;
939
  line-height: 1.7;
940
  margin: auto;
941
- max-width: 320px;
942
  text-align: center;
943
  }
944
 
@@ -1046,7 +1133,7 @@ small.smush-setting-description {
1046
 
1047
  /** Media Queries for resolution below 782px **/
1048
  @media only screen and (max-width: 800px) {
1049
- .wpmud .wp-smushit-container-wrap .col-two-third.wp-smushit-container-left, .wpmud .wp-smushit-container-wrap .col-third.wp-smushit-container-right {
1050
  padding: 0;
1051
  width: 100%;
1052
  }
@@ -1066,6 +1153,39 @@ small.smush-setting-description {
1066
  }
1067
  }
1068
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1069
  /** For Media Gallery and Other WordPress pages **/
1070
  /** No Caps for the tooltips **/
1071
  .wp-admin.wpmud [tooltip]:after {
@@ -1245,7 +1365,7 @@ small.smush-setting-description {
1245
  opacity: 0;
1246
  }
1247
 
1248
- .wp-smush-resize-settings-wrap {
1249
  background: rgba(0, 0, 0, 0.05);
1250
  border-radius: 5px;
1251
  color: #555;
@@ -1256,27 +1376,42 @@ small.smush-setting-description {
1256
  vertical-align: middle;
1257
  }
1258
 
 
 
 
 
 
 
1259
  .wpmud .wp-smush-resize-settings-wrap label {
1260
  display: inline-block;
1261
  margin-bottom: 0;
1262
  overflow: hidden;
1263
  }
1264
 
 
 
 
 
1265
  .wpmud .wp-smush-resize-settings-wrap label:first-child {
1266
  padding-left: 0;
1267
  }
1268
 
1269
- .wpmud .wp-smush-resize-settings-wrap .wp-smush-resize-input {
1270
  display: inline-block;
1271
  margin-left: 10px;
1272
  width: 120px;
1273
  }
1274
 
1275
- .wpmud .wp-smush-resize-input.error {
 
 
 
 
 
1276
  border-color: #fd8b8b;
1277
  }
1278
 
1279
- .wp-smush-size-info {
1280
  background: #e0f6fa;
1281
  border-radius: 5px;
1282
  font-size: 13px;
@@ -1288,4 +1423,111 @@ small.smush-setting-description {
1288
  .smush-final-log.notice.notice-warning {
1289
  max-height: 200px;
1290
  overflow: auto;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1291
  }
289
  }
290
 
291
  .wpmud .wp-smushit-container-right .smush-stats-wrapper .wp-smush-container-header {
292
+ margin-bottom: 0;
293
  }
294
 
295
  .smush-stats-wrapper td, .smush-stats-wrapper th {
301
  margin: 7px 8px 0;
302
  }
303
 
304
+ .smush-stats-wrapper .box-content {
305
+ margin-top: 20px;
306
+ }
307
+
308
+ .wp-smush-count-total {
309
+ display: inline-block;
310
+ line-height: 1;
311
+ margin-left: 15px;
312
+ overflow: hidden;
313
+ text-align: left;
314
+ }
315
+
316
+ .wp-smush-smush-stats-wrapper {
317
+ color: #555555;
318
+ font-size: 25px;
319
+ }
320
+
321
+ .total-stats-label {
322
+ color: #b9b9b9;
323
+ font-size: 12px;
324
+ }
325
+
326
+ .smush-total-savings.smush-total-reduction-percent {
327
+ text-align: center;
328
+ }
329
+
330
+ .smush-total-savings.smush-total-reduction-percent .wp-smush-stats-wrap {
331
+ display: inline-block;
332
+ max-width: 200px;
333
+ text-align: left;
334
+ vertical-align: middle;
335
+ }
336
+
337
+ .wp-smush-current-progress {
338
+ cursor: pointer;
339
+ margin: 0 auto;
340
+ width: 200px;
341
+ }
342
+
343
+ .wp-smushed-progress {
344
+ display: inline-block;
345
+ text-align: center;
346
+ vertical-align: bottom;
347
+ }
348
+
349
  table.wp-smush-stats-holder {
350
  border: 1px solid lightgray;
351
  border-collapse: collapse;
540
  float: right;
541
  font-size: 15px;
542
  line-height: 1.7;
543
+ margin: 1.2em auto;
544
  }
545
 
546
  .wp-smush-auto-disabled {
553
 
554
  .wp-smush-page-header {
555
  overflow: hidden;
 
556
  margin: 0 0 20px;
557
  width: 100%;
558
  }
582
  .wp-smush-premium .smush-container-subheading {
583
  border: solid 1px #ff6d6d;
584
  border-radius: 4px;
 
585
  font-size: 12px;
586
  line-height: 1.4;
587
  margin: 1.3em 10px;
589
  vertical-align: top;
590
  }
591
 
592
+ .wpmud .row .col-half.wp-smush-pro-for-free {
593
+ padding-left: 0;
594
+ }
595
+
596
+ .wpmud .row .col-half.wp-smush-pro-for-free .dev-box {
597
+ padding: 30px 0;
598
+ }
599
+
600
  .wpmud .wp-smush-premium .smush-container-subheading a {
601
  color: #ff6d6d;
602
  }
606
  max-width: 90%;
607
  }
608
 
609
+ .wpmud .row .col-half.wp-smushit-container-left {
610
  padding-left: 0;
 
611
  }
612
 
613
  .wp-smush-premium .box-content {
750
  width: 14px;
751
  }
752
 
 
 
 
 
753
  .wpmud .bulk-smush-wrapper .dev-icon {
754
  margin-right: 10px;
755
  vertical-align: top;
761
 
762
  .bulk-smush-wrapper .wp-smush-notice-text {
763
  display: inline-block;
764
+ max-width: 88%;
765
  }
766
 
767
  .bulk-smush-wrapper .wp-smush-all {
768
+ margin: 20px 0 0;
769
  }
770
 
771
  .bulk-smush-wrapper .wp-smush-remaining .wp-smush-skip-resmush {
869
  .wpmud .wp-smush-enable-lossy {
870
  color: #adadad;
871
  font-size: 13px;
872
+ margin-top: 20px;
873
  }
874
 
875
  /** Settings Styling **/
887
 
888
  /** Stats Container **/
889
  .wpmud .smush-stats-wrapper {
890
+ color: #555;
891
  font-size: 15px;
892
  font-family: 'Roboto Condensed', sans-serif;
893
  font-weight: 700;
894
  }
895
 
896
+ .wpmud .smush-stats-wrapper strong {
897
+ font-weight: 700;
898
+ }
899
+
900
  .wp-smush-lossy-disabled {
901
  color: #adadad;
902
  background: #fafafa;
905
  padding: 10px;
906
  }
907
 
908
+ .wpmud .wp-smush-stats .button-small.wp-smush-lossy-enable, .wpmud .wp-smush-stats .button-small.wp-smush-resize-enable {
909
  border-radius: 3px;
910
  font: 500 11px/20px 'Roboto';
911
  padding: 5px 8px;
912
  vertical-align: top;
913
  }
914
 
915
+ .wpmud .wp-smush-lossy-enable:hover, .wpmud .wp-smush-lossy-enable:active, .wpmud .wp-smush-lossy-enable:focus,
916
+ .wpmud .wp-smush-resize-enable:hover, .wpmud .wp-smush-resize-enable:active, .wpmud .wp-smush-resize-enable:focus {
917
  background-color: #0093B1;
918
  color: #FFF;
919
  box-shadow: none;
920
+ transform: none;
921
+ -webkit-transform: none;
922
  }
923
 
924
  .wpmud .wp-smush-stats, .wp-smush-stats-wrap {
925
  color: #555555;
926
  font-family: 'Roboto Condensed', sans-serif;
927
  font-size: 25px;
928
+ font-weight: 400;
929
  line-height: 1;
930
  padding: 5px 0;
931
  }
932
 
933
+ .wp-smush-stats-wrap .wp-smush-progress-text {
934
+ color: #b9b9b9;
935
+ font-size: 12px;
936
+ }
937
+
938
  .wpmud .wp-smush-lossy-disabled-wrap {
939
  padding: 0;
940
  }
945
  }
946
 
947
  .wpmud .wp-smush-stats-label {
948
+ padding-top: 9px;
949
  }
950
 
951
  .wp-smush-stats-label .wdv-icon.wdv-icon-question-sign {
952
  margin-left: 3px;
953
  }
954
 
955
+ .wpmud .wp-smush-stats-try-pro {
956
+ border: solid 1px #ff6d6d;
957
+ border-radius: 4px;
958
+ font-size: 12px;
959
+ font-weight: 500;
960
+ margin-left: 15px;
961
+ padding: 7px;
962
+ vertical-align: top;
963
+ }
964
+
965
+ .wpmud .wp-smush-stats-try-pro a, .wpmud .wp-smush-stats-try-pro a:focus {
966
+ color: #ff6d6d;
967
+ }
968
+
969
+ .wpmud .wp-smush-stats-try-pro a:hover {
970
+ color: #ff6d6d;
971
+ cursor: pointer;
972
+ }
973
+
974
  .wp-smush-total-thumbnails .dashicons-editor-help {
975
+ cursor: pointer;
976
  margin-top: -2px;
977
  }
978
 
979
  /** For Smush Pro Promo and Humming Bird promo **/
980
+ .wpmud .wp-smush-pro-adv {
981
+ background-image: url(../images/dev-team.png);
982
+ background-repeat: no-repeat;
983
+ background-position: center bottom;
984
+ background-size: 90%;
985
+ height: 500px;
986
+ margin-top: 8px;
987
  overflow: hidden;
 
988
  }
989
 
990
  .wpmud .dev-box.wp-smush-pro-adv .wp-smush-container-header {
1001
  display: block;
1002
  }
1003
 
1004
+ .wp-smush-pro-cta {
1005
  overflow: hidden;
1006
  display: block;
1007
  padding: 20px;
1008
  }
1009
 
1010
  .wp-smush-hb-cta {
1011
+ display: block;
1012
+ margin: 0 auto;
1013
+ overflow: hidden;
1014
  padding-bottom: 0;
1015
  padding-top: 30px;
1016
+ width: 242px;
1017
  }
1018
 
1019
  .wp-smush-hummingbird-image {
1026
  color: #555555;
1027
  line-height: 1.7;
1028
  margin: auto;
 
1029
  text-align: center;
1030
  }
1031
 
1133
 
1134
  /** Media Queries for resolution below 782px **/
1135
  @media only screen and (max-width: 800px) {
1136
+ .wpmud .wp-smushit-container-wrap .col-half.wp-smushit-container-left, .wpmud .wp-smushit-container-wrap .col-half.wp-smushit-container-right {
1137
  padding: 0;
1138
  width: 100%;
1139
  }
1153
  }
1154
  }
1155
 
1156
+ @media screen and (max-width: 750px) {
1157
+ .wpmud .dev-box#wp-smush-share-widget {
1158
+ background-position: 30px 45px;
1159
+ }
1160
+ }
1161
+
1162
+ @media screen and (max-width: 650px) {
1163
+ .wpmud .dev-box#wp-smush-share-widget {
1164
+ background-image: none;
1165
+ }
1166
+
1167
+ .wpmud #wp-smush-share-widget .box-content {
1168
+ margin-left: 0;
1169
+ padding: 20px;
1170
+ }
1171
+
1172
+ .wpmud .button.wp-smush-share-button,
1173
+ .wpmud a + .button.wp-smush-share-button {
1174
+ margin-bottom: 10px;
1175
+ margin-left: 0;
1176
+ text-align: center;
1177
+ width: 100%;
1178
+ }
1179
+
1180
+ .wpmud .button.wp-smush-share-button .dev-icon {
1181
+ float: left;
1182
+ }
1183
+
1184
+ .wpmud #wp-smush-whatsapp-share {
1185
+ display: inline-block;
1186
+ }
1187
+ }
1188
+
1189
  /** For Media Gallery and Other WordPress pages **/
1190
  /** No Caps for the tooltips **/
1191
  .wp-admin.wpmud [tooltip]:after {
1365
  opacity: 0;
1366
  }
1367
 
1368
+ .wp-smush-resize-settings-wrap, .wp-smush-png_to_jpg-wrap, .wp-smush-image-size-list {
1369
  background: rgba(0, 0, 0, 0.05);
1370
  border-radius: 5px;
1371
  color: #555;
1376
  vertical-align: middle;
1377
  }
1378
 
1379
+ .wpmud .wp-smush-image-size-list label {
1380
+ clear: left;
1381
+ float: left;
1382
+ font-size: 13px;
1383
+ }
1384
+
1385
  .wpmud .wp-smush-resize-settings-wrap label {
1386
  display: inline-block;
1387
  margin-bottom: 0;
1388
  overflow: hidden;
1389
  }
1390
 
1391
+ .wpmud .wp-smush-png_to_jpg-wrap label {
1392
+ font-weight: 400;
1393
+ }
1394
+
1395
  .wpmud .wp-smush-resize-settings-wrap label:first-child {
1396
  padding-left: 0;
1397
  }
1398
 
1399
+ .wpmud .wp-smush-resize-settings-wrap .wp-smush-resize-input, .wpmud .wp-smush-png_to_jpg-wrap .wp-smush-png_to_jpg_background {
1400
  display: inline-block;
1401
  margin-left: 10px;
1402
  width: 120px;
1403
  }
1404
 
1405
+ .wpmud .wp-smush-png_to_jpg-wrap .wp-smush-png_to_jpg_background {
1406
+ margin-left: 0;
1407
+ width: 100px;
1408
+ }
1409
+
1410
+ .wpmud .wp-smush-resize-input.error, .wpmud #png_to_jpg_background.error {
1411
  border-color: #fd8b8b;
1412
  }
1413
 
1414
+ .wp-smush-settings-info {
1415
  background: #e0f6fa;
1416
  border-radius: 5px;
1417
  font-size: 13px;
1423
  .smush-final-log.notice.notice-warning {
1424
  max-height: 200px;
1425
  overflow: auto;
1426
+ }
1427
+
1428
+ /** Hide W3TC notice on smush pages, it breaks them all **/
1429
+ .wpmud #edge-mode {
1430
+ display: none;
1431
+ }
1432
+
1433
+ .smush-page-wrap {
1434
+ margin: 10px 20px 0 2px;
1435
+ }
1436
+
1437
+ /** Circle Style **/
1438
+ .wp-smush-stats-graph {
1439
+ display: inline-block;
1440
+ }
1441
+
1442
+ .wp-smush-progress-circle {
1443
+ border-radius: 100%;
1444
+ display: block;
1445
+ height: 50px;
1446
+ position: relative;
1447
+ width: 50px;
1448
+ }
1449
+
1450
+ .wp-smush-progress-circle .wp-smush-svg-circle {
1451
+ stroke: #E5E5E5;
1452
+ stroke-dashoffset: 80;
1453
+ stroke-width: 5px;
1454
+ -ms-transition: stroke-dashoffset 1s linear;
1455
+ -moz-transition: stroke-dashoffset 1s linear;
1456
+ -webkit-transition: stroke-dashoffset 1s linear;
1457
+ transition: stroke-dashoffset 1s linear;
1458
+ }
1459
+
1460
+ .wp-smush-progress-circle .wp-smush-svg-circle-progress {
1461
+ transform: rotate(-80deg) translateX(-45px) translateY(4px);
1462
+ -moz-transform: rotate(-80deg) translateX(-45px) translateY(4px);
1463
+ -webkit-transform: rotate(-80deg) translateX(-45px) translateY(4px);
1464
+ }
1465
+
1466
+ .wp-smush-optimisation-progress {
1467
+ color: #28B576;
1468
+ cursor: pointer;
1469
+ position: relative;
1470
+ }
1471
+
1472
+ .wp-smush-optimisation-progress .wp-smush-progress-circle .wp-smush-svg-circle-progress {
1473
+ stroke: #28B576;
1474
+ }
1475
+
1476
+ .wpmud #wp-smush-share-widget {
1477
+ background-image: url(../images/share-bg-small.png);
1478
+ background-repeat: no-repeat;
1479
+ background-position: 30px 24px;
1480
+ min-height: 144px;
1481
+ padding: 21px;
1482
+ }
1483
+
1484
+ #wp-smush-share-widget .box-content {
1485
+ color: #767676;
1486
+ font-size: 15px;
1487
+ font-weight: 400;
1488
+ line-height: 1.5;
1489
+ margin-left: 158px;
1490
+ }
1491
+
1492
+ #wp-smush-twitter-share {
1493
+ background: #1da1f2;
1494
+ }
1495
+
1496
+ #wp-smush-facebook-share {
1497
+ background: #3b5998;
1498
+ }
1499
+
1500
+ #wp-smush-whatsapp-share {
1501
+ background-color: #00ba00;
1502
+ background-image: url(../images/whatsapp-button-16px.png);
1503
+ background-repeat: no-repeat;
1504
+ background-position: 20px 12px;
1505
+ display: none;
1506
+ padding-left: 47px;
1507
+ }
1508
+
1509
+ .wp-smush-share-buttons-wrapper {
1510
+ margin-top: 20px;
1511
+ overflow: hidden;
1512
+ }
1513
+
1514
+ .wpmud .button.wp-smush-share-button {
1515
+ font-weight: 400;
1516
+ }
1517
+
1518
+ .wp-smush-share-button .dev-icon {
1519
+ margin-right: 12px;
1520
+ }
1521
+
1522
+ .wpmud .wp-smush-share-message {
1523
+ font-weight: 500;
1524
+ }
1525
+
1526
+ /** Override WP Footer Styling, Hide it on WPMU pages only, if we really need to **/
1527
+ .wp-admin #wpfooter {
1528
+ display: block;
1529
+ }
1530
+
1531
+ .wpmud #wpfooter {
1532
+ display: none;
1533
  }
assets/images/share-bg-small.png ADDED
Binary file
assets/images/smush-no-media.png ADDED
Binary file
assets/images/smush-share-widget.png ADDED
Binary file
assets/images/whatsapp-button-14px.png ADDED
Binary file
assets/images/whatsapp-button-16px.png ADDED
Binary file
assets/js/wp-smushit-admin.js CHANGED
@@ -27,6 +27,34 @@ var progress_bar = function (cur_ele, txt, state) {
27
  progress_button.hide();
28
  }
29
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  jQuery(function ($) {
31
  var smushAddParams = function (url, data) {
32
  if (!$.isEmptyObject(data)) {
@@ -70,7 +98,7 @@ jQuery(function ($) {
70
  this.deferred.errors = [];
71
 
72
  //If button has resmush class, and we do have ids that needs to resmushed, put them in the list
73
- this.ids = wp_smushit_data.resmush.length > 0 && !skip_resmush ? ( wp_smushit_data.unsmushed.length > 0 ? wp_smushit_data.resmush.concat(wp_smushit_data.unsmushed) : wp_smushit_data.resmush ): wp_smushit_data.unsmushed;
74
 
75
  this.is_bulk_resmush = wp_smushit_data.resmush.length > 0 && !skip_resmush ? true : false;
76
 
@@ -160,8 +188,12 @@ jQuery(function ($) {
160
  self.$button.remove();
161
  } else {
162
  self.$status.addClass("error");
 
 
 
 
 
163
  }
164
- self.$status.html(response.data.status);
165
  //Check if stats div exists
166
  var parent = self.$status.parent();
167
  var stats_div = parent.find('.smush-stats-wrapper');
@@ -259,7 +291,7 @@ jQuery(function ($) {
259
  if (wp_smushit_data.resmush.length > 0) {
260
  //Update the Count
261
  $('.wp-smush-images-remaining').html(wp_smushit_data.resmush.length);
262
- } else if (wp_smushit_data.resmush.length == 0 && this.ids.length == 0 ) {
263
  //If all images are resmushed, show the All Smushed message
264
 
265
  //Show All Smushed
@@ -286,8 +318,8 @@ jQuery(function ($) {
286
  }
287
 
288
  //Update Total Images Tooltip
289
- if( 'undefined' !== typeof _res.data.stats.tooltip_text && '' != _res.data.stats.tooltip_text ) {
290
- $('.wp-smush-stats .smushed-count').attr('tooltip', _res.data.stats.tooltip_text );
291
  }
292
 
293
  //Update remaining count
@@ -296,15 +328,33 @@ jQuery(function ($) {
296
  //if we have received the progress data, update the stats else skip
297
  if ('undefined' != typeof _res.data.stats) {
298
 
 
 
299
  //Update stats
300
- $('.smush-total-reduction-percent .wp-smush-stats').html(_res.data.stats.percent);
301
- $('.smush-total-reduction-bytes .wp-smush-stats').html(_res.data.stats.human);
302
 
303
- $('.smush-attachments .wp-smush-stats .smushed-count, .wp-smush-images-smushed').html(_res.data.stats.smushed);
304
  if ($('.super-smush-attachments .smushed-count').length && 'undefined' != typeof _res.data.stats.super_smushed) {
305
  $('.super-smush-attachments .smushed-count').html(_res.data.stats.super_smushed);
306
  }
307
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  // increase the progress bar
309
  this._update_progress(_res.data.stats.smushed, progress);
310
  }
@@ -351,7 +401,7 @@ jQuery(function ($) {
351
  this.current_id = this.is_bulk ? this.ids.shift() : this.$button.data("id"); //remove from array while processing so we can continue where left off
352
 
353
  //Remove the id from respective variable as well
354
- this.update_smush_ids( this.current_id );
355
 
356
  var nonce_field = this.$button.parent().find('#_wp_smush_nonce');
357
  if (nonce_field) {
@@ -465,7 +515,7 @@ jQuery(function ($) {
465
  * Remove the current id from unsmushed/resmush variable
466
  * @param current_id
467
  */
468
- this.update_smush_ids = function( current_id ) {
469
  if ('undefined' !== typeof wp_smushit_data.unsmushed && wp_smushit_data.unsmushed.length > 0) {
470
  var u_index = wp_smushit_data.unsmushed.indexOf(current_id);
471
  if (u_index > -1) {
@@ -547,7 +597,7 @@ jQuery(function ($) {
547
  * @param smush_action
548
  * @returns {boolean}
549
  */
550
- var process_smush_action = function (e, current_button, smush_action) {
551
 
552
  //If disabled
553
  if ('disabled' == current_button.attr('disabled')) {
@@ -572,12 +622,12 @@ jQuery(function ($) {
572
  //Reduce the opacity of stats and disable the click
573
  disable_links(current_button);
574
 
575
- progress_bar(current_button, wp_smush_msgs.smushing, 'show');
576
 
577
  //Restore the image
578
  $.post(ajaxurl, params, function (r) {
579
 
580
- progress_bar(current_button, wp_smush_msgs.smushing, 'hide');
581
 
582
  //reset all functionality
583
  enable_links(current_button);
@@ -629,7 +679,7 @@ jQuery(function ($) {
629
  }
630
 
631
  //Check for width
632
- if ( !height_only && 'undefined' != typeof width_input && parseInt(wp_smushit_data.resize_sizes.width) > parseInt(width_input.val())) {
633
  width_input.addClass('error');
634
  width_error_note.show('slow');
635
  width_error = true;
@@ -753,28 +803,28 @@ jQuery(function ($) {
753
  $('body').on('click', '.wp-smush-action.wp-smush-restore', function (e) {
754
  var current_button = $(this);
755
  var smush_action = 'smush_restore_image';
756
- process_smush_action(e, current_button, smush_action);
757
  });
758
 
759
  /** Resmush: Media Library **/
760
  $('body').on('click', '.wp-smush-action.wp-smush-resmush', function (e) {
761
  var current_button = $(this);
762
  var smush_action = 'smush_resmush_image';
763
- process_smush_action(e, current_button, smush_action);
764
  });
765
 
766
  /** Restore: NextGen Gallery **/
767
  $('body').on('click', '.wp-smush-action.wp-smush-nextgen-restore', function (e) {
768
  var current_button = $(this);
769
  var smush_action = 'smush_restore_nextgen_image';
770
- process_smush_action(e, current_button, smush_action);
771
  });
772
 
773
  /** Resmush: NextGen Gallery **/
774
  $('body').on('click', '.wp-smush-action.wp-smush-nextgen-resmush', function (e) {
775
  var current_button = $(this);
776
  var smush_action = 'smush_resmush_nextgen_image';
777
- process_smush_action(e, current_button, smush_action);
778
  });
779
 
780
  //Scan For resmushing images
@@ -831,7 +881,7 @@ jQuery(function ($) {
831
  var smushed_count = wp_smushit_data.count_smushed - r.data.resmush_ids.length;
832
 
833
  //Update it in stats bar
834
- $('.smush-attachments .wp-smush-stats .smushed-count, .wp-smush-images-smushed').html(smushed_count);
835
 
836
  //Hide the Existing wrapper
837
  var notices = $('.bulk-smush-wrapper .wp-smush-notice');
@@ -844,9 +894,9 @@ jQuery(function ($) {
844
  //Show Bulk wrapper
845
  $('.wp-smush-bulk-wrapper').show();
846
 
847
- if( 'undefined' !== typeof r.data.count ) {
848
  //Update progress bar
849
- update_progress_bar_resmush( r.data.count );
850
  }
851
  }
852
  //If content is received, Prepend it
@@ -861,13 +911,13 @@ jQuery(function ($) {
861
  $('.smush-final-log').hide();
862
 
863
  //Hide Super Smush notice if it's enabled in media settings
864
- if ('undefined' != typeof r.data.super_smush && r.data.super_smush ) {
865
  var enable_lossy = jQuery('.wp-smush-enable-lossy');
866
- if( enable_lossy.length > 0 ) {
867
  enable_lossy.remove();
868
  }
869
- if( 'undefined' !== r.data.super_smush_stats ) {
870
- $('.super-smush-attachments .wp-smush-stats').html( r.data.super_smush_stats );
871
  }
872
  }
873
  }
@@ -925,13 +975,28 @@ jQuery(function ($) {
925
  var keep_exif = document.getElementById("wp-smush-keep_exif");
926
  var super_smush = document.getElementById("wp-smush-lossy");
927
  var smush_original = document.getElementById("wp-smush-original");
 
 
928
 
929
  var update_button_txt = true;
930
 
 
 
931
  //If Preserve Exif is Checked, and all other settings are off, just save the settings
932
- if (keep_exif.checked && !super_smush.checked && !smush_original.checked) {
933
  update_button_txt = false;
934
  }
 
 
 
 
 
 
 
 
 
 
 
935
 
936
  //Update text
937
  self.attr('disabled', 'disabled').addClass('button-grey');
@@ -998,7 +1063,7 @@ jQuery(function ($) {
998
  type = 'undefined' == typeof type ? 'media' : type;
999
 
1000
  var smushed_count = 'undefined' != typeof wp_smushit_data.count_smushed ? wp_smushit_data.count_smushed : 0
1001
- $('.smush-attachments .wp-smush-stats .smushed-count, .wp-smush-images-smushed').html(smushed_count);
1002
 
1003
  //Update the Progress Bar Width
1004
  // get the progress bar
@@ -1034,6 +1099,17 @@ jQuery(function ($) {
1034
  $('#wp-smush-save-settings').click();
1035
  });
1036
 
 
 
 
 
 
 
 
 
 
 
 
1037
  //Trigger Bulk
1038
  $('body').on('click', '.wp-smush-trigger-bulk', function (e) {
1039
  e.preventDefault();
@@ -1066,7 +1142,7 @@ jQuery(function ($) {
1066
  });
1067
 
1068
  //Handle Resize Checkbox toggle, to show/hide width, height settings
1069
- $('#wp-smush-resize').click(function() {
1070
  var self = $(this);
1071
  var settings_wrap = $('.wp-smush-resize-settings-wrap');
1072
 
@@ -1076,7 +1152,68 @@ jQuery(function ($) {
1076
  settings_wrap.hide();
1077
  }
1078
  });
 
 
 
 
1079
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1080
 
1081
  });
1082
  (function ($) {
27
  progress_button.hide();
28
  }
29
  };
30
+
31
+ var dash_offset = function (percent) {
32
+ //Get the dasharray value
33
+ var dasharray = jQuery('.wp-smush-svg-circle-progress').attr('stroke-dasharray');
34
+ return dasharray - ( dasharray * percent );
35
+ }
36
+
37
+ var update_dashoffset = function (stats) {
38
+ if (stats.total > 0) {
39
+ var dashoffset = dash_offset(stats.smushed / stats.total);
40
+ var circle_progress = jQuery('.wp-smush-svg-circle-progress');
41
+ if (typeof dashoffset != 'undefined' && circle_progress.length) {
42
+ circle_progress.css({'stroke-dashoffset': dashoffset});
43
+ }
44
+ }
45
+ }
46
+ /**
47
+ * Resize Background width
48
+ */
49
+ var resize_width = function () {
50
+ var width = jQuery('.wp-smush-pro-for-free').width();
51
+ if ('undefined' != typeof ( width ) && 500 < width) {
52
+ jQuery('.wpmud .wp-smush-pro-adv').css({'background-size': '500px'});
53
+ } else {
54
+ jQuery('.wpmud .wp-smush-pro-adv').css({'background-size': '90%'});
55
+ }
56
+ }
57
+
58
  jQuery(function ($) {
59
  var smushAddParams = function (url, data) {
60
  if (!$.isEmptyObject(data)) {
98
  this.deferred.errors = [];
99
 
100
  //If button has resmush class, and we do have ids that needs to resmushed, put them in the list
101
+ this.ids = wp_smushit_data.resmush.length > 0 && !skip_resmush ? ( wp_smushit_data.unsmushed.length > 0 ? wp_smushit_data.resmush.concat(wp_smushit_data.unsmushed) : wp_smushit_data.resmush ) : wp_smushit_data.unsmushed;
102
 
103
  this.is_bulk_resmush = wp_smushit_data.resmush.length > 0 && !skip_resmush ? true : false;
104
 
188
  self.$button.remove();
189
  } else {
190
  self.$status.addClass("error");
191
+ self.$status.html(response.data.error_msg);
192
+ self.$status.show();
193
+ }
194
+ if (response.data.status) {
195
+ self.$status.html(response.data.status);
196
  }
 
197
  //Check if stats div exists
198
  var parent = self.$status.parent();
199
  var stats_div = parent.find('.smush-stats-wrapper');
291
  if (wp_smushit_data.resmush.length > 0) {
292
  //Update the Count
293
  $('.wp-smush-images-remaining').html(wp_smushit_data.resmush.length);
294
+ } else if (wp_smushit_data.resmush.length == 0 && this.ids.length == 0) {
295
  //If all images are resmushed, show the All Smushed message
296
 
297
  //Show All Smushed
318
  }
319
 
320
  //Update Total Images Tooltip
321
+ if ('undefined' !== typeof _res.data.stats.tooltip_text && '' != _res.data.stats.tooltip_text) {
322
+ $('.wp-smush-current-progress').attr('tooltip', _res.data.stats.tooltip_text);
323
  }
324
 
325
  //Update remaining count
328
  //if we have received the progress data, update the stats else skip
329
  if ('undefined' != typeof _res.data.stats) {
330
 
331
+ update_dashoffset(_res.data.stats);
332
+
333
  //Update stats
334
+ $('.wp-smush-savings .wp-smush-stats-percent').html(_res.data.stats.percent);
335
+ $('.wp-smush-savings .wp-smush-stats-human').html(_res.data.stats.human);
336
 
337
+ $('.wp-smush-images-smushed, .wp-smush-optimised').html(_res.data.stats.smushed);
338
  if ($('.super-smush-attachments .smushed-count').length && 'undefined' != typeof _res.data.stats.super_smushed) {
339
  $('.super-smush-attachments .smushed-count').html(_res.data.stats.super_smushed);
340
  }
341
 
342
+ var smush_conversion_savings = $('.smush-conversion-savings');
343
+ //Update Conversion Savings
344
+ if (smush_conversion_savings.length > 0 && 'undefined' != typeof ( _res.data.stats.conversion_savings ) && _res.data.stats.conversion_savings != '') {
345
+ var conversion_savings = smush_conversion_savings.find('.wp-smush-stats');
346
+ if (conversion_savings.length > 0) {
347
+ conversion_savings.html(_res.data.stats.conversion_savings);
348
+ }
349
+ }
350
+ var smush_resize_savings = $('.smush-resize-savings');
351
+ //Update Resize Savings
352
+ if (smush_resize_savings.length > 0 && 'undefined' != typeof ( _res.data.stats.resize_savings ) && _res.data.stats.resize_savings != '') {
353
+ var resize_savings = smush_resize_savings.find('.wp-smush-stats');
354
+ if (resize_savings.length > 0) {
355
+ resize_savings.html(_res.data.stats.resize_savings);
356
+ }
357
+ }
358
  // increase the progress bar
359
  this._update_progress(_res.data.stats.smushed, progress);
360
  }
401
  this.current_id = this.is_bulk ? this.ids.shift() : this.$button.data("id"); //remove from array while processing so we can continue where left off
402
 
403
  //Remove the id from respective variable as well
404
+ this.update_smush_ids(this.current_id);
405
 
406
  var nonce_field = this.$button.parent().find('#_wp_smush_nonce');
407
  if (nonce_field) {
515
  * Remove the current id from unsmushed/resmush variable
516
  * @param current_id
517
  */
518
+ this.update_smush_ids = function (current_id) {
519
  if ('undefined' !== typeof wp_smushit_data.unsmushed && wp_smushit_data.unsmushed.length > 0) {
520
  var u_index = wp_smushit_data.unsmushed.indexOf(current_id);
521
  if (u_index > -1) {
597
  * @param smush_action
598
  * @returns {boolean}
599
  */
600
+ var process_smush_action = function (e, current_button, smush_action, action) {
601
 
602
  //If disabled
603
  if ('disabled' == current_button.attr('disabled')) {
622
  //Reduce the opacity of stats and disable the click
623
  disable_links(current_button);
624
 
625
+ progress_bar(current_button, wp_smush_msgs[action], 'show');
626
 
627
  //Restore the image
628
  $.post(ajaxurl, params, function (r) {
629
 
630
+ progress_bar(current_button, wp_smush_msgs[action], 'hide');
631
 
632
  //reset all functionality
633
  enable_links(current_button);
679
  }
680
 
681
  //Check for width
682
+ if (!height_only && 'undefined' != typeof width_input && parseInt(wp_smushit_data.resize_sizes.width) > parseInt(width_input.val())) {
683
  width_input.addClass('error');
684
  width_error_note.show('slow');
685
  width_error = true;
803
  $('body').on('click', '.wp-smush-action.wp-smush-restore', function (e) {
804
  var current_button = $(this);
805
  var smush_action = 'smush_restore_image';
806
+ process_smush_action(e, current_button, smush_action, 'restore');
807
  });
808
 
809
  /** Resmush: Media Library **/
810
  $('body').on('click', '.wp-smush-action.wp-smush-resmush', function (e) {
811
  var current_button = $(this);
812
  var smush_action = 'smush_resmush_image';
813
+ process_smush_action(e, current_button, smush_action, 'smushing');
814
  });
815
 
816
  /** Restore: NextGen Gallery **/
817
  $('body').on('click', '.wp-smush-action.wp-smush-nextgen-restore', function (e) {
818
  var current_button = $(this);
819
  var smush_action = 'smush_restore_nextgen_image';
820
+ process_smush_action(e, current_button, smush_action, 'restore');
821
  });
822
 
823
  /** Resmush: NextGen Gallery **/
824
  $('body').on('click', '.wp-smush-action.wp-smush-nextgen-resmush', function (e) {
825
  var current_button = $(this);
826
  var smush_action = 'smush_resmush_nextgen_image';
827
+ process_smush_action(e, current_button, smush_action, 'smushing');
828
  });
829
 
830
  //Scan For resmushing images
881
  var smushed_count = wp_smushit_data.count_smushed - r.data.resmush_ids.length;
882
 
883
  //Update it in stats bar
884
+ $('.wp-smush-images-smushed, .wp-smush-optimised').html(smushed_count);
885
 
886
  //Hide the Existing wrapper
887
  var notices = $('.bulk-smush-wrapper .wp-smush-notice');
894
  //Show Bulk wrapper
895
  $('.wp-smush-bulk-wrapper').show();
896
 
897
+ if ('undefined' !== typeof r.data.count) {
898
  //Update progress bar
899
+ update_progress_bar_resmush(r.data.count);
900
  }
901
  }
902
  //If content is received, Prepend it
911
  $('.smush-final-log').hide();
912
 
913
  //Hide Super Smush notice if it's enabled in media settings
914
+ if ('undefined' != typeof r.data.super_smush && r.data.super_smush) {
915
  var enable_lossy = jQuery('.wp-smush-enable-lossy');
916
+ if (enable_lossy.length > 0) {
917
  enable_lossy.remove();
918
  }
919
+ if ('undefined' !== r.data.super_smush_stats) {
920
+ $('.super-smush-attachments .wp-smush-stats').html(r.data.super_smush_stats);
921
  }
922
  }
923
  }
975
  var keep_exif = document.getElementById("wp-smush-keep_exif");
976
  var super_smush = document.getElementById("wp-smush-lossy");
977
  var smush_original = document.getElementById("wp-smush-original");
978
+ var resize_images = document.getElementById("wp-smush-resize");
979
+ var smush_pngjpg = document.getElementById("wp-smush-png_to_jpg");
980
 
981
  var update_button_txt = true;
982
 
983
+ $('.wp-smush-hex-notice').hide();
984
+
985
  //If Preserve Exif is Checked, and all other settings are off, just save the settings
986
+ if (keep_exif.checked && !super_smush.checked && !smush_original.checked && !resize_images.checked && !smush_pngjpg.checked) {
987
  update_button_txt = false;
988
  }
989
+ //If PNG to JPEG conversion is enabled
990
+ if (smush_pngjpg.checked && document.getElementById('png_to_jpg_transparent').checked ) {
991
+ var jpg_bg = $('[name="wp-smush-png_to_jpg_background"]');
992
+ //Check the length of hex code
993
+ if (jpg_bg.val().length < 6) {
994
+ $('.wp-smush-hex-notice').show();
995
+ //Return false and add error class
996
+ jpg_bg.addClass('error');
997
+ return false;
998
+ }
999
+ }
1000
 
1001
  //Update text
1002
  self.attr('disabled', 'disabled').addClass('button-grey');
1063
  type = 'undefined' == typeof type ? 'media' : type;
1064
 
1065
  var smushed_count = 'undefined' != typeof wp_smushit_data.count_smushed ? wp_smushit_data.count_smushed : 0
1066
+ $('.wp-smush-images-smushed, .wp-smush-optimised').html(smushed_count);
1067
 
1068
  //Update the Progress Bar Width
1069
  // get the progress bar
1099
  $('#wp-smush-save-settings').click();
1100
  });
1101
 
1102
+ //Enable Resi
1103
+ $('.wp-smush-resize-enable').on('click', function (e) {
1104
+ e.preventDefault();
1105
+
1106
+ //Enable Super Smush
1107
+ $('#wp-smush-resize').prop('checked', true);
1108
+ //Induce Setting button save click
1109
+ $('#wp-smush-save-settings').click();
1110
+ });
1111
+
1112
+
1113
  //Trigger Bulk
1114
  $('body').on('click', '.wp-smush-trigger-bulk', function (e) {
1115
  e.preventDefault();
1142
  });
1143
 
1144
  //Handle Resize Checkbox toggle, to show/hide width, height settings
1145
+ $('#wp-smush-resize').click(function () {
1146
  var self = $(this);
1147
  var settings_wrap = $('.wp-smush-resize-settings-wrap');
1148
 
1152
  settings_wrap.hide();
1153
  }
1154
  });
1155
+ //Handle PNG to JPG Checkbox toggle, to show/hide Transparent image conversion settings
1156
+ $('#wp-smush-png_to_jpg').click(function () {
1157
+ var self = $(this);
1158
+ var settings_wrap = $('.wp-smush-png_to_jpg-wrap');
1159
 
1160
+ if (self.is(':checked')) {
1161
+ settings_wrap.show();
1162
+ } else {
1163
+ settings_wrap.hide();
1164
+ }
1165
+ });
1166
+
1167
+ //On background input remove class error
1168
+ $('#png_to_jpg_background').on('mouseup', function (e) {
1169
+ $(this).removeClass('error');
1170
+ });
1171
+
1172
+ //Handle Twitter Share
1173
+ $('#wp-smush-twitter-share').on('click', function (e) {
1174
+ e.preventDefault();
1175
+ var width = 550,
1176
+ height = 420,
1177
+ left = ($(window).width() - width) / 2,
1178
+ top = ($(window).height() - height) / 2,
1179
+ url = this.href,
1180
+ opts = 'status=1' +
1181
+ ',width=' + width +
1182
+ ',height=' + height +
1183
+ ',top=' + top +
1184
+ ',left=' + left;
1185
+
1186
+ window.open(url, 'twitter', opts);
1187
+
1188
+ return false;
1189
+ });
1190
+ $('#wp-smush-facebook-share').on('click', function (e) {
1191
+ e.preventDefault();
1192
+ var width = 550,
1193
+ height = 420,
1194
+ left = ($(window).width() - width) / 2,
1195
+ top = ($(window).height() - height) / 2,
1196
+ url = this.href,
1197
+ opts = 'status=1' +
1198
+ ',width=' + width +
1199
+ ',height=' + height +
1200
+ ',top=' + top +
1201
+ ',left=' + left;
1202
+
1203
+ window.open(url, 'facebook', opts);
1204
+
1205
+ return false;
1206
+ });
1207
+
1208
+ //Adjust background image size if required
1209
+ if( $('.wp-smush-pro-for-free').length ) {
1210
+ //On Page load
1211
+ resize_width();
1212
+ //Adjust background image
1213
+ $(window).resize(function () {
1214
+ resize_width();
1215
+ });
1216
+ }
1217
 
1218
  });
1219
  (function ($) {
assets/shared-ui/notice.css CHANGED
@@ -115,7 +115,6 @@
115
  z-index: 1;
116
  }
117
  .frash-notice .frash-notice-logo:after {
118
- animation: spin 30s linear infinite;
119
  background-color: rgba(0, 0, 0, 0);
120
  z-index: 2;
121
  }
115
  z-index: 1;
116
  }
117
  .frash-notice .frash-notice-logo:after {
 
118
  background-color: rgba(0, 0, 0, 0);
119
  z-index: 2;
120
  }
assets/shared-ui/notice.js CHANGED
@@ -3,20 +3,30 @@ jQuery(function() {
3
 
4
  // Display the notice after the page was loaded.
5
  function initialize() {
6
- if (! jQuery(".frash-notice:visible").length) {
7
- el_notice = jQuery(".frash-notice");
8
- msg_id = el_notice.find("input[name=msg_id]").val();
9
- btn_dismiss = el_notice.find(".frash-notice-dismiss");
10
-
11
- // Dismiss the notice without any action.
12
- btn_dismiss.click(function(ev) {
13
- ev.preventDefault();
14
- notify_wordpress("wdev_notice_dismiss", btn_dismiss.data("msg"));
15
- });
16
-
17
- // Display the notification.
18
- el_notice.fadeIn(500);
19
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  }
21
 
22
  // Hide the notice after a CTA button was clicked
@@ -48,5 +58,11 @@ jQuery(function() {
48
  }
49
  }
50
 
51
- window.setTimeout(initialize, 550);
 
 
 
 
 
 
52
  });
3
 
4
  // Display the notice after the page was loaded.
5
  function initialize() {
6
+ if (jQuery(".frash-notice:visible").length) {
7
+ // Free plugin already displayed a notification...
8
+ return;
 
 
 
 
 
 
 
 
 
 
9
  }
10
+ if ( jQuery(".frash-notice.active").length) {
11
+ // Some other premium plugin already displayed a notification...
12
+ return;
13
+ }
14
+
15
+ el_notice = jQuery(".frash-notice");
16
+ msg_id = el_notice.find("input[name=msg_id]").val();
17
+ btn_dismiss = el_notice.find(".frash-notice-dismiss");
18
+
19
+ // Mark this notification "active" before it's visible to avoid duplicates.
20
+ el_notice.addClass("active");
21
+
22
+ // Dismiss the notice without any action.
23
+ btn_dismiss.click(function(ev) {
24
+ ev.preventDefault();
25
+ notify_wordpress("wdev_notice_dismiss", btn_dismiss.data("msg"));
26
+ });
27
+
28
+ // Display the notification.
29
+ el_notice.fadeIn(500);
30
  }
31
 
32
  // Hide the notice after a CTA button was clicked
58
  }
59
  }
60
 
61
+ // Premium version uses a HIGHER delay than the notice in free plugins.
62
+ // So if any free plugin display a notice it will be displayed instead of
63
+ // the premium notice.
64
+ //
65
+ // 1050 ... free notice uses 500 delay + 500 fade in + 20 to let browser render the changes.
66
+ // So after 1020ms the free notice is considered "visible".
67
+ window.setTimeout(initialize, 1050);
68
  });
assets/shared-ui/plugin-ui.php CHANGED
@@ -15,7 +15,7 @@ if ( ! class_exists( 'WDEV_Plugin_Ui' ) ) {
15
  /**
16
  * Current module version.
17
  */
18
- const VERSION = '1.1';
19
 
20
  /**
21
  * Internal translation container.
@@ -71,10 +71,16 @@ if ( ! class_exists( 'WDEV_Plugin_Ui' ) ) {
71
  if ( ! did_action( 'admin_enqueue_scripts' ) ) {
72
  add_action(
73
  'admin_enqueue_scripts',
74
- array( __CLASS__, 'enqueue' )
 
 
 
 
 
75
  );
76
  } else {
77
  self::enqueue();
 
78
  }
79
  }
80
 
@@ -85,26 +91,67 @@ if ( ! class_exists( 'WDEV_Plugin_Ui' ) ) {
85
  * @internal Do not call this method manually. It's called by `load()`!
86
  */
87
  static public function enqueue() {
 
 
 
 
 
 
 
 
 
 
88
  wp_enqueue_style(
89
  'wdev-plugin-google_fonts',
90
  'https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700|Roboto:400,500,300,300italic',
91
  false,
92
- self::VERSION
 
 
 
 
 
 
 
93
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
 
95
  wp_enqueue_style(
96
  'wdev-plugin-ui',
97
  self::$module_url . 'wdev-ui.css',
98
  array( 'wdev-plugin-google_fonts' ),
99
- self::VERSION
100
  );
101
 
102
  wp_enqueue_script(
103
  'wdev-plugin-ui',
104
  self::$module_url . 'wdev-ui.js',
105
  array( 'jquery' ),
106
- self::VERSION
107
  );
 
 
 
 
 
 
108
  }
109
 
110
  /**
@@ -248,7 +295,7 @@ if ( ! class_exists( 'WDEV_Plugin_Ui' ) ) {
248
  </div>
249
  <?php if ( $show_actions ) : ?>
250
  <div class="frash-notice-cta">
251
- <?php echo wp_kses( $msg['cta'], $allowed ); ?>
252
  <?php if ( $msg['can_dismiss'] ) : ?>
253
  <button class="frash-notice-dismiss" data-msg="<?php echo esc_attr( $msg_dismiss ); ?>">
254
  <?php esc_html_e( 'Dismiss', 'wpmudev' ); ?>
15
  /**
16
  * Current module version.
17
  */
18
+ const VERSION = '1.0';
19
 
20
  /**
21
  * Internal translation container.
71
  if ( ! did_action( 'admin_enqueue_scripts' ) ) {
72
  add_action(
73
  'admin_enqueue_scripts',
74
+ array( __CLASS__, 'enqueue_early' )
75
+ );
76
+ add_action(
77
+ 'admin_enqueue_scripts',
78
+ array( __CLASS__, 'enqueue_late' ),
79
+ 999
80
  );
81
  } else {
82
  self::enqueue();
83
+ self::enqueue_late();
84
  }
85
  }
86
 
91
  * @internal Do not call this method manually. It's called by `load()`!
92
  */
93
  static public function enqueue() {
94
+ /*
95
+ * Beta-testers will not have cached scripts!
96
+ * Just in case we have to update the plugin prior to launch.
97
+ */
98
+ if ( defined( 'WPMUDEV_BETATEST' ) && WPMUDEV_BETATEST ) {
99
+ $script_version = time();
100
+ } else {
101
+ $script_version = self::VERSION;
102
+ }
103
+
104
  wp_enqueue_style(
105
  'wdev-plugin-google_fonts',
106
  'https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700|Roboto:400,500,300,300italic',
107
  false,
108
+ $script_version
109
+ );
110
+
111
+ wp_enqueue_style(
112
+ 'wdev-plugin-notice',
113
+ self::$module_url . 'notice.css',
114
+ array( 'wdev-plugin-google_fonts' ),
115
+ $script_version
116
  );
117
+ }
118
+
119
+ /**
120
+ * Enqueues the CSS and JS files after all other files.
121
+ *
122
+ * @since 1.0.0
123
+ * @internal Do not call this method manually. It's called by `load()`!
124
+ */
125
+ static public function enqueue_late() {
126
+ /*
127
+ * Beta-testers will not have cached scripts!
128
+ * Just in case we have to update the plugin prior to launch.
129
+ */
130
+ if ( defined( 'WPMUDEV_BETATEST' ) && WPMUDEV_BETATEST ) {
131
+ $script_version = time();
132
+ } else {
133
+ $script_version = self::VERSION;
134
+ }
135
 
136
  wp_enqueue_style(
137
  'wdev-plugin-ui',
138
  self::$module_url . 'wdev-ui.css',
139
  array( 'wdev-plugin-google_fonts' ),
140
+ $script_version
141
  );
142
 
143
  wp_enqueue_script(
144
  'wdev-plugin-ui',
145
  self::$module_url . 'wdev-ui.js',
146
  array( 'jquery' ),
147
+ $script_version
148
  );
149
+
150
+ /**
151
+ * Allow other plugins to enqueue css/js after shared-ui to
152
+ * overwrite certain definitions.
153
+ */
154
+ do_action( 'wpmudev_plugin_ui_enqueued' );
155
  }
156
 
157
  /**
295
  </div>
296
  <?php if ( $show_actions ) : ?>
297
  <div class="frash-notice-cta">
298
+ <?php echo $msg['cta']; ?>
299
  <?php if ( $msg['can_dismiss'] ) : ?>
300
  <button class="frash-notice-dismiss" data-msg="<?php echo esc_attr( $msg_dismiss ); ?>">
301
  <?php esc_html_e( 'Dismiss', 'wpmudev' ); ?>
assets/shared-ui/wdev-ui.css CHANGED
@@ -115,18 +115,18 @@
115
  font-family: 'Roboto', sans-serif;
116
  font-weight: 400;
117
  font-size: 15px;
118
- line-height: 21px;
119
  color: #777771;
120
  }
121
  .wpmud p small {
122
  font-size: 12.5px;
123
- line-height: 17px;
124
  display: inline-block;
125
  color: #555550;
126
  }
127
  .wpmud p big {
128
  font-size: 18px;
129
- line-height: 24px;
130
  display: inline-block;
131
  font-weight: 400;
132
  color: #888882;
@@ -161,10 +161,13 @@
161
  display: inline-block;
162
  margin: 0;
163
  }
164
- .wpmud #wpfooter {
165
  display: none;
166
  }
167
-
 
 
 
168
  .wpmud a {
169
  text-decoration: none;
170
  color: #19B4CF;
@@ -1061,8 +1064,8 @@
1061
  display: inline-block;
1062
  margin: 0;
1063
  border: 0;
1064
- border-radius: 5px;
1065
- -moz-border-radius: 5px;
1066
  cursor: pointer;
1067
  box-shadow: none;
1068
  -moz-transition: color 0.3s, opacity 0.3s;
@@ -1099,6 +1102,13 @@
1099
  background: linear-gradient(to bottom, #0082a1 0%,#008fae 100%);
1100
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0082a1', endColorstr='#008fae',GradientType=0 );
1101
  }
 
 
 
 
 
 
 
1102
  /* Variation: Green button */
1103
  .wpmud .button-green {
1104
  background: #1ABC9C;
@@ -1297,9 +1307,9 @@
1297
  padding: 7px 10px;
1298
  font-weight: 500;
1299
  font-family: 'Roboto', sans-serif;
1300
- font-size: 16px;
1301
  margin: 0 0 4px;
1302
- color: #777771;
1303
  }
1304
  .wpmud label.inline-label {
1305
  display: inline-block;
@@ -1663,7 +1673,7 @@
1663
  margin-left: -1px;
1664
  margin-right: -1px;
1665
  margin-top: -2px;
1666
- opacity: 0;
1667
  border-radius: 0 0 4px 4px;
1668
  font: 500 15px/25px 'Roboto';
1669
  transition-property: opacity, border-color;
@@ -1681,6 +1691,21 @@
1681
  opacity: 0.8;
1682
  transition-property: opacity;
1683
  transition-duration: 0.3s;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1684
  }
1685
  .wpmud .select-list-container .list-results li:last-child {
1686
  border-radius: 0 0 3px 3px;
@@ -1689,6 +1714,9 @@
1689
  background: #b5e6f8;
1690
  color: #3d464d;
1691
  }
 
 
 
1692
  .wpmud .select-list-container .list-results .current {
1693
  background: #FFF;
1694
  color: #19b4cf;
@@ -1724,8 +1752,9 @@
1724
  left: 0;
1725
  right: 0;
1726
  width: auto;
1727
- opacity: 1;
1728
- transition-duration: 0;
 
1729
  }
1730
  .wpmud .select-container.active:hover {
1731
  border-color: #DDD;
@@ -1826,6 +1855,7 @@
1826
  /* ****************************************************************************
1827
  * 19. ELEMENT: USER NOTIFICATIONS
1828
  */
 
1829
  .wpmud .update-notice,
1830
  .wpmud .wpmud-loading-info {
1831
  position: fixed;
@@ -1899,6 +1929,59 @@
1899
  .wpmud.folded .wpmud-loading-info {
1900
  left: 36px;
1901
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1902
 
1903
  /* ****************************************************************************
1904
  * 20. ELEMENT: SEARCH BOX
115
  font-family: 'Roboto', sans-serif;
116
  font-weight: 400;
117
  font-size: 15px;
118
+ line-height: 29px;
119
  color: #777771;
120
  }
121
  .wpmud p small {
122
  font-size: 12.5px;
123
+ line-height: 22px;
124
  display: inline-block;
125
  color: #555550;
126
  }
127
  .wpmud p big {
128
  font-size: 18px;
129
+ line-height: 28px;
130
  display: inline-block;
131
  font-weight: 400;
132
  color: #888882;
161
  display: inline-block;
162
  margin: 0;
163
  }
164
+ #wpfooter {
165
  display: none;
166
  }
167
+ .wpmud b,
168
+ .wpmud strong {
169
+ font-weight: 500;
170
+ }
171
  .wpmud a {
172
  text-decoration: none;
173
  color: #19B4CF;
1064
  display: inline-block;
1065
  margin: 0;
1066
  border: 0;
1067
+ border-radius: 3px;
1068
+ -moz-border-radius: 3px;
1069
  cursor: pointer;
1070
  box-shadow: none;
1071
  -moz-transition: color 0.3s, opacity 0.3s;
1102
  background: linear-gradient(to bottom, #0082a1 0%,#008fae 100%);
1103
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0082a1', endColorstr='#008fae',GradientType=0 );
1104
  }
1105
+ .wpmud a.disabled,
1106
+ .wpmud button.disabled,
1107
+ .wpmud .close.disabled,
1108
+ .wpmud .button.disabled {
1109
+ /* Do not handle click events while disabled */
1110
+ pointer-events: none;
1111
+ }
1112
  /* Variation: Green button */
1113
  .wpmud .button-green {
1114
  background: #1ABC9C;
1307
  padding: 7px 10px;
1308
  font-weight: 500;
1309
  font-family: 'Roboto', sans-serif;
1310
+ font-size: 15px;
1311
  margin: 0 0 4px;
1312
+ color: #555;
1313
  }
1314
  .wpmud label.inline-label {
1315
  display: inline-block;
1673
  margin-left: -1px;
1674
  margin-right: -1px;
1675
  margin-top: -2px;
1676
+ display: none;
1677
  border-radius: 0 0 4px 4px;
1678
  font: 500 15px/25px 'Roboto';
1679
  transition-property: opacity, border-color;
1691
  opacity: 0.8;
1692
  transition-property: opacity;
1693
  transition-duration: 0.3s;
1694
+ border-radius: 0 !important;
1695
+ cursor: pointer;
1696
+ }
1697
+ .wpmud .select-list-container .list-results .optgroup{
1698
+ cursor: default;
1699
+ }
1700
+ .wpmud .select-list-container .list-results .optgroup li{
1701
+ padding-left: 30px;
1702
+ cursor: pointer;
1703
+ }
1704
+ .wpmud .select-list-container .list-results .optgroup li.optgroup-label{
1705
+ padding-left: 10px;
1706
+ color: #ababab;
1707
+ cursor: default;
1708
+ pointer-events: none;
1709
  }
1710
  .wpmud .select-list-container .list-results li:last-child {
1711
  border-radius: 0 0 3px 3px;
1714
  background: #b5e6f8;
1715
  color: #3d464d;
1716
  }
1717
+ .wpmud .select-list-container .list-results .optgroup li.optgroup-label:hover{
1718
+ background: none;
1719
+ }
1720
  .wpmud .select-list-container .list-results .current {
1721
  background: #FFF;
1722
  color: #19b4cf;
1752
  left: 0;
1753
  right: 0;
1754
  width: auto;
1755
+ /*opacity: 1;*/
1756
+ display: block;
1757
+ transition-duration: 0ms;
1758
  }
1759
  .wpmud .select-container.active:hover {
1760
  border-color: #DDD;
1855
  /* ****************************************************************************
1856
  * 19. ELEMENT: USER NOTIFICATIONS
1857
  */
1858
+ /* Notice floating on top of the screen */
1859
  .wpmud .update-notice,
1860
  .wpmud .wpmud-loading-info {
1861
  position: fixed;
1929
  .wpmud.folded .wpmud-loading-info {
1930
  left: 36px;
1931
  }
1932
+ /* Inline notifications */
1933
+ .wpmud .inline-notice {
1934
+ position: relative;
1935
+ display: block;
1936
+ padding: 20px 30px;
1937
+ line-height: 20px;
1938
+ font-size: 15px;
1939
+ font-family: "Roboto", Arial, sans-serif;
1940
+ border-radius: 5px;
1941
+ margin: 30px 0;
1942
+ background: #EBFCFF;
1943
+ color: #14485F;
1944
+ border: 1px solid #B5D3E0;
1945
+ }
1946
+ .wpmud .inline-notice.ok {
1947
+ background: #1ABC9C;
1948
+ color: #ffffff;
1949
+ border: 0;
1950
+ }
1951
+ .wpmud .inline-notice.err {
1952
+ background: #FF6D6D;
1953
+ color: #ffffff;
1954
+ border: 0;
1955
+ }
1956
+ .wpmud .inline-notice button,
1957
+ .wpmud .inline-notice button:hover:not(:focus):not(:active),
1958
+ .wpmud .inline-notice .button,
1959
+ .wpmud .inline-notice .button:hover:not(:focus):not(:active) {
1960
+ background: transparent;
1961
+ border: 1px solid #14485F;
1962
+ color: #14485F;
1963
+ padding: 3px 14px;
1964
+ }
1965
+ .wpmud .inline-notice.ok button,
1966
+ .wpmud .inline-notice.ok .button,
1967
+ .wpmud .inline-notice.ok button:hover:not(:focus):not(:active),
1968
+ .wpmud .inline-notice.ok .button:hover:not(:focus):not(:active),
1969
+ .wpmud .inline-notice.err button,
1970
+ .wpmud .inline-notice.err .button,
1971
+ .wpmud .inline-notice.err button:hover:not(:focus):not(:active),
1972
+ .wpmud .inline-notice.err .button:hover:not(:focus):not(:active) {
1973
+ border-color: #fff;
1974
+ color: #fff;
1975
+ }
1976
+ .wpmud .inline-notice button:hover:not(:focus):not(:active),
1977
+ .wpmud .inline-notice button:focus,
1978
+ .wpmud .inline-notice button:active,
1979
+ .wpmud .inline-notice .button:hover:not(:focus):not(:active),
1980
+ .wpmud .inline-notice .button:focus,
1981
+ .wpmud .inline-notice .button:active {
1982
+ background: rgba(255,255,255,0.1);
1983
+ }
1984
+
1985
 
1986
  /* ****************************************************************************
1987
  * 20. ELEMENT: SEARCH BOX
assets/shared-ui/wdev-ui.js CHANGED
@@ -30,6 +30,9 @@ jQuery(function() {
30
  // Handle close buttons inside boxes.
31
  jQuery(".wpmud").on("click", ".can-close .close", closeElement);
32
 
 
 
 
33
  // Initialize all tab-areas.
34
  jQuery(".wpmud .tabs").each(function(){
35
  WDP.wpmuTabs(this);
@@ -96,6 +99,29 @@ jQuery(function() {
96
  return false;
97
  }
98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  // Select all text inside the element.
100
  function selectOnClick(ev) {
101
  WDP.selectText(this);
@@ -146,7 +172,7 @@ jQuery(function() {
146
 
147
  // Parses the hash-tag in the current address bar.
148
  function checkLocalRoutes() {
149
- var route = window.location.hash.substr(1);
150
  parts = route.split("=");
151
 
152
  WDP.localRoutes = {
@@ -393,7 +419,7 @@ WDP.prepareOverlay = function() {
393
  WDP.overlay.box = jQuery('<div class="box"></div>');
394
  WDP.overlay.box_title = jQuery('<div class="title"><h3></h3></div>');
395
  WDP.overlay.box_content = jQuery('<div class="content"></div>');
396
- WDP.overlay.close = jQuery('<div class="close">&times;</div>');
397
 
398
  WDP.overlay.back.appendTo(WDP.overlay.wrapper);
399
  WDP.overlay.scroll.appendTo(WDP.overlay.wrapper);
@@ -606,7 +632,7 @@ WDP.wpmuSelect = function(el) {
606
  wrap, handle, list, value, items;
607
 
608
  if (! jq.is("select")) { return; }
609
- if (jq.closest(".select-container").length) { return; }
610
 
611
  // Add the DOM elements to style the select list.
612
  function setupElement() {
@@ -625,21 +651,48 @@ WDP.wpmuSelect = function(el) {
625
  // Add all the options to the new DOM elements.
626
  function populateList() {
627
  items.empty();
628
- jq.find("option").each(function onPopulateLoop() {
629
- var opt = jQuery(this),
630
- item;
631
- item = jQuery("<li></li>").appendTo(items);
632
- item.text(opt.text());
633
- item.data("value", opt.val());
634
-
635
- if (opt.val() == jq.val()) {
636
- selectItem(item);
637
- }
638
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
639
  }
640
 
641
  // Toggle the dropdown state between open/closed.
642
  function stateToggle() {
 
 
643
  if (! wrap.hasClass("active")) {
644
  stateOpen();
645
  } else {
@@ -664,16 +717,18 @@ WDP.wpmuSelect = function(el) {
664
  }
665
 
666
  // Visually mark the specified option as "selected".
667
- function selectItem(opt) {
 
668
  value.text(opt.text());
669
-
670
  jQuery(".current", items).removeClass("current");
671
  opt.addClass("current");
672
  stateClose();
673
 
674
  // Also update the select list value.
675
  jq.val(opt.data("value"));
676
- jq.trigger("change");
 
 
677
  }
678
 
679
  // Element constructor.
@@ -682,9 +737,9 @@ WDP.wpmuSelect = function(el) {
682
 
683
  setupElement();
684
  populateList();
685
- items.on("click", function onItemClick(ev) {
686
  var opt = jQuery(ev.target);
687
- selectItem(opt);
688
  });
689
 
690
  handle.on("click", stateToggle);
@@ -708,6 +763,7 @@ WDP.wpmuSelect = function(el) {
708
  if (sel_id) {
709
  jQuery("label[for=" + sel_id + "]").on("click", stateOpen);
710
  }
 
711
  }
712
 
713
  init();
@@ -1042,16 +1098,16 @@ WDP.showMessage = function(action) {
1042
  '<span class="the-msg-icon check-animation"></span>' +
1043
  '<p><span class="default-text">' + WDP.lang.default_msg_ok + '</span>' +
1044
  '<span class="extra-text" style="display:none"></span></p>' +
1045
- '<span class="close">&times;</span>' +
1046
  '</div>'
1047
- );
1048
 
1049
  jQuery("body").append(
1050
  '<div class="update-notice err" id="wdp-error" style="display:none">' +
1051
  '<i class="the-msg-icon wdv-icon wdv-icon-warning-sign"></i>' +
1052
  '<p><span class="default-text">' + WDP.lang.default_msg_err + '</span>' +
1053
  '<span class="extra-text" style="display:none"></span></p>' +
1054
- '<span class="close">&times;</span>' +
1055
  '</div>'
1056
  );
1057
 
@@ -1111,7 +1167,7 @@ WDP.showMessage = function(action) {
1111
  }
1112
 
1113
  return WDP;
1114
- };
1115
 
1116
  /**
1117
  * Displays the "Changes saved" message in the top of the window.
@@ -1200,4 +1256,41 @@ WDP.updateHash = function(newHash) {
1200
  fx.remove();
1201
  node.attr('id', newHash);
1202
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1203
  };
30
  // Handle close buttons inside boxes.
31
  jQuery(".wpmud").on("click", ".can-close .close", closeElement);
32
 
33
+ // Add a reload-page handler.
34
+ jQuery(".wpmud").on("click", ".reload-page", reloadPage);
35
+
36
  // Initialize all tab-areas.
37
  jQuery(".wpmud .tabs").each(function(){
38
  WDP.wpmuTabs(this);
99
  return false;
100
  }
101
 
102
+ // When a .reload-page item is clicked, we reload it!
103
+ function reloadPage(ev) {
104
+ if (ev && ev.preventDefault) { ev.preventDefault(); }
105
+
106
+ var btn = jQuery(ev.target),
107
+ scope = jQuery("#wpbody, .dev-overlay"),
108
+ elems = scope.find("button, .button, a[href], [tooltip]");
109
+
110
+ // Disable other elements on the page and start loading animation.
111
+ if (btn.closest(".box").length) {
112
+ btn.closest(".box").loading(true);
113
+ } else if (btn.find(".spin-on-click")) {
114
+ spinOnClick.call(btn, ev);
115
+ } else {
116
+ btn.loading(true);
117
+ }
118
+ elems.prop("disabled", true).addClass("disabled");
119
+
120
+ // Reload the page!
121
+ window.location.reload();
122
+ return false;
123
+ }
124
+
125
  // Select all text inside the element.
126
  function selectOnClick(ev) {
127
  WDP.selectText(this);
172
 
173
  // Parses the hash-tag in the current address bar.
174
  function checkLocalRoutes() {
175
+ var route = window.location.hash.substr(1),
176
  parts = route.split("=");
177
 
178
  WDP.localRoutes = {
419
  WDP.overlay.box = jQuery('<div class="box"></div>');
420
  WDP.overlay.box_title = jQuery('<div class="title"><h3></h3></div>');
421
  WDP.overlay.box_content = jQuery('<div class="content"></div>');
422
+ WDP.overlay.close = jQuery('<div class="close" aria-label="Close">&times;</div>');
423
 
424
  WDP.overlay.back.appendTo(WDP.overlay.wrapper);
425
  WDP.overlay.scroll.appendTo(WDP.overlay.wrapper);
632
  wrap, handle, list, value, items;
633
 
634
  if (! jq.is("select")) { return; }
635
+ if (jq.closest(".select-container").length || jq.data("select2") || jq.is(".none-wpmu") ) { return; }
636
 
637
  // Add the DOM elements to style the select list.
638
  function setupElement() {
651
  // Add all the options to the new DOM elements.
652
  function populateList() {
653
  items.empty();
654
+ if( jq.find("optgroup").length ){
655
+ jq.find("optgroup").each(function(){
656
+ var optgroup = jQuery(this),
657
+ optgroup_item;
658
+ optgroup_item = jQuery("<ul></ul>").appendTo(items);
659
+ $label = jQuery('<li class="optgroup-label"></li>').text( optgroup.prop('label') );
660
+
661
+ optgroup_item.html( $label );
662
+ optgroup_item.addClass('optgroup');
663
+
664
+ optgroup.find('option').each(function onPopulateLoop() {
665
+ var opt = jQuery(this),
666
+ item;
667
+ item = jQuery("<li></li>").appendTo(optgroup_item);
668
+ item.text(opt.text());
669
+ item.data("value", opt.val());
670
+
671
+ if (opt.val() == jq.val()) {
672
+ selectItem(item);
673
+ }
674
+ });
675
+ });
676
+ }else{
677
+ jq.find("option").each(function onPopulateLoop() {
678
+ var opt = jQuery(this),
679
+ item;
680
+ item = jQuery("<li></li>").appendTo(items);
681
+ item.text(opt.text());
682
+ item.data("value", opt.val());
683
+
684
+ if (opt.val() == jq.val()) {
685
+ selectItem(item, true);
686
+ }
687
+ });
688
+ }
689
+
690
  }
691
 
692
  // Toggle the dropdown state between open/closed.
693
  function stateToggle() {
694
+ if( wrap.find("select").is(":disabled") ) return;
695
+
696
  if (! wrap.hasClass("active")) {
697
  stateOpen();
698
  } else {
717
  }
718
 
719
  // Visually mark the specified option as "selected".
720
+ function selectItem(opt, is_init) {
721
+ is_init = typeof is_init === "undefined" ? false : is_init;
722
  value.text(opt.text());
 
723
  jQuery(".current", items).removeClass("current");
724
  opt.addClass("current");
725
  stateClose();
726
 
727
  // Also update the select list value.
728
  jq.val(opt.data("value"));
729
+
730
+ if( !is_init )
731
+ jq.trigger("change");
732
  }
733
 
734
  // Element constructor.
737
 
738
  setupElement();
739
  populateList();
740
+ items.find("li").not('.optgroup-label').on("click", function onItemClick(ev) {
741
  var opt = jQuery(ev.target);
742
+ selectItem(opt, false);
743
  });
744
 
745
  handle.on("click", stateToggle);
763
  if (sel_id) {
764
  jQuery("label[for=" + sel_id + "]").on("click", stateOpen);
765
  }
766
+ jq.addClass("wdev-styled");
767
  }
768
 
769
  init();
1098
  '<span class="the-msg-icon check-animation"></span>' +
1099
  '<p><span class="default-text">' + WDP.lang.default_msg_ok + '</span>' +
1100
  '<span class="extra-text" style="display:none"></span></p>' +
1101
+ '<span class="close" aria-label="Close">&times;</span>' +
1102
  '</div>'
1103
+ )
1104
 
1105
  jQuery("body").append(
1106
  '<div class="update-notice err" id="wdp-error" style="display:none">' +
1107
  '<i class="the-msg-icon wdv-icon wdv-icon-warning-sign"></i>' +
1108
  '<p><span class="default-text">' + WDP.lang.default_msg_err + '</span>' +
1109
  '<span class="extra-text" style="display:none"></span></p>' +
1110
+ '<span class="close" aria-label="Close">&times;</span>' +
1111
  '</div>'
1112
  );
1113
 
1167
  }
1168
 
1169
  return WDP;
1170
+ }
1171
 
1172
  /**
1173
  * Displays the "Changes saved" message in the top of the window.
1256
  fx.remove();
1257
  node.attr('id', newHash);
1258
  }
1259
+ }
1260
+
1261
+ /**
1262
+ * Create or replace a cookie via javascript.
1263
+ *
1264
+ * @since 4.1.0
1265
+ */
1266
+ WDP.setCookie = function(name, value, days) {
1267
+ var expires;
1268
+ if (days) {
1269
+ var date = new Date();
1270
+ date.setTime(date.getTime() + (days * 86400 * 1000));
1271
+ expires = "; expires=" + date.toGMTString();
1272
+ } else {
1273
+ expires = "";
1274
+ }
1275
+ document.cookie = name + "=" + value + expires + "; path=/";
1276
+ };
1277
+
1278
+ /**
1279
+ * Return the value of a cookie.
1280
+ *
1281
+ * @since 4.1.0
1282
+ */
1283
+ WDP.getCookie = function(cookieName) {
1284
+ if (document.cookie.length > 0) {
1285
+ offset = document.cookie.indexOf(cookieName + "=");
1286
+ if (-1 != offset) {
1287
+ offset = offset + cookieName.length + 1;
1288
+ end = document.cookie.indexOf(";", offset);
1289
+ if (end == -1) {
1290
+ end = document.cookie.length;
1291
+ }
1292
+ return unescape(document.cookie.substring(offset, end));
1293
+ }
1294
+ }
1295
+ return "";
1296
  };
extras/free-dashboard/admin.css CHANGED
@@ -1,5 +1,8 @@
1
- /**
2
- * CSS styles used by the WDev-Frash module.
 
 
 
3
  */
4
 
5
  .wrap .frash-notice.notice {
@@ -18,7 +21,6 @@
18
  display: table; /* The magic ingredient! */
19
  font: 13px "Open Sans", sans-serif;
20
  }
21
-
22
  .wrap .frash-notice.notice.loading:before {
23
  content: attr(data-message);
24
  position: absolute;
@@ -33,13 +35,11 @@
33
  font-size: 22px;
34
  font-weight: bold;
35
  }
36
-
37
  .frash-notice > div {
38
  display: table-cell; /* The magic ingredient! */
39
  vertical-align: middle;
40
  cursor: default;
41
  }
42
-
43
  .frash-notice.notice.loading > div {
44
  -webkit-filter: blur(2px);
45
  -moz-filter: blur(2px);
@@ -47,29 +47,24 @@
47
  -ms-filter: blur(2px);
48
  filter: blur(2px);
49
  }
50
-
51
  .frash-notice-logo {
52
  background-color: #0B2F3F;
53
  background-image: url(data:image/png;base64,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);
54
  background-repeat: no-repeat;
55
  background-position: 50% 50%;
56
  }
57
-
58
  .frash-notice-logo span {
59
  display: block;
60
  width: 80px;
61
  }
62
-
63
  .frash-notice-message {
64
  width: 100%;
65
  padding: 10px 20px;
66
  color: #444;
67
  }
68
-
69
  .frash-notice-message strong {
70
  color: #000;
71
  }
72
-
73
  .frash-notice-cta {
74
  border-left: 1px solid #E5E5E5;
75
  background: #F8F8F8;
@@ -77,12 +72,10 @@
77
  position: relative;
78
  white-space: nowrap;
79
  }
80
-
81
  .wp-core-ui .frash-notice-cta button,
82
  .wp-core-ui .frash-notice-cta .button-primary:active {
83
  vertical-align: middle;
84
  }
85
-
86
  .wp-core-ui .frash-notice-cta input[type="email"] {
87
  vertical-align: middle;
88
  line-height: 20px;
@@ -93,14 +86,12 @@
93
  padding-left: 0;
94
  padding-right: 0;
95
  }
96
-
97
  .frash-notice-dismiss {
98
  background: transparent;
99
  border: 0;
100
  cursor: pointer;
101
  color: #BBB;
102
  }
103
-
104
  .frash-notice-dismiss:hover {
105
  color: #666;
106
  }
@@ -120,7 +111,6 @@
120
  display: block;
121
  font-size: 13px;
122
  }
123
-
124
  .frash-notice > .frash-notice-logo {
125
  float: left;
126
  display: inline-block;
@@ -128,14 +118,12 @@
128
  margin: 10px;
129
  border-radius: 4px;
130
  }
131
-
132
  .frash-notice > .frash-notice-message {
133
  width: auto;
134
  display: block;
135
  padding: 10px;
136
  min-height: 80px;
137
  }
138
-
139
  .frash-notice > .frash-notice-cta {
140
  display: block;
141
  border-top: 1px solid #E5E5E5;
@@ -145,12 +133,10 @@
145
  line-height: 30px;
146
  padding: 10px 20px;
147
  }
148
-
149
  .wp-core-ui .frash-notice > .frash-notice-cta > input[type="email"],
150
  .frash-notice > .frash-notice-cta > button {
151
  font-size: 14px;
152
  }
153
-
154
  .frash-notice > .frash-notice-cta > .frash-notice-dismiss {
155
  display: inline-block;
156
  float: none;
@@ -171,7 +157,6 @@
171
  font-size: 16px;
172
  height: 34px;
173
  }
174
-
175
  .frash-notice > .frash-notice-cta > .frash-notice-dismiss {
176
  margin-top: 5px;
177
  font-size: 14px;
1
+ /* ****************************************************************************
2
+ * NOTIFICATION STYLES
3
+ *
4
+ * The styles are identical with the WPMUDEV dashboard CSS (section 22)
5
+ * Any changes made here should also be made to the dashboard CSS!
6
  */
7
 
8
  .wrap .frash-notice.notice {
21
  display: table; /* The magic ingredient! */
22
  font: 13px "Open Sans", sans-serif;
23
  }
 
24
  .wrap .frash-notice.notice.loading:before {
25
  content: attr(data-message);
26
  position: absolute;
35
  font-size: 22px;
36
  font-weight: bold;
37
  }
 
38
  .frash-notice > div {
39
  display: table-cell; /* The magic ingredient! */
40
  vertical-align: middle;
41
  cursor: default;
42
  }
 
43
  .frash-notice.notice.loading > div {
44
  -webkit-filter: blur(2px);
45
  -moz-filter: blur(2px);
47
  -ms-filter: blur(2px);
48
  filter: blur(2px);
49
  }
 
50
  .frash-notice-logo {
51
  background-color: #0B2F3F;
52
  background-image: url(data:image/png;base64,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);
53
  background-repeat: no-repeat;
54
  background-position: 50% 50%;
55
  }
 
56
  .frash-notice-logo span {
57
  display: block;
58
  width: 80px;
59
  }
 
60
  .frash-notice-message {
61
  width: 100%;
62
  padding: 10px 20px;
63
  color: #444;
64
  }
 
65
  .frash-notice-message strong {
66
  color: #000;
67
  }
 
68
  .frash-notice-cta {
69
  border-left: 1px solid #E5E5E5;
70
  background: #F8F8F8;
72
  position: relative;
73
  white-space: nowrap;
74
  }
 
75
  .wp-core-ui .frash-notice-cta button,
76
  .wp-core-ui .frash-notice-cta .button-primary:active {
77
  vertical-align: middle;
78
  }
 
79
  .wp-core-ui .frash-notice-cta input[type="email"] {
80
  vertical-align: middle;
81
  line-height: 20px;
86
  padding-left: 0;
87
  padding-right: 0;
88
  }
 
89
  .frash-notice-dismiss {
90
  background: transparent;
91
  border: 0;
92
  cursor: pointer;
93
  color: #BBB;
94
  }
 
95
  .frash-notice-dismiss:hover {
96
  color: #666;
97
  }
111
  display: block;
112
  font-size: 13px;
113
  }
 
114
  .frash-notice > .frash-notice-logo {
115
  float: left;
116
  display: inline-block;
118
  margin: 10px;
119
  border-radius: 4px;
120
  }
 
121
  .frash-notice > .frash-notice-message {
122
  width: auto;
123
  display: block;
124
  padding: 10px;
125
  min-height: 80px;
126
  }
 
127
  .frash-notice > .frash-notice-cta {
128
  display: block;
129
  border-top: 1px solid #E5E5E5;
133
  line-height: 30px;
134
  padding: 10px 20px;
135
  }
 
136
  .wp-core-ui .frash-notice > .frash-notice-cta > input[type="email"],
137
  .frash-notice > .frash-notice-cta > button {
138
  font-size: 14px;
139
  }
 
140
  .frash-notice > .frash-notice-cta > .frash-notice-dismiss {
141
  display: inline-block;
142
  float: none;
157
  font-size: 16px;
158
  height: 34px;
159
  }
 
160
  .frash-notice > .frash-notice-cta > .frash-notice-dismiss {
161
  margin-top: 5px;
162
  font-size: 14px;
extras/free-dashboard/module.php CHANGED
@@ -3,23 +3,12 @@
3
  * WPMUDEV Frash - Free Dashboard Notification module.
4
  * Used by wordpress.org hosted plugins.
5
  *
6
- * TODO:
7
- * - Form submit handler to submit email address to getdrip.com
8
- * - Show the WPMUDEV logo in left side
9
- *
10
- * @version 1.0.0
11
  * @author Incsub (Philipp Stracker)
12
  */
13
  if ( ! class_exists( 'WDev_Frash' ) ) {
14
  class WDev_Frash {
15
 
16
- /**
17
- * The text-domain of the module.
18
- *
19
- * @since 1.0.0
20
- */
21
- const LANG = 'wdev-frash';
22
-
23
  /**
24
  * List of all registered plugins.
25
  *
@@ -385,7 +374,7 @@ if ( ! class_exists( 'WDev_Frash' ) ) {
385
  $user_name = $user->display_name;
386
  $admin_email = get_site_option( 'admin_email' );
387
 
388
- $msg = __( "We're happy that you've chosen to install %s! Are you interested in how to make the most of this plugin? How would you like a quick 5 day email crash course with actionable advice on building your membership site? Only the info you want, no subscription!", self::LANG );
389
  $msg = apply_filters( 'wdev-email-message-' . $plugin->id, $msg );
390
 
391
  ?>
@@ -400,11 +389,11 @@ if ( ! class_exists( 'WDev_Frash' ) ) {
400
  </div>
401
  <div class="frash-notice-cta">
402
  <input type="email" name="email" value="<?php echo esc_attr( $admin_email ); ?>" />
403
- <button class="frash-notice-act button-primary" data-msg="<?php _e( 'Thanks :)', self::LANG ); ?>">
404
  <?php echo esc_html( $plugin->cta_email ); ?>
405
  </button>
406
- <button class="frash-notice-dismiss" data-msg="<?php _e( 'Saving', self::LANG ); ?>">
407
- <?php _e( 'No thanks', self::LANG ); ?>
408
  </button>
409
  </div>
410
  <?php
@@ -420,7 +409,7 @@ if ( ! class_exists( 'WDev_Frash' ) ) {
420
  $user = wp_get_current_user();
421
  $user_name = $user->display_name;
422
 
423
- $msg = __( "Hey %s, you've been using %s for a while now, and we hope you're happy with it.", self::LANG ) . '<br />'. __( "We've spent countless hours developing this free plugin for you, and we would really appreciate it if you dropped us a quick rating!", self::LANG );
424
  $msg = apply_filters( 'wdev-rating-message-' . $plugin->id, $msg );
425
 
426
  ?>
@@ -435,15 +424,15 @@ if ( ! class_exists( 'WDev_Frash' ) ) {
435
  ?>
436
  </div>
437
  <div class="frash-notice-cta">
438
- <button class="frash-notice-act button-primary" data-msg="<?php _e( 'Thanks :)', self::LANG ); ?>">
439
  <?php
440
  printf(
441
- __( 'Rate %s', self::LANG ),
442
  esc_html( $plugin->title )
443
  ); ?>
444
  </button>
445
- <button class="frash-notice-dismiss" data-msg="<?php _e( 'Saving', self::LANG ); ?>">
446
- <?php _e( 'No thanks', self::LANG ); ?>
447
  </button>
448
  </div>
449
  <?php
3
  * WPMUDEV Frash - Free Dashboard Notification module.
4
  * Used by wordpress.org hosted plugins.
5
  *
6
+ * @version 1.1.0
 
 
 
 
7
  * @author Incsub (Philipp Stracker)
8
  */
9
  if ( ! class_exists( 'WDev_Frash' ) ) {
10
  class WDev_Frash {
11
 
 
 
 
 
 
 
 
12
  /**
13
  * List of all registered plugins.
14
  *
374
  $user_name = $user->display_name;
375
  $admin_email = get_site_option( 'admin_email' );
376
 
377
+ $msg = __( "We're happy that you've chosen to install %s! Are you interested in how to make the most of this plugin? How would you like a quick 5 day email crash course with actionable advice on building your membership site? Only the info you want, no subscription!", 'wdev_frash' );
378
  $msg = apply_filters( 'wdev-email-message-' . $plugin->id, $msg );
379
 
380
  ?>
389
  </div>
390
  <div class="frash-notice-cta">
391
  <input type="email" name="email" value="<?php echo esc_attr( $admin_email ); ?>" />
392
+ <button class="frash-notice-act button-primary" data-msg="<?php _e( 'Thanks :)', 'wdev_frash' ); ?>">
393
  <?php echo esc_html( $plugin->cta_email ); ?>
394
  </button>
395
+ <button class="frash-notice-dismiss" data-msg="<?php _e( 'Saving', 'wdev_frash' ); ?>">
396
+ <?php _e( 'No thanks', 'wdev_frash' ); ?>
397
  </button>
398
  </div>
399
  <?php
409
  $user = wp_get_current_user();
410
  $user_name = $user->display_name;
411
 
412
+ $msg = __( "Hey %s, you've been using %s for a while now, and we hope you're happy with it.", 'wdev_frash' ) . '<br />'. __( "We've spent countless hours developing this free plugin for you, and we would really appreciate it if you dropped us a quick rating!", 'wdev_frash' );
413
  $msg = apply_filters( 'wdev-rating-message-' . $plugin->id, $msg );
414
 
415
  ?>
424
  ?>
425
  </div>
426
  <div class="frash-notice-cta">
427
+ <button class="frash-notice-act button-primary" data-msg="<?php _e( 'Thanks :)', 'wdev_frash' ); ?>">
428
  <?php
429
  printf(
430
+ __( 'Rate %s', 'wdev_frash' ),
431
  esc_html( $plugin->title )
432
  ); ?>
433
  </button>
434
+ <button class="frash-notice-dismiss" data-msg="<?php _e( 'Saving', 'wdev_frash' ); ?>">
435
+ <?php _e( 'No thanks', 'wdev_frash' ); ?>
436
  </button>
437
  </div>
438
  <?php
languages/wp-smushit.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the WP Smush package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: WP Smush 2.3.1\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/wp-smushit\n"
7
- "POT-Creation-Date: 2016-06-01 08:25:36+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -24,36 +24,36 @@ msgstr ""
24
  msgid "Oops, we could not do this..."
25
  msgstr ""
26
 
27
- #: assets/shared-ui/plugin-ui.php:225 extras/free-dashboard/module.php:406
28
- #: extras/free-dashboard/module.php:445 lib/class-wp-smush-ui.php:726
29
  msgid "Saving"
30
  msgstr ""
31
 
32
- #: assets/shared-ui/plugin-ui.php:254 lib/class-wp-smush-ui.php:726
33
  msgid "Dismiss"
34
  msgstr ""
35
 
36
- #: extras/free-dashboard/module.php:388
37
  msgid "We're happy that you've chosen to install %s! Are you interested in how to make the most of this plugin? How would you like a quick 5 day email crash course with actionable advice on building your membership site? Only the info you want, no subscription!"
38
  msgstr ""
39
 
40
- #: extras/free-dashboard/module.php:403 extras/free-dashboard/module.php:438
41
  msgid "Thanks :)"
42
  msgstr ""
43
 
44
- #: extras/free-dashboard/module.php:407 extras/free-dashboard/module.php:446
45
  msgid "No thanks"
46
  msgstr ""
47
 
48
- #: extras/free-dashboard/module.php:423
49
  msgid "Hey %s, you've been using %s for a while now, and we hope you're happy with it."
50
  msgstr ""
51
 
52
- #: extras/free-dashboard/module.php:423
53
  msgid "We've spent countless hours developing this free plugin for you, and we would really appreciate it if you dropped us a quick rating!"
54
  msgstr ""
55
 
56
- #: extras/free-dashboard/module.php:441
57
  msgid "Rate %s"
58
  msgstr ""
59
 
@@ -78,7 +78,7 @@ msgid "Resize original images"
78
  msgstr ""
79
 
80
  #: lib/class-wp-smush-admin.php:171
81
- msgid "Save a ton of space by not storing over-sized images on your server. Set image maximum width and height and large images will be automatically scaled before being added to the media library. "
82
  msgstr ""
83
 
84
  #: lib/class-wp-smush-admin.php:174
@@ -105,481 +105,536 @@ msgstr ""
105
  msgid "Save your original full-size images so you can restore them at any point. Note: Activating this setting will significantly increase the size of your uploads folder by nearly twice as much."
106
  msgstr ""
107
 
108
- #: lib/class-wp-smush-admin.php:190
 
 
 
 
 
 
 
 
109
  msgid "Enable NextGen Gallery integration"
110
  msgstr ""
111
 
112
- #: lib/class-wp-smush-admin.php:191
113
  msgid "Allow smushing images directly through NextGen Gallery settings."
114
  msgstr ""
115
 
116
- #: lib/class-wp-smush-admin.php:210 lib/class-wp-smush-ui.php:667
117
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:70
118
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:89
119
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:91
120
  msgid "WP Smush"
121
  msgstr ""
122
 
123
- #: lib/class-wp-smush-admin.php:309 lib/class-wp-smush.php:947
124
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:158
125
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:275
126
  msgid "Super-Smush"
127
  msgstr ""
128
 
129
- #: lib/class-wp-smush-admin.php:310
130
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:159
131
  msgid "Smush Now"
132
  msgstr ""
133
 
134
- #: lib/class-wp-smush-admin.php:311
135
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:160
136
  msgid "{{errors}} image(s) were skipped due to an error."
137
  msgstr ""
138
 
139
- #: lib/class-wp-smush-admin.php:312
140
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:161
141
  msgid "All images are fully optimised."
142
  msgstr ""
143
 
144
- #: lib/class-wp-smush-admin.php:313
145
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:162
146
  msgid "Restoring image.."
147
  msgstr ""
148
 
149
- #: lib/class-wp-smush-admin.php:314
150
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:163
151
  msgid "Smushing image.."
152
  msgstr ""
153
 
154
- #: lib/class-wp-smush-admin.php:315
155
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:164
156
  msgid "Checking images.."
157
  msgstr ""
158
 
159
- #: lib/class-wp-smush-admin.php:544
160
  msgid "Smush request timed out, You can try setting a higher value for `WP_SMUSH_API_TIMEOUT`."
161
  msgstr ""
162
 
163
- #: lib/class-wp-smush-admin.php:560 lib/class-wp-smush-ui.php:176
164
- msgid "%d images"
165
  msgstr ""
166
 
167
- #: lib/class-wp-smush-admin.php:578 lib/class-wp-smush-nextgen.php:372
168
  msgid "You don't have permission to work with uploaded files."
169
  msgstr ""
170
 
171
- #: lib/class-wp-smush-admin.php:582 lib/class-wp-smush-nextgen.php:376
172
  msgid "No attachment ID was provided."
173
  msgstr ""
174
 
175
- #: lib/class-wp-smush-admin.php:706
176
  msgid "<strong>%d of %d images</strong> were sent for smushing:"
177
  msgstr ""
178
 
179
- #: lib/class-wp-smush-admin.php:861 lib/class-wp-smush-admin.php:874
180
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:336
181
  msgid "Bulk Smush Now"
182
  msgstr ""
183
 
184
- #: lib/class-wp-smush-admin.php:868
185
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:340
186
  msgid "All Done!"
187
  msgstr ""
188
 
189
- #: lib/class-wp-smush-admin.php:907 lib/class-wp-smush-admin.php:1731
190
  msgid "Settings"
191
  msgstr ""
192
 
193
- #: lib/class-wp-smush-admin.php:1051 lib/class-wp-smush-nextgen.php:459
194
- msgid "Error in processing restore action, Fields empty."
195
- msgstr ""
196
-
197
- #: lib/class-wp-smush-admin.php:1058 lib/class-wp-smush-nextgen.php:466
198
- msgid "Image not restored, Nonce verification failed."
199
- msgstr ""
200
-
201
- #: lib/class-wp-smush-admin.php:1132 lib/class-wp-smush-nextgen.php:541
202
- msgid "Unable to restore image"
203
- msgstr ""
204
-
205
- #: lib/class-wp-smush-admin.php:1150
206
  msgid "Image not smushed, fields empty."
207
  msgstr ""
208
 
209
- #: lib/class-wp-smush-admin.php:1157 lib/class-wp-smush-nextgen.php:559
210
  msgid "Image couldn't be smushed as the nonce verification failed, try reloading the page."
211
  msgstr ""
212
 
213
- #: lib/class-wp-smush-admin.php:1174
214
  msgid "Unable to smush image"
215
  msgstr ""
216
 
217
- #: lib/class-wp-smush-admin.php:1193
218
  msgid "Yay! All images are optimised as per your current settings."
219
  msgstr ""
220
 
221
- #: lib/class-wp-smush-admin.php:1342 lib/class-wp-smush-ui.php:642
222
  msgid "You have images that need smushing. %sBulk smush now!%s"
223
  msgstr ""
224
 
225
- #: lib/class-wp-smush-admin.php:1732 lib/class-wp-smush-ui.php:536
226
- #: lib/class-wp-smush-ui.php:667
227
  msgid "WP Smush Pro"
228
  msgstr ""
229
 
230
- #: lib/class-wp-smush-admin.php:1735
231
  msgid "Woohoo! Your latest Smush update %s allows you to %sauto resize%s all your images, how cool is that! %sFind out more here >>%s"
232
  msgstr ""
233
 
234
- #: lib/class-wp-smush-nextgen.php:318
 
 
 
 
 
 
 
 
 
 
 
 
235
  msgid "We couldn't find the metadata for the image, possibly the image has been deleted."
236
  msgstr ""
237
 
238
- #: lib/class-wp-smush-nextgen.php:552
239
  msgid "We couldn't process the image, fields empty."
240
  msgstr ""
241
 
242
- #: lib/class-wp-smush-nextgen.php:576
243
  msgid "Unable to smush image, %s"
244
  msgstr ""
245
 
246
- #: lib/class-wp-smush-ui.php:53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  msgid "Dismiss Welcome notice"
248
  msgstr ""
249
 
250
- #: lib/class-wp-smush-ui.php:69
251
  msgid "WELCOME"
252
  msgstr ""
253
 
254
- #: lib/class-wp-smush-ui.php:77
255
  msgid "OH YEAH, IT'S COMPRESSION TIME!"
256
  msgstr ""
257
 
258
- #: lib/class-wp-smush-ui.php:78
259
  msgid "You've just installed %3$s, the most popular image compression plugin for WordPress! %1$sChoose your desired settings%2$s and get smushing!"
260
  msgstr ""
261
 
262
- #: lib/class-wp-smush-ui.php:92
263
  msgid "Smush individual images via your %sMedia Library%s"
264
  msgstr ""
265
 
266
- #: lib/class-wp-smush-ui.php:92
267
  msgid "Media Library"
268
  msgstr ""
269
 
270
- #: lib/class-wp-smush-ui.php:97
271
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:482
272
  msgid "BULK SMUSH"
273
  msgstr ""
274
 
275
- #: lib/class-wp-smush-ui.php:111
276
  msgid "SETTINGS"
277
  msgstr ""
278
 
279
- #: lib/class-wp-smush-ui.php:126
280
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:502
281
  msgid "Lets you check if any images can be further optimised. Useful after changing settings."
282
  msgstr ""
283
 
284
- #: lib/class-wp-smush-ui.php:126
285
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:502
286
  msgid "RE-CHECK IMAGES"
287
  msgstr ""
288
 
289
- #: lib/class-wp-smush-ui.php:127
290
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:503
291
  msgid "STATS"
292
  msgstr ""
293
 
294
- #: lib/class-wp-smush-ui.php:131
295
- #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:508
296
- msgid "TOTAL % REDUCTIONS"
297
  msgstr ""
298
 
299
- #: lib/class-wp-smush-ui.php:139
300
- #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:520
301
- msgid "TOTAL SIZE REDUCTIONS"
302
  msgstr ""
303
 
304
- #: lib/class-wp-smush-ui.php:146
305
- msgid "TOTAL RESIZE SAVINGS"
 
306
  msgstr ""
307
 
308
- #: lib/class-wp-smush-ui.php:153
309
- #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:529
310
- msgid "ATTACHMENTS SMUSHED"
311
  msgstr ""
312
 
313
- #: lib/class-wp-smush-ui.php:155
314
- msgid " You've smushed %d images in total"
315
  msgstr ""
316
 
317
- #: lib/class-wp-smush-ui.php:173
318
- #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:544
319
- msgid "ATTACHMENTS SUPER-SMUSHED"
320
  msgstr ""
321
 
322
- #: lib/class-wp-smush-ui.php:178
323
- msgid "%sENABLE%s"
 
 
 
 
 
 
 
 
 
 
 
 
324
  msgstr ""
325
 
326
- #: lib/class-wp-smush-ui.php:203
327
  msgid "UPDATE SETTINGS"
328
  msgstr ""
329
 
330
- #: lib/class-wp-smush-ui.php:224
331
- msgid "%sPRO ONLY%s"
332
  msgstr ""
333
 
334
- #: lib/class-wp-smush-ui.php:226
335
  msgid "ADVANCED SETTINGS"
336
  msgstr ""
337
 
338
- #: lib/class-wp-smush-ui.php:363
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  msgid "Width"
340
  msgstr ""
341
 
342
- #: lib/class-wp-smush-ui.php:366
343
  msgid "Height"
344
  msgstr ""
345
 
346
- #: lib/class-wp-smush-ui.php:369
347
  msgid "Currently, your largest thumbnail size is set at %s%dpx wide x %dpx high%s. Anything above 2048px in width or height is huge and not recommended."
348
  msgstr ""
349
 
350
- #: lib/class-wp-smush-ui.php:370
351
  msgid "Just to let you know, the width you've entered is less than your largest thumbnail and may result in pixelation."
352
  msgstr ""
353
 
354
- #: lib/class-wp-smush-ui.php:371
355
  msgid "Just to let you know, the height you’ve entered is less than your largest thumbnail and may result in pixelation."
356
  msgstr ""
357
 
358
- #: lib/class-wp-smush-ui.php:457
359
- msgid "TRY WP SMUSH PRO - DEV TEAM"
360
- msgstr ""
361
-
362
- #: lib/class-wp-smush-ui.php:473
363
  msgid "BOOST YOUR PERFORMANCE - HUMMINGBIRD"
364
  msgstr ""
365
 
366
- #: lib/class-wp-smush-ui.php:500
367
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:423
368
  msgid "No attachments found - Upload some images"
369
  msgstr ""
370
 
371
- #: lib/class-wp-smush-ui.php:502
372
  msgid "We haven’t found any images in your %smedia library%s yet so there’s no smushing to be done! Once you upload images, reload this page and start playing!"
373
  msgstr ""
374
 
375
- #: lib/class-wp-smush-ui.php:505
376
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:428
377
  msgid "UPLOAD IMAGES"
378
  msgstr ""
379
 
380
- #: lib/class-wp-smush-ui.php:510
381
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:433
382
  msgid "All images are smushed and up to date. Awesome!"
383
  msgstr ""
384
 
385
- #: lib/class-wp-smush-ui.php:515
386
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:438
387
  msgid "BULK SMUSH NOW"
388
  msgstr ""
389
 
390
- #: lib/class-wp-smush-ui.php:534
391
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:446
392
  msgid "%s, you have %s%s%d%s image%s that needs smushing!"
393
  msgid_plural "%s, you have %s%s%d%s images%s that need smushing!"
394
  msgstr[0] ""
395
  msgstr[1] ""
396
 
397
- #: lib/class-wp-smush-ui.php:536
398
  msgid "You can %sUpgrade to Pro%s to bulk smush all your images with one click."
399
  msgstr ""
400
 
401
- #: lib/class-wp-smush-ui.php:537
402
  msgid "Free users can smush 50 images with each click."
403
  msgstr ""
404
 
405
- #: lib/class-wp-smush-ui.php:546
406
  msgid "Enable Super-smush in the Settings area to get even more savings with almost no noticeable quality loss."
407
  msgstr ""
408
 
409
- #: lib/class-wp-smush-ui.php:569
410
- msgid "%sBulk smush is currently running.%s You need to keep this page open."
411
  msgstr ""
412
 
413
- #: lib/class-wp-smush-ui.php:579
414
  msgid "%s%d%s of %d attachments have been smushed."
415
  msgstr ""
416
 
417
- #: lib/class-wp-smush-ui.php:584
418
  msgid "CANCEL"
419
  msgstr ""
420
 
421
- #: lib/class-wp-smush-ui.php:620
422
  msgid "%s, you have %s%s%d%s image%s that needs re-compressing!"
423
  msgid_plural "%s, you have %s%s%d%s images%s that need re-compressing!"
424
  msgstr[0] ""
425
  msgstr[1] ""
426
 
427
- #: lib/class-wp-smush-ui.php:621
428
  msgid "Skip"
429
  msgstr ""
430
 
431
- #: lib/class-wp-smush-ui.php:635
432
  msgid "Your settings have been updated!"
433
  msgstr ""
434
 
435
- #: lib/class-wp-smush-ui.php:669
436
  msgid "Automatic smushing is %senabled%s. Newly uploaded images will be automagically compressed."
437
  msgstr ""
438
 
439
- #: lib/class-wp-smush-ui.php:669
440
  msgid "Automatic smushing is %sdisabled%s. Newly uploaded images will need to be manually smushed."
441
  msgstr ""
442
 
443
- #: lib/class-wp-smush-ui.php:698
444
  msgid "Thanks for installing Smush. We hope you like it!"
445
  msgstr ""
446
 
447
- #: lib/class-wp-smush-ui.php:699
448
  msgid "And hey, if you do, you can now try out Smush Pro for double the smushy goodness (benchmarked), entirely for free!"
449
  msgstr ""
450
 
451
- #: lib/class-wp-smush-ui.php:700 lib/class-wp-smush-ui.php:704
452
  msgid "Try Smush Pro for Free"
453
  msgstr ""
454
 
455
- #: lib/class-wp-smush-ui.php:702
456
  msgid "Thanks for updating Smush. Did you know that you can now try the Smush Pro for FREE?!"
457
  msgstr ""
458
 
459
- #: lib/class-wp-smush-ui.php:703
460
  msgid "Yep, Super Smush your images for double the savings, save originals and batch Smush thousands of images all at once.... no charge!"
461
  msgstr ""
462
 
463
- #: lib/class-wp-smush-ui.php:750
464
  msgid "Did you know WP Smush Pro delivers up to 10x better compression, allows you to smush your originals and removes any bulk smushing limits? – %sTry it absolutely FREE%s"
465
  msgstr ""
466
 
467
- #: lib/class-wp-smush-ui.php:750
468
  msgid "Try WP Smush Pro for FREE"
469
  msgstr ""
470
 
471
- #: lib/class-wp-smush.php:153
472
  msgid "File path is empty"
473
  msgstr ""
474
 
475
- #: lib/class-wp-smush.php:158
476
  msgid "Could not find %s"
477
  msgstr ""
478
 
479
- #: lib/class-wp-smush.php:163
480
  msgid "%s is not writable"
481
  msgstr ""
482
 
483
- #: lib/class-wp-smush.php:173
484
  msgid "Skipped (%s), image not found. Attachment: %s"
485
  msgstr ""
486
 
487
- #: lib/class-wp-smush.php:178
488
  msgid "Skipped (%s), size limit exceeded. Attachment: %s"
489
  msgstr ""
490
 
491
- #: lib/class-wp-smush.php:197
492
  msgid "Unknown API error"
493
  msgstr ""
494
 
495
- #: lib/class-wp-smush.php:617
496
  msgid "Error posting to API: %s"
497
  msgstr ""
498
 
499
- #: lib/class-wp-smush.php:623
500
  msgid "Error posting to API: %s %s"
501
  msgstr ""
502
 
503
- #: lib/class-wp-smush.php:640
504
  msgid "Smush data corrupted, try again."
505
  msgstr ""
506
 
507
- #: lib/class-wp-smush.php:656
508
  msgid "Image couldn't be smushed"
509
  msgstr ""
510
 
511
- #: lib/class-wp-smush.php:874 lib/class-wp-smush.php:878
512
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:193
513
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:196
514
  msgid "Already Optimized"
515
  msgstr ""
516
 
517
- #: lib/class-wp-smush.php:887
518
  msgid "%d images reduced "
519
  msgstr ""
520
 
521
- #: lib/class-wp-smush.php:887
522
  msgid "Reduced "
523
  msgstr ""
524
 
525
- #: lib/class-wp-smush.php:888
526
- msgid "by %s ( %01.1f%% )"
 
 
 
 
527
  msgstr ""
528
 
529
- #: lib/class-wp-smush.php:922
530
  msgid "Detailed stats for all the image sizes"
531
  msgstr ""
532
 
533
- #: lib/class-wp-smush.php:922
534
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:236
535
  msgid "Smush stats"
536
  msgstr ""
537
 
538
- #: lib/class-wp-smush.php:954
539
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:249
540
  msgid "Not processed"
541
  msgstr ""
542
 
543
- #: lib/class-wp-smush.php:960
544
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:255
545
  msgid "Smush Now!"
546
  msgstr ""
547
 
548
- #: lib/class-wp-smush.php:1258
549
  msgid "When you upload an image to WordPress it automatically creates %s thumbnail sizes that are commonly used in your pages. WordPress also stores the original full-size image, but because these are not usually embedded on your site we don’t Smush them. Pro users can override this."
550
  msgstr ""
551
 
552
- #: lib/class-wp-smush.php:1261
553
  msgid "Image couldn't be smushed as it exceeded the 1Mb size limit, Pro users can smush images with size upto 32Mb."
554
  msgstr ""
555
 
556
- #: lib/class-wp-smush.php:1263
557
  msgid " Skipped"
558
  msgstr ""
559
 
560
- #: lib/class-wp-smush.php:1283
561
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:432
562
  msgid "Image size"
563
  msgstr ""
564
 
565
- #: lib/class-wp-smush.php:1284
566
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:433
567
  msgid "Savings"
568
  msgstr ""
569
 
570
- #: lib/class-wp-smush.php:1466
571
  msgid "Restore original image."
572
  msgstr ""
573
 
574
- #: lib/class-wp-smush.php:1466
575
  msgid "Restore image"
576
  msgstr ""
577
 
578
- #: lib/class-wp-smush.php:1511
579
  msgid "Smush image including original file."
580
  msgstr ""
581
 
582
- #: lib/class-wp-smush.php:1511
583
  msgid "Resmush image"
584
  msgstr ""
585
 
@@ -603,7 +658,7 @@ msgstr ""
603
  msgid "Manage Galleries"
604
  msgstr ""
605
 
606
- #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:552
607
  msgid "%sDISABLED%s"
608
  msgstr ""
609
 
@@ -615,11 +670,11 @@ msgstr ""
615
  msgid "Reduced by %s ( %01.1f%% )"
616
  msgstr ""
617
 
618
- #: wp-smush.php:140
619
  msgid "Get Fast"
620
  msgstr ""
621
 
622
- #: wp-smush.php:193
623
  msgid "WP Smush Free was deactivated. You have WP Smush Pro active!"
624
  msgstr ""
625
  #. Plugin Name of the plugin/theme
2
  # This file is distributed under the same license as the WP Smush package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WP Smush 2.4\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/wp-smushit\n"
7
+ "POT-Creation-Date: 2016-07-26 05:38:33+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
24
  msgid "Oops, we could not do this..."
25
  msgstr ""
26
 
27
+ #: assets/shared-ui/plugin-ui.php:272 extras/free-dashboard/module.php:395
28
+ #: extras/free-dashboard/module.php:434 lib/class-wp-smush-ui.php:835
29
  msgid "Saving"
30
  msgstr ""
31
 
32
+ #: assets/shared-ui/plugin-ui.php:301 lib/class-wp-smush-ui.php:835
33
  msgid "Dismiss"
34
  msgstr ""
35
 
36
+ #: extras/free-dashboard/module.php:377
37
  msgid "We're happy that you've chosen to install %s! Are you interested in how to make the most of this plugin? How would you like a quick 5 day email crash course with actionable advice on building your membership site? Only the info you want, no subscription!"
38
  msgstr ""
39
 
40
+ #: extras/free-dashboard/module.php:392 extras/free-dashboard/module.php:427
41
  msgid "Thanks :)"
42
  msgstr ""
43
 
44
+ #: extras/free-dashboard/module.php:396 extras/free-dashboard/module.php:435
45
  msgid "No thanks"
46
  msgstr ""
47
 
48
+ #: extras/free-dashboard/module.php:412
49
  msgid "Hey %s, you've been using %s for a while now, and we hope you're happy with it."
50
  msgstr ""
51
 
52
+ #: extras/free-dashboard/module.php:412
53
  msgid "We've spent countless hours developing this free plugin for you, and we would really appreciate it if you dropped us a quick rating!"
54
  msgstr ""
55
 
56
+ #: extras/free-dashboard/module.php:430
57
  msgid "Rate %s"
58
  msgstr ""
59
 
78
  msgstr ""
79
 
80
  #: lib/class-wp-smush-admin.php:171
81
+ msgid "Save a ton of space by not storing over-sized images on your server. Set image maximum width and height and large images will be automatically scaled before being added to the media library."
82
  msgstr ""
83
 
84
  #: lib/class-wp-smush-admin.php:174
105
  msgid "Save your original full-size images so you can restore them at any point. Note: Activating this setting will significantly increase the size of your uploads folder by nearly twice as much."
106
  msgstr ""
107
 
108
+ #: lib/class-wp-smush-admin.php:186
109
+ msgid "Convert PNG to JPEG (lossy)"
110
+ msgstr ""
111
+
112
+ #: lib/class-wp-smush-admin.php:187
113
+ msgid "When you optimise a PNG, Smush will check if converting it to a JPEG will reduce the file size, and if so it will automatically convert it. Note: Smush will only convert the file format if it results in smaller file size. This will change the file's name, any hardcoded URLs will need updating."
114
+ msgstr ""
115
+
116
+ #: lib/class-wp-smush-admin.php:194
117
  msgid "Enable NextGen Gallery integration"
118
  msgstr ""
119
 
120
+ #: lib/class-wp-smush-admin.php:195
121
  msgid "Allow smushing images directly through NextGen Gallery settings."
122
  msgstr ""
123
 
124
+ #: lib/class-wp-smush-admin.php:217 lib/class-wp-smush-ui.php:774
125
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:70
126
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:89
127
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:91
128
  msgid "WP Smush"
129
  msgstr ""
130
 
131
+ #: lib/class-wp-smush-admin.php:316 lib/class-wp-smush.php:990
132
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:158
133
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:275
134
  msgid "Super-Smush"
135
  msgstr ""
136
 
137
+ #: lib/class-wp-smush-admin.php:317
138
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:159
139
  msgid "Smush Now"
140
  msgstr ""
141
 
142
+ #: lib/class-wp-smush-admin.php:318
143
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:160
144
  msgid "{{errors}} image(s) were skipped due to an error."
145
  msgstr ""
146
 
147
+ #: lib/class-wp-smush-admin.php:319
148
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:161
149
  msgid "All images are fully optimised."
150
  msgstr ""
151
 
152
+ #: lib/class-wp-smush-admin.php:320
153
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:162
154
  msgid "Restoring image.."
155
  msgstr ""
156
 
157
+ #: lib/class-wp-smush-admin.php:321
158
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:163
159
  msgid "Smushing image.."
160
  msgstr ""
161
 
162
+ #: lib/class-wp-smush-admin.php:322
163
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:164
164
  msgid "Checking images.."
165
  msgstr ""
166
 
167
+ #: lib/class-wp-smush-admin.php:575
168
  msgid "Smush request timed out, You can try setting a higher value for `WP_SMUSH_API_TIMEOUT`."
169
  msgstr ""
170
 
171
+ #: lib/class-wp-smush-admin.php:592
172
+ msgid "You've smushed %d images in total."
173
  msgstr ""
174
 
175
+ #: lib/class-wp-smush-admin.php:612 lib/class-wp-smush-nextgen.php:384
176
  msgid "You don't have permission to work with uploaded files."
177
  msgstr ""
178
 
179
+ #: lib/class-wp-smush-admin.php:616 lib/class-wp-smush-nextgen.php:388
180
  msgid "No attachment ID was provided."
181
  msgstr ""
182
 
183
+ #: lib/class-wp-smush-admin.php:743
184
  msgid "<strong>%d of %d images</strong> were sent for smushing:"
185
  msgstr ""
186
 
187
+ #: lib/class-wp-smush-admin.php:1024 lib/class-wp-smush-admin.php:1037
188
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:336
189
  msgid "Bulk Smush Now"
190
  msgstr ""
191
 
192
+ #: lib/class-wp-smush-admin.php:1031
193
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:340
194
  msgid "All Done!"
195
  msgstr ""
196
 
197
+ #: lib/class-wp-smush-admin.php:1070 lib/class-wp-smush-admin.php:1821
198
  msgid "Settings"
199
  msgstr ""
200
 
201
+ #: lib/class-wp-smush-admin.php:1216
 
 
 
 
 
 
 
 
 
 
 
 
202
  msgid "Image not smushed, fields empty."
203
  msgstr ""
204
 
205
+ #: lib/class-wp-smush-admin.php:1223 lib/class-wp-smush-nextgen.php:571
206
  msgid "Image couldn't be smushed as the nonce verification failed, try reloading the page."
207
  msgstr ""
208
 
209
+ #: lib/class-wp-smush-admin.php:1240
210
  msgid "Unable to smush image"
211
  msgstr ""
212
 
213
+ #: lib/class-wp-smush-admin.php:1259
214
  msgid "Yay! All images are optimised as per your current settings."
215
  msgstr ""
216
 
217
+ #: lib/class-wp-smush-admin.php:1432 lib/class-wp-smush-ui.php:749
218
  msgid "You have images that need smushing. %sBulk smush now!%s"
219
  msgstr ""
220
 
221
+ #: lib/class-wp-smush-admin.php:1822 lib/class-wp-smush-ui.php:643
222
+ #: lib/class-wp-smush-ui.php:774
223
  msgid "WP Smush Pro"
224
  msgstr ""
225
 
226
+ #: lib/class-wp-smush-admin.php:1825
227
  msgid "Woohoo! Your latest Smush update %s allows you to %sauto resize%s all your images, how cool is that! %sFind out more here >>%s"
228
  msgstr ""
229
 
230
+ #: lib/class-wp-smush-backup.php:81 lib/class-wp-smush-nextgen.php:471
231
+ msgid "Error in processing restore action, Fields empty."
232
+ msgstr ""
233
+
234
+ #: lib/class-wp-smush-backup.php:88 lib/class-wp-smush-nextgen.php:478
235
+ msgid "Image not restored, Nonce verification failed."
236
+ msgstr ""
237
+
238
+ #: lib/class-wp-smush-backup.php:182 lib/class-wp-smush-nextgen.php:553
239
+ msgid "Unable to restore image"
240
+ msgstr ""
241
+
242
+ #: lib/class-wp-smush-nextgen.php:330
243
  msgid "We couldn't find the metadata for the image, possibly the image has been deleted."
244
  msgstr ""
245
 
246
+ #: lib/class-wp-smush-nextgen.php:564
247
  msgid "We couldn't process the image, fields empty."
248
  msgstr ""
249
 
250
+ #: lib/class-wp-smush-nextgen.php:588
251
  msgid "Unable to smush image, %s"
252
  msgstr ""
253
 
254
+ #: lib/class-wp-smush-share.php:29
255
+ msgid "%s, you've smushed %d images and saved %s in total. Help your friends save bandwidth easily, and help me in my quest to Smush the internet!"
256
+ msgstr ""
257
+
258
+ #: lib/class-wp-smush-share.php:30
259
+ msgid "I saved %s on my site with WP Smush ( %s ) - wanna make your website smaller and faster?"
260
+ msgstr ""
261
+
262
+ #: lib/class-wp-smush-share.php:39
263
+ msgid "TWEET"
264
+ msgstr ""
265
+
266
+ #: lib/class-wp-smush-share.php:43
267
+ msgid "SHARE"
268
+ msgstr ""
269
+
270
+ #: lib/class-wp-smush-share.php:47
271
+ msgid "WhatsApp"
272
+ msgstr ""
273
+
274
+ #: lib/class-wp-smush-ui.php:46
275
  msgid "Dismiss Welcome notice"
276
  msgstr ""
277
 
278
+ #: lib/class-wp-smush-ui.php:62
279
  msgid "WELCOME"
280
  msgstr ""
281
 
282
+ #: lib/class-wp-smush-ui.php:70
283
  msgid "OH YEAH, IT'S COMPRESSION TIME!"
284
  msgstr ""
285
 
286
+ #: lib/class-wp-smush-ui.php:71
287
  msgid "You've just installed %3$s, the most popular image compression plugin for WordPress! %1$sChoose your desired settings%2$s and get smushing!"
288
  msgstr ""
289
 
290
+ #: lib/class-wp-smush-ui.php:85
291
  msgid "Smush individual images via your %sMedia Library%s"
292
  msgstr ""
293
 
294
+ #: lib/class-wp-smush-ui.php:85
295
  msgid "Media Library"
296
  msgstr ""
297
 
298
+ #: lib/class-wp-smush-ui.php:90
299
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:482
300
  msgid "BULK SMUSH"
301
  msgstr ""
302
 
303
+ #: lib/class-wp-smush-ui.php:104
304
  msgid "SETTINGS"
305
  msgstr ""
306
 
307
+ #: lib/class-wp-smush-ui.php:119
308
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:502
309
  msgid "Lets you check if any images can be further optimised. Useful after changing settings."
310
  msgstr ""
311
 
312
+ #: lib/class-wp-smush-ui.php:119
313
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:502
314
  msgid "RE-CHECK IMAGES"
315
  msgstr ""
316
 
317
+ #: lib/class-wp-smush-ui.php:120
318
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:503
319
  msgid "STATS"
320
  msgstr ""
321
 
322
+ #: lib/class-wp-smush-ui.php:123
323
+ msgid " You've smushed %d images in total"
 
324
  msgstr ""
325
 
326
+ #: lib/class-wp-smush-ui.php:148
327
+ #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:531
328
+ msgid "ATTACHMENTS SMUSHED"
329
  msgstr ""
330
 
331
+ #: lib/class-wp-smush-ui.php:154
332
+ #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:537
333
+ msgid "TOTAL SAVINGS"
334
  msgstr ""
335
 
336
+ #: lib/class-wp-smush-ui.php:170
337
+ #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:553
338
+ msgid "ATTACHMENTS SUPER-SMUSHED"
339
  msgstr ""
340
 
341
+ #: lib/class-wp-smush-ui.php:175 lib/class-wp-smush-ui.php:189
342
+ msgid "%sENABLE%s"
343
  msgstr ""
344
 
345
+ #: lib/class-wp-smush-ui.php:182
346
+ msgid "RESIZE SAVINGS"
 
347
  msgstr ""
348
 
349
+ #: lib/class-wp-smush-ui.php:199
350
+ msgid "PNG TO JPEG SAVINGS"
351
+ msgstr ""
352
+
353
+ #: lib/class-wp-smush-ui.php:229
354
+ msgid "%sTRY PRO FREE%s"
355
+ msgstr ""
356
+
357
+ #: lib/class-wp-smush-ui.php:231
358
+ msgid "BASED ON AVERAGE SAVINGS IF YOU UPGRADE TO PRO"
359
+ msgstr ""
360
+
361
+ #: lib/class-wp-smush-ui.php:232
362
+ msgid "PRO SAVINGS ESTIMATE"
363
  msgstr ""
364
 
365
+ #: lib/class-wp-smush-ui.php:263
366
  msgid "UPDATE SETTINGS"
367
  msgstr ""
368
 
369
+ #: lib/class-wp-smush-ui.php:284
370
+ msgid "%sTRY PRO FEATURES FREE%s"
371
  msgstr ""
372
 
373
+ #: lib/class-wp-smush-ui.php:286
374
  msgid "ADVANCED SETTINGS"
375
  msgstr ""
376
 
377
+ #: lib/class-wp-smush-ui.php:327
378
+ msgid "Enter 6 character Hexcode"
379
+ msgstr ""
380
+
381
+ #: lib/class-wp-smush-ui.php:332
382
+ msgid "Convert transparent images and use background color %s"
383
+ msgstr ""
384
+
385
+ #: lib/class-wp-smush-ui.php:334
386
+ msgid "Color hexcode should be 6 characters."
387
+ msgstr ""
388
+
389
+ #: lib/class-wp-smush-ui.php:411
390
+ msgid "The Following image sizes will be optimised by WP Smush:"
391
+ msgstr ""
392
+
393
+ #: lib/class-wp-smush-ui.php:462
394
  msgid "Width"
395
  msgstr ""
396
 
397
+ #: lib/class-wp-smush-ui.php:465
398
  msgid "Height"
399
  msgstr ""
400
 
401
+ #: lib/class-wp-smush-ui.php:468
402
  msgid "Currently, your largest thumbnail size is set at %s%dpx wide x %dpx high%s. Anything above 2048px in width or height is huge and not recommended."
403
  msgstr ""
404
 
405
+ #: lib/class-wp-smush-ui.php:469
406
  msgid "Just to let you know, the width you've entered is less than your largest thumbnail and may result in pixelation."
407
  msgstr ""
408
 
409
+ #: lib/class-wp-smush-ui.php:470
410
  msgid "Just to let you know, the height you’ve entered is less than your largest thumbnail and may result in pixelation."
411
  msgstr ""
412
 
413
+ #: lib/class-wp-smush-ui.php:580
 
 
 
 
414
  msgid "BOOST YOUR PERFORMANCE - HUMMINGBIRD"
415
  msgstr ""
416
 
417
+ #: lib/class-wp-smush-ui.php:607
418
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:423
419
  msgid "No attachments found - Upload some images"
420
  msgstr ""
421
 
422
+ #: lib/class-wp-smush-ui.php:609
423
  msgid "We haven’t found any images in your %smedia library%s yet so there’s no smushing to be done! Once you upload images, reload this page and start playing!"
424
  msgstr ""
425
 
426
+ #: lib/class-wp-smush-ui.php:612
427
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:428
428
  msgid "UPLOAD IMAGES"
429
  msgstr ""
430
 
431
+ #: lib/class-wp-smush-ui.php:617
432
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:433
433
  msgid "All images are smushed and up to date. Awesome!"
434
  msgstr ""
435
 
436
+ #: lib/class-wp-smush-ui.php:622
437
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:438
438
  msgid "BULK SMUSH NOW"
439
  msgstr ""
440
 
441
+ #: lib/class-wp-smush-ui.php:641
442
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:446
443
  msgid "%s, you have %s%s%d%s image%s that needs smushing!"
444
  msgid_plural "%s, you have %s%s%d%s images%s that need smushing!"
445
  msgstr[0] ""
446
  msgstr[1] ""
447
 
448
+ #: lib/class-wp-smush-ui.php:643
449
  msgid "You can %sUpgrade to Pro%s to bulk smush all your images with one click."
450
  msgstr ""
451
 
452
+ #: lib/class-wp-smush-ui.php:644
453
  msgid "Free users can smush 50 images with each click."
454
  msgstr ""
455
 
456
+ #: lib/class-wp-smush-ui.php:653
457
  msgid "Enable Super-smush in the Settings area to get even more savings with almost no noticeable quality loss."
458
  msgstr ""
459
 
460
+ #: lib/class-wp-smush-ui.php:676
461
+ msgid "%sBulk smush is currently running.%s You need to keep this page open for the process to complete."
462
  msgstr ""
463
 
464
+ #: lib/class-wp-smush-ui.php:686
465
  msgid "%s%d%s of %d attachments have been smushed."
466
  msgstr ""
467
 
468
+ #: lib/class-wp-smush-ui.php:691
469
  msgid "CANCEL"
470
  msgstr ""
471
 
472
+ #: lib/class-wp-smush-ui.php:727
473
  msgid "%s, you have %s%s%d%s image%s that needs re-compressing!"
474
  msgid_plural "%s, you have %s%s%d%s images%s that need re-compressing!"
475
  msgstr[0] ""
476
  msgstr[1] ""
477
 
478
+ #: lib/class-wp-smush-ui.php:728
479
  msgid "Skip"
480
  msgstr ""
481
 
482
+ #: lib/class-wp-smush-ui.php:742
483
  msgid "Your settings have been updated!"
484
  msgstr ""
485
 
486
+ #: lib/class-wp-smush-ui.php:776
487
  msgid "Automatic smushing is %senabled%s. Newly uploaded images will be automagically compressed."
488
  msgstr ""
489
 
490
+ #: lib/class-wp-smush-ui.php:776
491
  msgid "Automatic smushing is %sdisabled%s. Newly uploaded images will need to be manually smushed."
492
  msgstr ""
493
 
494
+ #: lib/class-wp-smush-ui.php:807
495
  msgid "Thanks for installing Smush. We hope you like it!"
496
  msgstr ""
497
 
498
+ #: lib/class-wp-smush-ui.php:808
499
  msgid "And hey, if you do, you can now try out Smush Pro for double the smushy goodness (benchmarked), entirely for free!"
500
  msgstr ""
501
 
502
+ #: lib/class-wp-smush-ui.php:809 lib/class-wp-smush-ui.php:813
503
  msgid "Try Smush Pro for Free"
504
  msgstr ""
505
 
506
+ #: lib/class-wp-smush-ui.php:811
507
  msgid "Thanks for updating Smush. Did you know that you can now try the Smush Pro for FREE?!"
508
  msgstr ""
509
 
510
+ #: lib/class-wp-smush-ui.php:812
511
  msgid "Yep, Super Smush your images for double the savings, save originals and batch Smush thousands of images all at once.... no charge!"
512
  msgstr ""
513
 
514
+ #: lib/class-wp-smush-ui.php:859
515
  msgid "Did you know WP Smush Pro delivers up to 10x better compression, allows you to smush your originals and removes any bulk smushing limits? – %sTry it absolutely FREE%s"
516
  msgstr ""
517
 
518
+ #: lib/class-wp-smush-ui.php:859
519
  msgid "Try WP Smush Pro for FREE"
520
  msgstr ""
521
 
522
+ #: lib/class-wp-smush.php:172
523
  msgid "File path is empty"
524
  msgstr ""
525
 
526
+ #: lib/class-wp-smush.php:177
527
  msgid "Could not find %s"
528
  msgstr ""
529
 
530
+ #: lib/class-wp-smush.php:182
531
  msgid "%s is not writable"
532
  msgstr ""
533
 
534
+ #: lib/class-wp-smush.php:192
535
  msgid "Skipped (%s), image not found. Attachment: %s"
536
  msgstr ""
537
 
538
+ #: lib/class-wp-smush.php:197
539
  msgid "Skipped (%s), size limit exceeded. Attachment: %s"
540
  msgstr ""
541
 
542
+ #: lib/class-wp-smush.php:216
543
  msgid "Unknown API error"
544
  msgstr ""
545
 
546
+ #: lib/class-wp-smush.php:646
547
  msgid "Error posting to API: %s"
548
  msgstr ""
549
 
550
+ #: lib/class-wp-smush.php:652
551
  msgid "Error posting to API: %s %s"
552
  msgstr ""
553
 
554
+ #: lib/class-wp-smush.php:669
555
  msgid "Smush data corrupted, try again."
556
  msgstr ""
557
 
558
+ #: lib/class-wp-smush.php:685
559
  msgid "Image couldn't be smushed"
560
  msgstr ""
561
 
562
+ #: lib/class-wp-smush.php:906 lib/class-wp-smush.php:910
563
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:193
564
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:196
565
  msgid "Already Optimized"
566
  msgstr ""
567
 
568
+ #: lib/class-wp-smush.php:919
569
  msgid "%d images reduced "
570
  msgstr ""
571
 
572
+ #: lib/class-wp-smush.php:919
573
  msgid "Reduced "
574
  msgstr ""
575
 
576
+ #: lib/class-wp-smush.php:923
577
+ msgid "by %s %s"
578
+ msgstr ""
579
+
580
+ #: lib/class-wp-smush.php:929
581
+ msgid "<br /> Image Size: %s"
582
  msgstr ""
583
 
584
+ #: lib/class-wp-smush.php:965
585
  msgid "Detailed stats for all the image sizes"
586
  msgstr ""
587
 
588
+ #: lib/class-wp-smush.php:965
589
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:236
590
  msgid "Smush stats"
591
  msgstr ""
592
 
593
+ #: lib/class-wp-smush.php:997
594
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:249
595
  msgid "Not processed"
596
  msgstr ""
597
 
598
+ #: lib/class-wp-smush.php:1003
599
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:255
600
  msgid "Smush Now!"
601
  msgstr ""
602
 
603
+ #: lib/class-wp-smush.php:1305
604
  msgid "When you upload an image to WordPress it automatically creates %s thumbnail sizes that are commonly used in your pages. WordPress also stores the original full-size image, but because these are not usually embedded on your site we don’t Smush them. Pro users can override this."
605
  msgstr ""
606
 
607
+ #: lib/class-wp-smush.php:1308
608
  msgid "Image couldn't be smushed as it exceeded the 1Mb size limit, Pro users can smush images with size upto 32Mb."
609
  msgstr ""
610
 
611
+ #: lib/class-wp-smush.php:1310
612
  msgid " Skipped"
613
  msgstr ""
614
 
615
+ #: lib/class-wp-smush.php:1332
616
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:432
617
  msgid "Image size"
618
  msgstr ""
619
 
620
+ #: lib/class-wp-smush.php:1333
621
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:433
622
  msgid "Savings"
623
  msgstr ""
624
 
625
+ #: lib/class-wp-smush.php:1535
626
  msgid "Restore original image."
627
  msgstr ""
628
 
629
+ #: lib/class-wp-smush.php:1535
630
  msgid "Restore image"
631
  msgstr ""
632
 
633
+ #: lib/class-wp-smush.php:1580
634
  msgid "Smush image including original file."
635
  msgstr ""
636
 
637
+ #: lib/class-wp-smush.php:1580
638
  msgid "Resmush image"
639
  msgstr ""
640
 
658
  msgid "Manage Galleries"
659
  msgstr ""
660
 
661
+ #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:561
662
  msgid "%sDISABLED%s"
663
  msgstr ""
664
 
670
  msgid "Reduced by %s ( %01.1f%% )"
671
  msgstr ""
672
 
673
+ #: wp-smush.php:156
674
  msgid "Get Fast"
675
  msgstr ""
676
 
677
+ #: wp-smush.php:197
678
  msgid "WP Smush Free was deactivated. You have WP Smush Pro active!"
679
  msgstr ""
680
  #. Plugin Name of the plugin/theme
lib/class-wp-smush-admin.php CHANGED
@@ -92,6 +92,9 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
92
 
93
  private $attachments = '';
94
 
 
 
 
95
  /**
96
  * Constructor
97
  */
@@ -109,9 +112,6 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
109
  //Handle Smush Single Ajax
110
  add_action( 'wp_ajax_wp_smushit_manual', array( $this, 'smush_manual' ) );
111
 
112
- //Handle Restore operation
113
- add_action( 'wp_ajax_smush_restore_image', array( $this, 'restore_image' ) );
114
-
115
  //Handle Restore operation
116
  add_action( 'wp_ajax_smush_resmush_image', array( $this, 'resmush_image' ) );
117
 
@@ -158,29 +158,33 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
158
 
159
  function init_settings() {
160
  $this->settings = array(
161
- 'auto' => array(
162
  'label' => esc_html__( 'Automatically smush my images on upload', 'wp-smushit' ),
163
  'desc' => esc_html__( 'When you upload images to the media library, we’ll automatically optimize them.', 'wp-smushit' )
164
  ),
165
- 'keep_exif' => array(
166
  'label' => esc_html__( 'Preserve image EXIF data', 'wp-smushit' ),
167
  'desc' => esc_html__( 'EXIF data stores camera settings, focal length, date, time and location information in image files. EXIF data makes image files larger but if you are a photographer you may want to preserve this information.', 'wp-smushit' )
168
  ),
169
- 'resize' => array(
170
  'label' => esc_html__( 'Resize original images', 'wp-smushit' ),
171
- 'desc' => esc_html__( 'Save a ton of space by not storing over-sized images on your server. Set image maximum width and height and large images will be automatically scaled before being added to the media library. ', 'wp-smushit' )
172
  ),
173
- 'lossy' => array(
174
  'label' => esc_html__( 'Super-smush my images', 'wp-smushit' ),
175
  'desc' => esc_html__( 'Compress images up to 10x more than regular smush with almost no visible drop in quality.', 'wp-smushit' )
176
  ),
177
- 'original' => array(
178
  'label' => esc_html__( 'Include my original full-size images', 'wp-smushit' ),
179
  'desc' => esc_html__( 'WordPress crops and resizes every image you upload for embedding on your site. By default, Smush only compresses these cropped and resized images, not your original full-size images. To save space on your server, activate this setting to smush your original images, too. Note: This doesn’t usually improve page speed.', 'wp-smushit' )
180
  ),
181
- 'backup' => array(
182
  'label' => esc_html__( 'Make a copy of my original images', 'wp-smushit' ),
183
  'desc' => esc_html__( 'Save your original full-size images so you can restore them at any point. Note: Activating this setting will significantly increase the size of your uploads folder by nearly twice as much.', 'wp-smushit' )
 
 
 
 
184
  )
185
  );
186
 
@@ -191,6 +195,9 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
191
  'desc' => esc_html__( 'Allow smushing images directly through NextGen Gallery settings.', 'wp-smushit' )
192
  );
193
  }
 
 
 
194
  }
195
 
196
  /**
@@ -267,7 +274,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
267
  $enqueue_smush = apply_filters( 'wp_smush_enqueue', true );
268
 
269
  //If we upgrade/install message is dismissed and for pro users
270
- if ( get_option( 'wp-smush-hide_upgrade_notice' ) || get_site_option( 'wp-smush-hide_upgrade_notice' ) || $this->is_pro() ) {
271
  //Do not enqueue, unless it is one of the required screen
272
  if ( ! $enqueue_smush || ( $current_page != 'nggallery-manage-images' && $current_page != 'gallery_page_wp-smush-nextgen-bulk' && $pagenow != 'post.php' && $pagenow != 'post-new.php' && $pagenow != 'upload.php' ) ) {
273
 
@@ -373,9 +380,10 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
373
  global $wpsmush_stats;
374
  $this->total_count = $wpsmush_stats->total_count();
375
  $this->smushed_attachments = $wpsmush_stats->smushed_count( true );
376
- $this->smushed_count = !empty( $this->smushed_attachments ) ? count( $this->smushed_attachments ) : 0;
377
  $this->remaining_count = $this->remaining_count();
378
- $this->stats = $this->global_stats( $force_update );
 
379
  }
380
 
381
  /**
@@ -408,7 +416,6 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
408
  //Store Option Name and their values in an array
409
  $settings = array();
410
 
411
-
412
  // process each setting and update options
413
  foreach ( $this->settings as $name => $text ) {
414
 
@@ -427,6 +434,11 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
427
  unset( $setting );
428
  }
429
 
 
 
 
 
 
430
  //Update Resize width and height settings if set
431
  $resize_sizes['width'] = isset( $_POST['wp-smush-resize_width'] ) ? intval( $_POST['wp-smush-resize_width'] ) : 0;
432
  $resize_sizes['height'] = isset( $_POST['wp-smush-resize_height'] ) ? intval( $_POST['wp-smush-resize_height'] ) : 0;
@@ -434,6 +446,20 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
434
  // update the resize sizes
435
  update_option( WP_SMUSH_PREFIX . 'resize_sizes', $resize_sizes );
436
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
437
  //Store the option in table
438
  update_option( 'wp-smush-settings_updated', 1 );
439
 
@@ -487,7 +513,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
487
  wp_send_json_error( 'missing id' );
488
  }
489
 
490
- if ( ! $this->is_pro() ) {
491
  //Free version bulk smush, check the transient counter value
492
  $should_continue = $this->check_bulk_limit();
493
  }
@@ -525,6 +551,11 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
525
  wp_update_attachment_metadata( $attachment_id, $original_meta );
526
  }
527
 
 
 
 
 
 
528
  $smush = $WpSmush->resize_from_meta_data( $original_meta, $attachment_id );
529
 
530
  //Get the updated Global Stats
@@ -541,8 +572,9 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
541
  $error = $smush->get_error_message();
542
  //Check for timeout error and suggest to filter timeout
543
  if ( strpos( $error, 'timed out' ) ) {
544
- $error = '<p class="wp-smush-error-message">' . esc_html__( "Smush request timed out, You can try setting a higher value for `WP_SMUSH_API_TIMEOUT`.", "wp-smushit" ) . '</p>';
545
  }
 
546
  } else {
547
  //Check if a resmush request, update the resmush list
548
  if ( ! empty( $_REQUEST['is_bulk_resmush'] ) && 'false' != $_REQUEST['is_bulk_resmush'] && $_REQUEST['is_bulk_resmush'] ) {
@@ -551,16 +583,18 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
551
  }
552
  $resmush_count = empty( $this->resmush_ids ) ? count( $this->resmush_ids = get_option( "wp-smush-resmush-list" ) ) : count( $this->resmush_ids );
553
 
554
- $stats['smushed'] = !empty( $this->resmush_ids ) ? $this->smushed_count - $resmush_count : $this->smushed_count;
555
 
556
  if ( $WpSmush->lossy_enabled ) {
557
  $stats['super_smushed'] = $wpsmush_stats->super_smushed_count();
558
  }
559
 
560
- $stats['tooltip_text'] = ! empty( $stats['total_images'] ) ? sprintf( esc_html__( "%d images", "wp-smushit" ), $stats['total_images'] ) : '';
561
 
562
  //Send ajax response
563
- $send_error ? wp_send_json_error( array( 'stats' => $stats, 'error_msg' => $error ) ) : wp_send_json_success( array( 'stats' => $stats ) );
 
 
564
 
565
  }
566
 
@@ -596,15 +630,18 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
596
  */
597
  function smush_single( $attachment_id, $return = false ) {
598
 
599
- global $WpSmush;
600
 
601
  $attachment_id = absint( (int) ( $attachment_id ) );
602
 
603
  $original_meta = wp_get_attachment_metadata( $attachment_id );
604
 
605
- //Send image for resizing
606
  $updated_meta = $this->resize_image( $attachment_id, $original_meta );
607
 
 
 
 
608
  $original_meta = ! empty( $updated_meta ) ? $updated_meta : $original_meta;
609
 
610
  //Update the details, as soon as we are done with resizing
@@ -756,7 +793,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
756
  */
757
  function global_stats( $force_update = false ) {
758
 
759
- if ( ! $force_update && $stats = wp_cache_get( 'global_stats', 'wp_smush' ) ) {
760
  if ( ! empty( $stats ) ) {
761
  return $stats;
762
  }
@@ -784,7 +821,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
784
  $global_data = $wpdb->get_col( $wpdb->prepare( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key=%s LIMIT $offset, $limit", "wp-smpro-smush-data" ) );
785
 
786
  if ( ! empty( $global_data ) ) {
787
- $smush_data['count'] = 0;
788
  $smush_data['total_images'] = 0;
789
  foreach ( $global_data as $data ) {
790
  $data = maybe_unserialize( $data );
@@ -812,10 +849,14 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
812
 
813
  }
814
 
815
- $resize_savings = $wpsmush_stats->resize_savings( false );
816
-
817
  $smush_data['resize_savings'] = ! empty( $resize_savings['bytes'] ) ? $resize_savings['bytes'] : 0;
818
 
 
 
 
 
819
  if ( ! isset( $smush_data['bytes'] ) || $smush_data['bytes'] < 0 ) {
820
  $smush_data['bytes'] = 0;
821
  }
@@ -825,16 +866,23 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
825
  $smush_data['size_before'] += $resize_savings['size_before'];
826
  $smush_data['size_after'] += $resize_savings['size_after'];
827
 
828
- //Add the size before and after
 
 
 
829
 
 
830
  $smush_data['resize_savings'] = $this->format_bytes( $smush_data['resize_savings'] );
831
 
 
 
 
832
  if ( $smush_data['size_before'] > 0 ) {
833
  $smush_data['percent'] = ( $smush_data['bytes'] / $smush_data['size_before'] ) * 100;
834
  }
835
 
836
  //Round off precentage
837
- $smush_data['percent'] = round( $smush_data['percent'], 2 );
838
 
839
  $smush_data['human'] = $WpSmush->format_bytes( $smush_data['bytes'] );
840
 
@@ -844,6 +892,121 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
844
  return $smush_data;
845
  }
846
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
847
  /**
848
  * Returns Bulk smush button id and other details, as per if bulk request is already sent or not
849
  *
@@ -856,7 +1019,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
856
  $button = array(
857
  'cancel' => false,
858
  );
859
- if ( $this->is_pro() && $resmush ) {
860
 
861
  $button['text'] = __( 'Bulk Smush Now', 'wp-smushit' );
862
  $button['class'] = 'wp-smush-button wp-smush-resmush wp-smush-all';
@@ -922,7 +1085,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
922
  function smush_upgrade() {
923
 
924
  //Return, If a pro user, or not super admin, or don't have the admin privilleges
925
- if ( $this->is_pro() || ! current_user_can( 'edit_others_posts' ) || ! is_super_admin() ) {
926
  return;
927
  }
928
 
@@ -970,16 +1133,16 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
970
 
971
  while ( $query_next ) {
972
  // get the attachment id, smush data
973
- $sql = "SELECT p.ID as attachment_id, p.post_mime_type as type, ms.meta_value as smush_data"
974
- . " FROM $wpdb->posts as p"
975
- . " LEFT JOIN $wpdb->postmeta as ms"
976
- . " ON (p.ID= ms.post_id AND ms.meta_key='wp-smpro-smush-data')"
977
- . " WHERE"
978
- . " p.post_type='attachment'"
979
- . " AND p.post_mime_type IN " . $allowed_images
980
- . " ORDER BY p . ID DESC"
981
- // add a limit
982
- . " LIMIT " . $limit;
983
  $results = $wpdb->get_results( $sql );
984
 
985
  //Update the offset
@@ -1027,116 +1190,19 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1027
  }
1028
 
1029
  //From Ajax
1030
- if( !empty( $_REQUEST['action'] ) && 'dismiss_update_info' == $_REQUEST['action']) {
1031
  $remove_notice = true;
1032
  }
1033
 
1034
  //Update Db
1035
- if( $remove_notice ) {
1036
  update_site_option( 'wp-smush-hide_update_info', 1 );
1037
  }
1038
 
1039
  }
1040
 
1041
  /**
1042
- * Restore the image and its sizes from backup
1043
- */
1044
- function restore_image( $attachment = '', $resp = true ) {
1045
-
1046
- if ( empty( $attachment ) ) {
1047
- //Check Empty fields
1048
- if ( empty( $_POST['attachment_id'] ) || empty( $_POST['_nonce'] ) ) {
1049
- wp_send_json_error( array(
1050
- 'error' => 'empty_fields',
1051
- 'message' => esc_html__( "Error in processing restore action, Fields empty.", "wp-smushit" )
1052
- ) );
1053
- }
1054
- //Check Nonce
1055
- if ( ! wp_verify_nonce( $_POST['_nonce'], "wp-smush-restore-" . $_POST['attachment_id'] ) ) {
1056
- wp_send_json_error( array(
1057
- 'error' => 'empty_fields',
1058
- 'message' => esc_html__( "Image not restored, Nonce verification failed.", "wp-smushit" )
1059
- ) );
1060
- }
1061
- }
1062
-
1063
- //Store the restore success/failure for all the sizes
1064
- $restored = array();
1065
-
1066
- //Process Now
1067
- $image_id = empty( $attachment ) ? absint( (int) $_POST['attachment_id'] ) : $attachment;
1068
-
1069
- //Restore Full size -> get other image sizes -> restore other images
1070
-
1071
- //Get the Original Path
1072
- $file_path = get_attached_file( $image_id );
1073
-
1074
- //Get the backup path
1075
- $backup_name = $this->get_image_backup_path( $file_path );
1076
-
1077
- //If file exists, corresponding to our backup path
1078
- if ( file_exists( $backup_name ) ) {
1079
- //Restore
1080
- $restored[] = @copy( $backup_name, $file_path );
1081
-
1082
- //Delete the backup
1083
- @unlink( $backup_name );
1084
- } elseif ( file_exists( $file_path . '_backup' ) ) {
1085
- //Restore from other backups
1086
- $restored[] = @copy( $file_path . '_backup', $file_path );
1087
- }
1088
-
1089
- //Get other sizes and restore
1090
- //Get attachment data
1091
- $attachment_data = wp_get_attachment_metadata( $image_id );
1092
-
1093
- //Get the sizes
1094
- $sizes = ! empty( $attachment_data['sizes'] ) ? $attachment_data['sizes'] : '';
1095
-
1096
- //Loop on images to restore them
1097
- foreach ( $sizes as $size ) {
1098
- //Get the file path
1099
- if ( empty( $size['file'] ) ) {
1100
- continue;
1101
- }
1102
-
1103
- //Image Path and Backup path
1104
- $image_size_path = path_join( dirname( $file_path ), $size['file'] );
1105
- $image_bckup_path = $this->get_image_backup_path( $image_size_path );
1106
-
1107
- //Restore
1108
- if ( file_exists( $image_bckup_path ) ) {
1109
- $restored[] = @copy( $image_bckup_path, $image_size_path );
1110
- //Delete the backup
1111
- @unlink( $image_bckup_path );
1112
- } elseif ( file_exists( $image_size_path . '_backup' ) ) {
1113
- $restored[] = @copy( $image_size_path . '_backup', $image_size_path );
1114
- }
1115
- }
1116
- //If any of the image is restored, we count it as success
1117
- if ( in_array( true, $restored ) ) {
1118
-
1119
- //Remove the Meta, And send json success
1120
- delete_post_meta( $image_id, $this->smushed_meta_key );
1121
-
1122
- //Get the Button html without wrapper
1123
- $button_html = $this->set_status( $image_id, false, false, false );
1124
-
1125
- if ( $resp ) {
1126
- wp_send_json_success( array( 'button' => $button_html ) );
1127
- } else {
1128
- return true;
1129
- }
1130
- }
1131
- if ( $resp ) {
1132
- wp_send_json_error( array( 'message' => '<div class="wp-smush-error">' . __( "Unable to restore image", "wp-smushit" ) . '</div>' ) );
1133
- }
1134
-
1135
- return false;
1136
- }
1137
-
1138
- /**
1139
- * Restore the image and its sizes from backup
1140
  *
1141
  * @uses smush_single()
1142
  *
@@ -1251,6 +1317,8 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1251
  if ( ! empty( $attachments ) && is_array( $attachments ) ) {
1252
  foreach ( $attachments as $attachment_k => $attachment ) {
1253
 
 
 
1254
  //For NextGen we get the metadata in the attachment data itself
1255
  if ( ! empty( $attachment['wp_smush'] ) ) {
1256
  $smush_data = $attachment['wp_smush'];
@@ -1259,6 +1327,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1259
  $smush_data = get_post_meta( $attachment, $this->smushed_meta_key, true );
1260
  }
1261
 
 
1262
  if ( ! empty( $smush_data['stats'] ) ) {
1263
 
1264
  //If we need to optmise losslessly, add to resmush list
@@ -1271,6 +1340,27 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1271
  $smush_original = $WpSmush->smush_original && empty( $smush_data['sizes']['full'] );
1272
 
1273
  if ( $smush_lossy || $strip_exif || $smush_original ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1274
  $resmush_list[] = 'nextgen' == $type ? $attachment_k : $attachment;
1275
  continue;
1276
  }
@@ -1317,9 +1407,9 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1317
  //Set the variables
1318
  $this->resmush_ids = $resmush_list;
1319
 
1320
- $resmush_count = count( $this->resmush_ids );
1321
 
1322
- $smushed = !empty( $this->resmush_ids ) ? $this->smushed_count - $resmush_count : $this->smushed_count;
1323
 
1324
  } else {
1325
  //To avoid the php warning
@@ -1346,13 +1436,13 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1346
  }
1347
 
1348
  //If there is a Ajax response return it, else return null
1349
- $return = ! empty( $ajax_response ) ? array(
1350
  "resmush_ids" => $resmush_list,
1351
  "content" => $ajax_response
1352
  ) : '';
1353
 
1354
  //Include the count
1355
- if( !empty( $count) && $count ) {
1356
  $return['count'] = $count;
1357
  }
1358
 
@@ -1551,10 +1641,10 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1551
  * Allows to bulk restore the images, if there is any backup for them
1552
  */
1553
  function bulk_restore() {
1554
- global $wpsmush_stats;
1555
- $smushed_attachments = !empty( $this->smushed_attachments ) ? $this->smushed_attachments : $wpsmush_stats->smushed_count( true );
1556
  foreach ( $smushed_attachments as $attachment ) {
1557
- $this->restore_image( $attachment->attachment_id, false );
1558
  }
1559
  }
1560
 
@@ -1718,7 +1808,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1718
  }
1719
 
1720
  //Handles the dismiss action
1721
- $js_url = WP_SMUSH_URL . 'assets/js/notice.js';
1722
  $upgrade_url = add_query_arg(
1723
  array(
1724
  'utm_source' => 'Smush-Free',
@@ -1729,7 +1819,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1729
  );
1730
 
1731
  $settings_link = '<a href="' . admin_url( 'upload.php?page=wp-smush-bulk#wp-smush-settings-box' ) . '" title="' . esc_html__( "Settings", "wp-smushit" ) . '">';
1732
- $upgrade_link = '<a href="' . esc_url( $upgrade_url ) . '" title="' . esc_html__( "WP Smush Pro", "wp-smushit" ) . '">';
1733
  ?>
1734
  <div class="notice notice-info is-dismissible wp-smush-update-info">
1735
  <p><?php printf( esc_html__( "Woohoo! Your latest Smush update %s allows you to %sauto resize%s all your images, how cool is that! %sFind out more here >>%s", 'wp-smushit' ), WP_SMUSH_VERSION, $settings_link, '</a>', $upgrade_link, '</a>' ); ?></p>
@@ -1738,6 +1828,73 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1738
  <script src="<?php echo esc_url( $js_url ) . '?v=' . WP_SMUSH_VERSION; ?>"></script><?php
1739
  }
1740
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1741
  }
1742
 
1743
  global $wpsmushit_admin;
92
 
93
  private $attachments = '';
94
 
95
+
96
+ public $image_sizes = array();
97
+
98
  /**
99
  * Constructor
100
  */
112
  //Handle Smush Single Ajax
113
  add_action( 'wp_ajax_wp_smushit_manual', array( $this, 'smush_manual' ) );
114
 
 
 
 
115
  //Handle Restore operation
116
  add_action( 'wp_ajax_smush_resmush_image', array( $this, 'resmush_image' ) );
117
 
158
 
159
  function init_settings() {
160
  $this->settings = array(
161
+ 'auto' => array(
162
  'label' => esc_html__( 'Automatically smush my images on upload', 'wp-smushit' ),
163
  'desc' => esc_html__( 'When you upload images to the media library, we’ll automatically optimize them.', 'wp-smushit' )
164
  ),
165
+ 'keep_exif' => array(
166
  'label' => esc_html__( 'Preserve image EXIF data', 'wp-smushit' ),
167
  'desc' => esc_html__( 'EXIF data stores camera settings, focal length, date, time and location information in image files. EXIF data makes image files larger but if you are a photographer you may want to preserve this information.', 'wp-smushit' )
168
  ),
169
+ 'resize' => array(
170
  'label' => esc_html__( 'Resize original images', 'wp-smushit' ),
171
+ 'desc' => esc_html__( 'Save a ton of space by not storing over-sized images on your server. Set image maximum width and height and large images will be automatically scaled before being added to the media library.', 'wp-smushit' )
172
  ),
173
+ 'lossy' => array(
174
  'label' => esc_html__( 'Super-smush my images', 'wp-smushit' ),
175
  'desc' => esc_html__( 'Compress images up to 10x more than regular smush with almost no visible drop in quality.', 'wp-smushit' )
176
  ),
177
+ 'original' => array(
178
  'label' => esc_html__( 'Include my original full-size images', 'wp-smushit' ),
179
  'desc' => esc_html__( 'WordPress crops and resizes every image you upload for embedding on your site. By default, Smush only compresses these cropped and resized images, not your original full-size images. To save space on your server, activate this setting to smush your original images, too. Note: This doesn’t usually improve page speed.', 'wp-smushit' )
180
  ),
181
+ 'backup' => array(
182
  'label' => esc_html__( 'Make a copy of my original images', 'wp-smushit' ),
183
  'desc' => esc_html__( 'Save your original full-size images so you can restore them at any point. Note: Activating this setting will significantly increase the size of your uploads folder by nearly twice as much.', 'wp-smushit' )
184
+ ),
185
+ 'png_to_jpg' => array(
186
+ 'label' => esc_html__( 'Convert PNG to JPEG (lossy)', 'wp-smushit' ),
187
+ 'desc' => esc_html__( "When you optimise a PNG, Smush will check if converting it to a JPEG will reduce the file size, and if so it will automatically convert it. Note: Smush will only convert the file format if it results in smaller file size. This will change the file's name, any hardcoded URLs will need updating.", 'wp-smushit' )
188
  )
189
  );
190
 
195
  'desc' => esc_html__( 'Allow smushing images directly through NextGen Gallery settings.', 'wp-smushit' )
196
  );
197
  }
198
+
199
+ //Initialize Image dimensions
200
+ $this->image_sizes = $this->image_dimensions();
201
  }
202
 
203
  /**
274
  $enqueue_smush = apply_filters( 'wp_smush_enqueue', true );
275
 
276
  //If we upgrade/install message is dismissed and for pro users
277
+ if ( get_option( 'wp-smush-hide_upgrade_notice' ) || get_site_option( 'wp-smush-hide_upgrade_notice' ) || $this->validate_install() ) {
278
  //Do not enqueue, unless it is one of the required screen
279
  if ( ! $enqueue_smush || ( $current_page != 'nggallery-manage-images' && $current_page != 'gallery_page_wp-smush-nextgen-bulk' && $pagenow != 'post.php' && $pagenow != 'post-new.php' && $pagenow != 'upload.php' ) ) {
280
 
380
  global $wpsmush_stats;
381
  $this->total_count = $wpsmush_stats->total_count();
382
  $this->smushed_attachments = $wpsmush_stats->smushed_count( true );
383
+ $this->smushed_count = ! empty( $this->smushed_attachments ) ? count( $this->smushed_attachments ) : 0;
384
  $this->remaining_count = $this->remaining_count();
385
+ $this->stats = $this->global_stats_from_ids( $force_update );
386
+ // $this->stats = $this->global_stats( $force_update );
387
  }
388
 
389
  /**
416
  //Store Option Name and their values in an array
417
  $settings = array();
418
 
 
419
  // process each setting and update options
420
  foreach ( $this->settings as $name => $text ) {
421
 
434
  unset( $setting );
435
  }
436
 
437
+ //Save the selected image sizes
438
+ $image_sizes = !empty( $_POST['wp-smush-image_sizes'] ) ? $_POST['wp-smush-image_sizes'] : array();
439
+ $image_sizes = array_filter( array_map("sanitize_text_field", $image_sizes ) );
440
+ update_option( WP_SMUSH_PREFIX . 'image_sizes', $image_sizes );
441
+
442
  //Update Resize width and height settings if set
443
  $resize_sizes['width'] = isset( $_POST['wp-smush-resize_width'] ) ? intval( $_POST['wp-smush-resize_width'] ) : 0;
444
  $resize_sizes['height'] = isset( $_POST['wp-smush-resize_height'] ) ? intval( $_POST['wp-smush-resize_height'] ) : 0;
446
  // update the resize sizes
447
  update_option( WP_SMUSH_PREFIX . 'resize_sizes', $resize_sizes );
448
 
449
+ //Transparent PNG Conversion settings
450
+ $transparent_png['convert'] = isset( $_POST['wp-smush-png_to_jpg_transparent'] ) ? 1 : 0;
451
+
452
+ //Validate Hexcode and Store it
453
+ $transparent_png['background'] = isset( $_POST['wp-smush-png_to_jpg_background'] ) && ctype_xdigit( $_POST['wp-smush-png_to_jpg_background'] ) ? sanitize_hex_color_no_hash( $_POST['wp-smush-png_to_jpg_background'] ) : 'ffffff';
454
+
455
+ //If background is not set, or length is not proper
456
+ if ( empty( $transparent_png['background'] ) || strlen( $transparent_png['background'] ) < 6 ) {
457
+ $transparent_png['background'] = 'ffffff';
458
+ }
459
+
460
+ // update the Transparent PNG settings
461
+ update_option( WP_SMUSH_PREFIX . 'transparent_png', $transparent_png );
462
+
463
  //Store the option in table
464
  update_option( 'wp-smush-settings_updated', 1 );
465
 
513
  wp_send_json_error( 'missing id' );
514
  }
515
 
516
+ if ( ! $this->validate_install() ) {
517
  //Free version bulk smush, check the transient counter value
518
  $should_continue = $this->check_bulk_limit();
519
  }
551
  wp_update_attachment_metadata( $attachment_id, $original_meta );
552
  }
553
 
554
+ global $wpsmush_pngjpg;
555
+
556
+ //Convert PNGs to JPG
557
+ $original_meta = $wpsmush_pngjpg->png_to_jpg( $attachment_id, $original_meta );
558
+
559
  $smush = $WpSmush->resize_from_meta_data( $original_meta, $attachment_id );
560
 
561
  //Get the updated Global Stats
572
  $error = $smush->get_error_message();
573
  //Check for timeout error and suggest to filter timeout
574
  if ( strpos( $error, 'timed out' ) ) {
575
+ $error = esc_html__( "Smush request timed out, You can try setting a higher value for `WP_SMUSH_API_TIMEOUT`.", "wp-smushit" );
576
  }
577
+ $error = '<p class="wp-smush-error-message">' . $error . '</p>';
578
  } else {
579
  //Check if a resmush request, update the resmush list
580
  if ( ! empty( $_REQUEST['is_bulk_resmush'] ) && 'false' != $_REQUEST['is_bulk_resmush'] && $_REQUEST['is_bulk_resmush'] ) {
583
  }
584
  $resmush_count = empty( $this->resmush_ids ) ? count( $this->resmush_ids = get_option( "wp-smush-resmush-list" ) ) : count( $this->resmush_ids );
585
 
586
+ $stats['smushed'] = ! empty( $this->resmush_ids ) ? $this->smushed_count - $resmush_count : $this->smushed_count;
587
 
588
  if ( $WpSmush->lossy_enabled ) {
589
  $stats['super_smushed'] = $wpsmush_stats->super_smushed_count();
590
  }
591
 
592
+ $stats['tooltip_text'] = ! empty( $stats['total_images'] ) ? sprintf( esc_html__( "You've smushed %d images in total.", "wp-smushit" ), $stats['total_images'] ) : '';
593
 
594
  //Send ajax response
595
+ $send_error ? wp_send_json_error( array( 'stats' => $stats,
596
+ 'error_msg' => $error
597
+ ) ) : wp_send_json_success( array( 'stats' => $stats ) );
598
 
599
  }
600
 
630
  */
631
  function smush_single( $attachment_id, $return = false ) {
632
 
633
+ global $WpSmush, $wpsmush_pngjpg;
634
 
635
  $attachment_id = absint( (int) ( $attachment_id ) );
636
 
637
  $original_meta = wp_get_attachment_metadata( $attachment_id );
638
 
639
+ //Send image for resizing, if enabled resize first before any other operation
640
  $updated_meta = $this->resize_image( $attachment_id, $original_meta );
641
 
642
+ //Convert PNGs to JPG
643
+ $updated_meta = $wpsmush_pngjpg->png_to_jpg( $attachment_id, $updated_meta );
644
+
645
  $original_meta = ! empty( $updated_meta ) ? $updated_meta : $original_meta;
646
 
647
  //Update the details, as soon as we are done with resizing
793
  */
794
  function global_stats( $force_update = false ) {
795
 
796
+ if ( ! $force_update && $stats = wp_cache_get( 'smush_global_stats' ) ) {
797
  if ( ! empty( $stats ) ) {
798
  return $stats;
799
  }
821
  $global_data = $wpdb->get_col( $wpdb->prepare( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key=%s LIMIT $offset, $limit", "wp-smpro-smush-data" ) );
822
 
823
  if ( ! empty( $global_data ) ) {
824
+ $smush_data['count'] = 0;
825
  $smush_data['total_images'] = 0;
826
  foreach ( $global_data as $data ) {
827
  $data = maybe_unserialize( $data );
849
 
850
  }
851
 
852
+ //Resize Savings
853
+ $resize_savings = $wpsmush_stats->resize_savings( false );
854
  $smush_data['resize_savings'] = ! empty( $resize_savings['bytes'] ) ? $resize_savings['bytes'] : 0;
855
 
856
+ //Conversion Savings
857
+ $conversion_savings = $wpsmush_stats->conversion_savings( false );
858
+ $smush_data['conversion_savings'] = ! empty( $conversion_savings['bytes'] ) ? $conversion_savings['bytes'] : 0;
859
+
860
  if ( ! isset( $smush_data['bytes'] ) || $smush_data['bytes'] < 0 ) {
861
  $smush_data['bytes'] = 0;
862
  }
866
  $smush_data['size_before'] += $resize_savings['size_before'];
867
  $smush_data['size_after'] += $resize_savings['size_after'];
868
 
869
+ //Add Conversion Savings
870
+ $smush_data['bytes'] += $smush_data['conversion_savings'];
871
+ $smush_data['size_before'] += $conversion_savings['size_before'];
872
+ $smush_data['size_after'] += $conversion_savings['size_after'];
873
 
874
+ //Add the size before and after
875
  $smush_data['resize_savings'] = $this->format_bytes( $smush_data['resize_savings'] );
876
 
877
+ //Conversion Savings
878
+ $smush_data['conversion_savings'] = $this->format_bytes( $smush_data['conversion_savings'] );
879
+
880
  if ( $smush_data['size_before'] > 0 ) {
881
  $smush_data['percent'] = ( $smush_data['bytes'] / $smush_data['size_before'] ) * 100;
882
  }
883
 
884
  //Round off precentage
885
+ $smush_data['percent'] = round( $smush_data['percent'], 1 );
886
 
887
  $smush_data['human'] = $WpSmush->format_bytes( $smush_data['bytes'] );
888
 
892
  return $smush_data;
893
  }
894
 
895
+ /**
896
+ * Get all the attachment meta, sum up the stats and return
897
+ *
898
+ * @param bool $force_update , Whether to forcefully update the Cache
899
+ *
900
+ * @return array|bool|mixed Stats
901
+ */
902
+ function global_stats_from_ids( $force_update = false ) {
903
+
904
+ if ( ! $force_update && $stats = wp_cache_get( 'smush_global_stats' ) ) {
905
+ if ( ! empty( $stats ) ) {
906
+ return $stats;
907
+ }
908
+ }
909
+
910
+ global $WpSmush, $wpsmush_stats;
911
+ if ( empty( $this->smushed_attachments ) ) {
912
+ $this->smushed_attachments = $wpsmush_stats->smushed_count( true );
913
+ }
914
+
915
+ $smush_data = array(
916
+ 'size_before' => 0,
917
+ 'size_after' => 0,
918
+ 'percent' => 0,
919
+ 'human' => 0
920
+ );
921
+ $smush_data['count'] = 0;
922
+ $smush_data['total_images'] = 0;
923
+
924
+ if( !empty( $this->smushed_attachments ) && is_array( $this->smushed_attachments ) ) {
925
+ //Iterate over all the attachments
926
+ foreach ( $this->smushed_attachments as $attachment ) {
927
+ //Get all the Savings for each image
928
+ $smush_stats = get_post_meta( $attachment, 'wp-smpro-smush-data', true );
929
+ $resize_savings = get_post_meta( $attachment, WP_SMUSH_PREFIX . 'resize_savings', true );
930
+ $conversion_savings = get_post_meta( $attachment, WP_SMUSH_PREFIX . 'pngjpg_savings', true );
931
+
932
+ $smush_data['count'] += 1;
933
+ $smush_data['total_images'] += ! empty( $smush_stats['sizes'] ) ? count( $smush_stats['sizes'] ) : 0;
934
+
935
+ //Sum up all the stats
936
+ if ( ! empty( $smush_stats['sizes'] ) ) {
937
+ foreach ( $smush_stats['sizes'] as $size_k => $size_savings ) {
938
+ //size_before from optimisation stats
939
+ $size_before = $size_savings->size_before;
940
+ $size_after = $size_savings->size_after;
941
+ if ( 'full' == $size_k ) {
942
+ //Check for savings from resizing for the original image
943
+ if ( ! empty( $resize_savings['size_before'] ) && $resize_savings['size_before'] > $size_before ) {
944
+ $size_before = $resize_savings['size_before'];
945
+ }
946
+ //Check for savings from resizing for the original image
947
+ if ( ! empty( $resize_savings['size_after'] ) && $resize_savings['size_after'] < $size_after ) {
948
+ $size_after = $resize_savings['size_after'];
949
+ }
950
+ }
951
+
952
+ //Add up conversion savings
953
+ if ( ! empty( $conversion_savings[ $size_k ] ) ) {
954
+ if ( ! empty( $conversion_savings[ $size_k ]['size_before'] ) && $conversion_savings[ $size_k ]['size_before'] > $size_before ) {
955
+ $size_before = $conversion_savings[ $size_k ]['size_before'];
956
+ }
957
+ if ( ! empty( $conversion_savings[ $size_k ]['size_after'] ) && $conversion_savings[ $size_k ]['size_after'] < $size_after ) {
958
+ $size_after = $conversion_savings[ $size_k ]['size_after'];
959
+ }
960
+ }
961
+ $smush_data['size_before'] += $size_before;
962
+ $smush_data['size_after'] += $size_after;
963
+ }
964
+
965
+ //Resize Savings: If full image wasn't optimised, but resized, combine the stats
966
+ if ( empty( $smush_stats['sizes']['full'] ) && ! empty( $resize_savings ) && $resize_savings['bytes'] > 0 ) {
967
+ $smush_data['size_before'] += $resize_savings['size_before'];
968
+ $smush_data['size_after'] += $resize_savings['size_after'];
969
+ }
970
+
971
+ //Conversion Savings: If full image wasn't optimised, but Conversion saved few bytes
972
+ if ( empty( $smush_stats['sizes']['full'] ) && ! empty( $conversion_savings['full'] ) && $conversion_savings['full']['bytes'] > 0 ) {
973
+ $smush_data['size_before'] += $conversion_savings['full']['size_before'];
974
+ $smush_data['size_after'] += $conversion_savings['full']['size_after'];
975
+ }
976
+ }
977
+ }
978
+ $smush_data['bytes'] = $smush_data['size_before'] - $smush_data['size_after'];
979
+
980
+ //Resize Savings
981
+ $resize_savings = $wpsmush_stats->resize_savings( false );
982
+ $smush_data['resize_savings'] = ! empty( $resize_savings['bytes'] ) ? $resize_savings['bytes'] : 0;
983
+
984
+ //Conversion Savings
985
+ $conversion_savings = $wpsmush_stats->conversion_savings( false );
986
+ $smush_data['conversion_savings'] = ! empty( $conversion_savings['bytes'] ) ? $conversion_savings['bytes'] : 0;
987
+
988
+ //Add the size before and after
989
+ $smush_data['resize_savings'] = $this->format_bytes( $smush_data['resize_savings'] );
990
+
991
+ //Conversion Savings
992
+ $smush_data['conversion_savings'] = $this->format_bytes( $smush_data['conversion_savings'] );
993
+
994
+ if ( $smush_data['size_before'] > 0 ) {
995
+ $smush_data['percent'] = ( $smush_data['bytes'] / $smush_data['size_before'] ) * 100;
996
+ }
997
+
998
+ //Round off precentage
999
+ $smush_data['percent'] = round( $smush_data['percent'], 1 );
1000
+
1001
+ $smush_data['human'] = $WpSmush->format_bytes( $smush_data['bytes'] );
1002
+
1003
+ }
1004
+ //Update Cache
1005
+ wp_cache_set( 'smush_global_stats', $smush_data, '', DAY_IN_SECONDS );
1006
+
1007
+ return $smush_data;
1008
+ }
1009
+
1010
  /**
1011
  * Returns Bulk smush button id and other details, as per if bulk request is already sent or not
1012
  *
1019
  $button = array(
1020
  'cancel' => false,
1021
  );
1022
+ if ( $this->validate_install() && $resmush ) {
1023
 
1024
  $button['text'] = __( 'Bulk Smush Now', 'wp-smushit' );
1025
  $button['class'] = 'wp-smush-button wp-smush-resmush wp-smush-all';
1085
  function smush_upgrade() {
1086
 
1087
  //Return, If a pro user, or not super admin, or don't have the admin privilleges
1088
+ if ( $this->validate_install() || ! current_user_can( 'edit_others_posts' ) || ! is_super_admin() ) {
1089
  return;
1090
  }
1091
 
1133
 
1134
  while ( $query_next ) {
1135
  // get the attachment id, smush data
1136
+ $sql = "SELECT p.ID as attachment_id, p.post_mime_type as type, ms.meta_value as smush_data"
1137
+ . " FROM $wpdb->posts as p"
1138
+ . " LEFT JOIN $wpdb->postmeta as ms"
1139
+ . " ON (p.ID= ms.post_id AND ms.meta_key='wp-smpro-smush-data')"
1140
+ . " WHERE"
1141
+ . " p.post_type='attachment'"
1142
+ . " AND p.post_mime_type IN " . $allowed_images
1143
+ . " ORDER BY p . ID DESC"
1144
+ // add a limit
1145
+ . " LIMIT " . $limit;
1146
  $results = $wpdb->get_results( $sql );
1147
 
1148
  //Update the offset
1190
  }
1191
 
1192
  //From Ajax
1193
+ if ( ! empty( $_REQUEST['action'] ) && 'dismiss_update_info' == $_REQUEST['action'] ) {
1194
  $remove_notice = true;
1195
  }
1196
 
1197
  //Update Db
1198
+ if ( $remove_notice ) {
1199
  update_site_option( 'wp-smush-hide_update_info', 1 );
1200
  }
1201
 
1202
  }
1203
 
1204
  /**
1205
+ * Resmush the image
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1206
  *
1207
  * @uses smush_single()
1208
  *
1317
  if ( ! empty( $attachments ) && is_array( $attachments ) ) {
1318
  foreach ( $attachments as $attachment_k => $attachment ) {
1319
 
1320
+ $should_resmush = false;
1321
+
1322
  //For NextGen we get the metadata in the attachment data itself
1323
  if ( ! empty( $attachment['wp_smush'] ) ) {
1324
  $smush_data = $attachment['wp_smush'];
1327
  $smush_data = get_post_meta( $attachment, $this->smushed_meta_key, true );
1328
  }
1329
 
1330
+ //If the image is already smushed
1331
  if ( ! empty( $smush_data['stats'] ) ) {
1332
 
1333
  //If we need to optmise losslessly, add to resmush list
1340
  $smush_original = $WpSmush->smush_original && empty( $smush_data['sizes']['full'] );
1341
 
1342
  if ( $smush_lossy || $strip_exif || $smush_original ) {
1343
+ $should_resmush = true;
1344
+ }
1345
+
1346
+ //If Image needs to be resized
1347
+ if( !$should_resmush ) {
1348
+ /**
1349
+ * Get the resize settings, get the image dimensions, and check if it needs to be resized
1350
+ *
1351
+ */
1352
+ global $wpsmush_resize;
1353
+ $should_resmush = $wpsmush_resize->should_resize( $attachment );
1354
+ }
1355
+
1356
+ //If image can be converted
1357
+ if( !$should_resmush ) {
1358
+ global $wpsmush_pngjpg;
1359
+ $should_resmush = $wpsmush_pngjpg->can_be_converted( $attachment );
1360
+ }
1361
+
1362
+ //If the image needs to be resmushed add it to the list
1363
+ if ( $should_resmush ) {
1364
  $resmush_list[] = 'nextgen' == $type ? $attachment_k : $attachment;
1365
  continue;
1366
  }
1407
  //Set the variables
1408
  $this->resmush_ids = $resmush_list;
1409
 
1410
+ $resmush_count = count( $this->resmush_ids );
1411
 
1412
+ $smushed = ! empty( $this->resmush_ids ) ? $this->smushed_count - $resmush_count : $this->smushed_count;
1413
 
1414
  } else {
1415
  //To avoid the php warning
1436
  }
1437
 
1438
  //If there is a Ajax response return it, else return null
1439
+ $return = ! empty( $ajax_response ) ? array(
1440
  "resmush_ids" => $resmush_list,
1441
  "content" => $ajax_response
1442
  ) : '';
1443
 
1444
  //Include the count
1445
+ if ( ! empty( $count ) && $count ) {
1446
  $return['count'] = $count;
1447
  }
1448
 
1641
  * Allows to bulk restore the images, if there is any backup for them
1642
  */
1643
  function bulk_restore() {
1644
+ global $wpsmush_stats, $wpsmush_backup;
1645
+ $smushed_attachments = ! empty( $this->smushed_attachments ) ? $this->smushed_attachments : $wpsmush_stats->smushed_count( true );
1646
  foreach ( $smushed_attachments as $attachment ) {
1647
+ $wpsmush_backup->restore_image( $attachment->attachment_id, false );
1648
  }
1649
  }
1650
 
1808
  }
1809
 
1810
  //Handles the dismiss action
1811
+ $js_url = WP_SMUSH_URL . 'assets/js/notice.js';
1812
  $upgrade_url = add_query_arg(
1813
  array(
1814
  'utm_source' => 'Smush-Free',
1819
  );
1820
 
1821
  $settings_link = '<a href="' . admin_url( 'upload.php?page=wp-smush-bulk#wp-smush-settings-box' ) . '" title="' . esc_html__( "Settings", "wp-smushit" ) . '">';
1822
+ $upgrade_link = '<a href="' . esc_url( $upgrade_url ) . '" title="' . esc_html__( "WP Smush Pro", "wp-smushit" ) . '">';
1823
  ?>
1824
  <div class="notice notice-info is-dismissible wp-smush-update-info">
1825
  <p><?php printf( esc_html__( "Woohoo! Your latest Smush update %s allows you to %sauto resize%s all your images, how cool is that! %sFind out more here >>%s", 'wp-smushit' ), WP_SMUSH_VERSION, $settings_link, '</a>', $upgrade_link, '</a>' ); ?></p>
1828
  <script src="<?php echo esc_url( $js_url ) . '?v=' . WP_SMUSH_VERSION; ?>"></script><?php
1829
  }
1830
 
1831
+ /**
1832
+ * Check whether to skip a specific image size or not
1833
+ *
1834
+ * @param string $size Registered image size
1835
+ *
1836
+ * @return bool true/false Whether to skip the image size or not
1837
+ *
1838
+ */
1839
+ function skip_image_size ( $size = '' ) {
1840
+
1841
+ //No image size specified, Don't skip
1842
+ if( empty( $size ) ) {
1843
+ return false;
1844
+ }
1845
+
1846
+ $image_sizes = get_option( WP_SMUSH_PREFIX.'image_sizes' );
1847
+
1848
+ //If Images sizes aren't set, don't skip any of the image size
1849
+ if( false === $image_sizes ) {
1850
+ return false;
1851
+ }
1852
+
1853
+ //Check if the size is in the smush list
1854
+ if( is_array( $image_sizes ) && !in_array( $size, $image_sizes ) ) {
1855
+ return true;
1856
+ }
1857
+
1858
+ }
1859
+
1860
+ /**
1861
+ * Get registered image sizes with dimension
1862
+ *
1863
+ */
1864
+ function image_dimensions() {
1865
+ global $_wp_additional_image_sizes;
1866
+ $additional_sizes = get_intermediate_image_sizes();
1867
+ $sizes = array();
1868
+
1869
+ // Create the full array with sizes and crop info
1870
+ foreach( $additional_sizes as $_size ) {
1871
+ if ( in_array( $_size, array( 'thumbnail', 'medium', 'large' ) ) ) {
1872
+ $sizes[ $_size ]['width'] = get_option( $_size . '_size_w' );
1873
+ $sizes[ $_size ]['height'] = get_option( $_size . '_size_h' );
1874
+ $sizes[ $_size ]['crop'] = (bool) get_option( $_size . '_crop' );
1875
+ } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
1876
+ $sizes[ $_size ] = array(
1877
+ 'width' => $_wp_additional_image_sizes[ $_size ]['width'],
1878
+ 'height' => $_wp_additional_image_sizes[ $_size ]['height'],
1879
+ 'crop' => $_wp_additional_image_sizes[ $_size ]['crop']
1880
+ );
1881
+ }
1882
+ }
1883
+ //Medium Large
1884
+ if ( empty( $sizes['medium_large'] ) ) {
1885
+ $width = intval( get_option( 'medium_large_size_w' ) );
1886
+ $height = intval( get_option( 'medium_large_size_h' ) );
1887
+
1888
+ $sizes['medium_large'] = array(
1889
+ 'width' => $width,
1890
+ 'height' => $height
1891
+ );
1892
+ }
1893
+
1894
+ return $sizes;
1895
+
1896
+ }
1897
+
1898
  }
1899
 
1900
  global $wpsmushit_admin;
lib/class-wp-smush-backup.php ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! class_exists( 'WpSmushBackup' ) ) {
4
+
5
+ class WpSmushBackup {
6
+
7
+ /**
8
+ * Whether to backp images or not
9
+ * @var bool
10
+ */
11
+ var $backup_enabled = false;
12
+
13
+ /**
14
+ * Constructor
15
+ */
16
+ function __construct() {
17
+ //Initialize Variables and perform other operations
18
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
19
+
20
+ //Handle Restore operation
21
+ add_action( 'wp_ajax_smush_restore_image', array( $this, 'restore_image' ) );
22
+ }
23
+
24
+ function admin_init() {
25
+
26
+ $this->initialize();
27
+
28
+ }
29
+
30
+ function initialize() {
31
+ //Whether backup is enabled or not
32
+ $this->backup_enabled = get_option( WP_SMUSH_PREFIX . 'backup' );
33
+ }
34
+
35
+ function create_backup( $file_path = '', $backup_path = '' ) {
36
+ global $WpSmush, $wpsmush_pngjpg;
37
+
38
+ if ( empty( $file_path ) ) {
39
+ return '';
40
+ }
41
+
42
+ //Return file path if backup is disabled
43
+ if ( ! $this->backup_enabled || ! $WpSmush->validate_install() ) {
44
+ return $file_path;
45
+ }
46
+
47
+ //Get a backup path if empty
48
+ if ( empty( $backup_path ) ) {
49
+ $backup_path = $WpSmush->get_image_backup_path( $file_path );
50
+ }
51
+
52
+ //If we don't have any backup path yet, bail!
53
+ if ( empty( $backup_path ) ) {
54
+ return $file_path;
55
+ }
56
+
57
+ if ( ! empty( $WpSmush->attachment_id ) && $wpsmush_pngjpg->is_converted( $WpSmush->attachment_id ) ) {
58
+ //No need to create a backup, we already have one if enabled
59
+ return $file_path;
60
+ }
61
+
62
+ //Check for backup from other plugins, like nextgen, if it doesn't exists, create our own
63
+ if ( ! file_exists( $file_path . '_backup' ) || ! file_exists( $backup_path ) ) {
64
+ @copy( $file_path, $backup_path );
65
+ }
66
+
67
+ }
68
+
69
+ /**
70
+ * Restore the image and its sizes from backup
71
+ *
72
+ */
73
+ function restore_image( $attachment = '', $resp = true ) {
74
+ global $WpSmush;
75
+ //If no attachment id is provided, check $_POST variable for attachment_id
76
+ if ( empty( $attachment ) ) {
77
+ //Check Empty fields
78
+ if ( empty( $_POST['attachment_id'] ) || empty( $_POST['_nonce'] ) ) {
79
+ wp_send_json_error( array(
80
+ 'error' => 'empty_fields',
81
+ 'message' => esc_html__( "Error in processing restore action, Fields empty.", "wp-smushit" )
82
+ ) );
83
+ }
84
+ //Check Nonce
85
+ if ( ! wp_verify_nonce( $_POST['_nonce'], "wp-smush-restore-" . $_POST['attachment_id'] ) ) {
86
+ wp_send_json_error( array(
87
+ 'error' => 'empty_fields',
88
+ 'message' => esc_html__( "Image not restored, Nonce verification failed.", "wp-smushit" )
89
+ ) );
90
+ }
91
+ }
92
+
93
+ //Store the restore success/failure for all the sizes
94
+ $restored = array();
95
+
96
+ //Process Now
97
+ $image_id = empty( $attachment ) ? absint( (int) $_POST['attachment_id'] ) : $attachment;
98
+
99
+ //Restore Full size -> get other image sizes -> restore other images
100
+
101
+ //Get the Original Path
102
+ $file_path = get_attached_file( $image_id );
103
+
104
+ //Get the backup path
105
+ $backup_name = $WpSmush->get_image_backup_path( $file_path );
106
+
107
+ //Check if it's a jpg converted from png, and restore the jpg to png
108
+ $original_file = get_post_meta( $image_id, WP_SMUSH_PREFIX . 'original_file', true );
109
+ $original_file_path = $WpSmush->original_file( $original_file );
110
+
111
+ //Flag used to restore other sizes
112
+ $restore_png = false;
113
+
114
+ if ( !empty( $original_file) && file_exists( $original_file_path ) ) {
115
+ //restore PNG full size and all other image sizes
116
+ $restored[] = $this->restore_png( $image_id, 'full', $original_file, $file_path );
117
+ $restore_png = true;
118
+ } elseif ( file_exists( $backup_name ) ) {
119
+ //If file exists, corresponding to our backup path
120
+ //Restore
121
+ $restored[] = @copy( $backup_name, $file_path );
122
+
123
+ //Delete the backup
124
+ @unlink( $backup_name );
125
+ } elseif ( file_exists( $file_path . '_backup' ) ) {
126
+ //Restore from other backups
127
+ $restored[] = @copy( $file_path . '_backup', $file_path );
128
+ }
129
+
130
+ //Get other sizes and restore
131
+ //Get attachment data
132
+ $attachment_data = wp_get_attachment_metadata( $image_id );
133
+
134
+ //Get the sizes
135
+ $sizes = ! empty( $attachment_data['sizes'] ) ? $attachment_data['sizes'] : '';
136
+
137
+ //Loop on images to restore them
138
+ foreach ( $sizes as $size_k => $size ) {
139
+ //Get the file path
140
+ if ( empty( $size['file'] ) ) {
141
+ continue;
142
+ }
143
+
144
+ //Image Path and Backup path
145
+ $image_size_path = path_join( dirname( $file_path ), $size['file'] );
146
+ $image_bckup_path = $WpSmush->get_image_backup_path( $image_size_path );
147
+
148
+ //Restore
149
+ if ( $restore_png ) {
150
+ $restored[] = $this->restore_png( $image_id, $size_k, $original_file, $image_size_path );
151
+ } elseif ( file_exists( $image_bckup_path ) ) {
152
+ $restored[] = @copy( $image_bckup_path, $image_size_path );
153
+ //Delete the backup
154
+ @unlink( $image_bckup_path );
155
+ } elseif ( file_exists( $image_size_path . '_backup' ) ) {
156
+ $restored[] = @copy( $image_size_path . '_backup', $image_size_path );
157
+ }
158
+ }
159
+
160
+ //If any of the image is restored, we count it as success
161
+ if ( in_array( true, $restored ) ) {
162
+
163
+ //Remove the Meta, And send json success
164
+ delete_post_meta( $image_id, $WpSmush->smushed_meta_key );
165
+
166
+ //Remove PNG to JPG conversion savings
167
+ delete_post_meta( $image_id, WP_SMUSH_PREFIX . 'pngjpg_savings' );
168
+
169
+ //Remove Original File
170
+ delete_post_meta( $image_id, WP_SMUSH_PREFIX . 'original_file' );
171
+
172
+ //Get the Button html without wrapper
173
+ $button_html = $WpSmush->set_status( $image_id, false, false, false );
174
+
175
+ if ( $resp ) {
176
+ wp_send_json_success( array( 'button' => $button_html ) );
177
+ } else {
178
+ return true;
179
+ }
180
+ }
181
+ if ( $resp ) {
182
+ wp_send_json_error( array( 'message' => '<div class="wp-smush-error">' . __( "Unable to restore image", "wp-smushit" ) . '</div>' ) );
183
+ }
184
+
185
+ return false;
186
+ }
187
+
188
+
189
+ function restore_png( $image_id = '', $size = 'full', $original_file = '', $file_path = '' ) {
190
+
191
+ global $WpSmush, $wpsmush_pngjpg;
192
+
193
+ //If we don't have attachment id, there is nothing we can do
194
+ if ( empty ( $image_id ) ) {
195
+ return false;
196
+ }
197
+
198
+ $meta = '';
199
+
200
+ //Else get the Attachment details
201
+ /**
202
+ * For Full Size
203
+ * 1. Get the original file path
204
+ * 2. Update the attachment metadata and all other meta details
205
+ * 3. Delete the JPEG
206
+ * 4. And we're done
207
+ * 5. Add a action after updating the URLs, that'd allow the users to perform a additional search, replace action
208
+ **/
209
+ if ( empty( $original_file ) ) {
210
+ $original_file = get_post_meta( $image_id, WP_SMUSH_PREFIX . 'original_file', true );
211
+ }
212
+ $original_file_path = $WpSmush->original_file( $original_file );
213
+ if ( 'full' == $size ) {
214
+ if ( file_exists( $original_file_path ) ) {
215
+ //Update the path details in meta and attached file, replace the image
216
+ $meta = $wpsmush_pngjpg->update_image_path( $image_id, $file_path, $original_file_path, $meta, $size, 'restore' );
217
+ //@todo: Add a check in meta if file was updated or not, before unlinking jpg
218
+ if ( ! empty( $meta['file'] ) && $original_file == $meta['file'] ) {
219
+ @unlink( $file_path );
220
+ }
221
+ /**
222
+ * Perform a action after the image URL is updated in post content
223
+ */
224
+ do_action( 'wp_smush_image_url_updated', $image_id, $file_path, $original_file, $size );
225
+ }
226
+ } else {
227
+ /**
228
+ * For any other size
229
+ * 1. Figure out the image path for the respective size
230
+ * 2. Update the image path in attachment metadata
231
+ * 3. Delete the JPEG
232
+ * 4. And done!
233
+ * 5. Add a action after updating the URLs, that'd allow the users to perform a additional search, replace action
234
+ **/
235
+ //Get the file path for the specific size
236
+ $n_file = dirname( $original_file_path ) . '/' . basename( $file_path );
237
+ $n_file_path = pathinfo( $n_file, PATHINFO_FILENAME ) . '.png';
238
+ if ( file_exists( $n_file ) ) {
239
+ //Update the path details in meta and attached file, replace the image
240
+ $meta = $wpsmush_pngjpg->update_image_path( $image_id, $file_path, $n_file_path, $meta, $size, 'restore' );
241
+ if ( ! empty( $meta['sizes'] ) && ! empty( $meta['sizes'][ $size ] ) && ! empty( $meta['sizes'][ $size ]['file'] ) && $n_file_path != $meta['sizes'][ $size ]['file'] ) {
242
+ @unlink( $file_path );
243
+ }
244
+ /**
245
+ * Perform a action after the image URL is updated in post content
246
+ */
247
+ do_action( 'wp_smush_image_url_updated', $image_id, $file_path, $n_file, $size );
248
+ }
249
+ }
250
+ //Update Meta
251
+ if ( ! empty( $meta ) ) {
252
+ //Remove Smushing, while attachment data is updated for the image
253
+ remove_filter( 'wp_update_attachment_metadata', array( $WpSmush, 'smush_image' ), 15 );
254
+ wp_update_attachment_metadata( $image_id, $meta );
255
+ return true;
256
+ }
257
+ return false;
258
+
259
+ }
260
+ }
261
+
262
+ global $wpsmush_backup;
263
+ $wpsmush_backup = new WpSmushBackup();
264
+
265
+ }
lib/class-wp-smush-bulk.php CHANGED
@@ -57,7 +57,7 @@ if ( ! class_exists( 'WpSmushitBulk' ) ) {
57
  while ( $get_posts ) {
58
 
59
  //Remove the Filters added by WP Media Folder
60
- $wpsmush_stats->remove_wmf_filters();
61
 
62
  $query = new WP_Query( $args );
63
 
57
  while ( $get_posts ) {
58
 
59
  //Remove the Filters added by WP Media Folder
60
+ $wpsmush_stats->remove_filters();
61
 
62
  $query = new WP_Query( $args );
63
 
lib/class-wp-smush-nextgen.php CHANGED
@@ -173,6 +173,18 @@ if ( ! class_exists( 'WpSmushNextGen' ) ) {
173
  continue;
174
  }
175
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  // We take the original image. Get the absolute path using the storage object
177
  $attachment_file_path_size = $storage->get_image_abspath( $image, $size );
178
 
173
  continue;
174
  }
175
 
176
+ //Check if registered size is supposed to be converted or not
177
+ global $wpsmushit_admin;
178
+ if( 'full' != $size && $wpsmushit_admin->skip_image_size( $size ) ) {
179
+ return false;
180
+ }
181
+
182
+ //Check if registered size is supposed to be converted or not
183
+ global $wpsmushit_admin;
184
+ if( 'full' != $size && $wpsmushit_admin->skip_image_size( $size ) ) {
185
+ return false;
186
+ }
187
+
188
  // We take the original image. Get the absolute path using the storage object
189
  $attachment_file_path_size = $storage->get_image_abspath( $image, $size );
190
 
lib/class-wp-smush-png_jpg.php ADDED
@@ -0,0 +1,678 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package WP Smush
4
+ *
5
+ * @version 2.4
6
+ *
7
+ * @author Umesh Kumar <umesh@incsub.com>
8
+ *
9
+ * @copyright (c) 2016, Incsub (http://incsub.com)
10
+ */
11
+ if ( ! class_exists( 'WpSmushPngtoJpg' ) ) {
12
+
13
+ class WpSmushPngtoJpg {
14
+
15
+ var $is_transparent = false;
16
+
17
+ /**
18
+ * Check if Imagick is available or not
19
+ *
20
+ * @return bool True/False Whether Imagick is available or not
21
+ *
22
+ */
23
+ function supports_imagick() {
24
+ if ( ! class_exists( 'Imagick' ) ) {
25
+ return false;
26
+ }
27
+
28
+ return true;
29
+ }
30
+
31
+ /**
32
+ * Check if GD is loaded
33
+ *
34
+ * @return bool True/False Whether GD is available or not
35
+ *
36
+ */
37
+ function supports_GD() {
38
+ if ( ! function_exists( 'gd_info' ) ) {
39
+ return false;
40
+ }
41
+
42
+ return true;
43
+ }
44
+
45
+ /**
46
+ * Checks if the Given PNG file is transparent or not
47
+ *
48
+ * @param string $id Attachment id
49
+ * @param string $file
50
+ *
51
+ * @return bool|int
52
+ */
53
+ function is_transparent( $id = '', $file = '' ) {
54
+
55
+ //No attachment id/ file path, return
56
+ if ( empty( $id ) && empty( $file ) ) {
57
+ return false;
58
+ }
59
+
60
+ if ( empty( $file ) ) {
61
+ $file = get_attached_file( $id );
62
+ }
63
+
64
+ //Check if File exists
65
+ if ( empty( $file ) || ! file_exists( $file ) ) {
66
+ return false;
67
+ }
68
+
69
+ $transparent = '';
70
+
71
+ //Try to get transparency using Imagick
72
+ if ( $this->supports_imagick() ) {
73
+ try {
74
+ $im = new Imagick( $file );
75
+
76
+ return $im->getImageAlphaChannel();
77
+ } catch ( Exception $e ) {
78
+ error_log( "Imagick: Error in checking PNG transparency " . $e->getMessage() );
79
+ }
80
+ } else {
81
+ //Simple check
82
+ //Src: http://camendesign.com/code/uth1_is-png-32bit
83
+ if ( ord( file_get_contents( $file, false, null, 25, 1 ) ) & 4 ) {
84
+ return true;
85
+ }
86
+ //Src: http://www.jonefox.com/blog/2011/04/15/how-to-detect-transparency-in-png-images/
87
+ $contents = file_get_contents( $file );
88
+ if ( stripos( $contents, 'PLTE' ) !== false && stripos( $contents, 'tRNS' ) !== false ) {
89
+ return true;
90
+ }
91
+
92
+ //If both the conditions failed, that means not transparent
93
+ return false;
94
+
95
+ }
96
+
97
+ //If Imagick is installed, and the code exited due to some error
98
+ //Src: StackOverflow
99
+ if ( empty( $transparent ) && $this->supports_GD() ) {
100
+ //Check for transparency using GD
101
+ $i = imagecreatefrompng( $file );
102
+ $palette = ( imagecolortransparent( $i ) < 0 );
103
+ if ( $palette ) {
104
+ return true;
105
+ }
106
+ }
107
+
108
+ return false;
109
+
110
+ }
111
+
112
+ /**
113
+ * Check whether to convert the PNG to JPG or not
114
+ *
115
+ * @param $id Attachment ID
116
+ * @param $file File path for the attachment
117
+ *
118
+ * @return bool Whether to convert the PNG or not
119
+ *
120
+ */
121
+ function should_convert( $id, $file ) {
122
+
123
+ $should_convert = false;
124
+
125
+ //Get the Transparency conversion settings
126
+ $convert_png = get_site_option( WP_SMUSH_PREFIX . 'png_to_jpg', false );
127
+ if ( ! $convert_png ) {
128
+ return $should_convert;
129
+ }
130
+
131
+ //Whether to convert transparent images or not
132
+ $transparent_settings = get_option( WP_SMUSH_PREFIX . 'transparent_png', false );
133
+
134
+ $convert_transparent = $transparent_settings['convert'];
135
+
136
+ /** Transparency Check */
137
+ $this->is_transparent = $this->is_transparent( $id, $file );
138
+
139
+ //If we are suppose to convert transaprent images, skip is transparent check
140
+ if ( $convert_transparent ) {
141
+ $should_convert = true;
142
+ } else {
143
+ if ( ! $this->is_transparent ) {
144
+ //If image is not transparent
145
+ $should_convert = true;
146
+ }
147
+ }
148
+
149
+ return $should_convert;
150
+ }
151
+
152
+ /**
153
+ * Check if given attachment id can be converted to JPEG or not
154
+ *
155
+ * @param string $id Atachment id
156
+ *
157
+ * @return bool True/False Can be converted or not
158
+ *
159
+ */
160
+ function can_be_converted( $id = '', $size = 'full' ) {
161
+
162
+ if ( empty( $id ) ) {
163
+ return false;
164
+ }
165
+
166
+ //False if not a PNG
167
+ $mime = get_post_mime_type( $id );
168
+ if ( 'image/png' != $mime ) {
169
+ return false;
170
+ }
171
+
172
+ /** Return if Imagick and GD is not available **/
173
+ if ( ! $this->supports_imagick() && ! $this->supports_GD() ) {
174
+ return false;
175
+ }
176
+
177
+ //If already tried the conversion
178
+ if ( get_post_meta( $id, WP_SMUSH_PREFIX . 'pngjpg_savings', false ) ) {
179
+ return false;
180
+ }
181
+
182
+ //Check if registered size is supposed to be converted or not
183
+ global $wpsmushit_admin;
184
+ if ( 'full' != $size && $wpsmushit_admin->skip_image_size( $size ) ) {
185
+ return false;
186
+ }
187
+
188
+ $file = get_attached_file( $id );
189
+
190
+ /** Whether to convert to jpg or not **/
191
+ $should_convert = $this->should_convert( $id, $file );
192
+
193
+ /**
194
+ * Filter whether to convert the PNG to JPG or not
195
+ *
196
+ * @since 2.4
197
+ *
198
+ * @param bool $should_convert Current choice for image conversion
199
+ *
200
+ * @param int $id Attachment id
201
+ *
202
+ * @param string $file File path for the image
203
+ *
204
+ * @param string $size Image size being converted
205
+ *
206
+ */
207
+ $should_convert = apply_filters( 'wp_smush_convert_to_jpg', $should_convert, $id, $file, $size );
208
+
209
+ return $should_convert;
210
+
211
+ }
212
+
213
+ /**
214
+ * Update the image URL, MIME Type, Attached File, file path in Meta, URL in post content
215
+ *
216
+ * @param $id Attachment ID
217
+ * @param $o_file Original File Path that has to be replaced
218
+ * @param $n_file New File Path which replaces the old file
219
+ * @param $meta Attachment Meta
220
+ * @param $size_k Image Size
221
+ * @param $o_type Operation Type "conversion", "restore"
222
+ *
223
+ * @return mixed Attachment Meta with updated file path
224
+ *
225
+ */
226
+ function update_image_path( $id, $o_file, $n_file, $meta, $size_k, $o_type = 'conversion' ) {
227
+
228
+ //Upload Directory
229
+ $upload_dir = wp_upload_dir();
230
+
231
+ //Upload Path
232
+ $upload_path = trailingslashit( $upload_dir['basedir'] );
233
+
234
+ $dir_name = pathinfo( $o_file, PATHINFO_DIRNAME );
235
+
236
+ //Full Path to new file
237
+ $n_file_path = path_join( $dir_name, $n_file );
238
+
239
+ //Current URL for image
240
+ $o_url = wp_get_attachment_url( $id );
241
+
242
+ //Update URL for image size
243
+ if ( 'full' != $size_k ) {
244
+ $base_url = dirname( $o_url );
245
+ $o_url = $base_url . '/' . basename( $o_file );
246
+ }
247
+
248
+ //Update File path, Attached File, GUID
249
+ $meta = empty( $meta ) ? wp_get_attachment_metadata( $id ) : $meta;
250
+
251
+ $mime = mime_content_type( $n_file_path );
252
+
253
+ //Update File Path, Attached file, Mime Type for Image
254
+ if ( 'full' == $size_k ) {
255
+ if ( ! empty( $meta ) ) {
256
+ $new_file = str_replace( $upload_path, '', $n_file_path );
257
+ $meta['file'] = $new_file;
258
+ }
259
+ //Update Attached File
260
+ update_attached_file( $id, $meta['file'] );
261
+
262
+ //Update Mime type
263
+ wp_update_post( array(
264
+ 'ID' => $id,
265
+ 'post_mime_type' => $mime
266
+ )
267
+ );
268
+ } else {
269
+ $meta['sizes'][ $size_k ]['file'] = basename( $n_file );
270
+ $meta['sizes'][ $size_k ]['mime-type'] = $mime;
271
+ }
272
+
273
+ if ( 'full' == $size_k ) {
274
+ //Get the updated image URL
275
+ $n_url = wp_get_attachment_url( $id );
276
+ } else {
277
+ $n_url = dirname( $o_url ) . '/' . basename( $n_file );
278
+ }
279
+
280
+ //Update In Post Content
281
+ global $wpdb;
282
+ $query = $wpdb->prepare( "UPDATE $wpdb->posts SET post_content = REPLACE(post_content, '%s', '%s');", $o_url, $n_url );
283
+ $wpdb->query( $query );
284
+
285
+ //Delete the Original files if backup not enabled
286
+ if ( 'conversion' == $o_type && ! get_option( WP_SMUSH_PREFIX . 'backup' ) ) {
287
+ @unlink( $o_file );
288
+ }
289
+
290
+ return $meta;
291
+ }
292
+
293
+ function update_stats( $id = '', $savings = '' ) {
294
+ if ( empty( $id ) || empty( $savings ) ) {
295
+ return false;
296
+ }
297
+
298
+ }
299
+
300
+ /**
301
+ * Replace the file if there are savings, and return savings
302
+ *
303
+ * @param string $file Original File Path
304
+ * @param array $result Array structure
305
+ * @param string $n_file Updated File path
306
+ *
307
+ * @return array
308
+ */
309
+ function replace_file( $file = '', $result = array(), $n_file = '' ) {
310
+
311
+ if ( empty( $file ) || empty( $n_file ) ) {
312
+ return $result;
313
+ }
314
+
315
+ //Get the file size of original image
316
+ $o_file_size = filesize( $file );
317
+
318
+ $n_file = path_join( dirname( $file ), $n_file );
319
+
320
+ $n_file_size = filesize( $n_file );
321
+
322
+ //If there aren't any savings return
323
+ if ( $n_file_size >= $o_file_size ) {
324
+ //Delete the JPG image and return
325
+ @unlink( $n_file );
326
+
327
+ return $result;
328
+ }
329
+
330
+ //Get the savings
331
+ $savings = $o_file_size - $n_file_size;
332
+
333
+ //Store Stats
334
+ $savings = array(
335
+ 'bytes' => $savings,
336
+ 'size_before' => $o_file_size,
337
+ 'size_after' => $n_file_size
338
+ );
339
+
340
+ $result['savings'] = $savings;
341
+
342
+ return $result;
343
+ }
344
+
345
+ /**
346
+ * Perform the conversion process, using WordPress Image Editor API
347
+ *
348
+ * @param $id Attachment Id
349
+ * @param $file Attachment File path
350
+ * @param $meta Attachment meta
351
+ * @param $size Image size, default empty for full image
352
+ *
353
+ * @return array $result array(
354
+ * 'meta' => array Update Attachment metadata
355
+ * 'savings' => Reduction of Image size in bytes
356
+ * )
357
+ *
358
+ */
359
+ function convert_to_jpg( $id = '', $file = '', $meta = '', $size = 'full' ) {
360
+
361
+ $result = array(
362
+ 'meta' => $meta,
363
+ 'savings' => ''
364
+ );
365
+
366
+ //Flag: Whether the image was converted or not
367
+ if ( 'full' == $size ) {
368
+ $result['converted'] = false;
369
+ }
370
+
371
+ //If any of the values is not set
372
+ if ( empty( $id ) || empty( $file ) || empty( $meta ) ) {
373
+ return $result;
374
+ }
375
+
376
+ $editor = wp_get_image_editor( $file );
377
+
378
+ if ( is_wp_error( $editor ) ) {
379
+ //Use custom method maybe
380
+ return $result;
381
+ }
382
+
383
+ $n_file = pathinfo( $file );
384
+
385
+ if ( ! empty( $n_file['filename'] ) && $n_file['dirname'] ) {
386
+ //Get a unique File name
387
+ $n_file['filename'] = wp_unique_filename( $n_file['dirname'], $n_file['filename'] . '.jpg' );
388
+ $n_file = path_join( $n_file['dirname'], $n_file['filename'] );
389
+ } else {
390
+ return $result;
391
+ }
392
+
393
+ //Save PNG as JPG
394
+ $new_image_info = $editor->save( $n_file, 'image/jpeg' );
395
+
396
+ //If image editor was unable to save the image, return
397
+ if ( is_wp_error( $new_image_info ) ) {
398
+ return $result;
399
+ }
400
+
401
+ $n_file = ! empty( $new_image_info ) ? $new_image_info['file'] : '';
402
+
403
+ //Replace file, and get savings
404
+ $result = $this->replace_file( $file, $result, $n_file );
405
+
406
+ if ( ! empty( $result['savings'] ) ) {
407
+ if ( 'full' == $size ) {
408
+ $result['converted'] = true;
409
+ }
410
+ //Update the File Details. and get updated meta
411
+ $result['meta'] = $this->update_image_path( $id, $file, $n_file, $meta, $size );
412
+
413
+ /**
414
+ * Perform a action after the image URL is updated in post content
415
+ */
416
+ do_action( 'wp_smush_image_url_changed', $id, $file, $n_file, $size );
417
+ }
418
+
419
+ return $result;
420
+ }
421
+
422
+ /**
423
+ * Convert a PNG to JPG Lossless conversion, if we have any savings
424
+ *
425
+ * @param $id
426
+ *
427
+ * @param $meta
428
+ */
429
+ function png_to_jpg( $id = '', $meta = '' ) {
430
+
431
+ //If we don't have meta or ID
432
+ if ( empty( $id ) || empty( $meta ) ) {
433
+ return $meta;
434
+ }
435
+
436
+ /** Whether to convert to jpg or not **/
437
+ $should_convert = $this->can_be_converted( $id );
438
+
439
+ if ( ! $should_convert ) {
440
+ return $meta;
441
+ }
442
+
443
+ $file = get_attached_file( $id );
444
+
445
+ $result['meta'] = $meta;
446
+
447
+ if ( ! $this->is_transparent ) {
448
+ //Perform the conversion, and update path
449
+ $result = $this->convert_to_jpg( $id, $file, $result['meta'] );
450
+ } else {
451
+ $result = $this->convert_tpng_to_jpg( $id, $file, $result['meta'] );
452
+ }
453
+
454
+ $savings['full'] = ! empty( $result['savings'] ) ? $result['savings'] : '';
455
+
456
+ //If original image was converted and other sizes are there for the image, Convert all other image sizes
457
+ if ( $result['converted'] ) {
458
+ if ( ! empty( $meta['sizes'] ) ) {
459
+ foreach ( $meta['sizes'] as $size_k => $data ) {
460
+
461
+ /** Whether to convert to jpg or not **/
462
+ $should_convert = $this->can_be_converted( $id, $size_k );
463
+
464
+ //Perform the conversion
465
+ if ( ! $should_convert = apply_filters( 'wp_smush_convert_to_jpg', $should_convert, $id, $file, $size_k ) ) {
466
+ continue;
467
+ }
468
+ $s_file = path_join( dirname( $file ), $data['file'] );
469
+
470
+ //Perform the conversion, and update path
471
+ if ( ! $this->is_transparent ) {
472
+ //Perform the conversion, and update path
473
+ $result = $this->convert_to_jpg( $id, $s_file, $result['meta'], $size_k );
474
+ } else {
475
+ $result = $this->convert_tpng_to_jpg( $id, $s_file, $result['meta'], $size_k );
476
+ }
477
+
478
+ //If there are savings
479
+ if ( ! empty( $result['savings'] ) ) {
480
+ //Add all the stats
481
+ array_walk_recursive( $result['savings'], function ( $item, $key ) use ( &$savings, $size_k ) {
482
+ $savings[ $size_k ][ $key ] = isset( $savings[ $size_k ][ $key ] ) ? $item + $savings[ $size_k ][ $key ] : $item;
483
+ } );
484
+ }
485
+ }
486
+ }
487
+
488
+ //Save the original File URL
489
+ $o_file = ! empty( $meta['file'] ) ? $meta['file'] : get_post_meta( $id, '_wp_attached_file', true );
490
+ update_post_meta( $id, WP_SMUSH_PREFIX . 'original_file', $o_file );
491
+
492
+ /**
493
+ * Do action, if the PNG to JPG conversion was successful
494
+ */
495
+ do_action( 'wp_smush_png_jpg_converted', $id, $meta, $savings );
496
+ }
497
+
498
+ //Update the Final Stats
499
+ update_post_meta( $id, WP_SMUSH_PREFIX . 'pngjpg_savings', $savings );
500
+
501
+ return $result['meta'];
502
+
503
+ }
504
+
505
+ /**
506
+ * Convert a transparent PNG to JPG, with specified background color
507
+ *
508
+ * @param string $id Attachment ID
509
+ * @param string $file File Path Original Image
510
+ * @param string $meta Attachment Meta
511
+ * @param string $size Image size. set to 'full' by default
512
+ *
513
+ * @return array Savings and Updated Meta
514
+ */
515
+ function convert_tpng_to_jpg( $id = '', $file = '', $meta = '', $size = 'full' ) {
516
+ $result = array(
517
+ 'meta' => $meta,
518
+ 'savings' => ''
519
+ );
520
+
521
+ //Flag: Whether the image was converted or not
522
+ if ( 'full' == $size ) {
523
+ $result['converted'] = false;
524
+ }
525
+
526
+ //If any of the values is not set
527
+ if ( empty( $id ) || empty( $file ) || empty( $meta ) ) {
528
+ return $result;
529
+ }
530
+
531
+ //Get the File name without ext
532
+ $n_file = pathinfo( $file );
533
+
534
+ if ( empty( $n_file['dirname'] ) || empty( $n_file['filename'] ) ) {
535
+ return $result;
536
+ }
537
+
538
+ $n_file['filename'] = wp_unique_filename( $n_file['dirname'], $n_file['filename'] . '.jpg' );
539
+
540
+ //Updated File name
541
+ $n_file = path_join( $n_file['dirname'], $n_file['filename'] );
542
+
543
+ $transparent_png = get_option( WP_SMUSH_PREFIX . 'transparent_png' );
544
+
545
+ /**
546
+ * Filter Background Color for Transparent PNGs
547
+ */
548
+ $bg = apply_filters( 'wp_smush_bg', $transparent_png['background'], $id, $size );
549
+
550
+ $quality = $this->get_quality( $file );
551
+
552
+ if ( $this->supports_imagick() ) {
553
+ try {
554
+ $imagick = new Imagick( $file );
555
+ $imagick->setImageBackgroundColor( new ImagickPixel( '#' . $bg ) );
556
+ $imagick->setImageAlphaChannel( 11 );
557
+ $imagick->setImageFormat( 'JPG' );
558
+ $imagick->setCompressionQuality( $quality );
559
+ $imagick->writeImage( $n_file );
560
+ } catch ( Exception $e ) {
561
+ error_log( "WP Smush PNG to JPG Conversion error in " . __FILE__ . " at " . __LINE__ . " " . $e->getMessage() );
562
+
563
+ return $result;
564
+ }
565
+ } else {
566
+ //Use GD for conversion
567
+ //Get data from PNG
568
+ $input = imagecreatefrompng( $file );
569
+
570
+ //Width and Height of image
571
+ list( $width, $height ) = getimagesize( $file );
572
+
573
+ //Create New image
574
+ $output = imagecreatetruecolor( $width, $height );
575
+
576
+ // set background color for GD
577
+ $r = hexdec( '0x' . strtoupper( substr( $bg, 0, 2 ) ) );
578
+ $g = hexdec( '0x' . strtoupper( substr( $bg, 2, 2 ) ) );
579
+ $b = hexdec( '0x' . strtoupper( substr( $bg, 4, 2 ) ) );
580
+
581
+ //Set the Background color
582
+ $rgb = imagecolorallocate( $output, $r, $g, $b );
583
+
584
+ //Fill Background
585
+ imagefilledrectangle( $output, 0, 0, $width, $height, $rgb );
586
+
587
+ //Create New image
588
+ imagecopy( $output, $input, 0, 0, 0, 0, $width, $height );
589
+
590
+ //Create JPG
591
+ imagejpeg( $output, $n_file, $quality );
592
+ }
593
+
594
+ //Replace file, and get savings
595
+ $result = $this->replace_file( $file, $result, $n_file );
596
+
597
+ if ( ! empty( $result['savings'] ) ) {
598
+ if ( 'full' == $size ) {
599
+ $result['converted'] = true;
600
+ }
601
+ //Update the File Details. and get updated meta
602
+ $result['meta'] = $this->update_image_path( $id, $file, $n_file, $meta, $size );
603
+
604
+ /**
605
+ * Perform a action after the image URL is updated in post content
606
+ */
607
+ do_action( 'wp_smush_image_url_changed', $id, $file, $n_file, $size );
608
+ }
609
+
610
+ return $result;
611
+ }
612
+
613
+ /**
614
+ * Get JPG quality from WordPress Image Editor
615
+ *
616
+ * @param $file
617
+ *
618
+ * @return int Quality for JPEG images
619
+ *
620
+ */
621
+ function get_quality( $file ) {
622
+ if ( empty( $file ) ) {
623
+ return 82;
624
+ }
625
+ $editor = wp_get_image_editor( $file );
626
+
627
+ if ( ! is_wp_error( $editor ) ) {
628
+
629
+ $quality = $editor->get_quality();
630
+ }
631
+
632
+ //Choose the default quaity if we didn't get it
633
+ if ( ! $quality || $quality < 1 || $quality > 100 ) {
634
+ //The default quality
635
+ $quality = 82;
636
+ }
637
+
638
+ return $quality;
639
+
640
+ }
641
+
642
+ /**
643
+ * Check whether the given attachment was converted from PNG to JPG
644
+ *
645
+ * @param string $id
646
+ *
647
+ * @return bool True/False Whether the image was converted from PNG or not
648
+ *
649
+ */
650
+ function is_converted( $id = '' ) {
651
+ if ( empty( $id ) ) {
652
+ return false;
653
+ }
654
+ //Get the original file path and check if it exists
655
+ $original_file = get_post_meta( $id, WP_SMUSH_PREFIX . 'original_file', true );
656
+
657
+ //If original file path is not stored, then it wasn't converted or was restored to original
658
+ if ( empty( $original_file ) ) {
659
+ return false;
660
+ }
661
+ //Upload Directory
662
+ $upload_dir = wp_upload_dir();
663
+
664
+ //Upload Path
665
+ $upload_path = trailingslashit( $upload_dir['basedir'] );
666
+
667
+ //If file exists return true
668
+ if ( file_exists( path_join( $upload_path, $original_file ) ) ) {
669
+ return true;
670
+ }
671
+
672
+ return false;
673
+ }
674
+ }
675
+
676
+ global $wpsmush_pngjpg;
677
+ $wpsmush_pngjpg = new WpSmushPngtoJpg();
678
+ }
lib/class-wp-smush-resize.php CHANGED
@@ -62,7 +62,7 @@ if ( ! class_exists( 'WpSmushResize' ) ) {
62
  *
63
  * @return bool
64
  */
65
- private function should_resize( $id = '' ) {
66
 
67
  //If resizing not enabled, or if both max width and height is set to 0, return
68
  if ( ! $this->resize_enabled || ( $this->max_w == 0 && $this->max_h == 0 ) ) {
@@ -104,7 +104,24 @@ if ( ! class_exists( 'WpSmushResize' ) ) {
104
  return false;
105
  }
106
 
107
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  }
109
 
110
  /**
62
  *
63
  * @return bool
64
  */
65
+ public function should_resize( $id = '' ) {
66
 
67
  //If resizing not enabled, or if both max width and height is set to 0, return
68
  if ( ! $this->resize_enabled || ( $this->max_w == 0 && $this->max_h == 0 ) ) {
104
  return false;
105
  }
106
 
107
+ //Get attachment metadata
108
+ $meta = wp_get_attachment_metadata( $id );
109
+
110
+ if( !empty( $meta['width'] ) && !empty( $meta['height'] ) ) {
111
+ $oldW = $meta['width'];
112
+ $oldH = $meta['height'];
113
+
114
+ $resize_dim = get_option( WP_SMUSH_PREFIX . 'resize_sizes' );
115
+
116
+ $maxW = ! empty( $resize_dim['width'] ) ? $resize_dim['width'] : 0;
117
+ $maxH = ! empty( $resize_dim['height'] ) ? $resize_dim['height'] : 0;
118
+
119
+ if ( ( $oldW > $maxW && $maxW > 0 ) || ( $oldH > $maxH && $maxH > 0 ) ) {
120
+ return true;
121
+ }
122
+ }
123
+
124
+ return false;
125
  }
126
 
127
  /**
lib/class-wp-smush-share.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package WP Smush
4
+ *
5
+ * @version 2.4
6
+ *
7
+ * @author Umesh Kumar <umesh@incsub.com>
8
+ *
9
+ * @copyright (c) 2016, Incsub (http://incsub.com)
10
+ */
11
+ if ( ! class_exists( 'WpSmushShare' ) ) {
12
+
13
+ class WpSmushShare {
14
+ function __construct() {
15
+ add_filter( 'language_attributes', array( $this, 'add_opengraph_doctype' ) );
16
+ add_action( 'admin_head', array( $this, 'insert_fb_in_head' ), 5 );
17
+ // add_action( 'admin_enqueue_scripts', array( $this, 'insert_fb_js' ), 5 );
18
+ }
19
+
20
+ function share_widget() {
21
+ global $wpsmushit_admin, $wpsmush_stats;
22
+ $savings = $wpsmushit_admin->global_stats_from_ids();
23
+ $image_count = $wpsmush_stats->smushed_count();
24
+
25
+ //If there is any saving, greater than 1Mb, show stats
26
+ if ( empty( $savings ) || empty( $savings['bytes'] ) || $savings['bytes'] <= 1048576 || $image_count <= 1 || ! is_super_admin() ) {
27
+ return false;
28
+ }
29
+ $message = sprintf( esc_html__( "%s, you've smushed %d images and saved %s in total. Help your friends save bandwidth easily, and help me in my quest to Smush the internet!", "wp-smushit" ), $wpsmushit_admin->get_user_name(), $image_count, $savings['human'] );
30
+ $share_msg = sprintf( esc_html__( 'I saved %s on my site with WP Smush ( %s ) - wanna make your website smaller and faster?', "wp-smushit" ) , $savings['human'], urlencode( "https://wordpress.org/plugins/wp-smushit/" ) );
31
+ $url = urlencode( "http://wordpress.org/plugins/wp-smushit/" ); ?>
32
+ <section class="dev-box" id="wp-smush-share-widget">
33
+ <div class="box-content roboto-medium">
34
+ <p class="wp-smush-share-message"><?php echo $message; ?></p>
35
+ <div class="wp-smush-share-buttons-wrapper">
36
+ <!-- Twitter Button -->
37
+ <a href="https://twitter.com/intent/tweet?text=<?php echo esc_attr( $share_msg ); ?>"
38
+ class="button wp-smush-share-button" id="wp-smush-twitter-share">
39
+ <i class="dev-icon dev-icon-twitter"></i><?php esc_html_e( "TWEET", "wp-smushit" ); ?></a>
40
+ <!-- Facebook Button -->
41
+ <a href="http://www.facebook.com/sharer.php?s=100&p[title]=WP Smush&p[url]=http://wordpress.org/plugins/wp-smushit/"
42
+ class="button wp-smush-share-button" id="wp-smush-facebook-share">
43
+ <i class="dev-icon dev-icon-facebook"></i><?php esc_html_e( "SHARE", "wp-smushit" ); ?></a>
44
+ <a href="whatsapp://send?text='<?php echo esc_attr( $share_msg ); ?>'"
45
+ class="button wp-smush-share-button"
46
+ id="wp-smush-whatsapp-share">
47
+ <?php esc_html_e( "WhatsApp", "wp-smushit" ); ?></a>
48
+ </div>
49
+ </div>
50
+ </section><?php
51
+ }
52
+
53
+ //Lets add Open Graph Meta Info
54
+
55
+ function insert_fb_in_head() {
56
+ if ( ! function_exists( 'get_current_screen' ) ) {
57
+ return;
58
+ }
59
+ $current_screen = get_current_screen();
60
+ $current_page = $current_screen->base;
61
+ if ( 'media_page_wp-smush-bulk' != $current_page ) {
62
+ return;
63
+ }
64
+ echo '<meta property="og:url" content="https://wordpress.org/plugins/wp-smushit/"/>';
65
+ echo '<meta property="og:type" content="article"/>';
66
+ echo '<meta property="og:title" content="I saved 6.5MB on my site with WP Smush - wanna make your website smaller and faster?"/>';
67
+ echo '<meta property="og:description" content="Resize and optimize all of your images with the incredibly powerful and 100% free image smusher, brought to you by the superteam at WPMU DEV!"/>';
68
+ }
69
+
70
+ //Adding the Open Graph in the Language Attributes
71
+ function add_opengraph_doctype( $output ) {
72
+ if ( ! function_exists( 'get_current_screen' ) ) {
73
+ return;
74
+ }
75
+
76
+ $current_screen = get_current_screen();
77
+ if ( empty( $current_screen ) ) {
78
+ return;
79
+ }
80
+
81
+ $current_page = $current_screen->base;
82
+ if ( 'media_page_wp-smush-bulk' != $current_page ) {
83
+ return;
84
+ }
85
+
86
+ return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"';
87
+ }
88
+
89
+ function insert_fb_js() { ?>
90
+ <!-- Comment #2: SDK -->
91
+ <div id="fb-root"></div>
92
+ <script>(function (d, s, id) {
93
+ var js, fjs = d.getElementsByTagName(s)[0];
94
+ if (d.getElementById(id)) return;
95
+ js = d.createElement(s);
96
+ js.id = id;
97
+ js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.6";
98
+ fjs.parentNode.insertBefore(js, fjs);
99
+ }(document, 'script', 'facebook-jssdk'));</script><?php
100
+
101
+ }
102
+
103
+ }
104
+
105
+ global $wpsmush_share;
106
+ $wpsmush_share = new WpSmushShare();
107
+ }
lib/class-wp-smush-stats.php CHANGED
@@ -17,6 +17,8 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
17
  function __construct() {
18
  //Update resize savings
19
  add_action( 'wp_smush_image_resized', array( $this, 'resize_savings' ) );
 
 
20
  }
21
 
22
  /**
@@ -27,7 +29,7 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
27
  global $wpsmushit_admin;
28
 
29
  //Remove the Filters added by WP Media Folder
30
- $this->remove_wmf_filters();
31
 
32
  $count = 0;
33
 
@@ -49,7 +51,7 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
49
  *
50
  * @return array|int
51
  */
52
- function smushed_count( $return_ids ) {
53
  global $wpsmushit_admin;
54
 
55
  //Don't query again, if the variable is already set
@@ -69,7 +71,7 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
69
  );
70
 
71
  //Remove the Filters added by WP Media Folder
72
- $this->remove_wmf_filters();
73
 
74
  $results = new WP_Query( $query );
75
 
@@ -205,7 +207,7 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
205
  while ( $get_posts ) {
206
 
207
  //Remove the Filters added by WP Media Folder
208
- $this->remove_wmf_filters();
209
 
210
  $query = new WP_Query( $args );
211
 
@@ -235,7 +237,7 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
235
  /**
236
  * Remove any pre_get_posts_filters added by WP Media Folder plugin
237
  */
238
- function remove_wmf_filters() {
239
  //remove any filters added b WP media Folder plugin to get the all attachments
240
  if ( class_exists( 'Wp_Media_Folder' ) ) {
241
  global $wp_media_folder;
@@ -244,6 +246,17 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
244
  remove_filter( 'pre_get_posts', array( $wp_media_folder, 'wpmf_pre_get_posts' ), 0, 1 );
245
  }
246
  }
 
 
 
 
 
 
 
 
 
 
 
247
  }
248
 
249
  /**
@@ -270,7 +283,7 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
270
  if ( empty( $savings ) || $force_update ) {
271
  global $wpsmushit_admin;
272
  $savings = array(
273
- 'bytes' => 0,
274
  'size_before' => 0,
275
  'size_after' => 0,
276
  );
@@ -282,9 +295,9 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
282
  foreach ( $resized_images as $id ) {
283
  $meta = get_post_meta( $id, WP_SMUSH_PREFIX . 'resize_savings', true );
284
  if ( ! empty( $meta ) && ! empty( $meta['bytes'] ) ) {
285
- $savings['bytes'] += intval( $meta['bytes'] );
286
- $savings['size_before'] += intval( $meta['size_before'] );
287
- $savings['size_after'] += intval( $meta['size_after'] );
288
  }
289
  }
290
 
@@ -298,6 +311,58 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
298
  return $savings;
299
  }
300
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  /**
302
  * Get all the resized images
303
  *
@@ -327,7 +392,7 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
327
  while ( $get_posts ) {
328
 
329
  //Remove the Filters added by WP Media Folder
330
- $this->remove_wmf_filters();
331
 
332
  $query = new WP_Query( $args );
333
 
@@ -351,6 +416,59 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
351
  return $resized_images;
352
  }
353
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
  /**
355
  * Returns the ids and meta which are losslessly compressed
356
  *
17
  function __construct() {
18
  //Update resize savings
19
  add_action( 'wp_smush_image_resized', array( $this, 'resize_savings' ) );
20
+ //Update Conversion savings
21
+ add_action( 'wp_smush_png_jpg_converted', array( $this, 'conversion_savings' ) );
22
  }
23
 
24
  /**
29
  global $wpsmushit_admin;
30
 
31
  //Remove the Filters added by WP Media Folder
32
+ $this->remove_filters();
33
 
34
  $count = 0;
35
 
51
  *
52
  * @return array|int
53
  */
54
+ function smushed_count( $return_ids = false ) {
55
  global $wpsmushit_admin;
56
 
57
  //Don't query again, if the variable is already set
71
  );
72
 
73
  //Remove the Filters added by WP Media Folder
74
+ $this->remove_filters();
75
 
76
  $results = new WP_Query( $query );
77
 
207
  while ( $get_posts ) {
208
 
209
  //Remove the Filters added by WP Media Folder
210
+ $this->remove_filters();
211
 
212
  $query = new WP_Query( $args );
213
 
237
  /**
238
  * Remove any pre_get_posts_filters added by WP Media Folder plugin
239
  */
240
+ function remove_filters() {
241
  //remove any filters added b WP media Folder plugin to get the all attachments
242
  if ( class_exists( 'Wp_Media_Folder' ) ) {
243
  global $wp_media_folder;
246
  remove_filter( 'pre_get_posts', array( $wp_media_folder, 'wpmf_pre_get_posts' ), 0, 1 );
247
  }
248
  }
249
+ global $wpml_query_filter;
250
+ //If WPML is not installed, return
251
+ if ( ! is_object( $wpml_query_filter ) ) {
252
+ return;
253
+ }
254
+
255
+ //Remove language filter and let all the images be smushed at once
256
+ if ( has_filter( 'posts_join', array( $wpml_query_filter, 'posts_join_filter' ) ) ) {
257
+ remove_filter( 'posts_join', array( $wpml_query_filter, 'posts_join_filter' ), 10, 2 );
258
+ remove_filter( 'posts_where', array( $wpml_query_filter, 'posts_where_filter' ), 10, 2 );
259
+ }
260
  }
261
 
262
  /**
283
  if ( empty( $savings ) || $force_update ) {
284
  global $wpsmushit_admin;
285
  $savings = array(
286
+ 'bytes' => 0,
287
  'size_before' => 0,
288
  'size_after' => 0,
289
  );
295
  foreach ( $resized_images as $id ) {
296
  $meta = get_post_meta( $id, WP_SMUSH_PREFIX . 'resize_savings', true );
297
  if ( ! empty( $meta ) && ! empty( $meta['bytes'] ) ) {
298
+ $savings['bytes'] += $meta['bytes'];
299
+ $savings['size_before'] += $meta['size_before'];
300
+ $savings['size_after'] += $meta['size_after'];
301
  }
302
  }
303
 
311
  return $savings;
312
  }
313
 
314
+ /**
315
+ * Return/Update PNG -> JPG Conversion savings
316
+ *
317
+ * @param bool $force_update Whether to force update the conversion savings or not
318
+ * @param bool $format Optionally return formatted savings
319
+ *
320
+ * @return array Savings
321
+ */
322
+ function conversion_savings( $force_update = true, $format = false ) {
323
+ $savings = '';
324
+
325
+ if ( ! $force_update ) {
326
+ $savings = wp_cache_get( WP_SMUSH_PREFIX . 'pngjpg_savings', 'wp-smush' );
327
+ }
328
+ //If nothing in cache, Calculate it
329
+ if ( empty( $savings ) || $force_update ) {
330
+ global $wpsmushit_admin;
331
+ $savings = array(
332
+ 'bytes' => 0,
333
+ 'size_before' => 0,
334
+ 'size_after' => 0,
335
+ );
336
+
337
+ //Get the List of resized images
338
+ $png_jpg_images = $this->converted_images();
339
+
340
+ //Iterate over them
341
+ foreach ( $png_jpg_images as $id ) {
342
+ $meta = get_post_meta( $id, WP_SMUSH_PREFIX . 'pngjpg_savings', true );
343
+ if ( ! empty( $meta ) ) {
344
+ //Iterate Over
345
+ foreach ( $meta as $size_savings ) {
346
+ if ( ! is_array( $size_savings ) ) {
347
+ continue;
348
+ }
349
+ $savings['bytes'] += $size_savings['bytes'];
350
+ $savings['size_before'] += $size_savings['size_before'];
351
+ $savings['size_after'] += $size_savings['size_after'];
352
+ }
353
+ }
354
+ }
355
+
356
+ if ( $format ) {
357
+ $savings['bytes'] = $wpsmushit_admin->format_bytes( $savings['bytes'] );
358
+ }
359
+
360
+ wp_cache_set( WP_SMUSH_PREFIX . 'pngjpg_savings', $savings, 'wp-smush' );
361
+ }
362
+
363
+ return $savings;
364
+ }
365
+
366
  /**
367
  * Get all the resized images
368
  *
392
  while ( $get_posts ) {
393
 
394
  //Remove the Filters added by WP Media Folder
395
+ $this->remove_filters();
396
 
397
  $query = new WP_Query( $args );
398
 
416
  return $resized_images;
417
  }
418
 
419
+ /**
420
+ * Get all the PNGJPG Converted images
421
+ *
422
+ * @return array Array of post ids of all the converted images
423
+ *
424
+ */
425
+ function converted_images() {
426
+ global $wpsmushit_admin;
427
+ $limit = $wpsmushit_admin->query_limit();
428
+ $limit = ! empty( $wpsmushit_admin->total_count ) && $wpsmushit_admin->total_count < $limit ? $wpsmushit_admin->total_count : $limit;
429
+ $get_posts = true;
430
+ $converted_images = array();
431
+ $args = array(
432
+ 'fields' => 'ids',
433
+ 'post_type' => 'attachment',
434
+ 'post_status' => 'inherit',
435
+ 'post_mime_type' => $wpsmushit_admin->mime_types,
436
+ 'orderby' => 'ID',
437
+ 'order' => 'DESC',
438
+ 'posts_per_page' => $limit,
439
+ 'offset' => 0,
440
+ 'meta_key' => WP_SMUSH_PREFIX . 'pngjpg_savings',
441
+ 'update_post_term_cache' => false,
442
+ 'no_found_rows' => true,
443
+ );
444
+ //Loop Over to get all the attachments
445
+ while ( $get_posts ) {
446
+
447
+ //Remove the Filters added by WP Media Folder
448
+ $this->remove_filters();
449
+
450
+ $query = new WP_Query( $args );
451
+
452
+ if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
453
+ //Merge the results
454
+ $converted_images = array_merge( $converted_images, $query->posts );
455
+
456
+ //Update the offset
457
+ $args['offset'] += $limit;
458
+ } else {
459
+ //If we didn't get any posts from query, set $get_posts to false
460
+ $get_posts = false;
461
+ }
462
+
463
+ //If total Count is set, and it is alread lesser than offset, don't query
464
+ if ( ! empty( $wpsmushit_admin->total_count ) && $wpsmushit_admin->total_count < $args['offset'] ) {
465
+ $get_posts = false;
466
+ }
467
+ }
468
+
469
+ return $converted_images;
470
+ }
471
+
472
  /**
473
  * Returns the ids and meta which are losslessly compressed
474
  *
lib/class-wp-smush-ui.php CHANGED
@@ -19,13 +19,6 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
19
  */
20
  class WpSmushBulkUi {
21
 
22
- function __construct() {
23
- //Add a container for Smush Pro promo
24
- add_action( 'wp_smush_after_stats_box', array( $this, 'wp_smush_promo' ) );
25
- //Add a Container for Hummingbird Promo
26
- add_action( 'wp_smush_after_stats_box', array( $this, 'wp_smush_hummingbird_promo' ) );
27
- }
28
-
29
  /**
30
  * Prints the Header Section for a container as per the Shared UI
31
  *
@@ -41,7 +34,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
41
  return '';
42
  }
43
  echo '<section class="dev-box ' . $classes . ' wp-smush-container" id="' . $id . '">'; ?>
44
- <div class="wp-smush-container-header box-title">
45
  <h3 tabindex="0"><?php echo $heading ?></h3><?php
46
  //Sub Heading
47
  if ( ! empty( $sub_heading ) ) { ?>
@@ -68,7 +61,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
68
  //Header Of the Box
69
  $this->container_header( 'wp-smush-welcome', 'wp-smush-welcome-box', esc_html__( "WELCOME", "wp-smushit" ), '', true );
70
  //Settings Page heading
71
- $plugin_name = $WpSmush->is_pro() ? "WP Smush Pro" : "WP Smush";
72
  ?>
73
  <!-- Content -->
74
  <div class="box-content">
@@ -91,7 +84,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
91
  //Subheading content
92
  $smush_individual_msg = sprintf( esc_html__( "Smush individual images via your %sMedia Library%s", "wp-smushit" ), '<a href="' . esc_url( admin_url( 'upload.php' ) ) . '" title="' . esc_html__( 'Media Library', 'wp-smushit' ) . '">', '</a>' );
93
 
94
- $class = $WpSmush->is_pro() ? 'bulk-smush-wrapper wp-smush-pro-install' : 'bulk-smush-wrapper';
95
 
96
  //Contianer Header
97
  $this->container_header( $class, 'wp-smush-bulk-wrap-box', esc_html__( "BULK SMUSH", "wp-smushit" ), $smush_individual_msg ); ?>
@@ -107,7 +100,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
107
  */
108
  function settings_ui() {
109
  global $WpSmush;
110
- $class = $WpSmush->is_pro() ? 'smush-settings-wrapper wp-smush-pro' : 'smush-settings-wrapper';
111
  $this->container_header( $class, 'wp-smush-settings-box', esc_html__( "SETTINGS", "wp-smushit" ), '' );
112
  // display the options
113
  $this->options_ui();
@@ -124,61 +117,128 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
124
  $smushed_count = $smushed_count > 0 ? $smushed_count : 0;
125
 
126
  $button = '<span class="spinner"></span><button tooltip="' . esc_html__( "Lets you check if any images can be further optimised. Useful after changing settings.", "wp-smushit" ) . '" class="wp-smush-title button button-grey button-small wp-smush-scan">' . esc_html__( "RE-CHECK IMAGES", "wp-smushit" ) . '</button>';
127
- $this->container_header( 'smush-stats-wrapper', 'wp-smush-stats-box', esc_html__( "STATS", "wp-smushit" ), $button ); ?>
 
 
 
128
  <div class="box-content">
129
- <div class="row smush-total-reduction-percent">
130
- <span
131
- class="float-l wp-smush-stats-label"><strong><?php esc_html_e( "TOTAL % REDUCTIONS", "wp-smushit" ); ?></strong></span>
132
- <span class="float-r wp-smush-stats-wrap"><strong><span
133
- class="wp-smush-stats"><?php echo $wpsmushit_admin->stats['percent'] > 0 ? number_format_i18n( $wpsmushit_admin->stats['percent'], 2, '.', '' ) : 0; ?></span>
134
- %</strong></span>
135
- </div>
136
- <hr>
137
- <div class="row smush-total-reduction-bytes">
138
- <span
139
- class="float-l wp-smush-stats-label"><strong><?php esc_html_e( "TOTAL SIZE REDUCTIONS", "wp-smushit" ); ?></strong></span>
140
- <span
141
- class="float-r wp-smush-stats"><strong><?php echo $wpsmushit_admin->stats['human'] > 0 ? $wpsmushit_admin->stats['human'] : "0MB"; ?></strong></span>
142
- </div>
143
- <hr><?php
144
- if( !empty( $wpsmushit_admin->stats['resize_savings'] ) && $wpsmushit_admin->stats['resize_savings'] > 0 ) { ?>
145
- <div class="row smush-resize-savings">
146
- <span class="float-l wp-smush-stats-label"><strong><?php esc_html_e( "TOTAL RESIZE SAVINGS", "wp-smushit" ); ?></strong></span>
147
- <span class="float-r wp-smush-stats"><strong><?php echo $wpsmushit_admin->stats['resize_savings'] > 0 ? $wpsmushit_admin->stats['resize_savings'] : "0MB"; ?></strong></span>
148
  </div>
149
- <hr><?php
150
- } ?>
151
- <div class="row smush-attachments">
152
- <span class="float-l wp-smush-stats-label">
153
- <strong><?php esc_html_e( "ATTACHMENTS SMUSHED", "wp-smushit" ); ?></strong><?php
154
- if( !empty( $wpsmushit_admin->stats['total_images'] ) && $wpsmushit_admin->stats['total_images'] > 0 ) {?>
155
- <span class="wp-smush-total-thumbnails" tooltip="<?php printf( esc_html__(" You've smushed %d images in total", "wp-smushit"), $wpsmushit_admin->stats['total_images'] ); ?>">
156
- <i class="dashicons dashicons-editor-help"></i>
157
- </span><?php
158
- }?>
159
- </span>
160
- <span class="float-r wp-smush-stats">
161
- <strong>
162
- <span class="smushed-count"><?php echo intval( $smushed_count ) . '</span>/' . $wpsmushit_admin->total_count; ?>
163
- </strong>
164
- </span>
 
 
 
 
165
  </div><?php
166
  /**
167
  * Allows to hide the Super Smush stats as it might be heavy for some users
168
  */
169
- if ( $WpSmush->is_pro() && apply_filters( 'wp_smush_show_lossy_stats', true ) ) {
170
  $wpsmushit_admin->super_smushed = $wpsmush_stats->super_smushed_count(); ?>
171
- <hr>
172
  <div class="row super-smush-attachments">
173
  <span class="float-l wp-smush-stats-label"><strong><?php esc_html_e( "ATTACHMENTS SUPER-SMUSHED", "wp-smushit" ); ?></strong></span>
174
  <span class="float-r wp-smush-stats<?php echo $WpSmush->lossy_enabled ? '' : ' wp-smush-lossy-disabled-wrap' ?>"><?php
175
  if ( $WpSmush->lossy_enabled ) {
176
- echo '<strong><span class="smushed-count" tooltip="' . sprintf( esc_html__("%d images", "wp-smushit"), $wpsmushit_admin->stats['total_images'] ) . '">' . intval( $wpsmushit_admin->super_smushed ) . '</span>/' . $wpsmushit_admin->total_count . '</strong>';
177
  } else {
178
  printf( esc_html__( "%sENABLE%s", "wp-smushit" ), '<button class="wp-smush-lossy-enable button button-small">', '</button>' );
179
  } ?>
180
  </span>
181
  </div><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  }
183
  /**
184
  * Allows you to output any content within the stats box at the end
@@ -211,7 +271,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
211
  }
212
 
213
  //For Basic User, Show advanced settings in a separate box
214
- if ( ! $WpSmush->is_pro() ) {
215
  echo $div_end;
216
  $upgrade_url = add_query_arg(
217
  array(
@@ -221,7 +281,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
221
  ),
222
  $wpsmushit_admin->upgrade_url
223
  );
224
- $pro_only = sprintf( esc_html__( '%sPRO ONLY%s', 'wp-smushit' ), '<a href="' . esc_url( $upgrade_url ) . '" target="_blank">', '</a>' );
225
 
226
  $this->container_header( 'wp-smush-premium', 'wp-smush-pro-settings-box', esc_html__( "ADVANCED SETTINGS", "wp-smushit" ), $pro_only, false ); ?>
227
  <div class="box-content"><?php
@@ -229,20 +289,24 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
229
 
230
  //Available advanced settings
231
  $pro_settings = array(
232
- 'original',
233
  'lossy',
 
234
  'backup',
 
235
  'nextgen'
236
  );
237
 
238
- if ( $WpSmush->is_pro() ) {
239
  echo "<hr />";
240
  }
 
 
 
241
  //Iterate Over all the available settings, and print a row for each of them
242
  foreach ( $pro_settings as $setting_key ) {
243
  if ( isset( $wpsmushit_admin->settings[ $setting_key ] ) ) {
244
  $setting_m_key = WP_SMUSH_PREFIX . $setting_key;
245
- $setting_val = $WpSmush->is_pro() ? get_option( $setting_m_key, false ) : 0; ?>
246
  <div class='wp-smush-setting-row wp-smush-advanced'>
247
  <label class="inline-label" for="<?php echo $setting_m_key; ?>" tabindex="0">
248
  <span
@@ -258,13 +322,25 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
258
  value="1"
259
  name="<?php echo $setting_m_key; ?>" tabindex= "0">
260
  <label class="toggle-label" for="<?php echo $setting_m_key; ?>"></label>
261
- </span>
 
 
 
 
 
 
 
 
 
 
 
 
262
  </div>
263
  <hr><?php
264
  }
265
  }
266
  //Output Form end and Submit button for pro version
267
- if ( $WpSmush->is_pro() ) {
268
  echo $div_end;
269
  } else {
270
  echo "</div><!-- Box Content -->
@@ -308,8 +384,10 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
308
  //Dimensions
309
  $resize_sizes = get_option( WP_SMUSH_PREFIX . 'resize_sizes', array( 'width' => '', 'height' => '' ) );
310
 
311
- //Fetch Max. width and height
312
- ?>
 
 
313
 
314
  <!-- A tab index of 0 keeps the element in tab flow with other elements with an unspecified tab index which are still tabbable.) -->
315
  <div class='wp-smush-setting-row wp-smush-basic'>
@@ -326,7 +404,28 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
326
  id="<?php echo $opt_auto; ?>"
327
  name="<?php echo $opt_auto; ?>" <?php checked( $opt_auto_val, 1, true ); ?> value="1" tabindex="0">
328
  <label class="toggle-label" for="<?php echo $opt_auto; ?>"></label>
329
- </span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  </div>
331
  <hr/>
332
  <div class='wp-smush-setting-row wp-smush-basic'>
@@ -367,8 +466,8 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
367
  <input type="text" id="<?php echo $opt_resize . '_height'; ?>" class="wp-smush-resize-input" value="<?php echo isset( $resize_sizes['height'] ) && '' != $resize_sizes['height'] ? $resize_sizes['height'] : $p_height; ?>" placeholder="<?php echo $p_height; ?>" name="<?php echo $opt_resize . '_height'; ?>" tabindex="0" width=100 /> px
368
  </label>
369
  <div class="wp-smush-resize-note"><?php printf( esc_html__("Currently, your largest thumbnail size is set at %s%dpx wide x %dpx high%s. Anything above 2048px in width or height is huge and not recommended.", "wp-smushit"), '<strong>', $max_sizes['width'], $max_sizes['height'], '</strong>' ); ?></div>
370
- <div class="wp-smush-size-info wp-smush-update-width hidden"><?php esc_html_e( "Just to let you know, the width you've entered is less than your largest thumbnail and may result in pixelation.", "wp-smushit" ); ?></div>
371
- <div class="wp-smush-size-info wp-smush-update-height hidden"><?php esc_html_e( "Just to let you know, the height you’ve entered is less than your largest thumbnail and may result in pixelation.", "wp-smushit" ); ?></div>
372
  </div>
373
  </div><!-- End of Basic Settings --><?php
374
 
@@ -383,8 +482,10 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
383
 
384
  global $WpSmush, $wpsmushit_admin;
385
 
386
- //Reset Transient
387
- $wpsmushit_admin->check_bulk_limit( true );
 
 
388
 
389
  $this->smush_page_header();
390
 
@@ -396,35 +497,43 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
396
  } ?>
397
 
398
  <!-- Bulk Smush Progress Bar -->
399
- <div class="wp-smushit-container-left col-two-third float-l"><?php
400
  //Bulk Smush Container
401
  $this->bulk_smush_container();
402
-
403
- if ( ! $WpSmush->is_pro() ) {
404
- //Settings
405
- $this->settings_ui();
406
- }
407
  ?>
408
  </div>
409
 
410
  <!-- Stats -->
411
- <div class="wp-smushit-container-right col-third float-l"><?php
412
  //Stats
413
  $this->smush_stats_container();
414
- if ( ! $WpSmush->is_pro() ) {
415
  /**
416
  * Allows to Hook in Additional Containers after Stats Box for free version
417
  * Pro Version has a full width settings box, so we don't want to do it there
418
  */
419
  do_action( 'wp_smush_after_stats_box' );
420
  } ?>
421
- </div><!-- End Of Smushit Container right --><?php
422
- if ( $WpSmush->is_pro() ) { ?>
423
- <div class="row"><?php
424
- //Settings
425
- $this->settings_ui(); ?>
426
- </div><?php
427
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
428
  $this->smush_page_footer();
429
  }
430
 
@@ -452,9 +561,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
452
  <a href="<?php echo esc_url( $upgrade_url ); ?>"
453
  class="button button-cta button-green" target="_blank">FIND OUT MORE</a>
454
  </span>
455
- </div>
456
- <img src="<?php echo WP_SMUSH_URL . 'assets/images/dev-team.png'; ?>"
457
- alt="<?php esc_html_e( "TRY WP SMUSH PRO - DEV TEAM", "wp-smushit" ); ?>"><?php
458
  echo "</section>";
459
  }
460
 
@@ -496,7 +603,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
496
  //If there are no images in Media Library
497
  if ( 0 >= $wpsmushit_admin->total_count ) { ?>
498
  <span class="wp-smush-no-image tc">
499
- <img src="<?php echo WP_SMUSH_URL . 'assets/images/smush-upload-images.png'; ?>"
500
  alt="<?php esc_html_e( "No attachments found - Upload some images", "wp-smushit" ); ?>">
501
  </span>
502
  <p class="wp-smush-no-images-content tc roboto-regular"><?php printf( esc_html__( "We haven’t found any images in your %smedia library%s yet so there’s no smushing to be done! Once you upload images, reload this page and start playing!", "wp-smushit" ), '<a href="' . esc_url( admin_url( 'upload.php' ) ) . '">', '</a>' ); ?></p>
@@ -532,7 +639,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
532
  </i>
533
  <span class="wp-smush-notice-text"><?php
534
  printf( _n( "%s, you have %s%s%d%s image%s that needs smushing!", "%s, you have %s%s%d%s images%s that need smushing!", $wpsmushit_admin->remaining_count, "wp-smushit" ), $wpsmushit_admin->get_user_name(), '<strong>', '<span class="wp-smush-remaining-count">', $wpsmushit_admin->remaining_count, '</span>', '</strong>' );
535
- if( !$WpSmush->is_pro() ) {
536
  printf( '<br />' . esc_html__("You can %sUpgrade to Pro%s to bulk smush all your images with one click.", "wp-smushit") .'<br />', '<a href="' . esc_url( $upgrade_url ). '" target="_blank" title="' . esc_html__("WP Smush Pro", "wp-smushit") . '">', '</a>' );
537
  esc_html_e("Free users can smush 50 images with each click.", "wp-smushit");
538
  }?>
@@ -542,7 +649,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
542
  <hr>
543
  <button type="button" class="wp-smush-all wp-smush-button"><?php echo $button_content; ?></button><?php
544
  //Enable Super Smush
545
- if ( $WpSmush->is_pro() && ! $WpSmush->lossy_enabled ) { ?>
546
  <p class="wp-smush-enable-lossy"><?php esc_html_e( "Enable Super-smush in the Settings area to get even more savings with almost no noticeable quality loss.", "wp-smushit" ); ?></p><?php
547
  } ?>
548
  </div><?php
@@ -566,7 +673,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
566
  } ?>
567
  <div class="wp-smush-bulk-progress-bar-wrapper hidden">
568
  <p class="wp-smush-bulk-active roboto-medium"><span
569
- class="spinner is-active"></span><?php printf( esc_html__( "%sBulk smush is currently running.%s You need to keep this page open.", "wp-smushit" ), '<strong>', '</strong>' ); ?>
570
  </p>
571
  <div class="wp-smush-progress-wrap">
572
  <div class="wp-smush-progress-bar-wrap">
@@ -664,14 +771,16 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
664
  }
665
 
666
  //Page Heading for Free and Pro Version
667
- $page_heading = $WpSmush->is_pro() ? esc_html__( 'WP Smush Pro', 'wp-smushit' ) : esc_html__( 'WP Smush', 'wp-smushit' );
668
 
669
  $auto_smush_message = $WpSmush->is_auto_smush_enabled() ? sprintf( esc_html__( "Automatic smushing is %senabled%s. Newly uploaded images will be automagically compressed." ), '<span class="wp-smush-auto-enabled">', '</span>' ) : sprintf( esc_html__( "Automatic smushing is %sdisabled%s. Newly uploaded images will need to be manually smushed." ), '<span class="wp-smush-auto-disabled">', '</span>' );
670
- echo '<div class="wrap">
671
- <div class="wp-smush-page-header">
672
- <h1 class="wp-smush-page-heading">' . $page_heading . '</h1>
673
- <div class="wp-smush-auto-message roboto-regular">' . $auto_smush_message . '</div>
674
- </div>';
 
 
675
  //Check if settings were updated and shoe a notice
676
  $this->settings_updated();
677
 
@@ -734,7 +843,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
734
  */
735
  function super_smush_promo() {
736
  global $WpSmush, $wpsmushit_admin;
737
- if ( $WpSmush->is_pro() ) {
738
  return;
739
  }
740
  $upgrade_url = add_query_arg(
19
  */
20
  class WpSmushBulkUi {
21
 
 
 
 
 
 
 
 
22
  /**
23
  * Prints the Header Section for a container as per the Shared UI
24
  *
34
  return '';
35
  }
36
  echo '<section class="dev-box ' . $classes . ' wp-smush-container" id="' . $id . '">'; ?>
37
+ <div class="wp-smush-container-header box-title" xmlns="http://www.w3.org/1999/html">
38
  <h3 tabindex="0"><?php echo $heading ?></h3><?php
39
  //Sub Heading
40
  if ( ! empty( $sub_heading ) ) { ?>
61
  //Header Of the Box
62
  $this->container_header( 'wp-smush-welcome', 'wp-smush-welcome-box', esc_html__( "WELCOME", "wp-smushit" ), '', true );
63
  //Settings Page heading
64
+ $plugin_name = $WpSmush->validate_install() ? "WP Smush Pro" : "WP Smush";
65
  ?>
66
  <!-- Content -->
67
  <div class="box-content">
84
  //Subheading content
85
  $smush_individual_msg = sprintf( esc_html__( "Smush individual images via your %sMedia Library%s", "wp-smushit" ), '<a href="' . esc_url( admin_url( 'upload.php' ) ) . '" title="' . esc_html__( 'Media Library', 'wp-smushit' ) . '">', '</a>' );
86
 
87
+ $class = $WpSmush->validate_install() ? 'bulk-smush-wrapper wp-smush-pro-install' : 'bulk-smush-wrapper';
88
 
89
  //Contianer Header
90
  $this->container_header( $class, 'wp-smush-bulk-wrap-box', esc_html__( "BULK SMUSH", "wp-smushit" ), $smush_individual_msg ); ?>
100
  */
101
  function settings_ui() {
102
  global $WpSmush;
103
+ $class = $WpSmush->validate_install() ? 'smush-settings-wrapper wp-smush-pro' : 'smush-settings-wrapper';
104
  $this->container_header( $class, 'wp-smush-settings-box', esc_html__( "SETTINGS", "wp-smushit" ), '' );
105
  // display the options
106
  $this->options_ui();
117
  $smushed_count = $smushed_count > 0 ? $smushed_count : 0;
118
 
119
  $button = '<span class="spinner"></span><button tooltip="' . esc_html__( "Lets you check if any images can be further optimised. Useful after changing settings.", "wp-smushit" ) . '" class="wp-smush-title button button-grey button-small wp-smush-scan">' . esc_html__( "RE-CHECK IMAGES", "wp-smushit" ) . '</button>';
120
+ $this->container_header( 'smush-stats-wrapper', 'wp-smush-stats-box', esc_html__( "STATS", "wp-smushit" ), $button );
121
+ $dasharray = 125.663706144;
122
+ $dash_offset = $wpsmushit_admin->total_count > 0 ? $dasharray - ( $dasharray * ( $smushed_count / $wpsmushit_admin->total_count) ) : $dasharray;
123
+ $tooltip = $wpsmushit_admin->stats['total_images'] > 0 ? 'tooltip="' . sprintf( esc_html__(" You've smushed %d images in total", "wp-smushit"), $wpsmushit_admin->stats['total_images'] ) . '"' : ''; ?>
124
  <div class="box-content">
125
+ <div class="row smush-total-savings smush-total-reduction-percent">
126
+
127
+ <div class="wp-smush-current-progress" <?php echo $tooltip; ?> >
128
+ <div class="wp-smushed-progress">
129
+ <div class="wp-smush-score inside">
130
+ <div class="tooltip-box">
131
+ <div class="wp-smush-optimisation-progress">
132
+ <div class="wp-smush-progress-circle">
133
+ <svg class="wp-smush-svg" xmlns="http://www.w3.org/2000/svg" width="50" height="50">
134
+ <circle class="wp-smush-svg-circle" r="20" cx="25" cy="25" fill="transparent" stroke-dasharray="0" stroke-dashoffset="0"></circle>
135
+ <!-- Stroke Dasharray is 2 PI r -->
136
+ <circle class="wp-smush-svg-circle wp-smush-svg-circle-progress" r="20" cx="25" cy="25" fill="transparent" stroke-dasharray="<?php echo $dasharray; ?>" style="stroke-dashoffset: <?php echo $dash_offset; ?>px;"></circle>
137
+ </svg>
138
+ </div>
139
+ </div>
140
+ </div><!-- end tooltip-box -->
 
 
 
141
  </div>
142
+ </div>
143
+
144
+ <div class="wp-smush-count-total">
145
+ <div class="wp-smush-smush-stats-wrapper">
146
+ <span class="wp-smush-optimised"><?php echo $smushed_count; ?></span>/<span><?php echo $wpsmushit_admin->total_count; ?></span>
147
+ </div>
148
+ <span class="total-stats-label"><strong><?php esc_html_e( "ATTACHMENTS SMUSHED", "wp-smushit" ); ?></strong></span>
149
+ </div>
150
+ </div>
151
+ </div>
152
+ <hr />
153
+ <div class="row wp-smush-savings">
154
+ <span class="float-l wp-smush-stats-label"><strong><?php esc_html_e("TOTAL SAVINGS", "wp-smushit");?></strong></span>
155
+ <span class="float-r wp-smush-stats">
156
+ <span class="wp-smush-stats-human">
157
+ <?php echo $wpsmushit_admin->stats['human'] > 0 ? $wpsmushit_admin->stats['human'] : "0MB"; ?>
158
+ </span>
159
+ <span class="wp-smush-stats-sep">/</span>
160
+ <span class="wp-smush-stats-percent"><?php echo $wpsmushit_admin->stats['percent'] > 0 ? number_format_i18n( $wpsmushit_admin->stats['percent'], 1, '.', '' ) : 0; ?></span>%
161
+ </span>
162
  </div><?php
163
  /**
164
  * Allows to hide the Super Smush stats as it might be heavy for some users
165
  */
166
+ if ( $WpSmush->validate_install() && apply_filters( 'wp_smush_show_lossy_stats', true ) ) {
167
  $wpsmushit_admin->super_smushed = $wpsmush_stats->super_smushed_count(); ?>
168
+ <hr />
169
  <div class="row super-smush-attachments">
170
  <span class="float-l wp-smush-stats-label"><strong><?php esc_html_e( "ATTACHMENTS SUPER-SMUSHED", "wp-smushit" ); ?></strong></span>
171
  <span class="float-r wp-smush-stats<?php echo $WpSmush->lossy_enabled ? '' : ' wp-smush-lossy-disabled-wrap' ?>"><?php
172
  if ( $WpSmush->lossy_enabled ) {
173
+ echo '<span class="smushed-count">' . intval( $wpsmushit_admin->super_smushed ) . '</span>/' . $wpsmushit_admin->total_count;
174
  } else {
175
  printf( esc_html__( "%sENABLE%s", "wp-smushit" ), '<button class="wp-smush-lossy-enable button button-small">', '</button>' );
176
  } ?>
177
  </span>
178
  </div><?php
179
+ } ?>
180
+ <hr />
181
+ <div class="row smush-resize-savings">
182
+ <span class="float-l wp-smush-stats-label"><strong><?php esc_html_e( "RESIZE SAVINGS", "wp-smushit" ); ?></strong></span>
183
+ <span class="float-r wp-smush-stats"><?php
184
+ if( !empty( $wpsmushit_admin->stats['resize_savings'] ) && $wpsmushit_admin->stats['resize_savings'] > 0 ) {
185
+ echo $wpsmushit_admin->stats['resize_savings'];
186
+ }else{
187
+ if( !get_option( WP_SMUSH_PREFIX . 'resize' ) ) {
188
+ //If Not enabled, Add a enable button
189
+ printf( esc_html__( "%sENABLE%s", "wp-smushit" ), '<button class="wp-smush-resize-enable button button-small">', '</button>' );
190
+ }else{
191
+ echo "0MB";
192
+ }
193
+ } ?>
194
+ </span>
195
+ </div><?php
196
+ if( $WpSmush->validate_install() && !empty( $wpsmushit_admin->stats['conversion_savings'] ) && $wpsmushit_admin->stats['conversion_savings'] > 0 ) { ?>
197
+ <hr />
198
+ <div class="row smush-conversion-savings">
199
+ <span class="float-l wp-smush-stats-label"><strong><?php esc_html_e( "PNG TO JPEG SAVINGS", "wp-smushit" ); ?></strong></span>
200
+ <span class="float-r wp-smush-stats"><?php echo $wpsmushit_admin->stats['conversion_savings'] > 0 ? $wpsmushit_admin->stats['conversion_savings'] : "0MB"; ?></span>
201
+ </div><?php
202
+ }
203
+ //Pro Savings Expected: For free Version
204
+ if ( ! $WpSmush->validate_install() ) {
205
+ $savings = $wpsmushit_admin->stats['percent'] > 0 ? number_format_i18n( $wpsmushit_admin->stats['percent'], 1, '.', '' ) : 0;
206
+ $savings_bytes = $wpsmushit_admin->stats['human'] > 0 ? $wpsmushit_admin->stats['bytes'] : "0";
207
+ $show_pro_savings = false;
208
+ //If the smush savings percent isn't empty and the percentage is below 45, double it
209
+ if( !empty( $savings ) && $savings < 49 ) {
210
+ $savings = 2 * $savings;
211
+ $savings_bytes = 2 * $savings_bytes;
212
+ $show_pro_savings = true;
213
+ }elseif( !empty( $savings ) && $savings < 80 ){
214
+ $savings = 1.1 * $savings;
215
+ $savings_bytes = 1.1 * $savings_bytes;
216
+ $show_pro_savings = true;
217
+ }
218
+
219
+ //If we have any savings
220
+ if( $savings > 0 && $show_pro_savings ) {
221
+ $upgrade_url = add_query_arg(
222
+ array(
223
+ 'utm_source' => 'Smush-Free',
224
+ 'utm_medium' => 'Banner',
225
+ 'utm_campaign'=> 'pro-only-stats'
226
+ ),
227
+ $wpsmushit_admin->upgrade_url
228
+ );
229
+ $pro_only = sprintf( esc_html__( '%sTRY PRO FREE%s', 'wp-smushit' ), '<a href="' . esc_url( $upgrade_url ) . '" target="_blank">', '</a>' ); ?>
230
+ <hr />
231
+ <div class="row smush-avg-pro-savings" tooltip="<?php esc_html_e("BASED ON AVERAGE SAVINGS IF YOU UPGRADE TO PRO", "wp-smushit"); ?>">
232
+ <span class="float-l wp-smush-stats-label"><strong><?php esc_html_e( "PRO SAVINGS ESTIMATE", "wp-smushit" ); ?></strong><span class="wp-smush-stats-try-pro roboto-regular"><?php echo $pro_only; ?></span></span>
233
+ <span class="float-r wp-smush-stats">
234
+ <span class="wp-smush-stats-human">
235
+ <?php echo $wpsmushit_admin->format_bytes( round( $savings_bytes, 1 ) ); ?>
236
+ </span>
237
+ <span class="wp-smush-stats-sep">/</span>
238
+ <span class="wp-smush-stats-percent"><?php echo number_format_i18n( $savings, 1, '.', '' ); ?></span>%
239
+ </span>
240
+ </div><?php
241
+ }
242
  }
243
  /**
244
  * Allows you to output any content within the stats box at the end
271
  }
272
 
273
  //For Basic User, Show advanced settings in a separate box
274
+ if ( ! $WpSmush->validate_install() ) {
275
  echo $div_end;
276
  $upgrade_url = add_query_arg(
277
  array(
281
  ),
282
  $wpsmushit_admin->upgrade_url
283
  );
284
+ $pro_only = sprintf( esc_html__( '%sTRY PRO FEATURES FREE%s', 'wp-smushit' ), '<a href="' . esc_url( $upgrade_url ) . '" target="_blank">', '</a>' );
285
 
286
  $this->container_header( 'wp-smush-premium', 'wp-smush-pro-settings-box', esc_html__( "ADVANCED SETTINGS", "wp-smushit" ), $pro_only, false ); ?>
287
  <div class="box-content"><?php
289
 
290
  //Available advanced settings
291
  $pro_settings = array(
 
292
  'lossy',
293
+ 'original',
294
  'backup',
295
+ 'png_to_jpg',
296
  'nextgen'
297
  );
298
 
299
+ if ( $WpSmush->validate_install() ) {
300
  echo "<hr />";
301
  }
302
+
303
+ $transparent_png = get_option( WP_SMUSH_PREFIX . 'transparent_png', array('convert' => '', 'background' => '' ) );
304
+
305
  //Iterate Over all the available settings, and print a row for each of them
306
  foreach ( $pro_settings as $setting_key ) {
307
  if ( isset( $wpsmushit_admin->settings[ $setting_key ] ) ) {
308
  $setting_m_key = WP_SMUSH_PREFIX . $setting_key;
309
+ $setting_val = $WpSmush->validate_install() ? get_option( $setting_m_key, false ) : 0; ?>
310
  <div class='wp-smush-setting-row wp-smush-advanced'>
311
  <label class="inline-label" for="<?php echo $setting_m_key; ?>" tabindex="0">
312
  <span
322
  value="1"
323
  name="<?php echo $setting_m_key; ?>" tabindex= "0">
324
  <label class="toggle-label" for="<?php echo $setting_m_key; ?>"></label>
325
+ </span><?php
326
+ if( 'png_to_jpg' == $setting_key ) {
327
+ $bg_color = '#<input type="text" pattern=".{6,}" id="png_to_jpg_background" class="wp-smush-png_to_jpg_background" value="' . $transparent_png['background'] . '" placeholder="ffffff" name="' . $setting_m_key . '_background" tabindex="0" width="50px" maxlength="6" title="' . esc_html__("Enter 6 character Hexcode", "wp-smushit") . '" />';
328
+ ?>
329
+ <div class="wp-smush-png_to_jpg-wrap<?php echo $setting_val ? '' : ' hidden'?>">
330
+ <label for="png_to_jpg_transparent">
331
+ <input type="checkbox" id="png_to_jpg_transparent" class="wp-smush-png_to_jpg_transparent" name="<?php echo $setting_m_key; ?>_transparent" tabindex="0" <?php checked( $transparent_png['convert'] ); ?>/>
332
+ <?php printf( esc_html__("Convert transparent images and use background color %s", "wp-smushit"), $bg_color ); ?>
333
+ </label>
334
+ <div class="wp-smush-settings-info wp-smush-hex-notice hidden"><?php esc_html_e("Color hexcode should be 6 characters.", "wp-smushit"); ?></div>
335
+ </div><?php
336
+ }
337
+ ?>
338
  </div>
339
  <hr><?php
340
  }
341
  }
342
  //Output Form end and Submit button for pro version
343
+ if ( $WpSmush->validate_install() ) {
344
  echo $div_end;
345
  } else {
346
  echo "</div><!-- Box Content -->
384
  //Dimensions
385
  $resize_sizes = get_option( WP_SMUSH_PREFIX . 'resize_sizes', array( 'width' => '', 'height' => '' ) );
386
 
387
+ //Additional Image sizes
388
+ $image_sizes = get_option( WP_SMUSH_PREFIX . 'image_sizes' );
389
+ $sizes = $wpsmushit_admin->image_dimensions();
390
+ ?>
391
 
392
  <!-- A tab index of 0 keeps the element in tab flow with other elements with an unspecified tab index which are still tabbable.) -->
393
  <div class='wp-smush-setting-row wp-smush-basic'>
404
  id="<?php echo $opt_auto; ?>"
405
  name="<?php echo $opt_auto; ?>" <?php checked( $opt_auto_val, 1, true ); ?> value="1" tabindex="0">
406
  <label class="toggle-label" for="<?php echo $opt_auto; ?>"></label>
407
+ </span><?php
408
+ if( !empty( $sizes ) ) { ?>
409
+ <!-- List of image sizes recognised by WP Smush -->
410
+ <div class="wp-smush-image-size-list">
411
+ <p><?php esc_html_e("The Following image sizes will be optimised by WP Smush:", "wp-smushit"); ?></p><?php
412
+ foreach ( $sizes as $size_k => $size ) {
413
+ if( 'medium_large' == $size_k ) {
414
+ continue;
415
+ }
416
+ //If image sizes array isn't set, mark all checked ( Default Values )
417
+ if ( false === $image_sizes ) {
418
+ $checked = true;
419
+ }else{
420
+ $checked = is_array( $image_sizes ) ? in_array( $size_k, $image_sizes ) : false;
421
+ } ?>
422
+ <label>
423
+ <input type="checkbox" id="wp-smush-size-<?php echo $size_k; ?>" <?php checked( $checked, true ); ?> name="wp-smush-image_sizes[]" value="<?php echo $size_k; ?>"><?php
424
+ echo $size_k . " (" . $size['width'] . "x" . $size['height'] . ") "; ?>
425
+ </label><?php
426
+ } ?>
427
+ </div><?php
428
+ } ?>
429
  </div>
430
  <hr/>
431
  <div class='wp-smush-setting-row wp-smush-basic'>
466
  <input type="text" id="<?php echo $opt_resize . '_height'; ?>" class="wp-smush-resize-input" value="<?php echo isset( $resize_sizes['height'] ) && '' != $resize_sizes['height'] ? $resize_sizes['height'] : $p_height; ?>" placeholder="<?php echo $p_height; ?>" name="<?php echo $opt_resize . '_height'; ?>" tabindex="0" width=100 /> px
467
  </label>
468
  <div class="wp-smush-resize-note"><?php printf( esc_html__("Currently, your largest thumbnail size is set at %s%dpx wide x %dpx high%s. Anything above 2048px in width or height is huge and not recommended.", "wp-smushit"), '<strong>', $max_sizes['width'], $max_sizes['height'], '</strong>' ); ?></div>
469
+ <div class="wp-smush-settings-info wp-smush-size-info wp-smush-update-width hidden"><?php esc_html_e( "Just to let you know, the width you've entered is less than your largest thumbnail and may result in pixelation.", "wp-smushit" ); ?></div>
470
+ <div class="wp-smush-settings-info wp-smush-size-info wp-smush-update-height hidden"><?php esc_html_e( "Just to let you know, the height you’ve entered is less than your largest thumbnail and may result in pixelation.", "wp-smushit" ); ?></div>
471
  </div>
472
  </div><!-- End of Basic Settings --><?php
473
 
482
 
483
  global $WpSmush, $wpsmushit_admin;
484
 
485
+ if( !$WpSmush->validate_install() ) {
486
+ //Reset Transient
487
+ $wpsmushit_admin->check_bulk_limit( true );
488
+ }
489
 
490
  $this->smush_page_header();
491
 
497
  } ?>
498
 
499
  <!-- Bulk Smush Progress Bar -->
500
+ <div class="wp-smushit-container-left col-half float-l"><?php
501
  //Bulk Smush Container
502
  $this->bulk_smush_container();
 
 
 
 
 
503
  ?>
504
  </div>
505
 
506
  <!-- Stats -->
507
+ <div class="wp-smushit-container-right col-half float-l"><?php
508
  //Stats
509
  $this->smush_stats_container();
510
+ if ( ! $WpSmush->validate_install() ) {
511
  /**
512
  * Allows to Hook in Additional Containers after Stats Box for free version
513
  * Pro Version has a full width settings box, so we don't want to do it there
514
  */
515
  do_action( 'wp_smush_after_stats_box' );
516
  } ?>
517
+ </div><!-- End Of Smushit Container right -->
518
+
519
+ <!-- Stats Share Widget -->
520
+ <div class="row"><?php
521
+ global $wpsmush_share;
522
+ $wpsmush_share->share_widget(); ?>
523
+ </div>
524
+
525
+ <!-- Settings -->
526
+ <div class="row"><?php
527
+ $this->settings_ui();
528
+ if( !$wpsmushit_admin->validate_install() ) {?>
529
+ <div class="wp-smush-pro-for-free wp-smushit-container-left col-half float-l"><?php
530
+ $this->wp_smush_promo();?>
531
+ </div>
532
+ <div class="wp-smushit-container-left col-half float-l"><?php
533
+ $this->wp_smush_hummingbird_promo(); ?>
534
+ </div><?php
535
+ } ?>
536
+ </div><?php
537
  $this->smush_page_footer();
538
  }
539
 
561
  <a href="<?php echo esc_url( $upgrade_url ); ?>"
562
  class="button button-cta button-green" target="_blank">FIND OUT MORE</a>
563
  </span>
564
+ </div><?php
 
 
565
  echo "</section>";
566
  }
567
 
603
  //If there are no images in Media Library
604
  if ( 0 >= $wpsmushit_admin->total_count ) { ?>
605
  <span class="wp-smush-no-image tc">
606
+ <img src="<?php echo WP_SMUSH_URL . 'assets/images/smush-no-media.png'; ?>"
607
  alt="<?php esc_html_e( "No attachments found - Upload some images", "wp-smushit" ); ?>">
608
  </span>
609
  <p class="wp-smush-no-images-content tc roboto-regular"><?php printf( esc_html__( "We haven’t found any images in your %smedia library%s yet so there’s no smushing to be done! Once you upload images, reload this page and start playing!", "wp-smushit" ), '<a href="' . esc_url( admin_url( 'upload.php' ) ) . '">', '</a>' ); ?></p>
639
  </i>
640
  <span class="wp-smush-notice-text"><?php
641
  printf( _n( "%s, you have %s%s%d%s image%s that needs smushing!", "%s, you have %s%s%d%s images%s that need smushing!", $wpsmushit_admin->remaining_count, "wp-smushit" ), $wpsmushit_admin->get_user_name(), '<strong>', '<span class="wp-smush-remaining-count">', $wpsmushit_admin->remaining_count, '</span>', '</strong>' );
642
+ if( !$WpSmush->validate_install() ) {
643
  printf( '<br />' . esc_html__("You can %sUpgrade to Pro%s to bulk smush all your images with one click.", "wp-smushit") .'<br />', '<a href="' . esc_url( $upgrade_url ). '" target="_blank" title="' . esc_html__("WP Smush Pro", "wp-smushit") . '">', '</a>' );
644
  esc_html_e("Free users can smush 50 images with each click.", "wp-smushit");
645
  }?>
649
  <hr>
650
  <button type="button" class="wp-smush-all wp-smush-button"><?php echo $button_content; ?></button><?php
651
  //Enable Super Smush
652
+ if ( $WpSmush->validate_install() && ! $WpSmush->lossy_enabled ) { ?>
653
  <p class="wp-smush-enable-lossy"><?php esc_html_e( "Enable Super-smush in the Settings area to get even more savings with almost no noticeable quality loss.", "wp-smushit" ); ?></p><?php
654
  } ?>
655
  </div><?php
673
  } ?>
674
  <div class="wp-smush-bulk-progress-bar-wrapper hidden">
675
  <p class="wp-smush-bulk-active roboto-medium"><span
676
+ class="spinner is-active"></span><?php printf( esc_html__( "%sBulk smush is currently running.%s You need to keep this page open for the process to complete.", "wp-smushit" ), '<strong>', '</strong>' ); ?>
677
  </p>
678
  <div class="wp-smush-progress-wrap">
679
  <div class="wp-smush-progress-bar-wrap">
771
  }
772
 
773
  //Page Heading for Free and Pro Version
774
+ $page_heading = $WpSmush->validate_install() ? esc_html__( 'WP Smush Pro', 'wp-smushit' ) : esc_html__( 'WP Smush', 'wp-smushit' );
775
 
776
  $auto_smush_message = $WpSmush->is_auto_smush_enabled() ? sprintf( esc_html__( "Automatic smushing is %senabled%s. Newly uploaded images will be automagically compressed." ), '<span class="wp-smush-auto-enabled">', '</span>' ) : sprintf( esc_html__( "Automatic smushing is %sdisabled%s. Newly uploaded images will need to be manually smushed." ), '<span class="wp-smush-auto-disabled">', '</span>' );
777
+ echo '<div class="smush-page-wrap">
778
+ <section id="header">
779
+ <div class="wp-smush-page-header">
780
+ <h1 class="wp-smush-page-heading">' . $page_heading . '</h1>
781
+ <div class="wp-smush-auto-message roboto-regular">' . $auto_smush_message . '</div>
782
+ </div>
783
+ </section>';
784
  //Check if settings were updated and shoe a notice
785
  $this->settings_updated();
786
 
843
  */
844
  function super_smush_promo() {
845
  global $WpSmush, $wpsmushit_admin;
846
+ if ( $WpSmush->validate_install() ) {
847
  return;
848
  }
849
  $upgrade_url = add_query_arg(
lib/class-wp-smush.php CHANGED
@@ -8,6 +8,15 @@ require_once WP_SMUSH_DIR . "lib/class-wp-smush-stats.php";
8
  //Include Resize class
9
  require_once WP_SMUSH_DIR . 'lib/class-wp-smush-resize.php';
10
 
 
 
 
 
 
 
 
 
 
11
  if ( ! class_exists( 'WpSmush' ) ) {
12
 
13
  class WpSmush {
@@ -56,6 +65,16 @@ if ( ! class_exists( 'WpSmush' ) ) {
56
  */
57
  var $keep_exif = false;
58
 
 
 
 
 
 
 
 
 
 
 
59
  /**
60
  * Constructor
61
  */
@@ -88,7 +107,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
88
  //Manage column sorting
89
  add_action( 'pre_get_posts', array( $this, 'smushit_orderby' ) );
90
 
91
- //Enqueue Scripts
92
  add_action( 'admin_init', array( $this, 'admin_init' ) );
93
 
94
  //Load Translation files
@@ -112,11 +131,11 @@ if ( ! class_exists( 'WpSmush' ) ) {
112
  function initialise() {
113
  //Check if Lossy enabled
114
  $opt_lossy = WP_SMUSH_PREFIX . 'lossy';
115
- $this->lossy_enabled = $this->is_pro() && get_option( $opt_lossy, false );
116
 
117
  //Check if Smush Original enabled
118
  $opt_original = WP_SMUSH_PREFIX . 'original';
119
- $this->smush_original = $this->is_pro() && get_option( $opt_original, false );
120
 
121
  //Check Whether to keep exif or not
122
  $opt_keep_exif = WP_SMUSH_PREFIX . 'keep_exif';
@@ -166,7 +185,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
166
  $file_size = file_exists( $file_path ) ? filesize( $file_path ) : '';
167
 
168
  //Check if premium user
169
- $max_size = $this->is_pro() ? WP_SMUSH_PREMIUM_MAX_BYTES : WP_SMUSH_MAX_BYTES;
170
 
171
  //Check if file exists
172
  if ( $file_size == 0 ) {
@@ -212,15 +231,9 @@ if ( ! class_exists( 'WpSmush' ) ) {
212
  //Add the file as tmp
213
  file_put_contents( $tempfile, $response['data']->image );
214
 
215
- //handle backups if enabled
216
- $backup = get_option( WP_SMUSH_PREFIX . 'backup' );
217
- if ( $backup && $this->is_pro() ) {
218
- //Check for backup from other plugins, like nextgen, if it doesn't exists, create our own
219
- if ( ! file_exists( $file_path . '_backup' ) ) {
220
- $backup_name = $wpsmushit_admin->get_image_backup_path( $file_path );
221
- @copy( $file_path, $backup_name );
222
- }
223
- }
224
 
225
  //replace the file
226
  $success = @rename( $tempfile, $file_path );
@@ -295,7 +308,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
295
 
296
  //Flag to check, if original size image should be smushed or not
297
  $original = get_option( WP_SMUSH_PREFIX . 'original' );
298
- $smush_full = ( $this->is_pro() && $original == 1 ) ? true : false;
299
 
300
  $errors = new WP_Error();
301
  $stats = array(
@@ -314,6 +327,10 @@ if ( ! class_exists( 'WpSmush' ) ) {
314
  return $meta;
315
  }
316
 
 
 
 
 
317
  //File path and URL for original image
318
  $attachment_file_path = get_attached_file( $ID );
319
 
@@ -335,8 +352,15 @@ if ( ! class_exists( 'WpSmush' ) ) {
335
  } else {
336
  $finfo = false;
337
  }
 
 
338
  foreach ( $meta['sizes'] as $size_key => $size_data ) {
339
 
 
 
 
 
 
340
  // We take the original image. The 'sizes' will all match the same URL and
341
  // path. So just get the dirname and replace the filename.
342
  $attachment_file_path_size = path_join( dirname( $attachment_file_path ), $size_data['file'] );
@@ -527,16 +551,21 @@ if ( ! class_exists( 'WpSmush' ) ) {
527
  return $meta;
528
  }
529
 
530
- global $wpsmush_resize;
531
- $meta = $wpsmush_resize->auto_resize( $ID, $meta );
532
 
533
  //Check if auto is enabled
534
  $auto_smush = $this->is_auto_smush_enabled();
535
 
 
 
 
536
  //Auto Smush the new image
537
  if ( $auto_smush ) {
538
- //Update API url for Hostgator
539
 
 
 
 
 
540
  //Check for use of http url, (Hostgator mostly)
541
  $use_http = wp_cache_get( WP_SMUSH_PREFIX . 'use_http', 'smush' );
542
  if ( ! $use_http ) {
@@ -584,7 +613,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
584
  $headers['apikey'] = $api_key;
585
  }
586
 
587
- if ( $this->lossy_enabled && $this->is_pro() ) {
588
  $headers['lossy'] = 'true';
589
  } else {
590
  $headers['lossy'] = 'false';
@@ -677,14 +706,14 @@ if ( ! class_exists( 'WpSmush' ) ) {
677
  * Return the filesize in a humanly readable format.
678
  * Taken from http://www.php.net/manual/en/function.filesize.php#91477
679
  */
680
- function format_bytes( $bytes, $precision = 2 ) {
681
  $units = array( 'B', 'KB', 'MB', 'GB', 'TB' );
682
  $bytes = max( $bytes, 0 );
683
  $pow = floor( ( $bytes ? log( $bytes ) : 0 ) / log( 1024 ) );
684
  $pow = min( $pow, count( $units ) - 1 );
685
  $bytes /= pow( 1024, $pow );
686
 
687
- return round( $bytes, $precision ) . ' ' . $units[ $pow ];
688
  }
689
 
690
  /**
@@ -702,7 +731,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
702
  *
703
  * @return mixed|string
704
  */
705
- function is_pro() {
706
 
707
  if ( isset( $this->is_pro ) ) {
708
  return $this->is_pro;
@@ -856,9 +885,12 @@ if ( ! class_exists( 'WpSmush' ) ) {
856
 
857
  $wp_smush_data = get_post_meta( $id, $this->smushed_meta_key, true );
858
  $wp_resize_savings = get_post_meta( $id, WP_SMUSH_PREFIX . 'resize_savings', true );
 
859
 
860
  $combined_stats = $this->combined_stats( $wp_smush_data, $wp_resize_savings );
861
 
 
 
862
  $attachment_data = wp_get_attachment_metadata( $id );
863
 
864
  // if the image is smushed
@@ -878,16 +910,27 @@ if ( ! class_exists( 'WpSmush' ) ) {
878
  $status_txt = __( 'Already Optimized', 'wp-smushit' );
879
 
880
  //Show resmush link, if the settings were changed
881
- $show_resmush = $this->show_resmush( $show_resmush, $wp_smush_data );
882
  if ( $show_resmush ) {
883
  $status_txt .= '<br />' . $this->get_resmsuh_link( $id );
884
  }
885
 
886
  } elseif ( ! empty( $percent ) && ! empty( $bytes_readable ) ) {
887
- $status_txt = $image_count > 1 ? sprintf( __( "%d images reduced ", 'wp-smushit' ), $image_count ) : __( "Reduced ", 'wp-smushit' );
888
- $status_txt .= sprintf( __( "by %s ( %01.1f%% )", 'wp-smushit' ), $bytes_readable, number_format_i18n( $percent, 2, '.', '' ) );
 
 
 
 
 
 
 
 
 
 
 
889
 
890
- $show_resmush = $this->show_resmush( $show_resmush, $wp_smush_data );
891
 
892
  if ( $show_resmush ) {
893
  $status_txt .= '<br />' . $this->get_resmsuh_link( $id );
@@ -942,7 +985,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
942
 
943
  //Check if premium user, compression was lossless, and lossy compression is enabled
944
  //If we are displaying the resmush option already, no need to show the Super Smush button
945
- if ( ! $show_resmush && $this->is_pro() && ! $is_lossy && $this->lossy_enabled && $image_type != 'image/gif' ) {
946
  // the button text
947
  $button_txt = __( 'Super-Smush', 'wp-smushit' );
948
  $show_button = true;
@@ -1145,6 +1188,10 @@ if ( ! class_exists( 'WpSmush' ) ) {
1145
  */
1146
  function smush_retina_image( $id, $retina_file, $image_size ) {
1147
 
 
 
 
 
1148
  /**
1149
  * Allows to Enable/Disable WP Retina 2x Integration
1150
  */
@@ -1201,7 +1248,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
1201
  //If full image was not smushed, reason 1. Large Size logic, 2. Free and greater than 1Mb
1202
  if ( ! array_key_exists( 'full', $size_stats ) ) {
1203
  //For free version, Check the image size
1204
- if ( ! $this->is_pro() ) {
1205
  //For free version, check if full size is greater than 1 Mb, show the skipped status
1206
  $file_size = file_exists( $full_image ) ? filesize( $full_image ) : '';
1207
  if ( ! empty( $file_size ) && ( $file_size / WP_SMUSH_MAX_BYTES ) > 1 ) {
@@ -1276,6 +1323,8 @@ if ( ! class_exists( 'WpSmush' ) ) {
1276
  */
1277
  function get_detailed_stats( $image_id, $wp_smush_data, $attachment_metadata ) {
1278
 
 
 
1279
  $stats = '<div id="smush-stats-' . $image_id . '" class="smush-stats-wrapper hidden">
1280
  <table class="wp-smush-stats-holder">
1281
  <thead>
@@ -1307,10 +1356,18 @@ if ( ! class_exists( 'WpSmush' ) ) {
1307
  }
1308
  //Show Sizes and their compression
1309
  foreach ( $size_stats as $size_key => $size_value ) {
 
 
 
 
 
 
1310
  if ( $size_value->bytes > 0 ) {
 
 
1311
  $stats .= '<tr>
1312
- <td>' . strtoupper( $size_key ) . '</td>
1313
- <td>' . $this->format_bytes( $size_value->bytes ) . ' ( ' . $size_value->percent . '% )</td>
1314
  </tr>';
1315
  }
1316
  }
@@ -1338,7 +1395,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
1338
  * Include and instantiate classes
1339
  */
1340
  function load_nextgen() {
1341
- if ( ! class_exists( 'C_NextGEN_Bootstrap' ) || ! $this->is_pro() ) {
1342
  return;
1343
  }
1344
  //Check if integration is Enabled or not
@@ -1434,6 +1491,18 @@ if ( ! class_exists( 'WpSmush' ) ) {
1434
  return true;
1435
  }
1436
 
 
 
 
 
 
 
 
 
 
 
 
 
1437
  //Check for backup of image sizes
1438
  foreach ( $attachment_data['sizes'] as $image_size ) {
1439
  $size_path = path_join( dirname( $file ), $image_size['file'] );
@@ -1543,6 +1612,9 @@ if ( ! class_exists( 'WpSmush' ) ) {
1543
  //Update the savings cache
1544
  $wpsmush_stats->resize_savings( true );
1545
 
 
 
 
1546
  //If no image id provided
1547
  if ( empty( $image_id ) ) {
1548
  return false;
@@ -1568,7 +1640,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
1568
  function send_smush_stats() {
1569
  global $wpsmushit_admin;
1570
 
1571
- $stats = $wpsmushit_admin->global_stats();
1572
 
1573
  return $stats;
1574
 
@@ -1587,6 +1659,11 @@ if ( ! class_exists( 'WpSmush' ) ) {
1587
  if ( empty( $attachment_id ) || ! class_exists( 'Upfront' ) ) {
1588
  return $stats;
1589
  }
 
 
 
 
 
1590
  //Get post meta to check for Upfront images
1591
  $upfront_images = get_post_meta( $attachment_id, 'upfront_used_image_sizes', true );
1592
 
@@ -1633,22 +1710,33 @@ if ( ! class_exists( 'WpSmush' ) ) {
1633
  *
1634
  * @return bool
1635
  */
1636
- function show_resmush( $show_resmush, $wp_smush_data ) {
1637
  //Resmush: Show resmush link, Check if user have enabled smushing the original and full image was skipped
1638
  //Or: If keep exif is unchecked and the smushed image have exif
 
1639
  if ( $this->smush_original ) {
1640
  //IF full image was not smushed
1641
  if ( ! empty( $wp_smush_data ) && empty( $wp_smush_data['sizes']['full'] ) ) {
1642
- $show_resmush = true;
1643
  }
1644
  }
1645
- if ( !$this->keep_exif ) {
1646
- //If Keep Exif was set to tru initially, and since it is set to false now
 
 
1647
  if ( isset( $wp_smush_data['stats']['keep_exif'] ) && $wp_smush_data['stats']['keep_exif'] == 1 ) {
1648
- $show_resmush = true;
1649
  }
1650
  }
1651
- return $show_resmush;
 
 
 
 
 
 
 
 
1652
  }
1653
 
1654
  /**
@@ -1802,26 +1890,58 @@ if ( ! class_exists( 'WpSmush' ) ) {
1802
  return $smush_stats;
1803
  }
1804
 
1805
- $smush_stats['stats']['bytes'] = ! empty( $resize_savings['bytes'] ) ? $smush_stats['stats']['bytes'] + $resize_savings['bytes'] : $smush_stats['stats']['bytes'];
1806
- $smush_stats['stats']['size_before'] = ! empty( $resize_savings['size_before'] ) ? $smush_stats['stats']['size_before'] + $resize_savings['size_before'] : $smush_stats['stats']['size_before'];
1807
- $smush_stats['stats']['size_after'] = ! empty( $resize_savings['size_after'] ) ? $smush_stats['stats']['size_after'] + $resize_savings['size_after'] : $smush_stats['stats']['size_after'];
1808
- $smush_stats['stats']['percent'] = ! empty( $smush_stats['stats']['bytes'] ) ? ( $smush_stats['stats']['bytes'] / $smush_stats['stats']['size_before'] ) * 100 : $smush_stats['stats']['percent'];
1809
-
1810
- //Round off
1811
- $smush_stats['stats']['percent'] = round( $smush_stats['stats']['percent'], 2 );
1812
-
1813
  //Full Image
1814
  if( !empty( $smush_stats['sizes']['full'] ) ) {
1815
  $smush_stats['sizes']['full']->bytes = ! empty( $resize_savings['bytes'] ) ? $smush_stats['sizes']['full']->bytes + $resize_savings['bytes'] : $smush_stats['sizes']['full']->bytes;
1816
- $smush_stats['sizes']['full']->size_before = ! empty( $resize_savings['size_before'] ) ? $smush_stats['sizes']['full']->size_before + $resize_savings['size_before'] : $smush_stats['sizes']['full']->size_before;
1817
- $smush_stats['sizes']['full']->size_after = ! empty( $resize_savings['size_after'] ) ? $smush_stats['sizes']['full']->size_after + $resize_savings['size_after'] : $smush_stats['sizes']['full']->size_after;
1818
  $smush_stats['sizes']['full']->percent = ! empty( $smush_stats['sizes']['full']->bytes ) && $smush_stats['sizes']['full']->size_before > 0 ? ( $smush_stats['sizes']['full']->bytes / $smush_stats['sizes']['full']->size_before ) * 100 : $smush_stats['sizes']['full']->percent;
1819
 
1820
- $smush_stats['sizes']['full']->percent = round( $smush_stats['sizes']['full']->percent, 2 );
1821
  }
1822
 
 
 
1823
  return $smush_stats;
1824
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1825
  }
1826
 
1827
  global $WpSmush;
8
  //Include Resize class
9
  require_once WP_SMUSH_DIR . 'lib/class-wp-smush-resize.php';
10
 
11
+ //Include PNG to JPG Converter
12
+ require_once WP_SMUSH_DIR . 'lib/class-wp-smush-png_jpg.php';
13
+
14
+ //Include Social Sharing
15
+ require_once WP_SMUSH_DIR . 'lib/class-wp-smush-share.php';
16
+
17
+ //Include Image backup class
18
+ require_once WP_SMUSH_DIR . 'lib/class-wp-smush-backup.php';
19
+
20
  if ( ! class_exists( 'WpSmush' ) ) {
21
 
22
  class WpSmush {
65
  */
66
  var $keep_exif = false;
67
 
68
+ /** @var Attachment id for the Image being smushed currently */
69
+ var $attachment_id;
70
+ /**
71
+ * Attachment type, being smushed currently
72
+ *
73
+ * @var string Possible values, "wp", "nextgen"
74
+ *
75
+ */
76
+ var $media_type = 'wp';
77
+
78
  /**
79
  * Constructor
80
  */
107
  //Manage column sorting
108
  add_action( 'pre_get_posts', array( $this, 'smushit_orderby' ) );
109
 
110
+ //Enqueue Scripts, And Initialize variables
111
  add_action( 'admin_init', array( $this, 'admin_init' ) );
112
 
113
  //Load Translation files
131
  function initialise() {
132
  //Check if Lossy enabled
133
  $opt_lossy = WP_SMUSH_PREFIX . 'lossy';
134
+ $this->lossy_enabled = $this->validate_install() && get_option( $opt_lossy, false );
135
 
136
  //Check if Smush Original enabled
137
  $opt_original = WP_SMUSH_PREFIX . 'original';
138
+ $this->smush_original = $this->validate_install() && get_option( $opt_original, false );
139
 
140
  //Check Whether to keep exif or not
141
  $opt_keep_exif = WP_SMUSH_PREFIX . 'keep_exif';
185
  $file_size = file_exists( $file_path ) ? filesize( $file_path ) : '';
186
 
187
  //Check if premium user
188
+ $max_size = $this->validate_install() ? WP_SMUSH_PREMIUM_MAX_BYTES : WP_SMUSH_MAX_BYTES;
189
 
190
  //Check if file exists
191
  if ( $file_size == 0 ) {
231
  //Add the file as tmp
232
  file_put_contents( $tempfile, $response['data']->image );
233
 
234
+ //Take Backup
235
+ global $wpsmush_backup;
236
+ $wpsmush_backup->create_backup( $file_path );
 
 
 
 
 
 
237
 
238
  //replace the file
239
  $success = @rename( $tempfile, $file_path );
308
 
309
  //Flag to check, if original size image should be smushed or not
310
  $original = get_option( WP_SMUSH_PREFIX . 'original' );
311
+ $smush_full = ( $this->validate_install() && $original == 1 ) ? true : false;
312
 
313
  $errors = new WP_Error();
314
  $stats = array(
327
  return $meta;
328
  }
329
 
330
+ //Set attachment id and Media type
331
+ $this->attachment_id = $ID;
332
+ $this->media_type = "wp";
333
+
334
  //File path and URL for original image
335
  $attachment_file_path = get_attached_file( $ID );
336
 
352
  } else {
353
  $finfo = false;
354
  }
355
+
356
+ global $wpsmushit_admin;
357
  foreach ( $meta['sizes'] as $size_key => $size_data ) {
358
 
359
+ //Check if registered size is supposed to be Smushed or not
360
+ if( 'full' != $size_key && $wpsmushit_admin->skip_image_size( $size_key ) ) {
361
+ continue;
362
+ }
363
+
364
  // We take the original image. The 'sizes' will all match the same URL and
365
  // path. So just get the dirname and replace the filename.
366
  $attachment_file_path_size = path_join( dirname( $attachment_file_path ), $size_data['file'] );
551
  return $meta;
552
  }
553
 
554
+ global $wpsmush_resize, $wpsmush_pngjpg, $wpsmush_backup;
 
555
 
556
  //Check if auto is enabled
557
  $auto_smush = $this->is_auto_smush_enabled();
558
 
559
+ //Optionally Resize Images
560
+ $meta = $wpsmush_resize->auto_resize( $ID, $meta );
561
+
562
  //Auto Smush the new image
563
  if ( $auto_smush ) {
 
564
 
565
+ //Optionally Convert PNGs to JPG
566
+ $meta = $wpsmush_pngjpg->png_to_jpg( $ID, $meta );
567
+
568
+ /** Fix for Hostgator */
569
  //Check for use of http url, (Hostgator mostly)
570
  $use_http = wp_cache_get( WP_SMUSH_PREFIX . 'use_http', 'smush' );
571
  if ( ! $use_http ) {
613
  $headers['apikey'] = $api_key;
614
  }
615
 
616
+ if ( $this->lossy_enabled && $this->validate_install() ) {
617
  $headers['lossy'] = 'true';
618
  } else {
619
  $headers['lossy'] = 'false';
706
  * Return the filesize in a humanly readable format.
707
  * Taken from http://www.php.net/manual/en/function.filesize.php#91477
708
  */
709
+ function format_bytes( $bytes, $precision = 1 ) {
710
  $units = array( 'B', 'KB', 'MB', 'GB', 'TB' );
711
  $bytes = max( $bytes, 0 );
712
  $pow = floor( ( $bytes ? log( $bytes ) : 0 ) / log( 1024 ) );
713
  $pow = min( $pow, count( $units ) - 1 );
714
  $bytes /= pow( 1024, $pow );
715
 
716
+ return round( $bytes, $precision ) . $units[ $pow ];
717
  }
718
 
719
  /**
731
  *
732
  * @return mixed|string
733
  */
734
+ function validate_install() {
735
 
736
  if ( isset( $this->is_pro ) ) {
737
  return $this->is_pro;
885
 
886
  $wp_smush_data = get_post_meta( $id, $this->smushed_meta_key, true );
887
  $wp_resize_savings = get_post_meta( $id, WP_SMUSH_PREFIX . 'resize_savings', true );
888
+ $conversion_savings = get_post_meta( $id, WP_SMUSH_PREFIX . 'pngjpg_savings', true );
889
 
890
  $combined_stats = $this->combined_stats( $wp_smush_data, $wp_resize_savings );
891
 
892
+ $combined_stats = $this->combine_conversion_stats( $combined_stats, $conversion_savings );
893
+
894
  $attachment_data = wp_get_attachment_metadata( $id );
895
 
896
  // if the image is smushed
910
  $status_txt = __( 'Already Optimized', 'wp-smushit' );
911
 
912
  //Show resmush link, if the settings were changed
913
+ $show_resmush = $this->show_resmush( $id, $wp_smush_data );
914
  if ( $show_resmush ) {
915
  $status_txt .= '<br />' . $this->get_resmsuh_link( $id );
916
  }
917
 
918
  } elseif ( ! empty( $percent ) && ! empty( $bytes_readable ) ) {
919
+ $status_txt = $image_count > 1 ? sprintf( __( "%d images reduced ", 'wp-smushit' ), $image_count ) : __( "Reduced ", 'wp-smushit' );
920
+
921
+ $stats_percent = number_format_i18n( $percent, 2, '.', '' );
922
+ $stats_percent = $stats_percent > 0 ? sprintf( "( %01.1f%% )", $stats_percent ) : '';
923
+ $status_txt .= sprintf( __( "by %s %s", 'wp-smushit' ), $bytes_readable, $stats_percent );
924
+
925
+ $file_path = get_attached_file( $id );
926
+ $size = file_exists( $file_path ) ? filesize( $file_path ) : 0;
927
+ if( $size > 0 ) {
928
+ $size = $this->format_bytes( $size );
929
+ $image_size = sprintf( __( "<br /> Image Size: %s", "wp-smushit"), $size );
930
+ $status_txt .= $image_size;
931
+ }
932
 
933
+ $show_resmush = $this->show_resmush( $id, $wp_smush_data );
934
 
935
  if ( $show_resmush ) {
936
  $status_txt .= '<br />' . $this->get_resmsuh_link( $id );
985
 
986
  //Check if premium user, compression was lossless, and lossy compression is enabled
987
  //If we are displaying the resmush option already, no need to show the Super Smush button
988
+ if ( ! $show_resmush && $this->validate_install() && ! $is_lossy && $this->lossy_enabled && $image_type != 'image/gif' ) {
989
  // the button text
990
  $button_txt = __( 'Super-Smush', 'wp-smushit' );
991
  $show_button = true;
1188
  */
1189
  function smush_retina_image( $id, $retina_file, $image_size ) {
1190
 
1191
+ //Initialize attachment id and media type
1192
+ $this->attachment_id = $id;
1193
+ $this->media_type = "wp";
1194
+
1195
  /**
1196
  * Allows to Enable/Disable WP Retina 2x Integration
1197
  */
1248
  //If full image was not smushed, reason 1. Large Size logic, 2. Free and greater than 1Mb
1249
  if ( ! array_key_exists( 'full', $size_stats ) ) {
1250
  //For free version, Check the image size
1251
+ if ( ! $this->validate_install() ) {
1252
  //For free version, check if full size is greater than 1 Mb, show the skipped status
1253
  $file_size = file_exists( $full_image ) ? filesize( $full_image ) : '';
1254
  if ( ! empty( $file_size ) && ( $file_size / WP_SMUSH_MAX_BYTES ) > 1 ) {
1323
  */
1324
  function get_detailed_stats( $image_id, $wp_smush_data, $attachment_metadata ) {
1325
 
1326
+ global $wpsmushit_admin;
1327
+
1328
  $stats = '<div id="smush-stats-' . $image_id . '" class="smush-stats-wrapper hidden">
1329
  <table class="wp-smush-stats-holder">
1330
  <thead>
1356
  }
1357
  //Show Sizes and their compression
1358
  foreach ( $size_stats as $size_key => $size_value ) {
1359
+ $dimensions = '';
1360
+ //Get the dimensions for the image size if available
1361
+ if ( ! empty( $wpsmushit_admin->image_sizes ) && !empty( $wpsmushit_admin->image_sizes[$size_key] ) ) {
1362
+ $dimensions = $wpsmushit_admin->image_sizes[ $size_key ]['width'] . 'x' . $wpsmushit_admin->image_sizes[ $size_key ]['height'];
1363
+ }
1364
+ $dimensions = !empty( $dimensions ) ? sprintf( " <br /> (%s)", $dimensions ) : '';
1365
  if ( $size_value->bytes > 0 ) {
1366
+ $percent = round( $size_value->percent, 1 );
1367
+ $percent = $percent > 0 ? ' ( ' . $percent . '% )' : '';
1368
  $stats .= '<tr>
1369
+ <td>' . strtoupper( $size_key ) . $dimensions . '</td>
1370
+ <td>' . $this->format_bytes( $size_value->bytes ) . $percent . '</td>
1371
  </tr>';
1372
  }
1373
  }
1395
  * Include and instantiate classes
1396
  */
1397
  function load_nextgen() {
1398
+ if ( ! class_exists( 'C_NextGEN_Bootstrap' ) || ! $this->validate_install() ) {
1399
  return;
1400
  }
1401
  //Check if integration is Enabled or not
1491
  return true;
1492
  }
1493
 
1494
+ //Additional Backup Check for JPEGs converted from PNG
1495
+ $pngjpg_savings = get_post_meta( $image_id, WP_SMUSH_PREFIX . 'pngjpg_savings', true );
1496
+ if ( ! empty( $pngjpg_savings ) ) {
1497
+ //Get the original File path and check if it exists
1498
+ $backup = get_post_meta( $image_id, WP_SMUSH_PREFIX . 'original_file', true );
1499
+ $backup = $this->original_file( $backup );
1500
+
1501
+ if ( !empty( $backup ) && file_exists( $backup ) ) {
1502
+ return true;
1503
+ }
1504
+ }
1505
+
1506
  //Check for backup of image sizes
1507
  foreach ( $attachment_data['sizes'] as $image_size ) {
1508
  $size_path = path_join( dirname( $file ), $image_size['file'] );
1612
  //Update the savings cache
1613
  $wpsmush_stats->resize_savings( true );
1614
 
1615
+ //Update the savings cache
1616
+ $wpsmush_stats->conversion_savings( true );
1617
+
1618
  //If no image id provided
1619
  if ( empty( $image_id ) ) {
1620
  return false;
1640
  function send_smush_stats() {
1641
  global $wpsmushit_admin;
1642
 
1643
+ $stats = $wpsmushit_admin->global_stats_from_ids();
1644
 
1645
  return $stats;
1646
 
1659
  if ( empty( $attachment_id ) || ! class_exists( 'Upfront' ) ) {
1660
  return $stats;
1661
  }
1662
+
1663
+ //Set attachment id and Media type
1664
+ $this->attachment_id = $attachment_id;
1665
+ $this->media_type = "upfront";
1666
+
1667
  //Get post meta to check for Upfront images
1668
  $upfront_images = get_post_meta( $attachment_id, 'upfront_used_image_sizes', true );
1669
 
1710
  *
1711
  * @return bool
1712
  */
1713
+ function show_resmush( $id = '', $wp_smush_data ) {
1714
  //Resmush: Show resmush link, Check if user have enabled smushing the original and full image was skipped
1715
  //Or: If keep exif is unchecked and the smushed image have exif
1716
+ //PNG To JPEG
1717
  if ( $this->smush_original ) {
1718
  //IF full image was not smushed
1719
  if ( ! empty( $wp_smush_data ) && empty( $wp_smush_data['sizes']['full'] ) ) {
1720
+ return true;
1721
  }
1722
  }
1723
+
1724
+ //EXIF Check
1725
+ if ( ! $this->keep_exif ) {
1726
+ //If Keep Exif was set to true initially, and since it is set to false now
1727
  if ( isset( $wp_smush_data['stats']['keep_exif'] ) && $wp_smush_data['stats']['keep_exif'] == 1 ) {
1728
+ return true;
1729
  }
1730
  }
1731
+
1732
+ //PNG to JPEG
1733
+ global $wpsmush_pngjpg;
1734
+ if ( $wpsmush_pngjpg->can_be_converted( $id ) ) {
1735
+ return true;
1736
+ }
1737
+
1738
+ return false;
1739
+
1740
  }
1741
 
1742
  /**
1890
  return $smush_stats;
1891
  }
1892
 
 
 
 
 
 
 
 
 
1893
  //Full Image
1894
  if( !empty( $smush_stats['sizes']['full'] ) ) {
1895
  $smush_stats['sizes']['full']->bytes = ! empty( $resize_savings['bytes'] ) ? $smush_stats['sizes']['full']->bytes + $resize_savings['bytes'] : $smush_stats['sizes']['full']->bytes;
1896
+ $smush_stats['sizes']['full']->size_before = ! empty( $resize_savings['size_before'] ) && ( $resize_savings['size_before'] > $smush_stats['sizes']['full']->size_before ) ? $resize_savings['size_before'] : $smush_stats['sizes']['full']->size_before;
 
1897
  $smush_stats['sizes']['full']->percent = ! empty( $smush_stats['sizes']['full']->bytes ) && $smush_stats['sizes']['full']->size_before > 0 ? ( $smush_stats['sizes']['full']->bytes / $smush_stats['sizes']['full']->size_before ) * 100 : $smush_stats['sizes']['full']->percent;
1898
 
1899
+ $smush_stats['sizes']['full']->percent = round( $smush_stats['sizes']['full']->percent, 1 );
1900
  }
1901
 
1902
+ $smush_stats = $this->total_compression( $smush_stats );
1903
+
1904
  return $smush_stats;
1905
  }
1906
+
1907
+ /**
1908
+ * Combine Savings from PNG to JPG conversion with smush stats
1909
+ *
1910
+ * @param $stats Savings from Smushing the image
1911
+ * @param $conversion_savings Savings from converting the PNG to JPG
1912
+ *
1913
+ * @return Object Total Savings
1914
+ */
1915
+ function combine_conversion_stats( $stats, $conversion_savings ) {
1916
+ if ( empty( $stats ) || empty( $conversion_savings ) ) {
1917
+ return $stats;
1918
+ }
1919
+ foreach ( $conversion_savings as $size_k => $savings ) {
1920
+ if ( ! empty( $stats['sizes'][ $size_k ] ) && ! empty( $savings ) ) {
1921
+ $stats['sizes'][ $size_k ]->bytes = $stats['sizes'][ $size_k ]->bytes + $savings['bytes'];
1922
+ $stats['sizes'][ $size_k ]->size_before = $stats['sizes'][ $size_k ]->size_before > $savings['size_before'] ? $stats['sizes'][ $size_k ]->size_before : $savings['size_before'];
1923
+ $stats['sizes'][ $size_k ]->percent = ! empty( $stats['sizes'][ $size_k ]->bytes ) && $stats['sizes'][ $size_k ]->size_before > 0 ? ( $stats['sizes'][ $size_k ]->bytes / $stats['sizes'][ $size_k ]->size_before ) * 100 : $stats['sizes'][ $size_k ]->percent;
1924
+ $stats['sizes'][ $size_k ]->percent = round( $stats['sizes'][ $size_k ]->percent, 1 );
1925
+ }
1926
+ }
1927
+
1928
+ $stats = $this->total_compression( $stats );
1929
+
1930
+ return $stats;
1931
+ }
1932
+
1933
+ /**
1934
+ * Original File path
1935
+ *
1936
+ * @param string $original_file
1937
+ *
1938
+ */
1939
+ function original_file( $original_file = '' ) {
1940
+ $uploads = wp_get_upload_dir();
1941
+ $upload_path = $uploads['basedir'];
1942
+
1943
+ return path_join( $upload_path, $original_file );
1944
+ }
1945
  }
1946
 
1947
  global $WpSmush;
lib/nextgen-integration/class-wp-smush-nextgen-admin.php CHANGED
@@ -378,14 +378,14 @@ if ( ! class_exists( 'WpSmushNextGenAdmin' ) ) {
378
  //Page Header
379
  $this->bulk_ui->smush_page_header(); ?>
380
  <!-- Bulk Smush Progress Bar -->
381
- <div class="wp-smushit-container-left col-two-third float-l"><?php
382
  //Bulk Smush Container
383
  $this->bulk_smush_container();
384
  ?>
385
  </div>
386
 
387
  <!-- Stats -->
388
- <div class="wp-smushit-container-right col-third float-l"><?php
389
  //Stats
390
  $this->smush_stats_container(); ?>
391
  </div><!-- End Of Smushit Container right -->
@@ -419,7 +419,7 @@ if ( ! class_exists( 'WpSmushNextGenAdmin' ) ) {
419
  //If there are no images in Media Library
420
  if ( 0 >= $this->total_count ) { ?>
421
  <span class="wp-smush-no-image tc">
422
- <img src="<?php echo WP_SMUSH_URL . 'assets/images/smush-upload-images.png'; ?>"
423
  alt="<?php esc_html_e( "No attachments found - Upload some images", "wp-smushit" ); ?>">
424
  </span>
425
  <p class="wp-smush-no-images-content tc roboto-regular"><?php printf( esc_html__( "We haven’t found any images in your %sgallery%s yet, so there’s no smushing to be done! Once you upload images, reload this page and start playing!", "wp-smushit" ), '<a href="' . esc_url( admin_url( 'admin.php?page=ngg_addgallery' ) ) . '">', '</a>' ); ?></p>
@@ -476,7 +476,7 @@ if ( ! class_exists( 'WpSmushNextGenAdmin' ) ) {
476
  //Subheading Content
477
  $smush_individual_msg = sprintf( esc_html__( "Smush individual images via your %sManage Galleries%s section", "wp-smushit" ), '<a href="' . esc_url( admin_url() . 'admin.php?page=nggallery-manage-gallery' ) . '" title="' . esc_html__( 'Manage Galleries', 'wp-smushit' ) . '">', '</a>' );
478
 
479
- $class = $WpSmush->is_pro() ? 'bulk-smush-wrapper wp-smush-pro-install' : 'bulk-smush-wrapper';
480
 
481
  //Container Header
482
  $this->bulk_ui->container_header( $class, 'wp-smush-bulk-wrap-box', esc_html__( "BULK SMUSH", "wp-smushit" ), $smush_individual_msg ); ?>
@@ -500,41 +500,50 @@ if ( ! class_exists( 'WpSmushNextGenAdmin' ) ) {
500
  $this->stats = $wpsmushnextgenstats->get_smush_stats();
501
 
502
  $button = '<span class="spinner"></span><button tooltip="' . esc_html__( "Lets you check if any images can be further optimised. Useful after changing settings.", "wp-smushit" ) . '" data-type="nextgen" class="wp-smush-title button button-grey button-small wp-smush-scan">' . esc_html__( "RE-CHECK IMAGES", "wp-smushit" ) . '</button>';
503
- $this->bulk_ui->container_header( 'smush-stats-wrapper', 'wp-smush-stats-box', esc_html__( "STATS", "wp-smushit" ), $button ); ?>
 
 
504
 
505
  <div class="box-content">
506
- <div class="row smush-total-reduction-percent">
507
- <span class="float-l wp-smush-stats-label">
508
- <strong><?php esc_html_e( "TOTAL % REDUCTIONS", "wp-smushit" ); ?></strong>
509
- </span>
510
- <span class="float-r wp-smush-stats-wrap">
511
- <strong>
512
- <span
513
- class="wp-smush-stats"><?php echo $this->stats['percent'] > 0 ? number_format_i18n( $this->stats['percent'], 2, '.', '' ) : 0; ?></span>%
514
- </strong>
515
- </span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
516
  </div>
517
- <hr>
518
- <div class="row smush-total-reduction-bytes">
519
- <span class="float-l wp-smush-stats-label">
520
- <strong><?php esc_html_e( "TOTAL SIZE REDUCTIONS", "wp-smushit" ); ?></strong>
521
- </span>
522
- <span class="float-r wp-smush-stats">
523
- <strong><?php echo $this->stats['human'] > 0 ? $this->stats['human'] : "0MB"; ?></strong>
 
524
  </span>
 
525
  </div>
526
- <hr>
527
- <div class="row smush-attachments">
528
- <span class="float-l wp-smush-stats-label">
529
- <strong><?php esc_html_e( "ATTACHMENTS SMUSHED", "wp-smushit" ); ?></strong>
530
- </span>
531
- <span class="float-r wp-smush-stats">
532
- <strong>
533
- <span
534
- class="smushed-count"><?php echo $smushed_count . '</span>/' . $this->total_count; ?>
535
- </strong>
536
- </span>
537
- </div><?php
538
  //Nonce Field for Ajax requests
539
  echo wp_nonce_field( 'save_wp_smush_options', 'wp_smush_options_nonce', '', false );
540
  if ( apply_filters( 'wp_smush_show_nextgen_lossy_stats', true ) ) { ?>
@@ -547,7 +556,7 @@ if ( ! class_exists( 'WpSmushNextGenAdmin' ) ) {
547
  <?php
548
  if ( $WpSmush->lossy_enabled ) {
549
  $count = $wpsmush_stats->super_smushed_count( 'nextgen', $wpsmushnextgenstats->get_ngg_images( 'smushed' ) );
550
- echo '<strong><span class="smushed-count">' . $count . '</span>/' . $this->total_count . '</strong>';
551
  } else {
552
  printf( esc_html__( "%sDISABLED%s", "wp-smushit" ), '<span class="wp-smush-lossy-disabled">', '</span>' );
553
  } ?>
378
  //Page Header
379
  $this->bulk_ui->smush_page_header(); ?>
380
  <!-- Bulk Smush Progress Bar -->
381
+ <div class="wp-smushit-container-left col-half float-l"><?php
382
  //Bulk Smush Container
383
  $this->bulk_smush_container();
384
  ?>
385
  </div>
386
 
387
  <!-- Stats -->
388
+ <div class="wp-smushit-container-right col-half float-l"><?php
389
  //Stats
390
  $this->smush_stats_container(); ?>
391
  </div><!-- End Of Smushit Container right -->
419
  //If there are no images in Media Library
420
  if ( 0 >= $this->total_count ) { ?>
421
  <span class="wp-smush-no-image tc">
422
+ <img src="<?php echo WP_SMUSH_URL . 'assets/images/smush-no-media.png'; ?>"
423
  alt="<?php esc_html_e( "No attachments found - Upload some images", "wp-smushit" ); ?>">
424
  </span>
425
  <p class="wp-smush-no-images-content tc roboto-regular"><?php printf( esc_html__( "We haven’t found any images in your %sgallery%s yet, so there’s no smushing to be done! Once you upload images, reload this page and start playing!", "wp-smushit" ), '<a href="' . esc_url( admin_url( 'admin.php?page=ngg_addgallery' ) ) . '">', '</a>' ); ?></p>
476
  //Subheading Content
477
  $smush_individual_msg = sprintf( esc_html__( "Smush individual images via your %sManage Galleries%s section", "wp-smushit" ), '<a href="' . esc_url( admin_url() . 'admin.php?page=nggallery-manage-gallery' ) . '" title="' . esc_html__( 'Manage Galleries', 'wp-smushit' ) . '">', '</a>' );
478
 
479
+ $class = $WpSmush->validate_install() ? 'bulk-smush-wrapper wp-smush-pro-install' : 'bulk-smush-wrapper';
480
 
481
  //Container Header
482
  $this->bulk_ui->container_header( $class, 'wp-smush-bulk-wrap-box', esc_html__( "BULK SMUSH", "wp-smushit" ), $smush_individual_msg ); ?>
500
  $this->stats = $wpsmushnextgenstats->get_smush_stats();
501
 
502
  $button = '<span class="spinner"></span><button tooltip="' . esc_html__( "Lets you check if any images can be further optimised. Useful after changing settings.", "wp-smushit" ) . '" data-type="nextgen" class="wp-smush-title button button-grey button-small wp-smush-scan">' . esc_html__( "RE-CHECK IMAGES", "wp-smushit" ) . '</button>';
503
+ $this->bulk_ui->container_header( 'smush-stats-wrapper', 'wp-smush-stats-box', esc_html__( "STATS", "wp-smushit" ), $button );
504
+ $dasharray = 125.663706144;
505
+ $dash_offset = $this->total_count > 0 ? $dasharray - ( $dasharray * ( $smushed_count / $this->total_count ) ) : $dasharray; ?>
506
 
507
  <div class="box-content">
508
+ <div class="row smush-total-savings smush-total-reduction-percent">
509
+
510
+ <div class="wp-smush-current-progress">
511
+ <div class="wp-smushed-progress">
512
+ <div class="wp-smush-score inside">
513
+ <div class="tooltip-box">
514
+ <div class="wp-smush-optimisation-progress">
515
+ <div class="wp-smush-progress-circle">
516
+ <svg class="wp-smush-svg" xmlns="http://www.w3.org/2000/svg" width="50" height="50">
517
+ <circle class="wp-smush-svg-circle" r="20" cx="25" cy="25" fill="transparent" stroke-dasharray="0" stroke-dashoffset="0"></circle>
518
+ <!-- Stroke Dasharray is 2 PI r -->
519
+ <circle class="wp-smush-svg-circle wp-smush-svg-circle-progress" r="20" cx="25" cy="25" fill="transparent" stroke-dasharray="<?php echo $dasharray; ?>" style="stroke-dashoffset: <?php echo $dash_offset; ?>px;"></circle>
520
+ </svg>
521
+ </div>
522
+ </div>
523
+ </div><!-- end tooltip-box -->
524
+ </div>
525
+ </div>
526
+
527
+ <div class="wp-smush-count-total">
528
+ <div class="wp-smush-smush-stats-wrapper">
529
+ <span class="wp-smush-optimised"><?php echo $smushed_count; ?></span>/<span><?php echo $this->total_count; ?></span>
530
+ </div>
531
+ <span class="total-stats-label"><strong><?php esc_html_e( "ATTACHMENTS SMUSHED", "wp-smushit" ); ?></strong></span>
532
+ </div>
533
+ </div>
534
  </div>
535
+ <hr />
536
+ <div class="row wp-smush-savings">
537
+ <span class="float-l wp-smush-stats-label"><strong><?php esc_html_e("TOTAL SAVINGS", "wp-smushit");?></strong></span>
538
+ <span class="float-r wp-smush-stats">
539
+ <span class="wp-smush-stats-percent"><?php echo $this->stats['percent'] > 0 ? number_format_i18n( $this->stats['percent'], 1, '.', '' ) : 0; ?></span>%
540
+ <span class="wp-smush-stats-sep">/</span>
541
+ <span class="wp-smush-stats-human">
542
+ <?php echo $this->stats['human'] > 0 ? $this->stats['human'] : "0MB"; ?>
543
  </span>
544
+ </span>
545
  </div>
546
+ <?php
 
 
 
 
 
 
 
 
 
 
 
547
  //Nonce Field for Ajax requests
548
  echo wp_nonce_field( 'save_wp_smush_options', 'wp_smush_options_nonce', '', false );
549
  if ( apply_filters( 'wp_smush_show_nextgen_lossy_stats', true ) ) { ?>
556
  <?php
557
  if ( $WpSmush->lossy_enabled ) {
558
  $count = $wpsmush_stats->super_smushed_count( 'nextgen', $wpsmushnextgenstats->get_ngg_images( 'smushed' ) );
559
+ echo '<span class="smushed-count">' . $count . '</span>/' . $this->total_count;
560
  } else {
561
  printf( esc_html__( "%sDISABLED%s", "wp-smushit" ), '<span class="wp-smush-lossy-disabled">', '</span>' );
562
  } ?>
lib/nextgen-integration/class-wp-smush-nextgen-stats.php CHANGED
@@ -24,7 +24,7 @@ if ( ! class_exists( 'WpSmushNextGenStats' ) ) {
24
  function __construct() {
25
 
26
  global $WpSmush;
27
- $this->is_pro_user = $WpSmush->is_pro();
28
 
29
  //Update Total Image count
30
  add_action( 'ngg_added_new_image', array( $this, 'image_count' ), 10 );
@@ -399,7 +399,7 @@ if ( ! class_exists( 'WpSmushNextGenStats' ) ) {
399
  }
400
 
401
  //Round off precentage
402
- $smushed_stats['percent'] = ! empty( $smushed_stats['percent'] ) ? round( $smushed_stats['percent'], 2 ) : 0;
403
 
404
  $smushed_stats['human'] = $WpSmush->format_bytes( $smushed_stats['bytes'] );
405
 
24
  function __construct() {
25
 
26
  global $WpSmush;
27
+ $this->is_pro_user = $WpSmush->validate_install();
28
 
29
  //Update Total Image count
30
  add_action( 'ngg_added_new_image', array( $this, 'image_count' ), 10 );
399
  }
400
 
401
  //Round off precentage
402
+ $smushed_stats['percent'] = ! empty( $smushed_stats['percent'] ) ? round( $smushed_stats['percent'], 1 ) : 0;
403
 
404
  $smushed_stats['human'] = $WpSmush->format_bytes( $smushed_stats['bytes'] );
405
 
readme.txt CHANGED
@@ -1,13 +1,13 @@
1
  === WP Smush - Image Optimization ===
2
  Plugin Name: WP Smush - Image Optimization
3
- Version: 2.3.1
4
  Author: WPMU DEV
5
  Author URI: http://premium.wpmudev.org/
6
  Contributors: WPMUDEV, alexdunae
7
  Tags: image optimization, image compression, attachment,Attachments,compress,Compress Image File,Compress Image Size,Compress JPG,Compressed JPG, Compression Image,Image,Images,JPG,Optimise,Optimize,Photo,Photos,Pictures,PNG,Reduce Image Size,Smush,Smush.it,Upload,WordPress Compression,WordPress Image Tool,Yahoo, Yahoo Smush.it
8
  Requires at least: 3.5
9
- Tested up to: 4.5.2
10
- Stable tag: 2.3.1
11
  License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12
 
13
  Reduce image file sizes, improve performance and boost your SEO using the free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
@@ -91,6 +91,23 @@ Yahoo's Smush.it API is gone forever. So WPMU DEV built our own free API that is
91
 
92
  == Changelog ==
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  = 2.3.1 =
95
 
96
  * Fixed:
1
  === WP Smush - Image Optimization ===
2
  Plugin Name: WP Smush - Image Optimization
3
+ Version: 2.4
4
  Author: WPMU DEV
5
  Author URI: http://premium.wpmudev.org/
6
  Contributors: WPMUDEV, alexdunae
7
  Tags: image optimization, image compression, attachment,Attachments,compress,Compress Image File,Compress Image Size,Compress JPG,Compressed JPG, Compression Image,Image,Images,JPG,Optimise,Optimize,Photo,Photos,Pictures,PNG,Reduce Image Size,Smush,Smush.it,Upload,WordPress Compression,WordPress Image Tool,Yahoo, Yahoo Smush.it
8
  Requires at least: 3.5
9
+ Tested up to: 4.5.3
10
+ Stable tag: 2.4
11
  License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12
 
13
  Reduce image file sizes, improve performance and boost your SEO using the free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
91
 
92
  == Changelog ==
93
 
94
+ = 2.4 =
95
+
96
+ * Compatibility:
97
+ * WPML Media Add-on compatibility, you can smush all the images for all the languages at once from Bulk Smush page
98
+
99
+ * Features:
100
+ * Added PNG to JPG - Lossy Conversion for higher savings ( Pro Feature )
101
+
102
+ *Fixed:
103
+ * EXIF: Device details were left out for some images, even when opted for stripping it
104
+
105
+ * Updated:
106
+ * Minor Tweaks on WP Smush Page ( Bulk Smush )
107
+ * Stats calculation
108
+ * Show current image size and image size dimensions in media library after image has been smushed
109
+ * JPEG optimisation - higher savings for JPEGs lossy optimisation ( Pro Feature )
110
+
111
  = 2.3.1 =
112
 
113
  * Fixed:
uninstall.php CHANGED
@@ -18,10 +18,14 @@ $smushit_keys = array(
18
  'lossy',
19
  'backup',
20
  'resize',
 
21
  'resize-sizes',
22
  'nextgen',
23
  'keep_exif',
24
  'resmush-list',
 
 
 
25
  'skip-redirect',
26
  'nextgen-resmush-list',
27
  'super_smushed',
@@ -44,6 +48,7 @@ $cache_keys = array(
44
  $cache_smush_group = array(
45
  'exceeding_items',
46
  'wp-smush-resize_savings',
 
47
  );
48
  $cache_nextgen_group = array(
49
  'wp_smush_images',
@@ -91,6 +96,8 @@ if ( is_multisite() ) {
91
  delete_metadata( $meta_type, null, $meta_key, $meta_value, $delete_all );
92
  delete_metadata( $meta_type, null, 'wp-smush-lossy', '', $delete_all );
93
  delete_metadata( $meta_type, null, 'wp-smush-resize_savings', '', $delete_all );
 
 
94
  foreach ( $smushit_keys as $key ) {
95
  $key = 'wp-smush-' . $key;
96
  delete_option( $key );
@@ -117,6 +124,9 @@ if ( is_multisite() ) {
117
  delete_metadata( $meta_type, null, $meta_key, $meta_value, $delete_all );
118
  delete_metadata( $meta_type, null, 'wp-smush-lossy', '', $delete_all );
119
  delete_metadata( $meta_type, null, 'wp-smush-resize_savings', '', $delete_all );
 
 
120
  }
121
  //@todo: Add procedure to delete backup files
 
122
  ?>
18
  'lossy',
19
  'backup',
20
  'resize',
21
+ 'png_to_jpg',
22
  'resize-sizes',
23
  'nextgen',
24
  'keep_exif',
25
  'resmush-list',
26
+ 'resize_sizes',
27
+ 'transparent_png',
28
+ 'image_sizes',
29
  'skip-redirect',
30
  'nextgen-resmush-list',
31
  'super_smushed',
48
  $cache_smush_group = array(
49
  'exceeding_items',
50
  'wp-smush-resize_savings',
51
+ 'pngjpg_savings'
52
  );
53
  $cache_nextgen_group = array(
54
  'wp_smush_images',
96
  delete_metadata( $meta_type, null, $meta_key, $meta_value, $delete_all );
97
  delete_metadata( $meta_type, null, 'wp-smush-lossy', '', $delete_all );
98
  delete_metadata( $meta_type, null, 'wp-smush-resize_savings', '', $delete_all );
99
+ delete_metadata( $meta_type, null, 'wp-smush-original_file', '', $delete_all );
100
+ delete_metadata( $meta_type, null, 'wp-smush-pngjpg_savings', '', $delete_all );
101
  foreach ( $smushit_keys as $key ) {
102
  $key = 'wp-smush-' . $key;
103
  delete_option( $key );
124
  delete_metadata( $meta_type, null, $meta_key, $meta_value, $delete_all );
125
  delete_metadata( $meta_type, null, 'wp-smush-lossy', '', $delete_all );
126
  delete_metadata( $meta_type, null, 'wp-smush-resize_savings', '', $delete_all );
127
+ delete_metadata( $meta_type, null, 'wp-smush-original_file', '', $delete_all );
128
+ delete_metadata( $meta_type, null, 'wp-smush-pngjpg_savings', '', $delete_all );
129
  }
130
  //@todo: Add procedure to delete backup files
131
+ //@todo: Update NextGen Metadata to remove Smush stats on plugin deletion
132
  ?>
wp-smush.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: WP Smush
4
  Plugin URI: http://wordpress.org/extend/plugins/wp-smushit/
5
  Description: Reduce image file sizes, improve performance and boost your SEO using the free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
6
  Author: WPMU DEV
7
- Version: 2.3.1
8
  Author URI: http://premium.wpmudev.org/
9
  Textdomain: wp-smushit
10
  */
@@ -35,7 +35,20 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35
  * Constants
36
  */
37
  $prefix = 'WP_SMUSH_';
38
- $version = '2.3.1';
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  /**
41
  * Set the default timeout for API request and AJAX timeout
@@ -74,7 +87,7 @@ require_once WP_SMUSH_DIR . 'lib/class-wp-smush.php';
74
  if ( ! function_exists( 'wp_smush_rating_message' ) ) {
75
  function wp_smush_rating_message( $message ) {
76
  global $wpsmushit_admin, $wpsmush_stats;
77
- $savings = $wpsmushit_admin->global_stats();
78
  $image_count = $wpsmush_stats->total_count();
79
  $show_stats = false;
80
 
@@ -109,14 +122,17 @@ if ( ! function_exists( 'wp_smush_email_message' ) ) {
109
  return $message;
110
  }
111
  }
112
- /**
113
- * Returns the dir path for the plugin
114
- *
115
- * @return string
116
- */
117
- function get_plugin_dir() {
118
- $dir_path = plugin_dir_path( __FILE__ );
119
- return $dir_path;
 
 
 
120
  }
121
 
122
  if ( is_admin() ) {
@@ -169,18 +185,6 @@ if ( is_admin() ) {
169
  );
170
  }
171
  }
172
- //Deactivate the .org version, if pro version is active
173
- add_action( 'admin_init', 'deactivate_smush_org' );
174
-
175
- if ( ! function_exists( 'deactivate_smush_org' ) ) {
176
- function deactivate_smush_org() {
177
- if ( is_plugin_active( 'wp-smush-pro/wp-smush.php' ) && is_plugin_active( 'wp-smushit/wp-smush.php' ) ) {
178
- deactivate_plugins( 'wp-smushit/wp-smush.php' );
179
- //Store in database, in order to show a notice on page load
180
- update_option( 'smush_deactivated', 1 );
181
- }
182
- }
183
- }
184
 
185
  //Show the required notice
186
  add_action( 'network_admin_notices', 'smush_deactivated' );
@@ -188,40 +192,82 @@ add_action( 'admin_notices', 'smush_deactivated' );
188
  //Display a admin Notice about plugin deactivation
189
  if ( ! function_exists( 'smush_deactivated' ) ) {
190
  function smush_deactivated() {
191
- if ( get_option( 'smush_deactivated' ) && is_admin() ) { ?>
192
  <div class="updated">
193
  <p><?php esc_html_e( 'WP Smush Free was deactivated. You have WP Smush Pro active!', 'wp-smushit' ); ?></p>
194
  </div> <?php
195
- delete_option( 'smush_deactivated' );
196
  }
197
  }
198
  }
199
 
 
200
  //Check if a existing install or new
201
- function smush_activated() {
202
-
203
- $version = get_site_option( WP_SMUSH_PREFIX . 'version' );
204
-
205
- //If the version is not saved or if the version is not same as the current version,
206
- if ( ! $version || WP_SMUSH_VERSION != $version ) {
207
- global $wpdb;
208
- //Check if there are any existing smush stats
209
- $query = "SELECT meta_id FROM {$wpdb->postmeta} WHERE meta_key=%s LIMIT 1";
210
- $results = $wpdb->get_var( $wpdb->prepare( $query, 'wp-smpro-smush-data' ) );
211
-
212
- if ( $results ) {
213
- update_option( 'wp-smush-install-type', 'existing' );
214
- }else{
215
- //Check for existing settings
216
- if( false !== get_site_option( WP_SMUSH_PREFIX . 'auto' ) || false !== get_option( WP_SMUSH_PREFIX . 'auto' ) ) {
217
  update_option( 'wp-smush-install-type', 'existing' );
 
 
 
 
 
218
  }
 
 
 
219
  }
220
 
221
- //Store the plugin version in db
222
- update_site_option( WP_SMUSH_PREFIX . 'version', WP_SMUSH_VERSION );
223
  }
 
224
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  }
226
 
227
  register_activation_hook( __FILE__, 'smush_activated' );
4
  Plugin URI: http://wordpress.org/extend/plugins/wp-smushit/
5
  Description: Reduce image file sizes, improve performance and boost your SEO using the free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
6
  Author: WPMU DEV
7
+ Version: 2.4
8
  Author URI: http://premium.wpmudev.org/
9
  Textdomain: wp-smushit
10
  */
35
  * Constants
36
  */
37
  $prefix = 'WP_SMUSH_';
38
+ $version = '2.4';
39
+
40
+ //Deactivate the .org version, if pro version is active
41
+ add_action( 'admin_init', 'deactivate_smush_org' );
42
+
43
+ if ( ! function_exists( 'deactivate_smush_org' ) ) {
44
+ function deactivate_smush_org() {
45
+ if ( is_plugin_active( 'wp-smush-pro/wp-smush.php' ) && is_plugin_active( 'wp-smushit/wp-smush.php' ) ) {
46
+ deactivate_plugins( 'wp-smushit/wp-smush.php' );
47
+ //Store in database, in order to show a notice on page load
48
+ update_site_option( 'smush_deactivated', 1 );
49
+ }
50
+ }
51
+ }
52
 
53
  /**
54
  * Set the default timeout for API request and AJAX timeout
87
  if ( ! function_exists( 'wp_smush_rating_message' ) ) {
88
  function wp_smush_rating_message( $message ) {
89
  global $wpsmushit_admin, $wpsmush_stats;
90
+ $savings = $wpsmushit_admin->global_stats_from_ids();
91
  $image_count = $wpsmush_stats->total_count();
92
  $show_stats = false;
93
 
122
  return $message;
123
  }
124
  }
125
+ if( !function_exists('get_plugin_dir') ) {
126
+ /**
127
+ * Returns the dir path for the plugin
128
+ *
129
+ * @return string
130
+ */
131
+ function get_plugin_dir() {
132
+ $dir_path = plugin_dir_path( __FILE__ );
133
+
134
+ return $dir_path;
135
+ }
136
  }
137
 
138
  if ( is_admin() ) {
185
  );
186
  }
187
  }
 
 
 
 
 
 
 
 
 
 
 
 
188
 
189
  //Show the required notice
190
  add_action( 'network_admin_notices', 'smush_deactivated' );
192
  //Display a admin Notice about plugin deactivation
193
  if ( ! function_exists( 'smush_deactivated' ) ) {
194
  function smush_deactivated() {
195
+ if ( get_site_option( 'smush_deactivated' ) && is_super_admin() ) { ?>
196
  <div class="updated">
197
  <p><?php esc_html_e( 'WP Smush Free was deactivated. You have WP Smush Pro active!', 'wp-smushit' ); ?></p>
198
  </div> <?php
199
+ delete_site_option( 'smush_deactivated' );
200
  }
201
  }
202
  }
203
 
204
+ if ( ! function_exists( 'smush_activated' ) ) {
205
  //Check if a existing install or new
206
+ function smush_activated() {
207
+
208
+ $version = get_site_option( WP_SMUSH_PREFIX . 'version' );
209
+
210
+ //If the version is not saved or if the version is not same as the current version,
211
+ if ( ! $version || WP_SMUSH_VERSION != $version ) {
212
+ global $wpdb;
213
+ //Check if there are any existing smush stats
214
+ $query = "SELECT meta_id FROM {$wpdb->postmeta} WHERE meta_key=%s LIMIT 1";
215
+ $results = $wpdb->get_var( $wpdb->prepare( $query, 'wp-smpro-smush-data' ) );
216
+
217
+ if ( $results ) {
 
 
 
 
218
  update_option( 'wp-smush-install-type', 'existing' );
219
+ } else {
220
+ //Check for existing settings
221
+ if ( false !== get_site_option( WP_SMUSH_PREFIX . 'auto' ) || false !== get_option( WP_SMUSH_PREFIX . 'auto' ) ) {
222
+ update_option( 'wp-smush-install-type', 'existing' );
223
+ }
224
  }
225
+
226
+ //Store the plugin version in db
227
+ update_site_option( WP_SMUSH_PREFIX . 'version', WP_SMUSH_VERSION );
228
  }
229
 
 
 
230
  }
231
+ }
232
 
233
+
234
+ if ( ! function_exists( 'sanitize_hex_color' ) ) {
235
+ /**
236
+ * Sanitizes a hex color.
237
+ *
238
+ * @param $color
239
+ *
240
+ * @return string Returns either '', a 3 or 6 digit hex color (with #), or nothing
241
+ */
242
+ function sanitize_hex_color( $color ) {
243
+ if ( '' === $color ) {
244
+ return '';
245
+ }
246
+
247
+ // 3 or 6 hex digits, or the empty string.
248
+ if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
249
+ return $color;
250
+ }
251
+ }
252
+ }
253
+
254
+ if ( ! function_exists( 'sanitize_hex_color_no_hash' ) ) {
255
+ /**
256
+ * Sanitizes a hex color without hash
257
+ *
258
+ * @param $color
259
+ *
260
+ * @return string Returns either '', a 3 or 6 digit hex color (with #), or nothing
261
+ */
262
+ function sanitize_hex_color_no_hash( $color ) {
263
+ $color = ltrim( $color, '#' );
264
+
265
+ if ( '' === $color ) {
266
+ return '';
267
+ }
268
+
269
+ return sanitize_hex_color( '#' . $color ) ? $color : null;
270
+ }
271
  }
272
 
273
  register_activation_hook( __FILE__, 'smush_activated' );