Content Aware Sidebars – Unlimited Widget Areas - Version 1.3.1

Version Description

  • Added: authors and bbpress user profiles now searchable on edit page
  • Added: items found in search on edit page are prepended and checked by default
  • Added: updated edit page gui
  • Added: search field only visible when quantity is above 20
  • Fixed: select all checkbox will now disable all input in container
  • Fixed: host sidebar could sometimes not be found in sidebar list
Download this release

Release Info

Developer intoxstudio
Plugin Icon 128x128 Content Aware Sidebars – Unlimited Widget Areas
Version 1.3.1
Comparing to
See all releases

Code changes from version 1.2 to 1.3.1

content-aware-sidebars.php CHANGED
@@ -7,101 +7,131 @@
7
  Plugin Name: Content Aware Sidebars
8
  Plugin URI: http://www.intox.dk/
9
  Description: Manage and show sidebars according to the content being viewed.
10
- Version: 1.2
11
- Author: Joachim Jensen
12
  Author URI: http://www.intox.dk/
13
  Text Domain: content-aware-sidebars
14
  Domain Path: /lang/
15
  License: GPL2
16
 
17
- Copyright 2011-2013 Joachim Jensen (email : jv@intox.dk)
18
 
19
- This program is free software; you can redistribute it and/or modify
20
- it under the terms of the GNU General Public License, version 2, as
21
- published by the Free Software Foundation.
22
 
23
- This program is distributed in the hope that it will be useful,
24
- but WITHOUT ANY WARRANTY; without even the implied warranty of
25
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
- GNU General Public License for more details.
27
 
28
- You should have received a copy of the GNU General Public License
29
- along with this program; if not, write to the Free Software
30
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31
 
32
  */
33
 
34
  final class ContentAwareSidebars {
35
 
 
 
 
36
  const db_version = 1.1;
 
 
 
 
37
  const prefix = '_cas_';
 
 
 
 
 
 
 
 
 
 
38
 
39
- private $plugin_url;
 
 
 
 
 
 
 
 
 
40
  private $metadata = array();
41
- private $taxonomies = array();
 
 
 
 
42
  private $sidebar_cache = array();
43
-
 
 
 
 
44
  private $modules = array();
45
 
46
  /**
47
- *
48
  * Constructor
49
- *
50
  */
51
  public function __construct() {
 
 
52
 
53
- $this->plugin_url = WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__));
54
-
55
- register_activation_hook(__FILE__, array(&$this,'plugin_activation'));
56
- register_deactivation_hook(__FILE__, array(&$this,'plugin_deactivation'));
57
 
58
  $this->_load_dependencies();
59
 
60
  // WordPress Hooks. Somewhat ordered by execution
61
 
62
  // On sitewide requests
63
- add_action('plugins_loaded', array(&$this,'deploy_modules'));
64
- add_action('init', array(&$this,'init_sidebar_type'),99);
65
- add_action('widgets_init', array(&$this,'create_sidebars'));
66
 
67
- // On admin requests
68
- add_action('admin_menu', array(&$this,'clear_admin_menu'));
69
- add_action('admin_enqueue_scripts', array(&$this,'load_admin_scripts'));
70
 
71
  // On post type and taxonomy requests
72
- add_action('delete_post', array(&$this,'remove_sidebar_widgets'));
73
- add_action('save_post', array(&$this,'save_post'));
74
 
75
  // Order not known yet
76
- add_action('add_meta_boxes_sidebar', array(&$this,'create_meta_boxes'));
77
-
78
- add_filter('default_hidden_meta_boxes', array(&$this,'change_default_hidden'),10,2);
79
- add_filter('manage_edit-sidebar_columns', array(&$this,'admin_column_headers'));
80
- add_filter('manage_edit-sidebar_sortable_columns', array(&$this,'admin_column_sortable_headers'));
81
- add_filter('manage_posts_custom_column', array(&$this,'admin_column_rows'),10,3);
82
- add_filter('post_row_actions', array(&$this,'sidebar_row_actions'),10,2);
83
- add_filter('post_updated_messages', array(&$this,'sidebar_updated_messages'));
84
-
85
-
86
  // Sitewide hooks that should not be loaded sitewide here
87
  if(is_admin()) {
88
- add_filter('request', array(&$this,'admin_column_orderby'));
89
 
90
- add_action('wp_loaded', array(&$this,'db_update'));
91
  } else {
92
- add_filter('wp', array(&$this,'replace_sidebar'));
93
  }
94
 
95
  }
96
 
97
  /**
98
- *
99
  * Deploy modules
100
- *
101
  */
