-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
160 lines (130 loc) · 5.07 KB
/
functions.php
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
<?php
//schedule changes loader and page
include 'schedule-changes.php';
include 'dashboard.php';
include 'remote-meetings-export.php';
include 'tsml_react.php';
//load parent style
add_action('wp_enqueue_scripts', function () {
wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
});
//remove sidebar
add_action('widgets_init', function () {
unregister_sidebar('sidebar-1');
register_sidebar(array(
'name' => 'Home Row Two',
'id' => 'home-2',
'description' => 'Widgets for the second row on the home page with two slots',
'before_widget' => '<div id="%1$s" class="column %2$s">',
'after_widget' => '</div></div>',
'before_title' => '<h3>',
'after_title' => '</h3><div class="widget-content">',
));
register_sidebar(array(
'name' => 'Home Row Three',
'id' => 'home-3',
'description' => 'Widgets for the third row on the home page with three slots',
'before_widget' => '<div id="%1$s" class="column %2$s">',
'after_widget' => '</div></div>',
'before_title' => '<h3>',
'after_title' => '</h3><div class="widget-content">',
));
register_sidebar(array(
'name' => 'Service Sidebar',
'id' => 'content-service',
'description' => 'Additional sidebar that appears on the right of the Service section pages.',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
));
}, 11);
/**
* Register all shortcodes
*
* @return null
*/
function register_shortcodes() {
add_shortcode( 'remote_meeting', 'shortcode_remote_meeting' );
}
add_action( 'init', 'register_shortcodes' );
/**
* Hello Everyone Remote Meeting Shortcode
*
* @param Array $atts
*
* @return string
*/
function shortcode_remote_meeting($atts)
{
global $wp_query, $post;
ob_start();
$atts = shortcode_atts(array(
'day' => 'monday',
'type' => 'post'
), $atts);
$loop = new WP_Query(array(
'posts_per_page' => -1,
'post_status' => 'publish',
'post_type' => $atts['type'],
'meta_key' => $atts['day'],
'meta_type' => 'DATE'
));
$events = array();
if ($loop->have_posts()) {
while ($loop->have_posts()) {
$loop->the_post();
$meeting_format_specifics_arm = get_post_meta(get_the_ID(), 'meeting_format_specifics_arm', true);
if (!empty($meeting_format_specifics_arm)) {
$meeting_format_specifics_arm_value = $meeting_format_specifics_arm;
}
$link_to_meeting_arm = get_post_meta(get_the_ID(), 'link_to_meeting_arm', true);
if (!empty($link_to_meeting_arm)) {
$link_to_meeting_arm_value = $link_to_meeting_arm;
}
// taxonomy
$term_obj_list = get_the_terms($post->ID, 'designation');
$terms_string = join(', ', wp_list_pluck($term_obj_list, 'name'));
// origin
$term_origin = get_the_terms($post->ID, 'origin');
$origin_string = join(', ', wp_list_pluck($term_origin, 'name'));
$day = get_post_meta(get_the_ID(), $atts['day'], true);
if (!empty($day)) {
$events[] = array(
'day' => $atts['day'],
'day_value' => strtolower($day),
'permalink' => get_the_permalink(),
'title' => get_the_title(),
'terms_string' => $terms_string,
'meeting_format_specifics_arm_value' => $meeting_format_specifics_arm_value,
'origin_string' => $origin_string,
'link_to_meeting_arm_value' => $link_to_meeting_arm_value,
);
}
}
}
if (count($events) > 0) {
usort($events, function ($a, $b) {
return strtotime($a['day_value']) > strtotime($b['day_value']);
});
foreach ($events as $event) {
echo '<div id="arm-listing" style="margin:15px 0;">';
echo '<div id="arm-time">' . $event['day_value'] . '</div>';
echo '<div id="arm-name"><a href="' . $event['permalink'] . '">' . $event['title'] . ' </a></div>';
if( ! empty( $event['terms_string']) ) {
echo '<div id="arm-designation">' . $event['terms_string'] . '</div>';;
}
// if( ! empty( $event['meeting_format_specifics_arm_value']) ) {
// echo '<div id="arm-format-spec">' . $event['meeting_format_specifics_arm_value'] . '</div>';
// }
//echo '<div id="arm-format-spec">' . $event['meeting_format_specifics_arm_value'] . '</div>';
if( ! empty( $event['origin_string']) ) {
echo '<div id="arm-origin">Origin: ' . $event['origin_string'] . '</div>';
}
// echo '<div id="arm-link"><label>Link to Meeting:</label> <a href="' . $event['link_to_meeting_arm_value'] . '">' . $event['link_to_meeting_arm_value'] . '</a></div>';
echo '</div>';
}
}
wp_reset_postdata();
return ob_get_clean();
}