Making WordPress.org

Changeset 3225


Ignore:
Timestamp:
05/24/2016 04:49:07 AM (9 years ago)
Author:
dd32
Message:

Plugin Directory: Rename Tags to Categories and add the extra taxonomies we plan on using.

See #1573

Location:
sites/trunk/wordpress.org/public_html/wp-content
Files:
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-plugin-categories.php

    r3223 r3225  
    33
    44/**
    5  * The Plugin Tags metabox
     5 * The Plugin Categories metabox
    66 *
    77 * @package WordPressdotorg\Plugin_Directory\Admin\Metabox
    88 */
    9 class Plugin_Tags {
     9class Plugin_Categories {
    1010    /**
    11      * Displays the Tags metabox for plugins.
     11     * Displays the categories metabox for plugins.
    1212     * The HTML here matches what Core uses.
    1313     *
     
    1616    static function display( $post ) {
    1717        ?>
    18         <div id="taxonomy-plugin_tag" class="categorydiv">
    19             <div id="plugin_tag-all" class="tabs-panel">
     18        <div id="taxonomy-plugin_category" class="categorydiv">
     19            <div id="plugin_category-all" class="tabs-panel">
    2020                <?php // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. ?>
    21                 <input type='hidden' name='tax_input[plugin_tag][]' value='0' />
    22                 <ul id="plugin_tagchecklist" data-wp-lists="list:plugin_tag" class="categorychecklist form-no-clear">
    23                     <?php wp_terms_checklist( $post->ID, array( 'taxonomy' => 'plugin_tag' ) ); ?>
     21                <input type='hidden' name='tax_input[plugin_category][]' value='0' />
     22                <ul id="plugin_tagchecklist" data-wp-lists="list:plugin_category" class="categorychecklist form-no-clear">
     23                    <?php wp_terms_checklist( $post->ID, array( 'taxonomy' => 'plugin_category' ) ); ?>
    2424                </ul>
    2525            </div>
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-capabilities.php

    r3175 r3225  
    7777            'plugin_dashboard_access' => true,
    7878            'plugin_edit_own' => true,
    79             'plugin_set_tags' => true,
     79            'plugin_set_category' => true,
    8080            'plugin_add_committer' => true,
    8181            'plugin_edit_others' => true,
     
    9393            'plugin_disable' => true,
    9494            'plugin_close' => true,
    95             'plugin_set_category' => true, // Special categories.
     95            'plugin_set_section' => true, // Special categories.
    9696            'manage_categories' => true, // Let them assign these special categories.
    9797        ) );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php

    r3221 r3225  
    2424        add_action( 'widgets_init', array( $this, 'register_widgets' ) );
    2525        add_filter( 'post_type_link', array( $this, 'package_link' ), 10, 2 );
     26        add_filter( 'term_link', array( $this, 'term_link' ), 10, 3 );
    2627        add_filter( 'pre_insert_term', array( $this, 'pre_insert_term_prevent' ) );
    2728        add_action( 'pre_get_posts', array( $this, 'use_plugins_in_query' ) );
     
    9596        ) );
    9697
    97         register_taxonomy( 'plugin_category', 'plugin', array(
     98        register_taxonomy( 'plugin_section', 'plugin', array(
    9899            'hierarchical'      => true,
    99             'query_var'         => 'plugin_category',
     100            'query_var'         => 'plugin_section',
    100101            'rewrite'           => false,
    101102            'public'            => true,
    102             'show_ui'           => current_user_can( 'plugin_set_category' ),
    103             'show_admin_column' => current_user_can( 'plugin_set_category' ),
     103            'show_ui'           => current_user_can( 'plugin_set_section' ),
     104            'show_admin_column' => current_user_can( 'plugin_set_section' ),
    104105            'meta_box_cb'       => 'post_categories_meta_box',
    105106            'capabilities'      => array(
    106                 'assign_terms' => 'manage_categories',
    107             )
    108         ) );
    109 
    110         register_taxonomy( 'plugin_tag', 'plugin', array(
     107                'assign_terms' => 'plugin_set_section',
     108            ),
     109            'labels'            => array(
     110                'name'          => __( 'Plugin Sections',  'wporg-plugins' ),
     111            ),
     112        ) );
     113
     114        register_taxonomy( 'plugin_category', 'plugin', array(
    111115            'hierarchical'      => true, /* for tax_input[] handling on post saves. */
    112             'query_var'         => 'plugin_tag',
     116            'query_var'         => 'plugin_category',
    113117            'rewrite'           => array(
    114118                'hierarchical' => false,
    115                 'slug'         => 'tags',
     119                'slug'         => 'category',
    116120                'with_front'   => false,
    117121                'ep_mask'      => EP_TAGS,
    118122            ),
    119123            'labels'            => array(
    120                 'name'          => __( 'Plugin Tags',  'wporg-plugins' ),
    121                 'singular_name' => __( 'Plugin Tag',   'wporg-plugins' ),
    122                 'edit_item'     => __( 'Edit Tag',     'wporg-plugins' ),
    123                 'update_item'   => __( 'Update Tag',   'wporg-plugins' ),
    124                 'add_new_item'  => __( 'Add New Tag',  'wporg-plugins' ),
    125                 'new_item_name' => __( 'New Tag Name', 'wporg-plugins' ),
    126                 'search_items'  => __( 'Search Tags',  'wporg-plugins' ),
     124                'name'          => __( 'Plugin Categories',  'wporg-plugins' ),
     125                'singular_name' => __( 'Plugin Category',   'wporg-plugins' ),
     126                'edit_item'     => __( 'Edit Category',     'wporg-plugins' ),
     127                'update_item'   => __( 'Update Category',   'wporg-plugins' ),
     128                'add_new_item'  => __( 'Add New Category',  'wporg-plugins' ),
     129                'new_item_name' => __( 'New Category Name', 'wporg-plugins' ),
     130                'search_items'  => __( 'Search Categories',  'wporg-plugins' ),
    127131            ),
    128132            'public'            => true,
    129133            'show_ui'           => true,
    130134            'show_admin_column' => true,
    131             'meta_box_cb'       => array( __NAMESPACE__ . '\Admin\Metabox\Plugin_Tags', 'display' ),
     135            'meta_box_cb'       => array( __NAMESPACE__ . '\Admin\Metabox\Plugin_Categories', 'display' ),
    132136            'capabilities'      => array(
    133                 'assign_terms' => 'plugin_set_tags'
     137                'assign_terms' => 'plugin_set_category'
     138            )
     139        ) );
     140
     141        register_taxonomy( 'plugin_built_for', 'plugin', array(
     142            'hierarchical'      => true, /* for tax_input[] handling on post saves. */
     143            'query_var'         => 'plugin_built_for',
     144            'rewrite'           => false,
     145            'labels'            => array(
     146                'name'          => __( 'Built For',  'wporg-plugins' ),
     147            ),
     148            'public'            => true,
     149            'show_ui'           => true,
     150            'show_admin_column' => false,
     151            //'meta_box_cb'       => array( __NAMESPACE__ . '\Admin\Metabox\Plugin_Categories', 'display' ),
     152            'capabilities'      => array(
     153                'assign_terms' => 'plugin_set_category'
     154            )
     155        ) );
     156
     157        register_taxonomy( 'plugin_business_model', 'plugin', array(
     158            'hierarchical'      => true, /* for tax_input[] handling on post saves. */
     159            'query_var'         => 'plugin_business_model',
     160            'rewrite'           => false,
     161            'labels'            => array(
     162                'name'          => __( 'Business Model',  'wporg-plugins' ),
     163            ),
     164            'public'            => true,
     165            'show_ui'           => true,
     166            'show_admin_column' => false,
     167            //'meta_box_cb'       => array( __NAMESPACE__ . '\Admin\Metabox\Plugin_Categories', 'display' ),
     168            'capabilities'      => array(
     169                'assign_terms' => 'plugin_set_category'
    134170            )
    135171        ) );
     
    231267        $wp_rewrite->set_permalink_structure( '/%postname%/' );
    232268
    233         // /tags/%slug% is required for tags.
    234         $wp_rewrite->set_tag_base( '/tags' );
     269        // /tags/ & /category/ shouldn't conflict
     270        $wp_rewrite->set_tag_base( '/post-tags' );
     271        $wp_rewrite->set_category_base( '/post-categories' );
     272
     273        // Add our custom capabilitie and roles.
     274        Capabilities::add_roles();
    235275
    236276        // We require the WordPress.org Ratings plugin also be active.
     
    319359
    320360    /**
     361     * Filter the permalink for terms to be more useful.
     362     *
     363     * @param string   $termlink The generated term link.
     364     * @param \WP_Term $term     The term the link is for.
     365     * @param string   $taxonomy The taxonomy the term is in.
     366     */
     367    public function term_link( $termlink, $term, $taxonomy ) {
     368        if ( 'plugin_business_model' == $taxonomy ) {
     369            return false;
     370        }
     371        if ( 'plugin_built_for' == $taxonomy ) {
     372            return $this->package_link( false, $this->get_plugin_post( $term->slug ) );
     373        }
     374
     375        return $termlink;
     376    }
     377
     378    /**
    321379     * Checks if the current users is a super admin before allowing terms to be added.
    322380     *
     
    351409        switch ( get_query_var( 'browse' ) ) {
    352410            case 'beta':
    353                 $wp_query->query_vars['plugin_category'] = 'beta';
     411                $wp_query->query_vars['plugin_section'] = 'beta';
    354412                break;
    355413
    356414            case 'featured':
    357                 $wp_query->query_vars['plugin_category'] = 'featured';
     415                $wp_query->query_vars['plugin_section'] = 'featured';
    358416                break;
    359417
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-meta.php

    r3201 r3225  
    4343            <li><?php printf( __( 'Active installs: %s', 'wporg-plugins' ), Template::active_installs( false ) ); ?></li>
    4444            <li><?php printf( __( 'Category: %s', 'wporg-plugins' ), get_the_term_list( get_post()->ID, 'plugin_category', '', ', ' ) ); ?></li>
    45             <li><?php printf( __( 'Designed to work with: %s', 'wporg-plugins' ), get_the_term_list( get_post()->ID, 'plugin_category', '', ', ' ) ); ?></li>
     45            <?php if ( $works_with = get_the_term_list( get_post()->ID, 'plugin_built_for', '', ', ' ) ) : ?>
     46                <li><?php printf( __( 'Designed to work with: %s', 'wporg-plugins' ), $works_with ); ?></li>
     47            <?php endif; ?>
     48            <?php if ( $business_model = get_the_term_list( get_post()->ID, 'plugin_business_model', '', ', ' ) ) : ?>
     49                <li><?php printf( __( 'Business Model: %s', 'wporg-plugins' ), $business_model ); ?></li>
     50            <?php endif; ?>
    4651        </ul>
    4752
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/front-page.php

    r3224 r3225  
    3030                'post_type'       => 'plugin',
    3131                'posts_per_page'  => 4,
    32                 'plugin_category' => $section_slug,
     32                'plugin_section' => $section_slug,
    3333            );
    3434
     
    3636                $section_args['meta_key'] = 'active_installs';
    3737                $section_args['orderby']  = 'meta_value_num';
    38                 unset( $section_args['plugin_category'] );
     38                unset( $section_args['plugin_section'] );
    3939            endif;
    4040
Note: See TracChangeset for help on using the changeset viewer.