Photo Gallery by WD – Responsive Photo Gallery - Version 1.3.41

Version Description

  • Added: Possibility to add images from Wordpress Media Library.
  • Fixed: Image info in lightbox with small effect duration.
  • Changed: Effect duration now can be float.
Download this release

Release Info

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

Code changes from version 1.3.40 to 1.3.41

admin/views/BWGViewGalleries_bwg.php CHANGED
@@ -27,7 +27,6 @@ class BWGViewGalleries_bwg {
27
  $rows_data = $this->model->get_rows_data();
28
  $page_nav = $this->model->page_nav();
29
  $search_value = ((isset($_POST['search_value'])) ? esc_html(stripslashes($_POST['search_value'])) : '');
30
- $search_select_value = ((isset($_POST['search_select_value'])) ? (int) $_POST['search_select_value'] : 0);
31
  $asc_or_desc = ((isset($_POST['asc_or_desc'])) ? esc_html(stripslashes($_POST['asc_or_desc'])) : 'asc');
32
  $order_by = (isset($_POST['order_by']) ? esc_html(stripslashes($_POST['order_by'])) : 'order');
33
  $order_class = 'manage-column column-title sorted ' . $asc_or_desc;
@@ -62,9 +61,7 @@ class BWGViewGalleries_bwg {
62
  <?php
63
  foreach($gallery_button_array as $key => $value) {
64
  ?>
65
- <option value="<?php echo $key; ?>">
66
- <?php echo $value; ?>
67
- </option>
68
  <?php
69
  }
70
  ?>
@@ -417,7 +414,7 @@ class BWGViewGalleries_bwg {
417
  input_alt.innerHTML = files[i]['name'];
418
  }
419
  else {/*uploaded images and direct URLs of images only*/
420
- input_alt.innerHTML = files[i]['filename'];
421
  }
422
  td_alt.appendChild(input_alt);
423
 
@@ -439,11 +436,10 @@ class BWGViewGalleries_bwg {
439
  textarea_desc.setAttribute('name', "image_description_" + bwg_j);
440
  textarea_desc.setAttribute('rows', "2");
441
  textarea_desc.setAttribute('style', "resize:vertical;");
442
- if (is_embed && !is_direct_url) {
443
- textarea_desc.innerHTML = files[i]['description'];
444
- }
445
- else if (<?php echo $wd_bwg_options->read_metadata; ?>) {
446
- textarea_desc.innerHTML = files[i]['credit'] ? 'Author: ' + files[i]['credit'] + '\n' : '';
447
  textarea_desc.innerHTML += ((files[i]['aperture'] != 0 && files[i]['aperture'] != '') ? 'Aperture: ' + files[i]['aperture'] + '\n' : '');
448
  textarea_desc.innerHTML += ((files[i]['camera'] != 0 && files[i]['camera'] != '') ? 'Camera: ' + files[i]['camera'] + '\n' : '');
449
  textarea_desc.innerHTML += ((files[i]['caption'] != 0 && files[i]['caption'] != '') ? 'Caption: ' + files[i]['caption'] + '\n' : '');
@@ -670,6 +666,7 @@ class BWGViewGalleries_bwg {
670
  }
671
 
672
  public function image_display($id) {
 
673
  global $WD_BWG_UPLOAD_DIR;
674
  global $wd_bwg_options;
675
  $rows_data = $this->model->get_image_rows_data($id);
@@ -706,12 +703,13 @@ class BWGViewGalleries_bwg {
706
  <a href="<?php echo $query_url; ?>" id="add_image_bwg" class="wd-btn wd-btn-primary wd-btn-icon wd-btn-add thickbox thickbox-preview" id="content-add_media" title="<?php _e("Add Images", 'bwg_back'); ?>" onclick="return false;" style="margin-bottom:5px; <?php if($gallery_type !='') {echo 'display:none';} ?>" >
707
  <?php _e('Add Images', 'bwg_back'); ?>
708
  </a>
 
709
  <?php
710
  $query_url = wp_nonce_url(admin_url('admin-ajax.php'), '', 'bwg_nonce');
711
  /*(re?)define ajax_url to add nonce only in admin*/
712
  ?>
713
  <script>
714
- var ajax_url = "<?php echo $query_url; ?>"
715
  </script>
716
  <input id="show_add_embed" class="wd-btn wd-btn-primary wd-btn-icon wd-btn-media" type="button" title="<?php _e("Embed Media", 'bwg_back'); ?>" onclick="jQuery('.opacity_add_embed').show(); jQuery('#add_embed_help').hide(); return false;" value="<?php _e("Embed Media", 'bwg_back'); ?>" />
717
  <input id="show_bulk_embed" class="wd-btn wd-btn-primary wd-btn-icon wd-btn-bulk_media spider_free_version_button" type="button" title="<?php _e("Social Bulk Embed", 'bwg_back'); ?>" onclick="jQuery('.opacity_bulk_embed').show(); return false;" value="<?php _e("Social Bulk Embed", 'bwg_back'); ?>" />
@@ -834,9 +832,7 @@ class BWGViewGalleries_bwg {
834
  <span class="sorting-indicator"></span>
835
  </a>
836
  </th>
837
- <th class="manage-column column-cb check-column table_small_col" style="padding-top:12px !important;"><input id="check_all" type="checkbox" onclick="spider_check_all(this)" style="margin:5px auto 0;" />
838
-
839
- </th>
840
  <th class="table_small_col">#</th>
841
  <th class="table_extra_large_col"><?php _e('Thumbnail', 'bwg_back'); ?></th>
842
  <th class="sortable table_extra_large_col <?php if ($image_order_by == 'filename') {echo $order_class;} ?>">
27
  $rows_data = $this->model->get_rows_data();
28
  $page_nav = $this->model->page_nav();
29
  $search_value = ((isset($_POST['search_value'])) ? esc_html(stripslashes($_POST['search_value'])) : '');
 
30
  $asc_or_desc = ((isset($_POST['asc_or_desc'])) ? esc_html(stripslashes($_POST['asc_or_desc'])) : 'asc');
31
  $order_by = (isset($_POST['order_by']) ? esc_html(stripslashes($_POST['order_by'])) : 'order');
32
  $order_class = 'manage-column column-title sorted ' . $asc_or_desc;
61
  <?php
62
  foreach($gallery_button_array as $key => $value) {
63
  ?>
64
+ <option value="<?php echo $key; ?>"><?php echo $value; ?></option>
 
 
65
  <?php
66
  }
67
  ?>
414
  input_alt.innerHTML = files[i]['name'];
415
  }
416
  else {/*uploaded images and direct URLs of images only*/
417
+ input_alt.innerHTML = files[i]['alt'];
418
  }
419
  td_alt.appendChild(input_alt);
420
 
436
  textarea_desc.setAttribute('name', "image_description_" + bwg_j);
437
  textarea_desc.setAttribute('rows', "2");
438
  textarea_desc.setAttribute('style', "resize:vertical;");
439
+ textarea_desc.innerHTML = files[i]['description'] ? files[i]['description'] : '';
440
+ if (<?php echo $wd_bwg_options->read_metadata; ?>) {
441
+ textarea_desc.innerHTML += files[i]['description'] ? '\n' : '';
442
+ textarea_desc.innerHTML += files[i]['credit'] ? 'Author: ' + files[i]['credit'] + '\n' : '';
 
443
  textarea_desc.innerHTML += ((files[i]['aperture'] != 0 && files[i]['aperture'] != '') ? 'Aperture: ' + files[i]['aperture'] + '\n' : '');
444
  textarea_desc.innerHTML += ((files[i]['camera'] != 0 && files[i]['camera'] != '') ? 'Camera: ' + files[i]['camera'] + '\n' : '');
445
  textarea_desc.innerHTML += ((files[i]['caption'] != 0 && files[i]['caption'] != '') ? 'Caption: ' + files[i]['caption'] + '\n' : '');
666
  }
667
 
668
  public function image_display($id) {
669
+ wp_enqueue_media();
670
  global $WD_BWG_UPLOAD_DIR;
671
  global $wd_bwg_options;
672
  $rows_data = $this->model->get_image_rows_data($id);
703
  <a href="<?php echo $query_url; ?>" id="add_image_bwg" class="wd-btn wd-btn-primary wd-btn-icon wd-btn-add thickbox thickbox-preview" id="content-add_media" title="<?php _e("Add Images", 'bwg_back'); ?>" onclick="return false;" style="margin-bottom:5px; <?php if($gallery_type !='') {echo 'display:none';} ?>" >
704
  <?php _e('Add Images', 'bwg_back'); ?>
705
  </a>
706
+ <input type="button" class="wd-btn wd-btn-primary wd-btn-icon wd-btn-add" onclick="spider_media_uploader(event, true); return false;" value="<?php _e("Import from Media Library", 'bwg_back'); ?>" />
707
  <?php
708
  $query_url = wp_nonce_url(admin_url('admin-ajax.php'), '', 'bwg_nonce');
709
  /*(re?)define ajax_url to add nonce only in admin*/
710
  ?>
711
  <script>
712
+ var ajax_url = "<?php echo $query_url; ?>";
713
  </script>
714
  <input id="show_add_embed" class="wd-btn wd-btn-primary wd-btn-icon wd-btn-media" type="button" title="<?php _e("Embed Media", 'bwg_back'); ?>" onclick="jQuery('.opacity_add_embed').show(); jQuery('#add_embed_help').hide(); return false;" value="<?php _e("Embed Media", 'bwg_back'); ?>" />
715
  <input id="show_bulk_embed" class="wd-btn wd-btn-primary wd-btn-icon wd-btn-bulk_media spider_free_version_button" type="button" title="<?php _e("Social Bulk Embed", 'bwg_back'); ?>" onclick="jQuery('.opacity_bulk_embed').show(); return false;" value="<?php _e("Social Bulk Embed", 'bwg_back'); ?>" />
832
  <span class="sorting-indicator"></span>
833
  </a>
834
  </th>
835
+ <th class="manage-column column-cb check-column table_small_col" style="padding-top:12px !important;"><input id="check_all" type="checkbox" onclick="spider_check_all(this)" style="margin:5px auto 0;" /></th>
 
 
836
  <th class="table_small_col">#</th>
837
  <th class="table_extra_large_col"><?php _e('Thumbnail', 'bwg_back'); ?></th>
838
  <th class="sortable table_extra_large_col <?php if ($image_order_by == 'filename') {echo $order_class;} ?>">
admin/views/BWGViewOptions_bwg.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
 
3
  class BWGViewOptions_bwg {
4
-
5
  private $model;
6
 
7
  public function __construct($model) {
@@ -1342,16 +1341,6 @@ class BWGViewOptions_bwg {
1342
  <div class="spider_description"><?php _e('Count of images to preload (0 for all).', 'bwg_back'); ?></div>
1343
  </td>
1344
  </tr>
1345
- <tr>
1346
- <td class="spider_label_options">
1347
- <label><?php _e('Import from Media Library:', 'bwg_back'); ?></label>
1348
- </td>
1349
- <td>
1350
- <input type="radio" name="enable_ML_import" id="enable_ML_import_1" value="1" <?php if ($row->enable_ML_import) echo 'checked="checked"'; ?> /><label for="enable_ML_import_1"><?php _e('Yes', 'bwg_back'); ?></label>
1351
- <input type="radio" name="enable_ML_import" id="enable_ML_import_0" value="0" <?php if (!$row->enable_ML_import) echo 'checked="checked"'; ?> /><label for="enable_ML_import_0"><?php _e('No', 'bwg_back'); ?></label>
1352
- <div class="spider_description"><?php _e('Enable import from Media Library in file manager.', 'bwg_back'); ?></div>
1353
- </td>
1354
- </tr>
1355
  <tr>
1356
  <td class="spider_label_options">
1357
  <label><?php _e('Enable html editor:', 'bwg_back'); ?></label>
1
  <?php
2
 
3
  class BWGViewOptions_bwg {
 
4
  private $model;
5
 
6
  public function __construct($model) {
1341
  <div class="spider_description"><?php _e('Count of images to preload (0 for all).', 'bwg_back'); ?></div>
1342
  </td>
1343
  </tr>
 
 
 
 
 
 
 
 
 
 
1344
  <tr>
1345
  <td class="spider_label_options">
1346
  <label><?php _e('Enable html editor:', 'bwg_back'); ?></label>
css/bwg_tables.css CHANGED
@@ -603,7 +603,7 @@
603
  }
604
 
605
  #ed_options {
606
- width:180px;
607
  padding: 45px 10px 20px 0;
608
  }
609
  .wp-pointer.wp-pointer-aligned-right .wp-pointer-arrow {
@@ -716,7 +716,7 @@ a.wd-btn-primary:hover, a.wd-btn-primary:active, a.wd-btn-primary:link{
716
  padding: 0px 10px 1px 36px !important;
717
  color:#fff;
718
  background-repeat: no-repeat;
719
- background-position: 10% 50%;
720
  }
721
 
722
  .wd-btn-delete{
@@ -1029,7 +1029,7 @@ textarea.bwg_popup_input {
1029
  margin-top: 3px;
1030
  }
1031
  #display_default_option_panel, #display_panel {
1032
- float: left
1033
  display: block !important;
1034
  }
1035
  #preview_built_in_watermark, #preview_watermark {
603
  }
604
 
605
  #ed_options {
606
+ width: 180px;
607
  padding: 45px 10px 20px 0;
608
  }
609
  .wp-pointer.wp-pointer-aligned-right .wp-pointer-arrow {
716
  padding: 0px 10px 1px 36px !important;
717
  color:#fff;
718
  background-repeat: no-repeat;
719
+ background-position: 10px 50%;
720
  }
721
 
722
  .wd-btn-delete{
1029
  margin-top: 3px;
1030
  }
1031
  #display_default_option_panel, #display_panel {
1032
+ float: left;
1033
  display: block !important;
1034
  }
1035
  #preview_built_in_watermark, #preview_watermark {
filemanager/UploadHandler.php CHANGED
@@ -24,7 +24,8 @@ require_once(WD_BWG_DIR . '/filemanager/controller.php');
24
  $controller = new FilemanagerController();
25
 
26
  $upload_handler = new bwg_UploadHandler(array(
27
- 'upload_dir' => $controller->uploads_dir . (isset($_GET['dir']) ? str_replace('\\', '', ($_GET['dir'])) : ''),
 
28
  'accept_file_types' => '/\.(gif|jpe?g|png|aac|m4a|f4a|oga|ogg|mp3|zip)$/i'
29
  ));
30
 
@@ -53,9 +54,10 @@ class bwg_UploadHandler {
53
 
54
  function __construct($options = null, $initialize = true, $error_messages = null) {
55
  $this->options = array(
56
- 'script_url' => $this->get_full_url().'/',
57
- 'upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']).'/files/',
58
- 'upload_url' => $this->get_full_url().'/files/',
 
59
  'user_dirs' => false,
60
  'mkdir_mode' => 0755,
61
  'param_name' => 'files',
@@ -185,8 +187,9 @@ class bwg_UploadHandler {
185
  protected function get_upload_path($file_name = null, $version = null) {
186
  $file_name = $file_name ? $file_name : '';
187
  $version_path = empty($version) ? '' : $version.'/';
188
- return $this->options['upload_dir'].$this->get_user_path()
189
- .$version_path.$file_name;
 
190
  }
191
 
192
  protected function get_query_separator($url) {
@@ -204,7 +207,7 @@ class bwg_UploadHandler {
204
  return $url.'&download=1';
205
  }
206
  $version_path = empty($version) ? '' : rawurlencode($version).'/';
207
- return $this->options['upload_url'].$this->get_user_path()
208
  .$version_path.rawurlencode($file_name);
209
  }
210
 
@@ -485,8 +488,7 @@ class bwg_UploadHandler {
485
  // Keep an existing filename if this is part of a chunked upload:
486
  $uploaded_bytes = $this->fix_integer_overflow(intval(isset($content_range[1]) ? $content_range[1] : 0));
487
  while(is_file($this->get_upload_path($name))) {
488
- if ($uploaded_bytes === $this->get_file_size(
489
- $this->get_upload_path($name))) {
490
  break;
491
  }
492
  $name = $this->upcount_name($name);
@@ -561,7 +563,7 @@ class bwg_UploadHandler {
561
 
562
  protected function handle_image_file($file_path, $file) {
563
  if ($this->options['orient_image']) {
564
- $this->orient_image($file_path);
565
  }
566
  $failed_versions = array();
567
  foreach($this->options['image_versions'] as $version => $options) {
@@ -665,35 +667,61 @@ class bwg_UploadHandler {
665
  }
666
  }
667
 
668
- protected function handle_file_import($uploaded_file, $name, $index = null, $content_range = null) {
669
  $parent_dir = wp_upload_dir();
670
- $parent_dir = $parent_dir['basedir'];
 
671
  $file_type_array = explode('.', $name);
672
  $type = strtolower(end($file_type_array));
673
-
674
  $file = new stdClass();
675
- $file->name = $this->get_file_name($name, $type, $index, $content_range);
676
  $file->type = $type;
677
- $this->handle_form_data($file, $index);
678
  $upload_dir = $this->get_upload_path();
679
- if (!is_dir($upload_dir)) {
680
  mkdir($upload_dir, $this->options['mkdir_mode'], true);
681
  }
682
  $file_path = $this->get_upload_path($file->name);
683
-
684
- copy($parent_dir . '/' . $uploaded_file, $file_path);
685
- list($img_width, $img_height) = @getimagesize(htmlspecialchars_decode($file_path, ENT_COMPAT | ENT_QUOTES));
686
-
687
- if ($this->options['max_width'] && $this->options['max_height']) {
688
- // Media libruary Upload.
689
  $this->create_scaled_image($file->name, 'main', $this->options);
690
  }
691
-
692
- if (is_int($img_width)) {
693
  $this->handle_image_file($file_path, $file);
694
- }
695
  $this->set_file_delete_properties($file);
696
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
697
  return $file;
698
  }
699
 
@@ -875,22 +903,19 @@ class bwg_UploadHandler {
875
  }
876
 
877
  public function get($print_response = true) {
878
- if (isset($_GET['import']) && $_GET['import'] == 'true') {
879
  $file_names = explode('**@**', (isset($_REQUEST['file_namesML']) ? stripslashes($_REQUEST['file_namesML']) : ''));
 
 
880
  foreach ($file_names as $index => $value) {
881
  $file_name_array = explode('/', $value);
882
- $files[] = $this->handle_file_import(
883
- $value,
884
- end($file_name_array),
885
- 0,
886
- ""
887
- );
888
  }
889
- $query_url = wp_nonce_url( admin_url('admin-ajax.php'), 'addImages', 'bwg_nonce' );
890
- $query_url = add_query_arg(array('action' => 'addImages', 'width' => '650', 'height' => '500', 'task' => 'show_file_manager', 'extensions' => 'jpg,jpeg,png,gif', 'callback' => $_REQUEST['callback'], 'dir' => $_REQUEST['redir'], 'TB_iframe' => '1'), $query_url);
891
- header('Location: ' . $query_url);
892
- exit;
893
  }
 
894
  if ($print_response && isset($_GET['download'])) {
895
  return $this->download();
896
  }
24
  $controller = new FilemanagerController();
25
 
26
  $upload_handler = new bwg_UploadHandler(array(
27
+ 'upload_dir' => $controller->uploads_dir . (isset($_GET['dir']) ? str_replace('\\', '', ($_GET['dir'])) : '/'),
28
+ 'upload_url' => $controller->uploads_url,
29
  'accept_file_types' => '/\.(gif|jpe?g|png|aac|m4a|f4a|oga|ogg|mp3|zip)$/i'
30
  ));
31
 
54
 
55
  function __construct($options = null, $initialize = true, $error_messages = null) {
56
  $this->options = array(
57
+ 'media_library_folder' => 'imported_from_media_libray' . '/',
58
+ 'script_url' => $this->get_full_url() . '/',
59
+ 'upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']) . '/files/',
60
+ 'upload_url' => $this->get_full_url() . '/files/',
61
  'user_dirs' => false,
62
  'mkdir_mode' => 0755,
63
  'param_name' => 'files',
187
  protected function get_upload_path($file_name = null, $version = null) {
188
  $file_name = $file_name ? $file_name : '';
189
  $version_path = empty($version) ? '' : $version.'/';
190
+ $media_library_folder = (isset($_GET['import']) && $_GET['import'] == 1) ? $this->options['media_library_folder'] : '';
191
+
192
+ return $this->options['upload_dir'] . $media_library_folder . $this->get_user_path() . $version_path . $file_name;
193
  }
194
 
195
  protected function get_query_separator($url) {
207
  return $url.'&download=1';
208
  }
209
  $version_path = empty($version) ? '' : rawurlencode($version).'/';
210
+ return $this->options['upload_url'].$this->get_user_path().'/'
211
  .$version_path.rawurlencode($file_name);
212
  }
213
 
488
  // Keep an existing filename if this is part of a chunked upload:
489
  $uploaded_bytes = $this->fix_integer_overflow(intval(isset($content_range[1]) ? $content_range[1] : 0));
490
  while(is_file($this->get_upload_path($name))) {
491
+ if ($uploaded_bytes === $this->get_file_size($this->get_upload_path($name))) {
 
492
  break;
493
  }
494
  $name = $this->upcount_name($name);
563
 
564
  protected function handle_image_file($file_path, $file) {
565
  if ($this->options['orient_image']) {
566
+ $this->orient_image($file_path);
567
  }
568
  $failed_versions = array();
569
  foreach($this->options['image_versions'] as $version => $options) {
667
  }
668
  }
669
 
670
+ protected function handle_file_import($uploaded_file, $name) {
671
  $parent_dir = wp_upload_dir();
672
+ $basedir = $parent_dir['basedir'];
673
+
674
  $file_type_array = explode('.', $name);
675
  $type = strtolower(end($file_type_array));
676
+
677
  $file = new stdClass();
678
+ $file->name = $this->get_file_name($name, $type, 0, "");
679
  $file->type = $type;
680
+ $this->handle_form_data($file, 0);
681
  $upload_dir = $this->get_upload_path();
682
+ if ( !is_dir($upload_dir) ) {
683
  mkdir($upload_dir, $this->options['mkdir_mode'], true);
684
  }
685
  $file_path = $this->get_upload_path($file->name);
686
+ copy($basedir . '/' . $uploaded_file, $file_path);
687
+ if ( $this->options['max_width'] && $this->options['max_height'] ) {
688
+ // Media library Upload.
 
 
 
689
  $this->create_scaled_image($file->name, 'main', $this->options);
690
  }
691
+ list($img_width) = @getimagesize(htmlspecialchars_decode($file_path, ENT_COMPAT | ENT_QUOTES));
692
+ if ( is_int($img_width) ) {
693
  $this->handle_image_file($file_path, $file);
694
+ }
695
  $this->set_file_delete_properties($file);
696
+
697
+ // Additional information.
698
+
699
+ $file->filetype = $type;
700
+ $file->filename = str_replace('.' . $file->filetype, '', $file->name);
701
+ $file->alt = $file->filename;
702
+ $file->reliative_url = $this->options['upload_url'] . '/' . $this->options['media_library_folder'] . $file->name;
703
+ $file->url = '/' . $this->options['media_library_folder'] . '/' . $file->name;
704
+ $file->thumb = $this->options['upload_url'] . '/' . $this->options['media_library_folder'] . '/thumb/' . $file->name;
705
+ $file->thumb_url = '/' . $this->options['media_library_folder'] . '/thumb/' . $file->name;
706
+
707
+ $file_size_kb = (int)(filesize($file_path) / 1024);
708
+ $file->size = $file_size_kb . ' KB';
709
+ $file->date_modified = date('d F Y, H:i', filemtime($file_path));
710
+ $image_info = getimagesize(htmlspecialchars_decode($file_path, ENT_COMPAT | ENT_QUOTES));
711
+ $file->resolution = $image_info[0] . ' x ' . $image_info[1] . ' px';
712
+
713
+ global $wd_bwg_options;
714
+ if ( $wd_bwg_options->read_metadata ) {
715
+ $exif = WDWLibrary::read_image_metadata($upload_dir . '.original/' . $file->name);
716
+ $file->credit = $exif['credit'];
717
+ $file->aperture = $exif['aperture'];
718
+ $file->camera = $exif['camera'];
719
+ $file->caption = $exif['caption'];
720
+ $file->iso = $exif['iso'];
721
+ $file->orientation = $exif['orientation'];
722
+ $file->copyright = $exif['copyright'];
723
+ }
724
+
725
  return $file;
726
  }
727
 
903
  }
904
 
905
  public function get($print_response = true) {
906
+ if ( isset($_GET['import']) && $_GET['import'] == 1 ) {
907
  $file_names = explode('**@**', (isset($_REQUEST['file_namesML']) ? stripslashes($_REQUEST['file_namesML']) : ''));
908
+
909
+ $files = array();
910
  foreach ($file_names as $index => $value) {
911
  $file_name_array = explode('/', $value);
912
+ $files[] = $this->handle_file_import($value, end($file_name_array));
 
 
 
 
 
913
  }
914
+
915
+ echo json_encode($files);
916
+ return;
 
917
  }
918
+
919
  if ($print_response && isset($_GET['download'])) {
920
  return $this->download();
921
  }
filemanager/controller.php CHANGED
@@ -7,309 +7,279 @@
7
 
8
 
9
  class FilemanagerController {
10
- ////////////////////////////////////////////////////////////////////////////////////////
11
- // Events //
12
- ////////////////////////////////////////////////////////////////////////////////////////
13
- ////////////////////////////////////////////////////////////////////////////////////////
14
- // Constants //
15
- ////////////////////////////////////////////////////////////////////////////////////////
16
- ////////////////////////////////////////////////////////////////////////////////////////
17
- // Variables //
18
- ////////////////////////////////////////////////////////////////////////////////////////
19
- public $uploads_dir;
20
- public $uploads_url;
21
 
22
- ////////////////////////////////////////////////////////////////////////////////////////
23
- // Constructor & Destructor //
24
- ////////////////////////////////////////////////////////////////////////////////////////
25
-
26
- public function __construct() {
27
- $upload_dir = wp_upload_dir();
28
- global $wd_bwg_options;
29
- $this->uploads_dir = (($wd_bwg_options->images_directory . '/photo-gallery') ? ABSPATH . $wd_bwg_options->images_directory . '/photo-gallery' : WD_BWG_DIR . '/filemanager/uploads');
30
- if (file_exists($this->uploads_dir) == FALSE) {
31
- mkdir($this->uploads_dir);
32
- }
33
- $this->uploads_url = (($wd_bwg_options->images_directory . '/photo-gallery') ? site_url() . '/' . $wd_bwg_options->images_directory . '/photo-gallery' : WD_BWG_URL . '/filemanager/uploads');
34
  }
 
 
35
 
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
-
49
- public function get_uploads_dir() {
50
- return $this->uploads_dir;
51
  }
 
52
 
53
- public function get_uploads_url() {
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() {
67
- $input_dir = (isset($_REQUEST['dir']) ? str_replace('\\', '', esc_html($_REQUEST['dir'])) : '');
68
- $input_dir = htmlspecialchars_decode($input_dir, ENT_COMPAT | ENT_QUOTES);
69
- $cur_dir_path = $input_dir == '' ? $this->uploads_dir : $this->uploads_dir . '/' . $input_dir;
70
 
71
- $new_dir_path = $cur_dir_path . '/' . (isset($_REQUEST['new_dir_name']) ? stripslashes(esc_html(sanitize_file_name($_REQUEST['new_dir_name']))) : '');
72
- $new_dir_path = htmlspecialchars_decode($new_dir_path, ENT_COMPAT | ENT_QUOTES);
73
- $msg = '';
74
- if (file_exists($new_dir_path) == true) {
75
- $msg = "Directory already exists.";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
77
- else {
78
- mkdir($new_dir_path);
 
 
 
79
  }
80
- $query_url = wp_nonce_url( admin_url('admin-ajax.php'), 'addImages', 'bwg_nonce' );
81
- $query_url = add_query_arg(array('action' => 'addImages', 'filemanager_msg' => $msg, 'width' => '650', 'height' => '500', 'task' => 'display', 'extensions' => esc_html($_REQUEST['extensions']), 'callback' => esc_html($_REQUEST['callback']), 'dir' => $input_dir, 'TB_iframe' => '1'), $query_url);
82
- header('Location: ' . $query_url);
83
- exit;
 
84
  }
 
 
 
 
 
 
85
 
86
- public function rename_item() {
87
- $input_dir = (isset($_REQUEST['dir']) ? str_replace('\\', '', esc_html($_REQUEST['dir'])) : '');
88
- $input_dir = htmlspecialchars_decode($input_dir, ENT_COMPAT | ENT_QUOTES);
89
- $cur_dir_path = $input_dir == '' ? $this->uploads_dir : $this->uploads_dir . '/' . $input_dir;
90
 
91
- $file_names = explode('**#**', (isset($_REQUEST['file_names']) ? stripslashes(esc_html($_REQUEST['file_names'])) : ''));
92
- $file_name = $file_names[0];
 
 
93
  $file_name = htmlspecialchars_decode($file_name, ENT_COMPAT | ENT_QUOTES);
94
  $file_name = str_replace('../', '', $file_name);
95
-
96
- $file_new_name = (isset($_REQUEST['file_new_name']) ? stripslashes(esc_html($_REQUEST['file_new_name'])) : '');
97
- $file_new_name = htmlspecialchars_decode($file_new_name, ENT_COMPAT | ENT_QUOTES);
98
-
99
  $file_path = $cur_dir_path . '/' . $file_name;
100
  $thumb_file_path = $cur_dir_path . '/thumb/' . $file_name;
101
  $original_file_path = $cur_dir_path . '/.original/' . $file_name;
102
-
103
- $msg = '';
104
-
105
  if (file_exists($file_path) == false) {
106
- $msg = "File doesn't exist.";
107
  }
108
- elseif (is_dir($file_path) == true) {
109
- if (rename($file_path, $cur_dir_path . '/' . sanitize_file_name($file_new_name)) == false) {
110
- $msg = "Can't rename the file.";
 
111
  }
112
- }
113
- elseif ((strrpos($file_name, '.') !== false)) {
114
- $file_extension = substr($file_name, strrpos($file_name, '.') + 1);
115
- if (rename($file_path, $cur_dir_path . '/' . $file_new_name . '.' . $file_extension) == false) {
116
- $msg = "Can't rename the file.";
117
  }
118
- rename($thumb_file_path, $cur_dir_path . '/thumb/' . $file_new_name . '.' . $file_extension);
119
- rename($original_file_path, $cur_dir_path . '/.original/' . $file_new_name . '.' . $file_extension);
120
- }
121
- else {
122
- $msg = "Can't rename the file.";
123
  }
124
- $_REQUEST['file_names'] = '';
125
- $query_url = wp_nonce_url( admin_url('admin-ajax.php'), 'addImages', 'bwg_nonce' );
126
- $query_url = add_query_arg(array('action' => 'addImages', 'filemanager_msg' => $msg, 'width' => '650', 'height' => '500', 'task' => 'display', 'extensions' => esc_html($_REQUEST['extensions']), 'callback' => esc_html($_REQUEST['callback']), 'dir' => $input_dir, 'TB_iframe' => '1'), $query_url);
127
- header('Location: ' . $query_url);
128
- exit;
129
  }
 
 
 
 
 
 
130
 
131
- public function remove_items() {
132
- $input_dir = (isset($_REQUEST['dir']) ? str_replace('\\', '', ($_REQUEST['dir'])) : '');
133
- $input_dir = htmlspecialchars_decode($input_dir, ENT_COMPAT | ENT_QUOTES);
134
- $cur_dir_path = $input_dir == '' ? $this->uploads_dir : $this->uploads_dir . '/' . $input_dir;
135
 
136
- $file_names = explode('**#**', (isset($_REQUEST['file_names']) ? stripslashes(esc_html($_REQUEST['file_names'])) : ''));
 
 
 
 
 
 
137
 
138
- $msg = '';
139
- foreach ($file_names as $file_name) {
140
- $file_name = htmlspecialchars_decode($file_name, ENT_COMPAT | ENT_QUOTES);
141
- $file_name = str_replace('../', '', $file_name);
142
- $file_path = $cur_dir_path . '/' . $file_name;
143
- $thumb_file_path = $cur_dir_path . '/thumb/' . $file_name;
144
- $original_file_path = $cur_dir_path . '/.original/' . $file_name;
145
- if (file_exists($file_path) == false) {
146
- $msg = "Some of the files couldn't be removed.";
147
- }
148
- else {
149
- $this->remove_file_dir($file_path);
150
- if (file_exists($thumb_file_path)) {
151
- $this->remove_file_dir($thumb_file_path);
152
  }
153
- if (file_exists($original_file_path)) {
154
- $this->remove_file_dir($original_file_path);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  }
156
- }
157
- }
158
- $_REQUEST['file_names'] = '';
159
- $query_url = wp_nonce_url( admin_url('admin-ajax.php'), 'addImages', 'bwg_nonce' );
160
- $query_url = add_query_arg(array('action' => 'addImages', 'filemanager_msg' => $msg, 'width' => '650', 'height' => '500', 'task' => 'show_file_manager', 'extensions' => esc_html($_REQUEST['extensions']), 'callback' => esc_html($_REQUEST['callback']), 'dir' => $input_dir, 'TB_iframe' => '1'), $query_url);
161
- header('Location: ' . $query_url);
162
- exit;
163
- }
164
-
165
- public function paste_items() {
166
- $input_dir = (isset($_REQUEST['dir']) ? str_replace('\\', '', ($_REQUEST['dir'])) : '');
167
- $input_dir = htmlspecialchars_decode($input_dir, ENT_COMPAT | ENT_QUOTES);
168
- $msg = '';
169
-
170
- $file_names = explode('**#**', (isset($_REQUEST['clipboard_files']) ? stripslashes($_REQUEST['clipboard_files']) : ''));
171
- // $src_dir = $_SESSION['clipboard_src'];
172
- $src_dir = (isset($_REQUEST['clipboard_src']) ? stripslashes($_REQUEST['clipboard_src']) : '');
173
- $src_dir = $src_dir == '' ? $this->uploads_dir : $this->uploads_dir . '/' . $src_dir;
174
- $src_dir = htmlspecialchars_decode($src_dir, ENT_COMPAT | ENT_QUOTES);
175
- // $dest_dir = $_SESSION['clipboard_dest'];
176
- $dest_dir = (isset($_REQUEST['clipboard_dest']) ? stripslashes($_REQUEST['clipboard_dest']) : '');
177
- $dest_dir = $dest_dir == '' ? $this->uploads_dir : $this->uploads_dir . '/' . $dest_dir;
178
- $dest_dir = htmlspecialchars_decode($dest_dir, ENT_COMPAT | ENT_QUOTES);
179
 
180
- switch ((isset($_REQUEST['clipboard_task']) ? stripslashes($_REQUEST['clipboard_task']) : '')) {
181
- case 'copy':
 
 
 
 
 
 
 
 
 
182
  foreach ($file_names as $file_name) {
183
  $file_name = htmlspecialchars_decode($file_name, ENT_COMPAT | ENT_QUOTES);
184
  $file_name = str_replace('../', '', $file_name);
185
  $src = $src_dir . '/' . $file_name;
186
- if (file_exists($src) == false) {
187
- $msg = "Failed to copy some of the files.";
188
- $msg = $file_name;
189
- continue;
190
- }
191
  $dest = $dest_dir . '/' . $file_name;
192
  if (!is_dir($src_dir . '/' . $file_name)) {
193
- if (!is_dir($dest_dir . '/thumb')) {
194
- mkdir($dest_dir . '/thumb', 0777);
195
- }
196
  $thumb_src = $src_dir . '/thumb/' . $file_name;
197
  $thumb_dest = $dest_dir . '/thumb/' . $file_name;
198
- if (!is_dir($dest_dir . '/.original')) {
199
- mkdir($dest_dir . '/.original', 0777);
200
  }
201
  $original_src = $src_dir . '/.original/' . $file_name;
202
  $original_dest = $dest_dir . '/.original/' . $file_name;
203
- }
204
- $i = 0;
205
- if (file_exists($dest) == true) {
206
- $path_parts = pathinfo($dest);
207
- while (file_exists($path_parts['dirname'] . '/' . $path_parts['filename'] . '(' . ++$i . ')' . '.' . $path_parts['extension'])) {
208
- }
209
- $dest = $path_parts['dirname'] . '/' . $path_parts['filename'] . '(' . $i . ')' . '.' . $path_parts['extension'];
210
- if (!is_dir($src_dir . '/' . $file_name)) {
211
- $thumb_dest = $path_parts['dirname'] . '/thumb/' . $path_parts['filename'] . '(' . $i . ')' . '.' . $path_parts['extension'];
212
- $original_dest = $path_parts['dirname'] . '/.original/' . $path_parts['filename'] . '(' . $i . ')' . '.' . $path_parts['extension'];
213
  }
214
  }
215
-
216
- if (!$this->copy_file_dir($src, $dest)) {
217
- $msg = "Failed to copy some of the files.";
218
  }
219
  if (!is_dir($src_dir . '/' . $file_name)) {
220
- $this->copy_file_dir($thumb_src, $thumb_dest);
221
- $this->copy_file_dir($original_src, $original_dest);
222
  }
223
  }
224
- break;
225
- case 'cut':
226
- if ($src_dir != $dest_dir) {
227
- foreach ($file_names as $file_name) {
228
- $file_name = htmlspecialchars_decode($file_name, ENT_COMPAT | ENT_QUOTES);
229
- $file_name = str_replace('../', '', $file_name);
230
- $src = $src_dir . '/' . $file_name;
231
- $dest = $dest_dir . '/' . $file_name;
232
- if (!is_dir($src_dir . '/' . $file_name)) {
233
- $thumb_src = $src_dir . '/thumb/' . $file_name;
234
- $thumb_dest = $dest_dir . '/thumb/' . $file_name;
235
- if (!is_dir($dest_dir . '/thumb')) {
236
- mkdir($dest_dir . '/thumb', 0777);
237
- }
238
- $original_src = $src_dir . '/.original/' . $file_name;
239
- $original_dest = $dest_dir . '/.original/' . $file_name;
240
- if (!is_dir($dest_dir . '/.original')) {
241
- mkdir($dest_dir . '/.original', 0777);
242
- }
243
- }
244
- if ((file_exists($src) == false) || (file_exists($dest) == true) || (!rename($src, $dest))) {
245
- $msg = "Failed to move some of the files.";
246
- }
247
- if (!is_dir($src_dir . '/' . $file_name)) {
248
- rename($thumb_src, $thumb_dest);
249
- rename($original_src, $original_dest);
250
- }
251
- }
252
- }
253
- break;
254
- }
255
- $query_url = wp_nonce_url( admin_url('admin-ajax.php'), 'addImages', 'bwg_nonce' );
256
- $query_url = add_query_arg(array('action' => 'addImages', 'filemanager_msg' => $msg, 'width' => '650', 'height' => '500', 'task' => 'show_file_manager', 'extensions' => esc_html($_REQUEST['extensions']), 'callback' => esc_html($_REQUEST['callback']), 'dir' => $input_dir, 'TB_iframe' => '1'), $query_url);
257
- header('Location: ' . $query_url);
258
- exit;
259
  }
 
 
 
 
 
260
 
261
- public function import_items() {
262
- $query_url = wp_nonce_url( admin_url('admin-ajax.php'), 'bwg_UploadHandler', 'bwg_nonce' );
263
- $query_url = add_query_arg(array('action' => 'bwg_UploadHandler', 'importer_thumb_width' => esc_html($_REQUEST['importer_thumb_width']), 'importer_thumb_height' => esc_html($_REQUEST['importer_thumb_height']), 'callback' => esc_html($_REQUEST['callback']), 'file_namesML' => esc_html($_REQUEST['file_namesML']), 'importer_img_width' => esc_html($_REQUEST['importer_img_width']), 'importer_img_height' => esc_html($_REQUEST['importer_img_height']), 'import' => 'true', 'redir' => esc_html($_REQUEST['dir']), 'dir' => esc_html($_REQUEST['dir']) . '/'), $query_url);
264
- header('Location: ' . $query_url);
265
- exit;
266
- }
267
 
268
- ////////////////////////////////////////////////////////////////////////////////////////
269
- // Getters & Setters //
270
- ////////////////////////////////////////////////////////////////////////////////////////
271
- ////////////////////////////////////////////////////////////////////////////////////////
272
- // Private Methods //
273
- ////////////////////////////////////////////////////////////////////////////////////////
274
- private function remove_file_dir($del_file_dir) {
275
- if (is_dir($del_file_dir) == true) {
276
- $files_to_remove = scandir($del_file_dir);
277
- foreach ($files_to_remove as $file) {
278
- if ($file != '.' and $file != '..') {
279
- $this->remove_file_dir($del_file_dir . '/' . $file);
280
- }
281
  }
282
- rmdir($del_file_dir);
283
- }
284
- else {
285
- unlink($del_file_dir);
286
  }
 
287
  }
 
 
 
 
288
 
289
- private function copy_file_dir($src, $dest) {
290
- if (is_dir($src) == true) {
291
- $dir = opendir($src);
292
- @mkdir($dest);
293
- while (false !== ($file = readdir($dir))) {
294
- if (($file != '.') && ($file != '..')) {
295
- if (is_dir($src . '/' . $file)) {
296
- $this->copy_file_dir($src . '/' . $file, $dest . '/' . $file);
297
- }
298
- else {
299
- copy($src . '/' . $file, $dest . '/' . $file);
300
- }
301
  }
302
  }
303
- closedir($dir);
304
- return true;
305
- }
306
- else {
307
- return copy($src, $dest);
308
  }
 
 
309
  }
310
-
311
-
312
- ////////////////////////////////////////////////////////////////////////////////////////
313
- // Listeners //
314
- ////////////////////////////////////////////////////////////////////////////////////////
315
  }
7
 
8
 
9
  class FilemanagerController {
10
+ public $uploads_dir;
11
+ public $uploads_url;
 
 
 
 
 
 
 
 
 
12
 
13
+ public function __construct() {
14
+ $upload_dir = wp_upload_dir();
15
+ global $wd_bwg_options;
16
+ $this->uploads_dir = (($wd_bwg_options->images_directory . '/photo-gallery') ? ABSPATH . $wd_bwg_options->images_directory . '/photo-gallery' : WD_BWG_DIR . '/filemanager/uploads');
17
+ if (file_exists($this->uploads_dir) == FALSE) {
18
+ mkdir($this->uploads_dir);
 
 
 
 
 
 
19
  }
20
+ $this->uploads_url = (($wd_bwg_options->images_directory . '/photo-gallery') ? site_url() . '/' . $wd_bwg_options->images_directory . '/photo-gallery' : WD_BWG_URL . '/filemanager/uploads');
21
+ }
22
 
23
+ public function execute() {
24
+ $task = isset($_REQUEST['task']) ? stripslashes(esc_html($_REQUEST['task'])) : 'display';
25
+ if (method_exists($this, $task)) {
26
+ $this->$task();
 
 
 
 
 
 
 
27
  }
28
+ else {
29
+ $this->display();
 
30
  }
31
+ }
32
 
33
+ public function get_uploads_dir() {
34
+ return $this->uploads_dir;
35
+ }
36
+
37
+ public function get_uploads_url() {
38
+ return $this->uploads_url;
39
+ }
40
 
41
+ public function display() {
42
+ require_once WD_BWG_DIR . '/filemanager/model.php';
43
+ $model = new FilemanagerModel($this);
44
+ require_once WD_BWG_DIR . '/filemanager/view.php';
45
+ $view = new FilemanagerView($this, $model);
46
+ $view->display();
47
+ }
48
 
49
+ public function make_dir() {
50
+ $input_dir = (isset($_REQUEST['dir']) ? str_replace('\\', '', esc_html($_REQUEST['dir'])) : '');
51
+ $input_dir = htmlspecialchars_decode($input_dir, ENT_COMPAT | ENT_QUOTES);
52
+ $cur_dir_path = $input_dir == '' ? $this->uploads_dir : $this->uploads_dir . '/' . $input_dir;
53
+
54
+ $new_dir_path = $cur_dir_path . '/' . (isset($_REQUEST['new_dir_name']) ? stripslashes(esc_html(sanitize_file_name($_REQUEST['new_dir_name']))) : '');
55
+ $new_dir_path = htmlspecialchars_decode($new_dir_path, ENT_COMPAT | ENT_QUOTES);
56
+ $msg = '';
57
+ if (file_exists($new_dir_path) == true) {
58
+ $msg = "Directory already exists.";
59
+ }
60
+ else {
61
+ mkdir($new_dir_path);
62
  }
63
+ $query_url = wp_nonce_url( admin_url('admin-ajax.php'), 'addImages', 'bwg_nonce' );
64
+ $query_url = add_query_arg(array('action' => 'addImages', 'filemanager_msg' => $msg, 'width' => '650', 'height' => '500', 'task' => 'display', 'extensions' => esc_html($_REQUEST['extensions']), 'callback' => esc_html($_REQUEST['callback']), 'dir' => $input_dir, 'TB_iframe' => '1'), $query_url);
65
+ header('Location: ' . $query_url);
66
+ exit;
67
+ }
68
 
69
+ public function rename_item() {
70
+ $input_dir = (isset($_REQUEST['dir']) ? str_replace('\\', '', esc_html($_REQUEST['dir'])) : '');
71
+ $input_dir = htmlspecialchars_decode($input_dir, ENT_COMPAT | ENT_QUOTES);
72
+ $cur_dir_path = $input_dir == '' ? $this->uploads_dir : $this->uploads_dir . '/' . $input_dir;
73
 
74
+ $file_names = explode('**#**', (isset($_REQUEST['file_names']) ? stripslashes(esc_html($_REQUEST['file_names'])) : ''));
75
+ $file_name = $file_names[0];
76
+ $file_name = htmlspecialchars_decode($file_name, ENT_COMPAT | ENT_QUOTES);
77
+ $file_name = str_replace('../', '', $file_name);
78
+
79
+ $file_new_name = (isset($_REQUEST['file_new_name']) ? stripslashes(esc_html($_REQUEST['file_new_name'])) : '');
80
+ $file_new_name = htmlspecialchars_decode($file_new_name, ENT_COMPAT | ENT_QUOTES);
81
+
82
+ $file_path = $cur_dir_path . '/' . $file_name;
83
+ $thumb_file_path = $cur_dir_path . '/thumb/' . $file_name;
84
+ $original_file_path = $cur_dir_path . '/.original/' . $file_name;
85
+
86
+ $msg = '';
87
+
88
+ if (file_exists($file_path) == false) {
89
+ $msg = "File doesn't exist.";
90
+ }
91
+ elseif (is_dir($file_path) == true) {
92
+ if (rename($file_path, $cur_dir_path . '/' . sanitize_file_name($file_new_name)) == false) {
93
+ $msg = "Can't rename the file.";
94
  }
95
+ }
96
+ elseif ((strrpos($file_name, '.') !== false)) {
97
+ $file_extension = substr($file_name, strrpos($file_name, '.') + 1);
98
+ if (rename($file_path, $cur_dir_path . '/' . $file_new_name . '.' . $file_extension) == false) {
99
+ $msg = "Can't rename the file.";
100
  }
101
+ rename($thumb_file_path, $cur_dir_path . '/thumb/' . $file_new_name . '.' . $file_extension);
102
+ rename($original_file_path, $cur_dir_path . '/.original/' . $file_new_name . '.' . $file_extension);
103
+ }
104
+ else {
105
+ $msg = "Can't rename the file.";
106
  }
107
+ $_REQUEST['file_names'] = '';
108
+ $query_url = wp_nonce_url( admin_url('admin-ajax.php'), 'addImages', 'bwg_nonce' );
109
+ $query_url = add_query_arg(array('action' => 'addImages', 'filemanager_msg' => $msg, 'width' => '650', 'height' => '500', 'task' => 'display', 'extensions' => esc_html($_REQUEST['extensions']), 'callback' => esc_html($_REQUEST['callback']), 'dir' => $input_dir, 'TB_iframe' => '1'), $query_url);
110
+ header('Location: ' . $query_url);
111
+ exit;
112
+ }
113
 
114
+ public function remove_items() {
115
+ $input_dir = (isset($_REQUEST['dir']) ? str_replace('\\', '', ($_REQUEST['dir'])) : '');
116
+ $input_dir = htmlspecialchars_decode($input_dir, ENT_COMPAT | ENT_QUOTES);
117
+ $cur_dir_path = $input_dir == '' ? $this->uploads_dir : $this->uploads_dir . '/' . $input_dir;
118
 
119
+ $file_names = explode('**#**', (isset($_REQUEST['file_names']) ? stripslashes(esc_html($_REQUEST['file_names'])) : ''));
120
+
121
+ $msg = '';
122
+ foreach ($file_names as $file_name) {
123
  $file_name = htmlspecialchars_decode($file_name, ENT_COMPAT | ENT_QUOTES);
124
  $file_name = str_replace('../', '', $file_name);
 
 
 
 
125
  $file_path = $cur_dir_path . '/' . $file_name;
126
  $thumb_file_path = $cur_dir_path . '/thumb/' . $file_name;
127
  $original_file_path = $cur_dir_path . '/.original/' . $file_name;
 
 
 
128
  if (file_exists($file_path) == false) {
129
+ $msg = "Some of the files couldn't be removed.";
130
  }
131
+ else {
132
+ $this->remove_file_dir($file_path);
133
+ if (file_exists($thumb_file_path)) {
134
+ $this->remove_file_dir($thumb_file_path);
135
  }
136
+ if (file_exists($original_file_path)) {
137
+ $this->remove_file_dir($original_file_path);
 
 
 
138
  }
 
 
 
 
 
139
  }
 
 
 
 
 
140
  }
141
+ $_REQUEST['file_names'] = '';
142
+ $query_url = wp_nonce_url( admin_url('admin-ajax.php'), 'addImages', 'bwg_nonce' );
143
+ $query_url = add_query_arg(array('action' => 'addImages', 'filemanager_msg' => $msg, 'width' => '650', 'height' => '500', 'task' => 'show_file_manager', 'extensions' => esc_html($_REQUEST['extensions']), 'callback' => esc_html($_REQUEST['callback']), 'dir' => $input_dir, 'TB_iframe' => '1'), $query_url);
144
+ header('Location: ' . $query_url);
145
+ exit;
146
+ }
147
 
148
+ public function paste_items() {
149
+ $input_dir = (isset($_REQUEST['dir']) ? str_replace('\\', '', ($_REQUEST['dir'])) : '');
150
+ $input_dir = htmlspecialchars_decode($input_dir, ENT_COMPAT | ENT_QUOTES);
151
+ $msg = '';
152
 
153
+ $file_names = explode('**#**', (isset($_REQUEST['clipboard_files']) ? stripslashes($_REQUEST['clipboard_files']) : ''));
154
+ $src_dir = (isset($_REQUEST['clipboard_src']) ? stripslashes($_REQUEST['clipboard_src']) : '');
155
+ $src_dir = $src_dir == '' ? $this->uploads_dir : $this->uploads_dir . '/' . $src_dir;
156
+ $src_dir = htmlspecialchars_decode($src_dir, ENT_COMPAT | ENT_QUOTES);
157
+ $dest_dir = (isset($_REQUEST['clipboard_dest']) ? stripslashes($_REQUEST['clipboard_dest']) : '');
158
+ $dest_dir = $dest_dir == '' ? $this->uploads_dir : $this->uploads_dir . '/' . $dest_dir;
159
+ $dest_dir = htmlspecialchars_decode($dest_dir, ENT_COMPAT | ENT_QUOTES);
160
 
161
+ switch ((isset($_REQUEST['clipboard_task']) ? stripslashes($_REQUEST['clipboard_task']) : '')) {
162
+ case 'copy':
163
+ foreach ($file_names as $file_name) {
164
+ $file_name = htmlspecialchars_decode($file_name, ENT_COMPAT | ENT_QUOTES);
165
+ $file_name = str_replace('../', '', $file_name);
166
+ $src = $src_dir . '/' . $file_name;
167
+ if (file_exists($src) == false) {
168
+ $msg = "Failed to copy some of the files.";
169
+ $msg = $file_name;
170
+ continue;
 
 
 
 
171
  }
172
+ $dest = $dest_dir . '/' . $file_name;
173
+ if (!is_dir($src_dir . '/' . $file_name)) {
174
+ if (!is_dir($dest_dir . '/thumb')) {
175
+ mkdir($dest_dir . '/thumb', 0777);
176
+ }
177
+ $thumb_src = $src_dir . '/thumb/' . $file_name;
178
+ $thumb_dest = $dest_dir . '/thumb/' . $file_name;
179
+ if (!is_dir($dest_dir . '/.original')) {
180
+ mkdir($dest_dir . '/.original', 0777);
181
+ }
182
+ $original_src = $src_dir . '/.original/' . $file_name;
183
+ $original_dest = $dest_dir . '/.original/' . $file_name;
184
+ }
185
+ $i = 0;
186
+ if (file_exists($dest) == true) {
187
+ $path_parts = pathinfo($dest);
188
+ while (file_exists($path_parts['dirname'] . '/' . $path_parts['filename'] . '(' . ++$i . ')' . '.' . $path_parts['extension'])) {
189
+ }
190
+ $dest = $path_parts['dirname'] . '/' . $path_parts['filename'] . '(' . $i . ')' . '.' . $path_parts['extension'];
191
+ if (!is_dir($src_dir . '/' . $file_name)) {
192
+ $thumb_dest = $path_parts['dirname'] . '/thumb/' . $path_parts['filename'] . '(' . $i . ')' . '.' . $path_parts['extension'];
193
+ $original_dest = $path_parts['dirname'] . '/.original/' . $path_parts['filename'] . '(' . $i . ')' . '.' . $path_parts['extension'];
194
+ }
195
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
+ if (!$this->copy_file_dir($src, $dest)) {
198
+ $msg = "Failed to copy some of the files.";
199
+ }
200
+ if (!is_dir($src_dir . '/' . $file_name)) {
201
+ $this->copy_file_dir($thumb_src, $thumb_dest);
202
+ $this->copy_file_dir($original_src, $original_dest);
203
+ }
204
+ }
205
+ break;
206
+ case 'cut':
207
+ if ($src_dir != $dest_dir) {
208
  foreach ($file_names as $file_name) {
209
  $file_name = htmlspecialchars_decode($file_name, ENT_COMPAT | ENT_QUOTES);
210
  $file_name = str_replace('../', '', $file_name);
211
  $src = $src_dir . '/' . $file_name;
 
 
 
 
 
212
  $dest = $dest_dir . '/' . $file_name;
213
  if (!is_dir($src_dir . '/' . $file_name)) {
 
 
 
214
  $thumb_src = $src_dir . '/thumb/' . $file_name;
215
  $thumb_dest = $dest_dir . '/thumb/' . $file_name;
216
+ if (!is_dir($dest_dir . '/thumb')) {
217
+ mkdir($dest_dir . '/thumb', 0777);
218
  }
219
  $original_src = $src_dir . '/.original/' . $file_name;
220
  $original_dest = $dest_dir . '/.original/' . $file_name;
221
+ if (!is_dir($dest_dir . '/.original')) {
222
+ mkdir($dest_dir . '/.original', 0777);
 
 
 
 
 
 
 
 
223
  }
224
  }
225
+ if ((file_exists($src) == false) || (file_exists($dest) == true) || (!rename($src, $dest))) {
226
+ $msg = "Failed to move some of the files.";
 
227
  }
228
  if (!is_dir($src_dir . '/' . $file_name)) {
229
+ rename($thumb_src, $thumb_dest);
230
+ rename($original_src, $original_dest);
231
  }
232
  }
233
+ }
234
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  }
236
+ $query_url = wp_nonce_url( admin_url('admin-ajax.php'), 'addImages', 'bwg_nonce' );
237
+ $query_url = add_query_arg(array('action' => 'addImages', 'filemanager_msg' => $msg, 'width' => '650', 'height' => '500', 'task' => 'show_file_manager', 'extensions' => esc_html($_REQUEST['extensions']), 'callback' => esc_html($_REQUEST['callback']), 'dir' => $input_dir, 'TB_iframe' => '1'), $query_url);
238
+ header('Location: ' . $query_url);
239
+ exit;
240
+ }
241
 
242
+ public function import_items() {
243
+ $query_url = wp_nonce_url( admin_url('admin-ajax.php'), 'bwg_UploadHandler', 'bwg_nonce' );
244
+ $query_url = add_query_arg(array('action' => 'bwg_UploadHandler', 'importer_thumb_width' => esc_html($_REQUEST['importer_thumb_width']), 'importer_thumb_height' => esc_html($_REQUEST['importer_thumb_height']), 'callback' => esc_html($_REQUEST['callback']), 'file_namesML' => esc_html($_REQUEST['file_namesML']), 'importer_img_width' => esc_html($_REQUEST['importer_img_width']), 'importer_img_height' => esc_html($_REQUEST['importer_img_height']), 'import' => 'true', 'redir' => esc_html($_REQUEST['dir']), 'dir' => esc_html($_REQUEST['dir']) . '/'), $query_url);
245
+ header('Location: ' . $query_url);
246
+ exit;
247
+ }
248
 
249
+ private function remove_file_dir($del_file_dir) {
250
+ if (is_dir($del_file_dir) == true) {
251
+ $files_to_remove = scandir($del_file_dir);
252
+ foreach ($files_to_remove as $file) {
253
+ if ($file != '.' and $file != '..') {
254
+ $this->remove_file_dir($del_file_dir . '/' . $file);
 
 
 
 
 
 
 
255
  }
 
 
 
 
256
  }
257
+ rmdir($del_file_dir);
258
  }
259
+ else {
260
+ unlink($del_file_dir);
261
+ }
262
+ }
263
 
264
+ private function copy_file_dir($src, $dest) {
265
+ if (is_dir($src) == true) {
266
+ $dir = opendir($src);
267
+ @mkdir($dest);
268
+ while (false !== ($file = readdir($dir))) {
269
+ if (($file != '.') && ($file != '..')) {
270
+ if (is_dir($src . '/' . $file)) {
271
+ $this->copy_file_dir($src . '/' . $file, $dest . '/' . $file);
272
+ }
273
+ else {
274
+ copy($src . '/' . $file, $dest . '/' . $file);
 
275
  }
276
  }
 
 
 
 
 
277
  }
278
+ closedir($dir);
279
+ return true;
280
  }
281
+ else {
282
+ return copy($src, $dest);
283
+ }
284
+ }
 
285
  }
filemanager/css/default.css CHANGED
@@ -88,6 +88,7 @@ html, body, div, span, th, td, a {
88
  bottom: 0;
89
  left: 0;
90
  right: 0;
 
91
  }
92
 
93
  #file_manager,
88
  bottom: 0;
89
  left: 0;
90
  right: 0;
91
+ width: 100%;
92
  }
93
 
94
  #file_manager,
filemanager/js/default.js CHANGED
@@ -7,13 +7,10 @@
7
  var keyFileSelected;
8
  var keyFileSelectedML;
9
  var filesSelected;
10
- var filesSelectedML;
11
  var dragFiles;
12
  var isUploading;
13
 
14
  var ajax = true;
15
- var importer_ajax = true;
16
- var media_lib_images = false;
17
 
18
  var all_files_selected = false;
19
  var no_selected_files = [];
@@ -36,29 +33,8 @@ jQuery(document).ready(function () {
36
  }
37
  }
38
  });
39
- var media_lib_elements = 2;
40
- var media_lib_item_count = jQuery("#importer_body_container #importer_body").data("files_count");
41
- jQuery("#importer_body_container").scroll(function () {
42
- var importer_item_count = jQuery("#importer_body .importer_item").length;
43
- if (importer_ajax && importer_item_count < media_lib_item_count) {
44
- var scroll_position = jQuery(this).scrollTop() + jQuery(this).innerHeight();
45
- var scroll_Height = jQuery(this)[0].scrollHeight;
46
- if (scroll_position >= scroll_Height) {
47
- var start_count = (media_lib_elements-1)*element_load_count;
48
- var end_count = media_lib_elements*element_load_count;
49
- var next_files = media_library_files.slice(start_count, end_count);
50
- ajax_print_images(next_files , jQuery("#importer_body"), 'importer_item', start_count);
51
- media_lib_elements++;
52
- }
53
- }
54
- });
55
 
56
- if (jQuery("#importer").css("display") != 'none') {
57
- var all_images_count = jQuery("#importer .item_thumb img").length;
58
- }
59
- else {
60
- var all_images_count = jQuery("#file_manager .item_thumb img").length;
61
- }
62
  if (!all_images_count) {
63
  setTimeout(function(){jQuery(document).trigger("onUpload")});
64
  }
@@ -70,10 +46,8 @@ jQuery(document).ready(function () {
70
  }
71
  setTimeout(function(){loaded()}, 10000);
72
  filesSelected = [];
73
- filesSelectedML = [];
74
  dragFiles = [];
75
 
76
- //file manager under system messages
77
  jQuery("#wrapper").css("top", jQuery("#file_manager_message").css("height"));
78
  jQuery(window).resize(function () {
79
  jQuery("#container").css("top", jQuery("#file_manager_message").css("height"));
@@ -117,7 +91,6 @@ function getClipboardFiles() {
117
 
118
  function submit(task, sortBy, sortOrder, itemsView, destDir, fileNewName, newDirName, clipboardTask, clipboardFiles, clipboardSrc, clipboardDest) {
119
  var names_array = [];
120
- var lib_names_array = [];
121
  if (all_files_selected === true) {
122
  for (i in wdb_all_files) {
123
  var index = no_selected_files.indexOf(wdb_all_files[i]["name"]);
@@ -126,19 +99,10 @@ function submit(task, sortBy, sortOrder, itemsView, destDir, fileNewName, newDir
126
  names_array.push(all_names);
127
  }
128
  }
129
- for (i in media_library_files) {
130
- var lib_index = no_selected_files.indexOf(media_library_files[i]["name"]);
131
- if (lib_index < 0) {
132
- var lib_all_names = media_library_files[i]["path"];
133
- lib_names_array.push(lib_all_names);
134
- }
135
- }
136
  fileNames = names_array.join("**#**");
137
- fileNamesML = lib_names_array.join("**@**");
138
  }
139
  else {
140
  fileNames = filesSelected.join("**#**");
141
- fileNamesML = filesSelectedML.join("**@**");
142
  }
143
 
144
  switch (task) {
@@ -188,23 +152,18 @@ function submit(task, sortBy, sortOrder, itemsView, destDir, fileNewName, newDir
188
  if (itemsView != null) {
189
  jQuery("form[name=adminForm]").find("input[name=items_view]").val(itemsView);
190
  }
191
-
192
  if (destDir != null) {
193
  jQuery("form[name=adminForm]").find("input[name=dir]").val(destDir);
194
  }
195
  if (fileNames != null) {
196
  jQuery("form[name=adminForm]").find("input[name=file_names]").val(fileNames);
197
  }
198
- if (fileNamesML != null) {
199
- jQuery("form[name=adminForm]").find("input[name=file_namesML]").val(fileNamesML);
200
- }
201
  if (fileNewName != null) {
202
  jQuery("form[name=adminForm]").find("input[name=file_new_name]").val(fileNewName);
203
  }
204
  if (newDirName != null) {
205
  jQuery("form[name=adminForm]").find("input[name=new_dir_name]").val(newDirName);
206
  }
207
-
208
  if (clipboardTask != null) {
209
  jQuery("form[name=adminForm]").find("input[name=clipboard_task]").val(clipboardTask);
210
  }
@@ -236,6 +195,7 @@ function submitFiles() {
236
  if (filesSelected.length == 0) {
237
  return;
238
  }
 
239
  var filesValid = [];
240
  if (all_files_selected === true) {
241
  for (i in wdb_all_files) {
@@ -245,6 +205,7 @@ function submitFiles() {
245
  if (index < 0) {
246
  fileData['name'] = wdb_all_files[i]["name"];
247
  fileData['filename'] = wdb_all_files[i]["filename"];;
 
248
  fileData['url'] = dir + "/" + wdb_all_files[i]["name"];
249
  fileData['reliative_url'] = dirUrl + "/" + wdb_all_files[i]["name"];
250
  fileData['thumb_url'] = dir + "/thumb/" + wdb_all_files[i]["name"];
@@ -272,6 +233,7 @@ function submitFiles() {
272
  var fileData = [];
273
  fileData['name'] = filesSelected[i];
274
  fileData['filename'] = jQuery(file_object).attr("filename");
 
275
  fileData['url'] = dir + "/" + filesSelected[i];
276
  fileData['reliative_url'] = dirUrl + "/" + filesSelected[i];
277
  fileData['thumb_url'] = dir + "/thumb/" + filesSelected[i];
@@ -296,17 +258,6 @@ function submitFiles() {
296
  window.parent.tb_remove();
297
  }
298
 
299
- function importFiles() {
300
- if (filesSelectedML.length == 0) {
301
- alert();
302
- alert("Select at least one file to import.");
303
- return;
304
- }
305
- else {
306
- submit("import_items", null, null, null, null, null, null, null, null, null, dir);
307
- }
308
- }
309
-
310
  function getScrollBarWidth() {
311
  var inner = document.createElement("p");
312
  inner.style.width = "100%";
@@ -449,7 +400,6 @@ function onPathComponentClick(event, obj, key) {
449
  }
450
 
451
  function onBtnShowImportClick(event, obj) {
452
- media_lib_images = true;
453
  jQuery("#importer").fadeIn();
454
  }
455
 
@@ -478,7 +428,6 @@ function onKeyDown(e) {
478
  jQuery(".explorer_item").addClass("explorer_item_select");
479
  jQuery(".importer_item").addClass("importer_item_select");
480
  filesSelected = [];
481
- filesSelectedML = [];
482
  jQuery(".explorer_item").each(function() {
483
  var objName = jQuery(this).attr("name");
484
  if (filesSelected.indexOf(objName) == -1) {
@@ -486,13 +435,6 @@ function onKeyDown(e) {
486
  keyFileSelected = this;
487
  }
488
  });
489
- jQuery(".importer_item").each(function() {
490
- var objName = jQuery(this).attr("path");
491
- if (filesSelectedML.indexOf(objName) == -1) {
492
- filesSelectedML.push(objName);
493
- keyFileSelectedML = this;
494
- }
495
- });
496
  e.preventDefault();
497
  }
498
  }
@@ -501,18 +443,10 @@ function onFileMOver(event, obj) {
501
  jQuery(obj).addClass("explorer_item_hover");
502
  }
503
 
504
- function onFileMOverML(event, obj) {
505
- jQuery(obj).addClass("importer_item_hover");
506
- }
507
-
508
  function onFileMOut(event, obj) {
509
  jQuery(obj).removeClass("explorer_item_hover");
510
  }
511
 
512
- function onFileMOutML(event, obj) {
513
- jQuery(obj).removeClass("importer_item_hover");
514
- }
515
-
516
  function onFileClick(event, obj) {
517
  jQuery(".explorer_item").removeClass("explorer_item_select");
518
  var objName = jQuery(obj).attr("name");
@@ -559,41 +493,6 @@ function onFileClick(event, obj) {
559
  updateFileNames();
560
  }
561
 
562
- function onFileClickML(event, obj) {
563
- jQuery(".importer_item").removeClass("importer_item_select");
564
- var objName = jQuery(obj).attr("path");
565
- if (event.ctrlKey == true || event.metaKey == true) {
566
- if (filesSelectedML.indexOf(objName) == -1) {
567
- filesSelectedML.push(objName);
568
- keyFileSelectedML = obj;
569
- }
570
- else {
571
- filesSelectedML.splice(filesSelectedML.indexOf(objName), 1);
572
- jQuery(obj).removeClass("importer_item_select");
573
- }
574
- }
575
- else if (event.shiftKey == true) {
576
- filesSelectedML = [];
577
- var explorerItems = jQuery(".importer_item");
578
- var curFileIndex = explorerItems.index(jQuery(obj));
579
- var keyFileIndex = explorerItems.index(keyFileSelectedML);
580
- var startIndex = Math.min(keyFileIndex, curFileIndex);
581
- var endIndex = startIndex + Math.abs(curFileIndex - keyFileIndex);
582
- for (var i = startIndex; i < endIndex + 1; i++) {
583
- filesSelectedML.push(jQuery(explorerItems[i]).attr("path"));
584
- }
585
- }
586
- else {
587
- filesSelectedML = [jQuery(obj).attr("path")];
588
- keyFileSelectedML = obj;
589
- }
590
-
591
- for (var i = 0; i < filesSelectedML.length; i++) {
592
- jQuery(".importer_item[path='" + filesSelectedML[i] + "']").addClass("importer_item_select");
593
- }
594
- updateFileNames();
595
- }
596
-
597
  function onFileDblClick(event, obj) {
598
  if (jQuery(obj).attr("isDir") == "true") {
599
  submit("", null, null, null, dir + DS + jQuery(obj).attr("name"), null, null, null, null, null, null);
@@ -605,12 +504,6 @@ function onFileDblClick(event, obj) {
605
  }
606
  }
607
 
608
- function onFileDblClickML(event, obj) {
609
- filesSelectedML = [];
610
- filesSelectedML.push(jQuery(obj).attr("path"));
611
- importFiles();
612
- }
613
-
614
  function onFileDragStart(event, obj) {
615
  var objName = jQuery(obj).attr("name");
616
  if (filesSelected.indexOf(objName) < 0) {
@@ -671,10 +564,6 @@ function onBtnOpenClick(event, obj) {
671
  }
672
  }
673
 
674
- function onBtnImportClick(event, obj) {
675
- importFiles();
676
- }
677
-
678
  function onBtnCancelClick(event, obj) {
679
  window.parent.tb_remove();
680
  }
@@ -693,44 +582,10 @@ function onBtnSelectAllClick() {
693
  all_files_selected = true;
694
  }
695
 
696
- function onBtnSelectAllMediLibraryClick() {
697
- jQuery(".importer_item").addClass("importer_item_select");
698
- filesSelectedML = [];
699
- jQuery(".importer_item").each(function() {
700
- var objName = jQuery(this).attr("path");
701
- if (filesSelectedML.indexOf(objName) == -1) {
702
- filesSelectedML.push(objName);
703
- keyFileSelectedML = this;
704
- }
705
- });
706
- }
707
-
708
  function ajax_print_images(files, element, view_type, count) {
709
- var element_class;
710
- if (view_type === "explorer_item") {
711
- element_class = "explorer_item";
712
- var onmouseover = "onFileMOver(event, this);";
713
- var onmouseout = "onFileMOut(event, this);";
714
- var onclick = "onFileClick(event, this);";
715
- var ondblclick = "onFileDblClick(event, this);";
716
- var ondragstart = "onFileDragStart(event, this);";
717
- }
718
- else {
719
- element_class = "importer_item";
720
- var onmouseover = "onFileMOverML(event, this);";
721
- var onmouseout = "onFileMOutML(event, this);";
722
- var onclick = "onFileClickML(event, this);";
723
- var ondblclick = "onFileDblClickML(event, this);";
724
- var ondragstart = "";
725
- }
726
-
727
  for (i in files) {
728
  var corent_file = files[i];
729
  var name = corent_file["name"];
730
- var path = "";
731
- if (view_type === "importer_item") {
732
- path = corent_file["path"];
733
- }
734
  var filename = corent_file["filename"];
735
  var filethumb = corent_file["thumb"];
736
  var filesize = corent_file["size"];
@@ -744,7 +599,11 @@ function ajax_print_images(files, element, view_type, count) {
744
  var fileIso = corent_file["iso"];
745
  var fileOrientation = corent_file["orientation"];
746
  var fileCopyright = corent_file["copyright"];
747
-
 
 
 
 
748
  var ondragover = "";
749
  var ondrop = "";
750
  if (corent_file['is_dir'] == true) {
@@ -764,9 +623,8 @@ function ajax_print_images(files, element, view_type, count) {
764
  var item_size = '<span class="item_size">'+corent_file['size']+'</span>';
765
  var item_date_modified = '<span class="item_date_modified">'+corent_file['date_modified']+'</span>';
766
  var item_numbering = '<span class="item_numbering">'+item_number+'</span>';
767
- var explorer_item = '<div class="' + element_class + '" ' +
768
  'name="' + name + '" ' +
769
- 'path="' + path + '" ' +
770
  'filename="' + filename + '" ' +
771
  'filethumb="' + filethumb + '" ' +
772
  'filesize="' + filesize + '" ' +
7
  var keyFileSelected;
8
  var keyFileSelectedML;
9
  var filesSelected;
 
10
  var dragFiles;
11
  var isUploading;
12
 
13
  var ajax = true;
 
 
14
 
15
  var all_files_selected = false;
16
  var no_selected_files = [];
33
  }
34
  }
35
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
+ var all_images_count = jQuery("#file_manager .item_thumb img").length;
 
 
 
 
 
38
  if (!all_images_count) {
39
  setTimeout(function(){jQuery(document).trigger("onUpload")});
40
  }
46
  }
47
  setTimeout(function(){loaded()}, 10000);
48
  filesSelected = [];
 
49
  dragFiles = [];
50
 
 
51
  jQuery("#wrapper").css("top", jQuery("#file_manager_message").css("height"));
52
  jQuery(window).resize(function () {
53
  jQuery("#container").css("top", jQuery("#file_manager_message").css("height"));
91
 
92
  function submit(task, sortBy, sortOrder, itemsView, destDir, fileNewName, newDirName, clipboardTask, clipboardFiles, clipboardSrc, clipboardDest) {
93
  var names_array = [];
 
94
  if (all_files_selected === true) {
95
  for (i in wdb_all_files) {
96
  var index = no_selected_files.indexOf(wdb_all_files[i]["name"]);
99
  names_array.push(all_names);
100
  }
101
  }
 
 
 
 
 
 
 
102
  fileNames = names_array.join("**#**");
 
103
  }
104
  else {
105
  fileNames = filesSelected.join("**#**");
 
106
  }
107
 
108
  switch (task) {
152
  if (itemsView != null) {
153
  jQuery("form[name=adminForm]").find("input[name=items_view]").val(itemsView);
154
  }
 
155
  if (destDir != null) {
156
  jQuery("form[name=adminForm]").find("input[name=dir]").val(destDir);
157
  }
158
  if (fileNames != null) {
159
  jQuery("form[name=adminForm]").find("input[name=file_names]").val(fileNames);
160
  }
 
 
 
161
  if (fileNewName != null) {
162
  jQuery("form[name=adminForm]").find("input[name=file_new_name]").val(fileNewName);
163
  }
164
  if (newDirName != null) {
165
  jQuery("form[name=adminForm]").find("input[name=new_dir_name]").val(newDirName);
166
  }
 
167
  if (clipboardTask != null) {
168
  jQuery("form[name=adminForm]").find("input[name=clipboard_task]").val(clipboardTask);
169
  }
195
  if (filesSelected.length == 0) {
196
  return;
197
  }
198
+
199
  var filesValid = [];
200
  if (all_files_selected === true) {
201
  for (i in wdb_all_files) {
205
  if (index < 0) {
206
  fileData['name'] = wdb_all_files[i]["name"];
207
  fileData['filename'] = wdb_all_files[i]["filename"];;
208
+ fileData['alt'] = wdb_all_files[i]["alt"];;
209
  fileData['url'] = dir + "/" + wdb_all_files[i]["name"];
210
  fileData['reliative_url'] = dirUrl + "/" + wdb_all_files[i]["name"];
211
  fileData['thumb_url'] = dir + "/thumb/" + wdb_all_files[i]["name"];
233
  var fileData = [];
234
  fileData['name'] = filesSelected[i];
235
  fileData['filename'] = jQuery(file_object).attr("filename");
236
+ fileData['alt'] = jQuery(file_object).attr("alt");
237
  fileData['url'] = dir + "/" + filesSelected[i];
238
  fileData['reliative_url'] = dirUrl + "/" + filesSelected[i];
239
  fileData['thumb_url'] = dir + "/thumb/" + filesSelected[i];
258
  window.parent.tb_remove();
259
  }
260
 
 
 
 
 
 
 
 
 
 
 
 
261
  function getScrollBarWidth() {
262
  var inner = document.createElement("p");
263
  inner.style.width = "100%";
400
  }
401
 
402
  function onBtnShowImportClick(event, obj) {
 
403
  jQuery("#importer").fadeIn();
404
  }
405
 
428
  jQuery(".explorer_item").addClass("explorer_item_select");
429
  jQuery(".importer_item").addClass("importer_item_select");
430
  filesSelected = [];
 
431
  jQuery(".explorer_item").each(function() {
432
  var objName = jQuery(this).attr("name");
433
  if (filesSelected.indexOf(objName) == -1) {
435
  keyFileSelected = this;
436
  }
437
  });
 
 
 
 
 
 
 
438
  e.preventDefault();
439
  }
440
  }
443
  jQuery(obj).addClass("explorer_item_hover");
444
  }
445
 
 
 
 
 
446
  function onFileMOut(event, obj) {
447
  jQuery(obj).removeClass("explorer_item_hover");
448
  }
449
 
 
 
 
 
450
  function onFileClick(event, obj) {
451
  jQuery(".explorer_item").removeClass("explorer_item_select");
452
  var objName = jQuery(obj).attr("name");
493
  updateFileNames();
494
  }
495
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
496
  function onFileDblClick(event, obj) {
497
  if (jQuery(obj).attr("isDir") == "true") {
498
  submit("", null, null, null, dir + DS + jQuery(obj).attr("name"), null, null, null, null, null, null);
504
  }
505
  }
506
 
 
 
 
 
 
 
507
  function onFileDragStart(event, obj) {
508
  var objName = jQuery(obj).attr("name");
509
  if (filesSelected.indexOf(objName) < 0) {
564
  }
565
  }
566
 
 
 
 
 
567
  function onBtnCancelClick(event, obj) {
568
  window.parent.tb_remove();
569
  }
582
  all_files_selected = true;
583
  }
584
 
 
 
 
 
 
 
 
 
 
 
 
 
585
  function ajax_print_images(files, element, view_type, count) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
586
  for (i in files) {
587
  var corent_file = files[i];
588
  var name = corent_file["name"];
 
 
 
 
589
  var filename = corent_file["filename"];
590
  var filethumb = corent_file["thumb"];
591
  var filesize = corent_file["size"];
599
  var fileIso = corent_file["iso"];
600
  var fileOrientation = corent_file["orientation"];
601
  var fileCopyright = corent_file["copyright"];
602
+ var onmouseover = "onFileMOver(event, this);";
603
+ var onmouseout = "onFileMOut(event, this);";
604
+ var onclick = "onFileClick(event, this);";
605
+ var ondblclick = "onFileDblClick(event, this);";
606
+ var ondragstart = "onFileDragStart(event, this);";
607
  var ondragover = "";
608
  var ondrop = "";
609
  if (corent_file['is_dir'] == true) {
623
  var item_size = '<span class="item_size">'+corent_file['size']+'</span>';
624
  var item_date_modified = '<span class="item_date_modified">'+corent_file['date_modified']+'</span>';
625
  var item_numbering = '<span class="item_numbering">'+item_number+'</span>';
626
+ var explorer_item = '<div class="explorer_item" ' +
627
  'name="' + name + '" ' +
 
628
  'filename="' + filename + '" ' +
629
  'filethumb="' + filethumb + '" ' +
630
  'filesize="' + filesize + '" ' +
filemanager/model.php CHANGED
@@ -9,421 +9,200 @@ $p_dir;
9
  $s_order;
10
 
11
  class FilemanagerModel {
12
- ////////////////////////////////////////////////////////////////////////////////////////
13
- // Events //
14
- ////////////////////////////////////////////////////////////////////////////////////////
15
- ////////////////////////////////////////////////////////////////////////////////////////
16
- // Constants //
17
- ////////////////////////////////////////////////////////////////////////////////////////
18
- ////////////////////////////////////////////////////////////////////////////////////////
19
- // Variables //
20
- ////////////////////////////////////////////////////////////////////////////////////////
21
- private $controller;
22
- private $element_load_count = 100;
23
- ////////////////////////////////////////////////////////////////////////////////////////
24
- // Constructor & Destructor //
25
- ////////////////////////////////////////////////////////////////////////////////////////
26
- public function __construct($controller) {
27
- $this->controller = $controller;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  }
29
-
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');
37
- $session_data['sort_order'] = $this->get_from_session('sort_order', 'desc');
38
- $session_data['items_view'] = $this->get_from_session('items_view', 'thumbs');
39
- $session_data['clipboard_task'] = $this->get_from_session('clipboard_task', '');
40
- $session_data['clipboard_files'] = $this->get_from_session('clipboard_files', '');
41
- $session_data['clipboard_src'] = $this->get_from_session('clipboard_src', '');
42
- $session_data['clipboard_dest'] = $this->get_from_session('clipboard_dest', '');
43
-
44
- $data = array();
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']);
49
- $data['files'] = $get_files_data['files'];
50
- $data['files_count'] = $get_files_data['files_count'];
51
- $data['all_files'] = $get_files_data['all_files'];
52
- $data['element_load_count'] = $this->element_load_count;
53
- $media_library_files = ($wd_bwg_options->enable_ML_import ? $this->get_media_library_files($session_data['sort_by'], $session_data['sort_order']) : array());
54
- if ( !empty($media_library_files) ) {
55
- $data['media_library_files'] = $media_library_files["files"];
56
- $data['importer_files_count'] = $media_library_files["importer_files_count"];
57
- $data['media_library_files_all'] = $media_library_files["media_library_files_all"];
58
- }
59
- else {
60
- $data['media_library_files'] = array();
61
- $data['importer_files_count'] = 0;
62
- $data['media_library_files_all'] = array();
63
- }
64
- $data['extensions'] = (isset($_REQUEST['extensions']) ? esc_html($_REQUEST['extensions']) : '');
65
- $data['callback'] = (isset($_REQUEST['callback']) ? esc_html($_REQUEST['callback']) : '');
66
- return $data;
67
  }
68
-
69
- ////////////////////////////////////////////////////////////////////////////////////////
70
- // Getters & Setters //
71
- ////////////////////////////////////////////////////////////////////////////////////////
72
- ////////////////////////////////////////////////////////////////////////////////////////
73
- // Private Methods //
74
- ////////////////////////////////////////////////////////////////////////////////////////
75
- private function get_from_session($key, $default) {
76
- if (isset($_REQUEST[$key])) {
77
- $_REQUEST[$key] = stripslashes($_REQUEST[$key]);
78
- }
79
- else {
80
- $_REQUEST[$key] = stripslashes($default);
 
 
 
 
81
  }
82
- return esc_html(stripslashes($_REQUEST[$key]));
83
- }
84
-
85
- public function get_path_components() {
86
- $dir_names = explode('/', (isset($_REQUEST['dir']) ? esc_html($_REQUEST['dir']) : ''));
87
- $path = '';
88
-
89
- $components = array();
90
  $component = array();
91
- global $WD_BWG_UPLOAD_DIR;
92
- $component['name'] = $WD_BWG_UPLOAD_DIR;
93
  $component['path'] = $path;
94
  $components[] = $component;
95
- for ($i = 0; $i < count($dir_names); $i++) {
96
- $dir_name = $dir_names[$i];
97
- if ($dir_name == '') {
98
- continue;
99
- }
100
- $path .= (($path == '') ? $dir_name : '/' . $dir_name);
101
- $component = array();
102
- $component['name'] = $dir_name;
103
- $component['path'] = $path;
104
- $components[] = $component;
105
- }
106
- return $components;
107
  }
108
-
109
- function get_files($sort_by, $sort_order) {
110
- $icons_dir_path = WD_BWG_DIR . '/filemanager/images/file_icons';
111
- $icons_dir_url = WD_BWG_URL . '/filemanager/images/file_icons';
112
- $valid_types = explode(',', isset($_REQUEST['extensions']) ? strtolower(esc_html($_REQUEST['extensions'])) : '*');
113
- $dir = (isset($_REQUEST['dir']) ? '/' . htmlspecialchars_decode(stripslashes(esc_html($_REQUEST['dir'])), ENT_COMPAT | ENT_QUOTES) : '');
114
- $parent_dir = $this->controller->get_uploads_dir() . $dir;
115
- $parent_dir_url = $this->controller->get_uploads_url() . $dir;
116
-
117
- $file_names = $this->get_sorted_file_names($parent_dir, $sort_by, $sort_order);
118
-
119
- $dirs = array();
120
- $files = array();
121
- foreach ($file_names as $file_name) {
122
- if (($file_name == '.') || ($file_name == '..') || ($file_name == 'thumb') || ($file_name == '.original')) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  continue;
124
  }
125
- if (is_dir($parent_dir . '/' . $file_name) == TRUE) {
126
- $file = array();
127
- $file['is_dir'] = TRUE;
128
- $file['name'] = $file_name;
129
- $file['filename'] = str_replace("_", " ", $file_name);
130
- $file['type'] = '';
131
- $file['thumb'] = $icons_dir_url . '/dir.png';
132
- $file['icon'] = $icons_dir_url . '/dir.png';
133
- $file['size'] = '';
134
- $file['date_modified'] = '';
135
- $file['resolution'] = '';
136
- $dirs[] = $file;
137
- }
138
- else {
139
- $file = array();
140
- $file['is_dir'] = FALSE;
141
- $file['name'] = $file_name;
142
- $filename = substr($file_name, 0, strrpos($file_name, '.'));
143
- $file['filename'] = str_replace("_", " ", $filename);
144
- $file_extension = explode('.', $file_name);
145
- $file['type'] = strtolower(end($file_extension));
146
- $icon = $icons_dir_url . '/' . $file['type'] . '.png';
147
- if (file_exists($icons_dir_path . '/' . $file['type'] . '.png') == FALSE) {
148
- $icon = $icons_dir_url . '/' . '_blank.png';
149
- }
150
- $file['thumb'] = $this->is_img($file['type']) ? $parent_dir_url . '/thumb/' . $file_name : $icon;
151
- $file['icon'] = $icon;
152
- if (($valid_types[0] != '*') && (in_array($file['type'], $valid_types) == FALSE)) {
153
- continue;
154
- }
155
- $file_size_kb = (int)(filesize($parent_dir . '/' . $file_name) / 1024);
156
- // $file_size_mb = (int)($file_size_kb / 1024);
157
- // $file['size'] = $file_size_kb < 1024 ? (string)$file_size_kb . 'KB' : (string)$file_size_mb . 'MB';
158
- $file['size'] = $file_size_kb . ' KB';
159
- $file['date_modified'] = date('d F Y, H:i', filemtime($parent_dir . '/' . $file_name));
160
- $image_info = getimagesize(htmlspecialchars_decode($parent_dir . '/' . $file_name, ENT_COMPAT | ENT_QUOTES));
161
- $file['resolution'] = $this->is_img($file['type']) ? $image_info[0] . ' x ' . $image_info[1] . ' px' : '';
162
- $exif = $this->bwg_wp_read_image_metadata( $parent_dir . '/.original/' . $file_name );
163
- $file['credit'] = $exif['credit'];
164
- $file['aperture'] = $exif['aperture'];
165
- $file['camera'] = $exif['camera'];
166
- $file['caption'] = $exif['caption'];
167
- $file['iso'] = $exif['iso'];
168
- $file['orientation'] = $exif['orientation'];
169
- $file['copyright'] = $exif['copyright'];
170
- $files[] = $file;
171
- }
172
  }
173
-
174
- // $result = $sort_order == 'asc' ? array_merge($dirs, $files) : array_merge($files, $dirs);
175
- $result = array_merge($dirs, $files);
176
- $files_count = count($result);
177
- $all_files = $result;
178
- $result = array_slice($result, 0, $this->element_load_count, true);
179
- return array("files" => $result, "all_files"=>$all_files, "files_count" => $files_count);
180
  }
181
 
182
- function get_media_library_files($sort_by, $sort_order) {
183
- $icons_dir_path = WD_BWG_DIR . '/filemanager/images/file_icons';
184
- $icons_dir_url = WD_BWG_URL . '/filemanager/images/file_icons';
185
- $valid_types = explode(',', isset($_REQUEST['extensions']) ? strtolower(esc_html($_REQUEST['extensions'])) : '*');
186
- $upload_dir = wp_upload_dir();
187
- $parent_dir = $upload_dir['basedir'];
188
- $parent_dir_url = $upload_dir['baseurl'];
189
-
190
- $query_images_args = array(
191
- 'post_type' => 'attachment', 'post_mime_type' =>'image', 'post_status' => 'inherit', 'posts_per_page' => -1,
192
- );
193
- $query_images = new WP_Query( $query_images_args );
194
 
195
- $files = array();
196
- $upload_dir = wp_upload_dir();
197
 
198
- foreach ($query_images->posts as $image) {
199
- $file_meta = wp_get_attachment_metadata($image->ID);
200
- if (isset($file_meta['file'])) {
201
- $file = array();
202
- $file['is_dir'] = FALSE;
203
- $file_name_array = explode('/', $file_meta['file']);
204
- $file_name = end($file_name_array);
205
- $file['name'] = $file_name;
206
- $file['path'] = $file_meta['file'];
207
- $file['filename'] = substr($file_name, 0, strrpos($file_name, '.'));
208
- $file_type_array = explode('.', $file_name);
209
- $file['type'] = strtolower(end($file_type_array));
210
- // $file['thumb'] = wp_get_attachment_thumb_url($image->ID);
211
- if (!empty($file_meta['sizes']) && $file_meta['sizes']['thumbnail']['file']) {
212
- $file_pos = strrpos($file_meta['file'], '/');
213
- $sub_folder = substr($file_meta['file'], 0, $file_pos);
214
- $file['thumb'] = $upload_dir['baseurl'] . '/' . $sub_folder . '/' . $file_meta['sizes']['thumbnail']['file'];
215
- }
216
- else {
217
- $file['thumb'] = $upload_dir['baseurl'] . '/' . $file_meta['file'];
218
- }
219
- $file['icon'] = $file['thumb'];
220
- if (($valid_types[0] != '*') && (in_array($file['type'], $valid_types) == FALSE)) {
221
- continue;
222
- }
223
- $file_size_kb = (int)(@filesize($parent_dir . '/' . $file_meta['file']) / 1024);
224
- if (!$file_size_kb) continue;
225
- $file['size'] = $file_size_kb . ' KB';
226
- $file['date_modified'] = date('d F Y, H:i', filemtime($parent_dir . '/' . $file_meta['file']));
227
- // $image_info = getimagesize(htmlspecialchars_decode($parent_dir . '/' . $file_meta['file'], ENT_COMPAT | ENT_QUOTES));
228
- $file['resolution'] = $this->is_img($file['type']) ? $file_meta['width'] . ' x ' . $file_meta['height'] . ' px' : '';
229
- $exif = $this->bwg_wp_read_image_metadata($parent_dir . '/.original/' . $file_name);
230
- $file['credit'] = $exif['credit'];
231
- $file['aperture'] = $exif['aperture'];
232
- $file['camera'] = $exif['camera'];
233
- $file['caption'] = $exif['caption'];
234
- $file['iso'] = $exif['iso'];
235
- $file['orientation'] = $exif['orientation'];
236
- $file['copyright'] = $exif['copyright'];
237
- $files[] = $file;
238
- }
239
- }
240
- $files_count = count($files);
241
- $all_files = $files;
242
- $files = array_slice($files, 0, $this->element_load_count, true);
243
- return array("files" => $files, 'media_library_files_all' => $all_files, "importer_files_count" => $files_count);
244
- }
245
-
246
- private function bwg_wp_read_image_metadata( $file ) {
247
- if (!file_exists($file)) {
248
- return false;
249
- }
250
- list( , , $sourceImageType ) = getimagesize($file);
251
- $meta = array(
252
- 'aperture' => 0,
253
- 'credit' => '',
254
- 'camera' => '',
255
- 'caption' => '',
256
- 'created_timestamp' => 0,
257
- 'copyright' => '',
258
- 'focal_length' => 0,
259
- 'iso' => 0,
260
- 'shutter_speed' => 0,
261
- 'title' => '',
262
- 'orientation' => 0,
263
- );
264
- if ( is_callable( 'iptcparse' ) ) {
265
- getimagesize( $file, $info );
266
- if ( ! empty( $info['APP13'] ) ) {
267
- $iptc = iptcparse( $info['APP13'] );
268
- if ( ! empty( $iptc['2#105'][0] ) ) {
269
- $meta['title'] = trim( $iptc['2#105'][0] );
270
- } elseif ( ! empty( $iptc['2#005'][0] ) ) {
271
- $meta['title'] = trim( $iptc['2#005'][0] );
272
- }
273
- if ( ! empty( $iptc['2#120'][0] ) ) {
274
- $caption = trim( $iptc['2#120'][0] );
275
- if ( empty( $meta['title'] ) ) {
276
- mbstring_binary_safe_encoding();
277
- $caption_length = strlen( $caption );
278
- reset_mbstring_encoding();
279
- if ( $caption_length < 80 ) {
280
- $meta['title'] = $caption;
281
- } else {
282
- $meta['caption'] = $caption;
283
- }
284
- } elseif ( $caption != $meta['title'] ) {
285
- $meta['caption'] = $caption;
286
- }
287
- }
288
- if ( ! empty( $iptc['2#110'][0] ) ) {
289
- $meta['credit'] = trim( $iptc['2#110'][0] );
290
- }
291
- elseif ( ! empty( $iptc['2#080'][0] ) ) {
292
- $meta['credit'] = trim( $iptc['2#080'][0] );
293
- }
294
- if ( ! empty( $iptc['2#055'][0] ) and ! empty( $iptc['2#060'][0] ) ) {
295
- $meta['created_timestamp'] = strtotime( $iptc['2#055'][0] . ' ' . $iptc['2#060'][0] );
296
- }
297
- if ( ! empty( $iptc['2#116'][0] ) ) {
298
- $meta['copyright'] = trim( $iptc['2#116'][0] );
299
- }
300
- }
301
- }
302
- if ( is_callable( 'exif_read_data' ) && in_array( $sourceImageType, apply_filters( 'wp_read_image_metadata_types', array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) ) ) ) {
303
- $exif = @exif_read_data( $file );
304
- if ( empty( $meta['title'] ) && ! empty( $exif['Title'] ) ) {
305
- $meta['title'] = trim( $exif['Title'] );
306
- }
307
- if ( ! empty( $exif['ImageDescription'] ) ) {
308
- mbstring_binary_safe_encoding();
309
- $description_length = strlen( $exif['ImageDescription'] );
310
- reset_mbstring_encoding();
311
- if ( empty( $meta['title'] ) && $description_length < 80 ) {
312
- $meta['title'] = trim( $exif['ImageDescription'] );
313
- if ( empty( $meta['caption'] ) && ! empty( $exif['COMPUTED']['UserComment'] ) && trim( $exif['COMPUTED']['UserComment'] ) != $meta['title'] ) {
314
- $meta['caption'] = trim( $exif['COMPUTED']['UserComment'] );
315
- }
316
- } elseif ( empty( $meta['caption'] ) && trim( $exif['ImageDescription'] ) != $meta['title'] ) {
317
- $meta['caption'] = trim( $exif['ImageDescription'] );
318
- }
319
- } elseif ( empty( $meta['caption'] ) && ! empty( $exif['Comments'] ) && trim( $exif['Comments'] ) != $meta['title'] ) {
320
- $meta['caption'] = trim( $exif['Comments'] );
321
- }
322
- if ( empty( $meta['credit'] ) ) {
323
- if ( ! empty( $exif['Artist'] ) ) {
324
- $meta['credit'] = trim( $exif['Artist'] );
325
- } elseif ( ! empty($exif['Author'] ) ) {
326
- $meta['credit'] = trim( $exif['Author'] );
327
- }
328
- }
329
- if ( empty( $meta['copyright'] ) && ! empty( $exif['Copyright'] ) ) {
330
- $meta['copyright'] = trim( $exif['Copyright'] );
331
- }
332
- if ( ! empty( $exif['FNumber'] ) ) {
333
- $meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 );
334
- }
335
- if ( ! empty( $exif['Model'] ) ) {
336
- $meta['camera'] = trim( $exif['Model'] );
337
- }
338
- if ( empty( $meta['created_timestamp'] ) && ! empty( $exif['DateTimeDigitized'] ) ) {
339
- $meta['created_timestamp'] = wp_exif_date2ts( $exif['DateTimeDigitized'] );
340
- }
341
- if ( ! empty( $exif['FocalLength'] ) ) {
342
- $meta['focal_length'] = (string) wp_exif_frac2dec( $exif['FocalLength'] );
343
- }
344
- if ( ! empty( $exif['ISOSpeedRatings'] ) ) {
345
- $meta['iso'] = is_array( $exif['ISOSpeedRatings'] ) ? reset( $exif['ISOSpeedRatings'] ) : $exif['ISOSpeedRatings'];
346
- $meta['iso'] = trim( $meta['iso'] );
347
- }
348
- if ( ! empty( $exif['ExposureTime'] ) ) {
349
- $meta['shutter_speed'] = (string) wp_exif_frac2dec( $exif['ExposureTime'] );
350
- }
351
- if ( ! empty( $exif['Orientation'] ) ) {
352
- $meta['orientation'] = $exif['Orientation'];
353
- }
354
- }
355
- foreach ( array( 'title', 'caption', 'credit', 'copyright', 'camera', 'iso' ) as $key ) {
356
- if ( $meta[ $key ] && ! seems_utf8( $meta[ $key ] ) ) {
357
- $meta[ $key ] = utf8_encode( $meta[ $key ] );
358
- }
359
- }
360
- foreach ( $meta as &$value ) {
361
- if ( is_string( $value ) ) {
362
- $value = wp_kses_post( $value );
363
- }
364
- }
365
- return $meta;
366
- }
367
 
368
- private function get_sorted_file_names($parent_dir, $sort_by, $sort_order) {
369
- $file_names = scandir($parent_dir);
370
 
 
371
  global $p_dir;
372
  global $s_order;
373
 
374
- $p_dir = $parent_dir;
375
- $s_order = $sort_order;
376
-
377
- function sort_by_size ($a, $b) {
378
- global $p_dir;
379
- global $s_order;
380
-
381
- $size_of_a = filesize($p_dir . '/' . $a);
382
- $size_of_b = filesize($p_dir . '/' . $b);
383
- return $s_order == 'asc' ? $size_of_a > $size_of_b : $size_of_a < $size_of_b;
384
- }
385
-
386
- function sort_by_date($a, $b) {
387
- global $p_dir;
388
- global $s_order;
389
 
390
- $m_time_a = filemtime($p_dir . '/' . $a);
391
- $m_time_b = filemtime($p_dir . '/' . $b);
392
- return $s_order == 'asc' ? $m_time_a > $m_time_b : $m_time_a < $m_time_b;
393
- }
394
 
395
- switch ($sort_by) {
396
- case 'name':
397
- natcasesort($file_names);
398
- if ($sort_order == 'desc') {
399
- $file_names = array_reverse($file_names);
400
- }
401
- break;
402
- case 'size':
403
- usort($file_names, 'sort_by_size');
404
- break;
405
- case 'date_modified':
406
- usort($file_names, 'sort_by_date');
407
- break;
408
- }
409
- return $file_names;
410
  }
411
 
412
- private function is_img($file_type) {
413
- switch ($file_type) {
414
- case 'jpg':
415
- case 'jpeg':
416
- case 'png':
417
- case 'bmp':
418
- case 'gif':
419
- return true;
420
- break;
421
- }
422
- return false;
 
 
423
  }
424
-
425
-
426
- ////////////////////////////////////////////////////////////////////////////////////////
427
- // Listeners //
428
- ////////////////////////////////////////////////////////////////////////////////////////
429
- }
 
 
 
 
 
 
 
 
 
 
9
  $s_order;
10
 
11
  class FilemanagerModel {
12
+ private $controller;
13
+ private $element_load_count = 100;
14
+
15
+ public function __construct($controller) {
16
+ $this->controller = $controller;
17
+ }
18
+
19
+ public function get_file_manager_data() {
20
+ $session_data = array();
21
+ $session_data['sort_by'] = $this->get_from_session('sort_by', 'date_modified');
22
+ $session_data['sort_order'] = $this->get_from_session('sort_order', 'desc');
23
+ $session_data['items_view'] = $this->get_from_session('items_view', 'thumbs');
24
+ $session_data['clipboard_task'] = $this->get_from_session('clipboard_task', '');
25
+ $session_data['clipboard_files'] = $this->get_from_session('clipboard_files', '');
26
+ $session_data['clipboard_src'] = $this->get_from_session('clipboard_src', '');
27
+ $session_data['clipboard_dest'] = $this->get_from_session('clipboard_dest', '');
28
+
29
+ $data = array();
30
+ $data['session_data'] = $session_data;
31
+ $data['path_components'] = $this->get_path_components();
32
+ $data['dir'] = $this->controller->get_uploads_dir() . (isset($_REQUEST['dir']) ? esc_html($_REQUEST['dir']) : '');
33
+ $get_files_data = $this->get_files($session_data['sort_by'], $session_data['sort_order']);
34
+ $data['files'] = $get_files_data['files'];
35
+ $data['files_count'] = $get_files_data['files_count'];
36
+ $data['all_files'] = $get_files_data['all_files'];
37
+ $data['element_load_count'] = $this->element_load_count;
38
+ $data['extensions'] = (isset($_REQUEST['extensions']) ? esc_html($_REQUEST['extensions']) : '');
39
+ $data['callback'] = (isset($_REQUEST['callback']) ? esc_html($_REQUEST['callback']) : '');
40
+ return $data;
41
+ }
42
+
43
+ private function get_from_session($key, $default) {
44
+ if (isset($_REQUEST[$key])) {
45
+ $_REQUEST[$key] = stripslashes($_REQUEST[$key]);
46
  }
47
+ else {
48
+ $_REQUEST[$key] = stripslashes($default);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
+ return esc_html(stripslashes($_REQUEST[$key]));
51
+ }
52
+
53
+ public function get_path_components() {
54
+ $dir_names = explode('/', (isset($_REQUEST['dir']) ? esc_html($_REQUEST['dir']) : ''));
55
+ $path = '';
56
+
57
+ $components = array();
58
+ $component = array();
59
+ global $WD_BWG_UPLOAD_DIR;
60
+ $component['name'] = $WD_BWG_UPLOAD_DIR;
61
+ $component['path'] = $path;
62
+ $components[] = $component;
63
+ for ($i = 0; $i < count($dir_names); $i++) {
64
+ $dir_name = $dir_names[$i];
65
+ if ($dir_name == '') {
66
+ continue;
67
  }
68
+ $path .= (($path == '') ? $dir_name : '/' . $dir_name);
 
 
 
 
 
 
 
69
  $component = array();
70
+ $component['name'] = $dir_name;
 
71
  $component['path'] = $path;
72
  $components[] = $component;
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
+ return $components;
75
+ }
76
+
77
+ function get_files($sort_by, $sort_order) {
78
+ $icons_dir_path = WD_BWG_DIR . '/filemanager/images/file_icons';
79
+ $icons_dir_url = WD_BWG_URL . '/filemanager/images/file_icons';
80
+ $valid_types = explode(',', isset($_REQUEST['extensions']) ? strtolower(esc_html($_REQUEST['extensions'])) : '*');
81
+ $dir = (isset($_REQUEST['dir']) ? '/' . htmlspecialchars_decode(stripslashes(esc_html($_REQUEST['dir'])), ENT_COMPAT | ENT_QUOTES) : '');
82
+ $parent_dir = $this->controller->get_uploads_dir() . $dir;
83
+ $parent_dir_url = $this->controller->get_uploads_url() . $dir;
84
+
85
+ $file_names = $this->get_sorted_file_names($parent_dir, $sort_by, $sort_order);
86
+
87
+ $dirs = array();
88
+ $files = array();
89
+ foreach ($file_names as $file_name) {
90
+ if (($file_name == '.') || ($file_name == '..') || ($file_name == 'thumb') || ($file_name == '.original')) {
91
+ continue;
92
+ }
93
+ if (is_dir($parent_dir . '/' . $file_name) == TRUE) {
94
+ $file = array();
95
+ $file['is_dir'] = TRUE;
96
+ $file['name'] = $file_name;
97
+ $file['alt'] = str_replace("_", " ", $file_name);
98
+ $file['filename'] = str_replace("_", " ", $file_name);
99
+ $file['type'] = '';
100
+ $file['thumb'] = $icons_dir_url . '/dir.png';
101
+ $file['icon'] = $icons_dir_url . '/dir.png';
102
+ $file['size'] = '';
103
+ $file['date_modified'] = '';
104
+ $file['resolution'] = '';
105
+ $dirs[] = $file;
106
+ }
107
+ else {
108
+ $file = array();
109
+ $file['is_dir'] = FALSE;
110
+ $file['name'] = $file_name;
111
+ $filename = substr($file_name, 0, strrpos($file_name, '.'));
112
+ $file['alt'] = str_replace("_", " ", $filename);
113
+ $file['filename'] = str_replace("_", " ", $filename);
114
+ $file_extension = explode('.', $file_name);
115
+ $file['type'] = strtolower(end($file_extension));
116
+ $icon = $icons_dir_url . '/' . $file['type'] . '.png';
117
+ if (file_exists($icons_dir_path . '/' . $file['type'] . '.png') == FALSE) {
118
+ $icon = $icons_dir_url . '/' . '_blank.png';
119
+ }
120
+ $file['thumb'] = $this->is_img($file['type']) ? $parent_dir_url . '/thumb/' . $file_name : $icon;
121
+ $file['icon'] = $icon;
122
+ if (($valid_types[0] != '*') && (in_array($file['type'], $valid_types) == FALSE)) {
123
  continue;
124
  }
125
+ $file_size_kb = (int)(filesize($parent_dir . '/' . $file_name) / 1024);
126
+ // $file_size_mb = (int)($file_size_kb / 1024);
127
+ // $file['size'] = $file_size_kb < 1024 ? (string)$file_size_kb . 'KB' : (string)$file_size_mb . 'MB';
128
+ $file['size'] = $file_size_kb . ' KB';
129
+ $file['date_modified'] = date('d F Y, H:i', filemtime($parent_dir . '/' . $file_name));
130
+ $image_info = getimagesize(htmlspecialchars_decode($parent_dir . '/' . $file_name, ENT_COMPAT | ENT_QUOTES));
131
+ $file['resolution'] = $this->is_img($file['type']) ? $image_info[0] . ' x ' . $image_info[1] . ' px' : '';
132
+ $exif = WDWLibrary::read_image_metadata( $parent_dir . '/.original/' . $file_name );
133
+ $file['credit'] = $exif['credit'];
134
+ $file['aperture'] = $exif['aperture'];
135
+ $file['camera'] = $exif['camera'];
136
+ $file['caption'] = $exif['caption'];
137
+ $file['iso'] = $exif['iso'];
138
+ $file['orientation'] = $exif['orientation'];
139
+ $file['copyright'] = $exif['copyright'];
140
+ $files[] = $file;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  }
 
 
 
 
 
 
 
142
  }
143
 
144
+ // $result = $sort_order == 'asc' ? array_merge($dirs, $files) : array_merge($files, $dirs);
145
+ $result = array_merge($dirs, $files);
146
+ $files_count = count($result);
147
+ $all_files = $result;
148
+ $result = array_slice($result, 0, $this->element_load_count, true);
149
+ return array("files" => $result, "all_files"=>$all_files, "files_count" => $files_count);
150
+ }
 
 
 
 
 
151
 
152
+ private function get_sorted_file_names($parent_dir, $sort_by, $sort_order) {
153
+ $file_names = scandir($parent_dir);
154
 
155
+ global $p_dir;
156
+ global $s_order;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
+ $p_dir = $parent_dir;
159
+ $s_order = $sort_order;
160
 
161
+ function sort_by_size ($a, $b) {
162
  global $p_dir;
163
  global $s_order;
164
 
165
+ $size_of_a = filesize($p_dir . '/' . $a);
166
+ $size_of_b = filesize($p_dir . '/' . $b);
167
+ return $s_order == 'asc' ? $size_of_a > $size_of_b : $size_of_a < $size_of_b;
168
+ }
 
 
 
 
 
 
 
 
 
 
 
169
 
170
+ function sort_by_date($a, $b) {
171
+ global $p_dir;
172
+ global $s_order;
 
173
 
174
+ $m_time_a = filemtime($p_dir . '/' . $a);
175
+ $m_time_b = filemtime($p_dir . '/' . $b);
176
+ return $s_order == 'asc' ? $m_time_a > $m_time_b : $m_time_a < $m_time_b;
 
 
 
 
 
 
 
 
 
 
 
 
177
  }
178
 
179
+ switch ($sort_by) {
180
+ case 'name':
181
+ natcasesort($file_names);
182
+ if ($sort_order == 'desc') {
183
+ $file_names = array_reverse($file_names);
184
+ }
185
+ break;
186
+ case 'size':
187
+ usort($file_names, 'sort_by_size');
188
+ break;
189
+ case 'date_modified':
190
+ usort($file_names, 'sort_by_date');
191
+ break;
192
  }
193
+ return $file_names;
194
+ }
195
+
196
+ private function is_img($file_type) {
197
+ switch ($file_type) {
198
+ case 'jpg':
199
+ case 'jpeg':
200
+ case 'png':
201
+ case 'bmp':
202
+ case 'gif':
203
+ return true;
204
+ break;
205
+ }
206
+ return false;
207
+ }
208
+ }
filemanager/view.php CHANGED
@@ -83,7 +83,6 @@ class FilemanagerView {
83
  var sortBy = "<?php echo $sort_by; ?>";
84
  var sortOrder = "<?php echo $sort_order; ?>";
85
  var wdb_all_files = <?php echo isset($file_manager_data["all_files"]) && json_encode($file_manager_data["all_files"]) ? json_encode($file_manager_data["all_files"]) : "''"; ?>;
86
- var media_library_files = <?php echo isset($file_manager_data["media_library_files_all"]) && json_encode($file_manager_data["media_library_files_all"]) ? json_encode($file_manager_data["media_library_files_all"]) : "''"; ?>;
87
  var element_load_count = <?php echo isset($file_manager_data["element_load_count"]) && json_encode($file_manager_data["element_load_count"]) ? json_encode($file_manager_data["element_load_count"]) : "''"; ?>;
88
  </script>
89
  <script src="<?php echo WD_BWG_URL; ?>/filemanager/js/default.js?ver=<?php echo wd_bwg_version(); ?>"></script>
@@ -125,12 +124,6 @@ class FilemanagerView {
125
  <span class="ctrl_bar_btn">
126
  <a id="upload_images" class="ctrl_bar_btn wd-btn wd-btn-primary wd-btn-icon wd-btn-uplaod" onclick="onBtnShowUploaderClick(event, this);"><?php echo __('Upload files', 'bwg_back'); ?></a>
127
  </span>
128
- <?php if ($wd_bwg_options->enable_ML_import) { ?>
129
- <span class="ctrl_bar_divider"></span>
130
- <span class="ctrl_bar_btn">
131
- <a class="ctrl_bar_btn wd-btn wd-btn-primary wd-btn-icon btn_import_files" onclick="onBtnShowImportClick(event, this);"><?php echo __('Media library', 'bwg_back'); ?></a>
132
- </span>
133
- <?php } ?>
134
  <span class="ctrl_bar_divider"></span>
135
  <span id="search_by_name" class="ctrl_bar_btn">
136
  <input type="search" placeholder="Search" class="ctrl_bar_btn search_by_name">
@@ -211,6 +204,7 @@ class FilemanagerView {
211
  <div class="explorer_item" draggable="true"
212
  name="<?php echo $file['name']; ?>"
213
  filename="<?php echo $file['filename']; ?>"
 
214
  filethumb="<?php echo $file['thumb']; ?>"
215
  filesize="<?php echo $file['size']; ?>"
216
  filetype="<?php echo strtoupper($file['type']); ?>"
@@ -276,89 +270,6 @@ class FilemanagerView {
276
  </div>
277
  </div>
278
  </div>
279
- <div id="importer" style="display: none;">
280
- <div id="importer_bg"></div>
281
- <div class="ctrls_bar ctrls_bar_header">
282
- <div class="ctrls_left upload_thumb">
283
- <?php echo __("Thumbnail Maximum Dimensions:", 'bwg_back'); ?>
284
- <input type="text" class="upload_thumb_dim" name="importer_thumb_width" id="importer_thumb_width" value="<?php echo $wd_bwg_options->upload_thumb_width; ?>" /> x
285
- <input type="text" class="upload_thumb_dim" name="importer_thumb_height" id="importer_thumb_height" value="<?php echo $wd_bwg_options->upload_thumb_height; ?>" /> px
286
- </div>
287
- <div class="ctrls_right">
288
- <a class="ctrl_bar_btn btn_back" onclick="onBtnBackClick(event, this);" title="<?php echo __('Back', 'bwg_back'); ?>"></a>
289
- </div>
290
- <div class="ctrls_right_img upload_thumb">
291
- <?php echo __("Image Maximum Dimensions:", 'bwg_back'); ?>
292
- <input type="text" class="upload_thumb_dim" name="importer_img_width" id="importer_img_width" value="<?php echo $wd_bwg_options->upload_img_width; ?>" /> x
293
- <input type="text" class="upload_thumb_dim" name="importer_img_height" id="importer_img_height" value="<?php echo $wd_bwg_options->upload_img_height; ?>" /> px
294
- </div>
295
- </div>
296
- <div id="importer_body_wrapper">
297
- <div id="importer_body_container">
298
- <div id="importer_body" data-files_count="<?php echo $file_manager_data['importer_files_count'];?>">
299
- <?php
300
- foreach ($file_manager_data['media_library_files'] as $key => $file) {
301
- $file['name'] = esc_html($file['name']);
302
- $file['filename'] = esc_html($file['filename']);
303
- $file['thumb'] = esc_html($file['thumb']);
304
- ?>
305
- <div class="importer_item" draggable="true"
306
- name="<?php echo $file['name']; ?>"
307
- path="<?php echo $file['path']; ?>"
308
- filename="<?php echo $file['filename']; ?>"
309
- filethumb="<?php echo $file['thumb']; ?>"
310
- filesize="<?php echo $file['size']; ?>"
311
- filetype="<?php echo strtoupper($file['type']); ?>"
312
- date_modified="<?php echo $file['date_modified']; ?>"
313
- fileresolution="<?php echo $file['resolution']; ?>"
314
- fileCredit="<?php echo $file['credit']; ?>"
315
- fileAperture="<?php echo $file['aperture']; ?>"
316
- fileCamera="<?php echo $file['camera']; ?>"
317
- fileCaption="<?php echo $file['caption']; ?>"
318
- fileIso="<?php echo $file['iso']; ?>"
319
- fileOrientation="<?php echo $file['orientation']; ?>"
320
- fileCopyright="<?php echo $file['copyright']; ?>"
321
- onmouseover="onFileMOverML(event, this);"
322
- onmouseout="onFileMOutML(event, this);"
323
- onclick="onFileClickML(event, this);"
324
- ondblclick="onFileDblClickML(event, this);"
325
- isDir="<?php echo $file['is_dir'] == true ? 'true' : 'false'; ?>">
326
- <span class="item_numbering"><?php echo ++$i; ?></span>
327
- <span class="item_thumb">
328
- <img src="<?php echo $file['thumb']; ?>" <?php echo $key >= 24 ? 'onload="loaded()"' : ''; ?> />
329
- </span>
330
- <span class="item_icon">
331
- <img src="<?php echo $file['icon']; ?>"/>
332
- </span>
333
- <span class="item_name">
334
- <?php echo $file['name']; ?>
335
- </span>
336
- <span class="item_size">
337
- <?php echo $file['size']; ?>
338
- </span>
339
- <span class="item_date_modified">
340
- <?php echo $file['date_modified']; ?>
341
- </span>
342
- </div>
343
- <?php
344
- }
345
- ?>
346
- </div>
347
- </div>
348
- </div>
349
- <div class="ctrls_bar ctrls_bar_footer">
350
- <div class="ctrls_left">
351
- <a class="ctrl_bar_btn wd-btn wd-btn-primary wd-not-image none_select" onclick="onBtnSelectAllMediLibraryClick();"><?php echo __('Select All','bwg_back'); ?></a>
352
- </div>
353
- <div class="ctrls_right">
354
- <span id="file_names_span">
355
- <span>
356
- </span>
357
- </span>
358
- <a class="ctrl_bar_btn btn_open wd-btn wd-btn-primary wd-not-image none_select" onclick="onBtnImportClick(event, this);"><?php echo __("Import selected images", 'bwg_back'); ?></a>
359
- </div>
360
- </div>
361
- </div>
362
  <div id="uploader">
363
  <div id="uploader_bg"></div>
364
  <div class="ctrls_bar ctrls_bar_header">
83
  var sortBy = "<?php echo $sort_by; ?>";
84
  var sortOrder = "<?php echo $sort_order; ?>";
85
  var wdb_all_files = <?php echo isset($file_manager_data["all_files"]) && json_encode($file_manager_data["all_files"]) ? json_encode($file_manager_data["all_files"]) : "''"; ?>;
 
86
  var element_load_count = <?php echo isset($file_manager_data["element_load_count"]) && json_encode($file_manager_data["element_load_count"]) ? json_encode($file_manager_data["element_load_count"]) : "''"; ?>;
87
  </script>
88
  <script src="<?php echo WD_BWG_URL; ?>/filemanager/js/default.js?ver=<?php echo wd_bwg_version(); ?>"></script>
124
  <span class="ctrl_bar_btn">
125
  <a id="upload_images" class="ctrl_bar_btn wd-btn wd-btn-primary wd-btn-icon wd-btn-uplaod" onclick="onBtnShowUploaderClick(event, this);"><?php echo __('Upload files', 'bwg_back'); ?></a>
126
  </span>
 
 
 
 
 
 
127
  <span class="ctrl_bar_divider"></span>
128
  <span id="search_by_name" class="ctrl_bar_btn">
129
  <input type="search" placeholder="Search" class="ctrl_bar_btn search_by_name">
204
  <div class="explorer_item" draggable="true"
205
  name="<?php echo $file['name']; ?>"
206
  filename="<?php echo $file['filename']; ?>"
207
+ alt="<?php echo $file['alt']; ?>"
208
  filethumb="<?php echo $file['thumb']; ?>"
209
  filesize="<?php echo $file['size']; ?>"
210
  filetype="<?php echo strtoupper($file['type']); ?>"
270
  </div>
271
  </div>
272
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
  <div id="uploader">
274
  <div id="uploader_bg"></div>
275
  <div class="ctrls_bar ctrls_bar_header">
framework/BWGOptions.php CHANGED
@@ -37,6 +37,7 @@ class WD_BWG_Options {
37
  public $blog_style_title_enable = 1;
38
  public $blog_style_images_per_page = 5;
39
  public $blog_style_enable_page = 1;
 
40
 
41
  public $slideshow_type = 'fade';
42
  public $slideshow_interval = 5;
@@ -116,7 +117,6 @@ class WD_BWG_Options {
116
  public $comment_moderation = 0;
117
  public $popup_info_always_show = 0;
118
  public $popup_hit_counter = 0;
119
- public $enable_ML_import = 0;
120
  public $showthumbs_name = 0;
121
  public $show_album_name = 0;
122
  public $show_image_counts = 0;
@@ -191,7 +191,7 @@ class WD_BWG_Options {
191
  if ($this->permissions != 'moderate_comments' && $this->permissions != 'publish_posts' && $this->permissions != 'edit_posts') {
192
  $this->permissions = 'manage_options';
193
  }
194
- $this->jpeg_quality = $this->image_quality;
195
  $this->png_quality = 9 - round(9 * $this->image_quality / 100);
196
  }
197
 
37
  public $blog_style_title_enable = 1;
38
  public $blog_style_images_per_page = 5;
39
  public $blog_style_enable_page = 1;
40
+ public $blog_style_description_enable = 0;
41
 
42
  public $slideshow_type = 'fade';
43
  public $slideshow_interval = 5;
117
  public $comment_moderation = 0;
118
  public $popup_info_always_show = 0;
119
  public $popup_hit_counter = 0;
 
120
  public $showthumbs_name = 0;
121
  public $show_album_name = 0;
122
  public $show_image_counts = 0;
191
  if ($this->permissions != 'moderate_comments' && $this->permissions != 'publish_posts' && $this->permissions != 'edit_posts') {
192
  $this->permissions = 'manage_options';
193
  }
194
+ $this->jpeg_quality = $this->image_quality;
195
  $this->png_quality = 9 - round(9 * $this->image_quality / 100);
196
  }
197
 
framework/WDWLibrary.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
 
3
  class WDWLibrary {
4
-
5
  public static function get($key, $default_value = '') {
6
  if (isset($_GET[$key])) {
7
  $value = $_GET[$key];
@@ -644,7 +643,7 @@ class WDWLibrary {
644
  }
645
 
646
  public static function ajax_html_frontend_search_box($form_id, $current_view, $cur_gal_id, $images_count, $search_box_width = 180, $placeholder = '') {
647
- $bwg_search = ((isset($_POST['bwg_search_' . $current_view]) && esc_html($_POST['bwg_search_' . $current_view]) != '') ? esc_html($_POST['bwg_search_' . $current_view]) : '');
648
  $type = (isset($_POST['type_' . $current_view]) ? esc_html($_POST['type_' . $current_view]) : 'album');
649
  $album_gallery_id = (isset($_POST['album_gallery_id_' . $current_view]) ? esc_html($_POST['album_gallery_id_' . $current_view]) : 0);
650
  ob_start();
@@ -1222,7 +1221,7 @@ class WDWLibrary {
1222
  else {
1223
  return false;
1224
  }
1225
-
1226
  $watermark_image_resized = imagecreatetruecolor($watermark_width, $watermark_height);
1227
  imagecolorallocatealpha($watermark_image_resized, 255, 255, 255, 127);
1228
  imagealphablending($watermark_image_resized, FALSE);
@@ -1233,7 +1232,7 @@ class WDWLibrary {
1233
  $image = imagecreatefromjpeg($original_filename);
1234
  imagecopy($image, $watermark_image_resized, $left, $top, 0, 0, $watermark_width, $watermark_height);
1235
  if ($dest_filename <> '') {
1236
- imagejpeg ($image, $dest_filename, $wd_bwg_options->jpeg_quality);
1237
  } else {
1238
  header('Content-Type: image/jpeg');
1239
  imagejpeg($image, null, $wd_bwg_options->jpeg_quality);
@@ -1373,11 +1372,133 @@ class WDWLibrary {
1373
  "height" => ($max_y - $min_y)
1374
  );
1375
  }
1376
-
1377
- ////////////////////////////////////////////////////////////////////////////////////////
1378
- // Private Methods //
1379
- ////////////////////////////////////////////////////////////////////////////////////////
1380
- ////////////////////////////////////////////////////////////////////////////////////////
1381
- // Listeners //
1382
- ////////////////////////////////////////////////////////////////////////////////////////
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1383
  }
1
  <?php
2
 
3
  class WDWLibrary {
 
4
  public static function get($key, $default_value = '') {
5
  if (isset($_GET[$key])) {
6
  $value = $_GET[$key];
643
  }
644
 
645
  public static function ajax_html_frontend_search_box($form_id, $current_view, $cur_gal_id, $images_count, $search_box_width = 180, $placeholder = '') {
646
+ $bwg_search = ((isset($_POST['bwg_search_' . $current_view]) && esc_html($_POST['bwg_search_' . $current_view]) != '') ? esc_html($_POST['bwg_search_' . $current_view]) : '');
647
  $type = (isset($_POST['type_' . $current_view]) ? esc_html($_POST['type_' . $current_view]) : 'album');
648
  $album_gallery_id = (isset($_POST['album_gallery_id_' . $current_view]) ? esc_html($_POST['album_gallery_id_' . $current_view]) : 0);
649
  ob_start();
1221
  else {
1222
  return false;
1223
  }
1224
+
1225
  $watermark_image_resized = imagecreatetruecolor($watermark_width, $watermark_height);
1226
  imagecolorallocatealpha($watermark_image_resized, 255, 255, 255, 127);
1227
  imagealphablending($watermark_image_resized, FALSE);
1232
  $image = imagecreatefromjpeg($original_filename);
1233
  imagecopy($image, $watermark_image_resized, $left, $top, 0, 0, $watermark_width, $watermark_height);
1234
  if ($dest_filename <> '') {
1235
+ imagejpeg ($image, $dest_filename, $wd_bwg_options->jpeg_quality);
1236
  } else {
1237
  header('Content-Type: image/jpeg');
1238
  imagejpeg($image, null, $wd_bwg_options->jpeg_quality);
1372
  "height" => ($max_y - $min_y)
1373
  );
1374
  }
1375
+
1376
+ /**
1377
+ * Return given file metadata.
1378
+ *
1379
+ * @param $file
1380
+ *
1381
+ * @return array|bool
1382
+ */
1383
+ public static function read_image_metadata( $file ) {
1384
+ if (!file_exists($file)) {
1385
+ return false;
1386
+ }
1387
+ list( , , $sourceImageType ) = getimagesize($file);
1388
+ $meta = array(
1389
+ 'aperture' => 0,
1390
+ 'credit' => '',
1391
+ 'camera' => '',
1392
+ 'caption' => '',
1393
+ 'created_timestamp' => 0,
1394
+ 'copyright' => '',
1395
+ 'focal_length' => 0,
1396
+ 'iso' => 0,
1397
+ 'shutter_speed' => 0,
1398
+ 'title' => '',
1399
+ 'orientation' => 0,
1400
+ );
1401
+ if ( is_callable( 'iptcparse' ) ) {
1402
+ getimagesize( $file, $info );
1403
+ if ( ! empty( $info['APP13'] ) ) {
1404
+ $iptc = iptcparse( $info['APP13'] );
1405
+ if ( ! empty( $iptc['2#105'][0] ) ) {
1406
+ $meta['title'] = trim( $iptc['2#105'][0] );
1407
+ } elseif ( ! empty( $iptc['2#005'][0] ) ) {
1408
+ $meta['title'] = trim( $iptc['2#005'][0] );
1409
+ }
1410
+ if ( ! empty( $iptc['2#120'][0] ) ) {
1411
+ $caption = trim( $iptc['2#120'][0] );
1412
+ if ( empty( $meta['title'] ) ) {
1413
+ mbstring_binary_safe_encoding();
1414
+ $caption_length = strlen( $caption );
1415
+ reset_mbstring_encoding();
1416
+ if ( $caption_length < 80 ) {
1417
+ $meta['title'] = $caption;
1418
+ } else {
1419
+ $meta['caption'] = $caption;
1420
+ }
1421
+ } elseif ( $caption != $meta['title'] ) {
1422
+ $meta['caption'] = $caption;
1423
+ }
1424
+ }
1425
+ if ( ! empty( $iptc['2#110'][0] ) ) {
1426
+ $meta['credit'] = trim( $iptc['2#110'][0] );
1427
+ }
1428
+ elseif ( ! empty( $iptc['2#080'][0] ) ) {
1429
+ $meta['credit'] = trim( $iptc['2#080'][0] );
1430
+ }
1431
+ if ( ! empty( $iptc['2#055'][0] ) and ! empty( $iptc['2#060'][0] ) ) {
1432
+ $meta['created_timestamp'] = strtotime( $iptc['2#055'][0] . ' ' . $iptc['2#060'][0] );
1433
+ }
1434
+ if ( ! empty( $iptc['2#116'][0] ) ) {
1435
+ $meta['copyright'] = trim( $iptc['2#116'][0] );
1436
+ }
1437
+ }
1438
+ }
1439
+ if ( is_callable( 'exif_read_data' ) && in_array( $sourceImageType, apply_filters( 'wp_read_image_metadata_types', array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) ) ) ) {
1440
+ $exif = @exif_read_data( $file );
1441
+ if ( empty( $meta['title'] ) && ! empty( $exif['Title'] ) ) {
1442
+ $meta['title'] = trim( $exif['Title'] );
1443
+ }
1444
+ if ( ! empty( $exif['ImageDescription'] ) ) {
1445
+ mbstring_binary_safe_encoding();
1446
+ $description_length = strlen( $exif['ImageDescription'] );
1447
+ reset_mbstring_encoding();
1448
+ if ( empty( $meta['title'] ) && $description_length < 80 ) {
1449
+ $meta['title'] = trim( $exif['ImageDescription'] );
1450
+ if ( empty( $meta['caption'] ) && ! empty( $exif['COMPUTED']['UserComment'] ) && trim( $exif['COMPUTED']['UserComment'] ) != $meta['title'] ) {
1451
+ $meta['caption'] = trim( $exif['COMPUTED']['UserComment'] );
1452
+ }
1453
+ } elseif ( empty( $meta['caption'] ) && trim( $exif['ImageDescription'] ) != $meta['title'] ) {
1454
+ $meta['caption'] = trim( $exif['ImageDescription'] );
1455
+ }
1456
+ } elseif ( empty( $meta['caption'] ) && ! empty( $exif['Comments'] ) && trim( $exif['Comments'] ) != $meta['title'] ) {
1457
+ $meta['caption'] = trim( $exif['Comments'] );
1458
+ }
1459
+ if ( empty( $meta['credit'] ) ) {
1460
+ if ( ! empty( $exif['Artist'] ) ) {
1461
+ $meta['credit'] = trim( $exif['Artist'] );
1462
+ } elseif ( ! empty($exif['Author'] ) ) {
1463
+ $meta['credit'] = trim( $exif['Author'] );
1464
+ }
1465
+ }
1466
+ if ( empty( $meta['copyright'] ) && ! empty( $exif['Copyright'] ) ) {
1467
+ $meta['copyright'] = trim( $exif['Copyright'] );
1468
+ }
1469
+ if ( ! empty( $exif['FNumber'] ) ) {
1470
+ $meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 );
1471
+ }
1472
+ if ( ! empty( $exif['Model'] ) ) {
1473
+ $meta['camera'] = trim( $exif['Model'] );
1474
+ }
1475
+ if ( empty( $meta['created_timestamp'] ) && ! empty( $exif['DateTimeDigitized'] ) ) {
1476
+ $meta['created_timestamp'] = wp_exif_date2ts( $exif['DateTimeDigitized'] );
1477
+ }
1478
+ if ( ! empty( $exif['FocalLength'] ) ) {
1479
+ $meta['focal_length'] = (string) wp_exif_frac2dec( $exif['FocalLength'] );
1480
+ }
1481
+ if ( ! empty( $exif['ISOSpeedRatings'] ) ) {
1482
+ $meta['iso'] = is_array( $exif['ISOSpeedRatings'] ) ? reset( $exif['ISOSpeedRatings'] ) : $exif['ISOSpeedRatings'];
1483
+ $meta['iso'] = trim( $meta['iso'] );
1484
+ }
1485
+ if ( ! empty( $exif['ExposureTime'] ) ) {
1486
+ $meta['shutter_speed'] = (string) wp_exif_frac2dec( $exif['ExposureTime'] );
1487
+ }
1488
+ if ( ! empty( $exif['Orientation'] ) ) {
1489
+ $meta['orientation'] = $exif['Orientation'];
1490
+ }
1491
+ }
1492
+ foreach ( array( 'title', 'caption', 'credit', 'copyright', 'camera', 'iso' ) as $key ) {
1493
+ if ( $meta[ $key ] && ! seems_utf8( $meta[ $key ] ) ) {
1494
+ $meta[ $key ] = utf8_encode( $meta[ $key ] );
1495
+ }
1496
+ }
1497
+ foreach ( $meta as &$value ) {
1498
+ if ( is_string( $value ) ) {
1499
+ $value = wp_kses_post( $value );
1500
+ }
1501
+ }
1502
+ return $meta;
1503
+ }
1504
  }
frontend/views/BWGViewGalleryBox.php CHANGED
@@ -44,7 +44,7 @@ class BWGViewGalleryBox {
44
  $popup_info_full_width = (isset($_GET['popup_info_full_width']) ? esc_html($_GET['popup_info_full_width']) : 0);
45
  $popup_enable_rate = WDWLibrary::esc_script('get', 'popup_enable_rate', 0, 'int');
46
  $popup_hit_counter = (isset($_GET['popup_hit_counter']) ? esc_html($_GET['popup_hit_counter']) : 0);
47
- $slideshow_effect_duration = (isset($_GET['slideshow_effect_duration']) ? (int) $_GET['slideshow_effect_duration'] : 1);
48
  $slideshow_interval = (isset($_GET['slideshow_interval']) ? (int) $_GET['slideshow_interval'] : 5);
49
  $enable_image_ctrl_btn = (isset($_GET['enable_image_ctrl_btn']) ? esc_html($_GET['enable_image_ctrl_btn']) : 0);
50
  $enable_comment_social = FALSE;
@@ -1110,6 +1110,9 @@ class BWGViewGalleryBox {
1110
  }
1111
  bwg_change_watermark_container();
1112
  }
 
 
 
1113
  }
1114
  function bwg_cubeH(current_image_class, next_image_class, direction) {
1115
  /* Set to half of image width.*/
@@ -1144,15 +1147,15 @@ class BWGViewGalleryBox {
1144
  /* Set active thumbnail.*/
1145
  jQuery(".bwg_filmstrip_thumbnail").removeClass("bwg_thumb_active").addClass("bwg_thumb_deactive");
1146
  jQuery("#bwg_filmstrip_thumbnail_" + bwg_current_key).removeClass("bwg_thumb_deactive").addClass("bwg_thumb_active");
 
 
 
 
1147
  if (bwg_testBrowser_cssTransitions()) {
1148
  jQuery(next_image_class).css('transition', 'opacity ' + bwg_transition_duration + 'ms linear');
1149
  jQuery(current_image_class).css({'opacity' : 0, 'z-index': 1});
1150
  jQuery(next_image_class).css({'opacity' : 1, 'z-index' : 2});
1151
  jQuery(next_image_class).one('webkitTransitionEnd transitionend otransitionend oTransitionEnd mstransitionend', jQuery.proxy(bwg_after_trans));
1152
- function bwg_after_trans() {
1153
- jQuery(".bwg_image_info").show();
1154
- bwg_change_watermark_container();
1155
- }
1156
  }
1157
  else {
1158
  jQuery(current_image_class).animate({'opacity' : 0, 'z-index' : 1}, bwg_transition_duration);
@@ -1172,6 +1175,9 @@ class BWGViewGalleryBox {
1172
  jQuery(current_image_class).fadeTo(bwg_transition_duration, 0);
1173
  jQuery(next_image_class).fadeTo(bwg_transition_duration, 1);
1174
  }
 
 
 
1175
  }
1176
  function bwg_grid(cols, rows, ro, tx, ty, sc, op, current_image_class, next_image_class, direction) {
1177
  /* If browser does not support CSS transitions.*/
@@ -1224,7 +1230,7 @@ class BWGViewGalleryBox {
1224
  rowAdd = Math.ceil(rowRemainder / rows),
1225
  leftDist = 0,
1226
  img_leftDist = Math.ceil((jQuery(".bwg_slide_bg").width() - cur_img.width()) / 2);
1227
- var imgSrc = typeof cur_img.attr('src')=='undefined' ? '' :cur_img.attr('src');
1228
  /* tx/ty args can be passed as 'auto'/'min-auto' (meaning use slide width/height or negative slide width/height).*/
1229
  tx = tx === 'auto' ? contWidth : tx;
1230
  tx = tx === 'min-auto' ? - contWidth : tx;
@@ -1296,6 +1302,9 @@ class BWGViewGalleryBox {
1296
  }
1297
  bwg_change_watermark_container();
1298
  }
 
 
 
1299
  }
1300
  function bwg_sliceV(current_image_class, next_image_class, direction) {
1301
  if (direction == 'right') {
44
  $popup_info_full_width = (isset($_GET['popup_info_full_width']) ? esc_html($_GET['popup_info_full_width']) : 0);
45
  $popup_enable_rate = WDWLibrary::esc_script('get', 'popup_enable_rate', 0, 'int');
46
  $popup_hit_counter = (isset($_GET['popup_hit_counter']) ? esc_html($_GET['popup_hit_counter']) : 0);
47
+ $slideshow_effect_duration = (isset($_GET['slideshow_effect_duration']) ? floatval($_GET['slideshow_effect_duration']) : 1);
48
  $slideshow_interval = (isset($_GET['slideshow_interval']) ? (int) $_GET['slideshow_interval'] : 5);
49
  $enable_image_ctrl_btn = (isset($_GET['enable_image_ctrl_btn']) ? esc_html($_GET['enable_image_ctrl_btn']) : 0);
50
  $enable_comment_social = FALSE;
1110
  }
1111
  bwg_change_watermark_container();
1112
  }
1113
+ if (bwg_transition_duration == 0) {
1114
+ bwg_after_trans();
1115
+ }
1116
  }
1117
  function bwg_cubeH(current_image_class, next_image_class, direction) {
1118
  /* Set to half of image width.*/
1147
  /* Set active thumbnail.*/
1148
  jQuery(".bwg_filmstrip_thumbnail").removeClass("bwg_thumb_active").addClass("bwg_thumb_deactive");
1149
  jQuery("#bwg_filmstrip_thumbnail_" + bwg_current_key).removeClass("bwg_thumb_deactive").addClass("bwg_thumb_active");
1150
+ function bwg_after_trans() {
1151
+ jQuery(".bwg_image_info").show();
1152
+ bwg_change_watermark_container();
1153
+ }
1154
  if (bwg_testBrowser_cssTransitions()) {
1155
  jQuery(next_image_class).css('transition', 'opacity ' + bwg_transition_duration + 'ms linear');
1156
  jQuery(current_image_class).css({'opacity' : 0, 'z-index': 1});
1157
  jQuery(next_image_class).css({'opacity' : 1, 'z-index' : 2});
1158
  jQuery(next_image_class).one('webkitTransitionEnd transitionend otransitionend oTransitionEnd mstransitionend', jQuery.proxy(bwg_after_trans));
 
 
 
 
1159
  }
1160
  else {
1161
  jQuery(current_image_class).animate({'opacity' : 0, 'z-index' : 1}, bwg_transition_duration);
1175
  jQuery(current_image_class).fadeTo(bwg_transition_duration, 0);
1176
  jQuery(next_image_class).fadeTo(bwg_transition_duration, 1);
1177
  }
1178
+ if (bwg_transition_duration == 0) {
1179
+ bwg_after_trans();
1180
+ }
1181
  }
1182
  function bwg_grid(cols, rows, ro, tx, ty, sc, op, current_image_class, next_image_class, direction) {
1183
  /* If browser does not support CSS transitions.*/
1230
  rowAdd = Math.ceil(rowRemainder / rows),
1231
  leftDist = 0,
1232
  img_leftDist = Math.ceil((jQuery(".bwg_slide_bg").width() - cur_img.width()) / 2);
1233
+ var imgSrc = typeof cur_img.attr('src')=='undefined' ? '' :cur_img.attr('src');
1234
  /* tx/ty args can be passed as 'auto'/'min-auto' (meaning use slide width/height or negative slide width/height).*/
1235
  tx = tx === 'auto' ? contWidth : tx;
1236
  tx = tx === 'min-auto' ? - contWidth : tx;
1302
  }
1303
  bwg_change_watermark_container();
1304
  }
1305
+ if (bwg_transition_duration == 0) {
1306
+ bwg_after_trans();
1307
+ }
1308
  }
1309
  function bwg_sliceV(current_image_class, next_image_class, direction) {
1310
  if (direction == 'right') {
includes/bwg_pointers.php CHANGED
@@ -1,165 +1,189 @@
1
  <?php
2
 
3
  class BWG_pointers {
4
- private $prefix = 'bwg';
5
- private $page_url = '';
6
- private $pointers = array();
7
- private $page_pointers = array();
8
- private $pointer_script = array();
9
- private $pointer_text = array();
10
 
11
- public function __construct() {
12
- $user_meta = get_user_meta(get_current_user_id(), 'bwg_photo_gallery');
13
- if (is_array($user_meta) && !empty($user_meta)) {
14
- $this->set_urls();
15
- $this->set_pointer_text();
16
- $this->set_pointers();
17
- $this->get_page_pointers();
18
- if ($this->page_url == 'upload_image.php') {
19
- $this->show_pointer();
20
- }
21
- else {
22
- add_action('admin_enqueue_scripts', array($this, 'show_pointer'));
23
- }
24
- add_action('wp_ajax_bwg_tour', array($this, 'dismiss_pointer'));
25
  }
 
 
 
 
26
  }
 
27
 
28
- public function dismiss_pointer() {
29
- delete_user_meta(get_current_user_id(), 'bwg_photo_gallery');
30
- wp_die();
 
 
 
 
 
 
 
 
 
 
31
  }
 
 
 
 
32
 
33
- private function set_urls() {
34
- $path_info = pathinfo($_SERVER['REQUEST_URI']);
35
- $file_name = $path_info['filename'];
36
- if ( $file_name === 'admin-ajax' && ($_REQUEST['action'] == 'addImages' || $_REQUEST['action'] == 'addAlbumsGalleries' || $_REQUEST['action'] == 'BWGShortcode') ) {
37
- $this->page_url = 'upload_image.php';
38
- }
39
- elseif ($file_name === 'plugins') {
40
- $this->page_url = 'plugins.php';
 
41
  }
42
- else {
43
- $this->page_url = basename($_SERVER['REQUEST_URI']);
44
  }
45
  }
 
46
 
47
- private function get_page_pointers() {
48
- $post_type = false;
49
- if (isset($_REQUEST['post']) && intval($_REQUEST['post']) !== 0 && isset($_REQUEST['action']) && $_REQUEST['action'] === 'edit') {
50
- $post_type = get_post_type($_REQUEST['post']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  }
52
- foreach ($this->pointers as $id => $options) {
53
- $t = false;
54
- if ((!$post_type && $this->page_url == 'upload_image.php') || !isset($options['post_type']) || (isset($options['post_type']) && $post_type === $options['post_type'])) {
55
- $t = true;
56
- }
57
- if ($options['page'] === $this->page_url && $t) {
58
- $this->page_pointers[$id] = $this->set_pointer_options($id, $options);
59
- }
60
  }
61
  }
 
 
 
 
62
 
63
- private function set_pointer_options($pointer_id, $options) {
64
- $container_id = $this->get_conteiner_id($pointer_id);
65
- $html = '<h3>' . $options['title'] . '</h3>';
66
- $content = (isset($this->pointer_text [$pointer_id])) ? $this->pointer_text [$pointer_id]: 'No text';
67
- $openFunctionContent = '(function( $ ) {' . join(";", $this->pointer_buttons($container_id, $options) ) . '; $("#' . $container_id . '").closest(".wp-pointer").addClass("wp-pointer-aligned-' . $options['align'] . ' ' . ( isset( $options['tooltip_class'] ) ? $options['tooltip_class'] : '' ) . '"); })( jQuery );';
68
- $html .= '<div style="padding:5px 10px; " id="' . $container_id . '">' . $this->pointer_text [$pointer_id] . '</div>';
69
- return array(
70
- 'selector' => $options['selector'],
71
- 'content' => $html,
72
- 'openFunctionContent' => $openFunctionContent,
73
- 'edge' => $options['edge'],
74
- 'align' => $options['align'],
75
- 'close_on_click' => isset( $options['close_on_click'] ) ? $options['close_on_click'] : false,
76
- 'target_delayed' => isset( $options['target_delayed'] ) ? $options['target_delayed'] : false,
77
- 'show_on_event' => isset( $options['show_on_event'] ) ? $options['show_on_event'] : '',
78
- 'hide_on_event' => isset( $options['hide_on_event'] ) ? $options['hide_on_event'] : ''
79
- );
80
- }
81
 
82
- private function pointer_buttons($container_id, $options) {
83
- $this->pointer_script = array();
84
- if (isset($options['buttons']) && is_array($options['buttons']) && !empty($options['buttons'])) {
85
- foreach ($options['buttons'] as $button_class => $button_options) {
86
- $button = $button_class . '_button';
87
- $this->add_button_script($button_class, $button_options, $container_id);
88
- $this->$button($button_class, $button_options, $container_id);
89
- }
90
- if (isset($options['display']) && $options['display'] === false) {
91
- $this->pointer_script[] = '$("#' . $container_id . '").closest(".wp-pointer").hide();';
92
- }
93
- if (isset($options['scroll'])) {
94
- $this->pointer_script[] = 'setTimeout(function(){window.scrollTo(0, $("' . $options['scroll'] . '").offset().top-100)},1000);';
95
- }
96
- if (isset($options['close_on_click']) && $options['close_on_click'] == true) {
97
- $this->pointer_script[] = '$("' . $options['selector'] . '").on("click", function() { $("#' . $container_id . '").closest(".wp-pointer").hide();});';
98
- }
99
- }
100
- $pointer_script = $this->pointer_script;
101
- $this->pointer_script = array();
102
- return $pointer_script;
103
  }
 
 
 
 
 
 
104
 
105
- private function next_page_button($button_class, $options, $container_id) {
106
- $this->pointer_script[] = '$(".' . $button_class . '").on("click",function(){'
107
- . 'window.location.href="' . $options['url'] . '"'
108
- . '});';
 
 
109
  }
 
110
 
111
- private function next_pointer_button($button_class, $options, $container_id) {
112
- $pointer_conteiner_id = $this->get_conteiner_id($options['pointer_id']);
113
- $scroll_srcpt = "";
114
- if (isset($options['scroll'])) {
115
- $scroll_srcpt = '$(document).scrollTop($("' . $options['scroll'] . '").offset().top - 35);';
116
- }
117
- $this->pointer_script[] = '$("#' . $container_id . '").closest(".wp-pointer").find(".' . $button_class . '").on("click",function(){'
118
- . '$("#' . $pointer_conteiner_id . '") . closest(".wp-pointer") . show();'
119
- . '$(this).closest(".wp-pointer").hide();'
120
- . $scroll_srcpt
121
- . '});';
122
  }
123
-
124
- private function add_button_script($button_class, $options, $container_id) {
125
- if ($container_id != 'bwg_Add_image' && $container_id != 'bwg_add_alboms_gallery' && $container_id != 'bwg_add-shortcode' && $container_id != 'bwg_upload_image' && $container_id != 'bwg_add_selected_images' && $container_id != 'bwg_add_albums_gallery' && $container_id != 'bwg_add_album' && $container_id != 'bwg_choose_file' && $container_id != 'bwg_save_album' && $container_id != 'bwg_add-shortcode-gallery' && $container_id != 'bwg_insert_shortcode' && $container_id != 'bwg_save_gallery') {
126
- $button_class = 'class="button-secondary ' . $button_class . '"';
127
- $element = 'jQuery("#' . $container_id . '").closest(".wp-pointer-content").find(".wp-pointer-buttons")';
128
- $script = "jQuery('<button " . $button_class . ">" . $options['title'] . "</button>').appendTo(" . $element . ");";
129
- $this->pointer_script[] = $script;
130
- }
131
  }
 
132
 
133
- public function show_pointer() {
134
- if ( $this->page_url == 'upload_image.php' ) {
135
- ob_start();
136
- $this->print_pointer_script();
137
- /* echo ob_get_clean();*/
138
- }
139
- else {
140
- wp_enqueue_style('wp-pointer');
141
- wp_enqueue_script('wp-pointer');
142
- add_action('admin_print_footer_scripts', array($this, 'print_pointer_script'));
143
- }
144
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
 
146
- public function print_pointer_script() {
147
- ?>
148
- <script type="text/javascript">
149
- if (typeof jQuery != "undefined") {
150
- jQuery(document).ready(function() {
151
- (function ($) {
152
- var action = 'bwg_tour';
153
- <?php
154
- foreach ($this->page_pointers as $id => $options) {
155
- ?>
156
- var t;
157
- var isDelayed = <?php echo isset( $options['target_delayed'] ) && $options['target_delayed'] == true ? 'true' : 'false'; ?>;
158
- var showOnEvent = '<?php echo isset( $options['show_on_event'] ) ? $options['show_on_event'] : ''; ?>';
159
- var hideOnEvent = '<?php echo isset( $options['hide_on_event'] ) ? $options['hide_on_event'] : ''; ?>';
160
- if ( showOnEvent && showOnEvent != "" ) {
161
- (function() {
162
- $(document).on(showOnEvent, function() {
163
  $('<?php echo $options['selector']; ?>').pointer({
164
  content: '<?php echo $options['content']; ?>',
165
  position: {
@@ -167,497 +191,428 @@ class BWG_pointers {
167
  align: '<?php echo $options['align']; ?>'
168
  },
169
  close: function () {
170
- if ('<?php echo $options['selector']; ?>' != '#select_all_images' ) {
171
  jQuery.post(
172
- ajaxurl, {'action': action},
173
- function (response) {
174
-
175
- });
176
- }
177
- }
178
- }).pointer('open');
179
- <?php echo $options['openFunctionContent']; ?>
180
- });
181
- })()
182
- }
183
- else if ( isDelayed ) {
184
- (function() {
185
- var interval = setInterval(function() {
186
- if ( $('<?php echo $options['selector']; ?>').length && $('<?php echo $options['selector']; ?>').is(":visible") ) {
187
- $('<?php echo $options['selector']; ?>').pointer({
188
- content: '<?php echo $options['content']; ?>',
189
- position: {
190
- edge: '<?php echo $options['edge']; ?>',
191
- align: '<?php echo $options['align']; ?>'
192
- },
193
- close: function () {
194
- jQuery.post(
195
- ajaxurl, {'action': action},
196
- function (response) {
197
 
198
- });
199
- }
200
- }).pointer('open');
201
-
202
- <?php echo $options['openFunctionContent']; ?>
203
- clearInterval( interval );
204
- }
205
- }, 350);
206
- })()
207
- }
208
- else {
209
- $('<?php echo $options['selector']; ?>').pointer({
210
- content: '<?php echo $options['content']; ?>',
211
- position: {
212
- edge: '<?php echo $options['edge']; ?>',
213
- align: '<?php echo $options['align']; ?>',
214
- },
215
- close: function () {
216
- if ('<?php echo $options['selector']; ?>' != '#select_all_images') {
217
- jQuery.post(
218
- ajaxurl, {'action': action},
219
- function (response) {
220
-
221
- });
222
  }
 
 
 
 
223
  }
224
- }).pointer('open');
225
-
226
- <?php echo $options['openFunctionContent']; ?>
227
- }
228
-
229
- $(document).on(hideOnEvent, function() {
230
-
231
- try {
232
- $('<?php echo $options['selector']; ?>').pointer('close');
 
 
 
 
 
 
 
 
233
  }
234
- catch( e ) {}
235
-
236
-
237
- });
238
- <?php
239
- }
240
- foreach ($this->pointer_script as $id => $script) {
241
- echo $script;
242
- }
243
- ?>
244
- })(jQuery);
245
- });
246
- }
247
- </script>
248
- <?php
249
- }
250
 
251
- private function get_conteiner_id($pointer_id) {
252
- return $this->prefix . '_' . $pointer_id;
253
- }
254
-
255
- public function set_pointer_text(){
256
- $this->pointer_text = array(
257
- 'plugins' => __('Press Start Tour to learn how to create your first Photo Gallery.', 'bwg_back'),
258
- 'edit_options' => __('Set the settings for gallery/album.', 'bwg_back'),
259
- 'galleries' => __('Press Add New button to create your gallery.', 'bwg_back'),
260
- /* 'gallery_name' => __('Name your gallery and press Next.', 'bwg_back'),*/
261
- 'Add_image' => __('Press add image button to open Image Upload to add images to gallery.', 'bwg_back'),
262
- 'upload_image' => __('Press to upload images. If you plan to create gallery based on images stored in standard WordPress Media Library, you must enable "Import from Media Library" option from "Global options".', 'bwg_back'),
263
- 'choose_file' => __('Browse photos or drag and drop to upload.', 'bwg_back'),
264
- 'select_all_img' => __('Hit on images you want to add to existing gallery or press Select All button for adding all images.', 'bwg_back'),
265
- 'add_selected_images' => __('To finalize the process of adding images press Add Selected image to gallery. Images will be added to your gallery and pop-up will be closed.', 'bwg_back'),
266
- 'save_gallery' => __('Press Save button. If you want to additionally create an album navigate to Photo Gallery/Albums or navigate to Pages section to insert created gallery into a page.', 'bwg_back'),
267
- 'add_albums' => __('Press Add New button to create your album.', 'bwg_back'),
268
- /*'albums_name' => __('Name your album and press Next', 'bwg_back'),*/
269
- 'add_albums_gallery' => __('Press Add Albums/Galleries button to choose the galleries and albums which will be included into newly created album.', 'bwg_back'),
270
- 'check_all_album' => __('Select albums/galleries which you want to add to the album.', 'bwg_back'),
271
- 'add_album' => __('Press Add button to add selected items to your album.', 'bwg_back'),
272
- 'save_album' => __('Press Save button. Navigate to Pages section to insert created album into a page.', 'bwg_back'),
273
- 'show_page_gallery_album' => __('Add New Photo Gallery page.', 'bwg_back'),
274
- 'add-page' => __('Press Add New button to create a new page with gallery/album.', 'bwg_back'),
275
- 'add-shortcode-gallery' => __('Click on Photo Gallery shortcode generator icon.', 'bwg_back'),
276
- 'shortcode_gallery_bwg' => __('Select the view option you want to use for your gallery/album based on provided display options', 'bwg_back'),
277
- 'theme_shortcode' => __('Select the gallery/album and define view-related options.', 'bwg_back'),
278
- 'laytbox_shortcode' => __('Define lightbox settings (except slideshow and carousel views with their own sets of features).', 'bwg_back'),
279
- 'advertisement_shortcode' => __('Enable Advertisement previously created in Options section.', 'bwg_back'),
280
- 'insert_shortcode' => __('To finalize the shortcode generation and to insert it to a page press Insert button.', 'bwg_back'),
281
- 'add-shortcode' => __('Publish the page.', 'bwg_back')
282
- );
283
- }
284
 
285
- public function set_pointers() {
286
- if(strpos($this->page_url,'bwg_nonce') > 0) {
287
- $Page_url = $this->page_url;
288
  }
289
- else {
290
- $Page_url = 'admin.php?page=galleries_bwg&show_pointer=true';
291
  }
292
-
293
- $this->pointers = array(
294
- 'plugins' => array(
295
- 'page' => 'plugins.php',
296
- 'buttons' => array(
297
- 'next_page' => array(
298
- 'title' => __('Start', 'bwg_back'),
299
- 'url' => 'admin.php?page=options_bwg'
300
- )
301
- ),
302
- 'title' => __('Click to Start Tour', 'bwg_back'),
303
- 'selector' => '#toplevel_page_galleries_bwg',
304
- 'edge' => 'left',
305
- 'scroll'=> '#toplevel_page_galleries_bwg',
306
- 'align' => 'center'
307
- ),
308
- 'edit_options' => array(
309
- 'page' => 'admin.php?page=options_bwg',
310
- 'buttons' => array(
311
- 'next_page' => array(
312
- 'title' => __('Next', 'bwg_back'),
313
- 'url' => 'admin.php?page=galleries_bwg',
314
- )
315
- ),
316
- 'title' => __('Photo Gallery options', 'bwg_back'),
317
- 'selector' => '#ed_options',
318
- 'edge' => 'left',
319
- 'align' => 'left',
320
- 'tooltip_class' => 'option_class'
321
- ),
322
- 'galleries' => array(
323
- 'page' => 'admin.php?page=galleries_bwg',
324
- 'buttons' => array(),
325
- 'title' => __('Add a Gallery', 'bwg_back'),
326
- 'selector' => '#galleries_id',
327
- 'edge' => 'left',
328
- 'align' => 'left',
329
- 'tooltip_class' => 'bwg_photo_galleries'
330
- ),
331
- /*'gallery_name' => array(
332
- 'page' => 'admin.php?page=galleries_bwg',
333
- 'buttons' => array(
334
- 'next_pointer' => array(
335
- 'title' => __('Next', 'bwg_back'),
336
- 'pointer_id' => 'Add_image',
337
- 'scroll' => '#add_image_bwg'
338
- )
339
- ),
340
- 'title' => __('Provide Title', 'bwg_back'),
341
- 'selector' => '#name',
342
- 'edge' => 'left',
343
- 'align' => 'left',
344
- ),*/
345
- 'Add_image' => array(
346
- 'page' => 'admin.php?page=galleries_bwg',
347
- 'buttons' => array(
348
- 'next_page' => array(
349
- 'title' => __('Next', 'bwg_back'),
350
- 'url' => 'admin.php?page=galleries_bwg'
351
- )
352
- ),
353
- 'title' => __('Add images', 'bwg_back'),
354
- 'selector' => '#add_image_bwg',
355
- 'edge' => 'top',
356
- 'align' => 'left',
357
- 'tooltip_class' => 'bwg_add_img',
358
- //'scroll' => '#add_image_bwg',
359
- 'close_on_click' => true
360
  ),
361
- 'upload_image' => array(
362
- 'page' => 'upload_image.php',
363
- 'buttons' => array(
364
- 'next_pointer' => array(
365
- 'title' => __('Next', 'bwg_back'),
366
- 'pointer_id' => 'choose_file'
367
- )
368
- ),
369
- 'title' => __('Upload Images', 'bwg_back'),
370
- 'selector' => '#upload_images',
371
- 'edge' => 'top',
372
- 'align' => 'left',
373
- 'tooltip_class' => 'bwg_upload_img',
374
- 'target_delayed' => true,
375
- 'show_on_event' => 'onUpload',
376
- 'close_on_click' => true,
377
  ),
378
- 'choose_file' => array(
379
- 'page' => 'upload_image.php',
380
- 'buttons' => array(
381
- 'next_pointer' => array(
382
- 'title' => __('Next', 'bwg_back'),
383
- 'pointer_id' => 'select_all_img'
384
- )
385
- ),
386
- 'title' => __('Choose file', 'bwg_back'),
387
- 'selector' => '#jQueryUploader',
388
- 'edge' => 'top',
389
- 'align' => 'left',
390
- 'close_on_click' => true,
391
- 'target_delayed' => true
 
 
 
 
 
 
 
 
392
  ),
393
- 'select_all_img' => array(
394
- 'page' => 'upload_image.php',
395
- 'buttons' => array(
396
- 'next_pointer' => array(
397
- 'title' => __('Next', 'bwg_back'),
398
- 'pointer_id' => 'add_selected_images'
399
- )
400
- ),
401
- 'title' => __('Select Images', 'bwg_back'),
402
- 'content' => 'description',
403
- 'selector' => '#select_all_images',
404
- 'edge' => 'left',
405
- 'align' => 'center',
406
- 'tooltip_class' => 'bwg_select_img',
407
- 'show_on_event' => 'onSelectAllImage',
408
- 'hide_on_event' => 'onUploadFilesPressed',
409
  ),
410
- 'add_selected_images' => array(
411
- 'page' => 'upload_image.php',
412
- 'buttons' => array(
413
- 'next_page' => array(
414
- 'title' => __('Next', 'bwg_back'),
415
- 'url' => 'admin.php?page=galleries_bwg',
416
- 'scroll' => '#save_gall',
417
- )
418
- ),
419
- 'title' => __('Add Selected images to gallery', 'bwg_back'),
420
- 'selector' => '#add_selectid_img',
421
- 'edge' => 'bottom',
422
- 'align' => 'left',
423
- 'tooltip_class' => 'bwg_selected_img',
424
- 'display' =>false,
 
425
  ),
426
- 'save_gallery' => array(
427
- 'page' => 'admin.php?page=galleries_bwg',
428
- 'buttons' => array(
429
- 'next_page' => array(
430
- 'title' => __('Next', 'bwg_back'),
431
- 'url' => 'admin.php?page=albums_bwg'
432
- )
433
- ),
434
- 'title' => __('Save gallery', 'bwg_back'),
435
- 'content' => 'description',
436
- 'selector' => '#save_gall',
437
- 'edge' => 'right',
438
- 'align' => 'center',
439
- 'tooltip_class' => 'bwg_gallery_save',
440
- 'scroll' => '#save_gall',
441
- 'show_on_event' => 'bwgImagesAdded',
442
- ),
443
- 'add_albums' => array(
444
- 'page' => 'admin.php?page=albums_bwg',
445
- 'buttons' => array(),
446
- 'title' => __('Add album/gallery', 'bwg_back'),
447
- 'selector' => '.add-new-h2',
448
- 'edge' => 'left',
449
- 'align' => 'left',
450
- 'tooltip_class' => 'bwg_gallery_album',
451
  ),
452
- /*'albums_name' => array(
453
- 'page' => 'admin.php?page=albums_bwg',
454
- 'buttons' => array(
455
- 'next_pointer' => array(
456
- 'title' => __('Next', 'bwg_back'),
457
- 'pointer_id' => 'add_albums_gallery',
458
- 'scroll' => '#content-add_media',
459
- )
460
- ),
461
- 'title' => __('Provide Title', 'bwg_back'),
462
- 'selector' => '#name',
463
- 'edge' => 'left',
464
- 'align' => 'left',
465
- ),*/
466
- 'add_albums_gallery' => array(
467
- 'page' => 'admin.php?page=albums_bwg',
468
- 'buttons' => array(
469
- 'next_page' => array(
470
- 'title' => __('Next', 'bwg_back'),
471
- 'url' => 'admin.php?page=albums_bwg',
472
- )
473
- ),
474
- 'title' => __('Add Albums/Galleries', 'bwg_back'),
475
- 'content' => 'description',
476
- 'selector' => '#content-add_media',
477
- 'edge' => 'left',
478
- 'align' => 'left',
479
- 'tooltip_class' => 'bwg_add_gallery_album',
480
- 'close_on_click' => true,
481
- //'display' =>false
482
  ),
483
- 'check_all_album' => array(
484
- 'page' => 'upload_image.php',
485
- 'buttons' => array(
486
- 'next_pointer' => array(
487
- 'title' => __('Next', 'bwg_back'),
488
- 'pointer_id' => 'add_album'
489
- )
490
- ),
491
- 'title' => __('Select album/gallery', 'bwg_back'),
492
- 'content' => 'description',
493
- 'selector' => '#check_all',
494
- 'edge' => 'left',
495
- 'align' => 'left',
496
- 'tooltip_class' => 'select_all_album'
497
  ),
498
- 'add_album' => array(
499
- 'page' => 'upload_image.php',
500
- 'buttons' => array(
501
- 'next_page' => array(
502
- 'title' => __('Next', 'bwg_back'),
503
- 'url' => 'upload_image.php'
504
- )
505
- ),
506
- 'title' => __('Choosing Galleries/Albums', 'bwg_back'),
507
- 'content' => 'description',
508
- 'selector' => '#add_albums',
509
- 'edge' => 'top',
510
- 'tooltip_class' => 'bwg_add_album_bwg',
511
- 'align' => 'right',
512
- 'display' => false
 
 
 
 
 
 
 
 
 
 
513
  ),
514
- 'save_album' => array(
515
- 'page' => 'admin.php?page=albums_bwg',
516
- 'buttons' => array(
517
- 'next_page' => array(
518
- 'title' => __('Next', 'bwg_back'),
519
- 'url' => 'edit.php?post_type=page'
520
- )
521
- ),
522
- 'title' => __('Save Album', 'bwg_back'),
523
- 'content' => 'description',
524
- 'selector' => '#save_albums',
525
- 'edge' => 'right',
526
- 'align' => 'left',
527
- 'tooltip_class' => 'bwg_album_save',
528
- 'scroll' =>'#save_albums',
529
- 'show_on_event' => 'onAddAlbum',
530
  ),
531
- 'show_page_gallery_album' => array(
532
- 'page' => $Page_url,
533
- 'buttons' => array(
534
- 'next_page' => array(
535
- 'title' => __('Next', 'bwg_back'),
536
- 'url' => 'edit.php?post_type=page'
537
- )
538
- ),
539
- 'title' => __('Add New Page', 'bwg_back'),
540
- 'content' => 'description',
541
- 'selector' => '.dashicons-admin-page',
542
- 'edge' => 'left',
543
- 'align' => 'left',
544
- 'scroll' => '.dashicons-admin-page',
545
- 'tooltip_class' => 'show_page',
546
  ),
547
- 'add-page' => array(
548
- 'page' => 'edit.php?post_type=page',
549
- 'buttons' => array(),
550
- 'title' => __('Add Page', 'bwg_back'),
551
- 'selector' => '.page-title-action',
552
- 'edge' => 'top',
553
- 'align' => 'left',
 
 
 
 
 
 
 
 
554
  ),
555
- 'add-shortcode-gallery' => array(
556
- 'page' => 'post-new.php?post_type=page',
557
- 'buttons' => array(
558
- 'next_pointer' => array(
559
- 'title' => __('Next', 'bwg_back'),
560
- 'pointer_id' => 'add-shortcode'
561
- )
562
- ),
563
- 'title' => __('Insert Shortcode', 'bwg_back'),
564
- 'selector' => '#mceu_bwg_shorcode',
565
- 'edge' => 'bottom',
566
- 'align' => 'left',
567
- 'close_on_click' =>true,
568
- 'show_on_event' => 'onUploadImg',
569
- 'tooltip_class' =>'add_short_gall'
 
570
  ),
571
- 'shortcode_gallery_bwg' => array(
572
- 'page' => 'upload_image.php',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
573
  'buttons' => array(
574
- 'next_pointer' => array(
575
- 'title' => __('Next', 'bwg_back'),
576
- 'pointer_id' => 'theme_shortcode'
577
- )
578
  ),
579
- 'title' => __('Choose View', 'bwg_back'),
580
- 'selector' => '#display_thumb',
581
- 'edge' => 'top',
582
  'align' => 'left',
583
- 'show_on_event' => 'onUploadShortcode'
 
 
 
 
 
 
 
 
 
 
584
  ),
585
- 'theme_shortcode' => array(
586
- 'page' => 'upload_image.php',
587
- 'buttons' => array(
588
- 'next_pointer' => array(
589
- 'title' => __('Next', 'bwg_back'),
590
- 'pointer_id' => 'laytbox_shortcode'
591
- )
592
- ),
593
- 'title' => __('Select gallery', 'bwg_back'),
594
- 'selector' => '#gallery',
595
- 'edge' => 'left',
596
- 'align' => 'center',
597
- 'display'=> false,
598
- 'tooltip_class' => 'theme_short',
599
- 'show_on_event' => 'onUploadShortcode',
600
  ),
601
- 'laytbox_shortcode' => array(
602
- 'page' => 'upload_image.php',
603
- 'buttons' => array(
604
- 'next_pointer' => array(
605
- 'title' => __('Next', 'bwg_back'),
606
- 'pointer_id' => 'insert_shortcode',
607
- 'scroll' =>'#insert'
608
- )
609
- ),
610
- 'title' => __('Ligthbox settings', 'bwg_back'),
611
- 'selector' => '#tbody_popup_other',
612
- 'edge' => 'left',
613
- 'align' => 'center',
614
- 'display'=> false
 
 
615
  ),
616
- /*'advertisement_shortcode' => array(
617
- 'page' => 'upload_image.php',
618
- 'buttons' => array(
619
- 'next_pointer' => array(
620
- 'title' => __('Next', 'bwg_back'),
621
- 'pointer_id' => 'insert_shortcode',
622
- 'scroll' =>'#insert'
623
- )
624
- ),
625
- 'title' => __('Advertisement settings', 'bwg_back'),
626
- 'selector' => '#advertisement_id',
627
- 'edge' => 'right',
628
- 'align' => 'center',
629
- 'display'=> false
630
- ),*/
631
- 'insert_shortcode' => array(
632
- 'page' => 'upload_image.php',
633
- 'buttons' => array(
634
- 'next_page' => array(
635
- 'title' => __('Next', 'bwg_back'),
636
- 'url' => 'post-new.php?post_type=page'
637
- )
638
- ),
639
- 'title' => __('Insert Shortcode', 'bwg_back'),
640
- 'selector' => '#insert',
641
- 'edge' => 'bottom',
642
- 'align' => 'right',
643
- 'tooltip_class' => 'bwg_insert_short',
644
- 'show_on_event' => 'onUploadShortcode',
645
- 'display'=> false
646
  ),
647
- 'add-shortcode' => array(
648
- 'page' => 'post-new.php?post_type=page',
649
- 'buttons' => array(
650
- 'next_page' => array(
651
- 'title' => __('Next', 'bwg_back'),
652
- 'url' => 'post-new.php?post_type=page'
653
- )
654
- ),
655
- 'title' => __('Publish Page', 'bwg_back'),
656
- 'selector' => '#publishing-action',
657
- 'edge' => 'right',
658
- 'align' => 'left',
659
- 'show_on_event' => 'onOpenShortcode'
 
 
660
  ),
661
- );
662
- }
 
 
 
 
 
 
663
  }
1
  <?php
2
 
3
  class BWG_pointers {
4
+ private $prefix = 'bwg';
5
+ private $page_url = '';
6
+ private $pointers = array();
7
+ private $page_pointers = array();
8
+ private $pointer_script = array();
9
+ private $pointer_text = array();
10
 
11
+ public function __construct() {
12
+ $user_meta = get_user_meta(get_current_user_id(), 'bwg_photo_gallery');
13
+ if (is_array($user_meta) && !empty($user_meta)) {
14
+ $this->set_urls();
15
+ $this->set_pointer_text();
16
+ $this->set_pointers();
17
+ $this->get_page_pointers();
18
+ if ($this->page_url == 'upload_image.php') {
19
+ $this->show_pointer();
 
 
 
 
 
20
  }
21
+ else {
22
+ add_action('admin_enqueue_scripts', array($this, 'show_pointer'));
23
+ }
24
+ add_action('wp_ajax_bwg_tour', array($this, 'dismiss_pointer'));
25
  }
26
+ }
27
 
28
+ public function dismiss_pointer() {
29
+ delete_user_meta(get_current_user_id(), 'bwg_photo_gallery');
30
+ wp_die();
31
+ }
32
+
33
+ private function set_urls() {
34
+ $path_info = pathinfo($_SERVER['REQUEST_URI']);
35
+ $file_name = $path_info['filename'];
36
+ if ( $file_name === 'admin-ajax' && ($_REQUEST['action'] == 'addImages' || $_REQUEST['action'] == 'addAlbumsGalleries' || $_REQUEST['action'] == 'BWGShortcode') ) {
37
+ $this->page_url = 'upload_image.php';
38
+ }
39
+ elseif ($file_name === 'plugins') {
40
+ $this->page_url = 'plugins.php';
41
  }
42
+ else {
43
+ $this->page_url = basename($_SERVER['REQUEST_URI']);
44
+ }
45
+ }
46
 
47
+ private function get_page_pointers() {
48
+ $post_type = false;
49
+ if (isset($_REQUEST['post']) && intval($_REQUEST['post']) !== 0 && isset($_REQUEST['action']) && $_REQUEST['action'] === 'edit') {
50
+ $post_type = get_post_type($_REQUEST['post']);
51
+ }
52
+ foreach ($this->pointers as $id => $options) {
53
+ $t = false;
54
+ if ((!$post_type && $this->page_url == 'upload_image.php') || !isset($options['post_type']) || (isset($options['post_type']) && $post_type === $options['post_type'])) {
55
+ $t = true;
56
  }
57
+ if ($options['page'] === $this->page_url && $t) {
58
+ $this->page_pointers[$id] = $this->set_pointer_options($id, $options);
59
  }
60
  }
61
+ }
62
 
63
+ private function set_pointer_options($pointer_id, $options) {
64
+ $container_id = $this->get_conteiner_id($pointer_id);
65
+ $html = '<h3>' . $options['title'] . '</h3>';
66
+ $content = (isset($this->pointer_text [$pointer_id])) ? $this->pointer_text [$pointer_id]: 'No text';
67
+ $openFunctionContent = '(function( $ ) {' . join(";", $this->pointer_buttons($container_id, $options) ) . '; $("#' . $container_id . '").closest(".wp-pointer").addClass("wp-pointer-aligned-' . $options['align'] . ' ' . ( isset( $options['tooltip_class'] ) ? $options['tooltip_class'] : '' ) . '"); })( jQuery );';
68
+ $html .= '<div style="padding:5px 10px; " id="' . $container_id . '">' . $this->pointer_text [$pointer_id] . '</div>';
69
+ return array(
70
+ 'selector' => $options['selector'],
71
+ 'content' => $html,
72
+ 'openFunctionContent' => $openFunctionContent,
73
+ 'edge' => $options['edge'],
74
+ 'align' => $options['align'],
75
+ 'close_on_click' => isset( $options['close_on_click'] ) ? $options['close_on_click'] : false,
76
+ 'target_delayed' => isset( $options['target_delayed'] ) ? $options['target_delayed'] : false,
77
+ 'show_on_event' => isset( $options['show_on_event'] ) ? $options['show_on_event'] : '',
78
+ 'hide_on_event' => isset( $options['hide_on_event'] ) ? $options['hide_on_event'] : ''
79
+ );
80
+ }
81
+
82
+ private function pointer_buttons($container_id, $options) {
83
+ $this->pointer_script = array();
84
+ if (isset($options['buttons']) && is_array($options['buttons']) && !empty($options['buttons'])) {
85
+ foreach ($options['buttons'] as $button_class => $button_options) {
86
+ $button = $button_class . '_button';
87
+ $this->add_button_script($button_class, $button_options, $container_id);
88
+ $this->$button($button_class, $button_options, $container_id);
89
+ }
90
+ if (isset($options['display']) && $options['display'] === false) {
91
+ $this->pointer_script[] = '$("#' . $container_id . '").closest(".wp-pointer").hide();';
92
+ }
93
+ if (isset($options['scroll'])) {
94
+ $this->pointer_script[] = 'setTimeout(function(){window.scrollTo(0, $("' . $options['scroll'] . '").offset().top-100)},1000);';
95
  }
96
+ if (isset($options['close_on_click']) && $options['close_on_click'] == true) {
97
+ $this->pointer_script[] = '$("' . $options['selector'] . '").on("click", function() { $("#' . $container_id . '").closest(".wp-pointer").hide();});';
 
 
 
 
 
 
98
  }
99
  }
100
+ $pointer_script = $this->pointer_script;
101
+ $this->pointer_script = array();
102
+ return $pointer_script;
103
+ }
104
 
105
+ private function next_page_button($button_class, $options, $container_id) {
106
+ $this->pointer_script[] = '$(".' . $button_class . '").on("click",function(){'
107
+ . 'window.location.href="' . $options['url'] . '"'
108
+ . '});';
109
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
+ private function next_pointer_button($button_class, $options, $container_id) {
112
+ $pointer_conteiner_id = $this->get_conteiner_id($options['pointer_id']);
113
+ $scroll_srcpt = "";
114
+ if (isset($options['scroll'])) {
115
+ $scroll_srcpt = '$(document).scrollTop($("' . $options['scroll'] . '").offset().top - 35);';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
117
+ $this->pointer_script[] = '$("#' . $container_id . '").closest(".wp-pointer").find(".' . $button_class . '").on("click",function(){'
118
+ . '$("#' . $pointer_conteiner_id . '") . closest(".wp-pointer") . show();'
119
+ . '$(this).closest(".wp-pointer").hide();'
120
+ . $scroll_srcpt
121
+ . '});';
122
+ }
123
 
124
+ private function add_button_script($button_class, $options, $container_id) {
125
+ if ($container_id != 'bwg_Add_image' && $container_id != 'bwg_add_alboms_gallery' && $container_id != 'bwg_add-shortcode' && $container_id != 'bwg_upload_image' && $container_id != 'bwg_add_selected_images' && $container_id != 'bwg_add_albums_gallery' && $container_id != 'bwg_add_album' && $container_id != 'bwg_choose_file' && $container_id != 'bwg_save_album' && $container_id != 'bwg_add-shortcode-gallery' && $container_id != 'bwg_insert_shortcode' && $container_id != 'bwg_save_gallery') {
126
+ $button_class = 'class="button-secondary ' . $button_class . '"';
127
+ $element = 'jQuery("#' . $container_id . '").closest(".wp-pointer-content").find(".wp-pointer-buttons")';
128
+ $script = "jQuery('<button " . $button_class . ">" . $options['title'] . "</button>').appendTo(" . $element . ");";
129
+ $this->pointer_script[] = $script;
130
  }
131
+ }
132
 
133
+ public function show_pointer() {
134
+ if ( $this->page_url == 'upload_image.php' ) {
135
+ ob_start();
136
+ $this->print_pointer_script();
137
+ /* echo ob_get_clean();*/
 
 
 
 
 
 
138
  }
139
+ else {
140
+ wp_enqueue_style('wp-pointer');
141
+ wp_enqueue_script('wp-pointer');
142
+ add_action('admin_print_footer_scripts', array($this, 'print_pointer_script'));
 
 
 
 
143
  }
144
+ }
145
 
146
+ public function print_pointer_script() {
147
+ ?>
148
+ <script type="text/javascript">
149
+ if (typeof jQuery != "undefined") {
150
+ jQuery(document).ready(function() {
151
+ (function ($) {
152
+ var action = 'bwg_tour';
153
+ <?php
154
+ foreach ($this->page_pointers as $id => $options) {
155
+ ?>
156
+ var t;
157
+ var isDelayed = <?php echo isset( $options['target_delayed'] ) && $options['target_delayed'] == true ? 'true' : 'false'; ?>;
158
+ var showOnEvent = '<?php echo isset( $options['show_on_event'] ) ? $options['show_on_event'] : ''; ?>';
159
+ var hideOnEvent = '<?php echo isset( $options['hide_on_event'] ) ? $options['hide_on_event'] : ''; ?>';
160
+ if ( showOnEvent && showOnEvent != "" ) {
161
+ (function() {
162
+ $(document).on(showOnEvent, function() {
163
+ $('<?php echo $options['selector']; ?>').pointer({
164
+ content: '<?php echo $options['content']; ?>',
165
+ position: {
166
+ edge: '<?php echo $options['edge']; ?>',
167
+ align: '<?php echo $options['align']; ?>'
168
+ },
169
+ close: function () {
170
+ if ('<?php echo $options['selector']; ?>' != '#select_all_images' ) {
171
+ jQuery.post(
172
+ ajaxurl, {'action': action},
173
+ function (response) {
174
 
175
+ });
176
+ }
177
+ }
178
+ }).pointer('open');
179
+ <?php echo $options['openFunctionContent']; ?>
180
+ });
181
+ })()
182
+ }
183
+ else if ( isDelayed ) {
184
+ (function() {
185
+ var interval = setInterval(function() {
186
+ if ( $('<?php echo $options['selector']; ?>').length && $('<?php echo $options['selector']; ?>').is(":visible") ) {
 
 
 
 
 
187
  $('<?php echo $options['selector']; ?>').pointer({
188
  content: '<?php echo $options['content']; ?>',
189
  position: {
191
  align: '<?php echo $options['align']; ?>'
192
  },
193
  close: function () {
 
194
  jQuery.post(
195
+ ajaxurl, {'action': action},
196
+ function (response) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
 
198
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  }
200
+ }).pointer('open');
201
+
202
+ <?php echo $options['openFunctionContent']; ?>
203
+ clearInterval( interval );
204
  }
205
+ }, 350);
206
+ })()
207
+ }
208
+ else {
209
+ $('<?php echo $options['selector']; ?>').pointer({
210
+ content: '<?php echo $options['content']; ?>',
211
+ position: {
212
+ edge: '<?php echo $options['edge']; ?>',
213
+ align: '<?php echo $options['align']; ?>',
214
+ },
215
+ close: function () {
216
+ if ('<?php echo $options['selector']; ?>' != '#select_all_images') {
217
+ jQuery.post(
218
+ ajaxurl, {'action': action},
219
+ function (response) {
220
+
221
+ });
222
  }
223
+ }
224
+ }).pointer('open');
225
+
226
+ <?php echo $options['openFunctionContent']; ?>
227
+ }
228
+
229
+ $(document).on(hideOnEvent, function() {
230
+
231
+ try {
232
+ $('<?php echo $options['selector']; ?>').pointer('close');
233
+ }
234
+ catch( e ) {}
 
 
 
 
235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
 
237
+ });
238
+ <?php
 
239
  }
240
+ foreach ($this->pointer_script as $id => $script) {
241
+ echo $script;
242
  }
243
+ ?>
244
+ })(jQuery);
245
+ });
246
+ }
247
+ </script>
248
+ <?php
249
+ }
250
+
251
+ private function get_conteiner_id($pointer_id) {
252
+ return $this->prefix . '_' . $pointer_id;
253
+ }
254
+
255
+ public function set_pointer_text(){
256
+ $this->pointer_text = array(
257
+ 'plugins' => __('Press Start Tour to learn how to create your first Photo Gallery.', 'bwg_back'),
258
+ 'edit_options' => __('Set the settings for gallery/album.', 'bwg_back'),
259
+ 'galleries' => __('Press Add New button to create your gallery.', 'bwg_back'),
260
+ 'Add_image' => __('Press add image button to open Image Upload to add images to gallery.', 'bwg_back'),
261
+ 'upload_image' => __('Press to upload images.".', 'bwg_back'),
262
+ 'choose_file' => __('Browse photos or drag and drop to upload.', 'bwg_back'),
263
+ 'select_all_img' => __('Hit on images you want to add to existing gallery or press Select All button for adding all images.', 'bwg_back'),
264
+ 'add_selected_images' => __('To finalize the process of adding images press Add Selected image to gallery. Images will be added to your gallery and pop-up will be closed.', 'bwg_back'),
265
+ 'save_gallery' => __('Press Save button. If you want to additionally create an album navigate to Photo Gallery/Albums or navigate to Pages section to insert created gallery into a page.', 'bwg_back'),
266
+ 'add_albums' => __('Press Add New button to create your album.', 'bwg_back'),
267
+ 'add_albums_gallery' => __('Press Add Albums/Galleries button to choose the galleries and albums which will be included into newly created album.', 'bwg_back'),
268
+ 'check_all_album' => __('Select albums/galleries which you want to add to the album.', 'bwg_back'),
269
+ 'add_album' => __('Press Add button to add selected items to your album.', 'bwg_back'),
270
+ 'save_album' => __('Press Save button. Navigate to Pages section to insert created album into a page.', 'bwg_back'),
271
+ 'show_page_gallery_album' => __('Add New Photo Gallery page.', 'bwg_back'),
272
+ 'add-page' => __('Press Add New button to create a new page with gallery/album.', 'bwg_back'),
273
+ 'add-shortcode-gallery' => __('Click on Photo Gallery shortcode generator icon.', 'bwg_back'),
274
+ 'shortcode_gallery_bwg' => __('Select the view option you want to use for your gallery/album based on provided display options', 'bwg_back'),
275
+ 'theme_shortcode' => __('Select the gallery/album and define view-related options.', 'bwg_back'),
276
+ 'laytbox_shortcode' => __('Define lightbox settings (except slideshow and carousel views with their own sets of features).', 'bwg_back'),
277
+ 'advertisement_shortcode' => __('Enable Advertisement previously created in Options section.', 'bwg_back'),
278
+ 'insert_shortcode' => __('To finalize the shortcode generation and to insert it to a page press Insert button.', 'bwg_back'),
279
+ 'add-shortcode' => __('Publish the page.', 'bwg_back')
280
+ );
281
+ }
282
+
283
+ public function set_pointers() {
284
+ if(strpos($this->page_url,'bwg_nonce') > 0) {
285
+ $Page_url = $this->page_url;
286
+ }
287
+ else {
288
+ $Page_url = 'admin.php?page=galleries_bwg&show_pointer=true';
289
+ }
290
+
291
+ $this->pointers = array(
292
+ 'plugins' => array(
293
+ 'page' => 'plugins.php',
294
+ 'buttons' => array(
295
+ 'next_page' => array(
296
+ 'title' => __('Start', 'bwg_back'),
297
+ 'url' => 'admin.php?page=options_bwg'
298
+ )
 
 
 
 
 
 
 
 
 
 
 
 
299
  ),
300
+ 'title' => __('Click to Start Tour', 'bwg_back'),
301
+ 'selector' => '#toplevel_page_galleries_bwg',
302
+ 'edge' => 'left',
303
+ 'scroll'=> '#toplevel_page_galleries_bwg',
304
+ 'align' => 'center'
305
+ ),
306
+ 'edit_options' => array(
307
+ 'page' => 'admin.php?page=options_bwg',
308
+ 'buttons' => array(
309
+ 'next_page' => array(
310
+ 'title' => __('Next', 'bwg_back'),
311
+ 'url' => 'admin.php?page=galleries_bwg',
312
+ )
 
 
 
313
  ),
314
+ 'title' => __('Photo Gallery options', 'bwg_back'),
315
+ 'selector' => '#ed_options',
316
+ 'edge' => 'left',
317
+ 'align' => 'left',
318
+ 'tooltip_class' => 'option_class'
319
+ ),
320
+ 'galleries' => array(
321
+ 'page' => 'admin.php?page=galleries_bwg',
322
+ 'buttons' => array(),
323
+ 'title' => __('Add a Gallery', 'bwg_back'),
324
+ 'selector' => '#galleries_id',
325
+ 'edge' => 'left',
326
+ 'align' => 'left',
327
+ 'tooltip_class' => 'bwg_photo_galleries'
328
+ ),
329
+ 'Add_image' => array(
330
+ 'page' => 'admin.php?page=galleries_bwg',
331
+ 'buttons' => array(
332
+ 'next_page' => array(
333
+ 'title' => __('Next', 'bwg_back'),
334
+ 'url' => 'admin.php?page=galleries_bwg'
335
+ )
336
  ),
337
+ 'title' => __('Add images', 'bwg_back'),
338
+ 'selector' => '#add_image_bwg',
339
+ 'edge' => 'top',
340
+ 'align' => 'left',
341
+ 'tooltip_class' => 'bwg_add_img',
342
+ //'scroll' => '#add_image_bwg',
343
+ 'close_on_click' => true
344
+ ),
345
+ 'upload_image' => array(
346
+ 'page' => 'upload_image.php',
347
+ 'buttons' => array(
348
+ 'next_pointer' => array(
349
+ 'title' => __('Next', 'bwg_back'),
350
+ 'pointer_id' => 'choose_file'
351
+ )
 
352
  ),
353
+ 'title' => __('Upload Images', 'bwg_back'),
354
+ 'selector' => '#upload_images',
355
+ 'edge' => 'top',
356
+ 'align' => 'left',
357
+ 'tooltip_class' => 'bwg_upload_img',
358
+ 'target_delayed' => true,
359
+ 'show_on_event' => 'onUpload',
360
+ 'close_on_click' => true,
361
+ ),
362
+ 'choose_file' => array(
363
+ 'page' => 'upload_image.php',
364
+ 'buttons' => array(
365
+ 'next_pointer' => array(
366
+ 'title' => __('Next', 'bwg_back'),
367
+ 'pointer_id' => 'select_all_img'
368
+ )
369
  ),
370
+ 'title' => __('Choose file', 'bwg_back'),
371
+ 'selector' => '#jQueryUploader',
372
+ 'edge' => 'top',
373
+ 'align' => 'left',
374
+ 'close_on_click' => true,
375
+ 'target_delayed' => true
376
+ ),
377
+ 'select_all_img' => array(
378
+ 'page' => 'upload_image.php',
379
+ 'buttons' => array(
380
+ 'next_pointer' => array(
381
+ 'title' => __('Next', 'bwg_back'),
382
+ 'pointer_id' => 'add_selected_images'
383
+ )
 
 
 
 
 
 
 
 
 
 
 
384
  ),
385
+ 'title' => __('Select Images', 'bwg_back'),
386
+ 'content' => 'description',
387
+ 'selector' => '#select_all_images',
388
+ 'edge' => 'left',
389
+ 'align' => 'center',
390
+ 'tooltip_class' => 'bwg_select_img',
391
+ 'show_on_event' => 'onSelectAllImage',
392
+ 'hide_on_event' => 'onUploadFilesPressed',
393
+ ),
394
+ 'add_selected_images' => array(
395
+ 'page' => 'upload_image.php',
396
+ 'buttons' => array(
397
+ 'next_page' => array(
398
+ 'title' => __('Next', 'bwg_back'),
399
+ 'url' => 'admin.php?page=galleries_bwg',
400
+ 'scroll' => '#save_gall',
401
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
402
  ),
403
+ 'title' => __('Add Selected images to gallery', 'bwg_back'),
404
+ 'selector' => '#add_selectid_img',
405
+ 'edge' => 'bottom',
406
+ 'align' => 'left',
407
+ 'tooltip_class' => 'bwg_selected_img',
408
+ 'display' =>false,
409
+ ),
410
+ 'save_gallery' => array(
411
+ 'page' => 'admin.php?page=galleries_bwg',
412
+ 'buttons' => array(
413
+ 'next_page' => array(
414
+ 'title' => __('Next', 'bwg_back'),
415
+ 'url' => 'admin.php?page=albums_bwg'
416
+ )
417
  ),
418
+ 'title' => __('Save gallery', 'bwg_back'),
419
+ 'content' => 'description',
420
+ 'selector' => '#save_gall',
421
+ 'edge' => 'right',
422
+ 'align' => 'center',
423
+ 'tooltip_class' => 'bwg_gallery_save',
424
+ 'scroll' => '#save_gall',
425
+ 'show_on_event' => 'bwgImagesAdded',
426
+ ),
427
+ 'add_albums' => array(
428
+ 'page' => 'admin.php?page=albums_bwg',
429
+ 'buttons' => array(),
430
+ 'title' => __('Add album/gallery', 'bwg_back'),
431
+ 'selector' => '.add-new-h2',
432
+ 'edge' => 'left',
433
+ 'align' => 'left',
434
+ 'tooltip_class' => 'bwg_gallery_album',
435
+ ),
436
+ 'add_albums_gallery' => array(
437
+ 'page' => 'admin.php?page=albums_bwg',
438
+ 'buttons' => array(
439
+ 'next_page' => array(
440
+ 'title' => __('Next', 'bwg_back'),
441
+ 'url' => 'admin.php?page=albums_bwg',
442
+ )
443
  ),
444
+ 'title' => __('Add Albums/Galleries', 'bwg_back'),
445
+ 'content' => 'description',
446
+ 'selector' => '#content-add_media',
447
+ 'edge' => 'left',
448
+ 'align' => 'left',
449
+ 'tooltip_class' => 'bwg_add_gallery_album',
450
+ 'close_on_click' => true,
451
+ //'display' =>false
452
+ ),
453
+ 'check_all_album' => array(
454
+ 'page' => 'upload_image.php',
455
+ 'buttons' => array(
456
+ 'next_pointer' => array(
457
+ 'title' => __('Next', 'bwg_back'),
458
+ 'pointer_id' => 'add_album'
459
+ )
460
  ),
461
+ 'title' => __('Select album/gallery', 'bwg_back'),
462
+ 'content' => 'description',
463
+ 'selector' => '#check_all',
464
+ 'edge' => 'left',
465
+ 'align' => 'left',
466
+ 'tooltip_class' => 'select_all_album'
467
+ ),
468
+ 'add_album' => array(
469
+ 'page' => 'upload_image.php',
470
+ 'buttons' => array(
471
+ 'next_page' => array(
472
+ 'title' => __('Next', 'bwg_back'),
473
+ 'url' => 'upload_image.php'
474
+ )
 
475
  ),
476
+ 'title' => __('Choosing Galleries/Albums', 'bwg_back'),
477
+ 'content' => 'description',
478
+ 'selector' => '#add_albums',
479
+ 'edge' => 'top',
480
+ 'tooltip_class' => 'bwg_add_album_bwg',
481
+ 'align' => 'right',
482
+ 'display' => false
483
+ ),
484
+ 'save_album' => array(
485
+ 'page' => 'admin.php?page=albums_bwg',
486
+ 'buttons' => array(
487
+ 'next_page' => array(
488
+ 'title' => __('Next', 'bwg_back'),
489
+ 'url' => 'edit.php?post_type=page'
490
+ )
491
  ),
492
+ 'title' => __('Save Album', 'bwg_back'),
493
+ 'content' => 'description',
494
+ 'selector' => '#save_albums',
495
+ 'edge' => 'right',
496
+ 'align' => 'left',
497
+ 'tooltip_class' => 'bwg_album_save',
498
+ 'scroll' =>'#save_albums',
499
+ 'show_on_event' => 'onAddAlbum',
500
+ ),
501
+ 'show_page_gallery_album' => array(
502
+ 'page' => $Page_url,
503
+ 'buttons' => array(
504
+ 'next_page' => array(
505
+ 'title' => __('Next', 'bwg_back'),
506
+ 'url' => 'edit.php?post_type=page'
507
+ )
508
  ),
509
+ 'title' => __('Add New Page', 'bwg_back'),
510
+ 'content' => 'description',
511
+ 'selector' => '.dashicons-admin-page',
512
+ 'edge' => 'left',
513
+ 'align' => 'left',
514
+ 'scroll' => '.dashicons-admin-page',
515
+ 'tooltip_class' => 'show_page',
516
+ ),
517
+ 'add-page' => array(
518
+ 'page' => 'edit.php?post_type=page',
519
+ 'buttons' => array(),
520
+ 'title' => __('Add Page', 'bwg_back'),
521
+ 'selector' => '.page-title-action',
522
+ 'edge' => 'top',
523
+ 'align' => 'left',
524
+ ),
525
+ 'add-shortcode-gallery' => array(
526
+ 'page' => 'post-new.php?post_type=page',
527
  'buttons' => array(
528
+ 'next_pointer' => array(
529
+ 'title' => __('Next', 'bwg_back'),
530
+ 'pointer_id' => 'add-shortcode'
531
+ )
532
  ),
533
+ 'title' => __('Insert Shortcode', 'bwg_back'),
534
+ 'selector' => '#mceu_bwg_shorcode',
535
+ 'edge' => 'bottom',
536
  'align' => 'left',
537
+ 'close_on_click' =>true,
538
+ 'show_on_event' => 'onUploadImg',
539
+ 'tooltip_class' =>'add_short_gall'
540
+ ),
541
+ 'shortcode_gallery_bwg' => array(
542
+ 'page' => 'upload_image.php',
543
+ 'buttons' => array(
544
+ 'next_pointer' => array(
545
+ 'title' => __('Next', 'bwg_back'),
546
+ 'pointer_id' => 'theme_shortcode'
547
+ )
548
  ),
549
+ 'title' => __('Choose View', 'bwg_back'),
550
+ 'selector' => '#display_thumb',
551
+ 'edge' => 'top',
552
+ 'align' => 'left',
553
+ 'show_on_event' => 'onUploadShortcode'
554
+ ),
555
+ 'theme_shortcode' => array(
556
+ 'page' => 'upload_image.php',
557
+ 'buttons' => array(
558
+ 'next_pointer' => array(
559
+ 'title' => __('Next', 'bwg_back'),
560
+ 'pointer_id' => 'laytbox_shortcode'
561
+ )
 
 
562
  ),
563
+ 'title' => __('Select gallery', 'bwg_back'),
564
+ 'selector' => '#gallery',
565
+ 'edge' => 'left',
566
+ 'align' => 'center',
567
+ 'display'=> false,
568
+ 'tooltip_class' => 'theme_short',
569
+ 'show_on_event' => 'onUploadShortcode',
570
+ ),
571
+ 'laytbox_shortcode' => array(
572
+ 'page' => 'upload_image.php',
573
+ 'buttons' => array(
574
+ 'next_pointer' => array(
575
+ 'title' => __('Next', 'bwg_back'),
576
+ 'pointer_id' => 'insert_shortcode',
577
+ 'scroll' =>'#insert'
578
+ )
579
  ),
580
+ 'title' => __('Ligthbox settings', 'bwg_back'),
581
+ 'selector' => '#tbody_popup_other',
582
+ 'edge' => 'left',
583
+ 'align' => 'center',
584
+ 'display'=> false
585
+ ),
586
+ 'insert_shortcode' => array(
587
+ 'page' => 'upload_image.php',
588
+ 'buttons' => array(
589
+ 'next_page' => array(
590
+ 'title' => __('Next', 'bwg_back'),
591
+ 'url' => 'post-new.php?post_type=page'
592
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
593
  ),
594
+ 'title' => __('Insert Shortcode', 'bwg_back'),
595
+ 'selector' => '#insert',
596
+ 'edge' => 'bottom',
597
+ 'align' => 'right',
598
+ 'tooltip_class' => 'bwg_insert_short',
599
+ 'show_on_event' => 'onUploadShortcode',
600
+ 'display'=> false
601
+ ),
602
+ 'add-shortcode' => array(
603
+ 'page' => 'post-new.php?post_type=page',
604
+ 'buttons' => array(
605
+ 'next_page' => array(
606
+ 'title' => __('Next', 'bwg_back'),
607
+ 'url' => 'post-new.php?post_type=page'
608
+ )
609
  ),
610
+ 'title' => __('Publish Page', 'bwg_back'),
611
+ 'selector' => '#publishing-action',
612
+ 'edge' => 'right',
613
+ 'align' => 'left',
614
+ 'show_on_event' => 'onOpenShortcode'
615
+ ),
616
+ );
617
+ }
618
  }
js/bwg.js CHANGED
@@ -18,7 +18,6 @@ function save_tag(tag_id) {
18
  var slug = jQuery('input[name=slug'+tag_id+']').val();
19
  var datas = "tagname="+tagname+"&"+"slug="+slug+"&"+"tag_id="+tag_id;
20
  var td_check,td_name,td_slug,td_count,td_edit,td_delete,massege;
21
-
22
  jQuery.ajax({
23
  type: "POST",
24
  url: ajax_url + "=bwg_edit_tag",
@@ -1082,7 +1081,6 @@ function bwg_is_instagram_gallery() {
1082
  }
1083
  }
1084
 
1085
-
1086
  /**
1087
  *
1088
  * @param reset:bool true if reset to standard in case of not empty
@@ -1276,4 +1274,68 @@ function bwg_change_tab(box) {
1276
  jQuery("#bwg_standart").css({'borderRight':'2px solid #E1E1E1'});
1277
  bwg_change_option_type(jQuery("#type").val());
1278
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1279
  }
18
  var slug = jQuery('input[name=slug'+tag_id+']').val();
19
  var datas = "tagname="+tagname+"&"+"slug="+slug+"&"+"tag_id="+tag_id;
20
  var td_check,td_name,td_slug,td_count,td_edit,td_delete,massege;
 
21
  jQuery.ajax({
22
  type: "POST",
23
  url: ajax_url + "=bwg_edit_tag",
1081
  }
1082
  }
1083
 
 
1084
  /**
1085
  *
1086
  * @param reset:bool true if reset to standard in case of not empty
1274
  jQuery("#bwg_standart").css({'borderRight':'2px solid #E1E1E1'});
1275
  bwg_change_option_type(jQuery("#type").val());
1276
  }
1277
+ }
1278
+
1279
+ /**
1280
+ * Open Wordpress media uploader.
1281
+ *
1282
+ * @param e
1283
+ * @param multiple
1284
+ */
1285
+ function spider_media_uploader(e, multiple) {
1286
+ if (typeof multiple == "undefined") {
1287
+ var multiple = false;
1288
+ }
1289
+ var custom_uploader;
1290
+ e.preventDefault();
1291
+ // If the uploader object has already been created, reopen the dialog.
1292
+ if (custom_uploader) {
1293
+ custom_uploader.open();
1294
+ }
1295
+
1296
+ custom_uploader = wp.media.frames.file_frame = wp.media({
1297
+ title: bwg_objectL10B.choose_images,
1298
+ library : { type : 'image'},
1299
+ button: { text: bwg_objectL10B.insert},
1300
+ multiple: multiple
1301
+ });
1302
+ // When a file is selected, grab the URL and set it as the text field's value
1303
+ custom_uploader.on('select', function() {
1304
+ if (multiple == false) {
1305
+ attachment = custom_uploader.state().get('selection').first().toJSON();
1306
+ }
1307
+ else {
1308
+ attachment = custom_uploader.state().get('selection').toJSON();
1309
+ }
1310
+
1311
+ var filesSelectedML = [];
1312
+ for (var image in attachment) {
1313
+ var image_url = attachment[image].url;
1314
+ image_url = image_url.replace(bwg_objectL10B.wp_upload_dir.baseurl + '/', '');
1315
+ filesSelectedML.push(image_url);
1316
+ }
1317
+ fileNamesML = filesSelectedML.join("**@**");
1318
+
1319
+ jQuery.ajax({
1320
+ url: bwg_objectL10B.ajax_url,
1321
+ method: "GET",
1322
+ data: {
1323
+ action : "bwg_UploadHandler",
1324
+ file_namesML : fileNamesML,
1325
+ import : 1,
1326
+ },
1327
+ dataType: "json"
1328
+ }).done(function( result ) {
1329
+ for (var i in result) {
1330
+ result[i].alt = attachment[i].alt ? attachment[i].alt : attachment[i].title;
1331
+ result[i].description = attachment[i].description;
1332
+ }
1333
+ bwg_add_image(result);
1334
+ }).fail(function( msg ) {
1335
+ alert(bwg_objectL10B.import_failed);
1336
+ });
1337
+ });
1338
+
1339
+ // Open the uploader dialog.
1340
+ custom_uploader.open();
1341
  }
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.40
8
  * Author: Photo Gallery Team
9
  * Author URI: https://web-dorado.com/
10
  * License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
@@ -48,7 +48,7 @@ $WD_BWG_UPLOAD_DIR = $wd_bwg_options->images_directory . '/photo-gallery';
48
  // Plugin menu.
49
  function bwg_options_panel() {
50
  $parent_slug = null;
51
- if( get_option( "bwg_subscribe_done" ) == 1 ) {
52
  add_menu_page('Photo Gallery', 'Photo Gallery', 'manage_options', 'galleries_bwg', 'bwg_gallery', WD_BWG_URL . '/images/icons/best-wordpress-gallery.png');
53
  $parent_slug = "galleries_bwg";
54
  }
@@ -163,9 +163,8 @@ function bwg_filemanager_ajax() {
163
  else {
164
  die('Access Denied');
165
  }
166
- global $wpdb;
167
  require_once(WD_BWG_DIR . '/framework/WDWLibrary.php');
168
- $page = WDWLibrary::get('action');
169
 
170
  if (($page != '') && (($page == 'addImages') || ($page == 'addMusic'))) {
171
  if (!WDWLibrary::verify_nonce($page)) {
@@ -174,16 +173,7 @@ function bwg_filemanager_ajax() {
174
  require_once(WD_BWG_DIR . '/filemanager/controller.php');
175
  $controller_class = 'FilemanagerController';
176
  $controller = new $controller_class();
177
- $addImages_ajax = WDWLibrary::get('addImages_ajax');
178
- if ($addImages_ajax == 'addImages_ajax') {
179
- $load_count = WDWLibrary::get('load_count');
180
- $images_list = $controller->get_images(intval($load_count));
181
- echo (json_encode($images_list, true));
182
- die;
183
- }
184
- else {
185
- $controller->execute(true, 1);
186
- }
187
  }
188
  }
189
 
@@ -326,7 +316,8 @@ function bwg_shortcode($params) {
326
  'watermark_type' => 'none',
327
  'load_more_image_count' => 15,
328
  'show_tag_box' => 0,
329
- 'show_gallery_description' => 0
 
330
  ), $params);
331
  break;
332
 
@@ -370,7 +361,8 @@ function bwg_shortcode($params) {
370
  'image_browser_title_enable' => 1,
371
  'image_browser_description_enable' => 1,
372
  'watermark_type' => 'none',
373
- 'show_gallery_description' => 0
 
374
  ), $params);
375
  break;
376
 
@@ -396,7 +388,8 @@ function bwg_shortcode($params) {
396
  'watermark_type' => 'none',
397
  'compuct_album_load_more_image_count' => 15,
398
  'compuct_albums_per_page_load_more' => 15,
399
- 'show_gallery_description' => 0
 
400
  ), $params);
401
  break;
402
 
@@ -422,7 +415,8 @@ function bwg_shortcode($params) {
422
  'watermark_type' => 'none',
423
  'extended_album_load_more_image_count' => 15,
424
  'extended_albums_per_page_load_more' => 15,
425
- 'show_gallery_description' => 0
 
426
  ), $params);
427
  break;
428
 
@@ -432,7 +426,7 @@ function bwg_shortcode($params) {
432
  die();
433
  }
434
  }
435
-
436
  shortcode_atts(array(
437
  'popup_fullscreen' => 0,
438
  'popup_autoplay' => 0,
@@ -504,12 +498,6 @@ add_shortcode('Best_Wordpress_Gallery', 'bwg_shortcode');
504
 
505
  $bwg = 0;
506
  function bwg_front_end($params) {
507
- // Disable Jetpack’s Photon module.
508
- $photon_removed = FALSE;
509
- if ( class_exists("Jetpack_Photon") && method_exists(Jetpack_Photon, "instance") ) {
510
- $photon_removed = remove_filter('image_downsize', array( Jetpack_Photon::instance(), 'filter_image_downsize' ));
511
- }
512
-
513
  require_once(WD_BWG_DIR . '/frontend/controllers/BWGController' . ucfirst($params['gallery_type']) . '.php');
514
  $controller_class = 'BWGController' . ucfirst($params['gallery_type']) . '';
515
  $controller = new $controller_class();
@@ -517,11 +505,6 @@ function bwg_front_end($params) {
517
  $controller->execute($params, 1, $bwg);
518
  $bwg++;
519
 
520
- // Enable Jetpack’s Photon module.
521
- if ( $photon_removed ) {
522
- add_filter( 'image_downsize', array( Jetpack_Photon::instance(), 'filter_image_downsize' ), 10, 3 );
523
- }
524
-
525
  return;
526
  }
527
 
@@ -706,6 +689,13 @@ function bwg_activate() {
706
  'thumb_title_font_weight' => 'bold',
707
  'thumb_title_margin' => '2px',
708
  'thumb_title_shadow' => '0px 0px 0px #888888',
 
 
 
 
 
 
 
709
 
710
  'page_nav_position' => 'bottom',
711
  'page_nav_align' => 'center',
@@ -834,6 +824,13 @@ function bwg_activate() {
834
  'album_compact_thumb_hover_effect' => 'scale',
835
  'album_compact_thumb_hover_effect_value' => '1.1',
836
  'album_compact_thumb_transition' => 0,
 
 
 
 
 
 
 
837
 
838
  'album_extended_thumb_margin' => 2,
839
  'album_extended_thumb_padding' => 0,
@@ -894,6 +891,13 @@ function bwg_activate() {
894
  'album_extended_desc_padding' => '2px',
895
  'album_extended_desc_more_color' => 'F2D22E',
896
  'album_extended_desc_more_size' => 12,
 
 
 
 
 
 
 
897
 
898
  'masonry_thumb_padding' => 4,
899
  'masonry_thumb_border_radius' => '0',
@@ -907,6 +911,13 @@ function bwg_activate() {
907
  'masonry_thumb_hover_effect' => 'scale',
908
  'masonry_thumb_hover_effect_value' => '1.1',
909
  'masonry_thumb_transition' => 0,
 
 
 
 
 
 
 
910
 
911
  'slideshow_cont_bg_color' => '000000',
912
  'slideshow_close_btn_transparent' => 100,
@@ -981,6 +992,13 @@ function bwg_activate() {
981
  'blog_style_share_buttons_color' => 'B3AFAF',
982
  'blog_style_share_buttons_bg_transparent' => 0,
983
  'blog_style_share_buttons_font_size' => 20,
 
 
 
 
 
 
 
984
 
985
  'image_browser_margin' => '2px auto',
986
  'image_browser_padding' => '4px',
@@ -1011,6 +1029,13 @@ function bwg_activate() {
1011
  'image_browser_full_bg_color' => 'F5F5F5',
1012
  'image_browser_full_transparent' => 90,
1013
  'image_browser_image_title_align' => 'top',
 
 
 
 
 
 
 
1014
 
1015
  'lightbox_info_pos' => 'top',
1016
  'lightbox_info_align' => 'right',
@@ -1085,6 +1110,13 @@ function bwg_activate() {
1085
  'album_masonry_thumb_hover_effect' => 'scale',
1086
  'album_masonry_thumb_hover_effect_value' => '1.1',
1087
  'album_masonry_thumb_transition' => 0,
 
 
 
 
 
 
 
1088
 
1089
  'mosaic_thumb_padding' => 4,
1090
  'mosaic_thumb_border_radius' => '0',
@@ -1103,6 +1135,13 @@ function bwg_activate() {
1103
  'mosaic_thumb_title_margin' => '2px',
1104
  'mosaic_thumb_title_shadow' => '0px 0px 0px #888888',
1105
  'mosaic_thumb_title_font_size' => 16,
 
 
 
 
 
 
 
1106
 
1107
  'carousel_cont_bg_color' => '000000',
1108
  'carousel_cont_btn_transparent' => 0,
@@ -1158,6 +1197,13 @@ function bwg_activate() {
1158
  'thumb_title_font_weight' => 'bold',
1159
  'thumb_title_margin' => '5px',
1160
  'thumb_title_shadow' => '',
 
 
 
 
 
 
 
1161
 
1162
  'page_nav_position' => 'bottom',
1163
  'page_nav_align' => 'center',
@@ -1286,6 +1332,13 @@ function bwg_activate() {
1286
  'album_compact_thumb_hover_effect' => 'rotate',
1287
  'album_compact_thumb_hover_effect_value' => '2deg',
1288
  'album_compact_thumb_transition' => 1,
 
 
 
 
 
 
 
1289
 
1290
  'album_extended_thumb_margin' => 2,
1291
  'album_extended_thumb_padding' => 4,
@@ -1346,6 +1399,13 @@ function bwg_activate() {
1346
  'album_extended_desc_padding' => '2px',
1347
  'album_extended_desc_more_color' => 'FFC933',
1348
  'album_extended_desc_more_size' => 12,
 
 
 
 
 
 
 
1349
 
1350
  'masonry_thumb_padding' => 4,
1351
  'masonry_thumb_border_radius' => '2px',
@@ -1359,6 +1419,13 @@ function bwg_activate() {
1359
  'masonry_thumb_hover_effect' => 'rotate',
1360
  'masonry_thumb_hover_effect_value' => '2deg',
1361
  'masonry_thumb_transition' => 0,
 
 
 
 
 
 
 
1362
 
1363
  'slideshow_cont_bg_color' => '000000',
1364
  'slideshow_close_btn_transparent' => 100,
@@ -1433,6 +1500,14 @@ function bwg_activate() {
1433
  'blog_style_share_buttons_color' => 'A1A1A1',
1434
  'blog_style_share_buttons_bg_transparent' => 0,
1435
  'blog_style_share_buttons_font_size' => 20,
 
 
 
 
 
 
 
 
1436
 
1437
  'image_browser_margin' => '2px auto',
1438
  'image_browser_padding' => '4px',
@@ -1463,6 +1538,13 @@ function bwg_activate() {
1463
  'image_browser_full_bg_color' => 'FFFFFF',
1464
  'image_browser_full_transparent' => 90,
1465
  'image_browser_image_title_align' => 'top',
 
 
 
 
 
 
 
1466
 
1467
  'lightbox_info_pos' => 'top',
1468
  'lightbox_info_align' => 'right',
@@ -1537,6 +1619,13 @@ function bwg_activate() {
1537
  'album_masonry_thumb_hover_effect' => 'rotate',
1538
  'album_masonry_thumb_hover_effect_value' => '2deg',
1539
  'album_masonry_thumb_transition' => 1,
 
 
 
 
 
 
 
1540
 
1541
  'mosaic_thumb_padding' => 4,
1542
  'mosaic_thumb_border_radius' => '2px',
@@ -1555,6 +1644,13 @@ function bwg_activate() {
1555
  'mosaic_thumb_title_margin' => '2px',
1556
  'mosaic_thumb_title_shadow' => '0px 0px 0px #888888',
1557
  'mosaic_thumb_title_font_size' => 16,
 
 
 
 
 
 
 
1558
 
1559
  'carousel_cont_bg_color' => '000000',
1560
  'carousel_cont_btn_transparent' => 0,
@@ -1605,7 +1701,7 @@ function bwg_activate() {
1605
  ));
1606
  }
1607
  $version = get_option('wd_bwg_version');
1608
- $new_version = '1.3.40';
1609
  if ($version && version_compare($version, $new_version, '<')) {
1610
  require_once WD_BWG_DIR . "/update/bwg_update.php";
1611
  bwg_update($version);
@@ -1657,7 +1753,7 @@ wp_oembed_add_provider( '#https://instagr(\.am|am\.com)/p/.*#i', 'https://api.in
1657
 
1658
  function bwg_update_hook() {
1659
  $version = get_option('wd_bwg_version');
1660
- $new_version = '1.3.40';
1661
  if ($version && version_compare($version, $new_version, '<')) {
1662
  require_once WD_BWG_DIR . "/update/bwg_update.php";
1663
  bwg_update($version);
@@ -1702,37 +1798,43 @@ function bwg_styles() {
1702
 
1703
  // Plugin scripts.
1704
  function bwg_scripts() {
 
1705
  wp_enqueue_script('thickbox');
1706
  wp_enqueue_script('bwg_admin', WD_BWG_URL . '/js/bwg.js', array(), wd_bwg_version());
1707
  wp_localize_script('bwg_admin', 'bwg_objectL10B', array(
1708
- 'bwg_field_required' => __('field is required.', 'bwg_back'),
1709
- 'bwg_select_image' => __('You must select an image file.', 'bwg_back'),
1710
- 'bwg_select_audio' => __('You must select an audio file.', 'bwg_back'),
1711
- 'bwg_client_id' => __('You do not have Instagram CLIENT_ID. Input its value in Options->Embed options. ', 'bwg_back'),
1712
- 'bwg_post_number' => __('Instagram recent post number must be between 1 and 33.', 'bwg_back'),
1713
- 'bwg_not_empty' => __('The gallery is not empty. Please delete all the images first.', 'bwg_back'),
1714
- 'bwg_enter_url' => __('Please enter url to embed.', 'bwg_back'),
1715
- 'bwg_cannot_response' => __('Error: cannot get response from the server.', 'bwg_back'),
1716
- 'bwg_something_wrong' => __('Error: something wrong happened at the server.', 'bwg_back'),
1717
- 'bwg_error' => __('Error', 'bwg_back'),
1718
- 'bwg_show_order' => __('Show order column', 'bwg_back'),
1719
- 'bwg_hide_order' => __('Hide order column', 'bwg_back'),
1720
- 'selected' => __('Selected', 'bwg_back'),
1721
- 'item' => __('item', 'bwg_back'),
1722
- 'saved' => __('Items Succesfully Saved.', 'bwg_back'),
1723
- 'recovered' => __('Item Succesfully Recovered.', 'bwg_back'),
1724
- 'published' => __('Item Succesfully Published.', 'bwg_back'),
1725
- 'unpublished' => __('Item Succesfully Unpublished.', 'bwg_back'),
1726
- 'deleted' => __('Item Succesfully Deleted.', 'bwg_back'),
1727
- 'one_item' => __('You must select at least one item.', 'bwg_back'),
1728
- 'resized' => __('Items Succesfully resized.', 'bwg_back'),
1729
- 'watermark_set' => __('Watermarks Succesfully Set.', 'bwg_back'),
1730
- 'reset' => __('Items Succesfully Reset.', 'bwg_back'),
1731
  'save_tag' => __('Save Tag', 'bwg_back'),
1732
  'delete_alert' => __('Do you want to delete selected items?', 'bwg_back'),
1733
  'default_warning' => __('This action will reset gallery type to mixed and will save that choice. You cannot undo it.', 'bwg_back'),
1734
  'change_warning' => __('After pressing save/apply buttons, you cannot change gallery type back to Instagram!', 'bwg_back'),
1735
- 'other_warning' => __('This action will reset gallery type to mixed and will save that choice. You cannot undo it.', 'bwg_back')
 
 
 
 
 
1736
  ));
1737
 
1738
  global $wp_scripts;
@@ -1885,7 +1987,7 @@ function bwg_options_scripts() {
1885
 
1886
  wp_localize_script( 'bwg-deactivate-popup', 'bwgWDDeactivateVars', array(
1887
  "prefix" => "bwg" ,
1888
- "deactivate_class" => 'bwg_deactivate_link',
1889
  "email" => $admin_data->data->user_email,
1890
  "plugin_wd_url" => "https://web-dorado.com/products/wordpress-photo-gallery-plugin.html",
1891
  ));
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.41
8
  * Author: Photo Gallery Team
9
  * Author URI: https://web-dorado.com/
10
  * License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
48
  // Plugin menu.
49
  function bwg_options_panel() {
50
  $parent_slug = null;
51
+ if ( get_option( "bwg_subscribe_done" ) == 1 ) {
52
  add_menu_page('Photo Gallery', 'Photo Gallery', 'manage_options', 'galleries_bwg', 'bwg_gallery', WD_BWG_URL . '/images/icons/best-wordpress-gallery.png');
53
  $parent_slug = "galleries_bwg";
54
  }
163
  else {
164
  die('Access Denied');
165
  }
 
166
  require_once(WD_BWG_DIR . '/framework/WDWLibrary.php');
167
+ $page = WDWLibrary::get('action');
168
 
169
  if (($page != '') && (($page == 'addImages') || ($page == 'addMusic'))) {
170
  if (!WDWLibrary::verify_nonce($page)) {
173
  require_once(WD_BWG_DIR . '/filemanager/controller.php');
174
  $controller_class = 'FilemanagerController';
175
  $controller = new $controller_class();
176
+ $controller->execute();
 
 
 
 
 
 
 
 
 
177
  }
178
  }
179
 
316
  'watermark_type' => 'none',
317
  'load_more_image_count' => 15,
318
  'show_tag_box' => 0,
319
+ 'show_gallery_description' => 0,
320
+ 'showthumbs_name' => 0,
321
  ), $params);
322
  break;
323
 
361
  'image_browser_title_enable' => 1,
362
  'image_browser_description_enable' => 1,
363
  'watermark_type' => 'none',
364
+ 'show_gallery_description' => 0,
365
+ 'showthumbs_name' => 0,
366
  ), $params);
367
  break;
368
 
388
  'watermark_type' => 'none',
389
  'compuct_album_load_more_image_count' => 15,
390
  'compuct_albums_per_page_load_more' => 15,
391
+ 'show_gallery_description' => 0,
392
+ 'show_album_name' => 0,
393
  ), $params);
394
  break;
395
 
415
  'watermark_type' => 'none',
416
  'extended_album_load_more_image_count' => 15,
417
  'extended_albums_per_page_load_more' => 15,
418
+ 'show_gallery_description' => 0,
419
+ 'show_album_name' => 0,
420
  ), $params);
421
  break;
422
 
426
  die();
427
  }
428
  }
429
+
430
  shortcode_atts(array(
431
  'popup_fullscreen' => 0,
432
  'popup_autoplay' => 0,
498
 
499
  $bwg = 0;
500
  function bwg_front_end($params) {
 
 
 
 
 
 
501
  require_once(WD_BWG_DIR . '/frontend/controllers/BWGController' . ucfirst($params['gallery_type']) . '.php');
502
  $controller_class = 'BWGController' . ucfirst($params['gallery_type']) . '';
503
  $controller = new $controller_class();
505
  $controller->execute($params, 1, $bwg);
506
  $bwg++;
507
 
 
 
 
 
 
508
  return;
509
  }
510
 
689
  'thumb_title_font_weight' => 'bold',
690
  'thumb_title_margin' => '2px',
691
  'thumb_title_shadow' => '0px 0px 0px #888888',
692
+ 'thumb_gal_title_font_color' => 'CCCCCC',
693
+ 'thumb_gal_title_font_style' => 'segoe ui',
694
+ 'thumb_gal_title_font_size' => 16,
695
+ 'thumb_gal_title_font_weight' => 'bold',
696
+ 'thumb_gal_title_margin' => '2px',
697
+ 'thumb_gal_title_shadow' => '0px 0px 0px #888888',
698
+ 'thumb_gal_title_align' => 'center',
699
 
700
  'page_nav_position' => 'bottom',
701
  'page_nav_align' => 'center',
824
  'album_compact_thumb_hover_effect' => 'scale',
825
  'album_compact_thumb_hover_effect_value' => '1.1',
826
  'album_compact_thumb_transition' => 0,
827
+ 'album_compact_gal_title_font_color' => 'CCCCCC',
828
+ 'album_compact_gal_title_font_style' => 'segoe ui',
829
+ 'album_compact_gal_title_font_size' => 16,
830
+ 'album_compact_gal_title_font_weight' => 'bold',
831
+ 'album_compact_gal_title_margin' => '2px',
832
+ 'album_compact_gal_title_shadow' => '0px 0px 0px #888888',
833
+ 'album_compact_gal_title_align' => 'center',
834
 
835
  'album_extended_thumb_margin' => 2,
836
  'album_extended_thumb_padding' => 0,
891
  'album_extended_desc_padding' => '2px',
892
  'album_extended_desc_more_color' => 'F2D22E',
893
  'album_extended_desc_more_size' => 12,
894
+ 'album_extended_gal_title_font_color' => 'CCCCCC',
895
+ 'album_extended_gal_title_font_style' => 'segoe ui',
896
+ 'album_extended_gal_title_font_size' => 16,
897
+ 'album_extended_gal_title_font_weight' => 'bold',
898
+ 'album_extended_gal_title_margin' => '2px',
899
+ 'album_extended_gal_title_shadow' => '0px 0px 0px #888888',
900
+ 'album_extended_gal_title_align' => 'center',
901
 
902
  'masonry_thumb_padding' => 4,
903
  'masonry_thumb_border_radius' => '0',
911
  'masonry_thumb_hover_effect' => 'scale',
912
  'masonry_thumb_hover_effect_value' => '1.1',
913
  'masonry_thumb_transition' => 0,
914
+ 'masonry_thumb_gal_title_font_color' => 'CCCCCC',
915
+ 'masonry_thumb_gal_title_font_style' => 'segoe ui',
916
+ 'masonry_thumb_gal_title_font_size' => 16,
917
+ 'masonry_thumb_gal_title_font_weight' => 'bold',
918
+ 'masonry_thumb_gal_title_margin' => '2px',
919
+ 'masonry_thumb_gal_title_shadow' => '0px 0px 0px #888888',
920
+ 'masonry_thumb_gal_title_align' => 'center',
921
 
922
  'slideshow_cont_bg_color' => '000000',
923
  'slideshow_close_btn_transparent' => 100,
992
  'blog_style_share_buttons_color' => 'B3AFAF',
993
  'blog_style_share_buttons_bg_transparent' => 0,
994
  'blog_style_share_buttons_font_size' => 20,
995
+ 'blog_style_gal_title_font_color' => 'CCCCCC',
996
+ 'blog_style_gal_title_font_style' => 'segoe ui',
997
+ 'blog_style_gal_title_font_size' => 16,
998
+ 'blog_style_gal_title_font_weight' => 'bold',
999
+ 'blog_style_gal_title_margin' => '2px',
1000
+ 'blog_style_gal_title_shadow' => '0px 0px 0px #888888',
1001
+ 'blog_style_gal_title_align' => 'center',
1002
 
1003
  'image_browser_margin' => '2px auto',
1004
  'image_browser_padding' => '4px',
1029
  'image_browser_full_bg_color' => 'F5F5F5',
1030
  'image_browser_full_transparent' => 90,
1031
  'image_browser_image_title_align' => 'top',
1032
+ 'image_browser_gal_title_font_color' => 'CCCCCC',
1033
+ 'image_browser_gal_title_font_style' => 'segoe ui',
1034
+ 'image_browser_gal_title_font_size' => 16,
1035
+ 'image_browser_gal_title_font_weight' => 'bold',
1036
+ 'image_browser_gal_title_margin' => '2px',
1037
+ 'image_browser_gal_title_shadow' => '0px 0px 0px #888888',
1038
+ 'image_browser_gal_title_align' => 'center',
1039
 
1040
  'lightbox_info_pos' => 'top',
1041
  'lightbox_info_align' => 'right',
1110
  'album_masonry_thumb_hover_effect' => 'scale',
1111
  'album_masonry_thumb_hover_effect_value' => '1.1',
1112
  'album_masonry_thumb_transition' => 0,
1113
+ 'album_masonry_gal_title_font_color' => 'CCCCCC',
1114
+ 'album_masonry_gal_title_font_style' => 'segoe ui',
1115
+ 'album_masonry_gal_title_font_size' => 16,
1116
+ 'album_masonry_gal_title_font_weight' => 'bold',
1117
+ 'album_masonry_gal_title_margin' => '2px',
1118
+ 'album_masonry_gal_title_shadow' => '0px 0px 0px #888888',
1119
+ 'album_masonry_gal_title_align' => 'center',
1120
 
1121
  'mosaic_thumb_padding' => 4,
1122
  'mosaic_thumb_border_radius' => '0',
1135
  'mosaic_thumb_title_margin' => '2px',
1136
  'mosaic_thumb_title_shadow' => '0px 0px 0px #888888',
1137
  'mosaic_thumb_title_font_size' => 16,
1138
+ 'mosaic_thumb_gal_title_font_color' => 'CCCCCC',
1139
+ 'mosaic_thumb_gal_title_font_style' => 'segoe ui',
1140
+ 'mosaic_thumb_gal_title_font_size' => 16,
1141
+ 'mosaic_thumb_gal_title_font_weight' => 'bold',
1142
+ 'mosaic_thumb_gal_title_margin' => '2px',
1143
+ 'mosaic_thumb_gal_title_shadow' => '0px 0px 0px #888888',
1144
+ 'mosaic_thumb_gal_title_align' => 'center',
1145
 
1146
  'carousel_cont_bg_color' => '000000',
1147
  'carousel_cont_btn_transparent' => 0,
1197
  'thumb_title_font_weight' => 'bold',
1198
  'thumb_title_margin' => '5px',
1199
  'thumb_title_shadow' => '',
1200
+ 'thumb_gal_title_font_color' => 'CCCCCC',
1201
+ 'thumb_gal_title_font_style' => 'segoe ui',
1202
+ 'thumb_gal_title_font_size' => 16,
1203
+ 'thumb_gal_title_font_weight' => 'bold',
1204
+ 'thumb_gal_title_margin' => '2px',
1205
+ 'thumb_gal_title_shadow' => '0px 0px 0px #888888',
1206
+ 'thumb_gal_title_align' => 'center',
1207
 
1208
  'page_nav_position' => 'bottom',
1209
  'page_nav_align' => 'center',
1332
  'album_compact_thumb_hover_effect' => 'rotate',
1333
  'album_compact_thumb_hover_effect_value' => '2deg',
1334
  'album_compact_thumb_transition' => 1,
1335
+ 'album_compact_gal_title_font_color' => 'CCCCCC',
1336
+ 'album_compact_gal_title_font_style' => 'segoe ui',
1337
+ 'album_compact_gal_title_font_size' => 16,
1338
+ 'album_compact_gal_title_font_weight' => 'bold',
1339
+ 'album_compact_gal_title_margin' => '2px',
1340
+ 'album_compact_gal_title_shadow' => '0px 0px 0px #888888',
1341
+ 'album_compact_gal_title_align' => 'center',
1342
 
1343
  'album_extended_thumb_margin' => 2,
1344
  'album_extended_thumb_padding' => 4,
1399
  'album_extended_desc_padding' => '2px',
1400
  'album_extended_desc_more_color' => 'FFC933',
1401
  'album_extended_desc_more_size' => 12,
1402
+ 'album_extended_gal_title_font_color' => 'CCCCCC',
1403
+ 'album_extended_gal_title_font_style' => 'segoe ui',
1404
+ 'album_extended_gal_title_font_size' => 16,
1405
+ 'album_extended_gal_title_font_weight' => 'bold',
1406
+ 'album_extended_gal_title_margin' => '2px',
1407
+ 'album_extended_gal_title_shadow' => '0px 0px 0px #888888',
1408
+ 'album_extended_gal_title_align' => 'center',
1409
 
1410
  'masonry_thumb_padding' => 4,
1411
  'masonry_thumb_border_radius' => '2px',
1419
  'masonry_thumb_hover_effect' => 'rotate',
1420
  'masonry_thumb_hover_effect_value' => '2deg',
1421
  'masonry_thumb_transition' => 0,
1422
+ 'masonry_thumb_gal_title_font_color' => 'CCCCCC',
1423
+ 'masonry_thumb_gal_title_font_style' => 'segoe ui',
1424
+ 'masonry_thumb_gal_title_font_size' => 16,
1425
+ 'masonry_thumb_gal_title_font_weight' => 'bold',
1426
+ 'masonry_thumb_gal_title_margin' => '2px',
1427
+ 'masonry_thumb_gal_title_shadow' => '0px 0px 0px #888888',
1428
+ 'masonry_thumb_gal_title_align' => 'center',
1429
 
1430
  'slideshow_cont_bg_color' => '000000',
1431
  'slideshow_close_btn_transparent' => 100,
1500
  'blog_style_share_buttons_color' => 'A1A1A1',
1501
  'blog_style_share_buttons_bg_transparent' => 0,
1502
  'blog_style_share_buttons_font_size' => 20,
1503
+ 'blog_style_image_title_align' => 'top',
1504
+ 'blog_style_gal_title_font_color' => 'CCCCCC',
1505
+ 'blog_style_gal_title_font_style' => 'segoe ui',
1506
+ 'blog_style_gal_title_font_size' => 16,
1507
+ 'blog_style_gal_title_font_weight' => 'bold',
1508
+ 'blog_style_gal_title_margin' => '2px',
1509
+ 'blog_style_gal_title_shadow' => '0px 0px 0px #888888',
1510
+ 'blog_style_gal_title_align' => 'center',
1511
 
1512
  'image_browser_margin' => '2px auto',
1513
  'image_browser_padding' => '4px',
1538
  'image_browser_full_bg_color' => 'FFFFFF',
1539
  'image_browser_full_transparent' => 90,
1540
  'image_browser_image_title_align' => 'top',
1541
+ 'image_browser_gal_title_font_color' => 'CCCCCC',
1542
+ 'image_browser_gal_title_font_style' => 'segoe ui',
1543
+ 'image_browser_gal_title_font_size' => 16,
1544
+ 'image_browser_gal_title_font_weight' => 'bold',
1545
+ 'image_browser_gal_title_margin' => '2px',
1546
+ 'image_browser_gal_title_shadow' => '0px 0px 0px #888888',
1547
+ 'image_browser_gal_title_align' => 'center',
1548
 
1549
  'lightbox_info_pos' => 'top',
1550
  'lightbox_info_align' => 'right',
1619
  'album_masonry_thumb_hover_effect' => 'rotate',
1620
  'album_masonry_thumb_hover_effect_value' => '2deg',
1621
  'album_masonry_thumb_transition' => 1,
1622
+ 'album_masonry_gal_title_font_color' => 'CCCCCC',
1623
+ 'album_masonry_gal_title_font_style' => 'segoe ui',
1624
+ 'album_masonry_gal_title_font_size' => 16,
1625
+ 'album_masonry_gal_title_font_weight' => 'bold',
1626
+ 'album_masonry_gal_title_margin' => '2px',
1627
+ 'album_masonry_gal_title_shadow' => '0px 0px 0px #888888',
1628
+ 'album_masonry_gal_title_align' => 'center',
1629
 
1630
  'mosaic_thumb_padding' => 4,
1631
  'mosaic_thumb_border_radius' => '2px',
1644
  'mosaic_thumb_title_margin' => '2px',
1645
  'mosaic_thumb_title_shadow' => '0px 0px 0px #888888',
1646
  'mosaic_thumb_title_font_size' => 16,
1647
+ 'mosaic_thumb_gal_title_font_color' => 'CCCCCC',
1648
+ 'mosaic_thumb_gal_title_font_style' => 'segoe ui',
1649
+ 'mosaic_thumb_gal_title_font_size' => 16,
1650
+ 'mosaic_thumb_gal_title_font_weight' => 'bold',
1651
+ 'mosaic_thumb_gal_title_margin' => '2px',
1652
+ 'mosaic_thumb_gal_title_shadow' => '0px 0px 0px #888888',
1653
+ 'mosaic_thumb_gal_title_align' => 'center',
1654
 
1655
  'carousel_cont_bg_color' => '000000',
1656
  'carousel_cont_btn_transparent' => 0,
1701
  ));
1702
  }
1703
  $version = get_option('wd_bwg_version');
1704
+ $new_version = '1.3.41';
1705
  if ($version && version_compare($version, $new_version, '<')) {
1706
  require_once WD_BWG_DIR . "/update/bwg_update.php";
1707
  bwg_update($version);
1753
 
1754
  function bwg_update_hook() {
1755
  $version = get_option('wd_bwg_version');
1756
+ $new_version = '1.3.41';
1757
  if ($version && version_compare($version, $new_version, '<')) {
1758
  require_once WD_BWG_DIR . "/update/bwg_update.php";
1759
  bwg_update($version);
1798
 
1799
  // Plugin scripts.
1800
  function bwg_scripts() {
1801
+ global $wd_bwg_options;
1802
  wp_enqueue_script('thickbox');
1803
  wp_enqueue_script('bwg_admin', WD_BWG_URL . '/js/bwg.js', array(), wd_bwg_version());
1804
  wp_localize_script('bwg_admin', 'bwg_objectL10B', array(
1805
+ 'bwg_field_required' => __('field is required.', 'bwg_back'),
1806
+ 'bwg_select_image' => __('You must select an image file.', 'bwg_back'),
1807
+ 'bwg_select_audio' => __('You must select an audio file.', 'bwg_back'),
1808
+ 'bwg_client_id' => __('You do not have Instagram CLIENT_ID. Input its value in Options->Embed options. ', 'bwg_back'),
1809
+ 'bwg_post_number' => __('Instagram recent post number must be between 1 and 33.', 'bwg_back'),
1810
+ 'bwg_not_empty' => __('The gallery is not empty. Please delete all the images first.', 'bwg_back'),
1811
+ 'bwg_enter_url' => __('Please enter url to embed.', 'bwg_back'),
1812
+ 'bwg_cannot_response' => __('Error: cannot get response from the server.', 'bwg_back'),
1813
+ 'bwg_something_wrong' => __('Error: something wrong happened at the server.', 'bwg_back'),
1814
+ 'bwg_error' => __('Error', 'bwg_back'),
1815
+ 'bwg_show_order' => __('Show order column', 'bwg_back'),
1816
+ 'bwg_hide_order' => __('Hide order column', 'bwg_back'),
1817
+ 'selected' => __('Selected', 'bwg_back'),
1818
+ 'item' => __('item', 'bwg_back'),
1819
+ 'saved' => __('Items Succesfully Saved.', 'bwg_back'),
1820
+ 'recovered' => __('Item Succesfully Recovered.', 'bwg_back'),
1821
+ 'published' => __('Item Succesfully Published.', 'bwg_back'),
1822
+ 'unpublished' => __('Item Succesfully Unpublished.', 'bwg_back'),
1823
+ 'deleted' => __('Item Succesfully Deleted.', 'bwg_back'),
1824
+ 'one_item' => __('You must select at least one item.', 'bwg_back'),
1825
+ 'resized' => __('Items Succesfully resized.', 'bwg_back'),
1826
+ 'watermark_set' => __('Watermarks Succesfully Set.', 'bwg_back'),
1827
+ 'reset' => __('Items Succesfully Reset.', 'bwg_back'),
1828
  'save_tag' => __('Save Tag', 'bwg_back'),
1829
  'delete_alert' => __('Do you want to delete selected items?', 'bwg_back'),
1830
  'default_warning' => __('This action will reset gallery type to mixed and will save that choice. You cannot undo it.', 'bwg_back'),
1831
  'change_warning' => __('After pressing save/apply buttons, you cannot change gallery type back to Instagram!', 'bwg_back'),
1832
+ 'other_warning' => __('This action will reset gallery type to mixed and will save that choice. You cannot undo it.', 'bwg_back'),
1833
+ 'insert' => __('Insert', 'bwg_back'),
1834
+ 'import_failed' => __('Failed to import images from media library', 'bwg_back'),
1835
+ 'wp_upload_dir' => wp_upload_dir(),
1836
+ 'ajax_url' => wp_nonce_url( admin_url('admin-ajax.php'), 'bwg_UploadHandler', 'bwg_nonce' ),
1837
+ 'uploads_url' => site_url() . '/' . $wd_bwg_options->images_directory . '/photo-gallery',
1838
  ));
1839
 
1840
  global $wp_scripts;
1987
 
1988
  wp_localize_script( 'bwg-deactivate-popup', 'bwgWDDeactivateVars', array(
1989
  "prefix" => "bwg" ,
1990
+ "deactivate_class" => 'bwg_deactivate_link',
1991
  "email" => $admin_data->data->user_email,
1992
  "plugin_wd_url" => "https://web-dorado.com/products/wordpress-photo-gallery-plugin.html",
1993
  ));
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://web-dorado.com/products/wordpress-photo-gallery-plugin.html
4
  Tags: gallery, photo gallery, image gallery, responsive gallery, wordpress gallery plugin, photo albums, gallery slider, gallery lightbox, wordpress photo gallery plugin, fullscreen gallery, watermarking, video gallery
5
  Requires at least: 3.4
6
  Tested up to: 4.7
7
- Stable tag: 1.3.40
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -188,6 +188,11 @@ To enable the feature of adding Media Library images, go to Photo Gallery > Opti
188
 
189
  == Changelog ==
190
 
 
 
 
 
 
191
  = 1.3.40 =
192
  * Fixed: Images in a column
193
 
4
  Tags: gallery, photo gallery, image gallery, responsive gallery, wordpress gallery plugin, photo albums, gallery slider, gallery lightbox, wordpress photo gallery plugin, fullscreen gallery, watermarking, video gallery
5
  Requires at least: 3.4
6
  Tested up to: 4.7
7
+ Stable tag: 1.3.41
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
188
 
189
  == Changelog ==
190
 
191
+ = 1.3.41 =
192
+ * Added: Possibility to add images from Wordpress Media Library.
193
+ * Fixed: Image info in lightbox with small effect duration.
194
+ * Changed: Effect duration now can be float.
195
+
196
  = 1.3.40 =
197
  * Fixed: Images in a column
198