Skip to content

Commit 21b3411

Browse files
authored
Merge pull request #398 from creativecommons/chapter-mb-fix
Fix Chapter lead issues on chapters metabox & view
2 parents ef7b4e1 + 32d8865 commit 21b3411

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

themes/cc-commoners-2019/archive-cc_chapters.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<div class="inline-container">
3030
<h3 class="chapter-title"></h3>
3131
<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>
3333
<p><small>founded on <em class="chapter-date"></em> </small></p>
3434
</div>
3535
<a href="#" class="button warning more">More information</a>

themes/cc-commoners-2019/assets/js/commoners-chapters.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,18 @@ jQuery(document).ready(function($){
66
var writeInfoBox = function (value) {
77
info_box.find('.chapter-title').html(value.name);
88
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+
}
1021
info_box.find('.button.more').attr('href',value.link);
1122
}
1223

themes/cc-commoners-2019/inc/custom-post-type/queulat-cc-chapters-cpt-plugin/class-cc-chapters-metabox.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ public function get_fields() : array
161161
'properties' => [
162162
'instance' => [
163163
'width' => '100%',
164-
'multiple' => false,
164+
'multiple' => true,
165165
'minimumInputLength' => 3,
166+
'allowClear' => true,
167+
'placeholder' => 'Select',
166168
'ajax' => [
167169
'url' => admin_url('admin-ajax.php?action=event-metabox__search-members&chapter_id=' . get_the_ID()),
168170
]
@@ -200,6 +202,8 @@ public function get_fields() : array
200202
'width' => '100%',
201203
'multiple' => false,
202204
'minimumInputLength' => 3,
205+
'allowClear' => true,
206+
'placeholder' => 'Select',
203207
'ajax' => [
204208
'url' => admin_url('admin-ajax.php?action=event-metabox__search-members&chapter_id=' . get_the_ID()),
205209
]

themes/cc-commoners-2019/inc/site.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,21 @@ public static function get_chapters_by_status() {
5757
$results = [];
5858
if ($query->have_posts()) {
5959
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+
}
6069
$single_chapter = [];
6170
$single_chapter['name'] = $post->post_title;
6271
$single_chapter['link'] = get_permalink( $post->ID );
6372
$single_chapter['date'] = $post->cc_chapters_date;
6473
$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;
6675
$single_chapter['member_gnc'] = get_user_by('id', $post->cc_chapters_member_gnc)->display_name;
6776
$single_chapter['country_code'] = $post->cc_chapters_chapter_country;
6877
$single_chapter['url'] = $post->cc_chapters_url;

themes/cc-commoners-2019/single-cc_chapters.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<section class="entry-meta chapter-metadata">
1616
<?php
1717
global $post;
18+
$chapter_lead = get_post_meta($post->ID, 'cc_chapters_chapter_lead',false);
1819
$date_founded = $post->cc_chapters_date;
1920
$chapter_mail = $post->cc_chapters_email;
20-
$chapter_lead = $post->cc_chapters_chapter_lead;
2121
$member_gnc = $post->cc_chapters_member_gnc;
2222
$external_url = $post->cc_chapters_url;
2323
$chapter_url = $post->cc_chapters_chapter_url;
@@ -64,9 +64,11 @@
6464
?>
6565
</div>
6666
<?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">';
6868
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+
}
7072
}
7173
if ( !empty( $member_gnc ) ) {
7274
echo render::chapter_member($member_gnc, 'Representative to the Global Network Council');

0 commit comments

Comments
 (0)