-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage-waw-list-contact-info.php
321 lines (312 loc) · 12.1 KB
/
page-waw-list-contact-info.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<?php /* Template Name: Waste Picker Groups List Contact info*/
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="spacetop col-md-2 col-md-push-10"><?php do_action('icl_language_selector'); ?></div>
<h2 id="post-<?php the_ID(); ?>" class="col-md-10 col-md-pull-2">
<?php the_title();?> « <?php _e('Waste pickers Around the World (WAW)','globalrec'); ?>
</h2>
</div>
<div class="row content">
<div class="col-md-9">
<?php the_content(); ?>
</div>
<?php endwhile; endif; ?>
</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">
<div class="col-md-12">
<?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><?php _e('Web','globalrec'); ?></th>
<th><?php _e('Scope','globalrec'); ?></th>
<th><?php _e('Type of Organization','globalrec'); ?></th>
<th><?php _e('Type of Member','globalrec'); ?></th>
<th><?php _e('Number of members','globalrec');
echo "<br>(";
_e('Number of groups','globalrec');
echo ")"; ?>
</th>
<th><?php _e('Location','globalrec'); ?></th>
<?php if ( is_user_logged_in() ) { ?>
<th><?php _e('Organization email','globalrec'); ?></th>
<th><?php _e('Physical address','globalrec'); ?></th>
<th><?php _e('Street number postal code','globalrec'); ?></th>
<th><?php _e('Postal address','globalrec'); ?></th>
<th><?php _e('City','globalrec'); ?></th>
<th><?php _e('Region','globalrec'); ?></th>
<th><?php _e('Country code','globalrec'); ?></th>
<th><?php _e('Phone 1','globalrec'); ?></th>
<th><?php _e('Phone 2','globalrec'); ?></th>
<th><?php _e('Cellphone','globalrec'); ?></th>
<th><?php _e('Fax','globalrec'); ?></th>
<th><?php _e('Skype','globalrec'); ?></th>
<th><?php _e('Facebook','globalrec'); ?></th>
<th><?php _e('Twitter','globalrec'); ?></th>
<th><?php _e('Primary name','globalrec'); ?></th>
<th><?php _e('primary position','globalrec'); ?></th>
<th><?php _e('primary phone','globalrec'); ?></th>
<th><?php _e('primary email','globalrec'); ?></th>
<th><?php _e('Secondary name','globalrec'); ?></th>
<th><?php _e('2nd position','globalrec'); ?></th>
<th><?php _e('2nd phone','globalrec'); ?></th>
<th><?php _e('2nd email','globalrec'); ?></th>
<?php } ?>
</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>
<td> <a href="<?php the_permalink() ?>" rel="bookmark" title="Go to <?php the_title_attribute(); ?> page">
<strong><?php the_title(); ?></strong></a>
<?php if ( is_user_logged_in() ) { ?><div class="btn btn-xs btn-default"> <?php edit_post_link(__('Edit This')); ?></div> <?php } ?>
</td>
<td>
<?php
$website = get_post_meta( $post_id, '_wpg_website', true );
$remove_this = array("http://","https://","www.","/");
$mainurl_stripped = str_replace($remove_this, "", $website);
$max_length = 20;
if ( strlen($mainurl_stripped) > $max_length ) {
$mainurl_stripped = substr($mainurl_stripped,0,$max_length).'...';
}
echo ($website != '') ? "<a href='" .$website. "'>" .$mainurl_stripped. "</a>" : '';
?>
</td>
<td>
<?php echo get_the_term_list( $post_id, 'wpg-scope', ' ', ', ', '' ); ?>
</td>
<td>
<?php
$org_type = get_the_term_list( $post_id, 'wpg-organization-type', ' ', ', ', '' );
echo $org_type == 'ngo' ? 'NGO' : $org_type;
?>
</td>
<td>
<?php
/*$member_type = get_post_meta( $post_id, '_wpg_members_type', true );
if (gettype($member_type) == 'array') {
echo list_of_items($post_id,'_wpg_members_type','');
} else {
echo get_post_meta( $post_id, '_wpg_members_type', true );
} */?>
<?php echo get_the_term_list( $post_id, 'wpg-member-type', ' ', ', ', '' ); ?>
</td>
<td class="text-right">
<?php
//echo list_of_items($post_id,'_wpg_members_occupation','');
$number_wp = get_post_meta( $post_id, '_wpg_number_individuals', true );
$number_wpg = get_post_meta( $post_id, '_wpg_number_groups', true );
echo $number_wp !='' ? number_format($number_wp) : '';
echo $number_wpg !='' ? ' ('.number_format($number_wpg).')' : '';
?>
</td>
<td><?php
//City
$city_id = get_post_meta( $post_id, '_wpg_cityselect', true );
$city = get_post($city_id);
$city_name = $city->post_title;
$city_link = get_permalink($city->ID);
//orgs without city selected
$city2 = get_post_meta( $post_id, 'city', true );
$city2_slug = strtolower (str_replace(" ","-",$city2));
if ( !empty($city) ) {
/*if ($city_name == 'Not specified' ) {
echo $city2. ", ";
} else {
echo '<a href="/city/'.$city2_slug.'">'.$city2.'</a>, ';
}
} else {
echo $city2;
if (!empty($city2)) { echo ", ";};
}*/
if ($city_name == "-" || $city_name == "Not specified") {
echo is_user_logged_in() ? "<span class='label label-danger'>!</span> " : "";
}
echo '<a href="/city/'.$city2_slug.'">'.$city2.'</a>, ';
}
//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 if ( is_user_logged_in() ) { ?>
<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_street_name', true ); ?>
<?php echo get_post_meta( $post_id, '_wpg_street_number', true ); ?>.
<?php echo get_post_meta( $post_id, '_wpg_postal_code', true ); ?>
</td>
<td>
<?php echo get_post_meta( $post_id, '_wpg_postal_address', true ); ?>
</td>
<td>
<?php echo get_post_meta( $post_id, 'city', true ); ?>
</td>
<td>
<?php echo get_post_meta( $post_id, '_wpg_region', true ); ?>
</td>
<td>
<?php echo get_post_meta( $post_id, '_wpg_country_code_telephone', 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_skype', true ); ?>
</td>
<td>
<?php echo get_post_meta( $post_id, '_wpg_facebook', true ); ?>
</td>
<td>
<?php echo get_post_meta( $post_id, '_wpg_twitter', 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_position', 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>
<?php } ?>
</tr>
</div>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
<?php get_footer(); ?>