Content Aware Sidebars – Unlimited Widget Areas - Version 1.3.5

Version Description

  • Fixed: menu would disappear in rare cases. Props grezvany13
  • Fixed: search function now searches in title and slug (not content) for post types
  • Added: search function displays at most 20 results instead of 10
Download this release

Release Info

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

Code changes from version 1.2 to 1.3.5

content-aware-sidebars.php CHANGED
@@ -7,101 +7,127 @@
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,17 +136,19 @@ 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
116
  'qtranslate' => defined('QT_SUPPORTED_WP_VERSION'), // qTranslate
117
  'transposh' => defined('TRANSPOSH_PLUGIN_VER'), // Transposh Translation Filter
118
- 'wpml' => defined('ICL_LANGUAGE_CODE') // WPML Multilingual Blog/CMS
119
  );
 
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 +157,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 +204,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 +247,124 @@ 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,216 +372,200 @@ 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;
482
- // $continue = apply_filters('cas_exclude_sidebar', $continue, $post, self::prefix);
483
  // if($continue)
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 +578,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
  */
@@ -615,13 +624,13 @@ final class ContentAwareSidebars {
615
  FROM $wpdb->posts posts
616
  LEFT JOIN $wpdb->postmeta handle
617
  ON handle.post_id = posts.ID
618
- AND handle.meta_key = '".self::prefix."handle'
619
  LEFT JOIN $wpdb->postmeta exposure
620
  ON exposure.post_id = posts.ID
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,353 +642,328 @@ 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
- //
711
- // // New sidebar
712
- // if($pagenow == 'post-new.php') {
713
- //
714
- // } else {
715
- //
716
- // }
717
-
718
  echo '<div id="cas-accordion">'."\n";
719
- foreach($this->modules as $module) {
720
- $module->meta_box_content();
721
- }
722
  echo '</div>'."\n";
723
 
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 +971,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.5
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
  $this->_load_dependencies();
88
+
89
  // WordPress Hooks. Somewhat ordered by execution
90
 
91
+ //For administration
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  if(is_admin()) {
 
93
 
94
+ add_action('wp_loaded', array(&$this,'db_update'));
95
+ add_action('admin_enqueue_scripts', array(&$this,'load_admin_scripts'));
96
+ add_action('delete_post', array(&$this,'remove_sidebar_widgets'));
97
+ add_action('save_post', array(&$this,'save_post'));
98
+ add_action('add_meta_boxes_'.self::TYPE_SIDEBAR, array(&$this,'create_meta_boxes'));
99
+ add_action('in_admin_header', array(&$this,'clear_admin_menu'),99);
100
+
101
+ add_filter('request', array(&$this,'admin_column_orderby'));
102
+ add_filter('default_hidden_meta_boxes', array(&$this,'change_default_hidden'),10,2);
103
+ add_filter('manage_edit-'.self::TYPE_SIDEBAR.'_columns', array(&$this,'admin_column_headers'),99);
104
+ add_filter('manage_edit-'.self::TYPE_SIDEBAR.'_sortable_columns',array(&$this,'admin_column_sortable_headers'));
105
+ add_filter('manage_posts_custom_column', array(&$this,'admin_column_rows'),10,3);
106
+ add_filter('post_row_actions', array(&$this,'sidebar_row_actions'),10,2);
107
+ add_filter('post_updated_messages', array(&$this,'sidebar_updated_messages'));
108
+
109
+ //For frontend
110
  } else {
111
+
112
+ add_filter('wp', array(&$this,'replace_sidebar'));
113
+
114
  }
115
+
116
+ //For both
117
+ add_action('plugins_loaded', array(&$this,'deploy_modules'));
118
+ add_action('init', array(&$this,'init_sidebar_type'),99);
119
+ add_action('widgets_init', array(&$this,'create_sidebars'),99);
120
+ add_action('wp_loaded', array(&$this,'update_sidebars'),99);
121
 
122
  }
123
 
124
  /**
 
125
  * Deploy modules
126
+ * @return void
127
  */
128
  public function deploy_modules() {
129
+
130
+ load_plugin_textdomain(self::DOMAIN, false, $this->basename.'/lang/');
131
 
132
  // List modules
133
  $modules = array(
136
  'author' => true,
137
  'page_template' => true,
138
  'taxonomy' => true,
139
+ 'url' => false,
140
  'bbpress' => function_exists('bbp_get_version'), // bbPress
141
  'bp_member' => defined('BP_VERSION'), // BuddyPress
142
  'polylang' => defined('POLYLANG_VERSION'), // Polylang
143
  'qtranslate' => defined('QT_SUPPORTED_WP_VERSION'), // qTranslate
144
  'transposh' => defined('TRANSPOSH_PLUGIN_VER'), // Transposh Translation Filter
145
+ 'wpml' => class_exists('SitePress') // WPML Multilingual Blog/CMS
146
  );
147
+ $modules = apply_filters('cas-module-pre-deploy',$modules);
148
 
149
  // Forge modules
150
  foreach($modules as $name => $enabled) {
151
+ if($enabled && include('modules/'.$name .'.php')) {
152
  $class = 'CASModule_'.$name;
153
  $this->modules[$name] = new $class;
154
  }
157
  }
158
 
159
  /**
 
160
  * Create post meta fields
 
 
161
  * @global array $wp_registered_sidebars
162
+ * @return void
163
  */
164
  private function _init_metadata() {
165
+ global $wp_registered_sidebars;
166
+
167
  // List of sidebars
168
  $sidebar_list = array();
169
  foreach($wp_registered_sidebars as $sidebar) {
170
+ $sidebar_list[$sidebar['id']] = $sidebar['name'];
 
171
  }
172
+
173
  // Meta fields
174
  $this->metadata['exposure'] = array(
175
+ 'name' => __('Exposure', self::DOMAIN),
176
  'id' => 'exposure',
177
  'desc' => '',
178
  'val' => 1,
179
  'type' => 'select',
180
  'list' => array(
181
+ __('Singular', self::DOMAIN),
182
+ __('Singular & Archive', self::DOMAIN),
183
+ __('Archive', self::DOMAIN)
184
  )
185
  );
186
  $this->metadata['handle'] = array(
187
+ 'name' => _x('Handle','option', self::DOMAIN),
188
  'id' => 'handle',
189
+ 'desc' => __('Replace host sidebar, merge with it or add sidebar manually.', self::DOMAIN),
190
  'val' => 0,
191
  'type' => 'select',
192
  'list' => array(
193
+ __('Replace', self::DOMAIN),
194
+ __('Merge', self::DOMAIN),
195
+ __('Manual', self::DOMAIN)
196
  )
197
  );
198
  $this->metadata['host'] = array(
199
+ 'name' => __('Host Sidebar', self::DOMAIN),
200
  'id' => 'host',
201
  'desc' => '',
202
  'val' => 'sidebar-1',
204
  'list' => $sidebar_list
205
  );
206
  $this->metadata['merge-pos'] = array(
207
+ 'name' => __('Merge position', self::DOMAIN),
208
  'id' => 'merge-pos',
209
+ 'desc' => __('Place sidebar on top or bottom of host when merging.', self::DOMAIN),
210
  'val' => 1,
211
  'type' => 'select',
212
  'list' => array(
213
+ __('Top', self::DOMAIN),
214
+ __('Bottom', self::DOMAIN)
215
  )
216
  );
217
 
218
  }
219
 
220
  /**
221
+ * Create sidebar post type
222
+ * @return void
 
223
  */
224
  public function init_sidebar_type() {
225
 
 
 
 
 
 
226
  // Register the sidebar type
227
+ register_post_type(self::TYPE_SIDEBAR,array(
228
  'labels' => array(
229
+ 'name' => __('Sidebars', self::DOMAIN),
230
+ 'singular_name' => __('Sidebar', self::DOMAIN),
231
+ 'add_new' => _x('Add New', 'sidebar', self::DOMAIN),
232
+ 'add_new_item' => __('Add New Sidebar', self::DOMAIN),
233
+ 'edit_item' => __('Edit Sidebar', self::DOMAIN),
234
+ 'new_item' => __('New Sidebar', self::DOMAIN),
235
+ 'all_items' => __('All Sidebars', self::DOMAIN),
236
+ 'view_item' => __('View Sidebar', self::DOMAIN),
237
+ 'search_items' => __('Search Sidebars', self::DOMAIN),
238
+ 'not_found' => __('No sidebars found', self::DOMAIN),
239
+ 'not_found_in_trash' => __('No sidebars found in Trash', self::DOMAIN)
240
  ),
241
  'capabilities' => array(
242
  'edit_post' => 'edit_theme_options',
247
  'publish_posts' => 'edit_theme_options',
248
  'read_private_posts' => 'edit_theme_options'
249
  ),
250
+ 'show_ui' => true,
251
+ 'show_in_menu' => true, //current_user_can('edit_theme_options'),
252
  'query_var' => false,
253
  'rewrite' => false,
254
+ 'menu_position' => 22,
255
+ 'supports' => array('title','page-attributes'),
256
+ 'menu_icon' => WP_PLUGIN_URL.'/'.$this->basename.'/img/icon-16.png'
 
257
  ));
258
+
259
  }
260
 
261
  /**
 
262
  * Create update messages
 
263
  * @global object $post
264
+ * @param array $messages
265
+ * @return array
266
  */
267
  public function sidebar_updated_messages( $messages ) {
268
+ $messages[self::TYPE_SIDEBAR] = array(
 
269
  0 => '',
270
+ 1 => sprintf(__('Sidebar updated. <a href="%s">Manage widgets</a>',self::DOMAIN),'widgets.php'),
271
  2 => '',
272
  3 => '',
273
+ 4 => __('Sidebar updated.',self::DOMAIN),
274
  5 => '',
275
+ 6 => sprintf(__('Sidebar published. <a href="%s">Manage widgets</a>',self::DOMAIN), 'widgets.php'),
276
+ 7 => __('Sidebar saved.',self::DOMAIN),
277
+ 8 => sprintf(__('Sidebar submitted. <a href="%s">Manage widgets</a>',self::DOMAIN),'widgets.php'),
278
+ 9 => sprintf(__('Sidebar scheduled for: <strong>%1$s</strong>. <a href="%2$s">Manage widgets</a>',self::DOMAIN),
279
  // translators: Publish box date format, see http://php.net/date
280
+ date_i18n(__('M j, Y @ G:i'),strtotime(get_the_ID())),'widgets.php'),
281
+ 10 => __('Sidebar draft updated.',self::DOMAIN),
282
  );
283
  return $messages;
284
  }
285
 
286
  /**
287
+ * Add sidebars to widgets area
288
+ * Triggered in widgets_init to save location for each theme
289
+ * @return void
290
  */
291
+ public function create_sidebars() {
292
+ //WP3.1 does not support (array) as post_status
293
+ $posts = get_posts(array(
294
+ 'numberposts' => -1,
295
+ 'post_type' => self::TYPE_SIDEBAR,
296
+ 'post_status' => 'publish,private,future'
297
+ ));
298
+
299
+ //Register sidebars to add them to the list
300
+ foreach($posts as $post) {
301
+ register_sidebar( array(
302
+ 'name' => $post->post_title,
303
+ 'id' => 'ca-sidebar-'.$post->ID
304
+ ));
305
  }
306
  }
307
 
308
  /**
309
+ * Update the created sidebars with metadata
310
+ * @return void
 
311
  */
312
+ public function update_sidebars() {
313
+
314
  //WP3.1 does not support (array) as post_status
315
  $posts = get_posts(array(
316
  'numberposts' => -1,
317
+ 'post_type' => self::TYPE_SIDEBAR,
318
  'post_status' => 'publish,private,future'
319
  ));
320
+
321
+ //Init metadata
322
+ $this->_init_metadata();
323
+
324
+ //Now reregister sidebars with proper content
325
  foreach($posts as $post) {
326
+
327
+ $handle = get_post_meta($post->ID, self::PREFIX . 'handle', true);
328
+ //$handle = $post->{self::PREFIX . 'handle'};
329
+ $desc = $this->metadata['handle']['list'][$handle];
330
+
331
+ if ($handle < 2) {
332
+ $host = get_post_meta($post->ID, self::PREFIX . 'host', true);
333
+ $desc .= ": " . (isset($this->metadata['host']['list'][$host]) ? $this->metadata['host']['list'][$host] : __('Please update Host Sidebar', self::DOMAIN) );
334
+ }
335
  register_sidebar( array(
336
  'name' => $post->post_title,
337
+ 'description' => $desc,
338
  'id' => 'ca-sidebar-'.$post->ID,
339
  'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
340
  'after_widget' => '</li>',
341
  'before_title' => '<h3 class="widget-title">',
342
  'after_title' => '</h3>',
343
  ));
344
+ }
345
  }
346
 
347
  /**
 
348
  * Add admin column headers
349
+ * @param array $columns
350
+ * @return array
 
351
  */
352
  public function admin_column_headers($columns) {
353
+ // Totally discard current columns and rebuild
354
+ return array(
355
+ 'cb' => $columns['cb'],
356
+ 'title' => $columns['title'],
357
+ 'exposure' => __('Exposure', self::DOMAIN),
358
+ 'handle' => _x('Handle','option', self::DOMAIN),
359
+ 'merge-pos' => __('Merge position', self::DOMAIN),
360
+ 'date' => $columns['date']
 
 
 
361
  );
362
  }
363
 
364
  /**
 
365
  * Make some columns sortable
366
+ * @param array $columns
367
+ * @return array
 
368
  */
369
  public function admin_column_sortable_headers($columns) {
370
  return array_merge(
372
  'exposure' => 'exposure',
373
  'handle' => 'handle',
374
  'merge-pos' => 'merge-pos'
375
+ ), $columns
 
376
  );
377
  }
378
 
379
  /**
 
380
  * Manage custom column sorting
381
+ * @param array $vars
 
382
  * @return array
383
  */
384
  public function admin_column_orderby($vars) {
385
+ if (isset($vars['orderby']) && in_array($vars['orderby'], array('exposure', 'handle', 'merge-pos'))) {
386
+ $vars = array_merge($vars, array(
387
+ 'meta_key' => self::PREFIX . $vars['orderby'],
388
+ 'orderby' => 'meta_value'
389
+ ));
390
  }
391
  return $vars;
392
  }
393
 
