Content Aware Sidebars – Unlimited Widget Areas - Version 2.4

Version Description

  • Added: compatibility with wp4.0
  • Added: better ux design for condition groups
  • Added: better ux design for sidebars in widgets screen, including an edit link
  • Added: dashicon for admin menu (wp3.8+)
  • Fixed: using some newer wordpress actions and filters for admin columns
  • Fixed: sidebars could be fetched and prepared in administration
Download this release

Release Info

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

Code changes from version 2.3 to 2.4

content-aware-sidebars.php CHANGED
@@ -5,9 +5,9 @@
5
  */
6
  /*
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: 2.3
11
  Author: Joachim Jensen, Intox Studio
12
  Author URI: http://www.intox.dk/
13
  Text Domain: content-aware-sidebars
@@ -47,7 +47,7 @@ final class ContentAwareSidebars {
47
  /**
48
  * Plugin version
49
  */
50
- const PLUGIN_VERSION = '2.3';
51
 
52
  /**
53
  * Prefix for data (keys) stored in database
@@ -132,17 +132,18 @@ final class ContentAwareSidebars {
132
  add_action('add_meta_boxes_'.self::TYPE_SIDEBAR, array(&$this,'create_meta_boxes'));
133
  add_action('in_admin_header', array(&$this,'clear_admin_menu'),99);
134
  add_action('transition_post_status', array(&$this,'cascade_sidebar_status'),10,3);
 
 
 
 
135
 
136
  add_filter('request', array(&$this,'admin_column_orderby'));
137
  add_filter('default_hidden_meta_boxes', array(&$this,'change_default_hidden'),10,2);
138
- add_filter('manage_edit-'.self::TYPE_SIDEBAR.'_columns', array(&$this,'admin_column_headers'),99);
139
  add_filter('manage_edit-'.self::TYPE_SIDEBAR.'_sortable_columns',array(&$this,'admin_column_sortable_headers'));
140
- add_filter('manage_posts_custom_column', array(&$this,'admin_column_rows'),10,3);
141
  add_filter('post_row_actions', array(&$this,'sidebar_row_actions'),10,2);
142
  add_filter('post_updated_messages', array(&$this,'sidebar_updated_messages'));
143
-
144
- add_action('wp_ajax_cas_add_rule', array(&$this,'add_sidebar_rule_ajax'));
145
- add_action('wp_ajax_cas_remove_group', array(&$this,'remove_sidebar_group_ajax'));
146
 
147
  //For frontend
148
  } else {
@@ -150,8 +151,10 @@ final class ContentAwareSidebars {
150
 
151
 
152
  }
 
153
  add_action('sidebars_widgets', array(&$this,'replace_sidebar'));
154
  add_action('wp_head',array(&$this,'sidebar_notify_theme_customizer'));
 
155
  //For both
156
  add_action('init', array(&$this,'deploy_modules'));
157
  add_action('init', array(&$this,'init_sidebar_type'),99);
@@ -160,6 +163,25 @@ final class ContentAwareSidebars {
160
 
161
  }
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  /**
164
  * Runs is_active_sidebar for sidebars
165
  * Widget management in Theme Customizer
@@ -207,7 +229,6 @@ final class ContentAwareSidebars {
207
  'author' => true,
208
  'page_template' => true,
209
  'taxonomy' => true,
210
- 'url' => false,
211
  'bbpress' => function_exists('bbp_get_version'), // bbPress
212
  'bp_member' => defined('BP_VERSION'), // BuddyPress
213
  'polylang' => defined('POLYLANG_VERSION'), // Polylang
@@ -339,7 +360,7 @@ final class ContentAwareSidebars {
339
  'rewrite' => false,
340
  'menu_position' => 25.099, //less probable to be overwritten
341
  'supports' => array('title','page-attributes'),
342
- 'menu_icon' => plugins_url('/img/icon-16.png', __FILE__ )
343
  ));
344
 
345
  // Register the condition group type
@@ -503,9 +524,6 @@ final class ContentAwareSidebars {
503
  */
