Changeset 10222
- Timestamp:
- 12/18/2008 07:12:26 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r10204 r10222 45 45 46 46 $s = $_GET['q']; // is this slashed already? 47 48 if ( isset($_GET['tax']) ) 49 $taxonomy = sanitize_title($_GET['tax']); 50 else 51 die('0'); 47 52 48 53 if ( false !== strpos( $s, ',' ) ) { … … 53 58 if ( strlen( $s ) < 2 ) 54 59 die; // require 2 chars for matching 55 $results = $wpdb->get_col( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = 'post_tag' AND t.name LIKE ('%". $s . "%')" ); 60 61 $results = $wpdb->get_col( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = '$taxonomy' AND t.name LIKE ('%" . $s . "%')" ); 62 56 63 echo join( $results, "\n" ); 57 64 die; … … 491 498 die('-1'); 492 499 493 $tags = get_tags( array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) ); 500 if ( isset($_POST['tax']) ) 501 $taxonomy = sanitize_title($_POST['tax']); 502 else 503 die('0'); 504 505 $tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) ); 494 506 495 507 if ( empty( $tags ) ) … … 777 789 778 790 $_POST['post_category'] = explode(",", $_POST['catslist']); 779 $_POST['tags_input'] = explode(",", $_POST['tags_input']);780 791 if($_POST['post_type'] == 'page' || empty($_POST['post_category'])) 781 792 unset($_POST['post_category']); -
trunk/wp-admin/css/colors-classic.css
r10152 r10222 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; … … 1008 1008 #timestampdiv input, 1009 1009 #namediv input, 1010 # tagsdiv #the-tagcloud {1010 #poststuff .inside .the-tagcloud { 1011 1011 border-color: #ddd; 1012 1012 } -
trunk/wp-admin/css/colors-fresh.css
r10152 r10222 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; … … 1008 1008 #timestampdiv input, 1009 1009 #namediv input, 1010 # tagsdiv #the-tagcloud {1010 #poststuff .inside .the-tagcloud { 1011 1011 border-color: #ddd; 1012 1012 } -
trunk/wp-admin/css/ie-rtl.css
r10150 r10222 45 45 padding-left: 1px; 46 46 } 47 #tagchecklist span a {47 .tagchecklist span a { 48 48 margin: 4px -9px 0 0; 49 49 } -
trunk/wp-admin/css/ie.css
r10017 r10222 246 246 .widget-sortable, 247 247 .widget-control-actions, 248 #tagchecklist,248 .tagchecklist, 249 249 #col-container, 250 250 #col-left, … … 297 297 } 298 298 299 #tagchecklist span, #tagchecklist span a {300 display: inline-block; 301 display: block; 302 } 303 304 #tagchecklist span a {299 .tagchecklist span, .tagchecklist span a { 300 display: inline-block; 301 display: block; 302 } 303 304 .tagchecklist span a { 305 305 margin: 4px 0 0 -9px; 306 306 } -
trunk/wp-admin/edit-form-advanced.php
r10094 r10222 264 264 * @param object $post 265 265 */ 266 function post_tags_meta_box($post) { 267 ?> 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 <p id="tagcloud-link" class="hide-if-no-js"><a href='#'><?php _e( 'Choose from the most popular tags' ); ?></a></p> 271 <?php 272 } 273 add_meta_box('tagsdiv', __('Tags'), 'post_tags_meta_box', 'post', 'side', 'core'); 266 function post_tags_meta_box($post, $box) { 267 $tax_name = substr($box['id'], 8); 268 $taxonomy = get_taxonomy($tax_name); 269 if ( isset($taxonomy->helps) ) 270 $helps = attribute_escape($taxonomy->helps); 271 else 272 $helps = ''; 273 ?> 274 <div class="tagsdiv" id="<?php echo $tax_name; ?>"> 275 <p class="jaxtag"> 276 <label class="hidden" for="newtag"><?php _e( $box['title'] ); ?></label> 277 <input type="hidden" name="<?php echo "tax_input[$tax_name]"; ?>" class="the-tags" id="tax-input[<?php echo $tax_name; ?>]" value="<?php echo get_terms_to_edit( $post->ID, $tax_name ); ?>" /> 278 279 <span class="ajaxtag" style="display:none;"> 280 <input type="text" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" value="<?php _e('Add new tag'); ?>" /> 281 <input type="button" class="button tagadd" value="<?php _e('Add'); ?>" tabindex="3" /> 282 </span> 283 <?php echo $helps ? "<div class='howto'>$helps</div>" : ''; ?> 284 </p> 285 <div class="tagchecklist"></div> 286 </div> 287 <p class="tagcloud-link hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php printf( __('Choose from the most used tags in %s'), $box['title'] ); ?></a></p> 288 <?php 289 } 290 291 // all tag-style post taxonomies 292 foreach ( get_object_taxonomies('post') as $tax_name ) { 293 if ( !is_taxonomy_hierarchical($tax_name) ) { 294 $taxonomy = get_taxonomy($tax_name); 295 $label = isset($taxonomy->label) ? attribute_escape($taxonomy->label) : $tax_name; 296 297 add_meta_box('tagsdiv-' . $tax_name, $label, 'post_tags_meta_box', 'post', 'side', 'core'); 298 } 299 } 274 300 275 301 /** -
trunk/wp-admin/includes/taxonomy.php
r9481 r10222 195 195 * @return unknown 196 196 */ 197 function get_tags_to_edit( $post_id ) { 197 function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) { 198 return get_terms_to_edit( $post_id, $taxonomy); 199 } 200 201 /** 202 * {@internal Missing Short Description}} 203 * 204 * @since unknown 205 * 206 * @param unknown_type $post_id 207 * @return unknown 208 */ 209 function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) { 198 210 $post_id = (int) $post_id; 199 211 if ( !$post_id ) 200 212 return false; 201 213 202 $tags = wp_get_post_t ags($post_id);214 $tags = wp_get_post_terms($post_id, $taxonomy, array()); 203 215 204 216 if ( !$tags ) 205 217 return false; 206 218 219 if ( is_wp_error($tags) ) 220 return $tags; 221 207 222 foreach ( $tags as $tag ) 208 223 $tag_names[] = $tag->name; 209 224 $tags_to_edit = join( ',', $tag_names ); 210 225 $tags_to_edit = attribute_escape( $tags_to_edit ); 211 $tags_to_edit = apply_filters( 'tags_to_edit', $tags_to_edit ); 226 $tags_to_edit = apply_filters( 'terms_to_edit', $tags_to_edit, $taxonomy ); 227 212 228 return $tags_to_edit; 213 229 } … … 234 250 */ 235 251 function wp_create_tag($tag_name) { 236 if ( $id = tag_exists($tag_name) ) 252 return wp_create_term( $tag_name, 'post_tag'); 253 } 254 255 /** 256 * {@internal Missing Short Description}} 257 * 258 * @since unknown 259 * 260 * @param unknown_type $tag_name 261 * @return unknown 262 */ 263 function wp_create_term($tag_name, $taxonomy = 'post_tag') { 264 if ( $id = is_term($tag_name, $taxonomy) ) 237 265 return $id; 238 266 239 return wp_insert_term($tag_name, 'post_tag'); 240 } 241 242 ?> 267 return wp_insert_term($tag_name, $taxonomy); 268 } -
trunk/wp-admin/includes/template.php
r10182 r10222 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 … … 2730 2730 $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title']; 2731 2731 $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback']; 2732 $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args']; 2732 2733 } 2733 2734 // An id can be in only one priority and one context … … 2743 2744 $wp_meta_boxes[$page][$context][$priority] = array(); 2744 2745 2745 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback );2746 $wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args); 2746 2747 } 2747 2748 -
trunk/wp-admin/js/post.js
r10150 r10222 1 1 // this file contains all the scripts used in the post/edit page 2 3 // return an array with any duplicate, whitespace or values removed 4 function array_unique_noempty(a) { 5 var out = []; 6 jQuery.each( a, function(key, val) { 7 val = jQuery.trim(val); 8 if ( val && jQuery.inArray(val, out) == -1 ) 9 out.push(val); 10 } ); 11 return out; 12 } 2 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( '.the-tags' ).val().split(','); 7 19 delete current_tags[num]; 8 20 var new_tags = []; 21 22 jQuery.each( current_tags, function(key, val) { 23 val = jQuery.trim(val); 24 if ( val ) { 25 new_tags.push(val); 26 } 27 }); 28 29 taxbox.find('.the-tags').val( new_tags.join(',').replace(/\s*,+\s*/, ',').replace(/,+/, ',').replace(/,+\s+,+/, ',').replace(/,+\s*$/, '').replace(/^\s*,+/, '') ); 30 31 tag_update_quickclicks(taxbox); 32 return false; 33 } 34 35 function tag_update_quickclicks(taxbox) { 36 if ( jQuery(taxbox).find('.the-tags').length == 0 ) 37 return; 38 39 var current_tags = jQuery(taxbox).find('.the-tags').val().split(','); 40 jQuery(taxbox).find('.tagchecklist').empty(); 41 shown = false; 42 9 43 jQuery.each( current_tags, function( key, val ) { 10 if ( val && !val.match(/^\s+$/) && '' != val ) { 11 new_tags = new_tags.concat( val ); 12 } 13 }); 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(); 44 val = jQuery.trim(val); 45 if ( !val.match(/^\s+$/) && '' != val ) { 46 var button_id = jQuery(taxbox).attr('id') + '-check-num-' + key; 47 txt = '<span><a id="' + button_id + '" class="ntdelbutton">X</a> ' + val + '</span> '; 48 jQuery(taxbox).find('.tagchecklist').append(txt); 49 jQuery( '#' + button_id ).click( new_tag_remove_tag ); 50 } 51 }); 52 if ( shown ) 53 jQuery(taxbox).find('.tagchecklist').prepend('<strong>'+postL10n.tagsUsed+'</strong><br />'); 54 } 55 56 function tag_flush_to_text(id, a) { 57 a = a || false; 58 var taxbox = jQuery('#'+id); 59 var text = a ? jQuery(a).text() : taxbox.find('input.newtag').val(); 60 61 // is the input box empty (i.e. showing the 'Add new tag' tip)? 62 if ( taxbox.find('input.newtag').hasClass('form-input-tip') && ! a ) 63 return false; 64 65 var tags = taxbox.find('.the-tags').val(); 66 var newtags = tags ? tags + ',' + text : text; 67 68 // massage 69 newtags = newtags.replace(/\s+,+\s*/g, ',').replace(/,+/g, ',').replace(/,+\s+,+/g, ',').replace(/,+\s*$/g, '').replace(/^\s*,+/g, ''); 70 newtags = array_unique_noempty(newtags.split(',')).join(','); 71 taxbox.find('.the-tags').val(newtags); 72 tag_update_quickclicks(taxbox); 73 74 if ( ! a ) 75 taxbox.find('input.newtag').val('').focus(); 76 17 77 return false; 18 78 } 19 79 20 function tag_update_quickclicks() {21 if ( jQuery( '#tags-input' ).length == 0 )22 return;23 var current_tags = jQuery( '#tags-input' ).val().split(',');24 jQuery( '#tagchecklist' ).empty();25 shown = false;26 // jQuery.merge( current_tags, current_tags ); // this doesn't work anymore, need something to array_unique27 jQuery.each( current_tags, function( key, val ) {28 val = val.replace( /^\s+/, '' ).replace( /\s+$/, '' ); // trim29 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;34 }35 });36 if ( shown )37 jQuery( '#tagchecklist' ).prepend( '<strong>'+postL10n.tagsUsed+'</strong><br />' );38 }39 40 function tag_flush_to_text(e,a) {41 a = a || false;42 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 )49 return false;50 51 newtags += text;52 53 // massage54 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 }61 return false;62 }63 64 80 function tag_save_on_publish() { 65 if ( jQuery('#newtag').val() != postL10n.addTag ) 66 tag_flush_to_text(); 81 jQuery('.tagsdiv').each( function(i) { 82 if ( !jQuery(this).find('input.newtag').hasClass('form-input-tip') ) 83 tag_flush_to_text(jQuery(this).parents('.tagsdiv').attr('id')); 84 } ); 67 85 } 68 86 69 87 function tag_press_key( e ) { 70 if ( 13 == e. keyCode) {71 tag_flush_to_text( );88 if ( 13 == e.which ) { 89 tag_flush_to_text(jQuery(e.target).parents('.tagsdiv').attr('id')); 72 90 return false; 73 91 } 74 92 }; 93 94 function tag_init() { 95 96 jQuery('.ajaxtag').show(); 97 jQuery('.tagsdiv').each( function(i) { 98 tag_update_quickclicks(this); 99 } ); 100 101 // add the quickadd form 102 jQuery('.ajaxtag input.tagadd').click(function(){tag_flush_to_text(jQuery(this).parents('.tagsdiv').attr('id'));}); 103 jQuery('.ajaxtag input.newtag').focus(function() { 104 if ( this.value == postL10n.addTag ) { 105 jQuery(this).val( '' ).removeClass( 'form-input-tip' ); 106 } 107 }); 108 109 jQuery('.ajaxtag input.newtag').blur(function() { 110 if ( this.value == '' ) { 111 jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' ); 112 } 113 }); 114 115 // auto-save tags on post save/publish 116 jQuery('#publish').click( tag_save_on_publish ); 117 jQuery('#save-post').click( tag_save_on_publish ); 118 119 // catch the enter key 120 jQuery('.ajaxtag input.newtag').keypress( tag_press_key ); 121 } 75 122 76 123 (function($){ 77 124 tagCloud = { 78 125 init : function() { 79 $(' #tagcloud-link').click(function(){tagCloud.get(); $(this).unbind().click(function(){return false;}); return false;});126 $('.tagcloud-link').click(function(){tagCloud.get($(this).attr('id')); $(this).unbind().click(function(){return false;}); return false;}); 80 127 }, 81 128 82 get : function() { 83 $.post('admin-ajax.php', {'action':'get-tagcloud'}, function(r, stat) { 129 get : function(id) { 130 tax = id.substr(id.indexOf('-')+1); 131 132 $.post('admin-ajax.php', {'action':'get-tagcloud','tax':tax}, function(r, stat) { 84 133 if ( 0 == r || 'success' != stat ) 85 134 r = wpAjax.broken; 86 135 87 r = '<p id="the-tagcloud">'+r+'</p>';88 $(' #tagcloud-link').after($(r));89 $('#the-tagcloud a').click(function(){90 tag_flush_to_text( 0,this);136 r = $('<p id="tagcloud-'+tax+'" class="the-tagcloud">'+r+'</p>'); 137 $('a', r).click(function(){ 138 var id = $(this).parents('p').attr('id'); 139 tag_flush_to_text(id.substr(id.indexOf('-')+1), this); 91 140 return false; 92 141 }); 142 143 $('#'+id).after(r); 93 144 }); 94 145 } … … 108 159 make_slugedit_clickable(); 109 160 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 }); 123 124 // auto-save tags on post save/publish 125 jQuery('#publish').click( tag_save_on_publish ); 126 jQuery('#save-post').click( tag_save_on_publish ); 161 // prepare the tag UI 162 tag_init(); 127 163 128 164 jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); 129 165 130 166 // 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 ); 167 jQuery('.newtag').each(function(){ 168 var tax = $(this).parents('div.tagsdiv').attr('id'); 169 $(this).suggest( 'admin-ajax.php?action=ajax-tag-search&tax='+tax, { delay: 500, minchars: 2, multiple: true, multipleSep: ", " } ); 170 }); 133 171 134 172 // category tabs -
trunk/wp-admin/rtl.css
r10147 r10222 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; … … 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 {233 float: right; 234 } 235 #tagchecklist span a {232 .tagchecklist span { 233 float: right; 234 } 235 .tagchecklist span a { 236 236 margin: 6px -9px 0 0; 237 237 float: right; -
trunk/wp-admin/wp-admin.css
r10168 r10222 1356 1356 } 1357 1357 1358 #post-body #tagsdiv #newtag {1358 #post-body .tagsdiv #newtag { 1359 1359 margin-right: 5px; 1360 1360 width: 16em; … … 1365 1365 } 1366 1366 1367 #side-info-column #tagsdiv #newtag {1367 #side-info-column .tagsdiv #newtag { 1368 1368 width: 68%; 1369 1369 } … … 1422 1422 } 1423 1423 1424 #tagchecklist {1424 .tagchecklist { 1425 1425 margin-left: 10px; 1426 1426 font-size: 12px; … … 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; … … 1443 1443 } 1444 1444 1445 #tagchecklist span a {1445 .tagchecklist span a { 1446 1446 margin: 6px 0pt 0pt -9px; 1447 1447 cursor: pointer; … … 2831 2831 } 2832 2832 2833 # tagsdiv #the-tagcloud {2834 margin: 5px 5px10px;2833 #poststuff .inside .the-tagcloud { 2834 margin: 5px 0 10px; 2835 2835 padding: 8px; 2836 2836 border-width: 1px; -
trunk/wp-includes/js/autosave.js
r9596 r10222 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. -
trunk/wp-includes/post.php
r10213 r10222 1207 1207 */ 1208 1208 function wp_get_post_tags( $post_id = 0, $args = array() ) { 1209 return wp_get_post_terms( $post_id, 'post_tag', $args); 1210 } 1211 1212 /** 1213 * Retrieve the terms for a post. 1214 * 1215 * There is only one default for this function, called 'fields' and by default 1216 * is set to 'all'. There are other defaults that can be override in 1217 * {@link wp_get_object_terms()}. 1218 * 1219 * @package WordPress 1220 * @subpackage Post 1221 * @since 2.8.0 1222 * 1223 * @uses wp_get_object_terms() Gets the tags for returning. Args can be found here 1224 * 1225 * @param int $post_id Optional. The Post ID 1226 * @param string $taxonomy The taxonomy for which to retrieve terms. Defaults to post_tag. 1227 * @param array $args Optional. Overwrite the defaults 1228 * @return array List of post tags. 1229 */ 1230 function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) { 1209 1231 $post_id = (int) $post_id; 1210 1232 … … 1212 1234 $args = wp_parse_args( $args, $defaults ); 1213 1235 1214 $tags = wp_get_object_terms($post_id, 'post_tag', $args);1236 $tags = wp_get_object_terms($post_id, $taxonomy, $args); 1215 1237 1216 1238 return $tags; … … 1499 1521 1500 1522 wp_set_post_categories( $post_ID, $post_category ); 1501 wp_set_post_tags( $post_ID, $tags_input ); 1523 // old-style tags_input 1524 if ( !empty($tags_input) ) 1525 wp_set_post_tags( $post_ID, $tags_input ); 1526 // new-style support for all tag-like taxonomies 1527 if ( !empty($tax_input) ) { 1528 foreach ( $tax_input as $taxonomy => $tags ) { 1529 wp_set_post_terms( $post_ID, $tags, $taxonomy ); 1530 } 1531 } 1502 1532 1503 1533 $current_guid = get_post_field( 'guid', $post_ID ); … … 1686 1716 */ 1687 1717 function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) { 1688 1718 return wp_set_post_terms( $post_id, $tags, 'post_tag', $append); 1719 } 1720 1721 /** 1722 * Set the terms for a post. 1723 * 1724 * @since 2.8.0 1725 * @uses wp_set_object_terms() Sets the tags for the post. 1726 * 1727 * @param int $post_id Post ID. 1728 * @param string $tags The tags to set for the post, separated by commas. 1729 * @param bool $append If true, don't delete existing tags, just add on. If false, replace the tags with the new tags. 1730 * @return bool|null Will return false if $post_id is not an integer or is 0. Will return null otherwise 1731 */ 1732 function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false ) { 1689 1733 $post_id = (int) $post_id; 1690 1734 … … 1694 1738 if ( empty($tags) ) 1695 1739 $tags = array(); 1696 $tags = (is_array($tags)) ? $tags : explode( ',', trim($tags, " \n\t\r\0\x0B,") ); 1697 wp_set_object_terms($post_id, $tags, 'post_tag', $append); 1740 1741 $tags = is_array($tags) ? $tags : explode( ',', trim($tags, " \n\t\r\0\x0B,") ); 1742 wp_set_object_terms($post_id, $tags, $taxonomy, $append); 1698 1743 } 1699 1744 -
trunk/wp-includes/script-loader.php
r10204 r10222 78 78 ) ); 79 79 80 $scripts->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '2008121 0' );80 $scripts->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20081217' ); 81 81 82 82 $scripts->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('wp-ajax-response'), '20081210' ); … … 180 180 'l10n_print_after' => 'try{convertEntities(slugL10n);}catch(e){};' 181 181 ) ); 182 $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '2008121 0' );182 $scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20081217' ); 183 183 $scripts->localize( 'post', 'postL10n', array( 184 184 'tagsUsed' => __('Tags used on this post:'), -
trunk/wp-includes/taxonomy.php
r10159 r10222 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' => __('Post Tags')); 22 22 $wp_taxonomies['link_category'] = (object) array('name' => 'link_category', 'object_type' => 'link', 'hierarchical' => false); 23 23
Note: See TracChangeset
for help on using the changeset viewer.