394
  /**
 
395
  * Add admin column rows
396
+ * @param string $column_name
397
+ * @param int $post_id
398
+ * @return void
 
399
  */
400
+ public function admin_column_rows($column_name, $post_id) {
401
+
402
+ if (get_post_type($post_id) != self::TYPE_SIDEBAR)
403
  return;
404
+
405
  // Load metadata
406
+ if (!$this->metadata)
407
+ $this->_init_metadata();
408
+
409
+ $current = get_post_meta($post_id, self::PREFIX . $column_name, true);
410
  $current_from_list = $this->metadata[$column_name]['list'][$current];
411
+
412
+ if ($column_name == 'handle' && $current < 2) {
413
+ $host = get_post_meta($post_id, self::PREFIX . 'host', true);
414
+ $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>');
415
+ }
416
  echo $current_from_list;
417
  }
418
 
419
  /**
 
420
  * Remove widget when its sidebar is removed
421
+ * @param int $post_id
422
+ * @return void
 
423
  */
424
  public function remove_sidebar_widgets($post_id) {
425
+
426
  // Authenticate and only continue on sidebar post type
427
+ if (!current_user_can('edit_theme_options') || get_post_type($post_id) != self::TYPE_SIDEBAR)
428
  return;
429
+
430
+ $id = 'ca-sidebar-' . $post_id;
431
+
432
  //Get widgets
433
  $sidebars_widgets = wp_get_sidebars_widgets();
434
+
435
  // Check if sidebar exists in database
436
+ if (!isset($sidebars_widgets[$id]))
437
  return;
438
+
439
  // Remove widgets settings from sidebar
440
+ foreach ($sidebars_widgets[$id] as $widget_id) {
441
+ $widget_type = preg_replace('/-[0-9]+$/', '', $widget_id);
442
+ $widget_settings = get_option('widget_' . $widget_type);
443
+ $widget_id = substr($widget_id, strpos($widget_id, '-') + 1);
444
+ if ($widget_settings && isset($widget_settings[$widget_id])) {
445
  unset($widget_settings[$widget_id]);
446
+ update_option('widget_' . $widget_type, $widget_settings);
447
  }
448
  }
449
+
450
  // Remove sidebar
451
  unset($sidebars_widgets[$id]);
452
  wp_set_sidebars_widgets($sidebars_widgets);
 
 
453
  }
454
 
455
  /**
 
456
  * Add admin rows actions
457
+ * @param array $actions
458
+ * @param object $post
 
459
  * @return array
460
  */
461
  public function sidebar_row_actions($actions, $post) {
462
+ if ($post->post_type == self::TYPE_SIDEBAR && $post->post_status != 'trash') {
463
+
464
  //View link is still there in WP3.1
465
+ unset($actions['view']);
466
+
 
467
  return array_merge(
468
+ array_slice($actions, 0, 2, true), array(
469
+ 'mng_widgets' => '<a href="widgets.php" title="' . esc_html(__('Manage Widgets', self::DOMAIN)) . '">' . __('Manage Widgets', self::DOMAIN) . '</a>'
470
+ ), $actions
 
 
471
  );
472
  }
473
  return $actions;
474
  }
475
 
476
  /**
477
+ * Replace or merge a sidebar with content aware sidebars.
478
+ * Handles sidebars with hosts
 
 
479
  * @global array $_wp_sidebars_widgets
480
  * @return void
481
  */
482
  public function replace_sidebar() {
483
  global $_wp_sidebars_widgets;
484
+
485
  $posts = $this->get_sidebars();
486
+ if (!$posts)
487
  return;
488
+
489
+ foreach ($posts as $post) {
490
+
491
+ // TODO
492
  // // Filter out sidebars with dependent content rules not present. Archives not yet decided.
493
  // if(!(is_archive() || (is_home() && !is_front_page()))) {
494
  // $continue = false;
495
+ // $continue = apply_filters('cas_exclude_sidebar', $continue, $post, self::PREFIX);
496
  // if($continue)
497
  // continue;
498
  // }
499
  //
500
+ $id = 'ca-sidebar-' . $post->ID;
501
+ $host = get_post_meta($post->ID, self::PREFIX . 'host', true);
502
+
503
  // Check for correct handling and if host exist
504
  if ($post->handle == 2 || !isset($_wp_sidebars_widgets[$host]))
505
  continue;
506
+
507
  // Sidebar might not have any widgets. Get it anyway!
508
+ if (!isset($_wp_sidebars_widgets[$id]))
509
  $_wp_sidebars_widgets[$id] = array();
510
+
511
  // If host has already been replaced, merge with it instead. Might change in future.
512
+ if ($post->handle || isset($handled_already[$host])) {
513
+ if (get_post_meta($post->ID, self::PREFIX . 'merge-pos', true))
514
+ $_wp_sidebars_widgets[$host] = array_merge($_wp_sidebars_widgets[$host], $_wp_sidebars_widgets[$id]);
515
  else
516
+ $_wp_sidebars_widgets[$host] = array_merge($_wp_sidebars_widgets[$id], $_wp_sidebars_widgets[$host]);
517
  } else {
518
  $_wp_sidebars_widgets[$host] = $_wp_sidebars_widgets[$id];
519
  $handled_already[$host] = 1;
520
+ }
521
  }
522
  }
523
 
524
  /**
 
525
  * Show manually handled content aware sidebars
 
526
  * @global array $_wp_sidebars_widgets
527
+ * @param string|array $args
528
+ * @return void
529
  */
530
  public function manual_sidebar($args) {
531
  global $_wp_sidebars_widgets;
532
+
533
  // Grab args or defaults
534
+ $args = wp_parse_args($args, array(
535
+ 'include' => '',
536
+ 'before' => '<div id="sidebar" class="widget-area"><ul class="xoxo">',
537
+ 'after' => '</ul></div>'
538
  ));
539
+ extract($args, EXTR_SKIP);
540
 
541
  // Get sidebars
542
  $posts = $this->get_sidebars();
543
+ if (!$posts)
544
  return;
545
 
546
  // Handle include argument
547
+ if (!empty($include)) {
548
+ if (!is_array($include))
549
+ $include = explode(',', $include);
550
  // Fast lookup
551
  $include = array_flip($include);
552
  }
553
 
554
+ $i = $host = 0;
555
+ foreach ($posts as $post) {
556
 
557
+ $id = 'ca-sidebar-' . $post->ID;
558
 
559
  // Check for manual handling, if sidebar exists and if id should be included
560
  if ($post->handle != 2 || !isset($_wp_sidebars_widgets[$id]) || (!empty($include) && !isset($include[$post->ID])))
561
  continue;
562
 
563
  // Merge if more than one. First one is host.
564
+ if ($i > 0) {
565
+ if (get_post_meta($post->ID, self::PREFIX . 'merge-pos', true))
566
+ $_wp_sidebars_widgets[$host] = array_merge($_wp_sidebars_widgets[$host], $_wp_sidebars_widgets[$id]);
567
  else
568
+ $_wp_sidebars_widgets[$host] = array_merge($_wp_sidebars_widgets[$id], $_wp_sidebars_widgets[$host]);
569
  } else {
570
  $host = $id;
571
  }
578
  echo $after;
579
  }
580
  }
581
+
582
  /**
 
583
  * Query sidebars according to content
 
584
  * @global type $wpdb
585
  * @return array|boolean
586
  */
624
  FROM $wpdb->posts posts
625
  LEFT JOIN $wpdb->postmeta handle
626
  ON handle.post_id = posts.ID
627
+ AND handle.meta_key = '".self::PREFIX."handle'
628
  LEFT JOIN $wpdb->postmeta exposure
629
  ON exposure.post_id = posts.ID
630
+ AND exposure.meta_key = '".self::PREFIX."exposure'
631
  ".implode(' ',$joins)."
632
  WHERE
633
+ posts.post_type = '".self::TYPE_SIDEBAR."' AND
634
  exposure.meta_value ".(is_archive() || is_home() ? '>' : '<')."= '1' AND
635
  posts.post_status ".(current_user_can('read_private_posts') ? "IN('publish','private')" : "= 'publish'")." AND
636
  (".implode(' AND ',$where).($where2 ? ' AND ('.implode(' OR ',$where2).')' : '').")
642
  return (empty($this->sidebar_cache) ? $this->sidebar_cache[0] = false : $this->sidebar_cache);
643
 
644
  }
645
+
646
+ /**
647
+ * Remove unwanted meta boxes
648
+ * @return void
649
+ */
650
+ public function clear_admin_menu() {
651
+ global $wp_meta_boxes;
652
+
653
+ $screen = get_current_screen();
654
+
655
+ // Post type not set on all pages in WP3.1
656
+ if(!(isset($screen->post_type) && $screen->post_type == self::TYPE_SIDEBAR && $screen->base == 'post'))
657
+ return;
658
+
659
+ // Names of whitelisted meta boxes
660
+ $whitelist = array(
661
+ 'cas-spread-words' => 'cas-spread-words',
662
+ 'cas-rules' => 'cas-rules',
663
+ 'cas-options' => 'cas-options',
664
+ 'submitdiv' => 'submitdiv',
665
+ 'pageparentdiv' => 'pageparentdiv',
666
+ 'slugdiv' => 'slugdiv'
667
+ );
668
+
669
+ // Loop through context (normal,advanced,side)
670
+ foreach($wp_meta_boxes[self::TYPE_SIDEBAR] as $context_k => $context_v) {
671
+ // Loop through priority (high,core,default,low)
672
+ foreach($context_v as $priority_k => $priority_v) {
673
+ // Loop through boxes
674
+ foreach($priority_v as $box_k => $box_v) {
675
+ // If box is not whitelisted, remove it
676
+ if(!in_array($box_k,$whitelist)) {
677
+ $wp_meta_boxes[self::TYPE_SIDEBAR][$context_k][$priority_k][$box_k] = false;
678
+ //unset($whitelist[$box_k]);
679
+ }
680
+ }
681
+ }
682
+ }
683
+ }
684
+
685
  /**
 
686
  * Meta boxes for sidebar edit
687
+ * @global object $post
688
+ * @return void
689
  */
690
  public function create_meta_boxes() {
691
 
692
+ // Remove ability to set self to host
693
+ if(get_the_ID())
694
+ unset($this->metadata['host']['list']['ca-sidebar-'.get_the_ID()]);
695
 
696
+ $boxes = array(
697
+ //Content
698
+ array(
699
+ 'id' => 'cas-rules',
700
+ 'title' => __('Content', self::DOMAIN),
701
+ 'callback' => 'meta_box_rules',
702
+ 'context' => 'normal',
703
+ 'priority' => 'high'
704
+ ),
705
+ //Add group
706
+ // array(
707
+ // 'id' => 'cas-new-group',
708
+ // 'title' => __('Rule Group', self::DOMAIN),
709
+ // 'callback' => 'meta_box_rules',
710
+ // 'context' => 'normal',
711
+ // 'priority' => 'high'
712
+ // )
713
+ //Options
714
+ array(
715
+ 'id' => 'cas-options',
716
+ 'title' => __('Options', self::DOMAIN),
717
+ 'callback' => 'meta_box_options',
718
+ 'context' => 'side',
719
+ 'priority' => 'default'
720
+ ),
721
+ //About
722
+ array(
723
+ 'id' => 'cas-spread-words',
724
+ 'title' => __('Spread the Word', self::DOMAIN),
725
+ 'callback' => 'meta_box_author_words',
726
+ 'context' => 'side',
727
+ 'priority' => 'high'
728
+ )
729
  );
730
+
731
+ //Add meta boxes
732
+ foreach($boxes as $box) {
733
+ add_meta_box(
734
+ $box['id'],
735
+ $box['title'],
736
+ array(&$this, $box['callback']),
737
+ self::TYPE_SIDEBAR,
738
+ $box['context'],
739
+ $box['priority']
740
+ );
741
+ }
742
+
743
  }
744
 
 
745
  /**
 
746
  * Hide some meta boxes from start
747
+ * @param array $hidden
748
+ * @param object $screen
 
749
  * @return array
750
  */
751
+ public function change_default_hidden($hidden, $screen) {
752
 
753
  //WordPress 3.3 has changed get_hidden_meta_boxes().
754
+ if (get_bloginfo('version') < 3.3) {
755
+ $condition = $screen->base == self::TYPE_SIDEBAR;
756
  } else {
757
+ $condition = $screen->post_type == self::TYPE_SIDEBAR;
758
  }
759
+
760
+ if ($condition && get_user_option('metaboxhidden_sidebar') === false) {
761
+
762
+ $hidden_meta_boxes = array('pageparentdiv');
763
+ $hidden = array_merge($hidden, $hidden_meta_boxes);
764
+
765
  $user = wp_get_current_user();
766
+ update_user_option($user->ID, 'metaboxhidden_sidebar', $hidden, true);
 
767
  }
768
  return $hidden;
769
  }
770
+
771
+ public function meta_box_new_group() {
772
+ echo '<input type="submit" value="Add new Rule Group"/>';
773
+ }
774
 
775
+ /**
776
+ * Meta box for content rules
777
+ * @return void
778
+ */
779
  public function meta_box_rules() {
780
+
 
 
 
 
 
 
 
 
781
  echo '<div id="cas-accordion">'."\n";
782
+ do_action('cas-module-admin-box');
 
 
783
  echo '</div>'."\n";
784
 
785
  }
786
 
787
  /**
788
+ * Meta box for options
789
+ * @return void
 
790
  */
791
  public function meta_box_options() {
792
+
793
  $columns = array(
794
  'exposure',
795
  'handle' => 'handle,host',
796
  'merge-pos'
797
  );
798
+
799
+ foreach ($columns as $key => $value) {
800
+
801
+ echo '<span>' . $this->metadata[is_numeric($key) ? $value : $key]['name'] . ':';
802
  echo '<p>';
803
+ $values = explode(',', $value);
804
+ foreach ($values as $val) {
805
  $this->_form_field($val);
806
  }
807
  echo '</p></span>';
808
  }
809
  }
810
+
811
  /**
812
+ * Meta box for author words
813
+ * @return void
 
814
  */
