Easy Watermark - Version 1.0.1

Version Description

  • [Fixed] Freemius screen displayed incorrectly after activation
  • [Fixed] Permission settings now actualy works
  • [Fixed] Config is now saved in unicode so you can use other character sets, like cyrylic
  • [Fixed] Incompatibilities with caching plugins
  • [Fixed] Srcset fatal error edge case
  • [Fixed] Watermark deleting
Download this release

Release Info

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

Code changes from version 1.0.0 to 1.0.1

easy-watermark.php CHANGED
@@ -1,12 +1,12 @@
1
<?php
2
/**
3
* Plugin Name: Easy Watermark
4
- * Description: This plugin can automatically add image and text watermark to pictures as they are uploaded to WordPress media library. You can also watermark existing images manually (all at once or an every single image). Watermark image can be a png, gif (alpha channel supported in both cases) or jpg. It's also possibile to set watermark opacity (doesn't apply to png with alpha channel). For text watermark you can select font, set color, size, angel and opacity.
5
* Author: BracketSpace
6
* Author URI: https://bracketspace.com/
7
* Text Domain: easy-watermark
8
* Domain Path: /languages
9
- * Version: 1.0.0
10
* License: GPLv2 or later
11
*
12
* @package easy-watermark
1
<?php
2
/**
3
* Plugin Name: Easy Watermark
4
+ * Description: This plugin can automatically add image and text watermark to pictures as they are uploaded to WordPress media library. You can also watermark existing images manually (all at once or an every single image). Watermark image can be a png, gif (alpha channel supported in both cases) or jpg. It's also possibile to set watermark opacity (doesn't apply to png with alpha channel). For text watermark you can select font, set color, size, angle and opacity.
5
* Author: BracketSpace
6
* Author URI: https://bracketspace.com/
7
* Text Domain: easy-watermark
8
* Domain Path: /languages
9
+ * Version: 1.0.1
10
* License: GPLv2 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.0
9
License: GPLv3 or later
10
License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
Text Domain: easy-watermark
@@ -86,7 +86,7 @@ Watermark position can be adjusted vertically and horizontally by selecting alig
86
Yes, there is a posibility to add only image, only text or both.
87
88
= How Can I adjust text watermark? =
89
- You can choose text font from the list of ten fonts included to this plugin. You can also set font size, color, angel and opacity. Position of text watermark can be adjusted exactly like the image watermark position.
90
91
= Can I use my font for text watermark? =
92
Unfortunately no. In PRO version you'll be able to use more fonts.
@@ -118,6 +118,14 @@ All available placeholders are listed in a box titled 'Placeholders' displayed w
118
119
== Changelog ==
120
121
= 1.0.0 =
122
* The plugin has been rewrote from ground up.
123
5
Requires at least: 3.8
6
Requires PHP: 5.6
7
Tested up to: 5.2
8
+ Stable tag: 1.0.1
9
License: GPLv3 or later
10
License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
Text Domain: easy-watermark
86
Yes, there is a posibility to add only image, only text or both.
87
88
= How Can I adjust text watermark? =
89
+ You can choose text font from the list of ten fonts included to this plugin. You can also set font size, color, angle and opacity. Position of text watermark can be adjusted exactly like the image watermark position.
90
91
= Can I use my font for text watermark? =
92
Unfortunately no. In PRO version you'll be able to use more fonts.
118
119
== Changelog ==
120
121
+ = 1.0.1 =
122
+ * [Fixed] Freemius screen displayed incorrectly after activation
123
+ * [Fixed] Permission settings now actualy works
124
+ * [Fixed] Config is now saved in unicode so you can use other character sets, like cyrylic
125
+ * [Fixed] Incompatibilities with caching plugins
126
+ * [Fixed] Srcset fatal error edge case
127
+ * [Fixed] Watermark deleting
128
+
129
= 1.0.0 =
130
* The plugin has been rewrote from ground up.
131
src/classes/Core/Assets.php CHANGED
@@ -125,6 +125,10 @@ class Assets {
125
];
126
break;
127
case 'upload':
128
$this->wp_enqueue_media();
129
$enqueue = 'media-library';
130
$localize = [
125
];
126
break;
127
case 'upload':
128
+ if ( ! current_user_can( 'apply_watermark' ) ) {
129
+ break;
130
+ }
131
+
132
$this->wp_enqueue_media();
133
$enqueue = 'media-library';
134
$localize = [
src/classes/Core/Installer.php CHANGED
@@ -107,6 +107,12 @@ class Installer {
107
$role->remove_cap( 'apply_watermark' );
108
}
109
110
}
111
112
/**
@@ -198,6 +204,9 @@ class Installer {
198
$defaults['general']['jpeg_quality'] = $settings['general']['jpg_quality'];
199
}
200
201
if ( isset( $settings['image']['watermark_id'] ) && ! empty( $settings['image']['watermark_id'] ) ) {
202
self::insert_image_watermark( $watermark_defaults, $settings );
203
}
@@ -206,9 +215,6 @@ class Installer {
206
self::insert_text_watermark( $watermark_defaults, $settings );
207
}
208
209
- update_option( Plugin::get()->get_slug() . '-settings', $defaults );
210
- update_option( Plugin::get()->get_slug() . '-version', Plugin::get()->get_version() );
211
-
212
self::update_backup_info();
213
214
}
107
$role->remove_cap( 'apply_watermark' );
108
}
109
110
+ $watermarks = Watermark::get_all();
111
+
112
+ foreach ( $watermarks as $watermark ) {
113
+ $result = wp_delete_post( $watermark->ID, true );
114
+ }
115
+
116
}
117
118
/**
204
$defaults['general']['jpeg_quality'] = $settings['general']['jpg_quality'];
205
}
206
207
+ update_option( Plugin::get()->get_slug() . '-settings', $defaults );
208
+ update_option( Plugin::get()->get_slug() . '-version', Plugin::get()->get_version() );
209
+
210
if ( isset( $settings['image']['watermark_id'] ) && ! empty( $settings['image']['watermark_id'] ) ) {
211
self::insert_image_watermark( $watermark_defaults, $settings );
212
}
215
self::insert_text_watermark( $watermark_defaults, $settings );
216
}
217
218
self::update_backup_info();
219
220
}
src/classes/Core/Plugin.php CHANGED
@@ -73,7 +73,6 @@ class Plugin extends Singleton {
73
74
register_activation_hook( EW_FILE_PATH, [ 'EasyWatermark\Core\Installer', 'activate' ] );
75
register_deactivation_hook( EW_FILE_PATH, [ 'EasyWatermark\Core\Installer', 'deactivate' ] );
76
- register_uninstall_hook( EW_FILE_PATH, [ 'EasyWatermark\Core\Installer', 'uninstall' ] );
77
78
if ( ! ew_dochooks_enabled() ) {
79
add_action( 'plugins_loaded', [ $this, 'setup' ] );
@@ -82,7 +81,10 @@ class Plugin extends Singleton {
82
$this->hook();
83
84
// Init Freemius.
85
- ew_fs();
86
87
// Signal that SDK was initiated.
88
do_action( 'ew_fs_loaded' );
@@ -111,13 +113,7 @@ class Plugin extends Singleton {
111
112
$this->get_watermark_handler();
113
114
- $settings = Settings::get();
115
-
116
- $last_version = get_option( $this->slug . '-version' );
117
- if ( $this->version !== $last_version ) {
118
- // Version has changed. Update.
119
- Installer::update( $last_version, $settings->get_settings() );
120
- }
121
122
$this->setup_metaboxes();
123
@@ -163,6 +159,13 @@ class Plugin extends Singleton {
163
add_rewrite_tag( '%watermark_id%', '([0-9]+)' );
164
add_rewrite_tag( '%image_size%', '([^./-]+)' );
165
166
}
167
168
/**
73
74
register_activation_hook( EW_FILE_PATH, [ 'EasyWatermark\Core\Installer', 'activate' ] );
75
register_deactivation_hook( EW_FILE_PATH, [ 'EasyWatermark\Core\Installer', 'deactivate' ] );
76
77
if ( ! ew_dochooks_enabled() ) {
78
add_action( 'plugins_loaded', [ $this, 'setup' ] );
81
$this->hook();
82
83
// Init Freemius.
84
+ $fs = ew_fs();
85
+
86
+ // Register uninstall hook with freemius.
87
+ $fs->add_action( 'after_uninstall', [ 'EasyWatermark\Core\Installer', 'uninstall' ] );
88
89
// Signal that SDK was initiated.
90
do_action( 'ew_fs_loaded' );
113
114
$this->get_watermark_handler();
115
116
+ Settings::get();
117
118
$this->setup_metaboxes();
119
159
add_rewrite_tag( '%watermark_id%', '([0-9]+)' );
160
add_rewrite_tag( '%image_size%', '([^./-]+)' );
161
162
+ $last_version = get_option( $this->slug . '-version' );
163
+ if ( $this->version !== $last_version ) {
164
+ // Version has changed. Update.
165
+ $settings = Settings::get();
166
+ Installer::update( $last_version, $settings->get_settings() );
167
+ }
168
+
169
}
170
171
/**
src/classes/Dashboard/Dashboard.php CHANGED
@@ -64,7 +64,7 @@ class Dashboard {
64
$this->page_hook = add_management_page(
65
__( 'Easy Watermark', 'easy-watermark' ),
66
__( 'Easy Watermark', 'easy-watermark' ),
67
- 'manage_options',
68
'easy-watermark',
69
[ $this, 'page_content' ]
70
);
64
$this->page_hook = add_management_page(
65
__( 'Easy Watermark', 'easy-watermark' ),
66
__( 'Easy Watermark', 'easy-watermark' ),
67
+ 'apply_watermark',
68
'easy-watermark',
69
[ $this, 'page_content' ]
70
);
src/classes/Dashboard/Page.php CHANGED
@@ -37,6 +37,13 @@ abstract class Page {
37
*/
38
protected $priority;
39
40
/**
41
* Constructor
42
*
@@ -66,10 +73,12 @@ abstract class Page {
66
*/
67
public function add_tab( $tabs ) {
68
69
- $tabs[ $this->slug ] = [
70
- 'title' => $this->title,
71
- 'priority' => $this->priority,
72
- ];
73
74
return $tabs;
75
37
*/
38
protected $priority;
39
40
+ /**
41
+ * Permission
42
+ *
43
+ * @var string
44
+ */
45
+ protected $permission = 'apply_watermark';
46
+
47
/**
48
* Constructor
49
*
73
*/
74
public function add_tab( $tabs ) {
75
76
+ if ( current_user_can( $this->permission ) ) {
77
+ $tabs[ $this->slug ] = [
78
+ 'title' => $this->title,
79
+ 'priority' => $this->priority,
80
+ ];
81
+ }
82
83
return $tabs;
84
src/classes/Dashboard/Permissions.php CHANGED
@@ -18,6 +18,7 @@ class Permissions extends Page {
18
* Constructor
19
*/
20
public function __construct() {
21
parent::__construct( __( 'Permissions', 'easy-watermark' ), null, 100 );
22
}
23
18
* Constructor
19
*/
20
public function __construct() {
21
+ $this->permission = 'manage_options';
22
parent::__construct( __( 'Permissions', 'easy-watermark' ), null, 100 );
23
}
24
src/classes/Dashboard/Settings.php CHANGED
@@ -19,6 +19,7 @@ class Settings extends Page {
19
* Constructor
20
*/
21
public function __construct() {
22
parent::__construct( __( 'Settings', 'easy-watermark' ), null, 80 );
23
}
24
19
* Constructor
20
*/
21
public function __construct() {
22
+ $this->permission = 'manage_options';
23
parent::__construct( __( 'Settings', 'easy-watermark' ), null, 80 );
24
}
25
src/classes/Dashboard/Tools.php CHANGED
@@ -60,33 +60,26 @@ class Tools extends Page {
60
return [
61
'watermarks' => $handler->get_watermarks(),
62
'backup_count' => $backup_count,
63
];
64
}
65
66
/**
67
- * Prepares arguments for view
68
- *
69
- * @action wp_ajax_easy-watermark/tools/get-attachments
70
*
71
- * @return void
72
*/
73
- public function get_attachments() {
74
-
75
- check_ajax_referer( 'get_attachments', 'nonce' );
76
77
$mime_types = ImageHelper::get_available_mime_types();
78
-
79
- // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
80
- $mode = isset( $_REQUEST['mode'] ) ? $_REQUEST['mode'] : null;
81
-
82
- $posts = get_posts( [
83
'post_type' => 'attachment',
84
'post_mime_type' => array_keys( $mime_types ),
85
'numberposts' => -1,
86
] );
87
88
- $result = [];
89
-
90
foreach ( $posts as $post ) {
91
if ( get_post_meta( $post->ID, '_ew_used_as_watermark', true ) ) {
92
// Skip images used as watermark.
@@ -104,6 +97,26 @@ class Tools extends Page {
104
];
105
}
106
107
wp_send_json_success( $result );
108
}
109
}
60
return [
61
'watermarks' => $handler->get_watermarks(),
62
'backup_count' => $backup_count,
63
+ 'attachments' => $this->get_attachments(),
64
];
65
}
66
67
/**
68
+ * Gets attachments available for watermarking
69
*
70
+ * @param string $mode Mode (watermark|restore).
71
+ * @return array
72
*/
73
+ private function get_attachments( $mode = 'watermark' ) {
74
75
$mime_types = ImageHelper::get_available_mime_types();
76
+ $result = [];
77
+ $posts = get_posts( [
78
'post_type' => 'attachment',
79
'post_mime_type' => array_keys( $mime_types ),
80
'numberposts' => -1,
81
] );
82
83
foreach ( $posts as $post ) {
84
if ( get_post_meta( $post->ID, '_ew_used_as_watermark', true ) ) {
85
// Skip images used as watermark.
97
];
98
}
99
100
+ return $result;
101
+
102
+ }
103
+
104
+ /**
105
+ * Prepares arguments for view
106
+ *
107
+ * @action wp_ajax_easy-watermark/tools/get-attachments
108
+ *
109
+ * @return void
110
+ */
111
+ public function ajax_get_attachments() {
112
+
113
+ check_ajax_referer( 'get_attachments', 'nonce' );
114
+
115
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
116
+ $mode = isset( $_REQUEST['mode'] ) ? $_REQUEST['mode'] : null;
117
+ $result = $this->get_attachments( $mode );
118
+
119
wp_send_json_success( $result );
120
+
121
}
122
}
src/classes/Features/SrcsetFilter.php CHANGED
@@ -92,6 +92,11 @@ class SrcsetFilter {
92
*/
93
public function wp_calculate_image_srcset_meta( $image_meta, $size_array, $image_src, $attachment_id ) {
94
95
if ( true === $this->switch->get_value() && isset( $image_meta['sizes'] ) && is_array( $image_meta['sizes'] ) ) {
96
$applied_watermarks = get_post_meta( $attachment_id, '_ew_applied_watermarks', true );
97
92
*/
93
public function wp_calculate_image_srcset_meta( $image_meta, $size_array, $image_src, $attachment_id ) {
94
95
+ if ( ! $this->switch ) {
96
+ // Don't do anything if settings have not been loaded yet.
97
+ return $image_meta;
98
+ }
99
+
100
if ( true === $this->switch->get_value() && isset( $image_meta['sizes'] ) && is_array( $image_meta['sizes'] ) ) {
101
$applied_watermarks = get_post_meta( $attachment_id, '_ew_applied_watermarks', true );
102
src/classes/Settings/Settings.php CHANGED
@@ -44,7 +44,7 @@ class Settings extends Singleton {
44
/**
45
* Constructor
46
*/
47
- public function __construct() {
48
$this->hook();
49
$this->register_sections();
50
$this->load_settings();
44
/**
45
* Constructor
46
*/
47
+ protected function __construct() {
48
$this->hook();
49
$this->register_sections();
50
$this->load_settings();
src/classes/Watermark/PostType.php CHANGED
@@ -233,7 +233,7 @@ class PostType {
233
public function redirect( $location ) {
234
global $post;
235
236
- if ( 'watermark' === $post->post_type ) {
237
if ( false !== strpos( $location, 'untrashed=1' ) && ! $this->untrashed ) {
238
$location = add_query_arg( [
239
'ew-limited' => '1',
@@ -447,7 +447,7 @@ class PostType {
447
if ( 'watermark' === $data['post_type'] && isset( $postarr['watermark'] ) ) {
448
$watermark_data = Watermark::parse_params( $postarr['watermark'] );
449
450
- $data['post_content'] = wp_json_encode( $watermark_data );
451
452
$old_attachment_id = isset( $postarr['ew-previous-attachment-id'] ) ? $postarr['ew-previous-attachment-id'] : false;
453
$new_attachment_id = $postarr['watermark']['attachment_id'];
233
public function redirect( $location ) {
234
global $post;
235
236
+ if ( $post && 'watermark' === $post->post_type ) {
237
if ( false !== strpos( $location, 'untrashed=1' ) && ! $this->untrashed ) {
238
$location = add_query_arg( [
239
'ew-limited' => '1',
447
if ( 'watermark' === $data['post_type'] && isset( $postarr['watermark'] ) ) {
448
$watermark_data = Watermark::parse_params( $postarr['watermark'] );
449
450
+ $data['post_content'] = wp_json_encode( $watermark_data, JSON_UNESCAPED_UNICODE );
451
452
$old_attachment_id = isset( $postarr['ew-previous-attachment-id'] ) ? $postarr['ew-previous-attachment-id'] : false;
453
$new_attachment_id = $postarr['watermark']['attachment_id'];
src/classes/Watermark/Watermark.php CHANGED
@@ -102,7 +102,8 @@ class Watermark {
102
public static function get_all() {
103
104
$posts = get_posts( [
105
- 'post_type' => 'watermark',
106
] );
107
108
foreach ( $posts as $post ) {
102
public static function get_all() {
103
104
$posts = get_posts( [
105
+ 'post_type' => 'watermark',
106
+ 'numberposts' => -1,
107
] );
108
109
foreach ( $posts as $post ) {
src/inc/freemius.php CHANGED
@@ -15,7 +15,7 @@ function ew_fs() {
15
// Include Freemius SDK.
16
require_once EW_DIR_PATH . '/freemius/start.php';
17
18
- $ew_fs = fs_dynamic_init( array(
19
'id' => '2801',
20
'slug' => 'easy-watermark',
21
'type' => 'plugin',
@@ -23,7 +23,16 @@ function ew_fs() {
23
'is_premium' => false,
24
'has_addons' => false,
25
'has_paid_plans' => false,
26
- ) );
27
}
28
29
return $ew_fs;
15
// Include Freemius SDK.
16
require_once EW_DIR_PATH . '/freemius/start.php';
17
18
+ $ew_fs = fs_dynamic_init( [
19
'id' => '2801',
20
'slug' => 'easy-watermark',
21
'type' => 'plugin',
23
'is_premium' => false,
24
'has_addons' => false,
25
'has_paid_plans' => false,
26
+ 'menu' => [
27
+ 'slug' => 'easy-watermark',
28
+ 'account' => false,
29
+ 'contact' => false,
30
+ 'support' => false,
31
+ 'parent' => [
32
+ 'slug' => 'tools.php',
33
+ ],
34
+ ],
35
+ ] );
36
}
37
38
return $ew_fs;
src/inc/hooks.php CHANGED
@@ -49,7 +49,7 @@ add_filter( 'easy-watermark/dashboard/permissions/view-args', [ $this->objects['
49
add_filter( 'easy-watermark/dashboard/tabs', [ $this->objects['EasyWatermark\Dashboard\Permissions']['instance'], 'add_tab' ], 10, 1 );
50
add_action( 'easy-watermark/dashboard/settings/notices', [ $this->objects['EasyWatermark\Dashboard\Tools']['instance'], 'admin_notices' ], 10, 0 );
51
add_filter( 'easy-watermark/dashboard/tools/view-args', [ $this->objects['EasyWatermark\Dashboard\Tools']['instance'], 'view_args' ], 10, 1 );
52
- add_action( 'wp_ajax_easy-watermark/tools/get-attachments', [ $this->objects['EasyWatermark\Dashboard\Tools']['instance'], 'get_attachments' ], 10, 0 );
53
add_filter( 'easy-watermark/dashboard/tabs', [ $this->objects['EasyWatermark\Dashboard\Tools']['instance'], 'add_tab' ], 10, 1 );
54
add_action( 'easy-watermark/settings/register/general', [ $this->objects['EasyWatermark\Features\SrcsetFilter']['instance'], 'register_settings' ], 10, 1 );
55
add_filter( 'wp_calculate_image_srcset_meta', [ $this->objects['EasyWatermark\Features\SrcsetFilter']['instance'], 'wp_calculate_image_srcset_meta' ], 1000, 4 );
49
add_filter( 'easy-watermark/dashboard/tabs', [ $this->objects['EasyWatermark\Dashboard\Permissions']['instance'], 'add_tab' ], 10, 1 );
50
add_action( 'easy-watermark/dashboard/settings/notices', [ $this->objects['EasyWatermark\Dashboard\Tools']['instance'], 'admin_notices' ], 10, 0 );
51
add_filter( 'easy-watermark/dashboard/tools/view-args', [ $this->objects['EasyWatermark\Dashboard\Tools']['instance'], 'view_args' ], 10, 1 );
52
+ add_action( 'wp_ajax_easy-watermark/tools/get-attachments', [ $this->objects['EasyWatermark\Dashboard\Tools']['instance'], 'ajax_get_attachments' ], 10, 0 );
53
add_filter( 'easy-watermark/dashboard/tabs', [ $this->objects['EasyWatermark\Dashboard\Tools']['instance'], 'add_tab' ], 10, 1 );
54
add_action( 'easy-watermark/settings/register/general', [ $this->objects['EasyWatermark\Features\SrcsetFilter']['instance'], 'register_settings' ], 10, 1 );
55
add_filter( 'wp_calculate_image_srcset_meta', [ $this->objects['EasyWatermark\Features\SrcsetFilter']['instance'], 'wp_calculate_image_srcset_meta' ], 1000, 4 );
src/views/dashboard/pages/tools.php CHANGED
@@ -13,19 +13,23 @@
13
<div class="content">
14
<p><?php esc_html_e( 'Using this tool you can quickly apply watermark to all images in the Media Library.', 'easy-watermark' ); ?></p>
15
<?php if ( count( $watermarks ) ) : ?>
16
- <p>
17
- <select class="watermark">
18
- <option value="-1"><?php esc_html_e( 'Select Watermark', 'easy-watermark' ); ?></option>
19
- <?php if ( 1 < count( $watermarks ) ) : ?>
20
- <option value="all" data-nonce="<?php echo esc_attr( wp_create_nonce( 'apply_all' ) ); ?>"><?php esc_html_e( 'All Watermarks', 'easy-watermark' ); ?></option>
21
- <?php endif; ?>
22
- <?php foreach ( $watermarks as $watermark ) : ?>
23
- <option value="<?php echo esc_attr( $watermark->ID ); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'apply_single-' . $watermark->ID ) ); ?>"><?php echo esc_html( $watermark->post_title ); ?></option>
24
- <?php endforeach; ?>
25
- </select>
26
- </p>
27
- <p><a href="#" class="button-primary"><?php esc_html_e( 'Start', 'easy-watermark' ); ?></a><span class="spinner"></span></p>
28
- <p class="description"><?php esc_html_e( 'Note: The same watermark will never get applied twice to the same image. This tool is safe to use even if some of the images are already watermarked.', 'easy-watermark' ); ?></p>
29
<?php else : ?>
30
<?php $link = sprintf( '<a href="%s">%s</a>', admin_url( 'post-new.php?post_type=watermark' ), esc_html_x( 'create watermark', 'link text for new watermark page', 'easy-watermark' ) ); ?>
31
<?php /* translators: %s is a "create watermark" link */ ?>
13
<div class="content">
14
<p><?php esc_html_e( 'Using this tool you can quickly apply watermark to all images in the Media Library.', 'easy-watermark' ); ?></p>
15
<?php if ( count( $watermarks ) ) : ?>
16
+ <?php if ( count( $attachments ) ) : ?>
17
+ <p>
18
+ <select class="watermark">
19
+ <option value="-1"><?php esc_html_e( 'Select Watermark', 'easy-watermark' ); ?></option>
20
+ <?php if ( 1 < count( $watermarks ) ) : ?>
21
+ <option value="all" data-nonce="<?php echo esc_attr( wp_create_nonce( 'apply_all' ) ); ?>"><?php esc_html_e( 'All Watermarks', 'easy-watermark' ); ?></option>
22
+ <?php endif; ?>
23
+ <?php foreach ( $watermarks as $watermark ) : ?>
24
+ <option value="<?php echo esc_attr( $watermark->ID ); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'apply_single-' . $watermark->ID ) ); ?>"><?php echo esc_html( $watermark->post_title ); ?></option>
25
+ <?php endforeach; ?>
26
+ </select>
27
+ </p>
28
+ <p><a href="#" class="button-primary"><?php esc_html_e( 'Start', 'easy-watermark' ); ?></a><span class="spinner"></span></p>
29
+ <p class="description"><?php esc_html_e( 'Note: The same watermark will never get applied twice to the same image. This tool is safe to use even if some of the images are already watermarked.', 'easy-watermark' ); ?></p>
30
+ <?php else : ?>
31
+ <p><?php esc_html_e( 'There are no image attachments in your Media Library available for watermarking.', 'easy-watermark' ); ?></p>
32
+ <?php endif; ?>
33
<?php else : ?>
34
<?php $link = sprintf( '<a href="%s">%s</a>', admin_url( 'post-new.php?post_type=watermark' ), esc_html_x( 'create watermark', 'link text for new watermark page', 'easy-watermark' ) ); ?>
35
<?php /* translators: %s is a "create watermark" link */ ?>
src/views/dashboard/pages/watermarks.php CHANGED
@@ -11,7 +11,13 @@
11
<div class="postbox item">
12
<div class="inside">
13
<?php /* translators: watermark name */ ?>
14
- <h3><a href="<?php echo esc_url( get_edit_post_link( $watermark->ID ) ); ?>" aria-label="<?php esc_attr_e( sprintf( 'Edit “%s”', $watermark->post_title ) ); ?>"><?php echo esc_html( $watermark->post_title ); ?></a></h3>
15
<div class="watermark-preview">
16
<?php if ( 'image' === $watermark->type ) : ?>
17
<?php echo wp_get_attachment_image( $watermark->attachment_id, 'full' ); ?>
@@ -20,16 +26,20 @@
20
<?php endif; ?>
21
</div>
22
<div class="row-actions">
23
- <?php /* translators: watermark name */ ?>
24
- <span class="edit"><a href="<?php echo esc_url( get_edit_post_link( $watermark->ID ) ); ?>" aria-label="<?php esc_attr_e( sprintf( 'Edit “%s”', $watermark->post_title ) ); ?>"><?php esc_html_e( 'Edit', 'easy-watermark' ); ?></a> | </span>
25
- <?php /* translators: watermark name */ ?>
26
- <span class="delete"><a href="<?php echo esc_url( get_delete_post_link( $watermark->ID, '', true ) ); ?>" class="submitdelete" data-watermark-name="<?php echo esc_attr( $watermark->post_title ); ?>" aria-label="<?php esc_attr_e( sprintf( 'Permanently Delete “%s”', $watermark->post_title ) ); ?>"><?php esc_html_e( 'Delete Permanently', 'easy-watermark' ); ?></a></span>
27
</div>
28
</div>
29
</div>
30
<?php endforeach; ?>
31
32
- <?php if ( 2 > $watermarks_count ) : ?>
33
<div class="postbox item">
34
<div class="inside">
35
<a href="<?php echo esc_url( admin_url( 'post-new.php?post_type=watermark' ) ); ?>" class="button button-primary button-hero"><?php esc_html_e( 'Add New Watermark', 'easy-watermark' ); ?></a>
11
<div class="postbox item">
12
<div class="inside">
13
<?php /* translators: watermark name */ ?>
14
+ <h3>
15
+ <?php if ( current_user_can( 'edit_others_watermarks' ) || get_current_user_id() === (int) $watermark->post_author ) : ?>
16
+ <a href="<?php echo esc_url( get_edit_post_link( $watermark->ID ) ); ?>" aria-label="<?php esc_attr_e( sprintf( 'Edit “%s”', $watermark->post_title ) ); ?>"><?php echo esc_html( $watermark->post_title ); ?></a>
17
+ <?php else : ?>
18
+ <?php echo esc_html( $watermark->post_title ); ?>
19
+ <?php endif; ?>
20
+ </h3>
21
<div class="watermark-preview">
22
<?php if ( 'image' === $watermark->type ) : ?>
23
<?php echo wp_get_attachment_image( $watermark->attachment_id, 'full' ); ?>
26
<?php endif; ?>
27
</div>
28
<div class="row-actions">
29
+ <?php if ( current_user_can( 'edit_others_watermarks' ) || get_current_user_id() === (int) $watermark->post_author ) : ?>
30
+ <?php /* translators: watermark name */ ?>
31
+ <span class="edit"><a href="<?php echo esc_url( get_edit_post_link( $watermark->ID ) ); ?>" aria-label="<?php esc_attr_e( sprintf( 'Edit “%s”', $watermark->post_title ) ); ?>"><?php esc_html_e( 'Edit', 'easy-watermark' ); ?></a> | </span>
32
+ <?php endif; ?>
33
+ <?php if ( current_user_can( 'delete_others_watermarks' ) || get_current_user_id() === (int) $watermark->post_author ) : ?>
34
+ <?php /* translators: watermark name */ ?>
35
+ <span class="delete"><a href="<?php echo esc_url( get_delete_post_link( $watermark->ID, '', true ) ); ?>" class="submitdelete" data-watermark-name="<?php echo esc_attr( $watermark->post_title ); ?>" aria-label="<?php esc_attr_e( sprintf( 'Permanently Delete “%s”', $watermark->post_title ) ); ?>"><?php esc_html_e( 'Delete Permanently', 'easy-watermark' ); ?></a></span>
36
+ <?php endif; ?>
37
</div>
38
</div>
39
</div>
40
<?php endforeach; ?>
41
42
+ <?php if ( 2 > $watermarks_count && current_user_can( 'edit_watermarks' ) ) : ?>
43
<div class="postbox item">
44
<div class="inside">
45
<a href="<?php echo esc_url( admin_url( 'post-new.php?post_type=watermark' ) ); ?>" class="button button-primary button-hero"><?php esc_html_e( 'Add New Watermark', 'easy-watermark' ); ?></a>