Content Aware Sidebars – Unlimited Widget Areas - Version 0.8.3

Version Description

  • Added: Danish and Italian translation
  • Fixed: sidebar query might be larger than max_join_size
  • Fixed: row content in admin overview would be loaded with post types with matching keys
Download this release

Release Info

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

Code changes from version 0.7 to 0.8.3

content-aware-sidebars.php CHANGED
@@ -6,14 +6,14 @@
6
  Plugin Name: Content Aware Sidebars
7
  Plugin URI: http://www.intox.dk/
8
  Description: Manage and show sidebars according to the content being viewed.
9
- Version: 0.7
10
  Author: Joachim Jensen
11
  Author URI: http://www.intox.dk/
12
  Text Domain: content-aware-sidebars
13
  Domain Path: /lang/
14
  License: GPL2
15
 
16
- Copyright 2011 Joachim Jensen (email : jv@intox.dk)
17
 
18
  This program is free software; you can redistribute it and/or modify
19
  it under the terms of the GNU General Public License, version 2, as
@@ -31,6 +31,9 @@ License: GPL2
31
  */
32
  class ContentAwareSidebars {
33
 
 
 
 
34
  protected $metadata = array();
35
  protected $post_types = array();
36
  protected $post_type_objects = array();
@@ -45,7 +48,7 @@ class ContentAwareSidebars {
45
  */
46
  public function __construct() {
47
 
48
- $this->load_dependencies();
49
 
50
  add_filter('wp', array(&$this,'replace_sidebar'));
51
  add_filter('request', array(&$this,'admin_column_orderby'));
@@ -55,17 +58,21 @@ class ContentAwareSidebars {
55
  add_filter('manage_posts_custom_column', array(&$this,'admin_column_rows'),10,3);
56
  add_filter('post_row_actions', array(&$this,'sidebar_row_actions'),10,2);
57
  add_filter('post_updated_messages', array(&$this,'sidebar_updated_messages'));
58
-
59
- add_action('init', array(&$this,'init_sidebar_type'),50);
60
  add_action('widgets_init', array(&$this,'create_sidebars'));
61
  add_action('add_meta_boxes_sidebar', array(&$this,'create_meta_boxes'));
62
- add_action('admin_init', array(&$this,'prepare_admin_scripts'));
63
  add_action('admin_menu', array(&$this,'clear_admin_menu'));
64
- add_action('save_post', array(&$this,'save_post'));
65
  add_action('admin_print_scripts-post-new.php', array(&$this,'load_admin_scripts'));
66
  add_action('admin_print_scripts-post.php', array(&$this,'load_admin_scripts'));
 
 
 
67
 
68
- register_activation_hook(__FILE__, array(&$this,'upon_activation'));
 
69
 
70
  }
71
 
@@ -74,7 +81,7 @@ class ContentAwareSidebars {
74
  * Create post meta fields
75
  *
76
  */
77
- private function init_metadata() {
78
  global $post, $wp_registered_sidebars, $wpdb;
79
 
80
  // List of sidebars
@@ -139,7 +146,7 @@ class ContentAwareSidebars {
139
  'exposure' => array(
140
  'name' => __('Exposure', 'content-aware-sidebars'),
141
  'id' => 'exposure',
142
- 'desc' => __('Affects post types, taxonomies and taxonomy terms.', 'content-aware-sidebars'),
143
  'val' => 1,
144
  'type' => 'select',
145
  'list' => array(
@@ -163,7 +170,7 @@ class ContentAwareSidebars {
163
  'host' => array(
164
  'name' => __('Host Sidebar', 'content-aware-sidebars'),
165
  'id' => 'host',
166
- 'desc' => __('The sidebar that should be handled. Nesting is possible. Manual handling makes this option superfluous.', 'content-aware-sidebars'),
167
  'val' => 'sidebar-1',
168
  'type' => 'select',
169
  'list' => $sidebar_list
@@ -225,7 +232,7 @@ class ContentAwareSidebars {
225
  'supports' => array('title','excerpt','page-attributes'),
226
  'taxonomies' => array_keys($this->taxonomies),
227
  'menu_icon' => WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__)).'/icon-16.png'
228
- ));
229
  }
230
 
231
  /**
@@ -233,7 +240,7 @@ class ContentAwareSidebars {
233
  * Create update messages
234
  *
235
  */
236
- function sidebar_updated_messages( $messages ) {
237
  global $post;
238
  $messages['sidebar'] = array(
239
  0 => '',
@@ -258,7 +265,7 @@ class ContentAwareSidebars {
258
  * Remove taxonomy shortcuts from menu and standard meta boxes.
259
  *
260
  */
261
- function clear_admin_menu() {
262
  foreach($this->taxonomies as $key => $value) {
263
  remove_submenu_page('edit.php?post_type=sidebar','edit-tags.php?taxonomy='.$key.'&post_type=sidebar');
264
  remove_meta_box('tagsdiv-'.$key, 'sidebar', 'side');
@@ -272,13 +279,14 @@ class ContentAwareSidebars {
272
  *
273
  */
274
  public function create_sidebars() {
 
275
  //WP3.1 does not support (array) as post_status
276
  $posts = get_posts(array(
277
  'numberposts' => -1,
278
  'post_type' => 'sidebar',
279
  'post_status' => 'publish,private,future'
280
  ));
281
- foreach($posts as $post)
282
  register_sidebar( array(
283
  'name' => $post->post_title,
284
  'description' => $post->post_excerpt,
@@ -288,6 +296,7 @@ class ContentAwareSidebars {
288
  'before_title' => '<h3 class="widget-title">',
289
  'after_title' => '</h3>',
290
  ));
 
291
  }
292
 
293
  /**
@@ -310,7 +319,7 @@ class ContentAwareSidebars {
310
 
311
  /**
312
  *
313
- * Make some headers sortable
314
  *
315
  */
316
  public function admin_column_sortable_headers($columns) {
@@ -332,7 +341,7 @@ class ContentAwareSidebars {
332
  public function admin_column_orderby($vars) {
333
  if (isset($vars['orderby']) && in_array($vars['orderby'],array('exposure','handle','merge-pos'))) {
334
  $vars = array_merge( $vars, array(
335
- 'meta_key' => $vars['orderby'],
336
  'orderby' => 'meta_value'
337
  ) );
338
  }
@@ -346,26 +355,69 @@ class ContentAwareSidebars {
346
  */
347
  public function admin_column_rows($column_name,$post_id) {
348
 
 
 
 
349
  // Load metadata
350
- if(!$this->metadata) $this->init_metadata();
351
 
352
- $current = get_post_meta($post_id,$column_name,true);
353
  $current_from_list = $this->metadata[$column_name]['list'][$current];
354
 
355
- if($column_name == 'handle' && $current < 2) {
356
- $host = $this->metadata['host']['list'][get_post_meta($post_id,'host',true)];
357
- $current_from_list .= ": ".$host;
358
  }
359
  echo $current_from_list;
360
  }
361
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
  /**
363
  *
364
  * Add admin rows actions
365
  *
366
  */
367
  public function sidebar_row_actions($actions, $post) {
368
- if($post->post_type == 'sidebar') {
 
 
369
  return array_merge(
370
  array_slice($actions, 0, 2, true),
371
  array(
@@ -394,8 +446,8 @@ class ContentAwareSidebars {
394
 
395
  $id = 'ca-sidebar-'.$post->ID;
396
 
397
- // Check for correct handling
398
- if ($post->handle == 2)
399
  continue;
400
 
401
  // Sidebar might not have any widgets. Get it anyway!
@@ -438,7 +490,7 @@ class ContentAwareSidebars {
438
  // Front page
439
  if(is_front_page()) {
440
 
441
- $joins .= "LEFT JOIN $wpdb->postmeta static ON static.post_id = posts.ID AND static.meta_key = 'static' ";
442
 
443
  $where .= "(static.meta_value LIKE '%front-page%') AND ";
444
  $where .= "exposure.meta_value <= '1' AND ";
@@ -446,21 +498,6 @@ class ContentAwareSidebars {
446
  // Single content
447
  } elseif(is_singular()) {
448
 
449
- // Post Type
450
- $joins .= "LEFT JOIN $wpdb->postmeta post_types ON post_types.post_id = posts.ID AND post_types.meta_key = 'post_types' ";
451
- $where .= "(post_types.meta_value LIKE '%".serialize(get_post_type())."%' OR post_types.meta_value LIKE '%".serialize((string)get_the_ID())."%'";
452
-
453
- //Author
454
- $joins .= "LEFT JOIN $wpdb->postmeta authors ON authors.post_id = posts.ID AND authors.meta_key = 'authors' ";
455
- $where .= "OR (authors.meta_value LIKE '%authors%' OR authors.meta_value LIKE '%".serialize((string)$post->post_author)."%')";
456
-
457
- //Page Template
458
- $template = get_post_meta(get_the_ID(),'_wp_page_template',true);
459
- if($template && $template != 'default') {
460
- $joins .= "LEFT JOIN $wpdb->postmeta page_templates ON page_templates.post_id = posts.ID AND page_templates.meta_key = 'page_templates' ";
461
- $where .= "OR (page_templates.meta_value LIKE '%page_templates%' OR page_templates.meta_value LIKE '%".$template."%')";
462
- }
463
-
464
  // Check if content has any taxonomies supported
465
  $post_taxonomies = get_object_taxonomies(get_post_type());
466
  if($post_taxonomies) {
@@ -470,24 +507,47 @@ class ContentAwareSidebars {
470
  $terms = array();
471
  $taxonomies = array();
472
 
 
 
473
  //Grab posts terms and make where rules for taxonomies.
474
  foreach($post_terms as $term) {
475
  $terms[] = $term->slug;
476
  if(!isset($taxonomies[$term->taxonomy])) {
477
- $where .= " OR post_tax.meta_value LIKE '%".$taxonomies[$term->taxonomy] = $term->taxonomy."%'";
478
  }
479
  }
480
 
481
  $joins .= "LEFT JOIN $wpdb->term_relationships term ON term.object_id = posts.ID ";
482
  $joins .= "LEFT JOIN $wpdb->term_taxonomy taxonomy ON taxonomy.term_taxonomy_id = term.term_taxonomy_id ";
483
  $joins .= "LEFT JOIN $wpdb->terms terms ON terms.term_id = taxonomy.term_id ";
484
- $joins .= "LEFT JOIN $wpdb->postmeta post_tax ON post_tax.post_id = posts.ID AND post_tax.meta_key = 'taxonomies'";
485
 
486
- $where .= " OR terms.slug IN('".implode("','",$terms)."')";
 
487
  }
488
  }
489
-
490
- $where .= ") AND ";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
  $where .= "exposure.meta_value <= '1' AND ";
492
 
493
  // Taxonomy archives
@@ -498,7 +558,7 @@ class ContentAwareSidebars {
498
  $joins .= "LEFT JOIN $wpdb->term_relationships term ON term.object_id = posts.ID ";
499
  $joins .= "LEFT JOIN $wpdb->term_taxonomy taxonomy ON taxonomy.term_taxonomy_id = term.term_taxonomy_id ";
500
  $joins .= "LEFT JOIN $wpdb->terms terms ON terms.term_id = taxonomy.term_id ";
501
- $joins .= "LEFT JOIN $wpdb->postmeta post_tax ON post_tax.post_id = posts.ID AND post_tax.meta_key = 'taxonomies'";
502
 
503
  $where .= "(terms.slug = '$term->slug'";
504
  $where .= " OR post_tax.meta_value LIKE '%".serialize($term->taxonomy)."%'";
@@ -511,28 +571,28 @@ class ContentAwareSidebars {
511
  // Home has post as default post type
512
  if(!$post_type) $post_type = 'post';
513
 
514
- $joins .= "LEFT JOIN $wpdb->postmeta post_types ON post_types.post_id = posts.ID AND post_types.meta_key = 'post_types' ";
515
  $where .= "(post_types.meta_value LIKE '%".serialize($post_type)."%') AND ";
516
  $where .= "exposure.meta_value >= '1' AND ";
517
 
518
- // Search
519
  } elseif(is_author()) {
520
 
521
- $joins .= "LEFT JOIN $wpdb->postmeta authors ON authors.post_id = posts.ID AND authors.meta_key = 'authors' ";
522
  $where .= "(authors.meta_value LIKE '%authors%' OR authors.meta_value LIKE '%".serialize((string)get_query_var('author'))."%') AND ";
523
  $where .= "exposure.meta_value >= '1' AND ";
524
 
525
  // Search
526
  } elseif(is_search()) {
527
 
528
- $joins .= "LEFT JOIN $wpdb->postmeta static ON static.post_id = posts.ID AND static.meta_key = 'static' ";
529
  $where .= "(static.meta_value LIKE '%search%') AND ";
530
  $where .= "exposure.meta_value <= '1' AND ";
531
 
532
  // 404
533
  } elseif(is_404()) {
534
 
535
- $joins .= "LEFT JOIN $wpdb->postmeta static ON static.post_id = posts.ID AND static.meta_key = 'static' ";
536
  $where .= "(static.meta_value LIKE '%404%') AND ";
537
  $where .= "exposure.meta_value <= '1' AND ";
538
 
@@ -550,6 +610,7 @@ class ContentAwareSidebars {
550
  $where .= "posts.post_status ".$post_status."";
551
 
552
  // Do query and cache it
 
553
  $this->sidebar_cache = $wpdb->get_results("
554
  SELECT
555
  posts.ID,
@@ -559,16 +620,16 @@ class ContentAwareSidebars {
559
  FROM $wpdb->posts posts
560
  LEFT JOIN $wpdb->postmeta handle
561
  ON handle.post_id = posts.ID
562
- AND handle.meta_key = 'handle'
563
  LEFT JOIN $wpdb->postmeta host
564
  ON host.post_id = posts.ID
565
- AND host.meta_key = 'host'
566
  LEFT JOIN $wpdb->postmeta merge_pos
567
  ON merge_pos.post_id = posts.ID
568
- AND merge_pos.meta_key = 'merge-pos'
569
  LEFT JOIN $wpdb->postmeta exposure
570
  ON exposure.post_id = posts.ID
571
- AND exposure.meta_key = 'exposure'
572
  $joins
573
  WHERE
574
  posts.post_type = 'sidebar' AND
@@ -590,7 +651,7 @@ class ContentAwareSidebars {
590
  public function create_meta_boxes() {
591
 
592
  // Load metadata
593
- $this->init_metadata();
594
 
595
  // Add boxes
596
  // Author Words
@@ -652,13 +713,59 @@ class ContentAwareSidebars {
652
  );
653
  }
654
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
655
  /**
656
  *
657
  * Options content
658
  *
659
  */
660
  public function meta_box_content() {
661
- $this->form_fields();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
662
  }
663
 
664
  /**
@@ -686,7 +793,7 @@ class ContentAwareSidebars {
686
  }
687
 
688
  public function meta_box_taxonomy($post, $box) {
689
- $meta = get_post_meta($post->ID, 'taxonomies', true);
690
  $current = $meta != '' ? $meta : array();
691
 
692
  $taxonomy = $box['args'];
@@ -711,7 +818,7 @@ class ContentAwareSidebars {
711
  </div>
712
 
713
  <div id="<?php echo $taxonomy->name; ?>-all" class="tabs-panel" style="height:inherit;max-height:200px;">
714
- <input type="hidden" name="<?php echo ($taxonomy->name == "category" ? "post_category[]" : "tax_input['.$taxonomy->name.']"); ?>" value="0" />
715
  <ul id="<?php echo $taxonomy->name; ?>checklist" class="list:<?php echo $taxonomy->name?> categorychecklist form-no-clear">
716
  <?php cas_terms_checklist($post->ID, array('taxonomy' => $taxonomy,'popular_terms' => $popular_ids, 'terms' => $terms)) ?>
717
  </ul>
@@ -721,13 +828,13 @@ class ContentAwareSidebars {
721
  }
722
 
723
  echo '<p style="padding:6px 0 4px;">'."\n";
724
- echo '<label><input type="checkbox" name="taxonomies[]" value="'.$taxonomy->name.'"'.(in_array($taxonomy->name,$current) ? ' checked="checked"' : '').' /> '.sprintf(__('Show with %s'),$taxonomy->labels->all_items).'</label>'."\n";
725
  echo '</p>'."\n";
726
 
727
  }
728
 
729
  public function meta_box_post_type($post, $box) {
730
- $meta = get_post_meta($post->ID, 'post_types', true);
731
  $current = $meta != '' ? $meta : array();
732
  $post_type = $box['args'];
733
 
@@ -765,14 +872,14 @@ class ContentAwareSidebars {
765
 
766
  //WP3.1.4 does not support $post_type->labels->all_items
767
  echo '<p style="padding:6px 0 4px;">'."\n";
768
- echo '<label><input type="checkbox" name="post_types[]" value="'.$post_type->name.'"'.(in_array($post_type->name,$current) ? ' checked="checked"' : '').' /> '.sprintf(__('Show with All %s'),$post_type->label).'</label>'."\n";
769
  echo '</p>'."\n";
770
 
771
  }
772
 
773
  public function meta_box_checkboxes($post, $box) {
774
  $field = $box['args'];
775
- $meta = get_post_meta($post->ID, $field, true);
776
  $current = $meta != '' ? $meta : array();
777
  ?>
778
  <div id="list-<?php echo $field; ?>" class="categorydiv">
@@ -790,101 +897,42 @@ class ContentAwareSidebars {
790
  </div>
791
  </div>
792
  <p style="padding:6px 0 4px;">
793
- <label><input type="checkbox" name="<?php echo $field; ?>[]" value="<?php echo $field; ?>"<?php echo (in_array($field,$current) ? ' checked="checked"' : ''); ?> /> <?php _e('Show with All '.$this->metadata[$field]['name']); ?></label>
794
  </p>
795
  <?php
796
  }
797
 
798
  /**
799
  *
800
- * Hide some meta boxes from start
801
- *
802
- */
803
- function change_default_hidden( $hidden, $screen ) {
804
- global $wp_version;
805
-
806
- //WordPress 3.3 has changed get_hidden_meta_boxes().
807
- if($wp_version < 3.3) {
808
- $condition = $screen->base == 'sidebar';
809
- } else {
810
- $condition = $screen->post_type == 'sidebar';
811
- }
812
-
813
- if ($condition && get_user_option( 'metaboxhidden_sidebar' ) === false) {
814
-
815
- $hidden_meta_boxes = array('postexcerpt','pageparentdiv','ca-sidebar-tax-post_format','ca-sidebar-post-type-attachment','ca-sidebar-authors');
816
- $hidden = array_merge($hidden,$hidden_meta_boxes);
817
-
818
- $user = wp_get_current_user();
819
- update_user_option( $user->ID, 'metaboxhidden_sidebar', $hidden, true );
820
-
821
- }
822
- return $hidden;
823
- }
824
-
825
- /**
826
- *
827
- * Create form fields
828
  *
829
  */
830
- private function form_fields($array = array(), $show_name = 1) {
831
  global $post;
832
-
833
- ?>
834
- <table class="form-table">
835
- <?php
836
- if(!empty($array)) {
837
- $array = array_intersect_key($this->metadata,array_keys($array));
838
- } else {
839
- $array = $this->metadata;
840
- unset($array['taxonomies']);
841
- unset($array['post_types']);
842
- unset($array['authors']);
843
- unset($array['page_templates']);
844
- }
845
-
846
- foreach($array as $setting) :
847
 
848
- $meta = get_post_meta($post->ID, $setting['id'], true);
849
- $current = $meta != '' ? $meta : $setting['val'];
850
- ?>
851
-
852
- <tr valign="top">
853
- <?php if($show_name) echo '<th scope="row">'.$setting['name'].'</th>'; ?>
854
- <td>
855
- <?php switch($setting['type']) :
856
- case 'select' :
857
- echo '<select style="width:200px;" name="'.$setting['id'].'">'."\n";
858
- foreach($setting['list'] as $key => $value) {
859
- echo '<option value="'.$key.'"'.($key == $current ? ' selected="selected"' : '').'>'.$value.'</option>'."\n";
860
- }
861
- echo '</select>'."\n";
862
- break;
863
- case 'select-multi' :
864
- echo '<select multiple="multiple" size="5" style="width:200px;height:60px;" name="'.$setting['id'].'[]">'."\n";
865
- foreach($setting['list'] as $key => $value) {
866
- echo '<option value="'.$key.'"'.(in_array($key,$current) ? ' selected="selected"' : '').'>'.$value.'</option>'."\n";
867
- }
868
- echo '</select>'."\n";
869
- break;
870
- case 'checkbox' :
871
- echo '<ul>'."\n";
872
- foreach($setting['list'] as $key => $value) {
873
- echo '<li><label><input type="checkbox" name="'.$setting['id'].'[]" value="'.$key.'"'.(in_array($key,$current) ? ' checked="checked"' : '').' /> '.$value.'</label></li>'."\n";
874
- }
875
- echo '</ul>'."\n";
876
- break;
877
- case 'text' :
878
- default :
879
- echo '<input style="width:200px;" type="text" name="'.$setting['id'].'" value="'.$current.'" />'."\n";
880
- break;
881
- endswitch; ?>
882
- <br /><span class="description"><?php echo $setting['desc'] ?></span>
883
- </td>
884
- </tr>
885
- <?php endforeach; ?>
886
- </table>
887
- <?php
888
  }
889
 
890
  /**
@@ -915,29 +963,51 @@ class ContentAwareSidebars {
915
  return;
916
 
917
  // Load metadata
918
- $this->init_metadata();
919
 
920
  // Update metadata
921
  foreach ($this->metadata as $field) {
922
- $old = get_post_meta($post_id, $field['id'], true);
923
  $new = isset($_POST[$field['id']]) ? $_POST[$field['id']] : '';
924
 
925
  if ($new != '' && $new != $old) {
926
- update_post_meta($post_id, $field['id'], $new);
927
  } elseif ($new == '' && $old != '') {
928
- delete_post_meta($post_id, $field['id'], $old);
929
  }
930
  }
931
  }
932
 
933
  /**
934
  *
935
- * Flush rewrite rules on plugin activation
936
  *
937
  */
938
- public function upon_activation() {
939
- $this->init_sidebar_type();
940
- flush_rewrite_rules();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
941
  }
942
 
943
  /**
@@ -945,28 +1015,30 @@ class ContentAwareSidebars {
945
  * Load dependencies
946
  *
947
  */
948
- private function load_dependencies() {
949
 
950
  require_once('walker.php');
 
951
 
952
  }
953
-
954
  /**
955
  *
956
- * Load scripts for administration
957
  *
958
  */
959
- public function load_admin_scripts() {
960
- wp_enqueue_script('cas_admin');
 
961
  }
962
 
963
  /**
964
  *
965
- * Prepare scripts for administration
966
  *
967
  */
968
- public function prepare_admin_scripts() {
969
- wp_register_script('cas_admin', WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__)).'/js/cas_admin.js', array('jquery'), '0.1');
970
  }
971
 
972
  }
@@ -1027,4 +1099,4 @@ function display_ca_sidebar($args = array()) {
1027
  dynamic_sidebar($host);
1028
  echo $after;
1029
  }
1030
- }
6
  Plugin Name: Content Aware Sidebars
7
  Plugin URI: http://www.intox.dk/
8
  Description: Manage and show sidebars according to the content being viewed.
9
+ Version: 0.8.3
10
  Author: Joachim Jensen
11
  Author URI: http://www.intox.dk/
12
  Text Domain: content-aware-sidebars
13
  Domain Path: /lang/
14
  License: GPL2
15
 
16
+ Copyright 2011-2012 Joachim Jensen (email : jv@intox.dk)
17
 
18
  This program is free software; you can redistribute it and/or modify
19
  it under the terms of the GNU General Public License, version 2, as
31
  */
32
  class ContentAwareSidebars {
33
 
34
+ const db_version = '0.8';
35
+ const prefix = '_cas_';
36
+
37
  protected $metadata = array();
38
  protected $post_types = array();
39
  protected $post_type_objects = array();
48
  */
49
  public function __construct() {
50
 
51
+ $this->_load_dependencies();
52
 
53
  add_filter('wp', array(&$this,'replace_sidebar'));
54
  add_filter('request', array(&$this,'admin_column_orderby'));
58
  add_filter('manage_posts_custom_column', array(&$this,'admin_column_rows'),10,3);
59
  add_filter('post_row_actions', array(&$this,'sidebar_row_actions'),10,2);
60
  add_filter('post_updated_messages', array(&$this,'sidebar_updated_messages'));
61
+
62
+ add_action('init', array(&$this,'init_sidebar_type'),99);
63
  add_action('widgets_init', array(&$this,'create_sidebars'));
64
  add_action('add_meta_boxes_sidebar', array(&$this,'create_meta_boxes'));
65
+ add_action('admin_init', array(&$this,'prepare_admin_scripts_styles'));
66
  add_action('admin_menu', array(&$this,'clear_admin_menu'));
67
+ add_action('admin_print_scripts-edit.php', array(&$this,'load_admin_scripts'));
68
  add_action('admin_print_scripts-post-new.php', array(&$this,'load_admin_scripts'));
69
  add_action('admin_print_scripts-post.php', array(&$this,'load_admin_scripts'));
70
+ add_action('save_post', array(&$this,'save_post'));
71
+ add_action('delete_post', array(&$this,'remove_sidebar_widgets'));
72
+ add_action('wp_loaded', array(&$this,'db_update'));
73
 
74
+ register_activation_hook(__FILE__, array(&$this,'plugin_activation'));
75
+ register_deactivation_hook(__FILE__, array(&$this,'plugin_deactivation'));
76
 
77
  }
78
 
81
  * Create post meta fields
82
  *
83
  */
84
+ private function _init_metadata() {
85
  global $post, $wp_registered_sidebars, $wpdb;
86
 
87
  // List of sidebars
146
  'exposure' => array(
147
  'name' => __('Exposure', 'content-aware-sidebars'),
148
  'id' => 'exposure',
149
+ 'desc' => '',
150
  'val' => 1,
151
  'type' => 'select',
152
  'list' => array(
170
  'host' => array(
171
  'name' => __('Host Sidebar', 'content-aware-sidebars'),
172
  'id' => 'host',
173
+ 'desc' => '',
174
  'val' => 'sidebar-1',
175
  'type' => 'select',
176
  'list' => $sidebar_list
232
  'supports' => array('title','excerpt','page-attributes'),
233
  'taxonomies' => array_keys($this->taxonomies),
234
  'menu_icon' => WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__)).'/icon-16.png'
235
+ ));
236
  }
237
 
238
  /**
240
  * Create update messages
241
  *
242
  */
243
+ public function sidebar_updated_messages( $messages ) {
244
  global $post;
245
  $messages['sidebar'] = array(
246
  0 => '',
265
  * Remove taxonomy shortcuts from menu and standard meta boxes.
266
  *
267
  */
268
+ public function clear_admin_menu() {
269
  foreach($this->taxonomies as $key => $value) {
270
  remove_submenu_page('edit.php?post_type=sidebar','edit-tags.php?taxonomy='.$key.'&amp;post_type=sidebar');
271
  remove_meta_box('tagsdiv-'.$key, 'sidebar', 'side');
279
  *
280
  */
281
  public function create_sidebars() {
282
+
283
  //WP3.1 does not support (array) as post_status
284
  $posts = get_posts(array(
285
  'numberposts' => -1,
286
  'post_type' => 'sidebar',
287
  'post_status' => 'publish,private,future'
288
  ));
289
+ foreach($posts as $post) {
290
  register_sidebar( array(
291
  'name' => $post->post_title,
292
  'description' => $post->post_excerpt,
296
  'before_title' => '<h3 class="widget-title">',
297
  'after_title' => '</h3>',
298
  ));
299
+ }
300
  }
301
 
302
  /**
319
 
320
  /**
321
  *
322
+ * Make some columns sortable
323
  *
324
  */
325
  public function admin_column_sortable_headers($columns) {
341
  public function admin_column_orderby($vars) {
342
  if (isset($vars['orderby']) && in_array($vars['orderby'],array('exposure','handle','merge-pos'))) {
343
  $vars = array_merge( $vars, array(
344
+ 'meta_key' => self::prefix.$vars['orderby'],
345
  'orderby' => 'meta_value'
346
  ) );
347
  }
355
  */
356
  public function admin_column_rows($column_name,$post_id) {
357
 
358
+ if(get_post_type($post_id) != 'sidebar')
359
+ return;
360
+
361
  // Load metadata
362
+ if(!$this->metadata) $this->_init_metadata();
363
 
364
+ $current = get_post_meta($post_id,self::prefix.$column_name,true);
365
  $current_from_list = $this->metadata[$column_name]['list'][$current];
366
 
367
+ if($column_name == 'handle' && $current < 2) {
368
+ $host = get_post_meta($post_id,self::prefix.'host',true);
369
+ $current_from_list .= ": ".(isset($this->metadata['host']['list'][$host]) ? $this->metadata['host']['list'][$host] : "HOST NOT FOUND");
370
  }
371
  echo $current_from_list;
372
  }
373
 
374
+ /**
375
+ *
376
+ * Remove widget when its sidebar is removed
377
+ *
378
+ */
379
+ public function remove_sidebar_widgets($post_id) {
380
+
381
+ // Authenticate and only continue on sidebar post type
382
+ if(!current_user_can('delete_posts') || get_post_type($post_id) != 'sidebar')
383
+ return;
384
+
385
+ $id = 'ca-sidebar-'.$post_id;
386
+
387
+ //Get widgets
388
+ $sidebars_widgets = wp_get_sidebars_widgets();
389
+
390
+ // Check if sidebar exists in database
391
+ if(!isset($sidebars_widgets[$id]))
392
+ return;
393
+
394
+ // Remove widgets settings from sidebar
395
+ foreach($sidebars_widgets[$id] as $widget_id) {
396
+ $widget_type = preg_replace( '/-[0-9]+$/', '', $widget_id );
397
+ $widget_settings = get_option('widget_'.$widget_type);
398
+ $widget_id = substr($widget_id,strpos($widget_id,'-')+1);
399
+ if($widget_settings && isset($widget_settings[$widget_id])) {
400
+ unset($widget_settings[$widget_id]);
401
+ update_option('widget_'.$widget_type,$widget_settings);
402
+ }
403
+ }
404
+
405
+ // Remove sidebar
406
+ unset($sidebars_widgets[$id]);
407
+ wp_set_sidebars_widgets($sidebars_widgets);
408
+
409
+
410
+ }
411
+
412
  /**
413
  *
414
  * Add admin rows actions
415
  *
416
  */
417
  public function sidebar_row_actions($actions, $post) {
418
+ if($post->post_type == 'sidebar' && $post->post_status != 'trash') {
419
+ //View link is still there in WP3.1
420
+ if(isset($actions['view'])) unset($actions['view']);
421
  return array_merge(
422
  array_slice($actions, 0, 2, true),
423
  array(
446
 
447
  $id = 'ca-sidebar-'.$post->ID;
448
 
449
+ // Check for correct handling and if host exist
450
+ if ($post->handle == 2 || !isset($_wp_sidebars_widgets[$post->host]))
451
  continue;
452
 
453
  // Sidebar might not have any widgets. Get it anyway!
490
  // Front page
491
  if(is_front_page()) {
492
 
493
+ $joins .= "LEFT JOIN $wpdb->postmeta static ON static.post_id = posts.ID AND static.meta_key = '".self::prefix."static' ";
494
 
495
  $where .= "(static.meta_value LIKE '%front-page%') AND ";
496
  $where .= "exposure.meta_value <= '1' AND ";
498
  // Single content
499
  } elseif(is_singular()) {
500
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
501
  // Check if content has any taxonomies supported
502
  $post_taxonomies = get_object_taxonomies(get_post_type());
503
  if($post_taxonomies) {
507
  $terms = array();
508
  $taxonomies = array();
509
 
510
+ $where .= "(";
511
+
512
  //Grab posts terms and make where rules for taxonomies.
513
  foreach($post_terms as $term) {
514
  $terms[] = $term->slug;
515
  if(!isset($taxonomies[$term->taxonomy])) {
516
+ $where .= "post_tax.meta_value LIKE '%".$taxonomies[$term->taxonomy] = $term->taxonomy."%' OR ";
517
  }
518
  }
519
 
520
  $joins .= "LEFT JOIN $wpdb->term_relationships term ON term.object_id = posts.ID ";
521
  $joins .= "LEFT JOIN $wpdb->term_taxonomy taxonomy ON taxonomy.term_taxonomy_id = term.term_taxonomy_id ";
522
  $joins .= "LEFT JOIN $wpdb->terms terms ON terms.term_id = taxonomy.term_id ";
523
+ $joins .= "LEFT JOIN $wpdb->postmeta post_tax ON post_tax.post_id = posts.ID AND post_tax.meta_key = '".self::prefix."taxonomies'";
524
 
525
+ $where .= "terms.slug IN('".implode("','",$terms)."') ";
526
+ $where .= ") OR ";
527
  }
528
  }
529
+
530
+ // Post Type
531
+ $joins .= "LEFT JOIN $wpdb->postmeta post_types ON post_types.post_id = posts.ID AND post_types.meta_key = '".self::prefix."post_types' ";
532
+ $where .= "((post_types.meta_value IS NULL OR (post_types.meta_value LIKE '%".serialize(get_post_type())."%' OR post_types.meta_value LIKE '%".serialize((string)get_the_ID())."%'))";
533
+ $where2 = "AND (post_types.meta_value IS NOT NULL";
534
+
535
+ //Author
536
+ $joins .= "LEFT JOIN $wpdb->postmeta authors ON authors.post_id = posts.ID AND authors.meta_key = '".self::prefix."authors' ";
537
+ $where .= " AND (authors.meta_value IS NULL OR (authors.meta_value LIKE '%authors%' OR authors.meta_value LIKE '%".serialize((string)$post->post_author)."%'))";
538
+ $where2 .= " OR authors.meta_value IS NOT NULL";
539
+
540
+ //Page Template
541
+ $template = get_post_meta(get_the_ID(),'_wp_page_template',true);
542
+ if($template && $template != 'default') {
543
+ $joins .= "LEFT JOIN $wpdb->postmeta page_templates ON page_templates.post_id = posts.ID AND page_templates.meta_key = '".self::prefix."page_templates' ";
544
+ $where .= " AND (page_templates.meta_value IS NULL OR (page_templates.meta_value LIKE '%page_templates%' OR page_templates.meta_value LIKE '%".$template."%'))";
545
+ $where2 .= " OR page_templates.meta_value IS NOT NULL";
546
+ }
547
+
548
+ $where2 .= ")";
549
+
550
+ $where .= $where2.") AND ";
551
  $where .= "exposure.meta_value <= '1' AND ";
552
 
553
  // Taxonomy archives
558
  $joins .= "LEFT JOIN $wpdb->term_relationships term ON term.object_id = posts.ID ";
559
  $joins .= "LEFT JOIN $wpdb->term_taxonomy taxonomy ON taxonomy.term_taxonomy_id = term.term_taxonomy_id ";
560
  $joins .= "LEFT JOIN $wpdb->terms terms ON terms.term_id = taxonomy.term_id ";
561
+ $joins .= "LEFT JOIN $wpdb->postmeta post_tax ON post_tax.post_id = posts.ID AND post_tax.meta_key = '".self::prefix."taxonomies'";
562
 
563
  $where .= "(terms.slug = '$term->slug'";
564
  $where .= " OR post_tax.meta_value LIKE '%".serialize($term->taxonomy)."%'";
571
  // Home has post as default post type
572
  if(!$post_type) $post_type = 'post';
573
 
574
+ $joins .= "LEFT JOIN $wpdb->postmeta post_types ON post_types.post_id = posts.ID AND post_types.meta_key = '".self::prefix."post_types' ";
575
  $where .= "(post_types.meta_value LIKE '%".serialize($post_type)."%') AND ";
576
  $where .= "exposure.meta_value >= '1' AND ";
577
 
578
+ // Author archive
579
  } elseif(is_author()) {
580
 
581
+ $joins .= "LEFT JOIN $wpdb->postmeta authors ON authors.post_id = posts.ID AND authors.meta_key = '".self::prefix."authors' ";
582
  $where .= "(authors.meta_value LIKE '%authors%' OR authors.meta_value LIKE '%".serialize((string)get_query_var('author'))."%') AND ";
583
  $where .= "exposure.meta_value >= '1' AND ";
584
 
585
  // Search
586
  } elseif(is_search()) {
587
 
588
+ $joins .= "LEFT JOIN $wpdb->postmeta static ON static.post_id = posts.ID AND static.meta_key = '".self::prefix."static' ";
589
  $where .= "(static.meta_value LIKE '%search%') AND ";
590
  $where .= "exposure.meta_value <= '1' AND ";
591
 
592
  // 404
593
  } elseif(is_404()) {
594
 
595
+ $joins .= "LEFT JOIN $wpdb->postmeta static ON static.post_id = posts.ID AND static.meta_key = '".self::prefix."static' ";
596
  $where .= "(static.meta_value LIKE '%404%') AND ";
597
  $where .= "exposure.meta_value <= '1' AND ";
598
 
610
  $where .= "posts.post_status ".$post_status."";
611
 
612
  // Do query and cache it
613
+ $wpdb->query('SET OPTION SQL_BIG_SELECTS = 1');
614
  $this->sidebar_cache = $wpdb->get_results("
615
  SELECT
616
  posts.ID,
620
  FROM $wpdb->posts posts
621
  LEFT JOIN $wpdb->postmeta handle
622
  ON handle.post_id = posts.ID
623
+ AND handle.meta_key = '".self::prefix."handle'
624
  LEFT JOIN $wpdb->postmeta host
625
  ON host.post_id = posts.ID
626
+ AND host.meta_key = '".self::prefix."host'
627
  LEFT JOIN $wpdb->postmeta merge_pos
628
  ON merge_pos.post_id = posts.ID
629
+ AND merge_pos.meta_key = '".self::prefix."merge-pos'
630
  LEFT JOIN $wpdb->postmeta exposure
631
  ON exposure.post_id = posts.ID
632
+ AND exposure.meta_key = '".self::prefix."exposure'
633
  $joins
634
  WHERE
635
  posts.post_type = 'sidebar' AND
651
  public function create_meta_boxes() {
652
 
653
  // Load metadata
654
+ $this->_init_metadata();
655
 
656
  // Add boxes
657
  // Author Words
713
  );
714
  }
715
 
716
+
717
+ /**
718
+ *
719
+ * Hide some meta boxes from start
720
+ *
721
+ */
722
+ public function change_default_hidden( $hidden, $screen ) {
723
+ global $wp_version;
724
+
725
+ //WordPress 3.3 has changed get_hidden_meta_boxes().
726
+ if($wp_version < 3.3) {
727
+ $condition = $screen->base == 'sidebar';
728
+ } else {
729
+ $condition = $screen->post_type == 'sidebar';
730
+ }
731
+
732
+ if ($condition && get_user_option( 'metaboxhidden_sidebar' ) === false) {
733
+
734
+ $hidden_meta_boxes = array('postexcerpt','pageparentdiv','ca-sidebar-tax-post_format','ca-sidebar-post-type-attachment','ca-sidebar-authors');
735
+ $hidden = array_merge($hidden,$hidden_meta_boxes);
736
+
737
+ $user = wp_get_current_user();
738
+ update_user_option( $user->ID, 'metaboxhidden_sidebar', $hidden, true );
739
+
740
+ }
741
+ return $hidden;
742
+ }
743
+
744
  /**
745
  *
746
  * Options content
747
  *
748
  */
749
  public function meta_box_content() {
750
+ $columns = array(
751
+ 'static',
752
+ 'exposure',
753
+ 'handle' => 'handle,host',
754
+ 'merge-pos'
755
+ );
756
+
757
+ echo '<table class="form-table">';
758
+ foreach($columns as $key => $value) {
759
+
760
+ echo '<tr><th scope="row">'.$this->metadata[is_numeric($key) ? $value : $key]['name'].'</th>';
761
+ echo '<td>';
762
+ $values = explode(',',$value);
763
+ foreach($values as $val) {
764
+ $this->_form_field($val);
765
+ }
766
+ echo '</td></tr>';
767
+ }
768
+ echo '</table>';
769
  }
770
 
771
  /**
793
  }
794
 
795
  public function meta_box_taxonomy($post, $box) {
796
+ $meta = get_post_meta($post->ID, self::prefix.'taxonomies', true);
797
  $current = $meta != '' ? $meta : array();
798
 
799
  $taxonomy = $box['args'];
818
  </div>
819
 
820
  <div id="<?php echo $taxonomy->name; ?>-all" class="tabs-panel" style="height:inherit;max-height:200px;">
821
+ <input type="hidden" name="<?php echo ($taxonomy->name == "category" ? "post_category[]" : "tax_input[$taxonomy->name]"); ?>" value="0" />
822
  <ul id="<?php echo $taxonomy->name; ?>checklist" class="list:<?php echo $taxonomy->name?> categorychecklist form-no-clear">
823
  <?php cas_terms_checklist($post->ID, array('taxonomy' => $taxonomy,'popular_terms' => $popular_ids, 'terms' => $terms)) ?>
824
  </ul>
828
  }
829
 
830
  echo '<p style="padding:6px 0 4px;">'."\n";
831
+ echo '<label><input type="checkbox" name="taxonomies[]" value="'.$taxonomy->name.'"'.(in_array($taxonomy->name,$current) ? ' checked="checked"' : '').' /> '.sprintf(__('Show with %s','content-aware-sidebars'),$taxonomy->labels->all_items).'</label>'."\n";
832
  echo '</p>'."\n";
833
 
834
  }
835
 
836
  public function meta_box_post_type($post, $box) {
837
+ $meta = get_post_meta($post->ID, self::prefix.'post_types', true);
838
  $current = $meta != '' ? $meta : array();
839
  $post_type = $box['args'];
840
 
872
 
873
  //WP3.1.4 does not support $post_type->labels->all_items
874
  echo '<p style="padding:6px 0 4px;">'."\n";
875
+ echo '<label><input type="checkbox" name="post_types[]" value="'.$post_type->name.'"'.(in_array($post_type->name,$current) ? ' checked="checked"' : '').' /> '.sprintf(__('Show with All %s','content-aware-sidebars'),$post_type->label).'</label>'."\n";
876
  echo '</p>'."\n";
877
 
878
  }
879
 
880
  public function meta_box_checkboxes($post, $box) {
881
  $field = $box['args'];
882
+ $meta = get_post_meta($post->ID, self::prefix.$field, true);
883
  $current = $meta != '' ? $meta : array();
884
  ?>
885
  <div id="list-<?php echo $field; ?>" class="categorydiv">
897
  </div>
898
  </div>
899
  <p style="padding:6px 0 4px;">
900
+ <label><input type="checkbox" name="<?php echo $field; ?>[]" value="<?php echo $field; ?>"<?php echo (in_array($field,$current) ? ' checked="checked"' : ''); ?> /> <?php printf(__('Show with All %s','content-aware-sidebars'),$this->metadata[$field]['name']); ?></label>
901
  </p>
902
  <?php
903
  }
904
 
905
  /**
906
  *
907
+ * Create form field for metadata
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
908
  *
909
  */
910
+ private function _form_field($setting) {
911
  global $post;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
912
 
913
+ $meta = get_post_meta($post->ID, self::prefix.$setting, true);
914
+ $setting = $this->metadata[$setting];
915
+ $current = $meta != '' ? $meta : $setting['val'];
916
+ switch($setting['type']) {
917
+ case 'select' :
918
+ echo '<select style="width:200px;" name="'.$setting['id'].'">'."\n";
919
+ foreach($setting['list'] as $key => $value) {
920
+ echo '<option value="'.$key.'"'.($key == $current ? ' selected="selected"' : '').'>'.$value.'</option>'."\n";
921
+ }
922
+ echo '</select>'."\n";
923
+ break;
924
+ case 'checkbox' :
925
+ echo '<ul>'."\n";
926
+ foreach($setting['list'] as $key => $value) {
927
+ echo '<li><label><input type="checkbox" name="'.$setting['id'].'[]" value="'.$key.'"'.(in_array($key,$current) ? ' checked="checked"' : '').' /> '.$value.'</label></li>'."\n";
928
+ }
929
+ echo '</ul>'."\n";
930
+ break;
931
+ case 'text' :
932
+ default :
933
+ echo '<input style="width:200px;" type="text" name="'.$setting['id'].'" value="'.$current.'" />'."\n";
934
+ break;
935
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
936
  }
937
 
938
  /**
963
  return;
964
 
965
  // Load metadata
966
+ $this->_init_metadata();
967
 
968
  // Update metadata
969
  foreach ($this->metadata as $field) {
970
+ $old = get_post_meta($post_id, self::prefix.$field['id'], true);
971
  $new = isset($_POST[$field['id']]) ? $_POST[$field['id']] : '';
972
 
973
  if ($new != '' && $new != $old) {
974
+ update_post_meta($post_id, self::prefix.$field['id'], $new);
975
  } elseif ($new == '' && $old != '') {
976
+ delete_post_meta($post_id, self::prefix.$field['id'], $old);
977
  }
978
  }
979
  }
980
 
981
  /**
982
  *
983
+ * Database data update module
984
  *
985
  */
986
+ public function db_update() {
987
+ cas_run_db_update(self::db_version);
988
+ }
989
+
990
+ /**
991
+ *
992
+ * Load scripts and styles for administration
993
+ *
994
+ */
995
+ public function load_admin_scripts() {
996
+ global $pagenow;
997
+ if($pagenow != 'edit.php') {
998
+ wp_enqueue_script('cas_admin_script');
999
+ }
1000
+ wp_enqueue_style('cas_admin_style');
1001
+ }
1002
+
1003
+ /**
1004
+ *
1005
+ * Prepare scripts and styles for administration
1006
+ *
1007
+ */
1008
+ public function prepare_admin_scripts_styles() {
1009
+ wp_register_script('cas_admin_script', WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__)).'/js/cas_admin.js', array('jquery'), '0.1');
1010
+ wp_register_style('cas_admin_style', WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__)).'/style.css', false, '0.1');
1011
  }
1012
 
1013
  /**
1015
  * Load dependencies
1016
  *
1017
  */
1018
+ private function _load_dependencies() {
1019
 
1020
  require_once('walker.php');
1021
+ require_once('update_db.php');
1022
 
1023
  }
1024
+
1025
  /**
1026
  *
1027
+ * Flush rewrite rules on plugin activation
1028
  *
1029
  */
1030
+ public function plugin_activation() {
1031
+ $this->init_sidebar_type();
1032
+ flush_rewrite_rules();
1033
  }
1034
 
1035
  /**
1036
  *
1037
+ * Flush rewrite rules on plugin deactivation
1038
  *
1039
  */
1040
+ public function plugin_deactivation() {
1041
+ flush_rewrite_rules();
1042
  }
1043
 
1044
  }
1099
  dynamic_sidebar($host);
1100
  echo $after;
1101
  }
1102
+ }
js/cas_admin.js CHANGED
@@ -2,7 +2,7 @@
2
  * @package Content Aware Sidebars
3
  */
4
  jQuery(document).ready(function($) {
5
-
6
  handleAllCheckbox("post_types","posttype");
7
  handleAllCheckbox("taxonomies","taxonomy");
8
  handleAllCheckbox("authors","list");
@@ -32,7 +32,8 @@ jQuery(document).ready(function($) {
32
 
33
  /**
34
  *
35
- * The state of a "Show with All" checkbox will control the accessibility of the respective checkboxes for specific entities
 
36
  * If state is checked, they will be disabled
37
  *
38
  */
@@ -68,16 +69,21 @@ jQuery(document).ready(function($) {
68
 
69
  /**
70
  *
71
- * The value of Handle selection will control the accessibility of the host sidebar selection
 
72
  * If Handling is manual, selection of host sidebar will be disabled
73
  *
74
  */
75
  function endisableHostSidebars(select) {
76
  var name = "select[name='host']";
77
- if(select.val() == 2)
 
78
  $(name).attr("disabled", true);
79
- else
 
 
80
  $(name).removeAttr("disabled");
 
81
  }
82
 
83
  });
2
  * @package Content Aware Sidebars
3
  */
4
  jQuery(document).ready(function($) {
5
+
6
  handleAllCheckbox("post_types","posttype");
7
  handleAllCheckbox("taxonomies","taxonomy");
8
  handleAllCheckbox("authors","list");
32
 
33
  /**
34
  *
35
+ * The state of a "Show with All" checkbox will control the
36
+ * accessibility of the respective checkboxes for specific entities
37
  * If state is checked, they will be disabled
38
  *
39
  */
69
 
70
  /**
71
  *
72
+ * The value of Handle selection will control the
73
+ * accessibility of the host sidebar selection
74
  * If Handling is manual, selection of host sidebar will be disabled
75
  *
76
  */
77
  function endisableHostSidebars(select) {
78
  var name = "select[name='host']";
79
+ if(select.val() == 2) {
80
+ $(name).hide();
81
  $(name).attr("disabled", true);
82
+
83
+ } else {
84
+ $(name).show();
85
  $(name).removeAttr("disabled");
86
+ }
87
  }
88
 
89
  });
lang/content-aware-sidebars-da_DK.mo ADDED
Binary file
lang/content-aware-sidebars-da_DK.po ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.3\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-04-23 22:25+0100\n"
12
+ "Last-Translator: Joachim Jensen <jv@intox.dk>\n"
13
+ "Language-Team: Intox Studio <jv@intox.dk>\n"
14
+ "X-Poedit-Language: Danish\n"
15
+ "X-Poedit-Country: DENMARK\n"
16
+
17
+ #: content-aware-sidebars.php:103
18
+ msgid "Post Types"
19
+ msgstr "Indholdstyper"
20
+
21
+ #: content-aware-sidebars.php:111
22
+ msgid "Taxonomies"
23
+ msgstr "Taksonomier"
24
+
25
+ #: content-aware-sidebars.php:119
26
+ msgid "Authors"
27
+ msgstr "Forfattere"
28
+
29
+ #: content-aware-sidebars.php:127
30
+ msgid "Page Templates"
31
+ msgstr "Skabeloner"
32
+
33
+ #: content-aware-sidebars.php:135
34
+ msgid "Static Pages"
35
+ msgstr "Statiske sider"
36
+
37
+ #: content-aware-sidebars.php:141
38
+ msgid "Front Page"
39
+ msgstr "Forside"
40
+
41
+ #: content-aware-sidebars.php:142
42
+ msgid "Search Results"
43
+ msgstr "Søgeresultater"
44
+
45
+ #: content-aware-sidebars.php:143
46
+ msgid "404 Page"
47
+ msgstr "404-side"
48
+
49
+ #: content-aware-sidebars.php:147
50
+ #: content-aware-sidebars.php:312
51
+ msgid "Exposure"
52
+ msgstr "Eksponering"
53
+
54
+ #: content-aware-sidebars.php:153
55
+ msgid "Singular"
56
+ msgstr "Singulær"
57
+
58
+ #: content-aware-sidebars.php:154
59
+ msgid "Singular & Archive"
60
+ msgstr "Singulær og arkiv"
61
+
62
+ #: content-aware-sidebars.php:155
63
+ msgid "Archive"
64
+ msgstr "Arkiv"
65
+
66
+ #: content-aware-sidebars.php:159
67
+ #: content-aware-sidebars.php:313
68
+ msgctxt "option"
69
+ msgid "Handle"
70
+ msgstr "Håndtering"
71
+
72
+ #: content-aware-sidebars.php:161
73
+ msgid "Replace host sidebar, merge with it or add sidebar manually."
74
+ msgstr "Erstat værts-sidebar, flet med den eller tilføj denne sidebar manuelt."
75
+
76
+ #: content-aware-sidebars.php:165
77
+ msgid "Replace"
78
+ msgstr "Erstat"
79
+
80
+ #: content-aware-sidebars.php:166
81
+ msgid "Merge"
82
+ msgstr "Flet"
83
+
84
+ #: content-aware-sidebars.php:167
85
+ msgid "Manual"
86
+ msgstr "Manuel"
87
+
88
+ #: content-aware-sidebars.php:171
89
+ msgid "Host Sidebar"
90
+ msgstr "Værts-sidebar"
91
+
92
+ #: content-aware-sidebars.php:179
93
+ #: content-aware-sidebars.php:314
94
+ msgid "Merge position"
95
+ msgstr "Fletteposition"
96
+
97
+ #: content-aware-sidebars.php:181
98
+ msgid "Place sidebar on top or bottom of host when merging."
99
+ msgstr "Flet ind fra oven eller bunden."
100
+
101
+ #: content-aware-sidebars.php:185
102
+ msgid "Top"
103
+ msgstr "Top"
104
+
105
+ #: content-aware-sidebars.php:186
106
+ msgid "Bottom"
107
+ msgstr "Bund"
108
+
109
+ #: content-aware-sidebars.php:216
110
+ msgid "Sidebars"
111
+ msgstr "Sidebars"
112
+
113
+ #: content-aware-sidebars.php:217
114
+ msgid "Sidebar"
115
+ msgstr "Sidebar"
116
+
117
+ #: content-aware-sidebars.php:218
118
+ msgctxt "sidebar"
119
+ msgid "Add New"
120
+ msgstr "Tilføj ny"
121
+
122
+ #: content-aware-sidebars.php:219
123
+ msgid "Add New Sidebar"
124
+ msgstr "Tilføj ny sidebar"
125
+
126
+ #: content-aware-sidebars.php:220
127
+ msgid "Edit Sidebar"
128
+ msgstr "Rediger sidebar"
129
+
130
+ #: content-aware-sidebars.php:221
131
+ msgid "New Sidebar"
132
+ msgstr "Ny sidebar"
133
+
134
+ #: content-aware-sidebars.php:222
135
+ msgid "All Sidebars"
136
+ msgstr "Alle sidebars"
137
+
138
+ #: content-aware-sidebars.php:223
139
+ msgid "View Sidebar"
140
+ msgstr "Vis sidebar"
141
+
142
+ #: content-aware-sidebars.php:224
143
+ msgid "Search Sidebars"
144
+ msgstr "Søg sidebars"
145
+
146
+ #: content-aware-sidebars.php:225
147
+ msgid "No sidebars found"
148
+ msgstr "Ingen sidebars fundet"
149
+
150
+ #: content-aware-sidebars.php:226
151
+ msgid "No sidebars found in Trash"
152
+ msgstr "Ingen sidebars fundet i papirkurven"
153
+
154
+ #: content-aware-sidebars.php:247
155
+ msgid "Sidebar updated. <a href=\"%s\">Manage widgets</a>"
156
+ msgstr "Sidebar opdateret. <a href=\"%s\">Håndter widgets</a>"
157
+
158
+ #: content-aware-sidebars.php:250
159
+ msgid "Sidebar updated."
160
+ msgstr "Sidebar opdateret."
161
+
162
+ #: content-aware-sidebars.php:252
163
+ msgid "Sidebar published. <a href=\"%s\">Manage widgets</a>"
164
+ msgstr "Sidebar udgivet. <a href=\"%s\">Håndter widgets</a>"
165
+
166
+ #: content-aware-sidebars.php:253
167
+ msgid "Sidebar saved."
168
+ msgstr "Sidebar gemt."
169
+
170
+ #: content-aware-sidebars.php:254
171
+ msgid "Sidebar submitted. <a href=\"%s\">Manage widgets</a>"
172
+ msgstr "Sidebar indsendt. <a href=\"%s\">Håndter widgets</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 "Sidebar planlagt til: <strong>%1$s</strong>. <a href=\"%2$s\">Håndter widgets</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 "j. M, Y @ G:i"
182
+
183
+ #: content-aware-sidebars.php:258
184
+ msgid "Sidebar draft updated. <a href=\"%s\">Manage widgets</a>"
185
+ msgstr "Sidebar-udkast opdateret. <a href=\"%s\">Håndter widgets</a>"
186
+
187
+ #: content-aware-sidebars.php:421
188
+ msgid "Manage Widgets"
189
+ msgstr "Håndter widgets"
190
+
191
+ #: content-aware-sidebars.php:656
192
+ msgid "Words from the author"
193
+ msgstr "Et par ord fra forfatteren"
194
+
195
+ #: content-aware-sidebars.php:704
196
+ msgid "Options"
197
+ msgstr "Indstillinger"
198
+
199
+ #: content-aware-sidebars.php:781
200
+ msgid "If you love this plugin, please consider donating."
201
+ msgstr "Venligst overvej at donere, hvis du elsker dette plugin."
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 "Glem ikke at <a class=\"button\" href=\"%1$s\" target=\"_blank\">vurdere</a> og <a class=\"button\" href=\"%2$s\" target=\"_blank\">dele</a> det!"
206
+
207
+ #: content-aware-sidebars.php:785
208
+ msgid "Check out Content Aware Sidebars for %23WordPress! :)"
209
+ msgstr "Jeg bruger Content Aware Sidebars til %23WordPress! :)"
210
+
211
+ #: content-aware-sidebars.php:800
212
+ #: content-aware-sidebars.php:852
213
+ msgid "No items."
214
+ msgstr "Ingen elementer."
215
+
216
+ #: content-aware-sidebars.php:806
217
+ msgid "Most Used"
218
+ msgstr "Mest brugte"
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 "Vis alle"
225
+
226
+ #: content-aware-sidebars.php:827
227
+ msgid "Show with %s"
228
+ msgstr "Vis ved %s"
229
+
230
+ #: content-aware-sidebars.php:871
231
+ msgid "Show with All %s"
232
+ msgstr "Vis ved alle %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 "Administrer og vis sidebars i henhold til det indhold, der vises."
248
+
249
+ #. Author of the plugin/theme
250
+ msgid "Joachim Jensen"
251
+ msgstr "Joachim Jensen"
252
+
lang/content-aware-sidebars-it_IT.mo ADDED
Binary file
lang/content-aware-sidebars-it_IT.po ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.3\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-04-23 22:09+0100\n"
12
+ "Last-Translator: Joachim Jensen <jv@intox.dk>\n"
13
+ "Language-Team: MyWeb2 <info@myweb2.it>\n"
14
+ "X-Poedit-Language: Italian\n"
15
+ "X-Poedit-Country: ITALY\n"
16
+
17
+ #: content-aware-sidebars.php:103
18
+ msgid "Post Types"
19
+ msgstr "Tipi di messaggi"
20
+
21
+ #: content-aware-sidebars.php:111
22
+ msgid "Taxonomies"
23
+ msgstr "Tassonomie"
24
+
25
+ #: content-aware-sidebars.php:119
26
+ msgid "Authors"
27
+ msgstr "Autori"
28
+
29
+ #: content-aware-sidebars.php:127
30
+ msgid "Page Templates"
31
+ msgstr "Template Pagine"
32
+
33
+ #: content-aware-sidebars.php:135
34
+ msgid "Static Pages"
35
+ msgstr "Pagine Statiche"
36
+
37
+ #: content-aware-sidebars.php:141
38
+ msgid "Front Page"
39
+ msgstr "Pagina Principale"
40
+
41
+ #: content-aware-sidebars.php:142
42
+ msgid "Search Results"
43
+ msgstr "Risultati di Ricerca"
44
+
45
+ #: content-aware-sidebars.php:143
46
+ msgid "404 Page"
47
+ msgstr "Pagina 404"
48
+
49
+ #: content-aware-sidebars.php:147
50
+ #: content-aware-sidebars.php:312
51
+ msgid "Exposure"
52
+ msgstr "Tipologia"
53
+
54
+ #: content-aware-sidebars.php:153
55
+ msgid "Singular"
56
+ msgstr "Singola"
57
+
58
+ #: content-aware-sidebars.php:154
59
+ msgid "Singular & Archive"
60
+ msgstr "Singola e Archivio"
61
+
62
+ #: content-aware-sidebars.php:155
63
+ msgid "Archive"
64
+ msgstr "Archivio"
65
+
66
+ #: content-aware-sidebars.php:159
67
+ #: content-aware-sidebars.php:313
68
+ msgctxt "option"
69
+ msgid "Handle"
70
+ msgstr "Comportamento e Posizione"
71
+
72
+ #: content-aware-sidebars.php:161
73
+ msgid "Replace host sidebar, merge with it or add sidebar manually."
74
+ msgstr "Sostituisce host sidebar, si fonde con essa o aggiunge la sidebar manualmente."
75
+
76
+ #: content-aware-sidebars.php:165
77
+ msgid "Replace"
78
+ msgstr "Sostituisci"
79
+
80
+ #: content-aware-sidebars.php:166
81
+ msgid "Merge"
82
+ msgstr "Fondi"
83
+
84
+ #: content-aware-sidebars.php:167
85
+ msgid "Manual"
86
+ msgstr "Manuale"
87
+
88
+ #: content-aware-sidebars.php:171
89
+ msgid "Host Sidebar"
90
+ msgstr "Sidebar Host"
91
+
92
+ #: content-aware-sidebars.php:179
93
+ #: content-aware-sidebars.php:314
94
+ msgid "Merge position"
95
+ msgstr "Fondi posizione"
96
+
97
+ #: content-aware-sidebars.php:181
98
+ msgid "Place sidebar on top or bottom of host when merging."
99
+ msgstr "Posizione sidebar in alto o in basso dell'host durante la fusione."
100
+
101
+ #: content-aware-sidebars.php:185
102
+ msgid "Top"
103
+ msgstr "Alto"
104
+
105
+ #: content-aware-sidebars.php:186
106
+ msgid "Bottom"
107
+ msgstr "Basso"
108
+
109
+ #: content-aware-sidebars.php:216
110
+ msgid "Sidebars"
111
+ msgstr "Sidebars"
112
+
113
+ #: content-aware-sidebars.php:217
114
+ msgid "Sidebar"
115
+ msgstr "Sidebar"
116
+
117
+ #: content-aware-sidebars.php:218
118
+ msgctxt "sidebar"
119
+ msgid "Add New"
120
+ msgstr "Aggiungi"
121
+
122
+ #: content-aware-sidebars.php:219
123
+ msgid "Add New Sidebar"
124
+ msgstr "Aggiungi Nuova Sidebar"
125
+
126
+ #: content-aware-sidebars.php:220
127
+ msgid "Edit Sidebar"
128
+ msgstr "Modifica Sidebar"
129
+
130
+ #: content-aware-sidebars.php:221
131
+ msgid "New Sidebar"
132
+ msgstr "Nuova Sidebar"
133
+
134
+ #: content-aware-sidebars.php:222
135
+ msgid "All Sidebars"
136
+ msgstr "Tutte le Sidebars"
137
+
138
+ #: content-aware-sidebars.php:223
139
+ msgid "View Sidebar"
140
+ msgstr "Vedi Sidebar"
141
+
142
+ #: content-aware-sidebars.php:224
143
+ msgid "Search Sidebars"
144
+ msgstr "Cerca Sidebars"
145
+
146
+ #: content-aware-sidebars.php:225
147
+ msgid "No sidebars found"
148
+ msgstr "Nessuna sidebars trovata"
149
+
150
+ #: content-aware-sidebars.php:226
151
+ msgid "No sidebars found in Trash"
152
+ msgstr "nessuna sidebar cancellata"
153
+
154
+ #: content-aware-sidebars.php:247
155
+ msgid "Sidebar updated. <a href=\"%s\">Manage widgets</a>"
156
+ msgstr "Sidebar aggiornata. <a href=\"%s\">Gestione widgets</a>"
157
+
158
+ #: content-aware-sidebars.php:250
159
+ msgid "Sidebar updated."
160
+ msgstr "Sidebar aggiornata."
161
+
162
+ #: content-aware-sidebars.php:252
163
+ msgid "Sidebar published. <a href=\"%s\">Manage widgets</a>"
164
+ msgstr "Sidebar publicata. <a href=\"%s\">Gestione widgets</a>"
165
+
166
+ #: content-aware-sidebars.php:253
167
+ msgid "Sidebar saved."
168
+ msgstr "Sidebar salvata."
169
+
170
+ #: content-aware-sidebars.php:254
171
+ msgid "Sidebar submitted. <a href=\"%s\">Manage widgets</a>"
172
+ msgstr "Sidebar inviata. <a href=\"%s\">Gestione widgets</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 "Sidebar posticipata per: <strong>%1$s</strong>. <a href=\"%2$s\">Gestione widgets</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 "Bozza sidebar aggiornata. <a href=\"%s\">Gestione widgets</a>"
186
+
187
+ #: content-aware-sidebars.php:421
188
+ msgid "Manage Widgets"
189
+ msgstr "Gestione Widgets"
190
+
191
+ #: content-aware-sidebars.php:656
192
+ msgid "Words from the author"
193
+ msgstr "Parole dell'autore"
194
+
195
+ #: content-aware-sidebars.php:704
196
+ msgid "Options"
197
+ msgstr "Opzioni"
198
+
199
+ #: content-aware-sidebars.php:781
200
+ msgid "If you love this plugin, please consider donating."
201
+ msgstr "Se ti piae questo plugin, considera di fare una donazione."
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 "Ricorda di <a class=\"button\" href=\"%1$s\" target=\"_blank\">valutarlo</a> e <a class=\"button\" href=\"%2$s\" target=\"_blank\">condiverlo</a>!"
206
+
207
+ #: content-aware-sidebars.php:785
208
+ msgid "Check out Content Aware Sidebars for %23WordPress! :)"
209
+ msgstr "Verifica Content Aware Sidebars per %23WordPress! :)"
210
+
211
+ #: content-aware-sidebars.php:800
212
+ #: content-aware-sidebars.php:852
213
+ msgid "No items."
214
+ msgstr "Nessun oggetto."
215
+
216
+ #: content-aware-sidebars.php:806
217
+ msgid "Most Used"
218
+ msgstr "Più usati"
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 "Vedi tutti"
225
+
226
+ #: content-aware-sidebars.php:827
227
+ msgid "Show with %s"
228
+ msgstr "Mostra %s"
229
+
230
+ #: content-aware-sidebars.php:871
231
+ msgid "Show with All %s"
232
+ msgstr "Mostra tutti %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 "Gestisce e mostra sidebars a seconda del contenuto visualizzato."
248
+
249
+ #. Author of the plugin/theme
250
+ msgid "Joachim Jensen"
251
+ msgstr "Joachim Jensen"
252
+
lang/content-aware-sidebars.pot ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-MO-DA HO:MI+ZONE\n"
12
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
+ "Language-Team: LANGUAGE <LL@li.org>\n"
14
+
15
+ #: content-aware-sidebars.php:103
16
+ msgid "Post Types"
17
+ msgstr ""
18
+
19
+ #: content-aware-sidebars.php:111
20
+ msgid "Taxonomies"
21
+ msgstr ""
22
+
23
+ #: content-aware-sidebars.php:119
24
+ msgid "Authors"
25
+ msgstr ""
26
+
27
+ #: content-aware-sidebars.php:127
28
+ msgid "Page Templates"
29
+ msgstr ""
30
+
31
+ #: content-aware-sidebars.php:135
32
+ msgid "Static Pages"
33
+ msgstr ""
34
+
35
+ #: content-aware-sidebars.php:141
36
+ msgid "Front Page"
37
+ msgstr ""
38
+
39
+ #: content-aware-sidebars.php:142
40
+ msgid "Search Results"
41
+ msgstr ""
42
+
43
+ #: content-aware-sidebars.php:143
44
+ msgid "404 Page"
45
+ msgstr ""
46
+
47
+ #: content-aware-sidebars.php:147 content-aware-sidebars.php:312
48
+ msgid "Exposure"
49
+ msgstr ""
50
+
51
+ #: content-aware-sidebars.php:153
52
+ msgid "Singular"
53
+ msgstr ""
54
+
55
+ #: content-aware-sidebars.php:154
56
+ msgid "Singular & Archive"
57
+ msgstr ""
58
+
59
+ #: content-aware-sidebars.php:155
60
+ msgid "Archive"
61
+ msgstr ""
62
+
63
+ #: content-aware-sidebars.php:159 content-aware-sidebars.php:313
64
+ msgctxt "option"
65
+ msgid "Handle"
66
+ msgstr ""
67
+
68
+ #: content-aware-sidebars.php:161
69
+ msgid "Replace host sidebar, merge with it or add sidebar manually."
70
+ msgstr ""
71
+
72
+ #: content-aware-sidebars.php:165
73
+ msgid "Replace"
74
+ msgstr ""
75
+
76
+ #: content-aware-sidebars.php:166
77
+ msgid "Merge"
78
+ msgstr ""
79
+
80
+ #: content-aware-sidebars.php:167
81
+ msgid "Manual"
82
+ msgstr ""
83
+
84
+ #: content-aware-sidebars.php:171
85
+ msgid "Host Sidebar"
86
+ msgstr ""
87
+
88
+ #: content-aware-sidebars.php:179 content-aware-sidebars.php:314
89
+ msgid "Merge position"
90
+ msgstr ""
91
+
92
+ #: content-aware-sidebars.php:181
93
+ msgid "Place sidebar on top or bottom of host when merging."
94
+ msgstr ""
95
+
96
+ #: content-aware-sidebars.php:185
97
+ msgid "Top"
98
+ msgstr ""
99
+
100
+ #: content-aware-sidebars.php:186
101
+ msgid "Bottom"
102
+ msgstr ""
103
+
104
+ #: content-aware-sidebars.php:216
105
+ msgid "Sidebars"
106
+ msgstr ""
107
+
108
+ #: content-aware-sidebars.php:217
109
+ msgid "Sidebar"
110
+ msgstr ""
111
+
112
+ #: content-aware-sidebars.php:218
113
+ msgctxt "sidebar"
114
+ msgid "Add New"
115
+ msgstr ""
116
+
117
+ #: content-aware-sidebars.php:219
118
+ msgid "Add New Sidebar"
119
+ msgstr ""
120
+
121
+ #: content-aware-sidebars.php:220
122
+ msgid "Edit Sidebar"
123
+ msgstr ""
124
+
125
+ #: content-aware-sidebars.php:221
126
+ msgid "New Sidebar"
127
+ msgstr ""
128
+
129
+ #: content-aware-sidebars.php:222
130
+ msgid "All Sidebars"
131
+ msgstr ""
132
+
133
+ #: content-aware-sidebars.php:223
134
+ msgid "View Sidebar"
135
+ msgstr ""
136
+
137
+ #: content-aware-sidebars.php:224
138
+ msgid "Search Sidebars"
139
+ msgstr ""
140
+
141
+ #: content-aware-sidebars.php:225
142
+ msgid "No sidebars found"
143
+ msgstr ""
144
+
145
+ #: content-aware-sidebars.php:226
146
+ msgid "No sidebars found in Trash"
147
+ msgstr ""
148
+
149
+ #: content-aware-sidebars.php:247
150
+ msgid "Sidebar updated. <a href=\"%s\">Manage widgets</a>"
151
+ msgstr ""
152
+
153
+ #: content-aware-sidebars.php:250
154
+ msgid "Sidebar updated."
155
+ msgstr ""
156
+
157
+ #: content-aware-sidebars.php:252
158
+ msgid "Sidebar published. <a href=\"%s\">Manage widgets</a>"
159
+ msgstr ""
160
+
161
+ #: content-aware-sidebars.php:253
162
+ msgid "Sidebar saved."
163
+ msgstr ""
164
+
165
+ #: content-aware-sidebars.php:254
166
+ msgid "Sidebar submitted. <a href=\"%s\">Manage widgets</a>"
167
+ msgstr ""
168
+
169
+ #: content-aware-sidebars.php:255
170
+ msgid ""
171
+ "Sidebar scheduled for: <strong>%1$s</strong>. <a href=\"%2$s\">Manage "
172
+ "widgets</a>"
173
+ msgstr ""
174
+
175
+ #. translators: Publish box date format, see http:php.net/date
176
+ #: content-aware-sidebars.php:257
177
+ msgid "M j, Y @ G:i"
178
+ msgstr ""
179
+
180
+ #: content-aware-sidebars.php:258
181
+ msgid "Sidebar draft updated. <a href=\"%s\">Manage widgets</a>"
182
+ msgstr ""
183
+
184
+ #: content-aware-sidebars.php:421
185
+ msgid "Manage Widgets"
186
+ msgstr ""
187
+
188
+ #: content-aware-sidebars.php:656
189
+ msgid "Words from the author"
190
+ msgstr ""
191
+
192
+ #: content-aware-sidebars.php:704
193
+ msgid "Options"
194
+ msgstr ""
195
+
196
+ #: content-aware-sidebars.php:781
197
+ msgid "If you love this plugin, please consider donating."
198
+ msgstr ""
199
+
200
+ #: content-aware-sidebars.php:783
201
+ msgid ""
202
+ "Remember to <a class=\"button\" href=\"%1$s\" target=\"_blank\">rate</a> and "
203
+ "<a class=\"button\" href=\"%2$s\" target=\"_blank\">share</a> it too!"
204
+ msgstr ""
205
+
206
+ #: content-aware-sidebars.php:785
207
+ msgid "Check out Content Aware Sidebars for %23WordPress! :)"
208
+ msgstr ""
209
+
210
+ #: content-aware-sidebars.php:800 content-aware-sidebars.php:852
211
+ msgid "No items."
212
+ msgstr ""
213
+
214
+ #: content-aware-sidebars.php:806
215
+ msgid "Most Used"
216
+ msgstr ""
217
+
218
+ #: content-aware-sidebars.php:807 content-aware-sidebars.php:858
219
+ #: content-aware-sidebars.php:883
220
+ msgid "View All"
221
+ msgstr ""
222
+
223
+ #: content-aware-sidebars.php:827
224
+ msgid "Show with %s"
225
+ msgstr ""
226
+
227
+ #: content-aware-sidebars.php:871
228
+ msgid "Show with All %s"
229
+ msgstr ""
230
+
231
+ #. Plugin Name of the plugin/theme
232
+ msgid "Content Aware Sidebars"
233
+ msgstr ""
234
+
235
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 0.8.2) #-#-#-#-#
236
+ #. Plugin URI of the plugin/theme
237
+ #. #-#-#-#-# plugin.pot (Content Aware Sidebars 0.8.2) #-#-#-#-#
238
+ #. Author URI of the plugin/theme
239
+ msgid "http://www.intox.dk/"
240
+ msgstr ""
241
+
242
+ #. Description of the plugin/theme
243
+ msgid "Manage and show sidebars according to the content being viewed."
244
+ msgstr ""
245
+
246
+ #. Author of the plugin/theme
247
+ msgid "Joachim Jensen"
248
+ msgstr ""
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
- === Plugin Name ===
2
  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, content aware, post type, taxonomy, term, archive, singular, seo
5
  Requires at least: 3.1
6
- Tested up to: 3.3
7
- Stable tag: 0.7
8
 
9
  Manage and show sidebars according to the content being viewed.
10
 
@@ -31,7 +31,11 @@ No extra database tables or table columns will be added.
31
 
32
  = Translations =
33
 
34
- Content Aware Sidebars can now be translated. If you want to help, please contact jv[at]intox.dk.
 
 
 
 
35
 
36
  = Contact =
37
 
@@ -42,25 +46,24 @@ www.intox.dk
42
  1. Upload the full plugin directory to your `/wp-content/plugins/` directory or install the plugin through `Plugins` in the administration
43
  1. Activate the plugin through `Plugins` in the administration
44
  1. Have fun creating your first sidebar
45
- 1. Optional: Insert `<?php display_ca_sidebar(); ?>` in a template if you have a special spot for the new, manual handled, sidebars.
46
 
47
  == Frequently Asked Questions ==
48
 
49
- If you have any questions not answered here, feel free to contact jv[at]intox.dk.
50
-
51
- = How do I use `display_ca_sidebar()`? =
52
 
53
- This function 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:
54
 
55
- `include` (array|string)
56
- Insert IDs of sidebars. By using this, the function will only handle the sidebars whose IDs are included. Default is `null`.
57
 
58
- `before` (string)
59
- Change the html to be displayed before the sidebar. Default is `<div id="sidebar" class="widget-area"><ul class="xoxo">`.
 
 
 
60
 
61
- `after` (string)
62
- Change the html to be displayed after the sidebar. Default is `</ul></div>`.
63
 
 
64
  The function accepts URL-style strings as parameters too, like the standard WordPress Template Tags.
65
 
66
  == Screenshots ==
@@ -73,6 +76,37 @@ The function accepts URL-style strings as parameters too, like the standard Word
73
 
74
  == Changelog ==
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  = 0.7 =
77
 
78
  * Added: sidebars will be displayed even if empty (i.e. hidden)
@@ -82,8 +116,8 @@ The function accepts URL-style strings as parameters too, like the standard Word
82
  * Fixed: minor tweak for full compatibility with wp3.3
83
  * Fixed: function for meta boxes is called only on editor page
84
  * Fixed: proper column sorting in administration
85
- * Fixed: specific post type label not supported in WP3.1.x
86
- * Fixed: type (array) not supported as post_status in get_posts() in WP3.1.x
87
  * Fixed: code cleanup
88
 
89
  = 0.6.3 =
@@ -144,6 +178,10 @@ The function accepts URL-style strings as parameters too, like the standard Word
144
 
145
  == Upgrade Notice ==
146
 
 
 
 
 
147
  = 0.5 =
148
 
149
  * Note that the plugin now requires at least WordPress 3.1 because of post type archives.
@@ -155,4 +193,4 @@ The function accepts URL-style strings as parameters too, like the standard Word
155
  = 0.1 =
156
 
157
  * Hello World
158
-
1
+ === Plugin Name ===
2
  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, content aware, post type, taxonomy, term, archive, singular, seo, dynamic
5
  Requires at least: 3.1
6
+ Tested up to: 3.3.2
7
+ Stable tag: 0.8.3
8
 
9
  Manage and show sidebars according to the content being viewed.
10
 
31
 
32
  = Translations =
33
 
34
+ * Danish (da_DK): [Joachim Jensen](http://www.intox.dk/)
35
+ * Italian (it_IT): [Luciano Del Fico](http://www.myweb2.it/)
36
+
37
+ 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.
38
+ 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/).
39
 
40
  = Contact =
41
 
46
  1. Upload the full plugin directory to your `/wp-content/plugins/` directory or install the plugin through `Plugins` in the administration
47
  1. Activate the plugin through `Plugins` in the administration
48
  1. Have fun creating your first sidebar
49
+ 1. Optional: Insert `<?php display_ca_sidebar( $args ); ?>` in a template if you have a special spot for the new, manual handled, sidebars.
50
 
51
  == Frequently Asked Questions ==
52
 
53
+ 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/).
 
 
54
 
55
+ = How do I use display_ca_sidebar( $args )? =
56
 
57
+ 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:
 
58
 
59
+ `$args = array(
60
+ 'include' => '',
61
+ 'before' => '<div id="sidebar" class="widget-area"><ul class="xoxo">',
62
+ 'after' => '</ul></div>'
63
+ );`
64
 
 
 
65
 
66
+ If ID's of specific sidebars are passed to `include`, the function will only handle these. The visuals of the content aware sidebars can be modified by passing `before` and `after`.
67
  The function accepts URL-style strings as parameters too, like the standard WordPress Template Tags.
68
 
69
  == Screenshots ==
76
 
77
  == Changelog ==
78
 
79
+ = 0.8.3 =
80
+
81
+ * Added: Danish and Italian translation
82
+ * Fixed: sidebar query might be larger than max_join_size
83
+ * Fixed: row content in admin overview would be loaded with post types with matching keys
84
+
85
+ = 0.8.2 =
86
+
87
+ * Fixed: new rules caused issues with post types with taxonomies
88
+
89
+ = 0.8.1 =
90
+
91
+ * Fixed: several checks for proper widget and sidebar removal
92
+
93
+ = 0.8 =
94
+
95
+ * Added: some rules are dependent of each other if present
96
+ * Added: widgets in removed sidebars will be removed too
97
+ * Added: database data update module
98
+ * Added: rewrite rules flushed on plugin deactivation
99
+ * Added: data will be removed when plugin is uninstalled
100
+ * Added: icon-32 is back
101
+ * Added: message if a host is not available in sidebar overview
102
+ * Fixed: prefixed data
103
+ * Fixed: data hidden from custom fields
104
+ * Fixed: manage widgets link removed from trashed sidebars
105
+ * Fixed: view sidebar link removed in wp3.1.x
106
+ * Fixed: all custom taxonomies could not be removed again when assigned to sidebar
107
+ * Fixed: altered options meta box on edit screen
108
+ * Fixed: check if host of sidebar exists before handling it
109
+
110
  = 0.7 =
111
 
112
  * Added: sidebars will be displayed even if empty (i.e. hidden)
116
  * Fixed: minor tweak for full compatibility with wp3.3
117
  * Fixed: function for meta boxes is called only on editor page
118
  * Fixed: proper column sorting in administration
119
+ * Fixed: specific post type label not supported in wp3.1.x
120
+ * Fixed: type (array) not supported as post_status in get_posts() in wp3.1.x
121
  * Fixed: code cleanup
122
 
123
  = 0.6.3 =
178
 
179
  == Upgrade Notice ==
180
 
181
+ = 0.8 =
182
+
183
+ * Content Aware Sidebar data in your database will be updated automatically. Remember to backup this data before updating the plugin.
184
+
185
  = 0.5 =
186
 
187
  * Note that the plugin now requires at least WordPress 3.1 because of post type archives.
193
  = 0.1 =
194
 
195
  * Hello World
196
+
style.css ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ .icon32-posts-sidebar {
2
+ background:transparent url('icon-32.png') no-repeat !important;
3
+ }
4
+ /*#preview-action {
5
+ display:none !important;
6
+ }*/
uninstall.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(!defined('WP_UNINSTALL_PLUGIN')) {
3
+ exit();
4
+ }
5
+
6
+ // Remove db version
7
+ delete_option('cas_db_version');
8
+
9
+ // Remove all sidebars
10
+ $posts = get_posts(array(
11
+ 'numberposts' => -1,
12
+ 'post_type' => 'sidebar',
13
+ 'post_status' => null
14
+ ));
15
+ foreach($posts as $post) {
16
+ wp_delete_post($post->ID, true);
17
+ }
18
+
19
+ ?>
update_db.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function cas_run_db_update($current_version) {
4
+
5
+ if(current_user_can('update_plugins')) {
6
+
7
+ // Get current plugin db version
8
+ $installed_version = get_option('cas_db_version');
9
+ if($installed_version === false)
10
+ $installed_version = 0;
11
+
12
+ // Database is up to date
13
+ if($installed_version == $current_version)
14
+ return true;
15
+
16
+ $versions = array('0.8');
17
+ $retry = array_flip($versions);
18
+
19
+ //Launch updates
20
+ for($i = 0; $i < sizeof($versions); $i++){
21
+ $return = false;
22
+
23
+ //After failing 3 times, something must be wrong
24
+ if($retry[$versions[$i]] == 3) break;
25
+
26
+ if(version_compare($installed_version,$versions[$i],'<')) {
27
+
28
+ $function = 'cas_update_to_'.str_replace('.','',$versions[$i]);
29
+
30
+ if(function_exists($function)) {
31
+ call_user_func_array($function, array(&$return));
32
+ if($return) {
33
+ $installed_version = $versions[$i];
34
+ } else {
35
+ $retry[$versions[$i]]++;
36
+ $i--;
37
+ }
38
+ }
39
+ }
40
+ }
41
+
42
+ // Update database on success
43
+ if($return)
44
+ update_option('cas_db_version',$installed_version);
45
+
46
+ return $return;
47
+ }
48
+ }
49
+
50
+ /**
51
+ *
52
+ * Version 0 -> 0.8
53
+ * Introduces database version management, adds preficed keys to metadata
54
+ *
55
+ */
56
+ function cas_update_to_08($return) {
57
+ global $wpdb;
58
+
59
+ $prefix = '_cas_';
60
+ $metadata = array(
61
+ 'post_types',
62
+ 'taxonomies',
63
+ 'authors',
64
+ 'page_templates',
65
+ 'static',
66
+ 'exposure',
67
+ 'handle',
68
+ 'host',
69
+ 'merge-pos'
70
+ );
71
+
72
+ // Get all sidebars
73
+ $posts = $wpdb->get_col($wpdb->prepare("
74
+ SELECT ID
75
+ FROM $wpdb->posts
76
+ WHERE post_type = %s
77
+ ",'sidebar'));
78
+
79
+ //Check if there is any
80
+ if(empty($posts)) {
81
+ $return = true;
82
+ } else {
83
+ //Update the meta keys
84
+ foreach($metadata as $meta) {
85
+ $wpdb->query("
86
+ UPDATE $wpdb->postmeta
87
+ SET meta_key = '".$prefix.$meta."'
88
+ WHERE meta_key = '".$meta."'
89
+ AND post_id IN(".implode(',',$posts).")
90
+ ");
91
+ }
92
+ }
93
+
94
+ $return = true;
95
+
96
+ }
97
+
98
+ ?>
walker.php CHANGED
@@ -178,7 +178,7 @@ function cas_posts_checklist($post_id = 0, $args = array()) {
178
  );
179
 
180
  if($post_id)
181
- $args['selected_cats'] = (array)get_post_meta($post_id, 'post_types', true);
182
  else
183
  $args['selected_cats'] = array();
184
 
178
  );
179
 
180
  if($post_id)
181
+ $args['selected_cats'] = (array)get_post_meta($post_id, '_cas_post_types', true);
182
  else
183
  $args['selected_cats'] = array();
184