Ticket #6387: post-taxonomy-ui-r7521-4.patch
File post-taxonomy-ui-r7521-4.patch, 13.4 KB (added by , 16 years ago) |
---|
-
wp-includes/taxonomy.php
2025 2025 return get_object_taxonomies($post); 2026 2026 } 2027 2027 2028 // FIXME: testing only, to be removed 2029 function add_test_taxonomies_alex() { 2030 register_taxonomy( 2031 'people', 2032 array('attachment:image', 'attachment:video', 'attachment:audio', 'post', 'page'), 2033 array( 2034 'label' => __('People'), 2035 'template' => __('People: %l.'), 2036 'helps' => __('Separate people with commas.'), 2037 'sort' => true, 2038 'args' => array('orderby' => 'term_order'), 2039 'rewrite' => array('slug' => 'person'), 2040 ) 2041 ); 2042 register_taxonomy( 'post_place', 'post' ); 2043 } 2044 2045 add_action('init', 'add_test_taxonomies_alex'); 2046 2047 2028 2048 ?> -
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-includes/js/autosave.js
128 128 post_ID: jQuery("#post_ID").val() || 0, 129 129 post_title: jQuery("#title").val() || "", 130 130 autosavenonce: jQuery('#autosavenonce').val(), 131 tags_input: jQuery("#tags-input").val() || "",131 //tags_input: jQuery("#tags-input").val() || "", 132 132 post_type: jQuery('#post_type').val() || "", 133 133 autosave: 1 134 134 }; 135 136 jQuery('.tags-input').each( function() { 137 post_data[this.name] = this.value; 138 } ); 135 139 136 140 // We always send the ajax request in order to keep the post lock fresh. 137 141 // 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 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 // catch the enter key 90 jQuery('.ajaxtag input.newtag').keypress( tag_press_key ); 91 92 } 93 94 95 jQuery(document).ready( function() { 96 // postboxes 97 add_postbox_toggles('post'); 98 99 // Editable slugs 100 make_slugedit_clickable(); 101 102 // hide advanced slug field 103 jQuery('#slugdiv').hide(); 104 105 // prepare the tag UI 106 tag_init(); 107 89 108 jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); 90 109 91 110 // auto-suggest stuff 92 111 jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2 } ); 93 jQuery('#newtag').keypress( tag_press_key );94 112 95 113 // category tabs 96 114 var categoryTabs =jQuery('#category-tabs').tabs(); -
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 $taxonomy = get_taxonomy($_tax); 213 214 $label = ( isset($taxonomy->label) ? $taxonomy->label : $_tax ); 215 $helps = ( isset($taxonomy->helps) ? $taxonomy->helps : __('Separate tags with commas') ); 216 217 $tags_to_edit = get_tax_to_edit( $post_ID, $_tax ); 218 219 ?> 220 <div id="tagsdiv-<?php echo $_tax; ?>" class="postbox tagsdiv <?php echo postbox_classes('tagsdiv-'.$_tax, 'post'); ?>"> 221 <h3><?php echo $label; ?></h3> 209 222 <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> 223 <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; ?>" /> 224 225 <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> 226 227 </p> 228 <div class="tagchecklist"></div> 212 229 </div> 213 230 </div> 231 <? 232 } 233 } 214 234 235 ?> 236 215 237 <div id="categorydiv" class="postbox <?php echo postbox_classes('categorydiv', 'post'); ?>"> 216 238 <h3><?php _e('Categories') ?></h3> 217 239 <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