-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimplyexclude.php
More file actions
3188 lines (2661 loc) · 118 KB
/
simplyexclude.php
File metadata and controls
3188 lines (2661 loc) · 118 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
Plugin Name: Simply Exclude
Plugin URI: http://www.codehooligans.com/projects/wordpress/simply-exclude/
Description: Provides an interface to selectively exclude/include all Taxonomies, Post Types and Users from the 4 actions used by WordPress. is_front, is_archive, is_search, is_feed. Also provides access to some of the common widgets user like tag cloud and categories listings.
Author: Paul Menard
Version: 2.0.6.2
Author URI: http://www.codehooligans.com
*/
define('SIMPLY_EXCLUDE_I18N_DOMAIN', 'simplyexclude');
class SimplyExclude
{
public $se_version;
public $admin_menu_label;
public $options_key;
public $se_taxonomies_exclude = array();
public $se_post_types_exclude = array();
private $plugindir_url;
private $current_taxonomy;
private $current_post_type;
private $current_se_type;
private $page_hooks;
private $tabs = array();
private $current_tab;
public function __construct() {
$this->se_version = "2.0.6.2";
$this->admin_menu_label = __("Simply Exclude", SIMPLY_EXCLUDE_I18N_DOMAIN);
$this->options_key = "simplyexclude_v2";
$plugindir_node = dirname(plugin_basename(__FILE__));
$this->plugindir_url = WP_PLUGIN_URL . "/". $plugindir_node;
$this->se_taxonomies_exclude = array('media-tags', 'post_format', 'link_category', 'nav_menu');
$this->se_post_types_exclude = array('revision', 'nav_menu_item', 'attachment');
$this->page_hooks = array();
/* Setup the tetdomain for i18n language handling see http://codex.wordpress.org/Function_Reference/load_plugin_textdomain */
load_plugin_textdomain( SIMPLY_EXCLUDE_I18N_DOMAIN, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
add_action( 'init', array(&$this,'init_proc') );
add_action( 'admin_init', array(&$this,'admin_init_proc') );
add_action( 'admin_menu', array(&$this,'se_add_nav') );
add_action( 'admin_footer', array(&$this,'se_admin_footer') );
add_action( 'wp_ajax_se_update', array(&$this, 'se_ajax_update') );
// Used to limit the categories displayed on the home page. Simple
add_filter('pre_get_posts', array(&$this,'se_filters'), 999);
}
function admin_init_proc()
{
$this->tabs = array(
'taxonomies' => __('Taxonomies', SIMPLY_EXCLUDE_I18N_DOMAIN),
'post_types' => __('Post Types', SIMPLY_EXCLUDE_I18N_DOMAIN),
'users' => __('Users', SIMPLY_EXCLUDE_I18N_DOMAIN),
);
$this->current_tab = '';
$this->se_load_config();
if ( ($this->check_url('wp-admin/edit-tags.php'))
|| ($this->check_url('wp-admin/edit.php'))
|| ($this->check_url('wp-admin/users.php')) )
{
wp_enqueue_style( 'simplyexclude-stylesheet', $this->plugindir_url .'/simplyexclude_style_admin.css', false, $this->se_version);
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-ui-dialog');
wp_enqueue_style( 'simplyexclude-jquery-ui',
$this->plugindir_url .'/js/jquery-ui/css/flick/jquery-ui-1.8.17.custom.css',
null, $this->se_version );
wp_enqueue_script('simplyexclude-admin-dialog-js', $this->plugindir_url .'/js/simplyexclude_admin_dialog.js',
array('jquery', 'jquery-ui-core', 'jquery-ui-dialog'), $this->se_version);
wp_enqueue_script('simplyexclude-admin-ajax-js', $this->plugindir_url .'/js/simplyexclude_admin_ajax.js',
array('jquery', 'jquery-ui-core'), $this->se_version);
}
add_action('edit_category_form_fields', array(&$this,'se_show_taxonomy_term_fields'), 99, 1);
add_action('edit_tag_form_fields', array(&$this,'se_show_taxonomy_term_fields'), 99, 1);
add_action('edited_term', array(&$this,'se_save_taxonomy_term_fields'), 99, 3);
add_action( 'show_user_profile', array(&$this,'se_show_user_profile'), 99 );
add_action( 'edit_user_profile', array(&$this,'se_show_user_profile'), 99 );
add_action( 'profile_update', array(&$this,'se_save_user_profile'), 99);
add_filter( 'plugin_action_links_'. basename( dirname( __FILE__ ) ). '/' .basename( __FILE__ ), array(&$this,'plugin_settings'));
}
// Adds a 'Settings' link on the Plugins listing row. Cool!
function plugin_settings( $links ) {
$settings_link = '<a href="admin.php?page=se_manage_settings">'.__( 'Settings', SIMPLY_EXCLUDE_I18N_DOMAIN ).'</a>';
array_unshift( $links, $settings_link );
return $links;
}
function init_proc()
{
if (!is_admin())
{
add_filter('widget_pages_args', array(&$this, 'se_widget_pages_args_proc'));
// Not needed since wp_list_pages is user managable.
//aad_filter('wp_list_pages_excludes', array(&$this, 'se_wp_list_pages_excludes_proc'));
// Suport for the Category list/dropdown widget
add_filter('widget_categories_dropdown_args', array(&$this, 'se_widget_categories_dropdown_args_proc'));
add_filter('widget_categories_args', array(&$this, 'se_widget_categories_dropdown_args_proc'));
// Support for the Tag Clod widget. This widget supports both the post_tag and category taxonomies.
add_filter('widget_tag_cloud_args', array(&$this, 'se_widget_tag_cloud_args_proc'));
}
}
function se_add_nav()
{
// Add the Main Nav item to the WP menu
add_menu_page( 'Simply Exclude', 'Simply Exclude', 'manage_options', 'se_manage_settings',
array(&$this, 'se_manage_settings'));
// Add our Options sub menu.
$this->pagehooks['se_manage_settings'] = add_submenu_page( 'se_manage_settings', 'Settings', 'Settings', 'manage_options',
'se_manage_settings', array(&$this, 'se_manage_settings'));
add_action('load-'. $this->pagehooks['se_manage_settings'], array(&$this, 'on_load_settings_page'));
// Add our Help sub menu.
$this->pagehooks['se_manage_help'] = add_submenu_page( 'se_manage_settings', 'Help', 'Help', 'manage_options',
'se_manage_help', array(&$this, 'se_manage_help'));
add_action('load-'. $this->pagehooks['se_manage_help'], array(&$this, 'on_load_help_page'));
if ( !current_user_can('manage_options') )
return;
$this->se_load_config();
// Now add a submenu for each registered taxonomy
$se_taxonomies = $this->se_load_taxonomy_list();
if ($se_taxonomies)
{
foreach($se_taxonomies as $t_item)
{
if ((isset($this->se_cfg['data']['taxonomies'][$t_item->name]['options']['showhide']))
&& ($this->se_cfg['data']['taxonomies'][$t_item->name]['options']['showhide'] == 'show'))
{
add_filter( "manage_edit-". $t_item->name ."_columns", array( &$this, 'se_manage_taxonomy_columns' ), 99, 1);
add_filter( "manage_". $t_item->name. "_custom_column", array(&$this, 'se_display_taxonomy_column_filters'), 99, 3);
}
}
//add_action("delete_term", array(&$this, 'se_delete_taxonomy_term'), 99, 3);
}
// Now add a submenu for each registered post_type
$se_post_types = $this->se_load_post_type_list();
if ($se_post_types)
{
foreach($se_post_types as $t_item)
{
if ((isset($this->se_cfg['data']['post_types'][$t_item->name]['options']['showhide']))
&& ($this->se_cfg['data']['post_types'][$t_item->name]['options']['showhide'] == 'show'))
{
add_filter( "manage_". $t_item->name ."_posts_columns", array( &$this, 'se_manage_post_type_columns' ), 99 );
add_action( "manage_". $t_item->name ."_posts_custom_column", array(&$this, 'se_display_post_type_column_actions'), 99, 2);
add_meta_box($this->options_key, $this->admin_menu_label, array(&$this,'show_post_type_exclude_sidebar_dbx'), $t_item->name, 'side');
add_action('save_post', array(&$this,'save_post_type_exclude_sidebar_dbx'));
}
}
}
// Users table
if ((isset($this->se_cfg['data']['se_types']['users']['options']['showhide']))
&& ($this->se_cfg['data']['se_types']['users']['options']['showhide'] == 'show'))
{
add_filter( "manage_users_columns", array( &$this, 'se_manage_user_columns' ), 99 );
add_filter( 'manage_users_custom_column', array(&$this, 'se_display_user_column_actions'), 99, 3);
}
}
/*
function se_delete_taxonomy_term($term, $tt_id, $taxonomy)
{
echo "term<pre>"; print_r($term); echo "</pre>";
echo "tt_id=[". $tt_id ."]<br />";
echo "taxonomy=[". $taxonomy ."]<br />";
exit;
}
*/
/****************************************************************************************************************************/
/* */
/* ON LOAD PAGES */
/* */
/****************************************************************************************************************************/
function on_load_settings_page() {
wp_enqueue_style( 'simplyexclude-stylesheet', $this->plugindir_url .'/simplyexclude_style_admin.css', false, $this->se_version);
wp_enqueue_script('simplyexclude-admin-ajax-js', $this->plugindir_url .'/js/simplyexclude_admin_ajax.js',
array('jquery', 'jquery-ui-core'), $this->se_version);
wp_enqueue_script('common');
wp_enqueue_script('wp-lists');
wp_enqueue_script('postbox');
if ( isset( $_GET['tab'] )) {
$this->current_tab = esc_attr($_GET['tab']);
if (!isset($this->tabs[$this->current_tab])) {
$this->current_tab = 'taxonomies';
}
} else {
$this->current_tab = 'taxonomies';
}
add_meta_box('se_settings_about_sidebar', 'About this Plugin', array(&$this, 'se_settings_about_sidebar'),
$this->pagehooks['se_manage_settings'], 'side', 'core');
add_meta_box('se_settings_donate_sidebar', 'Make a Donation', array(&$this, 'se_settings_donate_sidebar'),
$this->pagehooks['se_manage_settings'], 'side', 'core');
}
function on_load_help_page()
{
global $wp_version;
wp_enqueue_style( 'simplyexclude-stylesheet', $this->plugindir_url .'/simplyexclude_style_admin.css', false, $this->se_version);
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core');
if ( version_compare( $wp_version, '3.3', '<' ) ) {
wp_register_script( 'jquery-ui-widget-se', $this->plugindir_url .'/js/jquery-ui/jquery.ui.widget.min.js',
array('jquery', 'jquery-ui-core'), $this->se_version);
wp_enqueue_script( 'jquery-ui-widget-se' );
wp_register_script( 'jquery-ui-accordion-se', $this->plugindir_url .'/js/jquery-ui/jquery.ui.accordion.min.js',
array('jquery', 'jquery-ui-core', 'jquery-ui-widget-se'), $this->se_version);
wp_enqueue_script( 'jquery-ui-accordion-se' );
} else {
wp_enqueue_script('jquery-ui-widget');
wp_enqueue_script('jquery-ui-accordion');
}
add_meta_box('se_settings_about_sidebar', 'About this Plugin', array(&$this, 'se_settings_about_sidebar'),
$this->pagehooks['se_manage_help'], 'side', 'core');
add_meta_box('se_settings_donate_sidebar', 'Make a Donation', array(&$this, 'se_settings_donate_sidebar'),
$this->pagehooks['se_manage_help'], 'side', 'core');
}
/****************************************************************************************************************************/
/* */
/* ACTIONS PANELS */
/* */
/****************************************************************************************************************************/
function se_show_taxonomy_actions_panel($taxonomy)
{
if (!$taxonomy) return;
if (!isset($this->se_cfg['data']['taxonomies'][$taxonomy]))
return;
$this->current_taxonomy = $this->se_cfg['data']['taxonomies'][$taxonomy];
?>
<table class="widefat simply-exclude-settings-postbox simplyexclude-actions-panel" cellpadding="3" cellspacing="3" border="0">
<thead>
<tr>
<th class="action"><?php _e('Action Name') ?></th>
<th class="description"><?php _e('Description ') ?></th>
<th class="inc-excl"><?php _e('Inclusion/Exclusion') ?></th>
</tr>
</thead>
<tbody>
<?php
$class="";
foreach ($this->current_taxonomy['actions'] as $action_key => $action_val)
{
$class = ('alternate' == $class) ? '' : 'alternate';
?>
<tr <?php if (strlen($class)) echo "class='".$class."'" ?>>
<td class="action"><?php echo $this->get_taxonomy_action_label($taxonomy, $action_key, 'name'); //$action_val['name'] ?></td>
<td class="description"><?php echo $this->get_taxonomy_action_label($taxonomy, $action_key, 'description');//$action_val['description'] ?></td>
<td class="inc-excl">
<ul class="se-actions-list">
<li><input type="radio" id="se_cfg_<?php echo $taxonomy; ?>_actions_<?php echo $action_key ?>_i" name="se_cfg[<?php echo $taxonomy; ?>][actions][<?php echo $action_key ?>]" value="i" <?php if ($action_val == 'i') echo "checked='checked'"; ?> /> <label for="se_cfg_<?php echo $taxonomy; ?>_actions_<?php echo $action_key ?>_i"><?php _e('Include only', SIMPLY_EXCLUDE_I18N_DOMAIN); ?></label></li>
<li><input type="radio" id="se_cfg_<?php echo $taxonomy; ?>_actions_<?php echo $action_key ?>_e" name="se_cfg[<?php echo $taxonomy; ?>][actions][<?php echo $action_key ?>]" value="e" <?php if ($action_val == 'e') echo "checked='checked'"; ?> /> <label for="se_cfg_<?php echo $taxonomy; ?>_actions_<?php echo $action_key ?>_e"><?php _e('Exclude', SIMPLY_EXCLUDE_I18N_DOMAIN); ?></label></li>
</td>
<tr>
<?php
}
?>
</tbody>
</table>
<?php
}
function se_show_post_type_actions_panel($post_type='')
{
if (!$post_type) return;
if (!isset($this->se_cfg['data']['post_types'][$post_type]))
return;
$this->current_post_type = $this->se_cfg['data']['post_types'][$post_type];
?>
<table class="widefat simply-exclude-settings-postbox simplyexclude-actions-panel" cellpadding="3" cellspacing="3" border="0">
<thead>
<tr>
<th class="action"><?php _e('Action Name') ?></th>
<th class="description"><?php _e('Description ') ?></th>
<th class="inc-excl"><?php _e('Inclusion/Exclusion') ?></th>
</tr>
</thead>
<tbody>
<?php
$class="";
foreach ($this->current_post_type['actions'] as $action_key => $action_val)
{
$class = ('alternate' == $class) ? '' : 'alternate';
?>
<tr <?php if (strlen($class)) echo "class='".$class."'" ?>>
<td class="action"><?php echo $this->get_post_type_action_label($post_type, $action_key, 'name'); ?></td>
<td class="description"><?php echo $this->get_post_type_action_label($post_type, $action_key, 'description'); ?></td>
<td class="inc-excl">
<ul class="se-actions-list">
<li><input type="radio" id="se_cfg_<?php echo $post_type ?>_actions_<?php echo $action_key ?>_i" name="se_cfg[<?php echo $post_type; ?>][actions][<?php echo $action_key ?>]" value="i" <?php if ($action_val == 'i') echo "checked='checked'"; ?> /> <label for="se_cfg_<?php echo $post_type ?>_actions_<?php echo $action_key ?>_i"><?php _e('Include only', SIMPLY_EXCLUDE_I18N_DOMAIN); ?></label></li>
<li><input type="radio" id="se_cfg_<?php echo $post_type ?>_actions_<?php echo $action_key ?>_e" name="se_cfg[<?php echo $post_type; ?>][actions][<?php echo $action_key ?>]" value="e" <?php if ($action_val == 'e') echo "checked='checked'"; ?> /> <label for="se_cfg_<?php echo $post_type ?>_actions_<?php echo $action_key ?>_e"><?php _e('Exclude', SIMPLY_EXCLUDE_I18N_DOMAIN); ?></label></li>
<?php
if (($action_key == "is_home")
&& ((isset($this->current_post_type['options']['capability_type']))
&& ($this->current_post_type['options']['capability_type'] == "post"))) {
?><li><input type="radio" id="se_cfg_<?php echo $post_type ?>_actions_<?php echo $action_key ?>_a" name="se_cfg[<?php echo $post_type; ?>][actions][<?php echo $action_key ?>]" value="a" <?php if ($action_val == 'a') echo "checked='checked'"; ?> /> <label for="se_cfg_<?php echo $post_type ?>_actions_<?php echo $action_key ?>_a"><?php _e('Include All', SIMPLY_EXCLUDE_I18N_DOMAIN); ?></label></li><?php
} else if (($action_key == "is_feed")
&& ((isset($this->current_post_type['options']['capability_type']))
&& ($this->current_post_type['options']['capability_type'] == "post"))) {
?><li><input type="radio" id="se_cfg_<?php echo $post_type ?>_actions_<?php echo $action_key ?>_a" name="se_cfg[<?php echo $post_type; ?>][actions][<?php echo $action_key ?>]" value="a" <?php if ($action_val == 'a') echo "checked='checked'"; ?> /> <label for="se_cfg_<?php echo $post_type ?>_actions_<?php echo $action_key ?>_a"><?php _e('Include All', SIMPLY_EXCLUDE_I18N_DOMAIN); ?></label></li><?php
}
?>
</td>
<tr>
<?php
}
?>
</tbody>
</table>
<?php
}
function se_show_se_type_actions_panel($se_type='')
{
if (!$se_type) return;
if (!isset($this->se_cfg['data']['se_types'][$se_type]))
return;
$this->current_se_type = $this->se_cfg['data']['se_types'][$se_type];
?>
<table class="widefat simply-exclude-settings-postbox simplyexclude-actions-panel" cellpadding="3" cellspacing="3" border="0">
<thead>
<tr>
<th class="action"><?php _e('Action Name') ?></th>
<th class="description"><?php _e('Description ') ?></th>
<th class="inc-excl"><?php _e('Inclusion/Exclusion') ?></th>
</tr>
</thead>
<tbody>
<?php
$class="";
foreach ($this->current_se_type['actions'] as $action_key => $action_val)
{
$class = ('alternate' == $class) ? '' : 'alternate';
?>
<tr <?php if (strlen($class)) echo "class='".$class."'" ?>>
<td class="action"><?php echo $this->get_se_type_action_label($se_type, $action_key, 'name'); ?></td>
<td class="description"><?php echo $this->get_se_type_action_label($se_type, $action_key, 'description'); ?></td>
<td class="inc-excl">
<ul class="se-actions-list">
<li><input type="radio" id="se_cfg_<?php echo $se_type; ?>_actions_<?php echo $action_key ?>_i" name="se_cfg[<?php echo $se_type; ?>][actions][<?php echo $action_key ?>]" value="i" <?php if ($action_val == 'i') echo "checked='checked'"; ?> /> <label for="se_cfg_<?php echo $se_type; ?>_actions_<?php echo $action_key ?>_i"><?php _e('Include only', SIMPLY_EXCLUDE_I18N_DOMAIN); ?></label></li>
<li><input type="radio" id="se_cfg_<?php echo $se_type; ?>_actions_<?php echo $action_key ?>_e" name="se_cfg[<?php echo $se_type; ?>][actions][<?php echo $action_key ?>]" value="e" <?php if ($action_val == 'e') echo "checked='checked'"; ?> /> <label for="se_cfg_<?php echo $se_type; ?>_actions_<?php echo $action_key ?>_e"><?php _e('Exclude', SIMPLY_EXCLUDE_I18N_DOMAIN); ?></label></li>
</td>
<tr>
<?php
}
?>
</tbody>
</table>
<?php
}
/****************************************************************************************************************************/
/* */
/* ACTIVE PANELS */
/* */
/****************************************************************************************************************************/
function se_show_taxonomy_active_panel($taxonomy)
{
if (!$taxonomy) return;
if (!isset($this->se_cfg['data']['taxonomies'][$taxonomy]))
return;
$this->current_taxonomy = $this->se_cfg['data']['taxonomies'][$taxonomy];
if (!isset($this->current_taxonomy['options']['active']))
$this->current_taxonomy['options']['active'] = "yes";
?>
<table class="widefat simply-exclude-settings-postbox simplyexclude-active-panel" cellpadding="3" cellspacing="3" border="0">
<thead>
<tr>
<th class="action" colspan="2"><?php _e('Active', SIMPLY_EXCLUDE_I18N_DOMAIN) ?></th>
</tr>
</thead>
<tbody>
<tr>
<td class="description"><?php _e("Is this Taxonomy active? This is sometimes convenient instead of unsetting all Taxonomy terms.", SIMPLY_EXCLUDE_I18N_DOMAIN); ?></td>
<td class="inc-excl">
<input type="radio" name="se_cfg[<?php echo $taxonomy; ?>][options][active]" value="yes"
<?php if ($this->current_taxonomy['options']['active'] == 'yes')
echo "checked='checked'"; ?> /> <?php _e('Active', SIMPLY_EXCLUDE_I18N_DOMAIN); ?><br />
<input type="radio" name="se_cfg[<?php echo $taxonomy; ?>][options][active]" value="no"
<?php if ($this->current_taxonomy['options']['active'] == 'no')
echo "checked='checked'"; ?> /> <?php _e('Disabled', SIMPLY_EXCLUDE_I18N_DOMAIN); ?>
</td>
</tr>
</tbody>
</table>
<?php
}
function se_show_post_type_active_panel($post_type)
{
if (!$post_type) return;
if (!isset($this->se_cfg['data']['post_types'][$post_type]))
return;
$this->current_post_type = $this->se_cfg['data']['post_types'][$post_type];
if (!isset($this->current_post_type['options']['active']))
$this->current_post_type['options']['active'] = "yes";
?>
<table class="widefat simply-exclude-settings-postbox simplyexclude-active-panel" cellpadding="3" cellspacing="3" border="0">
<thead>
<tr>
<th class="action" colspan="2"><?php _e('Active', SIMPLY_EXCLUDE_I18N_DOMAIN) ?></th>
</tr>
</thead>
<tbody>
<tr>
<td class="description"><?php _e("Is this Post Type Active? This is sometimes convenient instead of unsetting all Post Type items.", SIMPLY_EXCLUDE_I18N_DOMAIN); ?></td>
<td class="inc-excl">
<input type="radio" name="se_cfg[<?php echo $post_type; ?>][options][active]" value="yes"
<?php if ($this->current_post_type['options']['active'] == 'yes')
echo "checked='checked'"; ?> /> <?php _e('Active', SIMPLY_EXCLUDE_I18N_DOMAIN); ?><br />
<input type="radio" name="se_cfg[<?php echo $post_type; ?>][options][active]" value="no"
<?php if ($this->current_post_type['options']['active'] == 'no')
echo "checked='checked'"; ?> /> <?php _e('Disabled', SIMPLY_EXCLUDE_I18N_DOMAIN); ?>
</td>
</tr>
</tbody>
</table>
<?php
}
function se_show_se_type_active_panel($se_type)
{
if (!$se_type) return;
if (!isset($this->se_cfg['data']['se_types'][$se_type]))
return;
$this->current_se_type = $this->se_cfg['data']['se_types'][$se_type];
if (!isset($this->current_se_type['options']['active']))
$this->current_se_type['options']['active'] = "yes";
?>
<table class="widefat simply-exclude-settings-postbox simplyexclude-active-panel" cellpadding="3" cellspacing="3" border="0">
<thead>
<tr>
<th class="action" colspan="2"><?php _e('Active', SIMPLY_EXCLUDE_I18N_DOMAIN) ?></th>
</tr>
</thead>
<tbody>
<tr>
<td class="description"><?php _e("Active?", SIMPLY_EXCLUDE_I18N_DOMAIN); ?></td>
<td class="inc-excl">
<input type="radio" name="se_cfg[<?php echo $se_type; ?>][options][active]" value="yes"
<?php if ($this->current_se_type['options']['active'] == 'yes')
echo "checked='checked'"; ?> /> <?php _e('Active', SIMPLY_EXCLUDE_I18N_DOMAIN); ?><br />
<input type="radio" name="se_cfg[<?php echo $se_type; ?>][options][active]" value="no"
<?php if ($this->current_se_type['options']['active'] == 'no')
echo "checked='checked'"; ?> /> <?php _e('Disabled', SIMPLY_EXCLUDE_I18N_DOMAIN); ?>
</td>
</tr>
</tbody>
</table>
<?php
}
/****************************************************************************************************************************/
/* */
/* SHOW/HIDE PANELS */
/* */
/****************************************************************************************************************************/
function se_show_taxonomy_showhide_panel($taxonomy)
{
if (!$taxonomy) return;
if (!isset($this->se_cfg['data']['taxonomies'][$taxonomy]))
return;
$this->current_taxonomy = $this->se_cfg['data']['taxonomies'][$taxonomy];
?>
<table class="widefat simply-exclude-settings-postbox simplyexclude-active-panel" cellpadding="3" cellspacing="3" border="0">
<thead>
<tr>
<th class="action" colspan="2"><?php _e('Show/Hide', SIMPLY_EXCLUDE_I18N_DOMAIN) ?></th>
</tr>
</thead>
<tbody>
<tr>
<td class="description"><?php _e("Show the extra columns on the Taxonomy listing and the Taxonomy edit form?", SIMPLY_EXCLUDE_I18N_DOMAIN); ?></td>
<td class="inc-excl">
<input type="radio" name="se_cfg[<?php echo $taxonomy; ?>][options][showhide]" value="show"
<?php if ($this->current_taxonomy['options']['showhide'] == 'show')
echo "checked='checked'"; ?> /> <?php _e('Show', SIMPLY_EXCLUDE_I18N_DOMAIN); ?><br />
<input type="radio" name="se_cfg[<?php echo $taxonomy; ?>][options][showhide]" value="hide"
<?php if ($this->current_taxonomy['options']['showhide'] == 'hide')
echo "checked='checked'"; ?> /> <?php _e('Hide', SIMPLY_EXCLUDE_I18N_DOMAIN); ?>
</td>
</tr>
</table>
<?php
}
function se_show_post_type_showhide_panel($post_type)
{
if (!$post_type) return;
if (!isset($this->se_cfg['data']['post_types'][$post_type]))
return;
$this->current_post_type = $this->se_cfg['data']['post_types'][$post_type];
?>
<table class="widefat simply-exclude-settings-postbox simplyexclude-active-panel" cellpadding="3" cellspacing="3" border="0">
<thead>
<tr>
<th class="action" colspan="2"><?php _e('Show/Hide', SIMPLY_EXCLUDE_I18N_DOMAIN) ?></th>
</tr>
</thead>
<tbody>
<tr>
<td class="description"><?php _e("Show the extra columns on the Post Type listing and the Post Type edit form?", SIMPLY_EXCLUDE_I18N_DOMAIN); ?></td>
<td class="inc-excl">
<input type="radio" name="se_cfg[<?php echo $post_type; ?>][options][showhide]" value="show"
<?php if ($this->current_post_type['options']['showhide'] == 'show')
echo "checked='checked'"; ?> /> <?php _e('Show', SIMPLY_EXCLUDE_I18N_DOMAIN); ?><br />
<input type="radio" name="se_cfg[<?php echo $post_type; ?>][options][showhide]" value="hide"
<?php if ($this->current_post_type['options']['showhide'] == 'hide')
echo "checked='checked'"; ?> /> <?php _e('Hide', SIMPLY_EXCLUDE_I18N_DOMAIN); ?>
</td>
</tr>
</table>
<?php
}
function se_show_se_type_showhide_panel($se_type)
{
if (!$se_type) return;
if (!isset($this->se_cfg['data']['se_types'][$se_type]))
return;
$this->current_se_type = $this->se_cfg['data']['se_types'][$se_type];
?>
<table class="widefat simply-exclude-settings-postbox simplyexclude-active-panel" cellpadding="3" cellspacing="3" border="0">
<thead>
<tr>
<th class="action" colspan="2"><?php _e('Show/Hide', SIMPLY_EXCLUDE_I18N_DOMAIN) ?></th>
</tr>
</thead>
<tbody>
<tr>
<td class="description"><?php _e("Show the extra columns on the listing and the edit form?", SIMPLY_EXCLUDE_I18N_DOMAIN); ?></td>
<td class="inc-excl">
<input type="radio" name="se_cfg[<?php echo $se_type; ?>][options][showhide]" value="show"
<?php if ($this->current_se_type['options']['showhide'] == 'show')
echo "checked='checked'"; ?> /> <?php _e('Show', SIMPLY_EXCLUDE_I18N_DOMAIN); ?><br />
<input type="radio" name="se_cfg[<?php echo $se_type; ?>][options][showhide]" value="hide"
<?php if ($this->current_se_type['options']['showhide'] == 'hide')
echo "checked='checked'"; ?> /> <?php _e('Hide', SIMPLY_EXCLUDE_I18N_DOMAIN); ?>
</td>
</tr>
</table>
<?php
}
/****************************************************************************************************************************/
/* */
/* QUERY OVERRIDE PANELS */
/* */
/****************************************************************************************************************************/
function se_show_taxonomy_query_override_panel($taxonomy)
{
if (!$taxonomy) return;
if (!isset($this->se_cfg['data']['taxonomies'][$taxonomy]))
return;
$this->current_taxonomy = $this->se_cfg['data']['taxonomies'][$taxonomy];
?>
<table class="widefat simply-exclude-settings-postbox simplyexclude-active-panel" cellpadding="3" cellspacing="3" border="0">
<thead>
<tr>
<th class="action" colspan="2"><?php _e('Query Filtering', SIMPLY_EXCLUDE_I18N_DOMAIN) ?></th>
</tr>
</thead>
<tbody>
<tr>
<td class="description">
<p><?php _e("Override query filtering for Main Loop Only or All Loops?", SIMPLY_EXCLUDE_I18N_DOMAIN) ?></p>
<p><?php _e("The Simply-Exclude plugin was designed to only work with the main page query. But sometimes other plugins or your theme will effect how the main filtering works. So if you are having trouble attempting to filter categories from your home page you might want to try and set this option to 'All' and see if it corrects your issue.", SIMPLY_EXCLUDE_I18N_DOMAIN); ?></p>
</td>
<td class="inc-excl">
<input type="radio" name="se_cfg[<?php echo $taxonomy; ?>][options][qover]" value="main"
<?php if ($this->current_taxonomy['options']['qover'] == 'main')
echo "checked='checked'"; ?> /> <?php _e('Main Loop Only', SIMPLY_EXCLUDE_I18N_DOMAIN); ?><br />
<input type="radio" name="se_cfg[<?php echo $taxonomy; ?>][options][qover]" value="all"
<?php if ($this->current_taxonomy['options']['qover'] == 'all')
echo "checked='checked'"; ?> /> <?php _e('All Loops', SIMPLY_EXCLUDE_I18N_DOMAIN); ?>
</td>
</tr>
</table>
<?php
}
function se_show_post_type_query_override_panel($post_type)
{
if (!$post_type) return;
if (!isset($this->se_cfg['data']['post_types'][$post_type]))
return;
$this->current_post_type = $this->se_cfg['data']['post_types'][$post_type];
?>
<table class="widefat simply-exclude-settings-postbox simplyexclude-active-panel" cellpadding="3" cellspacing="3" border="0">
<thead>
<tr>
<th class="action" colspan="2"><?php _e('Query Filtering', SIMPLY_EXCLUDE_I18N_DOMAIN) ?></th>
</tr>
</thead>
<tbody>
<tr>
<td class="description">
<p><?php _e("Override query filtering for Main Loop Only or All Loops?", SIMPLY_EXCLUDE_I18N_DOMAIN) ?></p>
<p><?php _e("The Simply-Exclude plugin was designed to only work with the main page query. But sometimes other plugins or your theme will effect how the main filtering works. So if you are having trouble attempting to filter categories from your home page you might want to try and set this option to 'All' and see if it corrects your issue.", SIMPLY_EXCLUDE_I18N_DOMAIN); ?></p>
</td>
<td class="inc-excl">
<input type="radio" name="se_cfg[<?php echo $post_type; ?>][options][qover]" value="main"
<?php if ($this->current_post_type['options']['qover'] == 'main')
echo "checked='checked'"; ?> /> <?php _e('Main Loop Only', SIMPLY_EXCLUDE_I18N_DOMAIN); ?><br />
<input type="radio" name="se_cfg[<?php echo $post_type; ?>][options][qover]" value="all"
<?php if ($this->current_post_type['options']['qover'] == 'all')
echo "checked='checked'"; ?> /> <?php _e('All Loops', SIMPLY_EXCLUDE_I18N_DOMAIN); ?>
</td>
</tr>
</table>
<?php
}
function se_show_se_type_query_override_panel($se_type)
{
if (!$se_type) return;
if (!isset($this->se_cfg['data']['se_types'][$se_type]))
return;
$this->current_se_type = $this->se_cfg['data']['se_types'][$se_type];
?>
<table class="widefat simply-exclude-settings-postbox simplyexclude-active-panel" cellpadding="3" cellspacing="3" border="0">
<thead>
<tr>
<th class="action" colspan="2"><?php _e('Query Filtering', SIMPLY_EXCLUDE_I18N_DOMAIN) ?></th>
</tr>
</thead>
<tbody>
<tr>
<td class="description">
<p><?php _e("Override query filtering for Main Loop Only or All Loops?", SIMPLY_EXCLUDE_I18N_DOMAIN) ?></p>
<p><?php _e("The Simply-Exclude plugin was designed to only work with the main page query. But sometimes other plugins or your theme will effect how the main filtering works. So if you are having trouble attempting to filter categories from your home page you might want to try and set this option to 'All' and see if it corrects your issue.", SIMPLY_EXCLUDE_I18N_DOMAIN); ?></p>
</td>
<td class="inc-excl">
<input type="radio" name="se_cfg[<?php echo $se_type; ?>][options][qover]" value="main"
<?php if ($this->current_se_type['options']['qover'] == 'main')
echo "checked='checked'"; ?> /> <?php _e('Main Loop Only', SIMPLY_EXCLUDE_I18N_DOMAIN); ?><br />
<input type="radio" name="se_cfg[<?php echo $se_type; ?>][options][qover]" value="all"
<?php if ($this->current_se_type['options']['qover'] == 'all')
echo "checked='checked'"; ?> /> <?php _e('All Loops', SIMPLY_EXCLUDE_I18N_DOMAIN); ?>
</td>
</tr>
</table>
<?php
}
/****************************************************************************************************************************/
/* */
/* COLUMNS (HEADERS) */
/* */
/****************************************************************************************************************************/
function se_manage_taxonomy_columns($columns)
{
if (current_user_can('manage_options')) {
if (!isset($columns['se-actions']))
$columns['se-actions'] = '<a id="se-show-actions-panel" title="" href="#">'. __('Simply Exclude', SIMPLY_EXCLUDE_I18N_DOMAIN) .'</a>';
}
return $columns;
}
function se_manage_post_type_columns($columns)
{
if (current_user_can('manage_options')) {
if (!isset($columns['se_actions']))
$columns['se-actions'] = __('Simply Exclude', SIMPLY_EXCLUDE_I18N_DOMAIN). ' <a id="se-show-actions-panel" href="#">'. __('show', SIMPLY_EXCLUDE_I18N_DOMAIN) .'</a>';
}
return $columns;
}
function se_manage_user_columns($columns)
{
if (current_user_can('manage_options')) {
if (!isset($columns['se_actions']))
$columns['se-actions'] = __('Simply Exclude', SIMPLY_EXCLUDE_I18N_DOMAIN). ' <a id="se-show-actions-panel" href="#">'. __('show', SIMPLY_EXCLUDE_I18N_DOMAIN) .'</a>';
}
return $columns;
}
/****************************************************************************************************************************/
/* */
/* COLUMNS (ACTIONS) */
/* */
/****************************************************************************************************************************/
function se_display_taxonomy_column_filters($content='', $column_name, $term_id)
{
global $taxonomy, $post_type;
if (current_user_can('manage_options')) {
if ($column_name == "se-actions")
{
if ($taxonomy)
{
$term = get_term( $term_id, $taxonomy );
if ($term)
{
$this->current_taxonomy = $this->se_cfg['data']['taxonomies'][$taxonomy];
ob_start();
$this->se_display_taxonomy_term_action_row($taxonomy, $term);
$out = ob_get_contents();
ob_end_clean();
return $out;
}
}
}
}
return $content;
}
function se_display_post_type_column_actions($column_name, $post_id)
{
global $post_type;
if (current_user_can('manage_options')) {
if ($column_name == "se-actions")
{
$this->current_post_type = $this->se_cfg['data']['post_types'][$post_type];
if ($post_id)
{
$p_item = get_post( $post_id );
if ($p_item)
{
$this->se_display_post_type_action_row($post_type, $p_item);
}
}
}
}
}
function se_display_user_column_actions($content='', $column_name, $user_id )
{
if (current_user_can('manage_options')) {
if ($column_name == "se-actions")
{
$se_type = "users";
if (isset($this->se_cfg['data']['se_types'][$se_type]))
{
ob_start();
$this->current_se_type = $this->se_cfg['data']['se_types'][$se_type];
if ($user_id)
{
$user = get_userdata($user_id);
if ($user)
{
$this->se_display_user_action_row($se_type, $user);
}
}
$out = ob_get_contents();
ob_end_clean();
return $out;
}
}
}
return $content;
}
/****************************************************************************************************************************/
/* */
/* COLUMNS ACTION ROW */
/* */
/****************************************************************************************************************************/
function se_display_taxonomy_term_action_row($taxonomy='', $term='')
{
if (!$taxonomy) return;
if (!$term) return;
if (current_user_can('manage_options')) {
if ((isset($this->current_taxonomy['actions'])) && (count($this->current_taxonomy['actions'])))
{
?><ul class="se-actions-list"><?php
foreach ($this->current_taxonomy['actions'] as $action_key => $action_val)
{
?>
<li><input type="checkbox"
name="se_cfg[<?php echo $taxonomy; ?>][terms][<?php echo $action_key ?>][<?php echo $term->term_id ?>]"
id="<?php echo $taxonomy; ?>-<?php echo $action_key ?>-<?php echo $term->term_id ?>" class="se-term-input"
<?php
if ((isset($this->current_taxonomy['terms'][$action_key][$term->term_id]))
&& ($this->current_taxonomy['terms'][$action_key][$term->term_id] == "on"))
echo "checked='checked' ";
?> /> <label for="<?php echo $taxonomy; ?>-<?php echo $action_key ?>-<?php echo $term->term_id ?>"
class="se-term-label"><?php echo $this->get_taxonomy_action_label($taxonomy, $action_key, 'name'); ?></label></li>
<?php
}
?></ul><?php
}
}
}
function se_display_post_type_action_row($post_type='', $p_item='')
{
if (!$post_type) return;
if (!$p_item) return;
if (current_user_can('manage_options')) {
if ((isset($this->current_post_type['actions'])) && (count($this->current_post_type['actions'])))
{
?><ul class="se-actions-list"><?php
foreach ($this->current_post_type['actions'] as $action_key => $action_val)
{
?><li><input type="checkbox"
name="se_cfg[<?php echo $post_type; ?>][terms][<?php echo $action_key ?>][<?php echo $p_item->ID ?>]"
id="<?php echo $post_type; ?>-<?php echo $action_key ?>-<?php echo $p_item->ID ?>" class="se-term-input"
<?php
if ((isset($this->current_post_type['terms'][$action_key][$p_item->ID]))
&& ($this->current_post_type['terms'][$action_key][$p_item->ID] == "on"))
echo "checked='checked' ";
?> /> <label for="<?php echo $post_type; ?>-<?php echo $action_key ?>-<?php echo $p_item->ID ?>">
<?php echo $this->get_post_type_action_label($post_type, $action_key, 'name') ?></label></li>
<?php
}
?></ul><?php
}
}
}
function se_display_user_action_row($se_type, $user)
{
if (!$se_type) return;
if (!$user) return;
if (current_user_can('manage_options')) {
if ((isset($this->current_se_type['actions'])) && (count($this->current_se_type['actions'])))
{
?><ul class="se-actions-list"><?php
foreach ($this->current_se_type['actions'] as $action_key => $action_val)
{
?><li><input type="checkbox"
name="se_cfg[<?php echo $se_type; ?>][terms][<?php echo $action_key ?>][<?php echo $user->ID ?>]"
id="<?php echo $se_type; ?>-<?php echo $action_key ?>-<?php echo $user->ID ?>" class="se-term-input"
<?php
if ((isset($this->current_se_type['terms'][$action_key][$user->ID]))
&& ($this->current_se_type['terms'][$action_key][$user->ID] == "on"))
echo "checked='checked' ";
?> /> <label for="<?php echo $se_type; ?>-<?php echo $action_key ?>-<?php echo $user->ID ?>">
<?php echo $this->get_se_type_action_label($se_type, $action_key, 'name') ?></label></li>
<?php
}
?></ul><?php
}
}
}
/****************************************************************************************************************************/
/* */
/* USER PROFILE */
/* */
/****************************************************************************************************************************/
function se_show_user_profile($profileuser)
{
$se_type = "users";
$this->current_se_type = $this->se_cfg['data']['se_types'][$se_type];
if (current_user_can('manage_options')) {
if ($this->current_se_type['options']['showhide'] == "show") {
?>
<table class="form-table">
<tr>
<th><label for="simply-exclude">Simply-Exclude</label></th>
<td class="cat-action"><?php $this->se_display_user_action_row('users', $profileuser) ?></td>
</tr>
</table>
<?php
}
}
}
function se_save_user_profile($user_id)
{
if (!$user_id)
return;
$this->se_load_config();
// First remove all traces of the post item in the actions
$se_type = "users";
if ((isset($this->se_cfg['data']['se_types'][$se_type]['terms'])) && (count($this->se_cfg['data']['se_types'][$se_type]['terms'])))
{
foreach($this->se_cfg['data']['se_types'][$se_type]['terms'] as $cfg_action => $cfg_action_items)
{
foreach($cfg_action_items as $action_id => $action_val)
{
if ($action_id == $_REQUEST['user_id'])
{
unset($this->se_cfg['data']['se_types'][$se_type]['terms'][$cfg_action][$action_id]);