Easy Watermark - Version 0.2

Version Description

  • added text watermark handling
  • corrected issue with auto adding watermark on upload
Download this release

Release Info

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

Code changes from version 0.1.1 to 0.2

Files changed (55) hide show
  1. EasyWatermark.php +341 -105
  2. EasyWatermarkPlugin.php +139 -66
  3. EasyWatermarkSettings.php +89 -32
  4. css/colorpicker.css +161 -0
  5. css/style.css +16 -0
  6. fonts/Arial.ttf +0 -0
  7. fonts/Arial_Black.ttf +0 -0
  8. fonts/Comic_Sans_MS.ttf +0 -0
  9. fonts/Courier_New.ttf +0 -0
  10. fonts/Georgia.ttf +0 -0
  11. fonts/Impact.ttf +0 -0
  12. fonts/Tahoma.ttf +0 -0
  13. fonts/Times_New_Roman.ttf +0 -0
  14. fonts/Trebuchet_MS.ttf +0 -0
  15. fonts/Verdana.ttf +0 -0
  16. images/Thumbs.db +0 -0
  17. images/blank.gif +0 -0
  18. images/colorpicker_background.png +0 -0
  19. images/colorpicker_hex.png +0 -0
  20. images/colorpicker_hsb_b.png +0 -0
  21. images/colorpicker_hsb_h.png +0 -0
  22. images/colorpicker_hsb_s.png +0 -0
  23. images/colorpicker_indic.gif +0 -0
  24. images/colorpicker_overlay.png +0 -0
  25. images/colorpicker_rgb_b.png +0 -0
  26. images/colorpicker_rgb_g.png +0 -0
  27. images/colorpicker_rgb_r.png +0 -0
  28. images/colorpicker_select.gif +0 -0
  29. images/colorpicker_submit.png +0 -0
  30. images/custom_background.png +0 -0
  31. images/custom_hex.png +0 -0
  32. images/custom_hsb_b.png +0 -0
  33. images/custom_hsb_h.png +0 -0
  34. images/custom_hsb_s.png +0 -0
  35. images/custom_indic.gif +0 -0
  36. images/custom_rgb_b.png +0 -0
  37. images/custom_rgb_g.png +0 -0
  38. images/custom_rgb_r.png +0 -0
  39. images/custom_submit.png +0 -0
  40. images/select.png +0 -0
  41. images/select2.png +0 -0
  42. images/slider.png +0 -0
  43. index.php +6 -3
  44. js/colorpicker.js +484 -0
  45. js/interface.js +10 -0
  46. languages/easy-watermark-pl_PL.mo +0 -0
  47. languages/easy-watermark-pl_PL.po +127 -67
  48. languages/easy-watermark.pot +128 -67
  49. plugin.php +139 -0
  50. readme.txt +17 -5
  51. screenshot-1.png +0 -0
  52. settings-form-general.php +23 -0
  53. settings-form-image.php +41 -0
  54. settings-form-text.php +46 -0
  55. settings-form.php +13 -57
EasyWatermark.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package Easy Watermark
4
- * @version 1.0
5
  * @license GPL
6
  * @author Wojtek Szałkiewicz
7
  * @author url http://szalkiewicz.pl
@@ -32,9 +32,10 @@
32
  * You can also specify custom output format, and save it as file using saveOutput method.
33
  * TODO:
34
  * - watermark scaling
35
- * - adding text watermark
36
  * Any other ideas, pleas contact me.
37
  */
 
 
38
 
39
  class EasyWatermark
40
  {
@@ -42,11 +43,25 @@ class EasyWatermark
42
  * @var array default settings
43
  */
44
  private $defaultSettings = array(
45
- 'position_x' => 2,
46
- 'position_y' => 2,
47
- 'offset_x' => 0,
48
- 'offset_y' => 0,
49
- 'opacity' => 100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  );
51
 
52
  /**
@@ -84,6 +99,11 @@ class EasyWatermark
84
  */
85
  private $outputMime = '';
86
 
 
 
 
 
 
87
  /**
88
  * @var string error message
89
  */
@@ -94,12 +114,13 @@ class EasyWatermark
94
  *
95
  * @param array settings
96
  */
97
- public function __construct($settings = array()){
98
- $this->set($settings);
 
99
  }
100
 
101
  /**
102
- * Sets all needed parameters (settings and values of some private fields)
103
  *
104
  * @see $defaultSettings
105
  * @chainable
@@ -107,11 +128,11 @@ class EasyWatermark
107
  * @param string value
108
  * @return object $this
109
  */
110
- public function set($key, $val = null){
111
  if(is_array($key)){
112
  // act recursive
113
  foreach($key as $k => $v){
114
- $this->set($k, $v);
115
  }
116
  return $this;
117
  }
@@ -136,13 +157,54 @@ class EasyWatermark
136
  $this->setOutputMime($val);
137
  break;
138
  default:
139
- $this->settings[$key] = $val;
140
  break;
141
  }
142
 
143
  return $this;
144
  }
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  /**
147
  * Sets input image path
148
  *
@@ -245,9 +307,14 @@ class EasyWatermark
245
  *
246
  * @return array settings
247
  */
248
- private function parseSettings(){
249
- // merge with defaults
250
- $settings = array_merge($this->defaultSettings, $this->settings);
 
 
 
 
 
251
 
252
  if(strpos($settings['offset_x'], '%') === (strlen($settings['offset_x']) - 1)){
253
  $settings['offset_x'] = substr($settings['offset_x'], 0, strlen($settings['offset_x']) - 1);
@@ -300,6 +367,17 @@ class EasyWatermark
300
  break;
301
  }
302
 
 
 
 
 
 
 
 
 
 
 
 
303
  return $settings;
304
  }
305
 
@@ -308,11 +386,31 @@ class EasyWatermark
308
  */
309
  private $inputImage;
310
 
 
 
 
 
 
 
 
 
 
 
311
  /**
312
  * @var resource GD image created from watermark file
313
  */
314
  private $watermarkImage;
315
 
 
 
 
 
 
 
 
 
 
 
316
  /**
317
  * @var resource GD image prepared as output
318
  */
@@ -335,132 +433,215 @@ class EasyWatermark
335
  * @param string output file mime
336
  * @return boolean
337
  */
338
- public function create($imagePath = null, $imageMime = null,
339
- $watermarkPath = null, $watermarkMime = null){
340
-
341
- if(empty($imagePath)) $imagePath = $this->imagePath;
342
- if(empty($imageMime)) $imageMime = $this->imageMime;
343
- if(empty($watermarkPath)) $watermarkPath = $this->watermarkPath;
344
- if(empty($watermarkMime)) $watermarkMime = $this->watermarkMime;
345
-
346
- if(!empty($imagePath) && !empty($watermarkPath)){
347
- if($imagePath != $watermarkPath){
348
- // Create GD image resources
349
- list($this->inputImage, $inputType) = $this->createImage($imagePath, $imageMime);
350
- list($this->watermarkImage, $wmType) = $this->createImage($watermarkPath, $watermarkMime);
351
-
352
- if(!$this->inputImage || !$this->watermarkImage)
353
- return false;
354
-
355
- // Prepare settings array
356
- $settings = $this->parseSettings();
357
-
358
- // Get image dimensions
359
- $imageWidth = imagesx($this->inputImage);
360
- $imageHeight = imagesy($this->inputImage);
361
-
362
- // Get watermark dimensions
363
- $watermarkWidth = imagesx($this->watermarkImage);
364
- $watermarkHeight = imagesy($this->watermarkImage);
365
-
366
- // Compute watermark offset
367
- $offsetX = $this->computeOffset($settings['position_x'], $settings['offset_x'],
368
- $imageWidth, $watermarkWidth, $settings['offset_x_pc']);
369
- $offsetY = $this->computeOffset($settings['position_y'], $settings['offset_y'],
370
- $imageHeight, $watermarkHeight, $settings['offset_y_pc']);
371
-
372
- // Create blank image
373
- $this->outputImage = imagecreatetruecolor($imageWidth, $imageHeight);
374
-
375
- imagecopy($this->outputImage, $this->inputImage,
376
- 0, 0, 0, 0, $imageWidth, $imageHeight
377
- );
378
-
379
- // Prepare params for copying function
380
- $params = array($this->outputImage, $this->watermarkImage,
381
- $offsetX, $offsetY,
382
- 0, 0,
383
- $watermarkWidth, $watermarkHeight
384
- );
385
- if($wmType == 'png' && $this->isAlphaPng($watermarkPath)){
386
- // Watermark is PNG with alpha channel, use imagecopy
387
- $func = 'imagecopy';
388
  }
389
  else {
390
- // Use imagecopymerge with opacity param for other images
391
- $func = 'imagecopymerge';
392
- $params[] = $settings['opacity'];
393
  }
 
394
 
395
- // Copy watermark to output image
396
- call_user_func_array($func, $params);
397
-
398
- return true;
399
  }
400
- else {
401
- $this->error = 'same image and watermark paths';
 
402
  }
403
  }
404
  else {
405
- $this->error = empty($imagePath) ? 'empty image path' : 'empty watermark path';
406
  }
407
 
408
- return false;
409
  }
410
 
411
  /**
412
- * Prints created image directly to the browser
413
  *
414
  * @return boolean
415
  */
416
- public function printOutput(){
417
- return $this->prepareOutput();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
418
  }
419
 
420
  /**
421
- * Saves created image
422
  *
423
- * @param string filename (required if not set earlier)
424
  * @return boolean
425
  */
426
- public function saveOutput($file = null){
427
- if(empty($file)) $file = $this->outputFile;
428
 
429
- if(empty($file)){
430
- $this->error = 'output file not defined';
431
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
432
  }
433
 
434
- return $this->prepareOutput($file);
435
  }
436
 
437
  /**
438
- * Saves or outputs created image depending on $output param
439
  *
440
- * @param string output file
441
- * @return boolean
442
  */
443
- private function prepareOutput($output = null){
444
- $type = !empty($this->outputMime) ? $this->detectMimeType($this->outputMime) : $this->inputImage[1];
 
445
 
446
- if(!$type || !in_array($type, $this->allowedTypes)){
447
- $this->error = 'invalid output type';
448
- return false;
 
 
 
449
  }
450
 
451
- if($output === null)
452
- // Return image directly to the browser
453
- header('Content-Type: image/'.$type);
454
 
455
- if($type == 'jpg') $type = 'jpeg';
456
- $func = 'image'.$type;
 
 
 
 
 
 
 
 
 
 
457
 
458
- if(!@$func($this->outputImage, $output)){
459
- $this->error = 'could not create output';
460
- return false;
 
 
 
 
 
 
 
 
 
 
 
461
  }
462
 
463
- return true;
464
  }
465
 
466
  /**
@@ -519,6 +700,61 @@ class EasyWatermark
519
  return array($image, $type);
520
  }
521
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  /**
523
  * Detects mime type using php finfo object and extracts what's needed
524
  *
1
  <?php
2
  /**
3
  * @package Easy Watermark
4
+ * @version 2.0
5
  * @license GPL
6
  * @author Wojtek Szałkiewicz
7
  * @author url http://szalkiewicz.pl
32
  * You can also specify custom output format, and save it as file using saveOutput method.
33
  * TODO:
34
  * - watermark scaling
 
35
  * Any other ideas, pleas contact me.
36
  */
37
+ namespace szaleq\Plugins\EasyWatermark;
38
+ /* Namespace is only needed for WP plugin, can be removed or changed if using this class separately. */
39
 
40
  class EasyWatermark
41
  {
43
  * @var array default settings
44
  */
45
  private $defaultSettings = array(
46
+ 'image' => array(
47
+ 'position_x' => 2,
48
+ 'position_y' => 2,
49
+ 'offset_x' => 0,
50
+ 'offset_y' => 0,
51
+ 'opacity' => 100
52
+ ),
53
+ 'text' => array(
54
+ 'position_x' => 2,
55
+ 'position_y' => 2,
56
+ 'offset_x' => 0,
57
+ 'offset_y' => 0,
58
+ 'opacity' => 60,
59
+ 'color' => 'fff',
60
+ 'font' => '',
61
+ 'size' => 24,
62
+ 'angle' => 0,
63
+ 'text' => ''
64
+ )
65
  );
66
 
67
  /**
99
  */
100
  private $outputMime = '';
101
 
102
+ /**
103
+ * @var string watermark text
104
+ */
105
+ private $text = '';
106
+
107
  /**
108
  * @var string error message
109
  */
114
  *
115
  * @param array settings
116
  */
117
+ public function __construct($imageSettings = array(), $textSettings = array()){
118
+ $this->imageSet($imageSettings);
119
+ $this->textSet($textSettings);
120
  }
121
 
122
  /**
123
+ * Sets watermark image parameters
124
  *
125
  * @see $defaultSettings
126
  * @chainable
128
  * @param string value
129
  * @return object $this
130
  */
131
+ public function imageSet($key, $val = null){
132
  if(is_array($key)){
133
  // act recursive
134
  foreach($key as $k => $v){
135
+ $this->imageSet($k, $v);
136
  }
137
  return $this;
138
  }
157
  $this->setOutputMime($val);
158
  break;
159
  default:
160
+ $this->settings['image'][$key] = $val;
161
  break;
162
  }
163
 
164
  return $this;
165
  }
166
 
167
+ /**
168
+ * Sets watermark text parameters
169
+ *
170
+ * @see $defaultSettings
171
+ * @chainable
172
+ * @param string settings key
173
+ * @param string value
174
+ * @return object $this
175
+ */
176
+ public function textSet($key, $val = null){
177
+ if(is_array($key)){
178
+ // act recursive
179
+ foreach($key as $k => $v){
180
+ $this->textSet($k, $v);
181
+ }
182
+ return $this;
183
+ }
184
+
185
+ if($key == 'text'){
186
+ $this->setText($val);
187
+ }
188
+ else {
189
+ $this->settings['text'][$key] = $val;
190
+ }
191
+
192
+ return $this;
193
+ }
194
+
195
+ /**
196
+ * Sets watermark text
197
+ *
198
+ * @chainable
199
+ * @param string watermark text
200
+ * @return object $this
201
+ */
202
+ public function setText($value){
203
+ $this->text = $value;
204
+
205
+ return $this;
206
+ }
207
+
208
  /**
209
  * Sets input image path
210
  *
307
  *
308
  * @return array settings
309
  */
310
+ private function parseSettings($section){
311
+
312
+ if(!isset($this->defaultSettings[$section]))
313
+ return false;
314
+
315
+ $settings = isset($this->settings[$section]) ?
316
+ array_merge($this->defaultSettings[$section], $this->settings[$section]) :
317
+ $this->defaultSettings[$section];
318
 
319
  if(strpos($settings['offset_x'], '%') === (strlen($settings['offset_x']) - 1)){
320
  $settings['offset_x'] = substr($settings['offset_x'], 0, strlen($settings['offset_x']) - 1);
367
  break;
368
  }
369
 
370
+ if(isset($settings['color'])){
371
+ if(strpos($settings['color'], '#') === 0){
372
+ $settings['color'] = substr($settings['color'], 1);
373
+ }
374
+ if(strlen($settings['color']) == 3){
375
+ $settings['color'] = $settings['color'][0].$settings['color'][0].
376
+ $settings['color'][1].$settings['color'][1].
377
+ $settings['color'][2].$settings['color'][2];
378
+ }
379
+ }
380
+
381
  return $settings;
382
  }
383
 
386
  */
387
  private $inputImage;
388
 
389
+ /**
390
+ * @var string image type
391
+ */
392
+ private $inputImageType;
393
+
394
+ /**
395
+ * @var array image size
396
+ */
397
+ private $imageSize;
398
+
399
  /**
400
  * @var resource GD image created from watermark file
401
  */
402
  private $watermarkImage;
403
 
404
+ /**
405
+ * @var string image type
406
+ */
407
+ private $watermarkImageType;
408
+
409
+ /**
410
+ * @var array watermark size
411
+ */
412
+ private $watermarkSize;
413
+
414
  /**
415
  * @var resource GD image prepared as output
416
  */
433
  * @param string output file mime
434
  * @return boolean
435
  */
436
+ public function create(){
437
+
438
+ $return = false;
439
+ if(!empty($this->imagePath)){
440
+ if(!empty($this->watermarkPath)){
441
+ if($this->imagePath != $this->watermarkPath){
442
+ $this->applyImageWatermark();
443
+ $return = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444
  }
445
  else {
446
+ $this->error = 'Same image and watermark paths';
 
 
447
  }
448
+ }
449
 
450
+ if(!empty($this->text)){
451
+ $this->applyTextWatermark();
452
+ $return = true;
 
453
  }
454
+
455
+ if(!$return){
456
+ $this->error = 'No watermark image and no text specified';
457
  }
458
  }
459
  else {
460
+ $this->error = 'Input image not specified';
461
  }
462
 
463
+ return $return;
464
  }
