-
Notifications
You must be signed in to change notification settings - Fork 0
/
sidebar.php
209 lines (171 loc) · 7.24 KB
/
sidebar.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
<?php
date_default_timezone_set('America/Argentina/Buenos_Aires');
$meses = array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
$dias = array("Domingo", "Lunes","Martes","Miércoles","Jueves","Viernes","Sábado");
$settings = json_decode(TWITTER_ACCESS,true);
//echo "<!--YULI:".TWITTER_ACCESS."-->";
require_once('twitter_api/TwitterAPIExchange.php');
$url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
$requestMethod = "GET";
$getfield = '?screen_name=it_floss&count=8';
?>
<div class="content">
<?php
if(get_field('fecha') AND empty($_GET['s'])): //Es evento // /inscribirme?pid=<?= get_the_ID()
if(strtotime(date_format(date_create(get_field('fecha')),'Ymd')) >= strtotime(date('Ymd'))): //Si la fecha es mayor o igual ?>
<?php
if (!is_user_logged_in()){
$clase = 'btn-login btn-iniciar-sesion';
$texto = 'Inscribirme al evento';
//$_SESSION['last_evento'] = get_the_ID();
}else{
$current_user = wp_get_current_user();
$current_user_ID = $current_user->ID;
$query = "SELECT COUNT(*) FROM if_inscripciones WHERE post_id = '".get_the_ID()."' AND user_id = '".$current_user_ID."';";
$resCount = $wpdb->get_var($query);
$wpdb->flush();
if($resCount > 0){
$clase = 'btn-ya-inscripto';
$texto = 'Ya estás inscripto :)';
}else{
$clase = 'btn-inscricipcion';
$texto = 'Inscribirme al evento';
}
}
?>
<div style="text-align:center;">
<a class="btn-naranja <?= $clase ?>" href="#" data-id="<?= get_the_ID() ?>" rel="nofollow" style="width:100%;">
<?= $texto ?> <i class="ion-pin"></i>
</a>
</div>
<div style="height: 15px;"></div>
<?php
$query = "SELECT * FROM if_inscripciones WHERE post_id = '".get_the_ID()."';";
$inscriptos = $wpdb->get_results($query);
$wpdb->flush();
if(count($inscriptos)>0): ?>
<div class="cf" style="margin-bottom:20px;">
<h3 class="h3blog">Asistirán <i class="ion-calendar"></i></h3>
<?php
foreach ($inscriptos as $insc) {
$user = get_user_by( 'ID', $insc->user_id);
$avatar = get_avatar_data($insc->user_id);
if(!empty($avatar['url'])){
echo '<img width="50" style="float:left;margin:2px;" src="'.$avatar['url'].'" title="'.$user->first_name." ".$user->last_name.'" />';
}
}
?>
</div>
<?php
endif;
else:
if (get_field('galeria')) {
?>
<div style="text-align:center;">
<a href='<?php echo get_field('galeria'); ?>' style='width:100%' class='btn-naranja' target='_blank'>Ver Galería <i class="ion-images"></i></a>
</div>
<?php
}
endif;
echo '<hr class="hr2">';
endif;
?>
<div class="buscador cf">
<h3 class="h3blog">Buscador <i class="ion-ios-search-strong"></i></h3>
<form role="search" method="get" class="search-form cf" action="<?= home_url( '/' ) ?>">
<label>
<input type="search" id="input-buscar" autocomplete="new-password" placeholder="Buscar..." value="<?= get_search_query() ?>" name="s" title="Buscar..." />
</label>
<button id="boton-buscar" name="boton-buscar">
<i class="ion-android-search"></i>
</button>
</form>
</div>
<hr class="hr2">
<div class="proximos-eventos cf">
<h3 class="h3blog">Próximos eventos <i class="ion-calendar"></i></h3>
<table class="evento">
<tbody>
<?php
$args = array(
'post_type' => 'post',
'category_name'=>'eventos',
'post_status'=>'publish',
'posts_per_page'=>'8',
'order' => 'ASC',
'orderby' => 'meta_value',
'meta_query' => array(
array(
'key' => 'fecha',
'value' => date('Ymd'),
'compare' => '>='
)
));
$query = new WP_Query($args);
?>
<?php if( $query->have_posts() ): while( $query->have_posts() ): $query->the_post(); ?>
<?php $fechaE = strtotime(date_format(date_create(get_post_meta(get_the_ID(), 'fecha', TRUE)),'Y-m-d')); ?>
<tr>
<th colspan="2">
<?php echo $dias[date('w',$fechaE)].", ".date('d',$fechaE)." de ".$meses[date('n', $fechaE)-1]." ".date('Y',$fechaE); ?>
</th>
</tr>
<tr class="trHover">
<td><a href="<?php the_permalink(); ?>"><?php echo get_post_meta(get_the_ID(), 'hora', TRUE); ?> Hs</a></td>
<td><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></td>
</tr>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
</tbody>
</table>
</div>
<?php
$twitter = new TwitterAPIExchange($settings);
$string = json_decode($twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest(),$assoc = TRUE);
if($string): ?>
<hr class="hr2">
<div class="twitter">
<h3 class="h3blog">Últimos tweets <a href="https://twitter.com/IT_Floss" style="color:gray;" target="_blank"><i class="ion-social-twitter"></i></a></h3>
<?php foreach ($string as $tweet): ?>
<p class="tweet">
<?php $fecha = strtotime($tweet['created_at']); ?>
<small>
<em><?= date('d', $fecha)." de ".$meses[date('n', $fecha)-1]. " de ".date('Y', $fecha) ; ?></em>
</small>
<br>
<?php
if (!empty($tweet['retweeted']) && $tweet['retweeted']) {
$tweet['text'] = $tweet['retweeted_status']['text'];
}
$tweet['text'] = preg_replace('/@(\w+)\b/i', '<a target="_blank" href="http://twitter.com/$1">@$1</a>', $tweet['text']);
$tweet['text'] = preg_replace('/#(\w+)\b/i', '<a target="_blank" href="https://twitter.com/hashtag/$1?src=itfloss.rocks">#$1</a>', $tweet['text']);
$tweet['text'] = preg_replace('/https:\/\/t.co\/(\w+)\b/i', '<a target="_blank" href="https://t.co/$1">https://t.co/$1</a>', $tweet['text']);
?>
<?= $tweet['text'] ?>
</p>
<hr class="hr3">
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<div id="inscripcion" style="display: none;">
<div class="contenido_modal">
<p>Hola <?php echo $current_user->first_name; ?>, gracias por inscribirte a <strong>"<?php the_title(); ?>"</strong>. <br>
Antes de continuar, te damos un espacio para expresarte.</p>
<form id="form-enteraste" action="" method="">
<input type="hidden" name="ajax_inscribirme" value="1" />
<input type="hidden" name="action" value="implement_ajax" />
<input type="hidden" name="id_usuario" value="<?php echo $current_user_ID; ?>" />
<input type="hidden" name="email_usuario" value="<?php echo $current_user->user_email; ?>" />
<input type="hidden" name="nombre_evento" value="<?php the_title(); ?>" />
<input type="hidden" name="id_evento" value="<?= get_the_ID() ?>" />
<input type="text" name="como" id="como" placeholder="Me entere por FB || Me encanta el grupo || Son unos nabos, sigan así" />
<a type="button" id="inscribirme" class="btn-naranja inscribirme">Inscribirme <i class="ion-happy-outline"></i></a>
</form>
</div>
</div>
<div id="msesion" style="display: none;">
<div class="contenido_modal">
<p><a href="https://itfloss.rocks/wp-login.php?redirect_to=<?php echo 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>" class="btn-naranja">Iniciar sesión</a></p>
</div>
</div>