Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager - Version 2.8.3

Version Description

Texts changed

Download this release

Release Info

Developer premiocommit
Plugin Icon wp plugin Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager
Version 2.8.3
Comparing to
See all releases

Code changes from version 2.8.2 to 2.8.3

folders.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Folders
4
  * Description: Organize your Media library, Pages, and Posts into folders. You can easily drag and drop items into directories and change the folders tree view.
5
- * Version: 2.8.2
6
  * Author: Premio
7
  * Author URI: https://premio.io/downloads/folders/
8
  * Text Domain: folders
@@ -24,7 +24,7 @@ if(!defined("WCP_FOLDER_URL")) {
24
  define('WCP_FOLDER_URL', plugin_dir_url(__FILE__));
25
  }
26
  if(!defined("WCP_FOLDER_VERSION")) {
27
- define('WCP_FOLDER_VERSION', "2.8.2");
28
  }
29
 
30
 
@@ -183,4 +183,4 @@ if(!function_exists('premio_folders_plugin_check_for_setting')) {
183
  }
184
 
185
  add_action( 'plugins_loaded', 'premio_folders_plugin_check_for_setting' );
186
- }
2
  /**
3
  * Plugin Name: Folders
4
  * Description: Organize your Media library, Pages, and Posts into folders. You can easily drag and drop items into directories and change the folders tree view.
5
+ * Version: 2.8.3
6
  * Author: Premio
7
  * Author URI: https://premio.io/downloads/folders/
8
  * Text Domain: folders
24
  define('WCP_FOLDER_URL', plugin_dir_url(__FILE__));
25
  }
26
  if(!defined("WCP_FOLDER_VERSION")) {
27
+ define('WCP_FOLDER_VERSION', "2.8.3");
28
  }
29
 
30
 
183
  }
184
 
185
  add_action( 'plugins_loaded', 'premio_folders_plugin_check_for_setting' );
186
+ }
includes/media.replace.php CHANGED
@@ -1,4 +1,11 @@
1
  <?php
 
 
 
 
 
 
 
2
  if ( ! defined( 'ABSPATH' ) ) exit;
3
 
4
  class folders_replace_media {
@@ -22,7 +29,7 @@ class folders_replace_media {
22
  if($this->is_enabled) {
23
 
24
  add_action('admin_menu', array($this, 'admin_menu'));
25
- //
26
  add_filter('media_row_actions', array($this, 'add_media_action'), 10, 2);
27
 
28
  add_action('add_meta_boxes', function () {
@@ -56,6 +63,13 @@ class folders_replace_media {
56
  add_action('admin_notices', array($this, 'admin_notices'));
57
  }
58
 
 
 
 
 
 
 
 
59
  public function admin_notices() {
60
  if(isset($_REQUEST['premio_message']) && $_REQUEST['premio_message'] == "success") { ?>
61
  <div class="notice notice-success is-dismissible">
@@ -158,6 +172,13 @@ class folders_replace_media {
158
  <?php }
159
  }
160
 
 
 
 
 
 
 
 
161
  public function change_file_name_box($post) { ?>
162
  <p class="upgrade-bottom">
163
  <label for="change_file_name"><input disabled type="checkbox" id="change_file_name" name="premio_change_file_name" value="yes"> <?php esc_html_e("Change file name according to title", "folders") ?></label>
@@ -168,6 +189,13 @@ class folders_replace_media {
168
  <?php
169
  }
170
 
 
 
 
 
 
 
 
171
  public function replace_media_file_script() {
172
  wp_enqueue_script('folders-replace-media', WCP_FOLDER_URL . 'assets/js/replace-file-name.js', array('jquery'), WCP_FOLDER_VERSION, true);
173
  wp_localize_script('folders-replace-media', 'replace_media_options', array(
@@ -203,7 +231,14 @@ class folders_replace_media {
203
  </style>';
204
  }
205
 
206
- public function attachment_replace_name_with_title($form_fields, $post)
 
 
 
 
 
 
 
207
  {
208
  $screen = null;
209
  if (function_exists('get_current_screen'))
@@ -211,19 +246,26 @@ class folders_replace_media {
211
  $screen = get_current_screen();
212
 
213
  if(! is_null($screen) && $screen->id == 'attachment') // hide on edit attachment screen.
214
- return $form_fields;
215
  }
216
 
217
- $form_fields["replace_file_name"] = array(
218
  "label" => esc_html__("Replace media", "folders"),
219
  "input" => "html",
220
  "html" => "<label for='attachment_title_{$post->ID}' data-post='{$post->ID}' data-nonce='".wp_create_nonce('change_attachment_title_'.$post->ID)."'><input id='attachment_title_{$post->ID}' type='checkbox' class='folder-replace-checkbox' value='{$post->ID}'>".esc_html__("Update file name with title")."</label><a href='".$this->upgradeLink."' target='_blank' style='background: {$this->button_color}; border-color: {$this->button_color}; color:#ffffff' type='button' class='button update-name-with-title' >".esc_html__("Upgrade to Pro", "folders")."</a>",
221
  "helps" => ""
222
  );
223
 
224
- return $form_fields;
225
  }
226
 
 
 
 
 
 
 
 
227
  public function folders_admin_css_and_js($page) {
228
  if($page == "media_page_folders-replace-media" || $page == "admin_page_folders-replace-media") {
229
  wp_enqueue_style('folders-media', plugin_dir_url(dirname(__FILE__)) . 'assets/css/replace-media.css', array(), WCP_FOLDER_VERSION);
@@ -231,6 +273,14 @@ class folders_replace_media {
231
  }
232
  }
233
 
 
 
 
 
 
 
 
 
234
  public function admin_menu() {
235
  add_submenu_page(null,
236
  esc_html__("Replace media", "folders"),
@@ -241,6 +291,14 @@ class folders_replace_media {
241
  );
242
  }
243
 
 
 
 
 
 
 
 
 
244
  public function folders_replace_media() {
245
  global $plugin_page;
246
  $action = isset($_GET['action']) ? sanitize_text_field($_GET['action']) : '';
@@ -265,6 +323,14 @@ class folders_replace_media {
265
  include_once dirname(dirname(__FILE__)) . WCP_DS . "/templates" . WCP_DS . "admin" . WCP_DS . "media-replace.php";
266
  }
267
 
 
 
 
 
 
 
 
 
268
  public function add_media_action($actions, $post) {
269
  if(!$this->is_enabled) {
270
  return array_merge($actions);
@@ -285,6 +351,14 @@ class folders_replace_media {
285
  return $actions;
286
  }
287
 
 
 
 
 
 
 
 
 
288
  public function getMediaReplaceURL($attach_id) {
289
  $url = admin_url( "upload.php");
290
  $url = add_query_arg(array(
@@ -297,6 +371,14 @@ class folders_replace_media {
297
  return $url;
298
  }
299
 
 
 
 
 
 
 
 
 
300
  public function replace_meta_box($post) {
301
  if (wp_attachment_is('image', $post->ID)) {
302
  $link = $this->getMediaReplaceURL($post->ID);
@@ -306,7 +388,15 @@ class folders_replace_media {
306
  }
307
  }
308
 
309
- public function attachment_editor($form_fields, $post)
 
 
 
 
 
 
 
 
310
  {
311
  $screen = null;
312
  if (function_exists('get_current_screen'))
@@ -314,18 +404,18 @@ class folders_replace_media {
314
  $screen = get_current_screen();
315
 
316
  if(! is_null($screen) && $screen->id == 'attachment') // hide on edit attachment screen.
317
- return $form_fields;
318
  }
319
  if (wp_attachment_is('image', $post->ID)) {
320
  $link = $this->getMediaReplaceURL( $post->ID );
321
- $form_fields["folders"] = array(
322
  "label" => esc_html__( "Replace media", "folders" ),
323
  "input" => "html",
324
  "html" => "<a style='background: {$this->button_color}; border-color: {$this->button_color}; color:#ffffff' href='" . $link . "' class='button-secondary'>" . esc_html__( "Upload a new file", "folders" ) . "</a>",
325
  "helps" => esc_html__( "Click on the button to replace the file with another file", "folders" )
326
  );
327
  } else {
328
- $form_fields["folders"] = array(
329
  "label" => esc_html__( "Replace media", "folders" ),
330
  "input" => "html",
331
  "html" => "<div style='border: solid 1px #c0c0c0; padding: 10px; border-radius: 2px; background: #ececec;'><a style='color: {$this->button_color}; font-weight: 500' target='_blank' href='" . $this->upgradeLink . "' >" . esc_html__( "Upgrade to Pro", "folders" ) . "</a> ".esc_html__( "to replace media files other than images", "folders" ) . "</div>",
@@ -333,9 +423,17 @@ class folders_replace_media {
333
  );
334
  }
335
 
336
- return $form_fields;
337
  }
338
 
 
 
 
 
 
 
 
 
339
  public function getFileSize($attachment_id) {
340
  $size = filesize( get_attached_file( $attachment_id ));
341
  if($size > 1000000) {
@@ -368,6 +466,14 @@ class folders_replace_media {
368
  public $is_new_image = 0;
369
  public $attachment_id;
370
 
 
 
 
 
 
 
 
 
371
  public function handle_folders_file_upload() {
372
  global $wpdb;
373
  if(isset($_FILES['new_media_file'])) {
@@ -547,6 +653,13 @@ class folders_replace_media {
547
  }
548
  }
549
 
 
 
 
 
 
 
 
550
  public function checkForFileName($fileName, $filePath, $postFix = 0) {
551
  $new_file_name = $fileName;
552
  if(!empty($postFix)) {
@@ -562,6 +675,14 @@ class folders_replace_media {
562
 
563
  public $replace_items = array();
564
 
 
 
 
 
 
 
 
 
565
  public function removeThumbImages() {
566
  if(!empty($this->old_image_meta) && isset($this->old_image_meta['sizes']) && !empty($this->upload_dir) && isset($this->upload_dir['path'])) {
567
  $path = $this->upload_dir['path'].DIRECTORY_SEPARATOR;
@@ -573,6 +694,14 @@ class folders_replace_media {
573
  }
574
  }
575
 
 
 
 
 
 
 
 
 
576
  public function searchAndReplace() {
577
  if (wp_attachment_is('image', $this->attachment_id)) {
578
  $this->is_new_image = 1;
@@ -626,6 +755,14 @@ class folders_replace_media {
626
  }
627
  }
628
 
 
 
 
 
 
 
 
 
629
  function replaceURL() {
630
  /* check in post content */