465
 
466
  /**
467
+ * Creates output image with watermarm
468
  *
469
  * @return boolean
470
  */
471
+ public function applyImageWatermark(){
472
+
473
+ $this->getInputImage();
474
+ $this->getOutputImage();
475
+
476
+ // Create GD image resources
477
+ list($this->watermarkImage, $this->watermarkImageType) = $this->createImage($this->watermarkPath, $this->watermarkMime);
478
+
479
+ if(!$this->inputImage || !$this->watermarkImage)
480
+ return false;
481
+
482
+ // Prepare settings array
483
+ $settings = $this->parseSettings('image');
484
+
485
+ // Get image dimensions
486
+ list($imageWidth, $imageHeight) = $this->getImageSize();
487
+
488
+ // Get watermark dimensions
489
+ list($watermarkWidth, $watermarkHeight) = $this->getWatermarkSize();
490
+
491
+ // Compute watermark offset
492
+ $offsetX = $this->computeOffset($settings['position_x'], $settings['offset_x'],
493
+ $imageWidth, $watermarkWidth, $settings['offset_x_pc']);
494
+ $offsetY = $this->computeOffset($settings['position_y'], $settings['offset_y'],
495
+ $imageHeight, $watermarkHeight, $settings['offset_y_pc']);
496
+
497
+ // Prepare params for copying function
498
+ $params = array($this->outputImage, $this->watermarkImage,
499
+ $offsetX, $offsetY,
500
+ 0, 0,
501
+ $watermarkWidth, $watermarkHeight
502
+ );
503
+ if($this->watermarkImageType == 'png' && $this->isAlphaPng($this->watermarkPath)){
504
+ // Watermark is PNG with alpha channel, use imagecopy
505
+ $func = 'imagecopy';
506
+ }
507
+ else {
508
+ // Use imagecopymerge with opacity param for other images
509
+ $func = 'imagecopymerge';
510
+ $params[] = $settings['opacity'];
511
+ }
512
+
513
+ // Copy watermark to output image
514
+ call_user_func_array($func, $params);
515
+
516
+ return true;
517
  }
518
 
519
  /**
520
+ * Adds text watermark to output image
521
  *
 
522
  * @return boolean
523
  */
524
+ public function applyTextWatermark(){
 
525
 
526
+ $this->getInputImage();
527
+ $this->getOutputImage();
528
+
529
+ $settings = $this->parseSettings('text');
530
+
531
+ list($textWidth, $textHeight, $deltaX, $deltaY) = $this->getTextSize($settings['size'], $settings['angle'], $settings['font'], $this->text);
532
+ list($imageWidth, $imageHeight) = $this->getImageSize();
533
+
534
+ $color = $settings['color'];
535
+ $color = imagecolorallocatealpha($this->outputImage,
536
+ hexdec(substr($color, 0, 2)),
537
+ hexdec(substr($color, 2, 2)),
538
+ hexdec(substr($color, 4, 2)),
539
+ 127 * (100 - $settings['opacity']) / 100);
540
+
541
+ // Compute watermark offset
542
+ $offsetX = $this->computeOffset($settings['position_x'], $settings['offset_x'],
543
+ $imageWidth, $textWidth, $settings['offset_x_pc']);
544
+ $offsetY = $this->computeOffset($settings['position_y'], $settings['offset_y'],
545
+ $imageHeight, $textHeight, $settings['offset_y_pc']);
546
+
547
+ imagettftext($this->outputImage,
548
+ $settings['size'],
549
+ $settings['angle'],
550
+ $offsetX - $deltaX, $offsetY - $deltaY,
551
+ $color,
552
+ $settings['font'],
553
+ $this->text);
554
+
555
+ return true;
556
+ }
557
+
558
+ /**
559
+ * Returns size of text bounding box width x and y distance from font baseline
560
+ *
561
+ * @param integer font size
562
+ * @param integer angle
563
+ * @param string font file path
564
+ * @param string text
565
+ * @return array
566
+ */
567
+ private function getTextSize($fontSize, $angle, $font, $text){
568
+
569
+ $bb = imagettfbbox($fontSize, $angle, $font, $text);
570
+
571
+ $maxX = max($bb[0], $bb[2], $bb[4], $bb[6]);
572
+ $minX = min($bb[0], $bb[2], $bb[4], $bb[6]);
573
+ $x = $maxX - $minX;
574
+
575
+ $maxY = max($bb[1], $bb[3], $bb[5], $bb[7]);
576
+ $minY = min($bb[1], $bb[3], $bb[5], $bb[7]);
577
+ $y = $maxY - $minY;
578
+
579
+ return array($x, $y, $minX, $minY);
580
+ }
581
+
582
+ /**
583
+ * Creates if not exist and returns input image
584
+ *
585
+ * @return resource GD image
586
+ */
587
+ private function getInputImage(){
588
+ if(empty($this->inputImage)){
589
+ list($this->inputImage, $this->inputImageType) = $this->createImage($this->imagePath, $this->imageMime);
590
  }
591
 
592
+ return $this->inputImage;
593
  }
594
 
595
  /**
596
+ * Creates if not exist and returns output image
597
  *
598
+ * @return resource GD image
 
599
  */
600
+ private function getOutputImage(){
601
+ if(empty($this->outputImage)){
602
+ list($imageWidth, $imageHeight) = $this->getImageSize();
603
 
604
+ // Create blank image
605
+ $this->outputImage = imagecreatetruecolor($imageWidth, $imageHeight);
606
+
607
+ imagecopy($this->outputImage, $this->inputImage,
608
+ 0, 0, 0, 0, $imageWidth, $imageHeight
609
+ );
610
  }
611
 
612
+ return $this->outputImage;
613
+ }
 
614
 
615
+ /**
616
+ * Returns input image size
617
+ *
618
+ * @return array width and height
619
+ */
620
+ private function getImageSize(){
621
+ if(empty($this->imageSize)){
622
+ $this->imageSize = array(
623
+ imagesx($this->inputImage),
624
+ imagesy($this->inputImage)
625
+ );
626
+ }
627
 
628
+ return $this->imageSize;
629
+ }
630
+
631
+ /**
632
+ * Returns watermark image size
633
+ *
634
+ * @return array width and height
635
+ */
636
+ private function getWatermarkSize(){
637
+ if(empty($this->watermarkSize)){
638
+ $this->watermarkSize = array(
639
+ imagesx($this->watermarkImage),
640
+ imagesy($this->watermarkImage)
641
+ );
642
  }
643
 
644
+ return $this->watermarkSize;
645
  }
646
 
647
  /**
700
  return array($image, $type);
701
  }
702
 
703
+ /**
704
+ * Prints created image directly to the browser
705
+ *
706
+ * @return boolean
707
+ */
708
+ public function printOutput(){
709
+ return $this->prepareOutput();
710
+ }
711
+
712
+ /**
713
+ * Saves created image
714
+ *
715
+ * @param string filename (required if not set earlier)
716
+ * @return boolean
717
+ */
718
+ public function saveOutput($file = null){
719
+ if(empty($file)) $file = $this->outputFile;
720
+
721
+ if(empty($file)){
722
+ $this->error = 'output file not defined';
723
+ return false;
724
+ }
725
+
726
+ return $this->prepareOutput($file);
727
+ }
728
+
729
+ /**
730
+ * Saves or outputs created image depending on $output param
731
+ *
732
+ * @param string output file
733
+ * @return boolean
734
+ */
735
+ private function prepareOutput($output = null){
736
+ $type = !empty($this->outputMime) ? $this->detectMimeType($this->outputMime) : $this->inputImageType;
737
+
738
+ if(!$type || !in_array($type, $this->allowedTypes)){
739
+ $this->error = 'invalid output type';
740
+ return false;
741
+ }
742
+
743
+ if($output === null)
744
+ // Return image directly to the browser
745
+ header('Content-Type: image/'.$type);
746
+
747
+ if($type == 'jpg') $type = 'jpeg';
748
+ $func = 'image'.$type;
749
+
750
+ if(!@$func($this->outputImage, $output)){
751
+ $this->error = 'could not create output';
752
+ return false;
753
+ }
754
+
755
+ return true;
756
+ }
757
+
758
  /**
759
  * Detects mime type using php finfo object and extracts what's needed
760
  *
EasyWatermarkPlugin.php CHANGED
@@ -1,40 +1,35 @@
1
  <?php
2
  /**
3
- This file is a part of EasyWatermark Wordpress plugin.
4
- For license informations, author name etc. see readme.txt
5
- */
 
6
 
7
  /**
8
  * Main plugin class
9
  */
10
-
11
- class EasyWatermarkPlugin
12
  {
13
- private static $version = '0.1.1';
14
-
15
- private $settings;
16
-
17
- private $messages = array();
18
 
19
- private $allowedMime = array('image/png', 'image/jpeg', 'image/gif');
 
 
 
20
 
21
  /**
22
- * Initiate plugin by creating self object,
23
- * registers activation and uninstall hooks
24
- *
25
- * @return void
26
  */
27
- public static function init(){
28
- register_activation_hook(__FILE__, array(self, 'install'));
29
- register_uninstall_hook(__FILE__, array(self, 'uninstall'));
30
 
31
- $version = get_option('easy-watermark-version');
32
- if(!$version || version_compare($version, self::$version, '<')){
33
- self::upgrade();
34
- }
35
 
36
- new self();
37
- }
 
38
 
39
  /**
40
  * Loads textdomain for translations,
@@ -42,15 +37,18 @@ class EasyWatermarkPlugin
42
  *
43
  * @return void
44
  */
45
- private function __construct(){
46
- load_plugin_textdomain('easy-watermark', false, '/easy-watermark/languages');
47
 
48
- add_action('admin_menu', array($this, 'add_media_page'));
49
- add_filter('media_row_actions', array($this, 'add_media_row_action'), 10, 3);
50
- add_filter('attachment_fields_to_edit', array($this, 'add_attachment_field'), 10, 2 );
51
- add_action('add_attachment', array($this, 'add_watermark_after_upload'));
 
 
 
52
 
53
- $this->settings = new EasyWatermarkSettings();
 
54
  }
55
 
56
  /**
@@ -96,19 +94,46 @@ class EasyWatermarkPlugin
96
  }
97
 
98
  /**
99
- * Creates 'Add watermark' button in media edit view
 
 
 
100
  *
101
  * @return array
102
  */
103
  public function add_watermark_after_upload($id){
104
- if($this->settings->get('auto_add')){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  $this->add_watermark($id);
 
 
 
106
  }
 
 
107
  }
108
 
109
  private function add_watermark($id){
110
- $watermark = $this->settings->get('image');
111
- if($watermark['path'] != ''){
112
  $post = get_post($id);
113
  $filepath = get_attached_file($id);
114
 
@@ -120,7 +145,7 @@ class EasyWatermarkPlugin
120
  return $this->create_watermark($filepath, $post->post_mime_type);
121
  }
122
  else {
123
- $this->add_error('No watermark image selected.');
124
  return false;
125
  }
126
  }
@@ -136,20 +161,20 @@ class EasyWatermarkPlugin
136
  ");
137
 
138
  $output = '';
139
- $watermark = $this->settings->get('image');
140
- if($images && $watermark['path'] != ''){
141
  foreach($images as $img){
142
  $filepath = get_attached_file($img->ID);
143
  if(!in_array($img->post_mime_type, $this->allowedMime)){
144
- $output .= $filepath.': not supported mime type. Skipping...<br/>';
145
  continue;
146
  }
147
 
148
  if($this->create_watermark($filepath, $img->post_mime_type)){
149
- $output .= $filepath.': watermark added.<br/>';
150
  }
151
  }
152
  }
 
153
 
154
  $output = '<p>'.$output.'</p>';
155
 
@@ -175,11 +200,19 @@ class EasyWatermarkPlugin
175
 
176
  public function getEasyWatermark(){
177
  if(!($ew instanceof EasyWatermark)){
178
- $settings = $this->settings->get('image');
 
179
  $ew = new EasyWatermark();
180
- $ew->set($settings)
181
- ->set('watermark_path', $settings['path'])
182
- ->set('watermark_mime', $settings['mime']);
 
 
 
 
 
 
 
183
  }
184
 
185
  return $ew;
@@ -195,7 +228,7 @@ class EasyWatermarkPlugin
195
  if($this->add_watermark($_GET['attachment_id'])) :
196
  ?>
197
  <div id="message" class="updated below-h2">
198
- <p><?php _e('Watermark successfully added.', 'easy-watermark'); ?> <a href="javascript:window.history.go(-1)"><?php _e('Go back', 'easy-watermark'); ?></a> or <a href="<?php echo get_edit_post_link($_GET['attachment_id']); ?>"><?php _e('go to edit page', 'easy-watermark'); ?></a></p>
199
  </div>
200
  <?php
201
  else :
@@ -224,41 +257,81 @@ class EasyWatermarkPlugin
224
  ?>
225
  <br/><a class="button-primary" href="<?php echo wp_nonce_url(admin_url('/upload.php?page=easy-watermark&watermark_all=1')); ?>"><?php _e('Add watermark to all images', 'easy-watermark'); ?></a><p class="description"><?php _e('Be carefull with that option. If some images alredy has watermark, it will be added though.'); ?></p>
226
  <?php
227
- $settings = $this->settings->get('image');
228
  }
229
  ?>
230
  </div>
231
  <?php
232
  }
233
 
234
- public static function install(){
235
- add_option('easy-watermark-settings', EasyWatermarkSettings::getDefaults());
236
- update_option('easy-watermark-version', self::$version);
 
 
 
 
237
  }
238
 
239
  public static function uninstall(){
240
- delete_option('easy-watermark-settings');
 
 
 
 
 
241
  }
242
 
243
- public static function upgrade(){
244
- $oldSettings = get_option('easy-watermark-settings');
245
- $settings = EasyWatermarkSettings::getDefaults();
246
 
247
- $settings['auto_add'] = $oldSettings['auto_add'];
248
- $settings['image_types'] = $oldSettings['image_types'];
249
- $settings['image']['position_x'] = $oldSettings['image']['position-horizontal'];
250
- $settings['image']['position_y'] = $oldSettings['image']['position-vert'];
251
- $settings['image']['offset_x'] = $oldSettings['image']['offset-horizontal'];
252
- $settings['image']['offset_y'] = $oldSettings['image']['offset-vert'];
253
- $settings['image']['opacity'] = $oldSettings['image']['alpha'];
254
-
255
- foreach($oldSettings['image'] as $key => $val){
256
- if(array_key_exists($key, $settings['image']))
257
- $settings['image'][$key] = $val;
258
  }
259
 
260
- update_option('easy-watermark-settings', $settings);
261
- update_option('easy-watermark-version', self::$version);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  }
263
 
