質問編集履歴
4
指摘された箇所の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -97,3 +97,11 @@
|
|
97
97
|
|
98
98
|
|
99
99
|
お知恵を拝借できれば幸いです。よろしくお願いいたします。
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
##追記
|
104
|
+
|
105
|
+
ご指摘を受けた事に関して、
|
106
|
+
|
107
|
+
私の想定は、selectedとなった、タブに絞り込みが適用され、そのカテゴリ−のイベントだけが初期の状態から表示されていることでした。しかし、今の状態はカテゴリーごとに絞り込みされておらず、全てのイベントが表示されている状態です。
|
3
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -93,3 +93,7 @@
|
|
93
93
|
```
|
94
94
|
|
95
95
|
selectedの値を、初期の状態にしたいidに変更したのですが、実際表示するとドロップダウンのタブがその状態になっているだけで、その絞り込みが適用されていないのです。これを適用するにはどうすれば良いのでしょうか。
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
お知恵を拝借できれば幸いです。よろしくお願いいたします。
|
2
質問内容の変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
wp_dropdown_categories()で初期状態の選択が反映されるようにしたい。
|
test
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
現在、、WordpressでEvents ManagerとFullCalendarを使用してイベントを管理するサイトを作っています。
|
4
4
|
|
5
|
+
|
6
|
+
|
5
|
-
実現したいのは、
|
7
|
+
実現したいのは、Fullcalendarの絞り込み機能の、wp_dropdown_categories()で初期状態の選択が反映されるようにしたいです。
|
6
8
|
|
7
9
|
|
8
10
|
|
@@ -10,96 +12,84 @@
|
|
10
12
|
|
11
13
|
|
12
14
|
|
13
|
-
e
|
15
|
+
wp-fullcalendar.phpの
|
14
16
|
|
15
17
|
```php
|
16
18
|
|
17
|
-
if
|
19
|
+
<div class="wpfc-calendar-wrapper"><form class="wpfc-calendar"></form><div class="wpfc-loading"></div></div>
|
18
20
|
|
19
|
-
|
21
|
+
<div class="wpfc-calendar-search" style="display:none;">
|
20
22
|
|
21
|
-
|
23
|
+
<?php
|
22
24
|
|
23
|
-
|
25
|
+
$post_type = !empty(self::$args['type']) ? self::$args['type']:'post';
|
24
26
|
|
25
|
-
|
27
|
+
//figure out what taxonomies to show
|
26
28
|
|
27
|
-
|
29
|
+
$wpfc_post_taxonomies = get_option('wpfc_post_taxonomies');
|
28
30
|
|
29
|
-
|
31
|
+
$search_taxonomies = !empty($wpfc_post_taxonomies[$post_type]) ? array_keys($wpfc_post_taxonomies[$post_type]):array();
|
30
32
|
|
31
|
-
|
33
|
+
if( !empty($args['taxonomies']) ){
|
32
34
|
|
33
|
-
|
35
|
+
//we accept taxonomies in arguments
|
34
36
|
|
35
|
-
|
37
|
+
$search_taxonomies = explode(',',$args['taxonomies']);
|
36
38
|
|
37
|
-
|
39
|
+
array_walk($search_taxonomies, 'trim');
|
38
40
|
|
39
|
-
|
41
|
+
unset(self::$args['taxonomies']);
|
40
42
|
|
41
|
-
|
43
|
+
}
|
42
44
|
|
43
|
-
|
45
|
+
//go through each post type taxonomy and display if told to
|
44
46
|
|
45
|
-
|
47
|
+
foreach( get_object_taxonomies($post_type) as $taxonomy_name ){
|
46
48
|
|
47
|
-
|
49
|
+
$taxonomy = get_taxonomy($taxonomy_name);
|
48
50
|
|
49
|
-
|
51
|
+
if( count(get_terms($taxonomy_name, array('hide_empty'=>1))) > 0 && in_array($taxonomy_name, $search_taxonomies) ){
|
50
52
|
|
51
|
-
|
53
|
+
$default_value = !empty(self::$args[$taxonomy_name]) ? self::$args[$taxonomy_name]:0;
|
52
54
|
|
53
|
-
|
55
|
+
$taxonomy_args = array( 'echo'=>true, 'hide_empty' => 1, 'name' => $taxonomy_name, 'hierarchical' => true, 'class' => 'wpfc-taxonomy '.$taxonomy_name, 'taxonomy' => $taxonomy_name, 'selected'=> $default_value, 'show_option_all' => $taxonomy->labels->all_items);
|
54
56
|
|
55
|
-
|
57
|
+
wp_dropdown_categories( apply_filters('wpmfc_calendar_taxonomy_args', $taxonomy_args, $taxonomy ) );
|
56
58
|
|
57
|
-
|
59
|
+
}
|
58
60
|
|
59
|
-
|
61
|
+
}
|
60
62
|
|
61
|
-
|
63
|
+
do_action('wpfc_calendar_search', self::$args);
|
62
64
|
|
63
|
-
|
65
|
+
?>
|
64
66
|
|
65
|
-
|
67
|
+
</div>
|
66
68
|
|
67
|
-
'separate_items_with_commas'=>__('Separate event categories with commas','events-manager'),
|
68
|
-
|
69
|
-
'add_or_remove_items'=>__('Add or remove events','events-manager'),
|
70
|
-
|
71
|
-
'choose_from_the_most_used'=>__('Choose from most used event categories','events-manager'),
|
72
|
-
|
73
|
-
|
69
|
+
```
|
74
|
-
|
75
|
-
'capabilities' => array(
|
76
|
-
|
77
|
-
'manage_terms' => 'edit_event_categories',
|
78
|
-
|
79
|
-
'edit_terms' => 'edit_event_categories',
|
80
|
-
|
81
|
-
'delete_terms' => 'delete_event_categories',
|
82
|
-
|
83
|
-
'assign_terms' => 'edit_events',
|
84
|
-
|
85
|
-
)
|
86
70
|
|
87
71
|
|
88
72
|
|
89
|
-
|
73
|
+
ここのapply_filters('wpmfc_calendar_taxonomy_args', $taxonomy_args, $taxonomy )でフックし、
|
90
74
|
|
91
|
-
|
92
75
|
|
93
|
-
));
|
94
76
|
|
77
|
+
```php
|
78
|
+
|
79
|
+
function my_wpmfc_calendar_taxonomy_args( $taxonomy_args, $taxonomy ){
|
80
|
+
|
81
|
+
$taxonomy_args['show_option_all'] = '';
|
82
|
+
|
83
|
+
$taxonomy_args['selected'] = 5;
|
84
|
+
|
85
|
+
return $taxonomy_args;
|
86
|
+
|
95
|
-
|
87
|
+
}
|
88
|
+
|
89
|
+
add_filter( 'wpmfc_calendar_taxonomy_args', 'my_wpmfc_calendar_taxonomy_args', 10, 3);
|
90
|
+
|
91
|
+
|
96
92
|
|
97
93
|
```
|
98
94
|
|
99
|
-
この辺で、カテゴリの受け渡しをしているのかなと考えているのですが、ここでどう絞り込みしていけば良いかで詰んでしまっています。
|
100
|
-
|
101
|
-
#追記
|
102
|
-
|
103
|
-
現在、FullCalendarのオプションでドロップダウンの絞り込みが追加できることを今更発見しました。wpmfc_calendar_taxonomy_args()でフックして、select要素のselectedをログインユーザーのランクにセットできれば、、、という状態です。
|
104
|
-
|
105
|
-
|
95
|
+
selectedの値を、初期の状態にしたいidに変更したのですが、実際表示するとドロップダウンのタブがその状態になっているだけで、その絞り込みが適用されていないのです。これを適用するにはどうすれば良いのでしょうか。
|
1
FullCalendar側のwpmfc_calendar_taxonomy_args()のフックで解決できないか追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -97,3 +97,9 @@
|
|
97
97
|
```
|
98
98
|
|
99
99
|
この辺で、カテゴリの受け渡しをしているのかなと考えているのですが、ここでどう絞り込みしていけば良いかで詰んでしまっています。
|
100
|
+
|
101
|
+
#追記
|
102
|
+
|
103
|
+
現在、FullCalendarのオプションでドロップダウンの絞り込みが追加できることを今更発見しました。wpmfc_calendar_taxonomy_args()でフックして、select要素のselectedをログインユーザーのランクにセットできれば、、、という状態です。
|
104
|
+
|
105
|
+
しかし、selectedを合わせてもドロップダウンの値が変わっているだけで、絞り込み自体はされない状態です。
|