Making WordPress.org

Changeset 3578


Ignore:
Timestamp:
06/26/2016 09:58:21 AM (10 years ago)
Author:
dd32
Message:

Plugin Directory: Track plugin tags in a taxonomy.

See #1573

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
2 edited

Legend:

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

    r3569 r3578  
    4242                add_filter( 'post_type_link', array( $this, 'package_link' ), 10, 2 );
    4343                add_filter( 'term_link', array( $this, 'term_link' ), 10, 2 );
    44                 add_filter( 'pre_insert_term', array( $this, 'pre_insert_term_prevent' ) );
     44                add_filter( 'pre_insert_term', array( $this, 'pre_insert_term_prevent' ), 10, 2 );
    4545                add_filter( 'tax_input_pre', array( $this, 'filter_tax_input' ) );
    4646                add_action( 'pre_get_posts', array( $this, 'use_plugins_in_query' ) );
    … …  
    196196                ) );
    197197
     198                register_taxonomy( 'plugin_tags', 'plugin', array(
     199                        'hierarchical'      => false,
     200                        'query_var'         => 'plugin_tags',
     201                        'rewrite'           => array(
     202                                'hierarchical' => false,
     203                                'slug'         => 'tags',
     204                                'with_front'   => false,
     205                                'ep_mask'      => EP_TAGS,
     206                        ),
     207                        'labels'            => array(
     208                                'name'          => __( 'Plugin Tags', 'wporg-plugins' ),
     209                                'singular_name' => __( 'Plugin Tag',   'wporg-plugins' ),
     210                                'edit_item'     => __( 'Edit Tag',     'wporg-plugins' ),
     211                                'update_item'   => __( 'Update Tag',   'wporg-plugins' ),
     212                                'add_new_item'  => __( 'Add New Tag',  'wporg-plugins' ),
     213                                'new_item_name' => __( 'New Tag Name', 'wporg-plugins' ),
     214                                'search_items'  => __( 'Search Tags', 'wporg-plugins' ),
     215                        ),
     216                        'public'            => true,
     217                        'show_ui'           => true,
     218                        'show_admin_column' => false,
     219                        'meta_box_cb'       => false,
     220                        'capabilities'      => array(
     221                                'assign_terms' => 'do_not_allow',
     222                        ),
     223                ) );
     224
    198225                register_post_status( 'pending', array(
    199226                        'label'                     => _x( 'Pending', 'plugin status', 'wporg-plugins' ),
    … …  
    421448         * Checks if the current users is a super admin before allowing terms to be added.
    422449         *
    423          * @param string $term The term to add or update.
     450         * @param string $term     The term to add or update.
     451         * @param string $taxonomy The taxonomy of the term.
    424452         * @return string|\WP_Error The term to add or update or WP_Error on failure.
    425453         */
    426         public function pre_insert_term_prevent( $term ) {
    427                 if ( ! is_super_admin() ) {
     454        public function pre_insert_term_prevent( $term, $taxonomy ) {
     455                if ( 'plugin_tags' != $taxonomy && ! is_super_admin() ) {
    428456                        $term = new \WP_Error( 'not-allowed', __( 'You are not allowed to add terms.', 'wporg-plugins' ) );
    429457                }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php

    r3527 r3578  
    142142                        wp_set_post_terms( $plugin->ID, Tag_To_Category::map( $readme->tags ), 'plugin_category' );
    143143                }
     144
     145                // Set tags from the readme
     146                wp_set_post_terms( $plugin->ID, $readme->tags, 'plugin_tags' );
    144147
    145148                if ( in_array( 'adopt-me', $readme->tags ) ) {
Note: See TracChangeset for help on using the changeset viewer.