Smush Image Compression and Optimization - Version 2.5.2

Version Description

  • Added:

    • Filter: wp_smush_image, Boolean, Whether to Smush image or not
    • Async Optimisation for Auto Smush on upload ( Set WP_SMUSH_ASYNC to false to turn off async optimisation )
    • Networkwide settings option in a Multisite
  • Fixed:

    • Double slash in file path causing 403 on some of the sites
    • Localisation error reported by @talgat ( Thank You :) )
Download this release

Release Info

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

Code changes from version 2.4.5 to 2.5.2

assets/css/wp-smushit-admin.css CHANGED
@@ -68,18 +68,6 @@ Smush button transformation
68
  margin-top: 18px;
69
  }
70
 
71
- .wpmud .dev-box.wp-smush-install-thanks-box {
72
- margin-bottom: 20px;
73
- padding-bottom: 0;
74
- }
75
-
76
- #wp-smush-install-thanks .row {
77
- background-image: url(../images/install-welcome.png);
78
- background-repeat: no-repeat;
79
- background-position: 30px bottom;
80
- min-height: 206px;
81
- }
82
-
83
  /** Settings Page **/
84
 
85
  .wp-smush-setting-row {
@@ -701,6 +689,7 @@ table.wp-smush-stats-holder tr td:first-child {
701
 
702
  .wpmud .wp-smush-welcome-content h4 {
703
  font-size: 30px;
 
704
  text-align: left;
705
  }
706
 
@@ -756,7 +745,9 @@ table.wp-smush-stats-holder tr td:first-child {
756
  padding: 20px 40px;
757
  }
758
 
759
- .wp-smush-resmush-message, .wp-smush-settings-updated {
 
 
760
  border: none;
761
  margin-bottom: 25px;
762
  padding: 18px 50px;
@@ -769,11 +760,15 @@ table.wp-smush-stats-holder tr td:first-child {
769
  text-decoration: underline;
770
  }
771
 
772
- .wp-smush-resmush-message .dev-icon, .wp-smush-settings-updated .dev-icon {
 
 
773
  font-size: 16px;
774
  }
775
 
776
- .wp-smush-resmush-message .dev-icon-cross, .wp-smush-settings-updated .dev-icon-cross {
 
 
777
  cursor: pointer;
778
  float: right;
779
  }
@@ -1124,127 +1119,6 @@ small.smush-setting-description {
1124
  font-weight: bold;
1125
  }
1126
 
1127
- @media screen and (max-width: 1024px) and ( min-width: 800px ) {
1128
- .wpmud .wrap .dev-box:not(.wp-smush-pro-adv) {
1129
- padding: 20px;
1130
- }
1131
-
1132
- .wpmud .dev-box.wp-smush-pro-adv .box-title, .wpmud .wp-smush-pro-adv .box-content {
1133
- padding: 0 20px;
1134
- }
1135
-
1136
- /** Stats Section **/
1137
- .wpmud .smush-stats-wrapper {
1138
- font-size: 12px;
1139
- }
1140
-
1141
- .smush-stats-wrapper h3 {
1142
- padding: 6px 0;
1143
- }
1144
-
1145
- .smush-stats-wrapper .smush-container-subheading {
1146
- margin-top: 20px;
1147
- }
1148
-
1149
- .wpmud .wp-smush-stats, .wp-smush-stats-wrap {
1150
- font-size: 20px;
1151
- }
1152
-
1153
- /** Sub Heading **/
1154
- .wpmud .smush-container-subheading {
1155
- font-size: 12px;
1156
- }
1157
- }
1158
-
1159
- /** Media Queries for resolution between 782px - 1024px **/
1160
- @media screen and (max-width: 1024px) {
1161
- /** Configure screen **/
1162
- .wpmud .row .wp-smush-lady.col-third {
1163
- display: none;
1164
- }
1165
-
1166
- /** Media Library Stats **/
1167
- .wp-list-table .smushit .wp-smush-stats-holder tr th {
1168
- display: inline-block;
1169
- width: 50%;
1170
- box-sizing: border-box;
1171
- }
1172
-
1173
- .wp-list-table .smushit .wp-smush-stats-holder tr td:first-child {
1174
- border-right: none;
1175
- box-sizing: border-box;
1176
- display: inline-block !important;
1177
- width: 50% !important;
1178
- }
1179
-
1180
- .wp-list-table .smushit .wp-smush-stats-holder tr td:last-child {
1181
- box-sizing: border-box;
1182
- display: inline-block !important;
1183
- float: none;
1184
- overflow: visible;
1185
- width: 50% !important;
1186
- }
1187
-
1188
- .wpmud .wp-smush-promo-content, .wpmud .wp-smush-promo-content-smaller {
1189
- max-width: none;
1190
- }
1191
- }
1192
-
1193
- /** Media Queries for resolution below 782px **/
1194
- @media only screen and (max-width: 800px) {
1195
- .wpmud .wp-smushit-container-wrap .col-half.wp-smushit-container-left, .wpmud .wp-smushit-container-wrap .col-half.wp-smushit-container-right {
1196
- padding: 0;
1197
- width: 100%;
1198
- }
1199
-
1200
- .wpmud .wp-smush-welcome-content {
1201
- margin: 0 30px 0px 160px;
1202
- }
1203
-
1204
- .dev-box.bulk-smush-wrapper.wp-smush-container {
1205
- padding: 20px 10px;
1206
- }
1207
-
1208
- .wpmud .wp-smush-super-smush-content {
1209
- font-size: 11px;
1210
- margin-left: 160px;
1211
- /*padding: 15px 20px;*/
1212
- }
1213
- }
1214
-
1215
- @media screen and (max-width: 750px) {
1216
- .wpmud .dev-box#wp-smush-share-widget {
1217
- background-position: 30px 45px;
1218
- }
1219
- }
1220
-
1221
- @media screen and (max-width: 650px) {
1222
- .wpmud .dev-box#wp-smush-share-widget {
1223
- background-image: none;
1224
- }
1225
-
1226
- .wpmud #wp-smush-share-widget .box-content {
1227
- margin-left: 0;
1228
- padding: 20px;
1229
- }
1230
-
1231
- .wpmud .button.wp-smush-share-button,
1232
- .wpmud a + .button.wp-smush-share-button {
1233
- margin-bottom: 10px;
1234
- margin-left: 0;
1235
- text-align: center;
1236
- width: 100%;
1237
- }
1238
-
1239
- .wpmud .button.wp-smush-share-button .dev-icon {
1240
- float: left;
1241
- }
1242
-
1243
- .wpmud #wp-smush-whatsapp-share {
1244
- display: inline-block;
1245
- }
1246
- }
1247
-
1248
  /** For Media Gallery and Other WordPress pages **/
1249
  /** No Caps for the tooltips **/
1250
  .wp-admin.wpmud [tooltip]:after {
@@ -1589,4 +1463,154 @@ small.smush-setting-description {
1589
 
1590
  .wpmud #wpfooter {
1591
  display: none;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1592
  }
68
  margin-top: 18px;
69
  }
70
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  /** Settings Page **/
72
 
73
  .wp-smush-setting-row {
689
 
690
  .wpmud .wp-smush-welcome-content h4 {
691
  font-size: 30px;
692
+ line-height: 1.4;
693
  text-align: left;
694
  }
695
 
745
  padding: 20px 40px;
746
  }
747
 
748
+ .wp-smush-resmush-message,
749
+ .wp-smush-settings-updated,
750
+ .wp-smush-re-check-message {
751
  border: none;
752
  margin-bottom: 25px;
753
  padding: 18px 50px;
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,
770
+ .wp-smush-settings-updated .dev-icon-cross,
771
+ .wp-smush-re-check-message .dev-icon-cross {
772
  cursor: pointer;
773
  float: right;
774
  }
1119
  font-weight: bold;
1120
  }
1121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1122
  /** For Media Gallery and Other WordPress pages **/
1123
  /** No Caps for the tooltips **/
1124
  .wp-admin.wpmud [tooltip]:after {
1463
 
1464
  .wpmud #wpfooter {
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;
1472
+ }
1473
+
1474
+ .wpmud .dev-box.wp-smush-pro-adv .box-title, .wpmud .wp-smush-pro-adv .box-content {
1475
+ padding: 0 20px;
1476
+ }
1477
+
1478
+ /** Stats Section **/
1479
+ .wpmud .smush-stats-wrapper {
1480
+ font-size: 12px;
1481
+ }
1482
+
1483
+ .smush-stats-wrapper h3 {
1484
+ padding: 6px 0;
1485
+ }
1486
+
1487
+ .smush-stats-wrapper .smush-container-subheading {
1488
+ margin-top: 20px;
1489
+ }
1490
+
1491
+ .wpmud .wp-smush-stats, .wp-smush-stats-wrap {
1492
+ font-size: 20px;
1493
+ }
1494
+
1495
+ /** Sub Heading **/
1496
+ .wpmud .smush-container-subheading {
1497
+ font-size: 12px;
1498
+ }
1499
+ }
1500
+
1501
+ /** Media Queries for resolution between 782px - 1024px **/
1502
+ @media screen and (max-width: 1024px) {
1503
+ /** Configure screen **/
1504
+ .wpmud .row .wp-smush-lady.col-third {
1505
+ display: none;
1506
+ }
1507
+
1508
+ /** Media Library Stats **/
1509
+ .wp-list-table .smushit .wp-smush-stats-holder tr th {
1510
+ display: inline-block;
1511
+ width: 50%;
1512
+ box-sizing: border-box;
1513
+ }
1514
+
1515
+ .wp-list-table .smushit .wp-smush-stats-holder tr td:first-child {
1516
+ border-right: none;
1517
+ box-sizing: border-box;
1518
+ display: inline-block !important;
1519
+ width: 50% !important;
1520
+ }
1521
+
1522
+ .wp-list-table .smushit .wp-smush-stats-holder tr td:last-child {
1523
+ box-sizing: border-box;
1524
+ display: inline-block !important;
1525
+ float: none;
1526
+ overflow: visible;
1527
+ width: 50% !important;
1528
+ }
1529
+
1530
+ .wpmud .wp-smush-promo-content, .wpmud .wp-smush-promo-content-smaller {
1531
+ max-width: none;
1532
+ }
1533
+ }
1534
+
1535
+ @media only screen and (min-width: 800px) and ( max-width: 1100px ) {
1536
+ .wp-smush-super-smush-promo {
1537
+ background-size: 120px;
1538
+ }
1539
+
1540
+ .wp-smush-super-smush-promo .wp-smush-super-smush-content {
1541
+ font-size: 10px;
1542
+ margin-left: 45%;
1543
+ padding: 10px 20px;
1544
+ width: 55%;
1545
+ }
1546
+ }
1547
+
1548
+ @media only screen and (min-width: 1100px) and ( max-width: 1200px ) {
1549
+ .wp-smush-super-smush-promo .wp-smush-super-smush-content {
1550
+ margin-left: 170px;
1551
+ padding: 10px 20px;
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 {
1558
+ padding: 0;
1559
+ width: 100%;
1560
+ }
1561
+
1562
+ .wpmud .wp-smush-welcome-content {
1563
+ margin: 0 30px 0px 160px;
1564
+ }
1565
+
1566
+ .dev-box.bulk-smush-wrapper.wp-smush-container {
1567
+ padding: 20px 10px;
1568
+ }
1569
+
1570
+ .wpmud .wp-smush-super-smush-content {
1571
+ margin-left: 160px;
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;
1584
+ }
1585
+
1586
+ .wpmud #wp-smush-share-widget .box-content {
1587
+ margin-left: 0;
1588
+ padding: 20px;
1589
+ }
1590
+
1591
+ .wpmud .button.wp-smush-share-button,
1592
+ .wpmud a + .button.wp-smush-share-button {
1593
+ margin-bottom: 10px;
1594
+ margin-left: 0;
1595
+ text-align: center;
1596
+ width: 100%;
1597
+ }
1598
+
1599
+ .wpmud .button.wp-smush-share-button .dev-icon {
1600
+ float: left;
1601
+ }
1602
+
1603
+ .wpmud #wp-smush-whatsapp-share {
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
  }
assets/images/dev-team.png CHANGED
Binary file
assets/images/share-bg-small.png CHANGED
Binary file
assets/images/smush-no-media.png CHANGED
Binary file
assets/images/welcome-notice.png CHANGED
Binary file
assets/js/wp-smushit-admin.js CHANGED
@@ -208,7 +208,7 @@ jQuery(function ($) {
208
  self.$status.html(response.data);
209
 
210
  //Check whether to show membership validity notice or not
211
- membership_validity( response.data );
212
 
213
  if (response.success && response.data !== "Not processed") {
214
  self.$status.removeClass('hidden');
@@ -455,7 +455,7 @@ jQuery(function ($) {
455
  }
456
 
457
  //Check whether to show the warning notice or not
458
- membership_validity( res.data );
459
 
460
  if (typeof res.data !== "undefined" && res.data.error == 'bulk_request_image_limit_exceeded' && !self.is_resolved()) {
461
  //Add a data attribute to the smush button, to stop sending ajax
@@ -774,97 +774,7 @@ jQuery(function ($) {
774
  $progress_bar.css('width', width + '%');
775
  };
776
 
777
- /**
778
- * Handle the Smush Stats link click
779
- */
780
- $('body').on('click', 'a.smush-stats-details', function (e) {
781
-
782
- //If disabled
783
- if ('disabled' == $(this).attr('disabled')) {
784
- return false;
785
- }
786
-
787
- // prevent the default action
788
- e.preventDefault();
789
- //Replace the `+` with a `-`
790
- var slide_symbol = $(this).find('.stats-toggle');
791
- $(this).parents().eq(1).find('.smush-stats-wrapper').slideToggle();
792
- slide_symbol.text(slide_symbol.text() == '+' ? '-' : '+');
793
-
794
-
795
- });
796
-
797
- /** Handle smush button click **/
798
- $('body').on('click', '.wp-smush-send:not(.wp-smush-resmush)', function (e) {
799
-
800
- // prevent the default action
801
- e.preventDefault();
802
- new WP_Smush.Smush($(this), false);
803
- });
804
-
805
- /** Handle NextGen Gallery smush button click **/
806
- $('body').on('click', '.wp-smush-nextgen-send', function (e) {
807
-
808
- // prevent the default action
809
- e.preventDefault();
810
- new WP_Smush.Smush($(this), false, 'nextgen');
811
- });
812
-
813
- /** Handle NextGen Gallery Bulk smush button click **/
814
- $('body').on('click', '.wp-smush-nextgen-bulk', function (e) {
815
-
816
- // prevent the default action
817
- e.preventDefault();
818
-
819
- //Check for ids, if there is none (Unsmushed or lossless), don't call smush function
820
- if (typeof wp_smushit_data == 'undefined' ||
821
- ( wp_smushit_data.unsmushed.length == 0 && wp_smushit_data.resmush.length == 0 )
822
- ) {
823
-
824
- return false;
825
-
826
- }
827
-
828
- jQuery('.wp-smush-button, .wp-smush-scan').attr('disabled', 'disabled');
829
- $(".wp-smush-notice.wp-smush-remaining").hide();
830
- new WP_Smush.Smush($(this), true, 'nextgen');
831
-
832
- });
833
-
834
- /** Restore: Media Library **/
835
- $('body').on('click', '.wp-smush-action.wp-smush-restore', function (e) {
836
- var current_button = $(this);
837
- var smush_action = 'smush_restore_image';
838
- process_smush_action(e, current_button, smush_action, 'restore');
839
- });
840
-
841
- /** Resmush: Media Library **/
842
- $('body').on('click', '.wp-smush-action.wp-smush-resmush', function (e) {
843
- var current_button = $(this);
844
- var smush_action = 'smush_resmush_image';
845
- process_smush_action(e, current_button, smush_action, 'smushing');
846
- });
847
-
848
- /** Restore: NextGen Gallery **/
849
- $('body').on('click', '.wp-smush-action.wp-smush-nextgen-restore', function (e) {
850
- var current_button = $(this);
851
- var smush_action = 'smush_restore_nextgen_image';
852
- process_smush_action(e, current_button, smush_action, 'restore');
853
- });
854
-
855
- /** Resmush: NextGen Gallery **/
856
- $('body').on('click', '.wp-smush-action.wp-smush-nextgen-resmush', function (e) {
857
- var current_button = $(this);
858
- var smush_action = 'smush_resmush_nextgen_image';
859
- process_smush_action(e, current_button, smush_action, 'smushing');
860
- });
861
-
862
- //Scan For resmushing images
863
- $('body').on('click', '.wp-smush-scan', function (e) {
864
-
865
- e.preventDefault();
866
-
867
- var button = jQuery(this);
868
  var spinner = button.parent().find('.spinner');
869
 
870
  //Check if type is set in data attributes
@@ -898,6 +808,7 @@ jQuery(function ($) {
898
  action: 'scan_for_resmush',
899
  type: scan_type,
900
  get_ui: true,
 
901
  wp_smush_options_nonce: jQuery('#wp_smush_options_nonce').val()
902
  };
903
 
@@ -965,7 +876,106 @@ jQuery(function ($) {
965
  //Hide Spinner
966
  spinner.removeClass('is-active');
967
  $('.wp-smush-button').removeAttr('disabled');
 
 
 
 
 
968
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
969
 
970
  });
971
 
@@ -973,7 +983,7 @@ jQuery(function ($) {
973
  $('#wp-smush-welcome-box .smush-dismiss-welcome').on('click', function (e) {
974
  e.preventDefault();
975
  var $el = $(this).parents().eq(1);
976
- remove_element( $el );
977
 
978
  //Send a ajax request to save the dismissed notice option
979
  var param = {
@@ -986,58 +996,85 @@ jQuery(function ($) {
986
  $('body').on('click', '.wp-smush-notice .dev-icon-cross', function (e) {
987
  e.preventDefault();
988
  var $el = $(this).parent();
989
- remove_element( $el );
990
  });
991
 
992
  //On Click Update Settings. Check for change in settings
993
  $('#wp-smush-save-settings').on('click', function (e) {
994
  e.preventDefault();
995
 
996
- var self = $(this);
997
- var wrapper_div = self.parents().eq(1);
 
 
 
 
998
 
999
- //Get all the main settings
1000
- var keep_exif = document.getElementById("wp-smush-keep_exif");
1001
- var super_smush = document.getElementById("wp-smush-lossy");
1002
- var smush_original = document.getElementById("wp-smush-original");
1003
- var resize_images = document.getElementById("wp-smush-resize");
1004
- var smush_pngjpg = document.getElementById("wp-smush-png_to_jpg");
 
1005
 
1006
- var update_button_txt = true;
1007
 
1008
- $('.wp-smush-hex-notice').hide();
 
 
 
 
 
1009
 
1010
- //If Preserve Exif is Checked, and all other settings are off, just save the settings
1011
- if (keep_exif.checked && !super_smush.checked && !smush_original.checked && !resize_images.checked && !smush_pngjpg.checked) {
1012
- update_button_txt = false;
1013
- }
1014
 
1015
- //Update text
1016
- self.attr('disabled', 'disabled').addClass('button-grey');
 
 
 
 
1017
 
1018
- if (update_button_txt) {
1019
- self.val(wp_smush_msgs.checking)
1020
- }
1021
 
1022
- self.parent().find('.spinner').addClass('is-active');
1023
 
1024
- //Check if type is set in data attributes
1025
- var scan_type = self.data('type');
1026
- scan_type = 'undefined' == typeof scan_type ? 'media' : scan_type;
 
1027
 
1028
- //Ajax param
1029
- var param = {
1030
- action: 'scan_for_resmush',
1031
- scan_type: scan_type
1032
- };
1033
 
1034
- param = jQuery.param(param) + '&' + jQuery('form#wp-smush-settings-form').serialize();
 
 
1035
 
1036
- //Send ajax, Update Settings, And Check For resmush
1037
- jQuery.post(ajaxurl, param).done(function () {
1038
- jQuery('form#wp-smush-settings-form').submit();
1039
- return true;
1040
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1041
  });
1042
 
1043
  //On Resmush click
@@ -1048,7 +1085,7 @@ jQuery(function ($) {
1048
 
1049
  //Remove Parent div
1050
  var $el = self.parent();
1051
- remove_element( $el );
1052
 
1053
  //Remove Settings Notice
1054
  $('.wp-smush-notice.wp-smush-settings-updated').remove();
@@ -1109,7 +1146,7 @@ jQuery(function ($) {
1109
  $('#wp-smush-save-settings').click();
1110
  });
1111
 
1112
- //Enable Resi
1113
  $('.wp-smush-resize-enable').on('click', function (e) {
1114
  e.preventDefault();
1115
 
@@ -1119,7 +1156,6 @@ jQuery(function ($) {
1119
  $('#wp-smush-save-settings').click();
1120
  });
1121
 
1122
-
1123
  //Trigger Bulk
1124
  $('body').on('click', '.wp-smush-trigger-bulk', function (e) {
1125
  e.preventDefault();
@@ -1162,6 +1198,7 @@ jQuery(function ($) {
1162
  settings_wrap.hide();
1163
  }
1164
  });
 
1165
  //Handle PNG to JPG Checkbox toggle, to show/hide Transparent image conversion settings
1166
  $('#wp-smush-png_to_jpg').click(function () {
1167
  var self = $(this);
@@ -1174,6 +1211,15 @@ jQuery(function ($) {
1174
  }
1175
  });
1176
 
 
 
 
 
 
 
 
 
 
1177
  //Handle Twitter Share
1178
  $('#wp-smush-twitter-share').on('click', function (e) {
1179
  e.preventDefault();
@@ -1192,6 +1238,8 @@ jQuery(function ($) {
1192
 
1193
  return false;
1194
  });
 
 
1195
  $('#wp-smush-facebook-share').on('click', function (e) {
1196
  e.preventDefault();
1197
  var width = 550,
@@ -1244,6 +1292,12 @@ jQuery(function ($) {
1244
  });
1245
  });
1246
 
 
 
 
 
 
 
1247
  });
1248
  (function ($) {
1249
  var Smush = function (element, options) {
208
  self.$status.html(response.data);
209
 
210
  //Check whether to show membership validity notice or not
211
+ membership_validity(response.data);
212
 
213
  if (response.success && response.data !== "Not processed") {
214
  self.$status.removeClass('hidden');
455
  }
456
 
457
  //Check whether to show the warning notice or not
458
+ membership_validity(res.data);
459
 
460
  if (typeof res.data !== "undefined" && res.data.error == 'bulk_request_image_limit_exceeded' && !self.is_resolved()) {
461
  //Add a data attribute to the smush button, to stop sending ajax
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
808
  action: 'scan_for_resmush',
809
  type: scan_type,
810
  get_ui: true,
811
+ process_settings: process_settings,
812
  wp_smush_options_nonce: jQuery('#wp_smush_options_nonce').val()
813
  };
814
 
876
  //Hide Spinner
877
  spinner.removeClass('is-active');
878
  $('.wp-smush-button').removeAttr('disabled');
879
+
880
+ //If wp-smush-re-check-message is there, remove it
881
+ if ($('.wp-smush-re-check-message').length) {
882
+ remove_element($('.wp-smush-re-check-message'));
883
+ }
884
  });
885
+ }
886
+
887
+ /**
888
+ * Handle the Smush Stats link click
889
+ */
890
+ $('body').on('click', 'a.smush-stats-details', function (e) {
891
+
892
+ //If disabled
893
+ if ('disabled' == $(this).attr('disabled')) {
894
+ return false;
895
+ }
896
+
897
+ // prevent the default action
898
+ e.preventDefault();
899
+ //Replace the `+` with a `-`
900
+ var slide_symbol = $(this).find('.stats-toggle');
901
+ $(this).parents().eq(1).find('.smush-stats-wrapper').slideToggle();
902
+ slide_symbol.text(slide_symbol.text() == '+' ? '-' : '+');
903
+
904
+
905
+ });
906
+
907
+ /** Handle smush button click **/
908
+ $('body').on('click', '.wp-smush-send:not(.wp-smush-resmush)', function (e) {
909
+
910
+ // prevent the default action
911
+ e.preventDefault();
912
+ new WP_Smush.Smush($(this), false);
913
+ });
914
+
915
+ /** Handle NextGen Gallery smush button click **/
916
+ $('body').on('click', '.wp-smush-nextgen-send', function (e) {
917
+
918
+ // prevent the default action
919
+ e.preventDefault();
920
+ new WP_Smush.Smush($(this), false, 'nextgen');
921
+ });
922
+
923
+ /** Handle NextGen Gallery Bulk smush button click **/
924
+ $('body').on('click', '.wp-smush-nextgen-bulk', function (e) {
925
+
926
+ // prevent the default action
927
+ e.preventDefault();
928
+
929
+ //Check for ids, if there is none (Unsmushed or lossless), don't call smush function
930
+ if (typeof wp_smushit_data == 'undefined' ||
931
+ ( wp_smushit_data.unsmushed.length == 0 && wp_smushit_data.resmush.length == 0 )
932
+ ) {
933
+
934
+ return false;
935
+
936
+ }
937
+
938
+ jQuery('.wp-smush-button, .wp-smush-scan').attr('disabled', 'disabled');
939
+ $(".wp-smush-notice.wp-smush-remaining").hide();
940
+ new WP_Smush.Smush($(this), true, 'nextgen');
941
+
942
+ });
943
+
944
+ /** Restore: Media Library **/
945
+ $('body').on('click', '.wp-smush-action.wp-smush-restore', function (e) {
946
+ var current_button = $(this);
947
+ var smush_action = 'smush_restore_image';
948
+ process_smush_action(e, current_button, smush_action, 'restore');
949
+ });
950
+
951
+ /** Resmush: Media Library **/
952
+ $('body').on('click', '.wp-smush-action.wp-smush-resmush', function (e) {
953
+ var current_button = $(this);
954
+ var smush_action = 'smush_resmush_image';
955
+ process_smush_action(e, current_button, smush_action, 'smushing');
956
+ });
957
+
958
+ /** Restore: NextGen Gallery **/
959
+ $('body').on('click', '.wp-smush-action.wp-smush-nextgen-restore', function (e) {
960
+ var current_button = $(this);
961
+ var smush_action = 'smush_restore_nextgen_image';
962
+ process_smush_action(e, current_button, smush_action, 'restore');
963
+ });
964
+
965
+ /** Resmush: NextGen Gallery **/
966
+ $('body').on('click', '.wp-smush-action.wp-smush-nextgen-resmush', function (e) {
967
+ var current_button = $(this);
968
+ var smush_action = 'smush_resmush_nextgen_image';
969
+ process_smush_action(e, current_button, smush_action, 'smushing');
970
+ });
971
+
972
+ //Scan For resmushing images
973
+ $('body').on('click', '.wp-smush-scan', function (e) {
974
+
975
+ e.preventDefault();
976
+
977
+ //Run the Re-check
978
+ run_re_check( $(this ), false );
979
 
980
  });
981
 
983
  $('#wp-smush-welcome-box .smush-dismiss-welcome').on('click', function (e) {
984
  e.preventDefault();
985
  var $el = $(this).parents().eq(1);
986
+ remove_element($el);
987
 
988
  //Send a ajax request to save the dismissed notice option
989
  var param = {
996
  $('body').on('click', '.wp-smush-notice .dev-icon-cross', function (e) {
997
  e.preventDefault();
998
  var $el = $(this).parent();
999
+ remove_element($el);
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
1016
+ var param = {
1017
+ action: 'save_settings',
1018
+ nonce: $('#wp_smush_options_nonce').val()
1019
+ };
1020
 
1021
+ param = jQuery.param(param) + '&' + jQuery('form#wp-smush-settings-form').serialize();
1022
 
1023
+ //Send ajax, Update Settings, And Check For resmush
1024
+ jQuery.post(ajaxurl, param).done(function () {
1025
+ jQuery('form#wp-smush-settings-form').submit();
1026
+ return true;
1027
+ });
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
1035
+ var keep_exif = document.getElementById("wp-smush-keep_exif");
1036
+ var super_smush = document.getElementById("wp-smush-lossy");
1037
+ var smush_original = document.getElementById("wp-smush-original");
1038
+ var resize_images = document.getElementById("wp-smush-resize");
1039
+ var smush_pngjpg = document.getElementById("wp-smush-png_to_jpg");
1040
 
1041
+ var update_button_txt = true;
 
 
1042
 
1043
+ $('.wp-smush-hex-notice').hide();
1044
 
1045
+ //If Preserve Exif is Checked, and all other settings are off, just save the settings
1046
+ if (keep_exif.checked && !super_smush.checked && !smush_original.checked && !resize_images.checked && !smush_pngjpg.checked) {
1047
+ update_button_txt = false;
1048
+ }
1049
 
1050
+ //Update text
1051
+ self.attr('disabled', 'disabled').addClass('button-grey');
 
 
 
1052
 
1053
+ if (update_button_txt) {
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;
1062
+
1063
+ //Ajax param
1064
+ var param = {
1065
+ action: 'scan_for_resmush',
1066
+ wp_smush_options_nonce: jQuery('#wp_smush_options_nonce').val(),
1067
+ scan_type: scan_type
1068
+ };
1069
+
1070
+ param = jQuery.param(param) + '&' + jQuery('form#wp-smush-settings-form').serialize();
1071
+
1072
+ //Send ajax, Update Settings, And Check For resmush
1073
+ jQuery.post(ajaxurl, param).done(function () {
1074
+ jQuery('form#wp-smush-settings-form').submit();
1075
+ return true;
1076
+ });
1077
+ }
1078
  });
1079
 
1080
  //On Resmush click
1085
 
1086
  //Remove Parent div
1087
  var $el = self.parent();
1088
+ remove_element($el);
1089
 
1090
  //Remove Settings Notice
1091
  $('.wp-smush-notice.wp-smush-settings-updated').remove();
1146
  $('#wp-smush-save-settings').click();
1147
  });
1148
 
1149
+ //Enable Resize
1150
  $('.wp-smush-resize-enable').on('click', function (e) {
1151
  e.preventDefault();
1152
 
1156
  $('#wp-smush-save-settings').click();
1157
  });
1158
 
 
1159
  //Trigger Bulk
1160
  $('body').on('click', '.wp-smush-trigger-bulk', function (e) {
1161
  e.preventDefault();
1198
  settings_wrap.hide();
1199
  }
1200
  });
1201
+
1202
  //Handle PNG to JPG Checkbox toggle, to show/hide Transparent image conversion settings
1203
  $('#wp-smush-png_to_jpg').click(function () {
1204
  var self = $(this);
1211
  }
1212
  });
1213
 
1214
+ //Handle, Change event in Enable Networkwide settings
1215
+ $('#wp-smush-networkwide').on('click', function (e) {
1216
+ if ( $( this ).is(':checked')) {
1217
+ $('.network-settings-wrapper').show();
1218
+ }else{
1219
+ $('.network-settings-wrapper').hide();
1220
+ }
1221
+ });
1222
+
1223
  //Handle Twitter Share
1224
  $('#wp-smush-twitter-share').on('click', function (e) {
1225
  e.preventDefault();
1238
 
1239
  return false;
1240
  });
1241
+
1242
+ //Handle Facebook Share
1243
  $('#wp-smush-facebook-share').on('click', function (e) {
1244
  e.preventDefault();
1245
  var width = 550,
1292
  });
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) {
assets/shared-ui/wdev-ui.css CHANGED
@@ -869,6 +869,9 @@
869
  .wpmud [tooltip].tooltip-s.tooltip-right:after {
870
  margin-left: -130px;
871
  }
 
 
 
872
  .wpmud [tooltip].tooltip-l.tooltip-right:after {
873
  margin-left: -260px;
874
  }
869
  .wpmud [tooltip].tooltip-s.tooltip-right:after {
870
  margin-left: -130px;
871
  }
872
+ .wpmud [tooltip].tooltip-s.tooltip-left:after {
873
+ margin-left: -30px;
874
+ }
875
  .wpmud [tooltip].tooltip-l.tooltip-right:after {
876
  margin-left: -260px;
877
  }
extras/dash-notice/wpmudev-dash-notification.php CHANGED
@@ -1,442 +1,630 @@
1
  <?php
2
  /////////////////////////////////////////////////////////////////////////
3
  /* -------- WPMU DEV Dashboard Notice - Aaron Edwards (Incsub) ------- */
4
- if ( !class_exists('WPMUDEV_Dashboard_Notice3') ) {
5
- class WPMUDEV_Dashboard_Notice3 {
6
-
7
- var $version = '3.1';
8
  var $screen_id = false;
9
  var $product_name = false;
10
  var $product_update = false;
11
  var $theme_pack = 128;
12
- var $server_url = 'http://premium.wpmudev.org/wdp-un.php';
13
  var $update_count = 0;
14
-
15
  function __construct() {
16
  add_action( 'init', array( &$this, 'init' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  }
18
-
19
  function init() {
20
  global $wpmudev_un;
21
-
22
- if ( class_exists( 'WPMUDEV_Dashboard' ) || ( isset($wpmudev_un->version) && version_compare($wpmudev_un->version, '3.4', '<') ) )
23
  return;
24
-
 
25
  // Schedule update cron on main site only
26
  if ( is_main_site() ) {
27
  if ( ! wp_next_scheduled( 'wpmudev_scheduled_jobs' ) ) {
28
  wp_schedule_event( time(), 'twicedaily', 'wpmudev_scheduled_jobs' );
29
  }
30
 
31
- add_action( 'wpmudev_scheduled_jobs', array( $this, 'updates_check') );
32
  }
33
- add_action( 'delete_site_transient_update_plugins', array( &$this, 'updates_check' ) ); //refresh after upgrade/install
34
- add_action( 'delete_site_transient_update_themes', array( &$this, 'updates_check' ) ); //refresh after upgrade/install
35
-
 
 
 
 
 
 
36
  if ( is_admin() && current_user_can( 'install_plugins' ) ) {
37
-
38
  add_action( 'site_transient_update_plugins', array( &$this, 'filter_plugin_count' ) );
39
  add_action( 'site_transient_update_themes', array( &$this, 'filter_theme_count' ) );
40
- add_filter( 'plugins_api', array( &$this, 'filter_plugin_info' ), 101, 3 ); //run later to work with bad autoupdate plugins
41
- add_filter( 'themes_api', array( &$this, 'filter_plugin_info' ), 101, 3 ); //run later to work with bad autoupdate plugins
42
- add_action( 'admin_init', array( &$this, 'filter_plugin_rows' ), 15 ); //make sure it runs after WP's
 
 
 
 
 
 
 
43
  add_action( 'core_upgrade_preamble', array( &$this, 'disable_checkboxes' ) );
44
  add_action( 'activated_plugin', array( &$this, 'set_activate_flag' ) );
45
-
46
- //remove version 1.0
47
- remove_action( 'admin_notices', 'wdp_un_check', 5 );
48
- remove_action( 'network_admin_notices', 'wdp_un_check', 5 );
49
- //remove version 2.0, a bit nasty but only way
50
- remove_all_actions( 'all_admin_notices', 5 );
51
-
52
  //if dashboard is installed but not activated
53
- if ( file_exists(WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php') ) {
54
- if ( !get_site_option('wdp_un_autoactivated') ) {
55
  //include plugin API if necessary
56
- if ( !function_exists('activate_plugin') ) require_once(ABSPATH . 'wp-admin/includes/plugin.php');
57
- $result = activate_plugin( '/wpmudev-updates/update-notifications.php', network_admin_url('admin.php?page=wpmudev'), is_multisite() );
58
- if ( !is_wp_error($result) ) { //if autoactivate successful don't show notices
59
- update_site_option('wdp_un_autoactivated', 1);
 
 
 
60
  return;
61
  }
62
  }
63
-
64
  add_action( 'admin_print_styles', array( &$this, 'notice_styles' ) );
 
65
  add_action( 'all_admin_notices', array( &$this, 'activate_notice' ), 5 );
66
  } else { //dashboard not installed at all
67
- if ( get_site_option('wdp_un_autoactivated') ) {
68
- update_site_option('wdp_un_autoactivated', 0);//reset flag when dashboard is deleted
69
  }
70
  add_action( 'admin_print_styles', array( &$this, 'notice_styles' ) );
 
71
  add_action( 'all_admin_notices', array( &$this, 'install_notice' ), 5 );
72
  }
73
  }
74
  }
75
-
76
  function is_allowed_screen() {
77
  global $wpmudev_notices;
78
- $screen = get_current_screen();
79
- $this->screen_id = $screen->id;
80
-
81
  //Show special message right after plugin activation
82
- if ( in_array( $this->screen_id, array('plugins', 'plugins-network') ) && ( isset($_GET['activate']) || isset($_GET['activate-multi']) ) ) {
83
- $activated = get_site_option('wdp_un_activated_flag');
84
- if ($activated === false) $activated = 1; //on first encounter of new installed notice show
85
- if ($activated) {
86
- if ($activated >= 2)
87
- update_site_option('wdp_un_activated_flag', 0);
88
- else
89
- update_site_option('wdp_un_activated_flag', 2);
 
 
 
 
 
 
 
 
90
  return true;
91
  }
92
  }
93
-
 
 
 
 
 
 
94
  //always show on certain core pages if updates are available
95
- $updates = get_site_option('wdp_un_updates_available');
96
- if (is_array($updates) && count($updates)) {
97
- $this->update_count = count($updates);
98
- if ( in_array( $this->screen_id, array('plugins', 'update-core', /*'plugin-install', 'theme-install',*/ 'plugins-network', 'themes-network', /*'theme-install-network', 'plugin-install-network',*/ 'update-core-network') ) )
 
 
 
99
  return true;
 
100
  }
101
-
102
  //check our registered plugins for hooks
103
- if ( isset($wpmudev_notices) && is_array($wpmudev_notices) ) {
104
  foreach ( $wpmudev_notices as $product ) {
105
- if ( isset($product['screens']) && is_array($product['screens']) && in_array( $this->screen_id, $product['screens'] ) ) {
106
  $this->product_name = $product['name'];
107
  //if this plugin needs updating flag it
108
- if ( isset($product['id']) && isset($updates[$product['id']]) )
109
  $this->product_update = true;
 
 
110
  return true;
111
  }
112
  }
113
  }
114
-
115
- if ( defined('WPMUDEV_SCREEN_ID') ) var_dump($this->screen_id); //for internal debugging
116
-
117
  return false;
118
  }
119
-
120
  function auto_install_url() {
121
  $function = is_multisite() ? 'network_admin_url' : 'admin_url';
122
- return wp_nonce_url($function("update.php?action=install-plugin&plugin=install_wpmudev_dash"), "install-plugin_install_wpmudev_dash");
 
123
  }
124
-
125
  function activate_url() {
126
  $function = is_multisite() ? 'network_admin_url' : 'admin_url';
127
- return wp_nonce_url($function('plugins.php?action=activate&plugin=wpmudev-updates%2Fupdate-notifications.php'), 'activate-plugin_wpmudev-updates/update-notifications.php');
 
128
  }
129
-
130
  function install_notice() {
131
- if ( !$this->is_allowed_screen() ) return;
132
 
133
- echo '<div class="updated" id="wpmu-install-dashboard"><div class="wpmu-install-wrap"><p class="wpmu-message">';
134
-
135
- if ($this->product_name) {
136
- if ($this->product_update)
137
- echo 'Important updates are available for <strong>' . esc_html($this->product_name) . '</strong>. Install the free WPMU DEV Dashboard plugin now for updates and support!';
138
- else
139
- echo '<strong>' . esc_html($this->product_name) . '</strong> is almost ready - install the free WPMU DEV Dashboard plugin for updates and support!';
140
- } else if ($this->update_count) {
141
- echo "Important updates are available for your WPMU DEV plugins/themes. Install the free WPMU DEV Dashboard plugin now for updates and support!";
142
- } else {
143
- echo 'Almost ready - install the free WPMU DEV Dashboard plugin for updates and support!';
144
- }
145
- echo '</p><a class="wpmu-button" href="' . $this->auto_install_url() . '">Install WPMU DEV Dashboard</a>';
146
- echo '</div>';
147
- echo '<div class="wpmu-more-wrap"><a href="http://premium.wpmudev.org/update-notifications-plugin-information/" class="wpmu-more-info">More Info&raquo;</a></div>';
148
- echo '</div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  }
150
-
151
  function activate_notice() {
152
- if ( !$this->is_allowed_screen() ) return;
153
-
154
- echo '<div class="updated" id="wpmu-install-dashboard"><div class="wpmu-install-wrap"><p class="wpmu-message">';
155
- if ($this->product_name) {
156
- if ($this->product_update)
157
- echo 'Important updates are available for <strong>' . esc_html($this->product_name) . '</strong>. Activate the WPMU DEV Dashboard to update now!';
158
- else
159
- echo "Just one more step to enable updates and support for <strong>" . esc_html($this->product_name) . '</strong>!';
160
- } else if ($this->update_count) {
161
- echo "Important updates are available for your WPMU DEV plugins/themes. Activate the WPMU DEV Dashboard to update now!";
162
- } else {
163
- echo "Just one more step - activate the WPMU DEV Dashboard plugin and you're all done!";
164
- }
165
- echo '</p><a class="wpmu-button" href="' . $this->activate_url() . '">Activate WPMU DEV Dashboard</a></div></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  }
167
-
168
  function notice_styles() {
169
  if ( !$this->is_allowed_screen() ) return;
170
  ?>
171
- <!-- WPMU DEV Dashboard notice -->
172
- <style type="text/css" media="all">
173
- #wpmu-install-dashboard{background-color:#031f34;font-family:sans-serif;display:block;border-radius:5px;position:relative;border:none;padding:14px 0.6em;font-size:1.3em;line-height:1.4em}
174
- #wpmu-install-dashboard .wpmu-button{width:auto;position:absolute;top:0;bottom:0;right:0;padding:10px;margin:auto 14px auto 10px;line-height:1em;max-height:1em;background-color:#06385e;color:#3bb2df;text-decoration:none;border:5px solid rgba(53,131,191,0.4);vertical-align:middle;text-shadow:0 1px 0 rgba(0,0,0,0.6)}
175
- #wpmu-install-dashboard .wpmu-button:hover{color:#e8da42;border-color:rgba(53,131,191,0.9);-webkit-transition:0.2s}
176
- #wpmu-install-dashboard .wpmu-message{color:#c0d7eb;margin:0 280px 0 15px;padding:12px 0;text-shadow:0 1px 0 rgba(0,0,0,1);font-size:1em}
177
- #wpmu-install-dashboard .wpmu-button,#wpmu-install-dashboard .wpmu-button:hover{-webkit-transition:0.2s}
178
- #wpmu-install-dashboard .wpmu-btn-wrap{min-width:10%;background-color:#fff}
179
- #wpmu-install-dashboard .wpmu-install-wrap{max-width:1050px;margin:0 auto;position:relative}#wpmu-install-dashboard .wpmu-more-wrap{max-width:1050px;margin:0 auto -9px;padding:5px 0 0;text-align:right}
180
- #wpmu-install-dashboard .wpmu-more-info{color:#e8da42;font-size:0.9em;margin:0 14px}
181
- #wpmu-install-dashboard, .wpmu-update-row{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAYAAACAvzbMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpCMDBDRENDMjJEOUUxMUUzQjQ0MThGOUZCNkQzMTIwNCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpCMDBDRENDMzJEOUUxMUUzQjQ0MThGOUZCNkQzMTIwNCI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkIwMENEQ0MwMkQ5RTExRTNCNDQxOEY5RkI2RDMxMjA0IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkIwMENEQ0MxMkQ5RTExRTNCNDQxOEY5RkI2RDMxMjA0Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+4bBa5AAAFnZJREFUeNrs3el2U0e6BuCyZTybmYSE9JAr6V/nqs+vcyPndHdCgAAGbPA8HFX7U0dxQ5BtWfpq7+dZq5ZJsoilUu16a9pbC+fn5wUArmpRFQAgQAAQIAAIEAAECAAIEAAECAACBAABAoAAAQABAoAAAUCAACBAABAgACBAABAgAAgQAAQIAAIEAAQIAAIEAAECgAABQIAAgAABQIAAIEAAaN5Sthf0t/9+5VMB+LrNYTn/n//69pMZCACTejQsPw7LhhkIAJP22U+H5ZthWRiWMwECwNfU2cazYdnKlGYA5PZ4WL4bluVs0yEAcrpTLpasnpSLJatUBAhATvWU1fcl0ZKVAAHIL+WSlQAByN0n1+BIuWQlQAByqqesfigXS1fNpB0A81NnGqMlqzutTZcAmI8aGN9HgDRHgADMx1aEx2arb0CAAMxWs0tWAgRgfpYjOB6VBk5ZCRCAHJpfshIgALNVZxpPYubRqT5XgADcnuWYdTzq4psTIAC34265ePz6elffoAABmK76Ta91yepp1/tYAQIwPSvlYsnqYR/erAABmI7OL1kJEIDpqktW9TvKv+1bnypAAK6vV0tWAgRgOnq3ZCVAAG5mtGRVT1kN+lwRAgRgcqvlYsnqgaoQIACTuh/hsaYqBAjAJOoy1eiU1UB1CBCASdRnWdXvKbdk9RmLqgDgi9aFhwABuI4FVSBAAK7jXBUIEAAECAACBAABAoAAAQABAoAAAUCAACBAABAgACBAABAgAAgQAAQIAAIEAAQIAAIEAAECgAABAAECgAABQIAAIEAAECAAIEAAECAAzN6SKpi6hQjm8Z/j/20wLKfDcj727+ufzy79hMvtaLwtDcbai3aEAGnw4r4zLMuXfi6NlcFn6njhMxf2SYTKyVg5HpajsZ9HOoRODzqWL5XLbWnp0orB19rR8aV2dDTWnkCAzKGu6oW9MSzrw7ISF/mdCIqb+KO/fxoXfS2Hw/JpWPaiMzjxsTRpEO1m1JbWptSW/ujvHo+V2n4+Dst+tCEDEwTILViOC3xzWLYiNAYzfg2DKKvxGh5HqBxEJ/BxLFDIPcvYGGtLa3H9Lczo948CqrpXLpa4jmNAshM/D3xMCJCbd9hbcZFtxIWe8TVuRPk2AqSW9xEopz7GNOqg40G0qY05DEC+ZDFeWy0Px2a3HyJQzG4RIFdQR/h342JfL22dUFuP8jA6gXfRCRz6WOemzjTuR3tabiToRmFXl7a2I0zMShAgX7lwHseFs9L4e1mMke5WXPg1SN4KkpkHx+MIj0GDr39hbEDyJIJEG0KAXFJHhY+irHTw/dUZ1XcRjLUTeFOcwLnt+n4Ss8CuXFcrY23obRRtiF4HyEJc5HXvYK0H77d2bN/HiPhVzEqcupmeQQxCvunoQGTUhp5FG3pZLvbaoHcBUqflT+NCWOjhe/9ruTgc8KJY256GjRih3+vR+/0xZiI1SJz8EyC98TjCY6XHn/do9lU7gl/KxdIW1/Mk2tNyz973Yrz3URv6oCkIkC67E6PExz2cdXxJDdG/RCdQZyOObF7tmvlee/rXjPbHmIn8Wn7/SBUESCfUPY4/lYtTSfznSLKu29f17Z+KJa1JrEZ7uqsq/qXu/zyLenlebLD3shPpqq0YIQmPP3Y36mlTVfyh0fq/8PhPj2JGu6oqBEhXOsW/ln6cspqG0Qa7sP28zaifdVXxRfeijoSIAGna/WjIyz7eK1kpv53S4j/DQ8c4+SxN0AqQZmcefy6/PTSOq1mO+jMT+W1m9pfS75N7160zgStAmhspCo/phchGz+thVUd44xCxCiBAmrASnZ6R4vQ6zz/3uAOopxN/KJZibjqgqyfWBqpCgGS/2GtDtWE+/VFkHzuAem9Hvc/DXtDN3Y+6dP+VAEnrqYv9VjuAb3v2nuuR1Cc++ql5EnWKAEmnPpbjGx/jraoB8qAn73UzRsxMd0b3rLjPSIAkM3pcuenx7beRWs9d318aRHg4hDF9SxEivn9IgKQZ1XxXnJCZlbUehHWdyTq+fLuzu6eqQYBk8KD0Z1klU513da9po1gKnYX6AEqPghEgc3UnRjKWrmbfVuosZMn74poG6lqAzFs91eHI7nyMvie7S+4Xp/hmqS5lOZUlQOZiLabBzE+t/65sqNeRsKWr2Rt9jQACZOadl1My87XcoVlIHQlv+Ei1IbofIHX55KGPLIWHHRhB3imWUubdhoS3AJlpg7P5pvOdlrr3YS9tfpYEuACZlTradWw3l/p5tPqwxYHZbJo2ZBYiQHRWPbTScKjXU1cerWEWQg8CZKk4ZpnV/dLe03oXzD7ShbkTWQLk1mya5qa10eBIfqt4ZEkmyzEQQYDc2iiXvKP51maH90r3vsq5CzNZB2QEyNStGC2md7e0sz+1XCyHZrTuOhcgt6E2KjcO5u+UW1nG2iy+9jjrTNZKgwCZeqPaKh6a2MLF38oTVs0+coe7zXQBMjV3YmpLfusNzBTrzMNhDDNZpijzxtV64yOSs2E5HJb9+Hka/67+HER4D+I9rkUH1+psazU+rw+JX+NGafteovNhOR6Wg2E5iXIW1/Ag2s9Kae9Y9bg6k30b7xUBcuMLvkU1MHaiMz2Mi/78K7PApbj4R48Wb22dfqGRAGkxoA8utadRcJxfakODaEeb5bcbJVsLk80I+UNdswC5icUGp7P7MXrajtC4ykzlKMrusLwuF08dflTaOtq4GZ/bWdJ2vtFge3ozLO8maE9nUY7j772OEHlc2tqcrsugWwJEgNzUckOj8PMIjRdTavh1xPlzjDqflXb2gdaiA8h48a+Udh6ceBbB8SoGFdf1IQYkNURa+hbAzXj/CJBrW2+kwdf9jF9ixDftddud6Iz/XNo45TSITjpjgGyUNm4ePI72NK0OtIbRrzEr+VMjIboW1/6J7jm/xcSNKPt6dW3gP8UFelubfrUz/keMJFtoS1k7qBZmccfxWd/G6Lu2n78Py14D9VBni47zCpAbyd6A6sjuebnY87htdRnj53Kz5Yw+f26Zg218Jls/49s8hFDD458NtKNB8T0tAuQG6jp69uOWr8ps12nrxf9LyX+8cbnkO/mzmrw9ncdgZHsGv+tTzJrPkrejFlYgSBwgmW9K+xABMmv1NM5OAwGSrbNeK7mPs76OMivvZ/z7rmO9tH0/iwCZo6WSdwO97nu8iCWHWaujxrfJR49LCcM/8w2adWb5ck4z6Mz7IavF03kFyA1mIFkv+DexDDAvdQayn7w9Zbvwsy5fnUV4HM/hd9ffeZuHP6bRjmykC5BOXfCHZf7n0+vMZzt5m8o0A1lK3J7qUuj7Of7+uiT6MWndLAgQAdKFDmjc+5LjHofdMp8ltBY/v0HSABndLHg+59eQeTAiQATItUeN2WQa+ddjmJnXr5dKniXIjHsyo9nHbpLXkXVJtOUHXwoQAfI7dap/kCjMBMjkM5CMbfxdybH/cFzyPgAza/iTPEAyHt/bLblOPx0mb1NZAiRjB7RXcu09ZGvb4/2Ak1gCpPnXVI/ufkr4mrKeoBmUXEtY2RyU+Zy8+qNAO0jajgSIALmybEd4a2ed7fEPme9IX0j0GWZs3+cJ2/dx0nbkZkIBAtD8QBIBAoAAAUCAQI9YmkGAACBAADMQECA6IQABghABBAgAAgQABAgAAgQAAQKAAAFAgACAAPG5AeiIABAgAAgQAAQIAAgQAAQItMqTlBEggPBAgACAADGKBRAgAAgQAAQIAAJEFQAgQAAQIAAIEAAECEm4DwQQIAgQQIAAIEAAQIAAIEAAECAACBBgYgvFKToECAACBAAESC9YAgEECAACBAABAgACBAABAoAAAUCAACBAaIP7QAABggABBAgAAgQABAgAAgQAAQKAAAEm5hsJESDAtQMEBAg6IUCAAIAAAUCAACBAABAgAAgQVQCAAAFAgAAgQJg+NxICAgQBAggQAAQIAAgQAAQIAAIEAAECTMw3EiJAABAgtDmKBRAgAAgQAAQIAAgQAAQIAAIEAAECgAAhP/eBAAIEAQIIEAAECAAIEAAECAACBAABAkzMCToECHDtABEiCBAABAhGsAACpCchAiBAABAgAAgQABAgAAgQAAQIAAIEAAFCbm4kBAQIAAIEAAECAAIEAAECnXCuChAgwHU4RYcAAa4dIJipdaI9CZA2L6zMF1emNjXw+ZmpdbyPPFM5XLUDOk38+mqnvZSkA1pLWD+n877oGxnt18/vToLXsZK8PzgRIDTVaCYIkAwXXe18VgVIswGSpfNeTXytnQoQruMo8WurI8f1BK9jK8kI9rLjhB121hntWpnvMuRi8gA5FiBct+GcJX59G2X+69dbJeeGdcbZY9YAWZ/zLGTev3+SfuBYgNDcyGOCkeM89x/qqPGu2eOV2lNGdfaxOedByCDxdXZUbKJzDYfJA+ROXHzzcr/kXL46TRogtS1l3Qe5N6eZ5CDxIGS8H5grAdKm0wyN5yselvmcxqpLDo+S1slJ0s8t477MyOacBiM1PDYSX1915rEvQLiug+Svr64fP5jD731c8m58niSdgcx9KeQrfdTjGc9C5vE7rzOIFCBc214Dr/HJsCzP8Pdtxe/MHPoZR/onJe8+SHU/yqw8KvNdgp20Lc39MxMg7dpPftFXdSP96Yx+Vw2qZyX3pmfW0K+zj8xLogvRjmYxGKmz129K/kfOfMowaxQg7TrJMIWdwOO4IG9TDY0fSu4163MBciPr8Rnf5gBhKX7HagPX1acML0KAtOu0tLGMVUdy35fb29iuF/2fynz2W66idtCZbwA9aKAtPYhZ5m30W4vRju41UA/HWT6vpULL9mJkm326PYiLs/58Xaa3D7AeHcrdBj6r7EuOh420pSfRjp5PMZBXoh09aOi6TzEYESDtB8hRyf/At1GI/BCd/qtys+W32m7rMeFvGnnv42Gf1VGESAvLNw/jc385LB9uUK+LMeP4ruR88OaXpNj/ECDtO4yOuJVOtI5uRydctuPi/3SFDmAlZhsPSv5TMuNaWG5sKUCqut/147C8j7JTJn8ky9JYO5rXjYo3aUs7WV6MAGnfbpntEcdpqKdp6qmaxxGAn+LnSfn9XdGjR8Ovxswl+7OJ/ijoswfIaJP/XkP1uhizkQfRfvbGZuUnY6P0xWhHyxE869GmWvxyr/2S6PCMAOlGgJw0+lkuxUxia6wTG//Zla9//VhyP3pmZLQ00trhmoWxAcaX2lHpSFvaKYlu+nQKq30HESJdMAqMxShd+frXnUZeZ5rN2VtoR11oS2fZrnUB0r46yvqgGlIvOew18lqPS5L7C/jiTDbVvV8CpBt2Sxvn+Ptop+R/YkCLs6U+qgPFVN/dIkC64ah0ZxmrS84a7JC7sozVxWs83UqDAOmOdyX3txT2Ue2MPzb2mg8bfM19mX2ke9yMAOmOTy58oT4F5zFrOvfxpZrJbmd8YQKkW43sjQs/1Uj+fcOjXXtqebwvSQ83CJBu2SlO0WS66FvdSzgpTvZlGhi+zTowFCDdcpq5sfVI7YC3G38P70obNz92XQ3ytAdkBEg3R777qmHun8Fe4+9hzyxk7upAMPWytADp5uj3jWpQ/1NQZ1FO9s139pH6YIwA6abt4r6QedZ9V/ahds1C5qYuR/+aPcAFSHcb30ujx5mrd5y/7tD7OY/3ox0ZBAqQnqknst6qhpmqI8auHX+tSyjvfLQzdRhtKT0B0v0OzWMpZqMuW3Vx7+k82tGxj3hm9f2ylYGIAOm22ghfqYZbV5d4XpTuHnutJ7Je+5hnou45NXMEXIB039tiI1Qd39zr4ibV23YUA5Fm9pwESPfVDfXnJeGD2DriU1z0XVdnV7+UZI8T75DzqN+m7h8SIP2wH52cO9SnH871ou/L/sBOsZR1W96UBg+9CJD+qI3zpWqY6ojxRenfFzDVNmRJdLo+xECkOQKkX+qGuiOZ07Hd09G4JdHpOoj6bPIAhgDp38X/U3GX+k3VWcfPpb832NUl0X8WD1u8qaOox2afXSdA+uc4Gu2eqriWTzrPf4fo8+Iu9V4P5gRIf6fN/yie2ntVe1Fvlm8uvIkQcTjjak5iEPK+9TciQHSGQmQy++rrs34VIteaeWx34c0IkH6ryzH/V9wgNmk9Wfb7vHo4o897QpM6ikHIdlfekABhPzrH96ris+pa/9/NPCaaifyzuNHwS0bLxp06Bbnkc6VcrOnXxl032J+ojn+r9848Lx4keJX6quv7z4ZlTXX8227M0Do3gxUgjNQL/6cYaX83LHd6XBej71NJ/4U+CdWb4o4iRO71vC5G36fS2QdtChA+1+BriHw/LFs9rIO631HvCt7RHK6ttp+/x2z2m572M4cRHJ3+Th4BwufULxH63+gAnvRkNnIa4em7L6Y3o30Rgfy0R4OROmOtm+T1YMFB19+sAOFrHUAdiX87LPeHZaGj73UnLnizjtup2xoij6Osdnz22qvHBQkQJrko6imtuzEbuduhIKkzrXoz3Pvi9NBtz+5eRT3XEHk4LMsden/70Y7e9W32KkCYRN0bqZujuzETeRhLEq0eA9+Nzmy7eCTJLNV9gedR7w+itDwj2Yv3UoOjl18dLUC4irOxC2YzOoB7jYwma1DsxGvfNeOY+4i9lrcxo62Dko1hGTQym/oY18Fu6fl+mQDhujOS3Sgr0QnUsp4sTE5ilLgb4bFfPHIj24zkdQTJRgxG1qNkCpM6cPoU5UO0Kce7BQhT7ARqWRvrADZieaIuc81qz+Q0RoSji30/fgqN/DPb0YBkEO1nLdpQ/fOdGQfKWbSjvZht7MefzVoFCDNamliK2chaBMlKdASjzmBwg2A5jXISF3oNsYP43Yfx74VGm07HwmQh2tFKBMlKtKnL7egmQTHejo7G2tF+/DczDQHCHJyU35aQRgZx4S/Fn8d/no91GAtj/4+z+OfRqHA8PEYXPt10Hp/vccwExvutUTsataHFsTC53I7Ooq0sxP/zZKyM2tKR6hYg5B9dTrIMsDDWgcCXBifakQCBz448QTtKzuPcARAgAAgQAAQIAAIEAAQIAAIEAAECgAABQIAAgAABQIAAIEAAECAACBAAECAACBAABAgAAgQAAQIAAgQAAQKAAAFAgAAgQABAgAAgQAAQII1ZUAUAAuSqzobl7bAcqwqA31tSBV90NCzPh2VbVQAIkEl9ivDYVRUAAmRS74bl55iBACBAvqrud7walpfxZwAEyFfV2cYv5WLDHAABMpG631GXrD6qCgABMqm631E3yw81BQABMonzcrHf8aLY7wAQIBM6jlmH/Q4AATIx+x0AAuTK3sfM48DHDiBAJjHa76j3d5z6yAEEyCTqfke9v+ONjxpAgEzK86wABMiV2e8AECBXYr8DQIBc2UnMOux3AAiQie2Vi/s77HcACJCJ2e8AECBXUvc7fi0Xz7Oy3wEgQCZivwNAgFyZ/Q4AAXJl7yM8fH8HgACZiP0OAAFyZXW/oz7P6rWPC0CATGq/XCxZ7fioAATI1yzGT/sdAALkSup+R12uqstWJz4iAAEyqZ+G5UMECQBJLZyf66cBuLpFVQCAAAFAgAAgQAAQIAAgQAAQIAAIEAAECAACBAAECAACBAABAoAAAUCAAIAAAUCAACBAABAgAAgQABAgAAgQAAQIAAIEgJ75fwEGABxQF9Ke8fBQAAAAAElFTkSuQmCC);background-repeat:no-repeat;background-position:95% 64%}
182
- #the-list .wpmu-update-row{background-color:#031f34;border:none;color:#c0d7eb;background-size:100px}
183
- #the-list .wpmu-update-row a{color:#3bb2df}
184
- #the-list .wpmu-update-row a:hover{color:#e8da42;-webkit-transition:0.2s}
185
- </style>
186
  <?php
187
  }
188
-
189
- function get_id_plugin($plugin_file) {
190
- return get_file_data( $plugin_file, array('name' => 'Plugin Name', 'id' => 'WDP ID', 'version' => 'Version') );
 
 
 
 
191
  }
192
-
193
  //simple check for updates
194
  function updates_check() {
195
  global $wp_version;
196
  $local_projects = array();
197
-
198
  //----------------------------------------------------------------------------------//
199
  //plugins directory
200
  //----------------------------------------------------------------------------------//
201
  $plugins_root = WP_PLUGIN_DIR;
202
- if( empty($plugins_root) ) {
203
  $plugins_root = ABSPATH . 'wp-content/plugins';
204
  }
205
-
206
- $plugins_dir = @opendir($plugins_root);
207
  $plugin_files = array();
208
  if ( $plugins_dir ) {
209
- while (($file = readdir( $plugins_dir ) ) !== false ) {
210
- if ( substr($file, 0, 1) == '.' )
211
  continue;
212
- if ( is_dir( $plugins_root.'/'.$file ) ) {
213
- $plugins_subdir = @ opendir( $plugins_root.'/'.$file );
 
214
  if ( $plugins_subdir ) {
215
- while (($subfile = readdir( $plugins_subdir ) ) !== false ) {
216
- if ( substr($subfile, 0, 1) == '.' )
217
  continue;
218
- if ( substr($subfile, -4) == '.php' )
 
219
  $plugin_files[] = "$file/$subfile";
 
220
  }
221
  }
222
  } else {
223
- if ( substr($file, -4) == '.php' )
224
  $plugin_files[] = $file;
 
225
  }
226
  }
227
  }
228
  @closedir( $plugins_dir );
229
  @closedir( $plugins_subdir );
230
-
231
- if ( $plugins_dir && !empty($plugin_files) ) {
232
  foreach ( $plugin_files as $plugin_file ) {
233
  if ( is_readable( "$plugins_root/$plugin_file" ) ) {
234
-
235
- unset($data);
236
  $data = $this->get_id_plugin( "$plugins_root/$plugin_file" );
237
-
238
- if ( isset($data['id']) && !empty($data['id']) ) {
239
- $local_projects[$data['id']]['type'] = 'plugin';
240
- $local_projects[$data['id']]['version'] = $data['version'];
241
- $local_projects[$data['id']]['filename'] = $plugin_file;
242
  }
243
  }
244
  }
245
  }
246
-
247
  //----------------------------------------------------------------------------------//
248
  // mu-plugins directory
249
  //----------------------------------------------------------------------------------//
250
  $mu_plugins_root = WPMU_PLUGIN_DIR;
251
- if( empty($mu_plugins_root) ) {
252
  $mu_plugins_root = ABSPATH . 'wp-content/mu-plugins';
253
  }
254
-
255
- if ( is_dir($mu_plugins_root) && $mu_plugins_dir = @opendir($mu_plugins_root) ) {
256
- while (($file = readdir( $mu_plugins_dir ) ) !== false ) {
257
- if ( substr($file, -4) == '.php' ) {
258
  if ( is_readable( "$mu_plugins_root/$file" ) ) {
259
-
260
- unset($data);
261
  $data = $this->get_id_plugin( "$mu_plugins_root/$file" );
262
-
263
- if ( isset($data['id']) && !empty($data['id']) ) {
264
- $local_projects[$data['id']]['type'] = 'mu-plugin';
265
- $local_projects[$data['id']]['version'] = $data['version'];
266
- $local_projects[$data['id']]['filename'] = $file;
267
  }
268
  }
269
  }
270
  }
271
- @closedir( $mu_plugins_dir );
272
  }
273
-
274
  //----------------------------------------------------------------------------------//
275
  // wp-content directory
276
  //----------------------------------------------------------------------------------//
277
  $content_plugins_root = WP_CONTENT_DIR;
278
- if( empty($content_plugins_root) ) {
279
  $content_plugins_root = ABSPATH . 'wp-content';
280
  }
281
-
282
- $content_plugins_dir = @opendir($content_plugins_root);
283
  $content_plugin_files = array();
284
  if ( $content_plugins_dir ) {
285
- while (($file = readdir( $content_plugins_dir ) ) !== false ) {
286
- if ( substr($file, 0, 1) == '.' )
287
  continue;
288
- if ( !is_dir( $content_plugins_root.'/'.$file ) ) {
289
- if ( substr($file, -4) == '.php' )
 
290
  $content_plugin_files[] = $file;
 
291
  }
292
  }
293
  }
294
  @closedir( $content_plugins_dir );
295
-
296
- if ( $content_plugins_dir && !empty($content_plugin_files) ) {
297
  foreach ( $content_plugin_files as $content_plugin_file ) {
298
  if ( is_readable( "$content_plugins_root/$content_plugin_file" ) ) {
299
- unset($data);
300
  $data = $this->get_id_plugin( "$content_plugins_root/$content_plugin_file" );
301
-
302
- if ( isset($data['id']) && !empty($data['id']) ) {
303
- $local_projects[$data['id']]['type'] = 'drop-in';
304
- $local_projects[$data['id']]['version'] = $data['version'];
305
- $local_projects[$data['id']]['filename'] = $content_plugin_file;
306
  }
307
  }
308
  }
309
  }
310
-
311
  //----------------------------------------------------------------------------------//
312
  //themes directory
313
  //----------------------------------------------------------------------------------//
314
  $themes_root = WP_CONTENT_DIR . '/themes';
315
- if ( empty($themes_root) ) {
316
  $themes_root = ABSPATH . 'wp-content/themes';
317
  }
318
-
319
- $themes_dir = @opendir($themes_root);
320
  $themes_files = array();
321
  $local_themes = array();
322
  if ( $themes_dir ) {
323
- while (($file = readdir( $themes_dir ) ) !== false ) {
324
- if ( substr($file, 0, 1) == '.' )
325
  continue;
326
- if ( is_dir( $themes_root.'/'.$file ) ) {
327
- $themes_subdir = @ opendir( $themes_root.'/'.$file );
 
328
  if ( $themes_subdir ) {
329
- while (($subfile = readdir( $themes_subdir ) ) !== false ) {
330
- if ( substr($subfile, 0, 1) == '.' )
331
  continue;
332
- if ( substr($subfile, -4) == '.css' )
 
333
  $themes_files[] = "$file/$subfile";
 
334
  }
335
  }
336
  } else {
337
- if ( substr($file, -4) == '.css' )
338
  $themes_files[] = $file;
 
339
  }
340
  }
341
  }
342
  @closedir( $themes_dir );
343
  @closedir( $themes_subdir );
344
-
345
- if ( $themes_dir && !empty($themes_files) ) {
346
  foreach ( $themes_files as $themes_file ) {
347
-
348
  //skip child themes
349
- if ( strpos( $themes_file, '-child' ) !== false )
350
  continue;
351
-
 
352
  if ( is_readable( "$themes_root/$themes_file" ) ) {
353
-
354
- unset($data);
355
  $data = $this->get_id_plugin( "$themes_root/$themes_file" );
356
-
357
- if ( isset($data['id']) && !empty($data['id']) ) {
358
- $local_projects[$data['id']]['type'] = 'theme';
359
- $local_projects[$data['id']]['filename'] = substr( $themes_file, 0, strpos( $themes_file, '/' ) );
360
-
361
  //keep record of all themes for 133 themepack
362
- if ($data['id'] == $this->theme_pack) {
363
- $local_themes[$themes_file]['id'] = $data['id'];
364
- $local_themes[$themes_file]['filename'] = substr( $themes_file, 0, strpos( $themes_file, '/' ) );
365
- $local_themes[$themes_file]['version'] = $data['version'];
366
  //increment 133 theme pack version to lowest in all of them
367
- if ( isset($local_projects[$data['id']]['version']) && version_compare($data['version'], $local_projects[$data['id']]['version'], '<') ) {
368
- $local_projects[$data['id']]['version'] = $data['version'];
369
- } else if ( !isset($local_projects[$data['id']]['version']) ) {
370
- $local_projects[$data['id']]['version'] = $data['version'];
371
  }
372
  } else {
373
- $local_projects[$data['id']]['version'] = $data['version'];
374
  }
375
  }
376
  }
377
  }
378
  }
379
- update_site_option('wdp_un_local_themes', $local_themes);
380
-
381
- update_site_option('wdp_un_local_projects', $local_projects);
382
-
383
  //now check the API
384
- $projects = '';
385
- foreach ($local_projects as $pid => $project)
386
- $projects .= "&p[$pid]=" . $project['version'];
387
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  //get WP/BP version string to help with support
389
- $wp = is_multisite() ? "WordPress Multisite $wp_version" : "WordPress $wp_version";
390
- if ( defined( 'BP_VERSION' ) )
391
- $wp .= ', BuddyPress ' . BP_VERSION;
392
-
 
393
  //add blog count if multisite
394
  $blog_count = is_multisite() ? get_blog_count() : 1;
395
-
396
- $url = $this->server_url . '?action=check&un-version=3.3.3&wp=' . urlencode($wp) . '&bcount=' . $blog_count . '&domain=' . urlencode(network_site_url()) . $projects;
397
-
398
  $options = array(
399
- 'timeout' => 15,
 
400
  'user-agent' => 'Dashboard Notification/' . $this->version
401
  );
402
-
403
- $response = wp_remote_get($url, $options);
404
- if ( wp_remote_retrieve_response_code($response) == 200 ) {
 
 
 
 
 
 
 
 
 
405
  $data = $response['body'];
406
  if ( $data != 'error' ) {
407
- $data = unserialize($data);
408
- if ( is_array($data) ) {
409
-
410
  //we've made it here with no errors, now check for available updates
411
- $remote_projects = isset($data['projects']) ? $data['projects'] : array();
412
- $updates = array();
413
-
414
  //check for updates
415
- if ( is_array($remote_projects) ) {
416
  foreach ( $remote_projects as $id => $remote_project ) {
417
- if ( isset($local_projects[$id]) && is_array($local_projects[$id]) ) {
418
  //match
419
- $local_version = $local_projects[$id]['version'];
420
  $remote_version = $remote_project['version'];
421
-
422
- if ( version_compare($remote_version, $local_version, '>') ) {
423
  //add to array
424
- $updates[$id] = $local_projects[$id];
425
- $updates[$id]['url'] = $remote_project['url'];
426
- $updates[$id]['instructions_url'] = $remote_project['instructions_url'];
427
- $updates[$id]['support_url'] = $remote_project['support_url'];
428
- $updates[$id]['name'] = $remote_project['name'];
429
- $updates[$id]['thumbnail'] = $remote_project['thumbnail'];
430
- $updates[$id]['version'] = $local_version;
431
- $updates[$id]['new_version'] = $remote_version;
432
- $updates[$id]['changelog'] = $remote_project['changelog'];
433
- $updates[$id]['autoupdate'] = $remote_project['autoupdate'];
434
  }
435
  }
436
  }
437
-
438
  //record results
439
- update_site_option('wdp_un_updates_available', $updates);
440
  } else {
441
  return false;
442
  }
@@ -444,249 +632,670 @@ if ( !class_exists('WPMUDEV_Dashboard_Notice3') ) {
444
  }
445
  }
446
  }
447
-
448
- function filter_plugin_info($res, $action, $args) {
449
  global $wp_version;
450
- $cur_wp_version = preg_replace('/-.*$/', '', $wp_version);
451
-
452
- //if in details iframe on update core page short-curcuit it
453
- if ( ($action == 'plugin_information' || $action == 'theme_information') && strpos($args->slug, 'wpmudev_install') !== false ) {
454
- $string = explode('-', $args->slug);
455
- $id = intval($string[1]);
456
- $updates = get_site_option('wdp_un_updates_available');
457
- if ( did_action( 'install_plugins_pre_plugin-information' ) && is_array( $updates ) && isset($updates[$id]) ) {
458
- echo '<iframe width="100%" height="100%" border="0" style="border:none;" src="' . $this->server_url . '?action=details&id=' . $id . '"></iframe>';
459
- exit;
460
  }
461
-
462
- $res = new stdClass;
463
- $res->name = $updates[$id]['name'];
464
- $res->slug = sanitize_title($updates[$id]['name']);
465
- $res->version = $updates[$id]['version'];
466
- $res->rating = 100;
467
- $res->homepage = $updates[$id]['url'];
468
  $res->download_link = '';
469
- $res->tested = $cur_wp_version;
470
-
471
  return $res;
472
  }
473
-
474
- if ( $action == 'plugin_information' && strpos($args->slug, 'install_wpmudev_dash') !== false ) {
475
- $res = new stdClass;
476
- $res->name = 'WPMU DEV Dashboard';
477
- $res->slug = 'wpmu-dev-dashboard';
478
- $res->version = '';
479
- $res->rating = 100;
480
- $res->homepage = 'http://premium.wpmudev.org/project/wpmu-dev-dashboard/';
481
- $res->download_link = $this->server_url . "?action=install_wpmudev_dash";
482
- $res->tested = $cur_wp_version;
483
-
484
  return $res;
485
  }
486
-
487
  return $res;
488
  }
489
-
490
  function filter_plugin_rows() {
491
- if ( !current_user_can( 'update_plugins' ) )
492
  return;
493
-
494
- $updates = get_site_option('wdp_un_updates_available');
495
- if ( is_array($updates) && count($updates) ) {
 
 
 
 
496
  foreach ( $updates as $id => $plugin ) {
497
  if ( $plugin['autoupdate'] != '2' ) {
498
  if ( $plugin['type'] == 'theme' ) {
499
  remove_all_actions( 'after_theme_row_' . $plugin['filename'] );
500
- add_action('after_theme_row_' . $plugin['filename'], array( &$this, 'plugin_row'), 9, 2 );
501
  } else {
502
  remove_all_actions( 'after_plugin_row_' . $plugin['filename'] );
503
- add_action('after_plugin_row_' . $plugin['filename'], array( &$this, 'plugin_row'), 9, 2 );
 
 
 
504
  }
505
  }
506
  }
507
  }
508
-
509
- $local_themes = get_site_option('wdp_un_local_themes');
510
- if ( is_array($local_themes) && count($local_themes) ) {
511
  foreach ( $local_themes as $id => $plugin ) {
512
  remove_all_actions( 'after_theme_row_' . $plugin['filename'] );
513
  //only add the notice if specific version is wrong
514
- if ( isset($updates[$this->theme_pack]) && version_compare($plugin['version'], $updates[$this->theme_pack]['new_version'], '<') ) {
515
- add_action('after_theme_row_' . $plugin['filename'], array( &$this, 'themepack_row'), 9, 2 );
516
  }
517
  }
518
  }
519
  }
520
-
521
  function filter_plugin_count( $value ) {
522
-
 
 
523
  //remove any conflicting slug local WPMU DEV plugins from WP update notifications
524
- $local_projects = get_site_option('wdp_un_local_projects');
525
- if ( is_array($local_projects) && count($local_projects) ) {
526
  foreach ( $local_projects as $id => $plugin ) {
527
- if (isset($value->response[$plugin['filename']]))
528
- unset($value->response[$plugin['filename']]);
 
529
  }
530
  }
531
-
532
- $updates = get_site_option('wdp_un_updates_available');
533
- if ( is_array($updates) && count($updates) ) {
534
  foreach ( $updates as $id => $plugin ) {
535
  if ( $plugin['type'] != 'theme' && $plugin['autoupdate'] != '2' ) {
536
-
537
  //build plugin class
538
- $object = new stdClass;
539
- $object->url = $plugin['url'];
540
- $object->slug = "wpmudev_install-$id";
541
- $object->upgrade_notice = $plugin['changelog'];
542
  $object->new_version = $plugin['new_version'];
543
- $object->package = '';
544
-
 
545
  //add to class
546
- $value->response[$plugin['filename']] = $object;
547
  }
548
  }
549
  }
550
-
551
  return $value;
552
  }
553
-
554
  function filter_theme_count( $value ) {
555
-
556
- $updates = get_site_option('wdp_un_updates_available');
557
- if ( is_array($updates) && count($updates) ) {
558
  foreach ( $updates as $id => $theme ) {
559
  if ( $theme['type'] == 'theme' && $theme['autoupdate'] != '2' ) {
 
 
 
560
  //build theme listing
561
- $value->response[$theme['filename']]['url'] = $this->server_url . '?action=details&id=' . $id;
562
- $value->response[$theme['filename']]['new_version'] = $theme['new_version'];
563
- $value->response[$theme['filename']]['package'] = '';
 
564
  }
565
  }
566
  }
567
-
568
  //filter 133 theme pack themes from the list unless update is available
569
- $local_themes = get_site_option('wdp_un_local_themes');
570
- if ( is_array($local_themes) && count($local_themes) ) {
571
  foreach ( $local_themes as $id => $theme ) {
 
 
572
  //add to count only if new version exists, otherwise remove
573
- if (isset($updates[$theme['id']]) && isset($updates[$theme['id']]['new_version']) && version_compare($theme['version'], $updates[$theme['id']]['new_version'], '<')) {
574
- $value->response[$theme['filename']]['new_version'] = $updates[$theme['id']]['new_version'];
575
- $value->response[$theme['filename']]['package'] = '';
576
- } else if (isset($value) && isset($value->response) && isset($theme['filename']) && isset($value->response[$theme['filename']])) {
577
- unset($value->response[$theme['filename']]);
578
  }
579
  }
580
  }
581
-
582
  return $value;
583
  }
584
-
585
  function plugin_row( $file, $plugin_data ) {
586
-
587
  //get new version and update url
588
- $updates = get_site_option('wdp_un_updates_available');
589
- if ( is_array($updates) && count($updates) ) {
590
  foreach ( $updates as $id => $plugin ) {
591
- if ($plugin['filename'] == $file) {
592
  $project_id = $id;
593
- $version = $plugin['new_version'];
594
  $plugin_url = $plugin['url'];
595
  $autoupdate = $plugin['autoupdate'];
596
- $filename = $plugin['filename'];
597
- $type = $plugin['type'];
598
  break;
599
  }
600
  }
601
  } else {
602
  return false;
603
  }
604
-
605
- $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
606
- $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
607
-
608
- $info_url = $this->server_url . '?action=details&id=' . $project_id . '&TB_iframe=true&width=640&height=800';
609
- if ( file_exists(WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php') ) {
610
- $message = "Activate WPMU DEV Dashboard";
 
 
 
 
 
 
 
611
  $action_url = $this->activate_url();
612
  } else { //dashboard not installed at all
613
- $message = "Install WPMU DEV Dashboard";
614
  $action_url = $this->auto_install_url();
615
  }
616
-
617
- if ( current_user_can('update_plugins') ) {
618
- echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update colspanchange"><div class="update-message wpmu-update-row">';
619
- printf( 'There is a new version of %1$s available on WPMU DEV. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">%6$s</a> to update.', $plugin_name, esc_url($info_url), esc_attr($plugin_name), $version, esc_url($action_url), $message );
620
- echo '</div></td></tr>';
621
  }
622
  }
623
-
624
  function themepack_row( $file, $plugin_data ) {
625
-
626
  //get new version and update url
627
- $updates = get_site_option('wdp_un_updates_available');
628
- if ( isset($updates[$this->theme_pack]) ) {
629
- $plugin = $updates[$this->theme_pack];
630
  $project_id = $this->theme_pack;
631
- $version = $plugin['new_version'];
632
  $plugin_url = $plugin['url'];
633
  } else {
634
  return false;
635
  }
636
-
637
- $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
638
- $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
639
-
640
- $info_url = $this->server_url . '?action=details&id=' . $project_id . '&TB_iframe=true&width=640&height=800';
641
- if ( file_exists(WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php') ) {
642
- $message = "Activate WPMU DEV Dashboard";
 
 
 
 
 
 
 
643
  $action_url = $this->activate_url();
644
  } else { //dashboard not installed at all
645
- $message = "Install WPMU DEV Dashboard";
646
  $action_url = $this->auto_install_url();
647
  }
648
-
649
- if ( current_user_can('update_themes') ) {
650
- echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update colspanchange"><div class="update-message">';
651
- printf( 'There is a new version of %1$s available on WPMU DEV. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">%6$s</a> to update.', $plugin_name, esc_url($info_url), esc_attr($plugin_name), $version, esc_url($action_url), $message );
652
- echo '</div></td></tr>';
653
  }
654
  }
655
-
656
  function disable_checkboxes() {
657
-
658
- $updates = get_site_option('wdp_un_updates_available');
659
- if ( !is_array( $updates ) || ( is_array( $updates ) && !count( $updates ) ) ) {
660
  return;
661
  }
662
-
663
- $jquery = '';
664
- foreach ( (array) $updates as $id => $plugin) {
665
- $jquery .= "<script type='text/javascript'>jQuery(\"input:checkbox[value='".esc_attr($plugin['filename'])."']\").remove();</script>\n";
 
 
 
 
 
 
 
 
 
 
 
 
666
  }
667
-
668
  //disable checkboxes for 133 theme pack themes
669
- $local_themes = get_site_option('wdp_un_local_themes');
670
- if ( is_array($local_themes) && count($local_themes) ) {
671
  foreach ( $local_themes as $id => $theme ) {
672
- $jquery .= "<script type='text/javascript'>jQuery(\"input:checkbox[value='".esc_attr($theme['filename'])."']\").remove();</script>\n";
 
673
  }
674
  }
 
 
 
675
  echo $jquery;
676
  }
677
-
678
- function set_activate_flag($plugin) {
679
  $data = $this->get_id_plugin( WP_PLUGIN_DIR . '/' . $plugin );
680
- if ( isset($data['id']) && !empty($data['id']) ) {
681
- update_site_option('wdp_un_activated_flag', 1);
682
  }
683
  }
684
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
685
  }
686
- $WPMUDEV_Dashboard_Notice3 = new WPMUDEV_Dashboard_Notice3();
 
687
  }
688
 
689
- //disable older version
690
- if ( !class_exists('WPMUDEV_Dashboard_Notice') ) {
691
- class WPMUDEV_Dashboard_Notice {}
 
 
 
 
 
 
692
  }
1
  <?php
2
  /////////////////////////////////////////////////////////////////////////
3
  /* -------- WPMU DEV Dashboard Notice - Aaron Edwards (Incsub) ------- */
4
+ if ( ! class_exists( 'WPMUDEV_Dashboard_Notice4' ) ) {
5
+ class WPMUDEV_Dashboard_Notice4 {
6
+
7
+ var $version = '4.1';
8
  var $screen_id = false;
9
  var $product_name = false;
10
  var $product_update = false;
11
  var $theme_pack = 128;
12
+ var $server_url = 'https://premium.wpmudev.org/api/dashboard/v1/';
13
  var $update_count = 0;
14
+
15
  function __construct() {
16
  add_action( 'init', array( &$this, 'init' ) );
17
+ add_action( 'plugins_loaded', array( &$this, 'remove_older' ), 5 );
18
+ }
19
+
20
+ function remove_older() {
21
+ global $WPMUDEV_Dashboard_Notice3;
22
+
23
+ //remove 3.0 notices
24
+ if ( is_object( $WPMUDEV_Dashboard_Notice3 ) ) {
25
+ remove_action( 'init', array( $WPMUDEV_Dashboard_Notice3, 'init' ) );
26
+ remove_action( 'plugins_loaded', array( $WPMUDEV_Dashboard_Notice3, 'init' ) );
27
+ } else if ( method_exists( 'WPMUDEV_Dashboard_Notice3', 'init' ) ) { //if class is not in global (some projects included inside a method), we have to use a hacky way to remove the filter
28
+ $this->deregister_hook( 'init', 'WPMUDEV_Dashboard_Notice3', 'init', 10 );
29
+ $this->deregister_hook( 'plugins_loaded', 'WPMUDEV_Dashboard_Notice3', 'init', 10 );
30
+ }
31
+
32
+ //remove version 2.0
33
+ if ( method_exists( 'WPMUDEV_Dashboard_Notice', 'init' ) ) {
34
+ $this->deregister_hook( 'init', 'WPMUDEV_Dashboard_Notice', 'init', 10 );
35
+ $this->deregister_hook( 'plugins_loaded', 'WPMUDEV_Dashboard_Notice', 'init', 10 );
36
+ }
37
+
38
+ //remove version 1.0
39
+ remove_action( 'admin_notices', 'wdp_un_check', 5 );
40
+ remove_action( 'network_admin_notices', 'wdp_un_check', 5 );
41
+ }
42
+
43
+ /* Adapted from: https://github.com/herewithme/wp-filters-extras/ - Copyright 2012 Amaury Balmer - amaury@beapi.fr */
44
+ function deregister_hook( $hook_name, $class_name, $method_name, $priority ) {
45
+ global $wp_filter;
46
+
47
+ // Take only filters on right hook name and priority
48
+ if ( ! isset( $wp_filter[ $hook_name ][ $priority ] ) || ! is_array( $wp_filter[ $hook_name ][ $priority ] ) ) {
49
+ return false;
50
+ }
51
+
52
+ // Loop on filters registered
53
+ foreach ( (array) $wp_filter[ $hook_name ][ $priority ] as $unique_id => $filter_array ) {
54
+ // Test if filter is an array ! (always for class/method)
55
+ if ( isset( $filter_array['function'] ) && is_array( $filter_array['function'] ) ) {
56
+ // Test if object is a class, class and method is equal to param !
57
+ if ( is_object( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) && get_class( $filter_array['function'][0] ) == $class_name && $filter_array['function'][1] == $method_name ) {
58
+ unset( $wp_filter[ $hook_name ][ $priority ][ $unique_id ] );
59
+ return true;
60
+ }
61
+ }
62
+ }
63
+
64
+ return false;
65
  }
66
+
67
  function init() {
68
  global $wpmudev_un;
69
+
70
+ if ( class_exists( 'WPMUDEV_Dashboard' ) || ( isset( $wpmudev_un->version ) && version_compare( $wpmudev_un->version, '3.4', '<' ) ) ) {
71
  return;
72
+ }
73
+
74
  // Schedule update cron on main site only
75
  if ( is_main_site() ) {
76
  if ( ! wp_next_scheduled( 'wpmudev_scheduled_jobs' ) ) {
77
  wp_schedule_event( time(), 'twicedaily', 'wpmudev_scheduled_jobs' );
78
  }
79
 
80
+ add_action( 'wpmudev_scheduled_jobs', array( $this, 'updates_check' ) );
81
  }
82
+ add_action( 'delete_site_transient_update_plugins', array(
83
+ &$this,
84
+ 'updates_check'
85
+ ) ); //refresh after upgrade/install
86
+ add_action( 'delete_site_transient_update_themes', array(
87
+ &$this,
88
+ 'updates_check'
89
+ ) ); //refresh after upgrade/install
90
+
91
  if ( is_admin() && current_user_can( 'install_plugins' ) ) {
92
+
93
  add_action( 'site_transient_update_plugins', array( &$this, 'filter_plugin_count' ) );
94
  add_action( 'site_transient_update_themes', array( &$this, 'filter_theme_count' ) );
95
+ add_filter( 'plugins_api', array(
96
+ &$this,
97
+ 'filter_plugin_info'
98
+ ), 101, 3 ); //run later to work with bad autoupdate plugins
99
+ add_filter( 'themes_api', array(
100
+ &$this,
101
+ 'filter_plugin_info'
102
+ ), 101, 3 ); //run later to work with bad autoupdate plugins
103
+ add_action( 'load-plugins.php', array( &$this, 'filter_plugin_rows' ), 21 ); //make sure it runs after WP's
104
+ add_action( 'load-themes.php', array( &$this, 'filter_plugin_rows' ), 21 ); //make sure it runs after WP's
105
  add_action( 'core_upgrade_preamble', array( &$this, 'disable_checkboxes' ) );
106
  add_action( 'activated_plugin', array( &$this, 'set_activate_flag' ) );
107
+ add_action( 'wp_ajax_wdpun-changelog', array( &$this, 'popup_changelog_ajax' ) );
108
+ add_action( 'wp_ajax_wdpun-dismiss', array( &$this, 'dismiss_ajax' ) );
109
+
 
 
 
 
110
  //if dashboard is installed but not activated
111
+ if ( file_exists( WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php' ) ) {
112
+ if ( ! get_site_option( 'wdp_un_autoactivated' ) ) {
113
  //include plugin API if necessary
114
+ if ( ! function_exists( 'activate_plugin' ) ) {
115
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
116
+ }
117
+ $result = activate_plugin( '/wpmudev-updates/update-notifications.php', network_admin_url( 'admin.php?page=wpmudev' ), is_multisite() );
118
+ if ( ! is_wp_error( $result ) ) { //if autoactivate successful don't show notices
119
+ update_site_option( 'wdp_un_autoactivated', 1 );
120
+
121
  return;
122
  }
123
  }
124
+
125
  add_action( 'admin_print_styles', array( &$this, 'notice_styles' ) );
126
+ add_action( 'admin_print_footer_scripts', array( &$this, 'notice_scripts' ) );
127
  add_action( 'all_admin_notices', array( &$this, 'activate_notice' ), 5 );
128
  } else { //dashboard not installed at all
129
+ if ( get_site_option( 'wdp_un_autoactivated' ) ) {
130
+ update_site_option( 'wdp_un_autoactivated', 0 );//reset flag when dashboard is deleted
131
  }
132
  add_action( 'admin_print_styles', array( &$this, 'notice_styles' ) );
133
+ add_action( 'admin_print_footer_scripts', array( &$this, 'notice_scripts' ) );
134
  add_action( 'all_admin_notices', array( &$this, 'install_notice' ), 5 );
135
  }
136
  }
137
  }
138
+
139
  function is_allowed_screen() {
140
  global $wpmudev_notices;
141
+ $screen = get_current_screen();
142
+ if ($screen && is_object($screen)) $this->screen_id = $screen->id;
143
+
144
  //Show special message right after plugin activation
145
+ if ( in_array( $this->screen_id, array(
146
+ 'plugins',
147
+ 'plugins-network'
148
+ ) ) && ( isset( $_GET['activate'] ) || isset( $_GET['activate-multi'] ) )
149
+ ) {
150
+ $activated = get_site_option( 'wdp_un_activated_flag' );
151
+ if ( $activated === false ) {
152
+ $activated = 1;
153
+ } //on first encounter of new installed notice show
154
+ if ( $activated ) {
155
+ if ( $activated >= 2 ) {
156
+ update_site_option( 'wdp_un_activated_flag', 0 );
157
+ } else {
158
+ update_site_option( 'wdp_un_activated_flag', 2 );
159
+ }
160
+
161
  return true;
162
  }
163
  }
164
+
165
+ //check dismiss flag
166
+ $dismissed = get_site_option( 'wdp_un_dismissed' );
167
+ if ( $dismissed && $dismissed > strtotime( '-1 week' ) ) {
168
+ return false;
169
+ }
170
+
171
  //always show on certain core pages if updates are available
172
+ $updates = get_site_option( 'wdp_un_updates_available' );
173
+ if ( is_array( $updates ) && count( $updates ) ) {
174
+ $this->update_count = count( $updates );
175
+ if ( in_array( $this->screen_id, array(
176
+ 'update-core',
177
+ 'update-core-network'
178
+ ) ) ) {
179
  return true;
180
+ }
181
  }
182
+
183
  //check our registered plugins for hooks
184
+ if ( isset( $wpmudev_notices ) && is_array( $wpmudev_notices ) ) {
185
  foreach ( $wpmudev_notices as $product ) {
186
+ if ( isset( $product['screens'] ) && is_array( $product['screens'] ) && in_array( $this->screen_id, $product['screens'] ) ) {
187
  $this->product_name = $product['name'];
188
  //if this plugin needs updating flag it
189
+ if ( isset( $product['id'] ) && isset( $updates[ $product['id'] ] ) ) {
190
  $this->product_update = true;
191
+ }
192
+
193
  return true;
194
  }
195
  }
196
  }
197
+
 
 
198
  return false;
199
  }
200
+
201
  function auto_install_url() {
202
  $function = is_multisite() ? 'network_admin_url' : 'admin_url';
203
+
204
+ return wp_nonce_url( $function( "update.php?action=install-plugin&plugin=install_wpmudev_dash" ), "install-plugin_install_wpmudev_dash" );
205
  }
206
+
207
  function activate_url() {
208
  $function = is_multisite() ? 'network_admin_url' : 'admin_url';
209
+
210
+ return wp_nonce_url( $function( 'plugins.php?action=activate&plugin=wpmudev-updates%2Fupdate-notifications.php' ), 'activate-plugin_wpmudev-updates/update-notifications.php' );
211
  }
212
+
213
  function install_notice() {
214
+ if ( ! $this->is_allowed_screen() ) return; ?>
215
 
216
+ <div class="notice wdpun-notice" style="display: none;">
217
+
218
+ <input type="hidden" name="msg_id" value="<?php _e( 'install', 'wpmudev' ); ?>" />
219
+
220
+ <div class="wdpun-notice-logo"></div>
221
+ <div class="wdpun-notice-message">
222
+ <?php
223
+ if ( $this->product_name ) {
224
+ if ( $this->product_update ) {
225
+ printf( __( 'Important updates are available for <strong>%s</strong>. Install the free WPMU DEV Dashboard plugin now for updates and support!', 'wpmudev' ), esc_html( $this->product_name ) );
226
+ } else {
227
+ printf( __( '<strong>%s</strong> is almost ready - install the free WPMU DEV Dashboard plugin for updates and support!', 'wpmudev' ), esc_html( $this->product_name ) );
228
+ }
229
+
230
+ } else if ( $this->update_count ) {
231
+ _e( 'Important updates are available for your WPMU DEV plugins/themes. Install the free WPMU DEV Dashboard plugin now for updates and support!', 'wpmudev' );
232
+ } else {
233
+ _e( 'Almost ready - install the free WPMU DEV Dashboard plugin for updates and support!', 'wpmudev' );
234
+ }
235
+ ?>
236
+ </div><!-- end wdpun-notice-message -->
237
+ <div class="wdpun-notice-cta">
238
+ <a href="<?php echo $this->auto_install_url(); ?>"
239
+ class="wdpun-button wdpun-button-small"><?php _e( 'Install Plugin', 'wpmudev' ); ?></a>
240
+
241
+ <button class="wdpun-button wdpun-button-notice-dismiss"
242
+ data-msg="<?php _e( 'Saving...', 'wpmudev' ); ?>">
243
+ <?php _e( 'Dismiss', 'wpmudev' ); ?>
244
+ </button>
245
+ </div><!-- end wdpun-notice-cta -->
246
+
247
+ </div><!-- end notice wdpun-notice -->
248
+
249
+ <?php
250
+
251
+ return;
252
  }
253
+
254
  function activate_notice() {
255
+ if ( ! $this->is_allowed_screen() ) return; ?>
256
+
257
+ <div class="notice wdpun-notice" style="display: none;">
258
+
259
+ <input type="hidden" name="msg_id" value="<?php _e( 'activate', 'wpmudev' ); ?>" />
260
+
261
+ <div class="wdpun-notice-logo"><span></span></div>
262
+ <div class="wdpun-notice-message">
263
+ <?php
264
+ if ( $this->product_name ) {
265
+ if ( $this->product_update ) {
266
+ printf( __( 'Important updates are available for <strong>%s</strong>. Activate the WPMU DEV Dashboard to update now!', 'wpmudev' ), esc_html( $this->product_name ) );
267
+ } else {
268
+ printf( __( 'Just one more step to enable updates and support for <strong>%s</strong>!', 'wpmudev' ), esc_html( $this->product_name ) );
269
+ }
270
+
271
+ } else if ( $this->update_count ) {
272
+ _e( 'Important updates are available for your WPMU DEV plugins/themes. Activate the WPMU DEV Dashboard to update now!', 'wpmudev' );
273
+ } else {
274
+ _e( "Just one more step - activate the WPMU DEV Dashboard plugin and you're all done!", 'wpmudev' );
275
+ }
276
+ ?>
277
+ </div><!-- end wdpun-notice-message -->
278
+ <div class="wdpun-notice-cta">
279
+ <a href="<?php echo $this->activate_url(); ?>"
280
+ class="wdpun-button wdpun-button-small"><?php _e( 'Activate WPMU DEV Dashboard', 'wpmudev' ); ?></a>
281
+
282
+ <button class="wdpun-button wdpun-button-notice-dismiss"
283
+ data-msg="<?php _e( 'Saving...', 'wpmudev' ); ?>">
284
+ <?php _e( 'Dismiss', 'wpmudev' ); ?>
285
+ </button>
286
+ </div><!-- end wdpun-notice-cta -->
287
+
288
+ </div><!-- end notice wdpun-notice -->
289
+
290
+ <?php
291
+
292
+ return;
293
  }
294
+
295
  function notice_styles() {
296
  if ( !$this->is_allowed_screen() ) return;
297
  ?>
298
+ <style type="text/css" media="all">
299
+ .cf:after{content:"";display:table;clear:both}@media only screen and (min-width: 1200px){.hide-to-large{display:none}}@media only screen and (min-width: 1140px){.hide-to-desktop{display:none}}.wrap>.wdpun-notice.notice,.wrap #header>.wdpun-notice.notice{width:100%}.wrap #header>.wdpun-notice.notice{box-shadow:none}.wdpun-notice *,.wdpun-notice *:after,.wdpun-notice *:before{box-sizing:border-box}.wdpun-notice.notice{background:#fff;border:1px solid #E5E5E5;border-radius:6px;box-shadow:0 1px 1px 0 rgba(0,0,0,0.05);clear:both;display:block;font:400 13px/20px "Open Sans",Arial,sans-serif;overflow:hidden;margin:10px 20px 20px 0;min-height:80px;padding:0;position:relative;text-align:center;z-index:1}.wdpun-notice.notice.loading:before{background-color:rgba(255,255,255,0.7);bottom:0;content:attr(data-message);font-size:22px;font-weight:600;left:0;line-height:80px;position:absolute;right:0;text-align:center;top:0;z-index:5}.wdpun-notice.notice.loading>div{-webkit-filter:blur(2px);filter:blur(2px)}.wdpun-notice-logo{background-color:transparent;background-image:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjU2cHgiIGhlaWdodD0iNTZweCIgdmlld0JveD0iMCAwIDU2IDU2IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPCEtLSBHZW5lcmF0b3I6IFNrZXRjaCAzLjguMyAoMjk4MDIpIC0gaHR0cDovL3d3dy5ib2hlbWlhbmNvZGluZy5jb20vc2tldGNoIC0tPgogICAgPHRpdGxlPndwbXVkZXYtc3ZnPC90aXRsZT4KICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPgogICAgPGRlZnM+PC9kZWZzPgogICAgPGcgaWQ9IlBhZ2UtMSIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgaWQ9ImlQYWQtUHJvLUxhbmRzY2FwZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTIzLjAwMDAwMCwgLTIyLjAwMDAwMCkiPgogICAgICAgICAgICA8ZyBpZD0id3BtdWRldi1zdmciIHRyYW5zZm9ybT0idHJhbnNsYXRlKDIzLjAwMDAwMCwgMjIuMDAwMDAwKSI+CiAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMjgsNTYgQzEyLjUzNTg3MSw1NiAwLDQzLjQ2NDEyOSAwLDI4IEMwLDEyLjUzNjc3NDIgMTIuNTM1ODcxLDAgMjgsMCBDNDMuNDY0MTI5LDAgNTYsMTIuNTM2Nzc0MiA1NiwyOCBDNTYsNDMuNDY0MTI5IDQzLjQ2NDEyOSw1NiAyOCw1NiBMMjgsNTYgWiIgaWQ9IkZpbGwtMSIgZmlsbD0iI0ZGRDAwNSI+PC9wYXRoPgogICAgICAgICAgICAgICAgPHBhdGggZD0iTTUxLjQ4Mzg3MSwyOCBDNTEuNDgzODcxLDQwLjk2OTQxOTQgNDAuOTY5NDE5NCw1MS40ODM4NzEgMjgsNTEuNDgzODcxIEMxNS4wMzA1ODA2LDUxLjQ4Mzg3MSA0LjUxNjEyOTAzLDQwLjk2OTQxOTQgNC41MTYxMjkwMywyOCBDNC41MTYxMjkwMywxNS4wMzA1ODA2IDE1LjAzMDU4MDYsNC41MTYxMjkwMyAyOCw0LjUxNjEyOTAzIEM0MC45Njk0MTk0LDQuNTE2MTI5MDMgNTEuNDgzODcxLDE1LjAzMDU4MDYgNTEuNDgzODcxLDI4IiBpZD0iRmlsbC0zIiBmaWxsPSIjMzMzMzMzIj48L3BhdGg+CiAgICAgICAgICAgICAgICA8cGF0aCBkPSJNNDIuNzc4ODUxNiwzMi42NzY2MzIzIEw0Mi43Nzg4NTE2LDEyLjUzMTA4MzkgTDM5LjUzMDg1MTYsMTUuMDU4MzA5NyBMMzkuNTMwODUxNiwzMi42NzY2MzIzIEwzOS41MjcyMzg3LDMyLjY3NjYzMjMgQzM5LjUyNzIzODcsMzMuNzA4MTE2MSAzOC43ODI5ODA2LDM0LjU0NDUwMzIgMzcuODY2MjA2NSwzNC41NDQ1MDMyIEMzNi45NDY3MjI2LDM0LjU0NDUwMzIgMzYuMjAyNDY0NSwzMy43MDgxMTYxIDM2LjIwMjQ2NDUsMzIuNjc2NjMyMyBMMzYuMjA3ODgzOSwyMy4zMjM3MjkgQzM2LjIwNzg4MzksMjAuMjc0NDM4NyAzNC4wMDU4MTk0LDE3LjgwMTQwNjUgMzEuMjkwNzIyNiwxNy44MDE0MDY1IEMyOC41NzM4MTk0LDE3LjgwMTQwNjUgMjYuMzcyNjU4MSwyMC4yNzQ0Mzg3IDI2LjM3MjY1ODEsMjMuMzIzNzI5IEwyNi4zNzI2NTgxLDMyLjY3NjYzMjMgQzI2LjM3MjY1ODEsMzMuNzA4MTE2MSAyNS42Mjg0LDM0LjU0NDUwMzIgMjQuNzA4OTE2MSwzNC41NDQ1MDMyIEMyMy43OTIxNDE5LDM0LjU0NDUwMzIgMjMuMDQ1MTc0MiwzMy43MDgxMTYxIDIzLjA0NTE3NDIsMzIuNjc2NjMyMyBMMjMuMDUyNCwyMy4zMjM3MjkgQzIzLjA1MjQsMjAuMjc0NDM4NyAyMC44NTEyMzg3LDE3LjgwMTQwNjUgMTguMTM2MTQxOSwxNy44MDE0MDY1IEMxNS40MjEwNDUyLDE3LjgwMTQwNjUgMTMuMjE4OTgwNiwyMC4yNzQ0Mzg3IDEzLjIxODk4MDYsMjMuMzIzNzI5IEwxMy4yMjA3ODcxLDIzLjMyMzcyOSBMMTMuMjIwNzg3MSw0My40NjkyNzc0IEwxNi40Njg3ODcxLDQwLjk0MTE0ODQgTDE2LjQ3MjQsMjMuMzIzNzI5IEMxNi40NzI0LDIyLjI5MjI0NTIgMTcuMjE2NjU4MSwyMS40NTU4NTgxIDE4LjEzNjE0MTksMjEuNDU1ODU4MSBDMTkuMDU0NzIyNiwyMS40NTU4NTgxIDE5Ljc5OTg4MzksMjIuMjkyMjQ1MiAxOS43OTk4ODM5LDIzLjMyMzcyOSBMMTkuNzkyNjU4MSwzMi42NzY2MzIzIEMxOS43OTI2NTgxLDM1LjcyNTkyMjYgMjEuOTkzODE5NCwzOC4xOTg5NTQ4IDI0LjcwODkxNjEsMzguMTk4OTU0OCBDMjcuNDI0MDEyOSwzOC4xOTg5NTQ4IDI5LjYyNTE3NDIsMzUuNzI1OTIyNiAyOS42MjUxNzQyLDMyLjY3NjYzMjMgTDI5LjYyNDI3MSwzMi42NzY2MzIzIEwyOS42MjY5ODA2LDIzLjMyMzcyOSBDMjkuNjI2OTgwNiwyMi4yOTIyNDUyIDMwLjM3MjE0MTksMjEuNDU1ODU4MSAzMS4yOTA3MjI2LDIxLjQ1NTg1ODEgQzMyLjIwODQsMjEuNDU1ODU4MSAzMi45NTI2NTgxLDIyLjI5MjI0NTIgMzIuOTUyNjU4MSwyMy4zMjM3MjkgTDMyLjk0NzIzODcsMzIuNjc2NjMyMyBDMzIuOTQ3MjM4NywzNS43MjU5MjI2IDM1LjE0OTMwMzIsMzguMTk4OTU0OCAzNy44NjYyMDY1LDM4LjE5ODk1NDggQzQwLjU4MDQsMzguMTk4OTU0OCA0Mi43ODA2NTgxLDM1LjcyNTkyMjYgNDIuNzgwNjU4MSwzMi42NzY2MzIzIEw0Mi43Nzg4NTE2LDMyLjY3NjYzMjMgTDQyLjc3ODg1MTYsMzIuNjc2NjMyMyBaIiBpZD0iRmlsbC01IiBmaWxsPSIjRjlFQzFDIj48L3BhdGg+CiAgICAgICAgICAgIDwvZz4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPg==);background-repeat:no-repeat;background-position:50% 50%;display:block;height:56px;margin:10px auto 0;width:56px}.wdpun-notice .wdpun-notice-message{color:#23282D;display:block;font-family:"Open Sans",Arial,sans-serif;font-size:13px;line-height:20px;padding:10px}.wdpun-notice .wdpun-notice-message strong{font-weight:600}.wdpun-notice .wdpun-button{background:#00ACCA;border:1px solid #0087B9;border-radius:2px;color:#fff;cursor:pointer;display:block;font-weight:500;font-size:16px;height:auto;line-height:18px;margin:0;padding:10px 20px;text-decoration:none;-webkit-transition:color 0.3s, opacity 0.3s, background 0.3s;transition:color 0.3s, opacity 0.3s, background 0.3s;white-space:nowrap}.wdpun-notice .wdpun-button:hover:not(:focus):not(:active){background-color:#0093B1;color:#fff}.wdpun-notice .wdpun-button:focus,.wdpun-notice .wdpun-button:active{background:#0082a1;background:-webkit-linear-gradient(top, #0082a1 0%, #008fae 100%);background:linear-gradient(to bottom, #0082a1 0%, #008fae 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#0082a1', endColorstr='#008fae',GradientType=0 );border-color:transparent;color:#fff;outline-color:transparent;outline-style:none}.wdpun-notice .wdpun-button-small{padding:5px 15px}.wdpun-notice .wdpun-button-notice-dismiss{background:transparent;border:none;border-radius:0;color:#C5C5C5;padding:0;text-transform:none;-webkit-transition:color 0.3s;transition:color 0.3s}.wdpun-notice .wdpun-button-notice-dismiss:hover:not(:focus):not(:active),.wdpun-notice .wdpun-button-notice-dismiss:active,.wdpun-notice .wdpun-button-notice-dismiss:focus{background:transparent;color:#666}.wdpun-notice .wdpun-notice-cta{border-top:1px solid #E5E5E5;background:#F8F8F8;clear:both;display:block;padding:15px 20px;position:relative;text-align:center;white-space:nowrap}.wdpun-notice .wdpun-notice-cta .wdpun-button{vertical-align:middle}.wdpun-notice .wdpun-notice-cta .wdpun-button-notice-dismiss{margin:10px auto 0}.wdpun-notice .wdpun-notice-cta input[type="email"]{line-height:20px;margin:0;max-width:320px;min-width:50px;padding-right:0;padding-left:0;text-align:center;vertical-align:middle}@media only screen and (min-width: 601px){.wdpun-notice.notice{text-align:left}.wdpun-notice-logo{float:left;margin:10px}.wdpun-notice .wdpun-notice-message{margin-top:5px;margin-left:76px;padding:10px 20px 10px 10px}.wdpun-notice .wdpun-button{display:inline-block;font-size:14px}}@media only screen and (min-width: 783px){.wdpun-notice .wdpun-notice-cta .wdpun-button-notice-dismiss{margin-top:0}.wdpun-notice button+button,.wdpun-notice .wdpun-button+button,.wdpun-notice button+.wdpun-button,.wdpun-notice .wdpun-button+.wdpun-button,.wdpun-notice a+button,.wdpun-notice a+.wdpun-button{margin-left:10px}}@media only screen and (min-width: 961px){.wdpun-notice.notice{display:table}.wdpun-notice-logo{border-radius:0;height:auto;margin:0;min-height:80px;min-width:80px;width:5%}.wdpun-notice .wdpun-notice-logo,.wdpun-notice .wdpun-notice-message,.wdpun-notice .wdpun-notice-cta{cursor:default;display:table-cell;float:none;vertical-align:middle}.wdpun-notice .wdpun-notice-message{margin-top:0;max-width:100%;min-height:80px;width:75%}.wdpun-notice .wdpun-notice-cta{border-left:1px solid #E5E5E5;border-top:none;padding:0 30px;width:20%}}@media only screen and (min-width: 1140px){.wdpun-notice .wdpun-button{font-size:13px}}
300
+ </style>
301
+ <?php
302
+ }
303
+
304
+ function notice_scripts() {
305
+ if ( !$this->is_allowed_screen() ) return;
306
+ ?>
307
+ <script type="text/javascript">
308
+ !function($){function n(){function n(){a.fadeIn(500)}function i(){a.fadeTo(100,0,function(){a.slideUp(100,function(){a.remove()})})}function t(n,t){"0"!==e?(a.attr("data-message",t),a.addClass("saving"),s.action=n,jQuery.post(window.ajaxurl,s,i)):i()}var a=jQuery(".wdpun-notice"),e=a.find("input[name=msg_id]").val(),o=a.find(".wdpun-button-notice-dismiss"),s={};s.msg_id=e,o.click(function(n){n.preventDefault(),t("wdpun-dismiss",o.data("msg"))}),window.setTimeout(n,500)}$(n)}(jQuery);
309
+ </script>
 
 
 
310
  <?php
311
  }
312
+
313
+ function get_id_plugin( $plugin_file ) {
314
+ return get_file_data( $plugin_file, array(
315
+ 'name' => 'Plugin Name',
316
+ 'id' => 'WDP ID',
317
+ 'version' => 'Version'
318
+ ) );
319
  }
320
+
321
  //simple check for updates
322
  function updates_check() {
323
  global $wp_version;
324
  $local_projects = array();
325
+
326
  //----------------------------------------------------------------------------------//
327
  //plugins directory
328
  //----------------------------------------------------------------------------------//
329
  $plugins_root = WP_PLUGIN_DIR;
330
+ if ( empty( $plugins_root ) ) {
331
  $plugins_root = ABSPATH . 'wp-content/plugins';
332
  }
333
+
334
+ $plugins_dir = @opendir( $plugins_root );
335
  $plugin_files = array();
336
  if ( $plugins_dir ) {
337
+ while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
338
+ if ( substr( $file, 0, 1 ) == '.' ) {
339
  continue;
340
+ }
341
+ if ( is_dir( $plugins_root . '/' . $file ) ) {
342
+ $plugins_subdir = @ opendir( $plugins_root . '/' . $file );
343
  if ( $plugins_subdir ) {
344
+ while ( ( $subfile = readdir( $plugins_subdir ) ) !== false ) {
345
+ if ( substr( $subfile, 0, 1 ) == '.' ) {
346
  continue;
347
+ }
348
+ if ( substr( $subfile, - 4 ) == '.php' ) {
349
  $plugin_files[] = "$file/$subfile";
350
+ }
351
  }
352
  }
353
  } else {
354
+ if ( substr( $file, - 4 ) == '.php' ) {
355
  $plugin_files[] = $file;
356
+ }
357
  }
358
  }
359
  }
360
  @closedir( $plugins_dir );
361
  @closedir( $plugins_subdir );
362
+
363
+ if ( $plugins_dir && ! empty( $plugin_files ) ) {
364
  foreach ( $plugin_files as $plugin_file ) {
365
  if ( is_readable( "$plugins_root/$plugin_file" ) ) {
366
+
367
+ unset( $data );
368
  $data = $this->get_id_plugin( "$plugins_root/$plugin_file" );
369
+
370
+ if ( isset( $data['id'] ) && ! empty( $data['id'] ) ) {
371
+ $local_projects[ $data['id'] ]['type'] = 'plugin';
372
+ $local_projects[ $data['id'] ]['version'] = $data['version'];
373
+ $local_projects[ $data['id'] ]['filename'] = $plugin_file;
374
  }
375
  }
376
  }
377
  }
378
+
379
  //----------------------------------------------------------------------------------//
380
  // mu-plugins directory
381
  //----------------------------------------------------------------------------------//
382
  $mu_plugins_root = WPMU_PLUGIN_DIR;
383
+ if ( empty( $mu_plugins_root ) ) {
384
  $mu_plugins_root = ABSPATH . 'wp-content/mu-plugins';
385
  }
386
+
387
+ if ( is_dir( $mu_plugins_root ) && $mu_plugins_dir = @opendir( $mu_plugins_root ) ) {
388
+ while ( ( $file = readdir( $mu_plugins_dir ) ) !== false ) {
389
+ if ( substr( $file, - 4 ) == '.php' ) {
390
  if ( is_readable( "$mu_plugins_root/$file" ) ) {
391
+
392
+ unset( $data );
393
  $data = $this->get_id_plugin( "$mu_plugins_root/$file" );
394
+
395
+ if ( isset( $data['id'] ) && ! empty( $data['id'] ) ) {
396
+ $local_projects[ $data['id'] ]['type'] = 'mu-plugin';
397
+ $local_projects[ $data['id'] ]['version'] = $data['version'];
398
+ $local_projects[ $data['id'] ]['filename'] = $file;
399
  }
400
  }
401
  }
402
  }
403
+ @closedir( $mu_plugins_dir );
404
  }
405
+
406
  //----------------------------------------------------------------------------------//
407
  // wp-content directory
408
  //----------------------------------------------------------------------------------//
409
  $content_plugins_root = WP_CONTENT_DIR;
410
+ if ( empty( $content_plugins_root ) ) {
411
  $content_plugins_root = ABSPATH . 'wp-content';
412
  }
413
+
414
+ $content_plugins_dir = @opendir( $content_plugins_root );
415
  $content_plugin_files = array();
416
  if ( $content_plugins_dir ) {
417
+ while ( ( $file = readdir( $content_plugins_dir ) ) !== false ) {
418
+ if ( substr( $file, 0, 1 ) == '.' ) {
419
  continue;
420
+ }
421
+ if ( ! is_dir( $content_plugins_root . '/' . $file ) ) {
422
+ if ( substr( $file, - 4 ) == '.php' ) {
423
  $content_plugin_files[] = $file;
424
+ }
425
  }
426
  }
427
  }
428
  @closedir( $content_plugins_dir );
429
+
430
+ if ( $content_plugins_dir && ! empty( $content_plugin_files ) ) {
431
  foreach ( $content_plugin_files as $content_plugin_file ) {
432
  if ( is_readable( "$content_plugins_root/$content_plugin_file" ) ) {
433
+ unset( $data );
434
  $data = $this->get_id_plugin( "$content_plugins_root/$content_plugin_file" );
435
+
436
+ if ( isset( $data['id'] ) && ! empty( $data['id'] ) ) {
437
+ $local_projects[ $data['id'] ]['type'] = 'drop-in';
438
+ $local_projects[ $data['id'] ]['version'] = $data['version'];
439
+ $local_projects[ $data['id'] ]['filename'] = $content_plugin_file;
440
  }
441
  }
442
  }
443
  }
444
+
445
  //----------------------------------------------------------------------------------//
446
  //themes directory
447
  //----------------------------------------------------------------------------------//
448
  $themes_root = WP_CONTENT_DIR . '/themes';
449
+ if ( empty( $themes_root ) ) {
450
  $themes_root = ABSPATH . 'wp-content/themes';
451
  }
452
+
453
+ $themes_dir = @opendir( $themes_root );
454
  $themes_files = array();
455
  $local_themes = array();
456
  if ( $themes_dir ) {
457
+ while ( ( $file = readdir( $themes_dir ) ) !== false ) {
458
+ if ( substr( $file, 0, 1 ) == '.' ) {
459
  continue;
460
+ }
461
+ if ( is_dir( $themes_root . '/' . $file ) ) {
462
+ $themes_subdir = @ opendir( $themes_root . '/' . $file );
463
  if ( $themes_subdir ) {
464
+ while ( ( $subfile = readdir( $themes_subdir ) ) !== false ) {
465
+ if ( substr( $subfile, 0, 1 ) == '.' ) {
466
  continue;
467
+ }
468
+ if ( substr( $subfile, - 4 ) == '.css' ) {
469
  $themes_files[] = "$file/$subfile";
470
+ }
471
  }
472
  }
473
  } else {
474
+ if ( substr( $file, - 4 ) == '.css' ) {
475
  $themes_files[] = $file;
476
+ }
477
  }
478
  }
479
  }
480
  @closedir( $themes_dir );
481
  @closedir( $themes_subdir );
482
+
483
+ if ( $themes_dir && ! empty( $themes_files ) ) {
484
  foreach ( $themes_files as $themes_file ) {
485
+
486
  //skip child themes
487
+ if ( strpos( $themes_file, '-child' ) !== false ) {
488
  continue;
489
+ }
490
+
491
  if ( is_readable( "$themes_root/$themes_file" ) ) {
492
+
493
+ unset( $data );
494
  $data = $this->get_id_plugin( "$themes_root/$themes_file" );
495
+
496
+ if ( isset( $data['id'] ) && ! empty( $data['id'] ) ) {
497
+ $local_projects[ $data['id'] ]['type'] = 'theme';
498
+ $local_projects[ $data['id'] ]['filename'] = substr( $themes_file, 0, strpos( $themes_file, '/' ) );
499
+
500
  //keep record of all themes for 133 themepack
501
+ if ( $data['id'] == $this->theme_pack ) {
502
+ $local_themes[ $themes_file ]['id'] = $data['id'];
503
+ $local_themes[ $themes_file ]['filename'] = substr( $themes_file, 0, strpos( $themes_file, '/' ) );
504
+ $local_themes[ $themes_file ]['version'] = $data['version'];
505
  //increment 133 theme pack version to lowest in all of them
506
+ if ( isset( $local_projects[ $data['id'] ]['version'] ) && version_compare( $data['version'], $local_projects[ $data['id'] ]['version'], '<' ) ) {
507
+ $local_projects[ $data['id'] ]['version'] = $data['version'];
508
+ } else if ( ! isset( $local_projects[ $data['id'] ]['version'] ) ) {
509
+ $local_projects[ $data['id'] ]['version'] = $data['version'];
510
  }
511
  } else {
512
+ $local_projects[ $data['id'] ]['version'] = $data['version'];
513
  }
514
  }
515
  }
516
  }
517
  }
518
+ update_site_option( 'wdp_un_local_themes', $local_themes );
519
+
520
+ update_site_option( 'wdp_un_local_projects', $local_projects );
521
+
522
  //now check the API
523
+
524
+ $projects = array();
525
+ $theme = wp_get_theme();
526
+ $ms_allowed = $theme->get_allowed();
527
+ foreach ( $local_projects as $pid => $item ) {
528
+ if ( ! empty( $blog_projects[ $pid ] ) ) { //not yet implemented
529
+ // This project is activated on a blog!
530
+ $active = true;
531
+ } else {
532
+ if ( is_multisite() ) {
533
+ if ( 'theme' == $item['type'] ) {
534
+ // If the theme is available on main site it's "active".
535
+ $slug = $item['filename'];
536
+ $active = ! empty( $ms_allowed[ $slug ] );
537
+ } else {
538
+ $active = is_plugin_active_for_network( $item['filename'] );
539
+ }
540
+ } else {
541
+ if ( 'theme' == $item['type'] ) {
542
+ $slug = $item['filename'];
543
+ $active = ( $theme->stylesheet == $slug || $theme->template == $slug );
544
+ } else {
545
+ $active = is_plugin_active( $item['filename'] );
546
+ }
547
+ }
548
+ }
549
+ $extra = '';
550
+
551
+ /**
552
+ * Collect extra data from individual plugins.
553
+ *
554
+ * @since 4.0.0
555
+ * @api wpmudev_api_project_extra_data-$pid
556
+ *
557
+ * @param string $extra Default extra data is an empty string.
558
+ */
559
+ $extra = apply_filters( "wpmudev_api_project_extra_data-$pid", $extra );
560
+ $extra = apply_filters( 'wpmudev_api_project_extra_data', $extra, $pid );
561
+
562
+ $projects[ $pid ] = array(
563
+ 'version' => $item['version'],
564
+ 'active' => $active ? true : false,
565
+ 'extra' => $extra,
566
+ );
567
+ }
568
+
569
  //get WP/BP version string to help with support
570
+ $wp_ver = is_multisite() ? "WordPress Multisite $wp_version" : "WordPress $wp_version";
571
+ if ( defined( 'BP_VERSION' ) ) {
572
+ $wp_ver .= ', BuddyPress ' . BP_VERSION;
573
+ }
574
+
575
  //add blog count if multisite
576
  $blog_count = is_multisite() ? get_blog_count() : 1;
577
+
578
+ $url = $this->server_url . 'updates';
579
+
580
  $options = array(
581
+ 'timeout' => 15,
582
+ 'sslverify' => false, // Many hosts have no updated CA bundle.
583
  'user-agent' => 'Dashboard Notification/' . $this->version
584
  );
585
+
586
+ $options['body'] = array(
587
+ 'blog_count' => $blog_count,
588
+ 'wp_version' => $wp_ver,
589
+ 'projects' => json_encode( $projects ),
590
+ 'domain' => network_site_url(),
591
+ 'admin_url' => network_admin_url(),
592
+ 'home_url' => network_home_url(),
593
+ );
594
+
595
+ $response = wp_remote_post( $url, $options );
596
+ if ( wp_remote_retrieve_response_code( $response ) == 200 ) {
597
  $data = $response['body'];
598
  if ( $data != 'error' ) {
599
+ $data = json_decode( $data, true );
600
+ if ( is_array( $data ) ) {
601
+
602
  //we've made it here with no errors, now check for available updates
603
+ $remote_projects = isset( $data['projects'] ) ? $data['projects'] : array();
604
+ $updates = array();
605
+
606
  //check for updates
607
+ if ( is_array( $remote_projects ) ) {
608
  foreach ( $remote_projects as $id => $remote_project ) {
609
+ if ( isset( $local_projects[ $id ] ) && is_array( $local_projects[ $id ] ) ) {
610
  //match
611
+ $local_version = $local_projects[ $id ]['version'];
612
  $remote_version = $remote_project['version'];
613
+
614
+ if ( version_compare( $remote_version, $local_version, '>' ) ) {
615
  //add to array
616
+ $updates[ $id ] = $local_projects[ $id ];
617
+ $updates[ $id ]['url'] = $remote_project['url'];
618
+ $updates[ $id ]['name'] = $remote_project['name'];
619
+ $updates[ $id ]['version'] = $local_version;
620
+ $updates[ $id ]['new_version'] = $remote_version;
621
+ $updates[ $id ]['autoupdate'] = $remote_project['autoupdate'];
 
 
 
 
622
  }
623
  }
624
  }
625
+
626
  //record results
627
+ update_site_option( 'wdp_un_updates_available', $updates );
628
  } else {
629
  return false;
630
  }
632
  }
633
  }
634
  }
635
+
636
+ function filter_plugin_info( $res, $action, $args ) {
637
  global $wp_version;
638
+ $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version );
639
+
640
+ if ( ( $action == 'plugin_information' || $action == 'theme_information' ) && strpos( $args->slug, 'wpmudev_install' ) !== false ) {
641
+ $string = explode( '-', $args->slug );
642
+ $id = intval( $string[1] );
643
+ $updates = get_site_option( 'wdp_un_updates_available' );
644
+ //if in details iframe on update core page short-curcuit it
645
+ if ( did_action( 'install_plugins_pre_plugin-information' ) && is_array( $updates ) && isset( $updates[ $id ] ) ) {
646
+ $this->popup_changelog( $id );
 
647
  }
648
+
649
+ $res = new stdClass;
650
+ $res->name = $updates[ $id ]['name'];
651
+ $res->slug = sanitize_title( $updates[ $id ]['name'] );
652
+ $res->version = $updates[ $id ]['version'];
653
+ $res->rating = 100;
654
+ $res->homepage = $updates[ $id ]['url'];
655
  $res->download_link = '';
656
+ $res->tested = $cur_wp_version;
657
+
658
  return $res;
659
  }
660
+
661
+ if ( $action == 'plugin_information' && strpos( $args->slug, 'install_wpmudev_dash' ) !== false ) {
662
+ $res = new stdClass;
663
+ $res->name = 'WPMU DEV Dashboard';
664
+ $res->slug = 'wpmu-dev-dashboard';
665
+ $res->version = '';
666
+ $res->rating = 100;
667
+ $res->homepage = 'https://premium.wpmudev.org/project/wpmu-dev-dashboard/';
668
+ $res->download_link = $this->server_url . "download-dashboard";
669
+ $res->tested = $cur_wp_version;
670
+
671
  return $res;
672
  }
673
+
674
  return $res;
675
  }
676
+
677
  function filter_plugin_rows() {
678
+ if ( ! current_user_can( 'update_plugins' ) ) {
679
  return;
680
+ }
681
+
682
+ //don't show on per site plugins list, just like core
683
+ if ( is_multisite() && ! is_network_admin() ) { return; }
684
+
685
+ $updates = get_site_option( 'wdp_un_updates_available' );
686
+ if ( is_array( $updates ) && count( $updates ) ) {
687
  foreach ( $updates as $id => $plugin ) {
688
  if ( $plugin['autoupdate'] != '2' ) {
689
  if ( $plugin['type'] == 'theme' ) {
690
  remove_all_actions( 'after_theme_row_' . $plugin['filename'] );
691
+ add_action( 'after_theme_row_' . $plugin['filename'], array( &$this, 'plugin_row' ), 99, 2 );
692
  } else {
693
  remove_all_actions( 'after_plugin_row_' . $plugin['filename'] );
694
+ add_action( 'after_plugin_row_' . $plugin['filename'], array(
695
+ &$this,
696
+ 'plugin_row'
697
+ ), 99, 2 );
698
  }
699
  }
700
  }
701
  }
702
+
703
+ $local_themes = get_site_option( 'wdp_un_local_themes' );
704
+ if ( is_array( $local_themes ) && count( $local_themes ) ) {
705
  foreach ( $local_themes as $id => $plugin ) {
706
  remove_all_actions( 'after_theme_row_' . $plugin['filename'] );
707
  //only add the notice if specific version is wrong
708
+ if ( isset( $updates[ $this->theme_pack ] ) && version_compare( $plugin['version'], $updates[ $this->theme_pack ]['new_version'], '<' ) ) {
709
+ add_action( 'after_theme_row_' . $plugin['filename'], array( &$this, 'themepack_row' ), 9, 2 );
710
  }
711
  }
712
  }
713
  }
714
+
715
  function filter_plugin_count( $value ) {
716
+ global $wp_version;
717
+ $cur_wp_version = preg_replace( '/-.*$/', '', $wp_version );
718
+
719
  //remove any conflicting slug local WPMU DEV plugins from WP update notifications
720
+ $local_projects = get_site_option( 'wdp_un_local_projects' );
721
+ if ( is_array( $local_projects ) && count( $local_projects ) ) {
722
  foreach ( $local_projects as $id => $plugin ) {
723
+ if ( isset( $value->response[ $plugin['filename'] ] ) ) {
724
+ unset( $value->response[ $plugin['filename'] ] );
725
+ }
726
  }
727
  }
728
+
729
+ $updates = get_site_option( 'wdp_un_updates_available' );
730
+ if ( is_array( $updates ) && count( $updates ) ) {
731
  foreach ( $updates as $id => $plugin ) {
732
  if ( $plugin['type'] != 'theme' && $plugin['autoupdate'] != '2' ) {
733
+
734
  //build plugin class
735
+ $object = new stdClass;
736
+ $object->url = $plugin['url'];
737
+ $object->slug = "wpmudev_install-$id";
 
738
  $object->new_version = $plugin['new_version'];
739
+ $object->package = '';
740
+ $object->tested = $cur_wp_version;
741
+
742
  //add to class
743
+ $value->response[ $plugin['filename'] ] = $object;
744
  }
745
  }
746
  }
747
+
748
  return $value;
749
  }
750
+
751
  function filter_theme_count( $value ) {
752
+
753
+ $updates = get_site_option( 'wdp_un_updates_available' );
754
+ if ( is_array( $updates ) && count( $updates ) ) {
755
  foreach ( $updates as $id => $theme ) {
756
  if ( $theme['type'] == 'theme' && $theme['autoupdate'] != '2' ) {
757
+
758
+ $theme_slug = $theme['filename'];
759
+
760
  //build theme listing
761
+ $value->response[ $theme_slug ]['theme'] = $theme['filename'];
762
+ $value->response[ $theme_slug ]['url'] = admin_url( 'admin-ajax.php?action=wdpun-changelog&pid=' . $id );
763
+ $value->response[ $theme_slug ]['new_version'] = $theme['new_version'];
764
+ $value->response[ $theme_slug ]['package'] = '';
765
  }
766
  }
767
  }
768
+
769
  //filter 133 theme pack themes from the list unless update is available
770
+ $local_themes = get_site_option( 'wdp_un_local_themes' );
771
+ if ( is_array( $local_themes ) && count( $local_themes ) ) {
772
  foreach ( $local_themes as $id => $theme ) {
773
+ $theme_slug = $theme['filename'];
774
+
775
  //add to count only if new version exists, otherwise remove
776
+ if ( isset( $updates[ $theme['id'] ] ) && isset( $updates[ $theme['id'] ]['new_version'] ) && version_compare( $theme['version'], $updates[ $theme['id'] ]['new_version'], '<' ) ) {
777
+ $value->response[ $theme_slug ]['new_version'] = $updates[ $theme['id'] ]['new_version'];
778
+ $value->response[ $theme_slug ]['package'] = '';
779
+ } else if ( isset( $value ) && isset( $value->response ) && isset( $theme_slug ) && isset( $value->response[ $theme_slug ] ) ) {
780
+ unset( $value->response[ $theme_slug ] );
781
  }
782
  }
783
  }
784
+
785
  return $value;
786
  }
787
+
788
  function plugin_row( $file, $plugin_data ) {
 
789
  //get new version and update url
790
+ $updates = get_site_option( 'wdp_un_updates_available' );
791
+ if ( is_array( $updates ) && count( $updates ) ) {
792
  foreach ( $updates as $id => $plugin ) {
793
+ if ( $plugin['filename'] == $file ) {
794
  $project_id = $id;
795
+ $version = $plugin['new_version'];
796
  $plugin_url = $plugin['url'];
797
  $autoupdate = $plugin['autoupdate'];
798
+ $filename = $plugin['filename'];
799
+ $type = $plugin['type'];
800
  break;
801
  }
802
  }
803
  } else {
804
  return false;
805
  }
806
+
807
+ $plugins_allowedtags = array(
808
+ 'a' => array( 'href' => array(), 'title' => array() ),
809
+ 'abbr' => array( 'title' => array() ),
810
+ 'acronym' => array( 'title' => array() ),
811
+ 'code' => array(),
812
+ 'em' => array(),
813
+ 'strong' => array()
814
+ );
815
+ $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
816
+
817
+ $info_url = admin_url( 'admin-ajax.php?action=wdpun-changelog&pid=' . $project_id . '&TB_iframe=true&width=640&height=800' );
818
+ if ( file_exists( WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php' ) ) {
819
+ $message = "Activate WPMU DEV Dashboard";
820
  $action_url = $this->activate_url();
821
  } else { //dashboard not installed at all
822
+ $message = "Install WPMU DEV Dashboard";
823
  $action_url = $this->auto_install_url();
824
  }
825
+
826
+ if ( current_user_can( 'update_plugins' ) ) {
827
+ echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>';
828
+ printf( 'There is a new version of %1$s available on WPMU DEV. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">%6$s</a> to update.', $plugin_name, esc_url( $info_url ), esc_attr( $plugin_name ), $version, esc_url( $action_url ), $message );
829
+ echo '</p></div></td></tr>';
830
  }
831
  }
832
+
833
  function themepack_row( $file, $plugin_data ) {
834
+
835
  //get new version and update url
836
+ $updates = get_site_option( 'wdp_un_updates_available' );
837
+ if ( isset( $updates[ $this->theme_pack ] ) ) {
838
+ $plugin = $updates[ $this->theme_pack ];
839
  $project_id = $this->theme_pack;
840
+ $version = $plugin['new_version'];
841
  $plugin_url = $plugin['url'];
842
  } else {
843
  return false;
844
  }
845
+
846
+ $plugins_allowedtags = array(
847
+ 'a' => array( 'href' => array(), 'title' => array() ),
848
+ 'abbr' => array( 'title' => array() ),
849
+ 'acronym' => array( 'title' => array() ),
850
+ 'code' => array(),
851
+ 'em' => array(),
852
+ 'strong' => array()
853
+ );
854
+ $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
855
+
856
+ $info_url = admin_url( 'admin_ajax.php?action=wdpun-changelog&pid=' . $project_id . '&TB_iframe=true&width=640&height=800' );
857
+ if ( file_exists( WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php' ) ) {
858
+ $message = "Activate WPMU DEV Dashboard";
859
  $action_url = $this->activate_url();
860
  } else { //dashboard not installed at all
861
+ $message = "Install WPMU DEV Dashboard";
862
  $action_url = $this->auto_install_url();
863
  }
864
+
865
+ if ( current_user_can( 'update_themes' ) ) {
866
+ echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>';
867
+ printf( 'There is a new version of %1$s available on WPMU DEV. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">%6$s</a> to update.', $plugin_name, esc_url( $info_url ), esc_attr( $plugin_name ), $version, esc_url( $action_url ), $message );
868
+ echo '</p></div></td></tr>';
869
  }
870
  }
871
+
872
  function disable_checkboxes() {
873
+
874
+ $updates = get_site_option( 'wdp_un_updates_available' );
875
+ if ( ! is_array( $updates ) || ( is_array( $updates ) && ! count( $updates ) ) ) {
876
  return;
877
  }
878
+
879
+ $jquery = "<script type='text/javascript'>";
880
+
881
+ if ( file_exists( WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php' ) ) {
882
+ $message = "Activate WPMU DEV Dashboard";
883
+ $action_url = $this->activate_url();
884
+ } else { //dashboard not installed at all
885
+ $message = "Install WPMU DEV Dashboard";
886
+ $action_url = $this->auto_install_url();
887
+ }
888
+ $jquery .= "var wdp_note = '<br><span class=\"notice inline notice-warning notice-alt\">" . sprintf( '<a href="%s">%s</a> to update.', esc_url( $action_url ), $message ) . "</span>';\n";
889
+
890
+ foreach ( (array) $updates as $id => $project ) {
891
+ $slug = $project['filename'];
892
+ $jquery .= "jQuery(\"input:checkbox[value='" . esc_attr( $slug ) . "']\").closest('tr').find('td p').last().append(wdp_note);\n";
893
+ $jquery .= "jQuery(\"input:checkbox[value='" . esc_attr( $slug ) . "']\").remove();\n";
894
  }
895
+
896
  //disable checkboxes for 133 theme pack themes
897
+ $local_themes = get_site_option( 'wdp_un_local_themes' );
898
+ if ( is_array( $local_themes ) && count( $local_themes ) ) {
899
  foreach ( $local_themes as $id => $theme ) {
900
+ $jquery .= "jQuery(\"input:checkbox[value='" . esc_attr( $theme['filename'] ) . "']\").closest('tr').find('td p').last().append(wdp_note);\n";
901
+ $jquery .= "jQuery(\"input:checkbox[value='" . esc_attr( $theme['filename'] ) . "']\").remove();\n";
902
  }
903
  }
904
+
905
+ $jquery .= "</script>\n";
906
+
907
  echo $jquery;
908
  }
909
+
910
+ function set_activate_flag( $plugin ) {
911
  $data = $this->get_id_plugin( WP_PLUGIN_DIR . '/' . $plugin );
912
+ if ( isset( $data['id'] ) && ! empty( $data['id'] ) ) {
913
+ update_site_option( 'wdp_un_activated_flag', 1 );
914
  }
915
  }
916
+
917
+ function popup_changelog( $project_id ) {
918
+ /**
919
+ * Dashboard popup template: Project changelog
920
+ *
921
+ * Displays the changelog of a specific project.
922
+ *
923
+ * Following variables are passed into the template:
924
+ * $pid (project ID)
925
+ *
926
+ * @since 4.0.5
927
+ * @package WPMUDEV_Dashboard
928
+ */
929
+
930
+ $url = $this->server_url . 'changelog/' . $project_id;
931
+
932
+ $options = array(
933
+ 'timeout' => 15,
934
+ 'sslverify' => false, // Many hosts have no updated CA bundle.
935
+ 'user-agent' => 'Dashboard Notification/' . $this->version
936
+ );
937
+
938
+ $response = wp_remote_get( $url, $options );
939
+ if ( wp_remote_retrieve_response_code( $response ) == 200 ) {
940
+ $changelog = json_decode( wp_remote_retrieve_body( $response ), true );
941
+ }
942
+
943
+ $updates = get_site_option( 'wdp_un_updates_available' );
944
+ $item = $updates[ $project_id ];
945
+
946
+ if ( ! $changelog || ! is_array( $changelog ) || ! $item ) {
947
+ wp_die( __( 'We did not find any data for this plugin or theme...', 'wpmudev' ) );
948
+ }
949
+ $dlg_id = 'dlg-' . md5( time() . '-' . $project_id );
950
+
951
+
952
+ ?>
953
+ <div id="content" class="<?php echo esc_attr( $dlg_id ); ?>">
954
+ <script src="<?php echo includes_url( '/wp-includes/js/jquery/jquery.js' ); ?>"></script>
955
+ <link rel="stylesheet"
956
+ href="https://fonts.googleapis.com/css?family=Roboto+Condensed%3A400%2C700%7CRoboto%3A400%2C500%2C300%2C300italic%2C100"
957
+ type="text/css" media="all"/>
958
+ <style>
959
+ * {
960
+ box-sizing: border-box;
961
+ -moz-box-sizing: border-box;
962
+ }
963
+
964
+ html, body {
965
+ margin: 0;
966
+ padding: 0;
967
+ height: 100%;
968
+ font-family: 'Roboto', 'Helvetica Neue', Helvetica, sans-serif;
969
+ font-size: 15px;
970
+ }
971
+
972
+ h1, h2, h3, h4 {
973
+ font-family: 'Roboto Condensed', 'Roboto', 'Helvetica Neue', Helvetica, sans-serif;
974
+ font-weight: 700;
975
+ color: #777771;
976
+ }
977
+
978
+ h1 {
979
+ font-size: 3em;
980
+ }
981
+
982
+ p {
983
+ font-size: 1.2em;
984
+ font-weight: 300;
985
+ color: #777771;
986
+ }
987
+
988
+ a {
989
+ color: #19b4cf;
990
+ text-decoration: none;
991
+ }
992
+
993
+ a:hover,
994
+ a:focus,
995
+ a:active {
996
+ color: #387ac1;
997
+ }
998
+
999
+ #content {
1000
+ min-height: 100%;
1001
+ text-align: center;
1002
+ background: #FFF;
1003
+ position: absolute;
1004
+ left: 0;
1005
+ top: 0;
1006
+ right: 0;
1007
+ bottom: 0;
1008
+ overflow: auto;
1009
+ }
1010
+
1011
+ #content .excerpt {
1012
+ width: 100%;
1013
+ background-color: #14485F;
1014
+ padding: 10px;
1015
+ color: #FFF;
1016
+ }
1017
+
1018
+ #content .excerpt h1 {
1019
+ margin: 30px;
1020
+ color: #FFF;
1021
+ font-weight: 100;
1022
+ }
1023
+
1024
+ #content .versions h4 {
1025
+ font-size: 15px;
1026
+ text-transform: uppercase;
1027
+ text-align: left;
1028
+ padding: 0 0 15px;
1029
+ font-weight: bold;
1030
+ line-height: 20px;
1031
+ }
1032
+
1033
+ #content .excerpt a {
1034
+ float: left;
1035
+ margin-right: 40px;
1036
+ text-decoration: none;
1037
+ color: #6ECEDE;
1038
+ }
1039
+
1040
+ #content .excerpt a:hover,
1041
+ #content .excerpt a:focus,
1042
+ #content .excerpt a:active {
1043
+ color: #C7F7FF;
1044
+ }
1045
+
1046
+ #content .footer {
1047
+ background-color: #0B2F3F;
1048
+ padding: 20px 0;
1049
+ margin: 0;
1050
+ position: relative;
1051
+ }
1052
+
1053
+ #content .footer p {
1054
+ color: #FFF;
1055
+ margin: 10px 0;
1056
+ padding: 0;
1057
+ font-size: 15px;
1058
+ }
1059
+
1060
+ #content .information {
1061
+ padding: 0;
1062
+ text-align: left;
1063
+ }
1064
+
1065
+ #content .versions > li {
1066
+ border-bottom: 1px solid #E5E5E5;
1067
+ padding: 40px;
1068
+ margin: 0;
1069
+ }
1070
+
1071
+ #content .versions > li.new {
1072
+ background: #fffff6;
1073
+ }
1074
+
1075
+ #content .information .current-version,
1076
+ #content .information .new-version {
1077
+ border-radius: 5px;
1078
+ color: #FFF;
1079
+ cursor: default;
1080
+ display: inline-block;
1081
+ position: relative;
1082
+ top: -2px;
1083
+ margin: 0 0 0 10px;
1084
+ padding: 1px 5px;
1085
+ font-size: 10px;
1086
+ line-height: 20px;
1087
+ height: 20px;
1088
+ box-sizing: border-box;
1089
+ }
1090
+
1091
+ #content .information .new-version {
1092
+ background: #FDCE43;
1093
+ text-shadow: 0 1px 1px #DDAE30;
1094
+ }
1095
+
1096
+ #content .current-version {
1097
+ background: #00ACCA;
1098
+ text-shadow: 0 1px 1px #008CAA;
1099
+ }
1100
+
1101
+ #content .versions {
1102
+ margin: 0;
1103
+ padding: 0;
1104
+ }
1105
+
1106
+ #content .versions .changes {
1107
+ list-style: disc;
1108
+ padding: 0 0 0 20px;
1109
+ margin: 0;
1110
+ }
1111
+
1112
+ #content .versions .changes li {
1113
+ padding: 3px 0 3px 20px;
1114
+ margin: 0;
1115
+ color: #777771;
1116
+ cursor: default;
1117
+ }
1118
+
1119
+ #content .version-meta {
1120
+ float: right;
1121
+ text-align: right;
1122
+ }
1123
+ </style>
1124
+
1125
+ <div class="excerpt">
1126
+ <h1><?php printf( esc_attr__( '%s changelog', 'wpmudev' ), esc_html( $item['name'] ) ); ?></h1>
1127
+ </div>
1128
+
1129
+ <div class="information">
1130
+
1131
+ <ul class="versions">
1132
+ <?php
1133
+ foreach ( $changelog as $log ) {
1134
+ $row_class = '';
1135
+ $badge = '';
1136
+
1137
+ if ( ! is_array( $log ) ) {
1138
+ continue;
1139
+ }
1140
+ if ( empty( $log ) ) {
1141
+ continue;
1142
+ }
1143
+
1144
+ // -1 .. local is higher (dev) | 0 .. equal | 1 .. new version available
1145
+ $version_check = version_compare( $log['version'], $item['version'] );
1146
+
1147
+ if ( $item['version'] && 1 === $version_check ) {
1148
+ $row_class = 'new';
1149
+ }
1150
+
1151
+ if ( $item['version'] ) {
1152
+ if ( 0 === $version_check ) {
1153
+ $badge = sprintf(
1154
+ '<div class="current-version">%s %s</div>',
1155
+ '<i class="wdv-icon wdv-icon-ok"></i>',
1156
+ __( 'Current', 'wpmudev' )
1157
+ );
1158
+ } elseif ( 1 === $version_check ) {
1159
+ $badge = sprintf(
1160
+ '<div class="new-version">%s %s</div>',
1161
+ '<i class="wdv-icon wdv-icon-star"></i>',
1162
+ __( 'New', 'wpmudev' )
1163
+ );
1164
+ }
1165
+ }
1166
+
1167
+ $version = $log['version'];
1168
+
1169
+ if ( empty( $log['time'] ) ) {
1170
+ $rel_date = '';
1171
+ } else {
1172
+ $rel_date = date_i18n( get_option( 'date_format' ), $log['time'] );
1173
+ }
1174
+
1175
+ printf(
1176
+ '<li class="%1$s"><h4>%2$s %3$s <small class="version-meta">%4$s</small></h4>',
1177
+ esc_attr( $row_class ),
1178
+ sprintf(
1179
+ esc_html__( 'Version %s', 'wpmudev' ), esc_html( $version )
1180
+ ),
1181
+ wp_kses_post( $badge ),
1182
+ esc_html( $rel_date )
1183
+ );
1184
+
1185
+ $notes = explode( "\n", $log['log'] );
1186
+ $detail_level = 0;
1187
+ $detail_class = 'intro';
1188
+
1189
+ echo '<ul class="changes">';
1190
+ foreach ( $notes as $note ) {
1191
+ if ( 0 === strpos( $note, '<p>' ) ) {
1192
+ if ( 1 == $detail_level ) {
1193
+ printf(
1194
+ '<li class="toggle-details">
1195
+ <a href="#" class="for-intro">%s</a><a href="#" class="for-detail">%s</a>
1196
+ </li>',
1197
+ esc_html__( 'Show all changes', 'wpmudev' ),
1198
+ esc_html__( 'Hide details', 'wpmudev' )
1199
+ );
1200
+ $detail_class = 'detail';
1201
+ }
1202
+ $detail_level += 1;
1203
+ }
1204
+
1205
+ $note = stripslashes( $note );
1206
+ $note = preg_replace( '/(<br ?\/?>|<p>|<\/p>)/', '', $note );
1207
+ $note = trim( preg_replace( '/^\s*(\*|\-)\s*/', '', $note ) );
1208
+ $note = str_replace( array( '<', '>' ), array( '&lt;', '&gt;' ), $note );
1209
+ $note = preg_replace( '/`(.*?)`/', '<code>\1</code>', $note );
1210
+ if ( empty( $note ) ) {
1211
+ continue;
1212
+ }
1213
+
1214
+ printf(
1215
+ '<li class="version-%s">%s</li>',
1216
+ esc_attr( $detail_class ),
1217
+ wp_kses_post( $note )
1218
+ );
1219
+ }
1220
+ echo '</ul></li>';
1221
+ }
1222
+ ?>
1223
+ </ul>
1224
+ </div>
1225
+
1226
+ <div class="footer">
1227
+ <p>Copyright 2009 - <?php echo esc_html( date( 'Y' ) ); ?> WPMU DEV</p>
1228
+ </div>
1229
+
1230
+ <style>
1231
+ .<?php echo esc_attr( $dlg_id ); ?> .versions ul.changes .for-detail,
1232
+ .<?php echo esc_attr( $dlg_id ); ?> .versions ul.changes .version-detail {
1233
+ display: none;
1234
+ }
1235
+
1236
+ .<?php echo esc_attr( $dlg_id ); ?> .versions ul.changes .for-intro {
1237
+ display: inline-block;
1238
+ }
1239
+
1240
+ .<?php echo esc_attr( $dlg_id ); ?> .versions ul.changes.show-details .for-intro {
1241
+ display: none;
1242
+ }
1243
+
1244
+ .<?php echo esc_attr( $dlg_id ); ?> .versions ul.changes.show-details .for-detail {
1245
+ display: inline-block;
1246
+ }
1247
+
1248
+ .<?php echo esc_attr( $dlg_id ); ?> .versions ul.changes.show-details .version-detail {
1249
+ display: list-item;
1250
+ }
1251
+
1252
+ .<?php echo esc_attr( $dlg_id ); ?> .versions ul.changes .toggle-details {
1253
+ padding: 8px 0 4px;
1254
+ text-align: right;
1255
+ font-size: 12px;
1256
+ list-style: none;
1257
+ }
1258
+ </style>
1259
+ <script>
1260
+ jQuery(function () {
1261
+ jQuery('.<?php echo esc_attr( $dlg_id ); ?>').on('click', '.toggle-details a', function (ev) {
1262
+ var li = jQuery(this),
1263
+ ver = li.closest('.changes');
1264
+
1265
+ ev.preventDefault();
1266
+ ev.stopPropagation();
1267
+ ver.toggleClass('show-details');
1268
+ return false;
1269
+ });
1270
+ });
1271
+ </script>
1272
+ </div>
1273
+ <?php
1274
+ exit; //this is for output, we are done after this.
1275
+ }
1276
+
1277
+ function popup_changelog_ajax() {
1278
+ $project_id = $_GET['pid'];
1279
+ $this->popup_changelog( $project_id );
1280
+ }
1281
+
1282
+ function dismiss_ajax() {
1283
+ update_site_option( 'wdp_un_dismissed', time() );
1284
+ wp_send_json_success();
1285
+ }
1286
+
1287
  }
1288
+
1289
+ $GLOBALS['WPMUDEV_Dashboard_Notice4'] = new WPMUDEV_Dashboard_Notice4();
1290
  }
1291
 
1292
+ //disable older versions
1293
+ if ( ! class_exists( 'WPMUDEV_Dashboard_Notice' ) ) {
1294
+ class WPMUDEV_Dashboard_Notice {
1295
+ }
1296
+ }
1297
+
1298
+ if ( ! class_exists( 'WPMUDEV_Dashboard_Notice3' ) ) {
1299
+ class WPMUDEV_Dashboard_Notice3 {
1300
+ }
1301
  }
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.4.4\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/wp-smushit\n"
7
- "POT-Creation-Date: 2016-08-16 05:15:22+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,98 @@ 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:828
29
  msgid "Saving"
30
  msgstr ""
31
 
32
- #: assets/shared-ui/plugin-ui.php:301 lib/class-wp-smush-ui.php:828
 
 
 
33
  msgid "Dismiss"
34
  msgstr ""
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  #: extras/free-dashboard/module.php:377
37
  msgid "We're happy that you've chosen to install %s! Are you interested in how to make the most of this plugin? How would you like a quick 5 day email crash course with actionable advice on building your membership site? Only the info you want, no subscription!"
38
  msgstr ""
@@ -57,193 +141,221 @@ msgstr ""
57
  msgid "Rate %s"
58
  msgstr ""
59
 
60
- #: lib/class-wp-smush-admin.php:173
 
 
 
 
 
 
 
 
61
  msgid "Automatically smush my images on upload"
62
  msgstr ""
63
 
64
- #: lib/class-wp-smush-admin.php:174
65
  msgid "When you upload images to the media library, we’ll automatically optimize them."
66
  msgstr ""
67
 
68
- #: lib/class-wp-smush-admin.php:177
69
  msgid "Preserve image EXIF data"
70
  msgstr ""
71
 
72
- #: lib/class-wp-smush-admin.php:178
73
  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."
74
  msgstr ""
75
 
76
- #: lib/class-wp-smush-admin.php:181
77
  msgid "Resize original images"
78
  msgstr ""
79
 
80
- #: lib/class-wp-smush-admin.php:182
81
  msgid "Save a ton of space by not storing over-sized images on your server. Set image maximum width and height and large images will be automatically scaled before being added to the media library."
82
  msgstr ""
83
 
84
- #: lib/class-wp-smush-admin.php:185
85
  msgid "Super-smush my images"
86
  msgstr ""
87
 
88
- #: lib/class-wp-smush-admin.php:186
89
  msgid "Compress images up to 2x more than regular smush with almost no visible drop in quality."
90
  msgstr ""
91
 
92
- #: lib/class-wp-smush-admin.php:189
93
  msgid "Include my original full-size images"
94
  msgstr ""
95
 
96
- #: lib/class-wp-smush-admin.php:190
97
  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."
98
  msgstr ""
99
 
100
- #: lib/class-wp-smush-admin.php:193
101
  msgid "Make a copy of my original images"
102
  msgstr ""
103
 
104
- #: lib/class-wp-smush-admin.php:194
105
  msgid "Save your original full-size images so you can restore them at any point. Note: Activating this setting will significantly increase the size of your uploads folder by nearly twice as much."
106
  msgstr ""
107
 
108
- #: lib/class-wp-smush-admin.php:197
109
  msgid "Convert PNG to JPEG (lossy)"
110
  msgstr ""
111
 
112
- #: lib/class-wp-smush-admin.php:198
113
  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."
114
  msgstr ""
115
 
116
- #: lib/class-wp-smush-admin.php:205
117
  msgid "Enable NextGen Gallery integration"
118
  msgstr ""
119
 
120
- #: lib/class-wp-smush-admin.php:206
121
  msgid "Allow smushing images directly through NextGen Gallery settings."
122
  msgstr ""
123
 
124
- #: lib/class-wp-smush-admin.php:228 lib/class-wp-smush-ui.php:762
125
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:70
126
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:89
127
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:91
128
  msgid "WP Smush"
129
  msgstr ""
130
 
131
- #: lib/class-wp-smush-admin.php:327 lib/class-wp-smush.php:998
132
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:158
133
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:275
134
  msgid "Super-Smush"
135
  msgstr ""
136
 
137
- #: lib/class-wp-smush-admin.php:328
138
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:159
139
  msgid "Smush Now"
140
  msgstr ""
141
 
142
- #: lib/class-wp-smush-admin.php:329
143
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:160
144
  msgid "{{errors}} image(s) were skipped due to an error."
145
  msgstr ""
146
 
147
- #: lib/class-wp-smush-admin.php:330
148
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:161
149
  msgid "All images are fully optimised."
150
  msgstr ""
151
 
152
- #: lib/class-wp-smush-admin.php:331
153
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:162
154
  msgid "Restoring image.."
155
  msgstr ""
156
 
157
- #: lib/class-wp-smush-admin.php:332
158
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:163
159
  msgid "Smushing image.."
160
  msgstr ""
161
 
162
- #: lib/class-wp-smush-admin.php:333
163
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:164
164
  msgid "Checking images.."
165
  msgstr ""
166
 
167
- #: lib/class-wp-smush-admin.php:334
168
  msgid "We successfully verified your membership, all the Pro features should work completely. "
169
  msgstr ""
170
 
171
- #: lib/class-wp-smush-admin.php:335
172
  msgid "Your membership couldn't be verified."
173
  msgstr ""
174
 
175
- #: lib/class-wp-smush-admin.php:586
176
  msgid "Smush request timed out, You can try setting a higher value for `WP_SMUSH_API_TIMEOUT`."
177
  msgstr ""
178
 
179
- #: lib/class-wp-smush-admin.php:603
180
  msgid "You've smushed %d images in total."
181
  msgstr ""
182
 
183
- #: lib/class-wp-smush-admin.php:629 lib/class-wp-smush-nextgen.php:381
184
  msgid "You don't have permission to work with uploaded files."
185
  msgstr ""
186
 
187
- #: lib/class-wp-smush-admin.php:633 lib/class-wp-smush-nextgen.php:385
188
  msgid "No attachment ID was provided."
189
  msgstr ""
190
 
191
- #: lib/class-wp-smush-admin.php:760
 
 
 
 
192
  msgid "<strong>%d of %d images</strong> were sent for smushing:"
193
  msgstr ""
194
 
195
- #: lib/class-wp-smush-admin.php:1057 lib/class-wp-smush-admin.php:1070
196
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:336
197
  msgid "Bulk Smush Now"
198
  msgstr ""
199
 
200
- #: lib/class-wp-smush-admin.php:1064
201
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:340
202
  msgid "All Done!"
203
  msgstr ""
204
 
205
- #: lib/class-wp-smush-admin.php:1103 lib/class-wp-smush-admin.php:1854
206
  msgid "Settings"
207
  msgstr ""
208
 
209
- #: lib/class-wp-smush-admin.php:1249
210
  msgid "Image not smushed, fields empty."
211
  msgstr ""
212
 
213
- #: lib/class-wp-smush-admin.php:1256 lib/class-wp-smush-nextgen.php:568
214
  msgid "Image couldn't be smushed as the nonce verification failed, try reloading the page."
215
  msgstr ""
216
 
217
- #: lib/class-wp-smush-admin.php:1273
218
  msgid "Unable to smush image"
219
  msgstr ""
220
 
221
- #: lib/class-wp-smush-admin.php:1292
 
 
 
 
222
  msgid "Yay! All images are optimised as per your current settings."
223
  msgstr ""
224
 
225
- #: lib/class-wp-smush-admin.php:1465 lib/class-wp-smush-ui.php:737
226
  msgid "You have images that need smushing. %sBulk smush now!%s"
227
  msgstr ""
228
 
229
- #: lib/class-wp-smush-admin.php:1855 lib/class-wp-smush-ui.php:631
230
- #: lib/class-wp-smush-ui.php:762
 
 
 
 
231
  msgid "WP Smush Pro"
232
  msgstr ""
233
 
234
- #: lib/class-wp-smush-admin.php:1858
235
- msgid "Woohoo! Your latest Smush update %s allows you to %sauto resize%s all your images, how cool is that! %sFind out more here >>%s"
236
  msgstr ""
237
 
238
- #: lib/class-wp-smush-backup.php:81 lib/class-wp-smush-nextgen.php:468
 
 
 
 
 
 
 
 
239
  msgid "Error in processing restore action, Fields empty."
240
  msgstr ""
241
 
242
- #: lib/class-wp-smush-backup.php:88 lib/class-wp-smush-nextgen.php:475
243
  msgid "Image not restored, Nonce verification failed."
244
  msgstr ""
245
 
246
- #: lib/class-wp-smush-backup.php:182 lib/class-wp-smush-nextgen.php:550
247
  msgid "Unable to restore image"
248
  msgstr ""
249
 
@@ -328,7 +440,7 @@ msgid "STATS"
328
  msgstr ""
329
 
330
  #: lib/class-wp-smush-ui.php:123
331
- msgid " You've smushed %d images in total"
332
  msgstr ""
333
 
334
  #: lib/class-wp-smush-ui.php:148
@@ -370,275 +482,283 @@ msgstr ""
370
  msgid "PRO SAVINGS ESTIMATE"
371
  msgstr ""
372
 
373
- #: lib/class-wp-smush-ui.php:263
374
- msgid "UPDATE SETTINGS"
375
- msgstr ""
376
-
377
- #: lib/class-wp-smush-ui.php:284
378
  msgid "%sTRY PRO FEATURES FREE%s"
379
  msgstr ""
380
 
381
- #: lib/class-wp-smush-ui.php:286
382
  msgid "ADVANCED SETTINGS"
383
  msgstr ""
384
 
385
- #: lib/class-wp-smush-ui.php:399
386
- msgid "The Following image sizes will be optimised by WP Smush:"
387
  msgstr ""
388
 
389
- #: lib/class-wp-smush-ui.php:450
390
  msgid "Width"
391
  msgstr ""
392
 
393
- #: lib/class-wp-smush-ui.php:453
394
  msgid "Height"
395
  msgstr ""
396
 
397
- #: lib/class-wp-smush-ui.php:456
398
  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."
399
  msgstr ""
400
 
401
- #: lib/class-wp-smush-ui.php:457
402
  msgid "Just to let you know, the width you've entered is less than your largest thumbnail and may result in pixelation."
403
  msgstr ""
404
 
405
- #: lib/class-wp-smush-ui.php:458
406
  msgid "Just to let you know, the height you’ve entered is less than your largest thumbnail and may result in pixelation."
407
  msgstr ""
408
 
409
- #: lib/class-wp-smush-ui.php:568
410
  msgid "BOOST YOUR PERFORMANCE - HUMMINGBIRD"
411
  msgstr ""
412
 
413
- #: lib/class-wp-smush-ui.php:595
414
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:423
415
  msgid "No attachments found - Upload some images"
416
  msgstr ""
417
 
418
- #: lib/class-wp-smush-ui.php:597
419
  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!"
420
  msgstr ""
421
 
422
- #: lib/class-wp-smush-ui.php:600
423
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:428
424
  msgid "UPLOAD IMAGES"
425
  msgstr ""
426
 
427
- #: lib/class-wp-smush-ui.php:605
428
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:433
429
  msgid "All images are smushed and up to date. Awesome!"
430
  msgstr ""
431
 
432
- #: lib/class-wp-smush-ui.php:610
433
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:438
434
  msgid "BULK SMUSH NOW"
435
  msgstr ""
436
 
437
- #: lib/class-wp-smush-ui.php:629
438
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:446
439
  msgid "%s, you have %s%s%d%s image%s that needs smushing!"
440
  msgid_plural "%s, you have %s%s%d%s images%s that need smushing!"
441
  msgstr[0] ""
442
  msgstr[1] ""
443
 
444
- #: lib/class-wp-smush-ui.php:631
445
  msgid "You can %sUpgrade to Pro%s to bulk smush all your images with one click."
446
  msgstr ""
447
 
448
- #: lib/class-wp-smush-ui.php:632
449
  msgid "Free users can smush 50 images with each click."
450
  msgstr ""
451
 
452
- #: lib/class-wp-smush-ui.php:641
453
  msgid "Enable Super-smush in the Settings area to get even more savings with almost no noticeable quality loss."
454
  msgstr ""
455
 
456
- #: lib/class-wp-smush-ui.php:664
457
  msgid "%sBulk smush is currently running.%s You need to keep this page open for the process to complete."
458
  msgstr ""
459
 
460
- #: lib/class-wp-smush-ui.php:674
461
  msgid "%s%d%s of %d attachments have been smushed."
462
  msgstr ""
463
 
464
- #: lib/class-wp-smush-ui.php:679
465
  msgid "CANCEL"
466
  msgstr ""
467
 
468
- #: lib/class-wp-smush-ui.php:715
469
  msgid "%s, you have %s%s%d%s image%s that needs re-compressing!"
470
  msgid_plural "%s, you have %s%s%d%s images%s that need re-compressing!"
471
  msgstr[0] ""
472
  msgstr[1] ""
473
 
474
- #: lib/class-wp-smush-ui.php:716
475
  msgid "Skip"
476
  msgstr ""
477
 
478
- #: lib/class-wp-smush-ui.php:730
479
  msgid "Your settings have been updated!"
480
  msgstr ""
481
 
482
- #: lib/class-wp-smush-ui.php:764
483
  msgid "Automatic smushing is %senabled%s. Newly uploaded images will be automagically compressed."
484
  msgstr ""
485
 
486
- #: lib/class-wp-smush-ui.php:764
487
  msgid "Automatic smushing is %sdisabled%s. Newly uploaded images will need to be manually smushed."
488
  msgstr ""
489
 
490
- #: lib/class-wp-smush-ui.php:800
491
  msgid "Thanks for installing Smush. We hope you like it!"
492
  msgstr ""
493
 
494
- #: lib/class-wp-smush-ui.php:801
495
  msgid "And hey, if you do, you can now try out Smush Pro for double the smushy goodness (benchmarked), entirely for free!"
496
  msgstr ""
497
 
498
- #: lib/class-wp-smush-ui.php:802 lib/class-wp-smush-ui.php:806
499
  msgid "Try Smush Pro for Free"
500
  msgstr ""
501
 
502
- #: lib/class-wp-smush-ui.php:804
503
  msgid "Thanks for updating Smush. Did you know that you can now try the Smush Pro for FREE?!"
504
  msgstr ""
505
 
506
- #: lib/class-wp-smush-ui.php:805
507
  msgid "Yep, Super Smush your images for double the savings, save originals and batch Smush thousands of images all at once.... no charge!"
508
  msgstr ""
509
 
510
- #: lib/class-wp-smush-ui.php:852
511
  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"
512
  msgstr ""
513
 
514
- #: lib/class-wp-smush-ui.php:852
515
  msgid "Try WP Smush Pro for FREE"
516
  msgstr ""
517
 
518
- #: lib/class-wp-smush-ui.php:875
519
  msgid "Validating.."
520
  msgstr ""
521
 
522
- #: lib/class-wp-smush-ui.php:877
523
  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."
524
  msgstr ""
525
 
526
- #: lib/class-wp-smush.php:175
 
 
 
 
 
 
 
 
527
  msgid "File path is empty"
528
  msgstr ""
529
 
530
- #: lib/class-wp-smush.php:180
531
  msgid "Could not find %s"
532
  msgstr ""
533
 
534
- #: lib/class-wp-smush.php:185
535
  msgid "%s is not writable"
536
  msgstr ""
537
 
538
- #: lib/class-wp-smush.php:195
539
  msgid "Skipped (%s), image not found. Attachment: %s"
540
  msgstr ""
541
 
542
- #: lib/class-wp-smush.php:200
543
  msgid "Skipped (%s), size limit exceeded. Attachment: %s"
544
  msgstr ""
545
 
546
- #: lib/class-wp-smush.php:219
547
  msgid "Unknown API error"
548
  msgstr ""
549
 
550
- #: lib/class-wp-smush.php:650
551
  msgid "Error posting to API: %s"
552
  msgstr ""
553
 
554
- #: lib/class-wp-smush.php:656
555
  msgid "Error posting to API: %s %s"
556
  msgstr ""
557
 
558
- #: lib/class-wp-smush.php:673
559
  msgid "Smush data corrupted, try again."
560
  msgstr ""
561
 
562
- #: lib/class-wp-smush.php:693
563
  msgid "Image couldn't be smushed"
564
  msgstr ""
565
 
566
- #: lib/class-wp-smush.php:914 lib/class-wp-smush.php:918
567
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:193
568
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:196
569
  msgid "Already Optimized"
570
  msgstr ""
571
 
572
- #: lib/class-wp-smush.php:927
573
  msgid "%d images reduced "
574
  msgstr ""
575
 
576
- #: lib/class-wp-smush.php:927
577
  msgid "Reduced "
578
  msgstr ""
579
 
580
- #: lib/class-wp-smush.php:931
581
  msgid "by %s %s"
582
  msgstr ""
583
 
584
- #: lib/class-wp-smush.php:937
585
  msgid "<br /> Image Size: %s"
586
  msgstr ""
587
 
588
- #: lib/class-wp-smush.php:973
589
  msgid "Detailed stats for all the image sizes"
590
  msgstr ""
591
 
592
- #: lib/class-wp-smush.php:973
593
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:236
594
  msgid "Smush stats"
595
  msgstr ""
596
 
597
- #: lib/class-wp-smush.php:1005
 
 
 
 
598
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:249
599
  msgid "Not processed"
600
  msgstr ""
601
 
602
- #: lib/class-wp-smush.php:1011
603
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:255
604
  msgid "Smush Now!"
605
  msgstr ""
606
 
607
- #: lib/class-wp-smush.php:1314
608
  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."
609
  msgstr ""
610
 
611
- #: lib/class-wp-smush.php:1317
612
  msgid "Image couldn't be smushed as it exceeded the 1Mb size limit, Pro users can smush images with size upto 32Mb."
613
  msgstr ""
614
 
615
- #: lib/class-wp-smush.php:1319
616
  msgid " Skipped"
617
  msgstr ""
618
 
619
- #: lib/class-wp-smush.php:1341
620
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:432
621
  msgid "Image size"
622
  msgstr ""
623
 
624
- #: lib/class-wp-smush.php:1342
625
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:433
626
  msgid "Savings"
627
  msgstr ""
628
 
629
- #: lib/class-wp-smush.php:1546
630
  msgid "Restore original image."
631
  msgstr ""
632
 
633
- #: lib/class-wp-smush.php:1546
634
  msgid "Restore image"
635
  msgstr ""
636
 
637
- #: lib/class-wp-smush.php:1591
638
  msgid "Smush image including original file."
639
  msgstr ""
640
 
641
- #: lib/class-wp-smush.php:1591
642
  msgid "Resmush image"
643
  msgstr ""
644
 
@@ -674,11 +794,11 @@ msgstr ""
674
  msgid "Reduced by %s ( %01.1f%% )"
675
  msgstr ""
676
 
677
- #: wp-smush.php:156
678
  msgid "Get Fast"
679
  msgstr ""
680
 
681
- #: wp-smush.php:197
682
  msgid "WP Smush Free was deactivated. You have WP Smush Pro active!"
683
  msgstr ""
684
  #. Plugin Name of the plugin/theme
2
  # This file is distributed under the same license as the WP Smush package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WP Smush 2.5.2\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/wp-smushit\n"
7
+ "POT-Creation-Date: 2016-11-03 15:54:00+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:879
29
  msgid "Saving"
30
  msgstr ""
31
 
32
+ #: assets/shared-ui/plugin-ui.php:301
33
+ #: extras/dash-notice/wpmudev-dash-notification.php:243
34
+ #: extras/dash-notice/wpmudev-dash-notification.php:284
35
+ #: lib/class-wp-smush-ui.php:879
36
  msgid "Dismiss"
37
  msgstr ""
38
 
39
+ #: extras/dash-notice/wpmudev-dash-notification.php:218
40
+ msgid "install"
41
+ msgstr ""
42
+
43
+ #: extras/dash-notice/wpmudev-dash-notification.php:225
44
+ msgid "Important updates are available for <strong>%s</strong>. Install the free WPMU DEV Dashboard plugin now for updates and support!"
45
+ msgstr ""
46
+
47
+ #: extras/dash-notice/wpmudev-dash-notification.php:227
48
+ msgid "<strong>%s</strong> is almost ready - install the free WPMU DEV Dashboard plugin for updates and support!"
49
+ msgstr ""
50
+
51
+ #: extras/dash-notice/wpmudev-dash-notification.php:231
52
+ msgid "Important updates are available for your WPMU DEV plugins/themes. Install the free WPMU DEV Dashboard plugin now for updates and support!"
53
+ msgstr ""
54
+
55
+ #: extras/dash-notice/wpmudev-dash-notification.php:233
56
+ msgid "Almost ready - install the free WPMU DEV Dashboard plugin for updates and support!"
57
+ msgstr ""
58
+
59
+ #: extras/dash-notice/wpmudev-dash-notification.php:239
60
+ msgid "Install Plugin"
61
+ msgstr ""
62
+
63
+ #: extras/dash-notice/wpmudev-dash-notification.php:242
64
+ #: extras/dash-notice/wpmudev-dash-notification.php:283
65
+ msgid "Saving..."
66
+ msgstr ""
67
+
68
+ #: extras/dash-notice/wpmudev-dash-notification.php:259
69
+ msgid "activate"
70
+ msgstr ""
71
+
72
+ #: extras/dash-notice/wpmudev-dash-notification.php:266
73
+ msgid "Important updates are available for <strong>%s</strong>. Activate the WPMU DEV Dashboard to update now!"
74
+ msgstr ""
75
+
76
+ #: extras/dash-notice/wpmudev-dash-notification.php:268
77
+ msgid "Just one more step to enable updates and support for <strong>%s</strong>!"
78
+ msgstr ""
79
+
80
+ #: extras/dash-notice/wpmudev-dash-notification.php:272
81
+ msgid "Important updates are available for your WPMU DEV plugins/themes. Activate the WPMU DEV Dashboard to update now!"
82
+ msgstr ""
83
+
84
+ #: extras/dash-notice/wpmudev-dash-notification.php:274
85
+ msgid "Just one more step - activate the WPMU DEV Dashboard plugin and you're all done!"
86
+ msgstr ""
87
+
88
+ #: extras/dash-notice/wpmudev-dash-notification.php:280
89
+ msgid "Activate WPMU DEV Dashboard"
90
+ msgstr ""
91
+
92
+ #: extras/dash-notice/wpmudev-dash-notification.php:947
93
+ msgid "We did not find any data for this plugin or theme..."
94
+ msgstr ""
95
+
96
+ #: extras/dash-notice/wpmudev-dash-notification.php:1126
97
+ msgid "%s changelog"
98
+ msgstr ""
99
+
100
+ #: extras/dash-notice/wpmudev-dash-notification.php:1156
101
+ msgid "Current"
102
+ msgstr ""
103
+
104
+ #: extras/dash-notice/wpmudev-dash-notification.php:1162
105
+ msgid "New"
106
+ msgstr ""
107
+
108
+ #: extras/dash-notice/wpmudev-dash-notification.php:1179
109
+ msgid "Version %s"
110
+ msgstr ""
111
+
112
+ #: extras/dash-notice/wpmudev-dash-notification.php:1197
113
+ msgid "Show all changes"
114
+ msgstr ""
115
+
116
+ #: extras/dash-notice/wpmudev-dash-notification.php:1198
117
+ msgid "Hide details"
118
+ msgstr ""
119
+
120
  #: extras/free-dashboard/module.php:377
121
  msgid "We're happy that you've chosen to install %s! Are you interested in how to make the most of this plugin? How would you like a quick 5 day email crash course with actionable advice on building your membership site? Only the info you want, no subscription!"
122
  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:809
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:1051
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:1129
302
  msgid "Settings"
303
  msgstr ""
304
 
305
+ #: lib/class-wp-smush-admin.php:1275
306
  msgid "Image not smushed, fields empty."
307
  msgstr ""
308
 
309
+ #: lib/class-wp-smush-admin.php:1282 lib/class-wp-smush-nextgen.php:568
310
  msgid "Image couldn't be smushed as the nonce verification failed, try reloading the page."
311
  msgstr ""
312
 
313
+ #: lib/class-wp-smush-admin.php:1299
314
  msgid "Unable to smush image"
315
  msgstr ""
316
 
317
+ #: lib/class-wp-smush-admin.php:1324
318
+ msgid "We haven’t found any images in your media library yet so there’s no smushing to be done!"
319
+ msgstr ""
320
+
321
+ #: lib/class-wp-smush-admin.php:1340
322
  msgid "Yay! All images are optimised as per your current settings."
323
  msgstr ""
324
 
325
+ #: lib/class-wp-smush-admin.php:1512 lib/class-wp-smush-ui.php:784
326
  msgid "You have images that need smushing. %sBulk smush now!%s"
327
  msgstr ""
328
 
329
+ #: lib/class-wp-smush-admin.php:1898
330
+ msgid "Review your setting now."
331
+ msgstr ""
332
+
333
+ #: lib/class-wp-smush-admin.php:1899 lib/class-wp-smush-ui.php:672
334
+ #: lib/class-wp-smush-ui.php:809
335
  msgid "WP Smush Pro"
336
  msgstr ""
337
 
338
+ #: lib/class-wp-smush-admin.php:1900
339
+ msgid "Welcome to the newest version of WP Smush! Auto-smushing on upload is lightning fast now that we handle all the smushing asynchronously."
340
  msgstr ""
341
 
342
+ #: lib/class-wp-smush-admin.php:1903
343
+ msgid " And as a multisite user, you can manage %sSmush settings%s globally across all sites!"
344
+ msgstr ""
345
+
346
+ #: lib/class-wp-smush-admin.php:1906
347
+ msgid " %sFind out more here >>%s"
348
+ msgstr ""
349
+
350
+ #: lib/class-wp-smush-backup.php:84 lib/class-wp-smush-nextgen.php:468
351
  msgid "Error in processing restore action, Fields empty."
352
  msgstr ""
353
 
354
+ #: lib/class-wp-smush-backup.php:91 lib/class-wp-smush-nextgen.php:475
355
  msgid "Image not restored, Nonce verification failed."
356
  msgstr ""
357
 
358
+ #: lib/class-wp-smush-backup.php:185 lib/class-wp-smush-nextgen.php:550
359
  msgid "Unable to restore image"
360
  msgstr ""
361
 
440
  msgstr ""
441
 
442
  #: lib/class-wp-smush-ui.php:123
443
+ msgid "You've smushed %d images in total"
444
  msgstr ""
445
 
446
  #: lib/class-wp-smush-ui.php:148
482
  msgid "PRO SAVINGS ESTIMATE"
483
  msgstr ""
484
 
485
+ #: lib/class-wp-smush-ui.php:277
 
 
 
 
486
  msgid "%sTRY PRO FEATURES FREE%s"
487
  msgstr ""
488
 
489
+ #: lib/class-wp-smush-ui.php:279
490
  msgid "ADVANCED SETTINGS"
491
  msgstr ""
492
 
493
+ #: lib/class-wp-smush-ui.php:423
494
+ msgid "The following image sizes will be optimised by WP Smush:"
495
  msgstr ""
496
 
497
+ #: lib/class-wp-smush-ui.php:474
498
  msgid "Width"
499
  msgstr ""
500
 
501
+ #: lib/class-wp-smush-ui.php:477
502
  msgid "Height"
503
  msgstr ""
504
 
505
+ #: lib/class-wp-smush-ui.php:480
506
  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."
507
  msgstr ""
508
 
509
+ #: lib/class-wp-smush-ui.php:481
510
  msgid "Just to let you know, the width you've entered is less than your largest thumbnail and may result in pixelation."
511
  msgstr ""
512
 
513
+ #: lib/class-wp-smush-ui.php:482
514
  msgid "Just to let you know, the height you’ve entered is less than your largest thumbnail and may result in pixelation."
515
  msgstr ""
516
 
517
+ #: lib/class-wp-smush-ui.php:609
518
  msgid "BOOST YOUR PERFORMANCE - HUMMINGBIRD"
519
  msgstr ""
520
 
521
+ #: lib/class-wp-smush-ui.php:636
522
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:423
523
  msgid "No attachments found - Upload some images"
524
  msgstr ""
525
 
526
+ #: lib/class-wp-smush-ui.php:638
527
  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!"
528
  msgstr ""
529
 
530
+ #: lib/class-wp-smush-ui.php:641
531
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:428
532
  msgid "UPLOAD IMAGES"
533
  msgstr ""
534
 
535
+ #: lib/class-wp-smush-ui.php:646
536
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:433
537
  msgid "All images are smushed and up to date. Awesome!"
538
  msgstr ""
539
 
540
+ #: lib/class-wp-smush-ui.php:651
541
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:438
542
  msgid "BULK SMUSH NOW"
543
  msgstr ""
544
 
545
+ #: lib/class-wp-smush-ui.php:670
546
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:446
547
  msgid "%s, you have %s%s%d%s image%s that needs smushing!"
548
  msgid_plural "%s, you have %s%s%d%s images%s that need smushing!"
549
  msgstr[0] ""
550
  msgstr[1] ""
551
 
552
+ #: lib/class-wp-smush-ui.php:672
553
  msgid "You can %sUpgrade to Pro%s to bulk smush all your images with one click."
554
  msgstr ""
555
 
556
+ #: lib/class-wp-smush-ui.php:673
557
  msgid "Free users can smush 50 images with each click."
558
  msgstr ""
559
 
560
+ #: lib/class-wp-smush-ui.php:682
561
  msgid "Enable Super-smush in the Settings area to get even more savings with almost no noticeable quality loss."
562
  msgstr ""
563
 
564
+ #: lib/class-wp-smush-ui.php:705
565
  msgid "%sBulk smush is currently running.%s You need to keep this page open for the process to complete."
566
  msgstr ""
567
 
568
+ #: lib/class-wp-smush-ui.php:715
569
  msgid "%s%d%s of %d attachments have been smushed."
570
  msgstr ""
571
 
572
+ #: lib/class-wp-smush-ui.php:720
573
  msgid "CANCEL"
574
  msgstr ""
575
 
576
+ #: lib/class-wp-smush-ui.php:756
577
  msgid "%s, you have %s%s%d%s image%s that needs re-compressing!"
578
  msgid_plural "%s, you have %s%s%d%s images%s that need re-compressing!"
579
  msgstr[0] ""
580
  msgstr[1] ""
581
 
582
+ #: lib/class-wp-smush-ui.php:757
583
  msgid "Skip"
584
  msgstr ""
585
 
586
+ #: lib/class-wp-smush-ui.php:777
587
  msgid "Your settings have been updated!"
588
  msgstr ""
589
 
590
+ #: lib/class-wp-smush-ui.php:811
591
  msgid "Automatic smushing is %senabled%s. Newly uploaded images will be automagically compressed."
592
  msgstr ""
593
 
594
+ #: lib/class-wp-smush-ui.php:811
595
  msgid "Automatic smushing is %sdisabled%s. Newly uploaded images will need to be manually smushed."
596
  msgstr ""
597
 
598
+ #: lib/class-wp-smush-ui.php:851
599
  msgid "Thanks for installing Smush. We hope you like it!"
600
  msgstr ""
601
 
602
+ #: lib/class-wp-smush-ui.php:852
603
  msgid "And hey, if you do, you can now try out Smush Pro for double the smushy goodness (benchmarked), entirely for free!"
604
  msgstr ""
605
 
606
+ #: lib/class-wp-smush-ui.php:853 lib/class-wp-smush-ui.php:857
607
  msgid "Try Smush Pro for Free"
608
  msgstr ""
609
 
610
+ #: lib/class-wp-smush-ui.php:855
611
  msgid "Thanks for updating Smush. Did you know that you can now try the Smush Pro for FREE?!"
612
  msgstr ""
613
 
614
+ #: lib/class-wp-smush-ui.php:856
615
  msgid "Yep, Super Smush your images for double the savings, save originals and batch Smush thousands of images all at once.... no charge!"
616
  msgstr ""
617
 
618
+ #: lib/class-wp-smush-ui.php:903
619
  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"
620
  msgstr ""
621
 
622
+ #: lib/class-wp-smush-ui.php:903
623
  msgid "Try WP Smush Pro for FREE"
624
  msgstr ""
625
 
626
+ #: lib/class-wp-smush-ui.php:926
627
  msgid "Validating.."
628
  msgstr ""
629
 
630
+ #: lib/class-wp-smush-ui.php:928
631
  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."
632
  msgstr ""
633
 
634
+ #: lib/class-wp-smush-ui.php:950
635
+ msgid "UPDATE SETTINGS"
636
+ msgstr ""
637
+
638
+ #: lib/class-wp-smush-ui.php:980
639
+ msgid "Smush settings were updated, performing a quick scan to check if any of the images need to be Smushed again."
640
+ msgstr ""
641
+
642
+ #: lib/class-wp-smush.php:194
643
  msgid "File path is empty"
644
  msgstr ""
645
 
646
+ #: lib/class-wp-smush.php:199
647
  msgid "Could not find %s"
648
  msgstr ""
649
 
650
+ #: lib/class-wp-smush.php:204
651
  msgid "%s is not writable"
652
  msgstr ""
653
 
654
+ #: lib/class-wp-smush.php:214
655
  msgid "Skipped (%s), image not found. Attachment: %s"
656
  msgstr ""
657
 
658
+ #: lib/class-wp-smush.php:219
659
  msgid "Skipped (%s), size limit exceeded. Attachment: %s"
660
  msgstr ""
661
 
662
+ #: lib/class-wp-smush.php:238
663
  msgid "Unknown API error"
664
  msgstr ""
665
 
666
+ #: lib/class-wp-smush.php:703
667
  msgid "Error posting to API: %s"
668
  msgstr ""
669
 
670
+ #: lib/class-wp-smush.php:709
671
  msgid "Error posting to API: %s %s"
672
  msgstr ""
673
 
674
+ #: lib/class-wp-smush.php:726
675
  msgid "Smush data corrupted, try again."
676
  msgstr ""
677
 
678
+ #: lib/class-wp-smush.php:746
679
  msgid "Image couldn't be smushed"
680
  msgstr ""
681
 
682
+ #: lib/class-wp-smush.php:967 lib/class-wp-smush.php:971
683
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:193
684
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:196
685
  msgid "Already Optimized"
686
  msgstr ""
687
 
688
+ #: lib/class-wp-smush.php:980
689
  msgid "%d images reduced "
690
  msgstr ""
691
 
692
+ #: lib/class-wp-smush.php:980
693
  msgid "Reduced "
694
  msgstr ""
695
 
696
+ #: lib/class-wp-smush.php:984
697
  msgid "by %s %s"
698
  msgstr ""
699
 
700
+ #: lib/class-wp-smush.php:990
701
  msgid "<br /> Image Size: %s"
702
  msgstr ""
703
 
704
+ #: lib/class-wp-smush.php:1026
705
  msgid "Detailed stats for all the image sizes"
706
  msgstr ""
707
 
708
+ #: lib/class-wp-smush.php:1026
709
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:236
710
  msgid "Smush stats"
711
  msgstr ""
712
 
713
+ #: lib/class-wp-smush.php:1057
714
+ msgid "Smushing in progress.."
715
+ msgstr ""
716
+
717
+ #: lib/class-wp-smush.php:1070
718
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:249
719
  msgid "Not processed"
720
  msgstr ""
721
 
722
+ #: lib/class-wp-smush.php:1076
723
  #: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:255
724
  msgid "Smush Now!"
725
  msgstr ""
726
 
727
+ #: lib/class-wp-smush.php:1379
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:1382
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:1384
736
  msgid " Skipped"
737
  msgstr ""
738
 
739
+ #: lib/class-wp-smush.php:1406
740
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:432
741
  msgid "Image size"
742
  msgstr ""
743
 
744
+ #: lib/class-wp-smush.php:1407
745
  #: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:433
746
  msgid "Savings"
747
  msgstr ""
748
 
749
+ #: lib/class-wp-smush.php:1614
750
  msgid "Restore original image."
751
  msgstr ""
752
 
753
+ #: lib/class-wp-smush.php:1614
754
  msgid "Restore image"
755
  msgstr ""
756
 
757
+ #: lib/class-wp-smush.php:1662
758
  msgid "Smush image including original file."
759
  msgstr ""
760
 
761
+ #: lib/class-wp-smush.php:1662
762
  msgid "Resmush image"
763
  msgstr ""
764
 
794
  msgid "Reduced by %s ( %01.1f%% )"
795
  msgstr ""
796
 
797
+ #: wp-smush.php:158
798
  msgid "Get Fast"
799
  msgstr ""
800
 
801
+ #: wp-smush.php:200
802
  msgid "WP Smush Free was deactivated. You have WP Smush Pro active!"
803
  msgstr ""
804
  #. Plugin Name of the plugin/theme
lib/class-wp-smush-admin.php CHANGED
@@ -72,6 +72,17 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
72
 
73
  public $bulk_ui = '';
74
 
 
 
 
 
 
 
 
 
 
 
 
75
  /**
76
  * @var int Limit for allowed number of images per bulk request
77
  */
@@ -112,6 +123,9 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
112
  // hook custom screen
113
  add_action( 'admin_menu', array( $this, 'screen' ) );
114
 
 
 
 
115
  //Handle Smush Bulk Ajax
116
  add_action( 'wp_ajax_wp_smushit_bulk', array( $this, 'process_smush_request' ) );
117
 
@@ -121,9 +135,12 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
121
  //Handle Restore operation
122
  add_action( 'wp_ajax_smush_resmush_image', array( $this, 'resmush_image' ) );
123
 
124
- //Handle Restore operation
125
  add_action( 'wp_ajax_scan_for_resmush', array( $this, 'scan_images' ) );
126
 
 
 
 
127
  add_filter( 'plugin_action_links_' . WP_SMUSH_BASENAME, array(
128
  $this,
129
  'settings_link'
@@ -139,7 +156,8 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
139
  add_action( 'admin_notices', array( $this, 'smush_upgrade' ) );
140
 
141
  // New Features Notice
142
- // add_action( 'admin_notices', array( $this, 'smush_updated' ) );
 
143
 
144
  //Handle the smush pro dismiss features notice ajax
145
  add_action( 'wp_ajax_dismiss_upgrade_notice', array( $this, 'dismiss_upgrade_notice' ) );
@@ -169,31 +187,35 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
169
 
170
  function init_settings() {
171
  $this->settings = array(
172
- 'auto' => array(
 
 
 
 
173
  'label' => esc_html__( 'Automatically smush my images on upload', 'wp-smushit' ),
174
  'desc' => esc_html__( 'When you upload images to the media library, we’ll automatically optimize them.', 'wp-smushit' )
175
  ),
176
- 'keep_exif' => array(
177
  'label' => esc_html__( 'Preserve image EXIF data', 'wp-smushit' ),
178
  'desc' => esc_html__( 'EXIF data stores camera settings, focal length, date, time and location information in image files. EXIF data makes image files larger but if you are a photographer you may want to preserve this information.', 'wp-smushit' )
179
  ),
180
- 'resize' => array(
181
  'label' => esc_html__( 'Resize original images', 'wp-smushit' ),
182
  'desc' => esc_html__( 'Save a ton of space by not storing over-sized images on your server. Set image maximum width and height and large images will be automatically scaled before being added to the media library.', 'wp-smushit' )
183
  ),
184
- 'lossy' => array(
185
  'label' => esc_html__( 'Super-smush my images', 'wp-smushit' ),
186
  'desc' => esc_html__( 'Compress images up to 2x more than regular smush with almost no visible drop in quality.', 'wp-smushit' )
187
  ),
188
- 'original' => array(
189
  'label' => esc_html__( 'Include my original full-size images', 'wp-smushit' ),
190
  'desc' => esc_html__( 'WordPress crops and resizes every image you upload for embedding on your site. By default, Smush only compresses these cropped and resized images, not your original full-size images. To save space on your server, activate this setting to smush your original images, too. Note: This doesn’t usually improve page speed.', 'wp-smushit' )
191
  ),
192
- 'backup' => array(
193
  'label' => esc_html__( 'Make a copy of my original images', 'wp-smushit' ),
194
  'desc' => esc_html__( 'Save your original full-size images so you can restore them at any point. Note: Activating this setting will significantly increase the size of your uploads folder by nearly twice as much.', 'wp-smushit' )
195
  ),
196
- 'png_to_jpg' => array(
197
  'label' => esc_html__( 'Convert PNG to JPEG (lossy)', 'wp-smushit' ),
198
  'desc' => sprintf( esc_html__( "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.", 'wp-smushit' ), "<br />" )
199
  )
@@ -246,6 +268,14 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
246
  'ui'
247
  ) );
248
 
 
 
 
 
 
 
 
 
249
  //For Nextgen gallery Pages, check later in enqueue function
250
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
251
 
@@ -274,8 +304,6 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
274
  */
275
  function enqueue() {
276
 
277
- global $pagenow;
278
-
279
  $current_screen = get_current_screen();
280
  $current_page = $current_screen->base;
281
 
@@ -284,10 +312,13 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
284
  */
285
  $enqueue_smush = apply_filters( 'wp_smush_enqueue', true );
286
 
287
- //If we upgrade/install message is dismissed and for pro users
 
288
  if ( get_option( 'wp-smush-hide_upgrade_notice' ) || get_site_option( 'wp-smush-hide_upgrade_notice' ) || $this->validate_install() ) {
 
 
289
  //Do not enqueue, unless it is one of the required screen
290
- if ( ! $enqueue_smush || ( $current_page != 'nggallery-manage-images' && $current_page != 'gallery_page_wp-smush-nextgen-bulk' && $pagenow != 'post.php' && $pagenow != 'post-new.php' && $pagenow != 'upload.php' ) ) {
291
 
292
  return;
293
  }
@@ -317,7 +348,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
317
  * Localize Translations
318
  */
319
  function localize() {
320
- global $current_screen;
321
  $current_page = ! empty( $current_screen ) ? $current_screen->base : '';
322
 
323
  $bulk = new WpSmushitBulk();
@@ -341,7 +372,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
341
  if ( $current_page == 'media_page_wp-smush-bulk' ) {
342
 
343
  //Setup all the stats
344
- $this->setup_global_stats();
345
 
346
  //Get attachments if all the images are not smushed
347
  $this->attachments = $this->remaining_count > 0 ? $bulk->get_attachments() : array();
@@ -380,6 +411,19 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
380
 
381
  wp_localize_script( 'wp-smushit-admin-js', 'wp_smushit_data', $data );
382
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
 
384
  }
385
 
@@ -391,94 +435,10 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
391
  */
392
  function setup_global_stats( $force_update = false ) {
393
  global $wpsmush_stats;
394
- $this->total_count = $wpsmush_stats->total_count();
395
- $this->stats = $this->global_stats( $force_update );
396
- $this->smushed_count = ! empty( $this->smushed_attachments ) ? count( $this->smushed_attachments ) : 0;
397
- $this->remaining_count = $this->remaining_count();
398
- }
399
-
400
- /**
401
- * Check if form is submitted and process it
402
- *
403
- * @return null
404
- */
405
- function process_options() {
406
-
407
- if ( ! is_admin() ) {
408
- return false;
409
- }
410
-
411
- // we aren't saving options
412
- if ( ! isset( $_POST['wp_smush_options_nonce'] ) ) {
413
- return false;
414
- }
415
-
416
- // the nonce doesn't pan out
417
- if ( ! wp_verify_nonce( $_POST['wp_smush_options_nonce'], 'save_wp_smush_options' ) ) {
418
- return false;
419
- }
420
-
421
- //Store that we need not redirect again on plugin activation
422
- update_site_option( 'wp-smush-hide_smush_welcome', true );
423
-
424
- // var to temporarily assign the option value
425
- $setting = null;
426
-
427
- //Store Option Name and their values in an array
428
- $settings = array();
429
-
430
- // process each setting and update options
431
- foreach ( $this->settings as $name => $text ) {
432
-
433
- // formulate the index of option
434
- $opt_name = WP_SMUSH_PREFIX . $name;
435
-
436
- // get the value to be saved
437
- $setting = isset( $_POST[ $opt_name ] ) ? 1 : 0;
438
-
439
- $settings[ $opt_name ] = $setting;
440
-
441
- // update the new value
442
- update_option( $opt_name, $setting );
443
-
444
- // unset the var for next loop
445
- unset( $setting );
446
- }
447
-
448
- //Save the selected image sizes
449
- $image_sizes = !empty( $_POST['wp-smush-image_sizes'] ) ? $_POST['wp-smush-image_sizes'] : array();
450
- $image_sizes = array_filter( array_map("sanitize_text_field", $image_sizes ) );
451
- update_option( WP_SMUSH_PREFIX . 'image_sizes', $image_sizes );
452
-
453
- //Update Resize width and height settings if set
454
- $resize_sizes['width'] = isset( $_POST['wp-smush-resize_width'] ) ? intval( $_POST['wp-smush-resize_width'] ) : 0;
455
- $resize_sizes['height'] = isset( $_POST['wp-smush-resize_height'] ) ? intval( $_POST['wp-smush-resize_height'] ) : 0;
456
-
457
- // update the resize sizes
458
- update_option( WP_SMUSH_PREFIX . 'resize_sizes', $resize_sizes );
459
-
460
- //Transparent PNG Conversion settings
461
- $transparent_png['convert'] = isset( $_POST['wp-smush-png_to_jpg_transparent'] ) ? 1 : 0;
462
-
463
- //Validate Hexcode and Store it
464
- $transparent_png['background'] = isset( $_POST['wp-smush-png_to_jpg_background'] ) && ctype_xdigit( $_POST['wp-smush-png_to_jpg_background'] ) ? smush_sanitize_hex_color_no_hash( $_POST['wp-smush-png_to_jpg_background'] ) : 'ffffff';
465
-
466
- //If background is not set, or length is not proper
467
- if ( empty( $transparent_png['background'] ) || strlen( $transparent_png['background'] ) < 6 ) {
468
- $transparent_png['background'] = 'ffffff';
469
- }
470
-
471
- // update the Transparent PNG settings
472
- update_option( WP_SMUSH_PREFIX . 'transparent_png', $transparent_png );
473
-
474
- //Store the option in table
475
- update_option( 'wp-smush-settings_updated', 1 );
476
-
477
- //Delete Show Resmush option
478
- if ( isset( $_POST['wp-smush-keep_exif'] ) && ! isset( $_POST['wp-smush-original'] ) && ! isset( $_POST['wp-smush-lossy'] ) ) {
479
- //@todo: Update Resmush ids
480
- }
481
-
482
  }
483
 
484
  /**
@@ -510,6 +470,9 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
510
 
511
  /**
512
  * Processes the Smush request and sends back the next id for smushing
 
 
 
513
  */
514
  function process_smush_request() {
515
 
@@ -539,35 +502,63 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
539
  );
540
  }
541
 
 
542
  $send_error = false;
543
 
544
  $attachment_id = (int) ( $_REQUEST['attachment_id'] );
545
 
546
- $original_meta = wp_get_attachment_metadata( $attachment_id, true );
547
-
548
- //Resize the dimensions of the image
549
  /**
550
- * Filter whether the existing image should be resized or not
551
  *
552
- * @since 2.3
553
  *
554
- * @param bool $should_resize , Set to True by default
555
  *
556
- * @param $attachment_id Image Attachment ID
557
  *
558
  */
559
- if ( $should_resize = apply_filters( 'wp_smush_resize_media_image', true, $attachment_id ) ) {
560
- $updated_meta = $this->resize_image( $attachment_id, $original_meta );
561
- $original_meta = ! empty( $updated_meta ) ? $updated_meta : $original_meta;
562
- wp_update_attachment_metadata( $attachment_id, $original_meta );
563
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
564
 
565
- global $wpsmush_pngjpg;
566
 
567
- //Convert PNGs to JPG
568
- $original_meta = $wpsmush_pngjpg->png_to_jpg( $attachment_id, $original_meta );
569
 
570
- $smush = $WpSmush->resize_from_meta_data( $original_meta, $attachment_id );
 
 
 
 
 
571
 
572
  //Get the updated Global Stats
573
  $this->setup_global_stats( true );
@@ -576,7 +567,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
576
 
577
  $stats['total'] = $wpsmush_stats->total_count();
578
 
579
- if ( is_wp_error( $smush ) ) {
580
 
581
  $send_error = true;
582
 
@@ -585,7 +576,6 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
585
  if ( strpos( $error, 'timed out' ) ) {
586
  $error = esc_html__( "Smush request timed out, You can try setting a higher value for `WP_SMUSH_API_TIMEOUT`.", "wp-smushit" );
587
  }
588
- $error = '<p class="wp-smush-error-message">' . $error . '</p>';
589
  } else {
590
  //Check if a resmush request, update the resmush list
591
  if ( ! empty( $_REQUEST['is_bulk_resmush'] ) && 'false' != $_REQUEST['is_bulk_resmush'] && $_REQUEST['is_bulk_resmush'] ) {
@@ -600,16 +590,19 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
600
  $stats['super_smushed'] = $this->super_smushed;
601
  }
602
 
603
- $stats['tooltip_text'] = ! empty( $stats['total_images'] ) ? sprintf( esc_html__( "You've smushed %d images in total.", "wp-smushit" ), $stats['total_images'] ) : '';
 
 
 
604
 
605
  //Send ajax response
606
  $send_error ? wp_send_json_error( array(
607
- 'stats' => $stats,
608
- 'error_msg' => $error,
609
  'show_warning' => intval( $this->show_warning() )
610
 
611
  ) ) : wp_send_json_success( array(
612
- 'stats' => $stats,
613
  'show_warning' => intval( $this->show_warning() )
614
  ) );
615
 
@@ -633,8 +626,23 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
633
  wp_die( __( 'No attachment ID was provided.', 'wp-smushit' ) );
634
  }
635
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
636
  //Pass on the attachment id to smush single function
637
- $this->smush_single( $_GET['attachment_id'] );
638
  }
639
 
640
  /**
@@ -647,6 +655,20 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
647
  */
648
  function smush_single( $attachment_id, $return = false ) {
649
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
650
  global $WpSmush, $wpsmush_pngjpg;
651
 
652
  $attachment_id = absint( (int) ( $attachment_id ) );
@@ -670,6 +692,8 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
670
  //Get the button status
671
  $status = $WpSmush->set_status( $attachment_id, false, true );
672
 
 
 
673
  //Send Json response if we are not suppose to return the results
674
 
675
  /** Send stats **/
@@ -677,7 +701,9 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
677
  if ( $return ) {
678
  return array( 'error' => $smush->get_error_message() );
679
  } else {
680
- wp_send_json_error( array( 'error_msg' => '<p class="wp-smush-error-message">' . $smush->get_error_message() . '</p>', 'show_warning' => intval( $this->show_warning() ) ) );
 
 
681
  }
682
  } else {
683
  if ( $return ) {
@@ -843,12 +869,12 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
843
  if ( ! empty( $global_data ) ) {
844
  foreach ( $global_data as $data ) {
845
  $smush_data['id'][] = $data->post_id;
846
- if( !empty( $data->meta_value ) ) {
847
  $meta = maybe_unserialize( $data->meta_value );
848
  if ( ! empty( $meta['stats'] ) ) {
849
 
850
  //Check for lossy Compression
851
- if( 1 == $meta['stats']['lossy'] ) {
852
  $supersmushed_count += 1;
853
  }
854
  //Total Image Smushed
@@ -914,7 +940,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
914
  $smush_data['human'] = size_format( $smush_data['bytes'], 1 );
915
 
916
  //Setup Smushed attachment ids
917
- $this->smushed_attachments = !empty( $smush_data['id'] ) ? $smush_data['id'] : '';
918
 
919
  //Super Smushed attachment count
920
  $this->super_smushed = $supersmushed_count;
@@ -954,7 +980,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
954
  $smush_data['count'] = 0;
955
  $smush_data['total_images'] = 0;
956
 
957
- if( !empty( $this->smushed_attachments ) && is_array( $this->smushed_attachments ) ) {
958
  //Iterate over all the attachments
959
  foreach ( $this->smushed_attachments as $attachment ) {
960
  //Get all the Savings for each image
@@ -1099,7 +1125,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1099
  */
1100
  function settings_link( $links ) {
1101
 
1102
- $settings_page = admin_url( 'upload.php?page=wp-smush-bulk' );
1103
  $settings = '<a href="' . $settings_page . '">' . __( 'Settings', 'wp-smushit' ) . '</a>';
1104
 
1105
  //Added a fix for weird warning in multisite, "array_unshift() expects parameter 1 to be array, null given"
@@ -1281,12 +1307,34 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1281
  */
1282
  function scan_images() {
1283
 
1284
- global $WpSmush, $wpsmushnextgenadmin, $wpsmush_stats;
1285
 
1286
  check_ajax_referer( 'save_wp_smush_options', 'wp_smush_options_nonce' );
1287
 
1288
  $resmush_list = array();
1289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1290
  //Default Notice, to be displayed at the top of page
1291
  //Show a message, at the top
1292
  $message = esc_html__( 'Yay! All images are optimised as per your current settings.', 'wp-smushit' );
@@ -1300,9 +1348,6 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1300
  //If a user manually runs smush check
1301
  $return_ui = isset( $_REQUEST['get_ui'] ) && 'true' == $_REQUEST['get_ui'] ? true : false;
1302
 
1303
- //Save Settings
1304
- $this->process_options();
1305
-
1306
  //Update the variables
1307
  $WpSmush->initialise();
1308
 
@@ -1327,6 +1372,8 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1327
 
1328
  if ( 0 == $remaining_count && ! $WpSmush->lossy_enabled && ! $WpSmush->smush_original && $WpSmush->keep_exif && ! $upfront_active ) {
1329
  delete_option( $key );
 
 
1330
  wp_send_json_success( array( 'notice' => $resp ) );
1331
  }
1332
 
@@ -1377,7 +1424,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1377
  }
1378
 
1379
  //If Image needs to be resized
1380
- if( !$should_resmush ) {
1381
  /**
1382
  * Get the resize settings, get the image dimensions, and check if it needs to be resized
1383
  *
@@ -1385,9 +1432,9 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1385
  global $wpsmush_resize;
1386
  $should_resmush = $wpsmush_resize->should_resize( $attachment );
1387
  }
1388
-
1389
  //If image can be converted
1390
- if( !$should_resmush ) {
1391
  global $wpsmush_pngjpg;
1392
  $should_resmush = $wpsmush_pngjpg->can_be_converted( $attachment );
1393
  }
@@ -1486,6 +1533,9 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1486
  $return['super_smush_stats'] = sprintf( '<strong><span class="smushed-count">%d</span>/%d</strong>', $ss_count, $wpsmushnextgenadmin->total_count );
1487
  }
1488
 
 
 
 
1489
  wp_send_json_success( $return );
1490
 
1491
  }
@@ -1528,10 +1578,9 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1528
  function get_upfront_images( $skip_ids = array() ) {
1529
 
1530
  $query = array(
1531
- 'fields' => 'ids',
1532
  'post_type' => 'attachment',
1533
  'post_status' => 'any',
1534
- 'post_mime_type' => $this->mime_types,
1535
  'order' => 'ASC',
1536
  'posts_per_page' => - 1,
1537
  'meta_key' => 'upfront_used_image_sizes',
@@ -1546,7 +1595,8 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1546
  $results = new WP_Query( $query );
1547
 
1548
  if ( ! is_wp_error( $results ) && $results->post_count > 0 ) {
1549
- return $results->posts;
 
1550
  } else {
1551
  return false;
1552
  }
@@ -1693,9 +1743,9 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1693
  if ( method_exists( 'WDEV_Plugin_Ui', 'load' ) ) {
1694
 
1695
  //Load Shared UI
1696
- WDEV_Plugin_Ui::load( WP_SMUSH_URL . '/assets/shared-ui/', false );
1697
 
1698
- if ( ( 'media_page_wp-smush-bulk' != $current_page && 'gallery_page_wp-smush-nextgen-bulk' != $current_page ) ) {
1699
 
1700
  //Don't add thhe WPMUD class to body to other admin pages
1701
  remove_filter(
@@ -1827,16 +1877,9 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1827
  return true;
1828
  }
1829
 
1830
- //Do not show for new installations
1831
- $install_type = get_site_option( 'wp-smush-install-type', false );
1832
-
1833
- if ( ! $install_type || 'new' == $install_type ) {
1834
- return true;
1835
- }
1836
-
1837
  //Do not display the notice on Bulk Smush Screen
1838
  global $current_screen;
1839
- if ( ! empty( $current_screen->base ) && ( 'media_page_wp-smush-bulk' == $current_screen->base || 'gallery_page_wp-smush-nextgen-bulk' == $current_screen->base ) ) {
1840
  return true;
1841
  }
1842
 
@@ -1846,16 +1889,24 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1846
  array(
1847
  'utm_source' => 'Smush-Free',
1848
  'utm_medium' => 'Banner',
1849
- 'utm_campaign' => 'now-with-resizing'
1850
  ),
1851
  $this->upgrade_url
1852
  );
 
1853
 
1854
- $settings_link = '<a href="' . admin_url( 'upload.php?page=wp-smush-bulk#wp-smush-settings-box' ) . '" title="' . esc_html__( "Settings", "wp-smushit" ) . '">';
1855
  $upgrade_link = '<a href="' . esc_url( $upgrade_url ) . '" title="' . esc_html__( "WP Smush Pro", "wp-smushit" ) . '">';
 
 
 
 
 
 
 
1856
  ?>
1857
  <div class="notice notice-info is-dismissible wp-smush-update-info">
1858
- <p><?php printf( esc_html__( "Woohoo! Your latest Smush update %s allows you to %sauto resize%s all your images, how cool is that! %sFind out more here >>%s", 'wp-smushit' ), WP_SMUSH_VERSION, $settings_link, '</a>', $upgrade_link, '</a>' ); ?></p>
1859
  </div>
1860
 
1861
  <script src="<?php echo esc_url( $js_url ) . '?v=' . WP_SMUSH_VERSION; ?>"></script><?php
@@ -1870,13 +1921,14 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1870
  *
1871
  */
1872
  function skip_image_size ( $size = '' ) {
 
1873
 
1874
  //No image size specified, Don't skip
1875
  if( empty( $size ) ) {
1876
  return false;
1877
  }
1878
 
1879
- $image_sizes = get_option( WP_SMUSH_PREFIX.'image_sizes' );
1880
 
1881
  //If Images sizes aren't set, don't skip any of the image size
1882
  if( false === $image_sizes ) {
@@ -1949,6 +2001,76 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
1949
  echo $this->bulk_ui->get_user_validation_message( $notice = true );
1950
  }
1951
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1952
  }
1953
 
1954
  global $wpsmushit_admin;
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
  */
123
  // hook custom screen
124
  add_action( 'admin_menu', array( $this, 'screen' ) );
125
 
126
+ //Network Settings Page
127
+ add_action( 'network_admin_menu', array( $this, 'screen' ) );
128
+
129
  //Handle Smush Bulk Ajax
130
  add_action( 'wp_ajax_wp_smushit_bulk', array( $this, 'process_smush_request' ) );
131
 
135
  //Handle Restore operation
136
  add_action( 'wp_ajax_smush_resmush_image', array( $this, 'resmush_image' ) );
137
 
138
+ //Scan images as per the latest settings
139
  add_action( 'wp_ajax_scan_for_resmush', array( $this, 'scan_images' ) );
140
 
141
+ //Save Settings
142
+ add_action( 'wp_ajax_save_settings', array( $this, 'save_settings' ) );
143
+
144
  add_filter( 'plugin_action_links_' . WP_SMUSH_BASENAME, array(
145
  $this,
146
  'settings_link'
156
  add_action( 'admin_notices', array( $this, 'smush_upgrade' ) );
157
 
158
  // New Features Notice
159
+ add_action( 'admin_notices', array( $this, 'smush_updated' ) );
160
+ add_action( 'network_admin_notices', array( $this, 'smush_updated' ) );
161
 
162
  //Handle the smush pro dismiss features notice ajax
163
  add_action( 'wp_ajax_dismiss_upgrade_notice', array( $this, 'dismiss_upgrade_notice' ) );
187
 
188
  function init_settings() {
189
  $this->settings = array(
190
+ 'networkwide' => array(
191
+ 'label' => esc_html__( 'Enable Network wide settings', 'wp-smushit' ),
192
+ 'desc' => esc_html__( 'If disabled sub sites can override the individual Smush settings.', 'wp-smushit' )
193
+ ),
194
+ 'auto' => array(
195
  'label' => esc_html__( 'Automatically smush my images on upload', 'wp-smushit' ),
196
  'desc' => esc_html__( 'When you upload images to the media library, we’ll automatically optimize them.', 'wp-smushit' )
197
  ),
198
+ 'keep_exif' => array(
199
  'label' => esc_html__( 'Preserve image EXIF data', 'wp-smushit' ),
200
  'desc' => esc_html__( 'EXIF data stores camera settings, focal length, date, time and location information in image files. EXIF data makes image files larger but if you are a photographer you may want to preserve this information.', 'wp-smushit' )
201
  ),
202
+ 'resize' => array(
203
  'label' => esc_html__( 'Resize original images', 'wp-smushit' ),
204
  'desc' => esc_html__( 'Save a ton of space by not storing over-sized images on your server. Set image maximum width and height and large images will be automatically scaled before being added to the media library.', 'wp-smushit' )
205
  ),
206
+ 'lossy' => array(
207
  'label' => esc_html__( 'Super-smush my images', 'wp-smushit' ),
208
  'desc' => esc_html__( 'Compress images up to 2x more than regular smush with almost no visible drop in quality.', 'wp-smushit' )
209
  ),
210
+ 'original' => array(
211
  'label' => esc_html__( 'Include my original full-size images', 'wp-smushit' ),
212
  'desc' => esc_html__( 'WordPress crops and resizes every image you upload for embedding on your site. By default, Smush only compresses these cropped and resized images, not your original full-size images. To save space on your server, activate this setting to smush your original images, too. Note: This doesn’t usually improve page speed.', 'wp-smushit' )
213
  ),
214
+ 'backup' => array(
215
  'label' => esc_html__( 'Make a copy of my original images', 'wp-smushit' ),
216
  'desc' => esc_html__( 'Save your original full-size images so you can restore them at any point. Note: Activating this setting will significantly increase the size of your uploads folder by nearly twice as much.', 'wp-smushit' )
217
  ),
218
+ 'png_to_jpg' => array(
219
  'label' => esc_html__( 'Convert PNG to JPEG (lossy)', 'wp-smushit' ),
220
  'desc' => sprintf( esc_html__( "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.", 'wp-smushit' ), "<br />" )
221
  )
268
  'ui'
269
  ) );
270
 
271
+ $page = 'settings.php';
272
+ $cap = 'manage_network_options';
273
+
274
+ add_submenu_page( $page, 'WP Smush', 'WP Smush', $cap, 'wp-smush', array(
275
+ $this->bulk_ui,
276
+ 'ui'
277
+ ) );
278
+
279
  //For Nextgen gallery Pages, check later in enqueue function
280
  add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
281
 
304
  */
305
  function enqueue() {
306
 
 
 
307
  $current_screen = get_current_screen();
308
  $current_page = $current_screen->base;
309
 
312
  */
313
  $enqueue_smush = apply_filters( 'wp_smush_enqueue', true );
314
 
315
+ //Load js and css on all admin pages, in order t display install/upgrade notice
316
+ // And If upgrade/install message is dismissed or for pro users, Do not enqueue script
317
  if ( get_option( 'wp-smush-hide_upgrade_notice' ) || get_site_option( 'wp-smush-hide_upgrade_notice' ) || $this->validate_install() ) {
318
+ /** @var $pages List of screens where script needs to be loaded */
319
+
320
  //Do not enqueue, unless it is one of the required screen
321
+ if ( ! $enqueue_smush || ! in_array( $current_page, $this->pages ) ) {
322
 
323
  return;
324
  }
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();
372
  if ( $current_page == 'media_page_wp-smush-bulk' ) {
373
 
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();
411
 
412
  wp_localize_script( 'wp-smushit-admin-js', 'wp_smushit_data', $data );
413
 
414
+ //Check if settings were changed for a multisite, and localize whether to run re-check on page load
415
+ if ( is_multisite() && get_site_option( WP_SMUSH_PREFIX . 'networkwide' ) && ! is_network_admin() ) {
416
+ //Check the last settings stored in db
417
+ $settings = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'last_settings', '' );
418
+
419
+ //Get current settings
420
+ $c_settings = $this->get_serialised_settings();
421
+
422
+ //If not same, Set a variable to run re-check on page load
423
+ if( $settings != $c_settings ) {
424
+ wp_localize_script( 'wp-smushit-admin-js', 'wp_smush_run_re_check', array( 1 ) );
425
+ }
426
+ }
427
 
428
  }
429
 
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
 
444
  /**
470
 
471
  /**
472
  * Processes the Smush request and sends back the next id for smushing
473
+ *
474
+ * Bulk Smushing Handler
475
+ *
476
  */
477
  function process_smush_request() {
478
 
502
  );
503
  }
504
 
505
+ $error = '';
506
  $send_error = false;
507
 
508
  $attachment_id = (int) ( $_REQUEST['attachment_id'] );
509
 
 
 
 
510
  /**
511
+ * Filter: wp_smush_image
512
  *
513
+ * Whether to smush the given attachment id or not
514
  *
515
+ * @param $skip bool, whether to Smush image or not
516
  *
517
+ * @param $Attachment Id, Attachment id of the image being processed
518
  *
519
  */
520
+ if ( ! apply_filters( 'wp_smush_image', true, $attachment_id ) ) {
521
+ $send_error = true;
522
+ $error = esc_html__( "Attachment $attachment_id was skipped.", "wp-smushit" );
523
+ }
524
+
525
+ if ( ! $send_error ) {
526
+ //Proceed only if Smushing Transient is not set for the given attachment id
527
+ if ( ! get_transient( 'smush-in-progress-' . $attachment_id ) ) {
528
+
529
+ //Set a transient to avoid multiple request
530
+ set_transient( 'smush-in-progress-' . $attachment_id, true, 5 * MINUTE_IN_SECONDS );
531
+
532
+ $original_meta = wp_get_attachment_metadata( $attachment_id, true );
533
+
534
+ //Resize the dimensions of the image
535
+ /**
536
+ * Filter whether the existing image should be resized or not
537
+ *
538
+ * @since 2.3
539
+ *
540
+ * @param bool $should_resize , Set to True by default
541
+ *
542
+ * @param $attachment_id Image Attachment ID
543
+ *
544
+ */
545
+ if ( $should_resize = apply_filters( 'wp_smush_resize_media_image', true, $attachment_id ) ) {
546
+ $updated_meta = $this->resize_image( $attachment_id, $original_meta );
547
+ $original_meta = ! empty( $updated_meta ) ? $updated_meta : $original_meta;
548
+ wp_update_attachment_metadata( $attachment_id, $original_meta );
549
+ }
550
 
551
+ global $wpsmush_pngjpg;
552
 
553
+ //Convert PNGs to JPG
554
+ $original_meta = $wpsmush_pngjpg->png_to_jpg( $attachment_id, $original_meta );
555
 
556
+ $smush = $WpSmush->resize_from_meta_data( $original_meta, $attachment_id );
557
+ }
558
+
559
+ //Delete Transient
560
+ delete_transient( 'smush-in-progress-' . $attachment_id );
561
+ }
562
 
563
  //Get the updated Global Stats
564
  $this->setup_global_stats( true );
567
 
568
  $stats['total'] = $wpsmush_stats->total_count();
569
 
570
+ if ( isset( $smush ) && is_wp_error( $smush ) ) {
571
 
572
  $send_error = true;
573
 
576
  if ( strpos( $error, 'timed out' ) ) {
577
  $error = esc_html__( "Smush request timed out, You can try setting a higher value for `WP_SMUSH_API_TIMEOUT`.", "wp-smushit" );
578
  }
 
579
  } else {
580
  //Check if a resmush request, update the resmush list
581
  if ( ! empty( $_REQUEST['is_bulk_resmush'] ) && 'false' != $_REQUEST['is_bulk_resmush'] && $_REQUEST['is_bulk_resmush'] ) {
590
  $stats['super_smushed'] = $this->super_smushed;
591
  }
592
 
593
+ $stats['tooltip_text'] = ! empty( $stats['total_images'] ) ? sprintf( __( "You've smushed %d images in total.", "wp-smushit" ), $stats['total_images'] ) : '';
594
+
595
+ //Wrap the error message in div
596
+ $error = !empty( $error ) ? '<p class="wp-smush-error-message">' . $error . '</p>' : $error;
597
 
598
  //Send ajax response
599
  $send_error ? wp_send_json_error( array(
600
+ 'stats' => $stats,
601
+ 'error_msg' => $error,
602
  'show_warning' => intval( $this->show_warning() )
603
 
604
  ) ) : wp_send_json_success( array(
605
+ 'stats' => $stats,
606
  'show_warning' => intval( $this->show_warning() )
607
  ) );
608
 
626
  wp_die( __( 'No attachment ID was provided.', 'wp-smushit' ) );
627
  }
628
 
629
+ $attachemnt_id = intval( $_GET['attachment_id'] );
630
+
631
+ /**
632
+ * Filter: wp_smush_image
633
+ *
634
+ * Whether to smush the given attachment id or not
635
+ *
636
+ */
637
+ if ( ! apply_filters( 'wp_smush_image', true, $attachemnt_id ) ) {
638
+ wp_send_json_error( array(
639
+ 'error_msg' => '<p class="wp-smush-error-message">' . esc_html__( "Attachment Skipped - Check `wp_smush_image` filter.", "wp-smushit" ) . '</p>',
640
+ 'show_warning' => intval( $this->show_warning() )
641
+ ) );
642
+ }
643
+
644
  //Pass on the attachment id to smush single function
645
+ $this->smush_single( $attachemnt_id );
646
  }
647
 
648
  /**
655
  */
656
  function smush_single( $attachment_id, $return = false ) {
657
 
658
+ //If the smushing transient is already set, return the status
659
+ if ( get_transient( 'smush-in-progress-' . $attachment_id ) ) {
660
+ //Get the button status
661
+ $status = $this->set_status( $attachment_id, false, true );
662
+ if ( $return ) {
663
+ return $status;
664
+ } else {
665
+ wp_send_json_success( $status );
666
+ }
667
+ }
668
+
669
+ //Set a transient to avoid multiple request
670
+ set_transient( 'smush-in-progress-' . $attachment_id, true, 5 * MINUTE_IN_SECONDS );
671
+
672
  global $WpSmush, $wpsmush_pngjpg;
673
 
674
  $attachment_id = absint( (int) ( $attachment_id ) );
692
  //Get the button status
693
  $status = $WpSmush->set_status( $attachment_id, false, true );
694
 
695
+ delete_transient( 'smush-in-progress-' . $attachment_id );
696
+
697
  //Send Json response if we are not suppose to return the results
698
 
699
  /** Send stats **/
701
  if ( $return ) {
702
  return array( 'error' => $smush->get_error_message() );
703
  } else {
704
+ wp_send_json_error( array( 'error_msg' => '<p class="wp-smush-error-message">' . $smush->get_error_message() . '</p>',
705
+ 'show_warning' => intval( $this->show_warning() )
706
+ ) );
707
  }
708
  } else {
709
  if ( $return ) {
869
  if ( ! empty( $global_data ) ) {
870
  foreach ( $global_data as $data ) {
871
  $smush_data['id'][] = $data->post_id;
872
+ if ( ! empty( $data->meta_value ) ) {
873
  $meta = maybe_unserialize( $data->meta_value );
874
  if ( ! empty( $meta['stats'] ) ) {
875
 
876
  //Check for lossy Compression
877
+ if ( 1 == $meta['stats']['lossy'] ) {
878
  $supersmushed_count += 1;
879
  }
880
  //Total Image Smushed
940
  $smush_data['human'] = size_format( $smush_data['bytes'], 1 );
941
 
942
  //Setup Smushed attachment ids
943
+ $this->smushed_attachments = ! empty( $smush_data['id'] ) ? $smush_data['id'] : '';
944
 
945
  //Super Smushed attachment count
946
  $this->super_smushed = $supersmushed_count;
980
  $smush_data['count'] = 0;
981
  $smush_data['total_images'] = 0;
982
 
983
+ if ( ! empty( $this->smushed_attachments ) && is_array( $this->smushed_attachments ) ) {
984
  //Iterate over all the attachments
985
  foreach ( $this->smushed_attachments as $attachment ) {
986
  //Get all the Savings for each image
1125
  */
1126
  function settings_link( $links ) {
1127
 
1128
+ $settings_page = is_multisite() ? network_admin_url( 'settings.php?page=wp-smush' ) : admin_url( 'upload.php?page=wp-smush-bulk' );
1129
  $settings = '<a href="' . $settings_page . '">' . __( 'Settings', 'wp-smushit' ) . '</a>';
1130
 
1131
  //Added a fix for weird warning in multisite, "array_unshift() expects parameter 1 to be array, null given"
1307
  */
1308
  function scan_images() {
1309
 
1310
+ global $WpSmush, $wpsmushnextgenadmin, $wpsmush_stats, $wpsmush_settings;
1311
 
1312
  check_ajax_referer( 'save_wp_smush_options', 'wp_smush_options_nonce' );
1313
 
1314
  $resmush_list = array();
1315
 
1316
+ //Save settings only if networkwide settings are disabled
1317
+ if ( ( ! is_multisite() || ! $wpsmush_settings->is_network_enabled() ) && ( ! isset( $_REQUEST['process_settings'] ) || 'false' != $_REQUEST['process_settings'] ) ) {
1318
+ //Save Settings
1319
+ $wpsmush_settings->process_options();
1320
+ }
1321
+
1322
+ //If there aren't any images in the library, return the notice
1323
+ if ( 0 == $wpsmush_stats->total_count() ) {
1324
+ $notice = esc_html__( "We haven’t found any images in your media library yet so there’s no smushing to be done!", "wp-smushit" );
1325
+ $resp = '<div class="wp-smush-notice wp-smush-resmush-message" tabindex="0"><i class="dev-icon dev-icon-tick"></i> ' . $notice . '
1326
+ <i class="dev-icon dev-icon-cross"></i>
1327
+ </div>';
1328
+
1329
+ //Save serialized settings
1330
+ $this->save_serialized_settings();
1331
+
1332
+ wp_send_json_success( array(
1333
+ 'notice' => $resp,
1334
+ 'super_smush' => $WpSmush->lossy_enabled
1335
+ ) );
1336
+ }
1337
+
1338
  //Default Notice, to be displayed at the top of page
1339
  //Show a message, at the top
1340
  $message = esc_html__( 'Yay! All images are optimised as per your current settings.', 'wp-smushit' );
1348
  //If a user manually runs smush check
1349
  $return_ui = isset( $_REQUEST['get_ui'] ) && 'true' == $_REQUEST['get_ui'] ? true : false;
1350
 
 
 
 
1351
  //Update the variables
1352
  $WpSmush->initialise();
1353
 
1372
 
1373
  if ( 0 == $remaining_count && ! $WpSmush->lossy_enabled && ! $WpSmush->smush_original && $WpSmush->keep_exif && ! $upfront_active ) {
1374
  delete_option( $key );
1375
+ //Save serialized settings
1376
+ $this->save_serialized_settings();
1377
  wp_send_json_success( array( 'notice' => $resp ) );
1378
  }
1379
 
1424
  }
1425
 
1426
  //If Image needs to be resized
1427
+ if ( ! $should_resmush ) {
1428
  /**
1429
  * Get the resize settings, get the image dimensions, and check if it needs to be resized
1430
  *
1432
  global $wpsmush_resize;
1433
  $should_resmush = $wpsmush_resize->should_resize( $attachment );
1434
  }
1435
+
1436
  //If image can be converted
1437
+ if ( ! $should_resmush ) {
1438
  global $wpsmush_pngjpg;
1439
  $should_resmush = $wpsmush_pngjpg->can_be_converted( $attachment );
1440
  }
1533
  $return['super_smush_stats'] = sprintf( '<strong><span class="smushed-count">%d</span>/%d</strong>', $ss_count, $wpsmushnextgenadmin->total_count );
1534
  }
1535
 
1536
+ //Save serialized settings
1537
+ $this->save_serialized_settings();
1538
+
1539
  wp_send_json_success( $return );
1540
 
1541
  }
1578
  function get_upfront_images( $skip_ids = array() ) {
1579
 
1580
  $query = array(
1581
+ 'fields' => array( 'ids', 'post_mime_type' ),
1582
  'post_type' => 'attachment',
1583
  'post_status' => 'any',
 
1584
  'order' => 'ASC',
1585
  'posts_per_page' => - 1,
1586
  'meta_key' => 'upfront_used_image_sizes',
1595
  $results = new WP_Query( $query );
1596
 
1597
  if ( ! is_wp_error( $results ) && $results->post_count > 0 ) {
1598
+ $posts = $this->filter_by_mime( $results->posts );
1599
+ return $posts;
1600
  } else {
1601
  return false;
1602
  }
1743
  if ( method_exists( 'WDEV_Plugin_Ui', 'load' ) ) {
1744
 
1745
  //Load Shared UI
1746
+ WDEV_Plugin_Ui::load( WP_SMUSH_URL . 'assets/shared-ui/', false );
1747
 
1748
+ if ( ( 'settings_page_wp-smush-network' != $current_page && 'media_page_wp-smush-bulk' != $current_page && 'gallery_page_wp-smush-nextgen-bulk' != $current_page ) ) {
1749
 
1750
  //Don't add thhe WPMUD class to body to other admin pages
1751
  remove_filter(
1877
  return true;
1878
  }
1879
 
 
 
 
 
 
 
 
1880
  //Do not display the notice on Bulk Smush Screen
1881
  global $current_screen;
1882
+ if ( ! empty( $current_screen->base ) && ( 'media_page_wp-smush-bulk' == $current_screen->base || 'gallery_page_wp-smush-nextgen-bulk' == $current_screen->base || 'settings_page_wp-smush-network' == $current_screen->base ) ) {
1883
  return true;
1884
  }
1885
 
1889
  array(
1890
  'utm_source' => 'Smush-Free',
1891
  'utm_medium' => 'Banner',
1892
+ 'utm_campaign' => 'now-with-async'
1893
  ),
1894
  $this->upgrade_url
1895
  );
1896
+ $settings_link = is_multisite() ? network_admin_url( 'settings.php?page=wp-smush' ) : admin_url( 'upload.php?page=wp-smush-bulk' );
1897
 
1898
+ $settings_link = '<a href="' . $settings_link . '" title="' . esc_html__( "Review your setting now.", "wp-smushit" ) . '">';
1899
  $upgrade_link = '<a href="' . esc_url( $upgrade_url ) . '" title="' . esc_html__( "WP Smush Pro", "wp-smushit" ) . '">';
1900
+ $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>' );
1901
+
1902
+ //Message for network admin
1903
+ $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>' ) : '';
1904
+
1905
+ //Upgrade link for free users
1906
+ $message_s .= ! $this->validate_install() ? sprintf( esc_html__( " %sFind out more here >>%s", "wp-smushit" ), $upgrade_link, '</a>' ) : '';
1907
  ?>
1908
  <div class="notice notice-info is-dismissible wp-smush-update-info">
1909
+ <p><?php echo $message_s; ?></p>
1910
  </div>
1911
 
1912
  <script src="<?php echo esc_url( $js_url ) . '?v=' . WP_SMUSH_VERSION; ?>"></script><?php
1921
  *
1922
  */
1923
  function skip_image_size ( $size = '' ) {
1924
+ global $wpsmush_settings;
1925
 
1926
  //No image size specified, Don't skip
1927
  if( empty( $size ) ) {
1928
  return false;
1929
  }
1930
 
1931
+ $image_sizes = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX.'image_sizes' );
1932
 
1933
  //If Images sizes aren't set, don't skip any of the image size
1934
  if( false === $image_sizes ) {
2001
  echo $this->bulk_ui->get_user_validation_message( $notice = true );
2002
  }
2003
 
2004
+ /**
2005
+ * Save settings, Used for networkwide option
2006
+ */
2007
+ function save_settings() {
2008
+ //Validate Ajax request
2009
+ check_ajax_referer( 'save_wp_smush_options', 'nonce' );
2010
+
2011
+ global $wpsmush_settings;
2012
+ //Save Settings
2013
+ $wpsmush_settings->process_options();
2014
+ wp_send_json_success();
2015
+
2016
+ }
2017
+
2018
+ /**
2019
+ * Returns a serialised string of current settings
2020
+ *
2021
+ * @return Serialised string of settings
2022
+ *
2023
+ */
2024
+ function get_serialised_settings() {
2025
+ global $wpsmush_settings;
2026
+ $settings = array();
2027
+ foreach ( $this->settings as $key => $val ) {
2028
+ $settings[ $key ] = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . $key );
2029
+ }
2030
+ $settings = maybe_serialize( $settings );
2031
+
2032
+ return $settings;
2033
+ }
2034
+
2035
+ /**
2036
+ * Stores the latest settings in serialised form in DB For the current settings
2037
+ *
2038
+ * No need to store the serialised settings, if network wide settings is disabled
2039
+ * because the site would run the scan when settings are saved
2040
+ *
2041
+ */
2042
+ function save_serialized_settings() {
2043
+ //Return -> Single Site | If network settings page | Networkwide Settings Disabled
2044
+ if ( ! is_multisite() || is_network_admin() || ! get_site_option( WP_SMUSH_PREFIX . 'networkwide' ) ) {
2045
+ return;
2046
+ }
2047
+ global $wpsmush_settings;
2048
+ $c_settings = $this->get_serialised_settings();
2049
+ $wpsmush_settings->update_setting( WP_SMUSH_PREFIX . 'last_settings', $c_settings );
2050
+ }
2051
+
2052
+ /**
2053
+ * Filter the Posts object as per mime type
2054
+ *
2055
+ * @param $posts Object of Posts
2056
+ *
2057
+ * @return mixed array of post ids
2058
+ *
2059
+ */
2060
+ function filter_by_mime( $posts ) {
2061
+ if ( empty( $posts ) ) {
2062
+ return $posts;
2063
+ }
2064
+ foreach ( $posts as $post_k => $post ) {
2065
+ if ( ! isset( $post->post_mime_type ) || ! in_array( $post->post_mime_type, $this->mime_types ) ) {
2066
+ unset( $posts[ $post_k ] );
2067
+ } else {
2068
+ $posts[ $post_k ] = $post->ID;
2069
+ }
2070
+ }
2071
+ return $posts;
2072
+ }
2073
+
2074
  }
2075
 
2076
  global $wpsmushit_admin;
lib/class-wp-smush-async.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package WP Smush
4
+ * @subpackage Admin
5
+ * @since 2.5
6
+ *
7
+ * @author Umesh Kumar <umesh@incsub.com>
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;
19
+ /**
20
+ * Whenever a attachment metadata is generated
21
+ * Had to be hooked on generate and not update, else it goes in infinite loop
22
+ *
23
+ * @var string
24
+ */
25
+ protected $action = 'wp_generate_attachment_metadata';
26
+
27
+ /**
28
+ * Prepare data for the asynchronous request
29
+ *
30
+ * @throws Exception If for any reason the request should not happen
31
+ *
32
+ * @param array $data An array of data sent to the hook
33
+ *
34
+ * @return array
35
+ */
36
+ protected function prepare_data( $data ) {
37
+ //We don't have the data, bail out
38
+ if ( empty( $data ) ) {
39
+ return $data;
40
+ }
41
+
42
+ //Return a associative array
43
+ $image_meta = array();
44
+ $image_meta['metadata'] = ! empty( $data[0] ) ? $data[0] : '';
45
+ $image_meta['id'] = ! empty( $data[1] ) ? $data[1] : '';
46
+
47
+ return $image_meta;
48
+ }
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
+ */
56
+ protected function run_action() {
57
+
58
+ $metadata = ! empty( $_POST['metadata'] ) ? $_POST['metadata'] : '';
59
+ $id = ! empty( $_POST['id'] ) ? $_POST['id'] : '';
60
+
61
+ //Get metadata from $_POST
62
+ if ( ! empty( $metadata ) && wp_attachment_is_image( $id ) ) {
63
+ // Allow the Asynchronous task to run
64
+ do_action( "wp_async_$this->action", $id );
65
+ }
66
+ }
67
+
68
+ }
69
+
70
+ class WpSmushEditorAsync extends WP_Async_Task {
71
+
72
+ protected $argument_count = 2;
73
+ protected $priority = 12;
74
+ /**
75
+ * Whenever a attachment metadata is generated
76
+ * Had to be hooked on generate and not update, else it goes in infinite loop
77
+ *
78
+ * @var string
79
+ */
80
+ protected $action = 'wp_save_image_editor_file';
81
+
82
+ /**
83
+ * Prepare data for the asynchronous request
84
+ *
85
+ * @throws Exception If for any reason the request should not happen
86
+ *
87
+ * @param array $data An array of data sent to the hook
88
+ *
89
+ * @return array
90
+ */
91
+ protected function prepare_data( $data ) {
92
+ //Store the post data in $data variable
93
+ if ( ! empty( $data ) ) {
94
+ $data = array_merge( $data, $_POST );
95
+ }
96
+
97
+ //Store the image path
98
+ $data['filepath'] = !empty( $data[1] ) ? $data[1] : '';
99
+ $data['wp-action'] = !empty( $data['action'] ) ? $data['action'] : '';
100
+ unset( $data['action'], $data[1] );
101
+
102
+ return $data;
103
+ }
104
+
105
+ /**
106
+ * Run the async task action
107
+ * @todo: Add a check for image
108
+ * @todo: See if auto smush is enabled or not
109
+ * @todo: Check if async is enabled or not
110
+ */
111
+ protected function run_action() {
112
+
113
+ if ( isset( $_POST['wp-action'], $_POST['do'], $_POST['postid'] )
114
+ && 'image-editor' === $_POST['wp-action']
115
+ && check_ajax_referer( 'image_editor-' . $_POST['postid'] )
116
+ && 'open' != $_POST['do']
117
+ ) {
118
+ $postid = ! empty( $_POST['postid'] ) ? $_POST['postid'] : '';
119
+ // Allow the Asynchronous task to run
120
+ do_action( "wp_async_$this->action", $postid, $_POST );
121
+ }
122
+ }
123
+
124
+ }
125
+ }
lib/class-wp-smush-backup.php CHANGED
@@ -28,8 +28,11 @@ if ( ! class_exists( 'WpSmushBackup' ) ) {
28
  }
29
 
30
  function initialize() {
 
 
 
31
  //Whether backup is enabled or not
32
- $this->backup_enabled = get_option( WP_SMUSH_PREFIX . 'backup' );
33
  }
34
 
35
  function create_backup( $file_path = '', $backup_path = '' ) {
28
  }
29
 
30
  function initialize() {
31
+
32
+ global $wpsmush_settings;
33
+
34
  //Whether backup is enabled or not
35
+ $this->backup_enabled = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'backup' );
36
  }
37
 
38
  function create_backup( $file_path = '', $backup_path = '' ) {
lib/class-wp-smush-bulk.php CHANGED
@@ -35,10 +35,9 @@ if ( ! class_exists( 'WpSmushitBulk' ) ) {
35
  $get_posts = true;
36
  $unsmushed_posts = array();
37
  $args = array(
38
- 'fields' => 'ids',
39
  'post_type' => 'attachment',
40
  'post_status' => 'any',
41
- 'post_mime_type' => $wpsmushit_admin->mime_types,
42
  'orderby' => 'ID',
43
  'order' => 'DESC',
44
  'posts_per_page' => $limit,
@@ -62,8 +61,12 @@ if ( ! class_exists( 'WpSmushitBulk' ) ) {
62
  $query = new WP_Query( $args );
63
 
64
  if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
 
 
 
 
65
  //Merge the results
66
- $unsmushed_posts = array_merge( $unsmushed_posts, $query->posts );
67
 
68
  //Update the offset
69
  $args['offset'] += $limit;
35
  $get_posts = true;
36
  $unsmushed_posts = array();
37
  $args = array(
38
+ 'fields' => array( 'ids', 'post_mime_type' ),
39
  'post_type' => 'attachment',
40
  'post_status' => 'any',
 
41
  'orderby' => 'ID',
42
  'order' => 'DESC',
43
  'posts_per_page' => $limit,
61
  $query = new WP_Query( $args );
62
 
63
  if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
64
+
65
+ //Get a filtered list of post ids
66
+ $posts = $wpsmushit_admin->filter_by_mime( $query->posts );
67
+
68
  //Merge the results
69
+ $unsmushed_posts = array_merge( $unsmushed_posts, $posts );
70
 
71
  //Update the offset
72
  $args['offset'] += $limit;
lib/class-wp-smush-png_jpg.php CHANGED
@@ -120,16 +120,19 @@ if ( ! class_exists( 'WpSmushPngtoJpg' ) ) {
120
  */
121
  function should_convert( $id, $file ) {
122
 
 
 
123
  $should_convert = false;
124
 
125
  //Get the Transparency conversion settings
126
- $convert_png = get_option( WP_SMUSH_PREFIX . 'png_to_jpg', false );
 
127
  if ( ! $convert_png ) {
128
  return $should_convert;
129
  }
130
 
131
  //Whether to convert transparent images or not
132
- $transparent_settings = get_option( WP_SMUSH_PREFIX . 'transparent_png', false );
133
 
134
  $convert_transparent = $transparent_settings['convert'];
135
 
@@ -227,6 +230,8 @@ if ( ! class_exists( 'WpSmushPngtoJpg' ) ) {
227
  */
228
  function update_image_path( $id, $o_file, $n_file, $meta, $size_k, $o_type = 'conversion' ) {
229
 
 
 
230
  //Upload Directory
231
  $upload_dir = wp_upload_dir();
232
 
@@ -285,7 +290,7 @@ if ( ! class_exists( 'WpSmushPngtoJpg' ) ) {
285
  $wpdb->query( $query );
286
 
287
  //Delete the Original files if backup not enabled
288
- if ( 'conversion' == $o_type && ! get_option( WP_SMUSH_PREFIX . 'backup' ) ) {
289
  @unlink( $o_file );
290
  }
291
 
@@ -511,6 +516,9 @@ if ( ! class_exists( 'WpSmushPngtoJpg' ) ) {
511
  * @return array Savings and Updated Meta
512
  */
513
  function convert_tpng_to_jpg( $id = '', $file = '', $meta = '', $size = 'full' ) {
 
 
 
514
  $result = array(
515
  'meta' => $meta,
516
  'savings' => ''
@@ -538,7 +546,7 @@ if ( ! class_exists( 'WpSmushPngtoJpg' ) ) {
538
  //Updated File name
539
  $n_file = path_join( $n_file['dirname'], $n_file['filename'] );
540
 
541
- $transparent_png = get_option( WP_SMUSH_PREFIX . 'transparent_png' );
542
 
543
  /**
544
  * Filter Background Color for Transparent PNGs
120
  */
121
  function should_convert( $id, $file ) {
122
 
123
+ global $wpsmush_settings;
124
+
125
  $should_convert = false;
126
 
127
  //Get the Transparency conversion settings
128
+ $convert_png = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'png_to_jpg', false );
129
+
130
  if ( ! $convert_png ) {
131
  return $should_convert;
132
  }
133
 
134
  //Whether to convert transparent images or not
135
+ $transparent_settings = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'transparent_png', false );
136
 
137
  $convert_transparent = $transparent_settings['convert'];
138
 
230
  */
231
  function update_image_path( $id, $o_file, $n_file, $meta, $size_k, $o_type = 'conversion' ) {
232
 
233
+ global $wpsmush_settings;
234
+
235
  //Upload Directory
236
  $upload_dir = wp_upload_dir();
237
 
290
  $wpdb->query( $query );
291
 
292
  //Delete the Original files if backup not enabled
293
+ if ( 'conversion' == $o_type && ! $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'backup' ) ) {
294
  @unlink( $o_file );
295
  }
296
 
516
  * @return array Savings and Updated Meta
517
  */
518
  function convert_tpng_to_jpg( $id = '', $file = '', $meta = '', $size = 'full' ) {
519
+
520
+ global $wpsmush_settings;
521
+
522
  $result = array(
523
  'meta' => $meta,
524
  'savings' => ''
546
  //Updated File name
547
  $n_file = path_join( $n_file['dirname'], $n_file['filename'] );
548
 
549
+ $transparent_png = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'transparent_png' );
550
 
551
  /**
552
  * Filter Background Color for Transparent PNGs
lib/class-wp-smush-resize.php CHANGED
@@ -36,7 +36,7 @@ if ( ! class_exists( 'WpSmushResize' ) ) {
36
  /**
37
  * Initialize class variables, after all stuff has been loaded
38
  */
39
- add_action( 'wp_loaded', array( $this, 'initialize' ) );
40
 
41
  }
42
 
@@ -44,10 +44,26 @@ if ( ! class_exists( 'WpSmushResize' ) ) {
44
  * Get the settings for resizing
45
  */
46
  function initialize() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  //If resizing is enabled
48
- $this->resize_enabled = get_option( WP_SMUSH_PREFIX . 'resize' );
49
 
50
- $resize_sizes = get_option( WP_SMUSH_PREFIX . 'resize_sizes', array() );
51
 
52
  //Resize width and Height
53
  $this->max_w = ! empty( $resize_sizes['width'] ) ? $resize_sizes['width'] : 0;
@@ -86,7 +102,7 @@ if ( ! class_exists( 'WpSmushResize' ) ) {
86
  }
87
 
88
  //Check for a supported mime type
89
- global $wpsmushit_admin;
90
 
91
  //Get image mime type
92
  $mime = get_post_mime_type( $id );
@@ -107,11 +123,11 @@ if ( ! class_exists( 'WpSmushResize' ) ) {
107
  //Get attachment metadata
108
  $meta = empty( $meta ) ? wp_get_attachment_metadata( $id ) : $meta;
109
 
110
- if( !empty( $meta['width'] ) && !empty( $meta['height'] ) ) {
111
  $oldW = $meta['width'];
112
  $oldH = $meta['height'];
113
 
114
- $resize_dim = get_option( WP_SMUSH_PREFIX . 'resize_sizes' );
115
 
116
  $maxW = ! empty( $resize_dim['width'] ) ? $resize_dim['width'] : 0;
117
  $maxH = ! empty( $resize_dim['height'] ) ? $resize_dim['height'] : 0;
@@ -190,7 +206,7 @@ if ( ! class_exists( 'WpSmushResize' ) ) {
190
  //Updated File size
191
  $u_file_size = filesize( $file_path );
192
 
193
- $savings['bytes'] = $original_file_size > $u_file_size ? $original_file_size - $u_file_size : 0;
194
  $savings['size_before'] = $original_file_size;
195
  $savings['size_after'] = $u_file_size;
196
 
@@ -270,7 +286,7 @@ if ( ! class_exists( 'WpSmushResize' ) ) {
270
  $file_size = filesize( $resize_path );
271
  if ( $file_size > $original_file_size ) {
272
  //Don't Unlink for nextgen images
273
- if( $unlink ) {
274
  $this->maybe_unlink( $resize_path, $meta );
275
  }
276
 
36
  /**
37
  * Initialize class variables, after all stuff has been loaded
38
  */
39
+ add_action( 'admin_init', array( $this, 'initialize' ) );
40
 
41
  }
42
 
44
  * Get the settings for resizing
45
  */
46
  function initialize() {
47
+ //Do not initialize unless in the WP Backend Or On one of the smush pages
48
+ if ( ! is_user_logged_in() || ! is_admin() ) {
49
+ return;
50
+ }
51
+
52
+ global $wpsmush_settings, $wpsmushit_admin;
53
+ $current_screen = get_current_screen();
54
+
55
+ if( !empty( $current_screen ) ) {
56
+ //Do not Proceed if not on one of the required screens
57
+ $current_page = $current_screen->base;
58
+ if ( ! in_array( $current_page, $wpsmushit_admin->pages ) ) {
59
+ return;
60
+ }
61
+ }
62
+
63
  //If resizing is enabled
64
+ $this->resize_enabled = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'resize' );
65
 
66
+ $resize_sizes = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'resize_sizes', array() );
67
 
68
  //Resize width and Height
69
  $this->max_w = ! empty( $resize_sizes['width'] ) ? $resize_sizes['width'] : 0;
102
  }
103
 
104
  //Check for a supported mime type
105
+ global $wpsmushit_admin, $wpsmush_settings;
106
 
107
  //Get image mime type
108
  $mime = get_post_mime_type( $id );
123
  //Get attachment metadata
124
  $meta = empty( $meta ) ? wp_get_attachment_metadata( $id ) : $meta;
125
 
126
+ if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
127
  $oldW = $meta['width'];
128
  $oldH = $meta['height'];
129
 
130
+ $resize_dim = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'resize_sizes' );
131
 
132
  $maxW = ! empty( $resize_dim['width'] ) ? $resize_dim['width'] : 0;
133
  $maxH = ! empty( $resize_dim['height'] ) ? $resize_dim['height'] : 0;
206
  //Updated File size
207
  $u_file_size = filesize( $file_path );
208
 
209
+ $savings['bytes'] = $original_file_size > $u_file_size ? $original_file_size - $u_file_size : 0;
210
  $savings['size_before'] = $original_file_size;
211
  $savings['size_after'] = $u_file_size;
212
 
286
  $file_size = filesize( $resize_path );
287
  if ( $file_size > $original_file_size ) {
288
  //Don't Unlink for nextgen images
289
+ if ( $unlink ) {
290
  $this->maybe_unlink( $resize_path, $meta );
291
  }
292
 
lib/class-wp-smush-settings.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! class_exists( 'WpSmushSettings' ) ) {
4
+ class WpSmushSettings {
5
+
6
+ function __construct() {
7
+ }
8
+
9
+ /**
10
+ * Check if form is submitted and process it
11
+ *
12
+ * @return null
13
+ */
14
+ function process_options() {
15
+
16
+ if ( ! is_user_logged_in() ) {
17
+ return false;
18
+ }
19
+
20
+ global $wpsmushit_admin, $wpsmush_settings;
21
+
22
+ //Store that we need not redirect again on plugin activation
23
+ update_site_option( 'wp-smush-hide_smush_welcome', true );
24
+
25
+ // var to temporarily assign the option value
26
+ $setting = null;
27
+
28
+ //Store Option Name and their values in an array
29
+ $settings = array();
30
+
31
+ //Save whether to use the settings networkwide or not ( Only if in network admin )
32
+ if ( ! empty( $_POST['action'] ) && 'save_settings' == $_POST['action'] ) {
33
+ if ( ! isset( $_POST['wp-smush-networkwide'] ) ) {
34
+ //Save the option to disable nwtwork wide settings and return
35
+ update_site_option( WP_SMUSH_PREFIX . 'networkwide', 0 );
36
+ } else {
37
+ //Save the option to disable nwtwork wide settings and return
38
+ update_site_option( WP_SMUSH_PREFIX . 'networkwide', 1 );
39
+ }
40
+ }
41
+
42
+ // process each setting and update options
43
+ foreach ( $wpsmushit_admin->settings as $name => $text ) {
44
+
45
+ // formulate the index of option
46
+ $opt_name = WP_SMUSH_PREFIX . $name;
47
+
48
+ // get the value to be saved
49
+ $setting = isset( $_POST[ $opt_name ] ) ? 1 : 0;
50
+
51
+ $settings[ $opt_name ] = $setting;
52
+
53
+ // update the new value
54
+ $wpsmush_settings->update_setting( $opt_name, $setting );
55
+
56
+ // unset the var for next loop
57
+ unset( $setting );
58
+ }
59
+
60
+ //Save the selected image sizes
61
+ $image_sizes = ! empty( $_POST['wp-smush-image_sizes'] ) ? $_POST['wp-smush-image_sizes'] : array();
62
+ $image_sizes = array_filter( array_map( "sanitize_text_field", $image_sizes ) );
63
+ $wpsmush_settings->update_setting( WP_SMUSH_PREFIX . 'image_sizes', $image_sizes );
64
+
65
+ //Update Resize width and height settings if set
66
+ $resize_sizes['width'] = isset( $_POST['wp-smush-resize_width'] ) ? intval( $_POST['wp-smush-resize_width'] ) : 0;
67
+ $resize_sizes['height'] = isset( $_POST['wp-smush-resize_height'] ) ? intval( $_POST['wp-smush-resize_height'] ) : 0;
68
+
69
+ // update the resize sizes
70
+ $wpsmush_settings->update_setting( WP_SMUSH_PREFIX . 'resize_sizes', $resize_sizes );
71
+
72
+ //Store the option in table
73
+ $wpsmush_settings->update_setting( 'wp-smush-settings_updated', 1 );
74
+
75
+ //Delete Show Resmush option
76
+ if ( isset( $_POST['wp-smush-keep_exif'] ) && ! isset( $_POST['wp-smush-original'] ) && ! isset( $_POST['wp-smush-lossy'] ) ) {
77
+ //@todo: Update Resmush ids
78
+ }
79
+
80
+ }
81
+
82
+ /**
83
+ * Checks whether the settings are applicable for the whole network/site or Sitewise ( Multisite )
84
+ * @todo: Check in subdirectory installation as well
85
+ */
86
+ function is_network_enabled() {
87
+ //If Single site return true
88
+ if ( ! is_multisite() ) {
89
+ return true;
90
+ }
91
+
92
+ //Check if the settings are network wide or site wise
93
+ $networkwide = get_site_option( WP_SMUSH_PREFIX . 'networkwide', true );
94
+ if ( $networkwide ) {
95
+ return true;
96
+ }
97
+
98
+ return false;
99
+ }
100
+
101
+ /**
102
+ * Returns the value of given setting key, based on if network settings are enabled or not
103
+ *
104
+ * @param string $name Setting to fetch
105
+ * @param string $default Default Value
106
+ *
107
+ * @return bool|mixed|void
108
+ *
109
+ */
110
+ function get_setting( $name = '', $default = '' ) {
111
+
112
+ if( empty( $name ) ) {
113
+ return false;
114
+ }
115
+
116
+ return $this->is_network_enabled() ? get_site_option( $name, $default ) : get_option( $name, $default );
117
+ }
118
+
119
+ /**
120
+ * Update value for given setting key
121
+ *
122
+ * @param string $name Key
123
+ * @param string $value Value
124
+ *
125
+ * @return bool If the setting was updated or not
126
+ */
127
+ function update_setting( $name = '', $value = '' ) {
128
+
129
+ if( empty( $name ) ) {
130
+ return false;
131
+ }
132
+
133
+ return $this->is_network_enabled() ? update_site_option( $name, $value ) : update_option( $name, $value );
134
+ }
135
+
136
+ /**
137
+ * Delete the given key name
138
+ *
139
+ * @param string $name Key
140
+ *
141
+ * @return bool If the setting was updated or not
142
+ */
143
+ function delete_setting( $name = '' ) {
144
+
145
+ if( empty( $name ) ) {
146
+ return false;
147
+ }
148
+
149
+ return $this->is_network_enabled() ? delete_site_option( $name ) : delete_option( $name );
150
+ }
151
+
152
+ }
153
+ global $wpsmush_settings;
154
+ $wpsmush_settings = new WpSmushSettings();
155
+ }
lib/class-wp-smush-stats.php CHANGED
@@ -60,10 +60,9 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
60
  }
61
 
62
  $query = array(
63
- 'fields' => 'ids',
64
  'post_type' => 'attachment',
65
  'post_status' => 'inherit',
66
- 'post_mime_type' => $wpsmushit_admin->mime_types,
67
  'order' => 'ASC',
68
  'posts_per_page' => - 1,
69
  'meta_key' => 'wp-smpro-smush-data',
@@ -76,12 +75,15 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
76
  $results = new WP_Query( $query );
77
 
78
  if ( ! is_wp_error( $results ) && $results->post_count > 0 ) {
 
 
 
79
  if ( ! $return_ids ) {
80
  //return Post Count
81
- return $results->post_count;
82
  } else {
83
  //Return post ids
84
- return $results->posts;
85
  }
86
  } else {
87
  return false;
@@ -168,8 +170,9 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
168
  *
169
  */
170
  function media_super_smush_count( $return_ids = false ) {
 
171
  global $wpsmushit_admin;
172
- $lossy_update = false;
173
  //Check if we have updated the stats for existing images, One time
174
  if ( ! $lossy_updated = get_option( WP_SMUSH_PREFIX . 'lossy-updated' ) ) {
175
 
@@ -181,15 +184,15 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
181
  }
182
  }
183
  }
 
184
  //Get all the attachments with wp-smush-lossy
185
  $limit = $wpsmushit_admin->query_limit();
186
  $get_posts = true;
187
  $super_smushed = array();
188
- $args = array(
189
- 'fields' => 'ids',
190
  'post_type' => 'attachment',
191
  'post_status' => 'any',
192
- 'post_mime_type' => $wpsmushit_admin->mime_types,
193
  'orderby' => 'ID',
194
  'order' => 'DESC',
195
  'posts_per_page' => $limit,
@@ -212,8 +215,9 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
212
  $query = new WP_Query( $args );
213
 
214
  if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
 
215
  //Merge the results
216
- $super_smushed = array_merge( $super_smushed, $query->posts );
217
 
218
  //Update the offset
219
  $args['offset'] += $limit;
@@ -419,10 +423,9 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
419
  $get_posts = true;
420
  $resized_images = array();
421
  $args = array(
422
- 'fields' => 'ids',
423
  'post_type' => 'attachment',
424
  'post_status' => 'inherit',
425
- 'post_mime_type' => $wpsmushit_admin->mime_types,
426
  'orderby' => 'ID',
427
  'order' => 'DESC',
428
  'posts_per_page' => $limit,
@@ -440,8 +443,11 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
440
  $query = new WP_Query( $args );
441
 
442
  if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
 
 
 
443
  //Merge the results
444
- $resized_images = array_merge( $resized_images, $query->posts );
445
 
446
  //Update the offset
447
  $args['offset'] += $limit;
@@ -472,10 +478,9 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
472
  $get_posts = true;
473
  $converted_images = array();
474
  $args = array(
475
- 'fields' => 'ids',
476
  'post_type' => 'attachment',
477
  'post_status' => 'inherit',
478
- 'post_mime_type' => $wpsmushit_admin->mime_types,
479
  'orderby' => 'ID',
480
  'order' => 'DESC',
481
  'posts_per_page' => $limit,
@@ -493,8 +498,12 @@ if ( ! class_exists( 'WpSmushStats' ) ) {
493
  $query = new WP_Query( $args );
494
 
495
  if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
 
 
 
 
496
  //Merge the results
497
- $converted_images = array_merge( $converted_images, $query->posts );
498
 
499
  //Update the offset
500
  $args['offset'] += $limit;
60
  }
61
 
62
  $query = array(
63
+ 'fields' => array( 'ids', 'post_mime_type' ) ,
64
  'post_type' => 'attachment',
65
  'post_status' => 'inherit',
 
66
  'order' => 'ASC',
67
  'posts_per_page' => - 1,
68
  'meta_key' => 'wp-smpro-smush-data',
75
  $results = new WP_Query( $query );
76
 
77
  if ( ! is_wp_error( $results ) && $results->post_count > 0 ) {
78
+
79
+ $posts = $wpsmushit_admin->filter_by_mime( $results->posts );
80
+
81
  if ( ! $return_ids ) {
82
  //return Post Count
83
+ return count( $posts );
84
  } else {
85
  //Return post ids
86
+ return $posts;
87
  }
88
  } else {
89
  return false;
170
  *
171
  */
172
  function media_super_smush_count( $return_ids = false ) {
173
+
174
  global $wpsmushit_admin;
175
+
176
  //Check if we have updated the stats for existing images, One time
177
  if ( ! $lossy_updated = get_option( WP_SMUSH_PREFIX . 'lossy-updated' ) ) {
178
 
184
  }
185
  }
186
  }
187
+
188
  //Get all the attachments with wp-smush-lossy
189
  $limit = $wpsmushit_admin->query_limit();
190
  $get_posts = true;
191
  $super_smushed = array();
192
+ $args = array(
193
+ 'fields' => array( 'ids', 'post_mime_type' ),
194
  'post_type' => 'attachment',
195
  'post_status' => 'any',
 
196
  'orderby' => 'ID',
197
  'order' => 'DESC',
198
  'posts_per_page' => $limit,
215
  $query = new WP_Query( $args );
216
 
217
  if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
218
+ $posts = $wpsmushit_admin->filter_by_mime( $query->posts );
219
  //Merge the results
220
+ $super_smushed = array_merge( $super_smushed, $posts );
221
 
222
  //Update the offset
223
  $args['offset'] += $limit;
423
  $get_posts = true;
424
  $resized_images = array();
425
  $args = array(
426
+ 'fields' => array( 'ids', 'post_mime_type' ),
427
  'post_type' => 'attachment',
428
  'post_status' => 'inherit',
 
429
  'orderby' => 'ID',
430
  'order' => 'DESC',
431
  'posts_per_page' => $limit,
443
  $query = new WP_Query( $args );
444
 
445
  if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
446
+
447
+ $posts = $wpsmushit_admin->filter_by_mime( $query->posts );
448
+
449
  //Merge the results
450
+ $resized_images = array_merge( $resized_images, $posts );
451
 
452
  //Update the offset
453
  $args['offset'] += $limit;
478
  $get_posts = true;
479
  $converted_images = array();
480
  $args = array(
481
+ 'fields' => array( 'ids', 'post_mime_type' ),
482
  'post_type' => 'attachment',
483
  'post_status' => 'inherit',
 
484
  'orderby' => 'ID',
485
  'order' => 'DESC',
486
  'posts_per_page' => $limit,
498
  $query = new WP_Query( $args );
499
 
500
  if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
501
+
502
+ //Filter Posts by mime types
503
+ $posts = $wpsmushit_admin->filter_by_mime( $query->posts );
504
+
505
  //Merge the results
506
+ $converted_images = array_merge( $converted_images, $posts );
507
 
508
  //Update the offset
509
  $args['offset'] += $limit;
lib/class-wp-smush-ui.php CHANGED
@@ -34,7 +34,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
34
  return '';
35
  }
36
  echo '<section class="dev-box ' . $classes . ' wp-smush-container" id="' . $id . '">'; ?>
37
- <div class="wp-smush-container-header box-title" xmlns="http://www.w3.org/1999/html">
38
  <h3 tabindex="0"><?php echo $heading ?></h3><?php
39
  //Sub Heading
40
  if ( ! empty( $sub_heading ) ) { ?>
@@ -110,7 +110,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
110
  * Outputs the Smush stats for the site
111
  */
112
  function smush_stats_container() {
113
- global $WpSmush, $wpsmushit_admin, $wpsmush_stats;
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;
@@ -120,7 +120,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
120
  $this->container_header( 'smush-stats-wrapper', 'wp-smush-stats-box', esc_html__( "STATS", "wp-smushit" ), $button );
121
  $dasharray = 125.663706144;
122
  $dash_offset = $wpsmushit_admin->total_count > 0 ? $dasharray - ( $dasharray * ( $smushed_count / $wpsmushit_admin->total_count) ) : $dasharray;
123
- $tooltip = $wpsmushit_admin->stats['total_images'] > 0 ? 'tooltip="' . sprintf( esc_html__(" You've smushed %d images in total", "wp-smushit"), $wpsmushit_admin->stats['total_images'] ) . '"' : ''; ?>
124
  <div class="box-content">
125
  <div class="row smush-total-savings smush-total-reduction-percent">
126
 
@@ -184,7 +184,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
184
  if( !empty( $wpsmushit_admin->stats['resize_savings'] ) && $wpsmushit_admin->stats['resize_savings'] > 0 ) {
185
  echo $wpsmushit_admin->stats['resize_savings'];
186
  }else{
187
- if( !get_option( WP_SMUSH_PREFIX . 'resize' ) ) {
188
  //If Not enabled, Add a enable button
189
  printf( esc_html__( "%sENABLE%s", "wp-smushit" ), '<button class="wp-smush-resize-enable button button-small">', '</button>' );
190
  }else{
@@ -253,26 +253,19 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
253
  * Outputs the advanced settings for Pro users, Disabled for basic users by default
254
  */
255
  function advanced_settings( $configure_screen = false ) {
256
- global $WpSmush, $wpsmushit_admin;
257
 
258
  //Content for the End of box container
259
- $div_end =
260
- wp_nonce_field( 'save_wp_smush_options', 'wp_smush_options_nonce', '', false ) .
261
- '<div class="wp-smush-submit-wrap">
262
- <input type="submit" id="wp-smush-save-settings" class="button button-grey"
263
- value="' . esc_html__( 'UPDATE SETTINGS', 'wp-smushit' ) . '">
264
- <span class="spinner"></span>
265
- </div>
266
- </form>';
267
- //For Configuration screen we need to show the advanced settings in single box
268
- if ( ! $configure_screen ) {
269
- $div_end .= '</div><!-- Box Content -->
270
- </section><!-- Main Section -->';
271
- }
272
 
273
  //For Basic User, Show advanced settings in a separate box
274
  if ( ! $WpSmush->validate_install() ) {
275
  echo $div_end;
 
 
 
 
 
276
  $upgrade_url = add_query_arg(
277
  array(
278
  'utm_source' => 'Smush-Free',
@@ -300,13 +293,11 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
300
  echo "<hr />";
301
  }
302
 
303
- $transparent_png = get_option( WP_SMUSH_PREFIX . 'transparent_png', array('convert' => '', 'background' => '' ) );
304
-
305
  //Iterate Over all the available settings, and print a row for each of them
306
  foreach ( $pro_settings as $setting_key ) {
307
  if ( isset( $wpsmushit_admin->settings[ $setting_key ] ) ) {
308
  $setting_m_key = WP_SMUSH_PREFIX . $setting_key;
309
- $setting_val = $WpSmush->validate_install() ? get_option( $setting_m_key, false ) : 0; ?>
310
  <div class='wp-smush-setting-row wp-smush-advanced'>
311
  <label class="inline-label" for="<?php echo $setting_m_key; ?>" tabindex="0">
312
  <span
@@ -334,13 +325,17 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
334
  echo "</div><!-- Box Content -->
335
  </section><!-- Main Section -->";
336
  }
 
 
 
 
337
  }
338
 
339
  /**
340
  * Process and display the options form
341
  */
342
  function options_ui( $configure_screen = false ) {
343
- global $wpsmushit_admin;
344
  echo '<div class="box-container">
345
  <form id="wp-smush-settings-form" method="post">';
346
 
@@ -350,10 +345,14 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
350
  //Placeholder width and Height
351
  $p_width = $p_height = 2048;
352
 
 
 
 
 
353
  //Smush auto key
354
  $opt_auto = WP_SMUSH_PREFIX . 'auto';
355
  //Auto value
356
- $opt_auto_val = get_option( $opt_auto, false );
357
 
358
  //If value is not set for auto smushing set it to 1
359
  if ( $opt_auto_val === false ) {
@@ -363,104 +362,135 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
363
 
364
  //Keep Exif
365
  $opt_keep_exif = WP_SMUSH_PREFIX . 'keep_exif';
366
- $opt_keep_exif_val = get_option( $opt_keep_exif, false );
367
 
368
  //Resize images
369
  $opt_resize = WP_SMUSH_PREFIX . 'resize';
370
- $opt_resize_val = get_option( $opt_resize, false );
371
 
372
  //Dimensions
373
- $resize_sizes = get_option( WP_SMUSH_PREFIX . 'resize_sizes', array( 'width' => '', 'height' => '' ) );
374
 
375
  //Additional Image sizes
376
- $image_sizes = get_option( WP_SMUSH_PREFIX . 'image_sizes' );
377
  $sizes = $wpsmushit_admin->image_dimensions();
378
- ?>
379
-
380
- <!-- A tab index of 0 keeps the element in tab flow with other elements with an unspecified tab index which are still tabbable.) -->
381
- <div class='wp-smush-setting-row wp-smush-basic'>
382
- <label class="inline-label" for="<?php echo $opt_auto; ?>" tabindex="0">
383
- <span class="wp-smush-setting-label">
384
- <?php echo $wpsmushit_admin->settings['auto']['label']; ?>
385
- </span><br/>
386
- <small class="smush-setting-description">
387
- <?php echo $wpsmushit_admin->settings['auto']['desc']; ?>
388
- </small>
389
- </label>
390
- <span class="toggle float-r">
391
- <input type="checkbox" class="toggle-checkbox"
392
- id="<?php echo $opt_auto; ?>"
393
- name="<?php echo $opt_auto; ?>" <?php checked( $opt_auto_val, 1, true ); ?> value="1" tabindex="0">
394
- <label class="toggle-label" for="<?php echo $opt_auto; ?>"></label>
395
- </span><?php
396
- if( !empty( $sizes ) ) { ?>
397
- <!-- List of image sizes recognised by WP Smush -->
398
- <div class="wp-smush-image-size-list">
399
- <p><?php esc_html_e("The Following image sizes will be optimised by WP Smush:", "wp-smushit"); ?></p><?php
400
- foreach ( $sizes as $size_k => $size ) {
401
- if( 'medium_large' == $size_k ) {
402
- continue;
403
- }
404
- //If image sizes array isn't set, mark all checked ( Default Values )
405
- if ( false === $image_sizes ) {
406
- $checked = true;
407
- }else{
408
- $checked = is_array( $image_sizes ) ? in_array( $size_k, $image_sizes ) : false;
409
- } ?>
410
- <label>
411
- <input type="checkbox" id="wp-smush-size-<?php echo $size_k; ?>" <?php checked( $checked, true ); ?> name="wp-smush-image_sizes[]" value="<?php echo $size_k; ?>"><?php
412
- echo $size_k . " (" . $size['width'] . "x" . $size['height'] . ") "; ?>
413
- </label><?php
414
- } ?>
415
- </div><?php
416
- } ?>
417
- </div>
418
- <hr/>
419
- <div class='wp-smush-setting-row wp-smush-basic'>
420
- <label class="inline-label" for="<?php echo $opt_keep_exif; ?>" tabindex="0">
421
- <span class="wp-smush-setting-label"><?php echo $wpsmushit_admin->settings['keep_exif']['label']; ?></span>
422
- <br/>
423
- <small class="smush-setting-description">
424
- <?php echo $wpsmushit_admin->settings['keep_exif']['desc']; ?>
425
- </small>
426
- </label>
427
- <span class="toggle float-r">
428
- <input type="checkbox" class="toggle-checkbox"
429
- id="<?php echo $opt_keep_exif; ?>" <?php checked( $opt_keep_exif_val, 1, true ); ?>
430
- value="1" name="<?php echo $opt_keep_exif; ?>" tabindex="0">
431
- <label class="toggle-label" for="<?php echo $opt_keep_exif; ?>"></label>
432
- </span>
433
- </div>
434
- <hr/>
435
- <div class='wp-smush-setting-row wp-smush-basic'>
436
- <label class="inline-label" for="<?php echo $opt_resize; ?>" tabindex="0">
437
- <span class="wp-smush-setting-label"><?php echo $wpsmushit_admin->settings['resize']['label']; ?></span>
438
- <br/>
439
- <small class="smush-setting-description">
440
- <?php echo $wpsmushit_admin->settings['resize']['desc']; ?>
441
- </small>
442
- </label>
443
- <span class="toggle float-r">
444
- <input type="checkbox" class="toggle-checkbox"
445
- id="<?php echo $opt_resize; ?>" <?php echo $resize_checked = checked( $opt_resize_val, 1, false ); ?>
446
- value="1" name="<?php echo $opt_resize; ?>" tabindex="0">
447
- <label class="toggle-label" for="<?php echo $opt_resize; ?>"></label>
448
- </span>
449
- <div class="wp-smush-resize-settings-wrap<?php echo $resize_checked ? '' : ' hidden'?>">
450
- <label for="<?php echo $opt_resize . '_width'; ?>"><?php esc_html_e("Width", "wp-smushit"); ?>
451
- <input type="text" id="<?php echo $opt_resize . '_width'; ?>" class="wp-smush-resize-input" value="<?php echo isset( $resize_sizes['width'] ) && '' != $resize_sizes['width'] ? $resize_sizes['width'] : $p_width; ?>" placeholder="<?php echo $p_width; ?>" name="<?php echo $opt_resize . '_width'; ?>" tabindex="0" width=100 /> px
452
  </label>
453
- <label for"<?php echo $opt_resize . '_height'; ?>"><?php esc_html_e("Height", "wp-smushit"); ?>
454
- <input type="text" id="<?php echo $opt_resize . '_height'; ?>" class="wp-smush-resize-input" value="<?php echo isset( $resize_sizes['height'] ) && '' != $resize_sizes['height'] ? $resize_sizes['height'] : $p_height; ?>" placeholder="<?php echo $p_height; ?>" name="<?php echo $opt_resize . '_height'; ?>" tabindex="0" width=100 /> px
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
455
  </label>
456
- <div class="wp-smush-resize-note"><?php printf( esc_html__("Currently, your largest thumbnail size is set at %s%dpx wide x %dpx high%s. Anything above 2048px in width or height is huge and not recommended.", "wp-smushit"), '<strong>', $max_sizes['width'], $max_sizes['height'], '</strong>' ); ?></div>
457
- <div class="wp-smush-settings-info wp-smush-size-info wp-smush-update-width hidden"><?php esc_html_e( "Just to let you know, the width you've entered is less than your largest thumbnail and may result in pixelation.", "wp-smushit" ); ?></div>
458
- <div class="wp-smush-settings-info wp-smush-size-info wp-smush-update-height hidden"><?php esc_html_e( "Just to let you know, the height you’ve entered is less than your largest thumbnail and may result in pixelation.", "wp-smushit" ); ?></div>
 
 
 
459
  </div>
460
- </div><!-- End of Basic Settings --><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
461
 
462
- do_action( 'wp_smush_after_basic_settings' );
463
- $this->advanced_settings( $configure_screen );
 
 
 
 
 
 
464
  }
465
 
466
  /**
@@ -468,7 +498,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
468
  */
469
  function ui() {
470
 
471
- global $WpSmush, $wpsmushit_admin;
472
 
473
  if( !$WpSmush->validate_install() ) {
474
  //Reset Transient
@@ -476,43 +506,54 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
476
  }
477
 
478
  $this->smush_page_header();
 
 
 
 
 
 
 
 
 
479
 
480
- //Show Configure screen for only a new installation and for only network admins
481
- if ( ( 1 != get_site_option( 'wp-smush-hide_smush_welcome' ) && 1 != get_option( 'wp-smush-hide_smush_welcome' ) ) && 1 != get_option( 'hide_smush_features' ) && 0 >= $wpsmushit_admin->smushed_count && is_super_admin() ) {
482
- echo '<div class="block float-l smush-welcome-wrapper">';
483
- $this->welcome_screen();
484
- echo '</div>';
485
- } ?>
486
-
487
- <!-- Bulk Smush Progress Bar -->
488
- <div class="wp-smushit-container-left col-half float-l"><?php
489
- //Bulk Smush Container
490
- $this->bulk_smush_container();
491
- ?>
492
- </div>
493
 
494
- <!-- Stats -->
495
- <div class="wp-smushit-container-right col-half float-l"><?php
496
- //Stats
497
- $this->smush_stats_container();
498
- if ( ! $WpSmush->validate_install() ) {
499
- /**
500
- * Allows to Hook in Additional Containers after Stats Box for free version
501
- * Pro Version has a full width settings box, so we don't want to do it there
502
- */
503
- do_action( 'wp_smush_after_stats_box' );
504
- } ?>
505
- </div><!-- End Of Smushit Container right -->
506
 
507
- <!-- Stats Share Widget -->
508
- <div class="row"><?php
509
- global $wpsmush_share;
510
- $wpsmush_share->share_widget(); ?>
511
- </div>
 
 
 
512
 
513
  <!-- Settings -->
514
  <div class="row"><?php
515
- $this->settings_ui();
 
 
 
 
 
 
516
  if( !$wpsmushit_admin->validate_install() ) {?>
517
  <div class="wp-smush-pro-for-free wp-smushit-container-left col-half float-l"><?php
518
  $this->wp_smush_promo();?>
@@ -722,9 +763,15 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
722
  * Displays a admin notice for settings update
723
  */
724
  function settings_updated() {
725
- global $wpsmushit_admin;
 
 
 
 
 
 
726
  //Show Setttings Saved message
727
- if ( 1 == get_option( 'wp-smush-settings_updated', false ) ) {
728
 
729
  //Default message
730
  $message = esc_html__( "Your settings have been updated!", "wp-smushit" );
@@ -741,7 +788,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
741
  </div>';
742
 
743
  //Remove the option
744
- delete_option( 'wp-smush-settings_updated' );
745
  }
746
  }
747
 
@@ -766,6 +813,9 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
766
  //User API check, and display a message if not valid
767
  $user_validation = $this->get_user_validation_message();
768
 
 
 
 
769
  echo '<div class="smush-page-wrap">
770
  <section id="header">
771
  <div class="wp-smush-page-header">
@@ -773,6 +823,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
773
  <div class="wp-smush-auto-message roboto-regular">' . $auto_smush_message . '</div>
774
  </div>' .
775
  $user_validation .
 
776
  '</section>';
777
  //Check if settings were updated and shoe a notice
778
  $this->settings_updated();
@@ -878,5 +929,57 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
878
  $content = sprintf( '<div id="wp-smush-invalid-member" data-message="%s" class="hidden' . $notice_class . '"><div class="message">%s</div></div>', $attr_message, $message );
879
  return $content;
880
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
881
  }
882
  }
34
  return '';
35
  }
36
  echo '<section class="dev-box ' . $classes . ' wp-smush-container" id="' . $id . '">'; ?>
37
+ <div class="wp-smush-container-header box-title" xmlns="http://www.w3.org/1999/html">
38
  <h3 tabindex="0"><?php echo $heading ?></h3><?php
39
  //Sub Heading
40
  if ( ! empty( $sub_heading ) ) { ?>
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;
120
  $this->container_header( 'smush-stats-wrapper', 'wp-smush-stats-box', esc_html__( "STATS", "wp-smushit" ), $button );
121
  $dasharray = 125.663706144;
122
  $dash_offset = $wpsmushit_admin->total_count > 0 ? $dasharray - ( $dasharray * ( $smushed_count / $wpsmushit_admin->total_count) ) : $dasharray;
123
+ $tooltip = $wpsmushit_admin->stats['total_images'] > 0 ? 'tooltip="' . sprintf( esc_html__("You've smushed %d images in total", "wp-smushit"), $wpsmushit_admin->stats['total_images'] ) . '"' : ''; ?>
124
  <div class="box-content">
125
  <div class="row smush-total-savings smush-total-reduction-percent">
126
 
184
  if( !empty( $wpsmushit_admin->stats['resize_savings'] ) && $wpsmushit_admin->stats['resize_savings'] > 0 ) {
185
  echo $wpsmushit_admin->stats['resize_savings'];
186
  }else{
187
+ if( !$wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'resize' ) ) {
188
  //If Not enabled, Add a enable button
189
  printf( esc_html__( "%sENABLE%s", "wp-smushit" ), '<button class="wp-smush-resize-enable button button-small">', '</button>' );
190
  }else{
253
  * Outputs the advanced settings for Pro users, Disabled for basic users by default
254
  */
255
  function advanced_settings( $configure_screen = false ) {
256
+ global $WpSmush, $wpsmushit_admin, $wpsmush_settings;
257
 
258
  //Content for the End of box container
259
+ $div_end = $this->save_button( $configure_screen );
 
 
 
 
 
 
 
 
 
 
 
 
260
 
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'; ?>
267
+ <div class="network-settings-wrapper<?php echo $class; ?>"><?php
268
+ }
269
  $upgrade_url = add_query_arg(
270
  array(
271
  'utm_source' => 'Smush-Free',
293
  echo "<hr />";
294
  }
295
 
 
 
296
  //Iterate Over all the available settings, and print a row for each of them
297
  foreach ( $pro_settings as $setting_key ) {
298
  if ( isset( $wpsmushit_admin->settings[ $setting_key ] ) ) {
299
  $setting_m_key = WP_SMUSH_PREFIX . $setting_key;
300
+ $setting_val = $WpSmush->validate_install() ? $wpsmush_settings->get_setting( $setting_m_key, false ) : 0; ?>
301
  <div class='wp-smush-setting-row wp-smush-advanced'>
302
  <label class="inline-label" for="<?php echo $setting_m_key; ?>" tabindex="0">
303
  <span
325
  echo "</div><!-- Box Content -->
326
  </section><!-- Main Section -->";
327
  }
328
+ //Close wrapper div
329
+ if( is_multisite() && is_network_admin() && !$WpSmush->validate_install() ) {
330
+ echo "</div>";
331
+ }
332
  }
333
 
334
  /**
335
  * Process and display the options form
336
  */
337
  function options_ui( $configure_screen = false ) {
338
+ global $wpsmushit_admin, $wpsmush_settings;
339
  echo '<div class="box-container">
340
  <form id="wp-smush-settings-form" method="post">';
341
 
345
  //Placeholder width and Height
346
  $p_width = $p_height = 2048;
347
 
348
+ //Use settings networkwide,@uses get_site_option() and not get_option
349
+ $opt_networkwide = WP_SMUSH_PREFIX . 'networkwide';
350
+ $opt_networkwide_val = get_site_option( $opt_networkwide, true );
351
+
352
  //Smush auto key
353
  $opt_auto = WP_SMUSH_PREFIX . 'auto';
354
  //Auto value
355
+ $opt_auto_val = $wpsmush_settings->get_setting( $opt_auto, false );
356
 
357
  //If value is not set for auto smushing set it to 1
358
  if ( $opt_auto_val === false ) {
362
 
363
  //Keep Exif
364
  $opt_keep_exif = WP_SMUSH_PREFIX . 'keep_exif';
365
+ $opt_keep_exif_val = $wpsmush_settings->get_setting( $opt_keep_exif, false );
366
 
367
  //Resize images
368
  $opt_resize = WP_SMUSH_PREFIX . 'resize';
369
+ $opt_resize_val = $wpsmush_settings->get_setting( $opt_resize, false );
370
 
371
  //Dimensions
372
+ $resize_sizes = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'resize_sizes', array( 'width' => '', 'height' => '' ) );
373
 
374
  //Additional Image sizes
375
+ $image_sizes = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'image_sizes', false );
376
  $sizes = $wpsmushit_admin->image_dimensions();
377
+
378
+ //Option to enable/disable networkwide settings
379
+ if( is_multisite() && is_network_admin() ) {
380
+ $class = get_site_option( WP_SMUSH_PREFIX . 'networkwide', 1 ) ? '' : ' hidden'; ?>
381
+ <!-- A tab index of 0 keeps the element in tab flow with other elements with an unspecified tab index which are still tabbable.) -->
382
+ <div class='wp-smush-setting-row wp-smush-basic'>
383
+ <label class="inline-label" for="<?php echo $opt_networkwide; ?>" tabindex="0">
384
+ <span class="wp-smush-setting-label">
385
+ <?php echo $wpsmushit_admin->settings['networkwide']['label']; ?>
386
+ </span><br/>
387
+ <small class="smush-setting-description">
388
+ <?php echo $wpsmushit_admin->settings['networkwide']['desc']; ?>
389
+ </small>
390
+ </label>
391
+ <span class="toggle float-r">
392
+ <input type="checkbox" class="toggle-checkbox"
393
+ id="<?php echo $opt_networkwide; ?>"
394
+ name="<?php echo $opt_networkwide; ?>" <?php checked( $opt_networkwide_val, 1, true ); ?> value="1" tabindex="0">
395
+ <label class="toggle-label" for="<?php echo $opt_networkwide; ?>"></label>
396
+ </span>
397
+ </div>
398
+ <input type="hidden" name="setting-type" value="network">
399
+ <hr />
400
+ <div class="network-settings-wrapper<?php echo $class; ?>"><?php
401
+ }
402
+
403
+ //Do not print settings in network page if networkwide settings are disabled
404
+ if( ! is_multisite() || ( ! get_site_option( WP_SMUSH_PREFIX . 'networkwide', 1 ) && !is_network_admin() ) || is_network_admin() ) { ?>
405
+ <div class='wp-smush-setting-row wp-smush-basic'>
406
+ <label class="inline-label" for="<?php echo $opt_auto; ?>" tabindex="0">
407
+ <span class="wp-smush-setting-label">
408
+ <?php echo $wpsmushit_admin->settings['auto']['label']; ?>
409
+ </span><br/>
410
+ <small class="smush-setting-description">
411
+ <?php echo $wpsmushit_admin->settings['auto']['desc']; ?>
412
+ </small>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
  </label>
414
+ <span class="toggle float-r">
415
+ <input type="checkbox" class="toggle-checkbox"
416
+ id="<?php echo $opt_auto; ?>"
417
+ name="<?php echo $opt_auto; ?>" <?php checked( $opt_auto_val, 1, true ); ?> value="1" tabindex="0">
418
+ <label class="toggle-label" for="<?php echo $opt_auto; ?>"></label>
419
+ </span><?php
420
+ if( !empty( $sizes ) ) { ?>
421
+ <!-- List of image sizes recognised by WP Smush -->
422
+ <div class="wp-smush-image-size-list">
423
+ <p><?php esc_html_e("The following image sizes will be optimised by WP Smush:", "wp-smushit"); ?></p><?php
424
+ foreach ( $sizes as $size_k => $size ) {
425
+ if( 'medium_large' == $size_k ) {
426
+ continue;
427
+ }
428
+ //If image sizes array isn't set, mark all checked ( Default Values )
429
+ if ( false === $image_sizes ) {
430
+ $checked = true;
431
+ }else{
432
+ $checked = is_array( $image_sizes ) ? in_array( $size_k, $image_sizes ) : false;
433
+ } ?>
434
+ <label>
435
+ <input type="checkbox" id="wp-smush-size-<?php echo $size_k; ?>" <?php checked( $checked, true ); ?> name="wp-smush-image_sizes[]" value="<?php echo $size_k; ?>"><?php
436
+ echo $size_k . " (" . $size['width'] . "x" . $size['height'] . ") "; ?>
437
+ </label><?php
438
+ } ?>
439
+ </div><?php
440
+ } ?>
441
+ </div>
442
+ <hr/>
443
+ <div class='wp-smush-setting-row wp-smush-basic'>
444
+ <label class="inline-label" for="<?php echo $opt_keep_exif; ?>" tabindex="0">
445
+ <span class="wp-smush-setting-label"><?php echo $wpsmushit_admin->settings['keep_exif']['label']; ?></span>
446
+ <br/>
447
+ <small class="smush-setting-description">
448
+ <?php echo $wpsmushit_admin->settings['keep_exif']['desc']; ?>
449
+ </small>
450
  </label>
451
+ <span class="toggle float-r">
452
+ <input type="checkbox" class="toggle-checkbox"
453
+ id="<?php echo $opt_keep_exif; ?>" <?php checked( $opt_keep_exif_val, 1, true ); ?>
454
+ value="1" name="<?php echo $opt_keep_exif; ?>" tabindex="0">
455
+ <label class="toggle-label" for="<?php echo $opt_keep_exif; ?>"></label>
456
+ </span>
457
  </div>
458
+ <hr/>
459
+ <div class='wp-smush-setting-row wp-smush-basic'>
460
+ <label class="inline-label" for="<?php echo $opt_resize; ?>" tabindex="0">
461
+ <span class="wp-smush-setting-label"><?php echo $wpsmushit_admin->settings['resize']['label']; ?></span>
462
+ <br/>
463
+ <small class="smush-setting-description">
464
+ <?php echo $wpsmushit_admin->settings['resize']['desc']; ?>
465
+ </small>
466
+ </label>
467
+ <span class="toggle float-r">
468
+ <input type="checkbox" class="toggle-checkbox"
469
+ id="<?php echo $opt_resize; ?>" <?php echo $resize_checked = checked( $opt_resize_val, 1, false ); ?>
470
+ value="1" name="<?php echo $opt_resize; ?>" tabindex="0">
471
+ <label class="toggle-label" for="<?php echo $opt_resize; ?>"></label>
472
+ </span>
473
+ <div class="wp-smush-resize-settings-wrap<?php echo $resize_checked ? '' : ' hidden'?>">
474
+ <label for="<?php echo $opt_resize . '_width'; ?>"><?php esc_html_e("Width", "wp-smushit"); ?>
475
+ <input type="text" id="<?php echo $opt_resize . '_width'; ?>" class="wp-smush-resize-input" value="<?php echo isset( $resize_sizes['width'] ) && '' != $resize_sizes['width'] ? $resize_sizes['width'] : $p_width; ?>" placeholder="<?php echo $p_width; ?>" name="<?php echo $opt_resize . '_width'; ?>" tabindex="0" width=100 /> px
476
+ </label>
477
+ <label for"<?php echo $opt_resize . '_height'; ?>"><?php esc_html_e("Height", "wp-smushit"); ?>
478
+ <input type="text" id="<?php echo $opt_resize . '_height'; ?>" class="wp-smush-resize-input" value="<?php echo isset( $resize_sizes['height'] ) && '' != $resize_sizes['height'] ? $resize_sizes['height'] : $p_height; ?>" placeholder="<?php echo $p_height; ?>" name="<?php echo $opt_resize . '_height'; ?>" tabindex="0" width=100 /> px
479
+ </label>
480
+ <div class="wp-smush-resize-note"><?php printf( esc_html__("Currently, your largest thumbnail size is set at %s%dpx wide x %dpx high%s. Anything above 2048px in width or height is huge and not recommended.", "wp-smushit"), '<strong>', $max_sizes['width'], $max_sizes['height'], '</strong>' ); ?></div>
481
+ <div class="wp-smush-settings-info wp-smush-size-info wp-smush-update-width hidden"><?php esc_html_e( "Just to let you know, the width you've entered is less than your largest thumbnail and may result in pixelation.", "wp-smushit" ); ?></div>
482
+ <div class="wp-smush-settings-info wp-smush-size-info wp-smush-update-height hidden"><?php esc_html_e( "Just to let you know, the height you’ve entered is less than your largest thumbnail and may result in pixelation.", "wp-smushit" ); ?></div>
483
+ </div>
484
+ </div><!-- End of Basic Settings --><?php
485
 
486
+ do_action( 'wp_smush_after_basic_settings' );
487
+ $this->advanced_settings( $configure_screen );
488
+ } else{
489
+ echo "<hr />";
490
+ echo $this->save_button( $configure_screen );
491
+ echo "</div><!-- Box Content -->
492
+ </section><!-- Main Section -->";
493
+ }
494
  }
495
 
496
  /**
498
  */
499
  function ui() {
500
 
501
+ global $WpSmush, $wpsmushit_admin, $wpsmush_settings;
502
 
503
  if( !$WpSmush->validate_install() ) {
504
  //Reset Transient
506
  }
507
 
508
  $this->smush_page_header();
509
+ $is_network = is_network_admin();
510
+
511
+ if( !$is_network ) {
512
+ //Show Configure screen for only a new installation and for only network admins
513
+ if ( ( 1 != get_site_option( 'wp-smush-hide_smush_welcome' ) && 1 != get_option( 'wp-smush-hide_smush_welcome' ) ) && 1 != get_option( 'hide_smush_features' ) && 0 >= $wpsmushit_admin->smushed_count && is_super_admin() ) {
514
+ echo '<div class="block float-l smush-welcome-wrapper">';
515
+ $this->welcome_screen();
516
+ echo '</div>';
517
+ } ?>
518
 
519
+ <!-- Bulk Smush Progress Bar -->
520
+ <div class="wp-smushit-container-left col-half float-l"><?php
521
+ //Bulk Smush Container
522
+ $this->bulk_smush_container();
523
+ ?>
524
+ </div>
 
 
 
 
 
 
 
525
 
526
+ <!-- Stats -->
527
+ <div class="wp-smushit-container-right col-half float-l"><?php
528
+ //Stats
529
+ $this->smush_stats_container();
530
+ if ( ! $WpSmush->validate_install() ) {
531
+ /**
532
+ * Allows to Hook in Additional Containers after Stats Box for free version
533
+ * Pro Version has a full width settings box, so we don't want to do it there
534
+ */
535
+ do_action( 'wp_smush_after_stats_box' );
536
+ } ?>
537
+ </div><!-- End Of Smushit Container right -->
538
 
539
+ <!-- Stats Share Widget -->
540
+ <div class="row"><?php
541
+ global $wpsmush_share;
542
+ $wpsmush_share->share_widget(); ?>
543
+ </div>
544
+ <?php
545
+ //End of "!is_network()' check
546
+ }?>
547
 
548
  <!-- Settings -->
549
  <div class="row"><?php
550
+ wp_nonce_field( 'save_wp_smush_options', 'wp_smush_options_nonce', '', true );
551
+ //Check if a network site and networkwide settings is enabled
552
+ if( ! is_multisite() || ( is_multisite() && ! get_site_option( WP_SMUSH_PREFIX . 'networkwide', true ) ) || ( is_multisite() && is_network_admin() ) ) {
553
+ $this->settings_ui();
554
+ }
555
+
556
+ //Validate Membership
557
  if( !$wpsmushit_admin->validate_install() ) {?>
558
  <div class="wp-smush-pro-for-free wp-smushit-container-left col-half float-l"><?php
559
  $this->wp_smush_promo();?>
763
  * Displays a admin notice for settings update
764
  */
765
  function settings_updated() {
766
+ global $wpsmushit_admin, $wpsmush_settings;
767
+
768
+ //Check if Networkwide settings are enabled, Do not show settings updated message
769
+ if( is_multisite() && get_site_option( WP_SMUSH_PREFIX . 'networkwide', 1 ) && !is_network_admin() ) {
770
+ return;
771
+ }
772
+
773
  //Show Setttings Saved message
774
+ if ( 1 == $wpsmush_settings->get_setting( 'wp-smush-settings_updated', false ) ) {
775
 
776
  //Default message
777
  $message = esc_html__( "Your settings have been updated!", "wp-smushit" );
788
  </div>';
789
 
790
  //Remove the option
791
+ $wpsmush_settings->delete_setting( 'wp-smush-settings_updated' );
792
  }
793
  }
794
 
813
  //User API check, and display a message if not valid
814
  $user_validation = $this->get_user_validation_message();
815
 
816
+ //Re-Check images notice
817
+ $recheck_notice = $this->get_recheck_message();
818
+
819
  echo '<div class="smush-page-wrap">
820
  <section id="header">
821
  <div class="wp-smush-page-header">
823
  <div class="wp-smush-auto-message roboto-regular">' . $auto_smush_message . '</div>
824
  </div>' .
825
  $user_validation .
826
+ $recheck_notice .
827
  '</section>';
828
  //Check if settings were updated and shoe a notice
829
  $this->settings_updated();
929
  $content = sprintf( '<div id="wp-smush-invalid-member" data-message="%s" class="hidden' . $notice_class . '"><div class="message">%s</div></div>', $attr_message, $message );
930
  return $content;
931
  }
932
+
933
+ /**
934
+ *
935
+ * @param $configure_screen
936
+ *
937
+ * @return string
938
+ *
939
+ */
940
+ function save_button( $configure_screen = false ) {
941
+ $div_end = '';
942
+ //Close wrapper div
943
+ if( is_multisite() && is_network_admin() ) {
944
+ $div_end .= "</div>";
945
+ }
946
+
947
+ $div_end .=
948
+ '<div class="wp-smush-submit-wrap">
949
+ <input type="submit" id="wp-smush-save-settings" class="button button-grey"
950
+ value="' . esc_html__( 'UPDATE SETTINGS', 'wp-smushit' ) . '">
951
+ <span class="spinner"></span>
952
+ </div>
953
+ </form>';
954
+
955
+ //For Configuration screen we need to show the advanced settings in single box
956
+ if ( ! $configure_screen ) {
957
+ $div_end .= '</div><!-- Box Content -->
958
+ </section><!-- Main Section -->';
959
+ }
960
+ return $div_end;
961
+ }
962
+
963
+ function get_recheck_message() {
964
+ //Return if not multisite, or on network settings page, Netowrkwide settings is disabled
965
+ if( ! is_multisite() || is_network_admin() || ! get_site_option( WP_SMUSH_PREFIX . 'networkwide' ) ) {
966
+ return;
967
+ }
968
+ global $wpsmush_settings, $wpsmushit_admin;
969
+
970
+ //Check the last settings stored in db
971
+ $settings = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'last_settings', '' );
972
+
973
+ //Get current settings
974
+ $c_settings = $wpsmushit_admin->get_serialised_settings();
975
+
976
+ //If not same, Display notice
977
+ if( $settings == $c_settings ) {
978
+ return;
979
+ }
980
+ $message = '<div class="wp-smush-notice wp-smush-re-check-message">' . esc_html__( "Smush settings were updated, performing a quick scan to check if any of the images need to be Smushed again.", "wp-smushit") . '<i class="dev-icon dev-icon-cross"></i></div>';
981
+
982
+ return $message;
983
+ }
984
  }
985
  }
lib/class-wp-smush.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
  //Migration Class
3
  require_once WP_SMUSH_DIR . "lib/class-wp-smush-migrate.php";
4
 
@@ -17,6 +20,9 @@ require_once WP_SMUSH_DIR . 'lib/class-wp-smush-share.php';
17
  //Include Image backup class
18
  require_once WP_SMUSH_DIR . 'lib/class-wp-smush-backup.php';
19
 
 
 
 
20
  if ( ! class_exists( 'WpSmush' ) ) {
21
 
22
  class WpSmush {
@@ -117,32 +123,45 @@ if ( ! class_exists( 'WpSmush' ) ) {
117
  add_action( 'plugins_loaded', array( $this, 'load_nextgen' ), 90 );
118
 
119
  //Send Smush Stats for pro members
120
- add_filter( 'wpmudev_api_project_extra_data-912164', array( $this, 'send_smush_stats') );
121
 
122
  //Send Smush Stats for pro members
123
- add_action( 'wp_ajax_smush_show_warning', array( $this, 'show_warning_ajax') );
 
 
 
 
 
 
 
 
 
124
 
125
  }
126
 
127
  function i18n() {
128
- load_plugin_textdomain( 'wp-smushit', false, WP_SMUSH_DIR . '/languages/' );
 
129
  }
130
 
131
  /**
132
  * Initialise the setting variables
133
  */
134
  function initialise() {
 
 
 
135
  //Check if Lossy enabled
136
  $opt_lossy = WP_SMUSH_PREFIX . 'lossy';
137
- $this->lossy_enabled = $this->validate_install() && get_option( $opt_lossy, false );
138
 
139
  //Check if Smush Original enabled
140
  $opt_original = WP_SMUSH_PREFIX . 'original';
141
- $this->smush_original = $this->validate_install() && get_option( $opt_original, false );
142
 
143
  //Check Whether to keep exif or not
144
  $opt_keep_exif = WP_SMUSH_PREFIX . 'keep_exif';
145
- $this->keep_exif = get_option( $opt_keep_exif, false );
146
  }
147
 
148
  function admin_init() {
@@ -206,7 +225,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
206
 
207
  // save original file permissions
208
  clearstatcache();
209
- $perms = fileperms($file_path) & 0777;
210
 
211
  /** Send image for smushing, and fetch the response */
212
  $response = $this->_post( $file_path, $file_size );
@@ -253,7 +272,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
253
  }
254
 
255
  //Some servers are having issue with file permission, this should fix it
256
- if( empty( $perms ) || !$perms ) {
257
  //Source: WordPress Core
258
  $stat = stat( dirname( $file_path ) );
259
  $perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits
@@ -299,6 +318,8 @@ if ( ! class_exists( 'WpSmush' ) ) {
299
  /**
300
  * Optimises the image sizes
301
  *
 
 
302
  * Read the image paths from an attachment's meta data and process each image
303
  * with wp_smushit().
304
  *
@@ -309,8 +330,10 @@ if ( ! class_exists( 'WpSmush' ) ) {
309
  */
310
  function resize_from_meta_data( $meta, $ID = null ) {
311
 
 
 
312
  //Flag to check, if original size image should be smushed or not
313
- $original = get_option( WP_SMUSH_PREFIX . 'original' );
314
  $smush_full = ( $this->validate_install() && $original == 1 ) ? true : false;
315
 
316
  $errors = new WP_Error();
@@ -332,7 +355,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
332
 
333
  //Set attachment id and Media type
334
  $this->attachment_id = $ID;
335
- $this->media_type = "wp";
336
 
337
  //File path and URL for original image
338
  $attachment_file_path = get_attached_file( $ID );
@@ -360,7 +383,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
360
  foreach ( $meta['sizes'] as $size_key => $size_data ) {
361
 
362
  //Check if registered size is supposed to be Smushed or not
363
- if( 'full' != $size_key && $wpsmushit_admin->skip_image_size( $size_key ) ) {
364
  continue;
365
  }
366
 
@@ -408,12 +431,12 @@ if ( ! class_exists( 'WpSmush' ) ) {
408
  }
409
 
410
  //If there are no stats
411
- if( empty( $response['data'] ) ) {
412
  continue;
413
  }
414
 
415
  //If the image size grew after smushing, skip it
416
- if( $response['data']->after_size > $response['data']->before_size ) {
417
  continue;
418
  }
419
 
@@ -424,7 +447,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
424
  if ( empty( $stats['stats']['api_version'] ) || $stats['stats']['api_version'] == - 1 ) {
425
  $stats['stats']['api_version'] = $response['data']->api_version;
426
  $stats['stats']['lossy'] = $response['data']->lossy;
427
- $stats['stats']['keep_exif'] = !empty( $response['data']->keep_exif ) ? $response['data']->keep_exif : 0;
428
  }
429
  }
430
  //Upfront Integration
@@ -454,12 +477,12 @@ if ( ! class_exists( 'WpSmush' ) ) {
454
  }
455
 
456
  //If there are no stats
457
- if( empty( $full_image_response['data'] ) ) {
458
  $store_stats = false;
459
  }
460
 
461
  //If the image size grew after smushing, skip it
462
- if( $full_image_response['data']->after_size > $full_image_response['data']->before_size ) {
463
  $store_stats = false;
464
  }
465
 
@@ -472,7 +495,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
472
  if ( empty( $stats['stats']['api_version'] ) || $stats['stats']['api_version'] == - 1 ) {
473
  $stats['stats']['api_version'] = $full_image_response['data']->api_version;
474
  $stats['stats']['lossy'] = $full_image_response['data']->lossy;
475
- $stats['stats']['keep_exif'] = !empty( $full_image_response['data']->keep_exif ) ? $full_image_response['data']->keep_exif : 0;
476
  }
477
 
478
  }
@@ -495,10 +518,10 @@ if ( ! class_exists( 'WpSmush' ) ) {
495
  $stats['sizes'][ $size_name ] = $existing_stats['sizes'][ $size_name ];
496
  } else {
497
 
498
- $existing_stats_size = (object)$existing_stats['sizes'][ $size_name ];
499
 
500
  //store the original image size
501
- $stats['sizes'][ $size_name ]->size_before = ( !empty( $existing_stats_size->size_before ) && $existing_stats_size->size_before > $stats['sizes'][ $size_name ]->size_before ) ? $existing_stats_size->size_before : $stats['sizes'][ $size_name ]->size_before;
502
 
503
  //Update compression percent and bytes saved for each size
504
  $stats['sizes'][ $size_name ]->bytes = $stats['sizes'][ $size_name ]->bytes + $existing_stats_size->bytes;
@@ -512,16 +535,16 @@ if ( ! class_exists( 'WpSmush' ) ) {
512
  $stats = $this->total_compression( $stats );
513
 
514
  //If there was any compression and there was no error in smushing
515
- if( isset( $stats['stats']['bytes'] ) && $stats['stats']['bytes'] >= 0 && !$has_errors ) {
516
  /**
517
  * Runs if the image smushing was successful
518
  *
519
- * @param int $ID Image Id
520
  *
521
  * @param array $stats Smush Stats for the image
522
- *
523
  */
524
- do_action('wp_smush_image_optimised', $ID, $stats );
525
  }
526
  update_post_meta( $ID, $this->smushed_meta_key, $stats );
527
  }
@@ -549,12 +572,39 @@ if ( ! class_exists( 'WpSmush' ) ) {
549
  */
550
  function smush_image( $meta, $ID = null ) {
551
 
 
 
 
 
 
552
  //Return directly if not a image
553
  if ( ! wp_attachment_is_image( $ID ) ) {
554
  return $meta;
555
  }
556
 
557
- global $wpsmush_resize, $wpsmush_pngjpg, $wpsmush_backup;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
558
 
559
  //Check if auto is enabled
560
  $auto_smush = $this->is_auto_smush_enabled();
@@ -572,10 +622,10 @@ if ( ! class_exists( 'WpSmush' ) ) {
572
  //Check for use of http url, (Hostgator mostly)
573
  $use_http = wp_cache_get( WP_SMUSH_PREFIX . 'use_http', 'smush' );
574
  if ( ! $use_http ) {
575
- $use_http = get_option( WP_SMUSH_PREFIX . 'use_http' );
576
  wp_cache_add( WP_SMUSH_PREFIX . 'use_http', $use_http, 'smush' );
577
  }
578
- if( $use_http ) {
579
  //HTTP Url
580
  define( 'WP_SMUSH_API_HTTP', 'http://smushpro.wpmudev.org/1.0/' );
581
  }
@@ -587,6 +637,9 @@ if ( ! class_exists( 'WpSmush' ) ) {
587
  delete_post_meta( $ID, $this->smushed_meta_key );
588
  }
589
 
 
 
 
590
  return $meta;
591
  }
592
 
@@ -600,7 +653,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
600
  * @return bool|array array containing success status, and stats
601
  */
602
  function _post( $file_path, $file_size ) {
603
- global $wpsmushit_admin;
604
 
605
  $data = false;
606
 
@@ -644,7 +697,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
644
  //Hostgator Issue
645
  if ( ! empty( $er_msg ) && strpos( $er_msg, 'SSL CA cert' ) !== false ) {
646
  //Update DB for using http protocol
647
- update_option( WP_SMUSH_PREFIX . 'use_http', 1 );
648
  }
649
  //Handle error
650
  $data['message'] = sprintf( __( 'Error posting to API: %s', 'wp-smushit' ), $result->get_error_message() );
@@ -685,7 +738,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
685
  $data['data'] = $response->data;
686
  }
687
  //If is_premium is set in response, send it over to check for member validity
688
- if( !empty( $response->data ) && isset( $response->data->is_premium ) ) {
689
  $wpsmushit_admin->api_headers['is_premium'] = $response->data->is_premium;
690
  }
691
  } else {
@@ -819,7 +872,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
819
 
820
  if ( ! is_wp_error( $request ) && '200' == wp_remote_retrieve_response_code( $request ) ) {
821
  $result = json_decode( wp_remote_retrieve_body( $request ) );
822
- if ( !empty( $result->success ) && $result->success ) {
823
  $valid = 'valid';
824
  } else {
825
  $valid = 'invalid';
@@ -891,9 +944,9 @@ if ( ! class_exists( 'WpSmush' ) ) {
891
  $status_txt = $button_txt = $stats = '';
892
  $show_button = $show_resmush = false;
893
 
894
- $wp_smush_data = get_post_meta( $id, $this->smushed_meta_key, true );
895
- $wp_resize_savings = get_post_meta( $id, WP_SMUSH_PREFIX . 'resize_savings', true );
896
- $conversion_savings = get_post_meta( $id, WP_SMUSH_PREFIX . 'pngjpg_savings', true );
897
 
898
  $combined_stats = $this->combined_stats( $wp_smush_data, $wp_resize_savings );
899
 
@@ -915,7 +968,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
915
  $show_button = false;
916
  } else {
917
  if ( $bytes == 0 || $percent == 0 ) {
918
- $status_txt = __( 'Already Optimized', 'wp-smushit' );
919
 
920
  //Show resmush link, if the settings were changed
921
  $show_resmush = $this->show_resmush( $id, $wp_smush_data );
@@ -924,17 +977,17 @@ if ( ! class_exists( 'WpSmush' ) ) {
924
  }
925
 
926
  } elseif ( ! empty( $percent ) && ! empty( $bytes_readable ) ) {
927
- $status_txt = $image_count > 1 ? sprintf( __( "%d images reduced ", 'wp-smushit' ), $image_count ) : __( "Reduced ", 'wp-smushit' );
928
 
929
  $stats_percent = number_format_i18n( $percent, 2, '.', '' );
930
  $stats_percent = $stats_percent > 0 ? sprintf( "( %01.1f%% )", $stats_percent ) : '';
931
  $status_txt .= sprintf( __( "by %s %s", 'wp-smushit' ), $bytes_readable, $stats_percent );
932
 
933
  $file_path = get_attached_file( $id );
934
- $size = file_exists( $file_path ) ? filesize( $file_path ) : 0;
935
- if( $size > 0 ) {
936
  $size = size_format( $size, 1 );
937
- $image_size = sprintf( __( "<br /> Image Size: %s", "wp-smushit"), $size );
938
  $status_txt .= $image_size;
939
  }
940
 
@@ -999,6 +1052,18 @@ if ( ! class_exists( 'WpSmush' ) ) {
999
  $show_button = true;
1000
  }
1001
 
 
 
 
 
 
 
 
 
 
 
 
 
1002
  } else {
1003
 
1004
  // the status
@@ -1106,7 +1171,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
1106
  return;
1107
  }
1108
 
1109
- $migrated_version = get_option( $this->migrated_version_key );
1110
 
1111
  if ( $migrated_version === $this->version ) {
1112
  return;
@@ -1129,7 +1194,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
1129
  }
1130
  }
1131
 
1132
- update_option( $this->migrated_version_key, $this->version );
1133
 
1134
  }
1135
 
@@ -1175,8 +1240,8 @@ if ( ! class_exists( 'WpSmush' ) ) {
1175
  'sizes' => array()
1176
  );
1177
  $stats['stats']['api_version'] = $data->api_version;
1178
- $stats['stats']['lossy'] = $data->lossy;
1179
- $stats['stats']['keep_exif'] = ! empty( $data->keep_exif ) ? $data->keep_exif : 0;
1180
 
1181
  //Update size wise details
1182
  $stats['sizes'][ $image_size ] = (object) $this->_array_fill_placeholders( $this->_get_size_signature(), (array) $data );
@@ -1199,7 +1264,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
1199
 
1200
  //Initialize attachment id and media type
1201
  $this->attachment_id = $id;
1202
- $this->media_type = "wp";
1203
 
1204
  /**
1205
  * Allows to Enable/Disable WP Retina 2x Integration
@@ -1367,10 +1432,10 @@ if ( ! class_exists( 'WpSmush' ) ) {
1367
  foreach ( $size_stats as $size_key => $size_value ) {
1368
  $dimensions = '';
1369
  //Get the dimensions for the image size if available
1370
- if ( ! empty( $wpsmushit_admin->image_sizes ) && !empty( $wpsmushit_admin->image_sizes[$size_key] ) ) {
1371
  $dimensions = $wpsmushit_admin->image_sizes[ $size_key ]['width'] . 'x' . $wpsmushit_admin->image_sizes[ $size_key ]['height'];
1372
  }
1373
- $dimensions = !empty( $dimensions ) ? sprintf( " <br /> (%s)", $dimensions ) : '';
1374
  if ( $size_value->bytes > 0 ) {
1375
  $percent = round( $size_value->percent, 1 );
1376
  $percent = $percent > 0 ? ' ( ' . $percent . '% )' : '';
@@ -1407,10 +1472,13 @@ if ( ! class_exists( 'WpSmush' ) ) {
1407
  if ( ! class_exists( 'C_NextGEN_Bootstrap' ) || ! $this->validate_install() ) {
1408
  return;
1409
  }
 
 
 
1410
  //Check if integration is Enabled or not
1411
  //Smush NextGen key
1412
  $opt_nextgen = WP_SMUSH_PREFIX . 'nextgen';
1413
- $opt_nextgen_val = get_option( $opt_nextgen, false );
1414
  if ( ! $opt_nextgen_val ) {
1415
  return;
1416
  }
@@ -1507,12 +1575,12 @@ if ( ! class_exists( 'WpSmush' ) ) {
1507
  $backup = get_post_meta( $image_id, WP_SMUSH_PREFIX . 'original_file', true );
1508
  $backup = $this->original_file( $backup );
1509
 
1510
- if ( !empty( $backup ) && file_exists( $backup ) ) {
1511
  return true;
1512
  }
1513
  }
1514
 
1515
- if( !empty( $attachment_data['sizes'] ) ) {
1516
  //Check for backup of image sizes
1517
  foreach ( $attachment_data['sizes'] as $image_size ) {
1518
  $size_path = path_join( dirname( $file ), $image_size['file'] );
@@ -1561,7 +1629,10 @@ if ( ! class_exists( 'WpSmush' ) ) {
1561
  * @return int|mixed|void
1562
  */
1563
  function is_auto_smush_enabled() {
1564
- $auto_smush = get_option( WP_SMUSH_PREFIX . 'auto' );
 
 
 
1565
 
1566
  //Keep the auto smush on by default
1567
  if ( $auto_smush === false ) {
@@ -1604,7 +1675,13 @@ if ( ! class_exists( 'WpSmush' ) ) {
1604
  if ( empty( $attachment_path ) ) {
1605
  return false;
1606
  }
1607
- $path = pathinfo( $attachment_path );
 
 
 
 
 
 
1608
  $backup_name = trailingslashit( $path['dirname'] ) . $path['filename'] . ".bak." . $path['extension'];
1609
 
1610
  return $backup_name;
@@ -1673,7 +1750,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
1673
 
1674
  //Set attachment id and Media type
1675
  $this->attachment_id = $attachment_id;
1676
- $this->media_type = "upfront";
1677
 
1678
  //Get post meta to check for Upfront images
1679
  $upfront_images = get_post_meta( $attachment_id, 'upfront_used_image_sizes', true );
@@ -1697,7 +1774,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
1697
 
1698
  //If the smushing was successful
1699
  if ( ! is_wp_error( $res ) && ! empty( $res['data'] ) ) {
1700
- if( $res['data']->bytes_saved > 0 ) {
1701
  //Update attachment stats
1702
  $stats['sizes'][ $element_id ] = (object) $this->_array_fill_placeholders( $this->_get_size_signature(), (array) $res['data'] );
1703
  }
@@ -1716,6 +1793,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
1716
 
1717
  /**
1718
  * Checks the current settings and returns the value whether to enable or not the resmush option
 
1719
  * @param $show_resmush
1720
  * @param $wp_smush_data
1721
  *
@@ -1763,7 +1841,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
1763
  return 0;
1764
  }
1765
  $size_before = ! empty( $stats->size_before ) ? $stats->size_before : $existing_stats->size_before;
1766
- $size_after = ! empty( $stats->size_after ) ? $stats->size_after : $existing_stats->size_after;
1767
  $savings = $size_before - $size_after;
1768
  if ( $savings > 0 ) {
1769
  $percentage = ( $savings / $size_before ) * 100;
@@ -1775,6 +1853,27 @@ if ( ! class_exists( 'WpSmush' ) ) {
1775
  return 0;
1776
  }
1777
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1778
  /**
1779
  * Redirects the user to Plugin settings page on Plugin activation
1780
  *
@@ -1787,7 +1886,7 @@ if ( ! class_exists( 'WpSmush' ) ) {
1787
  global $wpsmushit_admin, $wpsmush_stats;
1788
 
1789
  //Run for only our plugin
1790
- if( $plugin != WP_SMUSH_BASENAME ) {
1791
  return false;
1792
  }
1793
 
@@ -1796,31 +1895,32 @@ if ( ! class_exists( 'WpSmush' ) ) {
1796
  }
1797
 
1798
  //Skip if bulk activation, Or if we have to skip redirection
1799
- if ( isset( $_GET['activate-multi'] ) || get_site_option('wp-smush-skip-redirect') ) {
1800
  return false;
1801
  }
1802
 
1803
  //If images are already smushed
1804
- if( $wpsmush_stats->smushed_count( false ) > 0 ) {
1805
  return false;
1806
  }
1807
 
1808
  $url = admin_url( 'upload.php' );
1809
  $url = add_query_arg(
1810
  array(
1811
- 'page' => 'wp-smush-bulk'
1812
  ),
1813
  $url
1814
  );
1815
 
1816
  //Store that we need not redirect again
1817
- add_site_option('wp-smush-skip-redirect', true );
1818
 
1819
  exit( wp_redirect( $url ) );
1820
  }
1821
 
1822
  /**
1823
  * Clear up all the backup files for the image, if any
 
1824
  * @param $image_id
1825
  */
1826
  function delete_backup_files( $image_id ) {
@@ -1877,9 +1977,9 @@ if ( ! class_exists( 'WpSmush' ) ) {
1877
  function total_compression( $stats ) {
1878
  $stats['stats']['size_before'] = $stats['stats']['size_after'] = $stats['stats']['time'] = '';
1879
  foreach ( $stats['sizes'] as $size_stats ) {
1880
- $stats['stats']['size_before'] += !empty( $size_stats->size_before ) ? $size_stats->size_before : 0;
1881
- $stats['stats']['size_after'] += !empty( $size_stats->size_after) ? $size_stats->size_after : 0;
1882
- $stats['stats']['time'] += !empty($size_stats->time ) ? $size_stats->time : 0;
1883
  }
1884
  $stats['stats']['bytes'] = ! empty( $stats['stats']['size_before'] ) && $stats['stats']['size_before'] > $stats['stats']['size_after'] ? $stats['stats']['size_before'] - $stats['stats']['size_after'] : 0;
1885
  if ( ! empty( $stats['stats']['bytes'] ) && ! empty( $stats['stats']['size_before'] ) ) {
@@ -1903,9 +2003,9 @@ if ( ! class_exists( 'WpSmush' ) ) {
1903
  }
1904
 
1905
  //Full Image
1906
- if( !empty( $smush_stats['sizes']['full'] ) ) {
1907
  $smush_stats['sizes']['full']->bytes = ! empty( $resize_savings['bytes'] ) ? $smush_stats['sizes']['full']->bytes + $resize_savings['bytes'] : $smush_stats['sizes']['full']->bytes;
1908
- $smush_stats['sizes']['full']->size_before = ! empty( $resize_savings['size_before'] ) && ( $resize_savings['size_before'] > $smush_stats['sizes']['full']->size_before ) ? $resize_savings['size_before'] : $smush_stats['sizes']['full']->size_before;
1909
  $smush_stats['sizes']['full']->percent = ! empty( $smush_stats['sizes']['full']->bytes ) && $smush_stats['sizes']['full']->size_before > 0 ? ( $smush_stats['sizes']['full']->bytes / $smush_stats['sizes']['full']->size_before ) * 100 : $smush_stats['sizes']['full']->percent;
1910
 
1911
  $smush_stats['sizes']['full']->percent = round( $smush_stats['sizes']['full']->percent, 1 );
@@ -1969,12 +2069,12 @@ if ( ! class_exists( 'WpSmush' ) ) {
1969
 
1970
  global $wpsmushit_admin;
1971
  // Return. If we don't have any headers
1972
- if( !isset( $wpsmushit_admin->api_headers ) ) {
1973
  return false;
1974
  }
1975
 
1976
  //Show warning, if function says it's premium and api says not premium
1977
- if( isset( $wpsmushit_admin->api_headers['is_premium'] ) && ! intval( $wpsmushit_admin->api_headers['is_premium'] ) ) {
1978
  return true;
1979
  }
1980
 
@@ -1989,6 +2089,134 @@ if ( ! class_exists( 'WpSmush' ) ) {
1989
  $show = $this->show_warning();
1990
  wp_send_json( intval( $show ) );
1991
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1992
  }
1993
 
1994
  global $WpSmush;
1
  <?php
2
+ //Settings Class
3
+ require_once WP_SMUSH_DIR . "lib/class-wp-smush-settings.php";
4
+
5
  //Migration Class
6
  require_once WP_SMUSH_DIR . "lib/class-wp-smush-migrate.php";
7
 
20
  //Include Image backup class
21
  require_once WP_SMUSH_DIR . 'lib/class-wp-smush-backup.php';
22
 
23
+ //Include Smush Async class
24
+ require_once WP_SMUSH_DIR . 'lib/class-wp-smush-async.php';
25
+
26
  if ( ! class_exists( 'WpSmush' ) ) {
27
 
28
  class WpSmush {
123
  add_action( 'plugins_loaded', array( $this, 'load_nextgen' ), 90 );
124
 
125
  //Send Smush Stats for pro members
126
+ add_filter( 'wpmudev_api_project_extra_data-912164', array( $this, 'send_smush_stats' ) );
127
 
128
  //Send Smush Stats for pro members
129
+ add_action( 'wp_ajax_smush_show_warning', array( $this, 'show_warning_ajax' ) );
130
+
131
+ //Instanitate the Async class
132
+ add_action( 'plugins_loaded', array( $this, 'wp_smush_async' ) );
133
+
134
+ //Handle the Async optimisation
135
+ add_action( 'wp_async_wp_generate_attachment_metadata', array( $this, 'wp_smush_handle_async' ) );
136
+
137
+ //Handle the Async optimisation
138
+ add_action( 'wp_async_wp_save_image_editor_file', array( $this, 'wp_smush_handle_editor_async' ), '', 2 );
139
 
140
  }
141
 
142
  function i18n() {
143
+ $path = path_join( dirname( plugin_basename( __FILE__ ) ), 'languages' );
144
+ load_plugin_textdomain( 'wp-smushit', false, $path );
145
  }
146
 
147
  /**
148
  * Initialise the setting variables
149
  */
150
  function initialise() {
151
+
152
+ global $wpsmush_settings;
153
+
154
  //Check if Lossy enabled
155
  $opt_lossy = WP_SMUSH_PREFIX . 'lossy';
156
+ $this->lossy_enabled = $this->validate_install() && $wpsmush_settings->get_setting( $opt_lossy, false );
157
 
158
  //Check if Smush Original enabled
159
  $opt_original = WP_SMUSH_PREFIX . 'original';
160
+ $this->smush_original = $this->validate_install() && $wpsmush_settings->get_setting( $opt_original, false );
161
 
162
  //Check Whether to keep exif or not
163
  $opt_keep_exif = WP_SMUSH_PREFIX . 'keep_exif';
164
+ $this->keep_exif = $wpsmush_settings->get_setting( $opt_keep_exif, false );
165
  }
166
 
167
  function admin_init() {
225
 
226
  // save original file permissions
227
  clearstatcache();
228
+ $perms = fileperms( $file_path ) & 0777;
229
 
230
  /** Send image for smushing, and fetch the response */
231
  $response = $this->_post( $file_path, $file_size );
272
  }
273
 
274
  //Some servers are having issue with file permission, this should fix it
275
+ if ( empty( $perms ) || ! $perms ) {
276
  //Source: WordPress Core
277
  $stat = stat( dirname( $file_path ) );
278
  $perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits
318
  /**
319
  * Optimises the image sizes
320
  *
321
+ * Note: Function name is bit confusing, it is for optimisation, and calls the resizing function as well
322
+ *
323
  * Read the image paths from an attachment's meta data and process each image
324
  * with wp_smushit().
325
  *
330
  */
331
  function resize_from_meta_data( $meta, $ID = null ) {
332
 
333
+ global $wpsmush_settings;
334
+
335
  //Flag to check, if original size image should be smushed or not
336
+ $original = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'original', false );
337
  $smush_full = ( $this->validate_install() && $original == 1 ) ? true : false;
338
 
339
  $errors = new WP_Error();
355
 
356
  //Set attachment id and Media type
357
  $this->attachment_id = $ID;
358
+ $this->media_type = "wp";
359
 
360
  //File path and URL for original image
361
  $attachment_file_path = get_attached_file( $ID );
383
  foreach ( $meta['sizes'] as $size_key => $size_data ) {
384
 
385
  //Check if registered size is supposed to be Smushed or not
386
+ if ( 'full' != $size_key && $wpsmushit_admin->skip_image_size( $size_key ) ) {
387
  continue;
388
  }
389
 
431
  }
432
 
433
  //If there are no stats
434
+ if ( empty( $response['data'] ) ) {
435
  continue;
436
  }
437
 
438
  //If the image size grew after smushing, skip it
439
+ if ( $response['data']->after_size > $response['data']->before_size ) {
440
  continue;
441
  }
442
 
447
  if ( empty( $stats['stats']['api_version'] ) || $stats['stats']['api_version'] == - 1 ) {
448
  $stats['stats']['api_version'] = $response['data']->api_version;
449
  $stats['stats']['lossy'] = $response['data']->lossy;
450
+ $stats['stats']['keep_exif'] = ! empty( $response['data']->keep_exif ) ? $response['data']->keep_exif : 0;
451
  }
452
  }
453
  //Upfront Integration
477
  }
478
 
479
  //If there are no stats
480
+ if ( empty( $full_image_response['data'] ) ) {
481
  $store_stats = false;
482
  }
483
 
484
  //If the image size grew after smushing, skip it
485
+ if ( $full_image_response['data']->after_size > $full_image_response['data']->before_size ) {
486
  $store_stats = false;
487
  }
488
 
495
  if ( empty( $stats['stats']['api_version'] ) || $stats['stats']['api_version'] == - 1 ) {
496
  $stats['stats']['api_version'] = $full_image_response['data']->api_version;
497
  $stats['stats']['lossy'] = $full_image_response['data']->lossy;
498
+ $stats['stats']['keep_exif'] = ! empty( $full_image_response['data']->keep_exif ) ? $full_image_response['data']->keep_exif : 0;
499
  }
500
 
501
  }
518
  $stats['sizes'][ $size_name ] = $existing_stats['sizes'][ $size_name ];
519
  } else {
520
 
521
+ $existing_stats_size = (object) $existing_stats['sizes'][ $size_name ];
522
 
523
  //store the original image size
524
+ $stats['sizes'][ $size_name ]->size_before = ( ! empty( $existing_stats_size->size_before ) && $existing_stats_size->size_before > $stats['sizes'][ $size_name ]->size_before ) ? $existing_stats_size->size_before : $stats['sizes'][ $size_name ]->size_before;
525
 
526
  //Update compression percent and bytes saved for each size
527
  $stats['sizes'][ $size_name ]->bytes = $stats['sizes'][ $size_name ]->bytes + $existing_stats_size->bytes;
535
  $stats = $this->total_compression( $stats );
536
 
537
  //If there was any compression and there was no error in smushing
538
+ if ( isset( $stats['stats']['bytes'] ) && $stats['stats']['bytes'] >= 0 && ! $has_errors ) {
539
  /**
540
  * Runs if the image smushing was successful
541
  *
542
+ * @param int $ID Image Id
543
  *
544
  * @param array $stats Smush Stats for the image
545
+ *
546
  */
547
+ do_action( 'wp_smush_image_optimised', $ID, $stats );
548
  }
549
  update_post_meta( $ID, $this->smushed_meta_key, $stats );
550
  }
572
  */
573
  function smush_image( $meta, $ID = null ) {
574
 
575
+ //Check if Async is Enabled, Do not run
576
+ if ( defined( 'WP_SMUSH_ASYNC' ) && WP_SMUSH_ASYNC ) {
577
+ return $meta;
578
+ }
579
+
580
  //Return directly if not a image
581
  if ( ! wp_attachment_is_image( $ID ) ) {
582
  return $meta;
583
  }
584
 
585
+ /**
586
+ * Filter: wp_smush_image
587
+ *
588
+ * Whether to smush the given attachment id or not
589
+ *
590
+ * @param $skip bool, whether to Smush image or not
591
+ *
592
+ * @param $Attachment Id, Attachment id of the image being processed
593
+ *
594
+ */
595
+ if ( ! apply_filters( 'wp_smush_image', true, $ID ) ) {
596
+ return false;
597
+ }
598
+
599
+ //If the smushing transient is already set, return the status
600
+ if ( get_transient( 'smush-in-progress-' . $ID ) ) {
601
+ return $meta;
602
+ }
603
+
604
+ //Set a transient to avoid multiple request
605
+ set_transient( 'smush-in-progress-' . $ID, true, 5 * MINUTE_IN_SECONDS );
606
+
607
+ global $wpsmush_resize, $wpsmush_pngjpg, $wpsmush_settings;
608
 
609
  //Check if auto is enabled
610
  $auto_smush = $this->is_auto_smush_enabled();
622
  //Check for use of http url, (Hostgator mostly)
623
  $use_http = wp_cache_get( WP_SMUSH_PREFIX . 'use_http', 'smush' );
624
  if ( ! $use_http ) {
625
+ $use_http = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'use_http', false );
626
  wp_cache_add( WP_SMUSH_PREFIX . 'use_http', $use_http, 'smush' );
627
  }
628
+ if ( $use_http ) {
629
  //HTTP Url
630
  define( 'WP_SMUSH_API_HTTP', 'http://smushpro.wpmudev.org/1.0/' );
631
  }
637
  delete_post_meta( $ID, $this->smushed_meta_key );
638
  }
639
 
640
+ //Delete Transient
641
+ delete_transient( 'smush-in-progress-' . $ID );
642
+
643
  return $meta;
644
  }
645
 
653
  * @return bool|array array containing success status, and stats
654
  */
655
  function _post( $file_path, $file_size ) {
656
+ global $wpsmushit_admin, $wpsmush_settings;
657
 
658
  $data = false;
659
 
697
  //Hostgator Issue
698
  if ( ! empty( $er_msg ) && strpos( $er_msg, 'SSL CA cert' ) !== false ) {
699
  //Update DB for using http protocol
700
+ $wpsmush_settings->update_setting( WP_SMUSH_PREFIX . 'use_http', 1 );
701
  }
702
  //Handle error
703
  $data['message'] = sprintf( __( 'Error posting to API: %s', 'wp-smushit' ), $result->get_error_message() );
738
  $data['data'] = $response->data;
739
  }
740
  //If is_premium is set in response, send it over to check for member validity
741
+ if ( ! empty( $response->data ) && isset( $response->data->is_premium ) ) {
742
  $wpsmushit_admin->api_headers['is_premium'] = $response->data->is_premium;
743
  }
744
  } else {
872
 
873
  if ( ! is_wp_error( $request ) && '200' == wp_remote_retrieve_response_code( $request ) ) {
874
  $result = json_decode( wp_remote_retrieve_body( $request ) );
875
+ if ( ! empty( $result->success ) && $result->success ) {
876
  $valid = 'valid';
877
  } else {
878
  $valid = 'invalid';
944
  $status_txt = $button_txt = $stats = '';
945
  $show_button = $show_resmush = false;
946
 
947
+ $wp_smush_data = get_post_meta( $id, $this->smushed_meta_key, true );
948
+ $wp_resize_savings = get_post_meta( $id, WP_SMUSH_PREFIX . 'resize_savings', true );
949
+ $conversion_savings = get_post_meta( $id, WP_SMUSH_PREFIX . 'pngjpg_savings', true );
950
 
951
  $combined_stats = $this->combined_stats( $wp_smush_data, $wp_resize_savings );
952
 
968
  $show_button = false;
969
  } else {
970
  if ( $bytes == 0 || $percent == 0 ) {
971
+ $status_txt = __( 'Already Optimized', 'wp-smushit' );
972
 
973
  //Show resmush link, if the settings were changed
974
  $show_resmush = $this->show_resmush( $id, $wp_smush_data );
977
  }
978
 
979
  } elseif ( ! empty( $percent ) && ! empty( $bytes_readable ) ) {
980
+ $status_txt = $image_count > 1 ? sprintf( __( "%d images reduced ", 'wp-smushit' ), $image_count ) : __( "Reduced ", 'wp-smushit' );
981
 
982
  $stats_percent = number_format_i18n( $percent, 2, '.', '' );
983
  $stats_percent = $stats_percent > 0 ? sprintf( "( %01.1f%% )", $stats_percent ) : '';
984
  $status_txt .= sprintf( __( "by %s %s", 'wp-smushit' ), $bytes_readable, $stats_percent );
985
 
986
  $file_path = get_attached_file( $id );
987
+ $size = file_exists( $file_path ) ? filesize( $file_path ) : 0;
988
+ if ( $size > 0 ) {
989
  $size = size_format( $size, 1 );
990
+ $image_size = sprintf( __( "<br /> Image Size: %s", "wp-smushit" ), $size );
991
  $status_txt .= $image_size;
992
  }
993
 
1052
  $show_button = true;
1053
  }
1054
 
1055
+ } elseif ( get_transient( 'smush-in-progress-' . $id ) ) {
1056
+ // the status
1057
+ $status_txt = __( 'Smushing in progress..', 'wp-smushit' );
1058
+
1059
+ //Set WP Smush data to true in order to show the text
1060
+ $wp_smush_data = true;
1061
+
1062
+ // we need to show the smush button
1063
+ $show_button = false;
1064
+
1065
+ // the button text
1066
+ $button_txt = '';
1067
  } else {
1068
 
1069
  // the status
1171
  return;
1172
  }
1173
 
1174
+ $migrated_version = get_site_option( $this->migrated_version_key );
1175
 
1176
  if ( $migrated_version === $this->version ) {
1177
  return;
1194
  }
1195
  }
1196
 
1197
+ update_site_option( $this->migrated_version_key, $this->version );
1198
 
1199
  }
1200
 
1240
  'sizes' => array()
1241
  );
1242
  $stats['stats']['api_version'] = $data->api_version;
1243
+ $stats['stats']['lossy'] = $data->lossy;
1244
+ $stats['stats']['keep_exif'] = ! empty( $data->keep_exif ) ? $data->keep_exif : 0;
1245
 
1246
  //Update size wise details
1247
  $stats['sizes'][ $image_size ] = (object) $this->_array_fill_placeholders( $this->_get_size_signature(), (array) $data );
1264
 
1265
  //Initialize attachment id and media type
1266
  $this->attachment_id = $id;
1267
+ $this->media_type = "wp";
1268
 
1269
  /**
1270
  * Allows to Enable/Disable WP Retina 2x Integration
1432
  foreach ( $size_stats as $size_key => $size_value ) {
1433
  $dimensions = '';
1434
  //Get the dimensions for the image size if available
1435
+ if ( ! empty( $wpsmushit_admin->image_sizes ) && ! empty( $wpsmushit_admin->image_sizes[ $size_key ] ) ) {
1436
  $dimensions = $wpsmushit_admin->image_sizes[ $size_key ]['width'] . 'x' . $wpsmushit_admin->image_sizes[ $size_key ]['height'];
1437
  }
1438
+ $dimensions = ! empty( $dimensions ) ? sprintf( " <br /> (%s)", $dimensions ) : '';
1439
  if ( $size_value->bytes > 0 ) {
1440
  $percent = round( $size_value->percent, 1 );
1441
  $percent = $percent > 0 ? ' ( ' . $percent . '% )' : '';
1472
  if ( ! class_exists( 'C_NextGEN_Bootstrap' ) || ! $this->validate_install() ) {
1473
  return;
1474
  }
1475
+
1476
+ global $wpsmush_settings;
1477
+
1478
  //Check if integration is Enabled or not
1479
  //Smush NextGen key
1480
  $opt_nextgen = WP_SMUSH_PREFIX . 'nextgen';
1481
+ $opt_nextgen_val = $wpsmush_settings->get_setting( $opt_nextgen, false );
1482
  if ( ! $opt_nextgen_val ) {
1483
  return;
1484
  }
1575
  $backup = get_post_meta( $image_id, WP_SMUSH_PREFIX . 'original_file', true );
1576
  $backup = $this->original_file( $backup );
1577
 
1578
+ if ( ! empty( $backup ) && file_exists( $backup ) ) {
1579
  return true;
1580
  }
1581
  }
1582
 
1583
+ if ( ! empty( $attachment_data['sizes'] ) ) {
1584
  //Check for backup of image sizes
1585
  foreach ( $attachment_data['sizes'] as $image_size ) {
1586
  $size_path = path_join( dirname( $file ), $image_size['file'] );
1629
  * @return int|mixed|void
1630
  */
1631
  function is_auto_smush_enabled() {
1632
+
1633
+ global $wpsmush_settings;
1634
+
1635
+ $auto_smush = $wpsmush_settings->get_setting( WP_SMUSH_PREFIX . 'auto', false );
1636
 
1637
  //Keep the auto smush on by default
1638
  if ( $auto_smush === false ) {
1675
  if ( empty( $attachment_path ) ) {
1676
  return false;
1677
  }
1678
+ $path = pathinfo( $attachment_path );
1679
+
1680
+ //If we don't have complete filename return false
1681
+ if ( empty( $path['extension'] ) ) {
1682
+ return false;
1683
+ }
1684
+
1685
  $backup_name = trailingslashit( $path['dirname'] ) . $path['filename'] . ".bak." . $path['extension'];
1686
 
1687
  return $backup_name;
1750
 
1751
  //Set attachment id and Media type
1752
  $this->attachment_id = $attachment_id;
1753
+ $this->media_type = "upfront";
1754
 
1755
  //Get post meta to check for Upfront images
1756
  $upfront_images = get_post_meta( $attachment_id, 'upfront_used_image_sizes', true );
1774
 
1775
  //If the smushing was successful
1776
  if ( ! is_wp_error( $res ) && ! empty( $res['data'] ) ) {
1777
+ if ( $res['data']->bytes_saved > 0 ) {
1778
  //Update attachment stats
1779
  $stats['sizes'][ $element_id ] = (object) $this->_array_fill_placeholders( $this->_get_size_signature(), (array) $res['data'] );
1780
  }
1793
 
1794
  /**
1795
  * Checks the current settings and returns the value whether to enable or not the resmush option
1796
+ *
1797
  * @param $show_resmush
1798
  * @param $wp_smush_data
1799
  *
1841
  return 0;
1842
  }
1843
  $size_before = ! empty( $stats->size_before ) ? $stats->size_before : $existing_stats->size_before;
1844
+ $size_after = ! empty( $stats->size_after ) ? $stats->size_after : $existing_stats->size_after;
1845
  $savings = $size_before - $size_after;
1846
  if ( $savings > 0 ) {
1847
  $percentage = ( $savings / $size_before ) * 100;
1853
  return 0;
1854
  }
1855
 
1856
+ /**
1857
+ * Calculate saving percentage for a given size stats
1858
+ *
1859
+ * @param $stats
1860
+ *
1861
+ * @return float|int
1862
+ */
1863
+ function calculate_percentage_from_stats( $stats ) {
1864
+ if ( empty( $stats ) || ! isset( $stats->size_before, $stats->size_after ) ) {
1865
+ return 0;
1866
+ }
1867
+
1868
+ $savings = $stats->size_before - $stats->size_after;
1869
+ if ( $savings > 0 ) {
1870
+ $percentage = ( $savings / $stats->size_before ) * 100;
1871
+ $percentage = $percentage > 0 ? round( $percentage, 2 ) : $percentage;
1872
+
1873
+ return $percentage;
1874
+ }
1875
+ }
1876
+
1877
  /**
1878
  * Redirects the user to Plugin settings page on Plugin activation
1879
  *
1886
  global $wpsmushit_admin, $wpsmush_stats;
1887
 
1888
  //Run for only our plugin
1889
+ if ( $plugin != WP_SMUSH_BASENAME ) {
1890
  return false;
1891
  }
1892
 
1895
  }
1896
 
1897
  //Skip if bulk activation, Or if we have to skip redirection
1898
+ if ( isset( $_GET['activate-multi'] ) || get_site_option( 'wp-smush-skip-redirect' ) ) {
1899
  return false;
1900
  }
1901
 
1902
  //If images are already smushed
1903
+ if ( $wpsmush_stats->smushed_count( false ) > 0 ) {
1904
  return false;
1905
  }
1906
 
1907
  $url = admin_url( 'upload.php' );
1908
  $url = add_query_arg(
1909
  array(
1910
+ 'page' => 'wp-smush-bulk'
1911
  ),
1912
  $url
1913
  );
1914
 
1915
  //Store that we need not redirect again
1916
+ add_site_option( 'wp-smush-skip-redirect', true );
1917
 
1918
  exit( wp_redirect( $url ) );
1919
  }
1920
 
1921
  /**
1922
  * Clear up all the backup files for the image, if any
1923
+ *
1924
  * @param $image_id
1925
  */
1926
  function delete_backup_files( $image_id ) {
1977
  function total_compression( $stats ) {
1978
  $stats['stats']['size_before'] = $stats['stats']['size_after'] = $stats['stats']['time'] = '';
1979
  foreach ( $stats['sizes'] as $size_stats ) {
1980
+ $stats['stats']['size_before'] += ! empty( $size_stats->size_before ) ? $size_stats->size_before : 0;
1981
+ $stats['stats']['size_after'] += ! empty( $size_stats->size_after ) ? $size_stats->size_after : 0;
1982
+ $stats['stats']['time'] += ! empty( $size_stats->time ) ? $size_stats->time : 0;
1983
  }
1984
  $stats['stats']['bytes'] = ! empty( $stats['stats']['size_before'] ) && $stats['stats']['size_before'] > $stats['stats']['size_after'] ? $stats['stats']['size_before'] - $stats['stats']['size_after'] : 0;
1985
  if ( ! empty( $stats['stats']['bytes'] ) && ! empty( $stats['stats']['size_before'] ) ) {
2003
  }
2004
 
2005
  //Full Image
2006
+ if ( ! empty( $smush_stats['sizes']['full'] ) ) {
2007
  $smush_stats['sizes']['full']->bytes = ! empty( $resize_savings['bytes'] ) ? $smush_stats['sizes']['full']->bytes + $resize_savings['bytes'] : $smush_stats['sizes']['full']->bytes;
2008
+ $smush_stats['sizes']['full']->size_before = ! empty( $resize_savings['size_before'] ) && ( $resize_savings['size_before'] > $smush_stats['sizes']['full']->size_before ) ? $resize_savings['size_before'] : $smush_stats['sizes']['full']->size_before;
2009
  $smush_stats['sizes']['full']->percent = ! empty( $smush_stats['sizes']['full']->bytes ) && $smush_stats['sizes']['full']->size_before > 0 ? ( $smush_stats['sizes']['full']->bytes / $smush_stats['sizes']['full']->size_before ) * 100 : $smush_stats['sizes']['full']->percent;
2010
 
2011
  $smush_stats['sizes']['full']->percent = round( $smush_stats['sizes']['full']->percent, 1 );
2069
 
2070
  global $wpsmushit_admin;
2071
  // Return. If we don't have any headers
2072
+ if ( ! isset( $wpsmushit_admin->api_headers ) ) {
2073
  return false;
2074
  }
2075
 
2076
  //Show warning, if function says it's premium and api says not premium
2077
+ if ( isset( $wpsmushit_admin->api_headers['is_premium'] ) && ! intval( $wpsmushit_admin->api_headers['is_premium'] ) ) {
2078
  return true;
2079
  }
2080
 
2089
  $show = $this->show_warning();
2090
  wp_send_json( intval( $show ) );
2091
  }
2092
+
2093
+ /**
2094
+ * Initialize the Smush Async class
2095
+ */
2096
+ function wp_smush_async() {
2097
+
2098
+ //Don't load the Async task, if user not logged in or not in backend
2099
+ if ( ! is_user_logged_in() || ! is_admin() ) {
2100
+ return;
2101
+ }
2102
+
2103
+ //Check if Async is disabled
2104
+ if ( defined( 'WP_SMUSH_ASYNC' ) && ! WP_SMUSH_ASYNC ) {
2105
+ return;
2106
+ }
2107
+
2108
+ //Instantiate Class
2109
+ new WpSmushAsync();
2110
+ new WpSmushEditorAsync();
2111
+ }
2112
+
2113
+ /**
2114
+ * Send a smush request for the attachment
2115
+ *
2116
+ * @param $id Attachment ID
2117
+ */
2118
+ function wp_smush_handle_async( $id ) {
2119
+
2120
+ //If we don't have image id, or the smush is already in progress for the image, return
2121
+ if ( empty( $id ) || get_transient( 'smush-in-progress-' . $id ) ) {
2122
+ return;
2123
+ }
2124
+
2125
+ //If auto Smush is disabled
2126
+ if ( ! $this->is_auto_smush_enabled() ) {
2127
+ return;
2128
+ }
2129
+
2130
+ /**
2131
+ * Filter: wp_smush_image
2132
+ *
2133
+ * Whether to smush the given attachment id or not
2134
+ *
2135
+ * @param $skip bool, whether to Smush image or not
2136
+ *
2137
+ * @param $Attachment Id, Attachment id of the image being processed
2138
+ *
2139
+ */
2140
+ if ( ! apply_filters( 'wp_smush_image', true, $id ) ) {
2141
+ return;
2142
+ }
2143
+
2144
+ global $wpsmushit_admin;
2145
+ $wpsmushit_admin->smush_single( $id, true );
2146
+
2147
+ }
2148
+
2149
+ /**
2150
+ * Send a smush request for the attachment
2151
+ *
2152
+ * @param $id Attachment ID
2153
+ */
2154
+ function wp_smush_handle_editor_async( $id, $post_data ) {
2155
+
2156
+ //If we don't have image id, or the smush is already in progress for the image, return
2157
+ if ( empty( $id ) || get_transient( 'smush-in-progress-' . $id ) ) {
2158
+ return;
2159
+ }
2160
+
2161
+ //If auto Smush is disabled
2162
+ if ( ! $this->is_auto_smush_enabled() ) {
2163
+ return;
2164
+ }
2165
+
2166
+ /**
2167
+ * Filter: wp_smush_image
2168
+ *
2169
+ * Whether to smush the given attachment id or not
2170
+ *
2171
+ * @param $skip bool, whether to Smush image or not
2172
+ *
2173
+ * @param $Attachment Id, Attachment id of the image being processed
2174
+ *
2175
+ */
2176
+ if ( ! apply_filters( 'wp_smush_image', true, $id ) ) {
2177
+ return;
2178
+ }
2179
+
2180
+ //If filepath is not set or file doesn't exists
2181
+ if ( ! isset( $post_data['filepath'] ) || ! file_exists( $post_data['filepath'] ) ) {
2182
+ return;
2183
+ }
2184
+
2185
+ //Send image for smushing
2186
+ $res = $this->do_smushit( $post_data['filepath'] );
2187
+
2188
+ //Exit if smushing wasn't successful
2189
+ if ( empty( $res['success'] ) || ! $res['success'] ) {
2190
+ return;
2191
+ }
2192
+
2193
+ //Update stats if it's the full size image
2194
+ //Return if it's not the full image size
2195
+ if ( $post_data['filepath'] != get_attached_file( $post_data['postid'] ) ) {
2196
+ return;
2197
+ }
2198
+
2199
+ //Get the existing Stats
2200
+ $smush_stats = get_post_meta( $post_data['postid'], $this->smushed_meta_key, true );
2201
+ $stats_full = ! empty( $smush_stats['sizes'] ) && ! empty( $smush_stats['sizes']['full'] ) ? $smush_stats['sizes']['full'] : '';
2202
+
2203
+ if ( empty( $stats_full ) ) {
2204
+ return;
2205
+ }
2206
+
2207
+ //store the original image size
2208
+ $stats_full->size_before = ( ! empty( $stats_full->size_before ) && $stats_full->size_before > $res['data']->before_size ) ? $stats_full->size_before : $res['data']->before_size;
2209
+ $stats_full->size_after = $res['data']->after_size;
2210
+
2211
+ //Update compression percent and bytes saved for each size
2212
+ $stats_full->bytes = $stats_full->size_before - $stats_full->size_after;
2213
+
2214
+ $stats_full->percent = $this->calculate_percentage_from_stats( $stats_full );
2215
+ $smush_stats['sizes']['full'] = $stats_full;
2216
+
2217
+ //Update Stats
2218
+ update_post_meta( $post_data['postid'], $this->smushed_meta_key, $smush_stats );
2219
+ }
2220
  }
2221
 
2222
  global $WpSmush;
lib/nextgen-integration/class-wp-smush-nextgen-stats.php CHANGED
@@ -177,7 +177,7 @@ if ( ! class_exists( 'WpSmushNextGenStats' ) ) {
177
  * @return bool|null|string|void
178
  */
179
  function show_stats( $pid, $wp_smush_data = false, $image_type = '', $text_only = false, $echo = true ) {
180
- global $WpSmush, $wpsmushnextgenadmin;
181
  if ( empty( $wp_smush_data ) ) {
182
  return false;
183
  }
@@ -267,7 +267,7 @@ if ( ! class_exists( 'WpSmushNextGenStats' ) ) {
267
 
268
  //Check if Lossy enabled
269
  $opt_lossy = WP_SMUSH_PREFIX . 'lossy';
270
- $opt_lossy_val = get_option( $opt_lossy, false );
271
 
272
  //Check if premium user, compression was lossless, and lossy compression is enabled
273
  if ( !$show_resmush && $this->is_pro_user && ! $is_lossy && $opt_lossy_val && ! empty( $image_type ) && $image_type != 'image/gif' ) {
177
  * @return bool|null|string|void
178
  */
179
  function show_stats( $pid, $wp_smush_data = false, $image_type = '', $text_only = false, $echo = true ) {
180
+ global $WpSmush, $wpsmushnextgenadmin, $wpsmush_settings;
181
  if ( empty( $wp_smush_data ) ) {
182
  return false;
183
  }
267
 
268
  //Check if Lossy enabled
269
  $opt_lossy = WP_SMUSH_PREFIX . 'lossy';
270
+ $opt_lossy_val = $wpsmush_settings->get_setting( $opt_lossy, false );
271
 
272
  //Check if premium user, compression was lossless, and lossy compression is enabled
273
  if ( !$show_resmush && $this->is_pro_user && ! $is_lossy && $opt_lossy_val && ! empty( $image_type ) && $image_type != 'image/gif' ) {
lib/wp-async-task.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' ) ) {
12
+ abstract class WP_Async_Task {
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' => 0.01,
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,20 +1,20 @@
1
- === WP Smush - Image Optimization ===
2
- Plugin Name: WP Smush - Image Optimization
3
- Version: 2.4.5
4
  Author: WPMU DEV
5
  Author URI: http://premium.wpmudev.org/
6
  Contributors: WPMUDEV, alexdunae
7
- Tags: image optimization, image compression, attachment,Attachments,compress,Compress Image File,Compress Image Size,Compress JPG,Compressed JPG, Compression Image,Image,Images,JPG,Optimise,Optimize,Photo,Photos,Pictures,PNG,Reduce Image Size,Smush,Smush.it,Upload,WordPress Compression,WordPress Image Tool,Yahoo, Yahoo Smush.it
8
  Requires at least: 3.5
9
- Tested up to: 4.6
10
- Stable tag: 2.4.5
11
  License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12
 
13
- Reduce image file sizes, improve performance and boost your SEO using the free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
14
 
15
  == Description ==
16
 
17
- <strong>Resize and optimize all of your images</strong> with the <strong>incredibly powerful</strong> and <strong>100% free image smusher</strong>, brought to you by the superteam at WPMU DEV!
18
 
19
  <strong>Now with image resizing!</strong> Set a max width and height and large images will scale down as they are being compressed.
20
 
@@ -34,7 +34,9 @@ WP Smush meticulously scans every image you upload – or have already added to
34
  ★★★★★ <br>
35
  “I optimize my photos in Photoshop, but Smush makes it so easy – it does it automatically. I can just sit back and enjoy the speed.” - <a href="https://profiles.wordpress.org/helen432">helen432</a>
36
 
37
- WP Smush is super easy to use no confusing compression software settings! Smush images in your library one at a time or bulk smush up to 50 images at a time. Plus, configure automatic smush to scale and compress some or all of your images as they are being uploaded.
 
 
38
 
39
  The faster your site loads, the more Google, Bing, Yahoo and other search engines will like it. Your site will load faster and rank higher.
40
 
@@ -45,10 +47,11 @@ The faster your site loads, the more Google, Bing, Yahoo and other search engine
45
  <li>Optimize your images using advanced lossless compression techniques.</li>
46
  <li>Set maximum width and height and large images will automatically scale before being added to your media library</li>
47
  <li>Process JPEG, GIF and PNG image files.</li>
48
- <li>Auto-smush your attachments on upload.</li>
49
  <li>Manually smush your attachments individually in the media library, or in bulk 50 attachments at a time.</li>
50
  <li>Smush all standard web-sized images 1MB or smaller. </li>
51
  <li>Smush images with no slowdown using WPMU DEV's fast, reliable Smush API.</li>
 
52
  <li>View advanced compression stats per-attachment and library totals.</li>
53
  </ul>
54
 
@@ -72,6 +75,38 @@ WP Smush Pro gives you everything you'll find in WP Smush and more:
72
  Upgrade to WP Smush Pro and optimize more and larger image files faster to increase your site’s performance.
73
 
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  == Screenshots ==
76
 
77
  1. Watch as your image library is processed – up to 50 images at a time.
@@ -92,6 +127,17 @@ Yahoo's Smush.it API is gone forever. So WPMU DEV built our own free API that is
92
 
93
  == Changelog ==
94
 
 
 
 
 
 
 
 
 
 
 
 
95
  = 2.4.5 =
96
 
97
  * Fixed:
1
+ === Smush Image Compression and Optimization ===
2
+ Plugin Name: Smush Image Compression and Optimization
3
+ Version: 2.5.2
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
10
+ Stable tag: 2.5.2
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.
14
 
15
  == Description ==
16
 
17
+ <strong>Resize, optimize and compress all of your images</strong> with the <strong>incredibly powerful</strong> and <strong>100% free WordPress image smusher</strong>, brought to you by the superteam at WPMU DEV!
18
 
19
  <strong>Now with image resizing!</strong> Set a max width and height and large images will scale down as they are being compressed.
20
 
34
  ★★★★★ <br>
35
  “I optimize my photos in Photoshop, but Smush makes it so easy – it does it automatically. I can just sit back and enjoy the speed.” - <a href="https://profiles.wordpress.org/helen432">helen432</a>
36
 
37
+ <strong>What about Multisite?</strong> WP Smush can be used to optimize all the images across your entire network! Use global settings or configure each site individually.
38
+
39
+ WP Smush is super easy to use – no confusing compression software settings! Smush images in your library one at a time or bulk smush up to 50 images at a time. Plus, configure auto-smush to asyncronously scale and compress some or all of your images as they are being uploaded – it's incredibly fast.
40
 
41
  The faster your site loads, the more Google, Bing, Yahoo and other search engines will like it. Your site will load faster and rank higher.
42
 
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>
53
  <li>Smush images with no slowdown using WPMU DEV's fast, reliable Smush API.</li>
54
+ <li>Global and individual settings for Multisite </li>
55
  <li>View advanced compression stats per-attachment and library totals.</li>
56
  </ul>
57
 
75
  Upgrade to WP Smush Pro and optimize more and larger image files faster to increase your site’s performance.
76
 
77
 
78
+ == Frequently Asked Questions ==
79
+
80
+ = I just finished running Smush and Google Pagespeed still says my images need compressing and resizing. How do I fix it? =
81
+
82
+ This means your images were not properly scaled for where they are being displayed. Scaling images before uploading them can be time consuming but can save space and speedup load time. First, determine what size your image needs to be. You can use the built-in developer tools in Chrome or Firefox to find what height and width your image should be. Once you know how large the image should be, scale your images to the right size.
83
+
84
+
85
+ <strong>Tip:</strong> you may not be need to scale each image individually. If the images are in your Media Library, you may be able to fix them with a plugin.
86
+
87
+ = Does Smush delete or replace my original full-size images? =
88
+
89
+ Nope. 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 compress your original full-sized images use <a href="https://premium.wpmudev.org/project/wp-smush-pro/?utm_source=wordpress.org&utm_medium=readme">WP Smush Pro</a>.
90
+
91
+ = What type of file should I use for my images (GIF, PNG, JPG)? =
92
+
93
+ GIF files are large and can’t be optimized much. They should only be used if the image is animated.
94
+
95
+
96
+ PNG is best for computer generated graphics (vectors, logos, fonts, etc.), images with few colors or images with transparency.
97
+
98
+
99
+ JPG should be used for photography or images with a lot of color variation.
100
+
101
+ = I’m a photographer can I keep all my EXIF data? =
102
+
103
+ Yes! 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. We have included the option to preserve EXIF image data in WP Smush.
104
+
105
+ = I just ran bulk smush and some of my images didn't get compressed? =
106
+
107
+ First, check to see if you're receiving any server errors. If your images seem to be processing correctly check the file size of the images being skipped. Images over 1mb will be skipped. To compress images up to 32mb get <a href="https://premium.wpmudev.org/project/wp-smush-pro/?utm_source=wordpress.org&utm_medium=readme">WP Smush Pro</a>.
108
+
109
+
110
  == Screenshots ==
111
 
112
  1. Watch as your image library is processed – up to 50 images at a time.
127
 
128
  == Changelog ==
129
 
130
+ = 2.5.2 =
131
+
132
+ * Added:
133
+ * Filter: `wp_smush_image`, Boolean, Whether to Smush image or not
134
+ * Async Optimisation for Auto Smush on upload ( Set WP_SMUSH_ASYNC to false to turn off async optimisation )
135
+ * Networkwide settings option in a Multisite
136
+
137
+ * Fixed:
138
+ * Double slash in file path causing 403 on some of the sites
139
+ * Localisation error reported by @talgat ( Thank You :) )
140
+
141
  = 2.4.5 =
142
 
143
  * Fixed:
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.4.5
8
  Author URI: http://premium.wpmudev.org/
9
  Textdomain: 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.4.5';
39
 
40
  //Deactivate the .org version, if pro version is active
41
  add_action( 'admin_init', 'deactivate_smush_org' );
@@ -65,7 +65,9 @@ $smush_constants = array(
65
  'MAX_BYTES' => 1000000,
66
  'PREMIUM_MAX_BYTES' => 32000000,
67
  'PREFIX' => 'wp-smush-',
68
- 'TIMEOUT' => $timeout
 
 
69
  );
70
 
71
  foreach ( $smush_constants as $const_name => $constant_val ) {
@@ -180,7 +182,8 @@ if ( is_admin() ) {
180
  'id' => 912164,
181
  'name' => 'WP Smush Pro',
182
  'screens' => array(
183
- 'upload'
 
184
  )
185
  );
186
  }
@@ -215,11 +218,11 @@ if ( ! function_exists( 'smush_activated' ) ) {
215
  $results = $wpdb->get_var( $wpdb->prepare( $query, 'wp-smpro-smush-data' ) );
216
 
217
  if ( $results ) {
218
- update_option( 'wp-smush-install-type', 'existing' );
219
  } else {
220
  //Check for existing settings
221
  if ( false !== get_site_option( WP_SMUSH_PREFIX . 'auto' ) || false !== get_option( WP_SMUSH_PREFIX . 'auto' ) ) {
222
- update_option( 'wp-smush-install-type', 'existing' );
223
  }
224
  }
225
 
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.2
8
  Author URI: http://premium.wpmudev.org/
9
  Textdomain: wp-smushit
10
  */
35
  * Constants
36
  */
37
  $prefix = 'WP_SMUSH_';
38
+ $version = '2.5.2';
39
 
40
  //Deactivate the .org version, if pro version is active
41
  add_action( 'admin_init', 'deactivate_smush_org' );
65
  'MAX_BYTES' => 1000000,
66
  'PREMIUM_MAX_BYTES' => 32000000,
67
  'PREFIX' => 'wp-smush-',
68
+ 'TIMEOUT' => $timeout,
69
+ //If Set to false, WP Smush switch backs to the Old Sync Optimisation
70
+ 'ASYNC' => true
71
  );
72
 
73
  foreach ( $smush_constants as $const_name => $constant_val ) {
182
  'id' => 912164,
183
  'name' => 'WP Smush Pro',
184
  'screens' => array(
185
+ 'upload',
186
+ 'media_page_wp-smush-bulk'
187
  )
188
  );
189
  }
218
  $results = $wpdb->get_var( $wpdb->prepare( $query, 'wp-smpro-smush-data' ) );
219
 
220
  if ( $results ) {
221
+ update_site_option( 'wp-smush-install-type', 'existing' );
222
  } else {
223
  //Check for existing settings
224
  if ( false !== get_site_option( WP_SMUSH_PREFIX . 'auto' ) || false !== get_option( WP_SMUSH_PREFIX . 'auto' ) ) {
225
+ update_site_option( 'wp-smush-install-type', 'existing' );
226
  }
227
  }
228