Ticket #6387: post-taxonomy-ui-r7641-6.patch
File post-taxonomy-ui-r7641-6.patch, 14.1 KB (added by , 17 years ago) |
---|
-
wp-includes/taxonomy.php
2031 2031 return get_object_taxonomies($post); 2032 2032 } 2033 2033 2034 // FIXME: testing only, to be removed 2035 function add_test_taxonomies_alex() { 2036 register_taxonomy( 2037 'people', 2038 array('attachment:image', 'attachment:video', 'attachment:audio', 'post', 'page'), 2039 array( 2040 'label' => __('People'), 2041 'template' => __('People: %l.'), 2042 'helps' => __('Separate people with commas.'), 2043 'sort' => true, 2044 'args' => array('orderby' => 'term_order'), 2045 'rewrite' => array('slug' => 'person'), 2046 ) 2047 ); 2048 register_taxonomy( 'post_place', 'post' ); 2049 } 2050 2051 add_action('init', 'add_test_taxonomies_alex'); 2052 2053 2034 2054 ?> -
wp-includes/post.php
1320 1320 } 1321 1321 1322 1322 wp_set_post_categories( $post_ID, $post_category ); 1323 wp_set_post_tags( $post_ID, $tags_input ); 1323 // old-style tags_input 1324 if ( !empty($tags_input) ) 1325 wp_set_post_tags( $post_ID, $tags_input ); 1326 // new-style support for all tag-like taxonomies 1327 if ( !empty($tax_input) ) { 1328 foreach ( $tax_input as $taxonomy => $tags ) { 1329 wp_set_post_tax( $post_ID, $taxonomy, $tags ); 1330 } 1331 } 1324 1332 1325 1333 $current_guid = get_post_field( 'guid', $post_ID ); 1326 1334 … … 1474 1482 } 1475 1483 1476 1484 function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) { 1485 return wp_set_post_tax( $post_id, 'post_tag', $tags, $append); 1486 } 1487 1488 function wp_set_post_tax( $post_id = 0, $taxonomy='post_tag', $tags = '', $append = false ) { 1477 1489 /* $append - true = don't delete existing tags, just add on, false = replace the tags with the new tags */ 1478 1490 1479 1491 $post_id = (int) $post_id; … … 1484 1496 if ( empty($tags) ) 1485 1497 $tags = array(); 1486 1498 $tags = (is_array($tags)) ? $tags : explode( ',', trim($tags, " \n\t\r\0\x0B,") ); 1487 wp_set_object_terms($post_id, $tags, 'post_tag', $append);1499 wp_set_object_terms($post_id, $tags, $taxonomy, $append); 1488 1500 } 1489 1501 1490 1502 /** -
wp-includes/js/autosave.js
133 133 post_ID: jQuery("#post_ID").val() || 0, 134 134 post_title: jQuery("#title").val() || "", 135 135 autosavenonce: jQuery('#autosavenonce').val(), 136 tags_input: jQuery("#tags-input").val() || "",136 //tags_input: jQuery("#tags-input").val() || "", 137 137 post_type: jQuery('#post_type').val() || "", 138 138 autosave: 1 139 139 }; 140 141 jQuery('.tags-input').each( function() { 142 post_data[this.name] = this.value; 143 } ); 140 144 141 145 // We always send the ajax request in order to keep the post lock fresh. 142 146 // This (bool) tells whether or not to write the post to the DB during the ajax request. -
wp-admin/admin-ajax.php
465 465 466 466 $_POST['post_status'] = 'draft'; 467 467 $_POST['post_category'] = explode(",", $_POST['catslist']); 468 $_POST['tags_input'] = explode(",", $_POST['tags_input']);469 468 if($_POST['post_type'] == 'page' || empty($_POST['post_category'])) 470 469 unset($_POST['post_category']); 471 470 -
wp-admin/wp-admin.css
892 892 893 893 /* Post Screen */ 894 894 895 #tagsdiv #newtag {895 .tagsdiv .newtag { 896 896 margin-right: 5px; 897 897 width: 16em; 898 898 } 899 899 900 #tagchecklist {900 .tagchecklist { 901 901 margin-left: 10px; 902 902 903 903 font-size: 12px; 904 904 overflow: auto; 905 905 } 906 906 907 #tagchecklist strong {907 .tagchecklist strong { 908 908 margin-left: -8px; 909 909 position: absolute; 910 910 } 911 911 912 #tagchecklist span {912 .tagchecklist span { 913 913 margin-right: 25px; 914 914 display: block; 915 915 float: left; … … 919 919 cursor: default; 920 920 } 921 921 922 #tagchecklist span a {922 .tagchecklist span a { 923 923 margin: 6px 0pt 0pt -9px; 924 924 cursor: pointer; 925 925 width: 10px; -
wp-admin/includes/taxonomy.php
150 150 return wp_insert_term($tag_name, 'post_tag'); 151 151 } 152 152 153 // 154 // Other 155 // 156 157 // equivalent to get_tags_to_edit(), but for any tag-like taxonomy 158 function get_tax_to_edit( $post_id, $taxonomy ) { 159 $post_id = (int) $post_id; 160 if ( !$post_id ) 161 return false; 162 163 $tags = wp_get_object_terms( $post_id, $taxonomy, array('fields'=>'names') ); 164 if ( !$tags ) 165 return false; 166 167 $tags_to_edit = join( ', ', $tags ); 168 $tags_to_edit = attribute_escape( $tags_to_edit ); 169 $tags_to_edit = apply_filters( 'tax_to_edit', $tags_to_edit, $taxonomy ); 170 return $tags_to_edit; 171 } 172 153 173 ?> -
wp-admin/js/post.js
2 2 3 3 function new_tag_remove_tag() { 4 4 var id = jQuery( this ).attr( 'id' ); 5 var num = id.substr( 10 ); 6 var current_tags = jQuery( '#tags-input' ).val().split(','); 5 var num = id.split('-check-num-')[1]; 6 var obj = jQuery(this).parents('.tagsdiv'); 7 var current_tags = jQuery(obj).find( '.tags-input' ).val().split(','); 7 8 delete current_tags[num]; 8 9 var new_tags = []; 9 10 jQuery.each( current_tags, function( key, val ) { … … 11 12 new_tags = new_tags.concat( val ); 12 13 } 13 14 }); 14 jQuery( '#tags-input' ).val( new_tags.join( ',' ).replace( /\s*,+\s*/, ',' ).replace( /,+/, ',' ).replace( /,+\s+,+/, ',' ).replace( /,+\s*$/, '' ).replace( /^\s*,+/, '' ) );15 tag_update_quickclicks( );16 jQuery( '#newtag').focus();15 jQuery( obj ).find( '.tags-input' ).val( new_tags.join( ',' ).replace( /\s*,+\s*/, ',' ).replace( /,+/, ',' ).replace( /,+\s+,+/, ',' ).replace( /,+\s*$/, '' ).replace( /^\s*,+/, '' ) ); 16 tag_update_quickclicks(obj); 17 jQuery( obj ).find('input.newtag').focus(); 17 18 return false; 18 19 } 19 20 20 function tag_update_quickclicks( ) {21 var current_tags = jQuery( '#tags-input').val().split(',');22 jQuery( '#tagchecklist' ).empty();21 function tag_update_quickclicks(obj) { 22 var current_tags = jQuery(obj).find('.tags-input').val().split(','); 23 jQuery(obj).find( '.tagchecklist' ).empty(); 23 24 shown = false; 24 25 // jQuery.merge( current_tags, current_tags ); // this doesn't work anymore, need something to array_unique 25 26 jQuery.each( current_tags, function( key, val ) { 26 27 val = val.replace( /^\s+/, '' ).replace( /\s+$/, '' ); // trim 27 28 if ( !val.match(/^\s+$/) && '' != val ) { 28 txt = '<span><a id="tag-check-' + key + '" class="ntdelbutton">X</a> ' + val + '</span> '; 29 jQuery( '#tagchecklist' ).append( txt ); 30 jQuery( '#tag-check-' + key ).click( new_tag_remove_tag ); 29 var button_id = jQuery(obj).attr('id') + '-check-num-' + key; 30 txt = '<span><a id="' + button_id + '" class="ntdelbutton">X</a> ' + val + '</span> '; 31 jQuery(obj).find( '.tagchecklist' ).append( txt ); 32 jQuery( '#' + button_id ).click( new_tag_remove_tag ); 31 33 shown = true; 32 34 } 33 35 }); 34 36 if ( shown ) 35 jQuery( '#tagchecklist' ).prepend( '<strong>'+postL10n.tagsUsed+'</strong><br />' );37 jQuery(obj).find( '.tagchecklist' ).prepend( '<strong>'+postL10n.tagsUsed+'</strong><br />' ); 36 38 } 37 39 38 function tag_flush_to_text() { 39 var newtags = jQuery('#tags-input').val() + ',' + jQuery('#newtag').val(); 40 function tag_flush_to_text(obj) { 41 obj = jQuery(obj).parents('.tagsdiv'); 42 43 var newtags = jQuery(obj).find('.tags-input').val() + ',' + jQuery(obj).find('input.newtag').val(); 40 44 // massage 41 45 newtags = newtags.replace( /\s+,+\s*/g, ',' ).replace( /,+/g, ',' ).replace( /,+\s+,+/g, ',' ).replace( /,+\s*$/g, '' ).replace( /^\s*,+/g, '' ); 42 jQuery( '#tags-input').val( newtags );43 tag_update_quickclicks( );44 jQuery( '#newtag').val('');45 jQuery( '#newtag').focus();46 jQuery(obj).find('.tags-input').val( newtags ); 47 tag_update_quickclicks(obj); 48 jQuery(obj).find('input.newtag').val(''); 49 jQuery(obj).find('input.newtag').focus(); 46 50 return false; 47 51 } 48 52 49 53 function tag_save_on_publish() { 50 if ( jQuery('#newtag').val() != postL10n.addTag ) 51 tag_flush_to_text(); 54 jQuery('.tagsdiv').each( function(i) { 55 if ( jQuery(this).find('input.newtag').val() != postL10n.addTag ) 56 tag_flush_to_text(this); 57 } ); 52 58 } 53 59 54 60 function tag_press_key( e ) { 55 61 if ( 13 == e.keyCode ) { 56 tag_flush_to_text( );62 tag_flush_to_text(e.target); 57 63 return false; 58 64 } 59 65 } 60 66 67 function tag_init() { 68 jQuery('.ajaxtag').show(); 69 jQuery('.tags-input').hide(); 70 jQuery('.tagsdiv').each( function(i) { 71 tag_update_quickclicks(this); 72 } ); 73 74 // add the quickadd form 75 jQuery('.ajaxtag input.tagadd').click( tag_flush_to_text ); 76 jQuery('.ajaxtag input.newtag').focus(function() { 77 if ( this.value == postL10n.addTag ) 78 jQuery(this).val( '' ).removeClass( 'form-input-tip' ); 79 }); 80 jQuery('.ajaxtag input.newtag').blur(function() { 81 if ( this.value == '' ) 82 jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' ); 83 }); 84 85 // auto-save tags on post save/publish 86 jQuery('#publish').click( tag_save_on_publish ); 87 jQuery('#save-post').click( tag_save_on_publish ); 88 89 // catch the enter key 90 jQuery('.ajaxtag input.newtag').keypress( tag_press_key ); 91 92 } 93 94 61 95 jQuery(document).ready( function() { 62 // close postboxes that should be closed 63 jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); 96 // close postboxes that should be closed 97 jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed'); 64 98 65 // show things that should be visible, hide what should be hidden 66 jQuery('.hide-if-no-js').show(); 67 jQuery('.hide-if-js').hide(); 99 // show things that should be visible, hide what should be hidden 100 jQuery('.hide-if-no-js').show(); 101 jQuery('.hide-if-js').hide(); 68 102 69 103 // postboxes 70 104 add_postbox_toggles('post'); … … 74 108 75 109 // hide advanced slug field 76 110 jQuery('#slugdiv').hide(); 111 112 // prepare the tag UI 113 tag_init(); 77 114 78 jQuery('#tags-input').hide();79 tag_update_quickclicks();80 // add the quickadd form81 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>');82 jQuery('#tagadd').click( tag_flush_to_text );83 jQuery('#newtag').focus(function() {84 if ( this.value == postL10n.addTag )85 jQuery(this).val( '' ).removeClass( 'form-input-tip' );86 });87 jQuery('#newtag').blur(function() {88 if ( this.value == '' )89 jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' );90 });91 92 // auto-save tags on post save/publish93 jQuery('#publish').click( tag_save_on_publish );94 jQuery('#save-post').click( tag_save_on_publish );95 96 115 jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); 97 116 98 117 // auto-suggest stuff 99 118 jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2 } ); 100 jQuery('#newtag').keypress( tag_press_key );101 119 102 120 // category tabs 103 121 var categoryTabs =jQuery('#category-tabs').tabs(); -
wp-admin/edit-form-advanced.php
205 205 <?php echo $form_pingback ?> 206 206 <?php echo $form_prevstatus ?> 207 207 208 <div id="tagsdiv" class="postbox <?php echo postbox_classes('tagsdiv', 'post'); ?>"> 209 <h3><?php _e('Tags'); ?></h3> 208 <?php 209 210 // all tag-style post taxonomies 211 foreach ( get_object_taxonomies('post') as $_tax ) { 212 if ( !is_taxonomy_hierarchical($_tax) ) { 213 $taxonomy = get_taxonomy($_tax); 214 215 $label = ( isset($taxonomy->label) ? $taxonomy->label : $_tax ); 216 $helps = ( isset($taxonomy->helps) ? $taxonomy->helps : __('Separate tags with commas') ); 217 218 $tags_to_edit = get_tax_to_edit( $post_ID, $_tax ); 219 220 ?> 221 <div id="tagsdiv-<?php echo $_tax; ?>" class="postbox tagsdiv <?php echo postbox_classes('tagsdiv-'.$_tax, 'post'); ?>"> 222 <h3><?php echo $label; ?></h3> 210 223 <div class="inside"> 211 <p id="jaxtag"><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> 212 <div id="tagchecklist"></div> 224 <p class="jaxtag"><input type="text" name="<?php echo "tax_input[{$_tax}]"; ?>" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo $tags_to_edit; ?>" /> 225 226 <span class="ajaxtag" style="display:none;"><input type="text" name="newtag[]" class="newtag form-input-tip" size="16" autocomplete="off" value="<?php _e('Add new tag'); ?>" /><input type="button" class="button tagadd" value="<?php _e('Add'); ?>" tabindex="3" /><input type="hidden"/><input type="hidden"/><span class="howto"><?php echo $helps; ?></span></span> 227 228 </p> 229 <div class="tagchecklist"></div> 213 230 </div> 214 231 </div> 232 <? 233 } 234 } 215 235 236 ?> 237 216 238 <div id="categorydiv" class="postbox <?php echo postbox_classes('categorydiv', 'post'); ?>"> 217 239 <h3><?php _e('Categories') ?></h3> 218 240 <div class="inside"> -
wp-admin/css/colors-fresh.css
434 434 border-top-color: #e4f2fd; 435 435 } 436 436 437 #tagchecklist span a {437 .tagchecklist span a { 438 438 background: url(../images/xit.gif) no-repeat; 439 439 } 440 440 441 #tagchecklist span a:hover {441 .tagchecklist span a:hover { 442 442 background: url(../images/xit.gif) no-repeat -10px 0; 443 443 } 444 444 -
wp-admin/css/colors-classic.css
466 466 color: #cfebf6; 467 467 } 468 468 469 #tagchecklist span a {469 .tagchecklist span a { 470 470 background: url(../images/xit.gif) no-repeat; 471 471 } 472 472 473 #tagchecklist span a:hover {473 .tagchecklist span a:hover { 474 474 background: url(../images/xit.gif) no-repeat -10px 0; 475 475 } 476 476