Making WordPress.org

Changeset 13192


Ignore:
Timestamp:
02/09/2024 02:19:41 AM (3 years ago)
Author:
dd32
Message:

Plugin Directory: Register plugin_tags and plugin_contributors taxonomies first.

This helps with template routing, as it ensures they're returned by get_queried_object() in preference to other taxonomies.

See #7430.

File:
1 edited

Legend:

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

    r13139 r13192  
    137137        /**
    138138         * Set up the Plugin Directory.
     139         *
     140         * NOTE: The order of the taxonomy register calls defines which one will be
     141         *       returned by get_queried_object() for a multi-taxonomy query.
    139142         */
    140143        public function init() {
     
    220223                ) );
    221224
    222                 register_taxonomy( 'plugin_built_for', 'plugin', array(
    223                         'hierarchical'      => true, /* for tax_input[] handling on post saves. */
    224                         'query_var'         => 'plugin_built_for',
    225                         'rewrite'           => false,
     225                /*
     226                 * Register before other taxonomies.
     227                 * This ensures that it'll be returned by get_queried_object() in a multi-tax query.
     228                 */
     229                register_taxonomy( 'plugin_tags', array( 'plugin', 'force-count-to-include-all-post_status' ), array(
     230                        'hierarchical'      => false,
     231                        'query_var'         => 'plugin_tags',
     232                        'rewrite'           => array(
     233                                'hierarchical' => false,
     234                                'slug'         => 'tags',
     235                                'with_front'   => false,
     236                                'ep_mask'      => EP_TAGS,
     237                        ),
    226238                        'labels'            => array(
    227                                 'name' => __( 'Built For', 'wporg-plugins' ),
     239                                'name'          => __( 'Plugin Tags', 'wporg-plugins' ),
     240                                'singular_name' => __( 'Plugin Tag', 'wporg-plugins' ),
     241                                'edit_item'     => __( 'Edit Tag', 'wporg-plugins' ),
     242                                'update_item'   => __( 'Update Tag', 'wporg-plugins' ),
     243                                'add_new_item'  => __( 'Add New Tag', 'wporg-plugins' ),
     244                                'new_item_name' => __( 'New Tag Name', 'wporg-plugins' ),
     245                                'search_items'  => __( 'Search Tags', 'wporg-plugins' ),
    228246                        ),
    229247                        'public'            => true,
    230                         'show_ui'           => false,
    231                         'show_admin_column' => false,
     248                        'show_ui'           => true,
     249                        'show_admin_column' => true,
    232250                        'meta_box_cb'       => false,
    233251                        'capabilities'      => array(
    234                                 'assign_terms' => 'plugin_set_category',
    235                         ),
    236                 ) );
    237 
    238                 register_taxonomy( 'plugin_business_model', 'plugin', array(
    239                         'hierarchical'      => true, /* for tax_input[] handling on post saves. */
    240                         'query_var'         => 'plugin_business_model',
    241                         'rewrite'           => false,
    242                         'labels'            => array(
    243                                 'name' => __( 'Business Model', 'wporg-plugins' ),
    244                         ),
    245                         'public'            => true,
    246                         'show_ui'           => true,
    247                         'show_admin_column' => false,
    248                         'capabilities'      => array(
    249                                 'assign_terms' => 'plugin_set_category',
    250                         ),
    251                 ) );
    252 
     252                                'assign_terms' => 'do_not_allow',
     253                        ),
     254                ) );
     255
     256                // Next, Contributors as this is the taxonomy used for `/author/xxxxxx/`
    253257                register_taxonomy( 'plugin_contributors', array( 'plugin', 'force-count-to-include-all-post_status' ), array(
    254258                        'hierarchical'      => false,
     
    268272                ) );
    269273
     274                // Meta-data taxonomies can follow, these will always end up being used as query parameters in URLs.
     275                register_taxonomy( 'plugin_built_for', 'plugin', array(
     276                        'hierarchical'      => true, /* for tax_input[] handling on post saves. */
     277                        'query_var'         => 'plugin_built_for',
     278                        'rewrite'           => false,
     279                        'labels'            => array(
     280                                'name' => __( 'Built For', 'wporg-plugins' ),
     281                        ),
     282                        'public'            => true,
     283                        'show_ui'           => false,
     284                        'show_admin_column' => false,
     285                        'meta_box_cb'       => false,
     286                        'capabilities'      => array(
     287                                'assign_terms' => 'plugin_set_category',
     288                        ),
     289                ) );
     290
     291                register_taxonomy( 'plugin_business_model', 'plugin', array(
     292                        'hierarchical'      => true, /* for tax_input[] handling on post saves. */
     293                        'query_var'         => 'plugin_business_model',
     294                        'rewrite'           => false,
     295                        'labels'            => array(
     296                                'name' => __( 'Business Model', 'wporg-plugins' ),
     297                        ),
     298                        'public'            => true,
     299                        'show_ui'           => true,
     300                        'show_admin_column' => false,
     301                        'capabilities'      => array(
     302                                'assign_terms' => 'plugin_set_category',
     303                        ),
     304                ) );
     305
    270306                register_taxonomy( 'plugin_committers', array( 'plugin', 'force-count-to-include-all-post_status' ), array(
    271307                        'hierarchical'      => false,
     
    295331                        'show_ui'           => true,
    296332                        'show_admin_column' => true,
    297                         'capabilities'      => array(
    298                                 'assign_terms' => 'do_not_allow',
    299                         ),
    300                 ) );
    301 
    302                 register_taxonomy( 'plugin_tags', array( 'plugin', 'force-count-to-include-all-post_status' ), array(
    303                         'hierarchical'      => false,
    304                         'query_var'         => 'plugin_tags',
    305                         'rewrite'           => array(
    306                                 'hierarchical' => false,
    307                                 'slug'         => 'tags',
    308                                 'with_front'   => false,
    309                                 'ep_mask'      => EP_TAGS,
    310                         ),
    311                         'labels'            => array(
    312                                 'name'          => __( 'Plugin Tags', 'wporg-plugins' ),
    313                                 'singular_name' => __( 'Plugin Tag', 'wporg-plugins' ),
    314                                 'edit_item'     => __( 'Edit Tag', 'wporg-plugins' ),
    315                                 'update_item'   => __( 'Update Tag', 'wporg-plugins' ),
    316                                 'add_new_item'  => __( 'Add New Tag', 'wporg-plugins' ),
    317                                 'new_item_name' => __( 'New Tag Name', 'wporg-plugins' ),
    318                                 'search_items'  => __( 'Search Tags', 'wporg-plugins' ),
    319                         ),
    320                         'public'            => true,
    321                         'show_ui'           => true,
    322                         'show_admin_column' => true,
    323                         'meta_box_cb'       => false,
    324333                        'capabilities'      => array(
    325334                                'assign_terms' => 'do_not_allow',
Note: See TracChangeset for help on using the changeset viewer.