Easy Watermark - Version 1.0.0

Version Description

  • The plugin has been rewrote from ground up.
Download this release

Release Info

Developer Kubitomakita
Plugin Icon Easy Watermark
Version 1.0.0
Comparing to
See all releases

Code changes from version 0.7.1 to 1.0.0

Files changed (307) hide show
  1. {fonts → assets/dist/fonts}/Arial.ttf +0 -0
  2. {fonts → assets/dist/fonts}/Arial_Black.ttf +0 -0
  3. {fonts → assets/dist/fonts}/Comic_Sans_MS.ttf +0 -0
  4. {fonts → assets/dist/fonts}/Courier_New.ttf +0 -0
  5. {fonts → assets/dist/fonts}/Georgia.ttf +0 -0
  6. {fonts → assets/dist/fonts}/Impact.ttf +0 -0
  7. {fonts → assets/dist/fonts}/Tahoma.ttf +0 -0
  8. {fonts → assets/dist/fonts}/Times_New_Roman.ttf +0 -0
  9. {fonts → assets/dist/fonts}/Trebuchet_MS.ttf +0 -0
  10. {fonts → assets/dist/fonts}/Verdana.ttf +0 -0
  11. {images → assets/dist/images}/alignment-background.jpg +0 -0
  12. assets/dist/scripts/attachment-edit.js +1 -0
  13. assets/dist/scripts/dashboard.js +3 -0
  14. assets/dist/scripts/media-library.js +1 -0
  15. assets/dist/scripts/uploader.js +1 -0
  16. assets/dist/scripts/watermark-edit.js +8 -0
  17. assets/dist/styles/attachment-edit.css +1 -0
  18. assets/dist/styles/dashboard.css +2 -0
  19. assets/dist/styles/media-library.css +1 -0
  20. assets/dist/styles/uploader.css +1 -0
  21. assets/dist/styles/watermark-edit.css +1 -0
  22. classes/class-ew-pluggable.php +0 -48
  23. classes/class-ew-plugin-core.php +0 -114
  24. classes/class-ew-plugin.php +0 -1357
  25. classes/class-ew-settings.php +0 -385
  26. css/colorpicker.css +0 -161
  27. css/style.css +0 -108
  28. css/tools.css +0 -24
  29. easy-watermark.php +22 -0
  30. freemius.php +0 -32
  31. freemius/.gitignore +0 -11
  32. freemius/.travis.yml +0 -11
  33. freemius/README.md +0 -253
  34. freemius/assets/scss/_load.scss +4 -4
  35. freemius/assets/scss/_start.scss +3 -3
  36. freemius/assets/scss/_vars.scss +5 -5
  37. freemius/assets/scss/admin/common.scss +219 -219
  38. freemius/assets/scss/admin/connect.scss +548 -548
  39. freemius/composer.json +0 -10
  40. freemius/includes/class-freemius.php +21794 -21794
  41. freemius/includes/class-fs-api.php +624 -624
  42. freemius/includes/class-fs-options.php +430 -430
  43. freemius/includes/class-fs-plugin-updater.php +1360 -1360
  44. freemius/includes/class-fs-storage.php +523 -523
  45. freemius/includes/fs-core-functions.php +1321 -1321
  46. freemius/includes/fs-essential-functions.php +478 -478
  47. freemius/includes/fs-plugin-info-dialog.php +1142 -1142
  48. freemius/includes/i18n.php +603 -603
  49. freemius/includes/managers/class-fs-admin-notice-manager.php +471 -471
  50. freemius/includes/managers/class-fs-plugin-manager.php +219 -219
  51. freemius/includes/sdk/Exceptions/ArgumentNotExistException.php +8 -8
  52. freemius/includes/sdk/Exceptions/EmptyArgumentException.php +8 -8
  53. freemius/includes/sdk/Exceptions/Exception.php +73 -73
  54. freemius/includes/sdk/Exceptions/InvalidArgumentException.php +7 -7
  55. freemius/includes/sdk/Exceptions/OAuthException.php +11 -11
  56. freemius/includes/sdk/FreemiusBase.php +215 -215
  57. freemius/includes/sdk/FreemiusWordPress.php +703 -703
  58. freemius/package.json +0 -27
  59. freemius/start.php +521 -521
  60. freemius/templates/account.php +791 -791
  61. freemius/templates/account/partials/addon.php +349 -349
  62. freemius/templates/account/partials/site.php +335 -335
  63. freemius/templates/connect.php +931 -931
  64. freemius/templates/pricing.php +170 -170
  65. freemius/templates/tabs.php +189 -189
  66. images/Thumbs.db +0 -0
  67. images/alignment-background-dk.jpg +0 -0
  68. images/alignment-background-lt.jpg +0 -0
  69. images/blank.gif +0 -0
  70. images/colorpicker_background.png +0 -0
  71. images/colorpicker_hex.png +0 -0
  72. images/colorpicker_hsb_b.png +0 -0
  73. images/colorpicker_hsb_h.png +0 -0
  74. images/colorpicker_hsb_s.png +0 -0
  75. images/colorpicker_indic.gif +0 -0
  76. images/colorpicker_overlay.png +0 -0
  77. images/colorpicker_rgb_b.png +0 -0
  78. images/colorpicker_rgb_g.png +0 -0
  79. images/colorpicker_rgb_r.png +0 -0
  80. images/colorpicker_select.gif +0 -0
  81. images/colorpicker_submit.png +0 -0
  82. images/custom_background.png +0 -0
  83. images/custom_hex.png +0 -0
  84. images/custom_hsb_b.png +0 -0
  85. images/custom_hsb_h.png +0 -0
  86. images/custom_hsb_s.png +0 -0
  87. images/custom_indic.gif +0 -0
  88. images/custom_rgb_b.png +0 -0
  89. images/custom_rgb_g.png +0 -0
  90. images/custom_rgb_r.png +0 -0
  91. images/custom_submit.png +0 -0
  92. images/icon-32.png +0 -0
  93. images/select.png +0 -0
  94. images/select2.png +0 -0
  95. images/slider.png +0 -0
  96. index.php +15 -26
  97. js/colorpicker.js +0 -484
  98. js/easy-watermark.js +0 -175
  99. js/ewajax.js +0 -137
  100. js/media-library.js +0 -37
  101. js/old-media-library.js +0 -16
  102. js/restore-all.js +0 -12
  103. js/watermark-all.js +0 -12
  104. languages/easy-watermark-es_ES.mo +0 -0
  105. languages/easy-watermark-es_ES.po +0 -557
  106. languages/easy-watermark-fa_IR.mo +0 -0
  107. languages/easy-watermark-fa_IR.po +0 -548
  108. languages/easy-watermark-fr_FR.mo +0 -0
  109. languages/easy-watermark-fr_FR.po +0 -545
  110. languages/easy-watermark-pl_PL.mo +0 -0
  111. languages/easy-watermark-pl_PL.po +0 -850
  112. languages/easy-watermark-ru_RU.mo +0 -0
  113. languages/easy-watermark-ru_RU.po +0 -595
  114. languages/easy-watermark.pot +0 -754
  115. lib/EasyWatermark.php +0 -1004
  116. readme.txt +66 -40
  117. src/bootstrap.php +64 -0
  118. src/classes/AttachmentProcessor/AttachmentProcessor.php +258 -0
  119. src/classes/AttachmentProcessor/AttachmentProcessorGD.php +732 -0
  120. src/classes/AttachmentProcessor/Manager.php +51 -0
  121. src/classes/Backup/BackupperInterface.php +38 -0
  122. src/classes/Backup/LocalBackupper.php +159 -0
  123. src/classes/Backup/Manager.php +108 -0
  124. src/classes/Core/Assets.php +295 -0
  125. src/classes/Core/Hooks.php +83 -0
  126. src/classes/Core/Installer.php +443 -0
  127. src/classes/Core/Manager.php +195 -0
  128. src/classes/Core/Plugin.php +240 -0
  129. src/classes/Core/View.php +131 -0
  130. src/classes/Dashboard/Dashboard.php +162 -0
  131. src/classes/Dashboard/Page.php +77 -0
  132. src/classes/Dashboard/Permissions.php +133 -0
  133. src/classes/Dashboard/Settings.php +55 -0
  134. src/classes/Dashboard/Tools.php +109 -0
  135. src/classes/Dashboard/Watermarks.php +61 -0
  136. src/classes/Features/AutoWatermarkSwitch.php +58 -0
  137. src/classes/Features/SrcsetFilter.php +181 -0
  138. src/classes/Helpers/Image.php +57 -0
  139. src/classes/Helpers/Text.php +55 -0
  140. src/classes/Metaboxes/Attachment/Watermarks.php +93 -0
  141. src/classes/Metaboxes/AttachmentMetabox.php +25 -0
  142. src/classes/Metaboxes/Metabox.php +153 -0
  143. src/classes/Metaboxes/Watermark/Alignment.php +26 -0
  144. src/classes/Metaboxes/Watermark/ApplyingRules.php +47 -0
  145. src/classes/Metaboxes/Watermark/Placeholders.php +51 -0
  146. src/classes/Metaboxes/Watermark/Preview.php +157 -0
  147. src/classes/Metaboxes/Watermark/Scaling.php +26 -0
  148. src/classes/Metaboxes/Watermark/Submitdiv.php +42 -0
  149. src/classes/Metaboxes/Watermark/TextOptions.php +44 -0
  150. src/classes/Metaboxes/Watermark/WatermarkContent.php +48 -0
  151. src/classes/Metaboxes/WatermarkMetabox.php +70 -0
  152. src/classes/Placeholders/Abstracts/EmailPlaceholder.php +41 -0
  153. src/classes/Placeholders/Abstracts/IntegerPlaceholder.php +41 -0
  154. src/classes/Placeholders/Abstracts/Placeholder.php +201 -0
  155. src/classes/Placeholders/Abstracts/StringPlaceholder.php +41 -0
  156. src/classes/Placeholders/Abstracts/UrlPlaceholder.php +41 -0
  157. src/classes/Placeholders/Attachment/AttachmentDirectUrl.php +49 -0
  158. src/classes/Placeholders/Attachment/AttachmentHeight.php +50 -0
  159. src/classes/Placeholders/Attachment/AttachmentID.php +49 -0
  160. src/classes/Placeholders/Attachment/AttachmentMimeType.php +49 -0
  161. src/classes/Placeholders/Attachment/AttachmentPage.php +49 -0
  162. src/classes/Placeholders/Attachment/AttachmentSize.php +49 -0
  163. src/classes/Placeholders/Attachment/AttachmentTitle.php +49 -0
  164. src/classes/Placeholders/Attachment/AttachmentUploadDate.php +49 -0
  165. src/classes/Placeholders/Attachment/AttachmentWidth.php +50 -0
  166. src/classes/Placeholders/Author/AuthorDisplayName.php +52 -0
  167. src/classes/Placeholders/Author/AuthorEmail.php +52 -0
  168. src/classes/Placeholders/Author/AuthorFirstName.php +52 -0
  169. src/classes/Placeholders/Author/AuthorID.php +52 -0
  170. src/classes/Placeholders/Author/AuthorLastName.php +52 -0
  171. src/classes/Placeholders/Author/AuthorLogin.php +52 -0
  172. src/classes/Placeholders/Author/AuthorNicename.php +52 -0
  173. src/classes/Placeholders/Author/AuthorRole.php +61 -0
  174. src/classes/Placeholders/Author/AuthorUrl.php +52 -0
  175. src/classes/Placeholders/Blog/AdminEmail.php +39 -0
  176. src/classes/Placeholders/Blog/BlogName.php +39 -0
  177. src/classes/Placeholders/Blog/BlogUrl.php +39 -0
  178. src/classes/Placeholders/DateTime/Date.php +39 -0
  179. src/classes/Placeholders/DateTime/Time.php +39 -0
  180. src/classes/Placeholders/Defaults.php +82 -0
  181. src/classes/Placeholders/Resolver.php +154 -0
  182. src/classes/Placeholders/User/UserDisplayName.php +42 -0
  183. src/classes/Placeholders/User/UserEmail.php +42 -0
  184. src/classes/Placeholders/User/UserFirstName.php +42 -0
  185. src/classes/Placeholders/User/UserID.php +42 -0
  186. src/classes/Placeholders/User/UserLastName.php +42 -0
  187. src/classes/Placeholders/User/UserLogin.php +42 -0
  188. src/classes/Placeholders/User/UserNicename.php +42 -0
  189. src/classes/Placeholders/User/UserRole.php +51 -0
  190. src/classes/Placeholders/User/UserUrl.php +42 -0
  191. src/classes/Settings/Field.php +241 -0
  192. src/classes/Settings/Fields/Checkbox.php +47 -0
  193. src/classes/Settings/Fields/Dropdown.php +65 -0
  194. src/classes/Settings/Fields/Number.php +70 -0
  195. src/classes/Settings/Fields/SwitchField.php +28 -0
  196. src/classes/Settings/Fields/Text.php +35 -0
  197. src/classes/Settings/Section.php +170 -0
  198. src/classes/Settings/Settings.php +245 -0
  199. src/classes/Traits/Hookable.php +114 -0
  200. src/classes/Watermark/Ajax.php +281 -0
  201. src/classes/Watermark/Handler.php +522 -0
  202. src/classes/Watermark/Hooks.php +188 -0
  203. src/classes/Watermark/PostType.php +515 -0
  204. src/classes/Watermark/Preview.php +91 -0
  205. src/classes/Watermark/Watermark.php +261 -0
  206. src/inc/freemius.php +30 -0
  207. src/inc/functions.php +35 -0
  208. src/inc/hooks.php +89 -0
  209. src/views/dashboard/pages/permissions.php +52 -0
  210. src/views/dashboard/pages/settings.php +21 -0
  211. src/views/dashboard/pages/tools.php +51 -0
  212. src/views/dashboard/pages/watermarks.php +39 -0
  213. src/views/dashboard/settings/field-one-column.php +17 -0
  214. src/views/dashboard/settings/field-two-column.php +20 -0
  215. src/views/dashboard/settings/fields/switch.php +17 -0
  216. src/views/dashboard/settings/section.php +32 -0
  217. src/views/dashboard/wrap.php +27 -0
  218. src/views/edit-screen/attachment-id-field.php +10 -0
  219. src/views/edit-screen/metaboxes/attachment/used-as-watermark.php +16 -0
  220. src/views/edit-screen/metaboxes/attachment/watermarks.php +52 -0
  221. src/views/edit-screen/metaboxes/watermark/alignment.php +80 -0
  222. src/views/edit-screen/metaboxes/watermark/applying-rules.php +90 -0
  223. src/views/edit-screen/metaboxes/watermark/placeholders.php +29 -0
  224. src/views/edit-screen/metaboxes/watermark/preview-popup.php +27 -0
  225. src/views/edit-screen/metaboxes/watermark/preview.php +19 -0
  226. src/views/edit-screen/metaboxes/watermark/scaling.php +46 -0
  227. src/views/edit-screen/metaboxes/watermark/submitdiv.php +27 -0
  228. src/views/edit-screen/metaboxes/watermark/text-options.php +62 -0
  229. src/views/edit-screen/metaboxes/watermark/watermark-content.php +51 -0
  230. src/views/edit-screen/watermark-type-selector.php +36 -0
  231. src/views/notices/auto-watermark-warning.php +23 -0
  232. src/views/notices/success.php +11 -0
  233. src/views/notices/untrash-error.php +11 -0
  234. src/views/notices/watermarks-number-exceeded-error.php +11 -0
  235. src/views/upload/switch.php +15 -0
  236. vendor/autoload.php +7 -0
  237. vendor/composer/ClassLoader.php +445 -0
  238. vendor/composer/LICENSE +21 -0
  239. vendor/composer/autoload_classmap.php +10 -0
  240. vendor/composer/autoload_namespaces.php +10 -0
  241. vendor/composer/autoload_psr4.php +11 -0
  242. vendor/composer/autoload_real.php +52 -0
  243. vendor/composer/autoload_static.php +55 -0
  244. vendor/composer/installed.json +141 -0
  245. vendor/composer/installers/LICENSE +19 -0
  246. vendor/composer/installers/phpunit.xml.dist +25 -0
  247. vendor/composer/installers/src/Composer/Installers/AglInstaller.php +21 -0
  248. vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php +11 -0
  249. vendor/composer/installers/src/Composer/Installers/BaseInstaller.php +130 -0
  250. vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php +21 -0
  251. vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php +11 -0
  252. vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php +21 -0
  253. vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php +12 -0
  254. vendor/composer/installers/src/Composer/Installers/FuelInstaller.php +10 -0
  255. vendor/composer/installers/src/Composer/Installers/Installer.php +128 -0
  256. vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php +15 -0
  257. vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php +9 -0
  258. vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php +9 -0
  259. vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php +10 -0
  260. vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php +9 -0
  261. vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php +11 -0
  262. vendor/composer/installers/src/Composer/Installers/MakoInstaller.php +9 -0
  263. vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php +21 -0
  264. vendor/composer/installers/src/Composer/Installers/OxidInstaller.php +9 -0
  265. vendor/composer/installers/src/Composer/Installers/PPIInstaller.php +9 -0
  266. vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php +11 -0
  267. vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php +36 -0
  268. vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php +26 -0
  269. vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php +14 -0
  270. vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php +33 -0
  271. vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php +11 -0
  272. vendor/composer/installers/src/Composer/Installers/ZendInstaller.php +10 -0
  273. vendor/composer/installers/src/bootstrap.php +13 -0
  274. vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php +61 -0
  275. vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php +309 -0
  276. vendor/composer/installers/tests/Composer/Installers/Test/TestCase.php +64 -0
  277. vendor/composer/installers/tests/bootstrap.php +4 -0
  278. vendor/underdev/requirements/languages/underdev-requirements-de_DE.mo +0 -0
  279. vendor/underdev/requirements/languages/underdev-requirements-de_DE.po +83 -0
  280. vendor/underdev/requirements/languages/underdev-requirements-es_ES.mo +0 -0
  281. vendor/underdev/requirements/languages/underdev-requirements-es_ES.po +72 -0
  282. vendor/underdev/requirements/languages/underdev-requirements-fr_FR.mo +0 -0
  283. vendor/underdev/requirements/languages/underdev-requirements-fr_FR.po +74 -0
  284. vendor/underdev/requirements/languages/underdev-requirements-it_IT.mo +0 -0
  285. vendor/underdev/requirements/languages/underdev-requirements-it_IT.po +66 -0
  286. vendor/underdev/requirements/languages/underdev-requirements-pt_PT.mo +0 -0
  287. vendor/underdev/requirements/languages/underdev-requirements-pt_PT.po +73 -0
  288. vendor/underdev/requirements/languages/underdev-requirements-ru_RU.mo +0 -0
  289. vendor/underdev/requirements/languages/underdev-requirements-ru_RU.po +79 -0
  290. vendor/underdev/requirements/languages/underdev-requirements.pot +56 -0
  291. vendor/underdev/requirements/underDEV_Requirements.php +310 -0
  292. vendor/underdev/singleton/src/Singleton.php +32 -0
  293. views/about.php +0 -17
  294. views/donation.php +0 -10
  295. views/easy-watermark-page.php +0 -72
  296. views/help_tab_placeholders_author.php +0 -8
  297. views/help_tab_placeholders_general.php +0 -9
  298. views/help_tab_placeholders_image.php +0 -6
  299. views/help_tab_placeholders_user.php +0 -8
  300. views/placeholders.php +0 -23
  301. views/settings-form-general.php +0 -90
  302. views/settings-form-image.php +0 -59
  303. views/settings-form-text.php +0 -110
  304. views/settings-page.php +0 -32
  305. views/settings-sidebar.php +0 -6
  306. views/tools/restore_all.php +0 -27
  307. views/tools/watermark_all.php +0 -27
{fonts → assets/dist/fonts}/Arial.ttf RENAMED
File without changes
{fonts → assets/dist/fonts}/Arial_Black.ttf RENAMED
File without changes
{fonts → assets/dist/fonts}/Comic_Sans_MS.ttf RENAMED
File without changes
{fonts → assets/dist/fonts}/Courier_New.ttf RENAMED
File without changes
{fonts → assets/dist/fonts}/Georgia.ttf RENAMED
File without changes
{fonts → assets/dist/fonts}/Impact.ttf RENAMED
File without changes
{fonts → assets/dist/fonts}/Tahoma.ttf RENAMED
File without changes
{fonts → assets/dist/fonts}/Times_New_Roman.ttf RENAMED
File without changes
{fonts → assets/dist/fonts}/Trebuchet_MS.ttf RENAMED
File without changes
{fonts → assets/dist/fonts}/Verdana.ttf RENAMED
File without changes
{images → assets/dist/images}/alignment-background.jpg RENAMED
File without changes
assets/dist/scripts/attachment-edit.js ADDED
@@ -0,0 +1 @@
1
+ !function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="../",n(n.s=21)}({0:function(t,e){t.exports=jQuery},1:function(t,e,n){"use strict";n.d(e,"a",(function(){return s})),n.d(e,"b",(function(){return a})),n.d(e,"c",(function(){return o})),n.d(e,"d",(function(){return c}));var r=n(0),i=n.n(r);function s(t,e="info"){const n=i()(document.createElement("div")),r=i()(document.createElement("p")),s=i()(document.createElement("button"));n.addClass("notice notice-"+e+" is-dismissible").hide(),s.addClass("notice-dismiss"),r.html(t),n.append(r).append(s),s.on("click",t=>{t.preventDefault(),n.fadeOut(200,()=>{n.remove()})}),i()("hr.wp-header-end").after(n),n.fadeIn(200)}function a(t,e=!1,n=!0){let r=t.length;for(const i of t.clone().models)(!c(i)||i.get("usedAsWatermark")||!0===e&&!i.get("hasBackup"))&&(!0===n&&t.remove(i),r--);return r}function o(t,e){const n=t.indexOf("?");return-1!==n&&(t=t.substr(0,n)),t+="?v="+e}function c(t){return"object"==typeof t&&t.get&&(t=t.get("mime")),Object.keys(ew.mime).includes(t)}},21:function(t,e,n){"use strict";n.r(e);n(28);var r=n(0),i=n.n(r),s=n(1);new class{constructor(){this.handleClick=this.handleClick.bind(this),this.metabox=i()("#watermarks"),this.metaboxContent=this.metabox.find(".watermarks-metabox"),this.errorMessage=this.metabox.find(".error-message"),this.spinners=this.metabox.find(".spinner"),this.buttons=this.metabox.find("button"),this.form=i()("form#post"),this.postID=this.form.find("#post_ID").val(),this.headerEnd=i()("hr.wp-header-end"),this.image=i()(".wp_attachment_image img.thumbnail"),this.metabox.on("click","button",this.handleClick)}handleClick(t){t.preventDefault();const e=i()(t.target),n=e.data("action");this.buttons.prop("disabled",!0),e.next(".spinner").css("visibility","visible"),this.errorMessage.hide();const r={action:"easy-watermark/"+n,nonce:e.data("nonce"),attachment_id:this.postID};"apply_single"===n&&(r.watermark=e.data("watermark")),i.a.ajax(ajaxurl,{data:r}).done(t=>{if(!0===t.success){if(this.metaboxContent.replaceWith(t.data.metaboxContent),this.metaboxContent=this.metabox.find(".watermarks-metabox"),this.errorMessage=this.metabox.find(".error-message"),this.spinners=this.metabox.find(".spinner"),this.buttons=this.metabox.find("button"),t.data.attachmentVersion){const e=Object(s.c)(this.image.attr("src"),t.data.attachmentVersion);this.image.attr("src",e),"string"==typeof t.data.message&&Object(s.a)(t.data.message,"success")}}else{const e="string"==typeof t.data.message?t.data.message:ew.genericErrorMessage;Object(s.a)(e,"error")}}).fail(()=>{Object(s.a)(ew.genericErrorMessage,"error")}).complete(()=>{this.spinners.css("visibility","hidden"),this.buttons.prop("disabled",!1)})}}},28:function(t,e){}});
assets/dist/scripts/dashboard.js ADDED
@@ -0,0 +1,3 @@
1
+ !function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="../",n(n.s=20)}([function(t,e){t.exports=jQuery},function(t,e,n){"use strict";n.d(e,"a",(function(){return s})),n.d(e,"b",(function(){return r})),n.d(e,"c",(function(){return a})),n.d(e,"d",(function(){return l}));var o=n(0),i=n.n(o);function s(t,e="info"){const n=i()(document.createElement("div")),o=i()(document.createElement("p")),s=i()(document.createElement("button"));n.addClass("notice notice-"+e+" is-dismissible").hide(),s.addClass("notice-dismiss"),o.html(t),n.append(o).append(s),s.on("click",t=>{t.preventDefault(),n.fadeOut(200,()=>{n.remove()})}),i()("hr.wp-header-end").after(n),n.fadeIn(200)}function r(t,e=!1,n=!0){let o=t.length;for(const i of t.clone().models)(!l(i)||i.get("usedAsWatermark")||!0===e&&!i.get("hasBackup"))&&(!0===n&&t.remove(i),o--);return o}function a(t,e){const n=t.indexOf("?");return-1!==n&&(t=t.substr(0,n)),t+="?v="+e}function l(t){return"object"==typeof t&&t.get&&(t=t.get("mime")),Object.keys(ew.mime).includes(t)}},function(t,e){t.exports=Backbone},function(t,e,n){var o=n(5);o.registerPlugin(n(9)),t.exports=o},,function(t,e,n){n(6),n(7).polyfill();var o=n(8),i=function(t){if(void 0!==t){var e=document.createElement("div");return e.appendChild(document.createTextNode(t)),e.innerHTML}return""},s=function(t,e){if("string"==typeof e&&0!==e.length)for(var n=e.split(" "),o=0;o<n.length;o++){var i=n[o];i.length&&t.classList.add(i)}},r=function(){var t=document.createElement("div"),e={animation:"animationend",WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",OAnimation:"oanimationend",msAnimation:"MSAnimationEnd"};for(var n in e)if(void 0!==t.style[n])return e[n];return!1}(),a="vex",l="vex-content",c="vex-overlay",u="vex-close",d="vex-closing",f="vex-open",p={},h=1,m=!1,b={open:function(t){var e=function(t){console.warn('The "'+t+'" property is deprecated in vex 3. Use CSS classes and the appropriate "ClassName" options, instead.'),console.warn("See http://github.hubspot.com/vex/api/advanced/#options")};t.css&&e("css"),t.overlayCSS&&e("overlayCSS"),t.contentCSS&&e("contentCSS"),t.closeCSS&&e("closeCSS");var n={};n.id=h++,p[n.id]=n,n.isOpen=!0,n.close=function(){if(!this.isOpen)return!0;var t=this.options;if(m&&!t.escapeButtonCloses)return!1;if(!1===function(){return!t.beforeClose||t.beforeClose.call(this)}.bind(this)())return!1;this.isOpen=!1;var e=window.getComputedStyle(this.contentEl);function n(t){return"none"!==e.getPropertyValue(t+"animation-name")&&"0s"!==e.getPropertyValue(t+"animation-duration")}var o=n("")||n("-webkit-")||n("-moz-")||n("-o-"),i=function e(){this.rootEl.parentNode&&(this.rootEl.removeEventListener(r,e),this.overlayEl.removeEventListener(r,e),delete p[this.id],this.rootEl.parentNode.removeChild(this.rootEl),this.bodyEl.removeChild(this.overlayEl),t.afterClose&&t.afterClose.call(this),0===Object.keys(p).length&&document.body.classList.remove(f))}.bind(this);return r&&o?(this.rootEl.addEventListener(r,i),this.overlayEl.addEventListener(r,i),this.rootEl.classList.add(d),this.overlayEl.classList.add(d)):i(),!0},"string"==typeof t&&(t={content:t}),t.unsafeContent&&!t.content?t.content=t.unsafeContent:t.content&&(t.content=i(t.content));var g=n.options=Object.assign({},b.defaultOptions,t),v=n.bodyEl=document.getElementsByTagName("body")[0],y=n.rootEl=document.createElement("div");y.classList.add(a),s(y,g.className);var w=n.overlayEl=document.createElement("div");w.classList.add(c),s(w,g.overlayClassName),g.overlayClosesOnClick&&y.addEventListener("click",(function(t){t.target===y&&n.close()})),v.appendChild(w);var x=n.contentEl=document.createElement("div");if(x.classList.add(l),s(x,g.contentClassName),x.appendChild(g.content instanceof window.Node?g.content:o(g.content)),y.appendChild(x),g.showCloseButton){var k=n.closeEl=document.createElement("div");k.classList.add(u),s(k,g.closeClassName),k.addEventListener("click",n.close.bind(n)),x.appendChild(k)}return document.querySelector(g.appendLocation).appendChild(y),g.afterOpen&&g.afterOpen.call(n),document.body.classList.add(f),n},close:function(t){var e;if(t.id)e=t.id;else{if("string"!=typeof t)throw new TypeError("close requires a vex object or id string");e=t}return!!p[e]&&p[e].close()},closeTop:function(){var t=Object.keys(p);return!!t.length&&p[t[t.length-1]].close()},closeAll:function(){for(var t in p)this.close(t);return!0},getAll:function(){return p},getById:function(t){return p[t]}};window.addEventListener("keyup",(function(t){27===t.keyCode&&(m=!0,b.closeTop(),m=!1)})),window.addEventListener("popstate",(function(){b.defaultOptions.closeAllOnPopState&&b.closeAll()})),b.defaultOptions={content:"",showCloseButton:!0,escapeButtonCloses:!0,overlayClosesOnClick:!0,appendLocation:"body",className:"",overlayClassName:"",contentClassName:"",closeClassName:"",closeAllOnPopState:!0},Object.defineProperty(b,"_escapeHtml",{configurable:!1,enumerable:!1,writable:!1,value:i}),b.registerPlugin=function(t,e){var n=t(b),o=e||n.name;if(b[o])throw new Error("Plugin "+e+" is already registered.");b[o]=n},t.exports=b},function(t,e){
2
+ /*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js */
3
+ "document"in window.self&&("classList"in document.createElement("_")&&(!document.createElementNS||"classList"in document.createElementNS("http://www.w3.org/2000/svg","g"))||function(t){"use strict";if("Element"in t){var e=t.Element.prototype,n=Object,o=String.prototype.trim||function(){return this.replace(/^\s+|\s+#x2F;g,"")},i=Array.prototype.indexOf||function(t){for(var e=0,n=this.length;e<n;e++)if(e in this&&this[e]===t)return e;return-1},s=function(t,e){this.name=t,this.code=DOMException[t],this.message=e},r=function(t,e){if(""===e)throw new s("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(e))throw new s("INVALID_CHARACTER_ERR","String contains an invalid character");return i.call(t,e)},a=function(t){for(var e=o.call(t.getAttribute("class")||""),n=e?e.split(/\s+/):[],i=0,s=n.length;i<s;i++)this.push(n[i]);this._updateClassName=function(){t.setAttribute("class",this.toString())}},l=a.prototype=[],c=function(){return new a(this)};if(s.prototype=Error.prototype,l.item=function(t){return this[t]||null},l.contains=function(t){return-1!==r(this,t+="")},l.add=function(){var t,e=arguments,n=0,o=e.length,i=!1;do{t=e[n]+"",-1===r(this,t)&&(this.push(t),i=!0)}while(++n<o);i&&this._updateClassName()},l.remove=function(){var t,e,n=arguments,o=0,i=n.length,s=!1;do{for(t=n[o]+"",e=r(this,t);-1!==e;)this.splice(e,1),s=!0,e=r(this,t)}while(++o<i);s&&this._updateClassName()},l.toggle=function(t,e){t+="";var n=this.contains(t),o=n?!0!==e&&"remove":!1!==e&&"add";return o&&this[o](t),!0===e||!1===e?e:!n},l.toString=function(){return this.join(" ")},n.defineProperty){var u={get:c,enumerable:!0,configurable:!0};try{n.defineProperty(e,"classList",u)}catch(t){void 0!==t.number&&-2146823252!==t.number||(u.enumerable=!1,n.defineProperty(e,"classList",u))}}else n.prototype.__defineGetter__&&e.__defineGetter__("classList",c)}}(window.self),function(){"use strict";var t=document.createElement("_");if(t.classList.add("c1","c2"),!t.classList.contains("c2")){var e=function(t){var e=DOMTokenList.prototype[t];DOMTokenList.prototype[t]=function(t){var n,o=arguments.length;for(n=0;n<o;n++)t=arguments[n],e.call(this,t)}};e("add"),e("remove")}if(t.classList.toggle("c3",!1),t.classList.contains("c3")){var n=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(t,e){return 1 in arguments&&!this.contains(t)==!e?e:n.call(this,t)}}t=null}())},function(t,e,n){"use strict";function o(t,e){if(null==t)throw new TypeError("Cannot convert first argument to object");for(var n=Object(t),o=1;o<arguments.length;o++){var i=arguments[o];if(null!=i)for(var s=Object.keys(Object(i)),r=0,a=s.length;r<a;r++){var l=s[r],c=Object.getOwnPropertyDescriptor(i,l);void 0!==c&&c.enumerable&&(n[l]=i[l])}}return n}t.exports={assign:o,polyfill:function(){Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:o})}}},function(t,e){t.exports=function(t,e){if("string"!=typeof t)throw new TypeError("String expected");e||(e=document);var n=/<([\w:]+)/.exec(t);if(!n)return e.createTextNode(t);t=t.replace(/^\s+|\s+#x2F;g,"");var o=n[1];if("body"==o){return(s=e.createElement("html")).innerHTML=t,s.removeChild(s.lastChild)}var s,r=i[o]||i._default,a=r[0],l=r[1],c=r[2];(s=e.createElement("div")).innerHTML=l+t+c;for(;a--;)s=s.lastChild;if(s.firstChild==s.lastChild)return s.removeChild(s.firstChild);var u=e.createDocumentFragment();for(;s.firstChild;)u.appendChild(s.removeChild(s.firstChild));return u};var n,o=!1;"undefined"!=typeof document&&((n=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',o=!n.getElementsByTagName("link").length,n=void 0);var i={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:o?[1,"X<div>","</div>"]:[0,"",""]};i.td=i.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],i.option=i.optgroup=[1,'<select multiple="multiple">',"</select>"],i.thead=i.tbody=i.colgroup=i.caption=i.tfoot=[1,"<table>","</table>"],i.polyline=i.ellipse=i.polygon=i.circle=i.text=i.line=i.path=i.rect=i.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"]},function(t,e,n){var o;t.exports=function t(e,n,i){function s(a,l){if(!n[a]){if(!e[a]){if(!l&&"function"==typeof o&&o)return o(a,!0);if(r)return r(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[a]={exports:{}};e[a][0].call(u.exports,(function(t){var n=e[a][1][t];return s(n||t)}),u,u.exports,t,e,n,i)}return n[a].exports}for(var r="function"==typeof o&&o,a=0;a<i.length;a++)s(i[a]);return s}({1:[function(t,e,n){"use strict";e.exports=function t(e){if(!e||"object"!=typeof e)return e;if("[object Date]"==Object.prototype.toString.call(e))return new Date(e.getTime());if(Array.isArray(e))return e.map(t);var n={};return Object.keys(e).forEach((function(o){n[o]=t(e[o])})),n}},{}],2:[function(t,e,n){e.exports=function(t,e){if("string"!=typeof t)throw new TypeError("String expected");e||(e=document);var n=/<([\w:]+)/.exec(t);if(!n)return e.createTextNode(t);t=t.replace(/^\s+|\s+#x2F;g,"");var o=n[1];if("body"==o)return(i=e.createElement("html")).innerHTML=t,i.removeChild(i.lastChild);var i,r=s[o]||s._default,a=r[0],l=r[1],c=r[2];for((i=e.createElement("div")).innerHTML=l+t+c;a--;)i=i.lastChild;if(i.firstChild==i.lastChild)return i.removeChild(i.firstChild);for(var u=e.createDocumentFragment();i.firstChild;)u.appendChild(i.removeChild(i.firstChild));return u};var o,i=!1;"undefined"!=typeof document&&((o=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',i=!o.getElementsByTagName("link").length,o=void 0);var s={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:i?[1,"X<div>","</div>"]:[0,"",""]};s.td=s.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],s.option=s.optgroup=[1,'<select multiple="multiple">',"</select>"],s.thead=s.tbody=s.colgroup=s.caption=s.tfoot=[1,"<table>","</table>"],s.polyline=s.ellipse=s.polygon=s.circle=s.text=s.line=s.path=s.rect=s.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"]},{}],3:[function(t,e,n){var o=/^(?:submit|button|image|reset|file)#x2F;i,i=/^(?:input|select|textarea|keygen)/i,s=/(\[[^\[\]]*\])/g;function r(t,e,n){if(e.match(s))!function t(e,n,o){if(0===n.length)return e=o;var i=n.shift(),s=i.match(/^\[(.+?)\]#x2F;);if("[]"===i)return e=e||[],Array.isArray(e)?e.push(t(null,n,o)):(e._values=e._values||[],e._values.push(t(null,n,o))),e;if(s){var r=s[1],a=+r;isNaN(a)?(e=e||{})[r]=t(e[r],n,o):(e=e||[])[a]=t(e[a],n,o)}else e[i]=t(e[i],n,o);return e}(t,function(t){var e=[],n=new RegExp(s),o=/^([^\[\]]*)/.exec(t);for(o[1]&&e.push(o[1]);null!==(o=n.exec(t));)e.push(o[1]);return e}(e),n);else{var o=t[e];o?(Array.isArray(o)||(t[e]=[o]),t[e].push(n)):t[e]=n}return t}function a(t,e,n){return n=n.replace(/(\r)?\n/g,"\r\n"),n=(n=encodeURIComponent(n)).replace(/%20/g,"+"),t+(t?"&":"")+encodeURIComponent(e)+"="+n}e.exports=function(t,e){"object"!=typeof e?e={hash:!!e}:void 0===e.hash&&(e.hash=!0);for(var n=e.hash?{}:"",s=e.serializer||(e.hash?r:a),l=t&&t.elements?t.elements:[],c=Object.create(null),u=0;u<l.length;++u){var d=l[u];if((e.disabled||!d.disabled)&&d.name&&i.test(d.nodeName)&&!o.test(d.type)){var f=d.name,p=d.value;if("checkbox"!==d.type&&"radio"!==d.type||d.checked||(p=void 0),e.empty){if("checkbox"!==d.type||d.checked||(p=""),"radio"===d.type&&(c[d.name]||d.checked?d.checked&&(c[d.name]=!0):c[d.name]=!1),!p&&"radio"==d.type)continue}else if(!p)continue;if("select-multiple"!==d.type)n=s(n,f,p);else{p=[];for(var h=d.options,m=!1,b=0;b<h.length;++b){var g=h[b],v=e.empty&&!g.value,y=g.value||v;g.selected&&y&&(m=!0,n=e.hash&&"[]"!==f.slice(f.length-2)?s(n,f+"[]",g.value):s(n,f,g.value))}!m&&e.empty&&(n=s(n,f,""))}}}if(e.empty)for(var f in c)c[f]||(n=s(n,f,""));return n}},{}],4:[function(t,e,n){var o=t("domify"),i=t("form-serialize"),s=t("deep-clone-simple"),r=function(t){var e=document.createElement("div");e.classList.add("vex-dialog-buttons");for(var n=0;n<t.length;n++){var o=t[n],i=document.createElement("button");i.type=o.type,i.textContent=o.text,i.className=o.className,i.classList.add("vex-dialog-button"),0===n?i.classList.add("vex-first"):n===t.length-1&&i.classList.add("vex-last"),function(t){i.addEventListener("click",function(e){t.click&&t.click.call(this,e)}.bind(this))}.bind(this)(o),e.appendChild(i)}return e};e.exports=function(t){var e={name:"dialog",open:function(e){var n=Object.assign({},s(this.defaultOptions),e);n.unsafeMessage&&!n.message?n.message=n.unsafeMessage:n.message&&(n.message=t._escapeHtml(n.message));var i=n.unsafeContent=function(t){var e=document.createElement("form");e.classList.add("vex-dialog-form");var n=document.createElement("div");n.classList.add("vex-dialog-message"),n.appendChild(t.message instanceof window.Node?t.message:o(t.message));var i=document.createElement("div");return i.classList.add("vex-dialog-input"),i.appendChild(t.input instanceof window.Node?t.input:o(t.input)),e.appendChild(n),e.appendChild(i),e}(n),a=t.open(n);""!==n.yesText&&(n.buttons[0].text=n.yesText),""!==n.noText&&(n.buttons[1].text=n.noText);var l=n.beforeClose&&n.beforeClose.bind(a);if(a.options.beforeClose=function(){var t=!l||l();return t&&n.callback(this.value||!1),t}.bind(a),i.appendChild(r.call(a,n.buttons)),a.form=i,i.addEventListener("submit",n.onSubmit.bind(a)),n.focusFirstInput){var c=a.contentEl.querySelector("button, input, select, textarea");c&&c.focus()}return a},alert:function(t){return"string"==typeof t&&(t={message:t}),t=Object.assign({},s(this.defaultOptions),s(this.defaultAlertOptions),t),this.open(t)},confirm:function(t){if("object"!=typeof t||"function"!=typeof t.callback)throw new Error("dialog.confirm(options) requires options.callback.");return t=Object.assign({},s(this.defaultOptions),s(this.defaultConfirmOptions),t),this.open(t)},prompt:function(e){if("object"!=typeof e||"function"!=typeof e.callback)throw new Error("dialog.prompt(options) requires options.callback.");var n=Object.assign({},s(this.defaultOptions),s(this.defaultPromptOptions)),o={unsafeMessage:'<label for="vex">'+t._escapeHtml(e.label||n.label)+"</label>",input:'<input name="vex" type="text" class="vex-dialog-prompt-input" placeholder="'+t._escapeHtml(e.placeholder||n.placeholder)+'" value="'+t._escapeHtml(e.value||n.value)+'" />'},i=(e=Object.assign(n,o,e)).callback;return e.callback=function(t){if("object"==typeof t){var e=Object.keys(t);t=e.length?t[e[0]]:""}i(t)},this.open(e)},buttons:{YES:{text:"OK",type:"submit",className:"vex-dialog-button-primary",click:function(){this.value=!0}},NO:{text:"Cancel",type:"button",className:"vex-dialog-button-secondary",click:function(){this.value=!1,this.close()}}}};return e.defaultOptions={callback:function(){},afterOpen:function(){},message:"",input:"",yesText:"",noText:"",buttons:[e.buttons.YES,e.buttons.NO],showCloseButton:!1,onSubmit:function(t){return t.preventDefault(),this.options.input&&(this.value=i(this.form,{hash:!0})),this.close()},focusFirstInput:!0},e.defaultAlertOptions={buttons:[e.buttons.YES]},e.defaultPromptOptions={label:"Prompt:",placeholder:"",value:""},e.defaultConfirmOptions={},e}},{"deep-clone-simple":1,domify:2,"form-serialize":3}]},{},[4])(4)},function(t,e,n){var o=n(11);"string"==typeof o&&(o=[[t.i,o,""]]);var i={hmr:!0,transform:void 0,insertInto:void 0};n(13)(o,i);o.locals&&(t.exports=o.locals)},function(t,e,n){(t.exports=n(12)(!1)).push([t.i,'@-webkit-keyframes vex-fadein {\n 0% {\n opacity: 0; }\n 100% {\n opacity: 1; } }\n\n@keyframes vex-fadein {\n 0% {\n opacity: 0; }\n 100% {\n opacity: 1; } }\n\n@-webkit-keyframes vex-fadeout {\n 0% {\n opacity: 1; }\n 100% {\n opacity: 0; } }\n\n@keyframes vex-fadeout {\n 0% {\n opacity: 1; }\n 100% {\n opacity: 0; } }\n\n@-webkit-keyframes vex-rotation {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg); }\n 100% {\n -webkit-transform: rotate(359deg);\n transform: rotate(359deg); } }\n\n@keyframes vex-rotation {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg); }\n 100% {\n -webkit-transform: rotate(359deg);\n transform: rotate(359deg); } }\n\n.vex, .vex *, .vex *:before, .vex *:after {\n -moz-box-sizing: border-box;\n box-sizing: border-box; }\n\n.vex {\n position: fixed;\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n z-index: 1111;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0; }\n\n.vex-scrollbar-measure {\n position: absolute;\n top: -9999px;\n width: 50px;\n height: 50px;\n overflow: scroll; }\n\n.vex-overlay {\n -webkit-animation: vex-fadein .5s;\n animation: vex-fadein .5s;\n position: fixed;\n z-index: 1111;\n background: rgba(0, 0, 0, 0.4);\n top: 0;\n right: 0;\n bottom: 0;\n left: 0; }\n\n.vex-overlay.vex-closing {\n -webkit-animation: vex-fadeout .5s forwards;\n animation: vex-fadeout .5s forwards; }\n\n.vex-content {\n -webkit-animation: vex-fadein .5s;\n animation: vex-fadein .5s;\n background: #fff; }\n\n.vex.vex-closing .vex-content {\n -webkit-animation: vex-fadeout .5s forwards;\n animation: vex-fadeout .5s forwards; }\n\n.vex-close:before {\n font-family: Arial, sans-serif;\n content: "\\D7"; }\n\n.vex-dialog-form {\n margin: 0; }\n\n.vex-dialog-button {\n text-rendering: optimizeLegibility;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n cursor: pointer;\n -webkit-tap-highlight-color: transparent; }\n\n.vex-loading-spinner {\n -webkit-animation: vex-rotation .7s linear infinite;\n animation: vex-rotation .7s linear infinite;\n box-shadow: 0 0 1em rgba(0, 0, 0, 0.1);\n position: fixed;\n z-index: 1112;\n margin: auto;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n height: 2em;\n width: 2em;\n background: #fff; }\n\nbody.vex-open {\n overflow: hidden; }\n',""])},function(t,e){t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n=function(t,e){var n=t[1]||"",o=t[3];if(!o)return n;if(e&&"function"==typeof btoa){var i=(r=o,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */"),s=o.sources.map((function(t){return"/*# sourceURL="+o.sourceRoot+t+" */"}));return[n].concat(s).concat([i]).join("\n")}var r;return[n].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+n+"}":n})).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var o={},i=0;i<this.length;i++){var s=this[i][0];"number"==typeof s&&(o[s]=!0)}for(i=0;i<t.length;i++){var r=t[i];"number"==typeof r[0]&&o[r[0]]||(n&&!r[2]?r[2]=n:n&&(r[2]="("+r[2]+") and ("+n+")"),e.push(r))}},e}},function(t,e,n){var o,i,s={},r=(o=function(){return window&&document&&document.all&&!window.atob},function(){return void 0===i&&(i=o.apply(this,arguments)),i}),a=function(t,e){return e?e.querySelector(t):document.querySelector(t)},l=function(t){var e={};return function(t,n){if("function"==typeof t)return t();if(void 0===e[t]){var o=a.call(this,t,n);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(t){o=null}e[t]=o}return e[t]}}(),c=null,u=0,d=[],f=n(14);function p(t,e){for(var n=0;n<t.length;n++){var o=t[n],i=s[o.id];if(i){i.refs++;for(var r=0;r<i.parts.length;r++)i.parts[r](o.parts[r]);for(;r<o.parts.length;r++)i.parts.push(y(o.parts[r],e))}else{var a=[];for(r=0;r<o.parts.length;r++)a.push(y(o.parts[r],e));s[o.id]={id:o.id,refs:1,parts:a}}}}function h(t,e){for(var n=[],o={},i=0;i<t.length;i++){var s=t[i],r=e.base?s[0]+e.base:s[0],a={css:s[1],media:s[2],sourceMap:s[3]};o[r]?o[r].parts.push(a):n.push(o[r]={id:r,parts:[a]})}return n}function m(t,e){var n=l(t.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var o=d[d.length-1];if("top"===t.insertAt)o?o.nextSibling?n.insertBefore(e,o.nextSibling):n.appendChild(e):n.insertBefore(e,n.firstChild),d.push(e);else if("bottom"===t.insertAt)n.appendChild(e);else{if("object"!=typeof t.insertAt||!t.insertAt.before)throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");var i=l(t.insertAt.before,n);n.insertBefore(e,i)}}function b(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t);var e=d.indexOf(t);e>=0&&d.splice(e,1)}function g(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var o=function(){0;return n.nc}();o&&(t.attrs.nonce=o)}return v(e,t.attrs),m(t,e),e}function v(t,e){Object.keys(e).forEach((function(n){t.setAttribute(n,e[n])}))}function y(t,e){var n,o,i,s;if(e.transform&&t.css){if(!(s="function"==typeof e.transform?e.transform(t.css):e.transform.default(t.css)))return function(){};t.css=s}if(e.singleton){var r=u++;n=c||(c=g(e)),o=k.bind(null,n,r,!1),i=k.bind(null,n,r,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",v(e,t.attrs),m(t,e),e}(e),o=E.bind(null,n,e),i=function(){b(n),n.href&&URL.revokeObjectURL(n.href)}):(n=g(e),o=C.bind(null,n),i=function(){b(n)});return o(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;o(t=e)}else i()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=r()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var n=h(t,e);return p(n,e),function(t){for(var o=[],i=0;i<n.length;i++){var r=n[i];(a=s[r.id]).refs--,o.push(a)}t&&p(h(t,e),e);for(i=0;i<o.length;i++){var a;if(0===(a=o[i]).refs){for(var l=0;l<a.parts.length;l++)a.parts[l]();delete s[a.id]}}}};var w,x=(w=[],function(t,e){return w[t]=e,w.filter(Boolean).join("\n")});function k(t,e,n,o){var i=n?"":o.css;if(t.styleSheet)t.styleSheet.cssText=x(e,i);else{var s=document.createTextNode(i),r=t.childNodes;r[e]&&t.removeChild(r[e]),r.length?t.insertBefore(s,r[e]):t.appendChild(s)}}function C(t,e){var n=e.css,o=e.media;if(o&&t.setAttribute("media",o),t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}function E(t,e,n){var o=n.css,i=n.sourceMap,s=void 0===e.convertToAbsoluteUrls&&i;(e.convertToAbsoluteUrls||s)&&(o=f(o)),i&&(o+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */");var r=new Blob([o],{type:"text/css"}),a=t.href;t.href=URL.createObjectURL(r),a&&URL.revokeObjectURL(a)}},function(t,e){t.exports=function(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var n=e.protocol+"//"+e.host,o=n+e.pathname.replace(/\/[^\/]*#x2F;,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(t,e){var i,s=e.trim().replace(/^"(.*)"#x2F;,(function(t,e){return e})).replace(/^'(.*)'#x2F;,(function(t,e){return e}));return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(s)?t:(i=0===s.indexOf("//")?s:0===s.indexOf("/")?n+s:o+s.replace(/^\.\//,""),"url("+JSON.stringify(i)+")")}))}},,,,,,function(t,e,n){"use strict";n.r(e);var o=n(0),i=n.n(o),s=n(3),r=n.n(s);n(10),n(22);r.a.defaultOptions.className="vex-theme-ew",r.a.defaultOptions.contentClassName="postbox",r.a.dialog.buttons.YES={...r.a.dialog.buttons.YES,className:"button-primary",text:ew.i18n.yes},r.a.dialog.buttons.OK={...r.a.dialog.buttons.YES,className:"button-primary",text:ew.i18n.ok},r.a.dialog.buttons.NO={...r.a.dialog.buttons.NO,className:"button",text:ew.i18n.no};r.a;var a=n(2),l=class extends a.View{constructor(t){super(t),this.state=t.state,this.callback=t.callback,this.handleClick=this.handleClick.bind(this),this.button=this.$el.find("a"),this.spinner=this.$el.find(".spinner"),this.content=this.$el.find(".content"),this.status=this.$el.find(".status"),this.button.on("click",this.handleClick),this.mode=this.state.get("mode"),this.state.on("change",this.update,this)}template(){const t=this.state.get("processed"),e=this.state.get("total"),n=Math.floor(t/e*100);let o=this.state.get("statusText");return`${o=o.replace("{counter}",`${t}/${e}`)} (${n}%)`}handleClick(){this.button.hasClass("disabled")||this.callback()}update(){const t=this.state.get("mode"),e=this.state.get("action");this.mode!==t&&this.toggleMode(t),"processing"===t&&this.action===e&&this.status.html(this.template())}toggleMode(t){this.mode=t,this.action===this.state.get("action")||"loading"!==t&&"processing"!==t?"loading"===t?this.loading():"processing"===t?this.processing():this.reset():this.disable()}disable(){this.button.addClass("disabled")}loading(){this.disable(),this.spinner.css({visibility:"visible"})}processing(){this.content.hide(),this.status.show()}reset(){this.spinner.css({visibility:"hidden"}),this.status.hide(),this.content.show(),this.button.removeClass("disabled")}},c=class extends l{constructor(t){t.el=".tool-bulk-watermark",super(t),this.action="watermark",this.selectWatermark=this.selectWatermark.bind(this),this.toggleButton=this.toggleButton.bind(this),this.select=this.$el.find("select"),this.select.on("change",this.selectWatermark),this.toggleButton()}selectWatermark(){const t=this.select.val(),e=this.select.find("option:selected").data("nonce");this.state.set({watermark:t,nonce:e}),this.toggleButton()}toggleButton(){"-1"===this.select.val()?this.button.addClass("disabled"):this.button.removeClass("disabled")}disable(){super.disable(),this.select.prop({disabled:!0})}processing(){this.select.val("-1"),super.processing()}reset(){super.reset(),this.select.prop({disabled:!1}).change()}},u=class extends l{constructor(t){t.el=".tool-restore",super(t),this.action="restore",this.backupInfo=this.$el.find("p.has-backup"),this.noBackupInfo=this.$el.find("p.no-backup"),this.backupCountInfo=this.$el.find(".backup-count"),this.state.set({backupCount:this.$el.data("backup-count")}),this.toggleInfo()}handleClick(){this.state.set({nonce:this.button.data("nonce")}),super.handleClick()}toggleInfo(){const t=this.state.get("backupCount");0<t?(this.backupCountInfo.text(t),this.backupInfo.show(),this.noBackupInfo.hide()):(this.backupInfo.hide(),this.noBackupInfo.show())}update(){super.update(),this.toggleInfo()}},d=n(1);n(24);i()(document).ready(()=>{switch(i()("a.nav-tab-active").data("tab")){case"settings":new class{constructor(){this.form=i()("form#easy-watermark-settings-form"),this.form.length&&this.init()}init(){this.toggleGroup=this.toggleGroup.bind(this),this.checkboxes=this.form.find("input[data-toggle]"),this.checkboxes.on("change",this.toggleGroup),this.checkboxes.change()}toggleGroup(t){const e=i()(t.target),n=e.data("toggle"),o=this.form.find(`.group-${n}`),s=o.find("input, textarea, select");!0===e.is(":checked")?(o.show(),s.prop("disabled",!1)):(o.hide(),s.prop("disabled",!0))}};break;case"watermarks":new class{constructor(){this.wrap=i()(".watermarks"),this.wrap.length&&this.init()}init(){this.confirm=this.confirm.bind(this),this.deleteButtons=this.wrap.find(".row-actions a.submitdelete"),this.deleteButtons.on("click",this.confirm)}confirm(t){t.preventDefault();const e=i()(t.currentTarget),n=e.data("watermark-name");!function(t="",e=(()=>{})){r.a.dialog.confirm({message:t,callback:e,buttons:[r.a.dialog.buttons.YES,r.a.dialog.buttons.NO]})}(ew.i18n.deleteConfirmation.replace("{watermarkName}",n),t=>{!0===t&&(window.location=e.attr("href"))})}};break;case"tools":new class{constructor(){this.wrap=i()(".tools"),this.wrap.length&&this.init()}init(){this.bulkWatermark=this.bulkWatermark.bind(this),this.restore=this.restore.bind(this),this.state=new a.Model,this.state.set({mode:"none"}),this.bulkWatermarkTool=new c({state:this.state,callback:this.bulkWatermark}),this.restoreTool=new u({state:this.state,callback:this.restore})}bulkWatermark(){this.state.set({action:"watermark",successMessage:ew.i18n.watermarkingSuccessMessage,statusText:ew.i18n.watermarkingStatus}),this.getInfo()}restore(){this.state.set({action:"restore",successMessage:ew.i18n.restoringSuccessMessage,statusText:ew.i18n.restoringStatus}),this.getInfo()}getInfo(){this.state.set({mode:"loading"}),i.a.ajax(ajaxurl,{data:{action:"easy-watermark/tools/get-attachments",nonce:ew.nonce,mode:this.state.get("action")}}).done(t=>{t.success?(this.state.set({items:t.data}),this.start()):Object(d.a)(ew.i18n.genericErrorMessage,"error")}).fail(()=>{Object(d.a)(ew.i18n.genericErrorMessage,"error")})}start(){const t=this.state.get("items");if(!t)return function(t="",e=(()=>{})){r.a.dialog.alert({message:t,callback:e,buttons:[r.a.dialog.buttons.OK]})}(ew.i18n.noItemsToWatermark),void this.state.set({mode:"none"});this.state.set({mode:"processing",processed:0,total:t.length,error:!1,backupCount:0}),this.doActionRecursive(t)}doActionRecursive(t){const e=t.shift(),n=this.state.get("nonce"),o=this.state.get("watermark");let s="easy-watermark/",r=this.state.get("processed"),a=this.state.get("backupCount");"watermark"===this.state.get("action")?s+="all"===o?"apply_all":"apply_single":s+="restore_backup",this.state.set({attachment:e}),i.a.ajax(ajaxurl,{data:{action:s,nonce:n,watermark:o,attachment_id:e.id}}).done(e=>{!0===e.success?(r++,e.data.hasBackup&&a++,this.state.set({processed:r,backupCount:a}),t.length?this.doActionRecursive(t):this.finish()):this.fail(e.data)}).fail(()=>{this.fail(ew.i18n.genericErrorMessage)})}fail(t){const e=this.state.get("attachment").title,n=ew.i18n.bulkActionErrorMessage.replace("{imageTitle}",e).replace("{error}",t);this.state.set({error:n}),this.finish()}finish(){const t=this.state.get("error"),e=this.state.get("processed"),n=this.state.get("successMessage");t?Object(d.a)(t,"error"):Object(d.a)(n.replace("{procesed}",e),"success"),this.state.set({mode:"none"})}}}})},,function(t,e){},,function(t,e){}]);
assets/dist/scripts/media-library.js ADDED
@@ -0,0 +1 @@
1
+ !function(e){var t={};function s(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,s),r.l=!0,r.exports}s.m=e,s.c=t,s.d=function(e,t,i){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)s.d(i,r,function(t){return e[t]}.bind(null,r));return i},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="../",s(s.s=18)}({0:function(e,t){e.exports=jQuery},1:function(e,t,s){"use strict";s.d(t,"a",(function(){return a})),s.d(t,"b",(function(){return o})),s.d(t,"c",(function(){return n})),s.d(t,"d",(function(){return l}));var i=s(0),r=s.n(i);function a(e,t="info"){const s=r()(document.createElement("div")),i=r()(document.createElement("p")),a=r()(document.createElement("button"));s.addClass("notice notice-"+t+" is-dismissible").hide(),a.addClass("notice-dismiss"),i.html(e),s.append(i).append(a),a.on("click",e=>{e.preventDefault(),s.fadeOut(200,()=>{s.remove()})}),r()("hr.wp-header-end").after(s),s.fadeIn(200)}function o(e,t=!1,s=!0){let i=e.length;for(const r of e.clone().models)(!l(r)||r.get("usedAsWatermark")||!0===t&&!r.get("hasBackup"))&&(!0===s&&e.remove(r),i--);return i}function n(e,t){const s=e.indexOf("?");return-1!==s&&(e=e.substr(0,s)),e+="?v="+t}function l(e){return"object"==typeof e&&e.get&&(e=e.get("mime")),Object.keys(ew.mime).includes(e)}},16:function(e,t){wp.media&&"function"==typeof wp.media.view.SelectModeToggleButton&&(wp.media.view.SelectModeToggleButton=class extends wp.media.view.SelectModeToggleButton{initialize(){super.initialize(),this.controller.on("processing:activate processing:deactivate",this.toggleDisabled,this)}toggleDisabled(){this.model.set("disabled",this.controller.isModeActive("processing"))}toggleBulkEditHandler(){super.toggleBulkEditHandler(),this.controller.trigger("selection:toggle");const e=this.controller.content.get().toolbar;this.controller.isModeActive("select")?e.$(".watermark-mode-toggle-button").removeClass("hidden"):e.$(".watermark-mode-toggle-button").addClass("hidden"),e.$(".watermark-selector").css("display",""),e.$(".ew-status").css("display","")}})},17:function(e,t){wp.media&&("function"==typeof wp.media.view.AttachmentFilters.All&&(wp.media.view.AttachmentFilters.All=class extends wp.media.view.AttachmentFilters.All{initialize(){super.initialize(),this.controller.on("processing:activate processing:deactivate",this.toggleDisabled,this)}toggleDisabled(){this.$el.prop("disabled",!this.$el.is(":disabled"))}}),"function"==typeof wp.media.view.AttachmentFilters.Uploaded&&(wp.media.view.AttachmentFilters.Uploaded=class extends wp.media.view.AttachmentFilters.Uploaded{initialize(){super.initialize(),this.controller.on("processing:activate processing:deactivate",this.toggleDisabled,this)}toggleDisabled(){this.$el.prop("disabled",!this.$el.is(":disabled"))}}),"function"==typeof wp.media.view.DateFilter&&(wp.media.view.DateFilter=class extends wp.media.view.DateFilter{initialize(){super.initialize(),this.controller.on("processing:activate processing:deactivate",this.toggleDisabled,this)}toggleDisabled(){this.$el.prop("disabled",!this.$el.is(":disabled"))}}))},18:function(e,t,s){"use strict";s.r(t);s(30);var i=s(0),r=s.n(i),a=s(1);wp.media&&"function"==typeof wp.media.view.Attachment.Library&&(wp.media.view.Attachment.Library=class extends wp.media.view.Attachment.Library{initialize(){super.initialize(),this.listenTo(this.model,"ewBulkAction:start",this.showLoader),this.listenTo(this.model,"ewBulkAction:done",this.render),this.controller.on("selection:toggle watermark:activate processing:activate",this.disable,this),this.controller.on("watermark:deactivate processing:deactivate",this.enable,this)}render(){super.render(),this.$el.append(r()("<span></span>").addClass("spinner"))}toggleSelection(e){const{method:t}=e;(!this.controller.isModeActive("watermark")||Object(a.d)(this.model)&&!this.model.get("usedAsWatermark")||"between"===t)&&super.toggleSelection(e),this.controller.isModeActive("watermark")&&(Object(a.d)(this.model)&&!this.model.get("usedAsWatermark")||this.$el.blur(),"between"===t&&Object(a.b)(this.options.selection))}showLoader(){this.$el.find(".spinner").css({visibility:"visible"})}disable(){if(!this.controller.isModeActive("watermark")&&!this.controller.isModeActive("processing"))return;if(this.hasBadge)return;if(this.controller.isModeActive("processing")&&!this.wasSelected())return;let e;if(Object(a.d)(this.model))if(this.model.get("usedAsWatermark"))e=ew.i18n.usedAsWatermark;else{if(!this.controller.isModeActive("restoring")||this.model.get("hasBackup"))return;e=ew.i18n.noBackupAvailable}else e=ew.i18n.notSupported;const t=r()("<div>",{class:"badge"}).text(e);this.$el.addClass("disabled").append(t),this.hasBadge=!0}enable(){this.controller.isModeActive("watermark")||this.controller.isModeActive("processing")||(this.$el.removeClass("disabled").find(".badge").remove(),this.hasBadge=!1)}wasSelected(){const e=this.controller.state().get("originalSelection");if(e)return!!e.get(this.model.cid)}});let o=null;wp.media&&"function"==typeof wp.media.view.Button&&(o=class extends wp.media.view.Button{initialize(){super.initialize(),this.controller.on("watermark:activate",()=>{this.$el.removeClass("hidden").show()}),this.controller.on("watermark:deactivate",()=>{this.$el.addClass("hidden").hide()}),this.controller.on("watermark:selected",this.toggleDisabled,this),this.model.set("disabled",!0)}render(){return super.render(),this.controller.isModeActive("watermark")?this.$el.addClass("watermark-button"):this.$el.addClass("watermark-button hidden"),this}click(){super.click(),this.controller.state().get("watermark")&&this.controller.ewWatermark()}toggleDisabled(e){this.model.set("disabled",!e.length)}});var n=o;let l=null;wp.media&&"function"==typeof wp.media.view.Button&&(l=class extends wp.media.view.Button{initialize(){super.initialize(),this.model.set({originalText:this.model.get("text")}),this.controller.on("selection:toggle",this.update,this),this.controller.on("watermark:activate watermark:deactivate",this.render,this),this.controller.on("select:activate select:deactivate",this.render,this)}render(){return super.render(),this.controller.isModeActive("select")&&!this.controller.isModeActive("watermark")?this.$el.addClass("restore-button"):this.$el.addClass("restore-button hidden"),this.update(),this}click(){super.click(),this.controller.isModeActive("select")&&this.controller.ewRestoreBackup()}update(){const e=this.model.get("filteredSelectionCount"),t=Object(a.b)(this.controller.state().get("selection"),!0,!1);t!==e&&(this.model.set({filteredSelectionCount:t,text:`${this.model.get("originalText")} (${t})`}),this.model.set("disabled",!Boolean(t)))}});var c=l;let d=null;if(wp.media&&"function"==typeof wp.media.view.Button){class e extends wp.media.view.Button{initialize(){super.initialize(),this.model.set({originalText:this.model.get("text"),cancelText:this.options.cancelText}),delete this.options.cancelText,this.controller.on("selection:toggle",this.update,this),this.controller.on("watermark:activate",()=>this.$el.html(this.model.get("cancelText"))),this.controller.on("watermark:deactivate",this.update,this)}render(){return super.render(),this.controller.isModeActive("select")?this.$el.addClass("watermark-mode-toggle-button"):this.$el.addClass("watermark-mode-toggle-button hidden"),this.update(),this}click(){super.click(),this.controller.isModeActive("watermark")?this.controller.deactivateMode("watermark"):(this.controller.activateMode("watermark"),Object(a.b)(this.controller.state().get("selection")))}update(){if(this.controller.isModeActive("watermark"))return;const e=this.model.get("filteredSelectionCount"),t=Object(a.b)(this.controller.state().get("selection"),!1,!1);t!==e&&(this.model.set({filteredSelectionCount:t,text:`${this.model.get("originalText")} (${t})`}),this.model.set("disabled",!Boolean(t)),this.controller.state().get("selection").length||this.controller.deactivateMode("watermark"))}}d=e}var h=d;let u=null;if(wp.media&&"function"==typeof wp.media.View){class e extends wp.media.View{constructor(e){super(e),this.controller.on("watermark:activate",this.show,this),this.controller.on("watermark:deactivate",this.hide,this)}events(){return{change:"selectWatermark"}}tagName(){return"select"}selectWatermark(){this.controller.trigger("watermark:selected",this.$el.val()),this.controller.state().set("watermark",this.$el.val())}show(){this.$el.removeClass("hidden")}hide(){this.$el.addClass("hidden")}render(){if(super.render(),this.$el.append(r()("<option>",{value:""}).html(ew.i18n.selectWatermarkLabel)),ew.watermarks){1<Object.keys(ew.watermarks).length&&this.$el.append(r()("<option>",{value:"all"}).html(ew.i18n.allWatermarksLabel));for(const e in ew.watermarks)this.$el.append(r()("<option>",{value:e}).html(ew.watermarks[e]))}return this.controller.isModeActive("select")?this.$el.addClass("watermark-selector"):this.$el.addClass("watermark-selector hidden"),this}}u=e}var p=u;let g=null;if(wp.media&&"function"==typeof wp.media.View){class e extends wp.media.View{tagName(){return"p"}className(){return"ew-status"}template(){let e=this.status.get("text");if(this.status.get("progress")){const t=this.status.get("processed"),s=this.status.get("total"),i=`${t}/${s}`,r=Math.floor(t/s*100);"string"==typeof status&&(e=e.replace("{counter}",i)),e+=` (${r}%)`}return`<span class="status">${e}</span>`}constructor(e){super(e),this.status=this.controller.state().get("ewStatus"),this.status.on("change",this.update,this)}render(){return this.update(),this}update(){this.status.get("visible")?this.$el.removeClass("hidden").html(this.template()):this.$el.addClass("hidden")}cancel(e){e.preventDefault(),this.controller.deactivateMode("watermarking")}}g=e}var m=g;wp.media&&"function"==typeof wp.media.view.AttachmentsBrowser&&(wp.media.view.AttachmentsBrowser=class extends wp.media.view.AttachmentsBrowser{createToolbar(){super.createToolbar(),Object.keys(ew.watermarks).length&&(this.toolbar.set("watermarkModeToggleButton",new h({text:ew.i18n.watermarkModeToggleButtonLabel,cancelText:ew.i18n.cancelLabel,controller:this.controller,priority:-60}).render()),this.toolbar.set("watermarkSelector",new p({controller:this.controller,priority:-50}).render()),this.toolbar.set("watermarkButton",new n({text:ew.i18n.watermarkButtonLabel,style:"primary",controller:this.controller,priority:-40}).render())),this.toolbar.set("restoreButton",new c({text:ew.i18n.restoreButtonLabel,controller:this.controller,priority:-30}).render()),this.toolbar.set("watermarkingStatus",new m({style:"primary",controller:this.controller,priority:-20}).render()),this.controller.on("select:deactivate",()=>this.controller.deactivateMode("watermark")),this.controller.on("watermark:activate",this.hideButtons,this),this.controller.on("watermark:deactivate",this.showButtons,this),this.controller.on("processing:activate processing:deactivate",this.disableViewSwitch,this)}hideButtons(){this.$(".select-mode-toggle-button").addClass("hidden"),this.$(".delete-selected-button").addClass("hidden")}showButtons(){this.$el.html(this.model.get("text")),this.$(".select-mode-toggle-button").removeClass("hidden"),this.$(".delete-selected-button").removeClass("hidden")}disableViewSwitch(){const e=this.toolbar.$(".view-switch");e.hasClass("disabled")?e.removeClass("disabled"):e.addClass("disabled")}});s(16),s(17);var w=s(2);wp.media&&wp.media.view&&wp.media.view.MediaFrame&&"function"==typeof wp.media.view.MediaFrame.Manage&&(wp.media.view.MediaFrame.Manage=class extends wp.media.view.MediaFrame.Manage{browseContent(e){this.state().set({ewCollection:new w.Collection,ewStatus:new w.Model}),super.browseContent(e)}ewBulkAction(){const e=this.state(),t=e.get("selection"),s=e.get("ewAction"),i=t.clone();if(e.set("originalSelection",i),Object(a.b)(t,"restore"===s),!t.length)return;const r=e.get("ewCollection"),o=e.get("ewStatus");r.reset();for(const e of t.models)r.add(e),e.trigger("ewBulkAction:start");this.deactivateMode("watermark").trigger("selection:action:done"),this.activateMode("processing"),o.set({total:r.length,processed:0,error:!1,visible:!0,progress:!0}),this.ewBulkActionRecursive()}ewBulkActionRecursive(){const e=this.state(),t=e.get("ewAction"),s=e.get("watermark");let i,o="easy-watermark/";if("watermark"===t)o+="all"===s?"apply_all":"apply_single",i="all"===s?ew.applyAllNonce:ew.applySingleNonces[s];else{if("restore"!==t)return;o+="restore_backup",i=ew.restoreBackupNonce}const n=e.get("ewStatus"),l=e.get("ewCollection").shift(),c={action:o,nonce:i,watermark:s};let d=n.get("processed");c.attachment_id=l.get("id"),e.set("ewCurrentModel",l),r.a.ajax(ajaxurl,{data:c}).done(e=>{if(!0===e.success){if(e.data.attachmentVersion){l.set("url",Object(a.c)(l.get("url"),e.data.attachmentVersion));const t=l.get("sizes");for(const s of Object.keys(t))t[s].url=Object(a.c)(t[s].url,e.data.attachmentVersion);l.set("sizes",t)}l.set("hasBackup",!!e.data.hasBackup),d++,n.set({processed:d}),l.trigger("ewBulkAction:done"),n.get("total")===d?this.ewBulkActionDone():this.ewBulkActionRecursive()}else{const t="string"==typeof e.data.message?e.data.message:ew.i18n.genericErrorMessage;this.ewBulkActionError(t)}}).fail(()=>{this.ewBulkActionError(ew.i18n.genericErrorMessage)})}ewWatermark(){this.state().set({ewAction:"watermark",ewSuccessMessage:ew.i18n.watermarkingSuccessMessage}).get("ewStatus").set({text:ew.i18n.watermarkingStatus}),this.activateMode("watermarking"),this.ewBulkAction()}ewRestoreBackup(){this.state().set({ewAction:"restore",ewSuccessMessage:ew.i18n.restoringSuccessMessage}).get("ewStatus").set({text:ew.i18n.restoringStatus}),this.activateMode("restoring"),this.ewBulkAction()}ewBulkActionError(e){const t=this.state(),s=t.get("ewStatus"),i=t.get("ewCollection"),r=t.get("ewCurrentModel");r&&i.push(r);for(const e of i.models)e.trigger("ewBulkAction:done");s.set({error:e}),this.ewBulkActionDone()}ewBulkActionDone(){const e=this.state(),t=e.get("ewStatus"),s=e.get("ewCurrentModel"),i=t.get("processed"),r=t.get("error"),o=e.get("ewSuccessMessage");if(this.deactivateMode("watermarking"),this.deactivateMode("restoring"),this.deactivateMode("processing"),i>0&&Object(a.a)(o.replace("{procesed}",i),"success"),r){const e=ew.i18n.bulkActionErrorMessage.replace("{imageTitle}",s.get("title")).replace("{error}",r);Object(a.a)(e,"error")}t.set({visible:!1,progress:!1})}});var k=class extends w.View{constructor(e){super(e),this.controller=e.controller,this.bulkActionSelector=e.bulkActionSelector}},b=class extends k{tagName(){return"select"}className(){return"ew-status"}events(){return{change:"selectWatermark"}}constructor(e){super(e),this.listenTo(this.controller,"change",this.update),this.listenTo(this.controller,"bulkAction:start",this.reset)}render(){super.render(),this.$el.append(r()("<option>",{value:""}).html(ew.i18n.selectWatermarkLabel)),1<Object.keys(ew.watermarks).length&&this.$el.append(r()("<option>",{value:"all"}).html(ew.i18n.allWatermarksLabel));for(const e in ew.watermarks)this.$el.append(r()("<option>",{value:e}).html(ew.watermarks[e]));return this.attach(),this}update(){this.bulkActionSelector.is(this.controller.get("select"))&&("watermark"!==this.controller.get("action")||this.controller.status().get("processing")?this.$el.hide():this.$el.show())}reset(){this.$el.val("all").hide()}attach(){return this.bulkActionSelector.after(this.$el),this.$el.hide(),this}selectWatermark(){this.controller.set("watermark",this.$el.val())}},f=class extends k{tagName(){return"p"}className(){return"ew-status"}template(){let e=this.status.get("text");if(this.status.get("processing")){const t=this.status.get("processed"),s=this.status.get("total"),i=`${t}/${s}`;let r=Math.floor(t/s*100);"string"==typeof e&&(e=e.replace("{counter}",i)),isNaN(r)&&(r=0),e=`${e} (${r}%)`}return e}constructor(e){super(e),this.status=this.controller.status(),this.listenTo(this.status,"change",this.update)}render(){super.render(),this.attach()}update(){this.bulkActionSelector.is(this.controller.get("select"))&&(this.status.get("text")?(this.$el.html(this.template()),this.$el.show()):this.$el.hide())}attach(){return this.bulkActionSelector.parent().append(this.$el),this.$el.hide(),this}},v=class extends k{constructor(e){super(e),this.model=e.model,this.listenTo(this.model,"processing:start",this.showSpinner),this.listenTo(this.model,"processing:done",this.reset),this.listenTo(this.model,"remove",this.deselect),this.controller.on("bulkAction:finished",this.reset,this)}showSpinner(){this.getSpinner().appendTo(this.$el.find("span.media-icon"))}getSpinner(){return this.spinner||(this.spinner=r()("<span>",{class:"spinner ew-spinner"})),this.spinner}reset(){this.spinner&&this.spinner.remove(),this.getStatus().text(""),this.$el.find('input[type="checkbox"]').click().prop("checked",!1)}deselect(){if(this.controller.status().get("processing"))return;let e;this.$el.find('input[type="checkbox"]').click().prop("checked",!1),Object(a.d)(this.model)?this.model.get("usedAsWatermark")?e=ew.i18n.usedAsWatermark:"restore"!==this.controller.get("action")||this.model.get("hasBackup")||(e=ew.i18n.noBackupAvailable):e=ew.i18n.notSupported,this.getStatus().text(` - ${e}`)}getStatus(){return this.status||(this.status=r()("<span>",{class:"ew-status"}),this.$el.find("strong.has-media-icon").append(this.status)),this.status}};class A extends w.Model{constructor(){super(),this.bulkActionsSelectors=r()("select#bulk-action-selector-top, select#bulk-action-selector-bottom"),this.bulkActionsSelectors.length&&this.init()}init(){this.selectBulkAction=this.selectBulkAction.bind(this),this.doAction=this.doAction.bind(this),this.form=r()("form#posts-filter"),this.actionButtons=this.form.find("#doaction, #doaction2"),this.bulkActionsSelectors.each((e,t)=>{const s=r()(t);new b({controller:this,bulkActionSelector:s}).render(),new f({controller:this,bulkActionSelector:s}).render()}).val(-1).on("change",this.selectBulkAction),this.set({attachments:new w.Collection,selection:new w.Collection}),this.actionButtons.on("click",this.doAction),this.on("bulkAction:start",()=>{this.bulkActionsSelectors.val(-1).prop("disabled",!0),this.actionButtons.prop("disabled",!0)}),this.on("bulkAction:finished",()=>{this.bulkActionsSelectors.prop("disabled",!1),this.actionButtons.prop("disabled",!1)})}selectBulkAction(e){const t=r()(e.target);this.set({select:t,action:t.val()})}doAction(e){const t=this.get("action");if(!this.checkAction(t))return;e.preventDefault();const s=this.get("watermark");if("watermark"===t&&!s)return;const i=this.form.find('input[name="media[]"]:checked');if(!i.length)return void this.status().set({text:ew.i18n.noItemsSelected});const a=this.get("attachments"),o=this.get("selection"),n=[];this.trigger("bulkAction:start"),i.each((e,t)=>{const s=r()(t).val(),i=a.get(s);i?o.add(i):n.push(s)}),n.length?(this.status().set({text:'<span class="spinner ew-spinner"></span>'}),r.a.ajax(ajaxurl,{data:{action:"easy-watermark/attachments-info",nonce:ew.attachmentsInfoNonce,attachments:n}}).done(e=>{if(!0===e.success){for(const t of e.data){const e=new w.Model(t);a.push(e),o.push(e),new v({el:`#post-${t.id}`,controller:this,model:e})}this.prepare()}else{const t=e.data.message?e.data.message:ew.i18n.genericErrorMessage;this.actionError(t)}}).fail(()=>{this.actionError(ew.i18n.genericErrorMessage)})):o.length&&this.prepare()}prepare(){const e=this.get("action"),t=this.get("selection"),s="restore"===e,i="watermark"===e?ew.i18n.watermarkingStatus:ew.i18n.restoringStatus,r="watermark"===e?ew.i18n.watermarkingSuccessMessage:ew.i18n.restoringSuccessMessage;if(Object(a.b)(t,s),!t.length)return this.status().set({successMessage:"watermark"===e?ew.i18n.watermarkingNoItems:ew.i18n.restoringNoItems}),void this.actionDone();this.status().set({successMessage:r,text:i,processing:!0,total:t.length,processed:0});for(const e of t.models)e.trigger("processing:start");this.doActionRecursive()}doActionRecursive(){const e=this.get("action"),t=this.get("watermark");let s,i="easy-watermark/";if("watermark"===e)i+="all"===t?"apply_all":"apply_single",s="all"===t?ew.applyAllNonce:ew.applySingleNonces[t];else{if("restore"!==e)return;i+="restore_backup",s=ew.restoreBackupNonce}const o=this.status(),n=this.get("selection"),l=n.shift(),c={action:i,nonce:s,watermark:t};let d=o.get("processed");c.attachment_id=l.get("id"),this.set("currentAttachmentID",c.attachment_id),r.a.ajax(ajaxurl,{data:c}).done(e=>{if(!0===e.success){if(e.data.attachmentVersion){const t=this.form.find("tr#post-"+c.attachment_id+" img"),s=Object(a.c)(t.attr("src"),e.data.attachmentVersion);t.attr({src:s,srcset:""})}d++,o.set({processed:d}),l.set("hasBackup",!!e.data.hasBackup),l.trigger("processing:done"),n.length?this.doActionRecursive():this.actionDone()}else{const t="string"==typeof e.data.message?e.data.message:ew.i18n.genericErrorMessage;this.actionError(t)}}).fail(()=>{this.actionError(ew.i18n.genericErrorMessage)})}actionError(e){this.status().set({error:e}),this.actionDone()}actionDone(){this.trigger("bulkAction:finished"),this.bulkActionsSelectors.prop("disabled",!1);const e=this.status(),t=e.get("processed"),s=e.get("error"),i=e.get("successMessage"),r=this.get("currentAttachmentID");if(t>0?Object(a.a)(i.replace("{procesed}",t),"success"):Object(a.a)(i,"info"),s){const e=this.form.find("tr#post-"+r).find(".column-title a").attr("aria-label"),t=ew.i18n.bulkActionErrorMessage.replace("{imageTitle}",e).replace("{error}",s);Object(a.a)(t,"error")}this.status().set({processing:!1,processed:0,total:0,text:""})}status(){let e=this.get("status");return void 0===e&&((e=new w.Model).set({processed:0,total:0}),this.set({status:e})),e}checkAction(e){return["watermark","restore"].includes(e)}}r()(document).ready(()=>new A)},2:function(e,t){e.exports=Backbone},30:function(e,t){}});
assets/dist/scripts/uploader.js ADDED
@@ -0,0 +1 @@
1
+ !function(e){var t={};function r(a){if(t[a])return t[a].exports;var n=t[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.d=function(e,t,a){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(a,n,function(t){return e[t]}.bind(null,n));return a},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="../",r(r.s=15)}({0:function(e,t){e.exports=jQuery},15:function(e,t,r){"use strict";r.r(t);var a=r(0),n=r.n(a);r(26);if("undefined"!=typeof wp&&"function"==typeof wp.Uploader&&"function"==typeof wp.media.view.UploaderInline){class e extends wp.Uploader{init(){super.init(),this.updateAutoWatermarkParam=this.updateAutoWatermarkParam.bind(this),n()("body").on("change",".ew-watermark-all-switch input",this.updateAutoWatermarkParam),this.param("auto_watermark",ew.autoWatermark)}updateAutoWatermarkParam(e){ew.autoWatermark=n()(e.target).is(":checked"),this.param("auto_watermark",ew.autoWatermark)}}class t extends wp.media.view.UploaderInline{render(){super.render(),this.$el.hasClass("hidden")||this.$el.find(".ew-watermark-all-switch input").prop("checked",ew.autoWatermark)}}wp.Uploader=e,wp.media.view.UploaderInline=t}},26:function(e,t){}});
assets/dist/scripts/watermark-edit.js ADDED
@@ -0,0 +1,8 @@
1
+ !function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(n,o,function(e){return t[e]}.bind(null,o));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="../",i(i.s=19)}({0:function(t,e){t.exports=jQuery},1:function(t,e,i){"use strict";i.d(e,"a",(function(){return r})),i.d(e,"b",(function(){return a})),i.d(e,"c",(function(){return s})),i.d(e,"d",(function(){return c}));var n=i(0),o=i.n(n);function r(t,e="info"){const i=o()(document.createElement("div")),n=o()(document.createElement("p")),r=o()(document.createElement("button"));i.addClass("notice notice-"+e+" is-dismissible").hide(),r.addClass("notice-dismiss"),n.html(t),i.append(n).append(r),r.on("click",t=>{t.preventDefault(),i.fadeOut(200,()=>{i.remove()})}),o()("hr.wp-header-end").after(i),i.fadeIn(200)}function a(t,e=!1,i=!0){let n=t.length;for(const o of t.clone().models)(!c(o)||o.get("usedAsWatermark")||!0===e&&!o.get("hasBackup"))&&(!0===i&&t.remove(o),n--);return n}function s(t,e){const i=t.indexOf("?");return-1!==i&&(t=t.substr(0,i)),t+="?v="+e}function c(t){return"object"==typeof t&&t.get&&(t=t.get("mime")),Object.keys(ew.mime).includes(t)}},19:function(t,e,i){"use strict";i.r(e);var n=i(0),o=i.n(n),r=(i(32),class{constructor(){this.metabox=o()("#watermark-content"),this.form=o()("form#post"),this.imageContent=this.metabox.find(".image-content"),this.textContent=this.metabox.find(".text-content"),this.buttonWrap=this.metabox.find(".select-image-button"),this.button=this.buttonWrap.find("a"),this.imageWrap=this.metabox.find(".watermark-image"),this.image=this.imageWrap.find("img"),this.mimeTypeField=this.metabox.find("input.watermark-mime-type"),this.urlField=this.metabox.find("input.watermark-url"),this.attachmentIdField=this.metabox.find("input.watermark-id"),this.opacityField=this.metabox.find("input#opacity"),this.opacityFieldDesc=this.metabox.find(".opacity-desc"),this.watermarkTextField=this.metabox.find("input.watermark-text"),this.attachmentId=this.attachmentIdField.val(),this.openMediaLibrary=this.openMediaLibrary.bind(this),this.update=this.update.bind(this),this.watermarkTextChange=this.watermarkTextChange.bind(this),this.form.on("ew.update",this.update),this.button.on("click",this.openMediaLibrary),this.image.on("click",this.openMediaLibrary),this.image.attr("src")?(this.imageWrap.show(),this.switchOpacityField(this.mimeTypeField.val())):this.buttonWrap.show(),this.textChangeTimeout=null,this.watermarkTextField.on("input",this.watermarkTextChange)}enable(t){this.metabox.fadeIn(200),"image"===t?(this.imageContent.show(),this.textContent.hide(),this.opacityField.prop("disabled",!1)):(this.textContent.show(),this.imageContent.hide(),this.opacityField.prop("disabled",!0),this.prepareTextPreview())}watermarkTextChange(){clearTimeout(this.textChangeTimeout),this.textChangeTimeout=setTimeout(()=>{this.form.trigger("ew.save")},500)}prepareTextPreview(){this.previewWrap||(this.previewWrap=this.metabox.find(".text-preview"),this.preview=o()(document.createElement("img")),this.previewWrap.hide().append(this.preview)),this.refreshPreview()}refreshPreview(){if(this.watermarkTextField.val().length){const t=this.previewWrap.data("src")+"?t="+Date.now();this.preview.attr("src",t),this.previewWrap.show()}else this.previewWrap.hide()}openMediaLibrary(t){t.preventDefault(),this.frame||this.createMediaFrame(),this.frame.open()}createMediaFrame(){this.frame=wp.media.frames.watermarkSelection=wp.media({title:this.button.data("choose"),library:{type:"image"},button:{text:this.button.data("buttonLabel"),close:!0}}),this.frame.on("select",this.selectImage,this).on("open",this.applySelection,this).on("close",this.checkSelectedAttachment,this)}selectImage(){const t=this.frame.state().get("selection").first(),e=t.get("mime"),i=t.get("url");this.attachmentId=t.get("id"),this.mimeTypeField.val(e),this.urlField.val(i),this.attachmentIdField.val(this.attachmentId),this.switchOpacityField(e),this.image.attr("src",i),this.imageWrap.show(),this.buttonWrap.hide(),this.form.trigger("ew.save")}applySelection(){if(this.attachmentId){const t=this.frame.state().get("selection"),e=wp.media.attachment(this.attachmentId);e.fetch(),e&&t.add([e])}}checkSelectedAttachment(){const t=wp.media.attachment(this.attachmentId);t.fetch(),t&&!0!==t.destroyed||(this.mimeTypeField.val(""),this.urlField.val(""),this.attachmentIdField.val(""),this.imageWrap.hide(),this.buttonWrap.show())}switchOpacityField(t){"image/png"===t?(this.opacityField.parent().hide(),this.opacityFieldDesc.show()):(this.opacityField.parent().show(),this.opacityFieldDesc.hide())}update(){"text"===this.form.find("input.watermark-type:checked").val()&&this.refreshPreview()}}),a=class{constructor(){this.metabox=o()("#alignment")}enable(){this.metabox.fadeIn(200)}},s=class{constructor(){this.metabox=o()("#applying-rules"),this.autoAddCheckbox=this.metabox.find("#watermark-autoadd"),this.hiddenSections=this.metabox.find(".hidden"),this.toggleOptionsVisibility=this.toggleOptionsVisibility.bind(this),this.autoAddCheckbox.on("change",this.toggleOptionsVisibility),this.toggleOptionsVisibility()}enable(){this.metabox.fadeIn(200)}toggleOptionsVisibility(){this.autoAddCheckbox.prop("checked")?this.hiddenSections.show():this.hiddenSections.hide()}},c=class{constructor(){this.metabox=o()("#scaling"),this.scalingModeSelect=this.metabox.find("#watermark-scaling-mode"),this.hiddenSections=this.metabox.find(".hidden"),this.fields=this.metabox.find("input, select"),this.toggleOptionsVisibility=this.toggleOptionsVisibility.bind(this),this.scalingModeSelect.on("change",this.toggleOptionsVisibility),this.toggleOptionsVisibility()}enable(t){"image"===t?(this.metabox.fadeIn(200),this.fields.prop("disabled",!1)):(this.metabox.hide(),this.fields.prop("disabled",!0))}toggleOptionsVisibility(){switch(this.hiddenSections.hide(),this.scalingModeSelect.val()){case"fit_to_width":case"fit_to_height":this.hiddenSections.show();break;case"cover":case"contain":this.hiddenSections.filter(".show-for-all").show()}}},h=class{constructor(){this.metabox=o()("#text-options"),this.form=o()("form#post"),this.colorInput=this.metabox.find("#text-color"),this.fields=this.metabox.find("input, select"),this.colorChangeTimeout=null,this.colorChanged=this.colorChanged.bind(this),this.colorInput.wpColorPicker({palettes:!0,change:this.colorChanged})}colorChanged(){clearTimeout(this.colorChangeTimeout),this.colorChangeTimeout=setTimeout(()=>{this.form.trigger("ew.save")},500)}enable(t){"text"===t?(this.metabox.fadeIn(200),this.fields.prop("disabled",!1)):(this.metabox.hide(),this.fields.prop("disabled",!0))}},l=i(1),d=class{constructor(){this.metabox=o()("#preview"),this.body=o()("body"),this.form=o()("form#post"),this.watermarkTextField=this.form.find("input.watermark-text"),this.attachmentIdField=this.form.find("input.watermark-id"),this.link=this.metabox.find(".select-preview-image"),this.previewWrap=this.metabox.find(".preview-wrap"),this.contentWrap=this.metabox.find(".content-wrap"),this.imageSelector=this.metabox.find(".image-selector"),this.popup=this.metabox.find(".ew-preview-popup"),this.spinner=this.metabox.find("span.spinner"),this.image=o()(document.createElement("img")),this.popup.appendTo(this.body),this.openMediaLibrary=this.openMediaLibrary.bind(this),this.openPopup=this.openPopup.bind(this),this.closePopup=this.closePopup.bind(this),this.selectImage=this.selectImage.bind(this),this.imageSelected=this.imageSelected.bind(this),this.update=this.update.bind(this),this.hasImage=this.previewWrap.data("hasImage"),this.link.on("click",this.openMediaLibrary),this.form.on("ew.update",this.update),this.image.on("click",this.openPopup),this.popup.find(".media-modal-close, .media-modal-backdrop").on("click",this.closePopup),this.imageSelector.hide(),this.contentWrap.hide(),this.previewWrap.prepend(this.image),this.refreshPreview()}enable(){this.metabox.fadeIn(200)}openMediaLibrary(t){t.preventDefault(),this.frame||this.createMediaFrame(),this.frame.open()}createMediaFrame(){this.frame=wp.media.frames.previewImage=wp.media({title:this.link.data("choose"),library:{type:"image"},button:{text:this.link.data("buttonLabel"),close:!0}}),this.frame.on("select",this.selectImage)}selectImage(){const t=this.frame.state().get("selection").first(),e=this.form.find("input[name=post_ID]").val();this.contentWrap.hide(),this.spinner.css("display","block"),o.a.ajax({type:"post",url:ajaxurl,data:{action:"easy-watermark/preview_image",attachment_id:t.id,watermark_id:e,nonce:ew.previewImageNonce}}).done(this.imageSelected).fail(()=>{})}imageSelected(t){if(!0===t.success){if(this.link.html(this.link.data("changeLabel")),this.hasImage=!0,t.data.popup){const e=o()(t.data.popup);this.popup.find(".media-frame-content").replaceWith(e.find(".media-frame-content"))}this.refreshPreview()}}refreshPreview(){if(this.contentWrap.hide(),this.hasImage){this.imageSelector.hide(),this.spinner.css("display","block");const t=Date.now(),e=Object(l.c)(this.previewWrap.data("src"),t);this.popup.find("img").each((e,i)=>{const n=o()(i),r=Object(l.c)(n.attr("src"),t);n.attr("src",r)}),this.image.one("load",()=>{this.spinner.hide(),this.contentWrap.fadeIn(200),this.imageSelector.fadeIn(200)}).attr("src",e)}else this.imageSelector.show()}openPopup(){this.popup.show(),this.body.addClass("modal-open")}closePopup(){this.popup.hide(),this.body.removeClass("modal-open")}hasPreview(){const t=this.form.find("input.watermark-type:checked").val();return!("text"!==t||!this.watermarkTextField.val().length)||!("image"!==t||!this.attachmentIdField.val().length)}update(){this.refreshPreview()}},u=i(4),p=i.n(u),f=class{constructor(){this.metabox=o()("#placeholders"),this.placeholders=this.metabox.find(".placeholders-list li"),this.searchField=this.metabox.find("input.ew-search-placeholders"),this.clipboard=new p.a(".placeholders-list code"),this.clipboardSuccess=this.clipboardSuccess.bind(this),this.filterPlaceholders=this.filterPlaceholders.bind(this),this.clipboard.on("success",this.clipboardSuccess),this.searchField.on("keyup",this.filterPlaceholders)}enable(t){"text"===t?this.metabox.fadeIn(200):this.metabox.hide()}clipboardSuccess(t){const e=o()(t.trigger);e.text("Copied"),setTimeout(()=>{e.text(t.text)},1e3)}filterPlaceholders(t){const e=o()(t.target).val();this.placeholders.hide().each((t,i)=>{const n=o()(i);-1!==n.find("code").text().toLowerCase().indexOf(e)&&n.show()})}},m=class{constructor(){this.fields=o()(".form-field"),this.buttons=this.fields.find("button[data-toggle=dropdown]"),this.dropdowns=this.fields.find(".dropdown-menu[data-target]"),this.links=this.dropdowns.find("a"),this.init()}init(){this.toggleDropdown=this.toggleDropdown.bind(this),this.dropdownSelect=this.dropdownSelect.bind(this),this.hideDropdowns=this.hideDropdowns.bind(this),this.buttons.on("click",this.toggleDropdown),this.links.on("click",this.dropdownSelect),o()(document).on("click",this.hideDropdowns)}toggleDropdown(t){t.preventDefault();const e=o()(t.target),i=e.position();e.next(".dropdown-menu").css({left:i.left,top:i.top+e.height()}).toggle()}dropdownSelect(t){t.preventDefault();const e=o()(t.target),i=e.closest(".dropdown-menu"),n=o()(i.data("target"));n.length&&(n.val(e.data("value")),i.prev("button[data-toggle=dropdown]").text(e.text()))}hideDropdowns(t){o()(t.target).is(this.buttons)||this.dropdowns.hide()}};class g{constructor(){this.selectWatermarkType=this.selectWatermarkType.bind(this),this.triggerSave=this.triggerSave.bind(this),this.form=o()("form#post"),this.selector=this.form.find("input.watermark-type"),this.metaboxes=[new r,new a,new s,new c,new h,new d,new f],new m;const t=this.selector.filter("[checked]");t.length&&this.selectWatermarkType(t[0].value),this.selector.on("change",t=>{this.selectWatermarkType(t.target.value)}),this.form.on("change","input, select",this.triggerSave).on("ew.save",this.triggerSave)}selectWatermarkType(t){for(const e of this.metaboxes)e.enable(t)}triggerSave(){const t={action:"easy-watermark/autosave",nonce:ew.autosaveNonce};let e=this.form.find("[name^=watermark], [name=post_ID]").serialize();for(const i in t)e+="&"+encodeURIComponent(i)+"="+encodeURIComponent(t[i]);o.a.ajax({type:"post",url:ajaxurl,data:e}).done(t=>{!0===t.success&&this.form.trigger("ew.update")}).fail(()=>{})}}o()(document).ready(()=>new g)},32:function(t,e){},4:function(t,e,i){
2
+ /*!
3
+ * clipboard.js v2.0.4
4
+ * https://zenorocha.github.io/clipboard.js
5
+ *
6
+ * Licensed MIT © Zeno Rocha
7
+ */
8
+ var n;n=function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)i.d(n,o,function(e){return t[e]}.bind(null,o));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),r=c(i(1)),a=c(i(3)),s=c(i(4));function c(t){return t&&t.__esModule?t:{default:t}}var h=function(t){function e(t,i){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var n=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return n.resolveOptions(i),n.listenClick(t),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),o(e,[{key:"resolveOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText,this.container="object"===n(t.container)?t.container:document.body}},{key:"listenClick",value:function(t){var e=this;this.listener=(0,s.default)(t,"click",(function(t){return e.onClick(t)}))}},{key:"onClick",value:function(t){var e=t.delegateTarget||t.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new r.default({action:this.action(e),target:this.target(e),text:this.text(e),container:this.container,trigger:e,emitter:this})}},{key:"defaultAction",value:function(t){return l("action",t)}},{key:"defaultTarget",value:function(t){var e=l("target",t);if(e)return document.querySelector(e)}},{key:"defaultText",value:function(t){return l("text",t)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],e="string"==typeof t?[t]:t,i=!!document.queryCommandSupported;return e.forEach((function(t){i=i&&!!document.queryCommandSupported(t)})),i}}]),e}(a.default);function l(t,e){var i="data-clipboard-"+t;if(e.hasAttribute(i))return e.getAttribute(i)}t.exports=h},function(t,e,i){"use strict";var n,o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),a=i(2),s=(n=a)&&n.__esModule?n:{default:n},c=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.resolveOptions(e),this.initSelection()}return r(t,[{key:"resolveOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action=t.action,this.container=t.container,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function(){var t=this,e="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[e?"right":"left"]="-9999px";var i=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=i+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=(0,s.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=(0,s.default)(this.target),this.copyText()}},{key:"copyText",value:function(){var t=void 0;try{t=document.execCommand(this.action)}catch(e){t=!1}this.handleResult(t)}},{key:"handleResult",value:function(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(t){if(void 0!==t){if(!t||"object"!==(void 0===t?"undefined":o(t))||1!==t.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}},get:function(){return this._target}}]),t}();t.exports=c},function(t,e){t.exports=function(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var i=t.hasAttribute("readonly");i||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),i||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var n=window.getSelection(),o=document.createRange();o.selectNodeContents(t),n.removeAllRanges(),n.addRange(o),e=n.toString()}return e}},function(t,e){function i(){}i.prototype={on:function(t,e,i){var n=this.e||(this.e={});return(n[t]||(n[t]=[])).push({fn:e,ctx:i}),this},once:function(t,e,i){var n=this;function o(){n.off(t,o),e.apply(i,arguments)}return o._=e,this.on(t,o,i)},emit:function(t){for(var e=[].slice.call(arguments,1),i=((this.e||(this.e={}))[t]||[]).slice(),n=0,o=i.length;n<o;n++)i[n].fn.apply(i[n].ctx,e);return this},off:function(t,e){var i=this.e||(this.e={}),n=i[t],o=[];if(n&&e)for(var r=0,a=n.length;r<a;r++)n[r].fn!==e&&n[r].fn._!==e&&o.push(n[r]);return o.length?i[t]=o:delete i[t],this}},t.exports=i},function(t,e,i){var n=i(5),o=i(6);t.exports=function(t,e,i){if(!t&&!e&&!i)throw new Error("Missing required arguments");if(!n.string(e))throw new TypeError("Second argument must be a String");if(!n.fn(i))throw new TypeError("Third argument must be a Function");if(n.node(t))return function(t,e,i){return t.addEventListener(e,i),{destroy:function(){t.removeEventListener(e,i)}}}(t,e,i);if(n.nodeList(t))return function(t,e,i){return Array.prototype.forEach.call(t,(function(t){t.addEventListener(e,i)})),{destroy:function(){Array.prototype.forEach.call(t,(function(t){t.removeEventListener(e,i)}))}}}(t,e,i);if(n.string(t))return function(t,e,i){return o(document.body,t,e,i)}(t,e,i);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}},function(t,e){e.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},e.nodeList=function(t){var i=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===i||"[object HTMLCollection]"===i)&&"length"in t&&(0===t.length||e.node(t[0]))},e.string=function(t){return"string"==typeof t||t instanceof String},e.fn=function(t){return"[object Function]"===Object.prototype.toString.call(t)}},function(t,e,i){var n=i(7);function o(t,e,i,n,o){var a=r.apply(this,arguments);return t.addEventListener(i,a,o),{destroy:function(){t.removeEventListener(i,a,o)}}}function r(t,e,i,o){return function(i){i.delegateTarget=n(i.target,e),i.delegateTarget&&o.call(t,i)}}t.exports=function(t,e,i,n,r){return"function"==typeof t.addEventListener?o.apply(null,arguments):"function"==typeof i?o.bind(null,document).apply(null,arguments):("string"==typeof t&&(t=document.querySelectorAll(t)),Array.prototype.map.call(t,(function(t){return o(t,e,i,n,r)})))}},function(t,e){var i=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var n=Element.prototype;n.matches=n.matchesSelector||n.mozMatchesSelector||n.msMatchesSelector||n.oMatchesSelector||n.webkitMatchesSelector}t.exports=function(t,e){for(;t&&t.nodeType!==i;){if("function"==typeof t.matches&&t.matches(e))return t;t=t.parentNode}}}])},t.exports=n()}});
assets/dist/styles/attachment-edit.css ADDED
@@ -0,0 +1 @@
1
+ #watermarks table{margin-bottom:10px;text-align:left}#watermarks table td{padding:5px 10px}#watermarks table th{padding:5px 10px 5px 0}#watermarks .button-wrap{margin-bottom:10px}#watermarks .button-wrap:last-child{margin-bottom:0}#watermarks .button-wrap::after{clear:both;content:"";display:block}#watermarks .button-wrap button,#watermarks .button-wrap .spinner{float:left}#watermarks .error-message{display:none}
assets/dist/styles/dashboard.css ADDED
@@ -0,0 +1,2 @@
1
+ label.ew-switch{line-height:20px}label.ew-switch span.switch{background-color:#ccc;border-radius:7px;display:inline-block;height:14px;position:relative;transition:all 0.3s;vertical-align:sub;width:30px}label.ew-switch span.switch::before{background:#fff;border-radius:50%;box-shadow:0 0 4px rgba(0,0,0,0.3);content:"";display:block;height:18px;left:-2px;position:absolute;top:-2px;transition:all 0.3s;width:18px}label.ew-switch span.switch.left-aligned{margin-right:8px}label.ew-switch span.switch.right-aligned{margin-left:8px}label.ew-switch input{position:absolute;visibility:hidden}label.ew-switch input:checked+span.switch{background-color:#0073aa}label.ew-switch input:checked+span.switch::before{left:14px}.ew-field.layout-simple td{padding-left:0}.ew-grid{align-items:stretch;display:flex;flex-wrap:wrap;justify-content:flex-start;margin:0 -8px -8px;padding-top:2px}@media (max-width: 680px){.ew-grid{justify-content:center}}.ew-grid .item{flex:0 0 auto;margin:8px;max-width:480px;min-height:200px;width:calc(25% - 16px)}@media (max-width: 1500px){.ew-grid .item{width:calc(100% / 3 - 16px)}}@media (max-width: 1100px){.ew-grid .item{width:calc(50% - 18px)}}@media (max-width: 680px){.ew-grid .item{width:calc(100% - 16px)}}.watermarks .postbox{align-items:stretch;display:flex}.watermarks .postbox h3{margin-top:0}.watermarks .postbox a{text-decoration:none}.watermarks .inside{display:flex;flex-direction:column;justify-content:center;margin:0;padding:12px;width:100%}.watermarks .button-hero{align-self:center}.watermarks .watermark-preview{align-items:center;background-color:#c8c8c8;display:flex;flex:1 1 auto;justify-content:center;margin-bottom:20px;padding:20px;background-color:#ddd;background-image:linear-gradient(45deg, #bbb 25%, transparent 25%, transparent 75%, #bbb 75%, #bbb),linear-gradient(45deg, #bbb 25%, transparent 25%, transparent 75%, #bbb 75%, #bbb);background-position:0 0,10px 10px;background-size:20px 20px}.watermarks .watermark-preview img{height:auto;max-width:100%}.watermarks .row-actions{position:static}.tools .spinner{float:none;vertical-align:top}
2
+ @keyframes vex-fadein{0%{opacity:0}100%{opacity:1}}@keyframes vex-fadeout{0%{opacity:1}100%{opacity:0}}@keyframes vex-pulse{0%{box-shadow:inset 0 0 0 300px transparent}70%{box-shadow:inset 0 0 0 300px rgba(255,255,255,0.25)}100%{box-shadow:inset 0 0 0 300px transparent}}.wp-admin .vex{z-index:999999}.wp-admin .vex-overlay{z-index:999999}.vex.vex-theme-ew{align-items:center;display:flex;justify-content:center;padding:20px}.vex.vex-theme-ew .vex-content{animation:vex-fadein 0.5s;background:#fff;margin:0;max-width:100%;padding:12px;position:relative;width:450px}.vex.vex-theme-ew .vex-content h1,.vex.vex-theme-ew .vex-content h2,.vex.vex-theme-ew .vex-content h3,.vex.vex-theme-ew .vex-content h4,.vex.vex-theme-ew .vex-content h5,.vex.vex-theme-ew .vex-content h6,.vex.vex-theme-ew .vex-content p,.vex.vex-theme-ew .vex-content ul,.vex.vex-theme-ew .vex-content li{color:inherit}.vex.vex-theme-ew.vex-closing .vex-content{animation:vex-fadeout 0.5s forwards}.vex.vex-theme-ew .vex-close{border-radius:5px;cursor:pointer;position:absolute;right:0;top:0}.vex.vex-theme-ew .vex-close::before{background:transparent;border-radius:3px;color:#bbb;content:"\D7";font-size:26px;font-weight:400;height:30px;line-height:31px;position:absolute;right:3px;text-align:center;top:3px;width:30px}.vex.vex-theme-ew .vex-close:hover::before,.vex.vex-theme-ew .vex-close:active::before{background:#e0e0e0;color:#777}.vex.vex-theme-ew .vex-dialog-form .vex-dialog-message{margin-bottom:2em}.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input{margin-bottom:1em}.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input select,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input textarea,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="date"],.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="datetime"],.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="datetime-local"],.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="email"],.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="month"],.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="number"],.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="password"],.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="search"],.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="tel"],.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="text"],.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="time"],.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="url"],.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="week"]{background:#fff;border:0;border-radius:3px;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0 0 0.25em;min-height:2.5em;padding:0.25em 0.67em;width:100%}.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input select:focus,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input textarea:focus,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="date"]:focus,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="datetime"]:focus,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="datetime-local"]:focus,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="email"]:focus,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="month"]:focus,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="number"]:focus,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="password"]:focus,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="search"]:focus,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="tel"]:focus,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="text"]:focus,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="time"]:focus,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="url"]:focus,.vex.vex-theme-ew .vex-dialog-form .vex-dialog-input input[type="week"]:focus{box-shadow:inset 0 0 0 2px #8dbdf1;outline:none}.vex.vex-theme-ew .vex-dialog-form .vex-dialog-buttons{border-top:1px solid #eee;margin:0 -12px -12px;padding:12px;*zoom:1}.vex.vex-theme-ew .vex-dialog-form .vex-dialog-buttons:after{content:"";display:table;clear:both}.vex.vex-theme-ew .vex-dialog-button{float:right;margin:0 0 0 8px}.vex.vex-theme-ew .vex-dialog-button.vex-last{margin-left:0}.vex-loading-spinner.vex-theme-ew{background:#f0f0f0;border:0.2em solid transparent;border-radius:100%;border-top-color:#bbb;bottom:auto;box-shadow:0 0 0 0.5em #f0f0f0,0 0 1px 0.5em rgba(0,0,0,0.3);top:-1.1em}
assets/dist/styles/media-library.css ADDED
@@ -0,0 +1 @@
1
+ .spinner.ew-spinner{float:none;margin:0;visibility:visible}p.ew-status{display:inline-block;line-height:28px;margin:0 8px 0 0;vertical-align:middle}p.ew-status.hidden{display:none !important}.wp-list-table.media .media-icon{position:relative}.wp-list-table.media .media-icon .spinner{background-color:rgba(255,255,255,0.8);background-position:center;height:100%;left:0;margin:0;opacity:1;position:absolute;top:0;width:100%}.media-frame.mode-grid p.ew-status{margin:11px 8px 11px 0}.media-frame.mode-grid .media-toolbar select.watermark-selector{height:30px;margin:11px 10px 11px 0}.media-frame.mode-grid .media-toolbar .view-switch.disabled{position:relative}.media-frame.mode-grid .media-toolbar .view-switch.disabled::after{background-color:rgba(255,255,255,0.6);content:"";display:block;height:100%;left:0;position:absolute;top:0;width:100%;z-index:999}.media-frame.mode-grid .attachment.disabled{cursor:default;filter:grayscale(1)}.media-frame.mode-grid .attachment.disabled:focus{box-shadow:none;outline:none}.media-frame.mode-grid .attachment .badge,.media-frame.mode-grid .attachment .spinner{bottom:8px;left:8px;position:absolute;right:8px;top:8px}.media-frame.mode-grid .attachment .spinner{background-color:rgba(255,255,255,0.8);background-position:center;height:calc(100% - 16px);margin:0;opacity:1;width:calc(100% - 16px)}.media-frame.mode-grid .attachment .badge{align-items:center;background-color:rgba(222,222,222,0.6);color:#444;display:flex;font-size:16px;justify-content:center;padding:16px;text-shadow:0 0 5px #fff}
assets/dist/styles/uploader.css ADDED
@@ -0,0 +1 @@
1
+ label.ew-switch{line-height:20px}label.ew-switch span.switch{background-color:#ccc;border-radius:7px;display:inline-block;height:14px;position:relative;transition:all 0.3s;vertical-align:sub;width:30px}label.ew-switch span.switch::before{background:#fff;border-radius:50%;box-shadow:0 0 4px rgba(0,0,0,0.3);content:"";display:block;height:18px;left:-2px;position:absolute;top:-2px;transition:all 0.3s;width:18px}label.ew-switch span.switch.left-aligned{margin-right:8px}label.ew-switch span.switch.right-aligned{margin-left:8px}label.ew-switch input{position:absolute;visibility:hidden}label.ew-switch input:checked+span.switch{background-color:#0073aa}label.ew-switch input:checked+span.switch::before{left:14px}.ew-watermark-all-switch{margin-bottom:12px}
assets/dist/styles/watermark-edit.css ADDED
@@ -0,0 +1 @@
1
+ body.post-type-watermark .actions.bulkactions,body.settings_page_easy-watermark .actions.bulkactions{padding-right:0 !important}body.post-type-watermark .actions.bulkactions .button,body.settings_page_easy-watermark .actions.bulkactions .button{margin-right:16px !important}body.post-type-watermark .form-field,body.settings_page_easy-watermark .form-field{display:flex;justify-content:flex-start;margin-bottom:20px}body.post-type-watermark .form-field:last-child,body.settings_page_easy-watermark .form-field:last-child{margin-bottom:0}body.post-type-watermark .form-field input,body.settings_page_easy-watermark .form-field input{margin:0;position:relative}body.post-type-watermark .form-field input[type="number"],body.settings_page_easy-watermark .form-field input[type="number"]{width:70px}body.post-type-watermark .form-field input:focus,body.settings_page_easy-watermark .form-field input:focus{z-index:2}body.post-type-watermark .form-field-prepend,body.post-type-watermark .form-field-append,body.settings_page_easy-watermark .form-field-prepend,body.settings_page_easy-watermark .form-field-append{display:flex;position:relative}body.post-type-watermark .form-field-text,body.post-type-watermark .form-field button,body.settings_page_easy-watermark .form-field-text,body.settings_page_easy-watermark .form-field button{align-items:center;background-color:#eee;border:1px solid #ddd;border-radius:3px;display:flex;padding:0 5px;position:relative;z-index:1}body.post-type-watermark .form-field-prepend .form-field-text,body.post-type-watermark .form-field-prepend button,body.post-type-watermark .form-field-prepend .dropdown-menu,body.settings_page_easy-watermark .form-field-prepend .form-field-text,body.settings_page_easy-watermark .form-field-prepend button,body.settings_page_easy-watermark .form-field-prepend .dropdown-menu{border-bottom-right-radius:0;border-top-right-radius:0;margin-right:-1px}body.post-type-watermark .form-field-append .form-field-text,body.post-type-watermark .form-field-append button,body.post-type-watermark .form-field-append .dropdown-menu,body.settings_page_easy-watermark .form-field-append .form-field-text,body.settings_page_easy-watermark .form-field-append button,body.settings_page_easy-watermark .form-field-append .dropdown-menu{border-bottom-left-radius:0;border-top-left-radius:0;margin-left:-1px}body.post-type-watermark .form-field button:hover,body.settings_page_easy-watermark .form-field button:hover{background-color:#ddd;border:1px solid #aaa;cursor:pointer}body.post-type-watermark .form-field button[data-toggle="dropdown"]::after,body.settings_page_easy-watermark .form-field button[data-toggle="dropdown"]::after{border:4px solid transparent;border-top:4px solid #777;content:"";height:0;margin-bottom:-4px;margin-left:10px;width:0}body.post-type-watermark .form-field .dropdown-menu,body.settings_page_easy-watermark .form-field .dropdown-menu{background:#fff;border:1px solid #aaa;border-radius:3px;display:none;margin-top:3px;min-width:calc(100% - 2px);overflow:hidden;position:absolute;z-index:99}body.post-type-watermark .form-field .dropdown-menu .dropdown-item,body.settings_page_easy-watermark .form-field .dropdown-menu .dropdown-item{color:#333;display:block;padding:3px 6px;text-decoration:none}body.post-type-watermark .form-field .dropdown-menu .dropdown-item:hover,body.settings_page_easy-watermark .form-field .dropdown-menu .dropdown-item:hover{background-color:#eee}body.post-type-watermark #poststuff .watermark-type-selector h2{padding-left:0}body.post-type-watermark #poststuff .watermark-type-selector .buttons{display:flex}body.post-type-watermark #poststuff .watermark-type-selector .button.first{border-bottom-right-radius:0;border-top-right-radius:0}body.post-type-watermark #poststuff .watermark-type-selector .button.last{border-bottom-left-radius:0;border-top-left-radius:0}body.post-type-watermark #poststuff .watermark-type-selector input[type="radio"]{opacity:0;position:absolute;z-index:-1}body.post-type-watermark #poststuff .watermark-type-selector input[type="radio"]:checked+.button{background:#0085ba;border-color:#0073aa #006799 #006799;box-shadow:0 1px 0 #006799;color:#fff;text-decoration:none;text-shadow:0 -1px 1px #006799, 1px 0 1px #006799, 0 1px 1px #006799, -1px 0 1px #006799}body.post-type-watermark #poststuff .watermark-type-selector input[type="radio"]:checked+.button:active{transform:none}#watermark-content .image-content,#watermark-content .text-content,#watermark-content .select-image-button,#watermark-content .watermark-image{display:none}#watermark-content .watermark-image img{background-color:#ddd;cursor:pointer;height:auto;max-width:100%;width:auto}#watermark-content .text-content{overflow:hidden}#watermark-content .text-content input{width:100%}#watermark-content .text-preview{float:left;background-color:#ddd;background-image:linear-gradient(45deg, #999 25%, transparent 25%, transparent 75%, #999 75%, #999),linear-gradient(45deg, #999 25%, transparent 25%, transparent 75%, #999 75%, #999);background-position:0 0,6px 6px;background-size:12px 12px}#watermark-content .text-preview img{display:block;height:auto;max-width:100%}#alignment .alignment-selector{background-image:url(../images/alignment-background.jpg);background-size:cover;display:flex;flex-wrap:wrap;justify-content:space-between;width:240px}#alignment .alignment-selector label{background-repeat:no-repeat;display:block;float:left;height:58px;margin-bottom:3px;position:relative;text-align:center;width:78px}#alignment .alignment-selector label:nth-last-child(-n+6){margin-bottom:0}#alignment .alignment-selector label::after{background-color:rgba(255,255,255,0.2);bottom:0;content:"";left:0;position:absolute;right:0;top:0;transition:all 0.2s}#alignment .alignment-selector label:hover::after{background-color:rgba(255,255,255,0.35)}#alignment .alignment-selector input{opacity:0;position:absolute;z-index:-1}#alignment .alignment-selector input:checked+label::after{background-color:transparent}#watermarks table{margin-bottom:10px;text-align:left}#watermarks table td{padding:5px 10px}#watermarks table th{padding:5px 10px 5px 0}#watermarks .button-wrap{margin-bottom:10px}#watermarks .button-wrap:last-child{margin-bottom:0}#watermarks .button-wrap::after{clear:both;content:"";display:block}#watermarks .button-wrap button,#watermarks .button-wrap .spinner{float:left}#watermarks .error-message{display:none}.ew-preview-popup{display:none}.ew-preview-popup .media-frame-content{bottom:0;padding:16px;top:50px}.ew-preview-popup .media-frame-content img{display:block;height:auto;margin-bottom:16px;max-width:100%}#preview img{cursor:pointer;height:auto;max-width:100%}#preview .spinner{display:none;float:none;margin:10px 0 0;visibility:visible}#placeholders li{margin-bottom:20px}#placeholders li>label{display:block;font-weight:700;margin-bottom:5px;width:calc(100% - 30px)}#placeholders code{cursor:pointer;width:calc(100% - 30px)}#placeholders .ew-search-placeholders{margin:13px 0 7px}#placeholders .help{float:right;position:relative;top:10px}#placeholders .help .question-mark{background-color:#888;border-radius:50%;color:#fff;cursor:pointer;display:block;height:20px;line-height:20px;text-align:center;width:20px}#placeholders .help .description{background-color:#fff;border:1px solid #eee;box-shadow:0 0 8px rgba(0,0,0,0.3);display:none;font-size:12px;min-width:200px;opacity:0;position:absolute;right:0;top:32px;transition:opacity 0.2s;z-index:1}#placeholders .help .description::before,#placeholders .help .description::after{border-color:rgba(229,229,229,0);border-style:solid;bottom:100%;content:"";height:0;pointer-events:none;position:absolute;right:0;width:0;z-index:18}#placeholders .help .description::before{border-bottom-color:#eee;border-width:11px;margin-left:-11px}#placeholders .help .description::after{border-bottom-color:#fff;border-width:9px;margin-left:-9px;margin-right:2px}#placeholders .help .description label{display:block;font-weight:700}#placeholders .help .description span,#placeholders .help .description i{display:block}#placeholders .help .description-content{padding:10px}#placeholders .help:hover .description{display:block;opacity:1}
classes/class-ew-pluggable.php DELETED
@@ -1,48 +0,0 @@
1
- <?php
2
- /**
3
- * @copyright: Wojtek Szałkiewicz
4
- * @license: GPLv2 or later
5
- *
6
- * This class is a base class for wordpress plugins.
7
- * It's a part of package in which you found it.
8
- * See readme.txt for more information.
9
- */
10
-
11
- class EW_Pluggable
12
- {
13
- /**
14
- * Adds wordpress action
15
- *
16
- * @chainable
17
- * @param string action name
18
- * @param string function name
19
- * @param integer priority
20
- * @param integer accepted arguments
21
- * @return object
22
- */
23
- protected function add_action($actionName, $funcName = null, $priority = 10, $accepted_args = 1){
24
- add_action($actionName,
25
- array($this, (!empty($funcName) ? $funcName : $actionName)),
26
- $priority, $accepted_args);
27
-
28
- return $this;
29
- }
30
-
31
- /**
32
- * Adds wordpress filter
33
- *
34
- * @chainable
35
- * @param string filter name
36
- * @param string function name
37
- * @param integer priority
38
- * @param integer accepted arguments
39
- * @return object
40
- */
41
- protected function add_filter($filterName, $funcName = null, $priority = 10, $accepted_args = 1){
42
- add_filter($filterName,
43
- array($this, (!empty($funcName) ? $funcName : $filterName)),
44
- $priority, $accepted_args);
45
-
46
- return $this;
47
- }
48
- }
classes/class-ew-plugin-core.php DELETED
@@ -1,114 +0,0 @@
1
- <?php
2
- /**
3
- * @copyright: Wojtek Szałkiewicz
4
- * @license: GPLv2 or later
5
- *
6
- * This class is a base class for wordpress plugins.
7
- * It's a part of package in which you found it.
8
- * See readme.txt for more information.
9
- */
10
-
11
- class EW_Plugin_Core extends EW_Pluggable
12
- {
13
- /**
14
- * @var string plugin name
15
- */
16
- protected static $pluginName = 'Easy Watermark';
17
-
18
- /**
19
- * @var string plugin slug used in setting names etc.
20
- */
21
- protected static $pluginSlug = 'easy-watermark';
22
-
23
- /**
24
- * @var string plugin version
25
- */
26
- protected static $version = '0.7.1';
27
-
28
- /**
29
- * @var string plugin class name
30
- */
31
- protected static $className = 'EW_Plugin';
32
-
33
- /**
34
- * @var string main plugin file
35
- */
36
- protected static $mainFile = 'index.php';
37
-
38
- /**
39
- * Initiates plugin by creating an object of inheriting class,
40
- * registers activation and uninstall hooks,
41
- * checks version and executes upgrade function if needed.
42
- *
43
- * @return object
44
- */
45
- public static function init(){
46
- // Register install and uninstall methods
47
- register_activation_hook(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . self::$mainFile, array(self::$className, 'install'));
48
- register_uninstall_hook(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . self::$mainFile, array(self::$className, 'uninstall'));
49
-
50
- $version = get_option(self::$pluginSlug . '-version');
51
- if(!empty($version) & version_compare($version, self::$version, '<')){
52
- // Version from database is lower than current, upgrade...
53
- self::upgrade($version);
54
- }
55
-
56
- // Load plugin textdomain
57
- load_plugin_textdomain(self::$pluginSlug, false, '/'.self::$pluginSlug.'/languages');
58
-
59
- // Create object of plugin class (inheritign this one)
60
- $className = self::$className;
61
- return new $className();
62
- }
63
-
64
- /**
65
- * Returns plugin name
66
- *
67
- * @return string
68
- */
69
- public static function getName(){
70
- return self::$pluginName;
71
- }
72
-
73
- /**
74
- * Returns plugin slug
75
- *
76
- * @return string
77
- */
78
- public static function getSlug(){
79
- return self::$pluginSlug;
80
- }
81
-
82
-
83
- /**
84
- * Returns plugin version
85
- *
86
- * @return string
87
- */
88
- public static function getVersion(){
89
- return self::$version;
90
- }
91
-
92
- /**
93
- * Method run when activating plugin
94
- *
95
- * @return void
96
- */
97
- public static function install(){}
98
-
99
- /**
100
- * Method run when removing plugin
101
- *
102
- * @return void
103
- */
104
- public static function uninstall(){}
105
-
106
- /**
107
- * Method run when plugin version stored in WP options
108
- * is lower than current version.
109
- *
110
- * @param string previously installed version
111
- * @return void
112
- */
113
- protected static function upgrade($version){}
114
- }
classes/class-ew-plugin.php DELETED
@@ -1,1357 +0,0 @@
1
- <?php
2
- /**
3
- * This file is a part of Easy Watermark Wordpress plugin.
4
- * @see readme.txt
5
- */
6
-
7
- /**
8
- * Main plugin class
9
- */
10
- class EW_Plugin extends EW_Plugin_Core
11
- {
12
- /**
13
- * @var boolean
14
- */
15
- private static $GDEnabled;
16
-
17
- /**
18
- * @var boolean
19
- */
20
- private static $FreeTypeEnabled;
21
-
22
- /**
23
- * @var array
24
- */
25
- private $settings;
26
-
27
- /**
28
- * @var boolean
29
- */
30
- private $error = false;
31
-
32
- /**
33
- * @var array
34
- */
35
- private $allowedMime = array('image/png', 'image/jpeg', 'image/gif');
36
-
37
- /**
38
- * @var array
39
- */
40
- private $defaultPostTypes = array('post', 'page', 'unattached');
41
-
42
- /**
43
- * @var array
44
- */
45
- private $notices = array();
46
-
47
- /**
48
- * @var object post object for an image
49
- */
50
- private $currentImage;
51
-
52
- /**
53
- * @var array messages for different error codes from EasyWatermark class
54
- */
55
- private $ewErrors = array();
56
-
57
- /**
58
- * @var boolean
59
- */
60
- private $isBulkAction = false;
61
-
62
- /**
63
- * @var boolean flag to turn off auto watermark function when restoring files
64
- */
65
- private $restoring = false;
66
-
67
- /**
68
- * Loads textdomain for translations,
69
- * adds wordpress actions
70
- *
71
- * @return void
72
- */
73
- public function __construct(){
74
-
75
- $this->add_action('init', 'plugin_init')
76
- // This hook was used before version 0.5.1 but it is not called by some plugins (e.g. buddypress-media)
77
- // ->add_action('add_attachment', 'add_watermark_after_upload')
78
- // now the proper filter is attached direclty as it is called only when new image is uploaded (see add_watermark_after_upload)
79
- ->add_filter('wp_generate_attachment_metadata', null, 10, 2);
80
-
81
- // load admin interface
82
- if(is_admin()){
83
- $this->add_action('admin_menu', 'add_media_page')
84
- ->add_action('admin_init')
85
- ->add_filter('media_row_actions', 'add_media_row_action', 10, 3)
86
- // ->add_filter('attachment_fields_to_edit', 'add_attachment_field', 10, 2)
87
- ->add_action('admin_notices')
88
- ->add_action('admin_head-upload.php', 'add_bulk_action_script')
89
- ->add_action('admin_action_ew_add_watermark', 'bulk_action_handler')
90
- ->add_action('admin_print_scripts', 'easy_watermark_style')
91
- ->add_action('manage_media_columns', 'add_media_column')
92
- ->add_action('manage_media_custom_column', null, 10, 2)
93
- ->add_action('add_meta_boxes')
94
- ->add_action('delete_attachment', 'clean_backup')
95
- ->add_action('wp_ajax_watermark_all')
96
- ->add_action('wp_ajax_restore_all');
97
- }
98
-
99
- $this->test_GD();
100
-
101
- $this->ewErrors = array(
102
- EasyWatermark::ERROR_SAME_IMAGE_PATHS => __('Same image and watermark paths.', 'easy-watermark'),
103
- EasyWatermark::ERROR_NO_WATERMARK_SET => __('No watermark image or text specified.', 'easy-watermark'),
104
- EasyWatermark::ERROR_NO_INPUT_IMAGE => __('No input image specified.', 'easy-watermark'),
105
- EasyWatermark::ERROR_NOT_ALLOWED_TYPE => __('Not allowed image type.', 'easy-watermark'),
106
- EasyWatermark::ERROR_NO_OUTPUT_FILE_SET => __('No output file specified.', 'easy-watermark'),
107
- EasyWatermark::ERROR_NOT_ALLOWED_OUTPUT_TYPE => __('Not allowed output type.', 'easy-watermark'),
108
- EasyWatermark::ERROR_UNKNOWN => __('Could not apply watermark.', 'easy-watermark')
109
- );
110
-
111
- // Init Freemius.
112
- ew_fs();
113
-
114
- // Signal that SDK was initiated.
115
- do_action('ew_fs_loaded');
116
- }
117
-
118
- /**
119
- * Tests whether the GD library is installed and enabled
120
- *
121
- * @return void
122
- */
123
- private function test_GD(){
124
- if(extension_loaded('gd') && function_exists('gd_info')){
125
- self::$GDEnabled = true;
126
- $gdinfo = gd_info();
127
- self::$FreeTypeEnabled = $gdinfo['FreeType Support'];
128
- }
129
- else {
130
- self::$GDEnabled = false;
131
- }
132
- }
133
-
134
- /**
135
- * Tells whether the GD library is working
136
- *
137
- * @return boolean
138
- */
139
- public static function isGDEnabled(){
140
- return self::$GDEnabled;
141
- }
142
-
143
- /**
144
- * Tells whether the FreeType library is working
145
- *
146
- * @return boolean
147
- */
148
- public static function isFreeTypeEnabled(){
149
- return self::$FreeTypeEnabled;
150
- }
151
-
152
- /**
153
- * Performs some actions which need to be done before anything else
154
- *
155
- * @return void
156
- */
157
- public function plugin_init(){
158
- new EW_Settings($this);
159
- }
160
-
161
- public function admin_init(){
162
- if(isset($_GET['page'])){
163
- if($_GET['page'] == 'easy-watermark-settings' && isset($_GET['tp']) && $_GET['tp'] == 1){
164
- $this->print_text_preview();
165
- }
166
- elseif($_GET['page'] == 'easy-watermark' && isset($_GET['_wpnonce'])){
167
- if(wp_verify_nonce($_GET['_wpnonce'], 'ew_add_watermark'))
168
- $this->add_watermark();
169
- if(wp_verify_nonce($_GET['_wpnonce'], 'ew_mark'))
170
- $this->mark_image();
171
- if(wp_verify_nonce($_GET['_wpnonce'], 'ew_restore'))
172
- $this->restore_single();
173
- }
174
- }
175
- }
176
-
177
- /**
178
- * Returns generated jpeg image with text preview to the browser.
179
- * Used on settings page
180
- *
181
- * @return void
182
- */
183
- private function print_text_preview(){
184
- if($this->isGDEnabled()) :
185
-
186
- $ew = $this->getEasyWatermark();
187
- if($this->settings['general']['watermark_type'] == '1'){
188
- $settings = $this->getTextSettings();
189
-
190
- $fontFile = EWBASE . EWDS . 'fonts' . EWDS . $settings['font'];
191
- if(file_exists($fontFile))
192
- $settings['font'] = $fontFile;
193
-
194
- $ew->textSet($settings);
195
- }
196
-
197
- if(isset($_GET['text'])){
198
- $text = $this->parseText($_GET['text']);
199
- $ew->textSet('text', $text);
200
- }
201
- if(isset($_GET['size']))
202
- $ew->textSet('size', $_GET['size']);
203
- if(isset($_GET['angle']))
204
- $ew->textSet('angle', $_GET['angle']);
205
- if(isset($_GET['color']))
206
- $ew->textSet('color', $_GET['color']);
207
- if(isset($_GET['opacity']))
208
- $ew->textSet('opacity', $_GET['opacity']);
209
-
210
- if(isset($_GET['font'])){
211
- $fontFile = EWBASE . EWDS . 'fonts' . EWDS . $_GET['font'];
212
- if(file_exists($fontFile))
213
- $ew->textSet('font', $fontFile);
214
- }
215
-
216
- $ew->printTextPreview();
217
-
218
- endif;
219
-
220
- exit;
221
- }
222
-
223
- /**
224
- * Performs watermarking the single attachment
225
- *
226
- * @return void
227
- */
228
- private function add_watermark(){
229
- if(isset($_GET['attachment_id']) && $this->isGDEnabled()){
230
- $post = get_post((int) $_GET['attachment_id']);
231
- $roles = $this->getAllowedRoles();
232
-
233
- if(!$this->checkRolePermission() || !(current_user_can('edit_others_posts') || $post->post_author == wp_get_current_user()->ID))
234
- // User doesn't have a premission to add watermark, he was not able to click the link!
235
- wp_die( __( 'Cheatin&#8217; uh?' ) );
236
-
237
- $url = false;
238
- if($this->watermark_attachment($post)){
239
- switch($_GET['r']){
240
- case 'library':
241
- $url = admin_url('upload.php?watermarked=1');
242
- break;
243
- case 'post':
244
- $url = admin_url('post.php?post='.$_GET['attachment_id'].'&action=edit&watermarked=1');
245
- break;
246
- }
247
- }
248
- else {
249
- switch($_GET['r']){
250
- case 'library':
251
- $url = admin_url('upload.php?ew_error='.$this->error);
252
- break;
253
- case 'post':
254
- $url = admin_url('post.php?post='.$_GET['attachment_id'].'&action=edit&ew_error='.$this->error);
255
- break;
256
- }
257
- }
258
- if($url){
259
- wp_redirect($url);
260
- exit;
261
- }
262
- }
263
- }
264
-
265
- /**
266
- * Prints admin notices
267
- *
268
- * @return void
269
- */
270
- public function admin_notices(){
271
- if(isset($_GET['watermarked']) && $_GET['watermarked'] == '1'){
272
- echo '<div class="updated"><p>'.__('Watermark successfully added.', 'easy-watermark').'</p></div>';
273
- }
274
- elseif(isset($_GET['marked'])){
275
- $marked = $_GET['marked'] == 1 ? __('watermarked', 'easy-watermark') : __('not watermarked', 'easy-watermark');
276
- echo '<div class="updated"><p>'.sprintf(__('An Image has been marked as %s.', 'easy-watermark'), $marked).'</p></div>';
277
- }
278
- elseif(isset($_GET['ew_error'])){
279
- echo '<div class="error"><p>';
280
- switch($_GET['ew_error']):
281
- case '1':
282
- _e('Invalid mime type.', 'easy-watermark');
283
- break;
284
- case '2':
285
- _e('No watermark image selected and no watermark text set.', 'easy-watermark');
286
- echo ' <a href="'.admin_url('options-general.php?page=easy-watermark-settings').'">';
287
- _e('Go to settings page', 'easy-watermark');
288
- echo '</a>';
289
- break;
290
- default:
291
- _e('An error has occurred.', 'easy-watermark');
292
- endswitch;
293
- echo '</p></div>';
294
- }
295
-
296
- if(!self::isGDEnabled() && get_current_screen()->id == 'plugins'){
297
- echo '<div class="error"><p>'.__('Easy Watermark is active, but requires GD library to work. Please enable this extension.', 'easy-watermark').' <a href="http://www.php.net/manual/en/image.setup.php" target="_blank">'.__('Read more', 'easy-watermark').'</p></div>';
298
- }
299
-
300
- foreach($this->notices as $msg){
301
- echo '<div class="' . $msg[0] . '"><p>' . $msg[1] . '</p></div>';
302
- }
303
- }
304
-
305
- /**
306
- * Adds wordpress media page
307
- *
308
- * @return void
309
- */
310
- public function add_media_page(){
311
- $roles = $this->settings['general']['allowed_roles'];
312
-
313
- if($this->isGDEnabled() && $this->checkRolePermission())
314
- add_media_page( 'Easy Watermark', 'Easy Watermark', 'upload_files', 'easy-watermark', array($this, 'easy_watermark'));
315
- }
316
-
317
- /**
318
- * Adds javascript code providing 'Add Watermark' bulk action on media page
319
- *
320
- * @return void
321
- */
322
- function add_bulk_action_script() {
323
- $roles = $this->settings['general']['allowed_roles'];
324
- if($this->isGDEnabled() && $this->checkRolePermission()){
325
- $text = __('Add Watermark', 'easy-watermark');
326
- echo <<<EOD
327
- <script type="text/javascript">
328
- jQuery(document).ready(function() {
329
- jQuery('<option>').val('ew_add_watermark').text('$text').appendTo("select[name='action']");
330
- jQuery('<option>').val('ew_add_watermark').text('$text').appendTo("select[name='action2']");
331
- });
332
- </script>
333
- EOD;
334
- }
335
- }
336
-
337
- /**
338
- * Creates 'Add watermark' link for each row in media library
339
- *
340
- * @return array
341
- */
342
- public function add_media_row_action($actions, $post, $detached){
343
- $roles = $this->settings['general']['allowed_roles'];
344
- if($this->isGDEnabled() && $this->checkRolePermission()
345
- && in_array($post->post_mime_type, $this->allowedMime)
346
- && get_attached_file($post->ID) != $this->settings['image']['watermark_path']
347
- && (current_user_can('edit_others_posts') || $post->post_author == wp_get_current_user()->ID)){
348
-
349
-
350
-
351
- // Add link if it's supported image type
352
- $actions['add_watermark'] = '<a href="' . wp_nonce_url(admin_url('upload.php?page=easy-watermark&attachment_id='.$post->ID.'&r=library'), 'ew_add_watermark') . '">'.__('Add Watermark', 'easy-watermark').'</a>';
353
- }
354
-
355
- return $actions;
356
- }
357
-
358
- /**
359
- * Creates 'Add watermark' button in media edit view
360
- *
361
- * @return array
362
- */
363
- public function add_attachment_field($form_fields, $post){
364
- if($this->isGDEnabled() && in_array($post->post_mime_type, $this->allowedMime) && $post->ID != $this->settings['image']['watermark_id']){
365
- // Add link if it's supported image type
366
- $form_fields = array_reverse($form_fields);
367
- $form_fields['easy-watermark'] = array(
368
- 'label' => '<a href="'.wp_nonce_url(admin_url('upload.php?page=easy-watermark&attachment_id='.$post->ID.'&r=post'), 'ew_add_watermark').'" class="button-secondary">'.__('Add watermark', 'easy-watermark').'</a>',
369
- 'input' => 'html',
370
- 'html' => ' '
371
- );
372
- }
373
-
374
- return array_reverse($form_fields);
375
- }
376
-
377
- /**
378
- * Handles the ew_add_watermark bulk action
379
- * Performs watermarking selected images
380
- *
381
- * @uses self::watermark_single
382
- * @return void
383
- */
384
- public function bulk_action_handler(){
385
-
386
- if(empty($_REQUEST['action']) || ($_REQUEST['action'] != 'ew_add_watermark' && $_REQUEST['action2'] != 'ew_add_watermark')){
387
- return;
388
- }
389
-
390
- if(empty($_REQUEST['media']) || !is_array($_REQUEST['media'])){
391
- return;
392
- }
393
-
394
- check_admin_referer('bulk-media');
395
- $result = true;
396
- $this->isBulkAction = true;
397
- foreach($_REQUEST['media'] as $entry){
398
- if(!$this->watermark_attachment((int) $entry) && $this->error != 99)
399
- $result = false;
400
- }
401
-
402
- if(isset($_GET['_wp_http_referer'])){
403
- $referer = $_GET['_wp_http_referer'];
404
-
405
- $args = $result ? array('watermarked' => '1') : array('ew_error' => $this->error);
406
- $referer = add_query_arg($args, remove_query_arg(array('ew_error', 'watermarked'), $referer));
407
-
408
- wp_redirect($referer);
409
- exit;
410
- }
411
- }
412
-
413
- /**
414
- * Watermark image after it was uploaded.
415
- * In fact this method only marks that there is an image to watermark,
416
- * it's realy watermarked in wp_generate_attachment_metadata filter.
417
- * See wp_generate_attachment_metadata() method below.
418
- *
419
- * This function is deprecated since 0.5.1, it is not needed since the
420
- * 'wp_generate_attachment_metadata' filter is called only for newly uploaded files.
421
- * Some plugins (e.g. buddypress-media) calls this filter, but not the 'add_attachment' action
422
- * so existance of this function caused problems.
423
- *
424
- * @deprecated
425
- * @return array
426
- */
427
- public function add_watermark_after_upload($id){
428
- if($this->isGDEnabled() && $this->settings['general']['auto_add']){
429
- $this->watermark_uploaded = true;
430
- $this->uploaded_id = $id;
431
- $this->add_filter('wp_generate_attachment_metadata', null, 10, 2);
432
- }
433
- }
434
-
435
- /**
436
- * Filter used to add watermark (it is called after image resizing)
437
- *
438
- * @param array
439
- * @param integer
440
- * @return array
441
- */
442
- public function wp_generate_attachment_metadata($metadata, $id){
443
- if($this->settings['general']['auto_add'] && !$this->restoring
444
- && ($this->settings['general']['auto_add_perm'] == '1' || $this->checkRolePermission())
445
- && $this->checkPostType()){
446
-
447
- $this->watermark_attachment($id, true, $metadata);
448
-
449
- $this->watermark_uploaded = false;
450
- $this->uploaded_id = null;
451
- }
452
-
453
- return $metadata;
454
- }
455
-
456
- /**
457
- * Performs the action of a single attachment watermarking
458
- *
459
- * @uses self::create_watermark
460
- * @param integer image id
461
- * @param boolean whether to check mime if it's selected to auto watermarking
462
- * @param array image meta
463
- * @return boolean
464
- */
465
- private function watermark_attachment($post, $checkMime = false, $meta = array()){
466
- if($this->isGDEnabled()) :
467
- if($this->settings['image']['watermark_path'] != '' || $this->settings['text']['text'] != null){
468
- if(is_numeric($post))
469
- $post = get_post($post);
470
- $filepath = get_attached_file($post->ID);
471
- if(!in_array($post->post_mime_type, $this->allowedMime)){
472
- $this->error = 1;
473
- return false;
474
- }
475
- if($checkMime && !in_array($post->post_mime_type, $this->settings['general']['image_types'])){
476
- return false;
477
- }
478
-
479
- return $this->create_watermark($post, $meta);
480
- }
481
- else {
482
- $this->error = 2;
483
- return false;
484
- }
485
-
486
- endif;
487
- }
488
-
489
- public function wp_ajax_watermark_all(){
490
- check_ajax_referer('watermark_all_confirmed', '_ewnonce');
491
-
492
- $msg = $this->watermark_all();
493
-
494
- $output = array(
495
- 'progress' => get_option('ew-bulk-counter'),
496
- 'message' => $msg
497
- );
498
-
499
- echo json_encode($output);
500
-
501
- exit;
502
- }
503
-
504
- /**
505
- * Performs the action of watermarking all images from library
506
- *
507
- * @uses self::create_watermark
508
- * @return boolean
509
- */
510
- private function watermark_all(){
511
- if($this->isGDEnabled()) :
512
-
513
- $page = get_option('ew-bulk-page', 0);
514
- $count = get_option('ew-bulk-counter', 0);
515
- $total = get_option('ew-bulk-total', 0);
516
-
517
- $limit = 10;
518
- $offset = $page * $limit;
519
-
520
- global $wpdb;
521
-
522
- $images = $wpdb->get_results($wpdb->prepare("
523
- SELECT ID, post_mime_type, post_author, post_title
524
- FROM {$wpdb->posts}
525
- WHERE post_type = 'attachment'
526
- AND post_mime_type LIKE %s
527
- ORDER BY ID ASC LIMIT %d OFFSET %d",
528
-
529
- 'image/%', $limit, $offset
530
- ));
531
-
532
- $output = '';
533
- $skipped = 0;
534
- if($images && ($this->settings['image']['watermark_path'] != '' || $this->settings['text']['text'])){
535
- $this->isBulkAction = true;
536
-
537
- foreach($images as $img){
538
- $this->currentImage = $img;
539
-
540
- $filepath = get_attached_file($img->ID);
541
- if(!current_user_can('edit_others_posts') && wp_get_current_user()->ID != $img->post_author){
542
- // No permission to edit this image
543
- $output .= sprintf(__('No permission to edit file %s. Skipping...', 'easy-watermark'), '<strong>'.$filepath.'</strong>').'<br/>';
544
- $skipped++;
545
- continue;
546
- }
547
- if(!in_array($img->post_mime_type, $this->allowedMime)){
548
- $output .= sprintf(__('Not supported mime type of %s. Skipping...', 'easy-watermark'), '<strong>'.$filepath.'</strong>').'<br/>';
549
- $skipped++;
550
- continue;
551
- }
552
-
553
- if($this->create_watermark($img)){
554
- $output .= sprintf(__('Watermark successfully added to %s', 'easy-watermark'), '<strong>'.$filepath.'</strong>') . '<br/>';
555
- }
556
- }
557
- }
558
- else return false;
559
-
560
- $output = '<p>'.$output.'</p>';
561
-
562
- $count += $limit;
563
- if($count > $total) $count = $total;
564
-
565
- update_option('ew-bulk-page', $page + 1);
566
- update_option('ew-bulk-counter', $count);
567
-
568
- return $output;
569
-
570
- endif;
571
- }
572
-
573
- /**
574
- * Applies the watermark to the defined image sizes
575
- *
576
- * @use self::watermark_single_image()
577
- * @param object wp post
578
- * @return boolean
579
- */
580
- public function create_watermark($post, $meta = array()){
581
-
582
- if(empty($meta)){
583
- $meta = get_post_meta($post->ID, '_wp_attachment_metadata', true);
584
- }
585
-
586
- $filepath = get_attached_file($post->ID);
587
- $filebasename = wp_basename($meta['file']);
588
-
589
- if($this->settings['image']['watermark_path'] != $filepath){
590
-
591
- $this->currentImage = $post;
592
-
593
- if($this->settings['general']['backup']){
594
- $backup_file = $this->backup_attachment($filepath, $filebasename);
595
- if(is_string($backup_file)){
596
- update_post_meta($post->ID, '_ew_backup_file', $backup_file);
597
- }
598
- }
599
-
600
- if($this->isBulkAction){
601
- // Refresh watermark text for each image
602
- $this->getEasyWatermark()->setText($this->parseText($this->settings['text']['text']));
603
- }
604
-
605
- $sizes = $meta['sizes'];
606
- $sizes['full'] = array(
607
- 'file' => $meta['file'],
608
- 'mime-type' => $post->post_mime_type
609
- );
610
-
611
- $allowedSizes = $this->settings['general']['image_sizes'];
612
-
613
- $return = true;
614
- foreach($sizes as $size => $img){
615
- if(in_array($size, $allowedSizes)){
616
- $imgFile = str_replace($filebasename, wp_basename($img['file']), $filepath);
617
- if(!$this->watermark_single_image($imgFile, $img['mime-type']))
618
- $return = false;
619
- }
620
- }
621
-
622
- if($return){
623
- // mark attachment as watermarked
624
- update_post_meta($post->ID, '_ew_watermarked', '1');
625
- }
626
-
627
- return $return;
628
- }
629
-
630
- $this->error = 99;
631
-
632
- return false;
633
- }
634
-
635
- /**
636
- * Saves copy of the original image to allow to restore it
637
- *
638
- * @param string file path
639
- * @return void
640
- */
641
- private function backup_attachment($filepath, $filename){
642
- $upload_dir = wp_upload_dir();
643
- $uploads = $upload_dir['basedir'];
644
-
645
- $subdir = str_replace(array($uploads, $filename), '', $filepath);
646
-
647
- $backup_dir = WP_CONTENT_DIR . EWDS . 'ew_backup' . $subdir;
648
- $new_file = $backup_dir . $filename;
649
-
650
- if(!file_exists($new_file)){
651
-
652
- if(!is_dir($backup_dir)){
653
- mkdir($backup_dir, 0755, true);
654
- }
655
-
656
- $result = copy($filepath, $new_file);
657
-
658
- if($result){
659
- return $new_file;
660
- }
661
-
662
- return false;
663
- }
664
-
665
- return true;
666
- }
667
-
668
- public function clean_backup($post_id){
669
- $file = get_post_meta($post_id, '_ew_backup_file', true);
670
-
671
- if(file_exists($file)){
672
- unlink($file);
673
- }
674
- }
675
-
676
- /**
677
- * Applies the watermark to the given image file
678
- *
679
- * @param string path to image file
680
- * @param string image mime type
681
- * @return boolean
682
- */
683
- private function watermark_single_image($imageFile, $imageType){
684
- if($this->isGDEnabled()){
685
-
686
- $ew = $this->getEasyWatermark();
687
- $ew->setImagePath($imageFile)
688
- ->setImageMime($imageType)
689
- ->setOutputFile($imageFile)
690
- ->setOutputMime($imageType);
691
-
692
- if(!$ew->create() || !$ew->saveOutput()){
693
- $error = $this->ewErrors[$ew->getError()];
694
- if($this->isBulkAction){
695
- $error = sprintf(__("Error: '%s', file: %s", 'easy-watermark'), $error, $imageFile);
696
- }
697
- $this->add_error($error);
698
- return false;
699
- }
700
-
701
- $ew->clean();
702
- return true;
703
- }
704
-
705
- return false;
706
- }
707
-
708
- /**
709
- * @var object stores EasyWatermark object
710
- */
711
- private $ew;
712
-
713
- /**
714
- * Returns configured EasyWatermark object
715
- *
716
- * @return object
717
- */
718
- public function getEasyWatermark(){
719
- if(!($this->ew instanceof EasyWatermark) && $this->isGDEnabled()){
720
- $imageSettings = $this->settings['image'];
721
- $textSettings = $this->getTextSettings();
722
- $this->ew = new EasyWatermark();
723
- $this->ew->setJpegQuality($this->settings['general']['jpg_quality']);
724
-
725
- $fontFile = EWBASE . EWDS . 'fonts' . EWDS . $textSettings['font'];
726
- if(file_exists($fontFile))
727
- $textSettings['font'] = $fontFile;
728
-
729
- $wType = $this->settings['general']['watermark_type'];
730
- if(!self::isFreeTypeEnabled()) {
731
- if($wType == 3) $wType = 1;
732
- elseif($wType == 2) $wType = 0;
733
- }
734
- if($wType == 1 || $wType == 3)
735
- $this->ew->imageSet($imageSettings);
736
- if($wType == 2 || $wType == 3)
737
- $this->ew->textSet($textSettings);
738
- }
739
-
740
- return $this->ew;
741
- }
742
-
743
- /**
744
- * Prints Easy Watermark page
745
- *
746
- * @return void
747
- */
748
- public function easy_watermark(){
749
- if(isset($_GET['_wpnonce'])){
750
- global $wpdb, $wp_scripts;
751
-
752
- wp_enqueue_style('ew-tools', plugins_url() . '/easy-watermark/css/tools.css');
753
- wp_register_script('ewajax', plugin_dir_url(EWBASE . '/index.php') . 'js/ewajax.js', array('jquery', 'jquery-ui-progressbar'));
754
-
755
- wp_enqueue_style('jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/' . $wp_scripts->registered['jquery-ui-core']->ver . '/themes/smoothness/jquery-ui.css');
756
-
757
- update_option('ew-bulk-page', 0);
758
- update_option('ew-bulk-counter', 0);
759
-
760
- if(isset($_GET['watermark_all']) && wp_verify_nonce($_GET['_wpnonce'], 'watermark_all')){
761
- $count = $wpdb->get_var("SELECT count(*) FROM $wpdb->posts
762
- WHERE post_type = 'attachment'
763
- AND post_mime_type LIKE 'image/%'");
764
-
765
- wp_localize_script('ewajax', 'ewData', array(
766
- 'nonce' => wp_create_nonce('watermark_all_confirmed'),
767
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
768
- 'total_items' => $count,
769
- 'complete' => __('Complete!', 'easy-watermark')
770
- ));
771
-
772
- wp_enqueue_script('watermark-all', plugin_dir_url(EWBASE . '/index.php') . 'js/watermark-all.js', array('ewajax'));
773
-
774
- update_option('ew-bulk-total', $count);
775
-
776
- $current_tool = 'watermark_all';
777
- }
778
- elseif(isset($_GET['restore_all']) && wp_verify_nonce($_GET['_wpnonce'], 'restore_all')){
779
- $count = $wpdb->get_var("SELECT count(*) FROM $wpdb->postmeta
780
- WHERE meta_key = '_ew_backup_file'");
781
-
782
- wp_localize_script('ewajax', 'ewData', array(
783
- 'nonce' => wp_create_nonce('restore_all_confirmed'),
784
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
785
- 'total_items' => $count,
786
- 'complete' => __('Complete!', 'easy-watermark')
787
- ));
788
-
789
- wp_enqueue_script('restore-all', plugin_dir_url(EWBASE . '/index.php') . 'js/restore-all.js', array('ewajax'));
790
-
791
- update_option('ew-bulk-total', $count);
792
-
793
- $current_tool = 'restore_all';
794
- }
795
- }
796
-
797
- include EWVIEWS . EWDS . 'easy-watermark-page.php';
798
- }
799
-
800
- /**
801
- * Prints style for admin page
802
- *
803
- * @return void
804
- */
805
- public function easy_watermark_style(){
806
- if(get_current_screen()->id == 'media_page_easy-watermark') {
807
- echo '<style type="text/css" media="screen">
808
- #icon-easy-watermark {background: url('.plugins_url().'/'.self::$pluginSlug.'/images/icon-32.png) no-repeat 2px 0;}
809
- </style>';
810
- }
811
- }
812
-
813
- /**
814
- * Marks image as watermarked or not
815
- *
816
- * @return void
817
- */
818
- private function mark_image(){
819
- $id = (int) $_GET['attachment_id'];
820
- $mark = (int) $_GET['mark'];
821
- $page = $_GET['r'];
822
-
823
- update_post_meta($id, '_ew_watermarked', $mark);
824
-
825
- $url = $page == 'library' ? admin_url('upload.php?marked='.$mark) : admin_url('post.php?post='.$id.'&action=edit&marked='.$mark);
826
-
827
- wp_redirect($url);
828
- exit;
829
- }
830
-
831
- /**
832
- * Restores original image
833
- *
834
- * @return void
835
- */
836
- private function restore_single(){
837
- $id = (int) $_GET['attachment_id'];
838
- $page = $_GET['r'];
839
-
840
- $this->restore_image($id);
841
-
842
- $url = $page == 'library' ? admin_url('upload.php?restored=1') : admin_url('post.php?post='.$id.'&action=edit&restored=1');
843
-
844
- wp_redirect($url);
845
- exit;
846
- }
847
-
848
- /**
849
- * Restores original images for bulk action ajax request
850
- *
851
- * @return void
852
- */
853
- public function wp_ajax_restore_all(){
854
- check_ajax_referer('restore_all_confirmed', '_ewnonce');
855
-
856
- global $wpdb;
857
-
858
- $page = get_option('ew-bulk-page', 0);
859
- $count = get_option('ew-bulk-counter', 0);
860
- $total = get_option('ew-bulk-total', 0);
861
-
862
- $limit = 10;
863
- $offset = $page * $limit;
864
-
865
- $items = $wpdb->get_results($wpdb->prepare("
866
- SELECT * from $wpdb->postmeta where meta_key = '_ew_backup_file'
867
- order by meta_id ASC LIMIT %d
868
- ", $limit, $offset));
869
-
870
- $output = array();
871
- foreach($items as $item){
872
- $this->restore_image($item->post_id);
873
- $output[] = sprintf(__('Image succesfully restored: %s'), $item->meta_value);
874
- }
875
-
876
- $output = '<p>' . implode('<br/>', $output) . '</p>';
877
-
878
- $count += $limit;
879
- if($count > $total) $count = $total;
880
-
881
- update_option('ew-bulk-page', $page + 1);
882
- update_option('ew-bulk-counter', $count);
883
-
884
- echo json_encode(array(
885
- 'progress' => get_option('ew-bulk-counter'),
886
- 'message' => $output
887
- ));
888
-
889
- exit;
890
- }
891
-
892
- /**
893
- * Restores original image
894
- *
895
- * @param integer attachment id
896
- * @return void
897
- */
898
- private function restore_image($id){
899
-
900
- $backup_file = get_post_meta($id, '_ew_backup_file', true);
901
- $current_file = get_attached_file($id);
902
- $filebasename = wp_basename($current_file);
903
-
904
- // Restore main image file
905
- $r = rename($backup_file, $current_file);
906
-
907
- // Regenerate thumbnails
908
- $meta = get_post_meta($id, '_wp_attachment_metadata', true);
909
-
910
- foreach($meta['sizes'] as $size => $img){
911
- $file = str_replace($filebasename, wp_basename($img['file']), $current_file);
912
- unlink($file);
913
- }
914
-
915
- // Set flag to not watermark restored image
916
- $this->restoring = true;
917
-
918
- $metadata = wp_generate_attachment_metadata($id, $current_file);
919
- if(is_wp_error($metadata)){
920
- throw new Exception($metadata->get_error_message());
921
- }
922
- if(empty($metadata)) {
923
- throw new Exception(__('Unknown failure reason.', 'easy-watermark'));
924
- }
925
- wp_update_attachment_metadata($id, $metadata);
926
-
927
- // remove post metadata
928
- delete_post_meta($id, '_ew_backup_file');
929
- delete_post_meta($id, '_ew_watermarked');
930
-
931
- $this->restoring = false;
932
- }
933
-
934
- /**
935
- * Adds Easy Watermark column in media library
936
- *
937
- * @param array
938
- * @return array
939
- */
940
- public function add_media_column($columns){
941
-
942
- $columns['ew-status'] = 'Easy Watermark';
943
-
944
- return $columns;
945
- }
946
-
947
- /**
948
- * Prints the content of Easy Watermark custom column
949
- *
950
- * @param array
951
- * @return array
952
- */
953
- public function manage_media_custom_column($column_name, $post_id){
954
- if($column_name == 'ew-status'){
955
- $this->display_column_and_metabox($post_id);
956
- }
957
- }
958
-
959
- public function add_meta_boxes(){
960
- add_meta_box(
961
- 'easy_watermark',
962
- __( 'Easy Watermark', 'easy-watermark' ),
963
- array($this, 'media_metabox'),
964
- 'attachment', 'side', 'core'
965
- );
966
- }
967
-
968
- public function media_metabox(){
969
- global $post;
970
-
971
- $this->display_column_and_metabox($post->ID, 'post');
972
- }
973
-
974
- private function display_column_and_metabox($post_id, $page = 'library'){
975
- if($post_id != $this->settings['image']['watermark_id']){
976
- $watermarked = get_post_meta($post_id, '_ew_watermarked', true);
977
- $backup_file = get_post_meta($post_id, '_ew_backup_file', null);
978
-
979
- $status = $watermarked == '1' ? __('watermarked', 'easy-watermark') : __('not watermarked', 'easy-watermark');
980
- echo __('Status', 'easy-watermark') . ': <strong>' . $status . '</strong><br/>';
981
-
982
- global $post;
983
- if(current_user_can('edit_others_posts') || $post->post_author == wp_get_current_user()->ID){
984
- $mark = $watermarked == '1' ? '0' : '1';
985
-
986
- $link_text = $watermarked == '1' ?
987
- __('mark as not watermarked', 'easy-watermark') : __('mark as watermarked', 'easy-watermark');
988
-
989
- if($page == 'post'){
990
- $class = ' class="button-secondary"';
991
- }
992
- else {
993
- $class = null;
994
- }
995
-
996
- echo '<a href="'.wp_nonce_url(admin_url('upload.php?page=easy-watermark&attachment_id='.$post_id.'&r='.$page.'&mark='.$mark), 'ew_mark').'">' . $link_text . '</a><br/><br/><p><strong><a href="' . wp_nonce_url(admin_url('upload.php?page=easy-watermark&attachment_id='.$post_id.'&r='.$page), 'ew_add_watermark') . '"'.$class.'>'.__('Add Watermark', 'easy-watermark').'</a></strong></p>';
997
-
998
- if(!empty($backup_file)){
999
- // We can restore original image
1000
-
1001
- echo '<p><a href="' . wp_nonce_url(admin_url('upload.php?page=easy-watermark&attachment_id='.$post_id.'&r='.$page), 'ew_restore') . '"'.$class.'>'.__('Restore original image', 'easy-watermark').'</a></p>';
1002
- }
1003
- }
1004
- }
1005
-
1006
- else {
1007
- echo __('This image is used as watermark.', 'easy-watermark') . '<br/><a href="'.admin_url('options-general.php?page=easy-watermark-settings&tab=image').'">' . __('Change settings', 'easy-watermark') . '</a>';
1008
-
1009
- }
1010
- }
1011
-
1012
- /**
1013
- * Method run when activating plugin
1014
- *
1015
- * @return void
1016
- */
1017
- public static function install(){
1018
- $version = get_option(self::$pluginSlug.'-version', false);
1019
- if($version)
1020
- return; // Do nothing, the plugin has been installed before
1021
-
1022
- $settings = EW_Settings::getDefaults();
1023
-
1024
- self::update_settings($settings);
1025
- }
1026
-
1027
- /**
1028
- * Method to write given settings array to the db
1029
- *
1030
- * @param array
1031
- * @return void
1032
- */
1033
- private static function update_settings($settings){
1034
- foreach($settings as $sectionName => $section){
1035
- update_option(self::$pluginSlug.'-settings-'.$sectionName, $section);
1036
- }
1037
- update_option(self::$pluginSlug.'-version', self::$version);
1038
- }
1039
-
1040
- /**
1041
- * Method run when removing plugin
1042
- *
1043
- * @return void
1044
- */
1045
- public static function uninstall(){
1046
- $settings = EW_Settings::getDefaults();
1047
-
1048
- foreach($settings as $sectionName => $section){
1049
- delete_option(self::$pluginSlug.'-settings-'.$sectionName);
1050
- }
1051
- delete_option(self::$pluginSlug.'-version');
1052
- }
1053
-
1054
- /**
1055
- * Method run when plugin version stored in WP options
1056
- * is lower than current version.
1057
- *
1058
- * @param string previously installed version
1059
- * @return void
1060
- */
1061
- protected static function upgrade($version){
1062
- $defaults = EW_Settings::getDefaults();
1063
-
1064
- if(version_compare($version, '0.1.1', '>')){
1065
- $settings['general'] = get_option(self::$pluginSlug.'-settings-general');
1066
- $settings['image'] = get_option(self::$pluginSlug.'-settings-image');
1067
- $settings['text'] = get_option(self::$pluginSlug.'-settings-text');
1068
- }
1069
- else {
1070
- $oldSettings = get_option(self::$pluginSlug.'-settings');
1071
-
1072
- $imgTypes = array();
1073
- foreach($oldSettings['image_types'] as $type){
1074
- $imgTypes[] = $type;
1075
- }
1076
-
1077
- $general = array(
1078
- 'auto_add' => $oldSettings['auto_add'],
1079
- 'image_types' => $imgTypes
1080
- );
1081
-
1082
- switch($version){
1083
- case '0.1.1':
1084
- $image = array(
1085
- 'watermark_url' => $oldSettings['image']['url'],
1086
- 'watermark_id' => $oldSettings['image']['id'],
1087
- 'watermark_path' => $oldSettings['image']['path'],
1088
- 'watermark_mime' => $oldSettings['image']['mime'],
1089
- 'position_x' => $oldSettings['image']['position_x'],
1090
- 'position_y' => $oldSettings['image']['position_y'],
1091
- 'offset_x' => $oldSettings['image']['offset_x'],
1092
- 'offset_y' => $oldSettings['image']['offset_y'],
1093
- 'opacity' => $oldSettings['image']['opacity']
1094
- );
1095
- break;
1096
- default:
1097
- $image = array(
1098
- 'watermark_url' => $oldSettings['image']['url'],
1099
- 'watermark_id' => $oldSettings['image']['id'],
1100
- 'watermark_path' => $oldSettings['image']['path'],
1101
- 'watermark_mime' => $oldSettings['image']['mime'],
1102
- 'position_x' => $oldSettings['image']['position-horizontal'],
1103
- 'position_y' => $oldSettings['image']['position-vert'],
1104
- 'offset_x' => $oldSettings['image']['offset-horizontal'],
1105
- 'offset_y' => $oldSettings['image']['offset-vert'],
1106
- 'opacity' => $oldSettings['image']['alpha']
1107
- );
1108
- break;
1109
- }
1110
-
1111
- $settings = array(
1112
- 'general' => $general,
1113
- 'image' => $image,
1114
- 'text' => array()
1115
- );
1116
- delete_option(self::$pluginSlug.'-settings');
1117
- }
1118
-
1119
- if(version_compare($version, '0.2.2', '<')){
1120
- $settings['image']['alignment'] = self::getAlignment($settings['image']['position_x'], $settings['image']['position_y']);
1121
- $settings['text']['alignment'] = self::getAlignment($settings['text']['position_x'], $settings['text']['position_y']);
1122
- }
1123
-
1124
- $settings['general'] = array_merge($defaults['general'], $settings['general']);
1125
- $settings['image'] = array_merge($defaults['image'], $settings['image']);
1126
- $settings['text'] = array_merge($defaults['text'], $settings['text']);
1127
-
1128
- self::update_settings($settings);
1129
- }
1130
-
1131
- private function add_error($msg){
1132
- $this->notices[] = array('error', $msg);
1133
- }
1134
-
1135
- private function add_info($msg){
1136
- $this->notices[] = array('update', $msg);
1137
- }
1138
-
1139
- /**
1140
- * Computes alignment number based on position_x and position_y
1141
- *
1142
- * @param int
1143
- * @param int
1144
- * @return int
1145
- */
1146
- private static function getAlignment($x, $y){
1147
- $a = false;
1148
- switch($y){
1149
- case 'top':
1150
- switch($x){
1151
- case 'lft':
1152
- case 'left':
1153
- $a = 1;
1154
- break;
1155
- case 'ctr':
1156
- case 'center':
1157
- $a = 2;
1158
- break;
1159
- case 'rgt':
1160
- case 'right':
1161
- $a = 3;
1162
- break;
1163
- }
1164
- break;
1165
- case 'mdl':
1166
- case 'middle':
1167
- switch($x){
1168
- case 'lft':
1169
- case 'left':
1170
- $a = 4;
1171
- break;
1172
- case 'ctr':
1173
- case 'center':
1174
- $a = 5;
1175
- break;
1176
- case 'rgt':
1177
- case 'right':
1178
- $a = 6;
1179
- break;
1180
- }
1181
- break;
1182
- case 'btm':
1183
- case 'bottom':
1184
- switch($x){
1185
- case 'lft':
1186
- case 'left':
1187
- $a = 7;
1188
- break;
1189
- case 'ctr':
1190
- case 'center':
1191
- $a = 8;
1192
- break;
1193
- case 'rgt':
1194
- case 'right':
1195
- $a = 9;
1196
- break;
1197
- }
1198
- break;
1199
- }
1200
-
1201
- return $a;
1202
- }
1203
-
1204
- /**
1205
- * Sets settings array.
1206
- *
1207
- * @return void
1208
- */
1209
- public function setSettings($settings){
1210
- $this->settings = $settings;
1211
- }
1212
-
1213
- public function checkRolePermission($user_id = null){
1214
- if(is_numeric($user_id)){
1215
- $user = get_userdata($user_id);
1216
- }
1217
- else {
1218
- $user = wp_get_current_user();
1219
- }
1220
-
1221
- $result = false;
1222
-
1223
- $roles = $this->getAllowedRoles();
1224
-
1225
- if(!empty($user)){
1226
- if(is_string($user->roles) && isset($roles[$user->roles]) && ((int) $roles[$user->roles] == 1))
1227
- $result = true;
1228
- else
1229
- foreach($roles as $role => $allowed){
1230
- if(in_array($role, $user->roles) && ((int) $allowed == 1)){
1231
- $result = true;
1232
- break;
1233
- }
1234
- }
1235
- }
1236
-
1237
- return $result;
1238
- }
1239
-
1240
- private function checkPostType(){
1241
- if(isset($_REQUEST['post_id']) && $_REQUEST['post_id'] != 0){
1242
- $post_id = (int) $_REQUEST['post_id'];
1243
- $post_type = get_post_type($post_id);
1244
- }
1245
- else {
1246
- // unattached image
1247
- $post_type = 'unattached';
1248
- }
1249
-
1250
- $allowed_post_types = $this->settings['general']['allowed_post_types'];
1251
-
1252
- if($post_type != null){
1253
- if(in_array($post_type, $allowed_post_types))
1254
- return true;
1255
- }
1256
-
1257
- return false;
1258
- }
1259
-
1260
- private function getAllowedRoles(){
1261
- $roles = $this->settings['general']['allowed_roles'];
1262
-
1263
- $roles['administrator'] = 1;
1264
-
1265
- return $roles;
1266
- }
1267
-
1268
- private function getTextSettings(){
1269
- $settings = $this->settings['text'];
1270
-
1271
- $settings['text'] = $this->parseText($settings['text']);
1272
-
1273
- return $settings;
1274
- }
1275
-
1276
- private function parseText($text){
1277
- $user = wp_get_current_user();
1278
- $date = !empty($this->settings['general']['date_format']) ? $this->settings['general']['date_format'] : get_option('date_format');
1279
- $time = !empty($this->settings['general']['time_format']) ? $this->settings['general']['time_format'] : get_option('time_format');
1280
-
1281
- if(is_object($this->currentImage)){
1282
- $author = get_user_by('id', $this->currentImage->post_author);
1283
- $imageTitle = $this->currentImage->post_title;
1284
- $imageAlt = get_post_meta($this->currentImage->ID, '_wp_attachment_image_alt', true);
1285
- }
1286
- else {
1287
- $author = $user;
1288
- $imageTitle = '(image title here)';
1289
- $imageAlt = '(image alt here)';
1290
- }
1291
-
1292
- $placeholders = array(
1293
- '%user%',
1294
- '%user_name%',
1295
- '%user_email%',
1296
- '%user_url%',
1297
- '%author%',
1298
- '%author_name%',
1299
- '%author_email%',
1300
- '%author_url%',
1301
- '%admin_email%',
1302
- '%blog_name%',
1303
- '%blog_url%',
1304
- '%date%',
1305
- '%time%',
1306
- '%image_title%',
1307
- '%image_alt%',
1308
- );
1309
-
1310
- $replacements = array(
1311
- $user->user_login,
1312
- $user->display_name,
1313
- $user->user_email,
1314
- $user->user_url,
1315
- $author->user_login,
1316
- $author->display_name,
1317
- $author->user_email,
1318
- $author->user_url,
1319
- get_bloginfo('admin_email'),
1320
- get_bloginfo('name'),
1321
- home_url(),
1322
- date($date),
1323
- date($time),
1324
- $imageTitle,
1325
- $imageAlt
1326
- );
1327
-
1328
- return str_replace($placeholders, $replacements, $text);
1329
- }
1330
-
1331
- public function getRoles(){
1332
- $allRoles = get_editable_roles();
1333
-
1334
- $roles = array();
1335
- foreach($allRoles as $role => $details){
1336
- if($role == 'administrator')
1337
- continue;
1338
-
1339
- if(isset($details['capabilities']['upload_files']) && $details['capabilities']['upload_files'] == true){
1340
- $roles[$role] = $details['name'];
1341
- }
1342
- }
1343
-
1344
- return $roles;
1345
- }
1346
-
1347
- public function getPostTypes($result = null){
1348
- $args = array(
1349
- 'public' => true,
1350
- '_builtin' => false
1351
- );
1352
-
1353
- $post_types = get_post_types($args, $result);
1354
-
1355
- return $post_types;
1356
- }
1357
- }