Media from FTP - Version 9.99

Version Description

Fixed fine problem.

Download this release

Release Info

Developer Katsushi Kawamori
Plugin Icon wp plugin Media from FTP
Version 9.99
Comparing to
See all releases

Code changes from version 9.98 to 9.99

inc/MediaFromFtp.php CHANGED
@@ -21,6 +21,12 @@
21
 
22
  class MediaFromFtp {
23
 
 
 
 
 
 
 
24
  private $is_add_on_activate;
25
 
26
  /* ==================================================
@@ -29,6 +35,15 @@ class MediaFromFtp {
29
  */
30
  function __construct() {
31
 
 
 
 
 
 
 
 
 
 
32
  $exif_active = FALSE;
33
  if( function_exists('media_from_ftp_add_on_exif_load_textdomain') ){
34
  $exif_active = TRUE;
@@ -245,9 +260,9 @@ class MediaFromFtp {
245
 
246
  $cash_thumb_key = md5($new_url);
247
  if ( strtolower($ext) === 'pdf' ) {
248
- $cash_thumb_filename = MEDIAFROMFTP_PLUGIN_TMP_DIR.'/'.$cash_thumb_key.'-pdf.jpg';
249
  } else {
250
- $cash_thumb_filename = MEDIAFROMFTP_PLUGIN_TMP_DIR.'/'.$cash_thumb_key.'.'.$ext;
251
  }
252
 
253
  $value_cash = get_transient( $cash_thumb_key );
@@ -269,24 +284,24 @@ class MediaFromFtp {
269
  $cash_thumb2->resize( 40 ,40, true );
270
  $cash_thumb2->save( $cash_thumb_filename );
271
  }
272
- $view_thumb_url = MEDIAFROMFTP_PLUGIN_TMP_URL.'/'.$cash_thumb_key.'-pdf.jpg';
273
  } else {
274
  $cash_thumb->resize( 40 ,40, true );
275
  $cash_thumb->save( $cash_thumb_filename );
276
- $view_thumb_url = MEDIAFROMFTP_PLUGIN_TMP_URL.'/'.$cash_thumb_key.'.'.$ext;
277
  }
278
  } else {
279
  $filetype2 = wp_ext2type($ext);
280
  if ( empty($filetype2) ) { $filetype2 = 'default'; }
281
- $view_thumb_url = MEDIAFROMFTP_PLUGIN_SITE_URL. WPINC . '/images/media/'.$filetype2.'.png';
282
  }
283
  } else {
284
  if ( file_exists( $cash_thumb_filename )) {
285
- $view_thumb_url = MEDIAFROMFTP_PLUGIN_TMP_URL.'/'.$cash_thumb_key.'.'.$ext;
286
  } else {
287
  $filetype2 = wp_ext2type($ext);
288
  if ( empty($filetype2) ) { $filetype2 = 'default'; }
289
- $view_thumb_url = MEDIAFROMFTP_PLUGIN_SITE_URL. WPINC . '/images/media/'.$filetype2.'.png';
290
  }
291
  }
292
  set_transient( $cash_thumb_key, $view_thumb_url, DAY_IN_SECONDS);
@@ -310,9 +325,9 @@ class MediaFromFtp {
310
  if ( wp_ext2type($ext) === 'image' || strtolower($ext) === 'pdf' ){
311
  $del_cash_thumb_key = md5($new_url_attach);
312
  if ( strtolower($ext) === 'pdf' ) {
313
- $del_cash_thumb_filename = MEDIAFROMFTP_PLUGIN_TMP_DIR.'/'.$del_cash_thumb_key.'-pdf.jpg';
314
  } else {
315
- $del_cash_thumb_filename = MEDIAFROMFTP_PLUGIN_TMP_DIR.'/'.$del_cash_thumb_key.'.'.$ext;
316
  }
317
  $value_del_cash = get_transient( $del_cash_thumb_key );
318
  if ( $value_del_cash <> FALSE ) {
@@ -333,7 +348,7 @@ class MediaFromFtp {
333
  function delete_all_cash(){
334
 
335
  global $wpdb;
336
- $search_transients = MEDIAFROMFTP_PLUGIN_TMP_URL;
337
  $del_transients = $wpdb->get_results("
338
  SELECT option_value
339
  FROM $wpdb->options
@@ -351,7 +366,7 @@ class MediaFromFtp {
351
  }
352
  }
353
 
354
- $del_cash_thumb_filename = MEDIAFROMFTP_PLUGIN_TMP_DIR.'/*.*';
355
  foreach ( glob($del_cash_thumb_filename) as $val ) {
356
  unlink($val);
357
  ++$del_cash_count;
@@ -410,8 +425,8 @@ class MediaFromFtp {
410
  $ext = end($exts);
411
  $suffix_file = '.'.$ext;
412
  $file = wp_normalize_path($file);
413
- $upload_path = wp_normalize_path(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR);
414
- $new_url = MEDIAFROMFTP_PLUGIN_UPLOAD_URL.str_replace($upload_path, '', $file);
415
  $new_titles = explode('/', $new_url);
416
  $new_title = str_replace($suffix_file, '', end($new_titles));
417
  $new_title_md5 = md5($new_title);
@@ -419,7 +434,7 @@ class MediaFromFtp {
419
  $new_file = TRUE;
420
  $new_url = $this->mb_utf8($new_url, $character_code);
421
  foreach ( $attachments as $attachment ){
422
- $attach_url = MEDIAFROMFTP_PLUGIN_UPLOAD_URL.'/'.get_post_meta( $attachment->ID, '_wp_attached_file', true );
423
  $pdf_thumb_url = rtrim($attach_url, '.pdf').'-pdf.jpg'; // for pdf thumbnail by imagick
424
  if ( $attach_url === $new_url || $attach_url === $new_url_md5 || $pdf_thumb_url === $new_url || $pdf_thumb_url === $new_url_md5 ) {
425
  $new_file = FALSE;
@@ -462,13 +477,13 @@ class MediaFromFtp {
462
  if ( wp_ext2type($ext) === 'image' || strtolower($ext) === 'pdf' ){
463
  $view_thumb_url = $this->create_cash($ext, $file, $new_url);
464
  } else if ( wp_ext2type($ext) === 'audio' ) {
465
- $view_thumb_url = MEDIAFROMFTP_PLUGIN_SITE_URL. WPINC . '/images/media/audio.png';
466
  $metadata_audio = wp_read_audio_metadata( $file );
467
  $file_size = size_format($metadata_audio['filesize']);
468
  $mimetype = $metadata_audio['fileformat'].'('.$metadata_audio['mime_type'].')';
469
  $length = $metadata_audio['length_formatted'];
470
  } else if ( wp_ext2type($ext) === 'video' ) {
471
- $view_thumb_url = MEDIAFROMFTP_PLUGIN_SITE_URL. WPINC . '/images/media/video.png';
472
  $metadata_video = wp_read_video_metadata( $file );
473
  $file_size = size_format($metadata_video['filesize']);
474
  $mimetype = $metadata_video['fileformat'].'('.$metadata_video['mime_type'].')';
@@ -476,7 +491,7 @@ class MediaFromFtp {
476
  } else {
477
  $filetype2 = wp_ext2type($ext);
478
  if ( empty($filetype2) ) { $filetype2 = 'default'; }
479
- $view_thumb_url = MEDIAFROMFTP_PLUGIN_SITE_URL. WPINC . '/images/media/'.$filetype2.'.png';
480
  }
481
  $input_html .= '<img width="40" height="40" src="'.$view_thumb_url.'" style="float: left; margin: 5px;">';
482
  }
@@ -604,12 +619,12 @@ class MediaFromFtp {
604
  $linkselectbox .= '<div style="font-size: small; font-weight: bold;"><code>'.$wordpress_path.'</code></div>';
605
  $linkselectbox .= '<select name="searchdir" style="width: 250px">';
606
 
607
- $dirs = $this->scan_dir(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR);
608
  foreach ($dirs as $linkdir) {
609
  if ( strstr($linkdir, $wordpress_path ) ) {
610
  $linkdirenc = $this->mb_utf8(str_replace($wordpress_path, '', $linkdir), $character_code);
611
  } else {
612
- $linkdirenc = MEDIAFROMFTP_PLUGIN_UPLOAD_PATH.$this->mb_utf8(str_replace(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR, "", $linkdir), $character_code);
613
  }
614
  if( $searchdir === $linkdirenc ){
615
  $linkdirs = '<option value="'.urlencode($linkdirenc).'" selected>'.$linkdirenc.'</option>';
@@ -618,10 +633,10 @@ class MediaFromFtp {
618
  }
619
  $linkselectbox = $linkselectbox.$linkdirs;
620
  }
621
- if( $searchdir === MEDIAFROMFTP_PLUGIN_UPLOAD_PATH ){
622
- $linkdirs = '<option value="'.urlencode(MEDIAFROMFTP_PLUGIN_UPLOAD_PATH).'" selected>'.MEDIAFROMFTP_PLUGIN_UPLOAD_PATH.'</option>';
623
  }else{
624
- $linkdirs = '<option value="'.urlencode(MEDIAFROMFTP_PLUGIN_UPLOAD_PATH).'">'.MEDIAFROMFTP_PLUGIN_UPLOAD_PATH.'</option>';
625
  }
626
  $linkselectbox = $linkselectbox.$linkdirs.'</select>';
627
 
@@ -726,11 +741,11 @@ class MediaFromFtp {
726
  $path_parts = pathinfo($new_url_attach);
727
  $urlpath_dir = wp_make_link_relative($path_parts['dirname']);
728
 
729
- $relation_path_true = strstr(MEDIAFROMFTP_PLUGIN_UPLOAD_PATH, '../');
730
  if ( !$relation_path_true ) {
731
- $plus_path = ltrim(str_replace(MEDIAFROMFTP_PLUGIN_UPLOAD_PATH, '', strstr($urlpath_dir, MEDIAFROMFTP_PLUGIN_UPLOAD_PATH)), '/');
732
  } else {
733
- $plus_path_tmp = str_replace($urlpath_dir, '', str_replace('../', '', MEDIAFROMFTP_PLUGIN_UPLOAD_PATH).'/');
734
  $plus_path = ltrim(str_replace($plus_path_tmp, '', $urlpath_dir), '/');
735
  }
736
  if ( !empty($plus_path) ) {
@@ -761,12 +776,12 @@ class MediaFromFtp {
761
  $oldfilename = $filename;
762
  $currentfile = str_replace(' ', '-', $currentfile);
763
  $filename = $currentdir.$currentfile;
764
- $new_url_attach = MEDIAFROMFTP_PLUGIN_UPLOAD_URL.'/'.$filename;
765
- $copy_file_org1 = $this->mb_encode_multibyte(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.'/'.$oldfilename, $character_code);
766
- $copy_file_new1 = $this->mb_encode_multibyte(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.'/'.$filename, $character_code);
767
  $err_copy = @copy( $copy_file_org1, $copy_file_new1 );
768
  if ( !$err_copy ) {
769
- return array(-1, $this->mb_utf8($copy_file_org1, $character_code), $this->mb_utf8(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.'/'.$plus_path, $character_code), NULL);
770
  }
771
  }
772
  if ( function_exists('mb_check_encoding') ) {
@@ -783,16 +798,16 @@ class MediaFromFtp {
783
 
784
  $oldfilename = $currentdir.$currentfile.$suffix_attach_file;
785
  $filename = $currentdir.md5($currentfile).$suffix_attach_file;
786
- $new_url_attach = MEDIAFROMFTP_PLUGIN_UPLOAD_URL.'/'.$filename;
787
- $copy_file_org2 = $this->mb_encode_multibyte(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.'/'.$oldfilename, $character_code);
788
- $copy_file_new2 = $this->mb_encode_multibyte(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.'/'.$filename, $character_code);
789
  $err_copy = @copy( $copy_file_org2, $copy_file_new2 );
790
  if ( !$err_copy ) {
791
  if (!empty($copy_file_new1)) {
792
  $copy_file_org2 = $copy_file_org1;
793
  unlink( $copy_file_new1 );
794
  }
795
- return array(-1, $this->mb_utf8($copy_file_org2, $character_code), $this->mb_utf8(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.'/'.$plus_path, $character_code), NULL);
796
  }
797
  }
798
  }
@@ -803,15 +818,15 @@ class MediaFromFtp {
803
  $m = substr( $postdategmt, 5, 2 );
804
  $subdir = "/$y/$m";
805
  $filename_base = wp_basename($filename);
806
- if ( MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.'/'.$filename <> MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.$subdir.'/'.$filename_base ) {
807
- if ( !file_exists($this->mb_encode_multibyte(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.$subdir, $character_code)) ) {
808
- wp_mkdir_p($this->mb_encode_multibyte(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.$subdir, $character_code));
809
  }
810
- if ( file_exists($this->mb_encode_multibyte(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.$subdir.'/'.$filename_base, $character_code)) ) {
811
  $filename_base = wp_basename($filename, $suffix_attach_file).date_i18n( "dHis", FALSE, FALSE ).$suffix_attach_file;
812
  }
813
- $copy_file_org3 = $this->mb_encode_multibyte(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.'/'.$filename, $character_code);
814
- $copy_file_new3 = $this->mb_encode_multibyte(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.$subdir.'/'.$filename_base, $character_code);
815
  $err_copy = @copy( $copy_file_org3, $copy_file_new3 );
816
  if ( !$err_copy ) {
817
  if (!empty($copy_file_new1)) {
@@ -821,10 +836,10 @@ class MediaFromFtp {
821
  $copy_file_org3 = $copy_file_org2;
822
  unlink( $copy_file_new2 );
823
  }
824
- return array(-1, $this->mb_utf8($copy_file_org3, $character_code), $this->mb_utf8(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.$subdir, $character_code), NULL);
825
  }
826
  $filename = ltrim($subdir, '/').'/'.$filename_base;
827
- $new_url_attach = MEDIAFROMFTP_PLUGIN_UPLOAD_URL.'/'.$filename;
828
  }
829
  }
830
 
@@ -909,7 +924,7 @@ class MediaFromFtp {
909
  $filetype = wp_check_filetype( $this->mb_encode_multibyte(get_attached_file($attach_id), $character_code) );
910
  if ( wp_ext2type($ext) === 'image' || strtolower($ext) === 'pdf' ){
911
  $wp_attached_file = get_post_meta( $attach_id, '_wp_attached_file', true );
912
- $imagethumburl_base = MEDIAFROMFTP_PLUGIN_UPLOAD_URL.'/'.rtrim($wp_attached_file, wp_basename($wp_attached_file));
913
  if ( !empty($metadata) ) {
914
  foreach ( $metadata as $key1 => $key2 ){
915
  if ( $key1 === 'sizes' ) {
@@ -938,7 +953,7 @@ class MediaFromFtp {
938
  if ( $this->is_add_on_activate['exif'] ) {
939
  if ( $filetype['type'] === 'image/jpeg' || $filetype['type'] === 'image/tiff' ) {
940
  if ( !empty($exif_text_tag) ) {
941
- include_once MEDIAFROMFTP_ADDON_EXIF_PLUGIN_BASE_DIR.'/inc/MediaFromFtpAddOnExif.php';
942
  $mediafromftpaddonexif = new MediaFromFtpAddOnExif();
943
  $exif_text = $mediafromftpaddonexif->exifcaption($attach_id, $metadata, $exif_text_tag);
944
  unset($mediafromftpaddonexif);
@@ -1425,7 +1440,7 @@ MEDIAFROMFTP_AUTHOR_SELECT;
1425
  $db_wp_attachment_image_alt_array = array();
1426
  foreach ($data as $key => $value) {
1427
  if ($value['post_type'] === 'attachment') {
1428
- $file = MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.'/'.$value['postmeta_wp_attached_file_value'];
1429
  $filetype = wp_check_filetype( basename( $file ), null );
1430
 
1431
  $user = wp_get_current_user();
@@ -1462,7 +1477,7 @@ MEDIAFROMFTP_AUTHOR_SELECT;
1462
  $db_wp_attachment_metadata_array[$count] = json_encode($value['postmeta_wp_attachment_metadata_value']);
1463
  if ( strrpos($value['postmeta_wp_attached_file_value'], '/') ) {
1464
  $monthdir = '/'.substr($value['postmeta_wp_attached_file_value'], 0 , strrpos($value['postmeta_wp_attached_file_value'], '/'));
1465
- $dir = MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.$monthdir;
1466
  }
1467
  $thumbnails = maybe_unserialize($value['postmeta_wp_attachment_metadata_value']);
1468
  if ( is_array($thumbnails) ) {
21
 
22
  class MediaFromFtp {
23
 
24
+ private $plugin_dir;
25
+ private $upload_dir;
26
+ private $upload_url;
27
+ private $upload_path;
28
+ private $plugin_tmp_url;
29
+ private $plugin_tmp_dir;
30
  private $is_add_on_activate;
31
 
32
  /* ==================================================
35
  */
36
  function __construct() {
37
 
38
+ $plugin_base_dir = untrailingslashit(plugin_dir_path( __DIR__ ));
39
+ $slugs = explode('/', $plugin_base_dir);
40
+ $slug = end($slugs);
41
+ $this->plugin_dir = untrailingslashit(rtrim($plugin_base_dir, $slug));
42
+
43
+ list($this->upload_dir, $this->upload_url, $this->upload_path) = $this->upload_dir_url_path();
44
+ $this->plugin_tmp_url = $this->upload_url.'/media-from-ftp-tmp';
45
+ $this->plugin_tmp_dir = $this->upload_dir.'/media-from-ftp-tmp';
46
+
47
  $exif_active = FALSE;
48
  if( function_exists('media_from_ftp_add_on_exif_load_textdomain') ){
49
  $exif_active = TRUE;
260
 
261
  $cash_thumb_key = md5($new_url);
262
  if ( strtolower($ext) === 'pdf' ) {
263
+ $cash_thumb_filename = $this->plugin_tmp_dir.'/'.$cash_thumb_key.'-pdf.jpg';
264
  } else {
265
+ $cash_thumb_filename = $this->plugin_tmp_dir.'/'.$cash_thumb_key.'.'.$ext;
266
  }
267
 
268
  $value_cash = get_transient( $cash_thumb_key );
284
  $cash_thumb2->resize( 40 ,40, true );
285
  $cash_thumb2->save( $cash_thumb_filename );
286
  }
287
+ $view_thumb_url = $this->plugin_tmp_url.'/'.$cash_thumb_key.'-pdf.jpg';
288
  } else {
289
  $cash_thumb->resize( 40 ,40, true );
290
  $cash_thumb->save( $cash_thumb_filename );
291
+ $view_thumb_url = $this->plugin_tmp_url.'/'.$cash_thumb_key.'.'.$ext;
292
  }
293
  } else {
294
  $filetype2 = wp_ext2type($ext);
295
  if ( empty($filetype2) ) { $filetype2 = 'default'; }
296
+ $view_thumb_url = $this->siteurl(). WPINC . '/images/media/'.$filetype2.'.png';
297
  }
298
  } else {
299
  if ( file_exists( $cash_thumb_filename )) {
300
+ $view_thumb_url = $this->plugin_tmp_url.'/'.$cash_thumb_key.'.'.$ext;
301
  } else {
302
  $filetype2 = wp_ext2type($ext);
303
  if ( empty($filetype2) ) { $filetype2 = 'default'; }
304
+ $view_thumb_url = $this->siteurl(). WPINC . '/images/media/'.$filetype2.'.png';
305
  }
306
  }
307
  set_transient( $cash_thumb_key, $view_thumb_url, DAY_IN_SECONDS);
325
  if ( wp_ext2type($ext) === 'image' || strtolower($ext) === 'pdf' ){
326
  $del_cash_thumb_key = md5($new_url_attach);
327
  if ( strtolower($ext) === 'pdf' ) {
328
+ $del_cash_thumb_filename = $this->plugin_tmp_dir.'/'.$del_cash_thumb_key.'-pdf.jpg';
329
  } else {
330
+ $del_cash_thumb_filename = $this->plugin_tmp_dir.'/'.$del_cash_thumb_key.'.'.$ext;
331
  }
332
  $value_del_cash = get_transient( $del_cash_thumb_key );
333
  if ( $value_del_cash <> FALSE ) {
348
  function delete_all_cash(){
349
 
350
  global $wpdb;
351
+ $search_transients = $this->plugin_tmp_url;
352
  $del_transients = $wpdb->get_results("
353
  SELECT option_value
354
  FROM $wpdb->options
366
  }
367
  }
368
 
369
+ $del_cash_thumb_filename = $this->plugin_tmp_dir.'/*.*';
370
  foreach ( glob($del_cash_thumb_filename) as $val ) {
371
  unlink($val);
372
  ++$del_cash_count;
425
  $ext = end($exts);
426
  $suffix_file = '.'.$ext;
427
  $file = wp_normalize_path($file);
428
+ $upload_path = wp_normalize_path($this->upload_dir);
429
+ $new_url = $this->upload_url.str_replace($upload_path, '', $file);
430
  $new_titles = explode('/', $new_url);
431
  $new_title = str_replace($suffix_file, '', end($new_titles));
432
  $new_title_md5 = md5($new_title);
434
  $new_file = TRUE;
435
  $new_url = $this->mb_utf8($new_url, $character_code);
436
  foreach ( $attachments as $attachment ){
437
+ $attach_url = $this->upload_url.'/'.get_post_meta( $attachment->ID, '_wp_attached_file', true );
438
  $pdf_thumb_url = rtrim($attach_url, '.pdf').'-pdf.jpg'; // for pdf thumbnail by imagick
439
  if ( $attach_url === $new_url || $attach_url === $new_url_md5 || $pdf_thumb_url === $new_url || $pdf_thumb_url === $new_url_md5 ) {
440
  $new_file = FALSE;
477
  if ( wp_ext2type($ext) === 'image' || strtolower($ext) === 'pdf' ){
478
  $view_thumb_url = $this->create_cash($ext, $file, $new_url);
479
  } else if ( wp_ext2type($ext) === 'audio' ) {
480
+ $view_thumb_url = $this->siteurl(). WPINC . '/images/media/audio.png';
481
  $metadata_audio = wp_read_audio_metadata( $file );
482
  $file_size = size_format($metadata_audio['filesize']);
483
  $mimetype = $metadata_audio['fileformat'].'('.$metadata_audio['mime_type'].')';
484
  $length = $metadata_audio['length_formatted'];
485
  } else if ( wp_ext2type($ext) === 'video' ) {
486
+ $view_thumb_url = $this->siteurl(). WPINC . '/images/media/video.png';
487
  $metadata_video = wp_read_video_metadata( $file );
488
  $file_size = size_format($metadata_video['filesize']);
489
  $mimetype = $metadata_video['fileformat'].'('.$metadata_video['mime_type'].')';
491
  } else {
492
  $filetype2 = wp_ext2type($ext);
493
  if ( empty($filetype2) ) { $filetype2 = 'default'; }
494
+ $view_thumb_url = $this->siteurl(). WPINC . '/images/media/'.$filetype2.'.png';
495
  }
496
  $input_html .= '<img width="40" height="40" src="'.$view_thumb_url.'" style="float: left; margin: 5px;">';
497
  }
619
  $linkselectbox .= '<div style="font-size: small; font-weight: bold;"><code>'.$wordpress_path.'</code></div>';
620
  $linkselectbox .= '<select name="searchdir" style="width: 250px">';
621
 
622
+ $dirs = $this->scan_dir($this->upload_dir);
623
  foreach ($dirs as $linkdir) {
624
  if ( strstr($linkdir, $wordpress_path ) ) {
625
  $linkdirenc = $this->mb_utf8(str_replace($wordpress_path, '', $linkdir), $character_code);
626
  } else {
627
+ $linkdirenc = $this->upload_path.$this->mb_utf8(str_replace($this->upload_dir, "", $linkdir), $character_code);
628
  }
629
  if( $searchdir === $linkdirenc ){
630
  $linkdirs = '<option value="'.urlencode($linkdirenc).'" selected>'.$linkdirenc.'</option>';
633
  }
634
  $linkselectbox = $linkselectbox.$linkdirs;
635
  }
636
+ if( $searchdir === $this->upload_path ){
637
+ $linkdirs = '<option value="'.urlencode($this->upload_path).'" selected>'.$this->upload_path.'</option>';
638
  }else{
639
+ $linkdirs = '<option value="'.urlencode($this->upload_path).'">'.$this->upload_path.'</option>';
640
  }
641
  $linkselectbox = $linkselectbox.$linkdirs.'</select>';
642
 
741
  $path_parts = pathinfo($new_url_attach);
742
  $urlpath_dir = wp_make_link_relative($path_parts['dirname']);
743
 
744
+ $relation_path_true = strstr($this->upload_path, '../');
745
  if ( !$relation_path_true ) {
746
+ $plus_path = ltrim(str_replace($this->upload_path, '', strstr($urlpath_dir, $this->upload_path)), '/');
747
  } else {
748
+ $plus_path_tmp = str_replace($urlpath_dir, '', str_replace('../', '', $this->upload_path).'/');
749
  $plus_path = ltrim(str_replace($plus_path_tmp, '', $urlpath_dir), '/');
750
  }
751
  if ( !empty($plus_path) ) {
776
  $oldfilename = $filename;
777
  $currentfile = str_replace(' ', '-', $currentfile);
778
  $filename = $currentdir.$currentfile;
779
+ $new_url_attach = $this->upload_url.'/'.$filename;
780
+ $copy_file_org1 = $this->mb_encode_multibyte($this->upload_dir.'/'.$oldfilename, $character_code);
781
+ $copy_file_new1 = $this->mb_encode_multibyte($this->upload_dir.'/'.$filename, $character_code);
782
  $err_copy = @copy( $copy_file_org1, $copy_file_new1 );
783
  if ( !$err_copy ) {
784
+ return array(-1, $this->mb_utf8($copy_file_org1, $character_code), $this->mb_utf8($this->upload_dir.'/'.$plus_path, $character_code), NULL);
785
  }
786
  }
787
  if ( function_exists('mb_check_encoding') ) {
798
 
799
  $oldfilename = $currentdir.$currentfile.$suffix_attach_file;
800
  $filename = $currentdir.md5($currentfile).$suffix_attach_file;
801
+ $new_url_attach = $this->upload_url.'/'.$filename;
802
+ $copy_file_org2 = $this->mb_encode_multibyte($this->upload_dir.'/'.$oldfilename, $character_code);
803
+ $copy_file_new2 = $this->mb_encode_multibyte($this->upload_dir.'/'.$filename, $character_code);
804
  $err_copy = @copy( $copy_file_org2, $copy_file_new2 );
805
  if ( !$err_copy ) {
806
  if (!empty($copy_file_new1)) {
807
  $copy_file_org2 = $copy_file_org1;
808
  unlink( $copy_file_new1 );
809
  }
810
+ return array(-1, $this->mb_utf8($copy_file_org2, $character_code), $this->mb_utf8($this->upload_dir.'/'.$plus_path, $character_code), NULL);
811
  }
812
  }
813
  }
818
  $m = substr( $postdategmt, 5, 2 );
819
  $subdir = "/$y/$m";
820
  $filename_base = wp_basename($filename);
821
+ if ( $this->upload_dir.'/'.$filename <> $this->upload_dir.$subdir.'/'.$filename_base ) {
822
+ if ( !file_exists($this->mb_encode_multibyte($this->upload_dir.$subdir, $character_code)) ) {
823
+ wp_mkdir_p($this->mb_encode_multibyte($this->upload_dir.$subdir, $character_code));
824
  }
825
+ if ( file_exists($this->mb_encode_multibyte($this->upload_dir.$subdir.'/'.$filename_base, $character_code)) ) {
826
  $filename_base = wp_basename($filename, $suffix_attach_file).date_i18n( "dHis", FALSE, FALSE ).$suffix_attach_file;
827
  }
828
+ $copy_file_org3 = $this->mb_encode_multibyte($this->upload_dir.'/'.$filename, $character_code);
829
+ $copy_file_new3 = $this->mb_encode_multibyte($this->upload_dir.$subdir.'/'.$filename_base, $character_code);
830
  $err_copy = @copy( $copy_file_org3, $copy_file_new3 );
831
  if ( !$err_copy ) {
832
  if (!empty($copy_file_new1)) {
836
  $copy_file_org3 = $copy_file_org2;
837
  unlink( $copy_file_new2 );
838
  }
839
+ return array(-1, $this->mb_utf8($copy_file_org3, $character_code), $this->mb_utf8($this->upload_dir.$subdir, $character_code), NULL);
840
  }
841
  $filename = ltrim($subdir, '/').'/'.$filename_base;
842
+ $new_url_attach = $this->upload_url.'/'.$filename;
843
  }
844
  }
845
 
924
  $filetype = wp_check_filetype( $this->mb_encode_multibyte(get_attached_file($attach_id), $character_code) );
925
  if ( wp_ext2type($ext) === 'image' || strtolower($ext) === 'pdf' ){
926
  $wp_attached_file = get_post_meta( $attach_id, '_wp_attached_file', true );
927
+ $imagethumburl_base = $this->upload_url.'/'.rtrim($wp_attached_file, wp_basename($wp_attached_file));
928
  if ( !empty($metadata) ) {
929
  foreach ( $metadata as $key1 => $key2 ){
930
  if ( $key1 === 'sizes' ) {
953
  if ( $this->is_add_on_activate['exif'] ) {
954
  if ( $filetype['type'] === 'image/jpeg' || $filetype['type'] === 'image/tiff' ) {
955
  if ( !empty($exif_text_tag) ) {
956
+ include_once $this->plugin_dir.'/media-from-ftp-add-on-exif/inc/MediaFromFtpAddOnExif.php';
957
  $mediafromftpaddonexif = new MediaFromFtpAddOnExif();
958
  $exif_text = $mediafromftpaddonexif->exifcaption($attach_id, $metadata, $exif_text_tag);
959
  unset($mediafromftpaddonexif);
1440
  $db_wp_attachment_image_alt_array = array();
1441
  foreach ($data as $key => $value) {
1442
  if ($value['post_type'] === 'attachment') {
1443
+ $file = $this->upload_dir.'/'.$value['postmeta_wp_attached_file_value'];
1444
  $filetype = wp_check_filetype( basename( $file ), null );
1445
 
1446
  $user = wp_get_current_user();
1477
  $db_wp_attachment_metadata_array[$count] = json_encode($value['postmeta_wp_attachment_metadata_value']);
1478
  if ( strrpos($value['postmeta_wp_attached_file_value'], '/') ) {
1479
  $monthdir = '/'.substr($value['postmeta_wp_attached_file_value'], 0 , strrpos($value['postmeta_wp_attached_file_value'], '/'));
1480
+ $dir = $this->upload_dir.$monthdir;
1481
  }
1482
  $thumbnails = maybe_unserialize($value['postmeta_wp_attachment_metadata_value']);
1483
  if ( is_array($thumbnails) ) {
mediafromftp.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Media from FTP
4
  Plugin URI: https://wordpress.org/plugins/media-from-ftp/
5
- Version: 9.98
6
  Description: Register to media library from files that have been uploaded by FTP.
7
  Author: Katsushi Kawamori
8
  Author URI: https://riverforest-wp.info/
@@ -25,76 +25,14 @@ Domain Path: /languages
25
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
  */
27
 
28
- load_plugin_textdomain('media-from-ftp');
29
- // load_plugin_textdomain('media-from-ftp', false, basename( dirname( __FILE__ ) ) . '/languages' );
30
-
31
- define("MEDIAFROMFTP_PLUGIN_BASE_FILE", plugin_basename(__FILE__));
32
- define("MEDIAFROMFTP_PLUGIN_BASE_DIR", dirname(__FILE__));
33
- define("MEDIAFROMFTP_PLUGIN_URL", plugins_url($path='',$scheme=null).'/media-from-ftp');
34
-
35
- if ( !defined('MEDIAFROMFTP_ADDON_CATEGORY_PLUGIN_BASE_DIR') ) {
36
- define("MEDIAFROMFTP_ADDON_CATEGORY_PLUGIN_BASE_DIR", wp_normalize_path(WP_PLUGIN_DIR.'/media-from-ftp-add-on-category'));
37
- }
38
- if ( !defined('MEDIAFROMFTP_ADDON_CLI_PLUGIN_BASE_DIR') ) {
39
- define("MEDIAFROMFTP_ADDON_CLI_PLUGIN_BASE_DIR", wp_normalize_path(WP_PLUGIN_DIR.'/media-from-ftp-add-on-cli'));
40
- }
41
- if ( !defined('MEDIAFROMFTP_ADDON_CLI_PLUGIN_URL') ) {
42
- define("MEDIAFROMFTP_ADDON_CLI_PLUGIN_URL", plugins_url($path='',$scheme=null).'/media-from-ftp-add-on-cli');
43
- }
44
- if ( !defined('MEDIAFROMFTP_ADDON_EXIF_PLUGIN_BASE_DIR') ) {
45
- define("MEDIAFROMFTP_ADDON_EXIF_PLUGIN_BASE_DIR", wp_normalize_path(WP_PLUGIN_DIR.'/media-from-ftp-add-on-exif'));
46
- }
47
- if ( !defined('MEDIAFROMFTP_ADDON_WPCRON_PLUGIN_BASE_DIR') ) {
48
- define("MEDIAFROMFTP_ADDON_WPCRON_PLUGIN_BASE_DIR", wp_normalize_path(WP_PLUGIN_DIR.'/media-from-ftp-add-on-wpcron'));
49
  }
50
 
51
- include_once MEDIAFROMFTP_PLUGIN_BASE_DIR.'/inc/MediaFromFtp.php';
52
- $mediafromftp = new MediaFromFtp();
53
- define("MEDIAFROMFTP_PLUGIN_SITE_URL", $mediafromftp->siteurl());
54
- list($upload_dir, $upload_url, $upload_path) = $mediafromftp->upload_dir_url_path();
55
- define("MEDIAFROMFTP_PLUGIN_UPLOAD_DIR", $upload_dir);
56
- define("MEDIAFROMFTP_PLUGIN_UPLOAD_URL", $upload_url);
57
- define("MEDIAFROMFTP_PLUGIN_UPLOAD_PATH", $upload_path);
58
- unset($mediafromftp, $upload_dir, $upload_url, $upload_path);
59
-
60
- define("MEDIAFROMFTP_PLUGIN_TMP_URL", MEDIAFROMFTP_PLUGIN_UPLOAD_URL.'/media-from-ftp-tmp');
61
- define("MEDIAFROMFTP_PLUGIN_TMP_DIR", MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.'/media-from-ftp-tmp');
62
- define("MEDIAFROMFTP_PLUGIN_DISALLOW_TMP_DIR", str_replace(home_url(), '', site_url()).'/'.MEDIAFROMFTP_PLUGIN_UPLOAD_PATH.'/media-from-ftp-tmp/');
63
-
64
- // Make tmp dir
65
- if ( !is_dir( MEDIAFROMFTP_PLUGIN_TMP_DIR ) ) {
66
- wp_mkdir_p( MEDIAFROMFTP_PLUGIN_TMP_DIR );
67
- }
68
-
69
- require_once( MEDIAFROMFTP_PLUGIN_BASE_DIR.'/req/MediaFromFtpRegist.php' );
70
- $mediafromftpregist = new MediaFromFtpRegist();
71
- register_activation_hook( __FILE__, array($mediafromftpregist, 'log_settings') );
72
- add_action( 'plugins_loaded', array($mediafromftpregist, 'log_settings') );
73
- add_action( 'admin_init', array($mediafromftpregist, 'register_settings') );
74
- unset($mediafromftpregist);
75
-
76
- require_once( MEDIAFROMFTP_PLUGIN_BASE_DIR.'/req/MediaFromFtpAdmin.php' );
77
- $mediafromftpadmin = new MediaFromFtpAdmin();
78
- add_filter( 'plugin_action_links', array($mediafromftpadmin, 'settings_link'), 10, 2 );
79
- add_action( 'admin_menu', array($mediafromftpadmin, 'add_pages') );
80
- add_action( 'admin_enqueue_scripts', array($mediafromftpadmin, 'load_custom_wp_admin_style') );
81
- add_action( 'admin_footer', array($mediafromftpadmin, 'load_custom_wp_admin_style2') );
82
- add_action( 'admin_footer', array($mediafromftpadmin, 'custom_bulk_admin_footer') );
83
- add_action( 'screen_settings', array($mediafromftpadmin, 'search_register_show_screen_options'), 10, 2 );
84
- add_filter( 'set-screen-option', array($mediafromftpadmin, 'search_register_set_screen_options'), 11, 3 );
85
- add_filter( 'contextual_help', array($mediafromftpadmin, 'search_register_help_tab'), 12, 3);
86
- add_filter( 'robots_txt', array($mediafromftpadmin, 'custom_robots_txt'), 9999 );
87
- add_action( 'admin_notices', array($mediafromftpadmin, 'notices'));
88
- unset($mediafromftpadmin);
89
 
90
- require_once( MEDIAFROMFTP_PLUGIN_BASE_DIR.'/req/MediaFromFtpAjax.php' );
91
- $mediafromftpajax = new MediaFromFtpAjax();
92
- $action1 = 'mediafromftp-update-ajax-action';
93
- $action2 = 'mediafromftp-import-ajax-action';
94
- add_action( 'wp_ajax_'.$action1, array($mediafromftpajax, 'mediafromftp_update_callback') );
95
- add_action( 'wp_ajax_mediafromftp_message', array($mediafromftpajax, 'mediafromftp_message_callback') );
96
- add_action( 'wp_ajax_'.$action2, array($mediafromftpajax, 'mediafromftp_medialibraryimport_update_callback') );
97
- add_action( 'wp_ajax_mediafromftp_medialibraryimport_message', array($mediafromftpajax, 'mediafromftp_medialibraryimport_message_callback') );
98
- unset($mediafromftpajax, $action1, $action2);
99
 
100
  ?>
2
  /*
3
  Plugin Name: Media from FTP
4
  Plugin URI: https://wordpress.org/plugins/media-from-ftp/
5
+ Version: 9.99
6
  Description: Register to media library from files that have been uploaded by FTP.
7
  Author: Katsushi Kawamori
8
  Author URI: https://riverforest-wp.info/
25
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
  */
27
 
28
+ add_action( 'plugins_loaded', 'media_from_ftp_load_textdomain' );
29
+ function media_from_ftp_load_textdomain() {
30
+ load_plugin_textdomain('media-from-ftp');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
 
33
+ if(!class_exists('MediaFromFtpRegist')) require_once( dirname( __FILE__ ).'/req/MediaFromFtpRegist.php' );
34
+ if(!class_exists('MediaFromFtpAdmin')) require_once( dirname( __FILE__ ).'/req/MediaFromFtpAdmin.php' );
35
+ if(!class_exists('MediaFromFtpAjax')) require_once( dirname( __FILE__ ).'/req/MediaFromFtpAjax.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
 
 
 
 
 
 
 
 
 
37
 
38
  ?>
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: files, ftp, import, media, sync, uploads
5
  Requires at least: 3.6.0
6
  Requires PHP: 5.3.0
7
  Tested up to: 4.9
8
- Stable tag: 9.98
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -126,6 +126,9 @@ Register to media library from files that have been uploaded by FTP.
126
 
127
  == Changelog ==
128
 
 
 
 
129
  = 9.98 =
130
  Search option was added to the settings page.
131
 
5
  Requires at least: 3.6.0
6
  Requires PHP: 5.3.0
7
  Tested up to: 4.9
8
+ Stable tag: 9.99
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
126
 
127
  == Changelog ==
128
 
129
+ = 9.99 =
130
+ Fixed fine problem.
131
+
132
  = 9.98 =
133
  Search option was added to the settings page.
134
 
req/MediaFromFtpAdmin.php CHANGED
@@ -19,8 +19,21 @@
19
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
  */
21
 
 
 
 
 
 
22
  class MediaFromFtpAdmin {
23
 
 
 
 
 
 
 
 
 
24
  private $is_add_on_activate;
25
 
26
  /* ==================================================
@@ -29,27 +42,46 @@ class MediaFromFtpAdmin {
29
  */
30
  function __construct() {
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  $category_active = FALSE;
33
  if( function_exists('media_from_ftp_add_on_category_load_textdomain') ){
34
- include_once MEDIAFROMFTP_ADDON_CATEGORY_PLUGIN_BASE_DIR.'/inc/MediaFromFtpAddOnCategory.php';
35
  $category_active = TRUE;
36
  }
37
  $exif_active = FALSE;
38
  if( function_exists('media_from_ftp_add_on_exif_load_textdomain') ){
39
- include_once MEDIAFROMFTP_ADDON_EXIF_PLUGIN_BASE_DIR.'/inc/MediaFromFtpAddOnExif.php';
40
  $exif_active = TRUE;
41
  }
42
  $cli_active = FALSE;
43
  if( function_exists('media_from_ftp_add_on_cli_load_textdomain') ){
44
- require_once( MEDIAFROMFTP_ADDON_CLI_PLUGIN_BASE_DIR.'/req/MediaFromFtpCli.php' );
45
  $cli_active = TRUE;
46
  }
47
  $wpcron_active = FALSE;
48
  if( function_exists('media_from_ftp_add_on_wpcron_load_textdomain') ){
49
- include_once MEDIAFROMFTP_ADDON_WPCRON_PLUGIN_BASE_DIR.'/inc/MediaFromFtpAddOnWpcron.php';
50
  $wpcron_active = TRUE;
51
  }
52
-
53
  $this->is_add_on_activate = array(
54
  'category' => $category_active,
55
  'exif' => $exif_active,
@@ -57,12 +89,13 @@ class MediaFromFtpAdmin {
57
  'wpcron' => $wpcron_active
58
  );
59
 
60
- if(!class_exists('MediaFromFtp')){
61
- include_once MEDIAFROMFTP_PLUGIN_BASE_DIR.'/inc/MediaFromFtp.php';
62
- }
63
- if(!class_exists('TT_MediaFromFtp_List_Table')){
64
- require_once( MEDIAFROMFTP_PLUGIN_BASE_DIR.'/req/MediaFromFtpListTable.php' );
65
- }
 
66
 
67
  }
68
 
@@ -73,7 +106,7 @@ class MediaFromFtpAdmin {
73
  function settings_link( $links, $file ) {
74
  static $this_plugin;
75
  if ( empty($this_plugin) ) {
76
- $this_plugin = MEDIAFROMFTP_PLUGIN_BASE_FILE;
77
  }
78
  if ( $file == $this_plugin ) {
79
  $links[] = '<a href="'.admin_url('admin.php?page=mediafromftp').'">Media from FTP</a>';
@@ -220,7 +253,7 @@ class MediaFromFtpAdmin {
220
  */
221
  function get_help_message($screen_id) {
222
 
223
- $upload_dir_html = '<span style="color: red;">'.MEDIAFROMFTP_PLUGIN_UPLOAD_PATH.'</span>';
224
  $mediafromftp = new MediaFromFtp();
225
 
226
  switch ($screen_id) {
@@ -276,22 +309,22 @@ class MediaFromFtpAdmin {
276
  if ($this->is_my_plugin_screen()) {
277
  $mediafromftp_settings = get_option($this->wp_options_name());
278
  if ( $mediafromftp_settings['datetimepicker'] ) {
279
- wp_enqueue_style( 'jquery-datetimepicker', MEDIAFROMFTP_PLUGIN_URL.'/css/jquery.datetimepicker.css' );
280
  }
281
- wp_enqueue_style( 'jquery-responsiveTabs', MEDIAFROMFTP_PLUGIN_URL.'/css/responsive-tabs.css' );
282
- wp_enqueue_style( 'jquery-responsiveTabs-style', MEDIAFROMFTP_PLUGIN_URL.'/css/style.css' );
283
- wp_enqueue_style( 'mediafromftp', MEDIAFROMFTP_PLUGIN_URL.'/css/mediafromftp.css' );
284
  wp_enqueue_script( 'jquery' );
285
  if ( $mediafromftp_settings['datetimepicker'] ) {
286
- wp_enqueue_script( 'jquery-datetimepicker', MEDIAFROMFTP_PLUGIN_URL.'/js/jquery.datetimepicker.js', null, '2.3.4' );
287
- wp_enqueue_script( 'jquery-mediafromftp-datetimepicker', MEDIAFROMFTP_PLUGIN_URL.'/js/jquery.mediafromftp.datetimepicker.js', array('jquery') );
288
  }
289
- wp_enqueue_script( 'jquery-responsiveTabs', MEDIAFROMFTP_PLUGIN_URL.'/js/jquery.responsiveTabs.min.js' );
290
 
291
  $handle = 'mediafromftp-ajax-script';
292
  $action1 = 'mediafromftp-update-ajax-action';
293
  $action2 = 'mediafromftp-import-ajax-action';
294
- wp_enqueue_script( $handle, MEDIAFROMFTP_PLUGIN_URL.'/js/jquery.mediafromftp.js', array('jquery') );
295
  wp_localize_script( $handle, 'MEDIAFROMFTPUPDATE', array(
296
  'ajax_url' => admin_url('admin-ajax.php'),
297
  'action' => $action1,
@@ -913,7 +946,7 @@ class MediaFromFtpAdmin {
913
  </h2>
914
  <div style="clear: both;"></div>
915
 
916
- <div id="mediafromftp-loading"><img src="<?php echo MEDIAFROMFTP_PLUGIN_URL.'/css/loading.gif'; ?>"></div>
917
  <div id="mediafromftp-loading-container">
918
  <?php
919
  $MediaFromFtpListTable = new TT_MediaFromFtp_List_Table();
@@ -972,7 +1005,7 @@ class MediaFromFtpAdmin {
972
  $mediafromftp = new MediaFromFtp();
973
  if ( $this->is_add_on_activate['wpcron'] ) {
974
  $mediafromftpaddonwpcron = new MediaFromFtpAddOnWpcron();
975
- include_once MEDIAFROMFTP_ADDON_WPCRON_PLUGIN_BASE_DIR.'/req/MediaFromFtpCron.php';
976
  $mediafromftpcron = new MediaFromFtpCron();
977
  $mediafromftp_addon_wpcron = TRUE;
978
  }
@@ -1072,7 +1105,7 @@ class MediaFromFtpAdmin {
1072
  </h2>
1073
  <div style="clear: both;"></div>
1074
 
1075
- <div id="mediafromftp-loading"><img src="<?php echo MEDIAFROMFTP_PLUGIN_URL.'/css/loading.gif'; ?>"></div>
1076
  <div id="mediafromftp-loading-container">
1077
  <?php
1078
  global $wpdb;
@@ -1216,7 +1249,7 @@ class MediaFromFtpAdmin {
1216
 
1217
  $csv = $csv_head."\n".$csv;
1218
 
1219
- $csvFileName = MEDIAFROMFTP_PLUGIN_TMP_DIR.'/'.$table_name.'.csv';
1220
  if ( isset($_POST['media_from_ftp_put_log']) && $_POST['media_from_ftp_put_log'] ) {
1221
  if ( check_admin_referer('mff_put_log', 'media_from_ftp_put_log') ) {
1222
  if ( !empty($_POST['mediafromftp_put_log']) && $_POST['mediafromftp_put_log'] == 1 ) {
@@ -1250,7 +1283,7 @@ class MediaFromFtpAdmin {
1250
  <?php
1251
  if ( file_exists($csvFileName) ) {
1252
  ?>
1253
- <form method="post" action="<?php echo MEDIAFROMFTP_PLUGIN_TMP_URL.'/'.$table_name.'.csv'; ?>" />
1254
  <?php wp_nonce_field('mff_download', 'media_from_ftp_download'); ?>
1255
  <div>
1256
  <input type="hidden" name="mediafromftp_download" value="1" />
@@ -1310,7 +1343,7 @@ class MediaFromFtpAdmin {
1310
  </h2>
1311
  <div style="clear: both;"></div>
1312
 
1313
- <div id="mediafromftp-loading"><img src="<?php echo MEDIAFROMFTP_PLUGIN_URL.'/css/loading.gif'; ?>"></div>
1314
  <div id="medialibraryimport-loading-container">
1315
 
1316
  <?php
@@ -1319,13 +1352,13 @@ class MediaFromFtpAdmin {
1319
  if ( !empty($_FILES['filename']['name']) ) {
1320
  $filename = $_FILES['filename']['tmp_name'];
1321
  $name = basename($filename);
1322
- move_uploaded_file($filename, MEDIAFROMFTP_PLUGIN_TMP_DIR.'/'.$name);
1323
 
1324
  $mediafromftp = new MediaFromFtp();
1325
  ?>
1326
  <h4><?php _e('Assign Authors', 'media-from-ftp'); ?></h4>
1327
  <?php
1328
- echo $mediafromftp->author_select(MEDIAFROMFTP_PLUGIN_TMP_DIR.'/'.$name);
1329
  }
1330
  }
1331
  } else if ( isset($_POST['media_from_ftp_select_author']) && $_POST['media_from_ftp_select_author'] ) {
@@ -1411,7 +1444,7 @@ class MediaFromFtpAdmin {
1411
  </div>
1412
  <p>
1413
  <?php
1414
- if ( is_dir(WP_PLUGIN_DIR.'/media-from-ftp-add-on-cli') ) {
1415
  ?><div style="margin: 5px; padding: 5px;"><strong><?php
1416
  _e('Installed', 'media-from-ftp');?> & <?php
1417
  if ( $this->is_add_on_activate['cli'] ) {
@@ -1439,7 +1472,7 @@ class MediaFromFtpAdmin {
1439
  </div>
1440
  <p>
1441
  <?php
1442
- if ( is_dir(WP_PLUGIN_DIR.'/media-from-ftp-add-on-wpcron') ) {
1443
  ?><div style="margin: 5px; padding: 5px;"><strong><?php
1444
  _e('Installed', 'media-from-ftp');?> & <?php
1445
  if ( $this->is_add_on_activate['wpcron'] ) {
@@ -1466,7 +1499,7 @@ class MediaFromFtpAdmin {
1466
  </div>
1467
  <p>
1468
  <?php
1469
- if ( is_dir(WP_PLUGIN_DIR.'/media-from-ftp-add-on-category') ) {
1470
  ?><div style="margin: 5px; padding: 5px;"><strong><?php
1471
  _e('Installed', 'media-from-ftp');?> & <?php
1472
  if ( $this->is_add_on_activate['category'] ) {
@@ -1495,7 +1528,7 @@ class MediaFromFtpAdmin {
1495
 
1496
  <p>
1497
  <?php
1498
- if ( is_dir(WP_PLUGIN_DIR.'/media-from-ftp-add-on-exif') ) {
1499
  ?><div style="margin: 5px; padding: 5px;"><strong><?php
1500
  _e('Installed', 'media-from-ftp');?> & <?php
1501
  if ( $this->is_add_on_activate['exif'] ) {
@@ -1628,15 +1661,15 @@ class MediaFromFtpAdmin {
1628
  }
1629
  if (!empty($_POST['searchdir'])){
1630
  $searchdir = urldecode($_POST['searchdir']);
1631
- if ( strpos( realpath(wp_normalize_path(ABSPATH.$searchdir)), MEDIAFROMFTP_PLUGIN_UPLOAD_DIR) === FALSE ) {
1632
- $searchdir = MEDIAFROMFTP_PLUGIN_UPLOAD_PATH;
1633
- $mediafromftp_settings['basedir'] = MEDIAFROMFTP_PLUGIN_UPLOAD_PATH;
1634
  }
1635
  $mediafromftp_settings['searchdir'] = $searchdir;
1636
  } else {
1637
- if ( MEDIAFROMFTP_PLUGIN_UPLOAD_PATH <> $mediafromftp_settings['basedir'] ) {
1638
- $mediafromftp_settings['searchdir'] = MEDIAFROMFTP_PLUGIN_UPLOAD_PATH;
1639
- $mediafromftp_settings['basedir'] = MEDIAFROMFTP_PLUGIN_UPLOAD_PATH;
1640
  }
1641
  }
1642
  if (!empty($_POST['ext2type'])){
@@ -1756,10 +1789,7 @@ class MediaFromFtpAdmin {
1756
  */
1757
  function wp_options_name(){
1758
 
1759
- $user = wp_get_current_user();
1760
- $cron_user = $user->ID;
1761
-
1762
- $wp_options_name = 'mediafromftp_settings'.'_'.$cron_user;
1763
 
1764
  return $wp_options_name;
1765
 
@@ -1772,10 +1802,7 @@ class MediaFromFtpAdmin {
1772
  */
1773
  function wp_add_on_wpcron_events_name(){
1774
 
1775
- $user = wp_get_current_user();
1776
- $cron_user = $user->ID;
1777
-
1778
- $wp_cron_events_name = 'mediafromftp_add_on_wpcron_events'.'_'.$cron_user;
1779
 
1780
  return $wp_cron_events_name;
1781
 
@@ -1790,7 +1817,7 @@ class MediaFromFtpAdmin {
1790
 
1791
  $public = get_option( 'blog_public' );
1792
  if ( '0' != $public ) {
1793
- $output .= "\n".'Disallow: '.MEDIAFROMFTP_PLUGIN_DISALLOW_TMP_DIR."\n";
1794
  }
1795
 
1796
  return $output;
19
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
  */
21
 
22
+ $mediafromftpadmin = new MediaFromFtpAdmin();
23
+ add_filter( 'plugin_action_links', array($mediafromftpadmin, 'settings_link'), 10, 2 );
24
+ add_action( 'admin_footer', array($mediafromftpadmin, 'custom_bulk_admin_footer') );
25
+ add_action( 'admin_notices', array($mediafromftpadmin, 'notices') );
26
+
27
  class MediaFromFtpAdmin {
28
 
29
+ private $plugin_base_file;
30
+ private $plugin_base_url;
31
+ private $plugin_dir;
32
+ private $upload_dir;
33
+ private $upload_path;
34
+ private $plugin_tmp_url;
35
+ private $plugin_tmp_dir;
36
+ private $plugin_disallow_tmp_dir;
37
  private $is_add_on_activate;
38
 
39
  /* ==================================================
42
  */
43
  function __construct() {
44
 
45
+ $plugin_base_dir = untrailingslashit(plugin_dir_path( __DIR__ ));
46
+ $slugs = explode('/', $plugin_base_dir);
47
+ $slug = end($slugs);
48
+ $this->plugin_base_file = $slug.'/mediafromftp.php';
49
+ $this->plugin_base_url = plugins_url($path='',$scheme=null).'/'.$slug;
50
+ $this->plugin_dir = untrailingslashit(rtrim($plugin_base_dir, $slug));
51
+
52
+ if(!class_exists('MediaFromFtp')){
53
+ include_once $plugin_base_dir.'/inc/MediaFromFtp.php';
54
+ }
55
+ if(!class_exists('TT_MediaFromFtp_List_Table')){
56
+ require_once( $plugin_base_dir.'/req/MediaFromFtpListTable.php' );
57
+ }
58
+ $mediafromftp = new MediaFromFtp();
59
+ list($this->upload_dir, $upload_url, $this->upload_path) = $mediafromftp->upload_dir_url_path();
60
+
61
+ $this->plugin_tmp_url = $upload_url.'/media-from-ftp-tmp';
62
+ $this->plugin_tmp_dir = $this->upload_dir.'/media-from-ftp-tmp';
63
+ $this->plugin_disallow_tmp_dir = str_replace(home_url(), '', site_url()).'/'.$this->upload_path.'/media-from-ftp-tmp/';
64
+
65
  $category_active = FALSE;
66
  if( function_exists('media_from_ftp_add_on_category_load_textdomain') ){
67
+ include_once $this->plugin_dir.'/media-from-ftp-add-on-category/inc/MediaFromFtpAddOnCategory.php';
68
  $category_active = TRUE;
69
  }
70
  $exif_active = FALSE;
71
  if( function_exists('media_from_ftp_add_on_exif_load_textdomain') ){
72
+ include_once $this->plugin_dir.'/media-from-ftp-add-on-exif/inc/MediaFromFtpAddOnExif.php';
73
  $exif_active = TRUE;
74
  }
75
  $cli_active = FALSE;
76
  if( function_exists('media_from_ftp_add_on_cli_load_textdomain') ){
77
+ require_once( $this->plugin_dir.'/media-from-ftp-add-on-cli/req/MediaFromFtpCli.php' );
78
  $cli_active = TRUE;
79
  }
80
  $wpcron_active = FALSE;
81
  if( function_exists('media_from_ftp_add_on_wpcron_load_textdomain') ){
82
+ include_once $this->plugin_dir.'/media-from-ftp-add-on-wpcron/inc/MediaFromFtpAddOnWpcron.php';
83
  $wpcron_active = TRUE;
84
  }
 
85
  $this->is_add_on_activate = array(
86
  'category' => $category_active,
87
  'exif' => $exif_active,
89
  'wpcron' => $wpcron_active
90
  );
91
 
92
+ add_action( 'admin_menu', array($this, 'add_pages') );
93
+ add_action( 'admin_enqueue_scripts', array($this, 'load_custom_wp_admin_style') );
94
+ add_action( 'admin_footer', array($this, 'load_custom_wp_admin_style2') );
95
+ add_action( 'screen_settings', array($this, 'search_register_show_screen_options'), 10, 2 );
96
+ add_filter( 'set-screen-option', array($this, 'search_register_set_screen_options'), 11, 3 );
97
+ add_filter( 'contextual_help', array($this, 'search_register_help_tab'), 12, 3);
98
+ add_filter( 'robots_txt', array($this, 'custom_robots_txt'), 9999 );
99
 
100
  }
101
 
106
  function settings_link( $links, $file ) {
107
  static $this_plugin;
108
  if ( empty($this_plugin) ) {
109
+ $this_plugin = $this->plugin_base_file;
110
  }
111
  if ( $file == $this_plugin ) {
112
  $links[] = '<a href="'.admin_url('admin.php?page=mediafromftp').'">Media from FTP</a>';
253
  */
254
  function get_help_message($screen_id) {
255
 
256
+ $upload_dir_html = '<span style="color: red;">'.$this->upload_path.'</span>';
257
  $mediafromftp = new MediaFromFtp();
258
 
259
  switch ($screen_id) {
309
  if ($this->is_my_plugin_screen()) {
310
  $mediafromftp_settings = get_option($this->wp_options_name());
311
  if ( $mediafromftp_settings['datetimepicker'] ) {
312
+ wp_enqueue_style( 'jquery-datetimepicker', $this->plugin_base_url.'/css/jquery.datetimepicker.css' );
313
  }
314
+ wp_enqueue_style( 'jquery-responsiveTabs', $this->plugin_base_url.'/css/responsive-tabs.css' );
315
+ wp_enqueue_style( 'jquery-responsiveTabs-style', $this->plugin_base_url.'/css/style.css' );
316
+ wp_enqueue_style( 'mediafromftp', $this->plugin_base_url.'/css/mediafromftp.css' );
317
  wp_enqueue_script( 'jquery' );
318
  if ( $mediafromftp_settings['datetimepicker'] ) {
319
+ wp_enqueue_script( 'jquery-datetimepicker', $this->plugin_base_url.'/js/jquery.datetimepicker.js', null, '2.3.4' );
320
+ wp_enqueue_script( 'jquery-mediafromftp-datetimepicker', $this->plugin_base_url.'/js/jquery.mediafromftp.datetimepicker.js', array('jquery') );
321
  }
322
+ wp_enqueue_script( 'jquery-responsiveTabs', $this->plugin_base_url.'/js/jquery.responsiveTabs.min.js' );
323
 
324
  $handle = 'mediafromftp-ajax-script';
325
  $action1 = 'mediafromftp-update-ajax-action';
326
  $action2 = 'mediafromftp-import-ajax-action';
327
+ wp_enqueue_script( $handle, $this->plugin_base_url.'/js/jquery.mediafromftp.js', array('jquery') );
328
  wp_localize_script( $handle, 'MEDIAFROMFTPUPDATE', array(
329
  'ajax_url' => admin_url('admin-ajax.php'),
330
  'action' => $action1,
946
  </h2>
947
  <div style="clear: both;"></div>
948
 
949
+ <div id="mediafromftp-loading"><img src="<?php echo $this->plugin_base_url.'/css/loading.gif'; ?>"></div>
950
  <div id="mediafromftp-loading-container">
951
  <?php
952
  $MediaFromFtpListTable = new TT_MediaFromFtp_List_Table();
1005
  $mediafromftp = new MediaFromFtp();
1006
  if ( $this->is_add_on_activate['wpcron'] ) {
1007
  $mediafromftpaddonwpcron = new MediaFromFtpAddOnWpcron();
1008
+ include_once $this->plugin_dir.'/media-from-ftp-add-on-wpcron/req/MediaFromFtpCron.php';
1009
  $mediafromftpcron = new MediaFromFtpCron();
1010
  $mediafromftp_addon_wpcron = TRUE;
1011
  }
1105
  </h2>
1106
  <div style="clear: both;"></div>
1107
 
1108
+ <div id="mediafromftp-loading"><img src="<?php echo $this->plugin_base_url.'/css/loading.gif'; ?>"></div>
1109
  <div id="mediafromftp-loading-container">
1110
  <?php
1111
  global $wpdb;
1249
 
1250
  $csv = $csv_head."\n".$csv;
1251
 
1252
+ $csvFileName = $this->plugin_tmp_dir.'/'.$table_name.'.csv';
1253
  if ( isset($_POST['media_from_ftp_put_log']) && $_POST['media_from_ftp_put_log'] ) {
1254
  if ( check_admin_referer('mff_put_log', 'media_from_ftp_put_log') ) {
1255
  if ( !empty($_POST['mediafromftp_put_log']) && $_POST['mediafromftp_put_log'] == 1 ) {
1283
  <?php
1284
  if ( file_exists($csvFileName) ) {
1285
  ?>
1286
+ <form method="post" action="<?php echo $this->plugin_tmp_url.'/'.$table_name.'.csv'; ?>" />
1287
  <?php wp_nonce_field('mff_download', 'media_from_ftp_download'); ?>
1288
  <div>
1289
  <input type="hidden" name="mediafromftp_download" value="1" />
1343
  </h2>
1344
  <div style="clear: both;"></div>
1345
 
1346
+ <div id="mediafromftp-loading"><img src="<?php echo $this->plugin_base_url.'/css/loading.gif'; ?>"></div>
1347
  <div id="medialibraryimport-loading-container">
1348
 
1349
  <?php
1352
  if ( !empty($_FILES['filename']['name']) ) {
1353
  $filename = $_FILES['filename']['tmp_name'];
1354
  $name = basename($filename);
1355
+ move_uploaded_file($filename, $this->plugin_tmp_dir.'/'.$name);
1356
 
1357
  $mediafromftp = new MediaFromFtp();
1358
  ?>
1359
  <h4><?php _e('Assign Authors', 'media-from-ftp'); ?></h4>
1360
  <?php
1361
+ echo $mediafromftp->author_select($this->plugin_tmp_dir.'/'.$name);
1362
  }
1363
  }
1364
  } else if ( isset($_POST['media_from_ftp_select_author']) && $_POST['media_from_ftp_select_author'] ) {
1444
  </div>
1445
  <p>
1446
  <?php
1447
+ if ( is_dir($this->plugin_dir.'/media-from-ftp-add-on-cli') ) {
1448
  ?><div style="margin: 5px; padding: 5px;"><strong><?php
1449
  _e('Installed', 'media-from-ftp');?> & <?php
1450
  if ( $this->is_add_on_activate['cli'] ) {
1472
  </div>
1473
  <p>
1474
  <?php
1475
+ if ( is_dir($this->plugin_dir.'/media-from-ftp-add-on-wpcron') ) {
1476
  ?><div style="margin: 5px; padding: 5px;"><strong><?php
1477
  _e('Installed', 'media-from-ftp');?> & <?php
1478
  if ( $this->is_add_on_activate['wpcron'] ) {
1499
  </div>
1500
  <p>
1501
  <?php
1502
+ if ( is_dir($this->plugin_dir.'/media-from-ftp-add-on-category') ) {
1503
  ?><div style="margin: 5px; padding: 5px;"><strong><?php
1504
  _e('Installed', 'media-from-ftp');?> & <?php
1505
  if ( $this->is_add_on_activate['category'] ) {
1528
 
1529
  <p>
1530
  <?php
1531
+ if ( is_dir($this->plugin_dir.'/media-from-ftp-add-on-exif') ) {
1532
  ?><div style="margin: 5px; padding: 5px;"><strong><?php
1533
  _e('Installed', 'media-from-ftp');?> & <?php
1534
  if ( $this->is_add_on_activate['exif'] ) {
1661
  }
1662
  if (!empty($_POST['searchdir'])){
1663
  $searchdir = urldecode($_POST['searchdir']);
1664
+ if ( strpos( realpath(wp_normalize_path(ABSPATH.$searchdir)), $this->upload_dir) === FALSE ) {
1665
+ $searchdir = $this->upload_path;
1666
+ $mediafromftp_settings['basedir'] = $this->upload_path;
1667
  }
1668
  $mediafromftp_settings['searchdir'] = $searchdir;
1669
  } else {
1670
+ if ( $this->upload_path <> $mediafromftp_settings['basedir'] ) {
1671
+ $mediafromftp_settings['searchdir'] = $this->upload_path;
1672
+ $mediafromftp_settings['basedir'] = $this->upload_path;
1673
  }
1674
  }
1675
  if (!empty($_POST['ext2type'])){
1789
  */
1790
  function wp_options_name(){
1791
 
1792
+ $wp_options_name = 'mediafromftp_settings'.'_'.get_current_user_id();
 
 
 
1793
 
1794
  return $wp_options_name;
1795
 
1802
  */
1803
  function wp_add_on_wpcron_events_name(){
1804
 
1805
+ $wp_cron_events_name = 'mediafromftp_add_on_wpcron_events'.'_'.get_current_user_id();
 
 
 
1806
 
1807
  return $wp_cron_events_name;
1808
 
1817
 
1818
  $public = get_option( 'blog_public' );
1819
  if ( '0' != $public ) {
1820
+ $output .= "\n".'Disallow: '.$this->plugin_disallow_tmp_dir."\n";
1821
  }
1822
 
1823
  return $output;
req/MediaFromFtpAjax.php CHANGED
@@ -19,8 +19,12 @@
19
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
  */
21
 
 
 
22
  class MediaFromFtpAjax {
23
 
 
 
24
  private $is_add_on_activate;
25
 
26
  /* ==================================================
@@ -29,9 +33,24 @@ class MediaFromFtpAjax {
29
  */
30
  function __construct() {
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  $category_active = FALSE;
33
  if( function_exists('media_from_ftp_add_on_category_load_textdomain') ){
34
- include_once MEDIAFROMFTP_ADDON_CATEGORY_PLUGIN_BASE_DIR.'/inc/MediaFromFtpAddOnCategory.php';
35
  $category_active = TRUE;
36
  }
37
 
@@ -39,12 +58,12 @@ class MediaFromFtpAjax {
39
  'category' => $category_active
40
  );
41
 
42
- if(!class_exists('MediaFromFtpAdmin')){
43
- require_once( MEDIAFROMFTP_PLUGIN_BASE_DIR.'/req/MediaFromFtpAdmin.php' );
44
- }
45
- if(!class_exists('MediaFromFtp')){
46
- include_once MEDIAFROMFTP_PLUGIN_BASE_DIR.'/inc/MediaFromFtp.php';
47
- }
48
 
49
  }
50
 
@@ -178,7 +197,7 @@ class MediaFromFtpAjax {
178
  if ( isset( $_REQUEST['nonce'] ) && wp_verify_nonce( $_REQUEST['nonce'], $action2 ) ) {
179
  if ( current_user_can( 'upload_files' ) ) {
180
  $file = sanitize_text_field($_POST["file"]);
181
- $filepath = str_replace(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.'/' , '', $file);
182
  if ( is_file($file) ) {
183
  if ( !empty($_POST["db_array"]) ) {
184
  $db_array = $_POST["db_array"];
@@ -207,10 +226,10 @@ class MediaFromFtpAjax {
207
  update_post_meta( intval($db_array['ID']), '_wp_attachment_image_alt', sanitize_text_field($_POST["db_wp_attachment_image_alt"]) );
208
  }
209
  $msg = 'success_db';
210
- $output_html = $msg.','.'<div>'.__('Media').': <a href="'.get_permalink($db_array['ID']).'" target="_blank" style="text-decoration: none; color: green;">'.$this->esc_title($db_array['post_title']).'</a>: '.'<a href="'.MEDIAFROMFTP_PLUGIN_UPLOAD_URL.'/'.$filepath.'" target="_blank" style="text-decoration: none;">'.$filepath.'</a></div>';
211
  } else {
212
  $msg = 'success';
213
- $output_html = $msg.','.'<div>'.__('Thumbnail').': '.'<a href="'.MEDIAFROMFTP_PLUGIN_UPLOAD_URL.'/'.$filepath.'" target="_blank" style="text-decoration: none;">'.$filepath.'</a></div>';
214
  }
215
  } else {
216
  $error_string = __('No file!', 'media-from-ftp');
19
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
  */
21
 
22
+ $mediafromftpajax = new MediaFromFtpAjax();
23
+
24
  class MediaFromFtpAjax {
25
 
26
+ private $upload_dir;
27
+ private $upload_url;
28
  private $is_add_on_activate;
29
 
30
  /* ==================================================
33
  */
34
  function __construct() {
35
 
36
+ $plugin_base_dir = untrailingslashit(plugin_dir_path( __DIR__ ));
37
+ $slugs = explode('/', $plugin_base_dir);
38
+ $slug = end($slugs);
39
+ $plugin_dir = untrailingslashit(rtrim($plugin_base_dir, $slug));
40
+
41
+ if(!class_exists('MediaFromFtp')){
42
+ include_once $plugin_base_dir.'/inc/MediaFromFtp.php';
43
+ }
44
+ $mediafromftp = new MediaFromFtp();
45
+ list($this->upload_dir, $this->upload_url, $upload_path) = $mediafromftp->upload_dir_url_path();
46
+
47
+ if(!class_exists('MediaFromFtpAdmin')){
48
+ require_once( $plugin_base_dir.'/req/MediaFromFtpAdmin.php' );
49
+ }
50
+
51
  $category_active = FALSE;
52
  if( function_exists('media_from_ftp_add_on_category_load_textdomain') ){
53
+ include_once $plugin_dir.'/media-from-ftp-add-on-category/inc/MediaFromFtpAddOnCategory.php';
54
  $category_active = TRUE;
55
  }
56
 
58
  'category' => $category_active
59
  );
60
 
61
+ $action1 = 'mediafromftp-update-ajax-action';
62
+ $action2 = 'mediafromftp-import-ajax-action';
63
+ add_action( 'wp_ajax_'.$action1, array($this, 'mediafromftp_update_callback') );
64
+ add_action( 'wp_ajax_mediafromftp_message', array($this, 'mediafromftp_message_callback') );
65
+ add_action( 'wp_ajax_'.$action2, array($this, 'mediafromftp_medialibraryimport_update_callback') );
66
+ add_action( 'wp_ajax_mediafromftp_medialibraryimport_message', array($this, 'mediafromftp_medialibraryimport_message_callback') );
67
 
68
  }
69
 
197
  if ( isset( $_REQUEST['nonce'] ) && wp_verify_nonce( $_REQUEST['nonce'], $action2 ) ) {
198
  if ( current_user_can( 'upload_files' ) ) {
199
  $file = sanitize_text_field($_POST["file"]);
200
+ $filepath = str_replace($this->upload_dir.'/' , '', $file);
201
  if ( is_file($file) ) {
202
  if ( !empty($_POST["db_array"]) ) {
203
  $db_array = $_POST["db_array"];
226
  update_post_meta( intval($db_array['ID']), '_wp_attachment_image_alt', sanitize_text_field($_POST["db_wp_attachment_image_alt"]) );
227
  }
228
  $msg = 'success_db';
229
+ $output_html = $msg.','.'<div>'.__('Media').': <a href="'.get_permalink($db_array['ID']).'" target="_blank" style="text-decoration: none; color: green;">'.$this->esc_title($db_array['post_title']).'</a>: '.'<a href="'.$this->upload_url.'/'.$filepath.'" target="_blank" style="text-decoration: none;">'.$filepath.'</a></div>';
230
  } else {
231
  $msg = 'success';
232
+ $output_html = $msg.','.'<div>'.__('Thumbnail').': '.'<a href="'.$this->upload_url.'/'.$filepath.'" target="_blank" style="text-decoration: none;">'.$filepath.'</a></div>';
233
  }
234
  } else {
235
  $error_string = __('No file!', 'media-from-ftp');
req/MediaFromFtpListTable.php CHANGED
@@ -35,23 +35,28 @@ class TT_MediaFromFtp_List_Table extends WP_List_Table {
35
 
36
  function __construct(){
37
 
 
 
 
 
 
38
  $category_active = FALSE;
39
  if( function_exists('media_from_ftp_add_on_category_load_textdomain') ){
40
- include_once MEDIAFROMFTP_ADDON_CATEGORY_PLUGIN_BASE_DIR.'/inc/MediaFromFtpAddOnCategory.php';
41
  $category_active = TRUE;
42
  }
43
  if( function_exists('media_from_ftp_add_on_exif_load_textdomain') ){
44
- include_once MEDIAFROMFTP_ADDON_EXIF_PLUGIN_BASE_DIR.'/inc/MediaFromFtpAddOnExif.php';
45
  }
46
  if( function_exists('media_from_ftp_add_on_cli_load_textdomain') ){
47
- require_once( MEDIAFROMFTP_ADDON_CLI_PLUGIN_BASE_DIR.'/req/MediaFromFtpCli.php' );
48
  }
49
  if( function_exists('media_from_ftp_add_on_wpcron_load_textdomain') ){
50
- include_once MEDIAFROMFTP_ADDON_WPCRON_PLUGIN_BASE_DIR.'/inc/MediaFromFtpAddOnWpcron.php';
51
  }
52
 
53
  if(!class_exists('MediaFromFtp')){
54
- include_once MEDIAFROMFTP_PLUGIN_BASE_DIR.'/inc/MediaFromFtp.php';
55
  }
56
 
57
  // Media Library Categories
@@ -139,7 +144,6 @@ class TT_MediaFromFtp_List_Table extends WP_List_Table {
139
  $emlcategoryhtml = NULL;
140
  $mlacategoryhtml = NULL;
141
  if ( $this->is_add_on_activate['category'] ) {
142
- include_once MEDIAFROMFTP_ADDON_CATEGORY_PLUGIN_BASE_DIR.'/inc/MediaFromFtpAddOnCategory.php';
143
  $mediafromftpaddoncategory = new MediaFromFtpAddOnCategory();
144
  $mlccategoryhtml = $mediafromftpaddoncategory->mlc_category_check_html($count, $mlccs);
145
  $emlcategoryhtml = $mediafromftpaddoncategory->eml_category_check_html($count, $emlcs);
@@ -173,10 +177,7 @@ class TT_MediaFromFtp_List_Table extends WP_List_Table {
173
  */
174
  function wp_options_name(){
175
 
176
- $user = wp_get_current_user();
177
- $cron_user = $user->ID;
178
-
179
- $wp_options_name = 'mediafromftp_settings'.'_'.$cron_user;
180
 
181
  return $wp_options_name;
182
 
35
 
36
  function __construct(){
37
 
38
+ $plugin_base_dir = untrailingslashit(plugin_dir_path( __DIR__ ));
39
+ $slugs = explode('/', $plugin_base_dir);
40
+ $slug = end($slugs);
41
+ $plugin_dir = untrailingslashit(rtrim($plugin_base_dir, $slug));
42
+
43
  $category_active = FALSE;
44
  if( function_exists('media_from_ftp_add_on_category_load_textdomain') ){
45
+ include_once $plugin_dir.'/media-from-ftp-add-on-category/inc/MediaFromFtpAddOnCategory.php';
46
  $category_active = TRUE;
47
  }
48
  if( function_exists('media_from_ftp_add_on_exif_load_textdomain') ){
49
+ include_once $plugin_dir.'/media-from-ftp-add-on-exif/inc/MediaFromFtpAddOnExif.php';
50
  }
51
  if( function_exists('media_from_ftp_add_on_cli_load_textdomain') ){
52
+ require_once( $plugin_dir.'/media-from-ftp-add-on-cli/req/MediaFromFtpCli.php' );
53
  }
54
  if( function_exists('media_from_ftp_add_on_wpcron_load_textdomain') ){
55
+ include_once $plugin_dir.'/media-from-ftp-add-on-wpcron/inc/MediaFromFtpAddOnWpcron.php';
56
  }
57
 
58
  if(!class_exists('MediaFromFtp')){
59
+ include_once $plugin_base_dir.'/inc/MediaFromFtp.php';
60
  }
61
 
62
  // Media Library Categories
144
  $emlcategoryhtml = NULL;
145
  $mlacategoryhtml = NULL;
146
  if ( $this->is_add_on_activate['category'] ) {
 
147
  $mediafromftpaddoncategory = new MediaFromFtpAddOnCategory();
148
  $mlccategoryhtml = $mediafromftpaddoncategory->mlc_category_check_html($count, $mlccs);
149
  $emlcategoryhtml = $mediafromftpaddoncategory->eml_category_check_html($count, $emlcs);
177
  */
178
  function wp_options_name(){
179
 
180
+ $wp_options_name = 'mediafromftp_settings'.'_'.get_current_user_id();
 
 
 
181
 
182
  return $wp_options_name;
183
 
req/MediaFromFtpRegist.php CHANGED
@@ -19,8 +19,37 @@
19
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
  */
21
 
 
 
22
  class MediaFromFtpRegist {
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  /* ==================================================
25
  * Settings Log Settings
26
  * @since 9.19
@@ -127,8 +156,8 @@ class MediaFromFtpRegist {
127
  $wp_cron_events_name = 'mediafromftp_add_on_wpcron_events'.'_'.$cron_user;
128
 
129
  $pagemax = 20;
130
- $basedir = MEDIAFROMFTP_PLUGIN_UPLOAD_PATH;
131
- $searchdir = MEDIAFROMFTP_PLUGIN_UPLOAD_PATH;
132
  $ext2typefilter = 'all';
133
  $extfilter = 'all';
134
  $search_display_metadata = TRUE;
19
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
  */
21
 
22
+ $mediafromftpregist = new MediaFromFtpRegist();
23
+
24
  class MediaFromFtpRegist {
25
 
26
+ private $upload_path;
27
+
28
+ /* ==================================================
29
+ * Construct
30
+ * @since 9.81
31
+ */
32
+ function __construct() {
33
+
34
+ $plugin_base_dir = untrailingslashit(plugin_dir_path( __DIR__ ));
35
+
36
+ if(!class_exists('MediaFromFtp')){
37
+ include_once $plugin_base_dir.'/inc/MediaFromFtp.php';
38
+ }
39
+ $mediafromftp = new MediaFromFtp();
40
+ list($upload_dir, $upload_url, $this->upload_path) = $mediafromftp->upload_dir_url_path();
41
+ $plugin_tmp_dir = $upload_dir.'/media-from-ftp-tmp';
42
+ // Make tmp dir
43
+ if ( !is_dir( $plugin_tmp_dir ) ) {
44
+ wp_mkdir_p( $plugin_tmp_dir );
45
+ }
46
+
47
+ register_activation_hook( __FILE__, array($this, 'log_settings') );
48
+ add_action( 'plugins_loaded', array($this, 'log_settings') );
49
+ add_action( 'admin_init', array($this, 'register_settings') );
50
+
51
+ }
52
+
53
  /* ==================================================
54
  * Settings Log Settings
55
  * @since 9.19
156
  $wp_cron_events_name = 'mediafromftp_add_on_wpcron_events'.'_'.$cron_user;
157
 
158
  $pagemax = 20;
159
+ $basedir = $this->upload_path;
160
+ $searchdir = $this->upload_path;
161
  $ext2typefilter = 'all';
162
  $extfilter = 'all';
163
  $search_display_metadata = TRUE;