631
  $this->checkInPostContent();
@@ -641,6 +778,14 @@ class folders_replace_media {
641
  }
642
  }
643
 
 
 
 
 
 
 
 
 
644
  function checkInPostContent() {
645
  global $wpdb;
646
  $post_table = $wpdb->prefix."posts";
@@ -663,6 +808,14 @@ class folders_replace_media {
663
  }
664
  }
665
 
 
 
 
 
 
 
 
 
666
  function checkInOptions() {
667
  global $wpdb;
668
  $post_table = $wpdb->prefix."options";
@@ -685,6 +838,14 @@ class folders_replace_media {
685
  }
686
  }
687
 
 
 
 
 
 
 
 
 
688
  function checkInMetaData() {
689
  $tables = array(
690
  array(
@@ -731,21 +892,32 @@ class folders_replace_media {
731
  }
732
  }
733
 
734
- function findAndReplaceContent($content, $search, $replace, $in_deep = false) {
 
 
 
 
 
 
 
 
 
735
  $content = maybe_unserialize($content);
736
- $isJson = $this->isJSON($content);
737
 
 
 
738
  if ($isJson) {
739
  $content = json_decode($content);
740
  }
741
 
 
742
  if (is_string($content)) {
743
  $content = str_replace($search, $replace, $content);
744
  }
745
- else if(is_wp_error($content)) {
746
 
747
  }
748
- else if(is_array($content)) {
749
  foreach($content as $index => $value) {
750
  $content[$index] = $this->findAndReplaceContent($value, $search, $replace, true);
751
  if (is_string($index)) {
@@ -755,34 +927,51 @@ class folders_replace_media {
755
  }
756
  }
757
  }
758
- else if(is_object($content)) {
759
  foreach($content as $key => $value) {
760
  $content->{$key} = $this->findAndReplaceContent($value, $search, $replace, true);
761
  }
762
  }
763
 
764
- if ($isJson && $in_deep === false) {
765
  $content = json_encode($content, JSON_UNESCAPED_SLASHES);
766
  }
767
- else if($in_deep === false && (is_array($content) || is_object($content))) {
768
  $content = maybe_serialize($content);
769
  }
770
 
771
  return $content;
772
  }
773
 
 
 
 
 
 
 
 
 
774
  function changeArrayKey($array, $set) {
775
  if (is_array($array) && is_array($set)) {
776
- $newArr = array();
777
  foreach ($array as $k => $v) {
778
  $key = array_key_exists( $k, $set) ? $set[$k] : $k;
779
- $newArr[$key] = is_array($v) ? $this->changeArrayKey($v, $set) : $v;
780
  }
781
- return $newArr;
782
  }
783
  return $array;
784
  }
785
 
 
 
 
 
 
 
 
 
 
786
  function isJSON($content)
787
  {
788
  if (is_array($content) || is_object($content))
@@ -792,4 +981,4 @@ class folders_replace_media {
792
  return $json && $json != $content;
793
  }
794
  }
795
- $folders_replace_media = new folders_replace_media();
1
  <?php
2
+ /**
3
+ * Class Folders Replace Media
4
+ *
5
+ * @author : Premio <contact@premio.io>
6
+ * @license : GPL2
7
+ * */
8
+
9
  if ( ! defined( 'ABSPATH' ) ) exit;
10
 
11
  class folders_replace_media {
29
  if($this->is_enabled) {
30
 
31
  add_action('admin_menu', array($this, 'admin_menu'));
32
+
33
  add_filter('media_row_actions', array($this, 'add_media_action'), 10, 2);
34
 
35
  add_action('add_meta_boxes', function () {
63
  add_action('admin_notices', array($this, 'admin_notices'));
64
  }
65
 
66
+ /**
67
+ * Add admin notice
68
+ *
69
+ * @since 2.6.3
70
+ * @access public
71
+ *
72
+ */
73
  public function admin_notices() {
74
  if(isset($_REQUEST['premio_message']) && $_REQUEST['premio_message'] == "success") { ?>
75
  <div class="notice notice-success is-dismissible">
172
  <?php }
173
  }
174
 
175
+ /**
176
+ * Add Metabox to replace file name with title
177
+ *
178
+ * @since 2.6.3
179
+ * @access public
180
+ *
181
+ */
182
  public function change_file_name_box($post) { ?>
183
  <p class="upgrade-bottom">
184
  <label for="change_file_name"><input disabled type="checkbox" id="change_file_name" name="premio_change_file_name" value="yes"> <?php esc_html_e("Change file name according to title", "folders") ?></label>
189
  <?php
190
  }
191
 
192
+ /**
193
+ * Add Js and CSS files for replace file name with title
194
+ *
195
+ * @since 2.6.3
196
+ * @access public
197
+ *
198
+ */
199
  public function replace_media_file_script() {
200
  wp_enqueue_script('folders-replace-media', WCP_FOLDER_URL . 'assets/js/replace-file-name.js', array('jquery'), WCP_FOLDER_VERSION, true);
201
  wp_localize_script('folders-replace-media', 'replace_media_options', array(
231
  </style>';
232
  }
233
 
234
+ /**
235
+ * Replace file name with title
236
+ *
237
+ * @since 2.6.3
238
+ * @access public
239
+ *
240
+ */
241
+ public function attachment_replace_name_with_title($formFields, $post)
242
  {
243
  $screen = null;
244
  if (function_exists('get_current_screen'))
246
  $screen = get_current_screen();
247
 
248
  if(! is_null($screen) && $screen->id == 'attachment') // hide on edit attachment screen.
249
+ return $formFields;
250
  }
251
 
252
+ $formFields["replace_file_name"] = array(
253
  "label" => esc_html__("Replace media", "folders"),
254
  "input" => "html",
255
  "html" => "<label for='attachment_title_{$post->ID}' data-post='{$post->ID}' data-nonce='".wp_create_nonce('change_attachment_title_'.$post->ID)."'><input id='attachment_title_{$post->ID}' type='checkbox' class='folder-replace-checkbox' value='{$post->ID}'>".esc_html__("Update file name with title")."</label><a href='".$this->upgradeLink."' target='_blank' style='background: {$this->button_color}; border-color: {$this->button_color}; color:#ffffff' type='button' class='button update-name-with-title' >".esc_html__("Upgrade to Pro", "folders")."</a>",
256
  "helps" => ""
257
  );
258
 
259
+ return $formFields;
260
  }
261
 
262
+ /**
263
+ * Add Js and CSS files for replace file screen
264
+ *
265
+ * @since 2.6.3
266
+ * @access public
267
+ *
268
+ */
269
  public function folders_admin_css_and_js($page) {
270
  if($page == "media_page_folders-replace-media" || $page == "admin_page_folders-replace-media") {
271
  wp_enqueue_style('folders-media', plugin_dir_url(dirname(__FILE__)) . 'assets/css/replace-media.css', array(), WCP_FOLDER_VERSION);
273
  }
274
  }
275
 
276
+ /**
277
+ * Add file replace menu in admin
278
+ *
279
+ * @since 2.6.3
280
+ * @access public
281
+ * @return $string
282
+ *
283
+ */
284
  public function admin_menu() {
285
  add_submenu_page(null,
286
  esc_html__("Replace media", "folders"),
291
  );
292
  }
293
 
294
+ /**
295
+ * Add file replacement screen
296
+ *
297
+ * @since 2.6.3
298
+ * @access public
299
+ * @return $string
300
+ *
301
+ */
302
  public function folders_replace_media() {
303
  global $plugin_page;
304
  $action = isset($_GET['action']) ? sanitize_text_field($_GET['action']) : '';
323
  include_once dirname(dirname(__FILE__)) . WCP_DS . "/templates" . WCP_DS . "admin" . WCP_DS . "media-replace.php";
324
  }
325
 
326
+ /**
327
+ * Add action for file replacement
328
+ *
329
+ * @since 2.6.3
330
+ * @access public
331
+ * @return $actions
332
+ *
333
+ */
334
  public function add_media_action($actions, $post) {
335
  if(!$this->is_enabled) {
336
  return array_merge($actions);
351
  return $actions;
352
  }
353
 
354
+ /**
355
+ * Get URL for file Replacement
356
+ *
357
+ * @since 2.6.3
358
+ * @access public
359
+ * @return $url
360
+ *
361
+ */
362
  public function getMediaReplaceURL($attach_id) {
363
  $url = admin_url( "upload.php");
364
  $url = add_query_arg(array(
371
  return $url;
372
  }
373
 
374
+ /**
375
+ * Get file size
376
+ *
377
+ * @since 2.6.3
378
+ * @access public
379
+ * @return $size
380
+ *
381
+ */
382
  public function replace_meta_box($post) {
383
  if (wp_attachment_is('image', $post->ID)) {
384
  $link = $this->getMediaReplaceURL($post->ID);
388
  }
389
  }
390
 
391
+ /**
392
+ * Get file size
393
+ *
394
+ * @since 2.6.3
395
+ * @access public
396
+ * @return $size
397
+ *
398
+ */
399
+ public function attachment_editor($formFields, $post)
400
  {
401
  $screen = null;
402
  if (function_exists('get_current_screen'))
404
  $screen = get_current_screen();
405
 
406
  if(! is_null($screen) && $screen->id == 'attachment') // hide on edit attachment screen.
407
+ return $formFields;
408
  }
409
  if (wp_attachment_is('image', $post->ID)) {
410
  $link = $this->getMediaReplaceURL( $post->ID );
411
+ $formFields["folders"] = array(
412
  "label" => esc_html__( "Replace media", "folders" ),
413
  "input" => "html",
414
  "html" => "<a style='background: {$this->button_color}; border-color: {$this->button_color}; color:#ffffff' href='" . $link . "' class='button-secondary'>" . esc_html__( "Upload a new file", "folders" ) . "</a>",
415
  "helps" => esc_html__( "Click on the button to replace the file with another file", "folders" )
416
  );
417
  } else {
418
+ $formFields["folders"] = array(
419
  "label" => esc_html__( "Replace media", "folders" ),
420
  "input" => "html",
421
  "html" => "<div style='border: solid 1px #c0c0c0; padding: 10px; border-radius: 2px; background: #ececec;'><a style='color: {$this->button_color}; font-weight: 500' target='_blank' href='" . $this->upgradeLink . "' >" . esc_html__( "Upgrade to Pro", "folders" ) . "</a> ".esc_html__( "to replace media files other than images", "folders" ) . "</div>",
423
  );
424
  }
425
 
426
+ return $formFields;
427
  }
428
 
429
+ /**
430
+ * Get file size
431
+ *
432
+ * @since 2.6.3
433
+ * @access public
434
+ * @return $size
435
+ *
436
+ */
437
  public function getFileSize($attachment_id) {
438
  $size = filesize( get_attached_file( $attachment_id ));
439
  if($size > 1000000) {
466
  public $is_new_image = 0;
467
  public $attachment_id;
468
 
469
+
470
+ /**
471
+ * Upload file and Replace it
472
+ *
473
+ * @since 2.6.3
474
+ * @access public
475
+ *
476
+ */
477
  public function handle_folders_file_upload() {
478
  global $wpdb;
479
  if(isset($_FILES['new_media_file'])) {
653
  }
654
  }
655
 
656
+ /**
657
+ * Check for filename
658
+ *
659
+ * @since 2.6.3
660
+ * @access public
661
+ *
662
+ */
663
  public function checkForFileName($fileName, $filePath, $postFix = 0) {
664
  $new_file_name = $fileName;
665
  if(!empty($postFix)) {
675
 
676
  public $replace_items = array();
677
 
678
+
679
+ /**
680
+ * Check and Remove Thumb image in wp-content
681
+ *
682
+ * @since 2.6.3
683
+ * @access public
684
+ *
685
+ */
686
  public function removeThumbImages() {
687
  if(!empty($this->old_image_meta) && isset($this->old_image_meta['sizes']) && !empty($this->upload_dir) && isset($this->upload_dir['path'])) {
688
  $path = $this->upload_dir['path'].DIRECTORY_SEPARATOR;
694
  }
695
  }
696
 
697
+ /**
698
+ * Search and Replace files in Database
699
+ *
700
+ * @since 2.6.3
701
+ * @access public
702
+ * @return $string
703
+ *
704
+ */
705
  public function searchAndReplace() {
706
  if (wp_attachment_is('image', $this->attachment_id)) {
707
  $this->is_new_image = 1;
755
  }
756
  }
757
 
758
+ /**
759
+ * Replace URL in Database tables
760
+ *
761
+ * @since 2.6.3
762
+ * @access public
763
+ * @return $string
764
+ *
765
+ */
766
  function replaceURL() {
767
  /* check in post content */
768
  $this->checkInPostContent();
778
  }
779
  }
780
 
781
+ /**
782
+ * Checking image URLs in Post Content
783
+ *
784
+ * @since 2.6.3
785
+ * @access public
786
+ * @return $string
787
+ *
788
+ */
789
  function checkInPostContent() {
790
  global $wpdb;
791
  $post_table = $wpdb->prefix."posts";
808
  }
809
  }
810
 
811
+ /**
812
+ * Checking image URLs in MetaData
813
+ *
814
+ * @since 2.6.3
815
+ * @access public
816
+ * @return $string
817
+ *
818
+ */
819
  function checkInOptions() {
820
  global $wpdb;
821
  $post_table = $wpdb->prefix."options";
838
  }
839
  }
840
 
841
+ /**
842
+ * Checking image URLs in MetaData
843
+ *
844
+ * @since 2.6.3
845
+ * @access public
846
+ * @return $string
847
+ *
848
+ */
849
  function checkInMetaData() {
850
  $tables = array(
851
  array(
892
  }
893
  }
894
 
895
+ /**
896
+ * Checking for Array Key
897
+ *
898
+ * @since 2.6.3
899
+ * @access public
900
+ * @return $json
901
+ * Forked from Enable Media Replace
902
+ *
903
+ */
904
+ function findAndReplaceContent($content, $search, $replace, $depth = false) {
905
  $content = maybe_unserialize($content);
 
906
 
907
+ // Checking for JSON Data
908
+ $isJson = $this->isJSON($content);
909
  if ($isJson) {
910
  $content = json_decode($content);
911
  }
912
 
913
+ // Replace content if content is String
914
  if (is_string($content)) {
915
  $content = str_replace($search, $replace, $content);
916
  }
917
+ else if(is_wp_error($content)) { // Return if error in data
918
 
919
  }
920
+ else if(is_array($content)) { // Replace content if content is Array
921
  foreach($content as $index => $value) {
922
  $content[$index] = $this->findAndReplaceContent($value, $search, $replace, true);
923
  if (is_string($index)) {
927
  }
928
  }
929
  }
930
+ else if(is_object($content)) { // Replace content if content is Object
931
  foreach($content as $key => $value) {
932
  $content->{$key} = $this->findAndReplaceContent($value, $search, $replace, true);
933
  }
934
  }
935
 
936
+ if ($isJson && $depth === false) {
937
  $content = json_encode($content, JSON_UNESCAPED_SLASHES);
938
  }
939
+ else if($depth === false && (is_array($content) || is_object($content))) {
940
  $content = maybe_serialize($content);
941
  }
942
 
943
  return $content;
944
  }
945
 
946
+ /**
947
+ * Checking for Array Key
948
+ *
949
+ * @since 2.6.3
950
+ * @access public
951
+ * @return $json
952
+ *
953
+ */
954
  function changeArrayKey($array, $set) {
955
  if (is_array($array) && is_array($set)) {
956
+ $newArray = array();
957
  foreach ($array as $k => $v) {
958
  $key = array_key_exists( $k, $set) ? $set[$k] : $k;
959
+ $newArray[$key] = is_array($v) ? $this->changeArrayKey($v, $set) : $v;
960
  }
961
+ return $newArray;
962
  }
963
  return $array;
964
  }
965
 
966
+ /**
967
+ * Check if it is JSON or not
968
+ *
969
+ * @since 2.6.3
970
+ * @access public
971
+ * Forked from Enable Media Replace
972
+ * @return $json
973
+ *
974
+ */
975
  function isJSON($content)
976
  {
977
  if (is_array($content) || is_object($content))
981
  return $json && $json != $content;
982
  }
983
  }
984
+ $folders_replace_media = new folders_replace_media();
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: galdub, tomeraharon, premio
3
  Tags: folder, folders, replace media, pages folders, media library, posts folders, media folders, media replace, file manager, directories, media library folders, media library folder
4
  Requires at least: 3.0.0
5
  Tested up to: 6.0
6
- Stable tag: 2.8.2
7
  Plugin URI: https://premio.io/downloads/folders/
8
 
9
  Folders is a WordPress plugin that will help you quickly create unlimited folders and organize and manage your Media Library files, Pages & Posts in folders
@@ -95,6 +95,7 @@ It’s rather simple really – once you install the plugin, you can begin using
95
  = 🔁 Replace media files =
96
  With the Folders plugin, you can replace media library files with other files. This feature is a life-saver whenever you need to replace a media file on all of your pages, posts, etc. When you replace a media file, the change will reflect on all of your pages, posts, and more. Check out the media replace feature in action:
97
  [youtube https://www.youtube.com/watch?v=16MrxVo2EC4]
 
98
 
99
  = 👋 Import folders =
100
  You can import folders data from FileBird, Enhanced Media Library, Wicked Folders, Real Media Library, WP Media Folder, HappyFiles (Happy Files), and Mediamatic
@@ -198,6 +199,9 @@ A live demo for the Folders plugin is available at <a href="https://demo.premio.
198
 
199
  == Changelog ==
200
 
 
 
 
201
  = 2.8.2 =
202
  Keyboard shortcuts bugs fixed.
203
 
3
  Tags: folder, folders, replace media, pages folders, media library, posts folders, media folders, media replace, file manager, directories, media library folders, media library folder
4
  Requires at least: 3.0.0
5
  Tested up to: 6.0
6
+ Stable tag: 2.8.3
7
  Plugin URI: https://premio.io/downloads/folders/
8
 
9
  Folders is a WordPress plugin that will help you quickly create unlimited folders and organize and manage your Media Library files, Pages & Posts in folders
95
  = 🔁 Replace media files =
96
  With the Folders plugin, you can replace media library files with other files. This feature is a life-saver whenever you need to replace a media file on all of your pages, posts, etc. When you replace a media file, the change will reflect on all of your pages, posts, and more. Check out the media replace feature in action:
97
  [youtube https://www.youtube.com/watch?v=16MrxVo2EC4]
98
+ The media replacer code was forked from Enable Media Replace
99
 
100
  = 👋 Import folders =
101
  You can import folders data from FileBird, Enhanced Media Library, Wicked Folders, Real Media Library, WP Media Folder, HappyFiles (Happy Files), and Mediamatic
199
 
200
  == Changelog ==
201
 
202
+ = 2.8.3 =
203
+ Texts changed
204
+
205
  = 2.8.2 =
206
  Keyboard shortcuts bugs fixed.
207
 
templates/admin/media-replace.php CHANGED
@@ -38,10 +38,15 @@ if(isset($customize_folders['show_folder_in_settings']) && $customize_folders['s
38
  $upgradeURL = admin_url("admin.php?page=folders-upgrade-to-pro");
39
  }
40
  $current_date = date_i18n('d/M/Y H:i', strtotime($attachment->post_date) )
 
 
 
 
 
41
  ?>
42
  <div class="wrap">
43
  <h2><?php esc_html_e("Replace Media", "folders"); ?></h2>
44
- <form enctype="multipart/form-data" method="POST" action="<?php echo esc_url($form_action) ?>">
45
  <div class="replace-media-page">
46
  <p><b><?php esc_html_e("Current File", "folders") ?></b>: <?php echo esc_attr($file_name) ?></p>
47
  <p><?php esc_html_e("Upload a new file instead of the current one", "folders") ?></p>
@@ -100,39 +105,39 @@ $current_date = date_i18n('d/M/Y H:i', strtotime($attachment->post_date) )
100
  <div class="media-bottom-pro">
101
  <div class="media-bottom-box-left">
102
  <div class="media-setting">
103
- <div class="media-title"><?php esc_html_e("Replacement Options", "folders") ?></div>
104
  <div class="media-form">
105
  <div class="media-option">
106
- <label for="replace_only_file"><input type="radio" checked name="replacement_option" value="replace_only_file" id="replace_only_file" /> <?php esc_html_e("Just replace the file", "folders") ?></label>
107
  </div>
108
  <div class="media-note">
109
- <?php esc_html_e("Note: This option requires you to upload a file of the same type (png) as the one you are replacing. The name of the attachment will stay the same (image.png) no matter what the file you upload is called.", "folders"); ?>
110
  </div>
111
  <div class="media-option">
112
- <label for="replace_file_with_name"><input type="radio" name="replacement_option" value="replace_file_with_name" id="replace_file_with_name" /> <?php esc_html_e("Replace the file, use new file name and update all links", "folders") ?></label>
113
  </div>
114
  <div class="media-note">
115
- <?php esc_html_e("Note: If you check this option, the name and type of the file you are about to upload will replace the old file. All links pointing to the current file (image.png) will be updated to point to the new file name. (If any other websites link to the file directly, those links will no longer work. Be careful.)", "folders"); ?>
116
  </div>
117
  </div>
118
  </div>
119
  </div>
120
  <div class="media-bottom-box-right">
121
  <div class="media-setting">
122
- <div class="media-title"><?php esc_html_e("Date Options", "folders") ?></div>
123
  <div class="media-form">
124
  <div class="media-note">
125
- <?php esc_html_e("When replacing the media, do you want to:", "folders"); ?>
126
  </div>
127
  <ul>
128
  <li>
129
- <label for="replace_date"><input type="radio" name="date_options" value="replace_date" id="replace_date" /> <?php esc_html_e("Replace the date", "folders") ?></label>
130
  </li>
131
  <li>
132
- <label for="keep_date"><input type="radio" checked name="date_options" value="keep_date" id="keep_date" /> <?php esc_html_e("Keep the date", "folders") ?> <small>(<?php echo esc_attr($current_date) ?>)</small></label>
133
  </li>
134
  <li>
135
- <label for="select_custom_date"><input type="radio" name="date_options" value="custom_date" id="select_custom_date" /> <?php esc_html_e("Set a Custom Date", "folders") ?></label>
136
  </li>
137
  </ul>
138
  <div class="custom-date" id="custom-date">
38
  $upgradeURL = admin_url("admin.php?page=folders-upgrade-to-pro");
39
  }
40
  $current_date = date_i18n('d/M/Y H:i', strtotime($attachment->post_date) )
41
+
42
+ /*
43
+ * Forked from Enable Media Replace
44
+ *
45
+ * */
46
  ?>
47
  <div class="wrap">
48
  <h2><?php esc_html_e("Replace Media", "folders"); ?></h2>
49
+ <form enctype="multipart/form-data" method="POST" action="">
50
  <div class="replace-media-page">
51
  <p><b><?php esc_html_e("Current File", "folders") ?></b>: <?php echo esc_attr($file_name) ?></p>
52
  <p><?php esc_html_e("Upload a new file instead of the current one", "folders") ?></p>
105
  <div class="media-bottom-pro">
106
  <div class="media-bottom-box-left">
107
  <div class="media-setting">
108
+ <div class="media-title"><?php esc_html_e("Replace Files", "folders") ?></div>
109
  <div class="media-form">
110
  <div class="media-option">
111
+ <label for="replace_only_file"><input type="radio" checked name="replacement_option" value="replace_only_file" id="replace_only_file" /> <?php esc_html_e("Replace File Only", "folders") ?></label>
112
  </div>
113
  <div class="media-note">
114
+ <?php printf(esc_html__("%s Please upload a file with the same extension (jpg, jpeg, png etc). The file name will remain the same as the file being replaced.", "folders"), "<b>".esc_html__("Note:", "folders")."</b>" ); ?>
115
  </div>
116
  <div class="media-option">
117
+ <label for="replace_file_with_name"><input type="radio" name="replacement_option" value="replace_file_with_name" id="replace_file_with_name" /> <?php esc_html_e("Replace File and Update URLs with New File name", "folders") ?></label>
118
  </div>
119
  <div class="media-note">
120
+ <?php printf(esc_html__("%s After selecting this option, the new file name will be retained, and all the URLs pointing to the current file will be revised to the new file. If the file URL has been shared on external web pages, the links may not work.", "folders"), "<b>".esc_html__("Warning:", "folders")."</b>"); ?>
121
  </div>
122
  </div>
123
  </div>
124
  </div>
125
  <div class="media-bottom-box-right">
126
  <div class="media-setting">
127
+ <div class="media-title"><?php esc_html_e("File Date", "folders") ?></div>
128
  <div class="media-form">
129
  <div class="media-note">
130
+ <?php esc_html_e("After swapping the old file with the new one:", "folders"); ?>
131
  </div>
132
  <ul>
133
  <li>
134
+ <label for="replace_date"><input type="radio" name="date_options" value="replace_date" id="replace_date" /> <?php esc_html_e("Set the date of upload of the new file", "folders") ?></label>
135
  </li>
136
  <li>
137
+ <label for="keep_date"><input type="radio" checked name="date_options" value="keep_date" id="keep_date" /> <?php esc_html_e("Keep the old file's date of the upload", "folders") ?> <small>(<?php echo esc_attr($current_date) ?>)</small></label>
138
  </li>
139
  <li>
140
+ <label for="select_custom_date"><input type="radio" name="date_options" value="custom_date" id="select_custom_date" /> <?php esc_html_e("Set a date", "folders") ?></label>
141
  </li>
142
  </ul>
143
  <div class="custom-date" id="custom-date">