Version Description
- [Added] Role existence checks during plugin activation.
- [Added] Filter to prevent applying certain watermark.
Download this release
Release Info
Developer | bracketspace |
Plugin | Easy Watermark |
Version | 1.0.10 |
Comparing to | |
See all releases |
Code changes from version 1.0.9 to 1.0.10
- easy-watermark.php +1 -1
- readme.txt +5 -1
- src/classes/Core/Installer.php +24 -19
- src/classes/Watermark/Handler.php +24 -9
- vendor/autoload.php +1 -1
- vendor/composer/InstalledVersions.php +6 -6
- vendor/composer/autoload_real.php +4 -4
- vendor/composer/autoload_static.php +5 -5
- vendor/composer/installed.php +6 -6
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.
|
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.10
|
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: 4.6
|
6 |
Requires PHP: 5.6
|
7 |
Tested up to: 5.6
|
8 |
-
Stable tag: 1.0.
|
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,10 @@ All available placeholders are listed in a box titled 'Placeholders' displayed w
|
|
118 |
|
119 |
== Changelog ==
|
120 |
|
|
|
|
|
|
|
|
|
121 |
= 1.0.9 =
|
122 |
* [Fixed] Translated view file names causing `missing view` errors.
|
123 |
* [Fixed] Errors occuring on the first plugin activation.
|
5 |
Requires at least: 4.6
|
6 |
Requires PHP: 5.6
|
7 |
Tested up to: 5.6
|
8 |
+
Stable tag: 1.0.10
|
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.10 =
|
122 |
+
* [Added] Role existence checks during plugin activation.
|
123 |
+
* [Added] Filter to prevent applying certain watermark.
|
124 |
+
|
125 |
= 1.0.9 =
|
126 |
* [Fixed] Translated view file names causing `missing view` errors.
|
127 |
* [Fixed] Errors occuring on the first plugin activation.
|
src/classes/Core/Installer.php
CHANGED
@@ -37,29 +37,34 @@ class Installer {
|
|
37 |
|
38 |
$admin = get_role( 'administrator' );
|
39 |
|
40 |
-
$admin
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
46 |
|
47 |
$editor = get_role( 'editor' );
|
48 |
|
49 |
-
$editor
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
55 |
|
56 |
$author = get_role( 'author' );
|
57 |
|
58 |
-
$author
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
63 |
}
|
64 |
|
65 |
/**
|
@@ -121,6 +126,8 @@ class Installer {
|
|
121 |
*/
|
122 |
public static function update( $from, $defaults ) {
|
123 |
|
|
|
|
|
124 |
flush_rewrite_rules();
|
125 |
|
126 |
if ( version_compare( $from, '1.0.0', '>=' ) ) {
|
@@ -228,8 +235,6 @@ class Installer {
|
|
228 |
|
229 |
self::update_backup_info();
|
230 |
|
231 |
-
update_option( Plugin::get()->get_slug() . '-version', Plugin::get()->get_version() );
|
232 |
-
|
233 |
}
|
234 |
|
235 |
/**
|
37 |
|
38 |
$admin = get_role( 'administrator' );
|
39 |
|
40 |
+
if ( $admin ) {
|
41 |
+
$admin->add_cap( 'edit_watermark' );
|
42 |
+
$admin->add_cap( 'edit_watermarks' );
|
43 |
+
$admin->add_cap( 'edit_others_watermarks' );
|
44 |
+
$admin->add_cap( 'delete_watermarks' );
|
45 |
+
$admin->add_cap( 'delete_others_watermarks' );
|
46 |
+
$admin->add_cap( 'apply_watermark' );
|
47 |
+
}
|
48 |
|
49 |
$editor = get_role( 'editor' );
|
50 |
|
51 |
+
if ( $editor ) {
|
52 |
+
$editor->add_cap( 'edit_watermark' );
|
53 |
+
$editor->add_cap( 'edit_watermarks' );
|
54 |
+
$editor->add_cap( 'edit_others_watermarks' );
|
55 |
+
$editor->add_cap( 'delete_watermarks' );
|
56 |
+
$editor->add_cap( 'delete_others_watermarks' );
|
57 |
+
$editor->add_cap( 'apply_watermark' );
|
58 |
+
}
|
59 |
|
60 |
$author = get_role( 'author' );
|
61 |
|
62 |
+
if ( $author ) {
|
63 |
+
$author->add_cap( 'edit_watermark' );
|
64 |
+
$author->add_cap( 'edit_watermarks' );
|
65 |
+
$author->add_cap( 'delete_watermarks' );
|
66 |
+
$author->add_cap( 'apply_watermark' );
|
67 |
+
}
|
68 |
}
|
69 |
|
70 |
/**
|
126 |
*/
|
127 |
public static function update( $from, $defaults ) {
|
128 |
|
129 |
+
update_option( Plugin::get()->get_slug() . '-version', Plugin::get()->get_version() );
|
130 |
+
|
131 |
flush_rewrite_rules();
|
132 |
|
133 |
if ( version_compare( $from, '1.0.0', '>=' ) ) {
|
235 |
|
236 |
self::update_backup_info();
|
237 |
|
|
|
|
|
238 |
}
|
239 |
|
240 |
/**
|
src/classes/Watermark/Handler.php
CHANGED
@@ -223,31 +223,43 @@ class Handler {
|
|
223 |
return false;
|
224 |
}
|
225 |
|
226 |
-
$error = new WP_Error();
|
227 |
-
|
228 |
-
$this->resolver->reset();
|
229 |
-
$this->resolver->set_attachment( $attachment );
|
230 |
-
|
231 |
$applied_watermarks = get_post_meta( $attachment_id, '_ew_applied_watermarks', true );
|
232 |
|
233 |
if ( ! is_array( $applied_watermarks ) ) {
|
234 |
$applied_watermarks = [];
|
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 ) ) {
|
242 |
$meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true );
|
243 |
}
|
244 |
|
|
|
|
|
245 |
if ( ! $meta ) {
|
246 |
$error->add( 'empty_metadata', __( 'You try to watermark an item that doesn\'t exist. Please refresh the page and try again.', 'easy-watermark' ) );
|
247 |
|
248 |
return $error;
|
249 |
}
|
250 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
$filepath = get_attached_file( $attachment_id );
|
252 |
$sizes = $meta['sizes'];
|
253 |
$baename = wp_basename( $meta['file'] );
|
@@ -257,6 +269,9 @@ class Handler {
|
|
257 |
'mime-type' => $attachment->post_mime_type,
|
258 |
];
|
259 |
|
|
|
|
|
|
|
260 |
$this->do_backup( $attachment_id );
|
261 |
|
262 |
foreach ( $sizes as $size => $image ) {
|
223 |
return false;
|
224 |
}
|
225 |
|
|
|
|
|
|
|
|
|
|
|
226 |
$applied_watermarks = get_post_meta( $attachment_id, '_ew_applied_watermarks', true );
|
227 |
|
228 |
if ( ! is_array( $applied_watermarks ) ) {
|
229 |
$applied_watermarks = [];
|
230 |
}
|
231 |
|
|
|
|
|
|
|
|
|
232 |
if ( empty( $meta ) ) {
|
233 |
$meta = get_post_meta( $attachment_id, '_wp_attachment_metadata', true );
|
234 |
}
|
235 |
|
236 |
+
$error = new WP_Error();
|
237 |
+
|
238 |
if ( ! $meta ) {
|
239 |
$error->add( 'empty_metadata', __( 'You try to watermark an item that doesn\'t exist. Please refresh the page and try again.', 'easy-watermark' ) );
|
240 |
|
241 |
return $error;
|
242 |
}
|
243 |
|
244 |
+
$watermarks = array_filter( $watermarks, function( $watermark ) use ( $attachment_id, $attachment, $meta, $applied_watermarks ) {
|
245 |
+
if ( array_key_exists( $watermark->ID, $applied_watermarks ) ) {
|
246 |
+
return false;
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* This filter allows to programatically prevent watermarking certain
|
251 |
+
* attachment if `false` returned from attached function.
|
252 |
+
*
|
253 |
+
* @param boolean $should_apply Whether the image should be watermarked. Return false to prevent watermarking.
|
254 |
+
* @param Watermark $watermark Watermark object.
|
255 |
+
* @param integer $attachment_id Attachment ID.
|
256 |
+
* @param WP_Post $attachment Attachment post.
|
257 |
+
* @param array $meta Attachment metadata.
|
258 |
+
* @param array $applied_watermarks Array containing all watermarks applied to this attaachment.
|
259 |
+
*/
|
260 |
+
return apply_filters( 'easy-watermark/should-apply-watermark', true, $watermark, $attachment_id, $attachment, $meta, $applied_watermarks );
|
261 |
+
} );
|
262 |
+
|
263 |
$filepath = get_attached_file( $attachment_id );
|
264 |
$sizes = $meta['sizes'];
|
265 |
$baename = wp_basename( $meta['file'] );
|
269 |
'mime-type' => $attachment->post_mime_type,
|
270 |
];
|
271 |
|
272 |
+
$this->resolver->reset();
|
273 |
+
$this->resolver->set_attachment( $attachment );
|
274 |
+
|
275 |
$this->do_backup( $attachment_id );
|
276 |
|
277 |
foreach ( $sizes as $size => $image ) {
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit41236c1453d2778f3e4bcd114cbfb3b0::getLoader();
|
vendor/composer/InstalledVersions.php
CHANGED
@@ -25,12 +25,12 @@ class InstalledVersions
|
|
25 |
private static $installed = array (
|
26 |
'root' =>
|
27 |
array (
|
28 |
-
'pretty_version' => '1.0.
|
29 |
-
'version' => '1.0.
|
30 |
'aliases' =>
|
31 |
array (
|
32 |
),
|
33 |
-
'reference' => '
|
34 |
'name' => 'szaleq/easy-watermark',
|
35 |
),
|
36 |
'versions' =>
|
@@ -62,12 +62,12 @@ private static $installed = array (
|
|
62 |
),
|
63 |
'szaleq/easy-watermark' =>
|
64 |
array (
|
65 |
-
'pretty_version' => '1.0.
|
66 |
-
'version' => '1.0.
|
67 |
'aliases' =>
|
68 |
array (
|
69 |
),
|
70 |
-
'reference' => '
|
71 |
),
|
72 |
'underdev/requirements' =>
|
73 |
array (
|
25 |
private static $installed = array (
|
26 |
'root' =>
|
27 |
array (
|
28 |
+
'pretty_version' => '1.0.10',
|
29 |
+
'version' => '1.0.10.0',
|
30 |
'aliases' =>
|
31 |
array (
|
32 |
),
|
33 |
+
'reference' => '521a4a80ffcb55b1546c86e7841fa50f47fa3864',
|
34 |
'name' => 'szaleq/easy-watermark',
|
35 |
),
|
36 |
'versions' =>
|
62 |
),
|
63 |
'szaleq/easy-watermark' =>
|
64 |
array (
|
65 |
+
'pretty_version' => '1.0.10',
|
66 |
+
'version' => '1.0.10.0',
|
67 |
'aliases' =>
|
68 |
array (
|
69 |
),
|
70 |
+
'reference' => '521a4a80ffcb55b1546c86e7841fa50f47fa3864',
|
71 |
),
|
72 |
'underdev/requirements' =>
|
73 |
array (
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -24,15 +24,15 @@ class ComposerAutoloaderInita764a2c503e8d5eb9db23821edfa49f4
|
|
24 |
|
25 |
require __DIR__ . '/platform_check.php';
|
26 |
|
27 |
-
spl_autoload_register(array('
|
28 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
29 |
-
spl_autoload_unregister(array('
|
30 |
|
31 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
32 |
if ($useStaticLoader) {
|
33 |
require __DIR__ . '/autoload_static.php';
|
34 |
|
35 |
-
call_user_func(\Composer\Autoload\
|
36 |
} else {
|
37 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
38 |
foreach ($map as $namespace => $path) {
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit41236c1453d2778f3e4bcd114cbfb3b0
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
24 |
|
25 |
require __DIR__ . '/platform_check.php';
|
26 |
|
27 |
+
spl_autoload_register(array('ComposerAutoloaderInit41236c1453d2778f3e4bcd114cbfb3b0', 'loadClassLoader'), true, true);
|
28 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
29 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit41236c1453d2778f3e4bcd114cbfb3b0', 'loadClassLoader'));
|
30 |
|
31 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
32 |
if ($useStaticLoader) {
|
33 |
require __DIR__ . '/autoload_static.php';
|
34 |
|
35 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit41236c1453d2778f3e4bcd114cbfb3b0::getInitializer($loader));
|
36 |
} else {
|
37 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
38 |
foreach ($map as $namespace => $path) {
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'M' =>
|
@@ -163,10 +163,10 @@ class ComposerStaticInita764a2c503e8d5eb9db23821edfa49f4
|
|
163 |
public static function getInitializer(ClassLoader $loader)
|
164 |
{
|
165 |
return \Closure::bind(function () use ($loader) {
|
166 |
-
$loader->prefixLengthsPsr4 =
|
167 |
-
$loader->prefixDirsPsr4 =
|
168 |
-
$loader->prefixesPsr0 =
|
169 |
-
$loader->classMap =
|
170 |
|
171 |
}, null, ClassLoader::class);
|
172 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit41236c1453d2778f3e4bcd114cbfb3b0
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'M' =>
|
163 |
public static function getInitializer(ClassLoader $loader)
|
164 |
{
|
165 |
return \Closure::bind(function () use ($loader) {
|
166 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit41236c1453d2778f3e4bcd114cbfb3b0::$prefixLengthsPsr4;
|
167 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit41236c1453d2778f3e4bcd114cbfb3b0::$prefixDirsPsr4;
|
168 |
+
$loader->prefixesPsr0 = ComposerStaticInit41236c1453d2778f3e4bcd114cbfb3b0::$prefixesPsr0;
|
169 |
+
$loader->classMap = ComposerStaticInit41236c1453d2778f3e4bcd114cbfb3b0::$classMap;
|
170 |
|
171 |
}, null, ClassLoader::class);
|
172 |
}
|
vendor/composer/installed.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
<?php return array (
|
2 |
'root' =>
|
3 |
array (
|
4 |
-
'pretty_version' => '1.0.
|
5 |
-
'version' => '1.0.
|
6 |
'aliases' =>
|
7 |
array (
|
8 |
),
|
9 |
-
'reference' => '
|
10 |
'name' => 'szaleq/easy-watermark',
|
11 |
),
|
12 |
'versions' =>
|
@@ -38,12 +38,12 @@
|
|
38 |
),
|
39 |
'szaleq/easy-watermark' =>
|
40 |
array (
|
41 |
-
'pretty_version' => '1.0.
|
42 |
-
'version' => '1.0.
|
43 |
'aliases' =>
|
44 |
array (
|
45 |
),
|
46 |
-
'reference' => '
|
47 |
),
|
48 |
'underdev/requirements' =>
|
49 |
array (
|
1 |
<?php return array (
|
2 |
'root' =>
|
3 |
array (
|
4 |
+
'pretty_version' => '1.0.10',
|
5 |
+
'version' => '1.0.10.0',
|
6 |
'aliases' =>
|
7 |
array (
|
8 |
),
|
9 |
+
'reference' => '521a4a80ffcb55b1546c86e7841fa50f47fa3864',
|
10 |
'name' => 'szaleq/easy-watermark',
|
11 |
),
|
12 |
'versions' =>
|
38 |
),
|
39 |
'szaleq/easy-watermark' =>
|
40 |
array (
|
41 |
+
'pretty_version' => '1.0.10',
|
42 |
+
'version' => '1.0.10.0',
|
43 |
'aliases' =>
|
44 |
array (
|
45 |
),
|
46 |
+
'reference' => '521a4a80ffcb55b1546c86e7841fa50f47fa3864',
|
47 |
),
|
48 |
'underdev/requirements' =>
|
49 |
array (
|