AVH Extended Categories Widgets - Version 3.2

Version Description

Download this release

Release Info

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

Code changes from version 3.1 to 3.2

2.8/avh-ec.client.php CHANGED
@@ -26,6 +26,9 @@ class AVH_EC_Singleton
26
  case 'AVH_EC_Category_Group' :
27
  require_once (AVHEC_WORKING_DIR . '/class/avh-ec.category-group.php');
28
  break;
 
 
 
29
  }
30
  }
31
  $instances[$class] = new $class( $arg1 );
@@ -35,6 +38,11 @@ class AVH_EC_Singleton
35
  } // getInstance
36
  } // singleton
37
 
 
 
 
 
 
38
  require_once (AVHEC_WORKING_DIR . '/class/avh-ec.widgets.php');
39
 
40
  /**
26
  case 'AVH_EC_Category_Group' :
27
  require_once (AVHEC_WORKING_DIR . '/class/avh-ec.category-group.php');
28
  break;
29
+ case 'AVH_EC_Widget_Helper_Class' :
30
+ require_once (AVHEC_WORKING_DIR . '/class/avh-ec.widget-helper.php');
31
+ break;
32
  }
33
  }
34
  $instances[$class] = new $class( $arg1 );
38
  } // getInstance
39
  } // singleton
40
 
41
+ /**
42
+ * Include the necessary files
43
+ *
44
+ */
45
+ require_once (AVHEC_WORKING_DIR . '/helpers/avh-forms.php');
46
  require_once (AVHEC_WORKING_DIR . '/class/avh-ec.widgets.php');
47
 
48
  /**
2.8/class/avh-ec.admin.php CHANGED
@@ -464,15 +464,17 @@ class AVH_EC_Admin
464
  {
465
  global $screen_layout_columns;
466
 
467
- $data_add_group_default = array ('name' => '', 'slug' => '', 'description' => '' );
468
  $data_add_group_new = $data_add_group_default;
469
 
470
  $options_add_group[] = array ('avhec_add_group[add][name]', ' Group Name', 'text', 20, 'The name is used to identify the group.' );
471
- $options_add_group[] = array ('avhec_edit_group[add][slug]', ' Slug Group', 'text', 20, 'The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' );
 
472
  $options_add_group[] = array ('avhec_add_group[add][description]', ' Description', 'textarea', 40, 'Description is not prominent by default.', 5 );
473
 
474
  $options_edit_group[] = array ('avhec_edit_group[edit][name]', ' Group Name', 'text', 20, 'The name is used to identify the group.' );
475
  $options_edit_group[] = array ('avhec_edit_group[edit][slug]', ' Slug Group', 'text', 20, 'The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' );
 
476
  $options_edit_group[] = array ('avhec_edit_group[edit][description]', ' Description', 'textarea', 40, 'Description is not prominent by default.', 5 );
477
  $options_edit_group[] = array ('avhec_edit_group[edit][categories]', ' Categories', 'catlist', 0, 'Select categories to be included in the group.' );
478
 
@@ -483,11 +485,12 @@ class AVH_EC_Admin
483
 
484
  $data_add_group_new['name'] = $formoptions['add']['name'];
485
  $data_add_group_new['slug'] = empty( $formoptions['add']['slug'] ) ? sanitize_title( $data_add_group_new['name'] ) : sanitize_title( $formoptions['add']['slug'] );
486
- $data_add_group_new['decsription'] = $formoptions['add']['description'];
 
487
 
488
  $id = $this->catgrp->getTermIDBy( 'slug', $data_add_group_new['slug'] );
489
  if ( ! $id ) {
490
- $group_id = $this->catgrp->doInsertGroup( $data_add_group_new['name'], array ('description' => $data_add_group_new['description'], 'slug' => $data_add_group_new['slug'] ) );
491
  $this->catgrp->setCategoriesForGroup( $group_id );
492
  $this->message = __( 'Category group saved', 'avh-ec' );
493
  $this->status = 'updated fade';
@@ -513,9 +516,10 @@ class AVH_EC_Admin
513
  case 'edit' :
514
  $group_id = ( int ) $_GET['group_ID'];
515
  $group = $this->catgrp->getGroup( $group_id );
 
516
  $cats = $this->catgrp->getCategoriesFromGroup( $group_id );
517
 
518
- $data_edit_group['edit'] = array ('group_id' => $group_id, 'name' => $group->name, 'slug' => $group->slug, 'description' => $group->description, 'categories' => $cats );
519
  $data['edit'] = array ('form' => $options_edit_group, 'data' => $data_edit_group );
520
 
521
  add_meta_box( 'avhecBoxCategoryGroupEdit', __( 'Edit Group', 'avh-ec' ) . ': ' . $group->name, array (&$this, 'metaboxCategoryGroupEdit' ), $this->hooks['menu_category_groups'], 'normal', 'low' );
@@ -547,21 +551,22 @@ class AVH_EC_Admin
547
  $selected_categories = $_POST['post_category'];
548
 
549
  $group_id = ( int ) $_POST['avhec-group_id'];
550
- $group = $this->catgrp->getGroup( $group_id );
551
- if ( is_object( $group ) ) {
552
- $id = wp_update_term( $group->term_id, $this->catgrp->taxonomy_name, array ('name' => $formoptions['edit']['name'], 'slug' => $formoptions['edit']['slug'], 'description' => $formoptions['edit']['description'] ) );
553
- if ( ! is_wp_error( $id ) ) {
554
- $this->catgrp->setCategoriesForGroup( $group_id, $selected_categories );
555
  $this->message = __( 'Category group updated', 'avh-ec' );
556
  $this->status = 'updated fade';
557
- } else {
 
558
  $this->message = __( 'Category group not updated', 'avh-ec' );
559
  $this->message .= '<br />' . __( 'Duplicate slug detected', 'avh-ec' );
560
  $this->status = 'error';
561
- }
562
- } else {
563
- $this->message = __( 'Unknown category group', 'avh-ec' );
564
- $this->status = 'error';
 
565
  }
566
  $this->displayMessage();
567
  }
@@ -878,7 +883,7 @@ class AVH_EC_Admin
878
  */
879
  function filterManageCategoriesGroupColumns ( $columns )
880
  {
881
- $categories_group_columns = array ('name' => __( 'Name', 'avh-ec' ), 'slug' => 'Slug', 'description' => __( 'Description', 'avh-ec' ), 'cat-in-group' => __( 'Categories in the group', 'avh-ec' ) );
882
  return $categories_group_columns;
883
  }
884
 
@@ -1013,6 +1018,11 @@ class AVH_EC_Admin
1013
  $output .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug ) . '</div>';
1014
  $output .= '</div></td>';
1015
  break;
 
 
 
 
 
1016
  case 'description' :
1017
  $output .= '<td ' . $attributes . '>' . $qe_data->description . '</td>';
1018
  break;
