Changeset 3223894
- Timestamp:
- 01/17/2025 12:27:41 AM (7 weeks ago)
- Location:
- moving-users/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
moving-users/trunk/lib/class-movingusers.php
r3045309 r3223894 56 56 add_action( 'movingusers_update_db_hook', array( $this, 'update_db' ), 10, 2 ); 57 57 add_action( 'movingusers_clear_db_hook', array( $this, 'clear_db' ), 10, 1 ); 58 add_action( 'movingusers_logs_check_files', array( $this, 'logs_check_files' ), 10, 1 );59 add_action( 'movingusers_logs_slice_create', array( $this, 'logs_slice_create' ), 10, 3 );60 add_action( 'movingusers_logs_slice_delete', array( $this, 'logs_slice_delete' ), 10, 2 );61 58 } 62 59 … … 103 100 $file = null; 104 101 105 /* Option logs slice and file delete for create json */ 106 do_action( 'movingusers_logs_slice_create', 'moving_users_export_files', $name, get_option( 'moving_users_number_files', 5 ) ); 107 108 if ( get_option( 'moving_users_mail_send' ) ) { 109 /* Send mail JSON file */ 110 $message = 'Moving Users : ' . __( 'The JSON file for the contents has been generated.', 'moving-users' ); 111 wp_mail( get_option( 'admin_email' ), $message, $message, null, $json_file ); 102 /* Send mail JSON file */ 103 $message = 'Moving Users : ' . __( 'The JSON file for the users has been generated.', 'moving-users' ); 104 $send = wp_mail( get_option( 'admin_email' ), $message, $message, null, $json_file ); 105 if ( $send ) { 106 echo '<div class="notice notice-success is-dismissible"><ul><li>' . esc_html( __( 'Email has been sent.', 'moving-users' ) ) . '</li></ul></div>'; 107 } else { 108 echo '<div class="notice notice-error is-dismissible"><ul><li>' . esc_html( __( 'Failed to send email.', 'moving-users' ) ) . '</li></ul></div>'; 109 } 110 if ( file_exists( $json_file ) ) { 111 wp_delete_file( $json_file ); 112 112 } 113 113 } … … 191 191 ); 192 192 } 193 194 /** ==================================================195 * Check option logs and files196 *197 * @param string $option_name option_name.198 * @since 1.00199 */200 public function logs_check_files( $option_name ) {201 202 $logs = get_option( $option_name, array() );203 204 $json_files = array();205 $files = glob( $this->upload_dir . '*.json' );206 if ( ! empty( $files ) ) {207 foreach ( $files as $file ) {208 $json_files[] = wp_basename( $file );209 }210 }211 $delete_files_diff = array_diff( $logs, $json_files );212 if ( ! empty( $delete_files_diff ) ) {213 foreach ( $logs as $key => $value ) {214 if ( in_array( $value, $delete_files_diff ) ) {215 unset( $logs[ $key ] );216 }217 }218 array_values( $logs );219 update_option( $option_name, $logs );220 }221 }222 223 /** ==================================================224 * Option logs slice and file delete for create json225 *226 * @param string $option_name option_name.227 * @param string $name name.228 * @param int $number_files number_files.229 * @since 1.00230 */231 public function logs_slice_create( $option_name, $name, $number_files ) {232 233 $logs = get_option( $option_name, array() );234 235 if ( ! empty( $logs ) ) {236 $log_files_all = array_merge( array( $name ), $logs );237 } else {238 $log_files_all = array( $name );239 }240 $log_files = array_slice( $log_files_all, 0, $number_files );241 $delete_files = array_slice( $log_files_all, $number_files );242 update_option( $option_name, $log_files );243 foreach ( $delete_files as $value ) {244 $delete_file = $this->upload_dir . $value;245 if ( file_exists( $delete_file ) ) {246 wp_delete_file( $delete_file );247 }248 }249 }250 251 /** ==================================================252 * Option logs slice and file delete for delete json253 *254 * @param string $option_name option_name.255 * @param array $delete_files delete_files.256 * @since 1.00257 */258 public function logs_slice_delete( $option_name, $delete_files ) {259 260 $logs = get_option( $option_name, array() );261 262 foreach ( $delete_files as $name ) {263 if ( ! empty( $logs ) ) {264 foreach ( $logs as $key => $value ) {265 if ( $value === $name ) {266 unset( $logs[ $key ] );267 }268 }269 array_values( $logs );270 update_option( $option_name, $logs );271 }272 if ( file_exists( $this->upload_dir . $name ) ) {273 wp_delete_file( $this->upload_dir . $name );274 }275 }276 }277 193 } -
moving-users/trunk/lib/class-movingusersadmin.php
r3092630 r3223894 84 84 if ( $file == $this_plugin ) { 85 85 $links[] = '<a href="' . admin_url( 'admin.php?page=movingusers' ) . '">Moving Users</a>'; 86 $links[] = '<a href="' . admin_url( 'admin.php?page=movingusers-generate-json' ) . '">' . __( 'Export' ) . '</a>';87 $links[] = '<a href="' . admin_url( 'admin.php?page=movingusers-update-db' ) . '">' . __( 'Import' ) . '</a>';86 $links[] = '<a href="' . admin_url( 'admin.php?page=movingusers-generate-json' ) . '">' . __( 'Export', 'moving-users' ) . '</a>'; 87 $links[] = '<a href="' . admin_url( 'admin.php?page=movingusers-update-db' ) . '">' . __( 'Import', 'moving-users' ) . '</a>'; 88 88 } 89 89 return $links; … … 106 106 add_submenu_page( 107 107 'movingusers', 108 __( 'Export' ),109 __( 'Export' ),108 __( 'Export', 'moving-users' ), 109 __( 'Export', 'moving-users' ), 110 110 'manage_options', 111 111 'movingusers-generate-json', … … 114 114 add_submenu_page( 115 115 'movingusers', 116 __( 'Import' ),117 __( 'Import' ),116 __( 'Import', 'moving-users' ), 117 __( 'Import', 'moving-users' ), 118 118 'manage_options', 119 119 'movingusers-update-db', … … 130 130 131 131 if ( ! current_user_can( 'manage_options' ) ) { 132 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.' ) );132 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'moving-users' ) ); 133 133 } 134 134 135 135 $scriptname = admin_url( 'admin.php?page=movingusers-generate-json' ); 136 137 if ( isset( $_POST['Jsonmailsend'] ) && ! empty( $_POST['Jsonmailsend'] ) ) {138 if ( check_admin_referer( 'zm_file_json', 'movingusers_file_json' ) ) {139 if ( ! empty( $_POST['mail_send'] ) ) {140 update_option( 'moving_users_mail_send', true );141 } else {142 update_option( 'moving_users_mail_send', false );143 }144 echo '<div class="notice notice-success is-dismissible"><ul><li>' . esc_html( __( 'Settings' ) . ' --> ' . __( 'Changes saved.' ) ) . '</li></ul></div>';145 }146 }147 148 if ( isset( $_POST['Cnumber'] ) && ! empty( $_POST['Cnumber'] ) ) {149 if ( check_admin_referer( 'zm_file_json', 'movingusers_file_json' ) ) {150 if ( ! empty( $_POST['number_files'] ) ) {151 update_option( 'moving_users_number_files', absint( $_POST['number_files'] ) );152 echo '<div class="notice notice-success is-dismissible"><ul><li>' . esc_html( __( 'Settings' ) . ' --> ' . __( 'Changes saved.' ) ) . '</li></ul></div>';153 }154 }155 }156 157 do_action( 'movingusers_logs_check_files', 'moving_users_export_files' );158 136 159 137 if ( isset( $_POST['Cjson'] ) && ! empty( $_POST['Cjson'] ) ) { … … 162 140 } 163 141 } 164 if ( isset( $_POST['Djson'] ) && ! empty( $_POST['Djson'] ) ) {165 if ( check_admin_referer( 'zm_file_json', 'movingusers_file_json' ) ) {166 if ( ! empty( $_POST['delete_files'] ) ) {167 $delete_files = filter_var(168 wp_unslash( $_POST['delete_files'] ),169 FILTER_CALLBACK,170 array(171 'options' => function ( $value ) {172 return sanitize_text_field( $value );173 },174 )175 );176 do_action( 'movingusers_logs_slice_delete', 'moving_users_export_files', $delete_files );177 }178 }179 }180 142 181 143 ?> 182 144 <div class="wrap"> 183 145 184 <h2>Moving Users <a href="<?php echo esc_url( admin_url( 'admin.php?page=movingusers-generate-json' ) ); ?>" style="text-decoration: none;"><?php esc_html_e( 'Export' ); ?></a>185 <a href="<?php echo esc_url( admin_url( 'admin.php?page=movingusers-update-db' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Import' ); ?></a>146 <h2>Moving Users <a href="<?php echo esc_url( admin_url( 'admin.php?page=movingusers-generate-json' ) ); ?>" style="text-decoration: none;"><?php esc_html_e( 'Export', 'moving-users' ); ?></a> 147 <a href="<?php echo esc_url( admin_url( 'admin.php?page=movingusers-update-db' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Import', 'moving-users' ); ?></a> 186 148 <?php 187 149 if ( class_exists( 'MovingContents' ) ) { … … 207 169 <div style="clear: both;"></div> 208 170 209 <h3><?php esc_html_e( 'Export' ); ?></h3>171 <h3><?php esc_html_e( 'Export', 'moving-users' ); ?></h3> 210 172 <form method="post" action="<?php echo esc_url( $scriptname ); ?>"> 211 173 <div style="margin: 5px; padding: 5px;"> … … 214 176 </p> 215 177 <?php wp_nonce_field( 'zm_file_json', 'movingusers_file_json' ); ?> 216 <div style="margin: 5px; padding: 5px; vertical-align: middle;"> 217 <input type="checkbox" name="mail_send" value="1" <?php checked( get_option( 'moving_users_mail_send' ), true ); ?>> 218 <?php esc_html_e( 'Send the exported JSON file by e-mail', 'moving-users' ); ?> 219 <?php submit_button( __( 'Change' ), 'large', 'Jsonmailsend', false, array( 'style' => 'vertical-align: middle;' ) ); ?> 220 </div> 221 <?php submit_button( __( 'Export as JSON' ), 'large', 'Cjson', true ); ?> 222 </div> 178 <?php submit_button( __( 'Export and send by email', 'moving-users' ), 'large', 'Cjson', true ); ?> 179 </div> 180 </form> 181 182 </div> 183 223 184 <?php 224 $logs = get_option( 'moving_users_export_files' );225 if ( ! empty( $logs ) ) {226 ?>227 <h3>JSON <?php esc_html_e( 'File', 'moving-users' ); ?></h3>228 <div style="margin: 5px; padding: 5px;">229 <?php esc_html_e( 'Number of latest files to keep', 'moving-users' ); ?> :230 <input type="number" name="number_files" value="<?php echo esc_attr( get_option( 'moving_users_number_files', 5 ) ); ?>" min="1" max="100" step="1" style="width: 70px;" />231 <?php submit_button( __( 'Change' ), 'large', 'Cnumber', false ); ?>232 <?php submit_button( __( 'Delete' ), 'large', 'Djson', true ); ?>233 <table border=1 cellspacing="0" cellpadding="5" bordercolor="#000000" style="border-collapse: collapse;">234 <tr>235 <th><?php esc_html_e( 'Delete' ); ?></th>236 <th><?php esc_html_e( 'Name' ); ?></th>237 <th><?php esc_html_e( 'Date/time' ); ?></th>238 <th><?php esc_html_e( 'Size' ); ?></th>239 <th><?php esc_html_e( 'Action' ); ?></th>240 </tr>241 <?php242 foreach ( $logs as $value ) {243 $json_filename = $this->upload_dir . $value;244 $json_fileurl = $this->upload_url . $value;245 if ( file_exists( $json_filename ) ) {246 if ( function_exists( 'wp_date' ) ) {247 $json_time = wp_date( 'Y-m-d H:i:s', filemtime( $json_filename ) );248 } else {249 $json_time = date_i18n( 'Y-m-d H:i:s', filemtime( $json_filename ) );250 }251 $json_byte = filesize( $json_filename );252 $json_size = size_format( $json_byte, 2 );253 ?>254 <tr>255 <td>256 <input type="checkbox" name="delete_files[]" value="<?php echo esc_attr( $value ); ?>">257 </td>258 <td>259 <?php echo esc_html( $value ); ?>260 </td>261 <td>262 <?php echo esc_html( $json_time ); ?>263 </td>264 <td>265 <?php echo esc_html( $json_size ); ?>266 </td>267 <td>268 <button type="button" class="button button-large" onclick="location.href='<?php echo esc_url( $json_fileurl ); ?>'"><?php esc_html_e( 'View' ); ?></button>269 270 <a href="<?php echo esc_url( $json_fileurl ); ?>" download="<?php echo esc_attr( $value ); ?>"><button type="button" class="button button-large"><?php esc_html_e( 'Download', 'moving-users' ); ?></button></a>271 </td>272 </tr>273 <?php274 }275 }276 ?>277 </table>278 <?php submit_button( __( 'Delete' ), 'large', 'Djson', true ); ?>279 </div>280 <?php281 }282 ?>283 </form>284 285 </div>286 287 <?php288 185 } 289 186 … … 296 193 297 194 if ( ! current_user_can( 'manage_options' ) ) { 298 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.' ) );195 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'moving-users' ) ); 299 196 } 300 197 … … 307 204 if ( isset( $_SERVER['CONTENT_LENGTH'] ) && ! empty( $_SERVER['CONTENT_LENGTH'] ) ) { 308 205 if ( 0 < $max_upload_size && $max_upload_size < intval( $_SERVER['CONTENT_LENGTH'] ) ) { 309 echo '<div class="notice notice-error is-dismissible"><ul><li>' . esc_html__( 'This is larger than the maximum size. Please try another.' ) . '</li></ul></div>';206 echo '<div class="notice notice-error is-dismissible"><ul><li>' . esc_html__( 'This is larger than the maximum size. Please try another.', 'moving-users' ) . '</li></ul></div>'; 310 207 } 311 208 } … … 331 228 $filetype = wp_check_filetype( $filename ); 332 229 if ( ! $filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) ) { 333 echo '<div class="notice notice-error is-dismissible"><ul><li>' . esc_html__( 'Sorry, this file type is not permitted for security reasons.' ) . '</li></ul></div>';230 echo '<div class="notice notice-error is-dismissible"><ul><li>' . esc_html__( 'Sorry, this file type is not permitted for security reasons.', 'moving-users' ) . '</li></ul></div>'; 334 231 } else { 335 232 $filetype2 = wp_check_filetype( $filename, array( $filetype['ext'] => $mimetype ) ); … … 374 271 wp_delete_file( $json_file ); 375 272 } else { 376 echo '<div class="notice notice-error is-dismissible"><ul><li>' . esc_html__( 'Could not copy file.' ) . '</li></ul></div>';273 echo '<div class="notice notice-error is-dismissible"><ul><li>' . esc_html__( 'Could not copy file.', 'moving-users' ) . '</li></ul></div>'; 377 274 } 378 275 } else { 379 echo '<div class="notice notice-error is-dismissible"><ul><li>' . esc_html__( 'Sorry, this file type is not permitted for security reasons.' ) . '</li></ul></div>';276 echo '<div class="notice notice-error is-dismissible"><ul><li>' . esc_html__( 'Sorry, this file type is not permitted for security reasons.', 'moving-users' ) . '</li></ul></div>'; 380 277 } 381 278 } 382 279 } else { 383 echo '<div class="notice notice-error is-dismissible"><ul><li>' . esc_html__( 'No such file exists! Double check the name and try again.' ) . '</li></ul></div>';280 echo '<div class="notice notice-error is-dismissible"><ul><li>' . esc_html__( 'No such file exists! Double check the name and try again.', 'moving-users' ) . '</li></ul></div>'; 384 281 } 385 282 } … … 390 287 <div class="wrap"> 391 288 392 <h2>Moving Users <a href="<?php echo esc_url( admin_url( 'admin.php?page=movingusers-update-db' ) ); ?>" style="text-decoration: none;"><?php esc_html_e( 'Import' ); ?></a>393 <a href="<?php echo esc_url( admin_url( 'admin.php?page=movingusers-generate-json' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Export' ); ?></a>289 <h2>Moving Users <a href="<?php echo esc_url( admin_url( 'admin.php?page=movingusers-update-db' ) ); ?>" style="text-decoration: none;"><?php esc_html_e( 'Import', 'moving-users' ); ?></a> 290 <a href="<?php echo esc_url( admin_url( 'admin.php?page=movingusers-generate-json' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Export', 'moving-users' ); ?></a> 394 291 <?php 395 292 if ( class_exists( 'MovingContents' ) ) { … … 437 334 <?php 438 335 /* translators: Maximum upload file size */ 439 echo esc_html( sprintf( __( 'Maximum upload file size: %s.' ), $limit_str ) );336 echo esc_html( sprintf( __( 'Maximum upload file size: %s.', 'moving-users' ), $limit_str ) ); 440 337 ?> 441 338 </div> … … 459 356 460 357 if ( ! current_user_can( 'manage_options' ) ) { 461 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.' ) );358 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'moving-users' ) ); 462 359 } 463 360 … … 466 363 467 364 <h2>Moving Users 468 <a href="<?php echo esc_url( admin_url( 'admin.php?page=movingusers-generate-json' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Export' ); ?></a>469 <a href="<?php echo esc_url( admin_url( 'admin.php?page=movingusers-update-db' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Import' ); ?></a>365 <a href="<?php echo esc_url( admin_url( 'admin.php?page=movingusers-generate-json' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Export', 'moving-users' ); ?></a> 366 <a href="<?php echo esc_url( admin_url( 'admin.php?page=movingusers-update-db' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Import', 'moving-users' ); ?></a> 470 367 <?php 471 368 if ( class_exists( 'MovingContents' ) ) { … … 535 432 } 536 433 } 537 $plugin_version = __( 'Version:' ) . ' ' . $plugin_ver_num;434 $plugin_version = __( 'Version:', 'moving-users' ) . ' ' . $plugin_ver_num; 538 435 /* translators: FAQ Link & Slug */ 539 436 $faq = sprintf( __( 'https://wordpress.org/plugins/%s/faq', 'moving-users' ), $slug ); … … 556 453 <?php 557 454 /* translators: Plugin translation link */ 558 echo esc_html( sprintf( __( 'Translations for %s' ), $plugin_name ) );455 echo esc_html( sprintf( __( 'Translations for %s', 'moving-users' ), $plugin_name ) ); 559 456 ?> 560 457 </a> | <a style="text-decoration: none;" href="<?php echo esc_url( $facebook ); ?>" target="_blank" rel="noopener noreferrer"><span class="dashicons dashicons-facebook"></span></a> | <a style="text-decoration: none;" href="<?php echo esc_url( $twitter ); ?>" target="_blank" rel="noopener noreferrer"><span class="dashicons dashicons-twitter"></span></a> | <a style="text-decoration: none;" href="<?php echo esc_url( $youtube ); ?>" target="_blank" rel="noopener noreferrer"><span class="dashicons dashicons-video-alt3"></span></a> … … 565 462 <h3><?php esc_html_e( 'Please make a donation if you like my work or would like to further the development of this plugin.', 'moving-users' ); ?></h3> 566 463 <div style="text-align: right; margin: 5px; padding: 5px;"><span style="padding: 3px; color: #ffffff; background-color: #008000">Plugin Author</span> <span style="font-weight: bold;">Katsushi Kawamori</span></div> 567 <button type="button" style="margin: 5px; padding: 5px;" onclick="window.open('<?php echo esc_url( $donate ); ?>')"><?php esc_html_e( 'Donate to this plugin »' ); ?></button>464 <button type="button" style="margin: 5px; padding: 5px;" onclick="window.open('<?php echo esc_url( $donate ); ?>')"><?php esc_html_e( 'Donate to this plugin »', 'moving-users' ); ?></button> 568 465 </div> 569 466 … … 582 479 } 583 480 } 584 585 -
moving-users/trunk/movingusers.php
r3092630 r3223894 4 4 * Plugin URI: https://wordpress.org/plugins/moving-users/ 5 5 * Description: Supports the transfer of Users between servers. 6 * Version: 1. 056 * Version: 1.10 7 7 * Author: Katsushi Kawamori 8 8 * Author URI: https://riverforest-wp.info/ -
moving-users/trunk/readme.txt
r3182719 r3223894 6 6 Requires PHP: 8.0 7 7 Tested up to: 6.7 8 Stable tag: 1. 058 Stable tag: 1.10 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 50 50 == Changelog == 51 51 52 = [1.10] 2025/01/17 = 53 * Fix - json files are not left on the server but sent to the administrator via email. 54 52 55 = [1.05] 2024/05/26 = 53 56 * Fix - Fixed problem with import files not being copied. … … 68 71 = 1.00 = 69 72 Initial release. 73 74 == Upgrade Notice == 75 76 = 1.10 = 77 Security measures. 78 79 = 1.00 = 80 Initial release.
Note: See TracChangeset
for help on using the changeset viewer.