Changeset 3225 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
- Timestamp:
- 05/24/2016 04:49:07 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r3221 r3225 24 24 add_action( 'widgets_init', array( $this, 'register_widgets' ) ); 25 25 add_filter( 'post_type_link', array( $this, 'package_link' ), 10, 2 ); 26 add_filter( 'term_link', array( $this, 'term_link' ), 10, 3 ); 26 27 add_filter( 'pre_insert_term', array( $this, 'pre_insert_term_prevent' ) ); 27 28 add_action( 'pre_get_posts', array( $this, 'use_plugins_in_query' ) ); … … 95 96 ) ); 96 97 97 register_taxonomy( 'plugin_ category', 'plugin', array(98 register_taxonomy( 'plugin_section', 'plugin', array( 98 99 'hierarchical' => true, 99 'query_var' => 'plugin_ category',100 'query_var' => 'plugin_section', 100 101 'rewrite' => false, 101 102 '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' ), 104 105 'meta_box_cb' => 'post_categories_meta_box', 105 106 '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( 111 115 'hierarchical' => true, /* for tax_input[] handling on post saves. */ 112 'query_var' => 'plugin_ tag',116 'query_var' => 'plugin_category', 113 117 'rewrite' => array( 114 118 'hierarchical' => false, 115 'slug' => ' tags',119 'slug' => 'category', 116 120 'with_front' => false, 117 121 'ep_mask' => EP_TAGS, 118 122 ), 119 123 '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 TagName', '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' ), 127 131 ), 128 132 'public' => true, 129 133 'show_ui' => true, 130 134 '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' ), 132 136 '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' 134 170 ) 135 171 ) ); … … 231 267 $wp_rewrite->set_permalink_structure( '/%postname%/' ); 232 268 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(); 235 275 236 276 // We require the WordPress.org Ratings plugin also be active. … … 319 359 320 360 /** 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 /** 321 379 * Checks if the current users is a super admin before allowing terms to be added. 322 380 * … … 351 409 switch ( get_query_var( 'browse' ) ) { 352 410 case 'beta': 353 $wp_query->query_vars['plugin_ category'] = 'beta';411 $wp_query->query_vars['plugin_section'] = 'beta'; 354 412 break; 355 413 356 414 case 'featured': 357 $wp_query->query_vars['plugin_ category'] = 'featured';415 $wp_query->query_vars['plugin_section'] = 'featured'; 358 416 break; 359 417
Note: See TracChangeset
for help on using the changeset viewer.