Photo Gallery by WD – Responsive Photo Gallery - Version 1.3.30

Version Description

  • Changed: Scroll load in filemanager.
  • Fixed: Image dimensions on images reset.
Download this release

Release Info

Developer webdorado
Plugin Icon 128x128 Photo Gallery by WD – Responsive Photo Gallery
Version 1.3.30
Comparing to
See all releases

Code changes from version 1.3.29 to 1.3.30

admin/controllers/BWGControllerGalleries_bwg.php CHANGED
@@ -152,82 +152,18 @@ class BWGControllerGalleries_bwg {
152
  }
153
 
154
  public function recover() {
155
- global $wpdb;
156
  $id = ((isset($_POST['image_current_id'])) ? esc_html(stripslashes($_POST['image_current_id'])) : 0);
157
  global $wd_bwg_options;
158
  $thumb_width = $wd_bwg_options->upload_thumb_width;
159
- $thumb_height = $wd_bwg_options->upload_thumb_height;
160
- $this->recover_image($id, $thumb_width, $thumb_height);
161
  }
162
 
163
  public function image_recover_all() {
164
- global $wpdb;
165
  $gallery_id = ((isset($_POST['current_id'])) ? esc_html(stripslashes($_POST['current_id'])) : 0);
166
- global $wd_bwg_options;
167
- $thumb_width = $wd_bwg_options->upload_thumb_width;
168
- $thumb_height = $wd_bwg_options->upload_thumb_height;
169
- $image_ids_col = $wpdb->get_col($wpdb->prepare('SELECT id FROM ' . $wpdb->prefix . 'bwg_image WHERE gallery_id="%d"', $gallery_id));
170
- foreach ($image_ids_col as $image_id) {
171
- if (isset($_POST['check_' . $image_id]) || isset($_POST['check_all_items'])) {
172
- $this->recover_image($image_id, $thumb_width, $thumb_height);
173
- }
174
- }
175
  }
176
 
177
- public function recover_image($id, $thumb_width, $thumb_height) {
178
- global $WD_BWG_UPLOAD_DIR;
179
- global $wpdb;
180
- $image_data = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'bwg_image WHERE id="%d"', $id));
181
- $filename = htmlspecialchars_decode(ABSPATH . $WD_BWG_UPLOAD_DIR . $image_data->image_url, ENT_COMPAT | ENT_QUOTES);
182
- $thumb_filename = htmlspecialchars_decode(ABSPATH . $WD_BWG_UPLOAD_DIR . $image_data->thumb_url, ENT_COMPAT | ENT_QUOTES);
183
- copy(str_replace('/thumb/', '/.original/', $thumb_filename), $filename);
184
- list($width_orig, $height_orig, $type_orig) = getimagesize($filename);
185
- $percent = $width_orig / $thumb_width;
186
- $thumb_height = $height_orig / $percent;
187
- @ini_set('memory_limit', '-1');
188
- if ($type_orig == 2) {
189
- $img_r = imagecreatefromjpeg($filename);
190
- $dst_r = ImageCreateTrueColor($thumb_width, $thumb_height);
191
- imagecopyresampled($dst_r, $img_r, 0, 0, 0, 0, $thumb_width, $thumb_height, $width_orig, $height_orig);
192
- imagejpeg($dst_r, $thumb_filename, 100);
193
- imagedestroy($img_r);
194
- imagedestroy($dst_r);
195
- }
196
- elseif ($type_orig == 3) {
197
- $img_r = imagecreatefrompng($filename);
198
- $dst_r = ImageCreateTrueColor($thumb_width, $thumb_height);
199
- imageColorAllocateAlpha($dst_r, 0, 0, 0, 127);
200
- imagealphablending($dst_r, FALSE);
201
- imagesavealpha($dst_r, TRUE);
202
- imagecopyresampled($dst_r, $img_r, 0, 0, 0, 0, $thumb_width, $thumb_height, $width_orig, $height_orig);
203
- imagealphablending($dst_r, FALSE);
204
- imagesavealpha($dst_r, TRUE);
205
- imagepng($dst_r, $thumb_filename, 9);
206
- imagedestroy($img_r);
207
- imagedestroy($dst_r);
208
- }
209
- elseif ($type_orig == 1) {
210
- $img_r = imagecreatefromgif($filename);
211
- $dst_r = ImageCreateTrueColor($thumb_width, $thumb_height);
212
- imageColorAllocateAlpha($dst_r, 0, 0, 0, 127);
213
- imagealphablending($dst_r, FALSE);
214
- imagesavealpha($dst_r, TRUE);
215
- imagecopyresampled($dst_r, $img_r, 0, 0, 0, 0, $thumb_width, $thumb_height, $width_orig, $height_orig);
216
- imagealphablending($dst_r, FALSE);
217
- imagesavealpha($dst_r, TRUE);
218
- imagegif($dst_r, $thumb_filename);
219
- imagedestroy($img_r);
220
- imagedestroy($dst_r);
221
- }
222
- @ini_restore('memory_limit');
223
- ?>
224
- <script language="javascript">
225
- var image_src = window.parent.document.getElementById("image_thumb_<?php echo $id; ?>").src;
226
- document.getElementById("image_thumb_<?php echo $id; ?>").src = image_src + "?date=<?php echo date('Y-m-y H:i:s'); ?>";
227
- </script>
228
- <?php
229
- }
230
-
231
  public function image_publish() {
232
  $id = ((isset($_POST['image_current_id'])) ? esc_html(stripslashes($_POST['image_current_id'])) : 0);
233
  global $wpdb;
@@ -310,28 +246,8 @@ class BWGControllerGalleries_bwg {
310
  }
311
 
312
  public function image_set_watermark() {
313
- global $wpdb;
314
- global $WD_BWG_UPLOAD_DIR;
315
- global $wd_bwg_options;
316
  $gallery_id = ((isset($_POST['current_id'])) ? esc_html(stripslashes($_POST['current_id'])) : 0);
317
- $images = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'bwg_image WHERE gallery_id="%d"', $gallery_id));
318
- switch ($wd_bwg_options->built_in_watermark_type) {
319
- case 'text':
320
- foreach ($images as $image) {
321
- if (isset($_POST['check_' . $image->id]) || isset($_POST['check_all_items'])) {
322
- $this->set_text_watermark(ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, html_entity_decode($wd_bwg_options->built_in_watermark_text), $wd_bwg_options->built_in_watermark_font, $wd_bwg_options->built_in_watermark_font_size, '#' . $wd_bwg_options->built_in_watermark_color, $wd_bwg_options->built_in_watermark_opacity, $wd_bwg_options->built_in_watermark_position);
323
- }
324
- }
325
- break;
326
- case 'image':
327
- $watermark_path = str_replace(site_url() . '/', ABSPATH, $wd_bwg_options->built_in_watermark_url);
328
- foreach ($images as $image) {
329
- if (isset($_POST['check_' . $image->id]) || isset($_POST['check_all_items'])) {
330
- $this->set_image_watermark(ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, $watermark_path, $wd_bwg_options->built_in_watermark_size, $wd_bwg_options->built_in_watermark_size, $wd_bwg_options->built_in_watermark_position);
331
- }
332
- }
333
- break;
334
- }
335
  }
336
 
