Ticket #14877: 14877.diff
File 14877.diff, 28.6 KB (added by , 13 years ago) |
---|
-
wp-includes/taxonomy.php
43 43 44 44 register_taxonomy( 'category', 'post', array( 45 45 'hierarchical' => true, 46 'query_var' => 'category_name', 47 'rewrite' => $rewrite['category'], 48 'public' => true, 49 'show_ui' => true, 50 '_builtin' => true, 46 'query_var' => 'category_name', 47 'rewrite' => $rewrite['category'], 48 'public' => true, 49 'show_ui' => true, 50 '_builtin' => true, 51 'input' => 'checkbox', 51 52 ) ); 52 53 53 54 register_taxonomy( 'post_tag', 'post', array( 54 'hierarchical' => false, 55 'query_var' => 'tag', 56 'rewrite' => $rewrite['post_tag'], 57 'public' => true, 58 'show_ui' => true, 59 '_builtin' => true, 55 'hierarchical' => false, 56 'query_var' => 'tag', 57 'rewrite' => $rewrite['post_tag'], 58 'public' => true, 59 'show_ui' => true, 60 '_builtin' => true, 61 'input' => 'text', 60 62 ) ); 61 63 62 64 register_taxonomy( 'nav_menu', 'nav_menu_item', array( 63 'public' => false,64 'hierarchical' => false,65 'labels' => array(66 'name' => __( 'Navigation Menus' ),67 'singular_name' => __( 'Navigation Menu' ),65 'public' => false, 66 'hierarchical' => false, 67 'labels' => array( 68 'name' => __( 'Navigation Menus' ), 69 'singular_name' => __( 'Navigation Menu' ), 68 70 ), 69 'query_var' => false,70 'rewrite' => false,71 'show_ui' => false,72 '_builtin' => true,71 'query_var' => false, 72 'rewrite' => false, 73 'show_ui' => false, 74 '_builtin' => true, 73 75 'show_in_nav_menus' => false, 76 'input' => null, 74 77 ) ); 75 78 76 79 register_taxonomy( 'link_category', 'link', array( 77 'hierarchical' => false,78 'labels' => array(79 'name' => __( 'Link Categories' ),80 'singular_name' => __( 'Link Category' ),81 'search_items' => __( 'Search Link Categories' ),82 'popular_items' => null,83 'all_items' => __( 'All Link Categories' ),84 'edit_item' => __( 'Edit Link Category' ),85 'update_item' => __( 'Update Link Category' ),86 'add_new_item' => __( 'Add New Link Category' ),87 'new_item_name' => __( 'New Link Category Name' ),80 'hierarchical' => false, 81 'labels' => array( 82 'name' => __( 'Link Categories' ), 83 'singular_name' => __( 'Link Category' ), 84 'search_items' => __( 'Search Link Categories' ), 85 'popular_items' => null, 86 'all_items' => __( 'All Link Categories' ), 87 'edit_item' => __( 'Edit Link Category' ), 88 'update_item' => __( 'Update Link Category' ), 89 'add_new_item' => __( 'Add New Link Category' ), 90 'new_item_name' => __( 'New Link Category Name' ), 88 91 'separate_items_with_commas' => null, 89 'add_or_remove_items' => null,90 'choose_from_most_used' => null,92 'add_or_remove_items' => null, 93 'choose_from_most_used' => null, 91 94 ), 92 'query_var' => false, 93 'rewrite' => false, 94 'public' => false, 95 'show_ui' => false, 96 '_builtin' => true, 95 'query_var' => false, 96 'rewrite' => false, 97 'public' => false, 98 'show_ui' => false, 99 '_builtin' => true, 100 'input' => null, 97 101 ) ); 98 102 99 103 register_taxonomy( 'post_format', 'post', array( 100 'public' => true,101 'hierarchical' => false,102 'labels' => array(103 'name' => _x( 'Format', 'post format' ),104 'singular_name' => _x( 'Format', 'post format' ),104 'public' => true, 105 'hierarchical' => false, 106 'labels' => array( 107 'name' => _x( 'Format', 'post format' ), 108 'singular_name' => _x( 'Format', 'post format' ), 105 109 ), 106 'query_var' => true,107 'rewrite' => $rewrite['post_format'],108 'show_ui' => false,109 '_builtin' => true,110 'query_var' => true, 111 'rewrite' => $rewrite['post_format'], 112 'show_ui' => false, 113 '_builtin' => true, 110 114 'show_in_nav_menus' => current_theme_supports( 'post-formats' ), 115 'input' => null, 111 116 ) ); 117 112 118 } 119 113 120 add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority 114 121 115 122 /** … … 292 299 * 293 300 * labels - An array of labels for this taxonomy. You can see accepted values in {@link get_taxonomy_labels()}. By default tag labels are used for non-hierarchical types and category labels for hierarchical ones. 294 301 * 302 * input - the type of metabox to display on the post edit screen. Choices include text (tags), checkbox (categories), radio (exclusive), or dropdown (exclusive). Note: exclusive inputs limit the user to selecting only one term. 303 * 295 304 * @package WordPress 296 305 * @subpackage Taxonomy 297 306 * @since 2.3.0 … … 308 317 if ( ! is_array($wp_taxonomies) ) 309 318 $wp_taxonomies = array(); 310 319 311 $defaults = array( 'hierarchical' => false, 320 $defaults = array( 321 'hierarchical' => false, 312 322 'update_count_callback' => '', 313 'rewrite' => true, 314 'query_var' => $taxonomy, 315 'public' => true, 316 'show_ui' => null, 317 'show_tagcloud' => null, 318 '_builtin' => false, 319 'labels' => array(), 320 'capabilities' => array(), 321 'show_in_nav_menus' => null, 323 'rewrite' => true, 324 'query_var' => $taxonomy, 325 'public' => true, 326 'show_ui' => null, 327 'show_tagcloud' => null, 328 '_builtin' => false, 329 'labels' => array(), 330 'capabilities' => array(), 331 'show_in_nav_menus' => null, 332 'input' => 'input', 322 333 ); 334 323 335 $args = wp_parse_args($args, $defaults); 324 336 325 337 if ( false !== $args['query_var'] && !empty($wp) ) { … … 348 360 349 361 if ( is_null($args['show_ui']) ) 350 362 $args['show_ui'] = $args['public']; 363 364 //if no input is specified and UI is not used, set default to null to avoid confusion 365 if ( !$args['show_ui'] && is_null( $args['input'] ) ) 366 $args['input'] = null; 351 367 352 368 // Whether to show this type in nav-menus.php. Defaults to the setting for public. 353 369 if ( null === $args['show_in_nav_menus'] ) … … 1881 1897 $object_ids = array($object_ids); 1882 1898 $object_ids = array_map('intval', $object_ids); 1883 1899 1884 $defaults = array( 'orderby' => 'name', 'order' => 'ASC', 'fields' => 'all');1900 $defaults = array( 'orderby' => 'name', 'order' => 'ASC', 'fields' => 'all' ); 1885 1901 $args = wp_parse_args( $args, $defaults ); 1886 1902 1887 1903 $terms = array(); … … 2146 2162 2147 2163 if ( ! taxonomy_exists($taxonomy) ) 2148 2164 return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy')); 2165 2166 //if this is an exclusive taxonomy, and users has passed more than 1 term, only accept the first 2167 if ( is_array( $terms ) && in_array( get_taxonomy( $taxonomy )->input, array( 'dropdown', 'radio' ) ) ) 2168 $terms = array_shift( $terms ); 2149 2169 2150 2170 if ( !is_array($terms) ) 2151 2171 $terms = array($terms); -
wp-includes/post.php
2410 2410 * @param bool $wp_error Optional. Allow return of WP_Error on failure. 2411 2411 * @return int|WP_Error The value 0 or WP_Error on failure. The post ID on success. 2412 2412 */ 2413 function wp_insert_post($postarr, $wp_error = false) { 2413 function wp_insert_post($postarr, $wp_error = false) { 2414 2414 global $wpdb, $user_ID; 2415 2415 2416 2416 $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID, … … 2611 2611 if ( !empty($tax_input) ) { 2612 2612 foreach ( $tax_input as $taxonomy => $tags ) { 2613 2613 $taxonomy_obj = get_taxonomy($taxonomy); 2614 if ( is_array($tags) ) // array = hierarchical, string = non-hierarchical. 2614 2615 // array = hierarchical, string = non-hierarchical. 2616 if ( is_array($tags) ) 2615 2617 $tags = array_filter($tags); 2618 2619 //exclusive taxonomies pass IDs rather than slugs, typecast to prevent confusion 2620 if ( $taxonomy_obj->input == 'radio' || $taxonomy_obj->input == 'dropdown' ) 2621 $tags = array( (int) $tags ); 2622 2616 2623 if ( current_user_can($taxonomy_obj->cap->assign_terms) ) 2617 2624 wp_set_post_terms( $post_ID, $tags, $taxonomy ); 2625 2618 2626 } 2619 2627 } 2620 2628 -
wp-admin/includes/template.php
40 40 $name = 'post_category'; 41 41 else 42 42 $name = 'tax_input['.$taxonomy.']'; 43 43 44 //if this is not a radio input, each checkbox should be individually named with []'s 45 if ( $input != 'radio' ) 46 $name .= '[]'; 47 44 48 $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; 45 $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type=" checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';49 $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="'.$input.'" name="'.$name.'" id="in-'.$taxonomy.'-' . $category->term_id . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>'; 46 50 } 47 51 48 52 function end_el( &$output, $category, $depth = 0, $args = array() ) { … … 87 91 'popular_cats' => false, 88 92 'walker' => null, 89 93 'taxonomy' => 'category', 90 'checked_ontop' => true 94 'checked_ontop' => true, 91 95 ); 92 96 extract( wp_parse_args($args, $defaults), EXTR_SKIP ); 93 97 … … 120 124 } else { 121 125 $categories = (array) get_terms($taxonomy, array('get' => 'all')); 122 126 } 127 128 //set input type 129 if ( $tax->input == 'radio' ) 130 $args['input'] = 'radio'; 131 else 132 $args['input'] = 'checkbox'; 123 133 124 134 if ( $checked_ontop ) { 125 135 // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) -
wp-admin/includes/meta-boxes.php
232 232 } 233 233 234 234 /** 235 * Display post format form elements. 236 * 237 * @since 3.1.0 238 * 235 * Renders metabox for a given taxonomy 236 * Taxonomy should be passed via the initial filter as an argument within the box array 237 * @since 3.4 239 238 * @param object $post 239 * @param array $box 240 240 */ 241 function post_format_meta_box( $post, $box ) { 242 if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) : 243 $post_formats = get_theme_support( 'post-formats' ); 241 function post_taxonomy_meta_box( $post, $box ) { 244 242 245 if ( is_array( $post_formats[0] ) ) : 246 $post_format = get_post_format( $post->ID ); 247 if ( !$post_format ) 248 $post_format = '0'; 249 // Add in the current one if it isn't there yet, in case the current theme doesn't support it 250 if ( $post_format && !in_array( $post_format, $post_formats[0] ) ) 251 $post_formats[0][] = $post_format; 252 ?> 253 <div id="post-formats-select"> 254 <input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> <label for="post-format-0"><?php _e('Standard'); ?></label> 255 <?php foreach ( $post_formats[0] as $format ) : ?> 256 <br /><input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $post_format, $format ); ?> /> <label for="post-format-<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label> 257 <?php endforeach; ?><br /> 258 </div> 259 <?php endif; endif; 243 //default to tags if no taxonomy is passed 244 if ( !is_array( $box['args'] ) || !isset( $box['args']['taxonomy'] ) ) 245 $box['args']['taxonomy'] = 'post_tag'; 246 247 $taxonomy = get_taxonomy( $box['args']['taxonomy'] ); 248 249 if ( !$taxonomy ) 250 return; 251 252 //try to call a native function for built-in input types 253 //otherwise, allow users to hook in and fire their own callback 254 if ( function_exists( "_{$taxonomy->input}_taxonomy_meta_box" ) ) 255 call_user_func( "_{$taxonomy->input}_taxonomy_meta_box", $post, $taxonomy ); 256 else 257 do_action( '{$taxonomy->input}_taxonomy_meta_box', $post, $taxonomy ); 258 260 259 } 261 260 262 261 /** 263 * Display post tags form fields. 264 * 265 * @since 2.6.0 266 * 267 * @param object $post 262 * Help function to render text (tag-like) input taxonomy metaboxes 263 * @param object $post the post object 264 * @param object $taxonomy the taxonomy object 265 * @since 3.4 268 266 */ 269 function post_tags_meta_box($post, $box) { 270 $defaults = array('taxonomy' => 'post_tag'); 271 if ( !isset($box['args']) || !is_array($box['args']) ) 272 $args = array(); 273 else 274 $args = $box['args']; 275 extract( wp_parse_args($args, $defaults), EXTR_SKIP ); 276 $tax_name = esc_attr($taxonomy); 277 $taxonomy = get_taxonomy($taxonomy); 267 function _text_taxonomy_meta_box( $post, $taxonomy ) { 268 269 $tax_name = esc_attr( $taxonomy->name ); 278 270 $disabled = !current_user_can($taxonomy->cap->assign_terms) ? 'disabled="disabled"' : ''; 279 271 $comma = _x( ',', 'tag delimiter' ); 272 280 273 ?> 281 274 <div class="tagsdiv" id="<?php echo $tax_name; ?>"> 282 275 <div class="jaxtag"> … … 295 288 </div> 296 289 <div class="tagchecklist"></div> 297 290 </div> 298 <?php if ( current_user_can( $taxonomy->cap->assign_terms) ) : ?>291 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?> 299 292 <p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->choose_from_most_used; ?></a></p> 300 <?php endif; ?> 301 <?php 293 <?php endif; 302 294 } 303 295 304 296 /** 305 * Display post categories form fields. 306 * 307 * @since 2.6.0 308 * 309 * @param object $post 297 * Helper function to create checkbox (category) input metaboxes 298 * @param object $post the post object 299 * @param object $taxonomy the taxonomy object 300 * @since 3.4 310 301 */ 311 function post_categories_meta_box( $post, $box ) { 312 $defaults = array('taxonomy' => 'category'); 313 if ( !isset($box['args']) || !is_array($box['args']) ) 314 $args = array(); 315 else 316 $args = $box['args']; 317 extract( wp_parse_args($args, $defaults), EXTR_SKIP ); 318 $tax = get_taxonomy($taxonomy); 319 320 ?> 321 <div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv"> 322 <ul id="<?php echo $taxonomy; ?>-tabs" class="category-tabs"> 323 <li class="tabs"><a href="#<?php echo $taxonomy; ?>-all" tabindex="3"><?php echo $tax->labels->all_items; ?></a></li> 324 <li class="hide-if-no-js"><a href="#<?php echo $taxonomy; ?>-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li> 302 function _checkbox_taxonomy_meta_box( $post, $taxonomy ) { 303 ?> 304 <div id="taxonomy-<?php echo $taxonomy->name; ?>" class="categorydiv"> 305 <ul id="<?php echo $taxonomy->name; ?>-tabs" class="category-tabs"> 306 <li class="tabs"><a href="#<?php echo $taxonomy->name; ?>-all" tabindex="3"><?php echo $taxonomy->labels->all_items; ?></a></li> 307 <li class="hide-if-no-js"><a href="#<?php echo $taxonomy->name; ?>-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li> 325 308 </ul> 326 309 327 <div id="<?php echo $taxonomy ; ?>-pop" class="tabs-panel" style="display: none;">328 <ul id="<?php echo $taxonomy ; ?>checklist-pop" class="categorychecklist form-no-clear" >329 <?php $popular_ids = wp_popular_terms_checklist( $taxonomy); ?>310 <div id="<?php echo $taxonomy->name; ?>-pop" class="tabs-panel" style="display: none;"> 311 <ul id="<?php echo $taxonomy->name; ?>checklist-pop" class="categorychecklist form-no-clear" > 312 <?php $popular_ids = wp_popular_terms_checklist( $taxonomy->name ); ?> 330 313 </ul> 331 314 </div> 332 315 333 <div id="<?php echo $taxonomy ; ?>-all" class="tabs-panel">334 335 $name = ( $taxonomy == 'category' ) ? 'post_category' : 'tax_input[' . $taxonomy. ']';316 <div id="<?php echo $taxonomy->name; ?>-all" class="tabs-panel"> 317 <?php 318 $name = ( $taxonomy->name == 'category' ) ? 'post_category' : 'tax_input[' . $taxonomy->name . ']'; 336 319 echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. 337 320 ?> 338 <ul id="<?php echo $taxonomy ; ?>checklist" class="list:<?php echo $taxonomy?> categorychecklist form-no-clear">339 <?php wp_terms_checklist($post->ID, array( 'taxonomy' => $taxonomy , 'popular_cats' => $popular_ids ) ) ?>321 <ul id="<?php echo $taxonomy->name; ?>checklist" class="list:<?php echo $taxonomy->name?> categorychecklist form-no-clear"> 322 <?php wp_terms_checklist($post->ID, array( 'taxonomy' => $taxonomy->name, 'popular_cats' => $popular_ids ) ) ?> 340 323 </ul> 341 324 </div> 342 <?php if ( current_user_can($tax->cap->edit_terms) ) : ?>343 <div id="<?php echo $taxonomy ; ?>-adder" class="wp-hidden-children">325 <?php if ( current_user_can($taxonomy->cap->edit_terms) ) : ?> 326 <div id="<?php echo $taxonomy->name; ?>-adder" class="wp-hidden-children"> 344 327 <h4> 345 <a id="<?php echo $taxonomy ; ?>-add-toggle" href="#<?php echo $taxonomy; ?>-add" class="hide-if-no-js" tabindex="3">328 <a id="<?php echo $taxonomy->name; ?>-add-toggle" href="#<?php echo $taxonomy->name; ?>-add" class="hide-if-no-js" tabindex="3"> 346 329 <?php 347 330 /* translators: %s: add new taxonomy label */ 348 printf( __( '+ %s' ), $tax ->labels->add_new_item );331 printf( __( '+ %s' ), $taxonomy->labels->add_new_item ); 349 332 ?> 350 333 </a> 351 334 </h4> 352 <p id="<?php echo $taxonomy ; ?>-add" class="category-add wp-hidden-child">353 <label class="screen-reader-text" for="new<?php echo $taxonomy ; ?>"><?php echo $tax->labels->add_new_item; ?></label>354 <input type="text" name="new<?php echo $taxonomy ; ?>" id="new<?php echo $taxonomy; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( $tax->labels->new_item_name ); ?>" tabindex="3" aria-required="true"/>355 <label class="screen-reader-text" for="new<?php echo $taxonomy ; ?>_parent">356 <?php echo $tax ->labels->parent_item_colon; ?>335 <p id="<?php echo $taxonomy->name; ?>-add" class="category-add wp-hidden-child"> 336 <label class="screen-reader-text" for="new<?php echo $taxonomy->name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label> 337 <input type="text" name="new<?php echo $taxonomy->name; ?>" id="new<?php echo $taxonomy->name; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( $taxonomy->labels->new_item_name ); ?>" tabindex="3" aria-required="true"/> 338 <label class="screen-reader-text" for="new<?php echo $taxonomy->name; ?>_parent"> 339 <?php echo $taxonomy->name->labels->parent_item_colon; ?> 357 340 </label> 358 <?php wp_dropdown_categories( array( 'taxonomy' => $taxonomy , 'hide_empty' => 0, 'name' => 'new'.$taxonomy.'_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $tax->labels->parent_item . ' —', 'tab_index' => 3 ) ); ?>359 <input type="button" id="<?php echo $taxonomy ; ?>-add-submit" class="add:<?php echo $taxonomy ?>checklist:<?php echo $taxonomy ?>-add button category-add-sumbit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" tabindex="3" />360 <?php wp_nonce_field( 'add-'.$taxonomy , '_ajax_nonce-add-'.$taxonomy, false ); ?>361 <span id="<?php echo $taxonomy ; ?>-ajax-response"></span>341 <?php wp_dropdown_categories( array( 'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', 'tab_index' => 3 ) ); ?> 342 <input type="button" id="<?php echo $taxonomy->name; ?>-add-submit" class="add:<?php echo $taxonomy->name ?>checklist:<?php echo $taxonomy->name ?>-add button category-add-sumbit" value="<?php echo esc_attr( $taxonomy->labels->add_new_item ); ?>" tabindex="3" /> 343 <?php wp_nonce_field( 'add-'.$taxonomy->name, '_ajax_nonce-add-'.$taxonomy->name, false ); ?> 344 <span id="<?php echo $taxonomy->name; ?>-ajax-response"></span> 362 345 </p> 363 346 </div> 364 347 <?php endif; ?> 365 348 </div> 366 349 <?php 367 350 } 368 351 369 352 /** 353 * Helper function to create radio (exclusive) input taxonomy metaboxes 354 * @param object $post the post object 355 * @param object $taxonomy the taxonomy object 356 * @since 3.4 357 */ 358 function _radio_taxonomy_meta_box( $post, $taxonomy ) { 359 360 $selected = wp_get_post_terms( $post->ID, $taxonomy->name ); 361 if ( $selected ) 362 $selected = array( $selected[0]->ID ); 363 364 ?> 365 <div id="taxonomy-<?php echo $taxonomy->name; ?>" class="categorydiv"> 366 <ul id="<?php echo $taxonomy->name; ?>checklist" class="list:<?php echo $taxonomy->name?> categorychecklist form-no-clear"> 367 <li id='<?php echo $taxonomy->name; ?>-none'><label class="selectit"><input value="" type="radio" name="tax_input[radio]" id="in-radio-none" <?php checked( !$selected ); ?> /> <?php _e( 'None' ); ?></label></li> 368 <?php 369 370 wp_terms_checklist( $post->ID, array( 371 'taxonomy' => $taxonomy->name, 372 'popular_cats' => $selected, 373 ) ); 374 375 ?> 376 </ul> 377 <?php if ( current_user_can($taxonomy->cap->edit_terms) ) : ?> 378 <div id="<?php echo $taxonomy->name; ?>-adder" class="wp-hidden-children"> 379 <h4> 380 <a id="<?php echo $taxonomy->name; ?>-add-toggle" href="#<?php echo $taxonomy->name; ?>-add" class="hide-if-no-js" tabindex="3"> 381 <?php 382 /* translators: %s: add new taxonomy label */ 383 printf( __( '+ %s' ), $taxonomy->labels->add_new_item ); 384 ?> 385 </a> 386 </h4> 387 <p id="<?php echo $taxonomy->name; ?>-add" class="category-add wp-hidden-child"> 388 <label class="screen-reader-text" for="new<?php echo $taxonomy->name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label> 389 <input type="text" name="new<?php echo $taxonomy->name; ?>" id="new<?php echo $taxonomy->name; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( $taxonomy->labels->new_item_name ); ?>" tabindex="3" aria-required="true"/> 390 <label class="screen-reader-text" for="new<?php echo $taxonomy->name; ?>_parent"> 391 <?php echo $taxonomy->name->labels->parent_item_colon; ?> 392 </label> 393 <?php wp_dropdown_categories( array( 'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', 'tab_index' => 3 ) ); ?> 394 <input type="button" id="<?php echo $taxonomy->name; ?>-add-submit" class="add:<?php echo $taxonomy->name ?>checklist:<?php echo $taxonomy->name ?>-add button category-add-sumbit" value="<?php echo esc_attr( $taxonomy->labels->add_new_item ); ?>" tabindex="3" /> 395 <?php wp_nonce_field( 'add-'.$taxonomy->name, '_ajax_nonce-add-'.$taxonomy->name, false ); ?> 396 <span id="<?php echo $taxonomy->name; ?>-ajax-response"></span> 397 </p> 398 </div> 399 <?php endif; ?> 400 </div> 401 <?php 402 403 } 404 405 /** 406 * Helper function to create dropdown (exclusive) input taxonomy metaboxes 407 * @param object $post the post object 408 * @param object $taxonomy the taxonomy object 409 * @since 3.4 410 */ 411 function _dropdown_taxonomy_meta_box( $post, $taxonomy ) { 412 ?> 413 <div id="taxonomy-<?php echo $taxonomy->name; ?>" class="categorydiv"> 414 <?php 415 416 $selected = wp_get_post_terms( $post->ID, $taxonomy->name ); 417 if ( $selected ) 418 $selected = $selected[0]->term_id; 419 420 wp_dropdown_categories( array( 421 'taxonomy' => $taxonomy->name, 422 'show_option_none' => ' ', 423 'orderby' => 'slug', 424 'selected' => $selected, 425 'hierarchical' => $taxonomy->hierarchical, 426 'hide_empty' => false, 427 'name' => "tax_input[{$taxonomy->name}]", 428 ) ); 429 430 if ( current_user_can($taxonomy->cap->edit_terms) ) : 431 ?> 432 <div id="<?php echo $taxonomy->name; ?>-adder" class="wp-hidden-children"> 433 <h4> 434 <a id="<?php echo $taxonomy->name; ?>-add-toggle" href="#<?php echo $taxonomy->name; ?>-add" class="hide-if-no-js" tabindex="3"> 435 <?php 436 /* translators: %s: add new taxonomy label */ 437 printf( __( '+ %s' ), $taxonomy->labels->add_new_item ); 438 ?> 439 </a> 440 </h4> 441 <p id="<?php echo $taxonomy->name; ?>-add" class="category-add wp-hidden-child"> 442 <label class="screen-reader-text" for="new<?php echo $taxonomy->name; ?>"><?php echo $taxonomy->labels->add_new_item; ?></label> 443 <input type="text" name="new<?php echo $taxonomy->name; ?>" id="new<?php echo $taxonomy->name; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( $taxonomy->labels->new_item_name ); ?>" tabindex="3" aria-required="true"/> 444 <label class="screen-reader-text" for="new<?php echo $taxonomy->name; ?>_parent"> 445 <?php echo $taxonomy->name->labels->parent_item_colon; ?> 446 </label> 447 <?php wp_dropdown_categories( array( 'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', 'tab_index' => 3 ) ); ?> 448 <input type="button" id="<?php echo $taxonomy->name; ?>-add-submit" class="add:<?php echo $taxonomy->name ?>checklist:<?php echo $taxonomy->name ?>-add button category-add-sumbit" value="<?php echo esc_attr( $taxonomy->labels->add_new_item ); ?>" tabindex="3" /> 449 <?php wp_nonce_field( 'add-'.$taxonomy->name, '_ajax_nonce-add-'.$taxonomy->name, false ); ?> 450 <span id="<?php echo $taxonomy->name; ?>-ajax-response"></span> 451 </p> 452 </div> 453 <?php endif; ?> 454 </div> 455 <?php 456 } 457 458 /** 459 * Display post format form elements. 460 * 461 * @since 3.1.0 462 * 463 * @param object $post 464 */ 465 function post_format_meta_box( $post, $box ) { 466 467 if ( !current_theme_supports( 'post-formats' ) || !post_type_supports( $post->post_type, 'post-formats' ) ) 468 return; 469 470 $post_formats = get_theme_support( 'post-formats' ); 471 472 if ( !is_array( $post_formats[0] ) ) 473 return; 474 475 $post_format = get_post_format( $post->ID ); 476 477 if ( !$post_format ) 478 $post_format = '0'; 479 // Add in the current one if it isn't there yet, in case the current theme doesn't support it 480 if ( $post_format && !in_array( $post_format, $post_formats[0] ) ) 481 $post_formats[0][] = $post_format; 482 483 ?> 484 <div id="post-formats-select"> 485 <input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> <label for="post-format-0"><?php _e('Standard'); ?></label> 486 <?php foreach ( $post_formats[0] as $format ) : ?> 487 <br /><input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $post_format, $format ); ?> /> <label for="post-format-<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label> 488 <?php endforeach; ?><br /> 489 </div> 490 <?php 491 } 492 493 /** 494 * Display post tags form fields. 495 * 496 * @since 2.6.0 497 * 498 * @param object $post 499 * 500 */ 501 function post_tags_meta_box($post, $box) { 502 503 if ( !isset( $box['args'] ) || !is_array( $box['args'] ) ) 504 $box['args'] = array(); 505 506 $box['args']['taxonomy'] = 'post_tag'; 507 508 _deprecated_function( 'post_tags_meta_box', '3.4', 'post_taxonomy_meta_box' ); 509 post_taxonomy_meta_box( $post, $box ); 510 511 } 512 513 /** 514 * Display post categories form fields. 515 * 516 * @since 2.6.0 517 * 518 * @param object $post 519 */ 520 function post_categories_meta_box( $post, $box ) { 521 522 if ( !isset( $box['args'] ) || !is_array( $box['args'] ) ) 523 $box['args'] = array(); 524 525 $box['args']['taxonomy'] = 'category'; 526 527 _deprecated_function( 'post_categories_meta_box', '3.4', 'post_taxonomy_meta_box' ); 528 post_taxonomy_meta_box( $post, $box ); 529 530 } 531 532 /** 370 533 * Display post excerpt form fields. 371 534 * 372 535 * @since 2.6.0 -
wp-admin/edit-form-advanced.php
109 109 $taxonomy = get_taxonomy($tax_name); 110 110 if ( ! $taxonomy->show_ui ) 111 111 continue; 112 113 $label = $taxonomy->labels->name; 114 115 if ( !is_taxonomy_hierarchical($tax_name) ) 116 add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', null, 'side', 'core', array( 'taxonomy' => $tax_name )); 117 else 118 add_meta_box($tax_name . 'div', $label, 'post_categories_meta_box', null, 'side', 'core', array( 'taxonomy' => $tax_name )); 112 113 add_meta_box( $tax_name . 'div', $taxonomy->labels->name, 'post_taxonomy_meta_box', null, 'side', 'core', array( 'taxonomy' => $tax_name )); 114 119 115 } 120 116 121 117 if ( post_type_supports($post_type, 'page-attributes') )