Media from FTP - Version 10.01

Version Description

Fixed problem of database error when first activation. Added file type and file extension to the search options on the setting page.

Download this release

Release Info

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

Code changes from version 10.00 to 10.01

inc/MediaFromFtp.php CHANGED
@@ -644,6 +644,64 @@ class MediaFromFtp {
644
 
645
  }
646
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
647
  /* ==================================================
648
  * @param array $mediafromftp_settings
649
  * @return string $form_html
@@ -668,6 +726,7 @@ class MediaFromFtp {
668
  $wordpress_path = wp_normalize_path(ABSPATH);
669
 
670
  $linkselectbox = $this->dir_select_box($searchdir, $character_code, $wordpress_path);
 
671
 
672
  ?>
673
  <div class="wp-filter" style="margin: 0px;"> <!-- wp-admin/css/list-tables.css -->
@@ -676,29 +735,7 @@ class MediaFromFtp {
676
  <?php echo $linkselectbox; ?>
677
  <?php submit_button( __('Search'), 'large', '', FALSE ); ?>
678
  <span style="margin-right: 1em;"></span>
679
- <select name="ext2type" style="width: 110px;">
680
- <option value="all" <?php if ($ext2typefilter === 'all') echo 'selected';?>><?php echo esc_attr( __('All types', 'media-from-ftp') ); ?></option>
681
- <option value="image" <?php if ($ext2typefilter === 'image') echo 'selected';?>>image</option>
682
- <option value="audio" <?php if ($ext2typefilter === 'audio') echo 'selected';?>>audio</option>
683
- <option value="video" <?php if ($ext2typefilter === 'video') echo 'selected';?>>video</option>
684
- <option value="document" <?php if ($ext2typefilter === 'document') echo 'selected';?>>document</option>
685
- <option value="spreadsheet" <?php if ($ext2typefilter === 'spreadsheet') echo 'selected';?>>spreadsheet</option>
686
- <option value="interactive" <?php if ($ext2typefilter === 'interactive') echo 'selected';?>>interactive</option>
687
- <option value="text" <?php if ($ext2typefilter === 'text') echo 'selected';?>>text</option>
688
- <option value="archive" <?php if ($ext2typefilter === 'archive') echo 'selected';?>>archive</option>
689
- <option value="code" <?php if ($ext2typefilter === 'code') echo 'selected';?>>code</option>
690
- </select>
691
- <select name="extension" style="width: 120px;">
692
- <option value="all" <?php if ($extfilter === 'all') echo 'selected';?>><?php echo esc_attr( __('All extensions', 'media-from-ftp') ); ?></option>
693
- <?php
694
- $extensions = $this->scan_extensions($ext2typefilter);
695
- foreach ($extensions as $extselect) {
696
- ?>
697
- <option value="<?php echo $extselect; ?>" <?php if ($extfilter === $extselect) echo 'selected';?>><?php echo $extselect; ?></option>
698
- <?php
699
- }
700
- ?>
701
- </select>
702
  <?php
703
  if ( empty($searchtext) ) {
704
  ?>
644
 
645
  }
646
 
647
+ /* ==================================================
648
+ * @param string $ext2typefilter
649
+ * @param string $extfilter
650
+ * @return string $typeextselectbox
651
+ * @since 10.01
652
+ */
653
+ public function type_ext_select_box($ext2typefilter, $extfilter) {
654
+
655
+ $typeextselectbox = NULL;
656
+ $typeextselectbox .= '<select name="ext2type" style="width: 110px;">';
657
+ $typeextselectbox .= '<option value="all"';
658
+ if ($ext2typefilter === 'all') $typeextselectbox .= ' selected';
659
+ $typeextselectbox .= '>'.esc_attr( __('All types', 'media-from-ftp') ).'</option>';
660
+ $typeextselectbox .= '<option value="image"';
661
+ if ($ext2typefilter === 'image') $typeextselectbox .= ' selected';
662
+ $typeextselectbox .= '>image</option>';
663
+ $typeextselectbox .= '<option value="audio"';
664
+ if ($ext2typefilter === 'audio') $typeextselectbox .= ' selected';
665
+ $typeextselectbox .= '>audio</option>';
666
+ $typeextselectbox .= '<option value="video"';
667
+ if ($ext2typefilter === 'video') $typeextselectbox .= ' selected';
668
+ $typeextselectbox .= '>video</option>';
669
+ $typeextselectbox .= '<option value="document"';
670
+ if ($ext2typefilter === 'document') $typeextselectbox .= ' selected';
671
+ $typeextselectbox .= '>document</option>';
672
+ $typeextselectbox .= '<option value="spreadsheet"';
673
+ if ($ext2typefilter === 'spreadsheet') $typeextselectbox .= ' selected';
674
+ $typeextselectbox .= '>spreadsheet</option>';
675
+ $typeextselectbox .= '<option value="interactive"';
676
+ if ($ext2typefilter === 'interactive') $typeextselectbox .= ' selected';
677
+ $typeextselectbox .= '>interactive</option>';
678
+ $typeextselectbox .= '<option value="text"';
679
+ if ($ext2typefilter === 'text') $typeextselectbox .= ' selected';
680
+ $typeextselectbox .= '>text</option>';
681
+ $typeextselectbox .= '<option value="archive"';
682
+ if ($ext2typefilter === 'archive') $typeextselectbox .= ' selected';
683
+ $typeextselectbox .= '>archive</option>';
684
+ $typeextselectbox .= '<option value="code"';
685
+ if ($ext2typefilter === 'code') $typeextselectbox .= ' selected';
686
+ $typeextselectbox .= '>code</option>';
687
+ $typeextselectbox .= '</select>';
688
+ $typeextselectbox .= '<select name="extension" style="width: 120px;">';
689
+ $typeextselectbox .= '<option value="all"';
690
+ if ($extfilter === 'all') $typeextselectbox .= ' selected';
691
+ $typeextselectbox .= '>'.esc_attr( __('All extensions', 'media-from-ftp') ).'</option>';
692
+
693
+ $extensions = $this->scan_extensions($ext2typefilter);
694
+ foreach ($extensions as $extselect) {
695
+ $typeextselectbox .= '<option value="'.$extselect.'"';
696
+ if ($extfilter === $extselect) $typeextselectbox .= ' selected';
697
+ $typeextselectbox .= '>'.$extselect.'</option>';
698
+ }
699
+ $typeextselectbox .= '</select>';
700
+
701
+ return $typeextselectbox;
702
+
703
+ }
704
+
705
  /* ==================================================
706
  * @param array $mediafromftp_settings
707
  * @return string $form_html
726
  $wordpress_path = wp_normalize_path(ABSPATH);
727
 
728
  $linkselectbox = $this->dir_select_box($searchdir, $character_code, $wordpress_path);
729
+ $linkselectbox2 = $this->type_ext_select_box($ext2typefilter, $extfilter);
730
 
731
  ?>
732
  <div class="wp-filter" style="margin: 0px;"> <!-- wp-admin/css/list-tables.css -->
735
  <?php echo $linkselectbox; ?>
736
  <?php submit_button( __('Search'), 'large', '', FALSE ); ?>
737
  <span style="margin-right: 1em;"></span>
738
+ <?php echo $linkselectbox2; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
739
  <?php
740
  if ( empty($searchtext) ) {
741
  ?>
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: 10.00
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/
2
  /*
3
  Plugin Name: Media from FTP
4
  Plugin URI: https://wordpress.org/plugins/media-from-ftp/
5
+ Version: 10.01
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/
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: 10.00
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -126,6 +126,10 @@ Register to media library from files that have been uploaded by FTP.
126
 
127
  == Changelog ==
128
 
 
 
 
 
129
  = 10.00 =
130
  Fixed problem of error of "Screen Options".
131
  Fixed fine problem.
5
  Requires at least: 3.6.0
6
  Requires PHP: 5.3.0
7
  Tested up to: 4.9
8
+ Stable tag: 10.01
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
126
 
127
  == Changelog ==
128
 
129
+ = 10.01 =
130
+ Fixed problem of database error when first activation.
131
+ Added file type and file extension to the search options on the setting page.
132
+
133
  = 10.00 =
134
  Fixed problem of error of "Screen Options".
135
  Fixed fine problem.
req/MediaFromFtpAdmin.php CHANGED
@@ -769,8 +769,9 @@ class MediaFromFtpAdmin {
769
  <form method="post" id="mediafromftp_search_form" action="<?php echo $scriptname; ?>">
770
  <?php wp_nonce_field('mff_search', 'media_from_ftp_search'); ?>
771
  <div class="item-mediafromftp-settings">
772
- <h3><?php echo __('Search').' '.__('directory', 'media-from-ftp'); ?></h3>
773
  <?php echo $mediafromftp->dir_select_box($mediafromftp_settings['searchdir'], $mediafromftp_settings['character_code'], wp_normalize_path(ABSPATH)); ?>
 
774
  </div>
775
  <?php echo $mediafromftp->search_option_html($mediafromftp_settings); ?>
776
  <div style="display: block;padding:5px 5px">
769
  <form method="post" id="mediafromftp_search_form" action="<?php echo $scriptname; ?>">
770
  <?php wp_nonce_field('mff_search', 'media_from_ftp_search'); ?>
771
  <div class="item-mediafromftp-settings">
772
+ <h3><?php echo __('Search').' '.__('directory', 'media-from-ftp').' - '.__('type').' - '.__('extension'); ?></h3>
773
  <?php echo $mediafromftp->dir_select_box($mediafromftp_settings['searchdir'], $mediafromftp_settings['character_code'], wp_normalize_path(ABSPATH)); ?>
774
+ <?php echo $mediafromftp->type_ext_select_box($mediafromftp_settings['ext2typefilter'], $mediafromftp_settings['extfilter']); ?>
775
  </div>
776
  <?php echo $mediafromftp->search_option_html($mediafromftp_settings); ?>
777
  <div style="display: block;padding:5px 5px">
req/MediaFromFtpRegist.php CHANGED
@@ -44,8 +44,7 @@ class MediaFromFtpRegist {
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
  }
@@ -63,56 +62,7 @@ class MediaFromFtpRegist {
63
  global $wpdb;
64
  $log_name = $wpdb->prefix.'mediafromftp_log';
65
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
66
- $table_search = $wpdb->get_row("SHOW TABLES FROM " .DB_NAME. " LIKE '" .$log_name. "'");
67
- if ( $wpdb->num_rows == 1 ) { // db_version 1.0, 2.0
68
- $records = $wpdb->get_results("SELECT * FROM $log_name");
69
- $wpdb->query("DELETE FROM $log_name");
70
-
71
- $wpdb->query("ALTER TABLE $log_name DROP thumbnail1, DROP thumbnail2, DROP thumbnail3, DROP thumbnail4, DROP thumbnail5, DROP thumbnail6");
72
- $wpdb->query("ALTER TABLE $log_name ADD thumbnail longtext");
73
- $wpdb->query("ALTER TABLE $log_name ADD mlccategories longtext");
74
- $wpdb->query("ALTER TABLE $log_name ADD emlcategories longtext");
75
- $wpdb->query("ALTER TABLE $log_name ADD mlacategories longtext");
76
- $wpdb->query("ALTER TABLE $log_name ADD mlatags longtext");
77
-
78
- foreach ( $records as $record ) {
79
- $thumbnail = NULL;
80
- $thumbnails = array();
81
- if ( !empty($record->thumbnail1) ) { $thumbnails[0] = $record->thumbnail1; }
82
- if ( !empty($record->thumbnail2) ) { $thumbnails[1] = $record->thumbnail2; }
83
- if ( !empty($record->thumbnail3) ) { $thumbnails[2] = $record->thumbnail3; }
84
- if ( !empty($record->thumbnail4) ) { $thumbnails[3] = $record->thumbnail4; }
85
- if ( !empty($record->thumbnail5) ) { $thumbnails[4] = $record->thumbnail5; }
86
- if ( !empty($record->thumbnail6) ) { $thumbnails[5] = $record->thumbnail6; }
87
- if ( !empty($thumbnails) ) {
88
- $thumbnail = json_encode($thumbnails);
89
- $thumbnail = str_replace('\\', '', $thumbnail);
90
- } else {
91
- $thumbnail = $record->thumbnail;
92
- }
93
-
94
- $log_arr = array(
95
- 'id' => $record->id,
96
- 'user' => $record->user,
97
- 'title' => $record->title,
98
- 'permalink' => $record->permalink,
99
- 'url' => $record->url,
100
- 'filename' => $record->filename,
101
- 'time' => $record->time,
102
- 'filetype' => $record->filetype,
103
- 'filesize' => $record->filesize,
104
- 'exif' => $record->exif,
105
- 'length' => $record->length,
106
- 'thumbnail' => $thumbnail,
107
- 'mlccategories' => NULL,
108
- 'emlcategories' => NULL,
109
- 'mlacategories' => NULL,
110
- 'mlatags' => NULL
111
- );
112
- $wpdb->insert( $log_name, $log_arr);
113
- $wpdb->show_errors();
114
- }
115
- } else {
116
  // from version 9.57
117
  $sql = "CREATE TABLE " . $log_name . " (
118
  meta_id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -136,6 +86,58 @@ class MediaFromFtpRegist {
136
  )
137
  CHARACTER SET 'utf8';";
138
  dbDelta($sql);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
  update_option( 'mediafromftp_log_version', $mediafromftp_log_db_version );
141
  }
44
  wp_mkdir_p( $plugin_tmp_dir );
45
  }
46
 
47
+ register_activation_hook( $plugin_base_dir.'/mediafromftp.php', array($this, 'log_settings') );
 
48
  add_action( 'admin_init', array($this, 'register_settings') );
49
 
50
  }
62
  global $wpdb;
63
  $log_name = $wpdb->prefix.'mediafromftp_log';
64
  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
65
+ if ( !$installed_ver ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  // from version 9.57
67
  $sql = "CREATE TABLE " . $log_name . " (
68
  meta_id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
86
  )
87
  CHARACTER SET 'utf8';";
88
  dbDelta($sql);
89
+ } else {
90
+ $table_search = $wpdb->get_row("SHOW TABLES FROM " .DB_NAME. " LIKE '" .$log_name. "'");
91
+ if ( $wpdb->num_rows == 1 ) { // db_version 1.0, 2.0
92
+ $records = $wpdb->get_results("SELECT * FROM $log_name");
93
+ $wpdb->query("DELETE FROM $log_name");
94
+
95
+ $wpdb->query("ALTER TABLE $log_name DROP thumbnail1, DROP thumbnail2, DROP thumbnail3, DROP thumbnail4, DROP thumbnail5, DROP thumbnail6");
96
+ $wpdb->query("ALTER TABLE $log_name ADD thumbnail longtext");
97
+ $wpdb->query("ALTER TABLE $log_name ADD mlccategories longtext");
98
+ $wpdb->query("ALTER TABLE $log_name ADD emlcategories longtext");
99
+ $wpdb->query("ALTER TABLE $log_name ADD mlacategories longtext");
100
+ $wpdb->query("ALTER TABLE $log_name ADD mlatags longtext");
101
+
102
+ foreach ( $records as $record ) {
103
+ $thumbnail = NULL;
104
+ $thumbnails = array();
105
+ if ( !empty($record->thumbnail1) ) { $thumbnails[0] = $record->thumbnail1; }
106
+ if ( !empty($record->thumbnail2) ) { $thumbnails[1] = $record->thumbnail2; }
107
+ if ( !empty($record->thumbnail3) ) { $thumbnails[2] = $record->thumbnail3; }
108
+ if ( !empty($record->thumbnail4) ) { $thumbnails[3] = $record->thumbnail4; }
109
+ if ( !empty($record->thumbnail5) ) { $thumbnails[4] = $record->thumbnail5; }
110
+ if ( !empty($record->thumbnail6) ) { $thumbnails[5] = $record->thumbnail6; }
111
+ if ( !empty($thumbnails) ) {
112
+ $thumbnail = json_encode($thumbnails);
113
+ $thumbnail = str_replace('\\', '', $thumbnail);
114
+ } else {
115
+ $thumbnail = $record->thumbnail;
116
+ }
117
+
118
+ $log_arr = array(
119
+ 'id' => $record->id,
120
+ 'user' => $record->user,
121
+ 'title' => $record->title,
122
+ 'permalink' => $record->permalink,
123
+ 'url' => $record->url,
124
+ 'filename' => $record->filename,
125
+ 'time' => $record->time,
126
+ 'filetype' => $record->filetype,
127
+ 'filesize' => $record->filesize,
128
+ 'exif' => $record->exif,
129
+ 'length' => $record->length,
130
+ 'thumbnail' => $thumbnail,
131
+ 'mlccategories' => NULL,
132
+ 'emlcategories' => NULL,
133
+ 'mlacategories' => NULL,
134
+ 'mlatags' => NULL
135
+ );
136
+ $wpdb->insert( $log_name, $log_arr);
137
+ $wpdb->show_errors();
138
+ }
139
+
140
+ }
141
  }
142
  update_option( 'mediafromftp_log_version', $mediafromftp_log_db_version );
143
  }