504
  public function admin_column_rows($column_name, $post_id) {
505
 
506
- if (get_post_type($post_id) != self::TYPE_SIDEBAR)
507
- return;
508
-
509
  if($column_name == 'widgets') {
510
  $sidebars_widgets = wp_get_sidebars_widgets();
511
  echo (isset($sidebars_widgets[self::SIDEBAR_PREFIX . $post_id]) ? count($sidebars_widgets[self::SIDEBAR_PREFIX . $post_id]) : 0);
@@ -714,7 +732,7 @@ final class ContentAwareSidebars {
714
  public function get_sidebars() {
715
  global $wpdb;
716
 
717
- if(post_password_required())
718
  return false;
719
 
720
  // Return cache if present
@@ -941,7 +959,7 @@ final class ContentAwareSidebars {
941
  echo '<div id="cas-groups" class="postbox'.(empty($groups) ? '' : ' cas-has-groups').'">'."\n";
942
  echo '<div class="cas-groups-header"><h3>'.__('Condition Groups',self::DOMAIN).'</h3><input type="button" class="button button-primary js-cas-group-new" value="'.__('Add New Group',self::DOMAIN).'" /></div>';
943
  echo '<div class="cas-groups-body"><p>'.__('Click to edit a group or create a new one. Select content on the left to add it. In each group, you can combine different types of associated content.',self::DOMAIN).'</p>';
944
- echo '<h4>'.__('Display sidebar with',self::DOMAIN).':</h4>';
945
 
946
  $i = 0;
947
 
@@ -1304,6 +1322,7 @@ final class ContentAwareSidebars {
1304
  if($current_screen->post_type == self::TYPE_SIDEBAR) {
1305
 
1306
  wp_register_script('cas_admin_script', plugins_url('/js/cas_admin.js', __FILE__), array('jquery'), self::PLUGIN_VERSION, true);
 
1307
  wp_register_style('cas_admin_style', plugins_url('/css/style.css', __FILE__), array(), self::PLUGIN_VERSION);
1308
 
1309
  //Sidebar editor
@@ -1328,6 +1347,16 @@ final class ContentAwareSidebars {
1328
  } else if ($hook == 'edit.php') {
1329
  wp_enqueue_style('cas_admin_style');
1330
  }
 
 
 
 
 
 
 
 
 
 
1331
  }
1332
 
1333
  }
5
  */
6
  /*
7
  Plugin Name: Content Aware Sidebars
8
+ Plugin URI: http://www.intox.dk/en/plugin/content-aware-sidebars-en/
9
  Description: Manage and show sidebars according to the content being viewed.
10
+ Version: 2.4
11
  Author: Joachim Jensen, Intox Studio
12
  Author URI: http://www.intox.dk/
13
  Text Domain: content-aware-sidebars
47
  /**
48
  * Plugin version
49
  */
50
+ const PLUGIN_VERSION = '2.4';
51
 
52
  /**
53
  * Prefix for data (keys) stored in database
132
  add_action('add_meta_boxes_'.self::TYPE_SIDEBAR, array(&$this,'create_meta_boxes'));
133
  add_action('in_admin_header', array(&$this,'clear_admin_menu'),99);
134
  add_action('transition_post_status', array(&$this,'cascade_sidebar_status'),10,3);
135
+ add_action('manage_'.self::TYPE_SIDEBAR.'_posts_custom_column', array(&$this,'admin_column_rows'),10,2);
136
+
137
+ add_action('wp_ajax_cas_add_rule', array(&$this,'add_sidebar_rule_ajax'));
138
+ add_action('wp_ajax_cas_remove_group', array(&$this,'remove_sidebar_group_ajax'));
139
 
140
  add_filter('request', array(&$this,'admin_column_orderby'));
141
  add_filter('default_hidden_meta_boxes', array(&$this,'change_default_hidden'),10,2);
142
+ add_filter('manage_'.self::TYPE_SIDEBAR.'_posts_columns', array(&$this,'admin_column_headers'),99);
143
  add_filter('manage_edit-'.self::TYPE_SIDEBAR.'_sortable_columns',array(&$this,'admin_column_sortable_headers'));
 
144
  add_filter('post_row_actions', array(&$this,'sidebar_row_actions'),10,2);
145
  add_filter('post_updated_messages', array(&$this,'sidebar_updated_messages'));
146
+ add_filter( 'plugin_action_links_'.plugin_basename(__FILE__), array(&$this,'plugin_action_links'), 10, 4 );
 
 
147
 
148
  //For frontend
149
  } else {
151
 
152
 
153
  }
154
+
155
  add_action('sidebars_widgets', array(&$this,'replace_sidebar'));
156
  add_action('wp_head',array(&$this,'sidebar_notify_theme_customizer'));
157
+
158
  //For both
159
  add_action('init', array(&$this,'deploy_modules'));
160
  add_action('init', array(&$this,'init_sidebar_type'),99);
163
 
164
  }
165
 
166
+ /**
167
+ * Add actions to plugin in Plugins screen
168
+ * @author Joachim Jensen <jv@intox.dk>
169
+ * @version 2.4
170
+ * @param array $actions
171
+ * @param string $plugin_file
172
+ * @param [type] $plugin_data
173
+ * @param [type] $context
174
+ * @return array
175
+ */
176
+ public function plugin_action_links($actions, $plugin_file, $plugin_data, $context) {
177
+
178
+ $new_actions = array(
179
+ '<a href="http://www.intox.dk/en/plugin/content-aware-sidebars-en/faq/" target="_blank">'.__('FAQ',self::DOMAIN).'</a>'
180
+ );
181
+
182
+ return array_merge($new_actions,$actions);
183
+ }
184
+
185
  /**
186
  * Runs is_active_sidebar for sidebars
187
  * Widget management in Theme Customizer
229
  'author' => true,
230
  'page_template' => true,
231
  'taxonomy' => true,
 
232
  'bbpress' => function_exists('bbp_get_version'), // bbPress
233
  'bp_member' => defined('BP_VERSION'), // BuddyPress
234
  'polylang' => defined('POLYLANG_VERSION'), // Polylang
360
  'rewrite' => false,
361
  'menu_position' => 25.099, //less probable to be overwritten
362
  'supports' => array('title','page-attributes'),
363
+ 'menu_icon' => version_compare(get_bloginfo('version'), '3.8' ,'>=') ? 'dashicons-welcome-widgets-menus' : plugins_url('/img/icon-16.png', __FILE__ )
364
  ));
365
 
366
  // Register the condition group type
524
  */
525
  public function admin_column_rows($column_name, $post_id) {
526
 
 
 
 
527
  if($column_name == 'widgets') {
528
  $sidebars_widgets = wp_get_sidebars_widgets();
529
  echo (isset($sidebars_widgets[self::SIDEBAR_PREFIX . $post_id]) ? count($sidebars_widgets[self::SIDEBAR_PREFIX . $post_id]) : 0);
732
  public function get_sidebars() {
733
  global $wpdb;
734
 
735
+ if(is_admin() || post_password_required())
736
  return false;
737
 
738
  // Return cache if present
959
  echo '<div id="cas-groups" class="postbox'.(empty($groups) ? '' : ' cas-has-groups').'">'."\n";
960
  echo '<div class="cas-groups-header"><h3>'.__('Condition Groups',self::DOMAIN).'</h3><input type="button" class="button button-primary js-cas-group-new" value="'.__('Add New Group',self::DOMAIN).'" /></div>';
961
  echo '<div class="cas-groups-body"><p>'.__('Click to edit a group or create a new one. Select content on the left to add it. In each group, you can combine different types of associated content.',self::DOMAIN).'</p>';
962
+ echo '<strong>'.__('Display sidebar with',self::DOMAIN).':</strong>';
963
 
964
  $i = 0;
965
 
1322
  if($current_screen->post_type == self::TYPE_SIDEBAR) {
1323
 
1324
  wp_register_script('cas_admin_script', plugins_url('/js/cas_admin.js', __FILE__), array('jquery'), self::PLUGIN_VERSION, true);
1325
+
1326
  wp_register_style('cas_admin_style', plugins_url('/css/style.css', __FILE__), array(), self::PLUGIN_VERSION);
1327
 
1328
  //Sidebar editor
1347
  } else if ($hook == 'edit.php') {
1348
  wp_enqueue_style('cas_admin_style');
1349
  }
1350
+ } else if($current_screen->base == 'widgets') {
1351
+ wp_register_style('cas_admin_style', plugins_url('/css/style.css', __FILE__), array(), self::PLUGIN_VERSION);
1352
+ wp_enqueue_style('cas_admin_style');
1353
+
1354
+ wp_register_script('cas_admin_widgets', plugins_url('/js/widgets.js', __FILE__), array('jquery'), self::PLUGIN_VERSION, true);
1355
+ wp_enqueue_script('cas_admin_widgets');
1356
+ wp_localize_script( 'cas_admin_widgets', 'CASAdmin', array(
1357
+ 'edit' => __('Edit Sidebar', self::DOMAIN)
1358
+ ));
1359
+
1360
  }
1361
 
1362
  }
css/style.css CHANGED
@@ -1,305 +1,5 @@
1
- /**
2
- * @package Content Aware Sidebars
3
- * @author Joachim Jensen <jv@intox.dk>
4
- */
5
-
6
- .icon32-posts-sidebar {
7
- background:transparent url('../img/icon-32.png') no-repeat !important;
8
- }
9
-
10
- .fixed .column-widgets {
11
- width:10%;
12
- }
13
- .fixed .column-merge-pos {
14
- width:20%;
15
- }
16
- .fixed .column-handle {
17
- width:20%;
18
- }
19
-
20
- #cas-rules > .handlediv, #cas-rules > .hndle {
21
- display:none;
22
- }
23
-
24
- #cas-rules.postbox {
25
- background:none;
26
- border:none;
27
- box-shadow: none;
28
- }
29
-
30
- #cas-rules > .inside {
31
- overflow:hidden;
32
- margin:0;
33
- padding:0;
34
- }
35
-
36
- #cas-container {
37
- overflow:hidden;
38
- width:100%;
39
- }
40
-
41
- #cas-accordion {
42
- float:left;
43
- width:280px;
44
- }
45
-
46
- #cas-accordion .outer-border {
47
- margin:0;
48
- }
49
-
50
- #cas-accordion.accordion-container .accordion-section:first-child,
51
- #cas-accordion.accordion-container .accordion-section:first-child h3,
52
- #cas-accordion.accordion-container .top,
53
- #cas-accordion.accordion-container .top h3 {
54
- border-top-left-radius: 3px;
55
- border-top-right-radius: 3px;
56
- border-top:none;
57
- }
58
-
59
- #cas-accordion.accordion-container .accordion-section:last-child,
60
- #cas-accordion.accordion-container .accordion-section:last-child .accordion-section-content,
61
- #cas-accordion.accordion-container .bottom,
62
- #cas-accordion.accordion-container .bottom:not(.open) h3 {
63
- border-bottom-left-radius: 3px;
64
- border-bottom-right-radius: 3px;
65
- }
66
-
67
- .js #cas-accordion .accordion-section-title {
68
- cursor: pointer;
69
- border-radius:0!important;
70
- box-shadow:none!important;
71
- border-bottom-width: 0;
72
- }
73
-
74
- #cas-accordion .accordion-section-title {
75
- padding: 10px 20px;
76
- margin:0!important;
77
- overflow:hidden;
78
- border-left:none;
79
- border-right:none;
80
- }
81
-
82
- #cas-accordion .control-section.open .accordion-section-title {
83
- border-bottom:1px solid #DFDFDF;
84
- }
85
-
86
- #cas-accordion .accordion-section-content {
87
- padding: 18px 13px;
88
- font-size: 13px;
89
- border-left:none;
90
- border-right:none;
91
- }
92
-
93
- #cas-accordion .accordion-section {
94
- margin:0;
95
- border-bottom: 1px solid #DFDFDF;
96
- }
97
-
98
- .js #cas-accordion .accordion-section:not(.open) .accordion-section-content {
99
- display:none;
100
- }
101
-
102
- #cas-accordion ul.category-tabs {
103
- width:auto;
104
- margin: 20px 0 -1px;
105
- }
106
-
107
- #cas-accordion ul.category-tabs li {
108
- padding: 3px 5px 3px 8px;
109
- border-style: solid;
110
- border-width: 1px;
111
- position: relative;
112
- display: inline-block;
113
- line-height: 1.35em;
114
- margin:0;
115
- border-color: transparent;
116
- }
117
-
118
- #cas-accordion ul.category-tabs li.tabs {
119
- border-color: #DFDFDF #DFDFDF #FDFDFD;
120
- border-style: solid;
121
- border-width: 1px;
122
- }
123
-
124
- #cas-accordion .tabs-panel {
125
- overflow:auto;
126
- clear:both;
127
- }
128
-
129
- #cas-accordion .button-controls {
130
- margin:10px 0 0;
131
- }
132
-
133
- .cas-tick {
134
- background-image:url('../img/tick.png'); /* Icon by fatcow.com */
135
- background-repeat: no-repeat;
136
- background-position: 8px center;
137
- }
138
-
139
- .cas-contentlist .children li {
140
- padding-left:20px;
141
- }
142
-
143
- #cas-accordion .button-controls {
144
- overflow:hidden;
145
- }
146
-
147
- .add-to-group {
148
- float:right;
149
- }
150
-
151
- #cas-groups {
152
- box-sizing:border-box;
153
- -moz-box-sizing:border-box;
154
- -webkit-box-sizing:border-box;
155
- -o-box-sizing:border-box;
156
- -ms-box-sizing:border-box;
157
- margin-left:300px;
158
- }
159
-
160
- #cas-groups h3 {
161
- cursor:auto;
162
- display:inline-block;
163
- border:none;
164
- padding:0;
165
- line-height:2;
166
- background:none;
167
- box-shadow: none;
168
- }
169
-
170
- .cas-groups-header, .cas-groups-footer {
171
- background: none repeat scroll 0 0 #F5F5F5;
172
- padding: 6px 10px;
173
- overflow:hidden;
174
- }
175
-
176
- .cas-groups-header .button, .cas-groups-footer .button {
177
- float:right;
178
- }
179
-
180
- .cas-groups-header {
181
- border-bottom:1px solid #DFDFDF;
182
- }
183
-
184
- .cas-groups-footer {
185
- border-top:1px solid #DFDFDF;
186
- }
187
-
188
- .cas-groups-body {
189
- padding:8px 10px;
190
- background-color: #fff;
191
- }
192
-
193
- .cas-group-single.cas-group-active {
194
- border-color:#5B9DD9;
195
- box-shadow: 0 0 2px rgba(30, 140, 190, 0.8);
196
- }
197
- /*.cas-group-single.cas-group-active .cas-group-control {
198
- border-color:#555;
199
- }*/
200
-
201
- .cas-group-single {
202
- -webkit-box-sizing:border-box;
203
- -moz-box-sizing:border-box;
204
- -ms-box-sizing:border-box;
205
- box-sizing:border-box;
206
- border-width:1px;
207
- border-style:solid;
208
- border-color:#cfcfcf;
209
- padding:4px 10px;
210
- overflow:hidden;
211
- position:relative;
212
- box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
213
- min-height:45px;
214
- margin-bottom:10px;
215
- }
216
-
217
- .cas-group-single .cas-group-control {
218
- text-align: right;
219
- display:inline;
220
- position:absolute;
221
- top:0;
222
- right:0;
223
- line-height:30px;
224
- padding:5px 10px;
225
- background-color:#fafafa;
226
- border-width:0 0 1px 1px;
227
- border-style:solid;
228
- border-color:#cfcfcf;
229
- box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
230
- }
231
- .cas-group-single .cas-group-control a {
232
- text-decoration: none;
233
- }
234
- .cas-group-active .cas-group-control {
235
- display:none;
236
- }
237
-
238
- .cas-group-single .cas-group-control-active {
239
- display:none;
240
- }
241
-
242
- .cas-group-active .cas-group-control-active {
243
- display:inline;
244
- }
245
-
246
- .cas-group-single:not(.cas-group-active) label {
247
- cursor:auto;
248
- }
249
-
250
- .cas-group-single:not(.cas-group-active) input[type="checkbox"] {
251
- display:none;
252
- }
253
-
254
- .cas-group-single .submitdelete {
255
- color:#BC0B0B;
256
- }
257
- .cas-group-single .submitdelete:hover {
258
- color:#fff;
259
- background-color:#FF0000;
260
- }
261
-
262
- .cas-group-single li {
263
- list-style: disc inside;
264
- }
265
-
266
- .cas-group-single li.cas-new {
267
- background:#F6F3E4;
268
- }
269
-
270
- .cas-group-single.cas-group-active li {
271
- list-style:none;
272
- }
273
-
274
- .cas-condition {
275
- padding:0 0 5px;
276
- }
277
-
278
- #cas-groups.cas-has-groups .cas-no-groups {
279
- display:none;
280
- }
281
- #cas-groups:not(.cas-has-groups) .cas-no-groups {
282
- display:inline;
283
- }
284
-
285
- .cas-alert {
286
- position:fixed;
287
- top:23px;
288
- left:50%;
289
- }
290
-
291
- .cas-alert > div {
292
- padding:5px 30px;
293
- position: relative;
294
- left: -50%;
295
- }
296
-
297
- @media (max-width: 600px), (min-width:850px) and (max-width:1060px) {
298
- #cas-accordion {
299
- float:none;
300
- width:auto;
301
- }
302
- #cas-groups {
303
- margin:0;
304
- }
305
- }
1
+ /**
2
+ * @package Content Aware Sidebars
3
+ * @author Joachim Jensen <jv@intox.dk>
4
+ */
5
+ .icon32-posts-sidebar{background:transparent url(../img/icon-32.png) no-repeat!important}.fixed .column-widgets{width:10%}.fixed .column-merge-pos{width:20%}.fixed .column-handle{width:20%}#cas-rules>.handlediv,#cas-rules>.hndle{display:none}#cas-rules>.inside{overflow:hidden;margin:0;padding:0}#cas-rules.postbox{background:0 0;border:0;box-shadow:none}#cas-container{overflow:hidden;width:100%}#cas-accordion{float:left;width:280px}#cas-accordion .outer-border{margin:0}#cas-accordion.accordion-container .accordion-section:first-child,#cas-accordion.accordion-container .accordion-section:first-child h3,#cas-accordion.accordion-container .top,#cas-accordion.accordion-container .top h3{border-top-left-radius:3px;border-top-right-radius:3px;border-top:0}#cas-accordion.accordion-container .accordion-section:last-child,#cas-accordion.accordion-container .accordion-section:last-child .accordion-section-content,#cas-accordion.accordion-container .bottom,#cas-accordion.accordion-container .bottom:not(.open) h3{border-bottom-left-radius:3px;border-bottom-right-radius:3px}#cas-accordion .accordion-section-title{padding:10px 20px;margin:0!important;overflow:hidden;border-left:0;border-right:0}#cas-accordion .control-section.open .accordion-section-title{border-bottom:1px solid #dfdfdf}#cas-accordion .accordion-section-content{padding:18px 13px;font-size:13px;border-left:0;border-right:0}#cas-accordion .accordion-section{margin:0;border-bottom:1px solid #dfdfdf}#cas-accordion ul.category-tabs{width:auto;margin:20px 0 -1px}#cas-accordion ul.category-tabs li{padding:3px 5px 3px 8px;border-style:solid;border-width:1px;position:relative;display:inline-block;line-height:1.35em;margin:0;border-color:transparent}#cas-accordion ul.category-tabs li.tabs{border-color:#dfdfdf #dfdfdf #fdfdfd;border-style:solid;border-width:1px}#cas-accordion .tabs-panel{overflow:auto;clear:both}#cas-accordion .button-controls{margin:10px 0 0;overflow:hidden}.js #cas-accordion .accordion-section-title{cursor:pointer;border-radius:0!important;box-shadow:none!important;border-bottom-width:0}.js #cas-accordion .accordion-section:not(.open) .accordion-section-content{display:none}.cas-contentlist .children li{padding-left:20px}.add-to-group{float:right}#cas-groups{box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;-ms-box-sizing:border-box;margin-left:300px;line-height:inherit}#cas-groups h3{cursor:auto;display:inline-block;border:0;padding:0;line-height:2;background:0 0;box-shadow:none}#cas-groups.cas-has-groups .cas-no-groups{display:none!important}#cas-groups:not(.cas-has-groups) .cas-no-groups{display:inline}.cas-groups-header,.cas-groups-footer{background:none repeat scroll 0 0 #F5F5F5;padding:6px 10px;overflow:hidden}.cas-groups-header .button,.cas-groups-footer .button{float:right}.cas-groups-header{border-bottom:1px solid #dfdfdf}.cas-groups-footer{border-top:1px solid #dfdfdf}.cas-groups-body{padding:8px 10px;background-color:#fff}.cas-group-single{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;border-width:1px;border-style:solid;border-color:#cfcfcf;padding:10px 15px;overflow:hidden;position:relative;box-shadow:0 1px 1px rgba(0,0,0,.04);min-height:45px;margin-bottom:10px;box-shadow:inset 0 0 0 5px #f1f1f1}.cas-group-single.cas-group-active{box-shadow:inset 0 0 0 5px #c1f1c4}.cas-group-single.cas-group-active .cas-group-control{display:none}.cas-group-single.cas-group-active .cas-group-control-active{display:inline}.cas-group-single.cas-group-active label{padding-right:30px;border:1px solid #439eb4;background:#75d7ef}.cas-group-single.cas-group-active label:hover,.cas-group-single.cas-group-active label:active{background:#ff7058;border-color:#d13d25;color:#fff}.cas-group-single.cas-group-active label:after{text-align:center;width:20px;top:0;right:0;content:"✖";padding:5px 4px;margin-left:1px}.cas-group-single:not(.cas-group-active) label{cursor:auto}.cas-group-single .cas-group-control{text-align:right;display:inline;position:absolute;top:0;right:0;line-height:30px;padding:5px 10px;background-color:#fafafa;border-width:0 0 1px 1px;border-style:solid;border-color:#cfcfcf;box-shadow:0 1px 1px rgba(0,0,0,.04)}.cas-group-single .cas-group-control a{text-decoration:none}.cas-group-single .cas-group-control-active{display:none}.cas-group-single li{list-style:none;display:inline-block}.cas-group-single li.cas-new label{background:#50df75;border-color:#23a645}.cas-group-single label{box-shadow:inset 0 1px 0 rgba(255,255,255,.8);border:1px solid #b5b5b5;background:#dedede;padding:5px 10px;display:inline-block;border-radius:1px;transition:all .5s ease;-o-transition:all .5s ease;-ms-transition:all .5s ease;-moz-transition:all .5s ease;-webkit-transition:all .5s ease;position:relative}.cas-group-single label:after{position:absolute;transition:all .5s ease;-o-transition:all .5s ease;-ms-transition:all .5s ease;-moz-transition:all .5s ease;-webkit-transition:all .5s ease}.cas-group-single input[type=checkbox]{display:none}.cas-group-single .submitdelete{color:#BC0B0B}.cas-group-single .submitdelete:hover{color:#fff;background-color:red}.cas-condition{padding:0 0 5px}.cas-alert{position:fixed;top:23px;left:50%}.cas-alert>div{padding:5px 30px;position:relative;left:-50%}@media (max-width:600px),(min-width:850px) and (max-width:1060px){#cas-accordion{float:none;width:auto}#cas-groups{margin:0}}.content-aware-sidebar:not(.inactive-sidebar){box-shadow:inset 0 5px 0 #75d7ef,0 1px 1px rgba(0,0,0,.04)}.content-aware-sidebar:not(.inactive-sidebar) .sidebar-name{box-shadow:inset 0 5px 0 #75d7ef}.content-aware-sidebar:not(.inactive-sidebar) .widgets-sortables{background:0 0}.content-aware-sidebar:not(.inactive-sidebar).closed .cas-sidebar-footer{display:none}.content-aware-sidebar:not(.inactive-sidebar) .cas-sidebar-footer{border-top:1px solid #dfdfdf;padding:10px 5px 0}.content-aware-sidebar:not(.inactive-sidebar) .cas-sidebar-link{color:#444;text-decoration:none;margin-right:10px}.content-aware-sidebar:not(.inactive-sidebar) .cas-sidebar-link:hover{color:#2ea2cc}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/cas_admin.js CHANGED
@@ -1,651 +1,660 @@
1
- /**
2
- * @package Content Aware Sidebars
3
- * @author Joachim Jensen <jv@intox.dk>
4
- */
5
-
6
- (function($) {
7
-
8
- /**
9
- * Condition group management
10
- * @author Joachim Jensen <jv@intox.dk>
11
- * @since 2.0
12
- */
13
- function GroupHandler() {
14
- /**
15
- * Container element
16
- * @type {Object}
17
- */
18
- this._$groupContainer = $('#cas-groups');
19
-
20
- /**
21
- * Current condition group
22
- * @type {Object}
23
- */
24
- this._currentGroup = null;
25
-
26
- /**
27
- * CSS class for current group
28
- * @type {string}
29
- */
30
- this._activeClass = 'cas-group-active';
31
-
32
- /**
33
- * Add a group to gui
34
- * @author Joachim Jensen <jv@intox.dk>
35
- * @since 2.1
36
- * @param {Object} obj
37
- */
38
- this.add = function(obj) {
39
- var canSet = this.setCurrent(obj);
40
- if(canSet) {
41
- cas_alert.dismiss();
42
- if(!this.hasGroups()) {
43
- this.getGroupContainer().addClass('cas-has-groups');
44
- }
45
- $('ul', this._$groupContainer).first().append(obj);
46
- }
47
- }
48
-
49
- /**
50
- * Remove a group from gui
51
- * @author Joachim Jensen <jv@intox.dk>
52
- * @since 2.1
53
- * @param {Object} obj
54
- * @return {void}
55
- */
56
- this.remove = function(obj) {
57
- var that = this;
58
- obj
59
- .css('background','red')
60
- .fadeOut('slow', function() {
61
- obj.remove();
62
- if(!that.hasGroups()) {
63
- that.getGroupContainer().removeClass('cas-has-groups');
64
- }
65
- });
66
- }
67
-
68
- /**
69
- * Set a group as current group
70
- * Will reset former current group
71
- * @author Joachim Jensen <jv@intox.dk>
72
- * @since 2.1
73
- * @param {Object} obj
74
- * @return {Boolean}
75
- */
76
- this.setCurrent = function(obj) {
77
- var retval = true;
78
-
79
- if(obj.length == 0) {
80
- retval = false;
81
- } else if(this.getCurrent()) {
82
- retval = this.resetCurrent();
83
- }
84
- if(retval) {
85
- this._currentGroup = obj;
86
- this._setActive(true);
87
- }
88
- return retval;
89
- }
90
-
91
- /**
92
- * Reset current group if any
93
- * Will take care of confirmation on unsaved rules
94
- * and strip unsaved changes
95
- * @author Joachim Jensen <jv@intox.dk>
96
- * @since 2.1
97
- * @return {Boolean}
98
- */
99
- this.resetCurrent = function() {
100
- var retval = true;
101
- cas_alert.dismiss();
102
- if(this.getCurrent()) {
103
-
104
- if(this.isNewGroup()) {
105
- var remove = true;
106
- //Confirm if there are unsaved rules
107
- if(this.hasUnsavedRules()) {
108
- remove = confirm(CASAdmin.confirmCancel);
109
- }
110
- if(remove) {
111
- this._setActive(false);
112
- this.remove(this.getCurrent());
113
- this._currentGroup = null;
114
- } else {
115
- retval = false;
116
- }
117
-
118
- } else {
119
-
120
- var remove = true;
121
- //Confirm if there are unsaved rules
122
- if(this.hasUnsavedRules()) {
123
- remove = confirm(CASAdmin.confirmCancel);
124
- }
125
- if(remove) {
126
- //Remove new content that should not be saved
127
- $("li.cas-new",this.getCurrent()).remove();
128
- //Remove conditional headlines
129
- $(".cas-condition",this.getCurrent()).each( function() {
130
- if($(this).find('input').length == 0) {
131
- $(this).remove();
132
- }
133
- });
134
- this._setActive(false);
135
- this._currentGroup = null;
136
- } else {
137
- retval = false;
138
- }
139
-
140
-
141
- }
142
-
143
- }
144
- return retval;
145
- }
146
-
147
- /**
148
- * Get current group
149
- * @author Joachim Jensen <jv@intox.dk>
150
- * @since 2.1
151
- * @return {Object}
152
- */
153
- this.getCurrent = function() {
154
- return this._currentGroup;
155
- }
156
-
157
- /**
158
- * Determines if current group is a new one
159
- * I.e. it is not saved to database
160
- * @author Joachim Jensen <jv@intox.dk>
161
- * @since 2.1
162
- * @return {Boolean}
163
- */
164
- this.isNewGroup = function() {
165
- return this.getCurrent().find('.cas_group_id').length == 0;
166
- }
167
-
168
- /**
169
- * Determines if current group has unsaved changes
170
- * @author Joachim Jensen <jv@intox.dk>
171
- * @since 2.1
172
- * @return {Boolean}
173
- */
174
- this.hasUnsavedRules = function() {
175
- return this.getCurrent().find('li.cas-new').length > 0;
176
- }
177
-
178
- /**
179
- * Determines if there are any condition groups
180
- * @author Joachim Jensen <jv@intox.dk>
181
- * @since 2.1
182
- * @return {Boolean}
183
- */
184
- this.hasGroups = function() {
185
- return $('.cas-group-single',this.getGroupContainer()).length > 0;
186
- }
187
-
188
- /**
189
- * Manages CSS class for group and
190
- * the ability to add and edit rules
191
- * @author Joachim Jensen <jv@intox.dk>
192
- * @since 2.1
193
- * @param {Boolean} active
194
- */
195
- this._setActive = function(active) {
196
- $('.js-cas-condition-add').attr('disabled',!active);
197
- this.getCurrent().toggleClass(this._activeClass,active);
198
- var checkboxes = $("input:checkbox",this.getCurrent());
199
- checkboxes.attr('disabled',!active);
200
- if(active) {
201
- checkboxes.attr('checked',true);
202
- }
203
- }
204
-
205
- /**
206
- * Get condition group container
207
- * @author Joachim Jensen <jv@intox.dk>
208
- * @since 2.1
209
- * @return {Object}
210
- */
211
- this.getGroupContainer = function() {
212
- return this._$groupContainer;
213
- }
214
- }
215
-
216
- /**
217
- * Alert handler for sidebar editor
218
- * @type {Object}
219
- */
220
- var cas_alert = {
221
-
222
- /**
223
- * Message object
224
- * @type {Object}
225
- */
226
- _$message: null,
227
-
228
- /**
229
- * Set and print alert message
230
- * @author Joachim Jensen <jv@intox.dk>
231
- * @since 2.1
232
- * @param {string} text
233
- * @param {string} cssClass
234
- */
235
- set: function(text,cssClass) {
236
- if(this._$message) {
237
- this._$message.remove();
238
- }
239
- this._$message = $('<div class="cas-alert"><div class="'+cssClass+'"><p>'+text+'</p></div></div>');
240
- this._$message
241
- .fadeIn('slow')
242
- .appendTo('body');
243
- },
244
-
245
- /**
246
- * Remove a current alert message
247
- * @author Joachim Jensen <jv@intox.dk>
248
- * @since 2.1
249
- * @return {void}
250
- */
251
- dismiss: function() {
252
- if(this._$message) {
253
- this._$message.fadeOut('slow',function() {
254
- $(this).remove();
255
- });
256
- }
257
- }
258
- }
259
-
260
- var cas_admin = {
261
-
262
- groups:new GroupHandler(),
263
- nonce: $('#_ca-sidebar-nonce').val(),
264
- sidebarID: $('#current_sidebar').val(),
265
-
266
- init: function() {
267
-
268
- var new_current_group = $('.cas-group-single',this.groups.getGroupContainer()).first();
269
- if(new_current_group.length == 0) {
270
- $('.js-cas-condition-add').attr('disabled',true);
271
- } else {
272
- this.groups.setCurrent(new_current_group);
273
- }
274
-
275
- this.addPaginationListener();
276
- this.addTabListener();
277
- this.addPublishListener();
278
-
279
- //this.addCheckboxListener();
280
- this.addHandleListener();
281
- this.addSearchListener();
282
- this.addNewGroupListener();
283
- this.addSetGroupListener();
284
- this.addAddContentListener();
285
-
286
- },
287
-
288
- /**
289
- * Listen to publish click to remind
290
- * user of unsaved changes
291
- * @author Joachim Jensen <jv@intox.dk>
292
- * @since 2.1
293
- */
294
- addPublishListener: function() {
295
- $('#publish').click( function(e) {
296
- var canSave = cas_admin.groups.resetCurrent();
297
- if(!canSave) {
298
- e.preventDefault();
299
- }
300
- });
301
- },
302
-
303
- /**
304
- * Listen to pagination for select boxes
305
- * @author Joachim Jensen <jv@intox.dk>
306
- * @since 2.1
307
- */
308
- addPaginationListener: function() {
309
- $('.cas-contentlist').on('click','.page-numbers', function(e) {
310
- e.preventDefault();
311
-
312
- var link = $(this);
313
- var action = link.closest('.cas-rule-content');
314
-
315
- $.ajax({
316
- url: ajaxurl,
317
- data:link.attr('href').split('?')[1]+'&action=cas-module-'+action.attr('data-cas-module'),
318
- dataType: 'JSON',
319
- type: 'POST',
320
- success:function(data){
321
- link.closest('.cas-contentlist').html(data);
322
- },
323
- error: function(xhr, desc, e) {
324
- console.log(xhr.responseText);
325
- }
326
- });
327
-
328
- });
329
- },
330
-
331
- /**
332
- * Listen to and handle adding
333
- * content to current group
334
- * @author Joachim Jensen <jv@intox.dk>
335
- * @since 2.0
336
- */
337
- addAddContentListener: function() {
338
- $("#cas-accordion").on("click",".js-cas-condition-add", function(e) {
339
-
340
- e.preventDefault();
341
-
342
- if(cas_admin.groups.getCurrent() != null) {
343
-
344
- var button = $(this);
345
-
346
- var old_checkboxes = $("input:checkbox:checked", button.closest('.cas-rule-content'));
347
- var condition_elem = $('.cas-condition-'+button.attr('data-cas-condition'), cas_admin.groups.getCurrent());
348
- var data = [];
349
-
350
- if(condition_elem.length == 0) {
351
- condition_elem = $('<div class="cas-condition cas-condition-'+button.attr('data-cas-condition')+'"><strong>'+button.closest('.accordion-section').find('.accordion-section-title').text()+'</strong><ul></ul></div>');
352
- cas_admin.groups.getCurrent().find('.cas-content').append(condition_elem);
353
- }
354
-
355
- //Check if checkbox with value already exists
356
- old_checkboxes.each( function() {
357
- var elem = $(this);
358
- if(condition_elem.find("input[value='"+elem.val()+"']").length == 0) {
359
- var temp = elem.closest('li').clone().addClass('cas-new');
360
- //jQuery 1.7 fix
361
- data.push(temp[0]);
362
- }
363
- });
364
- old_checkboxes.attr('checked',false);
365
-
366
- $('ul',condition_elem).append(data);
367
- }
368
-
369
- });
370
- },
371
-
372
- /**
373
- * Listen to and handle Add New Group clicks
374
- * Uses AJAX to create a new group
375
- * @author Joachim Jensen <jv@intox.dk>
376
- * @since 2.0
377
- */
378
- addNewGroupListener: function() {
379
- this.groups.getGroupContainer().on('click', '.js-cas-group-new', function(e) {
380
-
381
- e.preventDefault();
382
-
383
- var group = $('<li>', {class: 'cas-group-single cas-group-single-new', html: '<span class="cas-group-control cas-group-control-active">'+
384
- '<input type="button" class="button js-cas-group-save" value="'+CASAdmin.save+'" /> | <a class="js-cas-group-cancel" href="#">'+CASAdmin.cancel+'</a>'+
385
- '</span>'+
386
- '<span class="cas-group-control">'+
387
- '<a class="js-cas-group-edit" href="#">'+CASAdmin.edit+'</a> | <a class="submitdelete trash js-cas-group-remove" href="#">'+CASAdmin.remove+'</a>'+
388
- '</span>'+
389
- '<div class="cas-content"></div>'});
390
-
391
- cas_admin.groups.add(group);
392
- });
393
- },
394
-
395
- /**
396
- * Listen to and manage
397
- * group saving, editing, removal and cancelling
398
- * @author Joachim Jensen <jv@intox.dk>
399
- * @since 2.0
400
- */
401
- addSetGroupListener: function() {
402
- this.groups.getGroupContainer().on("click", ".js-cas-group-save", function(e){
403
- e.preventDefault();
404
-
405
- var button = $(this);
406
- button.attr('disabled',true);
407
-
408
- var data = cas_admin.groups.getCurrent().find("input").serializeArray();
409
- data.push({name:"action",value:"cas_add_rule"});
410
- data.push({name:"token",value:cas_admin.nonce});
411
- data.push({name:"current_id",value:cas_admin.sidebarID});
412
-
413
- $.ajax({
414
- url: ajaxurl,
415
- data:$.param(data),
416
- dataType: 'JSON',
417
- type: 'POST',
418
- success:function(data){
419
-
420
- cas_alert.set(data.message,'updated')
421
-
422
- var content = $("input:checkbox",cas_admin.groups.getCurrent()).closest('li');
423
- if(content.length > 0) {
424
- $("input:checkbox:not(:checked)",cas_admin.groups.getCurrent()).closest('li').remove();
425
- content.removeClass('cas-new');
426
- }
427
-
428
- $(".cas-condition",cas_admin.groups.getCurrent()).each( function() {
429
- if($(this).find('input').length == 0) {
430
- $(this).remove();
431
- }
432
- });
433
-
434
- if(data.new_post_id) {
435
- cas_admin.groups.getCurrent().append('<input type="hidden" class="cas_group_id" name="cas_group_id" value="'+data.new_post_id+'" />');
436
- }
437
- button.attr('disabled',false);
438
-
439
- },
440
- error: function(xhr, desc, e) {
441
- cas_alert.set(xhr.responseText,'error');
442
- button.attr('disabled',false);
443
- }
444
- });
445
- })
446
- .on("click", ".js-cas-group-cancel", function(e){
447
- e.preventDefault();
448
- cas_admin.groups.resetCurrent();
449
- })
450
- .on("click", ".js-cas-group-edit", function(e){
451
- e.preventDefault();
452
- cas_admin.groups.setCurrent($(this).parents('.cas-group-single'));
453
- })
454
- .on("click", ".js-cas-group-remove", function(e){
455
- e.preventDefault();
456
-
457
- if(confirm(CASAdmin.confirmRemove) == true) {
458
-
459
- var button = $(this);
460
- button.attr('disabled',true);
461
- var group = $(this).closest('.cas-group-single');
462
- $.ajax({
463
- url: ajaxurl,
464
- data:{
465
- action: 'cas_remove_group',
466
- token: cas_admin.nonce,
467
- cas_group_id: group.find('.cas_group_id').val(),
468
- current_id: cas_admin.sidebarID
469
- },
470
- dataType: 'JSON',
471
- type: 'POST',
472
- success:function(data){
473
- cas_alert.set(data.message,'updated');
474
- cas_admin.groups.remove(group);
475
- button.attr('disabled',false);
476
- },
477
- error: function(xhr, desc, e) {
478
- cas_alert.set(xhr.responseText,'error');
479
- button.attr('disabled',false);
480
- }
481
- });
482
-
483
- }
484
- });
485
- },
486
-
487
- /**
488
- * Listen to and manage tab clicks
489
- * Based on code from WordPress Core
490
- * @author Joachim Jensen <jv@intox.dk>
491
- * @since 2.0
492
- */
493
- addTabListener: function() {
494
- var class_active = 'tabs-panel-active',
495
- class_inactive = 'tabs-panel-inactive';
496
-
497
- $("#cas-accordion .accordion-section:not(.hide-if-js)").first().addClass('open');
498
-
499
- $('.nav-tab-link').on('click', function(e) {
500
- e.preventDefault();
501
-
502
- panelId = $(this).data( 'type' );
503
-
504
- wrapper = $(this).closest('.accordion-section-content');
505
-
506
- // upon changing tabs, we want to uncheck all checkboxes
507
- $('input', wrapper).removeAttr('checked');
508
-
509
- //Change active tab panel
510
- $('.' + class_active, wrapper).removeClass(class_active).addClass(class_inactive);
511
- $('#' + panelId, wrapper).removeClass(class_inactive).addClass(class_active);
512
-
513
- $('.tabs', wrapper).removeClass('tabs');
514
- $(this).parent().addClass('tabs');
515
-
516
- // select the search bar
517
- $('.quick-search', wrapper).focus();
518
-
519
- });
520
- },
521
-
522
- /**
523
- * Set tickers if at least one checkbox is checked
524
- */
525
- addCheckboxListener: function() {
526
- $('.cas-rule-content :input').change( function() {
527
- var parent = $(this).parents('.cas-rule-content');
528
- cas_admin.toggleTick(parent);
529
- if($(this).attr('class') == 'cas-chk-all')
530
- cas_admin.toggleSelectAll(this, parent);
531
- }).change(); //fire change event on page load
532
- },
533
- toggleTick: function(parent) {
534
- //Toggle on any selected checkbox
535
- parent.prev().toggleClass('cas-tick',parent.find('input:checked').length > 0);
536
- },
537
- /**
538
- * Toggle specific input depending on "show with all" checkbox
539
- */
540
- toggleSelectAll: function(checkbox, parent) {
541
- var checkboxes = parent.find("input[type=checkbox]").not(checkbox);
542
- checkboxes.attr("disabled", $(checkbox).is(":checked"));
543
- },
544
- /**
545
- * The value of Handle selection will control the
546
- * accessibility of the host sidebar selection
547
- * If Handling is manual, selection of host sidebar will be disabled
548
- * @author Joachim Jensen <jv@intox.dk>
549
- * @since 2.1
550
- */
551
- addHandleListener: function() {
552
- var host = $("select[name='host']");
553
- var code = $('<code>display_ca_sidebar();</code>');
554
- var merge_pos = $('span.merge-pos');
555
- host.parent().append(code);
556
- $("select[name='handle']").change(function(){
557
- var handle = $(this);
558
- host.attr("disabled", handle.val() == 2);
559
- if(handle.val() == 2) {
560
- host.hide();
561
- code.show();
562
- } else {
563
- host.show();
564
- code.hide();
565
- }
566
- if(handle.val() == 3) {
567
- merge_pos.hide();
568
- } else {
569
- merge_pos.show();
570
- }
571
- }).change(); //fire change event on page load
572
- },
573
- /**
574
- * Use AJAX to search for content from a specific module
575
- */
576
- addSearchListener: function() {
577
- var searchTimer;
578
-
579
- $('.cas-autocomplete').keypress(function(e){
580
- var t = $(this);
581
-
582
- //If Enter (13) is pressed, search immediately
583
- if( 13 == e.which ) {
584
- cas_admin.updateSearchResults( t );
585
- return false;
586
- }
587
-
588
- //If timer is already in progress, stop it
589
- if( searchTimer ) clearTimeout(searchTimer);
590
-
591
- searchTimer = setTimeout(function(){
592
- cas_admin.updateSearchResults( t );
593
- }, 400);
594
- }).attr('autocomplete','off');
595
-
596
- },
597
- /**
598
- * Make AJAX request to get results
599
- * @author Joachim Jensen <jv@intox.dk>
600
- * @since 2
601
- * @param {Object} input
602
- * @return {void}
603
- */
604
- updateSearchResults: function(input) {
605
- var panel,
606
- minSearchLength = 2,
607
- q = input.val();
608
-
609
- if( q.length < minSearchLength ) return;
610
-
611
- panel = input.parents('.tabs-panel');
612
- var spinner = $('.spinner', panel);
613
-
614
- spinner.show();
615
-
616
- $.ajax({
617
- url: ajaxurl,
618
- data:{
619
- 'action': input.attr('class').split(' ')[0],
620
- 'response-format': 'JSON',
621
- 'nonce': cas_admin.nonce,
622
- 'sidebar_id': cas_admin.sidebarID,
623
- 'type': input.attr('id'),
624
- 'q': q
625
- },
626
- dataType: 'JSON',
627
- type: 'POST',
628
- success:function(response){
629
- var elements = "";
630
- if(response.length > 0) {
631
- $.each(response, function(i,item) {
632
- elements += '<li><label class="selectit"><input value="'+item.value+'" type="checkbox" name="'+item.name+'[]"/> '+item.label+'</label></li>';
633
- });
634
- } else {
635
- elements = '<li><p>'+CASAdmin.noResults+'</p></li>';
636
- }
637
-
638
- $('.categorychecklist', panel).html(elements);
639
- spinner.hide();
640
- },
641
- error: function(xhr, desc, e) {
642
- console.log(xhr.responseText);
643
- }
644
- });
645
-
646
- },
647
- }
648
-
649
- $(document).ready(function(){ cas_admin.init(); });
650
-
651
- })(jQuery);
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @package Content Aware Sidebars
3
+ * @author Joachim Jensen <jv@intox.dk>
4
+ */
5
+
6
+ (function($) {
7
+
8
+ /**
9
+ * Condition group management
10
+ * @author Joachim Jensen <jv@intox.dk>
11
+ * @since 2.0
12
+ */
13
+ function GroupHandler() {
14
+ /**
15
+ * Container element
16
+ * @type {Object}
17
+ */
18
+ this._$groupContainer = $('#cas-groups');
19
+
20
+ /**
21
+ * Current condition group
22
+ * @type {Object}
23
+ */
24
+ this._currentGroup = null;
25
+
26
+ /**
27
+ * CSS class for current group
28
+ * @type {string}
29
+ */
30
+ this._activeClass = 'cas-group-active';
31
+
32
+ /**
33
+ * Add a group to gui
34
+ * @author Joachim Jensen <jv@intox.dk>
35
+ * @since 2.1
36
+ * @param {Object} obj
37
+ */
38
+ this.add = function(obj) {
39
+ var canSet = this.setCurrent(obj);
40
+ if(canSet) {
41
+ cas_alert.dismiss();
42
+ if(!this.hasGroups()) {
43
+ this.getGroupContainer().addClass('cas-has-groups');
44
+ }
45
+ $('ul', this._$groupContainer).first().append(obj);
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Remove a group from gui
51
+ * @author Joachim Jensen <jv@intox.dk>
52
+ * @since 2.1
53
+ * @param {Object} obj
54
+ * @return {void}
55
+ */
56
+ this.remove = function(obj) {
57
+ var that = this;
58
+ obj
59
+ .css('background','red')
60
+ .fadeOut('slow', function() {
61
+ obj.remove();
62
+ if(!that.hasGroups()) {
63
+ that.getGroupContainer().removeClass('cas-has-groups');
64
+ }
65
+ });
66
+ }
67
+
68
+ /**
69
+ * Set a group as current group
70
+ * Will reset former current group
71
+ * @author Joachim Jensen <jv@intox.dk>
72
+ * @since 2.1
73
+ * @param {Object} obj
74
+ * @return {Boolean}
75
+ */
76
+ this.setCurrent = function(obj) {
77
+ var retval = true;
78
+
79
+ if(obj.length == 0) {
80
+ retval = false;
81
+ } else if(this.getCurrent()) {
82
+ retval = this.resetCurrent();
83
+ }
84
+ if(retval) {
85
+ this._currentGroup = obj;
86
+ this._setActive(true);
87
+ }
88
+ return retval;
89
+ }
90
+
91
+ /**
92
+ * Reset current group if any
93
+ * Will take care of confirmation on unsaved rules
94
+ * and strip unsaved changes
95
+ * @author Joachim Jensen <jv@intox.dk>
96
+ * @since 2.1
97
+ * @return {Boolean}
98
+ */
99
+ this.resetCurrent = function() {
100
+ var retval = true;
101
+ cas_alert.dismiss();
102
+ if(this.getCurrent()) {
103
+
104
+ if(this.isNewGroup()) {
105
+ var remove = true;
106
+ //Confirm if there are unsaved rules
107
+ if(this.hasUnsavedRules()) {
108
+ remove = confirm(CASAdmin.confirmCancel);
109
+ }
110
+ if(remove) {
111
+ this._setActive(false);
112
+ this.remove(this.getCurrent());
113
+ this._currentGroup = null;
114
+ } else {
115
+ retval = false;
116
+ }
117
+
118
+ } else {
119
+
120
+ var remove = true;
121
+ //Confirm if there are unsaved rules
122
+ if(this.hasUnsavedRules()) {
123
+ remove = confirm(CASAdmin.confirmCancel);
124
+ }
125
+ if(remove) {
126
+ //Remove new content that should not be saved
127
+ $("li.cas-new",this.getCurrent()).remove();
128
+ //Remove conditional headlines
129
+ $(".cas-condition",this.getCurrent()).each( function() {
130
+ if($(this).find('input').length == 0) {
131
+ $(this).remove();
132
+ }
133
+ });
134
+ //Show all again
135
+ $('li').fadeIn('slow');
136
+ this._setActive(false);
137
+ this._currentGroup = null;
138
+ } else {
139
+ retval = false;
140
+ }
141
+
142
+
143
+ }
144
+
145
+ }
146
+ return retval;
147
+ }
148
+
149
+ /**
150
+ * Get current group
151
+ * @author Joachim Jensen <jv@intox.dk>
152
+ * @since 2.1
153
+ * @return {Object}
154
+ */
155
+ this.getCurrent = function() {
156
+ return this._currentGroup;
157
+ }
158
+
159
+ /**
160
+ * Determines if current group is a new one
161
+ * I.e. it is not saved to database
162
+ * @author Joachim Jensen <jv@intox.dk>
163
+ * @since 2.1
164
+ * @return {Boolean}
165
+ */
166
+ this.isNewGroup = function() {
167
+ return this.getCurrent().find('.cas_group_id').length == 0;
168
+ }
169
+
170
+ /**
171
+ * Determines if current group has unsaved changes
172
+ * @author Joachim Jensen <jv@intox.dk>
173
+ * @since 2.1
174
+ * @return {Boolean}
175
+ */
176
+ this.hasUnsavedRules = function() {
177
+ return this.getCurrent().find('li.cas-new').length > 0;
178
+ }
179
+
180
+ /**
181
+ * Determines if there are any condition groups
182
+ * @author Joachim Jensen <jv@intox.dk>
183
+ * @since 2.1
184
+ * @return {Boolean}
185
+ */
186
+ this.hasGroups = function() {
187
+ return $('.cas-group-single',this.getGroupContainer()).length > 0;
188
+ }
189
+
190
+ /**
191
+ * Manages CSS class for group and
192
+ * the ability to add and edit rules
193
+ * @author Joachim Jensen <jv@intox.dk>
194
+ * @since 2.1
195
+ * @param {Boolean} active
196
+ */
197
+ this._setActive = function(active) {
198
+ $('.js-cas-condition-add, .accordion-section-content input:checkbox').attr('disabled',!active);
199
+ this.getCurrent().toggleClass(this._activeClass,active);
200
+ var checkboxes = $("input:checkbox",this.getCurrent());
201
+ checkboxes.attr('disabled',!active);
202
+ if(active) {
203
+ checkboxes.attr('checked',true);
204
+ }
205
+ }
206
+
207
+ /**
208
+ * Get condition group container
209
+ * @author Joachim Jensen <jv@intox.dk>
210
+ * @since 2.1
211
+ * @return {Object}
212
+ */
213
+ this.getGroupContainer = function() {
214
+ return this._$groupContainer;
215
+ }
216
+ }
217
+
218
+ /**
219
+ * Alert handler for sidebar editor
220
+ * @type {Object}
221
+ */
222
+ var cas_alert = {
223
+
224
+ /**
225
+ * Message object
226
+ * @type {Object}
227
+ */
228
+ _$message: null,
229
+
230
+ /**
231
+ * Set and print alert message
232
+ * @author Joachim Jensen <jv@intox.dk>
233
+ * @since 2.1
234
+ * @param {string} text
235
+ * @param {string} cssClass
236
+ */
237
+ set: function(text,cssClass) {
238
+ if(this._$message) {
239
+ this._$message.remove();
240
+ }
241
+ this._$message = $('<div class="cas-alert"><div class="'+cssClass+'"><p>'+text+'</p></div></div>');
242
+ this._$message
243
+ .fadeIn('slow')
244
+ .appendTo('body');
245
+ },
246
+
247
+ /**
248
+ * Remove a current alert message
249
+ * @author Joachim Jensen <jv@intox.dk>
250
+ * @since 2.1
251
+ * @return {void}
252
+ */
253
+ dismiss: function() {
254
+ if(this._$message) {
255
+ this._$message.fadeOut('slow',function() {
256
+ $(this).remove();
257
+ });
258
+ }
259
+ }
260
+ }
261
+
262
+ var cas_admin = {
263
+
264
+ groups:new GroupHandler(),
265
+ nonce: $('#_ca-sidebar-nonce').val(),
266
+ sidebarID: $('#current_sidebar').val(),
267
+
268
+ init: function() {
269
+
270
+ var new_current_group = $('.cas-group-single',this.groups.getGroupContainer()).first();
271
+ if(new_current_group.length == 0) {
272
+ $('.js-cas-condition-add').attr('disabled',true);
273
+ } else {
274
+ this.groups.setCurrent(new_current_group);
275
+ }
276
+
277
+ $('.cas-groups-body').on('change', 'input:checkbox', function(e) {
278
+ $this = $(this);
279
+ if(!$this.is('checked')) {
280
+ $this.closest('li').hide();
281
+ }
282
+ });
283
+
284
+ this.addPaginationListener();
285
+ this.addTabListener();
286
+ this.addPublishListener();
287
+
288
+ //this.addCheckboxListener();
289
+ this.addHandleListener();
290
+ this.addSearchListener();
291
+ this.addNewGroupListener();
292
+ this.addSetGroupListener();
293
+ this.addAddContentListener();
294
+
295
+ },
296
+
297
+ /**
298
+ * Listen to publish click to remind
299
+ * user of unsaved changes
300
+ * @author Joachim Jensen <jv@intox.dk>
301
+ * @since 2.1
302
+ */
303
+ addPublishListener: function() {
304
+ $('#publish').click( function(e) {
305
+ var canSave = cas_admin.groups.resetCurrent();
306
+ if(!canSave) {
307
+ e.preventDefault();
308
+ }
309
+ });
310
+ },
311
+
312
+ /**
313
+ * Listen to pagination for select boxes
314
+ * @author Joachim Jensen <jv@intox.dk>
315
+ * @since 2.1
316
+ */
317
+ addPaginationListener: function() {
318
+ $('.cas-contentlist').on('click','.page-numbers', function(e) {
319
+ e.preventDefault();
320
+
321
+ var link = $(this);
322
+ var action = link.closest('.cas-rule-content');
323
+
324
+ $.ajax({
325
+ url: ajaxurl,
326
+ data:link.attr('href').split('?')[1]+'&action=cas-module-'+action.attr('data-cas-module'),
327
+ dataType: 'JSON',
328
+ type: 'POST',
329
+ success:function(data){
330
+ link.closest('.cas-contentlist').html(data);
331
+ },
332
+ error: function(xhr, desc, e) {
333
+ console.log(xhr.responseText);
334
+ }
335
+ });
336
+
337
+ });
338
+ },
339
+
340
+ /**
341
+ * Listen to and handle adding
342
+ * content to current group
343
+ * @author Joachim Jensen <jv@intox.dk>
344
+ * @since 2.0
345
+ */
346
+ addAddContentListener: function() {
347
+ $("#cas-accordion").on("click",".js-cas-condition-add", function(e) {
348
+
349
+ e.preventDefault();
350
+
351
+ if(cas_admin.groups.getCurrent() != null) {
352
+
353
+ var button = $(this);
354
+
355
+ var old_checkboxes = $("input:checkbox:checked", button.closest('.cas-rule-content'));
356
+ var condition_elem = $('.cas-condition-'+button.attr('data-cas-condition'), cas_admin.groups.getCurrent());
357
+ var data = [];
358
+
359
+ if(condition_elem.length == 0) {
360
+ condition_elem = $('<div class="cas-condition cas-condition-'+button.attr('data-cas-condition')+'"><h4>'+button.closest('.accordion-section').find('.accordion-section-title').text()+'</h4><ul></ul></div>');
361
+ cas_admin.groups.getCurrent().find('.cas-content').append(condition_elem);
362
+ }
363
+
364
+ //Check if checkbox with value already exists
365
+ old_checkboxes.each( function() {
366
+ var elem = $(this);
367
+ if(condition_elem.find("input[value='"+elem.val()+"']").length == 0) {
368
+ var temp = elem.closest('li').clone().addClass('cas-new').append("&nbsp;"); //add whitespace to make it look nice
369
+ //jQuery 1.7 fix
370
+ data.push(temp[0]);
371
+ }
372
+ });
373
+ old_checkboxes.attr('checked',false);
374
+
375
+ $('ul',condition_elem).append(data);
376
+ }
377
+
378
+ });
379
+ },
380
+
381
+ /**
382
+ * Listen to and handle Add New Group clicks
383
+ * Uses AJAX to create a new group
384
+ * @author Joachim Jensen <jv@intox.dk>
385
+ * @since 2.0
386
+ */
387
+ addNewGroupListener: function() {
388
+ this.groups.getGroupContainer().on('click', '.js-cas-group-new', function(e) {
389
+
390
+ e.preventDefault();
391
+
392
+ var group = $('<li>', {class: 'cas-group-single cas-group-single-new', html: '<span class="cas-group-control cas-group-control-active">'+
393
+ '<input type="button" class="button js-cas-group-save" value="'+CASAdmin.save+'" /> | <a class="js-cas-group-cancel" href="#">'+CASAdmin.cancel+'</a>'+
394
+ '</span>'+
395
+ '<span class="cas-group-control">'+
396
+ '<a class="js-cas-group-edit" href="#">'+CASAdmin.edit+'</a> | <a class="submitdelete trash js-cas-group-remove" href="#">'+CASAdmin.remove+'</a>'+
397
+ '</span>'+
398
+ '<div class="cas-content"></div>'});
399
+
400
+ cas_admin.groups.add(group);
401
+ });
402
+ },
403
+
404
+ /**
405
+ * Listen to and manage
406
+ * group saving, editing, removal and cancelling
407
+ * @author Joachim Jensen <jv@intox.dk>
408
+ * @since 2.0
409
+ */
410
+ addSetGroupListener: function() {
411
+ this.groups.getGroupContainer().on("click", ".js-cas-group-save", function(e){
412
+ e.preventDefault();
413
+
414
+ var button = $(this);
415
+ button.attr('disabled',true);
416
+
417
+ var data = cas_admin.groups.getCurrent().find("input").serializeArray();
418
+ data.push({name:"action",value:"cas_add_rule"});
419
+ data.push({name:"token",value:cas_admin.nonce});
420
+ data.push({name:"current_id",value:cas_admin.sidebarID});
421
+
422
+ $.ajax({
423
+ url: ajaxurl,
424
+ data:$.param(data),
425
+ dataType: 'JSON',
426
+ type: 'POST',
427
+ success:function(data){
428
+
429
+ cas_alert.set(data.message,'updated')
430
+
431
+ var content = $("input:checkbox",cas_admin.groups.getCurrent()).closest('li');
432
+ if(content.length > 0) {
433
+ $("input:checkbox:not(:checked)",cas_admin.groups.getCurrent()).closest('li').remove();
434
+ content.removeClass('cas-new');
435
+ }
436
+
437
+ $(".cas-condition",cas_admin.groups.getCurrent()).each( function() {
438
+ if($(this).find('input').length == 0) {
439
+ $(this).remove();
440
+ }
441
+ });
442
+
443
+ if(data.new_post_id) {
444
+ cas_admin.groups.getCurrent().append('<input type="hidden" class="cas_group_id" name="cas_group_id" value="'+data.new_post_id+'" />');
445
+ }
446
+ button.attr('disabled',false);
447
+
448
+ },
449
+ error: function(xhr, desc, e) {
450
+ cas_alert.set(xhr.responseText,'error');
451
+ button.attr('disabled',false);
452
+ }
453
+ });
454
+ })
455
+ .on("click", ".js-cas-group-cancel", function(e){
456
+ e.preventDefault();
457
+ cas_admin.groups.resetCurrent();
458
+ })
459
+ .on("click", ".js-cas-group-edit", function(e){
460
+ e.preventDefault();
461
+ cas_admin.groups.setCurrent($(this).parents('.cas-group-single'));
462
+ })
463
+ .on("click", ".js-cas-group-remove", function(e){
464
+ e.preventDefault();
465
+
466
+ if(confirm(CASAdmin.confirmRemove) == true) {
467
+
468
+ var button = $(this);
469
+ button.attr('disabled',true);
470
+ var group = $(this).closest('.cas-group-single');
471
+ $.ajax({
472
+ url: ajaxurl,
473
+ data:{
474
+ action: 'cas_remove_group',
475
+ token: cas_admin.nonce,
476
+ cas_group_id: group.find('.cas_group_id').val(),
477
+ current_id: cas_admin.sidebarID
478
+ },
479
+ dataType: 'JSON',
480
+ type: 'POST',
481
+ success:function(data){
482
+ cas_alert.set(data.message,'updated');
483
+ cas_admin.groups.remove(group);
484
+ button.attr('disabled',false);
485
+ },
486
+ error: function(xhr, desc, e) {
487
+ cas_alert.set(xhr.responseText,'error');
488
+ button.attr('disabled',false);
489
+ }
490
+ });
491
+
492
+ }
493
+ });
494
+ },
495
+
496
+ /**
497
+ * Listen to and manage tab clicks
498
+ * Based on code from WordPress Core
499
+ * @author Joachim Jensen <jv@intox.dk>
500
+ * @since 2.0
501
+ */
502
+ addTabListener: function() {
503
+ var class_active = 'tabs-panel-active',
504
+ class_inactive = 'tabs-panel-inactive';
505
+
506
+ $("#cas-accordion .accordion-section:not(.hide-if-js)").first().addClass('open');
507
+
508
+ $('.nav-tab-link').on('click', function(e) {
509
+ e.preventDefault();
510
+
511
+ panelId = $(this).data( 'type' );
512
+
513
+ wrapper = $(this).closest('.accordion-section-content');
514
+
515
+ // upon changing tabs, we want to uncheck all checkboxes
516
+ $('input', wrapper).removeAttr('checked');
517
+
518
+ //Change active tab panel
519
+ $('.' + class_active, wrapper).removeClass(class_active).addClass(class_inactive);
520
+ $('#' + panelId, wrapper).removeClass(class_inactive).addClass(class_active);
521
+
522
+ $('.tabs', wrapper).removeClass('tabs');
523
+ $(this).parent().addClass('tabs');
524
+
525
+ // select the search bar
526
+ $('.quick-search', wrapper).focus();
527
+
528
+ });
529
+ },
530
+
531
+ /**
532
+ * Set tickers if at least one checkbox is checked
533
+ */
534
+ addCheckboxListener: function() {
535
+ $('.cas-rule-content :input').change( function() {
536
+ var parent = $(this).parents('.cas-rule-content');
537
+ cas_admin.toggleTick(parent);
538
+ if($(this).attr('class') == 'cas-chk-all')
539
+ cas_admin.toggleSelectAll(this, parent);
540
+ }).change(); //fire change event on page load
541
+ },
542
+ toggleTick: function(parent) {
543
+ //Toggle on any selected checkbox
544
+ parent.prev().toggleClass('cas-tick',parent.find('input:checked').length > 0);
545
+ },
546
+ /**
547
+ * Toggle specific input depending on "show with all" checkbox
548
+ */
549
+ toggleSelectAll: function(checkbox, parent) {
550
+ var checkboxes = parent.find("input[type=checkbox]").not(checkbox);
551
+ checkboxes.attr("disabled", $(checkbox).is(":checked"));
552
+ },
553
+ /**
554
+ * The value of Handle selection will control the
555
+ * accessibility of the host sidebar selection
556
+ * If Handling is manual, selection of host sidebar will be disabled
557
+ * @author Joachim Jensen <jv@intox.dk>
558
+ * @since 2.1
559
+ */
560
+ addHandleListener: function() {
561
+ var host = $("select[name='host']");
562
+ var code = $('<code>display_ca_sidebar();</code>');
563
+ var merge_pos = $('span.merge-pos');
564
+ host.parent().append(code);
565
+ $("select[name='handle']").change(function(){
566
+ var handle = $(this);
567
+ host.attr("disabled", handle.val() == 2);
568
+ if(handle.val() == 2) {
569
+ host.hide();
570
+ code.show();
571
+ } else {
572
+ host.show();
573
+ code.hide();
574
+ }
575
+ if(handle.val() == 3) {
576
+ merge_pos.hide();
577
+ } else {
578
+ merge_pos.show();
579
+ }
580
+ }).change(); //fire change event on page load
581
+ },
582
+ /**
583
+ * Use AJAX to search for content from a specific module
584
+ */
585
+ addSearchListener: function() {
586
+ var searchTimer;
587
+
588
+ $('.cas-autocomplete').keypress(function(e){
589
+ var t = $(this);
590
+
591
+ //If Enter (13) is pressed, search immediately
592
+ if( 13 == e.which ) {
593
+ cas_admin.updateSearchResults( t );
594
+ return false;
595
+ }
596
+
597
+ //If timer is already in progress, stop it
598
+ if( searchTimer ) clearTimeout(searchTimer);
599
+
600
+ searchTimer = setTimeout(function(){
601
+ cas_admin.updateSearchResults( t );
602
+ }, 400);
603
+ }).attr('autocomplete','off');
604
+
605
+ },
606
+ /**
607
+ * Make AJAX request to get results
608
+ * @author Joachim Jensen <jv@intox.dk>
609
+ * @since 2
610
+ * @param {Object} input
611
+ * @return {void}
612
+ */
613
+ updateSearchResults: function(input) {
614
+ var panel,
615
+ minSearchLength = 2,
616
+ q = input.val();
617
+
618
+ if( q.length < minSearchLength ) return;
619
+
620
+ panel = input.parents('.tabs-panel');
621
+ var spinner = $('.spinner', panel);
622
+
623
+ spinner.show();
624
+
625
+ $.ajax({
626
+ url: ajaxurl,
627
+ data:{
628
+ 'action': input.attr('class').split(' ')[0],
629
+ 'response-format': 'JSON',
630
+ 'nonce': cas_admin.nonce,
631
+ 'sidebar_id': cas_admin.sidebarID,
632
+ 'type': input.attr('id'),
633
+ 'q': q
634
+ },
635
+ dataType: 'JSON',
636
+ type: 'POST',
637
+ success:function(response){
638
+ var elements = "";
639
+ if(response.length > 0) {
640
+ $.each(response, function(i,item) {
641
+ elements += '<li><label class="selectit"><input value="'+item.value+'" type="checkbox" name="'+item.name+'[]"/> '+item.label+'</label></li>';
642
+ });
643
+ } else {
644
+ elements = '<li><p>'+CASAdmin.noResults+'</p></li>';
645
+ }
646
+
647
+ $('.categorychecklist', panel).html(elements);
648
+ spinner.hide();
649
+ },
650
+ error: function(xhr, desc, e) {
651
+ console.log(xhr.responseText);
652
+ }
653
+ });
654
+
655
+ },
656
+ }
657
+
658
+ $(document).ready(function(){ cas_admin.init(); });
659
+
660
+ })(jQuery);
js/widgets.js ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @package Content Aware Sidebars
3
+ * @author Joachim Jensen <jv@intox.dk>
4
+ */
5
+
6
+ (function($) {
7
+
8
+ var cas_admin = {
9
+
10
+ $sidebars: $(":not(.inactive) > div[id^='ca-sidebar']"),
11
+
12
+ init: function() {
13
+
14
+ this.addSidebarEditLink();
15
+
16
+ },
17
+
18
+ addSidebarEditLink: function() {
19
+
20
+ //When clicking on link, box should not close
21
+ $('.sidebar-name').on('click','.cas-edit-sidebar', function(e) {
22
+ e.stopPropagation();
23
+ });
24
+
25
+ this.$sidebars.each( function(e) {
26
+ $this = $(this);
27
+ var id = $this.attr('id').replace('ca-sidebar-','');
28
+ var $sidebar = $this.closest('.widgets-holder-wrap');
29
+
30
+ $sidebar.addClass('content-aware-sidebar')
31
+
32
+ $this.append('<div class="cas-sidebar-footer"><a title="'+CASAdmin.edit+'" class="cas-sidebar-link" href="post.php?post='+id+'&action=edit"><i class="dashicons dashicons-admin-generic"></i> '+CASAdmin.edit+'</a></div>');
33
+
34
+ });
35
+ }
36
+
37
+
38
+ }
39
+
40
+ $(document).ready(function(){ cas_admin.init(); });
41
+
42
+ })(jQuery);
modules/abstract.php CHANGED
@@ -208,7 +208,7 @@ abstract class CASModule {
208
  if($data) {
209
  echo '<div class="cas-condition cas-condition-'.$this->id.'">';
210
 
211
- echo '<strong>'.$this->name.'</strong>';
212
  echo '<ul>';
213
 
214
  if(in_array($this->id,$data)) {
208
  if($data) {
209
  echo '<div class="cas-condition cas-condition-'.$this->id.'">';
210
 
211
+ echo '<h4>'.$this->name.'</h4>';
212
  echo '<ul>';
213
 
214
  if(in_array($this->id,$data)) {
modules/post_type.php CHANGED
@@ -133,13 +133,13 @@ class CASModule_post_type extends CASModule {
133
  $posts =$this->_get_content(array('include' => $ids, 'posts_per_page' => -1, 'post_type' => $post_type->name, 'orderby' => 'title', 'order' => 'ASC'));
134
  if($posts || isset($lookup[$post_type->name]) || isset($lookup[ContentAwareSidebars::PREFIX.'sub_' . $post_type->name])) {
135
  echo '<div class="cas-condition cas-condition-'.$this->id.'-'.$post_type->name.'">';
136
- echo '<strong>'.$post_type->label.'</strong>';
137
  echo '<ul>';
138
  if(isset($lookup[ContentAwareSidebars::PREFIX.'sub_' . $post_type->name])) {
139
- echo '<li><label><input type="checkbox" name="cas_condition[post_types][]" value="'.ContentAwareSidebars::PREFIX.'sub_' . $post_type->name . '" checked="checked" /> ' . __('Automatically select new children of a selected ancestor', ContentAwareSidebars::DOMAIN) . '</label></li>' . "\n";
140
  }
141
  if(isset($lookup[$post_type->name])) {
142
- echo '<li><label><input type="checkbox" name="cas_condition[post_types][]" value="'.$post_type->name.'" checked="checked" /> '.$post_type->labels->all_items.'</label></li>' . "\n";
143
  }
144
  if($posts) {
145
  echo $this->post_checklist($post_type, $posts, false, $ids);
@@ -223,7 +223,11 @@ class CASModule_post_type extends CASModule {
223
  if(count($recent_posts) < 20) {
224
  $posts = $recent_posts;
225
  } else {
226
- $posts = $this->_get_content(array('post_type' => $post_type->name, 'orderby' => 'title', 'order' => 'ASC'));
 
 
 
 
227
  }
228
 
229
  $tabs = array();
133
  $posts =$this->_get_content(array('include' => $ids, 'posts_per_page' => -1, 'post_type' => $post_type->name, 'orderby' => 'title', 'order' => 'ASC'));
134
  if($posts || isset($lookup[$post_type->name]) || isset($lookup[ContentAwareSidebars::PREFIX.'sub_' . $post_type->name])) {
135
  echo '<div class="cas-condition cas-condition-'.$this->id.'-'.$post_type->name.'">';
136
+ echo '<h4>'.$post_type->label.'</h4>';
137
  echo '<ul>';
138
  if(isset($lookup[ContentAwareSidebars::PREFIX.'sub_' . $post_type->name])) {
139
+ echo '<li><label><input type="checkbox" name="cas_condition['.$this->id.'][]" value="'.ContentAwareSidebars::PREFIX.'sub_' . $post_type->name . '" checked="checked" /> ' . __('Automatically select new children of a selected ancestor', ContentAwareSidebars::DOMAIN) . '</label></li>' . "\n";
140
  }
141
  if(isset($lookup[$post_type->name])) {
142
+ echo '<li><label><input type="checkbox" name="cas_condition['.$this->id.'][]" value="'.$post_type->name.'" checked="checked" /> '.$post_type->labels->all_items.'</label></li>' . "\n";
143
  }
144
  if($posts) {
145
  echo $this->post_checklist($post_type, $posts, false, $ids);
223
  if(count($recent_posts) < 20) {
224
  $posts = $recent_posts;
225
  } else {
226
+ $posts = $this->_get_content(array(
227
+ 'post_type' => $post_type->name,
228
+ 'orderby' => 'title',
229
+ 'order' => 'ASC'
230
+ ));
231
  }
232
 
233
  $tabs = array();
modules/static.php CHANGED
@@ -37,9 +37,9 @@ class CASModule_static extends CASModule {
37
  */
38
  protected function _get_content($args = array()) {
39
  $static = array(
40
- 'front-page' => __('Front Page', ContentAwareSidebars::DOMAIN),
41
- 'search' => __('Search Results', ContentAwareSidebars::DOMAIN),
42
- '404' => __('404 Page', ContentAwareSidebars::DOMAIN)
43
  );
44
  if(isset($args['include'])) {
45
  $static = array_intersect_key($static, array_flip($args['include']));
@@ -71,7 +71,7 @@ class CASModule_static extends CASModule {
71
  }
72
  return array(
73
  $val
74
- );
75
  }
76
-
77
  }
37
  */
38
  protected function _get_content($args = array()) {
39
  $static = array(
40
+ 'front-page' => __('Front Page', ContentAwareSidebars::DOMAIN),
41
+ 'search' => __('Search Results', ContentAwareSidebars::DOMAIN),
42
+ '404' => __('404 Page', ContentAwareSidebars::DOMAIN)
43
  );
44
  if(isset($args['include'])) {
45
  $static = array_intersect_key($static, array_flip($args['include']));
71
  }
72
  return array(
73
  $val
74
+ );
75
  }
76
+
77
  }
modules/taxonomy.php CHANGED
@@ -67,7 +67,7 @@ class CASModule_taxonomy extends CASModule {
67
  * Determine if content is relevant
68
  * @return boolean
69
  */
70
- public function in_context() {
71
  if(is_singular()) {
72
  // Check if content has any taxonomies supported
73
  $taxonomies = get_object_taxonomies(get_post_type(),'object');
@@ -221,13 +221,13 @@ class CASModule_taxonomy extends CASModule {
221
  //$posts = wp_get_object_terms( $post_id, $taxonomy->name);
222
  if($posts || isset($ids[$taxonomy->name]) || isset($ids[ContentAwareSidebars::PREFIX.'sub_' . $taxonomy->name])) {
223
  echo '<div class="cas-condition cas-condition-'.$this->id.'-'.$taxonomy->name.'">';
224
- echo '<strong>'.$taxonomy->label.'</strong>';
225
  echo '<ul>';
226
  if(isset($ids[ContentAwareSidebars::PREFIX.'sub_' . $taxonomy->name])) {
227
- echo '<li class=""><label><input type="checkbox" name="cas_condition[taxonomies][]" value="'.ContentAwareSidebars::PREFIX.'sub_' . $taxonomy->name . '" checked="checked" /> ' . __('Automatically select new children of a selected ancestor', ContentAwareSidebars::DOMAIN) . '</label></li>' . "\n";
228
  }
229
  if(isset($ids[$taxonomy->name])) {
230
- echo '<li class=""><label><input type="checkbox" name="cas_condition[taxonomies][]" value="'.$taxonomy->name.'" checked="checked" /> '.$taxonomy->labels->all_items.'</label></li>' . "\n";
231
  }
232
  if($posts) {
233
  echo $this->term_checklist($taxonomy, $posts);
@@ -263,11 +263,11 @@ class CASModule_taxonomy extends CASModule {
263
 
264
  if($taxonomy->hierarchical) {
265
  echo '<ul><li>' . "\n";
266
- echo '<label><input type="checkbox" name="cas_condition[taxonomies][]" value="'.ContentAwareSidebars::PREFIX.'sub_' . $taxonomy->name . '" /> ' . __('Automatically select new children of a selected ancestor', ContentAwareSidebars::DOMAIN) . '</label>' . "\n";
267
  echo '</li></ul>' . "\n";
268
  }
269
  echo '<ul><li>' . "\n";
270
- echo '<label><input class="cas-chk-all" type="checkbox" name="cas_condition[taxonomies][]" value="' . $taxonomy->name . '" /> ' . sprintf(__('Display with %s', ContentAwareSidebars::DOMAIN), $taxonomy->labels->all_items) . '</label>' . "\n";
271
  echo '</li></ul>' . "\n";
272
 
273
  if (!$terms) {
@@ -330,7 +330,7 @@ class CASModule_taxonomy extends CASModule {
330
  $walker = new CAS_Walker_Checklist('category',array('parent' => 'parent', 'id' => 'term_id'));
331
 
332
  $args = array(
333
- 'taxonomy' => $taxonomy,
334
  'selected_terms' => $selected_terms
335
  );
336
 
67
  * Determine if content is relevant
68
  * @return boolean
69
  */
70
+ public function in_context() {
71
  if(is_singular()) {
72
  // Check if content has any taxonomies supported
73
  $taxonomies = get_object_taxonomies(get_post_type(),'object');
221
  //$posts = wp_get_object_terms( $post_id, $taxonomy->name);
222
  if($posts || isset($ids[$taxonomy->name]) || isset($ids[ContentAwareSidebars::PREFIX.'sub_' . $taxonomy->name])) {
223
  echo '<div class="cas-condition cas-condition-'.$this->id.'-'.$taxonomy->name.'">';
224
+ echo '<h4>'.$taxonomy->label.'</h4>';
225
  echo '<ul>';
226
  if(isset($ids[ContentAwareSidebars::PREFIX.'sub_' . $taxonomy->name])) {
227
+ echo '<li class=""><label><input type="checkbox" name="cas_condition['.$this->id.'][]" value="'.ContentAwareSidebars::PREFIX.'sub_' . $taxonomy->name . '" checked="checked" /> ' . __('Automatically select new children of a selected ancestor', ContentAwareSidebars::DOMAIN) . '</label></li>' . "\n";
228
  }
229
  if(isset($ids[$taxonomy->name])) {
230
+ echo '<li class=""><label><input type="checkbox" name="cas_condition['.$this->id.'][]" value="'.$taxonomy->name.'" checked="checked" /> '.$taxonomy->labels->all_items.'</label></li>' . "\n";
231
  }
232
  if($posts) {
233
  echo $this->term_checklist($taxonomy, $posts);
263
 
264
  if($taxonomy->hierarchical) {
265
  echo '<ul><li>' . "\n";
266
+ echo '<label><input type="checkbox" name="cas_condition['.$this->id.'][]" value="'.ContentAwareSidebars::PREFIX.'sub_' . $taxonomy->name . '" /> ' . __('Automatically select new children of a selected ancestor', ContentAwareSidebars::DOMAIN) . '</label>' . "\n";
267
  echo '</li></ul>' . "\n";
268
  }
269
  echo '<ul><li>' . "\n";
270
+ echo '<label><input class="cas-chk-all" type="checkbox" name="cas_condition['.$this->id.'][]" value="' . $taxonomy->name . '" /> ' . sprintf(__('Display with %s', ContentAwareSidebars::DOMAIN), $taxonomy->labels->all_items) . '</label>' . "\n";
271
  echo '</li></ul>' . "\n";
272
 
273
  if (!$terms) {
330
  $walker = new CAS_Walker_Checklist('category',array('parent' => 'parent', 'id' => 'term_id'));
331
 
332
  $args = array(
333
+ 'taxonomy' => $taxonomy,
334
  'selected_terms' => $selected_terms
335
  );
336
 
readme.txt CHANGED
@@ -1,403 +1,413 @@
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, widget area, content aware, context aware, conditional, seo, dynamic, bbpress, buddypress, qtranslate, polylang, transposh, wpml, woocommerce
5
- Requires at least: 3.3
6
- Tested up to: 3.9.1
7
- Stable tag: 2.3
8
- License: GPLv3
9
-
10
- Create and display sidebars according to the content being viewed.
11
-
12
- == Description ==
13
-
14
- Manage an infinite number of sidebars.
15
- Boost on-site SEO with better Calls to Action by controlling what content your sidebars should be displayed with.
16
- The sidebar manager makes it incredibly easy for anyone to create flexible, dynamic sidebars without the need of code.
17
- Developed with speed and performance in mind and will add no extra database tables or table columns.
18
-
19
- > **New in version 2**
20
- >
21
- > Manage widgets for your created sidebars in the Theme Customizer.
22
- >
23
- > Condition groups let you display a sidebar together with both associated and distinct content.
24
- >
25
- > Improved GUI makes it even easier to select content and edit sidebars.
26
- >
27
- > Improved API for developers who want to extend and manipulate content support.
28
- >
29
-
30
- = Features =
31
-
32
- * Easy-to-use Sidebar Manager
33
- * Widget management integration in Theme Customizer (WP3.9+)
34
- * Display sidebars with all or specific:
35
- * Singulars - e.g. posts or pages
36
- * (Custom) Post Types
37
- * Singulars with given (custom) taxonomies or taxonomy terms - e.g. categories or tags
38
- * Singulars by a given author
39
- * Page Templates
40
- * Post Formats
41
- * Post Type Archives
42
- * Author Archives
43
- * (Custom) Taxonomy Archives or Taxonomy Term Archives
44
- * Search Results
45
- * 404 Page
46
- * Front Page
47
- * bbPress User Profiles
48
- * BuddyPress Member Pages
49
- * Languages (qTranslate, Polylang, Transposh, WPML)
50
- * **Any combination of the above**
51
- * Sidebars can automatically merge with or replace others
52
- * Create complex content with nested sidebars
53
- * Private sidebars only for members
54
- * Schedule sidebars for later publishing
55
- * Template Tag to display content aware sidebars anywhere in your theme
56
-
57
- = Builtin Plugin Support =
58
-
59
- * bbPress (v2.0.2+)
60
- * BuddyPress (v1.6.2+)
61
- * qTranslate (v2.5.29+)
62
- * Polylang (v1.2+)
63
- * Transposh Translation Filter (v0.9.5+)
64
- * [WPML Multilingual Blog/CMS (v2.4.3+) Tested and certified](http://wpml.org/plugin/content-aware-sidebars/)
65
-
66
- = Translations =
67
-
68
- * Chinese (zh_CN): [Joe Tze](http://tkjune.com)
69
- * Danish (da_DK): [Joachim Jensen](http://www.intox.dk/)
70
- * German (de_DE): Enno Wulff
71
- * Hungarian (hu_HU): Kis Lukács
72
- * Italian (it_IT): [Luciano Del Fico](http://www.myweb2.it/)
73
- * Latvian (lv_LV): Haralds Gribusts
74
- * Lithuanian (lt_LT): Vincent G
75
- * Slovak (sk_SK): Branco
76
- * Spanish (es_ES): [Analia Jensen](http://www.linkedin.com/in/analiajensen)
77
- * Ukranian (uk_UA): [Michael Yunat](http://getvoip.com)
78
-
79
- Do you want to see your name here?
80
-
81
- 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.
82
- Download the latest [template .po file](http://plugins.svn.wordpress.org/content-aware-sidebars/trunk/lang/content-aware-sidebars.po) or the [.po file in your language](http://plugins.svn.wordpress.org/content-aware-sidebars/trunk/lang/).
83
-
84
- = More information =
85
-
86
- [Documentation](http://www.intox.dk/en/plugin/content-aware-sidebars-en/)
87
-
88
- == Installation ==
89
-
90
- 1. Upload the full plugin directory to your `/wp-content/plugins/` directory or install the plugin through `Plugins` in the administration
91
- 1. Activate the plugin through `Plugins` in the administration
92
- 1. Have fun creating your first sidebar
93
- 1. Optional: Insert `<?php display_ca_sidebar( $args ); ?>` in a template if you have a special spot for the new, manual handled, sidebars.
94
-
95
- == Frequently Asked Questions ==
96
-
97
- [Click here to go to the official FAQ page for Content Aware Sidebars](http://www.intox.dk/en/plugin/content-aware-sidebars-en/faq/).
98
-
99
- == Screenshots ==
100
-
101
- 1. Add a new Content Aware Sidebar to be displayed with all Posts that contains the category Very Categorized. It replaces `Primary Sidebar`
102
- 2. Simple overview of all created Content Aware Sidebars
103
- 3. Add widgets to the newly added sidebar
104
- 4. Viewing front page of site. `Primary Sidebar` is displayed
105
- 5. Viewing a Post that contains Very Categorized. `Very Categorized Posts` sidebar has replaced `Primary Sidebar`
106
-
107
- == Upgrade Notice ==
108
-
109
- = 2.0 =
110
-
111
- * Content Aware Sidebars data in your database will be updated automatically. It is highly recommended to backup this data before updating the plugin.
112
- * Minimum WordPress version compatibility is now 3.3.
113
-
114
- = 1.1 =
115
-
116
- * Content Aware Sidebars data in your database will be updated automatically. Remember to backup this data before updating the plugin.
117
-
118
- = 0.8 =
119
-
120
- * Content Aware Sidebars data in your database will be updated automatically. Remember to backup this data before updating the plugin.
121
-
122
- = 0.5 =
123
-
124
- * Note that the plugin now requires at least WordPress 3.1 because of post type archives.
125
-
126
- = 0.4 =
127
-
128
- * All current custom sidebars have to be updated after plugin upgrade due to the new archive rules
129
-
130
- = 0.1 =
131
-
132
- * Hello World
133
-
134
- == Changelog ==
135
-
136
- = 2.3 =
137
-
138
- * Added: ukranian translation
139
- * Added: error if trying to access php files directly
140
- * Added: bbpress, bp_member, polylang, qtranslate, transposh and wpml modules are more robust
141
- * Added: content rule boxes can be hidden in screen options in sidebar editor
142
- * Added: help tab in sidebar editor
143
- * Added: widgets count column in sidebar overview
144
- * Added: menu order moved to options meta box in sidebar editor
145
- * Fixed: merge position option hidden on forced replace handle
146
- * Fixed: polylang compatibility now 1.2+
147
- * Fixed: width of columns in sidebar overview
148
- * Removed: exposure column in sidebar overview
149
-
150
- = 2.2.1 =
151
-
152
- * Fixed: taxonomy archive conditions did not work with other modules properly
153
- * Fixed: removed display limit of 20 for saved post type conditions
154
- * Fixed: saved post type conditions ordered alphabetically
155
-
156
- = 2.2 =
157
-
158
- * Added: sidebar displayed in theme customizer (wp3.4+)
159
- * Added: widget management integration in theme customizer (wp3.9+)
160
- * Added: handle for forced replace
161
- * Fixed: reduced database queries in sidebar editor
162
- * Fixed: disable all add to group buttons before creating first condition group
163
-
164
- = 2.1 =
165
-
166
- * Added: empty condition groups cannot be saved
167
- * Added: confirmation on various condition group actions in sidebar editor
168
- * Added: improved ux design for sidebar editor
169
- * Added: chinese translation
170
- * Added: wp3.9 compatibility
171
- * Fixed: transposh compatibility now 0.9.5+
172
- * Fixed: removed warnings for auto-select new children functionality
173
- * Fixed: unprivileged users could in theory make, but never successfully execute, ajax requests for sidebar editor
174
- * Fixed: removed warning in widgets screen when handle is not set
175
-
176
- = 2.0.3 =
177
-
178
- * Fixed: taxonomy pagination in sidebar editor
179
- * Fixed: categories found in search can now be saved. props Xandoc
180
-
181
- = 2.0.2 =
182
-
183
- * Fixed: terms caused a sidebar to be displayed on all pages
184
-
185
- = 2.0.1 =
186
-
187
- * Fixed: admin menu would in some cases be overwritten by other plugins
188
-
189
- = 2.0 =
190
-
191
- * Added: condition groups
192
- * Added: gui and uxd overhaul for sidebar editor
193
- * Added: pagination for taxonomies in sidebar editor
194
- * Added: pagination for post types in sidebar editor
195
- * Added: mysql 5.6+ compatibility
196
- * Added: more efficient uninstall process
197
- * Added: easier for developers to extend and manipulate content support
198
- * Added: wp3.8 and mp6 compatibility
199
- * Added: german translation
200
- * Added: hungarian translation
201
- * Added: latvian translation
202
- * Added: spanish translation
203
- * Added: all conditions follow a strict logical "and" operator per group
204
- * Fixed: scripts and styles only loaded on sidebar administrative pages
205
- * Fixed: slovak translation now recognized
206
- * Fixed: paths to assets compatible with ssl
207
- * Removed: jquery ui autocomplete and accordion
208
-
209
- = 1.3.5 =
210
-
211
- * Fixed: menu would disappear in rare cases. Props grezvany13
212
- * Fixed: search function now searches in title and slug (not content) for post types
213
- * Added: search function displays at most 20 results instead of 10
214
-
215
- = 1.3.4 =
216
-
217
- * Fixed: cas_walker_checklist now follows walker declaration for wp3.6
218
- * Fixed: content list in accordion now not scrollable
219
- * Fixed: only terms from public taxonomies are included for content recognition.
220
- * Fixed: polylang fully supported again
221
- * Fixed: consistent css across wp versions
222
- * Removed: flushing rewrite rules on activation/deactivation is needless
223
-
224
- = 1.3.3 =
225
-
226
- * Added: html placeholder in search field
227
- * Added: items already displayed in edit page moved to top and checked when found in search
228
- * Fixed: private and scheduled singulars included in search results
229
- * Fixed: search results displayed in ascending order
230
-
231
- = 1.3.2 =
232
-
233
- * Added: items found in search now added to list directly on select
234
- * Fixed: some terms found by search could not be saved
235
- * Fixed: widget locations are saved again for each theme
236
-
237
- = 1.3.1 =
238
-
239
- * Added: authors and bbpress user profiles now searchable on edit page
240
- * Added: items found in search on edit page are prepended and checked by default
241
- * Added: updated edit page gui
242
- * Added: search field only visible when quantity is above 20
243
- * Fixed: select all checkbox will now disable all input in container
244
- * Fixed: host sidebar could sometimes not be found in sidebar list
245
-
246
- = 1.3 =
247
-
248
- * Added: post type posts and taxonomy terms now searchable on edit page
249
- * Added: sidebar handle and host shown on widgets page
250
- * Added: slovak translation
251
- * Fixed: sidebar meta boxes more robust to external modifications
252
- * Fixed: admin column headers more robust to external modifications
253
- * Fixed: sidebar menu now always hidden for users without right cap
254
- * Fixed: code optimization and refactor for performance
255
- * Removed: support for sidebar excerpt
256
-
257
- = 1.2 =
258
-
259
- * Added: polylang support
260
- * Added: buddypress support
261
- * Added: managing sidebars now requires edit_theme_options cap
262
- * Added: bbpress user profile has own rules instead of author rules
263
- * Added: filter for content recognition
264
- * Added: auto-select new children of selected taxonomy or post type ancestor
265
-
266
- = 1.1.2 =
267
-
268
- * Added: wordpress 3.5 compatibility
269
- * Fixed: slight css changes on edit screen
270
- * Fixed: "show with all" checkbox toggles other checkboxes correctly
271
-
272
- = 1.1.1 =
273
-
274
- * Fixed: slight css changes on edit screen
275
- * Fixed: tick.png included
276
- * Fixed: taxonomy terms could influence each other in rare cases
277
- * Fixed: taxonomy wide rules for taxonomy archives
278
- * Fixed: cache caused db update module to skip 1.1 update if going from 0
279
-
280
- = 1.1 =
281
-
282
- * Added: improved gui on edit screen including content accordion
283
- * Added: bbpress forum-topic dependency
284
- * Added: sidebars hidden on password protected content
285
- * Added: relevant usermeta cleared on plugin deletion
286
- * Fixed: performance gain by dropping serialized metadata
287
- * Fixed: database data update module revised
288
- * Fixed: css class in posts and terms walker
289
- * Fixed: limit of max 200 of each content type on edit screen (temp)
290
- * Fixed: style and scripts loaded properly
291
- * Removed: individual content meta boxes on edit screen
292
-
293
- = 1.0 =
294
-
295
- * Added: plugin rewritten to flexible modular system
296
- * Added: builtin support for bbpress, qtranslate, transposh, wpml
297
- * Added: lithuanian translation
298
- * Fixed: all present rules now dependent of each other
299
- * Fixed: sidebar update messages
300
- * Fixed: specific hooks now not sitewide
301
- * Fixed: better use of meta cache
302
- * Fixed: dir structure
303
- * Fixed: unexpected output notice on plugin activation
304
-
305
- = 0.8.3 =
306
-
307
- * Added: danish and italian translation
308
- * Fixed: sidebar query might be larger than max_join_size
309
- * Fixed: row content in admin overview would be loaded with post types with matching keys
310
-
311
- = 0.8.2 =
312
-
313
- * Fixed: new rules caused issues with post types with taxonomies
314
-
315
- = 0.8.1 =
316
-
317
- * Fixed: several checks for proper widget and sidebar removal
318
-
319
- = 0.8 =
320
-
321
- * Added: some rules are dependent of each other if present
322
- * Added: widgets in removed sidebars will be removed too
323
- * Added: database data update module
324
- * Added: rewrite rules flushed on plugin deactivation
325
- * Added: data will be removed when plugin is uninstalled
326
- * Added: icon-32 is back
327
- * Added: message if a host is not available in sidebar overview
328
- * Fixed: prefixed data
329
- * Fixed: data hidden from custom fields
330
- * Fixed: manage widgets link removed from trashed sidebars
331
- * Fixed: view sidebar link removed in wp3.1.x
332
- * Fixed: all custom taxonomies could not be removed again when assigned to sidebar
333
- * Fixed: altered options meta box on edit screen
334
- * Fixed: check if host of sidebar exists before handling it
335
-
336
- = 0.7 =
337
-
338
- * Added: sidebars will be displayed even if empty (i.e. hidden)
339
- * Added: author rules on singulars and archives
340
- * Added: page template rules
341
- * Added: javascript handling for disabling/enabling specific input on editor page
342
- * Fixed: minor tweak for full compatibility with wp3.3
343
- * Fixed: function for meta boxes is called only on editor page
344
- * Fixed: proper column sorting in administration
345
- * Fixed: specific post type label not supported in wp3.1.x
346
- * Fixed: type (array) not supported as post_status in get_posts() in wp3.1.x
347
- * Fixed: code cleanup
348
-
349
- = 0.6.3 =
350
-
351
- * Added: scheduled and private singulars are selectable in sidebar editor
352
- * Added: combined cache for manual and automatically handled sidebars
353
- * Added: display_ca_sidebar accepts specific ids to be included
354
- * Fixed: only a limited amount of sidebars were present in widgets area
355
- * Fixed: better caching in sidebar editor
356
- * Fixed: page list in sidebar editor could behave incorrectly if some pages were static
357
-
358
- = 0.6.2 =
359
-
360
- * Fixed: array_flip triggered type mismatch errors in some cases
361
-
362
- = 0.6.1 =
363
-
364
- * Fixed: an image caused headers already sent error
365
-
366
- = 0.6 =
367
-
368
- * Added: sidebars can be set with specific singulars
369
- * Added: sidebars can be set with specific post formats
370
- * Added: updated gui
371
- * Fixed: draft sidebars save meta
372
-
373
- = 0.5 =
374
-
375
- * Added: search, 404, front page rules now supported
376
- * Fixed: custom tax and terms are now supported properly (again)
377
-
378
- = 0.4 =
379
-
380
- * Added: post type archives, taxonomy archives and taxonomy terms archives now supported
381
- * Added: taxonomy rules
382
- * Added: removable donation button
383
- * Fixed: faster!
384
-
385
- = 0.3 =
386
-
387
- * Added: sidebars can now be private
388
- * Fixed: taxonomy terms are now supported by template function
389
- * Fixed: faster rule recognition and handling
390
- * Fixed: custom taxonomies are now supported properly
391
- * Fixed: error if several sidebars had taxonomy terms rules
392
-
393
- = 0.2 =
394
-
395
- * Added: taxonomy terms rules
396
- * Added: optional description for sidebars
397
- * Added: display_ca_sidebar also accepts URL-style string as parameter
398
- * Fixed: saving meta now only kicks in with sidebar types
399
- * Fixed: archives are not singulars and will not be treated like them
400
-
401
- = 0.1 =
402
-
403
- * First stable release
 
 
 
 
 
 
 
 
 
 
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, widget area, content aware, context aware, conditional, seo, dynamic, bbpress, buddypress, qtranslate, polylang, transposh, wpml, woocommerce
5
+ Requires at least: 3.3
6
+ Tested up to: 4.0
7
+ Stable tag: 2.4
8
+ License: GPLv3
9
+
10
+ Create and display sidebars according to the content being viewed.
11
+
12
+ == Description ==
13
+
14
+ Manage an infinite number of sidebars.
15
+ Boost on-site SEO with better Calls to Action by controlling what content your sidebars should be displayed with.
16
+ The sidebar manager makes it incredibly easy for anyone to create flexible, dynamic sidebars without the need of code.
17
+ Developed with speed and performance in mind and will add no extra database tables or table columns.
18
+
19
+ = Features =
20
+
21
+ * Easy-to-use Sidebar Manager
22
+ * Widget management integration in Theme Customizer (WP3.9+)
23
+ * Display sidebars with all or specific:
24
+ * Singulars - e.g. posts or pages
25
+ * (Custom) Post Types
26
+ * Singulars with given (custom) taxonomies or taxonomy terms - e.g. categories or tags
27
+ * Singulars by a given author
28
+ * Page Templates
29
+ * Post Formats
30
+ * Post Type Archives
31
+ * Author Archives
32
+ * (Custom) Taxonomy Archives or Taxonomy Term Archives
33
+ * Search Results
34
+ * 404 Page
35
+ * Front Page
36
+ * bbPress User Profiles
37
+ * BuddyPress Member Pages
38
+ * Languages (qTranslate, Polylang, Transposh, WPML)
39
+ * **Any combination of the above**
40
+ * Sidebars can automatically merge with or replace others
41
+ * Create complex content with nested sidebars
42
+ * Private sidebars only for members
43
+ * Schedule sidebars for later publishing
44
+ * Template Tag to display content aware sidebars anywhere in your theme
45
+
46
+ > **New in version 2**
47
+ >
48
+ > Manage widgets for your created sidebars in the Theme Customizer.
49
+ >
50
+ > Condition groups let you display a sidebar together with both associated and distinct content.
51
+ >
52
+ > Improved GUI makes it even easier to select content and edit sidebars.
53
+ >
54
+ > Improved API for developers who want to extend and manipulate content support.
55
+ >
56
+
57
+ = Builtin Plugin Support =
58
+
59
+ * bbPress (v2.0.2+)
60
+ * BuddyPress (v1.6.2+)
61
+ * qTranslate (v2.5.29+)
62
+ * Polylang (v1.2+)
63
+ * Transposh Translation Filter (v0.9.5+)
64
+ * [WPML Multilingual Blog/CMS (v2.4.3+) Tested and certified](http://wpml.org/plugin/content-aware-sidebars/)
65
+
66
+ = Translations =
67
+
68
+ * Chinese (zh_CN): [Joe Tze](http://tkjune.com)
69
+ * Danish (da_DK): [Joachim Jensen](http://www.intox.dk/)
70
+ * German (de_DE): Enno Wulff
71
+ * Hungarian (hu_HU): Kis Lukács
72
+ * Italian (it_IT): [Luciano Del Fico](http://www.myweb2.it/)
73
+ * Latvian (lv_LV): Haralds Gribusts
74
+ * Lithuanian (lt_LT): Vincent G
75
+ * Slovak (sk_SK): Branco
76
+ * Spanish (es_ES): [Analia Jensen](http://www.linkedin.com/in/analiajensen)
77
+ * Ukranian (uk_UA): [Michael Yunat](http://getvoip.com)
78
+
79
+ Do you want to see your name here?
80
+
81
+ 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.
82
+ Download the latest [template .po file](http://plugins.svn.wordpress.org/content-aware-sidebars/trunk/lang/content-aware-sidebars.po) or the [.po file in your language](http://plugins.svn.wordpress.org/content-aware-sidebars/trunk/lang/).
83
+
84
+ = More information =
85
+
86
+ [Documentation](http://www.intox.dk/en/plugin/content-aware-sidebars-en/)
87
+ [Follow development on Github](https://github.com/intoxstudio/content-aware-sidebars)
88
+
89
+ == Installation ==
90
+
91
+ 1. Upload the full plugin directory to your `/wp-content/plugins/` directory or install the plugin through `Plugins` in the administration
92
+ 1. Activate the plugin through `Plugins` in the administration
93
+ 1. Have fun creating your first sidebar
94
+ 1. Optional: Insert `<?php display_ca_sidebar( $args ); ?>` in a template if you have a special spot for the new, manual handled, sidebars.
95
+
96
+ == Frequently Asked Questions ==
97
+
98
+ [Click here to go to the official FAQ page for Content Aware Sidebars](http://www.intox.dk/en/plugin/content-aware-sidebars-en/faq/).
99
+
100
+ == Screenshots ==
101
+
102
+ 1. Add a new Content Aware Sidebar to be displayed with all Posts that contains the category Very Categorized. It replaces `Primary Sidebar`
103
+ 2. Simple overview of all created Content Aware Sidebars
104
+ 3. Add widgets to the newly added sidebar
105
+ 4. Viewing front page of site. `Primary Sidebar` is displayed
106
+ 5. Viewing a Post that contains Very Categorized. `Very Categorized Posts` sidebar has replaced `Primary Sidebar`
107
+
108
+ == Upgrade Notice ==
109
+
110
+ = 2.0 =
111
+
112
+ * Content Aware Sidebars data in your database will be updated automatically. It is highly recommended to backup this data before updating the plugin.
113
+ * Minimum WordPress version compatibility is now 3.3.
114
+
115
+ = 1.1 =
116
+
117
+ * Content Aware Sidebars data in your database will be updated automatically. Remember to backup this data before updating the plugin.
118
+
119
+ = 0.8 =
120
+
121
+ * Content Aware Sidebars data in your database will be updated automatically. Remember to backup this data before updating the plugin.
122
+
123
+ = 0.5 =
124
+
125
+ * Note that the plugin now requires at least WordPress 3.1 because of post type archives.
126
+
127
+ = 0.4 =
128
+
129
+ * All current custom sidebars have to be updated after plugin upgrade due to the new archive rules
130
+
131
+ = 0.1 =
132
+
133
+ * Hello World
134
+
135
+ == Changelog ==
136
+
137
+ = 2.4 =
138
+
139
+ * Added: compatibility with wp4.0
140
+ * Added: better ux design for condition groups
141
+ * Added: better ux design for sidebars in widgets screen, including an edit link
142
+ * Added: dashicon for admin menu (wp3.8+)
143
+ * Fixed: using some newer wordpress actions and filters for admin columns
144
+ * Fixed: sidebars could be fetched and prepared in administration
145
+
146
+ = 2.3 =
147
+
148
+ * Added: ukranian translation
149
+ * Added: error if trying to access php files directly
150
+ * Added: bbpress, bp_member, polylang, qtranslate, transposh and wpml modules are more robust
151
+ * Added: content rule boxes can be hidden in screen options in sidebar editor
152
+ * Added: help tab in sidebar editor
153
+ * Added: widgets count column in sidebar overview
154
+ * Added: menu order moved to options meta box in sidebar editor
155
+ * Fixed: merge position option hidden on forced replace handle
156
+ * Fixed: polylang compatibility now 1.2+
157
+ * Fixed: width of columns in sidebar overview
158
+ * Removed: exposure column in sidebar overview
159
+
160
+ = 2.2.1 =
161
+
162
+ * Fixed: taxonomy archive conditions did not work with other modules properly
163
+ * Fixed: removed display limit of 20 for saved post type conditions
164
+ * Fixed: saved post type conditions ordered alphabetically
165
+
166
+ = 2.2 =
167
+
168
+ * Added: sidebar displayed in theme customizer (wp3.4+)
169
+ * Added: widget management integration in theme customizer (wp3.9+)
170
+ * Added: handle for forced replace
171
+ * Fixed: reduced database queries in sidebar editor
172
+ * Fixed: disable all add to group buttons before creating first condition group
173
+
174
+ = 2.1 =
175
+
176
+ * Added: empty condition groups cannot be saved
177
+ * Added: confirmation on various condition group actions in sidebar editor
178
+ * Added: improved ux design for sidebar editor
179
+ * Added: chinese translation
180
+ * Added: wp3.9 compatibility
181
+ * Fixed: transposh compatibility now 0.9.5+
182
+ * Fixed: removed warnings for auto-select new children functionality
183
+ * Fixed: unprivileged users could in theory make, but never successfully execute, ajax requests for sidebar editor
184
+ * Fixed: removed warning in widgets screen when handle is not set
185
+
186
+ = 2.0.3 =
187
+
188
+ * Fixed: taxonomy pagination in sidebar editor
189
+ * Fixed: categories found in search can now be saved. props Xandoc
190
+
191
+ = 2.0.2 =
192
+
193
+ * Fixed: terms caused a sidebar to be displayed on all pages
194
+
195
+ = 2.0.1 =
196
+
197
+ * Fixed: admin menu would in some cases be overwritten by other plugins
198
+
199
+ = 2.0 =
200
+
201
+ * Added: condition groups
202
+ * Added: gui and uxd overhaul for sidebar editor
203
+ * Added: pagination for taxonomies in sidebar editor
204
+ * Added: pagination for post types in sidebar editor
205
+ * Added: mysql 5.6+ compatibility
206
+ * Added: more efficient uninstall process
207
+ * Added: easier for developers to extend and manipulate content support
208
+ * Added: wp3.8 and mp6 compatibility
209
+ * Added: german translation
210
+ * Added: hungarian translation
211
+ * Added: latvian translation
212
+ * Added: spanish translation
213
+ * Added: all conditions follow a strict logical "and" operator per group
214
+ * Fixed: scripts and styles only loaded on sidebar administrative pages
215
+ * Fixed: slovak translation now recognized
216
+ * Fixed: paths to assets compatible with ssl
217
+ * Removed: jquery ui autocomplete and accordion
218
+
219
+ = 1.3.5 =
220
+
221
+ * Fixed: menu would disappear in rare cases. Props grezvany13
222
+ * Fixed: search function now searches in title and slug (not content) for post types
223
+ * Added: search function displays at most 20 results instead of 10
224
+
225
+ = 1.3.4 =
226
+
227
+ * Fixed: cas_walker_checklist now follows walker declaration for wp3.6
228
+ * Fixed: content list in accordion now not scrollable
229
+ * Fixed: only terms from public taxonomies are included for content recognition.
230
+ * Fixed: polylang fully supported again
231
+ * Fixed: consistent css across wp versions
232
+ * Removed: flushing rewrite rules on activation/deactivation is needless
233
+
234
+ = 1.3.3 =
235
+
236
+ * Added: html placeholder in search field
237
+ * Added: items already displayed in edit page moved to top and checked when found in search
238
+ * Fixed: private and scheduled singulars included in search results
239
+ * Fixed: search results displayed in ascending order
240
+
241
+ = 1.3.2 =
242
+
243
+ * Added: items found in search now added to list directly on select
244
+ * Fixed: some terms found by search could not be saved
245
+ * Fixed: widget locations are saved again for each theme
246
+
247
+ = 1.3.1 =
248
+
249
+ * Added: authors and bbpress user profiles now searchable on edit page
250
+ * Added: items found in search on edit page are prepended and checked by default
251
+ * Added: updated edit page gui
252
+ * Added: search field only visible when quantity is above 20
253
+ * Fixed: select all checkbox will now disable all input in container
254
+ * Fixed: host sidebar could sometimes not be found in sidebar list
255
+
256
+ = 1.3 =
257
+
258
+ * Added: post type posts and taxonomy terms now searchable on edit page
259
+ * Added: sidebar handle and host shown on widgets page
260
+ * Added: slovak translation
261
+ * Fixed: sidebar meta boxes more robust to external modifications
262
+ * Fixed: admin column headers more robust to external modifications
263
+ * Fixed: sidebar menu now always hidden for users without right cap
264
+ * Fixed: code optimization and refactor for performance
265
+ * Removed: support for sidebar excerpt
266
+
267
+ = 1.2 =
268
+
269
+ * Added: polylang support
270
+ * Added: buddypress support
271
+ * Added: managing sidebars now requires edit_theme_options cap
272
+ * Added: bbpress user profile has own rules instead of author rules
273
+ * Added: filter for content recognition
274
+ * Added: auto-select new children of selected taxonomy or post type ancestor
275
+
276
+ = 1.1.2 =
277
+
278
+ * Added: wordpress 3.5 compatibility
279
+ * Fixed: slight css changes on edit screen
280
+ * Fixed: "show with all" checkbox toggles other checkboxes correctly
281
+
282
+ = 1.1.1 =
283
+
284
+ * Fixed: slight css changes on edit screen
285
+ * Fixed: tick.png included
286
+ * Fixed: taxonomy terms could influence each other in rare cases
287
+ * Fixed: taxonomy wide rules for taxonomy archives
288
+ * Fixed: cache caused db update module to skip 1.1 update if going from 0
289
+
290
+ = 1.1 =
291
+
292
+ * Added: improved gui on edit screen including content accordion
293
+ * Added: bbpress forum-topic dependency
294
+ * Added: sidebars hidden on password protected content
295
+ * Added: relevant usermeta cleared on plugin deletion
296
+ * Fixed: performance gain by dropping serialized metadata
297
+ * Fixed: database data update module revised
298
+ * Fixed: css class in posts and terms walker
299
+ * Fixed: limit of max 200 of each content type on edit screen (temp)
300
+ * Fixed: style and scripts loaded properly
301
+ * Removed: individual content meta boxes on edit screen
302
+
303
+ = 1.0 =
304
+
305
+ * Added: plugin rewritten to flexible modular system
306
+ * Added: builtin support for bbpress, qtranslate, transposh, wpml
307
+ * Added: lithuanian translation
308
+ * Fixed: all present rules now dependent of each other
309
+ * Fixed: sidebar update messages
310
+ * Fixed: specific hooks now not sitewide
311
+ * Fixed: better use of meta cache
312
+ * Fixed: dir structure
313
+ * Fixed: unexpected output notice on plugin activation
314
+
315
+ = 0.8.3 =
316
+
317
+ * Added: danish and italian translation
318
+ * Fixed: sidebar query might be larger than max_join_size
319
+ * Fixed: row content in admin overview would be loaded with post types with matching keys
320
+
321
+ = 0.8.2 =
322
+
323
+ * Fixed: new rules caused issues with post types with taxonomies
324
+
325
+ = 0.8.1 =
326
+
327
+ * Fixed: several checks for proper widget and sidebar removal
328
+
329
+ = 0.8 =
330
+
331
+ * Added: some rules are dependent of each other if present
332
+ * Added: widgets in removed sidebars will be removed too
333
+ * Added: database data update module
334
+ * Added: rewrite rules flushed on plugin deactivation
335
+ * Added: data will be removed when plugin is uninstalled
336
+ * Added: icon-32 is back
337
+ * Added: message if a host is not available in sidebar overview
338
+ * Fixed: prefixed data
339
+ * Fixed: data hidden from custom fields
340
+ * Fixed: manage widgets link removed from trashed sidebars
341
+ * Fixed: view sidebar link removed in wp3.1.x
342
+ * Fixed: all custom taxonomies could not be removed again when assigned to sidebar
343
+ * Fixed: altered options meta box on edit screen
344
+ * Fixed: check if host of sidebar exists before handling it
345
+
346
+ = 0.7 =
347
+
348
+ * Added: sidebars will be displayed even if empty (i.e. hidden)
349
+ * Added: author rules on singulars and archives
350
+ * Added: page template rules
351
+ * Added: javascript handling for disabling/enabling specific input on editor page
352
+ * Fixed: minor tweak for full compatibility with wp3.3
353
+ * Fixed: function for meta boxes is called only on editor page
354
+ * Fixed: proper column sorting in administration
355
+ * Fixed: specific post type label not supported in wp3.1.x
356
+ * Fixed: type (array) not supported as post_status in get_posts() in wp3.1.x
357
+ * Fixed: code cleanup
358
+
359
+ = 0.6.3 =
360
+
361
+ * Added: scheduled and private singulars are selectable in sidebar editor
362
+ * Added: combined cache for manual and automatically handled sidebars
363
+ * Added: display_ca_sidebar accepts specific ids to be included
364
+ * Fixed: only a limited amount of sidebars were present in widgets area
365
+ * Fixed: better caching in sidebar editor
366
+ * Fixed: page list in sidebar editor could behave incorrectly if some pages were static
367
+
368
+ = 0.6.2 =
369
+
370
+ * Fixed: array_flip triggered type mismatch errors in some cases
371
+
372
+ = 0.6.1 =
373
+
374
+ * Fixed: an image caused headers already sent error
375
+
376
+ = 0.6 =
377
+
378
+ * Added: sidebars can be set with specific singulars
379
+ * Added: sidebars can be set with specific post formats
380
+ * Added: updated gui
381
+ * Fixed: draft sidebars save meta
382
+
383
+ = 0.5 =
384
+
385
+ * Added: search, 404, front page rules now supported
386
+ * Fixed: custom tax and terms are now supported properly (again)
387
+
388
+ = 0.4 =
389
+
390
+ * Added: post type archives, taxonomy archives and taxonomy terms archives now supported
391
+ * Added: taxonomy rules
392
+ * Added: removable donation button
393
+ * Fixed: faster!
394
+
395
+ = 0.3 =
396
+
397
+ * Added: sidebars can now be private
398
+ * Fixed: taxonomy terms are now supported by template function
399
+ * Fixed: faster rule recognition and handling
400
+ * Fixed: custom taxonomies are now supported properly
401
+ * Fixed: error if several sidebars had taxonomy terms rules
402
+
403
+ = 0.2 =
404
+
405
+ * Added: taxonomy terms rules
406
+ * Added: optional description for sidebars
407
+ * Added: display_ca_sidebar also accepts URL-style string as parameter
408
+ * Fixed: saving meta now only kicks in with sidebar types
409
+ * Fixed: archives are not singulars and will not be treated like them
410
+
411
+ = 0.1 =
412
+
413
+ * First stable release
walker.php CHANGED
@@ -1,120 +1,120 @@
1
- <?php
2
- /**
3
- * @package Content Aware Sidebars
4
- * @author Joachim Jensen <jv@intox.dk>
5
- */
6
-
7
- if (!defined('ContentAwareSidebars::DB_VERSION')) {
8
- header('Status: 403 Forbidden');
9
- header('HTTP/1.1 403 Forbidden');
10
- exit;
11
- }
12
-
13
- /**
14
- *
15
- * Walker for post types and taxonomies
16
- *
17
- */
18
- class CAS_Walker_Checklist extends Walker {
19
-
20
- /**
21
- * Constructor
22
- * @param string $tree_type
23
- * @param array $db_fields
24
- */
25
- function __construct($tree_type, $db_fields) {
26
-
27
- $this->tree_type = $tree_type;
28
- $this->db_fields = $db_fields;
29
-
30
- }
31
-
32
- /**
33
- * Start outputting level
34
- * @param string $output
35
- * @param int $depth
36
- * @param array $args
37
- * @return void
38
- */
39
- public function start_lvl(&$output, $depth = 0, $args = array()) {
40
- $indent = str_repeat("\t", $depth);
41
- $output .= "</li>$indent<li><ul class='children'>\n";
42
- }
43
-
44
- /**
45
- * End outputting level
46
- * @param string $output
47
- * @param int $depth
48
- * @param array $args
49
- * @return void
50
- */
51
- public function end_lvl(&$output, $depth = 0, $args = array()) {
52
- $indent = str_repeat("\t", $depth);
53
- $output .= "$indent</ul></li>\n";
54
- }
55
-
56
- /**
57
- * Start outputting element
58
- * @param string $output
59
- * @param object $term
60
- * @param int $depth
61
- * @param array $args
62
- * @param int $current_object_id
63
- * @return void
64
- */
65
- public function start_el(&$output, $term, $depth = 0, $args = array(), $current_object_id = 0 ) {
66
- extract($args);
67
-
68
- if(isset($post_type)) {
69
-
70
- if (empty($post_type)) {
71
- $output .= "\n<li>";
72
- return;
73
- }
74
-
75
- $value = $term->ID;
76
- $title = $term->post_title;
77
- $name = 'cas_condition[post_types][]';
78
-
79
- } else {
80
-
81
- if (empty($taxonomy)) {
82
- $output .= "\n<li>";
83
- return;
84
- }
85
-
86
- //Hierarchical taxonomies use ids instead of slugs
87
- //see http://codex.wordpress.org/Function_Reference/wp_set_post_terms
88
- $value_var = ($taxonomy->hierarchical ? 'term_id' : 'slug');
89
-
90
- $value = $term->$value_var;
91
- $title = $term->name;
92
- $name = 'cas_condition[tax_input]['.$taxonomy->name.'][]';
93
-
94
- }
95
-
96
- if(is_array($selected_terms)) {
97
- $selected = checked(in_array($value,$selected_terms),true,false);
98
- } else {
99
- $selected = checked($selected_terms,true,false);
100
- }
101
-
102
- $output .= "\n".'<li><label class="selectit"><input value="'.$value.'" type="checkbox" title="'.esc_attr( $title ).'" name="'.$name.'"'.$selected.'/> '.esc_html( $title ).'</label>';
103
-
104
- }
105
-
106
- /**
107
- * End outputting element
108
- * @param string $output
109
- * @param object $object
110
- * @param int $depth
111
- * @param array $args
112
- * @return void
113
- */
114
- public function end_el(&$output, $object, $depth = 0, $args = array() ) {
115
- $output .= "</li>\n";
116
- }
117
-
118
- }
119
-
120
  //eol
1
+ <?php
2
+ /**
3
+ * @package Content Aware Sidebars
4
+ * @author Joachim Jensen <jv@intox.dk>
5
+ */
6
+
7
+ if (!defined('ContentAwareSidebars::DB_VERSION')) {
8
+ header('Status: 403 Forbidden');
9
+ header('HTTP/1.1 403 Forbidden');
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ *
15
+ * Walker for post types and taxonomies
16
+ *
17
+ */
18
+ class CAS_Walker_Checklist extends Walker {
19
+
20
+ /**
21
+ * Constructor
22
+ * @param string $tree_type
23
+ * @param array $db_fields
24
+ */
25
+ function __construct($tree_type, $db_fields) {
26
+
27
+ $this->tree_type = $tree_type;
28
+ $this->db_fields = $db_fields;
29
+
30
+ }
31
+
32
+ /**
33
+ * Start outputting level
34
+ * @param string $output
35
+ * @param int $depth
36
+ * @param array $args
37
+ * @return void
38
+ */
39
+ public function start_lvl(&$output, $depth = 0, $args = array()) {
40
+ $indent = str_repeat("\t", $depth);
41
+ $output .= "</li>$indent<li><ul class='children'>\n";
42
+ }
43
+
44
+ /**
45
+ * End outputting level
46
+ * @param string $output
47
+ * @param int $depth
48
+ * @param array $args
49
+ * @return void
50
+ */
51
+ public function end_lvl(&$output, $depth = 0, $args = array()) {
52
+ $indent = str_repeat("\t", $depth);
53
+ $output .= "$indent</ul></li>\n";
54
+ }
55
+
56
+ /**
57
+ * Start outputting element
58
+ * @param string $output
59
+ * @param object $term
60
+ * @param int $depth
61
+ * @param array $args
62
+ * @param int $current_object_id
63
+ * @return void
64
+ */
65
+ public function start_el(&$output, $term, $depth = 0, $args = array(), $current_object_id = 0 ) {
66
+ extract($args);
67
+
68
+ if(isset($post_type)) {
69
+
70
+ if (empty($post_type)) {
71
+ $output .= "\n<li>";
72
+ return;
73
+ }
74
+
75
+ $value = $term->ID;
76
+ $title = $term->post_title;
77
+ $name = 'cas_condition[post_types][]';
78
+
79
+ } else {
80
+
81
+ if (empty($taxonomy)) {
82
+ $output .= "\n<li>";
83
+ return;
84
+ }
85
+
86
+ //Hierarchical taxonomies use ids instead of slugs
87
+ //see http://codex.wordpress.org/Function_Reference/wp_set_post_terms
88
+ $value_var = ($taxonomy->hierarchical ? 'term_id' : 'slug');
89
+
90
+ $value = $term->$value_var;
91
+ $title = $term->name;
92
+ $name = 'cas_condition[tax_input]['.$taxonomy->name.'][]';
93
+
94
+ }
95
+
96
+ if(is_array($selected_terms)) {
97
+ $selected = checked(in_array($value,$selected_terms),true,false);
98
+ } else {
99
+ $selected = checked($selected_terms,true,false);
100
+ }
101
+
102
+ $output .= "\n".'<li><label class="selectit"><input value="'.$value.'" type="checkbox" title="'.esc_attr( $title ).'" name="'.$name.'"'.$selected.'/> '.esc_html( $title ).'</label>';
103
+
104
+ }
105
+
106
+ /**
107
+ * End outputting element
108
+ * @param string $output
109
+ * @param object $object
110
+ * @param int $depth
111
+ * @param array $args
112
+ * @return void
113
+ */
114
+ public function end_el(&$output, $object, $depth = 0, $args = array() ) {
115
+ $output .= "</li>\n";
116
+ }
117
+
118
+ }
119
+
120
  //eol
wpml-config.xml CHANGED
@@ -1,10 +1,10 @@
1
- <wpml-config>
2
- <custom-fields>
3
- <custom-field action="ignore">_cas_post_types</custom-field>
4
- <custom-field action="ignore">_cas_taxonomies</custom-fields>
5
- </custom-fields>
6
- <custom-types>
7
- <custom-type translate="0">sidebar</custom-type>
8
- <custom-type translate="0">sidebar_group</custom-type>
9
- </custom-types>
10
  </wpml-config>
1
+ <wpml-config>
2
+ <custom-fields>
3
+ <custom-field action="ignore">_cas_post_types</custom-field>
4
+ <custom-field action="ignore">_cas_taxonomies</custom-fields>
5
+ </custom-fields>
6
+ <custom-types>
7
+ <custom-type translate="0">sidebar</custom-type>
8
+ <custom-type translate="0">sidebar_group</custom-type>
9
+ </custom-types>
10
  </wpml-config>