102
  public function deploy_modules() {
103
-
104
- load_plugin_textdomain('content-aware-sidebars', false, dirname( plugin_basename(__FILE__)).'/lang/');
105
 
106
  // List modules
107
  $modules = array(
@@ -110,6 +140,7 @@ final class ContentAwareSidebars {
110
  'author' => true,
111
  'page_template' => true,
112
  'taxonomy' => true,
 
113
  'bbpress' => function_exists('bbp_get_version'), // bbPress
114
  'bp_member' => defined('BP_VERSION'), // BuddyPress
115
  'polylang' => defined('POLYLANG_VERSION'), // Polylang
@@ -120,7 +151,7 @@ final class ContentAwareSidebars {
120
 
121
  // Forge modules
122
  foreach($modules as $name => $enabled) {
123
- if($enabled && include_once('modules/'.$name .'.php')) {
124
  $class = 'CASModule_'.$name;
125
  $this->modules[$name] = new $class;
126
  }
@@ -129,49 +160,46 @@ final class ContentAwareSidebars {
129
  }
130
 
131
  /**
132
- *
133
  * Create post meta fields
134
- *
135
- * @global int $post
136
  * @global array $wp_registered_sidebars
 
137
  */
138
  private function _init_metadata() {
139
- global $post, $wp_registered_sidebars;
140
-
141
  // List of sidebars
142
  $sidebar_list = array();
143
  foreach($wp_registered_sidebars as $sidebar) {
144
- if(isset($post) && $sidebar['id'] != 'ca-sidebar-'.$post->ID)
145
- $sidebar_list[$sidebar['id']] = $sidebar['name'];
146
  }
147
-
148
  // Meta fields
149
  $this->metadata['exposure'] = array(
150
- 'name' => __('Exposure', 'content-aware-sidebars'),
151
  'id' => 'exposure',
152
  'desc' => '',
153
  'val' => 1,
154
  'type' => 'select',
155
  'list' => array(
156
- __('Singular', 'content-aware-sidebars'),
157
- __('Singular & Archive', 'content-aware-sidebars'),
158
- __('Archive', 'content-aware-sidebars')
159
  )
160
  );
161
  $this->metadata['handle'] = array(
162
- 'name' => _x('Handle','option', 'content-aware-sidebars'),
163
  'id' => 'handle',
164
- 'desc' => __('Replace host sidebar, merge with it or add sidebar manually.', 'content-aware-sidebars'),
165
  'val' => 0,
166
  'type' => 'select',
167
  'list' => array(
168
- __('Replace', 'content-aware-sidebars'),
169
- __('Merge', 'content-aware-sidebars'),
170
- __('Manual', 'content-aware-sidebars')
171
  )
172
  );
173
  $this->metadata['host'] = array(
174
- 'name' => __('Host Sidebar', 'content-aware-sidebars'),
175
  'id' => 'host',
176
  'desc' => '',
177
  'val' => 'sidebar-1',
@@ -179,45 +207,39 @@ final class ContentAwareSidebars {
179
  'list' => $sidebar_list
180
  );
181
  $this->metadata['merge-pos'] = array(
182
- 'name' => __('Merge position', 'content-aware-sidebars'),
183
  'id' => 'merge-pos',
184
- 'desc' => __('Place sidebar on top or bottom of host when merging.', 'content-aware-sidebars'),
185
  'val' => 1,
186
  'type' => 'select',
187
  'list' => array(
188
- __('Top', 'content-aware-sidebars'),
189
- __('Bottom', 'content-aware-sidebars')
190
  )
191
  );
192
 
193
  }
194
 
195
  /**
196
- *
197
- * Custom Post Type: Sidebar
198
- *
199
  */
200
  public function init_sidebar_type() {
201
 
202
- // List public taxonomies
203
- foreach(get_taxonomies(array('public'=>true),'names') as $tax) {
204
- $this->taxonomies[] = $tax;
205
- }
206
-
207
  // Register the sidebar type
208
- register_post_type('sidebar',array(
209
  'labels' => array(
210
- 'name' => __('Sidebars', 'content-aware-sidebars'),
211
- 'singular_name' => __('Sidebar', 'content-aware-sidebars'),
212
- 'add_new' => _x('Add New', 'sidebar', 'content-aware-sidebars'),
213
- 'add_new_item' => __('Add New Sidebar', 'content-aware-sidebars'),
214
- 'edit_item' => __('Edit Sidebar', 'content-aware-sidebars'),
215
- 'new_item' => __('New Sidebar', 'content-aware-sidebars'),
216
- 'all_items' => __('All Sidebars', 'content-aware-sidebars'),
217
- 'view_item' => __('View Sidebar', 'content-aware-sidebars'),
218
- 'search_items' => __('Search Sidebars', 'content-aware-sidebars'),
219
- 'not_found' => __('No sidebars found', 'content-aware-sidebars'),
220
- 'not_found_in_trash' => __('No sidebars found in Trash', 'content-aware-sidebars')
221
  ),
222
  'capabilities' => array(
223
  'edit_post' => 'edit_theme_options',
@@ -228,116 +250,109 @@ final class ContentAwareSidebars {
228
  'publish_posts' => 'edit_theme_options',
229
  'read_private_posts' => 'edit_theme_options'
230
  ),
231
- 'show_ui' => true,
 
232
  'query_var' => false,
233
  'rewrite' => false,
234
  'menu_position' => null,
235
- 'supports' => array('title','page-attributes','excerpt'),
236
- 'taxonomies' => $this->taxonomies,
237
- 'menu_icon' => WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__)).'/img/icon-16.png'
238
  ));
239
  }
240
 
241
  /**
242
- *
243
  * Create update messages
244
- *
245
  * @global object $post
246
- * @param array $messages
247
- * @return array
248
  */
249
  public function sidebar_updated_messages( $messages ) {
250
  global $post;
251
- $messages['sidebar'] = array(
252
  0 => '',
253
- 1 => sprintf(__('Sidebar updated. <a href="%s">Manage widgets</a>','content-aware-sidebars'),'widgets.php'),
254
  2 => '',
255
  3 => '',
256
- 4 => __('Sidebar updated.','content-aware-sidebars'),
257
  5 => '',
258
- 6 => sprintf(__('Sidebar published. <a href="%s">Manage widgets</a>','content-aware-sidebars'), 'widgets.php'),
259
- 7 => __('Sidebar saved.','content-aware-sidebars'),
260
- 8 => sprintf(__('Sidebar submitted. <a href="%s">Manage widgets</a>','content-aware-sidebars'),'widgets.php'),
261
- 9 => sprintf(__('Sidebar scheduled for: <strong>%1$s</strong>. <a href="%2$s">Manage widgets</a>','content-aware-sidebars'),
262
  // translators: Publish box date format, see http://php.net/date
263
  date_i18n(__('M j, Y @ G:i'),strtotime($post->post_date)),'widgets.php'),
264
- 10 => __('Sidebar draft updated.','content-aware-sidebars'),
265
  );
266
  return $messages;
267
  }
268
-
269
- /**
270
- *
271
- * Remove taxonomy shortcuts from menu and standard meta boxes.
272
- *
273
- */
274
- public function clear_admin_menu() {
275
- if(current_user_can('edit_theme_options')) {
276
- foreach($this->taxonomies as $name) {
277
- remove_submenu_page('edit.php?post_type=sidebar','edit-tags.php?taxonomy='.$name.'&amp;post_type=sidebar');
278
- remove_meta_box('tagsdiv-'.$name, 'sidebar', 'side');
279
- remove_meta_box($name.'div', 'sidebar', 'side');
280
- }
281
- } else {
282
- remove_menu_page('edit.php?post_type=sidebar');
283
-
284
- }
285
- }
286
 
287
  /**
288
- *
289
  * Add sidebars to widgets area
290
- *
291
  */
292
  public function create_sidebars() {
293
-
294
  //WP3.1 does not support (array) as post_status
295
  $posts = get_posts(array(
296
  'numberposts' => -1,
297
- 'post_type' => 'sidebar',
298
  'post_status' => 'publish,private,future'
299
  ));
 
 
 
 
 
 
 
 
 
 
 
 
 
300
  foreach($posts as $post) {
 
 
 
 
 
 
 
 
301
  register_sidebar( array(
302
  'name' => $post->post_title,
303
- 'description' => $post->post_excerpt,
304
  'id' => 'ca-sidebar-'.$post->ID,
305
  'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
306
  'after_widget' => '</li>',
307
  'before_title' => '<h3 class="widget-title">',
308
  'after_title' => '</h3>',
309
  ));
310
- }
311
  }
312
 
313
  /**
314
- *
315
  * Add admin column headers
316
- *
317
- * @param array $columns
318
- * @return array
319
  */
320
  public function admin_column_headers($columns) {
321
-
322
- unset($columns['categories'],$columns['tags']);
323
-
324
- return array_merge(
325
- array_slice($columns, 0, 2, true),
326
- array(
327
- 'exposure' => __('Exposure', 'content-aware-sidebars'),
328
- 'handle' => _x('Handle','option', 'content-aware-sidebars'),
329
- 'merge-pos' => __('Merge position', 'content-aware-sidebars')
330
- ),
331
- $columns
332
  );
333
  }
334
 
335
  /**
336
- *
337
  * Make some columns sortable
338
- *
339
- * @param array $columns
340
- * @return array
341
  */
342
  public function admin_column_sortable_headers($columns) {
343
  return array_merge(
@@ -345,137 +360,123 @@ final class ContentAwareSidebars {
345
  'exposure' => 'exposure',
346
  'handle' => 'handle',
347
  'merge-pos' => 'merge-pos'
348
- ),
349
- $columns
350
  );
351
  }
352
 
353
  /**
354
- *
355
  * Manage custom column sorting
356
- *
357
- * @param array $vars
358
  * @return array
359
  */
360
  public function admin_column_orderby($vars) {
361
- if (isset($vars['orderby']) && in_array($vars['orderby'],array('exposure','handle','merge-pos'))) {
362
- $vars = array_merge( $vars, array(
363
- 'meta_key' => self::prefix.$vars['orderby'],
364
- 'orderby' => 'meta_value'
365
- ) );
366
  }
367
  return $vars;
368
  }
369
 
370
  /**
371
- *
372
  * Add admin column rows
373
- *
374
- * @param string $column_name
375
- * @param int $post_id
376
- * @return void
377
  */
378
- public function admin_column_rows($column_name,$post_id) {
379
-
380
- if(get_post_type($post_id) != 'sidebar')
381
  return;
382
-
383
  // Load metadata
384
- if(!$this->metadata) $this->_init_metadata();
385
-
386
- $current = get_post_meta($post_id,self::prefix.$column_name,true);
 
387
  $current_from_list = $this->metadata[$column_name]['list'][$current];
388
-
389
- if($column_name == 'handle' && $current < 2) {
390
- $host = get_post_meta($post_id,self::prefix.'host',true);
391
- $current_from_list .= ": ".(isset($this->metadata['host']['list'][$host]) ? $this->metadata['host']['list'][$host] : '<span style="color:red;">'.__('Please update Host Sidebar','content-aware-sidebars').'</span>');
392
- }
393
  echo $current_from_list;
394
  }
395
 
396
  /**
397
- *
398
  * Remove widget when its sidebar is removed
399
- *
400
- * @param int $post_id
401
- * @return void
402
  */
403
  public function remove_sidebar_widgets($post_id) {
404
-
405
  // Authenticate and only continue on sidebar post type
406
- if(!current_user_can('edit_theme_options') || get_post_type($post_id) != 'sidebar')
407
  return;
408
-
409
- $id = 'ca-sidebar-'.$post_id;
410
-
411
  //Get widgets
412
  $sidebars_widgets = wp_get_sidebars_widgets();
413
-
414
  // Check if sidebar exists in database
415
- if(!isset($sidebars_widgets[$id]))
416
  return;
417
-
418
  // Remove widgets settings from sidebar
419
- foreach($sidebars_widgets[$id] as $widget_id) {
420
- $widget_type = preg_replace( '/-[0-9]+$/', '', $widget_id );
421
- $widget_settings = get_option('widget_'.$widget_type);
422
- $widget_id = substr($widget_id,strpos($widget_id,'-')+1);
423
- if($widget_settings && isset($widget_settings[$widget_id])) {
424
  unset($widget_settings[$widget_id]);
425
- update_option('widget_'.$widget_type,$widget_settings);
426
  }
427
  }
428
-
429
  // Remove sidebar
430
  unset($sidebars_widgets[$id]);
431
  wp_set_sidebars_widgets($sidebars_widgets);
432
-
433
-
434
  }
435
 
436
  /**
437
- *
438
  * Add admin rows actions
439
- *
440
- * @param array $actions
441
- * @param object $post
442
  * @return array
443
  */
444
  public function sidebar_row_actions($actions, $post) {
445
- if($post->post_type == 'sidebar' && $post->post_status != 'trash') {
446
-
447
  //View link is still there in WP3.1
448
- if(isset($actions['view']))
449
- unset($actions['view']);
450
-
451
  return array_merge(
452
- array_slice($actions, 0, 2, true),
453
- array(
454
- 'mng_widgets' => '<a href="widgets.php" title="'.esc_html(__( 'Manage Widgets','content-aware-sidebars')).'">'.__( 'Manage Widgets','content-aware-sidebars').'</a>'
455
- ),
456
- $actions
457
  );
458
  }
459
  return $actions;
460
  }
461
 
462
  /**
463
- *
464
- * Replace or merge a sidebar with content aware sidebars
465
- * Handles content aware sidebars with hosts
466
- *
467
  * @global array $_wp_sidebars_widgets
468
  * @return void
469
  */
470
  public function replace_sidebar() {
471
  global $_wp_sidebars_widgets;
472
-
473
  $posts = $this->get_sidebars();
474
- if(!$posts)
475
  return;
476
-
477
- foreach($posts as $post) {
478
-
 
479
  // // Filter out sidebars with dependent content rules not present. Archives not yet decided.
480
  // if(!(is_archive() || (is_home() && !is_front_page()))) {
481
  // $continue = false;
@@ -484,77 +485,75 @@ final class ContentAwareSidebars {
484
  // continue;
485
  // }
486
  //
487
- $id = 'ca-sidebar-'.$post->ID;
488
- $host = get_post_meta($post->ID, self::prefix.'host', true);
489
-
490
  // Check for correct handling and if host exist
491
  if ($post->handle == 2 || !isset($_wp_sidebars_widgets[$host]))
492
  continue;
493
-
494
  // Sidebar might not have any widgets. Get it anyway!
495
- if(!isset($_wp_sidebars_widgets[$id]))
496
  $_wp_sidebars_widgets[$id] = array();
497
-
498
  // If host has already been replaced, merge with it instead. Might change in future.
499
- if($post->handle || isset($handled_already[$host])) {
500
- if(get_post_meta($post->ID, self::prefix.'merge-pos', true))
501
- $_wp_sidebars_widgets[$host] = array_merge($_wp_sidebars_widgets[$host],$_wp_sidebars_widgets[$id]);
502
  else
503
- $_wp_sidebars_widgets[$host] = array_merge($_wp_sidebars_widgets[$id],$_wp_sidebars_widgets[$host]);
504
  } else {
505
  $_wp_sidebars_widgets[$host] = $_wp_sidebars_widgets[$id];
506
  $handled_already[$host] = 1;
507
- }
508
  }
509
  }
510
 
511
  /**
512
- *
513
  * Show manually handled content aware sidebars
514
- *
515
  * @global array $_wp_sidebars_widgets
516
- * @param string|array $args
517
- * @return void
518
  */
519
  public function manual_sidebar($args) {
520
  global $_wp_sidebars_widgets;
521
-
522
  // Grab args or defaults
523
- $args = wp_parse_args($args,array(
524
- 'include' => '',
525
- 'before' => '<div id="sidebar" class="widget-area"><ul class="xoxo">',
526
- 'after' => '</ul></div>'
527
  ));
528
- extract($args,EXTR_SKIP);
529
 
530
  // Get sidebars
531
  $posts = $this->get_sidebars();
532
- if(!$posts)
533
  return;
534
 
535
  // Handle include argument
536
- if(!empty($include)) {
537
- if(!is_array($include))
538
- $include = explode(',',$include);
539
  // Fast lookup
540
  $include = array_flip($include);
541
  }
542
 
543
- $i = $host = 0;
544
- foreach($posts as $post) {
545
 
546
- $id = 'ca-sidebar-'.$post->ID;
547
 
548
  // Check for manual handling, if sidebar exists and if id should be included
549
  if ($post->handle != 2 || !isset($_wp_sidebars_widgets[$id]) || (!empty($include) && !isset($include[$post->ID])))
550
  continue;
551
 
552
  // Merge if more than one. First one is host.
553
- if($i > 0) {
554
- if(get_post_meta($post->ID, self::prefix.'merge-pos', true))
555
- $_wp_sidebars_widgets[$host] = array_merge($_wp_sidebars_widgets[$host],$_wp_sidebars_widgets[$id]);
556
  else
557
- $_wp_sidebars_widgets[$host] = array_merge($_wp_sidebars_widgets[$id],$_wp_sidebars_widgets[$host]);
558
  } else {
559
  $host = $id;
560
  }
@@ -567,11 +566,9 @@ final class ContentAwareSidebars {
567
  echo $after;
568
  }
569
  }
570
-
571
  /**
572
- *
573
  * Query sidebars according to content
574
- *
575
  * @global type $wpdb
576
  * @return array|boolean
577
  */
@@ -621,7 +618,7 @@ final class ContentAwareSidebars {
621
  AND exposure.meta_key = '".self::prefix."exposure'
622
  ".implode(' ',$joins)."
623
  WHERE
624
- posts.post_type = 'sidebar' AND
625
  exposure.meta_value ".(is_archive() || is_home() ? '>' : '<')."= '1' AND
626
  posts.post_status ".(current_user_can('read_private_posts') ? "IN('publish','private')" : "= 'publish'")." AND
627
  (".implode(' AND ',$where).($where2 ? ' AND ('.implode(' OR ',$where2).')' : '').")
@@ -633,78 +630,119 @@ final class ContentAwareSidebars {
633
  return (empty($this->sidebar_cache) ? $this->sidebar_cache[0] = false : $this->sidebar_cache);
634
 
635
  }
636
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
637
  /**
638
- *
639
  * Meta boxes for sidebar edit
640
- *
 
641
  */
642
  public function create_meta_boxes() {
643
-
644
- // Load metadata
645
- $this->_init_metadata();
 
 
646
 
647
  // Add boxes
648
- // Author Words
649
- add_meta_box(
650
- 'cas-dev-words',
651
- __('Words from the author', 'content-aware-sidebars'),
652
- array(&$this,'meta_box_author_words'),
653
- 'sidebar',
654
- 'side',
655
- 'high'
656
- );
657
-
658
  // Module rules
659
  add_meta_box(
660
  'cas-rules',
661
- __('Content', 'content-aware-sidebars'),
662
- array(&$this,'meta_box_rules'),
663
- 'sidebar',
664
  'normal',
665
  'high'
666
  );
667
-
668
  // Options
669
  add_meta_box(
670
  'cas-options',
671
- __('Options', 'content-aware-sidebars'),
672
- array(&$this,'meta_box_options'),
673
- 'sidebar',
674
  'side'
675
  );
 
 
 
 
 
 
 
 
 
 
676
  }
677
 
678
-
679
  /**
680
- *
681
  * Hide some meta boxes from start
682
- *
683
- * @param array $hidden
684
- * @param object $screen
685
  * @return array
686
  */
687
- public function change_default_hidden( $hidden, $screen ) {
688
 
689
  //WordPress 3.3 has changed get_hidden_meta_boxes().
690
- if(get_bloginfo('version') < 3.3) {
691
- $condition = $screen->base == 'sidebar';
692
  } else {
693
- $condition = $screen->post_type == 'sidebar';
694
  }
695
-
696
- if ($condition && get_user_option( 'metaboxhidden_sidebar' ) === false) {
697
-
698
- $hidden_meta_boxes = array('postexcerpt','pageparentdiv');
699
- $hidden = array_merge($hidden,$hidden_meta_boxes);
700
-
701
  $user = wp_get_current_user();
702
- update_user_option( $user->ID, 'metaboxhidden_sidebar', $hidden, true );
703
-
704
  }
705
  return $hidden;
706
  }
707
 
 
 
 
 
708
  public function meta_box_rules() {
709
  // global $pagenow;
710
  //
@@ -724,262 +762,224 @@ final class ContentAwareSidebars {
724
  }
725
 
726
  /**
727
- *
728
- * Options content
729
- *
730
  */
731
  public function meta_box_options() {
732
-
733
  $columns = array(
734
  'exposure',
735
  'handle' => 'handle,host',
736
  'merge-pos'
737
  );
738
-
739
- foreach($columns as $key => $value) {
740
-
741
- echo '<span>'.$this->metadata[is_numeric($key) ? $value : $key]['name'].':';
742
  echo '<p>';
743
- $values = explode(',',$value);
744
- foreach($values as $val) {
745
  $this->_form_field($val);
746
  }
747
  echo '</p></span>';
748
  }
749
  }
750
-
751
  /**
752
- *
753
- * Author words content
754
- *
755
  */
756
  public function meta_box_author_words() {
757
-
758
  // Use nonce for verification
759
- wp_nonce_field(basename(__FILE__),'_ca-sidebar-nonce');
760
- ?>
761
- <div style="overflow:hidden;">
762
- <p><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=KPZHE6A72LEN4&lc=US&item_name=WordPress%20Plugin%3a%20Content%20Aware%20Sidebars&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"
763
- target="_blank" title="PayPal - The safer, easier way to pay online!">
764
- <img align="right" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" width="147" height="47" alt="PayPal - The safer, easier way to pay online!">
765
- </a></p>
766
- <p><?php _e('If you love this plugin, please consider donating.', 'content-aware-sidebars'); ?></p>
767
- <br />
768
- <p><?php printf(__('Remember to <a class="button" href="%1$s" target="_blank">rate</a> and <a class="button" href="%2$s" target="_blank">share</a> it too!', 'content-aware-sidebars'),
769
- 'http://wordpress.org/extend/plugins/content-aware-sidebars/',
770
- 'http://twitter.com/?status='.__('Check out Content Aware Sidebars for %23WordPress! :)','content-aware-sidebars').' http://tiny.cc/ca-sidebars'
771
- ); ?></p>
772
- <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://wordpress.org/extend/plugins/content-aware-sidebars/" data-text="<?php _e('Check out Content Aware Sidebars :)','content-aware-sidebars') ?>" data-hashtags="WordPress">Tweet</a>
773
- <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
774
- <iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwordpress.org%2Fextend%2Fplugins%2Fcontent-aware-sidebars%2F&amp;send=false&amp;layout=button_count&amp;width=150&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21&amp;appId=200775686659011" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:21px;" allowTransparency="true"></iframe>
775
- </div>
 
 
 
 
776
  <?php
777
  }
778
-
779
  /**
780
- *
781
  * Create form field for metadata
782
- *
783
  * @global object $post
784
- * @param array $setting
 
785
  */
786
  private function _form_field($setting) {
787
  global $post;
788
-
789
- $meta = get_post_meta($post->ID, self::prefix.$setting, true);
790
  $setting = $this->metadata[$setting];
791
  $current = $meta != '' ? $meta : $setting['val'];
792
- switch($setting['type']) {
793
- case 'select' :
794
- echo '<select style="width:250px;" name="'.$setting['id'].'">'."\n";
795
- foreach($setting['list'] as $key => $value) {
796
- echo '<option value="'.$key.'"'.($key == $current ? ' selected="selected"' : '').'>'.$value.'</option>'."\n";
797
  }
798
- echo '</select>'."\n";
799
  break;
800
  case 'checkbox' :
801
- echo '<ul>'."\n";
802
- foreach($setting['list'] as $key => $value) {
803
- echo '<li><label><input type="checkbox" name="'.$setting['id'].'[]" value="'.$key.'"'.(in_array($key,$current) ? ' checked="checked"' : '').' /> '.$value.'</label></li>'."\n";
804
  }
805
- echo '</ul>'."\n";
806
  break;
807
  case 'text' :
808
  default :
809
- echo '<input style="width:200px;" type="text" name="'.$setting['id'].'" value="'.$current.'" />'."\n";
810
  break;
811
  }
812
  }
813
-
814
  /**
815
- *
816
  * Save meta values for post
817
- *
818
- * @param int $post_id
819
  * @return void
820
  */
821
  public function save_post($post_id) {
822
-
823
  // Save button pressed
824
- if(!isset($_POST['original_publish']) && !isset($_POST['save_post']))
825
  return;
826
-
827
  // Only sidebar type
828
- if(get_post_type($post_id) != 'sidebar')
829
- return;
830
-
831
  // Verify nonce
832
- if (!check_admin_referer(basename(__FILE__),'_ca-sidebar-nonce'))
833
  return;
834
-
835
  // Check permissions
836
  if (!current_user_can('edit_theme_options', $post_id))
837
  return;
838
-
839
  // Check autosave
840
  if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
841
  return;
842
-
843
  // Load metadata
844
  $this->_init_metadata();
845
-
846
  // Update metadata
847
- foreach ($this->metadata as $field) {
848
  $new = isset($_POST[$field['id']]) ? $_POST[$field['id']] : '';
849
- $old = get_post_meta($post_id, self::prefix.$field['id'], true);
850
-
851
- if ($new != '' && $new != $old) {
852
- update_post_meta($post_id, self::prefix.$field['id'], $new);
853
  } elseif ($new == '' && $old != '') {
854
- delete_post_meta($post_id, self::prefix.$field['id'], $old);
855
  }
856
  }
857
  // Update module data
858
  foreach ($this->modules as $module) {
859
- $new = isset($_POST[$module->get_id()]) ? $_POST[$module->get_id()] : '';
860
- $old = array_flip(get_post_meta($post_id, self::prefix.$module->get_id(), false));
861
-
862
- if(is_array($new)) {
 
863
  // Skip existing data or insert new data
864
- foreach($new as $new_single) {
865
- if(isset($old[$new_single])) {
866
  unset($old[$new_single]);
867
  } else {
868
- add_post_meta($post_id, self::prefix.$module->get_id(), $new_single);
869
  }
870
  }
871
  // Remove existing data that have not been skipped
872
- foreach($old as $old_key => $old_value) {
873
- delete_post_meta($post_id, self::prefix.$module->get_id(), $old_key);
874
  }
875
- } elseif(!empty($old)) {
876
  // Remove any old values when $new is empty
877
- delete_post_meta($post_id, self::prefix.$module->get_id());
878
  }
879
  }
880
  }
881
-
882
- /**
883
- *
884
- * @param int $term_id
885
- * @param int $tt_id
886
- * @param string $taxonomy
887
- * @return void
888
- */
889
- public function term_ancestry_check($term_id, $tt_id, $taxonomy) {
890
-
891
- if(is_taxonomy_hierarchical($taxonomy)) {
892
- $term = get_term($term_id, $taxonomy);
893
- //var_dump($term);
894
- }
895
-
896
- // Save button pressed
897
- // if(!isset($_POST['original_publish']) && !isset($_POST['save_post']))
898
- // return;
899
- //
900
- // // Check autosave
901
- // if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
902
- // return;
903
-
904
- //$post = get_post($post_id);
905
-
906
- // Only other types than sidebar
907
- // if(get_post_type($post_id) == 'sidebar')
908
- // return;
909
-
910
-
911
 
912
- }
913
-
914
  /**
915
- *
916
  * Database data update module
917
- *
918
  */
919
  public function db_update() {
920
  cas_run_db_update(self::db_version);
921
  }
922
-
923
  /**
924
- *
925
  * Load scripts and styles for administration
926
- *
927
- * @param string $hook
928
  */
929
  public function load_admin_scripts($hook) {
930
-
931
- wp_register_script('cas_admin_script', WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__)).'/js/cas_admin.js', array('jquery'), '0.1', true);
932
- wp_register_style('cas_admin_style', WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__)).'/css/style.css', array(), '0.1');
933
-
934
- if($hook == 'post.php' || $hook == 'post-new.php') {
935
- // WordPress < 3.3 does not have jQuery UI accordion
936
- if(get_bloginfo('version') < 3.3) {
937
- wp_register_script('cas-jquery-ui-accordion', WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__)).'/js/jquery.ui.accordion.js', array('jquery-ui-core','jquery-ui-widget'), '1.8.9', true);
 
 
938
  wp_enqueue_script('cas-jquery-ui-accordion');
939
  } else {
940
  wp_enqueue_script('jquery-ui-accordion');
 
941
  }
942
  wp_enqueue_script('cas_admin_script');
943
-
944
  wp_enqueue_style('cas_admin_style');
945
- } else if($hook == 'edit.php') {
946
  wp_enqueue_style('cas_admin_style');
947
  }
948
-
949
  }
950
 
951
  /**
952
- *
953
  * Load dependencies
954
- *
955
  */
956
  private function _load_dependencies() {
957
-
958
- require_once('walker.php');
959
- require_once('update_db.php');
960
- require_once('modules/abstract.php');
961
-
962
  }
963
 
964
  /**
965
- *
966
  * Flush rewrite rules on plugin activation
967
- *
968
  */
969
  public function plugin_activation() {
970
  $this->init_sidebar_type();
971
  flush_rewrite_rules();
972
  }
973
-
974
  /**
975
- *
976
  * Flush rewrite rules on plugin deactivation
977
- *
978
  */
979
  public function plugin_deactivation() {
980
  flush_rewrite_rules();
981
  }
982
-
983
  }
984
 
985
  // Launch plugin
@@ -987,11 +987,10 @@ global $ca_sidebars;
987
  $ca_sidebars = new ContentAwareSidebars();
988
 
989
  /**
990
- *
991
- * Template wrapper function
992
- *
993
  * @global object $ca_sidebars
994
- * @param array|string $args
 
995
  */
996
  function display_ca_sidebar($args = array()) {
997
  global $ca_sidebars;
7
  Plugin Name: Content Aware Sidebars
8
  Plugin URI: http://www.intox.dk/
9
  Description: Manage and show sidebars according to the content being viewed.
10
+ Version: 1.3.1
11
+ Author: Joachim Jensen, Intox Studio
12
  Author URI: http://www.intox.dk/
13
  Text Domain: content-aware-sidebars
14
  Domain Path: /lang/
15
  License: GPL2
16
 
17
+ Copyright 2011-2013 Joachim Jensen (email : jv@intox.dk)
18
 
19
+ This program is free software; you can redistribute it and/or modify
20
+ it under the terms of the GNU General Public License, version 2, as
21
+ published by the Free Software Foundation.
22
 
23
+ This program is distributed in the hope that it will be useful,
24
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
25
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
+ GNU General Public License for more details.
27
 
28
+ You should have received a copy of the GNU General Public License
29
+ along with this program; if not, write to the Free Software
30
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31
 
32
  */
33
 
34
  final class ContentAwareSidebars {
35
 
36
+ /**
37
+ * Database version for update module
38
+ */
39
  const db_version = 1.1;
40
+
41
+ /**
42
+ * Prefix for data (keys) stored in database
43
+ */
44
  const prefix = '_cas_';
45
+
46
+ /**
47
+ * Post Type for sidebars
48
+ */
49
+ const type_sidebar = 'sidebar';
50
+
51
+ /**
52
+ * Language domain
53
+ */
54
+ const domain = 'content-aware-sidebars';
55
 
56
+ /**
57
+ * Plugin basename
58
+ * @var string
59
+ */
60
+ private $basename;
61
+
62
+ /**
63
+ * Sidebar metadata
64
+ * @var array
65
+ */
66
  private $metadata = array();
67
+
68
+ /**
69
+ * Sidebars retrieved from database
70
+ * @var array
71
+ */
72
  private $sidebar_cache = array();
73
+
74
+ /**
75
+ * Modules for specific content or cases
76
+ * @var array
77
+ */
78
  private $modules = array();
79
 
80
  /**
 
81
  * Constructor
 
82
  */
83
  public function __construct() {
84
+
85
+ $this->basename = dirname(plugin_basename(__FILE__));
86
 
87
+ register_activation_hook(__FILE__, array(&$this,'plugin_activation'));
88
+ register_deactivation_hook(__FILE__, array(&$this,'plugin_deactivation'));
 
 
89
 
90
  $this->_load_dependencies();
91
 
92
  // WordPress Hooks. Somewhat ordered by execution
93
 
94
  // On sitewide requests
95
+ add_action('plugins_loaded', array(&$this,'deploy_modules'));
96
+ add_action('init', array(&$this,'init_sidebar_type'),99);
97
+ add_action('wp_loaded', array(&$this,'create_sidebars'),99);
98
 
99
+ // On admin requests
100
+ add_action('admin_enqueue_scripts', array(&$this,'load_admin_scripts'));
 
101
 
102
  // On post type and taxonomy requests
103
+ add_action('delete_post', array(&$this,'remove_sidebar_widgets'));
104
+ add_action('save_post', array(&$this,'save_post'));
105
 
106
  // Order not known yet
107
+ add_action('add_meta_boxes_'.self::type_sidebar, array(&$this,'create_meta_boxes'));
108
+ add_action('in_admin_header', array(&$this,'clear_admin_menu'),99);
109
+
110
+ add_filter('default_hidden_meta_boxes', array(&$this,'change_default_hidden'),10,2);
111
+ add_filter('manage_edit-'.self::type_sidebar.'_columns', array(&$this,'admin_column_headers'),99);
112
+ add_filter('manage_edit-'.self::type_sidebar.'_sortable_columns', array(&$this,'admin_column_sortable_headers'));
113
+ add_filter('manage_posts_custom_column', array(&$this,'admin_column_rows'),10,3);
114
+ add_filter('post_row_actions', array(&$this,'sidebar_row_actions'),10,2);
115
+ add_filter('post_updated_messages', array(&$this,'sidebar_updated_messages'));
116
+
117
  // Sitewide hooks that should not be loaded sitewide here
118
  if(is_admin()) {
119
+ add_filter('request', array(&$this,'admin_column_orderby'));
120
 
121
+ add_action('wp_loaded', array(&$this,'db_update'));
122
  } else {
123
+ add_filter('wp', array(&$this,'replace_sidebar'));
124
  }
125
 
126
  }
127
 
128
  /**
 
129
  * Deploy modules
130
+ * @return void
131
  */
132
  public function deploy_modules() {
133
+
134
+ load_plugin_textdomain(self::domain, false, $this->basename.'/lang/');
135
 
136
  // List modules
137
  $modules = array(
140
  'author' => true,
141
  'page_template' => true,
142
  'taxonomy' => true,
143
+ 'url' => false,
144
  'bbpress' => function_exists('bbp_get_version'), // bbPress
145
  'bp_member' => defined('BP_VERSION'), // BuddyPress
146
  'polylang' => defined('POLYLANG_VERSION'), // Polylang
151
 
152
  // Forge modules
153
  foreach($modules as $name => $enabled) {
154
+ if($enabled && include('modules/'.$name .'.php')) {
155
  $class = 'CASModule_'.$name;
156
  $this->modules[$name] = new $class;
157
  }
160
  }
161
 
162
  /**
 
163
  * Create post meta fields
 
 
164
  * @global array $wp_registered_sidebars
165
+ * @return void
166
  */
167
  private function _init_metadata() {
168
+ global $wp_registered_sidebars;
169
+
170
  // List of sidebars
171
  $sidebar_list = array();
172
  foreach($wp_registered_sidebars as $sidebar) {
173
+ $sidebar_list[$sidebar['id']] = $sidebar['name'];
 
174
  }
175
+
176
  // Meta fields
177
  $this->metadata['exposure'] = array(
178
+ 'name' => __('Exposure', self::domain),
179
  'id' => 'exposure',
180
  'desc' => '',
181
  'val' => 1,
182
  'type' => 'select',
183
  'list' => array(
184
+ __('Singular', self::domain),
185
+ __('Singular & Archive', self::domain),
186
+ __('Archive', self::domain)
187
  )
188
  );
189
  $this->metadata['handle'] = array(
190
+ 'name' => _x('Handle','option', self::domain),
191
  'id' => 'handle',
192
+ 'desc' => __('Replace host sidebar, merge with it or add sidebar manually.', self::domain),
193
  'val' => 0,
194
  'type' => 'select',
195
  'list' => array(
196
+ __('Replace', self::domain),
197
+ __('Merge', self::domain),
198
+ __('Manual', self::domain)
199
  )
200
  );
201
  $this->metadata['host'] = array(
202
+ 'name' => __('Host Sidebar', self::domain),
203
  'id' => 'host',
204
  'desc' => '',
205
  'val' => 'sidebar-1',
207
  'list' => $sidebar_list
208
  );
209
  $this->metadata['merge-pos'] = array(
210
+ 'name' => __('Merge position', self::domain),
211
  'id' => 'merge-pos',
212
+ 'desc' => __('Place sidebar on top or bottom of host when merging.', self::domain),
213
  'val' => 1,
214
  'type' => 'select',
215
  'list' => array(
216
+ __('Top', self::domain),
217
+ __('Bottom', self::domain)
218
  )
219
  );
220
 
221
  }
222
 
223
  /**
224
+ * Create sidebar post type
225
+ * @return void
 
226
  */
227
  public function init_sidebar_type() {
228
 
 
 
 
 
 
229
  // Register the sidebar type
230
+ register_post_type(self::type_sidebar,array(
231
  'labels' => array(
232
+ 'name' => __('Sidebars', self::domain),
233
+ 'singular_name' => __('Sidebar', self::domain),
234
+ 'add_new' => _x('Add New', 'sidebar', self::domain),
235
+ 'add_new_item' => __('Add New Sidebar', self::domain),
236
+ 'edit_item' => __('Edit Sidebar', self::domain),
237
+ 'new_item' => __('New Sidebar', self::domain),
238
+ 'all_items' => __('All Sidebars', self::domain),
239
+ 'view_item' => __('View Sidebar', self::domain),
240
+ 'search_items' => __('Search Sidebars', self::domain),
241
+ 'not_found' => __('No sidebars found', self::domain),
242
+ 'not_found_in_trash' => __('No sidebars found in Trash', self::domain)
243
  ),
244
  'capabilities' => array(
245
  'edit_post' => 'edit_theme_options',
250
  'publish_posts' => 'edit_theme_options',
251
  'read_private_posts' => 'edit_theme_options'
252
  ),
253
+ 'show_ui' => true,
254
+ 'show_in_menu' => true, //current_user_can('edit_theme_options'),
255
  'query_var' => false,
256
  'rewrite' => false,
257
  'menu_position' => null,
258
+ 'supports' => array('title','page-attributes'),
259
+ 'menu_icon' => WP_PLUGIN_URL.'/'.$this->basename.'/img/icon-16.png'
 
260
  ));
261
  }
262
 
263
  /**
 
264
  * Create update messages
 
265
  * @global object $post
266
+ * @param array $messages
267
+ * @return array
268
  */
269
  public function sidebar_updated_messages( $messages ) {
270
  global $post;
271
+ $messages[self::type_sidebar] = array(
272
  0 => '',
273
+ 1 => sprintf(__('Sidebar updated. <a href="%s">Manage widgets</a>',self::domain),'widgets.php'),
274
  2 => '',
275
  3 => '',
276
+ 4 => __('Sidebar updated.',self::domain),
277
  5 => '',
278
+ 6 => sprintf(__('Sidebar published. <a href="%s">Manage widgets</a>',self::domain), 'widgets.php'),
279
+ 7 => __('Sidebar saved.',self::domain),
280
+ 8 => sprintf(__('Sidebar submitted. <a href="%s">Manage widgets</a>',self::domain),'widgets.php'),
281
+ 9 => sprintf(__('Sidebar scheduled for: <strong>%1$s</strong>. <a href="%2$s">Manage widgets</a>',self::domain),
282
  // translators: Publish box date format, see http://php.net/date
283
  date_i18n(__('M j, Y @ G:i'),strtotime($post->post_date)),'widgets.php'),
284
+ 10 => __('Sidebar draft updated.',self::domain),
285
  );
286
  return $messages;
287
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
 
289
  /**
 
290
  * Add sidebars to widgets area
291
+ * @return void
292
  */
293
  public function create_sidebars() {
294
+
295
  //WP3.1 does not support (array) as post_status
296
  $posts = get_posts(array(
297
  'numberposts' => -1,
298
+ 'post_type' => self::type_sidebar,
299
  'post_status' => 'publish,private,future'
300
  ));
301
+
302
+ //Register sidebars to add them to the list
303
+ foreach($posts as $post) {
304
+ register_sidebar( array(
305
+ 'name' => $post->post_title,
306
+ 'id' => 'ca-sidebar-'.$post->ID
307
+ ));
308
+ }
309
+
310
+ //Init metadata
311
+ $this->_init_metadata();
312
+
313
+ //Now reregister sidebars with proper content
314
  foreach($posts as $post) {
315
+
316
+ $handle = get_post_meta($post->ID, self::prefix . 'handle', true);
317
+ $desc = $this->metadata['handle']['list'][$handle];
318
+
319
+ if ($handle < 2) {
320
+ $host = get_post_meta($post->ID, self::prefix . 'host', true);
321
+ $desc .= ": " . (isset($this->metadata['host']['list'][$host]) ? $this->metadata['host']['list'][$host] : __('Please update Host Sidebar', self::domain) );
322
+ }
323
  register_sidebar( array(
324
  'name' => $post->post_title,
325
+ 'description' => $desc,
326
  'id' => 'ca-sidebar-'.$post->ID,
327
  'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
328
  'after_widget' => '</li>',
329
  'before_title' => '<h3 class="widget-title">',
330
  'after_title' => '</h3>',
331
  ));
332
+ }
333
  }
334
 
335
  /**
 
336
  * Add admin column headers
337
+ * @param array $columns
338
+ * @return array
 
339
  */
340
  public function admin_column_headers($columns) {
341
+ // Totally discard current columns and rebuild
342
+ return array(
343
+ 'cb' => $columns['cb'],
344
+ 'title' => $columns['title'],
345
+ 'exposure' => __('Exposure', self::domain),
346
+ 'handle' => _x('Handle','option', self::domain),
347
+ 'merge-pos' => __('Merge position', self::domain),
348
+ 'date' => $columns['date']
 
 
 
349
  );
350
  }
351
 
352
  /**
 
353
  * Make some columns sortable
354
+ * @param array $columns
355
+ * @return array
 
356
  */
357
  public function admin_column_sortable_headers($columns) {
358
  return array_merge(
360
  'exposure' => 'exposure',
361
  'handle' => 'handle',
362
  'merge-pos' => 'merge-pos'
363
+ ), $columns
 
364
  );
365
  }
366
 
367
  /**
 
368
  * Manage custom column sorting
369
+ * @param array $vars
 
370
  * @return array
371
  */
372
  public function admin_column_orderby($vars) {
373
+ if (isset($vars['orderby']) && in_array($vars['orderby'], array('exposure', 'handle', 'merge-pos'))) {
374
+ $vars = array_merge($vars, array(
375
+ 'meta_key' => self::prefix . $vars['orderby'],
376
+ 'orderby' => 'meta_value'
377
+ ));
378
  }
379
  return $vars;
380
  }
381
 
382
  /**
 
383
  * Add admin column rows
384
+ * @param string $column_name
385
+ * @param int $post_id
386
+ * @return void
 
387
  */
388
+ public function admin_column_rows($column_name, $post_id) {
389
+
390
+ if (get_post_type($post_id) != self::type_sidebar)
391
  return;
392
+
393
  // Load metadata
394
+ if (!$this->metadata)
395
+ $this->_init_metadata();
396
+
397
+ $current = get_post_meta($post_id, self::prefix . $column_name, true);
398
  $current_from_list = $this->metadata[$column_name]['list'][$current];
399
+
400
+ if ($column_name == 'handle' && $current < 2) {
401
+ $host = get_post_meta($post_id, self::prefix . 'host', true);
402
+ $current_from_list .= ": " . (isset($this->metadata['host']['list'][$host]) ? $this->metadata['host']['list'][$host] : '<span style="color:red;">' . __('Please update Host Sidebar', self::domain) . '</span>');
403
+ }
404
  echo $current_from_list;
405
  }
406
 
407
  /**
 
408
  * Remove widget when its sidebar is removed
409
+ * @param int $post_id
410
+ * @return void
 
411
  */
412
  public function remove_sidebar_widgets($post_id) {
413
+
414
  // Authenticate and only continue on sidebar post type
415
+ if (!current_user_can('edit_theme_options') || get_post_type($post_id) != self::type_sidebar)
416
  return;
417
+
418
+ $id = 'ca-sidebar-' . $post_id;
419
+
420
  //Get widgets
421
  $sidebars_widgets = wp_get_sidebars_widgets();
422
+
423
  // Check if sidebar exists in database
424
+ if (!isset($sidebars_widgets[$id]))
425
  return;
426
+
427
  // Remove widgets settings from sidebar
428
+ foreach ($sidebars_widgets[$id] as $widget_id) {
429
+ $widget_type = preg_replace('/-[0-9]+$/', '', $widget_id);
430
+ $widget_settings = get_option('widget_' . $widget_type);
431
+ $widget_id = substr($widget_id, strpos($widget_id, '-') + 1);
432
+ if ($widget_settings && isset($widget_settings[$widget_id])) {
433
  unset($widget_settings[$widget_id]);
434
+ update_option('widget_' . $widget_type, $widget_settings);
435
  }
436
  }
437
+
438
  // Remove sidebar
439
  unset($sidebars_widgets[$id]);
440
  wp_set_sidebars_widgets($sidebars_widgets);
 
 
441
  }
442
 
443
  /**
 
444
  * Add admin rows actions
445
+ * @param array $actions
446
+ * @param object $post
 
447
  * @return array
448
  */
449
  public function sidebar_row_actions($actions, $post) {
450
+ if ($post->post_type == self::type_sidebar && $post->post_status != 'trash') {
451
+
452
  //View link is still there in WP3.1
453
+ unset($actions['view']);
454
+
 
455
  return array_merge(
456
+ array_slice($actions, 0, 2, true), array(
457
+ 'mng_widgets' => '<a href="widgets.php" title="' . esc_html(__('Manage Widgets', self::domain)) . '">' . __('Manage Widgets', self::domain) . '</a>'
458
+ ), $actions
 
 
459
  );
460
  }
461
  return $actions;
462
  }
463
 
464
  /**
465
+ * Replace or merge a sidebar with content aware sidebars.
466
+ * Handles sidebars with hosts
 
 
467
  * @global array $_wp_sidebars_widgets
468
  * @return void
469
  */
470
  public function replace_sidebar() {
471
  global $_wp_sidebars_widgets;
472
+
473
  $posts = $this->get_sidebars();
474
+ if (!$posts)
475
  return;
476
+
477
+ foreach ($posts as $post) {
478
+
479
+ // TODO
480
  // // Filter out sidebars with dependent content rules not present. Archives not yet decided.
481
  // if(!(is_archive() || (is_home() && !is_front_page()))) {
482
  // $continue = false;
485
  // continue;
486
  // }
487
  //
488
+ $id = 'ca-sidebar-' . $post->ID;
489
+ $host = get_post_meta($post->ID, self::prefix . 'host', true);
490
+
491
  // Check for correct handling and if host exist
492
  if ($post->handle == 2 || !isset($_wp_sidebars_widgets[$host]))
493
  continue;
494
+
495
  // Sidebar might not have any widgets. Get it anyway!
496
+ if (!isset($_wp_sidebars_widgets[$id]))
497
  $_wp_sidebars_widgets[$id] = array();
498
+
499
  // If host has already been replaced, merge with it instead. Might change in future.
500
+ if ($post->handle || isset($handled_already[$host])) {
501
+ if (get_post_meta($post->ID, self::prefix . 'merge-pos', true))
502
+ $_wp_sidebars_widgets[$host] = array_merge($_wp_sidebars_widgets[$host], $_wp_sidebars_widgets[$id]);
503
  else
504
+ $_wp_sidebars_widgets[$host] = array_merge($_wp_sidebars_widgets[$id], $_wp_sidebars_widgets[$host]);
505
  } else {
506
  $_wp_sidebars_widgets[$host] = $_wp_sidebars_widgets[$id];
507
  $handled_already[$host] = 1;
508
+ }
509
  }
510
  }
511
 
512
  /**
 
513
  * Show manually handled content aware sidebars
 
514
  * @global array $_wp_sidebars_widgets
515
+ * @param string|array $args
516
+ * @return void
517
  */
518
  public function manual_sidebar($args) {
519
  global $_wp_sidebars_widgets;
520
+
521
  // Grab args or defaults
522
+ $args = wp_parse_args($args, array(
523
+ 'include' => '',
524
+ 'before' => '<div id="sidebar" class="widget-area"><ul class="xoxo">',
525
+ 'after' => '</ul></div>'
526
  ));
527
+ extract($args, EXTR_SKIP);
528
 
529
  // Get sidebars
530
  $posts = $this->get_sidebars();
531
+ if (!$posts)
532
  return;
533
 
534
  // Handle include argument
535
+ if (!empty($include)) {
536
+ if (!is_array($include))
537
+ $include = explode(',', $include);
538
  // Fast lookup
539
  $include = array_flip($include);
540
  }
541
 
542
+ $i = $host = 0;
543
+ foreach ($posts as $post) {
544
 
545
+ $id = 'ca-sidebar-' . $post->ID;
546
 
547
  // Check for manual handling, if sidebar exists and if id should be included
548
  if ($post->handle != 2 || !isset($_wp_sidebars_widgets[$id]) || (!empty($include) && !isset($include[$post->ID])))
549
  continue;
550
 
551
  // Merge if more than one. First one is host.
552
+ if ($i > 0) {
553
+ if (get_post_meta($post->ID, self::prefix . 'merge-pos', true))
554
+ $_wp_sidebars_widgets[$host] = array_merge($_wp_sidebars_widgets[$host], $_wp_sidebars_widgets[$id]);
555
  else
556
+ $_wp_sidebars_widgets[$host] = array_merge($_wp_sidebars_widgets[$id], $_wp_sidebars_widgets[$host]);
557
  } else {
558
  $host = $id;
559
  }
566
  echo $after;
567
  }
568
  }
569
+
570
  /**
 
571
  * Query sidebars according to content
 
572
  * @global type $wpdb
573
  * @return array|boolean
574
  */
618
  AND exposure.meta_key = '".self::prefix."exposure'
619
  ".implode(' ',$joins)."
620
  WHERE
621
+ posts.post_type = '".self::type_sidebar."' AND
622
  exposure.meta_value ".(is_archive() || is_home() ? '>' : '<')."= '1' AND
623
  posts.post_status ".(current_user_can('read_private_posts') ? "IN('publish','private')" : "= 'publish'")." AND
624
  (".implode(' AND ',$where).($where2 ? ' AND ('.implode(' OR ',$where2).')' : '').")
630
  return (empty($this->sidebar_cache) ? $this->sidebar_cache[0] = false : $this->sidebar_cache);
631
 
632
  }
633
+
634
+ /**
635
+ * Remove unwanted meta boxes
636
+ * @return void
637
+ */
638
+ public function clear_admin_menu() {
639
+ global $wp_meta_boxes;
640
+
641
+ $screen = get_current_screen();
642
+
643
+ // Post type not set on all pages in WP3.1
644
+ if(!(isset($screen->post_type) && $screen->post_type == self::type_sidebar && $screen->base == 'post'))
645
+ return;
646
+
647
+ // Names of whitelisted meta boxes
648
+ $whitelist = array(
649
+ 'cas-spread-words' => 'cas-spread-words',
650
+ 'cas-rules' => 'cas-rules',
651
+ 'cas-options' => 'cas-options',
652
+ 'submitdiv' => 'submitdiv',
653
+ 'pageparentdiv' => 'pageparentdiv',
654
+ 'slugdiv' => 'slugdiv'
655
+ );
656
+
657
+ // Loop through context (normal,advanced,side)
658
+ foreach($wp_meta_boxes[self::type_sidebar] as $context_k => $context_v) {
659
+ // Loop through priority (high,core,default,low)
660
+ foreach($context_v as $priority_k => $priority_v) {
661
+ // Loop through boxes
662
+ foreach($priority_v as $box_k => $box_v) {
663
+ // If box is not whitelisted, remove it
664
+ if(!in_array($box_k,$whitelist)) {
665
+ $wp_meta_boxes[self::type_sidebar][$context_k][$priority_k][$box_k] = false;
666
+ //unset($whitelist[$box_k]);
667
+ }
668
+ }
669
+ }
670
+ }
671
+ }
672
+
673
  /**
 
674
  * Meta boxes for sidebar edit
675
+ * @global object $post
676
+ * @return void
677
  */
678
  public function create_meta_boxes() {
679
+ global $post;
680
+
681
+ // Remove ability to set self to host
682
+ if(isset($post))
683
+ unset($this->metadata['host']['list']['ca-sidebar-'.$post->ID]);
684
 
685
  // Add boxes
 
 
 
 
 
 
 
 
 
 
686
  // Module rules
687
  add_meta_box(
688
  'cas-rules',
689
+ __('Content', self::domain),
690
+ array(&$this, 'meta_box_rules'),
691
+ self::type_sidebar,
692
  'normal',
693
  'high'
694
  );
695
+
696
  // Options
697
  add_meta_box(
698
  'cas-options',
699
+ __('Options', self::domain),
700
+ array(&$this, 'meta_box_options'),
701
+ self::type_sidebar,
702
  'side'
703
  );
704
+
705
+ // Author Words
706
+ add_meta_box(
707
+ 'cas-spread-words',
708
+ __('Spread the Word',self::domain),
709
+ array(&$this, 'meta_box_author_words'),
710
+ self::type_sidebar,
711
+ 'side',
712
+ 'high'
713
+ );
714
  }
715
 
 
716
  /**
 
717
  * Hide some meta boxes from start
718
+ * @param array $hidden
719
+ * @param object $screen
 
720
  * @return array
721
  */
722
+ public function change_default_hidden($hidden, $screen) {
723
 
724
  //WordPress 3.3 has changed get_hidden_meta_boxes().
725
+ if (get_bloginfo('version') < 3.3) {
726
+ $condition = $screen->base == self::type_sidebar;
727
  } else {
728
+ $condition = $screen->post_type == self::type_sidebar;
729
  }
730
+
731
+ if ($condition && get_user_option('metaboxhidden_sidebar') === false) {
732
+
733
+ $hidden_meta_boxes = array('pageparentdiv');
734
+ $hidden = array_merge($hidden, $hidden_meta_boxes);
735
+
736
  $user = wp_get_current_user();
737
+ update_user_option($user->ID, 'metaboxhidden_sidebar', $hidden, true);
 
738
  }
739
  return $hidden;
740
  }
741
 
742
+ /**
743
+ * Meta box for content rules
744
+ * @return void
745
+ */
746
  public function meta_box_rules() {
747
  // global $pagenow;
748
  //
762
  }
763
 
764
  /**
765
+ * Meta box for options
766
+ * @return void
 
767
  */
768
  public function meta_box_options() {
769
+
770
  $columns = array(
771
  'exposure',
772
  'handle' => 'handle,host',
773
  'merge-pos'
774
  );
775
+
776
+ foreach ($columns as $key => $value) {
777
+
778
+ echo '<span>' . $this->metadata[is_numeric($key) ? $value : $key]['name'] . ':';
779
  echo '<p>';
780
+ $values = explode(',', $value);
781
+ foreach ($values as $val) {
782
  $this->_form_field($val);
783
  }
784
  echo '</p></span>';
785
  }
786
  }
787
+
788
  /**
789
+ * Meta box for author words
790
+ * @return void
 
791
  */
792
  public function meta_box_author_words() {
793
+
794
  // Use nonce for verification
795
+ wp_nonce_field(basename(__FILE__), '_ca-sidebar-nonce');
796
+ ?>
797
+ <div style="overflow:hidden;">
798
+ <p><?php _e('If you love this plugin, please consider donating to support future development.', self::domain); ?></p>
799
+ <p><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=KPZHE6A72LEN4&amp;lc=US&amp;item_name=WordPress%20Plugin%3a%20Content%20Aware%20Sidebars&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"
800
+ target="_blank" title="PayPal - The safer, easier way to pay online!">
801
+ <img align="center" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" width="147" height="47" alt="PayPal - The safer, easier way to pay online!">
802
+ </a></p>
803
+ <p><?php _e('Or you could:',self::domain); ?></p>
804
+ <ul>
805
+ <li><a href="http://wordpress.org/support/view/plugin-reviews/content-aware-sidebars?rate=5#postform" target="_blank"><?php _e('Rate the plugin on WordPress.org',self::domain); ?></a></li>
806
+ <li><a href="http://wordpress.org/extend/plugins/content-aware-sidebars/" target="_blank"><?php _e('Link to the plugin page',self::domain); ?></a></li>
807
+ </ul>
808
+ <br />
809
+ <p>
810
+ <a href="https://twitter.com/intoxstudio" class="twitter-follow-button" data-show-count="false">Follow @intoxstudio</a>
811
+ <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></p>
812
+ <p>
813
+ <iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fintoxstudio&amp;send=false&amp;layout=button_count&amp;width=450&amp;show_faces=false&amp;font&amp;colorscheme=light&amp;action=like&amp;height=21&amp;appId=436031373100972" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100%; height:21px;" allowTransparency="true"></iframe>
814
+ </p>
815
+ </div>
816
  <?php
817
  }
818
+
819
  /**
 
820
  * Create form field for metadata
 
821
  * @global object $post
822
+ * @param array $setting
823
+ * @return void
824
  */
825
  private function _form_field($setting) {
826
  global $post;
827
+
828
+ $meta = get_post_meta($post->ID, self::prefix . $setting, true);
829
  $setting = $this->metadata[$setting];
830
  $current = $meta != '' ? $meta : $setting['val'];
831
+ switch ($setting['type']) {
832
+ case 'select' :
833
+ echo '<select style="width:250px;" name="' . $setting['id'] . '">' . "\n";
834
+ foreach ($setting['list'] as $key => $value) {
835
+ echo '<option value="' . $key . '"' . selected($current,$key,false) . '>' . $value . '</option>' . "\n";
836
  }
837
+ echo '</select>' . "\n";
838
  break;
839
  case 'checkbox' :
840
+ echo '<ul>' . "\n";
841
+ foreach ($setting['list'] as $key => $value) {
842
+ echo '<li><label><input type="checkbox" name="' . $setting['id'] . '[]" value="' . $key . '"' . (in_array($key, $current) ? ' checked="checked"' : '') . ' /> ' . $value . '</label></li>' . "\n";
843
  }
844
+ echo '</ul>' . "\n";
845
  break;
846
  case 'text' :
847
  default :
848
+ echo '<input style="width:200px;" type="text" name="' . $setting['id'] . '" value="' . $current . '" />' . "\n";
849
  break;
850
  }
851
  }
852
+
853
  /**
 
854
  * Save meta values for post
855
+ * @param int $post_id
 
856
  * @return void
857
  */
858
  public function save_post($post_id) {
859
+
860
  // Save button pressed
861
+ if (!isset($_POST['original_publish']) && !isset($_POST['save_post']))
862
  return;
863
+
864
  // Only sidebar type
865
+ if (get_post_type($post_id) != self::type_sidebar)
866
+ return;
867
+
868
  // Verify nonce
869
+ if (!check_admin_referer(basename(__FILE__), '_ca-sidebar-nonce'))
870
  return;
871
+
872
  // Check permissions
873
  if (!current_user_can('edit_theme_options', $post_id))
874
  return;
875
+
876
  // Check autosave
877
  if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
878
  return;
879
+
880
  // Load metadata
881
  $this->_init_metadata();
882
+
883
  // Update metadata
884
+ foreach ($this->metadata as $field) {
885
  $new = isset($_POST[$field['id']]) ? $_POST[$field['id']] : '';
886
+ $old = get_post_meta($post_id, self::prefix . $field['id'], true);
887
+
888
+ if ($new != '' && $new != $old) {
889
+ update_post_meta($post_id, self::prefix . $field['id'], $new);
890
  } elseif ($new == '' && $old != '') {
891
+ delete_post_meta($post_id, self::prefix . $field['id'], $old);
892
  }
893
  }
894
  // Update module data
895
  foreach ($this->modules as $module) {
896
+ $new = isset($_POST[$module->get_id()]) ? $_POST[$module->get_id()] : '';
897
+ $old = array_flip(get_post_meta($post_id, self::prefix . $module->get_id(), false));
898
+
899
+ if (is_array($new)) {
900
+ //$new = array_unique($new);
901
  // Skip existing data or insert new data
902
+ foreach ($new as $new_single) {
903
+ if (isset($old[$new_single])) {
904
  unset($old[$new_single]);
905
  } else {
906
+ add_post_meta($post_id, self::prefix . $module->get_id(), $new_single);
907
  }
908
  }
909
  // Remove existing data that have not been skipped
910
+ foreach ($old as $old_key => $old_value) {
911
+ delete_post_meta($post_id, self::prefix . $module->get_id(), $old_key);
912
  }
913
+ } elseif (!empty($old)) {
914
  // Remove any old values when $new is empty
915
+ delete_post_meta($post_id, self::prefix . $module->get_id());
916
  }
917
  }
918
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
919
 
 
 
920
  /**
 
921
  * Database data update module
922
+ * @return void
923
  */
924
  public function db_update() {
925
  cas_run_db_update(self::db_version);
926
  }
927
+
928
  /**
 
929
  * Load scripts and styles for administration
930
+ * @param string $hook
931
+ * @return void
932
  */
933
  public function load_admin_scripts($hook) {
934
+
935
+ wp_register_script('cas_admin_script', WP_PLUGIN_URL . '/' . $this->basename . '/js/cas_admin.js', array('jquery'), '1.2', true);
936
+ wp_register_style('cas_admin_style', WP_PLUGIN_URL . '/' . $this->basename . '/css/style.css', array(), '1.2');
937
+
938
+ if ($hook == 'post.php' || $hook == 'post-new.php') {
939
+ // WordPress < 3.3 does not have jQuery UI accordion and autocomplete
940
+ if (get_bloginfo('version') < 3.3) {
941
+ wp_register_script('cas-jquery-ui-autocomplete', WP_PLUGIN_URL . '/' . $this->basename . '/js/jquery.ui.autocomplete.js', array('jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position'), '1.8.9', true);
942
+ wp_register_script('cas-jquery-ui-accordion', WP_PLUGIN_URL . '/' . $this->basename . '/js/jquery.ui.accordion.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.8.9', true);
943
+ wp_enqueue_script('cas-jquery-ui-autocomplete');
944
  wp_enqueue_script('cas-jquery-ui-accordion');
945
  } else {
946
  wp_enqueue_script('jquery-ui-accordion');
947
+ wp_enqueue_script('jquery-ui-autocomplete');
948
  }
949
  wp_enqueue_script('cas_admin_script');
950
+
951
  wp_enqueue_style('cas_admin_style');
952
+ } else if ($hook == 'edit.php') {
953
  wp_enqueue_style('cas_admin_style');
954
  }
 
955
  }
956
 
957
  /**
 
958
  * Load dependencies
959
+ * @return void
960
  */
961
  private function _load_dependencies() {
962
+ require('walker.php');
963
+ require('update_db.php');
964
+ require('modules/abstract.php');
 
 
965
  }
966
 
967
  /**
 
968
  * Flush rewrite rules on plugin activation
969
+ * @return void
970
  */
971
  public function plugin_activation() {
972
  $this->init_sidebar_type();
973
  flush_rewrite_rules();
974
  }
975
+
976
  /**
 
977
  * Flush rewrite rules on plugin deactivation
978
+ * @return void
979
  */
980
  public function plugin_deactivation() {
981
  flush_rewrite_rules();
982
  }
 
983
  }
984
 
985
  // Launch plugin
987
  $ca_sidebars = new ContentAwareSidebars();
988
 
989
  /**
990
+ * Template wrapper to display content aware sidebars
 
 
991
  * @global object $ca_sidebars
992
+ * @param array|string $args
993
+ * @return void
994
  */
995
  function display_ca_sidebar($args = array()) {
996
  global $ca_sidebars;
css/style.css CHANGED
@@ -44,7 +44,12 @@
44
  border-style:solid;
45
  border-color:#eee #eee #cfcfcf !important;
46
  padding:10px !important;
47
- background-color:#dfdfdf !important;
 
 
 
 
 
48
  }
49
 
50
  #cas-accordion .ui-state-default:last-of-type, .cas-rule-content:last-child {
@@ -73,4 +78,8 @@
73
  background-image:url('../img/tick.png'); /* Icon by fatcow.com */
74
  background-repeat: no-repeat;
75
  background-position: 8px center;
 
 
 
 
76
  }
44
  border-style:solid;
45
  border-color:#eee #eee #cfcfcf !important;
46
  padding:10px !important;
47
+ background-color:#dfdfdf !important;
48
+ }
49
+
50
+ .cas-contentlist {
51
+ max-height:200px;
52
+ overflow-y:auto;
53
  }
54
 
55
  #cas-accordion .ui-state-default:last-of-type, .cas-rule-content:last-child {
78
  background-image:url('../img/tick.png'); /* Icon by fatcow.com */
79
  background-repeat: no-repeat;
80
  background-position: 8px center;
81
+ }
82
+
83
+ .cas-contentlist .children li {
84
+ padding-left:20px;
85
  }
index.php CHANGED
@@ -1 +1,2 @@
1
  <?php
 
1
  <?php
2
+ /**/
js/cas_admin.js CHANGED
@@ -3,89 +3,107 @@
3
  * @author Joachim Jensen <jv@intox.dk>
4
  */
5
 
6
- jQuery( "#cas-accordion" ).accordion({
7
- header: 'h4',
8
- autoHeight: false,
9
- collapsible: true,
10
- heightStyle: 'content'
11
- });
12
 
13
- jQuery(document).ready(function($) {
14
-
15
- handleSidebarHandle();
16
-
17
- /**
18
- *
19
- * Set tickers if at least one checkbox is checked
20
- *
21
- */
22
- $('.cas-rule-content :input').each( function() {
23
- toggleTick(this);
24
  });
25
- $('.cas-rule-content :input').change( function() {
26
- toggleTick(this);
27
- });
28
-
29
- /**
30
- *
31
- * Toggle specific checkboxes depending on "show with all" checkbox
32
- *
33
- */
34
- $('.cas-rule-content .cas-chk-all').each( function() {
35
- toggleAllSpecific(this);
36
- });
37
- $('.cas-rule-content .cas-chk-all').change( function() {
38
- toggleAllSpecific(this);
39
- });
40
-
41
- function toggleTick(checkbox) {
42
- $(checkbox).parents('.cas-rule-content').prev().toggleClass('cas-tick',$('#'+$(checkbox).parents('.cas-rule-content').attr('id')+' :input:checked').length > 0);
43
- }
44
-
45
- function toggleAllSpecific(checkbox) {
46
- var checkboxes = $(".cas-rule-content ."+$(checkbox).parents('.cas-rule-content').attr("id"));
47
- if($(checkbox).is(":checked")) {
48
- $(checkboxes).attr("disabled", true);
49
- } else {
50
- $(checkboxes).removeAttr("disabled");
51
- }
52
- }
53
-
54
- /**
55
- *
56
- * Handle the Handle selection
57
- *
58
- */
59
- function handleSidebarHandle() {
60
-
61
- var name = "select[name='handle']";
62
-
63
- // Execute on ready
64
- $(name).each(function(){
65
- endisableHostSidebars($(this));
66
- });
67
-
68
- // Execute on change
69
- $(name).change(function(){
70
- endisableHostSidebars($(this));
71
- });
72
- }
73
-
74
- /**
75
- * The value of Handle selection will control the
76
- * accessibility of the host sidebar selection
77
- * If Handling is manual, selection of host sidebar will be disabled
78
- */
79
- function endisableHostSidebars(select) {
80
- var name = "select[name='host']";
81
- if(select.val() == 2) {
82
- $(name).hide();
83
- $(name).attr("disabled", true);
84
-
85
- } else {
86
- $(name).show();
87
- $(name).removeAttr("disabled");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  }
89
  }
90
-
91
- });
 
 
3
  * @author Joachim Jensen <jv@intox.dk>
4
  */
5
 
6
+ (function($) {
 
 
 
 
 
7
 
8
+ $( "#cas-accordion" ).accordion({
9
+ header: 'h4',
10
+ autoHeight: false,
11
+ collapsible: true,
12
+ heightStyle: 'content'
 
 
 
 
 
 
13
  });
14
+
15
+ var api = {
16
+
17
+ init: function() {
18
+ this.addCheckboxListener();
19
+ this.addHandleListener();
20
+ this.addSearchListener();
21
+ },
22
+
23
+ /**
24
+ * Set tickers if at least one checkbox is checked
25
+ */
26
+ addCheckboxListener: function() {
27
+ $('.cas-rule-content :input').change( function() {
28
+ var parent = $(this).parents('.cas-rule-content');
29
+ api.toggleTick(this, parent);
30
+ if($(this).attr('class') == 'cas-chk-all')
31
+ api.toggleSelectAll(this, parent);
32
+ }).change(); //fire change event on page load
33
+ },
34
+ toggleTick: function(checkbox, parent) {
35
+ //Toggle on any selected checkbox
36
+ parent.prev().toggleClass('cas-tick',parent.find('input:checked').length > 0);
37
+ },
38
+ /**
39
+ * Toggle specific input depending on "show with all" checkbox
40
+ */
41
+ toggleSelectAll: function(checkbox, parent) {
42
+ var checkboxes = parent.find("input").not(checkbox);
43
+ checkboxes.attr("disabled", $(checkbox).is(":checked"));
44
+ },
45
+ /**
46
+ * The value of Handle selection will control the
47
+ * accessibility of the host sidebar selection
48
+ * If Handling is manual, selection of host sidebar will be disabled
49
+ */
50
+ addHandleListener: function() {
51
+ $("select[name='handle']").change(function(){
52
+ api.toggleHostOption($(this));
53
+ }).change(); //fire change event on page load
54
+ },
55
+ toggleHostOption: function(handle) {
56
+ var name = "select[name='host']";
57
+ $(name).attr("disabled", handle.val() == 2);
58
+ if(handle.val() == 2)
59
+ $(name).hide();
60
+ else
61
+ $(name).show();
62
+ },
63
+ /**
64
+ * Use AJAX to search for content from a specific module
65
+ */
66
+ addSearchListener: function() {
67
+ $('input.cas-autocomplete').each(function(i, el) {
68
+ $(el).keypress(function(e){
69
+ //If Enter (13) is pressed, disregard
70
+ if( 13 == e.which ) {
71
+ return false;
72
+ }
73
+ }).autocomplete({
74
+ source: ajaxurl+"?action="+$(el).attr('class').split(' ')[0]+"&nonce="+$('#_ca-sidebar-nonce').val()+"&type="+$(el).attr('id'),
75
+ minLength: 2,
76
+ delay: 500,
77
+ select: function(e,ui) {
78
+ api.clickToAddSearchResult(e,ui);
79
+ }
80
+ });
81
+ });
82
+
83
+ },
84
+ clickToAddSearchResult: function(e, ui) {
85
+ // Check if an element is found
86
+ if(ui.item != null) {
87
+ $("input#cas-add-"+ui.item.id2).click( function() {
88
+ // Check if element already exists
89
+ if($("#"+ui.item.elem).length == 0) {
90
+
91
+ var elem = $('<li id="'+ui.item.elem+'"><label class="selectit"><input class="cas-'+ui.item.module+'-'+ui.item.id+' cas-'+ui.item.id2+'" value="'+ui.item.id+'" type="checkbox" name="'+ui.item.name+'[]" checked="checked" /> '+ui.item.label+'</label>').change( function() {
92
+ var parent = $(this).parents('.cas-rule-content');
93
+ api.toggleTick(this,parent);
94
+ });
95
+
96
+ //Add element and clean up
97
+ $("#cas-list-"+ui.item.id2).prepend(elem);
98
+ elem.change(); // fire change event
99
+ $( "input#cas-autocomplete-"+ui.item.id2 ).val('');
100
+ $(this).unbind('click');
101
+ }
102
+ });
103
+ }
104
  }
105
  }
106
+
107
+ $(document).ready(function(){ api.init(); });
108
+
109
+ })(jQuery);
js/jquery.ui.autocomplete.js ADDED
@@ -0,0 +1,605 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery UI Autocomplete 1.8.9
3
+ *
4
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5
+ * Dual licensed under the MIT or GPL Version 2 licenses.
6
+ * http://jquery.org/license
7
+ *
8
+ * http://docs.jquery.com/UI/Autocomplete
9
+ *
10
+ * Depends:
11
+ * jquery.ui.core.js
12
+ * jquery.ui.widget.js
13
+ * jquery.ui.position.js
14
+ */
15
+ (function( $, undefined ) {
16
+
17
+ $.widget( "ui.autocomplete", {
18
+ options: {
19
+ appendTo: "body",
20
+ delay: 300,
21
+ minLength: 1,
22
+ position: {
23
+ my: "left top",
24
+ at: "left bottom",
25
+ collision: "none"
26
+ },
27
+ source: null
28
+ },
29
+
30
+ pending: 0,
31
+
32
+ _create: function() {
33
+ var self = this,
34
+ doc = this.element[ 0 ].ownerDocument,
35
+ suppressKeyPress;
36
+
37
+ this.element
38
+ .addClass( "ui-autocomplete-input" )
39
+ .attr( "autocomplete", "off" )
40
+ // TODO verify these actually work as intended
41
+ .attr({
42
+ role: "textbox",
43
+ "aria-autocomplete": "list",
44
+ "aria-haspopup": "true"
45
+ })
46
+ .bind( "keydown.autocomplete", function( event ) {
47
+ if ( self.options.disabled || self.element.attr( "readonly" ) ) {
48
+ return;
49
+ }
50
+
51
+ suppressKeyPress = false;
52
+ var keyCode = $.ui.keyCode;
53
+ switch( event.keyCode ) {
54
+ case keyCode.PAGE_UP:
55
+ self._move( "previousPage", event );
56
+ break;
57
+ case keyCode.PAGE_DOWN:
58
+ self._move( "nextPage", event );
59
+ break;
60
+ case keyCode.UP:
61
+ self._move( "previous", event );
62
+ // prevent moving cursor to beginning of text field in some browsers
63
+ event.preventDefault();
64
+ break;
65
+ case keyCode.DOWN:
66
+ self._move( "next", event );
67
+ // prevent moving cursor to end of text field in some browsers
68
+ event.preventDefault();
69
+ break;
70
+ case keyCode.ENTER:
71
+ case keyCode.NUMPAD_ENTER:
72
+ // when menu is open and has focus
73
+ if ( self.menu.active ) {
74
+ // #6055 - Opera still allows the keypress to occur
75
+ // which causes forms to submit
76
+ suppressKeyPress = true;
77
+ event.preventDefault();
78
+ }
79
+ //passthrough - ENTER and TAB both select the current element
80
+ case keyCode.TAB:
81
+ if ( !self.menu.active ) {
82
+ return;
83
+ }
84
+ self.menu.select( event );
85
+ break;
86
+ case keyCode.ESCAPE:
87
+ self.element.val( self.term );
88
+ self.close( event );
89
+ break;
90
+ default:
91
+ // keypress is triggered before the input value is changed
92
+ clearTimeout( self.searching );
93
+ self.searching = setTimeout(function() {
94
+ // only search if the value has changed
95
+ if ( self.term != self.element.val() ) {
96
+ self.selectedItem = null;
97
+ self.search( null, event );
98
+ }
99
+ }, self.options.delay );
100
+ break;
101
+ }
102
+ })
103
+ .bind( "keypress.autocomplete", function( event ) {
104
+ if ( suppressKeyPress ) {
105
+ suppressKeyPress = false;
106
+ event.preventDefault();
107
+ }
108
+ })
109
+ .bind( "focus.autocomplete", function() {
110
+ if ( self.options.disabled ) {
111
+ return;
112
+ }
113
+
114
+ self.selectedItem = null;
115
+ self.previous = self.element.val();
116
+ })
117
+ .bind( "blur.autocomplete", function( event ) {
118
+ if ( self.options.disabled ) {
119
+ return;
120
+ }
121
+
122
+ clearTimeout( self.searching );
123
+ // clicks on the menu (or a button to trigger a search) will cause a blur event
124
+ self.closing = setTimeout(function() {
125
+ self.close( event );
126
+ self._change( event );
127
+ }, 150 );
128
+ });
129
+ this._initSource();
130
+ this.response = function() {
131
+ return self._response.apply( self, arguments );
132
+ };
133
+ this.menu = $( "<ul></ul>" )
134
+ .addClass( "ui-autocomplete" )
135
+ .appendTo( $( this.options.appendTo || "body", doc )[0] )
136
+ // prevent the close-on-blur in case of a "slow" click on the menu (long mousedown)
137
+ .mousedown(function( event ) {
138
+ // clicking on the scrollbar causes focus to shift to the body
139
+ // but we can't detect a mouseup or a click immediately afterward
140
+ // so we have to track the next mousedown and close the menu if
141
+ // the user clicks somewhere outside of the autocomplete
142
+ var menuElement = self.menu.element[ 0 ];
143
+ if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
144
+ setTimeout(function() {
145
+ $( document ).one( 'mousedown', function( event ) {
146
+ if ( event.target !== self.element[ 0 ] &&
147
+ event.target !== menuElement &&
148
+ !$.ui.contains( menuElement, event.target ) ) {
149
+ self.close();
150
+ }
151
+ });
152
+ }, 1 );
153
+ }
154
+
155
+ // use another timeout to make sure the blur-event-handler on the input was already triggered
156
+ setTimeout(function() {
157
+ clearTimeout( self.closing );
158
+ }, 13);
159
+ })
160
+ .menu({
161
+ focus: function( event, ui ) {
162
+ var item = ui.item.data( "item.autocomplete" );
163
+ if ( false !== self._trigger( "focus", event, { item: item } ) ) {
164
+ // use value to match what will end up in the input, if it was a key event
165
+ if ( /^key/.test(event.originalEvent.type) ) {
166
+ self.element.val( item.value );
167
+ }
168
+ }
169
+ },
170
+ selected: function( event, ui ) {
171
+ var item = ui.item.data( "item.autocomplete" ),
172
+ previous = self.previous;
173
+
174
+ // only trigger when focus was lost (click on menu)
175
+ if ( self.element[0] !== doc.activeElement ) {
176
+ self.element.focus();
177
+ self.previous = previous;
178
+ // #6109 - IE triggers two focus events and the second
179
+ // is asynchronous, so we need to reset the previous
180
+ // term synchronously and asynchronously :-(
181
+ setTimeout(function() {
182
+ self.previous = previous;
183
+ self.selectedItem = item;
184
+ }, 1);
185
+ }
186
+
187
+ if ( false !== self._trigger( "select", event, { item: item } ) ) {
188
+ self.element.val( item.value );
189
+ }
190
+ // reset the term after the select event
191
+ // this allows custom select handling to work properly
192
+ self.term = self.element.val();
193
+
194
+ self.close( event );
195
+ self.selectedItem = item;
196
+ },
197
+ blur: function( event, ui ) {
198
+ // don't set the value of the text field if it's already correct
199
+ // this prevents moving the cursor unnecessarily
200
+ if ( self.menu.element.is(":visible") &&
201
+ ( self.element.val() !== self.term ) ) {
202
+ self.element.val( self.term );
203
+ }
204
+ }
205
+ })
206
+ .zIndex( this.element.zIndex() + 1 )
207
+ // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
208
+ .css({ top: 0, left: 0 })
209
+ .hide()
210
+ .data( "menu" );
211
+ if ( $.fn.bgiframe ) {
212
+ this.menu.element.bgiframe();
213
+ }
214
+ },
215
+
216
+ destroy: function() {
217
+ this.element
218
+ .removeClass( "ui-autocomplete-input" )
219
+ .removeAttr( "autocomplete" )
220
+ .removeAttr( "role" )
221
+ .removeAttr( "aria-autocomplete" )
222
+ .removeAttr( "aria-haspopup" );
223
+ this.menu.element.remove();
224
+ $.Widget.prototype.destroy.call( this );
225
+ },
226
+
227
+ _setOption: function( key, value ) {
228
+ $.Widget.prototype._setOption.apply( this, arguments );
229
+ if ( key === "source" ) {
230
+ this._initSource();
231
+ }
232
+ if ( key === "appendTo" ) {
233
+ this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
234
+ }
235
+ if ( key === "disabled" && value && this.xhr ) {
236
+ this.xhr.abort();
237
+ }
238
+ },
239
+
240
+ _initSource: function() {
241
+ var self = this,
242
+ array,
243
+ url;
244
+ if ( $.isArray(this.options.source) ) {
245
+ array = this.options.source;
246
+ this.source = function( request, response ) {
247
+ response( $.ui.autocomplete.filter(array, request.term) );
248
+ };
249
+ } else if ( typeof this.options.source === "string" ) {
250
+ url = this.options.source;
251
+ this.source = function( request, response ) {
252
+ if ( self.xhr ) {
253
+ self.xhr.abort();
254
+ }
255
+ self.xhr = $.ajax({
256
+ url: url,
257
+ data: request,
258
+ dataType: "json",
259
+ success: function( data, status, xhr ) {
260
+ if ( xhr === self.xhr ) {
261
+ response( data );
262
+ }
263
+ self.xhr = null;
264
+ },
265
+ error: function( xhr ) {
266
+ if ( xhr === self.xhr ) {
267
+ response( [] );
268
+ }
269
+ self.xhr = null;
270
+ }
271
+ });
272
+ };
273
+ } else {
274
+ this.source = this.options.source;
275
+ }
276
+ },
277
+
278
+ search: function( value, event ) {
279
+ value = value != null ? value : this.element.val();
280
+
281
+ // always save the actual value, not the one passed as an argument
282
+ this.term = this.element.val();
283
+
284
+ if ( value.length < this.options.minLength ) {
285
+ return this.close( event );
286
+ }
287
+
288
+ clearTimeout( this.closing );
289
+ if ( this._trigger( "search", event ) === false ) {
290
+ return;
291
+ }
292
+
293
+ return this._search( value );
294
+ },
295
+
296
+ _search: function( value ) {
297
+ this.pending++;
298
+ this.element.addClass( "ui-autocomplete-loading" );
299
+
300
+ this.source( { term: value }, this.response );
301
+ },
302
+
303
+ _response: function( content ) {
304
+ if ( !this.options.disabled && content && content.length ) {
305
+ content = this._normalize( content );
306
+ this._suggest( content );
307
+ this._trigger( "open" );
308
+ } else {
309
+ this.close();
310
+ }
311
+ this.pending--;
312
+ if ( !this.pending ) {
313
+ this.element.removeClass( "ui-autocomplete-loading" );
314
+ }
315
+ },
316
+
317
+ close: function( event ) {
318
+ clearTimeout( this.closing );
319
+ if ( this.menu.element.is(":visible") ) {
320
+ this.menu.element.hide();
321
+ this.menu.deactivate();
322
+ this._trigger( "close", event );
323
+ }
324
+ },
325
+
326
+ _change: function( event ) {
327
+ if ( this.previous !== this.element.val() ) {
328
+ this._trigger( "change", event, { item: this.selectedItem } );
329
+ }
330
+ },
331
+
332
+ _normalize: function( items ) {
333
+ // assume all items have the right format when the first item is complete
334
+ if ( items.length && items[0].label && items[0].value ) {
335
+ return items;
336
+ }
337
+ return $.map( items, function(item) {
338
+ if ( typeof item === "string" ) {
339
+ return {
340
+ label: item,
341
+ value: item
342
+ };
343
+ }
344
+ return $.extend({
345
+ label: item.label || item.value,
346
+ value: item.value || item.label
347
+ }, item );
348
+ });
349
+ },
350
+
351
+ _suggest: function( items ) {
352
+ var ul = this.menu.element
353
+ .empty()
354
+ .zIndex( this.element.zIndex() + 1 );
355
+ this._renderMenu( ul, items );
356
+ // TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate
357
+ this.menu.deactivate();
358
+ this.menu.refresh();
359
+
360
+ // size and position menu
361
+ ul.show();
362
+ this._resizeMenu();
363
+ ul.position( $.extend({
364
+ of: this.element
365
+ }, this.options.position ));
366
+ },
367
+
368
+ _resizeMenu: function() {
369
+ var ul = this.menu.element;
370
+ ul.outerWidth( Math.max(
371
+ ul.width( "" ).outerWidth(),
372
+ this.element.outerWidth()
373
+ ) );
374
+ },
375
+
376
+ _renderMenu: function( ul, items ) {
377
+ var self = this;
378
+ $.each( items, function( index, item ) {
379
+ self._renderItem( ul, item );
380
+ });
381
+ },
382
+
383
+ _renderItem: function( ul, item) {
384
+ return $( "<li></li>" )
385
+ .data( "item.autocomplete", item )
386
+ .append( $( "<a></a>" ).text( item.label ) )
387
+ .appendTo( ul );
388
+ },
389
+
390
+ _move: function( direction, event ) {
391
+ if ( !this.menu.element.is(":visible") ) {
392
+ this.search( null, event );
393
+ return;
394
+ }
395
+ if ( this.menu.first() && /^previous/.test(direction) ||
396
+ this.menu.last() && /^next/.test(direction) ) {
397
+ this.element.val( this.term );
398
+ this.menu.deactivate();
399
+ return;
400
+ }
401
+ this.menu[ direction ]( event );
402
+ },
403
+
404
+ widget: function() {
405
+ return this.menu.element;
406
+ }
407
+ });
408
+
409
+ $.extend( $.ui.autocomplete, {
410
+ escapeRegex: function( value ) {
411
+ return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
412
+ },
413
+ filter: function(array, term) {
414
+ var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
415
+ return $.grep( array, function(value) {
416
+ return matcher.test( value.label || value.value || value );
417
+ });
418
+ }
419
+ });
420
+
421
+ }( jQuery ));
422
+
423
+ /*
424
+ * jQuery UI Menu (not officially released)
425
+ *
426
+ * This widget isn't yet finished and the API is subject to change. We plan to finish
427
+ * it for the next release. You're welcome to give it a try anyway and give us feedback,
428
+ * as long as you're okay with migrating your code later on. We can help with that, too.
429
+ *
430
+ * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
431
+ * Dual licensed under the MIT or GPL Version 2 licenses.
432
+ * http://jquery.org/license
433
+ *
434
+ * http://docs.jquery.com/UI/Menu
435
+ *
436
+ * Depends:
437
+ * jquery.ui.core.js
438
+ * jquery.ui.widget.js
439
+ */
440
+ (function($) {
441
+
442
+ $.widget("ui.menu", {
443
+ _create: function() {
444
+ var self = this;
445
+ this.element
446
+ .addClass("ui-menu ui-widget ui-widget-content ui-corner-all")
447
+ .attr({
448
+ role: "listbox",
449
+ "aria-activedescendant": "ui-active-menuitem"
450
+ })
451
+ .click(function( event ) {
452
+ if ( !$( event.target ).closest( ".ui-menu-item a" ).length ) {
453
+ return;
454
+ }
455
+ // temporary
456
+ event.preventDefault();
457
+ self.select( event );
458
+ });
459
+ this.refresh();
460
+ },
461
+
462
+ refresh: function() {
463
+ var self = this;
464
+
465
+ // don't refresh list items that are already adapted
466
+ var items = this.element.children("li:not(.ui-menu-item):has(a)")
467
+ .addClass("ui-menu-item")
468
+ .attr("role", "menuitem");
469
+
470
+ items.children("a")
471
+ .addClass("ui-corner-all")
472
+ .attr("tabindex", -1)
473
+ // mouseenter doesn't work with event delegation
474
+ .mouseenter(function( event ) {
475
+ self.activate( event, $(this).parent() );
476
+ })
477
+ .mouseleave(function() {
478
+ self.deactivate();
479
+ });
480
+ },
481
+
482
+ activate: function( event, item ) {
483
+ this.deactivate();
484
+ if (this.hasScroll()) {
485
+ var offset = item.offset().top - this.element.offset().top,
486
+ scroll = this.element.attr("scrollTop"),
487
+ elementHeight = this.element.height();
488
+ if (offset < 0) {
489
+ this.element.attr("scrollTop", scroll + offset);
490
+ } else if (offset >= elementHeight) {
491
+ this.element.attr("scrollTop", scroll + offset - elementHeight + item.height());
492
+ }
493
+ }
494
+ this.active = item.eq(0)
495
+ .children("a")
496
+ .addClass("ui-state-hover")
497
+ .attr("id", "ui-active-menuitem")
498
+ .end();
499
+ this._trigger("focus", event, { item: item });
500
+ },
501
+
502
+ deactivate: function() {
503
+ if (!this.active) { return; }
504
+
505
+ this.active.children("a")
506
+ .removeClass("ui-state-hover")
507
+ .removeAttr("id");
508
+ this._trigger("blur");
509
+ this.active = null;
510
+ },
511
+
512
+ next: function(event) {
513
+ this.move("next", ".ui-menu-item:first", event);
514
+ },
515
+
516
+ previous: function(event) {
517
+ this.move("prev", ".ui-menu-item:last", event);
518
+ },
519
+
520
+ first: function() {
521
+ return this.active && !this.active.prevAll(".ui-menu-item").length;
522
+ },
523
+
524
+ last: function() {
525
+ return this.active && !this.active.nextAll(".ui-menu-item").length;
526
+ },
527
+
528
+ move: function(direction, edge, event) {
529
+ if (!this.active) {
530
+ this.activate(event, this.element.children(edge));
531
+ return;
532
+ }
533
+ var next = this.active[direction + "All"](".ui-menu-item").eq(0);
534
+ if (next.length) {
535
+ this.activate(event, next);
536
+ } else {
537
+ this.activate(event, this.element.children(edge));
538
+ }
539
+ },
540
+
541
+ // TODO merge with previousPage
542
+ nextPage: function(event) {
543
+ if (this.hasScroll()) {
544
+ // TODO merge with no-scroll-else
545
+ if (!this.active || this.last()) {
546
+ this.activate(event, this.element.children(".ui-menu-item:first"));
547
+ return;
548
+ }
549
+ var base = this.active.offset().top,
550
+ height = this.element.height(),
551
+ result = this.element.children(".ui-menu-item").filter(function() {
552
+ var close = $(this).offset().top - base - height + $(this).height();
553
+ // TODO improve approximation
554
+ return close < 10 && close > -10;
555
+ });
556
+
557
+ // TODO try to catch this earlier when scrollTop indicates the last page anyway
558
+ if (!result.length) {
559
+ result = this.element.children(".ui-menu-item:last");
560
+ }
561
+ this.activate(event, result);
562
+ } else {
563
+ this.activate(event, this.element.children(".ui-menu-item")
564
+ .filter(!this.active || this.last() ? ":first" : ":last"));
565
+ }
566
+ },
567
+
568
+ // TODO merge with nextPage
569
+ previousPage: function(event) {
570
+ if (this.hasScroll()) {
571
+ // TODO merge with no-scroll-else
572
+ if (!this.active || this.first()) {
573
+ this.activate(event, this.element.children(".ui-menu-item:last"));
574
+ return;
575
+ }
576
+
577
+ var base = this.active.offset().top,
578
+ height = this.element.height();
579
+ result = this.element.children(".ui-menu-item").filter(function() {
580
+ var close = $(this).offset().top - base + height - $(this).height();
581
+ // TODO improve approximation
582
+ return close < 10 && close > -10;
583
+ });
584
+
585
+ // TODO try to catch this earlier when scrollTop indicates the last page anyway
586
+ if (!result.length) {
587
+ result = this.element.children(".ui-menu-item:first");
588
+ }
589
+ this.activate(event, result);
590
+ } else {
591
+ this.activate(event, this.element.children(".ui-menu-item")
592
+ .filter(!this.active || this.first() ? ":last" : ":first"));
593
+ }
594
+ },
595
+
596
+ hasScroll: function() {
597
+ return this.element.height() < this.element.attr("scrollHeight");
598
+ },
599
+
600
+ select: function( event ) {
601
+ this._trigger("selected", event, { item: this.active });
602
+ }
603
+ });
604
+
605
+ }(jQuery));
lang/content-aware-sidebars-da_DK.mo CHANGED
Binary file
lang/content-aware-sidebars-da_DK.po CHANGED
@@ -2,140 +2,141 @@
2
  # This file is distributed under the same license as the Content Aware Sidebars package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Content Aware Sidebars 0.8.3\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/content-aware-sidebars\n"
7
- "POT-Creation-Date: 2013-01-07 16:09:52+00:00\n"
8
- "PO-Revision-Date: 2013-01-07 18:19+0100\n"
9
- "Last-Translator: Intox Studio <jv@intox.dk>\n"
10
  "Language-Team: Intox Studio <jv@intox.dk>\n"
11
  "Language: da_DK\n"
12
  "MIME-Version: 1.0\n"
13
  "Content-Type: text/plain; charset=UTF-8\n"
14
  "Content-Transfer-Encoding: 8bit\n"
 
15
 
16
- #: content-aware-sidebars.php:150 content-aware-sidebars.php:327
17
  msgid "Exposure"
18
  msgstr "Eksponering"
19
 
20
- #: content-aware-sidebars.php:156
21
  msgid "Singular"
22
  msgstr "Singulær"
23
 
24
- #: content-aware-sidebars.php:157
25
  msgid "Singular & Archive"
26
  msgstr "Singulær og arkiv"
27
 
28
- #: content-aware-sidebars.php:158
29
  msgid "Archive"
30
  msgstr "Arkiv"
31
 
32
- #: content-aware-sidebars.php:162 content-aware-sidebars.php:328
33
  msgctxt "option"
34
  msgid "Handle"
35
  msgstr "Håndtering"
36
 
37
- #: content-aware-sidebars.php:164
38
  msgid "Replace host sidebar, merge with it or add sidebar manually."
39
  msgstr "Erstat værts-sidebar, flet med den eller tilføj denne sidebar manuelt."
40
 
41
- #: content-aware-sidebars.php:168
42
  msgid "Replace"
43
  msgstr "Erstat"
44
 
45
- #: content-aware-sidebars.php:169
46
  msgid "Merge"
47
  msgstr "Flet"
48
 
49
- #: content-aware-sidebars.php:170
50
  msgid "Manual"
51
  msgstr "Manuel"
52
 
53
- #: content-aware-sidebars.php:174
54
  msgid "Host Sidebar"
55
  msgstr "Værts-sidebar"
56
 
57
- #: content-aware-sidebars.php:182 content-aware-sidebars.php:329
58
  msgid "Merge position"
59
  msgstr "Fletteposition"
60
 
61
- #: content-aware-sidebars.php:184
62
  msgid "Place sidebar on top or bottom of host when merging."
63
  msgstr "Flet ind fra oven eller bunden."
64
 
65
- #: content-aware-sidebars.php:188
66
  msgid "Top"
67
  msgstr "Top"
68
 
69
- #: content-aware-sidebars.php:189
70
  msgid "Bottom"
71
  msgstr "Bund"
72
 
73
- #: content-aware-sidebars.php:210
74
  msgid "Sidebars"
75
  msgstr "Sidebars"
76
 
77
- #: content-aware-sidebars.php:211
78
  msgid "Sidebar"
79
  msgstr "Sidebar"
80
 
81
- #: content-aware-sidebars.php:212
82
  msgctxt "sidebar"
83
  msgid "Add New"
84
  msgstr "Tilføj ny"
85
 
86
- #: content-aware-sidebars.php:213
87
  msgid "Add New Sidebar"
88
  msgstr "Tilføj ny sidebar"
89
 
90
- #: content-aware-sidebars.php:214
91
  msgid "Edit Sidebar"
92
  msgstr "Rediger sidebar"
93
 
94
- #: content-aware-sidebars.php:215
95
  msgid "New Sidebar"
96
  msgstr "Ny sidebar"
97
 
98
- #: content-aware-sidebars.php:216
99
  msgid "All Sidebars"
100
  msgstr "Alle sidebars"
101
 
102
- #: content-aware-sidebars.php:217
103
  msgid "View Sidebar"
104
  msgstr "Vis sidebar"
105
 
106
- #: content-aware-sidebars.php:218
107
  msgid "Search Sidebars"
108
  msgstr "Søg sidebars"
109
 
110
- #: content-aware-sidebars.php:219
111
  msgid "No sidebars found"
112
  msgstr "Ingen sidebars fundet"
113
 
114
- #: content-aware-sidebars.php:220
115
  msgid "No sidebars found in Trash"
116
  msgstr "Ingen sidebars fundet i papirkurven"
117
 
118
- #: content-aware-sidebars.php:253
119
  msgid "Sidebar updated. <a href=\"%s\">Manage widgets</a>"
120
  msgstr "Sidebar opdateret. <a href=\"%s\">Håndter widgets</a>"
121
 
122
- #: content-aware-sidebars.php:256
123
  msgid "Sidebar updated."
124
  msgstr "Sidebar opdateret."
125
 
126
- #: content-aware-sidebars.php:258
127
  msgid "Sidebar published. <a href=\"%s\">Manage widgets</a>"
128
  msgstr "Sidebar udgivet. <a href=\"%s\">Håndter widgets</a>"
129
 
130
- #: content-aware-sidebars.php:259
131
  msgid "Sidebar saved."
132
  msgstr "Sidebar gemt."
133
 
134
- #: content-aware-sidebars.php:260
135
  msgid "Sidebar submitted. <a href=\"%s\">Manage widgets</a>"
136
  msgstr "Sidebar indsendt. <a href=\"%s\">Håndter widgets</a>"
137
 
138
- #: content-aware-sidebars.php:261
139
  msgid ""
140
  "Sidebar scheduled for: <strong>%1$s</strong>. <a href=\"%2$s\">Manage "
141
  "widgets</a>"
@@ -144,130 +145,142 @@ msgstr ""
144
  "widgets</a>"
145
 
146
  #. translators: Publish box date format, see http:php.net/date
147
- #: content-aware-sidebars.php:263
148
  msgid "M j, Y @ G:i"
149
  msgstr "j. M, Y @ G:i"
150
 
151
- #: content-aware-sidebars.php:264
152
  msgid "Sidebar draft updated."
153
  msgstr "Sidebar-kladde opdateret."
154
 
155
- #: content-aware-sidebars.php:391
156
  msgid "Please update Host Sidebar"
157
  msgstr "Værts-sidebar skal opdateres"
158
 
159
- #: content-aware-sidebars.php:454
160
  msgid "Manage Widgets"
161
  msgstr "Håndter widgets"
162
 
163
- #: content-aware-sidebars.php:651
164
- msgid "Words from the author"
165
- msgstr "Et par ord fra forfatteren"
166
-
167
- #: content-aware-sidebars.php:661
168
  msgid "Content"
169
  msgstr "Indhold"
170
 
171
- #: content-aware-sidebars.php:671
172
  msgid "Options"
173
  msgstr "Indstillinger"
174
 
175
- #: content-aware-sidebars.php:766
176
- msgid "If you love this plugin, please consider donating."
177
- msgstr "Venligst overvej at donere, hvis du elsker dette plugin."
178
 
179
- #: content-aware-sidebars.php:768
180
  msgid ""
181
- "Remember to <a class=\"button\" href=\"%1$s\" target=\"_blank\">rate</a> and "
182
- "<a class=\"button\" href=\"%2$s\" target=\"_blank\">share</a> it too!"
183
  msgstr ""
184
- "Glem ikke at <a class=\"button\" href=\"%1$s\" target=\"_blank\">vurdere</a> "
185
- "og <a class=\"button\" href=\"%2$s\" target=\"_blank\">dele</a> det!"
186
 
187
- #: content-aware-sidebars.php:770
188
- msgid "Check out Content Aware Sidebars for %23WordPress! :)"
189
- msgstr "Jeg bruger Content Aware Sidebars til %23WordPress! :)"
190
 
191
- #: content-aware-sidebars.php:772
192
- msgid "Check out Content Aware Sidebars :)"
193
- msgstr "Jeg bruger Content Aware Sidebars :)"
194
 
195
- #: modules/abstract.php:39 modules/post_type.php:78
 
 
 
 
196
  msgid "Show with All %s"
197
  msgstr "Vis ved alle %s"
198
 
199
- #: modules/abstract.php:43 modules/post_type.php:88 modules/taxonomy.php:121
200
  msgid "View All"
201
  msgstr "Vis alle"
202
 
203
- #: modules/author.php:21
204
  msgid "Authors"
205
  msgstr "Forfattere"
206
 
207
- #: modules/bbpress.php:20
208
  msgid "bbPress User Profiles"
209
  msgstr "bbPress brugerprofiler"
210
 
211
- #: modules/bp_member.php:20
212
  msgid "BuddyPress Members"
213
  msgstr "BuddyPress medlemmer"
214
 
215
- #: modules/page_template.php:21
216
  msgid "Page Templates"
217
  msgstr "Skabeloner"
218
 
219
- #: modules/polylang.php:20 modules/qtranslate.php:20 modules/transposh.php:20
220
- #: modules/wpml.php:20
221
  msgid "Languages"
222
  msgstr "Sprog"
223
 
224
- #: modules/post_type.php:23
225
  msgid "Post Types"
226
  msgstr "Indholdstyper"
227
 
228
- #: modules/post_type.php:73 modules/taxonomy.php:107
229
  msgid "Automatically select new children of a selected ancestor"
230
  msgstr "Vælg automatisk nye børn af den valgte forælder"
231
 
232
- #: modules/post_type.php:82 modules/taxonomy.php:115
233
  msgid "No items."
234
  msgstr "Ingen elementer."
235
 
236
- #: modules/static.php:22
 
 
 
 
 
 
 
 
237
  msgid "Static Pages"
238
  msgstr "Statiske sider"
239
 
240
- #: modules/static.php:27
241
  msgid "Front Page"
242
  msgstr "Forside"
243
 
244
- #: modules/static.php:28
245
  msgid "Search Results"
246
  msgstr "Søgeresultater"
247
 
248
- #: modules/static.php:29
249
  msgid "404 Page"
250
  msgstr "404-side"
251
 
252
- #: modules/taxonomy.php:24
253
  msgid "Taxonomies"
254
  msgstr "Taksonomier"
255
 
256
- #: modules/taxonomy.php:111
257
  msgid "Show with %s"
258
  msgstr "Vis ved %s"
259
 
260
- #: modules/taxonomy.php:120
261
  msgid "Most Used"
262
  msgstr "Mest brugte"
263
 
 
 
 
 
264
  #. Plugin Name of the plugin/theme
265
  msgid "Content Aware Sidebars"
266
  msgstr "Content Aware Sidebars"
267
 
268
- #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.1.2) #-#-#-#-#
269
  #. Plugin URI of the plugin/theme
270
- #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.1.2) #-#-#-#-#
271
  #. Author URI of the plugin/theme
272
  msgid "http://www.intox.dk/"
273
  msgstr "http://www.intox.dk/"
@@ -277,8 +290,24 @@ msgid "Manage and show sidebars according to the content being viewed."
277
  msgstr "Administrer og vis sidebars i henhold til det indhold, der vises."
278
 
279
  #. Author of the plugin/theme
280
- msgid "Joachim Jensen"
281
- msgstr "Joachim Jensen"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
 
283
  #~ msgid "bbPress"
284
  #~ msgstr "bbPress"
2
  # This file is distributed under the same license as the Content Aware Sidebars package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Content Aware Sidebars 1.3\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/content-aware-sidebars\n"
7
+ "POT-Creation-Date: 2013-03-31 21:23:20+00:00\n"
8
+ "PO-Revision-Date: 2013-04-03 20:57+0100\n"
9
+ "Last-Translator: Joachim Jensen <jv@intox.dk>\n"
10
  "Language-Team: Intox Studio <jv@intox.dk>\n"
11
  "Language: da_DK\n"
12
  "MIME-Version: 1.0\n"
13
  "Content-Type: text/plain; charset=UTF-8\n"
14
  "Content-Transfer-Encoding: 8bit\n"
15
+ "X-Generator: Poedit 1.5.5\n"
16
 
17
+ #: content-aware-sidebars.php:178 content-aware-sidebars.php:345
18
  msgid "Exposure"
19
  msgstr "Eksponering"
20
 
21
+ #: content-aware-sidebars.php:184
22
  msgid "Singular"
23
  msgstr "Singulær"
24
 
25
+ #: content-aware-sidebars.php:185
26
  msgid "Singular & Archive"
27
  msgstr "Singulær og arkiv"
28
 
29
+ #: content-aware-sidebars.php:186
30
  msgid "Archive"
31
  msgstr "Arkiv"
32
 
33
+ #: content-aware-sidebars.php:190 content-aware-sidebars.php:346
34
  msgctxt "option"
35
  msgid "Handle"
36
  msgstr "Håndtering"
37
 
38
+ #: content-aware-sidebars.php:192
39
  msgid "Replace host sidebar, merge with it or add sidebar manually."
40
  msgstr "Erstat værts-sidebar, flet med den eller tilføj denne sidebar manuelt."
41
 
42
+ #: content-aware-sidebars.php:196
43
  msgid "Replace"
44
  msgstr "Erstat"
45
 
46
+ #: content-aware-sidebars.php:197
47
  msgid "Merge"
48
  msgstr "Flet"
49
 
50
+ #: content-aware-sidebars.php:198
51
  msgid "Manual"
52
  msgstr "Manuel"
53
 
54
+ #: content-aware-sidebars.php:202
55
  msgid "Host Sidebar"
56
  msgstr "Værts-sidebar"
57
 
58
+ #: content-aware-sidebars.php:210 content-aware-sidebars.php:347
59
  msgid "Merge position"
60
  msgstr "Fletteposition"
61
 
62
+ #: content-aware-sidebars.php:212
63
  msgid "Place sidebar on top or bottom of host when merging."
64
  msgstr "Flet ind fra oven eller bunden."
65
 
66
+ #: content-aware-sidebars.php:216
67
  msgid "Top"
68
  msgstr "Top"
69
 
70
+ #: content-aware-sidebars.php:217
71
  msgid "Bottom"
72
  msgstr "Bund"
73
 
74
+ #: content-aware-sidebars.php:232
75
  msgid "Sidebars"
76
  msgstr "Sidebars"
77
 
78
+ #: content-aware-sidebars.php:233
79
  msgid "Sidebar"
80
  msgstr "Sidebar"
81
 
82
+ #: content-aware-sidebars.php:234
83
  msgctxt "sidebar"
84
  msgid "Add New"
85
  msgstr "Tilføj ny"
86
 
87
+ #: content-aware-sidebars.php:235
88
  msgid "Add New Sidebar"
89
  msgstr "Tilføj ny sidebar"
90
 
91
+ #: content-aware-sidebars.php:236
92
  msgid "Edit Sidebar"
93
  msgstr "Rediger sidebar"
94
 
95
+ #: content-aware-sidebars.php:237
96
  msgid "New Sidebar"
97
  msgstr "Ny sidebar"
98
 
99
+ #: content-aware-sidebars.php:238
100
  msgid "All Sidebars"
101
  msgstr "Alle sidebars"
102
 
103
+ #: content-aware-sidebars.php:239
104
  msgid "View Sidebar"
105
  msgstr "Vis sidebar"
106
 
107
+ #: content-aware-sidebars.php:240
108
  msgid "Search Sidebars"
109
  msgstr "Søg sidebars"
110
 
111
+ #: content-aware-sidebars.php:241
112
  msgid "No sidebars found"
113
  msgstr "Ingen sidebars fundet"
114
 
115
+ #: content-aware-sidebars.php:242
116
  msgid "No sidebars found in Trash"
117
  msgstr "Ingen sidebars fundet i papirkurven"
118
 
119
+ #: content-aware-sidebars.php:273
120
  msgid "Sidebar updated. <a href=\"%s\">Manage widgets</a>"
121
  msgstr "Sidebar opdateret. <a href=\"%s\">Håndter widgets</a>"
122
 
123
+ #: content-aware-sidebars.php:276
124
  msgid "Sidebar updated."
125
  msgstr "Sidebar opdateret."
126
 
127
+ #: content-aware-sidebars.php:278
128
  msgid "Sidebar published. <a href=\"%s\">Manage widgets</a>"
129
  msgstr "Sidebar udgivet. <a href=\"%s\">Håndter widgets</a>"
130
 
131
+ #: content-aware-sidebars.php:279
132
  msgid "Sidebar saved."
133
  msgstr "Sidebar gemt."
134
 
135
+ #: content-aware-sidebars.php:280
136
  msgid "Sidebar submitted. <a href=\"%s\">Manage widgets</a>"
137
  msgstr "Sidebar indsendt. <a href=\"%s\">Håndter widgets</a>"
138
 
139
+ #: content-aware-sidebars.php:281
140
  msgid ""
141
  "Sidebar scheduled for: <strong>%1$s</strong>. <a href=\"%2$s\">Manage "
142
  "widgets</a>"
145
  "widgets</a>"
146
 
147
  #. translators: Publish box date format, see http:php.net/date
148
+ #: content-aware-sidebars.php:283
149
  msgid "M j, Y @ G:i"
150
  msgstr "j. M, Y @ G:i"
151
 
152
+ #: content-aware-sidebars.php:284
153
  msgid "Sidebar draft updated."
154
  msgstr "Sidebar-kladde opdateret."
155
 
156
+ #: content-aware-sidebars.php:321 content-aware-sidebars.php:402
157
  msgid "Please update Host Sidebar"
158
  msgstr "Værts-sidebar skal opdateres"
159
 
160
+ #: content-aware-sidebars.php:457
161
  msgid "Manage Widgets"
162
  msgstr "Håndter widgets"
163
 
164
+ #: content-aware-sidebars.php:688
 
 
 
 
165
  msgid "Content"
166
  msgstr "Indhold"
167
 
168
+ #: content-aware-sidebars.php:698
169
  msgid "Options"
170
  msgstr "Indstillinger"
171
 
172
+ #: content-aware-sidebars.php:707
173
+ msgid "Spread the Word"
174
+ msgstr "Spred ordet"
175
 
176
+ #: content-aware-sidebars.php:797
177
  msgid ""
178
+ "If you love this plugin, please consider donating to support future "
179
+ "development."
180
  msgstr ""
181
+ "Hvis du elsker dette plugin, kan du overveje at donere for at støtte den "
182
+ "fremtidige udvikling."
183
 
184
+ #: content-aware-sidebars.php:802
185
+ msgid "Or you could:"
186
+ msgstr "Eller du kunne:"
187
 
188
+ #: content-aware-sidebars.php:804
189
+ msgid "Rate the plugin on WordPress.org"
190
+ msgstr "Bedømme pluginnet WordPress.org"
191
 
192
+ #: content-aware-sidebars.php:805
193
+ msgid "Link to the plugin page"
194
+ msgstr "Linke til plugin-siden"
195
+
196
+ #: modules/abstract.php:53 modules/post_type.php:111
197
  msgid "Show with All %s"
198
  msgstr "Vis ved alle %s"
199
 
200
+ #: modules/abstract.php:57 modules/taxonomy.php:163
201
  msgid "View All"
202
  msgstr "Vis alle"
203
 
204
+ #: modules/author.php:24
205
  msgid "Authors"
206
  msgstr "Forfattere"
207
 
208
+ #: modules/bbpress.php:23
209
  msgid "bbPress User Profiles"
210
  msgstr "bbPress brugerprofiler"
211
 
212
+ #: modules/bp_member.php:23
213
  msgid "BuddyPress Members"
214
  msgstr "BuddyPress medlemmer"
215
 
216
+ #: modules/page_template.php:24
217
  msgid "Page Templates"
218
  msgstr "Skabeloner"
219
 
220
+ #: modules/polylang.php:23 modules/qtranslate.php:23 modules/transposh.php:23
221
+ #: modules/wpml.php:23
222
  msgid "Languages"
223
  msgstr "Sprog"
224
 
225
+ #: modules/post_type.php:30
226
  msgid "Post Types"
227
  msgstr "Indholdstyper"
228
 
229
+ #: modules/post_type.php:105 modules/taxonomy.php:149
230
  msgid "Automatically select new children of a selected ancestor"
231
  msgstr "Vælg automatisk nye børn af den valgte forælder"
232
 
233
+ #: modules/post_type.php:115 modules/taxonomy.php:157
234
  msgid "No items."
235
  msgstr "Ingen elementer."
236
 
237
+ #: modules/post_type.php:136 modules/url.php:42
238
+ msgid "Search"
239
+ msgstr "Søg"
240
+
241
+ #: modules/post_type.php:136 modules/url.php:42
242
+ msgid "Add"
243
+ msgstr "Tilføj"
244
+
245
+ #: modules/static.php:25
246
  msgid "Static Pages"
247
  msgstr "Statiske sider"
248
 
249
+ #: modules/static.php:34
250
  msgid "Front Page"
251
  msgstr "Forside"
252
 
253
+ #: modules/static.php:35
254
  msgid "Search Results"
255
  msgstr "Søgeresultater"
256
 
257
+ #: modules/static.php:36
258
  msgid "404 Page"
259
  msgstr "404-side"
260
 
261
+ #: modules/taxonomy.php:36
262
  msgid "Taxonomies"
263
  msgstr "Taksonomier"
264
 
265
+ #: modules/taxonomy.php:153
266
  msgid "Show with %s"
267
  msgstr "Vis ved %s"
268
 
269
+ #: modules/taxonomy.php:162
270
  msgid "Most Used"
271
  msgstr "Mest brugte"
272
 
273
+ #: modules/url.php:24
274
+ msgid "URLs"
275
+ msgstr "URLs"
276
+
277
  #. Plugin Name of the plugin/theme
278
  msgid "Content Aware Sidebars"
279
  msgstr "Content Aware Sidebars"
280
 
281
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.2) #-#-#-#-#
282
  #. Plugin URI of the plugin/theme