815
  public function meta_box_author_words() {
816
+
817
  // Use nonce for verification
818
+ wp_nonce_field(basename(__FILE__), '_ca-sidebar-nonce');
819
+ ?>
820
+ <div style="overflow:hidden;">
821
+ <p><?php _e('If you love this plugin, please consider donating to support future development.', self::DOMAIN); ?></p>
822
+ <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"
823
+ target="_blank" title="PayPal - The safer, easier way to pay online!">
824
+ <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!">
825
+ </a></p>
826
+ <p><?php _e('Or you could:',self::DOMAIN); ?></p>
827
+ <ul>
828
+ <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>
829
+ <li><a href="http://wordpress.org/extend/plugins/content-aware-sidebars/" target="_blank"><?php _e('Link to the plugin page',self::DOMAIN); ?></a></li>
830
+ </ul>
831
+ <br />
832
+ <p>
833
+ <a href="https://twitter.com/intoxstudio" class="twitter-follow-button" data-show-count="false">Follow @intoxstudio</a>
834
+ <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>
835
+ <p>
836
+ <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>
837
+ </p>
838
+ </div>
839
  <?php
840
  }
841
+
842
  /**
 
843
  * Create form field for metadata
 
844
  * @global object $post
845
+ * @param array $setting
846
+ * @return void
847
  */
848
  private function _form_field($setting) {
849
+
850
+ $meta = get_post_meta(get_the_ID(), self::PREFIX . $setting, true);
 
851
  $setting = $this->metadata[$setting];
852
  $current = $meta != '' ? $meta : $setting['val'];
853
+ switch ($setting['type']) {
854
+ case 'select' :
855
+ echo '<select style="width:250px;" name="' . $setting['id'] . '">' . "\n";
856
+ foreach ($setting['list'] as $key => $value) {
857
+ echo '<option value="' . $key . '"' . selected($current,$key,false) . '>' . $value . '</option>' . "\n";
858
  }
859
+ echo '</select>' . "\n";
860
  break;
861
  case 'checkbox' :
862
+ echo '<ul>' . "\n";
863
+ foreach ($setting['list'] as $key => $value) {
864
+ echo '<li><label><input type="checkbox" name="' . $setting['id'] . '[]" value="' . $key . '"' . (in_array($key, $current) ? ' checked="checked"' : '') . ' /> ' . $value . '</label></li>' . "\n";
865
  }
866
+ echo '</ul>' . "\n";
867
  break;
868
  case 'text' :
869
  default :
870
+ echo '<input style="width:200px;" type="text" name="' . $setting['id'] . '" value="' . $current . '" />' . "\n";
871
  break;
872
  }
873
  }
874
+
875
  /**
 
876
  * Save meta values for post
877
+ * @param int $post_id
 
878
  * @return void
879
  */
880
  public function save_post($post_id) {
881
+
882
  // Save button pressed
883
+ if (!isset($_POST['original_publish']) && !isset($_POST['save_post']))
884
  return;
885
+
886
  // Only sidebar type
887
+ if (get_post_type($post_id) != self::TYPE_SIDEBAR)
888
+ return;
889
+
890
  // Verify nonce
891
+ if (!check_admin_referer(basename(__FILE__), '_ca-sidebar-nonce'))
892
  return;
893
+
894
  // Check permissions
895
  if (!current_user_can('edit_theme_options', $post_id))
896
  return;
897
+
898
  // Check autosave
899
  if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
900
  return;
901
+
902
  // Load metadata
903
  $this->_init_metadata();
904
+
905
  // Update metadata
906
+ foreach ($this->metadata as $field) {
907
  $new = isset($_POST[$field['id']]) ? $_POST[$field['id']] : '';
908
+ $old = get_post_meta($post_id, self::PREFIX . $field['id'], true);
909
+
910
+ if ($new != '' && $new != $old) {
911
+ update_post_meta($post_id, self::PREFIX . $field['id'], $new);
912
  } elseif ($new == '' && $old != '') {
913
+ delete_post_meta($post_id, self::PREFIX . $field['id'], $old);
914
  }
915
  }
916
  // Update module data
917
+ do_action('cas-module-save-data',$post_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
 
969
  // Launch plugin
971
  $ca_sidebars = new ContentAwareSidebars();
972
 
973
  /**
974
+ * Template wrapper to display content aware sidebars
 
 
975
  * @global object $ca_sidebars
976
+ * @param array|string $args
977
+ * @return void
978
  */
979
  function display_ca_sidebar($args = array()) {
980
  global $ca_sidebars;
css/style.css CHANGED
@@ -17,21 +17,25 @@
17
  padding:0;
18
  }
19
 
20
- #cas-accordion > h4 {
21
  border-width:1px 0 !important;
22
  border-style:solid;
23
- border-color:#f9f9f9 #f9f9f9 #dfdfdf !important;
24
  margin:0;
25
- background-color:#ececec;
26
  display:block;
27
  outline: none;
28
  }
29
 
30
- #cas-accordion > h4:hover {
 
 
 
 
 
 
31
  background-color:#e4e4e4 !important;
32
  }
33
 
34
- #cas-accordion > h4 a {
35
  display:block;
36
  height:30px;
37
  line-height:30px;
@@ -39,38 +43,31 @@
39
  text-decoration: none;
40
  }
41
 
42
- .cas-rule-content {
43
- border-width:1px 0 !important;
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 {
51
- border-width:1px 0 0 !important;
52
- }
53
-
54
- #cas-accordion .ui-state-default.ui-state-active, #cas-accordion .ui-state-active {
55
- border-width:1px 0 !important;
56
  background-color:#dfdfdf;
57
  border-color:#c0c0c0 #fff #cfcfcf !important;
58
  box-shadow:inset 0 2px 1px 0 #cfcfcf;
59
  }
60
 
61
- #cas-accordion .tabs, #cas-accordion .tabs-panel {
62
- background-color:#fff;
63
- border-width:1px;
64
  border-style:solid;
65
- border-color:#ccc;
 
 
66
  }
67
 
68
- #cas-accordion .tabs {
69
- border-color:#ccc #ccc #fff;
 
70
  }
71
 
72
  .cas-tick {
73
  background-image:url('../img/tick.png'); /* Icon by fatcow.com */
74
  background-repeat: no-repeat;
75
  background-position: 8px center;
76
- }
 
 
 
 
17
  padding:0;
18
  }
19
 
20
+ #cas-accordion .ui-accordion-header {
21
  border-width:1px 0 !important;
22
  border-style:solid;
 
23
  margin:0;
 
24
  display:block;
25
  outline: none;
26
  }
27
 
28
+ #cas-accordion .ui-accordion-header.ui-state-default {
29
+ border-color:#f9f9f9 #f9f9f9 #dfdfdf !important;
30
+ background-color:#ececec;
31
+ }
32
+
33
+ #cas-accordion .ui-accordion-header:hover,
34
+ #cas-accordion .ui-accordion-header.ui-state-hover {
35
  background-color:#e4e4e4 !important;
36
  }
37
 
38
+ #cas-accordion .ui-accordion-header a {
39
  display:block;
40
  height:30px;
41
  line-height:30px;
43
  text-decoration: none;
44
  }
45
 
46
+ #cas-accordion .ui-accordion-header.ui-state-active {
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  background-color:#dfdfdf;
48
  border-color:#c0c0c0 #fff #cfcfcf !important;
49
  box-shadow:inset 0 2px 1px 0 #cfcfcf;
50
  }
51
 
52
+ #cas-accordion .ui-accordion-content {
53
+ border-width:1px 0 !important;
 
54
  border-style:solid;
55
+ border-color:#eee #eee #cfcfcf !important;
56
+ padding:10px !important;
57
+ background-color:#dfdfdf !important;
58
  }
59
 
60
+ #cas-accordion .ui-accordion-header.ui-state-default:last-of-type,
61
+ #cas-accordion .ui-accordion-content:last-child {
62
+ border-width:1px 0 0 !important;
63
  }
64
 
65
  .cas-tick {
66
  background-image:url('../img/tick.png'); /* Icon by fatcow.com */
67
  background-repeat: no-repeat;
68
  background-position: 8px center;
69
+ }
70
+
71
+ .cas-contentlist .children li {
72
+ padding-left:20px;
73
+ }
index.php CHANGED
@@ -1 +1,2 @@
1
  <?php
 
1
  <?php
2
+ /**/
js/cas_admin.js CHANGED
@@ -3,89 +3,110 @@
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(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(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 data is found
86
+ if(ui.item != null) {
87
+ // Check if element already exists
88
+ if($("#"+ui.item.elem).length == 0) {
89
+
90
+ 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></li>').change( function() {
91
+ var parent = $(this).parents('.cas-rule-content');
92
+ api.toggleTick(parent);
93
+ });
94
+
95
+ //Add element and clean up
96
+ $("#cas-list-"+ui.item.id2).prepend(elem);
97
+ elem.change(); // fire change event
98
+
99
+ } else {
100
+ //Move to top and check it
101
+ $("#"+ui.item.elem).prependTo("#cas-list-"+ui.item.id2).find('input').attr("checked", true).change();
102
+ }
103
+
104
+ $( "input#cas-autocomplete-"+ui.item.id2 ).val('');
105
+ e.preventDefault(); //clear field properly
106
+ }
107
  }
108
  }
109
+
110
+ $(document).ready(function(){ api.init(); });
111
+
112
+ })(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,136 @@ 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 +284,30 @@ 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.2\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/content-aware-sidebars\n"
7
+ "POT-Creation-Date: 2013-05-14 13:07:12+00:00\n"
8
+ "PO-Revision-Date: 2013-05-14 15:10+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:689
 
 
 
 
165
  msgid "Content"
166
  msgstr "Indhold"
167
 
168
+ #: content-aware-sidebars.php:699
169
  msgid "Options"
170
  msgstr "Indstillinger"
171
 
172
+ #: content-aware-sidebars.php:708
173
+ msgid "Spread the Word"
174
+ msgstr "Spred ordet"
175
 
176
+ #: content-aware-sidebars.php:798
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:803
185
+ msgid "Or you could:"
186
+ msgstr "Eller du kunne:"
187
 
188
+ #: content-aware-sidebars.php:805
189
+ msgid "Rate the plugin on WordPress.org"
190
+ msgstr "Bedømme pluginnet WordPress.org"
191
 
192
+ #: content-aware-sidebars.php:806
193
+ msgid "Link to the plugin page"
194
+ msgstr "Linke til plugin-siden"
195
+
196
+ #: modules/abstract.php:57 modules/post_type.php:110
197
  msgid "Show with All %s"
198
  msgstr "Vis ved alle %s"
199
 
200
+ #: modules/abstract.php:61 modules/post_type.php:134 modules/taxonomy.php:175
201
+ msgctxt "verb"
202
+ msgid "Search"
203
+ msgstr "Søg"
204
+
205
+ #: modules/abstract.php:61 modules/post_type.php:134 modules/taxonomy.php:175
206
+ #: modules/url.php:42
207
+ msgid "Add"
208
+ msgstr "Tilføj"
209
 
210
+ #: modules/author.php:24
211
  msgid "Authors"
212
  msgstr "Forfattere"
213
 
214
+ #: modules/bbpress.php:23
215
  msgid "bbPress User Profiles"
216
  msgstr "bbPress brugerprofiler"
217
 
218
+ #: modules/bp_member.php:23
219
  msgid "BuddyPress Members"
220
  msgstr "BuddyPress medlemmer"
221
 
222
+ #: modules/page_template.php:24
223
  msgid "Page Templates"
224
  msgstr "Skabeloner"
225
 
226
+ #: modules/polylang.php:23 modules/qtranslate.php:23 modules/transposh.php:23
227
+ #: modules/wpml.php:23
228
  msgid "Languages"
229
  msgstr "Sprog"
230
 
231
+ #: modules/post_type.php:30
232
  msgid "Post Types"
233
  msgstr "Indholdstyper"
234
 
235
+ #: modules/post_type.php:104 modules/taxonomy.php:151
236
  msgid "Automatically select new children of a selected ancestor"
237
  msgstr "Vælg automatisk nye børn af den valgte forælder"
238
 
239
+ #: modules/post_type.php:114 modules/taxonomy.php:159
240
  msgid "No items."
241
  msgstr "Ingen elementer."
242
 
243
+ #: modules/static.php:25
244
  msgid "Static Pages"
245
  msgstr "Statiske sider"
246
 
247
+ #: modules/static.php:34
248
  msgid "Front Page"
249
  msgstr "Forside"
250
 
251
+ #: modules/static.php:35
252
  msgid "Search Results"
253
  msgstr "Søgeresultater"
254
 
255
+ #: modules/static.php:36
256
  msgid "404 Page"
257
  msgstr "404-side"
258
 
259
+ #: modules/taxonomy.php:36
260
  msgid "Taxonomies"
261
  msgstr "Taksonomier"
262
 
263
+ #: modules/taxonomy.php:155
264
  msgid "Show with %s"
265
  msgstr "Vis ved %s"
266
 
267
+ #: modules/url.php:24
268
+ msgid "URLs"
269
+ msgstr "URLs"
270
 
271
  #. Plugin Name of the plugin/theme
272
  msgid "Content Aware Sidebars"
273
  msgstr "Content Aware Sidebars"
274
 
275
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.3.1) #-#-#-#-#
276
  #. Plugin URI of the plugin/theme
277
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.3.1) #-#-#-#-#
278
  #. Author URI of the plugin/theme
279
  msgid "http://www.intox.dk/"
280
  msgstr "http://www.intox.dk/"
284
  msgstr "Administrer og vis sidebars i henhold til det indhold, der vises."
285
 
286
  #. Author of the plugin/theme
287
+ msgid "Joachim Jensen, Intox Studio"
288
+ msgstr "Joachim Jensen, Intox Studio"
289
+
290
+ #~ msgid "View All"
291
+ #~ msgstr "Vis alle"
292
+
293
+ #~ msgid "Most Used"
294
+ #~ msgstr "Mest brugte"
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-it_IT.mo CHANGED
Binary file
lang/content-aware-sidebars-it_IT.po CHANGED
@@ -4,8 +4,8 @@ msgid ""
4
  msgstr ""
5
  "Project-Id-Version: Content Aware Sidebars\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-10 14:21+0100\n"
9
  "Last-Translator: Luciano Del Fico <info@myweb2.it>\n"
10
  "Language-Team: MyWeb2 <info@myweb2.it>\n"
11
  "Language: it_IT\n"
@@ -13,132 +13,132 @@ msgstr ""
13
  "Content-Type: text/plain; charset=UTF-8\n"
