Ticket #7000: 7000.diff
File 7000.diff, 5.9 KB (added by , 17 years ago) |
---|
-
wp-includes/script-loader.php
145 145 'save' => __('Save'), 146 146 'cancel' => __('Cancel'), 147 147 ) ); 148 $this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080 422' );148 $this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080519' ); 149 149 $this->localize( 'post', 'postL10n', array( 150 150 'tagsUsed' => __('Tags used on this post:'), 151 151 'add' => attribute_escape(__('Add')), -
wp-admin/admin-ajax.php
150 150 $parent = 0; 151 151 $post_category = isset($_POST['post_category'])? (array) $_POST['post_category'] : array(); 152 152 $checked_categories = array_map( 'absint', (array) $post_category ); 153 $popular_ids = isset( $_POST['popular_ids'] ) ? 154 array_map( 'absint', explode( ',', $_POST['popular_ids'] ) ) : 155 false; 153 156 154 157 $x = new WP_Ajax_Response(); 155 158 foreach ( $names as $cat_name ) { … … 163 166 continue; 164 167 $category = get_category( $cat_id ); 165 168 ob_start(); 166 wp_category_checklist( 0, $cat_id, $checked_categories );169 wp_category_checklist( 0, $cat_id, $checked_categories, $popular_ids ); 167 170 $data = ob_get_contents(); 168 171 ob_end_clean(); 169 172 $x->add( array( -
wp-admin/includes/template.php
148 148 } 149 149 } 150 150 151 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false ) {151 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false ) { 152 152 $walker = new Walker_Category_Checklist; 153 153 $descendants_and_self = (int) $descendants_and_self; 154 154 155 155 $args = array(); 156 156 157 if ( $post_id ) 157 if ( is_array( $selected_cats ) ) 158 $args['selected_cats'] = $selected_cats; 159 elseif ( $post_id ) 158 160 $args['selected_cats'] = wp_get_post_categories($post_id); 159 161 else 160 162 $args['selected_cats'] = array(); 161 if ( is_array( $selected_cats ) ) 162 $args['selected_cats'] = $selected_cats; 163 $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); 163 164 if ( is_array( $popular_cats ) ) 165 $args['popular_cats'] = $popular_cats; 166 else 167 $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); 168 164 169 if ( $descendants_and_self ) { 165 170 $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" ); 166 171 $self = get_category( $descendants_and_self ); … … 169 174 $categories = get_categories('get=all'); 170 175 } 171 176 172 $args = array($categories, 0, $args); 173 $output = call_user_func_array(array(&$walker, 'walk'), $args); 177 // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) 178 $checked_categories = array(); 179 for ( $i = 0; isset($categories[$i]); $i++ ) { 180 if ( in_array($categories[$i]->term_id, $args['selected_cats']) ) { 181 $checked_categories[] = $categories[$i]; 182 unset($categories[$i]); 183 } 184 } 174 185 175 echo $output; 186 // Put checked cats on top 187 echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args)); 188 // Then the rest of them 189 echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args)); 176 190 } 177 191 178 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10 ) {192 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { 179 193 global $post_ID; 180 194 if ( $post_ID ) 181 195 $checked_categories = wp_get_post_categories($post_ID); … … 186 200 $popular_ids = array(); 187 201 foreach ( (array) $categories as $category ) { 188 202 $popular_ids[] = $category->term_id; 203 if ( !$echo ) // hack for AJAX use 204 continue; 189 205 $id = "popular-category-$category->term_id"; 190 206 ?> 191 207 -
wp-admin/js/post.js
120 120 jQuery('#in-category-' + id + ', #in-popular-category-' + id).attr( 'checked', c ); 121 121 noSyncChecks = false; 122 122 }; 123 var popularCats = jQuery('#categorychecklist-pop :checkbox').map( function() { return parseInt(jQuery(this).val(), 10); } ).get().join(','); 123 124 var catAddBefore = function( s ) { 124 s.data += '& ' + jQuery( '#categorychecklist :checked' ).serialize();125 s.data += '&popular_ids=' + popularCats + '&' + jQuery( '#categorychecklist :checked' ).serialize(); 125 126 return s; 126 127 }; 127 128 var catAddAfter = function( r, s ) { … … 151 152 } ); 152 153 jQuery('#category-add-toggle').click( function() { 153 154 jQuery(this).parents('div:first').toggleClass( 'wp-hidden-children' ); 154 categoryTabs.tabsClick( 1 ); 155 // categoryTabs.tabs( 'select', '#categories-all' ); // this is broken (in the UI beta?) 156 categoryTabs.find( 'a[href="#categories-all"]' ).click(); 155 157 jQuery('#newcat').focus(); 156 158 return false; 157 159 } ); -
wp-admin/edit-form-advanced.php
260 260 261 261 <div id="categories-all" class="ui-tabs-panel"> 262 262 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 263 <?php wp_category_checklist($post->ID ) ?>263 <?php wp_category_checklist($post->ID, false, false, $popular_ids) ?> 264 264 </ul> 265 265 </div> 266 266 <?php