264
  private function add_error($msg){
1
  <?php
2
  /**
3
+ * This file is a part of EasyWatermark Wordpress plugin.
4
+ * @see readme.txt
5
+ */
6
+ namespace szaleq\Plugins\EasyWatermark;
7
 
8
  /**
9
  * Main plugin class
10
  */
11
+ class Plugin extends Core
 
12
  {
13
+ /**
14
+ * @var string plugin name
15
+ */
16
+ protected static $pluginName = 'Easy Watermark';
 
17
 
18
+ /**
19
+ * @var string plugin slug used in setting names etc.
20
+ */
21
+ protected static $pluginSlug = 'easy-watermark';
22
 
23
  /**
24
+ * @var string plugin version
 
 
 
25
  */
26
+ protected static $version = '0.2';
 
 
27
 
28
+ private $settings;
 
 
 
29
 
30
+ private $messages = array();
31
+
32
+ private $allowedMime = array('image/png', 'image/jpeg', 'image/gif');
33
 
34
  /**
35
  * Loads textdomain for translations,
37
  *
38
  * @return void
39
  */
40
+ public function __construct(){
 
41
 
42
+ $this->add_action('admin_menu', 'add_media_page')
43
+ ->add_filter('media_row_actions', 'add_media_row_action', 10, 3)
44
+ ->add_filter('attachment_fields_to_edit', 'add_attachment_field', 10, 2)
45
+ ->add_action('add_attachment', 'add_watermark_after_upload');
46
+
47
+ new EasyWatermarkSettings($this);
48
+ }
49
 
50
+ public function setSettings($settings){
51
+ $this->settings = $settings;
52
  }
53
 
54
  /**
94
  }
95
 
96
  /**
97
+ * Watermark image after it was uploaded.
98
+ * In fact this method only mark that there is an image to watermark,
99
+ * it's realy watermarked in wp_generate_attachment_metadata filter.
100
+ * See wp_generate_attachment_metadata() method below.
101
  *
102
  * @return array
103
  */
104
  public function add_watermark_after_upload($id){
105
+ if($this->settings['general']['auto_add']){
106
+ $this->watermark_uploaded = true;
107
+ $this->uploaded_id = $id;
108
+ $this->add_filter('wp_generate_attachment_metadata', null, 10, 2);
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Filter used to add watermark
114
+ * add_attachment action is called before image resizing,
115
+ * so image was watermarked first, then resized.
116
+ * To avoid that, in add_attachment action we only mark,
117
+ * that image was uploaded and then it's watermarked in this filter
118
+ * which is called after resizing.
119
+ *
120
+ * @param array
121
+ * @param integer
122
+ * @return array
123
+ */
124
+ public function wp_generate_attachment_metadata($metadata, $id){
125
+ if($this->watermark_uploaded && $this->uploaded_id == $id){
126
  $this->add_watermark($id);
127
+
128
+ $this->watermark_uploaded = false;
129
+ $this->uploaded_id = null;
130
  }
131
+
132
+ return $metadata;
133
  }
134
 
135
  private function add_watermark($id){
136
+ if($this->settings['image']['watermark_path'] != '' || $this->settings['text']['text'] == null){
 
137
  $post = get_post($id);
138
  $filepath = get_attached_file($id);
139
 
145
  return $this->create_watermark($filepath, $post->post_mime_type);
146
  }
147
  else {
148
+ $this->add_error('No watermark image selected and no watermark text set.');
149
  return false;
150
  }
151
  }
161
  ");
162
 
163
  $output = '';
164
+ if($images && ($this->settings['image']['watermark_path'] != '' || $this->settings['text']['text'])){
 
165
  foreach($images as $img){
166
  $filepath = get_attached_file($img->ID);
167
  if(!in_array($img->post_mime_type, $this->allowedMime)){
168
+ $output .= sprintf(__('Not supported mime type of %s. Skipping...', 'easy-watermark'), '<strong>'.$filepath.'</strong>').'<br/>';
169
  continue;
170
  }
171
 
172
  if($this->create_watermark($filepath, $img->post_mime_type)){
173
+ $output .= sprintf(__('Watermark successfully added to %s', 'easy-watermark'), '<strong>'.$filepath.'</strong>') . '<br/>';
174
  }
175
  }
176
  }
177
+ else return false;
178
 
179
  $output = '<p>'.$output.'</p>';
180
 
200
 
201
  public function getEasyWatermark(){
202
  if(!($ew instanceof EasyWatermark)){
203
+ $imageSettings = $this->settings['image'];
204
+ $textSettings = $this->settings['text'];
205
  $ew = new EasyWatermark();
206
+
207
+ $fontFile = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'fonts' . DIRECTORY_SEPARATOR . $textSettings['font'];
208
+ if(file_exists($fontFile))
209
+ $textSettings['font'] = $fontFile;
210
+
211
+ $wType = $this->settings['general']['watermark_type'];
212
+ if($wType == 1 || $wType == 3)
213
+ $ew->imageSet($imageSettings);
214
+ if($wType == 2 || $wType == 3)
215
+ $ew->textSet($textSettings);
216
  }
217
 
218
  return $ew;
228
  if($this->add_watermark($_GET['attachment_id'])) :
229
  ?>
230
  <div id="message" class="updated below-h2">
231
+ <p><?php _e('Watermark successfully added.', 'easy-watermark'); ?> <a href="javascript:window.history.go(-1)"><?php _e('Go back', 'easy-watermark'); ?></a> <?php _e('or', 'easy-watermark'); ?> <a href="<?php echo get_edit_post_link($_GET['attachment_id']); ?>"><?php _e('go to edit page', 'easy-watermark'); ?></a></p>
232
  </div>
233
  <?php
234
  else :
257
  ?>
258
  <br/><a class="button-primary" href="<?php echo wp_nonce_url(admin_url('/upload.php?page=easy-watermark&watermark_all=1')); ?>"><?php _e('Add watermark to all images', 'easy-watermark'); ?></a><p class="description"><?php _e('Be carefull with that option. If some images alredy has watermark, it will be added though.'); ?></p>
259
  <?php
 
260
  }
261
  ?>
262
  </div>
263
  <?php
264
  }
265
 
266
+ public static function install($settings = null){
267
+ if(empty($settings)) $settings = EasyWatermarkSettings::getDefaults();
268
+
269
+ foreach($settings as $sectionName => $section){
270
+ update_option(static::$pluginSlug.'-settings-'.$sectionName, $section);
271
+ }
272
+ update_option(static::$pluginSlug.'-version', static::$version);
273
  }
274
 
275
  public static function uninstall(){
276
+ $settings = EasyWatermarkSettings::getDefaults();
277
+
278
+ foreach($settings as $sectionName => $section){
279
+ delete_option(static::$pluginSlug.'-settings-'.$sectionName);
280
+ }
281
+ delete_option(static::$pluginSlug.'-version');
282
  }
283
 
284
+ public static function upgrade($version){
285
+ $oldSettings = get_option(static::$pluginSlug.'-settings');
286
+ $defaults = EasyWatermarkSettings::getDefaults();
287
 
288
+ $imgTypes = array();
289
+ foreach($oldSettings['image_types'] as $type){
290
+ $imgTypes[] = $type;
 
 
 
 
 
 
 
 
291
  }
292
 
293
+ $general = array(
294
+ 'auto_add' => $oldSettings['auto_add'],
295
+ 'image_types' => $imgTypes
296
+ );
297
+
298
+ switch($version){
299
+ case '0.1.1':
300
+ $image = array(
301
+ 'watermark_url' => $oldSettings['image']['url'],
302
+ 'watermark_id' => $oldSettings['image']['id'],
303
+ 'watermark_path' => $oldSettings['image']['path'],
304
+ 'watermark_mime' => $oldSettings['image']['mime'],
305
+ 'position_x' => $oldSettings['image']['position_x'],
306
+ 'position_y' => $oldSettings['image']['position_y'],
307
+ 'offset_x' => $oldSettings['image']['offset_x'],
308
+ 'offset_y' => $oldSettings['image']['offset_y'],
309
+ 'opacity' => $oldSettings['image']['opacity']
310
+ );
311
+ break;
312
+ default:
313
+ $image = array(
314
+ 'watermark_url' => $oldSettings['image']['url'],
315
+ 'watermark_id' => $oldSettings['image']['id'],
316
+ 'watermark_path' => $oldSettings['image']['path'],
317
+ 'watermark_mime' => $oldSettings['image']['mime'],
318
+ 'position_x' => $oldSettings['image']['position-horizontal'],
319
+ 'position_y' => $oldSettings['image']['position-vert'],
320
+ 'offset_x' => $oldSettings['image']['offset-horizontal'],
321
+ 'offset_y' => $oldSettings['image']['offset-vert'],
322
+ 'opacity' => $oldSettings['image']['alpha']
323
+ );
324
+ break;
325
+ }
326
+
327
+ $settings = array(
328
+ 'general' => array_merge($defaults['general'], $general),
329
+ 'image' => array_merge($defaults['image'], $image),
330
+ 'text' => $defaults['text']
331
+ );
332
+
333
+ delete_option(static::$pluginSlug.'-settings');
334
+ static::install($settings);
335
  }
336
 
337
  private function add_error($msg){
EasyWatermarkSettings.php CHANGED
@@ -1,39 +1,80 @@
1
  <?php
 
2
 
3
  class EasyWatermarkSettings
4
  {
5
- private $tabs = array();
6
 
7
- private $options = array();
8
 
9
  private static $defaults = array(
 
10
  'auto_add' => true,
11
- 'image_types' => array('jpeg' => 'jpeg', 'png' => 'png', 'gif' => 'gif'),
12
- 'image' => array(
13
- 'url' => null,
14
- 'path' => null,
15
- 'id' => null,
16
- 'mime' => null,
17
- 'position_x' => 'ctr',
18
- 'position_y' => 'mdl',
19
- 'offset_x' => 100,
20
- 'offset_y' => 100,
21
- 'opacity' => 100,
22
- )
23
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  public static function getDefaults(){
26
  return self::$defaults;
27
  }
28
 
29
- public function __construct(){
30
 
31
  add_action('admin_menu', array($this, 'add_options_page'));
32
  add_action('admin_init', array($this, 'register_settings'));
33
-
34
  add_filter('plugin_action_links', array($this, 'settings_link'), 10, 2);
35
 
36
- $this->options = get_option('easy-watermark-settings');
 
 
 
 
 
 
 
37
  }
38
 
39
  public function get($key){
@@ -41,18 +82,20 @@ class EasyWatermarkSettings
41
  }
42
 
43
  public function add_options_page(){
44
- add_options_page(__('Easy Watermark Settings', 'easy-watermark'), __('Easy Watermark Settings', 'easy-watermark'), 'manage_options', 'easy-watermark-settings', array($this, 'settings_page'));
45
  }
46
 
47
  public function register_settings(){
48
- register_setting(
49
- 'easy-watermark-settings',
50
- 'easy-watermark-settings',
51
- array($this, 'sanitize_settings')
52
- );
 
 
53
  }
54
 
55
- public function sanitize_settings($input){
56
  if(!isset($input['auto_add']) || $input['auto_add'] !== '1'){
57
  $input['auto_add'] = false;
58
  }
@@ -61,7 +104,14 @@ class EasyWatermarkSettings
61
  $input['image_types'] = array();
62
  }
63
 
64
- if(!empty($input['image']['url'])){
 
 
 
 
 
 
 
65
  if(isset($input['old-manager'])){
66
  // old wordpress media library, we have only image url
67
  global $wpdb;
@@ -73,21 +123,25 @@ class EasyWatermarkSettings
73
  AND $wpdb->posts.guid = '{$input['image']['url']}'
74
  ");
75
 
76
- $input['image']['id'] = $row->ID;
77
- $input['image']['mime'] = $row->post_mime_type;
78
  unset($input['old-manager']);
79
  }
80
 
81
- $input['image']['path'] = get_attached_file($input['image']['id']);
82
  }
 
 
83
 
84
- $input = wp_parse_args($input, $this->options);
85
-
86
  return $input;
87
  }
88
 
89
  public function settings_page(){
 
90
  wp_enqueue_script('ew-interface', plugin_dir_url(dirname(__File__) . '/index.php') . 'js/interface.js');
 
 
91
  if(function_exists('wp_enqueue_media')){
92
  // load new media manager (since wp 3.5)
93
  wp_enqueue_media();
@@ -100,7 +154,10 @@ class EasyWatermarkSettings
100
  wp_enqueue_script('ew-media-libraby', plugin_dir_url(dirname(__File__) . '/index.php') . 'js/old-media-library.js');
101
  }
102
 
103
- $options = $this->options;
 
 
 
104
  include dirname(__File__) . '/settings-form.php';
105
  }
106
 
1
  <?php
2
+ namespace szaleq\Plugins\EasyWatermark;
3
 
4
  class EasyWatermarkSettings
5
  {
6
+ private $settings = array();
7
 
8
+ private $plugin;
9
 
10
  private static $defaults = array(
11
+ 'general' => array(
12
  'auto_add' => true,
13
+ 'image_types' => array('jpeg', 'png', 'gif'),
14
+ 'watermark_type' => 3
15
+ ),
16
+ 'image' => array(
17
+ 'watermark_url' => null,
18
+ 'watermark_id' => null,
19
+ 'watermark_path' => null,
20
+ 'watermark_mime' => null,
21
+ 'position_x' => 'ctr',
22
+ 'position_y' => 'mdl',
23
+ 'offset_x' => 100,
24
+ 'offset_y' => 100,
25
+ 'opacity' => 100
26
+ ),
27
+ 'text' => array(
28
+ 'position_x' => 'ctr',
29
+ 'position_y' => 'mdl',
30
+ 'offset_x' => 0,
31
+ 'offset_y' => 0,
32
+ 'opacity' => 60,
33
+ 'color' => '000000',
34
+ 'font' => 'arial',
35
+ 'size' => 24,
36
+ 'angle' => 0,
37
+ 'text' => ''
38
+ )
39
+ );
40
+
41
+ private $tabs = array(
42
+ 'general' => 'General',
43
+ 'image' => 'Image',
44
+ 'text' => 'Text',
45
+ );
46
+
47
+ private $fonts = array(
48
+ 'Arial.ttf' => 'Arial',
49
+ 'Arial_Black.ttf' => 'Arial Black',
50
+ 'Comic_Sans_MS.ttf' => 'Comic Sans MS',
51
+ 'Courier_New.ttf' => 'Courier New',
52
+ 'Georgia.ttf' => 'Georgia',
53
+ 'Impact.ttf' => 'Impact',
54
+ 'Tahoma.ttf' => 'Tahoma',
55
+ 'Times_New_Roman.ttf' => 'Times New Roman',
56
+ 'Trebuchet_MS.ttf' => 'Trebuchet MS',
57
+ 'Verdana.ttf' => 'Verdana',
58
+ );
59
 
60
  public static function getDefaults(){
61
  return self::$defaults;
62
  }
63
 
64
+ public function __construct($plugin){
65
 
66
  add_action('admin_menu', array($this, 'add_options_page'));
67
  add_action('admin_init', array($this, 'register_settings'));
 
68
  add_filter('plugin_action_links', array($this, 'settings_link'), 10, 2);
69
 
70
+ foreach($this->tabs as $name => $caption){
71
+ $section = get_option($plugin->getSlug() . '-settings-' . $name);
72
+ $this->settings[$name] = array_merge(self::$defaults[$name], $section);
73
+ }
74
+
75
+ $this->plugin = $plugin;
76
+
77
+ $plugin->setSettings($this->settings);
78
  }
79
 
80
  public function get($key){
82
  }
83
 
84
  public function add_options_page(){
85
+ add_options_page(__('Easy Watermark', 'easy-watermark'), __('Easy Watermark', 'easy-watermark'), 'manage_options', 'easy-watermark-settings', array($this, 'settings_page'));
86
  }
87
 
88
  public function register_settings(){
89
+ foreach($this->tabs as $name => $caption){
90
+ register_setting(
91
+ $this->plugin->getSlug() . '-settings-' . $name,
92
+ $this->plugin->getSlug() . '-settings-' . $name,
93
+ array($this, 'sanitize_settings_' . $name)
94
+ );
95
+ }
96
  }
97
 
98
+ public function sanitize_settings_general($input){
99
  if(!isset($input['auto_add']) || $input['auto_add'] !== '1'){
100
  $input['auto_add'] = false;
101
  }
104
  $input['image_types'] = array();
105
  }
106
 
107
+ $input = wp_parse_args($input, $this->options);
108
+
109
+ return $input;
110
+ }
111
+
112
+ public function sanitize_settings_image($input){
113
+
114
+ if(!empty($input['watermark_url'])){
115
  if(isset($input['old-manager'])){
116
  // old wordpress media library, we have only image url
117
  global $wpdb;
123
  AND $wpdb->posts.guid = '{$input['image']['url']}'
124
  ");
125
 
126
+ $input['watermark_id'] = $row->ID;
127
+ $input['watermark_mime'] = $row->post_mime_type;
128
  unset($input['old-manager']);
129
  }
130
 
131
+ $input['watermark_path'] = get_attached_file($input['watermark_id']);
132
  }
133
+ return $input;
134
+ }
135
 
136
+ public function sanitize_settings_text($input){
 
137
  return $input;
138
  }
139
 
140
  public function settings_page(){
141
+ wp_enqueue_script('ew-colorpicker', plugin_dir_url(dirname(__File__) . '/index.php') . 'js/colorpicker.js');
142
  wp_enqueue_script('ew-interface', plugin_dir_url(dirname(__File__) . '/index.php') . 'js/interface.js');
143
+ wp_enqueue_style('ew-style', plugin_dir_url(dirname(__File__) . '/index.php') . 'css/style.css');
144
+ wp_enqueue_style('ew-cp-style', plugin_dir_url(dirname(__File__) . '/index.php') . 'css/colorpicker.css');
145
  if(function_exists('wp_enqueue_media')){
146
  // load new media manager (since wp 3.5)
147
  wp_enqueue_media();
154
  wp_enqueue_script('ew-media-libraby', plugin_dir_url(dirname(__File__) . '/index.php') . 'js/old-media-library.js');
155
  }
156
 
157
+ $fonts = $this->fonts;
158
+
159
+ $current_tab = (isset($_GET['tab']) && array_key_exists($_GET['tab'], $this->tabs)) ? $_GET['tab'] : 'general';
160
+ extract($this->settings[$current_tab]);
161
  include dirname(__File__) . '/settings-form.php';
162
  }
163
 
css/colorpicker.css ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .colorpicker {
2
+ width: 356px;
3
+ height: 176px;
4
+ overflow: hidden;
5
+ position: absolute;
6
+ background: url(../images/colorpicker_background.png);
7
+ font-family: Arial, Helvetica, sans-serif;
8
+ display: none;
9
+ }
10
+ .colorpicker_color {
11
+ width: 150px;
12
+ height: 150px;
13
+ left: 14px;
14
+ top: 13px;
15
+ position: absolute;
16
+ background: #f00;
17
+ overflow: hidden;
18
+ cursor: crosshair;
19
+ }
20
+ .colorpicker_color div {
21
+ position: absolute;
22
+ top: 0;
23
+ left: 0;
24
+ width: 150px;
25
+ height: 150px;
26
+ background: url(../images/colorpicker_overlay.png);
27
+ }
28
+ .colorpicker_color div div {
29
+ position: absolute;
30
+ top: 0;
31
+ left: 0;
32
+ width: 11px;
33
+ height: 11px;
34
+ overflow: hidden;
35
+ background: url(../images/colorpicker_select.gif);
36
+ margin: -5px 0 0 -5px;
37
+ }
38
+ .colorpicker_hue {
39
+ position: absolute;
40
+ top: 13px;
41
+ left: 171px;
42
+ width: 35px;
43
+ height: 150px;
44
+ cursor: n-resize;
45
+ }
46
+ .colorpicker_hue div {
47
+ position: absolute;
48
+ width: 35px;
49
+ height: 9px;
50
+ overflow: hidden;
51
+ background: url(../images/colorpicker_indic.gif) left top;
52
+ margin: -4px 0 0 0;
53
+ left: 0px;
54
+ }
55
+ .colorpicker_new_color {
56
+ position: absolute;
57
+ width: 60px;
58
+ height: 30px;
59
+ left: 213px;
60
+ top: 13px;
61
+ background: #f00;
62
+ }
63
+ .colorpicker_current_color {
64
+ position: absolute;
65
+ width: 60px;
66
+ height: 30px;
67
+ left: 283px;
68
+ top: 13px;
69
+ background: #f00;
70
+ }
71
+ .colorpicker input {
72
+ background-color: transparent;
73
+ border: 1px solid transparent;
74
+ position: absolute;
75
+ font-size: 10px;
76
+ font-family: Arial, Helvetica, sans-serif;
77
+ color: #898989;
78
+ top: 4px;
79
+ right: 11px;
80
+ text-align: right;
81
+ margin: 0;
82
+ padding: 0;
83
+ height: 11px;
84
+ }
85
+ .colorpicker_hex {
86
+ position: absolute;
87
+ width: 72px;
88
+ height: 22px;
89
+ background: url(../images/colorpicker_hex.png) top;
90
+ left: 212px;
91
+ top: 142px;
92
+ }
93
+ .colorpicker_hex input {
94
+ right: 6px;
95
+ }
96
+ .colorpicker_field {
97
+ height: 22px;
98
+ width: 62px;
99
+ background-position: top;
100
+ position: absolute;
101
+ }
102
+ .colorpicker_field span {
103
+ position: absolute;
104
+ width: 12px;
105
+ height: 22px;
106
+ overflow: hidden;
107
+ top: 0;
108
+ right: 0;
109
+ cursor: n-resize;
110
+ }
111
+ .colorpicker_rgb_r {
112
+ background-image: url(../images/colorpicker_rgb_r.png);
113
+ top: 52px;
114
+ left: 212px;
115
+ }
116
+ .colorpicker_rgb_g {
117
+ background-image: url(../images/colorpicker_rgb_g.png);
118
+ top: 82px;
119
+ left: 212px;
120
+ }
121
+ .colorpicker_rgb_b {
122
+ background-image: url(../images/colorpicker_rgb_b.png);
123
+ top: 112px;
124
+ left: 212px;
125
+ }
126
+ .colorpicker_hsb_h {
127
+ background-image: url(../images/colorpicker_hsb_h.png);
128
+ top: 52px;
129
+ left: 282px;
130
+ }
131
+ .colorpicker_hsb_s {
132
+ background-image: url(../images/colorpicker_hsb_s.png);
133
+ top: 82px;
134
+ left: 282px;
135
+ }
136
+ .colorpicker_hsb_b {
137
+ background-image: url(../images/colorpicker_hsb_b.png);
138
+ top: 112px;
139
+ left: 282px;
140
+ }
141
+ .colorpicker_submit {
142
+ position: absolute;
143
+ width: 22px;
144
+ height: 22px;
145
+ background: url(../images/colorpicker_submit.png) top;
146
+ left: 322px;
147
+ top: 142px;
148
+ overflow: hidden;
149
+ }
150
+ .colorpicker_focus {
151
+ background-position: center;
152
+ }
153
+ .colorpicker_hex.colorpicker_focus {
154
+ background-position: bottom;
155
+ }
156
+ .colorpicker_submit.colorpicker_focus {
157
+ background-position: bottom;
158
+ }
159
+ .colorpicker_slider {
160
+ background-position: bottom;
161
+ }
css/style.css ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #colorselector {
2
+ width:36px;
3
+ height:36px;
4
+ background:url(../images/select2.png);
5
+ display:inline-block;
6
+ vertical-align:middle;
7
+ position:relative;
8
+ }
9
+
10
+ #colorselector div {
11
+ width:28px;
12
+ height:28px;
13
+ margin:4px;
14
+ position:absolute;
15
+ background:url(../images/select2.png) 50% 50%;
16
+ }
fonts/Arial.ttf ADDED
Binary file
fonts/Arial_Black.ttf ADDED
Binary file
fonts/Comic_Sans_MS.ttf ADDED
Binary file
fonts/Courier_New.ttf ADDED
Binary file
fonts/Georgia.ttf ADDED
Binary file
fonts/Impact.ttf ADDED
Binary file
fonts/Tahoma.ttf ADDED
Binary file
fonts/Times_New_Roman.ttf ADDED
Binary file
fonts/Trebuchet_MS.ttf ADDED
Binary file
fonts/Verdana.ttf ADDED
Binary file
images/Thumbs.db ADDED
Binary file
images/blank.gif ADDED
Binary file
images/colorpicker_background.png ADDED
Binary file
images/colorpicker_hex.png ADDED
Binary file
images/colorpicker_hsb_b.png ADDED
Binary file
images/colorpicker_hsb_h.png ADDED
Binary file
images/colorpicker_hsb_s.png ADDED
Binary file
images/colorpicker_indic.gif ADDED
Binary file
images/colorpicker_overlay.png ADDED
Binary file
images/colorpicker_rgb_b.png ADDED
Binary file
images/colorpicker_rgb_g.png ADDED
Binary file
images/colorpicker_rgb_r.png ADDED
Binary file
images/colorpicker_select.gif ADDED
Binary file
images/colorpicker_submit.png ADDED
Binary file
images/custom_background.png ADDED
Binary file
images/custom_hex.png ADDED
Binary file
images/custom_hsb_b.png ADDED
Binary file
images/custom_hsb_h.png ADDED
Binary file
images/custom_hsb_s.png ADDED
Binary file
images/custom_indic.gif ADDED
Binary file
images/custom_rgb_b.png ADDED
Binary file
images/custom_rgb_g.png ADDED
Binary file
images/custom_rgb_r.png ADDED
Binary file
images/custom_submit.png ADDED
Binary file
images/select.png ADDED
Binary file
images/select2.png ADDED
Binary file
images/slider.png ADDED
Binary file
index.php CHANGED
@@ -1,17 +1,20 @@
1
  <?php
2
  /*
3
  Plugin Name: Easy Watermark
4
- Description: This plugin allows you to add image watermark to every single image or all images from library at once. It can also be configured to automatically watermark new images as they are uploaded. Watermark can be a png, gif (alpha channel supported in both cases) or jpg image. It's also possibile to set watermark opacity (doesn't apply to png with alpha channel).
5
- Version: 0.1.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
  require_once dirname(__FILE__) . '/EasyWatermark.php';
12
  require_once dirname(__FILE__) . '/EasyWatermarkPlugin.php';
13
  require_once dirname(__FILE__) . '/EasyWatermarkSettings.php';
14
 
15
  if(is_admin())
16
  // init plugin only in admin panel
17
- EasyWatermarkPlugin::init();
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
+ Version: 0.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
+ namespace szaleq\Plugins;
12
+
13
+ require_once dirname(__FILE__) . '/plugin.php';
14
  require_once dirname(__FILE__) . '/EasyWatermark.php';
15
  require_once dirname(__FILE__) . '/EasyWatermarkPlugin.php';
16
  require_once dirname(__FILE__) . '/EasyWatermarkSettings.php';
17
 
18
  if(is_admin())
19
  // init plugin only in admin panel
20
+ EasyWatermark\Plugin::init();
js/colorpicker.js ADDED
@@ -0,0 +1,484 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ *
3
+ * Color picker
4
+ * Author: Stefan Petre www.eyecon.ro
5
+ *
6
+ * Dual licensed under the MIT and GPL licenses
7
+ *
8
+ */
9
+ (function ($) {
10
+ var ColorPicker = function () {
11
+ var
12
+ ids = {},
13
+ inAction,
14
+ charMin = 65,
15
+ visible,
16
+ tpl = '<div class="colorpicker"><div class="colorpicker_color"><div><div></div></div></div><div class="colorpicker_hue"><div></div></div><div class="colorpicker_new_color"></div><div class="colorpicker_current_color"></div><div class="colorpicker_hex"><input type="text" maxlength="6" size="6" /></div><div class="colorpicker_rgb_r colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_g colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_h colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_s colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_submit"></div></div>',
17
+ defaults = {
18
+ eventName: 'click',
19
+ onShow: function () {},
20
+ onBeforeShow: function(){},
21
+ onHide: function () {},
22
+ onChange: function () {},
23
+ onSubmit: function () {},
24
+ color: 'ff0000',
25
+ livePreview: true,
26
+ flat: false
27
+ },
28
+ fillRGBFields = function (hsb, cal) {
29
+ var rgb = HSBToRGB(hsb);
30
+ $(cal).data('colorpicker').fields
31
+ .eq(1).val(rgb.r).end()
32
+ .eq(2).val(rgb.g).end()
33
+ .eq(3).val(rgb.b).end();
34
+ },
35
+ fillHSBFields = function (hsb, cal) {
36
+ $(cal).data('colorpicker').fields
37
+ .eq(4).val(hsb.h).end()
38
+ .eq(5).val(hsb.s).end()
39
+ .eq(6).val(hsb.b).end();
40
+ },
41
+ fillHexFields = function (hsb, cal) {
42
+ $(cal).data('colorpicker').fields
43
+ .eq(0).val(HSBToHex(hsb)).end();
44
+ },
45
+ setSelector = function (hsb, cal) {
46
+ $(cal).data('colorpicker').selector.css('backgroundColor', '#' + HSBToHex({h: hsb.h, s: 100, b: 100}));
47
+ $(cal).data('colorpicker').selectorIndic.css({
48
+ left: parseInt(150 * hsb.s/100, 10),
49
+ top: parseInt(150 * (100-hsb.b)/100, 10)
50
+ });
51
+ },
52
+ setHue = function (hsb, cal) {
53
+ $(cal).data('colorpicker').hue.css('top', parseInt(150 - 150 * hsb.h/360, 10));
54
+ },
55
+ setCurrentColor = function (hsb, cal) {
56
+ $(cal).data('colorpicker').currentColor.css('backgroundColor', '#' + HSBToHex(hsb));
57
+ },
58
+ setNewColor = function (hsb, cal) {
59
+ $(cal).data('colorpicker').newColor.css('backgroundColor', '#' + HSBToHex(hsb));
60
+ },
61
+ keyDown = function (ev) {
62
+ var pressedKey = ev.charCode || ev.keyCode || -1;
63
+ if ((pressedKey > charMin && pressedKey <= 90) || pressedKey == 32) {
64
+ return false;
65
+ }
66
+ var cal = $(this).parent().parent();
67
+ if (cal.data('colorpicker').livePreview === true) {
68
+ change.apply(this);
69
+ }
70
+ },
71
+ change = function (ev) {
72
+ var cal = $(this).parent().parent(), col;
73
+ if (this.parentNode.className.indexOf('_hex') > 0) {
74
+ cal.data('colorpicker').color = col = HexToHSB(fixHex(this.value));
75
+ } else if (this.parentNode.className.indexOf('_hsb') > 0) {
76
+ cal.data('colorpicker').color = col = fixHSB({
77
+ h: parseInt(cal.data('colorpicker').fields.eq(4).val(), 10),
78
+ s: parseInt(cal.data('colorpicker').fields.eq(5).val(), 10),
79
+ b: parseInt(cal.data('colorpicker').fields.eq(6).val(), 10)
80
+ });
81
+ } else {
82
+ cal.data('colorpicker').color = col = RGBToHSB(fixRGB({
83
+ r: parseInt(cal.data('colorpicker').fields.eq(1).val(), 10),
84
+ g: parseInt(cal.data('colorpicker').fields.eq(2).val(), 10),
85
+ b: parseInt(cal.data('colorpicker').fields.eq(3).val(), 10)
86
+ }));
87
+ }
88
+ if (ev) {
89
+ fillRGBFields(col, cal.get(0));
90
+ fillHexFields(col, cal.get(0));
91
+ fillHSBFields(col, cal.get(0));
92
+ }
93
+ setSelector(col, cal.get(0));
94
+ setHue(col, cal.get(0));
95
+ setNewColor(col, cal.get(0));
96
+ cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col)]);
97
+ },
98
+ blur = function (ev) {
99
+ var cal = $(this).parent().parent();
100
+ cal.data('colorpicker').fields.parent().removeClass('colorpicker_focus');
101
+ },
102
+ focus = function () {
103
+ charMin = this.parentNode.className.indexOf('_hex') > 0 ? 70 : 65;
104
+ $(this).parent().parent().data('colorpicker').fields.parent().removeClass('colorpicker_focus');
105
+ $(this).parent().addClass('colorpicker_focus');
106
+ },
107
+ downIncrement = function (ev) {
108
+ var field = $(this).parent().find('input').focus();
109
+ var current = {
110
+ el: $(this).parent().addClass('colorpicker_slider'),
111
+ max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
112
+ y: ev.pageY,
113
+ field: field,
114
+ val: parseInt(field.val(), 10),
115
+ preview: $(this).parent().parent().data('colorpicker').livePreview
116
+ };
117
+ $(document).bind('mouseup', current, upIncrement);
118
+ $(document).bind('mousemove', current, moveIncrement);
119
+ },
120
+ moveIncrement = function (ev) {
121
+ ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val + ev.pageY - ev.data.y, 10))));
122
+ if (ev.data.preview) {
123
+ change.apply(ev.data.field.get(0), [true]);
124
+ }
125
+ return false;
126
+ },
127
+ upIncrement = function (ev) {
128
+ change.apply(ev.data.field.get(0), [true]);
129
+ ev.data.el.removeClass('colorpicker_slider').find('input').focus();
130
+ $(document).unbind('mouseup', upIncrement);
131
+ $(document).unbind('mousemove', moveIncrement);
132
+ return false;
133
+ },
134
+ downHue = function (ev) {
135
+ var current = {
136
+ cal: $(this).parent(),
137
+ y: $(this).offset().top
138
+ };
139
+ current.preview = current.cal.data('colorpicker').livePreview;
140
+ $(document).bind('mouseup', current, upHue);
141
+ $(document).bind('mousemove', current, moveHue);
142
+ },
143
+ moveHue = function (ev) {
144
+ change.apply(
145
+ ev.data.cal.data('colorpicker')
146
+ .fields
147
+ .eq(4)
148
+ .val(parseInt(360*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.y))))/150, 10))
149
+ .get(0),
150
+ [ev.data.preview]
151
+ );
152
+ return false;
153
+ },
154
+ upHue = function (ev) {
155
+ fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
156
+ fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
157
+ $(document).unbind('mouseup', upHue);
158
+ $(document).unbind('mousemove', moveHue);
159
+ return false;
160
+ },
161
+ downSelector = function (ev) {
162
+ var current = {
163
+ cal: $(this).parent(),
164
+ pos: $(this).offset()
165
+ };
166
+ current.preview = current.cal.data('colorpicker').livePreview;
167
+ $(document).bind('mouseup', current, upSelector);
168
+ $(document).bind('mousemove', current, moveSelector);
169
+ },
170
+ moveSelector = function (ev) {
171
+ change.apply(
172
+ ev.data.cal.data('colorpicker')
173
+ .fields
174
+ .eq(6)
175
+ .val(parseInt(100*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.pos.top))))/150, 10))
176
+ .end()
177
+ .eq(5)
178
+ .val(parseInt(100*(Math.max(0,Math.min(150,(ev.pageX - ev.data.pos.left))))/150, 10))
179
+ .get(0),
180
+ [ev.data.preview]
181
+ );
182
+ return false;
183
+ },
184
+ upSelector = function (ev) {
185
+ fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
186
+ fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
187
+ $(document).unbind('mouseup', upSelector);
188
+ $(document).unbind('mousemove', moveSelector);
189
+ return false;
190
+ },
191
+ enterSubmit = function (ev) {
192
+ $(this).addClass('colorpicker_focus');
193
+ },
194
+ leaveSubmit = function (ev) {
195
+ $(this).removeClass('colorpicker_focus');
196
+ },
197
+ clickSubmit = function (ev) {
198
+ var cal = $(this).parent();
199
+ var col = cal.data('colorpicker').color;
200
+ cal.data('colorpicker').origColor = col;
201
+ setCurrentColor(col, cal.get(0));
202
+ cal.data('colorpicker').onSubmit(col, HSBToHex(col), HSBToRGB(col), cal.data('colorpicker').el);
203
+ },
204
+ show = function (ev) {
205
+ var cal = $('#' + $(this).data('colorpickerId'));
206
+ cal.data('colorpicker').onBeforeShow.apply(this, [cal.get(0)]);
207
+ var pos = $(this).offset();
208
+ var viewPort = getViewport();
209
+ var top = pos.top + this.offsetHeight;
210
+ var left = pos.left;
211
+ if (top + 176 > viewPort.t + viewPort.h) {
212
+ top -= this.offsetHeight + 176;
213
+ }
214
+ if (left + 356 > viewPort.l + viewPort.w) {
215
+ left -= 356;
216
+ }
217
+ cal.css({left: left + 'px', top: top + 'px'});
218
+ if (cal.data('colorpicker').onShow.apply(this, [cal.get(0)]) != false) {
219
+ cal.show();
220
+ }
221
+ $(document).bind('mousedown', {cal: cal}, hide);
222
+ return false;
223
+ },
224
+ hide = function (ev) {
225
+ if (!isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
226
+ if (ev.data.cal.data('colorpicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
227
+ ev.data.cal.hide();
228
+ }
229
+ $(document).unbind('mousedown', hide);
230
+ }
231
+ },
232
+ isChildOf = function(parentEl, el, container) {
233
+ if (parentEl == el) {
234
+ return true;
235
+ }
236
+ if (parentEl.contains) {
237
+ return parentEl.contains(el);
238
+ }
239
+ if ( parentEl.compareDocumentPosition ) {
240
+ return !!(parentEl.compareDocumentPosition(el) & 16);
241
+ }
242
+ var prEl = el.parentNode;
243
+ while(prEl && prEl != container) {
244
+ if (prEl == parentEl)
245
+ return true;
246
+ prEl = prEl.parentNode;
247
+ }
248
+ return false;
249
+ },
250
+ getViewport = function () {
251
+ var m = document.compatMode == 'CSS1Compat';
252
+ return {
253
+ l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
254
+ t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
255
+ w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
256
+ h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
257
+ };
258
+ },
259
+ fixHSB = function (hsb) {
260
+ return {
261
+ h: Math.min(360, Math.max(0, hsb.h)),
262
+ s: Math.min(100, Math.max(0, hsb.s)),
263
+ b: Math.min(100, Math.max(0, hsb.b))
264
+ };
265
+ },
266
+ fixRGB = function (rgb) {
267
+ return {
268
+ r: Math.min(255, Math.max(0, rgb.r)),
269
+ g: Math.min(255, Math.max(0, rgb.g)),
270
+ b: Math.min(255, Math.max(0, rgb.b))
271
+ };
272
+ },
273
+ fixHex = function (hex) {
274
+ var len = 6 - hex.length;
275
+ if (len > 0) {
276
+ var o = [];
277
+ for (var i=0; i<len; i++) {
278
+ o.push('0');
279
+ }
280
+ o.push(hex);
281
+ hex = o.join('');
282
+ }
283
+ return hex;
284
+ },
285
+ HexToRGB = function (hex) {
286
+ var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
287
+ return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
288
+ },
289
+ HexToHSB = function (hex) {
290
+ return RGBToHSB(HexToRGB(hex));
291
+ },
292
+ RGBToHSB = function (rgb) {
293
+ var hsb = {
294
+ h: 0,
295
+ s: 0,
296
+ b: 0
297
+ };
298
+ var min = Math.min(rgb.r, rgb.g, rgb.b);
299
+ var max = Math.max(rgb.r, rgb.g, rgb.b);
300
+ var delta = max - min;
301
+ hsb.b = max;
302
+ if (max != 0) {
303
+
304
+ }
305
+ hsb.s = max != 0 ? 255 * delta / max : 0;
306
+ if (hsb.s != 0) {
307
+ if (rgb.r == max) {
308
+ hsb.h = (rgb.g - rgb.b) / delta;
309
+ } else if (rgb.g == max) {
310
+ hsb.h = 2 + (rgb.b - rgb.r) / delta;
311
+ } else {
312
+ hsb.h = 4 + (rgb.r - rgb.g) / delta;
313
+ }
314
+ } else {
315
+ hsb.h = -1;
316
+ }
317
+ hsb.h *= 60;
318
+ if (hsb.h < 0) {
319
+ hsb.h += 360;
320
+ }
321
+ hsb.s *= 100/255;
322
+ hsb.b *= 100/255;
323
+ return hsb;
324
+ },
325
+ HSBToRGB = function (hsb) {
326
+ var rgb = {};
327
+ var h = Math.round(hsb.h);
328
+ var s = Math.round(hsb.s*255/100);
329
+ var v = Math.round(hsb.b*255/100);
330
+ if(s == 0) {
331
+ rgb.r = rgb.g = rgb.b = v;
332
+ } else {
333
+ var t1 = v;
334
+ var t2 = (255-s)*v/255;
335
+ var t3 = (t1-t2)*(h%60)/60;
336
+ if(h==360) h = 0;
337
+ if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
338
+ else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
339
+ else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
340
+ else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
341
+ else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
342
+ else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
343
+ else {rgb.r=0; rgb.g=0; rgb.b=0}
344
+ }
345
+ return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
346
+ },
347
+ RGBToHex = function (rgb) {
348
+ var hex = [
349
+ rgb.r.toString(16),
350
+ rgb.g.toString(16),
351
+ rgb.b.toString(16)
352
+ ];
353
+ $.each(hex, function (nr, val) {
354
+ if (val.length == 1) {
355
+ hex[nr] = '0' + val;
356
+ }
357
+ });
358
+ return hex.join('');
359
+ },
360
+ HSBToHex = function (hsb) {
361
+ return RGBToHex(HSBToRGB(hsb));
362
+ },
363
+ restoreOriginal = function () {
364
+ var cal = $(this).parent();
365
+ var col = cal.data('colorpicker').origColor;
366
+ cal.data('colorpicker').color = col;
367
+ fillRGBFields(col, cal.get(0));
368
+ fillHexFields(col, cal.get(0));
369
+ fillHSBFields(col, cal.get(0));
370
+ setSelector(col, cal.get(0));
371
+ setHue(col, cal.get(0));
372
+ setNewColor(col, cal.get(0));
373
+ };
374
+ return {
375
+ init: function (opt) {
376
+ opt = $.extend({}, defaults, opt||{});
377
+ if (typeof opt.color == 'string') {
378
+ opt.color = HexToHSB(opt.color);
379
+ } else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
380
+ opt.color = RGBToHSB(opt.color);
381
+ } else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) {
382
+ opt.color = fixHSB(opt.color);
383
+ } else {
384
+ return this;
385
+ }
386
+ return this.each(function () {
387
+ if (!$(this).data('colorpickerId')) {
388
+ var options = $.extend({}, opt);
389
+ options.origColor = opt.color;
390
+ var id = 'collorpicker_' + parseInt(Math.random() * 1000);
391
+ $(this).data('colorpickerId', id);
392
+ var cal = $(tpl).attr('id', id);
393
+ if (options.flat) {
394
+ cal.appendTo(this).show();
395
+ } else {
396
+ cal.appendTo(document.body);
397
+ }
398
+ options.fields = cal
399
+ .find('input')
400
+ .bind('keyup', keyDown)
401
+ .bind('change', change)
402
+ .bind('blur', blur)
403
+ .bind('focus', focus);
404
+ cal
405
+ .find('span').bind('mousedown', downIncrement).end()
406
+ .find('>div.colorpicker_current_color').bind('click', restoreOriginal);
407
+ options.selector = cal.find('div.colorpicker_color').bind('mousedown', downSelector);
408
+ options.selectorIndic = options.selector.find('div div');
409
+ options.el = this;
410
+ options.hue = cal.find('div.colorpicker_hue div');
411
+ cal.find('div.colorpicker_hue').bind('mousedown', downHue);
412
+ options.newColor = cal.find('div.colorpicker_new_color');
413
+ options.currentColor = cal.find('div.colorpicker_current_color');
414
+ cal.data('colorpicker', options);
415
+ cal.find('div.colorpicker_submit')
416
+ .bind('mouseenter', enterSubmit)
417
+ .bind('mouseleave', leaveSubmit)
418
+ .bind('click', clickSubmit);
419
+ fillRGBFields(options.color, cal.get(0));
420
+ fillHSBFields(options.color, cal.get(0));
421
+ fillHexFields(options.color, cal.get(0));
422
+ setHue(options.color, cal.get(0));
423
+ setSelector(options.color, cal.get(0));
424
+ setCurrentColor(options.color, cal.get(0));
425
+ setNewColor(options.color, cal.get(0));
426
+ if (options.flat) {
427
+ cal.css({
428
+ position: 'relative',
429
+ display: 'block'
430
+ });
431
+ } else {
432
+ $(this).bind(options.eventName, show);
433
+ }
434
+ }
435
+ });
436
+ },
437
+ showPicker: function() {
438
+ return this.each( function () {
439
+ if ($(this).data('colorpickerId')) {
440
+ show.apply(this);
441
+ }
442
+ });
443
+ },
444
+ hidePicker: function() {
445
+ return this.each( function () {
446
+ if ($(this).data('colorpickerId')) {
447
+ $('#' + $(this).data('colorpickerId')).hide();
448
+ }
449
+ });
450
+ },
451
+ setColor: function(col) {
452
+ if (typeof col == 'string') {
453
+ col = HexToHSB(col);
454
+ } else if (col.r != undefined && col.g != undefined && col.b != undefined) {
455
+ col = RGBToHSB(col);
456
+ } else if (col.h != undefined && col.s != undefined && col.b != undefined) {
457
+ col = fixHSB(col);
458
+ } else {
459
+ return this;
460
+ }
461
+ return this.each(function(){
462
+ if ($(this).data('colorpickerId')) {
463
+ var cal = $('#' + $(this).data('colorpickerId'));
464
+ cal.data('colorpicker').color = col;
465
+ cal.data('colorpicker').origColor = col;
466
+ fillRGBFields(col, cal.get(0));
467
+ fillHSBFields(col, cal.get(0));
468
+ fillHexFields(col, cal.get(0));
469
+ setHue(col, cal.get(0));
470
+ setSelector(col, cal.get(0));
471
+ setCurrentColor(col, cal.get(0));
472
+ setNewColor(col, cal.get(0));
473
+ }
474
+ });
475
+ }
476
+ };
477
+ }();
478
+ $.fn.extend({
479
+ ColorPicker: ColorPicker.init,
480
+ ColorPickerHide: ColorPicker.hidePicker,
481
+ ColorPickerShow: ColorPicker.showPicker,
482
+ ColorPickerSetColor: ColorPicker.setColor
483
+ });
484
+ })(jQuery)
js/interface.js CHANGED
@@ -18,4 +18,14 @@
18
  $('#easy-watermark-mime').val('');