14
  "Content-Transfer-Encoding: 8bit\n"
15
  "X-Poedit-SourceCharset: UTF-8\n"
16
- "X-Generator: Poedit 1.5.4\n"
17
 
18
- #: content-aware-sidebars.php:150 content-aware-sidebars.php:327
19
  msgid "Exposure"
20
  msgstr "Tipologia"
21
 
22
- #: content-aware-sidebars.php:156
23
  msgid "Singular"
24
  msgstr "Singola"
25
 
26
- #: content-aware-sidebars.php:157
27
  msgid "Singular & Archive"
28
  msgstr "Singola e archivio"
29
 
30
- #: content-aware-sidebars.php:158
31
  msgid "Archive"
32
  msgstr "Archivio"
33
 
34
- #: content-aware-sidebars.php:162 content-aware-sidebars.php:328
35
  msgctxt "option"
36
  msgid "Handle"
37
  msgstr "Comportamento"
38
 
39
- #: content-aware-sidebars.php:164
40
  msgid "Replace host sidebar, merge with it or add sidebar manually."
41
  msgstr ""
42
  "Sostituisce sidebar, si fonde con essa o aggiunge la sidebar manualmente."
43
 
44
- #: content-aware-sidebars.php:168
45
  msgid "Replace"
46
  msgstr "Sostituzione"
47
 
48
- #: content-aware-sidebars.php:169
49
  msgid "Merge"
50
  msgstr "Unione"
51
 
52
- #: content-aware-sidebars.php:170
53
  msgid "Manual"
54
  msgstr "Manuale"
55
 
56
- #: content-aware-sidebars.php:174
57
  msgid "Host Sidebar"
58
  msgstr "Sidebar"
59
 
60
- #: content-aware-sidebars.php:182 content-aware-sidebars.php:329
61
  msgid "Merge position"
62
  msgstr "Posizione"
63
 
64
- #: content-aware-sidebars.php:184
65
  msgid "Place sidebar on top or bottom of host when merging."
66
  msgstr "Posizione sidebar in alto o in basso dell'host durante la fusione."
67
 
68
- #: content-aware-sidebars.php:188
69
  msgid "Top"
70
  msgstr "Alto"
71
 
72
- #: content-aware-sidebars.php:189
73
  msgid "Bottom"
74
  msgstr "Basso"
75
 
76
- #: content-aware-sidebars.php:210
77
  msgid "Sidebars"
78
  msgstr "Sidebars"
79
 
80
- #: content-aware-sidebars.php:211
81
  msgid "Sidebar"
82
  msgstr "Sidebar"
83
 
84
- #: content-aware-sidebars.php:212
85
  msgctxt "sidebar"
86
  msgid "Add New"
87
  msgstr "Aggiungi"
88
 
89
- #: content-aware-sidebars.php:213
90
  msgid "Add New Sidebar"
91
  msgstr "Aggiungi Nuova Sidebar"
92
 
93
- #: content-aware-sidebars.php:214
94
  msgid "Edit Sidebar"
95
  msgstr "Modifica Sidebar"
96
 
97
- #: content-aware-sidebars.php:215
98
  msgid "New Sidebar"
99
  msgstr "Nuova Sidebar"
100
 
101
- #: content-aware-sidebars.php:216
102
  msgid "All Sidebars"
103
  msgstr "Tutte le Sidebars"
104
 
105
- #: content-aware-sidebars.php:217
106
  msgid "View Sidebar"
107
  msgstr "Vedi Sidebar"
108
 
109
- #: content-aware-sidebars.php:218
110
  msgid "Search Sidebars"
111
  msgstr "Cerca Sidebars"
112
 
113
- #: content-aware-sidebars.php:219
114
  msgid "No sidebars found"
115
  msgstr "Nessuna sidebar trovata"
116
 
117
- #: content-aware-sidebars.php:220
118
  msgid "No sidebars found in Trash"
119
  msgstr "nessuna sidebar cancellata"
120
 
121
- #: content-aware-sidebars.php:253
122
  msgid "Sidebar updated. <a href=\"%s\">Manage widgets</a>"
123
  msgstr "Sidebar aggiornata. <a href=\"%s\">Gestione widgets</a>"
124
 
125
- #: content-aware-sidebars.php:256
126
  msgid "Sidebar updated."
127
  msgstr "Sidebar aggiornata."
128
 
129
- #: content-aware-sidebars.php:258
130
  msgid "Sidebar published. <a href=\"%s\">Manage widgets</a>"
131
  msgstr "Sidebar publicata. <a href=\"%s\">Gestione widgets</a>"
132
 
133
- #: content-aware-sidebars.php:259
134
  msgid "Sidebar saved."
135
  msgstr "Sidebar salvata."
136
 
137
- #: content-aware-sidebars.php:260
138
  msgid "Sidebar submitted. <a href=\"%s\">Manage widgets</a>"
139
  msgstr "Sidebar inviata. <a href=\"%s\">Gestione widgets</a>"
140
 
141
- #: content-aware-sidebars.php:261
142
  msgid ""
143
  "Sidebar scheduled for: <strong>%1$s</strong>. <a href=\"%2$s\">Manage "
144
  "widgets</a>"
@@ -147,130 +147,134 @@ msgstr ""
147
  "widgets</a>"
148
 
149
  #. translators: Publish box date format, see http:php.net/date
150
- #: content-aware-sidebars.php:263
151
  msgid "M j, Y @ G:i"
152
  msgstr "M j, Y @ G:i"
153
 
154
- #: content-aware-sidebars.php:264
155
  msgid "Sidebar draft updated."
156
  msgstr "Bozza sidebar aggiornata. "
157
 
158
- #: content-aware-sidebars.php:391
159
  msgid "Please update Host Sidebar"
160
  msgstr "Aggiorna Sidebar"
161
 
162
- #: content-aware-sidebars.php:454
163
  msgid "Manage Widgets"
164
  msgstr "Gestione Widgets"
165
 
166
- #: content-aware-sidebars.php:651
167
- msgid "Words from the author"
168
- msgstr "Parole dell'autore"
169
-
170
- #: content-aware-sidebars.php:661
171
  msgid "Content"
172
  msgstr "Contenuto"
173
 
174
- #: content-aware-sidebars.php:671
175
  msgid "Options"
176
  msgstr "Opzioni"
177
 
178
- #: content-aware-sidebars.php:766
179
- msgid "If you love this plugin, please consider donating."
180
- msgstr "Se ti piace questo plugin, considera l'eventualità fare una donazione."
181
 
182
- #: content-aware-sidebars.php:768
183
  msgid ""
184
- "Remember to <a class=\"button\" href=\"%1$s\" target=\"_blank\">rate</a> and "
185
- "<a class=\"button\" href=\"%2$s\" target=\"_blank\">share</a> it too!"
186
- msgstr ""
187
- "Ricorda di <a class=\"button\" href=\"%1$s\" target=\"_blank\">valutarlo</"
188
- "a> e <a class=\"button\" href=\"%2$s\" target=\"_blank\">condiverlo</a>!"
 
 
189
 
190
- #: content-aware-sidebars.php:770
191
- msgid "Check out Content Aware Sidebars for %23WordPress! :)"
192
- msgstr "Verifica Content Aware Sidebars per %23WordPress! :)"
193
 
194
- #: content-aware-sidebars.php:772
195
- msgid "Check out Content Aware Sidebars :)"
196
- msgstr "Verifica Content Aware Sidebars per WordPress! :)"
197
 
198
- #: modules/abstract.php:39 modules/post_type.php:78
199
  msgid "Show with All %s"
200
  msgstr "Seleziona tutto: %s"
201
 
202
- #: modules/abstract.php:43 modules/post_type.php:88 modules/taxonomy.php:121
203
- msgid "View All"
204
- msgstr "Vedi tutti"
 
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 "Profilo utente bbPress"
213
 
214
- #: modules/bp_member.php:20
215
  msgid "BuddyPress Members"
216
  msgstr "Utenti BuddyPress"
217
 
218
- #: modules/page_template.php:21
219
  msgid "Page Templates"
220
  msgstr "Template Pagine"
221
 
222
- #: modules/polylang.php:20 modules/qtranslate.php:20 modules/transposh.php:20
223
- #: modules/wpml.php:20
224
  msgid "Languages"
225
  msgstr "Lingue"
226
 
227
- #: modules/post_type.php:23
228
  msgid "Post Types"
229
  msgstr "Tipi di messaggi"
230
 
231
- #: modules/post_type.php:73 modules/taxonomy.php:107
232
  msgid "Automatically select new children of a selected ancestor"
233
  msgstr "Seleziona automaticamente nuovi figli di un percorso selezionato"
234
 
235
- #: modules/post_type.php:82 modules/taxonomy.php:115
236
  msgid "No items."
237
  msgstr "Nessun oggetto."
238
 
239
- #: modules/static.php:22
240
  msgid "Static Pages"
241
  msgstr "Pagine statiche"
242
 
243
- #: modules/static.php:27
244
  msgid "Front Page"
245
  msgstr "Pagina principale"
246
 
247
- #: modules/static.php:28
248
  msgid "Search Results"
249
  msgstr "Risultati di ricerca"
250
 
251
- #: modules/static.php:29
252
  msgid "404 Page"
253
  msgstr "Pagina 404"
254
 
255
- #: modules/taxonomy.php:24
256
  msgid "Taxonomies"
257
  msgstr "Tassonomie"
258
 
259
- #: modules/taxonomy.php:111
260
  msgid "Show with %s"
261
  msgstr "Mostra %s"
262
 
263
- #: modules/taxonomy.php:120
264
- msgid "Most Used"
265
- msgstr "Più usati"
266
 
267
  #. Plugin Name of the plugin/theme
268
  msgid "Content Aware Sidebars"
269
  msgstr "Content Aware 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/"
@@ -280,8 +284,31 @@ msgid "Manage and show sidebars according to the content being viewed."
280
  msgstr "Gestisce e mostra sidebars a seconda del contenuto visualizzato."
281
 
282
  #. Author of the plugin/theme
283
- msgid "Joachim Jensen"
284
- msgstr "Joachim Jensen"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
 
286
  #~ msgid "bbPress"
287
  #~ msgstr "bbPress"
4
  msgstr ""
5
  "Project-Id-Version: Content Aware Sidebars\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/content-aware-sidebars\n"
7
+ "POT-Creation-Date: 2013-05-14 13:07:12+00:00\n"
8
+ "PO-Revision-Date: 2013-05-14 15:13+0100\n"
9
  "Last-Translator: Luciano Del Fico <info@myweb2.it>\n"
10
  "Language-Team: MyWeb2 <info@myweb2.it>\n"
11
  "Language: it_IT\n"
13
  "Content-Type: text/plain; charset=UTF-8\n"
14
  "Content-Transfer-Encoding: 8bit\n"
15
  "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Generator: Poedit 1.5.5\n"
17
 
18
+ #: content-aware-sidebars.php:178 content-aware-sidebars.php:345
19
  msgid "Exposure"
20
  msgstr "Tipologia"
21
 
22
+ #: content-aware-sidebars.php:184
23
  msgid "Singular"
24
  msgstr "Singola"
25
 
26
+ #: content-aware-sidebars.php:185
27
  msgid "Singular & Archive"
28
  msgstr "Singola e archivio"
29
 
30
+ #: content-aware-sidebars.php:186
31
  msgid "Archive"
32
  msgstr "Archivio"
33
 
34
+ #: content-aware-sidebars.php:190 content-aware-sidebars.php:346
35
  msgctxt "option"
36
  msgid "Handle"
37
  msgstr "Comportamento"
38
 
39
+ #: content-aware-sidebars.php:192
40
  msgid "Replace host sidebar, merge with it or add sidebar manually."
41
  msgstr ""
42
  "Sostituisce sidebar, si fonde con essa o aggiunge la sidebar manualmente."
43
 
44
+ #: content-aware-sidebars.php:196
45
  msgid "Replace"
46
  msgstr "Sostituzione"
47
 
48
+ #: content-aware-sidebars.php:197
49
  msgid "Merge"
50
  msgstr "Unione"
51
 
52
+ #: content-aware-sidebars.php:198
53
  msgid "Manual"
54
  msgstr "Manuale"
55
 
56
+ #: content-aware-sidebars.php:202
57
  msgid "Host Sidebar"
58
  msgstr "Sidebar"
59
 
60
+ #: content-aware-sidebars.php:210 content-aware-sidebars.php:347
61
  msgid "Merge position"
62
  msgstr "Posizione"
63
 
64
+ #: content-aware-sidebars.php:212
65
  msgid "Place sidebar on top or bottom of host when merging."
66
  msgstr "Posizione sidebar in alto o in basso dell'host durante la fusione."
67
 
68
+ #: content-aware-sidebars.php:216
69
  msgid "Top"
70
  msgstr "Alto"
71
 
72
+ #: content-aware-sidebars.php:217
73
  msgid "Bottom"
74
  msgstr "Basso"
75
 
76
+ #: content-aware-sidebars.php:232
77
  msgid "Sidebars"
78
  msgstr "Sidebars"
79
 
80
+ #: content-aware-sidebars.php:233
81
  msgid "Sidebar"
82
  msgstr "Sidebar"
83
 
84
+ #: content-aware-sidebars.php:234
85
  msgctxt "sidebar"
86
  msgid "Add New"
87
  msgstr "Aggiungi"
88
 
89
+ #: content-aware-sidebars.php:235
90
  msgid "Add New Sidebar"
91
  msgstr "Aggiungi Nuova Sidebar"
92
 
93
+ #: content-aware-sidebars.php:236
94
  msgid "Edit Sidebar"
95
  msgstr "Modifica Sidebar"
96
 
97
+ #: content-aware-sidebars.php:237
98
  msgid "New Sidebar"
99
  msgstr "Nuova Sidebar"
100
 
101
+ #: content-aware-sidebars.php:238
102
  msgid "All Sidebars"
103
  msgstr "Tutte le Sidebars"
104
 
105
+ #: content-aware-sidebars.php:239
106
  msgid "View Sidebar"
107
  msgstr "Vedi Sidebar"
108
 
109
+ #: content-aware-sidebars.php:240
110
  msgid "Search Sidebars"
111
  msgstr "Cerca Sidebars"
112
 
113
+ #: content-aware-sidebars.php:241
114
  msgid "No sidebars found"
