AVH Extended Categories Widgets - Version 3.2.1

Version Description

Download this release

Release Info

Developer petervanderdoes
Plugin Icon wp plugin AVH Extended Categories Widgets
Version 3.2.1
Comparing to
See all releases

Code changes from version 3.2.0.1 to 3.2.1

.gitignore ADDED
@@ -0,0 +1 @@
 
1
+ .project
2.8/class/avh-ec.core.php CHANGED
@@ -23,7 +23,7 @@ class AVH_EC_Core
23
  */
24
  $catgrp = & AVH_EC_Singleton::getInstance( 'AVH_EC_Category_Group' );
25
 
26
- $this->version = '3.2.0.1';
27
  $this->comment = '<!-- AVH Extended Categories version ' . $this->version . ' | http://blog.avirtualhome.com/wordpress-plugins/ -->';
28
  $db_version = 2;
29
  $this->db_options_core = 'avhec';
@@ -427,6 +427,26 @@ class AVH_EC_Core
427
  else
428
  return $output;
429
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
430
  }
431
 
432
  /**
23
  */
24
  $catgrp = & AVH_EC_Singleton::getInstance( 'AVH_EC_Category_Group' );
25
 
26
+ $this->version = '3.2.1';
27
  $this->comment = '<!-- AVH Extended Categories version ' . $this->version . ' | http://blog.avirtualhome.com/wordpress-plugins/ -->';
28
  $db_version = 2;
29
  $this->db_options_core = 'avhec';
427
  else
428
  return $output;
429
  }
430
+
431
+ function getCategories ( )
432
+ {
433
+ static $_categories = NULL;
434
+ if ( NULL === $_categories ) {
435
+ $_categories = get_categories( 'get=all' );
436
+ }
437
+ return $_categories;
438
+ }
439
+
440
+ function getCategoriesId ( $categories )
441
+ {
442
+ static $_categories_id = NULL;
443
+ if ( NULL == $_categories_id ) {
444
+ foreach ( $categories as $key => $category ) {
445
+ $_categories_id[$category->term_id] = $key;
446
+ }
447
+ }
448
+ return $_categories_id;
449
+ }
450
  }
451
 
452
  /**
2.8/class/avh-ec.widgets.php CHANGED
@@ -247,7 +247,9 @@ class WP_Widget_AVH_ExtendedCategories_Normal extends WP_Widget
247
  _e( 'All Categories', 'avh-ec' );
248
  echo '</label>';
249
  echo '</li>';
250
- $this->avh_wp_category_checklist( 0, 0, $selected_cats, FALSE, $this->number, 1 );
 
 
251
  echo '</ul>';
252
  echo '</p>';
253
 
@@ -267,55 +269,45 @@ class WP_Widget_AVH_ExtendedCategories_Normal extends WP_Widget
267
  * @param array $popular_cats
268
  * @param int $number
269
  */
270
- function avh_wp_category_checklist ( $post_id = 0, $descendants_and_self = 0, $selected_cats = FALSE, $popular_cats = FALSE, $number, $display = 1 )
271
  {
 
272
  $walker = new AVH_Walker_Category_Checklist();
273
  $walker->number = $number;
274
  $walker->input_id = $this->get_field_id( 'post_category' );
275
  $walker->input_name = $this->get_field_name( 'post_category' );
276
  $walker->li_id = $this->get_field_id( 'category--1' );
277
 
278
- $descendants_and_self = ( int ) $descendants_and_self;
 
 
 
 
 
 
279
 
280
- $args = array ();
281
  if ( is_array( $selected_cats ) )
282
  $args['selected_cats'] = $selected_cats;
283
- elseif ( $post_id )
284
- $args['selected_cats'] = wp_get_post_categories( $post_id );
285
  else
286
  $args['selected_cats'] = array ();
287
 
288
- if ( is_array( $popular_cats ) )
289
- $args['popular_cats'] = $popular_cats;
290
- else
291
- $args['popular_cats'] = get_terms( 'category', array ('fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => FALSE ) );
292
-
293
- if ( $descendants_and_self ) {
294
- $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" );
295
- $self = get_category( $descendants_and_self );
296
- array_unshift( $categories, $self );
297
- } else {
298
- $categories = get_categories( 'get=all' );
299
- }
300
- $all_categories = $categories;
301
 
302
  // 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)
303
  $checked_categories = array ();
304
- for ( $i = 0; isset( $categories[$i] ); $i ++ ) {
305
- if ( in_array( $categories[$i]->term_id, $args['selected_cats'] ) ) {
306
- $checked_categories[] = $categories[$i];
307
- unset( $categories[$i] );
 
308
  }
309
  }
310
 
311
- if ( 1 == $display ) {
312
- // Put checked cats on top
313
- echo call_user_func_array( array (&$walker, 'walk' ), array ($checked_categories, 0, $args ) );
314
- // Then the rest of them
315
- echo call_user_func_array( array (&$walker, 'walk' ), array ($categories, 0, $args ) );
316
- } else {
317
- return ($all_categories);
318
- }
319
  }
320
  }
321
 
@@ -784,11 +776,10 @@ class AVH_Walker_Category_Checklist extends Walker
784
  function start_el ( &$output, $category, $depth, $args )
785
  {
786
  extract( $args );
787
- $this->input_id = $this->input_id . '-' . $category->term_id;
788
- $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
789
- $output .= "\n" . '<li id="' . $this->li_id . '"' . $class . '>';
790
- $output .= '<label for="' . $this->input_id . '" class="selectit">';
791
- $output .= '<input value="' . $category->term_id . '" type="checkbox" name="' . $this->input_name . '[' . $category->term_id . ']" id="' . $this->input_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "") . '/> ' . wp_specialchars( apply_filters( 'the_category', $category->name ) ) . '</label>';
792
  }
