Changeset 11176 for sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/upload.php
- Timestamp:
- 08/13/2021 02:25:40 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/upload.php
r11175 r11176 45 45 $notice = ''; 46 46 47 if ( ! empty( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'wporg-themes-upload' ) && 'upload' === $_POST['action'] ) { 47 if ( 48 ! empty( $_POST['_wpnonce'] ) && 49 wp_verify_nonce( $_POST['_wpnonce'], 'wporg-themes-upload' ) && 50 'upload' === $_POST['action'] 51 ) { 48 52 $messages = wporg_themes_process_upload(); 49 53 50 if ( ! empty( $messages ) ) { 51 $notice_content = ""; 54 $notice_content = ''; 52 55 53 if ( is_array( $messages ) ) { 54 foreach ( $messages as $message){ 55 $notice_content .= "<li>{$message}</li>"; 56 } 57 } else { 58 $notice_content = "<li>{$messages}</li>"; 56 if ( is_wp_error( $messages ) ) { 57 foreach ( $messages->get_error_codes() as $code ) { 58 $message = $messages->get_error_message( $code ); 59 $notice_content .= "<li class='error-code-{$code}'>{$message}</li>"; 59 60 } 61 } else { 62 $notice_content = "<li>{$messages}</li>"; 63 } 60 64 61 $notice = "<div class='notice notice-warning notice-large'><ul>{$notice_content}</ul></div>"; 62 } 65 $notice = "<div class='notice notice-warning notice-large'><ul>{$notice_content}</ul></div>"; 63 66 } 64 67 … … 80 83 * Runs basic checks and hands off to the upload processor. 81 84 * 82 * @return string Failure or success message.85 * @return WP_Error|string Failure or success message. 83 86 */ 84 87 function wporg_themes_process_upload( ) { 85 88 if ( ! is_user_logged_in() ) { 86 return __( 'You must be logged in to upload a new theme.', 'wporg-themes' ); 89 return new WP_Error( 90 'not_logged_in', 91 __( 'You must be logged in to upload a new theme.', 'wporg-themes' ) 92 ); 87 93 } 88 94 89 95 if ( empty( $_FILES['zip_file'] ) ) { 90 return __( 'Error in file upload.', 'wporg-themes' ); 96 return new WP_Error( 97 'invalid_upload', 98 __( 'Error in file upload.', 'wporg-themes' ) 99 ); 91 100 } 92 101 93 102 if ( ! class_exists( 'WPORG_Themes_Upload' ) ) { 94 include_once plugin_dir_path( __FILE__ ) . 'class-wporg-themes-upload.php';103 include_once __DIR__ . '/class-wporg-themes-upload.php'; 95 104 } 96 105 97 $upload = new WPORG_Themes_Upload;106 $upload = new WPORG_Themes_Upload; 98 107 $message = $upload->process_upload( $_FILES['zip_file'] ); 99 108
Note: See TracChangeset
for help on using the changeset viewer.