19
  $('#easy-watermark-settings-form').submit();
20
  });
 
 
 
 
 
 
 
 
 
 
21
  }(jQuery))
18
  $('#easy-watermark-mime').val('');
19
  $('#easy-watermark-settings-form').submit();
20
  });
21
+
22
+ $('#colorselector').ColorPicker({
23
+ onSubmit: function(hsb, hex, rgb, el){
24
+ $('#easy-watermark-color').val(hex);
25
+ $('#colorselector div').css('backgroundColor', '#' + hex);
26
+ },
27
+ onBeforeShow: function () {
28
+ $(this).ColorPickerSetColor($(this).attr('data-color'));
29
+ }
30
+ });
31
  }(jQuery))
languages/easy-watermark-pl_PL.mo CHANGED
Binary file
languages/easy-watermark-pl_PL.po CHANGED
@@ -1,172 +1,232 @@
1
  msgid ""
2
  msgstr ""
3
- "Project-Id-Version: Easy Watermark 0.1\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2013-03-21 20:55+0100\n"
6
- "PO-Revision-Date: 2013-03-21 21:03+0100\n"
7
  "Last-Translator: Wojtek Szałkiewicz <wojtek@szalkiewicz.pl>\n"
8
- "Language-Team: Wojtek Szałkiewicz <szaleq@gmail.com>\n"
9
- "Language: \n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
- "X-Poedit-KeywordsList: __;_e\n"
14
- "X-Poedit-Basepath: .\n"
15
- "X-Poedit-Language: polish\n"
16
- "X-Poedit-SearchPath-0: /media/szaleq/Data/easy-watermark/0.1\n"
17
 
