Media from FTP - Version 11.11

Version Description

Fixed a problem with the output of metadata.

Download this release

Release Info

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

Code changes from version 11.10 to 11.11

inc/class-mediafromftp.php CHANGED
@@ -1075,29 +1075,24 @@ class MediaFromFtp {
1075
  public function output_metadata( $ext, $attach_id, $metadata, $character_code, $exif_text_tag ) {
1076
 
1077
  $imagethumburls = array();
1078
- $mimetype = null;
1079
  $length = null;
1080
  $exif_text = null;
1081
  $filetype = wp_check_filetype( $this->mb_encode_multibyte( get_attached_file( $attach_id ), $character_code ) );
 
1082
  if ( 'image' === wp_ext2type( $ext ) || 'pdf' === strtolower( $ext ) ) {
1083
- $wp_attached_file = get_post_meta( $attach_id, '_wp_attached_file', true );
1084
- $imagethumburl_base = $this->upload_url . '/' . rtrim( $wp_attached_file, wp_basename( $wp_attached_file ) );
 
 
 
1085
  if ( ! empty( $metadata ) ) {
1086
- foreach ( $metadata as $key1 => $key2 ) {
1087
- if ( 'sizes' === $key1 ) {
1088
- foreach ( $metadata[ $key1 ] as $key2 => $key3 ) {
1089
- $imagethumburls[ $key2 ] = $imagethumburl_base . $metadata['sizes'][ $key2 ]['file'];
1090
- }
1091
- }
1092
  }
1093
  }
1094
- $mimetype = $filetype['ext'] . '(' . $filetype['type'] . ')';
1095
  } else if ( 'video' === wp_ext2type( $ext ) || 'audio' === wp_ext2type( $ext ) ) {
1096
- $mimetype = $metadata['fileformat'] . '(' . $metadata['mime_type'] . ')';
1097
  $length = $metadata['length_formatted'];
1098
- } else {
1099
- $metadata = null;
1100
- $mimetype = $filetype['ext'] . '(' . $filetype['type'] . ')';
1101
  }
1102
 
1103
  $stamptime = get_the_time( 'Y-n-j ', $attach_id ) . get_the_time( 'G:i:s', $attach_id );
@@ -1148,19 +1143,21 @@ class MediaFromFtp {
1148
  */
1149
  public function output_html_and_log( $metadata, $ext, $attach_id, $new_attach_title, $new_url_attach, $imagethumburls, $mimetype, $length, $stamptime, $file_size, $exif_text, $image_attr_thumbnail, $mediafromftp_settings, $cat_html, $mlccategory, $emlcategory, $mlacategory, $mlatag ) {
1150
 
1151
- $thumbnails = array();
 
 
1152
 
1153
  $output_html = '<div style="border-bottom: 1px solid; padding-top: 5px; padding-bottom: 5px;">';
1154
  $output_html .= '<img width="40" height="40" src="' . $image_attr_thumbnail[0] . '" style="float: left; margin: 5px;">';
1155
  $output_html .= '<div style="overflow: hidden;">';
1156
  $output_html .= '<div>ID: ' . $attach_id . '</div>';
1157
  $output_html .= '<div>' . __( 'Title' ) . ': ' . $new_attach_title . '</div>';
1158
- $output_html .= '<div>' . __( 'Permalink:' ) . ' <a href="' . get_attachment_link( $attach_id ) . '" target="_blank" rel="noopener noreferrer" style="text-decoration: none; word-break: break-all;">' . get_attachment_link( $attach_id ) . '</a></div>';
1159
- $output_html .= '<div>URL: <a href="' . wp_get_attachment_url( $attach_id ) . '" target="_blank" rel="noopener noreferrer" style="text-decoration: none; word-break: break-all;">' . wp_get_attachment_url( $attach_id ) . '</a></div>';
1160
- $output_html .= '<div>' . __( 'File name:' ) . ' ' . wp_basename( wp_get_attachment_url( $attach_id ) ) . '</div>';
1161
  if ( ! empty( $metadata['original_image'] ) ) {
1162
- $output_html .= '<div>' . __( 'Original URL', 'media-from-ftp' ) . ': <a href="' . wp_get_original_image_url( $attach_id ) . '" target="_blank" rel="noopener noreferrer" style="text-decoration: none; word-break: break-all;">' . wp_get_original_image_url( $attach_id ) . '</a></div>';
1163
- $output_html .= '<div>' . __( 'Original File name', 'media-from-ftp' ) . ': ' . wp_basename( wp_get_original_image_url( $attach_id ) ) . '</div>';
1164
  }
1165
  $output_html .= '<div>' . __( 'Date/Time' ) . ': ' . $stamptime . '</div>';
1166
  if ( ! $file_size ) {
@@ -1172,10 +1169,11 @@ class MediaFromFtp {
1172
  $output_html .= '<div>' . __( 'File size:' ) . ' ' . $file_size . '</div>';
1173
  if ( ( 'image' === wp_ext2type( $ext ) || 'pdf' === strtolower( $ext ) ) && ! empty( $imagethumburls ) ) {
1174
  $output_html .= '<div>' . __( 'Images' ) . ': ';
 
1175
  $thumb_count = 0;
1176
  if ( ! empty( $metadata['original_image'] ) ) {
1177
  ++$thumb_count;
1178
- $thumbnails[ $thumb_count ] = wp_get_original_image_url( $attach_id );
1179
  }
1180
  foreach ( $imagethumburls as $thumbsize => $imagethumburl ) {
1181
  $output_html .= '[<a href="' . $imagethumburl . '" target="_blank" rel="noopener noreferrer" style="text-decoration: none; word-break: break-all;">' . $thumbsize . '</a>]';
@@ -1206,9 +1204,9 @@ class MediaFromFtp {
1206
  'id' => $attach_id,
1207
  'user' => $user->display_name,
1208
  'title' => $new_attach_title,
1209
- 'permalink' => get_attachment_link( $attach_id ),
1210
- 'url' => wp_get_attachment_url( $attach_id ),
1211
- 'filename' => wp_basename( wp_get_attachment_url( $attach_id ) ),
1212
  'time' => $stamptime,
1213
  'filetype' => $mimetype,
1214
  'filesize' => $file_size,
1075
  public function output_metadata( $ext, $attach_id, $metadata, $character_code, $exif_text_tag ) {
1076
 
1077
  $imagethumburls = array();
 
1078
  $length = null;
1079
  $exif_text = null;
1080
  $filetype = wp_check_filetype( $this->mb_encode_multibyte( get_attached_file( $attach_id ), $character_code ) );
1081
+ $mimetype = $filetype['type'];
1082
  if ( 'image' === wp_ext2type( $ext ) || 'pdf' === strtolower( $ext ) ) {
1083
+ $media_path = get_post_meta( $attach_id, '_wp_attached_file', true );
1084
+ $media_paths = explode( DIRECTORY_SEPARATOR, $media_path );
1085
+ $str_length = strlen( end( $media_paths ) );
1086
+ $media_path = substr( $media_path, 0, -$str_length );
1087
+ $media_url = $this->upload_url . '/' . $media_path;
1088
  if ( ! empty( $metadata ) ) {
1089
+ $thumbnails = $metadata['sizes'];
1090
+ foreach ( $thumbnails as $key => $key2 ) {
1091
+ $imagethumburls[ $key ] = $media_url . $key2['file'];
 
 
 
1092
  }
1093
  }
 
1094
  } else if ( 'video' === wp_ext2type( $ext ) || 'audio' === wp_ext2type( $ext ) ) {
 
1095
  $length = $metadata['length_formatted'];
 
 
 
1096
  }
1097
 
1098
  $stamptime = get_the_time( 'Y-n-j ', $attach_id ) . get_the_time( 'G:i:s', $attach_id );
1143
  */
1144
  public function output_html_and_log( $metadata, $ext, $attach_id, $new_attach_title, $new_url_attach, $imagethumburls, $mimetype, $length, $stamptime, $file_size, $exif_text, $image_attr_thumbnail, $mediafromftp_settings, $cat_html, $mlccategory, $emlcategory, $mlacategory, $mlatag ) {
1145
 
1146
+ $attachment_link = get_attachment_link( $attach_id );
1147
+ $attachment_url = wp_get_attachment_url( $attach_id );
1148
+ $original_image_url = wp_get_original_image_url( $attach_id );
1149
 
1150
  $output_html = '<div style="border-bottom: 1px solid; padding-top: 5px; padding-bottom: 5px;">';
1151
  $output_html .= '<img width="40" height="40" src="' . $image_attr_thumbnail[0] . '" style="float: left; margin: 5px;">';
1152
  $output_html .= '<div style="overflow: hidden;">';
1153
  $output_html .= '<div>ID: ' . $attach_id . '</div>';
1154
  $output_html .= '<div>' . __( 'Title' ) . ': ' . $new_attach_title . '</div>';
1155
+ $output_html .= '<div>' . __( 'Permalink:' ) . ' <a href="' . $attachment_link . '" target="_blank" rel="noopener noreferrer" style="text-decoration: none; word-break: break-all;">' . $attachment_link . '</a></div>';
1156
+ $output_html .= '<div>URL: <a href="' . $attachment_url . '" target="_blank" rel="noopener noreferrer" style="text-decoration: none; word-break: break-all;">' . $attachment_url . '</a></div>';
1157
+ $output_html .= '<div>' . __( 'File name:' ) . ' ' . wp_basename( $attachment_url ) . '</div>';
1158
  if ( ! empty( $metadata['original_image'] ) ) {
1159
+ $output_html .= '<div>' . __( 'Original URL', 'media-from-ftp' ) . ': <a href="' . $original_image_url . '" target="_blank" rel="noopener noreferrer" style="text-decoration: none; word-break: break-all;">' . $original_image_url . '</a></div>';
1160
+ $output_html .= '<div>' . __( 'Original File name', 'media-from-ftp' ) . ': ' . wp_basename( $original_image_url ) . '</div>';
1161
  }
1162
  $output_html .= '<div>' . __( 'Date/Time' ) . ': ' . $stamptime . '</div>';
1163
  if ( ! $file_size ) {
1169
  $output_html .= '<div>' . __( 'File size:' ) . ' ' . $file_size . '</div>';
1170
  if ( ( 'image' === wp_ext2type( $ext ) || 'pdf' === strtolower( $ext ) ) && ! empty( $imagethumburls ) ) {
1171
  $output_html .= '<div>' . __( 'Images' ) . ': ';
1172
+ $thumbnails = array();
1173
  $thumb_count = 0;
1174
  if ( ! empty( $metadata['original_image'] ) ) {
1175
  ++$thumb_count;
1176
+ $thumbnails[ $thumb_count ] = $original_image_url;
1177
  }
1178
  foreach ( $imagethumburls as $thumbsize => $imagethumburl ) {
1179
  $output_html .= '[<a href="' . $imagethumburl . '" target="_blank" rel="noopener noreferrer" style="text-decoration: none; word-break: break-all;">' . $thumbsize . '</a>]';
1204
  'id' => $attach_id,
1205
  'user' => $user->display_name,
1206
  'title' => $new_attach_title,
1207
+ 'permalink' => $attachment_link,
1208
+ 'url' => $attachment_url,
1209
+ 'filename' => wp_basename( $attachment_url ),
1210
  'time' => $stamptime,
1211
  'filetype' => $mimetype,
1212
  'filesize' => $file_size,
js/jquery.mediafromftp.js CHANGED
@@ -236,7 +236,7 @@ jQuery(
236
  jQuery( ".updated" ).remove();
237
  jQuery( ".error" ).remove();
238
 
239
- jQuery( "#mediafromftp-loading-container" ).append( "<div id=\"mediafromftp-update-progress\"><progress value=\"0\" max=\"100\"></progress> 0%</div><button type=\"button\" id=\"mediafromftp_ajax_stop\">Stop</button>" );
240
  jQuery( "#mediafromftp-loading-container" ).append( "<div id=\"mediafromftp-update-result\"></div>" );
241
 
242
  var update_continue = true;
@@ -244,7 +244,7 @@ jQuery(
244
  jQuery( "#mediafromftp_ajax_stop" ).click(
245
  function() {
246
  update_continue = false;
247
- jQuery( "#mediafromftp_ajax_stop" ).text( "Stopping now.." );
248
  }
249
  );
250
 
236
  jQuery( ".updated" ).remove();
237
  jQuery( ".error" ).remove();
238
 
239
+ jQuery( "#mediafromftp-loading-container" ).append( "<div id=\"mediafromftp-update-progress\"><progress value=\"0\" max=\"100\"></progress> 0%</div><button type=\"button\" id=\"mediafromftp_ajax_stop\">" + MEDIAFROMFTPTEXT.stop_button + "</button>" );
240
  jQuery( "#mediafromftp-loading-container" ).append( "<div id=\"mediafromftp-update-result\"></div>" );
241
 
242
  var update_continue = true;
244
  jQuery( "#mediafromftp_ajax_stop" ).click(
245
  function() {
246
  update_continue = false;
247
+ jQuery( "#mediafromftp_ajax_stop" ).text( MEDIAFROMFTPTEXT.stop_message );
248
  }
249
  );
250
 
mediafromftp.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Media from FTP
4
  * Plugin URI: https://wordpress.org/plugins/media-from-ftp/
5
  * Description: Register to media library from files that have been uploaded by FTP.
6
- * Version: 11.10
7
  * Author: Katsushi Kawamori
8
  * Author URI: https://riverforest-wp.info/
9
  * License: GPL2
3
  * Plugin Name: Media from FTP
4
  * Plugin URI: https://wordpress.org/plugins/media-from-ftp/
5
  * Description: Register to media library from files that have been uploaded by FTP.
6
+ * Version: 11.11
7
  * Author: Katsushi Kawamori
8
  * Author URI: https://riverforest-wp.info/
9
  * License: GPL2
readme.txt CHANGED
@@ -4,8 +4,8 @@ Donate link: https://shop.riverforest-wp.info/donate/
4
  Tags: files, ftp, import, media, sync, uploads
5
  Requires at least: 3.6.0
6
  Requires PHP: 5.6
7
- Tested up to: 5.4
8
- Stable tag: 11.10
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -20,8 +20,11 @@ Register to media library from files that have been uploaded by FTP.
20
  * Work with [DateTimePicker](https://xdsoft.net/jqplugins/datetimepicker/). jQuery plugin select date/time.
21
  * Export the log to a CSV file.
22
  * You can register a large number of files without timeout work with Ajax.
23
- * Sibling plugin -> [Media from ZIP](https://wordpress.org/plugins/media-from-zip/).
24
- * Sibling plugin -> [Moving Media Library](https://wordpress.org/plugins/moving-media-library/).
 
 
 
25
 
26
  = Tutorial Video =
27
  [youtube https://www.youtube.com/watch?v=vdxPvOFZaDk]
@@ -132,6 +135,9 @@ Password: live789user
132
 
133
  == Changelog ==
134
 
 
 
 
135
  = 11.10 =
136
  The import feature has been deprecated.
137
  Added an error handler for the registration screen.
4
  Tags: files, ftp, import, media, sync, uploads
5
  Requires at least: 3.6.0
6
  Requires PHP: 5.6
7
+ Tested up to: 5.5
8
+ Stable tag: 11.11
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
20
  * Work with [DateTimePicker](https://xdsoft.net/jqplugins/datetimepicker/). jQuery plugin select date/time.
21
  * Export the log to a CSV file.
22
  * You can register a large number of files without timeout work with Ajax.
23
+
24
+ = Sibling plugin =
25
+ * [Bulk Media Register](https://wordpress.org/plugins/bulk-media-register/).
26
+ * [Moving Media Library](https://wordpress.org/plugins/moving-media-library/).
27
+ * [Media from ZIP](https://wordpress.org/plugins/media-from-zip/).
28
 
29
  = Tutorial Video =
30
  [youtube https://www.youtube.com/watch?v=vdxPvOFZaDk]
135
 
136
  == Changelog ==
137
 
138
+ = 11.11 =
139
+ Fixed a problem with the output of metadata.
140
+
141
  = 11.10 =
142
  The import feature has been deprecated.
143
  Added an error handler for the registration screen.
req/class-mediafromftpadmin.php CHANGED
@@ -398,6 +398,14 @@ class MediaFromFtpAdmin {
398
  'nonce' => wp_create_nonce( $action1 ),
399
  )
400
  );
 
 
 
 
 
 
 
 
401
  wp_localize_script(
402
  $handle,
403
  'MEDIAFROMFTPMESSAGE',
398
  'nonce' => wp_create_nonce( $action1 ),
399
  )
400
  );
401
+ wp_localize_script(
402
+ $handle,
403
+ 'MEDIAFROMFTPTEXT',
404
+ array(
405
+ 'stop_button' => __( 'Stop', 'media-from-ftp' ),
406
+ 'stop_message' => __( 'Stopping now..', 'media-from-ftp' ),
407
+ )
408
+ );
409
  wp_localize_script(
410
  $handle,
411
  'MEDIAFROMFTPMESSAGE',
req/class-mediafromftpregist.php CHANGED
@@ -332,6 +332,16 @@ class MediaFromFtpRegist {
332
  $page = str_replace( 'media-from-ftp_page_', '', $screen->id );
333
  $scriptname = admin_url( 'admin.php?page=' . $page );
334
  }
 
 
 
 
 
 
 
 
 
 
335
  if ( 11.08 == get_option( 'mediafromftp_notice' ) || 11.09 == get_option( 'mediafromftp_notice' ) ) {
336
  if ( class_exists( 'MovingMediaLibrary' ) ) {
337
  $movingmedialibrary_url = admin_url( 'admin.php?page=movingmedialibrary' );
@@ -343,16 +353,6 @@ class MediaFromFtpRegist {
343
  }
344
  }
345
  $movingmedialibrary_link = '<strong><a style="text-decoration: none;" href="' . $movingmedialibrary_url . '">Moving Media Library</a></strong>';
346
- $allowed_button_html = array(
347
- 'input' => array(
348
- 'type' => array(),
349
- 'id' => array(),
350
- 'name' => array(),
351
- 'class' => array(),
352
- 'value' => array(),
353
- ),
354
- );
355
- $dismiss_button = get_submit_button( __( 'Dismiss' ), 'small', 'Notice_Dismiss', true );
356
  if ( 11.08 == get_option( 'mediafromftp_notice' ) ) {
357
  $import_html = '<strong><a style="text-decoration: none;" href="' . admin_url( 'admin.php?page=mediafromftp-import' ) . '">' . __( 'Import' ) . '</a></strong>';
358
  ?>
@@ -388,6 +388,33 @@ class MediaFromFtpRegist {
388
  <?php
389
  }
390
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  }
392
 
393
  }
332
  $page = str_replace( 'media-from-ftp_page_', '', $screen->id );
333
  $scriptname = admin_url( 'admin.php?page=' . $page );
334
  }
335
+ $allowed_button_html = array(
336
+ 'input' => array(
337
+ 'type' => array(),
338
+ 'id' => array(),
339
+ 'name' => array(),
340
+ 'class' => array(),
341
+ 'value' => array(),
342
+ ),
343
+ );
344
+ $dismiss_button = get_submit_button( __( 'Dismiss' ), 'small', 'Notice_Dismiss', true );
345
  if ( 11.08 == get_option( 'mediafromftp_notice' ) || 11.09 == get_option( 'mediafromftp_notice' ) ) {
346
  if ( class_exists( 'MovingMediaLibrary' ) ) {
347
  $movingmedialibrary_url = admin_url( 'admin.php?page=movingmedialibrary' );
353
  }
354
  }
355
  $movingmedialibrary_link = '<strong><a style="text-decoration: none;" href="' . $movingmedialibrary_url . '">Moving Media Library</a></strong>';
 
 
 
 
 
 
 
 
 
 
356
  if ( 11.08 == get_option( 'mediafromftp_notice' ) ) {
357
  $import_html = '<strong><a style="text-decoration: none;" href="' . admin_url( 'admin.php?page=mediafromftp-import' ) . '">' . __( 'Import' ) . '</a></strong>';
358
  ?>
388
  <?php
389
  }
390
  }
391
+ if ( 11.10 == get_option( 'mediafromftp_notice' ) ) {
392
+ if ( class_exists( 'BulkMediaRegister' ) ) {
393
+ $bulkmediaregister_url = admin_url( 'admin.php?page=bulkmediaregister' );
394
+ } else {
395
+ if ( is_multisite() ) {
396
+ $bulkmediaregister_url = network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=bulk-media-register' );
397
+ } else {
398
+ $bulkmediaregister_url = admin_url( 'plugin-install.php?tab=plugin-information&plugin=bulk-media-register' );
399
+ }
400
+ }
401
+ $bulkmediaregister_link = '<strong><a style="text-decoration: none;" href="' . $bulkmediaregister_url . '">Bulk Media Register</a></strong>';
402
+ $register_html = '<strong><a style="text-decoration: none;" href="' . admin_url( 'admin.php?page=mediafromftp-search-register' ) . '">' . __( 'Search & Register', 'media-from-ftp' ) . '</a></strong>';
403
+ ?>
404
+ <div class="notice notice-warning is-dismissible"><ul><li>
405
+ <form method="post" action="<?php echo esc_url( $scriptname ); ?>">
406
+ <?php
407
+ wp_nonce_field( 'mff_nt', 'mediafromftp_notice' );
408
+ /* translators: %1$s Plugin link %2$s Search & Register link */
409
+ echo wp_kses_post( sprintf( __( 'Created a plugin %1$s to bulk register files on the server. You can do it with your current %2$s, but it is faster and more accurate.', 'media-from-ftp' ), $bulkmediaregister_link, $register_html ) );
410
+ ?>
411
+ &nbsp
412
+ <?php echo wp_kses( $dismiss_button, $allowed_button_html ); ?>
413
+ <input type="hidden" name="notice_update_version" value="11.11">
414
+ </form>
415
+ </li></ul></div>
416
+ <?php
417
+ }
418
  }
419
 
420
  }