Easy Watermark - Version 1.0.5

Version Description

  • Images will now hold information about applied watermarks which has been removed
  • [Fixed] Missing FileBird dependency
  • [Fixed] Database query error in bulk actions
Download this release

Release Info

Developer bracketspace
Plugin Icon Easy Watermark
Version 1.0.5
Comparing to
See all releases

Code changes from version 1.0.4 to 1.0.5

assets/dist/styles/attachment-edit.css CHANGED
@@ -1 +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}
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}#watermarks p.description{margin-top:20px}#watermarks .removed-watermarks{list-style:initial;margin:0;padding-left:30px}
assets/dist/styles/watermark-edit.css CHANGED
@@ -1 +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}
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}#watermarks p.description{margin-top:20px}#watermarks .removed-watermarks{list-style:initial;margin:0;padding-left:30px}.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}
easy-watermark.php CHANGED
@@ -6,7 +6,7 @@
6
  * Author URI: https://bracketspace.com/
7
  * Text Domain: easy-watermark
8
  * Domain Path: /languages
9
- * Version: 1.0.4
10
  * License: GPLv3 or later
11
  *
12
  * @package easy-watermark
6
  * Author URI: https://bracketspace.com/
7
  * Text Domain: easy-watermark
8
  * Domain Path: /languages
9
+ * Version: 1.0.5
10
  * License: GPLv3 or later
11
  *
12
  * @package easy-watermark
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: watermark, image, picture, photo, media, gallery, signature, transparent,
5
  Requires at least: 3.8
6
  Requires PHP: 5.6
7
  Tested up to: 5.2
8
- Stable tag: 1.0.4
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
  Text Domain: easy-watermark
@@ -118,6 +118,11 @@ All available placeholders are listed in a box titled 'Placeholders' displayed w
118
 
119
  == Changelog ==
120
 
 
 
 
 
 
121
  = 1.0.4 =
122
  * [Fixed] Improved error handling
123
  * [Fixed] "Enhanced Media Library" plugin compatibility (and possibly some other plugins which replace media library components)
5
  Requires at least: 3.8
6
  Requires PHP: 5.6
7
  Tested up to: 5.2
8
+ Stable tag: 1.0.5
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
  Text Domain: easy-watermark
118
 
119
  == Changelog ==
120
 
121
+ = 1.0.5 =
122
+ * Images will now hold information about applied watermarks which has been removed
123
+ * [Fixed] Missing FileBird dependency
124
+ * [Fixed] Database query error in bulk actions
125
+
126
  = 1.0.4 =
127
  * [Fixed] Improved error handling
128
  * [Fixed] "Enhanced Media Library" plugin compatibility (and possibly some other plugins which replace media library components)
src/classes/Core/Assets.php CHANGED
@@ -65,7 +65,12 @@ class Assets {
65
  'watermark-edit' => [ 'jquery', 'wp-color-picker' ],
66
  ];
67
 
68
- if ( class_exists( 'FileBird' ) ) {
 
 
 
 
 
69
  $assets['uploader'][] = 'njt-filebird-upload-libray-scripts';
70
  }
71
 
65
  'watermark-edit' => [ 'jquery', 'wp-color-picker' ],
66
  ];
67
 
68
+ if ( class_exists( 'FileBird' ) && wp_script_is( 'njt-filebird-upload-libray-scripts' ) ) {
69
+ /**
70
+ * Add dependency to load FileBird script before ours.
71
+ *
72
+ * This script is not used in list mode, so we need to check if it is enqueued first.
73
+ */
74
  $assets['uploader'][] = 'njt-filebird-upload-libray-scripts';
75
  }
76
 
