Media from FTP - Version 11.08

Version Description

Fixed saving per-user settings.

Download this release

Release Info

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

Code changes from version 11.07 to 11.08

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.07
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.08
7
  * Author: Katsushi Kawamori
8
  * Author URI: https://riverforest-wp.info/
9
  * License: GPL2
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.6
7
  Tested up to: 5.4
8
- Stable tag: 11.07
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -133,6 +133,9 @@ Password: live789user
133
 
134
  == Changelog ==
135
 
 
 
 
136
  = 11.07 =
137
  Fixed an issue with file name sanitization.
138
  Added the display of original files for large images.
5
  Requires at least: 3.6.0
6
  Requires PHP: 5.6
7
  Tested up to: 5.4
8
+ Stable tag: 11.08
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
133
 
134
  == Changelog ==
135
 
136
+ = 11.08 =
137
+ Fixed saving per-user settings.
138
+
139
  = 11.07 =
140
  Fixed an issue with file name sanitization.
141
  Added the display of original files for large images.
req/class-mediafromftpadmin.php CHANGED
@@ -255,7 +255,7 @@ class MediaFromFtpAdmin {
255
  */
256
  public function search_register_show_screen_options( $status, $args ) {
257
 
258
- $mediafromftp_settings = get_option( $this->wp_options_name() );
259
 
260
  $return = $status;
261
  if ( 'media-from-ftp_page_mediafromftp-search-register' == $args->base ) {
@@ -388,7 +388,7 @@ class MediaFromFtpAdmin {
388
  */
389
  public function load_custom_wp_admin_style() {
390
  if ( $this->is_my_plugin_screen() ) {
391
- $mediafromftp_settings = get_option( $this->wp_options_name() );
392
  if ( $mediafromftp_settings['datetimepicker'] ) {
393
  wp_enqueue_style( 'jquery-datetimepicker', $this->plugin_base_url . '/css/jquery.datetimepicker.css', array(), '2.3.4' );
394
  }
@@ -734,7 +734,7 @@ class MediaFromFtpAdmin {
734
  $mediafromftp_addon_exif = true;
735
  }
736
 
737
- $mediafromftp_settings = get_option( $this->wp_options_name() );
738
 
739
  $def_max_execution_time = ini_get( 'max_execution_time' );
740
  $scriptname = admin_url( 'admin.php?page=mediafromftp-settings' );
@@ -1119,7 +1119,7 @@ class MediaFromFtpAdmin {
1119
 
1120
  <?php
1121
  if ( $this->is_add_on_activate['cli'] ) {
1122
- $mediafromftpcli->mediafromftp_command_line_html( $this->wp_options_name() );
1123
  unset( $mediafromftpcli );
1124
  }
1125
  ?>
@@ -1144,7 +1144,7 @@ class MediaFromFtpAdmin {
1144
 
1145
  $this->options_updated( 2 );
1146
 
1147
- $mediafromftp_settings = get_option( $this->wp_options_name() );
1148
 
1149
  $def_max_execution_time = ini_get( 'max_execution_time' );
1150
  $max_execution_time = $mediafromftp_settings['max_execution_time'];
@@ -1227,7 +1227,7 @@ class MediaFromFtpAdmin {
1227
  * @since 9.63
1228
  */
1229
  public function custom_bulk_admin_footer() {
1230
- $mediafromftp_settings = get_option( $this->wp_options_name() );
1231
  if ( 'server' === $mediafromftp_settings['dateset'] || 'exif' === $mediafromftp_settings['dateset'] ) {
1232
  if ( $this->is_my_plugin_screen3() ) {
1233
  if ( function_exists( 'wp_date' ) ) {
@@ -1299,7 +1299,7 @@ class MediaFromFtpAdmin {
1299
  if ( check_admin_referer( 'mff_event', 'media_from_ftp_event' ) ) {
1300
  if ( isset( $_POST['event-mediafromftp'] ) && ! empty( $_POST['event-mediafromftp'] ) ) {
1301
  $events_mediafromftp = array_map( 'sanitize_text_field', wp_unslash( $_POST['event-mediafromftp'] ) );
1302
- $events = get_option( $this->wp_add_on_wpcron_events_name() );
1303
  $event_names = null;
1304
  foreach ( $events_mediafromftp as $key => $event_id ) {
1305
  $option_name = $events[ $event_id ];
@@ -1307,7 +1307,7 @@ class MediaFromFtpAdmin {
1307
  delete_option( $option_name );
1308
  $event_names .= ' ' . $event_id . ' ';
1309
  unset( $events[ $event_id ] );
1310
- update_option( $this->wp_add_on_wpcron_events_name(), $events );
1311
  }
1312
  unset( $mediafromftpcron );
1313
  $allowed_notice_html = array(
@@ -1357,7 +1357,7 @@ class MediaFromFtpAdmin {
1357
  'form' => array(),
1358
  ),
1359
  );
1360
- echo wp_kses( $mediafromftpaddonwpcron->mediafromftp_event_html( $scriptname, get_option( $this->wp_add_on_wpcron_events_name() ) ), $allowed_event_html );
1361
  ?>
1362
  </div>
1363
  <?php
@@ -1375,7 +1375,7 @@ class MediaFromFtpAdmin {
1375
  wp_die( esc_html__( 'You do not have sufficient permissions to access this page.' ) );
1376
  }
1377
 
1378
- $mediafromftp_settings = get_option( $this->wp_options_name() );
1379
  if ( ! $mediafromftp_settings['log'] ) {
1380
  echo '<div class="notice notice-info is-dismissible"><ul><li>' . esc_html__( 'Current, log is not created. If you want to create a log, please put a check in the [Create log] in the settings.', 'media-from-ftp' ) . '</li></ul></div>';
1381
  }
@@ -1958,7 +1958,7 @@ class MediaFromFtpAdmin {
1958
 
1959
  $mediafromftp = new MediaFromFtp();
1960
 
1961
- $mediafromftp_settings = get_option( $this->wp_options_name() );
1962
 
1963
  $addonwpcron = false;
1964
  if ( $this->is_add_on_activate['wpcron'] ) {
@@ -2063,7 +2063,7 @@ class MediaFromFtpAdmin {
2063
  } else {
2064
  $mediafromftp_settings['mlat'] = null;
2065
  }
2066
- update_option( $this->wp_options_name(), $mediafromftp_settings );
2067
  if ( ! empty( $_POST['move_yearmonth_folders'] ) ) {
2068
  update_option( 'uploads_use_yearmonth_folders', 1 );
2069
  } else {
@@ -2121,7 +2121,7 @@ class MediaFromFtpAdmin {
2121
  if ( isset( $_POST['mediafromftp_thumb_deep_search'] ) ) {
2122
  $mediafromftp_settings['thumb_deep_search'] = sanitize_text_field( wp_unslash( $_POST['mediafromftp_thumb_deep_search'] ) );
2123
  }
2124
- update_option( $this->wp_options_name(), $mediafromftp_settings );
2125
  $screen = get_current_screen();
2126
  if ( is_object( $screen ) && 'media-from-ftp_page_mediafromftp-settings' === $screen->id ) {
2127
  echo '<div class="notice notice-success is-dismissible"><ul><li>' . esc_html( __( 'Settings' ) . ' --> ' . __( 'Changes saved.' ) ) . '</li></ul></div>';
@@ -2149,7 +2149,7 @@ class MediaFromFtpAdmin {
2149
  if ( check_admin_referer( 'mff_run_cron', 'media_from_ftp_run_cron' ) ) {
2150
  if ( $addonwpcron ) {
2151
  if ( ! empty( $_POST['mediafromftp_run_cron'] ) ) {
2152
- $mediafromftp_cron_events = get_option( $this->wp_add_on_wpcron_events_name() );
2153
  if ( ! empty( $_POST['cron-run'] ) ) {
2154
  $option_name = sanitize_text_field( wp_unslash( $_POST['cron-run'] ) );
2155
  echo wp_kses( $mediafromftpaddonwpcron->CronRun( $option_name ), $allowed_notice_html );
@@ -2163,7 +2163,7 @@ class MediaFromFtpAdmin {
2163
  }
2164
  } else {
2165
  $mediafromftp_settings['cron']['apply'] = false;
2166
- update_option( $this->wp_options_name(), $mediafromftp_settings );
2167
  }
2168
  }
2169
  }
@@ -2174,7 +2174,10 @@ class MediaFromFtpAdmin {
2174
  if ( check_admin_referer( 'mff_add_schedule', 'media_from_ftp_add_schedule' ) ) {
2175
  if ( ! empty( $_POST['mediafromftp_add_schedule'] ) ) {
2176
  if ( ! empty( $_POST['mediafromftp_cron_schedule_innername'] ) && ! empty( $_POST['mediafromftp_cron_schedule_secounds'] ) && ! empty( $_POST['mediafromftp_cron_schedule_viewname'] ) ) {
2177
- $mediafromftp_cron_intervals_tbl = get_option( 'mediafromftp_event_intervals' );
 
 
 
2178
  $innername = sanitize_text_field( wp_unslash( $_POST['mediafromftp_cron_schedule_innername'] ) );
2179
  $secounds = intval( $_POST['mediafromftp_cron_schedule_secounds'] );
2180
  $viewname = sanitize_text_field( wp_unslash( $_POST['mediafromftp_cron_schedule_viewname'] ) );
@@ -2182,7 +2185,7 @@ class MediaFromFtpAdmin {
2182
  'interval' => $secounds,
2183
  'display' => $viewname,
2184
  );
2185
- update_option( 'mediafromftp_event_intervals', $mediafromftp_cron_intervals_tbl );
2186
  echo wp_kses( $mediafromftpaddonwpcron->mediafromftp_schedule_notice_html( $submenu ), $allowed_notice_html );
2187
  }
2188
  }
@@ -2196,11 +2199,11 @@ class MediaFromFtpAdmin {
2196
  if ( ! empty( $_POST['mediafromftp_add_schedule_delete'] ) ) {
2197
  if ( ! empty( $_POST['mediafromftp_cron_schedule_delete'] ) ) {
2198
  $delete_keys = array_map( 'sanitize_text_field', wp_unslash( $_POST['mediafromftp_cron_schedule_delete'] ) );
2199
- $mediafromftp_cron_intervals_tbl = get_option( 'mediafromftp_event_intervals' );
2200
  foreach ( $delete_keys as $key ) {
2201
  unset( $mediafromftp_cron_intervals_tbl[ $key ] );
2202
  }
2203
- update_option( 'mediafromftp_event_intervals', $mediafromftp_cron_intervals_tbl );
2204
  echo wp_kses( $mediafromftpaddonwpcron->mediafromftp_schedule_notice_html( $submenu ), $allowed_notice_html );
2205
  }
2206
  }
@@ -2218,9 +2221,9 @@ class MediaFromFtpAdmin {
2218
  $event_id = date_i18n( 'Y-m-d-H-i-s' );
2219
  }
2220
  $event_option_name = 'mediafromftp_cronevent-' . $event_id;
2221
- $mediafromftp_cron_events = get_option( $this->wp_add_on_wpcron_events_name(), array() );
2222
  $mediafromftp_cron_events[ $event_id ] = $event_option_name;
2223
- update_option( $this->wp_add_on_wpcron_events_name(), $mediafromftp_cron_events );
2224
  update_option( $event_option_name, $mediafromftp_settings );
2225
  echo wp_kses( $mediafromftpaddonwpcron->mediafromftp_cronevent_create_html(), $allowed_notice_html );
2226
  }
@@ -2285,32 +2288,6 @@ class MediaFromFtpAdmin {
2285
 
2286
  }
2287
 
2288
- /** ==================================================
2289
- * Options name
2290
- *
2291
- * @return string $this->wp_options_name()
2292
- * @since 10.09
2293
- */
2294
- private function wp_options_name() {
2295
- if ( ! function_exists( 'wp_get_current_user' ) ) {
2296
- include_once( ABSPATH . 'wp-includes/pluggable.php' );
2297
- }
2298
- return 'mediafromftp_settings_' . get_current_user_id();
2299
- }
2300
-
2301
- /** ==================================================
2302
- * Add on
2303
- *
2304
- * @return string $this->wp_add_on_wpcron_events_name()
2305
- * @since 10.09
2306
- */
2307
- private function wp_add_on_wpcron_events_name() {
2308
- if ( ! function_exists( 'wp_get_current_user' ) ) {
2309
- include_once( ABSPATH . 'wp-includes/pluggable.php' );
2310
- }
2311
- return 'mediafromftp_add_on_wpcron_events_' . get_current_user_id();
2312
- }
2313
-
2314
  }
2315
 
2316
 
255
  */
256
  public function search_register_show_screen_options( $status, $args ) {
257
 
258
+ $mediafromftp_settings = get_user_option( 'mediafromftp', get_current_user_id() );
259
 
260
  $return = $status;
261
  if ( 'media-from-ftp_page_mediafromftp-search-register' == $args->base ) {
388
  */
389
  public function load_custom_wp_admin_style() {
390
  if ( $this->is_my_plugin_screen() ) {
391
+ $mediafromftp_settings = get_user_option( 'mediafromftp', get_current_user_id() );
392
  if ( $mediafromftp_settings['datetimepicker'] ) {
393
  wp_enqueue_style( 'jquery-datetimepicker', $this->plugin_base_url . '/css/jquery.datetimepicker.css', array(), '2.3.4' );
394
  }
734
  $mediafromftp_addon_exif = true;
735
  }
736
 
737
+ $mediafromftp_settings = get_user_option( 'mediafromftp', get_current_user_id() );
738
 
739
  $def_max_execution_time = ini_get( 'max_execution_time' );
740
  $scriptname = admin_url( 'admin.php?page=mediafromftp-settings' );
1119
 
1120
  <?php
1121
  if ( $this->is_add_on_activate['cli'] ) {
1122
+ $mediafromftpcli->mediafromftp_command_line_html( get_current_user_id() );
1123
  unset( $mediafromftpcli );
1124
  }
1125
  ?>
1144
 
1145
  $this->options_updated( 2 );
1146
 
1147
+ $mediafromftp_settings = get_user_option( 'mediafromftp', get_current_user_id() );
1148
 
1149
  $def_max_execution_time = ini_get( 'max_execution_time' );
1150
  $max_execution_time = $mediafromftp_settings['max_execution_time'];
1227
  * @since 9.63
1228
  */
1229
  public function custom_bulk_admin_footer() {
1230
+ $mediafromftp_settings = get_user_option( 'mediafromftp', get_current_user_id() );
1231
  if ( 'server' === $mediafromftp_settings['dateset'] || 'exif' === $mediafromftp_settings['dateset'] ) {
1232
  if ( $this->is_my_plugin_screen3() ) {
1233
  if ( function_exists( 'wp_date' ) ) {
1299
  if ( check_admin_referer( 'mff_event', 'media_from_ftp_event' ) ) {
1300
  if ( isset( $_POST['event-mediafromftp'] ) && ! empty( $_POST['event-mediafromftp'] ) ) {
1301
  $events_mediafromftp = array_map( 'sanitize_text_field', wp_unslash( $_POST['event-mediafromftp'] ) );
1302
+ $events = get_user_option( 'mediafromftp_add_on_wpcron_events', get_current_user_id() );
1303
  $event_names = null;
1304
  foreach ( $events_mediafromftp as $key => $event_id ) {
1305
  $option_name = $events[ $event_id ];
1307
  delete_option( $option_name );
1308
  $event_names .= ' ' . $event_id . ' ';
1309
  unset( $events[ $event_id ] );
1310
+ update_user_option( get_current_user_id(), 'mediafromftp_add_on_wpcron_events', $events );
1311
  }
1312
  unset( $mediafromftpcron );
1313
  $allowed_notice_html = array(
1357
  'form' => array(),
1358
  ),
1359
  );
1360
+ echo wp_kses( $mediafromftpaddonwpcron->mediafromftp_event_html( $scriptname, get_user_option( 'mediafromftp_add_on_wpcron_events', get_current_user_id() ) ), $allowed_event_html );
1361
  ?>
1362
  </div>
1363
  <?php
1375
  wp_die( esc_html__( 'You do not have sufficient permissions to access this page.' ) );
1376
  }
1377
 
1378
+ $mediafromftp_settings = get_user_option( 'mediafromftp', get_current_user_id() );
1379
  if ( ! $mediafromftp_settings['log'] ) {
1380
  echo '<div class="notice notice-info is-dismissible"><ul><li>' . esc_html__( 'Current, log is not created. If you want to create a log, please put a check in the [Create log] in the settings.', 'media-from-ftp' ) . '</li></ul></div>';
1381
  }
1958
 
1959
  $mediafromftp = new MediaFromFtp();
1960
 
1961
+ $mediafromftp_settings = get_user_option( 'mediafromftp', get_current_user_id() );
1962
 
1963
  $addonwpcron = false;
1964
  if ( $this->is_add_on_activate['wpcron'] ) {
2063
  } else {
2064
  $mediafromftp_settings['mlat'] = null;
2065
  }
2066
+ update_user_option( get_current_user_id(), 'mediafromftp', $mediafromftp_settings );
2067
  if ( ! empty( $_POST['move_yearmonth_folders'] ) ) {
2068
  update_option( 'uploads_use_yearmonth_folders', 1 );
2069
  } else {
2121
  if ( isset( $_POST['mediafromftp_thumb_deep_search'] ) ) {
2122
  $mediafromftp_settings['thumb_deep_search'] = sanitize_text_field( wp_unslash( $_POST['mediafromftp_thumb_deep_search'] ) );
2123
  }
2124
+ update_user_option( get_current_user_id(), 'mediafromftp', $mediafromftp_settings );
2125
  $screen = get_current_screen();
2126
  if ( is_object( $screen ) && 'media-from-ftp_page_mediafromftp-settings' === $screen->id ) {
2127
  echo '<div class="notice notice-success is-dismissible"><ul><li>' . esc_html( __( 'Settings' ) . ' --> ' . __( 'Changes saved.' ) ) . '</li></ul></div>';
2149
  if ( check_admin_referer( 'mff_run_cron', 'media_from_ftp_run_cron' ) ) {
2150
  if ( $addonwpcron ) {
2151
  if ( ! empty( $_POST['mediafromftp_run_cron'] ) ) {
2152
+ $mediafromftp_cron_events = get_user_option( 'mediafromftp_add_on_wpcron_events', get_current_user_id() );
2153
  if ( ! empty( $_POST['cron-run'] ) ) {
2154
  $option_name = sanitize_text_field( wp_unslash( $_POST['cron-run'] ) );
2155
  echo wp_kses( $mediafromftpaddonwpcron->CronRun( $option_name ), $allowed_notice_html );
2163
  }
2164
  } else {
2165
  $mediafromftp_settings['cron']['apply'] = false;
2166
+ update_user_option( get_current_user_id(), 'mediafromftp', $mediafromftp_settings );
2167
  }
2168
  }
2169
  }
2174
  if ( check_admin_referer( 'mff_add_schedule', 'media_from_ftp_add_schedule' ) ) {
2175
  if ( ! empty( $_POST['mediafromftp_add_schedule'] ) ) {
2176
  if ( ! empty( $_POST['mediafromftp_cron_schedule_innername'] ) && ! empty( $_POST['mediafromftp_cron_schedule_secounds'] ) && ! empty( $_POST['mediafromftp_cron_schedule_viewname'] ) ) {
2177
+ $mediafromftp_cron_intervals_tbl = get_user_option( 'mediafromftp_event_intervals', get_current_user_id() );
2178
+ if ( empty( $mediafromftp_cron_intervals_tbl ) ) {
2179
+ $mediafromftp_cron_intervals_tbl = array();
2180
+ }
2181
  $innername = sanitize_text_field( wp_unslash( $_POST['mediafromftp_cron_schedule_innername'] ) );
2182
  $secounds = intval( $_POST['mediafromftp_cron_schedule_secounds'] );
2183
  $viewname = sanitize_text_field( wp_unslash( $_POST['mediafromftp_cron_schedule_viewname'] ) );
2185
  'interval' => $secounds,
2186
  'display' => $viewname,
2187
  );
2188
+ update_user_option( get_current_user_id(), 'mediafromftp_event_intervals', $mediafromftp_cron_intervals_tbl );
2189
  echo wp_kses( $mediafromftpaddonwpcron->mediafromftp_schedule_notice_html( $submenu ), $allowed_notice_html );
2190
  }
2191
  }
2199
  if ( ! empty( $_POST['mediafromftp_add_schedule_delete'] ) ) {
2200
  if ( ! empty( $_POST['mediafromftp_cron_schedule_delete'] ) ) {
2201
  $delete_keys = array_map( 'sanitize_text_field', wp_unslash( $_POST['mediafromftp_cron_schedule_delete'] ) );
2202
+ $mediafromftp_cron_intervals_tbl = get_user_option( 'mediafromftp_event_intervals', get_current_user_id() );
2203
  foreach ( $delete_keys as $key ) {
2204
  unset( $mediafromftp_cron_intervals_tbl[ $key ] );
2205
  }
2206
+ update_user_option( get_current_user_id(), 'mediafromftp_event_intervals', $mediafromftp_cron_intervals_tbl );
2207
  echo wp_kses( $mediafromftpaddonwpcron->mediafromftp_schedule_notice_html( $submenu ), $allowed_notice_html );
2208
  }
2209
  }
2221
  $event_id = date_i18n( 'Y-m-d-H-i-s' );
2222
  }
2223
  $event_option_name = 'mediafromftp_cronevent-' . $event_id;
2224
+ $mediafromftp_cron_events = get_user_option( 'mediafromftp_add_on_wpcron_events', get_current_user_id() );
2225
  $mediafromftp_cron_events[ $event_id ] = $event_option_name;
2226
+ update_user_option( get_current_user_id(), 'mediafromftp_add_on_wpcron_events', $mediafromftp_cron_events );
2227
  update_option( $event_option_name, $mediafromftp_settings );
2228
  echo wp_kses( $mediafromftpaddonwpcron->mediafromftp_cronevent_create_html(), $allowed_notice_html );
2229
  }
2288
 
2289
  }
2290
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2291
  }
2292
 
2293
 
req/class-mediafromftpajax.php CHANGED
@@ -104,7 +104,7 @@ class MediaFromFtpAjax {
104
  $maxcount = intval( $_POST['maxcount'] );
105
  }
106
 
107
- $mediafromftp_settings = get_option( $this->wp_options_name() );
108
  $mediafromftp = new MediaFromFtp();
109
 
110
  if ( ! empty( $_POST['new_url'] ) ) {
@@ -425,19 +425,6 @@ class MediaFromFtpAjax {
425
  return $str;
426
  }
427
 
428
- /** ==================================================
429
- * Options name
430
- *
431
- * @return string $this->wp_options_name()
432
- * @since 10.09
433
- */
434
- private function wp_options_name() {
435
- if ( ! function_exists( 'wp_get_current_user' ) ) {
436
- include_once( ABSPATH . 'wp-includes/pluggable.php' );
437
- }
438
- return 'mediafromftp_settings_' . get_current_user_id();
439
- }
440
-
441
  }
442
 
443
 
104
  $maxcount = intval( $_POST['maxcount'] );
105
  }
106
 
107
+ $mediafromftp_settings = get_user_option( 'mediafromftp', get_current_user_id() );
108
  $mediafromftp = new MediaFromFtp();
109
 
110
  if ( ! empty( $_POST['new_url'] ) ) {
425
  return $str;
426
  }
427
 
 
 
 
 
 
 
 
 
 
 
 
 
 
428
  }
429
 
430
 
req/class-mediafromftpregist.php CHANGED
@@ -41,20 +41,18 @@ class MediaFromFtpRegist {
41
  */
42
  public function __construct() {
43
 
44
- $plugin_base_dir = untrailingslashit( plugin_dir_path( __DIR__ ) );
45
-
46
  if ( ! class_exists( 'MediaFromFtp' ) ) {
47
- include_once $plugin_base_dir . '/inc/class-mediafromftp.php';
48
  }
49
  $mediafromftp = new MediaFromFtp();
50
- list($upload_dir, $upload_url, $this->upload_path) = $mediafromftp->upload_dir_url_path();
51
  $plugin_tmp_dir = $upload_dir . '/media-from-ftp-tmp';
52
  /* Make tmp dir */
53
  if ( ! is_dir( $plugin_tmp_dir ) ) {
54
  wp_mkdir_p( $plugin_tmp_dir );
55
  }
56
 
57
- register_activation_hook( $plugin_base_dir . '/mediafromftp.php', array( $this, 'log_settings' ) );
58
  add_action( 'admin_init', array( $this, 'register_settings' ) );
59
 
60
  }
@@ -190,11 +188,6 @@ class MediaFromFtpRegist {
190
  public function register_settings() {
191
 
192
  $user = wp_get_current_user();
193
- $cron_mail = $user->user_email;
194
- $cron_user = $user->ID;
195
-
196
- $wp_options_name = 'mediafromftp_settings_' . $cron_user;
197
- $wp_cron_events_name = 'mediafromftp_add_on_wpcron_events_' . $cron_user;
198
 
199
  $pagemax = 20;
200
  $basedir = $this->upload_path;
@@ -234,224 +227,71 @@ class MediaFromFtpRegist {
234
  $mlac = null;
235
  $mlat = null;
236
 
237
- /* for media-from-ftp-add-on-wpcron */
238
- if ( ! get_option( 'mediafromftp_event_intervals' ) ) {
239
- update_option( 'mediafromftp_event_intervals', array() );
240
- }
241
- if ( ! get_option( $wp_cron_events_name ) ) {
242
- update_option( $wp_cron_events_name, array() );
243
  }
244
 
245
- /* << version 2.35 */
246
- if ( get_option( 'mediafromftp_exclude_file' ) ) {
247
- $exclude = get_option( 'mediafromftp_exclude_file' );
248
- delete_option( 'mediafromftp_exclude_file' );
 
249
  }
250
 
251
- if ( ! get_option( $wp_options_name ) ) {
252
- if ( get_option( 'mediafromftp_settings' ) ) { /* old settings */
253
- $mediafromftp_settings = get_option( 'mediafromftp_settings' );
254
- if ( array_key_exists( 'pagemax', $mediafromftp_settings ) ) {
255
- $pagemax = $mediafromftp_settings['pagemax'];
256
- }
257
- if ( array_key_exists( 'basedir', $mediafromftp_settings ) ) {
258
- $basedir = $mediafromftp_settings['basedir'];
259
- }
260
- if ( array_key_exists( 'searchdir', $mediafromftp_settings ) ) {
261
- $searchdir = $mediafromftp_settings['searchdir'];
262
- }
263
- if ( array_key_exists( 'ext2typefilter', $mediafromftp_settings ) ) {
264
- $ext2typefilter = $mediafromftp_settings['ext2typefilter'];
265
- }
266
- if ( array_key_exists( 'extfilter', $mediafromftp_settings ) ) {
267
- $extfilter = $mediafromftp_settings['extfilter'];
268
- }
269
- if ( array_key_exists( 'search_display_metadata', $mediafromftp_settings ) ) {
270
- $search_display_metadata = $mediafromftp_settings['search_display_metadata'];
271
- }
272
- if ( array_key_exists( 'dateset', $mediafromftp_settings ) ) {
273
- $dateset = $mediafromftp_settings['dateset'];
274
- }
275
- if ( array_key_exists( 'datefixed', $mediafromftp_settings ) ) {
276
- $datefixed = $mediafromftp_settings['datefixed'];
277
- }
278
- if ( array_key_exists( 'datetimepicker', $mediafromftp_settings ) ) {
279
- $datetimepicker = $mediafromftp_settings['datetimepicker'];
280
- }
281
- if ( array_key_exists( 'max_execution_time', $mediafromftp_settings ) ) {
282
- $max_execution_time = $mediafromftp_settings['max_execution_time'];
283
- }
284
- if ( array_key_exists( 'character_code', $mediafromftp_settings ) ) {
285
- $character_code = $mediafromftp_settings['character_code'];
286
- }
287
- if ( array_key_exists( 'exclude', $mediafromftp_settings ) ) {
288
- $exclude = $mediafromftp_settings['exclude'];
289
- }
290
- if ( array_key_exists( 'recursive_search', $mediafromftp_settings ) ) {
291
- $recursive_search = $mediafromftp_settings['recursive_search'];
292
- }
293
- if ( array_key_exists( 'thumb_deep_search', $mediafromftp_settings ) ) {
294
- $thumb_deep_search = $mediafromftp_settings['thumb_deep_search'];
295
- }
296
- if ( array_key_exists( 'search_limit_number', $mediafromftp_settings ) ) {
297
- $search_limit_number = $mediafromftp_settings['search_limit_number'];
298
- }
299
- if ( array_key_exists( 'apply', $mediafromftp_settings['cron'] ) ) {
300
- $cron_apply = $mediafromftp_settings['cron']['apply'];
301
- }
302
- if ( array_key_exists( 'schedule', $mediafromftp_settings['cron'] ) ) {
303
- $cron_schedule = $mediafromftp_settings['cron']['schedule'];
304
- }
305
- if ( array_key_exists( 'limit_number', $mediafromftp_settings['cron'] ) ) {
306
- $cron_limit_number = $mediafromftp_settings['cron']['limit_number'];
307
- }
308
- if ( array_key_exists( 'mail_apply', $mediafromftp_settings['cron'] ) ) {
309
- $cron_mail_apply = $mediafromftp_settings['cron']['mail_apply'];
310
- }
311
- if ( array_key_exists( 'apply', $mediafromftp_settings['caption'] ) ) {
312
- $caption_apply = $mediafromftp_settings['caption']['apply'];
313
- }
314
- if ( array_key_exists( 'exif_text', $mediafromftp_settings['caption'] ) ) {
315
- $exif_text = $mediafromftp_settings['caption']['exif_text'];
316
- }
317
- if ( array_key_exists( 'log', $mediafromftp_settings ) ) {
318
- $log = $mediafromftp_settings['log'];
319
- }
320
-
321
- /* for media-from-ftp-add-on-category */
322
- if ( array_key_exists( 'mlcc', $mediafromftp_settings ) ) {
323
- $mlcc = $mediafromftp_settings['mlcc'];
324
- }
325
- if ( array_key_exists( 'emlc', $mediafromftp_settings ) ) {
326
- $emlc = $mediafromftp_settings['emlc'];
327
- }
328
- if ( array_key_exists( 'mlac', $mediafromftp_settings ) ) {
329
- $mlac = $mediafromftp_settings['mlac'];
330
- }
331
- if ( array_key_exists( 'mlat', $mediafromftp_settings ) ) {
332
- $mlat = $mediafromftp_settings['mlat'];
333
- }
334
-
335
- delete_option( 'mediafromftp_settings' );
336
- }
337
- } else {
338
- $mediafromftp_settings = get_option( $wp_options_name );
339
- if ( array_key_exists( 'pagemax', $mediafromftp_settings ) ) {
340
- $pagemax = $mediafromftp_settings['pagemax'];
341
- }
342
- if ( array_key_exists( 'basedir', $mediafromftp_settings ) ) {
343
- $basedir = $mediafromftp_settings['basedir'];
344
- }
345
- if ( array_key_exists( 'searchdir', $mediafromftp_settings ) ) {
346
- $searchdir = $mediafromftp_settings['searchdir'];
347
- }
348
- if ( array_key_exists( 'ext2typefilter', $mediafromftp_settings ) ) {
349
- $ext2typefilter = $mediafromftp_settings['ext2typefilter'];
350
- }
351
- if ( array_key_exists( 'extfilter', $mediafromftp_settings ) ) {
352
- $extfilter = $mediafromftp_settings['extfilter'];
353
- }
354
- if ( array_key_exists( 'search_display_metadata', $mediafromftp_settings ) ) {
355
- $search_display_metadata = $mediafromftp_settings['search_display_metadata'];
356
- }
357
- if ( array_key_exists( 'dateset', $mediafromftp_settings ) ) {
358
- $dateset = $mediafromftp_settings['dateset'];
359
- }
360
- if ( array_key_exists( 'datefixed', $mediafromftp_settings ) ) {
361
- $datefixed = $mediafromftp_settings['datefixed'];
362
- }
363
- if ( array_key_exists( 'datetimepicker', $mediafromftp_settings ) ) {
364
- $datetimepicker = $mediafromftp_settings['datetimepicker'];
365
- }
366
- if ( array_key_exists( 'max_execution_time', $mediafromftp_settings ) ) {
367
- $max_execution_time = $mediafromftp_settings['max_execution_time'];
368
- }
369
- if ( array_key_exists( 'character_code', $mediafromftp_settings ) ) {
370
- $character_code = $mediafromftp_settings['character_code'];
371
- }
372
- if ( array_key_exists( 'exclude', $mediafromftp_settings ) ) {
373
- $exclude = $mediafromftp_settings['exclude'];
374
- }
375
- if ( array_key_exists( 'recursive_search', $mediafromftp_settings ) ) {
376
- $recursive_search = $mediafromftp_settings['recursive_search'];
377
- }
378
- if ( array_key_exists( 'thumb_deep_search', $mediafromftp_settings ) ) {
379
- $thumb_deep_search = $mediafromftp_settings['thumb_deep_search'];
380
- }
381
- if ( array_key_exists( 'search_limit_number', $mediafromftp_settings ) ) {
382
- $search_limit_number = $mediafromftp_settings['search_limit_number'];
383
- }
384
- if ( array_key_exists( 'apply', $mediafromftp_settings['cron'] ) ) {
385
- $cron_apply = $mediafromftp_settings['cron']['apply'];
386
- }
387
- if ( array_key_exists( 'schedule', $mediafromftp_settings['cron'] ) ) {
388
- $cron_schedule = $mediafromftp_settings['cron']['schedule'];
389
- }
390
- if ( array_key_exists( 'limit_number', $mediafromftp_settings['cron'] ) ) {
391
- $cron_limit_number = $mediafromftp_settings['cron']['limit_number'];
392
- }
393
- if ( array_key_exists( 'mail_apply', $mediafromftp_settings['cron'] ) ) {
394
- $cron_mail_apply = $mediafromftp_settings['cron']['mail_apply'];
395
- }
396
- if ( array_key_exists( 'apply', $mediafromftp_settings['caption'] ) ) {
397
- $caption_apply = $mediafromftp_settings['caption']['apply'];
398
- }
399
- if ( array_key_exists( 'exif_text', $mediafromftp_settings['caption'] ) ) {
400
- $exif_text = $mediafromftp_settings['caption']['exif_text'];
401
- }
402
- if ( array_key_exists( 'log', $mediafromftp_settings ) ) {
403
- $log = $mediafromftp_settings['log'];
404
- }
405
- /* for media-from-ftp-add-on-category */
406
- if ( array_key_exists( 'mlcc', $mediafromftp_settings ) ) {
407
- $mlcc = $mediafromftp_settings['mlcc'];
408
- }
409
- if ( array_key_exists( 'emlc', $mediafromftp_settings ) ) {
410
- $emlc = $mediafromftp_settings['emlc'];
411
- }
412
- if ( array_key_exists( 'mlac', $mediafromftp_settings ) ) {
413
- $mlac = $mediafromftp_settings['mlac'];
414
- }
415
- if ( array_key_exists( 'mlat', $mediafromftp_settings ) ) {
416
- $mlat = $mediafromftp_settings['mlat'];
417
- }
418
  }
419
 
420
- $mediafromftp_tbl = array(
421
- 'pagemax' => $pagemax,
422
- 'basedir' => $basedir,
423
- 'searchdir' => $searchdir,
424
- 'ext2typefilter' => $ext2typefilter,
425
- 'extfilter' => $extfilter,
426
- 'search_display_metadata' => $search_display_metadata,
427
- 'dateset' => $dateset,
428
- 'datefixed' => $datefixed,
429
- 'datetimepicker' => $datetimepicker,
430
- 'max_execution_time' => $max_execution_time,
431
- 'character_code' => $character_code,
432
- 'exclude' => $exclude,
433
- 'recursive_search' => $recursive_search,
434
- 'thumb_deep_search' => $thumb_deep_search,
435
- 'search_limit_number' => $search_limit_number,
436
- 'cron' => array(
437
- 'apply' => $cron_apply,
438
- 'schedule' => $cron_schedule,
439
- 'limit_number' => $cron_limit_number,
440
- 'mail_apply' => $cron_mail_apply,
441
- 'mail' => $cron_mail,
442
- 'user' => $cron_user,
443
- ),
444
- 'caption' => array(
445
- 'apply' => $caption_apply,
446
- 'exif_text' => $exif_text,
447
- ),
448
- 'log' => $log,
449
- 'mlcc' => $mlcc,
450
- 'emlc' => $emlc,
451
- 'mlac' => $mlac,
452
- 'mlat' => $mlat,
453
- );
454
- update_option( $wp_options_name, $mediafromftp_tbl );
 
 
 
 
 
 
 
 
 
455
 
456
  }
457
 
41
  */
42
  public function __construct() {
43
 
 
 
44
  if ( ! class_exists( 'MediaFromFtp' ) ) {
45
+ include_once plugin_dir_path( __DIR__ ) . 'inc/class-mediafromftp.php';
46
  }
47
  $mediafromftp = new MediaFromFtp();
48
+ list( $upload_dir, $upload_url, $this->upload_path ) = $mediafromftp->upload_dir_url_path();
49
  $plugin_tmp_dir = $upload_dir . '/media-from-ftp-tmp';
50
  /* Make tmp dir */
51
  if ( ! is_dir( $plugin_tmp_dir ) ) {
52
  wp_mkdir_p( $plugin_tmp_dir );
53
  }
54
 
55
+ register_activation_hook( plugin_dir_path( __DIR__ ) . 'mediafromftp.php', array( $this, 'log_settings' ) );
56
  add_action( 'admin_init', array( $this, 'register_settings' ) );
57
 
58
  }
188
  public function register_settings() {
189
 
190
  $user = wp_get_current_user();
 
 
 
 
 
191
 
192
  $pagemax = 20;
193
  $basedir = $this->upload_path;
227
  $mlac = null;
228
  $mlat = null;
229
 
230
+ /* Old option 11.07 -> New option for media-from-ftp-add-on-wpcron */
231
+ if ( get_option( 'mediafromftp_add_on_wpcron_events_' . $user->ID ) ) {
232
+ update_option( 'mediafromftp_add_on_wpcron_events', get_option( 'mediafromftp_add_on_wpcron_events_' . $user->ID ) );
233
+ delete_option( 'mediafromftp_add_on_wpcron_events_' . $user->ID );
234
+ update_user_option( $user->ID, 'mediafromftp_add_on_wpcron_events', get_option( 'mediafromftp_add_on_wpcron_events' ) );
 
235
  }
236
 
237
+ if ( ! get_option( 'mediafromftp_add_on_wpcron_events' ) ) {
238
+ update_option( 'mediafromftp_add_on_wpcron_events', array() );
239
+ }
240
+ if ( ! get_user_option( 'mediafromftp_add_on_wpcron_events', $user->ID ) ) {
241
+ update_user_option( $user->ID, 'mediafromftp_add_on_wpcron_events', array() );
242
  }
243
 
244
+ /* Old option 11.07 -> New option */
245
+ if ( get_option( 'mediafromftp_settings_' . $user->ID ) ) {
246
+ update_option( 'mediafromftp', get_option( 'mediafromftp_settings_' . $user->ID ) );
247
+ delete_option( 'mediafromftp_settings_' . $user->ID );
248
+ update_user_option( $user->ID, 'mediafromftp', get_option( 'mediafromftp' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  }
250
 
251
+ if ( ! get_option( 'mediafromftp' ) ) {
252
+ $mediafromftp_tbl = array(
253
+ 'pagemax' => $pagemax,
254
+ 'basedir' => $basedir,
255
+ 'searchdir' => $searchdir,
256
+ 'ext2typefilter' => $ext2typefilter,
257
+ 'extfilter' => $extfilter,
258
+ 'search_display_metadata' => $search_display_metadata,
259
+ 'dateset' => $dateset,
260
+ 'datefixed' => $datefixed,
261
+ 'datetimepicker' => $datetimepicker,
262
+ 'max_execution_time' => $max_execution_time,
263
+ 'character_code' => $character_code,
264
+ 'exclude' => $exclude,
265
+ 'recursive_search' => $recursive_search,
266
+ 'thumb_deep_search' => $thumb_deep_search,
267
+ 'search_limit_number' => $search_limit_number,
268
+ 'cron' => array(
269
+ 'apply' => $cron_apply,
270
+ 'schedule' => $cron_schedule,
271
+ 'limit_number' => $cron_limit_number,
272
+ 'mail_apply' => $cron_mail_apply,
273
+ 'mail' => $user->user_email,
274
+ 'user' => $user->ID,
275
+ ),
276
+ 'caption' => array(
277
+ 'apply' => $caption_apply,
278
+ 'exif_text' => $exif_text,
279
+ ),
280
+ 'log' => $log,
281
+ 'mlcc' => $mlcc,
282
+ 'emlc' => $emlc,
283
+ 'mlac' => $mlac,
284
+ 'mlat' => $mlat,
285
+ );
286
+
287
+ update_option( 'mediafromftp', $mediafromftp_tbl );
288
+ }
289
+ if ( ! get_user_option( 'mediafromftp', $user->ID ) ) {
290
+ $mediafromftp_set = get_option( 'mediafromftp' );
291
+ $mediafromftp_set['cron']['mail'] = $user->user_email;
292
+ $mediafromftp_set['cron']['user'] = $user->ID;
293
+ update_user_option( $user->ID, 'mediafromftp', $mediafromftp_set );
294
+ }
295
 
296
  }
297
 
req/class-tt-mediafromftp-list-table.php CHANGED
@@ -123,7 +123,7 @@ class TT_MediaFromFtp_List_Table extends WP_List_Table {
123
  private function read_data() {
124
 
125
  $mediafromftp = new MediaFromFtp();
126
- $mediafromftp_settings = get_option( $this->wp_options_name() );
127
  $pagemax = $mediafromftp_settings['pagemax'];
128
  $searchdir = $mediafromftp_settings['searchdir'];
129
  $ext2typefilter = $mediafromftp_settings['ext2typefilter'];
@@ -257,7 +257,7 @@ class TT_MediaFromFtp_List_Table extends WP_List_Table {
257
  'emlcategories' => '<div>' . __( 'Categories' ) . '<div></div>Enhanced Media Library</div>',
258
  'mlacategories' => '<div>' . __( 'Categories' ) . ' & ' . __( 'Tags' ) . '<div></div>Media Library Assistant</div>',
259
  );
260
- $mediafromftp_settings = get_option( $this->wp_options_name() );
261
  if ( 'new' === $mediafromftp_settings['dateset'] || 'fixed' === $mediafromftp_settings['dateset'] ) {
262
  unset( $columns['datetime'] );
263
  }
@@ -313,7 +313,7 @@ class TT_MediaFromFtp_List_Table extends WP_List_Table {
313
  /**
314
  * First, lets decide how many records per page to show
315
  */
316
- $mediafromftp_settings = get_option( $this->wp_options_name() );
317
  $per_page = $mediafromftp_settings['pagemax'];
318
 
319
  /**
@@ -429,19 +429,6 @@ class TT_MediaFromFtp_List_Table extends WP_List_Table {
429
  );
430
  }
431
 
432
- /** ==================================================
433
- * Options name
434
- *
435
- * @return string $this->wp_options_name()
436
- * @since 10.09
437
- */
438
- private function wp_options_name() {
439
- if ( ! function_exists( 'wp_get_current_user' ) ) {
440
- include_once( ABSPATH . 'wp-includes/pluggable.php' );
441
- }
442
- return 'mediafromftp_settings_' . get_current_user_id();
443
- }
444
-
445
  }
446
 
447
 
123
  private function read_data() {
124
 
125
  $mediafromftp = new MediaFromFtp();
126
+ $mediafromftp_settings = get_user_option( 'mediafromftp', get_current_user_id() );
127
  $pagemax = $mediafromftp_settings['pagemax'];
128
  $searchdir = $mediafromftp_settings['searchdir'];
129
  $ext2typefilter = $mediafromftp_settings['ext2typefilter'];
257
  'emlcategories' => '<div>' . __( 'Categories' ) . '<div></div>Enhanced Media Library</div>',
258
  'mlacategories' => '<div>' . __( 'Categories' ) . ' & ' . __( 'Tags' ) . '<div></div>Media Library Assistant</div>',
259
  );
260
+ $mediafromftp_settings = get_user_option( 'mediafromftp', get_current_user_id() );
261
  if ( 'new' === $mediafromftp_settings['dateset'] || 'fixed' === $mediafromftp_settings['dateset'] ) {
262
  unset( $columns['datetime'] );
263
  }
313
  /**
314
  * First, lets decide how many records per page to show
315
  */
316
+ $mediafromftp_settings = get_user_option( 'mediafromftp', get_current_user_id() );
317
  $per_page = $mediafromftp_settings['pagemax'];
318
 
319
  /**
429
  );
430
  }
431
 
 
 
 
 
 
 
 
 
 
 
 
 
 
432
  }
433
 
434
 
uninstall.php CHANGED
@@ -13,6 +13,11 @@ global $wpdb;
13
 
14
  /* For Single site */
15
  if ( ! is_multisite() ) {
 
 
 
 
 
16
  foreach ( media_from_ftp_uninstall_option_names() as $option_name ) {
17
  delete_option( $option_name );
18
  /* Delete log database */
@@ -25,6 +30,16 @@ if ( ! is_multisite() ) {
25
  $original_blog_id = get_current_blog_id();
26
  foreach ( $blog_ids as $blogid ) {
27
  switch_to_blog( $blogid );
 
 
 
 
 
 
 
 
 
 
28
  foreach ( media_from_ftp_uninstall_option_names() as $option_name ) {
29
  delete_option( $option_name );
30
  /* Delete log database */
13
 
14
  /* For Single site */
15
  if ( ! is_multisite() ) {
16
+ delete_option( 'mediafromftp' );
17
+ $blogusers = get_users( array( 'fields' => array( 'ID' ) ) );
18
+ foreach ( $blogusers as $user ) {
19
+ delete_user_option( $user->ID, 'mediafromftp', false );
20
+ }
21
  foreach ( media_from_ftp_uninstall_option_names() as $option_name ) {
22
  delete_option( $option_name );
23
  /* Delete log database */
30
  $original_blog_id = get_current_blog_id();
31
  foreach ( $blog_ids as $blogid ) {
32
  switch_to_blog( $blogid );
33
+ delete_option( 'mediafromftp' );
34
+ $blogusers = get_users(
35
+ array(
36
+ 'blog_id' => $blogid,
37
+ 'fields' => array( 'ID' ),
38
+ )
39
+ );
40
+ foreach ( $blogusers as $user ) {
41
+ delete_user_option( $user->ID, 'mediafromftp', false );
42
+ }
43
  foreach ( media_from_ftp_uninstall_option_names() as $option_name ) {
44
  delete_option( $option_name );
45
  /* Delete log database */