283
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.2) #-#-#-#-#
284
  #. Author URI of the plugin/theme
285
  msgid "http://www.intox.dk/"
286
  msgstr "http://www.intox.dk/"
290
  msgstr "Administrer og vis sidebars i henhold til det indhold, der vises."
291
 
292
  #. Author of the plugin/theme
293
+ msgid "Joachim Jensen, Intox Studio"
294
+ msgstr "Joachim Jensen, Intox Studio"
295
+
296
+ #~ msgid "Words from the author"
297
+ #~ msgstr "Et par ord fra forfatteren"
298
+
299
+ #~ msgid ""
300
+ #~ "Remember to <a class=\"button\" href=\"%1$s\" target=\"_blank\">rate</a> "
301
+ #~ "and <a class=\"button\" href=\"%2$s\" target=\"_blank\">share</a> it too!"
302
+ #~ msgstr ""
303
+ #~ "Glem ikke at <a class=\"button\" href=\"%1$s\" target=\"_blank\">vurdere</"
304
+ #~ "a> og <a class=\"button\" href=\"%2$s\" target=\"_blank\">dele</a> det!"
305
+
306
+ #~ msgid "Check out Content Aware Sidebars for %23WordPress! :)"
307
+ #~ msgstr "Jeg bruger Content Aware Sidebars til %23WordPress! :)"
308
+
309
+ #~ msgid "Check out Content Aware Sidebars :)"
310
+ #~ msgstr "Jeg bruger Content Aware Sidebars :)"
311
 
