Ticket #6387: post-taxonomy-ui-r7493-3.patch
File post-taxonomy-ui-r7493-3.patch, 10.0 KB (added by , 17 years ago) |
---|
-
wp-includes/taxonomy.php
1899 1899 } 1900 1900 } 1901 1901 1902 // FIXME: testing only, to be removed 1903 register_taxonomy( 'post_keyword', 'post' ); 1904 register_taxonomy( 'post_place', 'post' ); 1905 1906 1907 1902 1908 ?> -
wp-includes/post.php
1301 1301 } 1302 1302 1303 1303 wp_set_post_categories( $post_ID, $post_category ); 1304 wp_set_post_tags( $post_ID, $tags_input ); 1304 // old-style tags_input 1305 if ( !empty($tags_input) ) 1306 wp_set_post_tags( $post_ID, $tags_input ); 1307 // new-style support for all tag-like taxonomies 1308 if ( !empty($tax_input) ) { 1309 foreach ( $tax_input as $taxonomy => $tags ) { 1310 wp_set_post_tax( $post_ID, $taxonomy, $tags ); 1311 } 1312 } 1305 1313 1306 1314 $current_guid = get_post_field( 'guid', $post_ID ); 1307 1315 … … 1455 1463 } 1456 1464 1457 1465 function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) { 1466 return wp_set_post_tax( $post_id, 'post_tag', $tags, $append); 1467 } 1468 1469 function wp_set_post_tax( $post_id = 0, $taxonomy='post_tag', $tags = '', $append = false ) { 1458 1470 /* $append - true = don't delete existing tags, just add on, false = replace the tags with the new tags */ 1459 1471 1460 1472 $post_id = (int) $post_id; … … 1465 1477 if ( empty($tags) ) 1466 1478 $tags = array(); 1467 1479 $tags = (is_array($tags)) ? $tags : explode( ',', trim($tags, " \n\t\r\0\x0B,") ); 1468 wp_set_object_terms($post_id, $tags, 'post_tag', $append);1480 wp_set_object_terms($post_id, $tags, $taxonomy, $append); 1469 1481 } 1470 1482 1471 1483 /** -
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']);468 #$_POST['tags_input'] = explode(",", $_POST['tags_input']); 469 469 if($_POST['post_type'] == 'page' || empty($_POST['post_category'])) 470 470 unset($_POST['post_category']); 471 471 -
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 40 function tag_flush_to_text() { 39 var newtags = jQuery('#tags-input').val() + ',' + jQuery('#newtag').val(); 41 obj = jQuery(this).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(); 57 } ); 52 58 } 53 59 54 60 function tag_press_key( e ) { … … 58 64 } 59 65 } 60 66 61 jQuery(document).ready( function() { 62 // postboxes 63 add_postbox_toggles('post'); 64 65 // Editable slugs 66 make_slugedit_clickable(); 67 68 // hide advanced slug field 69 jQuery('#slugdiv').hide(); 70 71 jQuery('#tags-input').hide(); 72 tag_update_quickclicks(); 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 73 74 // add the quickadd form 74 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>'); 75 jQuery('#tagadd').click( tag_flush_to_text ); 76 jQuery('#newtag').focus(function() { 75 jQuery('.ajaxtag input.tagadd').click( tag_flush_to_text ); 76 jQuery('.ajaxtag input.newtag').focus(function() { 77 77 if ( this.value == postL10n.addTag ) 78 78 jQuery(this).val( '' ).removeClass( 'form-input-tip' ); 79 79 }); 80 jQuery(' #newtag').blur(function() {80 jQuery('.ajaxtag input.newtag').blur(function() { 81 81 if ( this.value == '' ) 82 82 jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' ); 83 83 }); … … 86 86 jQuery('#publish').click( tag_save_on_publish ); 87 87 jQuery('#save-post').click( tag_save_on_publish ); 88 88 89 } 90 91 92 jQuery(document).ready( function() { 93 // postboxes 94 add_postbox_toggles('post'); 95 96 // Editable slugs 97 make_slugedit_clickable(); 98 99 // hide advanced slug field 100 jQuery('#slugdiv').hide(); 101 102 // prepare the tag UI 103 tag_init(); 104 89 105 jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); 90 106 91 107 // auto-suggest stuff -
wp-admin/edit-form-advanced.php
204 204 <?php echo $form_pingback ?> 205 205 <?php echo $form_prevstatus ?> 206 206 207 <div id="tagsdiv" class="postbox <?php echo postbox_classes('tagsdiv', 'post'); ?>"> 208 <h3><?php _e('Tags'); ?></h3> 207 <?php 208 209 // all tag-style post taxonomies 210 foreach ( get_object_taxonomies('post') as $_tax ) { 211 if ( !is_taxonomy_hierarchical($_tax) ) { 212 $tags_to_edit = get_tax_to_edit( $post_ID, $_tax ); 213 214 ?> 215 <div id="tagsdiv-<?php echo $_tax; ?>" class="postbox tagsdiv <?php echo postbox_classes('tagsdiv-'.$_tax, 'post'); ?>"> 216 <h3><?php _e($_tax); ?></h3> 209 217 <div class="inside"> 210 <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> 211 <div id="tagchecklist"></div> 218 <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; ?>" /> 219 220 <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 _e('Separate tags with commas'); ?></span></span> 221 222 </p> 223 <div class="tagchecklist"></div> 212 224 </div> 213 225 </div> 226 <? 227 } 228 } 214 229 230 ?> 231 215 232 <div id="categorydiv" class="postbox <?php echo postbox_classes('categorydiv', 'post'); ?>"> 216 233 <h3><?php _e('Categories') ?></h3> 217 234 <div class="inside">