-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage-waw-list-contacts.php
executable file
·196 lines (187 loc) · 7.92 KB
/
page-waw-list-contacts.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
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
<?php /* Template Name: Waste Picker Groups List contacts */
get_header();
// Grabs continent from url to filter the list of organization displayed by continent
$continent = '';
if ( !empty($_GET['continent'])) {
$continent = sanitize_text_field( $_GET['continent'] );
}
// Countries in contintents are defined in functions.php
//$continent = sanitize_text_field( $_GET['continent'] );
if ($continent == '' ) {
$active_continent = $all;
} else if ( $continent == 'asia') {
$active_continent = $asia;
} else if ( $continent == 'latinamerica') {
$active_continent = $latinamerica;
} else if ( $continent == 'africa') {
$active_continent = $africa;
} else if ( $continent == 'northamerica') {
$active_continent = $northamerica;
} else if ( $continent == 'europe') {
$active_continent = $europe;
} else if ( $continent == 'all') {
$active_continent = $all;
}
$meta_query = array(
array(
'key' => 'country',
'value' => $active_continent,
'compare' => 'IN',
)
);
?>
<div id="page-wpg">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<?php get_template_part( 'nav', 'waw' ); ?>
<div class="row">
<div class="pull-right"><?php do_action('icl_language_selector'); ?></div>
<h2 id="post-<?php the_ID(); ?>" class="col-md-10 ">
<?php the_title();?> « <?php _e('Waste pickers Around the World (WAW)','globalrec'); ?>
</h2>
</div>
<div class="row">
<div class="col-md-10">
<h3> <?php if (current_user_can( 'moderate_comments' )) { echo 'number of queries: '. get_num_queries(); }?> </h3>
<ul class="nav nav-pills">
<li role="presentation" class="disabled"><a href="?continent=all" title=""><?php _e('Filter by continent','globalrec'); ?>: </a></li>
<li role="presentation"><a href="?continent=all" title="<?php _e('All','globalrec'); ?>"><?php _e('All','globalrec'); ?></a></li>
<li role="presentation"><a href="?continent=asia" title="<?php _e('Asia','globalrec'); ?>"><?php _e('Asia','globalrec'); ?></a></li>
<li role="presentation"><a href="?continent=latinamerica" title="<?php _e('Latin America','globalrec'); ?><"><?php _e('Latin America','globalrec'); ?></a></li>
<li role="presentation"><a href="?continent=africa" title="<?php _e('Africa','globalrec'); ?> "><?php _e('Africa','globalrec'); ?></a></li>
<li role="presentation"><a href="?continent=northamerica" title="<?php _e('North America','globalrec'); ?> "><?php _e('North America','globalrec'); ?></a></li>
<li role="presentation"><a href="?continent=europe" title="<?php _e('Europe','globalrec'); ?> "><?php _e('Europe','globalrec'); ?></a></li>
</ul>
</div>
</div>
<div class="row content">
<div class="col-md-9">
<?php the_content(); ?>
</div>
<?php endwhile; endif; ?>
</div>
<div class="row">
<?php
$args = array(
'post_type' => 'waste-picker-org',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
'suppress_filters'=> true, //removes filter by language so the list can be displayed in all the pages regardless its language
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'wpg-member-occupation',
'field' => 'slug',
'terms' => 'waste-pickers',
),
array(
'taxonomy' => 'wpg-member-type',
'field' => 'slug',
'terms' => array('members-are-waste-pickers', 'members-are-waste-picker-organizations'),
'operator' => 'IN',
),
),
'meta_query' => $meta_query,
);
$my_query = new WP_Query($args);
?>
<table class="table table-hover table-condensed" id="wpg-list">
<thead>
<tr>
<th>#</th>
<th><?php _e('Name','globalrec'); ?></th>
<th><span class='dashicons dashicons-twitter'></span></th>
<th><span class='dashicons dashicons-facebook-alt'></span></th>
<th>Skype</th>
<th>Email</th>
<th>Physical Adress</th>
<th>Postal Adress</th>
<th>Phone 1</th>
<th>Phone 2</th>
<th>Cellphone</th>
<th>Fax</th>
<th>Primary contact</th>
<th>position</th>
<th>phone</th>
<th>email</th>
<th>Secondary contact</th>
<th>phone</th>
<th>email</th>
<th>location</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
<?php if ( $my_query->have_posts() ) : while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
<?php //necessary to show the tags
global $wp_query;
$wp_query->in_the_loop = true;
$more = 0; // Set (inside the loop) to display content above the more "seguir leyendo" tag.
$post_id = $post->ID;
?>
<tr <?php post_class(''); ?> id="post-<?php the_ID(); ?>">
<td>
<?php echo "<small>". $i ."</small>";
$i++; ?>
</td>
<?php if ( is_user_logged_in() ) { ?>
<td> <a href="<?php the_permalink() ?>" rel="bookmark" title="Go to <?php the_title_attribute(); ?> page">
<strong><?php the_title(); ?></strong></a>
</td>
<td><?php
$twitter = get_post_meta( $post_id, '_wpg_twitter', true );
echo $twitter ? "<a href='http://twitter.com/".$twitter."' title='Twitter user @".$twitter."'><span class='dashicons dashicons-twitter'></span> @".$twitter."</a><br>" : ' '; ?>
</td>
<td><?php
$facebook = get_post_meta( $post_id, '_wpg_facebook', true );
echo $facebook ? "<a href='".$facebook. "'><span class='dashicons dashicons-facebook-alt'></span></a><br>" : ''; ?>
</td>
<td>
<?php echo get_post_meta( $post_id, '_wpg_skype', true ); ?>
</td>
<td><?php echo get_post_meta( $post_id, '_wpg_email', true ); ?></td>
<td><?php echo get_post_meta( $post_id, '_wpg_physical_address', true ); ?></td>
<td><?php echo get_post_meta( $post_id, '_wpg_postal_address', true ); ?></td>
<td><?php echo get_post_meta( $post_id, '_wpg_phone1', true ); ?></td>
<td><?php echo get_post_meta( $post_id, '_wpg_phone2', true ); ?></td>
<td><?php echo get_post_meta( $post_id, '_wpg_cell_phone', true ); ?></td>
<td><?php echo get_post_meta( $post_id, '_wpg_fax', true ); ?></td>
<td><?php echo get_post_meta( $post_id, '_wpg_primary_contact_name', true ); ?></td>
<td><?php echo get_post_meta( $post_id, '_wpg_primary_contact_position', true ); ?></td>
<td><?php echo get_post_meta( $post_id, '_wpg_primary_contact_phone', true ); ?></td>
<td><?php echo get_post_meta( $post_id, '_wpg_primary_contact_email', true ); ?></td>
<td><?php echo get_post_meta( $post_id, '_wpg_secondary_contact_name', true ); ?></td>
<td><?php echo get_post_meta( $post_id, '_wpg_secondary_contact_phone', true ); ?></td>
<td><?php echo get_post_meta( $post_id, '_wpg_secondary_contact_email', true ); ?></td>
<td><?php
//Country
$country_id = get_post_meta( $post_id, '_wpg_countryselect', true );
$country = get_post($country_id);
$country_name = $country->post_title;
$country_link = $country->post_name;
//orgs without country selected
$country2 =get_post_meta( $post_id, 'country', true );
$country2_slug = strtolower (str_replace(" ","-",$country2));
if ( !empty($country) ) { //displays the country from the selection list '_wpg_countryselect', if it has been selected, if not it displays the country from the open field '_wpg_city'
if ( empty($country_id) ) {//if no country selected from list
echo '<a href="/country/'.$country2_slug.'">'.$country2.'</a>';
echo is_user_logged_in() ? " <span class='label label-danger'>select country</span>" : "";
} else if ($country_name == "-" || $country_name == "Not specified") {//if not specified country from list
echo '<a href="/country/'.$country2_slug.'">'.$country2.'</a>';
echo is_user_logged_in() ? " <span class='label label-danger'>select country</span>" : "";
} else {//country selected
echo '<a href="/country/'.$country_link.'">'.$country_name.'</a>';
}
} else {
}
?></td>
<?php } ?>
</tr>
</div>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</tbody>
</table>
</div>
<?php get_footer(); ?>