337
  public function image_resize() {
@@ -435,180 +351,7 @@ class BWGControllerGalleries_bwg {
435
  @ini_restore('memory_limit');
436
  return $success;
437
  }
438
-
439
- function bwg_hex2rgb($hex) {
440
- $hex = str_replace("#", "", $hex);
441
- if (strlen($hex) == 3) {
442
- $r = hexdec(substr($hex,0,1).substr($hex,0,1));
443
- $g = hexdec(substr($hex,1,1).substr($hex,1,1));
444
- $b = hexdec(substr($hex,2,1).substr($hex,2,1));
445
- }
446
- else {
447
- $r = hexdec(substr($hex,0,2));
448
- $g = hexdec(substr($hex,2,2));
449
- $b = hexdec(substr($hex,4,2));
450
- }
451
- $rgb = array($r, $g, $b);
452
- return $rgb;
453
- }
454
-
455
- function bwg_imagettfbboxdimensions($font_size, $font_angle, $font, $text) {
456
- $box = @ImageTTFBBox($font_size, $font_angle, $font, $text) or die;
457
- $max_x = max(array($box[0], $box[2], $box[4], $box[6]));
458
- $max_y = max(array($box[1], $box[3], $box[5], $box[7]));
459
- $min_x = min(array($box[0], $box[2], $box[4], $box[6]));
460
- $min_y = min(array($box[1], $box[3], $box[5], $box[7]));
461
- return array(
462
- "width" => ($max_x - $min_x),
463
- "height" => ($max_y - $min_y)
464
- );
465
- }
466
-
467
- function set_text_watermark($original_filename, $dest_filename, $watermark_text, $watermark_font, $watermark_font_size, $watermark_color, $watermark_transparency, $watermark_position) {
468
- $original_filename = htmlspecialchars_decode($original_filename, ENT_COMPAT | ENT_QUOTES);
469
- $dest_filename = htmlspecialchars_decode($dest_filename, ENT_COMPAT | ENT_QUOTES);
470
-
471
- $watermark_transparency = 127 - ($watermark_transparency * 1.27);
472
- list($width, $height, $type) = getimagesize($original_filename);
473
- $watermark_image = imagecreatetruecolor($width, $height);
474
-
475
- $watermark_color = $this->bwg_hex2rgb($watermark_color);
476
- $watermark_color = imagecolorallocatealpha($watermark_image, $watermark_color[0], $watermark_color[1], $watermark_color[2], $watermark_transparency);
477
- $watermark_font = WD_BWG_DIR . '/fonts/' . $watermark_font;
478
- $watermark_font_size = (($height > $width ? $width : $height) * $watermark_font_size / 500) . 'px';
479
- $watermark_position = explode('-', $watermark_position);
480
- $watermark_sizes = $this->bwg_imagettfbboxdimensions($watermark_font_size, 0, $watermark_font, $watermark_text);
481
-
482
- $top = $height - 5;
483
- $left = $width - $watermark_sizes['width'] - 5;
484
- switch ($watermark_position[0]) {
485
- case 'top':
486
- $top = $watermark_sizes['height'] + 5;
487
- break;
488
- case 'middle':
489
- $top = ($height + $watermark_sizes['height']) / 2;
490
- break;
491
- }
492
- switch ($watermark_position[1]) {
493
- case 'left':
494
- $left = 5;
495
- break;
496
- case 'center':
497
- $left = ($width - $watermark_sizes['width']) / 2;
498
- break;
499
- }
500
- @ini_set('memory_limit', '-1');
501
- if ($type == 2) {
502
- $image = imagecreatefromjpeg($original_filename);
503
- imagettftext($image, $watermark_font_size, 0, $left, $top, $watermark_color, $watermark_font, $watermark_text);
504
- imagejpeg ($image, $dest_filename, 100);
505
- imagedestroy($image);
506
- }
507
- elseif ($type == 3) {
508
- $image = imagecreatefrompng($original_filename);
509
- imagettftext($image, $watermark_font_size, 0, $left, $top, $watermark_color, $watermark_font, $watermark_text);
510
- imageColorAllocateAlpha($image, 0, 0, 0, 127);
511
- imagealphablending($image, FALSE);
512
- imagesavealpha($image, TRUE);
513
- imagepng($image, $dest_filename, 9);
514
- imagedestroy($image);
515
- }
516
- elseif ($type == 1) {
517
- $image = imagecreatefromgif($original_filename);
518
- imageColorAllocateAlpha($watermark_image, 0, 0, 0, 127);
519
- imagecopy($watermark_image, $image, 0, 0, 0, 0, $width, $height);
520
- imagettftext($watermark_image, $watermark_font_size, 0, $left, $top, $watermark_color, $watermark_font, $watermark_text);
521
- imagealphablending($watermark_image, FALSE);
522
- imagesavealpha($watermark_image, TRUE);
523
- imagegif($watermark_image, $dest_filename);
524
- imagedestroy($image);
525
- }
526
- imagedestroy($watermark_image);
527
- @ini_restore('memory_limit');
528
- }
529
-
530
- function set_image_watermark($original_filename, $dest_filename, $watermark_url, $watermark_height, $watermark_width, $watermark_position) {
531
- $original_filename = htmlspecialchars_decode($original_filename, ENT_COMPAT | ENT_QUOTES);
532
- $dest_filename = htmlspecialchars_decode($dest_filename, ENT_COMPAT | ENT_QUOTES);
533
- $watermark_url = htmlspecialchars_decode($watermark_url, ENT_COMPAT | ENT_QUOTES);
534
-
535
- list($width, $height, $type) = getimagesize($original_filename);
536
- list($width_watermark, $height_watermark, $type_watermark) = getimagesize($watermark_url);
537
-
538
- $watermark_width = $width * $watermark_width / 100;
539
- $watermark_height = $height_watermark * $watermark_width / $width_watermark;
540
-
541
- $watermark_position = explode('-', $watermark_position);
542
- $top = $height - $watermark_height - 5;
543
- $left = $width - $watermark_width - 5;
544
- switch ($watermark_position[0]) {
545
- case 'top':
546
- $top = 5;
547
- break;
548
- case 'middle':
549
- $top = ($height - $watermark_height) / 2;
550
- break;
551
- }
552
- switch ($watermark_position[1]) {
553
- case 'left':
554
- $left = 5;
555
- break;
556
- case 'center':
557
- $left = ($width - $watermark_width) / 2;
558
- break;
559
- }
560
- @ini_set('memory_limit', '-1');
561
- if ($type_watermark == 2) {
562
- $watermark_image = imagecreatefromjpeg($watermark_url);
563
- }
564
- elseif ($type_watermark == 3) {
565
- $watermark_image = imagecreatefrompng($watermark_url);
566
- }
567
- elseif ($type_watermark == 1) {
568
- $watermark_image = imagecreatefromgif($watermark_url);
569
- }
570
- else {
571
- return false;
572
- }
573
-
574
- $watermark_image_resized = imagecreatetruecolor($watermark_width, $watermark_height);
575
- imagecolorallocatealpha($watermark_image_resized, 255, 255, 255, 127);
576
- imagealphablending($watermark_image_resized, FALSE);
577
- imagesavealpha($watermark_image_resized, TRUE);
578
- imagecopyresampled ($watermark_image_resized, $watermark_image, 0, 0, 0, 0, $watermark_width, $watermark_height, $width_watermark, $height_watermark);
579
-
580
- if ($type == 2) {
581
- $image = imagecreatefromjpeg($original_filename);
582
- imagecopy($image, $watermark_image_resized, $left, $top, 0, 0, $watermark_width, $watermark_height);
583
- if ($dest_filename <> '') {
584
- imagejpeg ($image, $dest_filename, 100);
585
- } else {
586
- header('Content-Type: image/jpeg');
587
- imagejpeg($image, null, 100);
588
- };
589
- imagedestroy($image);
590
- }
591
- elseif ($type == 3) {
592
- $image = imagecreatefrompng($original_filename);
593
- imagecopy($image, $watermark_image_resized, $left, $top, 0, 0, $watermark_width, $watermark_height);
594
- imagealphablending($image, FALSE);
595
- imagesavealpha($image, TRUE);
596
- imagepng($image, $dest_filename, 9);
597
- imagedestroy($image);
598
- }
599
- elseif ($type == 1) {
600
- $image = imagecreatefromgif($original_filename);
601
- $tempimage = imagecreatetruecolor($width, $height);
602
- imagecopy($tempimage, $image, 0, 0, 0, 0, $width, $height);
603
- imagecopy($tempimage, $watermark_image_resized, $left, $top, 0, 0, $watermark_width, $watermark_height);
604
- imagegif($tempimage, $dest_filename);
605
- imagedestroy($image);
606
- imagedestroy($tempimage);
607
- }
608
- imagedestroy($watermark_image);
609
- @ini_restore('memory_limit');
610
- }
611
-
612
  public function save_image_db() {
613
  global $wpdb;
614
  $gal_id = (isset($_POST['current_id']) ? (int) $_POST['current_id'] : 0);
152
  }
153
 
154
  public function recover() {
 
155
  $id = ((isset($_POST['image_current_id'])) ? esc_html(stripslashes($_POST['image_current_id'])) : 0);
156
  global $wd_bwg_options;
157
  $thumb_width = $wd_bwg_options->upload_thumb_width;
158
+ $width = $wd_bwg_options->upload_img_width;
159
+ WDWLibrary::recover_image($id, $thumb_width, $width, 'gallery_page');
160
  }
161
 
162
  public function image_recover_all() {
 
163
  $gallery_id = ((isset($_POST['current_id'])) ? esc_html(stripslashes($_POST['current_id'])) : 0);
164
+ WDWLibrary::bwg_image_recover_all($gallery_id);
 
 
 
 
 
 
 
 
165
  }
166
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  public function image_publish() {
168
  $id = ((isset($_POST['image_current_id'])) ? esc_html(stripslashes($_POST['image_current_id'])) : 0);
169
  global $wpdb;
246
  }
247
 
248
  public function image_set_watermark() {
 
 
 
249
  $gallery_id = ((isset($_POST['current_id'])) ? esc_html(stripslashes($_POST['current_id'])) : 0);
250
+ WDWLibrary::bwg_image_set_watermark($gallery_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  }
252
 
253
  public function image_resize() {
351
  @ini_restore('memory_limit');
352
  return $success;
353
  }
354
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
355
  public function save_image_db() {
356
  global $wpdb;
357
  $gal_id = (isset($_POST['current_id']) ? (int) $_POST['current_id'] : 0);
admin/controllers/BWGControllerOptions_bwg.php CHANGED
@@ -110,268 +110,16 @@ class BWGControllerOptions_bwg {
110
  }
111
  }
112
  }
113
-
114
- function bwg_hex2rgb($hex) {
115
- $hex = str_replace("#", "", $hex);
116
- if (strlen($hex) == 3) {
117
- $r = hexdec(substr($hex,0,1).substr($hex,0,1));
118
- $g = hexdec(substr($hex,1,1).substr($hex,1,1));
119
- $b = hexdec(substr($hex,2,1).substr($hex,2,1));
120
- }
121
- else {
122
- $r = hexdec(substr($hex,0,2));
123
- $g = hexdec(substr($hex,2,2));
124
- $b = hexdec(substr($hex,4,2));
125
- }
126
- $rgb = array($r, $g, $b);
127
- return $rgb;
128
- }
129
-
130
- function bwg_imagettfbboxdimensions($font_size, $font_angle, $font, $text) {
131
- $box = @ImageTTFBBox($font_size, $font_angle, $font, $text) or die;
132
- $max_x = max(array($box[0], $box[2], $box[4], $box[6]));
133
- $max_y = max(array($box[1], $box[3], $box[5], $box[7]));
134
- $min_x = min(array($box[0], $box[2], $box[4], $box[6]));
135
- $min_y = min(array($box[1], $box[3], $box[5], $box[7]));
136
- return array(
137
- "width" => ($max_x - $min_x),
138
- "height" => ($max_y - $min_y)
139
- );
140
- }
141
 
142
  public function image_set_watermark() {
143
- global $wpdb;
144
- global $WD_BWG_UPLOAD_DIR;
145
- global $wd_bwg_options;
146
- $images = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'bwg_image');
147
- switch ($wd_bwg_options->built_in_watermark_type) {
148
- case 'text':
149
- foreach ($images as $image) {
150
- $this->set_text_watermark(ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, $wd_bwg_options->built_in_watermark_text, $wd_bwg_options->built_in_watermark_font, $wd_bwg_options->built_in_watermark_font_size, '#' . $wd_bwg_options->built_in_watermark_color, $wd_bwg_options->built_in_watermark_opacity, $wd_bwg_options->built_in_watermark_position);
151
- }
152
- break;
153
- case 'image':
154
- $watermark_path = str_replace(site_url() . '/', ABSPATH, $wd_bwg_options->built_in_watermark_url);
155
- foreach ($images as $image) {
156
- $this->set_image_watermark(ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, $watermark_path, $wd_bwg_options->built_in_watermark_size, $wd_bwg_options->built_in_watermark_size, $wd_bwg_options->built_in_watermark_position);
157
- }
158
- break;
159
- }
160
- }
161
-
162
- function set_text_watermark($original_filename, $dest_filename, $watermark_text, $watermark_font, $watermark_font_size, $watermark_color, $watermark_transparency, $watermark_position) {
163
- if (!file_exists($original_filename)) {
164
- return;
165
- }
166
- $original_filename = htmlspecialchars_decode($original_filename, ENT_COMPAT | ENT_QUOTES);
167
- $dest_filename = htmlspecialchars_decode($dest_filename, ENT_COMPAT | ENT_QUOTES);
168
-
169
- $watermark_transparency = 127 - ($watermark_transparency * 1.27);
170
- list($width, $height, $type) = getimagesize($original_filename);
171
- $watermark_image = imagecreatetruecolor($width, $height);
172
- $watermark_color = $this->bwg_hex2rgb($watermark_color);
173
- $watermark_color = imagecolorallocatealpha($watermark_image, $watermark_color[0], $watermark_color[1], $watermark_color[2], $watermark_transparency);
174
- $watermark_font = WD_BWG_DIR . '/fonts/' . $watermark_font;
175
- $watermark_font_size = $height * $watermark_font_size / 500;
176
- $watermark_position = explode('-', $watermark_position);
177
- $watermark_sizes = $this->bwg_imagettfbboxdimensions($watermark_font_size, 0, $watermark_font, $watermark_text);
178
-
179
- $top = $height - 5;
180
- $left = $width - $watermark_sizes['width'] - 5;
181
- switch ($watermark_position[0]) {
182
- case 'top':
183
- $top = $watermark_sizes['height'] + 5;
184
- break;
185
- case 'middle':
186
- $top = ($height + $watermark_sizes['height']) / 2;
187
- break;
188
- }
189
- switch ($watermark_position[1]) {
190
- case 'left':
191
- $left = 5;
192
- break;
193
- case 'center':
194
- $left = ($width - $watermark_sizes['width']) / 2;
195
- break;
196
- }
197
- @ini_set('memory_limit', '-1');
198
- if ($type == 2) {
199
- $image = imagecreatefromjpeg($original_filename);
200
- imagettftext($image, $watermark_font_size, 0, $left, $top, $watermark_color, $watermark_font, $watermark_text);
201
- imagejpeg ($image, $dest_filename, 100);
202
- imagedestroy($image);
203
- }
204
- elseif ($type == 3) {
205
- $image = imagecreatefrompng($original_filename);
206
- imagettftext($image, $watermark_font_size, 0, $left, $top, $watermark_color, $watermark_font, $watermark_text);
207
- imageColorAllocateAlpha($image, 0, 0, 0, 127);
208
- imagealphablending($image, FALSE);
209
- imagesavealpha($image, TRUE);
210
- imagepng($image, $dest_filename, 9);
211
- imagedestroy($image);
212
- }
213
- elseif ($type == 1) {
214
- $image = imagecreatefromgif($original_filename);
215
- imageColorAllocateAlpha($watermark_image, 0, 0, 0, 127);
216
- imagecopy($watermark_image, $image, 0, 0, 0, 0, $width, $height);
217
- imagettftext($watermark_image, $watermark_font_size, 0, $left, $top, $watermark_color, $watermark_font, $watermark_text);
218
- imagealphablending($watermark_image, FALSE);
219
- imagesavealpha($watermark_image, TRUE);
220
- imagegif($watermark_image, $dest_filename);
221
- imagedestroy($image);
222
- }
223
- imagedestroy($watermark_image);
224
- @ini_restore('memory_limit');
225
- }
226
-
227
- function set_image_watermark($original_filename, $dest_filename, $watermark_url, $watermark_height, $watermark_width, $watermark_position) {
228
- if (!file_exists($original_filename)) {
229
- return;
230
- }
231
- $original_filename = htmlspecialchars_decode($original_filename, ENT_COMPAT | ENT_QUOTES);
232
- $dest_filename = htmlspecialchars_decode($dest_filename, ENT_COMPAT | ENT_QUOTES);
233
- $watermark_url = htmlspecialchars_decode($watermark_url, ENT_COMPAT | ENT_QUOTES);
234
-
235
- list($width, $height, $type) = getimagesize($original_filename);
236
- list($width_watermark, $height_watermark, $type_watermark) = getimagesize($watermark_url);
237
- $watermark_width = $width * $watermark_width / 100;
238
- $watermark_height = $height_watermark * $watermark_width / $width_watermark;
239
-
240
- $watermark_position = explode('-', $watermark_position);
241
- $top = $height - $watermark_height - 5;
242
- $left = $width - $watermark_width - 5;
243
- switch ($watermark_position[0]) {
244
- case 'top':
245
- $top = 5;
246
- break;
247
- case 'middle':
248
- $top = ($height - $watermark_height) / 2;
249
- break;
250
- }
251
- switch ($watermark_position[1]) {
252
- case 'left':
253
- $left = 5;
254
- break;
255
- case 'center':
256
- $left = ($width - $watermark_width) / 2;
257
- break;
258
- }
259
- @ini_set('memory_limit', '-1');
260
- if ($type_watermark == 2) {
261
- $watermark_image = imagecreatefromjpeg($watermark_url);
262
- }
263
- elseif ($type_watermark == 3) {
264
- $watermark_image = imagecreatefrompng($watermark_url);
265
- }
266
- elseif ($type_watermark == 1) {
267
- $watermark_image = imagecreatefromgif($watermark_url);
268
- }
269
- else {
270
- return false;
271
- }
272
-
273
- $watermark_image_resized = imagecreatetruecolor($watermark_width, $watermark_height);
274
- imagecolorallocatealpha($watermark_image_resized, 255, 255, 255, 127);
275
- imagealphablending($watermark_image_resized, FALSE);
276
- imagesavealpha($watermark_image_resized, TRUE);
277
- imagecopyresampled ($watermark_image_resized, $watermark_image, 0, 0, 0, 0, $watermark_width, $watermark_height, $width_watermark, $height_watermark);
278
-
279
- if ($type == 2) {
280
- $image = imagecreatefromjpeg($original_filename);
281
- imagecopy($image, $watermark_image_resized, $left, $top, 0, 0, $watermark_width, $watermark_height);
282
- if ($dest_filename <> '') {
283
- imagejpeg ($image, $dest_filename, 100);
284
- } else {
285
- header('Content-Type: image/jpeg');
286
- imagejpeg($image, null, 100);
287
- };
288
- imagedestroy($image);
289
- }
290
- elseif ($type == 3) {
291
- $image = imagecreatefrompng($original_filename);
292
- imagecopy($image, $watermark_image_resized, $left, $top, 0, 0, $watermark_width, $watermark_height);
293
- imagealphablending($image, FALSE);
294
- imagesavealpha($image, TRUE);
295
- imagepng($image, $dest_filename, 9);
296
- imagedestroy($image);
297
- }
298
- elseif ($type == 1) {
299
- $image = imagecreatefromgif($original_filename);
300
- $tempimage = imagecreatetruecolor($width, $height);
301
- imagecopy($tempimage, $image, 0, 0, 0, 0, $width, $height);
302
- imagecopy($tempimage, $watermark_image_resized, $left, $top, 0, 0, $watermark_width, $watermark_height);
303
- imagegif($tempimage, $dest_filename);
304
- imagedestroy($image);
305
- imagedestroy($tempimage);
306
- }
307
- imagedestroy($watermark_image);
308
- @ini_restore('memory_limit');
309
  }