312
  #~ msgid "bbPress"
313
  #~ msgstr "bbPress"
lang/content-aware-sidebars-lt_LT.mo CHANGED
Binary file
lang/content-aware-sidebars-lt_LT.po CHANGED
@@ -1,252 +1,299 @@
1
- # Copyright (C) 2012 Content Aware Sidebars
2
  # This file is distributed under the same license as the Content Aware Sidebars package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Content Aware Sidebars 0.8.2\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/content-aware-sidebars\n"
7
- "POT-Creation-Date: 2012-03-09 13:35:16+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
- "PO-Revision-Date: 2012-05-01 19:05+0200\n"
12
- "Last-Translator: \n"
13
- "Language-Team: \n"
14
- "X-Poedit-Language: Lithuanian\n"
15
- "X-Poedit-Country: Lithuania\n"
16
 
17
- #: content-aware-sidebars.php:103
18
- msgid "Post Types"
19
- msgstr "Įrašų tipai"
20
-
21
- #: content-aware-sidebars.php:111
22
- msgid "Taxonomies"
23
- msgstr "Taksonomijos"
24
-
25
- #: content-aware-sidebars.php:119
26
- msgid "Authors"
27
- msgstr "Autoriai"
28
-
29
- #: content-aware-sidebars.php:127
30
- msgid "Page Templates"
31
- msgstr "Puslapio Šablonai"
32
-
33
- #: content-aware-sidebars.php:135
34
- msgid "Static Pages"
35
- msgstr "Statiniai Puslapiai"
36
-
37
- #: content-aware-sidebars.php:141
38
- msgid "Front Page"
39
- msgstr "Namų Puslapis"
40
-
41
- #: content-aware-sidebars.php:142
42
- msgid "Search Results"
43
- msgstr "Paieškos Rezultatai"
44
-
45
- #: content-aware-sidebars.php:143
46
- msgid "404 Page"
47
- msgstr "404 Puslapis"
48
-
49
- #: content-aware-sidebars.php:147
50
- #: content-aware-sidebars.php:312
51
  msgid "Exposure"
52
- msgstr "Išlaikymas"
53
 
54
- #: content-aware-sidebars.php:153
55
  msgid "Singular"
56
- msgstr "Vienaskaitinis"
57
 
58
- #: content-aware-sidebars.php:154
59
  msgid "Singular & Archive"
60
- msgstr "Išlaikymas ir Archyvavimas"
61
 
62
- #: content-aware-sidebars.php:155
63
  msgid "Archive"
64
- msgstr "Archyvas"
65
 
66
- #: content-aware-sidebars.php:159
67
- #: content-aware-sidebars.php:313
68
  msgctxt "option"
69
  msgid "Handle"
70
- msgstr "Tvarkyti"
71
 
72
- #: content-aware-sidebars.php:161
73
  msgid "Replace host sidebar, merge with it or add sidebar manually."
74
- msgstr "Pakeisti serverio šoninę juostą , sulieti ją su tuo arba pridėti šoninę juostą rankiniu būdu"
 
 
75
 
76
- #: content-aware-sidebars.php:165
77
  msgid "Replace"
78
  msgstr "Pakeisti"
79
 
80
- #: content-aware-sidebars.php:166
81
  msgid "Merge"
82
  msgstr "Sulieti"
83
 
84
- #: content-aware-sidebars.php:167
85
  msgid "Manual"
86
- msgstr "Rankiniu būdu"
87
 
88
- #: content-aware-sidebars.php:171
89
  msgid "Host Sidebar"
90
  msgstr "Serverio šoninė juosta"
91
 
92
- #: content-aware-sidebars.php:179
93
- #: content-aware-sidebars.php:314
94
  msgid "Merge position"
95
- msgstr "Suliejimo pozicija"
96
 
97
- #: content-aware-sidebars.php:181
98
  msgid "Place sidebar on top or bottom of host when merging."
99
- msgstr "Suliejimo metu patalpinti šoninę juostą serverio viršuje arba apačioje"
 
100
 
101
- #: content-aware-sidebars.php:185
102
  msgid "Top"
103
  msgstr "Viršus"
104
 
105
- #: content-aware-sidebars.php:186
106
  msgid "Bottom"
107
  msgstr "Apačia"
108
 
109
- #: content-aware-sidebars.php:216
110
  msgid "Sidebars"
111
  msgstr "Šoninės juostos"
112
 
113
- #: content-aware-sidebars.php:217
114
  msgid "Sidebar"
115
  msgstr "Šoninė juosta"
116
 
117
- #: content-aware-sidebars.php:218
118
  msgctxt "sidebar"
119
  msgid "Add New"
120
- msgstr "Pridėti Naują"
121
 
122
- #: content-aware-sidebars.php:219
123
  msgid "Add New Sidebar"
124
- msgstr "Pridėti Naują Šoninė juostą"
125
 
126
- #: content-aware-sidebars.php:220
127
  msgid "Edit Sidebar"
128
- msgstr "Redaguoti Šoninė juostą"
129
 
130
- #: content-aware-sidebars.php:221
131
  msgid "New Sidebar"
132
- msgstr "Nauja Šoninė juosta"
133
 
134
- #: content-aware-sidebars.php:222
135
  msgid "All Sidebars"
136
- msgstr "Visos Šoninės juostos"
137
 
138
- #: content-aware-sidebars.php:223
139
  msgid "View Sidebar"
140
- msgstr "Peržiūrėti Šoninę juostą"
141
 
142
- #: content-aware-sidebars.php:224
143
  msgid "Search Sidebars"
144
- msgstr "Ieškoti Šoninių juostų"
145
 
146
- #: content-aware-sidebars.php:225
147
  msgid "No sidebars found"
148
- msgstr "Jokių šoninių juostų nerasta"
149
 
150
- #: content-aware-sidebars.php:226
151
  msgid "No sidebars found in Trash"
152
  msgstr "Šiukšlėse nerasta jokių šoninių juostų"
153
 
154
- #: content-aware-sidebars.php:247
155
  msgid "Sidebar updated. <a href=\"%s\">Manage widgets</a>"
156
- msgstr "Šoninė juosta atnaujinta. <a href=\"%s\">Valdyti tvarkiklius</a>"
157
 
158
- #: content-aware-sidebars.php:250
159
  msgid "Sidebar updated."
160
  msgstr "Šoninė juosta atnaujinta."
161
 
162
- #: content-aware-sidebars.php:252
163
  msgid "Sidebar published. <a href=\"%s\">Manage widgets</a>"
164
- msgstr "Šoninė juosta paskelbta. <a href=\"%s\">Valdyti tvarkiklius</a>"
165
 
166
- #: content-aware-sidebars.php:253
167
  msgid "Sidebar saved."
168
  msgstr "Šoninė juosta įrašyta."
169
 
170
- #: content-aware-sidebars.php:254
171
  msgid "Sidebar submitted. <a href=\"%s\">Manage widgets</a>"
172
- msgstr "Šoninė juosta pateikta <a href=\"%s\">Valdyti tvarkiklius</a>"
173
 
174
- #: content-aware-sidebars.php:255
175
- msgid "Sidebar scheduled for: <strong>%1$s</strong>. <a href=\"%2$s\">Manage widgets</a>"
176
- msgstr "Šoninė juosta suplanuota: <strong>%1$s</strong>. <a href=\"%2$s\">Valdyti tvarkiklius</a>"
 
 
 
 
177
 
178
  #. translators: Publish box date format, see http:php.net/date
179
- #: content-aware-sidebars.php:257
180
  msgid "M j, Y @ G:i"
181
  msgstr "M j, Y @ G:i"
182
 
183
- #: content-aware-sidebars.php:258
184
- msgid "Sidebar draft updated. <a href=\"%s\">Manage widgets</a>"
185
- msgstr "Šoninės juostas juodraštis atnaujintas. <a href=\"%s\">Valdyti tvarkiklius</a>"
186
 
187
- #: content-aware-sidebars.php:421
 
 
 
 
188
  msgid "Manage Widgets"
189
- msgstr "Valdyti Tvarkiklius"
190
 
191
- #: content-aware-sidebars.php:656
192
- msgid "Words from the author"
193
- msgstr "Autoriaus žodžiai"
194
 
195
- #: content-aware-sidebars.php:704
196
  msgid "Options"
197
  msgstr "Parinktys"
198
 
199
- #: content-aware-sidebars.php:781
200
- msgid "If you love this plugin, please consider donating."
201
- msgstr "Jeigu Jums patinka šis papildinys, prašome apsvarstyti paaukojimo galimybę."
202
 
203
- #: content-aware-sidebars.php:783
204
- msgid "Remember to <a class=\"button\" href=\"%1$s\" target=\"_blank\">rate</a> and <a class=\"button\" href=\"%2$s\" target=\"_blank\">share</a> it too!"
205
- msgstr "Neužmirškite <a class=\"button\" href=\"%1$s\" target=\"_blank\">įvertinti</a> ir <a class=\"button\" href=\"%2$s\" target=\"_blank\">pasidalinti</a> papildiniu!"
 
 
 
 
206
 
207
- #: content-aware-sidebars.php:785
208
- msgid "Check out Content Aware Sidebars for %23WordPress! :)"
209
- msgstr "Peržvelkite Content Aware Sidebars %23WordPress sistemai!"
210
 
211
- #: content-aware-sidebars.php:800
212
- #: content-aware-sidebars.php:852
213
- msgid "No items."
214
- msgstr "Jokių elementų."
215
 
216
- #: content-aware-sidebars.php:806
217
- msgid "Most Used"
218
- msgstr "Dažniausiai Naudoti"
 
 
 
 
219
 
220
- #: content-aware-sidebars.php:807
221
- #: content-aware-sidebars.php:858
222
- #: content-aware-sidebars.php:883
223
  msgid "View All"
224
- msgstr "Peržiūrėti Viską"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
 
226
- #: content-aware-sidebars.php:827
 
 
 
 
227
  msgid "Show with %s"
228
- msgstr "Rodyti per %s"
229
 
230
- #: content-aware-sidebars.php:871
231
- msgid "Show with All %s"
232
- msgstr "Rodyti per visus %s"
 
 
 
 
233
 
234
  #. Plugin Name of the plugin/theme
235
  msgid "Content Aware Sidebars"
236
  msgstr "Content Aware Sidebars"
237
 
238
- #. #-#-#-#-# plugin.pot (Content Aware Sidebars 0.8.2) #-#-#-#-#
239
  #. Plugin URI of the plugin/theme
240
- #. #-#-#-#-# plugin.pot (Content Aware Sidebars 0.8.2) #-#-#-#-#
241
  #. Author URI of the plugin/theme
242
  msgid "http://www.intox.dk/"
243
  msgstr "http://www.intox.dk/"
244
 
245
  #. Description of the plugin/theme