115
  msgstr "Nessuna sidebar trovata"
116
 
117
+ #: content-aware-sidebars.php:242
118
  msgid "No sidebars found in Trash"
119
  msgstr "nessuna sidebar cancellata"
120
 
121
+ #: content-aware-sidebars.php:273
122
  msgid "Sidebar updated. <a href=\"%s\">Manage widgets</a>"
123
  msgstr "Sidebar aggiornata. <a href=\"%s\">Gestione widgets</a>"
124
 
125
+ #: content-aware-sidebars.php:276
126
  msgid "Sidebar updated."
127
  msgstr "Sidebar aggiornata."
128
 
129
+ #: content-aware-sidebars.php:278
130
  msgid "Sidebar published. <a href=\"%s\">Manage widgets</a>"
131
  msgstr "Sidebar publicata. <a href=\"%s\">Gestione widgets</a>"
132
 
133
+ #: content-aware-sidebars.php:279
134
  msgid "Sidebar saved."
135
  msgstr "Sidebar salvata."
136
 
137
+ #: content-aware-sidebars.php:280
138
  msgid "Sidebar submitted. <a href=\"%s\">Manage widgets</a>"
139
  msgstr "Sidebar inviata. <a href=\"%s\">Gestione widgets</a>"
140
 
141
+ #: content-aware-sidebars.php:281
142
  msgid ""
143
  "Sidebar scheduled for: <strong>%1$s</strong>. <a href=\"%2$s\">Manage "
144
  "widgets</a>"
147
  "widgets</a>"
148
 
149
  #. translators: Publish box date format, see http:php.net/date
150
+ #: content-aware-sidebars.php:283
151
  msgid "M j, Y @ G:i"
152
  msgstr "M j, Y @ G:i"
153
 
154
+ #: content-aware-sidebars.php:284
155
  msgid "Sidebar draft updated."
156
  msgstr "Bozza sidebar aggiornata. "
157
 
158
+ #: content-aware-sidebars.php:321 content-aware-sidebars.php:402
159
  msgid "Please update Host Sidebar"
160
  msgstr "Aggiorna Sidebar"
161
 
162
+ #: content-aware-sidebars.php:457
163
  msgid "Manage Widgets"
164
  msgstr "Gestione Widgets"
165
 
166
+ #: content-aware-sidebars.php:689
 
 
 
 
167
  msgid "Content"
168
  msgstr "Contenuto"
169
 
170
+ #: content-aware-sidebars.php:699
171
  msgid "Options"
172
  msgstr "Opzioni"
173
 
174
+ #: content-aware-sidebars.php:708
175
+ msgid "Spread the Word"
176
+ msgstr "Spargi la voce"
177
 
178
+ #: content-aware-sidebars.php:798
179
  msgid ""
180
+ "If you love this plugin, please consider donating to support future "
181
+ "development."
182
+ msgstr "Se ti piace questo plugin, considera l'eventualità fare una donazione."
183
+
184
+ #: content-aware-sidebars.php:803
185
+ msgid "Or you could:"
186
+ msgstr "Oppure potresti:"
187
 
188
+ #: content-aware-sidebars.php:805
189
+ msgid "Rate the plugin on WordPress.org"
190
+ msgstr "Valutare il plugin su WordPress.org"
191
 
192
+ #: content-aware-sidebars.php:806
193
+ msgid "Link to the plugin page"
194
+ msgstr "Link alla pagina del plugin"
195
 
196
+ #: modules/abstract.php:57 modules/post_type.php:110
197
  msgid "Show with All %s"
198
  msgstr "Seleziona tutto: %s"
199
 
200
+ #: modules/abstract.php:61 modules/post_type.php:134 modules/taxonomy.php:175
201
+ msgctxt "verb"
202
+ msgid "Search"
203
+ msgstr "Ricercare"
204
 
205
+ #: modules/abstract.php:61 modules/post_type.php:134 modules/taxonomy.php:175
206
+ #: modules/url.php:42
207
+ msgid "Add"
208
+ msgstr "Aggiungi"
209
+
210
+ #: modules/author.php:24
211
  msgid "Authors"
212
  msgstr "Autori"
213
 
214
+ #: modules/bbpress.php:23
215
  msgid "bbPress User Profiles"
216
  msgstr "Profilo utente bbPress"
217
 
218
+ #: modules/bp_member.php:23
219
  msgid "BuddyPress Members"
220
  msgstr "Utenti BuddyPress"
221
 
222
+ #: modules/page_template.php:24
223
  msgid "Page Templates"
224
  msgstr "Template Pagine"
225
 
226
+ #: modules/polylang.php:23 modules/qtranslate.php:23 modules/transposh.php:23
227
+ #: modules/wpml.php:23
228
  msgid "Languages"
229
  msgstr "Lingue"
230
 
231
+ #: modules/post_type.php:30
232
  msgid "Post Types"
233
  msgstr "Tipi di messaggi"
234
 
235
+ #: modules/post_type.php:104 modules/taxonomy.php:151
236
  msgid "Automatically select new children of a selected ancestor"
237
  msgstr "Seleziona automaticamente nuovi figli di un percorso selezionato"
238
 
239
+ #: modules/post_type.php:114 modules/taxonomy.php:159
240
  msgid "No items."
241
  msgstr "Nessun oggetto."
242
 
243
+ #: modules/static.php:25
244
  msgid "Static Pages"
245
  msgstr "Pagine statiche"
246
 
247
+ #: modules/static.php:34
248
  msgid "Front Page"
249
  msgstr "Pagina principale"
250
 
251
+ #: modules/static.php:35
252
  msgid "Search Results"
253
  msgstr "Risultati di ricerca"
254
 
255
+ #: modules/static.php:36
256
  msgid "404 Page"
257
  msgstr "Pagina 404"
258
 
259
+ #: modules/taxonomy.php:36
260
  msgid "Taxonomies"
261
  msgstr "Tassonomie"
262
 
263
+ #: modules/taxonomy.php:155
264
  msgid "Show with %s"
265
  msgstr "Mostra %s"
266
 
267
+ #: modules/url.php:24
268
+ msgid "URLs"
269
+ msgstr "URL"
270
 
271
  #. Plugin Name of the plugin/theme
272
  msgid "Content Aware Sidebars"
273
  msgstr "Content Aware Sidebars"
274
 
275
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.3.1) #-#-#-#-#
276
  #. Plugin URI of the plugin/theme
277
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.3.1) #-#-#-#-#
278
  #. Author URI of the plugin/theme
279
  msgid "http://www.intox.dk/"
280
  msgstr "http://www.intox.dk/"
284
  msgstr "Gestisce e mostra sidebars a seconda del contenuto visualizzato."
285
 
286
  #. Author of the plugin/theme
287
+ msgid "Joachim Jensen, Intox Studio"
288
+ msgstr "Joachim Jensen, Intox Studio"
289
+
290
+ #~ msgid "View All"
291
+ #~ msgstr "Vedi tutti"
292
+
293
+ #~ msgid "Most Used"
294
+ #~ msgstr "Più usati"
295
+
296
+ #~ msgid "Words from the author"
297
+ #~ msgstr "Parole dell'autore"
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
+ #~ "Ricorda di <a class=\"button\" href=\"%1$s\" target=\"_blank"
304
+ #~ "\">valutarlo</a> e <a class=\"button\" href=\"%2$s\" target=\"_blank"
305
+ #~ "\">condiverlo</a>!"
306
+
307
+ #~ msgid "Check out Content Aware Sidebars for %23WordPress! :)"
308
+ #~ msgstr "Verifica Content Aware Sidebars per %23WordPress! :)"
309
+
310
+ #~ msgid "Check out Content Aware Sidebars :)"
311
+ #~ msgstr "Verifica Content Aware Sidebars per WordPress! :)"
312
 
313
  #~ msgid "bbPress"
314
  #~ 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-05-14 13:07:12+00:00\n"
8
+ "PO-Revision-Date: 2013-05-14 15:11+0100\n"
9
+ "Last-Translator: Joachim Jensen <jv@intox.dk>\n"
10
+ "Language-Team: Host1Free.com <info@host1free.com>\n"
11
+ "Language: Lithuanian\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 "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:689
168
+ msgid "Content"
169
+ msgstr "Turinys"
170
 
171
+ #: content-aware-sidebars.php:699
172
  msgid "Options"
173
  msgstr "Parinktys"
174
 
175
+ #: content-aware-sidebars.php:708
176
+ msgid "Spread the Word"
177
+ msgstr "Paskleiskite Žinią"
178
+
179
+ #: content-aware-sidebars.php:798
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:803
188
+ msgid "Or you could:"
189
+ msgstr "Arba galite:"
190
+
191
+ #: content-aware-sidebars.php:805
192
+ msgid "Rate the plugin on WordPress.org"
193
+ msgstr "Įvertinti papildinį WordPress.org svetainėje"
194
+
195
+ #: content-aware-sidebars.php:806
196
+ msgid "Link to the plugin page"
197
+ msgstr "Nukreipti į papildinio puslapį"
198
+
199
+ #: modules/abstract.php:57 modules/post_type.php:110
200
+ msgid "Show with All %s"
201
+ msgstr "Rodyti su Visais %s"
202
+
203
+ #: modules/abstract.php:61 modules/post_type.php:134 modules/taxonomy.php:175
204
+ msgctxt "verb"
205
+ msgid "Search"
206
+ msgstr "Ieškoti"
207
+
208
+ #: modules/abstract.php:61 modules/post_type.php:134 modules/taxonomy.php:175
209
+ #: modules/url.php:42
210
+ msgid "Add"
211
+ msgstr "Pridėti"
212
+
213
+ #: modules/author.php:24
214
+ msgid "Authors"
215
+ msgstr "Autorius"
216
+
217
+ #: modules/bbpress.php:23
218
+ msgid "bbPress User Profiles"
219
+ msgstr "bbPress Vartotojų Profilius"
220
+
221
+ #: modules/bp_member.php:23
222
+ msgid "BuddyPress Members"
223
+ msgstr "BuddyPress Narius"
224
+
225
+ #: modules/page_template.php:24
226
+ msgid "Page Templates"
227
+ msgstr "Puslapių Ruošinius"
228
+
229
+ #: modules/polylang.php:23 modules/qtranslate.php:23 modules/transposh.php:23
230
+ #: modules/wpml.php:23
231
+ msgid "Languages"
232
+ msgstr "Kalbas"
233
 
234
+ #: modules/post_type.php:30
235
+ msgid "Post Types"
236
+ msgstr "Įrašų Tipus"
237
 
238
+ #: modules/post_type.php:104 modules/taxonomy.php:151
239
+ msgid "Automatically select new children of a selected ancestor"
240
+ msgstr "Automatiškai pasirinkti naujus pažymėtų savininkų \"vaikus\"."
241
 
242
+ #: modules/post_type.php:114 modules/taxonomy.php:159
 
243
  msgid "No items."
244
+ msgstr "Jokių elementų. "
245
 
246
+ #: modules/static.php:25
247
+ msgid "Static Pages"
248
+ msgstr "Statiniai Puslapiai"
249
 
250
+ #: modules/static.php:34
251
+ msgid "Front Page"
252
+ msgstr "Titulinis Puslapis"
 
 
253
 
254
+ #: modules/static.php:35
255
+ msgid "Search Results"
256
+ msgstr "Paieškos Rezultatai"
257
+
258
+ #: modules/static.php:36
259
+ msgid "404 Page"
260
+ msgstr "404 Puslapis"
261
+
262
+ #: modules/taxonomy.php:36
263
+ msgid "Taxonomies"
264
+ msgstr "Taksonomijos"
265
+
266
+ #: modules/taxonomy.php:155
267
  msgid "Show with %s"
268
+ msgstr "Rodyti su %s"
269
 
270
+ #: modules/url.php:24
271
+ msgid "URLs"
272
+ msgstr "Universalieji Adresai"
273
 
274
  #. Plugin Name of the plugin/theme
275
  msgid "Content Aware Sidebars"
276
  msgstr "Content Aware Sidebars"
277
 
278
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.3.1) #-#-#-#-#
279
  #. Plugin URI of the plugin/theme
280
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.3.1) #-#-#-#-#
281
  #. Author URI of the plugin/theme
282
  msgid "http://www.intox.dk/"
283
  msgstr "http://www.intox.dk/"
284
 
285
  #. Description of the plugin/theme
286
  msgid "Manage and show sidebars according to the content being viewed."
287
+ msgstr ""
288
+ "Pagal šiuo metu peržiūrimą turinį valdykite ir rodykite tinkamas šonines "
289
+ "juostas."
290
 
291
  #. Author of the plugin/theme
292
+ msgid "Joachim Jensen, Intox Studio"
293
+ msgstr "Joachim Jensen, Intox Studio"
294
+
295
+ #~ msgid "View All"
296
+ #~ msgstr "Peržiūrėti Visus"
297
 
298
+ #~ msgid "Most Used"
299
+ #~ msgstr "Dažniausiai naudoti(os)"
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,263 @@ 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 +278,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.3.1\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/content-aware-sidebars\n"
7
+ "POT-Creation-Date: 2013-05-14 13:07:12+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:689
 
 
 
 
161
  msgid "Content"
162
  msgstr ""
163
 
164
+ #: content-aware-sidebars.php:699
165
  msgid "Options"
166
  msgstr ""
167
 
168
+ #: content-aware-sidebars.php:708
169
+ msgid "Spread the Word"
170
  msgstr ""
171
 
172
+ #: content-aware-sidebars.php:798
173
  msgid ""
174
+ "If you love this plugin, please consider donating to support future "
175
+ "development."
176
  msgstr ""
177
 
178
+ #: content-aware-sidebars.php:803
179
+ msgid "Or you could:"
180
  msgstr ""
181
 
182
+ #: content-aware-sidebars.php:805
183
+ msgid "Rate the plugin on WordPress.org"
184
  msgstr ""
185
 
186
+ #: content-aware-sidebars.php:806
187
+ msgid "Link to the plugin page"
188
+ msgstr ""
189
+
190
+ #: modules/abstract.php:57 modules/post_type.php:110
191
  msgid "Show with All %s"
192
  msgstr ""
193
 
