AVH Extended Categories Widgets - Version 3.3.3

Version Description

Download this release

Release Info

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

Code changes from version 3.3.2 to 3.3.3

.gitignore CHANGED
@@ -1 +1,4 @@
1
  .project
 
 
 
1
  .project
2
+ /.buildpath
3
+ /.settings
4
+ /.gitignore
2.8/avh-ec.client.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Singleton Class
4
  *
@@ -11,33 +12,33 @@ class AVH_EC_Singleton
11
  * @param $class
12
  * @param $arg1
13
  */
14
- function &getInstance ( $class, $arg1 = null )
15
  {
16
- static $instances = array (); // array of instance names
17
- if ( array_key_exists( $class, $instances ) ) {
18
  $instance = & $instances[$class];
19
  } else {
20
- if ( ! class_exists( $class ) ) {
21
- switch ( $class )
22
- {
23
- case 'AVH_EC_Core' :
24
  require_once (AVHEC_ABSOLUTE_WORKING_DIR . '/class/avh-ec.core.php');
25
  break;
26
- case 'AVH_EC_Category_Group' :
27
  require_once (AVHEC_ABSOLUTE_WORKING_DIR . '/class/avh-ec.category-group.php');
28
  break;
29
- case 'AVH_EC_Widget_Helper_Class' :
30
  require_once (AVHEC_ABSOLUTE_WORKING_DIR . '/class/avh-ec.widget-helper.php');
31
  break;
32
  }
33
  }
34
- $instances[$class] = new $class( $arg1 );
35
  $instance = & $instances[$class];
36
  }
37
  return $instance;
38
  } // getInstance
39
  } // singleton
40
 
 
41
  /**
42
  * Include the necessary files
43
  *
@@ -52,11 +53,11 @@ require_once (AVHEC_ABSOLUTE_WORKING_DIR . '/class/avh-ec.widgets.php');
52
  function avhextendedcategories_init ()
53
  {
54
  // Admin
55
- if ( is_admin() ) {
56
  require_once (AVHEC_ABSOLUTE_WORKING_DIR . '/class/avh-ec.admin.php');
57
  $avhec_admin = new AVH_EC_Admin();
58
  }
59
- add_action( 'widgets_init', 'avhextendedcategories_widgets_init' );
60
 
61
  } // End avhamazon_init()
62
 
@@ -70,10 +71,10 @@ function avhextendedcategories_init ()
70
  */
71
  function avhextendedcategories_widgets_init ()
72
  {
73
- register_widget( 'WP_Widget_AVH_ExtendedCategories_Normal' );
74
- register_widget( 'WP_Widget_AVH_ExtendedCategories_Top' );
75
- register_widget( 'WP_Widget_AVH_ExtendedCategories_Category_Group' );
76
  }
77
 
78
- add_action( 'plugins_loaded', 'avhextendedcategories_init' );
79
  ?>
1
  <?php
2
+
3
  /**
4
  * Singleton Class
5
  *
12
  * @param $class
13
  * @param $arg1
14
  */
15
+ function &getInstance ($class, $arg1 = null)
16
  {
17
+ static $instances = array(); // array of instance names
18
+ if (array_key_exists($class, $instances)) {
19
  $instance = & $instances[$class];
20
  } else {
21
+ if (! class_exists($class)) {
22
+ switch ($class) {
23
+ case 'AVH_EC_Core':
 
24
  require_once (AVHEC_ABSOLUTE_WORKING_DIR . '/class/avh-ec.core.php');
25
  break;
26
+ case 'AVH_EC_Category_Group':
27
  require_once (AVHEC_ABSOLUTE_WORKING_DIR . '/class/avh-ec.category-group.php');
28
  break;
29
+ case 'AVH_EC_Widget_Helper_Class':
30
  require_once (AVHEC_ABSOLUTE_WORKING_DIR . '/class/avh-ec.widget-helper.php');
31
  break;
32
  }
33
  }
34
+ $instances[$class] = new $class($arg1);
35
  $instance = & $instances[$class];
36
  }
37
  return $instance;
38
  } // getInstance
39
  } // singleton
40
 
41
+
42
  /**
43
  * Include the necessary files
44
  *
53
  function avhextendedcategories_init ()
54
  {
55
  // Admin
56
+ if (is_admin()) {
57
  require_once (AVHEC_ABSOLUTE_WORKING_DIR . '/class/avh-ec.admin.php');
58
  $avhec_admin = new AVH_EC_Admin();
59
  }
60
+ add_action('widgets_init', 'avhextendedcategories_widgets_init');
61
 
62
  } // End avhamazon_init()
63
 
71
  */
72
  function avhextendedcategories_widgets_init ()
73
  {
74
+ register_widget('WP_Widget_AVH_ExtendedCategories_Normal');
75
+ register_widget('WP_Widget_AVH_ExtendedCategories_Top');
76
+ register_widget('WP_Widget_AVH_ExtendedCategories_Category_Group');
77
  }
78
 
79
+ add_action('plugins_loaded', 'avhextendedcategories_init');
80
  ?>
2.8/class/avh-ec.admin.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  class AVH_EC_Admin
3
  {
4
  /**
@@ -6,14 +7,14 @@ class AVH_EC_Admin
6
  * @var AVH_EC_Core
7
  */
8
  var $core;
9
-
10
  /**
11
  *
12
  * @var AVH_EC_Category_Group
13
  */
14
  var $catgrp;
15
-
16
- var $hooks = array ();
17
  var $message;
18
 
19
  /**
@@ -22,28 +23,28 @@ class AVH_EC_Admin
22
  */
23
  function __construct ()
24
  {
25
-
26
  // Initialize the plugin
27
- $this->core = & AVH_EC_Singleton::getInstance( 'AVH_EC_Core' );
28
- $this->catgrp = & AVH_EC_Singleton::getInstance( 'AVH_EC_Category_Group' );
29
-
30
- add_action( 'wp_ajax_delete-group', array (&$this, 'ajaxDeleteGroup' ) );
31
-
32
  // Admin menu
33
- add_action( 'admin_menu', array (&$this, 'actionAdminMenu' ) );
34
- add_filter( 'plugin_action_links_extended-categories-widget/widget_extended_categories.php', array (&$this, 'filterPluginActions' ), 10, 2 );
35
-
36
  // Actions used for editing posts
37
- add_action( 'load-post.php', array (&$this, 'actionLoadPostPage' ) );
38
- add_action( 'load-page.php', array (&$this, 'actionLoadPostPage' ) );
39
-
40
  // Actions related to adding and deletes categories
41
- add_action( "created_category", array ($this, 'actionCreatedCategory' ), 10, 2 );
42
- add_action( "delete_category", array ($this, 'actionDeleteCategory' ), 10, 2 );
43
-
44
- add_filter( 'manage_categories_group_columns', array (&$this, 'filterManageCategoriesGroupColumns' ) );
45
- add_filter( 'explain_nonce_delete-avhecgroup', array (&$this, 'filterExplainNonceDeleteGroup' ), 10, 2 );
46
-
47
  return;
48
  }
49
 
@@ -61,10 +62,10 @@ class AVH_EC_Admin
61
  * @param $term_id
62
  * @param $term_taxonomy_id
63
  */
64
- function actionCreatedCategory ( $term_id, $term_taxonomy_id )
65
  {
66
- $group_id = $this->catgrp->getTermIDBy( 'slug', 'all' );
67
- $this->catgrp->setCategoriesForGroup( $group_id, ( array ) $term_id );
68
  }
69
 
70
  /**
@@ -73,9 +74,9 @@ class AVH_EC_Admin
73
  * @param object $term
74
  * @param int $term_taxonomy_id
75
  */
76
- function actionDeleteCategory ( $term_id, $term_taxonomy_id )
77
  {
78
- $this->catgrp->doDeleteCategoryFromGroup( $term_id );
79
  }
80
 
81
  /**
@@ -85,7 +86,7 @@ class AVH_EC_Admin
85
  */
86
  function actionLoadPostPage ()
87
  {
88
- wp_enqueue_style( 'avhec-admin-css' );
89
  }
90
 
91
  /**
@@ -96,32 +97,32 @@ class AVH_EC_Admin
96
  */
97
  function actionAdminMenu ()
98
  {
99
-
100
  // Register Style and Scripts
101
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
102
- wp_register_script( 'avhec-categorygroup-js', AVHEC_PLUGIN_URL . '/js/avh-ec.categorygroup' . $suffix . '.js', array ('jquery' ), $this->core->version, true );
103
- wp_register_style( 'avhec-admin-css', AVHEC_PLUGIN_URL . '/css/avh-ec.admin.css', array ('wp-admin' ), $this->core->version, 'screen' );
104
-
105
  // Add menu system
106
- $folder = $this->core->getBaseDirectory( AVHEC_PLUGIN_DIR );
107
- add_menu_page( 'AVH Extended Categories', 'AVH Extended Categories', 'manage_options', $folder, array (&$this, 'doMenuOverview' ) );
108
- $this->hooks['menu_overview'] = add_submenu_page( $folder, 'AVH Extended Categories: ' . __( 'Overview', 'avh-ec' ), __( 'Overview', 'avh-ec' ), 'manage_options', $folder, array (&$this, 'doMenuOverview' ) );
109
- $this->hooks['menu_general'] = add_submenu_page( $folder, 'AVH Extended Categories: ' . __( 'General Options', 'avh-ec' ), __( 'General Options', 'avh-ec' ), 'manage_options', 'avhec-general', array (&$this, 'doMenuGeneral' ) );
110
- $this->hooks['menu_category_groups'] = add_submenu_page( $folder, 'AVH Extended Categories: ' . __( 'Category Groups', 'avh-ec' ), __( 'Category Groups', 'avh-ec' ), 'manage_options', 'avhec-grouped', array (&$this, 'doMenuCategoryGroup' ) );
111
- $this->hooks['menu_faq'] = add_submenu_page( $folder, 'AVH Extended Categories:' . __( 'F.A.Q', 'avh-ec' ), __( 'F.A.Q', 'avh-ec' ), 'manage_options', 'avhec-faq', array (&$this, 'doMenuFAQ' ) );
112
-
113
  // Add actions for menu pages
114
  // Overview Menu
115
- add_action( 'load-' . $this->hooks['menu_overview'], array (&$this, 'actionLoadPageHook_Overview' ) );
116
-
117
  // General Options Menu
118
- add_action( 'load-' . $this->hooks['menu_general'], array (&$this, 'actionLoadPageHook_General' ) );
119
-
120
  // Category Groups Menu
121
- add_action( 'load-' . $this->hooks['menu_category_groups'], array (&$this, 'actionLoadPageHook_CategoryGroup' ) );
122
-
123
  // FAQ Menu
124
- add_action( 'load-' . $this->hooks['menu_faq'], array (&$this, 'actionLoadPageHook_faq' ) );
125
  }
126
 
127
  /**
@@ -131,23 +132,23 @@ class AVH_EC_Admin
131
  function actionLoadPageHook_Overview ()
132
  {
133
  // Add metaboxes
134
- add_meta_box( 'avhecBoxCategoryGroupList', __( 'Group Overview', 'avh-ec' ), array (&$this, 'metaboxCategoryGroupList' ), $this->hooks['menu_overview'], 'normal', 'core' );
135
-
136
- add_filter( 'screen_layout_columns', array (&$this, 'filterScreenLayoutColumns' ), 10, 2 );
137
-
138
  // WordPress core Scripts
139
- wp_enqueue_script( 'common' );
140
- wp_enqueue_script( 'wp-lists' );
141
- wp_enqueue_script( 'postbox' );
142
-
143
  // Plugin Scripts
144
- wp_enqueue_script( 'avhec-categorygroup-js' );
145
-
146
  // WordPress core Styles
147
- wp_admin_css( 'css/dashboard' );
148
-
149
  // Plugin Style
150
- wp_enqueue_style( 'avhec-admin-css' );
151
  }
152
 
153
  /**
@@ -158,42 +159,41 @@ class AVH_EC_Admin
158
  function doMenuOverview ()
159
  {
160
  global $screen_layout_columns;
161
-
162
  // This box can't be unselectd in the the Screen Options
163
- add_meta_box( 'avhecBoxAnnouncements', __( 'Announcements', 'avh-ec' ), array (&$this, 'metaboxAnnouncements' ), $this->hooks['menu_overview'], 'side', '' );
164
- add_meta_box( 'avhecBoxDonations', __( 'Donations', 'avh-ec' ), array (&$this, 'metaboxDonations' ), $this->hooks['menu_overview'], 'side', '' );
165
-
166
  $hide2 = '';
167
- switch ( $screen_layout_columns )
168
- {
169
- case 2 :
170
  $width = 'width:49%;';
171
  break;
172
- default :
173
  $width = 'width:98%;';
174
  $hide2 = 'display:none;';
175
  }
176
-
177
- echo '<div class="wrap avhec-wrap">';
178
- echo $this->displayIcon( 'index' );
179
- echo '<h2>' . 'AVH Extended Categories - ' . __( 'Overview', 'avh-ec' ) . '</h2>';
180
  echo ' <div id="dashboard-widgets-wrap">';
181
  echo ' <div id="dashboard-widgets" class="metabox-holder">';
182
  echo ' <div class="postbox-container" style="' . $width . '">' . "\n";
183
- do_meta_boxes( $this->hooks['menu_overview'], 'normal', '' );
184
  echo " </div>";
185
  echo ' <div class="postbox-container" style="' . $hide2 . $width . '">' . "\n";
186
- do_meta_boxes( $this->hooks['menu_overview'], 'side', '' );
187
  echo ' </div>';
188
  echo ' </div>';
189
-
190
  echo '<br class="clear"/>';
191
  echo ' </div>'; //dashboard-widgets-wrap
192
  echo '</div>'; // wrap
193
-
194
 
195
  $this->printMetaboxGeneralNonces();
196
- $this->printMetaboxJS( 'overview' );
197
  $this->printAdminFooter();
198
  }
199
 
@@ -204,21 +204,21 @@ class AVH_EC_Admin
204
  function actionLoadPageHook_General ()
205
  {
206
  // Add metaboxes
207
- add_meta_box( 'avhecBoxOptions', __( 'Options', 'avh-ec' ), array (&$this, 'metaboxOptions' ), $this->hooks['menu_general'], 'normal', 'core' );
208
-
209
- add_filter( 'screen_layout_columns', array (&$this, 'filterScreenLayoutColumns' ), 10, 2 );
210
-
211
  // WordPress core Scripts
212
- wp_enqueue_script( 'common' );
213
- wp_enqueue_script( 'wp-lists' );
214
- wp_enqueue_script( 'postbox' );
215
-
216
  // WordPress core Styles
217
- wp_admin_css( 'css/dashboard' );
218
-
219
  // Plugin Style and Scripts
220
- wp_enqueue_style( 'avhec-admin-css' );
221
-
222
  }
223
 
224
  /**
@@ -229,118 +229,114 @@ class AVH_EC_Admin
229
  function doMenuGeneral ()
230
  {
231
  global $screen_layout_columns;
232
-
233
- $groups = get_terms( $this->catgrp->taxonomy_name, array ('hide_empty' => FALSE ) );
234
- foreach ( $groups as $group ) {
235
  $group_id[] = $group->term_id;
236
  $groupname[] = $group->name;
237
  }
238
-
239
- $options_general[] = array ('avhec[general][alternative_name_select_category]', __('<em>Select Category</em> Alternative','avh-ec'), 'text', 20, __('Alternative text for Select Category.','avh-ec') );
240
- $options_general[] = array ('avhec[cat_group][home_group]', 'Home Group', 'dropdown', $group_id, $groupname, __('Select which group to show on the home page.<br />Selecting the group \'none\' will not show the widget on the page.','avh-ec') );
241
- $options_general[] = array ('avhec[cat_group][no_group]', 'Nonexistence Group', 'dropdown', $group_id, $groupname, __('Select which group to show when there is no group associated with the post.<br />Selecting the group \'none\' will not show the widget on the page.','avh-ec') );
242
- $options_general[] = array ('avhec[cat_group][default_group]', 'Default Group', 'dropdown', $group_id, $groupname, __('Select which group will be the default group when editing a post.<br />Selecting the group \'none\' will not show the widget on the page.','avh-ec') );
243
-
244
- if ( isset( $_POST['updateoptions'] ) ) {
245
- check_admin_referer( 'avh_ec_generaloptions' );
246
-
247
  $formoptions = $_POST['avhec'];
248
  $options = $this->core->getOptions();
249
-
250
  //$all_data = array_merge( $options_general );
251
  $all_data = $options_general;
252
- foreach ( $all_data as $option ) {
253
- $section = substr( $option[0], strpos( $option[0], '[' ) + 1 );
254
- $section = substr( $section, 0, strpos( $section, '][' ) );
255
- $option_key = rtrim( $option[0], ']' );
256
- $option_key = substr( $option_key, strpos( $option_key, '][' ) + 2 );
257
-
258
- switch ( $section )
259
- {
260
- case 'general' :
261
- case 'cat_group' :
262
  $current_value = $options[$section][$option_key];
263
  break;
264
  }
265
  // Every field in a form is set except unchecked checkboxes. Set an unchecked checkbox to 0.
266
- $newval = (isset( $formoptions[$section][$option_key] ) ? attribute_escape( $formoptions[$section][$option_key] ) : 0);
267
- if ( $newval != $current_value ) { // Only process changed fields.
268
- switch ( $section )
269
- {
270
- case 'general' :
271
- case 'cat_group' :
272
  $options[$section][$option_key] = $newval;
273
  break;
274
  }
275
  }
276
  }
277
- $this->core->saveOptions( $options );
278
- $this->message = __( 'Options saved', 'avh-ec' );
279
  $this->status = 'updated fade';
280
-
281
  }
282
  $this->displayMessage();
283
-
284
  $actual_options = $this->core->getOptions();
285
- foreach ( $actual_options['cat_group'] as $key => $value ) {
286
- if ( ! (in_array( $value, ( array ) $group_id )) ) {
287
- $actual_options['cat_group'][$key] = $this->catgrp->getTermIDBy( 'slug', 'none' );
288
  }
289
  }
290
-
291
  $hide2 = '';
292
- switch ( $screen_layout_columns )
293
- {
294
- case 2 :
295
  $width = 'width:49%;';
296
  break;
297
- default :
298
  $width = 'width:98%;';
299
  $hide2 = 'display:none;';
300
  }
301
  $data['options_general'] = $options_general;
302
  $data['actual_options'] = $actual_options;
303
-
304
  // This box can't be unselectd in the the Screen Options
305
- add_meta_box( 'avhecBoxDonations', __( 'Donations', 'avh-ec' ), array (&$this, 'metaboxDonations' ), $this->hooks['menu_general'], 'side', 'core' );
306
-
307
  $hide2 = '';
308
- switch ( $screen_layout_columns )
309
- {
310
- case 2 :
311
  $width = 'width:49%;';
312
  break;
313
- default :
314
  $width = 'width:98%;';
315
  $hide2 = 'display:none;';
316
  }
317
-
318
- echo '<div class="wrap avhec-wrap">';
319
- echo $this->displayIcon( 'index' );
320
- echo '<h2>' . 'AVH Extended Categories - ' . __( 'General Options', 'avh-ec' ) . '</h2>';
321
  echo '<form name="avhec-generaloptions" id="avhec-generaloptions" method="POST" action="' . admin_url('admin.php?page=avhec-general') . '" accept-charset="utf-8" >';
322
- wp_nonce_field( 'avh_ec_generaloptions' );
323
-
324
  echo ' <div id="dashboard-widgets-wrap">';
325
  echo ' <div id="dashboard-widgets" class="metabox-holder">';
326
  echo ' <div class="postbox-container" style="' . $width . '">' . "\n";
327
- do_meta_boxes( $this->hooks['menu_general'], 'normal', $data );
328
  echo " </div>";
329
  echo ' <div class="postbox-container" style="' . $hide2 . $width . '">' . "\n";
330
- do_meta_boxes( $this->hooks['menu_general'], 'side', $data );
331
  echo ' </div>';
332
  echo ' </div>';
333
-
334
  echo '<br class="clear"/>';
335
  echo ' </div>'; //dashboard-widgets-wrap
336
- echo '<p class="submit"><input class="button" type="submit" name="updateoptions" value="' . __( 'Save Changes', 'avhf-ec' ) . '" /></p>';
337
  echo '</form>';
338
-
339
  echo '</div>'; // wrap
340
-
341
 
342
  $this->printMetaboxGeneralNonces();
343
- $this->printMetaboxJS( 'general' );
344
  $this->printAdminFooter();
345
  }
346
 
@@ -348,9 +344,9 @@ class AVH_EC_Admin
348
  * Options Metabox
349
  *
350
  */
351
- function metaboxOptions ( $data )
352
  {
353
- echo $this->printOptions( $data['options_general'], $data['actual_options'] );
354
  }
355
 
356
  /**
@@ -359,27 +355,27 @@ class AVH_EC_Admin
359
  */
360
  function actionLoadPageHook_CategoryGroup ()
361
  {
362
-
363
  // Add metaboxes
364
- add_meta_box( 'avhecBoxCategoryGroupAdd', __( 'Add Group', 'avh-ec' ), array (&$this, 'metaboxCategoryGroupAdd' ), $this->hooks['menu_category_groups'], 'normal', 'core' );
365
- add_meta_box( 'avhecBoxCategoryGroupList', __( 'Group Overview', 'avh-ec' ), array (&$this, 'metaboxCategoryGroupList' ), $this->hooks['menu_category_groups'], 'side', 'core' );
366
- add_meta_box( 'avhecBoxCategoryGroupSpecialPages', __( 'Special Pages', 'avh-ec' ), array (&$this, 'metaboxCategoryGroupSpecialPages' ), $this->hooks['menu_category_groups'], 'normal', 'core' );
367
-
368
- add_filter( 'screen_layout_columns', array (&$this, 'filterScreenLayoutColumns' ), 10, 2 );
369
  // WordPress core Scripts
370
- wp_enqueue_script( 'common' );
371
- wp_enqueue_script( 'wp-lists' );
372
- wp_enqueue_script( 'postbox' );
373
-
374
  // Plugin Scripts
375
- wp_enqueue_script( 'avhec-categorygroup-js' );
376
-
377
  // WordPress core Styles
378
- wp_admin_css( 'css/dashboard' );
379
-
380
  // Plugin Style
381
- wp_enqueue_style( 'avhec-admin-css' );
382
-
383
  }
384
 
385
  /**
@@ -390,185 +386,181 @@ class AVH_EC_Admin
390
  function doMenuCategoryGroup ()
391
  {
392
  global $screen_layout_columns;
393
-
394
- $data_add_group_default = array ('name' => '', 'slug' => '', 'widget_title' => '', 'description' => '' );
395
  $data_add_group_new = $data_add_group_default;
396
-
397
- $options_add_group[] = array ('avhec_add_group[add][name]', __(' Group Name','avh-ec'), 'text', 20, __('The name is used to identify the group.','avh-ec') );
398
- $options_add_group[] = array ('avhec_add_group[add][slug]', __(' Slug Group','avh-ec'), 'text', 20, __('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.','avh-ec') );
399
- $options_add_group[] = array ('avhec_add_group[add][widget_title]', __(' Widget Title,','avh-ec'), '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.','avh-ec') );
400
- $options_add_group[] = array ('avhec_add_group[add][description]', __(' Description','avh-ec'), 'textarea', 40, __('Description is not prominent by default.','avh-ec'), 5 );
401
-
402
- $options_edit_group[] = array ('avhec_edit_group[edit][name]', __(' Group Name','avh-ec'), 'text', 20, __('The name is used to identify the group.','avh-ec') );
403
- $options_edit_group[] = array ('avhec_edit_group[edit][slug]', __(' Slug Group','avh-ec'), 'text', 20, __('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.','avh-ec') );
404
- $options_edit_group[] = array ('avhec_edit_group[edit][widget_title]', __(' Widget Title','avh-ec'), '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.','avh-ec') );
405
- $options_edit_group[] = array ('avhec_edit_group[edit][description]', __(' Description','avh-ec'), 'textarea', 40, __('Description is not prominent by default.','avh-ec'), 5 );
406
- $options_edit_group[] = array ('avhec_edit_group[edit][categories]', __(' Categories','avh-ec'), 'catlist', 0, __('Select categories to be included in the group.','avh-ec') );
407
-
408
-
409
- if ( isset( $_POST['addgroup'] ) ) {
410
- check_admin_referer( 'avh_ec_addgroup' );
411
-
412
  $formoptions = $_POST['avhec_add_group'];
413
-
414
  $data_add_group_new['name'] = $formoptions['add']['name'];
415
- $data_add_group_new['slug'] = empty( $formoptions['add']['slug'] ) ? sanitize_title( $data_add_group_new['name'] ) : sanitize_title( $formoptions['add']['slug'] );
416
  $data_add_group_new['widget_title'] = $formoptions['add']['widget_title'];
417
  $data_add_group_new['description'] = $formoptions['add']['description'];
418
-
419
- $id = $this->catgrp->getTermIDBy( 'slug', $data_add_group_new['slug'] );
420
- if ( ! $id ) {
421
- $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'] );
422
- $this->catgrp->setCategoriesForGroup( $group_id );
423
- $this->message = __( 'Category group saved', 'avh-ec' );
424
  $this->status = 'updated fade';
425
  $data_add_group_new = $data_add_group_default;
426
-
427
  } else {
428
- $group = $this->catgrp->getGroup( $id );
429
- $this->message = __( 'Category group conflicts with ', 'avh-ec' ) . $group->name;
430
- $this->message .= '<br />' . __( 'Same slug is used. ', 'avh-ec' );
431
  $this->status = 'error';
432
-
433
  }
434
  $this->displayMessage();
435
  }
436
  $data_add_group['add'] = $data_add_group_new;
437
- $data['add'] = array ('form' => $options_add_group, 'data' => $data_add_group );
438
-
439
- if ( isset( $_GET['action'] ) ) {
440
  $action = $_GET['action'];
441
-
442
- switch ( $action )
443
- {
444
- case 'edit' :
445
- $group_id = ( int ) $_GET['group_ID'];
446
- $group = $this->catgrp->getGroup( $group_id );
447
- $widget_title = $this->catgrp->getWidgetTitleForGroup( $group_id );
448
- $cats = $this->catgrp->getCategoriesFromGroup( $group_id );
449
-
450
- $data_edit_group['edit'] = array ('group_id' => $group_id, 'name' => $group->name, 'slug' => $group->slug, 'widget_title' => $widget_title, 'description' => $group->description, 'categories' => $cats );
451
- $data['edit'] = array ('form' => $options_edit_group, 'data' => $data_edit_group );
452
-
453
- add_meta_box( 'avhecBoxCategoryGroupEdit', __( 'Edit Group', 'avh-ec' ) . ': ' . $group->name, array (&$this, 'metaboxCategoryGroupEdit' ), $this->hooks['menu_category_groups'], 'normal', 'low' );
454
  break;
455
- case 'delete' :
456
- if ( ! isset( $_GET['group_ID'] ) ) {
457
- wp_redirect( $this->getBackLink() );
458
  exit();
459
  }
460
-
461
- $group_id = ( int ) $_GET['group_ID'];
462
- check_admin_referer( 'delete-avhecgroup_' . $group_id );
463
-
464
- if ( ! current_user_can( 'manage_categories' ) ) {
465
- wp_die( __( 'Cheatin&#8217; uh?' ) );
466
  }
467
- $this->catgrp->doDeleteGroup( $group_id );
468
  break;
469
- default :
470
  ;
471
  break;
472
  }
473
  }
474
-
475
- if ( isset( $_POST['editgroup'] ) ) {
476
- check_admin_referer( 'avh_ec_editgroup' );
477
-
478
  $formoptions = $_POST['avhec_edit_group'];
479
  $selected_categories = $_POST['post_category'];
480
-
481
- $group_id = ( int ) $_POST['avhec-group_id'];
482
- $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'] );
483
- switch ( $result )
484
- {
485
- case 1 :
486
- $this->message = __( 'Category group updated', 'avh-ec' );
487
  $this->status = 'updated fade';
488
  break;
489
- case 0 :
490
- $this->message = __( 'Category group not updated', 'avh-ec' );
491
- $this->message .= '<br />' . __( 'Duplicate slug detected', 'avh-ec' );
492
  $this->status = 'error';
493
  break;
494
- case - 1 :
495
- $this->message = __( 'Unknown category group', 'avh-ec' );
496
  $this->status = 'error';
497
  break;
498
  }
499
  $this->displayMessage();
500
  }
501
-
502
  $hide2 = '';
503
- switch ( $screen_layout_columns )
504
- {
505
- case 2 :
506
  $width = 'width:49%;';
507
  break;
508
- default :
509
  $width = 'width:98%;';
510
  $hide2 = 'display:none;';
511
  }
512
-
513
- $data_special_pages_old=$this->core->options['sp_cat_group'];
514
- $data_special_pages_new=$data_special_pages_old;
515
- if ( isset( $_POST['avhec_special_pages'] ) ) {
516
- check_admin_referer( 'avh_ec_specialpagesgroup' );
517
-
518
  $formoptions = $_POST['avhec_special_pages'];
519
  $formdata = $formoptions['sp'];
520
  foreach ($formdata as $key => $value) {
521
  $data_special_pages_new[$key] = $value;
522
  }
523
- $this->core->options['sp_cat_group']=$data_special_pages_new;
524
  $this->core->saveOptions($this->core->options);
525
-
526
  }
527
- $data_special_pages['sp']=$data_special_pages_new;
528
- $cat_groups = get_terms( $this->catgrp->taxonomy_name, array ('hide_empty' => FALSE ) );
529
-
530
- foreach ( $cat_groups as $group ) {
531
- $temp_cat = get_term( $group->term_id, $this->catgrp->taxonomy_name, OBJECT, 'edit' );
532
- $dropdown_value[]= $group->term_id;
533
- $dropdown_text[]= $temp_cat->name;
534
  }
535
- $options_special_pages[] = array('avhec_special_pages[sp][home_group]',__('Home page','avh-ec'),'dropdown',$dropdown_value,$dropdown_text,'');
536
- $options_special_pages[] = array('avhec_special_pages[sp][category_group]',__('Category Archive','avh-ec'),'dropdown',$dropdown_value,$dropdown_text,'');
537
- $options_special_pages[] = array('avhec_special_pages[sp][day_group]',__('Daily Archive','avh-ec'),'dropdown',$dropdown_value,$dropdown_text,'');
538
- $options_special_pages[] = array('avhec_special_pages[sp][month_group]',__('Monthly Archive','avh-ec'),'dropdown',$dropdown_value,$dropdown_text,'');
539
- $options_special_pages[] = array('avhec_special_pages[sp][year_group]',__('Yearly Archive','avh-ec'),'dropdown',$dropdown_value,$dropdown_text,'');
540
- $options_special_pages[] = array('avhec_special_pages[sp][author_group]',__('Author Archive','avh-ec'),'dropdown',$dropdown_value,$dropdown_text,'');
541
- $options_special_pages[] = array('avhec_special_pages[sp][search_group]',__('Search Page','avh-ec'),'dropdown',$dropdown_value,$dropdown_text,'');
542
-
543
- $data['sp']=array ('form' => $options_special_pages, 'data' => $data_special_pages );
544
-
545
  // This box can't be unselectd in the the Screen Options
546
  //add_meta_box( 'avhecBoxDonations', __( 'Donations', 'avh-ec' ), array (&$this, 'metaboxDonations' ), $this->hooks['menu_category_groups'], 'side', 'core' );
 
547
 
548
-
549
- echo '<div class="wrap avhec-wrap">';
550
- echo $this->displayIcon( 'index' );
551
- echo '<h2>' . 'AVH Extended Categories - ' . __( 'Category Groups', 'avh-ec' ) . '</h2>';
552
-
553
  echo ' <div id="dashboard-widgets-wrap">';
554
  echo ' <div id="dashboard-widgets" class="metabox-holder">';
555
-
556
  echo ' <div class="postbox-container" style="' . $width . '">' . "\n";
557
- do_meta_boxes( $this->hooks['menu_category_groups'], 'normal', $data );
558
  echo " </div>";
559
-
560
  echo ' <div class="postbox-container" style="' . $hide2 . $width . '">' . "\n";
561
- do_meta_boxes( $this->hooks['menu_category_groups'], 'side', $data );
562
  echo ' </div>';
563
-
564
  echo ' </div>'; // dashboard-widgets
565
  echo '<br class="clear" />';
566
  echo ' </div>'; //dashboard-widgets-wrap
567
  echo '</div>'; // wrap
568
-
569
 
570
  $this->printMetaboxGeneralNonces();
571
- $this->printMetaboxJS( 'grouped' );
572
  $this->printAdminFooter();
573
  }
574
 
@@ -576,12 +568,12 @@ class AVH_EC_Admin
576
  * Metabox for Adding a group
577
  * @param $data
578
  */
579
- function metaboxCategoryGroupAdd ( $data )
580
  {
581
  echo '<form name="avhec-addgroup" id="avhec-addgroup" method="POST" action="' . $this->getBackLink() . '" accept-charset="utf-8" >';
582
- wp_nonce_field( 'avh_ec_addgroup' );
583
- echo $this->printOptions( $data['add']['form'], $data['add']['data'] );
584
- echo '<p class="submit"><input class="button" type="submit" name="addgroup" value="' . __( 'Add group', 'avh-ec' ) . '" /></p>';
585
  echo '</form>';
586
  }
587
 
@@ -590,47 +582,47 @@ class AVH_EC_Admin
590
  *
591
  * @param $data
592
  */
593
- function metaboxCategoryGroupList ( $data )
594
  {
595
  echo '<form id="posts-filter" action="" method="get">';
596
-
597
  echo '<div class="clear"></div>';
598
-
599
  echo '<table class="widefat fixed" cellspacing="0">';
600
  echo '<thead>';
601
  echo '<tr>';
602
- print_column_headers( 'categories_group' );
603
  echo '</tr>';
604
  echo '</thead>';
605
-
606
  echo '<tfoot>';
607
  echo '<tr>';
608
- print_column_headers( 'categories_group', false );
609
  echo '</tr>';
610
  echo '</tfoot>';
611
-
612
  echo '<tbody id="the-list" class="list:group">';
613
  $this->printCategoryGroupRows();
614
  echo '</tbody>';
615
  echo '</table>';
616
-
617
  echo '<br class="clear" />';
618
  echo '</form>';
619
-
620
- //echo '</div>';
621
  }
622
 
623
  /**
624
  * Metabox Category Group Edit
625
  *
626
  */
627
- function metaboxCategoryGroupEdit ( $data )
628
  {
629
  echo '<form name="avhec-editgroup" id="avhec-editgroup" method="POST" action="' . $this->getBackLink() . '" accept-charset="utf-8" >';
630
- wp_nonce_field( 'avh_ec_editgroup' );
631
- echo $this->printOptions( $data['edit']['form'], $data['edit']['data'] );
632
  echo '<input type="hidden" value="' . $data['edit']['data']['edit']['group_id'] . '" name="avhec-group_id" id="avhec-group_id">';
633
- echo '<p class="submit"><input class="button" type="submit" name="editgroup" value="' . __( 'Update group', 'avh-ec' ) . '" /></p>';
634
  echo '</form>';
635
  }
636
 
@@ -638,37 +630,38 @@ class AVH_EC_Admin
638
  * Metabox Category Group Special pages
639
  *
640
  */
641
- function metaboxCategoryGroupSpecialPages ( $data )
642
  {
643
  echo '<form name="avhec-specialpagesgroup" id="avhec-specialpagesgroup" method="POST" action="' . $this->getBackLink() . '" accept-charset="utf-8" >';
644
- wp_nonce_field( 'avh_ec_specialpagesgroup' );
645
- echo $this->printOptions( $data['sp']['form'], $data['sp']['data'] );
646
- echo '<p class="submit"><input class="button" type="submit" name="spgroup" value="' . __( 'Save settings', 'avh-ec' ) . '" /></p>';
647
  echo '</form>';
648
  }
 
649
  /**
650
  * Setup everything needed for the FAQ page
651
  *
652
  */
653
  function actionLoadPageHook_faq ()
654
  {
655
-
656
- add_meta_box( 'avhecBoxFAQ', __( 'F.A.Q.', 'avh-ec' ), array (&$this, 'metaboxFAQ' ), $this->hooks['menu_faq'], 'normal', 'core' );
657
- add_meta_box( 'avhecBoxTranslation', __( 'Translation', 'avh-ec' ), array (&$this, 'metaboxTranslation' ), $this->hooks['menu_faq'], 'normal', 'core' );
658
-
659
- add_filter( 'screen_layout_columns', array (&$this, 'filterScreenLayoutColumns' ), 10, 2 );
660
-
661
  // WordPress core Styles and Scripts
662
- wp_enqueue_script( 'common' );
663
- wp_enqueue_script( 'wp-lists' );
664
- wp_enqueue_script( 'postbox' );
665
-
666
  // WordPress core Styles
667
- wp_admin_css( 'css/dashboard' );
668
-
669
  // Plugin Style
670
- wp_enqueue_style( 'avhec-admin-css' );
671
-
672
  }
673
 
674
  /**
@@ -679,41 +672,40 @@ class AVH_EC_Admin
679
  function doMenuFAQ ()
680
  {
681
  global $screen_layout_columns;
682
-
683
  // This box can't be unselectd in the the Screen Options
684
- add_meta_box( 'avhecBoxAnnouncements', __( 'Announcements', 'avh-ec' ), array (&$this, 'metaboxAnnouncements' ), $this->hooks['menu_faq'], 'side', 'core' );
685
- add_meta_box( 'avhecBoxDonations', __( 'Donations', 'avh-ec' ), array (&$this, 'metaboxDonations' ), $this->hooks['menu_faq'], 'side', 'core' );
686
-
687
  $hide2 = '';
688
- switch ( $screen_layout_columns )
689
- {
690
- case 2 :
691
  $width = 'width:49%;';
692
  break;
693
- default :
694
  $width = 'width:98%;';
695
  $hide2 = 'display:none;';
696
  }
697
-
698
- echo '<div class="wrap avhec-wrap">';
699
- echo $this->displayIcon( 'index' );
700
- echo '<h2>' . 'AVH Extended Categories - ' . __( 'F.A.Q', 'avh-ec' ) . '</h2>';
701
  echo ' <div id="dashboard-widgets-wrap">';
702
  echo ' <div id="dashboard-widgets" class="metabox-holder">';
703
  echo ' <div class="postbox-container" style="' . $width . '">' . "\n";
704
- do_meta_boxes( $this->hooks['menu_faq'], 'normal', '' );
705
  echo ' </div>';
706
  echo ' <div class="postbox-container" style="' . $hide2 . $width . '">' . "\n";
707
- do_meta_boxes( $this->hooks['menu_faq'], 'side', '' );
708
  echo ' </div>';
709
  echo ' </div>';
710
  echo '<br class="clear"/>';
711
  echo ' </div>'; //dashboard-widgets-wrap
712
  echo '</div>'; // wrap
713
-
714
 
715
  $this->printMetaboxGeneralNonces();
716
- $this->printMetaboxJS( 'faq' );
717
  $this->printAdminFooter();
718
  }
719
 
@@ -723,12 +715,13 @@ class AVH_EC_Admin
723
  */
724
  function metaboxTranslation ()
725
  {
726
- echo '<p>';
727
- echo 'This plugin is translated in several languages. Some of the languages might be incomplete. Please help to complete these translations or add a new language.<br />';
728
- echo 'You can visit <a href="https://translations.launchpad.net/avhextendedcategories/trunk" target="_blank">Launchpad</a> to help complete these translations or add a new language.';
729
- echo '</p>';
730
- echo '<p>';
731
- echo '<span class="b">Available Languages</span></p><p>';
 
732
  echo '<ul>';
733
  echo '<li>Czech - Čeština (cs_CZ)</li>';
734
  echo '<li>Dutch - Nederlands (nl_NL)</li>';
@@ -740,10 +733,12 @@ class AVH_EC_Admin
740
  echo '<li>Swedish - Svenska (sv_SE)</li>';
741
  echo '<li>Turkish - Türkçe (tr)</li>';
742
  echo '</ul>';
743
- echo '</p>';
744
- echo '<p>';
745
- echo 'More information about translating can found at http://codex.wordpress.org/Translating_WordPress . This page is dedicated for translating WordPress but the instructions are the same for this plugin.';
746
- echo '</p>';
 
 
747
  }
748
 
749
  /**
@@ -752,20 +747,27 @@ class AVH_EC_Admin
752
  */
753
  function metaboxDonations ()
754
  {
755
- echo '<p>If you enjoy this plug-in please consider a donation. There are several ways you can show your appreciation</p>';
756
- echo '<p>';
 
 
 
757
  echo '<span class="b">Amazon</span><br />';
758
- echo 'If you decide to buy something from Amazon click the button.<br />';
759
- echo '<a href="https://www.amazon.com/?&tag=avh-donation-20" target="_blank" title="Amazon Homepage"><img alt="Amazon Button" src="' . $this->core->info['graphics_url'] . '/us_banner_logow_120x60.gif" /></a></p>';
760
- echo '<p>';
761
- echo 'You can send me something from my <a href="http://www.amazon.com/gp/registry/wishlist/1U3DTWZ72PI7W?tag=avh-donation-20">Amazon Wish List</a>';
762
- echo '</p>';
763
- echo '<p>';
764
- echo '<span class="b">Through Paypal.</span><br />';
765
- echo 'Click on the Donate button and you will be directed to Paypal where you can make your donation and you don\'t need to have a Paypal account to make a donation.<br />';
 
 
 
766
  echo '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=S85FXJ9EBHAF2&lc=US&item_name=AVH%20Plugins&item_number=fdas&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted" target="_blank" title="Donate">';
767
  echo '<img src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" alt="Donate"/></a>';
768
- echo '</p>';
 
769
  }
770
 
771
  /***
@@ -774,39 +776,79 @@ class AVH_EC_Admin
774
  */
775
  function metaboxFAQ ()
776
  {
777
-
778
- echo '<p>';
779
- echo '<span class="b">What about support?</span><br />';
780
- echo 'I created a support site at http://forums.avirtualhome.com where you can ask questions or request features.<br />';
781
- echo '</p>';
782
-
783
- echo '<p>';
784
- echo '<span class="b">What is depth selection?</span><br />';
785
- echo 'Starting with version 2.0 and WordPress 2.8 you can select how many levels deep you want to show your categories. This option only works when you select Show Hierarchy as well.<br /><br />';
786
- echo 'Here is how it works: Say you have 5 top level categories and each top level has a number of children. You could manually select all the Top Level categories you want to show but now you can do the following:<br />';
787
- echo 'You select to display all categories, select to Show hierarchy and select how many levels you want to show, in this case Toplevel only.<br />';
788
- echo '</p>';
789
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
790
  }
791
 
792
  function metaboxAnnouncements ()
793
  {
794
- $php5 = version_compare( '5.2', phpversion(), '<' );
795
- echo '<p>';
796
- echo '<span class="b">PHP4 Support</span><br />';
797
- echo 'The next major release of the plugin will no longer support PHP4.<br />';
798
- echo 'It will be written for PHP 5.2 and ';
799
- if ( $php5 ) {
800
- echo 'your blog already runs the needed PHP version. When the new release comes out you can safely update.<br />';
801
  } else {
802
- echo 'your blog still runs PHP4. When the new release comes out you can not use it.<br />';
803
- echo 'I don\'t have a timeline for the next version but consider contacting your host if PHP 5.2 is available.<br />';
804
- echo 'If your hosts doesn\'t offer PHP 5.2 you might want to consider switching hosts.<br />';
805
- echo 'A host to consider is <a href="http://www.lunarpages.com/id/pdoes" target="_blank">Lunarpages</a>.';
806
- echo 'I run my personal blog there and I am very happy with their services. You can get an account with unlimited bandwidth, storage and much more for a low price.';
807
  }
808
- echo '</p>';
809
-
810
  }
811
 
812
  /**
@@ -816,24 +858,23 @@ class AVH_EC_Admin
816
  * @param $screen
817
  * @return strings
818
  */
819
-
820
- function filterScreenLayoutColumns ( $columns, $screen )
821
  {
822
- switch ( $screen )
823
- {
824
- case $this->hooks['menu_overview'] :
825
  $columns[$this->hooks['menu_overview']] = 2;
826
  break;
827
- case $this->hooks['menu_general'] :
828
  $columns[$this->hooks['menu_general']] = 2;
829
  break;
830
- case $this->hooks['menu_category_groups'] :
831
  $columns[$this->hooks['menu_category_groups']] = 2;
832
  break;
833
- case $this->hooks['menu_faq'] :
834
  $columns[$this->hooks['menu_faq']] = 2;
835
  break;
836
-
837
  }
838
  return $columns;
839
  }
@@ -844,12 +885,12 @@ class AVH_EC_Admin
844
  * @WordPress Filter plugin_action_links_avh-amazon/avh-amazon.php
845
  *
846
  */
847
- function filterPluginActions ( $links, $file )
848
  {
849
- $settings_link = '<a href="admin.php?page=extended-categories-widget">' . __( 'Settings', 'avh-ec' ) . '</a>';
850
- array_unshift( $links, $settings_link ); // before other links
851
  return $links;
852
-
853
  }
854
 
855
  /**
@@ -859,9 +900,9 @@ class AVH_EC_Admin
859
  * @return Array
860
  * @see print_column_headers, get_column_headers
861
  */
862
- function filterManageCategoriesGroupColumns ( $columns )
863
  {
864
- $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' ) );
865
  return $categories_group_columns;
866
  }
867
 
@@ -874,16 +915,16 @@ class AVH_EC_Admin
874
  * @WordPress Filter explain_nonce_$verb-$noun
875
  * @see wp_explain_nonce
876
  */
877
- function filterExplainNonceDeleteGroup ( $text, $group_id )
878
  {
879
- $group = get_term( $group_id, $this->catgrp->taxonomy_name, OBJECT, 'display' );
880
-
881
- $return = sprintf( __( 'Your attempt to delete this group: &#8220;%s&#8221; has failed.' ), $group->name );
882
  return ($return);
883
  }
884
 
885
  ############## Admin WP Helper ##############
886
-
887
 
888
  /**
889
  * Get the backlink for forms
@@ -892,13 +933,13 @@ class AVH_EC_Admin
892
  */
893
  function getBackLink ()
894
  {
895
- $page = basename( __FILE__ );
896
- if ( isset( $_GET['page'] ) && ! empty( $_GET['page'] ) ) {
897
- $page = preg_replace( '[^a-zA-Z0-9\.\_\-]', '', $_GET['page'] );
898
  }
899
-
900
- if ( function_exists( "admin_url" ) )
901
- return admin_url( basename( $_SERVER["PHP_SELF"] ) ) . "?page=" . $page;
902
  else
903
  return $_SERVER['PHP_SELF'] . "?page=" . $page;
904
  }
@@ -911,11 +952,11 @@ class AVH_EC_Admin
911
  */
912
  function printCategoryGroupRows ()
913
  {
914
- $cat_groups = get_terms( $this->catgrp->taxonomy_name, array ('hide_empty' => FALSE ) );
915
-
916
- foreach ( $cat_groups as $group ) {
917
- if ( 'none' != $group->slug ) {
918
- echo $this->printCategoryGroupRow( $group->term_id, $group->term_taxonomy_id );
919
  }
920
  }
921
  }
@@ -927,32 +968,32 @@ class AVH_EC_Admin
927
  * @param int $group_term_id
928
  * @param int $group_term_taxonomy_id
929
  */
930
- function printCategoryGroupRow ( $group_term_id, $group_term_taxonomy_id )
931
  {
932
  static $row_class = '';
933
-
934
- $group = get_term( $group_term_id, $this->catgrp->taxonomy_name, OBJECT, 'display' );
935
-
936
- $no_edit[$this->catgrp->getTermIDBy( 'slug', 'all' )] = 0;
937
- $no_delete[$this->catgrp->getTermIDBy( 'slug', 'all' )] = 0;
938
-
939
- if ( current_user_can( 'manage_categories' ) ) {
940
- $actions = array ();
941
- if ( ! array_key_exists( $group->term_id, $no_edit ) ) {
942
  $edit_link = "admin.php?page=avhec-grouped&amp;action=edit&amp;group_ID=$group->term_id";
943
- $edit = "<a class='row-title' href='$edit_link' title='" . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $group->name ) ) . "'>" . esc_attr( $group->name ) . '</a><br />';
944
-
945
- $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
946
  } else {
947
- $edit = esc_attr( $group->name );
948
  }
949
- if ( ! (array_key_exists( $group->term_id, $no_delete )) ) {
950
- $actions['delete'] = "<a class='delete:the-list:group-$group->term_id submitdelete' href='" . wp_nonce_url( "admin.php?page=avhec-grouped&amp;action=delete&amp;group_ID=$group->term_id", 'delete-avhecgroup_' . $group->term_id ) . "'>" . __( 'Delete' ) . "</a>";
951
  }
952
- $action_count = count( $actions );
953
  $i = 0;
954
  $edit .= '<div class="row-actions">';
955
- foreach ( $actions as $action => $link ) {
956
  ++ $i;
957
  ($i == $action_count) ? $sep = '' : $sep = ' | ';
958
  $edit .= "<span class='$action'>$link$sep</span>";
@@ -961,67 +1002,66 @@ class AVH_EC_Admin
961
  } else {
962
  $edit = $group->name;
963
  }
964
-
965
  $row_class = 'alternate' == $row_class ? '' : 'alternate';
966
- $qe_data = get_term( $group->term_id, $this->catgrp->taxonomy_name, OBJECT, 'edit' );
967
-
968
  $output = "<tr id='group-$group->term_id' class='iedit $row_class'>";
969
-
970
- $columns = get_column_headers( 'categories_group' );
971
- $hidden = get_hidden_columns( 'categories_group' );
972
- foreach ( $columns as $column_name => $column_display_name ) {
973
  $class = 'class="' . $column_name . ' column-' . $column_name . '"';
974
-
975
  $style = '';
976
- if ( in_array( $column_name, $hidden ) )
977
  $style = ' style="display:none;"';
978
-
979
  $attributes = $class . $style;
980
-
981
- switch ( $column_name )
982
- {
983
- case 'cb' :
984
  $output .= '<th scope="row" class="check-column">';
985
- if ( ! (array_key_exists( $group->term_id, $no_delete )) ) {
986
  $output .= '<input type="checkbox" name="delete[]" value="' . $group->term_id . '" />';
987
  } else {
988
  $output .= "&nbsp;";
989
  }
990
  $output .= '</th>';
991
  break;
992
- case 'name' :
993
  $output .= '<td ' . $attributes . '>' . $edit;
994
  $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
995
  $output .= '<div class="name">' . $qe_data->name . '</div>';
996
- $output .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug ) . '</div>';
997
  $output .= '</div></td>';
998
  break;
999
- case 'widget-title' :
1000
  $title = $this->catgrp->getWidgetTitleForGroup($group->term_id);
1001
  $output .= '<td ' . $attributes . '>' . $title . '</td>';
1002
  break;
1003
-
1004
- case 'description' :
1005
  $output .= '<td ' . $attributes . '>' . $qe_data->description . '</td>';
1006
  break;
1007
- case 'slug' :
1008
- $output .= "<td $attributes>" . apply_filters( 'editable_slug', $qe_data->slug ) . "</td>";
1009
  break;
1010
- case 'cat-in-group' :
1011
- $cats = $this->catgrp->getCategoriesFromGroup( $group_term_id );
1012
- $catname = array ();
1013
- foreach ( $cats as $cat_id ) {
1014
- $catname[] = get_cat_name( $cat_id );
1015
  }
1016
- natsort( $catname );
1017
- $cat = implode( ', ', $catname );
1018
  $output .= '<td ' . $attributes . '>' . $cat . '</td>';
1019
  break;
1020
-
1021
  }
1022
  }
1023
  $output .= '</tr>';
1024
-
1025
  return $output;
1026
  }
1027
 
@@ -1032,11 +1072,11 @@ class AVH_EC_Admin
1032
  {
1033
  echo '<form style="display:none" method="get" action="">';
1034
  echo '<p>';
1035
- wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
1036
- wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
1037
  echo '</p>';
1038
  echo '</form>';
1039
-
1040
  }
1041
 
1042
  /**
@@ -1044,7 +1084,7 @@ class AVH_EC_Admin
1044
  *
1045
  * @param $boxid
1046
  */
1047
- function printMetaboxJS ( $boxid )
1048
  {
1049
  $a = $this->hooks['menu_' . $boxid];
1050
  echo '<script type="text/javascript">' . "\n";
@@ -1056,7 +1096,7 @@ class AVH_EC_Admin
1056
  echo ' });' . "\n";
1057
  echo ' //]]>' . "\n";
1058
  echo '</script>';
1059
-
1060
  }
1061
 
1062
  /**
@@ -1066,7 +1106,7 @@ class AVH_EC_Admin
1066
  function printAdminFooter ()
1067
  {
1068
  echo '<p class="footer_avhec">';
1069
- printf( '&copy; Copyright 2011 <a href="http://blog.avirtualhome.com/" title="My Thoughts">Peter van der Does</a> | AVH Extended Categories Version %s', $this->core->version );
1070
  echo '</p>';
1071
  }
1072
 
@@ -1076,12 +1116,12 @@ class AVH_EC_Admin
1076
  */
1077
  function displayMessage ()
1078
  {
1079
- if ( $this->message != '' ) {
1080
  $message = $this->message;
1081
  $status = $this->status;
1082
  $this->message = $this->status = ''; // Reset
1083
  }
1084
- if ( isset( $message ) ) {
1085
  $status = ($status != '') ? $status : 'updated fade';
1086
  echo '<div id="message" class="' . $status . '">';
1087
  echo '<p><strong>' . $message . '</strong></p></div>';
@@ -1094,69 +1134,68 @@ class AVH_EC_Admin
1094
  * @param array $option_data
1095
  * @return string
1096
  */
1097
- function printOptions ( $option_data, $option_actual )
1098
  {
1099
  // Generate output
1100
  $output = '';
1101
  $output .= "\n" . '<table class="form-table avhec-options">' . "\n";
1102
- foreach ( $option_data as $option ) {
1103
- $section = substr( $option[0], strpos( $option[0], '[' ) + 1 );
1104
- $section = substr( $section, 0, strpos( $section, '][' ) );
1105
- $option_key = rtrim( $option[0], ']' );
1106
- $option_key = substr( $option_key, strpos( $option_key, '][' ) + 2 );
1107
  // Helper
1108
- if ( $option[2] == 'helper' ) {
1109
  $output .= '<tr style="vertical-align: top;"><td class="helper" colspan="2">' . $option[4] . '</td></tr>' . "\n";
1110
  continue;
1111
  }
1112
- switch ( $option[2] )
1113
- {
1114
- case 'checkbox' :
1115
- $input_type = '<input type="checkbox" id="' . $option[0] . '" name="' . $option[0] . '" value="' . attribute_escape( $option[3] ) . '" ' . $this->isChecked( '1', $option_actual[$section][$option_key] ) . ' />' . "\n";
1116
  $explanation = $option[4];
1117
  break;
1118
- case 'dropdown' :
1119
  $selvalue = $option[3];
1120
  $seltext = $option[4];
1121
  $seldata = '';
1122
- foreach ( ( array ) $selvalue as $key => $sel ) {
1123
- $seldata .= '<option value="' . $sel . '" ' . (($option_actual[$section][$option_key] == $sel) ? 'selected="selected"' : '') . ' >' . ucfirst( $seltext[$key] ) . '</option>' . "\n";
1124
  }
1125
  $input_type = '<select id="' . $option[0] . '" name="' . $option[0] . '">' . $seldata . '</select>' . "\n";
1126
  $explanation = $option[5];
1127
  break;
1128
- case 'text-color' :
1129
- $input_type = '<input type="text" ' . (($option[3] > 1) ? ' style="width: 95%" ' : '') . 'id="' . $option[0] . '" name="' . $option[0] . '" value="' . attribute_escape( $option_actual[$section][$option_key] ) . '" size="' . $option[3] . '" /><div class="box_color ' . $option[0] . '"></div>' . "\n";
1130
  $explanation = $option[4];
1131
  break;
1132
- case 'textarea' :
1133
- $input_type = '<textarea rows="' . $option[5] . '" ' . (($option[3] > 1) ? ' style="width: 95%" ' : '') . 'id="' . $option[0] . '" name="' . $option[0] . '" size="' . $option[3] . '" />' . attribute_escape( $option_actual[$section][$option_key] ) . '</textarea>';
1134
  $explanation = $option[4];
1135
  break;
1136
- case 'catlist' :
1137
  ob_start();
1138
  echo '<div id="avhec-catlist">';
1139
  echo '<ul>';
1140
- wp_category_checklist( 0, 0, $option_actual[$section][$option_key] );
1141
  echo '</ul>';
1142
  echo '</div>';
1143
  $input_type = ob_get_contents();
1144
  ob_end_clean();
1145
  $explanation = $option[4];
1146
  break;
1147
- case 'text' :
1148
- default :
1149
- $input_type = '<input type="text" ' . (($option[3] > 1) ? ' style="width: 95%" ' : '') . 'id="' . $option[0] . '" name="' . $option[0] . '" value="' . attribute_escape( $option_actual[$section][$option_key] ) . '" size="' . $option[3] . '" />' . "\n";
1150
  $explanation = $option[4];
1151
  break;
1152
  }
1153
  // Additional Information
1154
  $extra = '';
1155
- if ( $explanation ) {
1156
- $extra = '<br /><span class="description">' . __( $explanation ) . '</span>' . "\n";
1157
  }
1158
  // Output
1159
- $output .= '<tr style="vertical-align: top;"><th align="left" scope="row"><label for="' . $option[0] . '">' . __( $option[1] ) . '</label></th><td>' . $input_type . ' ' . $extra . '</td></tr>' . "\n";
1160
  }
1161
  $output .= '</table>' . "\n";
1162
  return $output;
@@ -1169,10 +1208,10 @@ class AVH_EC_Admin
1169
  * @param mixed $current
1170
  * @return strings
1171
  */
1172
- function isChecked ( $checked, $current )
1173
  {
1174
  $return = '';
1175
- if ( $checked == $current ) {
1176
  $return = ' checked="checked"';
1177
  }
1178
  return $return;
@@ -1183,7 +1222,7 @@ class AVH_EC_Admin
1183
  *
1184
  * @param $icon
1185
  */
1186
- function displayIcon ( $icon )
1187
  {
1188
  return ('<div class="icon32" id="icon-' . $icon . '"><br/></div>');
1189
  }
@@ -1193,21 +1232,21 @@ class AVH_EC_Admin
1193
  */
1194
  function ajaxDeleteGroup ()
1195
  {
1196
- $group_id = isset( $_POST['id'] ) ? ( int ) $_POST['id'] : 0;
1197
- check_ajax_referer( 'delete-avhecgroup_' . $group_id );
1198
-
1199
- if ( ! current_user_can( 'manage_categories' ) ) {
1200
- die( '-1' );
1201
  }
1202
- $check = $this->catgrp->getGroup( $group_id );
1203
- if ( false === $check ) {
1204
- die( '1' );
1205
  }
1206
-
1207
- if ( $this->catgrp->doDeleteGroup( $group_id ) ) {
1208
- die( '1' );
1209
  } else {
1210
- die( '0' );
1211
  }
1212
  }
1213
  }
1
  <?php
2
+
3
  class AVH_EC_Admin
4
  {
5
  /**
7
  * @var AVH_EC_Core
8
  */
9
  var $core;
10
+
11
  /**
12
  *
13
  * @var AVH_EC_Category_Group
14
  */
15
  var $catgrp;
16
+
17
+ var $hooks = array();
18
  var $message;
19
 
20
  /**
23
  */
24
  function __construct ()
25
  {
26
+
27
  // Initialize the plugin
28
+ $this->core = & AVH_EC_Singleton::getInstance('AVH_EC_Core');
29
+ $this->catgrp = & AVH_EC_Singleton::getInstance('AVH_EC_Category_Group');
30
+
31
+ add_action('wp_ajax_delete-group', array(&$this, 'ajaxDeleteGroup'));
32
+
33
  // Admin menu
34
+ add_action('admin_menu', array(&$this, 'actionAdminMenu'));
35
+ add_filter('plugin_action_links_extended-categories-widget/widget_extended_categories.php', array(&$this, 'filterPluginActions'), 10, 2);
36
+
37
  // Actions used for editing posts
38
+ add_action('load-post.php', array(&$this, 'actionLoadPostPage'));
39
+ add_action('load-page.php', array(&$this, 'actionLoadPostPage'));
40
+
41
  // Actions related to adding and deletes categories
42
+ add_action("created_category", array($this, 'actionCreatedCategory'), 10, 2);
43
+ add_action("delete_category", array($this, 'actionDeleteCategory'), 10, 2);
44
+
45
+ add_filter('manage_categories_group_columns', array(&$this, 'filterManageCategoriesGroupColumns'));
46
+ add_filter('explain_nonce_delete-avhecgroup', array(&$this, 'filterExplainNonceDeleteGroup'), 10, 2);
47
+
48
  return;
49
  }
50
 
62
  * @param $term_id
63
  * @param $term_taxonomy_id
64
  */
65
+ function actionCreatedCategory ($term_id, $term_taxonomy_id)
66
  {
67
+ $group_id = $this->catgrp->getTermIDBy('slug', 'all');
68
+ $this->catgrp->setCategoriesForGroup($group_id, (array) $term_id);
69
  }
70
 
71
  /**
74
  * @param object $term
75
  * @param int $term_taxonomy_id
76
  */
77
+ function actionDeleteCategory ($term_id, $term_taxonomy_id)
78
  {
79
+ $this->catgrp->doDeleteCategoryFromGroup($term_id);
80
  }
81
 
82
  /**
86
  */
87
  function actionLoadPostPage ()
88
  {
89
+ wp_enqueue_style('avhec-admin-css');
90
  }
91
 
92
  /**
97
  */
98
  function actionAdminMenu ()
99
  {
100
+
101
  // Register Style and Scripts
102
+ $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
103
+ wp_register_script('avhec-categorygroup-js', AVHEC_PLUGIN_URL . '/js/avh-ec.categorygroup' . $suffix . '.js', array('jquery'), $this->core->version, true);
104
+ wp_register_style('avhec-admin-css', AVHEC_PLUGIN_URL . '/css/avh-ec.admin.css', array('wp-admin'), $this->core->version, 'screen');
105
+
106
  // Add menu system
107
+ $folder = $this->core->getBaseDirectory(AVHEC_PLUGIN_DIR);
108
+ add_menu_page('AVH Extended Categories', 'AVH Extended Categories', 'manage_options', $folder, array(&$this, 'doMenuOverview'));
109
+ $this->hooks['menu_overview'] = add_submenu_page($folder, 'AVH Extended Categories: ' . __('Overview', 'avh-ec'), __('Overview', 'avh-ec'), 'manage_options', $folder, array(&$this, 'doMenuOverview'));
110
+ $this->hooks['menu_general'] = add_submenu_page($folder, 'AVH Extended Categories: ' . __('General Options', 'avh-ec'), __('General Options', 'avh-ec'), 'manage_options', 'avhec-general', array(&$this, 'doMenuGeneral'));
111
+ $this->hooks['menu_category_groups'] = add_submenu_page($folder, 'AVH Extended Categories: ' . __('Category Groups', 'avh-ec'), __('Category Groups', 'avh-ec'), 'manage_options', 'avhec-grouped', array(&$this, 'doMenuCategoryGroup'));
112
+ $this->hooks['menu_faq'] = add_submenu_page($folder, 'AVH Extended Categories:' . __('F.A.Q', 'avh-ec'), __('F.A.Q', 'avh-ec'), 'manage_options', 'avhec-faq', array(&$this, 'doMenuFAQ'));
113
+
114
  // Add actions for menu pages
115
  // Overview Menu
116
+ add_action('load-' . $this->hooks['menu_overview'], array(&$this, 'actionLoadPageHook_Overview'));
117
+
118
  // General Options Menu
119
+ add_action('load-' . $this->hooks['menu_general'], array(&$this, 'actionLoadPageHook_General'));
120
+
121
  // Category Groups Menu
122
+ add_action('load-' . $this->hooks['menu_category_groups'], array(&$this, 'actionLoadPageHook_CategoryGroup'));
123
+
124
  // FAQ Menu
125
+ add_action('load-' . $this->hooks['menu_faq'], array(&$this, 'actionLoadPageHook_faq'));
126
  }
127
 
128
  /**
132
  function actionLoadPageHook_Overview ()
133
  {
134
  // Add metaboxes
135
+ add_meta_box('avhecBoxCategoryGroupList', __('Group Overview', 'avh-ec'), array(&$this, 'metaboxCategoryGroupList'), $this->hooks['menu_overview'], 'normal', 'core');
136
+
137
+ add_filter('screen_layout_columns', array(&$this, 'filterScreenLayoutColumns'), 10, 2);
138
+
139
  // WordPress core Scripts
140
+ wp_enqueue_script('common');
141
+ wp_enqueue_script('wp-lists');
142
+ wp_enqueue_script('postbox');
143
+
144
  // Plugin Scripts
145
+ wp_enqueue_script('avhec-categorygroup-js');
146
+
147
  // WordPress core Styles
148
+ wp_admin_css('css/dashboard');
149
+
150
  // Plugin Style
151
+ wp_enqueue_style('avhec-admin-css');
152
  }
153
 
154
  /**
159
  function doMenuOverview ()
160
  {
161
  global $screen_layout_columns;
162
+
163
  // This box can't be unselectd in the the Screen Options
164
+ add_meta_box('avhecBoxAnnouncements', __('Announcements', 'avh-ec'), array(&$this, 'metaboxAnnouncements'), $this->hooks['menu_overview'], 'side', '');
165
+ add_meta_box('avhecBoxDonations', __('Donations', 'avh-ec'), array(&$this, 'metaboxDonations'), $this->hooks['menu_overview'], 'side', '');
166
+
167
  $hide2 = '';
168
+ switch ($screen_layout_columns) {
169
+ case 2:
 
170
  $width = 'width:49%;';
171
  break;
172
+ default:
173
  $width = 'width:98%;';
174
  $hide2 = 'display:none;';
175
  }
176
+
177
+ echo '<div class="wrap avhec-metabox-wrap">';
178
+ echo $this->displayIcon('index');
179
+ echo '<h2>' . 'AVH Extended Categories - ' . __('Overview', 'avh-ec') . '</h2>';
180
  echo ' <div id="dashboard-widgets-wrap">';
181
  echo ' <div id="dashboard-widgets" class="metabox-holder">';
182
  echo ' <div class="postbox-container" style="' . $width . '">' . "\n";
183
+ do_meta_boxes($this->hooks['menu_overview'], 'normal', '');
184
  echo " </div>";
185
  echo ' <div class="postbox-container" style="' . $hide2 . $width . '">' . "\n";
186
+ do_meta_boxes($this->hooks['menu_overview'], 'side', '');
187
  echo ' </div>';
188
  echo ' </div>';
189
+
190
  echo '<br class="clear"/>';
191
  echo ' </div>'; //dashboard-widgets-wrap
192
  echo '</div>'; // wrap
193
+
194
 
195
  $this->printMetaboxGeneralNonces();
196
+ $this->printMetaboxJS('overview');
197
  $this->printAdminFooter();
198
  }
199
 
204
  function actionLoadPageHook_General ()
205
  {
206
  // Add metaboxes
207
+ add_meta_box('avhecBoxOptions', __('Options', 'avh-ec'), array(&$this, 'metaboxOptions'), $this->hooks['menu_general'], 'normal', 'core');
208
+
209
+ add_filter('screen_layout_columns', array(&$this, 'filterScreenLayoutColumns'), 10, 2);
210
+
211
  // WordPress core Scripts
212
+ wp_enqueue_script('common');
213
+ wp_enqueue_script('wp-lists');
214
+ wp_enqueue_script('postbox');
215
+
216
  // WordPress core Styles
217
+ wp_admin_css('css/dashboard');
218
+
219
  // Plugin Style and Scripts
220
+ wp_enqueue_style('avhec-admin-css');
221
+
222
  }
223
 
224
  /**
229
  function doMenuGeneral ()
230
  {
231
  global $screen_layout_columns;
232
+
233
+ $groups = get_terms($this->catgrp->taxonomy_name, array('hide_empty'=>FALSE));
234
+ foreach ($groups as $group) {
235
  $group_id[] = $group->term_id;
236
  $groupname[] = $group->name;
237
  }
238
+
239
+ $options_general[] = array('avhec[general][alternative_name_select_category]', __('<em>Select Category</em> Alternative', 'avh-ec'), 'text', 20, __('Alternative text for Select Category.', 'avh-ec'));
240
+ $options_general[] = array('avhec[cat_group][home_group]', 'Home Group', 'dropdown', $group_id, $groupname, __('Select which group to show on the home page.', 'avh-ec') . '<br />' . __('Selecting the group \'none\' will not show the widget on the page.', 'avh-ec'));
241
+ $options_general[] = array('avhec[cat_group][no_group]', 'Nonexistence Group', 'dropdown', $group_id, $groupname, __('Select which group to show when there is no group associated with the post.', 'avh-ec') . '<br />' . __('Selecting the group \'none\' will not show the widget on the page.', 'avh-ec'));
242
+ $options_general[] = array('avhec[cat_group][default_group]', 'Default Group', 'dropdown', $group_id, $groupname, __('Select which group will be the default group when editing a post.', 'avh-ec') . '<br />' . __('Selecting the group \'none\' will not show the widget on the page.', 'avh-ec'));
243
+
244
+ if (isset($_POST['updateoptions'])) {
245
+ check_admin_referer('avh_ec_generaloptions');
246
+
247
  $formoptions = $_POST['avhec'];
248
  $options = $this->core->getOptions();
249
+
250
  //$all_data = array_merge( $options_general );
251
  $all_data = $options_general;
252
+ foreach ($all_data as $option) {
253
+ $section = substr($option[0], strpos($option[0], '[') + 1);
254
+ $section = substr($section, 0, strpos($section, ']['));
255
+ $option_key = rtrim($option[0], ']');
256
+ $option_key = substr($option_key, strpos($option_key, '][') + 2);
257
+
258
+ switch ($section) {
259
+ case 'general':
260
+ case 'cat_group':
 
261
  $current_value = $options[$section][$option_key];
262
  break;
263
  }
264
  // Every field in a form is set except unchecked checkboxes. Set an unchecked checkbox to 0.
265
+ $newval = (isset($formoptions[$section][$option_key]) ? attribute_escape($formoptions[$section][$option_key]) : 0);
266
+ if ($newval != $current_value) { // Only process changed fields.
267
+ switch ($section) {
268
+ case 'general':
269
+ case 'cat_group':
 
270
  $options[$section][$option_key] = $newval;
271
  break;
272
  }
273
  }
274
  }
275
+ $this->core->saveOptions($options);
276
+ $this->message = __('Options saved', 'avh-ec');
277
  $this->status = 'updated fade';
278
+
279
  }
280
  $this->displayMessage();
281
+
282
  $actual_options = $this->core->getOptions();
283
+ foreach ($actual_options['cat_group'] as $key => $value) {
284
+ if (! (in_array($value, (array) $group_id))) {
285
+ $actual_options['cat_group'][$key] = $this->catgrp->getTermIDBy('slug', 'none');
286
  }
287
  }
288
+
289
  $hide2 = '';
290
+ switch ($screen_layout_columns) {
291
+ case 2:
 
292
  $width = 'width:49%;';
293
  break;
294
+ default:
295
  $width = 'width:98%;';
296
  $hide2 = 'display:none;';
297
  }
298
  $data['options_general'] = $options_general;
299
  $data['actual_options'] = $actual_options;
300
+
301
  // This box can't be unselectd in the the Screen Options
302
+ add_meta_box('avhecBoxDonations', __('Donations', 'avh-ec'), array(&$this, 'metaboxDonations'), $this->hooks['menu_general'], 'side', 'core');
303
+
304
  $hide2 = '';
305
+ switch ($screen_layout_columns) {
306
+ case 2:
 
307
  $width = 'width:49%;';
308
  break;
309
+ default:
310
  $width = 'width:98%;';
311
  $hide2 = 'display:none;';
312
  }
313
+
314
+ echo '<div class="wrap avhec-metabox-wrap">';
315
+ echo $this->displayIcon('index');
316
+ echo '<h2>' . 'AVH Extended Categories - ' . __('General Options', 'avh-ec') . '</h2>';
317
  echo '<form name="avhec-generaloptions" id="avhec-generaloptions" method="POST" action="' . admin_url('admin.php?page=avhec-general') . '" accept-charset="utf-8" >';
318
+ wp_nonce_field('avh_ec_generaloptions');
319
+
320
  echo ' <div id="dashboard-widgets-wrap">';
321
  echo ' <div id="dashboard-widgets" class="metabox-holder">';
322
  echo ' <div class="postbox-container" style="' . $width . '">' . "\n";
323
+ do_meta_boxes($this->hooks['menu_general'], 'normal', $data);
324
  echo " </div>";
325
  echo ' <div class="postbox-container" style="' . $hide2 . $width . '">' . "\n";
326
+ do_meta_boxes($this->hooks['menu_general'], 'side', $data);
327
  echo ' </div>';
328
  echo ' </div>';
329
+
330
  echo '<br class="clear"/>';
331
  echo ' </div>'; //dashboard-widgets-wrap
332
+ echo '<p class="submit"><input class="button" type="submit" name="updateoptions" value="' . __('Save Changes', 'avhf-ec') . '" /></p>';
333
  echo '</form>';
334
+
335
  echo '</div>'; // wrap
336
+
337
 
338
  $this->printMetaboxGeneralNonces();
339
+ $this->printMetaboxJS('general');
340
  $this->printAdminFooter();
341
  }
342
 
344
  * Options Metabox
345
  *
346
  */
347
+ function metaboxOptions ($data)
348
  {
349
+ echo $this->printOptions($data['options_general'], $data['actual_options']);
350
  }
351
 
352
  /**
355
  */
356
  function actionLoadPageHook_CategoryGroup ()
357
  {
358
+
359
  // Add metaboxes
360
+ add_meta_box('avhecBoxCategoryGroupAdd', __('Add Group', 'avh-ec'), array(&$this, 'metaboxCategoryGroupAdd'), $this->hooks['menu_category_groups'], 'normal', 'core');
361
+ add_meta_box('avhecBoxCategoryGroupList', __('Group Overview', 'avh-ec'), array(&$this, 'metaboxCategoryGroupList'), $this->hooks['menu_category_groups'], 'side', 'core');
362
+ add_meta_box('avhecBoxCategoryGroupSpecialPages', __('Special Pages', 'avh-ec'), array(&$this, 'metaboxCategoryGroupSpecialPages'), $this->hooks['menu_category_groups'], 'normal', 'core');
363
+
364
+ add_filter('screen_layout_columns', array(&$this, 'filterScreenLayoutColumns'), 10, 2);
365
  // WordPress core Scripts
366
+ wp_enqueue_script('common');
367
+ wp_enqueue_script('wp-lists');
368
+ wp_enqueue_script('postbox');
369
+
370
  // Plugin Scripts
371
+ wp_enqueue_script('avhec-categorygroup-js');
372
+
373
  // WordPress core Styles
374
+ wp_admin_css('css/dashboard');
375
+
376
  // Plugin Style
377
+ wp_enqueue_style('avhec-admin-css');
378
+
379
  }
380
 
381
  /**
386
  function doMenuCategoryGroup ()
387
  {
388
  global $screen_layout_columns;
389
+
390
+ $data_add_group_default = array('name'=>'', 'slug'=>'', 'widget_title'=>'', 'description'=>'');
391
  $data_add_group_new = $data_add_group_default;
392
+
393
+ $options_add_group[] = array('avhec_add_group[add][name]', __(' Group Name', 'avh-ec'), 'text', 20, __('The name is used to identify the group.', 'avh-ec'));
394
+ $options_add_group[] = array('avhec_add_group[add][slug]', __(' Slug Group', 'avh-ec'), 'text', 20, __('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'avh-ec'));
395
+ $options_add_group[] = array('avhec_add_group[add][widget_title]', __(' Widget Title,', 'avh-ec'), '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.', 'avh-ec'));
396
+ $options_add_group[] = array('avhec_add_group[add][description]', __(' Description', 'avh-ec'), 'textarea', 40, __('Description is not prominent by default.', 'avh-ec'), 5);
397
+
398
+ $options_edit_group[] = array('avhec_edit_group[edit][name]', __(' Group Name', 'avh-ec'), 'text', 20, __('The name is used to identify the group.', 'avh-ec'));
399
+ $options_edit_group[] = array('avhec_edit_group[edit][slug]', __(' Slug Group', 'avh-ec'), 'text', 20, __('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'avh-ec'));
400
+ $options_edit_group[] = array('avhec_edit_group[edit][widget_title]', __(' Widget Title', 'avh-ec'), '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.', 'avh-ec'));
401
+ $options_edit_group[] = array('avhec_edit_group[edit][description]', __(' Description', 'avh-ec'), 'textarea', 40, __('Description is not prominent by default.', 'avh-ec'), 5);
402
+ $options_edit_group[] = array('avhec_edit_group[edit][categories]', __(' Categories', 'avh-ec'), 'catlist', 0, __('Select categories to be included in the group.', 'avh-ec'));
403
+
404
+ if (isset($_POST['addgroup'])) {
405
+ check_admin_referer('avh_ec_addgroup');
406
+
 
407
  $formoptions = $_POST['avhec_add_group'];
408
+
409
  $data_add_group_new['name'] = $formoptions['add']['name'];
410
+ $data_add_group_new['slug'] = empty($formoptions['add']['slug']) ? sanitize_title($data_add_group_new['name']) : sanitize_title($formoptions['add']['slug']);
411
  $data_add_group_new['widget_title'] = $formoptions['add']['widget_title'];
412
  $data_add_group_new['description'] = $formoptions['add']['description'];
413
+
414
+ $id = $this->catgrp->getTermIDBy('slug', $data_add_group_new['slug']);
415
+ if (! $id) {
416
+ $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']);
417
+ $this->catgrp->setCategoriesForGroup($group_id);
418
+ $this->message = __('Category group saved', 'avh-ec');
419
  $this->status = 'updated fade';
420
  $data_add_group_new = $data_add_group_default;
421
+
422
  } else {
423
+ $group = $this->catgrp->getGroup($id);
424
+ $this->message = __('Category group conflicts with ', 'avh-ec') . $group->name;
425
+ $this->message .= '<br />' . __('Same slug is used. ', 'avh-ec');
426
  $this->status = 'error';
427
+
428
  }
429
  $this->displayMessage();
430
  }
431
  $data_add_group['add'] = $data_add_group_new;
432
+ $data['add'] = array('form'=>$options_add_group, 'data'=>$data_add_group);
433
+
434
+ if (isset($_GET['action'])) {
435
  $action = $_GET['action'];
436
+
437
+ switch ($action) {
438
+ case 'edit':
439
+ $group_id = (int) $_GET['group_ID'];
440
+ $group = $this->catgrp->getGroup($group_id);
441
+ $widget_title = $this->catgrp->getWidgetTitleForGroup($group_id);
442
+ $cats = $this->catgrp->getCategoriesFromGroup($group_id);
443
+
444
+ $data_edit_group['edit'] = array('group_id'=>$group_id, 'name'=>$group->name, 'slug'=>$group->slug, 'widget_title'=>$widget_title, 'description'=>$group->description, 'categories'=>$cats);
445
+ $data['edit'] = array('form'=>$options_edit_group, 'data'=>$data_edit_group);
446
+
447
+ add_meta_box('avhecBoxCategoryGroupEdit', __('Edit Group', 'avh-ec') . ': ' . $group->name, array(&$this, 'metaboxCategoryGroupEdit'), $this->hooks['menu_category_groups'], 'normal', 'low');
 
448
  break;
449
+ case 'delete':
450
+ if (! isset($_GET['group_ID'])) {
451
+ wp_redirect($this->getBackLink());
452
  exit();
453
  }
454
+
455
+ $group_id = (int) $_GET['group_ID'];
456
+ check_admin_referer('delete-avhecgroup_' . $group_id);
457
+
458
+ if (! current_user_can('manage_categories')) {
459
+ wp_die(__('Cheatin&#8217; uh?'));
460
  }
461
+ $this->catgrp->doDeleteGroup($group_id);
462
  break;
463
+ default:
464
  ;
465
  break;
466
  }
467
  }
468
+
469
+ if (isset($_POST['editgroup'])) {
470
+ check_admin_referer('avh_ec_editgroup');
471
+
472
  $formoptions = $_POST['avhec_edit_group'];
473
  $selected_categories = $_POST['post_category'];
474
+
475
+ $group_id = (int) $_POST['avhec-group_id'];
476
+ $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']);
477
+ switch ($result) {
478
+ case 1:
479
+ $this->message = __('Category group updated', 'avh-ec');
 
480
  $this->status = 'updated fade';
481
  break;
482
+ case 0:
483
+ $this->message = __('Category group not updated', 'avh-ec');
484
+ $this->message .= '<br />' . __('Duplicate slug detected', 'avh-ec');
485
  $this->status = 'error';
486
  break;
487
+ case - 1:
488
+ $this->message = __('Unknown category group', 'avh-ec');
489
  $this->status = 'error';
490
  break;
491
  }
492
  $this->displayMessage();
493
  }
494
+
495
  $hide2 = '';
496
+ switch ($screen_layout_columns) {
497
+ case 2:
 
498
  $width = 'width:49%;';
499
  break;
500
+ default:
501
  $width = 'width:98%;';
502
  $hide2 = 'display:none;';
503
  }
504
+
505
+ $data_special_pages_old = $this->core->options['sp_cat_group'];
506
+ $data_special_pages_new = $data_special_pages_old;
507
+ if (isset($_POST['avhec_special_pages'])) {
508
+ check_admin_referer('avh_ec_specialpagesgroup');
509
+
510
  $formoptions = $_POST['avhec_special_pages'];
511
  $formdata = $formoptions['sp'];
512
  foreach ($formdata as $key => $value) {
513
  $data_special_pages_new[$key] = $value;
514
  }
515
+ $this->core->options['sp_cat_group'] = $data_special_pages_new;
516
  $this->core->saveOptions($this->core->options);
517
+
518
  }
519
+ $data_special_pages['sp'] = $data_special_pages_new;
520
+ $cat_groups = get_terms($this->catgrp->taxonomy_name, array('hide_empty'=>FALSE));
521
+
522
+ foreach ($cat_groups as $group) {
523
+ $temp_cat = get_term($group->term_id, $this->catgrp->taxonomy_name, OBJECT, 'edit');
524
+ $dropdown_value[] = $group->term_id;
525
+ $dropdown_text[] = $temp_cat->name;
526
  }
527
+ $options_special_pages[] = array('avhec_special_pages[sp][home_group]', __('Home page', 'avh-ec'), 'dropdown', $dropdown_value, $dropdown_text, '');
528
+ $options_special_pages[] = array('avhec_special_pages[sp][category_group]', __('Category Archive', 'avh-ec'), 'dropdown', $dropdown_value, $dropdown_text, '');
529
+ $options_special_pages[] = array('avhec_special_pages[sp][day_group]', __('Daily Archive', 'avh-ec'), 'dropdown', $dropdown_value, $dropdown_text, '');
530
+ $options_special_pages[] = array('avhec_special_pages[sp][month_group]', __('Monthly Archive', 'avh-ec'), 'dropdown', $dropdown_value, $dropdown_text, '');
531
+ $options_special_pages[] = array('avhec_special_pages[sp][year_group]', __('Yearly Archive', 'avh-ec'), 'dropdown', $dropdown_value, $dropdown_text, '');
532
+ $options_special_pages[] = array('avhec_special_pages[sp][author_group]', __('Author Archive', 'avh-ec'), 'dropdown', $dropdown_value, $dropdown_text, '');
533
+ $options_special_pages[] = array('avhec_special_pages[sp][search_group]', __('Search Page', 'avh-ec'), 'dropdown', $dropdown_value, $dropdown_text, '');
534
+
535
+ $data['sp'] = array('form'=>$options_special_pages, 'data'=>$data_special_pages);
536
+
537
  // This box can't be unselectd in the the Screen Options
538
  //add_meta_box( 'avhecBoxDonations', __( 'Donations', 'avh-ec' ), array (&$this, 'metaboxDonations' ), $this->hooks['menu_category_groups'], 'side', 'core' );
539
+
540
 
541
+ echo '<div class="wrap avhec-metabox-wrap">';
542
+ echo $this->displayIcon('index');
543
+ echo '<h2>' . 'AVH Extended Categories - ' . __('Category Groups', 'avh-ec') . '</h2>';
544
+
 
545
  echo ' <div id="dashboard-widgets-wrap">';
546
  echo ' <div id="dashboard-widgets" class="metabox-holder">';
547
+
548
  echo ' <div class="postbox-container" style="' . $width . '">' . "\n";
549
+ do_meta_boxes($this->hooks['menu_category_groups'], 'normal', $data);
550
  echo " </div>";
551
+
552
  echo ' <div class="postbox-container" style="' . $hide2 . $width . '">' . "\n";
553
+ do_meta_boxes($this->hooks['menu_category_groups'], 'side', $data);
554
  echo ' </div>';
555
+
556
  echo ' </div>'; // dashboard-widgets
557
  echo '<br class="clear" />';
558
  echo ' </div>'; //dashboard-widgets-wrap
559
  echo '</div>'; // wrap
560
+
561
 
562
  $this->printMetaboxGeneralNonces();
563
+ $this->printMetaboxJS('grouped');
564
  $this->printAdminFooter();
565
  }
566
 
568
  * Metabox for Adding a group
569
  * @param $data
570
  */
571
+ function metaboxCategoryGroupAdd ($data)
572
  {
573
  echo '<form name="avhec-addgroup" id="avhec-addgroup" method="POST" action="' . $this->getBackLink() . '" accept-charset="utf-8" >';
574
+ wp_nonce_field('avh_ec_addgroup');
575
+ echo $this->printOptions($data['add']['form'], $data['add']['data']);
576
+ echo '<p class="submit"><input class="button" type="submit" name="addgroup" value="' . __('Add group', 'avh-ec') . '" /></p>';
577
  echo '</form>';
578
  }
579
 
582
  *
583
  * @param $data
584
  */
585
+ function metaboxCategoryGroupList ($data)
586
  {
587
  echo '<form id="posts-filter" action="" method="get">';
588
+
589
  echo '<div class="clear"></div>';
590
+
591
  echo '<table class="widefat fixed" cellspacing="0">';
592
  echo '<thead>';
593
  echo '<tr>';
594
+ print_column_headers('categories_group');
595
  echo '</tr>';
596
  echo '</thead>';
597
+
598
  echo '<tfoot>';
599
  echo '<tr>';
600
+ print_column_headers('categories_group', false);
601
  echo '</tr>';
602
  echo '</tfoot>';
603
+
604
  echo '<tbody id="the-list" class="list:group">';
605
  $this->printCategoryGroupRows();
606
  echo '</tbody>';
607
  echo '</table>';
608
+
609
  echo '<br class="clear" />';
610
  echo '</form>';
611
+
612
+ //echo '</div>';
613
  }
614
 
615
  /**
616
  * Metabox Category Group Edit
617
  *
618
  */
619
+ function metaboxCategoryGroupEdit ($data)
620
  {
621
  echo '<form name="avhec-editgroup" id="avhec-editgroup" method="POST" action="' . $this->getBackLink() . '" accept-charset="utf-8" >';
622
+ wp_nonce_field('avh_ec_editgroup');
623
+ echo $this->printOptions($data['edit']['form'], $data['edit']['data']);
624
  echo '<input type="hidden" value="' . $data['edit']['data']['edit']['group_id'] . '" name="avhec-group_id" id="avhec-group_id">';
625
+ echo '<p class="submit"><input class="button" type="submit" name="editgroup" value="' . __('Update group', 'avh-ec') . '" /></p>';
626
  echo '</form>';
627
  }
628
 
630
  * Metabox Category Group Special pages
631
  *
632
  */
633
+ function metaboxCategoryGroupSpecialPages ($data)
634
  {
635
  echo '<form name="avhec-specialpagesgroup" id="avhec-specialpagesgroup" method="POST" action="' . $this->getBackLink() . '" accept-charset="utf-8" >';
636
+ wp_nonce_field('avh_ec_specialpagesgroup');
637
+ echo $this->printOptions($data['sp']['form'], $data['sp']['data']);
638
+ echo '<p class="submit"><input class="button" type="submit" name="spgroup" value="' . __('Save settings', 'avh-ec') . '" /></p>';
639
  echo '</form>';
640
  }
641
+
642
  /**
643
  * Setup everything needed for the FAQ page
644
  *
645
  */
646
  function actionLoadPageHook_faq ()
647
  {
648
+
649
+ add_meta_box('avhecBoxFAQ', __('F.A.Q.', 'avh-ec'), array(&$this, 'metaboxFAQ'), $this->hooks['menu_faq'], 'normal', 'core');
650
+ add_meta_box('avhecBoxTranslation', __('Translation', 'avh-ec'), array(&$this, 'metaboxTranslation'), $this->hooks['menu_faq'], 'normal', 'core');
651
+
652
+ add_filter('screen_layout_columns', array(&$this, 'filterScreenLayoutColumns'), 10, 2);
653
+
654
  // WordPress core Styles and Scripts
655
+ wp_enqueue_script('common');
656
+ wp_enqueue_script('wp-lists');
657
+ wp_enqueue_script('postbox');
658
+
659
  // WordPress core Styles
660
+ wp_admin_css('css/dashboard');
661
+
662
  // Plugin Style
663
+ wp_enqueue_style('avhec-admin-css');
664
+
665
  }
666
 
667
  /**
672
  function doMenuFAQ ()
673
  {
674
  global $screen_layout_columns;
675
+
676
  // This box can't be unselectd in the the Screen Options
677
+ add_meta_box('avhecBoxAnnouncements', __('Announcements', 'avh-ec'), array(&$this, 'metaboxAnnouncements'), $this->hooks['menu_faq'], 'side', 'core');
678
+ add_meta_box('avhecBoxDonations', __('Donations', 'avh-ec'), array(&$this, 'metaboxDonations'), $this->hooks['menu_faq'], 'side', 'core');
679
+
680
  $hide2 = '';
681
+ switch ($screen_layout_columns) {
682
+ case 2:
 
683
  $width = 'width:49%;';
684
  break;
685
+ default:
686
  $width = 'width:98%;';
687
  $hide2 = 'display:none;';
688
  }
689
+
690
+ echo '<div class="wrap avhec-metabox-wrap">';
691
+ echo $this->displayIcon('index');
692
+ echo '<h2>' . 'AVH Extended Categories - ' . __('F.A.Q', 'avh-ec') . '</h2>';
693
  echo ' <div id="dashboard-widgets-wrap">';
694
  echo ' <div id="dashboard-widgets" class="metabox-holder">';
695
  echo ' <div class="postbox-container" style="' . $width . '">' . "\n";
696
+ do_meta_boxes($this->hooks['menu_faq'], 'normal', '');
697
  echo ' </div>';
698
  echo ' <div class="postbox-container" style="' . $hide2 . $width . '">' . "\n";
699
+ do_meta_boxes($this->hooks['menu_faq'], 'side', '');
700
  echo ' </div>';
701
  echo ' </div>';
702
  echo '<br class="clear"/>';
703
  echo ' </div>'; //dashboard-widgets-wrap
704
  echo '</div>'; // wrap
705
+
706
 
707
  $this->printMetaboxGeneralNonces();
708
+ $this->printMetaboxJS('faq');
709
  $this->printAdminFooter();
710
  }
711
 
715
  */
716
  function metaboxTranslation ()
717
  {
718
+ echo '<div class="p">';
719
+ echo __('This plugin is translated in several languages. Some of the languages might be incomplete. Please help to complete these translations or add a new language.', 'avh-ec') . '<br />';
720
+ echo __('You can visit ', 'avh-ec') . '<a href="https://translations.launchpad.net/avhextendedcategories/trunk" target="_blank">Launchpad</a> ' . __('to help complete these translations or add a new language.', 'avh-ec');
721
+ echo '</div>';
722
+
723
+ echo '<div class="p">';
724
+ echo '<span class="b">' . __('Available Languages', 'avh-ec') . '</span>';
725
  echo '<ul>';
726
  echo '<li>Czech - Čeština (cs_CZ)</li>';
727
  echo '<li>Dutch - Nederlands (nl_NL)</li>';
733
  echo '<li>Swedish - Svenska (sv_SE)</li>';
734
  echo '<li>Turkish - Türkçe (tr)</li>';
735
  echo '</ul>';
736
+ echo '</div>';
737
+
738
+ echo '<div class="p">';
739
+ echo __('More information about translating can found at http://codex.wordpress.org/Translating_WordPress . This page is dedicated for translating WordPress but the instructions are the same for this plugin.', 'avh-ec');
740
+ echo '</div>';
741
+
742
  }
743
 
744
  /**
747
  */
748
  function metaboxDonations ()
749
  {
750
+ echo '<div class="p">';
751
+ echo __('If you enjoy this plug-in please consider a donation. There are several ways you can show your appreciation.', 'avh-ec');
752
+ echo '</div>';
753
+
754
+ echo '<div class="p">';
755
  echo '<span class="b">Amazon</span><br />';
756
+ echo __('If you decide to buy something from Amazon click the button.', 'avh-ec') . '</span><br />';
757
+ echo '<a href="https://www.amazon.com/?&tag=avh-donation-20" target="_blank" title="Amazon Homepage"><img alt="Amazon Button" src="' . $this->core->info['graphics_url'] . '/us_banner_logow_120x60.gif" /></a>';
758
+ echo '</div>';
759
+
760
+ echo '<div class="p">';
761
+ echo __('You can send me something from my ', 'avh-ec') . '<a href="http://www.amazon.com/gp/registry/wishlist/1U3DTWZ72PI7W?tag=avh-donation-20">' . __('Amazon Wish List', 'avh-ec') . '</a>';
762
+ echo '</div>';
763
+
764
+ echo '<div class="p">';
765
+ echo '<span class="b">' . __('Through Paypal.', 'avh-ec') . '</span><br />';
766
+ echo __('Click on the Donate button and you will be directed to Paypal where you can make your donation and you don\'t need to have a Paypal account to make a donation.', 'avh-ec') . '<br />';
767
  echo '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=S85FXJ9EBHAF2&lc=US&item_name=AVH%20Plugins&item_number=fdas&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted" target="_blank" title="Donate">';
768
  echo '<img src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" alt="Donate"/></a>';
769
+ echo '</div>';
770
+
771
  }
772
 
773
  /***
776
  */
777
  function metaboxFAQ ()
778
  {
779
+
780
+ echo '<div class="p">';
781
+ echo '<span class="b">' . __('What about support?', 'avh-ec') . '</span><br />';
782
+ echo __('I created a support site at http://forums.avirtualhome.com where you can ask questions or request features.', 'avh-ec') . '<br />';
783
+ echo '</div>';
784
+
785
+ echo '<div class="p">';
786
+ echo '<span class="b">' . __('What is depth selection?', 'avh-ec') . '</span><br />';
787
+ echo __('Starting with version 2.0 and WordPress 2.8 you can select how many levels deep you want to show your categories. This option only works when you select Show Hierarchy as well.', 'avh-ec') . '<br /><br />';
788
+ echo __('Here is how it works: Say you have 5 top level categories and each top level has a number of children. You could manually select all the Top Level categories you want to show but now you can do the following:', 'avh-ec') . '<br />';
789
+ echo __('You select to display all categories, select to Show hierarchy and select how many levels you want to show, in this case Toplevel only.', 'avh-ec') . '<br />';
790
+ echo '</div>';
791
+
792
+ echo '<div class="p">';
793
+ echo '<span class="b">' . __('Multiple Category Groups', 'avh-ec') . '</span><br />';
794
+ echo __('The following is an explanation how assigning multiple groups to page/post works.', 'avh-ec') . '<br /><br />';
795
+ echo __('Lets say you have the following groups:', 'avh-ec');
796
+ echo '<ul>';
797
+ echo '<li>' . __('Free Time', 'avh-ec') . '</li>';
798
+ echo '<li>' . __('Theater', 'avh-ec') . '</li>';
799
+ echo '<li>' . __('Movie', 'avh-ec') . '</li>';
800
+ echo '<li>' . __('Music', 'avh-ec') . '</li>';
801
+ echo '</ul>';
802
+
803
+ echo __('Setup several Category Group widgets and associated each widget with one or more groups.', 'avh-ec') . '<br />';
804
+ echo __('Widget 1 has association with Free Time', 'avh-ec') . '<br />';
805
+ echo __('Widget 2 has association with Theater, Movie and Music', 'avh-ec') . '<br />';
806
+ echo __('Widget 3 has association with Theater, Movie and Music', 'avh-ec') . '<br /><br />';
807
+
808
+ echo __('Page has associations the groups Free Time and Theater', 'avh-ec');
809
+ echo '<ul>';
810
+ echo '<li>' . __('Widget 1: Shows categories of the Free Time group', 'avh-ec') . '</li>';
811
+ echo '<li>' . __('Widget 2: Shows categories of the Theater group.', 'avh-ec') . '</li>';
812
+ echo '<li>' . __('Widget 3: Not displayed', 'avh-ec') . '</li>';
813
+ echo '</ul>';
814
+
815
+ echo __('Page has associations the group Movie.', 'avh-ec');
816
+ echo '<ul>';
817
+ echo '<li>' . __('Widget 1: Not displayed', 'avh-ec') . '</li>';
818
+ echo '<li>' . __('Widget 2: Shows categories of the Movie group.', 'avh-ec') . '</li>';
819
+ echo '<li>' . __('Widget 3: Not displayed', 'avh-ec') . '</li>';
820
+ echo '</ul>';
821
+
822
+ echo __('Page has associations the groups Free Time, Movie and Music', 'avh-ec');
823
+ echo '<ul>';
824
+ echo '<li>' . __('Widget 1: Shows categories of the Free Time group', 'avh-ec') . '</li>';
825
+ echo '<li>' . __('Widget 2: Shows categories of the Movie or Music group.', 'avh-ec') . '</li>';
826
+ echo '<li>' . __('Widget 3: Shows categories of the Music or Movie group.', 'avh-ec') . '</li>';
827
+ echo '</ul>';
828
+
829
+ echo __('Whether Widget 2 shows Movie or Music depends on the creation order of groups. If Widget 2 shows Movie, Widget 3 will show Music but if Widget 2 shows Music, Widget 3 will show Movie.', 'avh-ec') . '<br />';
830
+ echo '</div>';
831
+
832
  }
833
 
834
  function metaboxAnnouncements ()
835
  {
836
+ $php5 = version_compare('5.2', phpversion(), '<');
837
+ echo '<div class="p">';
838
+ echo '<span class="b">' . __('PHP4 Support', 'avh-ec') . '</span><br />';
839
+ echo __('The next major release of the plugin will no longer support PHP4.', 'avh-ec') . '<br />';
840
+ echo __('It will be written for PHP 5.2 and ', 'avh-ec');
841
+ if ($php5) {
842
+ echo __('your blog already runs the needed PHP version. When the new release comes out you can safely update.', 'avh-ec') . '<br />';
843
  } else {
844
+ echo __('your blog still runs PHP4. When the new release comes out you can not use it.', 'avh-ec') . '<br />';
845
+ echo __('I don\'t have a timeline for the next version but consider contacting your host if PHP 5.2 is available.', 'avh-ec') . '<br />';
846
+ echo __('If your hosts doesn\'t offer PHP 5.2 you might want to consider switching hosts.', 'avh-ec') . '<br />';
847
+ echo __('A host to consider is ', 'avh-ec') . '<a href="http://www.lunarpages.com/id/pdoes" target="_blank">Lunarpages</a>';
848
+ echo __('I run my personal blog there and I am very happy with their services. You can get an account with unlimited bandwidth, storage and much more for a low price.', 'avh-ec');
849
  }
850
+ echo '</div>';
851
+
852
  }
853
 
854
  /**
858
  * @param $screen
859
  * @return strings
860
  */
861
+
862
+ function filterScreenLayoutColumns ($columns, $screen)
863
  {
864
+ switch ($screen) {
865
+ case $this->hooks['menu_overview']:
 
866
  $columns[$this->hooks['menu_overview']] = 2;
867
  break;
868
+ case $this->hooks['menu_general']:
869
  $columns[$this->hooks['menu_general']] = 2;
870
  break;
871
+ case $this->hooks['menu_category_groups']:
872
  $columns[$this->hooks['menu_category_groups']] = 2;
873
  break;
874
+ case $this->hooks['menu_faq']:
875
  $columns[$this->hooks['menu_faq']] = 2;
876
  break;
877
+
878
  }
879
  return $columns;
880
  }
885
  * @WordPress Filter plugin_action_links_avh-amazon/avh-amazon.php
886
  *
887
  */
888
+ function filterPluginActions ($links, $file)
889
  {
890
+ $settings_link = '<a href="admin.php?page=extended-categories-widget">' . __('Settings', 'avh-ec') . '</a>';
891
+ array_unshift($links, $settings_link); // before other links
892
  return $links;
893
+
894
  }
895
 
896
  /**
900
  * @return Array
901
  * @see print_column_headers, get_column_headers
902
  */
903
+ function filterManageCategoriesGroupColumns ($columns)
904
  {
905
+ $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'));
906
  return $categories_group_columns;
907
  }
908
 
915
  * @WordPress Filter explain_nonce_$verb-$noun
916
  * @see wp_explain_nonce
917
  */
918
+ function filterExplainNonceDeleteGroup ($text, $group_id)
919
  {
920
+ $group = get_term($group_id, $this->catgrp->taxonomy_name, OBJECT, 'display');
921
+
922
+ $return = sprintf(__('Your attempt to delete this group: &#8220;%s&#8221; has failed.'), $group->name);
923
  return ($return);
924
  }
925
 
926
  ############## Admin WP Helper ##############
927
+
928
 
929
  /**
930
  * Get the backlink for forms
933
  */
934
  function getBackLink ()
935
  {
936
+ $page = basename(__FILE__);
937
+ if (isset($_GET['page']) && ! empty($_GET['page'])) {
938
+ $page = preg_replace('[^a-zA-Z0-9\.\_\-]', '', $_GET['page']);
939
  }
940
+
941
+ if (function_exists("admin_url"))
942
+ return admin_url(basename($_SERVER["PHP_SELF"])) . "?page=" . $page;
943
  else
944
  return $_SERVER['PHP_SELF'] . "?page=" . $page;
945
  }
952
  */
953
  function printCategoryGroupRows ()
954
  {
955
+ $cat_groups = get_terms($this->catgrp->taxonomy_name, array('hide_empty'=>FALSE));
956
+
957
+ foreach ($cat_groups as $group) {
958
+ if ('none' != $group->slug) {
959
+ echo $this->printCategoryGroupRow($group->term_id, $group->term_taxonomy_id);
960
  }
961
  }
962
  }
968
  * @param int $group_term_id
969
  * @param int $group_term_taxonomy_id
970
  */
971
+ function printCategoryGroupRow ($group_term_id, $group_term_taxonomy_id)
972
  {
973
  static $row_class = '';
974
+
975
+ $group = get_term($group_term_id, $this->catgrp->taxonomy_name, OBJECT, 'display');
976
+
977
+ $no_edit[$this->catgrp->getTermIDBy('slug', 'all')] = 0;
978
+ $no_delete[$this->catgrp->getTermIDBy('slug', 'all')] = 0;
979
+
980
+ if (current_user_can('manage_categories')) {
981
+ $actions = array();
982
+ if (! array_key_exists($group->term_id, $no_edit)) {
983
  $edit_link = "admin.php?page=avhec-grouped&amp;action=edit&amp;group_ID=$group->term_id";
984
+ $edit = "<a class='row-title' href='$edit_link' title='" . esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $group->name)) . "'>" . esc_attr($group->name) . '</a><br />';
985
+
986
+ $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
987
  } else {
988
+ $edit = esc_attr($group->name);
989
  }
990
+ if (! (array_key_exists($group->term_id, $no_delete))) {
991
+ $actions['delete'] = "<a class='delete:the-list:group-$group->term_id submitdelete' href='" . wp_nonce_url("admin.php?page=avhec-grouped&amp;action=delete&amp;group_ID=$group->term_id", 'delete-avhecgroup_' . $group->term_id) . "'>" . __('Delete') . "</a>";
992
  }
993
+ $action_count = count($actions);
994
  $i = 0;
995
  $edit .= '<div class="row-actions">';
996
+ foreach ($actions as $action => $link) {
997
  ++ $i;
998
  ($i == $action_count) ? $sep = '' : $sep = ' | ';
999
  $edit .= "<span class='$action'>$link$sep</span>";
1002
  } else {
1003
  $edit = $group->name;
1004
  }
1005
+
1006
  $row_class = 'alternate' == $row_class ? '' : 'alternate';
1007
+ $qe_data = get_term($group->term_id, $this->catgrp->taxonomy_name, OBJECT, 'edit');
1008
+
1009
  $output = "<tr id='group-$group->term_id' class='iedit $row_class'>";
1010
+
1011
+ $columns = get_column_headers('categories_group');
1012
+ $hidden = get_hidden_columns('categories_group');
1013
+ foreach ($columns as $column_name => $column_display_name) {
1014
  $class = 'class="' . $column_name . ' column-' . $column_name . '"';
1015
+
1016
  $style = '';
1017
+ if (in_array($column_name, $hidden))
1018
  $style = ' style="display:none;"';
1019
+
1020
  $attributes = $class . $style;
1021
+
1022
+ switch ($column_name) {
1023
+ case 'cb':
 
1024
  $output .= '<th scope="row" class="check-column">';
1025
+ if (! (array_key_exists($group->term_id, $no_delete))) {
1026
  $output .= '<input type="checkbox" name="delete[]" value="' . $group->term_id . '" />';
1027
  } else {
1028
  $output .= "&nbsp;";
1029
  }
1030
  $output .= '</th>';
1031
  break;
1032
+ case 'name':
1033
  $output .= '<td ' . $attributes . '>' . $edit;
1034
  $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
1035
  $output .= '<div class="name">' . $qe_data->name . '</div>';
1036
+ $output .= '<div class="slug">' . apply_filters('editable_slug', $qe_data->slug) . '</div>';
1037
  $output .= '</div></td>';
1038
  break;
1039
+ case 'widget-title':
1040
  $title = $this->catgrp->getWidgetTitleForGroup($group->term_id);
1041
  $output .= '<td ' . $attributes . '>' . $title . '</td>';
1042
  break;
1043
+
1044
+ case 'description':
1045
  $output .= '<td ' . $attributes . '>' . $qe_data->description . '</td>';
1046
  break;
1047
+ case 'slug':
1048
+ $output .= "<td $attributes>" . apply_filters('editable_slug', $qe_data->slug) . "</td>";
1049
  break;
1050
+ case 'cat-in-group':
1051
+ $cats = $this->catgrp->getCategoriesFromGroup($group_term_id);
1052
+ $catname = array();
1053
+ foreach ($cats as $cat_id) {
1054
+ $catname[] = get_cat_name($cat_id);
1055
  }
1056
+ natsort($catname);
1057
+ $cat = implode(', ', $catname);
1058
  $output .= '<td ' . $attributes . '>' . $cat . '</td>';
1059
  break;
1060
+
1061
  }
1062
  }
1063
  $output .= '</tr>';
1064
+
1065
  return $output;
1066
  }
1067
 
1072
  {
1073
  echo '<form style="display:none" method="get" action="">';
1074
  echo '<p>';
1075
+ wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1076
+ wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1077
  echo '</p>';
1078
  echo '</form>';
1079
+
1080
  }
1081
 
1082
  /**
1084
  *
1085
  * @param $boxid
1086
  */
1087
+ function printMetaboxJS ($boxid)
1088
  {
1089
  $a = $this->hooks['menu_' . $boxid];
1090
  echo '<script type="text/javascript">' . "\n";
1096
  echo ' });' . "\n";
1097
  echo ' //]]>' . "\n";
1098
  echo '</script>';
1099
+
1100
  }
1101
 
1102
  /**
1106
  function printAdminFooter ()
1107
  {
1108
  echo '<p class="footer_avhec">';
1109
+ printf('&copy; Copyright 2011 <a href="http://blog.avirtualhome.com/" title="My Thoughts">Peter van der Does</a> | AVH Extended Categories Version %s', $this->core->version);
1110
  echo '</p>';
1111
  }
1112
 
1116
  */
1117
  function displayMessage ()
1118
  {
1119
+ if ($this->message != '') {
1120
  $message = $this->message;
1121
  $status = $this->status;
1122
  $this->message = $this->status = ''; // Reset
1123
  }
1124
+ if (isset($message)) {
1125
  $status = ($status != '') ? $status : 'updated fade';
1126
  echo '<div id="message" class="' . $status . '">';
1127
  echo '<p><strong>' . $message . '</strong></p></div>';
1134
  * @param array $option_data
1135
  * @return string
1136
  */
1137
+ function printOptions ($option_data, $option_actual)
1138
  {
1139
  // Generate output
1140
  $output = '';
1141
  $output .= "\n" . '<table class="form-table avhec-options">' . "\n";
1142
+ foreach ($option_data as $option) {
1143
+ $section = substr($option[0], strpos($option[0], '[') + 1);
1144
+ $section = substr($section, 0, strpos($section, ']['));
1145
+ $option_key = rtrim($option[0], ']');
1146
+ $option_key = substr($option_key, strpos($option_key, '][') + 2);
1147
  // Helper
1148
+ if ($option[2] == 'helper') {
1149
  $output .= '<tr style="vertical-align: top;"><td class="helper" colspan="2">' . $option[4] . '</td></tr>' . "\n";
1150
  continue;
1151
  }
1152
+ switch ($option[2]) {
1153
+ case 'checkbox':
1154
+ $input_type = '<input type="checkbox" id="' . $option[0] . '" name="' . $option[0] . '" value="' . attribute_escape($option[3]) . '" ' . $this->isChecked('1', $option_actual[$section][$option_key]) . ' />' . "\n";
 
1155
  $explanation = $option[4];
1156
  break;
1157
+ case 'dropdown':
1158
  $selvalue = $option[3];
1159
  $seltext = $option[4];
1160
  $seldata = '';
1161
+ foreach ((array) $selvalue as $key => $sel) {
1162
+ $seldata .= '<option value="' . $sel . '" ' . (($option_actual[$section][$option_key] == $sel) ? 'selected="selected"' : '') . ' >' . ucfirst($seltext[$key]) . '</option>' . "\n";
1163
  }
1164
  $input_type = '<select id="' . $option[0] . '" name="' . $option[0] . '">' . $seldata . '</select>' . "\n";
1165
  $explanation = $option[5];
1166
  break;
1167
+ case 'text-color':
1168
+ $input_type = '<input type="text" ' . (($option[3] > 1) ? ' style="width: 95%" ' : '') . 'id="' . $option[0] . '" name="' . $option[0] . '" value="' . attribute_escape($option_actual[$section][$option_key]) . '" size="' . $option[3] . '" /><div class="box_color ' . $option[0] . '"></div>' . "\n";
1169
  $explanation = $option[4];
1170
  break;
1171
+ case 'textarea':
1172
+ $input_type = '<textarea rows="' . $option[5] . '" ' . (($option[3] > 1) ? ' style="width: 95%" ' : '') . 'id="' . $option[0] . '" name="' . $option[0] . '" size="' . $option[3] . '" />' . attribute_escape($option_actual[$section][$option_key]) . '</textarea>';
1173
  $explanation = $option[4];
1174
  break;
1175
+ case 'catlist':
1176
  ob_start();
1177
  echo '<div id="avhec-catlist">';
1178
  echo '<ul>';
1179
+ wp_category_checklist(0, 0, $option_actual[$section][$option_key]);
1180
  echo '</ul>';
1181
  echo '</div>';
1182
  $input_type = ob_get_contents();
1183
  ob_end_clean();
1184
  $explanation = $option[4];
1185
  break;
1186
+ case 'text':
1187
+ default:
1188
+ $input_type = '<input type="text" ' . (($option[3] > 1) ? ' style="width: 95%" ' : '') . 'id="' . $option[0] . '" name="' . $option[0] . '" value="' . attribute_escape($option_actual[$section][$option_key]) . '" size="' . $option[3] . '" />' . "\n";
1189
  $explanation = $option[4];
1190
  break;
1191
  }
1192
  // Additional Information
1193
  $extra = '';
1194
+ if ($explanation) {
1195
+ $extra = '<br /><span class="description">' . __($explanation) . '</span>' . "\n";
1196
  }
1197
  // Output
1198
+ $output .= '<tr style="vertical-align: top;"><th align="left" scope="row"><label for="' . $option[0] . '">' . __($option[1]) . '</label></th><td>' . $input_type . ' ' . $extra . '</td></tr>' . "\n";
1199
  }
1200
  $output .= '</table>' . "\n";
1201
  return $output;
1208
  * @param mixed $current
1209
  * @return strings
1210
  */
1211
+ function isChecked ($checked, $current)
1212
  {
1213
  $return = '';
1214
+ if ($checked == $current) {
1215
  $return = ' checked="checked"';
1216
  }
1217
  return $return;
1222
  *
1223
  * @param $icon
1224
  */
1225
+ function displayIcon ($icon)
1226
  {
1227
  return ('<div class="icon32" id="icon-' . $icon . '"><br/></div>');
1228
  }
1232
  */
1233
  function ajaxDeleteGroup ()
1234
  {
1235
+ $group_id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
1236
+ check_ajax_referer('delete-avhecgroup_' . $group_id);
1237
+
1238
+ if (! current_user_can('manage_categories')) {
1239
+ die('-1');
1240
  }
1241
+ $check = $this->catgrp->getGroup($group_id);
1242
+ if (false === $check) {
1243
+ die('1');
1244
  }
1245
+
1246
+ if ($this->catgrp->doDeleteGroup($group_id)) {
1247
+ die('1');
1248
  } else {
1249
+ die('0');
1250
  }
1251
  }
1252
  }
2.8/class/avh-ec.category-group.php CHANGED
@@ -13,11 +13,11 @@ class AVH_EC_Category_Group
13
  * @var string
14
  */
15
  var $taxonomy_name;
16
-
17
  var $db_options_widget_titles;
18
-
19
  var $options_widget_titles;
20
-
21
  var $widget_done_catgroup;
22
 
23
  /**
@@ -37,29 +37,31 @@ class AVH_EC_Category_Group
37
  function __construct ()
38
  {
39
  global $wpdb;
40
-
41
  register_shutdown_function(array(&$this, '__destruct'));
42
-
43
  /**
44
  * Taxonomy name
45
  * @var string
46
  */
47
  $this->taxonomy_name = 'avhec_catgroup';
48
-
49
  $this->db_options_widget_titles = 'avhec_widget_titles';
50
  // add DB pointer
51
  $wpdb->avhec_cat_group = $wpdb->prefix . 'avhec_category_groups';
52
-
53
  /**
54
  * Create the table if it doesn't exist.
55
  *
56
  */
57
  if ($wpdb->get_var('show tables like \'' . $wpdb->avhec_cat_group . '\'') != $wpdb->avhec_cat_group) {
58
- add_action('init', array(&$this, 'doCreateTable') ,2); // Priority needs to be the same as the Register Taxonomy
59
  }
60
  add_action('init', array(&$this, 'doRegisterTaxonomy'), 2); // Priority for registering custom taxonomies is +1 over the creation of the initial taxonomies
61
  add_action('init', array(&$this, 'doSetupOptions'));
62
-
 
 
63
  }
64
 
65
  /**
@@ -72,25 +74,60 @@ class AVH_EC_Category_Group
72
  return true;
73
  }
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  /**
76
  * Setup Group Categories Taxonomy
77
- * @WordPress_action init
78
  *
79
  */
80
  function doRegisterTaxonomy ()
81
  {
82
  /**
83
- * Setup Group Categories Taxonomy
 
84
  */
85
  $labels = array('name'=>__('Category Groups', 'avh-ec'), 'singular_name'=>__('Category Group', 'avh-ec'), 'search_items'=>__('Search Category Groups', 'avh-ec'), 'popular_items'=>__('Popular Category Groups'), 'all_items'=>__('All Category Groups'), 'parent_item'=>__('Parent Category Group'), 'parent_item_colon'=>__('Parent Category Group:'), 'edit_item'=>__('Edit Category Group'), 'update_item'=>__('Update Category Group'), 'add_new_item'=>__('Add New Category Group'), 'new_item_name'=>__('New Category Group Name'));
86
- register_taxonomy($this->taxonomy_name, array('post', 'page'), array('hierarchical'=>FALSE, 'labels'=> $labels, 'query_var'=>TRUE, 'rewrite'=>TRUE, 'show_in_nav_menus'=>FALSE));
 
 
 
87
 
 
 
 
 
 
 
 
88
  // Setup the standard groups if the none group does not exists.
89
  if (false === $this->getTermIDBy('slug', 'none')) {
90
- $none_group_id = wp_insert_term('none', $this->taxonomy_name, array('description'=>__('This group will not show the widget.','avh-ec')));
91
- $all_group_id = wp_insert_term('All', $this->taxonomy_name, array('description'=>__('Holds all the categories.','avh-ec')));
92
- $home_group_id = wp_insert_term('Home', $this->taxonomy_name, array('description'=>__('This group will be shown on the front page.','avh-ec')));
93
-
94
  // Fill the standard groups with all categories
95
  $all_categories = $this->getAllCategoriesTermID();
96
  $this->setCategoriesForGroup($all_group_id['term_id'], $all_categories);
@@ -98,15 +135,7 @@ class AVH_EC_Category_Group
98
  $this->setWidgetTitleForGroup($all_group_id['term_id'], '');
99
  $this->setWidgetTitleForGroup($home_group_id['term_id'], '');
100
  }
101
- }
102
-
103
- /**
104
- * Setup the options for the widget titles
105
- * @WordPress_action init
106
- *
107
- */
108
- function doSetupOptions ()
109
- {
110
  $options = get_option($this->db_options_widget_titles);
111
  if (! $options) {
112
  $options = array();
@@ -120,27 +149,14 @@ class AVH_EC_Category_Group
120
  }
121
 
122
  /**
123
- * Create Table
124
- * @WordPress_action init
125
  *
126
  */
127
- function doCreateTable ()
128
  {
129
- global $wpdb;
130
-
131
- // Setup the DB Tables
132
- $charset_collate = '';
133
-
134
- if (version_compare(mysql_get_server_info(), '4.1.0', '>=')) {
135
- if (! empty($wpdb->charset))
136
- $charset_collate = 'DEFAULT CHARACTER SET ' . $wpdb->charset;
137
- if (! empty($wpdb->collate))
138
- $charset_collate .= ' COLLATE ' . $wpdb->collate;
139
- }
140
-
141
- $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 . ';';
142
-
143
- $result = $wpdb->query($sql);
144
  }
145
 
146
  /**
@@ -167,10 +183,10 @@ class AVH_EC_Category_Group
167
  function getCategoriesFromGroup ($group_id)
168
  {
169
  global $wpdb;
170
-
171
  // Query database
172
  $result = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->terms . ' t, ' . $wpdb->avhec_cat_group . ' cg WHERE t.term_id = cg.term_id AND cg.group_term_id = %d', $group_id));
173
-
174
  if (is_array($result)) { // Call succeeded
175
  if (empty($result)) { // No rows found
176
  $return = array();
@@ -196,9 +212,9 @@ class AVH_EC_Category_Group
196
  function setCategoriesForGroup ($group_id, $categories = array())
197
  {
198
  global $wpdb;
199
-
200
  $old_categories = $this->getCategoriesFromGroup($group_id);
201
-
202
  if (! is_array($categories)) {
203
  $categories = array();
204
  }
@@ -209,10 +225,10 @@ class AVH_EC_Category_Group
209
  if ($new_categories === $old_categories) {
210
  return false;
211
  }
212
-
213
  $new = array_diff($new_categories, $old_categories);
214
  $removed = array_diff($old_categories, $new_categories);
215
-
216
  if (! empty($new)) {
217
  foreach ($new as $cat_term_id) {
218
  $insert[] = '(' . $group_id . ',' . $cat_term_id . ')';
@@ -220,16 +236,16 @@ class AVH_EC_Category_Group
220
  $value = implode(',', $insert);
221
  $sql = 'INSERT INTO ' . $wpdb->avhec_cat_group . ' (group_term_id, term_id) VALUES ' . $value;
222
  $result = $wpdb->query($sql);
223
-
224
  }
225
-
226
  if (! empty($removed)) {
227
  $delete = implode(',', $removed);
228
  $sql = $wpdb->prepare('DELETE FROM ' . $wpdb->avhec_cat_group . ' WHERE group_term_id=%d and term_id IN (' . $delete . ')', $group_id);
229
  $result = $wpdb->query($sql);
230
-
231
  }
232
-
233
  return $result;
234
  }
235
 
@@ -297,7 +313,7 @@ class AVH_EC_Category_Group
297
  function getGroup ($group_id)
298
  {
299
  global $wpdb;
300
-
301
  $result = get_term((int) $group_id, $this->taxonomy_name);
302
  if (null === $result) {
303
  $result = false;
@@ -325,14 +341,14 @@ class AVH_EC_Category_Group
325
  */
326
  function doDeleteGroup ($group_id)
327
  {
328
-
329
  global $wpdb;
330
-
331
  $group = $this->getGroup($group_id);
332
  $result = $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->avhec_cat_group . ' WHERE group_term_id=%d', $group_id));
333
  $this->doDeleteWidgetTitle($group_id);
334
  $return = wp_delete_term($group->term_id, $this->taxonomy_name);
335
-
336
  return ($return);
337
  }
338
 
@@ -347,7 +363,7 @@ class AVH_EC_Category_Group
347
  */
348
  function doUpdateGroup ($group_id, $args = array(), $selected_categories, $widget_title = '')
349
  {
350
-
351
  $group = $this->getGroup($group_id);
352
  if (is_object($group)) {
353
  $id = wp_update_term($group->term_id, $this->taxonomy_name, $args);
13
  * @var string
14
  */
15
  var $taxonomy_name;
16
+
17
  var $db_options_widget_titles;
18
+
19
  var $options_widget_titles;
20
+
21
  var $widget_done_catgroup;
22
 
23
  /**
37
  function __construct ()
38
  {
39
  global $wpdb;
40
+
41
  register_shutdown_function(array(&$this, '__destruct'));
42
+
43
  /**
44
  * Taxonomy name
45
  * @var string
46
  */
47
  $this->taxonomy_name = 'avhec_catgroup';
48
+
49
  $this->db_options_widget_titles = 'avhec_widget_titles';
50
  // add DB pointer
51
  $wpdb->avhec_cat_group = $wpdb->prefix . 'avhec_category_groups';
52
+
53
  /**
54
  * Create the table if it doesn't exist.
55
  *
56
  */
57
  if ($wpdb->get_var('show tables like \'' . $wpdb->avhec_cat_group . '\'') != $wpdb->avhec_cat_group) {
58
+ add_action('init', array(&$this, 'doCreateTable'), 2); // Priority needs to be the same as the Register Taxonomy
59
  }
60
  add_action('init', array(&$this, 'doRegisterTaxonomy'), 2); // Priority for registering custom taxonomies is +1 over the creation of the initial taxonomies
61
  add_action('init', array(&$this, 'doSetupOptions'));
62
+
63
+ add_action('admin_init', array(&$this, 'addMetaBoxes'));
64
+
65
  }
66
 
67
  /**
74
  return true;
75
  }
76
 
77
+ /**
78
+ * Create Table
79
+ * @WordPress action init
80
+ *
81
+ */
82
+ function doCreateTable ()
83
+ {
84
+ global $wpdb;
85
+
86
+ // Setup the DB Tables
87
+ $charset_collate = '';
88
+
89
+ if (version_compare(mysql_get_server_info(), '4.1.0', '>=')) {
90
+ if (! empty($wpdb->charset))
91
+ $charset_collate = 'DEFAULT CHARACTER SET ' . $wpdb->charset;
92
+ if (! empty($wpdb->collate))
93
+ $charset_collate .= ' COLLATE ' . $wpdb->collate;
94
+ }
95
+
96
+ $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 . ';';
97
+
98
+ $result = $wpdb->query($sql);
99
+ }
100
+
101
  /**
102
  * Setup Group Categories Taxonomy
103
+ * @WordPress action init
104
  *
105
  */
106
  function doRegisterTaxonomy ()
107
  {
108
  /**
109
+ * As we don't want to see the Menu Item we have to disable show_ui. This also disables the metabox on the posts and pages, so we add thse manually instead.
110
+ * We remove the capabilities to manage, edit and delete the terms. We have written this part ourselves and don't use WordPress for these functions. The only one we use is the assign_terms.
111
  */
112
  $labels = array('name'=>__('Category Groups', 'avh-ec'), 'singular_name'=>__('Category Group', 'avh-ec'), 'search_items'=>__('Search Category Groups', 'avh-ec'), 'popular_items'=>__('Popular Category Groups'), 'all_items'=>__('All Category Groups'), 'parent_item'=>__('Parent Category Group'), 'parent_item_colon'=>__('Parent Category Group:'), 'edit_item'=>__('Edit Category Group'), 'update_item'=>__('Update Category Group'), 'add_new_item'=>__('Add New Category Group'), 'new_item_name'=>__('New Category Group Name'));
113
+ $caps = array('manage_terms'=>null, 'edit_terms'=>null, 'delete_terms'=>null, 'assign_terms'=>'edit_posts');
114
+ register_taxonomy($this->taxonomy_name, array('post', 'page'), array('hierarchical'=>FALSE, 'labels'=>$labels, 'query_var'=>TRUE, 'rewrite'=>TRUE, 'show_in_nav_menus'=>FALSE, 'public'=>TRUE, 'show_ui'=>FALSE, 'capabilities'=>$caps));
115
+
116
+ }
117
 
118
+ /**
119
+ * Setup the options for the widget titles
120
+ * @WordPress action init
121
+ *
122
+ */
123
+ function doSetupOptions ()
124
+ {
125
  // Setup the standard groups if the none group does not exists.
126
  if (false === $this->getTermIDBy('slug', 'none')) {
127
+ $none_group_id = wp_insert_term('none', $this->taxonomy_name, array('description'=>__('This group will not show the widget.', 'avh-ec')));
128
+ $all_group_id = wp_insert_term('All', $this->taxonomy_name, array('description'=>__('Holds all the categories.', 'avh-ec')));
129
+ $home_group_id = wp_insert_term('Home', $this->taxonomy_name, array('description'=>__('This group will be shown on the front page.', 'avh-ec')));
130
+
131
  // Fill the standard groups with all categories
132
  $all_categories = $this->getAllCategoriesTermID();
133
  $this->setCategoriesForGroup($all_group_id['term_id'], $all_categories);
135
  $this->setWidgetTitleForGroup($all_group_id['term_id'], '');
136
  $this->setWidgetTitleForGroup($home_group_id['term_id'], '');
137
  }
138
+
 
 
 
 
 
 
 
 
139
  $options = get_option($this->db_options_widget_titles);
140
  if (! $options) {
141
  $options = array();
149
  }
150
 
151
  /**
152
+ * Add the metaboxes for the pots and page pages.
153
+ * @WordPress action admin_init
154
  *
155
  */
156
+ function addMetaBoxes ()
157
  {
158
+ add_meta_box($this->taxonomy_name . 'div', __('Category Groups', 'avh-ec'), 'post_categories_meta_box', 'post', 'side', 'core', array('taxonomy'=>$this->taxonomy_name));
159
+ add_meta_box($this->taxonomy_name . 'div', __('Category Groups', 'avh-ec'), 'post_categories_meta_box', 'page', 'side', 'core', array('taxonomy'=>$this->taxonomy_name));
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  }
161
 
162
  /**
183
  function getCategoriesFromGroup ($group_id)
184
  {
185
  global $wpdb;
186
+
187
  // Query database
188
  $result = $wpdb->get_results($wpdb->prepare('SELECT * FROM ' . $wpdb->terms . ' t, ' . $wpdb->avhec_cat_group . ' cg WHERE t.term_id = cg.term_id AND cg.group_term_id = %d', $group_id));
189
+
190
  if (is_array($result)) { // Call succeeded
191
  if (empty($result)) { // No rows found
192
  $return = array();
212
  function setCategoriesForGroup ($group_id, $categories = array())
213
  {
214
  global $wpdb;
215
+
216
  $old_categories = $this->getCategoriesFromGroup($group_id);
217
+
218
  if (! is_array($categories)) {
219
  $categories = array();
220
  }
225
  if ($new_categories === $old_categories) {
226
  return false;
227
  }
228
+
229
  $new = array_diff($new_categories, $old_categories);
230
  $removed = array_diff($old_categories, $new_categories);
231
+
232
  if (! empty($new)) {
233
  foreach ($new as $cat_term_id) {
234
  $insert[] = '(' . $group_id . ',' . $cat_term_id . ')';
236
  $value = implode(',', $insert);
237
  $sql = 'INSERT INTO ' . $wpdb->avhec_cat_group . ' (group_term_id, term_id) VALUES ' . $value;
238
  $result = $wpdb->query($sql);
239
+
240
  }
241
+
242
  if (! empty($removed)) {
243
  $delete = implode(',', $removed);
244
  $sql = $wpdb->prepare('DELETE FROM ' . $wpdb->avhec_cat_group . ' WHERE group_term_id=%d and term_id IN (' . $delete . ')', $group_id);
245
  $result = $wpdb->query($sql);
246
+
247
  }
248
+
249
  return $result;
250
  }
251
 
313
  function getGroup ($group_id)
314
  {
315
  global $wpdb;
316
+
317
  $result = get_term((int) $group_id, $this->taxonomy_name);
318
  if (null === $result) {
319
  $result = false;
341
  */
342
  function doDeleteGroup ($group_id)
343
  {
344
+
345
  global $wpdb;
346
+
347
  $group = $this->getGroup($group_id);
348
  $result = $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->avhec_cat_group . ' WHERE group_term_id=%d', $group_id));
349
  $this->doDeleteWidgetTitle($group_id);
350
  $return = wp_delete_term($group->term_id, $this->taxonomy_name);
351
+
352
  return ($return);
353
  }
354
 
363
  */
364
  function doUpdateGroup ($group_id, $args = array(), $selected_categories, $widget_title = '')
365
  {
366
+
367
  $group = $this->getGroup($group_id);
368
  if (is_object($group)) {
369
  $id = wp_update_term($group->term_id, $this->taxonomy_name, $args);
2.8/class/avh-ec.core.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  class AVH_EC_Core
3
  {
4
  var $version;
@@ -9,7 +10,7 @@ class AVH_EC_Core
9
  var $default_options_general;
10
  var $default_options_category_group;
11
  var $default_options_sp_category_group;
12
-
13
  var $options;
14
 
15
  /**
@@ -22,13 +23,13 @@ class AVH_EC_Core
22
  *
23
  * @var AVH_EC_Category_Group
24
  */
25
- $catgrp = & AVH_EC_Singleton::getInstance( 'AVH_EC_Category_Group' );
26
-
27
- $this->version = '3.3.2';
28
  $this->comment = '<!-- AVH Extended Categories version ' . $this->version . ' | http://blog.avirtualhome.com/wordpress-plugins/ -->';
29
  $this->db_options_core = 'avhec';
30
-
31
- add_action('init', array(&$this,'handleInitializePlugin'),10);
32
  }
33
 
34
  /**
@@ -41,45 +42,47 @@ class AVH_EC_Core
41
  $this->__construct();
42
  }
43
 
44
- function handleInitializePlugin() {
45
- $catgrp = & AVH_EC_Singleton::getInstance( 'AVH_EC_Category_Group' );
 
46
  $db_version = 4;
47
-
48
- $info['siteurl'] = get_option( 'siteurl' );
49
  $info['plugin_dir'] = AVHEC_PLUGIN_DIR;
50
  $info['lang_dir'] = AVHEC_RELATIVE_WORKING_DIR . '/lang';
51
  $info['graphics_url'] = AVHEC_PLUGIN_URL . '/images';
52
-
53
  // Set class property for info
54
- $this->info = array ('home' => get_option( 'home' ), 'siteurl' => $info['siteurl'], 'plugin_dir' => $info['plugin_dir'], 'lang_dir' => $info['lang_dir'], 'graphics_url' => $info['graphics_url'] );
55
-
56
  // Set the default options
57
- $this->default_options_general = array ('version' => $this->version, 'dbversion' => $db_version, 'alternative_name_select_category' => '' );
58
-
59
  // Set the default category group options
60
- $no_group_id = $catgrp->getTermIDBy( 'slug', 'all' );
61
- $home_group_id = $catgrp->getTermIDBy( 'slug', 'home' );
62
- $default_group_id = $catgrp->getTermIDBy( 'slug', 'all' );
63
- $this->default_options_category_group = array ('no_group' => $no_group_id, 'home_group' => $home_group_id, 'default_group' => $default_group_id );
64
-
65
- $this->default_options_sp_category_group = array('home_group' => $home_group_id,'category_group' => $default_group_id,'day_group'=>$default_group_id,'month_group'=>$default_group_id,'year_group'=>$default_group_id,'author_group'=>$default_group_id,'search_group'=>$default_group_id);
66
-
67
- $this->default_options = array ('general' => $this->default_options_general, 'cat_group' => $this->default_options_category_group, 'widget_titles'=>array(),'sp_cat_group'=>$this->default_options_sp_category_group );
68
-
69
  /**
70
  * Set the options for the program
71
  *
72
  */
73
  $this->loadOptions();
74
-
75
  // Check if we have to do updates
76
- if ( (! isset( $this->options['general']['dbversion'] )) || $this->options['general']['dbversion'] < $db_version ) {
77
- $this->doUpdateOptions( $db_version );
78
  }
79
-
80
  $this->handleTextdomain();
81
-
82
  }
 
83
  /**
84
  * Loads the i18n
85
  *
@@ -87,9 +90,9 @@ class AVH_EC_Core
87
  */
88
  function handleTextdomain ()
89
  {
90
-
91
- load_plugin_textdomain( 'avh-ec', false, $this->info['lang_dir'] );
92
-
93
  }
94
 
95
  /**
@@ -98,29 +101,29 @@ class AVH_EC_Core
98
  * @since 1.2.3
99
  *
100
  */
101
- function doUpdateOptions ( $db_version )
102
  {
103
  $options = $this->getOptions();
104
-
105
  // Add none existing sections and/or elements to the options
106
- foreach ( $this->default_options as $section => $default_data ) {
107
- if ( ! array_key_exists( $section, $options ) ) {
108
  $options[$section] = $default_data;
109
  continue;
110
  }
111
- foreach ( $default_data as $element => $default_value ) {
112
- if ( ! array_key_exists( $element, $options[$section] ) ) {
113
  $options[$section][$element] = $default_value;
114
  }
115
  }
116
  }
117
-
118
  /**
119
  * Update the options to the latests versions
120
  */
121
  $options['general']['version'] = $this->version;
122
  $options['general']['dbversion'] = $db_version;
123
- $this->saveOptions( $options );
124
  }
125
 
126
  /**
@@ -132,9 +135,9 @@ class AVH_EC_Core
132
  *
133
  * @since 2.0
134
  */
135
- function isChecked ( $checked, $current )
136
  {
137
- if ( $checked == $current ) {
138
  return (' checked="checked"');
139
  }
140
  return ('');
@@ -147,12 +150,14 @@ class AVH_EC_Core
147
  * @param string $field
148
  * @return string
149
  */
150
- function isSelected($current, $field) {
 
151
  if ($current == $field) {
152
  return (' SELECTED');
153
  }
154
  return ('');
155
  }
 
156
  /**
157
  * Get the base directory of a directory structure
158
  *
@@ -160,11 +165,11 @@ class AVH_EC_Core
160
  * @return string
161
  *
162
  */
163
- function getBaseDirectory ( $directory )
164
  {
165
  //place each directory into array and get the last element
166
- $return = end( explode( '/', $directory ) );
167
-
168
  return $return;
169
  }
170
 
@@ -173,11 +178,11 @@ class AVH_EC_Core
173
  * Methods for variable: options *
174
  * *
175
  ********************************/
176
-
177
  /**
178
  * @param array $data
179
  */
180
- function setOptions ( $options )
181
  {
182
  $this->options = $options;
183
  }
@@ -194,11 +199,11 @@ class AVH_EC_Core
194
  * Save all current options and set the options
195
  *
196
  */
197
- function saveOptions ( $options )
198
  {
199
- update_option( $this->db_options_core, $options );
200
  wp_cache_flush(); // Delete cache
201
- $this->setOptions( $options );
202
  }
203
 
204
  /**
@@ -209,11 +214,11 @@ class AVH_EC_Core
209
  */
210
  function loadOptions ()
211
  {
212
- $options = get_option( $this->db_options_core );
213
- if ( false === $options ) { // New installation
214
  $this->resetToDefaultOptions();
215
  } else {
216
- $this->setOptions( $options );
217
  }
218
  }
219
 
@@ -224,9 +229,9 @@ class AVH_EC_Core
224
  * @param string $option
225
  * @return mixed
226
  */
227
- function getOptionElement ( $option, $key )
228
  {
229
- if ( $this->options[$option][$key] ) {
230
  $return = $this->options[$option][$key]; // From Admin Page
231
  } else {
232
  $return = $this->default_options[$option][$key]; // Default
@@ -241,7 +246,7 @@ class AVH_EC_Core
241
  function resetToDefaultOptions ()
242
  {
243
  $this->options = $this->default_options;
244
- $this->saveOptions( $this->default_options );
245
  }
246
 
247
  /**
@@ -277,61 +282,61 @@ class AVH_EC_Core
277
  * @param string|array $args Optional. Override default arguments.
278
  * @return string HTML content only if 'echo' argument is 0.
279
  */
280
- function avh_wp_dropdown_categories ( $args = '', $selectedonly )
281
  {
282
  $mywalker = new AVH_Walker_CategoryDropdown();
283
-
284
- $defaults = array ('show_option_all' => '', 'show_option_none' => '', 'orderby' => 'id', 'order' => 'ASC', 'show_last_update' => 0, 'show_count' => 0, 'hide_empty' => 1, 'child_of' => 0, 'exclude' => '', 'echo' => 1, 'selected' => 0, 'hierarchical' => 0, 'name' => 'cat', 'class' => 'postform', 'depth' => 0, 'tab_index' => 0, 'walker' => $mywalker );
285
-
286
- $defaults['selected'] = (is_category()) ? get_query_var( 'cat' ) : 0;
287
-
288
- $r = wp_parse_args( $args, $defaults );
289
-
290
- if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
291
  $r['pad_counts'] = true;
292
  }
293
-
294
  $r['include_last_update_time'] = $r['show_last_update'];
295
- extract( $r );
296
-
297
  $tab_index_attribute = '';
298
- if ( ( int ) $tab_index > 0 )
299
  $tab_index_attribute = ' tabindex="' . $tab_index . '"';
300
-
301
- $categories = get_categories( $r );
302
- $name = esc_attr( $name );
303
- $class = esc_attr( $class );
304
-
305
  $output = '';
306
- if ( ! empty( $categories ) ) {
307
  $output = '<select name="' . $name . '" id="' . $name . '" class="' . $class . '" ' . $tab_index_attribute . '>' . "\n";
308
-
309
- if ( $show_option_all ) {
310
- $show_option_all = apply_filters( 'list_cats', $show_option_all );
311
- $selected = ('0' === strval( $r['selected'] )) ? " selected='selected'" : '';
312
  $output .= "\t" . '<option value="0"' . $selected . '>' . $show_option_all . '</option>' . "\n";
313
  }
314
-
315
- if ( $show_option_none ) {
316
- $show_option_none = apply_filters( 'list_cats', $show_option_none );
317
- $selected = ('-1' === strval( $r['selected'] )) ? " selected='selected'" : '';
318
  $output .= "\t" . '<option value="-1"' . $selected . '>' . $show_option_none . '</option>' . "\n";
319
  }
320
-
321
- if ( $hierarchical ) {
322
  $depth = $r['depth']; // Walk the full depth.
323
  } else {
324
  $depth = - 1; // Flat
325
  }
326
- $output .= walk_category_dropdown_tree( $categories, $depth, $r );
327
  $output .= "</select>\n";
328
  }
329
-
330
- $output = apply_filters( 'wp_dropdown_cats', $output );
331
-
332
- if ( $echo )
333
  echo $output;
334
-
335
  return $output;
336
  }
337
 
@@ -368,89 +373,89 @@ class AVH_EC_Core
368
  * @param string|array $args Optional. Override default arguments.
369
  * @return string HTML content only if 'echo' argument is 0.
370
  */
371
- function avh_wp_list_categories ( $args = '', $selectedonly )
372
  {
373
  $mywalker = new AVHEC_Walker_Category();
374
- $defaults = array ('show_option_all' => '', 'orderby' => 'name', 'order' => 'ASC', 'show_last_update' => 0, 'style' => 'list', 'show_count' => 0, 'hide_empty' => 1, 'use_desc_for_title' => 1, 'child_of' => 0, 'feed' => '', 'feed_type' => '', 'feed_image' => '', 'exclude' => '', 'exclude_tree' => '', 'current_category' => 0, 'hierarchical' => true, 'title_li' => __( 'Categories' ), 'echo' => 1, 'depth' => 0, 'walker' => $mywalker );
375
-
376
- $r = wp_parse_args( $args, $defaults );
377
-
378
- if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
379
  $r['pad_counts'] = true;
380
  }
381
-
382
- if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
383
  $r['pad_counts'] = true;
384
  }
385
-
386
- if ( isset( $r['show_date'] ) ) {
387
  $r['include_last_update_time'] = $r['show_date'];
388
  }
389
-
390
- if ( true == $r['hierarchical'] ) {
391
  $r['exclude_tree'] = $r['exclude'];
392
  $r['exclude'] = '';
393
  }
394
-
395
- extract( $r );
396
-
397
- $categories = get_categories( $r );
398
-
399
  $output = '';
400
- if ( $title_li && 'list' == $style )
401
  $output = '<li class="categories">' . $r['title_li'] . '<ul>';
402
-
403
- if ( empty( $categories ) ) {
404
- if ( 'list' == $style )
405
- $output .= '<li>' . __( "No categories" ) . '</li>';
406
  else
407
- $output .= __( "No categories" );
408
  } else {
409
  global $wp_query;
410
-
411
- if ( ! empty( $show_option_all ) )
412
- if ( 'list' == $style )
413
- $output .= '<li><a href="' . get_bloginfo( 'url' ) . '">' . $show_option_all . '</a></li>';
414
  else
415
- $output .= '<a href="' . get_bloginfo( 'url' ) . '">' . $show_option_all . '</a>';
416
-
417
- if ( empty( $r['current_category'] ) && is_category() )
418
  $r['current_category'] = $wp_query->get_queried_object_id();
419
-
420
- if ( $hierarchical ) {
421
  $depth = $r['depth'];
422
  } else {
423
  $depth = - 1; // Flat.
424
  }
425
-
426
- $output .= walk_category_tree( $categories, $depth, $r );
427
  }
428
-
429
- if ( $title_li && 'list' == $style )
430
  $output .= '</ul></li>';
431
-
432
- $output = apply_filters( 'wp_list_categories', $output );
433
-
434
- if ( $echo )
435
  echo $output;
436
  else
437
  return $output;
438
  }
439
 
440
- function getCategories ( )
441
  {
442
  static $_categories = NULL;
443
- if ( NULL === $_categories ) {
444
- $_categories = get_categories( 'get=all' );
445
  }
446
  return $_categories;
447
  }
448
 
449
- function getCategoriesId ( $categories )
450
  {
451
  static $_categories_id = NULL;
452
- if ( NULL == $_categories_id ) {
453
- foreach ( $categories as $key => $category ) {
454
  $_categories_id[$category->term_id] = $key;
455
  }
456
  }
@@ -466,80 +471,81 @@ class AVH_EC_Core
466
  class AVH_Walker_CategoryDropdown extends Walker_CategoryDropdown
467
  {
468
 
469
- function walk ( $elements, $max_depth )
470
  {
471
-
472
- $args = array_slice( func_get_args(), 2 );
473
  $output = '';
474
-
475
- if ( $max_depth < - 1 ) //invalid parameter
476
  return $output;
477
-
478
- if ( empty( $elements ) ) //nothing to walk
479
  return $output;
480
-
481
  $id_field = $this->db_fields['id'];
482
  $parent_field = $this->db_fields['parent'];
483
-
484
  // flat display
485
- if ( - 1 == $max_depth ) {
486
- $empty_array = array ();
487
- foreach ( $elements as $e )
488
- $this->display_element( $e, $empty_array, 1, 0, $args, $output );
489
  return $output;
490
  }
491
-
492
  /*
493
  * need to display in hierarchical order
494
  * seperate elements into two buckets: top level and children elements
495
  * children_elements is two dimensional array, eg.
496
  * children_elements[10][] contains all sub-elements whose parent is 10.
497
  */
498
- $top_level_elements = array ();
499
- $children_elements = array ();
500
- foreach ( $elements as $e ) {
501
- if ( 0 == $e->$parent_field )
502
  $top_level_elements[] = $e;
503
  else
504
  $children_elements[$e->$parent_field][] = $e;
505
  }
506
-
507
  /*
508
  * when none of the elements is top level
509
  * assume the first one must be root of the sub elements
510
  */
511
- if ( empty( $top_level_elements ) ) {
512
-
513
- $first = array_slice( $elements, 0, 1 );
514
  $root = $first[0];
515
-
516
- $top_level_elements = array ();
517
- $children_elements = array ();
518
- foreach ( $elements as $e ) {
519
- if ( $root->$parent_field == $e->$parent_field )
520
  $top_level_elements[] = $e;
521
  else
522
  $children_elements[$e->$parent_field][] = $e;
523
  }
524
  }
525
-
526
- foreach ( $top_level_elements as $e )
527
- $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output );
528
-
529
  /*
530
  * if we are displaying all levels, and remaining children_elements is not empty,
531
  * then we got orphans, which should be displayed regardless
532
  */
533
- if ( (0 == $max_depth) && count( $children_elements ) > 0 ) {
534
- $empty_array = array ();
535
- foreach ( $children_elements as $orphans )
536
- foreach ( $orphans as $op )
537
- $this->display_element( $op, $empty_array, 1, 0, $args, $output );
538
  }
539
-
540
  return $output;
541
  }
542
  }
 
543
  /**
544
  * Create HTML list of categories.
545
  *
@@ -553,14 +559,14 @@ class AVHEC_Walker_Category extends Walker
553
  * @var string
554
  */
555
  var $tree_type = 'category';
556
-
557
  /**
558
  * @see Walker::$db_fields
559
  * @since 2.1.0
560
  * @todo Decouple this
561
  * @var array
562
  */
563
- var $db_fields = array ('parent' => 'parent', 'id' => 'term_id' );
564
 
565
  /**
566
  * @see Walker::start_lvl()
@@ -570,12 +576,12 @@ class AVHEC_Walker_Category extends Walker
570
  * @param int $depth Depth of category. Used for tab indentation.
571
  * @param array $args Will only append content if style argument value is 'list'.
572
  */
573
- function start_lvl ( &$output, $depth, $args )
574
  {
575
- if ( 'list' != $args['style'] )
576
  return;
577
-
578
- $indent = str_repeat( "\t", $depth );
579
  $output .= $indent . '<ul class="children">' . "\n";
580
  }
581
 
@@ -587,12 +593,12 @@ class AVHEC_Walker_Category extends Walker
587
  * @param int $depth Depth of category. Used for tab indentation.
588
  * @param array $args Will only append content if style argument value is 'list'.
589
  */
590
- function end_lvl ( &$output, $depth, $args )
591
  {
592
- if ( 'list' != $args['style'] )
593
  return;
594
-
595
- $indent = str_repeat( "\t", $depth );
596
  $output .= $indent . '</ul>' . "\n";
597
  }
598
 
@@ -605,65 +611,65 @@ class AVHEC_Walker_Category extends Walker
605
  * @param int $depth Depth of category in reference to parents.
606
  * @param array $args
607
  */
608
- function start_el ( &$output, $category, $depth, $args )
609
  {
610
- extract( $args );
611
-
612
- $cat_name = esc_attr( $category->name );
613
- $cat_name = apply_filters( 'list_cats', $cat_name, $category );
614
- $link = '<div class="avhec-widget-line"><a href="' . get_category_link( $category->term_id ) . '" ';
615
- if ( $use_desc_for_title == 0 || empty( $category->description ) )
616
- $link .= 'title="' . sprintf( __( 'View all posts filed under %s' ), $cat_name ) . '"';
617
  else
618
- $link .= 'title="' . esc_attr( strip_tags( apply_filters( 'category_description', $category->description, $category ) ) ) . '"';
619
  $link .= '>';
620
  $link .= $cat_name . '</a>';
621
-
622
- if ( (! empty( $feed_image )) || (! empty( $feed )) ) {
623
  $link .= '<div class="avhec-widget-rss"> ';
624
-
625
- if ( empty( $feed_image ) )
626
  $link .= '(';
627
-
628
- $link .= '<a href="' . get_category_feed_link( $category->term_id, $feed_type ) . '"';
629
-
630
- if ( empty( $feed ) )
631
- $alt = ' alt="' . sprintf( __( 'Feed for all posts filed under %s' ), $cat_name ) . '"';
632
  else {
633
  $title = ' title="' . $feed . '"';
634
  $alt = ' alt="' . $feed . '"';
635
  $name = $feed;
636
  $link .= $title;
637
  }
638
-
639
  $link .= '>';
640
-
641
- if ( empty( $feed_image ) )
642
  $link .= $name;
643
  else
644
  $link .= '<img src="' . $feed_image . '"' . $alt . $title . ' />';
645
  $link .= '</a>';
646
- if ( empty( $feed_image ) )
647
  $link .= ')';
648
  $link .= '</div>';
649
  }
650
-
651
- if ( isset( $show_count ) && $show_count )
652
- $link .= '<div class="avhec-widget-count"> (' . intval( $category->count ) . ')</div>';
653
-
654
- if ( isset( $show_date ) && $show_date ) {
655
- $link .= ' ' . gmdate( 'Y-m-d', $category->last_update_timestamp );
656
  }
657
-
658
- if ( isset( $current_category ) && $current_category )
659
- $_current_category = get_category( $current_category );
660
-
661
- if ( 'list' == $args['style'] ) {
662
  $output .= "\t" . '<li';
663
  $class = 'cat-item cat-item-' . $category->term_id;
664
- if ( isset( $current_category ) && $current_category && ($category->term_id == $current_category) )
665
  $class .= ' current-cat';
666
- elseif ( isset( $_current_category ) && $_current_category && ($category->term_id == $_current_category->parent) )
667
  $class .= ' current-cat-parent';
668
  $output .= ' class="' . $class . '"';
669
  $output .= '>' . $link . '</div>' . "\n";
@@ -681,11 +687,11 @@ class AVHEC_Walker_Category extends Walker
681
  * @param int $depth Depth of category. Not used.
682
  * @param array $args Only uses 'list' for whether should append to output.
683
  */
684
- function end_el ( &$output, $page, $depth, $args )
685
  {
686
- if ( 'list' != $args['style'] )
687
  return;
688
-
689
  $output .= '</li>' . "\n";
690
  }
691
  }
1
  <?php
2
+
3
  class AVH_EC_Core
4
  {
5
  var $version;
10
  var $default_options_general;
11
  var $default_options_category_group;
12
  var $default_options_sp_category_group;
13
+
14
  var $options;
15
 
16
  /**
23
  *
24
  * @var AVH_EC_Category_Group
25
  */
26
+ $catgrp = & AVH_EC_Singleton::getInstance('AVH_EC_Category_Group');
27
+
28
+ $this->version = '3.3.3';
29
  $this->comment = '<!-- AVH Extended Categories version ' . $this->version . ' | http://blog.avirtualhome.com/wordpress-plugins/ -->';
30
  $this->db_options_core = 'avhec';
31
+
32
+ add_action('init', array(&$this, 'handleInitializePlugin'), 10);
33
  }
34
 
35
  /**
42
  $this->__construct();
43
  }
44
 
45
+ function handleInitializePlugin ()
46
+ {
47
+ $catgrp = & AVH_EC_Singleton::getInstance('AVH_EC_Category_Group');
48
  $db_version = 4;
49
+
50
+ $info['siteurl'] = get_option('siteurl');
51
  $info['plugin_dir'] = AVHEC_PLUGIN_DIR;
52
  $info['lang_dir'] = AVHEC_RELATIVE_WORKING_DIR . '/lang';
53
  $info['graphics_url'] = AVHEC_PLUGIN_URL . '/images';
54
+
55
  // Set class property for info
56
+ $this->info = array('home'=>get_option('home'), 'siteurl'=>$info['siteurl'], 'plugin_dir'=>$info['plugin_dir'], 'lang_dir'=>$info['lang_dir'], 'graphics_url'=>$info['graphics_url']);
57
+
58
  // Set the default options
59
+ $this->default_options_general = array('version'=>$this->version, 'dbversion'=>$db_version, 'alternative_name_select_category'=>'');
60
+
61
  // Set the default category group options
62
+ $no_group_id = $catgrp->getTermIDBy('slug', 'all');
63
+ $home_group_id = $catgrp->getTermIDBy('slug', 'home');
64
+ $default_group_id = $catgrp->getTermIDBy('slug', 'all');
65
+ $this->default_options_category_group = array('no_group'=>$no_group_id, 'home_group'=>$home_group_id, 'default_group'=>$default_group_id);
66
+
67
+ $this->default_options_sp_category_group = array('home_group'=>$home_group_id, 'category_group'=>$default_group_id, 'day_group'=>$default_group_id, 'month_group'=>$default_group_id, 'year_group'=>$default_group_id, 'author_group'=>$default_group_id, 'search_group'=>$default_group_id);
68
+
69
+ $this->default_options = array('general'=>$this->default_options_general, 'cat_group'=>$this->default_options_category_group, 'widget_titles'=>array(), 'sp_cat_group'=>$this->default_options_sp_category_group);
70
+
71
  /**
72
  * Set the options for the program
73
  *
74
  */
75
  $this->loadOptions();
76
+
77
  // Check if we have to do updates
78
+ if ((! isset($this->options['general']['dbversion'])) || $this->options['general']['dbversion'] < $db_version) {
79
+ $this->doUpdateOptions($db_version);
80
  }
81
+
82
  $this->handleTextdomain();
83
+
84
  }
85
+
86
  /**
87
  * Loads the i18n
88
  *
90
  */
91
  function handleTextdomain ()
92
  {
93
+
94
+ load_plugin_textdomain('avh-ec', false, $this->info['lang_dir']);
95
+
96
  }
97
 
98
  /**
101
  * @since 1.2.3
102
  *
103
  */
104
+ function doUpdateOptions ($db_version)
105
  {
106
  $options = $this->getOptions();
107
+
108
  // Add none existing sections and/or elements to the options
109
+ foreach ($this->default_options as $section => $default_data) {
110
+ if (! array_key_exists($section, $options)) {
111
  $options[$section] = $default_data;
112
  continue;
113
  }
114
+ foreach ($default_data as $element => $default_value) {
115
+ if (! array_key_exists($element, $options[$section])) {
116
  $options[$section][$element] = $default_value;
117
  }
118
  }
119
  }
120
+
121
  /**
122
  * Update the options to the latests versions
123
  */
124
  $options['general']['version'] = $this->version;
125
  $options['general']['dbversion'] = $db_version;
126
+ $this->saveOptions($options);
127
  }
128
 
129
  /**
135
  *
136
  * @since 2.0
137
  */
138
+ function isChecked ($checked, $current)
139
  {
140
+ if ($checked == $current) {
141
  return (' checked="checked"');
142
  }
143
  return ('');
150
  * @param string $field
151
  * @return string
152
  */
153
+ function isSelected ($current, $field)
154
+ {
155
  if ($current == $field) {
156
  return (' SELECTED');
157
  }
158
  return ('');
159
  }
160
+
161
  /**
162
  * Get the base directory of a directory structure
163
  *
165
  * @return string
166
  *
167
  */
168
+ function getBaseDirectory ($directory)
169
  {
170
  //place each directory into array and get the last element
171
+ $return = end(explode('/', $directory));
172
+
173
  return $return;
174
  }
175
 
178
  * Methods for variable: options *
179
  * *
180
  ********************************/
181
+
182
  /**
183
  * @param array $data
184
  */
185
+ function setOptions ($options)
186
  {
187
  $this->options = $options;
188
  }
199
  * Save all current options and set the options
200
  *
201
  */
202
+ function saveOptions ($options)
203
  {
204
+ update_option($this->db_options_core, $options);
205
  wp_cache_flush(); // Delete cache
206
+ $this->setOptions($options);
207
  }
208
 
209
  /**
214
  */
215
  function loadOptions ()
216
  {
217
+ $options = get_option($this->db_options_core);
218
+ if (false === $options) { // New installation
219
  $this->resetToDefaultOptions();
220
  } else {
221
+ $this->setOptions($options);
222
  }
223
  }
224
 
229
  * @param string $option
230
  * @return mixed
231
  */
232
+ function getOptionElement ($option, $key)
233
  {
234
+ if ($this->options[$option][$key]) {
235
  $return = $this->options[$option][$key]; // From Admin Page
236
  } else {
237
  $return = $this->default_options[$option][$key]; // Default
246
  function resetToDefaultOptions ()
247
  {
248
  $this->options = $this->default_options;
249
+ $this->saveOptions($this->default_options);
250
  }
251
 
252
  /**
282
  * @param string|array $args Optional. Override default arguments.
283
  * @return string HTML content only if 'echo' argument is 0.
284
  */
285
+ function avh_wp_dropdown_categories ($args = '', $selectedonly)
286
  {
287
  $mywalker = new AVH_Walker_CategoryDropdown();
288
+
289
+ $defaults = array('show_option_all'=>'', 'show_option_none'=>'', 'orderby'=>'id', 'order'=>'ASC', 'show_last_update'=>0, 'show_count'=>0, 'hide_empty'=>1, 'child_of'=>0, 'exclude'=>'', 'echo'=>1, 'selected'=>0, 'hierarchical'=>0, 'name'=>'cat', 'class'=>'postform', 'depth'=>0, 'tab_index'=>0, 'walker'=>$mywalker);
290
+
291
+ $defaults['selected'] = (is_category()) ? get_query_var('cat') : 0;
292
+
293
+ $r = wp_parse_args($args, $defaults);
294
+
295
+ if (! isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical']) {
296
  $r['pad_counts'] = true;
297
  }
298
+
299
  $r['include_last_update_time'] = $r['show_last_update'];
300
+ extract($r);
301
+
302
  $tab_index_attribute = '';
303
+ if ((int) $tab_index > 0)
304
  $tab_index_attribute = ' tabindex="' . $tab_index . '"';
305
+
306
+ $categories = get_categories($r);
307
+ $name = esc_attr($name);
308
+ $class = esc_attr($class);
309
+
310
  $output = '';
311
+ if (! empty($categories)) {
312
  $output = '<select name="' . $name . '" id="' . $name . '" class="' . $class . '" ' . $tab_index_attribute . '>' . "\n";
313
+
314
+ if ($show_option_all) {
315
+ $show_option_all = apply_filters('list_cats', $show_option_all);
316
+ $selected = ('0' === strval($r['selected'])) ? " selected='selected'" : '';
317
  $output .= "\t" . '<option value="0"' . $selected . '>' . $show_option_all . '</option>' . "\n";
318
  }
319
+
320
+ if ($show_option_none) {
321
+ $show_option_none = apply_filters('list_cats', $show_option_none);
322
+ $selected = ('-1' === strval($r['selected'])) ? " selected='selected'" : '';
323
  $output .= "\t" . '<option value="-1"' . $selected . '>' . $show_option_none . '</option>' . "\n";
324
  }
325
+
326
+ if ($hierarchical) {
327
  $depth = $r['depth']; // Walk the full depth.
328
  } else {
329
  $depth = - 1; // Flat
330
  }
331
+ $output .= walk_category_dropdown_tree($categories, $depth, $r);
332
  $output .= "</select>\n";
333
  }
334
+
335
+ $output = apply_filters('wp_dropdown_cats', $output);
336
+
337
+ if ($echo)
338
  echo $output;
339
+
340
  return $output;
341
  }
342
 
373
  * @param string|array $args Optional. Override default arguments.
374
  * @return string HTML content only if 'echo' argument is 0.
375
  */
376
+ function avh_wp_list_categories ($args = '', $selectedonly)
377
  {
378
  $mywalker = new AVHEC_Walker_Category();
379
+ $defaults = array('show_option_all'=>'', 'orderby'=>'name', 'order'=>'ASC', 'show_last_update'=>0, 'style'=>'list', 'show_count'=>0, 'hide_empty'=>1, 'use_desc_for_title'=>1, 'child_of'=>0, 'feed'=>'', 'feed_type'=>'', 'feed_image'=>'', 'exclude'=>'', 'exclude_tree'=>'', 'current_category'=>0, 'hierarchical'=>true, 'title_li'=>__('Categories'), 'echo'=>1, 'depth'=>0, 'walker'=>$mywalker);
380
+
381
+ $r = wp_parse_args($args, $defaults);
382
+
383
+ if (! isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical']) {
384
  $r['pad_counts'] = true;
385
  }
386
+
387
+ if (! isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical']) {
388
  $r['pad_counts'] = true;
389
  }
390
+
391
+ if (isset($r['show_date'])) {
392
  $r['include_last_update_time'] = $r['show_date'];
393
  }
394
+
395
+ if (true == $r['hierarchical']) {
396
  $r['exclude_tree'] = $r['exclude'];
397
  $r['exclude'] = '';
398
  }
399
+
400
+ extract($r);
401
+
402
+ $categories = get_categories($r);
403
+
404
  $output = '';
405
+ if ($title_li && 'list' == $style)
406
  $output = '<li class="categories">' . $r['title_li'] . '<ul>';
407
+
408
+ if (empty($categories)) {
409
+ if ('list' == $style)
410
+ $output .= '<li>' . __("No categories") . '</li>';
411
  else
412
+ $output .= __("No categories");
413
  } else {
414
  global $wp_query;
415
+
416
+ if (! empty($show_option_all))
417
+ if ('list' == $style)
418
+ $output .= '<li><a href="' . get_bloginfo('url') . '">' . $show_option_all . '</a></li>';
419
  else
420
+ $output .= '<a href="' . get_bloginfo('url') . '">' . $show_option_all . '</a>';
421
+
422
+ if (empty($r['current_category']) && is_category())
423
  $r['current_category'] = $wp_query->get_queried_object_id();
424
+
425
+ if ($hierarchical) {
426
  $depth = $r['depth'];
427
  } else {
428
  $depth = - 1; // Flat.
429
  }
430
+
431
+ $output .= walk_category_tree($categories, $depth, $r);
432
  }
433
+
434
+ if ($title_li && 'list' == $style)
435
  $output .= '</ul></li>';
436
+
437
+ $output = apply_filters('wp_list_categories', $output);
438
+
439
+ if ($echo)
440
  echo $output;
441
  else
442
  return $output;
443
  }
444
 
445
+ function getCategories ()
446
  {
447
  static $_categories = NULL;
448
+ if (NULL === $_categories) {
449
+ $_categories = get_categories('get=all');
450
  }
451
  return $_categories;
452
  }
453
 
454
+ function getCategoriesId ($categories)
455
  {
456
  static $_categories_id = NULL;
457
+ if (NULL == $_categories_id) {
458
+ foreach ($categories as $key => $category) {
459
  $_categories_id[$category->term_id] = $key;
460
  }
461
  }
471
  class AVH_Walker_CategoryDropdown extends Walker_CategoryDropdown
472
  {
473
 
474
+ function walk ($elements, $max_depth)
475
  {
476
+
477
+ $args = array_slice(func_get_args(), 2);
478
  $output = '';
479
+
480
+ if ($max_depth < - 1) //invalid parameter
481
  return $output;
482
+
483
+ if (empty($elements)) //nothing to walk
484
  return $output;
485
+
486
  $id_field = $this->db_fields['id'];
487
  $parent_field = $this->db_fields['parent'];
488
+
489
  // flat display
490
+ if (- 1 == $max_depth) {
491
+ $empty_array = array();
492
+ foreach ($elements as $e)
493
+ $this->display_element($e, $empty_array, 1, 0, $args, $output);
494
  return $output;
495
  }
496
+
497
  /*
498
  * need to display in hierarchical order
499
  * seperate elements into two buckets: top level and children elements
500
  * children_elements is two dimensional array, eg.
501
  * children_elements[10][] contains all sub-elements whose parent is 10.
502
  */
503
+ $top_level_elements = array();
504
+ $children_elements = array();
505
+ foreach ($elements as $e) {
506
+ if (0 == $e->$parent_field)
507
  $top_level_elements[] = $e;
508
  else
509
  $children_elements[$e->$parent_field][] = $e;
510
  }
511
+
512
  /*
513
  * when none of the elements is top level
514
  * assume the first one must be root of the sub elements
515
  */
516
+ if (empty($top_level_elements)) {
517
+
518
+ $first = array_slice($elements, 0, 1);
519
  $root = $first[0];
520
+
521
+ $top_level_elements = array();
522
+ $children_elements = array();
523
+ foreach ($elements as $e) {
524
+ if ($root->$parent_field == $e->$parent_field)
525
  $top_level_elements[] = $e;
526
  else
527
  $children_elements[$e->$parent_field][] = $e;
528
  }
529
  }
530
+
531
+ foreach ($top_level_elements as $e)
532
+ $this->display_element($e, $children_elements, $max_depth, 0, $args, $output);
533
+
534
  /*
535
  * if we are displaying all levels, and remaining children_elements is not empty,
536
  * then we got orphans, which should be displayed regardless
537
  */
538
+ if ((0 == $max_depth) && count($children_elements) > 0) {
539
+ $empty_array = array();
540
+ foreach ($children_elements as $orphans)
541
+ foreach ($orphans as $op)
542
+ $this->display_element($op, $empty_array, 1, 0, $args, $output);
543
  }
544
+
545
  return $output;
546
  }
547
  }
548
+
549
  /**
550
  * Create HTML list of categories.
551
  *
559
  * @var string
560
  */
561
  var $tree_type = 'category';
562
+
563
  /**
564
  * @see Walker::$db_fields
565
  * @since 2.1.0
566
  * @todo Decouple this
567
  * @var array
568
  */
569
+ var $db_fields = array('parent'=>'parent', 'id'=>'term_id');
570
 
571
  /**
572
  * @see Walker::start_lvl()
576
  * @param int $depth Depth of category. Used for tab indentation.
577
  * @param array $args Will only append content if style argument value is 'list'.
578
  */
579
+ function start_lvl (&$output, $depth, $args)
580
  {
581
+ if ('list' != $args['style'])
582
  return;
583
+
584
+ $indent = str_repeat("\t", $depth);
585
  $output .= $indent . '<ul class="children">' . "\n";
586
  }
587
 
593
  * @param int $depth Depth of category. Used for tab indentation.
594
  * @param array $args Will only append content if style argument value is 'list'.
595
  */
596
+ function end_lvl (&$output, $depth, $args)
597
  {
598
+ if ('list' != $args['style'])
599
  return;
600
+
601
+ $indent = str_repeat("\t", $depth);
602
  $output .= $indent . '</ul>' . "\n";
603
  }
604
 
611
  * @param int $depth Depth of category in reference to parents.
612
  * @param array $args
613
  */
614
+ function start_el (&$output, $category, $depth, $args)
615
  {
616
+ extract($args);
617
+
618
+ $cat_name = esc_attr($category->name);
619
+ $cat_name = apply_filters('list_cats', $cat_name, $category);
620
+ $link = '<div class="avhec-widget-line"><a href="' . get_category_link($category->term_id) . '" ';
621
+ if ($use_desc_for_title == 0 || empty($category->description))
622
+ $link .= 'title="' . sprintf(__('View all posts filed under %s'), $cat_name) . '"';
623
  else
624
+ $link .= 'title="' . esc_attr(strip_tags(apply_filters('category_description', $category->description, $category))) . '"';
625
  $link .= '>';
626
  $link .= $cat_name . '</a>';
627
+
628
+ if ((! empty($feed_image)) || (! empty($feed))) {
629
  $link .= '<div class="avhec-widget-rss"> ';
630
+
631
+ if (empty($feed_image))
632
  $link .= '(';
633
+
634
+ $link .= '<a href="' . get_category_feed_link($category->term_id, $feed_type) . '"';
635
+
636
+ if (empty($feed))
637
+ $alt = ' alt="' . sprintf(__('Feed for all posts filed under %s'), $cat_name) . '"';
638
  else {
639
  $title = ' title="' . $feed . '"';
640
  $alt = ' alt="' . $feed . '"';
641
  $name = $feed;
642
  $link .= $title;
643
  }
644
+
645
  $link .= '>';
646
+
647
+ if (empty($feed_image))
648
  $link .= $name;
649
  else
650
  $link .= '<img src="' . $feed_image . '"' . $alt . $title . ' />';
651
  $link .= '</a>';
652
+ if (empty($feed_image))
653
  $link .= ')';
654
  $link .= '</div>';
655
  }
656
+
657
+ if (isset($show_count) && $show_count)
658
+ $link .= '<div class="avhec-widget-count"> (' . intval($category->count) . ')</div>';
659
+
660
+ if (isset($show_date) && $show_date) {
661
+ $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp);
662
  }
663
+
664
+ if (isset($current_category) && $current_category)
665
+ $_current_category = get_category($current_category);
666
+
667
+ if ('list' == $args['style']) {
668
  $output .= "\t" . '<li';
669
  $class = 'cat-item cat-item-' . $category->term_id;
670
+ if (isset($current_category) && $current_category && ($category->term_id == $current_category))
671
  $class .= ' current-cat';
672
+ elseif (isset($_current_category) && $_current_category && ($category->term_id == $_current_category->parent))
673
  $class .= ' current-cat-parent';
674
  $output .= ' class="' . $class . '"';
675
  $output .= '>' . $link . '</div>' . "\n";
687
  * @param int $depth Depth of category. Not used.
688
  * @param array $args Only uses 'list' for whether should append to output.
689
  */
690
+ function end_el (&$output, $page, $depth, $args)
691
  {
692
+ if ('list' != $args['style'])
693
  return;
694
+
695
  $output .= '</li>' . "\n";
696
  }
697
  }
2.8/class/avh-ec.widgets.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Widget Class for displaying categories. Extended version of the dfeault categories.
4
  *
@@ -17,19 +18,19 @@ class WP_Widget_AVH_ExtendedCategories_Normal extends WP_Widget
17
  */
18
  function __construct ()
19
  {
20
- $this->core = & AVH_EC_Singleton::getInstance( 'AVH_EC_Core' );
21
-
22
  //Convert the old option widget_extended_categories to widget_extended-categories
23
- $old = get_option( 'widget_extended_categories' );
24
- if ( ! (FALSE === $old) ) {
25
- update_option( 'widget_extended-categories', $old );
26
- delete_option( 'widget_extended_categories' );
27
- }
28
- $widget_ops = array ('description' => __( "An extended version of the default Categories widget.", 'avh-ec' ) );
29
- WP_Widget::__construct( 'extended-categories', __( 'AVH Extended Categories' ), $widget_ops );
30
-
31
- add_action( 'wp_print_styles', array (&$this, 'actionWpPrintStyles' ) );
32
-
33
  }
34
 
35
  function WP_Widget_AVH_ExtendedCategories_Normal ()
@@ -39,10 +40,10 @@ class WP_Widget_AVH_ExtendedCategories_Normal extends WP_Widget
39
 
40
  function actionWpPrintStyles ()
41
  {
42
-
43
- if ( ! (FALSE === is_active_widget( FALSE, FALSE, $this->id_base, TRUE )) ) {
44
- wp_register_style( 'avhec-widget', AVHEC_PLUGIN_URL . '/css/avh-ec.widget.css', array (), $this->core->version );
45
- wp_enqueue_style( 'avhec-widget' );
46
  }
47
  }
48
 
@@ -52,11 +53,11 @@ class WP_Widget_AVH_ExtendedCategories_Normal extends WP_Widget
52
  * @param unknown_type $args
53
  * @param unknown_type $instance
54
  */
55
- function widget ( $args, $instance )
56
  {
57
-
58
- extract( $args );
59
-
60
  $selectedonly = $instance['selectedonly'] ? TRUE : FALSE;
61
  $c = $instance['count'] ? TRUE : FALSE;
62
  $h = $instance['hierarchical'] ? TRUE : FALSE;
@@ -68,59 +69,59 @@ class WP_Widget_AVH_ExtendedCategories_Normal extends WP_Widget
68
  $r = $instance['rssfeed'] ? 'RSS' : '';
69
  $i = $instance['rssimage'] ? $instance['rssimage'] : '';
70
  $invert = $instance['invert_included'] ? TRUE : FALSE;
71
-
72
- if ( empty( $r ) ) {
73
  $i = '';
74
  }
75
-
76
- if ( empty( $d ) ) {
77
  $d = 0;
78
  }
79
-
80
- $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories', 'avh-ec' ) : $instance['title'] );
81
- $style = empty( $instance['style'] ) ? 'list' : $instance['style'];
82
-
83
  $included_cats = '';
84
- if ( $instance['post_category'] ) {
85
- $post_category = unserialize( $instance['post_category'] );
86
- $children = array ();
87
- if ( ! $instance['selectedonly'] ) {
88
- foreach ( $post_category as $cat_id ) {
89
- $children = array_merge( $children, get_term_children( $cat_id, 'category' ) );
90
  }
91
  }
92
- $included_cats = implode( ",", array_merge( $post_category, $children ) );
93
  }
94
-
95
- if ( $invert ) {
96
  $inc_exc = 'exclude';
97
  } else {
98
  $inc_exc = 'include';
99
  }
100
-
101
  $options = $this->core->getOptions();
102
- $show_option_none = __( 'Select Category', 'avh-ec' );
103
- if ( $options['general']['alternative_name_select_category'] ) {
104
  $show_option_none = $options['general']['alternative_name_select_category'];
105
  }
106
-
107
- $cat_args = array ($inc_exc => $included_cats, 'orderby' => $s, 'order' => $o, 'show_count' => $c, 'use_desc_for_title' => $use_desc_for_title, 'hide_empty' => $e, 'hierarchical' => $h, 'depth' => $d, 'title_li' => '', 'show_option_none' => $show_option_none, 'feed' => $r, 'feed_image' => $i, 'name' => 'extended-categories-select-' . $this->number );
108
  echo $before_widget;
109
  echo $this->core->comment;
110
  echo $before_title . $title . $after_title;
111
-
112
- if ( $style == 'list' ) {
113
  echo '<ul>';
114
- $this->core->avh_wp_list_categories( $cat_args, $selectedonly );
115
  echo '</ul>';
116
  } else {
117
- $this->core->avh_wp_dropdown_categories( $cat_args, $selectedonly );
118
  echo '<script type=\'text/javascript\'>' . "\n";
119
  echo '/* <![CDATA[ */' . "\n";
120
  echo ' var ec_dropdown_' . $this->number . ' = document.getElementById("extended-categories-select-' . $this->number . '");' . "\n";
121
  echo ' function ec_onCatChange_' . $this->number . '() {' . "\n";
122
  echo ' if ( ec_dropdown_' . $this->number . '.options[ec_dropdown_' . $this->number . '.selectedIndex].value > 0 ) {' . "\n";
123
- echo ' location.href = "' . get_option( 'home' ) . '/?cat="+ec_dropdown_' . $this->number . '.options[ec_dropdown_' . $this->number . '.selectedIndex].value;' . "\n";
124
  echo ' }' . "\n";
125
  echo ' }' . "\n";
126
  echo ' ec_dropdown_' . $this->number . '.onchange = ec_onCatChange_' . $this->number . ';' . "\n";
@@ -137,37 +138,37 @@ class WP_Widget_AVH_ExtendedCategories_Normal extends WP_Widget
137
  * @param unknown_type $old_instance
138
  * @return unknown
139
  */
140
- function update ( $new_instance, $old_instance )
141
  {
142
  // update the instance's settings
143
- if ( ! isset( $new_instance['submit'] ) ) {
144
  return FALSE;
145
  }
146
-
147
  $instance = $old_instance;
148
-
149
- $instance['title'] = strip_tags( stripslashes( $new_instance['title'] ) );
150
  $instance['selectedonly'] = $new_instance['selectedonly'] ? TRUE : FALSE;
151
  $instance['count'] = $new_instance['count'] ? TRUE : FALSE;
152
  $instance['hierarchical'] = $new_instance['hierarchical'] ? TRUE : FALSE;
153
  $instance['hide_empty'] = $new_instance['hide_empty'] ? TRUE : FALSE;
154
  $instance['use_desc_for_title'] = $new_instance['use_desc_for_title'] ? TRUE : FALSE;
155
- $instance['sort_column'] = strip_tags( stripslashes( $new_instance['sort_column'] ) );
156
- $instance['sort_order'] = strip_tags( stripslashes( $new_instance['sort_order'] ) );
157
- $instance['style'] = strip_tags( stripslashes( $new_instance['style'] ) );
158
  $instance['rssfeed'] = $new_instance['rssfeed'] ? TRUE : FALSE;
159
- $instance['rssimage'] = strip_tags( stripslashes( $new_instance['rssimage'] ) );
160
- if ( array_key_exists( 'all', $new_instance['post_category'] ) ) {
161
  $instance['post_category'] = FALSE;
162
  } else {
163
- $instance['post_category'] = serialize( $new_instance['post_category'] );
164
  }
165
- $instance['depth'] = ( int ) $new_instance['depth'];
166
- if ( $instance['depth'] < 0 || 11 < $instance['depth'] ) {
167
  $instance['depth'] = 0;
168
  }
169
  $instance['invert_included'] = $new_instance['invert_included'] ? TRUE : FALSE;
170
-
171
  return $instance;
172
  }
173
 
@@ -176,88 +177,88 @@ class WP_Widget_AVH_ExtendedCategories_Normal extends WP_Widget
176
  *
177
  * @param unknown_type $instance
178
  */
179
- function form ( $instance )
180
  {
181
  // displays the widget admin form
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>';
242
- echo '<b>' . __( 'Select categories', 'avh-ec' ) . '</b><hr />';
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>';
250
  ob_start();
251
- $this->avh_wp_category_checklist( $selected_cats, $this->number );
252
  ob_end_flush();
253
  echo '</ul>';
254
  echo '</p>';
255
-
256
  echo '<p>';
257
- avh_doWidgetFormCheckbox( $this->get_field_id( 'invert_included' ), $this->get_field_name( 'invert_included' ), __( 'Exclude the selected categories', 'avh-ec' ), ( bool ) $instance['invert_included'] );
258
  echo '</p>';
259
-
260
- echo '<input type="hidden" id="' . $this->get_field_id( 'submit' ) . '" name="' . $this->get_field_name( 'submit' ) . '" value="1" />';
261
  }
262
 
263
  /**
@@ -269,45 +270,39 @@ class WP_Widget_AVH_ExtendedCategories_Normal extends WP_Widget
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
 
@@ -329,12 +324,12 @@ class WP_Widget_AVH_ExtendedCategories_Top extends WP_Widget
329
  */
330
  function __construct ()
331
  {
332
- $this->core = & AVH_EC_Singleton::getInstance( 'AVH_EC_Core' );
333
-
334
- $widget_ops = array ('description' => __( "Shows the top categories.", 'avh-ec' ) );
335
- WP_Widget::__construct( FALSE, __( 'AVH Extended Categories: Top Categories' ), $widget_ops );
336
- add_action( 'wp_print_styles', array (&$this, 'actionWpPrintStyles' ) );
337
-
338
  }
339
 
340
  function WP_Widget_AVH_ExtendedCategories_Top ()
@@ -344,9 +339,9 @@ class WP_Widget_AVH_ExtendedCategories_Top extends WP_Widget
344
 
345
  function actionWpPrintStyles ()
346
  {
347
- if ( ! (FALSE === is_active_widget( FALSE, FALSE, $this->id_base, TRUE )) ) {
348
- wp_register_style( 'avhec-widget', AVHEC_PLUGIN_URL . '/css/avh-ec.widget.css', array (), $this->core->version );
349
- wp_enqueue_style( 'avhec-widget' );
350
  }
351
  }
352
 
@@ -357,15 +352,15 @@ class WP_Widget_AVH_ExtendedCategories_Top extends WP_Widget
357
  * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
358
  * @param array $instance The settings for the particular instance of the widget
359
  */
360
- function widget ( $args, $instance )
361
  {
362
- extract( $args );
363
-
364
- $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories', 'avh-ec' ) : $instance['title'] );
365
- $style = empty( $instance['style'] ) ? 'list' : $instance['style'];
366
- if ( ! $a = ( int ) $instance['amount'] ) {
367
  $a = 5;
368
- } elseif ( $a < 1 ) {
369
  $a = 1;
370
  }
371
  $c = $instance['count'] ? TRUE : FALSE;
@@ -374,40 +369,40 @@ class WP_Widget_AVH_ExtendedCategories_Top extends WP_Widget
374
  $o = $instance['sort_order'] ? $instance['sort_order'] : 'asc';
375
  $r = $instance['rssfeed'] ? 'RSS' : '';
376
  $i = $instance['rssimage'] ? $instance['rssimage'] : '';
377
- if ( empty( $r ) ) {
378
  $i = '';
379
  }
380
- if ( ! empty( $i ) ) {
381
- if ( ! file_exists( ABSPATH . '/' . $i ) ) {
382
  $i = '';
383
  }
384
  }
385
-
386
  $options = $this->core->getOptions();
387
- $show_option_none = __( 'Select Category', 'avh-ec' );
388
- if ( $options['general']['alternative_name_select_category'] ) {
389
  $show_option_none = $options['general']['alternative_name_select_category'];
390
  }
391
-
392
- $top_cats = get_terms( 'category', array ('fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => $a, 'hierarchical' => FALSE ) );
393
- $included_cats = implode( ",", $top_cats );
394
-
395
- $cat_args = array ('include' => $included_cats, 'orderby' => $s, 'order' => $o, 'show_count' => $c, 'use_desc_for_title' => $use_desc_for_title, 'hide_empty' => FALSE, 'hierarchical' => FALSE, 'depth' => - 1, 'title_li' => '', 'show_option_none' => $show_option_none, 'feed' => $r, 'feed_image' => $i, 'name' => 'extended-categories-top-select-' . $this->number );
396
  echo $before_widget;
397
  echo $this->core->comment;
398
  echo $before_title . $title . $after_title;
399
  echo '<ul>';
400
-
401
- if ( $style == 'list' ) {
402
- wp_list_categories( $cat_args );
403
  } else {
404
- wp_dropdown_categories( $cat_args );
405
  echo '<script type=\'text/javascript\'>' . "\n";
406
  echo '/* <![CDATA[ */' . "\n";
407
  echo ' var ec_dropdown_top_' . $this->number . ' = document.getElementById("extended-categories-top-select-' . $this->number . '");' . "\n";
408
  echo ' function ec_top_onCatChange_' . $this->number . '() {' . "\n";
409
  echo ' if ( ec_dropdown_top_' . $this->number . '.options[ec_dropdown_top_' . $this->number . '.selectedIndex].value > 0 ) {' . "\n";
410
- echo ' location.href = "' . get_option( 'home' ) . '/?cat="+ec_dropdown_top_' . $this->number . '.options[ec_dropdown_top_' . $this->number . '.selectedIndex].value;' . "\n";
411
  echo ' }' . "\n";
412
  echo ' }' . "\n";
413
  echo ' ec_dropdown_top_' . $this->number . '.onchange = ec_top_onCatChange_' . $this->number . ';' . "\n";
@@ -428,25 +423,25 @@ class WP_Widget_AVH_ExtendedCategories_Top extends WP_Widget
428
  * @param array $old_instance Old settings for this instance
429
  * @return array Settings to save or bool FALSE to cancel saving
430
  */
431
- function update ( $new_instance, $old_instance )
432
  {
433
  // update the instance's settings
434
- if ( ! isset( $new_instance['submit'] ) ) {
435
  return FALSE;
436
  }
437
-
438
  $instance = $old_instance;
439
-
440
- $instance['title'] = strip_tags( stripslashes( $new_instance['title'] ) );
441
- $instance['amount'] = ( int ) $new_instance['amount'];
442
  $instance['count'] = $new_instance['count'] ? TRUE : FALSE;
443
  $instance['use_desc_for_title'] = $new_instance['use_desc_for_title'] ? TRUE : FALSE;
444
- $instance['sort_column'] = strip_tags( stripslashes( $new_instance['sort_column'] ) );
445
- $instance['sort_order'] = strip_tags( stripslashes( $new_instance['sort_order'] ) );
446
- $instance['style'] = strip_tags( stripslashes( $new_instance['style'] ) );
447
  $instance['rssfeed'] = $new_instance['rssfeed'] ? TRUE : FALSE;
448
- $instance['rssimage'] = strip_tags( stripslashes( $new_instance['rssimage'] ) );
449
-
450
  return $instance;
451
  }
452
 
@@ -454,62 +449,62 @@ class WP_Widget_AVH_ExtendedCategories_Top extends WP_Widget
454
  *
455
  * @param array $instance Current settings
456
  */
457
- function form ( $instance )
458
  {
459
  // displays the widget admin form
460
- $instance = wp_parse_args( ( array ) $instance, array ('title' => '', 'rssimage' => '' ) );
461
-
462
  // Prepare data for display
463
- if ( ! $amount = ( int ) $instance['amount'] ) {
464
  $amount = 5;
465
  }
466
-
467
- if ( $amount < 1 ) {
468
  $amount = 1;
469
  }
470
  echo '<p>';
471
- avh_doWidgetFormText( $this->get_field_id( 'title' ), $this->get_field_name( 'title' ), __( 'Title', 'avh-ec' ), $instance['title'] );
472
  echo '</p>';
473
-
474
  echo '<p>';
475
- avh_doWidgetFormText( $this->get_field_id( 'amount' ), $this->get_field_name( 'amount' ), __( 'How many categories to show', 'avh-ec' ), $amount );
476
  echo '</p>';
477
-
478
  echo '<p>';
479
- avh_doWidgetFormCheckbox( $this->get_field_id( 'count' ), $this->get_field_name( 'count' ), __( 'Show post counts', 'avh-ec' ), ( bool ) $instance['count'] );
480
  echo '<br />';
481
-
482
- 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'] );
483
  echo '</p>';
484
-
485
  echo '<p>';
486
- $options['ID'] = __( 'ID', 'avh-ec' );
487
- $options['name'] = __( 'Name', 'avh-ec' );
488
- $options['count'] = __( 'Count', 'avh-ec' );
489
- $options['slug'] = __( 'Slug', 'avh-ec' );
490
- avh_doWidgetFormSelect( $this->get_field_id( 'sort_column' ), $this->get_field_name( 'sort_column' ), __( 'Sort by', 'avh-ec' ), $options, $instance['sort_column'] );
491
- unset( $options );
492
-
493
- $options['asc'] = __( 'Ascending', 'avh-ec' );
494
- $options['desc'] = __( 'Descending', 'avh-ec' );
495
- avh_doWidgetFormSelect( $this->get_field_id( 'sort_order' ), $this->get_field_name( 'sort_order' ), __( 'Sort order', 'avh-ec' ), $options, $instance['sort_order'] );
496
- unset( $options );
497
-
498
- $options['list'] = __( 'List', 'avh-ec' );
499
- $options['drop'] = __( 'Drop down', 'avh-ec' );
500
- avh_doWidgetFormSelect( $this->get_field_id( 'style' ), $this->get_field_name( 'style' ), __( 'Display style', 'avh-ec' ), $options, $instance['style'] );
501
- unset( $options );
502
  echo '</p>';
503
-
504
  echo '<p>';
505
-
506
- avh_doWidgetFormCheckbox( $this->get_field_id( 'rssfeed' ), $this->get_field_name( 'rssfeed' ), __( 'Show RSS Feed', 'avh-ec' ), ( bool ) $instance['rssfeed'] );
507
-
508
- avh_doWidgetFormText( $this->get_field_id( 'rssimage' ), $this->get_field_name( 'rssimage' ), __( 'Path (URI) to RSS image', 'avh-ec' ), $instance['rssimage'] );
509
-
510
  echo '</p>';
511
-
512
- echo '<input type="hidden" id="' . $this->get_field_id( 'submit' ) . '" name="' . $this->get_field_name( 'submit' ) . '" value="1" />';
513
  }
514
  }
515
 
@@ -531,12 +526,12 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
531
  */
532
  function __construct ()
533
  {
534
- $this->core = & AVH_EC_Singleton::getInstance( 'AVH_EC_Core' );
535
-
536
- $widget_ops = array ('description' => __( "Shows grouped categories.", 'avh-ec' ) );
537
- WP_Widget::__construct( FALSE, __( 'AVH Extended Category: Category Group' ), $widget_ops );
538
- add_action( 'wp_print_styles', array (&$this, 'actionWpPrintStyles' ) );
539
-
540
  }
541
 
542
  function WP_Widget_AVH_ExtendedCategories_Category_Group ()
@@ -546,9 +541,9 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
546
 
547
  function actionWpPrintStyles ()
548
  {
549
- if ( ! (FALSE === is_active_widget( FALSE, FALSE, $this->id_base, TRUE )) ) {
550
- wp_register_style( 'avhec-widget', AVHEC_PLUGIN_URL . '/css/avh-ec.widget.css', array (), $this->core->version );
551
- wp_enqueue_style( 'avhec-widget' );
552
  }
553
  }
554
 
@@ -558,46 +553,46 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
558
  * @param unknown_type $args
559
  * @param unknown_type $instance
560
  */
561
- function widget ( $args, $instance )
562
  {
563
  global $post;
564
-
565
- $catgrp = & AVH_EC_Singleton::getInstance( 'AVH_EC_Category_Group' );
566
  $options = $this->core->getOptions();
567
-
568
- $row = array ();
569
-
570
- if (is_home () ) {
571
- $special_page='home_group';
572
  } elseif (is_category()) {
573
- $special_page='category_group';
574
  } elseif (is_day()) {
575
- $special_page='day_group';
576
  } elseif (is_month()) {
577
- $special_page='month_group';
578
- }elseif (is_year()) {
579
- $special_page='year_group';
580
  } elseif (is_author()) {
581
- $special_page='author_group';
582
  } elseif (is_search()) {
583
- $special_page='search_group';
584
  } else {
585
- $special_page='none';
586
  }
587
-
588
  $toDisplay = FALSE;
589
- if ( $special_page != 'none' ) {
590
  $sp_category_group = $options['sp_cat_group'][$special_page];
591
- if (!($this->getWidgetDoneCatGroup($sp_category_group))) {
592
- $row = get_term_by( 'id', $sp_category_group, $catgrp->taxonomy_name ); // Returns FALSE when non-existance. (empty(FALSE)=TRUE)
593
  $toDisplay = TRUE;
594
  }
595
  } else {
596
- $terms = wp_get_object_terms( $post->ID, $catgrp->taxonomy_name );
597
- if ( ! empty( $terms ) ) {
598
- foreach ($terms as $key => $value){
599
- if (!($this->getWidgetDoneCatGroup($value->term_id))) {
600
- $row=$value;
601
  $toDisplay = TRUE;
602
  break;
603
  }
@@ -605,19 +600,19 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
605
  } else {
606
  $options = $this->core->options;
607
  $no_cat_group = $options['cat_group']['no_group'];
608
- $row = get_term_by( 'id', $no_cat_group, $catgrp->taxonomy_name );
609
  $toDisplay = TRUE;
610
  }
611
  }
612
-
613
  $selected_catgroups = unserialize($instance['post_group_category']);
614
  if (! (FALSE == $selected_catgroups || array_key_exists($row->term_id, $selected_catgroups))) {
615
  $toDisplay = FALSE;
616
  }
617
-
618
- if ( $toDisplay ) {
619
- extract( $args );
620
-
621
  $c = $instance['count'] ? TRUE : FALSE;
622
  $e = $instance['hide_empty'] ? TRUE : FALSE;
623
  $h = $instance['hierarchical'] ? TRUE : FALSE;
@@ -626,48 +621,48 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
626
  $o = $instance['sort_order'] ? $instance['sort_order'] : 'asc';
627
  $r = $instance['rssfeed'] ? 'RSS' : '';
628
  $i = $instance['rssimage'] ? $instance['rssimage'] : '';
629
-
630
- if ( empty( $r ) ) {
631
  $i = '';
632
  }
633
-
634
- $style = empty( $instance['style'] ) ? 'list' : $instance['style'];
635
  $group_id = $row->term_id;
636
- $cats = $catgrp->getCategoriesFromGroup( $group_id );
637
- if ( empty( $instance['title'] ) ) {
638
- $title = $catgrp->getWidgetTitleForGroup( $group_id );
639
- if ( ! $title ) {
640
- $title = __( 'Categories', 'avh-ec' );
641
  }
642
  } else {
643
  $title = $instance['title'];
644
  }
645
- $title = apply_filters( 'widget_title', $title );
646
-
647
- $included_cats = implode( ',', $cats );
648
-
649
- $show_option_none = __( 'Select Category', 'avh-ec' );
650
- if ( $options['general']['alternative_name_select_category'] ) {
651
  $show_option_none = $options['general']['alternative_name_select_category'];
652
  }
653
-
654
- $cat_args = array ('include' => $included_cats, 'orderby' => $s, 'order' => $o, 'show_count' => $c, 'use_desc_for_title' => $use_desc_for_title, 'hide_empty' => $e, 'hierarchical' => $h, 'title_li' => '', 'show_option_none' => $show_option_none, 'feed' => $r, 'feed_image' => $i, 'name' => 'extended-categories-select-group-' . $this->number );
655
  echo $before_widget;
656
  echo $this->core->comment;
657
  echo $before_title . $title . $after_title;
658
-
659
- if ( $style == 'list' ) {
660
  echo '<ul>';
661
- $this->core->avh_wp_list_categories( $cat_args, TRUE );
662
  echo '</ul>';
663
  } else {
664
- $this->core->avh_wp_dropdown_categories( $cat_args, TRUE );
665
  echo '<script type=\'text/javascript\'>' . "\n";
666
  echo '/* <![CDATA[ */' . "\n";
667
  echo ' var ec_dropdown_' . $this->number . ' = document.getElementById("extended-categories-select-group-' . $this->number . '");' . "\n";
668
  echo ' function ec_onCatChange_' . $this->number . '() {' . "\n";
669
  echo ' if ( ec_dropdown_' . $this->number . '.options[ec_dropdown_' . $this->number . '.selectedIndex].value > 0 ) {' . "\n";
670
- echo ' location.href = "' . get_option( 'home' ) . '/?cat="+ec_dropdown_' . $this->number . '.options[ec_dropdown_' . $this->number . '.selectedIndex].value;' . "\n";
671
  echo ' }' . "\n";
672
  echo ' }' . "\n";
673
  echo ' ec_dropdown_' . $this->number . '.onchange = ec_onCatChange_' . $this->number . ';' . "\n";
@@ -685,29 +680,29 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
685
  * @param unknown_type $old_instance
686
  * @return unknown
687
  */
688
- function update ( $new_instance, $old_instance )
689
  {
690
  // update the instance's settings
691
- if ( ! isset( $new_instance['submit'] ) ) {
692
  return FALSE;
693
  }
694
-
695
  $instance = $old_instance;
696
-
697
- $instance['title'] = strip_tags( stripslashes( $new_instance['title'] ) );
698
  $instance['count'] = $new_instance['count'] ? TRUE : FALSE;
699
  $instance['hierarchical'] = $new_instance['hierarchical'] ? TRUE : FALSE;
700
  $instance['hide_empty'] = $new_instance['hide_empty'] ? TRUE : FALSE;
701
  $instance['use_desc_for_title'] = $new_instance['use_desc_for_title'] ? TRUE : FALSE;
702
- $instance['sort_column'] = strip_tags( stripslashes( $new_instance['sort_column'] ) );
703
- $instance['sort_order'] = strip_tags( stripslashes( $new_instance['sort_order'] ) );
704
- $instance['style'] = strip_tags( stripslashes( $new_instance['style'] ) );
705
  $instance['rssfeed'] = $new_instance['rssfeed'] ? TRUE : FALSE;
706
- $instance['rssimage'] = strip_tags( stripslashes( $new_instance['rssimage'] ) );
707
- if ( array_key_exists( 'all', $new_instance['post_group_category'] ) ) {
708
  $instance['post_group_category'] = FALSE;
709
  } else {
710
- $instance['post_group_category'] = serialize( $new_instance['post_group_category'] );
711
  }
712
  return $instance;
713
  }
@@ -717,17 +712,17 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
717
  *
718
  * @param unknown_type $instance
719
  */
720
- function form ( $instance )
721
  {
722
  // displays the widget admin form
723
- $instance = wp_parse_args( ( array ) $instance, array ('title' => '', 'rssimage' => '' ) );
724
-
725
  // Prepare data for display
726
- $title = esc_attr( $instance['title'] );
727
- $count = ( bool ) $instance['count'];
728
- $hierarchical = ( bool ) $instance['hierarchical'];
729
- $hide_empty = ( bool ) $instance['hide_empty'];
730
- $use_desc_for_title = ( bool ) $instance['use_desc_for_title'];
731
  $sort_id = ($instance['sort_column'] == 'ID') ? ' SELECTED' : '';
732
  $sort_name = ($instance['sort_column'] == 'name') ? ' SELECTED' : '';
733
  $sort_count = ($instance['sort_column'] == 'count') ? ' SELECTED' : '';
@@ -735,116 +730,112 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
735
  $sort_order_d = ($instance['sort_order'] == 'desc') ? ' SELECTED' : '';
736
  $style_list = ($instance['style'] == 'list') ? ' SELECTED' : '';
737
  $style_drop = ($instance['style'] == 'drop') ? ' SELECTED' : '';
738
- $rssfeed = ( bool ) $instance['rssfeed'];
739
- $rssimage = esc_attr( $instance['rssimage'] );
740
-
741
- $selected_cats = ($instance['post_group_category'] != '') ? unserialize( $instance['post_group_category'] ) : FALSE;
742
-
743
  echo '<p>';
744
- avh_doWidgetFormText( $this->get_field_id( 'title' ), $this->get_field_name( 'title' ), __( 'Title', 'avh-ec' ), $instance['title'] );
745
  echo '</p>';
746
-
747
  echo '<p>';
748
-
749
- avh_doWidgetFormCheckbox( $this->get_field_id( 'count' ), $this->get_field_name( 'count' ), __( 'Show post counts', 'avh-ec' ), ( bool ) $instance['count'] );
750
-
751
- avh_doWidgetFormCheckbox( $this->get_field_id( 'hierarchical' ), $this->get_field_name( 'hierarchical' ), __( 'Show hierarchy', 'avh-ec' ), ( bool ) $instance['hierarchical'] );
752
-
753
- avh_doWidgetFormCheckbox( $this->get_field_id( 'hide_empty' ), $this->get_field_name( 'hide_empty' ), __( 'Hide empty categories', 'avh-ec' ), ( bool ) $instance['hide_empty'] );
754
-
755
- 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'] );
756
  echo '</p>';
757
-
758
  echo '<p>';
759
- $options['ID'] = __( 'ID', 'avh-ec' );
760
- $options['name'] = __( 'Name', 'avh-ec' );
761
- $options['count'] = __( 'Count', 'avh-ec' );
762
- $options['slug'] = __( 'Slug', 'avh-ec' );
763
- avh_doWidgetFormSelect( $this->get_field_id( 'sort_column' ), $this->get_field_name( 'sort_column' ), __( 'Sort by', 'avh-ec' ), $options, $instance['sort_column'] );
764
- unset( $options );
765
-
766
- $options['asc'] = __( 'Ascending', 'avh-ec' );
767
- $options['desc'] = __( 'Descending', 'avh-ec' );
768
- avh_doWidgetFormSelect( $this->get_field_id( 'sort_order' ), $this->get_field_name( 'sort_order' ), __( 'Sort order', 'avh-ec' ), $options, $instance['sort_order'] );
769
- unset( $options );
770
-
771
- $options['list'] = __( 'List', 'avh-ec' );
772
- $options['drop'] = __( 'Drop down', 'avh-ec' );
773
- avh_doWidgetFormSelect( $this->get_field_id( 'style' ), $this->get_field_name( 'style' ), __( 'Display style', 'avh-ec' ), $options, $instance['style'] );
774
- unset( $options );
775
  echo '</p>';
776
-
777
  echo '<p>';
778
-
779
- avh_doWidgetFormCheckbox( $this->get_field_id( 'rssfeed' ), $this->get_field_name( 'rssfeed' ), __( 'Show RSS Feed', 'avh-ec' ), ( bool ) $instance['rssfeed'] );
780
-
781
- avh_doWidgetFormText( $this->get_field_id( 'rssimage' ), $this->get_field_name( 'rssimage' ), __( 'Path (URI) to RSS image', 'avh-ec' ), $instance['rssimage'] );
782
  echo '</p>';
783
-
784
- echo '<p>';
785
- echo '<b>' . __( 'Select Groups', 'avh-ec' ) . '</b><hr />';
786
  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;">';
787
- echo '<li id="' . $this->get_field_id( 'group_category--1' ) . '" class="popular-group_category">';
788
- echo '<label for="' . $this->get_field_id( 'group_post_category' ) . '" class="selectit">';
789
- echo '<input value="all" id="' . $this->get_field_id( 'group_post_category' ) . '" name="' . $this->get_field_name( 'post_group_category' ) . '[all]" type="checkbox" ' . (FALSE === $selected_cats ? ' CHECKED' : '') . '> ';
790
- _e( 'Any Group', 'avh-ec' );
791
  echo '</label>';
792
  echo '</li>';
793
  ob_start();
794
- $this->avh_wp_group_category_checklist($selected_cats,$this->number );
795
  ob_end_flush();
796
  echo '</ul>';
797
  echo '</p>';
798
-
799
- echo '<input type="hidden" id="' . $this->get_field_id( 'submit' ) . '" name="' . $this->get_field_name( 'submit' ) . '" value="1" />';
800
  }
801
 
802
- function avh_wp_group_category_checklist ( $selected_cats, $number)
803
  {
804
-
805
  $walker = new AVH_Walker_Category_Checklist();
806
  $walker->number = $number;
807
- $walker->input_id = $this->get_field_id( 'post_group_category' );
808
- $walker->input_name = $this->get_field_name( 'post_group_category' );
809
- $walker->li_id = $this->get_field_id( 'group_category--1' );
810
-
811
- $args = array ('taxonomy' => 'avhec_catgroup',
812
- 'descendants_and_self' => 0,
813
- 'selected_cats' => array(),
814
- 'popular_cats' => array(),
815
- 'walker' => $walker,
816
- 'checked_ontop' => true);
817
-
818
- if ( is_array( $selected_cats ) )
819
  $args['selected_cats'] = $selected_cats;
820
  else
821
- $args['selected_cats'] = array ();
822
-
823
- $categories = (array) get_terms($args['taxonomy'], array('get' => 'all'));
824
-
825
  // 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)
826
- $checked_categories = array ();
827
- $keys = array_keys( $categories );
828
-
829
- foreach( $keys as $k ) {
830
- if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
831
  $checked_categories[] = $categories[$k];
832
- unset( $categories[$k] );
833
  }
834
  }
835
-
836
  // Put checked cats on top
837
- echo call_user_func_array( array (&$walker, 'walk' ), array ($checked_categories, 0, $args ) );
838
  // Then the rest of them
839
- echo call_user_func_array( array (&$walker, 'walk' ), array ($categories, 0, $args ) );
840
  }
841
 
842
- function getWidgetDoneCatGroup($id) {
843
- $catgrp = & AVH_EC_Singleton::getInstance( 'AVH_EC_Category_Group' );
 
844
  if (is_array($catgrp->widget_done_catgroup) && array_key_exists($id, $catgrp->widget_done_catgroup)) {
845
  return TRUE;
846
  }
847
- $catgrp->widget_done_catgroup[$id]=TRUE;
848
  return FALSE;
849
  }
850
  }
@@ -856,34 +847,34 @@ class WP_Widget_AVH_ExtendedCategories_Category_Group extends WP_Widget
856
  class AVH_Walker_Category_Checklist extends Walker
857
  {
858
  var $tree_type = 'category';
859
- var $db_fields = array ('parent' => 'parent', 'id' => 'term_id' ); //TODO: decouple this
860
  var $number;
861
  var $input_id;
862
  var $input_name;
863
  var $li_id;
864
 
865
- function start_lvl ( &$output, $depth, $args )
866
  {
867
- $indent = str_repeat( "\t", $depth );
868
  $output .= $indent . '<ul class="children">' . "\n";
869
  }
870
 
871
- function end_lvl ( &$output, $depth, $args )
872
  {
873
- $indent = str_repeat( "\t", $depth );
874
  $output .= $indent . '</ul>' . "\n";
875
  }
876
 
877
- function start_el ( &$output, $category, $depth, $args )
878
  {
879
- extract( $args );
880
  $input_id = $this->input_id . '-' . $category->term_id;
881
  $output .= "\n" . '<li id="' . $this->li_id . '">';
882
  $output .= '<label for="' . $input_id . '" class="selectit">';
883
- $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>';
884
  }
885
 
886
- function end_el ( &$output, $category, $depth, $args )
887
  {
888
  $output .= "</li>\n";
889
  }
1
  <?php
2
+
3
  /**
4
  * Widget Class for displaying categories. Extended version of the dfeault categories.
5
  *
18
  */
19
  function __construct ()
20
  {
21
+ $this->core = & AVH_EC_Singleton::getInstance('AVH_EC_Core');
22
+
23
  //Convert the old option widget_extended_categories to widget_extended-categories
24
+ $old = get_option('widget_extended_categories');
25
+ if (! (FALSE === $old)) {
26
+ update_option('widget_extended-categories', $old);
27
+ delete_option('widget_extended_categories');
28
+ }
29
+ $widget_ops = array('description'=>__("An extended version of the default Categories widget.", 'avh-ec'));
30
+ WP_Widget::__construct('extended-categories', __('AVH Extended Categories'), $widget_ops);
31
+
32
+ add_action('wp_print_styles', array(&$this, 'actionWpPrintStyles'));
33
+
34
  }
35
 
36
  function WP_Widget_AVH_ExtendedCategories_Normal ()
40
 
41
  function actionWpPrintStyles ()
42
  {
43
+
44
+ if (! (FALSE === is_active_widget(FALSE, FALSE, $this->id_base, TRUE))) {
45
+ wp_register_style('avhec-widget', AVHEC_PLUGIN_URL . '/css/avh-ec.widget.css', array(), $this->core->version);
46
+ wp_enqueue_style('avhec-widget');
47
  }
48
  }
49
 
53
  * @param unknown_type $args
54
  * @param unknown_type $instance
55
  */
56
+ function widget ($args, $instance)
57
  {
58
+
59
+ extract($args);
60
+
61
  $selectedonly = $instance['selectedonly'] ? TRUE : FALSE;
62
  $c = $instance['count'] ? TRUE : FALSE;
63
  $h = $instance['hierarchical'] ? TRUE : FALSE;
69
  $r = $instance['rssfeed'] ? 'RSS' : '';
70
  $i = $instance['rssimage'] ? $instance['rssimage'] : '';
71
  $invert = $instance['invert_included'] ? TRUE : FALSE;
72
+
73
+ if (empty($r)) {
74
  $i = '';
75
  }
76
+
77
+ if (empty($d)) {
78
  $d = 0;
79
  }
80
+
81
+ $title = apply_filters('widget_title', empty($instance['title']) ? __('Categories', 'avh-ec') : $instance['title']);
82
+ $style = empty($instance['style']) ? 'list' : $instance['style'];
83
+
84
  $included_cats = '';
85
+ if ($instance['post_category']) {
86
+ $post_category = unserialize($instance['post_category']);
87
+ $children = array();
88
+ if (! $instance['selectedonly']) {
89
+ foreach ($post_category as $cat_id) {
90
+ $children = array_merge($children, get_term_children($cat_id, 'category'));
91
  }
92
  }
93
+ $included_cats = implode(",", array_merge($post_category, $children));
94
  }
95
+
96
+ if ($invert) {
97
  $inc_exc = 'exclude';
98
  } else {
99
  $inc_exc = 'include';
100
  }
101
+
102
  $options = $this->core->getOptions();
103
+ $show_option_none = __('Select Category', 'avh-ec');
104
+ if ($options['general']['alternative_name_select_category']) {
105
  $show_option_none = $options['general']['alternative_name_select_category'];
106
  }
107
+
108
+ $cat_args = array($inc_exc=>$included_cats, 'orderby'=>$s, 'order'=>$o, 'show_count'=>$c, 'use_desc_for_title'=>$use_desc_for_title, 'hide_empty'=>$e, 'hierarchical'=>$h, 'depth'=>$d, 'title_li'=>'', 'show_option_none'=>$show_option_none, 'feed'=>$r, 'feed_image'=>$i, 'name'=>'extended-categories-select-' . $this->number);
109
  echo $before_widget;
110
  echo $this->core->comment;
111
  echo $before_title . $title . $after_title;
112
+
113
+ if ($style == 'list') {
114
  echo '<ul>';
115
+ $this->core->avh_wp_list_categories($cat_args, $selectedonly);
116
  echo '</ul>';
117
  } else {
118
+ $this->core->avh_wp_dropdown_categories($cat_args, $selectedonly);
119
  echo '<script type=\'text/javascript\'>' . "\n";
120
  echo '/* <![CDATA[ */' . "\n";
121
  echo ' var ec_dropdown_' . $this->number . ' = document.getElementById("extended-categories-select-' . $this->number . '");' . "\n";
122
  echo ' function ec_onCatChange_' . $this->number . '() {' . "\n";
123
  echo ' if ( ec_dropdown_' . $this->number . '.options[ec_dropdown_' . $this->number . '.selectedIndex].value > 0 ) {' . "\n";
124
+ echo ' location.href = "' . get_option('home') . '/?cat="+ec_dropdown_' . $this->number . '.options[ec_dropdown_' . $this->number . '.selectedIndex].value;' . "\n";
125
  echo ' }' . "\n";
126
  echo ' }' . "\n";
127
  echo ' ec_dropdown_' . $this->number . '.onchange = ec_onCatChange_' . $this->number . ';' . "\n";
138
  * @param unknown_type $old_instance
139
  * @return unknown
140
  */
141
+ function update ($new_instance, $old_instance)
142
  {
143
  // update the instance's settings
144
+ if (! isset($new_instance['submit'])) {
145
  return FALSE;
146
  }
147
+
148
  $instance = $old_instance;
149
+
150
+ $instance['title'] = strip_tags(stripslashes($new_instance['title']));
151
  $instance['selectedonly'] = $new_instance['selectedonly'] ? TRUE : FALSE;
152
  $instance['count'] = $new_instance['count'] ? TRUE : FALSE;
153
  $instance['hierarchical'] = $new_instance['hierarchical'] ? TRUE : FALSE;
154
  $instance['hide_empty'] = $new_instance['hide_empty'] ? TRUE : FALSE;
155
  $instance['use_desc_for_title'] = $new_instance['use_desc_for_title'] ? TRUE : FALSE;
156
+ $instance['sort_column'] = strip_tags(stripslashes($new_instance['sort_column']));
157
+ $instance['sort_order'] = strip_tags(stripslashes($new_instance['sort_order']));
158
+ $instance['style'] = strip_tags(stripslashes($new_instance['style']));
159
  $instance['rssfeed'] = $new_instance['rssfeed'] ? TRUE : FALSE;
160
+ $instance['rssimage'] = strip_tags(stripslashes($new_instance['rssimage']));
161
+ if (array_key_exists('all', $new_instance['post_category'])) {
162
  $instance['post_category'] = FALSE;
163
  } else {
164
+ $instance['post_category'] = serialize($new_instance['post_category']);
165
  }
166
+ $instance['depth'] = (int) $new_instance['depth'];
167
+ if ($instance['depth'] < 0 || 11 < $instance['depth']) {
168
  $instance['depth'] = 0;
169
  }
170
  $instance['invert_included'] = $new_instance['invert_included'] ? TRUE : FALSE;
171
+
172
  return $instance;
173
  }
174
 
177
  *
178
  * @param unknown_type $instance
179
  */
180
+ function form ($instance)
181
  {
182
  // displays the widget admin form
183
+ $instance = wp_parse_args((array) $instance, array('title'=>'', 'rssimage'=>'', 'depth'=>0));
184
+
185
  // Prepare data for display
186
+ $depth = (int) $instance['depth'];
187
+ if ($depth < 0 || 11 < $depth) {
188
  $depth = 0;
189
  }
190
+ $selected_cats = ($instance['post_category'] != '') ? unserialize($instance['post_category']) : FALSE;
191
+
192
  echo '<p>';
193
+ avh_doWidgetFormText($this->get_field_id('title'), $this->get_field_name('title'), __('Title', 'avh-ec'), $instance['title']);
194
  echo '</p>';
195
+
196
  echo '<p>';
197
+ avh_doWidgetFormCheckbox($this->get_field_id('selectedonly'), $this->get_field_name('selectedonly'), __('Show selected categories only', 'avh-ec'), (bool) $instance['selectedonly']);
198
+
199
+ avh_doWidgetFormCheckbox($this->get_field_id('count'), $this->get_field_name('count'), __('Show post counts', 'avh-ec'), (bool) $instance['count']);
200
+
201
+ avh_doWidgetFormCheckbox($this->get_field_id('hierarchical'), $this->get_field_name('hierarchical'), __('Show hierarchy', 'avh-ec'), (bool) $instance['hierarchical']);
202
+
203
+ $options = array(0=>__('All Levels', 'avh-ec'), 1=>__('Toplevel only', 'avh-ec'));
204
+ for ($i = 2; $i <= 11; $i ++) {
205
+ $options[$i] = __('Child ', 'avh-ec') . ($i - 1);
206
+ }
207
+ avh_doWidgetFormSelect($this->get_field_id('depth'), $this->get_field_name('depth'), __('How many levels to show', 'avh-ec'), $options, $depth);
208
+ unset($options);
209
+
210
+ avh_doWidgetFormCheckbox($this->get_field_id('hide_empty'), $this->get_field_name('hide_empty'), __('Hide empty categories', 'avh-ec'), (bool) $instance['hide_empty']);
211
+
212
+ 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']);
213
  echo '</p>';
214
+
215
  echo '<p>';
216
+ $options['ID'] = __('ID', 'avh-ec');
217
+ $options['name'] = __('Name', 'avh-ec');
218
+ $options['count'] = __('Count', 'avh-ec');
219
+ $options['slug'] = __('Slug', 'avh-ec');
220
+ avh_doWidgetFormSelect($this->get_field_id('sort_column'), $this->get_field_name('sort_column'), __('Sort by', 'avh-ec'), $options, $instance['sort_column']);
221
+ unset($options);
222
+
223
+ $options['asc'] = __('Ascending', 'avh-ec');
224
+ $options['desc'] = __('Descending', 'avh-ec');
225
+ avh_doWidgetFormSelect($this->get_field_id('sort_order'), $this->get_field_name('sort_order'), __('Sort order', 'avh-ec'), $options, $instance['sort_order']);
226
+ unset($options);
227
+
228
+ $options['list'] = __('List', 'avh-ec');
229
+ $options['drop'] = __('Drop down', 'avh-ec');
230
+ avh_doWidgetFormSelect($this->get_field_id('style'), $this->get_field_name('style'), __('Display style', 'avh-ec'), $options, $instance['style']);
231
+ unset($options);
232
  echo '</p>';
233
+
234
  echo '<p>';
235
+
236
+ avh_doWidgetFormCheckbox($this->get_field_id('rssfeed'), $this->get_field_name('rssfeed'), __('Show RSS Feed', 'avh-ec'), (bool) $instance['rssfeed']);
237
+
238
+ avh_doWidgetFormText($this->get_field_id('rssimage'), $this->get_field_name('rssimage'), __('Path (URI) to RSS image', 'avh-ec'), $instance['rssimage']);
239
+
240
  echo '</p>';
241
+
242
  echo '<p>';
243
+ echo '<b>' . __('Select categories', 'avh-ec') . '</b><hr />';
244
  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;">';
245
+ echo '<li id="' . $this->get_field_id('category--1') . '" class="popular-category">';
246
+ echo '<label for="' . $this->get_field_id('post_category') . '" class="selectit">';
247
+ 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' : '') . '> ';
248
+ _e('All Categories', 'avh-ec');
249
  echo '</label>';
250
  echo '</li>';
251
  ob_start();
252
+ $this->avh_wp_category_checklist($selected_cats, $this->number);
253
  ob_end_flush();
254
  echo '</ul>';
255
  echo '</p>';
256
+
257
  echo '<p>';
258
+ avh_doWidgetFormCheckbox($this->get_field_id('invert_included'), $this->get_field_name('invert_included'), __('Exclude the selected categories', 'avh-ec'), (bool) $instance['invert_included']);
259
  echo '</p>';
260
+
261
+ echo '<input type="hidden" id="' . $this->get_field_id('submit') . '" name="' . $this->get_field_name('submit') . '" value="1" />';
262
  }
263
 
264
  /**
270
  * @param array $popular_cats
271
  * @param int $number
272
  */
273
+ function avh_wp_category_checklist ($selected_cats, $number)
274
  {
275
+
276
  $walker = new AVH_Walker_Category_Checklist();
277
  $walker->number = $number;
278
+ $walker->input_id = $this->get_field_id('post_category');
279
+ $walker->input_name = $this->get_field_name('post_category');
280
+ $walker->li_id = $this->get_field_id('category--1');
281
+
282
+ $args = array('taxonomy'=>'category', 'descendants_and_self'=>0, 'selected_cats'=>$selected_cats, 'popular_cats'=>array(), 'walker'=>$walker, 'checked_ontop'=>true, 'popular_cats'=>array());
283
+
284
+ if (is_array($selected_cats))
 
 
 
 
 
 
285
  $args['selected_cats'] = $selected_cats;
286
  else
287
+ $args['selected_cats'] = array();
288
+
289
  $categories = $this->core->getCategories();
290
  $_categories_id = $this->core->getCategoriesId($categories);
291
+
292
  // 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)
293
+ $checked_categories = array();
294
  foreach ($args['selected_cats'] as $key => $value) {
295
  if (isset($_categories_id[$key])) {
296
+ $category_key = $_categories_id[$key];
297
  $checked_categories[] = $categories[$category_key];
298
+ unset($categories[$category_key]);
299
  }
300
  }
301
+
302
  // Put checked cats on top
303
+ echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
304
  // Then the rest of them
305
+ echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
306
  }
307
  }
308
 
324
  */
325
  function __construct ()
326
  {
327
+ $this->core = & AVH_EC_Singleton::getInstance('AVH_EC_Core');
328
+
329
+ $widget_ops = array('description'=>__("Shows the top categories.", 'avh-ec'));
330
+ WP_Widget::__construct(FALSE, __('AVH Extended Categories: Top Categories'), $widget_ops);
331
+ add_action('wp_print_styles', array(&$this, 'actionWpPrintStyles'));
332
+
333
  }
334
 
335
  function WP_Widget_AVH_ExtendedCategories_Top ()
339
 
340
  function actionWpPrintStyles ()
341
  {
342
+ if (! (FALSE === is_active_widget(FALSE, FALSE, $this->id_base, TRUE))) {
343
+ wp_register_style('avhec-widget', AVHEC_PLUGIN_URL . '/css/avh-ec.widget.css', array(), $this->core->version);
344
+ wp_enqueue_style('avhec-widget');
345
  }
346
  }
347
 
352
  * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
353
  * @param array $instance The settings for the particular instance of the widget
354
  */
355
+ function widget ($args, $instance)
356
  {
357
+ extract($args);
358
+
359
+ $title = apply_filters('widget_title', empty($instance['title']) ? __('Categories', 'avh-ec') : $instance['title']);
360
+ $style = empty($instance['style']) ? 'list' : $instance['style'];
361
+ if (! $a = (int) $instance['amount']) {
362
  $a = 5;
363
+ } elseif ($a < 1) {
364
  $a = 1;
365
  }
366
  $c = $instance['count'] ? TRUE : FALSE;
369
  $o = $instance['sort_order'] ? $instance['sort_order'] : 'asc';
370
  $r = $instance['rssfeed'] ? 'RSS' : '';
371
  $i = $instance['rssimage'] ? $instance['rssimage'] : '';
372
+ if (empty($r)) {
373
  $i = '';
374
  }
375
+ if (! empty($i)) {
376
+ if (! file_exists(ABSPATH . '/' . $i)) {
377
  $i = '';
378
  }
379
  }
380
+
381
  $options = $this->core->getOptions();
382
+ $show_option_none = __('Select Category', 'avh-ec');
383
+ if ($options['general']['alternative_name_select_category']) {
384
  $show_option_none = $options['general']['alternative_name_select_category'];
385
  }
386
+
387
+ $top_cats = get_terms('category', array('fields'=>'ids', 'orderby'=>'count', 'order'=>'DESC', 'number'=>$a, 'hierarchical'=>FALSE));
388
+ $included_cats = implode(",", $top_cats);
389
+
390
+ $cat_args = array('include'=>$included_cats, 'orderby'=>$s, 'order'=>$o, 'show_count'=>$c, 'use_desc_for_title'=>$use_desc_for_title, 'hide_empty'=>FALSE, 'hierarchical'=>FALSE, 'depth'=>- 1, 'title_li'=>'', 'show_option_none'=>$show_option_none, 'feed'=>$r, 'feed_image'=>$i, 'name'=>'extended-categories-top-select-' . $this->number);
391
  echo $before_widget;
392
  echo $this->core->comment;
393
  echo $before_title . $title . $after_title;
394
  echo '<ul>';
395
+
396
+ if ($style == 'list') {
397
+ wp_list_categories($cat_args);
398
  } else {
399
+ wp_dropdown_categories($cat_args);
400
  echo '<script type=\'text/javascript\'>' . "\n";
401
  echo '/* <![CDATA[ */' . "\n";
402
  echo ' var ec_dropdown_top_' . $this->number . ' = document.getElementById("extended-categories-top-select-' . $this->number . '");' . "\n";
403
  echo ' function ec_top_onCatChange_' . $this->number . '() {' . "\n";
404
  echo ' if ( ec_dropdown_top_' . $this->number . '.options[ec_dropdown_top_' . $this->number . '.selectedIndex].value > 0 ) {' . "\n";
405
+ echo ' location.href = "' . get_option('home') . '/?cat="+ec_dropdown_top_' . $this->number . '.options[ec_dropdown_top_' . $this->number . '.selectedIndex].value;' . "\n";
406
  echo ' }' . "\n";
407
  echo ' }' . "\n";
408
  echo ' ec_dropdown_top_' . $this->number . '.onchange = ec_top_onCatChange_' . $this->number . ';' . "\n";
423
  * @param array $old_instance Old settings for this instance
424
  * @return array Settings to save or bool FALSE to cancel saving
425
  */
426
+ function update ($new_instance, $old_instance)
427
  {
428
  // update the instance's settings
429
+ if (! isset($new_instance['submit'])) {
430
  return FALSE;
431
  }
432
+
433
  $instance = $old_instance;
434
+
435
+ $instance['title'] = strip_tags(stripslashes($new_instance['title']));
436
+ $instance['amount'] = (int) $new_instance['amount'];
437
  $instance['count'] = $new_instance['count'] ? TRUE : FALSE;
438
  $instance['use_desc_for_title'] = $new_instance['use_desc_for_title'] ? TRUE : FALSE;
439
+ $instance['sort_column'] = strip_tags(stripslashes($new_instance['sort_column']));
440
+ $instance['sort_order'] = strip_tags(stripslashes($new_instance['sort_order']));
441
+ $instance['style'] = strip_tags(stripslashes($new_instance['style']));
442
  $instance['rssfeed'] = $new_instance['rssfeed'] ? TRUE : FALSE;
443
+ $instance['rssimage'] = strip_tags(stripslashes($new_instance['rssimage']));
444
+
445
  return $instance;
446
  }
447
 
449
  *
450
  * @param array $instance Current settings
451
  */
452
+ function form ($instance)
453
  {
454
  // displays the widget admin form
455
+ $instance = wp_parse_args((array) $instance, array('title'=>'', 'rssimage'=>''));
456
+
457
  // Prepare data for display
458
+ if (! $amount = (int) $instance['amount']) {
459
  $amount = 5;
460
  }
461
+
462
+ if ($amount < 1) {
463
  $amount = 1;
464
  }
465
  echo '<p>';
466
+ avh_doWidgetFormText($this->get_field_id('title'), $this->get_field_name('title'), __('Title', 'avh-ec'), $instance['title']);
467
  echo '</p>';
468
+
469
  echo '<p>';
470
+ avh_doWidgetFormText($this->get_field_id('amount'), $this->get_field_name('amount'), __('How many categories to show', 'avh-ec'), $amount);
471
  echo '</p>';
472
+
473
  echo '<p>';
474
+ avh_doWidgetFormCheckbox($this->get_field_id('count'), $this->get_field_name('count'), __('Show post counts', 'avh-ec'), (bool) $instance['count']);
475
  echo '<br />';
476
+
477
+ 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']);
478
  echo '</p>';
479
+
480
  echo '<p>';
481
+ $options['ID'] = __('ID', 'avh-ec');
482
+ $options['name'] = __('Name', 'avh-ec');
483
+ $options['count'] = __('Count', 'avh-ec');
484
+ $options['slug'] = __('Slug', 'avh-ec');
485
+ avh_doWidgetFormSelect($this->get_field_id('sort_column'), $this->get_field_name('sort_column'), __('Sort by', 'avh-ec'), $options, $instance['sort_column']);
486
+ unset($options);
487
+
488
+ $options['asc'] = __('Ascending', 'avh-ec');
489
+ $options['desc'] = __('Descending', 'avh-ec');
490
+ avh_doWidgetFormSelect($this->get_field_id('sort_order'), $this->get_field_name('sort_order'), __('Sort order', 'avh-ec'), $options, $instance['sort_order']);
491
+ unset($options);
492
+
493
+ $options['list'] = __('List', 'avh-ec');
494
+ $options['drop'] = __('Drop down', 'avh-ec');
495
+ avh_doWidgetFormSelect($this->get_field_id('style'), $this->get_field_name('style'), __('Display style', 'avh-ec'), $options, $instance['style']);
496
+ unset($options);
497
  echo '</p>';
498
+
499
  echo '<p>';
500
+
501
+ avh_doWidgetFormCheckbox($this->get_field_id('rssfeed'), $this->get_field_name('rssfeed'), __('Show RSS Feed', 'avh-ec'), (bool) $instance['rssfeed']);
502
+
503
+ avh_doWidgetFormText($this->get_field_id('rssimage'), $this->get_field_name('rssimage'), __('Path (URI) to RSS image', 'avh-ec'), $instance['rssimage']);
504
+
505
  echo '</p>';
506
+
507
+ echo '<input type="hidden" id="' . $this->get_field_id('submit') . '" name="' . $this->get_field_name('submit') . '" value="1" />';
508
  }
509
  }
510
 
526
  */
527
  function __construct ()
528
  {
529
+ $this->core = & AVH_EC_Singleton::getInstance('AVH_EC_Core');
530
+
531
+ $widget_ops = array('description'=>__("Shows grouped categories.", 'avh-ec'));
532
+ WP_Widget::__construct(FALSE, __('AVH Extended Category: Category Group'), $widget_ops);
533
+ add_action('wp_print_styles', array(&$this, 'actionWpPrintStyles'));
534
+
535
  }
536
 
537
  function WP_Widget_AVH_ExtendedCategories_Category_Group ()
541
 
542
  function actionWpPrintStyles ()
543
  {
544
+ if (! (FALSE === is_active_widget(FALSE, FALSE, $this->id_base, TRUE))) {
545
+ wp_register_style('avhec-widget', AVHEC_PLUGIN_URL . '/css/avh-ec.widget.css', array(), $this->core->version);
546
+ wp_enqueue_style('avhec-widget');
547
  }
548
  }
549
 
553
  * @param unknown_type $args
554
  * @param unknown_type $instance
555
  */
556
+ function widget ($args, $instance)
557
  {
558
  global $post;
559
+
560
+ $catgrp = & AVH_EC_Singleton::getInstance('AVH_EC_Category_Group');
561
  $options = $this->core->getOptions();
562
+
563
+ $row = array();
564
+
565
+ if (is_home()) {
566
+ $special_page = 'home_group';
567
  } elseif (is_category()) {
568
+ $special_page = 'category_group';
569
  } elseif (is_day()) {
570
+ $special_page = 'day_group';
571
  } elseif (is_month()) {
572
+ $special_page = 'month_group';
573
+ } elseif (is_year()) {
574
+ $special_page = 'year_group';
575
  } elseif (is_author()) {
576
+ $special_page = 'author_group';
577
  } elseif (is_search()) {
578
+ $special_page = 'search_group';
579
  } else {
580
+ $special_page = 'none';
581
  }
582
+
583
  $toDisplay = FALSE;
584
+ if ($special_page != 'none') {
585
  $sp_category_group = $options['sp_cat_group'][$special_page];
586
+ if (! ($this->getWidgetDoneCatGroup($sp_category_group))) {
587
+ $row = get_term_by('id', $sp_category_group, $catgrp->taxonomy_name); // Returns FALSE when non-existance. (empty(FALSE)=TRUE)
588
  $toDisplay = TRUE;
589
  }
590
  } else {
591
+ $terms = wp_get_object_terms($post->ID, $catgrp->taxonomy_name);
592
+ if (! empty($terms)) {
593
+ foreach ($terms as $key => $value) {
594
+ if (! ($this->getWidgetDoneCatGroup($value->term_id))) {
595
+ $row = $value;
596
  $toDisplay = TRUE;
597
  break;
598
  }
600
  } else {
601
  $options = $this->core->options;
602
  $no_cat_group = $options['cat_group']['no_group'];
603
+ $row = get_term_by('id', $no_cat_group, $catgrp->taxonomy_name);
604
  $toDisplay = TRUE;
605
  }
606
  }
607
+
608
  $selected_catgroups = unserialize($instance['post_group_category']);
609
  if (! (FALSE == $selected_catgroups || array_key_exists($row->term_id, $selected_catgroups))) {
610
  $toDisplay = FALSE;
611
  }
612
+
613
+ if ($toDisplay) {
614
+ extract($args);
615
+
616
  $c = $instance['count'] ? TRUE : FALSE;
617
  $e = $instance['hide_empty'] ? TRUE : FALSE;
618
  $h = $instance['hierarchical'] ? TRUE : FALSE;
621
  $o = $instance['sort_order'] ? $instance['sort_order'] : 'asc';
622
  $r = $instance['rssfeed'] ? 'RSS' : '';
623
  $i = $instance['rssimage'] ? $instance['rssimage'] : '';
624
+
625
+ if (empty($r)) {
626
  $i = '';
627
  }
628
+
629
+ $style = empty($instance['style']) ? 'list' : $instance['style'];
630
  $group_id = $row->term_id;
631
+ $cats = $catgrp->getCategoriesFromGroup($group_id);
632
+ if (empty($instance['title'])) {
633
+ $title = $catgrp->getWidgetTitleForGroup($group_id);
634
+ if (! $title) {
635
+ $title = __('Categories', 'avh-ec');
636
  }
637
  } else {
638
  $title = $instance['title'];
639
  }
640
+ $title = apply_filters('widget_title', $title);
641
+
642
+ $included_cats = implode(',', $cats);
643
+
644
+ $show_option_none = __('Select Category', 'avh-ec');
645
+ if ($options['general']['alternative_name_select_category']) {
646
  $show_option_none = $options['general']['alternative_name_select_category'];
647
  }
648
+
649
+ $cat_args = array('include'=>$included_cats, 'orderby'=>$s, 'order'=>$o, 'show_count'=>$c, 'use_desc_for_title'=>$use_desc_for_title, 'hide_empty'=>$e, 'hierarchical'=>$h, 'title_li'=>'', 'show_option_none'=>$show_option_none, 'feed'=>$r, 'feed_image'=>$i, 'name'=>'extended-categories-select-group-' . $this->number);
650
  echo $before_widget;
651
  echo $this->core->comment;
652
  echo $before_title . $title . $after_title;
653
+
654
+ if ($style == 'list') {
655
  echo '<ul>';
656
+ $this->core->avh_wp_list_categories($cat_args, TRUE);
657
  echo '</ul>';
658
  } else {
659
+ $this->core->avh_wp_dropdown_categories($cat_args, TRUE);
660
  echo '<script type=\'text/javascript\'>' . "\n";
661
  echo '/* <![CDATA[ */' . "\n";
662
  echo ' var ec_dropdown_' . $this->number . ' = document.getElementById("extended-categories-select-group-' . $this->number . '");' . "\n";
663
  echo ' function ec_onCatChange_' . $this->number . '() {' . "\n";
664
  echo ' if ( ec_dropdown_' . $this->number . '.options[ec_dropdown_' . $this->number . '.selectedIndex].value > 0 ) {' . "\n";
665
+ echo ' location.href = "' . get_option('home') . '/?cat="+ec_dropdown_' . $this->number . '.options[ec_dropdown_' . $this->number . '.selectedIndex].value;' . "\n";
666
  echo ' }' . "\n";
667
  echo ' }' . "\n";
668
  echo ' ec_dropdown_' . $this->number . '.onchange = ec_onCatChange_' . $this->number . ';' . "\n";
680
  * @param unknown_type $old_instance
681
  * @return unknown
682
  */
683
+ function update ($new_instance, $old_instance)
684
  {
685
  // update the instance's settings
686
+ if (! isset($new_instance['submit'])) {
687
  return FALSE;
688
  }
689
+
690
  $instance = $old_instance;
691
+
692
+ $instance['title'] = strip_tags(stripslashes($new_instance['title']));
693
  $instance['count'] = $new_instance['count'] ? TRUE : FALSE;
694
  $instance['hierarchical'] = $new_instance['hierarchical'] ? TRUE : FALSE;
695
  $instance['hide_empty'] = $new_instance['hide_empty'] ? TRUE : FALSE;
696
  $instance['use_desc_for_title'] = $new_instance['use_desc_for_title'] ? TRUE : FALSE;
697
+ $instance['sort_column'] = strip_tags(stripslashes($new_instance['sort_column']));
698
+ $instance['sort_order'] = strip_tags(stripslashes($new_instance['sort_order']));
699
+ $instance['style'] = strip_tags(stripslashes($new_instance['style']));
700
  $instance['rssfeed'] = $new_instance['rssfeed'] ? TRUE : FALSE;
701
+ $instance['rssimage'] = strip_tags(stripslashes($new_instance['rssimage']));
702
+ if (array_key_exists('all', $new_instance['post_group_category'])) {
703
  $instance['post_group_category'] = FALSE;
704
  } else {
705
+ $instance['post_group_category'] = serialize($new_instance['post_group_category']);
706
  }
707
  return $instance;
708
  }
712
  *
713
  * @param unknown_type $instance
714
  */
715
+ function form ($instance)
716
  {
717
  // displays the widget admin form
718
+ $instance = wp_parse_args((array) $instance, array('title'=>'', 'rssimage'=>''));
719
+
720
  // Prepare data for display
721
+ $title = esc_attr($instance['title']);
722
+ $count = (bool) $instance['count'];
723
+ $hierarchical = (bool) $instance['hierarchical'];
724
+ $hide_empty = (bool) $instance['hide_empty'];
725
+ $use_desc_for_title = (bool) $instance['use_desc_for_title'];
726
  $sort_id = ($instance['sort_column'] == 'ID') ? ' SELECTED' : '';
727
  $sort_name = ($instance['sort_column'] == 'name') ? ' SELECTED' : '';
728
  $sort_count = ($instance['sort_column'] == 'count') ? ' SELECTED' : '';
730
  $sort_order_d = ($instance['sort_order'] == 'desc') ? ' SELECTED' : '';
731
  $style_list = ($instance['style'] == 'list') ? ' SELECTED' : '';
732
  $style_drop = ($instance['style'] == 'drop') ? ' SELECTED' : '';
733
+ $rssfeed = (bool) $instance['rssfeed'];
734
+ $rssimage = esc_attr($instance['rssimage']);
735
+
736
+ $selected_cats = ($instance['post_group_category'] != '') ? unserialize($instance['post_group_category']) : FALSE;
737
+
738
  echo '<p>';
739
+ avh_doWidgetFormText($this->get_field_id('title'), $this->get_field_name('title'), __('Title', 'avh-ec'), $instance['title']);
740
  echo '</p>';
741
+
742
  echo '<p>';
743
+
744
+ avh_doWidgetFormCheckbox($this->get_field_id('count'), $this->get_field_name('count'), __('Show post counts', 'avh-ec'), (bool) $instance['count']);
745
+
746
+ avh_doWidgetFormCheckbox($this->get_field_id('hierarchical'), $this->get_field_name('hierarchical'), __('Show hierarchy', 'avh-ec'), (bool) $instance['hierarchical']);
747
+
748
+ avh_doWidgetFormCheckbox($this->get_field_id('hide_empty'), $this->get_field_name('hide_empty'), __('Hide empty categories', 'avh-ec'), (bool) $instance['hide_empty']);
749
+
750
+ 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']);
751
  echo '</p>';
752
+
753
  echo '<p>';
754
+ $options['ID'] = __('ID', 'avh-ec');
755
+ $options['name'] = __('Name', 'avh-ec');
756
+ $options['count'] = __('Count', 'avh-ec');
757
+ $options['slug'] = __('Slug', 'avh-ec');
758
+ avh_doWidgetFormSelect($this->get_field_id('sort_column'), $this->get_field_name('sort_column'), __('Sort by', 'avh-ec'), $options, $instance['sort_column']);
759
+ unset($options);
760
+
761
+ $options['asc'] = __('Ascending', 'avh-ec');
762
+ $options['desc'] = __('Descending', 'avh-ec');
763
+ avh_doWidgetFormSelect($this->get_field_id('sort_order'), $this->get_field_name('sort_order'), __('Sort order', 'avh-ec'), $options, $instance['sort_order']);
764
+ unset($options);
765
+
766
+ $options['list'] = __('List', 'avh-ec');
767
+ $options['drop'] = __('Drop down', 'avh-ec');
768
+ avh_doWidgetFormSelect($this->get_field_id('style'), $this->get_field_name('style'), __('Display style', 'avh-ec'), $options, $instance['style']);
769
+ unset($options);
770
  echo '</p>';
771
+
772
  echo '<p>';
773
+
774
+ avh_doWidgetFormCheckbox($this->get_field_id('rssfeed'), $this->get_field_name('rssfeed'), __('Show RSS Feed', 'avh-ec'), (bool) $instance['rssfeed']);
775
+
776
+ avh_doWidgetFormText($this->get_field_id('rssimage'), $this->get_field_name('rssimage'), __('Path (URI) to RSS image', 'avh-ec'), $instance['rssimage']);
777
  echo '</p>';
778
+
779
+ echo '<p>';
780
+ echo '<b>' . __('Select Groups', 'avh-ec') . '</b><hr />';
781
  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;">';
782
+ echo '<li id="' . $this->get_field_id('group_category--1') . '" class="popular-group_category">';
783
+ echo '<label for="' . $this->get_field_id('group_post_category') . '" class="selectit">';
784
+ echo '<input value="all" id="' . $this->get_field_id('group_post_category') . '" name="' . $this->get_field_name('post_group_category') . '[all]" type="checkbox" ' . (FALSE === $selected_cats ? ' CHECKED' : '') . '> ';
785
+ _e('Any Group', 'avh-ec');
786
  echo '</label>';
787
  echo '</li>';
788
  ob_start();
789
+ $this->avh_wp_group_category_checklist($selected_cats, $this->number);
790
  ob_end_flush();
791
  echo '</ul>';
792
  echo '</p>';
793
+
794
+ echo '<input type="hidden" id="' . $this->get_field_id('submit') . '" name="' . $this->get_field_name('submit') . '" value="1" />';
795
  }
796
 
797
+ function avh_wp_group_category_checklist ($selected_cats, $number)
798
  {
799
+
800
  $walker = new AVH_Walker_Category_Checklist();
801
  $walker->number = $number;
802
+ $walker->input_id = $this->get_field_id('post_group_category');
803
+ $walker->input_name = $this->get_field_name('post_group_category');
804
+ $walker->li_id = $this->get_field_id('group_category--1');
805
+
806
+ $args = array('taxonomy'=>'avhec_catgroup', 'descendants_and_self'=>0, 'selected_cats'=>array(), 'popular_cats'=>array(), 'walker'=>$walker, 'checked_ontop'=>true);
807
+
808
+ if (is_array($selected_cats))
 
 
 
 
 
809
  $args['selected_cats'] = $selected_cats;
810
  else
811
+ $args['selected_cats'] = array();
812
+
813
+ $categories = (array) get_terms($args['taxonomy'], array('get'=>'all'));
814
+
815
  // 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)
816
+ $checked_categories = array();
817
+ $keys = array_keys($categories);
818
+
819
+ foreach ($keys as $k) {
820
+ if (in_array($categories[$k]->term_id, $args['selected_cats'])) {
821
  $checked_categories[] = $categories[$k];
822
+ unset($categories[$k]);
823
  }
824
  }
825
+
826
  // Put checked cats on top
827
+ echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
828
  // Then the rest of them
829
+ echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
830
  }
831
 
832
+ function getWidgetDoneCatGroup ($id)
833
+ {
834
+ $catgrp = & AVH_EC_Singleton::getInstance('AVH_EC_Category_Group');
835
  if (is_array($catgrp->widget_done_catgroup) && array_key_exists($id, $catgrp->widget_done_catgroup)) {
836
  return TRUE;
837
  }
838
+ $catgrp->widget_done_catgroup[$id] = TRUE;
839
  return FALSE;
840
  }
841
  }
847
  class AVH_Walker_Category_Checklist extends Walker
848
  {
849
  var $tree_type = 'category';
850
+ var $db_fields = array('parent'=>'parent', 'id'=>'term_id'); //TODO: decouple this
851
  var $number;
852
  var $input_id;
853
  var $input_name;
854
  var $li_id;
855
 
856
+ function start_lvl (&$output, $depth, $args)
857
  {
858
+ $indent = str_repeat("\t", $depth);
859
  $output .= $indent . '<ul class="children">' . "\n";
860
  }
861
 
862
+ function end_lvl (&$output, $depth, $args)
863
  {
864
+ $indent = str_repeat("\t", $depth);
865
  $output .= $indent . '</ul>' . "\n";
866
  }
867
 
868
+ function start_el (&$output, $category, $depth, $args)
869
  {
870
+ extract($args);
871
  $input_id = $this->input_id . '-' . $category->term_id;
872
  $output .= "\n" . '<li id="' . $this->li_id . '">';
873
  $output .= '<label for="' . $input_id . '" class="selectit">';
874
+ $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>';
875
  }
876
 
877
+ function end_el (&$output, $category, $depth, $args)
878
  {
879
  $output .= "</li>\n";
880
  }
2.8/css/avh-ec.admin.css CHANGED
@@ -15,20 +15,42 @@ table.avhec-options {
15
  font-size: 11px;
16
  }
17
 
18
- #avhecBoxOptions option{
 
 
 
 
 
 
 
 
 
 
19
  padding: .5em;
20
  }
21
- .avhec-wrap span.description {
 
22
  font-size: 11px;
23
  }
24
 
25
- .avhec-wrap .b {
26
  font-weight: bold;
27
  }
28
 
 
 
 
 
 
 
 
 
 
 
29
  #avhec-options input {
30
  font-size: 11px;
31
  }
 
32
  #avhec-generaloptions input {
33
  font-size: 11px;
34
  }
@@ -49,17 +71,17 @@ table.avhec-options {
49
 
50
  /* Metabox in post and page */
51
  #post_avhec_category_group {
52
- width:100%;
53
  }
54
 
55
  #avhec-catlist {
56
- -moz-border-radius:4px 4px 4px 4px;
57
- background-color:#FFFFFF;
58
- border:1px solid #DFDFDF;
59
- height:20em;
60
- margin-bottom:-1.8em;
61
- overflow:auto;
62
- width:95%;
63
  }
64
 
65
  #avhec-catlist ul {
@@ -71,5 +93,5 @@ table.avhec-options {
71
  }
72
 
73
  #avhec-catlist li {
74
- margin-bottom: 0px;
75
  }
15
  font-size: 11px;
16
  }
17
 
18
+ .avhec-metabox-wrap {
19
+ font-size: 11px;
20
+ }
21
+
22
+ .avhec-metabox-wrap .p {
23
+ font-size: 11px;
24
+ line-height: 140%;
25
+ margin: 1em 0;
26
+ }
27
+
28
+ #avhecBoxOptions option {
29
  padding: .5em;
30
  }
31
+
32
+ .avhec-metabox-wrap span.description {
33
  font-size: 11px;
34
  }
35
 
36
+ .avhec-metabox-wrap .b {
37
  font-weight: bold;
38
  }
39
 
40
+ .avhec-metabox-wrap ul {
41
+ margin-bottom: 1em;
42
+ }
43
+
44
+ .avhec-metabox-wrap ul li {
45
+ line-height: 120%;
46
+ list-style: disc inside none;
47
+ margin-bottom: 0;
48
+ }
49
+
50
  #avhec-options input {
51
  font-size: 11px;
52
  }
53
+
54
  #avhec-generaloptions input {
55
  font-size: 11px;
56
  }
71
 
72
  /* Metabox in post and page */
73
  #post_avhec_category_group {
74
+ width: 100%;
75
  }
76
 
77
  #avhec-catlist {
78
+ -moz-border-radius: 4px 4px 4px 4px;
79
+ background-color: #FFFFFF;
80
+ border: 1px solid #DFDFDF;
81
+ height: 20em;
82
+ margin-bottom: -1.8em;
83
+ overflow: auto;
84
+ width: 95%;
85
  }
86
 
87
  #avhec-catlist ul {
93
  }
94
 
95
  #avhec-catlist li {
96
+ margin-bottom: 0px;
97
  }
2.8/css/avh-ec.widget.css CHANGED
@@ -1,5 +1,4 @@
1
  /* AVH Extended Categories Widget CSS */
2
-
3
  .avhec-widget-line {
4
  display: inline-block;
5
  }
1
  /* AVH Extended Categories Widget CSS */
 
2
  .avhec-widget-line {
3
  display: inline-block;
4
  }
2.8/helpers/avh-forms.php CHANGED
@@ -1,21 +1,21 @@
1
  <?php
2
- if ( ! function_exists( 'avh_doWidgetFormText' ) ) {
3
 
4
- function avh_doWidgetFormText ( $field_id, $field_name, $description, $value )
5
  {
6
  echo '<label for="' . $field_id . '">';
7
  echo $description;
8
- echo '<input class="widefat" id="' . $field_id . '" name="' . $field_name . '" type="text" value="' . esc_attr( $value ) . '" /> ';
9
  echo '</label>';
10
  echo '<br />';
11
  }
12
  }
13
 
14
- if ( ! function_exists( 'avh_doWidgetFormCheckbox' ) ) {
15
 
16
- function avh_doWidgetFormCheckbox ( $field_id, $field_name, $description, $is_checked = FALSE )
17
  {
18
-
19
  echo '<label for="' . $field_id . '">';
20
  echo '<input class="checkbox" type="checkbox" id="' . $field_id . '" name="' . $field_name . '"' . ($is_checked ? ' CHECKED' : '') . ' /> ';
21
  echo $description;
@@ -24,16 +24,16 @@ if ( ! function_exists( 'avh_doWidgetFormCheckbox' ) ) {
24
  }
25
  }
26
 
27
- if ( ! function_exists( 'avh_doWidgetFormSelect' ) ) {
28
 
29
- function avh_doWidgetFormSelect ( $field_id, $field_name, $description, $options, $selected_value )
30
  {
31
  echo '<label for="' . $field_id . '">';
32
  echo $description . ' ';
33
  echo '</label>';
34
-
35
  $data = '';
36
- foreach ( $options as $value => $text ) {
37
  $data .= '<option value="' . $value . '" ' . ($value == $selected_value ? "SELECTED" : '') . '>' . $text . '</option>' . "/n";
38
  }
39
  echo '<select id="' . $field_id . '" name="' . $field_name . '"> ';
1
  <?php
2
+ if (! function_exists('avh_doWidgetFormText')) {
3
 
4
+ function avh_doWidgetFormText ($field_id, $field_name, $description, $value)
5
  {
6
  echo '<label for="' . $field_id . '">';
7
  echo $description;
8
+ echo '<input class="widefat" id="' . $field_id . '" name="' . $field_name . '" type="text" value="' . esc_attr($value) . '" /> ';
9
  echo '</label>';
10
  echo '<br />';
11
  }
12
  }
13
 
14
+ if (! function_exists('avh_doWidgetFormCheckbox')) {
15
 
16
+ function avh_doWidgetFormCheckbox ($field_id, $field_name, $description, $is_checked = FALSE)
17
  {
18
+
19
  echo '<label for="' . $field_id . '">';
20
  echo '<input class="checkbox" type="checkbox" id="' . $field_id . '" name="' . $field_name . '"' . ($is_checked ? ' CHECKED' : '') . ' /> ';
21
  echo $description;
24
  }
25
  }
26
 
27
+ if (! function_exists('avh_doWidgetFormSelect')) {
28
 
29
+ function avh_doWidgetFormSelect ($field_id, $field_name, $description, $options, $selected_value)
30
  {
31
  echo '<label for="' . $field_id . '">';
32
  echo $description . ' ';
33
  echo '</label>';
34
+
35
  $data = '';
36
+ foreach ($options as $value => $text) {
37
  $data .= '<option value="' . $value . '" ' . ($value == $selected_value ? "SELECTED" : '') . '>' . $text . '</option>' . "/n";
38
  }
39
  echo '<select id="' . $field_id . '" name="' . $field_name . '"> ';
2.8/lang/{avh-ec_cs_CZ.mo → avh-ec-cs_CZ.mo} RENAMED
Binary file
2.8/lang/{avh-ec_el.mo → avh-ec-el.mo} RENAMED
Binary file
2.8/lang/{avh-ec_es_ES.mo → avh-ec-es_ES.mo} RENAMED
Binary file
2.8/lang/{avh-ec_id_ID.mo → avh-ec-id_ID.mo} RENAMED
Binary file
2.8/lang/avh-ec-it_IT.mo ADDED
Binary file
2.8/lang/{avh-ec_nl_NL.mo → avh-ec-nl_NL.mo} RENAMED
Binary file
2.8/lang/{avh-ec_ru_RU.mo → avh-ec-ru_RU.mo} RENAMED
Binary file
2.8/lang/{avh-ec_sv_SE.mo → avh-ec-sv_SE.mo} RENAMED
Binary file
2.8/lang/{avh-ec_tr.mo → avh-ec-tr.mo} RENAMED
Binary file
2.8/lang/avh-ec.mo CHANGED
Binary file
2.8/lang/avh-ec.po CHANGED
@@ -2,7 +2,7 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: AVH Extended Categories\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2011-02-10 21:37-0500\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: Peter van der Does <peter@avirtualhome.com>\n"
8
  "Language-Team: \n"
@@ -67,15 +67,21 @@ msgid "Alternative text for Select Category."
67
  msgstr ""
68
 
69
  #: ../class/avh-ec.admin.php:240
70
- msgid "Select which group to show on the home page.<br />Selecting the group 'none' will not show the widget on the page."
71
  msgstr ""
72
 
 
73
  #: ../class/avh-ec.admin.php:241
74
- msgid "Select which group to show when there is no group associated with the post.<br />Selecting the group 'none' will not show the widget on the page."
 
 
 
 
 
75
  msgstr ""
76
 
77
  #: ../class/avh-ec.admin.php:242
78
- msgid "Select which group will be the default group when editing a post.<br />Selecting the group 'none' will not show the widget on the page."
79
  msgstr ""
80
 
81
  #: ../class/avh-ec.admin.php:278
@@ -229,44 +235,238 @@ msgstr ""
229
  msgid "Translation"
230
  msgstr ""
231
 
232
- #: ../class/avh-ec.admin.php:842
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  msgid "Settings"
234
  msgstr ""
235
 
236
- #: ../class/avh-ec.admin.php:857
237
  #: ../class/avh-ec.widgets.php:216
238
  #: ../class/avh-ec.widgets.php:487
239
  #: ../class/avh-ec.widgets.php:760
240
  msgid "Name"
241
  msgstr ""
242
 
243
- #: ../class/avh-ec.admin.php:857
244
  msgid "Widget Title"
245
  msgstr ""
246
 
247
- #: ../class/avh-ec.admin.php:857
248
  msgid "Description"
249
  msgstr ""
250
 
251
- #: ../class/avh-ec.admin.php:857
252
  msgid "Categories in the group"
253
  msgstr ""
254
 
255
- #: ../class/avh-ec.admin.php:874
256
  #, php-format
257
  msgid "Your attempt to delete this group: &#8220;%s&#8221; has failed."
258
  msgstr ""
259
 
260
- #: ../class/avh-ec.admin.php:936
261
  #, php-format
262
  msgid "Edit &#8220;%s&#8221;"
263
  msgstr ""
264
 
265
- #: ../class/avh-ec.admin.php:938
266
  msgid "Edit"
267
  msgstr ""
268
 
269
- #: ../class/avh-ec.admin.php:943
270
  msgid "Delete"
271
  msgstr ""
272
 
@@ -322,24 +522,24 @@ msgstr ""
322
  msgid "This group will be shown on the front page."
323
  msgstr ""
324
 
325
- #: ../class/avh-ec.core.php:373
326
  #: ../class/avh-ec.widgets.php:80
327
  #: ../class/avh-ec.widgets.php:364
328
  #: ../class/avh-ec.widgets.php:640
329
  msgid "Categories"
330
  msgstr ""
331
 
332
- #: ../class/avh-ec.core.php:404
333
- #: ../class/avh-ec.core.php:406
334
  msgid "No categories"
335
  msgstr ""
336
 
337
- #: ../class/avh-ec.core.php:615
338
  #, php-format
339
  msgid "View all posts filed under %s"
340
  msgstr ""
341
 
342
- #: ../class/avh-ec.core.php:630
343
  #, php-format
344
  msgid "Feed for all posts filed under %s"
345
  msgstr ""
2
  msgstr ""
3
  "Project-Id-Version: AVH Extended Categories\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-02-13 22:02-0500\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: Peter van der Does <peter@avirtualhome.com>\n"
8
  "Language-Team: \n"
67
  msgstr ""
68
 
69
  #: ../class/avh-ec.admin.php:240
70
+ msgid "Select which group to show on the home page."
71
  msgstr ""
72
 
73
+ #: ../class/avh-ec.admin.php:240
74
  #: ../class/avh-ec.admin.php:241
75
+ #: ../class/avh-ec.admin.php:242
76
+ msgid "Selecting the group 'none' will not show the widget on the page."
77
+ msgstr ""
78
+
79
+ #: ../class/avh-ec.admin.php:241
80
+ msgid "Select which group to show when there is no group associated with the post."
81
  msgstr ""
82
 
83
  #: ../class/avh-ec.admin.php:242
84
+ msgid "Select which group will be the default group when editing a post."
85
  msgstr ""
86
 
87
  #: ../class/avh-ec.admin.php:278
235
  msgid "Translation"
236
  msgstr ""
237
 
238
+ #: ../class/avh-ec.admin.php:727
239
+ msgid "This plugin is translated in several languages. Some of the languages might be incomplete. Please help to complete these translations or add a new language."
240
+ msgstr ""
241
+
242
+ #: ../class/avh-ec.admin.php:728
243
+ msgid "You can visit "
244
+ msgstr ""
245
+
246
+ #: ../class/avh-ec.admin.php:728
247
+ msgid "to help complete these translations or add a new language."
248
+ msgstr ""
249
+
250
+ #: ../class/avh-ec.admin.php:732
251
+ msgid "Available Languages"
252
+ msgstr ""
253
+
254
+ #: ../class/avh-ec.admin.php:747
255
+ msgid "More information about translating can found at http://codex.wordpress.org/Translating_WordPress . This page is dedicated for translating WordPress but the instructions are the same for this plugin."
256
+ msgstr ""
257
+
258
+ #: ../class/avh-ec.admin.php:759
259
+ msgid "If you enjoy this plug-in please consider a donation. There are several ways you can show your appreciation."
260
+ msgstr ""
261
+
262
+ #: ../class/avh-ec.admin.php:764
263
+ msgid "If you decide to buy something from Amazon click the button."
264
+ msgstr ""
265
+
266
+ #: ../class/avh-ec.admin.php:769
267
+ msgid "You can send me something from my "
268
+ msgstr ""
269
+
270
+ #: ../class/avh-ec.admin.php:769
271
+ msgid "Amazon Wish List"
272
+ msgstr ""
273
+
274
+ #: ../class/avh-ec.admin.php:773
275
+ msgid "Through Paypal."
276
+ msgstr ""
277
+
278
+ #: ../class/avh-ec.admin.php:774
279
+ msgid "Click on the Donate button and you will be directed to Paypal where you can make your donation and you don't need to have a Paypal account to make a donation."
280
+ msgstr ""
281
+
282
+ #: ../class/avh-ec.admin.php:789
283
+ msgid "What about support?"
284
+ msgstr ""
285
+
286
+ #: ../class/avh-ec.admin.php:790
287
+ msgid "I created a support site at http://forums.avirtualhome.com where you can ask questions or request features."
288
+ msgstr ""
289
+
290
+ #: ../class/avh-ec.admin.php:794
291
+ msgid "What is depth selection?"
292
+ msgstr ""
293
+
294
+ #: ../class/avh-ec.admin.php:795
295
+ msgid "Starting with version 2.0 and WordPress 2.8 you can select how many levels deep you want to show your categories. This option only works when you select Show Hierarchy as well."
296
+ msgstr ""
297
+
298
+ #: ../class/avh-ec.admin.php:796
299
+ msgid "Here is how it works: Say you have 5 top level categories and each top level has a number of children. You could manually select all the Top Level categories you want to show but now you can do the following:"
300
+ msgstr ""
301
+
302
+ #: ../class/avh-ec.admin.php:797
303
+ msgid "You select to display all categories, select to Show hierarchy and select how many levels you want to show, in this case Toplevel only."
304
+ msgstr ""
305
+
306
+ #: ../class/avh-ec.admin.php:801
307
+ msgid "Multiple Category Groups"
308
+ msgstr ""
309
+
310
+ #: ../class/avh-ec.admin.php:802
311
+ msgid "The following is an explanation how assigning multiple groups to page/post works."
312
+ msgstr ""
313
+
314
+ #: ../class/avh-ec.admin.php:803
315
+ msgid "Lets say you have the following groups:"
316
+ msgstr ""
317
+
318
+ #: ../class/avh-ec.admin.php:805
319
+ msgid "Free Time"
320
+ msgstr ""
321
+
322
+ #: ../class/avh-ec.admin.php:806
323
+ msgid "Theater"
324
+ msgstr ""
325
+
326
+ #: ../class/avh-ec.admin.php:807
327
+ msgid "Movie"
328
+ msgstr ""
329
+
330
+ #: ../class/avh-ec.admin.php:808
331
+ msgid "Music"
332
+ msgstr ""
333
+
334
+ #: ../class/avh-ec.admin.php:811
335
+ msgid "Setup several Category Group widgets and associated each widget with one or more groups."
336
+ msgstr ""
337
+
338
+ #: ../class/avh-ec.admin.php:812
339
+ msgid "Widget 1 has association with Free Time"
340
+ msgstr ""
341
+
342
+ #: ../class/avh-ec.admin.php:813
343
+ msgid "Widget 2 has association with Theater, Movie and Music"
344
+ msgstr ""
345
+
346
+ #: ../class/avh-ec.admin.php:814
347
+ msgid "Widget 3 has association with Theater, Movie and Music"
348
+ msgstr ""
349
+
350
+ #: ../class/avh-ec.admin.php:816
351
+ msgid "Page has associations the groups Free Time and Theater"
352
+ msgstr ""
353
+
354
+ #: ../class/avh-ec.admin.php:818
355
+ #: ../class/avh-ec.admin.php:832
356
+ msgid "Widget 1: Shows categories of the Free Time group"
357
+ msgstr ""
358
+
359
+ #: ../class/avh-ec.admin.php:819
360
+ msgid "Widget 2: Shows categories of the Theater group."
361
+ msgstr ""
362
+
363
+ #: ../class/avh-ec.admin.php:820
364
+ #: ../class/avh-ec.admin.php:827
365
+ msgid "Widget 3: Not displayed"
366
+ msgstr ""
367
+
368
+ #: ../class/avh-ec.admin.php:823
369
+ msgid "Page has associations the group Movie."
370
+ msgstr ""
371
+
372
+ #: ../class/avh-ec.admin.php:825
373
+ msgid "Widget 1: Not displayed"
374
+ msgstr ""
375
+
376
+ #: ../class/avh-ec.admin.php:826
377
+ msgid "Widget 2: Shows categories of the Movie group."
378
+ msgstr ""
379
+
380
+ #: ../class/avh-ec.admin.php:830
381
+ msgid "Page has associations the groups Free Time, Movie and Music"
382
+ msgstr ""
383
+
384
+ #: ../class/avh-ec.admin.php:833
385
+ msgid "Widget 2: Shows categories of the Movie or Music group."
386
+ msgstr ""
387
+
388
+ #: ../class/avh-ec.admin.php:834
389
+ msgid "Widget 3: Shows categories of the Music or Movie group."
390
+ msgstr ""
391
+
392
+ #: ../class/avh-ec.admin.php:837
393
+ msgid "Whether Widget 2 shows Movie or Music depends on the creation order of groups. If Widget 2 shows Movie, Widget 3 will show Music but if Widget 2 shows Music, Widget 3 will show Movie."
394
+ msgstr ""
395
+
396
+ #: ../class/avh-ec.admin.php:846
397
+ msgid "PHP4 Support"
398
+ msgstr ""
399
+
400
+ #: ../class/avh-ec.admin.php:847
401
+ msgid "The next major release of the plugin will no longer support PHP4."
402
+ msgstr ""
403
+
404
+ #: ../class/avh-ec.admin.php:848
405
+ msgid "It will be written for PHP 5.2 and "
406
+ msgstr ""
407
+
408
+ #: ../class/avh-ec.admin.php:850
409
+ msgid "your blog already runs the needed PHP version. When the new release comes out you can safely update."
410
+ msgstr ""
411
+
412
+ #: ../class/avh-ec.admin.php:852
413
+ msgid "your blog still runs PHP4. When the new release comes out you can not use it."
414
+ msgstr ""
415
+
416
+ #: ../class/avh-ec.admin.php:853
417
+ msgid "I don't have a timeline for the next version but consider contacting your host if PHP 5.2 is available."
418
+ msgstr ""
419
+
420
+ #: ../class/avh-ec.admin.php:854
421
+ msgid "If your hosts doesn't offer PHP 5.2 you might want to consider switching hosts."
422
+ msgstr ""
423
+
424
+ #: ../class/avh-ec.admin.php:855
425
+ msgid "A host to consider is "
426
+ msgstr ""
427
+
428
+ #: ../class/avh-ec.admin.php:856
429
+ msgid "I run my personal blog there and I am very happy with their services. You can get an account with unlimited bandwidth, storage and much more for a low price."
430
+ msgstr ""
431
+
432
+ #: ../class/avh-ec.admin.php:899
433
  msgid "Settings"
434
  msgstr ""
435
 
436
+ #: ../class/avh-ec.admin.php:914
437
  #: ../class/avh-ec.widgets.php:216
438
  #: ../class/avh-ec.widgets.php:487
439
  #: ../class/avh-ec.widgets.php:760
440
  msgid "Name"
441
  msgstr ""
442
 
443
+ #: ../class/avh-ec.admin.php:914
444
  msgid "Widget Title"
445
  msgstr ""
446
 
447
+ #: ../class/avh-ec.admin.php:914
448
  msgid "Description"
449
  msgstr ""
450
 
451
+ #: ../class/avh-ec.admin.php:914
452
  msgid "Categories in the group"
453
  msgstr ""
454
 
455
+ #: ../class/avh-ec.admin.php:931
456
  #, php-format
457
  msgid "Your attempt to delete this group: &#8220;%s&#8221; has failed."
458
  msgstr ""
459
 
460
+ #: ../class/avh-ec.admin.php:993
461
  #, php-format
462
  msgid "Edit &#8220;%s&#8221;"
463
  msgstr ""
464
 
465
+ #: ../class/avh-ec.admin.php:995
466
  msgid "Edit"
467
  msgstr ""
468
 
469
+ #: ../class/avh-ec.admin.php:1000
470
  msgid "Delete"
471
  msgstr ""
472
 
522
  msgid "This group will be shown on the front page."
523
  msgstr ""
524
 
525
+ #: ../class/avh-ec.core.php:374
526
  #: ../class/avh-ec.widgets.php:80
527
  #: ../class/avh-ec.widgets.php:364
528
  #: ../class/avh-ec.widgets.php:640
529
  msgid "Categories"
530
  msgstr ""
531
 
532
+ #: ../class/avh-ec.core.php:405
533
+ #: ../class/avh-ec.core.php:407
534
  msgid "No categories"
535
  msgstr ""
536
 
537
+ #: ../class/avh-ec.core.php:616
538
  #, php-format
539
  msgid "View all posts filed under %s"
540
  msgstr ""
541
 
542
+ #: ../class/avh-ec.core.php:631
543
  #, php-format
544
  msgid "Feed for all posts filed under %s"
545
  msgstr ""
2.8/lang/avh-ec.pot CHANGED
@@ -2,7 +2,7 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: AVH Extended Categories\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2011-02-10 21:37-0500\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: Peter van der Does <peter@avirtualhome.com>\n"
8
  "Language-Team: \n"
@@ -67,15 +67,21 @@ msgid "Alternative text for Select Category."
67
  msgstr ""
68
 
69
  #: ../class/avh-ec.admin.php:240
70
- msgid "Select which group to show on the home page.<br />Selecting the group 'none' will not show the widget on the page."
71
  msgstr ""
72
 
 
73
  #: ../class/avh-ec.admin.php:241
74
- msgid "Select which group to show when there is no group associated with the post.<br />Selecting the group 'none' will not show the widget on the page."
 
 
 
 
 
75
  msgstr ""
76
 
77
  #: ../class/avh-ec.admin.php:242
78
- msgid "Select which group will be the default group when editing a post.<br />Selecting the group 'none' will not show the widget on the page."
79
  msgstr ""
80
 
81
  #: ../class/avh-ec.admin.php:278
@@ -229,44 +235,238 @@ msgstr ""
229
  msgid "Translation"
230
  msgstr ""
231
 
232
- #: ../class/avh-ec.admin.php:842
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  msgid "Settings"
234
  msgstr ""
235
 
236
- #: ../class/avh-ec.admin.php:857
237
  #: ../class/avh-ec.widgets.php:216
238
  #: ../class/avh-ec.widgets.php:487
239
  #: ../class/avh-ec.widgets.php:760
240
  msgid "Name"
241
  msgstr ""
242
 
243
- #: ../class/avh-ec.admin.php:857
244
  msgid "Widget Title"
245
  msgstr ""
246
 
247
- #: ../class/avh-ec.admin.php:857
248
  msgid "Description"
249
  msgstr ""
250
 
251
- #: ../class/avh-ec.admin.php:857
252
  msgid "Categories in the group"
253
  msgstr ""
254
 
255
- #: ../class/avh-ec.admin.php:874
256
  #, php-format
257
  msgid "Your attempt to delete this group: &#8220;%s&#8221; has failed."
258
  msgstr ""
259
 
260
- #: ../class/avh-ec.admin.php:936
261
  #, php-format
262
  msgid "Edit &#8220;%s&#8221;"
263
  msgstr ""
264
 
265
- #: ../class/avh-ec.admin.php:938
266
  msgid "Edit"
267
  msgstr ""
268
 
269
- #: ../class/avh-ec.admin.php:943
270
  msgid "Delete"
271
  msgstr ""
272
 
@@ -322,24 +522,24 @@ msgstr ""
322
  msgid "This group will be shown on the front page."
323
  msgstr ""
324
 
325
- #: ../class/avh-ec.core.php:373
326
  #: ../class/avh-ec.widgets.php:80
327
  #: ../class/avh-ec.widgets.php:364
328
  #: ../class/avh-ec.widgets.php:640
329
  msgid "Categories"
330
  msgstr ""
331
 
332
- #: ../class/avh-ec.core.php:404
333
- #: ../class/avh-ec.core.php:406
334
  msgid "No categories"
335
  msgstr ""
336
 
337
- #: ../class/avh-ec.core.php:615
338
  #, php-format
339
  msgid "View all posts filed under %s"
340
  msgstr ""
341
 
342
- #: ../class/avh-ec.core.php:630
343
  #, php-format
344
  msgid "Feed for all posts filed under %s"
345
  msgstr ""
2
  msgstr ""
3
  "Project-Id-Version: AVH Extended Categories\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2011-02-13 22:02-0500\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: Peter van der Does <peter@avirtualhome.com>\n"
8
  "Language-Team: \n"
67
  msgstr ""
68
 
69
  #: ../class/avh-ec.admin.php:240
70
+ msgid "Select which group to show on the home page."
71
  msgstr ""
72
 
73
+ #: ../class/avh-ec.admin.php:240
74
  #: ../class/avh-ec.admin.php:241
75
+ #: ../class/avh-ec.admin.php:242
76
+ msgid "Selecting the group 'none' will not show the widget on the page."
77
+ msgstr ""
78
+
79
+ #: ../class/avh-ec.admin.php:241
80
+ msgid "Select which group to show when there is no group associated with the post."
81
  msgstr ""
82
 
83
  #: ../class/avh-ec.admin.php:242
84
+ msgid "Select which group will be the default group when editing a post."
85
  msgstr ""
86
 
87
  #: ../class/avh-ec.admin.php:278
235
  msgid "Translation"
236
  msgstr ""
237
 
238
+ #: ../class/avh-ec.admin.php:727
239
+ msgid "This plugin is translated in several languages. Some of the languages might be incomplete. Please help to complete these translations or add a new language."
240
+ msgstr ""
241
+
242
+ #: ../class/avh-ec.admin.php:728
243
+ msgid "You can visit "
244
+ msgstr ""
245
+
246
+ #: ../class/avh-ec.admin.php:728
247
+ msgid "to help complete these translations or add a new language."
248
+ msgstr ""
249
+
250
+ #: ../class/avh-ec.admin.php:732
251
+ msgid "Available Languages"
252
+ msgstr ""
253
+
254
+ #: ../class/avh-ec.admin.php:747
255
+ msgid "More information about translating can found at http://codex.wordpress.org/Translating_WordPress . This page is dedicated for translating WordPress but the instructions are the same for this plugin."
256
+ msgstr ""
257
+
258
+ #: ../class/avh-ec.admin.php:759
259
+ msgid "If you enjoy this plug-in please consider a donation. There are several ways you can show your appreciation."
260
+ msgstr ""
261
+
262
+ #: ../class/avh-ec.admin.php:764
263
+ msgid "If you decide to buy something from Amazon click the button."
264
+ msgstr ""
265
+
266
+ #: ../class/avh-ec.admin.php:769
267
+ msgid "You can send me something from my "
268
+ msgstr ""
269
+
270
+ #: ../class/avh-ec.admin.php:769
271
+ msgid "Amazon Wish List"
272
+ msgstr ""
273
+
274
+ #: ../class/avh-ec.admin.php:773
275
+ msgid "Through Paypal."
276
+ msgstr ""
277
+
278
+ #: ../class/avh-ec.admin.php:774
279
+ msgid "Click on the Donate button and you will be directed to Paypal where you can make your donation and you don't need to have a Paypal account to make a donation."
280
+ msgstr ""
281
+
282
+ #: ../class/avh-ec.admin.php:789
283
+ msgid "What about support?"
284
+ msgstr ""
285
+
286
+ #: ../class/avh-ec.admin.php:790
287
+ msgid "I created a support site at http://forums.avirtualhome.com where you can ask questions or request features."
288
+ msgstr ""
289
+
290
+ #: ../class/avh-ec.admin.php:794
291
+ msgid "What is depth selection?"
292
+ msgstr ""
293
+
294
+ #: ../class/avh-ec.admin.php:795
295
+ msgid "Starting with version 2.0 and WordPress 2.8 you can select how many levels deep you want to show your categories. This option only works when you select Show Hierarchy as well."
296
+ msgstr ""
297
+
298
+ #: ../class/avh-ec.admin.php:796
299
+ msgid "Here is how it works: Say you have 5 top level categories and each top level has a number of children. You could manually select all the Top Level categories you want to show but now you can do the following:"
300
+ msgstr ""
301
+
302
+ #: ../class/avh-ec.admin.php:797
303
+ msgid "You select to display all categories, select to Show hierarchy and select how many levels you want to show, in this case Toplevel only."
304
+ msgstr ""
305
+
306
+ #: ../class/avh-ec.admin.php:801
307
+ msgid "Multiple Category Groups"
308
+ msgstr ""
309
+
310
+ #: ../class/avh-ec.admin.php:802
311
+ msgid "The following is an explanation how assigning multiple groups to page/post works."
312
+ msgstr ""
313
+
314
+ #: ../class/avh-ec.admin.php:803
315
+ msgid "Lets say you have the following groups:"
316
+ msgstr ""
317
+
318
+ #: ../class/avh-ec.admin.php:805
319
+ msgid "Free Time"
320
+ msgstr ""
321
+
322
+ #: ../class/avh-ec.admin.php:806
323
+ msgid "Theater"
324
+ msgstr ""
325
+
326
+ #: ../class/avh-ec.admin.php:807
327
+ msgid "Movie"
328
+ msgstr ""
329
+
330
+ #: ../class/avh-ec.admin.php:808
331
+ msgid "Music"
332
+ msgstr ""
333
+
334
+ #: ../class/avh-ec.admin.php:811
335
+ msgid "Setup several Category Group widgets and associated each widget with one or more groups."
336
+ msgstr ""
337
+
338
+ #: ../class/avh-ec.admin.php:812
339
+ msgid "Widget 1 has association with Free Time"
340
+ msgstr ""
341
+
342
+ #: ../class/avh-ec.admin.php:813
343
+ msgid "Widget 2 has association with Theater, Movie and Music"
344
+ msgstr ""
345
+
346
+ #: ../class/avh-ec.admin.php:814
347
+ msgid "Widget 3 has association with Theater, Movie and Music"
348
+ msgstr ""
349
+
350
+ #: ../class/avh-ec.admin.php:816
351
+ msgid "Page has associations the groups Free Time and Theater"
352
+ msgstr ""
353
+
354
+ #: ../class/avh-ec.admin.php:818
355
+ #: ../class/avh-ec.admin.php:832
356
+ msgid "Widget 1: Shows categories of the Free Time group"
357
+ msgstr ""
358
+
359
+ #: ../class/avh-ec.admin.php:819
360
+ msgid "Widget 2: Shows categories of the Theater group."
361
+ msgstr ""
362
+
363
+ #: ../class/avh-ec.admin.php:820
364
+ #: ../class/avh-ec.admin.php:827
365
+ msgid "Widget 3: Not displayed"
366
+ msgstr ""
367
+
368
+ #: ../class/avh-ec.admin.php:823
369
+ msgid "Page has associations the group Movie."
370
+ msgstr ""
371
+
372
+ #: ../class/avh-ec.admin.php:825
373
+ msgid "Widget 1: Not displayed"
374
+ msgstr ""
375
+
376
+ #: ../class/avh-ec.admin.php:826
377
+ msgid "Widget 2: Shows categories of the Movie group."
378
+ msgstr ""
379
+
380
+ #: ../class/avh-ec.admin.php:830
381
+ msgid "Page has associations the groups Free Time, Movie and Music"
382
+ msgstr ""
383
+
384
+ #: ../class/avh-ec.admin.php:833
385
+ msgid "Widget 2: Shows categories of the Movie or Music group."
386
+ msgstr ""
387
+
388
+ #: ../class/avh-ec.admin.php:834
389
+ msgid "Widget 3: Shows categories of the Music or Movie group."
390
+ msgstr ""
391
+
392
+ #: ../class/avh-ec.admin.php:837
393
+ msgid "Whether Widget 2 shows Movie or Music depends on the creation order of groups. If Widget 2 shows Movie, Widget 3 will show Music but if Widget 2 shows Music, Widget 3 will show Movie."
394
+ msgstr ""
395
+
396
+ #: ../class/avh-ec.admin.php:846
397
+ msgid "PHP4 Support"
398
+ msgstr ""
399
+
400
+ #: ../class/avh-ec.admin.php:847
401
+ msgid "The next major release of the plugin will no longer support PHP4."
402
+ msgstr ""
403
+
404
+ #: ../class/avh-ec.admin.php:848
405
+ msgid "It will be written for PHP 5.2 and "
406
+ msgstr ""
407
+
408
+ #: ../class/avh-ec.admin.php:850
409
+ msgid "your blog already runs the needed PHP version. When the new release comes out you can safely update."
410
+ msgstr ""
411
+
412
+ #: ../class/avh-ec.admin.php:852
413
+ msgid "your blog still runs PHP4. When the new release comes out you can not use it."
414
+ msgstr ""
415
+
416
+ #: ../class/avh-ec.admin.php:853
417
+ msgid "I don't have a timeline for the next version but consider contacting your host if PHP 5.2 is available."
418
+ msgstr ""
419
+
420
+ #: ../class/avh-ec.admin.php:854
421
+ msgid "If your hosts doesn't offer PHP 5.2 you might want to consider switching hosts."
422
+ msgstr ""
423
+
424
+ #: ../class/avh-ec.admin.php:855
425
+ msgid "A host to consider is "
426
+ msgstr ""
427
+
428
+ #: ../class/avh-ec.admin.php:856
429
+ msgid "I run my personal blog there and I am very happy with their services. You can get an account with unlimited bandwidth, storage and much more for a low price."
430
+ msgstr ""
431
+
432
+ #: ../class/avh-ec.admin.php:899
433
  msgid "Settings"
434
  msgstr ""
435
 
436
+ #: ../class/avh-ec.admin.php:914
437
  #: ../class/avh-ec.widgets.php:216
438
  #: ../class/avh-ec.widgets.php:487
439
  #: ../class/avh-ec.widgets.php:760
440
  msgid "Name"
441
  msgstr ""
442
 
443
+ #: ../class/avh-ec.admin.php:914
444
  msgid "Widget Title"
445
  msgstr ""
446
 
447
+ #: ../class/avh-ec.admin.php:914
448
  msgid "Description"
449
  msgstr ""
450
 
451
+ #: ../class/avh-ec.admin.php:914
452
  msgid "Categories in the group"
453
  msgstr ""
454
 
455
+ #: ../class/avh-ec.admin.php:931
456
  #, php-format
457
  msgid "Your attempt to delete this group: &#8220;%s&#8221; has failed."
458
  msgstr ""
459
 
460
+ #: ../class/avh-ec.admin.php:993
461
  #, php-format
462
  msgid "Edit &#8220;%s&#8221;"
463
  msgstr ""
464
 
465
+ #: ../class/avh-ec.admin.php:995
466
  msgid "Edit"
467
  msgstr ""
468
 
469
+ #: ../class/avh-ec.admin.php:1000
470
  msgid "Delete"
471
  msgstr ""
472
 
522
  msgid "This group will be shown on the front page."
523
  msgstr ""
524
 
525
+ #: ../class/avh-ec.core.php:374
526
  #: ../class/avh-ec.widgets.php:80
527
  #: ../class/avh-ec.widgets.php:364
528
  #: ../class/avh-ec.widgets.php:640
529
  msgid "Categories"
530
  msgstr ""
531
 
532
+ #: ../class/avh-ec.core.php:405
533
+ #: ../class/avh-ec.core.php:407
534
  msgid "No categories"
535
  msgstr ""
536
 
537
+ #: ../class/avh-ec.core.php:616
538
  #, php-format
539
  msgid "View all posts filed under %s"
540
  msgstr ""
541
 
542
+ #: ../class/avh-ec.core.php:631
543
  #, php-format
544
  msgid "Feed for all posts filed under %s"
545
  msgstr ""
2.8/lang/avh-ec_it_IT.mo DELETED
Binary file
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: 3.0.5
7
- Stable tag: 3.3.2
8
 
9
  The AVH Extended Categories Widgets gives you three widgets for displaying categories.
10
  == Description ==
@@ -114,18 +114,18 @@ Widget 3 has association with Theater, Movie and Music
114
 
115
  Page has associations the groups Free Time and Theater
116
  * Widget 1: Shows categories of the Free Time group
117
- * Widget 2 :Shows categories of the Theater group.
118
  * Widget 3: Not displayed
119
 
120
  Page has associations the group Movie.
121
  * Widget 1: Not displayed
122
- * Widget 2 :Shows categories of the Movie group.
123
  * Widget 3: Not displayed
124
 
125
 
126
  Page has associations the groups Free Time, Movie and Music
127
  * Widget 1: Shows categories of the Free Time group
128
- * Widget 2 :Shows categories of the Movie or Music group.
129
  * Widget 3: Shows categories of the Music or Movie group.
130
  Whether Widget 2 shows Movie or Music depends on the creation order of groups. If Widget 2 shows Movie, Widget 3 will show Music but if Widget 2 shows Music, Widget 3 will show Movie.
131
 
@@ -133,6 +133,10 @@ Whether Widget 2 shows Movie or Music depends on the creation order of groups. I
133
  None
134
 
135
  == Changelog ==
 
 
 
 
136
  = Version 3.3.2 =
137
  * Added several new localizations.
138
  * Bugfix: When using multiple Category Group widgets, all of them would show up on the special pages instead of just the one selected in the options.
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.1
7
+ Stable tag: 3.3.3
8
 
9
  The AVH Extended Categories Widgets gives you three widgets for displaying categories.
10
  == Description ==
114
 
115
  Page has associations the groups Free Time and Theater
116
  * Widget 1: Shows categories of the Free Time group
117
+ * Widget 2: Shows categories of the Theater group.
118
  * Widget 3: Not displayed
119
 
120
  Page has associations the group Movie.
121
  * Widget 1: Not displayed
122
+ * Widget 2: Shows categories of the Movie group.
123
  * Widget 3: Not displayed
124
 
125
 
126
  Page has associations the groups Free Time, Movie and Music
127
  * Widget 1: Shows categories of the Free Time group
128
+ * Widget 2: Shows categories of the Movie or Music group.
129
  * Widget 3: Shows categories of the Music or Movie group.
130
  Whether Widget 2 shows Movie or Music depends on the creation order of groups. If Widget 2 shows Movie, Widget 3 will show Music but if Widget 2 shows Music, Widget 3 will show Movie.
131
 
133
  None
134
 
135
  == Changelog ==
136
+ = Version 3.3.3 =
137
+ * RFC: Changed selecting Category groups in posts from tag-like to checkboxes.
138
+ * Removed the Menu item Category groups under Posts and Pages.
139
+
140
  = Version 3.3.2 =
141
  * Added several new localizations.
142
  * Bugfix: When using multiple Category Group widgets, all of them would show up on the special pages instead of just the one selected in the options.
uninstall.php CHANGED
@@ -3,12 +3,12 @@
3
  // Because the plugin is already deactivated it won't regonize any class declarations.
4
 
5
 
6
- if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) )
7
  exit();
8
 
9
  global $wpdb;
10
- if ( 'extended-categories-widget' == dirname( $file )) {
11
- delete_option( 'avhec' );
12
  $db__used_by_plugin = $wpdb->prefix . 'avhec_category_groups';
13
- $result = $wpdb->query( 'DROP TABLE IF EXISTS `'. $db__used_by_plugin.'`' );
14
  }
3
  // Because the plugin is already deactivated it won't regonize any class declarations.
4
 
5
 
6
+ if (! defined('ABSPATH') && ! defined('WP_UNINSTALL_PLUGIN'))
7
  exit();
8
 
9
  global $wpdb;
10
+ if ('extended-categories-widget' == dirname($file)) {
11
+ delete_option('avhec');
12
  $db__used_by_plugin = $wpdb->prefix . 'avhec_category_groups';
13
+ $result = $wpdb->query('DROP TABLE IF EXISTS `' . $db__used_by_plugin . '`');
14
  }
widget-pre2.8.php CHANGED
@@ -1,274 +1,390 @@
1
  <?php
2
 
3
- function widget_extended_categories_init() {
 
4
  // Widgets exists?
5
- if (! function_exists ( 'wp_register_sidebar_widget' ) || ! function_exists ( 'wp_register_widget_control' )) {
6
  return;
7
  }
8
 
9
- function widget_extended_categories($args, $number = 1) {
10
- $version = '3.3.2';
 
11
  // Check for version
12
  require (ABSPATH . WPINC . '/version.php');
13
- if ( version_compare($wp_version, '2.5.1', '<') ) {
14
- $avh_extcat_canselectcats=false;
15
- } else {
16
- $avh_extcat_canselectcats=true;
17
- }
18
- extract ( $args );
19
- $options = get_option ( 'widget_extended_categories' );
20
- $c = $options [$number]['count'] ? '1' : '0';
21
- $h = $options [$number]['hierarchical'] ? '1' : '0';
22
- $e = $options [$number]['hide_empty'] ? '1' : '0';
23
- $s = $options [$number]['sort_column'] ? $options [$number]['sort_column'] : 'name';
24
- $o = $options [$number]['sort_order'] ? $options [$number]['sort_order'] : 'asc';
25
- $r = $options [$number]['rssfeed'] ? 'RSS' : '';
26
- $i = $options [$number]['rssimage'] ? $options [$number]['rssimage'] : '';
27
  if (empty($r)) {
28
- $i='';
29
  }
30
-
31
- $title = empty ( $options [$number]['title'] ) ? __ ( 'Categories' ) : attribute_escape($options [$number]['title']);
32
- $style = empty ( $options [$number]['style'] ) ? 'list' : $options [$number]['style'];
33
  if ($avh_extcat_canselectcats) {
34
- if ($options [$number]['post_category']) {
35
- $post_category = unserialize ( $options [$number]['post_category'] );
36
- $included_cats = implode ( ",", $post_category );
37
  }
38
- $cat_args = array (
39
- 'include' => $included_cats,
40
- 'orderby' => $s,
41
- 'order' => $o,
42
- 'show_count' => $c,
43
- 'hide_empty' => $e,
44
- 'hierarchical' => $h,
45
- 'title_li' => '',
46
- 'show_option_none' => __ ( 'Select Category' ),
47
- 'feed' => $r,
48
- 'feed_image' => $i,
49
- 'name' => 'ec-cat-'.$number,
50
- 'depth' => 2, );
51
  } else {
52
- $cat_args = array (
53
- 'orderby' => $s,
54
- 'order' => $o,
55
- 'show_count' => $c,
56
- 'hide_empty' => $e,
57
- 'hierarchical' => $h,
58
- 'title_li' => '',
59
- 'show_option_none' => __ ( 'Select Category' ),
60
- 'feed' => $r,
61
- 'feed_image' => $i,
62
- 'name' => 'ec-cat-'.$number);
63
  }
64
  echo $before_widget;
65
- echo '<!-- AVH Extended Categories version ' . $version .' | http://blog.avirtualhome.com/wordpress-plugins/ -->';
66
  echo $before_title . $title . $after_title;
67
-
68
  if ($style == 'list') {
69
  echo '<ul>';
70
- wp_list_categories ( $cat_args );
71
  echo '</ul>';
72
  } else {
73
- wp_dropdown_categories ( $cat_args );
74
  ?>
75
  <script lang='javascript'><!--
76
- var ec_dropdown_<?php echo ($number); ?> = document.getElementById('ec-cat-<?php echo ($number); ?>');
77
- function ec_onCatChange_<?php echo ($number); ?>() {
78
- if ( ec_dropdown_<?php echo ($number); ?>.options[ec_dropdown_<?php echo ($number); ?>.selectedIndex].value > 0 ) {
79
- location.href = "<?php echo get_option ( 'home' ); ?>/?cat="+ec_dropdown_<?php echo ($number); ?>.options[ec_dropdown_<?php echo ($number); ?>.selectedIndex].value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
  }
82
- ec_dropdown_<?php echo ($number); ?>.onchange = ec_onCatChange_<?php echo ($number); ?>;
 
 
 
 
83
  --></script>
84
  <?php
85
  }
86
  echo $after_widget;
87
  }
88
 
89
- function widget_extended_categories_control($number = 1) {
90
- // Check for version
 
91
  require (ABSPATH . WPINC . '/version.php');
92
- if ( version_compare($wp_version, '2.5.1', '<') ) {
93
- $avh_extcat_canselectcats=false;
94
- } else {
95
- $avh_extcat_canselectcats=true;
96
- }
97
  // Get actual options
98
- $options = $newoptions = get_option ( 'widget_extended_categories' );
99
- if (! is_array ( $options )) {
100
- $options = $newoptions = array ( );
101
  }
102
  // Post to new options array
103
-
104
- if ($_POST ['categories-submit-' . $number]) {
105
- $newoptions [$number]['title'] = strip_tags ( stripslashes ( $_POST ['categories-title-' . $number] ) );
106
- $newoptions [$number]['count'] = isset ( $_POST ['categories-count-' . $number] );
107
- $newoptions [$number]['hierarchical'] = isset ( $_POST ['categories-hierarchical-' . $number] );
108
- $newoptions [$number]['hide_empty'] = isset ( $_POST ['categories-hide_empty-' . $number] );
109
- $newoptions [$number]['sort_column'] = strip_tags ( stripslashes ( $_POST ['categories-sort_column-' . $number] ) );
110
- $newoptions [$number]['sort_order'] = strip_tags ( stripslashes ( $_POST ['categories-sort_order-' . $number] ) );
111
- $newoptions [$number]['style'] = strip_tags ( stripslashes ( $_POST ['categories-style-' . $number] ) );
112
- $newoptions [$number]['rssfeed'] = isset ( $_POST ['categories-rssfeed-' . $number] );
113
- $newoptions [$number]['rssimage'] = attribute_escape ( $_POST ['categories-rssimage-' . $number] );
 
114
  if ($avh_extcat_canselectcats) {
115
- if (in_array ( '-1', $_POST ['post_category-' . $number], true )) {
116
- $newoptions [$number]['post_category'] = false;
117
  } else {
118
- $newoptions [$number]['post_category'] = serialize ( $_POST ['post_category-' . $number] );
119
  }
120
  }
121
-
122
  }
123
-
124
  // Update if new options
125
  if ($options != $newoptions) {
126
  $options = $newoptions;
127
- update_option ( 'widget_extended_categories', $options );
128
  }
129
-
130
  // Prepare data for display
131
- $title = htmlspecialchars ( $options [$number]['title'], ENT_QUOTES );
132
- $count = $options [$number]['count'] ? 'checked="checked"' : '';
133
- $hierarchical = $options [$number]['hierarchical'] ? 'checked="checked"' : '';
134
- $hide_empty = $options [$number]['hide_empty'] ? 'checked="checked"' : '';
135
- $sort_id = ($options [$number]['sort_column'] == 'ID') ? ' SELECTED' : '';
136
- $sort_name = ($options [$number]['sort_column'] == 'name') ? ' SELECTED' : '';
137
- $sort_count = ($options [$number]['sort_column'] == 'count') ? ' SELECTED' : '';
138
- $sort_order_a = ($options [$number]['sort_order'] == 'asc') ? ' SELECTED' : '';
139
- $sort_order_d = ($options [$number]['sort_order'] == 'desc') ? ' SELECTED' : '';
140
- $style_list = ($options [$number]['style'] == 'list') ? ' SELECTED' : '';
141
- $style_drop = ($options [$number]['style'] == 'drop') ? ' SELECTED' : '';
142
- $rssfeed = $options [$number]['rssfeed'] ? 'checked="checked"' : '';
143
- $rssimage = htmlspecialchars ( $options [$number]['rssimage'], ENT_QUOTES );
144
  if ($avh_extcat_canselectcats) {
145
- $selected_cats = ($options [$number]['post_category'] != '') ? unserialize ( $options [$number]['post_category'] ) : false;
146
  }
147
  ?>
148
- <div>
149
- <label for="categories-title-<?php echo $number; ?>"><?php _e ( 'Title:' ); ?>
150
- <input style="width: 250px;" id="categories-title-<?php echo $number; ?>" name="categories-title-<?php echo $number; ?>" type="text" value="<?php echo $title; ?>" />
151
- </label>
152
-
153
- <label for="categories-count-<?php echo $number; ?>" style="line-height: 35px; display: block;">Show post counts
154
- <input class="checkbox" type="checkbox" <?php echo $count; ?> id="categories-count-<?php echo $number; ?>" name="categories-count-<?php echo $number; ?>" />
155
- </label>
156
-
157
- <label for="categories-hierarchical" style="line-height: 35px; display: block;">Show hierarchy
158
- <input class="checkbox" type="checkbox" <?php echo $hierarchical; ?> id="categories-hierarchical-<?php echo $number; ?>" name="categories-hierarchical-<?php echo $number; ?>" />
159
- </label>
160
-
161
- <label for="categories-hide_empty-<?php echo $number; ?>" style="line-height: 35px; display: block;">Hide empty categories
162
- <input class="checkbox" type="checkbox" <?php echo $hide_empty; ?> id="categories-hide_empty-<?php echo $number; ?>" name="categories-hide_empty-<?php echo $number; ?>" />
163
- </label>
164
-
165
- <label for="categories-sort_column-<?php echo $number; ?>" style="line-height: 35px; display: block;">Sort by
166
- <select id="categories-sort_column-<?php echo $number; ?>" name="categories-sort_column-<?php echo $number; ?>">
167
- <option value="ID" <?php echo $sort_id?>>ID</option>
168
- <option value="name" <?php echo $sort_name?>>Name</option>
169
- <option value="count" <?php echo $sort_count?>>Count</option>
170
- </select>
171
- </label>
172
-
173
- <label for="categories-sort_order-<?php echo $number; ?>" style="line-height: 35px; display: block;">Sort order
174
- <select id="categories-sort_order-<?php echo $number; ?>" name="categories-sort_order-<?php echo $number; ?>">
175
- <option value="asc" <?php echo $sort_order_a?>>Ascending</option>
176
- <option value="desc" <?php echo $sort_order_d?>>Descending</option>
177
- </select>
178
- </label>
179
-
180
- <label for="categories-style-<?php echo $number; ?>" style="line-height: 35px; display: block;">Display style
181
- <select id="categories-style-<?php echo $number; ?>" name="categories-style-<?php echo $number; ?>">
182
- <option value='list' <?php echo $style_list; ?>>List</option>
183
- <option value='drop' <?php echo $style_drop; ?>>Drop down</option>
184
- </select>
185
- </label>
186
-
187
- <label for="categories-rssfeed-<?php echo $number; ?>" style="line-height: 35px; display: block;">Show RSS Feed
188
- <input class="checkbox" type="checkbox" <?php echo $rssfeed; ?> id="categories-rssfeed-<?php echo $number; ?>" name="categories-rssfeed-<?php echo $number; ?>" />
189
- </label>
190
-
191
- <label for="categories-rssimage-<?php echo $number; ?>"><?php _e ( 'Path (URI) to RSS image:' ); ?>
192
- <input style="width: 250px;" id="categories-rssimage-<?php echo $number; ?>" name="categories-rssimage-<?php echo $number; ?>" type="text" value="<?php echo $rssimage; ?>" />
193
- </label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
 
195
  <?php
196
- if ($avh_extcat_canselectcats) {
197
- echo ' <b>Include these categories</b><hr />';
198
- 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;">';
199
- echo ' <li id="category--1-'.$number.'" class="popular-category">';
200
- echo ' <label for="in-category--1-'.$number.'" class="selectit">';
201
- echo ' <input value="-1" name="post_category-'.$number.'[]" id="in-category--1-'.$number.'" type="checkbox"';
202
- if (!$selected_cats) { echo 'checked'; }
203
- echo '> Include All Categories';
204
- echo ' </label>';
205
- echo ' </li>';
206
- avh_wp_category_checklist(0,0,$selected_cats,false,$number);
207
- echo ' </ul>';
208
- }
209
- ?>
 
 
210
 
211
- <input type="hidden" id="categories-submit-<?php echo $number; ?>" name="categories-submit-<?php echo $number; ?>" value="1" /></div>
 
 
 
 
 
212
  <?php
213
  }
 
214
  /**
215
  * Called after the widget_extended_categories_page form has been submitted.
216
  * Set the amount of widgets wanted and register the widgets
217
  *
218
  */
219
- function widget_extended_categories_setup() {
 
220
  $options = $newoptions = get_option('widget_extended_categories');
221
- if ( isset($_POST['extended_categories-number-submit']) ) {
222
  $number = (int) $_POST['extended_categories-number'];
223
- if ( $number > 9 ) $number = 9;
224
- if ( $number < 1 ) $number = 1;
 
 
225
  $newoptions['number'] = $number;
226
  }
227
- if ( $options != $newoptions ) {
228
  $options = $newoptions;
229
  update_option('widget_extended_categories', $options);
230
  widget_extended_categories_register($options['number']);
231
  }
232
  }
 
233
  /**
234
  * How many Wish List widgets are wanted.
235
  *
236
  */
237
- function widget_extended_categories_page() {
 
238
  $options = get_option('widget_extended_categories');
239
  ?>
240
- <div class="wrap">
241
- <form method="post">
242
- <h2><?php _e('AVH Extended Categories Widgets', 'avhextendedcategories'); ?></h2>
243
- <p style="line-height: 30px;"><?php _e('How many wishlist widgets would you like?', 'avhextendedcategories'); ?>
244
- <select id="extended_categories-number" name="extended_categories-number" value="<?php echo $options['number']; ?>">
245
- <?php for ( $i = 1; $i < 10; ++$i ) echo "<option value='$i' ".($options['number']==$i ? "selected='selected'" : '').">$i</option>"; ?>
246
- </select>
247
- <span class="submit"><input type="submit" name="extended_categories-number-submit" id="extended_categories-number-submit" value="<?php echo attribute_escape(__('Save', 'avhextendedcategories')); ?>" /></span></p>
248
- </form>
249
- </div>
250
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  }
252
- function widget_extended_categories_register() {
253
- $options = get_option( 'widget_extended_categories' );
254
 
255
- $number = ( int ) $options['number'];
256
- if ( $number < 1 ) $number = 1;
257
- if ( $number > 9 ) $number = 9;
258
- for ( $i = 1; $i <= 9; $i ++ ) {
259
- $id = "extended-categories-$i";
260
- $name = sprintf( __('Extended Categories %d'), $i );
261
- wp_register_sidebar_widget( $id, $name, $i <= $number ? 'widget_extended_categories' : /* unregister */ '', array ( 'classname'=>'widget_extended_categories_init'), $i );
262
- wp_register_widget_control( $id, $name, $i <= $number ? 'widget_extended_categories_control' : /* unregister */ '', array ( 'width'=>300, 'height'=>270), $i );
 
 
 
 
 
 
263
  }
264
  add_action('sidebar_admin_setup', 'widget_extended_categories_setup');
265
  add_action('sidebar_admin_page', 'widget_extended_categories_page');
266
  }
267
-
268
  // Launch Widgets
269
- widget_extended_categories_register ();
270
  }
271
- add_action ( 'plugins_loaded', 'widget_extended_categories_init' );
272
 
273
  /**
274
  * As the original wp_category_checklist doesn't support multiple lists on the same page I needed to duplicate the functions
@@ -279,29 +395,34 @@ add_action ( 'plugins_loaded', 'widget_extended_categories_init' );
279
  * Class that will display the categories
280
  *
281
  */
282
- class AVH_Walker_Category_Checklist extends Walker {
 
283
  var $tree_type = 'category';
284
- var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
285
  var $number;
286
 
287
- function start_lvl(&$output, $depth, $args) {
 
288
  $indent = str_repeat("\t", $depth);
289
  $output .= "$indent<ul class='children'>\n";
290
  }
291
 
292
- function end_lvl(&$output, $depth, $args) {
 
293
  $indent = str_repeat("\t", $depth);
294
  $output .= "$indent</ul>\n";
295
  }
296
 
297
- function start_el(&$output, $category, $depth, $args) {
 
298
  extract($args);
299
-
300
- $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
301
- $output .= "\n<li id='category-$category->term_id-$this->number'$class>" . '<label for="in-category-' . $category->term_id . '-' .$this->number. '" class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category-' . $this->number . '[]" id="in-category-' . $category->term_id . '-'.$this->number.'"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . wp_specialchars( apply_filters('the_category', $category->name )) . '</label>';
302
  }
303
 
304
- function end_el(&$output, $category, $depth, $args) {
 
305
  $output .= "</li>\n";
306
  }
307
  }
@@ -315,42 +436,43 @@ class AVH_Walker_Category_Checklist extends Walker {
315
  * @param array $popular_cats
316
  * @param int $number
317
  */
318
- function avh_wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $number ) {
319
- $walker = new AVH_Walker_Category_Checklist;
 
320
  $walker->number = $number;
321
-
322
  $descendants_and_self = (int) $descendants_and_self;
323
-
324
  $args = array();
325
- if ( is_array( $selected_cats ) )
326
  $args['selected_cats'] = $selected_cats;
327
- elseif ( $post_id )
328
  $args['selected_cats'] = wp_get_post_categories($post_id);
329
  else
330
  $args['selected_cats'] = array();
331
-
332
- if ( is_array( $popular_cats ) )
333
  $args['popular_cats'] = $popular_cats;
334
  else
335
- $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
336
-
337
- if ( $descendants_and_self ) {
338
- $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" );
339
- $self = get_category( $descendants_and_self );
340
- array_unshift( $categories, $self );
341
  } else {
342
  $categories = get_categories('get=all');
343
  }
344
-
345
  // 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)
346
  $checked_categories = array();
347
- for ( $i = 0; isset($categories[$i]); $i++ ) {
348
- if ( in_array($categories[$i]->term_id, $args['selected_cats']) ) {
349
  $checked_categories[] = $categories[$i];
350
  unset($categories[$i]);
351
  }
352
  }
353
-
354
  // Put checked cats on top
355
  echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
356
  // Then the rest of them
1
  <?php
2
 
3
+ function widget_extended_categories_init ()
4
+ {
5
  // Widgets exists?
6
+ if (! function_exists('wp_register_sidebar_widget') || ! function_exists('wp_register_widget_control')) {
7
  return;
8
  }
9
 
10
+ function widget_extended_categories ($args, $number = 1)
11
+ {
12
+ $version = '3.3.3';
13
  // Check for version
14
  require (ABSPATH . WPINC . '/version.php');
15
+ if (version_compare($wp_version, '2.5.1', '<')) {
16
+ $avh_extcat_canselectcats = false;
17
+ } else {
18
+ $avh_extcat_canselectcats = true;
19
+ }
20
+ extract($args);
21
+ $options = get_option('widget_extended_categories');
22
+ $c = $options[$number]['count'] ? '1' : '0';
23
+ $h = $options[$number]['hierarchical'] ? '1' : '0';
24
+ $e = $options[$number]['hide_empty'] ? '1' : '0';
25
+ $s = $options[$number]['sort_column'] ? $options[$number]['sort_column'] : 'name';
26
+ $o = $options[$number]['sort_order'] ? $options[$number]['sort_order'] : 'asc';
27
+ $r = $options[$number]['rssfeed'] ? 'RSS' : '';
28
+ $i = $options[$number]['rssimage'] ? $options[$number]['rssimage'] : '';
29
  if (empty($r)) {
30
+ $i = '';
31
  }
32
+
33
+ $title = empty($options[$number]['title']) ? __('Categories') : attribute_escape($options[$number]['title']);
34
+ $style = empty($options[$number]['style']) ? 'list' : $options[$number]['style'];
35
  if ($avh_extcat_canselectcats) {
36
+ if ($options[$number]['post_category']) {
37
+ $post_category = unserialize($options[$number]['post_category']);
38
+ $included_cats = implode(",", $post_category);
39
  }
40
+ $cat_args = array('include'=>$included_cats, 'orderby'=>$s, 'order'=>$o, 'show_count'=>$c, 'hide_empty'=>$e, 'hierarchical'=>$h, 'title_li'=>'', 'show_option_none'=>__('Select Category'), 'feed'=>$r, 'feed_image'=>$i, 'name'=>'ec-cat-' . $number, 'depth'=>2);
 
 
 
 
 
 
 
 
 
 
 
 
41
  } else {
42
+ $cat_args = array('orderby'=>$s, 'order'=>$o, 'show_count'=>$c, 'hide_empty'=>$e, 'hierarchical'=>$h, 'title_li'=>'', 'show_option_none'=>__('Select Category'), 'feed'=>$r, 'feed_image'=>$i, 'name'=>'ec-cat-' . $number);
 
 
 
 
 
 
 
 
 
 
43
  }
44
  echo $before_widget;
45
+ echo '<!-- AVH Extended Categories version ' . $version . ' | http://blog.avirtualhome.com/wordpress-plugins/ -->';
46
  echo $before_title . $title . $after_title;
47
+
48
  if ($style == 'list') {
49
  echo '<ul>';
50
+ wp_list_categories($cat_args);
51
  echo '</ul>';
52
  } else {
53
+ wp_dropdown_categories($cat_args);
54
  ?>
55
  <script lang='javascript'><!--
56
+ var ec_dropdown_<?php
57
+ echo ($number);
58
+ ?> = document.getElementById('ec-cat-<?php
59
+ echo ($number);
60
+ ?>');
61
+ function ec_onCatChange_<?php
62
+ echo ($number);
63
+ ?>() {
64
+ if ( ec_dropdown_<?php
65
+ echo ($number);
66
+ ?>.options[ec_dropdown_<?php
67
+ echo ($number);
68
+ ?>.selectedIndex].value > 0 ) {
69
+ location.href = "<?php
70
+ echo get_option('home');
71
+ ?>/?cat="+ec_dropdown_<?php
72
+ echo ($number);
73
+ ?>.options[ec_dropdown_<?php
74
+ echo ($number);
75
+ ?>.selectedIndex].value;
76
  }
77
  }
78
+ ec_dropdown_<?php
79
+ echo ($number);
80
+ ?>.onchange = ec_onCatChange_<?php
81
+ echo ($number);
82
+ ?>;
83
  --></script>
84
  <?php
85
  }
86
  echo $after_widget;
87
  }
88
 
89
+ function widget_extended_categories_control ($number = 1)
90
+ {
91
+ // Check for version
92
  require (ABSPATH . WPINC . '/version.php');
93
+ if (version_compare($wp_version, '2.5.1', '<')) {
94
+ $avh_extcat_canselectcats = false;
95
+ } else {
96
+ $avh_extcat_canselectcats = true;
97
+ }
98
  // Get actual options
99
+ $options = $newoptions = get_option('widget_extended_categories');
100
+ if (! is_array($options)) {
101
+ $options = $newoptions = array();
102
  }
103
  // Post to new options array
104
+
105
+
106
+ if ($_POST['categories-submit-' . $number]) {
107
+ $newoptions[$number]['title'] = strip_tags(stripslashes($_POST['categories-title-' . $number]));
108
+ $newoptions[$number]['count'] = isset($_POST['categories-count-' . $number]);
109
+ $newoptions[$number]['hierarchical'] = isset($_POST['categories-hierarchical-' . $number]);
110
+ $newoptions[$number]['hide_empty'] = isset($_POST['categories-hide_empty-' . $number]);
111
+ $newoptions[$number]['sort_column'] = strip_tags(stripslashes($_POST['categories-sort_column-' . $number]));
112
+ $newoptions[$number]['sort_order'] = strip_tags(stripslashes($_POST['categories-sort_order-' . $number]));
113
+ $newoptions[$number]['style'] = strip_tags(stripslashes($_POST['categories-style-' . $number]));
114
+ $newoptions[$number]['rssfeed'] = isset($_POST['categories-rssfeed-' . $number]);
115
+ $newoptions[$number]['rssimage'] = attribute_escape($_POST['categories-rssimage-' . $number]);
116
  if ($avh_extcat_canselectcats) {
117
+ if (in_array('-1', $_POST['post_category-' . $number], true)) {
118
+ $newoptions[$number]['post_category'] = false;
119
  } else {
120
+ $newoptions[$number]['post_category'] = serialize($_POST['post_category-' . $number]);
121
  }
122
  }
123
+
124
  }
125
+
126
  // Update if new options
127
  if ($options != $newoptions) {
128
  $options = $newoptions;
129
+ update_option('widget_extended_categories', $options);
130
  }
131
+
132
  // Prepare data for display
133
+ $title = htmlspecialchars($options[$number]['title'], ENT_QUOTES);
134
+ $count = $options[$number]['count'] ? 'checked="checked"' : '';
135
+ $hierarchical = $options[$number]['hierarchical'] ? 'checked="checked"' : '';
136
+ $hide_empty = $options[$number]['hide_empty'] ? 'checked="checked"' : '';
137
+ $sort_id = ($options[$number]['sort_column'] == 'ID') ? ' SELECTED' : '';
138
+ $sort_name = ($options[$number]['sort_column'] == 'name') ? ' SELECTED' : '';
139
+ $sort_count = ($options[$number]['sort_column'] == 'count') ? ' SELECTED' : '';
140
+ $sort_order_a = ($options[$number]['sort_order'] == 'asc') ? ' SELECTED' : '';
141
+ $sort_order_d = ($options[$number]['sort_order'] == 'desc') ? ' SELECTED' : '';
142
+ $style_list = ($options[$number]['style'] == 'list') ? ' SELECTED' : '';
143
+ $style_drop = ($options[$number]['style'] == 'drop') ? ' SELECTED' : '';
144
+ $rssfeed = $options[$number]['rssfeed'] ? 'checked="checked"' : '';
145
+ $rssimage = htmlspecialchars($options[$number]['rssimage'], ENT_QUOTES);
146
  if ($avh_extcat_canselectcats) {
147
+ $selected_cats = ($options[$number]['post_category'] != '') ? unserialize($options[$number]['post_category']) : false;
148
  }
149
  ?>
150
+ <div><label for="categories-title-<?php
151
+ echo $number;
152
+ ?>"><?php
153
+ _e('Title:');
154
+ ?>
155
+ <input style="width: 250px;"
156
+ id="categories-title-<?php
157
+ echo $number;
158
+ ?>"
159
+ name="categories-title-<?php
160
+ echo $number;
161
+ ?>" type="text"
162
+ value="<?php
163
+ echo $title;
164
+ ?>" /> </label> <label
165
+ for="categories-count-<?php
166
+ echo $number;
167
+ ?>"
168
+ style="line-height: 35px; display: block;">Show post counts <input
169
+ class="checkbox" type="checkbox" <?php
170
+ echo $count;
171
+ ?>
172
+ id="categories-count-<?php
173
+ echo $number;
174
+ ?>"
175
+ name="categories-count-<?php
176
+ echo $number;
177
+ ?>" /> </label> <label
178
+ for="categories-hierarchical"
179
+ style="line-height: 35px; display: block;">Show hierarchy <input
180
+ class="checkbox" type="checkbox" <?php
181
+ echo $hierarchical;
182
+ ?>
183
+ id="categories-hierarchical-<?php
184
+ echo $number;
185
+ ?>"
186
+ name="categories-hierarchical-<?php
187
+ echo $number;
188
+ ?>" /> </label> <label
189
+ for="categories-hide_empty-<?php
190
+ echo $number;
191
+ ?>"
192
+ style="line-height: 35px; display: block;">Hide empty categories <input
193
+ class="checkbox" type="checkbox" <?php
194
+ echo $hide_empty;
195
+ ?>
196
+ id="categories-hide_empty-<?php
197
+ echo $number;
198
+ ?>"
199
+ name="categories-hide_empty-<?php
200
+ echo $number;
201
+ ?>" /> </label> <label
202
+ for="categories-sort_column-<?php
203
+ echo $number;
204
+ ?>"
205
+ style="line-height: 35px; display: block;">Sort by <select
206
+ id="categories-sort_column-<?php
207
+ echo $number;
208
+ ?>"
209
+ name="categories-sort_column-<?php
210
+ echo $number;
211
+ ?>">
212
+ <option value="ID" <?php
213
+ echo $sort_id?>>ID</option>
214
+ <option value="name" <?php
215
+ echo $sort_name?>>Name</option>
216
+ <option value="count" <?php
217
+ echo $sort_count?>>Count</option>
218
+ </select> </label> <label
219
+ for="categories-sort_order-<?php
220
+ echo $number;
221
+ ?>"
222
+ style="line-height: 35px; display: block;">Sort order <select
223
+ id="categories-sort_order-<?php
224
+ echo $number;
225
+ ?>"
226
+ name="categories-sort_order-<?php
227
+ echo $number;
228
+ ?>">
229
+ <option value="asc" <?php
230
+ echo $sort_order_a?>>Ascending</option>
231
+ <option value="desc" <?php
232
+ echo $sort_order_d?>>Descending</option>
233
+ </select> </label> <label for="categories-style-<?php
234
+ echo $number;
235
+ ?>"
236
+ style="line-height: 35px; display: block;">Display style <select
237
+ id="categories-style-<?php
238
+ echo $number;
239
+ ?>"
240
+ name="categories-style-<?php
241
+ echo $number;
242
+ ?>">
243
+ <option value='list' <?php
244
+ echo $style_list;
245
+ ?>>List</option>
246
+ <option value='drop' <?php
247
+ echo $style_drop;
248
+ ?>>Drop down</option>
249
+ </select> </label> <label
250
+ for="categories-rssfeed-<?php
251
+ echo $number;
252
+ ?>"
253
+ style="line-height: 35px; display: block;">Show RSS Feed <input
254
+ class="checkbox" type="checkbox" <?php
255
+ echo $rssfeed;
256
+ ?>
257
+ id="categories-rssfeed-<?php
258
+ echo $number;
259
+ ?>"
260
+ name="categories-rssfeed-<?php
261
+ echo $number;
262
+ ?>" /> </label> <label
263
+ for="categories-rssimage-<?php
264
+ echo $number;
265
+ ?>"><?php
266
+ _e('Path (URI) to RSS image:');
267
+ ?>
268
+ <input style="width: 250px;"
269
+ id="categories-rssimage-<?php
270
+ echo $number;
271
+ ?>"
272
+ name="categories-rssimage-<?php
273
+ echo $number;
274
+ ?>" type="text"
275
+ value="<?php
276
+ echo $rssimage;
277
+ ?>" /> </label>
278
 
279
  <?php
280
+ if ($avh_extcat_canselectcats) {
281
+ echo ' <b>Include these categories</b><hr />';
282
+ 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;">';
283
+ echo ' <li id="category--1-' . $number . '" class="popular-category">';
284
+ echo ' <label for="in-category--1-' . $number . '" class="selectit">';
285
+ echo ' <input value="-1" name="post_category-' . $number . '[]" id="in-category--1-' . $number . '" type="checkbox"';
286
+ if (! $selected_cats) {
287
+ echo 'checked';
288
+ }
289
+ echo '> Include All Categories';
290
+ echo ' </label>';
291
+ echo ' </li>';
292
+ avh_wp_category_checklist(0, 0, $selected_cats, false, $number);
293
+ echo ' </ul>';
294
+ }
295
+ ?>
296
 
297
+ <input type="hidden" id="categories-submit-<?php
298
+ echo $number;
299
+ ?>"
300
+ name="categories-submit-<?php
301
+ echo $number;
302
+ ?>" value="1" /></div>
303
  <?php
304
  }
305
+
306
  /**
307
  * Called after the widget_extended_categories_page form has been submitted.
308
  * Set the amount of widgets wanted and register the widgets
309
  *
310
  */
311
+ function widget_extended_categories_setup ()
312
+ {
313
  $options = $newoptions = get_option('widget_extended_categories');
314
+ if (isset($_POST['extended_categories-number-submit'])) {
315
  $number = (int) $_POST['extended_categories-number'];
316
+ if ($number > 9)
317
+ $number = 9;
318
+ if ($number < 1)
319
+ $number = 1;
320
  $newoptions['number'] = $number;
321
  }
322
+ if ($options != $newoptions) {
323
  $options = $newoptions;
324
  update_option('widget_extended_categories', $options);
325
  widget_extended_categories_register($options['number']);
326
  }
327
  }
328
+
329
  /**
330
  * How many Wish List widgets are wanted.
331
  *
332
  */
333
+ function widget_extended_categories_page ()
334
+ {
335
  $options = get_option('widget_extended_categories');
336
  ?>
337
+ <div class="wrap">
338
+ <form method="post">
339
+ <h2><?php
340
+ _e('AVH Extended Categories Widgets', 'avhextendedcategories');
341
+ ?></h2>
342
+ <p style="line-height: 30px;"><?php
343
+ _e('How many wishlist widgets would you like?', 'avhextendedcategories');
344
+ ?>
345
+ <select id="extended_categories-number"
346
+ name="extended_categories-number"
347
+ value="<?php
348
+ echo $options['number'];
349
+ ?>">
350
+ <?php
351
+ for ($i = 1; $i < 10; ++ $i)
352
+ echo "<option value='$i' " . ($options['number'] == $i ? "selected='selected'" : '') . ">$i</option>";
353
+ ?>
354
+ </select> <span class="submit"><input type="submit"
355
+ name="extended_categories-number-submit"
356
+ id="extended_categories-number-submit"
357
+ value="<?php
358
+ echo attribute_escape(__('Save', 'avhextendedcategories'));
359
+ ?>" /></span></p>
360
+ </form>
361
+ </div>
362
+ <?php
363
  }
 
 
364
 
365
+ function widget_extended_categories_register ()
366
+ {
367
+ $options = get_option('widget_extended_categories');
368
+
369
+ $number = (int) $options['number'];
370
+ if ($number < 1)
371
+ $number = 1;
372
+ if ($number > 9)
373
+ $number = 9;
374
+ for ($i = 1; $i <= 9; $i ++) {
375
+ $id = "extended-categories-$i";
376
+ $name = sprintf(__('Extended Categories %d'), $i);
377
+ wp_register_sidebar_widget($id, $name, $i <= $number ? 'widget_extended_categories' : /* unregister */ '', array('classname'=>'widget_extended_categories_init'), $i);
378
+ wp_register_widget_control($id, $name, $i <= $number ? 'widget_extended_categories_control' : /* unregister */ '', array('width'=>300, 'height'=>270), $i);
379
  }
380
  add_action('sidebar_admin_setup', 'widget_extended_categories_setup');
381
  add_action('sidebar_admin_page', 'widget_extended_categories_page');
382
  }
383
+
384
  // Launch Widgets
385
+ widget_extended_categories_register();
386
  }
387
+ add_action('plugins_loaded', 'widget_extended_categories_init');
388
 
389
  /**
390
  * As the original wp_category_checklist doesn't support multiple lists on the same page I needed to duplicate the functions
395
  * Class that will display the categories
396
  *
397
  */
398
+ class AVH_Walker_Category_Checklist extends Walker
399
+ {
400
  var $tree_type = 'category';
401
+ var $db_fields = array('parent'=>'parent', 'id'=>'term_id'); //TODO: decouple this
402
  var $number;
403
 
404
+ function start_lvl (&$output, $depth, $args)
405
+ {
406
  $indent = str_repeat("\t", $depth);
407
  $output .= "$indent<ul class='children'>\n";
408
  }
409
 
410
+ function end_lvl (&$output, $depth, $args)
411
+ {
412
  $indent = str_repeat("\t", $depth);
413
  $output .= "$indent</ul>\n";
414
  }
415
 
416
+ function start_el (&$output, $category, $depth, $args)
417
+ {
418
  extract($args);
419
+
420
+ $class = in_array($category->term_id, $popular_cats) ? ' class="popular-category"' : '';
421
+ $output .= "\n<li id='category-$category->term_id-$this->number'$class>" . '<label for="in-category-' . $category->term_id . '-' . $this->number . '" class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category-' . $this->number . '[]" id="in-category-' . $category->term_id . '-' . $this->number . '"' . (in_array($category->term_id, $selected_cats) ? ' checked="checked"' : "") . '/> ' . wp_specialchars(apply_filters('the_category', $category->name)) . '</label>';
422
  }
423
 
424
+ function end_el (&$output, $category, $depth, $args)
425
+ {
426
  $output .= "</li>\n";
427
  }
428
  }
436
  * @param array $popular_cats
437
  * @param int $number
438
  */
439
+ function avh_wp_category_checklist ($post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $number)
440
+ {
441
+ $walker = new AVH_Walker_Category_Checklist();
442
  $walker->number = $number;
443
+
444
  $descendants_and_self = (int) $descendants_and_self;
445
+
446
  $args = array();
447
+ if (is_array($selected_cats))
448
  $args['selected_cats'] = $selected_cats;
449
+ elseif ($post_id)
450
  $args['selected_cats'] = wp_get_post_categories($post_id);
451
  else
452
  $args['selected_cats'] = array();
453
+
454
+ if (is_array($popular_cats))
455
  $args['popular_cats'] = $popular_cats;
456
  else
457
+ $args['popular_cats'] = get_terms('category', array('fields'=>'ids', 'orderby'=>'count', 'order'=>'DESC', 'number'=>10, 'hierarchical'=>false));
458
+
459
+ if ($descendants_and_self) {
460
+ $categories = get_categories("child_of=$descendants_and_self&hierarchical=0&hide_empty=0");
461
+ $self = get_category($descendants_and_self);
462
+ array_unshift($categories, $self);
463
  } else {
464
  $categories = get_categories('get=all');
465
  }
466
+
467
  // 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)
468
  $checked_categories = array();
469
+ for ($i = 0; isset($categories[$i]); $i ++) {
470
+ if (in_array($categories[$i]->term_id, $args['selected_cats'])) {
471
  $checked_categories[] = $categories[$i];
472
  unset($categories[$i]);
473
  }
474
  }
475
+
476
  // Put checked cats on top
477
  echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
478
  // Then the rest of them
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.3.2
7
  Author: Peter van der Does
8
  Author URI: http://blog.avirtualhome.com/
9
 
@@ -29,17 +29,17 @@ 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 );
37
 
38
- if ( ( float ) $wp_version >= 2.8 ) {
39
- define( 'AVHEC_PLUGIN_URL', WP_PLUGIN_URL . '/' . $dir . '/2.8' );
40
- define( 'AVHEC_ABSOLUTE_WORKING_DIR', AVHEC_PLUGIN_DIR . '/2.8' );
41
- define ('AVHEC_RELATIVE_WORKING_DIR', $dir . '/2.8');
42
- unset ($dir);
43
  require (AVHEC_ABSOLUTE_WORKING_DIR . '/avh-ec.client.php');
44
  } else {
45
  require_once 'widget-pre2.8.php';
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.3.3
7
  Author: Peter van der Does
8
  Author URI: http://blog.avirtualhome.com/
9
 
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);
37
 
38
+ if ((float) $wp_version >= 2.8) {
39
+ define('AVHEC_PLUGIN_URL', WP_PLUGIN_URL . '/' . $dir . '/2.8');
40
+ define('AVHEC_ABSOLUTE_WORKING_DIR', AVHEC_PLUGIN_DIR . '/2.8');
41
+ define('AVHEC_RELATIVE_WORKING_DIR', $dir . '/2.8');
42
+ unset($dir);
43
  require (AVHEC_ABSOLUTE_WORKING_DIR . '/avh-ec.client.php');
44
  } else {
45
  require_once 'widget-pre2.8.php';