246
  msgid "Manage and show sidebars according to the content being viewed."
247
- msgstr "Valdyti ir rodyti šonines juostas pagal tai, koks turinys šiuo metu yra peržiūrimas."
 
 
248
 
249
  #. Author of the plugin/theme
250
- msgid "Joachim Jensen"
251
- msgstr "Joachim Jensen"
252
-
1
+ # Copyright (C) 2013 Content Aware Sidebars
2
  # This file is distributed under the same license as the Content Aware Sidebars package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Content Aware Sidebars 1.3\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/content-aware-sidebars\n"
7
+ "POT-Creation-Date: 2013-03-31 21:23:20+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2013-04-03 20:58+0100\n"
12
+ "Last-Translator: Joachim Jensen <jv@intox.dk>\n"
13
+ "Language-Team: Host1Free.com <info@host1free.com>\n"
14
+ "Language: Lithuanian\n"
15
+ "X-Generator: Poedit 1.5.5\n"
16
 
17
+ #: content-aware-sidebars.php:178 content-aware-sidebars.php:345
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  msgid "Exposure"
19
+ msgstr "Atidengimas"
20
 
21
+ #: content-aware-sidebars.php:184
22
  msgid "Singular"
23
+ msgstr "Išskirti"
24
 
25
+ #: content-aware-sidebars.php:185
26
  msgid "Singular & Archive"
27
+ msgstr "Išskirti ir Archyvuoti"
28
 
29
+ #: content-aware-sidebars.php:186
30
  msgid "Archive"
31
+ msgstr "Archyvuoti"
32
 
33
+ #: content-aware-sidebars.php:190 content-aware-sidebars.php:346
 
34
  msgctxt "option"
35
  msgid "Handle"
36
+ msgstr "Apdoroti [ parinktis ]"
37
 
38
+ #: content-aware-sidebars.php:192
39
  msgid "Replace host sidebar, merge with it or add sidebar manually."
40
+ msgstr ""
41
+ "Pakeisti serverio šoninę juostą, sulieti ją ar pridėti šoninę juostą "
42
+ "rankiniu būdu"
43
 
44
+ #: content-aware-sidebars.php:196
45
  msgid "Replace"
46
  msgstr "Pakeisti"
47
 
48
+ #: content-aware-sidebars.php:197
49
  msgid "Merge"
50
  msgstr "Sulieti"
51
 
52
+ #: content-aware-sidebars.php:198
53
  msgid "Manual"
54
+ msgstr "Rankinis"
55
 
56
+ #: content-aware-sidebars.php:202
57
  msgid "Host Sidebar"
58
  msgstr "Serverio šoninė juosta"
59
 
60
+ #: content-aware-sidebars.php:210 content-aware-sidebars.php:347
 
61
  msgid "Merge position"
62
+ msgstr "Sulieti poziciją"
63
 
64
+ #: content-aware-sidebars.php:212
65
  msgid "Place sidebar on top or bottom of host when merging."
66
+ msgstr ""
67
+ "Patalpinti šoninę serverio juostą viršuje arba apačioje kuomet suliejama."
68
 
69
+ #: content-aware-sidebars.php:216
70
  msgid "Top"
71
  msgstr "Viršus"
72
 
73
+ #: content-aware-sidebars.php:217
74
  msgid "Bottom"
75
  msgstr "Apačia"
76
 
77
+ #: content-aware-sidebars.php:232
78
  msgid "Sidebars"
79
  msgstr "Šoninės juostos"
80
 
81
+ #: content-aware-sidebars.php:233
82
  msgid "Sidebar"
83
  msgstr "Šoninė juosta"
84
 
85
+ #: content-aware-sidebars.php:234
86
  msgctxt "sidebar"
87
  msgid "Add New"
88
+ msgstr "Pridėti Naują [ šoninę juostą ]"
89
 
90
+ #: content-aware-sidebars.php:235
91
  msgid "Add New Sidebar"
92
+ msgstr "Pridėti Naują Šoninę Juostą"
93
 
94
+ #: content-aware-sidebars.php:236
95
  msgid "Edit Sidebar"
96
+ msgstr "Redaguoti Šoninę Juostą"
97
 
98
+ #: content-aware-sidebars.php:237
99
  msgid "New Sidebar"
100
+ msgstr "Nauja Šoninė Juosta"
101
 
102
+ #: content-aware-sidebars.php:238
103
  msgid "All Sidebars"
104
+ msgstr "Visos Šoninės Juostos"
105
 
106
+ #: content-aware-sidebars.php:239
107
  msgid "View Sidebar"
108
+ msgstr "Peržiūrėti Šoninę Juostą"
109
 
110
+ #: content-aware-sidebars.php:240
111
  msgid "Search Sidebars"
112
+ msgstr "Ieškoti Šoninių Juostų"
113
 
114
+ #: content-aware-sidebars.php:241
115
  msgid "No sidebars found"
116
+ msgstr "Šoninių juostų nerasta"
117
 
118
+ #: content-aware-sidebars.php:242
119
  msgid "No sidebars found in Trash"
120
  msgstr "Šiukšlėse nerasta jokių šoninių juostų"
121
 
122
+ #: content-aware-sidebars.php:273
123
  msgid "Sidebar updated. <a href=\"%s\">Manage widgets</a>"
124
+ msgstr "Šoninė juosta atnaujinta. <a href=\"%s\">Tvarkyti Valdiklius</a>"
125
 
126
+ #: content-aware-sidebars.php:276
127
  msgid "Sidebar updated."
128
  msgstr "Šoninė juosta atnaujinta."
129
 
130
+ #: content-aware-sidebars.php:278
131
  msgid "Sidebar published. <a href=\"%s\">Manage widgets</a>"
132
+ msgstr "Šoninė juosta publikuota. <a href=\"%s\">Manage widgets</a>"
133
 
134
+ #: content-aware-sidebars.php:279
135
  msgid "Sidebar saved."
136
  msgstr "Šoninė juosta įrašyta."
137
 
138
+ #: content-aware-sidebars.php:280
139
  msgid "Sidebar submitted. <a href=\"%s\">Manage widgets</a>"
140
+ msgstr "Šoninė juosta išsiųsta. <a href=\"%s\">Manage widgets</a>"
141
 
142
+ #: content-aware-sidebars.php:281
143
+ msgid ""
144
+ "Sidebar scheduled for: <strong>%1$s</strong>. <a href=\"%2$s\">Manage "
145
+ "widgets</a>"
146
+ msgstr ""
147
+ "Šoninė juosta suplanuota už: <strong>%1$s</strong>. <a href=\"%s\">Manage "
148
+ "widgets</a>"
149
 
150
  #. translators: Publish box date format, see http:php.net/date
151
+ #: content-aware-sidebars.php:283
152
  msgid "M j, Y @ G:i"
153
  msgstr "M j, Y @ G:i"
154
 
155
+ #: content-aware-sidebars.php:284
156
+ msgid "Sidebar draft updated."
157
+ msgstr "Šoninės juostos juodraštis atnaujintas."
158
 
159
+ #: content-aware-sidebars.php:321 content-aware-sidebars.php:402
160
+ msgid "Please update Host Sidebar"
161
+ msgstr "Prašome atnaujinti Serverio Šoninę Juostą"
162
+
163
+ #: content-aware-sidebars.php:457
164
  msgid "Manage Widgets"
165
+ msgstr "Tvarkyti Valdiklius"
166
 
167
+ #: content-aware-sidebars.php:688
168
+ msgid "Content"
169
+ msgstr "Turinys"
170
 
171
+ #: content-aware-sidebars.php:698
172
  msgid "Options"
173
  msgstr "Parinktys"
174
 
175
+ #: content-aware-sidebars.php:707
176
+ msgid "Spread the Word"
177
+ msgstr "Paskleiskite Žinią"
178
 
179
+ #: content-aware-sidebars.php:797
180
+ msgid ""
181
+ "If you love this plugin, please consider donating to support future "
182
+ "development."
183
+ msgstr ""
184
+ "Jeigu Jums patiko šis papildinys, prašome paaukoti. Taip prisidėsi prie "
185
+ "tolesnio papildinio plėtojimo."
186
 
187
+ #: content-aware-sidebars.php:802
188
+ msgid "Or you could:"
189
+ msgstr "Arba galite:"
190
 
191
+ #: content-aware-sidebars.php:804
192
+ msgid "Rate the plugin on WordPress.org"
193
+ msgstr "Įvertinti papildinį WordPress.org svetainėje"
 
194
 
195
+ #: content-aware-sidebars.php:805
196
+ msgid "Link to the plugin page"
197
+ msgstr "Nukreipti į papildinio puslapį"
198
+
199
+ #: modules/abstract.php:53 modules/post_type.php:111
200
+ msgid "Show with All %s"
201
+ msgstr "Rodyti su Visais %s"
202
 
203
+ #: modules/abstract.php:57 modules/taxonomy.php:163
 
 
204
  msgid "View All"
205
+ msgstr "Peržiūrėti Visus"
206
+
207
+ #: modules/author.php:24
208
+ msgid "Authors"
209
+ msgstr "Autorius"
210
+
211
+ #: modules/bbpress.php:23
212
+ msgid "bbPress User Profiles"
213
+ msgstr "bbPress Vartotojų Profilius"
214
+
215
+ #: modules/bp_member.php:23
216
+ msgid "BuddyPress Members"
217
+ msgstr "BuddyPress Narius"
218
+
219
+ #: modules/page_template.php:24
220
+ msgid "Page Templates"
221
+ msgstr "Puslapių Ruošinius"
222
+
223
+ #: modules/polylang.php:23 modules/qtranslate.php:23 modules/transposh.php:23
224
+ #: modules/wpml.php:23
225
+ msgid "Languages"
226
+ msgstr "Kalbas"
227
+
228
+ #: modules/post_type.php:30
229
+ msgid "Post Types"
230
+ msgstr "Įrašų Tipus"
231
+
232
+ #: modules/post_type.php:105 modules/taxonomy.php:149
233
+ msgid "Automatically select new children of a selected ancestor"
234
+ msgstr "Automatiškai pasirinkti naujus pažymėtų savininkų \"vaikus\"."
235
+
236
+ #: modules/post_type.php:115 modules/taxonomy.php:157
237
+ msgid "No items."
238
+ msgstr "Jokių elementų. "
239
+
240
+ #: modules/post_type.php:136 modules/url.php:42
241
+ msgid "Search"
242
+ msgstr "Ieškoti"
243
+
244
+ #: modules/post_type.php:136 modules/url.php:42
245
+ msgid "Add"
246
+ msgstr "Pridėti"
247
+
248
+ #: modules/static.php:25
249
+ msgid "Static Pages"
250
+ msgstr "Statiniai Puslapiai"
251
+
252
+ #: modules/static.php:34
253
+ msgid "Front Page"
254
+ msgstr "Titulinis Puslapis"
255
+
256
+ #: modules/static.php:35
257
+ msgid "Search Results"
258
+ msgstr "Paieškos Rezultatai"
259
+
260
+ #: modules/static.php:36
261
+ msgid "404 Page"
262
+ msgstr "404 Puslapis"
263
 
264
+ #: modules/taxonomy.php:36
265
+ msgid "Taxonomies"
266
+ msgstr "Taksonomijos"
267
+
268
+ #: modules/taxonomy.php:153
269
  msgid "Show with %s"
270
+ msgstr "Rodyti su %s"
271
 
272
+ #: modules/taxonomy.php:162
273
+ msgid "Most Used"
274
+ msgstr "Dažniausiai naudoti(os)"
275
+
276
+ #: modules/url.php:24
277
+ msgid "URLs"
278
+ msgstr "Universalieji Adresai"
279
 
280
  #. Plugin Name of the plugin/theme
281
  msgid "Content Aware Sidebars"
282
  msgstr "Content Aware Sidebars"
283
 
284
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.2) #-#-#-#-#
285
  #. Plugin URI of the plugin/theme
286
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.2) #-#-#-#-#
287
  #. Author URI of the plugin/theme
288
  msgid "http://www.intox.dk/"
289
  msgstr "http://www.intox.dk/"
290
 
291
  #. Description of the plugin/theme
292
  msgid "Manage and show sidebars according to the content being viewed."
293
+ msgstr ""
294
+ "Pagal šiuo metu peržiūrimą turinį valdykite ir rodykite tinkamas šonines "
295
+ "juostas."
296
 
297
  #. Author of the plugin/theme
298
+ msgid "Joachim Jensen, Intox Studio"
299
+ msgstr "Joachim Jensen, Intox Studio"
 
lang/content-aware-sidebars.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the Content Aware Sidebars package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Content Aware Sidebars 1.1.2\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/content-aware-sidebars\n"
7
- "POT-Creation-Date: 2013-01-07 16:09:52+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -12,257 +12,269 @@ msgstr ""
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
- #: content-aware-sidebars.php:150 content-aware-sidebars.php:327
16
  msgid "Exposure"
17
  msgstr ""
18
 
19
- #: content-aware-sidebars.php:156
20
  msgid "Singular"
21
  msgstr ""
22
 
23
- #: content-aware-sidebars.php:157
24
  msgid "Singular & Archive"
25
  msgstr ""
26
 
27
- #: content-aware-sidebars.php:158
28
  msgid "Archive"
29
  msgstr ""
30
 
31
- #: content-aware-sidebars.php:162 content-aware-sidebars.php:328
32
  msgctxt "option"
33
  msgid "Handle"
34
  msgstr ""
35
 
36
- #: content-aware-sidebars.php:164
37
  msgid "Replace host sidebar, merge with it or add sidebar manually."
38
  msgstr ""
39
 
40
- #: content-aware-sidebars.php:168
41
  msgid "Replace"
42
  msgstr ""
43
 
44
- #: content-aware-sidebars.php:169
45
  msgid "Merge"
46
  msgstr ""
47
 
48
- #: content-aware-sidebars.php:170
49
  msgid "Manual"
50
  msgstr ""
51
 
52
- #: content-aware-sidebars.php:174
53
  msgid "Host Sidebar"
54
  msgstr ""
55
 
56
- #: content-aware-sidebars.php:182 content-aware-sidebars.php:329
57
  msgid "Merge position"
58
  msgstr ""
59
 
60
- #: content-aware-sidebars.php:184
61
  msgid "Place sidebar on top or bottom of host when merging."
62
  msgstr ""
63
 
64
- #: content-aware-sidebars.php:188
65
  msgid "Top"
66
  msgstr ""
67
 
68
- #: content-aware-sidebars.php:189
69
  msgid "Bottom"
70
  msgstr ""
71
 
72
- #: content-aware-sidebars.php:210
73
  msgid "Sidebars"
74
  msgstr ""
75
 
76
- #: content-aware-sidebars.php:211
77
  msgid "Sidebar"
78
  msgstr ""
79
 
80
- #: content-aware-sidebars.php:212
81
  msgctxt "sidebar"
82
  msgid "Add New"
83
  msgstr ""
84
 
85
- #: content-aware-sidebars.php:213
86
  msgid "Add New Sidebar"
87
  msgstr ""
88
 
89
- #: content-aware-sidebars.php:214
90
  msgid "Edit Sidebar"
91
  msgstr ""
92
 
93
- #: content-aware-sidebars.php:215
94
  msgid "New Sidebar"
95
  msgstr ""
96
 
97
- #: content-aware-sidebars.php:216
98
  msgid "All Sidebars"
99
  msgstr ""
100
 
101
- #: content-aware-sidebars.php:217
102
  msgid "View Sidebar"
103
  msgstr ""
104
 
105
- #: content-aware-sidebars.php:218
106
  msgid "Search Sidebars"
107
  msgstr ""
108
 
109
- #: content-aware-sidebars.php:219
110
  msgid "No sidebars found"
111
  msgstr ""
112
 
113
- #: content-aware-sidebars.php:220
114
  msgid "No sidebars found in Trash"
115
  msgstr ""
116
 
117
- #: content-aware-sidebars.php:253
118
  msgid "Sidebar updated. <a href=\"%s\">Manage widgets</a>"
119
  msgstr ""
120
 
121
- #: content-aware-sidebars.php:256
122
  msgid "Sidebar updated."
123
  msgstr ""
124
 
125
- #: content-aware-sidebars.php:258
126
  msgid "Sidebar published. <a href=\"%s\">Manage widgets</a>"
127
  msgstr ""
128
 
129
- #: content-aware-sidebars.php:259
130
  msgid "Sidebar saved."
131
  msgstr ""
132
 
133
- #: content-aware-sidebars.php:260
134
  msgid "Sidebar submitted. <a href=\"%s\">Manage widgets</a>"
135
  msgstr ""
136
 
137
- #: content-aware-sidebars.php:261
138
  msgid ""
139
  "Sidebar scheduled for: <strong>%1$s</strong>. <a href=\"%2$s\">Manage "
140
  "widgets</a>"
141
  msgstr ""
142
 
143
  #. translators: Publish box date format, see http:php.net/date
144
- #: content-aware-sidebars.php:263
145
  msgid "M j, Y @ G:i"
146
  msgstr ""
147
 
148
- #: content-aware-sidebars.php:264
149
  msgid "Sidebar draft updated."
150
  msgstr ""
151
 
152
- #: content-aware-sidebars.php:391
153
  msgid "Please update Host Sidebar"
154
  msgstr ""
155
 
156
- #: content-aware-sidebars.php:454
157
  msgid "Manage Widgets"
158
  msgstr ""
159
 
160
- #: content-aware-sidebars.php:651
161
- msgid "Words from the author"
162
- msgstr ""
163
-
164
- #: content-aware-sidebars.php:661
165
  msgid "Content"
166
  msgstr ""
167
 
168
- #: content-aware-sidebars.php:671
169
  msgid "Options"
170
  msgstr ""
171
 
172
- #: content-aware-sidebars.php:766
173
- msgid "If you love this plugin, please consider donating."
174
  msgstr ""
175
 
176
- #: content-aware-sidebars.php:768
177
  msgid ""
178
- "Remember to <a class=\"button\" href=\"%1$s\" target=\"_blank\">rate</a> and "
179
- "<a class=\"button\" href=\"%2$s\" target=\"_blank\">share</a> it too!"
 
 
 
 
180
  msgstr ""
181
 
182
- #: content-aware-sidebars.php:770
183
- msgid "Check out Content Aware Sidebars for %23WordPress! :)"
184
  msgstr ""
185
 
186
- #: content-aware-sidebars.php:772
187
- msgid "Check out Content Aware Sidebars :)"
188
  msgstr ""
189
 
190
- #: modules/abstract.php:39 modules/post_type.php:78
191
  msgid "Show with All %s"
192
  msgstr ""
193
 
194
- #: modules/abstract.php:43 modules/post_type.php:88 modules/taxonomy.php:121
195
  msgid "View All"
196
  msgstr ""
197
 
198
- #: modules/author.php:21
199
  msgid "Authors"
200
  msgstr ""
201
 
202
- #: modules/bbpress.php:20
203
  msgid "bbPress User Profiles"
204
  msgstr ""
205
 
206
- #: modules/bp_member.php:20
207
  msgid "BuddyPress Members"
208
  msgstr ""
209
 
210
- #: modules/page_template.php:21
211
  msgid "Page Templates"
212
  msgstr ""
213
 
214
- #: modules/polylang.php:20 modules/qtranslate.php:20 modules/transposh.php:20
215
- #: modules/wpml.php:20
216
  msgid "Languages"
217
  msgstr ""
218
 
219
- #: modules/post_type.php:23
220
  msgid "Post Types"
221
  msgstr ""
222
 
223
- #: modules/post_type.php:73 modules/taxonomy.php:107
224
  msgid "Automatically select new children of a selected ancestor"
225
  msgstr ""
226
 
227
- #: modules/post_type.php:82 modules/taxonomy.php:115
228
  msgid "No items."
229
  msgstr ""
230
 
231
- #: modules/static.php:22
 
 
 
 
 
 
 
 
232
  msgid "Static Pages"
233
  msgstr ""
234
 
235
- #: modules/static.php:27
236
  msgid "Front Page"
237
  msgstr ""
238
 
239
- #: modules/static.php:28
240
  msgid "Search Results"
241
  msgstr ""
242
 
243
- #: modules/static.php:29
244
  msgid "404 Page"
245
  msgstr ""
246
 
247
- #: modules/taxonomy.php:24
248
  msgid "Taxonomies"
249
  msgstr ""
250
 
251
- #: modules/taxonomy.php:111
252
  msgid "Show with %s"
253
  msgstr ""
254
 
255
- #: modules/taxonomy.php:120
256
  msgid "Most Used"
257
  msgstr ""
258
 
 
 
 
 
259
  #. Plugin Name of the plugin/theme
260
  msgid "Content Aware Sidebars"
261
  msgstr ""
262
 
263
- #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.1.2) #-#-#-#-#
264
  #. Plugin URI of the plugin/theme
265
- #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.1.2) #-#-#-#-#
266
  #. Author URI of the plugin/theme
267
  msgid "http://www.intox.dk/"
268
  msgstr ""
@@ -272,5 +284,5 @@ msgid "Manage and show sidebars according to the content being viewed."
272
  msgstr ""
273
 
274
  #. Author of the plugin/theme
275
- msgid "Joachim Jensen"
276
  msgstr ""
2
  # This file is distributed under the same license as the Content Aware Sidebars package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Content Aware Sidebars 1.2\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/content-aware-sidebars\n"
7
+ "POT-Creation-Date: 2013-03-31 21:23:20+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
+ #: content-aware-sidebars.php:178 content-aware-sidebars.php:345
16
  msgid "Exposure"
17
  msgstr ""
18
 
19
+ #: content-aware-sidebars.php:184
20
  msgid "Singular"
21
  msgstr ""
22
 
23
+ #: content-aware-sidebars.php:185
24
  msgid "Singular & Archive"
25
  msgstr ""
26
 
27
+ #: content-aware-sidebars.php:186
28
  msgid "Archive"
29
  msgstr ""
30
 
31
+ #: content-aware-sidebars.php:190 content-aware-sidebars.php:346
32
  msgctxt "option"
33
  msgid "Handle"
34
  msgstr ""
35
 
36
+ #: content-aware-sidebars.php:192
37
  msgid "Replace host sidebar, merge with it or add sidebar manually."
38
  msgstr ""
39
 
40
+ #: content-aware-sidebars.php:196
41
  msgid "Replace"
42
  msgstr ""
43
 
44
+ #: content-aware-sidebars.php:197
45
  msgid "Merge"
46
  msgstr ""
47
 
48
+ #: content-aware-sidebars.php:198
49
  msgid "Manual"
50
  msgstr ""
51
 
52
+ #: content-aware-sidebars.php:202
53
  msgid "Host Sidebar"
54
  msgstr ""
55
 
56
+ #: content-aware-sidebars.php:210 content-aware-sidebars.php:347
57
  msgid "Merge position"
58
  msgstr ""
59
 
60
+ #: content-aware-sidebars.php:212
61
  msgid "Place sidebar on top or bottom of host when merging."
62
  msgstr ""
63
 
64
+ #: content-aware-sidebars.php:216
65
  msgid "Top"
66
  msgstr ""
67
 
68
+ #: content-aware-sidebars.php:217
69
  msgid "Bottom"
70
  msgstr ""
71
 
72
+ #: content-aware-sidebars.php:232
73
  msgid "Sidebars"
74
  msgstr ""
75
 
76
+ #: content-aware-sidebars.php:233
77
  msgid "Sidebar"
78
  msgstr ""
79
 
80
+ #: content-aware-sidebars.php:234
81
  msgctxt "sidebar"
82
  msgid "Add New"
83
  msgstr ""
84
 
85
+ #: content-aware-sidebars.php:235
86
  msgid "Add New Sidebar"
87
  msgstr ""
88
 
89
+ #: content-aware-sidebars.php:236
90
  msgid "Edit Sidebar"
91
  msgstr ""
92
 
93
+ #: content-aware-sidebars.php:237
94
  msgid "New Sidebar"
95
  msgstr ""
96
 
97
+ #: content-aware-sidebars.php:238
98
  msgid "All Sidebars"
99
  msgstr ""
100
 
101
+ #: content-aware-sidebars.php:239
102
  msgid "View Sidebar"
103
  msgstr ""
104
 
105
+ #: content-aware-sidebars.php:240
106
  msgid "Search Sidebars"
107
  msgstr ""
108
 
109
+ #: content-aware-sidebars.php:241
110
  msgid "No sidebars found"
111
  msgstr ""
112
 
113
+ #: content-aware-sidebars.php:242
114
  msgid "No sidebars found in Trash"
115
  msgstr ""
116
 
117
+ #: content-aware-sidebars.php:273
118
  msgid "Sidebar updated. <a href=\"%s\">Manage widgets</a>"
119
  msgstr ""
120
 
121
+ #: content-aware-sidebars.php:276
122
  msgid "Sidebar updated."
123
  msgstr ""
124
 
125
+ #: content-aware-sidebars.php:278
126
  msgid "Sidebar published. <a href=\"%s\">Manage widgets</a>"
127
  msgstr ""
128
 
129
+ #: content-aware-sidebars.php:279
130
  msgid "Sidebar saved."
131
  msgstr ""
132
 
133
+ #: content-aware-sidebars.php:280
134
  msgid "Sidebar submitted. <a href=\"%s\">Manage widgets</a>"
135
  msgstr ""
136
 
137
+ #: content-aware-sidebars.php:281
138
  msgid ""
139
  "Sidebar scheduled for: <strong>%1$s</strong>. <a href=\"%2$s\">Manage "
140
  "widgets</a>"
141
  msgstr ""
142
 
143
  #. translators: Publish box date format, see http:php.net/date
144
+ #: content-aware-sidebars.php:283
145
  msgid "M j, Y @ G:i"
146
  msgstr ""
147
 
148
+ #: content-aware-sidebars.php:284
149
  msgid "Sidebar draft updated."
150
  msgstr ""
151
 
152
+ #: content-aware-sidebars.php:321 content-aware-sidebars.php:402
153
  msgid "Please update Host Sidebar"
154
  msgstr ""
155
 
156
+ #: content-aware-sidebars.php:457
157
  msgid "Manage Widgets"
158
  msgstr ""
159
 
160
+ #: content-aware-sidebars.php:688
 
 
 
 
161
  msgid "Content"
162
  msgstr ""
163
 
164
+ #: content-aware-sidebars.php:698
165
  msgid "Options"
166
  msgstr ""
167
 
168
+ #: content-aware-sidebars.php:707
169
+ msgid "Spread the Word"
170
  msgstr ""
171
 
172
+ #: content-aware-sidebars.php:797
173
  msgid ""
174
+ "If you love this plugin, please consider donating to support future "
175
+ "development."
176
+ msgstr ""
177
+
178
+ #: content-aware-sidebars.php:802
179
+ msgid "Or you could:"
180
  msgstr ""
181
 
182
+ #: content-aware-sidebars.php:804
183
+ msgid "Rate the plugin on WordPress.org"
184
  msgstr ""
185
 
186
+ #: content-aware-sidebars.php:805
187
+ msgid "Link to the plugin page"
188
  msgstr ""
189
 
190
+ #: modules/abstract.php:53 modules/post_type.php:111
191
  msgid "Show with All %s"
192
  msgstr ""
193
 
194
+ #: modules/abstract.php:57 modules/taxonomy.php:163
195
  msgid "View All"
196
  msgstr ""
197
 
198
+ #: modules/author.php:24
199
  msgid "Authors"
200
  msgstr ""
201
 
202
+ #: modules/bbpress.php:23
203
  msgid "bbPress User Profiles"
204
  msgstr ""
205
 
206
+ #: modules/bp_member.php:23
207
  msgid "BuddyPress Members"
208
  msgstr ""
209
 
210
+ #: modules/page_template.php:24
211
  msgid "Page Templates"
212
  msgstr ""
213
 
214
+ #: modules/polylang.php:23 modules/qtranslate.php:23 modules/transposh.php:23
215
+ #: modules/wpml.php:23
216
  msgid "Languages"
217
  msgstr ""
218
 
219
+ #: modules/post_type.php:30
220
  msgid "Post Types"
221
  msgstr ""
222
 
223
+ #: modules/post_type.php:105 modules/taxonomy.php:149
224
  msgid "Automatically select new children of a selected ancestor"
225
  msgstr ""
226
 
227
+ #: modules/post_type.php:115 modules/taxonomy.php:157
228
  msgid "No items."
229
  msgstr ""
230
 
231
+ #: modules/post_type.php:136 modules/url.php:42
232
+ msgid "Search"
233
+ msgstr ""
234
+
235
+ #: modules/post_type.php:136 modules/url.php:42
236
+ msgid "Add"
237
+ msgstr ""
238
+
239
+ #: modules/static.php:25
240
  msgid "Static Pages"
241
  msgstr ""
242
 
243
+ #: modules/static.php:34
244
  msgid "Front Page"
245
  msgstr ""
246
 
247
+ #: modules/static.php:35
248
  msgid "Search Results"
249
  msgstr ""
250
 
251
+ #: modules/static.php:36
252
  msgid "404 Page"
253
  msgstr ""
254
 
255
+ #: modules/taxonomy.php:36
256
  msgid "Taxonomies"
257
  msgstr ""
258
 
259
+ #: modules/taxonomy.php:153
260
  msgid "Show with %s"
261
  msgstr ""
262
 
263
+ #: modules/taxonomy.php:162
264
  msgid "Most Used"
265
  msgstr ""
266
 
267
+ #: modules/url.php:24
268
+ msgid "URLs"
269
+ msgstr ""
270
+
271
  #. Plugin Name of the plugin/theme
272
  msgid "Content Aware Sidebars"
273
  msgstr ""
274
 
275
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.2) #-#-#-#-#
276
  #. Plugin URI of the plugin/theme
277
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.2) #-#-#-#-#
278
  #. Author URI of the plugin/theme
279
  msgid "http://www.intox.dk/"
280
  msgstr ""
284
  msgstr ""
285
 
286
  #. Author of the plugin/theme
287
+ msgid "Joachim Jensen, Intox Studio"
288
  msgstr ""
