Making WordPress.org


Ignore:
Timestamp:
06/11/2016 08:43:06 AM (10 years ago)
Author:
obenland
Message:

Plugin Directory: Import tags and map them to categories.

Maps existing tags, that are part of the top 1000 most used tags, to their new
categories. Mapping only occurs for up to three categories and only if there
are no categories set yet.

H/t samuelsidler for putting together the tag/category spreadsheet.

See #1573.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php

    r3213 r3328  
    7979                }
    8080
    81                 if ( ! $plugin ) {                     
     81                if ( ! $plugin ) {
    8282                        $plugin = Plugin_Directory::create_plugin_post( array(
    8383                                'slug' => $plugin_slug,
     
    131131                wp_update_post( $plugin );
    132132                remove_filter( 'wp_insert_post_data', array( $this, 'filter_wp_insert_post_data' ) );
     133
     134                // Set categories if there aren't any yet. wp-admin takes precedent.
     135                if ( ! wp_get_post_terms( $plugin->ID, 'plugin_category', array( 'fields' => 'ids' ) ) ) {
     136                        wp_set_post_terms( $plugin->ID, Tag_To_Category::map( $readme->tags ), 'plugin_category' );
     137                }
    133138
    134139                foreach ( $this->readme_fields as $readme_field ) {
Note: See TracChangeset for help on using the changeset viewer.