src/classes/Core/Installer.php CHANGED
@@ -121,6 +121,13 @@ class Installer {
121
  */
122
  public static function update( $from, $defaults ) {
123
 
 
 
 
 
 
 
 
124
  $plugin_slug = Plugin::get()->get_slug();
125
  $settings = [];
126
 
@@ -128,9 +135,15 @@ class Installer {
128
  $settings['general'] = get_option( $plugin_slug . '-settings-general' );
129
  $settings['image'] = get_option( $plugin_slug . '-settings-image' );
130
  $settings['text'] = get_option( $plugin_slug . '-settings-text' );
 
 
 
 
131
  } else {
132
  $old_settings = get_option( $plugin_slug . '-settings' );
133
 
 
 
134
  $general = [
135
  'auto_add' => $old_settings['auto_add'],
136
  'image_types' => $old_settings['image_types'],
@@ -202,7 +215,6 @@ class Installer {
202
  }
203
 
204
  update_option( Plugin::get()->get_slug() . '-settings', $defaults );
205
- update_option( Plugin::get()->get_slug() . '-version', Plugin::get()->get_version() );
206
 
207
  if ( isset( $settings['image']['watermark_id'] ) && ! empty( $settings['image']['watermark_id'] ) ) {
208
  self::insert_image_watermark( $watermark_defaults, $settings );
@@ -216,6 +228,40 @@ class Installer {
216
 
217
  }
218
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219
  /**
220
  * Updates backup info
221
  *
121
  */
122
  public static function update( $from, $defaults ) {
123
 
124
+ update_option( Plugin::get()->get_slug() . '-version', Plugin::get()->get_version() );
125
+
126
+ if ( version_compare( $from, '1.0.0', '>=' ) ) {
127
+ self::update_attachment_meta();
128
+ return;
129
+ }
130
+
131
  $plugin_slug = Plugin::get()->get_slug();
132
  $settings = [];
133
 
135
  $settings['general'] = get_option( $plugin_slug . '-settings-general' );
136
  $settings['image'] = get_option( $plugin_slug . '-settings-image' );
137
  $settings['text'] = get_option( $plugin_slug . '-settings-text' );
138
+
139
+ delete_option( $plugin_slug . '-settings-general' );
140
+ delete_option( $plugin_slug . '-settings-image' );
141
+ delete_option( $plugin_slug . '-settings-text' );
142
  } else {
143
  $old_settings = get_option( $plugin_slug . '-settings' );
144
 
145
+ delete_option( $plugin_slug . '-settings' );
146
+
147
  $general = [
148
  'auto_add' => $old_settings['auto_add'],
149
  'image_types' => $old_settings['image_types'],
215
  }
216
 
217
  update_option( Plugin::get()->get_slug() . '-settings', $defaults );
 
218
 
219
  if ( isset( $settings['image']['watermark_id'] ) && ! empty( $settings['image']['watermark_id'] ) ) {
220
  self::insert_image_watermark( $watermark_defaults, $settings );
228
 
229
  }
230
 
231
+ /**
232
+ * Update attachment meta
233
+ *
234
+ * @return void
235
+ */
236
+ private static function update_attachment_meta() {
237
+ global $wpdb;
238
+
239
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery
240
+ $meta = $wpdb->get_results( $wpdb->prepare( "SELECT `post_id`, `meta_value` FROM {$wpdb->postmeta} WHERE `meta_key` = %s", '_ew_applied_watermarks' ) );
241
+
242
+ foreach ( $meta as $entry ) {
243
+ $value = maybe_unserialize( $entry->meta_value );
244
+
245
+ if ( is_array( $value ) ) {
246
+ $new_value = [];
247
+
248
+ foreach ( $value as $watermark_id ) {
249
+ $watermark = Watermark::get( $watermark_id );
250
+
251
+ if ( $watermark ) {
252
+ $new_value[ $watermark_id ] = $watermark->post_title;
253
+ }
254
+ }
255
+
256
+ if ( $new_value ) {
257
+ update_post_meta( $entry->post_id, '_ew_applied_watermarks', $new_value );
258
+ } else {
259
+ delete_post_meta( $entry->post_id, '_ew_applied_watermarks' );
260
+ }
261
+ }
262
+ }
263
+ }
264
+
265
  /**
266
  * Updates backup info
267
  *
src/classes/Metaboxes/Attachment/Watermarks.php CHANGED
@@ -61,10 +61,13 @@ class Watermarks extends AttachmentMetabox {
61
  $applied_watermarks = [];
62
  }
63
 
64
- $all_applied = true;
 
65
 
66
  foreach ( $watermarks as $watermark ) {
67
- if ( in_array( $watermark->ID, $applied_watermarks, true ) ) {
 
 
68
  $watermark->is_applied = true;
69
  } else {
70
  $watermark->is_applied = false;
@@ -72,6 +75,14 @@ class Watermarks extends AttachmentMetabox {
72
  }
73
  }
74
 
 
 
 
 
 
 
 
 
75
  $used_as_watermark = get_post_meta( $post->ID, '_ew_used_as_watermark', true );
76
 
77
  if ( $used_as_watermark ) {
@@ -85,6 +96,7 @@ class Watermarks extends AttachmentMetabox {
85
  'post' => $post,
86
  'watermarks' => $watermarks,
87
  'applied_watermarks' => $applied_watermarks,
 
88
  'all_applied' => $all_applied,
89
  'has_backup' => $has_backup,
90
  ] );
61
  $applied_watermarks = [];
62
  }
63
 
64
+ $all_applied = true;
65
+ $watermark_ids = [];
66
 
67
  foreach ( $watermarks as $watermark ) {
68
+ $watermark_ids[] = $watermark->ID;
69
+
70
+ if ( array_key_exists( $watermark->ID, $applied_watermarks ) ) {
71
  $watermark->is_applied = true;
72
  } else {
73
  $watermark->is_applied = false;
75
  }
76
  }
77
 
78
+ $removed_watermarks = [];
79
+
80
+ foreach ( $applied_watermarks as $id => $name ) {
81
+ if ( ! in_array( $id, $watermark_ids, true ) ) {
82
+ $removed_watermarks[] = $name;
83
+ }
84
+ }
85
+
86
  $used_as_watermark = get_post_meta( $post->ID, '_ew_used_as_watermark', true );
87
 
88
  if ( $used_as_watermark ) {
96
  'post' => $post,
97
  'watermarks' => $watermarks,
98
  'applied_watermarks' => $applied_watermarks,
99
+ 'removed_watermarks' => $removed_watermarks,
100
  'all_applied' => $all_applied,
101
  'has_backup' => $has_backup,
102
  ] );
src/classes/Watermark/Ajax.php CHANGED
@@ -202,13 +202,13 @@ class Ajax {
202
 
203
  $query = "
204
  SELECT
205
- `{$wpdb->prefix}posts`.`ID` as id,
206
- `{$wpdb->prefix}posts`.`post_mime_type` as mime,
207
- EXISTS( SELECT `{$wpdb->prefix}postmeta`.`meta_value` FROM wp_postmeta WHERE `{$wpdb->prefix}postmeta`.`post_id` = `{$wpdb->prefix}posts`.`ID` AND `{$wpdb->prefix}postmeta`.`meta_key` = '_ew_used_as_watermark' ) AS 'usedAsWatermark',
208
- EXISTS( SELECT `{$wpdb->prefix}postmeta`.`meta_value` FROM wp_postmeta WHERE `{$wpdb->prefix}postmeta`.`post_id` = `{$wpdb->prefix}posts`.`ID` AND `{$wpdb->prefix}postmeta`.`meta_key` = '_ew_has_backup' ) AS 'hasBackup'
209
  FROM
210
- `{$wpdb->prefix}posts`
211
- WHERE `{$wpdb->prefix}posts`.`ID` IN ({$placeholders})
212
  ";
213
 
214
  // phpcs:ignore WordPress.DB
202
 
203
  $query = "
204
  SELECT
205
+ `{$wpdb->posts}`.`ID` as id,
206
+ `{$wpdb->posts}`.`post_mime_type` as mime,
207
+ EXISTS( SELECT `{$wpdb->postmeta}`.`meta_value` FROM `{$wpdb->postmeta}` WHERE `{$wpdb->postmeta}`.`post_id` = `{$wpdb->posts}`.`ID` AND `{$wpdb->postmeta}`.`meta_key` = '_ew_used_as_watermark' ) AS 'usedAsWatermark',
208
+ EXISTS( SELECT `{$wpdb->postmeta}`.`meta_value` FROM `{$wpdb->postmeta}` WHERE `{$wpdb->postmeta}`.`post_id` = `{$wpdb->posts}`.`ID` AND `{$wpdb->postmeta}`.`meta_key` = '_ew_has_backup' ) AS 'hasBackup'
209
  FROM
210
+ `{$wpdb->posts}`
211
+ WHERE `{$wpdb->posts}`.`ID` IN ({$placeholders})
212
  ";
213
 
214
  // phpcs:ignore WordPress.DB
src/classes/Watermark/Handler.php CHANGED
@@ -235,7 +235,7 @@ class Handler {
235
  }
236
 
237
  $watermarks = array_filter( $watermarks, function( $watermark ) use ( $applied_watermarks ) {
238
- return ! in_array( $watermark->ID, $applied_watermarks, true );
239
  } );
240
 
241
  if ( empty( $meta ) ) {
@@ -272,8 +272,8 @@ class Handler {
272
 
273
  $this->processor->add_watermark( $watermark );
274
 
275
- if ( ! in_array( $watermark->ID, $applied_watermarks, true ) ) {
276
- $applied_watermarks[] = $watermark->ID;
277
  }
278
  }
279
  }
235
  }
236
 
237
  $watermarks = array_filter( $watermarks, function( $watermark ) use ( $applied_watermarks ) {
238
+ return ! array_key_exists( $watermark->ID, $applied_watermarks );
239
  } );
240
 
241
  if ( empty( $meta ) ) {
272
 
273
  $this->processor->add_watermark( $watermark );
274
 
275
+ if ( ! array_key_exists( $watermark->ID, $applied_watermarks ) ) {
276
+ $applied_watermarks[ $watermark->ID ] = $watermark->post_title;
277
  }
278
  }
279
  }
src/views/edit-screen/metaboxes/attachment/watermarks.php CHANGED
@@ -48,5 +48,14 @@
48
  <p><a href="<?php echo esc_url( admin_url( 'post-new.php?post_type=watermark' ) ); ?>"><?php esc_html_e( 'Create watermark', 'easy-watermark' ); ?></a></p>
49
  <?php endif; ?>
50
 
 
 
 
 
 
 
 
 
 
51
  <?php do_action( 'easy-watermark/attachment-metabox-content', $watermarks ); ?>
52
  </div>
48
  <p><a href="<?php echo esc_url( admin_url( 'post-new.php?post_type=watermark' ) ); ?>"><?php esc_html_e( 'Create watermark', 'easy-watermark' ); ?></a></p>
49
  <?php endif; ?>
50
 
51
+ <?php if ( $removed_watermarks ) : ?>
52
+ <p class="description"><?php esc_html_e( 'This image contains watermarks which has been removed:', 'easy-watermark' ); ?></p>
53
+ <ul class="removed-watermarks">
54
+ <?php foreach ( $removed_watermarks as $watermark_name ) : ?>
55
+ <li><?php echo esc_html( $watermark_name ); ?></li>
56
+ <?php endforeach; ?>
57
+ </ul>
58
+ <?php endif; ?>
59
+
60
  <?php do_action( 'easy-watermark/attachment-metabox-content', $watermarks ); ?>
61
  </div>