Changeset 2983
- Timestamp:
- 04/19/2016 08:09:35 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-custom-fields.php
r2655 r2983 9 9 class Custom_Fields { 10 10 static function display() { 11 $post = get_post();11 $post = get_post(); 12 12 $fields = array( 13 13 'version' => 'Latest Plugin Version', … … 22 22 'header_description' => 'Plugin Description', 23 23 ); 24 24 25 echo '<dl>'; 25 26 foreach ( $fields as $field => $text ) { 26 if ( ! ($value = get_post_meta( $post->ID, $field, true )) ) {27 if ( ! $value = get_post_meta( $post->ID, $field, true ) ) { 27 28 continue; 28 29 } 29 30 printf( '<dt>%s</dt><dd>%s</dd>', esc_html( $text ), make_clickable( esc_html( $value ) ) ); 30 31 } 31 // Description is stored in the post_excerpt rather than meta32 printf( '<dt>%s</dt><dd>%s</dd>', esc_html( $fields['header_description'] ), get_the_excerpt() );33 32 echo '</dl>'; 34 33 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r2976 r2983 467 467 * @type int $author The ID of the plugin author. 468 468 * @type string $description The short description of the plugin. 469 * @type string $content The long description of the plugin. 470 * @type array $tags The tags associated with the plugin. 471 * @type array $tags The meta information of the plugin. 469 472 * } 470 473 * @return \WP_Post|\WP_Error 471 474 */ 472 475 static public function create_plugin_post( array $plugin_info ) { 473 $title = !empty( $plugin_info['title'] ) ? $plugin_info['title'] : ''; 474 $slug = !empty( $plugin_info['slug'] ) ? $plugin_info['slug'] : sanitize_title( $title ); 475 $status = !empty( $plugin_info['status'] ) ? $plugin_info['status'] : 'pending'; 476 $author = !empty( $plugin_info['author'] ) ? $plugin_info['author'] : 0; 477 $desc = !empty( $plugin_info['description'] ) ? $plugin_info['description'] : ''; 476 $title = ! empty( $plugin_info['title'] ) ? $plugin_info['title'] : ''; 477 $slug = ! empty( $plugin_info['slug'] ) ? $plugin_info['slug'] : sanitize_title( $title ); 478 $status = ! empty( $plugin_info['status'] ) ? $plugin_info['status'] : 'pending'; 479 $author = ! empty( $plugin_info['author'] ) ? $plugin_info['author'] : 0; 480 $desc = ! empty( $plugin_info['description'] ) ? $plugin_info['description'] : ''; 481 $content = ! empty( $plugin_info['content'] ) ? $plugin_info['content'] : ''; 482 $tags = ! empty( $plugin_info['tags'] ) ? $plugin_info['tags'] : array(); 483 $meta = ! empty( $plugin_info['meta'] ) ? $plugin_info['meta'] : array(); 478 484 479 485 $id = wp_insert_post( array( … … 483 489 'post_title' => $title ?: $slug, 484 490 'post_author' => $author, 485 'post_content' => '',491 'post_content' => $content, 486 492 'post_excerpt' => $desc, 493 'tags_input' => $tags, 494 'meta_input' => $meta, 487 495 ), true ); 488 496 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload-handler.php
r2640 r2983 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Shortcodes; 3 use WordPressdotorg\Plugin_Directory\Readme_Parser; 3 4 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 4 5 use WordPressdotorg\Plugin_Directory\Tools\Filesystem; … … 122 123 123 124 if ( preg_match( '|[^\d\.]|', $this->plugin['Version'] ) ) { 124 /* translators: %s: style.css*/125 /* translators: %s: Version header */ 125 126 return sprintf( __( 'Version strings can only contain numeric and period characters (like 1.2). Please fix your %s line in your main plugin file and upload the plugin again.', 'wporg-plugins' ), 126 127 '<code>Version:</code>' … … 129 130 130 131 // Prevent duplicate URLs. 131 $plugin_uri = $this->plugin['PluginURI']; 132 $author_uri = $this->plugin['AuthorURI']; 133 if ( ! empty( $plugin_uri ) && ! empty( $author_uri ) && $plugin_uri == $author_uri ) { 132 if ( ! empty( $this->plugin['PluginURI'] ) && ! empty( $this->plugin['AuthorURI'] ) && $this->plugin['PluginURI'] == $this->plugin['AuthorURI'] ) { 134 133 return __( 'Duplicate plugin and author URLs. 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 aren’t required to provide both, so pick the one that best applies to your URL.', 'wporg-plugins' ); 135 134 } 135 136 $readme = $this->find_readme_file(); 137 if ( empty( $readme ) ) { 138 /* translators: 1: readme.txt, 2: readme.md */ 139 return sprintf( __( 'The zip file must include a file named %1$s or %2$s.', 'wporg-plugins' ), 140 '<code>readme.txt</code>', 141 '<code>readme.md</code>' 142 ); 143 } 144 $readme = new Readme_Parser( $readme ); 136 145 137 146 // Pass it through Plugin Check and see how great this plugin really is. … … 149 158 // Let's save everything and get things wrapped up. 150 159 160 $content = ''; 161 foreach ( $readme->sections as $section => $section_content ) { 162 $content .= "\n\n<!--section={$section}-->\n{$section_content}"; 163 } 164 151 165 // Add a Plugin Directory entry for this plugin. 152 166 $plugin_post = Plugin_Directory::create_plugin_post( array( 153 167 'title' => $this->plugin['Name'], 154 168 'slug' => $this->plugin_slug, 155 'status' => ' pending',169 'status' => 'draft', 156 170 'author' => get_current_user_id(), 157 'description' => $this->plugin['Description'] 171 'content' => $content, 172 'description' => $this->plugin['Description'], 173 'tags' => $readme->tags, 174 'meta' => array( 175 'stable_tag' => $readme->stable_tag, 176 'tested' => $readme->tested, 177 'requires' => $readme->requires, 178 'donate_link' => $readme->donate_link, 179 'version' => $this->plugin['Version'], 180 'header_plugin_uri' => $this->plugin['PluginURI'], 181 'header_author' => $this->plugin['Author'], 182 'header_author_uri' => $this->plugin['AuthorURI'], 183 'header_textdomain' => $this->plugin['TextDomain'], 184 'header_description' => $this->plugin['Description'], 185 'support_resolutions' => 0, 186 ), 158 187 ) ); 159 188 if ( is_wp_error( $plugin_post ) ) { … … 195 224 'new', 196 225 'updated', 226 'about', 227 'admin', 228 'wp-admin', 197 229 ); 198 230 199 231 return in_array( $this->plugin_slug, $reserved_slugs ); 232 } 233 234 /** 235 * Find the plugin readme file. 236 * 237 * Looks for either a readme.txt or readme.md file, prioritizing readme.txt. 238 * 239 * @return string The plugin readme.txt or readme.md filename. 240 */ 241 protected function find_readme_file() { 242 $files = Filesystem::list_files( "{$this->plugin_dir}/{$this->plugin_slug}", false /* non-recursive */, '!^readme\.(txt|md)$!i' ); 243 244 // Prioritize readme.txt 245 foreach ( $files as $file ) { 246 if ( '.txt' === strtolower( substr( $file, -4 ) ) ) { 247 return $file; 248 } 249 } 250 251 return reset( $files ); 200 252 } 201 253
Note: See TracChangeset
for help on using the changeset viewer.