18
- #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark-settings.php:116
19
- msgid "Settings"
20
- msgstr "Ustawienia"
21
-
22
- #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:33
23
  msgid "Add watermark"
24
  msgstr "Dodaj znak wodny"
25
 
26
- #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:190
 
 
 
 
 
 
 
 
 
 
 
27
  msgid "Easy Watermark"
28
  msgstr ""
29
 
30
- #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:197
31
- #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:215
32
  msgid "Watermark successfully added."
33
  msgstr "Znak wodny został dodany."
34
 
35
- #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:197
36
- #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:206
37
  msgid "Go back"
38
  msgstr "Wróć"
39
 
40
- #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:197
41
- #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:206
 
 
 
 
42
  msgid "go to edit page"
43
  msgstr "idź na stronę edycji"
44
 
45
- #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:215
46
  msgid "Go to Media Library"
47
  msgstr "Idź do biblioteki mediów"
48
 
49
- #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:224
50
  msgid "Add watermark to all images"
51
  msgstr "Dodaj znak wodny do wszystkich obrazów"
52
 
53
- #: /media/szaleq/Data/easy-watermark/0.1/easy-watermark.php:224
54
  msgid "Be carefull with that option. If some images alredy has watermark, it will be added though."
55
- msgstr "Bądź ostrożny używając tej opcji. Jeśli jakieś zdjęcia mają już znak wodny, zostanie on dodany po raz drugi."
56
-
57
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:6
58
- msgid "Easy Watermark Settings"
59
- msgstr "Ustawienia Easy Watermark"
60
-
61
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:6
62
- msgid "Go to Easy Watermark Tool"
63
- msgstr "Otwórz Easy Watermark"
64
 
65
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:9
66
- msgid "General settings"
67
- msgstr "Ustawienia główne"
68
 
69
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:11
70
  msgid "Auto watermark"
71
  msgstr "Automatyczne dodawanie"
72
 
73
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:12
74
  msgid "Add watermark when uploading images"
75
  msgstr "Dodawaj znak wodny podczas wgrywania obrazów"
76
 
77
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:14
78
  msgid "Image types"
79
  msgstr "Typy obrazów"
80
 
81
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:18
82
  msgid "Select image types which should be watermarked"
83
  msgstr "Zaznacz typy obrazów, które mają być oznaczane znakiem wodnym"
84
 
85
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:21
86
- msgid "Watermark settings"
87
- msgstr "Ustawienia znaku wodnego"
 
 
 
 
88
 
89
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:23
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  msgid "Watermark image"
91
  msgstr "Znak wodny"
92
 
93
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:32
94
  msgid "Choose Watermark Image"
95
  msgstr "Wybierz znak wodny"
96
 
97
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:32
98
  msgid "Set as Watermark Image"
99
  msgstr "Ustaw jako znak wodny"
100
 
101
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:32
102
  msgid "Select/Upload Image"
103
  msgstr "Wybierz/wgraj obraz"
104
 
105
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:40
106
  msgid "Loading preview..."