194
+ #: modules/abstract.php:61 modules/post_type.php:134 modules/taxonomy.php:175
195
+ msgctxt "verb"
196
+ msgid "Search"
197
+ msgstr ""
198
+
199
+ #: modules/abstract.php:61 modules/post_type.php:134 modules/taxonomy.php:175
200
+ #: modules/url.php:42
201
+ msgid "Add"
202
  msgstr ""
203
 
204
+ #: modules/author.php:24
205
  msgid "Authors"
206
  msgstr ""
207
 
208
+ #: modules/bbpress.php:23
209
  msgid "bbPress User Profiles"
210
  msgstr ""
211
 
212
+ #: modules/bp_member.php:23
213
  msgid "BuddyPress Members"
214
  msgstr ""
215
 
216
+ #: modules/page_template.php:24
217
  msgid "Page Templates"
218
  msgstr ""
219
 
220
+ #: modules/polylang.php:23 modules/qtranslate.php:23 modules/transposh.php:23
221
+ #: modules/wpml.php:23
222
  msgid "Languages"
223
  msgstr ""
224
 
225
+ #: modules/post_type.php:30
226
  msgid "Post Types"
227
  msgstr ""
228
 
229
+ #: modules/post_type.php:104 modules/taxonomy.php:151
230
  msgid "Automatically select new children of a selected ancestor"
231
  msgstr ""
232
 
233
+ #: modules/post_type.php:114 modules/taxonomy.php:159
234
  msgid "No items."
235
  msgstr ""
236
 
237
+ #: modules/static.php:25
238
  msgid "Static Pages"
239
  msgstr ""
240
 
241
+ #: modules/static.php:34
242
  msgid "Front Page"
243
  msgstr ""
244
 
245
+ #: modules/static.php:35
246
  msgid "Search Results"
247
  msgstr ""
248
 
249
+ #: modules/static.php:36
250
  msgid "404 Page"
251
  msgstr ""
252
 
253
+ #: modules/taxonomy.php:36
254
  msgid "Taxonomies"
255
  msgstr ""
256
 
257
+ #: modules/taxonomy.php:155
258
  msgid "Show with %s"
259
  msgstr ""
260
 
261
+ #: modules/url.php:24
262
+ msgid "URLs"
263
  msgstr ""
264
 
265
  #. Plugin Name of the plugin/theme
266
  msgid "Content Aware Sidebars"
267
  msgstr ""
268
 
269
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.3.1) #-#-#-#-#
270
  #. Plugin URI of the plugin/theme
271
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.3.1) #-#-#-#-#
272
  #. Author URI of the plugin/theme
273
  msgid "http://www.intox.dk/"
274
  msgstr ""
278
  msgstr ""
279
 
280
  #. Author of the plugin/theme
281
+ msgid "Joachim Jensen, Intox Studio"
282
  msgstr ""
lang/content-aware-sidebars_sk_SK.mo ADDED
Binary file
lang/content-aware-sidebars_sk_SK.po ADDED
@@ -0,0 +1,311 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: \n"
4
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/content-aware-sidebars\n"
5
+ "POT-Creation-Date: 2013-05-14 13:07:12+00:00\n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: \n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=iso-8859-1\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.5.5\n"
13
+
14
+ # Copyright (C) 2013 Content Aware Sidebars
15
+ # This file is distributed under the same license as the Content Aware Sidebars package.
16
+ #: content-aware-sidebars.php:178 content-aware-sidebars.php:345
17
+ msgid "Exposure"
18
+ msgstr "Expozicie"
19
+
20
+ #: content-aware-sidebars.php:184
21
+ msgid "Singular"
22
+ msgstr "Singularni"
23
+
24
+ #: content-aware-sidebars.php:185
25
+ msgid "Singular & Archive"
26
+ msgstr "Singularni & Archiv"
27
+
28
+ #: content-aware-sidebars.php:186
29
+ msgid "Archive"
30
+ msgstr "Archiv"
31
+
32
+ #: content-aware-sidebars.php:190 content-aware-sidebars.php:346
33
+ msgctxt "option"
34
+ msgid "Handle"
35
+ msgstr "Rukovat"
36
+
37
+ #: content-aware-sidebars.php:192
38
+ msgid "Replace host sidebar, merge with it or add sidebar manually."
39
+ msgstr ""
40
+ "Nahradit hostitela sidebar, zlucit s nim alebo manualne pridat sidebar."
41
+
42
+ #: content-aware-sidebars.php:196
43
+ msgid "Replace"
44
+ msgstr "Nahradit"
45
+
46
+ #: content-aware-sidebars.php:197
47
+ msgid "Merge"
48
+ msgstr "Zlucit"
49
+
50
+ #: content-aware-sidebars.php:198
51
+ msgid "Manual"
52
+ msgstr "Manual"
53
+
54
+ #: content-aware-sidebars.php:202
55
+ msgid "Host Sidebar"
56
+ msgstr "Hostitel Sidebar"
57
+
58
+ #: content-aware-sidebars.php:210 content-aware-sidebars.php:347
59
+ msgid "Merge position"
60
+ msgstr "Zlucit pozicie"
61
+
62
+ #: content-aware-sidebars.php:212
63
+ msgid "Place sidebar on top or bottom of host when merging."
64
+ msgstr "Miesto sidebar na hornej alebo dolnej casti hostitela pri zlucovani."
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 "Dno"
73
+
74
+ #: content-aware-sidebars.php:232
75
+ msgid "Sidebars"
76
+ msgstr "Bocne panely"
77
+
78
+ #: content-aware-sidebars.php:233
79
+ msgid "Sidebar"
80
+ msgstr "Bocny panel"
81
+
82
+ #: content-aware-sidebars.php:234
83
+ msgctxt "sidebar"
84
+ msgid "Add New"
85
+ msgstr "Pridat nove"
86
+
87
+ #: content-aware-sidebars.php:235
88
+ msgid "Add New Sidebar"
89
+ msgstr "Pridat novy bocny panel"
90
+
91
+ #: content-aware-sidebars.php:236
92
+ msgid "Edit Sidebar"
93
+ msgstr "Upravit Sidebar"
94
+
95
+ #: content-aware-sidebars.php:237
96
+ msgid "New Sidebar"
97
+ msgstr "Novy bocny panel"
98
+
99
+ #: content-aware-sidebars.php:238
100
+ msgid "All Sidebars"
101
+ msgstr "Vsetci postranne"
102
+
103
+ #: content-aware-sidebars.php:239
104
+ msgid "View Sidebar"
105
+ msgstr "Zobrazit bocny panel"
106
+
107
+ #: content-aware-sidebars.php:240
108
+ msgid "Search Sidebars"
109
+ msgstr "Hladat Sidebars"
110
+
111
+ #: content-aware-sidebars.php:241
112
+ msgid "No sidebars found"
113
+ msgstr "C sidebars nasiel"
114
+
115
+ #: content-aware-sidebars.php:242
116
+ msgid "No sidebars found in Trash"
117
+ msgstr "Ziadne sidebars, nachadza v kosi"
118
+
119
+ #: content-aware-sidebars.php:273
120
+ msgid "Sidebar updated. <a href=\"%s\">Manage widgets</a>"
121
+ msgstr "Sidebar aktualizovane. <a href=\"%s\">Spravovat widgety</a>"
122
+
123
+ #: content-aware-sidebars.php:276
124
+ msgid "Sidebar updated."
125
+ msgstr "Sidebar aktualizovane."
126
+
127
+ #: content-aware-sidebars.php:278
128
+ msgid "Sidebar published. <a href=\"%s\">Manage widgets</a>"
129
+ msgstr "Bocny panel publikoval. <a href=\"%s\">Spravovat widgety</a>"
130
+
131
+ #: content-aware-sidebars.php:279
132
+ msgid "Sidebar saved."
133
+ msgstr "Sidebar ulozene."
134
+
135
+ #: content-aware-sidebars.php:280
136
+ msgid "Sidebar submitted. <a href=\"%s\">Manage widgets</a>"
137
+ msgstr "Bocnom paneli posielaju. <a href=\"%s\">Spravovat widgety</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>"
143
+ msgstr ""
144
+ "Sidebar naplanovane na: <strong>%1$s</strong>. <a href=\"%2$s\">Spravovat "
145
+ "widgety</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 "M j, Y @ G:i"
151
+
152
+ #: content-aware-sidebars.php:284
153
+ msgid "Sidebar draft updated."
154
+ msgstr "Sidebar navrh aktualizovane."
155
+
156
+ #: content-aware-sidebars.php:321 content-aware-sidebars.php:402
157
+ msgid "Please update Host Sidebar"
158
+ msgstr "Prosim aktualizujte hostitela Sidebar"
159
+
160
+ #: content-aware-sidebars.php:457
161
+ msgid "Manage Widgets"
162
+ msgstr "Spravovat widgety"
163
+
164
+ #: content-aware-sidebars.php:689
165
+ msgid "Content"
166
+ msgstr "Obsah"
167
+
168
+ #: content-aware-sidebars.php:699
169
+ msgid "Options"
170
+ msgstr "Moznosti"
171
+
172
+ #: content-aware-sidebars.php:708
173
+ msgid "Spread the Word"
174
+ msgstr ""
175
+
176
+ #: content-aware-sidebars.php:798
177
+ #, fuzzy
178
+ msgid ""
179
+ "If you love this plugin, please consider donating to support future "
180
+ "development."
181
+ msgstr "Ak mate radi tento plugin, prosim zvazte darovanie."
182
+
183
+ #: content-aware-sidebars.php:803
184
+ msgid "Or you could:"
185
+ msgstr ""
186
+
187
+ #: content-aware-sidebars.php:805
188
+ msgid "Rate the plugin on WordPress.org"
189
+ msgstr ""
190
+
191
+ #: content-aware-sidebars.php:806
192
+ msgid "Link to the plugin page"
193
+ msgstr ""
194
+
195
+ #: modules/abstract.php:57 modules/post_type.php:110
196
+ msgid "Show with All %s"
197
+ msgstr "Zobrazit s vsetky %s"
198
+
199
+ #: modules/abstract.php:61 modules/post_type.php:134 modules/taxonomy.php:175
200
+ msgctxt "verb"
201
+ msgid "Search"
202
+ msgstr "Hladat"
203
+
204
+ #: modules/abstract.php:61 modules/post_type.php:134 modules/taxonomy.php:175
205
+ #: modules/url.php:42
206
+ msgid "Add"
207
+ msgstr ""
208
+
209
+ #: modules/author.php:24
210
+ msgid "Authors"
211
+ msgstr "Autori"
212
+
213
+ #: modules/bbpress.php:23
214
+ msgid "bbPress User Profiles"
215
+ msgstr "bbPress pouzivatelske profily"
216
+
217
+ #: modules/bp_member.php:23
218
+ msgid "BuddyPress Members"
219
+ msgstr "BuddyPress clenov"
220
+
221
+ #: modules/page_template.php:24
222
+ msgid "Page Templates"
223
+ msgstr "Stranky sablony"
224
+
225
+ #: modules/polylang.php:23 modules/qtranslate.php:23 modules/transposh.php:23
226
+ #: modules/wpml.php:23
227
+ msgid "Languages"
228
+ msgstr "Jazyky"
229
+
230
+ #: modules/post_type.php:30
231
+ msgid "Post Types"
232
+ msgstr "Prispevok typy"
233
+
234
+ #: modules/post_type.php:104 modules/taxonomy.php:151
235
+ msgid "Automatically select new children of a selected ancestor"
236
+ msgstr "Automaticky vybrat nove deti z vybranych predok"
237
+
238
+ #: modules/post_type.php:114 modules/taxonomy.php:159
239
+ msgid "No items."
240
+ msgstr "Ziadne polozky."
241
+
242
+ #: modules/static.php:25
243
+ msgid "Static Pages"
244
+ msgstr "Staticke stranky"
245
+
246
+ #: modules/static.php:34
247
+ msgid "Front Page"
248
+ msgstr "Predna strana"
249
+
250
+ #: modules/static.php:35
251
+ msgid "Search Results"
252
+ msgstr "Vysledky hladania"
253
+
254
+ #: modules/static.php:36
255
+ msgid "404 Page"
256
+ msgstr "404 Stranka"
257
+
258
+ #: modules/taxonomy.php:36
259
+ msgid "Taxonomies"
260
+ msgstr "Taxonomie"
261
+
262
+ #: modules/taxonomy.php:155
263
+ msgid "Show with %s"
264
+ msgstr "Zobrazit s %s"
265
+
266
+ #: modules/url.php:24
267
+ msgid "URLs"
268
+ msgstr ""
269
+
270
+ #. Plugin Name of the plugin/theme
271
+ msgid "Content Aware Sidebars"
272
+ msgstr "Obsah vedomi Sidebars"
273
+
274
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.3.1) #-#-#-#-#
275
+ #. Plugin URI of the plugin/theme
276
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 1.3.1) #-#-#-#-#
277
+ #. Author URI of the plugin/theme
278
+ msgid "http://www.intox.dk/"
279
+ msgstr "http://www.Intox.dk/"
280
+
281
+ #. Description of the plugin/theme
282
+ msgid "Manage and show sidebars according to the content being viewed."
283
+ msgstr "Spravovat a Zobrazit sidebars podla obsahu je prezerana."
284
+
285
+ #. Author of the plugin/theme
286
+ msgid "Joachim Jensen, Intox Studio"
287
+ msgstr "Joachim Jensen, Intox Studio"
288
+
289
+ #~ msgid "Words from the author"
290
+ #~ msgstr "Slov od autora"
291
+
292
+ #~ msgid ""
293
+ #~ "this-is-translatedRemember to <a class=\"button\" href=\"%1$s\" target="
294
+ #~ "\"_blank\">rate</a> and <a class=\"button\" href=\"%2$s\" target=\"_blank"
295
+ #~ "\">share</a> it too!"
296
+ #~ msgstr ""
297
+ #~ "Nezabudnite <a class=\"button\" href=\"%1$s\" target=\"_blank\">rate</a> "
298
+ #~ "and <a class=\"button\" href=\"%2$s\" target=\"_blank\">zdielat</a> to "
299
+ #~ "taky!"
300
+
301
+ #~ msgid "Check out Content Aware Sidebars for %23WordPress! :)"
302
+ #~ msgstr "Pozrite sa na obsah vedomi postrehov pre % 23WordPress! :)"
303
+
304
+ #~ msgid "Check out Content Aware Sidebars :)"
305
+ #~ msgstr "Pozrite sa na obsah vedomi Sidebars:)"
306
+
307
+ #~ msgid "View All"
308
+ #~ msgstr "Zobrazit vsetky"
309
+
310
+ #~ msgid "Most Used"
311
+ #~ msgstr "Najpouzivanejsie"
modules/abstract.php CHANGED
@@ -11,8 +11,23 @@
11
  */
