Revert [7689], gonna try another approach. see #6677
git-svn-id: http://svn.automattic.com/wordpress/trunk@7720 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
35f17e4dea
commit
d5f5f07270
|
@ -1,28 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
require('admin.php' );
|
|
||||||
|
|
||||||
$post_ID = (int) $_GET['post'];
|
|
||||||
|
|
||||||
if ( $post_ID ? !current_user_can( 'edit_post', $post_ID ) : !current_user_can( 'edit_posts' ) )
|
|
||||||
die();
|
|
||||||
|
|
||||||
ob_start();
|
|
||||||
$popular_ids = wp_popular_terms_checklist('category');
|
|
||||||
ob_end_clean();
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
|
|
||||||
<?php dropdown_categories( 0, 0, $popular_ids ); ?>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
|
||||||
<div id="category-add-hidden" style="display: none;">
|
|
||||||
<input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" />
|
|
||||||
<?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
|
|
||||||
<input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
|
|
||||||
<?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
|
|
||||||
<span id="category-ajax-response"></span>
|
|
||||||
</div>
|
|
|
@ -219,17 +219,29 @@ endif; ?>
|
||||||
|
|
||||||
<div id="category-adder" class="wp-hidden-children">
|
<div id="category-adder" class="wp-hidden-children">
|
||||||
<h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
|
<h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
|
||||||
<p id="category-add" class="wp-hidden-child"></p>
|
<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' ); ?>" tabindex="3" />
|
||||||
|
<?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
|
||||||
|
<input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
|
||||||
|
<?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
|
||||||
|
<span id="category-ajax-response"></span>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul id="category-tabs">
|
<ul id="category-tabs">
|
||||||
<li class="ui-tabs-selected"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
|
<li class="ui-tabs-selected"><a href="#categories-all" tabindex="3"><?php _e( 'All Categories' ); ?></a></li>
|
||||||
<li class="wp-no-js-hidden"><a id="category-tabs-all" href="edit-form-advanced-tabs.php?post=<?php echo $post_ID; ?>" tabindex="3"><?php _e( 'All Categories' ); ?></a></li>
|
<li class="wp-no-js-hidden"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div id="categories-pop" class="ui-tabs-panel" style="display: none;">
|
<div id="categories-pop" class="ui-tabs-panel" style="display: none;">
|
||||||
<ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
|
<ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
|
||||||
<?php $popular_ids = wp_popular_terms_checklist('category'); // If we up the # here we have to do so in edit-form-advanced-tabs.php too ?>
|
<?php $popular_ids = wp_popular_terms_checklist('category'); ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="categories-all" class="ui-tabs-panel">
|
||||||
|
<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
|
||||||
|
<?php dropdown_categories( 0, 0, $popular_ids ); ?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.5 KiB |
|
@ -194,8 +194,6 @@ function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array()
|
||||||
}
|
}
|
||||||
|
|
||||||
function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10 ) {
|
function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10 ) {
|
||||||
global $checked_categories;
|
|
||||||
wp_set_checked_post_categories( $default );
|
|
||||||
$categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number ) );
|
$categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number ) );
|
||||||
|
|
||||||
$popular_ids = array();
|
$popular_ids = array();
|
||||||
|
@ -206,7 +204,7 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10 ) {
|
||||||
|
|
||||||
<li id="<?php echo $id; ?>" class="popular-category">
|
<li id="<?php echo $id; ?>" class="popular-category">
|
||||||
<label class="selectit" for="in-<?php echo $id; ?>">
|
<label class="selectit" for="in-<?php echo $id; ?>">
|
||||||
<input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" name="post_category[]" <?php checked( in_array( $category->term_id, $checked_categories ), true ); ?> />
|
<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 ) ); ?>
|
<?php echo wp_specialchars( apply_filters( 'the_category', $category->name ) ); ?>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -100,79 +100,60 @@ jQuery(document).ready( function() {
|
||||||
jQuery('#newtag').keypress( tag_press_key );
|
jQuery('#newtag').keypress( tag_press_key );
|
||||||
|
|
||||||
// category tabs
|
// category tabs
|
||||||
var newCatFocus = false;
|
var categoryTabs =jQuery('#category-tabs').tabs();
|
||||||
var categoryTabs =jQuery('#category-tabs').tabs( {
|
|
||||||
cache: true,
|
|
||||||
show: function(ui) {
|
|
||||||
if ( 'category-tabs-all' != ui.id ) { return; } // only do this for the all tab
|
|
||||||
var adder = jQuery('#category-add-hidden');
|
|
||||||
|
|
||||||
if ( !adder.size() ) { return; } // we're already done
|
// Ajax Cat
|
||||||
|
var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } );
|
||||||
// Put HTML in proper place and set up the wp-lists etc
|
jQuery('#category-add-sumbit').click( function() { newCat.focus(); } );
|
||||||
jQuery('#category-add').html( adder.remove().html() );
|
var newCatParent = false;
|
||||||
|
var newCatParentOption = false;
|
||||||
// Ajax Cat
|
var noSyncChecks = false; // prophylactic. necessary?
|
||||||
var newCat = jQuery('#newcat').one( 'focus', function() { jQuery(this).val( '' ).removeClass( 'form-input-tip' ) } );
|
var syncChecks = function() {
|
||||||
jQuery('#category-add-sumbit').click( function() { newCat.focus(); } );
|
if ( noSyncChecks )
|
||||||
var newCatParent = false;
|
return;
|
||||||
var newCatParentOption = false;
|
noSyncChecks = true;
|
||||||
var noSyncChecks = false; // prophylactic. necessary?
|
var th = jQuery(this);
|
||||||
var syncChecks = function() {
|
var c = th.is(':checked');
|
||||||
if ( noSyncChecks )
|
var id = th.val().toString();
|
||||||
return;
|
jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c );
|
||||||
noSyncChecks = true;
|
noSyncChecks = false;
|
||||||
|
};
|
||||||
|
var catAddBefore = function( s ) {
|
||||||
|
s.data += '&' + jQuery( '#categorychecklist :checked' ).serialize();
|
||||||
|
return s;
|
||||||
|
};
|
||||||
|
var catAddAfter = function( r, s ) {
|
||||||
|
if ( !newCatParent ) newCatParent = jQuery('#newcat_parent');
|
||||||
|
if ( !newCatParentOption ) newCatParentOption = newCatParent.find( 'option[value=-1]' );
|
||||||
|
jQuery(s.what + ' response_data', r).each( function() {
|
||||||
|
var t = jQuery(jQuery(this).text());
|
||||||
|
t.find( 'label' ).each( function() {
|
||||||
var th = jQuery(this);
|
var th = jQuery(this);
|
||||||
var c = th.is(':checked');
|
var val = th.find('input').val();
|
||||||
var id = th.val().toString();
|
var id = th.find('input')[0].id
|
||||||
jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c );
|
jQuery('#' + id).change( syncChecks );
|
||||||
noSyncChecks = false;
|
if ( newCatParent.find( 'option[value=' + val + ']' ).size() )
|
||||||
};
|
return;
|
||||||
var catAddBefore = function( s ) {
|
var name = jQuery.trim( th.text() );
|
||||||
s.data += '&' + jQuery( '#categorychecklist :checked' ).serialize();
|
var o = jQuery( '<option value="' + parseInt( val, 10 ) + '"></option>' ).text( name );
|
||||||
return s;
|
newCatParent.prepend( o );
|
||||||
};
|
|
||||||
var catAddAfter = function( r, s ) {
|
|
||||||
if ( !newCatParent ) newCatParent = jQuery('#newcat_parent');
|
|
||||||
if ( !newCatParentOption ) newCatParentOption = newCatParent.find( 'option[value=-1]' );
|
|
||||||
jQuery(s.what + ' response_data', r).each( function() {
|
|
||||||
var t = jQuery(jQuery(this).text());
|
|
||||||
t.find( 'label' ).each( function() {
|
|
||||||
var th = jQuery(this);
|
|
||||||
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( val, 10 ) + '"></option>' ).text( name );
|
|
||||||
newCatParent.prepend( o );
|
|
||||||
} );
|
|
||||||
newCatParentOption.attr( 'selected', true );
|
|
||||||
} );
|
|
||||||
};
|
|
||||||
jQuery('#categorychecklist').wpList( {
|
|
||||||
alt: '',
|
|
||||||
response: 'category-ajax-response',
|
|
||||||
addBefore: catAddBefore,
|
|
||||||
addAfter: catAddAfter
|
|
||||||
} );
|
} );
|
||||||
jQuery('.categorychecklist .popular-category :checkbox').change( syncChecks ).filter( ':checked' ).change();
|
newCatParentOption.attr( 'selected', true );
|
||||||
|
} );
|
||||||
if ( newCatFocus ) {
|
};
|
||||||
jQuery('#newcat').focus();
|
jQuery('#categorychecklist').wpList( {
|
||||||
newCatFocus = false;
|
alt: '',
|
||||||
}
|
response: 'category-ajax-response',
|
||||||
}
|
addBefore: catAddBefore,
|
||||||
|
addAfter: catAddAfter
|
||||||
} );
|
} );
|
||||||
|
|
||||||
jQuery('#category-add-toggle').click( function() {
|
jQuery('#category-add-toggle').click( function() {
|
||||||
jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' );
|
jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' );
|
||||||
categoryTabs.tabsClick( 2 );
|
categoryTabs.tabsClick( 1 );
|
||||||
jQuery('#newcat').focus();
|
jQuery('#newcat').focus();
|
||||||
newCatFocus = true;
|
|
||||||
return false;
|
return false;
|
||||||
} );
|
} );
|
||||||
|
jQuery('.categorychecklist .popular-category :checkbox').change( syncChecks ).filter( ':checked' ).change();
|
||||||
|
|
||||||
jQuery('.edit-timestamp').click(function () {
|
jQuery('.edit-timestamp').click(function () {
|
||||||
if (jQuery('#timestampdiv').is(":hidden")) {
|
if (jQuery('#timestampdiv').is(":hidden")) {
|
||||||
|
|
|
@ -1269,16 +1269,6 @@ ul.categorychecklist li {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul#category-tabs a {
|
|
||||||
width: 100%;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ui-tabs-loading {
|
|
||||||
outline: none;
|
|
||||||
background: url(../images/loading.gif) no-repeat 0 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#linkcategorydiv ul#category-tabs {
|
#linkcategorydiv ul#category-tabs {
|
||||||
float: left;
|
float: left;
|
||||||
width: 120px;
|
width: 120px;
|
||||||
|
|
|
@ -144,7 +144,7 @@ class WP_Scripts {
|
||||||
'save' => __('Save'),
|
'save' => __('Save'),
|
||||||
'cancel' => __('Cancel'),
|
'cancel' => __('Cancel'),
|
||||||
) );
|
) );
|
||||||
$this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080412' );
|
$this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080411' );
|
||||||
$this->localize( 'post', 'postL10n', array(
|
$this->localize( 'post', 'postL10n', array(
|
||||||
'tagsUsed' => __('Tags used on this post:'),
|
'tagsUsed' => __('Tags used on this post:'),
|
||||||
'add' => attribute_escape(__('Add')),
|
'add' => attribute_escape(__('Add')),
|
||||||
|
|
Loading…
Reference in New Issue