107
  msgstr "Ładowanie podglądu..."
108
 
109
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:41
110
  msgid "Click on image to change it."
111
  msgstr "Kliknij na obraz by go zmienić."
112
 
113
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:41
114
  msgid "Remove image"
115
  msgstr "Usuń obraz"
116
 
117
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:42
118
  msgid "Note: if \"Auto watermark\" option is ticked, untick it before uploading new watermark image or remove current image first."
119
  msgstr "Uwaga: Jeśli opcja \"Automatycznie dodawanie\" jest zaznaczona, odznacz ją przed wgrywaniem nowego znaku wodnego lub usuń najpierw bieżący znak wodny."
120
 
121
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:46
122
- msgid "Watermark position"
123
- msgstr "Pozycja znaku"
124
 
125
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:47
 
126
  msgid "vertical"
127
  msgstr "pionowa"
128
 
129
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:48
 
130
  msgid "top"
131
  msgstr "góra"
132
 
133
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:49
 
134
  msgid "middle"
135
  msgstr "środek"
136
 
137
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:50
 
138
  msgid "bottom"
139
  msgstr "dół"
140
 
141
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:51
 
142
  msgid "offset"
143
  msgstr ""
144
 
145
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:52
 
146
  msgid "horizontal"
147
  msgstr "pozioma"
148
 
149
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:53
 
150
  msgid "left"
151
  msgstr "do lewej"
152
 
153
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:54
 
154
  msgid "center"
155
  msgstr "wyśrodkowany"
156
 
157
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:55
 
158
  msgid "right"
159
  msgstr "do prawej"
160
 
161
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:60
 
 
 
 
 
 
162
  msgid "Opacity"
163
  msgstr "Nieprzezroczystość"
164
 
165
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:60
166
- msgid "Opacity does not affect the png images with alpha chanel."
167
  msgstr "Ta opcja nie dotyczy obrazów png posiadających kanał alfa."
168
 
169
- #: /media/szaleq/Data/easy-watermark/0.1/settings-form.php:66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  msgid "Save Changes"
171
  msgstr "Zapisz zmiany"
172
 
1
  msgid ""
2
  msgstr ""
3
+ "Project-Id-Version: Easy Watermark 0.2\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2013-03-29 22:55+0100\n"
6
+ "PO-Revision-Date: 2013-03-29 23:05+0100\n"
7
  "Last-Translator: Wojtek Szałkiewicz <wojtek@szalkiewicz.pl>\n"
8
+ "Language-Team: Wojtek Szałkiewicz <wojtek@szalkiewicz.pl>\n"
9
+ "Language: Polish\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
 
 
 
 
13
 
14
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:71
15
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:87
 
 
 
16
  msgid "Add watermark"
17
  msgstr "Dodaj znak wodny"
18
 
19
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:168
20
+ #, php-format
21
+ msgid "Not supported mime type of %s. Skipping..."
22
+ msgstr "Nieobsługiwany typ pliku %s. Omijanie..."
23
+
24
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:173
25
+ #, php-format
26
+ msgid "Watermark successfully added to %s"
27
+ msgstr "Znak wodny dodany do %s"
28
+
29
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:224
30
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkSettings.php:84
31
  msgid "Easy Watermark"
32
  msgstr ""
33
 
34
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:231
35
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:249
36
  msgid "Watermark successfully added."
37
  msgstr "Znak wodny został dodany."
38
 
39
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:231
40
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:240
41
  msgid "Go back"
42
  msgstr "Wróć"
43
 
44
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:231
45
+ msgid "or"
46
+ msgstr "lub"
47
+
48
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:231
49
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:240
50
  msgid "go to edit page"
51
  msgstr "idź na stronę edycji"
52
 
53
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:249
54
  msgid "Go to Media Library"
55
  msgstr "Idź do biblioteki mediów"
56
 
57
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:258
58
  msgid "Add watermark to all images"
59
  msgstr "Dodaj znak wodny do wszystkich obrazów"
60
 
61
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:258
62
  msgid "Be carefull with that option. If some images alredy has watermark, it will be added though."
63
+ msgstr "Bądź ostrożny używając tej opcji. Jeśli któreś zdjęcia posiadają już znak wodny, zostanie on dodany po raz drugi."
 
 
 
 
 
 
 
 
64
 
65
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkSettings.php:170
66
+ msgid "Settings"
67
+ msgstr "Ustawienia"
68
 
69
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:3
70
  msgid "Auto watermark"
71
  msgstr "Automatyczne dodawanie"
72
 
73
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:4
74
  msgid "Add watermark when uploading images"
75
  msgstr "Dodawaj znak wodny podczas wgrywania obrazów"
76
 
77
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:6
78
  msgid "Image types"
79
  msgstr "Typy obrazów"
80
 
81
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:10
82
  msgid "Select image types which should be watermarked"
83
  msgstr "Zaznacz typy obrazów, które mają być oznaczane znakiem wodnym"
84
 
85
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:13
86
+ msgid "Watermark Type"
87
+ msgstr "Typ znaku wodnego"
88
+
89
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:16
90
+ msgid "Image"
91
+ msgstr "Obraz"
92
 
93
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:17
94
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:3
95
+ msgid "Text"
96
+ msgstr "Tekst"
97
+
98
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:18
99
+ msgid "Image + Text"
100
+ msgstr "Obraz i tekst"
101
+
102
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:20
103
+ msgid "Choose, whether to apply image, text, or both."
104
+ msgstr "Wybierz, czy jako znak wodny zastosować obraz, tekst, czy tekst z obrazem."
105
+
106
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:3
107
  msgid "Watermark image"
108
  msgstr "Znak wodny"
109
 
110
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:8
111
  msgid "Choose Watermark Image"
112
  msgstr "Wybierz znak wodny"
113
 
114
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:8
115
  msgid "Set as Watermark Image"
116
  msgstr "Ustaw jako znak wodny"
117
 
118
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:8
119
  msgid "Select/Upload Image"
120
  msgstr "Wybierz/wgraj obraz"
121
 
122
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:17
123
  msgid "Loading preview..."
124
  msgstr "Ładowanie podglądu..."
125
 
126
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:18
127
  msgid "Click on image to change it."
128
  msgstr "Kliknij na obraz by go zmienić."
129
 
130
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:18
131
  msgid "Remove image"
132
  msgstr "Usuń obraz"
133
 
134
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:19
135
  msgid "Note: if \"Auto watermark\" option is ticked, untick it before uploading new watermark image or remove current image first."
136
  msgstr "Uwaga: Jeśli opcja \"Automatycznie dodawanie\" jest zaznaczona, odznacz ją przed wgrywaniem nowego znaku wodnego lub usuń najpierw bieżący znak wodny."
137
 
138
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:23
139
+ msgid "Image position"
140
+ msgstr "Pozycja obrazu"
141
 
142
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:24
143
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:7
144
  msgid "vertical"
145
  msgstr "pionowa"
146
 
147
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:25
148
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:8
149
  msgid "top"
150
  msgstr "góra"
151
 
152
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:26
153
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:9
154
  msgid "middle"
155
  msgstr "środek"
156
 
157
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:27
158
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:10
159
  msgid "bottom"
160
  msgstr "dół"
161
 
162
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:28
163
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:11
164
  msgid "offset"
165
  msgstr ""
166
 
167
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:29
168
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:12
169
  msgid "horizontal"
170
  msgstr "pozioma"
171
 
172
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:30
173
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:13
174
  msgid "left"
175
  msgstr "do lewej"
176
 
177
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:31
178
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:14
179
  msgid "center"
180
  msgstr "wyśrodkowany"
181
 
182
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:32
183
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:15
184
  msgid "right"
185
  msgstr "do prawej"
186
 
187
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:34
188
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:17
189
+ msgid "Offset can be defined in pixels (just numeric value) or as percentage (e.g. '33%')"
190
+ msgstr "Offset może być ustawiony w pikselach (po porstu numer) lub procentowo (np. '33%')"
191
+
192
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:37
193
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:42
194
  msgid "Opacity"
195
  msgstr "Nieprzezroczystość"
196
 
197
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:37
198
+ msgid "Opacity does not affect the png images with opacity chanel."
199
  msgstr "Ta opcja nie dotyczy obrazów png posiadających kanał alfa."
200
 
201
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:6
202
+ msgid "Text position"
203
+ msgstr "Pozycja tekstu"
204
+
205
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:20
206
+ msgid "Font"
207
+ msgstr "Czcionka"
208
+
209
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:31
210
+ msgid "Text color"
211
+ msgstr "Kolor tekstu"
212
+
213
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:34
214
+ msgid "Text size"
215
+ msgstr "Rozmiar tekstu"
216
+
217
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:38
218
+ msgid "Text angle"
219
+ msgstr "Kąt obrotu tekstu"
220
+
221
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form.php:2
222
+ msgid "Easy Watermark Settings"
223
+ msgstr "Ustawienia Easy Watermark"
224
+
225
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form.php:3
226
+ msgid "Go to Easy Watermark Tool"
227
+ msgstr "Przejdź do Easy Watermark"
228
+
229
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form.php:19
230
  msgid "Save Changes"
231
  msgstr "Zapisz zmiany"
232
 
languages/easy-watermark.pot CHANGED
@@ -1,171 +1,232 @@
1
  msgid ""
2
  msgstr ""
3
- "Project-Id-Version: Easy Watermark 0.1\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2013-03-22 14:32+0100\n"
6
- "PO-Revision-Date: 2013-03-22 14:33+0100\n"
7
  "Last-Translator: Wojtek Szałkiewicz <wojtek@szalkiewicz.pl>\n"
8
- "Language-Team: Wojtek Szałkiewicz <szaleq@gmail.com>\n"
9
  "Language: \n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
- "X-Poedit-KeywordsList: __;_e\n"
14
- "X-Poedit-Basepath: .\n"
15
- "X-Poedit-SearchPath-0: /home/szaleq/easy-watermark/trunk\n"
16
 
17
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:6
18
- msgid "Easy Watermark Settings"
 
19
  msgstr ""
20
 
21
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:6
22
- msgid "Go to Easy Watermark Tool"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  msgstr ""
24
 
25
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:9
26
- msgid "General settings"
27
  msgstr ""
28
 
29
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:11
30
  msgid "Auto watermark"
31
  msgstr ""
32
 
33
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:12
34
  msgid "Add watermark when uploading images"
35
  msgstr ""
36
 
37
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:14
38
  msgid "Image types"
39
  msgstr ""
40
 
41
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:18
42
  msgid "Select image types which should be watermarked"
43
  msgstr ""
44
 
45
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:21
46
- msgid "Watermark settings"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  msgstr ""
48
 
49
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:23
50
  msgid "Watermark image"
51
  msgstr ""
52
 
53
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:32
54
  msgid "Choose Watermark Image"
55
  msgstr ""
56
 
57
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:32
58
  msgid "Set as Watermark Image"
59
  msgstr ""
60
 
61
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:32
62
  msgid "Select/Upload Image"
63
  msgstr ""
64
 
65
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:40
66
  msgid "Loading preview..."
67
  msgstr ""
68
 
69
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:41
70
  msgid "Click on image to change it."
71
  msgstr ""
72
 
73
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:41
74
  msgid "Remove image"
75
  msgstr ""
76
 
77
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:42
78
  msgid "Note: if \"Auto watermark\" option is ticked, untick it before uploading new watermark image or remove current image first."
79
  msgstr ""
80
 
81
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:46
82
- msgid "Watermark position"
83
  msgstr ""
84
 
85
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:47
 
86
  msgid "vertical"
87
  msgstr ""
88
 
89
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:48
 
90
  msgid "top"
91
  msgstr ""
92
 
93
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:49
 
94
  msgid "middle"
95
  msgstr ""
96
 
97
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:50
 
98
  msgid "bottom"
99
  msgstr ""
100
 
101
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:51
 
102
  msgid "offset"
103
  msgstr ""
104
 
105
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:52
 
106
  msgid "horizontal"
107
  msgstr ""
108
 
109
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:53
 
110
  msgid "left"
111
  msgstr ""
112
 
113
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:54
 
114
  msgid "center"
115
  msgstr ""
116
 
117
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:55
 
118
  msgid "right"
119
  msgstr ""
120
 
121
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:60
122
- msgid "Opacity"
 
123
  msgstr ""
124
 
125
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:60
126
- msgid "Opacity does not affect the png images with alpha chanel."
127
- msgstr ""
128
-
129
- #: /home/szaleq/easy-watermark/trunk/settings-form.php:66
130
- msgid "Save Changes"
131
  msgstr ""
132
 
133
- #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:33
134
- msgid "Add watermark"
135
  msgstr ""
136
 
137
- #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:190
138
- msgid "Easy Watermark"
139
  msgstr ""
140
 
141
- #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:197
142
- #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:215
143
- msgid "Watermark successfully added."
144
  msgstr ""
145
 
146
- #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:197
147
- #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:206
148
- msgid "Go back"
149
  msgstr ""
150
 
151
- #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:197
152
- #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:206
153
- msgid "go to edit page"
154
  msgstr ""
155
 
156
- #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:215
157
- msgid "Go to Media Library"
158
  msgstr ""
159
 
160
- #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:224
161
- msgid "Add watermark to all images"
162
  msgstr ""
163
 
164
- #: /home/szaleq/easy-watermark/trunk/easy-watermark.php:224
165
- msgid "Be carefull with that option. If some images alredy has watermark, it will be added though."
166
  msgstr ""
167
 
168
- #: /home/szaleq/easy-watermark/trunk/easy-watermark-settings.php:116
169
- msgid "Settings"
170
  msgstr ""
171
 
1
  msgid ""
2
  msgstr ""
3
+ "Project-Id-Version: Easy Watermark 0.2\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2013-03-29 22:55+0100\n"
6
+ "PO-Revision-Date: 2013-03-29 22:55+0100\n"
7
  "Last-Translator: Wojtek Szałkiewicz <wojtek@szalkiewicz.pl>\n"
8
+ "Language-Team: Wojtek Szałkiewicz <wojtek@szalkiewicz.pl>\n"
9
  "Language: \n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
 
 
 
13
 
14
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:71
15
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:87
16
+ msgid "Add watermark"
17
  msgstr ""
18
 
19
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:168
20
+ #, php-format
21
+ msgid "Not supported mime type of %s. Skipping..."
22
+ msgstr ""
23
+
24
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:173
25
+ #, php-format
26
+ msgid "Watermark successfully added to %s"
27
+ msgstr ""
28
+
29
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:224
30
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkSettings.php:84
31
+ msgid "Easy Watermark"
32
+ msgstr ""
33
+
34
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:231
35
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:249
36
+ msgid "Watermark successfully added."
37
+ msgstr ""
38
+
39
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:231
40
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:240
41
+ msgid "Go back"
42
+ msgstr ""
43
+
44
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:231
45
+ msgid "or"
46
+ msgstr ""
47
+
48
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:231
49
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:240
50
+ msgid "go to edit page"
51
+ msgstr ""
52
+
53
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:249
54
+ msgid "Go to Media Library"
55
+ msgstr ""
56
+
57
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:258
58
+ msgid "Add watermark to all images"
59
+ msgstr ""
60
+
61
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkPlugin.php:258
62
+ msgid "Be carefull with that option. If some images alredy has watermark, it will be added though."
63
  msgstr ""
64
 
65
+ #: /media/szaleq/Data/easy-watermark/trunk/EasyWatermarkSettings.php:170
66
+ msgid "Settings"
67
  msgstr ""
68
 
69
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:3
70
  msgid "Auto watermark"
71
  msgstr ""
72
 
73
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:4
74
  msgid "Add watermark when uploading images"
75
  msgstr ""
76
 
77
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:6
78
  msgid "Image types"
79
  msgstr ""
80
 
81
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:10
82
  msgid "Select image types which should be watermarked"
83
  msgstr ""
84
 
85
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:13
86
+ msgid "Watermark Type"
87
+ msgstr ""
88
+
89
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:16
90
+ msgid "Image"
91
+ msgstr ""
92
+
93
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:17
94
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:3
95
+ msgid "Text"
96
+ msgstr ""
97
+
98
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:18
99
+ msgid "Image + Text"
100
+ msgstr ""
101
+
102
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-general.php:20
103
+ msgid "Choose, whether to apply image, text, or both."
104
  msgstr ""
105
 
106
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:3
107
  msgid "Watermark image"
108
  msgstr ""
109
 
110
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:8
111
  msgid "Choose Watermark Image"
112
  msgstr ""
113
 
114
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:8
115
  msgid "Set as Watermark Image"
116
  msgstr ""
117
 
118
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:8
119
  msgid "Select/Upload Image"