464
  {
465
  global $screen_layout_columns;
466
 
467
+ $data_add_group_default = array ('name' => '', 'slug' => '', 'widget_title' => '', 'description' => '' );
468
  $data_add_group_new = $data_add_group_default;
469
 
470
  $options_add_group[] = array ('avhec_add_group[add][name]', ' Group Name', 'text', 20, 'The name is used to identify the group.' );
471
+ $options_add_group[] = array ('avhec_add_group[add][slug]', ' Slug Group', 'text', 20, 'The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' );
472
+ $options_add_group[] = array ('avhec_add_group[add][widget_title]', ' Widget Title', 'text', 20, 'When no title is given in the widget options, this will used as the title of the widget when this group is shown.' );
473
  $options_add_group[] = array ('avhec_add_group[add][description]', ' Description', 'textarea', 40, 'Description is not prominent by default.', 5 );
474
 
475
  $options_edit_group[] = array ('avhec_edit_group[edit][name]', ' Group Name', 'text', 20, 'The name is used to identify the group.' );
476
  $options_edit_group[] = array ('avhec_edit_group[edit][slug]', ' Slug Group', 'text', 20, 'The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' );
477
+ $options_edit_group[] = array ('avhec_edit_group[edit][widget_title]', ' Widget Title', 'text', 20, 'When no title is given in the widget options, this will used as the title of the widget when this group is shown.' );
478
  $options_edit_group[] = array ('avhec_edit_group[edit][description]', ' Description', 'textarea', 40, 'Description is not prominent by default.', 5 );
479
  $options_edit_group[] = array ('avhec_edit_group[edit][categories]', ' Categories', 'catlist', 0, 'Select categories to be included in the group.' );
480
 
485
 
486
  $data_add_group_new['name'] = $formoptions['add']['name'];
487
  $data_add_group_new['slug'] = empty( $formoptions['add']['slug'] ) ? sanitize_title( $data_add_group_new['name'] ) : sanitize_title( $formoptions['add']['slug'] );
488
+ $data_add_group_new['widget_title'] = $formoptions['add']['widget_title'];
489
+ $data_add_group_new['description'] = $formoptions['add']['description'];
490
 
491
  $id = $this->catgrp->getTermIDBy( 'slug', $data_add_group_new['slug'] );
492
  if ( ! $id ) {
493
+ $group_id = $this->catgrp->doInsertGroup( $data_add_group_new['name'], array ('description' => $data_add_group_new['description'], 'slug' => $data_add_group_new['slug'] ), $data_add_group_new['widget_title'] );
494
  $this->catgrp->setCategoriesForGroup( $group_id );
495
  $this->message = __( 'Category group saved', 'avh-ec' );
496
  $this->status = 'updated fade';
516
  case 'edit' :
517
  $group_id = ( int ) $_GET['group_ID'];
518
  $group = $this->catgrp->getGroup( $group_id );
519
+ $widget_title = $this->catgrp->getWidgetTitleForGroup( $group_id );
520
  $cats = $this->catgrp->getCategoriesFromGroup( $group_id );
521
 
522
+ $data_edit_group['edit'] = array ('group_id' => $group_id, 'name' => $group->name, 'slug' => $group->slug, 'widget_title' => $widget_title, 'description' => $group->description, 'categories' => $cats );
523
  $data['edit'] = array ('form' => $options_edit_group, 'data' => $data_edit_group );
524
 
525
  add_meta_box( 'avhecBoxCategoryGroupEdit', __( 'Edit Group', 'avh-ec' ) . ': ' . $group->name, array (&$this, 'metaboxCategoryGroupEdit' ), $this->hooks['menu_category_groups'], 'normal', 'low' );
551
  $selected_categories = $_POST['post_category'];
552
 
553
  $group_id = ( int ) $_POST['avhec-group_id'];
554
+ $result = $this->catgrp->doUpdateGroup( $group_id, array ('name' => $formoptions['edit']['name'], 'slug' => $formoptions['edit']['slug'], 'description' => $formoptions['edit']['description'] ), $selected_categories, $formoptions['edit']['widget_title'] );
555
+ switch ( $result )
556
+ {
557
+ case 1 :
 
558
  $this->message = __( 'Category group updated', 'avh-ec' );
559
  $this->status = 'updated fade';
560
+ break;
561
+ case 0 :
562
  $this->message = __( 'Category group not updated', 'avh-ec' );
563
  $this->message .= '<br />' . __( 'Duplicate slug detected', 'avh-ec' );
564
  $this->status = 'error';
565
+ break;
566
+ case - 1 :
567
+ $this->message = __( 'Unknown category group', 'avh-ec' );
568
+ $this->status = 'error';
569
+ break;
570
  }
571
  $this->displayMessage();
572
  }
883
  */
884
  function filterManageCategoriesGroupColumns ( $columns )
885
  {
886
+ $categories_group_columns = array ('name' => __( 'Name', 'avh-ec' ), 'slug' => 'Slug', 'widget-title' => __( 'Widget Title', 'avh-ec' ), 'description' => __( 'Description', 'avh-ec' ), 'cat-in-group' => __( 'Categories in the group', 'avh-ec' ) );
887
  return $categories_group_columns;
888
  }
889
 
1018
  $output .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug ) . '</div>';
1019
  $output .= '</div></td>';
1020
  break;
1021
+ case 'widget-title' :
1022
+ $title = $this->catgrp->getWidgetTitleForGroup($group->term_id);
1023
+ $output .= '<td ' . $attributes . '>' . $title . '</td>';
1024
+ break;
1025
+
1026
  case 'description' :
1027
  $output .= '<td ' . $attributes . '>' . $qe_data->description . '</td>';
1028
  break;
2.8/class/avh-ec.category-group.php CHANGED
@@ -13,6 +13,10 @@ class AVH_EC_Category_Group
13
  */
14
  var $taxonomy_name;
15
 
 
 
 
 
16
  /**
17
  * PHP4 constructor.
18
  *
@@ -33,21 +37,13 @@ class AVH_EC_Category_Group
33
 
34
  register_shutdown_function( array (&$this, '__destruct' ) );
35
 
36
-
37
  /**
38
  * Taxonomy name
39
  * @var string
40
  */
41
  $this->taxonomy_name = 'avhec_catgroup';
42
 
43
- /**
44
- * Setup Group Categories Taxonomy
45
- */
46
- if (!is_taxonomy($this->taxonomy_name)) {
47
- register_taxonomy( $this->taxonomy_name, 'post', array ('hierarchical' => false, 'label' => __( 'Category Groups', 'avh-ec' ), 'query_var' => true, 'rewrite' => true ) );
48
- register_taxonomy( $this->taxonomy_name, 'page', array ('hierarchical' => false, 'label' => __( 'Category Groups', 'avh-ec' ), 'query_var' => true, 'rewrite' => true ) );
49
- }
50
-
51
  // add DB pointer
52
  $wpdb->avhec_cat_group = $wpdb->prefix . 'avhec_category_groups';
53
 
@@ -56,7 +52,36 @@ class AVH_EC_Category_Group
56
  *
57
  */
58
  if ( $wpdb->get_var( 'show tables like \'' . $wpdb->avhec_cat_group . '\'' ) != $wpdb->avhec_cat_group ) {
59
- $this->doCreateTable();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  }
61
 
62
  // Setup the standard groups if the none group does not exists.
@@ -69,19 +94,35 @@ class AVH_EC_Category_Group
69
  $all_categories = $this->getAllCategoriesTermID();
70
  $this->setCategoriesForGroup( $all_group_id['term_id'], $all_categories );
71
  $this->setCategoriesForGroup( $home_group_id['term_id'], $all_categories );
 
 
72
  }
73
  }
74
 
75
  /**
76
- * PHP5 style destructor and will run when database object is destroyed.
 
77
  *
78
- * @return bool Always true
79
  */
80
- function __destruct ()
81
  {
82
- return true;
 
 
 
 
 
 
 
 
 
83
  }
84
 
 
 
 
 
 
85
  function doCreateTable ()
86
  {
87
  global $wpdb;
@@ -99,7 +140,6 @@ class AVH_EC_Category_Group
99
  $sql = 'CREATE TABLE `' . $wpdb->avhec_cat_group . '` ( `group_term_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `term_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`group_term_id`, `term_id`) )' . $charset_collate . ';';
100
 
101
  $result = $wpdb->query( $sql );
102
-
103
  }
104
 
105
  /**
@@ -161,9 +201,9 @@ class AVH_EC_Category_Group
161
  if ( ! is_array( $categories ) ) {
162
  $categories = array ();
163
  }
164
- $new_categories = $categories;
165
- sort($old_categories);
166
- sort($new_categories);
167
  // If the new and old values are the same, no need to update.
168
  if ( $new_categories === $old_categories ) {
169
  return false;
@@ -192,6 +232,44 @@ class AVH_EC_Category_Group
192
  return $result;
193
  }
194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  /**
196
  * Same as get_term_by, but returns the ID only if found, else false
197
  * @param string $field
@@ -232,9 +310,10 @@ class AVH_EC_Category_Group
232
  * @param $term
233
  * @param array $args
234
  */
235
- function doInsertGroup ( $term, $args = array() )
236
  {
237
  $row = wp_insert_term( $term, $this->taxonomy_name, $args );
 
238
  return ($row['term_id']);
239
  }
240
 
@@ -250,7 +329,37 @@ class AVH_EC_Category_Group
250
 
251
  $group = $this->getGroup( $group_id );
252
  $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->avhec_cat_group . ' WHERE group_term_id=%d', $group_id ) );
 
253
  $return = wp_delete_term( $group->term_id, $this->taxonomy_name );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  return ($return);
255
  }
256
 
13
  */
14
  var $taxonomy_name;
15
 
16
+ var $db_options_widget_titles;
17
+
18
+ var $options_widget_titles;
19
+
20
  /**
21
  * PHP4 constructor.
22
  *
37
 
38
  register_shutdown_function( array (&$this, '__destruct' ) );
39
 
 
40
  /**
41
  * Taxonomy name
42
  * @var string
43
  */
44
  $this->taxonomy_name = 'avhec_catgroup';
45
 
46
+ $this->db_options_widget_titles = 'avhec_widget_titles';
 
 
 
 
 
 
 
47
  // add DB pointer
48
  $wpdb->avhec_cat_group = $wpdb->prefix . 'avhec_category_groups';
49
 
52
  *
53
  */
