Version Description
- Fixed:
- Tooltip on image edit page
- Warning and Notices
- Updated:
- Improved stats calculation
- Bulk Smush page optimised for Image heavy sites
- Cleanup on uninstall
- Added:
- Image Resizing option for Media, NextGen(Pro Only) images
- Total image count on stats page
Download this release
Release Info
Developer | jdailey |
Plugin | Smush Image Compression and Optimization |
Version | 2.3 |
Comparing to | |
See all releases |
Code changes from version 2.2.2 to 2.3
- assets/css/notice.css +181 -0
- assets/css/wp-smushit-admin.css +98 -19
- assets/js/notice.js +55 -0
- assets/js/wp-smushit-admin.js +252 -98
- extras/free-dashboard/.gitignore +0 -1
- extras/free-dashboard/README.md +0 -71
- languages/wp-smushit.pot +190 -159
- lib/class-wp-smush-admin.php +315 -355
- lib/class-wp-smush-bulk.php +18 -7
- lib/class-wp-smush-nextgen.php +222 -44
- lib/class-wp-smush-resize.php +400 -0
- lib/class-wp-smush-stats.php +422 -0
- lib/class-wp-smush-ui.php +110 -73
- lib/class-wp-smush.php +112 -81
- lib/nextgen-integration/class-wp-smush-nextgen-admin.php +57 -18
- lib/nextgen-integration/class-wp-smush-nextgen-bulk.php +28 -19
- lib/nextgen-integration/class-wp-smush-nextgen-stats.php +43 -7
- readme.txt +26 -10
- uninstall.php +65 -24
- wp-smush.php +4 -4
assets/css/notice.css
ADDED
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* CSS styles used Admin notice
|
3 |
+
*/
|
4 |
+
|
5 |
+
.wrap .smush-notice.notice {
|
6 |
+
padding: 0;
|
7 |
+
margin: 5px 0 10px;
|
8 |
+
border: 1px solid #E5E5E5;
|
9 |
+
background: #FFF;
|
10 |
+
overflow: hidden;
|
11 |
+
-webkit-border-radius: 6px;
|
12 |
+
border-radius: 6px;
|
13 |
+
-webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.05);
|
14 |
+
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.05);
|
15 |
+
position: relative;
|
16 |
+
z-index: 1;
|
17 |
+
min-height: 80px;
|
18 |
+
display: table; /* The magic ingredient! */
|
19 |
+
font: 13px "Open Sans", sans-serif;
|
20 |
+
}
|
21 |
+
|
22 |
+
.wrap .smush-notice.notice.loading:before {
|
23 |
+
content: attr(data-message);
|
24 |
+
position: absolute;
|
25 |
+
left: 0;
|
26 |
+
right: 0;
|
27 |
+
top: 0;
|
28 |
+
bottom: 0;
|
29 |
+
background-color: rgba(255, 255, 255, 0.7);
|
30 |
+
z-index: 5;
|
31 |
+
text-align: center;
|
32 |
+
line-height: 80px;
|
33 |
+
font-size: 22px;
|
34 |
+
font-weight: bold;
|
35 |
+
}
|
36 |
+
|
37 |
+
.smush-notice > div {
|
38 |
+
display: table-cell; /* The magic ingredient! */
|
39 |
+
vertical-align: middle;
|
40 |
+
cursor: default;
|
41 |
+
line-height: 1.5;
|
42 |
+
}
|
43 |
+
|
44 |
+
.smush-notice.notice.loading > div {
|
45 |
+
-webkit-filter: blur(2px);
|
46 |
+
-moz-filter: blur(2px);
|
47 |
+
-o-filter: blur(2px);
|
48 |
+
-ms-filter: blur(2px);
|
49 |
+
filter: blur(2px);
|
50 |
+
}
|
51 |
+
|
52 |
+
.smush-notice-logo {
|
53 |
+
background-color: #0B2F3F;
|
54 |
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAABNGlDQ1BJQ0MgUHJvZmlsZQAAKJFjYGBSSSwoyGESYGDIzSspCnJ3UoiIjFJgv8/AwcDNIMYgyKCWmFxc4BgQ4MOAE3y7xsAIoi/rgszCrQ4r4EpJLU4G0n+AOC65oKiEgYExBshWLi8pALEbgGyRpGwwewqIXQR0IJC9AsROh7D3gNVA2BfAakKCnIHsJ0C2QxISOx2JDbUXBJiTjUh0NRGgJLWiBEQ75xdUFmWmZ5QoOAJDJ1XBMy9ZT0fByMDQlIEBFNYQ1YgwRIgxiwGxMQMD0xKEWP4iBgaLr0DxCQixpJkMDNtbGRgkbiHEVBYwMPC3MDBsO59cWlQGdZIUEJ9mPMmczDqJI5v7m4C9aKC0ieJHzQlGEtaT3FgDy2PfZhdUsXZunFWzJnN/7eXDLw3+/wcAZQZcDK/8PeoAAAAJcEhZcwAACxMAAAsTAQCanBgAAAQkaVRYdFhNTDpjb20uYWRvYmUueG1wAAAAAAA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJYTVAgQ29yZSA1LjQuMCI+CiAgIDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CiAgICAgIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICAgICAgICAgIHhtbG5zOnRpZmY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vdGlmZi8xLjAvIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyIKICAgICAgICAgICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICAgICAgICAgICB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iPgogICAgICAgICA8dGlmZjpSZXNvbHV0aW9uVW5pdD4yPC90aWZmOlJlc29sdXRpb25Vbml0PgogICAgICAgICA8dGlmZjpDb21wcmVzc2lvbj41PC90aWZmOkNvbXByZXNzaW9uPgogICAgICAgICA8dGlmZjpYUmVzb2x1dGlvbj43MjwvdGlmZjpYUmVzb2x1dGlvbj4KICAgICAgICAgPHRpZmY6T3JpZW50YXRpb24+MTwvdGlmZjpPcmllbnRhdGlvbj4KICAgICAgICAgPHRpZmY6WVJlc29sdXRpb24+NzI8L3RpZmY6WVJlc29sdXRpb24+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj44MDwvZXhpZjpQaXhlbFhEaW1lbnNpb24+CiAgICAgICAgIDxleGlmOkNvbG9yU3BhY2U+MTwvZXhpZjpDb2xvclNwYWNlPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+ODA8L2V4aWY6UGl4ZWxZRGltZW5zaW9uPgogICAgICAgICA8ZGM6c3ViamVjdD4KICAgICAgICAgICAgPHJkZjpCYWcvPgogICAgICAgICA8L2RjOnN1YmplY3Q+CiAgICAgICAgIDx4bXA6TW9kaWZ5RGF0ZT4yMDE1LTA4LTExVDIyOjA4OjU5PC94bXA6TW9kaWZ5RGF0ZT4KICAgICAgICAgPHhtcDpDcmVhdG9yVG9vbD5QaXhlbG1hdG9yIDMuMy4yPC94bXA6Q3JlYXRvclRvb2w+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgrYxXXjAAAONElEQVR4Ae1be3AV1Rn/zu595HETCIEkYEIIbwg+OlF5WYva6iAjApXIoJ2Kdvrw0fpC/yhaxlYtgjg+pjM6Yzv1wdjQ1lYqjsVKxAe+BRUV5A0JJIQk5J3cu3v6+/ZmL/fe7N7cu7kBnNnDhN09e77vfOe333e+73znXCK3OEJgzpw5HkeELpGLgIuAi4CLgIuAi4CLgIuAi4CLgIuAi4CLwHccAXGmyT/x6Y+Hh/JGZeleoRBl9IrXRUpQ6p6m2o5dvzi/4UyS+bQDOPalPRN14a0Q5KnQFTlJ6PoUCJUtSQohw1BJQ0rjqV0qytcKiZ1Sl58oUn6yd0nxrtMJ6GkBsGzd3kKp+K8kj3o1acGLhFDyhQfZIV3Dn05SSmLBevEz7g2QBGoVKKaikgwFud1xUr3vkNT+LYKejfuWFtadajBPKYBjquqLpNCuF1LeqAiaQgBEaqEwcCmPPAymUAE8ANclfS2F+meRJV7YP6/gaMrsHBKcEgDHb5T+YHvdT4TU74QCTeHRSi3oUGRrMqF6iT+ILuXXQqhr1ezC53dfKbqtW6evdtABHPti/QTdH3oEc9sCwRoH0xvMwkDi8+CfeCVE6orDlUVfDGZ/6mAyL/nHsfkkgs+pQp2Fuc6hqaYoodRBIDFNeibhcy0YsmR58x1TA9urq6vNKTVFhombD4oGVjz9tLdp6Ly7IfH9QhEZg611dkPk+ZGnR10oDweo6YEdleU9dm2d1qcdwPKVVb72KbMfQAxyL0tveFan0qWDjr02KZgbxeqA0rwi3SAy97SW9imz7kIIfA+xKXFYcroLwiIIQorQl7cpefdTVVVap620Ajj6X8eugqT3sdFwPHfGFJYF1qBIurdUvXhZOuVKmwmP/fuhCZomXlMVMe50zXn9ASMUD3RRNpLHO2//j4ve7699Mu/TooHFaw9l6qQ+ono8Zyx4DIbUQ/DO6jBMLY+OrWockgxA/bVJC4BqqXcpVhdXy+Cgx639jaff9zIYxCyjzNKVrl/12ziJBgM24TF/2VdE2d5qRYhJyZguB2PsnHlZm2rnWMA4oovHQahYS0ulTvUrl+5eMPKr+PepPA9YA2VWxvWKogI8rGkTFA2DbwvqvIojnyqIn9tDxho2ARX8Z2+7IG6YjsFvC+kE0oQfgOm60MjqI0lNIyQvCoM9+p0JO0/ipRX/JMjCTcY9t7tAy8jYgsSALYDcQRfQGupT6cbJOXR5cRbl+xU60qHRhgMd9MLuFmOgDE58CQEFOCVaOj6H5pdmUUm2hxq7dfpfTSc9u7OFGro0ymRQowjN/vweQT+fPIRe2tNKTaDpw54zOkSNIdU/4/A1Bd9GsUjpdkAnjDRf5jysbydJzT7A7wZ4o3O89Oz3R9DUPF9EuFFZHqoY7qe5o7PoxrfqqaVHIy/AMguDl+lVQFdAFxWZiVWiUVlE08BnbkkW3bSlnva2BCmjF0SmZq0ele2lJ2fl09nDfPT8ty0my9grYlTF6x/m0bRFeLEq9mXyT85NeDECUoUWcoIgRgWi+mYz8gCUx2cOjwEvqglNH+GnR6fnGyYZrUmwUnrogvwY8KLpJg7x0lOzR0ADFWM64Hf8saYX+OnlHxXS7MIMQ/Ojafrcc3wo9MrxT7yf2+ddkhWOARy3eE4Z4oJZRj7PprNODOiq0gBdCJCiS1OPTifwZxY264uhZWzqXPh6fkEGLSzNNpsY19agpOYounOhYYvKsqkDaJumOx80pYHkDIvDGqFrZ/cUjT4npqMUHhwDqMngBZxJTrTiYOW8ovik+YXgAR78rJku+U8t3QCz/d3HjVSLuZAtd25JNrHZMhDsMC4blWnU81gY1sd3nKAfbDhM12+uozu2NtCuE+G02BUwZdZyA3oQ97Da9xbmlXCAkEd4/V5FarNMmlSvCfknYgaRK4w0vI398jAywH1cLhKdveXdo1306BdNdLQjRPkZKpXh3bLN9bQb81gZ5kkPEGc6nvCLAyeXrHtag7Tm8yaADY1Bmxkwz1vePkZb67po8lAvZcFhnITN7C18NaaY2Kq4J1AqnslxlUk/OgNw5UpFCs/ERNrHErDw2ACKCMPeEGOlTPz330PtdOlZmbT8vKF0FzSKNUftdZVM58WfWRrhbTloyfQotPVoJxVmeuix2cPpvg+P05F2jXysgXYImkzsrpzwkLK8eO17mXZNEtU7AvCs4XPzSAanJpNtiR4XmyoXviASo0NtIfohQKzI9yPcaIsJSaLpVONDGKQG8RFoInviJRNy6EmYdgZ/FafFSDSESqi4ZJgTFo4A9BdgwpIy4Pyzh0E0h/2zqbn02fHuyByYaCBMY36I6wBgXadmxIZRCpuIvM87/lACYTWR/9RpoK4hz4yOo7Wkj2QpVHBMOANel72pVTGBjn/HQfQlcDa8wrHSBDu6WD7YP5GUpas+R6GMVb+x/K2eMk56VqvXTupmwTFEOdAYFuy97T4Wh0h+ngNjKMIPHNzY8Yw0hwlDe7N93S2jI3Up3DgDMIUOkm1amKkaXtiqfW2HTkHEhlYaVRLwYg5ULAFs6tawMuFstBXX9NQ5BLBrwL3zmKIHZjhgm4F+1tCFlUpYxwy6qN7Zf1jDR/RJQze125h3hAX2TMC6XfpzD0bqUrhxBCAf9OHh2Iw36e6j6a1MkBnxauYtxI9ZWLJZFaazouW61w93Ghkc65nV5AYXQrJT03psFs1mO+urtVTWbSO13fUI4oRo48ljMAoP3hz0i9+20kiYd8Bnp2exEph+aMuRTmpDgqIYGZxE8yCPAP1pPgrZZ0Riu4h5cgRgTcNrTaR6vuJDPukqhhYZ/3FcS1SAlcpuLNfWIz5cNjHXSBRY9cUkvdZNGlDnFQ575Ye3NdNNk3MTgmfwYyWAMvhYKRwURwDSypU4giJ3GSelHHTKJOxXe3MHBodsOALkCgCUjowKEgtIS93yzjG6ryKPirJU6ul1IgZgUX1m8yQIELj9JCzr2BndUF1PS8YGjExOR3QnUXSRW1YCRf3ym1umN0bqUrhxBiA6EDifF85COzNjThgcaj+Zxa7I99F1SJx6MKmzx10HzXsIaa6LijKNtXIPrxh6CydjzcKA/aZ8iJE7zEb+cB1M/mY83zAph2qxzGtlJ5JIRN54D2nbeCI0eaZyTS7vY8FRzfB+pHV1HxcKZ2RODsiiaaQqPuv89pEuuhaawoXfPT4zn24tzzWcEychzHFX13ZGRsdJ182Y324DSCYwv542hBYircVpsHBSItzlppoO6gCAOQDWskBzsREW1HwZb1q+T6LShnP/lHu6q/cJVXnPOJ/Xf3OkqIg2wSvyupYLJ0I3Hm6nT7GEiy4TANz4KPC2N3bTqwfbjfbczg+gP6zvojdqO6LJjHQ/05rLYk79Pwdt5Gy1XREwX+jnTrWl5nO7Nv3VOwaQKis1HLp9WfIRDnsZjczLYZjq0s1HjfQ6Z2K4sPZ0Y966HZmYvUhXWRWmu/29BkOzTG1jasZk+QeNtC0OfJNHC77Wbe820KHWkJGpMev7XHEUDgC8vn/Z95r7vEuyYkBudNhV99TqqjYfm9XDrVJbnGYag+zw3RjsdgS18abE5liPZMDGgx3YD1GoEGtiLpx1fgV1d77P4IaMLE30eDhv2II2G9CG59JCOBnWbN6tewMbTtzfVmhptjf8saJpI/dGAK13gOye5vWP1UTqU7xJ0ENynErX19yNzZHV0gijYudhZs6my7UI4yLzWDxnBoEz9XnYrRuChq09EhkW3mSimI2maDrmDQVGoK1TrlelYaDjoPsY6Fgr2NQTFeHD2lvXqsbs2HVd9cpLTnqzREQW7xL3YkEQXzWmChvrEhvrivXGOoOXbCcc8GoI6rBJb5hpfF92z0yHuArRTJJ07HmF0oZvdvmByuKtdnyTqQengZX9lWVH8dODNZCfR9CHWd+aPk0iFTzPsVn3ozyR9uYN0/G+SLJ0woPtVUV5ZqDgcf8DBpCZaFJ7EUqwwRCMK87gIjxe0kOhbaqe88d0iJmKgiTsb9w/G6dpoc5NWLEWJdrqTMhksF/yaQRF6UACetH+awpfT0d3adFAFmTPomFfSo/6WykUbJ2ljW06xhjmYcx7CLyk+H26wGPGaR3phaEtf8WEvsoAkAU+U4ohCw40CbE6m5rWplOstJmwKVR51Q5fGw39gyL15UbgErWGNduc0msEPGV1TvmoFTvKhaO0lZ3MaVcTPgUfoOYV2Gl4CAquJ7vUsxNwIPW8VOMgSlM8q3Io/eCxbANaidgN7tj6P2knxIy38s4uq0GybiZOMGRZrVTs6NNRzxEBfu/Zgajy/uFNIx/c/lNhvV4cYGdpN+F4eUqr6mYKEVrDx2oJPyyUSWZu4vkk/QyTNUIVSZ9Kqa44sLjgtaRpHTQcdABZpjEvNw0lrfuXQtNuFx610DgKnG4g4fmFF1oX0tpwKvMZRQms2rMop94BJimRnBIATYlGrztQDnO+A1m4BZif8vHrzfDPXc2cvNkw2StWPsY8x8FxMNiONeCrqh56Ys+1pe8my2Kg7U4pgKawZVU1k7DuWwgvvRggTsMRM5+RlA0f9AknHQxQeSXNBWIyWMYt/mfPykFxqAdpB7ETNZvA62/7Kks+QhOTiFsPejFkGvRebDrgk6HdI0efq4aCl+HHL+cht1iOn0sE8OcBMJlIDuCEJWJf7Nvy1iOcQgh/bTiXuINCwW2az/umqGv44uDN5zTZdDHo1acVwPjRTX7qg/zuvBGBYCDgVRVfrmgNH7eQObkHNV20eNuOB/1Nx9q+uXX68Xha99lFwEXARcBFwEXARcBFwEXARcBFwEXARcBFwEXAReA7gcD/ATWUF/aWa8NWAAAAAElFTkSuQmCC);
|
55 |
+
background-repeat: no-repeat;
|
56 |
+
background-position: 50% 50%;
|
57 |
+
}
|
58 |
+
|
59 |
+
.smush-notice-logo span {
|
60 |
+
display: block;
|
61 |
+
width: 80px;
|
62 |
+
}
|
63 |
+
|
64 |
+
.smush-notice-message {
|
65 |
+
width: 100%;
|
66 |
+
padding: 10px 20px;
|
67 |
+
color: #444;
|
68 |
+
}
|
69 |
+
|
70 |
+
.smush-notice-message strong {
|
71 |
+
color: #000;
|
72 |
+
}
|
73 |
+
|
74 |
+
.smush-notice-cta {
|
75 |
+
border-left: 1px solid #E5E5E5;
|
76 |
+
background: #F8F8F8;
|
77 |
+
padding: 0 30px;
|
78 |
+
position: relative;
|
79 |
+
white-space: nowrap;
|
80 |
+
}
|
81 |
+
|
82 |
+
.wp-core-ui .smush-notice-cta button,
|
83 |
+
.wp-core-ui .smush-notice-cta .button-primary:active {
|
84 |
+
vertical-align: middle;
|
85 |
+
}
|
86 |
+
|
87 |
+
.wp-core-ui .smush-notice-cta input[type="email"] {
|
88 |
+
vertical-align: middle;
|
89 |
+
line-height: 20px;
|
90 |
+
margin: 0;
|
91 |
+
min-width: 50px;
|
92 |
+
max-width: 320px;
|
93 |
+
text-align: center;
|
94 |
+
padding-left: 0;
|
95 |
+
padding-right: 0;
|
96 |
+
}
|
97 |
+
|
98 |
+
.smush-notice-dismiss {
|
99 |
+
background: transparent;
|
100 |
+
border: 0;
|
101 |
+
cursor: pointer;
|
102 |
+
color: #BBB;
|
103 |
+
}
|
104 |
+
|
105 |
+
.smush-notice-dismiss:hover {
|
106 |
+
color: #666;
|
107 |
+
}
|
108 |
+
|
109 |
+
@media only all and (max-width: 1200px) {
|
110 |
+
.smush-notice-dismiss {
|
111 |
+
display: block;
|
112 |
+
margin: 0 auto;
|
113 |
+
line-height: 18px;
|
114 |
+
padding-top: 8px;
|
115 |
+
padding-bottom: 2px;
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
@media only all and (max-width: 1000px) {
|
120 |
+
.wrap .smush-notice.notice {
|
121 |
+
display: block;
|
122 |
+
font-size: 13px;
|
123 |
+
}
|
124 |
+
|
125 |
+
.smush-notice > .smush-notice-logo {
|
126 |
+
float: left;
|
127 |
+
display: inline-block;
|
128 |
+
height: 80px;
|
129 |
+
margin: 10px;
|
130 |
+
border-radius: 4px;
|
131 |
+
}
|
132 |
+
|
133 |
+
.smush-notice > .smush-notice-message {
|
134 |
+
width: auto;
|
135 |
+
display: block;
|
136 |
+
padding: 10px;
|
137 |
+
min-height: 80px;
|
138 |
+
}
|
139 |
+
|
140 |
+
.smush-notice > .smush-notice-cta {
|
141 |
+
display: block;
|
142 |
+
border-top: 1px solid #E5E5E5;
|
143 |
+
border-left: 0;
|
144 |
+
text-align: center;
|
145 |
+
white-space: normal;
|
146 |
+
line-height: 30px;
|
147 |
+
padding: 10px 20px;
|
148 |
+
}
|
149 |
+
|
150 |
+
.wp-core-ui .smush-notice > .smush-notice-cta > input[type="email"],
|
151 |
+
.smush-notice > .smush-notice-cta > button {
|
152 |
+
font-size: 14px;
|
153 |
+
}
|
154 |
+
|
155 |
+
.smush-notice > .smush-notice-cta > .smush-notice-dismiss {
|
156 |
+
display: inline-block;
|
157 |
+
float: none;
|
158 |
+
line-height: 26px;
|
159 |
+
padding-top: 0;
|
160 |
+
padding-bottom: 0;
|
161 |
+
font-size: 13px;
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
@media only all and (max-width: 500px) {
|
166 |
+
.wp-core-ui .smush-notice > .smush-notice-cta > input[type="email"],
|
167 |
+
.smush-notice > .smush-notice-cta > button {
|
168 |
+
display: block;
|
169 |
+
width: 100% !important;
|
170 |
+
max-width: none;
|
171 |
+
margin-bottom: 4px;
|
172 |
+
font-size: 16px;
|
173 |
+
height: 34px;
|
174 |
+
}
|
175 |
+
|
176 |
+
.smush-notice > .smush-notice-cta > .smush-notice-dismiss {
|
177 |
+
margin-top: 5px;
|
178 |
+
font-size: 14px;
|
179 |
+
height: 23px;
|
180 |
+
}
|
181 |
+
}
|
assets/css/wp-smushit-admin.css
CHANGED
@@ -86,8 +86,12 @@ Smush button transformation
|
|
86 |
margin: 15px 20px 15px 0;
|
87 |
}
|
88 |
|
89 |
-
.
|
90 |
-
|
|
|
|
|
|
|
|
|
91 |
}
|
92 |
|
93 |
.wpmud .wp-smushit-container-wrap {
|
@@ -254,7 +258,6 @@ input#wp-smush-save-settings {
|
|
254 |
.compat-field-wp_smush .smush-wrap {
|
255 |
margin: 0 0 5px 0;
|
256 |
max-width: 100%;
|
257 |
-
overflow: hidden;
|
258 |
}
|
259 |
|
260 |
.inactive {
|
@@ -885,6 +888,14 @@ small.smush-setting-description {
|
|
885 |
padding-top: 7px;
|
886 |
}
|
887 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
888 |
/** For Smush Pro Promo and Humming Bird promo **/
|
889 |
.wpmud .wp-smushit-container-right .wp-smush-pro-adv {
|
890 |
overflow: hidden;
|
@@ -1024,6 +1035,7 @@ small.smush-setting-description {
|
|
1024 |
box-sizing: border-box;
|
1025 |
display: inline-block !important;
|
1026 |
float: none;
|
|
|
1027 |
width: 50% !important;
|
1028 |
}
|
1029 |
|
@@ -1060,12 +1072,16 @@ small.smush-setting-description {
|
|
1060 |
text-transform: none !important;
|
1061 |
}
|
1062 |
|
1063 |
-
.
|
|
|
|
|
|
|
|
|
1064 |
position: relative;
|
1065 |
overflow: visible;
|
1066 |
}
|
1067 |
|
1068 |
-
.smushit [tooltip]:before {
|
1069 |
content: '';
|
1070 |
position: absolute;
|
1071 |
border: 5px solid transparent;
|
@@ -1080,20 +1096,20 @@ small.smush-setting-description {
|
|
1080 |
pointer-events: none;
|
1081 |
}
|
1082 |
|
1083 |
-
.smushit [tooltip]:after {
|
1084 |
content: attr(tooltip);
|
1085 |
position: absolute;
|
1086 |
background: #0B2F3F;
|
1087 |
color: #FFF;
|
1088 |
bottom: 100%;
|
1089 |
left: 50%;
|
1090 |
-
width:
|
1091 |
margin-left: -100px;
|
1092 |
margin-bottom: 5px;
|
1093 |
text-align: center;
|
1094 |
padding: 5px;
|
1095 |
border-radius: 4px;
|
1096 |
-
font:
|
1097 |
opacity: 0;
|
1098 |
z-index: -1;
|
1099 |
transition: margin .2s, opacity .2s, z-index .2s linear .2s;
|
@@ -1101,29 +1117,44 @@ small.smush-setting-description {
|
|
1101 |
pointer-events: none;
|
1102 |
}
|
1103 |
|
1104 |
-
.smushit [tooltip].tooltip
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1105 |
width: 150px;
|
1106 |
margin-left: -75px;
|
1107 |
}
|
1108 |
|
1109 |
-
.smushit [tooltip].tooltip-l:after {
|
1110 |
width: 280px;
|
1111 |
margin-left: -140px;
|
1112 |
}
|
1113 |
|
1114 |
-
.smushit [tooltip].tooltip-right:after {
|
1115 |
margin-left: -180px;
|
1116 |
}
|
1117 |
|
1118 |
-
.smushit [tooltip].tooltip-s.tooltip-right:after {
|
1119 |
margin-left: -130px;
|
1120 |
}
|
1121 |
|
1122 |
-
.smushit [tooltip].tooltip-l.tooltip-right:after {
|
1123 |
margin-left: -260px;
|
1124 |
}
|
1125 |
|
1126 |
-
.smushit [tooltip].tooltip-bottom:before {
|
1127 |
border-color: transparent;
|
1128 |
border-bottom-color: #0B2F3F;
|
1129 |
top: 100%;
|
@@ -1132,21 +1163,21 @@ small.smush-setting-description {
|
|
1132 |
margin-bottom: 0;
|
1133 |
}
|
1134 |
|
1135 |
-
.smushit [tooltip].tooltip-bottom:after {
|
1136 |
bottom: auto;
|
1137 |
top: 100%;
|
1138 |
margin-top: 5px;
|
1139 |
margin-bottom: 0;
|
1140 |
}
|
1141 |
|
1142 |
-
.smushit [tooltip]:hover:before {
|
1143 |
-
opacity: 1;
|
1144 |
z-index: 1;
|
1145 |
margin-bottom: 0;
|
|
|
1146 |
transition: margin .2s, opacity .2s;
|
1147 |
}
|
1148 |
|
1149 |
-
.smushit [tooltip]:hover:after {
|
1150 |
opacity: 1;
|
1151 |
z-index: 1;
|
1152 |
margin-bottom: 10px;
|
@@ -1154,7 +1185,9 @@ small.smush-setting-description {
|
|
1154 |
}
|
1155 |
|
1156 |
.smushit .disabled[tooltip]:before,
|
1157 |
-
.smushit .disabled[tooltip]:after
|
|
|
|
|
1158 |
display: none;
|
1159 |
}
|
1160 |
|
@@ -1202,7 +1235,53 @@ small.smush-setting-description {
|
|
1202 |
color: black;
|
1203 |
text-decoration: underline;
|
1204 |
}
|
|
|
1205 |
.wpmud .wp-smush-setting-row .toggle .toggle-checkbox {
|
1206 |
display: inline-block;
|
1207 |
opacity: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1208 |
}
|
86 |
margin: 15px 20px 15px 0;
|
87 |
}
|
88 |
|
89 |
+
.wpmud .toggle .toggle-checkbox:focus+.toggle-label:before {
|
90 |
+
background: #c1c1c1;
|
91 |
+
}
|
92 |
+
|
93 |
+
.wpmud .wp-smush-setting-row .toggle-checkbox:checked:focus + .toggle-label {
|
94 |
+
box-shadow: 0 1px 1px rgba(26, 188, 156, 0.75);
|
95 |
}
|
96 |
|
97 |
.wpmud .wp-smushit-container-wrap {
|
258 |
.compat-field-wp_smush .smush-wrap {
|
259 |
margin: 0 0 5px 0;
|
260 |
max-width: 100%;
|
|
|
261 |
}
|
262 |
|
263 |
.inactive {
|
888 |
padding-top: 7px;
|
889 |
}
|
890 |
|
891 |
+
.wp-smush-stats-label .wdv-icon.wdv-icon-question-sign {
|
892 |
+
margin-left: 3px;
|
893 |
+
}
|
894 |
+
|
895 |
+
.wp-smush-total-thumbnails .dashicons-editor-help {
|
896 |
+
margin-top: -2px;
|
897 |
+
}
|
898 |
+
|
899 |
/** For Smush Pro Promo and Humming Bird promo **/
|
900 |
.wpmud .wp-smushit-container-right .wp-smush-pro-adv {
|
901 |
overflow: hidden;
|
1035 |
box-sizing: border-box;
|
1036 |
display: inline-block !important;
|
1037 |
float: none;
|
1038 |
+
overflow: visible;
|
1039 |
width: 50% !important;
|
1040 |
}
|
1041 |
|
1072 |
text-transform: none !important;
|
1073 |
}
|
1074 |
|
1075 |
+
.compat-item .compat-field-wp_smush {
|
1076 |
+
overflow: visible;
|
1077 |
+
}
|
1078 |
+
|
1079 |
+
.smushit [tooltip], .compat-field-wp_smush [tooltip] {
|
1080 |
position: relative;
|
1081 |
overflow: visible;
|
1082 |
}
|
1083 |
|
1084 |
+
.smushit [tooltip]:before, .compat-field-wp_smush [tooltip]:before {
|
1085 |
content: '';
|
1086 |
position: absolute;
|
1087 |
border: 5px solid transparent;
|
1096 |
pointer-events: none;
|
1097 |
}
|
1098 |
|
1099 |
+
.smushit [tooltip]:after, .compat-field-wp_smush [tooltip]:after {
|
1100 |
content: attr(tooltip);
|
1101 |
position: absolute;
|
1102 |
background: #0B2F3F;
|
1103 |
color: #FFF;
|
1104 |
bottom: 100%;
|
1105 |
left: 50%;
|
1106 |
+
width: 180px;
|
1107 |
margin-left: -100px;
|
1108 |
margin-bottom: 5px;
|
1109 |
text-align: center;
|
1110 |
padding: 5px;
|
1111 |
border-radius: 4px;
|
1112 |
+
font: 400 13px/20px 'Roboto Condensed';
|
1113 |
opacity: 0;
|
1114 |
z-index: -1;
|
1115 |
transition: margin .2s, opacity .2s, z-index .2s linear .2s;
|
1117 |
pointer-events: none;
|
1118 |
}
|
1119 |
|
1120 |
+
.smushit .smush-skipped [tooltip]:before, .compat-field-wp_smush .smush-skipped [tooltip]:before {
|
1121 |
+
border-top-color: transparent;
|
1122 |
+
border-left-color: #0B2F3F;
|
1123 |
+
bottom: 0;
|
1124 |
+
left: 0;
|
1125 |
+
}
|
1126 |
+
|
1127 |
+
.smushit .smush-skipped [tooltip]:after, .compat-field-wp_smush .smush-skipped [tooltip]:after {
|
1128 |
+
margin-left: 0;
|
1129 |
+
left: -195px;
|
1130 |
+
top: -35px;
|
1131 |
+
bottom: inherit;
|
1132 |
+
margin-bottom: 5px;
|
1133 |
+
}
|
1134 |
+
|
1135 |
+
.smushit [tooltip].tooltip-s:after, .compat-field-wp_smush [tooltip].tooltip-s:after {
|
1136 |
width: 150px;
|
1137 |
margin-left: -75px;
|
1138 |
}
|
1139 |
|
1140 |
+
.smushit [tooltip].tooltip-l:after, .compat-field-wp_smush [tooltip].tooltip-l:after {
|
1141 |
width: 280px;
|
1142 |
margin-left: -140px;
|
1143 |
}
|
1144 |
|
1145 |
+
.smushit [tooltip].tooltip-right:after, .compat-field-wp_smush [tooltip].tooltip-right:after {
|
1146 |
margin-left: -180px;
|
1147 |
}
|
1148 |
|
1149 |
+
.smushit [tooltip].tooltip-s.tooltip-right:after, .compat-field-wp_smush [tooltip].tooltip-s.tooltip-right:after {
|
1150 |
margin-left: -130px;
|
1151 |
}
|
1152 |
|
1153 |
+
.smushit [tooltip].tooltip-l.tooltip-right:after, .compat-field-wp_smush [tooltip].tooltip-l.tooltip-right:after {
|
1154 |
margin-left: -260px;
|
1155 |
}
|
1156 |
|
1157 |
+
.smushit [tooltip].tooltip-bottom:before, .compat-field-wp_smush [tooltip].tooltip-bottom:before {
|
1158 |
border-color: transparent;
|
1159 |
border-bottom-color: #0B2F3F;
|
1160 |
top: 100%;
|
1163 |
margin-bottom: 0;
|
1164 |
}
|
1165 |
|
1166 |
+
.smushit [tooltip].tooltip-bottom:after, .compat-field-wp_smush [tooltip].tooltip-bottom:after {
|
1167 |
bottom: auto;
|
1168 |
top: 100%;
|
1169 |
margin-top: 5px;
|
1170 |
margin-bottom: 0;
|
1171 |
}
|
1172 |
|
1173 |
+
.smushit [tooltip]:hover:before, .compat-field-wp_smush [tooltip]:hover:before {
|
|
|
1174 |
z-index: 1;
|
1175 |
margin-bottom: 0;
|
1176 |
+
opacity: 1;
|
1177 |
transition: margin .2s, opacity .2s;
|
1178 |
}
|
1179 |
|
1180 |
+
.smushit [tooltip]:hover:after, .compat-field-wp_smush [tooltip]:hover:after {
|
1181 |
opacity: 1;
|
1182 |
z-index: 1;
|
1183 |
margin-bottom: 10px;
|
1185 |
}
|
1186 |
|
1187 |
.smushit .disabled[tooltip]:before,
|
1188 |
+
.smushit .disabled[tooltip]:after,
|
1189 |
+
.compat-field-wp_smush .disabled[tooltip]:before,
|
1190 |
+
.compat-field-wp_smush .disabled[tooltip]:after {
|
1191 |
display: none;
|
1192 |
}
|
1193 |
|
1235 |
color: black;
|
1236 |
text-decoration: underline;
|
1237 |
}
|
1238 |
+
|
1239 |
.wpmud .wp-smush-setting-row .toggle .toggle-checkbox {
|
1240 |
display: inline-block;
|
1241 |
opacity: 0;
|
1242 |
+
}
|
1243 |
+
|
1244 |
+
.wp-smush-resize-settings-wrap {
|
1245 |
+
background: rgba(0, 0, 0, 0.05);
|
1246 |
+
border-radius: 5px;
|
1247 |
+
color: #555;
|
1248 |
+
font-family: "Roboto", sans-serif;
|
1249 |
+
margin: 1.5em 0;
|
1250 |
+
overflow: auto;
|
1251 |
+
padding: 30px;
|
1252 |
+
vertical-align: middle;
|
1253 |
+
}
|
1254 |
+
|
1255 |
+
.wpmud .wp-smush-resize-settings-wrap label {
|
1256 |
+
display: inline-block;
|
1257 |
+
margin-bottom: 0;
|
1258 |
+
overflow: hidden;
|
1259 |
+
}
|
1260 |
+
|
1261 |
+
.wpmud .wp-smush-resize-settings-wrap label:first-child {
|
1262 |
+
padding-left: 0;
|
1263 |
+
}
|
1264 |
+
|
1265 |
+
.wpmud .wp-smush-resize-settings-wrap .wp-smush-resize-input {
|
1266 |
+
display: inline-block;
|
1267 |
+
margin-left: 10px;
|
1268 |
+
width: 120px;
|
1269 |
+
}
|
1270 |
+
|
1271 |
+
.wpmud .wp-smush-resize-input.error {
|
1272 |
+
border-color: #fd8b8b;
|
1273 |
+
}
|
1274 |
+
|
1275 |
+
.wp-smush-size-info {
|
1276 |
+
background: #e0f6fa;
|
1277 |
+
border-radius: 5px;
|
1278 |
+
font-size: 13px;
|
1279 |
+
line-height: 1.5;
|
1280 |
+
margin-top: 20px;
|
1281 |
+
padding: 20px 30px;
|
1282 |
+
}
|
1283 |
+
|
1284 |
+
.smush-final-log.notice.notice-warning {
|
1285 |
+
max-height: 200px;
|
1286 |
+
overflow: auto;
|
1287 |
}
|
assets/js/notice.js
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Created by umeshkumar on 12/05/16.
|
3 |
+
*/
|
4 |
+
jQuery(function () {
|
5 |
+
var el_notice = jQuery(".smush-notice"),
|
6 |
+
btn_act = el_notice.find(".smush-notice-act"),
|
7 |
+
btn_dismiss = el_notice.find(".smush-notice-dismiss");
|
8 |
+
el_notice.fadeIn(500);
|
9 |
+
|
10 |
+
// Hide the notice after a CTA button was clicked
|
11 |
+
function remove_notice() {
|
12 |
+
el_notice.fadeTo(100, 0, function () {
|
13 |
+
el_notice.slideUp(100, function () {
|
14 |
+
el_notice.remove();
|
15 |
+
});
|
16 |
+
});
|
17 |
+
}
|
18 |
+
|
19 |
+
btn_act.click(function (ev) {
|
20 |
+
remove_notice();
|
21 |
+
notify_wordpress(btn_act.data("msg"));
|
22 |
+
});
|
23 |
+
btn_dismiss.click(function (ev) {
|
24 |
+
remove_notice();
|
25 |
+
notify_wordpress(btn_act.data("msg"));
|
26 |
+
});
|
27 |
+
|
28 |
+
// Notify WordPress about the users choice and close the message.
|
29 |
+
function notify_wordpress(message) {
|
30 |
+
el_notice.attr("data-message", message);
|
31 |
+
el_notice.addClass("loading");
|
32 |
+
|
33 |
+
//Send a ajax request to save the dismissed notice option
|
34 |
+
var param = {
|
35 |
+
action: 'dismiss_upgrade_notice'
|
36 |
+
};
|
37 |
+
jQuery.post(ajaxurl, param);
|
38 |
+
}
|
39 |
+
|
40 |
+
//Store the preference in db
|
41 |
+
jQuery('.wp-smush-update-info').on('click', '.notice-dismiss', function (e) {
|
42 |
+
e.preventDefault();
|
43 |
+
var $el = jQuery(this);
|
44 |
+
$el.fadeTo( 100, 0, function() {
|
45 |
+
$el.slideUp( 100, function() {
|
46 |
+
$el.remove();
|
47 |
+
});
|
48 |
+
});
|
49 |
+
var param = {
|
50 |
+
action: 'dismiss_update_info'
|
51 |
+
};
|
52 |
+
jQuery.post(ajaxurl, param);
|
53 |
+
});
|
54 |
+
|
55 |
+
});
|
assets/js/wp-smushit-admin.js
CHANGED
@@ -14,16 +14,16 @@ var WP_Smush = WP_Smush || {};
|
|
14 |
* @param txt Message to be displayed
|
15 |
* @param state show/hide
|
16 |
*/
|
17 |
-
var progress_bar = function(
|
18 |
|
19 |
//Update Progress bar text and show it
|
20 |
var progress_button = cur_ele.parents().eq(1).find('.wp-smush-progress');
|
21 |
|
22 |
-
if(
|
23 |
progress_button.find('span').html(txt);
|
24 |
progress_button.removeClass('hidden');
|
25 |
-
}else{
|
26 |
-
progress_button.find('span').html(
|
27 |
progress_button.hide();
|
28 |
}
|
29 |
};
|
@@ -70,7 +70,7 @@ jQuery(function ($) {
|
|
70 |
this.deferred.errors = [];
|
71 |
|
72 |
//If button has resmush class, and we do have ids that needs to resmushed, put them in the list
|
73 |
-
this.ids = wp_smushit_data.resmush.length > 0 && !skip_resmush ? wp_smushit_data.resmush.concat(
|
74 |
|
75 |
this.is_bulk_resmush = wp_smushit_data.resmush.length > 0 && !skip_resmush ? true : false;
|
76 |
|
@@ -121,16 +121,6 @@ jQuery(function ($) {
|
|
121 |
//Show the Progress Bar
|
122 |
$('.bulk-smush-wrapper .wp-smush-bulk-progress-bar-wrapper').show();
|
123 |
|
124 |
-
//Set Progress Bar width
|
125 |
-
if( 'undefined' !== typeof this.ids && 'undefined' !== typeof wp_smushit_data.count_total && wp_smushit_data.count_total > 0 ) {
|
126 |
-
var progress = ( ( wp_smushit_data.count_total - this.ids.length ) / wp_smushit_data.count_total ) * 100;
|
127 |
-
var progress_bar = jQuery('.bulk-smush-wrapper .wp-smush-progress-inner');
|
128 |
-
if ( progress_bar.length < 1) {
|
129 |
-
return;
|
130 |
-
}
|
131 |
-
// increase progress
|
132 |
-
progress_bar.css('width', progress + '%');
|
133 |
-
}
|
134 |
//Remove any Global Notices if there
|
135 |
$('.wp-smush-notice.wp-smush-resmush-message').remove();
|
136 |
};
|
@@ -171,14 +161,14 @@ jQuery(function ($) {
|
|
171 |
} else {
|
172 |
self.$status.addClass("error");
|
173 |
}
|
174 |
-
self.$status.html(
|
175 |
//Check if stats div exists
|
176 |
var parent = self.$status.parent();
|
177 |
var stats_div = parent.find('.smush-stats-wrapper');
|
178 |
-
if(
|
179 |
-
stats_div.replaceWith(
|
180 |
-
}else{
|
181 |
-
parent.append(
|
182 |
}
|
183 |
}
|
184 |
self.enable_button();
|
@@ -198,8 +188,9 @@ jQuery(function ($) {
|
|
198 |
this.enable_button();
|
199 |
|
200 |
//Show Notice
|
201 |
-
if (
|
202 |
$('.bulk-smush-wrapper .wp-smush-all-done').show();
|
|
|
203 |
} else {
|
204 |
if ($('.bulk-smush-wrapper .wp-smush-resmush-notice').length > 0) {
|
205 |
$('.bulk-smush-wrapper .wp-smush-resmush-notice').show();
|
@@ -225,7 +216,7 @@ jQuery(function ($) {
|
|
225 |
//Hide the Progress bar and show the Bulk smush wrapper
|
226 |
$('.wp-smush-bulk-progress-bar-wrapper').hide();
|
227 |
|
228 |
-
if (
|
229 |
//Show Bulk wrapper
|
230 |
$('.wp-smush-bulk-wrapper ').show();
|
231 |
} else {
|
@@ -234,15 +225,15 @@ jQuery(function ($) {
|
|
234 |
};
|
235 |
|
236 |
this.update_remaining_count = function () {
|
237 |
-
if(
|
238 |
//ReSmush Notice
|
239 |
-
if(
|
240 |
-
$('.wp-smush-resmush-notice .wp-smush-remaining-count').html(
|
241 |
}
|
242 |
-
}else{
|
243 |
//Smush Notice
|
244 |
-
if(
|
245 |
-
$('.bulk-smush-wrapper .wp-smush-remaining-count').html(
|
246 |
}
|
247 |
}
|
248 |
}
|
@@ -268,7 +259,7 @@ jQuery(function ($) {
|
|
268 |
if (wp_smushit_data.resmush.length > 0) {
|
269 |
//Update the Count
|
270 |
$('.wp-smush-images-remaining').html(wp_smushit_data.resmush.length);
|
271 |
-
} else if (wp_smushit_data.resmush.length == 0) {
|
272 |
//If all images are resmushed, show the All Smushed message
|
273 |
|
274 |
//Show All Smushed
|
@@ -287,26 +278,29 @@ jQuery(function ($) {
|
|
287 |
}
|
288 |
|
289 |
//Show Bulk Wrapper and Smush Notice
|
290 |
-
if(
|
291 |
//Hide the bulk wrapper
|
292 |
$('.wp-smush-bulk-wrapper').hide();
|
293 |
//Show All done notice
|
294 |
$('.wp-smush-notice.wp-smush-all-done').show();
|
295 |
}
|
296 |
|
|
|
|
|
|
|
|
|
|
|
297 |
//Update remaining count
|
298 |
self.update_remaining_count();
|
299 |
|
300 |
//if we have received the progress data, update the stats else skip
|
301 |
if ('undefined' != typeof _res.data.stats) {
|
302 |
-
|
303 |
-
var smushed_count = self.is_bulk_resmush ? ( _res.data.stats.total - self.ids.length ) + 1 : _res.data.stats.smushed;
|
304 |
-
smushed_count = smushed_count > _res.data.stats.total ? _res.data.stats.total : smushed_count;
|
305 |
//Update stats
|
306 |
$('.smush-total-reduction-percent .wp-smush-stats').html(_res.data.stats.percent);
|
307 |
$('.smush-total-reduction-bytes .wp-smush-stats').html(_res.data.stats.human);
|
308 |
|
309 |
-
$('.smush-attachments .wp-smush-stats .smushed-count, .wp-smush-images-smushed').html(
|
310 |
if ($('.super-smush-attachments .smushed-count').length && 'undefined' != typeof _res.data.stats.super_smushed) {
|
311 |
$('.super-smush-attachments .smushed-count').html(_res.data.stats.super_smushed);
|
312 |
}
|
@@ -318,7 +312,7 @@ jQuery(function ($) {
|
|
318 |
|
319 |
this._update_progress = function (count, width) {
|
320 |
"use strict";
|
321 |
-
if (
|
322 |
return;
|
323 |
}
|
324 |
//Update the Progress Bar Width
|
@@ -347,7 +341,7 @@ jQuery(function ($) {
|
|
347 |
return continue_smush && this.ids.length > 0 && this.is_bulk;
|
348 |
};
|
349 |
|
350 |
-
this.increment_errors = function (
|
351 |
WP_Smush.errors.push(id);
|
352 |
};
|
353 |
|
@@ -355,6 +349,10 @@ jQuery(function ($) {
|
|
355 |
this.call_ajax = function () {
|
356 |
var nonce_value = '';
|
357 |
this.current_id = this.is_bulk ? this.ids.shift() : this.$button.data("id"); //remove from array while processing so we can continue where left off
|
|
|
|
|
|
|
|
|
358 |
var nonce_field = this.$button.parent().find('#_wp_smush_nonce');
|
359 |
if (nonce_field) {
|
360 |
nonce_value = nonce_field.val();
|
@@ -362,11 +360,11 @@ jQuery(function ($) {
|
|
362 |
|
363 |
this.request = WP_Smush.ajax(this.is_bulk_resmush, this.current_id, this.url, 0, nonce_value)
|
364 |
.error(function () {
|
365 |
-
self.increment_errors(
|
366 |
-
}).done(function (res
|
367 |
//Increase the error count if any
|
368 |
if (typeof res.success === "undefined" || ( typeof res.success !== "undefined" && res.success === false && res.data.error !== 'bulk_request_image_limit_exceeded' )) {
|
369 |
-
self.increment_errors(
|
370 |
}
|
371 |
//If no response or success is false, do not process further
|
372 |
if (typeof res == 'undefined' || !res || !res.success) {
|
@@ -377,7 +375,7 @@ jQuery(function ($) {
|
|
377 |
}
|
378 |
}
|
379 |
|
380 |
-
if (typeof res.data !== "undefined" && res.data.error == 'bulk_request_image_limit_exceeded' && !self.is_resolved()
|
381 |
//Add a data attribute to the smush button, to stop sending ajax
|
382 |
self.$button.attr('continue_smush', false);
|
383 |
|
@@ -390,7 +388,7 @@ jQuery(function ($) {
|
|
390 |
self.update_remaining_count();
|
391 |
} else {
|
392 |
|
393 |
-
if (self.is_bulk && res.success
|
394 |
self.update_progress(res);
|
395 |
}
|
396 |
}
|
@@ -399,7 +397,7 @@ jQuery(function ($) {
|
|
399 |
if (!self.continue() || !self.is_bulk) {
|
400 |
//Calls deferred.done()
|
401 |
self.deferred.resolve();
|
402 |
-
}else{
|
403 |
self.call_ajax();
|
404 |
}
|
405 |
});
|
@@ -452,7 +450,7 @@ jQuery(function ($) {
|
|
452 |
this.cancel_ajax = function () {
|
453 |
$('.wp-smush-cancel-bulk').on('click', function () {
|
454 |
//Add a data attribute to the smush button, to stop sending ajax
|
455 |
-
self.$button.attr('continue_smush', false
|
456 |
|
457 |
self.request.abort();
|
458 |
self.enable_button();
|
@@ -463,6 +461,25 @@ jQuery(function ($) {
|
|
463 |
$('.wp-smush-bulk-progress-bar-wrapper').hide();
|
464 |
});
|
465 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
466 |
|
467 |
this.start();
|
468 |
this.run();
|
@@ -500,7 +517,7 @@ jQuery(function ($) {
|
|
500 |
|
501 |
new WP_Smush.Smush($(this), true);
|
502 |
|
503 |
-
|
504 |
});
|
505 |
|
506 |
/** Disable the action links **/
|
@@ -530,10 +547,10 @@ jQuery(function ($) {
|
|
530 |
* @param smush_action
|
531 |
* @returns {boolean}
|
532 |
*/
|
533 |
-
var process_smush_action = function(
|
534 |
|
535 |
//If disabled
|
536 |
-
if(
|
537 |
return false;
|
538 |
}
|
539 |
|
@@ -553,23 +570,23 @@ jQuery(function ($) {
|
|
553 |
};
|
554 |
|
555 |
//Reduce the opacity of stats and disable the click
|
556 |
-
disable_links(
|
557 |
|
558 |
-
progress_bar(
|
559 |
|
560 |
//Restore the image
|
561 |
$.post(ajaxurl, params, function (r) {
|
562 |
|
563 |
-
progress_bar(
|
564 |
|
565 |
//reset all functionality
|
566 |
-
enable_links(
|
567 |
|
568 |
-
if (r.success && 'undefined' != typeof( r.data.button )
|
569 |
//Show the smush button, and remove stats and restore option
|
570 |
current_button.parents().eq(1).html(r.data.button);
|
571 |
} else {
|
572 |
-
if(r.data.message
|
573 |
//show error
|
574 |
current_button.parent().append(r.data.message);
|
575 |
}
|
@@ -577,13 +594,111 @@ jQuery(function ($) {
|
|
577 |
})
|
578 |
};
|
579 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
580 |
/**
|
581 |
* Handle the Smush Stats link click
|
582 |
*/
|
583 |
$('body').on('click', 'a.smush-stats-details', function (e) {
|
584 |
|
585 |
//If disabled
|
586 |
-
if(
|
587 |
return false;
|
588 |
}
|
589 |
|
@@ -594,7 +709,7 @@ jQuery(function ($) {
|
|
594 |
$(this).parents().eq(1).find('.smush-stats-wrapper').slideToggle();
|
595 |
slide_symbol.text(slide_symbol.text() == '+' ? '-' : '+');
|
596 |
|
597 |
-
|
598 |
});
|
599 |
|
600 |
/** Handle smush button click **/
|
@@ -631,39 +746,39 @@ jQuery(function ($) {
|
|
631 |
jQuery('.wp-smush-button, .wp-smush-scan').attr('disabled', 'disabled');
|
632 |
$(".wp-smush-notice.wp-smush-remaining").hide();
|
633 |
new WP_Smush.Smush($(this), true, 'nextgen');
|
634 |
-
|
635 |
});
|
636 |
|
637 |
/** Restore: Media Library **/
|
638 |
$('body').on('click', '.wp-smush-action.wp-smush-restore', function (e) {
|
639 |
var current_button = $(this);
|
640 |
var smush_action = 'smush_restore_image';
|
641 |
-
process_smush_action(
|
642 |
});
|
643 |
|
644 |
/** Resmush: Media Library **/
|
645 |
$('body').on('click', '.wp-smush-action.wp-smush-resmush', function (e) {
|
646 |
var current_button = $(this);
|
647 |
var smush_action = 'smush_resmush_image';
|
648 |
-
process_smush_action(
|
649 |
});
|
650 |
|
651 |
/** Restore: NextGen Gallery **/
|
652 |
$('body').on('click', '.wp-smush-action.wp-smush-nextgen-restore', function (e) {
|
653 |
var current_button = $(this);
|
654 |
var smush_action = 'smush_restore_nextgen_image';
|
655 |
-
process_smush_action(
|
656 |
});
|
657 |
|
658 |
/** Resmush: NextGen Gallery **/
|
659 |
$('body').on('click', '.wp-smush-action.wp-smush-nextgen-resmush', function (e) {
|
660 |
var current_button = $(this);
|
661 |
var smush_action = 'smush_resmush_nextgen_image';
|
662 |
-
process_smush_action(
|
663 |
});
|
664 |
|
665 |
//Scan For resmushing images
|
666 |
-
$('body').on('click', '.wp-smush-scan', function(e) {
|
667 |
|
668 |
e.preventDefault();
|
669 |
|
@@ -688,7 +803,7 @@ jQuery(function ($) {
|
|
688 |
|
689 |
//Disable Bulk smush button and itself
|
690 |
button.attr('disabled', 'disabled');
|
691 |
-
$('.wp-smush-button'
|
692 |
|
693 |
//Hide Settings changed Notice
|
694 |
$('.wp-smush-settings-changed').hide();
|
@@ -707,9 +822,9 @@ jQuery(function ($) {
|
|
707 |
//Send ajax request and get ids if any
|
708 |
$.get(ajaxurl, params, function (r) {
|
709 |
//Check if we have the ids, initialize the local variable
|
710 |
-
if(
|
711 |
//Update Resmush id list
|
712 |
-
if(
|
713 |
wp_smushit_data.resmush = r.data.resmush_ids;
|
714 |
|
715 |
//Get the Smushed image count
|
@@ -728,18 +843,36 @@ jQuery(function ($) {
|
|
728 |
|
729 |
//Show Bulk wrapper
|
730 |
$('.wp-smush-bulk-wrapper').show();
|
|
|
|
|
|
|
|
|
|
|
731 |
}
|
732 |
//If content is received, Prepend it
|
733 |
if ('undefined' != typeof r.data.content) {
|
734 |
$('.bulk-smush-wrapper .box-container').prepend(r.data.content);
|
735 |
}
|
736 |
//If we have any notice to show
|
737 |
-
if ('undefined' != typeof r.data.notice
|
738 |
$('.wp-smush-page-header').after(r.data.notice);
|
739 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
740 |
}
|
741 |
|
742 |
-
}).always(
|
743 |
|
744 |
//Hide the progress bar
|
745 |
jQuery('.bulk-smush-wrapper .wp-smush-bulk-progress-bar-wrapper').hide();
|
@@ -755,11 +888,11 @@ jQuery(function ($) {
|
|
755 |
});
|
756 |
|
757 |
//Dismiss Welcome notice
|
758 |
-
$('#wp-smush-welcome-box .smush-dismiss-welcome').on('click', function(e) {
|
759 |
e.preventDefault();
|
760 |
var $el = $(this).parents().eq(1);
|
761 |
-
$el.fadeTo(
|
762 |
-
$el.slideUp(
|
763 |
$el.remove();
|
764 |
});
|
765 |
});
|
@@ -767,25 +900,26 @@ jQuery(function ($) {
|
|
767 |
var param = {
|
768 |
action: 'dismiss_welcome_notice'
|
769 |
};
|
770 |
-
$.post(ajaxurl, param
|
771 |
});
|
772 |
|
773 |
//Remove Notice
|
774 |
-
$('body').on('click', '.wp-smush-notice .dev-icon-cross', function(e) {
|
775 |
e.preventDefault();
|
776 |
var $el = $(this).parent();
|
777 |
-
$el.fadeTo(
|
778 |
-
$el.slideUp(
|
779 |
$el.remove();
|
780 |
});
|
781 |
});
|
782 |
});
|
783 |
|
784 |
//On Click Update Settings. Check for change in settings
|
785 |
-
$('#wp-smush-save-settings').on('click', function(e) {
|
786 |
e.preventDefault();
|
787 |
|
788 |
var self = $(this);
|
|
|
789 |
|
790 |
//Get all the main settings
|
791 |
var keep_exif = document.getElementById("wp-smush-keep_exif");
|
@@ -795,15 +929,15 @@ jQuery(function ($) {
|
|
795 |
var update_button_txt = true;
|
796 |
|
797 |
//If Preserve Exif is Checked, and all other settings are off, just save the settings
|
798 |
-
if (
|
799 |
update_button_txt = false;
|
800 |
}
|
801 |
|
802 |
//Update text
|
803 |
self.attr('disabled', 'disabled').addClass('button-grey');
|
804 |
|
805 |
-
if(
|
806 |
-
self.val(
|
807 |
}
|
808 |
|
809 |
self.parent().find('.spinner').addClass('is-active');
|
@@ -818,7 +952,7 @@ jQuery(function ($) {
|
|
818 |
scan_type: scan_type
|
819 |
};
|
820 |
|
821 |
-
param = jQuery.param(
|
822 |
|
823 |
//Send ajax, Update Settings, And Check For resmush
|
824 |
jQuery.post(ajaxurl, param).done(function () {
|
@@ -835,8 +969,8 @@ jQuery(function ($) {
|
|
835 |
|
836 |
//Remove Parent div
|
837 |
var $el = self.parent();
|
838 |
-
$el.fadeTo(
|
839 |
-
$el.slideUp(
|
840 |
$el.remove();
|
841 |
});
|
842 |
});
|
@@ -848,7 +982,7 @@ jQuery(function ($) {
|
|
848 |
container.find('.wp-smush-all').attr('data-smush', 'skip_resmush');
|
849 |
|
850 |
//Update Stats
|
851 |
-
if(
|
852 |
|
853 |
//Show all done notice
|
854 |
$('.wp-smush-notice.wp-smush-all-done').show();
|
@@ -866,12 +1000,24 @@ jQuery(function ($) {
|
|
866 |
var smushed_count = 'undefined' != typeof wp_smushit_data.count_smushed ? wp_smushit_data.count_smushed : 0
|
867 |
$('.smush-attachments .wp-smush-stats .smushed-count, .wp-smush-images-smushed').html(smushed_count);
|
868 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
869 |
//Show the default bulk smush notice
|
870 |
-
$('.wp-smush-bulk-wrapper .wp-smush-notice').
|
871 |
|
872 |
var params = {
|
873 |
action: 'delete_resmush_list',
|
874 |
-
type:
|
875 |
}
|
876 |
//Delete resmush list
|
877 |
$.post(ajaxurl, params);
|
@@ -896,22 +1042,6 @@ jQuery(function ($) {
|
|
896 |
|
897 |
});
|
898 |
|
899 |
-
//Dismiss Install/Upgrade notice
|
900 |
-
$('#wp-smush-install-thanks .smush-dismiss-welcome').on('click', function(e) {
|
901 |
-
e.preventDefault();
|
902 |
-
var $el = $(this).parents().eq(2);
|
903 |
-
$el.fadeTo( 100, 0, function() {
|
904 |
-
$el.slideUp( 100, function() {
|
905 |
-
$el.remove();
|
906 |
-
});
|
907 |
-
});
|
908 |
-
//Send a ajax request to save the dismissed notice option
|
909 |
-
var param = {
|
910 |
-
action: 'dismiss_upgrade_notice'
|
911 |
-
};
|
912 |
-
$.post(ajaxurl, param );
|
913 |
-
});
|
914 |
-
|
915 |
//Allow the checkboxes to be Keyboard Accessible
|
916 |
$('.wp-smush-setting-row .toggle-checkbox').focus(function () {
|
917 |
//If Space is pressed
|
@@ -923,6 +1053,30 @@ jQuery(function ($) {
|
|
923 |
});
|
924 |
});
|
925 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
926 |
|
927 |
});
|
928 |
(function ($) {
|
14 |
* @param txt Message to be displayed
|
15 |
* @param state show/hide
|
16 |
*/
|
17 |
+
var progress_bar = function (cur_ele, txt, state) {
|
18 |
|
19 |
//Update Progress bar text and show it
|
20 |
var progress_button = cur_ele.parents().eq(1).find('.wp-smush-progress');
|
21 |
|
22 |
+
if ('show' == state) {
|
23 |
progress_button.find('span').html(txt);
|
24 |
progress_button.removeClass('hidden');
|
25 |
+
} else {
|
26 |
+
progress_button.find('span').html(wp_smush_msgs.all_done);
|
27 |
progress_button.hide();
|
28 |
}
|
29 |
};
|
70 |
this.deferred.errors = [];
|
71 |
|
72 |
//If button has resmush class, and we do have ids that needs to resmushed, put them in the list
|
73 |
+
this.ids = wp_smushit_data.resmush.length > 0 && !skip_resmush ? ( wp_smushit_data.unsmushed.length > 0 ? wp_smushit_data.resmush.concat(wp_smushit_data.unsmushed) : wp_smushit_data.resmush ): wp_smushit_data.unsmushed;
|
74 |
|
75 |
this.is_bulk_resmush = wp_smushit_data.resmush.length > 0 && !skip_resmush ? true : false;
|
76 |
|
121 |
//Show the Progress Bar
|
122 |
$('.bulk-smush-wrapper .wp-smush-bulk-progress-bar-wrapper').show();
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
//Remove any Global Notices if there
|
125 |
$('.wp-smush-notice.wp-smush-resmush-message').remove();
|
126 |
};
|
161 |
} else {
|
162 |
self.$status.addClass("error");
|
163 |
}
|
164 |
+
self.$status.html(response.data.status);
|
165 |
//Check if stats div exists
|
166 |
var parent = self.$status.parent();
|
167 |
var stats_div = parent.find('.smush-stats-wrapper');
|
168 |
+
if ('undefined' != stats_div && stats_div.length) {
|
169 |
+
stats_div.replaceWith(response.data.stats);
|
170 |
+
} else {
|
171 |
+
parent.append(response.data.stats);
|
172 |
}
|
173 |
}
|
174 |
self.enable_button();
|
188 |
this.enable_button();
|
189 |
|
190 |
//Show Notice
|
191 |
+
if (self.ids.length == 0) {
|
192 |
$('.bulk-smush-wrapper .wp-smush-all-done').show();
|
193 |
+
$('.wp-smush-bulk-wrapper').hide();
|
194 |
} else {
|
195 |
if ($('.bulk-smush-wrapper .wp-smush-resmush-notice').length > 0) {
|
196 |
$('.bulk-smush-wrapper .wp-smush-resmush-notice').show();
|
216 |
//Hide the Progress bar and show the Bulk smush wrapper
|
217 |
$('.wp-smush-bulk-progress-bar-wrapper').hide();
|
218 |
|
219 |
+
if (self.ids.length > 0) {
|
220 |
//Show Bulk wrapper
|
221 |
$('.wp-smush-bulk-wrapper ').show();
|
222 |
} else {
|
225 |
};
|
226 |
|
227 |
this.update_remaining_count = function () {
|
228 |
+
if (this.is_bulk_resmush) {
|
229 |
//ReSmush Notice
|
230 |
+
if ($('.wp-smush-resmush-notice .wp-smush-remaining-count').length && 'undefined' != typeof self.ids) {
|
231 |
+
$('.wp-smush-resmush-notice .wp-smush-remaining-count').html(self.ids.length);
|
232 |
}
|
233 |
+
} else {
|
234 |
//Smush Notice
|
235 |
+
if ($('.bulk-smush-wrapper .wp-smush-remaining-count').length && 'undefined' != typeof self.ids) {
|
236 |
+
$('.bulk-smush-wrapper .wp-smush-remaining-count').html(self.ids.length);
|
237 |
}
|
238 |
}
|
239 |
}
|
259 |
if (wp_smushit_data.resmush.length > 0) {
|
260 |
//Update the Count
|
261 |
$('.wp-smush-images-remaining').html(wp_smushit_data.resmush.length);
|
262 |
+
} else if (wp_smushit_data.resmush.length == 0 && this.ids.length == 0 ) {
|
263 |
//If all images are resmushed, show the All Smushed message
|
264 |
|
265 |
//Show All Smushed
|
278 |
}
|
279 |
|
280 |
//Show Bulk Wrapper and Smush Notice
|
281 |
+
if (self.ids.length == 0) {
|
282 |
//Hide the bulk wrapper
|
283 |
$('.wp-smush-bulk-wrapper').hide();
|
284 |
//Show All done notice
|
285 |
$('.wp-smush-notice.wp-smush-all-done').show();
|
286 |
}
|
287 |
|
288 |
+
//Update Total Images Tooltip
|
289 |
+
if( 'undefined' !== typeof _res.data.stats.tooltip_text && '' != _res.data.stats.tooltip_text ) {
|
290 |
+
$('.wp-smush-stats .smushed-count').attr('tooltip', _res.data.stats.tooltip_text );
|
291 |
+
}
|
292 |
+
|
293 |
//Update remaining count
|
294 |
self.update_remaining_count();
|
295 |
|
296 |
//if we have received the progress data, update the stats else skip
|
297 |
if ('undefined' != typeof _res.data.stats) {
|
298 |
+
|
|
|
|
|
299 |
//Update stats
|
300 |
$('.smush-total-reduction-percent .wp-smush-stats').html(_res.data.stats.percent);
|
301 |
$('.smush-total-reduction-bytes .wp-smush-stats').html(_res.data.stats.human);
|
302 |
|
303 |
+
$('.smush-attachments .wp-smush-stats .smushed-count, .wp-smush-images-smushed').html(_res.data.stats.smushed);
|
304 |
if ($('.super-smush-attachments .smushed-count').length && 'undefined' != typeof _res.data.stats.super_smushed) {
|
305 |
$('.super-smush-attachments .smushed-count').html(_res.data.stats.super_smushed);
|
306 |
}
|
312 |
|
313 |
this._update_progress = function (count, width) {
|
314 |
"use strict";
|
315 |
+
if (!this.is_bulk && !this.is_bulk_resmush) {
|
316 |
return;
|
317 |
}
|
318 |
//Update the Progress Bar Width
|
341 |
return continue_smush && this.ids.length > 0 && this.is_bulk;
|
342 |
};
|
343 |
|
344 |
+
this.increment_errors = function (id) {
|
345 |
WP_Smush.errors.push(id);
|
346 |
};
|
347 |
|
349 |
this.call_ajax = function () {
|
350 |
var nonce_value = '';
|
351 |
this.current_id = this.is_bulk ? this.ids.shift() : this.$button.data("id"); //remove from array while processing so we can continue where left off
|
352 |
+
|
353 |
+
//Remove the id from respective variable as well
|
354 |
+
this.update_smush_ids( this.current_id );
|
355 |
+
|
356 |
var nonce_field = this.$button.parent().find('#_wp_smush_nonce');
|
357 |
if (nonce_field) {
|
358 |
nonce_value = nonce_field.val();
|
360 |
|
361 |
this.request = WP_Smush.ajax(this.is_bulk_resmush, this.current_id, this.url, 0, nonce_value)
|
362 |
.error(function () {
|
363 |
+
self.increment_errors(self.current_id);
|
364 |
+
}).done(function (res) {
|
365 |
//Increase the error count if any
|
366 |
if (typeof res.success === "undefined" || ( typeof res.success !== "undefined" && res.success === false && res.data.error !== 'bulk_request_image_limit_exceeded' )) {
|
367 |
+
self.increment_errors(self.current_id);
|
368 |
}
|
369 |
//If no response or success is false, do not process further
|
370 |
if (typeof res == 'undefined' || !res || !res.success) {
|
375 |
}
|
376 |
}
|
377 |
|
378 |
+
if (typeof res.data !== "undefined" && res.data.error == 'bulk_request_image_limit_exceeded' && !self.is_resolved()) {
|
379 |
//Add a data attribute to the smush button, to stop sending ajax
|
380 |
self.$button.attr('continue_smush', false);
|
381 |
|
388 |
self.update_remaining_count();
|
389 |
} else {
|
390 |
|
391 |
+
if (self.is_bulk && res.success) {
|
392 |
self.update_progress(res);
|
393 |
}
|
394 |
}
|
397 |
if (!self.continue() || !self.is_bulk) {
|
398 |
//Calls deferred.done()
|
399 |
self.deferred.resolve();
|
400 |
+
} else {
|
401 |
self.call_ajax();
|
402 |
}
|
403 |
});
|
450 |
this.cancel_ajax = function () {
|
451 |
$('.wp-smush-cancel-bulk').on('click', function () {
|
452 |
//Add a data attribute to the smush button, to stop sending ajax
|
453 |
+
self.$button.attr('continue_smush', false);
|
454 |
|
455 |
self.request.abort();
|
456 |
self.enable_button();
|
461 |
$('.wp-smush-bulk-progress-bar-wrapper').hide();
|
462 |
});
|
463 |
};
|
464 |
+
/**
|
465 |
+
* Remove the current id from unsmushed/resmush variable
|
466 |
+
* @param current_id
|
467 |
+
*/
|
468 |
+
this.update_smush_ids = function( current_id ) {
|
469 |
+
if ('undefined' !== typeof wp_smushit_data.unsmushed && wp_smushit_data.unsmushed.length > 0) {
|
470 |
+
var u_index = wp_smushit_data.unsmushed.indexOf(current_id);
|
471 |
+
if (u_index > -1) {
|
472 |
+
wp_smushit_data.unsmushed.splice(u_index, 1);
|
473 |
+
}
|
474 |
+
}
|
475 |
+
//remove from the resmush list
|
476 |
+
if ('undefined' !== typeof wp_smushit_data.resmush && wp_smushit_data.resmush.length > 0) {
|
477 |
+
var index = wp_smushit_data.resmush.indexOf(current_id);
|
478 |
+
if (index > -1) {
|
479 |
+
wp_smushit_data.resmush.splice(index, 1);
|
480 |
+
}
|
481 |
+
}
|
482 |
+
}
|
483 |
|
484 |
this.start();
|
485 |
this.run();
|
517 |
|
518 |
new WP_Smush.Smush($(this), true);
|
519 |
|
520 |
+
|
521 |
});
|
522 |
|
523 |
/** Disable the action links **/
|
547 |
* @param smush_action
|
548 |
* @returns {boolean}
|
549 |
*/
|
550 |
+
var process_smush_action = function (e, current_button, smush_action) {
|
551 |
|
552 |
//If disabled
|
553 |
+
if ('disabled' == current_button.attr('disabled')) {
|
554 |
return false;
|
555 |
}
|
556 |
|
570 |
};
|
571 |
|
572 |
//Reduce the opacity of stats and disable the click
|
573 |
+
disable_links(current_button);
|
574 |
|
575 |
+
progress_bar(current_button, wp_smush_msgs.smushing, 'show');
|
576 |
|
577 |
//Restore the image
|
578 |
$.post(ajaxurl, params, function (r) {
|
579 |
|
580 |
+
progress_bar(current_button, wp_smush_msgs.smushing, 'hide');
|
581 |
|
582 |
//reset all functionality
|
583 |
+
enable_links(current_button);
|
584 |
|
585 |
+
if (r.success && 'undefined' != typeof( r.data.button )) {
|
586 |
//Show the smush button, and remove stats and restore option
|
587 |
current_button.parents().eq(1).html(r.data.button);
|
588 |
} else {
|
589 |
+
if (r.data.message) {
|
590 |
//show error
|
591 |
current_button.parent().append(r.data.message);
|
592 |
}
|
594 |
})
|
595 |
};
|
596 |
|
597 |
+
/**
|
598 |
+
* Validates the Resize Width and Height against the Largest Thumbnail Width and Height
|
599 |
+
*
|
600 |
+
* @param wrapper_div jQuery object for the whole setting row wrapper div
|
601 |
+
* @param width_only Whether to validate only width
|
602 |
+
* @param height_only Validate only Height
|
603 |
+
* @returns {boolean} All Good or not
|
604 |
+
*
|
605 |
+
*/
|
606 |
+
var validate_resize_settings = function (wrapper_div, width_only, height_only) {
|
607 |
+
var resize_checkbox = wrapper_div.find('#wp-smush-resize');
|
608 |
+
if (!height_only) {
|
609 |
+
var width_input = wrapper_div.find('#wp-smush-resize_width');
|
610 |
+
var width_error_note = wrapper_div.find('.wp-smush-size-info.wp-smush-update-width');
|
611 |
+
}
|
612 |
+
if (!width_only) {
|
613 |
+
var height_input = wrapper_div.find('#wp-smush-resize_height');
|
614 |
+
var height_error_note = wrapper_div.find('.wp-smush-size-info.wp-smush-update-height');
|
615 |
+
}
|
616 |
+
|
617 |
+
var width_error = false;
|
618 |
+
var height_error = false
|
619 |
+
|
620 |
+
//If resize settings is not enabled, return true
|
621 |
+
if (!resize_checkbox.is(':checked')) {
|
622 |
+
return true;
|
623 |
+
}
|
624 |
+
|
625 |
+
//Check if we have localised width and height
|
626 |
+
if ('undefined' == typeof (wp_smushit_data.resize_sizes) || 'undefined' == typeof (wp_smushit_data.resize_sizes.width)) {
|
627 |
+
//Rely on server validation
|
628 |
+
return true;
|
629 |
+
}
|
630 |
+
|
631 |
+
//Check for width
|
632 |
+
if ( !height_only && 'undefined' != typeof width_input && parseInt(wp_smushit_data.resize_sizes.width) > parseInt(width_input.val())) {
|
633 |
+
width_input.addClass('error');
|
634 |
+
width_error_note.show('slow');
|
635 |
+
width_error = true;
|
636 |
+
} else {
|
637 |
+
//Remove error class
|
638 |
+
width_input.removeClass('error');
|
639 |
+
width_error_note.hide();
|
640 |
+
if (height_input.hasClass('error')) {
|
641 |
+
height_error_note.show('slow');
|
642 |
+
}
|
643 |
+
}
|
644 |
+
|
645 |
+
//Check for height
|
646 |
+
if (!width_only && 'undefined' != typeof height_input && parseInt(wp_smushit_data.resize_sizes.height) > parseInt(height_input.val())) {
|
647 |
+
height_input.addClass('error');
|
648 |
+
//If we are not showing the width error already
|
649 |
+
if (!width_error) {
|
650 |
+
height_error_note.show('slow');
|
651 |
+
}
|
652 |
+
height_error = true;
|
653 |
+
} else {
|
654 |
+
//Remove error class
|
655 |
+
height_input.removeClass('error');
|
656 |
+
height_error_note.hide();
|
657 |
+
if (width_input.hasClass('error')) {
|
658 |
+
width_error_note.show('slow');
|
659 |
+
}
|
660 |
+
}
|
661 |
+
|
662 |
+
if (width_error || height_error) {
|
663 |
+
return false;
|
664 |
+
}
|
665 |
+
return true;
|
666 |
+
|
667 |
+
};
|
668 |
+
|
669 |
+
/**
|
670 |
+
* Update the progress bar width if we have images that needs to be resmushed
|
671 |
+
* @param unsmushed_count
|
672 |
+
* @returns {boolean}
|
673 |
+
*/
|
674 |
+
var update_progress_bar_resmush = function (unsmushed_count) {
|
675 |
+
|
676 |
+
if ('undefined' == typeof unsmushed_count) {
|
677 |
+
return false;
|
678 |
+
}
|
679 |
+
|
680 |
+
var smushed_count = wp_smushit_data.count_total - unsmushed_count;
|
681 |
+
|
682 |
+
//Update the Progress Bar Width
|
683 |
+
// get the progress bar
|
684 |
+
var $progress_bar = jQuery('.bulk-smush-wrapper .wp-smush-progress-inner');
|
685 |
+
if ($progress_bar.length < 1) {
|
686 |
+
return;
|
687 |
+
}
|
688 |
+
|
689 |
+
var width = ( smushed_count / wp_smushit_data.count_total ) * 100;
|
690 |
+
|
691 |
+
// increase progress
|
692 |
+
$progress_bar.css('width', width + '%');
|
693 |
+
};
|
694 |
+
|
695 |
/**
|
696 |
* Handle the Smush Stats link click
|
697 |
*/
|
698 |
$('body').on('click', 'a.smush-stats-details', function (e) {
|
699 |
|
700 |
//If disabled
|
701 |
+
if ('disabled' == $(this).attr('disabled')) {
|
702 |
return false;
|
703 |
}
|
704 |
|
709 |
$(this).parents().eq(1).find('.smush-stats-wrapper').slideToggle();
|
710 |
slide_symbol.text(slide_symbol.text() == '+' ? '-' : '+');
|
711 |
|
712 |
+
|
713 |
});
|
714 |
|
715 |
/** Handle smush button click **/
|
746 |
jQuery('.wp-smush-button, .wp-smush-scan').attr('disabled', 'disabled');
|
747 |
$(".wp-smush-notice.wp-smush-remaining").hide();
|
748 |
new WP_Smush.Smush($(this), true, 'nextgen');
|
749 |
+
|
750 |
});
|
751 |
|
752 |
/** Restore: Media Library **/
|
753 |
$('body').on('click', '.wp-smush-action.wp-smush-restore', function (e) {
|
754 |
var current_button = $(this);
|
755 |
var smush_action = 'smush_restore_image';
|
756 |
+
process_smush_action(e, current_button, smush_action);
|
757 |
});
|
758 |
|
759 |
/** Resmush: Media Library **/
|
760 |
$('body').on('click', '.wp-smush-action.wp-smush-resmush', function (e) {
|
761 |
var current_button = $(this);
|
762 |
var smush_action = 'smush_resmush_image';
|
763 |
+
process_smush_action(e, current_button, smush_action);
|
764 |
});
|
765 |
|
766 |
/** Restore: NextGen Gallery **/
|
767 |
$('body').on('click', '.wp-smush-action.wp-smush-nextgen-restore', function (e) {
|
768 |
var current_button = $(this);
|
769 |
var smush_action = 'smush_restore_nextgen_image';
|
770 |
+
process_smush_action(e, current_button, smush_action);
|
771 |
});
|
772 |
|
773 |
/** Resmush: NextGen Gallery **/
|
774 |
$('body').on('click', '.wp-smush-action.wp-smush-nextgen-resmush', function (e) {
|
775 |
var current_button = $(this);
|
776 |
var smush_action = 'smush_resmush_nextgen_image';
|
777 |
+
process_smush_action(e, current_button, smush_action);
|
778 |
});
|
779 |
|
780 |
//Scan For resmushing images
|
781 |
+
$('body').on('click', '.wp-smush-scan', function (e) {
|
782 |
|
783 |
e.preventDefault();
|
784 |
|
803 |
|
804 |
//Disable Bulk smush button and itself
|
805 |
button.attr('disabled', 'disabled');
|
806 |
+
$('.wp-smush-button').attr('disabled', 'disabled');
|
807 |
|
808 |
//Hide Settings changed Notice
|
809 |
$('.wp-smush-settings-changed').hide();
|
822 |
//Send ajax request and get ids if any
|
823 |
$.get(ajaxurl, params, function (r) {
|
824 |
//Check if we have the ids, initialize the local variable
|
825 |
+
if ('undefined' != typeof r.data) {
|
826 |
//Update Resmush id list
|
827 |
+
if ('undefined' != typeof r.data.resmush_ids) {
|
828 |
wp_smushit_data.resmush = r.data.resmush_ids;
|
829 |
|
830 |
//Get the Smushed image count
|
843 |
|
844 |
//Show Bulk wrapper
|
845 |
$('.wp-smush-bulk-wrapper').show();
|
846 |
+
|
847 |
+
if( 'undefined' !== typeof r.data.count ) {
|
848 |
+
//Update progress bar
|
849 |
+
update_progress_bar_resmush( r.data.count );
|
850 |
+
}
|
851 |
}
|
852 |
//If content is received, Prepend it
|
853 |
if ('undefined' != typeof r.data.content) {
|
854 |
$('.bulk-smush-wrapper .box-container').prepend(r.data.content);
|
855 |
}
|
856 |
//If we have any notice to show
|
857 |
+
if ('undefined' != typeof r.data.notice) {
|
858 |
$('.wp-smush-page-header').after(r.data.notice);
|
859 |
}
|
860 |
+
//Hide errors
|
861 |
+
$('.smush-final-log').hide();
|
862 |
+
|
863 |
+
//Hide Super Smush notice if it's enabled in media settings
|
864 |
+
if ('undefined' != typeof r.data.super_smush && r.data.super_smush ) {
|
865 |
+
var enable_lossy = jQuery('.wp-smush-enable-lossy');
|
866 |
+
if( enable_lossy.length > 0 ) {
|
867 |
+
enable_lossy.remove();
|
868 |
+
}
|
869 |
+
if( 'undefined' !== r.data.super_smush_stats ) {
|
870 |
+
$('.super-smush-attachments .wp-smush-stats').html( r.data.super_smush_stats );
|
871 |
+
}
|
872 |
+
}
|
873 |
}
|
874 |
|
875 |
+
}).always(function () {
|
876 |
|
877 |
//Hide the progress bar
|
878 |
jQuery('.bulk-smush-wrapper .wp-smush-bulk-progress-bar-wrapper').hide();
|
888 |
});
|
889 |
|
890 |
//Dismiss Welcome notice
|
891 |
+
$('#wp-smush-welcome-box .smush-dismiss-welcome').on('click', function (e) {
|
892 |
e.preventDefault();
|
893 |
var $el = $(this).parents().eq(1);
|
894 |
+
$el.fadeTo(100, 0, function () {
|
895 |
+
$el.slideUp(100, function () {
|
896 |
$el.remove();
|
897 |
});
|
898 |
});
|
900 |
var param = {
|
901 |
action: 'dismiss_welcome_notice'
|
902 |
};
|
903 |
+
$.post(ajaxurl, param);
|
904 |
});
|
905 |
|
906 |
//Remove Notice
|
907 |
+
$('body').on('click', '.wp-smush-notice .dev-icon-cross', function (e) {
|
908 |
e.preventDefault();
|
909 |
var $el = $(this).parent();
|
910 |
+
$el.fadeTo(100, 0, function () {
|
911 |
+
$el.slideUp(100, function () {
|
912 |
$el.remove();
|
913 |
});
|
914 |
});
|
915 |
});
|
916 |
|
917 |
//On Click Update Settings. Check for change in settings
|
918 |
+
$('#wp-smush-save-settings').on('click', function (e) {
|
919 |
e.preventDefault();
|
920 |
|
921 |
var self = $(this);
|
922 |
+
var wrapper_div = self.parents().eq(1);
|
923 |
|
924 |
//Get all the main settings
|
925 |
var keep_exif = document.getElementById("wp-smush-keep_exif");
|
929 |
var update_button_txt = true;
|
930 |
|
931 |
//If Preserve Exif is Checked, and all other settings are off, just save the settings
|
932 |
+
if (keep_exif.checked && !super_smush.checked && !smush_original.checked) {
|
933 |
update_button_txt = false;
|
934 |
}
|
935 |
|
936 |
//Update text
|
937 |
self.attr('disabled', 'disabled').addClass('button-grey');
|
938 |
|
939 |
+
if (update_button_txt) {
|
940 |
+
self.val(wp_smush_msgs.checking)
|
941 |
}
|
942 |
|
943 |
self.parent().find('.spinner').addClass('is-active');
|
952 |
scan_type: scan_type
|
953 |
};
|
954 |
|
955 |
+
param = jQuery.param(param) + '&' + jQuery('form#wp-smush-settings-form').serialize();
|
956 |
|
957 |
//Send ajax, Update Settings, And Check For resmush
|
958 |
jQuery.post(ajaxurl, param).done(function () {
|
969 |
|
970 |
//Remove Parent div
|
971 |
var $el = self.parent();
|
972 |
+
$el.fadeTo(100, 0, function () {
|
973 |
+
$el.slideUp(100, function () {
|
974 |
$el.remove();
|
975 |
});
|
976 |
});
|
982 |
container.find('.wp-smush-all').attr('data-smush', 'skip_resmush');
|
983 |
|
984 |
//Update Stats
|
985 |
+
if (wp_smushit_data.count_smushed == wp_smushit_data.count_total) {
|
986 |
|
987 |
//Show all done notice
|
988 |
$('.wp-smush-notice.wp-smush-all-done').show();
|
1000 |
var smushed_count = 'undefined' != typeof wp_smushit_data.count_smushed ? wp_smushit_data.count_smushed : 0
|
1001 |
$('.smush-attachments .wp-smush-stats .smushed-count, .wp-smush-images-smushed').html(smushed_count);
|
1002 |
|
1003 |
+
//Update the Progress Bar Width
|
1004 |
+
// get the progress bar
|
1005 |
+
var $progress_bar = jQuery('.bulk-smush-wrapper .wp-smush-progress-inner');
|
1006 |
+
if ($progress_bar.length < 1) {
|
1007 |
+
return;
|
1008 |
+
}
|
1009 |
+
|
1010 |
+
var width = ( smushed_count / wp_smushit_data.count_total ) * 100;
|
1011 |
+
|
1012 |
+
// increase progress
|
1013 |
+
$progress_bar.css('width', width + '%');
|
1014 |
+
|
1015 |
//Show the default bulk smush notice
|
1016 |
+
$('.wp-smush-bulk-wrapper .wp-smush-notice').show();
|
1017 |
|
1018 |
var params = {
|
1019 |
action: 'delete_resmush_list',
|
1020 |
+
type: type
|
1021 |
}
|
1022 |
//Delete resmush list
|
1023 |
$.post(ajaxurl, params);
|
1042 |
|
1043 |
});
|
1044 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1045 |
//Allow the checkboxes to be Keyboard Accessible
|
1046 |
$('.wp-smush-setting-row .toggle-checkbox').focus(function () {
|
1047 |
//If Space is pressed
|
1053 |
});
|
1054 |
});
|
1055 |
|
1056 |
+
//Re-Validate Resize Width And Height
|
1057 |
+
$('.wp-smush-resize-input').blur(function () {
|
1058 |
+
|
1059 |
+
var self = $(this);
|
1060 |
+
|
1061 |
+
var wrapper_div = self.parents().eq(2);
|
1062 |
+
|
1063 |
+
//Initiate the check
|
1064 |
+
validate_resize_settings(wrapper_div, false, false); // run the validation
|
1065 |
+
|
1066 |
+
});
|
1067 |
+
|
1068 |
+
//Handle Resize Checkbox toggle, to show/hide width, height settings
|
1069 |
+
$('#wp-smush-resize').click(function() {
|
1070 |
+
var self = $(this);
|
1071 |
+
var settings_wrap = $('.wp-smush-resize-settings-wrap');
|
1072 |
+
|
1073 |
+
if (self.is(':checked')) {
|
1074 |
+
settings_wrap.show();
|
1075 |
+
} else {
|
1076 |
+
settings_wrap.hide();
|
1077 |
+
}
|
1078 |
+
});
|
1079 |
+
|
1080 |
|
1081 |
});
|
1082 |
(function ($) {
|
extras/free-dashboard/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
.svn
|
|
extras/free-dashboard/README.md
DELETED
@@ -1,71 +0,0 @@
|
|
1 |
-
# WDEV Frash module #
|
2 |
-
|
3 |
-
WPMU DEV Free Dashboard module (short wdev-frash) is used in our free plugins hosted on wordpress.org
|
4 |
-
It will display a welcome message upon plugin activation that offers the user a 5-day introduction email course for the plugin. After 7 days the module will display another message asking the user to rate the plugin on wordpress.org
|
5 |
-
|
6 |
-
# How to use it #
|
7 |
-
|
8 |
-
1. Insert this repository as **sub-module** into the existing project
|
9 |
-
|
10 |
-
2. Include the file `module.php` in your main plugin file.
|
11 |
-
|
12 |
-
3. Call the action `wdev-register-plugin` with the params mentioned below.
|
13 |
-
|
14 |
-
4. Done!
|
15 |
-
|
16 |
-
|
17 |
-
## Code Example (from Membership 2) ##
|
18 |
-
|
19 |
-
```
|
20 |
-
#!php
|
21 |
-
|
22 |
-
<?php
|
23 |
-
// Load the WDev-Frash module.
|
24 |
-
include_once 'lib/wdev-frash/module.php';
|
25 |
-
|
26 |
-
// Register the current plugin.
|
27 |
-
do_action(
|
28 |
-
'wdev-register-plugin',
|
29 |
-
/* 1 Plugin ID */ plugin_basename( __FILE__ ),
|
30 |
-
/* 2 Plugin Title */ 'Membership 2',
|
31 |
-
/* 3 https://wordpress.org */ '/plugins/membership/',
|
32 |
-
/* 4 Email Button CTA */ __( 'Get Members!', MYD_TEXT_DOMAIN ),
|
33 |
-
/* 5 getdrip Plugin param */ 'Membership'
|
34 |
-
);
|
35 |
-
// All done!
|
36 |
-
```
|
37 |
-
|
38 |
-
1. Always same, do not change
|
39 |
-
2. The plugin title, same as in the plugin header (no translation!)
|
40 |
-
3. The wordpress.org plugin-URL
|
41 |
-
4. Optional: Title of the Email-subscription button. If empty no email message is displayed.
|
42 |
-
5. Optional: getdrip plugin name (defined in the getdrip rule). If empty no email message is displayed
|
43 |
-
|
44 |
-
|
45 |
-
## Optional: Customize the messages via filters ##
|
46 |
-
|
47 |
-
```
|
48 |
-
<?php
|
49 |
-
// The email message contains 1 variable: plugin-name
|
50 |
-
add_filter(
|
51 |
-
'wdev-email-message-' . plugin_basename( __FILE__ ),
|
52 |
-
'custom_email_message'
|
53 |
-
);
|
54 |
-
function custom_email_message( $message ) {
|
55 |
-
$message = 'You installed %s! This is a custom <u>email message</u>';
|
56 |
-
return $message;
|
57 |
-
}
|
58 |
-
```
|
59 |
-
|
60 |
-
```
|
61 |
-
<?php
|
62 |
-
// The rating message contains 2 variables: user-name, plugin-name
|
63 |
-
add_filter(
|
64 |
-
'wdev-rating-message-' . plugin_basename( __FILE__ ),
|
65 |
-
'custom_rating_message'
|
66 |
-
);
|
67 |
-
function custom_rating_message( $message ) {
|
68 |
-
$message = 'Hi %s, you used %s for a while now! This is a custom <u>rating message</u>';
|
69 |
-
return $message;
|
70 |
-
}
|
71 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/wp-smushit\n"
|
7 |
-
"POT-Creation-Date: 2016-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -25,11 +25,11 @@ msgid "Oops, we could not do this..."
|
|
25 |
msgstr ""
|
26 |
|
27 |
#: assets/shared-ui/plugin-ui.php:225 extras/free-dashboard/module.php:406
|
28 |
-
#: extras/free-dashboard/module.php:445
|
29 |
msgid "Saving"
|
30 |
msgstr ""
|
31 |
|
32 |
-
#: assets/shared-ui/plugin-ui.php:254
|
33 |
msgid "Dismiss"
|
34 |
msgstr ""
|
35 |
|
@@ -57,176 +57,189 @@ msgstr ""
|
|
57 |
msgid "Rate %s"
|
58 |
msgstr ""
|
59 |
|
60 |
-
#: lib/class-wp-smush-admin.php:
|
61 |
msgid "Automatically smush my images on upload"
|
62 |
msgstr ""
|
63 |
|
64 |
-
#: lib/class-wp-smush-admin.php:
|
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:
|
69 |
msgid "Preserve image EXIF data"
|
70 |
msgstr ""
|
71 |
|
72 |
-
#: lib/class-wp-smush-admin.php:
|
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:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
msgid "Super-smush my images"
|
78 |
msgstr ""
|
79 |
|
80 |
-
#: lib/class-wp-smush-admin.php:
|
81 |
msgid "Compress images up to 10x more than regular smush with almost no visible drop in quality."
|
82 |
msgstr ""
|
83 |
|
84 |
-
#: lib/class-wp-smush-admin.php:
|
85 |
msgid "Include my original full-size images"
|
86 |
msgstr ""
|
87 |
|
88 |
-
#: lib/class-wp-smush-admin.php:
|
89 |
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."
|
90 |
msgstr ""
|
91 |
|
92 |
-
#: lib/class-wp-smush-admin.php:
|
93 |
msgid "Make a copy of my original images"
|
94 |
msgstr ""
|
95 |
|
96 |
-
#: lib/class-wp-smush-admin.php:
|
97 |
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."
|
98 |
msgstr ""
|
99 |
|
100 |
-
#: lib/class-wp-smush-admin.php:
|
101 |
msgid "Enable NextGen Gallery integration"
|
102 |
msgstr ""
|
103 |
|
104 |
-
#: lib/class-wp-smush-admin.php:
|
105 |
msgid "Allow smushing images directly through NextGen Gallery settings."
|
106 |
msgstr ""
|
107 |
|
108 |
-
#: lib/class-wp-smush-admin.php:
|
109 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:70
|
110 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:89
|
111 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:91
|
112 |
msgid "WP Smush"
|
113 |
msgstr ""
|
114 |
|
115 |
-
#: lib/class-wp-smush-admin.php:
|
116 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
117 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:
|
118 |
msgid "Super-Smush"
|
119 |
msgstr ""
|
120 |
|
121 |
-
#: lib/class-wp-smush-admin.php:
|
122 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
123 |
msgid "Smush Now"
|
124 |
msgstr ""
|
125 |
|
126 |
-
#: lib/class-wp-smush-admin.php:
|
127 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
128 |
msgid "{{errors}} image(s) were skipped due to an error."
|
129 |
msgstr ""
|
130 |
|
131 |
-
#: lib/class-wp-smush-admin.php:
|
132 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
133 |
msgid "All images are fully optimised."
|
134 |
msgstr ""
|
135 |
|
136 |
-
#: lib/class-wp-smush-admin.php:
|
137 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
138 |
msgid "Restoring image.."
|
139 |
msgstr ""
|
140 |
|
141 |
-
#: lib/class-wp-smush-admin.php:
|
142 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
143 |
msgid "Smushing image.."
|
144 |
msgstr ""
|
145 |
|
146 |
-
#: lib/class-wp-smush-admin.php:
|
147 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
148 |
msgid "Checking images.."
|
149 |
msgstr ""
|
150 |
|
151 |
-
#: lib/class-wp-smush-admin.php:
|
152 |
msgid "Smush request timed out, You can try setting a higher value for `WP_SMUSH_API_TIMEOUT`."
|
153 |
msgstr ""
|
154 |
|
155 |
-
#: lib/class-wp-smush-admin.php:
|
|
|
|
|
|
|
|
|
156 |
msgid "You don't have permission to work with uploaded files."
|
157 |
msgstr ""
|
158 |
|
159 |
-
#: lib/class-wp-smush-admin.php:
|
160 |
msgid "No attachment ID was provided."
|
161 |
msgstr ""
|
162 |
|
163 |
-
#: lib/class-wp-smush-admin.php:
|
164 |
msgid "<strong>%d of %d images</strong> were sent for smushing:"
|
165 |
msgstr ""
|
166 |
|
167 |
-
#: lib/class-wp-smush-admin.php:
|
168 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
169 |
msgid "Bulk Smush Now"
|
170 |
msgstr ""
|
171 |
|
172 |
-
#: lib/class-wp-smush-admin.php:
|
173 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
174 |
msgid "All Done!"
|
175 |
msgstr ""
|
176 |
|
177 |
-
#: lib/class-wp-smush-admin.php:
|
178 |
msgid "Settings"
|
179 |
msgstr ""
|
180 |
|
181 |
-
#: lib/class-wp-smush-admin.php:
|
182 |
-
msgid "THANKS FOR UPDATING SMUSH!"
|
183 |
-
msgstr ""
|
184 |
-
|
185 |
-
#: lib/class-wp-smush-admin.php:950
|
186 |
-
msgid "HAPPY SMUSHING!"
|
187 |
-
msgstr ""
|
188 |
-
|
189 |
-
#: lib/class-wp-smush-admin.php:1106 lib/class-wp-smush-nextgen.php:471
|
190 |
msgid "Error in processing restore action, Fields empty."
|
191 |
msgstr ""
|
192 |
|
193 |
-
#: lib/class-wp-smush-admin.php:
|
194 |
msgid "Image not restored, Nonce verification failed."
|
195 |
msgstr ""
|
196 |
|
197 |
-
#: lib/class-wp-smush-admin.php:
|
198 |
msgid "Unable to restore image"
|
199 |
msgstr ""
|
200 |
|
201 |
-
#: lib/class-wp-smush-admin.php:
|
202 |
msgid "Image not smushed, fields empty."
|
203 |
msgstr ""
|
204 |
|
205 |
-
#: lib/class-wp-smush-admin.php:
|
206 |
msgid "Image couldn't be smushed as the nonce verification failed, try reloading the page."
|
207 |
msgstr ""
|
208 |
|
209 |
-
#: lib/class-wp-smush-admin.php:
|
210 |
msgid "Unable to smush image"
|
211 |
msgstr ""
|
212 |
|
213 |
-
#: lib/class-wp-smush-admin.php:
|
214 |
msgid "Yay! All images are optimised as per your current settings."
|
215 |
msgstr ""
|
216 |
|
217 |
-
#: lib/class-wp-smush-admin.php:
|
218 |
msgid "You have images that need smushing. %sBulk smush now!%s"
|
219 |
msgstr ""
|
220 |
|
221 |
-
#: lib/class-wp-smush-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
msgid "We couldn't find the metadata for the image, possibly the image has been deleted."
|
223 |
msgstr ""
|
224 |
|
225 |
-
#: lib/class-wp-smush-nextgen.php:
|
226 |
msgid "We couldn't process the image, fields empty."
|
227 |
msgstr ""
|
228 |
|
229 |
-
#: lib/class-wp-smush-nextgen.php:
|
230 |
msgid "Unable to smush image, %s"
|
231 |
msgstr ""
|
232 |
|
@@ -255,7 +268,7 @@ msgid "Media Library"
|
|
255 |
msgstr ""
|
256 |
|
257 |
#: lib/class-wp-smush-ui.php:97
|
258 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
259 |
msgid "BULK SMUSH"
|
260 |
msgstr ""
|
261 |
|
@@ -264,291 +277,309 @@ msgid "SETTINGS"
|
|
264 |
msgstr ""
|
265 |
|
266 |
#: lib/class-wp-smush-ui.php:126
|
267 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
268 |
msgid "Lets you check if any images can be further optimised. Useful after changing settings."
|
269 |
msgstr ""
|
270 |
|
271 |
#: lib/class-wp-smush-ui.php:126
|
272 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
273 |
msgid "RE-CHECK IMAGES"
|
274 |
msgstr ""
|
275 |
|
276 |
#: lib/class-wp-smush-ui.php:127
|
277 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
278 |
msgid "STATS"
|
279 |
msgstr ""
|
280 |
|
281 |
#: lib/class-wp-smush-ui.php:131
|
282 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
283 |
msgid "TOTAL % REDUCTIONS"
|
284 |
msgstr ""
|
285 |
|
286 |
#: lib/class-wp-smush-ui.php:139
|
287 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
288 |
msgid "TOTAL SIZE REDUCTIONS"
|
289 |
msgstr ""
|
290 |
|
291 |
#: lib/class-wp-smush-ui.php:146
|
292 |
-
|
|
|
|
|
|
|
|
|
293 |
msgid "ATTACHMENTS SMUSHED"
|
294 |
msgstr ""
|
295 |
|
296 |
-
#: lib/class-wp-smush-ui.php:
|
297 |
-
|
|
|
|
|
|
|
|
|
298 |
msgid "ATTACHMENTS SUPER-SMUSHED"
|
299 |
msgstr ""
|
300 |
|
301 |
-
#: lib/class-wp-smush-ui.php:
|
302 |
msgid "%sENABLE%s"
|
303 |
msgstr ""
|
304 |
|
305 |
-
#: lib/class-wp-smush-ui.php:
|
306 |
msgid "UPDATE SETTINGS"
|
307 |
msgstr ""
|
308 |
|
309 |
-
#: lib/class-wp-smush-ui.php:
|
310 |
msgid "%sPRO ONLY%s"
|
311 |
msgstr ""
|
312 |
|
313 |
-
#: lib/class-wp-smush-ui.php:
|
314 |
msgid "ADVANCED SETTINGS"
|
315 |
msgstr ""
|
316 |
|
317 |
-
#: lib/class-wp-smush-ui.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
msgid "TRY WP SMUSH PRO - DEV TEAM"
|
319 |
msgstr ""
|
320 |
|
321 |
-
#: lib/class-wp-smush-ui.php:
|
322 |
msgid "BOOST YOUR PERFORMANCE - HUMMINGBIRD"
|
323 |
msgstr ""
|
324 |
|
325 |
-
#: lib/class-wp-smush-ui.php:
|
326 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:423
|
327 |
msgid "No attachments found - Upload some images"
|
328 |
msgstr ""
|
329 |
|
330 |
-
#: lib/class-wp-smush-ui.php:
|
331 |
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!"
|
332 |
msgstr ""
|
333 |
|
334 |
-
#: lib/class-wp-smush-ui.php:
|
335 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:428
|
336 |
msgid "UPLOAD IMAGES"
|
337 |
msgstr ""
|
338 |
|
339 |
-
#: lib/class-wp-smush-ui.php:
|
340 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:433
|
341 |
-
msgid "
|
342 |
msgstr ""
|
343 |
|
344 |
-
#: lib/class-wp-smush-ui.php:
|
345 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:438
|
346 |
msgid "BULK SMUSH NOW"
|
347 |
msgstr ""
|
348 |
|
349 |
-
#: lib/class-wp-smush-ui.php:
|
350 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:446
|
351 |
msgid "%s, you have %s%s%d%s image%s that needs smushing!"
|
352 |
msgid_plural "%s, you have %s%s%d%s images%s that need smushing!"
|
353 |
msgstr[0] ""
|
354 |
msgstr[1] ""
|
355 |
|
356 |
-
#: lib/class-wp-smush-ui.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
msgid "Enable Super-smush in the Settings area to get even more savings with almost no noticeable quality loss."
|
358 |
msgstr ""
|
359 |
|
360 |
-
#: lib/class-wp-smush-ui.php:
|
361 |
msgid "%sBulk smush is currently running.%s You need to keep this page open."
|
362 |
msgstr ""
|
363 |
|
364 |
-
#: lib/class-wp-smush-ui.php:
|
365 |
msgid "%s%d%s of %d attachments have been smushed."
|
366 |
msgstr ""
|
367 |
|
368 |
-
#: lib/class-wp-smush-ui.php:
|
369 |
msgid "CANCEL"
|
370 |
msgstr ""
|
371 |
|
372 |
-
#: lib/class-wp-smush-ui.php:
|
373 |
-
msgid "%sBulk re-smush is currently running.%s You need to keep this page open."
|
374 |
-
msgstr ""
|
375 |
-
|
376 |
-
#: lib/class-wp-smush-ui.php:520
|
377 |
-
msgid "%s%d%s image left to Re-Smush"
|
378 |
-
msgid_plural "%s%d%s images left to Re-Smush"
|
379 |
-
msgstr[0] ""
|
380 |
-
msgstr[1] ""
|
381 |
-
|
382 |
-
#: lib/class-wp-smush-ui.php:568
|
383 |
msgid "%s, you have %s%s%d%s image%s that needs re-compressing!"
|
384 |
msgid_plural "%s, you have %s%s%d%s images%s that need re-compressing!"
|
385 |
msgstr[0] ""
|
386 |
msgstr[1] ""
|
387 |
|
388 |
-
#: lib/class-wp-smush-ui.php:
|
389 |
msgid "Skip"
|
390 |
msgstr ""
|
391 |
|
392 |
-
#: lib/class-wp-smush-ui.php:
|
393 |
msgid "Your settings have been updated!"
|
394 |
msgstr ""
|
395 |
|
396 |
-
#: lib/class-wp-smush-ui.php:
|
397 |
-
msgid "WP Smush Pro"
|
398 |
-
msgstr ""
|
399 |
-
|
400 |
-
#: lib/class-wp-smush-ui.php:617
|
401 |
msgid "Automatic smushing is %senabled%s. Newly uploaded images will be automagically compressed."
|
402 |
msgstr ""
|
403 |
|
404 |
-
#: lib/class-wp-smush-ui.php:
|
405 |
msgid "Automatic smushing is %sdisabled%s. Newly uploaded images will need to be manually smushed."
|
406 |
msgstr ""
|
407 |
|
408 |
-
#: lib/class-wp-smush-ui.php:
|
409 |
msgid "Thanks for installing Smush. We hope you like it!"
|
410 |
msgstr ""
|
411 |
|
412 |
-
#: lib/class-wp-smush-ui.php:
|
413 |
msgid "And hey, if you do, you can now try out Smush Pro for double the smushy goodness (benchmarked), entirely for free!"
|
414 |
msgstr ""
|
415 |
|
416 |
-
#: lib/class-wp-smush-ui.php:
|
417 |
-
msgid "
|
418 |
-
msgstr ""
|
419 |
-
|
420 |
-
#: lib/class-wp-smush-ui.php:648
|
421 |
-
msgid "Did you know that you can now %stry out Smush Pro%s for FREE?"
|
422 |
msgstr ""
|
423 |
|
424 |
-
#: lib/class-wp-smush-ui.php:
|
425 |
-
msgid "
|
426 |
msgstr ""
|
427 |
|
428 |
-
#: lib/class-wp-smush-ui.php:
|
429 |
-
msgid "
|
430 |
msgstr ""
|
431 |
|
432 |
-
#: lib/class-wp-smush-ui.php:
|
433 |
msgid "Did you know WP Smush Pro delivers up to 10x better compression, allows you to smush your originals and removes any bulk smushing limits? – %sTry it absolutely FREE%s"
|
434 |
msgstr ""
|
435 |
|
436 |
-
#: lib/class-wp-smush-ui.php:
|
437 |
msgid "Try WP Smush Pro for FREE"
|
438 |
msgstr ""
|
439 |
|
440 |
-
#: lib/class-wp-smush.php:
|
441 |
msgid "File path is empty"
|
442 |
msgstr ""
|
443 |
|
444 |
-
#: lib/class-wp-smush.php:
|
445 |
msgid "Could not find %s"
|
446 |
msgstr ""
|
447 |
|
448 |
-
#: lib/class-wp-smush.php:
|
449 |
msgid "%s is not writable"
|
450 |
msgstr ""
|
451 |
|
452 |
-
#: lib/class-wp-smush.php:
|
453 |
msgid "Skipped (%s), image not found. Attachment: %s"
|
454 |
msgstr ""
|
455 |
|
456 |
-
#: lib/class-wp-smush.php:
|
457 |
msgid "Skipped (%s), size limit exceeded. Attachment: %s"
|
458 |
msgstr ""
|
459 |
|
460 |
-
#: lib/class-wp-smush.php:
|
461 |
msgid "Unknown API error"
|
462 |
msgstr ""
|
463 |
|
464 |
-
#: lib/class-wp-smush.php:
|
465 |
msgid "Error posting to API: %s"
|
466 |
msgstr ""
|
467 |
|
468 |
-
#: lib/class-wp-smush.php:
|
469 |
msgid "Error posting to API: %s %s"
|
470 |
msgstr ""
|
471 |
|
472 |
-
#: lib/class-wp-smush.php:
|
473 |
msgid "Smush data corrupted, try again."
|
474 |
msgstr ""
|
475 |
|
476 |
-
#: lib/class-wp-smush.php:
|
477 |
msgid "Image couldn't be smushed"
|
478 |
msgstr ""
|
479 |
|
480 |
-
#: lib/class-wp-smush.php:
|
481 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:
|
482 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:
|
483 |
msgid "Already Optimized"
|
484 |
msgstr ""
|
485 |
|
486 |
-
#: lib/class-wp-smush.php:
|
487 |
msgid "%d images reduced "
|
488 |
msgstr ""
|
489 |
|
490 |
-
#: lib/class-wp-smush.php:
|
491 |
msgid "Reduced "
|
492 |
msgstr ""
|
493 |
|
494 |
-
#: lib/class-wp-smush.php:
|
495 |
msgid "by %s ( %01.1f%% )"
|
496 |
msgstr ""
|
497 |
|
498 |
-
#: lib/class-wp-smush.php:
|
499 |
msgid "Detailed stats for all the image sizes"
|
500 |
msgstr ""
|
501 |
|
502 |
-
#: lib/class-wp-smush.php:
|
503 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:
|
504 |
msgid "Smush stats"
|
505 |
msgstr ""
|
506 |
|
507 |
-
#: lib/class-wp-smush.php:
|
508 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
509 |
msgid "Not processed"
|
510 |
msgstr ""
|
511 |
|
512 |
-
#: lib/class-wp-smush.php:
|
513 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
514 |
msgid "Smush Now!"
|
515 |
msgstr ""
|
516 |
|
517 |
-
#: lib/class-wp-smush.php:
|
518 |
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."
|
519 |
msgstr ""
|
520 |
|
521 |
-
#: lib/class-wp-smush.php:
|
522 |
msgid "Image couldn't be smushed as it exceeded the 1Mb size limit, Pro users can smush images with size upto 32Mb."
|
523 |
msgstr ""
|
524 |
|
525 |
-
#: lib/class-wp-smush.php:
|
526 |
msgid " Skipped"
|
527 |
msgstr ""
|
528 |
|
529 |
-
#: lib/class-wp-smush.php:
|
530 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:
|
531 |
msgid "Image size"
|
532 |
msgstr ""
|
533 |
|
534 |
-
#: lib/class-wp-smush.php:
|
535 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:
|
536 |
msgid "Savings"
|
537 |
msgstr ""
|
538 |
|
539 |
-
#: lib/class-wp-smush.php:
|
540 |
msgid "Restore original image."
|
541 |
msgstr ""
|
542 |
|
543 |
-
#: lib/class-wp-smush.php:
|
544 |
msgid "Restore image"
|
545 |
msgstr ""
|
546 |
|
547 |
-
#: lib/class-wp-smush.php:
|
548 |
msgid "Smush image including original file."
|
549 |
msgstr ""
|
550 |
|
551 |
-
#: lib/class-wp-smush.php:
|
552 |
msgid "Resmush image"
|
553 |
msgstr ""
|
554 |
|
@@ -560,27 +591,27 @@ msgstr ""
|
|
560 |
msgid "We haven’t found any images in your %sgallery%s yet, so there’s no smushing to be done! Once you upload images, reload this page and start playing!"
|
561 |
msgstr ""
|
562 |
|
563 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
564 |
msgid "Enable Super-smush in the %sSettings%s area to get even more savings with almost no noticeable quality loss."
|
565 |
msgstr ""
|
566 |
|
567 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
568 |
msgid "Smush individual images via your %sManage Galleries%s section"
|
569 |
msgstr ""
|
570 |
|
571 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
572 |
msgid "Manage Galleries"
|
573 |
msgstr ""
|
574 |
|
575 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:
|
576 |
msgid "%sDISABLED%s"
|
577 |
msgstr ""
|
578 |
|
579 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-bulk.php:
|
580 |
msgid "Smush request timed out, You can try setting a higher value ( > 60 ) for `WP_SMUSH_API_TIMEOUT`."
|
581 |
msgstr ""
|
582 |
|
583 |
-
#: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:
|
584 |
msgid "Reduced by %s ( %01.1f%% )"
|
585 |
msgstr ""
|
586 |
|
2 |
# This file is distributed under the same license as the WP Smush package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: WP Smush 2.3\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/wp-smushit\n"
|
7 |
+
"POT-Creation-Date: 2016-05-24 10:32: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 |
msgstr ""
|
26 |
|
27 |
#: assets/shared-ui/plugin-ui.php:225 extras/free-dashboard/module.php:406
|
28 |
+
#: extras/free-dashboard/module.php:445 lib/class-wp-smush-ui.php:694
|
29 |
msgid "Saving"
|
30 |
msgstr ""
|
31 |
|
32 |
+
#: assets/shared-ui/plugin-ui.php:254 lib/class-wp-smush-ui.php:694
|
33 |
msgid "Dismiss"
|
34 |
msgstr ""
|
35 |
|
57 |
msgid "Rate %s"
|
58 |
msgstr ""
|
59 |
|
60 |
+
#: lib/class-wp-smush-admin.php:162
|
61 |
msgid "Automatically smush my images on upload"
|
62 |
msgstr ""
|
63 |
|
64 |
+
#: lib/class-wp-smush-admin.php:163
|
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:166
|
69 |
msgid "Preserve image EXIF data"
|
70 |
msgstr ""
|
71 |
|
72 |
+
#: lib/class-wp-smush-admin.php:167
|
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:170
|
77 |
+
msgid "Resize original images"
|
78 |
+
msgstr ""
|
79 |
+
|
80 |
+
#: lib/class-wp-smush-admin.php:171
|
81 |
+
msgid "Save a ton of space by not storing over-sized images on your server. Set image maximum width and height and large images will be automatically scaled before being added to the media library. "
|
82 |
+
msgstr ""
|
83 |
+
|
84 |
+
#: lib/class-wp-smush-admin.php:174
|
85 |
msgid "Super-smush my images"
|
86 |
msgstr ""
|
87 |
|
88 |
+
#: lib/class-wp-smush-admin.php:175
|
89 |
msgid "Compress images up to 10x more than regular smush with almost no visible drop in quality."
|
90 |
msgstr ""
|
91 |
|
92 |
+
#: lib/class-wp-smush-admin.php:178
|
93 |
msgid "Include my original full-size images"
|
94 |
msgstr ""
|
95 |
|
96 |
+
#: lib/class-wp-smush-admin.php:179
|
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:182
|
101 |
msgid "Make a copy of my original images"
|
102 |
msgstr ""
|
103 |
|
104 |
+
#: lib/class-wp-smush-admin.php:183
|
105 |
msgid "Save your original full-size images so you can restore them at any point. Note: Activating this setting will significantly increase the size of your uploads folder by nearly twice as much."
|
106 |
msgstr ""
|
107 |
|
108 |
+
#: lib/class-wp-smush-admin.php:190
|
109 |
msgid "Enable NextGen Gallery integration"
|
110 |
msgstr ""
|
111 |
|
112 |
+
#: lib/class-wp-smush-admin.php:191
|
113 |
msgid "Allow smushing images directly through NextGen Gallery settings."
|
114 |
msgstr ""
|
115 |
|
116 |
+
#: lib/class-wp-smush-admin.php:210 lib/class-wp-smush-ui.php:643
|
117 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:70
|
118 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:89
|
119 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:91
|
120 |
msgid "WP Smush"
|
121 |
msgstr ""
|
122 |
|
123 |
+
#: lib/class-wp-smush-admin.php:309 lib/class-wp-smush.php:947
|
124 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:158
|
125 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:275
|
126 |
msgid "Super-Smush"
|
127 |
msgstr ""
|
128 |
|
129 |
+
#: lib/class-wp-smush-admin.php:310
|
130 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:159
|
131 |
msgid "Smush Now"
|
132 |
msgstr ""
|
133 |
|
134 |
+
#: lib/class-wp-smush-admin.php:311
|
135 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:160
|
136 |
msgid "{{errors}} image(s) were skipped due to an error."
|
137 |
msgstr ""
|
138 |
|
139 |
+
#: lib/class-wp-smush-admin.php:312
|
140 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:161
|
141 |
msgid "All images are fully optimised."
|
142 |
msgstr ""
|
143 |
|
144 |
+
#: lib/class-wp-smush-admin.php:313
|
145 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:162
|
146 |
msgid "Restoring image.."
|
147 |
msgstr ""
|
148 |
|
149 |
+
#: lib/class-wp-smush-admin.php:314
|
150 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:163
|
151 |
msgid "Smushing image.."
|
152 |
msgstr ""
|
153 |
|
154 |
+
#: lib/class-wp-smush-admin.php:315
|
155 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:164
|
156 |
msgid "Checking images.."
|
157 |
msgstr ""
|
158 |
|
159 |
+
#: lib/class-wp-smush-admin.php:544
|
160 |
msgid "Smush request timed out, You can try setting a higher value for `WP_SMUSH_API_TIMEOUT`."
|
161 |
msgstr ""
|
162 |
|
163 |
+
#: lib/class-wp-smush-admin.php:560 lib/class-wp-smush-ui.php:176
|
164 |
+
msgid "%d images"
|
165 |
+
msgstr ""
|
166 |
+
|
167 |
+
#: lib/class-wp-smush-admin.php:578 lib/class-wp-smush-nextgen.php:372
|
168 |
msgid "You don't have permission to work with uploaded files."
|
169 |
msgstr ""
|
170 |
|
171 |
+
#: lib/class-wp-smush-admin.php:582 lib/class-wp-smush-nextgen.php:376
|
172 |
msgid "No attachment ID was provided."
|
173 |
msgstr ""
|
174 |
|
175 |
+
#: lib/class-wp-smush-admin.php:706
|
176 |
msgid "<strong>%d of %d images</strong> were sent for smushing:"
|
177 |
msgstr ""
|
178 |
|
179 |
+
#: lib/class-wp-smush-admin.php:861 lib/class-wp-smush-admin.php:874
|
180 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:336
|
181 |
msgid "Bulk Smush Now"
|
182 |
msgstr ""
|
183 |
|
184 |
+
#: lib/class-wp-smush-admin.php:868
|
185 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:340
|
186 |
msgid "All Done!"
|
187 |
msgstr ""
|
188 |
|
189 |
+
#: lib/class-wp-smush-admin.php:907 lib/class-wp-smush-admin.php:1717
|
190 |
msgid "Settings"
|
191 |
msgstr ""
|
192 |
|
193 |
+
#: lib/class-wp-smush-admin.php:1051 lib/class-wp-smush-nextgen.php:459
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
msgid "Error in processing restore action, Fields empty."
|
195 |
msgstr ""
|
196 |
|
197 |
+
#: lib/class-wp-smush-admin.php:1058 lib/class-wp-smush-nextgen.php:466
|
198 |
msgid "Image not restored, Nonce verification failed."
|
199 |
msgstr ""
|
200 |
|
201 |
+
#: lib/class-wp-smush-admin.php:1132 lib/class-wp-smush-nextgen.php:541
|
202 |
msgid "Unable to restore image"
|
203 |
msgstr ""
|
204 |
|
205 |
+
#: lib/class-wp-smush-admin.php:1150
|
206 |
msgid "Image not smushed, fields empty."
|
207 |
msgstr ""
|
208 |
|
209 |
+
#: lib/class-wp-smush-admin.php:1157 lib/class-wp-smush-nextgen.php:559
|
210 |
msgid "Image couldn't be smushed as the nonce verification failed, try reloading the page."
|
211 |
msgstr ""
|
212 |
|
213 |
+
#: lib/class-wp-smush-admin.php:1174
|
214 |
msgid "Unable to smush image"
|
215 |
msgstr ""
|
216 |
|
217 |
+
#: lib/class-wp-smush-admin.php:1193
|
218 |
msgid "Yay! All images are optimised as per your current settings."
|
219 |
msgstr ""
|
220 |
|
221 |
+
#: lib/class-wp-smush-admin.php:1342 lib/class-wp-smush-ui.php:618
|
222 |
msgid "You have images that need smushing. %sBulk smush now!%s"
|
223 |
msgstr ""
|
224 |
|
225 |
+
#: lib/class-wp-smush-admin.php:1718 lib/class-wp-smush-ui.php:512
|
226 |
+
#: lib/class-wp-smush-ui.php:643
|
227 |
+
msgid "WP Smush Pro"
|
228 |
+
msgstr ""
|
229 |
+
|
230 |
+
#: lib/class-wp-smush-admin.php:1721
|
231 |
+
msgid "Woohoo! Your latest Smush update %s allows you to %sauto resize%s all your images, how cool is that! %sFind out more here >>%s"
|
232 |
+
msgstr ""
|
233 |
+
|
234 |
+
#: lib/class-wp-smush-nextgen.php:318
|
235 |
msgid "We couldn't find the metadata for the image, possibly the image has been deleted."
|
236 |
msgstr ""
|
237 |
|
238 |
+
#: lib/class-wp-smush-nextgen.php:552
|
239 |
msgid "We couldn't process the image, fields empty."
|
240 |
msgstr ""
|
241 |
|
242 |
+
#: lib/class-wp-smush-nextgen.php:576
|
243 |
msgid "Unable to smush image, %s"
|
244 |
msgstr ""
|
245 |
|
268 |
msgstr ""
|
269 |
|
270 |
#: lib/class-wp-smush-ui.php:97
|
271 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:482
|
272 |
msgid "BULK SMUSH"
|
273 |
msgstr ""
|
274 |
|
277 |
msgstr ""
|
278 |
|
279 |
#: lib/class-wp-smush-ui.php:126
|
280 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:502
|
281 |
msgid "Lets you check if any images can be further optimised. Useful after changing settings."
|
282 |
msgstr ""
|
283 |
|
284 |
#: lib/class-wp-smush-ui.php:126
|
285 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:502
|
286 |
msgid "RE-CHECK IMAGES"
|
287 |
msgstr ""
|
288 |
|
289 |
#: lib/class-wp-smush-ui.php:127
|
290 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:503
|
291 |
msgid "STATS"
|
292 |
msgstr ""
|
293 |
|
294 |
#: lib/class-wp-smush-ui.php:131
|
295 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:508
|
296 |
msgid "TOTAL % REDUCTIONS"
|
297 |
msgstr ""
|
298 |
|
299 |
#: lib/class-wp-smush-ui.php:139
|
300 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:520
|
301 |
msgid "TOTAL SIZE REDUCTIONS"
|
302 |
msgstr ""
|
303 |
|
304 |
#: lib/class-wp-smush-ui.php:146
|
305 |
+
msgid "TOTAL RESIZE SAVINGS"
|
306 |
+
msgstr ""
|
307 |
+
|
308 |
+
#: lib/class-wp-smush-ui.php:153
|
309 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:529
|
310 |
msgid "ATTACHMENTS SMUSHED"
|
311 |
msgstr ""
|
312 |
|
313 |
+
#: lib/class-wp-smush-ui.php:155
|
314 |
+
msgid " You've smushed %d images in total"
|
315 |
+
msgstr ""
|
316 |
+
|
317 |
+
#: lib/class-wp-smush-ui.php:173
|
318 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:544
|
319 |
msgid "ATTACHMENTS SUPER-SMUSHED"
|
320 |
msgstr ""
|
321 |
|
322 |
+
#: lib/class-wp-smush-ui.php:178
|
323 |
msgid "%sENABLE%s"
|
324 |
msgstr ""
|
325 |
|
326 |
+
#: lib/class-wp-smush-ui.php:203
|
327 |
msgid "UPDATE SETTINGS"
|
328 |
msgstr ""
|
329 |
|
330 |
+
#: lib/class-wp-smush-ui.php:217
|
331 |
msgid "%sPRO ONLY%s"
|
332 |
msgstr ""
|
333 |
|
334 |
+
#: lib/class-wp-smush-ui.php:219
|
335 |
msgid "ADVANCED SETTINGS"
|
336 |
msgstr ""
|
337 |
|
338 |
+
#: lib/class-wp-smush-ui.php:356
|
339 |
+
msgid "Width"
|
340 |
+
msgstr ""
|
341 |
+
|
342 |
+
#: lib/class-wp-smush-ui.php:359
|
343 |
+
msgid "Height"
|
344 |
+
msgstr ""
|
345 |
+
|
346 |
+
#: lib/class-wp-smush-ui.php:362
|
347 |
+
msgid "Currently, your largest thumbnail size is set at %s%dpx wide x %dpx high%s. Anything above 2048px in width or height is huge and not recommended."
|
348 |
+
msgstr ""
|
349 |
+
|
350 |
+
#: lib/class-wp-smush-ui.php:363
|
351 |
+
msgid "Just to let you know, the width you've entered is less than your largest thumbnail and may result in pixelation."
|
352 |
+
msgstr ""
|
353 |
+
|
354 |
+
#: lib/class-wp-smush-ui.php:364
|
355 |
+
msgid "Just to let you know, the height you’ve entered is less than your largest thumbnail and may result in pixelation."
|
356 |
+
msgstr ""
|
357 |
+
|
358 |
+
#: lib/class-wp-smush-ui.php:441
|
359 |
msgid "TRY WP SMUSH PRO - DEV TEAM"
|
360 |
msgstr ""
|
361 |
|
362 |
+
#: lib/class-wp-smush-ui.php:457
|
363 |
msgid "BOOST YOUR PERFORMANCE - HUMMINGBIRD"
|
364 |
msgstr ""
|
365 |
|
366 |
+
#: lib/class-wp-smush-ui.php:484
|
367 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:423
|
368 |
msgid "No attachments found - Upload some images"
|
369 |
msgstr ""
|
370 |
|
371 |
+
#: lib/class-wp-smush-ui.php:486
|
372 |
msgid "We haven’t found any images in your %smedia library%s yet so there’s no smushing to be done! Once you upload images, reload this page and start playing!"
|
373 |
msgstr ""
|
374 |
|
375 |
+
#: lib/class-wp-smush-ui.php:489
|
376 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:428
|
377 |
msgid "UPLOAD IMAGES"
|
378 |
msgstr ""
|
379 |
|
380 |
+
#: lib/class-wp-smush-ui.php:494
|
381 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:433
|
382 |
+
msgid "All images are smushed and up to date. Awesome!"
|
383 |
msgstr ""
|
384 |
|
385 |
+
#: lib/class-wp-smush-ui.php:499
|
386 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:438
|
387 |
msgid "BULK SMUSH NOW"
|
388 |
msgstr ""
|
389 |
|
390 |
+
#: lib/class-wp-smush-ui.php:510
|
391 |
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:446
|
392 |
msgid "%s, you have %s%s%d%s image%s that needs smushing!"
|
393 |
msgid_plural "%s, you have %s%s%d%s images%s that need smushing!"
|
394 |
msgstr[0] ""
|
395 |
msgstr[1] ""
|
396 |
|
397 |
+
#: lib/class-wp-smush-ui.php:512
|
398 |
+
msgid "You can %sUpgrade to Pro%s to bulk smush all your images with one click."
|
399 |
+
msgstr ""
|
400 |
+
|
401 |
+
#: lib/class-wp-smush-ui.php:513
|
402 |
+
msgid "Free users can smush 50 images with each click."
|
403 |
+
msgstr ""
|
404 |
+
|
405 |
+
#: lib/class-wp-smush-ui.php:522
|
406 |
msgid "Enable Super-smush in the Settings area to get even more savings with almost no noticeable quality loss."
|
407 |
msgstr ""
|
408 |
|
409 |
+
#: lib/class-wp-smush-ui.php:545
|
410 |
msgid "%sBulk smush is currently running.%s You need to keep this page open."
|
411 |
msgstr ""
|
412 |
|
413 |
+
#: lib/class-wp-smush-ui.php:555
|
414 |
msgid "%s%d%s of %d attachments have been smushed."
|
415 |
msgstr ""
|
416 |
|
417 |
+
#: lib/class-wp-smush-ui.php:560
|
418 |
msgid "CANCEL"
|
419 |
msgstr ""
|
420 |
|
421 |
+
#: lib/class-wp-smush-ui.php:596
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
msgid "%s, you have %s%s%d%s image%s that needs re-compressing!"
|
423 |
msgid_plural "%s, you have %s%s%d%s images%s that need re-compressing!"
|
424 |
msgstr[0] ""
|
425 |
msgstr[1] ""
|
426 |
|
427 |
+
#: lib/class-wp-smush-ui.php:597
|
428 |
msgid "Skip"
|
429 |
msgstr ""
|
430 |
|
431 |
+
#: lib/class-wp-smush-ui.php:611
|
432 |
msgid "Your settings have been updated!"
|
433 |
msgstr ""
|
434 |
|
435 |
+
#: lib/class-wp-smush-ui.php:645
|
|
|
|
|
|
|
|
|
436 |
msgid "Automatic smushing is %senabled%s. Newly uploaded images will be automagically compressed."
|
437 |
msgstr ""
|
438 |
|
439 |
+
#: lib/class-wp-smush-ui.php:645
|
440 |
msgid "Automatic smushing is %sdisabled%s. Newly uploaded images will need to be manually smushed."
|
441 |
msgstr ""
|
442 |
|
443 |
+
#: lib/class-wp-smush-ui.php:674
|
444 |
msgid "Thanks for installing Smush. We hope you like it!"
|
445 |
msgstr ""
|
446 |
|
447 |
+
#: lib/class-wp-smush-ui.php:675
|
448 |
msgid "And hey, if you do, you can now try out Smush Pro for double the smushy goodness (benchmarked), entirely for free!"
|
449 |
msgstr ""
|
450 |
|
451 |
+
#: lib/class-wp-smush-ui.php:676 lib/class-wp-smush-ui.php:680
|
452 |
+
msgid "Try Smush Pro for Free"
|
|
|
|
|
|
|
|
|
453 |
msgstr ""
|
454 |
|
455 |
+
#: lib/class-wp-smush-ui.php:678
|
456 |
+
msgid "Thanks for updating Smush. Did you know that you can now try the Smush Pro for FREE?!"
|
457 |
msgstr ""
|
458 |
|
459 |
+
#: lib/class-wp-smush-ui.php:679
|
460 |
+
msgid "Yep, Super Smush your images for double the savings, save originals and batch Smush thousands of images all at once.... no charge!"
|
461 |
msgstr ""
|
462 |
|
463 |
+
#: lib/class-wp-smush-ui.php:710
|
464 |
msgid "Did you know WP Smush Pro delivers up to 10x better compression, allows you to smush your originals and removes any bulk smushing limits? – %sTry it absolutely FREE%s"
|
465 |
msgstr ""
|
466 |
|
467 |
+
#: lib/class-wp-smush-ui.php:710
|
468 |
msgid "Try WP Smush Pro for FREE"
|
469 |
msgstr ""
|
470 |
|
471 |
+
#: lib/class-wp-smush.php:153
|
472 |
msgid "File path is empty"
|
473 |
msgstr ""
|
474 |
|
475 |
+
#: lib/class-wp-smush.php:158
|
476 |
msgid "Could not find %s"
|
477 |
msgstr ""
|
478 |
|
479 |
+
#: lib/class-wp-smush.php:163
|
480 |
msgid "%s is not writable"
|
481 |
msgstr ""
|
482 |
|
483 |
+
#: lib/class-wp-smush.php:173
|
484 |
msgid "Skipped (%s), image not found. Attachment: %s"
|
485 |
msgstr ""
|
486 |
|
487 |
+
#: lib/class-wp-smush.php:178
|
488 |
msgid "Skipped (%s), size limit exceeded. Attachment: %s"
|
489 |
msgstr ""
|
490 |
|
491 |
+
#: lib/class-wp-smush.php:197
|
492 |
msgid "Unknown API error"
|
493 |
msgstr ""
|
494 |
|
495 |
+
#: lib/class-wp-smush.php:617
|
496 |
msgid "Error posting to API: %s"
|
497 |
msgstr ""
|
498 |
|
499 |
+
#: lib/class-wp-smush.php:623
|
500 |
msgid "Error posting to API: %s %s"
|
501 |
msgstr ""
|
502 |
|
503 |
+
#: lib/class-wp-smush.php:640
|
504 |
msgid "Smush data corrupted, try again."
|
505 |
msgstr ""
|
506 |
|
507 |
+
#: lib/class-wp-smush.php:656
|
508 |
msgid "Image couldn't be smushed"
|
509 |
msgstr ""
|
510 |
|
511 |
+
#: lib/class-wp-smush.php:874 lib/class-wp-smush.php:878
|
512 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:193
|
513 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:196
|
514 |
msgid "Already Optimized"
|
515 |
msgstr ""
|
516 |
|
517 |
+
#: lib/class-wp-smush.php:887
|
518 |
msgid "%d images reduced "
|
519 |
msgstr ""
|
520 |
|
521 |
+
#: lib/class-wp-smush.php:887
|
522 |
msgid "Reduced "
|
523 |
msgstr ""
|
524 |
|
525 |
+
#: lib/class-wp-smush.php:888
|
526 |
msgid "by %s ( %01.1f%% )"
|
527 |
msgstr ""
|
528 |
|
529 |
+
#: lib/class-wp-smush.php:922
|
530 |
msgid "Detailed stats for all the image sizes"
|
531 |
msgstr ""
|
532 |
|
533 |
+
#: lib/class-wp-smush.php:922
|
534 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:236
|
535 |
msgid "Smush stats"
|
536 |
msgstr ""
|
537 |
|
538 |
+
#: lib/class-wp-smush.php:954
|
539 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:249
|
540 |
msgid "Not processed"
|
541 |
msgstr ""
|
542 |
|
543 |
+
#: lib/class-wp-smush.php:960
|
544 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:255
|
545 |
msgid "Smush Now!"
|
546 |
msgstr ""
|
547 |
|
548 |
+
#: lib/class-wp-smush.php:1258
|
549 |
msgid "When you upload an image to WordPress it automatically creates %s thumbnail sizes that are commonly used in your pages. WordPress also stores the original full-size image, but because these are not usually embedded on your site we don’t Smush them. Pro users can override this."
|
550 |
msgstr ""
|
551 |
|
552 |
+
#: lib/class-wp-smush.php:1261
|
553 |
msgid "Image couldn't be smushed as it exceeded the 1Mb size limit, Pro users can smush images with size upto 32Mb."
|
554 |
msgstr ""
|
555 |
|
556 |
+
#: lib/class-wp-smush.php:1263
|
557 |
msgid " Skipped"
|
558 |
msgstr ""
|
559 |
|
560 |
+
#: lib/class-wp-smush.php:1283
|
561 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:432
|
562 |
msgid "Image size"
|
563 |
msgstr ""
|
564 |
|
565 |
+
#: lib/class-wp-smush.php:1284
|
566 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:433
|
567 |
msgid "Savings"
|
568 |
msgstr ""
|
569 |
|
570 |
+
#: lib/class-wp-smush.php:1466
|
571 |
msgid "Restore original image."
|
572 |
msgstr ""
|
573 |
|
574 |
+
#: lib/class-wp-smush.php:1466
|
575 |
msgid "Restore image"
|
576 |
msgstr ""
|
577 |
|
578 |
+
#: lib/class-wp-smush.php:1511
|
579 |
msgid "Smush image including original file."
|
580 |
msgstr ""
|
581 |
|
582 |
+
#: lib/class-wp-smush.php:1511
|
583 |
msgid "Resmush image"
|
584 |
msgstr ""
|
585 |
|
591 |
msgid "We haven’t found any images in your %sgallery%s yet, so there’s no smushing to be done! Once you upload images, reload this page and start playing!"
|
592 |
msgstr ""
|
593 |
|
594 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:462
|
595 |
msgid "Enable Super-smush in the %sSettings%s area to get even more savings with almost no noticeable quality loss."
|
596 |
msgstr ""
|
597 |
|
598 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:477
|
599 |
msgid "Smush individual images via your %sManage Galleries%s section"
|
600 |
msgstr ""
|
601 |
|
602 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:477
|
603 |
msgid "Manage Galleries"
|
604 |
msgstr ""
|
605 |
|
606 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-admin.php:552
|
607 |
msgid "%sDISABLED%s"
|
608 |
msgstr ""
|
609 |
|
610 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-bulk.php:31
|
611 |
msgid "Smush request timed out, You can try setting a higher value ( > 60 ) for `WP_SMUSH_API_TIMEOUT`."
|
612 |
msgstr ""
|
613 |
|
614 |
+
#: lib/nextgen-integration/class-wp-smush-nextgen-stats.php:205
|
615 |
msgid "Reduced by %s ( %01.1f%% )"
|
616 |
msgstr ""
|
617 |
|
lib/class-wp-smush-admin.php
CHANGED
@@ -9,6 +9,7 @@
|
|
9 |
*
|
10 |
* @copyright (c) 2016, Incsub (http://incsub.com)
|
11 |
*/
|
|
|
12 |
//Include Bulk UI
|
13 |
require_once WP_SMUSH_DIR . 'lib/class-wp-smush-ui.php';
|
14 |
|
@@ -60,6 +61,10 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
60 |
*/
|
61 |
public $super_smushed;
|
62 |
|
|
|
|
|
|
|
|
|
63 |
/**
|
64 |
* @array Stores the stats for all the images
|
65 |
*/
|
@@ -92,9 +97,6 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
92 |
*/
|
93 |
public function __construct() {
|
94 |
|
95 |
-
// Save Settings, Process Option, Need to process it early, so the pages are loaded accordingly, nextgen gallery integration is loaded at same action
|
96 |
-
// add_action( 'plugins_loaded', array( $this, 'process_options' ), 16 );
|
97 |
-
|
98 |
// hook scripts and styles
|
99 |
add_action( 'admin_init', array( $this, 'register' ) );
|
100 |
|
@@ -127,15 +129,21 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
127 |
//Attachment status, Grid view
|
128 |
add_filter( 'attachment_fields_to_edit', array( $this, 'filter_attachment_fields_to_edit' ), 10, 2 );
|
129 |
|
130 |
-
|
131 |
add_action( 'admin_notices', array( $this, 'smush_upgrade' ) );
|
132 |
|
|
|
|
|
|
|
133 |
//Handle the smush pro dismiss features notice ajax
|
134 |
add_action( 'wp_ajax_dismiss_upgrade_notice', array( $this, 'dismiss_upgrade_notice' ) );
|
135 |
|
136 |
//Handle the smush pro dismiss features notice ajax
|
137 |
add_action( 'wp_ajax_dismiss_welcome_notice', array( $this, 'dismiss_welcome_notice' ) );
|
138 |
|
|
|
|
|
|
|
139 |
//Update the Super Smush count, after the smushing
|
140 |
add_action( 'wp_smush_image_optimised', array( $this, 'update_lists' ), '', 2 );
|
141 |
|
@@ -158,6 +166,10 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
158 |
'label' => esc_html__( 'Preserve image EXIF data', 'wp-smushit' ),
|
159 |
'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' )
|
160 |
),
|
|
|
|
|
|
|
|
|
161 |
'lossy' => array(
|
162 |
'label' => esc_html__( 'Super-smush my images', 'wp-smushit' ),
|
163 |
'desc' => esc_html__( 'Compress images up to 10x more than regular smush with almost no visible drop in quality.', 'wp-smushit' )
|
@@ -234,6 +246,9 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
234 |
|
235 |
/* Register Style. */
|
236 |
wp_register_style( 'wp-smushit-admin-css', WP_SMUSH_URL . 'assets/css/wp-smushit-admin.css', array(), $WpSmush->version );
|
|
|
|
|
|
|
237 |
}
|
238 |
|
239 |
/**
|
@@ -252,7 +267,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
252 |
$enqueue_smush = apply_filters( 'wp_smush_enqueue', true );
|
253 |
|
254 |
//If we upgrade/install message is dismissed and for pro users
|
255 |
-
if( get_option( 'wp-smush-hide_upgrade_notice' ) || get_site_option( 'wp-smush-hide_upgrade_notice' ) || $this->is_pro() ) {
|
256 |
//Do not enqueue, unless it is one of the required screen
|
257 |
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' ) ) {
|
258 |
|
@@ -285,7 +300,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
285 |
*/
|
286 |
function localize() {
|
287 |
global $current_screen;
|
288 |
-
$current_page = !empty( $current_screen ) ? $current_screen->base : '';
|
289 |
|
290 |
$bulk = new WpSmushitBulk();
|
291 |
$handle = 'wp-smushit-admin-js';
|
@@ -297,7 +312,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
297 |
'all_resmushed' => esc_html__( 'All images are fully optimised.', 'wp-smushit' ),
|
298 |
'restore' => esc_html__( "Restoring image..", "wp-smushit" ),
|
299 |
'smushing' => esc_html__( "Smushing image..", "wp-smushit" ),
|
300 |
-
'checking' => esc_html__( "Checking images..", "wp-smushit" )
|
301 |
);
|
302 |
|
303 |
wp_localize_script( $handle, 'wp_smush_msgs', $wp_smush_msgs );
|
@@ -305,11 +320,12 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
305 |
//Load the stats on selected screens only
|
306 |
if ( $current_page == 'media_page_wp-smush-bulk' ) {
|
307 |
|
308 |
-
$this->attachments = $bulk->get_attachments();
|
309 |
-
|
310 |
//Setup all the stats
|
311 |
$this->setup_global_stats();
|
312 |
|
|
|
|
|
|
|
313 |
//Localize smushit_ids variable, if there are fix number of ids
|
314 |
$this->ids = ! empty( $_REQUEST['ids'] ) ? array_map( 'intval', explode( ',', $_REQUEST['ids'] ) ) : $this->attachments;
|
315 |
|
@@ -328,7 +344,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
328 |
'unsmushed' => $this->ids,
|
329 |
'resmush' => $this->resmush_ids,
|
330 |
);
|
331 |
-
}else{
|
332 |
$data = array(
|
333 |
'count_smushed' => '',
|
334 |
'count_total' => '',
|
@@ -338,6 +354,8 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
338 |
|
339 |
}
|
340 |
|
|
|
|
|
341 |
$data['timeout'] = WP_SMUSH_TIMEOUT * 1000; //Convert it into ms
|
342 |
|
343 |
wp_localize_script( 'wp-smushit-admin-js', 'wp_smushit_data', $data );
|
@@ -352,10 +370,12 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
352 |
*
|
353 |
*/
|
354 |
function setup_global_stats( $force_update = false ) {
|
355 |
-
|
356 |
-
$this->
|
357 |
-
$this->
|
358 |
-
$this->
|
|
|
|
|
359 |
}
|
360 |
|
361 |
/**
|
@@ -407,6 +427,13 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
407 |
unset( $setting );
|
408 |
}
|
409 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
//Store the option in table
|
411 |
update_option( 'wp-smush-settings_updated', 1 );
|
412 |
|
@@ -449,7 +476,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
449 |
*/
|
450 |
function process_smush_request() {
|
451 |
|
452 |
-
global $WpSmush;
|
453 |
|
454 |
// turn off errors for ajax result
|
455 |
@error_reporting( 0 );
|
@@ -475,10 +502,29 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
475 |
);
|
476 |
}
|
477 |
|
|
|
|
|
478 |
$attachment_id = (int) ( $_REQUEST['attachment_id'] );
|
479 |
|
480 |
$original_meta = wp_get_attachment_metadata( $attachment_id, true );
|
481 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
$smush = $WpSmush->resize_from_meta_data( $original_meta, $attachment_id );
|
483 |
|
484 |
//Get the updated Global Stats
|
@@ -486,30 +532,36 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
486 |
|
487 |
$stats = $this->stats;
|
488 |
|
489 |
-
$stats['
|
490 |
|
491 |
-
if ( $
|
492 |
-
$stats['super_smushed'] = $this->super_smushed_count();
|
493 |
-
}
|
494 |
-
|
495 |
-
$stats['resmush_count'] = count( $this->resmush_ids );
|
496 |
|
497 |
-
|
498 |
|
499 |
-
if ( is_wp_error( $smush ) ) {
|
500 |
$error = $smush->get_error_message();
|
501 |
//Check for timeout error and suggest to filter timeout
|
502 |
if ( strpos( $error, 'timed out' ) ) {
|
503 |
$error = '<p class="wp-smush-error-message">' . esc_html__( "Smush request timed out, You can try setting a higher value for `WP_SMUSH_API_TIMEOUT`.", "wp-smushit" ) . '</p>';
|
504 |
}
|
505 |
-
wp_send_json_error( array( 'stats' => $stats, 'error_msg' => $error ) );
|
506 |
} else {
|
507 |
//Check if a resmush request, update the resmush list
|
508 |
if ( ! empty( $_REQUEST['is_bulk_resmush'] ) && 'false' != $_REQUEST['is_bulk_resmush'] && $_REQUEST['is_bulk_resmush'] ) {
|
509 |
$this->update_resmush_list( $attachment_id );
|
510 |
}
|
511 |
-
wp_send_json_success( array( 'stats' => $stats ) );
|
512 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
513 |
}
|
514 |
|
515 |
/**
|
@@ -518,6 +570,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
518 |
* @uses smush_single()
|
519 |
*/
|
520 |
function smush_manual() {
|
|
|
521 |
// turn off errors for ajax result
|
522 |
@error_reporting( 0 );
|
523 |
|
@@ -549,6 +602,14 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
549 |
|
550 |
$original_meta = wp_get_attachment_metadata( $attachment_id );
|
551 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
552 |
//Smush the image
|
553 |
$smush = $WpSmush->resize_from_meta_data( $original_meta, $attachment_id );
|
554 |
|
@@ -580,10 +641,10 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
580 |
*/
|
581 |
function check_bulk_limit( $reset = false ) {
|
582 |
|
583 |
-
$transient_name
|
584 |
|
585 |
//Do not go through this, if we need to reset
|
586 |
-
if(
|
587 |
$bulk_sent_count = get_transient( $transient_name );
|
588 |
|
589 |
//If bulk sent count is not set
|
@@ -609,7 +670,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
609 |
}
|
610 |
|
611 |
//Reset the transient
|
612 |
-
if( $reset ) {
|
613 |
//clear it and return false to stop the process
|
614 |
set_transient( $transient_name, 0, 60 );
|
615 |
|
@@ -617,79 +678,6 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
617 |
}
|
618 |
}
|
619 |
|
620 |
-
/**
|
621 |
-
* Total Image count
|
622 |
-
* @return int
|
623 |
-
*/
|
624 |
-
function total_count() {
|
625 |
-
|
626 |
-
//Don't query again, if the variable is already set
|
627 |
-
if ( ! empty( $this->total_count ) && $this->total_count > 0 ) {
|
628 |
-
return $this->total_count;
|
629 |
-
}
|
630 |
-
|
631 |
-
$query = array(
|
632 |
-
'fields' => 'ids',
|
633 |
-
'post_type' => 'attachment',
|
634 |
-
'post_status' => 'any',
|
635 |
-
'post_mime_type' => array( 'image/jpeg', 'image/gif', 'image/png' ),
|
636 |
-
'order' => 'ASC',
|
637 |
-
'posts_per_page' => - 1,
|
638 |
-
'no_found_rows' => true
|
639 |
-
);
|
640 |
-
//Remove the Filters added by WP Media Folder
|
641 |
-
$this->remove_wmf_filters();
|
642 |
-
|
643 |
-
$results = new WP_Query( $query );
|
644 |
-
$count = ! empty( $results->post_count ) ? $results->post_count : 0;
|
645 |
-
|
646 |
-
// send the count
|
647 |
-
return $count;
|
648 |
-
}
|
649 |
-
|
650 |
-
/**
|
651 |
-
* Optimised images count
|
652 |
-
*
|
653 |
-
* @param bool $return_ids
|
654 |
-
*
|
655 |
-
* @return array|int
|
656 |
-
*/
|
657 |
-
function smushed_count( $return_ids ) {
|
658 |
-
|
659 |
-
//Don't query again, if the variable is already set
|
660 |
-
if ( ! $return_ids && ! empty( $this->smushed_count ) && $this->smushed_count > 0 ) {
|
661 |
-
return $this->smushed_count;
|
662 |
-
}
|
663 |
-
|
664 |
-
$query = array(
|
665 |
-
'fields' => 'ids',
|
666 |
-
'post_type' => 'attachment',
|
667 |
-
'post_status' => 'any',
|
668 |
-
'post_mime_type' => array( 'image/jpeg', 'image/gif', 'image/png' ),
|
669 |
-
'order' => 'ASC',
|
670 |
-
'posts_per_page' => - 1,
|
671 |
-
'meta_key' => 'wp-smpro-smush-data',
|
672 |
-
'no_found_rows' => true
|
673 |
-
);
|
674 |
-
|
675 |
-
//Remove the Filters added by WP Media Folder
|
676 |
-
$this->remove_wmf_filters();
|
677 |
-
|
678 |
-
$results = new WP_Query( $query );
|
679 |
-
|
680 |
-
if ( ! is_wp_error( $results ) && $results->post_count > 0 ) {
|
681 |
-
if ( ! $return_ids ) {
|
682 |
-
//return Post Count
|
683 |
-
return $results->post_count;
|
684 |
-
} else {
|
685 |
-
//Return post ids
|
686 |
-
return $results->posts;
|
687 |
-
}
|
688 |
-
} else {
|
689 |
-
return false;
|
690 |
-
}
|
691 |
-
}
|
692 |
-
|
693 |
/**
|
694 |
* Returns remaining count
|
695 |
*
|
@@ -774,7 +762,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
774 |
}
|
775 |
}
|
776 |
|
777 |
-
global $wpdb, $WpSmush;
|
778 |
|
779 |
$smush_data = array(
|
780 |
'size_before' => 0,
|
@@ -787,8 +775,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
787 |
* Allows to set a limit of mysql query
|
788 |
* Default value is 2000
|
789 |
*/
|
790 |
-
$limit =
|
791 |
-
$limit = intval( $limit );
|
792 |
$offset = 0;
|
793 |
$query_next = true;
|
794 |
|
@@ -798,10 +785,12 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
798 |
|
799 |
if ( ! empty( $global_data ) ) {
|
800 |
$smush_data['count'] = 0;
|
|
|
801 |
foreach ( $global_data as $data ) {
|
802 |
$data = maybe_unserialize( $data );
|
803 |
if ( ! empty( $data['stats'] ) ) {
|
804 |
$smush_data['count'] += 1;
|
|
|
805 |
$smush_data['size_before'] += ! empty( $data['stats']['size_before'] ) ? (int) $data['stats']['size_before'] : 0;
|
806 |
$smush_data['size_after'] += ! empty( $data['stats']['size_after'] ) ? (int) $data['stats']['size_after'] : 0;
|
807 |
}
|
@@ -823,10 +812,23 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
823 |
|
824 |
}
|
825 |
|
|
|
|
|
|
|
|
|
826 |
if ( ! isset( $smush_data['bytes'] ) || $smush_data['bytes'] < 0 ) {
|
827 |
$smush_data['bytes'] = 0;
|
828 |
}
|
829 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
830 |
if ( $smush_data['size_before'] > 0 ) {
|
831 |
$smush_data['percent'] = ( $smush_data['bytes'] / $smush_data['size_before'] ) * 100;
|
832 |
}
|
@@ -932,8 +934,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
932 |
//Return if notice is already dismissed
|
933 |
if ( get_option( 'wp-smush-hide_upgrade_notice' ) || get_site_option( 'wp-smush-hide_upgrade_notice' ) ) {
|
934 |
return;
|
935 |
-
}
|
936 |
-
<div class="wpmud wp-smush-updated"><?php
|
937 |
|
938 |
$install_type = get_site_option( 'wp-smush-install-type', false );
|
939 |
|
@@ -946,14 +947,8 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
946 |
update_site_option( 'wp-smush-install-type', $install_type );
|
947 |
}
|
948 |
|
949 |
-
//Whether New/Existing Installation
|
950 |
-
$box_heading = 'existing' == $install_type ? esc_html__( "THANKS FOR UPDATING SMUSH!", "wp-smushit" ) : esc_html__( "HAPPY SMUSHING!", "wp-smushit" );
|
951 |
-
|
952 |
//Container Header
|
953 |
-
echo $this->bulk_ui->container_header( 'wp-smush-install-thanks-box', 'wp-smush-install-thanks', $box_heading, '', true );
|
954 |
echo $this->bulk_ui->installation_notice();
|
955 |
-
?>
|
956 |
-
</div><?php
|
957 |
}
|
958 |
|
959 |
/**
|
@@ -965,32 +960,31 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
965 |
*/
|
966 |
function get_smushed_attachments() {
|
967 |
|
968 |
-
global $wpdb;
|
969 |
|
970 |
$allowed_images = "( 'image/jpeg', 'image/jpg', 'image/png' )";
|
971 |
|
972 |
-
$limit =
|
973 |
-
$limit = intval( $limit );
|
974 |
$offset = 0;
|
975 |
$query_next = true;
|
976 |
|
977 |
while ( $query_next ) {
|
978 |
// get the attachment id, smush data
|
979 |
-
$sql
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
$results = $wpdb->get_results( $sql );
|
990 |
|
991 |
//Update the offset
|
992 |
$offset += $limit;
|
993 |
-
if ( $
|
994 |
$query_next = false;
|
995 |
} else if ( ! $results || empty( $results ) ) {
|
996 |
$query_next = false;
|
@@ -1000,80 +994,6 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
1000 |
return $results;
|
1001 |
}
|
1002 |
|
1003 |
-
/**
|
1004 |
-
* Returns the ids and meta which are losslessly compressed
|
1005 |
-
*
|
1006 |
-
* @return array
|
1007 |
-
*/
|
1008 |
-
function get_lossy_attachments( $attachments = '', $return_count = true ) {
|
1009 |
-
|
1010 |
-
$lossy_attachments = array();
|
1011 |
-
$count = 0;
|
1012 |
-
|
1013 |
-
if ( empty( $attachments ) ) {
|
1014 |
-
//Fetch all the smushed attachment ids
|
1015 |
-
$attachments = $this->get_smushed_attachments();
|
1016 |
-
}
|
1017 |
-
|
1018 |
-
//If we dont' have any attachments
|
1019 |
-
if ( empty( $attachments ) || 0 == count( $attachments ) ) {
|
1020 |
-
return 0;
|
1021 |
-
}
|
1022 |
-
|
1023 |
-
//Check if image is lossless or lossy
|
1024 |
-
foreach ( $attachments as $attachment ) {
|
1025 |
-
|
1026 |
-
//Check meta for lossy value
|
1027 |
-
$smush_data = ! empty( $attachment->smush_data ) ? maybe_unserialize( $attachment->smush_data ) : '';
|
1028 |
-
|
1029 |
-
//For Nextgen Gallery images
|
1030 |
-
if ( empty( $smush_data ) && is_array( $attachment ) && ! empty( $attachment['wp_smush'] ) ) {
|
1031 |
-
$smush_data = ! empty( $attachment['wp_smush'] ) ? $attachment['wp_smush'] : '';
|
1032 |
-
}
|
1033 |
-
|
1034 |
-
//Return if not smushed
|
1035 |
-
if ( empty( $smush_data ) ) {
|
1036 |
-
continue;
|
1037 |
-
}
|
1038 |
-
|
1039 |
-
//if stats not set or lossy is not set for attachment, return
|
1040 |
-
if ( empty( $smush_data['stats'] ) || ! isset( $smush_data['stats']['lossy'] ) ) {
|
1041 |
-
continue;
|
1042 |
-
}
|
1043 |
-
|
1044 |
-
//Add to array if lossy is not 1
|
1045 |
-
if ( 1 == $smush_data['stats']['lossy'] ) {
|
1046 |
-
$count ++;
|
1047 |
-
if ( ! empty( $attachment->attachment_id ) ) {
|
1048 |
-
$lossy_attachments[] = $attachment->attachment_id;
|
1049 |
-
} elseif ( is_array( $attachment ) && ! empty( $attachment['pid'] ) ) {
|
1050 |
-
$lossy_attachments[] = $attachment['pid'];
|
1051 |
-
}
|
1052 |
-
}
|
1053 |
-
}
|
1054 |
-
unset( $attachments );
|
1055 |
-
|
1056 |
-
if ( $return_count ) {
|
1057 |
-
return $count;
|
1058 |
-
}
|
1059 |
-
|
1060 |
-
return $lossy_attachments;
|
1061 |
-
}
|
1062 |
-
|
1063 |
-
/**
|
1064 |
-
* Remove any pre_get_posts_filters added by WP Media Folder plugin
|
1065 |
-
*/
|
1066 |
-
function remove_wmf_filters() {
|
1067 |
-
//remove any filters added b WP media Folder plugin to get the all attachments
|
1068 |
-
if ( class_exists( 'Wp_Media_Folder' ) ) {
|
1069 |
-
global $wp_media_folder;
|
1070 |
-
if ( is_object( $wp_media_folder ) ) {
|
1071 |
-
remove_filter( 'pre_get_posts', array( $wp_media_folder, 'wpmf_pre_get_posts1' ) );
|
1072 |
-
remove_filter( 'pre_get_posts', array( $wp_media_folder, 'wpmf_pre_get_posts' ), 0, 1 );
|
1073 |
-
}
|
1074 |
-
}
|
1075 |
-
}
|
1076 |
-
|
1077 |
/**
|
1078 |
* Store a key/value to hide the smush features on bulk page
|
1079 |
*/
|
@@ -1093,12 +1013,37 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
1093 |
}
|
1094 |
}
|
1095 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1096 |
/**
|
1097 |
* Restore the image and its sizes from backup
|
1098 |
*/
|
1099 |
function restore_image( $attachment = '', $resp = true ) {
|
1100 |
|
1101 |
-
if( empty( $attachment ) ) {
|
1102 |
//Check Empty fields
|
1103 |
if ( empty( $_POST['attachment_id'] ) || empty( $_POST['_nonce'] ) ) {
|
1104 |
wp_send_json_error( array(
|
@@ -1177,15 +1122,16 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
1177 |
//Get the Button html without wrapper
|
1178 |
$button_html = $this->set_status( $image_id, false, false, false );
|
1179 |
|
1180 |
-
if( $resp ) {
|
1181 |
wp_send_json_success( array( 'button' => $button_html ) );
|
1182 |
-
}else{
|
1183 |
return true;
|
1184 |
}
|
1185 |
}
|
1186 |
-
if( $resp ) {
|
1187 |
wp_send_json_error( array( 'message' => '<div class="wp-smush-error">' . __( "Unable to restore image", "wp-smushit" ) . '</div>' ) );
|
1188 |
}
|
|
|
1189 |
return false;
|
1190 |
}
|
1191 |
|
@@ -1236,7 +1182,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
1236 |
*/
|
1237 |
function scan_images() {
|
1238 |
|
1239 |
-
global $WpSmush, $wpsmushnextgenadmin;
|
1240 |
|
1241 |
check_ajax_referer( 'save_wp_smush_options', 'wp_smush_options_nonce' );
|
1242 |
|
@@ -1245,7 +1191,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
1245 |
//Default Notice, to be displayed at the top of page
|
1246 |
//Show a message, at the top
|
1247 |
$message = esc_html__( 'Yay! All images are optimised as per your current settings.', 'wp-smushit' );
|
1248 |
-
$resp
|
1249 |
<i class="dev-icon dev-icon-cross"></i>
|
1250 |
</div>';
|
1251 |
|
@@ -1292,7 +1238,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
1292 |
if ( 'nextgen' != $type ) {
|
1293 |
|
1294 |
//Get list of Smushed images
|
1295 |
-
$attachments = $this->smushed_count( true );
|
1296 |
} else {
|
1297 |
global $wpsmushnextgenstats;
|
1298 |
|
@@ -1370,6 +1316,11 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
1370 |
if ( 'nextgen' != $type ) {
|
1371 |
//Set the variables
|
1372 |
$this->resmush_ids = $resmush_list;
|
|
|
|
|
|
|
|
|
|
|
1373 |
} else {
|
1374 |
//To avoid the php warning
|
1375 |
$wpsmushnextgenadmin->resmush_ids = $resmush_list;
|
@@ -1387,7 +1338,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
1387 |
}
|
1388 |
}
|
1389 |
|
1390 |
-
if( !empty( $resmush_list ) || $remaining_count > 0 ) {
|
1391 |
$message = sprintf( esc_html__( "You have images that need smushing. %sBulk smush now!%s", "wp-smushit" ), '<a href="#" class="wp-smush-trigger-bulk">', '</a>' );
|
1392 |
$resp = '<div class="wp-smush-notice wp-smush-resmush-message wp-smush-resmush-pending" tabindex="0"><i class="dev-icon dev-icon-tick"></i> ' . $message . '
|
1393 |
<i class="dev-icon dev-icon-cross"></i>
|
@@ -1399,7 +1350,18 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
1399 |
"resmush_ids" => $resmush_list,
|
1400 |
"content" => $ajax_response
|
1401 |
) : '';
|
1402 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1403 |
|
1404 |
wp_send_json_success( $return );
|
1405 |
|
@@ -1446,7 +1408,7 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
1446 |
'fields' => 'ids',
|
1447 |
'post_type' => 'attachment',
|
1448 |
'post_status' => 'any',
|
1449 |
-
'post_mime_type' =>
|
1450 |
'order' => 'ASC',
|
1451 |
'posts_per_page' => - 1,
|
1452 |
'meta_key' => 'upfront_used_image_sizes',
|
@@ -1494,79 +1456,6 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
1494 |
}
|
1495 |
}
|
1496 |
|
1497 |
-
/**
|
1498 |
-
* Returns/Updates the number of images Super Smushed
|
1499 |
-
*
|
1500 |
-
* @param string $type media/nextgen, Type of images to get/set the super smushed count for
|
1501 |
-
*
|
1502 |
-
* @param array $attachments Optional, By default Media attachments will be fetched
|
1503 |
-
*
|
1504 |
-
* @return array|mixed|void
|
1505 |
-
*
|
1506 |
-
*/
|
1507 |
-
function super_smushed_count( $type = 'media', $attachments = '' ) {
|
1508 |
-
|
1509 |
-
if ( 'media' == $type ) {
|
1510 |
-
$count = $this->media_super_smush_count();
|
1511 |
-
} else {
|
1512 |
-
$key = 'wp-smush-super_smushed_nextgen';
|
1513 |
-
|
1514 |
-
//Flag to check if we need to re-evaluate the count
|
1515 |
-
$revaluate = false;
|
1516 |
-
|
1517 |
-
$super_smushed = get_option( $key, false );
|
1518 |
-
|
1519 |
-
//Check if need to revalidate
|
1520 |
-
if ( ! $super_smushed || empty( $super_smushed ) || empty( $super_smushed['ids'] ) ) {
|
1521 |
-
|
1522 |
-
$super_smushed = array(
|
1523 |
-
'ids' => array()
|
1524 |
-
);
|
1525 |
-
|
1526 |
-
$revaluate = true;
|
1527 |
-
} else {
|
1528 |
-
$last_checked = $super_smushed['timestamp'];
|
1529 |
-
|
1530 |
-
$diff = $last_checked - current_time( 'timestamp' );
|
1531 |
-
|
1532 |
-
//Difference in hour
|
1533 |
-
$diff_h = $diff / 3600;
|
1534 |
-
|
1535 |
-
//if last checked was more than 1 hours.
|
1536 |
-
if ( $diff_h > 1 ) {
|
1537 |
-
$revaluate = true;
|
1538 |
-
}
|
1539 |
-
}
|
1540 |
-
//Do not Revaluate stats if nextgen attachments are not provided
|
1541 |
-
if ( 'nextgen' == $type && empty( $attachments ) && $revaluate ) {
|
1542 |
-
$revaluate = false;
|
1543 |
-
}
|
1544 |
-
|
1545 |
-
//Need to scan all the image
|
1546 |
-
if ( $revaluate ) {
|
1547 |
-
//Get all the Smushed attachments ids
|
1548 |
-
$super_smushed_images = $this->get_lossy_attachments( $attachments, false );
|
1549 |
-
|
1550 |
-
if ( ! empty( $super_smushed_images ) && is_array( $super_smushed_images ) ) {
|
1551 |
-
//Iterate over all the attachments to check if it's already there in list, else add it
|
1552 |
-
foreach ( $super_smushed_images as $id ) {
|
1553 |
-
if ( ! in_array( $id, $super_smushed['ids'] ) ) {
|
1554 |
-
$super_smushed['ids'][] = $id;
|
1555 |
-
}
|
1556 |
-
}
|
1557 |
-
}
|
1558 |
-
|
1559 |
-
$super_smushed['timestamp'] = current_time( 'timestamp' );
|
1560 |
-
|
1561 |
-
update_option( $key, $super_smushed );
|
1562 |
-
}
|
1563 |
-
|
1564 |
-
$count = ! empty( $super_smushed['ids'] ) ? count( $super_smushed['ids'] ) : 0;
|
1565 |
-
}
|
1566 |
-
|
1567 |
-
return $count;
|
1568 |
-
}
|
1569 |
-
|
1570 |
/**
|
1571 |
* Add/Remove image id from Super Smushed images count
|
1572 |
*
|
@@ -1658,88 +1547,20 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
1658 |
wp_send_json_success();
|
1659 |
}
|
1660 |
|
1661 |
-
/**
|
1662 |
-
* Updates the Meta for existing smushed images and retrieves the count of Super Smushed images
|
1663 |
-
*
|
1664 |
-
* @return int Count of Super Smushed images
|
1665 |
-
*
|
1666 |
-
*/
|
1667 |
-
function media_super_smush_count() {
|
1668 |
-
//Check if we have updated the stats for existing images, One time
|
1669 |
-
if ( ! get_option( 'wp-smush-lossy-updated' ) ) {
|
1670 |
-
|
1671 |
-
//Get all the smushed attachments
|
1672 |
-
$attachments = $this->get_lossy_attachments( '', false );
|
1673 |
-
if( !empty( $attachments ) ) {
|
1674 |
-
foreach ( $attachments as $attachment ) {
|
1675 |
-
update_post_meta( $attachment, 'wp-smush-lossy', 1 );
|
1676 |
-
}
|
1677 |
-
}
|
1678 |
-
}
|
1679 |
-
//Get all the attachments with wp-smush-lossy
|
1680 |
-
$limit = apply_filters( 'wp_smush_query_limit', 2000 );
|
1681 |
-
$limit = intval( $limit );
|
1682 |
-
$get_posts = true;
|
1683 |
-
$super_smushed = array();
|
1684 |
-
$args = array(
|
1685 |
-
'fields' => 'ids',
|
1686 |
-
'post_type' => 'attachment',
|
1687 |
-
'post_status' => 'any',
|
1688 |
-
'post_mime_type' => array( 'image/jpeg', 'image/gif', 'image/png' ),
|
1689 |
-
'orderby' => 'ID',
|
1690 |
-
'order' => 'DESC',
|
1691 |
-
'posts_per_page' => $limit,
|
1692 |
-
'offset' => 0,
|
1693 |
-
'meta_query' => array(
|
1694 |
-
array(
|
1695 |
-
'key' => 'wp-smush-lossy',
|
1696 |
-
'value' => 1
|
1697 |
-
)
|
1698 |
-
),
|
1699 |
-
'update_post_term_cache' => false,
|
1700 |
-
'no_found_rows' => true,
|
1701 |
-
);
|
1702 |
-
//Loop Over to get all the attachments
|
1703 |
-
while ( $get_posts ) {
|
1704 |
-
|
1705 |
-
//Remove the Filters added by WP Media Folder
|
1706 |
-
$this->remove_wmf_filters();
|
1707 |
-
|
1708 |
-
$query = new WP_Query( $args );
|
1709 |
-
|
1710 |
-
if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
|
1711 |
-
//Merge the results
|
1712 |
-
$super_smushed = array_merge( $super_smushed, $query->posts );
|
1713 |
-
|
1714 |
-
//Update the offset
|
1715 |
-
$args['offset'] += $limit;
|
1716 |
-
} else {
|
1717 |
-
//If we didn't get any posts from query, set $get_posts to false
|
1718 |
-
$get_posts = false;
|
1719 |
-
}
|
1720 |
-
|
1721 |
-
//If total Count is set, and it is alread lesser than offset, don't query
|
1722 |
-
if ( ! empty( $this->total_count ) && $this->total_count < $args['offset'] ) {
|
1723 |
-
$get_posts = false;
|
1724 |
-
}
|
1725 |
-
}
|
1726 |
-
update_option( 'wp-smush-lossy-updated', true );
|
1727 |
-
|
1728 |
-
return count( $super_smushed );
|
1729 |
-
}
|
1730 |
-
|
1731 |
/**
|
1732 |
* Allows to bulk restore the images, if there is any backup for them
|
1733 |
*/
|
1734 |
function bulk_restore() {
|
1735 |
-
|
1736 |
-
|
|
|
1737 |
$this->restore_image( $attachment->attachment_id, false );
|
1738 |
}
|
1739 |
}
|
1740 |
|
1741 |
/**
|
1742 |
* Loads the Shared UI to on all admin pages
|
|
|
1743 |
* @param $current_page
|
1744 |
*/
|
1745 |
function load_shared_ui( $current_page ) {
|
@@ -1764,6 +1585,145 @@ if ( ! class_exists( 'WpSmushitAdmin' ) ) {
|
|
1764 |
}
|
1765 |
}
|
1766 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1767 |
}
|
1768 |
|
1769 |
global $wpsmushit_admin;
|
9 |
*
|
10 |
* @copyright (c) 2016, Incsub (http://incsub.com)
|
11 |
*/
|
12 |
+
|
13 |
//Include Bulk UI
|
14 |
require_once WP_SMUSH_DIR . 'lib/class-wp-smush-ui.php';
|
15 |
|
61 |
*/
|
62 |
public $super_smushed;
|
63 |
|
64 |
+
public $smushed_attachments = array();
|
65 |
+
|
66 |
+
public $mime_types = array( 'image/jpg', 'image/jpeg', 'image/gif', 'image/png' );
|
67 |
+
|
68 |
/**
|
69 |
* @array Stores the stats for all the images
|
70 |
*/
|
97 |
*/
|
98 |
public function __construct() {
|
99 |
|
|
|
|
|
|
|
100 |
// hook scripts and styles
|
101 |
add_action( 'admin_init', array( $this, 'register' ) );
|
102 |
|
129 |
//Attachment status, Grid view
|
130 |
add_filter( 'attachment_fields_to_edit', array( $this, 'filter_attachment_fields_to_edit' ), 10, 2 );
|
131 |
|
132 |
+
// Smush Upgrade
|
133 |
add_action( 'admin_notices', array( $this, 'smush_upgrade' ) );
|
134 |
|
135 |
+
// New Features Notice
|
136 |
+
add_action( 'admin_notices', array( $this, 'smush_updated' ) );
|
137 |
+
|
138 |
//Handle the smush pro dismiss features notice ajax
|
139 |
add_action( 'wp_ajax_dismiss_upgrade_notice', array( $this, 'dismiss_upgrade_notice' ) );
|
140 |
|
141 |
//Handle the smush pro dismiss features notice ajax
|
142 |
add_action( 'wp_ajax_dismiss_welcome_notice', array( $this, 'dismiss_welcome_notice' ) );
|
143 |
|
144 |
+
//Handle the smush pro dismiss features notice ajax
|
145 |
+
add_action( 'wp_ajax_dismiss_update_info', array( $this, 'dismiss_update_info' ) );
|
146 |
+
|
147 |
//Update the Super Smush count, after the smushing
|
148 |
add_action( 'wp_smush_image_optimised', array( $this, 'update_lists' ), '', 2 );
|
149 |
|
166 |
'label' => esc_html__( 'Preserve image EXIF data', 'wp-smushit' ),
|
167 |
'desc' => esc_html__( 'EXIF data stores camera settings, focal length, date, time and location information in image files. EXIF data makes image files larger but if you are a photographer you may want to preserve this information.', 'wp-smushit' )
|
168 |
),
|
169 |
+
'resize' => array(
|
170 |
+
'label' => esc_html__( 'Resize original images', 'wp-smushit' ),
|
171 |
+
'desc' => esc_html__( 'Save a ton of space by not storing over-sized images on your server. Set image maximum width and height and large images will be automatically scaled before being added to the media library. ', 'wp-smushit' )
|
172 |
+
),
|
173 |
'lossy' => array(
|
174 |
'label' => esc_html__( 'Super-smush my images', 'wp-smushit' ),
|
175 |
'desc' => esc_html__( 'Compress images up to 10x more than regular smush with almost no visible drop in quality.', 'wp-smushit' )
|
246 |
|
247 |
/* Register Style. */
|
248 |
wp_register_style( 'wp-smushit-admin-css', WP_SMUSH_URL . 'assets/css/wp-smushit-admin.css', array(), $WpSmush->version );
|
249 |
+
|
250 |
+
//Dismiss Update Info
|
251 |
+
$this->dismiss_update_info();
|
252 |
}
|
253 |
|
254 |
/**
|
267 |
$enqueue_smush = apply_filters( 'wp_smush_enqueue', true );
|
268 |
|
269 |
//If we upgrade/install message is dismissed and for pro users
|
270 |
+
if ( get_option( 'wp-smush-hide_upgrade_notice' ) || get_site_option( 'wp-smush-hide_upgrade_notice' ) || $this->is_pro() ) {
|
271 |
//Do not enqueue, unless it is one of the required screen
|
272 |
if ( ! $enqueue_smush || ( $current_page != 'nggallery-manage-images' && $current_page != 'gallery_page_wp-smush-nextgen-bulk' && $pagenow != 'post.php' && $pagenow != 'post-new.php' && $pagenow != 'upload.php' ) ) {
|
273 |
|
300 |
*/
|
301 |
function localize() {
|
302 |
global $current_screen;
|
303 |
+
$current_page = ! empty( $current_screen ) ? $current_screen->base : '';
|
304 |
|
305 |
$bulk = new WpSmushitBulk();
|
306 |
$handle = 'wp-smushit-admin-js';
|
312 |
'all_resmushed' => esc_html__( 'All images are fully optimised.', 'wp-smushit' ),
|
313 |
'restore' => esc_html__( "Restoring image..", "wp-smushit" ),
|
314 |
'smushing' => esc_html__( "Smushing image..", "wp-smushit" ),
|
315 |
+
'checking' => esc_html__( "Checking images..", "wp-smushit" ),
|
316 |
);
|
317 |
|
318 |
wp_localize_script( $handle, 'wp_smush_msgs', $wp_smush_msgs );
|
320 |
//Load the stats on selected screens only
|
321 |
if ( $current_page == 'media_page_wp-smush-bulk' ) {
|
322 |
|
|
|
|
|
323 |
//Setup all the stats
|
324 |
$this->setup_global_stats();
|
325 |
|
326 |
+
//Get attachments if all the images are not smushed
|
327 |
+
$this->attachments = $this->remaining_count > 0 ? $bulk->get_attachments() : array();
|
328 |
+
|
329 |
//Localize smushit_ids variable, if there are fix number of ids
|
330 |
$this->ids = ! empty( $_REQUEST['ids'] ) ? array_map( 'intval', explode( ',', $_REQUEST['ids'] ) ) : $this->attachments;
|
331 |
|
344 |
'unsmushed' => $this->ids,
|
345 |
'resmush' => $this->resmush_ids,
|
346 |
);
|
347 |
+
} else {
|
348 |
$data = array(
|
349 |
'count_smushed' => '',
|
350 |
'count_total' => '',
|
354 |
|
355 |
}
|
356 |
|
357 |
+
$data['resize_sizes'] = $this->get_max_image_dimensions();
|
358 |
+
|
359 |
$data['timeout'] = WP_SMUSH_TIMEOUT * 1000; //Convert it into ms
|
360 |
|
361 |
wp_localize_script( 'wp-smushit-admin-js', 'wp_smushit_data', $data );
|
370 |
*
|
371 |
*/
|
372 |
function setup_global_stats( $force_update = false ) {
|
373 |
+
global $wpsmush_stats;
|
374 |
+
$this->total_count = $wpsmush_stats->total_count();
|
375 |
+
$this->smushed_attachments = $wpsmush_stats->smushed_count( true );
|
376 |
+
$this->smushed_count = !empty( $this->smushed_attachments ) ? count( $this->smushed_attachments ) : 0;
|
377 |
+
$this->remaining_count = $this->remaining_count();
|
378 |
+
$this->stats = $this->global_stats( $force_update );
|
379 |
}
|
380 |
|
381 |
/**
|
427 |
unset( $setting );
|
428 |
}
|
429 |
|
430 |
+
//Update Resize width and height settings if set
|
431 |
+
$resize_sizes['width'] = isset( $_POST['wp-smush-resize_width'] ) ? intval( $_POST['wp-smush-resize_width'] ) : 0;
|
432 |
+
$resize_sizes['height'] = isset( $_POST['wp-smush-resize_height'] ) ? intval( $_POST['wp-smush-resize_height'] ) : 0;
|
433 |
+
|
434 |
+
// update the resize sizes
|
435 |
+
update_option( WP_SMUSH_PREFIX . 'resize_sizes', $resize_sizes );
|
436 |
+
|
437 |
//Store the option in table
|
438 |
update_option( 'wp-smush-settings_updated', 1 );
|
439 |
|
476 |
*/
|
477 |
function process_smush_request() {
|
478 |
|
479 |
+
global $WpSmush, $wpsmush_stats;
|
480 |
|
481 |
// turn off errors for ajax result
|
482 |
@error_reporting( 0 );
|
502 |
);
|
503 |
}
|
504 |
|
505 |
+
$send_error = false;
|
506 |
+
|
507 |
$attachment_id = (int) ( $_REQUEST['attachment_id'] );
|
508 |
|
509 |
$original_meta = wp_get_attachment_metadata( $attachment_id, true );
|
510 |
|
511 |
+
//Resize the dimensions of the image
|
512 |
+
/**
|
513 |
+
* Filter whether the existing image should be resized or not
|
514 |
+
*
|
515 |
+
* @since 2.3
|
516 |
+
*
|
517 |
+
* @param bool $should_resize , Set to True by default
|
518 |
+
*
|
519 |
+
* @param $attachment_id Image Attachment ID
|
520 |
+
*
|
521 |
+
*/
|
522 |
+
if ( $should_resize = apply_filters( 'wp_smush_resize_media_image', true, $attachment_id ) ) {
|
523 |
+
$updated_meta = $this->resize_image( $attachment_id, $original_meta );
|
524 |
+
$original_meta = ! empty( $updated_meta ) ? $updated_meta : $original_meta;
|
525 |
+
wp_update_attachment_metadata( $attachment_id, $original_meta );
|
526 |
+
}
|
527 |
+
|
528 |
$smush = $WpSmush->resize_from_meta_data( $original_meta, $attachment_id );
|
529 |
|
530 |
//Get the updated Global Stats
|
532 |
|
533 |
$stats = $this->stats;
|
534 |
|
535 |
+
$stats['total'] = $wpsmush_stats->total_count();
|
536 |
|
537 |
+
if ( is_wp_error( $smush ) ) {
|
|
|
|
|
|
|
|
|
538 |
|
539 |
+
$send_error = true;
|
540 |
|
|
|
541 |
$error = $smush->get_error_message();
|
542 |
//Check for timeout error and suggest to filter timeout
|
543 |
if ( strpos( $error, 'timed out' ) ) {
|
544 |
$error = '<p class="wp-smush-error-message">' . esc_html__( "Smush request timed out, You can try setting a higher value for `WP_SMUSH_API_TIMEOUT`.", "wp-smushit" ) . '</p>';
|
545 |
}
|
|
|
546 |
} else {
|
547 |
//Check if a resmush request, update the resmush list
|
548 |
if ( ! empty( $_REQUEST['is_bulk_resmush'] ) && 'false' != $_REQUEST['is_bulk_resmush'] && $_REQUEST['is_bulk_resmush'] ) {
|
549 |
$this->update_resmush_list( $attachment_id );
|
550 |
}
|
|
|
551 |
}
|
552 |
+
$resmush_count = empty( $this->resmush_ids ) ? count( $this->resmush_ids = get_option( "wp-smush-resmush-list" ) ) : count( $this->resmush_ids );
|
553 |
+
|
554 |
+
$stats['smushed'] = !empty( $this->resmush_ids ) ? $this->smushed_count - $resmush_count : $this->smushed_count;
|
555 |
+
|
556 |
+
if ( $WpSmush->lossy_enabled ) {
|
557 |
+
$stats['super_smushed'] = $wpsmush_stats->super_smushed_count();
|
558 |
+
}
|
559 |
+
|
560 |
+
$stats['tooltip_text'] = ! empty( $stats['total_images'] ) ? sprintf( esc_html__( "%d images", "wp-smushit" ), $stats['total_images'] ) : '';
|
561 |
+
|
562 |
+
//Send ajax response
|
563 |
+
$send_error ? wp_send_json_error( array( 'stats' => $stats, 'error_msg' => $error ) ) : wp_send_json_success( array( 'stats' => $stats ) );
|
564 |
+
|
565 |
}
|
566 |
|
567 |
/**
|
570 |
* @uses smush_single()
|
571 |
*/
|
572 |
function smush_manual() {
|
573 |
+
|
574 |
// turn off errors for ajax result
|
575 |
@error_reporting( 0 );
|
576 |
|
602 |
|
603 |
$original_meta = wp_get_attachment_metadata( $attachment_id );
|
604 |
|
605 |
+
//Send image for resizing
|
606 |
+
$updated_meta = $this->resize_image( $attachment_id, $original_meta );
|
607 |
+
|
608 |
+
$original_meta = ! empty( $updated_meta ) ? $updated_meta : $original_meta;
|
609 |
+
|
610 |
+
//Update the details, as soon as we are done with resizing
|
611 |
+
wp_update_attachment_metadata( $attachment_id, $original_meta );
|
612 |
+
|
613 |
//Smush the image
|
614 |
$smush = $WpSmush->resize_from_meta_data( $original_meta, $attachment_id );
|
615 |
|
641 |
*/
|
642 |
function check_bulk_limit( $reset = false ) {
|
643 |
|
644 |
+
$transient_name = WP_SMUSH_PREFIX . 'bulk_sent_count';
|
645 |
|
646 |
//Do not go through this, if we need to reset
|
647 |
+
if ( ! $reset ) {
|
648 |
$bulk_sent_count = get_transient( $transient_name );
|
649 |
|
650 |
//If bulk sent count is not set
|
670 |
}
|
671 |
|
672 |
//Reset the transient
|
673 |
+
if ( $reset ) {
|
674 |
//clear it and return false to stop the process
|
675 |
set_transient( $transient_name, 0, 60 );
|
676 |
|
678 |
}
|
679 |
}
|
680 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
681 |
/**
|
682 |
* Returns remaining count
|
683 |
*
|
762 |
}
|
763 |
}
|
764 |
|
765 |
+
global $wpdb, $WpSmush, $wpsmush_stats;
|
766 |
|
767 |
$smush_data = array(
|
768 |
'size_before' => 0,
|
775 |
* Allows to set a limit of mysql query
|
776 |
* Default value is 2000
|
777 |
*/
|
778 |
+
$limit = $this->query_limit();
|
|
|
779 |
$offset = 0;
|
780 |
$query_next = true;
|
781 |
|
785 |
|
786 |
if ( ! empty( $global_data ) ) {
|
787 |
$smush_data['count'] = 0;
|
788 |
+
$smush_data['total_images'] = 0;
|
789 |
foreach ( $global_data as $data ) {
|
790 |
$data = maybe_unserialize( $data );
|
791 |
if ( ! empty( $data['stats'] ) ) {
|
792 |
$smush_data['count'] += 1;
|
793 |
+
$smush_data['total_images'] += ! empty( $data['sizes'] ) ? count( $data['sizes'] ) : 0;
|
794 |
$smush_data['size_before'] += ! empty( $data['stats']['size_before'] ) ? (int) $data['stats']['size_before'] : 0;
|
795 |
$smush_data['size_after'] += ! empty( $data['stats']['size_after'] ) ? (int) $data['stats']['size_after'] : 0;
|
796 |
}
|
812 |
|
813 |
}
|
814 |
|
815 |
+
$resize_savings = $wpsmush_stats->resize_savings( false );
|
816 |
+
|
817 |
+
$smush_data['resize_savings'] = ! empty( $resize_savings['bytes'] ) ? $resize_savings['bytes'] : 0;
|
818 |
+
|
819 |
if ( ! isset( $smush_data['bytes'] ) || $smush_data['bytes'] < 0 ) {
|
820 |
$smush_data['bytes'] = 0;
|
821 |
}
|
822 |
|
823 |
+
//Add the resize savings to bytes
|
824 |
+
$smush_data['bytes'] += $smush_data['resize_savings'];
|
825 |
+
$smush_data['size_before'] += $resize_savings['size_before'];
|
826 |
+
$smush_data['size_after'] += $resize_savings['size_after'];
|
827 |
+
|
828 |
+
//Add the size before and after
|
829 |
+
|
830 |
+
$smush_data['resize_savings'] = $this->format_bytes( $smush_data['resize_savings'] );
|
831 |
+
|
832 |
if ( $smush_data['size_before'] > 0 ) {
|
833 |
$smush_data['percent'] = ( $smush_data['bytes'] / $smush_data['size_before'] ) * 100;
|
834 |
}
|
934 |
//Return if notice is already dismissed
|
935 |
if ( get_option( 'wp-smush-hide_upgrade_notice' ) || get_site_option( 'wp-smush-hide_upgrade_notice' ) ) {
|
936 |
return;
|
937 |
+
}
|
|
|
938 |
|
939 |
$install_type = get_site_option( 'wp-smush-install-type', false );
|
940 |
|
947 |
update_site_option( 'wp-smush-install-type', $install_type );
|
948 |
}
|
949 |
|
|
|
|
|
|
|
950 |
//Container Header
|
|
|
951 |
echo $this->bulk_ui->installation_notice();
|
|
|
|
|
952 |
}
|
953 |
|
954 |
/**
|
960 |
*/
|
961 |
function get_smushed_attachments() {
|
962 |
|
963 |
+
global $wpdb, $wpsmush_stats;
|
964 |
|
965 |
$allowed_images = "( 'image/jpeg', 'image/jpg', 'image/png' )";
|
966 |
|
967 |
+
$limit = $this->query_limit();
|
|
|
968 |
$offset = 0;
|
969 |
$query_next = true;
|
970 |
|
971 |
while ( $query_next ) {
|
972 |
// get the attachment id, smush data
|
973 |
+
$sql = "SELECT p.ID as attachment_id, p.post_mime_type as type, ms.meta_value as smush_data"
|
974 |
+
. " FROM $wpdb->posts as p"
|
975 |
+
. " LEFT JOIN $wpdb->postmeta as ms"
|
976 |
+
. " ON (p.ID= ms.post_id AND ms.meta_key='wp-smpro-smush-data')"
|
977 |
+
. " WHERE"
|
978 |
+
. " p.post_type='attachment'"
|
979 |
+
. " AND p.post_mime_type IN " . $allowed_images
|
980 |
+
. " ORDER BY p . ID DESC"
|
981 |
+
// add a limit
|
982 |
+
. " LIMIT " . $limit;
|
983 |
$results = $wpdb->get_results( $sql );
|
984 |
|
985 |
//Update the offset
|
986 |
$offset += $limit;
|
987 |
+
if ( $wpsmush_stats->total_count() && $wpsmush_stats->total_count() < $offset ) {
|
988 |
$query_next = false;
|
989 |
} else if ( ! $results || empty( $results ) ) {
|
990 |
$query_next = false;
|
994 |
return $results;
|
995 |
}
|
996 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
997 |
/**
|
998 |
* Store a key/value to hide the smush features on bulk page
|
999 |
*/
|
1013 |
}
|
1014 |
}
|
1015 |
|
1016 |
+
/**
|
1017 |
+
* Remove the Update info
|
1018 |
+
*
|
1019 |
+
* @param bool $remove_notice
|
1020 |
+
*
|
1021 |
+
*/
|
1022 |
+
function dismiss_update_info( $remove_notice = false ) {
|
1023 |
+
|
1024 |
+
//From URL arg
|
1025 |
+
if ( isset( $_GET['dismiss_smush_update_info'] ) && 1 == $_GET['dismiss_smush_update_info'] ) {
|
1026 |
+
$remove_notice = true;
|
1027 |
+
}
|
1028 |
+
|
1029 |
+
//From Ajax
|
1030 |
+
if( !empty( $_REQUEST['action'] ) && 'dismiss_update_info' == $_REQUEST['action']) {
|
1031 |
+
$remove_notice = true;
|
1032 |
+
}
|
1033 |
+
|
1034 |
+
//Update Db
|
1035 |
+
if( $remove_notice ) {
|
1036 |
+
update_site_option( 'wp-smush-hide_update_info', 1 );
|
1037 |
+
}
|
1038 |
+
|
1039 |
+
}
|
1040 |
+
|
1041 |
/**
|
1042 |
* Restore the image and its sizes from backup
|
1043 |
*/
|
1044 |
function restore_image( $attachment = '', $resp = true ) {
|
1045 |
|
1046 |
+
if ( empty( $attachment ) ) {
|
1047 |
//Check Empty fields
|
1048 |
if ( empty( $_POST['attachment_id'] ) || empty( $_POST['_nonce'] ) ) {
|
1049 |
wp_send_json_error( array(
|
1122 |
//Get the Button html without wrapper
|
1123 |
$button_html = $this->set_status( $image_id, false, false, false );
|
1124 |
|
1125 |
+
if ( $resp ) {
|
1126 |
wp_send_json_success( array( 'button' => $button_html ) );
|
1127 |
+
} else {
|
1128 |
return true;
|
1129 |
}
|
1130 |
}
|
1131 |
+
if ( $resp ) {
|
1132 |
wp_send_json_error( array( 'message' => '<div class="wp-smush-error">' . __( "Unable to restore image", "wp-smushit" ) . '</div>' ) );
|
1133 |
}
|
1134 |
+
|
1135 |
return false;
|
1136 |
}
|
1137 |
|
1182 |
*/
|
1183 |
function scan_images() {
|
1184 |
|
1185 |
+
global $WpSmush, $wpsmushnextgenadmin, $wpsmush_stats;
|
1186 |
|
1187 |
check_ajax_referer( 'save_wp_smush_options', 'wp_smush_options_nonce' );
|
1188 |
|
1191 |
//Default Notice, to be displayed at the top of page
|
1192 |
//Show a message, at the top
|
1193 |
$message = esc_html__( 'Yay! All images are optimised as per your current settings.', 'wp-smushit' );
|
1194 |
+
$resp = '<div class="wp-smush-notice wp-smush-resmush-message" tabindex="0"><i class="dev-icon dev-icon-tick"></i> ' . $message . '
|
1195 |
<i class="dev-icon dev-icon-cross"></i>
|
1196 |
</div>';
|
1197 |
|
1238 |
if ( 'nextgen' != $type ) {
|
1239 |
|
1240 |
//Get list of Smushed images
|
1241 |
+
$attachments = ! empty( $this->smushed_attachments ) ? $this->smushed_attachments : $wpsmush_stats->smushed_count( true );
|
1242 |
} else {
|
1243 |
global $wpsmushnextgenstats;
|
1244 |
|
1316 |
if ( 'nextgen' != $type ) {
|
1317 |
//Set the variables
|
1318 |
$this->resmush_ids = $resmush_list;
|
1319 |
+
|
1320 |
+
$resmush_count = count( $this->resmush_ids );
|
1321 |
+
|
1322 |
+
$smushed = !empty( $this->resmush_ids ) ? $this->smushed_count - $resmush_count : $this->smushed_count;
|
1323 |
+
|
1324 |
} else {
|
1325 |
//To avoid the php warning
|
1326 |
$wpsmushnextgenadmin->resmush_ids = $resmush_list;
|
1338 |
}
|
1339 |
}
|
1340 |
|
1341 |
+
if ( ! empty( $resmush_list ) || $remaining_count > 0 ) {
|
1342 |
$message = sprintf( esc_html__( "You have images that need smushing. %sBulk smush now!%s", "wp-smushit" ), '<a href="#" class="wp-smush-trigger-bulk">', '</a>' );
|
1343 |
$resp = '<div class="wp-smush-notice wp-smush-resmush-message wp-smush-resmush-pending" tabindex="0"><i class="dev-icon dev-icon-tick"></i> ' . $message . '
|
1344 |
<i class="dev-icon dev-icon-cross"></i>
|
1350 |
"resmush_ids" => $resmush_list,
|
1351 |
"content" => $ajax_response
|
1352 |
) : '';
|
1353 |
+
|
1354 |
+
//Include the count
|
1355 |
+
if( !empty( $count) && $count ) {
|
1356 |
+
$return['count'] = $count;
|
1357 |
+
}
|
1358 |
+
|
1359 |
+
$return['notice'] = $resp;
|
1360 |
+
$return['super_smush'] = $WpSmush->lossy_enabled;
|
1361 |
+
if ( $WpSmush->lossy_enabled && 'nextgen' == $type ) {
|
1362 |
+
$ss_count = $wpsmush_stats->super_smushed_count( 'nextgen', $wpsmushnextgenstats->get_ngg_images( 'smushed' ) );
|
1363 |
+
$return['super_smush_stats'] = sprintf( '<strong><span class="smushed-count">%d</span>/%d</strong>', $ss_count, $wpsmushnextgenadmin->total_count );
|
1364 |
+
}
|
1365 |
|
1366 |
wp_send_json_success( $return );
|
1367 |
|
1408 |
'fields' => 'ids',
|
1409 |
'post_type' => 'attachment',
|
1410 |
'post_status' => 'any',
|
1411 |
+
'post_mime_type' => $this->mime_types,
|
1412 |
'order' => 'ASC',
|
1413 |
'posts_per_page' => - 1,
|
1414 |
'meta_key' => 'upfront_used_image_sizes',
|
1456 |
}
|
1457 |
}
|
1458 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1459 |
/**
|
1460 |
* Add/Remove image id from Super Smushed images count
|
1461 |
*
|
1547 |
wp_send_json_success();
|
1548 |
}
|
1549 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1550 |
/**
|
1551 |
* Allows to bulk restore the images, if there is any backup for them
|
1552 |
*/
|
1553 |
function bulk_restore() {
|
1554 |
+
global $wpsmush_stats;
|
1555 |
+
$smushed_attachments = !empty( $this->smushed_attachments ) ? $this->smushed_attachments : $wpsmush_stats->smushed_count( true );
|
1556 |
+
foreach ( $smushed_attachments as $attachment ) {
|
1557 |
$this->restore_image( $attachment->attachment_id, false );
|
1558 |
}
|
1559 |
}
|
1560 |
|
1561 |
/**
|
1562 |
* Loads the Shared UI to on all admin pages
|
1563 |
+
*
|
1564 |
* @param $current_page
|
1565 |
*/
|
1566 |
function load_shared_ui( $current_page ) {
|
1585 |
}
|
1586 |
}
|
1587 |
|
1588 |
+
/** Get the Maximum Width and Height settings for WrodPress
|
1589 |
+
*
|
1590 |
+
* @return array, Array of Max. Width and Height for image
|
1591 |
+
*
|
1592 |
+
*/
|
1593 |
+
function get_max_image_dimensions() {
|
1594 |
+
global $_wp_additional_image_sizes;
|
1595 |
+
|
1596 |
+
$width = $height = 0;
|
1597 |
+
$limit = 9999; //Post-thumbnail
|
1598 |
+
|
1599 |
+
$image_sizes = get_intermediate_image_sizes();
|
1600 |
+
|
1601 |
+
// Create the full array with sizes and crop info
|
1602 |
+
foreach ( $image_sizes as $size ) {
|
1603 |
+
if ( in_array( $size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) {
|
1604 |
+
$size_width = get_option( "{$size}_size_w" );
|
1605 |
+
$size_height = get_option( "{$size}_size_h" );
|
1606 |
+
} elseif ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
|
1607 |
+
$size_width = $_wp_additional_image_sizes[ $size ]['width'];
|
1608 |
+
$size_height = $_wp_additional_image_sizes[ $size ]['height'];
|
1609 |
+
}
|
1610 |
+
|
1611 |
+
//Skip if no width and height
|
1612 |
+
if ( ! isset( $size_width, $size_height ) ) {
|
1613 |
+
continue;
|
1614 |
+
}
|
1615 |
+
|
1616 |
+
//If within te limit, check for a max value
|
1617 |
+
if ( $size_width <= $limit ) {
|
1618 |
+
$width = max( $width, $size_width );
|
1619 |
+
}
|
1620 |
+
|
1621 |
+
if ( $size_height <= $limit ) {
|
1622 |
+
$height = max( $height, $size_height );
|
1623 |
+
}
|
1624 |
+
}
|
1625 |
+
|
1626 |
+
return array(
|
1627 |
+
'width' => $width,
|
1628 |
+
'height' => $height
|
1629 |
+
);
|
1630 |
+
}
|
1631 |
+
|
1632 |
+
/**
|
1633 |
+
* Perform the resize operation for the image
|
1634 |
+
*
|
1635 |
+
* @param $attachment_id
|
1636 |
+
*
|
1637 |
+
* @param $meta
|
1638 |
+
*
|
1639 |
+
* @return mixed
|
1640 |
+
*/
|
1641 |
+
function resize_image( $attachment_id, $meta ) {
|
1642 |
+
if ( empty( $attachment_id ) || empty( $meta ) ) {
|
1643 |
+
return $meta;
|
1644 |
+
}
|
1645 |
+
global $wpsmush_resize;
|
1646 |
+
|
1647 |
+
return $wpsmush_resize->auto_resize( $attachment_id, $meta );
|
1648 |
+
}
|
1649 |
+
|
1650 |
+
/**
|
1651 |
+
* Limit for all the queries
|
1652 |
+
*
|
1653 |
+
* @return int|mixed|void
|
1654 |
+
*
|
1655 |
+
*/
|
1656 |
+
function query_limit() {
|
1657 |
+
$limit = apply_filters( 'wp_smush_query_limit', 1000 );
|
1658 |
+
$limit = intval( $limit );
|
1659 |
+
|
1660 |
+
return $limit;
|
1661 |
+
}
|
1662 |
+
|
1663 |
+
/**
|
1664 |
+
* Filter the number of results fetched at once for NextGen queries
|
1665 |
+
*
|
1666 |
+
* @return int|mixed|void
|
1667 |
+
*
|
1668 |
+
*/
|
1669 |
+
function nextgen_query_limit() {
|
1670 |
+
$limit = apply_filters( 'wp_smush_nextgen_query_limit', 1000 );
|
1671 |
+
$limit = intval( $limit );
|
1672 |
+
|
1673 |
+
return $limit;
|
1674 |
+
}
|
1675 |
+
|
1676 |
+
/**
|
1677 |
+
* Show Update info in admin Notice
|
1678 |
+
*
|
1679 |
+
*/
|
1680 |
+
function smush_updated() {
|
1681 |
+
//@todo: Update Smush Update Notice for next release
|
1682 |
+
//Make sure to not display this message for next release
|
1683 |
+
$plugin_data = get_plugin_data( WP_SMUSH_DIR . 'wp-smush.php', false, false );
|
1684 |
+
$version = ! empty( $plugin_data['Version'] ) ? $plugin_data['Version'] : '';
|
1685 |
+
|
1686 |
+
//If Versions Do not match
|
1687 |
+
if ( empty( $version ) || $version != WP_SMUSH_VERSION ) {
|
1688 |
+
return true;
|
1689 |
+
}
|
1690 |
+
|
1691 |
+
//Do not display it for other users
|
1692 |
+
if ( ! is_super_admin() || ! current_user_can( 'manage_options' ) ) {
|
1693 |
+
return true;
|
1694 |
+
}
|
1695 |
+
|
1696 |
+
//If dismissed, Delete the option on Plugin Activation, For alter releases
|
1697 |
+
if ( 1 == get_site_option( 'wp-smush-hide_update_info' ) ) {
|
1698 |
+
return true;
|
1699 |
+
}
|
1700 |
+
|
1701 |
+
//Do not show for new installations
|
1702 |
+
$install_type = get_site_option( 'wp-smush-install-type', false );
|
1703 |
+
|
1704 |
+
if ( ! $install_type || 'new' == $install_type ) {
|
1705 |
+
return true;
|
1706 |
+
}
|
1707 |
+
|
1708 |
+
//Do not display the notice on Bulk Smush Screen
|
1709 |
+
global $current_screen;
|
1710 |
+
if ( ! empty( $current_screen->base ) && ( 'media_page_wp-smush-bulk' == $current_screen->base || 'gallery_page_wp-smush-nextgen-bulk' == $current_screen->base ) ) {
|
1711 |
+
return true;
|
1712 |
+
}
|
1713 |
+
|
1714 |
+
//Handles the dismiss action
|
1715 |
+
$js_url = WP_SMUSH_URL . 'assets/js/notice.js';
|
1716 |
+
|
1717 |
+
$settings_link = '<a href="' . admin_url( 'upload.php?page=wp-smush-bulk#wp-smush-settings-box' ) . '" title="' . esc_html__( "Settings", "wp-smushit" ) . '">';
|
1718 |
+
$upgrade_link = '<a href="' . $this->upgrade_url . '" title="' . esc_html__( "WP Smush Pro", "wp-smushit" ) . '">';
|
1719 |
+
?>
|
1720 |
+
<div class="notice notice-info is-dismissible wp-smush-update-info">
|
1721 |
+
<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>
|
1722 |
+
</div>
|
1723 |
+
|
1724 |
+
<script src="<?php echo esc_url( $js_url ) . '?v=' . WP_SMUSH_VERSION; ?>"></script><?php
|
1725 |
+
}
|
1726 |
+
|
1727 |
}
|
1728 |
|
1729 |
global $wpsmushit_admin;
|
lib/class-wp-smush-bulk.php
CHANGED
@@ -22,18 +22,23 @@ if ( ! class_exists( 'WpSmushitBulk' ) ) {
|
|
22 |
* @return array $attachments
|
23 |
*/
|
24 |
function get_attachments() {
|
25 |
-
global $wpsmushit_admin;
|
26 |
|
27 |
if ( ! isset( $_REQUEST['ids'] ) ) {
|
28 |
-
$limit
|
29 |
-
$limit
|
|
|
|
|
|
|
|
|
|
|
30 |
$get_posts = true;
|
31 |
$unsmushed_posts = array();
|
32 |
$args = array(
|
33 |
'fields' => 'ids',
|
34 |
'post_type' => 'attachment',
|
35 |
'post_status' => 'any',
|
36 |
-
'post_mime_type' =>
|
37 |
'orderby' => 'ID',
|
38 |
'order' => 'DESC',
|
39 |
'posts_per_page' => $limit,
|
@@ -44,6 +49,7 @@ if ( ! class_exists( 'WpSmushitBulk' ) ) {
|
|
44 |
'compare' => 'NOT EXISTS'
|
45 |
)
|
46 |
),
|
|
|
47 |
'update_post_term_cache' => false,
|
48 |
'no_found_rows' => true,
|
49 |
);
|
@@ -51,21 +57,26 @@ if ( ! class_exists( 'WpSmushitBulk' ) ) {
|
|
51 |
while ( $get_posts ) {
|
52 |
|
53 |
//Remove the Filters added by WP Media Folder
|
54 |
-
$
|
55 |
|
56 |
$query = new WP_Query( $args );
|
57 |
|
58 |
-
if( !empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
|
59 |
//Merge the results
|
60 |
$unsmushed_posts = array_merge( $unsmushed_posts, $query->posts );
|
61 |
|
62 |
//Update the offset
|
63 |
$args['offset'] += $limit;
|
64 |
-
}else{
|
65 |
//If we didn't get any posts from query, set $get_posts to false
|
66 |
$get_posts = false;
|
67 |
}
|
68 |
|
|
|
|
|
|
|
|
|
|
|
69 |
//If total Count is set, and it is alread lesser than offset, don't query
|
70 |
if ( ! empty( $wpsmushit_admin->total_count ) && $wpsmushit_admin->total_count < $args['offset'] ) {
|
71 |
$get_posts = false;
|
22 |
* @return array $attachments
|
23 |
*/
|
24 |
function get_attachments() {
|
25 |
+
global $wpsmushit_admin, $wpsmush_stats;
|
26 |
|
27 |
if ( ! isset( $_REQUEST['ids'] ) ) {
|
28 |
+
$limit = $wpsmushit_admin->query_limit();
|
29 |
+
$limit = ! empty( $wpsmushit_admin->total_count ) && $wpsmushit_admin->total_count < $limit ? $wpsmushit_admin->total_count : $limit;
|
30 |
+
|
31 |
+
//Do not fetch more than this, any time
|
32 |
+
//Localizing all rows at once increases the page load and sloes down everything
|
33 |
+
$r_limit = apply_filters( 'wp_smush_max_rows', 5000 );
|
34 |
+
|
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,
|
49 |
'compare' => 'NOT EXISTS'
|
50 |
)
|
51 |
),
|
52 |
+
'update_post_meta_cache' => false,
|
53 |
'update_post_term_cache' => false,
|
54 |
'no_found_rows' => true,
|
55 |
);
|
57 |
while ( $get_posts ) {
|
58 |
|
59 |
//Remove the Filters added by WP Media Folder
|
60 |
+
$wpsmush_stats->remove_wmf_filters();
|
61 |
|
62 |
$query = new WP_Query( $args );
|
63 |
|
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;
|
70 |
+
} else {
|
71 |
//If we didn't get any posts from query, set $get_posts to false
|
72 |
$get_posts = false;
|
73 |
}
|
74 |
|
75 |
+
//If we already got enough posts
|
76 |
+
if ( count( $unsmushed_posts ) >= $r_limit ) {
|
77 |
+
$get_posts = false;
|
78 |
+
}
|
79 |
+
|
80 |
//If total Count is set, and it is alread lesser than offset, don't query
|
81 |
if ( ! empty( $wpsmushit_admin->total_count ) && $wpsmushit_admin->total_count < $args['offset'] ) {
|
82 |
$get_posts = false;
|
lib/class-wp-smush-nextgen.php
CHANGED
@@ -107,7 +107,7 @@ if ( ! class_exists( 'WpSmushNextGen' ) ) {
|
|
107 |
* @return bool|string
|
108 |
*/
|
109 |
function get_file_type( $file_path ) {
|
110 |
-
if ( empty( $file_path ) || !file_exists( $file_path ) ) {
|
111 |
return false;
|
112 |
}
|
113 |
if ( function_exists( 'exif_imagetype' ) ) {
|
@@ -127,9 +127,6 @@ if ( ! class_exists( 'WpSmushNextGen' ) ) {
|
|
127 |
* Read the image paths from an attachment's meta data and process each image
|
128 |
* with wp_smushit().
|
129 |
*
|
130 |
-
* This method also adds a `wp_smushit` meta key for use in the media library.
|
131 |
-
* Called after `wp_generate_attachment_metadata` is completed.
|
132 |
-
*
|
133 |
* @param $meta
|
134 |
* @param null $ID
|
135 |
*
|
@@ -153,7 +150,7 @@ if ( ! class_exists( 'WpSmushNextGen' ) ) {
|
|
153 |
// Registry Object for NextGen Gallery
|
154 |
$registry = C_Component_Registry::get_instance();
|
155 |
|
156 |
-
//
|
157 |
$storage = $registry->get_utility( 'I_Gallery_Storage' );
|
158 |
|
159 |
//File path and URL for original image
|
@@ -172,7 +169,7 @@ if ( ! class_exists( 'WpSmushNextGen' ) ) {
|
|
172 |
foreach ( $sizes as $size ) {
|
173 |
|
174 |
//Skip Full size, if smush original is not checked
|
175 |
-
if( 'full' == $size &&
|
176 |
continue;
|
177 |
}
|
178 |
|
@@ -218,55 +215,33 @@ if ( ! class_exists( 'WpSmushNextGen' ) ) {
|
|
218 |
}
|
219 |
|
220 |
//If there are no stats
|
221 |
-
if( empty( $response['data'] ) ) {
|
222 |
continue;
|
223 |
}
|
224 |
|
225 |
//If the image size grew after smushing, skip it
|
226 |
-
if( $response['data']->after_size > $response['data']->before_size ) {
|
227 |
continue;
|
228 |
}
|
229 |
|
230 |
$stats['sizes'][ $size ] = (object) $WpSmush->_array_fill_placeholders( $WpSmush->_get_size_signature(), (array) $response['data'] );
|
231 |
|
232 |
-
//Total Stats, store all data in bytes
|
233 |
-
list( $size_before, $size_after, $total_time, $compression, $bytes_saved )
|
234 |
-
= $WpSmush->_update_stats_data( $response['data'], $size_before, $size_after, $total_time, $bytes_saved );
|
235 |
-
|
236 |
if ( empty( $stats['stats']['api_version'] ) || $stats['stats']['api_version'] == - 1 ) {
|
237 |
$stats['stats']['api_version'] = $response['data']->api_version;
|
238 |
$stats['stats']['lossy'] = $response['data']->lossy;
|
239 |
-
$stats['stats']['keep_exif'] = !empty( $response['data']->keep_exif ) ? $response['data']->keep_exif : 0;
|
240 |
}
|
241 |
}
|
242 |
}
|
243 |
|
244 |
$has_errors = (bool) count( $errors->get_error_messages() );
|
245 |
|
246 |
-
list( $stats['stats']['size_before'], $stats['stats']['size_after'], $stats['stats']['time'], $stats['stats']['percent'], $stats['stats']['bytes'] ) =
|
247 |
-
array( $size_before, $size_after, $total_time, $compression, $bytes_saved );
|
248 |
-
|
249 |
//Set smush status for all the images, store it in wp-smpro-smush-data
|
250 |
if ( ! $has_errors ) {
|
251 |
|
252 |
$existing_stats = ( ! empty( $image->meta_data ) && ! empty( $image->meta_data['wp_smush'] ) ) ? $image->meta_data['wp_smush'] : '';
|
253 |
|
254 |
if ( ! empty( $existing_stats ) ) {
|
255 |
-
$e_size_before = !empty( $existing_stats['stats']['size_before'] ) ? $existing_stats['stats']['size_before'] : '';
|
256 |
-
$e_size_after = isset( $existing_stats['stats']['size_after'] ) ? $existing_stats['stats']['size_after'] : '';
|
257 |
-
|
258 |
-
//Store Original size before
|
259 |
-
$stats['stats']['size_before'] = ( !empty($e_size_before ) && $e_size_before > $stats['stats']['size_before'] ) ? $e_size_before : $stats['stats']['size_before'];
|
260 |
-
|
261 |
-
if ( $size_after == 0 || empty( $stats['stats']['size_after'] ) || $stats['stats']['size_after'] == $stats['stats']['size_before'] ) {
|
262 |
-
$stats['stats']['size_after'] = $e_size_after < $stats['stats']['size_before'] ? $e_size_after : $stats['stats']['size_before'];
|
263 |
-
}
|
264 |
-
|
265 |
-
//Update total bytes saved, and compression percent
|
266 |
-
$stats['stats']['bytes'] = isset( $existing_stats['stats']['bytes'] ) ? $existing_stats['stats']['bytes'] + $stats['stats']['bytes'] : $stats['stats']['bytes'];
|
267 |
-
|
268 |
-
$stats['stats']['percent'] = $WpSmush->calculate_percentage( (object) $stats['stats'], (object) $existing_stats['stats'] );
|
269 |
-
|
270 |
//Update stats for each size
|
271 |
if ( ! empty( $existing_stats['sizes'] ) && ! empty( $stats['sizes'] ) ) {
|
272 |
|
@@ -279,30 +254,34 @@ if ( ! class_exists( 'WpSmushNextGen' ) ) {
|
|
279 |
}
|
280 |
$stats['sizes'][ $size_name ] = $existing_stats['sizes'][ $size_name ];
|
281 |
} else {
|
282 |
-
$existing_stats_size = (object)$existing_stats['sizes'][ $size_name ];
|
283 |
|
284 |
//store the original image size
|
285 |
$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;
|
286 |
|
287 |
//Update compression percent and bytes saved for each size
|
288 |
-
$stats['sizes'][ $size_name ]->bytes
|
289 |
//Calculate percentage
|
290 |
$stats['sizes'][ $size_name ]->percent = $WpSmush->calculate_percentage( $stats['sizes'][ $size_name ], $existing_stats_size );
|
291 |
}
|
292 |
}
|
293 |
}
|
294 |
}
|
|
|
|
|
|
|
|
|
295 |
//If there was any compression and there was no error in smushing
|
296 |
-
if( isset( $stats['stats']['bytes'] ) && $stats['stats']['bytes'] >= 0 &&
|
297 |
/**
|
298 |
* Runs if the image smushing was successful
|
299 |
*
|
300 |
-
* @param int
|
301 |
*
|
302 |
* @param array $stats Smush Stats for the image
|
303 |
*
|
304 |
*/
|
305 |
-
do_action('wp_smush_image_optimised_nextgen', $image->pid, $stats );
|
306 |
}
|
307 |
$image->meta_data['wp_smush'] = $stats;
|
308 |
nggdb::update_image_meta( $image->pid, $image->meta_data );
|
@@ -339,8 +318,17 @@ if ( ! class_exists( 'WpSmushNextGen' ) ) {
|
|
339 |
wp_send_json_error( array( 'error_msg' => '<p class="wp-smush-error-message">' . esc_html__( "We couldn't find the metadata for the image, possibly the image has been deleted.", "wp-smushit" ) . '</p>' ) );
|
340 |
}
|
341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
//smush the main image and its sizes
|
343 |
-
$smush = $this->resize_from_meta_data( $image );
|
344 |
|
345 |
if ( ! is_wp_error( $smush ) ) {
|
346 |
$status = $wpsmushnextgenstats->show_stats( $pid, $smush, false, true );
|
@@ -513,8 +501,8 @@ if ( ! class_exists( 'WpSmushNextGen' ) ) {
|
|
513 |
$restored[] = @copy( $attachment_file_path . '_backup', $attachment_file_path );
|
514 |
}
|
515 |
//Restoring the other sizes
|
516 |
-
$attachment_data = !empty( $image->meta_data['wp_smush'] ) ? $image->meta_data['wp_smush'] : '';
|
517 |
-
if( !empty( $attachment_data['sizes'] ) ) {
|
518 |
foreach ( $attachment_data['sizes'] as $size => $size_data ) {
|
519 |
if ( 'full' == $size ) {
|
520 |
continue;
|
@@ -548,7 +536,7 @@ if ( ! class_exists( 'WpSmushNextGen' ) ) {
|
|
548 |
//Get the Button html without wrapper
|
549 |
$button_html = $wpsmushnextgenadmin->wp_smush_column_options( '', $image_id, false );
|
550 |
|
551 |
-
wp_send_json_success( array('button' => $button_html ) );
|
552 |
}
|
553 |
wp_send_json_error( array( 'message' => '<div class="wp-smush-error">' . __( "Unable to restore image", "wp-smushit" ) . '</div>' ) );
|
554 |
}
|
@@ -577,7 +565,7 @@ if ( ! class_exists( 'WpSmushNextGen' ) ) {
|
|
577 |
$smushed = $this->smush_image( $image_id, '', false );
|
578 |
|
579 |
//If any of the image is restored, we count it as success
|
580 |
-
if ( ! empty( $smushed ) && !is_wp_error( $smushed ) ) {
|
581 |
|
582 |
//Send button content
|
583 |
wp_send_json_success( array( 'button' => $smushed['status'] . $smushed['stats'] ) );
|
@@ -590,7 +578,197 @@ if ( ! class_exists( 'WpSmushNextGen' ) ) {
|
|
590 |
}
|
591 |
}
|
592 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
593 |
}//End of Class
|
|
|
594 |
}//End Of if class not exists
|
595 |
|
596 |
//Extend NextGen Mixin class to smush dynamic images
|
@@ -657,7 +835,7 @@ if ( class_exists( 'WpSmushNextGen' ) ) {
|
|
657 |
$stats['size_before'] = $response['data']->before_size;
|
658 |
$stats['time'] = $response['data']->time;
|
659 |
}
|
660 |
-
$stats['sizes'][ $size ]
|
661 |
|
662 |
if ( isset( $image->metadata ) ) {
|
663 |
$image->meta_data['wp_smush'] = $stats;
|
@@ -675,8 +853,8 @@ if ( class_exists( 'WpSmushNextGen' ) ) {
|
|
675 |
}
|
676 |
}
|
677 |
}
|
678 |
-
if ( class_exists('WpSmushNextGenDynamicThumbs') ) {
|
679 |
-
if(! get_option('ngg_options') ) {
|
680 |
return;
|
681 |
}
|
682 |
$storage = C_Gallery_Storage::get_instance();
|
107 |
* @return bool|string
|
108 |
*/
|
109 |
function get_file_type( $file_path ) {
|
110 |
+
if ( empty( $file_path ) || ! file_exists( $file_path ) ) {
|
111 |
return false;
|
112 |
}
|
113 |
if ( function_exists( 'exif_imagetype' ) ) {
|
127 |
* Read the image paths from an attachment's meta data and process each image
|
128 |
* with wp_smushit().
|
129 |
*
|
|
|
|
|
|
|
130 |
* @param $meta
|
131 |
* @param null $ID
|
132 |
*
|
150 |
// Registry Object for NextGen Gallery
|
151 |
$registry = C_Component_Registry::get_instance();
|
152 |
|
153 |
+
//Storage Object for NextGen Gallery
|
154 |
$storage = $registry->get_utility( 'I_Gallery_Storage' );
|
155 |
|
156 |
//File path and URL for original image
|
169 |
foreach ( $sizes as $size ) {
|
170 |
|
171 |
//Skip Full size, if smush original is not checked
|
172 |
+
if ( 'full' == $size && ! $WpSmush->smush_original ) {
|
173 |
continue;
|
174 |
}
|
175 |
|
215 |
}
|
216 |
|
217 |
//If there are no stats
|
218 |
+
if ( empty( $response['data'] ) ) {
|
219 |
continue;
|
220 |
}
|
221 |
|
222 |
//If the image size grew after smushing, skip it
|
223 |
+
if ( $response['data']->after_size > $response['data']->before_size ) {
|
224 |
continue;
|
225 |
}
|
226 |
|
227 |
$stats['sizes'][ $size ] = (object) $WpSmush->_array_fill_placeholders( $WpSmush->_get_size_signature(), (array) $response['data'] );
|
228 |
|
|
|
|
|
|
|
|
|
229 |
if ( empty( $stats['stats']['api_version'] ) || $stats['stats']['api_version'] == - 1 ) {
|
230 |
$stats['stats']['api_version'] = $response['data']->api_version;
|
231 |
$stats['stats']['lossy'] = $response['data']->lossy;
|
232 |
+
$stats['stats']['keep_exif'] = ! empty( $response['data']->keep_exif ) ? $response['data']->keep_exif : 0;
|
233 |
}
|
234 |
}
|
235 |
}
|
236 |
|
237 |
$has_errors = (bool) count( $errors->get_error_messages() );
|
238 |
|
|
|
|
|
|
|
239 |
//Set smush status for all the images, store it in wp-smpro-smush-data
|
240 |
if ( ! $has_errors ) {
|
241 |
|
242 |
$existing_stats = ( ! empty( $image->meta_data ) && ! empty( $image->meta_data['wp_smush'] ) ) ? $image->meta_data['wp_smush'] : '';
|
243 |
|
244 |
if ( ! empty( $existing_stats ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
//Update stats for each size
|
246 |
if ( ! empty( $existing_stats['sizes'] ) && ! empty( $stats['sizes'] ) ) {
|
247 |
|
254 |
}
|
255 |
$stats['sizes'][ $size_name ] = $existing_stats['sizes'][ $size_name ];
|
256 |
} else {
|
257 |
+
$existing_stats_size = (object) $existing_stats['sizes'][ $size_name ];
|
258 |
|
259 |
//store the original image size
|
260 |
$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;
|
261 |
|
262 |
//Update compression percent and bytes saved for each size
|
263 |
+
$stats['sizes'][ $size_name ]->bytes = $stats['sizes'][ $size_name ]->bytes + $existing_stats_size->bytes;
|
264 |
//Calculate percentage
|
265 |
$stats['sizes'][ $size_name ]->percent = $WpSmush->calculate_percentage( $stats['sizes'][ $size_name ], $existing_stats_size );
|
266 |
}
|
267 |
}
|
268 |
}
|
269 |
}
|
270 |
+
//Total Stats
|
271 |
+
$stats = $WpSmush->total_compression( $stats );
|
272 |
+
$stats['total_images'] = !empty( $stats['sizes'] ) ? count( $stats['sizes'] ) : 0;
|
273 |
+
|
274 |
//If there was any compression and there was no error in smushing
|
275 |
+
if ( isset( $stats['stats']['bytes'] ) && $stats['stats']['bytes'] >= 0 && ! $has_errors ) {
|
276 |
/**
|
277 |
* Runs if the image smushing was successful
|
278 |
*
|
279 |
+
* @param int $ID Image Id
|
280 |
*
|
281 |
* @param array $stats Smush Stats for the image
|
282 |
*
|
283 |
*/
|
284 |
+
do_action( 'wp_smush_image_optimised_nextgen', $image->pid, $stats );
|
285 |
}
|
286 |
$image->meta_data['wp_smush'] = $stats;
|
287 |
nggdb::update_image_meta( $image->pid, $image->meta_data );
|
318 |
wp_send_json_error( array( 'error_msg' => '<p class="wp-smush-error-message">' . esc_html__( "We couldn't find the metadata for the image, possibly the image has been deleted.", "wp-smushit" ) . '</p>' ) );
|
319 |
}
|
320 |
|
321 |
+
$registry = C_Component_Registry::get_instance();
|
322 |
+
$storage = $registry->get_utility( 'I_Gallery_Storage' );
|
323 |
+
|
324 |
+
$metadata = $this->resize_image( $pid, $image, $metadata, $storage );
|
325 |
+
|
326 |
+
//Store Meta
|
327 |
+
$image->meta_data = $metadata;
|
328 |
+
nggdb::update_image_meta( $image->pid, $image->meta_data );
|
329 |
+
|
330 |
//smush the main image and its sizes
|
331 |
+
$smush = $this->resize_from_meta_data( $image, $registry, $storage );
|
332 |
|
333 |
if ( ! is_wp_error( $smush ) ) {
|
334 |
$status = $wpsmushnextgenstats->show_stats( $pid, $smush, false, true );
|
501 |
$restored[] = @copy( $attachment_file_path . '_backup', $attachment_file_path );
|
502 |
}
|
503 |
//Restoring the other sizes
|
504 |
+
$attachment_data = ! empty( $image->meta_data['wp_smush'] ) ? $image->meta_data['wp_smush'] : '';
|
505 |
+
if ( ! empty( $attachment_data['sizes'] ) ) {
|
506 |
foreach ( $attachment_data['sizes'] as $size => $size_data ) {
|
507 |
if ( 'full' == $size ) {
|
508 |
continue;
|
536 |
//Get the Button html without wrapper
|
537 |
$button_html = $wpsmushnextgenadmin->wp_smush_column_options( '', $image_id, false );
|
538 |
|
539 |
+
wp_send_json_success( array( 'button' => $button_html ) );
|
540 |
}
|
541 |
wp_send_json_error( array( 'message' => '<div class="wp-smush-error">' . __( "Unable to restore image", "wp-smushit" ) . '</div>' ) );
|
542 |
}
|
565 |
$smushed = $this->smush_image( $image_id, '', false );
|
566 |
|
567 |
//If any of the image is restored, we count it as success
|
568 |
+
if ( ! empty( $smushed ) && ! is_wp_error( $smushed ) ) {
|
569 |
|
570 |
//Send button content
|
571 |
wp_send_json_success( array( 'button' => $smushed['status'] . $smushed['stats'] ) );
|
578 |
}
|
579 |
}
|
580 |
|
581 |
+
/**
|
582 |
+
* Get file extension from file path
|
583 |
+
*
|
584 |
+
* @param string $file_path Absolute image path to get the mime for
|
585 |
+
*
|
586 |
+
* @return string Null/ Mime Type
|
587 |
+
*
|
588 |
+
*/
|
589 |
+
function get_file_ext( $file_path = '' ) {
|
590 |
+
if ( empty( $file_path ) ) {
|
591 |
+
return '';
|
592 |
+
}
|
593 |
+
|
594 |
+
if ( class_exists( 'finfo' ) ) {
|
595 |
+
$finfo = new finfo( FILEINFO_MIME_TYPE );
|
596 |
+
} else {
|
597 |
+
$finfo = false;
|
598 |
+
}
|
599 |
+
|
600 |
+
if ( $finfo ) {
|
601 |
+
$ext = file_exists( $file_path ) ? $finfo->file( $file_path ) : '';
|
602 |
+
} elseif ( function_exists( 'mime_content_type' ) ) {
|
603 |
+
$ext = mime_content_type( $file_path );
|
604 |
+
} else {
|
605 |
+
$ext = '';
|
606 |
+
}
|
607 |
+
|
608 |
+
return $ext;
|
609 |
+
}
|
610 |
+
|
611 |
+
/**
|
612 |
+
* Optionally resize a NextGen image
|
613 |
+
*
|
614 |
+
* @param $attachment_id Gallery Image id
|
615 |
+
* @param $image Image object for NextGen gallery
|
616 |
+
* @param $meta Image meta from nextgen gallery
|
617 |
+
* @param $storage Storage object for nextgen gallery
|
618 |
+
*
|
619 |
+
* @return mixed
|
620 |
+
*/
|
621 |
+
function resize_image( $attachment_id, $image, $meta, $storage ) {
|
622 |
+
global $wpsmush_resize, $wpsmushit_admin;
|
623 |
+
if ( empty( $attachment_id ) || empty( $meta ) || ! is_object( $storage ) ) {
|
624 |
+
return $meta;
|
625 |
+
}
|
626 |
+
|
627 |
+
//If resizing not enabled, or if both max width and height is set to 0, return
|
628 |
+
if ( ! $wpsmush_resize->resize_enabled || ( $wpsmush_resize->max_w == 0 && $wpsmush_resize->max_h == 0 ) ) {
|
629 |
+
return $meta;
|
630 |
+
}
|
631 |
+
|
632 |
+
$file_path = $storage->get_image_abspath( $image );
|
633 |
+
if ( ! file_exists( $file_path ) ) {
|
634 |
+
return $meta;
|
635 |
+
}
|
636 |
+
|
637 |
+
$ext = $this->get_file_ext( $file_path );
|
638 |
+
|
639 |
+
$mime_supported = in_array( $ext, $wpsmushit_admin->mime_types );
|
640 |
+
|
641 |
+
//If type of upload doesn't matches the criteria return
|
642 |
+
if ( ! empty( $mime ) && ! $mime_supported = apply_filters( 'wp_smush_resmush_mime_supported', $mime_supported, $mime ) ) {
|
643 |
+
return $meta;
|
644 |
+
}
|
645 |
+
|
646 |
+
//If already resized
|
647 |
+
if ( ! empty( $meta['wp_smush_resize_savings'] ) ) {
|
648 |
+
return $meta;
|
649 |
+
}
|
650 |
+
|
651 |
+
$sizes = $storage->get_image_sizes();
|
652 |
+
|
653 |
+
$should_resize = true;
|
654 |
+
|
655 |
+
/**
|
656 |
+
* Filter whether the NextGen image should be resized or not
|
657 |
+
*
|
658 |
+
* @since 2.3
|
659 |
+
*
|
660 |
+
* @param bool $should_resize
|
661 |
+
*
|
662 |
+
* @param object NextGen Gallery image object
|
663 |
+
*
|
664 |
+
* @param array NextGen Gallery image object
|
665 |
+
*
|
666 |
+
* @param string $context The type of upload action. Values include 'upload' or 'sideload'.
|
667 |
+
*
|
668 |
+
*/
|
669 |
+
if ( ! $should_resize = apply_filters( 'wp_smush_resize_nextgen_image', $should_resize, $image, $meta ) ) {
|
670 |
+
return $meta;
|
671 |
+
}
|
672 |
+
|
673 |
+
$original_file_size = filesize( $file_path );
|
674 |
+
|
675 |
+
$resized = $wpsmush_resize->perform_resize( $file_path, $original_file_size, $attachment_id, '', false );
|
676 |
+
|
677 |
+
//If resize wasn't successful
|
678 |
+
if ( ! $resized ) {
|
679 |
+
//Unlink Image, if other size path is not similar
|
680 |
+
$this->maybe_unlink( $file_path, $sizes, $image, $storage );
|
681 |
+
|
682 |
+
return $meta;
|
683 |
+
} else {
|
684 |
+
|
685 |
+
//Else Replace the Original file with resized file
|
686 |
+
$replaced = @copy( $resized['file_path'], $file_path );
|
687 |
+
$this->maybe_unlink( $resized['file_path'], $sizes, $image, $storage );
|
688 |
+
}
|
689 |
+
|
690 |
+
if ( $replaced ) {
|
691 |
+
//Updated File size
|
692 |
+
$u_file_size = filesize( $file_path );
|
693 |
+
|
694 |
+
$savings['bytes'] = $original_file_size > $u_file_size ? $original_file_size - $u_file_size : 0;
|
695 |
+
$savings['size_before'] = $original_file_size;
|
696 |
+
$savings['size_after'] = $u_file_size;
|
697 |
+
|
698 |
+
//Store savings in meta data
|
699 |
+
if ( ! empty( $savings ) ) {
|
700 |
+
$meta['wp_smush_resize_savings'] = $savings;
|
701 |
+
}
|
702 |
+
|
703 |
+
//Update dimensions of the image in meta
|
704 |
+
$meta['width'] = ! empty( $resized['width'] ) ? $resized['width'] : $meta['width'];
|
705 |
+
$meta['full']['width'] = ! empty( $resized['width'] ) ? $resized['width'] : $meta['width'];
|
706 |
+
|
707 |
+
$meta['height'] = ! empty( $resized['height'] ) ? $resized['height'] : $meta['height'];
|
708 |
+
$meta['full']['height'] = ! empty( $resized['height'] ) ? $resized['height'] : $meta['height'];
|
709 |
+
|
710 |
+
/**
|
711 |
+
* Called after the image have been successfully resized
|
712 |
+
* Can be used to update the stored stats
|
713 |
+
*/
|
714 |
+
do_action( 'wp_smush_image_nextgen_resized', $attachment_id, array( 'stats' => $savings ) );
|
715 |
+
|
716 |
+
/**
|
717 |
+
* Called after the image have been successfully resized
|
718 |
+
* Can be used to update the stored stats
|
719 |
+
*/
|
720 |
+
do_action( 'wp_smush_image_resized', $attachment_id, $savings );
|
721 |
+
}
|
722 |
+
|
723 |
+
return $meta;
|
724 |
+
|
725 |
+
}
|
726 |
+
|
727 |
+
/**
|
728 |
+
* Unlinks a file if none of the thumbnails have same file path
|
729 |
+
*
|
730 |
+
* @param $path Full path of the file to be unlinked
|
731 |
+
* @param $sizes All the available image sizes for the image
|
732 |
+
* @param $image Image object to fetch the full path of all the sizes
|
733 |
+
* @param $storage Gallery storage object
|
734 |
+
*
|
735 |
+
* @return bool Whether the file was unlinked or not
|
736 |
+
*
|
737 |
+
*/
|
738 |
+
function maybe_unlink( $path, $sizes, $image, $storage ) {
|
739 |
+
if ( empty( $path ) || ! is_object( $storage ) || ! is_object( $image ) ) {
|
740 |
+
return false;
|
741 |
+
}
|
742 |
+
|
743 |
+
//Unlink directly if meta value is not specified
|
744 |
+
if ( empty( $sizes ) ) {
|
745 |
+
@unlink( $path );
|
746 |
+
}
|
747 |
+
|
748 |
+
$unlink = true;
|
749 |
+
|
750 |
+
//Check if the file name is similar to one of the image sizes
|
751 |
+
$path_parts = pathinfo( $path );
|
752 |
+
|
753 |
+
$filename = ! empty( $path_parts['basename'] ) ? $path_parts['basename'] : $path_parts['filename'];
|
754 |
+
foreach ( $sizes as $image_size ) {
|
755 |
+
$file_path_size = $storage->get_image_abspath( $image, $image_size );
|
756 |
+
if ( false === strpos( $file_path_size, $filename ) ) {
|
757 |
+
continue;
|
758 |
+
}
|
759 |
+
$unlink = false;
|
760 |
+
}
|
761 |
+
|
762 |
+
//Unlink the file
|
763 |
+
if ( $unlink ) {
|
764 |
+
@unlink( $path );
|
765 |
+
}
|
766 |
+
|
767 |
+
return $unlink;
|
768 |
+
}
|
769 |
+
|
770 |
}//End of Class
|
771 |
+
|
772 |
}//End Of if class not exists
|
773 |
|
774 |
//Extend NextGen Mixin class to smush dynamic images
|
835 |
$stats['size_before'] = $response['data']->before_size;
|
836 |
$stats['time'] = $response['data']->time;
|
837 |
}
|
838 |
+
$stats['sizes'][ $size ] = (object) $WpSmush->_array_fill_placeholders( $WpSmush->_get_size_signature(), (array) $response['data'] );
|
839 |
|
840 |
if ( isset( $image->metadata ) ) {
|
841 |
$image->meta_data['wp_smush'] = $stats;
|
853 |
}
|
854 |
}
|
855 |
}
|
856 |
+
if ( class_exists( 'WpSmushNextGenDynamicThumbs' ) ) {
|
857 |
+
if ( ! get_option( 'ngg_options' ) ) {
|
858 |
return;
|
859 |
}
|
860 |
$storage = C_Gallery_Storage::get_instance();
|
lib/class-wp-smush-resize.php
ADDED
@@ -0,0 +1,400 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package WP Smush
|
4 |
+
* @subpackage Admin
|
5 |
+
* @version 2.3
|
6 |
+
*
|
7 |
+
* @author Umesh Kumar <umesh@incsub.com>
|
8 |
+
*
|
9 |
+
* @copyright (c) 2016, Incsub (http://incsub.com)
|
10 |
+
*/
|
11 |
+
if ( ! class_exists( 'WpSmushResize' ) ) {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Class WpSmushResize
|
15 |
+
*/
|
16 |
+
class WpSmushResize {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var int Specified width for resizing images
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
public $max_w = 0;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var int Specified Height for resizing images
|
26 |
+
*
|
27 |
+
*/
|
28 |
+
public $max_h = 0;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @var bool If resizing is enabled or not
|
32 |
+
*/
|
33 |
+
public $resize_enabled = false;
|
34 |
+
|
35 |
+
function __construct() {
|
36 |
+
/**
|
37 |
+
* Initialize class variables, after all stuff has been loaded
|
38 |
+
*/
|
39 |
+
add_action( 'wp_loaded', array( $this, 'initialize' ) );
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
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;
|
54 |
+
$this->max_h = ! empty( $resize_sizes['height'] ) ? $resize_sizes['height'] : 0;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Check whether Image should be resized or not
|
59 |
+
*
|
60 |
+
* @param string $params
|
61 |
+
* @param string $action
|
62 |
+
*
|
63 |
+
* @return bool
|
64 |
+
*/
|
65 |
+
private function should_resize( $id = '' ) {
|
66 |
+
|
67 |
+
//If resizing not enabled, or if both max width and height is set to 0, return
|
68 |
+
if ( ! $this->resize_enabled || ( $this->max_w == 0 && $this->max_h == 0 ) ) {
|
69 |
+
return false;
|
70 |
+
}
|
71 |
+
|
72 |
+
$file_path = get_attached_file( $id );
|
73 |
+
|
74 |
+
if ( ! empty( $file_path ) ) {
|
75 |
+
|
76 |
+
// Skip: if "noresize" is included in the filename, Thanks to Imsanity
|
77 |
+
if ( strpos( $file_path, 'noresize' ) !== false ) {
|
78 |
+
return false;
|
79 |
+
}
|
80 |
+
|
81 |
+
//If file doesn't exists, return
|
82 |
+
if ( ! file_exists( $file_path ) ) {
|
83 |
+
return false;
|
84 |
+
}
|
85 |
+
|
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 );
|
93 |
+
|
94 |
+
$mime_supported = in_array( $mime, $wpsmushit_admin->mime_types );
|
95 |
+
|
96 |
+
//If type of upload doesn't matches the criteria return
|
97 |
+
if ( ! empty( $mime ) && ! $mime_supported = apply_filters( 'wp_smush_resmush_mime_supported', $mime_supported, $mime ) ) {
|
98 |
+
return false;
|
99 |
+
}
|
100 |
+
//Check if already resized
|
101 |
+
$resize_meta = get_post_meta( $id, WP_SMUSH_PREFIX . 'resize_savings', true );
|
102 |
+
if ( ! empty( $resize_meta ) ) {
|
103 |
+
return false;
|
104 |
+
}
|
105 |
+
|
106 |
+
return true;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Handles the Auto resizing of new uploaded images
|
111 |
+
*
|
112 |
+
* @param array $upload
|
113 |
+
* @param string $action
|
114 |
+
*
|
115 |
+
* @return array $upload
|
116 |
+
*/
|
117 |
+
function auto_resize( $id, $meta ) {
|
118 |
+
|
119 |
+
if ( empty( $id ) || ! wp_attachment_is_image( $id ) ) {
|
120 |
+
return $meta;
|
121 |
+
}
|
122 |
+
|
123 |
+
//Do not perform resize while restoring images/ Editing images
|
124 |
+
if ( ! empty( $_REQUEST['do'] ) && ( 'restore' == $_REQUEST['do'] || 'scale' == $_REQUEST['do'] ) ) {
|
125 |
+
return $meta;
|
126 |
+
}
|
127 |
+
|
128 |
+
//Check if the image should be resized or not
|
129 |
+
$should_resize = $this->should_resize( $id );
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Filter whether the uploaded image should be resized or not
|
133 |
+
*
|
134 |
+
* @since 2.3
|
135 |
+
*
|
136 |
+
* @param bool $should_resize
|
137 |
+
*
|
138 |
+
* @param array $upload {
|
139 |
+
* Array of upload data.
|
140 |
+
*
|
141 |
+
* @type string $file Filename of the newly-uploaded file.
|
142 |
+
* @type string $url URL of the uploaded file.
|
143 |
+
* @type string $type File type.
|
144 |
+
* }
|
145 |
+
*
|
146 |
+
* @param string $context The type of upload action. Values include 'upload' or 'sideload'.
|
147 |
+
*
|
148 |
+
*/
|
149 |
+
if ( ! $should_resize = apply_filters( 'wp_smush_resize_uploaded_image', $should_resize, $id, $meta ) ) {
|
150 |
+
return $meta;
|
151 |
+
}
|
152 |
+
|
153 |
+
//Good to go
|
154 |
+
$file_path = get_attached_file( $id );
|
155 |
+
|
156 |
+
$original_file_size = filesize( $file_path );
|
157 |
+
|
158 |
+
$resize = $this->perform_resize( $file_path, $original_file_size, $id, $meta );
|
159 |
+
|
160 |
+
//If resize wasn't successful
|
161 |
+
if ( ! $resize ) {
|
162 |
+
return $meta;
|
163 |
+
}
|
164 |
+
|
165 |
+
//Else Replace the Original file with resized file
|
166 |
+
$replaced = $this->replcae_original_image( $file_path, $resize, $id, $meta );
|
167 |
+
|
168 |
+
if ( $replaced ) {
|
169 |
+
//Updated File size
|
170 |
+
$u_file_size = filesize( $file_path );
|
171 |
+
|
172 |
+
$savings['bytes'] = $original_file_size > $u_file_size ? $original_file_size - $u_file_size : 0;
|
173 |
+
$savings['size_before'] = $original_file_size;
|
174 |
+
$savings['size_after'] = $u_file_size;
|
175 |
+
|
176 |
+
//Store savings in meta data
|
177 |
+
if ( ! empty( $savings ) ) {
|
178 |
+
update_post_meta( $id, WP_SMUSH_PREFIX . 'resize_savings', $savings );
|
179 |
+
}
|
180 |
+
|
181 |
+
$meta['width'] = ! empty( $resize['width'] ) ? $resize['width'] : $meta['width'];
|
182 |
+
$meta['height'] = ! empty( $resize['height'] ) ? $resize['height'] : $meta['height'];
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Called after the image have been successfully resized
|
186 |
+
* Can be used to update the stored stats
|
187 |
+
*/
|
188 |
+
do_action( 'wp_smush_image_resized', $id, $savings );
|
189 |
+
|
190 |
+
}
|
191 |
+
|
192 |
+
return $meta;
|
193 |
+
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Generates the new image for specified width and height,
|
198 |
+
* Checks if the size of generated image is greater,
|
199 |
+
*
|
200 |
+
* @param $file_path Original File path
|
201 |
+
*
|
202 |
+
* @return bool, If the image generation was succesfull
|
203 |
+
*/
|
204 |
+
function perform_resize( $file_path, $original_file_size, $id, $meta = '', $unlink = true ) {
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Filter the resize image dimensions
|
208 |
+
*
|
209 |
+
* @since 2.3
|
210 |
+
*
|
211 |
+
* @param array $sizes {
|
212 |
+
* Array of sizes containing max width and height for all the uploaded images.
|
213 |
+
*
|
214 |
+
* @type int $width Maximum Width For resizing
|
215 |
+
* @type int $height Maximum Height for resizing
|
216 |
+
* }
|
217 |
+
*
|
218 |
+
* @param string $file_path Original Image file path
|
219 |
+
*
|
220 |
+
* @param array $upload {
|
221 |
+
* Array of upload data.
|
222 |
+
*
|
223 |
+
* @type string $file Filename of the newly-uploaded file.
|
224 |
+
* @type string $url URL of the uploaded file.
|
225 |
+
* @type string $type File type.
|
226 |
+
* }
|
227 |
+
*
|
228 |
+
*/
|
229 |
+
$sizes = apply_filters( 'wp_smush_resize_sizes', array(
|
230 |
+
'width' => $this->max_w,
|
231 |
+
'height' => $this->max_h
|
232 |
+
), $file_path, $id );
|
233 |
+
|
234 |
+
$data = image_make_intermediate_size( $file_path, $sizes['width'], $sizes['height'] );
|
235 |
+
|
236 |
+
//If the image wasn't resized
|
237 |
+
if ( empty( $data['file'] ) || is_wp_error( $data ) ) {
|
238 |
+
return false;
|
239 |
+
}
|
240 |
+
|
241 |
+
//Check if file size is lesser than original image
|
242 |
+
$resize_path = path_join( dirname( $file_path ), $data['file'] );
|
243 |
+
if ( ! file_exists( $resize_path ) ) {
|
244 |
+
return false;
|
245 |
+
}
|
246 |
+
|
247 |
+
$data['file_path'] = $resize_path;
|
248 |
+
|
249 |
+
$file_size = filesize( $resize_path );
|
250 |
+
if ( $file_size > $original_file_size ) {
|
251 |
+
//Don't Unlink for nextgen images
|
252 |
+
if( $unlink ) {
|
253 |
+
$this->maybe_unlink( $resize_path, $meta );
|
254 |
+
}
|
255 |
+
|
256 |
+
return false;
|
257 |
+
}
|
258 |
+
|
259 |
+
//Store filesize
|
260 |
+
$data['filesize'] = $file_size;
|
261 |
+
|
262 |
+
return $data;
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Replace the original file with resized file
|
267 |
+
*
|
268 |
+
* @param $upload
|
269 |
+
*
|
270 |
+
* @param $resized
|
271 |
+
*
|
272 |
+
*/
|
273 |
+
function replcae_original_image( $file_path, $resized, $attachment_id = '', $meta = '' ) {
|
274 |
+
$replaced = false;
|
275 |
+
|
276 |
+
//Take Backup, if we have to, off by default
|
277 |
+
$this->backup_image( $file_path, $attachment_id, $meta );
|
278 |
+
|
279 |
+
$replaced = @copy( $resized['file_path'], $file_path );
|
280 |
+
$this->maybe_unlink( $resized['file_path'], $meta );
|
281 |
+
|
282 |
+
return $replaced;
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Creates a WordPress backup of original image, Disabled by default
|
287 |
+
*
|
288 |
+
* @param $upload
|
289 |
+
*
|
290 |
+
* @param $attachment_id
|
291 |
+
*
|
292 |
+
* @param $meta
|
293 |
+
*/
|
294 |
+
function backup_image( $path, $attachment_id, $meta ) {
|
295 |
+
|
296 |
+
/**
|
297 |
+
* Allows to turn on the backup for resized image
|
298 |
+
*/
|
299 |
+
$backup = apply_filters( 'wp_smush_resize_create_backup', false );
|
300 |
+
|
301 |
+
//If we don't have a attachment id, return
|
302 |
+
if ( empty( $attachment_id ) || ! $backup ) {
|
303 |
+
return;
|
304 |
+
}
|
305 |
+
|
306 |
+
//Creating Backup
|
307 |
+
$backup_sizes = get_post_meta( $attachment_id, '_wp_attachment_backup_sizes', true );
|
308 |
+
|
309 |
+
if ( ! is_array( $backup_sizes ) ) {
|
310 |
+
$backup_sizes = array();
|
311 |
+
}
|
312 |
+
|
313 |
+
//There is alrready a backup, no need to create one
|
314 |
+
if ( ! empty( $backup_sizes['full-orig'] ) ) {
|
315 |
+
return;
|
316 |
+
}
|
317 |
+
|
318 |
+
//Create a copy of original
|
319 |
+
if ( empty( $path ) ) {
|
320 |
+
$path = get_attached_file( $attachment_id );
|
321 |
+
}
|
322 |
+
|
323 |
+
$path_parts = pathinfo( $path );
|
324 |
+
$filename = $path_parts['filename'];
|
325 |
+
$filename .= '-orig';
|
326 |
+
|
327 |
+
//Backup Path
|
328 |
+
$backup_path = path_join( $path_parts['dirname'], $filename ) . ".{$path_parts['extension']}";
|
329 |
+
|
330 |
+
//Create a copy
|
331 |
+
if ( file_exists( $path ) ) {
|
332 |
+
$copy_created = @copy( $path, $backup_path );
|
333 |
+
if ( $copy_created ) {
|
334 |
+
$backup_sizes['full-orig'] = array(
|
335 |
+
'file' => basename( $backup_path ),
|
336 |
+
'width' => $meta['width'],
|
337 |
+
'height' => $meta['height']
|
338 |
+
);
|
339 |
+
//Save in Attachment meta
|
340 |
+
update_post_meta( $attachment_id, '_wp_attachment_backup_sizes', $backup_sizes );
|
341 |
+
}
|
342 |
+
}
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* @param $filename
|
347 |
+
*
|
348 |
+
* @return mixed
|
349 |
+
*/
|
350 |
+
function file_name( $filename ) {
|
351 |
+
if ( empty( $filename ) ) {
|
352 |
+
return $filename;
|
353 |
+
}
|
354 |
+
|
355 |
+
return $filename . 'tmp';
|
356 |
+
}
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Do not unlink the resized file if the name is similar to one of the image sizes
|
360 |
+
*
|
361 |
+
* @param $path Image File Path
|
362 |
+
* @param $meta Image Meta
|
363 |
+
*
|
364 |
+
* @return bool
|
365 |
+
*/
|
366 |
+
function maybe_unlink( $path, $meta ) {
|
367 |
+
if ( empty( $path ) ) {
|
368 |
+
return true;
|
369 |
+
}
|
370 |
+
|
371 |
+
//Unlink directly if meta value is not specified
|
372 |
+
if ( empty( $meta ) || empty( $meta['sizes'] ) ) {
|
373 |
+
@unlink( $path );
|
374 |
+
}
|
375 |
+
|
376 |
+
$unlink = true;
|
377 |
+
//Check if the file name is similar to one of the image sizes
|
378 |
+
$path_parts = pathinfo( $path );
|
379 |
+
$filename = ! empty( $path_parts['basename'] ) ? $path_parts['basename'] : $path_parts['filename'];
|
380 |
+
foreach ( $meta['sizes'] as $image_size ) {
|
381 |
+
if ( false === strpos( $image_size['file'], $filename ) ) {
|
382 |
+
continue;
|
383 |
+
}
|
384 |
+
$unlink = false;
|
385 |
+
}
|
386 |
+
if ( $unlink ) {
|
387 |
+
@unlink( $path );
|
388 |
+
}
|
389 |
+
|
390 |
+
return true;
|
391 |
+
|
392 |
+
}
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* Initialise class
|
397 |
+
*/
|
398 |
+
global $wpsmush_resize;
|
399 |
+
$wpsmush_resize = new WpSmushResize();
|
400 |
+
}
|
lib/class-wp-smush-stats.php
ADDED
@@ -0,0 +1,422 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package WP Smush
|
4 |
+
* @subpackage Admin
|
5 |
+
* @version 2.3
|
6 |
+
*
|
7 |
+
* @author Umesh Kumar <umesh@incsub.com>
|
8 |
+
*
|
9 |
+
* @copyright (c) 2016, Incsub (http://incsub.com)
|
10 |
+
*/
|
11 |
+
if ( ! class_exists( 'WpSmushStats' ) ) {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Class WpSmushStats
|
15 |
+
*/
|
16 |
+
class WpSmushStats {
|
17 |
+
function __construct() {
|
18 |
+
//Update resize savings
|
19 |
+
add_action( 'wp_smush_image_resized', array( $this, 'resize_savings' ) );
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Total Image count
|
24 |
+
* @return int
|
25 |
+
*/
|
26 |
+
function total_count() {
|
27 |
+
global $wpsmushit_admin;
|
28 |
+
|
29 |
+
//Remove the Filters added by WP Media Folder
|
30 |
+
$this->remove_wmf_filters();
|
31 |
+
|
32 |
+
$count = 0;
|
33 |
+
|
34 |
+
$counts = wp_count_attachments( $wpsmushit_admin->mime_types );
|
35 |
+
foreach ( $wpsmushit_admin->mime_types as $mime ) {
|
36 |
+
if ( isset( $counts->$mime ) ) {
|
37 |
+
$count += $counts->$mime;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
// send the count
|
42 |
+
return $count;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Optimised images count
|
47 |
+
*
|
48 |
+
* @param bool $return_ids
|
49 |
+
*
|
50 |
+
* @return array|int
|
51 |
+
*/
|
52 |
+
function smushed_count( $return_ids ) {
|
53 |
+
global $wpsmushit_admin;
|
54 |
+
|
55 |
+
//Don't query again, if the variable is already set
|
56 |
+
if ( ! $return_ids && ! empty( $wpsmushit_admin->smushed_count ) && $wpsmushit_admin->smushed_count > 0 ) {
|
57 |
+
return $wpsmushit_admin->smushed_count;
|
58 |
+
}
|
59 |
+
|
60 |
+
$query = array(
|
61 |
+
'fields' => 'ids',
|
62 |
+
'post_type' => 'attachment',
|
63 |
+
'post_status' => 'inherit',
|
64 |
+
'post_mime_type' => $wpsmushit_admin->mime_types,
|
65 |
+
'order' => 'ASC',
|
66 |
+
'posts_per_page' => - 1,
|
67 |
+
'meta_key' => 'wp-smpro-smush-data',
|
68 |
+
'no_found_rows' => true
|
69 |
+
);
|
70 |
+
|
71 |
+
//Remove the Filters added by WP Media Folder
|
72 |
+
$this->remove_wmf_filters();
|
73 |
+
|
74 |
+
$results = new WP_Query( $query );
|
75 |
+
|
76 |
+
if ( ! is_wp_error( $results ) && $results->post_count > 0 ) {
|
77 |
+
if ( ! $return_ids ) {
|
78 |
+
//return Post Count
|
79 |
+
return $results->post_count;
|
80 |
+
} else {
|
81 |
+
//Return post ids
|
82 |
+
return $results->posts;
|
83 |
+
}
|
84 |
+
} else {
|
85 |
+
return false;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Returns/Updates the number of images Super Smushed
|
91 |
+
*
|
92 |
+
* @param string $type media/nextgen, Type of images to get/set the super smushed count for
|
93 |
+
*
|
94 |
+
* @param array $attachments Optional, By default Media attachments will be fetched
|
95 |
+
*
|
96 |
+
* @return array|mixed|void
|
97 |
+
*
|
98 |
+
*/
|
99 |
+
function super_smushed_count( $type = 'media', $attachments = '' ) {
|
100 |
+
|
101 |
+
if ( 'media' == $type ) {
|
102 |
+
$count = $this->media_super_smush_count();
|
103 |
+
} else {
|
104 |
+
$key = 'wp-smush-super_smushed_nextgen';
|
105 |
+
|
106 |
+
//Flag to check if we need to re-evaluate the count
|
107 |
+
$revaluate = false;
|
108 |
+
|
109 |
+
$super_smushed = get_option( $key, false );
|
110 |
+
|
111 |
+
//Check if need to revalidate
|
112 |
+
if ( ! $super_smushed || empty( $super_smushed ) || empty( $super_smushed['ids'] ) ) {
|
113 |
+
|
114 |
+
$super_smushed = array(
|
115 |
+
'ids' => array()
|
116 |
+
);
|
117 |
+
|
118 |
+
$revaluate = true;
|
119 |
+
} else {
|
120 |
+
$last_checked = $super_smushed['timestamp'];
|
121 |
+
|
122 |
+
$diff = $last_checked - current_time( 'timestamp' );
|
123 |
+
|
124 |
+
//Difference in hour
|
125 |
+
$diff_h = $diff / 3600;
|
126 |
+
|
127 |
+
//if last checked was more than 1 hours.
|
128 |
+
if ( $diff_h > 1 ) {
|
129 |
+
$revaluate = true;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
//Do not Revaluate stats if nextgen attachments are not provided
|
133 |
+
if ( 'nextgen' == $type && empty( $attachments ) && $revaluate ) {
|
134 |
+
$revaluate = false;
|
135 |
+
}
|
136 |
+
|
137 |
+
//Need to scan all the image
|
138 |
+
if ( $revaluate ) {
|
139 |
+
//Get all the Smushed attachments ids
|
140 |
+
$super_smushed_images = $this->get_lossy_attachments( $attachments, false );
|
141 |
+
|
142 |
+
if ( ! empty( $super_smushed_images ) && is_array( $super_smushed_images ) ) {
|
143 |
+
//Iterate over all the attachments to check if it's already there in list, else add it
|
144 |
+
foreach ( $super_smushed_images as $id ) {
|
145 |
+
if ( ! in_array( $id, $super_smushed['ids'] ) ) {
|
146 |
+
$super_smushed['ids'][] = $id;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
$super_smushed['timestamp'] = current_time( 'timestamp' );
|
152 |
+
|
153 |
+
update_option( $key, $super_smushed );
|
154 |
+
}
|
155 |
+
|
156 |
+
$count = ! empty( $super_smushed['ids'] ) ? count( $super_smushed['ids'] ) : 0;
|
157 |
+
}
|
158 |
+
|
159 |
+
return $count;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Updates the Meta for existing smushed images and retrieves the count of Super Smushed images
|
164 |
+
*
|
165 |
+
* @return int Count of Super Smushed images
|
166 |
+
*
|
167 |
+
*/
|
168 |
+
function media_super_smush_count( $return_ids = false ) {
|
169 |
+
global $wpsmushit_admin;
|
170 |
+
$lossy_update = false;
|
171 |
+
//Check if we have updated the stats for existing images, One time
|
172 |
+
if ( ! $lossy_updated = get_option( WP_SMUSH_PREFIX . 'lossy-updated' ) ) {
|
173 |
+
|
174 |
+
//Get all the smushed attachments
|
175 |
+
$attachments = $this->get_lossy_attachments( '', false );
|
176 |
+
if ( ! empty( $attachments ) ) {
|
177 |
+
foreach ( $attachments as $attachment ) {
|
178 |
+
update_post_meta( $attachment, WP_SMUSH_PREFIX . 'lossy', 1 );
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
//Get all the attachments with wp-smush-lossy
|
183 |
+
$limit = $wpsmushit_admin->query_limit();
|
184 |
+
$get_posts = true;
|
185 |
+
$super_smushed = array();
|
186 |
+
$args = array(
|
187 |
+
'fields' => 'ids',
|
188 |
+
'post_type' => 'attachment',
|
189 |
+
'post_status' => 'any',
|
190 |
+
'post_mime_type' => $wpsmushit_admin->mime_types,
|
191 |
+
'orderby' => 'ID',
|
192 |
+
'order' => 'DESC',
|
193 |
+
'posts_per_page' => $limit,
|
194 |
+
'offset' => 0,
|
195 |
+
'meta_query' => array(
|
196 |
+
array(
|
197 |
+
'key' => 'wp-smush-lossy',
|
198 |
+
'value' => 1
|
199 |
+
)
|
200 |
+
),
|
201 |
+
'update_post_term_cache' => false,
|
202 |
+
'no_found_rows' => true,
|
203 |
+
);
|
204 |
+
//Loop Over to get all the attachments
|
205 |
+
while ( $get_posts ) {
|
206 |
+
|
207 |
+
//Remove the Filters added by WP Media Folder
|
208 |
+
$this->remove_wmf_filters();
|
209 |
+
|
210 |
+
$query = new WP_Query( $args );
|
211 |
+
|
212 |
+
if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
|
213 |
+
//Merge the results
|
214 |
+
$super_smushed = array_merge( $super_smushed, $query->posts );
|
215 |
+
|
216 |
+
//Update the offset
|
217 |
+
$args['offset'] += $limit;
|
218 |
+
} else {
|
219 |
+
//If we didn't get any posts from query, set $get_posts to false
|
220 |
+
$get_posts = false;
|
221 |
+
}
|
222 |
+
|
223 |
+
//If total Count is set, and it is alread lesser than offset, don't query
|
224 |
+
if ( ! empty( $this->total_count ) && $this->total_count < $args['offset'] ) {
|
225 |
+
$get_posts = false;
|
226 |
+
}
|
227 |
+
}
|
228 |
+
if ( ! $lossy_updated ) {
|
229 |
+
update_option( 'wp-smush-lossy-updated', true );
|
230 |
+
}
|
231 |
+
|
232 |
+
return $return_ids ? $super_smushed : count( $super_smushed );
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Remove any pre_get_posts_filters added by WP Media Folder plugin
|
237 |
+
*/
|
238 |
+
function remove_wmf_filters() {
|
239 |
+
//remove any filters added b WP media Folder plugin to get the all attachments
|
240 |
+
if ( class_exists( 'Wp_Media_Folder' ) ) {
|
241 |
+
global $wp_media_folder;
|
242 |
+
if ( is_object( $wp_media_folder ) ) {
|
243 |
+
remove_filter( 'pre_get_posts', array( $wp_media_folder, 'wpmf_pre_get_posts1' ) );
|
244 |
+
remove_filter( 'pre_get_posts', array( $wp_media_folder, 'wpmf_pre_get_posts' ), 0, 1 );
|
245 |
+
}
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Get the savings from image resizing, And force update if set to true
|
251 |
+
*
|
252 |
+
* @param bool $force_update , Whether to Re-Calculate all the stats or not
|
253 |
+
*
|
254 |
+
* @param bool $format Format the Bytes in readable format
|
255 |
+
*
|
256 |
+
* @return array|bool|mixed|string Array of {
|
257 |
+
* 'bytes',
|
258 |
+
* 'before_size',
|
259 |
+
* 'after_size'
|
260 |
+
* }
|
261 |
+
*
|
262 |
+
*/
|
263 |
+
function resize_savings( $force_update = true, $format = false ) {
|
264 |
+
$savings = '';
|
265 |
+
|
266 |
+
if ( ! $force_update ) {
|
267 |
+
$savings = wp_cache_get( WP_SMUSH_PREFIX . 'resize_savings', 'wp-smush' );
|
268 |
+
}
|
269 |
+
//If nothing in cache, Calculate it
|
270 |
+
if ( empty( $savings ) || $force_update ) {
|
271 |
+
global $wpsmushit_admin;
|
272 |
+
$savings = array(
|
273 |
+
'bytes' => 0,
|
274 |
+
'size_before' => 0,
|
275 |
+
'size_after' => 0,
|
276 |
+
);
|
277 |
+
|
278 |
+
//Get the List of resized images
|
279 |
+
$resized_images = $this->resize_images();
|
280 |
+
|
281 |
+
//Iterate over them
|
282 |
+
foreach ( $resized_images as $id ) {
|
283 |
+
$meta = get_post_meta( $id, WP_SMUSH_PREFIX . 'resize_savings', true );
|
284 |
+
if ( ! empty( $meta ) && ! empty( $meta['bytes'] ) ) {
|
285 |
+
$savings['bytes'] += intval( $meta['bytes'] );
|
286 |
+
$savings['size_before'] += intval( $meta['size_before'] );
|
287 |
+
$savings['size_after'] += intval( $meta['size_after'] );
|
288 |
+
}
|
289 |
+
}
|
290 |
+
|
291 |
+
if ( $format ) {
|
292 |
+
$savings['bytes'] = $wpsmushit_admin->format_bytes( $savings['bytes'] );
|
293 |
+
}
|
294 |
+
|
295 |
+
wp_cache_set( WP_SMUSH_PREFIX . 'resize_savings', $savings, 'wp-smush' );
|
296 |
+
}
|
297 |
+
|
298 |
+
return $savings;
|
299 |
+
}
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Get all the resized images
|
303 |
+
*
|
304 |
+
* @return array Array of post ids of all the resized images
|
305 |
+
*
|
306 |
+
*/
|
307 |
+
function resize_images() {
|
308 |
+
global $wpsmushit_admin;
|
309 |
+
$limit = $wpsmushit_admin->query_limit();
|
310 |
+
$limit = ! empty( $wpsmushit_admin->total_count ) && $wpsmushit_admin->total_count < $limit ? $wpsmushit_admin->total_count : $limit;
|
311 |
+
$get_posts = true;
|
312 |
+
$resized_images = array();
|
313 |
+
$args = array(
|
314 |
+
'fields' => 'ids',
|
315 |
+
'post_type' => 'attachment',
|
316 |
+
'post_status' => 'inherit',
|
317 |
+
'post_mime_type' => $wpsmushit_admin->mime_types,
|
318 |
+
'orderby' => 'ID',
|
319 |
+
'order' => 'DESC',
|
320 |
+
'posts_per_page' => $limit,
|
321 |
+
'offset' => 0,
|
322 |
+
'meta_key' => WP_SMUSH_PREFIX . 'resize_savings',
|
323 |
+
'update_post_term_cache' => false,
|
324 |
+
'no_found_rows' => true,
|
325 |
+
);
|
326 |
+
//Loop Over to get all the attachments
|
327 |
+
while ( $get_posts ) {
|
328 |
+
|
329 |
+
//Remove the Filters added by WP Media Folder
|
330 |
+
$this->remove_wmf_filters();
|
331 |
+
|
332 |
+
$query = new WP_Query( $args );
|
333 |
+
|
334 |
+
if ( ! empty( $query->post_count ) && sizeof( $query->posts ) > 0 ) {
|
335 |
+
//Merge the results
|
336 |
+
$resized_images = array_merge( $resized_images, $query->posts );
|
337 |
+
|
338 |
+
//Update the offset
|
339 |
+
$args['offset'] += $limit;
|
340 |
+
} else {
|
341 |
+
//If we didn't get any posts from query, set $get_posts to false
|
342 |
+
$get_posts = false;
|
343 |
+
}
|
344 |
+
|
345 |
+
//If total Count is set, and it is alread lesser than offset, don't query
|
346 |
+
if ( ! empty( $wpsmushit_admin->total_count ) && $wpsmushit_admin->total_count < $args['offset'] ) {
|
347 |
+
$get_posts = false;
|
348 |
+
}
|
349 |
+
}
|
350 |
+
|
351 |
+
return $resized_images;
|
352 |
+
}
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Returns the ids and meta which are losslessly compressed
|
356 |
+
*
|
357 |
+
* Called only if the meta key isn't updated for old images, else it is not used
|
358 |
+
*
|
359 |
+
* @return array
|
360 |
+
*/
|
361 |
+
function get_lossy_attachments( $attachments = '', $return_count = true ) {
|
362 |
+
|
363 |
+
$lossy_attachments = array();
|
364 |
+
$count = 0;
|
365 |
+
|
366 |
+
if ( empty( $attachments ) ) {
|
367 |
+
//Fetch all the smushed attachment ids
|
368 |
+
$attachments = $this->smushed_count( true );
|
369 |
+
}
|
370 |
+
|
371 |
+
//If we dont' have any attachments
|
372 |
+
if ( empty( $attachments ) || 0 == count( $attachments ) ) {
|
373 |
+
return 0;
|
374 |
+
}
|
375 |
+
|
376 |
+
//Check if image is lossless or lossy
|
377 |
+
foreach ( $attachments as $attachment ) {
|
378 |
+
|
379 |
+
//Check meta for lossy value
|
380 |
+
$smush_data = ! empty( $attachment->smush_data ) ? maybe_unserialize( $attachment->smush_data ) : '';
|
381 |
+
|
382 |
+
//For Nextgen Gallery images
|
383 |
+
if ( empty( $smush_data ) && is_array( $attachment ) && ! empty( $attachment['wp_smush'] ) ) {
|
384 |
+
$smush_data = ! empty( $attachment['wp_smush'] ) ? $attachment['wp_smush'] : '';
|
385 |
+
}
|
386 |
+
|
387 |
+
//Return if not smushed
|
388 |
+
if ( empty( $smush_data ) ) {
|
389 |
+
continue;
|
390 |
+
}
|
391 |
+
|
392 |
+
//if stats not set or lossy is not set for attachment, return
|
393 |
+
if ( empty( $smush_data['stats'] ) || ! isset( $smush_data['stats']['lossy'] ) ) {
|
394 |
+
continue;
|
395 |
+
}
|
396 |
+
|
397 |
+
//Add to array if lossy is not 1
|
398 |
+
if ( 1 == $smush_data['stats']['lossy'] ) {
|
399 |
+
$count ++;
|
400 |
+
if ( ! empty( $attachment->attachment_id ) ) {
|
401 |
+
$lossy_attachments[] = $attachment->attachment_id;
|
402 |
+
} elseif ( is_array( $attachment ) && ! empty( $attachment['pid'] ) ) {
|
403 |
+
$lossy_attachments[] = $attachment['pid'];
|
404 |
+
}
|
405 |
+
}
|
406 |
+
}
|
407 |
+
unset( $attachments );
|
408 |
+
|
409 |
+
if ( $return_count ) {
|
410 |
+
return $count;
|
411 |
+
}
|
412 |
+
|
413 |
+
return $lossy_attachments;
|
414 |
+
}
|
415 |
+
}
|
416 |
+
|
417 |
+
/**
|
418 |
+
* Initialise class
|
419 |
+
*/
|
420 |
+
global $wpsmush_stats;
|
421 |
+
$wpsmush_stats = new WpSmushStats();
|
422 |
+
}
|
lib/class-wp-smush-ui.php
CHANGED
@@ -117,7 +117,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
|
|
117 |
* Outputs the Smush stats for the site
|
118 |
*/
|
119 |
function smush_stats_container() {
|
120 |
-
global $WpSmush, $wpsmushit_admin;
|
121 |
|
122 |
//If we have resmush list, smushed_count = totalcount - resmush count, else smushed_count
|
123 |
$smushed_count = ( $resmush_count = count( $wpsmushit_admin->resmush_ids ) ) > 0 ? $wpsmushit_admin->total_count - ( $resmush_count + $wpsmushit_admin->remaining_count ) : $wpsmushit_admin->smushed_count;
|
@@ -140,25 +140,40 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
|
|
140 |
<span
|
141 |
class="float-r wp-smush-stats"><strong><?php echo $wpsmushit_admin->stats['human'] > 0 ? $wpsmushit_admin->stats['human'] : "0MB"; ?></strong></span>
|
142 |
</div>
|
143 |
-
<hr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
<div class="row smush-attachments">
|
145 |
-
<span
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
</div><?php
|
151 |
/**
|
152 |
* Allows to hide the Super Smush stats as it might be heavy for some users
|
153 |
*/
|
154 |
if ( $WpSmush->is_pro() && apply_filters( 'wp_smush_show_lossy_stats', true ) ) {
|
155 |
-
$wpsmushit_admin->super_smushed = $
|
156 |
<hr>
|
157 |
<div class="row super-smush-attachments">
|
158 |
<span class="float-l wp-smush-stats-label"><strong><?php esc_html_e( "ATTACHMENTS SUPER-SMUSHED", "wp-smushit" ); ?></strong></span>
|
159 |
<span class="float-r wp-smush-stats<?php echo $WpSmush->lossy_enabled ? '' : ' wp-smush-lossy-disabled-wrap' ?>"><?php
|
160 |
if ( $WpSmush->lossy_enabled ) {
|
161 |
-
echo '<strong><span class="smushed-count">' . intval( $wpsmushit_admin->super_smushed ) . '</span>/' . $wpsmushit_admin->total_count . '</strong>';
|
162 |
} else {
|
163 |
printf( esc_html__( "%sENABLE%s", "wp-smushit" ), '<button class="wp-smush-lossy-enable button button-small">', '</button>' );
|
164 |
} ?>
|
@@ -257,6 +272,13 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
|
|
257 |
global $wpsmushit_admin;
|
258 |
echo '<div class="box-container">
|
259 |
<form id="wp-smush-settings-form" method="post">';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
260 |
//Smush auto key
|
261 |
$opt_auto = WP_SMUSH_PREFIX . 'auto';
|
262 |
//Auto value
|
@@ -270,8 +292,18 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
|
|
270 |
|
271 |
//Keep Exif
|
272 |
$opt_keep_exif = WP_SMUSH_PREFIX . 'keep_exif';
|
273 |
-
|
274 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
<!-- A tab index of 0 keeps the element in tab flow with other elements with an unspecified tab index which are still tabbable.) -->
|
276 |
<div class='wp-smush-setting-row wp-smush-basic'>
|
277 |
<label class="inline-label" for="<?php echo $opt_auto; ?>" tabindex="0">
|
@@ -304,7 +336,34 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
|
|
304 |
value="1" name="<?php echo $opt_keep_exif; ?>" tabindex="0">
|
305 |
<label class="toggle-label" for="<?php echo $opt_keep_exif; ?>"></label>
|
306 |
</span>
|
307 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
|
309 |
do_action( 'wp_smush_after_basic_settings' );
|
310 |
$this->advanced_settings( $configure_screen );
|
@@ -323,7 +382,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
|
|
323 |
$this->smush_page_header();
|
324 |
|
325 |
//Show Configure screen for only a new installation and for only network admins
|
326 |
-
if ( ( 1 != get_site_option( 'wp-smush-hide_smush_welcome' )
|
327 |
echo '<div class="block float-l smush-welcome-wrapper">';
|
328 |
$this->welcome_screen();
|
329 |
echo '</div>';
|
@@ -391,12 +450,12 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
|
|
391 |
if ( class_exists( 'WP_Hummingbird' ) ) {
|
392 |
return;
|
393 |
}
|
394 |
-
$this->container_header( 'wp-smush-hb-adv', 'wp-smush-hb-promo', "OH YEAH, SMUSHING ON
|
395 |
<div class="box-content">
|
396 |
<span class="wp-smush-hummingbird-image tc">
|
397 |
<img src="<?php echo WP_SMUSH_URL . 'assets/images/hummingbird.png'; ?>"
|
398 |
alt="<?php esc_html_e( "BOOST YOUR PERFORMANCE - HUMMINGBIRD", "wp-smushit" ); ?>">
|
399 |
-
|
400 |
<p class="wp-smush-promo-content tc roboto-medium">Hummingbird goes beyond Smush compression with
|
401 |
minification, caching, performance monitoring and more - every millisecond counts!</p>
|
402 |
<span class="wp-smush-hb-cta tc roboto-medium">
|
@@ -432,7 +491,7 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
|
|
432 |
} else { ?>
|
433 |
<!-- Hide All done div if there are images pending -->
|
434 |
<div class="wp-smush-notice wp-smush-all-done<?php echo $all_done ? '' : ' hidden' ?>" tabindex="0">
|
435 |
-
<i class="dev-icon dev-icon-tick"></i><?php esc_html_e( "
|
436 |
</div>
|
437 |
<div class="wp-smush-bulk-wrapper <?php echo $all_done ? ' hidden' : ''; ?>"><?php
|
438 |
//If all the images in media library are smushed
|
@@ -443,17 +502,20 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
|
|
443 |
if ( $wpsmushit_admin->remaining_count > 0 ) {
|
444 |
$class = count( $wpsmushit_admin->resmush_ids ) > 0 ? ' hidden' : '';
|
445 |
?>
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
<span class="wp-smush-notice-text"
|
451 |
-
|
|
|
|
|
|
|
|
|
452 |
</span>
|
453 |
</div><?php
|
454 |
} ?>
|
455 |
<hr>
|
456 |
-
<div class="smush-final-log notice notice-warning inline hidden"></div>
|
457 |
<button type="button" class="wp-smush-all wp-smush-button"><?php echo $button_content; ?></button><?php
|
458 |
//Enable Super Smush
|
459 |
if ( $WpSmush->is_pro() && ! $WpSmush->lossy_enabled ) { ?>
|
@@ -470,14 +532,14 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
|
|
470 |
*/
|
471 |
function progress_bar( $count ) {
|
472 |
|
|
|
|
|
473 |
// calculate %ages, avoid divide by zero error with no attachments
|
474 |
if ( $count->total_count > 0 && $count->smushed_count > 0 ) {
|
475 |
-
$smushed_pc = $
|
476 |
} else {
|
477 |
$smushed_pc = 0;
|
478 |
-
}
|
479 |
-
//If we have resmush list, smushed_count = totalcount - resmush count, else smushed_count
|
480 |
-
$smushed_count = ( $resmush_count = count( $count->resmush_ids ) ) > 0 ? ( $count->total_count - $resmush_count ) : $count->smushed_count; ?>
|
481 |
<div class="wp-smush-bulk-progress-bar-wrapper hidden">
|
482 |
<p class="wp-smush-bulk-active roboto-medium"><span
|
483 |
class="spinner is-active"></span><?php printf( esc_html__( "%sBulk smush is currently running.%s You need to keep this page open.", "wp-smushit" ), '<strong>', '</strong>' ); ?>
|
@@ -493,45 +555,11 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
|
|
493 |
<?php printf( esc_html__( "%s%d%s of %d attachments have been smushed." ), '<span class="wp-smush-images-smushed">', $smushed_count, '</span>', $count->total_count ); ?>
|
494 |
</div>
|
495 |
</div>
|
496 |
-
<div class="smush-final-log notice notice-warning inline hidden"></div>
|
497 |
<hr class="wp-smush-sep">
|
498 |
<button type="button"
|
499 |
class="button button-grey wp-smush-cancel-bulk"><?php esc_html_e( "CANCEL", "wp-smushit" ); ?></button>
|
500 |
-
</div><?php
|
501 |
-
}
|
502 |
-
|
503 |
-
/**
|
504 |
-
* Progress Bar for Resmush UI
|
505 |
-
*/
|
506 |
-
function resmush_progress_bar( $resmush_count = '', $return = false ) {
|
507 |
-
global $wpsmushit_admin;
|
508 |
-
if ( empty( $resmush_count ) ) {
|
509 |
-
//Get Resmush List
|
510 |
-
$resmush_list = get_option( 'wp-smush-resmush-list' );
|
511 |
-
$resmush_count = ! empty( $resmush_list ) ? count( $resmush_list ) : 0;
|
512 |
-
}
|
513 |
-
|
514 |
-
$content = '<div class="wp-smush-bulk-progress-bar-wrapper hidden">
|
515 |
-
<p class="wp-smush-bulk-active roboto-medium">' . sprintf( esc_html__( "%sBulk re-smush is currently running.%s You need to keep this page open.", "wp-smushit" ), '<strong>', '</strong>' ) . '</p>
|
516 |
-
<div class="wp-smush-progress-wrap">
|
517 |
-
<div class="wp-smush-progress-bar-wrap">
|
518 |
-
<div class="wp-smush-progress-bar">
|
519 |
-
<div class="wp-smush-progress-inner" style="width: 100%;">
|
520 |
-
<div class="wp-smush-progress-count">' . sprintf( _n( "%s%d%s image left to Re-Smush", "%s%d%s images left to Re-Smush", $resmush_count, "wp-smushit" ), '<span class="wp-smush-images-remaining">', $wpsmushit_admin->format_number( $resmush_count ), '</span>' ) . '
|
521 |
-
</div>
|
522 |
-
</div>
|
523 |
-
</div>
|
524 |
-
</div>
|
525 |
</div>
|
526 |
-
<div class="smush-final-log notice notice-warning inline hidden"></div
|
527 |
-
<hr class="wp-smush-sep">
|
528 |
-
<button type="button"
|
529 |
-
class="button button-grey wp-smush-cancel-bulk">' . esc_html__( "CANCEL", "wp-smushit" ) . '</button>
|
530 |
-
</div>';
|
531 |
-
if ( $return ) {
|
532 |
-
return $content;
|
533 |
-
}
|
534 |
-
echo $content;
|
535 |
}
|
536 |
|
537 |
/**
|
@@ -631,6 +659,8 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
|
|
631 |
*/
|
632 |
function installation_notice() {
|
633 |
global $wpsmushit_admin;
|
|
|
|
|
634 |
|
635 |
//Whether New/Existing Installation
|
636 |
$install_type = get_site_option('wp-smush-install-type', false );
|
@@ -643,21 +673,28 @@ if ( ! class_exists( 'WpSmushBulkUi' ) ) {
|
|
643 |
if ( 'new' == $install_type ) {
|
644 |
$notice_heading = esc_html__( "Thanks for installing Smush. We hope you like it!", "wp-smushit" );
|
645 |
$notice_content = esc_html__( "And hey, if you do, you can now try out Smush Pro for double the smushy goodness (benchmarked), entirely for free!", "wp-smushit" );
|
646 |
-
$button_content = esc_html__( "
|
647 |
} else {
|
648 |
-
$notice_heading = sprintf( esc_html__( "Did you know that you can now
|
649 |
-
$notice_content = esc_html__( "Yep, Super Smush your images for double the savings, save originals and batch Smush thousands of images all at once.... no charge
|
650 |
-
$button_content = esc_html__( "
|
651 |
} ?>
|
652 |
-
<
|
653 |
-
<div class="
|
654 |
-
<div class="
|
655 |
-
|
656 |
-
|
657 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
658 |
</div>
|
659 |
</div>
|
660 |
-
|
661 |
}
|
662 |
|
663 |
/**
|
117 |
* Outputs the Smush stats for the site
|
118 |
*/
|
119 |
function smush_stats_container() {
|
120 |
+
global $WpSmush, $wpsmushit_admin, $wpsmush_stats;
|
121 |
|
122 |
//If we have resmush list, smushed_count = totalcount - resmush count, else smushed_count
|
123 |
$smushed_count = ( $resmush_count = count( $wpsmushit_admin->resmush_ids ) ) > 0 ? $wpsmushit_admin->total_count - ( $resmush_count + $wpsmushit_admin->remaining_count ) : $wpsmushit_admin->smushed_count;
|
140 |
<span
|
141 |
class="float-r wp-smush-stats"><strong><?php echo $wpsmushit_admin->stats['human'] > 0 ? $wpsmushit_admin->stats['human'] : "0MB"; ?></strong></span>
|
142 |
</div>
|
143 |
+
<hr><?php
|
144 |
+
if( !empty( $wpsmushit_admin->stats['resize_savings'] ) && $wpsmushit_admin->stats['resize_savings'] > 0 ) { ?>
|
145 |
+
<div class="row smush-resize-savings">
|
146 |
+
<span class="float-l wp-smush-stats-label"><strong><?php esc_html_e( "TOTAL RESIZE SAVINGS", "wp-smushit" ); ?></strong></span>
|
147 |
+
<span class="float-r wp-smush-stats"><strong><?php echo $wpsmushit_admin->stats['resize_savings'] > 0 ? $wpsmushit_admin->stats['resize_savings'] : "0MB"; ?></strong></span>
|
148 |
+
</div>
|
149 |
+
<hr><?php
|
150 |
+
} ?>
|
151 |
<div class="row smush-attachments">
|
152 |
+
<span class="float-l wp-smush-stats-label">
|
153 |
+
<strong><?php esc_html_e( "ATTACHMENTS SMUSHED", "wp-smushit" ); ?></strong><?php
|
154 |
+
if( !empty( $wpsmushit_admin->stats['total_images'] ) && $wpsmushit_admin->stats['total_images'] > 0 ) {?>
|
155 |
+
<span class="wp-smush-total-thumbnails" tooltip="<?php printf( esc_html__(" You've smushed %d images in total", "wp-smushit"), $wpsmushit_admin->stats['total_images'] ); ?>">
|
156 |
+
<i class="dashicons dashicons-editor-help"></i>
|
157 |
+
</span><?php
|
158 |
+
}?>
|
159 |
+
</span>
|
160 |
+
<span class="float-r wp-smush-stats">
|
161 |
+
<strong>
|
162 |
+
<span class="smushed-count"><?php echo intval( $smushed_count ) . '</span>/' . $wpsmushit_admin->total_count; ?>
|
163 |
+
</strong>
|
164 |
+
</span>
|
165 |
</div><?php
|
166 |
/**
|
167 |
* Allows to hide the Super Smush stats as it might be heavy for some users
|
168 |
*/
|
169 |
if ( $WpSmush->is_pro() && apply_filters( 'wp_smush_show_lossy_stats', true ) ) {
|
170 |
+
$wpsmushit_admin->super_smushed = $wpsmush_stats->super_smushed_count(); ?>
|
171 |
<hr>
|
172 |
<div class="row super-smush-attachments">
|
173 |
<span class="float-l wp-smush-stats-label"><strong><?php esc_html_e( "ATTACHMENTS SUPER-SMUSHED", "wp-smushit" ); ?></strong></span>
|
174 |
<span class="float-r wp-smush-stats<?php echo $WpSmush->lossy_enabled ? '' : ' wp-smush-lossy-disabled-wrap' ?>"><?php
|
175 |
if ( $WpSmush->lossy_enabled ) {
|
176 |
+
echo '<strong><span class="smushed-count" tooltip="' . sprintf( esc_html__("%d images", "wp-smushit"), $wpsmushit_admin->stats['total_images'] ) . '">' . intval( $wpsmushit_admin->super_smushed ) . '</span>/' . $wpsmushit_admin->total_count . '</strong>';
|
177 |
} else {
|
178 |
printf( esc_html__( "%sENABLE%s", "wp-smushit" ), '<button class="wp-smush-lossy-enable button button-small">', '</button>' );
|
179 |
} ?>
|
272 |
global $wpsmushit_admin;
|
273 |
echo '<div class="box-container">
|
274 |
<form id="wp-smush-settings-form" method="post">';
|
275 |
+
|
276 |
+
//Get max. dimesnions
|
277 |
+
$max_sizes = $wpsmushit_admin->get_max_image_dimensions();
|
278 |
+
|
279 |
+
//Placeholder width and Height
|
280 |
+
$p_width = $p_height = 2048;
|
281 |
+
|
282 |
//Smush auto key
|
283 |
$opt_auto = WP_SMUSH_PREFIX . 'auto';
|
284 |
//Auto value
|
292 |
|
293 |
//Keep Exif
|
294 |
$opt_keep_exif = WP_SMUSH_PREFIX . 'keep_exif';
|
295 |
+
$opt_keep_exif_val = get_option( $opt_keep_exif, false );
|
296 |
+
|
297 |
+
//Resize images
|
298 |
+
$opt_resize = WP_SMUSH_PREFIX . 'resize';
|
299 |
+
$opt_resize_val = get_option( $opt_resize, false );
|
300 |
+
|
301 |
+
//Dimensions
|
302 |
+
$resize_sizes = get_option( WP_SMUSH_PREFIX . 'resize_sizes', array( 'width' => '', 'height' => '' ) );
|
303 |
+
|
304 |
+
//Fetch Max. width and height
|
305 |
+
?>
|
306 |
+
|
307 |
<!-- A tab index of 0 keeps the element in tab flow with other elements with an unspecified tab index which are still tabbable.) -->
|
308 |
<div class='wp-smush-setting-row wp-smush-basic'>
|
309 |
<label class="inline-label" for="<?php echo $opt_auto; ?>" tabindex="0">
|
336 |
value="1" name="<?php echo $opt_keep_exif; ?>" tabindex="0">
|
337 |
<label class="toggle-label" for="<?php echo $opt_keep_exif; ?>"></label>
|
338 |
</span>
|
339 |
+
</div>
|
340 |
+
<hr/>
|
341 |
+
<div class='wp-smush-setting-row wp-smush-basic'>
|
342 |
+
<label class="inline-label" for="<?php echo $opt_resize; ?>" tabindex="0">
|
343 |
+
<span class="wp-smush-setting-label"><?php echo $wpsmushit_admin->settings['resize']['label']; ?></span>
|
344 |
+
<br/>
|
345 |
+
<small class="smush-setting-description">
|
346 |
+
<?php echo $wpsmushit_admin->settings['resize']['desc']; ?>
|
347 |
+
</small>
|
348 |
+
</label>
|
349 |
+
<span class="toggle float-r">
|
350 |
+
<input type="checkbox" class="toggle-checkbox"
|
351 |
+
id="<?php echo $opt_resize; ?>" <?php echo $resize_checked = checked( $opt_resize_val, 1, false ); ?>
|
352 |
+
value="1" name="<?php echo $opt_resize; ?>" tabindex="0">
|
353 |
+
<label class="toggle-label" for="<?php echo $opt_resize; ?>"></label>
|
354 |
+
</span>
|
355 |
+
<div class="wp-smush-resize-settings-wrap<?php echo $resize_checked ? '' : ' hidden'?>">
|
356 |
+
<label for="<?php echo $opt_resize . '_width'; ?>"><?php esc_html_e("Width", "wp-smushit"); ?>
|
357 |
+
<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
|
358 |
+
</label>
|
359 |
+
<label for"<?php echo $opt_resize . '_height'; ?>"><?php esc_html_e("Height", "wp-smushit"); ?>
|
360 |
+
<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
|
361 |
+
</label>
|
362 |
+
<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>
|
363 |
+
<div class="wp-smush-size-info wp-smush-update-width hidden"><?php esc_html_e( "Just to let you know, the width you've entered is less than your largest thumbnail and may result in pixelation.", "wp-smushit" ); ?></div>
|
364 |
+
<div class="wp-smush-size-info wp-smush-update-height hidden"><?php esc_html_e( "Just to let you know, the height you’ve entered is less than your largest thumbnail and may result in pixelation.", "wp-smushit" ); ?></div>
|
365 |
+
</div>
|
366 |
+
</div><!-- End of Basic Settings --><?php
|
367 |
|
368 |
do_action( 'wp_smush_after_basic_settings' );
|
369 |
$this->advanced_settings( $configure_screen );
|
382 |
$this->smush_page_header();
|
383 |
|
384 |
//Show Configure screen for only a new installation and for only network admins
|
385 |
+
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() ) {
|
386 |
echo '<div class="block float-l smush-welcome-wrapper">';
|
387 |
$this->welcome_screen();
|
388 |
echo '</div>';
|
450 |
if ( class_exists( 'WP_Hummingbird' ) ) {
|
451 |
return;
|
452 |
}
|
453 |
+
$this->container_header( 'wp-smush-hb-adv', 'wp-smush-hb-promo', "OH YEAH, SMUSHING ON STEROIDS!" ); ?>
|
454 |
<div class="box-content">
|
455 |
<span class="wp-smush-hummingbird-image tc">
|
456 |
<img src="<?php echo WP_SMUSH_URL . 'assets/images/hummingbird.png'; ?>"
|
457 |
alt="<?php esc_html_e( "BOOST YOUR PERFORMANCE - HUMMINGBIRD", "wp-smushit" ); ?>">
|
458 |
+
</span>
|
459 |
<p class="wp-smush-promo-content tc roboto-medium">Hummingbird goes beyond Smush compression with
|
460 |
minification, caching, performance monitoring and more - every millisecond counts!</p>
|
461 |
<span class="wp-smush-hb-cta tc roboto-medium">
|
491 |
} else { ?>
|
492 |
<!-- Hide All done div if there are images pending -->
|
493 |
<div class="wp-smush-notice wp-smush-all-done<?php echo $all_done ? '' : ' hidden' ?>" tabindex="0">
|
494 |
+
<i class="dev-icon dev-icon-tick"></i><?php esc_html_e( "All images are smushed and up to date. Awesome!", "wp-smushit" ); ?>
|
495 |
</div>
|
496 |
<div class="wp-smush-bulk-wrapper <?php echo $all_done ? ' hidden' : ''; ?>"><?php
|
497 |
//If all the images in media library are smushed
|
502 |
if ( $wpsmushit_admin->remaining_count > 0 ) {
|
503 |
$class = count( $wpsmushit_admin->resmush_ids ) > 0 ? ' hidden' : '';
|
504 |
?>
|
505 |
+
<div class="wp-smush-notice wp-smush-remaining<?php echo $class; ?>" tabindex="0">
|
506 |
+
<i class="dev-icon">
|
507 |
+
<img src="<?php echo WP_SMUSH_URL . 'assets/images/icon-gzip.svg'; ?>" width="14px">
|
508 |
+
</i>
|
509 |
+
<span class="wp-smush-notice-text"><?php
|
510 |
+
printf( _n( "%s, you have %s%s%d%s image%s that needs smushing!", "%s, you have %s%s%d%s images%s that need smushing!", $wpsmushit_admin->remaining_count, "wp-smushit" ), $wpsmushit_admin->get_user_name(), '<strong>', '<span class="wp-smush-remaining-count">', $wpsmushit_admin->remaining_count, '</span>', '</strong>' );
|
511 |
+
if( !$WpSmush->is_pro() ) {
|
512 |
+
printf( '<br />' . esc_html__("You can %sUpgrade to Pro%s to bulk smush all your images with one click.", "wp-smushit") .'<br />', '<a href="' . esc_url( $wpsmushit_admin->upgrade_url ). '" target="_blank" title="' . esc_html__("WP Smush Pro", "wp-smushit") . '">', '</a>' );
|
513 |
+
esc_html_e("Free users can smush 50 images with each click.", "wp-smushit");
|
514 |
+
}?>
|
515 |
</span>
|
516 |
</div><?php
|
517 |
} ?>
|
518 |
<hr>
|
|
|
519 |
<button type="button" class="wp-smush-all wp-smush-button"><?php echo $button_content; ?></button><?php
|
520 |
//Enable Super Smush
|
521 |
if ( $WpSmush->is_pro() && ! $WpSmush->lossy_enabled ) { ?>
|
532 |
*/
|
533 |
function progress_bar( $count ) {
|
534 |
|
535 |
+
//If we have resmush list, smushed_count = totalcount - resmush count, else smushed_count
|
536 |
+
$smushed_count = ( $resmush_count = count( $count->resmush_ids ) ) > 0 ? ( $count->total_count - ( $count->remaining_count + $resmush_count ) ) : $count->smushed_count;
|
537 |
// calculate %ages, avoid divide by zero error with no attachments
|
538 |
if ( $count->total_count > 0 && $count->smushed_count > 0 ) {
|
539 |
+
$smushed_pc = $smushed_count / $count->total_count * 100;
|
540 |
} else {
|
541 |
$smushed_pc = 0;
|
542 |
+
} ?>
|
|
|
|
|
543 |
<div class="wp-smush-bulk-progress-bar-wrapper hidden">
|
544 |
<p class="wp-smush-bulk-active roboto-medium"><span
|
545 |
class="spinner is-active"></span><?php printf( esc_html__( "%sBulk smush is currently running.%s You need to keep this page open.", "wp-smushit" ), '<strong>', '</strong>' ); ?>
|
555 |
<?php printf( esc_html__( "%s%d%s of %d attachments have been smushed." ), '<span class="wp-smush-images-smushed">', $smushed_count, '</span>', $count->total_count ); ?>
|
556 |
</div>
|
557 |
</div>
|
|
|
558 |
<hr class="wp-smush-sep">
|
559 |
<button type="button"
|
560 |
class="button button-grey wp-smush-cancel-bulk"><?php esc_html_e( "CANCEL", "wp-smushit" ); ?></button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
561 |
</div>
|
562 |
+
<div class="smush-final-log notice notice-warning inline hidden"></div><?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
563 |
}
|
564 |
|
565 |
/**
|
659 |
*/
|
660 |
function installation_notice() {
|
661 |
global $wpsmushit_admin;
|
662 |
+
$css_url = WP_SMUSH_URL . 'assets/css/notice.css?1';
|
663 |
+
$js_url = WP_SMUSH_URL . 'assets/js/notice.js';
|
664 |
|
665 |
//Whether New/Existing Installation
|
666 |
$install_type = get_site_option('wp-smush-install-type', false );
|
673 |
if ( 'new' == $install_type ) {
|
674 |
$notice_heading = esc_html__( "Thanks for installing Smush. We hope you like it!", "wp-smushit" );
|
675 |
$notice_content = esc_html__( "And hey, if you do, you can now try out Smush Pro for double the smushy goodness (benchmarked), entirely for free!", "wp-smushit" );
|
676 |
+
$button_content = esc_html__( "Try Smush Pro for Free", "wp-smushit" );
|
677 |
} else {
|
678 |
+
$notice_heading = sprintf( esc_html__( "Thanks for updating Smush. Did you know that you can now try the Smush Pro for FREE?!", "wp-smushit" ), '<a href="' . esc_url( $wpsmushit_admin->upgrade_url ) . '" target="_blank">', '</a>' );
|
679 |
+
$notice_content = '<br />' . esc_html__( "Yep, Super Smush your images for double the savings, save originals and batch Smush thousands of images all at once.... no charge!", "wp-smushit" );
|
680 |
+
$button_content = esc_html__( "Try Smush Pro for Free", "wp-smushit" );
|
681 |
} ?>
|
682 |
+
<link rel="stylesheet" type="text/css" href="<?php echo esc_url( $css_url ); ?>" />
|
683 |
+
<div class="notice smush-notice" style="display: none;">
|
684 |
+
<div class="smush-notice-logo"><span></span></div>
|
685 |
+
<div
|
686 |
+
class="smush-notice-message<?php echo 'new' == $install_type ? ' wp-smush-fresh' : ' wp-smush-existing'; ?>">
|
687 |
+
<strong><?php echo $notice_heading; ?></strong>
|
688 |
+
<?php echo $notice_content; ?>
|
689 |
+
</div>
|
690 |
+
<div class="smush-notice-cta">
|
691 |
+
<a href="<?php echo esc_url( $wpsmushit_admin->upgrade_url ); ?>" class="smush-notice-act button-primary" target="_blank">
|
692 |
+
<?php echo $button_content; ?>
|
693 |
+
</a>
|
694 |
+
<button class="smush-notice-dismiss smush-dismiss-welcome" data-msg="<?php esc_html_e( 'Saving', 'wp-smushit'); ?>"><?php esc_html_e( 'Dismiss', "wp-smushit" ); ?></button>
|
695 |
</div>
|
696 |
</div>
|
697 |
+
<script src="<?php echo esc_url( $js_url ) . '?v=' . WP_SMUSH_VERSION; ?>"></script><?php
|
698 |
}
|
699 |
|
700 |
/**
|
lib/class-wp-smush.php
CHANGED
@@ -1,5 +1,13 @@
|
|
1 |
<?php
|
|
|
2 |
require_once WP_SMUSH_DIR . "lib/class-wp-smush-migrate.php";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
if ( ! class_exists( 'WpSmush' ) ) {
|
4 |
|
5 |
class WpSmush {
|
@@ -61,8 +69,8 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
61 |
*/
|
62 |
add_filter( 'wp_update_attachment_metadata', array(
|
63 |
$this,
|
64 |
-
'
|
65 |
-
),
|
66 |
|
67 |
//Delete Backup files
|
68 |
add_action( 'delete_attachment', array(
|
@@ -264,21 +272,20 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
264 |
*/
|
265 |
function _get_size_signature() {
|
266 |
return array(
|
267 |
-
'percent' =>
|
268 |
-
'bytes' =>
|
269 |
-
'size_before' =>
|
270 |
-
'size_after' =>
|
271 |
-
'time' =>
|
272 |
);
|
273 |
}
|
274 |
|
275 |
/**
|
|
|
|
|
276 |
* Read the image paths from an attachment's meta data and process each image
|
277 |
* with wp_smushit().
|
278 |
*
|
279 |
-
* This method also adds a `wp_smushit` meta key for use in the media library.
|
280 |
-
* Called after `wp_generate_attachment_metadata` is completed.
|
281 |
-
*
|
282 |
* @param $meta
|
283 |
* @param null $ID
|
284 |
*
|
@@ -384,12 +391,9 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
384 |
}
|
385 |
|
386 |
//All Clear, Store the stat
|
|
|
387 |
$stats['sizes'][ $size_key ] = (object) $this->_array_fill_placeholders( $this->_get_size_signature(), (array) $response['data'] );
|
388 |
|
389 |
-
//Total Stats, store all data in bytes
|
390 |
-
list( $size_before, $size_after, $total_time, $compression, $bytes_saved )
|
391 |
-
= $this->_update_stats_data( $response['data'], $size_before, $size_after, $total_time, $bytes_saved );
|
392 |
-
|
393 |
if ( empty( $stats['stats']['api_version'] ) || $stats['stats']['api_version'] == - 1 ) {
|
394 |
$stats['stats']['api_version'] = $response['data']->api_version;
|
395 |
$stats['stats']['lossy'] = $response['data']->lossy;
|
@@ -436,12 +440,6 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
436 |
$stats['sizes']['full'] = (object) $this->_array_fill_placeholders( $this->_get_size_signature(), (array) $full_image_response['data'] );
|
437 |
}
|
438 |
|
439 |
-
//Update stats
|
440 |
-
if ( $store_stats ) {
|
441 |
-
list( $size_before, $size_after, $total_time, $compression, $bytes_saved )
|
442 |
-
= $this->_update_stats_data( $full_image_response['data'], $size_before, $size_after, $total_time, $bytes_saved );
|
443 |
-
}
|
444 |
-
|
445 |
//Api version and lossy, for some images, full image i skipped and for other images only full exists
|
446 |
//so have to add code again
|
447 |
if ( empty( $stats['stats']['api_version'] ) || $stats['stats']['api_version'] == - 1 ) {
|
@@ -454,27 +452,12 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
454 |
|
455 |
$has_errors = (bool) count( $errors->get_error_messages() );
|
456 |
|
457 |
-
list( $stats['stats']['size_before'], $stats['stats']['size_after'], $stats['stats']['time'], $stats['stats']['percent'], $stats['stats']['bytes'] ) =
|
458 |
-
array( $size_before, $size_after, $total_time, $compression, $bytes_saved );
|
459 |
-
|
460 |
//Set smush status for all the images, store it in wp-smpro-smush-data
|
461 |
if ( ! $has_errors ) {
|
462 |
|
463 |
$existing_stats = get_post_meta( $ID, $this->smushed_meta_key, true );
|
464 |
|
465 |
if ( ! empty( $existing_stats ) ) {
|
466 |
-
$e_size_before = isset( $existing_stats['stats']['size_before'] ) ? $existing_stats['stats']['size_before'] : '';
|
467 |
-
$e_size_after = isset( $existing_stats['stats']['size_after'] ) ? $existing_stats['stats']['size_after'] : '';
|
468 |
-
//Store Original size before
|
469 |
-
$stats['stats']['size_before'] = ! empty( $e_size_before ) && $e_size_before > $stats['stats']['size_before'] ? $e_size_before : $stats['stats']['size_before'];
|
470 |
-
|
471 |
-
if ( $size_after == 0 || empty( $stats['stats']['size_after'] ) || $stats['stats']['size_after'] == $stats['stats']['size_before'] ) {
|
472 |
-
$stats['stats']['size_after'] = $e_size_after < $stats['stats']['size_before'] ? $e_size_after : $stats['stats']['size_before'];
|
473 |
-
}
|
474 |
-
|
475 |
-
//Update total bytes saved, and compression percent
|
476 |
-
$stats['stats']['bytes'] = isset( $existing_stats['stats']['bytes'] ) ? $existing_stats['stats']['bytes'] + $stats['stats']['bytes'] : $stats['stats']['bytes'];
|
477 |
-
$stats['stats']['percent'] = $this->calculate_percentage( (object) $stats['stats'], (object) $existing_stats['stats'] );
|
478 |
|
479 |
//Update stats for each size
|
480 |
if ( isset( $existing_stats['sizes'] ) && ! empty( $stats['sizes'] ) ) {
|
@@ -497,6 +480,10 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
497 |
}
|
498 |
}
|
499 |
}
|
|
|
|
|
|
|
|
|
500 |
//If there was any compression and there was no error in smushing
|
501 |
if( isset( $stats['stats']['bytes'] ) && $stats['stats']['bytes'] >= 0 && !$has_errors ) {
|
502 |
/**
|
@@ -512,6 +499,13 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
512 |
update_post_meta( $ID, $this->smushed_meta_key, $stats );
|
513 |
}
|
514 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
515 |
return $meta;
|
516 |
}
|
517 |
|
@@ -519,8 +513,6 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
519 |
* Read the image paths from an attachment's meta data and process each image
|
520 |
* with wp_smushit()
|
521 |
*
|
522 |
-
* Filters wp_generate_attachment_metadata
|
523 |
-
*
|
524 |
* @uses resize_from_meta_data
|
525 |
*
|
526 |
* @param $meta
|
@@ -528,7 +520,16 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
528 |
*
|
529 |
* @return mixed
|
530 |
*/
|
531 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
532 |
//Check if auto is enabled
|
533 |
$auto_smush = $this->is_auto_smush_enabled();
|
534 |
|
@@ -854,15 +855,19 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
854 |
$show_button = $show_resmush = false;
|
855 |
|
856 |
$wp_smush_data = get_post_meta( $id, $this->smushed_meta_key, true );
|
|
|
|
|
|
|
|
|
857 |
$attachment_data = wp_get_attachment_metadata( $id );
|
858 |
|
859 |
// if the image is smushed
|
860 |
if ( ! empty( $wp_smush_data ) ) {
|
861 |
|
862 |
$image_count = count( $wp_smush_data['sizes'] );
|
863 |
-
$bytes = isset( $
|
864 |
$bytes_readable = ! empty( $bytes ) ? $this->format_bytes( $bytes ) : '';
|
865 |
-
$percent = isset( $
|
866 |
$percent = $percent < 0 ? 0 : $percent;
|
867 |
|
868 |
if ( isset( $wp_smush_data['stats']['size_before'] ) && $wp_smush_data['stats']['size_before'] == 0 && ! empty( $wp_smush_data['sizes'] ) ) {
|
@@ -1076,36 +1081,6 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
1076 |
|
1077 |
}
|
1078 |
|
1079 |
-
/**
|
1080 |
-
* Update the Given array by adding to existing values and returns a array of variables
|
1081 |
-
*
|
1082 |
-
* @param Object $response_data , Object containing the latest stats (before_size, after_size, time, bytes_saved)
|
1083 |
-
* @param $size_before
|
1084 |
-
* @param $size_after
|
1085 |
-
* @param $total_time
|
1086 |
-
* @param $bytes_saved
|
1087 |
-
*
|
1088 |
-
* @return array('size_before', 'size_after', 'total_time', 'compression', 'bytes_saved' )
|
1089 |
-
*/
|
1090 |
-
function _update_stats_data( $response_data, $size_before, $size_after, $total_time, $bytes_saved ) {
|
1091 |
-
|
1092 |
-
//If image is already optimised, do not add in stats
|
1093 |
-
if( $response_data->before_size == $response_data->after_size ) {
|
1094 |
-
|
1095 |
-
$compression = ( $bytes_saved > 0 && $size_before > 0 ) ? ( ( $bytes_saved / $size_before ) * 100 ) : 0;
|
1096 |
-
|
1097 |
-
return array( $size_before, $size_after, $total_time, $compression, $bytes_saved );
|
1098 |
-
}
|
1099 |
-
|
1100 |
-
$size_before += ! empty( $response_data->before_size ) ? (int) $response_data->before_size : 0;
|
1101 |
-
$size_after += ( ! empty( $response_data->after_size ) && $response_data->after_size > 0 ) ? (int) $response_data->after_size : (int) $response_data->before_size;
|
1102 |
-
$total_time += ! empty( $response_data->time ) ? (float) $response_data->time : 0;
|
1103 |
-
$bytes_saved += ( ! empty( $response_data->bytes_saved ) && $response_data->bytes_saved > 0 ) ? $response_data->bytes_saved : 0;
|
1104 |
-
$compression = ( $bytes_saved > 0 && $size_before > 0 ) ? ( ( $bytes_saved / $size_before ) * 100 ) : 0;
|
1105 |
-
|
1106 |
-
return array( $size_before, $size_after, $total_time, $compression, $bytes_saved );
|
1107 |
-
}
|
1108 |
-
|
1109 |
/**
|
1110 |
* Updates the smush stats for a single image size
|
1111 |
*
|
@@ -1123,11 +1098,6 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
1123 |
$stats = get_post_meta( $id, $this->smushed_meta_key, true );
|
1124 |
//Update existing Stats
|
1125 |
if ( ! empty( $stats ) ) {
|
1126 |
-
//Update total bytes saved, and compression percent
|
1127 |
-
//Update Main Stats
|
1128 |
-
list( $stats['stats']['size_before'], $stats['stats']['size_after'], $stats['stats']['time'], $stats['stats']['percent'], $stats['stats']['bytes'] ) =
|
1129 |
-
$this->_update_stats_data( $data, $stats['stats']['size_before'], $stats['stats']['size_after'], $stats['stats']['time'], $stats['stats']['bytes'] );
|
1130 |
-
|
1131 |
|
1132 |
//Update stats for each size
|
1133 |
if ( isset( $stats['sizes'] ) ) {
|
@@ -1156,13 +1126,12 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
1156 |
$stats['stats']['lossy'] = $data->lossy;
|
1157 |
$stats['stats']['keep_exif'] = ! empty( $data->keep_exif ) ? $data->keep_exif : 0;
|
1158 |
|
1159 |
-
//Update Main Stats
|
1160 |
-
list( $stats['stats']['size_before'], $stats['stats']['size_after'], $stats['stats']['time'], $stats['stats']['percent'], $stats['stats']['bytes'] ) =
|
1161 |
-
array( $data->before_size, $data->after_size, $data->time, $data->compression, $data->bytes_saved );
|
1162 |
//Update size wise details
|
1163 |
$stats['sizes'][ $image_size ] = (object) $this->_array_fill_placeholders( $this->_get_size_signature(), (array) $data );
|
1164 |
}
|
1165 |
-
//Calculate
|
|
|
|
|
1166 |
update_post_meta( $id, $this->smushed_meta_key, $stats );
|
1167 |
|
1168 |
}
|
@@ -1569,6 +1538,10 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
1569 |
* @param $image_id
|
1570 |
*/
|
1571 |
function delete_images( $image_id ) {
|
|
|
|
|
|
|
|
|
1572 |
|
1573 |
//If no image id provided
|
1574 |
if ( empty( $image_id ) ) {
|
@@ -1712,20 +1685,24 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
1712 |
*/
|
1713 |
function wp_smush_redirect( $plugin ) {
|
1714 |
|
1715 |
-
global $wpsmushit_admin;
|
1716 |
|
1717 |
//Run for only our plugin
|
1718 |
if( $plugin != WP_SMUSH_BASENAME ) {
|
1719 |
return false;
|
1720 |
}
|
1721 |
|
|
|
|
|
|
|
|
|
1722 |
//Skip if bulk activation, Or if we have to skip redirection
|
1723 |
if ( isset( $_GET['activate-multi'] ) || get_site_option('wp-smush-skip-redirect') ) {
|
1724 |
return false;
|
1725 |
}
|
1726 |
|
1727 |
//If images are already smushed
|
1728 |
-
if( $
|
1729 |
return false;
|
1730 |
}
|
1731 |
|
@@ -1791,6 +1768,60 @@ if ( ! class_exists( 'WpSmush' ) ) {
|
|
1791 |
$wpsmushit_admin->dismiss_upgrade_notice( false );
|
1792 |
}
|
1793 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1794 |
}
|
1795 |
|
1796 |
global $WpSmush;
|
1 |
<?php
|
2 |
+
//Migration Class
|
3 |
require_once WP_SMUSH_DIR . "lib/class-wp-smush-migrate.php";
|
4 |
+
|
5 |
+
//Stats
|
6 |
+
require_once WP_SMUSH_DIR . "lib/class-wp-smush-stats.php";
|
7 |
+
|
8 |
+
//Include Resize class
|
9 |
+
require_once WP_SMUSH_DIR . 'lib/class-wp-smush-resize.php';
|
10 |
+
|
11 |
if ( ! class_exists( 'WpSmush' ) ) {
|
12 |
|
13 |
class WpSmush {
|
69 |
*/
|
70 |
add_filter( 'wp_update_attachment_metadata', array(
|
71 |
$this,
|
72 |
+
'smush_image'
|
73 |
+
), 15, 2 );
|
74 |
|
75 |
//Delete Backup files
|
76 |
add_action( 'delete_attachment', array(
|
272 |
*/
|
273 |
function _get_size_signature() {
|
274 |
return array(
|
275 |
+
'percent' => 0,
|
276 |
+
'bytes' => 0,
|
277 |
+
'size_before' => 0,
|
278 |
+
'size_after' => 0,
|
279 |
+
'time' => 0
|
280 |
);
|
281 |
}
|
282 |
|
283 |
/**
|
284 |
+
* Optimises the image sizes
|
285 |
+
*
|
286 |
* Read the image paths from an attachment's meta data and process each image
|
287 |
* with wp_smushit().
|
288 |
*
|
|
|
|
|
|
|
289 |
* @param $meta
|
290 |
* @param null $ID
|
291 |
*
|
391 |
}
|
392 |
|
393 |
//All Clear, Store the stat
|
394 |
+
//@todo: Move the existing stats code over here, we don't need to do the stats part twice
|
395 |
$stats['sizes'][ $size_key ] = (object) $this->_array_fill_placeholders( $this->_get_size_signature(), (array) $response['data'] );
|
396 |
|
|
|
|
|
|
|
|
|
397 |
if ( empty( $stats['stats']['api_version'] ) || $stats['stats']['api_version'] == - 1 ) {
|
398 |
$stats['stats']['api_version'] = $response['data']->api_version;
|
399 |
$stats['stats']['lossy'] = $response['data']->lossy;
|
440 |
$stats['sizes']['full'] = (object) $this->_array_fill_placeholders( $this->_get_size_signature(), (array) $full_image_response['data'] );
|
441 |
}
|
442 |
|
|
|
|
|
|
|
|
|
|
|
|
|
443 |
//Api version and lossy, for some images, full image i skipped and for other images only full exists
|
444 |
//so have to add code again
|
445 |
if ( empty( $stats['stats']['api_version'] ) || $stats['stats']['api_version'] == - 1 ) {
|
452 |
|
453 |
$has_errors = (bool) count( $errors->get_error_messages() );
|
454 |
|
|
|
|
|
|
|
455 |
//Set smush status for all the images, store it in wp-smpro-smush-data
|
456 |
if ( ! $has_errors ) {
|
457 |
|
458 |
$existing_stats = get_post_meta( $ID, $this->smushed_meta_key, true );
|
459 |
|
460 |
if ( ! empty( $existing_stats ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
461 |
|
462 |
//Update stats for each size
|
463 |
if ( isset( $existing_stats['sizes'] ) && ! empty( $stats['sizes'] ) ) {
|
480 |
}
|
481 |
}
|
482 |
}
|
483 |
+
|
484 |
+
//Sum Up all the stats
|
485 |
+
$stats = $this->total_compression( $stats );
|
486 |
+
|
487 |
//If there was any compression and there was no error in smushing
|
488 |
if( isset( $stats['stats']['bytes'] ) && $stats['stats']['bytes'] >= 0 && !$has_errors ) {
|
489 |
/**
|
499 |
update_post_meta( $ID, $this->smushed_meta_key, $stats );
|
500 |
}
|
501 |
|
502 |
+
unset( $stats );
|
503 |
+
|
504 |
+
//Unset Response
|
505 |
+
if ( ! empty( $response ) ) {
|
506 |
+
unset( $response );
|
507 |
+
}
|
508 |
+
|
509 |
return $meta;
|
510 |
}
|
511 |
|
513 |
* Read the image paths from an attachment's meta data and process each image
|
514 |
* with wp_smushit()
|
515 |
*
|
|
|
|
|
516 |
* @uses resize_from_meta_data
|
517 |
*
|
518 |
* @param $meta
|
520 |
*
|
521 |
* @return mixed
|
522 |
*/
|
523 |
+
function smush_image( $meta, $ID = null ) {
|
524 |
+
|
525 |
+
//Return directly if not a image
|
526 |
+
if ( ! wp_attachment_is_image( $ID ) ) {
|
527 |
+
return $meta;
|
528 |
+
}
|
529 |
+
|
530 |
+
global $wpsmush_resize;
|
531 |
+
$meta = $wpsmush_resize->auto_resize( $ID, $meta );
|
532 |
+
|
533 |
//Check if auto is enabled
|
534 |
$auto_smush = $this->is_auto_smush_enabled();
|
535 |
|
855 |
$show_button = $show_resmush = false;
|
856 |
|
857 |
$wp_smush_data = get_post_meta( $id, $this->smushed_meta_key, true );
|
858 |
+
$wp_resize_savings = get_post_meta( $id, WP_SMUSH_PREFIX . 'resize_savings', true );
|
859 |
+
|
860 |
+
$combined_stats = $this->combined_stats( $wp_smush_data, $wp_resize_savings );
|
861 |
+
|
862 |
$attachment_data = wp_get_attachment_metadata( $id );
|
863 |
|
864 |
// if the image is smushed
|
865 |
if ( ! empty( $wp_smush_data ) ) {
|
866 |
|
867 |
$image_count = count( $wp_smush_data['sizes'] );
|
868 |
+
$bytes = isset( $combined_stats['stats']['bytes'] ) ? $combined_stats['stats']['bytes'] : 0;
|
869 |
$bytes_readable = ! empty( $bytes ) ? $this->format_bytes( $bytes ) : '';
|
870 |
+
$percent = isset( $combined_stats['stats']['percent'] ) ? $combined_stats['stats']['percent'] : 0;
|
871 |
$percent = $percent < 0 ? 0 : $percent;
|
872 |
|
873 |
if ( isset( $wp_smush_data['stats']['size_before'] ) && $wp_smush_data['stats']['size_before'] == 0 && ! empty( $wp_smush_data['sizes'] ) ) {
|
1081 |
|
1082 |
}
|
1083 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1084 |
/**
|
1085 |
* Updates the smush stats for a single image size
|
1086 |
*
|
1098 |
$stats = get_post_meta( $id, $this->smushed_meta_key, true );
|
1099 |
//Update existing Stats
|
1100 |
if ( ! empty( $stats ) ) {
|
|
|
|
|
|
|
|
|
|
|
1101 |
|
1102 |
//Update stats for each size
|
1103 |
if ( isset( $stats['sizes'] ) ) {
|
1126 |
$stats['stats']['lossy'] = $data->lossy;
|
1127 |
$stats['stats']['keep_exif'] = ! empty( $data->keep_exif ) ? $data->keep_exif : 0;
|
1128 |
|
|
|
|
|
|
|
1129 |
//Update size wise details
|
1130 |
$stats['sizes'][ $image_size ] = (object) $this->_array_fill_placeholders( $this->_get_size_signature(), (array) $data );
|
1131 |
}
|
1132 |
+
//Calculate the total compression
|
1133 |
+
$stats = $this->total_compression( $stats );
|
1134 |
+
|
1135 |
update_post_meta( $id, $this->smushed_meta_key, $stats );
|
1136 |
|
1137 |
}
|
1538 |
* @param $image_id
|
1539 |
*/
|
1540 |
function delete_images( $image_id ) {
|
1541 |
+
global $wpsmush_stats;
|
1542 |
+
|
1543 |
+
//Update the savings cache
|
1544 |
+
$wpsmush_stats->resize_savings( true );
|
1545 |
|
1546 |
//If no image id provided
|
1547 |
if ( empty( $image_id ) ) {
|
1685 |
*/
|
1686 |
function wp_smush_redirect( $plugin ) {
|
1687 |
|
1688 |
+
global $wpsmushit_admin, $wpsmush_stats;
|
1689 |
|
1690 |
//Run for only our plugin
|
1691 |
if( $plugin != WP_SMUSH_BASENAME ) {
|
1692 |
return false;
|
1693 |
}
|
1694 |
|
1695 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
1696 |
+
return true;
|
1697 |
+
}
|
1698 |
+
|
1699 |
//Skip if bulk activation, Or if we have to skip redirection
|
1700 |
if ( isset( $_GET['activate-multi'] ) || get_site_option('wp-smush-skip-redirect') ) {
|
1701 |
return false;
|
1702 |
}
|
1703 |
|
1704 |
//If images are already smushed
|
1705 |
+
if( $wpsmush_stats->smushed_count( false ) > 0 ) {
|
1706 |
return false;
|
1707 |
}
|
1708 |
|
1768 |
$wpsmushit_admin->dismiss_upgrade_notice( false );
|
1769 |
}
|
1770 |
}
|
1771 |
+
|
1772 |
+
/**
|
1773 |
+
* Iterate over all the size stats and calculate the total stats
|
1774 |
+
*
|
1775 |
+
* @param $stats
|
1776 |
+
*
|
1777 |
+
*/
|
1778 |
+
function total_compression( $stats ) {
|
1779 |
+
foreach ( $stats['sizes'] as $size_stats ) {
|
1780 |
+
$stats['stats']['size_before'] += !empty( $size_stats->size_before ) ? $size_stats->size_before : 0;
|
1781 |
+
$stats['stats']['size_after'] += !empty( $size_stats->size_after) ? $size_stats->size_after : 0;
|
1782 |
+
$stats['stats']['time'] += !empty($size_stats->time ) ? $size_stats->time : 0;
|
1783 |
+
}
|
1784 |
+
$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;
|
1785 |
+
if ( ! empty( $stats['stats']['bytes'] ) && ! empty( $stats['stats']['size_before'] ) ) {
|
1786 |
+
$stats['stats']['percent'] = ( $stats['stats']['bytes'] / $stats['stats']['size_before'] ) * 100;
|
1787 |
+
}
|
1788 |
+
|
1789 |
+
return $stats;
|
1790 |
+
}
|
1791 |
+
|
1792 |
+
/**
|
1793 |
+
* Smush and Resizing Stats Combined together
|
1794 |
+
*
|
1795 |
+
* @param $smush_stats
|
1796 |
+
* @param $resize_savings
|
1797 |
+
*
|
1798 |
+
* @return array Array of all the stats
|
1799 |
+
*/
|
1800 |
+
function combined_stats( $smush_stats, $resize_savings ) {
|
1801 |
+
if ( empty( $smush_stats ) || empty( $resize_savings ) ) {
|
1802 |
+
return $smush_stats;
|
1803 |
+
}
|
1804 |
+
|
1805 |
+
$smush_stats['stats']['bytes'] = ! empty( $resize_savings['bytes'] ) ? $smush_stats['stats']['bytes'] + $resize_savings['bytes'] : $smush_stats['stats']['bytes'];
|
1806 |
+
$smush_stats['stats']['size_before'] = ! empty( $resize_savings['size_before'] ) ? $smush_stats['stats']['size_before'] + $resize_savings['size_before'] : $smush_stats['stats']['size_before'];
|
1807 |
+
$smush_stats['stats']['size_after'] = ! empty( $resize_savings['size_after'] ) ? $smush_stats['stats']['size_after'] + $resize_savings['size_after'] : $smush_stats['stats']['size_after'];
|
1808 |
+
$smush_stats['stats']['percent'] = ! empty( $smush_stats['stats']['bytes'] ) ? ( $smush_stats['stats']['bytes'] / $smush_stats['stats']['size_before'] ) * 100 : $smush_stats['stats']['percent'];
|
1809 |
+
|
1810 |
+
//Round off
|
1811 |
+
$smush_stats['stats']['percent'] = round( $smush_stats['stats']['percent'], 2 );
|
1812 |
+
|
1813 |
+
//Full Image
|
1814 |
+
if( !empty( $smush_stats['sizes']['full'] ) ) {
|
1815 |
+
$smush_stats['sizes']['full']->bytes = ! empty( $resize_savings['bytes'] ) ? $smush_stats['sizes']['full']->bytes + $resize_savings['bytes'] : $smush_stats['sizes']['full']->bytes;
|
1816 |
+
$smush_stats['sizes']['full']->size_before = ! empty( $resize_savings['size_before'] ) ? $smush_stats['sizes']['full']->size_before + $resize_savings['size_before'] : $smush_stats['sizes']['full']->size_before;
|
1817 |
+
$smush_stats['sizes']['full']->size_after = ! empty( $resize_savings['size_after'] ) ? $smush_stats['sizes']['full']->size_after + $resize_savings['size_after'] : $smush_stats['sizes']['full']->size_after;
|
1818 |
+
$smush_stats['sizes']['full']->percent = ! empty( $smush_stats['sizes']['full']->bytes ) && $smush_stats['sizes']['full']->size_before > 0 ? ( $smush_stats['sizes']['full']->bytes / $smush_stats['sizes']['full']->size_before ) * 100 : $smush_stats['sizes']['full']->percent;
|
1819 |
+
|
1820 |
+
$smush_stats['sizes']['full']->percent = round( $smush_stats['sizes']['full']->percent, 2 );
|
1821 |
+
}
|
1822 |
+
|
1823 |
+
return $smush_stats;
|
1824 |
+
}
|
1825 |
}
|
1826 |
|
1827 |
global $WpSmush;
|
lib/nextgen-integration/class-wp-smush-nextgen-admin.php
CHANGED
@@ -101,11 +101,10 @@ if ( ! class_exists( 'WpSmushNextGenAdmin' ) ) {
|
|
101 |
* @param $id
|
102 |
*/
|
103 |
function wp_smush_column_options( $column_name, $id, $echo = false ) {
|
104 |
-
global $wpsmushnextgenstats;
|
105 |
|
106 |
//NExtGen Doesn't returns Column name, weird? yeah, right, it is proper because hook is called for the particular column
|
107 |
if ( $column_name == 'wp_smush_image' || $column_name == '' ) {
|
108 |
-
$supported_image = array( 'image/jpeg', 'image/gif', 'image/png', 'image/jpg' );
|
109 |
|
110 |
// Registry Object for NextGen Gallery
|
111 |
$registry = C_Component_Registry::get_instance();
|
@@ -129,10 +128,12 @@ if ( ! class_exists( 'WpSmushNextGenAdmin' ) ) {
|
|
129 |
$image_type = $this->get_file_type( $file_path );
|
130 |
|
131 |
//If image type not supported
|
132 |
-
if ( ! $image_type || ! in_array( $image_type, $
|
133 |
return;
|
134 |
}
|
135 |
|
|
|
|
|
136 |
//Check Image metadata, if smushed, print the stats or super smush button
|
137 |
if ( ! empty( $image->meta_data['wp_smush'] ) ) {
|
138 |
//Echo the smush stats
|
@@ -377,18 +378,17 @@ if ( ! class_exists( 'WpSmushNextGenAdmin' ) ) {
|
|
377 |
//Page Header
|
378 |
$this->bulk_ui->smush_page_header(); ?>
|
379 |
<!-- Bulk Smush Progress Bar -->
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
$this->get_nextgen_attachments(); ?>
|
392 |
</div><?php
|
393 |
$this->bulk_ui->smush_page_footer();
|
394 |
}
|
@@ -430,7 +430,7 @@ if ( ! class_exists( 'WpSmushNextGenAdmin' ) ) {
|
|
430 |
} else { ?>
|
431 |
<!-- Hide All done div if there are images pending -->
|
432 |
<div class="wp-smush-notice wp-smush-all-done<?php echo $all_done ? '' : ' hidden' ?>">
|
433 |
-
<i class="dev-icon dev-icon-tick"></i><?php esc_html_e( "
|
434 |
</div>
|
435 |
<div class="wp-smush-bulk-wrapper <?php echo $all_done ? ' hidden' : ''; ?>"><?php
|
436 |
//If all the images in media library are smushed
|
@@ -447,7 +447,6 @@ if ( ! class_exists( 'WpSmushNextGenAdmin' ) ) {
|
|
447 |
</span>
|
448 |
</div>
|
449 |
<hr class="wp-smush-sep">
|
450 |
-
<div class="smush-final-log notice notice-warning inline hidden"></div>
|
451 |
<button type="button"
|
452 |
class="wp-smush-button wp-smush-nextgen-bulk"><?php echo $button_content; ?></button><?php
|
453 |
|
@@ -492,7 +491,7 @@ if ( ! class_exists( 'WpSmushNextGenAdmin' ) ) {
|
|
492 |
* Outputs the Smush stats for the site
|
493 |
*/
|
494 |
function smush_stats_container() {
|
495 |
-
global $WpSmush, $wpsmushnextgenstats, $wpsmushit_admin;
|
496 |
|
497 |
//If we have resmush list, smushed_count = totalcount - resmush count, else smushed_count
|
498 |
$smushed_count = ( $resmush_count = count( $this->resmush_ids ) ) > 0 ? ( $this->total_count - ( $resmush_count + $this->remaining_count ) ) : $this->smushed_count;
|
@@ -547,7 +546,7 @@ if ( ! class_exists( 'WpSmushNextGenAdmin' ) ) {
|
|
547 |
<span class="float-r wp-smush-stats">
|
548 |
<?php
|
549 |
if ( $WpSmush->lossy_enabled ) {
|
550 |
-
$count = $
|
551 |
echo '<strong><span class="smushed-count">' . $count . '</span>/' . $this->total_count . '</strong>';
|
552 |
} else {
|
553 |
printf( esc_html__( "%sDISABLED%s", "wp-smushit" ), '<span class="wp-smush-lossy-disabled">', '</span>' );
|
@@ -646,6 +645,46 @@ if ( ! class_exists( 'WpSmushNextGenAdmin' ) ) {
|
|
646 |
$this->remaining_count = $wpsmushnextgenstats->get_ngg_images( 'unsmushed', true );
|
647 |
}
|
648 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
649 |
}//End of Class
|
650 |
|
651 |
}//End Of if class not exists
|
101 |
* @param $id
|
102 |
*/
|
103 |
function wp_smush_column_options( $column_name, $id, $echo = false ) {
|
104 |
+
global $wpsmushnextgenstats, $wpsmushit_admin;
|
105 |
|
106 |
//NExtGen Doesn't returns Column name, weird? yeah, right, it is proper because hook is called for the particular column
|
107 |
if ( $column_name == 'wp_smush_image' || $column_name == '' ) {
|
|
|
108 |
|
109 |
// Registry Object for NextGen Gallery
|
110 |
$registry = C_Component_Registry::get_instance();
|
128 |
$image_type = $this->get_file_type( $file_path );
|
129 |
|
130 |
//If image type not supported
|
131 |
+
if ( ! $image_type || ! in_array( $image_type, $wpsmushit_admin->mime_types ) ) {
|
132 |
return;
|
133 |
}
|
134 |
|
135 |
+
$image->meta_data = $this->get_combined_stats( $image->meta_data );
|
136 |
+
|
137 |
//Check Image metadata, if smushed, print the stats or super smush button
|
138 |
if ( ! empty( $image->meta_data['wp_smush'] ) ) {
|
139 |
//Echo the smush stats
|
378 |
//Page Header
|
379 |
$this->bulk_ui->smush_page_header(); ?>
|
380 |
<!-- Bulk Smush Progress Bar -->
|
381 |
+
<div class="wp-smushit-container-left col-two-third float-l"><?php
|
382 |
+
//Bulk Smush Container
|
383 |
+
$this->bulk_smush_container();
|
384 |
+
?>
|
385 |
+
</div>
|
386 |
|
387 |
+
<!-- Stats -->
|
388 |
+
<div class="wp-smushit-container-right col-third float-l"><?php
|
389 |
+
//Stats
|
390 |
+
$this->smush_stats_container(); ?>
|
391 |
+
</div><!-- End Of Smushit Container right -->
|
|
|
392 |
</div><?php
|
393 |
$this->bulk_ui->smush_page_footer();
|
394 |
}
|
430 |
} else { ?>
|
431 |
<!-- Hide All done div if there are images pending -->
|
432 |
<div class="wp-smush-notice wp-smush-all-done<?php echo $all_done ? '' : ' hidden' ?>">
|
433 |
+
<i class="dev-icon dev-icon-tick"></i><?php esc_html_e( "All images are smushed and up to date. Awesome!", "wp-smushit" ); ?>
|
434 |
</div>
|
435 |
<div class="wp-smush-bulk-wrapper <?php echo $all_done ? ' hidden' : ''; ?>"><?php
|
436 |
//If all the images in media library are smushed
|
447 |
</span>
|
448 |
</div>
|
449 |
<hr class="wp-smush-sep">
|
|
|
450 |
<button type="button"
|
451 |
class="wp-smush-button wp-smush-nextgen-bulk"><?php echo $button_content; ?></button><?php
|
452 |
|
491 |
* Outputs the Smush stats for the site
|
492 |
*/
|
493 |
function smush_stats_container() {
|
494 |
+
global $WpSmush, $wpsmushnextgenstats, $wpsmushit_admin, $wpsmush_stats;
|
495 |
|
496 |
//If we have resmush list, smushed_count = totalcount - resmush count, else smushed_count
|
497 |
$smushed_count = ( $resmush_count = count( $this->resmush_ids ) ) > 0 ? ( $this->total_count - ( $resmush_count + $this->remaining_count ) ) : $this->smushed_count;
|
546 |
<span class="float-r wp-smush-stats">
|
547 |
<?php
|
548 |
if ( $WpSmush->lossy_enabled ) {
|
549 |
+
$count = $wpsmush_stats->super_smushed_count( 'nextgen', $wpsmushnextgenstats->get_ngg_images( 'smushed' ) );
|
550 |
echo '<strong><span class="smushed-count">' . $count . '</span>/' . $this->total_count . '</strong>';
|
551 |
} else {
|
552 |
printf( esc_html__( "%sDISABLED%s", "wp-smushit" ), '<span class="wp-smush-lossy-disabled">', '</span>' );
|
645 |
$this->remaining_count = $wpsmushnextgenstats->get_ngg_images( 'unsmushed', true );
|
646 |
}
|
647 |
|
648 |
+
/**
|
649 |
+
* Combine the resizing stats and smush stats
|
650 |
+
*
|
651 |
+
* @param $metadata
|
652 |
+
*
|
653 |
+
* @return bool|string
|
654 |
+
*/
|
655 |
+
function get_combined_stats( $metadata ) {
|
656 |
+
if ( empty( $metadata ) ) {
|
657 |
+
return $metadata;
|
658 |
+
}
|
659 |
+
|
660 |
+
$smush_stats = ! empty( $metadata['wp_smush'] ) ? $metadata['wp_smush'] : '';
|
661 |
+
$resize_savings = ! empty( $metadata['wp_smush_resize_savings'] ) ? $metadata['wp_smush_resize_savings'] : '';
|
662 |
+
|
663 |
+
if ( empty( $resize_savings ) ) {
|
664 |
+
return $metadata;
|
665 |
+
}
|
666 |
+
|
667 |
+
$smush_stats['stats']['bytes'] = ! empty( $resize_savings['bytes'] ) ? $smush_stats['stats']['bytes'] + $resize_savings['bytes'] : $smush_stats['stats']['bytes'];
|
668 |
+
$smush_stats['stats']['size_before'] = ! empty( $resize_savings['size_before'] ) ? $smush_stats['stats']['size_before'] + $resize_savings['size_before'] : $smush_stats['stats']['size_before'];
|
669 |
+
$smush_stats['stats']['size_after'] = ! empty( $resize_savings['size_after'] ) ? $smush_stats['stats']['size_after'] + $resize_savings['size_after'] : $smush_stats['stats']['size_after'];
|
670 |
+
$smush_stats['stats']['percent'] = ! empty( $resize_savings['size_before'] ) ? ( $smush_stats['stats']['bytes'] / $smush_stats['stats']['size_before'] ) * 100 : $smush_stats['stats']['percent'];
|
671 |
+
|
672 |
+
//Round off
|
673 |
+
$smush_stats['stats']['percent'] = round( $smush_stats['stats']['percent'], 2 );
|
674 |
+
|
675 |
+
//Full Image
|
676 |
+
$smush_stats['sizes']['full']['bytes'] = ! empty( $resize_savings['bytes'] ) ? $smush_stats['sizes']['full']['bytes'] + $resize_savings['bytes'] : $smush_stats['stats']['bytes'];
|
677 |
+
$smush_stats['sizes']['full']['size_before'] = ! empty( $resize_savings['size_before'] ) ? $smush_stats['sizes']['full']['size_before'] + $resize_savings['size_before'] : $smush_stats['sizes']['full']['size_before'];
|
678 |
+
$smush_stats['sizes']['full']['size_after'] = ! empty( $resize_savings['size_after'] ) ? $smush_stats['sizes']['full']['size_after'] + $resize_savings['size_after'] : $smush_stats['sizes']['full']['size_after'];
|
679 |
+
$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'];
|
680 |
+
|
681 |
+
$smush_stats['sizes']['full']['percent'] = round( $smush_stats['sizes']['full']['percent'], 2 );
|
682 |
+
|
683 |
+
$metadata['wp_smush'] = $smush_stats;
|
684 |
+
return $metadata;
|
685 |
+
|
686 |
+
}
|
687 |
+
|
688 |
}//End of Class
|
689 |
|
690 |
}//End Of if class not exists
|
lib/nextgen-integration/class-wp-smush-nextgen-bulk.php
CHANGED
@@ -8,7 +8,7 @@ if ( ! class_exists( 'WPSmushNextGenBulk' ) ) {
|
|
8 |
|
9 |
function smush_bulk() {
|
10 |
|
11 |
-
global $wpsmushnextgenstats, $wpsmushit_admin, $wpsmushnextgenadmin, $WpSmush;
|
12 |
|
13 |
$stats = array();
|
14 |
|
@@ -16,40 +16,49 @@ if ( ! class_exists( 'WPSmushNextGenBulk' ) ) {
|
|
16 |
wp_send_json_error( 'missing id' );
|
17 |
}
|
18 |
|
|
|
|
|
19 |
$atchmnt_id = absint( (int) $_GET['attachment_id'] );
|
20 |
|
21 |
$smush = $this->smush_image( $atchmnt_id, '', false );
|
22 |
|
23 |
-
$stats = $wpsmushnextgenstats->get_smush_stats();
|
24 |
-
|
25 |
-
$stats['smushed'] = $wpsmushnextgenstats->get_ngg_images('smushed', true );
|
26 |
-
|
27 |
-
if ( $WpSmush->lossy_enabled ) {
|
28 |
-
//Most of the time the stats would be update and the function won't need to go thorugh all the
|
29 |
-
//images to get the count, but in case it has to, we provide the SMushed attachment list
|
30 |
-
$stats['super_smushed'] = $wpsmushit_admin->super_smushed_count('nextgen', $wpsmushnextgenstats->get_ngg_images('smushed' ) );
|
31 |
-
}
|
32 |
-
if( empty( $wpsmushnextgenadmin->resmush_ids ) ) {
|
33 |
-
$wpsmushnextgenadmin->resmush_ids = get_option( 'wp-smush-nextgen-resmush-list' );
|
34 |
-
}
|
35 |
-
$stats['resmush_count'] = count( $wpsmushnextgenadmin->resmush_ids );
|
36 |
-
|
37 |
-
$stats['total'] = $wpsmushnextgenstats->total_count();
|
38 |
-
|
39 |
if ( is_wp_error( $smush ) ) {
|
|
|
|
|
40 |
$error = $smush->get_error_message();
|
41 |
//Check for timeout error and suggest to filter timeout
|
42 |
if( strpos( $error, 'timed out') ) {
|
43 |
$msg = '<p class="wp-smush-error-message">' . esc_html__( "Smush request timed out, You can try setting a higher value ( > 60 ) for `WP_SMUSH_API_TIMEOUT`.", "wp-smushit" ) . '</p>';
|
44 |
}
|
45 |
-
wp_send_json_error( array( 'stats' => $stats, 'error_msg' => $msg ) );
|
46 |
} else {
|
47 |
//Check if a resmush request, update the resmush list
|
48 |
if( !empty( $_REQUEST['is_bulk_resmush']) && $_REQUEST['is_bulk_resmush'] ) {
|
49 |
$wpsmushit_admin->update_resmush_list( $atchmnt_id, 'wp-smush-nextgen-resmush-list' );
|
50 |
}
|
51 |
-
wp_send_json_success( array( 'stats' => $stats ) );
|
52 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
|
55 |
}
|
8 |
|
9 |
function smush_bulk() {
|
10 |
|
11 |
+
global $wpsmushnextgenstats, $wpsmush_stats, $wpsmushit_admin, $wpsmushnextgenadmin, $WpSmush;
|
12 |
|
13 |
$stats = array();
|
14 |
|
16 |
wp_send_json_error( 'missing id' );
|
17 |
}
|
18 |
|
19 |
+
$send_error = false;
|
20 |
+
|
21 |
$atchmnt_id = absint( (int) $_GET['attachment_id'] );
|
22 |
|
23 |
$smush = $this->smush_image( $atchmnt_id, '', false );
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
if ( is_wp_error( $smush ) ) {
|
26 |
+
$send_error = true;
|
27 |
+
$msg = '';
|
28 |
$error = $smush->get_error_message();
|
29 |
//Check for timeout error and suggest to filter timeout
|
30 |
if( strpos( $error, 'timed out') ) {
|
31 |
$msg = '<p class="wp-smush-error-message">' . esc_html__( "Smush request timed out, You can try setting a higher value ( > 60 ) for `WP_SMUSH_API_TIMEOUT`.", "wp-smushit" ) . '</p>';
|
32 |
}
|
|
|
33 |
} else {
|
34 |
//Check if a resmush request, update the resmush list
|
35 |
if( !empty( $_REQUEST['is_bulk_resmush']) && $_REQUEST['is_bulk_resmush'] ) {
|
36 |
$wpsmushit_admin->update_resmush_list( $atchmnt_id, 'wp-smush-nextgen-resmush-list' );
|
37 |
}
|
|
|
38 |
}
|
39 |
+
|
40 |
+
//Get the Latest Stats
|
41 |
+
$stats = $wpsmushnextgenstats->get_smush_stats();
|
42 |
+
|
43 |
+
if ( $WpSmush->lossy_enabled ) {
|
44 |
+
//Most of the time the stats would be update and the function won't need to go thorugh all the
|
45 |
+
//images to get the count, but in case it has to, we provide the SMushed attachment list
|
46 |
+
$stats['super_smushed'] = $wpsmush_stats->super_smushed_count('nextgen', $wpsmushnextgenstats->get_ngg_images('smushed' ) );
|
47 |
+
}
|
48 |
+
if( empty( $wpsmushnextgenadmin->resmush_ids ) ) {
|
49 |
+
$wpsmushnextgenadmin->resmush_ids = get_option( 'wp-smush-nextgen-resmush-list' );
|
50 |
+
}
|
51 |
+
|
52 |
+
$resmush_count = ! empty( $wpsmushnextgenadmin->resmush_ids ) ? count( $wpsmushnextgenadmin->resmush_ids ) : count( $wpsmushnextgenadmin->resmush_ids = get_option( 'wp-smush-nextgen-resmush-list' ) );
|
53 |
+
$smushed_count = $wpsmushnextgenstats->get_ngg_images( 'smushed', true );
|
54 |
+
|
55 |
+
$stats['total'] = $wpsmushnextgenstats->total_count();
|
56 |
+
|
57 |
+
$stats['smushed'] = ! empty( $wpsmushnextgenadmin->resmush_ids ) ? $smushed_count - $resmush_count : $smushed_count;
|
58 |
+
|
59 |
+
$send_error ? wp_send_json_error( array( 'stats' => $stats,
|
60 |
+
'error_msg' => $msg
|
61 |
+
) ) : wp_send_json_success( array( 'stats' => $stats ) );
|
62 |
}
|
63 |
|
64 |
}
|
lib/nextgen-integration/class-wp-smush-nextgen-stats.php
CHANGED
@@ -32,6 +32,9 @@ if ( ! class_exists( 'WpSmushNextGenStats' ) ) {
|
|
32 |
//Update images list in cache
|
33 |
add_action( 'wp_smush_nextgen_image_stats', array( $this, 'update_cache' ) );
|
34 |
|
|
|
|
|
|
|
35 |
//Get the stats for single image, update the global stats
|
36 |
add_action( 'wp_smush_nextgen_image_stats', array( $this, 'update_stats' ), '', 2 );
|
37 |
}
|
@@ -91,13 +94,8 @@ if ( ! class_exists( 'WpSmushNextGenStats' ) ) {
|
|
91 |
*/
|
92 |
function get_ngg_images( $type = 'smushed', $count = false, $force_update = false ) {
|
93 |
|
94 |
-
global $wpdb;
|
95 |
-
|
96 |
-
* Allows to set a limit of mysql query
|
97 |
-
* Default value is 2000
|
98 |
-
*/
|
99 |
-
$limit = apply_filters( 'wp_smush_nextgen_query_limit', 2000 );
|
100 |
-
$limit = intval( $limit );
|
101 |
$offset = 0;
|
102 |
|
103 |
//Check type of images being queried
|
@@ -299,6 +297,44 @@ if ( ! class_exists( 'WpSmushNextGenStats' ) ) {
|
|
299 |
*
|
300 |
*/
|
301 |
function update_stats( $image_id, $stats ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
global $WpSmush;
|
303 |
|
304 |
$stats = ! empty( $stats['stats'] ) ? $stats['stats'] : '';
|
32 |
//Update images list in cache
|
33 |
add_action( 'wp_smush_nextgen_image_stats', array( $this, 'update_cache' ) );
|
34 |
|
35 |
+
//Add the resizing stats to Global stats
|
36 |
+
add_action( 'wp_smush_image_nextgen_resized', array( $this, 'update_stats' ), '', 2 );
|
37 |
+
|
38 |
//Get the stats for single image, update the global stats
|
39 |
add_action( 'wp_smush_nextgen_image_stats', array( $this, 'update_stats' ), '', 2 );
|
40 |
}
|
94 |
*/
|
95 |
function get_ngg_images( $type = 'smushed', $count = false, $force_update = false ) {
|
96 |
|
97 |
+
global $wpdb, $wpsmushit_admin;
|
98 |
+
$limit = $wpsmushit_admin->nextgen_query_limit();
|
|
|
|
|
|
|
|
|
|
|
99 |
$offset = 0;
|
100 |
|
101 |
//Check type of images being queried
|
297 |
*
|
298 |
*/
|
299 |
function update_stats( $image_id, $stats ) {
|
300 |
+
|
301 |
+
global $WpSmush;
|
302 |
+
|
303 |
+
$stats = ! empty( $stats['stats'] ) ? $stats['stats'] : '';
|
304 |
+
|
305 |
+
$smush_stats = get_option( 'wp_smush_stats_nextgen', array() );
|
306 |
+
|
307 |
+
if ( ! empty( $stats ) ) {
|
308 |
+
|
309 |
+
//Compression Bytes
|
310 |
+
$smush_stats['bytes'] = ! empty( $smush_stats['bytes'] ) ? ( $smush_stats['bytes'] + $stats['bytes'] ) : $stats['bytes'];
|
311 |
+
|
312 |
+
//Human Readable
|
313 |
+
$smush_stats['human'] = ! empty( $smush_stats['bytes'] ) ? $WpSmush->format_bytes( $smush_stats['bytes'] ) : '';
|
314 |
+
|
315 |
+
//Size of images before the compression
|
316 |
+
$smush_stats['size_before'] = ! empty( $smush_stats['size_before'] ) ? ( $smush_stats['size_before'] + $stats['size_before'] ) : $stats['size_before'];
|
317 |
+
|
318 |
+
//Size of image after compression
|
319 |
+
$smush_stats['size_after'] = ! empty( $smush_stats['size_after'] ) ? ( $smush_stats['size_after'] + $stats['size_after'] ) : $stats['size_after'];
|
320 |
+
|
321 |
+
//Compression Percentage
|
322 |
+
$smush_stats['percent'] = ! empty( $smush_stats['size_before'] ) && !empty( $smush_stats['size_after'] ) && $smush_stats['size_before'] > 0 ? ( $smush_stats['bytes'] / $smush_stats['size_before'] ) * 100 : $stats['percent'];
|
323 |
+
}
|
324 |
+
|
325 |
+
update_option( 'wp_smush_stats_nextgen', $smush_stats );
|
326 |
+
|
327 |
+
//Cahce the results, we don't need a timed cache expiration.
|
328 |
+
wp_cache_set( 'wp_smush_stats_nextgen', $smush_stats, 'nextgen' );
|
329 |
+
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
* Updated the global smush stats for NextGen gallery
|
333 |
+
*
|
334 |
+
* @param $stats Compression stats fo respective image
|
335 |
+
*
|
336 |
+
*/
|
337 |
+
function update_resize_stats( $image_id, $stats ) {
|
338 |
global $WpSmush;
|
339 |
|
340 |
$stats = ! empty( $stats['stats'] ) ? $stats['stats'] : '';
|
readme.txt
CHANGED
@@ -1,28 +1,30 @@
|
|
1 |
=== WP Smush - Image Optimization ===
|
2 |
Plugin Name: WP Smush - Image Optimization
|
3 |
-
Version: 2.
|
4 |
Author: WPMU DEV
|
5 |
Author URI: http://premium.wpmudev.org/
|
6 |
Contributors: WPMUDEV, alexdunae
|
7 |
Tags: image optimization, image compression, attachment,Attachments,compress,Compress Image File,Compress Image Size,Compress JPG,Compressed JPG, Compression Image,Image,Images,JPG,Optimise,Optimize,Photo,Photos,Pictures,PNG,Reduce Image Size,Smush,Smush.it,Upload,WordPress Compression,WordPress Image Tool,Yahoo, Yahoo Smush.it
|
8 |
Requires at least: 3.5
|
9 |
-
Tested up to: 4.5
|
10 |
-
Stable tag: 2.
|
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>
|
|
|
|
|
18 |
|
19 |
Our servers do all the heavy lifting. Strip hidden bulky information from your images and reduce file size without losing quality.
|
20 |
|
21 |
Large image files may be slowing down your site without you even knowing it. WP Smush uses WPMU DEV’s super servers to quickly smush every single one of your images and cuts all the unnecessary data without slowing down your site.
|
22 |
|
23 |
-
[youtube https://www.youtube.com/watch?v=
|
24 |
|
25 |
-
|
26 |
|
27 |
<a href="https://garage.godaddy.com/wordpress-plugin-partner-program/directory/?cvosrc=advocacy.evangelism.WP3" rel="nofollow"><img src="https://garage.godaddy.com/wp-content/uploads/badges/godaddy-plugin-partner-program-badge.svg" title="GoDaddy Plugin Program Partner" alt="GoDaddy Plugin Program Partner"/></a>
|
28 |
|
@@ -32,7 +34,7 @@ Heavy image files may be slowing down your site without you even knowing it. WP
|
|
32 |
★★★★★ <br>
|
33 |
“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>
|
34 |
|
35 |
-
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, Smush can help keep your site running fast. Use automatic smush and compress every new image upload without thinking about.
|
36 |
|
37 |
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.
|
38 |
|
@@ -41,12 +43,13 @@ The faster your site loads, the more Google, Bing, Yahoo and other search engine
|
|
41 |
<br>
|
42 |
<ul>
|
43 |
<li>Optimize your images using advanced lossless compression techniques.</li>
|
|
|
44 |
<li>Process JPEG, GIF and PNG image files.</li>
|
45 |
<li>Auto-smush your attachments on upload.</li>
|
46 |
<li>Manually smush your attachments individually in the media library, or in bulk 50 attachments at a time.</li>
|
47 |
<li>Smush all standard web-sized images 1MB or smaller. </li>
|
48 |
-
|
49 |
-
|
50 |
</ul>
|
51 |
|
52 |
Install WP Smush now and find out why it's the most popular image optimization plugin for WordPress available today with over 2.7 million downloads.
|
@@ -71,7 +74,7 @@ Upgrade to WP Smush Pro and optimize more and larger image files faster to incre
|
|
71 |
== Screenshots ==
|
72 |
|
73 |
1. Watch as your image library is processed – up to 50 images at a time.
|
74 |
-
2. Set automatic smush and optomize every image as it is uploaded.
|
75 |
3. Smush will find and optimize images for you.
|
76 |
|
77 |
== Installation ==
|
@@ -88,6 +91,19 @@ Yahoo's Smush.it API is gone forever. So WPMU DEV built our own free API that is
|
|
88 |
|
89 |
== Changelog ==
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
= 2.2.2 =
|
92 |
|
93 |
- Fixed: JS error causing issue with Editor on some installs, plugin conflict with CoursePress plugin, ACF ( Clear All Caches after plugin upgrade, Cloudflare as well )
|
1 |
=== WP Smush - Image Optimization ===
|
2 |
Plugin Name: WP Smush - Image Optimization
|
3 |
+
Version: 2.3
|
4 |
Author: WPMU DEV
|
5 |
Author URI: http://premium.wpmudev.org/
|
6 |
Contributors: WPMUDEV, alexdunae
|
7 |
Tags: image optimization, image compression, attachment,Attachments,compress,Compress Image File,Compress Image Size,Compress JPG,Compressed JPG, Compression Image,Image,Images,JPG,Optimise,Optimize,Photo,Photos,Pictures,PNG,Reduce Image Size,Smush,Smush.it,Upload,WordPress Compression,WordPress Image Tool,Yahoo, Yahoo Smush.it
|
8 |
Requires at least: 3.5
|
9 |
+
Tested up to: 4.5.2
|
10 |
+
Stable tag: 2.3
|
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 |
|
21 |
Our servers do all the heavy lifting. Strip hidden bulky information from your images and reduce file size without losing quality.
|
22 |
|
23 |
Large image files may be slowing down your site without you even knowing it. WP Smush uses WPMU DEV’s super servers to quickly smush every single one of your images and cuts all the unnecessary data without slowing down your site.
|
24 |
|
25 |
+
[youtube https://www.youtube.com/watch?v=BLqk4KPRz28&feature=youtu.be]
|
26 |
|
27 |
+
WP Smush meticulously scans every image you upload – or have already added to your site – cuts all the unnecessary data and scales it for you before adding it to your media library.
|
28 |
|
29 |
<a href="https://garage.godaddy.com/wordpress-plugin-partner-program/directory/?cvosrc=advocacy.evangelism.WP3" rel="nofollow"><img src="https://garage.godaddy.com/wp-content/uploads/badges/godaddy-plugin-partner-program-badge.svg" title="GoDaddy Plugin Program Partner" alt="GoDaddy Plugin Program Partner"/></a>
|
30 |
|
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, Smush can help keep your site running fast. Use automatic smush to scale and compress every new image upload without thinking about it.
|
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 |
|
43 |
<br>
|
44 |
<ul>
|
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 |
|
55 |
Install WP Smush now and find out why it's the most popular image optimization plugin for WordPress available today with over 2.7 million downloads.
|
74 |
== Screenshots ==
|
75 |
|
76 |
1. Watch as your image library is processed – up to 50 images at a time.
|
77 |
+
2. Set automatic smush to resize and optomize every image as it is uploaded.
|
78 |
3. Smush will find and optimize images for you.
|
79 |
|
80 |
== Installation ==
|
91 |
|
92 |
== Changelog ==
|
93 |
|
94 |
+
= 2.3 =
|
95 |
+
|
96 |
+
* Fixed:
|
97 |
+
* Tooltip on image edit page
|
98 |
+
* Warning and Notices
|
99 |
+
* Updated:
|
100 |
+
* Improved stats calculation
|
101 |
+
* Bulk Smush page optimised for Image heavy sites
|
102 |
+
* Cleanup on uninstall
|
103 |
+
* Added:
|
104 |
+
* Image Resizing option for Media, NextGen(Pro Only) images
|
105 |
+
* Total image count on stats page
|
106 |
+
|
107 |
= 2.2.2 =
|
108 |
|
109 |
- Fixed: JS error causing issue with Editor on some installs, plugin conflict with CoursePress plugin, ACF ( Clear All Caches after plugin upgrade, Cloudflare as well )
|
uninstall.php
CHANGED
@@ -17,9 +17,12 @@ $smushit_keys = array(
|
|
17 |
'original',
|
18 |
'lossy',
|
19 |
'backup',
|
|
|
|
|
20 |
'nextgen',
|
21 |
'keep_exif',
|
22 |
'resmush-list',
|
|
|
23 |
'nextgen-resmush-list',
|
24 |
'super_smushed',
|
25 |
'super_smushed_nextgen',
|
@@ -27,53 +30,91 @@ $smushit_keys = array(
|
|
27 |
'skip-redirect',
|
28 |
'hide_smush_welcome',
|
29 |
'hide_upgrade_notice',
|
|
|
30 |
'install-type',
|
31 |
'lossy-updated'
|
32 |
);
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
50 |
delete_option( $key );
|
51 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
|
|
53 |
//Delete Post meta
|
54 |
$meta_type = 'post';
|
55 |
-
$user_id = 0;
|
56 |
$meta_key = 'wp-smpro-smush-data';
|
57 |
$meta_value = '';
|
58 |
$delete_all = true;
|
59 |
|
60 |
if ( is_multisite() ) {
|
61 |
$offset = 0;
|
62 |
-
$limit
|
63 |
-
while( $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs} LIMIT $offset, $limit", ARRAY_A ) ) {
|
64 |
if ( $blogs ) {
|
65 |
foreach ( $blogs as $blog ) {
|
66 |
switch_to_blog( $blog['blog_id'] );
|
67 |
-
delete_metadata( $meta_type,
|
68 |
-
delete_metadata( $meta_type,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
}
|
70 |
restore_current_blog();
|
71 |
}
|
72 |
$offset += $limit;
|
73 |
}
|
74 |
} else {
|
75 |
-
delete_metadata( $meta_type,
|
76 |
-
delete_metadata( $meta_type,
|
|
|
77 |
}
|
78 |
//@todo: Add procedure to delete backup files
|
79 |
?>
|
17 |
'original',
|
18 |
'lossy',
|
19 |
'backup',
|
20 |
+
'resize',
|
21 |
+
'resize-sizes',
|
22 |
'nextgen',
|
23 |
'keep_exif',
|
24 |
'resmush-list',
|
25 |
+
'skip-redirect',
|
26 |
'nextgen-resmush-list',
|
27 |
'super_smushed',
|
28 |
'super_smushed_nextgen',
|
30 |
'skip-redirect',
|
31 |
'hide_smush_welcome',
|
32 |
'hide_upgrade_notice',
|
33 |
+
'hide_update_info',
|
34 |
'install-type',
|
35 |
'lossy-updated'
|
36 |
);
|
37 |
+
|
38 |
+
//Cache Keys
|
39 |
+
$cache_keys = array(
|
40 |
+
'smush_global_stats',
|
41 |
+
);
|
42 |
+
|
43 |
+
$cache_smush_group = array(
|
44 |
+
'exceeding_items',
|
45 |
+
'wp-smush-resize_savings',
|
46 |
+
);
|
47 |
+
$cache_nextgen_group = array(
|
48 |
+
'wp_smush_images',
|
49 |
+
'wp_smush_images_smushed',
|
50 |
+
'wp_smush_images_unsmushed',
|
51 |
+
'wp_smush_stats_nextgen',
|
52 |
+
|
53 |
+
);
|
54 |
+
|
55 |
+
if ( ! is_multisite() ) {
|
56 |
+
//Delete Options
|
57 |
+
foreach ( $smushit_keys as $key ) {
|
58 |
+
$key = 'wp-smush-' . $key;
|
59 |
delete_option( $key );
|
60 |
}
|
61 |
+
//Delete Cache data
|
62 |
+
foreach ( $cache_keys as $key ) {
|
63 |
+
wp_cache_delete( $key );
|
64 |
+
}
|
65 |
+
|
66 |
+
foreach ( $cache_smush_group as $s_key ) {
|
67 |
+
wp_cache_delete( $s_key, 'smush' );
|
68 |
+
}
|
69 |
+
|
70 |
+
foreach ( $cache_nextgen_group as $n_key ) {
|
71 |
+
wp_cache_delete( $n_key, 'nextgen' );
|
72 |
+
}
|
73 |
+
|
74 |
}
|
75 |
+
|
76 |
//Delete Post meta
|
77 |
$meta_type = 'post';
|
|
|
78 |
$meta_key = 'wp-smpro-smush-data';
|
79 |
$meta_value = '';
|
80 |
$delete_all = true;
|
81 |
|
82 |
if ( is_multisite() ) {
|
83 |
$offset = 0;
|
84 |
+
$limit = 100;
|
85 |
+
while ( $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs} LIMIT $offset, $limit", ARRAY_A ) ) {
|
86 |
if ( $blogs ) {
|
87 |
foreach ( $blogs as $blog ) {
|
88 |
switch_to_blog( $blog['blog_id'] );
|
89 |
+
delete_metadata( $meta_type, null, $meta_key, $meta_value, $delete_all );
|
90 |
+
delete_metadata( $meta_type, null, 'wp-smush-lossy', '', $delete_all );
|
91 |
+
delete_metadata( $meta_type, null, 'wp-smush-resize_savings', '', $delete_all );
|
92 |
+
foreach ( $smushit_keys as $key ) {
|
93 |
+
$key = 'wp-smush-' . $key;
|
94 |
+
delete_option( $key );
|
95 |
+
delete_site_option( $key );
|
96 |
+
}
|
97 |
+
//Delete Cache data
|
98 |
+
foreach ( $cache_keys as $key ) {
|
99 |
+
wp_cache_delete( $key );
|
100 |
+
}
|
101 |
+
|
102 |
+
foreach ( $cache_smush_group as $s_key ) {
|
103 |
+
wp_cache_delete( $s_key, 'smush' );
|
104 |
+
}
|
105 |
+
|
106 |
+
foreach ( $cache_nextgen_group as $n_key ) {
|
107 |
+
wp_cache_delete( $n_key, 'nextgen' );
|
108 |
+
}
|
109 |
}
|
110 |
restore_current_blog();
|
111 |
}
|
112 |
$offset += $limit;
|
113 |
}
|
114 |
} else {
|
115 |
+
delete_metadata( $meta_type, null, $meta_key, $meta_value, $delete_all );
|
116 |
+
delete_metadata( $meta_type, null, 'wp-smush-lossy', '', $delete_all );
|
117 |
+
delete_metadata( $meta_type, null, 'wp-smush-resize_savings', '', $delete_all );
|
118 |
}
|
119 |
//@todo: Add procedure to delete backup files
|
120 |
?>
|
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.
|
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.
|
39 |
|
40 |
/**
|
41 |
* Set the default timeout for API request and AJAX timeout
|
@@ -73,9 +73,9 @@ require_once WP_SMUSH_DIR . 'lib/class-wp-smush.php';
|
|
73 |
*/
|
74 |
if ( ! function_exists( 'wp_smush_rating_message' ) ) {
|
75 |
function wp_smush_rating_message( $message ) {
|
76 |
-
global $wpsmushit_admin;
|
77 |
$savings = $wpsmushit_admin->global_stats();
|
78 |
-
$image_count = $
|
79 |
$show_stats = false;
|
80 |
|
81 |
//If there is any saving, greater than 1Mb, show stats
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/wp-smushit/
|
5 |
Description: Reduce image file sizes, improve performance and boost your SEO using the free <a href="https://premium.wpmudev.org/">WPMU DEV</a> WordPress Smush API.
|
6 |
Author: WPMU DEV
|
7 |
+
Version: 2.3
|
8 |
Author URI: http://premium.wpmudev.org/
|
9 |
Textdomain: wp-smushit
|
10 |
*/
|
35 |
* Constants
|
36 |
*/
|
37 |
$prefix = 'WP_SMUSH_';
|
38 |
+
$version = '2.3';
|
39 |
|
40 |
/**
|
41 |
* Set the default timeout for API request and AJAX timeout
|
73 |
*/
|
74 |
if ( ! function_exists( 'wp_smush_rating_message' ) ) {
|
75 |
function wp_smush_rating_message( $message ) {
|
76 |
+
global $wpsmushit_admin, $wpsmush_stats;
|
77 |
$savings = $wpsmushit_admin->global_stats();
|
78 |
+
$image_count = $wpsmush_stats->total_count();
|
79 |
$show_stats = false;
|
80 |
|
81 |
//If there is any saving, greater than 1Mb, show stats
|