Easy Watermark - Version 0.5.2

Version Description

  • Fix: watermarking class optimised to avoid out-of-memory errors
  • Fix: settings are now kept after deactivation
  • Fix: many small bugs in a code
  • Added: bunch of new text placeholders
  • small changes in UI
Download this release

Release Info

Developer szaleq
Plugin Icon Easy Watermark
Version 0.5.2
Comparing to
See all releases

Code changes from version 0.5.1 to 0.5.2

classes/class-ew-plugin-core.php CHANGED
@@ -23,7 +23,7 @@ class EW_Plugin_Core extends EW_Pluggable
23
/**
24
* @var string plugin version
25
*/
26
- protected static $version = '0.5.1';
27
28
/**
29
* @var string plugin class name
23
/**
24
* @var string plugin version
25
*/
26
+ protected static $version = '0.5.2';
27
28
/**
29
* @var string plugin class name
classes/class-ew-plugin.php CHANGED
@@ -34,6 +34,26 @@ class EW_Plugin extends EW_Plugin_Core
34
*/
35
private $defaultPostTypes = array('post', 'page', 'unattached');
36
37
/**
38
* Loads textdomain for translations,
39
* adds wordpress actions
@@ -52,7 +72,7 @@ class EW_Plugin extends EW_Plugin_Core
52
if(is_admin()){
53
$this->add_action('admin_menu', 'add_media_page')
54
->add_filter('media_row_actions', 'add_media_row_action', 10, 3)
55
- ->add_filter('attachment_fields_to_edit', 'add_attachment_field', 10, 2)
56
->add_action('admin_notices')
57
->add_action('admin_head-upload.php', 'add_bulk_action_script')
58
->add_action('admin_action_ew_add_watermark', 'bulk_action_handler')
@@ -63,6 +83,16 @@ class EW_Plugin extends EW_Plugin_Core
63
}
64
65
$this->test_GD();
66
}
67
68
/**
@@ -231,6 +261,10 @@ class EW_Plugin extends EW_Plugin_Core
231
if(!self::isGDEnabled() && get_current_screen()->id == 'plugins'){
232
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>';
233
}
234
}
235
236
/**
@@ -292,7 +326,7 @@ EOD;
292
* @return array
293
*/
294
public function add_attachment_field($form_fields, $post){
295
- if($this->isGDEnabled() && in_array($post->post_mime_type, $this->allowedMime)){
296
// Add link if it's supported image type
297
$form_fields = array_reverse($form_fields);
298
$form_fields['easy-watermark'] = array(
@@ -324,19 +358,23 @@ EOD;
324
325
check_admin_referer('bulk-media');
326
$result = true;
327
foreach($_REQUEST['media'] as $entry){
328
- if(!$this->watermark_single((int) $entry))
329
$result = false;
330
}
331
332
if(isset($_GET['_wp_http_referer'])){
333
$referer = $_GET['_wp_http_referer'];
334
- if(strpos($referer, '?'))
335
- $referer .= '&';
336
- else
337
- $referer .= '?';
338
339
- $referer .= $result ? 'watermarked=1' : 'ew_error=2';
340
341
wp_redirect($referer);
342
exit;
@@ -432,7 +470,7 @@ EOD;
432
global $wpdb;
433
434
$images = $wpdb->get_results("
435
- SELECT ID, post_mime_type, post_author as author
436
FROM $wpdb->posts
437
WHERE post_type = 'attachment'
438
AND post_mime_type LIKE 'image/%'
@@ -441,9 +479,13 @@ EOD;
441
$output = '';
442
$skipped = 0;
443
if($images && ($this->settings['image']['watermark_path'] != '' || $this->settings['text']['text'])){
444
foreach($images as $img){
445
$filepath = get_attached_file($img->ID);
446
- if(!current_user_can('edit_others_posts') && wp_get_current_user()->ID != $img->author){
447
// No permission to edit this image
448
$output .= sprintf(__('No permission to edit file %s. Skipping...', 'easy-watermark'), '<strong>'.$filepath.'</strong>').'<br/>';
449
$skipped++;
@@ -488,6 +530,13 @@ EOD;
488
489
if($this->settings['image']['watermark_path'] != $filepath){
490
491
$sizes = $meta['sizes'];
492
$sizes['full'] = array(
493
'file' => $meta['file'],
@@ -511,6 +560,8 @@ EOD;
511
return $return;
512
}
513
514
return false;
515
}
516
@@ -531,7 +582,11 @@ EOD;
531
->setOutputMime($imageType);
532
533
if(!$ew->create() || !$ew->saveOutput()){
534
- $this->add_error($ew->getError());
535
return false;
536
}
537
@@ -654,25 +709,32 @@ echo '<style type="text/css" media="screen">
654
}
655
656
private function display_column_and_metabox($post_id, $page = 'library'){
657
- $watermarked = get_post_meta($post_id, '_ew_watermarked', true);
658
- $status = $watermarked == '1' ? __('watermarked', 'easy-watermark') : __('not watermarked', 'easy-watermark');
659
- echo __('Status', 'easy-watermark') . ': <strong>' . $status . '</strong><br/>';
660
661
- global $post;
662
- if(current_user_can('edit_others_posts') || $post->post_author == wp_get_current_user()->ID){
663
- $mark = $watermarked == '1' ? '0' : '1';
664
665
- $link_text = $watermarked == '1' ?
666
- __('mark as not watermarked', 'easy-watermark') : __('mark as watermarked', 'easy-watermark');
667
668
- if($page == 'post'){
669
- $class = ' class="button-secondary"';
670
- }
671
- else {
672
- $class = null;
673
}
674
675
- 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/><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>';
676
}
677
}
678
@@ -681,13 +743,27 @@ echo '<style type="text/css" media="screen">
681
*
682
* @return void
683
*/
684
- public static function install($settings = null){
685
- if(empty($settings)) $settings = EW_Settings::getDefaults();
686
687
foreach($settings as $sectionName => $section){
688
update_option(self::$pluginSlug.'-settings-'.$sectionName, $section);
689
}
690
- update_option(self::$pluginSlug.'-version', self::$version);
691
}
692
693
/**
@@ -778,7 +854,15 @@ echo '<style type="text/css" media="screen">
778
$settings['image'] = array_merge($defaults['image'], $settings['image']);
779
$settings['text'] = array_merge($defaults['text'], $settings['text']);
780
781
- self::install($settings);
782
}
783
784
/**
@@ -923,26 +1007,51 @@ echo '<style type="text/css" media="screen">
923
$date = !empty($this->settings['general']['date_format']) ? $this->settings['general']['date_format'] : get_option('date_format');
924
$time = !empty($this->settings['general']['time_format']) ? $this->settings['general']['time_format'] : get_option('time_format');
925
926
$placeholders = array(
927
'%user%',
928
'%user_name%',
929
'%user_email%',
930
'%admin_email%',
931
'%blog_name%',
932
'%blog_url%',
933
'%date%',
934
'%time%',
935
);
936
937
$replacements = array(
938
$user->user_login,
939
$user->display_name,
940
$user->user_email,
941
get_bloginfo('admin_email'),
942
get_bloginfo('name'),
943
home_url(),
944
date($date),
945
date($time),
946
);
947
948
return str_replace($placeholders, $replacements, $text);
34
*/
35
private $defaultPostTypes = array('post', 'page', 'unattached');
36
37
+ /**
38
+ * @var array
39
+ */
40
+ private $notices = array();
41
+
42
+ /**
43
+ * @var object post object for an image
44
+ */
45
+ private $currentImage;
46
+
47
+ /**
48
+ * @var array messages for different error codes from EasyWatermark class
49
+ */
50
+ private $ewErrors = array();
51
+
52
+ /**
53
+ * @var boolean
54
+ */
55
+ private $isBulkAction = false;
56
+
57
/**
58
* Loads textdomain for translations,
59
* adds wordpress actions
72
if(is_admin()){
73
$this->add_action('admin_menu', 'add_media_page')
74
->add_filter('media_row_actions', 'add_media_row_action', 10, 3)
75
+ // ->add_filter('attachment_fields_to_edit', 'add_attachment_field', 10, 2)
76
->add_action('admin_notices')
77
->add_action('admin_head-upload.php', 'add_bulk_action_script')
78
->add_action('admin_action_ew_add_watermark', 'bulk_action_handler')
83
}
84
85
$this->test_GD();
86
+
87
+ $this->ewErrors = array(
88
+ EasyWatermark::ERROR_SAME_IMAGE_PATHS => __('Same image and watermark paths.', 'easy-watermark'),
89
+ EasyWatermark::ERROR_NO_WATERMARK_SET => __('No watermark image or text specified.', 'easy-watermark'),
90
+ EasyWatermark::ERROR_NO_INPUT_IMAGE => __('No input image specified.', 'easy-watermark'),
91
+ EasyWatermark::ERROR_NOT_ALLOWED_TYPE => __('Not allowed image type.', 'easy-watermark'),
92
+ EasyWatermark::ERROR_NO_OUTPUT_FILE_SET => __('No output file specified.', 'easy-watermark'),
93
+ EasyWatermark::ERROR_NOT_ALLOWED_OUTPUT_TYPE => __('Not allowed output type.', 'easy-watermark'),
94
+ EasyWatermark::ERROR_UNKNOWN => __('Could not apply watermark.', 'easy-watermark')
95
+ );
96
}
97
98
/**
261
if(!self::isGDEnabled() && get_current_screen()->id == 'plugins'){
262
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>';
263
}
264
+
265
+ foreach($this->notices as $msg){
266
+ echo '<div class="' . $msg[0] . '"><p>' . $msg[1] . '</p></div>';
267
+ }
268
}
269
270
/**
326
* @return array
327
*/
328
public function add_attachment_field($form_fields, $post){
329
+ if($this->isGDEnabled() && in_array($post->post_mime_type, $this->allowedMime) && $post->ID != $this->settings['image']['watermark_id']){
330
// Add link if it's supported image type
331
$form_fields = array_reverse($form_fields);
332
$form_fields['easy-watermark'] = array(
358
359
check_admin_referer('bulk-media');
360
$result = true;
361
+ $this->isBulkAction = true;
362
foreach($_REQUEST['media'] as $entry){
363
+ if(!$this->watermark_single((int) $entry) && $this->error != 99)
364
$result = false;
365
}
366
367
if(isset($_GET['_wp_http_referer'])){
368
$referer = $_GET['_wp_http_referer'];
369
+ // if(strpos($referer, '?'))
370
+ // $referer .= '&';
371
+ // else
372
+ // $referer .= '?';
373
+
374
+ // $referer .= $result ? 'watermarked=1' : 'ew_error=2';
375
376
+ $args = $result ? array('watermarked' => '1') : array('ew_error' => $this->error);
377
+ $referer = add_query_arg($args, remove_query_arg(array('ew_error', 'watermarked'), $referer));
378
379
wp_redirect($referer);
380
exit;
470
global $wpdb;
471
472
$images = $wpdb->get_results("
473
+ SELECT ID, post_mime_type, post_author, post_title
474
FROM $wpdb->posts
475
WHERE post_type = 'attachment'
476
AND post_mime_type LIKE 'image/%'
479
$output = '';
480
$skipped = 0;
481
if($images && ($this->settings['image']['watermark_path'] != '' || $this->settings['text']['text'])){
482
+ $this->isBulkAction = true;
483
+
484
foreach($images as $img){
485
+ $this->currentImage = $img;
486
+
487
$filepath = get_attached_file($img->ID);
488
+ if(!current_user_can('edit_others_posts') && wp_get_current_user()->ID != $img->post_author){
489
// No permission to edit this image
490
$output .= sprintf(__('No permission to edit file %s. Skipping...', 'easy-watermark'), '<strong>'.$filepath.'</strong>').'<br/>';
491
$skipped++;
530
531
if($this->settings['image']['watermark_path'] != $filepath){
532
533
+ $this->currentImage = $post;
534
+
535
+ if($this->isBulkAction){
536
+ // Refresh watermark text for each image
537
+ $this->getEasyWatermark()->setText($this->parseText($this->settings['text']['text']));
538
+ }
539
+
540
$sizes = $meta['sizes'];
541
$sizes['full'] = array(
542
'file' => $meta['file'],
560
return $return;
561
}
562
563
+ $this->error = 99;
564
+
565
return false;
566
}
567
582
->setOutputMime($imageType);
583
584
if(!$ew->create() || !$ew->saveOutput()){
585
+ $error = $this->ewErrors[$ew->getError()];
586
+ if($this->isBulkAction){
587
+ $error = sprintf(__("Error: '%s', file: %s", 'easy-watermark'), $error, $imageFile);
588
+ }
589
+ $this->add_error($error);
590
return false;
591
}
592
709
}
710
711
private function display_column_and_metabox($post_id, $page = 'library'){
712
+ if($post_id != $this->settings['image']['watermark_id']){
713
+ $watermarked = get_post_meta($post_id, '_ew_watermarked', true);
714
+ $status = $watermarked == '1' ? __('watermarked', 'easy-watermark') : __('not watermarked', 'easy-watermark');
715
+ echo __('Status', 'easy-watermark') . ': <strong>' . $status . '</strong><br/>';
716
717
+ global $post;
718
+ if(current_user_can('edit_others_posts') || $post->post_author == wp_get_current_user()->ID){
719
+ $mark = $watermarked == '1' ? '0' : '1';
720
721
+ $link_text = $watermarked == '1' ?
722
+ __('mark as not watermarked', 'easy-watermark') : __('mark as watermarked', 'easy-watermark');
723
724
+ if($page == 'post'){
725
+ $class = ' class="button-secondary"';
726
+ }
727
+ else {
728
+ $class = null;
729
+ }
730
+
731
+ 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/><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>';
732
}
733
+ }
734
735
+ else {
736
+ 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>';
737
+
738
}
739
}
740
743
*
744
* @return void
745
*/
746
+ public static function install(){
747
+ $version = get_option(self::$pluginSlug.'-version', false);
748
+ if($version)
749
+ return; // Do nothing, the plugin has been installed before
750
+
751
+ $settings = EW_Settings::getDefaults();
752
+
753
+ self::update_settings($settings);
754
+ }
755
756
+ /**
757
+ * Method to write given settings array to the db
758
+ *
759
+ * @param array
760
+ * @return void
761
+ */
762
+ private static function update_settings($settings){
763
foreach($settings as $sectionName => $section){
764
update_option(self::$pluginSlug.'-settings-'.$sectionName, $section);
765
}
766
+ update_option(self::$pluginSlug.'-version', self::$version);
767
}
768
769
/**
854
$settings['image'] = array_merge($defaults['image'], $settings['image']);
855
$settings['text'] = array_merge($defaults['text'], $settings['text']);
856
857
+ self::update_settings($settings);
858
+ }
859
+
860
+ private function add_error($msg){
861
+ $this->notices[] = array('error', $msg);
862
+ }
863
+
864
+ private function add_info($msg){
865
+ $this->notices[] = array('update', $msg);
866
}
867
868
/**
1007
$date = !empty($this->settings['general']['date_format']) ? $this->settings['general']['date_format'] : get_option('date_format');
1008
$time = !empty($this->settings['general']['time_format']) ? $this->settings['general']['time_format'] : get_option('time_format');
1009
1010
+ if(is_object($this->currentImage)){
1011
+ $author = get_user_by('id', $this->currentImage->post_author);
1012
+ $imageTitle = $this->currentImage->post_title;
1013
+ $imageAlt = get_post_meta($this->currentImage->ID, '_wp_attachment_image_alt', true);
1014
+ }
1015
+ else {
1016
+ $author = $user;
1017
+ $imageTitle = '(image title here)';
1018
+ $imageAlt = '(image alt here)';
1019
+ }
1020
+
1021
$placeholders = array(
1022
'%user%',
1023
'%user_name%',
1024
'%user_email%',
1025
+ '%user_url%',
1026
+ '%author%',
1027
+ '%author_name%',
1028
+ '%author_email%',
1029
+ '%author_url%',
1030
'%admin_email%',
1031
'%blog_name%',
1032
'%blog_url%',
1033
'%date%',
1034
'%time%',
1035
+ '%image_title%',
1036
+ '%image_alt%',
1037
);
1038
1039
$replacements = array(
1040
$user->user_login,
1041
$user->display_name,
1042
$user->user_email,
1043
+ $user->user_url,
1044
+ $author->user_login,
1045
+ $author->display_name,
1046
+ $author->user_email,
1047
+ $author->user_url,
1048
get_bloginfo('admin_email'),
1049
get_bloginfo('name'),
1050
home_url(),
1051
date($date),
1052
date($time),
1053
+ $imageTitle,
1054
+ $imageAlt
1055
);
1056
1057
return str_replace($placeholders, $replacements, $text);
classes/class-ew-settings.php CHANGED
@@ -112,7 +112,47 @@ class EW_Settings
112
}
113
114
public function add_options_page(){
115
- add_options_page(__('Easy Watermark', 'easy-watermark'), __('Easy Watermark', 'easy-watermark'), 'manage_options', 'easy-watermark-settings', array($this, 'settings_page'));
116
}
117
118
public function register_settings(){
112
}
113
114
public function add_options_page(){
115
+ $page_id = add_options_page(__('Easy Watermark', 'easy-watermark'), __('Easy Watermark', 'easy-watermark'), 'manage_options', 'easy-watermark-settings', array($this, 'settings_page'));
116
+
117
+ add_action('load-' . $page_id, array($this, 'add_help_tab'));
118
+ }
119
+
120
+ public function add_help_tab(){
121
+ if(isset($_GET['tab']) && $_GET['tab'] == 'text'){
122
+ $screen = get_current_screen();
123
+
124
+ $author = $this->get_help_tab('author');
125
+ $user = $this->get_help_tab('user');
126
+ $general = $this->get_help_tab('general');
127
+ $image = $this->get_help_tab('image');
128
+
129
+ $screen->add_help_tab(array(
130
+ 'id' => 'ew_placeholders_author',
131
+ 'title' => __('Author placeholders'),
132
+ 'content' => $author,
133
+ ));
134
+ $screen->add_help_tab(array(
135
+ 'id' => 'ew_placeholders_user',
136
+ 'title' => __('User placeholders'),
137
+ 'content' => $user,
138
+ ));
139
+ $screen->add_help_tab(array(
140
+ 'id' => 'ew_placeholders_image',
141
+ 'title' => __('Image placeholders'),
142
+ 'content' => $image,
143
+ ));
144
+ $screen->add_help_tab(array(
145
+ 'id' => 'ew_placeholders_general',
146
+ 'title' => __('General placeholders'),
147
+ 'content' => $general,
148
+ ));
149
+ }
150
+ }
151
+
152
+ private function get_help_tab($name){
153
+ ob_start();
154
+ include EWVIEWS . EWDS . 'help_tab_placeholders_' . $name . '.php';
155
+ return ob_get_clean();
156
}
157
158
public function register_settings(){
index.php CHANGED
@@ -2,10 +2,10 @@
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
- Version: 0.5.1
6
- Author: Wojtek Szałkiewicz
7
- Author URI: http://szalkiewicz.pl/
8
- License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
*/
11
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
+ Version: 0.5.2
6
+ Author: Wojtek Szałkiewicz
7
+ Author URI: http://szalkiewicz.pl/
8
+ License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
*/
11
lib/EasyWatermark.php CHANGED
@@ -1,7 +1,7 @@
1
<?php
2
/**
3
* @package Easy Watermark
4
- * @version 3.2
5
* @license GPL
6
* @author Wojtek Szałkiewicz
7
* @author url http://szalkiewicz.pl
@@ -34,6 +34,15 @@
34
35
class EasyWatermark
36
{
37
/**
38
* @var array default settings
39
*/
@@ -470,7 +479,7 @@ class EasyWatermark
470
$return = true;
471
}
472
else {
473
- $this->error = 'Same image and watermark paths';
474
}
475
}
476
@@ -480,11 +489,11 @@ class EasyWatermark
480
}
481
482
if(!$return){
483
- $this->error = 'No watermark image and no text specified';
484
}
485
}
486
else {
487
- $this->error = 'Input image not specified';
488
}
489
490
return $return;
@@ -497,13 +506,15 @@ class EasyWatermark
497
*/
498
public function applyImageWatermark(){
499
500
- $this->getInputImage();
501
$this->getOutputImage();
502
503
// Create GD image resources
504
list($this->watermarkImage, $this->watermarkImageType) = $this->createImage($this->watermarkPath, $this->watermarkMime);
505
506
- if(!$this->inputImage || !$this->watermarkImage)
507
return false;
508
509
// Prepare settings array
@@ -555,10 +566,12 @@ class EasyWatermark
555
$newWidth, $newHeight, $watermarkWidth, $watermarkHeight
556
);
557
558
$this->watermarkImage = $tmpImage;
559
$watermarkWidth = $newWidth;
560
$watermarkHeight = $newHeight;
561
-
562
unset($tmpImage, $newWidth, $nweHeight);
563
}
564
@@ -597,9 +610,11 @@ class EasyWatermark
597
*/
598
public function applyTextWatermark(){
599
600
- $this->getInputImage();
601
$this->getOutputImage();
602
603
$settings = $this->parseSettings('text');
604
605
list($textWidth, $textHeight, $deltaX, $deltaY) = $this->getTextSize($settings['size'], $settings['angle'], $settings['font'], $this->text);
@@ -640,29 +655,35 @@ class EasyWatermark
640
641
$this->outputImage = imagecreatetruecolor($width, $height);
642
643
- $grid = 6;
644
- $grey = imagecolorallocate($this->outputImage, 130,130,130);
645
- $white = imagecolorallocate($this->outputImage, 200,200,200);
646
- $startColor = 1;
647
- for($i = 0; $i < ($height / $grid); $i++){
648
- $currentColor = $startColor;
649
- for($n = 0; $n < ($width / $grid); $n++){
650
- $color = ($currentColor == 1) ? $grey : $white;
651
- imagefilledrectangle($this->outputImage, $grid * $n, $grid * $i, $grid * $n + $grid, $grid * $i + $grid, $color);
652
- $currentColor = ($currentColor == 1) ? 0 : 1;
653
}
654
- $startColor = ($startColor == 1) ? 0 : 1;
655
- }
656
657
- $this->settings['text']['position_x'] = 1;
658
- $this->settings['text']['position_y'] = 1;
659
- $this->settings['text']['offset_x'] = 0;
660
- $this->settings['text']['offset_y'] = 0;
661
- $this->outputMime = 'jpeg';
662
663
- $this->applyTextWatermark();
664
665
- return $this->printOutput();
666
}
667
668
/**
@@ -709,25 +730,40 @@ class EasyWatermark
709
*/
710
private function getOutputImage(){
711
if(empty($this->outputImage)){
712
- list($imageWidth, $imageHeight) = $this->getImageSize(true);
713
714
- // Create blank image
715
- $this->outputImage = imagecreatetruecolor($imageWidth, $imageHeight);
716
717
- $this->outputMime = !empty($this->outputMime) ? $this->detectMimeType($this->outputMime) : $this->inputImageType;
718
719
- if(($this->outputMime == 'png' && $this->isAlphaPng($this->imagePath))){
720
- // Preserve opacity for png images
721
- imagealphablending($this->outputImage, false);
722
- imagesavealpha($this->outputImage, true);
723
- }
724
725
- imagecopy($this->outputImage, $this->inputImage,
726
- 0, 0, 0, 0, $imageWidth, $imageHeight
727
- );
728
}
729
730
- imagealphablending($this->outputImage, true);
731
732
return $this->outputImage;
733
}
@@ -737,9 +773,9 @@ class EasyWatermark
737
*
738
* @return array width and height
739
*/
740
- private function getImageSize($input = false){
741
- $img = $input ? $this->inputImage : $this->outputImage;
742
if(empty($this->imageSize)){
743
$this->imageSize = array(
744
imagesx($img),
745
imagesy($img)
@@ -805,7 +841,7 @@ class EasyWatermark
805
$type = $this->detectMimeType($mime, $filePath);
806
807
if(!in_array($type, $this->allowedTypes)){
808
- $this->error = 'invalid mime type in file: '.$filePath;
809
return false;
810
}
811
@@ -840,7 +876,7 @@ class EasyWatermark
840
if(empty($file)) $file = $this->outputFile;
841
842
if(empty($file)){
843
- $this->error = 'output file not defined';
844
return false;
845
}
846
@@ -857,7 +893,7 @@ class EasyWatermark
857
$type = !empty($this->outputMime) ? $this->detectMimeType($this->outputMime) : $this->inputImageType;
858
859
if(!$type || !in_array($type, $this->allowedTypes)){
860
- $this->error = 'invalid output type';
861
return false;
862
}
863
@@ -880,8 +916,10 @@ class EasyWatermark
880
881
$result = @call_user_func_array($func, $params);
882
883
if(!$result){
884
- $this->error = 'could not create output';
885
return false;
886
}
887
@@ -951,10 +989,10 @@ class EasyWatermark
951
* cleans up image resources when object is destructed
952
*/
953
public function clean(){
954
- if($this->inputImage) imagedestroy($this->inputImage); $this->inputImage = null;
955
if($this->watermarkImage) imagedestroy($this->watermarkImage); $this->watermarkImage = null;
956
if($this->outputImage) imagedestroy($this->outputImage); $this->outputImage = null;
957
$this->imageSize = null;
958
}
959
960
/**
1
<?php
2
/**
3
* @package Easy Watermark
4
+ * @version 3.3
5
* @license GPL
6
* @author Wojtek Szałkiewicz
7
* @author url http://szalkiewicz.pl
34
35
class EasyWatermark
36
{
37
+ // Error codes
38
+ const ERROR_SAME_IMAGE_PATHS = 1,
39
+ ERROR_NO_WATERMARK_SET = 2,
40
+ ERROR_NO_INPUT_IMAGE = 3,
41
+ ERROR_NOT_ALLOWED_TYPE = 4,
42
+ ERROR_NO_OUTPUT_FILE_SET = 5,
43
+ ERROR_NOT_ALLOWED_OUTPUT_TYPE = 6,
44
+ ERROR_UNKNOWN = 9;
45
+
46
/**
47
* @var array default settings
48
*/
479
$return = true;
480
}
481
else {
482
+ $this->error = self::ERROR_SAME_IMAGE_PATHS;
483
}
484
}
485
489
}
490
491
if(!$return){
492
+ $this->error = self::ERROR_NO_WATERMARK_SET;
493
}
494
}
495
else {
496
+ $this->error = self::ERROR_NO_INPUT_IMAGE;
497
}
498
499
return $return;
506
*/
507
public function applyImageWatermark(){
508
509
$this->getOutputImage();
510
511
+ if(!$this->outputImage)
512
+ return false;
513
+
514
// Create GD image resources
515
list($this->watermarkImage, $this->watermarkImageType) = $this->createImage($this->watermarkPath, $this->watermarkMime);
516
517
+ if(!$this->watermarkImage)
518
return false;
519
520
// Prepare settings array
566
$newWidth, $newHeight, $watermarkWidth, $watermarkHeight
567
);
568
569
+ // Clean memory
570
+ imagedestroy($this->watermarkImage);
571
+
572
$this->watermarkImage = $tmpImage;
573
$watermarkWidth = $newWidth;
574
$watermarkHeight = $newHeight;
575
unset($tmpImage, $newWidth, $nweHeight);
576
}
577
610
*/
611
public function applyTextWatermark(){
612
613
$this->getOutputImage();
614
615
+ if(!$this->outputImage)
616
+ return false;
617
+
618
$settings = $this->parseSettings('text');
619
620
list($textWidth, $textHeight, $deltaX, $deltaY) = $this->getTextSize($settings['size'], $settings['angle'], $settings['font'], $this->text);
655
656
$this->outputImage = imagecreatetruecolor($width, $height);
657
658
+ if($this->outputImage){
659
+ $grid = 6;
660
+ $grey = imagecolorallocate($this->outputImage, 130,130,130);
661
+ $white = imagecolorallocate($this->outputImage, 200,200,200);
662
+ $startColor = 1;
663
+ for($i = 0; $i < ($height / $grid); $i++){
664
+ $currentColor = $startColor;
665
+ for($n = 0; $n < ($width / $grid); $n++){
666
+ $color = ($currentColor == 1) ? $grey : $white;
667
+ imagefilledrectangle($this->outputImage, $grid * $n, $grid * $i, $grid * $n + $grid, $grid * $i + $grid, $color);
668
+ $currentColor = ($currentColor == 1) ? 0 : 1;
669
+ }
670
+ $startColor = ($startColor == 1) ? 0 : 1;
671
}
672
673
+ $this->settings['text']['position_x'] = 1;
674
+ $this->settings['text']['position_y'] = 1;
675
+ $this->settings['text']['offset_x'] = 0;
676
+ $this->settings['text']['offset_y'] = 0;
677
+ $this->outputMime = 'jpeg';
678
+
679
+ $this->applyTextWatermark();
680
+
681
+ return $this->printOutput();
682
+ }
683
684
+ $this->error = self::ERROR_UNKNOWN;
685
686
+ return false;
687
}
688
689
/**
730
*/
731
private function getOutputImage(){
732
if(empty($this->outputImage)){
733
+ if(empty($this->inputImage)){
734
+ // Create Input Image
735
+ $this->getInputImage();
736
+ }
737
738
+ if(!$this->inputImage){
739
+ $this->outputImage = false;
740
+ }
741
+ else {
742
+ list($imageWidth, $imageHeight) = $this->getImageSize();
743
744
+ // Create blank image
745
+ $this->outputImage = imagecreatetruecolor($imageWidth, $imageHeight);
746
747
+ $this->outputMime = !empty($this->outputMime) ? $this->detectMimeType($this->outputMime) : $this->inputImageType;
748
749
+ if(($this->outputMime == 'png' && $this->isAlphaPng($this->imagePath))){
750
+ // Preserve opacity for png images
751
+ imagealphablending($this->outputImage, false);
752
+ imagesavealpha($this->outputImage, true);
753
+ }
754
+
755
+ imagecopy($this->outputImage, $this->inputImage,
756
+ 0, 0, 0, 0, $imageWidth, $imageHeight
757
+ );
758
+
759
+ // Destroy Input Image to save memory
760
+ imagedestroy($this->inputImage);
761
+ unset($this->inputImage);
762
+ }
763
}
764
765
+ if($this->outputImage)
766
+ imagealphablending($this->outputImage, true);
767
768
return $this->outputImage;
769
}
773
*
774
* @return array width and height
775
*/
776
+ private function getImageSize(){
777
if(empty($this->imageSize)){
778
+ $img = is_resource($this->inputImage) ? $this->inputImage : $this->outputImage;
779
$this->imageSize = array(
780
imagesx($img),
781
imagesy($img)
841
$type = $this->detectMimeType($mime, $filePath);
842
843
if(!in_array($type, $this->allowedTypes)){
844
+ $this->error = self::ERROR_NOT_ALLOWED_TYPE;
845
return false;
846
}
847
876
if(empty($file)) $file = $this->outputFile;
877
878
if(empty($file)){
879
+ $this->error = self::ERROR_NO_OUTPUT_FILE_SET;
880
return false;
881
}
882
893
$type = !empty($this->outputMime) ? $this->detectMimeType($this->outputMime) : $this->inputImageType;
894
895
if(!$type || !in_array($type, $this->allowedTypes)){
896
+ $this->error = self::ERROR_NOT_ALLOWED_OUTPUT_TYPE;
897
return false;
898
}
899
916
917
$result = @call_user_func_array($func, $params);
918
919
+ $this->clean();
920
+
921
if(!$result){
922
+ $this->error = self::ERROR_UNKNOWN;
923
return false;
924
}
925
989
* cleans up image resources when object is destructed
990
*/
991
public function clean(){
992
if($this->watermarkImage) imagedestroy($this->watermarkImage); $this->watermarkImage = null;
993
if($this->outputImage) imagedestroy($this->outputImage); $this->outputImage = null;
994
$this->imageSize = null;
995
+ $this->inputImage = null;
996
}
997
998
/**
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
Contributors: szaleq
3
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=wojtek%40szalkiewicz%2epl&lc=GB&item_name=Easy%20Watermark%20Wordpress%20Plugin&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted
4
Tags: watermark, image, picture, photo, media, gallery, signature, transparent, upload, admin
5
- Requires at least: 3.3
6
- Tested up to: 3.6
7
- Stable tag: 0.5.1
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -83,6 +83,13 @@ All available placeholders are listed in a box titled 'Placeholders' on the text
83
84
== Changelog ==
85
86
= 0.5.1 =
87
* fixed cooperation with front-end upload plugins (like BuddyPress Media)
88
* added possibility to define which post type attachments should be watermarked on upload
2
Contributors: szaleq
3
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=wojtek%40szalkiewicz%2epl&lc=GB&item_name=Easy%20Watermark%20Wordpress%20Plugin&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted
4
Tags: watermark, image, picture, photo, media, gallery, signature, transparent, upload, admin
5
+ Requires at least: 3.5
6
+ Tested up to: 3.9.0
7
+ Stable tag: 0.5.2
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
83
84
== Changelog ==
85
86
+ = 0.5.2 =
87
+ * Fix: watermarking class optimised to avoid out-of-memory errors
88
+ * Fix: settings are now kept after deactivation
89
+ * Fix: many small bugs in a code
90
+ * Added: bunch of new text placeholders
91
+ * small changes in UI
92
+
93
= 0.5.1 =
94
* fixed cooperation with front-end upload plugins (like BuddyPress Media)
95
* added possibility to define which post type attachments should be watermarked on upload
views/easy-watermark-page.php CHANGED
@@ -2,14 +2,14 @@
2
<div class="wrap easy-watermark">
3
<div id="icon-easy-watermark" class="icon32"><br /></div>
4
<h2><?php _e('Easy Watermark', 'easy-watermark'); ?></h2>
5
- <?php
6
if(isset($_GET['_wpnonce'])) :
7
if(wp_verify_nonce($_GET['_wpnonce'], 'watermark_all_confirmed') && isset($_GET['watermark_all']) && ($output = $this->watermark_all())) :
8
?>
9
<div id="message" class="updated below-h2">
10
<p><?php _e('Watermark successfully added.', 'easy-watermark'); ?> <a href="<?php echo admin_url('upload.php') ?>"><?php _e('Go to Media Library', 'easy-watermark'); ?></a></p>
11
</div>
12
- <?
13
echo $output;
14
else: ?>
15
<div id="message" class="updated below-h2">
2
<div class="wrap easy-watermark">
3
<div id="icon-easy-watermark" class="icon32"><br /></div>
4
<h2><?php _e('Easy Watermark', 'easy-watermark'); ?></h2>
5
+ <?php
6
if(isset($_GET['_wpnonce'])) :
7
if(wp_verify_nonce($_GET['_wpnonce'], 'watermark_all_confirmed') && isset($_GET['watermark_all']) && ($output = $this->watermark_all())) :
8
?>
9
<div id="message" class="updated below-h2">
10
<p><?php _e('Watermark successfully added.', 'easy-watermark'); ?> <a href="<?php echo admin_url('upload.php') ?>"><?php _e('Go to Media Library', 'easy-watermark'); ?></a></p>
11
</div>
12
+ <?php
13
echo $output;
14
else: ?>
15
<div id="message" class="updated below-h2">
views/help_tab_placeholders_author.php ADDED
@@ -0,0 +1,8 @@
1
+ <h3><?php _e('Placeholders', 'easy-watermark'); ?></h3>
2
+ <p class="description"><?php _e('You can use this placeholders in your text watermark, it will be replaced with proper value just befor applying watermark.', 'easy-watermark'); ?></p>
3
+ <table class="widefat"><tbody>
4
+ <tr><td>%author%</td><td><?php _e('image author login', 'easy-watermark'); ?></td></tr>
5
+ <tr><td>%author_name%</td><td><?php _e('image author display name', 'easy-watermark'); ?></td></tr>
6
+ <tr><td>%author_email%</td><td><?php _e('image author email address', 'easy-watermark'); ?></td></tr>
7
+ <tr><td>%author_url%</td><td><?php _e('image author url', 'easy-watermark'); ?></td></tr>
8
+ </tbody></table>
views/help_tab_placeholders_general.php ADDED
@@ -0,0 +1,9 @@
1
+ <h3><?php _e('Placeholders', 'easy-watermark'); ?></h3>
2
+ <p class="description"><?php _e('You can use this placeholders in your text watermark, it will be replaced with proper value just befor applying watermark.', 'easy-watermark'); ?></p>
3
+ <table class="widefat"><tbody>
4
+ <tr><td>%admin_email%</td><td><?php _e('site admin email', 'easy-watermark'); ?></td></tr>
5
+ <tr><td>%blog_name%</td><td><?php _e('blog title', 'easy-watermark'); ?></td></tr>
6
+ <tr><td>%blog_url%</td><td><?php _e('blog url', 'easy-watermark'); ?></td></tr>
7
+ <tr><td>%date%</td><td><?php _e('current date (see general settings for date format)', 'easy-watermark'); ?></td></tr>
8
+ <tr><td>%time%</td><td><?php _e('current time', 'easy-watermark'); ?></td></tr>
9
+ </tbody></table>
views/help_tab_placeholders_image.php ADDED
@@ -0,0 +1,6 @@
1
+ <h3><?php _e('Placeholders', 'easy-watermark'); ?></h3>
2
+ <p class="description"><?php _e('You can use this placeholders in your text watermark, it will be replaced with proper value just befor applying watermark.', 'easy-watermark'); ?></p>
3
+ <table class="widefat"><tbody>
4
+ <tr><td>%image_title%</td><td><?php _e('image title', 'easy-watermark'); ?></td></tr>
5
+ <tr><td>%image_alt%</td><td><?php _e('alternative text for the image', 'easy-watermark'); ?></td></tr>
6
+ </tbody></table>
views/help_tab_placeholders_user.php ADDED
@@ -0,0 +1,8 @@
1
+ <h3><?php _e('Placeholders', 'easy-watermark'); ?></h3>
2
+ <p class="description"><?php _e('You can use this placeholders in your text watermark, it will be replaced with proper value just befor applying watermark.', 'easy-watermark'); ?></p>
3
+ <table class="widefat"><tbody>
4
+ <tr><td>%user%</td><td><?php _e('current user login', 'easy-watermark'); ?></td></tr>
5
+ <tr><td>%user_name%</td><td><?php _e('current user display name', 'easy-watermark'); ?></td></tr>
6
+ <tr><td>%user_email%</td><td><?php _e('current user email address', 'easy-watermark'); ?></td></tr>
7
+ <tr><td>%user_url%</td><td><?php _e('current user url', 'easy-watermark'); ?></td></tr>
8
+ </tbody></table>
views/placeholders.php CHANGED
@@ -3,14 +3,21 @@
3
<div class="inside">
4
<p class="description"><?php _e('You can use this placeholders in your text watermark, it will be replaced with proper value just befor applying watermark.', 'easy-watermark'); ?></p>
5
<table class="widefat"><tbody>
6
<tr><td>%user%</td><td><?php _e('current user login', 'easy-watermark'); ?></td></tr>
7
<tr><td>%user_name%</td><td><?php _e('current user display name', 'easy-watermark'); ?></td></tr>
8
<tr><td>%user_email%</td><td><?php _e('current user email address', 'easy-watermark'); ?></td></tr>
9
<tr><td>%admin_email%</td><td><?php _e('site admin email', 'easy-watermark'); ?></td></tr>
10
<tr><td>%blog_name%</td><td><?php _e('blog title', 'easy-watermark'); ?></td></tr>
11
<tr><td>%blog_url%</td><td><?php _e('blog url', 'easy-watermark'); ?></td></tr>
12
<tr><td>%date%</td><td><?php _e('current date (see general settings for date format)', 'easy-watermark'); ?></td></tr>
13
<tr><td>%time%</td><td><?php _e('current time', 'easy-watermark'); ?></td></tr>
14
</tbody></table>
15
</div><!-- .inside -->
16
</div>
3
<div class="inside">
4
<p class="description"><?php _e('You can use this placeholders in your text watermark, it will be replaced with proper value just befor applying watermark.', 'easy-watermark'); ?></p>
5
<table class="widefat"><tbody>
6
+ <tr><td>%author%</td><td><?php _e('image author login', 'easy-watermark'); ?></td></tr>
7
+ <tr><td>%author_name%</td><td><?php _e('image author display name', 'easy-watermark'); ?></td></tr>
8
+ <tr><td>%author_email%</td><td><?php _e('image author email address', 'easy-watermark'); ?></td></tr>
9
+ <tr><td>%author_url%</td><td><?php _e('image author url', 'easy-watermark'); ?></td></tr>
10
<tr><td>%user%</td><td><?php _e('current user login', 'easy-watermark'); ?></td></tr>
11
<tr><td>%user_name%</td><td><?php _e('current user display name', 'easy-watermark'); ?></td></tr>
12
<tr><td>%user_email%</td><td><?php _e('current user email address', 'easy-watermark'); ?></td></tr>
13
+ <tr><td>%user_url%</td><td><?php _e('current user url', 'easy-watermark'); ?></td></tr>
14
<tr><td>%admin_email%</td><td><?php _e('site admin email', 'easy-watermark'); ?></td></tr>
15
<tr><td>%blog_name%</td><td><?php _e('blog title', 'easy-watermark'); ?></td></tr>
16
<tr><td>%blog_url%</td><td><?php _e('blog url', 'easy-watermark'); ?></td></tr>
17
<tr><td>%date%</td><td><?php _e('current date (see general settings for date format)', 'easy-watermark'); ?></td></tr>
18
<tr><td>%time%</td><td><?php _e('current time', 'easy-watermark'); ?></td></tr>
19
+ <tr><td>%image_title%</td><td><?php _e('image title', 'easy-watermark'); ?></td></tr>
20
+ <tr><td>%image_alt%</td><td><?php _e('alternative text for the image', 'easy-watermark'); ?></td></tr>
21
</tbody></table>
22
</div><!-- .inside -->
23
</div>
views/settings-form-general.php CHANGED
@@ -45,6 +45,7 @@ foreach($_wp_additional_image_sizes as $sizeName => $size) : ?>
45
</table>
46
<h3><?php _e('User Roles', 'easy-watermark'); ?></h3>
47
<p class="description"><?php _e('Select, which user roles can have a permission to apply watermarks (only roles with permission to upload files are listed here)', 'easy-watermark'); ?></p>
48
<?php
49
$roles = $this->plugin->getRoles();
50
@@ -53,7 +54,6 @@ foreach($_wp_additional_image_sizes as $sizeName => $size) : ?>
53
54
$allowed = isset($allowed_roles[$role]) ? (int) $allowed_roles[$role] : 0;
55
?>
56
- <table class="form-table">
57
<tr valign="top"><th scope="row"><label for="easy-watermark-role-<?php echo $role ?>"><?php echo $name ?></label></th>
58
<td><select id="easy-watermark-role-<?php echo $role ?>" name="easy-watermark-settings-general[allowed_roles][<?php echo $role; ?>]">
59
<option <?php selected(1, $allowed); ?> value="1"><?php _e("allow", 'easy-watermark'); ?></option>
45
</table>
46
<h3><?php _e('User Roles', 'easy-watermark'); ?></h3>
47
<p class="description"><?php _e('Select, which user roles can have a permission to apply watermarks (only roles with permission to upload files are listed here)', 'easy-watermark'); ?></p>
48
+ <table class="form-table">
49
<?php
50
$roles = $this->plugin->getRoles();
51
54
55
$allowed = isset($allowed_roles[$role]) ? (int) $allowed_roles[$role] : 0;
56
?>
57
<tr valign="top"><th scope="row"><label for="easy-watermark-role-<?php echo $role ?>"><?php echo $name ?></label></th>
58
<td><select id="easy-watermark-role-<?php echo $role ?>" name="easy-watermark-settings-general[allowed_roles][<?php echo $role; ?>]">
59
<option <?php selected(1, $allowed); ?> value="1"><?php _e("allow", 'easy-watermark'); ?></option>
views/settings-form-text.php CHANGED
@@ -1,6 +1,6 @@
1
<div id="titlediv">
2
<input type="text" value="<?php echo $text; ?>" id="title" placeholder="<?php _e('Watermark Text', 'easy-watermark'); ?>" name="easy-watermark-settings-text[text]" />
3
- <p class="description"><?php _e('You can use placeholders listed on the right side of this page'); ?></p>
4
</div>
5
<?php $class = empty($text) ? ' class="hidden"' : ''; ?>
6
<?php if(EW_Plugin::isGDEnabled()) : ?>
@@ -9,9 +9,9 @@
9
<img id="ew-text-preview" src="<?php echo admin_url('options-general.php?page=easy-watermark-settings&tp=1'); ?>">
10
</div>
11
</div>
12
13
<table class="form-table">
14
- <?php endif; ?>
15
<tr valign="top" class="watermark-options"><th scope="row"><?php _e('Text Alignment', 'easy-watermark'); ?></th><td>
16
<div id="alignmentbox">
17
<label for="alignment-1" id="alignment-1-label"><input type="radio" name="easy-watermark-settings-text[alignment]" value="1" id="alignment-1" <?php checked('1', $alignment); ?> /></label>
@@ -33,13 +33,9 @@
33
</td></tr>
34
<tr><th scope="row"><?php _e('Font', 'easy-watermark'); ?></th><td>
35
<select name="easy-watermark-settings-text[font]" id="ew-font">
36
- <?php
37
- foreach($fonts as $val => $name){
38
- ?>
39
<option value="<?php echo $val; ?>" style="font-family:<?php echo $name; ?>!important;font-size:1.2em;" <?php selected($val, $font); ?>><?php echo $name; ?></option>
40
- <?
41
- }
42
- ?>
43
</select>
44
</td></tr>
45
<tr><th scope="row"><?php _e('Text Color', 'easy-watermark'); ?></th><td>
@@ -81,7 +77,7 @@
81
$g /= 255;
82
$b /= 255;
83
84
- $max = max( $r, $g, $b );
85
$min = min( $r, $g, $b );
86
87
$h;
@@ -106,9 +102,9 @@
106
case $b:
107
$h = 60 * ( ( $r - $g ) / $d + 4 );
108
break;
109
- }
110
}
111
112
- return array( $h, $s, $l );
113
}
114
?>
1
<div id="titlediv">
2
<input type="text" value="<?php echo $text; ?>" id="title" placeholder="<?php _e('Watermark Text', 'easy-watermark'); ?>" name="easy-watermark-settings-text[text]" />
3
+ <p class="description"><?php _e('You can use placeholders. See help.', 'easy-watermark'); ?></p>
4
</div>
5
<?php $class = empty($text) ? ' class="hidden"' : ''; ?>
6
<?php if(EW_Plugin::isGDEnabled()) : ?>
9
<img id="ew-text-preview" src="<?php echo admin_url('options-general.php?page=easy-watermark-settings&tp=1'); ?>">
10
</div>
11
</div>
12
+ <?php endif; ?>
13
14
<table class="form-table">
15
<tr valign="top" class="watermark-options"><th scope="row"><?php _e('Text Alignment', 'easy-watermark'); ?></th><td>
16
<div id="alignmentbox">
17
<label for="alignment-1" id="alignment-1-label"><input type="radio" name="easy-watermark-settings-text[alignment]" value="1" id="alignment-1" <?php checked('1', $alignment); ?> /></label>
33
</td></tr>
34
<tr><th scope="row"><?php _e('Font', 'easy-watermark'); ?></th><td>
35
<select name="easy-watermark-settings-text[font]" id="ew-font">
36
+ <?php foreach($fonts as $val => $name) : ?>
37
<option value="<?php echo $val; ?>" style="font-family:<?php echo $name; ?>!important;font-size:1.2em;" <?php selected($val, $font); ?>><?php echo $name; ?></option>
38
+ <?php endforeach; ?>
39
</select>
40
</td></tr>
41
<tr><th scope="row"><?php _e('Text Color', 'easy-watermark'); ?></th><td>
77
$g /= 255;
78
$b /= 255;
79
80
+ $max = max( $r, $g, $b );
81
$min = min( $r, $g, $b );
82
83
$h;
102
case $b:
103
$h = 60 * ( ( $r - $g ) / $d + 4 );
104
break;
105
+ }
106
}
107
108
+ return array($h, $s, $l);
109
}
110
?>
views/settings-page.php CHANGED
@@ -1,3 +1,4 @@
1
<div class="wrap easy-watermark">
2
<div class="has-right-sidebar">
3
<?php include dirname(__FILE__) . EWDS . 'settings-sidebar.php'; ?>
1
+
2
<div class="wrap easy-watermark">
3
<div class="has-right-sidebar">
4
<?php include dirname(__FILE__) . EWDS . 'settings-sidebar.php'; ?>
views/settings-sidebar.php CHANGED
@@ -1,5 +1,6 @@
1
<div class="metabox-holder inner-sidebar">
2
<?php include dirname(__FILE__) . EWDS . 'about.php'; ?>
3
- <?php if($current_tab == 'text')
4
- include dirname(__FILE__) . EWDS . 'placeholders.php'; ?>
5
</div><!-- .metabox-holder -->
1
<div class="metabox-holder inner-sidebar">
2
+ <?php // placeholders are now described in help
3
+ /*if($current_tab == 'text')
4
+ include dirname(__FILE__) . EWDS . 'placeholders.php'; */ ?>
5
<?php include dirname(__FILE__) . EWDS . 'about.php'; ?>
6
</div><!-- .metabox-holder -->