54
  if ( $wpdb->get_var( 'show tables like \'' . $wpdb->avhec_cat_group . '\'' ) != $wpdb->avhec_cat_group ) {
55
+ add_action( 'init', array (&$this, 'doCreateTable' ) );
56
+ }
57
+ add_action( 'init', array (&$this, 'doRegisterTaxonomy' ) );
58
+ add_action( 'init', array (&$this, 'doSetupOptions' ) );
59
+
60
+ }
61
+
62
+ /**
63
+ * PHP5 style destructor and will run when database object is destroyed.
64
+ *
65
+ * @return bool Always true
66
+ */
67
+ function __destruct ()
68
+ {
69
+ return true;
70
+ }
71
+
72
+ /**
73
+ * Setup Group Categories Taxonomy
74
+ * @WordPress_action init
75
+ *
76
+ */
77
+ function doRegisterTaxonomy ()
78
+ {
79
+ /**
80
+ * Setup Group Categories Taxonomy
81
+ */
82
+ if ( ! is_taxonomy( $this->taxonomy_name ) ) {
83
+ register_taxonomy( $this->taxonomy_name, 'post', array ('hierarchical' => false, 'label' => __( 'Category Groups', 'avh-ec' ), 'query_var' => true, 'rewrite' => true ) );
84
+ register_taxonomy( $this->taxonomy_name, 'page', array ('hierarchical' => false, 'label' => __( 'Category Groups', 'avh-ec' ), 'query_var' => true, 'rewrite' => true ) );
85
  }
86
 
87
  // Setup the standard groups if the none group does not exists.
94
  $all_categories = $this->getAllCategoriesTermID();
95
  $this->setCategoriesForGroup( $all_group_id['term_id'], $all_categories );
96
  $this->setCategoriesForGroup( $home_group_id['term_id'], $all_categories );
97
+ $this->setWidgetTitleForGroup( $all_group_id['term_id'], '' );
98
+ $this->setWidgetTitleForGroup( $home_group_id['term_id'], '' );
99
  }
100
  }
101
 
102
  /**
103
+ * Setup the options for the widget titles
104
+ * @WordPress_action init
105
  *
 
106
  */
107
+ function doSetupOptions ()
108
  {
109
+ $options = get_option( $this->db_options_widget_titles );
110
+ if ( ! $options ) {
111
+ $options = array ();
112
+ $id = $this->getTermIDBy( 'slug', 'all' );
113
+ $options[$id] = '';
114
+ $id = $this->getTermIDBy( 'slug', 'home' );
115
+ $options[$id] = '';
116
+ update_option( $this->db_options_widget_titles, $options );
117
+ }
118
+ $this->options_widget_titles = $options;
119
  }
120
 
121
+ /**
122
+ * Create Table
123
+ * @WordPress_action init
124
+ *
125
+ */
126
  function doCreateTable ()
127
  {
128
  global $wpdb;
140
  $sql = 'CREATE TABLE `' . $wpdb->avhec_cat_group . '` ( `group_term_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, `term_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, PRIMARY KEY (`group_term_id`, `term_id`) )' . $charset_collate . ';';
141
 
142
  $result = $wpdb->query( $sql );
 
143
  }
144
 
145
  /**
201
  if ( ! is_array( $categories ) ) {
202
  $categories = array ();
203
  }
204
+ $new_categories = $categories;
205
+ sort( $old_categories );
206
+ sort( $new_categories );
207
  // If the new and old values are the same, no need to update.
208
  if ( $new_categories === $old_categories ) {
209
  return false;
232
  return $result;
233
  }
234
 
235
+ /**
236
+ * Set the Widget Title for a Group
237
+ * @param int $group_id
238
+ * @param string $widget_title
239
+ *
240
+ */
241
+ function setWidgetTitleForGroup ( $group_id, $widget_title = '' )
242
+ {
243
+ $this->options_widget_titles[$group_id] = $widget_title;
244
+ update_option( $this->db_options_widget_titles, $this->options_widget_titles );
245
+ }
246
+
247
+ /**
248
+ * Return the title for a group_id if exsist otherwise return false
249
+ * @param $group_id
250
+ *
251
+ */
252
+ function getWidgetTitleForGroup ( $group_id )
253
+ {
254
+ if ( isset( $this->options_widget_titles[$group_id] ) ) {
255
+ return ($this->options_widget_titles[$group_id]);
256
+ }
257
+ return false;
258
+ }
259
+
260
+ /**
261
+ * Delete the Widget Title for a group
262
+ *
263
+ * @param $group_id
264
+ */
265
+ function doDeleteWidgetTitle ( $group_id )
266
+ {
267
+ if ( isset( $this->db_options_widget_titles[$group_id] ) ) {
268
+ unset( $this->db_options_widget_titles[$group_id] );
269
+ }
270
+ update_option( $this->db_options_widget_titles, $this->options_widget_titles );
271
+ }
272
+
273
  /**
274
  * Same as get_term_by, but returns the ID only if found, else false
275
  * @param string $field
310
  * @param $term
311
  * @param array $args
312
  */
313
+ function doInsertGroup ( $term, $args = array(), $widget_title = '' )
314
  {
315
  $row = wp_insert_term( $term, $this->taxonomy_name, $args );
316
+ $this->setWidgetTitleForGroup( $term, $widget_title );
317
  return ($row['term_id']);
318
  }
319
 
329
 
330
  $group = $this->getGroup( $group_id );
331
  $result = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->avhec_cat_group . ' WHERE group_term_id=%d', $group_id ) );
332
+ $this->doDeleteWidgetTitle( $group_id );
333
  $return = wp_delete_term( $group->term_id, $this->taxonomy_name );
334
+
335
+ return ($return);
336
+ }
337
+
338
+ /**
339
+ * Update a group
340
+ *
341
+ * @param $group_id
342
+ * @param $selected_categories
343
+ * @param $widget_title
344
+ *
345
+ * return -1,0,1 Unknown Group, Duplicate Slug, Succesfull
346
+ */
347
+ function doUpdateGroup ( $group_id, $args = array(), $selected_categories, $widget_title = '' )
348
+ {
349
+
350
+ $group = $this->getGroup( $group_id );
351
+ if ( is_object( $group ) ) {
352
+ $id = wp_update_term( $group->term_id, $this->taxonomy_name, $args );
353
+ if ( ! is_wp_error( $id ) ) {
354
+ $this->setWidgetTitleForGroup( $group_id, $widget_title );
355
+ $this->setCategoriesForGroup( $group_id, $selected_categories );
356
+ $return = 1; // Succesful
357
+ } else {
358
+ $return = 0; // Duplicate Slug
359
+ }
360
+ } else {
361
+ $return = - 1; // Unknown group
362
+ }
363
  return ($return);
364
  }
365
 
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.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';
@@ -45,7 +45,7 @@ class AVH_EC_Core
45
  $default_group_id = $catgrp->getTermIDBy( 'slug', 'all' );
46
  $this->default_options_category_group = array ('no_group' => $no_group_id, 'home_group' => $home_group_id, 'default_group' => $default_group_id );
47
 
48
- $this->default_options = array ('general' => $this->default_options_general, 'cat_group' => $this->default_options_category_group );
49
 
50
  /**
51
  * Set the options for the program
@@ -131,6 +131,19 @@ class AVH_EC_Core
131
  return ('');
132
  }
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  /**
135
  * Get the base directory of a directory structure
136
  *
23
  */
24
  $catgrp = & AVH_EC_Singleton::getInstance( 'AVH_EC_Category_Group' );
25
 
26
+ $this->version = '3.2';
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';
45
  $default_group_id = $catgrp->getTermIDBy( 'slug', 'all' );
46
  $this->default_options_category_group = array ('no_group' => $no_group_id, 'home_group' => $home_group_id, 'default_group' => $default_group_id );
47
 
48
+ $this->default_options = array ('general' => $this->default_options_general, 'cat_group' => $this->default_options_category_group, 'widget_titles'=>array() );
49
 