12
  abstract class CASModule {
13
 
 
 
 
 
14
  protected $id;
 
 
 
 
 
15
  protected $name;
 
 
 
 
 
 
16
 
17
  /**
18
  *
@@ -21,8 +36,17 @@ abstract class CASModule {
21
  */
22
  public function __construct() {
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 +55,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 +103,67 @@ 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
  *
36
  */
37
  public function __construct() {
38
  $this->id = substr(get_class($this),strpos(get_class($this),'_')+1);
39
+
40
+ add_action('cas-module-admin-box',array(&$this,'meta_box_content'));
41
+ add_action('cas-module-save-data',array(&$this,'save_data'));
42
+
43
  }
44
 
45
+ /**
46
+ * Default meta box content
47
+ * @global object $post
48
+ * @return void
49
+ */
50
  public function meta_box_content() {
51
  global $post;
52
 
55
 
56
  echo '<h4><a href="#">'.$this->name.'</a></h4>'."\n";
57
  echo '<div class="cas-rule-content" id="cas-'.$this->id.'">';
58
+ $meta = get_post_meta($post->ID, ContentAwareSidebars::PREFIX.$this->id, false);
 
59
  $current = $meta != '' ? $meta : array();
60
+
61
+ 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";
62
+
63
+ // Show search if enabled and there is too much content
64
+ if($this->searchable && count($this->_get_content()) > 20) {
65
+ 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="" placeholder="'.$this->name.'" />'."\n";
66
+ }
67
+
68
+ echo '<ul id="cas-list-' . $this->id . '" class="cas-contentlist categorychecklist form-no-clear">'."\n";
69
+ foreach($this->_get_content() as $id => $name) {
70
+ 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";
71
+ }
72
+ echo '</ul>'."\n";
73
+
 
 
 
 
 
74
  echo '</div>';
75
  }
76
 
77
+ /**
78
+ * Default query join
79
+ * @global object $wpdb
80
+ * @return string
81
+ */
82
  public function db_join() {
83
  global $wpdb;
84
+ return "LEFT JOIN $wpdb->postmeta {$this->id} ON {$this->id}.post_id = posts.ID AND {$this->id}.meta_key = '".ContentAwareSidebars::PREFIX.$this->id."' ";
85
  }
86
 
87
+ /**
88
+ * Exclude sidebar. TODO: revise
89
+ * @param boolean $continue
90
+ * @param object $post
91
+ * @param string $prefix
92
+ * @return boolean
93
+ */
94
  public function exclude_sidebar($continue, $post, $prefix) {
95
  if(!$continue) {
96
  //print_r($this->id."<br />");
103
 
104
  }
105
 
106
+ /**
107
+ * Default where2 query
108
+ * @return string
109
+ */
110
  public function db_where2() {
111
  return "{$this->id}.meta_value IS NOT NULL";
112
  }
113
 
114
+ /**
115
+ * Idenficiation getter
116
+ * @return string
117
+ */
118
  public function get_id() {
119
  return $this->id;
120
  }
121
+
122
+ /**
123
+ * Save data on POST
124
+ * @param int $post_id
125
+ * @return void
126
+ */
127
+ public function save_data($post_id) {
128
+ $new = isset($_POST[$this->id]) ? $_POST[$this->id] : '';
129
+ $old = array_flip(get_post_meta($post_id, ContentAwareSidebars::PREFIX . $this->id, false));
130
+
131
+ if (is_array($new)) {
132
+ //$new = array_unique($new);
133
+ // Skip existing data or insert new data
134
+ foreach ($new as $new_single) {
135
+ if (isset($old[$new_single])) {
136
+ unset($old[$new_single]);
137
+ } else {
138
+ add_post_meta($post_id, ContentAwareSidebars::PREFIX . $this->id, $new_single);
139
+ }
140
+ }
141
+ // Remove existing data that have not been skipped
142
+ foreach ($old as $old_key => $old_value) {
143
+ delete_post_meta($post_id, ContentAwareSidebars::PREFIX . $this->id, $old_key);
144
+ }
145
+ } elseif (!empty($old)) {
146
+ // Remove any old values when $new is empty
147
+ delete_post_meta($post_id, ContentAwareSidebars::PREFIX . $this->id);
148
+ }
149
+ }
150
 
151
+ /**
152
+ * Get content for sidebar edit screen
153
+ * @return array
154
+ */
155
  abstract protected function _get_content();
156
+
157
+ /**
158
+ * Determine if current content is relevant
159
+ * @return boolean
160
+ */
161
  abstract public function is_content();
162
+
163
+ /**
164
+ * Where query
165
+ * @return string
166
+ */
167
  abstract public function db_where();
168
 
169
  }
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,56 @@ 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
+ * Get authors with AJAX search
66
+ * @return void
67
+ */
68
+ public function ajax_content_search() {
69
+ global $wpdb;
70
+
71
+ // Verify request
72
+ check_ajax_referer(basename('content-aware-sidebars.php'),'nonce');
73
+
74
+ $suggestions = array();
75
+
76
+ $authors =$wpdb->get_results($wpdb->prepare("
77
+ SELECT ID, display_name
78
+ FROM $wpdb->users
79
+ WHERE display_name
80
+ LIKE '%s'
81
+ ORDER BY display_name ASC
82
+ LIMIT 0,20
83
+ ",
84
+ '%'.$_REQUEST['term'].'%'));
85
+
86
+ foreach($authors as $user) {
87
+ $suggestions[] = array(
88
+ 'label' => $user->display_name,
89
+ 'value' => $user->display_name,
90
+ 'id' => $user->ID,
91
+ 'module' => $this->id,
92
+ 'name' => $this->id,
93
+ 'id2' => $this->id,
94
+ 'elem' => $this->id.'-'.$user->ID
95
+ );
96
+ }
97
+
98
+ echo json_encode($suggestions);
99
+ die();
100
+ }
101
 
102
  }
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,164 @@ 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,16 +263,16 @@ 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(
141
- 'key' => ContentAwareSidebars::prefix . $this->id,
142
  'value' => get_ancestors($post->ID,$post->post_type),
143
  'type' => 'numeric',
144
  'compare' => 'IN'
@@ -147,15 +281,12 @@ class CASModule_post_type extends CASModule {
147
  ));
148
  if($sidebars) {
149
  foreach($sidebars as $sidebar) {
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="" placeholder="'.$post_type->label.'" />'."\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
+ global $wpdb;
186
+
187
+ // Verify request
188
+ check_ajax_referer(basename('content-aware-sidebars.php'),'nonce');
189
+
190
+ $suggestions = array();
191
+ if ( preg_match('/cas-autocomplete-'.$this->id.'-([a-zA-Z_-]*\b)/', $_REQUEST['type'], $matches) ) {
192
+ if(get_post_type_object( $matches[1] )) {
193
+ $exclude = array();
194
+ $exclude_query = "";
195
+ if ($matches[1] == 'page' && 'page' == get_option('show_on_front')) {
196
+ $exclude[] = get_option('page_on_front');
197
+ $exclude[] = get_option('page_for_posts');
198
+ $exclude_query = " AND ID NOT IN (".implode(",", $exclude).")";
199
+ }
200
+
201
+ //WordPress searches in title and content by default
202
+ //We want to search in title and slug
203
+ //Using unprepared (safe) exclude because WP is not good at parsing arrays
204
+ $posts = $wpdb->get_results($wpdb->prepare("
205
+ SELECT ID, post_title, post_type
206
+ FROM $wpdb->posts
207
+ WHERE post_type = '%s' AND (post_title LIKE '%s' OR post_name LIKE '%s') AND post_status IN('publish','private','future')
208
+ ".$exclude_query."
209
+ ORDER BY post_title ASC
210
+ LIMIT 0,20
211
+ ",
212
+ $matches[1],
213
+ "%".$_REQUEST['term']."%",
214
+ "%".$_REQUEST['term']."%"
215
+ ));
216
+
217
+ // $posts = get_posts(array(
218
+ // 'posts_per_page' => 10,
219
+ // 'post_type' => $matches[1],
220
+ // 's' => $_REQUEST['term'],
221
+ // 'exclude' => $exclude,
222
+ // 'orderby' => 'title',
223
+ // 'order' => 'ASC',
224
+ // 'post_status' => 'publish,private,future'
225
+ // ));
226
+
227
+ foreach($posts as $post) {
228
+ $suggestions[] = array(
229
+ 'label' => $post->post_title,
230
+ 'value' => $post->post_title,
231
+ 'id' => $post->ID,
232
+ 'module' => $this->id,
233
+ 'name' => $this->id,
234
+ 'id2' => $this->id.'-'.$post->post_type,
235
+ 'elem' => $post->post_type.'-'.$post->ID
236
+ );
237
+ }
238
+ }
239
+ }
240
+
241
+ echo json_encode($suggestions);
242
+ die();
243
  }
244
+
245
 
246
  /**
247
+ * Automatically select child of selected parent
248
+ * @param string $new_status
249
+ * @param string $old_status
250
+ * @param object $post
251
+ * @return void
252
  */
253
  public function post_ancestry_check($new_status, $old_status, $post) {
254
 
255
+ if($post->post_type != ContentAwareSidebars::TYPE_SIDEBAR) {
256
 
257
  $status = array('publish','private','future');
258
  // Only new posts are relevant
263
 
264
  // Get sidebars with post ancestor wanting to auto-select post
265
  $sidebars = new WP_Query(array(
266
+ 'post_type' => ContentAwareSidebars::TYPE_SIDEBAR,
267
  'meta_query' => array(
268
  'relation' => 'AND',
269
  array(
270
+ 'key' => ContentAwareSidebars::PREFIX . $this->id,
271
+ 'value' => ContentAwareSidebars::PREFIX.'sub_' . $post->post_type,
272
  'compare' => '='
273
  ),
274
  array(
275
+ 'key' => ContentAwareSidebars::PREFIX . $this->id,
276
  'value' => get_ancestors($post->ID,$post->post_type),
277
  'type' => 'numeric',
278
  'compare' => 'IN'
281
  ));
282
  if($sidebars) {
283
  foreach($sidebars as $sidebar) {
284
+ add_post_meta($sidebar->ID, ContentAwareSidebars::PREFIX.$this->id, $post->ID);
285
  }
286
  }
287
+ }
288
+ }
289
+ }
 
 
 
290
  }
291
 
292
  }
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,47 +15,78 @@
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
 
50
  $joins = "LEFT JOIN $wpdb->term_relationships term ON term.object_id = posts.ID ";
51
  $joins .= "LEFT JOIN $wpdb->term_taxonomy taxonomy ON taxonomy.term_taxonomy_id = term.term_taxonomy_id ";
52
  $joins .= "LEFT JOIN $wpdb->terms terms ON terms.term_id = taxonomy.term_id ";
53
- $joins .= "LEFT JOIN $wpdb->postmeta taxonomies ON taxonomies.post_id = posts.ID AND taxonomies.meta_key = '".ContentAwareSidebars::prefix."taxonomies'";
54
 
55
  return $joins;
56
 
57
  }
58
 
 
 
 
 
59
  public function db_where() {
60
 
61
  if(is_singular()) {
@@ -82,81 +113,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 +303,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(),'object');
54
+ //Only want public taxonomies
55
+ $taxonomy_names = array();
56
+ foreach($taxonomies as $taxonomy) {
57
+ if($taxonomy->public)
58
+ $taxonomy_names[] = $taxonomy->name;
59
+ }
60
+ if(!empty($taxonomy_names)) {
61
  // Check if content has any actual taxonomy terms
62
+ $this->post_terms = wp_get_object_terms(get_the_ID(),$taxonomy_names);
63
+ return !empty($this->post_terms);
 
64
  }
65
+ return false;
 
66
  }
67
+ return is_tax() || is_category() || is_tag();
68
  }
69
 
70
+ /**
71
+ * Query join
72
+ * @return string
73
+ */
74
  public function db_join() {
75
  global $wpdb;
76
 
77
  $joins = "LEFT JOIN $wpdb->term_relationships term ON term.object_id = posts.ID ";
78
  $joins .= "LEFT JOIN $wpdb->term_taxonomy taxonomy ON taxonomy.term_taxonomy_id = term.term_taxonomy_id ";
79
  $joins .= "LEFT JOIN $wpdb->terms terms ON terms.term_id = taxonomy.term_id ";
80
+ $joins .= "LEFT JOIN $wpdb->postmeta taxonomies ON taxonomies.post_id = posts.ID AND taxonomies.meta_key = '".ContentAwareSidebars::PREFIX."taxonomies'";
81
 
82
  return $joins;
83
 
84
  }
85
 