lang/content-aware-sidebars_sk_SK.mo ADDED
Binary file
lang/content-aware-sidebars_sk_SK.po ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: \n"
4
+ "POT-Creation-Date: \n"
5
+ "PO-Revision-Date: \n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: \n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=iso-8859-1\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 1.5.4\n"
12
+
13
+ # Copyright (C) 2013 Content Aware Sidebars
14
+ # This file is distributed under the same license as the Content Aware Sidebars package.
15
+
16
+
17
+ #: content-aware-sidebars.php:150 content-aware-sidebars.php:327
18
+ msgid "Exposure"
19
+ msgstr "Expozicie"
20
+
21
+ #: content-aware-sidebars.php:156
22
+ msgid "Singular"
23
+ msgstr "Singularni"
24
+
25
+ #: content-aware-sidebars.php:157
26
+ msgid "Singular & Archive"
27
+ msgstr "Singularni & Archiv"
28
+
29
+ #: content-aware-sidebars.php:158
30
+ msgid "Archive"
31
+ msgstr "Archiv"
32
+
33
+ #: content-aware-sidebars.php:162 content-aware-sidebars.php:328
34
+ msgctxt "option"
35
+ msgid "Handle"
36
+ msgstr "Rukovat"
37
+
38
+ #: content-aware-sidebars.php:164
39
+ msgid "Replace host sidebar, merge with it or add sidebar manually."
40
+ msgstr ""
41
+ "Nahradit hostitela sidebar, zlucit s nim alebo manualne pridat sidebar."
42
+
43
+ #: content-aware-sidebars.php:168
44
+ msgid "Replace"
45
+ msgstr "Nahradit"
46
+
47
+ #: content-aware-sidebars.php:169
48
+ msgid "Merge"
49
+ msgstr "Zlucit"
50
+
51
+ #: content-aware-sidebars.php:170
52
+ msgid "Manual"
53
+ msgstr "Manual"
54
+
55
+ #: content-aware-sidebars.php:174
56
+ msgid "Host Sidebar"
57
+ msgstr "Hostitel Sidebar"
58
+
59
+ #: content-aware-sidebars.php:182 content-aware-sidebars.php:329
60
+ msgid "Merge position"
61
+ msgstr "Zlucit pozicie"
62
+
63
+ #: content-aware-sidebars.php:184
64
+ msgid "Place sidebar on top or bottom of host when merging."
65
+ msgstr "Miesto sidebar na hornej alebo dolnej casti hostitela pri zlucovani."
66
+
67
+ #: content-aware-sidebars.php:188
68
+ msgid "Top"
69
+ msgstr "Top"
70
+
71
+ #: content-aware-sidebars.php:189
72
+ msgid "Bottom"
73
+ msgstr "Dno"
74
+
75
+ #: content-aware-sidebars.php:210
76
+ msgid "Sidebars"
77
+ msgstr "Bocne panely"
78
+
79
+ #: content-aware-sidebars.php:211
80
+ msgid "Sidebar"
81
+ msgstr "Bocny panel"
82
+
83
+ #: content-aware-sidebars.php:212
84
+ msgctxt "sidebar"
85
+ msgid "Add New"
86
+ msgstr "Pridat nove"
87
+
88
+ #: content-aware-sidebars.php:213
89
+ msgid "Add New Sidebar"
90
+ msgstr "Pridat novy bocny panel"
91
+
92
+ #: content-aware-sidebars.php:214
93
+ msgid "Edit Sidebar"
94
+ msgstr "Upravit Sidebar"
95
+
96
+ #: content-aware-sidebars.php:215
97
+ msgid "New Sidebar"
98
+ msgstr "Novy bocny panel"
99
+
100
+ #: content-aware-sidebars.php:216
101
+ msgid "All Sidebars"
102
+ msgstr "Vsetci postranne"
103
+
104
+ #: content-aware-sidebars.php:217
105
+ msgid "View Sidebar"
106
+ msgstr "Zobrazit bocny panel"
107
+
108
+ #: content-aware-sidebars.php:218
109
+ msgid "Search Sidebars"
110
+ msgstr "Hladat Sidebars"
111
+
112
+ #: content-aware-sidebars.php:219
113
+ msgid "No sidebars found"
114
+ msgstr "C sidebars nasiel"
115
+
116
+ #: content-aware-sidebars.php:220
117
+ msgid "No sidebars found in Trash"
118
+ msgstr "Ziadne sidebars, nachadza v kosi"
119
+
120
+ #: content-aware-sidebars.php:253
121
+ msgid "Sidebar updated. <a href=\"%s\">Manage widgets</a>"
122
+ msgstr "Sidebar aktualizovane. <a href=\"%s\">Spravovat widgety</a>"
123
+
124
+ #: content-aware-sidebars.php:256
125
+ msgid "Sidebar updated."
126
+ msgstr "Sidebar aktualizovane."
127
+
128
+ #: content-aware-sidebars.php:258
129
+ msgid "Sidebar published. <a href=\"%s\">Manage widgets</a>"
130
+ msgstr "Bocny panel publikoval. <a href=\"%s\">Spravovat widgety</a>"
131
+
132
+ #: content-aware-sidebars.php:259
133
+ msgid "Sidebar saved."
134
+ msgstr "Sidebar ulozene."
135
+
136
+ #: content-aware-sidebars.php:260
137
+ msgid "Sidebar submitted. <a href=\"%s\">Manage widgets</a>"
138
+ msgstr "Bocnom paneli posielaju. <a href=\"%s\">Spravovat widgety</a>"
139
+
140
+ #: content-aware-sidebars.php:261
141
+ msgid ""
142
+ "this-is-translatedSidebar scheduled for: <strong>%1$s</strong>. <a href="
143
+ "\"%2$s\">Manage widgets</a>"
144
+ msgstr ""
145
+ "Sidebar naplanovane na: <strong>%1$</strong>. <a href=\"%2$s\">Spravovat "
146
+ "widgety</a>"
147
+
148
+ #. translators: Publish box date format, see http:php.net/date
149
+ #: content-aware-sidebars.php:263
150
+ msgid "M j, Y @ G:i"
151
+ msgstr "M j, Y @ G:i"
152
+
153
+ #: content-aware-sidebars.php:264
154
+ msgid "Sidebar draft updated."
155
+ msgstr "Sidebar navrh aktualizovane."
156
+
157
+ #: content-aware-sidebars.php:391
158
+ msgid "Please update Host Sidebar"
159
+ msgstr "Prosim aktualizujte hostitela Sidebar"
160
+
161
+ #: content-aware-sidebars.php:454
162
+ msgid "Manage Widgets"
163
+ msgstr "Spravovat widgety"
164
+
165
+ #: content-aware-sidebars.php:651
166
+ msgid "Words from the author"
167
+ msgstr "Slov od autora"
168
+
169
+ #: content-aware-sidebars.php:661
170
+ msgid "Content"
171
+ msgstr "Obsah"
172
+
173
+ #: content-aware-sidebars.php:671
174
+ msgid "Options"
175
+ msgstr "Moznosti"
176
+
177
+ #: content-aware-sidebars.php:766
178
+ msgid "If you love this plugin, please consider donating."
179
+ msgstr "Ak mate radi tento plugin, prosim zvazte darovanie."
180
+
181
+ #: content-aware-sidebars.php:768
182
+ msgid ""
183
+ "this-is-translatedRemember to <a class=\"button\" href=\"%1$s\" target="
184
+ "\"_blank\">rate</a> and <a class=\"button\" href=\"%2$s\" target=\"_blank"
185
+ "\">share</a> it too!"
186
+ msgstr ""
187
+ "Nezabudnite <a class=\"button\" href=\"%1$s\" target=\"_blank\">rate</a> and "
188
+ "<a class=\"button\" href=\"%2$s\" target=\"_blank\">zdielat</a> to taky!"
189
+
190
+ #: content-aware-sidebars.php:770
191
+ msgid "Check out Content Aware Sidebars for %23WordPress! :)"
192
+ msgstr "Pozrite sa na obsah vedomi postrehov pre % 23WordPress! :)"
193
+
194
+ #: content-aware-sidebars.php:772
195
+ msgid "Check out Content Aware Sidebars :)"
196
+ msgstr "Pozrite sa na obsah vedomi Sidebars:)"
197
+
198
+ #: modules/abstract.php:39 modules/post_type.php:78
199
+ msgid "Show with All %s"
200
+ msgstr "Zobrazit s vsetky %s"
201
+
202
+ #: modules/abstract.php:43 modules/post_type.php:88 modules/taxonomy.php:121
203
+ msgid "View All"
204
+ msgstr "Zobrazit vsetky"
205
+
206
+ #: modules/author.php:21
207
+ msgid "Authors"
208
+ msgstr "Autori"
209
+
210
+ #: modules/bbpress.php:20
211
+ msgid "bbPress User Profiles"
212
+ msgstr "bbPress pouzivatelske profily"
213
+
214
+ #: modules/bp_member.php:20
215
+ msgid "BuddyPress Members"
216
+ msgstr "BuddyPress clenov"
217
+
218
+ #: modules/page_template.php:21
219
+ msgid "Page Templates"
220
+ msgstr "Stranky sablony"
221
+
222
+ #: modules/polylang.php:20 modules/qtranslate.php:20 modules/transposh.php:20
223
+ #: modules/wpml.php:20
224
+ msgid "Languages"
225
+ msgstr "Jazyky"
226
+
227
+ #: modules/post_type.php:23
228
+ msgid "Post Types"
229
+ msgstr "Prispevok typy"
230
+
231
+ #: modules/post_type.php:73 modules/taxonomy.php:107
232
+ msgid "Automatically select new children of a selected ancestor"
233
+ msgstr "Automaticky vybrat nove deti z vybranych predok"
234
+
235
+ #: modules/post_type.php:82 modules/taxonomy.php:115
236
+ msgid "No items."
237
+ msgstr "Ziadne polozky."
238
+
239
+ #: modules/static.php:22
240
+ msgid "Static Pages"
241
+ msgstr "Staticke stranky"
242
+
243
+ #: modules/static.php:27
244
+ msgid "Front Page"
245
+ msgstr "Predna strana"
246
+
247
+ #: modules/static.php:28
248
+ msgid "Search Results"
249
+ msgstr "Vysledky hladania"
250
+
251
+ #: modules/static.php:29
252
+ msgid "404 Page"
253
+ msgstr "404 Stranka"
254
+
255
+ #: modules/taxonomy.php:24
256
+ msgid "Taxonomies"
257
+ msgstr "Taxonomie"
258
+
259
+ #: modules/taxonomy.php:111
260
+ msgid "Show with %s"
261
+ msgstr "Zobrazit s %s"
262
+
263
+ #: modules/taxonomy.php:120
264
+ msgid "Most Used"
265
+ msgstr "Najpouzivanejsie"
266
+
267
+ #. Plugin Name of the plugin/theme
268
+ msgid "Content Aware Sidebars"
269
+ msgstr "Obsah vedomi Sidebars"
270
+
271
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.1.2) #-#-#-#-#
272
+ #. Plugin URI of the plugin/theme
273
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.1.2) #-#-#-#-#
274
+ #. Author URI of the plugin/theme
275
+ msgid "http://www.intox.dk/"
276
+ msgstr "http://www.Intox.dk/"
277
+
278
+ #. Description of the plugin/theme
279
+ msgid "Manage and show sidebars according to the content being viewed."
280
+ msgstr "Spravovat a Zobrazit sidebars podla obsahu je prezerana."
281
+
282
+ #. Author of the plugin/theme
283
+ msgid "Joachim Jensen"
284
+ msgstr "Joachim Jensen"
modules/abstract.php CHANGED
@@ -11,8 +11,23 @@
11
  */
