Smush Image Compression and Optimization - Version 2.6.1

Version Description

  • Fixed:
    • PHP 5.2 compatibility
    • DB error: Use a smaller value for Path Index size ( Prefix Indexes )
    • Updated translation function name
    • UI/UX fixes for directory smush
    • Improved optimisation process for directory smush
    • Updated uninstall.php
    • Skip sites directory from Directory Smush in a Multisite
Download this release

Release Info

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

Code changes from version 2.5.3 to 2.6.1

Files changed (53) hide show
  1. assets/css/jQueryFileTree.min.css +1 -0
  2. assets/css/wp-smushit-admin.css +724 -40
  3. assets/images/application.png +0 -0
  4. assets/images/bulk-smush.png +0 -0
  5. assets/images/code.png +0 -0
  6. assets/images/css.png +0 -0
  7. assets/images/db.png +0 -0
  8. assets/images/directory-lock.png +0 -0
  9. assets/images/directory.png +0 -0
  10. assets/images/doc.png +0 -0
  11. assets/images/file-lock.png +0 -0
  12. assets/images/file.png +0 -0
  13. assets/images/film.png +0 -0
  14. assets/images/flash.png +0 -0
  15. assets/images/folder-closed.svg +12 -0
  16. assets/images/folder-open-selected.svg +12 -0
  17. assets/images/folder-open.svg +12 -0
  18. assets/images/folder_open.png +0 -0
  19. assets/images/html.png +0 -0
  20. assets/images/image.svg +12 -0
  21. assets/images/install-welcome.png +0 -0
  22. assets/images/java.png +0 -0
  23. assets/images/linux.png +0 -0
  24. assets/images/music.png +0 -0
  25. assets/images/pdf.png +0 -0
  26. assets/images/php.png +0 -0
  27. assets/images/picture.png +0 -0
  28. assets/images/ppt.png +0 -0
  29. assets/images/psd.png +0 -0
  30. assets/images/ruby.png +0 -0
  31. assets/images/script.png +0 -0
  32. assets/images/smush-share-widget.png +0 -0
  33. assets/images/smush-upload-images.png +0 -0
  34. assets/images/spinner.gif +0 -0
  35. assets/images/txt.png +0 -0
  36. assets/images/xls.png +0 -0
  37. assets/images/zip.png +0 -0
  38. assets/js/jQueryFileTree.js +215 -0
  39. assets/js/wp-smushit-admin.js +860 -27
  40. languages/wp-smushit.pot +259 -153
  41. lib/class-wp-smush-admin.php +128 -135
  42. lib/class-wp-smush-async.php +3 -4
  43. lib/class-wp-smush-db.php +750 -0
  44. lib/class-wp-smush-dir.php +1277 -0
  45. lib/class-wp-smush-share.php +4 -5
  46. lib/class-wp-smush-ui.php +26 -17
  47. lib/class-wp-smush.php +24 -13
  48. lib/nextgen-integration/class-wp-smush-nextgen-admin.php +2 -2
  49. lib/nextgen-integration/class-wp-smush-nextgen-bulk.php +2 -2
  50. lib/wp-async-task-smush.php +275 -0
  51. readme.txt +35 -5
  52. uninstall.php +11 -3
  53. wp-smush.php +11 -9
assets/css/jQueryFileTree.min.css ADDED
@@ -0,0 +1 @@
 
1
+ UL.jqueryFileTree{font-family:Verdana,sans-serif;font-size:11px;line-height:18px;padding:0;margin:0;display:none}UL.jqueryFileTree LI{list-style:none;padding:0 0 0 20px;margin:0;white-space:nowrap}UL.jqueryFileTree LI.directory{background:url(../images/directory.png) left top no-repeat} UL.jqueryFileTree LI.directory-locked{background:url(../images/directory-lock.png) left top no-repeat} UL.jqueryFileTree LI.expanded{background:url(../images/folder_open.png) left top no-repeat} UL.jqueryFileTree LI.file{background:url(../images/file.png) left top no-repeat} UL.jqueryFileTree LI.file-locked{background:url(../images/file-lock.png) left top no-repeat!important} UL.jqueryFileTree LI.wait{background:url(../images/spinner.gif) left top no-repeat} UL.jqueryFileTree LI.selected>a{font-weight:700} UL.jqueryFileTree LI.ext_3gp{background:url(../images/film.png) left top no-repeat} UL.jqueryFileTree LI.ext_afp,UL.jqueryFileTree LI.ext_afpa,UL.jqueryFileTree LI.ext_asp,UL.jqueryFileTree LI.ext_aspx{background:url(../images/code.png) left top no-repeat} UL.jqueryFileTree LI.ext_avi{background:url(../images/film.png) left top no-repeat} UL.jqueryFileTree LI.ext_bat{background:url(../images/application.png) left top no-repeat} UL.jqueryFileTree LI.ext_bmp{background:url(../images/picture.png) left top no-repeat} UL.jqueryFileTree LI.ext_c,UL.jqueryFileTree LI.ext_cfm,UL.jqueryFileTree LI.ext_cgi{background:url(../images/code.png) left top no-repeat} UL.jqueryFileTree LI.ext_com{background:url(../images/application.png) left top no-repeat} UL.jqueryFileTree LI.ext_cpp{background:url(../images/code.png) left top no-repeat} UL.jqueryFileTree LI.ext_css{background:url(../images/css.png) left top no-repeat} UL.jqueryFileTree LI.ext_doc{background:url(../images/doc.png) left top no-repeat} UL.jqueryFileTree LI.ext_exe{background:url(../images/application.png) left top no-repeat} UL.jqueryFileTree LI.ext_gif{background:url(../images/picture.png) left top no-repeat} UL.jqueryFileTree LI.ext_fla{background:url(../images/flash.png) left top no-repeat} UL.jqueryFileTree LI.ext_h{background:url(../images/code.png) left top no-repeat} UL.jqueryFileTree LI.ext_htm,UL.jqueryFileTree LI.ext_html{background:url(../images/html.png) left top no-repeat} UL.jqueryFileTree LI.ext_jar{background:url(../images/java.png) left top no-repeat} UL.jqueryFileTree LI.ext_jpeg,UL.jqueryFileTree LI.ext_jpg{background:url(../images/picture.png) left top no-repeat} UL.jqueryFileTree LI.ext_js{background:url(../images/script.png) left top no-repeat} UL.jqueryFileTree LI.ext_lasso{background:url(../images/code.png) left top no-repeat} UL.jqueryFileTree LI.ext_log{background:url(../images/txt.png) left top no-repeat} UL.jqueryFileTree LI.ext_m4p{background:url(../images/music.png) left top no-repeat} UL.jqueryFileTree LI.ext_mov{background:url(../images/film.png) left top no-repeat} UL.jqueryFileTree LI.ext_mp3{background:url(../images/music.png) left top no-repeat} UL.jqueryFileTree LI.ext_mp4,UL.jqueryFileTree LI.ext_mpeg,UL.jqueryFileTree LI.ext_mpg{background:url(../images/film.png) left top no-repeat} UL.jqueryFileTree LI.ext_ogg{background:url(../images/music.png) left top no-repeat} UL.jqueryFileTree LI.ext_ogv{background:url(../images/film.png) left top no-repeat} UL.jqueryFileTree LI.ext_pcx{background:url(../images/picture.png) left top no-repeat} UL.jqueryFileTree LI.ext_pdf{background:url(../images/pdf.png) left top no-repeat} UL.jqueryFileTree LI.ext_php{background:url(../images/php.png) left top no-repeat} UL.jqueryFileTree LI.ext_png{background:url(../images/picture.png) left top no-repeat} UL.jqueryFileTree LI.ext_ppt{background:url(../images/ppt.png) left top no-repeat} UL.jqueryFileTree LI.ext_psd{background:url(../images/psd.png) left top no-repeat} UL.jqueryFileTree LI.ext_pl,UL.jqueryFileTree LI.ext_py{background:url(../images/script.png) left top no-repeat} UL.jqueryFileTree LI.ext_rb,UL.jqueryFileTree LI.ext_rbx,UL.jqueryFileTree LI.ext_rhtml{background:url(../images/ruby.png) left top no-repeat} UL.jqueryFileTree LI.ext_rpm{background:url(../images/linux.png) left top no-repeat} UL.jqueryFileTree LI.ext_ruby{background:url(../images/ruby.png) left top no-repeat} UL.jqueryFileTree LI.ext_sql{background:url(../images/db.png) left top no-repeat} UL.jqueryFileTree LI.ext_swf{background:url(../images/flash.png) left top no-repeat} UL.jqueryFileTree LI.ext_tif,UL.jqueryFileTree LI.ext_tiff{background:url(../images/picture.png) left top no-repeat} UL.jqueryFileTree LI.ext_txt{background:url(../images/txt.png) left top no-repeat} UL.jqueryFileTree LI.ext_vb{background:url(../images/code.png) left top no-repeat} UL.jqueryFileTree LI.ext_wav{background:url(../images/music.png) left top no-repeat} UL.jqueryFileTree LI.ext_webm,UL.jqueryFileTree LI.ext_wmv{background:url(../images/film.png) left top no-repeat} UL.jqueryFileTree LI.ext_xls{background:url(../images/xls.png) left top no-repeat} UL.jqueryFileTree LI.ext_xml{background:url(../images/code.png) left top no-repeat} UL.jqueryFileTree LI.ext_zip{background:url(../images/zip.png) left top no-repeat} UL.jqueryFileTree A{color:#333;text-decoration:none;display:inline-block;padding:0 2px;cursor:pointer} UL.jqueryFileTree A:hover{background:#BDF}
assets/css/wp-smushit-admin.css CHANGED
@@ -91,7 +91,8 @@ Smush button transformation
91
  padding-bottom: 0;
92
  }
93
 
94
- .wp-smush-pro.smush-settings-wrapper {
 
95
  width: 100%;
96
  }
97
 
@@ -102,6 +103,7 @@ Smush button transformation
102
  }
103
 
104
  .wpmud .wp-smush-submit-wrap {
 
105
  padding-top: 0;
106
  }
107
 
@@ -315,7 +317,8 @@ input#wp-smush-save-settings {
315
  font-size: 12px;
316
  }
317
 
318
- .smush-total-savings.smush-total-reduction-percent {
 
319
  text-align: center;
320
  }
321
 
