Changeset 6045
- Timestamp:
- 10/19/2017 12:06:14 AM (7 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php
r6026 r6045 55 55 * Runs various tests and creates plugin post. 56 56 * 57 * @return string Failure or success message.57 * @return string|WP_Error Confirmation message on success, WP_Error object on failure. 58 58 */ 59 59 public function process_upload() { … … 76 76 $error = __( 'Error: The plugin has no name.', 'wporg-plugins' ); 77 77 78 /* translators: 1: plugin header line, 2: Codex URL */ 79 return $error . ' ' . sprintf( __( 'Add a %1$s line to your main plugin file and upload the plugin again. <a href="%2$s">Plugin Headers</a>', 'wporg-plugins' ), 78 return new \WP_Error( 'no_name', $error . ' ' . sprintf( 79 /* translators: 1: plugin header line, 2: Codex URL */ 80 __( 'Add a %1$s line to your main plugin file and upload the plugin again. <a href="%2$s">Plugin Headers</a>', 'wporg-plugins' ), 80 81 '<code>Plugin Name:</code>', 81 82 __( 'https://codex.wordpress.org/File_Header', 'wporg-plugins' ) 82 ) ;83 ) ); 83 84 } 84 85 … … 92 93 $error = __( 'Error: The plugin has an unsupported name.', 'wporg-plugins' ); 93 94 94 /* translators: %s: 'Plugin Name:' */ 95 return $error . ' ' . sprintf( __( 'Plugin names can only contain latin letters (A-z), numbers, spaces, and hyphens. Please change the %s line in your main plugin file and upload it again.', 'wporg-plugins' ), 95 return new \WP_Error( 'unsupported_name', $error . ' ' . sprintf( 96 /* translators: %s: 'Plugin Name:' */ 97 __( 'Plugin names can only contain latin letters (A-z), numbers, spaces, and hyphens. Please change the %s line in your main plugin file and upload it again.', 'wporg-plugins' ), 96 98 esc_html( $this->plugin['Name'] ), 97 99 '<code>Plugin Name:</code>' 98 ) ;100 ) ); 99 101 } 100 102 … … 103 105 $error = __( 'Error: The plugin has a reserved name.', 'wporg-plugins' ); 104 106 105 /* translators: 1: plugin slug, 2: 'Plugin Name:' */ 106 return $error . ' ' . sprintf( __( 'Your chosen plugin name - %1$s - has been reserved for use by WordPress. Please change the %2$s line in your main plugin file and upload it again.', 'wporg-plugins' ), 107 return new \WP_Error( 'reserved_name', $error . ' ' . sprintf( 108 /* translators: 1: plugin slug, 2: 'Plugin Name:' */ 109 __( 'Your chosen plugin name - %1$s - has been reserved for use by WordPress. Please change the %2$s line in your main plugin file and upload it again.', 'wporg-plugins' ), 107 110 '<code>' . $this->plugin_slug . '</code>', 108 111 '<code>Plugin Name:</code>' 109 ) ;112 ) ); 110 113 } 111 114 … … 116 119 $error = __( 'Error: The plugin already exists.', 'wporg-plugins' ); 117 120 118 /* translators: 1: plugin slug, 2: 'Plugin Name:' */ 119 return $error . ' ' . sprintf( __( 'There is already a plugin called %1$s by a different author. Please change the %2$s line in your main plugin file and upload it again.', 'wporg-plugins' ), 121 return new \WP_Error( 'already_exists', $error . ' ' . sprintf( 122 /* translators: 1: plugin slug, 2: 'Plugin Name:' */ 123 __( 'There is already a plugin called %1$s by a different author. Please change the %2$s line in your main plugin file and upload it again.', 'wporg-plugins' ), 120 124 '<code>' . $this->plugin_slug . '</code>', 121 125 '<code>Plugin Name:</code>' 122 ) ;126 ) ); 123 127 } 124 128 … … 127 131 $error = __( 'Error: The plugin has already been submitted.', 'wporg-plugins' ); 128 132 129 /* translators: 1: plugin slug, 2: plugins@wordpress.org */ 130 return $error . ' ' . sprintf( __( 'You have already submitted a plugin called %1$s. Please be patient and wait for a review. If you have made a mistake, please email <a href="mailto:%2$s">%2$s</a> and let us know.', 'wporg-plugins' ), 133 return new \WP_Error( 'already_submitted', $error . ' ' . sprintf( 134 /* translators: 1: plugin slug, 2: plugins@wordpress.org */ 135 __( 'You have already submitted a plugin called %1$s. Please be patient and wait for a review. If you have made a mistake, please email <a href="mailto:%2$s">%2$s</a> and let us know.', 'wporg-plugins' ), 131 136 '<code>' . $this->plugin_slug . '</code>', 132 137 'plugins@wordpress.org' 133 ) ;138 ) ); 134 139 } 135 140 … … 137 142 $error = __( 'Error: The plugin has no description.', 'wporg-plugins' ); 138 143 139 /* translators: 1: plugin header line, 2: Codex URL */ 140 return $error . ' ' . sprintf( __( 'Add a %1$s line to your main plugin file and upload the plugin again. <a href="%2$s">Plugin Headers</a>', 'wporg-plugins' ), 144 return new \WP_Error( 'no_description', $error . ' ' . sprintf( 145 /* translators: 1: plugin header line, 2: Codex URL */ 146 __( 'Add a %1$s line to your main plugin file and upload the plugin again. <a href="%2$s">Plugin Headers</a>', 'wporg-plugins' ), 141 147 '<code>Description:</code>', 142 148 __( 'https://codex.wordpress.org/File_Header', 'wporg-plugins' ) 143 ) ;149 ) ); 144 150 } 145 151 … … 147 153 $error = __( 'Error: The plugin has no version.', 'wporg-plugins' ); 148 154 149 /* translators: 1: plugin header line, 2: Codex URL */ 150 return $error . ' ' . sprintf( __( 'Add a %1$s line to your main plugin file and upload the plugin again. <a href="%2$s">Plugin Headers</a>', 'wporg-plugins' ), 155 return new \WP_Error( 'no_version', $error . ' ' . sprintf( 156 /* translators: 1: plugin header line, 2: Codex URL */ 157 __( 'Add a %1$s line to your main plugin file and upload the plugin again. <a href="%2$s">Plugin Headers</a>', 'wporg-plugins' ), 151 158 '<code>Version:</code>', 152 159 __( 'https://codex.wordpress.org/File_Header', 'wporg-plugins' ) 153 ) ;160 ) ); 154 161 } 155 162 … … 157 164 $error = __( 'Error: Plugin versions are expected to be numbers.', 'wporg-plugins' ); 158 165 159 /* translators: %s: 'Version:' */ 160 return $error . ' ' . sprintf( __( 'Version strings can only contain numeric and period characters (like 1.2). Please fix the %s line in your main plugin file and upload the plugin again.', 'wporg-plugins' ), 166 return new \WP_Error( 'invalid_version', $error . ' ' . sprintf( 167 /* translators: %s: 'Version:' */ 168 __( 'Version strings can only contain numeric and period characters (like 1.2). Please fix the %s line in your main plugin file and upload the plugin again.', 'wporg-plugins' ), 161 169 '<code>Version:</code>' 162 ) ;170 ) ); 163 171 } 164 172 … … 167 175 $error = __( 'Error: Your plugin and author URIs are the same.', 'wporg-plugins' ); 168 176 169 return $error . ' ' . __( 'A plugin URL is a page/site that provides details about this specific plugin. An author URL is a page/site that provides information about the author of the plugin. You are not required to provide both, so pick the one that best applies to your URL.', 'wporg-plugins' ); 177 return new \WP_Error( 'plugin_author_uri', $error . ' ' . 178 __( 'A plugin URL is a page/site that provides details about this specific plugin. An author URL is a page/site that provides information about the author of the plugin. You are not required to provide both, so pick the one that best applies to your URL.', 'wporg-plugins' ) 179 ); 170 180 } 171 181 … … 174 184 $error = __( 'Error: The plugin has no readme.', 'wporg-plugins' ); 175 185 176 /* translators: 1: readme.txt, 2: readme.md */ 177 return $error . ' ' . sprintf( __( 'The zip file must include a file named %1$s or %2$s. We recommend using %1$s as it will allow you to fully utilize our directory.', 'wporg-plugins' ), 186 return new \WP_Error( 'no_readme', $error . ' ' . sprintf( 187 /* translators: 1: readme.txt, 2: readme.md */ 188 __( 'The zip file must include a file named %1$s or %2$s. We recommend using %1$s as it will allow you to fully utilize our directory.', 'wporg-plugins' ), 178 189 '<code>readme.txt</code>', 179 190 '<code>readme.md</code>' 180 ) ;191 ) ); 181 192 } 182 193 $readme = new Parser( $readme ); … … 189 200 $error = __( 'Error: The plugin has failed the automated checks.', 'wporg-plugins' ); 190 201 191 /* translators: 1: Plugin Check Plugin URL, 2: make.wordpress.org/plugins */ 192 return $error . ' ' . sprintf( __( 'Please correct the problems with the plugin and upload it again. You can also use the <a href="%1$s">Plugin Check Plugin</a> to test your plugin before uploading. If you have any questions about this please post them to %2$s.', 'wporg-plugins' ), 202 return new \WP_Error( 'failed_checks', $error . ' ' . sprintf( 203 /* translators: 1: Plugin Check Plugin URL, 2: make.wordpress.org/plugins */ 204 __( 'Please correct the problems with the plugin and upload it again. You can also use the <a href="%1$s">Plugin Check Plugin</a> to test your plugin before uploading. If you have any questions about this please post them to %2$s.', 'wporg-plugins' ), 193 205 '//wordpress.org/plugins/plugin-check/', 194 206 '<a href="https://make.wordpress.org/plugins">https://make.wordpress.org/plugins</a>' 195 ) ;207 ) ); 196 208 } 197 209 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload.php
r6025 r6045 46 46 } 47 47 48 $upload_result = false; 49 48 50 if ( ! empty( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'wporg-plugins-upload' ) && 'upload' === $_POST['action'] ) : 49 51 if ( UPLOAD_ERR_OK === $_FILES['zip_file']['error'] ) : 50 $uploader = new Upload_Handler; 51 $message = $uploader->process_upload(); 52 $uploader = new Upload_Handler; 53 $upload_result = $uploader->process_upload(); 54 55 if ( is_wp_error( $upload_result ) ) { 56 $message = $upload_result->get_error_message(); 57 } else { 58 $message = $upload_result; 59 } 52 60 else : 53 61 $message = __( 'Error in file upload.', 'wporg-plugins' ); … … 119 127 <?php endif; // wp_verify_nonce() && 'upload' === $_POST['action'] ?> 120 128 121 <?php if ( ! $ submitted_counts->total) : ?>129 <?php if ( ! $upload_result && ! $submitted_counts->total || is_wp_error( $upload_result ) ) : ?> 122 130 123 131 <form id="upload_form" class="plugin-upload-form" enctype="multipart/form-data" method="POST" action="">
Note: See TracChangeset
for help on using the changeset viewer.