50
  /**
51
  * Set the options for the program
131
  return ('');
132
  }
133
 
134
+ /**
135
+ * Used in forms to set the SELECTED option
136
+ *
137
+ * @param string $current
138
+ * @param string $field
139
+ * @return string
140
+ */
141
+ function isSelected($current, $field) {
142
+ if ($current == $field) {
143
+ return (' SELECTED');
144
+ }
145
+ return ('');
146
+ }
147
  /**
148
  * Get the base directory of a directory structure
149
  *
2.8/class/avh-ec.widgets.php CHANGED
@@ -182,126 +182,60 @@ class WP_Widget_AVH_ExtendedCategories_Normal extends WP_Widget
182
  $instance = wp_parse_args( ( array ) $instance, array ('title' => '', 'rssimage' => '', 'depth' => 0 ) );
183
 
184
  // Prepare data for display
185
- $title = esc_attr( $instance['title'] );
186
- $selectedonly = ( bool ) $instance['selectedonly'];
187
- $count = ( bool ) $instance['count'];
188
- $hierarchical = ( bool ) $instance['hierarchical'];
189
  $depth = ( int ) $instance['depth'];
190
- $hide_empty = ( bool ) $instance['hide_empty'];
191
- $use_desc_for_title = ( bool ) $instance['use_desc_for_title'];
192
- $sort_id = ($instance['sort_column'] == 'ID') ? ' SELECTED' : '';
193
- $sort_name = ($instance['sort_column'] == 'name') ? ' SELECTED' : '';
194
- $sort_count = ($instance['sort_column'] == 'count') ? ' SELECTED' : '';
195
- $sort_order_a = ($instance['sort_order'] == 'asc') ? ' SELECTED' : '';
196
- $sort_order_d = ($instance['sort_order'] == 'desc') ? ' SELECTED' : '';
197
- $style_list = ($instance['style'] == 'list') ? ' SELECTED' : '';
198
- $style_drop = ($instance['style'] == 'drop') ? ' SELECTED' : '';
199
- $rssfeed = ( bool ) $instance['rssfeed'];
200
- $rssimage = esc_attr( $instance['rssimage'] );
201
- $selected_cats = ($instance['post_category'] != '') ? unserialize( $instance['post_category'] ) : FALSE;
202
- $invert_included = ( bool ) $instance['invert_included'];
203
-
204
  if ( $depth < 0 || 11 < $depth ) {
205
  $depth = 0;
206
  }
 
207
 
208
- if ( TRUE == $selectedonly ) {
209
- $hierarchical = FALSE;
210
- }
211
  echo '<p>';
212
- echo '<label for="' . $this->get_field_id( 'title' ) . '">';
213
- _e( 'Title', 'avh-ec' );
214
- echo '<input class="widefat" id="' . $this->get_field_id( 'title' ) . '" name="' . $this->get_field_name( 'title' ) . '" type="text" value="' . $title . '" /> ';
215
- echo '</label>';
216
  echo '</p>';
217
 
218
  echo '<p>';
 
219
 
220
- echo '<label for="' . $this->get_field_id( 'selectedonly' ) . '">';
221
- echo '<input class="checkbox" type="checkbox" id="' . $this->get_field_id( 'selectedonly' ) . '" name="' . $this->get_field_name( 'selectedonly' ) . '" ' . $this->core->isChecked( TRUE, $selectedonly ) . ' /> ';
222
- _e( 'Show selected categories only', 'avh-ec' );
223
- echo '</label>';
224
- echo '<br />';
225
 
226
- echo '<label for="' . $this->get_field_id( 'count' ) . '">';
227
- echo '<input class="checkbox" type="checkbox" id="' . $this->get_field_id( 'count' ) . '" name="' . $this->get_field_name( 'count' ) . '" ' . $this->core->isChecked( TRUE, $count ) . ' /> ';
228
- _e( 'Show post counts', 'avh-ec' );
229
- echo '</label>';
230
- echo '<br />';
231
 
232
- echo '<label for="' . $this->get_field_id( 'hierarchical' ) . '">';
233
- echo '<input class="checkbox" type="checkbox" id="' . $this->get_field_id( 'hierarchical' ) . '" name="' . $this->get_field_name( 'hierarchical' ) . '" ' . $this->core->isChecked( TRUE, $hierarchical ) . ' /> ';
234
- _e( 'Show hierarchy', 'avh-ec' );
235
- echo '</label>';
236
- echo '<br />';
237
-
238
- echo '<label for="' . $this->get_field_id( 'depth' ) . '">';
239
- _e( 'How many levels to show', 'avh-ec' );
240
- echo '</label>';
241
- echo '<select id="' . $this->get_field_id( 'depth' ) . '" name="' . $this->get_field_name( 'depth' ) . '"> ';
242
- echo '<option value="0" ' . (0 == $depth ? "selected='selected'" : '') . '>' . __( 'All Levels', 'avh-ec' ) . '</option>';
243
- echo '<option value="1" ' . (1 == $depth ? "selected='selected'" : '') . '>' . __( 'Toplevel only', 'avh-ec' ) . '</option>';
244
  for ( $i = 2; $i <= 11; $i ++ ) {
245
- echo '<option value="' . $i . '" ' . ($i == $depth ? "selected='selected'" : '') . '>' . __( 'Child ', 'avh-ec' ) . ($i - 1) . '</option>';
246
  }
247
- echo '</select>';
248
- echo '<br />';
249
 
250
- echo '<label for="' . $this->get_field_id( 'hide_empty' ) . '">';
251
- echo '<input class="checkbox" type="checkbox" id="' . $this->get_field_id( 'hide_empty' ) . '" name="' . $this->get_field_name( 'hide_empty' ) . '" ' . $this->core->isChecked( TRUE, $hide_empty ) . '/> ';
252
- _e( 'Hide empty categories', 'avh-ec' );
253
- echo '</label>';
254
- echo '<br />';
255
 
256
- echo '<label for="' . $this->get_field_id( 'use_desc_for_title' ) . '">';
257
- echo '<input class="checkbox" type="checkbox" id="' . $this->get_field_id( 'use_desc_for_title' ) . '" name="' . $this->get_field_name( 'use_desc_for_title' ) . '" ' . $this->core->isChecked( TRUE, $use_desc_for_title ) . '/> ';
258
- _e( 'Use description for title', 'avh-ec' );
259
- echo '</label>';
260
- echo '<br />';
261
  echo '</p>';
262
 
263
  echo '<p>';
264
- echo '<label for="' . $this->get_field_id( 'sort_column' ) . '">';
265
- _e( 'Sort by ', 'avh-ec' );
266
- echo '<select id="' . $this->get_field_id( 'sort_column' ) . '" name="' . $this->get_field_name( 'sort_column' ) . '"> ';
267
- echo '<option value="ID" ' . $sort_id . '>' . __( 'ID', 'avh-ec' ) . '</option>';
268
- echo '<option value="name" ' . $sort_name . '>' . __( 'Name', 'avh-ec' ) . '</option>';
269
- echo '<option value="count" ' . $sort_count . '>' . __( 'Count', 'avh-ec' ) . '</option>';
270
- echo '</select>';
271
- echo '</label>';
272
- echo '<br />';
273
-
274
- echo '<label for="' . $this->get_field_id( 'sort_order' ) . '">';
275
- _e( 'Sort order ', 'avh-ec' );
276
- echo '<select id="' . $this->get_field_id( 'sort_order' ) . '" name="' . $this->get_field_name( 'sort_order' ) . '"> ';
277
- echo '<option value="asc" ' . $sort_order_a . '>' . __( 'Ascending', 'avh-ec' ) . '</option>';
278
- echo '<option value="desc" ' . $sort_order_d . '>' . __( 'Descending', 'avh-ec' ) . '</option>';
279
- echo '</select>';
280
- echo '</label>';
281
- echo '<br />';
282
-
283
- echo '<label for="' . $this->get_field_id( 'style' ) . '">';
284
- _e( 'Display style ', 'avh-ec' );
285
- echo '<select id="' . $this->get_field_id( 'style' ) . '" name="' . $this->get_field_name( 'style' ) . '"> ';
286
- echo '<option value="list" ' . $style_list . '>' . __( 'List', 'avh-ec' ) . '</option>';
287
- echo '<option value="drop" ' . $style_drop . '>' . __( 'Drop down', 'avh-ec' ) . '</option>';
288
- echo '</select>';
289
- echo '</label>';
290
- echo '<br />';
291
  echo '</p>';
292
 
293
  echo '<p>';
294
 
295
- echo '<label for="' . $this->get_field_id( 'rssfeed' ) . '">';
296
- echo '<input class="checkbox" type="checkbox" id="' . $this->get_field_id( 'rssfeed' ) . '" name="' . $this->get_field_name( 'rssfeed' ) . '" ' . $this->core->isChecked( TRUE, $rssfeed ) . '/> ';
297
- _e( 'Show RSS Feed', 'avh-ec' );
298
- echo '</label>';
299
- echo '<br />';
300
 
301
- echo '<label for="">';
302
- _e( 'Path (URI) to RSS image', 'avh-ec' );
303
- echo '<input class="widefat" id="' . $this->get_field_id( 'rssimage' ) . '" name="' . $this->get_field_name( 'rssimage' ) . '" type="text" value="' . $rssimage . '" />';
304
- echo '</label>';
305
  echo '</p>';
306
 
307
  echo '<p>';
@@ -309,7 +243,7 @@ class WP_Widget_AVH_ExtendedCategories_Normal extends WP_Widget
309
  echo '<ul id="categorychecklist" class="list:category categorychecklist form-no-clear" style="list-style-type: none; margin-left: 5px; padding-left: 0px; margin-bottom: 20px;">';
310
  echo '<li id="' . $this->get_field_id( 'category--1' ) . '" class="popular-category">';
311
  echo '<label for="' . $this->get_field_id( 'post_category' ) . '" class="selectit">';
312
- echo '<input value="all" id="' . $this->get_field_id( 'post_category' ) . '" name="' . $this->get_field_name( 'post_category' ) . '[all]" type="checkbox" ' . $this->core->isChecked( FALSE, $selected_cats ) . '> ';
313
  _e( 'All Categories', 'avh-ec' );
314
  echo '</label>';
315
  echo '</li>';
@@ -318,11 +252,7 @@ class WP_Widget_AVH_ExtendedCategories_Normal extends WP_Widget
318
  echo '</p>';
319
 
320
  echo '<p>';
321
- echo '<label for="' . $this->get_field_id( 'invert_included' ) . '">';
322
- echo '<input class="checkbox" type="checkbox" id="' . $this->get_field_id( 'invert_included' ) . '" name="' . $this->get_field_name( 'invert_included' ) . '" ' . $this->core->isChecked( TRUE, $invert_included ) . '/> ';
323
- _e( 'Exclude the selected categories', 'avh-ec' );
324
- echo '</label>';
325
- echo '<br />';
326
  echo '</p>';
327
 
328
  echo '<input type="hidden" id="' . $this->get_field_id( 'submit' ) . '" name="' . $this->get_field_name( 'submit' ) . '" value="1" />';
@@ -539,94 +469,53 @@ class WP_Widget_AVH_ExtendedCategories_Top extends WP_Widget
539
  $instance = wp_parse_args( ( array ) $instance, array ('title' => '', 'rssimage' => '' ) );
540
 
541
  // Prepare data for display
542
- $title = esc_attr( $instance['title'] );
543
  if ( ! $amount = ( int ) $instance['amount'] ) {
544
  $amount = 5;
545
  }
546
- $count = ( bool ) $instance['count'];
547
- $use_desc_for_title = ( bool ) $instance['use_desc_for_title'];
548
- $sort_id = ($instance['sort_column'] == 'ID') ? ' SELECTED' : '';
549
- $sort_name = ($instance['sort_column'] == 'name') ? ' SELECTED' : '';
550
- $sort_count = ($instance['sort_column'] == 'count') ? ' SELECTED' : '';
551
- $sort_order_a = ($instance['sort_order'] == 'asc') ? ' SELECTED' : '';
552
- $sort_order_d = ($instance['sort_order'] == 'desc') ? ' SELECTED' : '';
553
- $style_list = ($instance['style'] == 'list') ? ' SELECTED' : '';
554
- $style_drop = ($instance['style'] == 'drop') ? ' SELECTED' : '';
555
- $rssfeed = ( bool ) $instance['rssfeed'];
556
- $rssimage = esc_attr( $instance['rssimage'] );
557
 
558
  if ( $amount < 1 ) {
559
  $amount = 1;
560
  }
561
  echo '<p>';
562
- echo '<label for="' . $this->get_field_id( 'title' ) . '">';
563
- _e( 'Title', 'avh-ec' );
564
- echo '<input class="widefat" id="' . $this->get_field_id( 'title' ) . '" name="' . $this->get_field_name( 'title' ) . '" type="text" value="' . $title . '" /> ';
565
- echo '</label>';
566
  echo '</p>';
567
 
568
  echo '<p>';
569
- echo '<label for="' . $this->get_field_id( 'amount' ) . '">';
570
- _e( 'How many categories to show', 'avh-ec' );
571
- echo '</label>';
572
- echo '<input class="widefat" id="' . $this->get_field_id( 'amount' ) . '" name="' . $this->get_field_name( 'amount' ) . '" type="text" value="' . $amount . '" /> ';
573
- echo '</select>';
574
  echo '</p>';
575
 
576
  echo '<p>';
577
- echo '<label for="' . $this->get_field_id( 'count' ) . '">';
578
- echo '<input class="checkbox" type="checkbox" id="' . $this->get_field_id( 'count' ) . '" name="' . $this->get_field_name( 'count' ) . '" ' . $this->core->isChecked( TRUE, $count ) . ' /> ';
579
- _e( 'Show post counts', 'avh-ec' );
580
- echo '</label>';
581
  echo '<br />';
582
 
583
- echo '<label for="' . $this->get_field_id( 'use_desc_for_title' ) . '">';
584
- echo '<input class="checkbox" type="checkbox" id="' . $this->get_field_id( 'use_desc_for_title' ) . '" name="' . $this->get_field_name( 'use_desc_for_title' ) . '" ' . $this->core->isChecked( TRUE, $use_desc_for_title ) . '/> ';
585
- _e( 'Use description for title', 'avh-ec' );
586
- echo '</label>';
587
- echo '<br />';
588
-
589
- echo '<label for="' . $this->get_field_id( 'sort_column' ) . '">';
590
- _e( 'Sort by ', 'avh-ec' );
591
- echo '<select id="' . $this->get_field_id( 'sort_column' ) . '" name="' . $this->get_field_name( 'sort_column' ) . '"> ';
592
- echo '<option value="ID" ' . $sort_id . '>' . __( 'ID', 'avh-ec' ) . '</option>';
593
- echo '<option value="name" ' . $sort_name . '>' . __( 'Name', 'avh-ec' ) . '</option>';
594
- echo '<option value="count" ' . $sort_count . '>' . __( 'Count', 'avh-ec' ) . '</option>';
595
- echo '</select>';
596
- echo '</label>';
597
- echo '<br />';
598
-
599
- echo '<label for="' . $this->get_field_id( 'sort_order' ) . '">';
600
- _e( 'Sort order ', 'avh-ec' );
601
- echo '<select id="' . $this->get_field_id( 'sort_order' ) . '" name="' . $this->get_field_name( 'sort_order' ) . '"> ';
602
- echo '<option value="asc" ' . $sort_order_a . '>' . __( 'Ascending', 'avh-ec' ) . '</option>';
603
- echo '<option value="desc" ' . $sort_order_d . '>' . __( 'Descending', 'avh-ec' ) . '</option>';
604
- echo '</select>';
605
- echo '</label>';
606
- echo '<br />';
607
 
608
- echo '<label for="' . $this->get_field_id( 'style' ) . '">';
609
- _e( 'Display style ', 'avh-ec' );
610
- echo '<select id="' . $this->get_field_id( 'style' ) . '" name="' . $this->get_field_name( 'style' ) . '"> ';
611
- echo '<option value="list" ' . $style_list . '>' . __( 'List', 'avh-ec' ) . '</option>';
612
- echo '<option value="drop" ' . $style_drop . '>' . __( 'Drop down', 'avh-ec' ) . '</option>';
613
- echo '</select>';
614
- echo '</label>';
615
- echo '<br />';
 
 
 
 
 
 
 
 
 
616
  echo '</p>';
617
 
618
  echo '<p>';
619
 
620
- echo '<label for="' . $this->get_field_id( 'rssfeed' ) . '">';
621
- echo '<input class="checkbox" type="checkbox" id="' . $this->get_field_id( 'rssfeed' ) . '" name="' . $this->get_field_name( 'rssfeed' ) . '" ' . $this->core->isChecked( TRUE, $rssfeed ) . '/> ';
622
- _e( 'Show RSS Feed', 'avh-ec' );
623
- echo '</label>';
624
- echo '<br />';
625
 
626
- echo '<label for="">';
627
- _e( 'Path (URI) to RSS image', 'avh-ec' );
628
- echo '<input class="widefat" id="' . $this->get_field_id( 'rssimage' ) . '" name="' . $this->get_field_name( 'rssimage' ) . '" type="text" value="' . $rssimage . '" />';
629
- echo '</label>';
630
  echo '</p>';
631
 
632
  echo '<input type="hidden" id="' . $this->get_field_id( 'submit' ) . '" name="' . $this->get_field_name( 'submit' ) . '" value="1" />';
@@ -683,25 +572,7 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
683
  {
684
  global $post;
685
 
686
- $catgrp = new AVH_EC_Category_Group();
687
- extract( $args );
688
-
689
- $c = $instance['count'] ? TRUE : FALSE;
690
- $e = $instance['hide_empty'] ? TRUE : FALSE;
691
- $h = $instance['hierarchical'] ? TRUE : FALSE;
692
- $use_desc_for_title = $instance['use_desc_for_title'] ? TRUE : FALSE;
693
- $s = $instance['sort_column'] ? $instance['sort_column'] : 'name';
694
- $o = $instance['sort_order'] ? $instance['sort_order'] : 'asc';
695
- $r = $instance['rssfeed'] ? 'RSS' : '';
696
- $i = $instance['rssimage'] ? $instance['rssimage'] : '';
697
-
698
- if ( empty( $r ) ) {
699
- $i = '';
700
- }
701
-
702
- $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories', 'avh-ec' ) : $instance['title'] );
703
- $style = empty( $instance['style'] ) ? 'list' : $instance['style'];
704
-
705
  $options = $this->core->getOptions();
706
 
707
  $row = array ();
@@ -721,8 +592,34 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
721
  }
722
 
723
  if ( ! ('none' == $row->name) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
724
  $group_id = $row->term_id;
725
  $cats = $catgrp->getCategoriesFromGroup( $group_id );
 
 
 
 
 
 
 
 
 
 
726
  $included_cats = implode( ',', $cats );
727
 
728
  $show_option_none = __( 'Select Category', 'avh-ec' );
@@ -815,81 +712,44 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
815
  $rssimage = esc_attr( $instance['rssimage'] );
816
 
817
  echo '<p>';
818
- echo '<label for="' . $this->get_field_id( 'title' ) . '">';
819
- _e( 'Title', 'avh-ec' );
820
- echo '<input class="widefat" id="' . $this->get_field_id( 'title' ) . '" name="' . $this->get_field_name( 'title' ) . '" type="text" value="' . $title . '" /> ';
821
- echo '</label>';
822
  echo '</p>';
823
 
824
  echo '<p>';
825
 
826
- echo '<label for="' . $this->get_field_id( 'count' ) . '">';
827
- echo '<input class="checkbox" type="checkbox" id="' . $this->get_field_id( 'count' ) . '" name="' . $this->get_field_name( 'count' ) . '" ' . $this->core->isChecked( TRUE, $count ) . ' /> ';
828
- _e( 'Show post counts', 'avh-ec' );
829
- echo '</label>';
830
- echo '<br />';
831
 
832
- echo '<label for="' . $this->get_field_id( 'hierarchical' ) . '">';
833
- echo '<input class="checkbox" type="checkbox" id="' . $this->get_field_id( 'hierarchical' ) . '" name="' . $this->get_field_name( 'hierarchical' ) . '" ' . $this->core->isChecked( TRUE, $hierarchical ) . ' /> ';
834
- _e( 'Show hierarchy', 'avh-ec' );
835
- echo '</label>';
836
- echo '<br />';
837
 
838
- echo '<label for="' . $this->get_field_id( 'hide_empty' ) . '">';
839
- echo '<input class="checkbox" type="checkbox" id="' . $this->get_field_id( 'hide_empty' ) . '" name="' . $this->get_field_name( 'hide_empty' ) . '" ' . $this->core->isChecked( TRUE, $hide_empty ) . '/> ';
840
- _e( 'Hide empty categories', 'avh-ec' );
841
- echo '</label>';
842
- echo '<br />';
843
 
844
- echo '<label for="' . $this->get_field_id( 'use_desc_for_title' ) . '">';
845
- echo '<input class="checkbox" type="checkbox" id="' . $this->get_field_id( 'use_desc_for_title' ) . '" name="' . $this->get_field_name( 'use_desc_for_title' ) . '" ' . $this->core->isChecked( TRUE, $use_desc_for_title ) . '/> ';
846
- _e( 'Use description for title', 'avh-ec' );
847
- echo '</label>';
848
- echo '<br />';
849
  echo '</p>';
850
 
851
  echo '<p>';
852
- echo '<label for="' . $this->get_field_id( 'sort_column' ) . '">';
853
- _e( 'Sort by ', 'avh-ec' );
854
- echo '<select id="' . $this->get_field_id( 'sort_column' ) . '" name="' . $this->get_field_name( 'sort_column' ) . '"> ';
855
- echo '<option value="ID" ' . $sort_id . '>' . __( 'ID', 'avh-ec' ) . '</option>';
856
- echo '<option value="name" ' . $sort_name . '>' . __( 'Name', 'avh-ec' ) . '</option>';
857
- echo '<option value="count" ' . $sort_count . '>' . __( 'Count', 'avh-ec' ) . '</option>';
858
- echo '</select>';
859
- echo '</label>';
860
- echo '<br />';
861
-
862
- echo '<label for="' . $this->get_field_id( 'sort_order' ) . '">';
863
- _e( 'Sort order ', 'avh-ec' );
864
- echo '<select id="' . $this->get_field_id( 'sort_order' ) . '" name="' . $this->get_field_name( 'sort_order' ) . '"> ';
865
- echo '<option value="asc" ' . $sort_order_a . '>' . __( 'Ascending', 'avh-ec' ) . '</option>';
866
- echo '<option value="desc" ' . $sort_order_d . '>' . __( 'Descending', 'avh-ec' ) . '</option>';
867
- echo '</select>';
868
- echo '</label>';
869
- echo '<br />';
870
-
871
- echo '<label for="' . $this->get_field_id( 'style' ) . '">';
872
- _e( 'Display style ', 'avh-ec' );
873
- echo '<select id="' . $this->get_field_id( 'style' ) . '" name="' . $this->get_field_name( 'style' ) . '"> ';
874
- echo '<option value="list" ' . $style_list . '>' . __( 'List', 'avh-ec' ) . '</option>';
875
- echo '<option value="drop" ' . $style_drop . '>' . __( 'Drop down', 'avh-ec' ) . '</option>';
876
- echo '</select>';
877
- echo '</label>';
878
- echo '<br />';
879
  echo '</p>';
880
 
881
  echo '<p>';
882
 
883
- echo '<label for="' . $this->get_field_id( 'rssfeed' ) . '">';
884
- echo '<input class="checkbox" type="checkbox" id="' . $this->get_field_id( 'rssfeed' ) . '" name="' . $this->get_field_name( 'rssfeed' ) . '" ' . $this->core->isChecked( TRUE, $rssfeed ) . '/> ';
885
- _e( 'Show RSS Feed', 'avh-ec' );
886
- echo '</label>';
887
- echo '<br />';
888
 
889
- echo '<label for="">';
890
- _e( 'Path (URI) to RSS image', 'avh-ec' );
891
- echo '<input class="widefat" id="' . $this->get_field_id( 'rssimage' ) . '" name="' . $this->get_field_name( 'rssimage' ) . '" type="text" value="' . $rssimage . '" />';
892
- echo '</label>';
893
  echo '</p>';
894
 
895
  echo '<input type="hidden" id="' . $this->get_field_id( 'submit' ) . '" name="' . $this->get_field_name( 'submit' ) . '" value="1" />';
182
  $instance = wp_parse_args( ( array ) $instance, array ('title' => '', 'rssimage' => '', 'depth' => 0 ) );
183
 
184
  // Prepare data for display
 
 
 
 
185
  $depth = ( int ) $instance['depth'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  if ( $depth < 0 || 11 < $depth ) {
187
  $depth = 0;
188
  }
189
+ $selected_cats = ($instance['post_category'] != '') ? unserialize( $instance['post_category'] ) : FALSE;
190
 
 
 
 
191
  echo '<p>';
192
+ avh_doWidgetFormText( $this->get_field_id( 'title' ), $this->get_field_name( 'title' ), __( 'Title', 'avh-ec' ), $instance['title'] );
 
 
 
193
  echo '</p>';
194
 
195
  echo '<p>';
196
+ avh_doWidgetFormCheckbox( $this->get_field_id( 'selectedonly' ), $this->get_field_name( 'selectedonly' ), __( 'Show selected categories only', 'avh-ec' ), ( bool ) $instance['selectedonly'] );
197
 
198
+ avh_doWidgetFormCheckbox( $this->get_field_id( 'count' ), $this->get_field_name( 'count' ), __( 'Show post counts', 'avh-ec' ), ( bool ) $instance['count'] );
 
 
 
 
199
 
200
+ avh_doWidgetFormCheckbox( $this->get_field_id( 'hierarchical' ), $this->get_field_name( 'hierarchical' ), __( 'Show hierarchy', 'avh-ec' ), ( bool ) $instance['hierarchical'] );
 
 
 
 
201
 
202
+ $options = array (0 => __( 'All Levels', 'avh-ec' ), 1 => __( 'Toplevel only', 'avh-ec' ) );
 
 
 
 
 
 
 
 
 
 
 
203
  for ( $i = 2; $i <= 11; $i ++ ) {
204
+ $options[$i] = __( 'Child ', 'avh-ec' ) . ($i - 1);
205
  }
206
+ avh_doWidgetFormSelect( $this->get_field_id( 'depth' ), $this->get_field_name( 'depth' ), __( 'How many levels to show', 'avh-ec' ), $options, $depth );
207
+ unset( $options );
208
 
209
+ avh_doWidgetFormCheckbox( $this->get_field_id( 'hide_empty' ), $this->get_field_name( 'hide_empty' ), __( 'Hide empty categories', 'avh-ec' ), ( bool ) $instance['hide_empty'] );
 
 
 
 
210
 
211
+ avh_doWidgetFormCheckbox( $this->get_field_id( 'use_desc_for_title' ), $this->get_field_name( 'use_desc_for_title' ), __( 'Use description for title', 'avh-ec' ), ( bool ) $instance['use_desc_for_title'] );
 
 
 
 
212
  echo '</p>';
213
 
214
  echo '<p>';
215
+ $options['ID'] = __( 'ID', 'avh-ec' );
216
+ $options['name'] = __( 'Name', 'avh-ec' );
217
+ $options['count'] = __( 'Count', 'avh-ec' );
218
+ $options['slug'] = __( 'Slug', 'avh-ec' );
219
+ avh_doWidgetFormSelect( $this->get_field_id( 'sort_column' ), $this->get_field_name( 'sort_column' ), __( 'Sort by', 'avh-ec' ), $options, $instance['sort_column'] );
220
+ unset( $options );
221
+
222
+ $options['asc'] = __( 'Ascending', 'avh-ec' );
223
+ $options['desc'] = __( 'Descending', 'avh-ec' );
224
+ avh_doWidgetFormSelect( $this->get_field_id( 'sort_order' ), $this->get_field_name( 'sort_order' ), __( 'Sort order', 'avh-ec' ), $options, $instance['sort_order'] );
225
+ unset( $options );
226
+
227
+ $options['list'] = __( 'List', 'avh-ec' );
228
+ $options['drop'] = __( 'Drop down', 'avh-ec' );
229
+ avh_doWidgetFormSelect( $this->get_field_id( 'style' ), $this->get_field_name( 'style' ), __( 'Display style', 'avh-ec' ), $options, $instance['style'] );
230
+ unset( $options );
 
 
 
 
 
 
 
 
 
 
 
231
  echo '</p>';
232
 
233
  echo '<p>';
234
 
235
+ avh_doWidgetFormCheckbox( $this->get_field_id( 'rssfeed' ), $this->get_field_name( 'rssfeed' ), __( 'Show RSS Feed', 'avh-ec' ), ( bool ) $instance['rssfeed'] );
236
+
237
+ avh_doWidgetFormText( $this->get_field_id( 'rssimage' ), $this->get_field_name( 'rssimage' ), __( 'Path (URI) to RSS image', 'avh-ec' ), $instance['rssimage'] );
 
 
238
 
 
 
 
 
239
  echo '</p>';
240
 
241
  echo '<p>';
243
  echo '<ul id="categorychecklist" class="list:category categorychecklist form-no-clear" style="list-style-type: none; margin-left: 5px; padding-left: 0px; margin-bottom: 20px;">';
244
  echo '<li id="' . $this->get_field_id( 'category--1' ) . '" class="popular-category">';
245
  echo '<label for="' . $this->get_field_id( 'post_category' ) . '" class="selectit">';
246
+ echo '<input value="all" id="' . $this->get_field_id( 'post_category' ) . '" name="' . $this->get_field_name( 'post_category' ) . '[all]" type="checkbox" ' . (FALSE === $selected_cats ? ' CHECKED' : '') . '> ';
247
  _e( 'All Categories', 'avh-ec' );
248
  echo '</label>';
249
  echo '</li>';
252
  echo '</p>';
253
 
254
  echo '<p>';
255
+ avh_doWidgetFormCheckbox( $this->get_field_id( 'invert_included' ), $this->get_field_name( 'invert_included' ), __( 'Exclude the selected categories', 'avh-ec' ), ( bool ) $instance['invert_included'] );
 
 
 
 
256
  echo '</p>';
257
 
258
  echo '<input type="hidden" id="' . $this->get_field_id( 'submit' ) . '" name="' . $this->get_field_name( 'submit' ) . '" value="1" />';
469
  $instance = wp_parse_args( ( array ) $instance, array ('title' => '', 'rssimage' => '' ) );
470
 
471
  // Prepare data for display
 
472
  if ( ! $amount = ( int ) $instance['amount'] ) {
473
  $amount = 5;
474
  }
 
 
 
 
 
 
 
 
 
 
 
475
 
476
  if ( $amount < 1 ) {
477
  $amount = 1;
478
  }
479
  echo '<p>';
480
+ avh_doWidgetFormText( $this->get_field_id( 'title' ), $this->get_field_name( 'title' ), __( 'Title', 'avh-ec' ), $instance['title'] );
 
 
 
481
  echo '</p>';
482
 
483
  echo '<p>';
484
+ avh_doWidgetFormText( $this->get_field_id( 'amount' ), $this->get_field_name( 'amount' ), __( 'How many categories to show', 'avh-ec' ), $amount );
 
 
 
 
485
  echo '</p>';
486
 
487
  echo '<p>';
488
+ avh_doWidgetFormCheckbox( $this->get_field_id( 'count' ), $this->get_field_name( 'count' ), __( 'Show post counts', 'avh-ec' ), ( bool ) $instance['count'] );
 
 
 
489
  echo '<br />';
490
 
491
+ avh_doWidgetFormCheckbox( $this->get_field_id( 'use_desc_for_title' ), $this->get_field_name( 'use_desc_for_title' ), __( 'Use description for title', 'avh-ec' ), ( bool ) $instance['use_desc_for_title'] );
492
+ echo '</p>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
493
 
494
+ echo '<p>';
495
+ $options['ID'] = __( 'ID', 'avh-ec' );
496
+ $options['name'] = __( 'Name', 'avh-ec' );
497
+ $options['count'] = __( 'Count', 'avh-ec' );
498
+ $options['slug'] = __( 'Slug', 'avh-ec' );
499
+ avh_doWidgetFormSelect( $this->get_field_id( 'sort_column' ), $this->get_field_name( 'sort_column' ), __( 'Sort by', 'avh-ec' ), $options, $instance['sort_column'] );
500
+ unset( $options );
501
+
502
+ $options['asc'] = __( 'Ascending', 'avh-ec' );
503
+ $options['desc'] = __( 'Descending', 'avh-ec' );
504
+ avh_doWidgetFormSelect( $this->get_field_id( 'sort_order' ), $this->get_field_name( 'sort_order' ), __( 'Sort order', 'avh-ec' ), $options, $instance['sort_order'] );
505
+ unset( $options );
506
+
507
+ $options['list'] = __( 'List', 'avh-ec' );
508
+ $options['drop'] = __( 'Drop down', 'avh-ec' );
509
+ avh_doWidgetFormSelect( $this->get_field_id( 'style' ), $this->get_field_name( 'style' ), __( 'Display style', 'avh-ec' ), $options, $instance['style'] );
510
+ unset( $options );
511
  echo '</p>';
512
 
513
  echo '<p>';
514
 
515
+ avh_doWidgetFormCheckbox( $this->get_field_id( 'rssfeed' ), $this->get_field_name( 'rssfeed' ), __( 'Show RSS Feed', 'avh-ec' ), ( bool ) $instance['rssfeed'] );
516
+
517
+ avh_doWidgetFormText( $this->get_field_id( 'rssimage' ), $this->get_field_name( 'rssimage' ), __( 'Path (URI) to RSS image', 'avh-ec' ), $instance['rssimage'] );
 
 
518
 
 
 
 
 
519
  echo '</p>';
520
 
521
  echo '<input type="hidden" id="' . $this->get_field_id( 'submit' ) . '" name="' . $this->get_field_name( 'submit' ) . '" value="1" />';
572
  {
573
  global $post;
574
 
575
+ $catgrp = & AVH_EC_Singleton::getInstance( 'AVH_EC_Category_Group' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
576
  $options = $this->core->getOptions();
577
 
578
  $row = array ();
592
  }
593
 
594
  if ( ! ('none' == $row->name) ) {
595
+ extract( $args );
596
+
597
+ $c = $instance['count'] ? TRUE : FALSE;
598
+ $e = $instance['hide_empty'] ? TRUE : FALSE;
599
+ $h = $instance['hierarchical'] ? TRUE : FALSE;
600
+ $use_desc_for_title = $instance['use_desc_for_title'] ? TRUE : FALSE;
601
+ $s = $instance['sort_column'] ? $instance['sort_column'] : 'name';
602
+ $o = $instance['sort_order'] ? $instance['sort_order'] : 'asc';
603
+ $r = $instance['rssfeed'] ? 'RSS' : '';
604
+ $i = $instance['rssimage'] ? $instance['rssimage'] : '';
605
+
606
+ if ( empty( $r ) ) {
607
+ $i = '';
608
+ }
609
+
610
+ $style = empty( $instance['style'] ) ? 'list' : $instance['style'];
611
  $group_id = $row->term_id;
612
  $cats = $catgrp->getCategoriesFromGroup( $group_id );
613
+ if ( empty( $instance['title'] ) ) {
614
+ $title = $catgrp->getWidgetTitleForGroup( $group_id );
615
+ if ( ! $title ) {
616
+ $title = __( 'Categories', 'avh-ec' );
617
+ }
618
+ } else {
619
+ $title = $instance['title'];
620
+ }
621
+ $title = apply_filters( 'widget_title', $title );
622
+
623
  $included_cats = implode( ',', $cats );
624
 
625
  $show_option_none = __( 'Select Category', 'avh-ec' );
712
  $rssimage = esc_attr( $instance['rssimage'] );
713
 
714
  echo '<p>';
715
+ avh_doWidgetFormText( $this->get_field_id( 'title' ), $this->get_field_name( 'title' ), __( 'Title', 'avh-ec' ), $instance['title'] );
 
 
 
716
  echo '</p>';
717
 
718
  echo '<p>';
719
 
720
+ avh_doWidgetFormCheckbox( $this->get_field_id( 'count' ), $this->get_field_name( 'count' ), __( 'Show post counts', 'avh-ec' ), ( bool ) $instance['count'] );
 
 
 
 
721
 
722
+ avh_doWidgetFormCheckbox( $this->get_field_id( 'hierarchical' ), $this->get_field_name( 'hierarchical' ), __( 'Show hierarchy', 'avh-ec' ), ( bool ) $instance['hierarchical'] );
 
 
 
 
723
 
724
+ avh_doWidgetFormCheckbox( $this->get_field_id( 'hide_empty' ), $this->get_field_name( 'hide_empty' ), __( 'Hide empty categories', 'avh-ec' ), ( bool ) $instance['hide_empty'] );
 
 
 
 
725
 
726
+ avh_doWidgetFormCheckbox( $this->get_field_id( 'use_desc_for_title' ), $this->get_field_name( 'use_desc_for_title' ), __( 'Use description for title', 'avh-ec' ), ( bool ) $instance['use_desc_for_title'] );
 
 
 
 
727
  echo '</p>';
728
 
729
  echo '<p>';
730
+ $options['ID'] = __( 'ID', 'avh-ec' );
731
+ $options['name'] = __( 'Name', 'avh-ec' );
732
+ $options['count'] = __( 'Count', 'avh-ec' );
733
+ $options['slug'] = __( 'Slug', 'avh-ec' );
734
+ avh_doWidgetFormSelect( $this->get_field_id( 'sort_column' ), $this->get_field_name( 'sort_column' ), __( 'Sort by', 'avh-ec' ), $options, $instance['sort_column'] );
735
+ unset( $options );
736
+
737
+ $options['asc'] = __( 'Ascending', 'avh-ec' );
738
+ $options['desc'] = __( 'Descending', 'avh-ec' );
739
+ avh_doWidgetFormSelect( $this->get_field_id( 'sort_order' ), $this->get_field_name( 'sort_order' ), __( 'Sort order', 'avh-ec' ), $options, $instance['sort_order'] );
740
+ unset( $options );
741
+
742
+ $options['list'] = __( 'List', 'avh-ec' );
743
+ $options['drop'] = __( 'Drop down', 'avh-ec' );
744
+ avh_doWidgetFormSelect( $this->get_field_id( 'style' ), $this->get_field_name( 'style' ), __( 'Display style', 'avh-ec' ), $options, $instance['style'] );
745
+ unset( $options );
 
 
 
 
 
 
 
 
 
 
 
746
  echo '</p>';
747
 
748
  echo '<p>';
749
 
750
+ avh_doWidgetFormCheckbox( $this->get_field_id( 'rssfeed' ), $this->get_field_name( 'rssfeed' ), __( 'Show RSS Feed', 'avh-ec' ), ( bool ) $instance['rssfeed'] );
 
 
 
 
751
 
752
+ avh_doWidgetFormText( $this->get_field_id( 'rssimage' ), $this->get_field_name( 'rssimage' ), __( 'Path (URI) to RSS image', 'avh-ec' ), $instance['rssimage'] );
 
 
 
753
  echo '</p>';
754
 
755
  echo '<input type="hidden" id="' . $this->get_field_id( 'submit' ) . '" name="' . $this->get_field_name( 'submit' ) . '" value="1" />';
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: petervanderdoes
3
  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: 2.9.1
7
- Stable tag: 3.1
8
 
9
  The AVH Extended Categories Widgets gives you three widgets for displaying categories.
10
  == Description ==
@@ -25,7 +25,7 @@ The replacement widget gives you the following customizable options:
25
  * Hide empty categories.
26
  * Show categories hierarchical.
27
  * Show categories up to a certain depth. (Requires WordPress 2.8 or higher).
28
- * Sort by ID, Name,Count.
29
  * Sort ascending or descending.
30
  * Show RSS link after the category as text or image.
31
  * Select which categories to show. (Requires WordPress 2.5.1 or higher).
@@ -36,18 +36,18 @@ The Top Categories widget gives you the following customizable options:
36
  * How many categories to show.
37
  * Display as List or Drop-down.
38
  * Show number of posts (Count) after the category.
39
- * Sort by ID, Name,Count.
40
  * Sort ascending or descending.
41
  * Show RSS link after the category as text or image.
42
  * Select which categories to show. (Requires WordPress 2.5.1 or higher).
43
 
44
  The Category Group widget gives you the following customizable options:
45
 
46
- * Title of the widget.
47
  * Display as List or Drop-down.
48
  * Show number of posts (Count) after the category.
49
  * Hide empty categories.
50
- * Sort by ID, Name,Count.
51
  * Sort ascending or descending.
52
  * Show RSS link after the category as text or image.
53
 
@@ -99,6 +99,12 @@ I have also setup a project in Launchpad for translating the plug-in. Just visit
99
  None
100
 
101
  == Changelog ==
 
 
 
 
 
 
102
  = Version 3.1 =
103
  * Wrap the group widget in a div with id = name of group. This enables CSS modification based on the group.
104
  * Hierarchical now works with the option "Select Categories" as well.
@@ -187,4 +193,4 @@ None
187
  * Drop down menu didn't work. Page wasn't refreshed with selected category.
188
 
189
  = Version 1.0 =
190
- * Initial version
3
  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
8
 
9
  The AVH Extended Categories Widgets gives you three widgets for displaying categories.
10
  == Description ==
25
  * Hide empty categories.
26
  * Show categories hierarchical.
27
  * Show categories up to a certain depth. (Requires WordPress 2.8 or higher).
28
+ * Sort by ID, Name, Count, Slug.
29
  * Sort ascending or descending.
30
  * Show RSS link after the category as text or image.
31
  * Select which categories to show. (Requires WordPress 2.5.1 or higher).
36
  * How many categories to show.
37
  * Display as List or Drop-down.
38
  * Show number of posts (Count) after the category.
39
+ * Sort by ID, Name, Count, Slug.
40
  * Sort ascending or descending.
41
  * Show RSS link after the category as text or image.
42
  * Select which categories to show. (Requires WordPress 2.5.1 or higher).
43
 
44
  The Category Group widget gives you the following customizable options:
45
 
46
+ * Title of the widget. Either per widget or per group.
47
  * Display as List or Drop-down.
48
  * Show number of posts (Count) after the category.
49
  * Hide empty categories.
50
+ * Sort by ID, Name, Count, Slug.
51
  * Sort ascending or descending.
52
  * Show RSS link after the category as text or image.
53
 
99
  None
100
 
101
  == Changelog ==
102
+ = Version 3.2 =
103
+ * Compatibility issues with upcoming WordPress 3 resolved.
104
+ * Bugfix: Description of the groups didn't save.
105
+ * RFC: All widgets - Option to sort the categories by slug.
106
+ * RFC: Category Group widget - Ability to set the widget title per group.
107
+
108
  = Version 3.1 =
109
  * Wrap the group widget in a div with id = name of group. This enables CSS modification based on the group.
110
  * Hierarchical now works with the option "Select Categories" as well.
193
  * Drop down menu didn't work. Page wasn't refreshed with selected category.
194
 
195
  = Version 1.0 =
196
+ * Initial version
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.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';
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.1
7
  Author: Peter van der Does
8
  Author URI: http://blog.avirtualhome.com/
9
 
@@ -28,8 +28,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
  require (ABSPATH . WPINC . '/version.php');
29
 
30
  global $plugin;
31
- $dir = current( explode( '/', $plugin ) );
32
  $pluginname = plugin_basename( trim( $plugin ) );
 
33
 
34
  define( 'AVHEC_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . $dir );
35
  define( 'AVHEC_PLUGIN_NAME', $pluginname );
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
7
  Author: Peter van der Does
8
  Author URI: http://blog.avirtualhome.com/
9
 
28
  require (ABSPATH . WPINC . '/version.php');
29
 
30
  global $plugin;
31
+
32
  $pluginname = plugin_basename( trim( $plugin ) );
33
+ $dir = current( explode( '/', $pluginname ) );
34
 
35
  define( 'AVHEC_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . $dir );
36
  define( 'AVHEC_PLUGIN_NAME', $pluginname );