@@ -531,6 +534,7 @@ table.wp-smush-stats-holder tr td:first-child {
531
  .wp-smush-auto-message {
532
  float: right;
533
  font-size: 15px;
 
534
  line-height: 1.7;
535
  margin: 1.2em auto;
536
  }
@@ -613,8 +617,19 @@ table.wp-smush-stats-holder tr td:first-child {
613
  min-height: 149px;
614
  }
615
 
616
- .wpmud .dev-box .box-title h3 {
 
 
 
 
 
 
 
 
 
 
617
  display: inline-block;
 
618
  }
619
 
620
  .smush-container-subheading {
@@ -647,10 +662,15 @@ table.wp-smush-stats-holder tr td:first-child {
647
  }
648
 
649
  .smush-stats-wrapper .smush-container-subheading {
650
- margin: 1em 0;
651
  max-width: 90%;
652
  }
653
 
 
 
 
 
 
654
  .wpmud .row .col-half.wp-smushit-container-left {
655
  padding-left: 0;
656
  }
@@ -731,18 +751,20 @@ table.wp-smush-stats-holder tr td:first-child {
731
 
732
  .wp-smush-bulk-active .spinner {
733
  float: left;
734
- margin-top: 0;
735
  }
736
 
737
  /** All Smushed **/
738
  .wp-smush-notice {
739
- background-color: #1abc9c;
740
  border-radius: 5px;
741
- color: white;
742
  font-family: 'Roboto', sans-serif;
743
  font-size: 15px;
744
- margin-bottom: 20px;
745
- padding: 20px 40px;
 
 
746
  }
747
 
748
  .wp-smush-resmush-message,
@@ -756,14 +778,21 @@ table.wp-smush-stats-holder tr td:first-child {
756
 
757
  .wpmud a.wp-smush-trigger-bulk, .wpmud a.wp-smush-trigger-bulk:hover,
758
  .wpmud a.wp-smush-trigger-bulk:focus, .wpmud a.wp-smush-trigger-bulk:active {
759
- color: white;
760
  text-decoration: underline;
761
  }
762
 
763
  .wp-smush-resmush-message .dev-icon,
764
  .wp-smush-settings-updated .dev-icon,
765
  .wp-smush-re-check-message .dev-icon {
766
- font-size: 16px;
 
 
 
 
 
 
 
767
  }
768
 
769
  .wp-smush-resmush-message .dev-icon-cross,
@@ -771,26 +800,47 @@ table.wp-smush-stats-holder tr td:first-child {
771
  .wp-smush-re-check-message .dev-icon-cross {
772
  cursor: pointer;
773
  float: right;
774
- }
775
-
776
- .wp-smush-notice .dev-icon-tick:before {
777
- line-height: 1.1;
778
- vertical-align: bottom;
779
  }
780
 
781
  .wp-smush-all-done .dev-icon-tick {
782
  display: inline-block;
783
- font-size: 16px;
784
  margin-right: 10px;
785
- vertical-align: bottom;
 
786
  }
787
 
788
  /** Image Remaining **/
789
- .wp-smush-remaining, #wp-smush-invalid-member {
790
- background-color: #fee696;
 
 
 
791
  border: none;
792
- color: #514a30;
793
- line-height: 1.7;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
794
  }
795
 
796
  .wp-smush-resmush-wrap .wp-smush-remaining {
@@ -799,12 +849,13 @@ table.wp-smush-stats-holder tr td:first-child {
799
 
800
  .wp-smush-remaining .dev-icon img {
801
  position: relative;
802
- top: 6px;
803
  width: 14px;
804
  }
805
 
806
- .wpmud .bulk-smush-wrapper .dev-icon {
807
  margin-right: 10px;
 
808
  vertical-align: top;
809
  }
810
 
@@ -817,14 +868,16 @@ table.wp-smush-stats-holder tr td:first-child {
817
  max-width: 88%;
818
  }
819
 
820
- .bulk-smush-wrapper .wp-smush-all {
821
- margin: 20px 0 0;
822
  }
823
 
824
- .bulk-smush-wrapper .wp-smush-remaining .wp-smush-skip-resmush {
825
- display: block;
826
- margin-left: 27px;
827
- margin-top: 10px;
 
 
828
  }
829
 
830
  .wp-smush-pro-trial {
@@ -935,16 +988,20 @@ table.wp-smush-stats-holder tr td:first-child {
935
  }
936
 
937
  small.smush-setting-description {
938
- margin-top: 10px;
939
  display: block;
 
 
 
940
  }
941
 
942
  /** Stats Container **/
943
- .wpmud .smush-stats-wrapper {
944
- color: #555;
945
- font-size: 15px;
946
  font-family: 'Roboto Condensed', sans-serif;
947
  font-weight: 700;
 
948
  }
949
 
950
  .wpmud .smush-stats-wrapper strong {
@@ -961,8 +1018,8 @@ small.smush-setting-description {
961
 
962
  .wpmud .wp-smush-stats .button-small.wp-smush-lossy-enable, .wpmud .wp-smush-stats .button-small.wp-smush-resize-enable {
963
  border-radius: 3px;
964
- font: 500 11px/20px 'Roboto';
965
- padding: 5px 8px;
966
  vertical-align: top;
967
  }
968
 
@@ -978,7 +1035,7 @@ small.smush-setting-description {
978
  .wpmud .wp-smush-stats, .wp-smush-stats-wrap {
979
  color: #555555;
980
  font-family: 'Roboto Condensed', sans-serif;
981
- font-size: 25px;
982
  font-weight: 400;
983
  line-height: 1;
984
  padding: 5px 0;
@@ -1087,9 +1144,17 @@ small.smush-setting-description {
1087
  margin-top: 30px;
1088
  }
1089
 
 
 
 
 
 
 
 
 
1090
  .wpmud .wp-smush-hb-cta .button.button-cta {
1091
- background-color: #ffe900;
1092
- box-shadow: inset 0 -3px 0 0 #f0db00;
1093
  color: #4e4b10;
1094
  width: 100%;
1095
  }
@@ -1098,7 +1163,8 @@ small.smush-setting-description {
1098
  .wpmud .box-content .wp-smush-hb-cta .button.button-cta.button-yellow:active,
1099
  .wpmud .box-content .wp-smush-hb-cta .button.button-cta.button-yellow:focus {
1100
  box-shadow: none;
1101
- color: #4e4b10;
 
1102
  }
1103
 
1104
  /** Re Smush **/
@@ -1418,6 +1484,7 @@ small.smush-setting-description {
1418
  color: #767676;
1419
  font-size: 15px;
1420
  font-weight: 400;
 
1421
  line-height: 1.5;
1422
  margin-left: 158px;
1423
  }
@@ -1426,10 +1493,18 @@ small.smush-setting-description {
1426
  background: #1da1f2;
1427
  }
1428
 
 
 
 
 
1429
  #wp-smush-facebook-share {
1430
  background: #3b5998;
1431
  }
1432
 
 
 
 
 
1433
  #wp-smush-whatsapp-share {
1434
  background-color: #00ba00;
1435
  background-image: url(../images/whatsapp-button-16px.png);
@@ -1465,7 +1540,571 @@ small.smush-setting-description {
1465
  display: none;
1466
  }
1467
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1468
  /** Media Queries **/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1469
  @media screen and (max-width: 1024px) and ( min-width: 800px ) {
1470
  .wpmud .wrap .dev-box:not(.wp-smush-pro-adv) {
1471
  padding: 20px;
@@ -1552,6 +2191,12 @@ small.smush-setting-description {
1552
  }
1553
  }
1554
 
 
 
 
 
 
 
1555
  /** Media Queries for resolution below 782px **/
1556
  @media only screen and (max-width: 800px) {
1557
  .wpmud .wp-smushit-container-wrap .col-half.wp-smushit-container-left, .wpmud .wp-smushit-container-wrap .col-half.wp-smushit-container-right {
@@ -1572,12 +2217,25 @@ small.smush-setting-description {
1572
  }
1573
  }
1574
 
 
 
 
 
 
 
1575
  @media screen and (max-width: 750px) {
1576
  .wpmud .dev-box#wp-smush-share-widget {
1577
  background-position: 30px 45px;
1578
  }
1579
  }
1580
 
 
 
 
 
 
 
 
1581
  @media screen and (max-width: 650px) {
1582
  .wpmud .dev-box#wp-smush-share-widget {
1583
  background-image: none;
@@ -1604,13 +2262,39 @@ small.smush-setting-description {
1604
  display: inline-block;
1605
  }
1606
  }
 
1607
  @media screen and (max-width: 600px) {
1608
  .wpmud .wp-smush-welcome.wp-smush-container {
1609
  background-position: 43% bottom;
1610
  padding-bottom: 148px;
1611
  }
 
1612
  .wpmud .wp-smush-welcome-content {
1613
  margin: 0 30px 0px 0;
1614
  max-width: 100%;
1615
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1616
  }
91
  padding-bottom: 0;
92
  }
93
 
94
+ .wpmud .wp-smush-pro.smush-settings-wrapper {
95
+ padding-bottom: 24px;
96
  width: 100%;
97
  }
98
 
103
  }
104
 
105
  .wpmud .wp-smush-submit-wrap {
106
+ margin-top: 17px;
107
  padding-top: 0;
108
  }
109
 
317
  font-size: 12px;
318
  }
319
 
320
+ .wpmud .smush-total-savings.smush-total-reduction-percent {
321
+ margin-bottom: 18px;
322
  text-align: center;
323
  }
324
 
534
  .wp-smush-auto-message {
535
  float: right;
536
  font-size: 15px;
537
+ letter-spacing: -0.015em;
538
  line-height: 1.7;
539
  margin: 1.2em auto;
540
  }
617
  min-height: 149px;
618
  }
619
 
620
+ .wpmud .box-container {
621
+ letter-spacing: -0.015em;
622
+ }
623
+
624
+ .wpmud .smush-page-wrap .dev-box .box-title {
625
+ height: 67px;
626
+ margin: -25px -30px 28px;
627
+ }
628
+
629
+ .wpmud .dev-box .wp-smush-container-header.box-title h3 {
630
+ color: #333333;
631
  display: inline-block;
632
+ font-size: 15px;
633
  }
634
 
635
  .smush-container-subheading {
662
  }
663
 
664
  .smush-stats-wrapper .smush-container-subheading {
665
+ margin: 1.2em 0 0.9em;
666
  max-width: 90%;
667
  }
668
 
669
+ .wpmud .smush-stats-wrapper .smush-container-subheading button.wp-smush-scan:not(.wph-button):not(#collapse-button) {
670
+ font-size: 12px;
671
+ padding: 5px 16px 5px;
672
+ }
673
+
674
  .wpmud .row .col-half.wp-smushit-container-left {
675
  padding-left: 0;
676
  }
751
 
752
  .wp-smush-bulk-active .spinner {
753
  float: left;
754
+ margin-top: 5px;
755
  }
756
 
757
  /** All Smushed **/
758
  .wp-smush-notice {
759
+ background-color: #D1F1EA;
760
  border-radius: 5px;
761
+ color: #333333;
762
  font-family: 'Roboto', sans-serif;
763
  font-size: 15px;
764
+ line-height: 30px;
765
+ margin-bottom: 30px;
766
+ padding: 15px 30px;
767
+ letter-spacing: -0.015em;
768
  }
769
 
770
  .wp-smush-resmush-message,
778
 
779
  .wpmud a.wp-smush-trigger-bulk, .wpmud a.wp-smush-trigger-bulk:hover,
780
  .wpmud a.wp-smush-trigger-bulk:focus, .wpmud a.wp-smush-trigger-bulk:active {
781
+ color: #333333;
782
  text-decoration: underline;
783
  }
784
 
785
  .wp-smush-resmush-message .dev-icon,
786
  .wp-smush-settings-updated .dev-icon,
787
  .wp-smush-re-check-message .dev-icon {
788
+ font-size: 22px;
789
+ }
790
+
791
+ .wp-smush-resmush-message .dev-icon-tick,
792
+ .wp-smush-settings-updated .dev-icon-tick {
793
+ font-size: 22px;
794
+ margin-right: 5px;
795
+ vertical-align: middle;
796
  }
797
 
798
  .wp-smush-resmush-message .dev-icon-cross,
800
  .wp-smush-re-check-message .dev-icon-cross {
801
  cursor: pointer;
802
  float: right;
803
+ font-size: 16px;
804
+ margin-top: 8px;
 
 
 
805
  }
806
 
807
  .wp-smush-all-done .dev-icon-tick {
808
  display: inline-block;
809
+ font-size: 22px;
810
  margin-right: 10px;
811
+ margin-top: -3px;
812
+ vertical-align: middle;
813
  }
814
 
815
  /** Image Remaining **/
816
+ .wp-smush-remaining,
817
+ #wp-smush-invalid-member,
818
+ .wp-smush-dir-remaining,
819
+ .wp-smush-dir-limit {
820
+ background-color: #FFF5D5;
821
  border: none;
822
+ color: #333333;
823
+ line-height: 30px;
824
+ font-size: 15px;
825
+ letter-spacing: -0.015em;
826
+ }
827
+
828
+ div.wp-smush-notice .dev-icon-tick:before,
829
+ div.wp-smush-all-done .dev-icon-tick:before,
830
+ div.wp-smush-dir-all-done .dev-icon-tick:before {
831
+ content: "\67";
832
+ color: #1ABC9C;
833
+ }
834
+
835
+ .wpmud div.wp-smush-notice.wp-smush-dir-limit a,
836
+ .wpmud div.wp-smush-notice.wp-smush-remaining a {
837
+ color: #333;
838
+ text-decoration: underline;
839
+ }
840
+
841
+ div.wp-smush-dir-remaining .wdv-icon-exclamation-sign:before,
842
+ div.wp-smush-dir-limit .wdv-icon-info-sign:before{
843
+ color: #FECF2F;
844
  }
845
 
846
  .wp-smush-resmush-wrap .wp-smush-remaining {
849
 
850
  .wp-smush-remaining .dev-icon img {
851
  position: relative;
852
+ top: 8px;
853
  width: 14px;
854
  }
855
 
856
+ .wpmud .bulk-smush-wrapper .wp-smush-remaining .dev-icon {
857
  margin-right: 10px;
858
+ line-height: 30px;
859
  vertical-align: top;
860
  }
861
 
868
  max-width: 88%;
869
  }
870
 
871
+ .wpmud .bulk-smush-wrapper .wp-smush-all {
872
+ margin: 22px 0 0 !important;
873
  }
874
 
875
+ .wpmud .bulk-smush-wrapper .wp-smush-remaining button.wp-smush-skip-resmush:not(.wph-button):not(#collapse-button) {
876
+ display: block !important;
877
+ font-size: 12px;
878
+ margin-left: 27px !important;
879
+ margin-top: 10px !important;
880
+ padding: 5px 16px;
881
  }
882
 
883
  .wp-smush-pro-trial {
988
  }
989
 
990
  small.smush-setting-description {
991
+ color: #888888;
992
  display: block;
993
+ font-size: 13px;
994
+ line-height: 22px;
995
+ margin-top: 10px;
996
  }
997
 
998
  /** Stats Container **/
999
+ .wpmud .dev-box.smush-stats-wrapper {
1000
+ color: #333333;
1001
+ font-size: 13px;
1002
  font-family: 'Roboto Condensed', sans-serif;
1003
  font-weight: 700;
1004
+ padding-bottom: 24px;
1005
  }
1006
 
1007
  .wpmud .smush-stats-wrapper strong {
1018
 
1019
  .wpmud .wp-smush-stats .button-small.wp-smush-lossy-enable, .wpmud .wp-smush-stats .button-small.wp-smush-resize-enable {
1020
  border-radius: 3px;
1021
+ font: 500 12px/20px 'Roboto' !important;
1022
+ padding: 5px 16px !important;
1023
  vertical-align: top;
1024
  }
1025
 
1035
  .wpmud .wp-smush-stats, .wp-smush-stats-wrap {
1036
  color: #555555;
1037
  font-family: 'Roboto Condensed', sans-serif;
1038
+ font-size: 20px;
1039
  font-weight: 400;
1040
  line-height: 1;
1041
  padding: 5px 0;
1144
  margin-top: 30px;
1145
  }
1146
 
1147
+ .wpmud .wp-smush-pro-cta .button.button-cta {
1148
+ box-shadow: none !important;
1149
+ }
1150
+
1151
+ .wpmud .wp-smush-pro-cta .button.button-cta:hover {
1152
+ background: #0A9BD6 !important;
1153
+ }
1154
+
1155
  .wpmud .wp-smush-hb-cta .button.button-cta {
1156
+ background-color: #FFEA00;
1157
+ box-shadow: none;
1158
  color: #4e4b10;
1159
  width: 100%;
1160
  }
1163
  .wpmud .box-content .wp-smush-hb-cta .button.button-cta.button-yellow:active,
1164
  .wpmud .box-content .wp-smush-hb-cta .button.button-cta.button-yellow:focus {
1165
  box-shadow: none;
1166
+ background: #f7e303 !important;
1167
+ color: #4e4b10 !important;
1168
  }
1169
 
1170
  /** Re Smush **/
1484
  color: #767676;
1485
  font-size: 15px;
1486
  font-weight: 400;
1487
+ letter-spacing: -0.015em;
1488
  line-height: 1.5;
1489
  margin-left: 158px;
1490
  }
1493
  background: #1da1f2;
1494
  }
1495
 
1496
+ #wp-smush-twitter-share:hover:not(:focus):not(:active):not(.wph-button):not(#collapse-button):not([tooltip]) {
1497
+ background-color: #0A9BD6;
1498
+ }
1499
+
1500
  #wp-smush-facebook-share {
1501
  background: #3b5998;
1502
  }
1503
 
1504
+ #wp-smush-facebook-share:hover:not(:focus):not(:active):not(.wph-button):not(#collapse-button):not([tooltip]) {
1505
+ background-color: #2b4886;
1506
+ }
1507
+
1508
  #wp-smush-whatsapp-share {
1509
  background-color: #00ba00;
1510
  background-image: url(../images/whatsapp-button-16px.png);
1540
  display: none;
1541
  }
1542
 
1543
+ /** Directory Browser **/
1544
+ div.wp-smush-dir-desc {
1545
+ font-size: 15px;
1546
+ font-weight: 500;
1547
+ line-height: 30px;
1548
+ padding: 10px 0 25px;
1549
+ }
1550
+
1551
+ .wp-smush-dir-browser {
1552
+ overflow: hidden;
1553
+ }
1554
+
1555
+ .wpmud .wp-smush-dir-browser input.wp-smush-dir-path {
1556
+ width: 450px;
1557
+ }
1558
+
1559
+ .wpmud .wp-smush-dir-browser input.wp-smush-dir-path,
1560
+ .wpmud .wp-smush-dir-browser button,
1561
+ .wpmud .wp-smush-dir-browser label {
1562
+ display: inline-block;
1563
+ }
1564
+
1565
+ .wp-smush-loading-wrap {
1566
+ float: left;
1567
+ margin: 0 auto;
1568
+ overflow: hidden;
1569
+ width: 150px;
1570
+ }
1571
+
1572
+ .wpmud .dev-overlay.wp-smush-list-dialog .title h3 {
1573
+ padding: 20px 0;
1574
+ }
1575
+
1576
+ .wp-smush-list-dialog .box-scroll {
1577
+ margin-top: 80px;
1578
+ }
1579
+
1580
+ .wpmud .dev-overlay.wp-smush-list-dialog .box {
1581
+ margin-left: -300px;
1582
+ padding: 35px 35px 30px;
1583
+ width: 600px;
1584
+ }
1585
+
1586
+ .wp-smush-select-dir {
1587
+ float: right;
1588
+ margin-top: 20px;
1589
+ width: 154px;
1590
+ }
1591
+
1592
+ .wp-smush-list-dialog .spinner {
1593
+ float: left;
1594
+ }
1595
+
1596
+ .wpmud .dev-overlay.wp-smush-list-dialog .box .title {
1597
+ margin-bottom: 20px;
1598
+ }
1599
+
1600
+ .dev-overlay.wp-smush-list-dialog .wp-smush-instruct {
1601
+ color: #888888;
1602
+ font-size: 14px;
1603
+ font-weight: 500;
1604
+ padding-bottom: 20px;
1605
+ padding-top: 8px;
1606
+ }
1607
+
1608
+ .wpmud UL.jqueryFileTree a, .wpmud UL.jqueryFileTree a:hover {
1609
+ background: #f8f8f8;
1610
+ color: #888888;
1611
+ font-family: "Roboto", sans-serif;
1612
+ font-size: 14px;
1613
+ font-weight: 500;
1614
+ }
1615
+
1616
+ .jqueryFileTree .wp-smush-list {
1617
+ margin-top: 2px;
1618
+ vertical-align: top;
1619
+ }
1620
+
1621
+ .jqueryFileTree li {
1622
+ display: inline-block;
1623
+ }
1624
+
1625
+ .wpmud UL.jqueryFileTree LI {
1626
+ padding: 0 0 5px 20px;
1627
+ }
1628
+
1629
+ .wpmud UL.jqueryFileTree LI.ext_tif,
1630
+ .wpmud UL.jqueryFileTree LI.ext_tiff,
1631
+ .wpmud UL.jqueryFileTree LI.ext_png,
1632
+ .wpmud UL.jqueryFileTree LI.ext_pcx,
1633
+ .wpmud UL.jqueryFileTree LI.ext_jpeg,
1634
+ .wpmud UL.jqueryFileTree LI.ext_jpg,
1635
+ .wpmud UL.jqueryFileTree LI.ext_gif,
1636
+ .wpmud UL.jqueryFileTree LI.ext_bmp {
1637
+ background: url(../images/image.svg) left top no-repeat
1638
+ }
1639
+
1640
+ .wpmud UL.jqueryFileTree LI.directory {
1641
+ background: url(../images/folder-closed.svg) left top no-repeat;
1642
+ }
1643
+
1644
+ .wpmud UL.jqueryFileTree LI.expanded {
1645
+ background: url(../images/folder-open.svg) left top no-repeat;
1646
+ }
1647
+
1648
+ .wpmud UL.jqueryFileTree LI.expanded.selected {
1649
+ background: url(../images/folder-open-selected.svg) left top no-repeat;
1650
+ }
1651
+
1652
+ .wpmud UL.jqueryFileTree LI.expanded.selected > a {
1653
+ color: #17a8e3;
1654
+ }
1655
+
1656
+ .wpmud UL.jqueryFileTree LI.expanded.selected #Folder-22px-Solid-3-Open {
1657
+ fill: #17a8e3;
1658
+ }
1659
+
1660
+ .wpmud UL.jqueryFileTree LI.selected > a {
1661
+ font-weight: 500;
1662
+ }
1663
+
1664
+ li.directory.selected.expanded ul.jqueryFileTree {
1665
+ margin-top: 10px;
1666
+ }
1667
+
1668
+ /** Image List **/
1669
+ .wpmud .wp-smush-div-heading {
1670
+ display: inline-block;
1671
+ overflow: hidden;
1672
+ }
1673
+
1674
+ /** Smush Button Wrapper **/
1675
+ .wp-smush-all-button-wrap {
1676
+ display: inline-block;
1677
+ float: right;
1678
+ overflow: hidden;
1679
+ }
1680
+
1681
+ .wp-smush-all-button-wrap.top {
1682
+ display: inline-block;
1683
+ margin-bottom: 20px;
1684
+ }
1685
+
1686
+ div.wp-smush-all-button-wrap.bottom {
1687
+ margin-top: 14px;
1688
+ }
1689
+
1690
+ .wp-smush-all-button-wrap .spinner {
1691
+ margin-top: 12px;
1692
+ }
1693
+
1694
+ .wp-smush-start {
1695
+ float: right;
1696
+ vertical-align: top;
1697
+ }
1698
+
1699
+ .wpmud button.wp-smush-pause {
1700
+ cursor: pointer;
1701
+ float: right;
1702
+ }
1703
+
1704
+ .wpmud button.wp-smush-start:disabled:not(.finished),
1705
+ .wpmud button.wp-smush-pause.disabled {
1706
+ display: none !important;
1707
+ }
1708
+
1709
+ .wpmud button.wp-smush-start.finished {
1710
+ background: #1abc9c !important;
1711
+ opacity: 1;
1712
+ }
1713
+
1714
+ .wp-smush-image-list {
1715
+ line-height: 1.5;
1716
+ }
1717
+
1718
+ .wp-smush-image-ul {
1719
+ margin: 5px 0;
1720
+ }
1721
+
1722
+ .wp-smush-image-list-inner {
1723
+ display: none;
1724
+ max-height: 0;
1725
+ opacity: 0;
1726
+ overflow-y: scroll;
1727
+ padding: 15px 20px 0;
1728
+ transition: 0.6s ease-in-out;
1729
+ }
1730
+
1731
+ .wp-smush-image-list-inner.show {
1732
+ display: block;
1733
+ opacity: 1;
1734
+ max-height: 500px;
1735
+ }
1736
+
1737
+ span.wp-smush-li-path {
1738
+ cursor: pointer;
1739
+ font-weight: 500;
1740
+ position: relative;
1741
+ }
1742
+
1743
+ li.wp-smush-image-ul span.wp-smush-li-path {
1744
+ background: url("../images/folder-closed.svg") no-repeat;
1745
+ background-position-y: 3px;
1746
+ line-height: 1.5;
1747
+ padding: 4px 30px 3px;
1748
+
1749
+ }
1750
+
1751
+ li.wp-smush-image-ul.in-progress span.wp-smush-li-path {
1752
+ background: none;
1753
+ padding: 0;
1754
+ }
1755
+
1756
+ li.wp-smush-image-ul.complete span.wp-smush-li-path,
1757
+ li.wp-smush-image-ul.partial span.wp-smush-li-path {
1758
+ background: none;
1759
+ }
1760
+
1761
+ /** Show loader **/
1762
+ li.wp-smush-image-ul.in-progress span.spinner,
1763
+ li.wp-smush-image-ul li.wp-smush-image-ele.in-progress span.spinner {
1764
+ float: left;
1765
+ margin-top: 0px;
1766
+ margin-left: 0;
1767
+ display: inline-block;
1768
+ margin-right: 11px;
1769
+ }
1770
+
1771
+ li.wp-smush-image-ul.complete span.wp-smush-li-path:before,
1772
+ li.wp-smush-image-ul.partial span.wp-smush-li-path:before {
1773
+ box-shadow: none;
1774
+ color: #1ABC9C;
1775
+ content: '\67';
1776
+ font-family: 'WPMU-DEV-App-Icons';
1777
+ font-size: 20px;
1778
+ font-style: normal;
1779
+ font-variant: normal;
1780
+ font-weight: normal;
1781
+ height: 22px;
1782
+ left: 0;
1783
+ line-height: 22px;
1784
+ margin-top: -8px;
1785
+ opacity: 1;
1786
+ position: absolute;
1787
+ speak: none;
1788
+ transition-duration: 0.2s;
1789
+ transition-property: color, opacity;
1790
+ text-transform: none;
1791
+ top: 50%;
1792
+ vertical-align: middle;
1793
+ width: 22px;
1794
+ -webkit-font-smoothing: antialiased;
1795
+ -moz-osx-font-smoothing: grayscale;
1796
+ }
1797
+
1798
+ li.wp-smush-image-ul.partial span.wp-smush-li-path:before {
1799
+ color: #ffd000;
1800
+ content: '\f06a';
1801
+ font-family: 'FontAwesomeWdv';
1802
+ font-size: 22px;
1803
+ margin-left: 1px;
1804
+ }
1805
+
1806
+ .wp-smush-image-count {
1807
+ background: #f2f2f2;
1808
+ border-radius: 20px;
1809
+ margin-left: 10px;
1810
+ padding: 5px 10px;
1811
+ vertical-align: middle;
1812
+ }
1813
+
1814
+ div.wp-smush-dir-stats-wrap, div.wp-smush-scan-result {
1815
+ background: white;
1816
+ }
1817
+
1818
+ div.wp-smush-scan-result div.wp-smush-notice {
1819
+ margin-top: 14px;
1820
+ padding: 15px 30px;
1821
+
1822
+ }
1823
+
1824
+ div.wp-smush-scan-result div.wp-smush-notice .wdv-icon,
1825
+ div.wp-smush-scan-result div.wp-smush-notice .dev-icon {
1826
+ display: inline-block;
1827
+ font-size: 22px;
1828
+ margin-right: 15px;
1829
+ margin-top: -3px;
1830
+ vertical-align: middle;
1831
+ }
1832
+
1833
+ div.wp-smush-scan-result hr.primary-separator {
1834
+ margin: 10px 0 28px;
1835
+ }
1836
+
1837
+ div.wp-smush-scan-result hr {
1838
+ margin: 20px 0;
1839
+ }
1840
+
1841
+ div.wp-smush-scan-result div.content {
1842
+ overflow: hidden;
1843
+ width: 100%;
1844
+ }
1845
+
1846
+ .wpmud a.wp-smush-exclude-dir {
1847
+ color: #878787;
1848
+ cursor: pointer;
1849
+ display: inline-block;
1850
+ float: right;
1851
+ font-size: 15px;
1852
+ font-weight: 700;
1853
+ margin-right: 16px;
1854
+ padding: 0 10px;
1855
+ }
1856
+
1857
+ .wpmud a.wp-smush-exclude-dir:hover {
1858
+ color: #878787;
1859
+ }
1860
+
1861
+ div.dir-smush-button-wrap {
1862
+ margin-top: 14px;
1863
+ overflow: hidden;
1864
+ }
1865
+
1866
+ div.dir-smush-button-wrap.top {
1867
+ height: 40px;
1868
+ margin-top: 0;
1869
+ margin-bottom: 30px;
1870
+ }
1871
+
1872
+ div.dir-smush-button-wrap button, div.dir-smush-button-wrap span {
1873
+ float: left;
1874
+ }
1875
+
1876
+ div.dir-smush-button-wrap span {
1877
+ margin-top: 10px;
1878
+ }
1879
+
1880
+ .wpmud button.wp-smush-browse {
1881
+ background-color: #9E9E9E !important;
1882
+ }
1883
+
1884
+ .wp-smush-loading-text {
1885
+ font-size: 20px;
1886
+ line-height: 1.3;
1887
+ visibility: visible;
1888
+ }
1889
+
1890
+ .wp-smush-select-button-wrap {
1891
+ padding: 20px;
1892
+ background: #f9f9f9;
1893
+ border-radius: 5px;
1894
+ margin-top: 25px;
1895
+ overflow: hidden;
1896
+ }
1897
+
1898
+ .wp-smush-select-button-wrap .wp-smush-section-desc {
1899
+ color: #888;
1900
+ display: inline-block;
1901
+ float: left;
1902
+ line-height: 22px;
1903
+ max-width: 59%;
1904
+ }
1905
+
1906
+ .wp-smush-select-button-wrap .spinner {
1907
+ margin-top: 12px;
1908
+ }
1909
+
1910
+ .wp-smush-image-ele {
1911
+ margin: 15px 0;
1912
+ }
1913
+
1914
+ li.wp-smush-image-ele span.wp-smush-image-path {
1915
+ padding: 4px 0 3px;
1916
+ }
1917
+
1918
+ .wp-smush-image-ele:last-child {
1919
+ margin: 15px 0 0;
1920
+ }
1921
+
1922
+ .wp-smush-image-ele .spinner {
1923
+ float: left;
1924
+ margin-left: 0;
1925
+ margin-top: 1px;
1926
+ }
1927
+
1928
+ .wp-smush-image-ul .wp-smush-image-ele .spinner {
1929
+ margin-left: 18px;
1930
+ position: relative;
1931
+ }
1932
+
1933
+ .wp-smush-image-ele-status {
1934
+ color: #C6C6C6;
1935
+ display: inline-block;
1936
+ height: 22px;
1937
+ line-height: 1;
1938
+ margin-right: 10px;
1939
+ overflow: hidden;
1940
+ position: relative;
1941
+ width: 22px;
1942
+ vertical-align: middle;
1943
+ }
1944
+
1945
+ .wp-smush-image-ele-status:after {
1946
+ box-shadow: none;
1947
+ content: url("../images/image.svg");
1948
+ font-family: 'WPMU-DEV-App-Icons';
1949
+ font-size: 20px;
1950
+ font-style: normal;
1951
+ font-variant: normal;
1952
+ font-weight: normal;
1953
+ height: 22px;
1954
+ line-height: 22px;
1955
+ margin-top: -12px;
1956
+ opacity: 1;
1957
+ position: absolute;
1958
+ speak: none;
1959
+ transition-duration: 0.2s;
1960
+ transition-property: color, opacity;
1961
+ text-transform: none;
1962
+ top: 50%;
1963
+ vertical-align: middle;
1964
+ width: 22px;
1965
+ -webkit-font-smoothing: antialiased;
1966
+ -moz-osx-font-smoothing: grayscale;
1967
+ }
1968
+
1969
+ li.wp-smush-image-ele.in-progress .wp-smush-image-ele-status {
1970
+ display: none;
1971
+ }
1972
+
1973
+ /** Optimised Image **/
1974
+ li.wp-smush-image-ele.optimised .wp-smush-image-ele-status:after {
1975
+ content: '\67';
1976
+ color: #1ABC9C;
1977
+ }
1978
+
1979
+ li.wp-smush-image-ele.error .wp-smush-image-ele-status:after {
1980
+ color: #ffd000;
1981
+ content: '\f06a';
1982
+ font-family: 'FontAwesomeWdv';
1983
+ }
1984
+
1985
+ div.wp-smush-dir-notice {
1986
+ padding: 15px 20px;
1987
+ background: #fff5d5;
1988
+ border-radius: 5px;
1989
+ margin-top: 20px;
1990
+ font-size: 14px;
1991
+ font-weight: 500;
1992
+ }
1993
+
1994
+ div.wp-smush-dir-notice .wdv-icon-exclamation-sign {
1995
+ margin-right: 10px;
1996
+ vertical-align: middle;
1997
+ }
1998
+
1999
+ div.wp-smush-dir-notice .wdv-icon-exclamation-sign:before {
2000
+ color: #ffd000;
2001
+ content: '\f06a';
2002
+ font-family: 'FontAwesomeWdv';
2003
+ font-size: 22px;
2004
+ margin-left: 1px;
2005
+ margin-top: 4px;
2006
+ vertical-align: middle;
2007
+ }
2008
+
2009
+ div.wp-smush-dir-progress-wrap {
2010
+ display: inline-block;
2011
+ float: right;
2012
+ font-weight: 600;
2013
+ padding-top: 4px;
2014
+ width: 145px;
2015
+ }
2016
+
2017
+ div.wp-smush-dir-progress-wrap.hidden {
2018
+ display: none;
2019
+ }
2020
+
2021
+ span.smush-percent {
2022
+ display: inline-block;
2023
+ text-align: right;
2024
+ width: 34px;
2025
+ }
2026
+
2027
+ div.wp-smush-dir-progress-wrap-inner {
2028
+ background: #e6e6e6;
2029
+ -moz-border-radius: 10px;
2030
+ -webkit-border-radius: 10px;
2031
+ border-radius: 10px;
2032
+ display: inline-block;
2033
+ height: 10px;
2034
+ margin-left: 10px;
2035
+ position: relative;
2036
+ width: 100px;
2037
+ }
2038
+
2039
+ .wp-smush-dir-progress {
2040
+ background: #ffd000;
2041
+ -webkit-border-radius: 20px;
2042
+ -moz-border-radius: 20px;
2043
+ border-radius: 20px;
2044
+ display: block;
2045
+ height: 100%;
2046
+ position: relative;
2047
+ overflow: hidden;
2048
+ transition: 0.4s linear;
2049
+ transition-property: width, background-color;
2050
+ }
2051
+
2052
+ .wp-smush-dir-progress.complete {
2053
+ background: #1abc9c;
2054
+ }
2055
+
2056
+ .wp-smush-dir-progress.complete ~ a.wp-smush-exclude-dir {
2057
+ display: none;
2058
+ }
2059
+
2060
+ div.wp-smush-info.notice {
2061
+ font-size: 15px;
2062
+ letter-spacing: -0.015em;
2063
+ margin: 0 0 30px;
2064
+ padding: 15px;
2065
+ }
2066
+
2067
+ .wpmud div.smush-page-wrap button:not(.wph-button):not(#collapse-button),
2068
+ .wpmud div.smush-page-wrap .button {
2069
+ background-color: #17A8E3;
2070
+ }
2071
+
2072
+ .wpmud div.smush-page-wrap button:hover:not(:focus):not(:active):not(.wph-button):not(#collapse-button):not([tooltip]),
2073
+ .wpmud .div.smush-page-wrap button:hover:not(:focus):not(:active):not(.wph-button):not(#collapse-button):not([tooltip]),
2074
+ .wpmud .smush-page-wrap .wp-smush-submit-wrap .button.button-grey:hover:not(:focus):not(:active):not(.wph-button):not(#collapse-button):not([tooltip]) {
2075
+ background: #0A9BD6;
2076
+ }
2077
+
2078
+ .wpmud .smush-page-wrap .button.button-grey {
2079
+ background: #AEAEAE;
2080
+ }
2081
+
2082
  /** Media Queries **/
2083
+ @media screen and (max-width: 1100px) {
2084
+ li.wp-smush-image-ul span.wp-smush-li-path {
2085
+ max-width: 75%;
2086
+ display: inline-block;
2087
+ padding-right: 0;
2088
+ }
2089
+
2090
+ span.wp-smush-image-count {
2091
+ display: inline-block;
2092
+ margin-left: 0;
2093
+ overflow: hidden;
2094
+ text-align: center;
2095
+ }
2096
+
2097
+ li.wp-smush-image-ul.complete span.wp-smush-li-path:before,
2098
+ li.wp-smush-image-ul.partial span.wp-smush-li-path:before {
2099
+ margin-top: 0;
2100
+ top: 4px;
2101
+ }
2102
+
2103
+ li.wp-smush-image-ul.partial span.wp-smush-li-path:before {
2104
+ margin-top: 2px;
2105
+ }
2106
+ }
2107
+
2108
  @media screen and (max-width: 1024px) and ( min-width: 800px ) {
2109
  .wpmud .wrap .dev-box:not(.wp-smush-pro-adv) {
2110
  padding: 20px;
2191
  }
2192
  }
2193
 
2194
+ @media only screen and (max-width: 960px) {
2195
+ .wpmud .dev-overlay.wp-smush-list-dialog {
2196
+ left: 35px;
2197
+ }
2198
+ }
2199
+
2200
  /** Media Queries for resolution below 782px **/
2201
  @media only screen and (max-width: 800px) {
2202
  .wpmud .wp-smushit-container-wrap .col-half.wp-smushit-container-left, .wpmud .wp-smushit-container-wrap .col-half.wp-smushit-container-right {
2217
  }
2218
  }
2219
 
2220
+ @media only screen and (max-width: 782px) {
2221
+ .wpmud .dev-overlay.wp-smush-list-dialog {
2222
+ left: 0;
2223
+ }
2224
+ }
2225
+
2226
  @media screen and (max-width: 750px) {
2227
  .wpmud .dev-box#wp-smush-share-widget {
2228
  background-position: 30px 45px;
2229
  }
2230
  }
2231
 
2232
+ /** For directory smush image listing **/
2233
+ @media screen and (max-width: 672px) {
2234
+ li.wp-smush-image-ul span.wp-smush-li-path {
2235
+ max-width: 65%;
2236
+ }
2237
+ }
2238
+
2239
  @media screen and (max-width: 650px) {
2240
  .wpmud .dev-box#wp-smush-share-widget {
2241
  background-image: none;
2262
  display: inline-block;
2263
  }
2264
  }
2265
+
2266
  @media screen and (max-width: 600px) {
2267
  .wpmud .wp-smush-welcome.wp-smush-container {
2268
  background-position: 43% bottom;
2269
  padding-bottom: 148px;
2270
  }
2271
+
2272
  .wpmud .wp-smush-welcome-content {
2273
  margin: 0 30px 0px 0;
2274
  max-width: 100%;
2275
  }
2276
+
2277
+ .wpmud .dev-overlay.wp-smush-list-dialog {
2278
+ top: 0;
2279
+ }
2280
+
2281
+ .wpmud .dev-overlay.wp-smush-list-dialog .box {
2282
+ margin-left: -40%;
2283
+ width: 80%;
2284
+ }
2285
+
2286
+ .wp-smush-select-button-wrap .wp-smush-section-desc {
2287
+ width: 100%;
2288
+ max-width: none;
2289
+ }
2290
+
2291
+ div.wp-smush-select-button-wrap-child {
2292
+ overflow: hidden;
2293
+ float: left;
2294
+ margin-top: 14px;
2295
+ }
2296
+
2297
+ div.wp-smush-select-button-wrap-child span.spinner {
2298
+ float: right;
2299
+ }
2300
  }
assets/images/application.png ADDED
Binary file
assets/images/bulk-smush.png DELETED
Binary file
assets/images/code.png ADDED
Binary file
assets/images/css.png ADDED
Binary file
assets/images/db.png ADDED
Binary file
assets/images/directory-lock.png ADDED
Binary file
assets/images/directory.png ADDED
Binary file
assets/images/doc.png ADDED
Binary file
assets/images/file-lock.png ADDED
Binary file
assets/images/file.png ADDED
Binary file
assets/images/film.png ADDED
Binary file
assets/images/flash.png ADDED
Binary file
assets/images/folder-closed.svg ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="18px" height="15px" viewBox="0 0 18 15" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <!-- Generator: Sketch 41.2 (35397) - http://www.bohemiancoding.com/sketch -->
4
+ <title>folder-closed</title>
5
+ <desc>Created with Sketch.</desc>
6
+ <defs></defs>
7
+ <g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
8
+ <g id="Folder-22px-Solid-3-Closed" fill="#888888">
9
+ <path d="M0,1 C0,0.44771525 0.45303631,0 0.99703014,0 L7.00296986,0 C7.5536144,0 8,0.44386482 8,1 L8,2 L0,2 L0,1 Z M0,3 L18,3 L18,15 L0,15 L0,3 Z" id="folder-closed"></path>
10
+ </g>
11
+ </g>
12
+ </svg>
assets/images/folder-open-selected.svg ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="18px" height="15px" viewBox="0 0 18 15" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <!-- Generator: Sketch 41.2 (35397) - http://www.bohemiancoding.com/sketch -->
4
+ <title>folder-open</title>
5
+ <desc>Created with Sketch.</desc>
6
+ <defs></defs>
7
+ <g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
8
+ <g id="Folder-22px-Solid-3-Open" fill="#17a8e3">
9
+ <path d="M2.00010759,5 L17.9871925,5 L16.1942557,14.0229504 C16.0870306,14.56256 15.5496251,15 14.9982973,15 L0.791347791,15 C0.238063241,15 -0.104466299,14.5709592 0.0287507007,14.0317368 L0.246548481,13.1501568 L2.00010759,5 Z M0.000107590658,0.99396592 C0.000107590658,0.4450137 0.453143901,0 0.997137731,0 L7.00307745,0 C7.55372199,0 8.00010759,0.44386482 8.00010759,1 L8.00010759,2 L16.5001076,2 L16.5001076,4 L1.50010759,4 L0.000107590658,10.5 L0.000107590658,2.44374814 L0.000107590658,0.99396592 Z" id="folder-open"></path>
10
+ </g>
11
+ </g>
12
+ </svg>
assets/images/folder-open.svg ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="18px" height="15px" viewBox="0 0 18 15" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <!-- Generator: Sketch 41.2 (35397) - http://www.bohemiancoding.com/sketch -->
4
+ <title>folder-open</title>
5
+ <desc>Created with Sketch.</desc>
6
+ <defs></defs>
7
+ <g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
8
+ <g id="Folder-22px-Solid-3-Open" fill="#888888">
9
+ <path d="M2.00010759,5 L17.9871925,5 L16.1942557,14.0229504 C16.0870306,14.56256 15.5496251,15 14.9982973,15 L0.791347791,15 C0.238063241,15 -0.104466299,14.5709592 0.0287507007,14.0317368 L0.246548481,13.1501568 L2.00010759,5 Z M0.000107590658,0.99396592 C0.000107590658,0.4450137 0.453143901,0 0.997137731,0 L7.00307745,0 C7.55372199,0 8.00010759,0.44386482 8.00010759,1 L8.00010759,2 L16.5001076,2 L16.5001076,4 L1.50010759,4 L0.000107590658,10.5 L0.000107590658,2.44374814 L0.000107590658,0.99396592 Z" id="folder-open"></path>
10
+ </g>
11
+ </g>
12
+ </svg>
assets/images/folder_open.png ADDED
Binary file
assets/images/html.png ADDED
Binary file
assets/images/image.svg ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="18px" height="14px" viewBox="0 0 18 14" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <!-- Generator: Sketch 41.2 (35397) - http://www.bohemiancoding.com/sketch -->
4
+ <title>image</title>
5
+ <desc>Created with Sketch.</desc>
6
+ <defs></defs>
7
+ <g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
8
+ <g id="Image-22px-Solid" fill="#888888">
9
+ <path d="M9.25,12 L15.5176792,12 C15.7911357,12 16,11.7782068 16,11.504611 L16,9 L11,4 L6.97222222,9.23611111 L4.5,8 L2,10.5 L2,11.4921684 C2,11.7786698 2.22673949,12 2.50643682,12 L9.25,12 Z M0,2.00585866 C0,0.898053512 0.892622799,0 1.99508929,0 L16.0049107,0 C17.1067681,0 18,0.897060126 18,2.00585866 L18,11.9941413 C18,13.1019465 17.1073772,14 16.0049107,14 L1.99508929,14 C0.893231902,14 0,13.1029399 0,11.9941413 L0,2.00585866 Z M4.5,7 C5.88071187,7 7,5.88071187 7,4.5 C7,3.11928813 5.88071187,2 4.5,2 C3.11928813,2 2,3.11928813 2,4.5 C2,5.88071187 3.11928813,7 4.5,7 Z" id="image"></path>
10
+ </g>
11
+ </g>
12
+ </svg>
assets/images/install-welcome.png DELETED
Binary file
assets/images/java.png ADDED
Binary file
assets/images/linux.png ADDED
Binary file
assets/images/music.png ADDED
Binary file
assets/images/pdf.png ADDED
Binary file
assets/images/php.png ADDED
Binary file
assets/images/picture.png ADDED
Binary file
assets/images/ppt.png ADDED
Binary file
assets/images/psd.png ADDED
Binary file
assets/images/ruby.png ADDED
Binary file
assets/images/script.png ADDED
Binary file
assets/images/smush-share-widget.png DELETED
Binary file
assets/images/smush-upload-images.png DELETED
Binary file
assets/images/spinner.gif ADDED
Binary file
assets/images/txt.png ADDED
Binary file
assets/images/xls.png ADDED
Binary file
assets/images/zip.png ADDED
Binary file
assets/js/jQueryFileTree.js ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*
3
+ * jQueryFileTree Plugin
4
+ *
5
+ * @author - Cory S.N. LaViska - A Beautiful Site (http://abeautifulsite.net/) - 24 March 2008
6
+ * @author - Dave Rogers - (https://github.com/daverogers/)
7
+ *
8
+ * Usage: $('.fileTreeDemo').fileTree({ options }, callback )
9
+ *
10
+ * TERMS OF USE
11
+ *
12
+ * This plugin is dual-licensed under the GNU General Public License and the MIT License and
13
+ * is copyright 2008 A Beautiful Site, LLC.
14
+ */
15
+ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
16
+
17
+ (function($, window) {
18
+ var FileTree;
19
+ FileTree = (function() {
20
+ function FileTree(el, args, callback) {
21
+ this.onEvent = bind(this.onEvent, this);
22
+ var $el, _this, defaults;
23
+ $el = $(el);
24
+ _this = this;
25
+ defaults = {
26
+ root: '/',
27
+ script: '/files/filetree',
28
+ folderEvent: 'click',
29
+ expandSpeed: 500,
30
+ collapseSpeed: 500,
31
+ expandEasing: 'swing',
32
+ collapseEasing: 'swing',
33
+ multiFolder: true,
34
+ loadMessage: 'Loading...',
35
+ errorMessage: 'Unable to get file tree information',
36
+ multiSelect: false,
37
+ onlyFolders: false,
38
+ onlyFiles: false,
39
+ preventLinkAction: false
40
+ };
41
+ this.jqft = {
42
+ container: $el
43
+ };
44
+ this.options = $.extend(defaults, args);
45
+ this.callback = callback;
46
+ this.data = {};
47
+ $el.html('<ul class="jqueryFileTree start"><li class="wait">' + this.options.loadMessage + '<li></ul>');
48
+ _this.showTree($el, escape(this.options.root), function() {
49
+ return _this._trigger('filetreeinitiated', {});
50
+ });
51
+ $el.delegate("li a", this.options.folderEvent, _this.onEvent);
52
+ }
53
+
54
+ FileTree.prototype.onEvent = function(event) {
55
+ var $ev, _this, callback, jqft, options, ref;
56
+ $ev = $(event.target);
57
+ options = this.options;
58
+ jqft = this.jqft;
59
+ _this = this;
60
+ callback = this.callback;
61
+ _this.data = {};
62
+ _this.data.li = $ev.closest('li');
63
+ _this.data.type = (ref = _this.data.li.hasClass('directory')) != null ? ref : {
64
+ 'directory': 'file'
65
+ };
66
+ _this.data.value = $ev.text();
67
+ _this.data.rel = $ev.prop('rel');
68
+ _this.data.container = jqft.container;
69
+ if (options.preventLinkAction) {
70
+ event.preventDefault();
71
+ }
72
+ if ($ev.parent().hasClass('directory')) {
73
+ //Add a selected class to directory, Thanks to shortpixel for the modification in here
74
+ _this.jqft.container.find('LI.directory').removeClass('selected');
75
+ $ev.parent().addClass('selected');
76
+
77
+ if ($ev.parent().hasClass('collapsed')) {
78
+ if (!options.multiFolder) {
79
+ $ev.parent().parent().find('UL').slideUp({
80
+ duration: options.collapseSpeed,
81
+ easing: options.collapseEasing
82
+ });
83
+ $ev.parent().parent().find('LI.directory').removeClass('expanded').addClass('collapsed');
84
+ }
85
+ $ev.parent().removeClass('collapsed').addClass('expanded');
86
+ $ev.parent().find('UL').remove();
87
+ return _this.showTree($ev.parent(), $ev.attr('rel'), function() {
88
+ _this._trigger('filetreeexpanded', _this.data);
89
+ return callback != null;
90
+ });
91
+ } else {
92
+ return $ev.parent().find('UL').slideUp({
93
+ duration: options.collapseSpeed,
94
+ easing: options.collapseEasing,
95
+ start: function() {
96
+ return _this._trigger('filetreecollapse', _this.data);
97
+ },
98
+ complete: function() {
99
+ $ev.parent().removeClass('expanded').addClass('collapsed');
100
+ _this._trigger('filetreecollapsed', _this.data);
101
+ return callback != null;
102
+ }
103
+ });
104
+ }
105
+ } else {
106
+ if (!options.multiSelect) {
107
+ jqft.container.find('li').removeClass('selected');
108
+ $ev.parent().addClass('selected');
109
+ } else {
110
+ if ($ev.parent().find('input').is(':checked')) {
111
+ $ev.parent().find('input').prop('checked', false);
112
+ $ev.parent().removeClass('selected');
113
+ } else {
114
+ $ev.parent().find('input').prop('checked', true);
115
+ $ev.parent().addClass('selected');
116
+ }
117
+ }
118
+ _this._trigger('filetreeclicked', _this.data);
119
+ return typeof callback === "function" ? callback($ev.attr('rel')) : void 0;
120
+ }
121
+ };
122
+
123
+ FileTree.prototype.showTree = function(el, dir, finishCallback) {
124
+ var $el, _this, data, handleFail, handleResult, options, result;
125
+ $el = $(el);
126
+ options = this.options;
127
+ _this = this;
128
+ $el.addClass('wait');
129
+ $(".jqueryFileTree.start").remove();
130
+ data = {
131
+ dir: dir,
132
+ onlyFolders: options.onlyFolders,
133
+ onlyFiles: options.onlyFiles,
134
+ multiSelect: options.multiSelect
135
+ };
136
+ handleResult = function(result) {
137
+ var li;
138
+ $el.find('.start').html('');
139
+ $el.removeClass('wait').append(result);
140
+ if (options.root === dir) {
141
+ $el.find('UL:hidden').show(typeof callback !== "undefined" && callback !== null);
142
+ } else {
143
+ if (jQuery.easing[options.expandEasing] === void 0) {
144
+ console.log('Easing library not loaded. Include jQueryUI or 3rd party lib.');
145
+ options.expandEasing = 'swing';
146
+ }
147
+ $el.find('UL:hidden').slideDown({
148
+ duration: options.expandSpeed,
149
+ easing: options.expandEasing,
150
+ start: function() {
151
+ return _this._trigger('filetreeexpand', _this.data);
152
+ },
153
+ complete: finishCallback
154
+ });
155
+ }
156
+ li = $('[rel="' + decodeURIComponent(dir) + '"]').parent();
157
+ if (options.multiSelect && li.children('input').is(':checked')) {
158
+ li.find('ul li input').each(function() {
159
+ $(this).prop('checked', true);
160
+ return $(this).parent().addClass('selected');
161
+ });
162
+ }
163
+ return false;
164
+ };
165
+ handleFail = function() {
166
+ $el.find('.start').html('');
167
+ $el.removeClass('wait').append("<p>" + options.errorMessage + "</p>");
168
+ return false;
169
+ };
170
+ if (typeof options.script === 'function') {
171
+ result = options.script(data);
172
+ if (typeof result === 'string' || result instanceof jQuery) {
173
+ return handleResult(result);
174
+ } else {
175
+ return handleFail();
176
+ }
177
+ } else {
178
+ return $.ajax({
179
+ url: options.script,
180
+ type: 'POST',
181
+ dataType: 'HTML',
182
+ data: data
183
+ }).done(function(result) {
184
+ return handleResult(result);
185
+ }).fail(function() {
186
+ return handleFail();
187
+ });
188
+ }
189
+ };
190
+
191
+ FileTree.prototype._trigger = function(eventType, data) {
192
+ var $el;
193
+ $el = this.jqft.container;
194
+ return $el.triggerHandler(eventType, data);
195
+ };
196
+
197
+ return FileTree;
198
+
199
+ })();
200
+ return $.fn.extend({
201
+ fileTree: function(args, callback) {
202
+ return this.each(function() {
203
+ var $this, data;
204
+ $this = $(this);
205
+ data = $this.data('fileTree');
206
+ if (!data) {
207
+ $this.data('fileTree', (data = new FileTree(this, args, callback)));
208
+ }
209
+ if (typeof args === 'string') {
210
+ return data[option].apply(data);
211
+ }
212
+ });
213
+ }
214
+ });
215
+ })(window.jQuery, window);
assets/js/wp-smushit-admin.js CHANGED
@@ -1,10 +1,11 @@
1
  /**
2
  * Processes bulk smushing
3
  *
4
- * @author Saurabh Shukla <saurabh@incsub.com>
5
  * @author Umesh Kumar <umeshsingla05@gmail.com>
6
  *
7
  */
 
 
8
  var WP_Smush = WP_Smush || {};
9
 
10
  /**
@@ -35,8 +36,9 @@ var dash_offset = function (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});
@@ -44,14 +46,14 @@ var update_dashoffset = function (stats) {
44
  }
45
  };
46
 
47
- var membership_validity = function( data ) {
48
  var member_validity_notice = jQuery('#wp-smush-invalid-member');
49
 
50
  //Check for Membership warning
51
- if( 'undefined' != typeof ( data.show_warning ) && member_validity_notice.length > 0 ) {
52
- if( data.show_warning ) {
53
  member_validity_notice.show();
54
- }else{
55
  member_validity_notice.hide();
56
  }
57
  }
@@ -68,8 +70,8 @@ var resize_width = function () {
68
  }
69
  };
70
 
71
- var remove_element = function( el, timeout ) {
72
- if( typeof timeout == 'undefined' ) {
73
  timeout = 100;
74
  }
75
  el.fadeTo(timeout, 0, function () {
@@ -311,7 +313,7 @@ jQuery(function ($) {
311
  return;
312
  }
313
  //handle progress for normal bulk smush
314
- progress = ( _res.data.stats.smushed / _res.data.stats.total) * 100;
315
  } else {
316
  //If the Request was successful, Update the progress bar
317
  if (_res.success) {
@@ -747,6 +749,11 @@ jQuery(function ($) {
747
  return true;
748
 
749
  };
 
 
 
 
 
750
 
751
  /**
752
  * Update the progress bar width if we have images that needs to be resmushed
@@ -774,7 +781,7 @@ jQuery(function ($) {
774
  $progress_bar.css('width', width + '%');
775
  };
776
 
777
- var run_re_check = function( button, process_settings ) {
778
  var spinner = button.parent().find('.spinner');
779
 
780
  //Check if type is set in data attributes
@@ -884,6 +891,514 @@ jQuery(function ($) {
884
  });
885
  }
886
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
887
  /**
888
  * Handle the Smush Stats link click
889
  */
@@ -975,7 +1490,7 @@ jQuery(function ($) {
975
  e.preventDefault();
976
 
977
  //Run the Re-check
978
- run_re_check( $(this ), false );
979
 
980
  });
981
 
@@ -1000,16 +1515,20 @@ jQuery(function ($) {
1000
  });
1001
 
1002
  //On Click Update Settings. Check for change in settings
1003
- $('#wp-smush-save-settings').on('click', function (e) {
1004
  e.preventDefault();
1005
 
1006
  var setting_type = '';
1007
  var setting_input = $('input[name="setting-type"]');
1008
  //Check if setting type is set in the form
1009
- if ( setting_input.length > 0 ) {
1010
  setting_type = setting_input.val();
1011
  }
1012
 
 
 
 
 
1013
  //Save settings if in network admin
1014
  if ('' != setting_type && 'network' == setting_type) {
1015
  //Ajax param
@@ -1028,7 +1547,6 @@ jQuery(function ($) {
1028
  } else {
1029
 
1030
  //Check for all the settings, and scan for resmush
1031
- var self = $(this);
1032
  var wrapper_div = self.parents().eq(1);
1033
 
1034
  //Get all the main settings
@@ -1054,8 +1572,6 @@ jQuery(function ($) {
1054
  self.val(wp_smush_msgs.checking)
1055
  }
1056
 
1057
- self.parent().find('.spinner').addClass('is-active');
1058
-
1059
  //Check if type is set in data attributes
1060
  var scan_type = self.data('type');
1061
  scan_type = 'undefined' == typeof scan_type ? 'media' : scan_type;
@@ -1259,7 +1775,7 @@ jQuery(function ($) {
1259
  });
1260
 
1261
  //Adjust background image size if required
1262
- if( $('.wp-smush-pro-for-free').length ) {
1263
  //On Page load
1264
  resize_width();
1265
  //Adjust background image
@@ -1268,7 +1784,7 @@ jQuery(function ($) {
1268
  });
1269
  }
1270
  //Handle Re-check button functionality
1271
- $("#wp-smush-revalidate-member").on( 'click', function( e ) {
1272
  e.preventDefault();
1273
  //Ajax Params
1274
  var params = {
@@ -1277,14 +1793,14 @@ jQuery(function ($) {
1277
  var link = $(this);
1278
  var parent = link.parents().eq(1);
1279
  parent.addClass('loading-notice');
1280
- $.get(ajaxurl, params, function ( r ) {
1281
  //remove the warning
1282
  parent.removeClass('loading-notice').addClass("loaded-notice");
1283
- if( 0 == r ) {
1284
- parent.attr('data-message', wp_smush_msgs.membership_valid );
1285
- remove_element( parent, 1000 );
1286
- }else{
1287
- parent.attr( 'data-message', wp_smush_msgs.membership_invalid );
1288
  setTimeout(function remove_loader() {
1289
  parent.removeClass('loaded-notice');
1290
  }, 1000)
@@ -1293,11 +1809,328 @@ jQuery(function ($) {
1293
  });
1294
 
1295
  //Initiate Re-check if the variable is set
1296
- if( 'undefined' != typeof (wp_smush_run_re_check) && 1 == wp_smush_run_re_check && $('.wp-smush-scan').length > 0 ) {
1297
  //Run the Re-check
1298
- run_re_check( $('.wp-smush-scan' ), false );
1299
  }
1300
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1301
  });
1302
  (function ($) {
1303
  var Smush = function (element, options) {
1
  /**
2
  * Processes bulk smushing
3
  *
 
4
  * @author Umesh Kumar <umeshsingla05@gmail.com>
5
  *
6
  */
7
+ /**@todo: Use Element tag for all the class selectors **/
8
+
9
  var WP_Smush = WP_Smush || {};
10
 
11
  /**
36
  }
37
 
38
  var update_dashoffset = function (stats) {
39
+ var total = stats.total.length;
40
+ if (total > 0) {
41
+ var dashoffset = dash_offset(stats.smushed / total);
42
  var circle_progress = jQuery('.wp-smush-svg-circle-progress');
43
  if (typeof dashoffset != 'undefined' && circle_progress.length) {
44
  circle_progress.css({'stroke-dashoffset': dashoffset});
46
  }
47
  };
48
 
49
+ var membership_validity = function (data) {
50
  var member_validity_notice = jQuery('#wp-smush-invalid-member');
51
 
52
  //Check for Membership warning
53
+ if ('undefined' != typeof ( data.show_warning ) && member_validity_notice.length > 0) {
54
+ if (data.show_warning) {
55
  member_validity_notice.show();
56
+ } else {
57
  member_validity_notice.hide();
58
  }
59
  }
70
  }
71
  };
72
 
73
+ var remove_element = function (el, timeout) {
74
+ if (typeof timeout == 'undefined') {
75
  timeout = 100;
76
  }
77
  el.fadeTo(timeout, 0, function () {
313
  return;
314
  }
315
  //handle progress for normal bulk smush
316
+ progress = ( _res.data.stats.smushed / _res.data.stats.total.length ) * 100;
317
  } else {
318
  //If the Request was successful, Update the progress bar
319
  if (_res.success) {
749
  return true;
750
 
751
  };
752
+ //Stackoverflow: http://stackoverflow.com/questions/1726630/formatting-a-number-with-exactly-two-decimals-in-javascript
753
+ var precise_round = function (num, decimals) {
754
+ var sign = num >= 0 ? 1 : -1;
755
+ return (Math.round((num * Math.pow(10, decimals)) + (sign * 0.001)) / Math.pow(10, decimals));
756
+ };
757
 
758
  /**
759
  * Update the progress bar width if we have images that needs to be resmushed
781
  $progress_bar.css('width', width + '%');
782
  };
783
 
784
+ var run_re_check = function (button, process_settings) {
785
  var spinner = button.parent().find('.spinner');
786
 
787
  //Check if type is set in data attributes
891
  });
892
  }
893
 
894
+ /**
895
+ * Get directory list using Ajax
896
+ *
897
+ * @param param
898
+ * @returns {string}
899
+ *
900
+ */
901
+ var getDirectoryList = function (param) {
902
+ param.action = 'smush_get_directory_list';
903
+ param.list_nonce = jQuery('input[name="list_nonce"]').val();
904
+ var res = '';
905
+ $.ajax({
906
+ type: "GET",
907
+ url: ajaxurl,
908
+ data: param,
909
+ success: function (response) {
910
+ res = response;
911
+ },
912
+ async: false
913
+ });
914
+ return res;
915
+ }
916
+ /**
917
+ * Hide the popup and reset the opacity for the button
918
+ *
919
+ */
920
+ var close_dialog = function () {
921
+ //Hide the dialog
922
+ $('.wp-smush-list-dialog').hide();
923
+ $('.wp-smush-select-dir, button.wp-smush-browse, button.wp-smush-resume').removeAttr('disabled');
924
+
925
+ //Remove the spinner
926
+ $('div.dir-smush-button-wrap span.spinner').removeClass('is-active');
927
+
928
+ //Reset the opacity for content and scan button
929
+ $('.wp-smush-select-dir, .wp-smush-list-dialog .box .content').css({'opacity': '1'});
930
+ $('.wp-smush-select-button-wrap .spinner').removeClass('is-active');
931
+ }
932
+
933
+ /**
934
+ * Initialize accordion
935
+ *
936
+ */
937
+ var set_accordion = function () {
938
+ //Accordion On WP Smush All Page
939
+ var acc = document.getElementsByClassName("wp-smush-li-path");
940
+ var i;
941
+
942
+ for (i = 0; i < acc.length; i++) {
943
+ acc[i].onclick = function () {
944
+ var parent = $(this).parent();
945
+ if (parent.hasClass('active')) {
946
+ parent.removeClass('active');
947
+ parent.find('.wp-smush-image-list-inner').removeClass("show");
948
+ } else {
949
+ parent.addClass("active");
950
+ $('.wp-smush-image-ul.active .wp-smush-image-list-inner').addClass("show");
951
+ }
952
+ }
953
+ }
954
+ }
955
+
956
+ /**
957
+ * Appends the waiting message to child elements for a directory
958
+ * @param ele
959
+ */
960
+ var update_dir_ele_status = function (ele) {
961
+ //Get the parent element
962
+ var parent = ele.parents('li.wp-smush-image-ul');
963
+
964
+ //Spinner
965
+ var spinner = $('div.wp-smush-scan-result span.spinner:first').clone();
966
+
967
+ if (!parent.length) {
968
+ return;
969
+ }
970
+ //Check if the selected element is under expandable li
971
+ parent.removeClass('partial complete').addClass('active in-progress');
972
+
973
+ //Append a spinner, if parent doesn't have it
974
+ if (!parent.find('span.wp-smush-li-path span.spinner').length) {
975
+ parent.find('span.wp-smush-li-path').prepend(spinner.clone());
976
+ }
977
+
978
+ var list = parent.find('.wp-smush-image-list-inner');
979
+ list.addClass('show');
980
+
981
+ //Check if first image, Add a loader against directory path
982
+ var progress_wrap = parent.find('div.wp-smush-dir-progress-wrap');
983
+
984
+ var waiting_message = $('content').find('span.waiting-message').clone();
985
+
986
+ if (ele.is(':first-child')) {
987
+ progress_wrap.css({'display': 'inline-block'});
988
+ parent.find('a.wp-smush-exclude-dir').remove();
989
+ }
990
+
991
+ var child = parent.find('ul.wp-smush-image-list-inner li');
992
+
993
+ //Mark all the images inside a directory path, as waiting. Copy and append a single span from the page
994
+ var unsmushed = child.filter(":not('.optimised')");
995
+ if (unsmushed.length > 0) {
996
+ //Append a waiting message
997
+ unsmushed.append(waiting_message);
998
+ unsmushed.find(waiting_message).show();
999
+ }
1000
+ }
1001
+
1002
+ /**
1003
+ * Check if all the elements in the directory are smushed or not
1004
+ *
1005
+ * @param parent directory selector
1006
+ *
1007
+ * @returns {boolean}
1008
+ *
1009
+ */
1010
+ var is_last_element = function(parent) {
1011
+ var elements = parent.find('li.wp-smush-image-ele:not(.optimised,.error)');
1012
+ if( elements.length <= 0 ) {
1013
+ return true;
1014
+ }
1015
+ return false;
1016
+ };
1017
+
1018
+ /**
1019
+ * Update directory optimisation progress if the element has a parent
1020
+ *
1021
+ * @param ele
1022
+ *
1023
+ */
1024
+ var update_dir_progress = function (ele) {
1025
+ //Get the parent element
1026
+ var parent = ele.parents('li.wp-smush-image-ul');
1027
+
1028
+ if (!parent.length) {
1029
+ return;
1030
+ }
1031
+ var child = parent.find('ul.wp-smush-image-list-inner li');
1032
+
1033
+ //Check if first image, Add a loader against directory path
1034
+ var progress_wrap = parent.find('div.wp-smush-dir-progress-wrap');
1035
+
1036
+ //Update the percentage, Check the total number of images inside dir, smushed images count
1037
+ var total = child.length;
1038
+ var smushed = child.filter('.optimised').length;
1039
+ var smush_progress = progress_wrap.find('.wp-smush-dir-progress');
1040
+ if (smushed > 0 && total > 0) {
1041
+ var percent = ( smushed / total ) * 100;
1042
+ percent = precise_round(percent, 1);
1043
+ progress_wrap.find('.smush-percent').html(percent + '%');
1044
+ smush_progress.css({'width': percent + '%'});
1045
+ }
1046
+
1047
+ //Add the class in-progress, to show the respective icon for parent
1048
+ if (0 != $('input[name="wp-smush-continue-ajax"]').val() && !parent.hasClass('in-progress') && smushed != total) {
1049
+ parent.addClass('in-progress').removeClass('partial');
1050
+ //Append a spinner
1051
+ var spinner = $('div.wp-smush-scan-result span.spinner:first').clone();
1052
+ if (spinner) {
1053
+ parent.find('span.wp-smush-li-path').prepend(spinner);
1054
+ }
1055
+ }
1056
+
1057
+ var parent_class = '';
1058
+ //Check if last image, and if all the images are not smushed under the specified directory path, add a generic warning message
1059
+ if (is_last_element(parent)) {
1060
+ if (smushed < total) {
1061
+ var unsmushed = total - smushed;
1062
+ var message = '<div class="wp-smush-dir-notice"><i class="dev-icon wdv-icon wdv-icon-fw wdv-icon-exclamation-sign"></i>' + unsmushed + ' ' + ( 1 == unsmushed ? wp_smush_msgs.unfinished_smush_single : wp_smush_msgs.unfinished_smush ) + '</div>';
1063
+
1064
+ //If the notice is already displayed, remove it
1065
+ var notice = parent.find('div.wp-smush-dir-notice');
1066
+ if( notice.length ) {
1067
+ notice.remove();
1068
+ }
1069
+
1070
+ //Append message to 2nd parent i.e li
1071
+ parent.find('ul.wp-smush-image-list-inner').after(message);
1072
+
1073
+ //Check If all the images are smushed, remove the class in-progress and add the class complete, else add class partial
1074
+ parent_class = 'partial';
1075
+
1076
+ //Remove the Spinner
1077
+ parent.find('span.wp-smush-li-path span.spinner').remove();
1078
+ } else {
1079
+ parent_class = 'complete';
1080
+ smush_progress.removeClass('partial').addClass('complete');
1081
+ }
1082
+ //Remove Spinner
1083
+ parent.find('span.wp-smush-li-path span.spinner').remove();
1084
+
1085
+ //Remove In progress class for the element and add partial/complete class
1086
+ parent.removeClass('in-progress active').addClass(parent_class);
1087
+
1088
+ //Remove active class from parent
1089
+ parent.removeClass('active').find('.wp-smush-image-list-inner').removeClass("show");
1090
+ }
1091
+
1092
+ }
1093
+
1094
+ /**
1095
+ * Add choose directory button at the top
1096
+ *
1097
+ */
1098
+ var add_dir_browser_button = function () {
1099
+ //Get the content div length, if less than 700, Skip
1100
+ if( $('div.wp-smush-scan-result div.content').height() < 700 || $('div.dir-smush-button-wrap.top').length >= 1 ) {
1101
+ return;
1102
+ }
1103
+
1104
+ var choose_button = $('div.dir-smush-button-wrap').clone();
1105
+ choose_button.addClass('top');
1106
+ $('div.wp-smush-scan-result div.content').prepend(choose_button);
1107
+ };
1108
+
1109
+ var add_smush_button = function() {
1110
+ //Get the content div length, if less than 700, Skip
1111
+ if( $('div.wp-smush-scan-result div.content').height() < 700 || $('div.wp-smush-all-button-wrap.top').length >= 1 ) {
1112
+ return;
1113
+ }
1114
+
1115
+ var smush_button = $('div.wp-smush-all-button-wrap.bottom').clone();
1116
+ smush_button.addClass('top').removeClass('bottom');
1117
+ $('div.wp-smush-scan-result div.content').prepend(smush_button);
1118
+
1119
+ };
1120
+
1121
+ /**
1122
+ * Add smush notice after directory smushing is finished
1123
+ *
1124
+ * @param notice_type
1125
+ * all_done - If all the images were smushed else warning
1126
+ * smush_limit - If Free users exceeded limit
1127
+ *
1128
+ */
1129
+ var add_smush_dir_notice = function ( notice_type ) {
1130
+ //Get the content div length, if less than 700, Skip
1131
+ if( $('div.wp-smush-scan-result div.content').height() < 700 || $('div.wp-smush-scan-result div.wp-smush-notice.top').length >= 1 ) {
1132
+ return;
1133
+ }
1134
+ var notice = '';
1135
+ //Clone and append the notice
1136
+ if( 'all_done' == notice_type ) {
1137
+ notice = $('div.wp-smush-notice.wp-smush-dir-all-done').clone();
1138
+ }else if( 'smush_limit' == notice_type ){
1139
+ notice = $('div.wp-smush-notice.wp-smush-dir-limit').clone();
1140
+ }else{
1141
+ notice = $('div.wp-smush-notice.wp-smush-dir-remaining').clone();
1142
+ }
1143
+
1144
+ //Add class top
1145
+ notice.addClass('top');
1146
+
1147
+ //Append the notice
1148
+ $('div.wp-smush-scan-result div.dir-smush-button-wrap').after( notice );
1149
+ };
1150
+
1151
+ var update_smush_progress = function() {
1152
+ var in_progress_path = $('ul.wp-smush-image-list li.in-progress');
1153
+ in_progress_path.removeClass('in-progress active');
1154
+ if( in_progress_path.length > 0 ) {
1155
+ in_progress_path.each( function( index, ele ) {
1156
+ if ($(ele).hasClass('wp-smush-image-ul')) {
1157
+ //Remove Spinner
1158
+ $(ele).find('span.spinner').remove();
1159
+
1160
+ //Check if images are pending
1161
+ var in_progress_ele = $(ele).find('li.wp-smush-image-ele');
1162
+
1163
+ //If there are elements
1164
+ if (in_progress_ele.length > 0) {
1165
+ var optimised = in_progress_ele.filter('.optimised').length;
1166
+ var error = in_progress_ele.filter('.error').length;
1167
+ //if all the elements are optimised
1168
+ if (optimised == in_progress_ele.length) {
1169
+ $( ele ).addClass('complete');
1170
+ } else if (0 < optimised || 0 < error) {
1171
+ //If there are images that needs to be smushed, add the class partial
1172
+ $( ele ).addClass('partial');
1173
+ }
1174
+ }
1175
+
1176
+ }else{
1177
+ //Remove spinner for the element
1178
+ $(ele).find('span.spinner').remove();
1179
+ }
1180
+ });
1181
+ }
1182
+ };
1183
+
1184
+ /**
1185
+ * Update the progress and show notice when smush completes
1186
+ */
1187
+ var directory_smush_finished = function( notice_type ) {
1188
+ //If there are no images left
1189
+ $('div.wp-smush-all-button-wrap span.spinner').remove();
1190
+ $('button.wp-smush-pause').hide().attr('disabled', 'disabled');
1191
+
1192
+ //Hide Bulk Smush button if smush was stopped for error or finished
1193
+ if ('' == notice_type) {
1194
+ $('button.wp-smush-start').parent().hide();
1195
+ } else {
1196
+ $('button.wp-smush-start').show().removeAttr('disabled');
1197
+ }
1198
+
1199
+ //Enable Choose directory button
1200
+ $('button.wp-smush-browse').show().removeAttr('disabled', 'disabled');
1201
+
1202
+ //Clone Choose Directory Button and add at the top
1203
+ add_dir_browser_button();
1204
+
1205
+ //Clone and add Smush button
1206
+ add_smush_button();
1207
+
1208
+ if( '' == notice_type ) {
1209
+ //Get the Total and Optimised image count
1210
+ var image_ele = $('li.wp-smush-image-ele')
1211
+ var total = image_ele.length;
1212
+ var remaning = image_ele.filter(':not(.optimised)').length;
1213
+ var smushed = total - remaning;
1214
+ if (remaning > 0) {
1215
+
1216
+ //Append the count
1217
+ $('span.wp-smush-dir-remaining').html(remaning);
1218
+ $('span.wp-smush-dir-total').html(total);
1219
+ $('span.wp-smush-dir-smushed').html(smushed);
1220
+
1221
+ //Show remaining image notice
1222
+ $('.wp-smush-notice.wp-smush-dir-remaining').show();
1223
+
1224
+ //Show notice on top if required
1225
+ add_smush_dir_notice();
1226
+ } else {
1227
+ //Show All done notice
1228
+ $('.wp-smush-notice.wp-smush-dir-all-done').show();
1229
+
1230
+ //Show notice on top if required
1231
+ add_smush_dir_notice('all_done');
1232
+ }
1233
+ }else{
1234
+ //Show Bulk Limit Notice
1235
+ $('.wp-smush-notice.wp-smush-dir-limit').show();
1236
+ //Show notice on top if required
1237
+ add_smush_dir_notice('smush_limit');
1238
+ }
1239
+
1240
+ //Update Directory progress and remove any loaders still in there
1241
+ update_smush_progress();
1242
+
1243
+ }
1244
+
1245
+ /**
1246
+ * Start Optimising all the images listed in last directory scan
1247
+ *
1248
+ */
1249
+ var smush_all = function () {
1250
+
1251
+ var spinner = $('div.smush-page-wrap span.spinner:first').clone();
1252
+ spinner.addClass('is-active');
1253
+ //Update the Optimising status for the image
1254
+ var first_child = $('ul.wp-smush-image-list li.wp-smush-image-ele:not(".optimised, .processed"):first');
1255
+
1256
+ var parent = first_child.parents('li.wp-smush-image-ul');
1257
+
1258
+ //Check if the selected element is under expandable li
1259
+ if (parent.length == 1) {
1260
+ parent.addClass('active in-progress').removeClass('partial');
1261
+ parent.find('.wp-smush-image-list-inner').addClass('show');
1262
+ if (!parent.find('span.wp-smush-li-path span.spinner').length) {
1263
+ parent.find('span.wp-smush-li-path').prepend(spinner.clone());
1264
+ }
1265
+ }
1266
+
1267
+ //Append and show spinner
1268
+ first_child.addClass('in-progress processed');
1269
+ if (!first_child.find('spam.spinner').length) {
1270
+ first_child.prepend(spinner.clone());
1271
+ }
1272
+
1273
+ //If all the elements are optimised, No need to send ajax request
1274
+ if( first_child.length == 0 ) {
1275
+ directory_smush_finished('');
1276
+ return;
1277
+ }
1278
+
1279
+ /** Ajax Request to optimise directory images */
1280
+ var param = {
1281
+ action: 'optimise',
1282
+ image_id: first_child.attr('id'),
1283
+ nonce: $('#wp-smush-all').val()
1284
+ };
1285
+
1286
+ //Send Ajax request
1287
+ $.get(ajaxurl, param, function (res) {
1288
+
1289
+ //Check, if limit is exceeded for free version
1290
+ if (typeof res.data !== "undefined" && res.data.error == 'dir_smush_limit_exceeded') {
1291
+ //Show error, Bulk Smush limit exceeded
1292
+ directory_smush_finished( 'wp-smush-dir-limit' );
1293
+ return;
1294
+ }
1295
+
1296
+ //append stats, remove loader, add loader to next image, loop
1297
+ var data = 'undefined' != typeof ( res.data ) ? res.data : '';
1298
+
1299
+ //If image element is there
1300
+ if ('undefined' != typeof(data.image)) {
1301
+ //Mark Optimised
1302
+ var ele = jQuery(document.getElementById(data.image.id));
1303
+
1304
+ //Remove the spinner
1305
+ ele.find('span.spinner').remove();
1306
+ ele.removeClass('in-progress');
1307
+
1308
+ if (res.success) {
1309
+
1310
+ ele.addClass('optimised');
1311
+
1312
+ //Show the Optimisation status
1313
+ ele.find('span.wp-smush-image-ele-status').show();
1314
+
1315
+ //Update Directory progress
1316
+ update_dir_progress(ele);
1317
+ } else {
1318
+ //If there was an error optimising the image
1319
+ ele.addClass('error');
1320
+ //Update Directory progress
1321
+ update_dir_progress(ele);
1322
+ }
1323
+ }
1324
+
1325
+ //If user haven't paused the Smushing
1326
+ if ( 1 == $('input[name="wp-smush-continue-ajax"]').val() ) {
1327
+ //Loop
1328
+ smush_all(false);
1329
+ } else {
1330
+ //Reset the Ajax flag
1331
+ $('input.wp-smush-continue-ajax').val(1);
1332
+ }
1333
+
1334
+ });
1335
+ }
1336
+
1337
+ //Scroll the element to top of the page
1338
+ var goToByScroll = function (selector) {
1339
+ // Scroll
1340
+ $('html,body').animate({
1341
+ scrollTop: selector.offset().top
1342
+ },
1343
+ 'slow');
1344
+ };
1345
+
1346
+ var disable_buttons = function (self) {
1347
+ self.attr('disabled', 'disabled');
1348
+ $('.wp-smush-browse').attr('disabled', 'disabled');
1349
+ };
1350
+
1351
+ var update_cummulative_stats = function (stats) {
1352
+ //Update Directory Smush Stats
1353
+ if ('undefined' != typeof ( stats.dir_smush )) {
1354
+ var stats_human = $('div.smush-dir-savings span.wp-smush-stats span.wp-smush-stats-human');
1355
+ var stats_percent = $('div.smush-dir-savings span.wp-smush-stats span.wp-smush-stats-percent');
1356
+
1357
+ //Update Savings in bytes
1358
+ if (stats_human.length > 0) {
1359
+ stats_human.html(stats.dir_smush.human);
1360
+ } else {
1361
+ var span = '<span class="wp-smush-stats-human">' + stats.dir_smush.bytes + '</span>';
1362
+ }
1363
+
1364
+ //Update Optimisation percentage
1365
+ if (stats_percent.length > 0) {
1366
+ stats_percent.html(stats.dir_smush.percent + '%');
1367
+ } else {
1368
+ var span = '<span class="wp-smush-stats-percent">' + stats.dir_smush.percent + '%' + '</span>';
1369
+ }
1370
+ }
1371
+
1372
+ //Update Combined stats
1373
+ if ('undefined' != typeof ( stats.combined_stats ) && stats.combined_stats.length > 0) {
1374
+ var c_stats = stats.combined_stats;
1375
+
1376
+ //Update Circle Progress
1377
+ if (c_stats.dash_offset) {
1378
+ $('circle.wp-smush-svg-circle-progress').css({'stroke-dashoffset': c_stats.dash_offset});
1379
+ }
1380
+ //Update Tooltip Text
1381
+ if (c_stats.tooltip_text) {
1382
+ $('div.wp-smush-current-progress').attr('tooltip', c_stats.tooltip_text);
1383
+ }
1384
+ //Update Smushed count
1385
+ if (c_stats.smushed_count) {
1386
+ $('div.wp-smush-count-total span.wp-smush-optimised').html(c_stats.smushed_count);
1387
+ }
1388
+ //Update Total Attachment Count
1389
+ if (c_stats.total_count) {
1390
+ $('div.wp-smush-count-total div.wp-smush-smush-stats-wrapper span:last-child').html(c_stats.total_count);
1391
+ }
1392
+ //Update Savings and Percent
1393
+ if (c_stats.savings) {
1394
+ $('div.wp-smush-savings span.wp-smush-stats-human').html(c_stats.savings);
1395
+ }
1396
+ if (c_stats.percent) {
1397
+ $('div.wp-smush-savings span.wp-smush-stats-percent').html(c_stats.percent);
1398
+ }
1399
+ }
1400
+ };
1401
+
1402
  /**
1403
  * Handle the Smush Stats link click
1404
  */
1490
  e.preventDefault();
1491
 
1492
  //Run the Re-check
1493
+ run_re_check($(this), false);
1494
 
1495
  });
1496
 
1515
  });
1516
 
1517
  //On Click Update Settings. Check for change in settings
1518
+ $('input#wp-smush-save-settings').on('click', function (e) {
1519
  e.preventDefault();
1520
 
1521
  var setting_type = '';
1522
  var setting_input = $('input[name="setting-type"]');
1523
  //Check if setting type is set in the form
1524
+ if (setting_input.length > 0) {
1525
  setting_type = setting_input.val();
1526
  }
1527
 
1528
+ //Show the spinner
1529
+ var self = $(this);
1530
+ self.parent().find('span.spinner').addClass('is-active');
1531
+
1532
  //Save settings if in network admin
1533
  if ('' != setting_type && 'network' == setting_type) {
1534
  //Ajax param
1547
  } else {
1548
 
1549
  //Check for all the settings, and scan for resmush
 
1550
  var wrapper_div = self.parents().eq(1);
1551
 
1552
  //Get all the main settings
1572
  self.val(wp_smush_msgs.checking)
1573
  }
1574
 
 
 
1575
  //Check if type is set in data attributes
1576
  var scan_type = self.data('type');
1577
  scan_type = 'undefined' == typeof scan_type ? 'media' : scan_type;
1775
  });
1776
 
1777
  //Adjust background image size if required
1778
+ if ($('.wp-smush-pro-for-free').length) {
1779
  //On Page load
1780
  resize_width();
1781
  //Adjust background image
1784
  });
1785
  }
1786
  //Handle Re-check button functionality
1787
+ $("#wp-smush-revalidate-member").on('click', function (e) {
1788
  e.preventDefault();
1789
  //Ajax Params
1790
  var params = {
1793
  var link = $(this);
1794
  var parent = link.parents().eq(1);
1795
  parent.addClass('loading-notice');
1796
+ $.get(ajaxurl, params, function (r) {
1797
  //remove the warning
1798
  parent.removeClass('loading-notice').addClass("loaded-notice");
1799
+ if (0 == r) {
1800
+ parent.attr('data-message', wp_smush_msgs.membership_valid);
1801
+ remove_element(parent, 1000);
1802
+ } else {
1803
+ parent.attr('data-message', wp_smush_msgs.membership_invalid);
1804
  setTimeout(function remove_loader() {
1805
  parent.removeClass('loaded-notice');
1806
  }, 1000)
1809
  });
1810
 
1811
  //Initiate Re-check if the variable is set
1812
+ if ('undefined' != typeof (wp_smush_run_re_check) && 1 == wp_smush_run_re_check && $('.wp-smush-scan').length > 0) {
1813
  //Run the Re-check
1814
+ run_re_check($('.wp-smush-scan'), false);
1815
  }
1816
 
1817
+ //WP Smush all : Scan Images
1818
+ $('div.row').on('click', 'button.wp-smush-browse', function (e) {
1819
+
1820
+ e.preventDefault();
1821
+
1822
+ //Hide all the notices
1823
+ $('div.wp-smush-scan-result div.wp-smush-notice').hide();
1824
+
1825
+ //If disabled, do not process
1826
+ if ($(this).attr('disabled')) {
1827
+ return;
1828
+ } else {
1829
+ //Disable Buttons
1830
+ $(this).attr('disabled', 'disabled');
1831
+ $('button.wp-smush-resume').attr('disabled', 'disabled');
1832
+ $('div.dir-smush-button-wrap span.spinner').addClass('is-active');
1833
+
1834
+ }
1835
+
1836
+ //Remove Notice
1837
+ $('div.wp-smush-info').remove();
1838
+
1839
+ //Shows the directories available
1840
+ $('.wp-smush-list-dialog').show();
1841
+
1842
+ //Display the loader
1843
+ $('button.dir-smush-button-wrap span.spinner').addClass('is-active');
1844
+
1845
+ $(".wp-smush-list-dialog .content").fileTree({
1846
+ script: getDirectoryList,
1847
+ //folderEvent: 'dblclick',
1848
+ multiFolder: false
1849
+ //onlyFolders: true
1850
+ });
1851
+
1852
+ });
1853
+
1854
+ //WP Smush all: Close button functionality
1855
+ $('.wp-smush-list-dialog').on('click', '.close', function (e) {
1856
+ e.preventDefault();
1857
+ close_dialog();
1858
+ });
1859
+
1860
+ //Image Directories: On Select button click
1861
+ $('.wp-smush-select-dir').on('click', function (e) {
1862
+ e.preventDefault();
1863
+
1864
+ //If disabled, do not process
1865
+ if ($(this).attr('disabled')) {
1866
+ return;
1867
+ }
1868
+
1869
+ var button = $(this);
1870
+
1871
+ button.css({'opacity': '0.5'});
1872
+ $('div.wp-smush-list-dialog div.box div.content').css({'opacity': '0.8'});
1873
+ $('div.wp-smush-list-dialog div.box div.content a').unbind('click');
1874
+
1875
+ //Remove resume button
1876
+ $('button.wp-smush-resume').remove();
1877
+
1878
+ //Disable Button
1879
+ button.attr('disabled', 'disabled');
1880
+
1881
+ //Display the spinner
1882
+ button.parent().find('.spinner').addClass('is-active');
1883
+
1884
+ //Get the Selected directory path
1885
+ var path = $('.jqueryFileTree .selected a').attr('rel');
1886
+ path = 'undefined' == typeof (path) ? '' : path;
1887
+
1888
+ //Absolute path
1889
+ var abs_path = $('input[name="wp-smush-base-path"]').val();
1890
+
1891
+ //Fill in the input field
1892
+ $('.wp-smush-dir-path').val(abs_path + path);
1893
+
1894
+ //Send a ajax request to get a list of all the image files
1895
+ var param = {
1896
+ action: 'image_list',
1897
+ smush_path: $('.wp-smush-dir-path').val(),
1898
+ image_list_nonce: $('input[name="image_list_nonce"]').val()
1899
+ };
1900
+
1901
+ //Get the List of images
1902
+ $.get(ajaxurl, param, function (res) {
1903
+ if( !res.success && 'undefined' !== typeof ( res.data.message ) ) {
1904
+ $('div.wp-smush-scan-result div.content').html(res.data.message );
1905
+ }else {
1906
+ $('div.wp-smush-scan-result div.content').html(res.data );
1907
+ wp_smush_dir_image_ids = res.data.ids;
1908
+ }
1909
+ set_accordion();
1910
+ close_dialog();
1911
+
1912
+ //Show Scan result
1913
+ $('.wp-smush-scan-result').removeClass('hidden');
1914
+ }).done(function (res) {
1915
+
1916
+ //If there was no image list, return
1917
+ if( !res.success ) {
1918
+ //Hide the smush button
1919
+ $('div.wp-smush-all-button-wrap.bottom').hide();
1920
+ return;
1921
+ }
1922
+
1923
+ //Show the smush button
1924
+ $('div.wp-smush-all-button-wrap.bottom').show();
1925
+
1926
+ //Remove disabled attribute for the button
1927
+ $('button.wp-smush-start').removeAttr('disabled');
1928
+
1929
+ //Append a Directory browser button at the top
1930
+ add_dir_browser_button();
1931
+
1932
+ //Clone and add Smush button
1933
+ add_smush_button();
1934
+
1935
+ });
1936
+ });
1937
+
1938
+ /**
1939
+ * Handle the Smush Now button click
1940
+ */
1941
+ $('div.wp-smush-scan-result').on('click', 'button.wp-smush-start', function (e) {
1942
+ e.preventDefault();
1943
+
1944
+ //Check if we have images to be optimised
1945
+ if (!$('.wp-smush-image-list li').length) {
1946
+ return;
1947
+ }
1948
+
1949
+ //Disable this button
1950
+ var button = $('.wp-smush-start');
1951
+ var parent = button.parent();
1952
+
1953
+ //Hide all the notices
1954
+ $('div.wp-smush-scan-result div.wp-smush-notice').hide();
1955
+
1956
+ //Set the button status to 0, to cancel next ajax request
1957
+ $('input[name="wp-smush-continue-ajax"]').val(1);
1958
+
1959
+ //Hide Directory browser button
1960
+ $('button.wp-smush-browse').hide();
1961
+
1962
+ //Hide Exclude directory button link
1963
+ $('a.wp-smush-exclude-dir').hide();
1964
+
1965
+ /** All the Styling changes **/
1966
+ button.attr('disabled', 'disabled');
1967
+ parent.find('span.spinner').addClass('is-active');
1968
+ parent.find('button.wp-smush-pause').show().removeAttr('disabled');
1969
+
1970
+ //Disable Select Directory button
1971
+ $('button.wp-smush-browse').attr('disabled', 'disabled');
1972
+
1973
+ //Initialize the optimisation
1974
+ smush_all(true);
1975
+
1976
+ });
1977
+
1978
+ //Handle the Pause button click
1979
+ $('div.wp-smush-scan-result').on('click', 'button.wp-smush-pause', function (e) {
1980
+ e.preventDefault();
1981
+
1982
+ var pause_button = $('button.wp-smush-pause');
1983
+ //Return if the link is disabled
1984
+ if (pause_button.hasClass('disabled')) {
1985
+ return false;
1986
+ }
1987
+
1988
+ //Set the button status to 0, to cancel next ajax request
1989
+ $('input[name="wp-smush-continue-ajax"]').val(0);
1990
+
1991
+ //Enable the smush button, disable Pause button
1992
+ pause_button.attr('disabled', 'disabled');
1993
+
1994
+ //Enable the smush button, hide the spinner
1995
+ $('button.wp-smush-start, button.wp-smush-browse').show().removeAttr('disabled');
1996
+ $('div.wp-smush-all-button-wrap span.spinner').removeClass('is-active');
1997
+
1998
+ //Show directory exclude option
1999
+ $('a.wp-smush-exclude-dir').show();
2000
+
2001
+ //Remove the loaders
2002
+ update_smush_progress();
2003
+
2004
+
2005
+ });
2006
+
2007
+ //Exclude Directory from list - Handle Click
2008
+ $('div.wp-smush-scan-result').on('click', 'a.wp-smush-exclude-dir', function (e) {
2009
+ e.preventDefault();
2010
+
2011
+ var self = $(this);
2012
+ var parent = self.parent();
2013
+
2014
+ //Hide the link
2015
+ self.hide();
2016
+
2017
+ //Append the loader
2018
+ parent.find('span.wp-smush-li-path').after($('div.wp-smush-scan-result span.spinner:first').clone());
2019
+
2020
+ //Store the spinner in a element
2021
+ var loader = parent.find('span.spinner:first');
2022
+
2023
+ loader.removeClass('is-active');
2024
+
2025
+ var path = self.data('path');
2026
+ var param = {
2027
+ action: 'smush_exclude_path',
2028
+ path: path,
2029
+ nonce: $('input[name="exclude-path-nonce"]').val()
2030
+ };
2031
+
2032
+ //Send Ajax request to remove image for the given path from db
2033
+ $.post(ajaxurl, param, function (res) {
2034
+ loader.remove();
2035
+ //Remove the whole li element on success
2036
+ if (res.success) {
2037
+ //Check if immediate sibling is ul, add a hr tag to it
2038
+ if (parent.is("li.wp-smush-image-ul:first")) {
2039
+ //Add a hr tag for the next element
2040
+ parent.siblings('li.wp-smush-image-ul:first').prepend('<hr />');
2041
+ }
2042
+ parent.remove();
2043
+ }
2044
+ });
2045
+ });
2046
+
2047
+ //Handle Click for Resume Last scan button
2048
+ $('button.wp-smush-resume').on('click', function () {
2049
+
2050
+ var self = $(this);
2051
+
2052
+ //Disable buttons
2053
+ disable_buttons(self);
2054
+
2055
+ //Show Spinner
2056
+ $('div.dir-smush-button-wrap span.spinner').addClass('is-active');
2057
+
2058
+ var params = {
2059
+ action: 'resume_scan',
2060
+ };
2061
+
2062
+ //Send Ajax request to load a list of images
2063
+ $.get(ajaxurl, params, function (r) {
2064
+
2065
+ //Hide the buttons
2066
+ $('button.wp-smush-resume').remove();
2067
+ //Remove the loader for choose directory button
2068
+ $('div.dir-smush-button-wrap span.spinner').remove();
2069
+ // Allow to select a new directory
2070
+ $('button.wp-smush-browse').removeAttr('disabled');
2071
+ //Append the results
2072
+ if (!r.success) {
2073
+ //Append the error message before the buttons
2074
+ $('div.wp-smush-dir-desc').after(r.data.message);
2075
+ } else {
2076
+ //Append the image markup after the buttons
2077
+ $('div.wp-smush-scan-result div.content').html(r.data);
2078
+ $('div.wp-smush-scan-result').removeClass('hidden');
2079
+
2080
+ set_accordion();
2081
+ }
2082
+ }).done(function () {
2083
+ //Add Choose dir browser button
2084
+ add_dir_browser_button();
2085
+
2086
+ //Clone and add Smush button
2087
+ add_smush_button();
2088
+ });
2089
+
2090
+ });
2091
+
2092
+ if ($('div.smush-dir-savings').length > 0) {
2093
+ //Update Directory Smush, as soon as the page loads
2094
+ var stats_param = {
2095
+ action: 'get_dir_smush_stats'
2096
+ }
2097
+ $.get(ajaxurl, stats_param, function (r) {
2098
+
2099
+ //Hide the spinner
2100
+ $('div.smush-dir-savings span.spinner').hide();
2101
+
2102
+ //If there are no errors, and we have a message to display
2103
+ if (!r.success && 'undefined' != typeof ( r.data.message )) {
2104
+ $('div.wp-smush-scan-result div.content').prepend(r.data.message);
2105
+ return;
2106
+ }
2107
+
2108
+ //If there is no value in r
2109
+ if ('undefined' == typeof ( r.data) || 'undefined' == typeof ( r.data.dir_smush )) {
2110
+ //Append the text
2111
+ $('div.smush-dir-savings span.wp-smush-stats').append(wp_smush_msgs.ajax_error);
2112
+ $('div.smush-dir-savings span.wp-smush-stats span').hide();
2113
+ return;
2114
+ } else {
2115
+ //Update the stats
2116
+ update_cummulative_stats(r.data);
2117
+ }
2118
+
2119
+ });
2120
+ }
2121
+ //Close Directory smush modal, if pressed esc
2122
+ $(document).keyup(function (e) {
2123
+ if (e.keyCode === 27) {
2124
+ var modal = $('div.dev-overlay.wp-smush-list-dialog');
2125
+ //If the Directory dialog is not visible
2126
+ if (!modal.is(':visible')) {
2127
+ return;
2128
+ }
2129
+ modal.find('div.close').click();
2130
+
2131
+ }
2132
+ });
2133
+
2134
  });
2135
  (function ($) {
2136
  var Smush = function (element, options) {
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.5.3\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/wp-smushit\n"
7
- "POT-Creation-Date: 2017-01-06 06:34:05+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -25,14 +25,14 @@ 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:878
29
  msgid "Saving"
30
  msgstr ""
31
 
32
  #: assets/shared-ui/plugin-ui.php:301
33
  #: extras/dash-notice/wpmudev-dash-notification.php:248
34
  #: extras/dash-notice/wpmudev-dash-notification.php:289
35
- #: lib/class-wp-smush-ui.php:878
36
  msgid "Dismiss"
37
  msgstr ""
38
 
@@ -141,218 +141,240 @@ msgstr ""
141
  msgid "Rate %s"
142
  msgstr ""
143
 
144
- #: lib/class-wp-smush-admin.php:191
145
  msgid "Enable Network wide settings"
146
  msgstr ""
147
 
148
- #: lib/class-wp-smush-admin.php:192
149
  msgid "If disabled sub sites can override the individual Smush settings."
150
  msgstr ""
151
 
152
- #: lib/class-wp-smush-admin.php:195
153
  msgid "Automatically smush my images on upload"
154
  msgstr ""
155
 
156
- #: lib/class-wp-smush-admin.php:196
157
  msgid "When you upload images to the media library, we’ll automatically optimize them."
158
  msgstr ""
159
 
160
- #: lib/class-wp-smush-admin.php:199
161
  msgid "Preserve image EXIF data"
162
  msgstr ""
163
 
164
- #: lib/class-wp-smush-admin.php:200
165
  msgid "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."
166
  msgstr ""
167
 
168
- #: lib/class-wp-smush-admin.php:203
169
  msgid "Resize original images"
170
  msgstr ""
171
 
172
- #: lib/class-wp-smush-admin.php:204
173
  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."
174
  msgstr ""
175
 
176
- #: lib/class-wp-smush-admin.php:207
177
  msgid "Super-smush my images"
178
  msgstr ""
179
 
180
- #: lib/class-wp-smush-admin.php:208
181
  msgid "Compress images up to 2x more than regular smush with almost no visible drop in quality."
182
  msgstr ""
183
 
184
- #: lib/class-wp-smush-admin.php:211
185
  msgid "Include my original full-size images"
186
  msgstr ""
187
 
188
- #: lib/class-wp-smush-admin.php:212
189
  msgid "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."
190
  msgstr ""
191
 
192
- #: lib/class-wp-smush-admin.php:215
193
  msgid "Make a copy of my original images"
194
  msgstr ""
195
 
196
- #: lib/class-wp-smush-admin.php:216
197
  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."
198
  msgstr ""
199
 
200
- #: lib/class-wp-smush-admin.php:219
201
  msgid "Convert PNG to JPEG (lossy)"
202
  msgstr ""
203
 
204
- #: lib/class-wp-smush-admin.php:220
205
  msgid "When you compress a PNG file, Smush will check if converting the file to JPEG will further reduce its size. %s Note: PNGs with transparency will be ignored and Smush will only convert the file format if it results in a smaller file size. This will change the file’s name and extension, and any hard-coded URLs will need to be updated."
206
  msgstr ""
207
 
208
- #: lib/class-wp-smush-admin.php:227
209
  msgid "Enable NextGen Gallery integration"
210
  msgstr ""
211
 
212
- #: lib/class-wp-smush-admin.php:228
213
  msgid "Allow smushing images directly through NextGen Gallery settings."
214
  msgstr ""
215
 
216
- #: lib/class-wp-smush-admin.php:250 lib/class-wp-smush-ui.php:808
217
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:70
218
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:89
219
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:91
220
  msgid "WP Smush"
221
  msgstr ""
222
 
223
- #: lib/class-wp-smush-admin.php:358 lib/class-wp-smush.php:1039
224
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:158
225
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:275
226
  msgid "Super-Smush"
227
  msgstr ""
228
 
229
- #: lib/class-wp-smush-admin.php:359
230
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:159
231
  msgid "Smush Now"
232
  msgstr ""
233
 
234
- #: lib/class-wp-smush-admin.php:360
235
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:160
236
  msgid "{{errors}} image(s) were skipped due to an error."
237
  msgstr ""
238
 
239
- #: lib/class-wp-smush-admin.php:361
240
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:161
241
  msgid "All images are fully optimised."
242
  msgstr ""
243
 
244
- #: lib/class-wp-smush-admin.php:362
245
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:162
246
  msgid "Restoring image.."
247
  msgstr ""
248
 
249
- #: lib/class-wp-smush-admin.php:363
250
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:163
251
  msgid "Smushing image.."
252
  msgstr ""
253
 
254
- #: lib/class-wp-smush-admin.php:364
255
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:164
256
  msgid "Checking images.."
257
  msgstr ""
258
 
259
- #: lib/class-wp-smush-admin.php:365
260
  msgid "We successfully verified your membership, all the Pro features should work completely. "
261
  msgstr ""
262
 
263
- #: lib/class-wp-smush-admin.php:366
264
  msgid "Your membership couldn't be verified."
265
  msgstr ""
266
 
267
- #: lib/class-wp-smush-admin.php:577
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  msgid "Smush request timed out, You can try setting a higher value for `WP_SMUSH_API_TIMEOUT`."
269
  msgstr ""
270
 
271
- #: lib/class-wp-smush-admin.php:593
272
  msgid "You've smushed %d images in total."
273
  msgstr ""
274
 
275
- #: lib/class-wp-smush-admin.php:622 lib/class-wp-smush-nextgen.php:381
276
  msgid "You don't have permission to work with uploaded files."
277
  msgstr ""
278
 
279
- #: lib/class-wp-smush-admin.php:626 lib/class-wp-smush-nextgen.php:385
280
  msgid "No attachment ID was provided."
281
  msgstr ""
282
 
283
- #: lib/class-wp-smush-admin.php:639
284
  msgid "Attachment Skipped - Check `wp_smush_image` filter."
285
  msgstr ""
286
 
287
- #: lib/class-wp-smush-admin.php:786
288
  msgid "<strong>%d of %d images</strong> were sent for smushing:"
289
  msgstr ""
290
 
291
- #: lib/class-wp-smush-admin.php:1083 lib/class-wp-smush-admin.php:1096
292
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:336
293
  msgid "Bulk Smush Now"
294
  msgstr ""
295
 
296
- #: lib/class-wp-smush-admin.php:1090
297
- #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:340
298
- msgid "All Done!"
299
- msgstr ""
300
-
301
- #: lib/class-wp-smush-admin.php:1118 lib/class-wp-smush.php:1045
302
  msgid "Smushing in progress.."
303
  msgstr ""
304
 
305
- #: lib/class-wp-smush-admin.php:1124 lib/class-wp-smush.php:1064
306
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:255
307
  msgid "Smush Now!"
308
  msgstr ""
309
 
310
- #: lib/class-wp-smush-admin.php:1145
311
  msgid "Settings"
312
  msgstr ""
313
 
314
- #: lib/class-wp-smush-admin.php:1291
315
  msgid "Image not smushed, fields empty."
316
  msgstr ""
317
 
318
- #: lib/class-wp-smush-admin.php:1298 lib/class-wp-smush-nextgen.php:568
319
  msgid "Image couldn't be smushed as the nonce verification failed, try reloading the page."
320
  msgstr ""
321
 
322
- #: lib/class-wp-smush-admin.php:1315
323
  msgid "Unable to smush image"
324
  msgstr ""
325
 
326
- #: lib/class-wp-smush-admin.php:1340
327
  msgid "We haven’t found any images in your media library yet so there’s no smushing to be done!"
328
  msgstr ""
329
 
330
- #: lib/class-wp-smush-admin.php:1356
331
  msgid "Yay! All images are optimised as per your current settings."
332
  msgstr ""
333
 
334
- #: lib/class-wp-smush-admin.php:1528 lib/class-wp-smush-ui.php:783
335
  msgid "You have images that need smushing. %sBulk smush now!%s"
336
  msgstr ""
337
 
338
- #: lib/class-wp-smush-admin.php:1914
339
  msgid "Review your setting now."
340
  msgstr ""
341
 
342
- #: lib/class-wp-smush-admin.php:1915 lib/class-wp-smush-ui.php:671
343
- #: lib/class-wp-smush-ui.php:808
 
344
  msgid "WP Smush Pro"
345
  msgstr ""
346
 
347
- #: lib/class-wp-smush-admin.php:1916
348
- msgid "Welcome to the newest version of WP Smush! Auto-smushing on upload is lightning fast now that we handle all the smushing asynchronously."
349
  msgstr ""
350
 
351
- #: lib/class-wp-smush-admin.php:1919
352
  msgid " And as a multisite user, you can manage %sSmush settings%s globally across all sites!"
353
  msgstr ""
354
 
355
- #: lib/class-wp-smush-admin.php:1922
356
  msgid " %sFind out more here >>%s"
357
  msgstr ""
358
 
@@ -368,6 +390,104 @@ msgstr ""
368
  msgid "Unable to restore image"
369
  msgstr ""
370
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
371
  #: lib/class-wp-smush-nextgen.php:326
372
  msgid "We couldn't find the metadata for the image, possibly the image has been deleted."
373
  msgstr ""
@@ -388,15 +508,15 @@ msgstr ""
388
  msgid "I saved %s on my site with WP Smush ( %s ) - wanna make your website smaller and faster?"
389
  msgstr ""
390
 
391
- #: lib/class-wp-smush-share.php:35
392
  msgid "TWEET"
393
  msgstr ""
394
 
395
- #: lib/class-wp-smush-share.php:39
396
  msgid "SHARE"
397
  msgstr ""
398
 
399
- #: lib/class-wp-smush-share.php:43
400
  msgid "WhatsApp"
401
  msgstr ""
402
 
@@ -424,341 +544,327 @@ msgstr ""
424
  msgid "Media Library"
425
  msgstr ""
426
 
427
- #: lib/class-wp-smush-ui.php:90
428
- #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:482
429
- msgid "BULK SMUSH"
430
- msgstr ""
431
-
432
  #: lib/class-wp-smush-ui.php:104
433
  msgid "SETTINGS"
434
  msgstr ""
435
 
436
- #: lib/class-wp-smush-ui.php:119
437
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:502
438
  msgid "Lets you check if any images can be further optimised. Useful after changing settings."
439
  msgstr ""
440
 
441
- #: lib/class-wp-smush-ui.php:119
442
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:502
443
  msgid "RE-CHECK IMAGES"
444
  msgstr ""
445
 
446
- #: lib/class-wp-smush-ui.php:120
447
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:503
448
  msgid "STATS"
449
  msgstr ""
450
 
451
- #: lib/class-wp-smush-ui.php:123
452
  msgid "You've smushed %d images in total"
453
  msgstr ""
454
 
455
- #: lib/class-wp-smush-ui.php:148
456
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:531
457
  msgid "ATTACHMENTS SMUSHED"
458
  msgstr ""
459
 
460
- #: lib/class-wp-smush-ui.php:154
461
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:537
462
  msgid "TOTAL SAVINGS"
463
  msgstr ""
464
 
465
- #: lib/class-wp-smush-ui.php:170
466
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:553
467
  msgid "ATTACHMENTS SUPER-SMUSHED"
468
  msgstr ""
469
 
470
- #: lib/class-wp-smush-ui.php:175 lib/class-wp-smush-ui.php:189
471
  msgid "%sENABLE%s"
472
  msgstr ""
473
 
474
- #: lib/class-wp-smush-ui.php:182
475
  msgid "RESIZE SAVINGS"
476
  msgstr ""
477
 
478
- #: lib/class-wp-smush-ui.php:199
479
  msgid "PNG TO JPEG SAVINGS"
480
  msgstr ""
481
 
482
- #: lib/class-wp-smush-ui.php:229
483
  msgid "%sTRY PRO FREE%s"
484
  msgstr ""
485
 
486
- #: lib/class-wp-smush-ui.php:231
487
  msgid "BASED ON AVERAGE SAVINGS IF YOU UPGRADE TO PRO"
488
  msgstr ""
489
 
490
- #: lib/class-wp-smush-ui.php:232
491
  msgid "PRO SAVINGS ESTIMATE"
492
  msgstr ""
493
 
494
- #: lib/class-wp-smush-ui.php:277
495
  msgid "%sTRY PRO FEATURES FREE%s"
496
  msgstr ""
497
 
498
- #: lib/class-wp-smush-ui.php:279
499
  msgid "ADVANCED SETTINGS"
500
  msgstr ""
501
 
502
- #: lib/class-wp-smush-ui.php:423
503
  msgid "The following image sizes will be optimised by WP Smush:"
504
  msgstr ""
505
 
506
- #: lib/class-wp-smush-ui.php:473
507
  msgid "Width"
508
  msgstr ""
509
 
510
- #: lib/class-wp-smush-ui.php:476
511
  msgid "Height"
512
  msgstr ""
513
 
514
- #: lib/class-wp-smush-ui.php:479
515
  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."
516
  msgstr ""
517
 
518
- #: lib/class-wp-smush-ui.php:480
519
  msgid "Just to let you know, the width you've entered is less than your largest thumbnail and may result in pixelation."
520
  msgstr ""
521
 
522
- #: lib/class-wp-smush-ui.php:481
523
  msgid "Just to let you know, the height you’ve entered is less than your largest thumbnail and may result in pixelation."
524
  msgstr ""
525
 
526
- #: lib/class-wp-smush-ui.php:608
527
  msgid "BOOST YOUR PERFORMANCE - HUMMINGBIRD"
528
  msgstr ""
529
 
530
- #: lib/class-wp-smush-ui.php:635
531
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:423
532
  msgid "No attachments found - Upload some images"
533
  msgstr ""
534
 
535
- #: lib/class-wp-smush-ui.php:637
536
  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!"
537
  msgstr ""
538
 
539
- #: lib/class-wp-smush-ui.php:640
540
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:428
541
  msgid "UPLOAD IMAGES"
542
  msgstr ""
543
 
544
- #: lib/class-wp-smush-ui.php:645
545
- #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:433
546
- msgid "All images are smushed and up to date. Awesome!"
547
- msgstr ""
548
-
549
- #: lib/class-wp-smush-ui.php:650
550
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:438
551
  msgid "BULK SMUSH NOW"
552
  msgstr ""
553
 
554
- #: lib/class-wp-smush-ui.php:669
555
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:446
556
  msgid "%s, you have %s%s%d%s image%s that needs smushing!"
557
  msgid_plural "%s, you have %s%s%d%s images%s that need smushing!"
558
  msgstr[0] ""
559
  msgstr[1] ""
560
 
561
- #: lib/class-wp-smush-ui.php:671
562
- msgid "You can %sUpgrade to Pro%s to bulk smush all your images with one click."
563
  msgstr ""
564
 
565
- #: lib/class-wp-smush-ui.php:672
566
  msgid "Free users can smush 50 images with each click."
567
  msgstr ""
568
 
569
- #: lib/class-wp-smush-ui.php:681
570
  msgid "Enable Super-smush in the Settings area to get even more savings with almost no noticeable quality loss."
571
  msgstr ""
572
 
573
- #: lib/class-wp-smush-ui.php:704
574
  msgid "%sBulk smush is currently running.%s You need to keep this page open for the process to complete."
575
  msgstr ""
576
 
577
- #: lib/class-wp-smush-ui.php:714
578
  msgid "%s%d%s of %d attachments have been smushed."
579
  msgstr ""
580
 
581
- #: lib/class-wp-smush-ui.php:719
582
- msgid "CANCEL"
583
- msgstr ""
584
-
585
- #: lib/class-wp-smush-ui.php:755
586
  msgid "%s, you have %s%s%d%s image%s that needs re-compressing!"
587
  msgid_plural "%s, you have %s%s%d%s images%s that need re-compressing!"
588
  msgstr[0] ""
589
  msgstr[1] ""
590
 
591
- #: lib/class-wp-smush-ui.php:756
592
  msgid "Skip"
593
  msgstr ""
594
 
595
- #: lib/class-wp-smush-ui.php:776
596
  msgid "Your settings have been updated!"
597
  msgstr ""
598
 
599
- #: lib/class-wp-smush-ui.php:810
600
  msgid "Automatic smushing is %senabled%s. Newly uploaded images will be automagically compressed."
601
  msgstr ""
602
 
603
- #: lib/class-wp-smush-ui.php:810
604
  msgid "Automatic smushing is %sdisabled%s. Newly uploaded images will need to be manually smushed."
605
  msgstr ""
606
 
607
- #: lib/class-wp-smush-ui.php:850
608
  msgid "Thanks for installing Smush. We hope you like it!"
609
  msgstr ""
610
 
611
- #: lib/class-wp-smush-ui.php:851
612
  msgid "And hey, if you do, you can now try out Smush Pro for double the smushy goodness (benchmarked), entirely for free!"
613
  msgstr ""
614
 
615
- #: lib/class-wp-smush-ui.php:852 lib/class-wp-smush-ui.php:856
616
  msgid "Try Smush Pro for Free"
617
  msgstr ""
618
 
619
- #: lib/class-wp-smush-ui.php:854
620
  msgid "Thanks for updating Smush. Did you know that you can now try the Smush Pro for FREE?!"
621
  msgstr ""
622
 
623
- #: lib/class-wp-smush-ui.php:855
624
  msgid "Yep, Super Smush your images for double the savings, save originals and batch Smush thousands of images all at once.... no charge!"
625
  msgstr ""
626
 
627
- #: lib/class-wp-smush-ui.php:902
628
  msgid "Did you know WP Smush Pro delivers up to 2x better compression, allows you to smush your originals and removes any bulk smushing limits? – %sTry it absolutely FREE%s"
629
  msgstr ""
630
 
631
- #: lib/class-wp-smush-ui.php:902
632
  msgid "Try WP Smush Pro for FREE"
633
  msgstr ""
634
 
635
- #: lib/class-wp-smush-ui.php:925
636
  msgid "Validating.."
637
  msgstr ""
638
 
639
- #: lib/class-wp-smush-ui.php:927
640
  msgid "It looks like Smush couldn’t verify your WPMU DEV membership so Pro features like Super-Smush may not work correctly. If you think this is an error, run a %sre-check%s or get in touch with our %ssupport team%s."
641
  msgstr ""
642
 
643
- #: lib/class-wp-smush-ui.php:949
644
  msgid "UPDATE SETTINGS"
645
  msgstr ""
646
 
647
- #: lib/class-wp-smush-ui.php:979
648
  msgid "Smush settings were updated, performing a quick scan to check if any of the images need to be Smushed again."
649
  msgstr ""
650
 
651
- #: lib/class-wp-smush.php:187
652
  msgid "File path is empty"
653
  msgstr ""
654
 
655
- #: lib/class-wp-smush.php:190
656
  msgid "Could not find %s"
657
  msgstr ""
658
 
659
- #: lib/class-wp-smush.php:193
660
  msgid "%s is not writable"
661
  msgstr ""
662
 
663
- #: lib/class-wp-smush.php:203
664
  msgid "Skipped (%s), image not found. Attachment: %s"
665
  msgstr ""
666
 
667
- #: lib/class-wp-smush.php:206
668
  msgid "Skipped (%s), size limit exceeded. Attachment: %s"
669
  msgstr ""
670
 
671
- #: lib/class-wp-smush.php:224
672
  msgid "Unknown API error"
673
  msgstr ""
674
 
675
- #: lib/class-wp-smush.php:691
676
  msgid "Error posting to API: %s"
677
  msgstr ""
678
 
679
- #: lib/class-wp-smush.php:697
680
  msgid "Error posting to API: %s %s"
681
  msgstr ""
682
 
683
- #: lib/class-wp-smush.php:714
684
  msgid "Smush data corrupted, try again."
685
  msgstr ""
686
 
687
- #: lib/class-wp-smush.php:734
688
  msgid "Image couldn't be smushed"
689
  msgstr ""
690
 
691
- #: lib/class-wp-smush.php:955 lib/class-wp-smush.php:959
692
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:193
693
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:196
694
  msgid "Already Optimized"
695
  msgstr ""
696
 
697
- #: lib/class-wp-smush.php:968
698
  msgid "%d images reduced "
699
  msgstr ""
700
 
701
- #: lib/class-wp-smush.php:968
702
  msgid "Reduced "
703
  msgstr ""
704
 
705
- #: lib/class-wp-smush.php:972
706
  msgid "by %s %s"
707
  msgstr ""
708
 
709
- #: lib/class-wp-smush.php:978
710
  msgid "<br /> Image Size: %s"
711
  msgstr ""
712
 
713
- #: lib/class-wp-smush.php:1014
714
  msgid "Detailed stats for all the image sizes"
715
  msgstr ""
716
 
717
- #: lib/class-wp-smush.php:1014
718
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:236
719
  msgid "Smush stats"
720
  msgstr ""
721
 
722
- #: lib/class-wp-smush.php:1058
723
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:249
724
  msgid "Not processed"
725
  msgstr ""
726
 
727
- #: lib/class-wp-smush.php:1367
728
  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."
729
  msgstr ""
730
 
731
- #: lib/class-wp-smush.php:1370
732
  msgid "Image couldn't be smushed as it exceeded the 1Mb size limit, Pro users can smush images with size upto 32Mb."
733
  msgstr ""
734
 
735
- #: lib/class-wp-smush.php:1372
736
  msgid " Skipped"
737
  msgstr ""
738
 
739
- #: lib/class-wp-smush.php:1394
740
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:432
741
  msgid "Image size"
742
  msgstr ""
743
 
744
- #: lib/class-wp-smush.php:1395
745
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:433
746
  msgid "Savings"
747
  msgstr ""
748
 
749
- #: lib/class-wp-smush.php:1602
750
  msgid "Restore original image."
751
  msgstr ""
752
 
753
- #: lib/class-wp-smush.php:1602
754
  msgid "Restore image"
755
  msgstr ""
756
 
757
- #: lib/class-wp-smush.php:1650
758
  msgid "Smush image including original file."
759
  msgstr ""
760
 
761
- #: lib/class-wp-smush.php:1650
762
  msgid "Resmush image"
763
  msgstr ""
764
 
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.6.1\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/wp-smushit\n"
7
+ "POT-Creation-Date: 2017-03-06 09:20:46+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
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:884
29
  msgid "Saving"
30
  msgstr ""
31
 
32
  #: assets/shared-ui/plugin-ui.php:301
33
  #: extras/dash-notice/wpmudev-dash-notification.php:248
34
  #: extras/dash-notice/wpmudev-dash-notification.php:289
35
+ #: lib/class-wp-smush-ui.php:884
36
  msgid "Dismiss"
37
  msgstr ""
38
 
141
  msgid "Rate %s"
142
  msgstr ""
143
 
144
+ #: lib/class-wp-smush-admin.php:203
145
  msgid "Enable Network wide settings"
146
  msgstr ""
147
 
148
+ #: lib/class-wp-smush-admin.php:204
149
  msgid "If disabled sub sites can override the individual Smush settings."
150
  msgstr ""
151
 
152
+ #: lib/class-wp-smush-admin.php:207
153
  msgid "Automatically smush my images on upload"
154
  msgstr ""
155
 
156
+ #: lib/class-wp-smush-admin.php:208
157
  msgid "When you upload images to the media library, we’ll automatically optimize them."
158
  msgstr ""
159
 
160
+ #: lib/class-wp-smush-admin.php:211
161
  msgid "Preserve image EXIF data"
162
  msgstr ""
163
 
164
+ #: lib/class-wp-smush-admin.php:212
165
  msgid "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."
166
  msgstr ""
167
 
168
+ #: lib/class-wp-smush-admin.php:215
169
  msgid "Resize original images"
170
  msgstr ""
171
 
172
+ #: lib/class-wp-smush-admin.php:216
173
  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."
174
  msgstr ""
175
 
176
+ #: lib/class-wp-smush-admin.php:219
177
  msgid "Super-smush my images"
178
  msgstr ""
179
 
180
+ #: lib/class-wp-smush-admin.php:220
181
  msgid "Compress images up to 2x more than regular smush with almost no visible drop in quality."
182
  msgstr ""
183
 
184
+ #: lib/class-wp-smush-admin.php:223
185
  msgid "Include my original full-size images"
186
  msgstr ""
187
 
188
+ #: lib/class-wp-smush-admin.php:224
189
  msgid "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."
190
  msgstr ""
191
 
192
+ #: lib/class-wp-smush-admin.php:227
193
  msgid "Make a copy of my original images"
194
  msgstr ""
195
 
196
+ #: lib/class-wp-smush-admin.php:228
197
  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."
198
  msgstr ""
199
 
200
+ #: lib/class-wp-smush-admin.php:231
201
  msgid "Convert PNG to JPEG (lossy)"
202
  msgstr ""
203
 
204
+ #: lib/class-wp-smush-admin.php:232
205
  msgid "When you compress a PNG file, Smush will check if converting the file to JPEG will further reduce its size. %s Note: PNGs with transparency will be ignored and Smush will only convert the file format if it results in a smaller file size. This will change the file’s name and extension, and any hard-coded URLs will need to be updated."
206
  msgstr ""
207
 
208
+ #: lib/class-wp-smush-admin.php:239
209
  msgid "Enable NextGen Gallery integration"
210
  msgstr ""
211
 
212
+ #: lib/class-wp-smush-admin.php:240
213
  msgid "Allow smushing images directly through NextGen Gallery settings."
214
  msgstr ""
215
 
216
+ #: lib/class-wp-smush-admin.php:262 lib/class-wp-smush-ui.php:817
217
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:70
218
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:89
219
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:91
220
  msgid "WP Smush"
221
  msgstr ""
222
 
223
+ #: lib/class-wp-smush-admin.php:392 lib/class-wp-smush.php:1045
224
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:158
225
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:275
226
  msgid "Super-Smush"
227
  msgstr ""
228
 
229
+ #: lib/class-wp-smush-admin.php:393
230
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:159
231
  msgid "Smush Now"
232
  msgstr ""
233
 
234
+ #: lib/class-wp-smush-admin.php:394
235
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:160
236
  msgid "{{errors}} image(s) were skipped due to an error."
237
  msgstr ""
238
 
239
+ #: lib/class-wp-smush-admin.php:395
240
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:161
241
  msgid "All images are fully optimised."
242
  msgstr ""
243
 
244
+ #: lib/class-wp-smush-admin.php:396
245
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:162
246
  msgid "Restoring image.."
247
  msgstr ""
248
 
249
+ #: lib/class-wp-smush-admin.php:397
250
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:163
251
  msgid "Smushing image.."
252
  msgstr ""
253
 
254
+ #: lib/class-wp-smush-admin.php:398
255
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:164
256
  msgid "Checking images.."
257
  msgstr ""
258
 
259
+ #: lib/class-wp-smush-admin.php:399
260
  msgid "We successfully verified your membership, all the Pro features should work completely. "
261
  msgstr ""
262
 
263
+ #: lib/class-wp-smush-admin.php:400
264
  msgid "Your membership couldn't be verified."
265
  msgstr ""
266
 
267
+ #: lib/class-wp-smush-admin.php:401
268
+ msgid "Missing file path."
269
+ msgstr ""
270
+
271
+ #: lib/class-wp-smush-admin.php:403
272
+ msgid "image could not be smushed."
273
+ msgstr ""
274
+
275
+ #: lib/class-wp-smush-admin.php:404
276
+ msgid "images could not be smushed."
277
+ msgstr ""
278
+
279
+ #: lib/class-wp-smush-admin.php:405
280
+ msgid "Already Optimised"
281
+ msgstr ""
282
+
283
+ #: lib/class-wp-smush-admin.php:406
284
+ msgid "Ajax Error"
285
+ msgstr ""
286
+
287
+ #: lib/class-wp-smush-admin.php:407 lib/class-wp-smush-admin.php:408
288
+ #: lib/class-wp-smush-admin.php:1140
289
+ #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:340
290
+ msgid "All Done!"
291
+ msgstr ""
292
+
293
+ #: lib/class-wp-smush-admin.php:624
294
  msgid "Smush request timed out, You can try setting a higher value for `WP_SMUSH_API_TIMEOUT`."
295
  msgstr ""
296
 
297
+ #: lib/class-wp-smush-admin.php:640 lib/class-wp-smush-dir.php:1219
298
  msgid "You've smushed %d images in total."
299
  msgstr ""
300
 
301
+ #: lib/class-wp-smush-admin.php:669 lib/class-wp-smush-nextgen.php:381
302
  msgid "You don't have permission to work with uploaded files."
303
  msgstr ""
304
 
305
+ #: lib/class-wp-smush-admin.php:673 lib/class-wp-smush-nextgen.php:385
306
  msgid "No attachment ID was provided."
307
  msgstr ""
308
 
309
+ #: lib/class-wp-smush-admin.php:686
310
  msgid "Attachment Skipped - Check `wp_smush_image` filter."
311
  msgstr ""
312
 
313
+ #: lib/class-wp-smush-admin.php:836
314
  msgid "<strong>%d of %d images</strong> were sent for smushing:"
315
  msgstr ""
316
 
317
+ #: lib/class-wp-smush-admin.php:1133 lib/class-wp-smush-admin.php:1146
318
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:336
319
  msgid "Bulk Smush Now"
320
  msgstr ""
321
 
322
+ #: lib/class-wp-smush-admin.php:1168 lib/class-wp-smush.php:1051
 
 
 
 
 
323
  msgid "Smushing in progress.."
324
  msgstr ""
325
 
326
+ #: lib/class-wp-smush-admin.php:1174 lib/class-wp-smush.php:1070
327
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:255
328
  msgid "Smush Now!"
329
  msgstr ""
330
 
331
+ #: lib/class-wp-smush-admin.php:1195
332
  msgid "Settings"
333
  msgstr ""
334
 
335
+ #: lib/class-wp-smush-admin.php:1341
336
  msgid "Image not smushed, fields empty."
337
  msgstr ""
338
 
339
+ #: lib/class-wp-smush-admin.php:1348 lib/class-wp-smush-nextgen.php:568
340
  msgid "Image couldn't be smushed as the nonce verification failed, try reloading the page."
341
  msgstr ""
342
 
343
+ #: lib/class-wp-smush-admin.php:1365
344
  msgid "Unable to smush image"
345
  msgstr ""
346
 
347
+ #: lib/class-wp-smush-admin.php:1390
348
  msgid "We haven’t found any images in your media library yet so there’s no smushing to be done!"
349
  msgstr ""
350
 
351
+ #: lib/class-wp-smush-admin.php:1406
352
  msgid "Yay! All images are optimised as per your current settings."
353
  msgstr ""
354
 
355
+ #: lib/class-wp-smush-admin.php:1578 lib/class-wp-smush-ui.php:792
356
  msgid "You have images that need smushing. %sBulk smush now!%s"
357
  msgstr ""
358
 
359
+ #: lib/class-wp-smush-admin.php:1929
360
  msgid "Review your setting now."
361
  msgstr ""
362
 
363
+ #: lib/class-wp-smush-admin.php:1930 lib/class-wp-smush-dir.php:238
364
+ #: lib/class-wp-smush-dir.php:264 lib/class-wp-smush-ui.php:680
365
+ #: lib/class-wp-smush-ui.php:817
366
  msgid "WP Smush Pro"
367
  msgstr ""
368
 
369
+ #: lib/class-wp-smush-admin.php:1931
370
+ msgid "Welcome to the newest version of WP Smush! In this update we've added the ability to bulk smush images in directories outside your uploads folder."
371
  msgstr ""
372
 
373
+ #: lib/class-wp-smush-admin.php:1934
374
  msgid " And as a multisite user, you can manage %sSmush settings%s globally across all sites!"
375
  msgstr ""
376
 
377
+ #: lib/class-wp-smush-admin.php:1937
378
  msgid " %sFind out more here >>%s"
379
  msgstr ""
380
 
390
  msgid "Unable to restore image"
391
  msgstr ""
392
 
393
+ #: lib/class-wp-smush-dir.php:91
394
+ msgid "DIRECTORY SMUSH SAVINGS"
395
+ msgstr ""
396
+
397
+ #: lib/class-wp-smush-dir.php:99
398
+ msgid "Updating Stats"
399
+ msgstr ""
400
+
401
+ #: lib/class-wp-smush-dir.php:208
402
+ msgid "RESUME LAST SCAN"
403
+ msgstr ""
404
+
405
+ #: lib/class-wp-smush-dir.php:240
406
+ msgid "DIRECTORY SMUSH"
407
+ msgstr ""
408
+
409
+ #: lib/class-wp-smush-dir.php:245
410
+ msgid "In addition to smushing your media uploads, you may want to also smush images living outside your uploads directory. Simply add any directories you wish to smush and bulk smush away!"
411
+ msgstr ""
412
+
413
+ #: lib/class-wp-smush-dir.php:258 lib/class-wp-smush-ui.php:654
414
+ #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:433
415
+ msgid "All images are smushed and up to date. Awesome!"
416
+ msgstr ""
417
+
418
+ #: lib/class-wp-smush-dir.php:261
419
+ msgid "%s/%s image(s) were successfully smushed, however %s image(s) could not be smushed due to an error."
420
+ msgstr ""
421
+
422
+ #: lib/class-wp-smush-dir.php:264
423
+ msgid " %sUpgrade to pro%s to bulk smush all your directory images with one click. Free users can smush 50 images with each click."
424
+ msgstr ""
425
+
426
+ #: lib/class-wp-smush-dir.php:268 lib/class-wp-smush-ui.php:90
427
+ #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:482
428
+ msgid "BULK SMUSH"
429
+ msgstr ""
430
+
431
+ #: lib/class-wp-smush-dir.php:270
432
+ msgid "Click to stop the directory smushing process."
433
+ msgstr ""
434
+
435
+ #: lib/class-wp-smush-dir.php:271 lib/class-wp-smush-ui.php:728
436
+ msgid "CANCEL"
437
+ msgstr ""
438
+
439
+ #: lib/class-wp-smush-dir.php:279
440
+ msgid "CHOOSE DIRECTORY"
441
+ msgstr ""
442
+
443
+ #: lib/class-wp-smush-dir.php:288
444
+ msgid "Directory list"
445
+ msgstr ""
446
+
447
+ #: lib/class-wp-smush-dir.php:291
448
+ msgid "Choose the folder you wish to smush."
449
+ msgstr ""
450
+
451
+ #: lib/class-wp-smush-dir.php:295
452
+ msgid "Smush will also include any images in sub folders of your selected folder."
453
+ msgstr ""
454
+
455
+ #: lib/class-wp-smush-dir.php:298
456
+ msgid "ADD DIRECTORY"
457
+ msgstr ""
458
+
459
+ #: lib/class-wp-smush-dir.php:461
460
+ msgid "Exclude directory from Smush List"
461
+ msgstr ""
462
+
463
+ #: lib/class-wp-smush-dir.php:566
464
+ msgid "We could not find any images in the selected directory."
465
+ msgstr ""
466
+
467
+ #: lib/class-wp-smush-dir.php:877
468
+ msgid "%d images"
469
+ msgstr ""
470
+
471
+ #: lib/class-wp-smush-dir.php:906
472
+ msgid "Waiting.."
473
+ msgstr ""
474
+
475
+ #: lib/class-wp-smush-dir.php:1020
476
+ msgid "Incorrect image id"
477
+ msgstr ""
478
+
479
+ #: lib/class-wp-smush-dir.php:1050
480
+ msgid "Could not find image id in last scanned images"
481
+ msgstr ""
482
+
483
+ #: lib/class-wp-smush-dir.php:1063
484
+ msgid "Image couldn't be optimised"
485
+ msgstr ""
486
+
487
+ #: lib/class-wp-smush-dir.php:1159
488
+ msgid "We were unable to retrieve the image list from last scan, please continue with a latest scan"
489
+ msgstr ""
490
+
491
  #: lib/class-wp-smush-nextgen.php:326
492
  msgid "We couldn't find the metadata for the image, possibly the image has been deleted."
493
  msgstr ""
508
  msgid "I saved %s on my site with WP Smush ( %s ) - wanna make your website smaller and faster?"
509
  msgstr ""
510
 
511
+ #: lib/class-wp-smush-share.php:34
512
  msgid "TWEET"
513
  msgstr ""
514
 
515
+ #: lib/class-wp-smush-share.php:38
516
  msgid "SHARE"
517
  msgstr ""
518
 
519
+ #: lib/class-wp-smush-share.php:42
520
  msgid "WhatsApp"
521
  msgstr ""
522
 
544
  msgid "Media Library"
545
  msgstr ""
546
 
 
 
 
 
 
547
  #: lib/class-wp-smush-ui.php:104
548
  msgid "SETTINGS"
549
  msgstr ""
550
 
551
+ #: lib/class-wp-smush-ui.php:122
552
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:502
553
  msgid "Lets you check if any images can be further optimised. Useful after changing settings."
554
  msgstr ""
555
 
556
+ #: lib/class-wp-smush-ui.php:122
557
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:502
558
  msgid "RE-CHECK IMAGES"
559
  msgstr ""
560
 
561
+ #: lib/class-wp-smush-ui.php:123
562
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:503
563
  msgid "STATS"
564
  msgstr ""
565
 
566
+ #: lib/class-wp-smush-ui.php:126
567
  msgid "You've smushed %d images in total"
568
  msgstr ""
569
 
570
+ #: lib/class-wp-smush-ui.php:151
571
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:531
572
  msgid "ATTACHMENTS SMUSHED"
573
  msgstr ""
574
 
575
+ #: lib/class-wp-smush-ui.php:157
576
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:537
577
  msgid "TOTAL SAVINGS"
578
  msgstr ""
579
 
580
+ #: lib/class-wp-smush-ui.php:173
581
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:553
582
  msgid "ATTACHMENTS SUPER-SMUSHED"
583
  msgstr ""
584
 
585
+ #: lib/class-wp-smush-ui.php:178 lib/class-wp-smush-ui.php:192
586
  msgid "%sENABLE%s"
587
  msgstr ""
588
 
589
+ #: lib/class-wp-smush-ui.php:185
590
  msgid "RESIZE SAVINGS"
591
  msgstr ""
592
 
593
+ #: lib/class-wp-smush-ui.php:203
594
  msgid "PNG TO JPEG SAVINGS"
595
  msgstr ""
596
 
597
+ #: lib/class-wp-smush-ui.php:237
598
  msgid "%sTRY PRO FREE%s"
599
  msgstr ""
600
 
601
+ #: lib/class-wp-smush-ui.php:239
602
  msgid "BASED ON AVERAGE SAVINGS IF YOU UPGRADE TO PRO"
603
  msgstr ""
604
 
605
+ #: lib/class-wp-smush-ui.php:240
606
  msgid "PRO SAVINGS ESTIMATE"
607
  msgstr ""
608
 
609
+ #: lib/class-wp-smush-ui.php:284
610
  msgid "%sTRY PRO FEATURES FREE%s"
611
  msgstr ""
612
 
613
+ #: lib/class-wp-smush-ui.php:286
614
  msgid "ADVANCED SETTINGS"
615
  msgstr ""
616
 
617
+ #: lib/class-wp-smush-ui.php:430
618
  msgid "The following image sizes will be optimised by WP Smush:"
619
  msgstr ""
620
 
621
+ #: lib/class-wp-smush-ui.php:480
622
  msgid "Width"
623
  msgstr ""
624
 
625
+ #: lib/class-wp-smush-ui.php:483
626
  msgid "Height"
627
  msgstr ""
628
 
629
+ #: lib/class-wp-smush-ui.php:486
630
  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."
631
  msgstr ""
632
 
633
+ #: lib/class-wp-smush-ui.php:487
634
  msgid "Just to let you know, the width you've entered is less than your largest thumbnail and may result in pixelation."
635
  msgstr ""
636
 
637
+ #: lib/class-wp-smush-ui.php:488
638
  msgid "Just to let you know, the height you’ve entered is less than your largest thumbnail and may result in pixelation."
639
  msgstr ""
640
 
641
+ #: lib/class-wp-smush-ui.php:617
642
  msgid "BOOST YOUR PERFORMANCE - HUMMINGBIRD"
643
  msgstr ""
644
 
645
+ #: lib/class-wp-smush-ui.php:644
646
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:423
647
  msgid "No attachments found - Upload some images"
648
  msgstr ""
649
 
650
+ #: lib/class-wp-smush-ui.php:646
651
  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!"
652
  msgstr ""
653
 
654
+ #: lib/class-wp-smush-ui.php:649
655
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:428
656
  msgid "UPLOAD IMAGES"
657
  msgstr ""
658
 
659
+ #: lib/class-wp-smush-ui.php:659
 
 
 
 
 
660
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:438
661
  msgid "BULK SMUSH NOW"
662
  msgstr ""
663
 
664
+ #: lib/class-wp-smush-ui.php:678
665
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:446
666
  msgid "%s, you have %s%s%d%s image%s that needs smushing!"
667
  msgid_plural "%s, you have %s%s%d%s images%s that need smushing!"
668
  msgstr[0] ""
669
  msgstr[1] ""
670
 
671
+ #: lib/class-wp-smush-ui.php:680
672
+ msgid "%sUpgrade to Pro%s to bulk smush all your images with one click."
673
  msgstr ""
674
 
675
+ #: lib/class-wp-smush-ui.php:681
676
  msgid "Free users can smush 50 images with each click."
677
  msgstr ""
678
 
679
+ #: lib/class-wp-smush-ui.php:690
680
  msgid "Enable Super-smush in the Settings area to get even more savings with almost no noticeable quality loss."
681
  msgstr ""
682
 
683
+ #: lib/class-wp-smush-ui.php:713
684
  msgid "%sBulk smush is currently running.%s You need to keep this page open for the process to complete."
685
  msgstr ""
686
 
687
+ #: lib/class-wp-smush-ui.php:723
688
  msgid "%s%d%s of %d attachments have been smushed."
689
  msgstr ""
690
 
691
+ #: lib/class-wp-smush-ui.php:764
 
 
 
 
692
  msgid "%s, you have %s%s%d%s image%s that needs re-compressing!"
693
  msgid_plural "%s, you have %s%s%d%s images%s that need re-compressing!"
694
  msgstr[0] ""
695
  msgstr[1] ""
696
 
697
+ #: lib/class-wp-smush-ui.php:765
698
  msgid "Skip"
699
  msgstr ""
700
 
701
+ #: lib/class-wp-smush-ui.php:785
702
  msgid "Your settings have been updated!"
703
  msgstr ""
704
 
705
+ #: lib/class-wp-smush-ui.php:819
706
  msgid "Automatic smushing is %senabled%s. Newly uploaded images will be automagically compressed."
707
  msgstr ""
708
 
709
+ #: lib/class-wp-smush-ui.php:819
710
  msgid "Automatic smushing is %sdisabled%s. Newly uploaded images will need to be manually smushed."
711
  msgstr ""
712
 
713
+ #: lib/class-wp-smush-ui.php:857
714
  msgid "Thanks for installing Smush. We hope you like it!"
715
  msgstr ""
716
 
717
+ #: lib/class-wp-smush-ui.php:858
718
  msgid "And hey, if you do, you can now try out Smush Pro for double the smushy goodness (benchmarked), entirely for free!"
719
  msgstr ""
720
 
721
+ #: lib/class-wp-smush-ui.php:859 lib/class-wp-smush-ui.php:863
722
  msgid "Try Smush Pro for Free"
723
  msgstr ""
724
 
725
+ #: lib/class-wp-smush-ui.php:861
726
  msgid "Thanks for updating Smush. Did you know that you can now try the Smush Pro for FREE?!"
727
  msgstr ""
728
 
729
+ #: lib/class-wp-smush-ui.php:862
730
  msgid "Yep, Super Smush your images for double the savings, save originals and batch Smush thousands of images all at once.... no charge!"
731
  msgstr ""
732
 
733
+ #: lib/class-wp-smush-ui.php:911
734
  msgid "Did you know WP Smush Pro delivers up to 2x better compression, allows you to smush your originals and removes any bulk smushing limits? – %sTry it absolutely FREE%s"
735
  msgstr ""
736
 
737
+ #: lib/class-wp-smush-ui.php:911
738
  msgid "Try WP Smush Pro for FREE"
739
  msgstr ""
740
 
741
+ #: lib/class-wp-smush-ui.php:934
742
  msgid "Validating.."
743
  msgstr ""
744
 
745
+ #: lib/class-wp-smush-ui.php:936
746
  msgid "It looks like Smush couldn’t verify your WPMU DEV membership so Pro features like Super-Smush may not work correctly. If you think this is an error, run a %sre-check%s or get in touch with our %ssupport team%s."
747
  msgstr ""
748
 
749
+ #: lib/class-wp-smush-ui.php:958
750
  msgid "UPDATE SETTINGS"
751
  msgstr ""
752
 
753
+ #: lib/class-wp-smush-ui.php:988
754
  msgid "Smush settings were updated, performing a quick scan to check if any of the images need to be Smushed again."
755
  msgstr ""
756
 
757
+ #: lib/class-wp-smush.php:195
758
  msgid "File path is empty"
759
  msgstr ""
760
 
761
+ #: lib/class-wp-smush.php:198
762
  msgid "Could not find %s"
763
  msgstr ""
764
 
765
+ #: lib/class-wp-smush.php:201
766
  msgid "%s is not writable"
767
  msgstr ""
768
 
769
+ #: lib/class-wp-smush.php:211
770
  msgid "Skipped (%s), image not found. Attachment: %s"
771
  msgstr ""
772
 
773
+ #: lib/class-wp-smush.php:214
774
  msgid "Skipped (%s), size limit exceeded. Attachment: %s"
775
  msgstr ""
776
 
777
+ #: lib/class-wp-smush.php:232
778
  msgid "Unknown API error"
779
  msgstr ""
780
 
781
+ #: lib/class-wp-smush.php:697
782
  msgid "Error posting to API: %s"
783
  msgstr ""
784
 
785
+ #: lib/class-wp-smush.php:703
786
  msgid "Error posting to API: %s %s"
787
  msgstr ""
788
 
789
+ #: lib/class-wp-smush.php:720
790
  msgid "Smush data corrupted, try again."
791
  msgstr ""
792
 
793
+ #: lib/class-wp-smush.php:740
794
  msgid "Image couldn't be smushed"
795
  msgstr ""
796
 
797
+ #: lib/class-wp-smush.php:961 lib/class-wp-smush.php:965
798
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:193
799
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:196
800
  msgid "Already Optimized"
801
  msgstr ""
802
 
803
+ #: lib/class-wp-smush.php:974
804
  msgid "%d images reduced "
805
  msgstr ""
806
 
807
+ #: lib/class-wp-smush.php:974
808
  msgid "Reduced "
809
  msgstr ""
810
 
811
+ #: lib/class-wp-smush.php:978
812
  msgid "by %s %s"
813
  msgstr ""
814
 
815
+ #: lib/class-wp-smush.php:984
816
  msgid "<br /> Image Size: %s"
817
  msgstr ""
818
 
819
+ #: lib/class-wp-smush.php:1020
820
  msgid "Detailed stats for all the image sizes"
821
  msgstr ""
822
 
823
+ #: lib/class-wp-smush.php:1020
824
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:236
825
  msgid "Smush stats"
826
  msgstr ""
827
 
828
+ #: lib/class-wp-smush.php:1064
829
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:249
830
  msgid "Not processed"
831
  msgstr ""
832
 
833
+ #: lib/class-wp-smush.php:1373
834
  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."
835
  msgstr ""
836
 
837
+ #: lib/class-wp-smush.php:1376
838
  msgid "Image couldn't be smushed as it exceeded the 1Mb size limit, Pro users can smush images with size upto 32Mb."
839
  msgstr ""
840
 
841
+ #: lib/class-wp-smush.php:1378
842
  msgid " Skipped"
843
  msgstr ""
844
 
845
+ #: lib/class-wp-smush.php:1400
846
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:432
847
  msgid "Image size"
848
  msgstr ""
849
 
850
+ #: lib/class-wp-smush.php:1401
851
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:433
852
  msgid "Savings"
853
  msgstr ""
854
 
855
+ #: lib/class-wp-smush.php:1608
856
  msgid "Restore original image."
857
  msgstr ""
858
 
859
+ #: lib/class-wp-smush.php:1608
860
  msgid "Restore image"
861
  msgstr ""
862
 
863
+ #: lib/class-wp-smush.php:1656
864
  msgid "Smush image including original file."
865
  msgstr ""
866
 
867
+ #: lib/class-wp-smush.php:1656
868
  msgid "Resmush image"
869
  msgstr ""
870
 
lib/class-wp-smush-admin.php CHANGED
@@ -4,7 +4,6 @@
4
  * @subpackage Admin
5
  * @version 1.0
6
  *
7
- * @author Saurabh Shukla <saurabh@incsub.com>
8
  * @author Umesh Kumar <umesh@incsub.com>
9
  *
10
  * @copyright (c) 2016, Incsub (http://incsub.com)
@@ -57,12 +56,36 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
57
  public $remaining_count;
58
 
59
  /**
60
- * @var Smushed attachments out of total attachments
61
  */
62
  public $super_smushed;
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  public $smushed_attachments = array();
65
 
 
 
 
 
 
 
 
 
 
 
66
  public $mime_types = array( 'image/jpg', 'image/jpeg', 'image/gif', 'image/png' );
67
 
68
  /**
@@ -72,17 +95,6 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
72
 
73
  public $bulk_ui = '';
74
 
75
- //List of pages where smush needs to be loaded
76
- public $pages = array(
77
- 'nggallery-manage-images',
78
- 'gallery_page_wp-smush-nextgen-bulk',
79
- 'post',
80
- 'post-new',
81
- 'upload',
82
- 'settings_page_wp-smush-network',
83
- 'media_page_wp-smush-bulk'
84
- );
85
-
86
  /**
87
  * @var int Limit for allowed number of images per bulk request
88
  */
@@ -90,20 +102,6 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
90
 
91
  public $upgrade_url = 'https://premium.wpmudev.org/project/wp-smush-pro/';
92
 
93
- //Stores unsmushed ids
94
- private $ids = '';
95
-
96
- //Stores all lossless smushed ids
97
- public $resmush_ids = array();
98
-
99
- /**
100
- * @var int Number of attachments exceeding free limit
101
- */
102
- public $exceeding_items_count = 0;
103
-
104
- private $attachments = '';
105
-
106
-
107
  public $image_sizes = array();
108
 
109
  /**
@@ -112,6 +110,20 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
112
  */
113
  public $api_headers = array();
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  /**
116
  * Constructor
117
  */
@@ -263,11 +275,13 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
263
  function screen() {
264
  global $admin_page_suffix;
265
 
 
266
  $admin_page_suffix = add_media_page( 'Bulk WP Smush', 'WP Smush', 'edit_others_posts', 'wp-smush-bulk', array(
267
  $this->bulk_ui,
268
  'ui'
269
  ) );
270
 
 
271
  $page = 'settings.php';
272
  $cap = 'manage_network_options';
273
 
@@ -288,12 +302,26 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
288
 
289
  global $WpSmush;
290
 
 
291
  wp_register_script( 'wp-smushit-admin-js', WP_SMUSH_URL . 'assets/js/wp-smushit-admin.js', array(
292
  'jquery'
293
  ), WP_SMUSH_VERSION );
294
 
295
- /* Register Style. */
296
- wp_register_style( 'wp-smushit-admin-css', WP_SMUSH_URL . 'assets/css/wp-smushit-admin.css', array(), $WpSmush->version );
 
 
 
 
 
 
 
 
 
 
 
 
 
297
 
298
  //Dismiss Update Info
299
  $this->dismiss_update_info();
@@ -340,6 +368,13 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
340
  );
341
  }
342
 
 
 
 
 
 
 
 
343
  // localize translatable strings for js
344
  $this->localize();
345
  }
@@ -348,22 +383,29 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
348
  * Localize Translations
349
  */
350
  function localize() {
351
- global $current_screen, $wpsmush_settings;
352
  $current_page = ! empty( $current_screen ) ? $current_screen->base : '';
353
 
354
- $bulk = new WpSmushitBulk();
355
  $handle = 'wp-smushit-admin-js';
356
 
357
  $wp_smush_msgs = array(
358
- 'resmush' => esc_html__( 'Super-Smush', 'wp-smushit' ),
359
- 'smush_now' => esc_html__( 'Smush Now', 'wp-smushit' ),
360
- 'error_in_bulk' => esc_html__( '{{errors}} image(s) were skipped due to an error.', 'wp-smushit' ),
361
- 'all_resmushed' => esc_html__( 'All images are fully optimised.', 'wp-smushit' ),
362
- 'restore' => esc_html__( "Restoring image..", "wp-smushit" ),
363
- 'smushing' => esc_html__( "Smushing image..", "wp-smushit" ),
364
- 'checking' => esc_html__( "Checking images..", "wp-smushit" ),
365
- 'membership_valid' => esc_html__( "We successfully verified your membership, all the Pro features should work completely. ", "wp-smushit" ),
366
- 'membership_invalid' => esc_html__( "Your membership couldn't be verified.", "wp-smushit" ),
 
 
 
 
 
 
 
 
367
  );
368
 
369
  wp_localize_script( $handle, 'wp_smush_msgs', $wp_smush_msgs );
@@ -374,11 +416,13 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
374
  //Setup all the stats
375
  $this->setup_global_stats( true );
376
 
377
- //Get attachments if all the images are not smushed
378
- $this->attachments = $this->remaining_count > 0 ? $bulk->get_attachments() : array();
379
-
380
  //Localize smushit_ids variable, if there are fix number of ids
381
- $this->ids = ! empty( $_REQUEST['ids'] ) ? array_map( 'intval', explode( ',', $_REQUEST['ids'] ) ) : $this->attachments;
 
 
 
 
 
382
 
383
  //Get resmush list, If we have a resmush list already, localize those ids
384
  if ( $resmush_ids = get_option( "wp-smush-resmush-list" ) ) {
@@ -392,7 +436,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
392
  $data = array(
393
  'count_smushed' => $this->smushed_count,
394
  'count_total' => $this->total_count,
395
- 'unsmushed' => $this->ids,
396
  'resmush' => $this->resmush_ids,
397
  );
398
  } else {
@@ -434,10 +478,13 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
434
  *
435
  */
436
  function setup_global_stats( $force_update = false ) {
437
- global $wpsmush_stats;
438
- $this->total_count = $wpsmush_stats->total_count();
 
 
439
  $this->stats = $this->global_stats( $force_update );
440
  $this->smushed_count = ! empty( $this->smushed_attachments ) ? count( $this->smushed_attachments ) : 0;
 
441
  $this->remaining_count = $this->remaining_count();
442
  }
443
 
@@ -453,7 +500,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
453
  if ( ! $count || $force_update ) {
454
  $count = 0;
455
  //Check images bigger than 1Mb, used to display the count of images that can't be smushed
456
- foreach ( $this->attachments as $attachment ) {
457
  if ( file_exists( get_attached_file( $attachment ) ) ) {
458
  $size = filesize( get_attached_file( $attachment ) );
459
  }
@@ -476,7 +523,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
476
  */
477
  function process_smush_request() {
478
 
479
- global $WpSmush, $wpsmush_stats;
480
 
481
  // turn off errors for ajax result
482
  @error_reporting( 0 );
@@ -565,7 +612,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
565
 
566
  $stats = $this->stats;
567
 
568
- $stats['total'] = $wpsmush_stats->total_count();
569
 
570
  if ( isset( $smush ) && is_wp_error( $smush ) ) {
571
 
@@ -717,11 +764,14 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
717
  /**
718
  * Check bulk sent count, whether to allow further smushing or not
719
  *
 
 
 
720
  * @return bool
721
  */
722
- function check_bulk_limit( $reset = false ) {
723
 
724
- $transient_name = WP_SMUSH_PREFIX . 'bulk_sent_count';
725
 
726
  //Do not go through this, if we need to reset
727
  if ( ! $reset ) {
@@ -764,7 +814,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
764
  * @return int
765
  */
766
  function remaining_count() {
767
- return $this->total_count - $this->smushed_count;
768
  }
769
 
770
  /**
@@ -842,7 +892,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
842
  }
843
  }
844
 
845
- global $wpdb, $wpsmush_stats;
846
 
847
  $smush_data = array(
848
  'size_before' => 0,
@@ -893,7 +943,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
893
  $offset += $limit;
894
 
895
  //Compare the Offset value to total images
896
- if ( ! empty( $this->total_count ) && $this->total_count < $offset ) {
897
  $query_next = false;
898
  } elseif ( ! $global_data ) {
899
  //If we didn' got any results
@@ -903,11 +953,11 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
903
  }
904
 
905
  //Resize Savings
906
- $resize_savings = $wpsmush_stats->resize_savings( false );
907
  $smush_data['resize_savings'] = ! empty( $resize_savings['bytes'] ) ? $resize_savings['bytes'] : 0;
908
 
909
  //Conversion Savings
910
- $conversion_savings = $wpsmush_stats->conversion_savings( false );
911
  $smush_data['conversion_savings'] = ! empty( $conversion_savings['bytes'] ) ? $conversion_savings['bytes'] : 0;
912
 
913
  if ( ! isset( $smush_data['bytes'] ) || $smush_data['bytes'] < 0 ) {
@@ -966,9 +1016,9 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
966
  }
967
  }
968
 
969
- global $WpSmush, $wpsmush_stats;
970
  if ( empty( $this->smushed_attachments ) ) {
971
- $this->smushed_attachments = $wpsmush_stats->smushed_count( true );
972
  }
973
 
974
  $smush_data = array(
@@ -1037,11 +1087,11 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1037
  $smush_data['bytes'] = $smush_data['size_before'] - $smush_data['size_after'];
1038
 
1039
  //Resize Savings
1040
- $resize_savings = $wpsmush_stats->resize_savings( false );
1041
  $smush_data['resize_savings'] = ! empty( $resize_savings['bytes'] ) ? $resize_savings['bytes'] : 0;
1042
 
1043
  //Conversion Savings
1044
- $conversion_savings = $wpsmush_stats->conversion_savings( false );
1045
  $smush_data['conversion_savings'] = ! empty( $conversion_savings['bytes'] ) ? $conversion_savings['bytes'] : 0;
1046
 
1047
  //Add the size before and after
@@ -1198,7 +1248,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1198
  */
1199
  function get_smushed_attachments() {
1200
 
1201
- global $wpdb, $wpsmush_stats;
1202
 
1203
  $allowed_images = "( 'image/jpeg', 'image/jpg', 'image/png' )";
1204
 
@@ -1222,7 +1272,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1222
 
1223
  //Update the offset
1224
  $offset += $limit;
1225
- if ( $wpsmush_stats->total_count() && $wpsmush_stats->total_count() < $offset ) {
1226
  $query_next = false;
1227
  } else if ( ! $results || empty( $results ) ) {
1228
  $query_next = false;
@@ -1323,7 +1373,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1323
  */
1324
  function scan_images() {
1325
 
1326
- global $WpSmush, $wpsmushnextgenadmin, $wpsmush_stats, $wpsmush_settings;
1327
 
1328
  check_ajax_referer( 'save_wp_smush_options', 'wp_smush_options_nonce' );
1329
 
@@ -1336,7 +1386,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1336
  }
1337
 
1338
  //If there aren't any images in the library, return the notice
1339
- if ( 0 == $wpsmush_stats->total_count() ) {
1340
  $notice = esc_html__( "We haven’t found any images in your media library yet so there’s no smushing to be done!", "wp-smushit" );
1341
  $resp = '<div class="wp-smush-notice wp-smush-resmush-message" tabindex="0"><i class="dev-icon dev-icon-tick"></i> ' . $notice . '
1342
  <i class="dev-icon dev-icon-cross"></i>
@@ -1400,7 +1450,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1400
  if ( 'nextgen' != $type ) {
1401
 
1402
  //Get list of Smushed images
1403
- $attachments = ! empty( $this->smushed_attachments ) ? $this->smushed_attachments : $wpsmush_stats->smushed_count( true );
1404
  } else {
1405
  global $wpsmushnextgenstats;
1406
 
@@ -1465,7 +1515,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1465
 
1466
  //Check for Upfront images that needs to be smushed
1467
  if ( $upfront_active && 'nextgen' != $type ) {
1468
- $upfront_attachments = $this->get_upfront_images( $resmush_list );
1469
  if ( ! empty( $upfront_attachments ) && is_array( $upfront_attachments ) ) {
1470
  foreach ( $upfront_attachments as $u_attachment_id ) {
1471
  if ( ! in_array( $u_attachment_id, $resmush_list ) ) {
@@ -1535,7 +1585,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1535
  $return = ! empty( $ajax_response ) ? array(
1536
  "resmush_ids" => $resmush_list,
1537
  "content" => $ajax_response
1538
- ) : '';
1539
 
1540
  //Include the count
1541
  if ( ! empty( $count ) && $count ) {
@@ -1545,7 +1595,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1545
  $return['notice'] = $resp;
1546
  $return['super_smush'] = $WpSmush->lossy_enabled;
1547
  if ( $WpSmush->lossy_enabled && 'nextgen' == $type ) {
1548
- $ss_count = $wpsmush_stats->super_smushed_count( 'nextgen', $wpsmushnextgenstats->get_ngg_images( 'smushed' ) );
1549
  $return['super_smush_stats'] = sprintf( '<strong><span class="smushed-count">%d</span>/%d</strong>', $ss_count, $wpsmushnextgenadmin->total_count );
1550
  }
1551
 
@@ -1584,40 +1634,6 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1584
  }
1585
  }
1586
 
1587
- /**
1588
- * Get the attachment ids with Upfront images
1589
- *
1590
- * @param array $skip_ids
1591
- *
1592
- * @return array|bool
1593
- */
1594
- function get_upfront_images( $skip_ids = array() ) {
1595
-
1596
- $query = array(
1597
- 'fields' => array( 'ids', 'post_mime_type' ),
1598
- 'post_type' => 'attachment',
1599
- 'post_status' => 'any',
1600
- 'order' => 'ASC',
1601
- 'posts_per_page' => - 1,
1602
- 'meta_key' => 'upfront_used_image_sizes',
1603
- 'no_found_rows' => true
1604
- );
1605
-
1606
- //Skip all the ids which are already in resmush list
1607
- if ( ! empty( $skip_ids ) && is_array( $skip_ids ) ) {
1608
- $query['post__not_in'] = $skip_ids;
1609
- }
1610
-
1611
- $results = new WP_Query( $query );
1612
-
1613
- if ( ! is_wp_error( $results ) && $results->post_count > 0 ) {
1614
- $posts = $this->filter_by_mime( $results->posts );
1615
- return $posts;
1616
- } else {
1617
- return false;
1618
- }
1619
- }
1620
-
1621
  /**
1622
  * Returns current user name to be displayed
1623
  * @return string
@@ -1740,8 +1756,8 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1740
  * Allows to bulk restore the images, if there is any backup for them
1741
  */
1742
  function bulk_restore() {
1743
- global $wpsmush_stats, $wpsmush_backup;
1744
- $smushed_attachments = ! empty( $this->smushed_attachments ) ? $this->smushed_attachments : $wpsmush_stats->smushed_count( true );
1745
  foreach ( $smushed_attachments as $attachment ) {
1746
  $wpsmush_backup->restore_image( $attachment->attachment_id, false );
1747
  }
@@ -1761,7 +1777,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1761
  //Load Shared UI
1762
  WDEV_Plugin_Ui::load( WP_SMUSH_URL . 'assets/shared-ui/', false );
1763
 
1764
- if ( ( 'settings_page_wp-smush-network' != $current_page && 'media_page_wp-smush-bulk' != $current_page && 'gallery_page_wp-smush-nextgen-bulk' != $current_page ) ) {
1765
 
1766
  //Don't add thhe WPMUD class to body to other admin pages
1767
  remove_filter(
@@ -1843,7 +1859,8 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1843
  *
1844
  */
1845
  function query_limit() {
1846
- $limit = apply_filters( 'wp_smush_query_limit', 1000 );
 
1847
  $limit = intval( $limit );
1848
 
1849
  return $limit;
@@ -1899,8 +1916,6 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1899
  return true;
1900
  }
1901
 
1902
- //Handles the dismiss action
1903
- $js_url = WP_SMUSH_URL . 'assets/js/notice.js';
1904
  $upgrade_url = add_query_arg(
1905
  array(
1906
  'utm_source' => 'Smush-Free',
@@ -1913,7 +1928,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1913
 
1914
  $settings_link = '<a href="' . $settings_link . '" title="' . esc_html__( "Review your setting now.", "wp-smushit" ) . '">';
1915
  $upgrade_link = '<a href="' . esc_url( $upgrade_url ) . '" title="' . esc_html__( "WP Smush Pro", "wp-smushit" ) . '">';
1916
- $message_s = sprintf( esc_html__( "Welcome to the newest version of WP Smush! Auto-smushing on upload is lightning fast now that we handle all the smushing asynchronously.", 'wp-smushit' ), WP_SMUSH_VERSION, '<strong>', '</strong>' );
1917
 
1918
  //Message for network admin
1919
  $message_s .= is_multisite() ? sprintf( esc_html__( " And as a multisite user, you can manage %sSmush settings%s globally across all sites!", 'wp-smushit' ), $settings_link, '</a>' ) : '';
@@ -1923,9 +1938,9 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1923
  ?>
1924
  <div class="notice notice-info is-dismissible wp-smush-update-info">
1925
  <p><?php echo $message_s; ?></p>
1926
- </div>
1927
-
1928
- <script src="<?php echo esc_url( $js_url ) . '?v=' . WP_SMUSH_VERSION; ?>"></script><?php
1929
  }
1930
 
1931
  /**
@@ -2065,28 +2080,6 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
2065
  $wpsmush_settings->update_setting( WP_SMUSH_PREFIX . 'last_settings', $c_settings );
2066
  }
2067
 
2068
- /**
2069
- * Filter the Posts object as per mime type
2070
- *
2071
- * @param $posts Object of Posts
2072
- *
2073
- * @return mixed array of post ids
2074
- *
2075
- */
2076
- function filter_by_mime( $posts ) {
2077
- if ( empty( $posts ) ) {
2078
- return $posts;
2079
- }
2080
- foreach ( $posts as $post_k => $post ) {
2081
- if ( ! isset( $post->post_mime_type ) || ! in_array( $post->post_mime_type, $this->mime_types ) ) {
2082
- unset( $posts[ $post_k ] );
2083
- } else {
2084
- $posts[ $post_k ] = $post->ID;
2085
- }
2086
- }
2087
- return $posts;
2088
- }
2089
-
2090
  }
2091
 
2092
  global $wpsmushit_admin;
4
  * @subpackage Admin
5
  * @version 1.0
6
  *
 
7
  * @author Umesh Kumar <umesh@incsub.com>
8
  *
9
  * @copyright (c) 2016, Incsub (http://incsub.com)
56
  public $remaining_count;
57
 
58
  /**
59
+ * @var Super Smushed attachments out of total attachments
60
  */
61
  public $super_smushed;
62
 
63
+ /**
64
+ * @var array Unsmushed image ids
65
+ */
66
+ public $attachments = array();
67
+
68
+ /**
69
+ * @var array Unsmushed image ids
70
+ */
71
+ public $unsmushed_attachments = array();
72
+
73
+ /**
74
+ * @var array Attachment ids which are smushed
75
+ *
76
+ */
77
  public $smushed_attachments = array();
78
 
79
+ /**
80
+ * @var array Image ids that needs to be resmushed
81
+ */
82
+ public $resmush_ids = array();
83
+
84
+ /**
85
+ * @var int Number of attachments exceeding free limit
86
+ */
87
+ public $exceeding_items_count = 0;
88
+
89
  public $mime_types = array( 'image/jpg', 'image/jpeg', 'image/gif', 'image/png' );
90
 
91
  /**
95
 
96
  public $bulk_ui = '';
97
 
 
 
 
 
 
 
 
 
 
 
 
98
  /**
99
  * @var int Limit for allowed number of images per bulk request
100
  */
102
 
103
  public $upgrade_url = 'https://premium.wpmudev.org/project/wp-smush-pro/';
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  public $image_sizes = array();
106
 
107
  /**
110
  */
111
  public $api_headers = array();
112
 
113
+ public $page_smush_all = '';
114
+
115
+ //List of pages where smush needs to be loaded
116
+ public $pages = array(
117
+ 'nggallery-manage-images',
118
+ 'gallery_page_wp-smush-nextgen-bulk',
119
+ 'post',
120
+ 'post-new',
121
+ 'upload',
122
+ 'settings_page_wp-smush-network',
123
+ 'media_page_wp-smush-bulk',
124
+ 'media_page_wp-smush-all'
125
+ );
126
+
127
  /**
128
  * Constructor
129
  */
275
  function screen() {
276
  global $admin_page_suffix;
277
 
278
+ //Bulk Smush Page for each site
279
  $admin_page_suffix = add_media_page( 'Bulk WP Smush', 'WP Smush', 'edit_others_posts', 'wp-smush-bulk', array(
280
  $this->bulk_ui,
281
  'ui'
282
  ) );
283
 
284
+ //Network Settings Page
285
  $page = 'settings.php';
286
  $cap = 'manage_network_options';
287
 
302
 
303
  global $WpSmush;
304
 
305
+ //Main JS
306
  wp_register_script( 'wp-smushit-admin-js', WP_SMUSH_URL . 'assets/js/wp-smushit-admin.js', array(
307
  'jquery'
308
  ), WP_SMUSH_VERSION );
309
 
310
+ //Notice JS
311
+ wp_register_script( 'wp-smushit-notice-js', WP_SMUSH_URL . 'assets/js/notice.js', array(
312
+ 'jquery'
313
+ ), WP_SMUSH_VERSION );
314
+
315
+ /* Register Style */
316
+ wp_register_style( 'wp-smushit-admin-css', WP_SMUSH_URL . 'assets/css/wp-smushit-admin.css', array(), WP_SMUSH_VERSION );
317
+ //Notice CSS
318
+ wp_register_style( 'wp-smushit-notice-css', WP_SMUSH_URL . 'assets/css/notice.css', array(), WP_SMUSH_VERSION );
319
+
320
+ //jQuery tree
321
+ wp_register_script( 'jqft-js', WP_SMUSH_URL . 'assets/js/jQueryFileTree.js', array(
322
+ 'jquery'
323
+ ), WP_SMUSH_VERSION, true );
324
+ wp_register_style( 'jqft-css', WP_SMUSH_URL . 'assets/css/jQueryFileTree.min.css', array(), WP_SMUSH_VERSION );
325
 
326
  //Dismiss Update Info
327
  $this->dismiss_update_info();
368
  );
369
  }
370
 
371
+ //Load on Smush all page only
372
+ if ( 'media_page_wp-smush-bulk' == $current_page ) {
373
+ //Load Jquery tree on specified page
374
+ wp_enqueue_script( 'jqft-js' );
375
+ wp_enqueue_style( 'jqft-css' );
376
+ }
377
+
378
  // localize translatable strings for js
379
  $this->localize();
380
  }
383
  * Localize Translations
384
  */
385
  function localize() {
386
+ global $current_screen, $wpsmush_settings, $wpsmush_db;
387
  $current_page = ! empty( $current_screen ) ? $current_screen->base : '';
388
 
 
389
  $handle = 'wp-smushit-admin-js';
390
 
391
  $wp_smush_msgs = array(
392
+ 'resmush' => esc_html__( 'Super-Smush', 'wp-smushit' ),
393
+ 'smush_now' => esc_html__( 'Smush Now', 'wp-smushit' ),
394
+ 'error_in_bulk' => esc_html__( '{{errors}} image(s) were skipped due to an error.', 'wp-smushit' ),
395
+ 'all_resmushed' => esc_html__( 'All images are fully optimised.', 'wp-smushit' ),
396
+ 'restore' => esc_html__( "Restoring image..", "wp-smushit" ),
397
+ 'smushing' => esc_html__( "Smushing image..", "wp-smushit" ),
398
+ 'checking' => esc_html__( "Checking images..", "wp-smushit" ),
399
+ 'membership_valid' => esc_html__( "We successfully verified your membership, all the Pro features should work completely. ", "wp-smushit" ),
400
+ 'membership_invalid' => esc_html__( "Your membership couldn't be verified.", "wp-smushit" ),
401
+ 'missing_path' => esc_html__( "Missing file path.", "wp-smushit" ),
402
+ //Used by Directory Smush
403
+ 'unfinished_smush_single' => esc_html__( "image could not be smushed.", "wp-smushit" ),
404
+ 'unfinished_smush' => esc_html__( "images could not be smushed.", "wp-smushit" ),
405
+ 'already_optimised' => esc_html__( "Already Optimised", "wp-smushit" ),
406
+ 'ajax_error' => esc_html__( "Ajax Error", "wp-smushit" ),
407
+ 'all_done' => esc_html__( "All Done!", "wp-smushit" ),
408
+ 'all_done' => esc_html__( "All Done!", "wp-smushit" ),
409
  );
410
 
411
  wp_localize_script( $handle, 'wp_smush_msgs', $wp_smush_msgs );
416
  //Setup all the stats
417
  $this->setup_global_stats( true );
418
 
 
 
 
419
  //Localize smushit_ids variable, if there are fix number of ids
420
+ $this->unsmushed_attachments = ! empty( $_REQUEST['ids'] ) ? array_map( 'intval', explode( ',', $_REQUEST['ids'] ) ) : array();
421
+
422
+ if( empty( $this->unsmushed_attachments ) ) {
423
+ //Get attachments if all the images are not smushed
424
+ $this->unsmushed_attachments = $this->remaining_count > 0 ? $wpsmush_db->get_unsmushed_attachments() : array();
425
+ }
426
 
427
  //Get resmush list, If we have a resmush list already, localize those ids
428
  if ( $resmush_ids = get_option( "wp-smush-resmush-list" ) ) {
436
  $data = array(
437
  'count_smushed' => $this->smushed_count,
438
  'count_total' => $this->total_count,
439
+ 'unsmushed' => $this->unsmushed_attachments,
440
  'resmush' => $this->resmush_ids,
441
  );
442
  } else {
478
  *
479
  */
480
  function setup_global_stats( $force_update = false ) {
481
+ global $wpsmush_db;
482
+ //Setup Attachments and total count
483
+ $wpsmush_db->total_count( true );
484
+
485
  $this->stats = $this->global_stats( $force_update );
486
  $this->smushed_count = ! empty( $this->smushed_attachments ) ? count( $this->smushed_attachments ) : 0;
487
+ //@todo: Rename to unsmushed_count
488
  $this->remaining_count = $this->remaining_count();
489
  }
490
 
500
  if ( ! $count || $force_update ) {
501
  $count = 0;
502
  //Check images bigger than 1Mb, used to display the count of images that can't be smushed
503
+ foreach ( $this->unsmushed_attachments as $attachment ) {
504
  if ( file_exists( get_attached_file( $attachment ) ) ) {
505
  $size = filesize( get_attached_file( $attachment ) );
506
  }
523
  */
524
  function process_smush_request() {
525
 
526
+ global $WpSmush, $wpsmush_db;
527
 
528
  // turn off errors for ajax result
529
  @error_reporting( 0 );
612
 
613
  $stats = $this->stats;
614
 
615
+ $stats['total'] = $wpsmush_db->total_count( true );
616
 
617
  if ( isset( $smush ) && is_wp_error( $smush ) ) {
618
 
764
  /**
765
  * Check bulk sent count, whether to allow further smushing or not
766
  *
767
+ * @param bool $reset To hard reset the transient
768
+ * @param string $key Transient Key - bulk_sent_count/dir_sent_count
769
+ *
770
  * @return bool
771
  */
772
+ function check_bulk_limit( $reset = false, $key = 'bulk_sent_count' ) {
773
 
774
+ $transient_name = WP_SMUSH_PREFIX . $key;
775
 
776
  //Do not go through this, if we need to reset
777
  if ( ! $reset ) {
814
  * @return int
815
  */
816
  function remaining_count() {
817
+ return ( $this->total_count - $this->smushed_count );
818
  }
819
 
820
  /**
892
  }
893
  }
894
 
895
+ global $wpdb, $wpsmush_db;
896
 
897
  $smush_data = array(
898
  'size_before' => 0,
943
  $offset += $limit;
944
 
945
  //Compare the Offset value to total images
946
+ if ( ! empty( $this->total_count ) && $this->total_count <= $offset ) {
947
  $query_next = false;
948
  } elseif ( ! $global_data ) {
949
  //If we didn' got any results
953
  }
954
 
955
  //Resize Savings
956
+ $resize_savings = $wpsmush_db->resize_savings( false );
957
  $smush_data['resize_savings'] = ! empty( $resize_savings['bytes'] ) ? $resize_savings['bytes'] : 0;
958
 
959
  //Conversion Savings
960
+ $conversion_savings = $wpsmush_db->conversion_savings( false );
961
  $smush_data['conversion_savings'] = ! empty( $conversion_savings['bytes'] ) ? $conversion_savings['bytes'] : 0;
962
 
963
  if ( ! isset( $smush_data['bytes'] ) || $smush_data['bytes'] < 0 ) {
1016
  }
1017
  }
1018
 
1019
+ global $wpsmush_db;
1020
  if ( empty( $this->smushed_attachments ) ) {
1021
+ $this->smushed_attachments = $wpsmush_db->smushed_count( true );
1022
  }
1023
 
1024
  $smush_data = array(
1087
  $smush_data['bytes'] = $smush_data['size_before'] - $smush_data['size_after'];
1088
 
1089
  //Resize Savings
1090
+ $resize_savings = $wpsmush_db->resize_savings( false );
1091
  $smush_data['resize_savings'] = ! empty( $resize_savings['bytes'] ) ? $resize_savings['bytes'] : 0;
1092
 
1093
  //Conversion Savings
1094
+ $conversion_savings = $wpsmush_db->conversion_savings( false );
1095
  $smush_data['conversion_savings'] = ! empty( $conversion_savings['bytes'] ) ? $conversion_savings['bytes'] : 0;
1096
 
1097
  //Add the size before and after
1248
  */
1249
  function get_smushed_attachments() {
1250
 
1251
+ global $wpdb;
1252
 
1253
  $allowed_images = "( 'image/jpeg', 'image/jpg', 'image/png' )";
1254
 
1272
 
1273
  //Update the offset
1274
  $offset += $limit;
1275
+ if ( !empty( $this->total_count ) && $this->total_count <= $offset ) {
1276
  $query_next = false;
1277
  } else if ( ! $results || empty( $results ) ) {
1278
  $query_next = false;
1373
  */
1374
  function scan_images() {
1375
 
1376
+ global $WpSmush, $wpsmushnextgenadmin, $wpsmush_db, $wpsmush_settings;
1377
 
1378
  check_ajax_referer( 'save_wp_smush_options', 'wp_smush_options_nonce' );
1379
 
1386
  }
1387
 
1388
  //If there aren't any images in the library, return the notice
1389
+ if ( 0 == $wpsmush_db->total_count() ) {
1390
  $notice = esc_html__( "We haven’t found any images in your media library yet so there’s no smushing to be done!", "wp-smushit" );
1391
  $resp = '<div class="wp-smush-notice wp-smush-resmush-message" tabindex="0"><i class="dev-icon dev-icon-tick"></i> ' . $notice . '
1392
  <i class="dev-icon dev-icon-cross"></i>
1450
  if ( 'nextgen' != $type ) {
1451
 
1452
  //Get list of Smushed images
1453
+ $attachments = ! empty( $this->smushed_attachments ) ? $this->smushed_attachments : $wpsmush_db->smushed_count( true );
1454
  } else {
1455
  global $wpsmushnextgenstats;
1456
 
1515
 
1516
  //Check for Upfront images that needs to be smushed
1517
  if ( $upfront_active && 'nextgen' != $type ) {
1518
+ $upfront_attachments = $wpsmush_db->get_upfront_images( $resmush_list );
1519
  if ( ! empty( $upfront_attachments ) && is_array( $upfront_attachments ) ) {
1520
  foreach ( $upfront_attachments as $u_attachment_id ) {
1521
  if ( ! in_array( $u_attachment_id, $resmush_list ) ) {
1585
  $return = ! empty( $ajax_response ) ? array(
1586
  "resmush_ids" => $resmush_list,
1587
  "content" => $ajax_response
1588
+ ) : array();
1589
 
1590
  //Include the count
1591
  if ( ! empty( $count ) && $count ) {
1595
  $return['notice'] = $resp;
1596
  $return['super_smush'] = $WpSmush->lossy_enabled;
1597
  if ( $WpSmush->lossy_enabled && 'nextgen' == $type ) {
1598
+ $ss_count = $wpsmush_db->super_smushed_count( 'nextgen', $wpsmushnextgenstats->get_ngg_images( 'smushed' ) );
1599
  $return['super_smush_stats'] = sprintf( '<strong><span class="smushed-count">%d</span>/%d</strong>', $ss_count, $wpsmushnextgenadmin->total_count );
1600
  }
1601
 
1634
  }
1635
  }
1636
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1637
  /**
1638
  * Returns current user name to be displayed
1639
  * @return string
1756
  * Allows to bulk restore the images, if there is any backup for them
1757
  */
1758
  function bulk_restore() {
1759
+ global $wpsmush_db, $wpsmush_backup;
1760
+ $smushed_attachments = ! empty( $this->smushed_attachments ) ? $this->smushed_attachments : $wpsmush_db->smushed_count( true );
1761
  foreach ( $smushed_attachments as $attachment ) {
1762
  $wpsmush_backup->restore_image( $attachment->attachment_id, false );
1763
  }
1777
  //Load Shared UI
1778
  WDEV_Plugin_Ui::load( WP_SMUSH_URL . 'assets/shared-ui/', false );
1779
 
1780
+ if ( ( 'settings_page_wp-smush-network' != $current_page && 'media_page_wp-smush-bulk' != $current_page && 'gallery_page_wp-smush-nextgen-bulk' != $current_page && 'media_page_wp-smush-all' != $current_page) ) {
1781
 
1782
  //Don't add thhe WPMUD class to body to other admin pages
1783
  remove_filter(
1859
  *
1860
  */
1861
  function query_limit() {
1862
+ $limit = apply_filters( 'wp_smush_query_limit', 2000 );
1863
+ $limit = !empty( $this->total_count ) && $limit > $this->total_count ? $this->total_count : $limit;
1864
  $limit = intval( $limit );
1865
 
1866
  return $limit;
1916
  return true;
1917
  }
1918
 
 
 
1919
  $upgrade_url = add_query_arg(
1920
  array(
1921
  'utm_source' => 'Smush-Free',
1928
 
1929
  $settings_link = '<a href="' . $settings_link . '" title="' . esc_html__( "Review your setting now.", "wp-smushit" ) . '">';
1930
  $upgrade_link = '<a href="' . esc_url( $upgrade_url ) . '" title="' . esc_html__( "WP Smush Pro", "wp-smushit" ) . '">';
1931
+ $message_s = sprintf( esc_html__( "Welcome to the newest version of WP Smush! In this update we've added the ability to bulk smush images in directories outside your uploads folder.", 'wp-smushit' ), WP_SMUSH_VERSION, '<strong>', '</strong>' );
1932
 
1933
  //Message for network admin
1934
  $message_s .= is_multisite() ? sprintf( esc_html__( " And as a multisite user, you can manage %sSmush settings%s globally across all sites!", 'wp-smushit' ), $settings_link, '</a>' ) : '';
1938
  ?>
1939
  <div class="notice notice-info is-dismissible wp-smush-update-info">
1940
  <p><?php echo $message_s; ?></p>
1941
+ </div><?php
1942
+ //Notice JS
1943
+ wp_enqueue_script('wp-smushit-notice-js', '', array(), '', true );
1944
  }
1945
 
1946
  /**
2080
  $wpsmush_settings->update_setting( WP_SMUSH_PREFIX . 'last_settings', $c_settings );
2081
  }
2082
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2083
  }
2084
 
2085
  global $wpsmushit_admin;
lib/class-wp-smush-async.php CHANGED
@@ -8,11 +8,11 @@
8
  *
9
  * @copyright (c) 2016, Incsub (http://incsub.com)
10
  */
11
- require_once 'wp-async-task.php';
12
 
13
  if ( ! class_exists( 'WpSmushAsync' ) ) {
14
 
15
- class WpSmushAsync extends WP_Async_Task {
16
 
17
  protected $argument_count = 2;
18
  protected $priority = 12;
@@ -49,7 +49,6 @@ if ( ! class_exists( 'WpSmushAsync' ) ) {
49
 
50
  /**
51
  * Run the async task action
52
- * @todo: Add a check for image
53
  * @todo: See if auto smush is enabled or not
54
  * @todo: Check if async is enabled or not
55
  */
@@ -67,7 +66,7 @@ if ( ! class_exists( 'WpSmushAsync' ) ) {
67
 
68
  }
69
 
70
- class WpSmushEditorAsync extends WP_Async_Task {
71
 
72
  protected $argument_count = 2;
73
  protected $priority = 12;
8
  *
9
  * @copyright (c) 2016, Incsub (http://incsub.com)
10
  */
11
+ require_once 'wp-async-task-smush.php';
12
 
13
  if ( ! class_exists( 'WpSmushAsync' ) ) {
14
 
15
+ class WpSmushAsync extends WP_Async_Task_Smush {
16
 
17
  protected $argument_count = 2;
18
  protected $priority = 12;
49
 
50
  /**
51
  * Run the async task action
 
52
  * @todo: See if auto smush is enabled or not
53
  * @todo: Check if async is enabled or not
54
  */
66
 
67
  }
68
 
69
+ class WpSmushEditorAsync extends WP_Async_Task_Smush {
70
 
71
  protected $argument_count = 2;
72
  protected $priority = 12;
lib/class-wp-smush-db.php ADDED
@@ -0,0 +1,750 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package WP Smush
4
+ * @subpackage Admin
5
+ * @version 2.3
6
+ *
7
+ * @author Umesh Kumar <umesh@incsub.com>
8
+ *
9
+ * @copyright (c) 2016, Incsub (http://incsub.com)
10
+ */
11
+ if ( ! class_exists( 'WpSmushDB' ) ) {
12
+
13
+ /**
14
+ * Class WpSmushStats
15
+ */
16
+ class WpSmushDB {
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
+ /**
25
+ * Filter the Posts object as per mime type
26
+ *
27
+ * @param $posts Object of Posts
28
+ *
29
+ * @return mixed array of post ids
30
+ *
31
+ */
32
+ function filter_by_mime( $posts ) {
33
+ global $wpsmushit_admin;
34
+ if ( empty( $posts ) ) {
35
+ return $posts;
36
+ }
37
+ foreach ( $posts as $post_k => $post ) {
38
+ if ( ! isset( $post->post_mime_type ) || ! in_array( $post->post_mime_type, $wpsmushit_admin->mime_types ) ) {
39
+ unset( $posts[ $post_k ] );
40
+ } else {
41
+ $posts[ $post_k ] = $post->ID;
42
+ }
43
+ }
44
+
45
+ return $posts;
46
+ }
47
+
48
+ /**
49
+ * Fetch all the unsmushed attachments
50
+ *
51
+ * @return array $attachments
52
+ */
53
+ function get_unsmushed_attachments() {
54
+ global $wpsmushit_admin, $wpsmush_db;
55
+
56
+ if ( ! isset( $_REQUEST['ids'] ) ) {
57
+
58
+ /** Do not fetch more than this, any time
59
+ Localizing all rows at once increases the page load and slows down everything */
60
+ $r_limit = apply_filters( 'wp_smush_max_rows', 5000 );
61
+
62
+ //Check if we can get the unsmushed attachments from the other two variables
63
+ if ( ! empty( $wpsmushit_admin->attachments ) && ! empty( $wpsmushit_admin->smushed_attachments ) ) {
64
+ $unsmushed_posts = array_diff( $wpsmushit_admin->attachments, $wpsmushit_admin->smushed_attachments );
65
+ $unsmushed_posts = ! empty( $unsmushed_posts ) && is_array( $unsmushed_posts ) ? array_slice( $unsmushed_posts, 0, $r_limit ) : array();
66
+
67
+ return $unsmushed_posts;
68
+ } else {
69
+ $limit = $wpsmushit_admin->query_limit();
70
+
71
+ $get_posts = true;
72
+ $unsmushed_posts = array();
73
+ $args = array(
74
+ 'fields' => array( 'ids', 'post_mime_type' ),
75
+ 'post_type' => 'attachment',
76
+ 'post_status' => 'any',
77
+ 'orderby' => 'ID',
78
+ 'order' => 'DESC',
79
+ 'posts_per_page' => $limit,
80
+ 'offset' => 0,
81
+ 'meta_query' => array(
82
+ array(
83
+ 'key' => 'wp-smpro-smush-data',
84
+ 'compare' => 'NOT EXISTS'
85
+ )
86
+ ),
87
+ 'update_post_term_cache' => false,
88
+ 'no_found_rows' => true,
89
+ );
90
+ //Loop Over to get all the attachments
91
+ while ( $get_posts ) {
92
+
93
+ //Remove the Filters added by WP Media Folder
94
+ $wpsmush_db->remove_filters();
95
+
96
+ $query = new WP_Query( $args );
97
+
98
+ if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
99
+
100
+ //Get a filtered list of post ids
101
+ $posts = $wpsmush_db->filter_by_mime( $query->posts );
102
+
103
+ //Merge the results
104
+ $unsmushed_posts = array_merge( $unsmushed_posts, $posts );
105
+
106
+ //Update the offset
107
+ $args['offset'] += $limit;
108
+ } else {
109
+ //If we didn't get any posts from query, set $get_posts to false
110
+ $get_posts = false;
111
+ }
112
+
113
+ //If we already got enough posts
114
+ if ( count( $unsmushed_posts ) >= $r_limit ) {
115
+ $get_posts = false;
116
+ } else if ( ! empty( $wpsmushit_admin->total_count ) && $wpsmushit_admin->total_count <= $args['offset'] ) {
117
+ //If total Count is set, and it is alread lesser than offset, don't query
118
+ $get_posts = false;
119
+ }
120
+ }
121
+ }
122
+ } else {
123
+ return array_map( 'intval', explode( ',', $_REQUEST['ids'] ) );
124
+ }
125
+
126
+ return $unsmushed_posts;
127
+ }
128
+
129
+ /**
130
+ * Total Image count
131
+ *
132
+ * @param bool $force_update
133
+ *
134
+ * @return bool|int|mixed
135
+ */
136
+ function total_count( $force_update = false ) {
137
+ global $wpsmushit_admin, $wpdb;
138
+
139
+ //Retrieve from Cache
140
+ if ( ! $force_update && $count = wp_cache_get( 'total_count', 'wp-smush' ) ) {
141
+ return $count;
142
+ }
143
+
144
+ $posts = array();
145
+ $offset = 0;
146
+ $limit = $wpsmushit_admin->query_limit();
147
+
148
+ $mime = implode( "', '", $wpsmushit_admin->mime_types );
149
+ $query = "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_mime_type IN ('$mime') LIMIT %d, %d";
150
+ //Remove the Filters added by WP Media Folder
151
+ $this->remove_filters();
152
+
153
+ $get_posts = true;
154
+
155
+ while ( $get_posts ) {
156
+ $results = $wpdb->get_col( $wpdb->prepare( $query, $offset, $limit ) );
157
+ if ( ! empty( $results ) && is_array( $results ) && sizeof( $results ) > 0 ) {
158
+
159
+ //Get a filtered list of post ids
160
+ $posts = array_merge( $posts, $results );
161
+
162
+ //Update the offset
163
+ $offset += $limit;
164
+ } else {
165
+ //If we didn't get any posts from query, set $get_posts to false
166
+ $get_posts = false;
167
+ }
168
+ }
169
+
170
+ //If we have got the Query result
171
+ if ( ! empty( $posts ) && is_array( $posts ) ) {
172
+ wp_cache_add( 'smush_attachments', $posts, 'wp-smush' );
173
+ }
174
+
175
+ //Set Attachment ids, and total count
176
+ $wpsmushit_admin->attachments = $posts;
177
+ $wpsmushit_admin->total_count = ! empty( $posts ) && is_array( $posts ) ? sizeof( $posts ) : 0;
178
+
179
+ // send the count
180
+ return $posts;
181
+ }
182
+
183
+ /**
184
+ * Optimised images count
185
+ *
186
+ * @param bool $return_ids
187
+ *
188
+ * @return array|int
189
+ */
190
+ function smushed_count( $return_ids = false ) {
191
+ global $wpsmushit_admin;
192
+
193
+ //Don't query again, if the variable is already set
194
+ if ( ! $return_ids && ! empty( $wpsmushit_admin->smushed_count ) && $wpsmushit_admin->smushed_count > 0 ) {
195
+ return $wpsmushit_admin->smushed_count;
196
+ }
197
+
198
+ $query = array(
199
+ 'fields' => array( 'ids', 'post_mime_type' ),
200
+ 'post_type' => 'attachment',
201
+ 'post_status' => 'inherit',
202
+ 'order' => 'ASC',
203
+ 'posts_per_page' => - 1,
204
+ 'meta_key' => 'wp-smpro-smush-data',
205
+ 'no_found_rows' => true
206
+ );
207
+
208
+ //Remove the Filters added by WP Media Folder
209
+ $this->remove_filters();
210
+
211
+ $results = new WP_Query( $query );
212
+
213
+ if ( ! is_wp_error( $results ) && $results->post_count > 0 ) {
214
+
215
+ $posts = $this->filter_by_mime( $results->posts );
216
+
217
+ if ( ! $return_ids ) {
218
+ //return Post Count
219
+ return count( $posts );
220
+ } else {
221
+ //Return post ids
222
+ return $posts;
223
+ }
224
+ } else {
225
+ return false;
226
+ }
227
+ }
228
+
229
+ /**
230
+ * Returns/Updates the number of images Super Smushed
231
+ *
232
+ * @param string $type media/nextgen, Type of images to get/set the super smushed count for
233
+ *
234
+ * @param array $attachments Optional, By default Media attachments will be fetched
235
+ *
236
+ * @return array|mixed|void
237
+ *
238
+ * @todo: Refactor Method, Separate Media Library and Nextgen, moreover nextgen functioanlity is broken
239
+ *
240
+ */
241
+ function super_smushed_count( $type = 'media', $attachments = array() ) {
242
+
243
+ if ( 'media' == $type ) {
244
+ $count = $this->get_super_smushed_attachments();
245
+ } else {
246
+ $key = 'wp-smush-super_smushed_nextgen';
247
+
248
+ //Flag to check if we need to re-evaluate the count
249
+ $revaluate = false;
250
+
251
+ $super_smushed = get_option( $key, false );
252
+
253
+ //Check if need to revalidate
254
+ if ( ! $super_smushed || empty( $super_smushed ) || empty( $super_smushed['ids'] ) ) {
255
+
256
+ $super_smushed = array(
257
+ 'ids' => array()
258
+ );
259
+
260
+ $revaluate = true;
261
+ } else {
262
+ $last_checked = $super_smushed['timestamp'];
263
+
264
+ $diff = $last_checked - current_time( 'timestamp' );
265
+
266
+ //Difference in hour
267
+ $diff_h = $diff / 3600;
268
+
269
+ //if last checked was more than 1 hours.
270
+ if ( $diff_h > 1 ) {
271
+ $revaluate = true;
272
+ }
273
+ }
274
+ //Do not Revaluate stats if nextgen attachments are not provided
275
+ if ( 'nextgen' == $type && empty( $attachments ) && $revaluate ) {
276
+ $revaluate = false;
277
+ }
278
+
279
+ //Need to scan all the image
280
+ if ( $revaluate ) {
281
+ //Get all the Smushed attachments ids
282
+ //Note: Wrong Method called, it'll fetch media images and not NextGen images
283
+ //Should be $attachments, in place of $super_smushed_images
284
+ $super_smushed_images = $this->get_super_smushed_attachments( true );
285
+
286
+ if ( ! empty( $super_smushed_images ) && is_array( $super_smushed_images ) ) {
287
+ //Iterate over all the attachments to check if it's already there in list, else add it
288
+ foreach ( $super_smushed_images as $id ) {
289
+ if ( ! in_array( $id, $super_smushed['ids'] ) ) {
290
+ $super_smushed['ids'][] = $id;
291
+ }
292
+ }
293
+ }
294
+
295
+ $super_smushed['timestamp'] = current_time( 'timestamp' );
296
+
297
+ update_option( $key, $super_smushed );
298
+ }
299
+
300
+ $count = ! empty( $super_smushed['ids'] ) ? count( $super_smushed['ids'] ) : 0;
301
+ }
302
+
303
+ return $count;
304
+ }
305
+
306
+ /**
307
+ * Updates the Meta for existing smushed images and retrieves the count of Super Smushed images
308
+ *
309
+ * @param bool $return_ids Whether to return ids or just the count
310
+ *
311
+ * @return array|int Super Smushed images Id / Count of Super Smushed images
312
+ */
313
+ function get_super_smushed_attachments( $return_ids = false ) {
314
+
315
+ global $wpsmushit_admin;
316
+
317
+ //Get all the attachments with wp-smush-lossy
318
+ $limit = $wpsmushit_admin->query_limit();
319
+ $get_posts = true;
320
+ $super_smushed = array();
321
+ $args = array(
322
+ 'fields' => array( 'ids', 'post_mime_type' ),
323
+ 'post_type' => 'attachment',
324
+ 'post_status' => 'any',
325
+ 'orderby' => 'ID',
326
+ 'order' => 'DESC',
327
+ 'posts_per_page' => $limit,
328
+ 'offset' => 0,
329
+ 'meta_query' => array(
330
+ array(
331
+ 'key' => 'wp-smush-lossy',
332
+ 'value' => 1
333
+ )
334
+ ),
335
+ 'update_post_term_cache' => false,
336
+ 'no_found_rows' => true,
337
+ );
338
+ //Loop Over to get all the attachments
339
+ while ( $get_posts ) {
340
+
341
+ //Remove the Filters added by WP Media Folder
342
+ $this->remove_filters();
343
+
344
+ $query = new WP_Query( $args );
345
+
346
+ if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
347
+ $posts = $this->filter_by_mime( $query->posts );
348
+ //Merge the results
349
+ $super_smushed = array_merge( $super_smushed, $posts );
350
+
351
+ //Update the offset
352
+ $args['offset'] += $limit;
353
+ } else {
354
+ //If we didn't get any posts from query, set $get_posts to false
355
+ $get_posts = false;
356
+ }
357
+ //If total Count is set, and it is alread lesser than offset, don't query
358
+ if ( ! empty( $wpsmushit_admin->total_count ) && $wpsmushit_admin->total_count <= $args['offset'] ) {
359
+ $get_posts = false;
360
+ }
361
+ }
362
+
363
+ return $return_ids ? $super_smushed : count( $super_smushed );
364
+ }
365
+
366
+ /**
367
+ * Remove any pre_get_posts_filters added by WP Media Folder plugin
368
+ */
369
+ function remove_filters() {
370
+ //remove any filters added b WP media Folder plugin to get the all attachments
371
+ if ( class_exists( 'Wp_Media_Folder' ) ) {
372
+ global $wp_media_folder;
373
+ if ( is_object( $wp_media_folder ) ) {
374
+ remove_filter( 'pre_get_posts', array( $wp_media_folder, 'wpmf_pre_get_posts1' ) );
375
+ remove_filter( 'pre_get_posts', array( $wp_media_folder, 'wpmf_pre_get_posts' ), 0, 1 );
376
+ }
377
+ }
378
+ global $wpml_query_filter;
379
+ //If WPML is not installed, return
380
+ if ( ! is_object( $wpml_query_filter ) ) {
381
+ return;
382
+ }
383
+
384
+ //Remove language filter and let all the images be smushed at once
385
+ if ( has_filter( 'posts_join', array( $wpml_query_filter, 'posts_join_filter' ) ) ) {
386
+ remove_filter( 'posts_join', array( $wpml_query_filter, 'posts_join_filter' ), 10, 2 );
387
+ remove_filter( 'posts_where', array( $wpml_query_filter, 'posts_where_filter' ), 10, 2 );
388
+ }
389
+ }
390
+
391
+ /**
392
+ * Get the savings from image resizing, And force update if set to true
393
+ *
394
+ * @param bool $force_update , Whether to Re-Calculate all the stats or not
395
+ *
396
+ * @param bool $format Format the Bytes in readable format
397
+ *
398
+ * @return array|bool|mixed|string Array of {
399
+ * 'bytes',
400
+ * 'before_size',
401
+ * 'after_size'
402
+ * }
403
+ *
404
+ */
405
+ function resize_savings( $force_update = true, $format = false ) {
406
+ $savings = '';
407
+
408
+ if ( ! $force_update ) {
409
+ $savings = wp_cache_get( WP_SMUSH_PREFIX . 'resize_savings', 'wp-smush' );
410
+ }
411
+
412
+ global $wpsmushit_admin;
413
+
414
+ //If nothing in cache, Calculate it
415
+ if ( empty( $savings ) || $force_update ) {
416
+ $savings = array(
417
+ 'bytes' => 0,
418
+ 'size_before' => 0,
419
+ 'size_after' => 0,
420
+ );
421
+
422
+ $limit = $wpsmushit_admin->query_limit();
423
+ $offset = 0;
424
+ $query_next = true;
425
+ global $wpdb;
426
+
427
+ while ( $query_next ) {
428
+
429
+ $resize_data = $wpdb->get_col( $wpdb->prepare( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key=%s LIMIT $offset, $limit", WP_SMUSH_PREFIX . 'resize_savings' ) );
430
+
431
+ if ( ! empty( $resize_data ) ) {
432
+ foreach ( $resize_data as $data ) {
433
+
434
+ if ( ! empty( $data ) ) {
435
+ $meta = maybe_unserialize( $data );
436
+ if ( ! empty( $meta ) && ! empty( $meta['bytes'] ) ) {
437
+ $savings['bytes'] += $meta['bytes'];
438
+ $savings['size_before'] += $meta['size_before'];
439
+ $savings['size_after'] += $meta['size_after'];
440
+ }
441
+ }
442
+ }
443
+ }
444
+ //Update the offset
445
+ $offset += $limit;
446
+
447
+ //Compare the Offset value to total images
448
+ if ( ! empty( $wpsmushit_admin->total_count ) && $wpsmushit_admin->total_count < $offset ) {
449
+ $query_next = false;
450
+ } elseif ( ! $resize_data ) {
451
+ //If we didn' got any results
452
+ $query_next = false;
453
+ }
454
+ }
455
+
456
+ if ( $format ) {
457
+ $savings['bytes'] = size_format( $savings['bytes'], 1 );
458
+ }
459
+
460
+ wp_cache_set( WP_SMUSH_PREFIX . 'resize_savings', $savings, 'wp-smush' );
461
+ }
462
+
463
+ return $savings;
464
+ }
465
+
466
+ /**
467
+ * Return/Update PNG -> JPG Conversion savings
468
+ *
469
+ * @param bool $force_update Whether to force update the conversion savings or not
470
+ * @param bool $format Optionally return formatted savings
471
+ *
472
+ * @return array Savings
473
+ */
474
+ function conversion_savings( $force_update = true, $format = false ) {
475
+ $savings = '';
476
+
477
+ if ( ! $force_update ) {
478
+ $savings = wp_cache_get( WP_SMUSH_PREFIX . 'pngjpg_savings', 'wp-smush' );
479
+ }
480
+ //If nothing in cache, Calculate it
481
+ if ( empty( $savings ) || $force_update ) {
482
+ global $wpsmushit_admin;
483
+ $savings = array(
484
+ 'bytes' => 0,
485
+ 'size_before' => 0,
486
+ 'size_after' => 0,
487
+ );
488
+
489
+ $limit = $wpsmushit_admin->query_limit();
490
+ $offset = 0;
491
+ $query_next = true;
492
+ global $wpdb;
493
+
494
+ while ( $query_next ) {
495
+
496
+ $conversion_savings = $wpdb->get_col( $wpdb->prepare( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key=%s LIMIT $offset, $limit", WP_SMUSH_PREFIX . 'pngjpg_savings' ) );
497
+
498
+ if ( ! empty( $conversion_savings ) ) {
499
+ foreach ( $conversion_savings as $data ) {
500
+
501
+ if ( ! empty( $data ) ) {
502
+ $meta = maybe_unserialize( $data );
503
+
504
+ if ( is_array( $meta ) ) {
505
+ foreach ( $meta as $size ) {
506
+ if ( ! empty( $size ) && is_array( $size ) ) {
507
+ $savings['bytes'] += $size['bytes'];
508
+ $savings['size_before'] += $size['size_before'];
509
+ $savings['size_after'] += $size['size_after'];
510
+ }
511
+ }
512
+ }
513
+ }
514
+ }
515
+ }
516
+ //Update the offset
517
+ $offset += $limit;
518
+
519
+ //Compare the Offset value to total images
520
+ if ( ! empty( $wpsmushit_admin->total_count ) && $wpsmushit_admin->total_count < $offset ) {
521
+ $query_next = false;
522
+ } elseif ( ! $conversion_savings ) {
523
+ //If we didn' got any results
524
+ $query_next = false;
525
+ }
526
+ }
527
+
528
+ if ( $format ) {
529
+ $savings['bytes'] = size_format( $savings['bytes'], 1 );
530
+ }
531
+
532
+ wp_cache_set( WP_SMUSH_PREFIX . 'pngjpg_savings', $savings, 'wp-smush' );
533
+ }
534
+
535
+ return $savings;
536
+ }
537
+
538
+ /**
539
+ * Get all the resized images
540
+ *
541
+ * @return array Array of post ids of all the resized images
542
+ *
543
+ */
544
+ function resize_images() {
545
+ global $wpsmushit_admin;
546
+ $limit = $wpsmushit_admin->query_limit();
547
+ $get_posts = true;
548
+ $resized_images = array();
549
+ $args = array(
550
+ 'fields' => array( 'ids', 'post_mime_type' ),
551
+ 'post_type' => 'attachment',
552
+ 'post_status' => 'inherit',
553
+ 'orderby' => 'ID',
554
+ 'order' => 'DESC',
555
+ 'posts_per_page' => $limit,
556
+ 'offset' => 0,
557
+ 'meta_key' => WP_SMUSH_PREFIX . 'resize_savings',
558
+ 'update_post_term_cache' => false,
559
+ 'no_found_rows' => true,
560
+ );
561
+ //Loop Over to get all the attachments
562
+ while ( $get_posts ) {
563
+
564
+ //Remove the Filters added by WP Media Folder
565
+ $this->remove_filters();
566
+
567
+ $query = new WP_Query( $args );
568
+
569
+ if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
570
+
571
+ $posts = $this->filter_by_mime( $query->posts );
572
+
573
+ //Merge the results
574
+ $resized_images = array_merge( $resized_images, $posts );
575
+
576
+ //Update the offset
577
+ $args['offset'] += $limit;
578
+ } else {
579
+ //If we didn't get any posts from query, set $get_posts to false
580
+ $get_posts = false;
581
+ }
582
+
583
+ //If total Count is set, and it is alread lesser than offset, don't query
584
+ if ( ! empty( $wpsmushit_admin->total_count ) && $wpsmushit_admin->total_count < $args['offset'] ) {
585
+ $get_posts = false;
586
+ }
587
+ }
588
+
589
+ return $resized_images;
590
+ }
591
+
592
+ /**
593
+ * Get all the PNGJPG Converted images
594
+ *
595
+ * @return array Array of post ids of all the converted images
596
+ *
597
+ */
598
+ function converted_images() {
599
+ global $wpsmushit_admin;
600
+ $limit = $wpsmushit_admin->query_limit();
601
+ $get_posts = true;
602
+ $converted_images = array();
603
+ $args = array(
604
+ 'fields' => array( 'ids', 'post_mime_type' ),
605
+ 'post_type' => 'attachment',
606
+ 'post_status' => 'inherit',
607
+ 'orderby' => 'ID',
608
+ 'order' => 'DESC',
609
+ 'posts_per_page' => $limit,
610
+ 'offset' => 0,
611
+ 'meta_key' => WP_SMUSH_PREFIX . 'pngjpg_savings',
612
+ 'update_post_term_cache' => false,
613
+ 'no_found_rows' => true,
614
+ );
615
+ //Loop Over to get all the attachments
616
+ while ( $get_posts ) {
617
+
618
+ //Remove the Filters added by WP Media Folder
619
+ $this->remove_filters();
620
+
621
+ $query = new WP_Query( $args );
622
+
623
+ if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
624
+
625
+ //Filter Posts by mime types
626
+ $posts = $this->filter_by_mime( $query->posts );
627
+
628
+ //Merge the results
629
+ $converted_images = array_merge( $converted_images, $posts );
630
+
631
+ //Update the offset
632
+ $args['offset'] += $limit;
633
+ } else {
634
+ //If we didn't get any posts from query, set $get_posts to false
635
+ $get_posts = false;
636
+ }
637
+
638
+ //If total Count is set, and it is alread lesser than offset, don't query
639
+ if ( ! empty( $wpsmushit_admin->total_count ) && $wpsmushit_admin->total_count < $args['offset'] ) {
640
+ $get_posts = false;
641
+ }
642
+ }
643
+
644
+ return $converted_images;
645
+ }
646
+
647
+ /**
648
+ * Returns the ids and meta which are losslessly compressed
649
+ *
650
+ * Called only if the meta key isn't updated for old images, else it is not used
651
+ *
652
+ * @return array
653
+ */
654
+ function get_lossy_attachments( $attachments = '', $return_count = true ) {
655
+
656
+ $lossy_attachments = array();
657
+ $count = 0;
658
+
659
+ if ( empty( $attachments ) ) {
660
+ //Fetch all the smushed attachment ids
661
+ $attachments = $this->smushed_count( true );
662
+ }
663
+
664
+ //If we dont' have any attachments
665
+ if ( empty( $attachments ) || 0 == count( $attachments ) ) {
666
+ return 0;
667
+ }
668
+
669
+ //Check if image is lossless or lossy
670
+ foreach ( $attachments as $attachment ) {
671
+
672
+ //Check meta for lossy value
673
+ $smush_data = ! empty( $attachment->smush_data ) ? maybe_unserialize( $attachment->smush_data ) : '';
674
+
675
+ //For Nextgen Gallery images
676
+ if ( empty( $smush_data ) && is_array( $attachment ) && ! empty( $attachment['wp_smush'] ) ) {
677
+ $smush_data = ! empty( $attachment['wp_smush'] ) ? $attachment['wp_smush'] : '';
678
+ }
679
+
680
+ //Return if not smushed
681
+ if ( empty( $smush_data ) ) {
682
+ continue;
683
+ }
684
+
685
+ //if stats not set or lossy is not set for attachment, return
686
+ if ( empty( $smush_data['stats'] ) || ! isset( $smush_data['stats']['lossy'] ) ) {
687
+ continue;
688
+ }
689
+
690
+ //Add to array if lossy is not 1
691
+ if ( 1 == $smush_data['stats']['lossy'] ) {
692
+ $count ++;
693
+ if ( ! empty( $attachment->attachment_id ) ) {
694
+ $lossy_attachments[] = $attachment->attachment_id;
695
+ } elseif ( is_array( $attachment ) && ! empty( $attachment['pid'] ) ) {
696
+ $lossy_attachments[] = $attachment['pid'];
697
+ }
698
+ }
699
+ }
700
+ unset( $attachments );
701
+
702
+ if ( $return_count ) {
703
+ return $count;
704
+ }
705
+
706
+ return $lossy_attachments;
707
+ }
708
+
709
+ /**
710
+ * Get the attachment ids with Upfront images
711
+ *
712
+ * @param array $skip_ids
713
+ *
714
+ * @return array|bool
715
+ */
716
+ function get_upfront_images( $skip_ids = array() ) {
717
+
718
+ $query = array(
719
+ 'fields' => array( 'ids', 'post_mime_type' ),
720
+ 'post_type' => 'attachment',
721
+ 'post_status' => 'any',
722
+ 'order' => 'ASC',
723
+ 'posts_per_page' => - 1,
724
+ 'meta_key' => 'upfront_used_image_sizes',
725
+ 'no_found_rows' => true
726
+ );
727
+
728
+ //Skip all the ids which are already in resmush list
729
+ if ( ! empty( $skip_ids ) && is_array( $skip_ids ) ) {
730
+ $query['post__not_in'] = $skip_ids;
731
+ }
732
+
733
+ $results = new WP_Query( $query );
734
+
735
+ if ( ! is_wp_error( $results ) && $results->post_count > 0 ) {
736
+ $posts = $this->filter_by_mime( $results->posts );
737
+
738
+ return $posts;
739
+ } else {
740
+ return false;
741
+ }
742
+ }
743
+ }
744
+
745
+ /**
746
+ * Initialise class
747
+ */
748
+ global $wpsmush_db;
749
+ $wpsmush_db = new WpSmushDB();
750
+ }
lib/class-wp-smush-dir.php ADDED
@@ -0,0 +1,1277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package WP Smush
4
+ * @subpackage Admin
5
+ * @since 2.6
6
+ *
7
+ * @author Umesh Kumar <umesh@incsub.com>
8
+ *
9
+ * @copyright (c) 2016, Incsub (http://incsub.com)
10
+ */
11
+
12
+ if ( ! class_exists( 'WpSmushDir' ) ) {
13
+
14
+ class WpSmushDir {
15
+
16
+ /**
17
+ * @var Contains a list of optimised images
18
+ */
19
+ public $optimised_images;
20
+
21
+ /**
22
+ * @var Total Stats for the image optimisation
23
+ *
24
+ */
25
+ public $stats;
26
+
27
+ function __construct() {
28
+
29
+ if ( ! $this->should_continue() ) {
30
+ return;
31
+ }
32
+
33
+ global $WpSmush;
34
+
35
+
36
+ //Hook early for free version, in order to display it before the advanced settings
37
+ add_action( 'wp_smush_before_advanced_settings', array( $this, 'ui' ) );
38
+
39
+ //Hook UI at the end of Settings UI
40
+ add_action( 'smush_settings_ui_bottom', array( $this, 'ui' ) );
41
+
42
+ //Output Stats after Resize savings
43
+ add_action( 'stats_ui_after_resize_savings', array( $this, 'stats_ui' ) );
44
+
45
+ //Handle Ajax request 'smush_get_directory_list'
46
+ add_action( 'wp_ajax_smush_get_directory_list', array( $this, 'directory_list' ) );
47
+
48
+ //Scan the given directory path for the list of images
49
+ add_action( 'wp_ajax_image_list', array( $this, 'image_list' ) );
50
+
51
+ //Handle Ajax Request to optimise images
52
+ add_action( 'wp_ajax_optimise', array( $this, 'optimise' ) );
53
+
54
+ //Handle Exclude path request
55
+ add_action( 'wp_ajax_smush_exclude_path', array( $this, 'smush_exclude_path' ) );
56
+
57
+ //Handle Ajax request: resume scan
58
+ add_action( 'wp_ajax_resume_scan', array( $this, 'resume_scan' ) );
59
+
60
+ //Handle Ajax request for directory smush stats
61
+ add_action( 'wp_ajax_get_dir_smush_stats', array( $this, 'get_dir_smush_stats' ) );
62
+
63
+ }
64
+
65
+ /**
66
+ * Do not display Directory smush for Subsites
67
+ *
68
+ * @return bool True/False, whether to display the Directory smush or not
69
+ *
70
+ */
71
+ function should_continue() {
72
+
73
+ //Do not show directory smush, if not main site in a network
74
+ if ( is_multisite() && ! is_main_site() ) {
75
+ return false;
76
+ }
77
+
78
+ return true;
79
+ }
80
+
81
+ function stats_ui() { ?>
82
+ <hr/><?php
83
+ $dir_smush_stats = get_option( 'dir_smush_stats' );
84
+ $human = $percent = 0;
85
+ if ( ! empty( $dir_smush_stats ) && ! empty( $dir_smush_stats['dir_smush'] ) ) {
86
+ $human = ! empty( $dir_smush_stats['dir_smush']['percent'] ) && ! $dir_smush_stats['dir_smush']['percent'] > 0 ? $dir_smush_stats['dir_smush']['bytes'] : 0;
87
+ $percent = ! empty( $dir_smush_stats['dir_smush']['percent'] ) && $dir_smush_stats['dir_smush']['percent'] > 0 ? number_format_i18n( $dir_smush_stats['dir_smush']['percent'], 1, '.', '' ) : 0;
88
+ } ?>
89
+ <!-- Savings from Directory Smush -->
90
+ <div class="row smush-dir-savings">
91
+ <span class="float-l wp-smush-stats-label"><strong><?php esc_html_e( "DIRECTORY SMUSH SAVINGS", "wp-smushit" ); ?></strong></span>
92
+ <span class="float-r wp-smush-stats"><?php
93
+ if ( ! empty( $dir_smush_stats ) && $human == 0 && $percent < 1 ) {
94
+ //If smush percentage is lower, Show stats as < 1Kb
95
+ $human = "< 1KB";
96
+ $percent = "< 1";
97
+ } ?>
98
+ <span class="spinner" style="visibility: visible"
99
+ title="<?php esc_html_e( "Updating Stats", "wp-smushit" ); ?>"></span>
100
+ <span class="wp-smush-stats-human"><?php echo ! empty( $human ) ? $human : ''; ?></span><?php
101
+ if ( $percent > 1 ) { ?>
102
+ <span class="wp-smush-stats-sep">/</span>
103
+ <span class="wp-smush-stats-percent"><?php echo ! empty( $percent ) ? $percent : ''; ?>%</span><?php
104
+ } ?>
105
+ </span>
106
+ </div><?php
107
+ }
108
+
109
+ /**
110
+ * Create the Smush image table to store the paths of scanned images, and stats
111
+ */
112
+ function create_table() {
113
+ global $wpdb;
114
+
115
+ $charset_collate = $wpdb->get_charset_collate();
116
+
117
+ //Use a lower index size
118
+ $path_index_size = 191;
119
+
120
+ /**
121
+ * Table: wp_smush_dir_images
122
+ * Columns:
123
+ * id -> Auto Increment ID
124
+ * path -> Absolute path to the image file
125
+ * resize -> Whether the image was resized or not
126
+ * image_size -> Current image size post optimisation
127
+ * orig_size -> Original image size before optimisation
128
+ * file_time -> Unix time for the file creation, to match it against the current creation time,
129
+ * in order to confirm if it is optimised or not
130
+ * last_scan -> Timestamp, Get images form last scan by latest timestamp
131
+ * are from latest scan only and not the whole list from db
132
+ * meta -> For any future use
133
+ *
134
+ */
135
+ $sql = "CREATE TABLE {$wpdb->prefix}smush_dir_images (
136
+ id mediumint(9) NOT NULL AUTO_INCREMENT,
137
+ path text NOT NULL,
138
+ resize varchar(55),
139
+ error varchar(55) DEFAULT NULL,
140
+ image_size int(10) unsigned,
141
+ orig_size int(10) unsigned,
142
+ file_time int(10) unsigned,
143
+ last_scan timestamp DEFAULT '0000-00-00 00:00:00',
144
+ meta text,
145
+ UNIQUE KEY id (id),
146
+ UNIQUE KEY path (path($path_index_size)),
147
+ KEY image_size (image_size)
148
+ ) $charset_collate;";
149
+
150
+ // include the upgrade library to initialize a table
151
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
152
+ dbDelta( $sql );
153
+ }
154
+
155
+ /**
156
+ * Get the image ids and path for last scanned images
157
+ *
158
+ * @return array Array of last scanned images containing image id and path
159
+ */
160
+ function get_scanned_images() {
161
+ global $wpdb;
162
+
163
+ $query = "SELECT id, path, orig_size FROM {$wpdb->prefix}smush_dir_images WHERE last_scan = (SELECT MAX(last_scan) FROM {$wpdb->prefix}smush_dir_images ) GROUP BY id ORDER BY id";
164
+
165
+ $results = $wpdb->get_results( $query, ARRAY_A );
166
+
167
+ //Return image ids
168
+ if ( is_wp_error( $results ) ) {
169
+ error_log( sprintf( "WP Smush Query Error in %s at %s: %s", __FILE__, __LINE__, $results->get_error_message() ) );
170
+ $results = array();
171
+ }
172
+
173
+ return $results;
174
+ }
175
+
176
+ /**
177
+ * Check if there is any unsmushed image from last scan
178
+ *
179
+ * @return bool True/False
180
+ *
181
+ */
182
+ function get_unsmushed_image() {
183
+ global $wpdb;
184
+ $query = $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}smush_dir_images WHERE image_size IS NULL && last_scan = (SELECT MAX(last_scan) FROM {$wpdb->prefix}smush_dir_images t2 ) GROUP BY id ORDER BY id LIMIT %d", 1 );
185
+ $results = $wpdb->get_col( $query );
186
+
187
+ //If The query went through
188
+ if ( empty( $results ) ) {
189
+ return false;
190
+ } elseif ( is_wp_error( $results ) ) {
191
+ error_log( sprintf( "WP Smush Query Error in %s at %s: %s", __FILE__, __LINE__, $results->get_error_message() ) );
192
+
193
+ return false;
194
+ }
195
+
196
+ return true;
197
+ }
198
+
199
+
200
+ /**
201
+ * Prints a resume button if required
202
+ */
203
+ function show_resume_button() {
204
+ if ( ! $this->get_unsmushed_image() ) {
205
+ return null;
206
+ }
207
+ //Print the button ?>
208
+ <button class="wp-smush-resume wp-smush-button button"><?php esc_html_e( "RESUME LAST SCAN", "wp-smushit" ); ?></button><?php
209
+ }
210
+
211
+ /**
212
+ * Output the required UI for WP Smush All page
213
+ */
214
+ function ui() {
215
+ global $WpSmush, $wpsmushit_admin;
216
+
217
+ //Print Directory Smush UI, if not a network site
218
+ if ( is_network_admin() ) {
219
+ return;
220
+ }
221
+
222
+ //Remove the early hook
223
+ if ( $WpSmush->validate_install() ) {
224
+ remove_action( 'wp_smush_before_advanced_settings', array( $this, 'ui' ) );
225
+ } else {
226
+ remove_action( 'smush_settings_ui_bottom', array( $this, 'ui' ) );
227
+ }
228
+
229
+ //Reset the bulk limit
230
+ if ( ! $WpSmush->validate_install() ) {
231
+ //Reset Transient
232
+ $wpsmushit_admin->check_bulk_limit( true, 'dir_sent_count' );
233
+ }
234
+
235
+ wp_nonce_field( 'smush_get_dir_list', 'list_nonce' );
236
+ wp_nonce_field( 'smush_get_image_list', 'image_list_nonce' );
237
+
238
+ $upgrade_link = '<a href="' . esc_url( $wpsmushit_admin->upgrade_url ) . '" title="' . esc_html__( "WP Smush Pro", "wp-smushit" ) . '">';
239
+ /** Directory Browser and Image List **/
240
+ $wpsmushit_admin->bulk_ui->container_header( 'wp-smush-dir-browser', 'wp-smush-dir-browser', esc_html__( "DIRECTORY SMUSH", "wp-smushit" ) ); ?>
241
+ <div class="box-content">
242
+ <div class="row">
243
+ <div class="wp-smush-dir-desc roboto-regular">
244
+ <!-- Description -->
245
+ <?php esc_html_e( "In addition to smushing your media uploads, you may want to also smush images living outside your uploads directory. Simply add any directories you wish to smush and bulk smush away!", "wp-smushit" ); ?>
246
+ </div>
247
+ <!-- Directory Path -->
248
+ <input type="hidden" class="wp-smush-dir-path" value=""/>
249
+ <div class="wp-smush-scan-result hidden">
250
+ <hr class="primary-separator"/>
251
+ <div class="content">
252
+ <!-- Show a list of images, inside a fixed height div, with a scroll. As soon as the image is
253
+ optimised show a tick mark, with savings below the image. Scroll the li each time for the
254
+ current optimised image -->
255
+ </div>
256
+ <!-- Notices -->
257
+ <div class="wp-smush-notice wp-smush-dir-all-done hidden" tabindex="0">
258
+ <i class="dev-icon dev-icon-tick"></i><?php esc_html_e( "All images are smushed and up to date. Awesome!", "wp-smushit" ); ?>
259
+ </div>
260
+ <div class="wp-smush-notice wp-smush-dir-remaining hidden" tabindex="0">
261
+ <i class="dev-icon wdv-icon wdv-icon-fw wdv-icon-exclamation-sign"></i><?php printf( esc_html__( "%s/%s image(s) were successfully smushed, however %s image(s) could not be smushed due to an error.", "wp-smushit" ), '<span class="wp-smush-dir-smushed"></span>', '<span class="wp-smush-dir-total"></span>', '<span class="wp-smush-dir-remaining"></span>' ); ?>
262
+ </div>
263
+ <div class="wp-smush-notice wp-smush-dir-limit hidden" tabindex="0">
264
+ <i class="dev-icon wdv-icon wdv-icon-fw wdv-icon-info-sign"></i><?php printf( esc_html__( " %sUpgrade to pro%s to bulk smush all your directory images with one click. Free users can smush 50 images with each click.", "wp-smushit" ), '<a href="' . esc_url( $wpsmushit_admin->upgrade_url ) . '" target="_blank" title="' . esc_html__( "WP Smush Pro", "wp-smushit" ) . '">', '</a>' ); ?>
265
+ </div>
266
+ <div class="wp-smush-all-button-wrap bottom">
267
+ <!-- @todo: Check status of the images in last scan and do not show smush now button, if already finished -->
268
+ <button class="wp-smush-start"><?php esc_html_e( "BULK SMUSH", "wp-smushit" ); ?></button>
269
+ <button type="button"
270
+ title="<?php esc_html_e( "Click to stop the directory smushing process.", "wp-smushit" ); ?>"
271
+ class="button button-grey wp-smush-pause disabled"><?php esc_html_e( "CANCEL", "wp-smushit" ); ?></button>
272
+ <span class="spinner"></span>
273
+ </div><?php
274
+ //Nonce Field
275
+ wp_nonce_field( 'wp_smush_all', 'wp-smush-all' ); ?>
276
+ <input type="hidden" name="wp-smush-continue-ajax" value=1>
277
+ </div>
278
+ <div class="dir-smush-button-wrap">
279
+ <button class="wp-smush-browse wp-smush-button button"><?php esc_html_e( "CHOOSE DIRECTORY", "wp-smushit" ); ?></button><?php
280
+ //Optionally show a resume button, if there were images left from last scan
281
+ $this->show_resume_button(); ?>
282
+ <span class="spinner"></span>
283
+ </div>
284
+ <div class="dev-overlay wp-smush-list-dialog roboto-regular">
285
+ <div class="back"></div>
286
+ <div class="box-scroll">
287
+ <div class="box">
288
+ <div class="title"><h3><?php esc_html_e( "Directory list", "wp-smushit" ); ?></h3>
289
+ <div class="close" aria-label="Close">×</div>
290
+ </div>
291
+ <div class="wp-smush-instruct"><?php esc_html_e( "Choose the folder you wish to smush.", "wp-smushit" ); ?></div>
292
+ <div class="content">
293
+ </div>
294
+ <div class="wp-smush-select-button-wrap">
295
+ <div class="wp-smush-section-desc"><?php esc_html_e( "Smush will also include any images in sub folders of your selected folder.", "wp-smushit" ); ?></div>
296
+ <div class="wp-smush-select-button-wrap-child">
297
+ <span class="spinner"></span>
298
+ <button class="wp-smush-select-dir"><?php esc_html_e( "ADD DIRECTORY", "wp-smushit" ); ?></button>
299
+ </div>
300
+ </div>
301
+ </div>
302
+ </div>
303
+ </div>
304
+ <input type="hidden" name="wp-smush-base-path" value="<?php echo $this->get_root_path(); ?>">
305
+ </div>
306
+ </div><?php
307
+ echo "</section>";
308
+
309
+ }
310
+
311
+ /**
312
+ * Check if the image file is media library file
313
+ *
314
+ * @param $file_path
315
+ *
316
+ * @return bool
317
+ *
318
+ */
319
+ function is_media_library_file( $file_path ) {
320
+ $upload_dir = wp_upload_dir();
321
+ $upload_path = $upload_dir["path"];
322
+
323
+ //Get the base path of file
324
+ $base_dir = dirname( $file_path );
325
+ if ( $base_dir == $upload_path ) {
326
+ return true;
327
+ }
328
+
329
+ return false;
330
+ }
331
+
332
+ /**
333
+ * Return a directory/File list
334
+ */
335
+ function directory_list() {
336
+ //Check For Permission
337
+ if ( ! current_user_can( 'manage_options' ) || ! is_user_logged_in() ) {
338
+ wp_send_json_error( "Unauthorized" );
339
+ }
340
+ //Verify nonce
341
+ check_ajax_referer( 'smush_get_dir_list', 'list_nonce' );
342
+
343
+ //Get the Root path for a main site or subsite
344
+ $root = $this->get_root_path();
345
+
346
+ $postDir = rawurldecode( $root . ( isset( $_GET['dir'] ) ? $_GET['dir'] : null ) );
347
+
348
+ $supported_image = array(
349
+ 'gif',
350
+ 'jpg',
351
+ 'jpeg',
352
+ 'png'
353
+ );
354
+
355
+ $list = '';
356
+
357
+ // set checkbox if multiSelect set to true
358
+ $onlyFolders = ( '/' == $_GET['dir'] || isset( $_GET['onlyFolders'] ) && $_GET['onlyFolders'] == 'true' ) ? true : false;
359
+ $onlyFiles = ( isset( $_GET['onlyFiles'] ) && $_GET['onlyFiles'] == 'true' ) ? true : false;
360
+
361
+ if ( file_exists( $postDir ) ) {
362
+
363
+ $files = scandir( $postDir );
364
+ $returnDir = substr( $postDir, strlen( $root ) );
365
+
366
+ natcasesort( $files );
367
+
368
+ if ( count( $files ) > 2 ) {
369
+ $list = "<ul class='jqueryFileTree'>";
370
+ foreach ( $files as $file ) {
371
+
372
+ $htmlRel = htmlentities( $returnDir . $file );
373
+ $htmlName = htmlentities( $file );
374
+ $ext = preg_replace( '/^.*\./', '', $file );
375
+
376
+ if ( file_exists( $postDir . $file ) && $file != '.' && $file != '..' ) {
377
+ if ( is_dir( $postDir . $file ) && ( ! $onlyFiles || $onlyFolders ) && ! $this->skip_dir( $postDir . $file ) ) {
378
+ //Skip Uploads folder - Media Files
379
+ $list .= "<li class='directory collapsed'><a rel='" . $htmlRel . "/'>" . $htmlName . "</a></li><br />";
380
+ } else if ( ( ! $onlyFolders || $onlyFiles ) && in_array( $ext, $supported_image ) && ! $this->is_media_library_file( $postDir . $file ) ) {
381
+ $list .= "<li class='file ext_{$ext}'><a rel='" . $htmlRel . "'>" . $htmlName . "</a></li><br />";
382
+ }
383
+ }
384
+ }
385
+
386
+ $list .= "</ul>";
387
+ }
388
+ }
389
+ echo $list;
390
+ die();
391
+
392
+ }
393
+
394
+ public function get_root_path() {
395
+ if ( is_main_site() ) {
396
+
397
+ return rtrim( get_home_path(), '/' );
398
+ } else {
399
+ $up = wp_upload_dir();
400
+
401
+ return $up['basedir'];
402
+ }
403
+ }
404
+
405
+ /**
406
+ * @param SplFileInfo $file
407
+ * @param mixed $key
408
+ * @param RecursiveCallbackFilterIterator $iterator
409
+ *
410
+ * @return bool True if you need to recurse or if the item is acceptable
411
+ */
412
+ function exclude( $file, $key, $iterator ) {
413
+ // Will exclude everything under these directories
414
+ $exclude_dir = array( '.git', 'test' );
415
+
416
+ //Exclude from the list, if one of the media upload folders
417
+ if ( $this->skip_dir( $file->getPath() ) ) {
418
+ return true;
419
+ }
420
+
421
+ //Exclude Directories like git, and test
422
+ if ( $iterator->hasChildren() && ! in_array( $file->getFilename(), $exclude_dir ) ) {
423
+ return true;
424
+ }
425
+
426
+ //Do not exclude, if image
427
+ if ( $file->isFile() && $this->is_image_from_extension( $file->getPath() ) ) {
428
+ return true;
429
+ }
430
+
431
+ return $file->isFile();
432
+ }
433
+
434
+ /**
435
+ * Display a progress bar for the images in particular directory
436
+ *
437
+ * @param $count
438
+ * @param $optimised
439
+ * @param $dir_path
440
+ *
441
+ * @return bool|string
442
+ */
443
+ function progress_ui( $count, $optimised, $dir_path ) {
444
+
445
+ if ( ! $count ) {
446
+ return false;
447
+ }
448
+
449
+ $width = ( $optimised > 0 ) ? ( $optimised / $count ) * 100 : 0;
450
+
451
+ $class = 0 < $width && 100 == $width ? 'complete' : 'partial';
452
+ $o_class = 0 == $width ? 'hidden' : '';
453
+
454
+ $content = "<div class='wp-smush-dir-progress-wrap {$o_class}'>";
455
+ $content .= '<span class="smush-percent">' . number_format_i18n( $width, 0 ) . '% </span>';
456
+ $content .= "<div class='wp-smush-dir-progress-wrap-inner'>
457
+ <span class='wp-smush-dir-progress {$class}' style='width: {$width}px'></span>
458
+ </div>
459
+ </div>";
460
+
461
+ $content .= 0 == $width ? "<a href='#' class='wp-smush-exclude-dir' data-path='" . $dir_path . "' title='" . esc_html__( "Exclude directory from Smush List", "wp-smushit" ) . "'>&times;</a>" : '';
462
+
463
+ return $content;
464
+ }
465
+
466
+ /**
467
+ * Get the image list in a specified directory path
468
+ *
469
+ * @param string $path
470
+ *
471
+ * @return string
472
+ */
473
+ function get_image_list( $path = '' ) {
474
+ global $wpdb;
475
+
476
+ $base_dir = empty( $path ) ? $_GET['path'] : $path;
477
+ //Directory Path
478
+ $base_dir = realpath( $base_dir );
479
+
480
+ //Store the path in option
481
+ update_option( 'wp_smush_dir_path', $base_dir );
482
+
483
+ //Directory Iterator, Exclude . and ..
484
+ $dirIterator = new RecursiveDirectoryIterator(
485
+ $base_dir
486
+ //PHP 5.2 compatibility
487
+ //RecursiveDirectoryIterator::SKIP_DOTS
488
+ );
489
+
490
+ $filtered_dir = new WPSmushRecursiveFilterIterator( $dirIterator );
491
+
492
+ //File Iterator
493
+ $iterator = new RecursiveIteratorIterator( $filtered_dir,
494
+ RecursiveIteratorIterator::CHILD_FIRST
495
+ );
496
+
497
+ //Iterate over the file List
498
+ $files_arr = array();
499
+ $images = array();
500
+ $count = 0;
501
+ $timestamp = gmdate( 'Y-m-d H:i:s' );
502
+ foreach ( $iterator as $path ) {
503
+
504
+ //Used in place of Skip Dots, For php 5.2 compatability
505
+ if ( basename( $path ) == '..' || basename( $path ) == '.' ) {
506
+ continue;
507
+ }
508
+ if ( $path->isFile() ) {
509
+ $file_path = $path->getPathname();
510
+ $file_name = $path->getFilename();
511
+
512
+ if ( $this->is_image( $file_path ) && ! $this->is_media_library_file( $file_path ) ) {
513
+
514
+ /** To generate Markup **/
515
+ $dir_name = dirname( $file_path );
516
+
517
+ //Initialize if dirname doesn't exists in array already
518
+ if ( ! isset( $files_arr[ $dir_name ] ) ) {
519
+ $files_arr[ $dir_name ] = array();
520
+ }
521
+ $files_arr[ $dir_name ][ $file_name ] = $file_path;
522
+ /** End */
523
+
524
+ //Get the file modification time
525
+ $file_time = @filectime( $file_path );
526
+
527
+ /** To be stored in DB, Part of code borrowed from Ewwww Optimiser */
528
+ $image_size = $path->getSize();
529
+ $images[] = "('" . utf8_encode( $file_path ) . "',$image_size, $file_time, '$timestamp' )";
530
+ $count ++;
531
+ }
532
+ }
533
+ //Store the Images in db at an interval of 5k
534
+ if ( $count >= 5000 ) {
535
+ $count = 0;
536
+ $query = "INSERT INTO {$wpdb->prefix}smush_dir_images (path,orig_size,file_time,last_scan) VALUES %s ON DUPLICATE KEY UPDATE image_size = IF( file_time < VALUES(file_time), NULL, image_size ), image_size = IF( file_time < VALUES(file_time), VALUES(file_time), file_time ), last_scan = VALUES( last_scan )";
537
+ $sql = sprintf( $query, implode( ',', $images ) );
538
+ $wpdb->query( $sql );
539
+ $images = array();
540
+ }
541
+ }
542
+
543
+ //Update rest of the images
544
+ if ( ! empty( $images ) && $count > 0 ) {
545
+ $query = "INSERT INTO {$wpdb->prefix}smush_dir_images (path,orig_size,file_time,last_scan) VALUES %s ON DUPLICATE KEY UPDATE image_size = IF( file_time < VALUES(file_time), NULL, image_size ), file_time = IF( file_time < VALUES(file_time), VALUES(file_time), file_time ), last_scan = VALUES( last_scan )";
546
+ $sql = sprintf( $query, implode( ',', $images ) );
547
+ $wpdb->query( $sql );
548
+ }
549
+
550
+ //remove scanne dimages from cache
551
+ wp_cache_delete( 'wp_smush_scanned_images' );
552
+
553
+ //Get the image ids
554
+ $images = $this->get_scanned_images();
555
+
556
+ //Store scanned images in cache
557
+ wp_cache_add( 'wp_smush_scanned_images', $images );
558
+
559
+ return array( 'files_arr' => $files_arr, 'base_dir' => $base_dir, 'image_items' => $images );
560
+ }
561
+
562
+ /**
563
+ * Sends a Ajax response if no images are found in selected directory
564
+ */
565
+ function send_error() {
566
+ $message = sprintf( "<div class='wp-smush-info notice notice-info roboto-regular'>%s</div>", esc_html__( "We could not find any images in the selected directory.", "wp-smushit" ) );
567
+ wp_send_json_error( array( 'message' => $message ) );
568
+ }
569
+
570
+ /**
571
+ * Handles Ajax request to obtain the Image list within a selected directory path
572
+ *
573
+ */
574
+ function image_list() {
575
+
576
+ //Check For Permission
577
+ if ( ! current_user_can( 'manage_options' ) ) {
578
+ wp_send_json_error( "Unauthorized" );
579
+ }
580
+
581
+ //Verify nonce
582
+ check_ajax_referer( 'smush_get_image_list', 'image_list_nonce' );
583
+
584
+ //Check if directory path is set or not
585
+ if ( empty( $_GET['smush_path'] ) ) {
586
+ wp_send_json_error( "Empth Directory Path" );
587
+ }
588
+
589
+ //Remove the transient
590
+ delete_transient( 'wp_smush_dir_curr_id' );
591
+
592
+ //Get the File list
593
+ $files = $this->get_image_list( $_GET['smush_path'] );
594
+
595
+ //If files array is empty, send a message
596
+ if ( empty( $files['files_arr'] ) ) {
597
+ $this->send_error();
598
+ }
599
+
600
+ //Get the markup from the list
601
+ $markup = $this->generate_markup( $files );
602
+
603
+ //Send response
604
+ wp_send_json_success( $markup );
605
+
606
+ }
607
+
608
+ /**
609
+ * Check whether the given path is a image or not
610
+ *
611
+ * @param $path
612
+ *
613
+ * @return bool
614
+ *
615
+ */
616
+ function is_image( $path ) {
617
+
618
+ //Check if the path is valid
619
+ if ( ! file_exists( $path ) || ! $this->is_image_from_extension( $path ) ) {
620
+ return false;
621
+ }
622
+
623
+ $a = @getimagesize( $path );
624
+
625
+ //If a is not set
626
+ if ( ! $a || empty( $a ) ) {
627
+ return false;
628
+ }
629
+
630
+ $image_type = $a[2];
631
+
632
+ if ( in_array( $image_type, array( IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG ) ) ) {
633
+ return true;
634
+ }
635
+
636
+ return false;
637
+ }
638
+
639
+ /**
640
+ * Obtain the path to the admin directory.
641
+ *
642
+ * @return string
643
+ *
644
+ * Thanks @andrezrv (Github)
645
+ *
646
+ */
647
+ function get_admin_path() {
648
+ // Replace the site base URL with the absolute path to its installation directory.
649
+ $admin_path = rtrim( str_replace( get_bloginfo( 'url' ) . '/', ABSPATH, get_admin_url() ), '/' );
650
+
651
+ // Make it filterable, so other plugins can hook into it.
652
+ $admin_path = apply_filters( 'wp_smush_get_admin_path', $admin_path );
653
+
654
+ return $admin_path;
655
+ }
656
+
657
+ /**
658
+ * Check if the given file path is a supported image format
659
+ *
660
+ * @param $path File Path
661
+ *
662
+ * @return bool Whether a image or not
663
+ */
664
+ function is_image_from_extension( $path ) {
665
+ $supported_image = array(
666
+ 'gif',
667
+ 'jpg',
668
+ 'jpeg',
669
+ 'png'
670
+ );
671
+ $ext = strtolower( pathinfo( $path, PATHINFO_EXTENSION ) ); // Using strtolower to overcome case sensitive
672
+ if ( in_array( $ext, $supported_image ) ) {
673
+ return true;
674
+ }
675
+
676
+ return false;
677
+ }
678
+
679
+ /**
680
+ * Excludes the Media Upload Directory ( Checks for Year and Month )
681
+ *
682
+ * @param $path
683
+ *
684
+ * @return bool
685
+ *
686
+ * Borrowed from Shortpixel - (y)
687
+ *
688
+ * @todo: Add a option to filter images if User have turned off the Year and Month Organize option
689
+ *
690
+ */
691
+ public function skip_dir( $path ) {
692
+
693
+ //Admin Directory path
694
+ $admin_dir = $this->get_admin_path();
695
+
696
+ //Includes directory path
697
+ $includes_dir = ABSPATH . WPINC;
698
+
699
+ //Upload Directory
700
+ $upload_dir = wp_upload_dir();
701
+ $base_dir = $upload_dir["basedir"];
702
+
703
+ $skip = false;
704
+
705
+ //Skip sites folder for Multisite
706
+ if ( false !== strpos( $path, $base_dir . '/sites' ) ) {
707
+ $skip = true;
708
+ } else if ( false !== strpos( $path, $base_dir ) ) {
709
+ //If matches the current upload path
710
+ //contains one of the year subfolders of the media library
711
+ $pathArr = explode( '/', str_replace( $base_dir . '/', "", $path ) );
712
+ if ( count( $pathArr ) >= 1
713
+ && is_numeric( $pathArr[0] ) && $pathArr[0] > 1900 && $pathArr[0] < 2100 //contains the year subfolder
714
+ && ( count( $pathArr ) == 1 //if there is another subfolder then it's the month subfolder
715
+ || ( is_numeric( $pathArr[1] ) && $pathArr[1] > 0 && $pathArr[1] < 13 ) )
716
+ ) {
717
+ $skip = true;
718
+ }
719
+ } elseif ( ( false !== strpos( $path, $admin_dir ) ) || false !== strpos( $path, $includes_dir ) ) {
720
+ $skip = true;
721
+ }
722
+
723
+ /**
724
+ * Can be used to skip/include folders matching a specific directory path
725
+ *
726
+ */
727
+ apply_filters( 'wp_smush_skip_folder', $skip, $path );
728
+
729
+ return $skip;
730
+ }
731
+
732
+ /**
733
+ * Creates a tree out of Given path array
734
+ *
735
+ * @param $path_list Array of path and images
736
+ * @param $base_dir Selected Base Path for the image search
737
+ *
738
+ * @return array Array of images, Child Directories and images inside
739
+ *
740
+ */
741
+ function build_tree( $path_list, $base_dir ) {
742
+ $path_tree = array();
743
+ foreach ( $path_list as $path => $images ) {
744
+ $path = str_replace( $base_dir, '', $path );
745
+ $list = explode( '/', trim( $path, '/' ), 3 );
746
+ $last_dir = &$path_tree;
747
+ $length = sizeof( $list );
748
+ foreach ( $list as $dir ) {
749
+ $length --;
750
+ $last_dir =& $last_dir[ $dir ];
751
+ }
752
+ }
753
+
754
+ return $path_tree;
755
+ }
756
+
757
+ /**
758
+ * Returns the count of optimised image
759
+ *
760
+ * @param array $images
761
+ *
762
+ * @return int
763
+ */
764
+ function optimised_count( $images = array() ) {
765
+ //If we have optimised images
766
+ if ( ! empty( $images ) && is_array( $images ) ) {
767
+ $optimised = 0;
768
+ if ( ! is_array( $this->optimised_images ) ) {
769
+ return 0;
770
+ }
771
+ foreach ( $images as $item ) {
772
+ //Check if the image is already in optimised list
773
+ if ( array_key_exists( $item, $this->optimised_images ) ) {
774
+ $optimised ++;
775
+ }
776
+ }
777
+ }
778
+
779
+ return $optimised;
780
+ }
781
+
782
+ /**
783
+ *
784
+ * Search for image id from path
785
+ *
786
+ * @param $path Image path to be searched
787
+ * @param $images Array of images
788
+ *
789
+ * @return image id
790
+ */
791
+ function get_image_id( $path, $images ) {
792
+ foreach ( $images as $key => $val ) {
793
+ if ( $val['path'] === $path ) {
794
+ return $val['id'];
795
+ }
796
+ }
797
+
798
+ return null;
799
+ }
800
+
801
+ /**
802
+ *
803
+ * Search for image id from path
804
+ *
805
+ * @param $path Image path to be searched
806
+ * @param $images Array of images
807
+ *
808
+ * @return image id
809
+ */
810
+ function get_image_path( $id, $images ) {
811
+ foreach ( $images as $key => $val ) {
812
+ if ( $val['id'] === $id ) {
813
+ return $val['path'];
814
+ }
815
+ }
816
+
817
+ return null;
818
+ }
819
+
820
+ /**
821
+ * Search for image from given image id or path
822
+ *
823
+ * @param string $id Image id to search for
824
+ * @param string $path Image path to search for
825
+ * @param $images Image array to search within
826
+ *
827
+ * @return Image array or Empty array
828
+ */
829
+ function get_image( $id = '', $path = '', $images ) {
830
+ foreach ( $images as $key => $val ) {
831
+ if ( ! empty( $id ) && $val['id'] == $id ) {
832
+ return $images[ $key ];
833
+ } elseif ( ! empty( $path ) && $val['path'] == $path ) {
834
+ return $images[ $key ];
835
+ }
836
+ }
837
+
838
+ return array();
839
+ }
840
+
841
+ /*
842
+ * Generate the markup for all the images
843
+ */
844
+ function generate_markup( $images ) {
845
+
846
+ if ( empty( $images ) || empty( $images['files_arr'] ) || empty( $images['image_items'] ) ) {
847
+ return null;
848
+ }
849
+
850
+ $this->total_stats();
851
+
852
+ $div = wp_nonce_field( 'wp-smush-exclude-path', 'exclude-path-nonce', '', false );
853
+ $div .= '<ul class="wp-smush-image-list roboto-regular">';
854
+ //Flag - Whether to print top hr tag or not
855
+ $hr = true;
856
+ //Flag - Not to print hr tag, if first element is ul in the scanned image list
857
+ $index = 1;
858
+ $files_arr = $images['files_arr'];
859
+
860
+ foreach ( $files_arr as $image_path => $image ) {
861
+ $count = sizeof( $image );
862
+ $wrapper_class = '';
863
+ if ( is_array( $image ) && $count > 1 ) {
864
+
865
+ //Get the number of optimised images for the given image array
866
+ $optimised_count = $this->optimised_count( $image );
867
+
868
+ if ( $optimised_count > 0 ) {
869
+ $wrapper_class = $count == $optimised_count ? 'complete' : 'partial';
870
+ }
871
+
872
+ $div .= "<li class='wp-smush-image-ul {$wrapper_class}'>";
873
+ if ( $hr && $index > 1 ) {
874
+ $div .= "<hr/>";
875
+ }
876
+
877
+ $div .= "<span class='wp-smush-li-path'>{$image_path} <span class='wp-smush-image-count'>" . sprintf( esc_html__( "%d images", "wp-smushit" ), $count ) . "</span></span>";
878
+ $div .= $this->progress_ui( $count, $optimised_count, $image_path );
879
+ $div .= "<ul class='wp-smush-image-list-inner'>";
880
+ foreach ( $image as $item ) {
881
+ //Check if the image is already in optimised list
882
+ $class = is_array( $this->optimised_images ) && array_key_exists( $item, $this->optimised_images ) ? ' optimised' : '';
883
+
884
+ $image_id = $this->get_image_id( $item, $images['image_items'] );
885
+ $div .= "<li class='wp-smush-image-ele{$class}' id='{$image_id}'><span class='wp-smush-image-ele-status'></span><span class='wp-smush-image-path'>{$item}</span>";
886
+ //Close LI
887
+ $div .= "</li>";
888
+ }
889
+ $div .= "</ul>
890
+ <hr />
891
+ </li>";
892
+ $hr = false;
893
+ } else {
894
+ $hr = true;
895
+ $image_p = array_pop( $image );
896
+ //Check if the image is already in optimised list
897
+ $class = is_array( $this->optimised_images ) && array_key_exists( $image_p, $this->optimised_images ) ? ' optimised' : '';
898
+ $image_id = $this->get_image_id( $image_p, $images['image_items'] );
899
+ $div .= "<li class='wp-smush-image-ele{$class}' id='{$image_id}'><span class='wp-smush-image-ele-status'></span><span class='wp-smush-image-path'>{$image_p}</span>";
900
+ //Close LI
901
+ $div .= "</li>";
902
+ }
903
+ $index ++;
904
+ }
905
+ $div .= '</ul>';
906
+ $div .= "<span class='waiting-message hidden' title='" . esc_html__( "Waiting..", "wp-smushit" ) . "'></span>";
907
+
908
+ return $div;
909
+
910
+ }
911
+
912
+ /**
913
+ * Fetch all the optimised image, Calculate stats
914
+ *
915
+ * @return array Total Stats
916
+ *
917
+ */
918
+ function total_stats() {
919
+ global $wpdb;
920
+
921
+ $offset = 0;
922
+ $optimised = 0;
923
+ $limit = 1000;
924
+ $images = array();
925
+
926
+ $total = $wpdb->get_col( "SELECT count(id) FROM {$wpdb->prefix}smush_dir_images" );
927
+
928
+ $total = ! empty( $total ) && is_array( $total ) ? $total[0] : 0;
929
+
930
+ while ( $results = $wpdb->get_results( "SELECT path, image_size, orig_size FROM {$wpdb->prefix}smush_dir_images WHERE image_size IS NOT NULL LIMIT $offset, $limit ", ARRAY_A ) ) {
931
+ if ( ! empty( $results ) ) {
932
+ $images = array_merge( $images, $results );
933
+ }
934
+ $offset += $limit;
935
+ }
936
+
937
+ //Iterate over stats, Return Count and savings
938
+ if ( ! empty( $images ) ) {
939
+ $this->stats = array_shift( $images );
940
+ $path = $this->stats['path'];
941
+ $this->optimised_images[ $path ] = $this->stats;
942
+
943
+ foreach ( $images as $im ) {
944
+ foreach ( $im as $key => $val ) {
945
+ if ( 'path' == $key ) {
946
+ $this->optimised_images[ $val ] = $im;
947
+ continue;
948
+ }
949
+ $this->stats[ $key ] += $val;
950
+ }
951
+ $optimised ++;
952
+ }
953
+ }
954
+
955
+ //Get the savings in bytes and percent
956
+ if ( ! empty( $this->stats ) ) {
957
+ $this->stats['bytes'] = $this->stats['orig_size'] - $this->stats['image_size'];
958
+ $this->stats['percent'] = number_format_i18n( ( ( $this->stats['bytes'] / $this->stats['orig_size'] ) * 100 ), 1 );
959
+ //Convert to human readable form
960
+ $this->stats['human'] = size_format( $this->stats['bytes'], 1 );
961
+ }
962
+
963
+ $this->stats['total'] = $total;
964
+ $this->stats['optimised'] = $optimised;
965
+
966
+ return $this->stats;
967
+
968
+ }
969
+
970
+ /**
971
+ * Returns the number of images scanned and optimised
972
+ *
973
+ * @return array
974
+ *
975
+ */
976
+ function last_scan_stats() {
977
+ global $wpdb;
978
+ $query = "SELECT id, image_size, orig_size FROM {$wpdb->prefix}smush_dir_images WHERE last_scan = (SELECT MAX(last_scan) FROM {$wpdb->prefix}smush_dir_images ) GROUP BY id";
979
+ $results = $wpdb->get_results( $query, ARRAY_A );
980
+ $total = count( $results );
981
+ $smushed = 0;
982
+ $stats = array(
983
+ 'image_size' => 0,
984
+ 'orig_size' => 0
985
+ );
986
+
987
+ //Get the Smushed count, and stats sum
988
+ foreach ( $results as $image ) {
989
+ if ( ! is_null( $image['image_size'] ) ) {
990
+ $smushed ++;
991
+ }
992
+ //Summation of stats
993
+ foreach ( $image as $k => $v ) {
994
+ if ( 'id' == $k ) {
995
+ continue;
996
+ }
997
+ $stats[ $k ] += $v;
998
+ }
999
+ }
1000
+
1001
+ //Stats
1002
+ $stats['total'] = $total;
1003
+ $stats['smushed'] = $smushed;
1004
+
1005
+ return $stats;
1006
+ }
1007
+
1008
+ /**
1009
+ * Handles the ajax request for image optimisation in a folder
1010
+ */
1011
+ function optimise() {
1012
+ global $wpdb, $WpSmush, $wpsmushit_admin;
1013
+
1014
+ //Verify the ajax nonce
1015
+ check_ajax_referer( 'wp_smush_all', 'nonce' );
1016
+
1017
+ $error_msg = '';
1018
+ if ( empty( $_GET['image_id'] ) ) {
1019
+ //If there are no stats
1020
+ $error_msg = esc_html__( "Incorrect image id", "wp-smushit" );
1021
+ wp_send_json_error( $error_msg );
1022
+ }
1023
+
1024
+ //Check smush limit for free users
1025
+ if ( ! $WpSmush->validate_install() ) {
1026
+
1027
+ //Free version bulk smush, check the transient counter value
1028
+ $should_continue = $wpsmushit_admin->check_bulk_limit( false, 'dir_sent_count' );
1029
+
1030
+ //Send a error for the limit
1031
+ if ( ! $should_continue ) {
1032
+ wp_send_json_error(
1033
+ array(
1034
+ 'error' => 'dir_smush_limit_exceeded',
1035
+ 'continue' => false
1036
+ )
1037
+ );
1038
+ }
1039
+ }
1040
+
1041
+ $id = intval( $_GET['image_id'] );
1042
+ if ( ! $scanned_images = wp_cache_get( 'wp_smush_scanned_images' ) ) {
1043
+ $scanned_images = $this->get_scanned_images();
1044
+ }
1045
+
1046
+ $image = $this->get_image( $id, '', $scanned_images );
1047
+
1048
+ if ( empty( $image ) ) {
1049
+ //If there are no stats
1050
+ $error_msg = esc_html__( "Could not find image id in last scanned images", "wp-smushit" );
1051
+ wp_send_json_error( $error_msg );
1052
+ }
1053
+
1054
+ $path = $image['path'];
1055
+
1056
+ //We have the image path, optimise
1057
+ $smush_results = $WpSmush->do_smushit( $path );
1058
+
1059
+ if ( is_wp_error( $smush_results ) ) {
1060
+ $error_msg = $smush_results->get_error_message();
1061
+ } else if ( empty( $smush_results['data'] ) ) {
1062
+ //If there are no stats
1063
+ $error_msg = esc_html__( "Image couldn't be optimised", "wp-smushit" );
1064
+ }
1065
+
1066
+ if ( ! empty( $error_msg ) ) {
1067
+
1068
+ //Store the error in DB
1069
+ //All good, Update the stats
1070
+ $query = "UPDATE {$wpdb->prefix}smush_dir_images SET error=%s WHERE id=%d LIMIT 1";
1071
+ $query = $wpdb->prepare( $query, $error_msg, $id );
1072
+ $wpdb->query( $query );
1073
+
1074
+ $error_msg = "<div class='wp-smush-error'>" . $error_msg . "</div>";
1075
+
1076
+ wp_send_json_error(
1077
+ array(
1078
+ 'error' => $error_msg,
1079
+ 'image' => array( 'id' => $id )
1080
+ )
1081
+ );
1082
+ }
1083
+ //Get file time
1084
+ $file_time = @filectime( $path );
1085
+
1086
+ //All good, Update the stats
1087
+ $query = "UPDATE {$wpdb->prefix}smush_dir_images SET image_size=%d, file_time=%d WHERE id=%d LIMIT 1";
1088
+ $query = $wpdb->prepare( $query, $smush_results['data']->after_size, $file_time, $id );
1089
+ $wpdb->query( $query );
1090
+
1091
+ //Get Total stats
1092
+ $this->total_stats();
1093
+
1094
+ //Get the total stats
1095
+ $total = $this->stats;
1096
+ $last_scan = $this->last_scan_stats();
1097
+
1098
+ //Show the image wise stats
1099
+ $image = array(
1100
+ 'id' => $id,
1101
+ 'orig_size' => $image['orig_size'],
1102
+ 'img_size' => $smush_results['data']->after_size
1103
+ );
1104
+
1105
+ $bytes = $image['orig_size'] - $image['img_size'];
1106
+ $image['savings'] = size_format( $bytes, 1 );
1107
+ $image['percent'] = number_format_i18n( ( ( $bytes / $image['orig_size'] ) * 100 ), 1 ) . '%';
1108
+
1109
+ $data = array(
1110
+ 'image' => $image,
1111
+ 'total' => $total,
1112
+ 'latest_scan' => $last_scan
1113
+ );
1114
+ wp_send_json_success( $data );
1115
+ }
1116
+
1117
+ /**
1118
+ * Remove image/image from db based on path details
1119
+ */
1120
+ function smush_exclude_path() {
1121
+
1122
+ //Validate Ajax nonce
1123
+ check_ajax_referer( 'wp-smush-exclude-path', 'nonce' );
1124
+
1125
+ //If we don't have path, send json error
1126
+ if ( empty( $_POST['path'] ) ) {
1127
+ wp_send_json_error( 'missing_path' );
1128
+ }
1129
+
1130
+ global $wpdb;
1131
+
1132
+ $path = realpath( $_POST['path'] );
1133
+ $table = "{$wpdb->prefix}smush_dir_images";
1134
+ if ( is_file( $path ) ) {
1135
+ $sql = sprintf( "DELETE FROM $table WHERE path='%s'", $path );
1136
+ } else {
1137
+ $sql = sprintf( "DELETE FROM $table WHERE path LIKE '%s'", '%' . $path . '%' );
1138
+ }
1139
+
1140
+ //Execute the query
1141
+ $result = $wpdb->query( $sql );
1142
+
1143
+ if ( $result ) {
1144
+ wp_send_json_success();
1145
+ } else {
1146
+ wp_send_json_error();
1147
+ }
1148
+ }
1149
+
1150
+ /**
1151
+ * Send the markup for image list scanned from a directory path
1152
+ *
1153
+ */
1154
+ function resume_scan() {
1155
+ $dir_path = get_option( 'wp_smush_dir_path' );
1156
+
1157
+ //If we don't get an error path, return an error message
1158
+ if ( empty( $dir_path ) ) {
1159
+ $message = "<div class='error'>" . esc_html__( "We were unable to retrieve the image list from last scan, please continue with a latest scan", "wp-smushit" ) . "</div>";
1160
+ wp_send_json_error( array( 'message' => $message ) );
1161
+ }
1162
+
1163
+ //Else, Get the image list and then markup
1164
+ $file_list = $this->get_image_list( $dir_path );
1165
+
1166
+ //If there are no image files in selected directory
1167
+ if ( empty( $file_list['files_arr'] ) ) {
1168
+ $this->send_error();
1169
+ }
1170
+
1171
+ $markup = $this->generate_markup( $file_list );
1172
+
1173
+ //Send response
1174
+ wp_send_json_success( $markup );
1175
+ }
1176
+
1177
+ /**
1178
+ * Combine the stats from Directory Smush and Media Library Smush
1179
+ *
1180
+ * @param $stats Directory Smush stats
1181
+ *
1182
+ * @return array Combined array of Stats
1183
+ */
1184
+ function combined_stats( $stats ) {
1185
+
1186
+ if ( empty( $stats ) || empty( $stats['percent'] ) || empty( $stats['bytes'] ) ) {
1187
+ return array();
1188
+ }
1189
+
1190
+ global $wpsmushit_admin;
1191
+
1192
+ $result = array();
1193
+ $dasharray = 125.663706144;
1194
+
1195
+ //Initialize Global Stats
1196
+ $wpsmushit_admin->setup_global_stats();
1197
+
1198
+ //@todo: Redundant code, Move this to a single function
1199
+ $smushed_count = ( $resmush_count = count( $wpsmushit_admin->resmush_ids ) ) > 0 ? $wpsmushit_admin->total_count - ( $resmush_count + $wpsmushit_admin->remaining_count ) : $wpsmushit_admin->smushed_count;
1200
+ $smushed_count = $smushed_count > 0 ? $smushed_count : 0;
1201
+
1202
+ //Get the total/Smushed attachment count
1203
+ $total_attachments = $wpsmushit_admin->total_count + $stats['total'];
1204
+ $total_images = $wpsmushit_admin->stats['total_images'] + $stats['total'];
1205
+
1206
+ $smushed = $smushed_count + $stats['optimised'];
1207
+ $savings = ! empty( $wpsmushit_admin->stats ) ? $wpsmushit_admin->stats['bytes'] + $stats['bytes'] : $stats['bytes'];
1208
+ $size_before = ! empty( $wpsmushit_admin->stats ) ? $wpsmushit_admin->stats['size_before'] + $stats['orig_size'] : $stats['orig_size'];
1209
+ $percent = $size_before > 0 ? ( $savings / $size_before ) * 100 : 0;
1210
+
1211
+ //Store the stats in array
1212
+ $result = array(
1213
+ 'total_count' => $total_attachments,
1214
+ 'smushed_count' => $smushed,
1215
+ 'savings' => size_format( $savings ),
1216
+ 'percent' => round( $percent, 1 ),
1217
+ 'image_count' => $total_images,
1218
+ 'dash_offset' => $total_attachments > 0 ? $dasharray - ( $dasharray * ( $smushed / $total_attachments ) ) : $dasharray,
1219
+ 'tooltip_text' => ! empty( $total_images ) ? sprintf( __( "You've smushed %d images in total.", "wp-smushit" ), $total_images ) : ''
1220
+ );
1221
+
1222
+ return $result;
1223
+ }
1224
+
1225
+ /**
1226
+ * Returns Directory Smush stats and Cumulative stats
1227
+ *
1228
+ */
1229
+ function get_dir_smush_stats() {
1230
+
1231
+ $result = array();
1232
+
1233
+ //Store the Total/Smushed count
1234
+ $stats = $this->total_stats();
1235
+
1236
+ $result['dir_smush'] = $stats;
1237
+
1238
+ //Cumulative Stats
1239
+ $result['combined_stats'] = $this->combined_stats( $stats );
1240
+
1241
+ //Store the stats in options table
1242
+ update_option( 'dir_smush_stats', $result, false );
1243
+
1244
+ //Send ajax response
1245
+ wp_send_json_success( $result );
1246
+ }
1247
+
1248
+ }
1249
+
1250
+ //Class Object
1251
+ global $wpsmush_dir;
1252
+ $wpsmush_dir = new WpSmushDir();
1253
+ }
1254
+
1255
+ /**
1256
+ * Filters the list of directories, Exclude the Media Subfolders
1257
+ *
1258
+ */
1259
+ if ( class_exists( 'RecursiveFilterIterator' ) && ! class_exists( 'WPSmushRecursiveFilterIterator' ) ) {
1260
+ class WPSmushRecursiveFilterIterator extends RecursiveFilterIterator {
1261
+
1262
+ public function accept() {
1263
+ global $wpsmush_dir;
1264
+ $path = $this->current()->getPathname();
1265
+ if ( $this->isDir() ) {
1266
+ if ( ! $wpsmush_dir->skip_dir( $path ) ) {
1267
+ return true;
1268
+ }
1269
+ } else {
1270
+ return true;
1271
+ }
1272
+
1273
+ return false;
1274
+ }
1275
+
1276
+ }
1277
+ }
lib/class-wp-smush-share.php CHANGED
@@ -14,17 +14,16 @@ if ( ! class_exists( 'WpSmushShare' ) ) {
14
  function __construct() {}
15
 
16
  function share_widget() {
17
- global $wpsmushit_admin, $wpsmush_stats;
18
- $savings = $wpsmushit_admin->global_stats_from_ids();
19
- $image_count = $wpsmush_stats->smushed_count();
20
 
21
  //If there is any saving, greater than 1Mb, show stats
22
  if ( empty( $savings ) || empty( $savings['bytes'] ) || $savings['bytes'] <= 1048576 || $image_count <= 1 || ! is_super_admin() ) {
23
  return false;
24
  }
25
  $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'] );
26
- $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/" ) );
27
- $url = urlencode( "http://wordpress.org/plugins/wp-smushit/" ); ?>
28
  <section class="dev-box" id="wp-smush-share-widget">
29
  <div class="box-content roboto-medium">
30
  <p class="wp-smush-share-message"><?php echo $message; ?></p>
14
  function __construct() {}
15
 
16
  function share_widget() {
17
+ global $wpsmushit_admin;
18
+ $savings = $wpsmushit_admin->stats;
19
+ $image_count = $wpsmushit_admin->smushed_count;
20
 
21
  //If there is any saving, greater than 1Mb, show stats
22
  if ( empty( $savings ) || empty( $savings['bytes'] ) || $savings['bytes'] <= 1048576 || $image_count <= 1 || ! is_super_admin() ) {
23
  return false;
24
  }
25
  $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'] );
26
+ $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/" ) ); ?>
 
27
  <section class="dev-box" id="wp-smush-share-widget">
28
  <div class="box-content roboto-medium">
29
  <p class="wp-smush-share-message"><?php echo $message; ?></p>
lib/class-wp-smush-ui.php CHANGED
@@ -107,11 +107,14 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
107
  }
108
 
109
  /**
110
- * Outputs the Smush stats for the site
111
- */
 
 
112
  function smush_stats_container() {
113
- global $WpSmush, $wpsmushit_admin, $wpsmush_stats, $wpsmush_settings;
114
 
 
115
  //If we have resmush list, smushed_count = totalcount - resmush count, else smushed_count
116
  $smushed_count = ( $resmush_count = count( $wpsmushit_admin->resmush_ids ) ) > 0 ? $wpsmushit_admin->total_count - ( $resmush_count + $wpsmushit_admin->remaining_count ) : $wpsmushit_admin->smushed_count;
117
  $smushed_count = $smushed_count > 0 ? $smushed_count : 0;
@@ -164,7 +167,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
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>
@@ -192,7 +195,8 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
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">
@@ -200,6 +204,10 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
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;
@@ -244,9 +252,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
244
  * Allows you to output any content within the stats box at the end
245
  */
246
  do_action( 'wp_smush_after_stats' );
247
- ?>
248
- </div><?php
249
- echo "</section>";
250
  }
251
 
252
  /**
@@ -261,6 +267,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
261
  //For Basic User, Show advanced settings in a separate box
262
  if ( ! $WpSmush->validate_install() ) {
263
  echo $div_end;
 
264
  //Network settings wrapper
265
  if( is_multisite() && is_network_admin() ) {
266
  $class = get_site_option( WP_SMUSH_PREFIX . 'networkwide', 1 ) ? '' : ' hidden'; ?>
@@ -497,7 +504,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
497
  */
498
  function ui() {
499
 
500
- global $WpSmush, $wpsmushit_admin, $wpsmush_settings;
501
 
502
  if( !$WpSmush->validate_install() ) {
503
  //Reset Transient
@@ -552,6 +559,8 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
552
  $this->settings_ui();
553
  }
554
 
 
 
555
  //Validate Membership
556
  if( !$wpsmushit_admin->validate_install() ) {?>
557
  <div class="wp-smush-pro-for-free wp-smushit-container-left col-half float-l"><?php
@@ -583,8 +592,8 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
583
  <div class="box-content">
584
  <p class="wp-smush-promo-content roboto-medium">You can now get Smush Pro... for FREE!</p>
585
  <p class="wp-smush-promo-content wp-smush-promo-content-2 roboto-medium">No obligation, no contracts, no
586
- catches. You'll get Smush Pro plus 100+ WPMU DEV plugins, Defender, Hummingbird & 24/7 WP support
587
- for absolutely nothing for 14 days.</p>
588
  <span class="wp-smush-pro-cta tc">
589
  <a href="<?php echo esc_url( $upgrade_url ); ?>"
590
  class="button button-cta button-green" target="_blank">FIND OUT MORE</a>
@@ -668,7 +677,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
668
  <span class="wp-smush-notice-text"><?php
669
  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>' );
670
  if( !$WpSmush->validate_install() ) {
671
- 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>' );
672
  esc_html_e("Free users can smush 50 images with each click.", "wp-smushit");
673
  }?>
674
  </span>
@@ -835,8 +844,6 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
835
  */
836
  function installation_notice() {
837
  global $wpsmushit_admin;
838
- $css_url = WP_SMUSH_URL . 'assets/css/notice.css?1';
839
- $js_url = WP_SMUSH_URL . 'assets/js/notice.js';
840
 
841
  //Whether New/Existing Installation
842
  $install_type = get_site_option('wp-smush-install-type', false );
@@ -863,7 +870,6 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
863
  ),
864
  $wpsmushit_admin->upgrade_url
865
  );?>
866
- <link rel="stylesheet" type="text/css" href="<?php echo esc_url( $css_url ); ?>" />
867
  <div class="notice smush-notice" style="display: none;">
868
  <div class="smush-notice-logo"><span></span></div>
869
  <div
@@ -877,8 +883,11 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
877
  </a>
878
  <button class="smush-notice-dismiss smush-dismiss-welcome" data-msg="<?php esc_html_e( 'Saving', 'wp-smushit'); ?>"><?php esc_html_e( 'Dismiss', "wp-smushit" ); ?></button>
879
  </div>
880
- </div>
881
- <script src="<?php echo esc_url( $js_url ) . '?v=' . WP_SMUSH_VERSION; ?>"></script><?php
 
 
 
882
  }
883
 
884
  /**
107
  }
108
 
109
  /**
110
+ * Outputs the Smush stats for the site
111
+ * @todo: Divide the function into parts, way too big
112
+ *
113
+ */
114
  function smush_stats_container() {
115
+ global $WpSmush, $wpsmushit_admin, $wpsmush_db, $wpsmush_settings;
116
 
117
+ //@todo: Move this to Stats section, In order to have a proper count somewhere
118
  //If we have resmush list, smushed_count = totalcount - resmush count, else smushed_count
119
  $smushed_count = ( $resmush_count = count( $wpsmushit_admin->resmush_ids ) ) > 0 ? $wpsmushit_admin->total_count - ( $resmush_count + $wpsmushit_admin->remaining_count ) : $wpsmushit_admin->smushed_count;
120
  $smushed_count = $smushed_count > 0 ? $smushed_count : 0;
167
  * Allows to hide the Super Smush stats as it might be heavy for some users
168
  */
169
  if ( $WpSmush->validate_install() && apply_filters( 'wp_smush_show_lossy_stats', true ) ) {
170
+ $wpsmushit_admin->super_smushed = $wpsmush_db->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>
195
  }
196
  } ?>
197
  </span>
198
+ </div>
199
+ <?php
200
  if( $WpSmush->validate_install() && !empty( $wpsmushit_admin->stats['conversion_savings'] ) && $wpsmushit_admin->stats['conversion_savings'] > 0 ) { ?>
201
  <hr />
202
  <div class="row smush-conversion-savings">
204
  <span class="float-r wp-smush-stats"><?php echo $wpsmushit_admin->stats['conversion_savings'] > 0 ? $wpsmushit_admin->stats['conversion_savings'] : "0MB"; ?></span>
205
  </div><?php
206
  }
207
+ /**
208
+ * Allows to output Directory Smush stats
209
+ */
210
+ do_action('stats_ui_after_resize_savings');
211
  //Pro Savings Expected: For free Version
212
  if ( ! $WpSmush->validate_install() ) {
213
  $savings = $wpsmushit_admin->stats['percent'] > 0 ? number_format_i18n( $wpsmushit_admin->stats['percent'], 1, '.', '' ) : 0;
252
  * Allows you to output any content within the stats box at the end
253
  */
254
  do_action( 'wp_smush_after_stats' );
255
+ echo "</div></section>";
 
 
256
  }
257
 
258
  /**
267
  //For Basic User, Show advanced settings in a separate box
268
  if ( ! $WpSmush->validate_install() ) {
269
  echo $div_end;
270
+ do_action('wp_smush_before_advanced_settings');
271
  //Network settings wrapper
272
  if( is_multisite() && is_network_admin() ) {
273
  $class = get_site_option( WP_SMUSH_PREFIX . 'networkwide', 1 ) ? '' : ' hidden'; ?>
504
  */
505
  function ui() {
506
 
507
+ global $WpSmush, $wpsmushit_admin;
508
 
509
  if( !$WpSmush->validate_install() ) {
510
  //Reset Transient
559
  $this->settings_ui();
560
  }
561
 
562
+ do_action('smush_settings_ui_bottom');
563
+
564
  //Validate Membership
565
  if( !$wpsmushit_admin->validate_install() ) {?>
566
  <div class="wp-smush-pro-for-free wp-smushit-container-left col-half float-l"><?php
592
  <div class="box-content">
593
  <p class="wp-smush-promo-content roboto-medium">You can now get Smush Pro... for FREE!</p>
594
  <p class="wp-smush-promo-content wp-smush-promo-content-2 roboto-medium">No obligation, no contracts, no
595
+ catches. You'll get Smush Pro plus 100+ WPMU DEV plugins, Defender, Hummingbird & 24/7 WP support.
596
+ Try it today absolutely free.</p>
597
  <span class="wp-smush-pro-cta tc">
598
  <a href="<?php echo esc_url( $upgrade_url ); ?>"
599
  class="button button-cta button-green" target="_blank">FIND OUT MORE</a>
677
  <span class="wp-smush-notice-text"><?php
678
  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>' );
679
  if( !$WpSmush->validate_install() ) {
680
+ printf( '<br />' . esc_html__("%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>' );
681
  esc_html_e("Free users can smush 50 images with each click.", "wp-smushit");
682
  }?>
683
  </span>
844
  */
845
  function installation_notice() {
846
  global $wpsmushit_admin;
 
 
847
 
848
  //Whether New/Existing Installation
849
  $install_type = get_site_option('wp-smush-install-type', false );
870
  ),
871
  $wpsmushit_admin->upgrade_url
872
  );?>
 
873
  <div class="notice smush-notice" style="display: none;">
874
  <div class="smush-notice-logo"><span></span></div>
875
  <div
883
  </a>
884
  <button class="smush-notice-dismiss smush-dismiss-welcome" data-msg="<?php esc_html_e( 'Saving', 'wp-smushit'); ?>"><?php esc_html_e( 'Dismiss', "wp-smushit" ); ?></button>
885
  </div>
886
+ </div><?php
887
+ //Notice CSS
888
+ wp_enqueue_style('wp-smushit-notice-css');
889
+ //Notice JS
890
+ wp_enqueue_script('wp-smushit-notice-js', '', array(), '', true );
891
  }
892
 
893
  /**
lib/class-wp-smush.php CHANGED
@@ -6,7 +6,7 @@ require_once WP_SMUSH_DIR . "lib/class-wp-smush-settings.php";
6
  require_once WP_SMUSH_DIR . "lib/class-wp-smush-migrate.php";
7
 
8
  //Stats
9
- require_once WP_SMUSH_DIR . "lib/class-wp-smush-stats.php";
10
 
11
  //Include Resize class
12
  require_once WP_SMUSH_DIR . 'lib/class-wp-smush-resize.php';
@@ -158,6 +158,8 @@ if ( ! class_exists( 'WpSmush' ) ) {
158
 
159
  function admin_init() {
160
 
 
 
161
  //Handle Notice dismiss
162
  $this->dismiss_smush_upgrade();
163
 
@@ -166,6 +168,12 @@ if ( ! class_exists( 'WpSmush' ) ) {
166
 
167
  //Initialize variables
168
  $this->initialise();
 
 
 
 
 
 
169
  }
170
 
171
  /**
@@ -643,8 +651,8 @@ if ( ! class_exists( 'WpSmush' ) ) {
643
 
644
  $data = false;
645
 
646
- $file = @fopen( $file_path, 'r' );
647
- $file_data = fread( $file, $file_size );
648
  $headers = array(
649
  'accept' => 'application/json', // The API returns JSON
650
  'content-type' => 'application/binary', // Set content type to binary
@@ -675,8 +683,6 @@ if ( ! class_exists( 'WpSmush' ) ) {
675
  @ini_set('memory_limit','256M');
676
  $result = wp_remote_post( $api_url, $args );
677
 
678
- //Close file connection
679
- fclose( $file );
680
  unset( $file_data );//free memory
681
  if ( is_wp_error( $result ) ) {
682
 
@@ -1683,13 +1689,13 @@ if ( ! class_exists( 'WpSmush' ) ) {
1683
  * @param $image_id
1684
  */
1685
  function delete_images( $image_id ) {
1686
- global $wpsmush_stats;
1687
 
1688
  //Update the savings cache
1689
- $wpsmush_stats->resize_savings( true );
1690
 
1691
  //Update the savings cache
1692
- $wpsmush_stats->conversion_savings( true );
1693
 
1694
  //If no image id provided
1695
  if ( empty( $image_id ) ) {
@@ -1871,7 +1877,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
1871
  */
1872
  function wp_smush_redirect( $plugin ) {
1873
 
1874
- global $wpsmushit_admin, $wpsmush_stats;
1875
 
1876
  //Run for only our plugin
1877
  if ( $plugin != WP_SMUSH_BASENAME ) {
@@ -1888,7 +1894,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
1888
  }
1889
 
1890
  //If images are already smushed
1891
- if ( $wpsmush_stats->smushed_count( false ) > 0 ) {
1892
  return false;
1893
  }
1894
 
@@ -1961,9 +1967,10 @@ if ( ! class_exists( 'WpSmush' ) ) {
1961
  *
1962
  * @param $stats
1963
  *
 
1964
  */
1965
  function total_compression( $stats ) {
1966
- $stats['stats']['size_before'] = $stats['stats']['size_after'] = $stats['stats']['time'] = '';
1967
  foreach ( $stats['sizes'] as $size_stats ) {
1968
  $stats['stats']['size_before'] += ! empty( $size_stats->size_before ) ? $size_stats->size_before : 0;
1969
  $stats['stats']['size_after'] += ! empty( $size_stats->size_after ) ? $size_stats->size_after : 0;
@@ -2035,6 +2042,8 @@ if ( ! class_exists( 'WpSmush' ) ) {
2035
  *
2036
  * @param string $original_file
2037
  *
 
 
2038
  */
2039
  function original_file( $original_file = '' ) {
2040
  $uploads = wp_get_upload_dir();
@@ -2213,5 +2222,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
2213
  }
2214
 
2215
  //Include Admin classes
2216
- require_once( WP_SMUSH_DIR . 'lib/class-wp-smush-bulk.php' );
2217
- require_once( WP_SMUSH_DIR . 'lib/class-wp-smush-admin.php' );
 
 
6
  require_once WP_SMUSH_DIR . "lib/class-wp-smush-migrate.php";
7
 
8
  //Stats
9
+ require_once WP_SMUSH_DIR . "lib/class-wp-smush-db.php";
10
 
11
  //Include Resize class
12
  require_once WP_SMUSH_DIR . 'lib/class-wp-smush-resize.php';
158
 
159
  function admin_init() {
160
 
161
+ global $wpsmush_dir;
162
+
163
  //Handle Notice dismiss
164
  $this->dismiss_smush_upgrade();
165
 
168
 
169
  //Initialize variables
170
  $this->initialise();
171
+
172
+ //Create a clas object, if doesn't exists
173
+ if ( empty( $wpsmush_dir ) && class_exists( 'WpSmushDir' ) ) {
174
+ $wpsmush_dir = new WpSmushDir();
175
+ }
176
+ $wpsmush_dir->create_table();
177
  }
178
 
179
  /**
651
 
652
  $data = false;
653
 
654
+ $file_data = file_get_contents( $file_path );
655
+
656
  $headers = array(
657
  'accept' => 'application/json', // The API returns JSON
658
  'content-type' => 'application/binary', // Set content type to binary
683
  @ini_set('memory_limit','256M');
684
  $result = wp_remote_post( $api_url, $args );
685
 
 
 
686
  unset( $file_data );//free memory
687
  if ( is_wp_error( $result ) ) {
688
 
1689
  * @param $image_id
1690
  */
1691
  function delete_images( $image_id ) {
1692
+ global $wpsmush_db;
1693
 
1694
  //Update the savings cache
1695
+ $wpsmush_db->resize_savings( true );
1696
 
1697
  //Update the savings cache
1698
+ $wpsmush_db->conversion_savings( true );
1699
 
1700
  //If no image id provided
1701
  if ( empty( $image_id ) ) {
1877
  */
1878
  function wp_smush_redirect( $plugin ) {
1879
 
1880
+ global $wpsmush_db;
1881
 
1882
  //Run for only our plugin
1883
  if ( $plugin != WP_SMUSH_BASENAME ) {
1894
  }
1895
 
1896
  //If images are already smushed
1897
+ if ( $wpsmush_db->smushed_count( false ) > 0 ) {
1898
  return false;
1899
  }
1900
 
1967
  *
1968
  * @param $stats
1969
  *
1970
+ * @return mixed
1971
  */
1972
  function total_compression( $stats ) {
1973
+ $stats['stats']['size_before'] = $stats['stats']['size_after'] = $stats['stats']['time'] = 0;
1974
  foreach ( $stats['sizes'] as $size_stats ) {
1975
  $stats['stats']['size_before'] += ! empty( $size_stats->size_before ) ? $size_stats->size_before : 0;
1976
  $stats['stats']['size_after'] += ! empty( $size_stats->size_after ) ? $size_stats->size_after : 0;
2042
  *
2043
  * @param string $original_file
2044
  *
2045
+ * @return string File Path
2046
+ *
2047
  */
2048
  function original_file( $original_file = '' ) {
2049
  $uploads = wp_get_upload_dir();
2222
  }
2223
 
2224
  //Include Admin classes
2225
+ require_once( WP_SMUSH_DIR . 'lib/class-wp-smush-admin.php' );
2226
+
2227
+ //Include Directory Smush
2228
+ require_once WP_SMUSH_DIR . 'lib/class-wp-smush-dir.php';
lib/nextgen-integration/class-wp-smush-nextgen-admin.php CHANGED
@@ -491,7 +491,7 @@ if ( ! class_exists( 'WpSmushNextGenAdmin' ) ) {
491
  * Outputs the Smush stats for the site
492
  */
493
  function smush_stats_container() {
494
- global $WpSmush, $wpsmushnextgenstats, $wpsmushit_admin, $wpsmush_stats;
495
 
496
  //If we have resmush list, smushed_count = totalcount - resmush count, else smushed_count
497
  $smushed_count = ( $resmush_count = count( $this->resmush_ids ) ) > 0 ? ( $this->total_count - ( $resmush_count + $this->remaining_count ) ) : $this->smushed_count;
@@ -555,7 +555,7 @@ if ( ! class_exists( 'WpSmushNextGenAdmin' ) ) {
555
  <span class="float-r wp-smush-stats">
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>' );
491
  * Outputs the Smush stats for the site
492
  */
493
  function smush_stats_container() {
494
+ global $WpSmush, $wpsmushnextgenstats, $wpsmushit_admin, $wpsmush_db;
495
 
496
  //If we have resmush list, smushed_count = totalcount - resmush count, else smushed_count
497
  $smushed_count = ( $resmush_count = count( $this->resmush_ids ) ) > 0 ? ( $this->total_count - ( $resmush_count + $this->remaining_count ) ) : $this->smushed_count;
555
  <span class="float-r wp-smush-stats">
556
  <?php
557
  if ( $WpSmush->lossy_enabled ) {
558
+ $count = $wpsmush_db->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>' );
lib/nextgen-integration/class-wp-smush-nextgen-bulk.php CHANGED
@@ -8,7 +8,7 @@ if ( ! class_exists( 'WPSmushNextGenBulk' ) ) {
8
 
9
  function smush_bulk() {
10
 
11
- global $wpsmushnextgenstats, $wpsmush_stats, $wpsmushit_admin, $wpsmushnextgenadmin, $WpSmush;
12
 
13
  $stats = array();
14
 
@@ -43,7 +43,7 @@ if ( ! class_exists( 'WPSmushNextGenBulk' ) ) {
43
  if ( $WpSmush->lossy_enabled ) {
44
  //Most of the time the stats would be update and the function won't need to go thorugh all the
45
  //images to get the count, but in case it has to, we provide the SMushed attachment list
46
- $stats['super_smushed'] = $wpsmush_stats->super_smushed_count('nextgen', $wpsmushnextgenstats->get_ngg_images('smushed' ) );
47
  }
48
  if( empty( $wpsmushnextgenadmin->resmush_ids ) ) {
49
  $wpsmushnextgenadmin->resmush_ids = get_option( 'wp-smush-nextgen-resmush-list' );
8
 
9
  function smush_bulk() {
10
 
11
+ global $wpsmushnextgenstats, $wpsmush_db, $wpsmushit_admin, $wpsmushnextgenadmin, $WpSmush;
12
 
13
  $stats = array();
14
 
43
  if ( $WpSmush->lossy_enabled ) {
44
  //Most of the time the stats would be update and the function won't need to go thorugh all the
45
  //images to get the count, but in case it has to, we provide the SMushed attachment list
46
+ $stats['super_smushed'] = $wpsmush_db->super_smushed_count('nextgen', $wpsmushnextgenstats->get_ngg_images('smushed' ) );
47
  }
48
  if( empty( $wpsmushnextgenadmin->resmush_ids ) ) {
49
  $wpsmushnextgenadmin->resmush_ids = get_option( 'wp-smush-nextgen-resmush-list' );
lib/wp-async-task-smush.php ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WP Asynchronous Tasks
4
+ * Version: 1.0
5
+ * Description: Creates an abstract class to execute asynchronous tasks
6
+ * Author: 10up, Eric Mann, Luke Gedeon, John P. Bloch
7
+ * License: MIT
8
+ * Note: Modified to return metadata at the end of the launch function
9
+ */
10
+
11
+ if ( ! class_exists( 'WP_Async_Task_Smush' ) ) {
12
+ abstract class WP_Async_Task_Smush {
13
+
14
+ /**
15
+ * Constant identifier for a task that should be available to logged-in users
16
+ *
17
+ * See constructor documentation for more details.
18
+ */
19
+ const LOGGED_IN = 1;
20
+
21
+ /**
22
+ * Constant identifier for a task that should be available to logged-out users
23
+ *
24
+ * See constructor documentation for more details.
25
+ */
26
+ const LOGGED_OUT = 2;
27
+
28
+ /**
29
+ * Constant identifier for a task that should be available to all users regardless of auth status
30
+ *
31
+ * See constructor documentation for more details.
32
+ */
33
+ const BOTH = 3;
34
+
35
+ /**
36
+ * This is the argument count for the main action set in the constructor. It
37
+ * is set to an arbitrarily high value of twenty, but can be overridden if
38
+ * necessary
39
+ *
40
+ * @var int
41
+ */
42
+ protected $argument_count = 20;
43
+
44
+ /**
45
+ * Priority to fire intermediate action.
46
+ *
47
+ * @var int
48
+ */
49
+ protected $priority = 10;
50
+
51
+ /**
52
+ * @var string
53
+ */
54
+ protected $action;
55
+
56
+ /**
57
+ * @var array
58
+ */
59
+ protected $_body_data;
60
+
61
+ /**
62
+ * Constructor to wire up the necessary actions
63
+ *
64
+ * Which hooks the asynchronous postback happens on can be set by the
65
+ * $auth_level parameter. There are essentially three options: logged in users
66
+ * only, logged out users only, or both. Set this when you instantiate an
67
+ * object by using one of the three class constants to do so:
68
+ * - LOGGED_IN
69
+ * - LOGGED_OUT
70
+ * - BOTH
71
+ * $auth_level defaults to BOTH
72
+ *
73
+ * @throws Exception If the class' $action value hasn't been set
74
+ *
75
+ * @param int $auth_level The authentication level to use (see above)
76
+ */
77
+ public function __construct( $auth_level = self::BOTH ) {
78
+ if ( empty( $this->action ) ) {
79
+ throw new Exception( 'Action not defined for class ' . __CLASS__ );
80
+ }
81
+ //Handle the actual action
82
+ add_action( $this->action, array( $this, 'launch' ), (int) $this->priority, (int) $this->argument_count );
83
+
84
+ add_action( "admin_post_wp_async_$this->action", array( $this, 'handle_postback' ) );
85
+ }
86
+
87
+ /**
88
+ * Add the shutdown action for launching the real postback if we don't
89
+ * get an exception thrown by prepare_data().
90
+ *
91
+ * @uses func_get_args() To grab any arguments passed by the action
92
+ */
93
+ public function launch() {
94
+ $data = func_get_args();
95
+ try {
96
+ $data = $this->prepare_data( $data );
97
+ } catch ( Exception $e ) {
98
+ return;
99
+ }
100
+
101
+ $data['action'] = "wp_async_$this->action";
102
+ $data['_nonce'] = $this->create_async_nonce();
103
+
104
+ $this->_body_data = $data;
105
+
106
+ if ( ! has_action( 'shutdown', array( $this, 'launch_on_shutdown' ) ) ) {
107
+ add_action( 'shutdown', array( $this, 'launch_on_shutdown' ) );
108
+ }
109
+
110
+ //If we have image metadata return it
111
+ if ( ! empty( $data['metadata'] ) ) {
112
+ return $data['metadata'];
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Launch the request on the WordPress shutdown hook
118
+ *
119
+ * On VIP we got into data races due to the postback sometimes completing
120
+ * faster than the data could propogate to the database server cluster.
121
+ * This made WordPress get empty data sets from the database without
122
+ * failing. On their advice, we're moving the actual firing of the async
123
+ * postback to the shutdown hook. Supposedly that will ensure that the
124
+ * data at least has time to get into the object cache.
125
+ *
126
+ * @uses $_COOKIE To send a cookie header for async postback
127
+ * @uses apply_filters()
128
+ * @uses admin_url()
129
+ * @uses wp_remote_post()
130
+ */
131
+ public function launch_on_shutdown() {
132
+ if ( ! empty( $this->_body_data ) ) {
133
+ $cookies = array();
134
+ foreach ( $_COOKIE as $name => $value ) {
135
+ $cookies[] = "$name=" . urlencode( is_array( $value ) ? serialize( $value ) : $value );
136
+ }
137
+
138
+ //@todo: We've set sslverify to false
139
+ $request_args = array(
140
+ 'timeout' => 10,
141
+ 'blocking' => false,
142
+ 'sslverify' => false,
143
+ 'body' => $this->_body_data,
144
+ 'headers' => array(
145
+ 'cookie' => implode( '; ', $cookies ),
146
+ ),
147
+ );
148
+
149
+ $url = admin_url( 'admin-post.php' );
150
+
151
+ wp_remote_post( $url, $request_args );
152
+ }
153
+ }
154
+
155
+ /**
156
+ * Verify the postback is valid, then fire any scheduled events.
157
+ *
158
+ * @uses $_POST['_nonce']
159
+ * @uses is_user_logged_in()
160
+ * @uses add_filter()
161
+ * @uses wp_die()
162
+ */
163
+ public function handle_postback() {
164
+ if ( isset( $_POST['_nonce'] ) && $this->verify_async_nonce( $_POST['_nonce'] ) ) {
165
+ $this->run_action();
166
+ }
167
+
168
+ add_filter( 'wp_die_handler', array( $this, 'handle_die' ) );
169
+ wp_die();
170
+ }
171
+
172
+ /**
173
+ * Handle Die
174
+ */
175
+ function handle_die() {
176
+ die();
177
+ }
178
+
179
+ /**
180
+ * Create a random, one time use token.
181
+ *
182
+ * Based entirely on wp_create_nonce() but does not tie the nonce to the
183
+ * current logged-in user.
184
+ *
185
+ * @uses wp_nonce_tick()
186
+ * @uses wp_hash()
187
+ *
188
+ * @return string The one-time use token
189
+ */
190
+ protected function create_async_nonce() {
191
+ $action = $this->get_nonce_action();
192
+ $i = wp_nonce_tick();
193
+
194
+ return substr( wp_hash( $i . $action . get_class( $this ), 'nonce' ), - 12, 10 );
195
+ }
196
+
197
+ /**
198
+ * Verify that the correct nonce was used within the time limit.
199
+ *
200
+ * @uses wp_nonce_tick()
201
+ * @uses wp_hash()
202
+ *
203
+ * @param string $nonce Nonce to be verified
204
+ *
205
+ * @return bool Whether the nonce check passed or failed
206
+ */
207
+ protected function verify_async_nonce( $nonce ) {
208
+ $action = $this->get_nonce_action();
209
+ $i = wp_nonce_tick();
210
+
211
+ // Nonce generated 0-12 hours ago
212
+ if ( substr( wp_hash( $i . $action . get_class( $this ), 'nonce' ), - 12, 10 ) == $nonce ) {
213
+ return 1;
214
+ }
215
+
216
+ // Nonce generated 12-24 hours ago
217
+ if ( substr( wp_hash( ( $i - 1 ) . $action . get_class( $this ), 'nonce' ), - 12, 10 ) == $nonce ) {
218
+ return 2;
219
+ }
220
+
221
+ // Invalid nonce
222
+ return false;
223
+ }
224
+
225
+ /**
226
+ * Get a nonce action based on the $action property of the class
227
+ *
228
+ * @return string The nonce action for the current instance
229
+ */
230
+ protected function get_nonce_action() {
231
+ $action = $this->action;
232
+ if ( substr( $action, 0, 7 ) === 'nopriv_' ) {
233
+ $action = substr( $action, 7 );
234
+ }
235
+ $action = "wp_async_$action";
236
+
237
+ return $action;
238
+ }
239
+
240
+ /**
241
+ * Prepare any data to be passed to the asynchronous postback
242
+ *
243
+ * The array this function receives will be a numerically keyed array from
244
+ * func_get_args(). It is expected that you will return an associative array
245
+ * so that the $_POST values used in the asynchronous call will make sense.
246
+ *
247
+ * The array you send back may or may not have anything to do with the data
248
+ * passed into this method. It all depends on the implementation details and
249
+ * what data is needed in the asynchronous postback.
250
+ *
251
+ * Do not set values for 'action' or '_nonce', as those will get overwritten
252
+ * later in launch().
253
+ *
254
+ * @throws Exception If the postback should not occur for any reason
255
+ *
256
+ * @param array $data The raw data received by the launch method
257
+ *
258
+ * @return array The prepared data
259
+ */
260
+ abstract protected function prepare_data( $data );
261
+
262
+ /**
263
+ * Run the do_action function for the asynchronous postback.
264
+ *
265
+ * This method needs to fetch and sanitize any and all data from the $_POST
266
+ * superglobal and provide them to the do_action call.
267
+ *
268
+ * The action should be constructed as "wp_async_task_$this->action"
269
+ */
270
+ abstract protected function run_action();
271
+
272
+ }
273
+
274
+ }
275
+
readme.txt CHANGED
@@ -1,13 +1,13 @@
1
  === Smush Image Compression and Optimization ===
2
  Plugin Name: Smush Image Compression and Optimization
3
- Version: 2.5.3
4
  Author: WPMU DEV
5
  Author URI: http://premium.wpmudev.org/
6
  Contributors: WPMUDEV, alexdunae
7
- Tags: image, optimize, compress, performance, lossless, lossy, photo, pictures, optimize JPG, compress PNG, Smush WordPress Compression, Smush.it
8
  Requires at least: 3.5
9
- Tested up to: 4.7.1
10
- Stable tag: 2.5.3
11
  License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12
 
13
  Compress and optimize image files, improve performance and boost your SEO rank using Smush WordPress image compression and optimization.
@@ -28,6 +28,10 @@ WP Smush meticulously scans every image you upload – or have already added to
28
 
29
  <a href="https://garage.godaddy.com/wordpress-plugin-partner-program/directory/?cvosrc=advocacy.evangelism.WP3" rel="nofollow"><img src="https://garage.godaddy.com/wp-content/uploads/badges/godaddy-plugin-partner-program-badge.svg" title="GoDaddy Plugin Program Partner" alt="GoDaddy Plugin Program Partner"/></a>
30
 
 
 
 
 
31
  ★★★★★ <br>
32
  “I had no idea that my page load time was being dragged down by the images. The plugin nearly halved the time it took.” - <a href="http://profiles.wordpress.org/karlcw">karlcw</a>
33
 
@@ -47,6 +51,7 @@ The faster your site loads, the more Google, Bing, Yahoo and other search engine
47
  <li>Optimize your images using advanced lossless compression techniques.</li>
48
  <li>Set maximum width and height and large images will automatically scale before being added to your media library</li>
49
  <li>Process JPEG, GIF and PNG image files.</li>
 
50
  <li>Asynchronously auto-smush your attachments for super fast compression on upload.</li>
51
  <li>Manually smush your attachments individually in the media library, or in bulk 50 attachments at a time.</li>
52
  <li>Smush all standard web-sized images 1MB or smaller. </li>
@@ -58,7 +63,7 @@ The faster your site loads, the more Google, Bing, Yahoo and other search engine
58
  Install WP Smush now and find out why it's the most popular image optimization plugin for WordPress available today with over 2.7 million downloads.
59
  </blockquote>
60
 
61
- <h4>If you like WP Smush, you'll love <a href="https://premium.wpmudev.org/project/wp-smush-pro/?utm_source=wordpress.org&utm_medium=readme">WP Smush Pro</a></h4>
62
 
63
  WP Smush Pro gives you everything you'll find in WP Smush and more:
64
  <ul>
@@ -127,6 +132,31 @@ Yahoo's Smush.it API is gone forever. So WPMU DEV built our own free API that is
127
 
128
  == Changelog ==
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  = 2.5.3 =
131
 
132
  * Fixed:
1
  === Smush Image Compression and Optimization ===
2
  Plugin Name: Smush Image Compression and Optimization
3
+ Version: 2.6.1
4
  Author: WPMU DEV
5
  Author URI: http://premium.wpmudev.org/
6
  Contributors: WPMUDEV, alexdunae
7
+ Tags: image, resize, optimize, compress, performance, lossless, lossy, photo, pictures, optimize JPG, compress PNG, Smush WordPress Compression, Smush.it
8
  Requires at least: 3.5
9
+ Tested up to: 4.7.2
10
+ Stable tag: 2.6.1
11
  License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12
 
13
  Compress and optimize image files, improve performance and boost your SEO rank using Smush WordPress image compression and optimization.
28
 
29
  <a href="https://garage.godaddy.com/wordpress-plugin-partner-program/directory/?cvosrc=advocacy.evangelism.WP3" rel="nofollow"><img src="https://garage.godaddy.com/wp-content/uploads/badges/godaddy-plugin-partner-program-badge.svg" title="GoDaddy Plugin Program Partner" alt="GoDaddy Plugin Program Partner"/></a>
30
 
31
+ = Compress any Image in any Directory =
32
+
33
+ In addition to smushing your media uploads, you may want to compress the images stored in other folders. Smush now lets you compress any image in any directory so that you can optimize all the images on your site – including NextGEN images and the images in EVERY WordPress plugin and theme package!
34
+
35
  ★★★★★ <br>
36
  “I had no idea that my page load time was being dragged down by the images. The plugin nearly halved the time it took.” - <a href="http://profiles.wordpress.org/karlcw">karlcw</a>
37
 
51
  <li>Optimize your images using advanced lossless compression techniques.</li>
52
  <li>Set maximum width and height and large images will automatically scale before being added to your media library</li>
53
  <li>Process JPEG, GIF and PNG image files.</li>
54
+ <li>Optimize any image in any directory.</li>
55
  <li>Asynchronously auto-smush your attachments for super fast compression on upload.</li>
56
  <li>Manually smush your attachments individually in the media library, or in bulk 50 attachments at a time.</li>
57
  <li>Smush all standard web-sized images 1MB or smaller. </li>
63
  Install WP Smush now and find out why it's the most popular image optimization plugin for WordPress available today with over 2.7 million downloads.
64
  </blockquote>
65
 
66
+ = If you like WP Smush, you'll love <a href="https://premium.wpmudev.org/project/wp-smush-pro/?utm_source=wordpress.org&utm_medium=readme">WP Smush Pro</a> =
67
 
68
  WP Smush Pro gives you everything you'll find in WP Smush and more:
69
  <ul>
132
 
133
  == Changelog ==
134
 
135
+ = 2.6.1 =
136
+
137
+ * Fixed:
138
+ * PHP 5.2 compatibility
139
+ * DB error: Use a smaller value for Path Index size ( Prefix Indexes )
140
+ * Updated translation function name
141
+ * UI/UX fixes for directory smush
142
+ * Improved optimisation process for directory smush
143
+ * Updated uninstall.php
144
+ * Skip sites directory from Directory Smush in a Multisite
145
+
146
+ = 2.6 =
147
+
148
+ * Fixed:
149
+ * PHP 7 warning ( https://goo.gl/GKEMim ), @props: @alexis-mag
150
+ * Async Smush conflict with other plugins
151
+
152
+ * Changes:
153
+ * Moved notice JS/CSS in footer
154
+ * Bulk Smush page optimisation
155
+ * Increased timeout for Async request - Fixes Async smush not working for some hosting services
156
+
157
+ * Added:
158
+ * Directory Smush
159
+
160
  = 2.5.3 =
161
 
162
  * Fixed:
uninstall.php CHANGED
@@ -37,7 +37,9 @@ $smushit_keys = array(
37
  'hide_update_info',
38
  'install-type',
39
  'lossy-updated',
40
- 'version'
 
 
41
  );
42
 
43
  //Cache Keys
@@ -80,6 +82,9 @@ if ( ! is_multisite() ) {
80
 
81
  }
82
 
 
 
 
83
  //Delete Post meta
84
  $meta_type = 'post';
85
  $meta_key = 'wp-smpro-smush-data';
@@ -127,6 +132,9 @@ if ( is_multisite() ) {
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
- ?>
37
  'hide_update_info',
38
  'install-type',
39
  'lossy-updated',
40
+ 'version',
41
+ 'networkwide',
42
+ 'dir_path'
43
  );
44
 
45
  //Cache Keys
82
 
83
  }
84
 
85
+ //Delete Directory Smush stats
86
+ delete_option( 'dir_smush_stats' );
87
+
88
  //Delete Post meta
89
  $meta_type = 'post';
90
  $meta_key = 'wp-smpro-smush-data';
132
  delete_metadata( $meta_type, null, 'wp-smush-original_file', '', $delete_all );
133
  delete_metadata( $meta_type, null, 'wp-smush-pngjpg_savings', '', $delete_all );
134
  }
135
+ //Delete Directory smush table
136
+ global $wpdb;
137
+ $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}smush_dir_images" );
138
+
139
  //@todo: Add procedure to delete backup files
140
+ //@todo: Update NextGen Metadata to remove Smush stats on plugin deletion
 
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.5.3
8
  Author URI: http://premium.wpmudev.org/
9
  Text Domain: wp-smushit
10
  */
@@ -35,7 +35,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35
  * Constants
36
  */
37
  $prefix = 'WP_SMUSH_';
38
- $version = '2.5.3';
39
 
40
  //Deactivate the .org version, if pro version is active
41
  add_action( 'admin_init', 'deactivate_smush_org' );
@@ -88,9 +88,9 @@ require_once WP_SMUSH_DIR . 'lib/class-wp-smush.php';
88
  */
89
  if ( ! function_exists( 'wp_smush_rating_message' ) ) {
90
  function wp_smush_rating_message( $message ) {
91
- global $wpsmushit_admin, $wpsmush_stats;
92
  $savings = $wpsmushit_admin->global_stats_from_ids();
93
- $image_count = $wpsmush_stats->total_count();
94
  $show_stats = false;
95
 
96
  //If there is any saving, greater than 1Mb, show stats
@@ -124,7 +124,7 @@ if ( ! function_exists( 'wp_smush_email_message' ) ) {
124
  return $message;
125
  }
126
  }
127
- if( !function_exists('get_plugin_dir') ) {
128
  /**
129
  * Returns the dir path for the plugin
130
  *
@@ -273,10 +273,12 @@ if ( ! function_exists( 'smush_sanitize_hex_color_no_hash' ) ) {
273
  }
274
  }
275
  //Load Translation files
276
- add_action( 'plugins_loaded', 'i18n' );
277
- function i18n() {
278
- $path = path_join( dirname( plugin_basename( __FILE__ ) ), 'languages/' );
279
- load_plugin_textdomain( 'wp-smushit', false, $path );
 
 
280
  }
281
 
282
  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.6.1
8
  Author URI: http://premium.wpmudev.org/
9
  Text Domain: wp-smushit
10
  */
35
  * Constants
36
  */
37
  $prefix = 'WP_SMUSH_';
38
+ $version = '2.6.1';
39
 
40
  //Deactivate the .org version, if pro version is active
41
  add_action( 'admin_init', 'deactivate_smush_org' );
88
  */
89
  if ( ! function_exists( 'wp_smush_rating_message' ) ) {
90
  function wp_smush_rating_message( $message ) {
91
+ global $wpsmushit_admin, $wpsmush_db;
92
  $savings = $wpsmushit_admin->global_stats_from_ids();
93
+ $image_count = $wpsmush_db->total_count();
94
  $show_stats = false;
95
 
96
  //If there is any saving, greater than 1Mb, show stats
124
  return $message;
125
  }
126
  }
127
+ if ( ! function_exists( 'get_plugin_dir' ) ) {
128
  /**
129
  * Returns the dir path for the plugin
130
  *
273
  }
274
  }
275
  //Load Translation files
276
+ add_action( 'plugins_loaded', 'smush_i18n' );
277
+ if( !function_exists('smush_i18n')) {
278
+ function smush_i18n() {
279
+ $path = path_join( dirname( plugin_basename( __FILE__ ) ), 'languages/' );
280
+ load_plugin_textdomain( 'wp-smushit', false, $path );
281
+ }
282
  }
283
 
284
  register_activation_hook( __FILE__, 'smush_activated' );