793
 
794
  function end_el ( &$output, $category, $depth, $args )
247
  _e( 'All Categories', 'avh-ec' );
248
  echo '</label>';
249
  echo '</li>';
250
+ ob_start();
251
+ $this->avh_wp_category_checklist( $selected_cats, $this->number );
252
+ ob_end_flush();
253
  echo '</ul>';
254
  echo '</p>';
255
 
269
  * @param array $popular_cats
270
  * @param int $number
271
  */
272
+ function avh_wp_category_checklist ( $selected_cats, $number)
273
  {
274
+
275
  $walker = new AVH_Walker_Category_Checklist();
276
  $walker->number = $number;
277
  $walker->input_id = $this->get_field_id( 'post_category' );
278
  $walker->input_name = $this->get_field_name( 'post_category' );
279
  $walker->li_id = $this->get_field_id( 'category--1' );
280
 
281
+ $args = array ('taxonomy' => 'category',
282
+ 'descendants_and_self' => 0,
283
+ 'selected_cats' => $selected_cats,
284
+ 'popular_cats' => array(),
285
+ 'walker' => $walker,
286
+ 'checked_ontop' => true,
287
+ 'popular_cats' => array ());
288
 
 
289
  if ( is_array( $selected_cats ) )
290
  $args['selected_cats'] = $selected_cats;
 
 
291
  else
292
  $args['selected_cats'] = array ();
293
 
294
+ $categories = $this->core->getCategories();
295
+ $_categories_id = $this->core->getCategoriesId($categories);
 
 
 
 
 
 
 
 
 
 
 
296
 
297
  // 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)
298
  $checked_categories = array ();
299
+ foreach ($args['selected_cats'] as $key => $value) {
300
+ if (isset($_categories_id[$key])) {
301
+ $category_key=$_categories_id[$key];
302
+ $checked_categories[] = $categories[$category_key];
303
+ unset ($categories[$category_key]);
304
  }
305
  }
306
 
307
+ // Put checked cats on top
308
+ echo call_user_func_array( array (&$walker, 'walk' ), array ($checked_categories, 0, $args ) );
309
+ // Then the rest of them
310
+ echo call_user_func_array( array (&$walker, 'walk' ), array ($categories, 0, $args ) );
 
 
 
 
311
  }
312
  }
313
 
776
  function start_el ( &$output, $category, $depth, $args )
777
  {
778
  extract( $args );
779
+ $input_id = $this->input_id . '-' . $category->term_id;
780
+ $output .= "\n" . '<li id="' . $this->li_id . '">';
781
+ $output .= '<label for="' . $input_id . '" class="selectit">';
782
+ $output .= '<input value="' . $category->term_id . '" type="checkbox" name="' . $this->input_name . '[' . $category->term_id . ']" id="' . $input_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "") . '/> ' . wp_specialchars( apply_filters( 'the_category', $category->name ) ) . '</label>';
 
783
  }
784
 
785
  function end_el ( &$output, $category, $depth, $args )
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://blog.avirtualhome.com/wordpress-plugins/
4
  Tags: extended, categories, widget, top categories
5
  Requires at least: 2.3
6
  Tested up to: 3.0-Beta1
7
- Stable tag: 3.2.0.1
8
 
9
  The AVH Extended Categories Widgets gives you three widgets for displaying categories.
10
  == Description ==
@@ -99,6 +99,9 @@ I have also setup a project in Launchpad for translating the plug-in. Just visit
99
  None
100
 
101
  == Changelog ==
 
 
 
102
  = Version 3.2.0.1 =
103
  * Bugfix: Forgot to add a directory into SVN.
104
 
4
  Tags: extended, categories, widget, top categories
5
  Requires at least: 2.3
6
  Tested up to: 3.0-Beta1
7
+ Stable tag: 3.2.1
8
 
9
  The AVH Extended Categories Widgets gives you three widgets for displaying categories.
10
  == Description ==
99
  None
100
 
101
  == Changelog ==
102
+ = Version 3.2.1 =
103
+ * Speed improvements in the admin section when there are a lot of categories and several Categories widgets.
104
+
105
  = Version 3.2.0.1 =
106
  * Bugfix: Forgot to add a directory into SVN.
107
 
widget-pre2.8.php CHANGED
@@ -7,7 +7,7 @@ function widget_extended_categories_init() {
7
  }
8
 
9
  function widget_extended_categories($args, $number = 1) {
10
- $version = '3.2.0.1';
11
  // Check for version
12
  require (ABSPATH . WPINC . '/version.php');
13
  if ( version_compare($wp_version, '2.5.1', '<') ) {
7
  }
8
 
9
  function widget_extended_categories($args, $number = 1) {
10
+ $version = '3.2.1';
11
  // Check for version
12
  require (ABSPATH . WPINC . '/version.php');
13
  if ( version_compare($wp_version, '2.5.1', '<') ) {
widget_extended_categories.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: AVH Extended Categories Widgets
4
  Plugin URI: http://blog.avirtualhome.com/wordpress-plugins
5
  Description: Replacement of the category widget to allow for greater customization of the category widget.
6
- Version: 3.2.0.1
7
  Author: Peter van der Does
8
  Author URI: http://blog.avirtualhome.com/
9
 
3
  Plugin Name: AVH Extended Categories Widgets
4
  Plugin URI: http://blog.avirtualhome.com/wordpress-plugins
5
  Description: Replacement of the category widget to allow for greater customization of the category widget.
6
+ Version: 3.2.1
7
  Author: Peter van der Does
8
  Author URI: http://blog.avirtualhome.com/
9