File tree 5 files changed +33
-7
lines changed
custom-post-type/queulat-cc-chapters-cpt-plugin
5 files changed +33
-7
lines changed Original file line number Diff line number Diff line change 29
29
<div class="inline-container">
30
30
<h3 class="chapter-title"></h3>
31
31
<div class="chapter-metadata">
32
- <p>Chapter lead: <span class="chapter-lead-name"></span></p>
32
+ <p class="chaper-lead-container" >Chapter lead: <span class="chapter-lead-name"></span></p>
33
33
<p><small>founded on <em class="chapter-date"></em> </small></p>
34
34
</div>
35
35
<a href="#" class="button warning more">More information</a>
Original file line number Diff line number Diff line change @@ -6,7 +6,18 @@ jQuery(document).ready(function($){
6
6
var writeInfoBox = function ( value ) {
7
7
info_box . find ( '.chapter-title' ) . html ( value . name ) ;
8
8
info_box . find ( '.chapter-date' ) . html ( value . date ) ;
9
- info_box . find ( '.chapter-lead-name' ) . html ( value . chapter_lead ) ;
9
+ if ( value . chapter_lead != null ) {
10
+ var chapter_lead_string = '' ;
11
+ $ ( '.chaper-lead-container' ) . show ( ) ;
12
+ if ( Array . isArray ( value . chapter_lead ) ) {
13
+ chapter_lead_string = value . chapter_lead . join ( ', ' ) ;
14
+ } else {
15
+ chapter_lead_string = value . chapter_lead ;
16
+ }
17
+ info_box . find ( '.chapter-lead-name' ) . html ( chapter_lead_string ) ;
18
+ } else {
19
+ $ ( '.chaper-lead-container' ) . hide ( ) ;
20
+ }
10
21
info_box . find ( '.button.more' ) . attr ( 'href' , value . link ) ;
11
22
}
12
23
Original file line number Diff line number Diff line change @@ -161,8 +161,10 @@ public function get_fields() : array
161
161
'properties ' => [
162
162
'instance ' => [
163
163
'width ' => '100% ' ,
164
- 'multiple ' => false ,
164
+ 'multiple ' => true ,
165
165
'minimumInputLength ' => 3 ,
166
+ 'allowClear ' => true ,
167
+ 'placeholder ' => 'Select ' ,
166
168
'ajax ' => [
167
169
'url ' => admin_url ('admin-ajax.php?action=event-metabox__search-members&chapter_id= ' . get_the_ID ()),
168
170
]
@@ -200,6 +202,8 @@ public function get_fields() : array
200
202
'width ' => '100% ' ,
201
203
'multiple ' => false ,
202
204
'minimumInputLength ' => 3 ,
205
+ 'allowClear ' => true ,
206
+ 'placeholder ' => 'Select ' ,
203
207
'ajax ' => [
204
208
'url ' => admin_url ('admin-ajax.php?action=event-metabox__search-members&chapter_id= ' . get_the_ID ()),
205
209
]
Original file line number Diff line number Diff line change @@ -57,12 +57,21 @@ public static function get_chapters_by_status() {
57
57
$ results = [];
58
58
if ($ query ->have_posts ()) {
59
59
foreach ($ query ->posts as $ post ) {
60
+ $ chapter_lead = get_post_meta ($ post ->ID , 'cc_chapters_chapter_lead ' ,false );
61
+ $ chapter_lead_name = '' ;
62
+ if (count ($ chapter_lead ) > 1 ) {
63
+ foreach ($ chapter_lead as $ member_id ) {
64
+ $ chapter_lead_name [] = get_user_by ('id ' , $ member_id )->display_name ;
65
+ }
66
+ } else {
67
+ $ chapter_lead_name = get_user_by ('id ' , $ chapter_lead [0 ])->display_name ;
68
+ }
60
69
$ single_chapter = [];
61
70
$ single_chapter ['name ' ] = $ post ->post_title ;
62
71
$ single_chapter ['link ' ] = get_permalink ( $ post ->ID );
63
72
$ single_chapter ['date ' ] = $ post ->cc_chapters_date ;
64
73
$ single_chapter ['email ' ] = $ post ->cc_chapters_email ;
65
- $ single_chapter ['chapter_lead ' ] = get_user_by ( ' id ' , $ post -> cc_chapters_chapter_lead )-> display_name ;
74
+ $ single_chapter ['chapter_lead ' ] = $ chapter_lead_name ;
66
75
$ single_chapter ['member_gnc ' ] = get_user_by ('id ' , $ post ->cc_chapters_member_gnc )->display_name ;
67
76
$ single_chapter ['country_code ' ] = $ post ->cc_chapters_chapter_country ;
68
77
$ single_chapter ['url ' ] = $ post ->cc_chapters_url ;
Original file line number Diff line number Diff line change 15
15
<section class="entry-meta chapter-metadata">
16
16
<?php
17
17
global $ post ;
18
+ $ chapter_lead = get_post_meta ($ post ->ID , 'cc_chapters_chapter_lead ' ,false );
18
19
$ date_founded = $ post ->cc_chapters_date ;
19
20
$ chapter_mail = $ post ->cc_chapters_email ;
20
- $ chapter_lead = $ post ->cc_chapters_chapter_lead ;
21
21
$ member_gnc = $ post ->cc_chapters_member_gnc ;
22
22
$ external_url = $ post ->cc_chapters_url ;
23
23
$ chapter_url = $ post ->cc_chapters_chapter_url ;
64
64
?>
65
65
</div>
66
66
<?php
67
- echo '<div class="grid-x grid-margin-x large-up-2 medium-up-2"> ' ;
67
+ echo '<div class="grid-x grid-margin-x grid-margin-y large-up-2 medium-up-2"> ' ;
68
68
if ( !empty ( $ chapter_lead ) ) {
69
- echo render::chapter_member ($ chapter_lead , 'Chapter Lead ' );
69
+ foreach ($ chapter_lead as $ chapter_lead_id ) {
70
+ echo render::chapter_member ($ chapter_lead_id , 'Chapter Lead ' );
71
+ }
70
72
}
71
73
if ( !empty ( $ member_gnc ) ) {
72
74
echo render::chapter_member ($ member_gnc , 'Representative to the Global Network Council ' );
You can’t perform that action at this time.
0 commit comments