310
 
311
-
312
  public function image_recover_all() {
313
- global $wpdb;
314
- global $wd_bwg_options;
315
- $thumb_width = $wd_bwg_options->upload_thumb_width;
316
- $thumb_height = $wd_bwg_options->upload_thumb_height;
317
- $image_ids_col = $wpdb->get_col('SELECT id FROM ' . $wpdb->prefix . 'bwg_image');
318
- foreach ($image_ids_col as $image_id) {
319
- $this->recover_image($image_id, $thumb_width, $thumb_height);
320
- }
321
  $this->display();
322
  }
323
 
324
- public function recover_image($id, $thumb_width, $thumb_height) {
325
- global $WD_BWG_UPLOAD_DIR;
326
- global $wpdb;
327
- $image_data = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'bwg_image WHERE id="%d"', $id));
328
- $filename = htmlspecialchars_decode(ABSPATH . $WD_BWG_UPLOAD_DIR . $image_data->image_url, ENT_COMPAT | ENT_QUOTES);
329
- $thumb_filename = htmlspecialchars_decode(ABSPATH . $WD_BWG_UPLOAD_DIR . $image_data->thumb_url, ENT_COMPAT | ENT_QUOTES);
330
-
331
- if (file_exists($filename) && file_exists($thumb_filename)) {
332
- copy(str_replace('/thumb/', '/.original/', $thumb_filename), $filename);
333
- list($width_orig, $height_orig, $type_orig) = getimagesize($filename);
334
- $percent = $width_orig / $thumb_width;
335
- $thumb_height = $height_orig / $percent;
336
- @ini_set('memory_limit', '-1');
337
- if ($type_orig == 2) {
338
- $img_r = imagecreatefromjpeg($filename);
339
- $dst_r = ImageCreateTrueColor($thumb_width, $thumb_height);
340
- imagecopyresampled($dst_r, $img_r, 0, 0, 0, 0, $thumb_width, $thumb_height, $width_orig, $height_orig);
341
- imagejpeg($dst_r, $thumb_filename, 100);
342
- imagedestroy($img_r);
343
- imagedestroy($dst_r);
344
- }
345
- elseif ($type_orig == 3) {
346
- $img_r = imagecreatefrompng($filename);
347
- $dst_r = ImageCreateTrueColor($thumb_width, $thumb_height);
348
- imageColorAllocateAlpha($dst_r, 0, 0, 0, 127);
349
- imagealphablending($dst_r, FALSE);
350
- imagesavealpha($dst_r, TRUE);
351
- imagecopyresampled($dst_r, $img_r, 0, 0, 0, 0, $thumb_width, $thumb_height, $width_orig, $height_orig);
352
- imagealphablending($dst_r, FALSE);
353
- imagesavealpha($dst_r, TRUE);
354
- imagepng($dst_r, $thumb_filename, 9);
355
- imagedestroy($img_r);
356
- imagedestroy($dst_r);
357
- }
358
- elseif ($type_orig == 1) {
359
- $img_r = imagecreatefromgif($filename);
360
- $dst_r = ImageCreateTrueColor($thumb_width, $thumb_height);
361
- imageColorAllocateAlpha($dst_r, 0, 0, 0, 127);
362
- imagealphablending($dst_r, FALSE);
363
- imagesavealpha($dst_r, TRUE);
364
- imagecopyresampled($dst_r, $img_r, 0, 0, 0, 0, $thumb_width, $thumb_height, $width_orig, $height_orig);
365
- imagealphablending($dst_r, FALSE);
366
- imagesavealpha($dst_r, TRUE);
367
- imagegif($dst_r, $thumb_filename);
368
- imagedestroy($img_r);
369
- imagedestroy($dst_r);
370
- }
371
- @ini_restore('memory_limit');
372
- }
373
- }
374
-
375
  public function resize_image_thumb() {
376
  global $WD_BWG_UPLOAD_DIR;
377
  global $wpdb;
110
  }
111
  }
