Ticket #6387: taxonomies-ui.r10210.patch
File taxonomies-ui.r10210.patch, 20.0 KB (added by , 16 years ago) |
---|
-
wp-includes/taxonomy.php
17 17 * @global array $wp_taxonomies 18 18 */ 19 19 $wp_taxonomies = array(); 20 $wp_taxonomies['category'] = (object) array('name' => 'category', 'object_type' => 'post', 'hierarchical' => true, 'update_count_callback' => '_update_post_term_count' );21 $wp_taxonomies['post_tag'] = (object) array('name' => 'post_tag', 'object_type' => 'post', 'hierarchical' => false, 'update_count_callback' => '_update_post_term_count' );20 $wp_taxonomies['category'] = (object) array('name' => 'category', 'object_type' => 'post', 'hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Categories')); 21 $wp_taxonomies['post_tag'] = (object) array('name' => 'post_tag', 'object_type' => 'post', 'hierarchical' => false, 'update_count_callback' => '_update_post_term_count', 'label' => __('Tags')); 22 22 $wp_taxonomies['link_category'] = (object) array('name' => 'link_category', 'object_type' => 'link', 'hierarchical' => false); 23 23 24 24 /** -
wp-includes/post.php
1493 1493 } 1494 1494 1495 1495 wp_set_post_categories( $post_ID, $post_category ); 1496 wp_set_post_tags( $post_ID, $tags_input ); 1496 // old-style tags_input 1497 if ( !empty($tags_input) ) 1498 wp_set_post_tags( $post_ID, $tags_input ); 1499 // new-style support for all tag-like taxonomies 1500 if ( !empty($tax_input) ) { 1501 foreach ( $tax_input as $taxonomy => $tags ) { 1502 wp_set_post_tax( $post_ID, $taxonomy, $tags ); 1503 } 1504 } 1497 1505 1498 1506 $current_guid = get_post_field( 'guid', $post_ID ); 1499 1507 … … 1680 1688 * @return bool|null Will return false if $post_id is not an integer or is 0. Will return null otherwise 1681 1689 */ 1682 1690 function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) { 1691 return wp_set_post_tax( $post_id, 'post_tag', $tags, $append); 1692 } 1683 1693 1694 function wp_set_post_tax( $post_id = 0, $taxonomy='post_tag', $tags = '', $append = false ) { 1684 1695 $post_id = (int) $post_id; 1685 1696 1686 1697 if ( !$post_id ) … … 1689 1700 if ( empty($tags) ) 1690 1701 $tags = array(); 1691 1702 $tags = (is_array($tags)) ? $tags : explode( ',', trim($tags, " \n\t\r\0\x0B,") ); 1692 wp_set_object_terms($post_id, $tags, 'post_tag', $append);1703 wp_set_object_terms($post_id, $tags, $taxonomy, $append); 1693 1704 } 1694 1705 1695 1706 /** -
wp-includes/js/autosave.js
130 130 post_ID: jQuery("#post_ID").val() || 0, 131 131 post_title: jQuery("#title").val() || "", 132 132 autosavenonce: jQuery('#autosavenonce').val(), 133 tags_input: jQuery("#tags-input").val() || "",133 //tags_input: jQuery("#tags-input").val() || "", 134 134 post_type: jQuery('#post_type').val() || "", 135 135 autosave: 1 136 136 }; 137 138 jQuery('.tags-input').each( function() { 139 post_data[this.name] = this.value; 140 } ); 137 141 138 142 // We always send the ajax request in order to keep the post lock fresh. 139 143 // This (bool) tells whether or not to write the post to the DB during the ajax request. -
wp-content/themes/default/functions.php
4 4 * @subpackage Default_Theme 5 5 */ 6 6 7 // FIXME: testing only, to be removed 8 //function add_test_taxonomies_alex() { 9 //register_taxonomy( 10 //'people', 11 //array('attachment:image', 'attachment:video', 'attachment:audio', 'post', 'page'), 12 //array( 13 //'label' => __('People'), 14 //'template' => __('People: %l.'), 15 //'helps' => __('Separate people with commas.'), 16 //'sort' => true, 17 //'args' => array('orderby' => 'term_order'), 18 //'rewrite' => array('slug' => 'person'), 19 //) 20 //); 21 // register_taxonomy( 'post_place', 'post' ); 22 //} 23 24 //add_action('init', 'add_test_taxonomies_alex'); 25 26 7 27 if ( function_exists('register_sidebar') ) 8 28 register_sidebar(array( 9 29 'before_widget' => '<li id="%1$s" class="widget %2$s">', -
wp-admin/admin-ajax.php
776 776 global $current_user; 777 777 778 778 $_POST['post_category'] = explode(",", $_POST['catslist']); 779 $_POST['tags_input'] = explode(",", $_POST['tags_input']);780 779 if($_POST['post_type'] == 'page' || empty($_POST['post_category'])) 781 780 unset($_POST['post_category']); 782 781 -
wp-admin/wp-admin.css
1355 1355 display: none; 1356 1356 } 1357 1357 1358 #post-body #tagsdiv #newtag {1358 #post-body .tagsdiv #newtag { 1359 1359 margin-right: 5px; 1360 1360 width: 16em; 1361 1361 } … … 1364 1364 width: 94% 1365 1365 } 1366 1366 1367 #side-info-column #tagsdiv #newtag {1367 #side-info-column .tagsdiv #newtag { 1368 1368 width: 68%; 1369 1369 } 1370 1370 … … 1421 1421 padding: 5px 0; 1422 1422 } 1423 1423 1424 #tagchecklist {1424 .tagchecklist { 1425 1425 margin-left: 10px; 1426 1426 font-size: 12px; 1427 1427 overflow: auto; 1428 1428 } 1429 1429 1430 #tagchecklist strong {1430 .tagchecklist strong { 1431 1431 margin-left: -8px; 1432 1432 position: absolute; 1433 1433 } 1434 1434 1435 #tagchecklist span {1435 .tagchecklist span { 1436 1436 margin-right: 25px; 1437 1437 display: block; 1438 1438 float: left; … … 1442 1442 cursor: default; 1443 1443 } 1444 1444 1445 #tagchecklist span a {1445 .tagchecklist span a { 1446 1446 margin: 6px 0pt 0pt -9px; 1447 1447 cursor: pointer; 1448 1448 width: 10px; … … 2830 2830 margin-top: 8px; 2831 2831 } 2832 2832 2833 #tagsdiv #the-tagcloud {2833 .tagsdiv #the-tagcloud { 2834 2834 margin: 5px 5px 10px; 2835 2835 padding: 8px; 2836 2836 border-width: 1px; -
wp-admin/includes/taxonomy.php
239 239 return wp_insert_term($tag_name, 'post_tag'); 240 240 } 241 241 242 // 243 // Other 244 // 245 246 // equivalent to get_tags_to_edit(), but for any tag-like taxonomy 247 function get_tax_to_edit( $post_id, $taxonomy ) { 248 $post_id = (int) $post_id; 249 if ( !$post_id ) 250 return false; 251 252 $tags = wp_get_object_terms( $post_id, $taxonomy, array('fields'=>'names') ); 253 if ( !$tags ) 254 return false; 255 256 $tags_to_edit = join( ', ', $tags ); 257 $tags_to_edit = attribute_escape( $tags_to_edit ); 258 $tags_to_edit = apply_filters( 'tax_to_edit', $tags_to_edit, $taxonomy ); 259 return $tags_to_edit; 260 } 261 242 262 ?> -
wp-admin/includes/template.php
2695 2695 * @param string $context The context within the page where the boxes should show ('normal', 'advanced'). 2696 2696 * @param string $priority The priority within the context where the boxes should show ('high', 'low'). 2697 2697 */ 2698 function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default' ) {2698 function add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args=null) { 2699 2699 global $wp_meta_boxes; 2700 2700 2701 2701 if ( !isset($wp_meta_boxes) ) … … 2742 2742 if ( !isset($wp_meta_boxes[$page][$context][$priority]) ) 2743 2743 $wp_meta_boxes[$page][$context][$priority] = array(); 2744 2744 2745 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback );2745 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args); 2746 2746 } 2747 2747 2748 2748 /** -
wp-admin/js/post.js
1 1 // this file contains all the scripts used in the post/edit page 2 2 3 // return an array with any duplicate, whitespace or values removed 4 function array_unique_noempty(a) { 5 out = []; 6 jQuery.each( a, function( key, val ) { 7 val.replace( /^\s+/, '' ).replace( /\s+$/, '' ); // trim 8 if ( val && !val.match(/\s+$/) && jQuery.inArray(val, out) == -1 ) 9 out.push(val); 10 } ); 11 return out; 12 } 13 3 14 function new_tag_remove_tag() { 4 15 var id = jQuery( this ).attr( 'id' ); 5 var num = id.substr( 10 ); 6 var current_tags = jQuery( '#tags-input' ).val().split(','); 16 var num = id.split('-check-num-')[1]; 17 var taxbox = jQuery(this).parents('.tagsdiv'); 18 var current_tags = taxbox.find( '.tags-input' ).val().split(','); 7 19 delete current_tags[num]; 8 20 var new_tags = []; 9 21 jQuery.each( current_tags, function( key, val ) { … … 11 23 new_tags = new_tags.concat( val ); 12 24 } 13 25 }); 14 jQuery( '#tags-input' ).val( new_tags.join( ',' ).replace( /\s*,+\s*/, ',' ).replace( /,+/, ',' ).replace( /,+\s+,+/, ',' ).replace( /,+\s*$/, '' ).replace( /^\s*,+/, '' ) );26 taxbox.find( '.tags-input' ).val( new_tags.join( ',' ).replace( /\s*,+\s*/, ',' ).replace( /,+/, ',' ).replace( /,+\s+,+/, ',' ).replace( /,+\s*$/, '' ).replace( /^\s*,+/, '' ) ); 15 27 tag_update_quickclicks(); 16 jQuery('#newtag').focus();28 taxbox.find('input.newtag').focus(); 17 29 return false; 18 30 } 19 31 20 function tag_update_quickclicks( ) {21 if ( jQuery( '#tags-input' ).length == 0 )32 function tag_update_quickclicks(taxbox) { 33 if ( jQuery(taxbox).find('.tags-input').length == 0 ) 22 34 return; 23 var current_tags = jQuery( '#tags-input').val().split(',');24 jQuery( '#tagchecklist' ).empty();35 var current_tags = jQuery(taxbox).find('.tags-input').val().split(','); 36 jQuery(taxbox).find( '.tagchecklist' ).empty(); 25 37 shown = false; 26 38 // jQuery.merge( current_tags, current_tags ); // this doesn't work anymore, need something to array_unique 27 39 jQuery.each( current_tags, function( key, val ) { 28 40 val = val.replace( /^\s+/, '' ).replace( /\s+$/, '' ); // trim 29 41 if ( !val.match(/^\s+$/) && '' != val ) { 30 txt = '<span><a id="tag-check-' + key + '" class="ntdelbutton">X</a> ' + val + '</span> ';31 jQuery( '#tagchecklist' ).append( txt ); 32 jQuery( '#tag-check-' + key ).click( new_tag_remove_tag ); 33 shown = true; 42 var button_id = jQuery(taxbox).attr('id') + '-check-num-' + key; 43 txt = '<span><a id="' + button_id + '" class="ntdelbutton">X</a> ' + val + '</span> '; 44 jQuery(taxbox).find( '.tagchecklist' ).append( txt ); 45 jQuery( '#' + button_id ).click( new_tag_remove_tag ); 34 46 } 35 47 }); 36 48 if ( shown ) 37 jQuery( '#tagchecklist' ).prepend( '<strong>'+postL10n.tagsUsed+'</strong><br />' );49 jQuery(taxbox).find( '.tagchecklist' ).prepend( '<strong>'+postL10n.tagsUsed+'</strong><br />' ); 38 50 } 39 51 40 52 function tag_flush_to_text(e,a) { 41 53 a = a || false; 42 54 var text = a ? jQuery(a).text() : jQuery('#newtag').val(); 43 var newtags = jQuery('#tags-input').val(); 44 45 var t = text.replace( /\s*([^,]+).*/, '$1,' ); 46 newtags += ',' 47 48 if ( newtags.indexOf(t) != -1 ) 55 taxbox = jQuery(e.target).parents('.tagsdiv'); 56 // is the input box empty (i.e. showing the 'Add new tag' tip)? 57 if ( taxbox.find('input.newtag').hasClass('form-input-tip') ) 49 58 return false; 50 51 newtags += text; 52 59 var newtags = taxbox.find('.tags-input').val() + ',' + taxbox.find('input.newtag').val(); 53 60 // massage 54 61 newtags = newtags.replace( /\s+,+\s*/g, ',' ).replace( /,+/g, ',' ).replace( /,+\s+,+/g, ',' ).replace( /,+\s*$/g, '' ).replace( /^\s*,+/g, '' ); 55 jQuery('#tags-input').val( newtags ); 56 tag_update_quickclicks(); 57 if ( ! a ) { 58 jQuery('#newtag').val(''); 59 jQuery('#newtag').focus(); 60 } 62 newtags = array_unique_noempty(newtags.split(',')).join(','); 63 taxbox.find('.tags-input').val( newtags ); 64 tag_update_quickclicks(taxbox); 65 taxbox.find('input.newtag').val(''); 66 taxbox.find('input.newtag').focus(); 61 67 return false; 62 68 } 63 69 64 70 function tag_save_on_publish() { 65 if ( jQuery('#newtag').val() != postL10n.addTag ) 66 tag_flush_to_text(); 71 jQuery('.tagsdiv').each( function(i) { 72 if ( !jQuery(this).find('input.newtag').hasClass('form-input-tip') ) 73 tag_flush_to_text(this); 74 } ); 67 75 } 68 76 69 77 function tag_press_key( e ) { 70 if ( 13 == e.keyCode ) { 71 tag_flush_to_text(); 78 keycode = e.which; 79 if ( 13 == e.which ) { 80 tag_flush_to_text(e); 72 81 return false; 73 82 } 74 83 }; 84 function tag_init() { 85 jQuery('.ajaxtag').show(); 86 jQuery('.tagsdiv').each( function(i) { 87 tag_update_quickclicks(this); 88 } ); 89 90 // add the quickadd form 91 jQuery('.ajaxtag input.tagadd').click( tag_flush_to_text ); 92 jQuery('.ajaxtag input.newtag').focus(function() { 93 if ( this.value == postL10n.addTag ) { 94 jQuery(this).val( '' ).removeClass( 'form-input-tip' ); 95 } 96 }); 97 jQuery('.ajaxtag input.newtag').blur(function() { 98 if ( this.value == '' ) { 99 jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' ); 100 } 101 }); 102 103 // auto-save tags on post save/publish 104 jQuery('#publish').click( tag_save_on_publish ); 105 jQuery('#save-post').click( tag_save_on_publish ); 106 107 // catch the enter key 108 jQuery('.ajaxtag input.newtag').keypress( tag_press_key ); 109 } 75 110 76 111 (function($){ 77 112 tagCloud = { … … 107 142 // Editable slugs 108 143 make_slugedit_clickable(); 109 144 110 jQuery('#tags-input').hide(); 111 tag_update_quickclicks(); 112 // add the quickadd form 113 jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" class="form-input-tip" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="button" class="button" id="tagadd" value="' + postL10n.add + '" tabindex="3" /><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>'); 114 jQuery('#tagadd').click( tag_flush_to_text ); 115 jQuery('#newtag').focus(function() { 116 if ( this.value == postL10n.addTag ) 117 jQuery(this).val( '' ).removeClass( 'form-input-tip' ); 118 }); 119 jQuery('#newtag').blur(function() { 120 if ( this.value == '' ) 121 jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' ); 122 }); 145 // prepare the tag UI 146 tag_init(); 123 147 124 // auto-save tags on post save/publish125 jQuery('#publish').click( tag_save_on_publish );126 jQuery('#save-post').click( tag_save_on_publish );127 128 148 jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); 129 149 130 150 // auto-suggest stuff 131 jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } ); 132 jQuery('#newtag').keypress( tag_press_key ); 151 jQuery('.newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } ); 133 152 134 153 // category tabs 135 154 var categoryTabs =jQuery('#category-tabs').tabs(); -
wp-admin/rtl.css
211 211 #normal-sortables .postbox .submit { 212 212 float: left; 213 213 } 214 #post-body #tagsdiv #newtag {214 #post-body .tagsdiv #newtag { 215 215 margin-right: 0; 216 216 margin-left: 5px; 217 217 } … … 221 221 #comment-status-radio input { 222 222 margin: 2px 0 5px 3px; 223 223 } 224 #tagchecklist {224 .tagchecklist { 225 225 margin-left: 0; 226 226 margin-right: 10px; 227 227 } 228 #tagchecklist strong {228 .tagchecklist strong { 229 229 margin-left: 0; 230 230 margin-right: -8px; 231 231 } 232 #tagchecklist span {232 .tagchecklist span { 233 233 float: right; 234 234 } 235 #tagchecklist span a {235 .tagchecklist span a { 236 236 margin: 6px -9px 0 0; 237 237 float: right; 238 238 } -
wp-admin/edit-form-advanced.php
263 263 * 264 264 * @param object $post 265 265 */ 266 function post_tags_meta_box($post) { 266 function post_tags_meta_box($post, $box) { 267 $taxonomy = $box['args']['taxonomy']; 268 $helps = $box['args']['helps']; 267 269 ?> 268 <p id="jaxtag"><label class="hidden" for="newtag"><?php _e('Tags'); ?></label><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" /></p> 269 <div id="tagchecklist"></div> 270 <div class="tagsdiv"> 271 <p class="jaxtag"> 272 <label class="hidden" for="newtag"><?php _e( $box['title'] ); ?></label> 273 <input type="hidden" name="<?php echo "tax_input[$taxonomy]"; ?>" class="tags-input" id="tax-input[<?php echo $taxonomy; ?>]" size="40" tabindex="3" value="<?php echo get_tax_to_edit( $post->ID, $taxonomy ); ?>" /> 274 275 <span class="ajaxtag" style="display:none;"> 276 <input type="text" name="newtag[<?php echo $taxonomy; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" value="<?php _e('Add new tag'); ?>" /> 277 <input type="button" class="button tagadd" value="<?php _e('Add'); ?>" tabindex="3" /> 278 <input type="hidden"/><input type="hidden"/> 279 <span class="howto"><?php echo $helps; ?></span> 280 </span> 281 </p> 282 <div class="tagchecklist"></div> 283 </div> 270 284 <p id="tagcloud-link" class="hide-if-no-js"><a href='#'><?php _e( 'Choose from the most popular tags' ); ?></a></p> 271 285 <?php 272 286 } 273 add_meta_box('tagsdiv', __('Tags'), 'post_tags_meta_box', 'post', 'side', 'core');274 287 288 // all tag-style post taxonomies 289 foreach ( get_object_taxonomies('post') as $_tax ) { 290 if ( !is_taxonomy_hierarchical($_tax) ) { 291 $taxonomy = get_taxonomy($_tax); 292 293 $label = ( isset($taxonomy->label) ? $taxonomy->label : $_tax ); 294 $helps = ( isset($taxonomy->helps) ? $taxonomy->helps : '' ); 295 296 $tags_to_edit = get_tax_to_edit( $post_ID, $_tax ); 297 298 add_meta_box('tagsdiv-'.$_tax, $label, 'post_tags_meta_box', 'post', 'side', 'core', array('taxonomy' => $_tax, 'helps' => $helps ) ); 299 } 300 } 301 275 302 /** 276 303 * Display post categories form fields. 277 304 * -
wp-admin/css/ie-rtl.css
44 44 padding-right: 0; 45 45 padding-left: 1px; 46 46 } 47 #tagchecklist span a {47 .tagchecklist span a { 48 48 margin: 4px -9px 0 0; 49 49 } 50 50 .widefat th input { -
wp-admin/css/ie.css
245 245 li.widget-list-control-item h4, 246 246 .widget-sortable, 247 247 .widget-control-actions, 248 #tagchecklist,248 .tagchecklist, 249 249 #col-container, 250 250 #col-left, 251 251 #col-right { … … 296 296 padding-right: 1px; 297 297 } 298 298 299 #tagchecklist span, #tagchecklist span a {299 .tagchecklist span, .tagchecklist span a { 300 300 display: inline-block; 301 301 display: block; 302 302 } 303 303 304 #tagchecklist span a {304 .tagchecklist span a { 305 305 margin: 4px 0 0 -9px; 306 306 } 307 307 -
wp-admin/css/colors-fresh.css
682 682 color: #448abd; 683 683 } 684 684 685 #tagchecklist span a,685 .tagchecklist span a, 686 686 #bulk-titles div a { 687 687 background: url(../images/xit.gif) no-repeat; 688 688 } 689 689 690 #tagchecklist span a:hover,690 .tagchecklist span a:hover, 691 691 #bulk-titles div a:hover { 692 692 background: url(../images/xit.gif) no-repeat -10px 0; 693 693 } … … 1007 1007 1008 1008 #timestampdiv input, 1009 1009 #namediv input, 1010 #tagsdiv #the-tagcloud {1010 .tagsdiv #the-tagcloud { 1011 1011 border-color: #ddd; 1012 1012 } 1013 1013 -
wp-admin/css/colors-classic.css
682 682 color: #448abd; 683 683 } 684 684 685 #tagchecklist span a,685 .tagchecklist span a, 686 686 #bulk-titles div a { 687 687 background: url(../images/xit.gif) no-repeat; 688 688 } 689 689 690 #tagchecklist span a:hover,690 .tagchecklist span a:hover, 691 691 #bulk-titles div a:hover { 692 692 background: url(../images/xit.gif) no-repeat -10px 0; 693 693 } … … 1007 1007 1008 1008 #timestampdiv input, 1009 1009 #namediv input, 1010 #tagsdiv #the-tagcloud {1010 .tagsdiv #the-tagcloud { 1011 1011 border-color: #ddd; 1012 1012 } 1013 1013