120
  msgstr ""
121
 
122
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:17
123
  msgid "Loading preview..."
124
  msgstr ""
125
 
126
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:18
127
  msgid "Click on image to change it."
128
  msgstr ""
129
 
130
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:18
131
  msgid "Remove image"
132
  msgstr ""
133
 
134
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:19
135
  msgid "Note: if \"Auto watermark\" option is ticked, untick it before uploading new watermark image or remove current image first."
136
  msgstr ""
137
 
138
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:23
139
+ msgid "Image position"
140
  msgstr ""
141
 
142
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:24
143
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:7
144
  msgid "vertical"
145
  msgstr ""
146
 
147
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:25
148
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:8
149
  msgid "top"
150
  msgstr ""
151
 
152
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:26
153
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:9
154
  msgid "middle"
155
  msgstr ""
156
 
157
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:27
158
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:10
159
  msgid "bottom"
160
  msgstr ""
161
 
162
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:28
163
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:11
164
  msgid "offset"
165
  msgstr ""
166
 
167
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:29
168
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:12
169
  msgid "horizontal"
170
  msgstr ""
171
 
172
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:30
173
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:13
174
  msgid "left"
175
  msgstr ""
176
 
177
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:31
178
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:14
179
  msgid "center"
180
  msgstr ""
181
 
182
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:32
183
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:15
184
  msgid "right"
185
  msgstr ""
186
 
187
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:34
188
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:17
189
+ msgid "Offset can be defined in pixels (just numeric value) or as percentage (e.g. '33%')"
190
  msgstr ""
191
 
192
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:37
193
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:42
194
+ msgid "Opacity"
 
 
 
195
  msgstr ""
196
 
197
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-image.php:37
198
+ msgid "Opacity does not affect the png images with opacity chanel."
199
  msgstr ""
200
 
201
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:6
202
+ msgid "Text position"
203
  msgstr ""
204
 
205
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:20
206
+ msgid "Font"
 
207
  msgstr ""
208
 
209
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:31
210
+ msgid "Text color"
 
211
  msgstr ""
212
 
213
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:34
214
+ msgid "Text size"
 
215
  msgstr ""
216
 
217
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form-text.php:38
218
+ msgid "Text angle"
219
  msgstr ""
220
 
221
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form.php:2
222
+ msgid "Easy Watermark Settings"
223
  msgstr ""
224
 
225
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form.php:3
226
+ msgid "Go to Easy Watermark Tool"
227
  msgstr ""
228
 
229
+ #: /media/szaleq/Data/easy-watermark/trunk/settings-form.php:19
230
+ msgid "Save Changes"
231
  msgstr ""
232
 
plugin.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @copyright: Wojtek Szałkiewicz
4
+ * @license: GPLv2 or later
5
+ *
6
+ * This class is a base class for wordpress plugins.
7
+ * It's a part of package in which you found it.
8
+ * See readme.txt for more information.
9
+ */
10
+ namespace szaleq\Plugins\EasyWatermark;
11
+
12
+ class Core
13
+ {
14
+ /**
15
+ * @var string plugin name
16
+ */
17
+ protected static $pluginName;
18
+
19
+ /**
20
+ * @var string plugin slug used in setting names etc.
21
+ */
22
+ protected static $pluginSlug;
23
+
24
+ /**
25
+ * @var string plugin version
26
+ */
27
+ protected static $version;
28
+
29
+ /**
30
+ * Initiates plugin by creating an object of inheriting class,
31
+ * registers activation and uninstall hooks,
32
+ * checks version and executes upgrade function if needed.
33
+ *
34
+ * @return object
35
+ */
36
+ public static function init(){
37
+ // Register install and uninstall methods
38
+ register_activation_hook(__FILE__, array(self, 'install'));
39
+ register_uninstall_hook(__FILE__, array(self, 'uninstall'));
40
+
41
+ $version = get_option(static::$pluginSlug . '-version');
42
+ if(!$version || version_compare($version, static::$version, '<')){
43
+ // Version from database is lower than current, upgrade...
44
+ static::upgrade($version);
45
+ }
46
+
47
+ // Load plugin textdomain
48
+ load_plugin_textdomain(static::$pluginSlug, false, '/'.static::$pluginSlug.'/languages');
49
+
50
+ // Create object of plugin class (inheritign this one)
51
+ return new static();
52
+ }
53
+
54
+ /**
55
+ * Adds wordpress action
56
+ *
57
+ * @chainable
58
+ * @param string action name
59
+ * @param string function name
60
+ * @param integer priority
61
+ * @param integer accepted arguments
62
+ * @return object
63
+ */
64
+ protected function add_action($actionName, $funcName = null, $priority = 10, $accepted_args = 1){
65
+ add_action($actionName,
66
+ array($this, (!empty($funcName) ? $funcName : $actionName)),
67
+ $priority, $accepted_args);
68
+
69
+ return $this;
70
+ }
71
+
72
+ /**
73
+ * Adds wordpress filter
74
+ *
75
+ * @chainable
76
+ * @param string filter name
77
+ * @param string function name
78
+ * @param integer priority
79
+ * @param integer accepted arguments
80
+ * @return object
81
+ */
82
+ protected function add_filter($filterName, $funcName = null, $priority = 10, $accepted_args = 1){
83
+ add_filter($filterName,
84
+ array($this, (!empty($funcName) ? $funcName : $filterName)),
85
+ $priority, $accepted_args);
86
+
87
+ return $this;
88
+ }
89
+
90
+ /**
91
+ * Returns plugin name
92
+ *
93
+ * @return string
94
+ */
95
+ public function getName(){
96
+ return static::$pluginName;
97
+ }
98
+
99
+ /**
100
+ * Returns plugin slug
101
+ *
102
+ * @return string
103
+ */
104
+ public function getSlug(){
105
+ return static::$pluginSlug;
106
+ }
107
+
108
+
109
+ /**
110
+ * Returns plugin version
111
+ *
112
+ * @return string
113
+ */
114
+ public function getVersion(){
115
+ return static::$vertion;
116
+ }
117
+
118
+ /**
119
+ * Method run when activating plugin
120
+ *
121
+ * @return void
122
+ */
123
+ public static function install(){}
124
+
125
+ /**
126
+ * Method run when removing plugin
127
+ *
128
+ * @return void
129
+ */
130
+ public static function uninstall(){}
131
+
132
+ /**
133
+ * Method run when plugin version stored in WP options
134
+ * is lower than current version.
135
+ *
136
+ * @return void
137
+ */
138
+ public static function upgrade($version){}
139
+ }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: szaleq
3
  Tags: watermark, image, picture, photo, media, gallery, signature, transparent, upload, admin
4
  Requires at least: 3.3
5
  Tested up to: 3.5.1
6
- Stable tag: 0.1.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -11,15 +11,17 @@ Automatically adds watermark to images when they are uploaded to the WordPress M
11
 
12
  == Description ==
13
 
14
- This plugin allows you to add image watermark to every single image or all images from library at once. It can also be configured to automatically watermark new images as they are uploaded. Watermark can be a png, gif (alpha channel supported in both cases) or jpg image. It's also possibile to set watermark opacity (doesn't apply to png with alpha channel).
15
 
16
- The possibility of adding text watermark as well as defining many watermarks is in nearest plans. Check for updates.
 
 
17
 
18
  Please, contact me if you have any questions/ideas or issues.
19
 
20
  == Installation ==
21
 
22
- Note: Easy Watermark requires GD extension installed and enabled on the server to work correctly.
23
 
24
  1. Unpack easy-watermark.zip and upload its content to the `/wp-content/plugins/` directory
25
  1. Activate the plugin through the 'Plugins' menu in WordPress
@@ -33,9 +35,15 @@ Unfortunately, not yet. Keeping oryginal pictures feature is in plans, so it wil
33
  = How can I add watermark to pictures that were uploaded before the plugin was installed? =
34
  You can go to "Media >> Easy Watermark" and click "Add watermark to all images" button. If you wont to add watermark to single images, you can find links titled "Add watermark" in the media library (see screenshots) or "Add watermark" button on image edit page.
35
 
36
- = How can I adjust watermark position? =
37
  Watermark position can be adjusted vertically and horizontally by selecting alignment (left, center, right, top, middle, bottom). You can also define horizontal and vertical offset, for example if vertical alignment is set to bottom with offset 100 and horizontal alignment is right with offset 200, watermark will show up 100px from lower edge and 200px from right edge of the picture.
38
 
 
 
 
 
 
 
39
 
40
  If you have any other questions, please contact me.
41
 
@@ -47,6 +55,10 @@ If you have any other questions, please contact me.
47
 
48
  == Changelog ==
49
 
 
 
 
 
50
  = 0.1.1 =
51
  * offset can be now also a percentage, not only pixel value
52
  * changed code structure
3
  Tags: watermark, image, picture, photo, media, gallery, signature, transparent, upload, admin
4
  Requires at least: 3.3
5
  Tested up to: 3.5.1
6
+ Stable tag: 0.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
11
 
12
  == Description ==
13
 
14
+ 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.
15
 
16
+ This plugin requires PHP 5.3 or higher.
17
+
18
+ The possibility of defining many watermarks is coming soon. Check for updates.
19
 
20
  Please, contact me if you have any questions/ideas or issues.
21
 
22
  == Installation ==
23
 
24
+ Note: Easy Watermark requires at least PHP 5.3 with GD extension installed and enabled.
25
 
26
  1. Unpack easy-watermark.zip and upload its content to the `/wp-content/plugins/` directory
27
  1. Activate the plugin through the 'Plugins' menu in WordPress
35
  = How can I add watermark to pictures that were uploaded before the plugin was installed? =
36
  You can go to "Media >> Easy Watermark" and click "Add watermark to all images" button. If you wont to add watermark to single images, you can find links titled "Add watermark" in the media library (see screenshots) or "Add watermark" button on image edit page.
37
 
38
+ = How can I adjust watermark image position? =
39
  Watermark position can be adjusted vertically and horizontally by selecting alignment (left, center, right, top, middle, bottom). You can also define horizontal and vertical offset, for example if vertical alignment is set to bottom with offset 100 and horizontal alignment is right with offset 200, watermark will show up 100px from lower edge and 200px from right edge of the picture.
40
 
41
+ = Can I add both, text and image watermark at once? =
42
+ Yes, there is a posibility to add only image, only text or both.
43
+
44
+ = How Can I adjust text watermark? =
45
+ You can choose text font from the list of ten fonts included to this plugin. In future releases you will be able to upload your own font file. You can also set font size, color, angel and opacity. Position of text watermark can be adjusted exactly like image position.
46
+
47
 
48
  If you have any other questions, please contact me.
49
 
55
 
56
  == Changelog ==
57
 
58
+ = 0.2 =
59
+ * added text watermark handling
60
+ * corrected issue with auto adding watermark on upload
61
+
62
  = 0.1.1 =
63
  * offset can be now also a percentage, not only pixel value
64
  * changed code structure
