Simply Exclude - Version 1.5

Version Description

Download this release

Release Info

Developer pmenard
Plugin Icon wp plugin Simply Exclude
Version 1.5
Comparing to
See all releases

Version 1.5

Files changed (3) hide show
  1. readme.txt +39 -0
  2. simplyexclude.php +1005 -0
  3. simplyexclude_style_admin.css +49 -0
readme.txt ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Simply Exclude ===
2
+ Contributors: Paul Menard
3
+ Donate link: http://www.codehooligans.com
4
+ Tags: admin, posts, pages, categories, tags, exclude, include, is_front, is_archive, is_search, is_feed
5
+ Requires at least: 2.3
6
+ Tested up to: 2.5
7
+ Stable tag: 1.5
8
+
9
+ == Description ==
10
+
11
+ Provides an interface to selectively exclude/include categories, tags and page from the 4 actions used by WordPress
12
+
13
+ is_front - When the user views the Front page.
14
+ is_archive - When the user views an category or tags Archive.
15
+ is_search - When the user views a search result page.
16
+ is_feed - When a Feed is viewed/requested.
17
+
18
+ [Plugin Homepage](http://www.codehooligans.com/2008/04/27/simply-exclude-plugin/ "SimplyExclude Plugin for WordPress")
19
+
20
+ == Installation ==
21
+
22
+ 1. Upload the extracted plugin folder and contained files to your `/wp-content/plugins/` directory
23
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
24
+ 3. Navigate to Settings -> Simply Exclude (Options -> Simply Exclude is pre 2.5).
25
+ 4. Once on the plugin admin page you should see navigation links at the top: Manage Categories, Manage Tags, Manage Pages.On each of these page you can selectively exclude/include the cat/tag/page for the given action is_front/is_archive/is_feed/is_search.
26
+
27
+ == Frequently Asked Questions ==
28
+
29
+ = I've excluded all my categories and all tags why am I seeing my 404 page? =
30
+
31
+ Well you need to be careful when excluding both categories and tags. Since a post can be associated with both there is potential that you have excluded all your posts because they are either members of excluded categories or members or excluded tags.
32
+
33
+ = Why doesn't the plugin auto-update itself? =
34
+
35
+ I've not added that feature. A minor version coming soon.
36
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
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Simply Exclude
4
+ Plugin URI: http://www.codehooligans.com/2008/04/27/simply-exclude-plugin/
5
+ Description: Provides an interface to selectively exclude/include categories, tags and page from the 4 actions used by WordPress. is_front, is_archive, is_search, is_feed.
6
+ Author: Paul Menard
7
+ Version: 1.5
8
+ Author URI: http://www.codehooligans.com
9
+
10
+ Revision history
11
+ 1.0 - 2007-11-20: Initial release
12
+ 1.1 - 2008-12-15: Added logic to work with WP version greater than 2.2
13
+ 1.5 - 20008-04-27 Fixed display issues. Changes 'List' to 'Archive'. Added tags inclusion/exclusion login. Works only with WP 2.3 and greater.
14
+ */
15
+
16
+ class SimplyExclude
17
+ {
18
+ var $se_cfg;
19
+ var $options_key;
20
+ var $default_IsActions;
21
+
22
+ var $categories;
23
+ var $pages;
24
+
25
+ var $wp_version;
26
+
27
+ function SimplyExclude()
28
+ {
29
+ global $wp_version;
30
+ $this->wp_version = $wp_version;
31
+
32
+ $this->_admin_menu_label = "Simply Exclude";
33
+ $this->options_key = "simplyexclude";
34
+
35
+ $this->se_load_config();
36
+
37
+ add_action('admin_menu', array(&$this,'admin_init_proc'));
38
+
39
+ // Add our own admin menu
40
+ add_action('admin_menu', array(&$this,'se_add_nav'));
41
+
42
+ if ($_REQUEST['page'] == $this->options_key)
43
+ add_action('admin_head', array(&$this,'se_admin_head'));
44
+
45
+ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'activate')
46
+ add_action('init', array(&$this,'se_install'));
47
+
48
+ // Used to limit the categories displayed on the home page. Simple
49
+ add_filter('pre_get_posts', array(&$this,'se_filters'));
50
+
51
+ add_action('save_post', array(&$this,'save_page_exclude_answer'));
52
+ }
53
+
54
+ function admin_init_proc()
55
+ {
56
+ if (function_exists('add_meta_box')) {
57
+ add_meta_box($this->_options_key, $this->_admin_menu_label, array(&$this,'add_page_exclude_sidebar_dbx'), 'page');
58
+ }
59
+ else {
60
+ add_filter('dbx_page_sidebar', array(&$this,'add_page_exclude_sidebar_dbx'));
61
+ }
62
+ }
63
+
64
+
65
+ function se_load_config()
66
+ {
67
+ // This is the pre-defined WordPress is_* actions.
68
+ $this->default_IsActions = array();
69
+
70
+ // Define the actions allow on Post Categories
71
+ $this->default_IsActions['cats'] = array();
72
+ $this->default_IsActions['cats']['is_home']['name']
73
+ = "Front";
74
+ $this->default_IsActions['cats']['is_home']['description']
75
+ = "Visibility on the front/main page.";
76
+ $this->default_IsActions['cats']['is_home']['action']
77
+ = "i";
78
+
79
+ $this->default_IsActions['cats']['is_archive']['name']
80
+ = "Archive";
81
+ $this->default_IsActions['cats']['is_archive']['description']
82
+ = "Visibility on the archive of categories on the sidebar";
83
+ $this->default_IsActions['cats']['is_archive']['action']
84
+ = "e";
85
+
86
+ $this->default_IsActions['cats']['is_search']['name']
87
+ = "Search";
88
+ $this->default_IsActions['cats']['is_search']['description']
89
+ = "Visibility in search results.";
90
+ $this->default_IsActions['cats']['is_search']['action']
91
+ = "e";
92
+
93
+ $this->default_IsActions['cats']['is_feed']['name']
94
+ = "Feed";
95
+ $this->default_IsActions['cats']['is_feed']['description']
96
+ = "Visibility in RSS/RSS2/Atom feeds.";
97
+ $this->default_IsActions['cats']['is_feed']['action']
98
+ = "e";
99
+
100
+ $this->default_IsActions['cats']['is_archive']['name']
101
+ = "Archive";
102
+ $this->default_IsActions['cats']['is_archive']['description']
103
+ = "Visibility in archive links (i.e., calendar links).";
104
+ $this->default_IsActions['cats']['is_archive']['action'] = "e";
105
+
106
+
107
+ // Tag Definitions
108
+ $this->default_IsActions['tags'] = array();
109
+ $this->default_IsActions['tags']['is_home']['name']
110
+ = "Front";
111
+ $this->default_IsActions['tags']['is_home']['description']
112
+ = "Visibility on the front/main page.";
113
+ $this->default_IsActions['tags']['is_home']['action']
114
+ = "i";
115
+
116
+ $this->default_IsActions['tags']['is_archive']['name']
117
+ = "Archive";
118
+ $this->default_IsActions['tags']['is_archive']['description']
119
+ = "Visibility on the archive of tags on the sidebar";
120
+ $this->default_IsActions['tags']['is_archive']['action']
121
+ = "e";
122
+
123
+ $this->default_IsActions['tags']['is_search']['name']
124
+ = "Search";
125
+ $this->default_IsActions['tags']['is_search']['description']
126
+ = "Visibility in search results.";
127
+ $this->default_IsActions['tags']['is_search']['action']
128
+ = "e";
129
+
130
+ $this->default_IsActions['tags']['is_feed']['name']
131
+ = "Feed";
132
+ $this->default_IsActions['tags']['is_feed']['description']
133
+ = "Visibility in RSS/RSS2/Atom feeds.";
134
+ $this->default_IsActions['tags']['is_feed']['action']
135
+ = "e";
136
+
137
+ $this->default_IsActions['tags']['is_archive']['name']
138
+ = "Archive";
139
+ $this->default_IsActions['tags']['is_archive']['description']
140
+ = "Visibility in archive links (i.e., calendar links).";
141
+ $this->default_IsActions['tags']['is_archive']['action'] = "e";
142
+
143
+
144
+ // Pages Definitions
145
+ $this->default_IsActions['pages'] = array();
146
+ $this->default_IsActions['pages']['is_search']['name'] = "Search";
147
+ $this->default_IsActions['pages']['is_search']['description'] = "Visibility in search results.";
148
+ $this->default_IsActions['pages']['is_search']['action'] = "e";
149
+
150
+ $this->se_cfg['cfg']['page_name'] = "simplyexclude";
151
+ $tmp_se_cfg = get_option($this->options_key);
152
+ if ($tmp_se_cfg)
153
+ {
154
+ if (!is_array($tmp_se_cfg))
155
+ $this->se_cfg = unserialize($tmp_se_cfg);
156
+ }
157
+ $plugindir_node = dirname(plugin_basename(__FILE__));
158
+ $plugindir_url = get_bloginfo('wpurl') . "/wp-content/plugins/". $plugindir_node;
159
+ $this->se_cfg['cfg']['myurl'] = $plugindir_url;
160
+
161
+ if (!isset($this->se_cfg['cats']['actions']))
162
+ {
163
+ foreach($this->default_IsActions['cats'] as $cat_key => $cat_action)
164
+ {
165
+ $this->se_cfg['cats']['actions'][$cat_key] = $cat_action['action'];
166
+ }
167
+ }
168
+ if (!isset($this->se_cfg['tags']['actions']))
169
+ {
170
+ foreach($this->default_IsActions['tags'] as $tag_key => $tag_action)
171
+ {
172
+ $this->se_cfg['tags']['actions'][$tag_key] = $tag_action['action'];
173
+ }
174
+ }
175
+ if (!isset($this->se_cfg['pages']['actions']))
176
+ {
177
+ foreach($this->default_IsActions['pages'] as $page_key => $page_action)
178
+ {
179
+ $this->se_cfg['pages']['actions'][$page_key] = $page_action['action'];
180
+ }
181
+ }
182
+ }
183
+
184
+ function se_save_config()
185
+ {
186
+ $ret = update_option($this->options_key, serialize($this->se_cfg));
187
+ }
188
+
189
+
190
+ function se_add_nav()
191
+ {
192
+ // Add a new menu under Manage:
193
+ add_options_page('Simply Exclude', 'Simply Exclude', 8,
194
+ $this->options_key, array(&$this, 'se_manage_page'));
195
+ }
196
+
197
+ function se_admin_head()
198
+ {
199
+ ?>
200
+ <link rel="stylesheet" href="<?php echo $this->se_cfg['cfg']['myurl'] ?>/simplyexclude_style_admin.css"
201
+ type="text/css" media="screen" />
202
+ <?php
203
+ }
204
+
205
+ function se_install()
206
+ {
207
+ add_option($this->options_key,
208
+ serialize($this->se_cfg),
209
+ "This is the serialized config structures used.");
210
+ }
211
+
212
+ function se_manage_page()
213
+ {
214
+ $this->se_display_navigation();
215
+
216
+ ?>
217
+ <div class="wrap">
218
+ <?php
219
+
220
+ if (isset($_REQUEST['se_admin']))
221
+ $se_admin = $_REQUEST['se_admin'];
222
+
223
+ switch ($se_admin['action'])
224
+ {
225
+ case 'edit_pages':
226
+ case 'save_pages':
227
+ $this->se_display_pages_panel($se_admin);
228
+ break;
229
+
230
+ case 'edit_tags':
231
+ case 'save_tags':
232
+ $this->se_display_tags_panel($se_admin);
233
+ break;
234
+
235
+
236
+ default:
237
+ case 'edit_categories':
238
+ case 'save_categories':
239
+ $this->se_display_categories_panel($se_admin);
240
+ break;
241
+ }
242
+ ?>
243
+ </div>
244
+ <?php
245
+ }
246
+
247
+
248
+ function se_display_navigation()
249
+ {
250
+
251
+ ?>
252
+ <div id="se_admin_nav">
253
+ <ul>
254
+ <li><a href="?page=<?php
255
+ echo $this->options_key ?>&amp;se_admin[action]=edit_categories"
256
+ title="Manage Category Exclusions">Manage Categories</a></li>
257
+ <?php
258
+ if ($this->wp_version >= 2.3)
259
+ {
260
+ ?>
261
+ <li><a href="?page=<?php
262
+ echo $this->options_key ?>&amp;se_admin[action]=edit_tags"
263
+ title="Manage Tag Exclusions">Manage Tags</a></li><?php
264
+ }
265
+ ?>
266
+ <li><a href="?page=<?php
267
+ echo $this->options_key ?>&amp;se_admin[action]=edit_pages"
268
+ title="Manage Page Exclusions">Manage Pages</a></li>
269
+ </ul>
270
+ </div>
271
+ <?php
272
+ }
273
+
274
+ // CATEGORY FUNCTIONS
275
+ /////////////////////////////////////////////////////////////////
276
+ function se_display_categories_panel($se_admin)
277
+ {
278
+ ?>
279
+ <h2>Manage Category Exclusions</h2>
280
+ <?php
281
+ if ($se_admin['action'] == "save_categories")
282
+ {
283
+ if (isset($se_admin['cats']))
284
+ $this->se_cfg['cats'] = $se_admin['cats'];
285
+ else
286
+ unset($this->se_cfg['cats']);
287
+
288
+ $this->se_save_config();
289
+ ?>
290
+ <div class="updated">
291
+ <p>Category Exclusions successfully updated.</p>
292
+ </div>
293
+ <?php
294
+ }
295
+ $this->se_show_categories_form();
296
+ }
297
+
298
+ function se_load_categories()
299
+ {
300
+ global $wpdb;
301
+ if (!$this->categories)
302
+ {
303
+ //$this->categories = $wpdb->get_results("SELECT cat_ID, cat_name
304
+ // FROM $wpdb->categories ORDER BY cat_name");
305
+
306
+ $this->categories = get_categories();
307
+ }
308
+ }
309
+
310
+ function se_show_categories_form()
311
+ {
312
+ $this->se_load_categories();
313
+ if ($this->categories)
314
+ {
315
+ $this->display_instructions('cats');
316
+ ?>
317
+ <form name="cat_exclusion" id="cat_exclusion"
318
+ action="?page=<?php
319
+ echo $this->options_key ?>&amp;se_admin[action]=save_categories" method="post">
320
+
321
+ <table width="80%" cellpadding="3" cellspacing="3" border="0">
322
+ <thead>
323
+ <tr>
324
+ <th><?php _e('Action Name') ?></th>
325
+ <th><?php _e('Description ') ?></th>
326
+ <th><?php _e('Inclusion/Exclusion') ?></th>
327
+ </tr>
328
+ </thead>
329
+ <tbody>
330
+ <?php
331
+ foreach ($this->default_IsActions['cats'] as $action_key => $action_val)
332
+ {
333
+ $class = ('alternate' == $class) ? '' : 'alternate';
334
+ ?>
335
+ <tr <?php if (strlen($class)) echo "class='".$class."'" ?>>
336
+ <td><?php echo $action_val['name'] ?></td>
337
+ <td><?php echo $action_val['description'] ?></td>
338
+ <td>
339
+ <input type="radio"
340
+ name="se_admin[cats][actions][<?php echo $action_key ?>]" value="i"
341
+ <?php if ($this->se_cfg['cats']['actions'][$action_key] == 'i')
342
+ echo "checked='checked'"; ?> /> Include only<br />
343
+ <input type="radio"
344
+ name="se_admin[cats][actions][<?php echo $action_key ?>]" value="e"
345
+ <?php if ($this->se_cfg['cats']['actions'][$action_key] == 'e')
346
+ echo "checked='checked'"; ?> /> Exclude
347
+ </td>
348
+ <tr>
349
+ <?php
350
+ }
351
+ ?>
352
+ </tbody>
353
+ </table>
354
+ <br />
355
+ <table width="80%" cellpadding="3" cellspacing="3" border="0">
356
+ <thead>
357
+ <tr>
358
+ <th class="cat-id" scope="col"><?php _e('ID') ?></th>
359
+ <th class="cat-name" scope="col"><?php _e('Category Name') ?></th>
360
+ <th class="cat-action" scope="col"><?php _e('Exclude from...') ?></th>
361
+ </tr>
362
+ </thead>
363
+ <tbody>
364
+ <?php
365
+ foreach($this->categories as $cat_info)
366
+ {
367
+ $class = ('alternate' == $class) ? '' : 'alternate';
368
+ $this->se_show_cat_item_row($cat_info, $class);
369
+ }
370
+ ?>
371
+ <tr>
372
+ <td>
373
+ <div style="float:right;"><p class="submit"><input type="hidden" name="action" value="editcatvis" /><input type="submit" name="submit" value="<?php _e('Save Changes &raquo;') ?>" />
374
+
375
+ </td>
376
+ </tr>
377
+ </tbody>
378
+ </table>
379
+ </p></div>
380
+ </form>
381
+ <?php
382
+ }
383
+ else
384
+ {
385
+ ?><p>You don't have any Categories defined.</p><?php
386
+ }
387
+ }
388
+
389
+ function se_show_cat_item_row($cat_info, $class)
390
+ {
391
+ ?>
392
+ <tr <?php if (strlen($class)) echo "class='".$class."'" ?>>
393
+ <td class="cat-id"><?php echo $cat_info->cat_ID ?></td>
394
+ <td class="cat-name"><?php echo $cat_info->cat_name ?></td>
395
+ <td class="cat-action"><?php $this->se_display_cat_action_row($cat_info->cat_ID) ?></td>
396
+ </tr>
397
+ <?php
398
+ }
399
+
400
+ function se_display_cat_action_row($cat_id)
401
+ {
402
+ foreach ($this->default_IsActions['cats'] as $action_key => $action_val)
403
+ {
404
+ ?>
405
+ <label for="cats-<?php echo $action_key ?>-<?php echo $cat_id ?>">
406
+ <?php echo $action_val['name'] ?></label>&nbsp;
407
+ <input type="checkbox"
408
+ name="se_admin[cats][<?php echo $action_key ?>][<?php echo $cat_id ?>]"
409
+ id="cats-<?php echo $action_key ?>-<?php echo $cat_id ?>"
410
+ <?php
411
+ if ($this->se_cfg['cats'][$action_key][$cat_id] == "on")
412
+ echo "checked='checked' ";
413
+ ?> />
414
+ <?php
415
+ }
416
+ }
417
+
418
+ // END CONFIG FUNCTIONS
419
+ /////////////////////////////////////////////////////////////////
420
+
421
+
422
+ // TAG FUNCTIONS
423
+ /////////////////////////////////////////////////////////////////
424
+ function se_display_tags_panel($se_admin)
425
+ {
426
+ ?>
427
+ <h2>Manage Tag Exclusions</h2>
428
+ <?php
429
+ if ($se_admin['action'] == "save_tags")
430
+ {
431
+ if (isset($se_admin['tags']))
432
+ $this->se_cfg['tags'] = $se_admin['tags'];
433
+ else
434
+ unset($this->se_cfg['tags']);
435
+
436
+ $this->se_save_config();
437
+ ?>
438
+ <div class="updated">
439
+ <p>Tag Exclusions successfully updated.</p>
440
+ </div>
441
+ <?php
442
+ }
443
+ $this->se_show_tags_form();
444
+ }
445
+
446
+ function se_load_tags()
447
+ {
448
+ global $wpdb;
449
+ if (!$this->tags)
450
+ {
451
+ $this->tags = get_tags();
452
+ }
453
+ }
454
+
455
+
456
+ function se_show_tags_form()
457
+ {
458
+ $this->se_load_tags();
459
+ if ($this->tags)
460
+ {
461
+ $this->display_instructions('tags');
462
+ ?>
463
+ <form name="tag_exclusion" id="tag_exclusion"
464
+ action="?page=<?php
465
+ echo $this->options_key ?>&amp;se_admin[action]=save_tags" method="post">
466
+
467
+ <table width="80%" cellpadding="3" cellspacing="3" border="0">
468
+ <thead>
469
+ <tr>
470
+ <th><?php _e('Action Name') ?></th>
471
+ <th><?php _e('Description ') ?></th>
472
+ <th><?php _e('Inclusion/Exclusion') ?></th>
473
+ </tr>
474
+ </thead>
475
+ <tbody>
476
+ <?php
477
+ foreach ($this->default_IsActions['tags'] as $action_key => $action_val)
478
+ {
479
+ $class = ('alternate' == $class) ? '' : 'alternate';
480
+ ?>
481
+ <tr <?php if (strlen($class)) echo "class='".$class."'" ?>>
482
+ <td><?php echo $action_val['name'] ?></td>
483
+ <td><?php echo $action_val['description'] ?></td>
484
+ <td>
485
+ <input type="radio"
486
+ name="se_admin[tags][actions][<?php echo $action_key ?>]" value="i"
487
+ <?php if ($this->se_cfg['tags']['actions'][$action_key] == 'i')
488
+ echo "checked='checked'"; ?> /> Include only<br />
489
+ <input type="radio"
490
+ name="se_admin[tags][actions][<?php echo $action_key ?>]" value="e"
491
+ <?php if ($this->se_cfg['tags']['actions'][$action_key] == 'e')
492
+ echo "checked='checked'"; ?> /> Exclude
493
+ </td>
494
+ <tr>
495
+ <?php
496
+ }
497
+ ?>
498
+ </tbody>
499
+ </table>
500
+ <br />
501
+ <table width="80%" cellpadding="3" cellspacing="3" border="0">
502
+ <thead>
503
+ <tr>
504
+ <th class="cat-id" scope="col"><?php _e('ID') ?></th>
505
+ <th class="cat-name" scope="col"><?php _e('Tag Name') ?></th>
506
+ <th class="cat-action" scope="col"><?php _e('Exclude from...') ?></th>
507
+ </tr>
508
+ </thead>
509
+ <tbody>
510
+ <?php
511
+ foreach($this->tags as $tag_info)
512
+ {
513
+ $class = ('alternate' == $class) ? '' : 'alternate';
514
+ $this->se_show_tag_item_row($tag_info, $class);
515
+ }
516
+ ?>
517
+ <tr>
518
+ <td>
519
+ <div style="float:right;"><p class="submit"><input type="hidden" name="action" value="editcatvis" /><input type="submit" name="submit" value="<?php _e('Save Changes &raquo;') ?>" />
520
+
521
+ </td>
522
+ </tr>
523
+ </tbody>
524
+ </table>
525
+ </p></div>
526
+ </form>
527
+ <?php
528
+ }
529
+ else
530
+ {
531
+ ?><p>You don't have any Tags defined.</p><?php
532
+ }
533
+ }
534
+
535
+
536
+ function se_show_tag_item_row($tag_info, $class)
537
+ {
538
+ ?>
539
+ <tr <?php if (strlen($class)) echo "class='".$class."'" ?>>
540
+ <td class="tag-id"><?php echo $tag_info->term_id ?></td>
541
+ <td class="tag-name"><?php echo $tag_info->name ?></td>
542
+ <td class="tag-action"><?php $this->se_display_tag_action_row($tag_info->term_id) ?></td>
543
+ </tr>
544
+ <?php
545
+ }
546
+
547
+ function se_display_tag_action_row($tag_id)
548
+ {
549
+ foreach ($this->default_IsActions['tags'] as $action_key => $action_val)
550
+ {
551
+ ?>
552
+ <label for="tags-<?php echo $action_key ?>-<?php echo $tag_id ?>">
553
+ <?php echo $action_val['name'] ?></label>&nbsp;
554
+ <input type="checkbox"
555
+ name="se_admin[tags][<?php echo $action_key ?>][<?php echo $tag_id ?>]"
556
+ id="tags-<?php echo $action_key ?>-<?php echo $tag_id ?>"
557
+ <?php
558
+ if ($this->se_cfg['tags'][$action_key][$tag_id] == "on")
559
+ echo "checked='checked' ";
560
+ ?> />
561
+ <?php
562
+ }
563
+ }
564
+
565
+
566
+ // END CONFIG FUNCTIONS
567
+ /////////////////////////////////////////////////////////////////
568
+
569
+
570
+ // PAGE FUNCTIONS
571
+ /////////////////////////////////////////////////////////////////
572
+ function se_display_pages_panel($se_admin)
573
+ {
574
+ ?>
575
+ <h2>Manage Page Exclusions</h2>
576
+ <?php
577
+ if ($se_admin['action'] == "save_pages")
578
+ {
579
+ if (isset($se_admin['pages']))
580
+ {
581
+ $this->se_cfg['pages'] = $se_admin['pages'];
582
+ $this->se_save_config();
583
+ ?>
584
+ <div class="updated">
585
+ <p>Page Exclusions successfully updated.</p>
586
+ </div>
587
+ <?php
588
+ }
589
+ }
590
+ $this->se_show_pages_form();
591
+ }
592
+
593
+ function se_load_pages()
594
+ {
595
+ global $wpdb;
596
+ if (!$this->pages)
597
+ $this->pages = $wpdb->get_results("SELECT ID, post_title
598
+ FROM $wpdb->posts
599
+ WHERE post_type='page'
600
+ AND post_status='publish'
601
+ ORDER BY post_title");
602
+ }
603
+
604
+ function se_show_pages_form()
605
+ {
606
+ //$this->display_instructions('pages');
607
+ //return;
608
+
609
+ $this->se_load_pages();
610
+ if ($this->pages)
611
+ {
612
+ $this->display_instructions('pages');
613
+ ?>
614
+ <form name="page_exclusion" id="page_exclusion"
615
+ action="?page=<?php
616
+ echo $this->options_key ?>&amp;se_admin[action]=save_pages" method="post">
617
+ <table width="80%" cellpadding="3" cellspacing="3" border="0">
618
+ <thead>
619
+ <tr>
620
+ <th><?php _e('Action Name') ?></th>
621
+ <th><?php _e('Description ') ?></th>
622
+ <th><?php _e('Inclusion/Exclusion Default') ?></th>
623
+ </tr>
624
+ </thead>
625
+ <tbody>
626
+ <?php
627
+ foreach ($this->default_IsActions['pages'] as $action_key => $action_val)
628
+ {
629
+ $class = ('alternate' == $class) ? '' : 'alternate';
630
+ ?>
631
+ <tr <?php if (strlen($class)) echo "class='".$class."'" ?>>
632
+ <td><?php echo $action_val['name'] ?></td>
633
+ <td><?php echo $action_val['description'] ?></td>
634
+ <td>
635
+ <input type="radio"
636
+ name="se_admin[pages][actions][<?php echo $action_key ?>]" value="i"
637
+ <?php if ($this->se_cfg['pages']['actions'][$action_key] == 'i')
638
+ echo "checked='checked'"; ?> /> Include only<br />
639
+
640
+ <input type="radio"
641
+ name="se_admin[pages][actions][<?php echo $action_key ?>]" value="e"
642
+ <?php if ($this->se_cfg['pages']['actions'][$action_key] == 'e')
643
+ echo "checked='checked'"; ?> /> Exclude
644
+ </td>
645
+ <tr>
646
+ <?php
647
+ }
648
+ ?>
649
+ </tbody>
650
+ </table>
651
+ <br />
652
+
653
+
654
+ <table width="80%" cellpadding="3" cellspacing="3">
655
+ <thead>
656
+ <tr>
657
+ <th class="page-id" scope="col"><?php _e('ID') ?></th>
658
+ <th class="page-name" scope="col"><?php _e('Title') ?></th>
659
+ <th class="page-action" scope="col"><?php _e('Exclude from...') ?></th>
660
+ </tr>
661
+ </thead>
662
+ <tbody>
663
+ <?php
664
+ foreach($this->pages as $page_info)
665
+ {
666
+ $class = ('alternate' == $class) ? '' : 'alternate';
667
+ $this->se_show_page_item_row($page_info, $class);
668
+ }
669
+ ?>
670
+ <tr>
671
+ <td>
672
+ <div style="float:right;"><p class="submit"><input type="hidden" name="action" value="editcatvis" /><input type="submit" name="submit" value="<?php _e('Save Changes &raquo;') ?>" />
673
+ </p></div>
674
+
675
+ </td>
676
+ </tr>
677
+ </tbody>
678
+ </table>
679
+
680
+ </form>
681
+ <?php
682
+ }
683
+ else
684
+ {
685
+ ?><p>You don't have any Pages.</p><?php
686
+ }
687
+
688
+ }
689
+
690
+ function se_show_page_item_row($page_info, $class = '')
691
+ {
692
+ ?>
693
+ <tr <?php if (strlen($class)) echo "class='".$class."'" ?>>
694
+ <td class="page-id"><?php echo $page_info->ID ?></td>
695
+ <td class="page-name"><?php echo $page_info->post_title ?></td>
696
+ <td class="page-action"><?php $this->se_display_page_action_row($page_info->ID) ?></td>
697
+ </tr>
698
+ <?php
699
+ }
700
+
701
+
702
+ function se_display_page_action_row($page_id)
703
+ {
704
+ foreach ($this->default_IsActions['pages'] as $action_key => $action_val)
705
+ {
706
+ ?>
707
+ <label for="pages-<?php echo $action_key ?>-<?php echo $page_id ?>">
708
+ <?php echo $action_val['name'] ?></label>&nbsp;
709
+ <input type="checkbox"
710
+ name="se_admin[pages][<?php echo $action_key ?>][<?php echo $page_id ?>]"
711
+ id="pages-<?php echo $action_key ?>-<?php echo $page_id ?>"
712
+ <?php
713
+
714
+ if ($this->se_cfg['pages'][$action_key][$page_id] == "on")
715
+ echo "checked='checked' ";
716
+ ?> />
717
+ <?php
718
+ }
719
+ }
720
+
721
+ function get_pages_list($sep, $ids)
722
+ {
723
+ foreach($ids as $id_key => $id_val)
724
+ {
725
+ if (strlen($id_list))
726
+ $id_list .= ",";
727
+ $id_list .= $id_key;
728
+ }
729
+ return $id_list;
730
+
731
+ }
732
+
733
+ // The following 2 function we taken from the wonderful SearchEverything plugin.
734
+ // http://wordpress.org/extend/plugins/search-everything/
735
+ function SE4_exclude_posts($where) {
736
+ global $wp_query;
737
+ if ((!empty($wp_query->query_vars['s']))
738
+ && (count($this->se_cfg['pages'][$action_key]) > 0))
739
+ {
740
+ $action_key = "is_search";
741
+ $excl_list = $this->get_pages_list(',', $this->se_cfg['pages'][$action_key]);
742
+
743
+ //$excl_list = implode(',', explode(',', trim($this->options['SE4_exclude_posts_list'])));
744
+
745
+ $where = str_replace('"', '\'', $where);
746
+ $where = 'AND ('.substr($where, strpos($where, 'AND')+3).' )';
747
+ if ($this->se_cfg['pages']['actions'][$action_key] == 'e')
748
+ $where .= ' AND (ID NOT IN ( '.$excl_list.' ))';
749
+ else
750
+ $where .= ' AND (ID IN ( '.$excl_list.' ))';
751
+ }
752
+ return $where;
753
+ }
754
+
755
+ //search pages (except password protected pages provided by loops)
756
+ function SE4_search_pages($where) {
757
+ global $wp_query;
758
+
759
+ if (!empty($wp_query->query_vars['s'])) {
760
+
761
+ $where = str_replace('"', '\'', $where);
762
+ if ('true' == $this->options['SE4_approved_pages_only']) {
763
+ $where = str_replace('post_type = \'post\' AND ', 'post_password = \'\' AND ', $where);
764
+ }
765
+ else { // < v 2.1
766
+ $where = str_replace('post_type = \'post\' AND ', '', $where);
767
+ }
768
+ }
769
+ return $where;
770
+ }
771
+
772
+
773
+
774
+ // END CONFIG FUNCTIONS
775
+ /////////////////////////////////////////////////////////////////
776
+
777
+
778
+ function se_filters($query)
779
+ {
780
+ //echo "query before<pre>"; print_r($query); echo "</pre>";
781
+ if (count($this->default_IsActions['cats']) > 0)
782
+ {
783
+ foreach ($this->default_IsActions['cats'] as $action_key => $action_val)
784
+ {
785
+ $cats_list = "";
786
+ if ($query->{$action_key})
787
+ {
788
+ if (isset($this->se_cfg['cats'][$action_key]))
789
+ {
790
+ if (count($this->se_cfg['cats'][$action_key]))
791
+ {
792
+ $cats_list = $this->se_listify_ids( $this->se_cfg['cats']['actions'][$action_key],
793
+ $this->se_cfg['cats'][$action_key]);
794
+ }
795
+ }
796
+ if (strlen($cats_list))
797
+ $query->set('cat', $cats_list);
798
+ }
799
+ }
800
+ }
801
+
802
+ if ($this->wp_version >= 2.3)
803
+ {
804
+ foreach ($this->default_IsActions['tags'] as $action_key => $action_val)
805
+ {
806
+ if ($query->{$action_key})
807
+ {
808
+ if (isset($this->se_cfg['tags'][$action_key]))
809
+ {
810
+ if (isset($tag_array_list))
811
+ unset($tag_array_list);
812
+
813
+ $tag_array_list = array();
814
+ if (count($this->se_cfg['tags'][$action_key]) > 0)
815
+ {
816
+ foreach($this->se_cfg['tags'][$action_key] as $key => $val)
817
+ {
818
+ $tag_array_list[] = $key;
819
+ }
820
+
821
+ if ($this->se_cfg['tags']['actions'][$action_key] == "e")
822
+ {
823
+ $query->set('tag__not_in', $tag_array_list);
824
+ }
825
+ else
826
+ {
827
+ $query->set('tag__in', $tag_array_list);
828
+ }
829
+ }
830
+ }
831
+ }
832
+ }
833
+ }
834
+
835
+ foreach ($this->default_IsActions['pages'] as $action_key => $action_val)
836
+ {
837
+ //echo "action_key=[". $action_key. "]<br />";
838
+ if ($query->{$action_key})
839
+ {
840
+ add_filter('posts_where', array(&$this, 'SE4_search_pages'));
841
+ add_filter('posts_where', array(&$this, 'SE4_exclude_posts'));
842
+
843
+ /*
844
+ $pages_list;
845
+ if (isset($this->se_cfg['pages'][$action_key]))
846
+ {
847
+ //echo "this->se_cfg['pages'][$action_key]=[". $this->se_cfg['pages'][$action_key]. "]<br />";
848
+
849
+ $pages_list = $this->se_listify_ids($this->se_cfg['pages']['actions'][$action_key],
850
+ $this->se_cfg['pages'][$action_key]);
851
+ //echo "pages_list=[". $pages_list."]<br />";
852
+ }
853
+ if (strlen($pages_list))
854
+ $query->set('page', $pages_list);
855
+ */
856
+ }
857
+ }
858
+ //echo "query after<pre>"; print_r($query); echo "</pre>";
859
+ return $query;
860
+ }
861
+
862
+ function se_listify_ids($action, $ids)
863
+ {
864
+ if ($action == "e")
865
+ $action_value = "-";
866
+ else
867
+ $action_value = "";
868
+ foreach($ids as $id_key => $id_val)
869
+ {
870
+ if (strlen($id_list))
871
+ $id_list .= ",";
872
+ $id_list .= $action_value.$id_key;
873
+ }
874
+ return $id_list;
875
+ }
876
+
877
+
878
+ function display_instructions($type)
879
+ {
880
+ if ($type == "cats")
881
+ {
882
+ ?>
883
+ <p>Set the checkbox to exclude the respective page from the action</p>
884
+ <p>So what is the difference between Exclusion and Inclusion?<br />
885
+ <strong>Exclude</strong>: Select this action to exclude Categories from WP
886
+ action. For example you may wish to exclude the Category 'Blogroll' from Searches.<br />
887
+ <strong>Include</strong>: Select the Categories you wish to be included for certain
888
+ WP actions. For example you want only a certain category displayed on the home
889
+ page. Note that with Include only those checked items will be included in the
890
+ WP action. </p>
891
+ <?php
892
+ }
893
+ else if ($type == "tags")
894
+ {
895
+ ?>
896
+ <p>Set the checkbox to exclude the respective page from the action</p>
897
+ <p>So what is the difference between Exclusion and Inclusion?<br />
898
+ <strong>Exclude</strong>: Select this action to exclude Tags from WP
899
+ action. For example you may wish to exclude the Tag 'Blogroll' from Searches.<br />
900
+ <strong>Include</strong>: Select the Tag you wish to be included for certain
901
+ WP actions. For example you want only a certain tag displayed on the home
902
+ page. Note that with Include only those checked items will be included in the
903
+ WP action. </p>
904
+ <?php
905
+ }
906
+ else if ($type == "pages")
907
+ {
908
+
909
+ ?>
910
+ <p>Set the checkbox to exclude the respective page from the action</p>
911
+ <p>So what is the difference between Exclusion and Inclusion?<br />
912
+ <strong>Exclude</strong>: Select this action to exclude Pages from WP
913
+ action. For example you may wish to exclude a Page from Searches. Most common use.<br />
914
+ <strong>Include</strong>: Select the Page you wish to be included for certain
915
+ WP actions. For example you want only certain Pages displayed from a Search. Note with Include only those checked items will be included in the
916
+ WP action. And as new Pages are added they will need to be checked here. </p>
917
+
918
+ <p><strong>Note</strong>: The Pages section of this plugin is at best experimental until Page Search is included
919
+ by default into WordPress core. Also, you might consider using the SearchEverything plugin which offers much more
920
+ functionality on Searched. http://wordpress.org/extend/plugins/search-everything/</p>
921
+ <?php
922
+
923
+ /*
924
+ ?>
925
+ <p>This is a placeholder section for Pages Exclusion. Since WordPress does not yet include Pages in searches this section is pointless. From various sources version 2.6 of WordPress should include native support for including Pages in search results. Look for changes to this plugin shortly after that.</p>
926
+ <?php
927
+ */
928
+ }
929
+ }
930
+
931
+ function add_page_exclude_sidebar_dbx()
932
+ {
933
+ global $post;
934
+
935
+ $action_key = "is_search";
936
+
937
+ if ($this->se_cfg['pages'][$action_key][$post->ID] == "on")
938
+ $exclude_page = "yes";
939
+
940
+ if ($this->wp_version < 2.5)
941
+ {
942
+ ?>
943
+ <fieldset id="use_ssl" class="dbx-box">
944
+ <h3 class="dbx-handle"><?php _e('Exclude from Search?') ?></h3>
945
+ <div class="dbx-content">
946
+ <?php
947
+ }
948
+ ?>
949
+ <p><?php
950
+ if ($this->wp_version >= 2.5)
951
+ {
952
+ ?>Select this option 'Yes' to exclude this page from Searches or visit <a href="<?php echo get_option('siteurl') ?>/wp-admin/edit.php?page=simplyexclude&amp;se_admin[action]=edit_pages">Simply Exclude</a> Settings page to mass edit all Pages.<br /><?php
953
+ } ?>
954
+ <select name="se_page_exclude">
955
+ <option value='No' selected><?php echo _e('No'); ?></option>
956
+ <option value='Yes' <?php if ($exclude_page == "yes") echo "selected"; ?>><?php _e('Yes'); ?></option>
957
+ </select>
958
+ </p>
959
+ <?php
960
+ if ($this->wp_version < 2.5)
961
+ {
962
+ ?>
963
+ </div>
964
+ </fieldset>
965
+ <?php
966
+ }
967
+ }
968
+
969
+
970
+ function save_page_exclude_answer()
971
+ {
972
+ if (!$_REQUEST['post_ID'])
973
+ return;
974
+
975
+ if (!$_REQUEST['se_page_exclude'])
976
+ return;
977
+
978
+ $post_id = $_REQUEST['post_ID'];
979
+ $action_key = "is_search";
980
+
981
+ if ($_REQUEST['se_page_exclude'] == "Yes")
982
+ $this->se_cfg['pages'][$action_key][$post_id] = "on";
983
+ else
984
+ $this->se_cfg['pages'][$action_key][$post_id] = "";
985
+
986
+ $this->se_save_config();
987
+ }
988
+ }
989
+ $simplyexclude = new SimplyExclude();
990
+
991
+ /*
992
+ function myBlogPostsFilter($query)
993
+ {
994
+ global $wp_query;
995
+
996
+ if ($query->is_search)
997
+ {
998
+ $query->set('cat','-3,-4,-5,-6,-7');
999
+ $query->set('page','-33');
1000
+ }
1001
+ return $query;
1002
+ }
1003
+ add_filter('pre_get_posts','myBlogPostsFilter');
1004
+ */
1005
+ ?>
simplyexclude_style_admin.css ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #se_admin_nav ul li {
2
+ display: inline;
3
+ text-decoration: none;
4
+ padding-right: 4px;
5
+ margin: 0px;
6
+ }
7
+
8
+ form#cat_exclusion table tbody tr td.cat-id,
9
+ form#tag_exclusion table tbody tr td.tag-id,
10
+ form#page_exclusion table tbody tr td.page-id {
11
+ text-align: center;
12
+ width: 10%;
13
+ padding: 8px 5px;
14
+ }
15
+
16
+ form#cat_exclusion table thead tr th.cat-name,
17
+ form#cat_exclusion table tbody tr td.cat-name,
18
+ form#tag_exclusion table thead tr th.tag-name,
19
+ form#tag_exclusion table tbody tr td.tag-name,
20
+ form#page_exclusion table thead tr th.page-name,
21
+ form#page_exclusion table tbody tr td.page-name {
22
+ text-align: left;
23
+ padding-left: 20px;
24
+ width: 40%;
25
+ }
26
+
27
+ form#cat_exclusion table tbody tr td.cat-action,
28
+ form#tag_exclusion table tbody tr td.tag-action,
29
+ form#page_exclusion table tbody tr td.page-action {
30
+ text-align: center;
31
+ }
32
+
33
+ form#cat_exclusion table tbody tr td.cat-action label,
34
+ form#tag_exclusion table tbody tr td.tag-action label,
35
+ form#page_exclusion table tbody tr td.page-action label {
36
+ padding: 0;
37
+ margin: 0;
38
+ }
39
+
40
+ form#cat_exclusion table tbody tr td.cat-action input,
41
+ form#tag_exclusion table tbody tr td.tag-action input {
42
+ margin-right: 15px;
43
+ margin-left: -5px;
44
+ }
45
+
46
+ form#page_exclusion table tbody tr td.page-action input {
47
+ margin-right: 15px;
48
+ margin-left: -5px;
49
+ }