Fixes to category list saving. Hat tip: mdawaffe. Fixes #5631
git-svn-id: https://develop.svn.wordpress.org/trunk@6597 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9310d7cc6f
commit
3a11dc94c0
@ -127,14 +127,15 @@ else
|
||||
<p id="category-add" class="wp-hidden-child">
|
||||
<input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" />
|
||||
<?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category') ) ); ?>
|
||||
<a id="category-add-sumbit" class="add:categorychecklist:categorydiv button" href="<?php echo wp_nonce_url( '', 'add-category' ); ?>"><?php _e( 'Add' ); ?></a>
|
||||
<input type="button" id="category-add-sumbit" class="add:categorychecklist:categorydiv button" value="<?php _e( 'Add' ); ?>" />
|
||||
<?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
|
||||
<span id="category-ajax-response"></span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<ul id="category-tabs">
|
||||
<li class="ui-tabs-selected"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li>
|
||||
<li><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li>
|
||||
<li class="wp-no-js-hidden"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li>
|
||||
</ul>
|
||||
|
||||
<div id="categories-all" class="ui-tabs-panel">
|
||||
@ -143,7 +144,7 @@ else
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="categories-pop" class="ui-tabs-panel">
|
||||
<div id="categories-pop" class="ui-tabs-panel" style="display: none;">
|
||||
<ul id="categorychecklist-pop" class="categorychecklist form-no-clear">
|
||||
<?php wp_popular_categories_checklist(); ?>
|
||||
</ul>
|
||||
|
@ -188,20 +188,15 @@ function dropdown_categories( $default = 0, $parent = 0 ) {
|
||||
}
|
||||
|
||||
function wp_popular_categories_checklist( $default = 0, $number = 10 ) {
|
||||
global $checked_categories;
|
||||
|
||||
wp_set_checked_post_categories( $default );
|
||||
|
||||
$categories = get_categories( array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number ) );
|
||||
|
||||
foreach ( (array) $categories as $category ) {
|
||||
$id = "popular-category-$category->term_id";
|
||||
$checked = in_array( $category->term_id, $checked_categories ) ? ' checked="checked"' : '';
|
||||
?>
|
||||
|
||||
<li id="<?php echo $id; ?>">
|
||||
<label class="selectit" for="in-<?php echo $id; ?>">
|
||||
<input id="in-<?php echo $id; ?>" type="checkbox" name="post_category[]" value="<?php echo (int) $category->term_id; ?>"<?php echo $checked; ?> />
|
||||
<input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />
|
||||
<?php echo wp_specialchars( apply_filters( 'the_category', $category->name ) ); ?>
|
||||
</label>
|
||||
</li>
|
||||
|
@ -1,4 +1,6 @@
|
||||
addLoadEvent( function() {
|
||||
// pulse
|
||||
jQuery('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300);
|
||||
});
|
||||
|
||||
jQuery('.wp-no-js-hidden').removeClass( 'wp-no-js-hidden' );
|
||||
});
|
||||
|
@ -95,6 +95,17 @@ addLoadEvent( function() {
|
||||
jQuery('#category-add-sumbit').click( function() { newCat.focus(); } );
|
||||
var newCatParent = false;
|
||||
var newCatParentOption = false;
|
||||
var noSyncChecks = false; // prophylactic. necessary?
|
||||
var syncChecks = function() {
|
||||
if ( noSyncChecks )
|
||||
return;
|
||||
noSyncChecks = true;
|
||||
var th = jQuery(this);
|
||||
var c = th.is(':checked');
|
||||
var id = th.val().toString();
|
||||
jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c );
|
||||
noSyncChecks = false;
|
||||
};
|
||||
var catAddAfter = function( r, s ) {
|
||||
if ( !newCatParent ) newCatParent = jQuery('#newcat_parent');
|
||||
if ( !newCatParentOption ) newCatParentOption = newCatParent.find( 'option[value=-1]' );
|
||||
@ -102,14 +113,16 @@ addLoadEvent( function() {
|
||||
var t = jQuery(jQuery(this).text());
|
||||
t.find( 'label' ).each( function() {
|
||||
var th = jQuery(this);
|
||||
var id = th.find('input').val();
|
||||
if ( newCatParent.find( 'option[value=' + id + ']' ).size() )
|
||||
var val = th.find('input').val();
|
||||
var id = th.find('input')[0].id
|
||||
jQuery('#' + id).change( syncChecks );
|
||||
if ( newCatParent.find( 'option[value=' + val + ']' ).size() )
|
||||
return;
|
||||
var name = jQuery.trim( th.text() );
|
||||
var o = jQuery( '<option value="' + parseInt( id, 10 ) + '"></option>' ).text( name );
|
||||
var o = jQuery( '<option value="' + parseInt( val, 10 ) + '"></option>' ).text( name );
|
||||
newCatParent.prepend( o );
|
||||
newCatParentOption.attr( 'selected', true );
|
||||
} );
|
||||
newCatParentOption.attr( 'selected', true );
|
||||
} );
|
||||
};
|
||||
jQuery('#categorychecklist').wpList( {
|
||||
@ -122,4 +135,5 @@ addLoadEvent( function() {
|
||||
categoryTabs.tabsClick( 1 );
|
||||
return false;
|
||||
} );
|
||||
jQuery('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change();
|
||||
});
|
||||
|
@ -1237,6 +1237,10 @@ a.view-comment-post-link {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
#category-add input#category-add-sumbit {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
#categorydiv ul#category-tabs {
|
||||
float: left;
|
||||
width: 120px;
|
||||
@ -1279,5 +1283,6 @@ ul.categorychecklist li {
|
||||
|
||||
/* Global classes */
|
||||
.wp-hidden-children .wp-hidden-child { display: none; }
|
||||
.wp-no-js-hidden { display: none; }
|
||||
.ui-tabs-hide { display: none; }
|
||||
.form-input-tip { color: #999; }
|
||||
|
Loading…
Reference in New Issue
Block a user