12
  abstract class CASModule {
13
 
 
 
 
 
14
  protected $id;
 
 
 
 
 
15
  protected $name;
 
 
 
 
 
 
16
 
17
  /**
18
  *
@@ -23,6 +38,11 @@ abstract class CASModule {
23
  $this->id = substr(get_class($this),strpos(get_class($this),'_')+1);
24
  }
25
 
 
 
 
 
 
26
  public function meta_box_content() {
27
  global $post;
28
 
@@ -31,36 +51,42 @@ abstract class CASModule {
31
 
32
  echo '<h4><a href="#">'.$this->name.'</a></h4>'."\n";
33
  echo '<div class="cas-rule-content" id="cas-'.$this->id.'">';
34
- $field = $this->id;
35
- $meta = get_post_meta($post->ID, ContentAwareSidebars::prefix.$field, false);
36
  $current = $meta != '' ? $meta : array();
37
- ?>
38
- <p>
39
- <label><input class="cas-chk-all" type="checkbox" name="<?php echo $field; ?>[]" value="<?php echo $field; ?>" <?php checked(in_array($field, $current), true, true); ?> /> <?php printf(__('Show with All %s','content-aware-sidebars'),$this->name); ?></label>
40
- </p>
41
- <div id="list-<?php echo $field; ?>" class="categorydiv" style="min-height:100%;">
42
- <ul id="<?php echo $field; ?>-tabs" class="category-tabs">
43
- <li class="tabs"><a href="#<?php echo $field; ?>-all" tabindex="3"><?php _e('View All'); ?></a></li>
44
- </ul>
45
- <div id="<?php echo $field; ?>-all" class="tabs-panel" style="min-height:100%;">
46
- <ul id="authorlistchecklist" class="list:<?php echo $field; ?> categorychecklist form-no-clear">
47
- <?php
48
- foreach($this->_get_content() as $id => $name) {
49
- echo '<li><label><input class="cas-' . $this->id . '" type="checkbox" name="'.$field.'[]" value="'.$id.'"'.checked(in_array($id,$current), true, false).' /> '.$name.'</label></li>'."\n";
50
- }
51
- ?>
52
- </ul>
53
- </div>
54
- </div>
55
- <?php
56
  echo '</div>';
57
  }
58
 
 
 
 
 
 
59
  public function db_join() {
60
  global $wpdb;
61
  return "LEFT JOIN $wpdb->postmeta {$this->id} ON {$this->id}.post_id = posts.ID AND {$this->id}.meta_key = '".ContentAwareSidebars::prefix.$this->id."' ";
62
  }
63
 
 
 
 
 
 
 
 
64
  public function exclude_sidebar($continue, $post, $prefix) {
65
  if(!$continue) {
66
  //print_r($this->id."<br />");
@@ -73,16 +99,38 @@ abstract class CASModule {
73
 
74
  }
75
 
 
 
 
 
76
  public function db_where2() {
77
  return "{$this->id}.meta_value IS NOT NULL";
78
  }
79
 
 
 
 
 
80
  public function get_id() {
81
  return $this->id;
82
  }
83
 
 
 
 
 
84
  abstract protected function _get_content();
 
 
 
 
 
85
  abstract public function is_content();
 
 
 
 
 
86
  abstract public function db_where();
87
 
88
  }
11
  */
12
  abstract class CASModule {
13
 
14
+ /**
15
+ * Module idenfification
16
+ * @var string
17
+ */
18
  protected $id;
19
+
20
+ /**
21
+ * Module name
22
+ * @var string
23
+ */
24
  protected $name;
25
+
26
+ /**
27
+ * Enable AJAX search in editor
28
+ * @var boolean
29
+ */
30
+ protected $searchable = false;
31
 
32
  /**
33
  *
38
  $this->id = substr(get_class($this),strpos(get_class($this),'_')+1);
39
  }
40
 
41
+ /**
42
+ * Default meta box content
43
+ * @global object $post
44
+ * @return void
45
+ */
46
  public function meta_box_content() {
47
  global $post;
48
 
51
 
52
  echo '<h4><a href="#">'.$this->name.'</a></h4>'."\n";
53
  echo '<div class="cas-rule-content" id="cas-'.$this->id.'">';
54
+ $meta = get_post_meta($post->ID, ContentAwareSidebars::prefix.$this->id, false);
 
55
  $current = $meta != '' ? $meta : array();
56
+
57
+ echo '<p><label><input class="cas-chk-all" type="checkbox" name="'.$this->id.'[]" value="'.$this->id.'"'.checked(in_array($this->id, $current), true, false).' /> '.sprintf(__('Show with All %s',ContentAwareSidebars::domain),$this->name).'</label></p>'."\n";
58
+
59
+ // Show search if enabled and there is too much content
60
+ if($this->searchable ) {
61
+ echo _x('Search','verb',ContentAwareSidebars::domain).' <input class="cas-autocomplete-' . $this->id . ' cas-autocomplete" id="cas-autocomplete-' . $this->id . '" type="text" name="cas-autocomplete" value="" /> <input type="button" id="cas-add-' . $this->id . '" class="button" value="'.__('Add',ContentAwareSidebars::domain).'"/>'."\n";
62
+ }
63
+
64
+ echo '<ul id="cas-list-' . $this->id . '" class="cas-contentlist categorychecklist form-no-clear">'."\n";
65
+ foreach($this->_get_content() as $id => $name) {
66
+ echo '<li id="'.$this->id.'-'.$id.'"><label><input class="cas-' . $this->id . '" type="checkbox" name="'.$this->id.'[]" value="'.$id.'"'.checked(in_array($id,$current), true, false).' /> '.$name.'</label></li>'."\n";
67
+ }
68
+ echo '</ul>'."\n";
69
+
 
 
 
 
 
70
  echo '</div>';
71
  }
72
 
73
+ /**
74
+ * Default query join
75
+ * @global object $wpdb
76
+ * @return string
77
+ */
78
  public function db_join() {
79
  global $wpdb;
80
  return "LEFT JOIN $wpdb->postmeta {$this->id} ON {$this->id}.post_id = posts.ID AND {$this->id}.meta_key = '".ContentAwareSidebars::prefix.$this->id."' ";
81
  }
82
 
83
+ /**
84
+ * Exclude sidebar. TODO: revise
85
+ * @param boolean $continue
86
+ * @param object $post
87
+ * @param string $prefix
88
+ * @return boolean
89
+ */
90
  public function exclude_sidebar($continue, $post, $prefix) {
91
  if(!$continue) {
92
  //print_r($this->id."<br />");
99
 
100
  }
101
 
102
+ /**
103
+ * Default where2 query
104
+ * @return string
105
+ */
106
  public function db_where2() {
107
  return "{$this->id}.meta_value IS NOT NULL";
108
  }
109
 
110
+ /**
111
+ * Idenficiation getter
112
+ * @return string
113
+ */
114
  public function get_id() {
115
  return $this->id;
116
  }
117
 
118
+ /**
119
+ * Get content for sidebar edit screen
120
+ * @return array
121
+ */
122
  abstract protected function _get_content();
123
+
124
+ /**
125
+ * Determine if current content is relevant
126
+ * @return boolean
127
+ */
128
  abstract public function is_content();
129
+
130
+ /**
131
+ * Where query
132
+ * @return string
133
+ */
134
  abstract public function db_where();
135
 
136
  }
modules/author.php CHANGED
@@ -15,16 +15,31 @@
15
  */
16
  class CASModule_author extends CASModule {
17
 
 
 
 
18
  public function __construct() {
19
  parent::__construct();
20
  $this->id = 'authors';
21
- $this->name = __('Authors','content-aware-sidebars');
 
 
 
22
  }
23
 
 
 
 
 
24
  public function is_content() {
25
  return (is_singular() && !is_front_page()) || is_author();
26
  }
27
 
 
 
 
 
 
28
  public function db_where() {
29
  global $post;
30
  $author = (string)(is_singular() ? $post->post_author : get_query_var('author'));
@@ -32,13 +47,57 @@ class CASModule_author extends CASModule {
32
 
33
  }
34
 
35
- public function _get_content() {
 
 
 
 
 
36
  global $wpdb;
37
  $author_list = array();
38
- foreach($wpdb->get_results("SELECT ID, display_name FROM $wpdb->users ORDER BY ID ASC LIMIT 0,200") as $user) {
39
  $author_list[$user->ID] = $user->display_name;
40
  }
41
  return $author_list;
42
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  }
15
  */
16
  class CASModule_author extends CASModule {
17
 
18
+ /**
19
+ * Constructor
20
+ */
21
  public function __construct() {
22
  parent::__construct();
23
  $this->id = 'authors';
24
+ $this->name = __('Authors',ContentAwareSidebars::domain);
25
+ $this->searchable = true;
26
+
27
+ add_action('wp_ajax_cas-autocomplete-'.$this->id, array(&$this,'ajax_content_search'));
28
  }
29
 
30
+ /**
31
+ * Determine if content is relevant
32
+ * @return boolean
33
+ */
34
  public function is_content() {
35
  return (is_singular() && !is_front_page()) || is_author();
36
  }
37
 
38
+ /**
39
+ * Query where
40
+ * @global object $post
41
+ * @return string
42
+ */
43
  public function db_where() {
44
  global $post;
45
  $author = (string)(is_singular() ? $post->post_author : get_query_var('author'));
47
 
48
  }
49
 
50
+ /**
51
+ * Get authors
52
+ * @global object $wpdb
53
+ * @return array
54
+ */
55
+ protected function _get_content() {
56
  global $wpdb;
57
  $author_list = array();
58
+ foreach($wpdb->get_results("SELECT ID, display_name FROM $wpdb->users ORDER BY ID ASC LIMIT 0,20") as $user) {
59
  $author_list[$user->ID] = $user->display_name;
60
  }
61
  return $author_list;
62
  }
63
+
64
+
65
+ /**
66
+ * Get authors with AJAX search
67
+ * @return void
68
+ */
69
+ public function ajax_content_search() {
70
+ global $wpdb;
71
+
72
+ // Verify request
73
+ check_ajax_referer(basename('content-aware-sidebars.php'),'nonce');
74
+
75
+ $suggestions = array();
76
+
77
+ $authors =$wpdb->get_results($wpdb->prepare("
78
+ SELECT ID, display_name
79
+ FROM $wpdb->users
80
+ WHERE display_name
81
+ LIKE '%s'
82
+ ORDER BY display_name ASC
83
+ LIMIT 0,10
84
+ ",
85
+ '%'.$_REQUEST['term'].'%'));
86
+
87
+ foreach($authors as $user) {
88
+ $suggestions[] = array(
89
+ 'label' => $user->display_name,
90
+ 'value' => $user->display_name,
91
+ 'id' => $user->ID,
92
+ 'module' => $this->id,
93
+ 'name' => $this->id,
94
+ 'id2' => $this->id,
95
+ 'elem' => $this->id.'-'.$user->ID
96
+ );
97
+ }
98
+
99
+ echo json_encode($suggestions);
100
+ die();
101
+ }
102
 
103
  }
modules/bbpress.php CHANGED
@@ -12,33 +12,42 @@
12
  * a) any or specific bbpress user profile
13
  *
14
  */
15
- class CASModule_bbpress extends CASModule {
16
 
 
 
 
17
  public function __construct() {
18
  parent::__construct();
19
  $this->id = 'bb_profile';
20
- $this->name = __('bbPress User Profiles','content-aware-sidebars');
21
 
22
  add_filter('cas-db-where-post_types', array(&$this,'add_forum_dependency'));
 
23
  }
24
 
 
 
 
 
25
  public function is_content() {
26
  return bbp_is_single_user();
27
  }
28
 
 
 
 
 
29
  public function db_where() {
30
  return "(bb_profile.meta_value = 'bb_profile' OR bb_profile.meta_value = '".bbp_get_displayed_user_id()."')";
31
  }
32
-
33
- public function _get_content() {
34
- global $wpdb;
35
- $author_list = array();
36
- foreach($wpdb->get_results("SELECT ID, display_name FROM $wpdb->users ORDER BY ID ASC LIMIT 0,200") as $user) {
37
- $author_list[$user->ID] = $user->display_name;
38
- }
39
- return $author_list;
40
- }
41
 
 
 
 
 
 
 
42
  public function add_forum_dependency($where) {
43
  if(is_singular(array('topic','reply'))) {
44
  $where = "(post_types.meta_value IS NULL OR post_types.meta_value IN('".get_post_type()."','".get_the_ID()."','".bbp_get_forum_id()."','forum'))";
12
  * a) any or specific bbpress user profile
13
  *
14
  */
15
+ class CASModule_bbpress extends CASModule_author {
16
 
17
+ /**
18
+ * Constructor
19
+ */
20
  public function __construct() {
21
  parent::__construct();
22
  $this->id = 'bb_profile';
23
+ $this->name = __('bbPress User Profiles',ContentAwareSidebars::domain);
24
 
25
  add_filter('cas-db-where-post_types', array(&$this,'add_forum_dependency'));
26
+ add_action('wp_ajax_cas-autocomplete-'.$this->id, array(&$this,'ajax_content_search'));
27
  }
28
 
29
+ /**
30
+ * Determine if content is relevant
31
+ * @return boolean
32
+ */
33
  public function is_content() {
34
  return bbp_is_single_user();
35
  }
36
 
37
+ /**
38
+ * Query where
39
+ * @return string
40
+ */
41
  public function db_where() {
42
  return "(bb_profile.meta_value = 'bb_profile' OR bb_profile.meta_value = '".bbp_get_displayed_user_id()."')";
43
  }
 
 
 
 
 
 
 
 
 
44
 
45
+ /**
46
+ * Sidebars to be displayed with forums will also
47
+ * be dislpayed with respective topics and replies
48
+ * @param string $where
49
+ * @return string
50
+ */
51
  public function add_forum_dependency($where) {
52
  if(is_singular(array('topic','reply'))) {
53
  $where = "(post_types.meta_value IS NULL OR post_types.meta_value IN('".get_post_type()."','".get_the_ID()."','".bbp_get_forum_id()."','forum'))";
modules/bp_member.php CHANGED
@@ -14,15 +14,23 @@
14
  */
15
  class CASModule_bp_member extends CASModule {
16
 
 
 
 
17
  public function __construct() {
18
  parent::__construct();
19
  $this->id = 'bp_member';
20
- $this->name = __('BuddyPress Members','content-aware-sidebars');
21
 
22
  add_filter('cas-is-content-static', array(&$this,'static_is_content'));
23
 
24
  }
25
 
 
 
 
 
 
26
  protected function _get_content() {
27
  global $bp;
28
 
@@ -38,46 +46,65 @@ class CASModule_bp_member extends CASModule {
38
  return $content;
39
  }
40
 
 
 
 
 
 
41
  public function is_content() {
42
  global $bp;
43
  return $bp->displayed_user->domain != null;
44
  }
45
 
 
 
 
 
 
46
  public function db_where() {
47
  global $bp;
48
  return "(bp_member.meta_value IS NULL OR bp_member.meta_value IN ('".$bp->current_component."','".$bp->current_component."-".$bp->current_action."'))";
49
 
50
  }
51
 
 
 
 
 
 
 
52
  public function meta_box_content() {
53
  global $post, $bp;
54
 
55
  echo '<h4><a href="#">'.$this->name.'</a></h4>'."\n";
56
- echo '<div class="cas-rule-content" id="cas-' . $this->id . '">';
57
  $field = $this->id;
58
  $meta = get_post_meta($post->ID, ContentAwareSidebars::prefix . $field, false);
59
  $current = $meta != '' ? $meta : array();
60
- ?>
61
- <div style="min-height:100%;">
62
- <ul class="list:<?php echo $field; ?> categorychecklist form-no-clear">
63
- <?php
64
  foreach ($this->_get_content() as $id => $name) {
65
  echo '<li><label class="selectit"><input type="checkbox" name="' . $field . '[]" value="' . $id . '"' . (in_array($id, $current) ? ' checked="checked"' : '') . ' /> ' . $name . '</label></li>' . "\n";
66
  if(isset($bp->bp_options_nav[$id])) {
67
  echo '<ul class="children">';
68
  foreach($bp->bp_options_nav[$id] as $child) {
69
- echo '<li style="padding-left:20px;"><label class="selectit"><input type="checkbox" name="' . $field . '[]" value="' . $id . '-'. $child['slug'].'"' . (in_array($id . '-'. $child['slug'], $current) ? ' checked="checked"' : '') . ' /> ' . $child['name'] . '</label></li>' . "\n";
70
  }
71
  echo '</ul>';
72
  }
73
 
74
  }
75
- ?>
76
- </ul></div>
77
- <?php
78
- echo '</div>';
79
  }
80
 
 
 
 
 
 
 
81
  public function static_is_content($content) {
82
  return $content && !$this->is_content();
83
  }
14
  */
15
  class CASModule_bp_member extends CASModule {
16
 
17
+ /**
18
+ * Constructor
19
+ */
20
  public function __construct() {
21
  parent::__construct();
22
  $this->id = 'bp_member';
23
+ $this->name = __('BuddyPress Members',ContentAwareSidebars::domain);
24
 
25
  add_filter('cas-is-content-static', array(&$this,'static_is_content'));
26
 
27
  }
28
 
29
+ /**
30
+ * Get member pages
31
+ * @global object $bp
32
+ * @return array
33
+ */
34
  protected function _get_content() {
35
  global $bp;
36
 
46
  return $content;
47
  }
48
 
49
+ /**
50
+ * Determine if content is relevant
51
+ * @global object $bp
52
+ * @return boolean
53
+ */
54
  public function is_content() {
55
  global $bp;
56
  return $bp->displayed_user->domain != null;
57
  }
58
 
59
+ /**
60
+ * Query where
61
+ * @global object $bp
62
+ * @return string
63
+ */
64
  public function db_where() {
65
  global $bp;
66
  return "(bp_member.meta_value IS NULL OR bp_member.meta_value IN ('".$bp->current_component."','".$bp->current_component."-".$bp->current_action."'))";
67
 
68
  }
69
 
70
+ /**
71
+ * Meta box content
72
+ * @global object $post
73
+ * @global object $bp
74
+ * @return void
75
+ */
76
  public function meta_box_content() {
77
  global $post, $bp;
78
 
79
  echo '<h4><a href="#">'.$this->name.'</a></h4>'."\n";
80
+ echo '<div class="cas-rule-content" id="cas-' . $this->id . '">'."\n";
81
  $field = $this->id;
82
  $meta = get_post_meta($post->ID, ContentAwareSidebars::prefix . $field, false);
83
  $current = $meta != '' ? $meta : array();
84
+
85
+ echo '<ul class="cas-contentlist categorychecklist form-no-clear">'."\n";
 
 
86
  foreach ($this->_get_content() as $id => $name) {
87
  echo '<li><label class="selectit"><input type="checkbox" name="' . $field . '[]" value="' . $id . '"' . (in_array($id, $current) ? ' checked="checked"' : '') . ' /> ' . $name . '</label></li>' . "\n";
88
  if(isset($bp->bp_options_nav[$id])) {
89
  echo '<ul class="children">';
90
  foreach($bp->bp_options_nav[$id] as $child) {
91
+ echo '<li><label class="selectit"><input type="checkbox" name="' . $field . '[]" value="' . $id . '-'. $child['slug'].'"' . (in_array($id . '-'. $child['slug'], $current) ? ' checked="checked"' : '') . ' /> ' . $child['name'] . '</label></li>' . "\n";
92
  }
93
  echo '</ul>';
94
  }
95
 
96
  }
97
+
98
+ echo '</ul>'."\n";
99
+ echo '</div>'."\n";
 
100
  }
101
 
102
+ /**
103
+ * Avoid collision with content of static module
104
+ * Somehow buddypress pages pass is_404()
105
+ * @param boolean $content
106
+ * @return boolean
107
+ */
108
  public function static_is_content($content) {
109
  return $content && !$this->is_content();
110
  }
modules/index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ /**/
modules/page_template.php CHANGED
@@ -15,28 +15,41 @@
15
  */
16
  class CASModule_page_template extends CASModule {
17
 
 
 
 
18
  public function __construct() {
19
  parent::__construct();
20
  $this->id = 'page_templates';
21
- $this->name = __('Page Templates','content-aware-sidebars');
22
  }
23
 
 
 
 
 
24
  public function is_content() {
25
  if(is_singular() && !('page' == get_option( 'show_on_front') && get_option('page_on_front') == get_the_ID())) {
26
  $template = get_post_meta(get_the_ID(),'_wp_page_template',true);
27
- if($template && $template != 'default') {
28
- return true;
29
- }
30
  }
31
  return false;
32
  }
33
 
 
 
 
 
34
  public function db_where() {
35
  $template = get_post_meta(get_the_ID(),'_wp_page_template',true);
36
  return "(page_templates.meta_value IS NULL OR page_templates.meta_value IN('page_templates','".$template."'))";
37
  }
38
 
39
- public function _get_content() {
 
 
 
 
40
  return array_flip(get_page_templates());
41
  }
42
 
15
  */
16
  class CASModule_page_template extends CASModule {
17
 
18
+ /**
19
+ * Constructor
20
+ */
21
  public function __construct() {
22
  parent::__construct();
23
  $this->id = 'page_templates';
24
+ $this->name = __('Page Templates',ContentAwareSidebars::domain);
25
  }
26
 
27
+ /**
28
+ * Determine if content is relevant
29
+ * @return boolean
30
+ */
31
  public function is_content() {
32
  if(is_singular() && !('page' == get_option( 'show_on_front') && get_option('page_on_front') == get_the_ID())) {
33
  $template = get_post_meta(get_the_ID(),'_wp_page_template',true);
34
+ return ($template && $template != 'default');
 
 
35
  }
36
  return false;
37
  }
38
 
39
+ /**
40
+ * Query where
41
+ * @return string
42
+ */
43
  public function db_where() {
44
  $template = get_post_meta(get_the_ID(),'_wp_page_template',true);
45
  return "(page_templates.meta_value IS NULL OR page_templates.meta_value IN('page_templates','".$template."'))";
46
  }
47
 
48
+ /**
49
+ * Get page templates
50
+ * @return array
51
+ */
52
+ protected function _get_content() {
53
  return array_flip(get_page_templates());
54
  }
55
 
modules/polylang.php CHANGED
@@ -14,25 +14,40 @@
14
  */
15
  class CASModule_polylang extends CASModule {
16
 
 
 
 
17
  public function __construct() {
18
  parent::__construct();
19
  $this->id = 'language';
20
- $this->name = __('Languages','content-aware-sidebars');
21
-
22
 
23
  add_filter('pll_get_post_types', array(&$this,'remove_sidebar_multilingual'));
24
 
25
  }
26
 
 
 
 
 
27
  public function is_content() {
28
  return true;
29
  }
30
 
 
 
 
 
31
  public function db_where() {
32
  return "(language.meta_value IS NULL OR language.meta_value IN('language','".pll_current_language()."'))";
33
  }
34
 
35
- public function _get_content() {
 
 
 
 
 
36
  global $polylang;
37
  $langs = array();
38
 
@@ -42,9 +57,13 @@ class CASModule_polylang extends CASModule {
42
  return $langs;
43
  }
44
 
 
 
 
 
 
45
  public function remove_sidebar_multilingual($post_types) {
46
- if(isset($post_types['sidebar']))
47
- unset($post_types['sidebar']);
48
  return $post_types;
49
  }
50
 
14
  */
15
  class CASModule_polylang extends CASModule {
16
 
17
+ /**
18
+ * Constructor
19
+ */
20
  public function __construct() {
21
  parent::__construct();
22
  $this->id = 'language';
23
+ $this->name = __('Languages',ContentAwareSidebars::domain);
 
24
 
25
  add_filter('pll_get_post_types', array(&$this,'remove_sidebar_multilingual'));
26
 
27
  }
28
 
29
+ /**
30
+ * Determine if content is relevant
31
+ * @return boolean
32
+ */
33
  public function is_content() {
34
  return true;
35
  }
36
 
37
+ /**
38
+ * Query where
39
+ * @return string
40
+ */
41
  public function db_where() {
42
  return "(language.meta_value IS NULL OR language.meta_value IN('language','".pll_current_language()."'))";
43
  }
44
 
45
+ /**
46
+ * Get languages
47
+ * @global object $polylang
48
+ * @return array
49
+ */
50
+ protected function _get_content() {
51
  global $polylang;
52
  $langs = array();
53
 
57
  return $langs;
58
  }
59
 
60
+ /**
61
+ * Remove sidebars from multilingual list
62
+ * @param array $post_types
63
+ * @return array
64
+ */
65
  public function remove_sidebar_multilingual($post_types) {
66
+ unset($post_types[ContentAwareSidebars::type_sidebar]);
 
67
  return $post_types;
68
  }
69
 
modules/post_type.php CHANGED
@@ -15,43 +15,78 @@
15
  */
16
  class CASModule_post_type extends CASModule {
17
 
 
 
 
 
18
  private $post_type_objects;
19
 
 
 
 
20
  public function __construct() {
21
  parent::__construct();
22
  $this->id = 'post_types';
23
- $this->name = __('Post Types','content-aware-sidebars');
24
 
25
  add_action('transition_post_status', array(&$this,'post_ancestry_check'),10,3);
26
-
 
 
27
  }
28
 
 
 
 
 
29
  protected function _get_content() {
30
-
 
 
 
 
 
 
31
  }
32
 
 
 
 
 
33
  public function is_content() {
34
  return ((is_singular() || is_home()) && !is_front_page()) || is_post_type_archive();
35
  }
36
 
 
 
 
 
 
37
  public function db_where() {
38
  if(is_singular()) {
39
- return "(post_types.meta_value IS NULL OR post_types.meta_value IN('".get_post_type()."','".get_the_ID()."'))";
40
  }
41
  global $post_type;
42
 
43
  // Home has post as default post type
44
  if(!$post_type) $post_type = 'post';
45
- return "(post_types.meta_value IS NULL OR post_types.meta_value = '".$post_type."')";
46
  }
47
 
 
 
 
 
 
 
48
  public function meta_box_content() {
49
- global $post;
 
 
50
 
51
- foreach ($this->_get_post_types() as $post_type) {
52
  echo '<h4><a href="#">' . $post_type->label . '</a></h4>'."\n";
53
  echo '<div class="cas-rule-content" id="cas-' . $this->id . '-' . $post_type->name . '">'."\n";
54
- $meta = get_post_meta($post->ID, ContentAwareSidebars::prefix . 'post_types', false);
55
  $current = $meta != '' ? $meta : array();
56
 
57
  $exclude = array();
@@ -60,65 +95,140 @@ class CASModule_post_type extends CASModule {
60
  $exclude[] = get_option('page_for_posts');
61
  }
62
 
63
- //WP3.1 does not support (array) as post_status
64
- $posts = get_posts(array(
65
- 'numberposts' => 200,
66
- 'post_type' => $post_type->name,
67
- 'post_status' => 'publish,private,future',
68
- 'exclude' => $exclude
69
- ));
70
-
71
  if($post_type->hierarchical) {
72
  echo '<p>' . "\n";
73
- echo '<label><input type="checkbox" name="post_types[]" value="_cas_sub_' . $post_type->name . '"' . checked(in_array("_cas_sub_" . $post_type->name, $current), true, false) . ' /> ' . __('Automatically select new children of a selected ancestor', 'content-aware-sidebars') . '</label>' . "\n";
74
  echo '</p>' . "\n";
75
  }
 
76
  //WP3.1.4 does not support $post_type->labels->all_items
77
  echo '<p>' . "\n";
78
- echo '<label><input class="cas-chk-all" type="checkbox" name="post_types[]" value="' . $post_type->name . '"' . checked(in_array($post_type->name, $current), true, false) . ' /> ' . sprintf(__('Show with All %s', 'content-aware-sidebars'), $post_type->label) . '</label>' . "\n";
79
  echo '</p>' . "\n";
80
 
81
- if (!$posts || is_wp_error($posts)) {
82
  echo '<p>' . __('No items.') . '</p>';
83
  } else {
84
 
85
- ?>
86
- <div id="posttype-<?php echo $post_type->name; ?>" class="categorydiv" style="min-height:100%;">
87
- <ul id="posttype-<?php echo $post_type->name; ?>-tabs" class="category-tabs">
88
- <li class="tabs"><a href="#<?php echo $post_type->name; ?>-all" tabindex="3"><?php _e('View All'); ?></a></li>
89
- </ul>
90
- <div id="<?php echo $post_type->name; ?>-all" class="tabs-panel" style="min-height:100%;">
91
- <ul id="<?php echo $post_type->name; ?>checklist" class="list:<?php echo $post_type->name ?> categorychecklist form-no-clear">
92
- <?php cas_posts_checklist($post->ID, array('post_type' => $post_type, 'posts' => $posts)); ?>
93
- </ul>
94
- </div>
95
- </div>
96
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
97
  }
98
 
99
  echo '</div>';
 
100
  }
101
  }
102
 
103
- private function _get_post_types() {
104
- if (empty($this->post_type_objects)) {
105
- // List public post types
106
- foreach (get_post_types(array('public' => true), 'objects') as $post_type) {
107
- $this->post_type_objects[$post_type->name] = $post_type;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  }
109
  }
110
- return $this->post_type_objects;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  }
 
112
 
113
  /**
114
- *
115
- * @param string $new_status
116
- * @param string $old_status
117
- * @param object $post
 
118
  */
119
  public function post_ancestry_check($new_status, $old_status, $post) {
120
 
121
- if($post->post_type != 'sidebar') {
122
 
123
  $status = array('publish','private','future');
124
  // Only new posts are relevant
@@ -129,12 +239,12 @@ class CASModule_post_type extends CASModule {
129
 
130
  // Get sidebars with post ancestor wanting to auto-select post
131
  $sidebars = new WP_Query(array(
132
- 'post_type' => 'sidebar',
133
  'meta_query' => array(
134
  'relation' => 'AND',
135
  array(
136
  'key' => ContentAwareSidebars::prefix . $this->id,
137
- 'value' => '_cas_sub_' . $post->post_type,
138
  'compare' => '='
139
  ),
140
  array(
@@ -150,12 +260,9 @@ class CASModule_post_type extends CASModule {
150
  add_post_meta($sidebar->ID, ContentAwareSidebars::prefix.$this->id, $post->ID);
151
  }
152
  }
153
-
154
- }
155
- }
156
-
157
- }
158
-
159
  }
160
 
161
  }
15
  */
16
  class CASModule_post_type extends CASModule {
17
 
18
+ /**
19
+ * Registered public post types
20
+ * @var array
21
+ */
22
  private $post_type_objects;
23
 
24
+ /**
25
+ * Constructor
26
+ */
27
  public function __construct() {
28
  parent::__construct();
29
  $this->id = 'post_types';
30
+ $this->name = __('Post Types',ContentAwareSidebars::domain);
31
 
32
  add_action('transition_post_status', array(&$this,'post_ancestry_check'),10,3);
33
+
34
+ add_action('wp_ajax_cas-autocomplete-'.$this->id, array(&$this,'ajax_content_search'));
35
+
36
  }
37
 
38
+ /**
39
+ * Get registered post types
40
+ * @return array
41
+ */
42
  protected function _get_content() {
43
+ if (empty($this->post_type_objects)) {
44
+ // List public post types
45
+ foreach (get_post_types(array('public' => true), 'objects') as $post_type) {
46
+ $this->post_type_objects[$post_type->name] = $post_type;
47
+ }
48
+ }
49
+ return $this->post_type_objects;
50
  }
51
 
52
+ /**
53
+ * Determine if content is relevant
54
+ * @return boolean
55
+ */
56
  public function is_content() {
57
  return ((is_singular() || is_home()) && !is_front_page()) || is_post_type_archive();
58
  }
59
 
60
+ /**
61
+ * Query where
62
+ * @global string $post_type
63
+ * @return string
64
+ */
65
  public function db_where() {
66
  if(is_singular()) {
67
+ return "(".$this->id.".meta_value IS NULL OR ".$this->id.".meta_value IN('".get_post_type()."','".get_the_ID()."'))";
68
  }
69
  global $post_type;
70
 
71
  // Home has post as default post type
72
  if(!$post_type) $post_type = 'post';
73
+ return "(".$this->id.".meta_value IS NULL OR ".$this->id.".meta_value = '".$post_type."')";
74
  }
75
 
76
+ /**
77
+ * Meta box content
78
+ * @global object $post
79
+ * @global object $wpdb
80
+ * @return void
81
+ */
82
  public function meta_box_content() {
83
+ global $post, $wpdb;
84
+
85
+ foreach ($this->_get_content() as $post_type) {
86
 
 
87
  echo '<h4><a href="#">' . $post_type->label . '</a></h4>'."\n";
88
  echo '<div class="cas-rule-content" id="cas-' . $this->id . '-' . $post_type->name . '">'."\n";
89
+ $meta = get_post_meta($post->ID, ContentAwareSidebars::prefix . $this->id, false);
90
  $current = $meta != '' ? $meta : array();
91
 
92
  $exclude = array();
95
  $exclude[] = get_option('page_for_posts');
96
  }
97
 
98
+ $number_of_posts = (int)$wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type = '{$post_type->name}' AND post_status IN('publish','private','future')");
99
+
100
+ echo '<div style="min-height:100%;">'."\n";
101
+
 
 
 
 
102
  if($post_type->hierarchical) {
103
  echo '<p>' . "\n";
104
+ echo '<label><input type="checkbox" name="'.$this->id.'[]" value="'.ContentAwareSidebars::prefix.'sub_' . $post_type->name . '"' . checked(in_array(ContentAwareSidebars::prefix."sub_" . $post_type->name, $current), true, false) . ' /> ' . __('Automatically select new children of a selected ancestor', ContentAwareSidebars::domain) . '</label>' . "\n";
105
  echo '</p>' . "\n";
106
  }
107
+
108
  //WP3.1.4 does not support $post_type->labels->all_items
109
  echo '<p>' . "\n";
110
+ echo '<label><input class="cas-chk-all" type="checkbox" name="'.$this->id.'[]" value="' . $post_type->name . '"' . checked(in_array($post_type->name, $current), true, false) . ' /> ' . sprintf(__('Show with All %s', ContentAwareSidebars::domain), $post_type->label) . '</label>' . "\n";
111
  echo '</p>' . "\n";
112
 
113
+ if (!$number_of_posts) {
114
  echo '<p>' . __('No items.') . '</p>';
115
  } else {
116
 
117
+ //WP3.1 does not support (array) as post_status
118
+ $posts = get_posts(array(
119
+ 'posts_per_page' => 20,
120
+ 'post_type' => $post_type->name,
121
+ 'post_status' => 'publish,private,future',
122
+ 'exclude' => array_merge($exclude,$current),
123
+ ));
124
+ if(!empty($current)) {
125
+ $selected = get_posts(array(
126
+ 'include' => $current,
127
+ 'post_type' => $post_type->name
128
+ ));
129
+ } else {
130
+ $selected = array();
131
+ }
132
+
133
+ if($number_of_posts > 20) {
134
+ echo _x('Search','verb',ContentAwareSidebars::domain).' <input class="cas-autocomplete-' . $this->id . ' cas-autocomplete" id="cas-autocomplete-' . $this->id . '-' . $post_type->name . '" type="text" name="cas-autocomplete" value="" /> <input type="button" id="cas-add-' . $this->id . '-' . $post_type->name . '" class="button" value="'.__('Add',ContentAwareSidebars::domain).'"/>'."\n";
135
+ }
136
+
137
+ echo '<ul id="cas-list-' . $this->id . '-' . $post_type->name . '" class="cas-contentlist categorychecklist form-no-clear">'."\n";
138
+ $this->post_checklist($post->ID, $post_type, array_merge($selected,$posts), $current);
139
+ echo '</ul>'."\n";
140
+
141
  }
142
 
143
  echo '</div>';
144
+ echo '</div>';
145
  }
146
  }
147
 
148
+ /**
149
+ * Show posts from a specific post type
150
+ * @param int $post_id
151
+ * @param object $post_type
152
+ * @param array $posts
153
+ * @param array $selected_ids
154
+ * @return void
155
+ */
156
+ private function post_checklist($post_id = 0, $post_type, $posts, $selected_ids) {
157
+
158
+ $walker = new CAS_Walker_Checklist('post',array ('parent' => 'post_parent', 'id' => 'ID'));
159
+
160
+ $args = array(
161
+ 'post_type' => $post_type,
162
+ 'selected_cats' => $post_id ? $selected_ids : array()
163
+ );
164
+
165
+ $checked_posts = array();
166
+
167
+ foreach( $posts as $key => $value ) {
168
+ if (in_array($posts[$key]->ID, $args['selected_cats'])) {
169
+ $checked_posts[] = $posts[$key];
170
+ unset($posts[$key]);
171
  }
172
  }
173
+
174
+ //Put checked posts on top
175
+ echo call_user_func_array(array(&$walker, 'walk'), array($checked_posts, 0, $args));
176
+ // Then the rest of them
177
+ echo call_user_func_array(array(&$walker, 'walk'), array($posts, 0, $args));
178
+ }
179
+
180
+ /**
181
+ * Get posts with AJAX search
182
+ * @return void
183
+ */
184
+ public function ajax_content_search() {
185
+
186
+ // Verify request
187
+ check_ajax_referer(basename('content-aware-sidebars.php'),'nonce');
188
+
189
+ $suggestions = array();
190
+ if ( preg_match('/cas-autocomplete-'.$this->id.'-([a-zA-Z_-]*\b)/', $_REQUEST['type'], $matches) ) {
191
+ if(get_post_type_object( $matches[1] )) {
192
+ $exclude = array();
193
+ if ($matches[1] == 'page' && 'page' == get_option('show_on_front')) {
194
+ $exclude[] = get_option('page_on_front');
195
+ $exclude[] = get_option('page_for_posts');
196
+ }
197
+ $posts = get_posts(array(
198
+ 'posts_per_page' => 10,
199
+ 'post_type' => $matches[1],
200
+ 's' => $_REQUEST['term'],
201
+ 'exclude' => $exclude
202
+ ));
203
+ foreach($posts as $post) {
204
+ $suggestions[] = array(
205
+ 'label' => $post->post_title,
206
+ 'value' => $post->post_title,
207
+ 'id' => $post->ID,
208
+ 'module' => $this->id,
209
+ 'name' => $this->id,
210
+ 'id2' => $this->id.'-'.$post->post_type,
211
+ 'elem' => $post->post_type.'-'.$post->ID
212
+ );
213
+ }
214
+ }
215
+ }
216
+
217
+ echo json_encode($suggestions);
218
+ die();
219
  }
220
+
221
 
222
  /**
223
+ * Automatically select child of selected parent
224
+ * @param string $new_status
225
+ * @param string $old_status
226
+ * @param object $post
227
+ * @return void
228
  */
229
  public function post_ancestry_check($new_status, $old_status, $post) {
230
 
231
+ if($post->post_type != ContentAwareSidebars::type_sidebar) {
232
 
233
  $status = array('publish','private','future');
234
  // Only new posts are relevant
239
 
240
  // Get sidebars with post ancestor wanting to auto-select post
241
  $sidebars = new WP_Query(array(
242
+ 'post_type' => ContentAwareSidebars::type_sidebar,
243
  'meta_query' => array(
244
  'relation' => 'AND',
245
  array(
246
  'key' => ContentAwareSidebars::prefix . $this->id,
247
+ 'value' => ContentAwareSidebars::prefix.'sub_' . $post->post_type,
248
  'compare' => '='
249
  ),
250
  array(
260
  add_post_meta($sidebar->ID, ContentAwareSidebars::prefix.$this->id, $post->ID);
261
  }
262
  }
263
+ }
264
+ }
265
+ }
 
 
 
266
  }
267
 
268
  }
modules/qtranslate.php CHANGED
@@ -6,37 +6,46 @@
6
 
7
  /**
8
  *
9
- * bbPress Module
10
  *
11
  * Detects if current content is:
12
- * a) any or specific bbpress user profile
13
  *
14
  */
15
  class CASModule_qtranslate extends CASModule {
16
 
 
 
 
17
  public function __construct() {
18
  parent::__construct();
19
  $this->id = 'language';
20
- $this->name = __('Languages','content-aware-sidebars');
21
-
22
- add_filter('manage_edit-sidebar_columns', array(&$this,'admin_column_headers'));
23
 
24
  }
25
 
 
 
 
 
26
  public function is_content() {
27
  return true;
28
  }
29
 
 
 
 
 
30
  public function db_where() {
31
  return "(language.meta_value IS NULL OR language.meta_value IN('language','".qtrans_getLanguage()."'))";
32
  }
33
 
34
- public function admin_column_headers($columns) {
35
- unset($columns['language']);
36
- return $columns;
37
- }
38
-
39
- public function _get_content() {
40
  global $q_config;
41
  $langs = array();
42
 
6
 
7
  /**
8
  *
9
+ * qTranslate Module
10
  *
11
  * Detects if current content is:
12
+ * a) in specific language
13
  *
14
  */
15
  class CASModule_qtranslate extends CASModule {
16
 
17
+ /**
18
+ * Constructor
19
+ */
20
  public function __construct() {
21
  parent::__construct();
22
  $this->id = 'language';
23
+ $this->name = __('Languages',ContentAwareSidebars::domain);
 
 
24
 
25
  }
26
 
27
+ /**
28
+ * Determine if content is relevant
29
+ * @return boolean
30
+ */
31
  public function is_content() {
32
  return true;
33
  }
34
 
35
+ /**
36
+ * Where query
37
+ * @return string
38
+ */
39
  public function db_where() {
40
  return "(language.meta_value IS NULL OR language.meta_value IN('language','".qtrans_getLanguage()."'))";
41
  }
42
 
43
+ /**
44
+ * Get languages
45
+ * @global array $q_config
46
+ * @return array
47
+ */
48
+ protected function _get_content() {
49
  global $q_config;
50
  $langs = array();
51
 
modules/static.php CHANGED
@@ -16,24 +16,39 @@
16
  */
17
  class CASModule_static extends CASModule {
18
 
 
 
 
19
  public function __construct() {
20
  parent::__construct();
21
  $this->id = 'static';
22
- $this->name = __('Static Pages','content-aware-sidebars');
23
  }
24
 
25
- public function _get_content() {
 
 
 
 
26
  return array(
27
- 'front-page' => __('Front Page', 'content-aware-sidebars'),
28
- 'search' => __('Search Results', 'content-aware-sidebars'),
29
- '404' => __('404 Page', 'content-aware-sidebars')
30
  );
31
  }
32
 
 
 
 
 
33
  public function is_content() {
34
  return is_front_page() || is_search() || is_404();
35
  }
36
 
 
 
 
 
37
  public function db_where() {
38
  if(is_front_page()) {
39
  $val = 'front-page';
@@ -46,24 +61,25 @@ class CASModule_static extends CASModule {
46
 
47
  }
48
 
 
 
 
 
 
49
  public function meta_box_content() {
50
  global $post;
51
 
52
  echo '<h4><a href="#">'.$this->name.'</a></h4>'."\n";
53
- echo '<div class="cas-rule-content" id="cas-' . $this->id . '">';
54
- $field = $this->id;
55
- $meta = get_post_meta($post->ID, ContentAwareSidebars::prefix . $field, false);
56
  $current = $meta != '' ? $meta : array();
57
- ?>
58
- <ul class="list:<?php echo $field; ?> categorychecklist form-no-clear">
59
- <?php
60
  foreach ($this->_get_content() as $id => $name) {
61
- echo '<li><label><input type="checkbox" name="' . $field . '[]" value="' . $id . '"' . (in_array($id, $current) ? ' checked="checked"' : '') . ' /> ' . $name . '</label></li>' . "\n";
62
  }
63
- ?>
64
- </ul>
65
- <?php
66
- echo '</div>';
67
  }
68
 
69
  }
16
  */
17
  class CASModule_static extends CASModule {
18
 
19
+ /**
20
+ * Constructor
21
+ */
22
  public function __construct() {
23
  parent::__construct();
24
  $this->id = 'static';
25
+ $this->name = __('Static Pages',ContentAwareSidebars::domain);
26
  }
27
 
28
+ /**
29
+ * Get static content
30
+ * @return array
31
+ */
32
+ protected function _get_content() {
33
  return array(
34
+ 'front-page' => __('Front Page', ContentAwareSidebars::domain),
35
+ 'search' => __('Search Results', ContentAwareSidebars::domain),
36
+ '404' => __('404 Page', ContentAwareSidebars::domain)
37
  );
38
  }
39
 
40
+ /**
41
+ * Determine if content is relevant
42
+ * @return boolean
43
+ */
44
  public function is_content() {
45
  return is_front_page() || is_search() || is_404();
46
  }
47
 
48
+ /**
49
+ * Where query
50
+ * @return string
51
+ */
52
  public function db_where() {
53
  if(is_front_page()) {
54
  $val = 'front-page';
61
 
62
  }
63
 
64
+ /**
65
+ * Meta box content
66
+ * @global object $post
67
+ * @return void
68
+ */
69
  public function meta_box_content() {
70
  global $post;
71
 
72
  echo '<h4><a href="#">'.$this->name.'</a></h4>'."\n";
73
+ echo '<div class="cas-rule-content" id="cas-' . $this->id . '">'. "\n";
74
+ $meta = get_post_meta($post->ID, ContentAwareSidebars::prefix . $this->id, false);
 
75
  $current = $meta != '' ? $meta : array();
76
+
77
+ echo '<ul id="cas-list-' . $this->id . '" class="cas-contentlist categorychecklist form-no-clear">'. "\n";
 
78
  foreach ($this->_get_content() as $id => $name) {
79
+ echo '<li><label><input type="checkbox" name="' . $this->id . '[]" value="' . $id . '"' . (in_array($id, $current) ? ' checked="checked"' : '') . ' /> ' . $name . '</label></li>' . "\n";
80
  }
81
+ echo '</ul>'. "\n";
82
+ echo '</div>'. "\n";
 
 
83
  }
84
 
85
  }
modules/taxonomy.php CHANGED
@@ -15,35 +15,56 @@
15
  */
16
  class CASModule_taxonomy extends CASModule {
17
 
 
 
 
 
18
  private $taxonomy_objects;
 
 
 
 
 
19
  private $post_terms;
20
 
 
 
 
21
  public function __construct() {
22
  parent::__construct();
23
  $this->id = 'taxonomies';
24
- $this->name = __('Taxonomies','content-aware-sidebars');
25
-
 
 
26
  add_action('created_term', array(&$this,'term_ancestry_check'),10,3);
 
 
27
 
28
  }
29
 
 
 
 
 
30
  public function is_content() {
31
  if(is_singular()) {
32
  // Check if content has any taxonomies supported
33
  $taxonomies = get_object_taxonomies(get_post_type());
34
  if($taxonomies) {
35
- $this->post_terms = wp_get_object_terms(get_the_ID(),$taxonomies);
36
  // Check if content has any actual taxonomy terms
37
- if($this->post_terms) {
38
- return true;
39
- }
40
  }
41
- } else if(is_tax() || is_category() || is_tag()) {
42
- return true;
43
  }
44
- return false;
45
  }
46
 
 
 
 
 
47
  public function db_join() {
48
  global $wpdb;
49
 
@@ -56,6 +77,10 @@ class CASModule_taxonomy extends CASModule {
56
 
57
  }
58
 
 
 
 
 
59
  public function db_where() {
60
 
61
  if(is_singular()) {
@@ -82,81 +107,187 @@ class CASModule_taxonomy extends CASModule {
82
 
83
  }
84
 
 
 
 
 
85
  public function db_where2() {
86
  return "terms.slug IS NOT NULL OR taxonomies.meta_value IS NOT NULL";
87
  }
88
 
89
- public function _get_content() {
90
-
 
 
 
 
 
 
 
 
 
 
91
  }
92
 
 
 
 
 
 
93
  public function meta_box_content() {
94
  global $post;
95
 
96
- foreach ($this->_get_taxonomies() as $taxonomy) {
97
  echo '<h4><a href="#">' . $taxonomy->label . '</a></h4>'."\n";
98
  echo '<div class="cas-rule-content" id="cas-' . $this->id . '-' . $taxonomy->name . '">';
99
 
100
  $meta = get_post_meta($post->ID, ContentAwareSidebars::prefix . 'taxonomies', false);
101
  $current = $meta != '' ? $meta : array();
102
 
103
- $terms = get_terms($taxonomy->name, array('get' => 'all','number' => 200));
104
 
105
  if($taxonomy->hierarchical) {
106
  echo '<p>' . "\n";
107
- echo '<label><input type="checkbox" name="taxonomies[]" value="_cas_sub_' . $taxonomy->name . '"' . checked(in_array("_cas_sub_" . $taxonomy->name, $current), true, false) . ' /> ' . __('Automatically select new children of a selected ancestor', 'content-aware-sidebars') . '</label>' . "\n";
108
  echo '</p>' . "\n";
109
  }
110
  echo '<p>' . "\n";
111
- echo '<label><input class="cas-chk-all" type="checkbox" name="taxonomies[]" value="' . $taxonomy->name . '"' . checked(in_array($taxonomy->name, $current), true, false) . ' /> ' . sprintf(__('Show with %s', 'content-aware-sidebars'), $taxonomy->labels->all_items) . '</label>' . "\n";
112
  echo '</p>' . "\n";
113
 
114
- if (!$terms || is_wp_error($terms)) {
115
  echo '<p>' . __('No items.') . '</p>';
116
  } else {
117
- ?>
118
- <div id="taxonomy-<?php echo $taxonomy->name; ?>" class="categorydiv" style="min-height:100%;">
119
- <ul id="<?php echo $taxonomy->name; ?>-tabs" class="category-tabs">
120
- <li class="hide-if-no-js"><a href="#<?php echo $taxonomy->name; ?>-pop" tabindex="3"><?php _e('Most Used'); ?></a></li>
121
- <li class="tabs"><a href="#<?php echo $taxonomy->name; ?>-all" tabindex="3"><?php _e('View All'); ?></a></li>
122
- </ul>
123
-
124
- <div id="<?php echo $taxonomy->name; ?>-pop" class="tabs-panel" style="display: none;min-height:100%;">
125
- <ul id="<?php echo $taxonomy->name; ?>checklist-pop" class="categorychecklist form-no-clear" >
126
- <?php $popular_ids = cas_popular_terms_checklist($taxonomy); ?>
127
- </ul>
128
- </div>
129
-
130
- <div id="<?php echo $taxonomy->name; ?>-all" class="tabs-panel" style="min-height:100%;">
131
- <input type="hidden" name="<?php echo ($taxonomy->name == "category" ? "post_category[]" : "tax_input[$taxonomy->name]"); ?>" value="0" />
132
- <ul id="<?php echo $taxonomy->name; ?>checklist" class="list:<?php echo $taxonomy->name ?> categorychecklist form-no-clear">
133
- <?php cas_terms_checklist($post->ID, array('taxonomy' => $taxonomy, 'popular_terms' => $popular_ids, 'terms' => $terms)) ?>
134
- </ul>
135
- </div>
136
- </div>
137
- <?php
 
138
  }
139
  echo '</div>'."\n";
140
  }
141
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
 
143
- private function _get_taxonomies() {
144
- // List public taxonomies
145
- if (empty($this->taxonomy_objects)) {
146
- foreach (get_taxonomies(array('public' => true), 'objects') as $tax) {
147
- $this->taxonomy_objects[$tax->name] = $tax;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  }
149
  }
150
- return $this->taxonomy_objects;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  }
152
 
153
  /**
154
- *
155
  * Auto-select children of selected ancestor
156
- *
157
- * @param int $term_id
158
- * @param int $tt_id
159
- * @param string $taxonomy
160
  */
161
  public function term_ancestry_check($term_id, $tt_id, $taxonomy) {
162
 
@@ -166,11 +297,11 @@ class CASModule_taxonomy extends CASModule {
166
  if($term->parent != '0') {
167
  // Get sidebars with term ancestor wanting to auto-select term
168
  $posts = new WP_Query(array(
169
- 'post_type' => 'sidebar',
170
  'meta_query' => array(
171
  array(
172
  'key' => ContentAwareSidebars::prefix . $this->id,
173
- 'value' => '_cas_sub_' . $taxonomy,
174
  'compare' => '='
175
  )
176
  ),
15
  */
16
  class CASModule_taxonomy extends CASModule {
17
 
18
+ /**
19
+ * Registered public taxonomies
20
+ * @var array
21
+ */
22
  private $taxonomy_objects;
23
+
24
+ /**
25
+ * Terms of a given singular
26
+ * @var array
27
+ */
28
  private $post_terms;
29
 
30
+ /**
31
+ * Constructor
32
+ */
33
  public function __construct() {
34
  parent::__construct();
35
  $this->id = 'taxonomies';
36
+ $this->name = __('Taxonomies',ContentAwareSidebars::domain);
37
+
38
+ add_action('init', array(&$this,'add_taxonomies_to_sidebar'),100);
39
+ add_action('admin_menu',array(&$this,'clear_admin_menu'));
40
  add_action('created_term', array(&$this,'term_ancestry_check'),10,3);
41
+
42
+ add_action('wp_ajax_cas-autocomplete-'.$this->id, array(&$this,'ajax_content_search'));
43
 
44
  }
45
 
46
+ /**
47
+ * Determine if content is relevant
48
+ * @return boolean
49
+ */
50
  public function is_content() {
51
  if(is_singular()) {
52
  // Check if content has any taxonomies supported
53
  $taxonomies = get_object_taxonomies(get_post_type());
54
  if($taxonomies) {
 
55
  // Check if content has any actual taxonomy terms
56
+ $this->post_terms = wp_get_object_terms(get_the_ID(),$taxonomies);
57
+ return !empty($this->post_terms);
 
58
  }
59
+ return false;
 
60
  }
61
+ return is_tax() || is_category() || is_tag();
62
  }
63
 
64
+ /**
65
+ * Query join
66
+ * @return string
67
+ */
68
  public function db_join() {
69
  global $wpdb;
70
 
77
 
78
  }
79
 
80
+ /**
81
+ * Query where
82
+ * @return string
83
+ */
84
  public function db_where() {
85
 
86
  if(is_singular()) {
107
 
108
  }
109
 
110
+ /**
111
+ * Query where2
112
+ * @return string
113
+ */
114
  public function db_where2() {
115
  return "terms.slug IS NOT NULL OR taxonomies.meta_value IS NOT NULL";
116
  }
117
 
118
+ /**
119
+ * Get registered taxonomies
120
+ * @return array
121
+ */
122
+ protected function _get_content() {
123
+ // List public taxonomies
124
+ if (empty($this->taxonomy_objects)) {
125
+ foreach (get_taxonomies(array('public' => true), 'objects') as $tax) {
126
+ $this->taxonomy_objects[$tax->name] = $tax;
127
+ }
128
+ }
129
+ return $this->taxonomy_objects;
130
  }
131
 
132
+ /**
133
+ * Meta box content
134
+ * @global object $post
135
+ * @return void
136
+ */
137
  public function meta_box_content() {
138
  global $post;
139
 
140
+ foreach ($this->_get_content() as $taxonomy) {
141
  echo '<h4><a href="#">' . $taxonomy->label . '</a></h4>'."\n";
142
  echo '<div class="cas-rule-content" id="cas-' . $this->id . '-' . $taxonomy->name . '">';
143
 
144
  $meta = get_post_meta($post->ID, ContentAwareSidebars::prefix . 'taxonomies', false);
145
  $current = $meta != '' ? $meta : array();
146
 
147
+ $number_of_terms = wp_count_terms($taxonomy->name,array('hide_empty'=>false));
148
 
149
  if($taxonomy->hierarchical) {
150
  echo '<p>' . "\n";
151
+ echo '<label><input type="checkbox" name="taxonomies[]" value="'.ContentAwareSidebars::prefix.'sub_' . $taxonomy->name . '"' . checked(in_array(ContentAwareSidebars::prefix."_sub_" . $taxonomy->name, $current), true, false) . ' /> ' . __('Automatically select new children of a selected ancestor', ContentAwareSidebars::domain) . '</label>' . "\n";
152
  echo '</p>' . "\n";
153
  }
154
  echo '<p>' . "\n";
155
+ echo '<label><input class="cas-chk-all" type="checkbox" name="taxonomies[]" value="' . $taxonomy->name . '"' . checked(in_array($taxonomy->name, $current), true, false) . ' /> ' . sprintf(__('Show with %s', ContentAwareSidebars::domain), $taxonomy->labels->all_items) . '</label>' . "\n";
156
  echo '</p>' . "\n";
157
 
158
+ if (!$number_of_terms) {
159
  echo '<p>' . __('No items.') . '</p>';
160
  } else {
161
+
162
+ $selected_ids = array();
163
+ if(($selected = wp_get_object_terms($post->ID, $taxonomy->name))) {
164
+ $selected_ids = wp_get_object_terms($post->ID, $taxonomy->name, array('fields' => 'ids'));
165
+ } else {
166
+ $selected = array();
167
+ }
168
+ $terms = get_terms($taxonomy->name, array(
169
+ 'number' => 20,
170
+ 'hide_empty' => false,
171
+ 'exclude' => $selected_ids
172
+ ));
173
+
174
+ if($number_of_terms > 20) {
175
+ echo _x('Search','verb',ContentAwareSidebars::domain).' <input class="cas-autocomplete-' . $this->id . ' cas-autocomplete" id="cas-autocomplete-' . $this->id . '-' . $taxonomy->name . '" type="text" name="cas-autocomplete" value="" /> <input type="button" id="cas-add-' . $this->id . '-' . $taxonomy->name . '" class="button" value="'.__('Add',ContentAwareSidebars::domain).'"/>'."\n";
176
+ }
177
+
178
+ echo '<ul id="cas-list-' . $this->id . '-' . $taxonomy->name . '" class="cas-contentlist categorychecklist form-no-clear">'."\n";
179
+ echo '<input type="hidden" name="'.($taxonomy->name == "category" ? "post_category[]" : "tax_input[".$taxonomy->name."]").'" value="0" />';
180
+ $this->term_checklist($post->ID, $taxonomy, array_merge($selected,$terms), $selected_ids);
181
+ echo '</ul>'."\n";
182
+
183
  }
184
  echo '</div>'."\n";
185
  }
186
  }
187
+
188
+ /**
189
+ * Show terms from a specific taxonomy
190
+ * @param int $post_id
191
+ * @param object $taxonomy
192
+ * @param array $terms
193
+ * @param array $selected_ids
194
+ * @return void
195
+ */
196
+ private function term_checklist($post_id = 0, $taxonomy, $terms, $selected_ids) {
197
+
198
+ $walker = new CAS_Walker_Checklist('category',array ('parent' => 'parent', 'id' => 'term_id'));
199
+
200
+ $args = array(
201
+ 'taxonomy' => $taxonomy,
202
+ 'selected_terms' => $post_id ? $selected_ids : array()
203
+ );
204
+
205
+ $checked_terms = array();
206
+
207
+ foreach( $terms as $key => $value ) {
208
+ if (in_array($terms[$key]->term_id, $args['selected_terms'])) {
209
+ $checked_terms[] = $terms[$key];
210
+ unset($terms[$key]);
211
+ }
212
+ }
213
+
214
+ //Put checked posts on top
215
+ echo call_user_func_array(array(&$walker, 'walk'), array($checked_terms, 0, $args));
216
+ // Then the rest of them
217
+ echo call_user_func_array(array(&$walker, 'walk'), array($terms, 0, $args));
218
+ }
219
+
220
+ /**
221
+ * Get terms with AJAX search
222
+ * @return void
223
+ */
224
+ public function ajax_content_search() {
225
+
226
+ // Verify request
227
+ check_ajax_referer(basename('content-aware-sidebars.php'),'nonce');
228
 
229
+ $suggestions = array();
230
+ if ( preg_match('/cas-autocomplete-'.$this->id.'-([a-zA-Z_-]*\b)/', $_REQUEST['type'], $matches) ) {
231
+ if(($taxonomy = get_taxonomy( $matches[1] ))) {
232
+ $terms = get_terms($taxonomy->name, array(
233
+ 'number' => 10,
234
+ 'hide_empty' => false,
235
+ 'search' => $_REQUEST['term']
236
+ ));
237
+ $name = ($taxonomy->name == 'category' ? 'post_category' : 'tax_input['.$matches[1].']');
238
+ $value = ($taxonomy->hierarchical ? 'term_id' : 'slug');
239
+ foreach($terms as $term) {
240
+ $suggestions[] = array(
241
+ 'label' => $term->name,
242
+ 'value' => $term->name,
243
+ 'id' => $term->$value,
244
+ 'module' => $this->id,
245
+ 'name' => $name,
246
+ 'id2' => $this->id.'-'.$term->taxonomy,
247
+ 'elem' => $term->taxonomy.'-'.$term->term_id
248
+ );
249
+ }
250
  }
251
  }
252
+
253
+ echo json_encode($suggestions);
254
+ die();
255
+ }
256
+
257
+ /**
258
+ * Register taxonomies to sidebar post type
259
+ * @return void
260
+ */
261
+ public function add_taxonomies_to_sidebar() {
262
+ foreach($this->_get_content() as $tax) {
263
+ register_taxonomy_for_object_type( $tax->name, ContentAwareSidebars::type_sidebar );
264
+ }
265
+ }
266
+
267
+
268
+ /**
269
+ * Remove taxonomy shortcuts from menu and standard meta boxes.
270
+ * @return void
271
+ */
272
+ public function clear_admin_menu() {
273
+ if(current_user_can('edit_theme_options')) {
274
+ foreach($this->_get_content() as $tax) {
275
+ remove_submenu_page('edit.php?post_type='.ContentAwareSidebars::type_sidebar,'edit-tags.php?taxonomy='.$tax->name.'&amp;post_type='.ContentAwareSidebars::type_sidebar);
276
+ }
277
+ } else {
278
+ // Remove those taxonomies left in the menu when it should be hidden
279
+ foreach($this->_get_content() as $tax) {
280
+ remove_menu_page('edit-tags.php?taxonomy='.$tax->name.'&amp;post_type='.ContentAwareSidebars::type_sidebar);
281
+ }
282
+ }
283
  }
284
 
285
  /**
 
286
  * Auto-select children of selected ancestor
287
+ * @param int $term_id
288
+ * @param int $tt_id
289
+ * @param string $taxonomy
290
+ * @return void
291
  */
292
  public function term_ancestry_check($term_id, $tt_id, $taxonomy) {
293
 
297
  if($term->parent != '0') {
298
  // Get sidebars with term ancestor wanting to auto-select term
299
  $posts = new WP_Query(array(
300
+ 'post_type' => ContentAwareSidebars::type_sidebar,
301
  'meta_query' => array(
302
  array(
303
  'key' => ContentAwareSidebars::prefix . $this->id,
304
+ 'value' => ContentAwareSidebars::prefix.'sub_' . $taxonomy,
305
  'compare' => '='
306
  )
307
  ),
modules/transposh.php CHANGED
@@ -14,22 +14,39 @@
14
  */
15
  class CASModule_transposh extends CASModule {
16
 
 
 
 
17
  public function __construct() {
18
  parent::__construct();
19
  $this->id = 'language';
20
- $this->name = __('Languages','content-aware-sidebars');
21
  }
22
 
 
 
 
 
23
  public function is_content() {
24
  return true;
25
  }
26
 
 
 
 
 
 
27
  public function db_where() {
28
  global $my_transposh_plugin;
29
  return "(language.meta_value IS NULL OR language.meta_value IN('language','".$my_transposh_plugin->tgl."'))";
30
 
31
  }
32
 
 
 
 
 
 
33
  protected function _get_content() {
34
  global $my_transposh_plugin;
35
  $langs = array();
14
  */
15
  class CASModule_transposh extends CASModule {
16
 
17
+ /**
18
+ * Constructor
19
+ */
20
  public function __construct() {
21
  parent::__construct();
22
  $this->id = 'language';
23
+ $this->name = __('Languages',ContentAwareSidebars::domain);
24
  }
25
 
26
+ /**
27
+ * Determine if content is relevant
28
+ * @return boolean
29
+ */
30
  public function is_content() {
31
  return true;
32
  }
33
 
34
+ /**
35
+ * Where query
36
+ * @global object $my_transposh_plugin
37
+ * @return string
38
+ */
39
  public function db_where() {
40
  global $my_transposh_plugin;
41
  return "(language.meta_value IS NULL OR language.meta_value IN('language','".$my_transposh_plugin->tgl."'))";
42
 
43
  }
44
 
45
+ /**
46
+ * Get languages
47
+ * @global object $my_transposh_plugin
48
+ * @return array
49
+ */
50
  protected function _get_content() {
51
  global $my_transposh_plugin;
52
  $langs = array();
modules/wpml.php CHANGED
@@ -14,20 +14,35 @@
14
  */
15
  class CASModule_wpml extends CASModule {
16
 
 
 
 
17
  public function __construct() {
18
  parent::__construct();
19
  $this->id = 'language';
20
- $this->name = __('Languages','content-aware-sidebars');
21
  }
22
 
 
 
 
 
23
  public function is_content() {
24
  return true;
25
  }
26
 
 
 
 
 
27
  public function db_where() {
28
  return "(language.meta_value IS NULL OR language.meta_value IN('language','".ICL_LANGUAGE_CODE."'))";
29
  }
30
 
 
 
 
 
31
  protected function _get_content() {
32
  $langs = array();
33
 
14
  */
15
  class CASModule_wpml extends CASModule {
16
 
17
+ /**
18
+ * Constructor
19
+ */
20
  public function __construct() {
21
  parent::__construct();
22
  $this->id = 'language';
23
+ $this->name = __('Languages',ContentAwareSidebars::domain);
24
  }
25
 
26
+ /**
27
+ * Determine if content is relevant
28
+ * @return boolean
29
+ */
30
  public function is_content() {
31
  return true;
32
  }
33
 
34
+ /**
35
+ * Where query
36
+ * @return string
37
+ */
38
  public function db_where() {
39
  return "(language.meta_value IS NULL OR language.meta_value IN('language','".ICL_LANGUAGE_CODE."'))";
40
  }
41
 
42
+ /**
43
+ * Get languages
44
+ * @return array
45
+ */
46
  protected function _get_content() {
47
  $langs = array();
48
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: intoxstudio
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=KPZHE6A72LEN4&lc=US&item_name=WordPress%20Plugin%3a%20Content%20Aware%20Sidebars&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
4
  Tags: sidebar, widget area, content aware, context aware, seo, dynamic, flexible, modular, bbpress, buddypress, qtranslate, polylang, transposh, wpml
5
  Requires at least: 3.1
6
- Tested up to: 3.5
7
- Stable tag: 1.2
8
  License: GPL2
9
 
10
  Create and display sidebars according to the content being viewed.
@@ -52,6 +52,7 @@ No extra database tables or table columns will be added.
52
  * Danish (da_DK): [Joachim Jensen](http://www.intox.dk/)
53
  * Italian (it_IT): [Luciano Del Fico](http://www.myweb2.it/)
54
  * Lithuanian (lt_LT): [Vincent G](http://host1free.com/)
 
55
 
56
  If you have translated the plugin into your language or updated an existing translation, please send the .po and .mo files to jv[at]intox.dk.
57
  Download the latest [.pot file](http://plugins.svn.wordpress.org/content-aware-sidebars/trunk/lang/content-aware-sidebars.pot) or the [.po file in your language](http://plugins.svn.wordpress.org/content-aware-sidebars/trunk/lang/).
@@ -107,6 +108,26 @@ The function accepts URL-style strings as parameters too, like the standard Word
107
 
108
  == Changelog ==
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  = 1.2 =
111
 
112
  * Added: polylang support
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=KPZHE6A72LEN4&lc=US&item_name=WordPress%20Plugin%3a%20Content%20Aware%20Sidebars&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
4
  Tags: sidebar, widget area, content aware, context aware, seo, dynamic, flexible, modular, bbpress, buddypress, qtranslate, polylang, transposh, wpml
5
  Requires at least: 3.1
6
+ Tested up to: 3.6
7
+ Stable tag: 1.3.1
8
  License: GPL2
9
 
10
  Create and display sidebars according to the content being viewed.
52
  * Danish (da_DK): [Joachim Jensen](http://www.intox.dk/)
53
  * Italian (it_IT): [Luciano Del Fico](http://www.myweb2.it/)
54
  * Lithuanian (lt_LT): [Vincent G](http://host1free.com/)
55
+ * Slovak (sk_SK): [Branco](http://webhostinggeeks.com/)
56
 
57
  If you have translated the plugin into your language or updated an existing translation, please send the .po and .mo files to jv[at]intox.dk.
58
  Download the latest [.pot file](http://plugins.svn.wordpress.org/content-aware-sidebars/trunk/lang/content-aware-sidebars.pot) or the [.po file in your language](http://plugins.svn.wordpress.org/content-aware-sidebars/trunk/lang/).
108
 
109
  == Changelog ==
110
 
111
+ = 1.3.1 =
112
+
113
+ * Added: authors and bbpress user profiles now searchable on edit page
114
+ * Added: items found in search on edit page are prepended and checked by default
115
+ * Added: updated edit page gui
116
+ * Added: search field only visible when quantity is above 20
117
+ * Fixed: select all checkbox will now disable all input in container
118
+ * Fixed: host sidebar could sometimes not be found in sidebar list
119
+
120
+ = 1.3 =
121
+
122
+ * Added: post type posts and taxonomy terms now searchable on edit page
123
+ * Added: sidebar handle and host shown on widgets page
124
+ * Added: slovak translation
125
+ * Fixed: sidebar meta boxes more robust to external modifications
126
+ * Fixed: admin column headers more robust to external modifications
127
+ * Fixed: sidebar menu now always hidden for users without right cap
128
+ * Fixed: code optimization and refactor for performance
129
+ * Removed: support for sidebar excerpt
130
+
131
  = 1.2 =
132
 
133
  * Added: polylang support
uninstall.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
  /**
3
  * @package Content Aware Sidebars
 
4
  */
5
 
6
  if(!defined('WP_UNINSTALL_PLUGIN')) {
@@ -13,7 +14,7 @@ delete_option('cas_db_version');
13
  // Remove all sidebars
14
  $posts = get_posts(array(
15
  'numberposts' => -1,
16
- 'post_type' => 'sidebar',
17
  'post_status' => 'any'
18
  ));
19
  foreach($posts as $post) {
@@ -23,4 +24,3 @@ foreach($posts as $post) {
23
  // Remove user meta
24
  global $wpdb;
25
  $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN('metaboxhidden_sidebar','closedpostboxes_sidebar')");
26
-
1
  <?php
2
  /**
3
  * @package Content Aware Sidebars
4
+ * @author Joachim Jensen <jv@intox.dk>
5
  */
6
 
7
  if(!defined('WP_UNINSTALL_PLUGIN')) {
14
  // Remove all sidebars
15
  $posts = get_posts(array(
16
  'numberposts' => -1,
17
+ 'post_type' => 'sidebar',
18
  'post_status' => 'any'
19
  ));
20
  foreach($posts as $post) {
24
  // Remove user meta
25
  global $wpdb;
26
  $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN('metaboxhidden_sidebar','closedpostboxes_sidebar')");
 
update_db.php CHANGED
@@ -1,58 +1,54 @@
1
  <?php
2
  /**
3
  * @package Content Aware Sidebars
 
4
  */
5
 
6
  /**
7
- *
8
  * Run updates
9
- *
10
- * @param type $current_version
11
- * @return boolean
12
  */
13
  function cas_run_db_update($current_version) {
14
-
15
- if(current_user_can('update_plugins')) {
16
-
17
- // Get current plugin db version
18
- $installed_version = get_option('cas_db_version');
19
-
20
  if($installed_version === false)
21
- $installed_version = 0;
22
-
23
- // Database is up to date
24
- if($installed_version == $current_version)
25
- return true;
26
-
27
- $versions = array(0.8,1.1);
28
-
29
  //Launch updates
30
  foreach($versions as $version) {
 
31
  $return = false;
32
-
33
- if(version_compare($installed_version,$version,'<')) {
34
- $function = 'cas_update_to_'.str_replace('.','',$version);
35
- if(function_exists($function)) {
36
-
37
  $return = $function();
38
-
39
- // Update database on success
40
- if($return) {
41
  update_option('cas_db_version',$installed_version = $version);
42
- }
43
- }
44
- }
45
  }
46
-
47
- return $return;
48
- }
49
  }
50
 
51
  /**
52
  * Version 0.8 -> 1.1
53
  * Serialized metadata gets their own rows
54
- *
55
- * @param boolean $return
56
  */
57
  function cas_update_to_11() {
58
 
@@ -68,7 +64,7 @@ function cas_update_to_11() {
68
  // Get all sidebars
69
  $posts = get_posts(array(
70
  'numberposts' => -1,
71
- 'post_type' => 'sidebar',
72
  'post_status' => 'publish,pending,draft,future,private,trash'
73
  ));
74
 
@@ -91,19 +87,16 @@ function cas_update_to_11() {
91
  }
92
 
93
  /**
94
- *
95
  * Version 0 -> 0.8
96
  * Introduces database version management, adds preficed keys to metadata
97
- *
98
  * @global object $wpdb
99
- * @param boolean $return
100
  */
101
  function cas_update_to_08() {
102
- global $wpdb;
103
-
104
- $prefix = '_cas_';
105
- $metadata = array(
106
- 'post_types',
107
  'taxonomies',
108
  'authors',
109
  'page_templates',
@@ -112,30 +105,29 @@ function cas_update_to_08() {
112
  'handle',
113
  'host',
114
  'merge-pos'
115
- );
116
-
117
- // Get all sidebars
118
- $posts = $wpdb->get_col($wpdb->prepare("
119
- SELECT ID
120
- FROM $wpdb->posts
121
- WHERE post_type = %s
122
- ",'sidebar'));
123
-
124
- //Check if there is any
125
- if(!empty($posts)) {
126
- //Update the meta keys
127
- foreach($metadata as $meta) {
128
- $wpdb->query("
129
- UPDATE $wpdb->postmeta
130
- SET meta_key = '".$prefix.$meta."'
131
- WHERE meta_key = '".$meta."'
132
- AND post_id IN(".implode(',',$posts).")
133
- ");
134
- }
135
  // Clear cache for new meta keys
136
  wp_cache_flush();
137
- }
138
-
139
- return true;
140
-
141
  }
1
  <?php
2
  /**
3
  * @package Content Aware Sidebars
4
+ * @author Joachim Jensen <jv@intox.dk>
5
  */
6
 
7
  /**
 
8
  * Run updates
9
+ * @param float $current_version
10
+ * @return boolean
 
11
  */
12
  function cas_run_db_update($current_version) {
13
+
14
+ if(current_user_can('update_plugins')) {
15
+ // Get current plugin db version
16
+ $installed_version = get_option('cas_db_version');
17
+
 
18
  if($installed_version === false)
19
+ $installed_version = 0;
20
+
21
+ // Database is up to date
22
+ if($installed_version == $current_version)
23
+ return true;
24
+
25
+ $versions = array(0.8,1.1);
26
+
27
  //Launch updates
28
  foreach($versions as $version) {
29
+
30
  $return = false;
31
+
32
+ if(version_compare($installed_version,$version,'<')) {
33
+ $function = 'cas_update_to_'.str_replace('.','',$version);
34
+ if(function_exists($function)) {
 
35
  $return = $function();
36
+ // Update database on success
37
+ if($return) {
 
38
  update_option('cas_db_version',$installed_version = $version);
39
+ }
40
+ }
41
+ }
42
  }
43
+ return $return;
44
+ }
45
+ return false;
46
  }
47
 
48
  /**
49
  * Version 0.8 -> 1.1
50
  * Serialized metadata gets their own rows
51
+ * @return boolean
 
52
  */
53
  function cas_update_to_11() {
54
 
64
  // Get all sidebars
65
  $posts = get_posts(array(
66
  'numberposts' => -1,
67
+ 'post_type' => ContentAwareSidebars::type_sidebar,
68
  'post_status' => 'publish,pending,draft,future,private,trash'
69
  ));
70
 
87
  }
88
 
89
  /**
 
90
  * Version 0 -> 0.8
91
  * Introduces database version management, adds preficed keys to metadata
 
92
  * @global object $wpdb
93
+ * @return boolean
94
  */
95
  function cas_update_to_08() {
96
+ global $wpdb;
97
+
98
+ $metadata = array(
99
+ 'post_types',
 
100
  'taxonomies',
101
  'authors',
102
  'page_templates',
105
  'handle',
106
  'host',
107
  'merge-pos'
108
+ );
109
+
110
+ // Get all sidebars
111
+ $posts = $wpdb->get_col($wpdb->prepare("
112
+ SELECT ID
113
+ FROM $wpdb->posts
114
+ WHERE post_type = %s
115
+ ",ContentAwareSidebars::type_sidebar));
116
+
117
+ //Check if there is any
118
+ if(!empty($posts)) {
119
+ //Update the meta keys
120
+ foreach($metadata as $meta) {
121
+ $wpdb->query("
122
+ UPDATE $wpdb->postmeta
123
+ SET meta_key = '".ContentAwareSidebars::prefix.$meta."'
124
+ WHERE meta_key = '".$meta."'
125
+ AND post_id IN(".implode(',',$posts).")
126
+ ");
127
+ }
128
  // Clear cache for new meta keys
129
  wp_cache_flush();
130
+ }
131
+
132
+ return true;
 
133
  }
walker.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
  /**
3
  * @package Content Aware Sidebars
 
4
  */
5
 
6
  /**
@@ -11,8 +12,9 @@
11
  class CAS_Walker_Checklist extends Walker {
12
 
13
  /**
14
- * @param type $tree_type
15
- * @param type $db_fields
 
16
  */
17
  function __construct($tree_type, $db_fields) {
18
 
@@ -22,9 +24,11 @@ class CAS_Walker_Checklist extends Walker {
22
  }
23
 
24
  /**
25
- * @param type $output
26
- * @param type $depth
27
- * @param type $args
 
 
28
  */
29
  public function start_lvl(&$output, $depth, $args) {
30
  $indent = str_repeat("\t", $depth);
@@ -32,9 +36,11 @@ class CAS_Walker_Checklist extends Walker {
32
  }
33
 
34
  /**
35
- * @param type $output
36
- * @param type $depth
37
- * @param type $args
 
 
38
  */
39
  public function end_lvl(&$output, $depth, $args) {
40
  $indent = str_repeat("\t", $depth);
@@ -42,11 +48,12 @@ class CAS_Walker_Checklist extends Walker {
42
  }
43
 
44
  /**
45
- * @param type $output
46
- * @param type $term
47
- * @param type $depth
48
- * @param type $args
49
- * @return type
 
50
  */
51
  public function start_el(&$output, $term, $depth, $args) {
52
  extract($args);
@@ -58,7 +65,7 @@ class CAS_Walker_Checklist extends Walker {
58
  return;
59
  }
60
 
61
- $output .= "\n".'<li id="'.$post_type->name.'-'.$term->ID.'"><label class="selectit"><input class="cas-post_types-'.$post_type->name.'" value="'.$term->ID.'" type="checkbox" name="post_types[]" id="in-'.$post_type->name.'-'.$term->ID.'"'.checked(in_array($term->ID,$selected_cats),true,false).disabled(empty($disabled),false,false).'/> '.esc_html( $term->post_title ).'</label>';
62
 
63
  } else {
64
 
@@ -67,21 +74,21 @@ class CAS_Walker_Checklist extends Walker {
67
  return;
68
  }
69
 
70
- $name = $taxonomy->name == 'category' ? 'post_category' : 'tax_input['.$taxonomy->name.']';
71
- $value = $taxonomy->hierarchical ? 'term_id' : 'slug';
72
- $class = in_array( $term->term_id, $popular_terms ) ? ' class="popular-category"' : '';
73
 
74
- $output .= "\n".'<li id="'.$taxonomy->name.'-'.$term->term_id.'"'.$class.'><label class="selectit"><input class="cas-taxonomies-'.$taxonomy->name.'" value="'.$term->$value.'" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy->name.'-'.$term->term_id.'"'.checked(in_array($term->term_id,$selected_terms),true,false).disabled(empty($disabled),false,false).'/> '.esc_html( apply_filters('the_category', $term->name )) . '</label>';
75
 
76
  }
77
-
78
- }
79
 
80
  /**
81
- * @param string $output
82
- * @param type $term
83
- * @param type $depth
84
- * @param type $args
 
 
85
  */
86
  public function end_el(&$output, $term, $depth, $args) {
87
  $output .= "</li>\n";
@@ -90,73 +97,14 @@ class CAS_Walker_Checklist extends Walker {
90
  }
91
 
92
  /**
93
- *
94
- * Show terms checklist
95
- *
96
- * @param type $post_id
97
- * @param type $args
98
- */
99
- function cas_terms_checklist($post_id = 0, $args = array()) {
100
- $defaults = array(
101
- 'popular_terms' => false,
102
- 'taxonomy' => 'category',
103
- 'terms' => null,
104
- 'checked_ontop' => true
105
- );
106
- extract(wp_parse_args($args, $defaults), EXTR_SKIP);
107
-
108
- $walker = new CAS_Walker_Checklist('category',array ('parent' => 'parent', 'id' => 'term_id'));
109
-
110
- if(!is_object($taxonomy))
111
- $taxonomy = get_taxonomy($taxonomy);
112
-
113
- $args = array(
114
- 'taxonomy' => $taxonomy,
115
- 'disabled' => !current_user_can($taxonomy->cap->assign_terms)
116
- );
117
-
118
- if ($post_id)
119
- $args['selected_terms'] = wp_get_object_terms($post_id, $taxonomy->name, array_merge($args, array('fields' => 'ids')));
120
- else
121
- $args['selected_terms'] = array();
122
-
123
- if (is_array($popular_terms))
124
- $args['popular_terms'] = $popular_terms;
125
- else
126
- $args['popular_terms'] = get_terms( $taxonomy->name, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
127
-
128
- if(!$terms)
129
- $terms = (array) get_terms($taxonomy->name, array('get' => 'all'));
130
-
131
- if ($checked_ontop) {
132
- $checked_terms = array();
133
- $keys = array_keys( $terms );
134
-
135
- foreach($keys as $k) {
136
- if (in_array($terms[$k]->term_id, $args['selected_terms'])) {
137
- $checked_terms[] = $terms[$k];
138
- unset($terms[$k]);
139
- }
140
- }
141
-
142
- // Put checked terms on top
143
- echo call_user_func_array(array(&$walker, 'walk'), array($checked_terms, 0, $args));
144
- }
145
- // Then the rest of them
146
- echo call_user_func_array(array(&$walker, 'walk'), array($terms, 0, $args));
147
- }
148
-
149
- /**
150
- *
151
  * Show checklist for popular terms
152
- *
153
- * @global type $post_ID
154
- * @param type $taxonomy
155
- * @param type $default
156
- * @param type $number
157
- * @param type $echo
158
- * @return type
159
- */
160
  function cas_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
161
  global $post_ID;
162
 
@@ -166,10 +114,9 @@ function cas_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ec
166
  $checked_terms = array();
167
 
168
  $terms = get_terms( $taxonomy->name, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
 
 
169
 
170
- $disabled = current_user_can($taxonomy->cap->assign_terms) ? '' : ' disabled="disabled"';
171
-
172
- $popular_ids = array();
173
  foreach ( (array) $terms as $term ) {
174
  $popular_ids[] = $term->term_id;
175
  if ( !$echo ) // hack for AJAX use
@@ -188,59 +135,3 @@ function cas_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ec
188
  }
189
  return $popular_ids;
190
  }
191
-
192
- /**
193
- *
194
- * Show posts checklist
195
- *
196
- * @param type $post_id
197
- * @param type $args
198
- */
199
- function cas_posts_checklist($post_id = 0, $args = array()) {
200
- $defaults = array(
201
- 'post_type' => 'post',
202
- 'posts' => null,
203
- 'checked_ontop' => true
204
- );
205
- extract(wp_parse_args($args, $defaults), EXTR_SKIP);
206
-
207
- $walker = new CAS_Walker_Checklist('post',array ('parent' => 'post_parent', 'id' => 'ID'));
208
-
209
- if(!is_object($post_type))
210
- $post_type = get_post_type_object($post_type);
211
-
212
- $args = array(
213
- 'post_type' => $post_type,
214
- //'disabled' => !current_user_can($post_type->cap->read_post,$post_type)
215
- );
216
-
217
- if($post_id)
218
- $args['selected_cats'] = get_post_meta($post_id, '_cas_post_types', false);
219
- else
220
- $args['selected_cats'] = array();
221
-
222
- if(!$posts)
223
- $posts = get_posts(array(
224
- 'numberposts' => -1,
225
- 'post_type' => $post_type->name,
226
- 'post_status' => array('publish','private','future'),
227
- ));
228
-
229
- if ( $checked_ontop ) {
230
- $checked_posts = array();
231
- $keys = array_keys($posts);
232
-
233
- foreach( $keys as $k ) {
234
- if (in_array($posts[$k]->ID, $args['selected_cats'])) {
235
- $checked_posts[] = $posts[$k];
236
- unset($posts[$k]);
237
- }
238
- }
239
-
240
- //Put checked posts on top
241
- echo call_user_func_array(array(&$walker, 'walk'), array($checked_posts, 0, $args));
242
- }
243
-
244
- // Then the rest of them
245
- echo call_user_func_array(array(&$walker, 'walk'), array($posts, 0, $args));
246
- }
1
  <?php
2
  /**
3
  * @package Content Aware Sidebars
4
+ * @author Joachim Jensen <jv@intox.dk>
5
  */
6
 
7
  /**
12
  class CAS_Walker_Checklist extends Walker {
13
 
14
  /**
15
+ * Constructor
16
+ * @param string $tree_type
17
+ * @param array $db_fields
18
  */
19
  function __construct($tree_type, $db_fields) {
20
 
24
  }
25
 
26
  /**
27
+ * Start outputting level
28
+ * @param string $output
29
+ * @param int $depth
30
+ * @param array $args
31
+ * @return void
32
  */
33
  public function start_lvl(&$output, $depth, $args) {
34
  $indent = str_repeat("\t", $depth);
36
  }
37
 
38
  /**
39
+ * End outputting level
40
+ * @param string $output
41
+ * @param int $depth
42
+ * @param array $args
43
+ * @return void
44
  */
45
  public function end_lvl(&$output, $depth, $args) {
46
  $indent = str_repeat("\t", $depth);
48
  }
49
 
50
  /**
51
+ * Start outputting element
52
+ * @param string $output
53
+ * @param object $term
54
+ * @param int $depth
55
+ * @param array $args
56
+ * @return void
57
  */
58
  public function start_el(&$output, $term, $depth, $args) {
59
  extract($args);
65
  return;
66
  }
67
 
68
+ $output .= "\n".'<li id="'.$post_type->name.'-'.$term->ID.'"><label class="selectit"><input class="cas-post_types-'.$term->ID.' cas-post_types-'.$post_type->name.'" value="'.$term->ID.'" type="checkbox" name="post_types[]"'.checked(in_array($term->ID,$selected_cats),true,false).'/> '.esc_html( $term->post_title ).'</label>';
69
 
70
  } else {
71
 
74
  return;
75
  }
76
 
77
+ $name = ($taxonomy->name == 'category' ? 'post_category' : 'tax_input['.$taxonomy->name.']');
78
+ $value = ($taxonomy->hierarchical ? 'term_id' : 'slug');
 
79
 
80
+ $output .= "\n".'<li id="'.$taxonomy->name.'-'.$term->term_id.'"><label class="selectit"><input class="cas-taxonomies-'.$taxonomy->name.'" value="'.$term->$value.'" type="checkbox" name="'.$name.'[]"'.checked(in_array($term->term_id,$selected_terms),true,false).'/> '.esc_html( $term->name ) . '</label>';
81
 
82
  }
83
+ }
 
84
 
85
  /**
86
+ * End outputting element
87
+ * @param string $output
88
+ * @param object $term
89
+ * @param int $depth
90
+ * @param array $args
91
+ * @return void
92
  */
93
  public function end_el(&$output, $term, $depth, $args) {
94
  $output .= "</li>\n";
97
  }
98
 
99
  /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  * Show checklist for popular terms
101
+ * @global int $post_ID
102
+ * @param object $taxonomy
103
+ * @param int $default
104
+ * @param int $number
105
+ * @param boolean $echo
106
+ * @return array
107
+ */
 
108
  function cas_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
109
  global $post_ID;
110
 
114
  $checked_terms = array();
115
 
116
  $terms = get_terms( $taxonomy->name, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
117
+ $disabled = current_user_can($taxonomy->cap->assign_terms) ? '' : ' disabled="disabled"';
118
+ $popular_ids = array();
119
 
 
 
 
120
  foreach ( (array) $terms as $term ) {
121
  $popular_ids[] = $term->term_id;
122
  if ( !$echo ) // hack for AJAX use
135
  }
136
  return $popular_ids;
137
  }