mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 02:34:38 +00:00
Allow muliple tag-like taxonomies in the post editor. see #6387
git-svn-id: https://develop.svn.wordpress.org/trunk@10222 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -130,10 +130,14 @@ var autosave = function() {
|
||||
post_ID: jQuery("#post_ID").val() || 0,
|
||||
post_title: jQuery("#title").val() || "",
|
||||
autosavenonce: jQuery('#autosavenonce').val(),
|
||||
tags_input: jQuery("#tags-input").val() || "",
|
||||
//tags_input: jQuery("#tags-input").val() || "",
|
||||
post_type: jQuery('#post_type').val() || "",
|
||||
autosave: 1
|
||||
};
|
||||
|
||||
jQuery('.tags-input').each( function() {
|
||||
post_data[this.name] = this.value;
|
||||
} );
|
||||
|
||||
// We always send the ajax request in order to keep the post lock fresh.
|
||||
// This (bool) tells whether or not to write the post to the DB during the ajax request.
|
||||
|
||||
@@ -1206,12 +1206,34 @@ function wp_get_post_categories( $post_id = 0, $args = array() ) {
|
||||
* @return array List of post tags.
|
||||
*/
|
||||
function wp_get_post_tags( $post_id = 0, $args = array() ) {
|
||||
return wp_get_post_terms( $post_id, 'post_tag', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the terms for a post.
|
||||
*
|
||||
* There is only one default for this function, called 'fields' and by default
|
||||
* is set to 'all'. There are other defaults that can be override in
|
||||
* {@link wp_get_object_terms()}.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Post
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @uses wp_get_object_terms() Gets the tags for returning. Args can be found here
|
||||
*
|
||||
* @param int $post_id Optional. The Post ID
|
||||
* @param string $taxonomy The taxonomy for which to retrieve terms. Defaults to post_tag.
|
||||
* @param array $args Optional. Overwrite the defaults
|
||||
* @return array List of post tags.
|
||||
*/
|
||||
function wp_get_post_terms( $post_id = 0, $taxonomy = 'post_tag', $args = array() ) {
|
||||
$post_id = (int) $post_id;
|
||||
|
||||
$defaults = array('fields' => 'all');
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
$tags = wp_get_object_terms($post_id, 'post_tag', $args);
|
||||
$tags = wp_get_object_terms($post_id, $taxonomy, $args);
|
||||
|
||||
return $tags;
|
||||
}
|
||||
@@ -1498,7 +1520,15 @@ function wp_insert_post($postarr = array(), $wp_error = false) {
|
||||
}
|
||||
|
||||
wp_set_post_categories( $post_ID, $post_category );
|
||||
wp_set_post_tags( $post_ID, $tags_input );
|
||||
// old-style tags_input
|
||||
if ( !empty($tags_input) )
|
||||
wp_set_post_tags( $post_ID, $tags_input );
|
||||
// new-style support for all tag-like taxonomies
|
||||
if ( !empty($tax_input) ) {
|
||||
foreach ( $tax_input as $taxonomy => $tags ) {
|
||||
wp_set_post_terms( $post_ID, $tags, $taxonomy );
|
||||
}
|
||||
}
|
||||
|
||||
$current_guid = get_post_field( 'guid', $post_ID );
|
||||
|
||||
@@ -1685,7 +1715,21 @@ function wp_add_post_tags($post_id = 0, $tags = '') {
|
||||
* @return bool|null Will return false if $post_id is not an integer or is 0. Will return null otherwise
|
||||
*/
|
||||
function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
|
||||
return wp_set_post_terms( $post_id, $tags, 'post_tag', $append);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the terms for a post.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @uses wp_set_object_terms() Sets the tags for the post.
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
* @param string $tags The tags to set for the post, separated by commas.
|
||||
* @param bool $append If true, don't delete existing tags, just add on. If false, replace the tags with the new tags.
|
||||
* @return bool|null Will return false if $post_id is not an integer or is 0. Will return null otherwise
|
||||
*/
|
||||
function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false ) {
|
||||
$post_id = (int) $post_id;
|
||||
|
||||
if ( !$post_id )
|
||||
@@ -1693,8 +1737,9 @@ function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
|
||||
|
||||
if ( empty($tags) )
|
||||
$tags = array();
|
||||
$tags = (is_array($tags)) ? $tags : explode( ',', trim($tags, " \n\t\r\0\x0B,") );
|
||||
wp_set_object_terms($post_id, $tags, 'post_tag', $append);
|
||||
|
||||
$tags = is_array($tags) ? $tags : explode( ',', trim($tags, " \n\t\r\0\x0B,") );
|
||||
wp_set_object_terms($post_id, $tags, $taxonomy, $append);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -77,7 +77,7 @@ function wp_default_scripts( &$scripts ) {
|
||||
'l10n_print_after' => 'try{convertEntities(wpAjax);}catch(e){};'
|
||||
) );
|
||||
|
||||
$scripts->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20081210' );
|
||||
$scripts->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20081217' );
|
||||
|
||||
$scripts->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('wp-ajax-response'), '20081210' );
|
||||
$scripts->localize( 'wp-lists', 'wpListL10n', array(
|
||||
@@ -179,7 +179,7 @@ function wp_default_scripts( &$scripts ) {
|
||||
'cancel' => __('Cancel'),
|
||||
'l10n_print_after' => 'try{convertEntities(slugL10n);}catch(e){};'
|
||||
) );
|
||||
$scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20081210' );
|
||||
$scripts->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20081217' );
|
||||
$scripts->localize( 'post', 'postL10n', array(
|
||||
'tagsUsed' => __('Tags used on this post:'),
|
||||
'add' => attribute_escape(__('Add')),
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
* @global array $wp_taxonomies
|
||||
*/
|
||||
$wp_taxonomies = array();
|
||||
$wp_taxonomies['category'] = (object) array('name' => 'category', 'object_type' => 'post', 'hierarchical' => true, 'update_count_callback' => '_update_post_term_count');
|
||||
$wp_taxonomies['post_tag'] = (object) array('name' => 'post_tag', 'object_type' => 'post', 'hierarchical' => false, 'update_count_callback' => '_update_post_term_count');
|
||||
$wp_taxonomies['category'] = (object) array('name' => 'category', 'object_type' => 'post', 'hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Categories'));
|
||||
$wp_taxonomies['post_tag'] = (object) array('name' => 'post_tag', 'object_type' => 'post', 'hierarchical' => false, 'update_count_callback' => '_update_post_term_count', 'label' => __('Post Tags'));
|
||||
$wp_taxonomies['link_category'] = (object) array('name' => 'link_category', 'object_type' => 'link', 'hierarchical' => false);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user