86
+ /**
87
+ * Query where
88
+ * @return string
89
+ */
90
  public function db_where() {
91
 
92
  if(is_singular()) {
113
 
114
  }
115
 
116
+ /**
117
+ * Query where2
118
+ * @return string
119
+ */
120
  public function db_where2() {
121
  return "terms.slug IS NOT NULL OR taxonomies.meta_value IS NOT NULL";
122
  }
123
 
124
+ /**
125
+ * Get registered taxonomies
126
+ * @return array
127
+ */
128
+ protected function _get_content() {
129
+ // List public taxonomies
130
+ if (empty($this->taxonomy_objects)) {
131
+ foreach (get_taxonomies(array('public' => true), 'objects') as $tax) {
132
+ $this->taxonomy_objects[$tax->name] = $tax;
133
+ }
134
+ }
135
+ return $this->taxonomy_objects;
136
  }
137
 
138
+ /**
139
+ * Meta box content
140
+ * @global object $post
141
+ * @return void
142
+ */
143
  public function meta_box_content() {
144
  global $post;
145
 
146
+ foreach ($this->_get_content() as $taxonomy) {
147
  echo '<h4><a href="#">' . $taxonomy->label . '</a></h4>'."\n";
148
  echo '<div class="cas-rule-content" id="cas-' . $this->id . '-' . $taxonomy->name . '">';
149
 
150
+ $meta = get_post_meta($post->ID, ContentAwareSidebars::PREFIX . 'taxonomies', false);
151
  $current = $meta != '' ? $meta : array();
152
 
153
+ $number_of_terms = wp_count_terms($taxonomy->name,array('hide_empty'=>false));
154
 
155
  if($taxonomy->hierarchical) {
156
  echo '<p>' . "\n";
157
+ 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";
158
  echo '</p>' . "\n";
159
  }
160
  echo '<p>' . "\n";
161
+ 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";
162
  echo '</p>' . "\n";
163
 
164
+ if (!$number_of_terms) {
165
  echo '<p>' . __('No items.') . '</p>';
166
  } else {
167
+
168
+ $selected_ids = array();
169
+ if(($selected = wp_get_object_terms($post->ID, $taxonomy->name))) {
170
+ $selected_ids = wp_get_object_terms($post->ID, $taxonomy->name, array('fields' => 'ids'));
171
+ } else {
172
+ $selected = array();
173
+ }
174
+ $terms = get_terms($taxonomy->name, array(
175
+ 'number' => 20,
176
+ 'hide_empty' => false,
177
+ 'exclude' => $selected_ids
178
+ ));
179
+
180
+ if($number_of_terms > 20) {
181
+ 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="" placeholder="' . $taxonomy->label . '" />'."\n";
182
+ }
183
+
184
+ echo '<input type="hidden" name="'.($taxonomy->name == "category" ? "post_category[]" : "tax_input[".$taxonomy->name."]").'" value="0" />';
185
+ echo '<ul id="cas-list-' . $this->id . '-' . $taxonomy->name . '" class="cas-contentlist categorychecklist form-no-clear">'."\n";
186
+ $this->term_checklist($post->ID, $taxonomy, array_merge($selected,$terms), $selected_ids);
187
+ echo '</ul>'."\n";
188
+
189
  }
190
  echo '</div>'."\n";
191
  }
192
  }
193
+
194
+ /**
195
+ * Show terms from a specific taxonomy
196
+ * @param int $post_id
197
+ * @param object $taxonomy
198
+ * @param array $terms
199
+ * @param array $selected_ids
200
+ * @return void
201
+ */
202
+ private function term_checklist($post_id = 0, $taxonomy, $terms, $selected_ids) {
203
+
204
+ $walker = new CAS_Walker_Checklist('category',array ('parent' => 'parent', 'id' => 'term_id'));
205
+
206
+ $args = array(
207
+ 'taxonomy' => $taxonomy,
208
+ 'selected_terms' => $post_id ? $selected_ids : array()
209
+ );
210
+
211
+ $checked_terms = array();
212
+
213
+ foreach( $terms as $key => $value ) {
214
+ if (in_array($terms[$key]->term_id, $args['selected_terms'])) {
215
+ $checked_terms[] = $terms[$key];
216
+ unset($terms[$key]);
217
+ }
218
+ }
219
+
220
+ //Put checked posts on top
221
+ echo call_user_func_array(array(&$walker, 'walk'), array($checked_terms, 0, $args));
222
+ // Then the rest of them
223
+ echo call_user_func_array(array(&$walker, 'walk'), array($terms, 0, $args));
224
+ }
225
+
226
+ /**
227
+ * Get terms with AJAX search
228
+ * @return void
229
+ */
230
+ public function ajax_content_search() {
231
+
232
+ // Verify request
233
+ check_ajax_referer(basename('content-aware-sidebars.php'),'nonce');
234
 
235
+ $suggestions = array();
236
+ if ( preg_match('/cas-autocomplete-'.$this->id.'-([a-zA-Z_-]*\b)/', $_REQUEST['type'], $matches) ) {
237
+ if(($taxonomy = get_taxonomy( $matches[1] ))) {
238
+ $terms = get_terms($taxonomy->name, array(
239
+ 'number' => 20,
240
+ 'hide_empty' => false,
241
+ 'search' => $_REQUEST['term']
242
+ ));
243
+ $name = ($taxonomy->name == 'category' ? 'post_category' : 'tax_input['.$matches[1].']');
244
+ $value = ($taxonomy->hierarchical ? 'term_id' : 'slug');
245
+ foreach($terms as $term) {
246
+ $suggestions[] = array(
247
+ 'label' => $term->name,
248
+ 'value' => $term->name,
249
+ 'id' => $term->$value,
250
+ 'module' => $this->id,
251
+ 'name' => $name,
252
+ 'id2' => $this->id.'-'.$term->taxonomy,
253
+ 'elem' => $term->taxonomy.'-'.$term->term_id
254
+ );
255
+ }
256
  }
257
  }
258
+
259
+ echo json_encode($suggestions);
260
+ die();
261
+ }
262
+
263
+ /**
264
+ * Register taxonomies to sidebar post type
265
+ * @return void
266
+ */
267
+ public function add_taxonomies_to_sidebar() {
268
+ foreach($this->_get_content() as $tax) {
269
+ register_taxonomy_for_object_type( $tax->name, ContentAwareSidebars::TYPE_SIDEBAR );
270
+ }
271
+ }
272
+
273
+
274
+ /**
275
+ * Remove taxonomy shortcuts from menu and standard meta boxes.
276
+ * @return void
277
+ */
278
+ public function clear_admin_menu() {
279
+ if(current_user_can('edit_theme_options')) {
280
+ foreach($this->_get_content() as $tax) {
281
+ remove_submenu_page('edit.php?post_type='.ContentAwareSidebars::TYPE_SIDEBAR,'edit-tags.php?taxonomy='.$tax->name.'&amp;post_type='.ContentAwareSidebars::TYPE_SIDEBAR);
282
+ }
283
+ } else {
284
+ // Remove those taxonomies left in the menu when it should be hidden
285
+ foreach($this->_get_content() as $tax) {
286
+ remove_menu_page('edit-tags.php?taxonomy='.$tax->name.'&amp;post_type='.ContentAwareSidebars::TYPE_SIDEBAR);
287
+ }
288
+ }
289
  }
290
 
291
  /**
 
292
  * Auto-select children of selected ancestor
293
+ * @param int $term_id
294
+ * @param int $tt_id
295
+ * @param string $taxonomy
296
+ * @return void
297
  */
298
  public function term_ancestry_check($term_id, $tt_id, $taxonomy) {
299
 
303
  if($term->parent != '0') {
304
  // Get sidebars with term ancestor wanting to auto-select term
305
  $posts = new WP_Query(array(
306
+ 'post_type' => ContentAwareSidebars::TYPE_SIDEBAR,
307
  'meta_query' => array(
308
  array(
309
+ 'key' => ContentAwareSidebars::PREFIX . $this->id,
310
+ 'value' => ContentAwareSidebars::PREFIX.'sub_' . $taxonomy,
311
  'compare' => '='
312
  )
313
  ),
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/).
@@ -69,20 +70,34 @@ www.intox.dk
69
 
70
  == Frequently Asked Questions ==
71
 
72
- If you have any questions not answered here, head to the [Support Forum](http://wordpress.org/tags/content-aware-sidebars?forum_id=10) or [contact me directly](http://www.intox.dk/kontakt/).
73
 
74
  = Will Content Aware Sidebars work with my theme? =
75
 
76
- Yes. If the theme supports dynamic widget areas/sidebars, new sidebars can be created to replace or merge with those.
 
 
77
  If not, it is still possible to create sidebars and then use the function `display_ca_sidebar()` in the theme.
78
 
 
 
 
 
 
 
79
  = My new sidebar is not displayed where I expect it to? =
80
 
81
- All content rules are dependent of each other (when they collide), which makes it possible to create extremely focused rules for where to display a sidebar; e.g. with posts written by a given author and with a given category.
82
- However, this also means that it currently is not possible to create a single sidebar that should be displayed with posts by a given author or posts with a given category.
83
 
84
  Note the exposure setting as it determines whether the selected rules apply to archives, singulars or both.
85
 
 
 
 
 
 
 
86
  = How do I use display_ca_sidebar( $args )? =
87
 
88
  This function is optional and handles all sidebars that are set to be handled manually. It can be inserted anywhere on your site in any quantity, either as it is, or with the following parameters:
@@ -107,6 +122,54 @@ 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.7
7
+ Stable tag: 1.3.5
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/).
70
 
71
  == Frequently Asked Questions ==
72
 
73
+ If you have any questions not answered here, head over to the [Support Forum](http://wordpress.org/tags/content-aware-sidebars?forum_id=10).
74
 
75
  = Will Content Aware Sidebars work with my theme? =
76
 
77
+ Yes.
78
+
79
+ If the theme supports dynamic widget areas/sidebars, new sidebars can be created to replace or merge with those.
80
  If not, it is still possible to create sidebars and then use the function `display_ca_sidebar()` in the theme.
81
 
82
+ = Will Content Aware Sidebars work with/support my plugin? =
83
+
84
+ Most likely.
85
+
86
+ If the plugin uses public Custom Post Types or Custom Taxonomies, these will automatically be supported. Additionally, Content Aware Sidebars uses modules with WordPress Hooks that you can control and features builtin support for some of the most popular plugins in the WordPress Repository.
87
+
88
  = My new sidebar is not displayed where I expect it to? =
89
 
90
+ All content rules are dependent of each other (when they collide), which makes it possible to create extremely focused rules for where to display a sidebar; e.g. with posts written by a given author AND with a given category.
91
+ However, this also means that it currently is not possible to create a single sidebar that should be displayed with posts by a given author OR with a given category. This has to be done with two or more sidebars.
92
 
93
  Note the exposure setting as it determines whether the selected rules apply to archives, singulars or both.
94
 
95
+ = All content items are not listed in the sidebar editor? =
96
+
97
+ For the plugin to scale better such that sites with a lot of content can use it, only the 20 recent items are listed for each type of content in the sidebar editor (excluding items previously selected when updating a sidebar). To find and select the rest, simply use the search function above the list.
98
+
99
+ Note that only public, private and scheduled items are displayed.
100
+
101
  = How do I use display_ca_sidebar( $args )? =
102
 
103
  This function is optional and handles all sidebars that are set to be handled manually. It can be inserted anywhere on your site in any quantity, either as it is, or with the following parameters:
122
 
123
  == Changelog ==
124
 
125
+ = 1.3.5 =
126
+
127
+ * Fixed: menu would disappear in rare cases. Props grezvany13
128
+ * Fixed: search function now searches in title and slug (not content) for post types
129
+ * Added: search function displays at most 20 results instead of 10
130
+
131
+ = 1.3.4 =
132
+
133
+ * Fixed: cas_walker_checklist now follows walker declaration for wp3.6
134
+ * Fixed: content list in accordion now not scrollable
135
+ * Fixed: only terms from public taxonomies are included for content recognition.
136
+ * Fixed: polylang fully supported again
137
+ * Fixed: consistent css across wp versions
138
+ * Removed: flushing rewrite rules on activation/deactivation is needless
139
+
140
+ = 1.3.3 =
141
+
142
+ * Added: html placeholder in search field
143
+ * Added: items already displayed in edit page moved to top and checked when found in search
144
+ * Fixed: private and scheduled singulars included in search results
145
+ * Fixed: search results displayed in ascending order
146
+
147
+ = 1.3.2 =
148
+
149
+ * Added: items found in search now added to list directly on select
150
+ * Fixed: some terms found by search could not be saved
151
+ * Fixed: widget locations are saved again for each theme
152
+
153
+ = 1.3.1 =
154
+
155
+ * Added: authors and bbpress user profiles now searchable on edit page
156
+ * Added: items found in search on edit page are prepended and checked by default
157
+ * Added: updated edit page gui
158
+ * Added: search field only visible when quantity is above 20
159
+ * Fixed: select all checkbox will now disable all input in container
160
+ * Fixed: host sidebar could sometimes not be found in sidebar list
161
+
162
+ = 1.3 =
163
+
164
+ * Added: post type posts and taxonomy terms now searchable on edit page
165
+ * Added: sidebar handle and host shown on widgets page
166
+ * Added: slovak translation
167
+ * Fixed: sidebar meta boxes more robust to external modifications
168
+ * Fixed: admin column headers more robust to external modifications
169
+ * Fixed: sidebar menu now always hidden for users without right cap
170
+ * Fixed: code optimization and refactor for performance
171
+ * Removed: support for sidebar excerpt
172
+
173
  = 1.2 =
174
 
175
  * 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
 
@@ -76,11 +72,11 @@ function cas_update_to_11() {
76
  foreach($posts as $post) {
77
  foreach($moduledata as $field) {
78
  // Remove old serialized data and insert it again properly
79
- $old = get_post_meta($post->ID, ContentAwareSidebars::prefix.$field, true);
80
  if($old != '') {
81
- delete_post_meta($post->ID, ContentAwareSidebars::prefix.$field, $old);
82
  foreach((array)$old as $new_single) {
83
- add_post_meta($post->ID, ContentAwareSidebars::prefix.$field, $new_single);
84
  }
85
  }
86
  }
@@ -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
 
72
  foreach($posts as $post) {
73
  foreach($moduledata as $field) {
74
  // Remove old serialized data and insert it again properly
75
+ $old = get_post_meta($post->ID, ContentAwareSidebars::PREFIX.$field, true);
76
  if($old != '') {
77
+ delete_post_meta($post->ID, ContentAwareSidebars::PREFIX.$field, $old);
78
  foreach((array)$old as $new_single) {
79
+ add_post_meta($post->ID, ContentAwareSidebars::PREFIX.$field, $new_single);
80
  }
81
  }
82
  }
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,33 +24,38 @@ 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);
31
  $output .= "$indent<ul class='children'>\n";
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);
41
  $output .= "$indent</ul>\n";
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);
53
 
54
  if(isset($post_type)) {
@@ -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,96 +74,37 @@ 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";
88
  }
89
 
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 = 0, $args = array()) {
34
  $indent = str_repeat("\t", $depth);
35
  $output .= "$indent<ul class='children'>\n";
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 = 0, $args = array()) {
46
  $indent = str_repeat("\t", $depth);
47
  $output .= "$indent</ul>\n";
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 = 0, $args = array(), $current_object_id = 0 ) {
59
  extract($args);
60
 
61
  if(isset($post_type)) {
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, $object, $depth = 0, $args = array() ) {
94
  $output .= "</li>\n";
95
  }
96
 
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
  }