112
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
  public function image_set_watermark() {
115
+ WDWLibrary::bwg_image_set_watermark(0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
117
 
 
118
  public function image_recover_all() {
119
+ WDWLibrary::bwg_image_recover_all(0);
 
 
 
 
 
 
 
120
  $this->display();
121
  }
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  public function resize_image_thumb() {
124
  global $WD_BWG_UPLOAD_DIR;
125
  global $wpdb;
filemanager/UploadHandler.php CHANGED
@@ -11,7 +11,8 @@
11
  */
12
 
13
  if (function_exists('current_user_can')) {
14
- if (!current_user_can('manage_options')) {
 
15
  die('Access Denied');
16
  }
17
  }
@@ -105,9 +106,6 @@ class bwg_UploadHandler {
105
  }
106
  $this->options += array(
107
  'image_versions' => array(
108
- // Uncomment the following version to restrict the size of
109
- // uploaded images:
110
-
111
  // Uncomment the following to create medium sized images:
112
  /*
113
  'medium' => array(
11
  */
12
 
13
  if (function_exists('current_user_can')) {
14
+ global $wd_bwg_options;
15
+ if (!current_user_can($wd_bwg_options->permissions)) {
16
  die('Access Denied');
17
  }
18
  }
106
  }
107
  $this->options += array(
108
  'image_versions' => array(
 
 
 
109
  // Uncomment the following to create medium sized images:
110
  /*
111
  'medium' => array(
filemanager/controller.php CHANGED
@@ -36,13 +36,13 @@ class FilemanagerController {
36
  ////////////////////////////////////////////////////////////////////////////////////////
37
  // Public Methods //
38
  ////////////////////////////////////////////////////////////////////////////////////////
39
- public function execute() {
40
  $task = isset($_REQUEST['task']) ? stripslashes(esc_html($_REQUEST['task'])) : 'display';
41
  if (method_exists($this, $task)) {
42
- $this->$task();
43
  }
44
  else {
45
- $this->display();
46
  }
47
  }
48
 
@@ -54,13 +54,20 @@ class FilemanagerController {
54
  return $this->uploads_url;
55
  }
56
 
57
- public function display() {
58
  require_once WD_BWG_DIR . '/filemanager/model.php';
59
  $model = new FilemanagerModel($this);
60
 
61
  require_once WD_BWG_DIR . '/filemanager/view.php';
62
  $view = new FilemanagerView($this, $model);
63
- $view->display();
 
 
 
 
 
 
 
64
  }
65
 
66
  public function make_dir() {
36
  ////////////////////////////////////////////////////////////////////////////////////////
37
  // Public Methods //
38
  ////////////////////////////////////////////////////////////////////////////////////////
39
+ public function execute($ajax = false, $load_count = 0) {
40
  $task = isset($_REQUEST['task']) ? stripslashes(esc_html($_REQUEST['task'])) : 'display';
41
  if (method_exists($this, $task)) {
42
+ $this->$task($ajax, $load_count);
43
  }
44
  else {
45
+ $this->display($ajax, $load_count);
46
  }
47
  }
48
 
54
  return $this->uploads_url;
55
  }
56
 
57
+ public function display($ajax = false, $load_count = 0) {
58
  require_once WD_BWG_DIR . '/filemanager/model.php';
59
  $model = new FilemanagerModel($this);
60
 
61
  require_once WD_BWG_DIR . '/filemanager/view.php';
62
  $view = new FilemanagerView($this, $model);
63
+ $view->display($ajax, $load_count);
64
+ }
65
+
66
+ public function get_images($load_count){
67
+ require_once WD_BWG_DIR . '/filemanager/model.php';
68
+ $model = new FilemanagerModel($this);
69
+ $file_manager_data = $model->get_file_manager_data(true, $load_count);
70
+ return $file_manager_data;
71
  }
72
 
73
  public function make_dir() {
filemanager/css/default.css CHANGED
@@ -134,12 +134,11 @@ html, body, div, span, th, td, a {
134
  float: left;
135
  margin: 0;
136
  padding: 0;
137
- margin-left: 5px;
138
  }
139
 
140
  .ctrls_bar .ctrls_right {
141
  float: right;
142
- margin: 0;
143
  padding: 0;
144
  }
145
 
@@ -243,8 +242,8 @@ html, body, div, span, th, td, a {
243
  color: #F5F6F7;
244
  cursor: pointer;
245
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
246
- height: 30px !important;
247
- font-size: 14px !important;
248
  }
249
 
250
  .ctrl_bar_btn.btn_upload_files, .ctrl_bar_btn.btn_import_files:hover {
@@ -272,7 +271,7 @@ html, body, div, span, th, td, a {
272
  }
273
 
274
  .ctrl_bar_btn.btn_secondary {
275
- background: linear-gradient(to bottom, #FEFEFE, #F4F4F4) repeat scroll 0 0 #F3F3F3;
276
  border-color: #BBBBBB;
277
  color: #333333 !important;
278
  text-shadow: 0 1px 0 #FFFFFF;
@@ -305,6 +304,8 @@ html, body, div, span, th, td, a {
305
  .ctrl_bar_btn.btn_back {
306
  background-image: url("../images/btn_icons/back.png");
307
  }
 
 
308
  /* sort icons */
309
  .sort_order_asc {
310
  display: inline-block !important;
@@ -335,6 +336,8 @@ html, body, div, span, th, td, a {
335
  text-decoration: none;
336
  cursor: pointer;
337
  }
 
 
338
  /* path */
339
  #path {
340
  display: table-row;
@@ -436,7 +439,7 @@ html, body, div, span, th, td, a {
436
  right: 0;
437
  font-size: 24pt !important;
438
  color: #c0c0c0;
439
- line-height:33px;
440
  }
441
 
442
  #btnBrowseContainer {
@@ -535,6 +538,7 @@ html, body, div, span, th, td, a {
535
  margin-left:-30px;
536
  }
537
 
 
538
  .wp-pointer.wp-pointer-aligned-right .wp-pointer-arrow {
539
  left: auto;
540
  right: 233px;
@@ -545,20 +549,6 @@ html, body, div, span, th, td, a {
545
  margin:10px 0 0 -30px;
546
  }
547
 
548
- .bwg_selected_img {
549
- margin-top :-20px;
550
- }
551
- .bwg_select_img {
552
- margin-top: -50px;
553
- margin-left:10px;
554
- }
555
- .wp-pointer-aligned-center .wp-pointer-arrow {
556
- margin-top:30px;
557
- }
558
- .bwg_upload_img {
559
- margin:10px 0 0 -30px;
560
- }
561
-
562
  .bwg_selected_img {
563
  margin-top :-20px;
564
  }
@@ -592,9 +582,9 @@ a.wd-btn{
592
  outline:none !important;
593
  }
594
  .wd-btn-secondary{
595
- background-color: #FFFFFF;
596
- color: #686;
597
- border: 1px solid #ddd;
598
  }
599
 
600
  .wd-btn-primary{
@@ -620,16 +610,16 @@ a.wd-btn-primary:hover, a.wd-btn-primary:active, a.wd-btn-primary:link{
620
  background-image:url(../images/btn_icons/upload.png);
621
  }
622
  .wd-btn-add{
623
- background-image:url(../images/icons/add-new.png);
624
  }
625
  .wd-btn-apply{
626
- background-image:url(../images/icons/apply.png);
627
  }
628
  .wd-btn-cancel{
629
- background-image:url(../images/icons/cancel.png);
630
  }
631
  .wd-not-image{
632
  padding: 0px 10px 1px 10px !important;
633
  background-repeat: no-repeat;
634
  background-position: 10% 50%;
635
- }
134
  float: left;
135
  margin: 0;
136
  padding: 0;
 
137
  }
138
 
139
  .ctrls_bar .ctrls_right {
140
  float: right;
141
+ margin: 0 auto;
142
  padding: 0;
143
  }
144
 
242
  color: #F5F6F7;
243
  cursor: pointer;
244
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
245
+ height: 32px !important;
246
+ font-size: 13px !important;
247
  }
248
 
249
  .ctrl_bar_btn.btn_upload_files, .ctrl_bar_btn.btn_import_files:hover {
271
  }
272
 
273
  .ctrl_bar_btn.btn_secondary {
274
+ background: linear-gradient(to bottom, #FEFEFE, #fff) repeat scroll 0 0 #F3F3F3;
275
  border-color: #BBBBBB;
276
  color: #333333 !important;
277
  text-shadow: 0 1px 0 #FFFFFF;
304
  .ctrl_bar_btn.btn_back {
305
  background-image: url("../images/btn_icons/back.png");
306
  }
307
+
308
+
309
  /* sort icons */
310
  .sort_order_asc {
311
  display: inline-block !important;
336
  text-decoration: none;
337
  cursor: pointer;
338
  }
339
+
340
+
341
  /* path */
342
  #path {
343
  display: table-row;
439
  right: 0;
440
  font-size: 24pt !important;
441
  color: #c0c0c0;
442
+ line-height: 33px;
443
  }
444
 
445
  #btnBrowseContainer {
538
  margin-left:-30px;
539
  }
540
 
541
+
542
  .wp-pointer.wp-pointer-aligned-right .wp-pointer-arrow {
543
  left: auto;
544
  right: 233px;
549
  margin:10px 0 0 -30px;
550
  }
551
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
552
  .bwg_selected_img {
553
  margin-top :-20px;
554
  }
582
  outline:none !important;
583
  }
584
  .wd-btn-secondary{
585
+ background-color: #FFFFFF;
586
+ color: #686;
587
+ border: 1px solid #ddd;
588
  }
589
 
590
  .wd-btn-primary{
610
  background-image:url(../images/btn_icons/upload.png);
611
  }
612
  .wd-btn-add{
613
+ background-image:url("../images/icons/add-new.png");
614
  }
615
  .wd-btn-apply{
616
+ background-image:url("../images/icons/apply.png");
617
  }
618
  .wd-btn-cancel{
619
+ background-image:url("../images/icons/cancel.png");
620
  }
621
  .wd-not-image{
622
  padding: 0px 10px 1px 10px !important;
623
  background-repeat: no-repeat;
624
  background-position: 10% 50%;
625
+ }
filemanager/js/default.js CHANGED
@@ -4,7 +4,6 @@
4
  * Time: 3:56 PM
5
  */
6
 
7
-
8
  ////////////////////////////////////////////////////////////////////////////////////////
9
  // Events //
10
  ////////////////////////////////////////////////////////////////////////////////////////
@@ -21,7 +20,8 @@ var filesSelectedML;
21
  var dragFiles;
22
  var isUploading;
23
 
24
-
 
25
  ////////////////////////////////////////////////////////////////////////////////////////
26
  // Constructor //
27
  ////////////////////////////////////////////////////////////////////////////////////////
@@ -29,6 +29,42 @@ var isUploading;
29
  // Public Methods //
30
  ////////////////////////////////////////////////////////////////////////////////////////
31
  jQuery(document).ready(function () {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  if (jQuery("#importer").css("display") != 'none') {
33
  var all_images_count = jQuery("#importer .item_thumb img").length;
34
  }
@@ -596,4 +632,76 @@ function onBtnSelectAllMediLibraryClick() {
596
  keyFileSelectedML = this;
597
  }
598
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
599
  }
4
  * Time: 3:56 PM
5
  */
6
 
 
7
  ////////////////////////////////////////////////////////////////////////////////////////
8
  // Events //
9
  ////////////////////////////////////////////////////////////////////////////////////////
20
  var dragFiles;
21
  var isUploading;
22
 
23
+ var ajax = true;
24
+ var item_number = 100;
25
  ////////////////////////////////////////////////////////////////////////////////////////
26
  // Constructor //
27
  ////////////////////////////////////////////////////////////////////////////////////////
29
  // Public Methods //
30
  ////////////////////////////////////////////////////////////////////////////////////////
31
  jQuery(document).ready(function () {
32
+ var elements = 1;
33
+ var all_item_count = jQuery("#explorer_body_container #explorer_body").data("files_count");
34
+ jQuery("#explorer_body_container").scroll(function () {
35
+ var explorer_item_count = jQuery("#explorer_body .explorer_item").length;
36
+ if (ajax && explorer_item_count < all_item_count) {
37
+ var scroll = jQuery(this).scrollTop();
38
+ var scroll_position = jQuery(this).scrollTop() + jQuery(this).innerHeight();
39
+ var scroll_Height = jQuery(this)[0].scrollHeight;
40
+ if (scroll_position >= scroll_Height) {
41
+ jQuery('#loading_div').show();
42
+ jQuery('#opacity_div').show();
43
+ elements++;
44
+ jQuery.ajax({
45
+ type: "POST",
46
+ url: ajaxurl,
47
+ dataType: 'json',
48
+ data: {
49
+ action: 'addImages',
50
+ load_count: elements,
51
+ addImages_ajax: 'addImages_ajax'
52
+ },
53
+ success: function (response) {
54
+ if (response.files.length === 0) {
55
+ jQuery('#loading_div').hide();
56
+ jQuery('#opacity_div').hide();
57
+ ajax = false;
58
+ return;
59
+ } else {
60
+ ajax_print_images(response);
61
+ }
62
+ }
63
+ });
64
+ }
65
+ }
66
+ });
67
+
68
  if (jQuery("#importer").css("display") != 'none') {
69
  var all_images_count = jQuery("#importer .item_thumb img").length;
70
  }
632
  keyFileSelectedML = this;
633
  }
634
  });
635
+ }
636
+
637
+ function ajax_print_images(response) {
638
+ for (i in response.files) {
639
+ var corent_file = response.files[i];
640
+ var name = corent_file["name"];
641
+ var filename = corent_file["filename"];
642
+ var filethumb = corent_file["thumb"];
643
+ var filesize = corent_file["size"];
644
+ var filetype = corent_file["type"];
645
+ var date_modified = corent_file["date_modified"];
646
+ var fileresolution = corent_file["resolution"];
647
+ var fileCredit = corent_file["credit"];
648
+ var fileAperture = corent_file["aperture"];
649
+ var fileCamera = corent_file["camera"];
650
+ var fileCaption = corent_file["caption"];
651
+ var fileIso = corent_file["iso"];
652
+ var fileOrientation = corent_file["orientation"];
653
+ var fileCopyright = corent_file["copyright"];
654
+ var onmouseover = "onFileMOver(event, this);";
655
+ var onmouseout = "onFileMOut(event, this);";
656
+ var onclick = "onFileClick(event, this);";
657
+ var ondblclick = "onFileDblClick(event, this);";
658
+ var ondragstart = "onFileDragStart(event, this);";
659
+ var ondragover = "";
660
+ var ondrop = "";
661
+ if (corent_file['is_dir'] == true) {
662
+ ondragover = "onFileDragOver(event, this);";
663
+ ondrop = "onFileDrop(event, this);";
664
+ }
665
+ var isDir = false;
666
+ if (corent_file['is_dir'] === true) {
667
+ isDir = 'true';
668
+ }
669
+
670
+ item_number = item_number + i;
671
+ var item_thumb = '<span class="item_thumb"><img src="' + corent_file['thumb'] + '"/></span>';
672
+ var item_icon = '<span class="item_icon"><img src="'+corent_file['icon']+'"/> </span>';
673
+ var item_name = '<span class="item_name">'+corent_file['name']+'</span>';
674
+ var item_size = '<span class="item_size">'+corent_file['size']+'</span>';
675
+ var item_date_modified = '<span class="item_date_modified">'+corent_file['date_modified']+'</span>';
676
+ var item_numbering = '<span class="item_numbering">'+item_number+'</span>';
677
+
678
+ var explorer_item = '<div class="explorer_item" ' +
679
+ 'name="' + name + '" ' +
680
+ 'filename="' + filename + '" ' +
681
+ 'filethumb="' + filethumb + '" ' +
682
+ 'filesize="' + filesize + '" ' +
683
+ 'filetype="' + filetype + '" ' +
684
+ 'date_modified="' + date_modified + '" ' +
685
+ 'fileresolution="' + fileresolution + '" ' +
686
+ 'fileresolution="' + fileresolution + '" ' +
687
+ 'fileCredit="' + fileCredit + '" ' +
688
+ 'fileAperture="' + fileAperture + '" ' +
689
+ 'fileCamera="' + fileCamera + '" ' +
690
+ 'fileCaption="' + fileCaption + '" ' +
691
+ 'fileIso="' + fileIso + '" ' +
692
+ 'fileOrientation="' + fileOrientation + '" ' +
693
+ 'fileCopyright="' + fileCopyright + '" ' +
694
+ 'isDir="' + isDir + '" ' +
695
+ 'onmouseover="' + onmouseover + '" ' +
696
+ 'onmouseout="' + onmouseout + '" ' +
697
+ 'onclick="' + onclick + '" ' +
698
+ 'ondblclick="' + ondblclick + '" ' +
699
+ 'ondragstart="' + ondragstart + '" ' +
700
+ 'ondragover="' + ondragover + '" ' +
701
+ 'ondrop="' + ondrop + '" ' +
702
+ 'draggable="true" >'+item_numbering + item_thumb + item_icon+item_name+item_size+item_date_modified+'</div>';
703
+ jQuery("#explorer_body").append(explorer_item);
704
+ jQuery('#loading_div').hide();
705
+ jQuery('#opacity_div').hide();
706
+ }
707
  }
filemanager/model.php CHANGED
@@ -30,7 +30,7 @@ class FilemanagerModel {
30
  ////////////////////////////////////////////////////////////////////////////////////////
31
  // Public Methods //
32
  ////////////////////////////////////////////////////////////////////////////////////////
33
- public function get_file_manager_data() {
34
  global $wd_bwg_options;
35
  $session_data = array();
36
  $session_data['sort_by'] = $this->get_from_session('sort_by', 'date_modified');
@@ -45,11 +45,12 @@ class FilemanagerModel {
45
  $data['session_data'] = $session_data;
46
  $data['path_components'] = $this->get_path_components();
47
  $data['dir'] = $this->controller->get_uploads_dir() . (isset($_REQUEST['dir']) ? esc_html($_REQUEST['dir']) : '');
48
- $data['files'] = $this->get_files($session_data['sort_by'], $session_data['sort_order']);
 
 
49
  $data['media_library_files'] = ($wd_bwg_options->enable_ML_import ? $this->get_media_library_files($session_data['sort_by'], $session_data['sort_order']) : array());
50
  $data['extensions'] = (isset($_REQUEST['extensions']) ? esc_html($_REQUEST['extensions']) : '');
51
  $data['callback'] = (isset($_REQUEST['callback']) ? esc_html($_REQUEST['callback']) : '');
52
-
53
  return $data;
54
  }
55
 
@@ -100,7 +101,7 @@ class FilemanagerModel {
100
  return $components;
101
  }
102
 
103
- function get_files($sort_by, $sort_order) {
104
  $icons_dir_path = WD_BWG_DIR . '/filemanager/images/file_icons';
105
  $icons_dir_url = WD_BWG_URL . '/filemanager/images/file_icons';
106
  $valid_types = explode(',', isset($_REQUEST['extensions']) ? strtolower(esc_html($_REQUEST['extensions'])) : '*');
@@ -167,7 +168,13 @@ class FilemanagerModel {
167
 
168
  // $result = $sort_order == 'asc' ? array_merge($dirs, $files) : array_merge($files, $dirs);
169
  $result = array_merge($dirs, $files);
170
- return $result;
 
 
 
 
 
 
171
  }
172
 
173
  function get_media_library_files($sort_by, $sort_order) {
30
  ////////////////////////////////////////////////////////////////////////////////////////
31
  // Public Methods //
32
  ////////////////////////////////////////////////////////////////////////////////////////
33
+ public function get_file_manager_data($ajax = false, $load_count = 0) {
34
  global $wd_bwg_options;
35
  $session_data = array();
36
  $session_data['sort_by'] = $this->get_from_session('sort_by', 'date_modified');
45
  $data['session_data'] = $session_data;
46
  $data['path_components'] = $this->get_path_components();
47
  $data['dir'] = $this->controller->get_uploads_dir() . (isset($_REQUEST['dir']) ? esc_html($_REQUEST['dir']) : '');
48
+ $get_files_data = $this->get_files($session_data['sort_by'], $session_data['sort_order'], $ajax, $load_count);
49
+ $data['files'] = $get_files_data['files'];
50
+ $data['files_count'] = $get_files_data['files_count'];
51
  $data['media_library_files'] = ($wd_bwg_options->enable_ML_import ? $this->get_media_library_files($session_data['sort_by'], $session_data['sort_order']) : array());
52
  $data['extensions'] = (isset($_REQUEST['extensions']) ? esc_html($_REQUEST['extensions']) : '');
53
  $data['callback'] = (isset($_REQUEST['callback']) ? esc_html($_REQUEST['callback']) : '');
 
54
  return $data;
55
  }
56
 
101
  return $components;
102
  }
103
 
104
+ function get_files($sort_by, $sort_order, $ajax = false, $load_count = 0) {
105
  $icons_dir_path = WD_BWG_DIR . '/filemanager/images/file_icons';
106
  $icons_dir_url = WD_BWG_URL . '/filemanager/images/file_icons';
107
  $valid_types = explode(',', isset($_REQUEST['extensions']) ? strtolower(esc_html($_REQUEST['extensions'])) : '*');
168
 
169
  // $result = $sort_order == 'asc' ? array_merge($dirs, $files) : array_merge($files, $dirs);
170
  $result = array_merge($dirs, $files);
171
+ $files_count = count($result);
172
+ if ($ajax && $load_count > 0) {
173
+ $images_count = 100;
174
+ $min_count = $images_count * ($load_count - 1);
175
+ $result = array_slice($result, $min_count, $images_count, true);
176
+ }
177
+ return array("files" => $result, "files_count" => $files_count);
178
  }
179
 
180
  function get_media_library_files($sort_by, $sort_order) {
filemanager/view.php CHANGED
@@ -29,7 +29,7 @@ class FilemanagerView {
29
  ////////////////////////////////////////////////////////////////////////////////////////
30
  // Public Methods //
31
  ////////////////////////////////////////////////////////////////////////////////////////
32
- public function display() {
33
  if (isset($_GET['filemanager_msg']) && esc_html($_GET['filemanager_msg']) != '') {
34
  ?>
35
  <div id="file_manager_message" style="height:40px;">
@@ -41,7 +41,7 @@ class FilemanagerView {
41
  $_GET['filemanager_msg'] = '';
42
  }
43
  global $wd_bwg_options;
44
- $file_manager_data = $this->model->get_file_manager_data();
45
  $items_view = $file_manager_data['session_data']['items_view'];
46
  $sort_by = $file_manager_data['session_data']['sort_by'];
47
  $sort_order = $file_manager_data['session_data']['sort_order'];
@@ -63,8 +63,8 @@ class FilemanagerView {
63
  ?>
64
  <script src="<?php echo WD_BWG_URL; ?>/filemanager/js/jq_uploader/jquery.iframe-transport.js"></script>
65
  <script src="<?php echo WD_BWG_URL; ?>/filemanager/js/jq_uploader/jquery.fileupload.js"></script>
66
- <link media="all" type="text/css" href="<?php echo get_admin_url(); ?>load-styles.php?c=1&amp;dir=ltr&amp;load=admin-bar,dashicons,wp-admin,buttons,wp-auth-check,wp-pointer" rel="stylesheet">
67
  <script>
 
68
  var DS = "<?php echo addslashes('/'); ?>";
69
 
70
  var errorLoadingFile = "<?php echo __('File loading failed', 'bwg_back'); ?>";
@@ -100,9 +100,8 @@ class FilemanagerView {
100
  }
101
  $i = 0;
102
  ?>
103
-
104
  <form id="adminForm" name="adminForm" action="" method="post">
105
- <?php wp_nonce_field( '', 'bwg_nonce' ); ?>
106
  <div id="wrapper">
107
  <div id="opacity_div" style="background-color: rgba(0, 0, 0, 0.2); position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 99998;"></div>
108
  <div id="loading_div" style="text-align: center; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 99999;">
@@ -199,7 +198,7 @@ class FilemanagerView {
199
  </div>
200
  <div id="explorer_body_wrapper">
201
  <div id="explorer_body_container">
202
- <div id="explorer_body">
203
  <?php
204
  foreach ($file_manager_data['files'] as $key => $file) {
205
  $file['name'] = esc_html($file['name']);
@@ -229,12 +228,12 @@ class FilemanagerView {
229
  <?php
230
  if ($file['is_dir'] == true) {
231
  ?>
232
- ondragover="onFileDragOver(event, this);"
233
- ondrop="onFileDrop(event, this);"
234
  <?php
235
  }
236
  ?>
237
- isDir="<?php echo $file['is_dir'] == true ? 'true' : 'false'; ?>">
238
  <span class="item_numbering"><?php echo ++$i; ?></span>
239
  <span class="item_thumb">
240
  <img src="<?php echo $file['thumb']; ?>" <?php echo $key >= 24 ? 'onload="loaded()"' : ''; ?> />
@@ -380,10 +379,10 @@ class FilemanagerView {
380
  <span><?php echo __('Drag files here or click the button below','bwg_back') . '<br />' . __('to upload files','bwg_back')?></span>
381
  </div>
382
  <div id="btnBrowseContainer">
383
- <?php
384
- $query_url = wp_nonce_url( admin_url('admin-ajax.php'), 'bwg_UploadHandler', 'bwg_nonce' );
385
- $query_url = add_query_arg(array('action' => 'bwg_UploadHandler', 'dir' => (isset($_REQUEST['dir']) ? esc_html($_REQUEST['dir']) : '') . '/'), $query_url);
386
- ?>
387
  <input id="jQueryUploader" type="file" name="files[]"
388
  data-url="<?php echo $query_url; ?>"
389
  multiple>
29
  ////////////////////////////////////////////////////////////////////////////////////////
30
  // Public Methods //
31
  ////////////////////////////////////////////////////////////////////////////////////////
32
+ public function display($ajax = false, $load_count = 0) {
33
  if (isset($_GET['filemanager_msg']) && esc_html($_GET['filemanager_msg']) != '') {
34
  ?>
35
  <div id="file_manager_message" style="height:40px;">
41
  $_GET['filemanager_msg'] = '';
42
  }
43
  global $wd_bwg_options;
44
+ $file_manager_data = $this->model->get_file_manager_data($ajax,$load_count);
45
  $items_view = $file_manager_data['session_data']['items_view'];
46
  $sort_by = $file_manager_data['session_data']['sort_by'];
47
  $sort_order = $file_manager_data['session_data']['sort_order'];
63
  ?>
64
  <script src="<?php echo WD_BWG_URL; ?>/filemanager/js/jq_uploader/jquery.iframe-transport.js"></script>
65
  <script src="<?php echo WD_BWG_URL; ?>/filemanager/js/jq_uploader/jquery.fileupload.js"></script>
 
66
  <script>
67
+ var ajaxurl = "<?php echo wp_nonce_url( admin_url('admin-ajax.php'), 'addImages', 'bwg_nonce' ); ?>";
68
  var DS = "<?php echo addslashes('/'); ?>";
69
 
70
  var errorLoadingFile = "<?php echo __('File loading failed', 'bwg_back'); ?>";
100
  }
101
  $i = 0;
102
  ?>
 
103
  <form id="adminForm" name="adminForm" action="" method="post">
104
+ <?php wp_nonce_field( '', 'bwg_nonce' ); ?>
105
  <div id="wrapper">
106
  <div id="opacity_div" style="background-color: rgba(0, 0, 0, 0.2); position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 99998;"></div>
107
  <div id="loading_div" style="text-align: center; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 99999;">
198
  </div>
199
  <div id="explorer_body_wrapper">
200
  <div id="explorer_body_container">
201
+ <div id="explorer_body" data-files_count="<?php echo $file_manager_data["files_count"]; ?>">
202
  <?php
203
  foreach ($file_manager_data['files'] as $key => $file) {
204
  $file['name'] = esc_html($file['name']);
228
  <?php
229
  if ($file['is_dir'] == true) {
230
  ?>
231
+ ondragover="onFileDragOver(event, this);"
232
+ ondrop="onFileDrop(event, this);"
233
  <?php
234
  }
235
  ?>
236
+ isDir="<?php echo $file['is_dir'] == true ? 'true' : 'false'; ?>">
237
  <span class="item_numbering"><?php echo ++$i; ?></span>
238
  <span class="item_thumb">
239
  <img src="<?php echo $file['thumb']; ?>" <?php echo $key >= 24 ? 'onload="loaded()"' : ''; ?> />
379
  <span><?php echo __('Drag files here or click the button below','bwg_back') . '<br />' . __('to upload files','bwg_back')?></span>
380
  </div>
381
  <div id="btnBrowseContainer">
382
+ <?php
383
+ $query_url = wp_nonce_url( admin_url('admin-ajax.php'), 'bwg_UploadHandler', 'bwg_nonce' );
384
+ $query_url = add_query_arg(array('action' => 'bwg_UploadHandler', 'dir' => (isset($_REQUEST['dir']) ? esc_html($_REQUEST['dir']) : '') . '/'), $query_url);
385
+ ?>
386
  <input id="jQueryUploader" type="file" name="files[]"
387
  data-url="<?php echo $query_url; ?>"
388
  multiple>
framework/WDWLibrary.php CHANGED
@@ -723,7 +723,8 @@ class WDWLibrary {
723
  jQuery(".search_tags").SumoSelect({
724
  placeholder: bwg_objectsL10n.bwg_select_tag,
725
  search: 1,
726
- searchText: bwg_objectsL10n.bwg_search
 
727
  });
728
  </script>
729
  <?php
@@ -873,8 +874,8 @@ class WDWLibrary {
873
  $len_end = strpos(substr(substr($shortcode_font_string, $len_start), $len_current + 1), '"');
874
  $shortcode_fonts = str_replace('"', '', substr(substr($shortcode_font_string, $len_start), $len_current, $len_end + 1));
875
  if (true == in_array($shortcode_fonts, $google_fonts)) {
876
- $google_array[$shortcode_fonts] = $shortcode_fonts;
877
- }
878
  }
879
  }
880
  if ($theme) {
@@ -1071,4 +1072,303 @@ class WDWLibrary {
1071
 
1072
  return array('rows' => $row, 'page_nav' => $page_nav);
1073
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1074
  }
723
  jQuery(".search_tags").SumoSelect({
724
  placeholder: bwg_objectsL10n.bwg_select_tag,
725
  search: 1,
726
+ searchText: bwg_objectsL10n.bwg_search,
727
+ forceCustomRendering: true
728
  });
729
  </script>
730
  <?php
874
  $len_end = strpos(substr(substr($shortcode_font_string, $len_start), $len_current + 1), '"');
875
  $shortcode_fonts = str_replace('"', '', substr(substr($shortcode_font_string, $len_start), $len_current, $len_end + 1));
876
  if (true == in_array($shortcode_fonts, $google_fonts)) {
877
+ $google_array[$shortcode_fonts] = $shortcode_fonts;
878
+ }
879
  }
880
  }
881
  if ($theme) {
1072
 
1073
  return array('rows' => $row, 'page_nav' => $page_nav);
1074
  }
1075
+
1076
+ public static function bwg_image_set_watermark($gallery_id) {
1077
+ global $wpdb;
1078
+ global $WD_BWG_UPLOAD_DIR;
1079
+ global $wd_bwg_options;
1080
+ if ($gallery_id != 0) {
1081
+ $images = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'bwg_image WHERE gallery_id="%d"', $gallery_id));
1082
+ }
1083
+ else {
1084
+ $images = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'bwg_image');
1085
+ }
1086
+ switch ($wd_bwg_options->built_in_watermark_type) {
1087
+ case 'text':
1088
+ foreach ($images as $image) {
1089
+ if (isset($_POST['check_' . $image->id]) || isset($_POST['check_all_items'])) {
1090
+ self::set_text_watermark(ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, html_entity_decode($wd_bwg_options->built_in_watermark_text), $wd_bwg_options->built_in_watermark_font, $wd_bwg_options->built_in_watermark_font_size, '#' . $wd_bwg_options->built_in_watermark_color, $wd_bwg_options->built_in_watermark_opacity, $wd_bwg_options->built_in_watermark_position);
1091
+ }
1092
+ if ($gallery_id == 0) {
1093
+ self::set_text_watermark(ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, html_entity_decode($wd_bwg_options->built_in_watermark_text), $wd_bwg_options->built_in_watermark_font, $wd_bwg_options->built_in_watermark_font_size, '#' . $wd_bwg_options->built_in_watermark_color, $wd_bwg_options->built_in_watermark_opacity, $wd_bwg_options->built_in_watermark_position);
1094
+ }
1095
+ }
1096
+ break;
1097
+ case 'image':
1098
+ $watermark_path = str_replace(site_url() . '/', ABSPATH, $wd_bwg_options->built_in_watermark_url);
1099
+ foreach ($images as $image) {
1100
+ if (isset($_POST['check_' . $image->id]) || isset($_POST['check_all_items'])) {
1101
+ self::set_image_watermark(ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, $watermark_path, $wd_bwg_options->built_in_watermark_size, $wd_bwg_options->built_in_watermark_size, $wd_bwg_options->built_in_watermark_position);
1102
+ }
1103
+ if ($gallery_id == 0) {
1104
+ self::set_image_watermark(ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, ABSPATH . $WD_BWG_UPLOAD_DIR . $image->image_url, $watermark_path, $wd_bwg_options->built_in_watermark_size, $wd_bwg_options->built_in_watermark_size, $wd_bwg_options->built_in_watermark_position);
1105
+ }
1106
+ }
1107
+ break;
1108
+ }
1109
+ }
1110
+
1111
+ public static function set_text_watermark($original_filename, $dest_filename, $watermark_text, $watermark_font, $watermark_font_size, $watermark_color, $watermark_transparency, $watermark_position) {
1112
+ $original_filename = htmlspecialchars_decode($original_filename, ENT_COMPAT | ENT_QUOTES);
1113
+ $dest_filename = htmlspecialchars_decode($dest_filename, ENT_COMPAT | ENT_QUOTES);
1114
+
1115
+ $watermark_transparency = 127 - ($watermark_transparency * 1.27);
1116
+ list($width, $height, $type) = getimagesize($original_filename);
1117
+ $watermark_image = imagecreatetruecolor($width, $height);
1118
+
1119
+ $watermark_color = self::bwg_hex2rgb($watermark_color);
1120
+ $watermark_color = imagecolorallocatealpha($watermark_image, $watermark_color[0], $watermark_color[1], $watermark_color[2], $watermark_transparency);
1121
+ $watermark_font = WD_BWG_DIR . '/fonts/' . $watermark_font;
1122
+ $watermark_font_size = (($height > $width ? $width : $height) * $watermark_font_size / 500) . 'px';
1123
+ $watermark_position = explode('-', $watermark_position);
1124
+ $watermark_sizes = self::bwg_imagettfbboxdimensions($watermark_font_size, 0, $watermark_font, $watermark_text);
1125
+
1126
+ $top = $height - 5;
1127
+ $left = $width - $watermark_sizes['width'] - 5;
1128
+ switch ($watermark_position[0]) {
1129
+ case 'top':
1130
+ $top = $watermark_sizes['height'] + 5;
1131
+ break;
1132
+ case 'middle':
1133
+ $top = ($height + $watermark_sizes['height']) / 2;
1134
+ break;
1135
+ }
1136
+ switch ($watermark_position[1]) {
1137
+ case 'left':
1138
+ $left = 5;
1139
+ break;
1140
+ case 'center':
1141
+ $left = ($width - $watermark_sizes['width']) / 2;
1142
+ break;
1143
+ }
1144
+ @ini_set('memory_limit', '-1');
1145
+ if ($type == 2) {
1146
+ $image = imagecreatefromjpeg($original_filename);
1147
+ imagettftext($image, $watermark_font_size, 0, $left, $top, $watermark_color, $watermark_font, $watermark_text);
1148
+ imagejpeg ($image, $dest_filename, 100);
1149
+ imagedestroy($image);
1150
+ }
1151
+ elseif ($type == 3) {
1152
+ $image = imagecreatefrompng($original_filename);
1153
+ imagettftext($image, $watermark_font_size, 0, $left, $top, $watermark_color, $watermark_font, $watermark_text);
1154
+ imageColorAllocateAlpha($image, 0, 0, 0, 127);
1155
+ imagealphablending($image, FALSE);
1156
+ imagesavealpha($image, TRUE);
1157
+ imagepng($image, $dest_filename, 9);
1158
+ imagedestroy($image);
1159
+ }
1160
+ elseif ($type == 1) {
1161
+ $image = imagecreatefromgif($original_filename);
1162
+ imageColorAllocateAlpha($watermark_image, 0, 0, 0, 127);
1163
+ imagecopy($watermark_image, $image, 0, 0, 0, 0, $width, $height);
1164
+ imagettftext($watermark_image, $watermark_font_size, 0, $left, $top, $watermark_color, $watermark_font, $watermark_text);
1165
+ imagealphablending($watermark_image, FALSE);
1166
+ imagesavealpha($watermark_image, TRUE);
1167
+ imagegif($watermark_image, $dest_filename);
1168
+ imagedestroy($image);
1169
+ }
1170
+ imagedestroy($watermark_image);
1171
+ @ini_restore('memory_limit');
1172
+ }
1173
+
1174
+ public static function set_image_watermark($original_filename, $dest_filename, $watermark_url, $watermark_height, $watermark_width, $watermark_position) {
1175
+ $original_filename = htmlspecialchars_decode($original_filename, ENT_COMPAT | ENT_QUOTES);
1176
+ $dest_filename = htmlspecialchars_decode($dest_filename, ENT_COMPAT | ENT_QUOTES);
1177
+ $watermark_url = htmlspecialchars_decode($watermark_url, ENT_COMPAT | ENT_QUOTES);
1178
+
1179
+ list($width, $height, $type) = getimagesize($original_filename);
1180
+ list($width_watermark, $height_watermark, $type_watermark) = getimagesize($watermark_url);
1181
+
1182
+ $watermark_width = $width * $watermark_width / 100;
1183
+ $watermark_height = $height_watermark * $watermark_width / $width_watermark;
1184
+
1185
+ $watermark_position = explode('-', $watermark_position);
1186
+ $top = $height - $watermark_height - 5;
1187
+ $left = $width - $watermark_width - 5;
1188
+ switch ($watermark_position[0]) {
1189
+ case 'top':
1190
+ $top = 5;
1191
+ break;
1192
+ case 'middle':
1193
+ $top = ($height - $watermark_height) / 2;
1194
+ break;
1195
+ }
1196
+ switch ($watermark_position[1]) {
1197
+ case 'left':
1198
+ $left = 5;
1199
+ break;
1200
+ case 'center':
1201
+ $left = ($width - $watermark_width) / 2;
1202
+ break;
1203
+ }
1204
+ @ini_set('memory_limit', '-1');
1205
+ if ($type_watermark == 2) {
1206
+ $watermark_image = imagecreatefromjpeg($watermark_url);
1207
+ }
1208
+ elseif ($type_watermark == 3) {
1209
+ $watermark_image = imagecreatefrompng($watermark_url);
1210
+ }
1211
+ elseif ($type_watermark == 1) {
1212
+ $watermark_image = imagecreatefromgif($watermark_url);
1213
+ }
1214
+ else {
1215
+ return false;
1216
+ }
1217
+
1218
+ $watermark_image_resized = imagecreatetruecolor($watermark_width, $watermark_height);
1219
+ imagecolorallocatealpha($watermark_image_resized, 255, 255, 255, 127);
1220
+ imagealphablending($watermark_image_resized, FALSE);
1221
+ imagesavealpha($watermark_image_resized, TRUE);
1222
+ imagecopyresampled ($watermark_image_resized, $watermark_image, 0, 0, 0, 0, $watermark_width, $watermark_height, $width_watermark, $height_watermark);
1223
+
1224
+ if ($type == 2) {
1225
+ $image = imagecreatefromjpeg($original_filename);
1226
+ imagecopy($image, $watermark_image_resized, $left, $top, 0, 0, $watermark_width, $watermark_height);
1227
+ if ($dest_filename <> '') {
1228
+ imagejpeg ($image, $dest_filename, 100);
1229
+ } else {
1230
+ header('Content-Type: image/jpeg');
1231
+ imagejpeg($image, null, 100);
1232
+ };
1233
+ imagedestroy($image);
1234
+ }
1235
+ elseif ($type == 3) {
1236
+ $image = imagecreatefrompng($original_filename);
1237
+ imagecopy($image, $watermark_image_resized, $left, $top, 0, 0, $watermark_width, $watermark_height);
1238
+ imagealphablending($image, FALSE);
1239
+ imagesavealpha($image, TRUE);
1240
+ imagepng($image, $dest_filename, 9);
1241
+ imagedestroy($image);
1242
+ }
1243
+ elseif ($type == 1) {
1244
+ $image = imagecreatefromgif($original_filename);
1245
+ $tempimage = imagecreatetruecolor($width, $height);
1246
+ imagecopy($tempimage, $image, 0, 0, 0, 0, $width, $height);
1247
+ imagecopy($tempimage, $watermark_image_resized, $left, $top, 0, 0, $watermark_width, $watermark_height);
1248
+ imagegif($tempimage, $dest_filename);
1249
+ imagedestroy($image);
1250
+ imagedestroy($tempimage);
1251
+ }
1252
+ imagedestroy($watermark_image);
1253
+ @ini_restore('memory_limit');
1254
+ }
1255
+
1256
+ public static function bwg_image_recover_all($gallery_id) {
1257
+ global $wpdb;
1258
+ global $wd_bwg_options;
1259
+ $thumb_width = $wd_bwg_options->upload_thumb_width;
1260
+ $width = $wd_bwg_options->upload_img_width;
1261
+ if($gallery_id == 0) {
1262
+ $image_ids_col = $wpdb->get_col('SELECT id FROM ' . $wpdb->prefix . 'bwg_image');
1263
+ }
1264
+ else{
1265
+ $image_ids_col = $wpdb->get_col($wpdb->prepare('SELECT id FROM ' . $wpdb->prefix . 'bwg_image WHERE gallery_id="%d"', $gallery_id));
1266
+ }
1267
+ foreach ($image_ids_col as $image_id) {
1268
+ if (isset($_POST['check_' . $image_id]) || isset($_POST['check_all_items'])) {
1269
+ self::recover_image($image_id, $thumb_width, $width, 'gallery_page');
1270
+ }
1271
+ if($gallery_id == 0) {
1272
+ self::recover_image($image_id, $thumb_width, $width, 'option_page');
1273
+ }
1274
+ }
1275
+ }
1276
+
1277
+ public static function recover_image($id, $thumb_width, $width, $page) {
1278
+ global $WD_BWG_UPLOAD_DIR;
1279
+ global $wpdb;
1280
+ $image_data = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . 'bwg_image WHERE id="%d"', $id));
1281
+ $filename = htmlspecialchars_decode(ABSPATH . $WD_BWG_UPLOAD_DIR . $image_data->image_url, ENT_COMPAT | ENT_QUOTES);
1282
+ $thumb_filename = htmlspecialchars_decode(ABSPATH . $WD_BWG_UPLOAD_DIR . $image_data->thumb_url, ENT_COMPAT | ENT_QUOTES);
1283
+ $original_filename = str_replace('/thumb/', '/.original/', $thumb_filename);
1284
+ if (file_exists($filename) && file_exists($thumb_filename) && file_exists($original_filename)) {
1285
+ list($width_orig, $height_orig, $type_orig) = getimagesize($original_filename);
1286
+ self::recover_image_size($width_orig, $height_orig, $width, $original_filename, $filename, $type_orig);
1287
+ self::recover_image_size($width_orig, $height_orig, $thumb_width, $original_filename, $thumb_filename, $type_orig);
1288
+ }
1289
+ @ini_restore('memory_limit');
1290
+ if ($page == 'gallery_page') {
1291
+ ?>
1292
+ <script language="javascript">
1293
+ var image_src = window.parent.document.getElementById("image_thumb_<?php echo $id; ?>").src;
1294
+ document.getElementById("image_thumb_<?php echo $id; ?>").src = image_src + "?date=<?php echo date('Y-m-y H:i:s'); ?>";
1295
+ </script>
1296
+ <?php
1297
+ }
1298
+ }
1299
+
1300
+ public static function recover_image_size($width_orig, $height_orig, $width, $original_filename, $filename, $type_orig) {
1301
+ $percent = $width_orig / $width;
1302
+ $height = $height_orig / $percent;
1303
+ @ini_set('memory_limit', '-1');
1304
+ if ($type_orig == 2) {
1305
+ $img_r = imagecreatefromjpeg($original_filename);
1306
+ $dst_r = ImageCreateTrueColor($width, $height);
1307
+ imagecopyresampled($dst_r, $img_r, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
1308
+ imagejpeg($dst_r, $filename, 100);
1309
+ imagedestroy($img_r);
1310
+ imagedestroy($dst_r);
1311
+ }
1312
+ elseif ($type_orig == 3) {
1313
+ $img_r = imagecreatefrompng($original_filename);
1314
+ $dst_r = ImageCreateTrueColor($width, $height);
1315
+ imageColorAllocateAlpha($dst_r, 0, 0, 0, 127);
1316
+ imagealphablending($dst_r, FALSE);
1317
+ imagesavealpha($dst_r, TRUE);
1318
+ imagecopyresampled($dst_r, $img_r, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
1319
+ imagealphablending($dst_r, FALSE);
1320
+ imagesavealpha($dst_r, TRUE);
1321
+ imagepng($dst_r, $filename, 9);
1322
+ imagedestroy($img_r);
1323
+ imagedestroy($dst_r);
1324
+ }
1325
+ elseif ($type_orig == 1) {
1326
+ $img_r = imagecreatefromgif($original_filename);
1327
+ $dst_r = ImageCreateTrueColor($width, $height);
1328
+ imageColorAllocateAlpha($dst_r, 0, 0, 0, 127);
1329
+ imagealphablending($dst_r, FALSE);
1330
+ imagesavealpha($dst_r, TRUE);
1331
+ imagecopyresampled($dst_r, $img_r, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
1332
+ imagealphablending($dst_r, FALSE);
1333
+ imagesavealpha($dst_r, TRUE);
1334
+ imagegif($dst_r, $filename);
1335
+ imagedestroy($img_r);
1336
+ imagedestroy($dst_r);
1337
+ }
1338
+ }
1339
+
1340
+ public static function bwg_hex2rgb($hex) {
1341
+ $hex = str_replace("#", "", $hex);
1342
+ if (strlen($hex) == 3) {
1343
+ $r = hexdec(substr($hex,0,1).substr($hex,0,1));
1344
+ $g = hexdec(substr($hex,1,1).substr($hex,1,1));
1345
+ $b = hexdec(substr($hex,2,1).substr($hex,2,1));
1346
+ }
1347
+ else {
1348
+ $r = hexdec(substr($hex,0,2));
1349
+ $g = hexdec(substr($hex,2,2));
1350
+ $b = hexdec(substr($hex,4,2));
1351
+ }
1352
+ $rgb = array($r, $g, $b);
1353
+ return $rgb;
1354
+ }
1355
+
1356
+ public static function bwg_imagettfbboxdimensions($font_size, $font_angle, $font, $text) {
1357
+ $box = @ImageTTFBBox($font_size, $font_angle, $font, $text) or die;
1358
+ $max_x = max(array($box[0], $box[2], $box[4], $box[6]));
1359
+ $max_y = max(array($box[1], $box[3], $box[5], $box[7]));
1360
+ $min_x = min(array($box[0], $box[2], $box[4], $box[6]));
1361
+ $min_y = min(array($box[1], $box[3], $box[5], $box[7]));
1362
+ return array(
1363
+ "width" => ($max_x - $min_x),
1364
+ "height" => ($max_y - $min_y)
1365
+ );
1366
+ }
1367
+
1368
+ ////////////////////////////////////////////////////////////////////////////////////////
1369
+ // Private Methods //
1370
+ ////////////////////////////////////////////////////////////////////////////////////////
1371
+ ////////////////////////////////////////////////////////////////////////////////////////
1372
+ // Listeners //
1373
+ ////////////////////////////////////////////////////////////////////////////////////////
1374
  }
photo-gallery.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Photo Gallery
5
  * Plugin URI: https://web-dorado.com/products/wordpress-photo-gallery-plugin.html
6
  * Description: This plugin is a fully responsive gallery plugin with advanced functionality. It allows having different image galleries for your posts and pages. You can create unlimited number of galleries, combine them into albums, and provide descriptions and tags.
7
- * Version: 1.3.29
8
  * Author: WebDorado
9
  * Author URI: https://web-dorado.com/
10
  * License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
@@ -194,18 +194,28 @@ function bwg_filemanager_ajax() {
194
  }
195
  global $wpdb;
196
  require_once(WD_BWG_DIR . '/framework/WDWLibrary.php');
197
- $page = WDWLibrary::get('action');
 
198
  if (($page != '') && (($page == 'addImages') || ($page == 'addMusic'))) {
199
-
200
- if(!WDWLibrary::verify_nonce($page)){
201
  die('Sorry, your nonce did not verify.');
202
  }
203
  require_once(WD_BWG_DIR . '/filemanager/controller.php');
204
  $controller_class = 'FilemanagerController';
205
  $controller = new $controller_class();
206
- $controller->execute();
 
 
 
 
 
 
 
 
 
207
  }
208
  }
 
209
  function bwg_add_embed_ajax() {
210
  if (function_exists('current_user_can')) {
211
  if (!current_user_can('manage_options')) {
@@ -219,7 +229,7 @@ function bwg_add_embed_ajax() {
219
  if (!WDWLibrary::verify_nonce('')) {
220
  die(WDWLibrary::delimit_wd_output(json_encode(array("error", "Sorry, your nonce did not verify."))));
221
  }
222
-
223
  require_once(WD_BWG_DIR . '/framework/WDWLibraryEmbed.php');
224
  $embed_action = WDWLibrary::get('action');
225
 
@@ -1609,7 +1619,7 @@ function bwg_activate() {
1609
  ));
1610
  }
1611
  $version = get_option('wd_bwg_version');
1612
- $new_version = '1.3.29';
1613
  if ($version && version_compare($version, $new_version, '<')) {
1614
  require_once WD_BWG_DIR . "/update/bwg_update.php";
1615
  bwg_update($version);
@@ -1661,7 +1671,7 @@ wp_oembed_add_provider( '#https://instagr(\.am|am\.com)/p/.*#i', 'https://api.in
1661
 
1662
  function bwg_update_hook() {
1663
  $version = get_option('wd_bwg_version');
1664
- $new_version = '1.3.29';
1665
  if ($version && version_compare($version, $new_version, '<')) {
1666
  require_once WD_BWG_DIR . "/update/bwg_update.php";
1667
  bwg_update($version);
@@ -1886,7 +1896,6 @@ function bwg_options_scripts() {
1886
 
1887
  function bwg_front_end_scripts() {
1888
  $version = wd_bwg_version();
1889
- /*wp_enqueue_style('jquery-ui', WD_BWG_FRONT_URL . '/css/jquery-ui-1.10.3.custom.css', array(), $version);*/
1890
 
1891
  wp_register_script('bwg_frontend', WD_BWG_FRONT_URL . '/js/bwg_frontend.js', array('jquery'), $version);
1892
  wp_register_style('bwg_frontend', WD_BWG_FRONT_URL . '/css/bwg_frontend.css', array(), $version);
4
  * Plugin Name: Photo Gallery
5
  * Plugin URI: https://web-dorado.com/products/wordpress-photo-gallery-plugin.html
6
  * Description: This plugin is a fully responsive gallery plugin with advanced functionality. It allows having different image galleries for your posts and pages. You can create unlimited number of galleries, combine them into albums, and provide descriptions and tags.
7
+ * Version: 1.3.30
8
  * Author: WebDorado
9
  * Author URI: https://web-dorado.com/
10
  * License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
194
  }
195
  global $wpdb;
196
  require_once(WD_BWG_DIR . '/framework/WDWLibrary.php');
197
+ $page = WDWLibrary::get('action');
198
+
199
  if (($page != '') && (($page == 'addImages') || ($page == 'addMusic'))) {
200
+ if (!WDWLibrary::verify_nonce($page)) {
 
201
  die('Sorry, your nonce did not verify.');
202
  }
203
  require_once(WD_BWG_DIR . '/filemanager/controller.php');
204
  $controller_class = 'FilemanagerController';
205
  $controller = new $controller_class();
206
+ $addImages_ajax = WDWLibrary::get('addImages_ajax');
207
+ if ($addImages_ajax == 'addImages_ajax') {
208
+ $load_count = WDWLibrary::get('load_count');
209
+ $images_list = $controller->get_images(intval($load_count));
210
+ echo (json_encode($images_list, true));
211
+ die;
212
+ }
213
+ else {
214
+ $controller->execute(true, 1);
215
+ }
216
  }
217
  }
218
+
219
  function bwg_add_embed_ajax() {
220
  if (function_exists('current_user_can')) {
221
  if (!current_user_can('manage_options')) {
229
  if (!WDWLibrary::verify_nonce('')) {
230
  die(WDWLibrary::delimit_wd_output(json_encode(array("error", "Sorry, your nonce did not verify."))));
231
  }
232
+
233
  require_once(WD_BWG_DIR . '/framework/WDWLibraryEmbed.php');
234
  $embed_action = WDWLibrary::get('action');
235
 
1619
  ));
1620
  }
1621
  $version = get_option('wd_bwg_version');
1622
+ $new_version = '1.3.30';
1623
  if ($version && version_compare($version, $new_version, '<')) {
1624
  require_once WD_BWG_DIR . "/update/bwg_update.php";
1625
  bwg_update($version);
1671
 
1672
  function bwg_update_hook() {
1673
  $version = get_option('wd_bwg_version');
1674
+ $new_version = '1.3.30';
1675
  if ($version && version_compare($version, $new_version, '<')) {
1676
  require_once WD_BWG_DIR . "/update/bwg_update.php";
1677
  bwg_update($version);
1896
 
1897
  function bwg_front_end_scripts() {
1898
  $version = wd_bwg_version();
 
1899
 
1900
  wp_register_script('bwg_frontend', WD_BWG_FRONT_URL . '/js/bwg_frontend.js', array('jquery'), $version);
1901
  wp_register_style('bwg_frontend', WD_BWG_FRONT_URL . '/css/bwg_frontend.css', array(), $version);
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://web-dorado.com/products/wordpress-photo-gallery-plugin.html
4
  Tags: content gallery, gallery, gallery image, image gallery, images gallery, lightbox gallery, media gallery, photo gallery, responsive gallery, thumbnail gallery, wordpress gallery, youtube gallery
5
  Requires at least: 3.4
6
  Tested up to: 4.7
7
- Stable tag: 1.3.29
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -175,6 +175,10 @@ To enable the feature of adding Media Library images, go to Photo Gallery > Opti
175
 
176
  == Changelog ==
177
 
 
 
 
 
178
  = 1.3.29 =
179
  * Changed: Possibility to include scripts only in necessary pages.
180
 
4
  Tags: content gallery, gallery, gallery image, image gallery, images gallery, lightbox gallery, media gallery, photo gallery, responsive gallery, thumbnail gallery, wordpress gallery, youtube gallery
5
  Requires at least: 3.4
6
  Tested up to: 4.7
7
+ Stable tag: 1.3.30
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
175
 
176
  == Changelog ==
177
 
178
+ = 1.3.30 =
179
+ * Changed: Scroll load in filemanager.
180
+ * Fixed: Image dimensions on images reset.
181
+
182
  = 1.3.29 =
183
  * Changed: Possibility to include scripts only in necessary pages.
184