Changeset 3034 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php
- Timestamp:
- 04/28/2016 05:40:32 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php
r3025 r3034 94 94 } 95 95 96 // Is there already a plugin with the name name? 97 if ( Plugin_Directory::get_plugin_post( $this->plugin_slug ) ) { 96 $plugin_post = Plugin_Directory::get_plugin_post( $this->plugin_slug ); 97 98 // Is there already a plugin by a different author? 99 if ( $plugin_post instanceof \WP_Post && $plugin_post->post_author != get_current_user_id() ) { 98 100 /* translators: 1: plugin slug, 2: style.css */ 99 101 return sprintf( __( 'There is already a plugin called %1$s by a different author. Please change the name of your plugin and upload it again.', 'wporg-plugins' ), … … 158 160 // Let's save everything and get things wrapped up. 159 161 160 $content = ''; 161 foreach ( $readme->sections as $section => $section_content ) { 162 $content .= "\n\n<!--section={$section}-->\n{$section_content}"; 163 } 164 165 // Add a Plugin Directory entry for this plugin. 166 $plugin_post = Plugin_Directory::create_plugin_post( array( 167 'title' => $this->plugin['Name'], 168 'slug' => $this->plugin_slug, 169 'status' => 'draft', 170 'author' => get_current_user_id(), 171 'content' => $content, 172 'description' => $this->plugin['Description'], 173 'tags' => $readme->tags, 174 'meta' => array( 175 'tested' => $readme->tested, 176 'requires' => $readme->requires, 177 'stable_tag' => $readme->stable_tag, 178 'upgrade_notice' => $readme->upgrade_notice, 179 'contributors' => $readme->contributors, 180 'screenshots' => $readme->screenshots, 181 'donate_link' => $readme->donate_link, 182 'sections' => array_keys( $readme->sections ), 183 'version' => $this->plugin['Version'], 184 'header_name' => $this->plugin['Name'], 185 'header_plugin_uri' => $this->plugin['PluginURI'], 186 'header_author' => $this->plugin['Author'], 187 'header_author_uri' => $this->plugin['AuthorURI'], 188 'header_textdomain' => $this->plugin['TextDomain'], 189 'header_description' => $this->plugin['Description'], 190 'assets_screenshots' => array(), 191 'assets_icons' => array(), 192 'assets_banners' => array(), 193 'assets_banners_color' => false, 194 'support_threads' => 0, 195 'support_threads_resolved' => 0, 196 ), 197 ) ); 198 if ( is_wp_error( $plugin_post ) ) { 199 return $plugin_post->get_error_message(); 162 // Create a new post on first-time submissions. 163 if ( ! ( $plugin_post instanceof \WP_Post ) ) { 164 $content = ''; 165 foreach ( $readme->sections as $section => $section_content ) { 166 $content .= "\n\n<!--section={$section}-->\n{$section_content}"; 167 } 168 169 // Add a Plugin Directory entry for this plugin. 170 $plugin_post = Plugin_Directory::create_plugin_post( array( 171 'title' => $this->plugin['Name'], 172 'slug' => $this->plugin_slug, 173 'status' => 'draft', 174 'author' => get_current_user_id(), 175 'content' => $content, 176 'description' => $this->plugin['Description'], 177 'tags' => $readme->tags, 178 'meta' => array( 179 'tested' => $readme->tested, 180 'requires' => $readme->requires, 181 'stable_tag' => $readme->stable_tag, 182 'upgrade_notice' => $readme->upgrade_notice, 183 'contributors' => $readme->contributors, 184 'screenshots' => $readme->screenshots, 185 'donate_link' => $readme->donate_link, 186 'sections' => array_keys( $readme->sections ), 187 'version' => $this->plugin['Version'], 188 'header_name' => $this->plugin['Name'], 189 'header_plugin_uri' => $this->plugin['PluginURI'], 190 'header_author' => $this->plugin['Author'], 191 'header_author_uri' => $this->plugin['AuthorURI'], 192 'header_textdomain' => $this->plugin['TextDomain'], 193 'header_description' => $this->plugin['Description'], 194 'assets_screenshots' => array(), 195 'assets_icons' => array(), 196 'assets_banners' => array(), 197 'assets_banners_color' => false, 198 'support_threads' => 0, 199 'support_threads_resolved' => 0, 200 ), 201 ) ); 202 if ( is_wp_error( $plugin_post ) ) { 203 return $plugin_post->get_error_message(); 204 } 200 205 } 201 206 … … 294 299 */ 295 300 public function save_zip_file( $post_id ) { 296 $_FILES['zip_file']['name'] = wp_generate_password( 12, false ) . '-' . $_FILES['zip_file']['name'];301 $_FILES['zip_file']['name'] = date( 'd_H-i-s' ) . '_' . $_FILES['zip_file']['name']; 297 302 298 303 add_filter( 'site_option_upload_filetypes', array( $this, 'whitelist_zip_files' ) );
Note: See TracChangeset
for help on using the changeset viewer.