screenshot-1.png CHANGED
Binary file
settings-form-general.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <table class="form-table">
3
+ <tr valign="top"><th scope="row"><?php _e('Auto watermark', 'easy-watermark'); ?></th>
4
+ <td><label for="easy-watermark-autoadd"><input id="easy-watermark-autoadd" name="easy-watermark-settings-general[auto_add]" type="checkbox" value="1" <?php checked('1', $auto_add); ?> /> <?php _e('Add watermark when uploading images', 'easy-watermark'); ?></label></td>
5
+ </tr>
6
+ <tr valign="top" class="auto-add-options" style="display:none;"><th scope="row"><?php _e('Image types', 'easy-watermark'); ?></th>
7
+ <td>
8
+ <label for="image-type-jpg"><input id="image-type-jpg" type="checkbox" name="easy-watermark-settings-general[image_types][]" value="jpeg" <?php checked('1', in_array('jpeg', $image_types)); ?> /> jpg/jpeg</label><br/></fieldset>
9
+ <label for="image-type-png"><input id="image-type-png" type="checkbox" name="easy-watermark-settings-general[image_types][]" value="png" <?php checked('1', in_array('png', $image_types)); ?> /> png</label><br/>
10
+ <label for="image-type-gif"><input id="image-type-gif" type="checkbox" name="easy-watermark-settings-general[image_types][]" value="gif" <?php checked('1', in_array('gif', $image_types)); ?> /> gif</label><p class="description"><?php _e('Select image types which should be watermarked', 'easy-watermark'); ?></p></td>
11
+ </tr>
12
+ <tr><th scope="row">
13
+ <?php _e('Watermark Type', 'easy-watermark'); ?>
14
+ </th><td>
15
+ <select name="easy-watermark-settings-general[watermark_type]">
16
+ <option value="1" <?php selected('1', $watermark_type) ?>><?php _e('Image', 'easy-watermark'); ?></option>
17
+ <option value="2" <?php selected('2', $watermark_type) ?>><?php _e('Text', 'easy-watermark'); ?></option>
18
+ <option value="3" <?php selected('3', $watermark_type) ?>><?php _e('Image + Text', 'easy-watermark'); ?></option>
19
+ </select>
20
+ <p class="description"><?php _e('Choose, whether to apply image, text, or both.', 'easy-watermark'); ?></p>
21
+ </td>
22
+ </tr>
23
+ </table>
settings-form-image.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <table class="form-table">
3
+ <tr valign="top"><th scope="row"><label for="easy-watermark-url"><?php _e('Watermark image', 'easy-watermark'); ?></label></th>
4
+ <td><input id="easy-watermark-url" class="regular-text" name="easy-watermark-settings-image[watermark_url]" type="hidden" value="<?php echo $watermark_url; ?>" /><input id="easy-watermark-id" name="easy-watermark-settings-image[watermark_id]" type="hidden" value="<?php echo $watermark_id; ?>" /><input id="easy-watermark-mime" name="easy-watermark-settings-image[watermark_mime]" type="hidden" value="<?php echo $watermark_mime; ?>" />
5
+ <?php
6
+ if(empty($watermark_url)) :
7
+ ?>
8
+ <a class="button-secondary" id="select-image-button" data-choose="<?php _e('Choose Watermark Image', 'easy-watermark'); ?>" data-button-label="<?php _e('Set as Watermark Image', 'easy-watermark'); ?>" href="#"><?php _e('Select/Upload Image', 'easy-watermark'); ?></a>
9
+ <br/>
10
+ <input id="easy-watermark-position_y" name="easy-watermark-settings-image[position_y]" type="hidden" value="<?php echo $position_y; ?>" />
11
+ <input id="easy-watermark-position_x" name="easy-watermark-settings-image[position_x]" type="hidden" value="<?php echo $position_x; ?>" />
12
+ <input id="easy-watermark-position_y" name="easy-watermark-settings-image[offset_y]" type="hidden" value="<?php echo $offset_y; ?>" />
13
+ <input id="easy-watermark-position_x" name="easy-watermark-settings-image[offset_x]" type="hidden" value="<?php echo $offset_x; ?>" />
14
+ <input id="easy-watermark-opacity" name="easy-watermark-settings-image[opacity]" type="hidden" value="<?php echo $opacity; ?>" />
15
+ <?php else : ?>
16
+ <img id="watermark-preview" style="max-height:200px;width:auto;cursor:pointer;" src="<?php echo $watermark_url; ?>" />
17
+ <span style="display:none;" id="loading-preview"><?php _e('Loading preview...', 'easy-watermark'); ?></span>
18
+ <p class="description"><?php _e('Click on image to change it.', 'easy-watermark'); ?> <a href="#" class="remove-image"><?php _e('Remove image', 'easy-watermark'); ?></a><br />
19
+ <?php _e('Note: if "Auto watermark" option is ticked, untick it before uploading new watermark image or remove current image first.', 'easy-watermark'); ?></p>
20
+ </td>
21
+ </tr>
22
+
23
+ <tr valign="top" class="watermark-options"><th scope="row"><?php _e('Image position', 'easy-watermark'); ?></th>
24
+ <td><strong> <?php _e('vertical', 'easy-watermark'); ?>: </strong>
25
+ <label for="easy-watermark-position-top"><input id="easy-watermark-position-top" name="easy-watermark-settings-image[position_y]" type="radio" value="top" <?php checked('top', $position_y); ?>/> <?php _e('top', 'easy-watermark'); ?></label>
26
+ <label for="easy-watermark-position-mdl"><input id="easy-watermark-position-mdl" name="easy-watermark-settings-image[position_y]" type="radio" value="mdl" <?php echo checked('mdl', $position_y); ?> /> <?php _e('middle', 'easy-watermark'); ?></label>
27
+ <label for="easy-watermark-position-btm"><input id="easy-watermark-position-btm" name="easy-watermark-settings-image[position_y]" type="radio" value="btm" <?php echo checked('btm', $position_y); ?> /> <?php _e('bottom', 'easy-watermark'); ?></label><br />
28
+ <label for="easy-watermark-position-offset_y"> <?php _e('offset', 'easy-watermark'); ?>: </label>
29
+ <input size="3" type="text" id="easy-watermark-position-offset_y" name="easy-watermark-settings-image[offset_y]" value="<?php echo $offset_y; ?>" /><br /><br /><strong> <?php _e('horizontal', 'easy-watermark'); ?>: </strong>
30
+ <label for="easy-watermark-position-lft"><input id="easy-watermark-position-lft" name="easy-watermark-settings-image[position_x]" type="radio" value="lft" <?php checked('lft', $position_x); ?>/> <?php _e('left', 'easy-watermark'); ?></label>
31
+ <label for="easy-watermark-position-ctr"><input id="easy-watermark-position-ctr" name="easy-watermark-settings-image[position_x]" type="radio" value="ctr" <?php checked('ctr', $position_x); ?> /> <?php _e('center', 'easy-watermark'); ?></label>
32
+ <label for="easy-watermark-position-rgt"><input id="easy-watermark-position-rgt" name="easy-watermark-settings-image[position_x]" type="radio" value="rgt" <?php checked('rgt', $position_x); ?> /> <?php _e('right', 'easy-watermark'); ?></label><br />
33
+ <label for="easy-watermark-position-offset_x">offset: </label>
34
+ <input type="text" size="3" id="easy-watermark-position-offset_x" name="easy-watermark-settings-image[offset_x]" value="<?php echo $offset_x; ?>"/><p class="description"><?php _e('Offset can be defined in pixels (just numeric value) or as percentage (e.g. \'33%\')', 'easy-watermark'); ?></p>
35
+ </td>
36
+ </tr>
37
+ <tr valign="top" class="watermark-options"><th scope="row"><?php _e('Opacity', 'easy-watermark'); ?></th><td><input id="easy-watermark-opacity" name="easy-watermark-settings-image[opacity]" size="3" type="text" value="<?php echo $opacity; ?>" /> %<p class="description"><?php _e('Opacity does not affect the png images with opacity chanel.', 'easy-watermark'); ?></p>
38
+ <?php endif; ?>
39
+ </td>
40
+ </tr>
41
+ </table>
settings-form-text.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <table class="form-table">
3
+ <tr><th scope="row"><?php _e('Text', 'easy-watermark'); ?></th><td>
4
+ <input type="text" value="<?php echo $text; ?>" name="easy-watermark-settings-text[text]" />
5
+ </tr>
6
+ <tr valign="top" class="watermark-options"><th scope="row"><?php _e('Text position', 'easy-watermark'); ?></th>
7
+ <td><strong> <?php _e('vertical', 'easy-watermark'); ?>: </strong>
8
+ <label for="easy-watermark-position-top"><input id="easy-watermark-position-top" name="easy-watermark-settings-text[position_y]" type="radio" value="top" <?php checked('top', $position_y); ?>/> <?php _e('top', 'easy-watermark'); ?></label>
9
+ <label for="easy-watermark-position-mdl"><input id="easy-watermark-position-mdl" name="easy-watermark-settings-text[position_y]" type="radio" value="mdl" <?php echo checked('mdl', $position_y); ?> /> <?php _e('middle', 'easy-watermark'); ?></label>
10
+ <label for="easy-watermark-position-btm"><input id="easy-watermark-position-btm" name="easy-watermark-settings-text[position_y]" type="radio" value="btm" <?php echo checked('btm', $position_y); ?> /> <?php _e('bottom', 'easy-watermark'); ?></label><br />
11
+ <label for="easy-watermark-position-offset_y"> <?php _e('offset', 'easy-watermark'); ?>: </label>
12
+ <input size="3" type="text" id="easy-watermark-position-offset_y" name="easy-watermark-settings-text[offset_y]" value="<?php echo $offset_y; ?>" /><br /><br /><strong> <?php _e('horizontal', 'easy-watermark'); ?>: </strong>
13
+ <label for="easy-watermark-position-lft"><input id="easy-watermark-position-lft" name="easy-watermark-settings-text[position_x]" type="radio" value="lft" <?php checked('lft', $position_x); ?>/> <?php _e('left', 'easy-watermark'); ?></label>
14
+ <label for="easy-watermark-position-ctr"><input id="easy-watermark-position-ctr" name="easy-watermark-settings-text[position_x]" type="radio" value="ctr" <?php checked('ctr', $position_x); ?> /> <?php _e('center', 'easy-watermark'); ?></label>
15
+ <label for="easy-watermark-position-rgt"><input id="easy-watermark-position-rgt" name="easy-watermark-settings-text[position_x]" type="radio" value="rgt" <?php checked('rgt', $position_x); ?> /> <?php _e('right', 'easy-watermark'); ?></label><br />
16
+ <label for="easy-watermark-position-offset_x">offset: </label>
17
+ <input type="text" size="3" id="easy-watermark-position-offset_x" name="easy-watermark-settings-text[offset_x]" value="<?php echo $offset_x; ?>"/><p class="description"><?php _e('Offset can be defined in pixels (just numeric value) or as percentage (e.g. \'33%\')', 'easy-watermark'); ?></p>
18
+ </td>
19
+ </tr>
20
+ <tr><th scope="row"><?php _e('Font', 'easy-watermark'); ?></th><td>
21
+ <select name="easy-watermark-settings-text[font]">
22
+ <?php
23
+ foreach($fonts as $val => $name){
24
+ ?>
25
+ <option value="<?php echo $val; ?>" <?php selected($val, $font); ?>><?php _e($name, 'easy-watermark') ?></option>
26
+ <?
27
+ }
28
+ ?>
29
+ </select>
30
+ </td>
31
+ <tr><th scope="row"><?php _e('Text color', 'easy-watermark'); ?></th><td>
32
+ #<input type="text" size="6" maxlength="6" name="easy-watermark-settings-text[color]" id="easy-watermark-color" value="<?php echo $color; ?>" /><div id="colorselector" data-color="<?php echo $color; ?>"><div style="background-color:#<?php echo $color; ?>"></div></div>
33
+ </td>
34
+ <tr><th scope="row"><?php _e('Text size', 'easy-watermark'); ?></th><td>
35
+ <input type="text" size="3" name="easy-watermark-settings-text[size]" id="easy-watermark-size" value="<?php echo $size; ?>" /> pt
36
+ </td>
37
+ </tr>
38
+ <tr><th scope="row"><?php _e('Text angle', 'easy-watermark'); ?></th><td>
39
+ <input type="text" size="3" name="easy-watermark-settings-text[angle]" id="easy-watermark-angle" value="<?php echo $angle; ?>" /> &deg;
40
+ </td>
41
+ </tr>
42
+ <tr><th scope="row"><?php _e('Opacity', 'easy-watermark'); ?></th><td>
43
+ <input type="text" size="3" name="easy-watermark-settings-text[opacity]" id="easy-watermark-angle" value="<?php echo $opacity; ?>" /> %
44
+ </td>
45
+ </tr>
46
+ </table>
settings-form.php CHANGED
@@ -1,64 +1,20 @@
1
- <?php
2
- $auto_add = $options['auto_add'];
3
- $image_types = $options['image_types'];
4
- ?>
5
  <div class="wrap easy-watermark">
6
  <h2><?php _e('Easy Watermark Settings', 'easy-watermark'); ?></h2>
7
  <a href="<?php echo admin_url('/upload.php?page=easy-watermark'); ?>"><?php _e('Go to Easy Watermark Tool', 'easy-watermark'); ?></a>
8
  <form method="post" action="options.php" id="easy-watermark-settings-form">
9
- <?php settings_fields('easy-watermark-settings'); ?>
10
- <h3><?php _e('General settings', 'easy-watermark'); ?></h3>
11
- <table class="form-table">
12
- <tr valign="top"><th scope="row"><?php _e('Auto watermark', 'easy-watermark'); ?></th>
13
- <td><label for="easy-watermark-autoadd"><input id="easy-watermark-autoadd" name="easy-watermark-settings[auto_add]" type="checkbox" value="1" <?php checked('1', $auto_add); ?> /> <?php _e('Add watermark when uploading images', 'easy-watermark'); ?></label></td>
14
- </tr>
15
- <tr valign="top" class="auto-add-options" style="display:none;"><th scope="row"><?php _e('Image types', 'easy-watermark'); ?></th>
16
- <td>
17
- <label for="image-type-jpg"><input id="image-type-jpg" type="checkbox" name="easy-watermark-settings[image_types][jpeg]" value="jpeg" <?php checked('1', isset($image_types['jpeg'])); ?> /> jpg/jpeg</label><br/></fieldset>
18
- <label for="image-type-png"><input id="image-type-png" type="checkbox" name="easy-watermark-settings[image_types][png]" value="png" <?php checked('1', isset($image_types['png'])); ?> /> png</label><br/>
19
- <label for="image-type-gif"><input id="image-type-gif" type="checkbox" name="easy-watermark-settings[image_types][gif]" value="gif" <?php checked('1', isset($image_types['gif'])); ?> /> gif</label><p class="description"><?php _e('Select image types which should be watermarked', 'easy-watermark'); ?></p></td>
20
- </tr>
21
- </table>
22
- <h3><?php _e('Watermark settings', 'easy-watermark'); ?></h3>
23
- <table class="form-table">
24
- <tr valign="top"><th scope="row"><label for="easy-watermark-url"><?php _e('Watermark image', 'easy-watermark'); ?></label></th>
25
- <td><input id="easy-watermark-url" class="regular-text" name="easy-watermark-settings[image][url]" type="hidden" value="<?php echo $options['image']['url']; ?>" /><input id="easy-watermark-id" name="easy-watermark-settings[image][id]" type="hidden" value="<?php echo $options['image']['id']; ?>" /><input id="easy-watermark-mime" name="easy-watermark-settings[image][mime]" type="hidden" value="<?php echo $options['image']['mime']; ?>" />
26
- <?php
27
- if(empty($options['image']['url'])) :
28
- ?>
29
- <a class="button-secondary" id="select-image-button" data-choose="<?php _e('Choose Watermark Image', 'easy-watermark'); ?>" data-button-label="<?php _e('Set as Watermark Image', 'easy-watermark'); ?>" href="#"><?php _e('Select/Upload Image', 'easy-watermark'); ?></a>
30
- <br/>
31
- <input id="easy-watermark-position_y" name="easy-watermark-settings[image][position_y]" type="hidden" value="<?php echo $options['image']['position_y']; ?>" />
32
- <input id="easy-watermark-position_x" name="easy-watermark-settings[image][position_x]" type="hidden" value="<?php echo $options['image']['position_x']; ?>" />
33
- <input id="easy-watermark-position_y" name="easy-watermark-settings[image][offset_y]" type="hidden" value="<?php echo $options['image']['offset_y']; ?>" />
34
- <input id="easy-watermark-position_x" name="easy-watermark-settings[image][offset_x]" type="hidden" value="<?php echo $options['image']['offset_x']; ?>" />
35
- <input id="easy-watermark-opacity" name="easy-watermark-settings[image][opacity]" type="hidden" value="<?php echo $options['image']['opacity']; ?>" />
36
- <?php else : ?>
37
- <img id="watermark-preview" style="max-height:200px;width:auto;cursor:pointer;" src="<?php echo $options['image']['url']; ?>" /><span style="display:none;" id="loading-preview"><?php _e('Loading preview...', 'easy-watermark'); ?></span>
38
- <p class="description"><?php _e('Click on image to change it.', 'easy-watermark'); ?> <a href="#" class="remove-image"><?php _e('Remove image', 'easy-watermark'); ?></a></p>
39
- <p class="description"><?php _e('Note: if "Auto watermark" option is ticked, untick it before uploading new watermark image or remove current image first.', 'easy-watermark'); ?></p>
40
- </td>
41
- </tr>
42
-
43
- <tr valign="top" class="watermark-options"><th scope="row"><?php _e('Watermark position', 'easy-watermark'); ?></th>
44
- <td><strong> <?php _e('vertical', 'easy-watermark'); ?>: </strong>
45
- <label for="easy-watermark-position-top"><input id="easy-watermark-position-top" name="easy-watermark-settings[image][position_y]" type="radio" value="top" <?php echo $options['image']['position_y'] == 'top' ? 'checked' : null; ?>/> <?php _e('top', 'easy-watermark'); ?></label>
46
- <label for="easy-watermark-position-mdl"><input id="easy-watermark-position-mdl" name="easy-watermark-settings[image][position_y]" type="radio" value="mdl" <?php echo $options['image']['position_y'] == 'mdl' ? 'checked' : null; ?> /> <?php _e('middle', 'easy-watermark'); ?></label>
47
- <label for="easy-watermark-position-btm"><input id="easy-watermark-position-btm" name="easy-watermark-settings[image][position_y]" type="radio" value="btm" <?php echo $options['image']['position_y'] == 'btm' ? 'checked' : null; ?> /> <?php _e('bottom', 'easy-watermark'); ?></label><br />
48
- <label for="easy-watermark-position-offset_y"> <?php _e('offset', 'easy-watermark'); ?>: </label>
49
- <input style="width:60px;" type="text" id="easy-watermark-position-offset_y" name="easy-watermark-settings[image][offset_y]" value="<?php echo $options['image']['offset_y']; ?>" /><br /><br /><strong> <?php _e('horizontal', 'easy-watermark'); ?>: </strong>
50
- <label for="easy-watermark-position-lft"><input id="easy-watermark-position-lft" name="easy-watermark-settings[image][position_x]" type="radio" value="lft" <?php echo $options['image']['position_x'] == 'lft' ? 'checked' : null; ?>/> <?php _e('left', 'easy-watermark'); ?></label>
51
- <label for="easy-watermark-position-ctr"><input id="easy-watermark-position-ctr" name="easy-watermark-settings[image][position_x]" type="radio" value="ctr" <?php echo $options['image']['position_x'] == 'ctr' ? 'checked' : null; ?> /> <?php _e('center', 'easy-watermark'); ?></label>
52
- <label for="easy-watermark-position-rgt"><input id="easy-watermark-position-rgt" name="easy-watermark-settings[image][position_x]" type="radio" value="rgt" <?php echo $options['image']['position_x'] == 'rgt' ? 'checked' : null; ?> /> <?php _e('right', 'easy-watermark'); ?></label><br />
53
- <label for="easy-watermark-position-offset_x">offset: </label>
54
- <input type="text" style="width:60px;" id="easy-watermark-position-offset_x" name="easy-watermark-settings[image][offset_x]" value="<?php echo $options['image']['offset_x']; ?>"/><p class="description"><?php _e('Offset can be defined in pixels (just numeric value) or as percentage (e.g. \'33%\')', 'easy-watermark'); ?></p>
55
- </td>
56
- </tr>
57
- <tr valign="top" class="watermark-options"><th scope="row"><?php _e('Opacity', 'easy-watermark'); ?></th><td><input id="easy-watermark-opacity" name="easy-watermark-settings[image][opacity]" style="width:60px;" type="text" value="<?php echo $options['image']['opacity']; ?>" /> %<p class="description"><?php _e('Opacity does not affect the png images with opacity chanel.', 'easy-watermark'); ?></p>
58
- <?php endif; ?>
59
- </td>
60
- </tr>
61
- </table>
62
  <p class="submit">
63
  <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
64
  </p>
 
 
 
 
1
  <div class="wrap easy-watermark">
2
  <h2><?php _e('Easy Watermark Settings', 'easy-watermark'); ?></h2>
3
  <a href="<?php echo admin_url('/upload.php?page=easy-watermark'); ?>"><?php _e('Go to Easy Watermark Tool', 'easy-watermark'); ?></a>
4
  <form method="post" action="options.php" id="easy-watermark-settings-form">
5
+ <?php settings_fields('easy-watermark-settings-' . $current_tab); ?>
6
+ <h3 class="nav-tab-wrapper">
7
+ <?php
8
+ foreach ( $this->tabs as $name => $caption ) {
9
+ $active = $current_tab == $name ? 'nav-tab-active' : '';
10
+ echo '<a class="nav-tab ' . $active . '" href="?page=' . $this->plugin->getSlug() . '-settings&tab=' . $name . '">' . __($caption, 'easy-watermark') . '</a>';
11
+ }
12
+ ?></h3>
13
+ <?php
14
+ $filename = dirname(__FILE__) . '/settings-form-' . $current_tab . '.php';
15
+ if(file_exists($filename))
16
+ include $filename;
17
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  <p class="submit">
19
  <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
20
  </p>