· 5 years ago · Mar 17, 2020, 06:24 PM
1<?php
2define('VERSIONPX', '1.5.2');
3define('THEMEPX', 'appyn');
4
5add_theme_support( 'title-tag' );
6
7add_action( 'after_setup_theme', 'remove_admin_bar' );
8function remove_admin_bar() {
9 if( wp_is_mobile() ) {
10 show_admin_bar(false);
11 }
12}
13function get_image_id($image_url) {
14 global $wpdb;
15 $attachment = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE guid LIKE '%$image_url%'");
16 return $attachment[0];
17}
18function ads($ads){
19 if( is_404() ) return;
20
21 $ads_output = '';
22 if($ads == "ads_header"){
23 $ads_pc = get_option( 'appyn_ads_header' );
24 $ads_movil = get_option( 'appyn_ads_header_movil' );
25 $ads_amp = get_option( 'appyn_ads_header_amp' );
26 $ads_h = '<aside class="ads ads_header">';
27 $ads_h .= appyn_options('ads_text_above') ? '<small>'.appyn_options('ads_text_above').'</small>': '';
28 if( is_amp_px() ) {
29 if( !empty($ads_amp) ) {
30 $ads_output = $ads_h.$ads_amp;
31 $ads_output .= '</aside>';
32 }
33 } else {
34 if( !empty($ads_pc) && !wp_is_mobile()) {
35 $ads_output = $ads_h.$ads_pc;
36 $ads_output .= '</aside>';
37 }
38 elseif(!empty($ads_movil) && wp_is_mobile()) {
39 $ads_output = $ads_h.$ads_movil;
40 $ads_output .= '</aside>';
41 }
42 }
43 }
44 elseif($ads == "ads_home"){
45 $ads_pc = get_option( 'appyn_ads_home' );
46 $ads_movil = get_option( 'appyn_ads_home_movil' );
47 $ads_amp = get_option( 'appyn_ads_home_amp' );
48 $ads_h = '<aside class="ads ads_home">';
49 $ads_h .= appyn_options('ads_text_above') ? '<small>'.appyn_options('ads_text_above').'</small>': '';
50 if( is_amp_px() ) {
51 if( !empty($ads_amp) ) {
52 $ads_output = $ads_h.$ads_amp;
53 $ads_output .= '</aside>';
54 }
55 } else {
56 if(!empty($ads_pc) && !wp_is_mobile()) {
57 $ads_output = $ads_h.$ads_pc;
58 $ads_output .= '</aside>';
59 }
60 elseif(!empty($ads_movil) && wp_is_mobile()) {
61 $ads_output = $ads_h.$ads_movil;
62 $ads_output .= '</aside>';
63 }
64 }
65 }
66 elseif($ads == "ads_single_top"){
67 $ads_pc = get_option( 'appyn_ads_single_top' );
68 $ads_movil = get_option( 'appyn_ads_single_top_movil' );
69 $ads_amp = get_option( 'appyn_ads_single_top_amp' );
70 $ads_h = '<aside class="ads ads_single_top">';
71 $ads_h .= appyn_options('ads_text_above') ? '<small>'.appyn_options('ads_text_above').'</small>': '';
72 if( is_amp_px() ) {
73 if( !empty($ads_amp) ) {
74 $ads_output = $ads_h.$ads_amp;
75 $ads_output .= '</aside>';
76 }
77 } else {
78 if(!empty($ads_pc) && !wp_is_mobile()) {
79 $ads_output = $ads_h.$ads_pc;
80 $ads_output .= '</aside>';
81 }
82 elseif(!empty($ads_movil) && wp_is_mobile()) {
83 $ads_output = $ads_h.$ads_movil;
84 $ads_output .= '</aside>';
85 }
86 }
87 }
88 elseif($ads == "ads_single_center"){
89 $ads_pc = get_option( 'appyn_ads_single_center' );
90 $ads_movil = get_option( 'appyn_ads_single_center_movil' );
91 $ads_amp = get_option( 'appyn_ads_single_center_amp' );
92 $ads_h = '<aside class="ads ads_single_center">';
93 $ads_h .= appyn_options('ads_text_above') ? '<small>'.appyn_options('ads_text_above').'</small>': '';
94 if( is_amp_px() ) {
95 if( !empty($ads_amp) ) {
96 $ads_output = $ads_h.$ads_amp;
97 $ads_output .= '</aside>';
98 }
99 } else {
100 if(!empty($ads_pc) && !wp_is_mobile()) {
101 $ads_output = $ads_h.$ads_pc;
102 $ads_output .= '</aside>';
103 }
104 elseif(!empty($ads_movil) && wp_is_mobile()) {
105 $ads_output = $ads_h.$ads_movil;
106 $ads_output .= '</aside>';
107 }
108 }
109 }
110 return stripslashes($ads_output);
111}
112remove_action('wp_head', 'print_emoji_detection_script', 7);
113remove_action('wp_print_styles', 'print_emoji_styles');
114remove_action('wp_head', 'rest_output_link_wp_head');
115remove_action('wp_head', 'wp_oembed_add_discovery_links');
116remove_action('template_redirect', 'rest_output_link_header', 11, 0);
117remove_action('wp_head', 'wp_generator');
118remove_action('wp_head', 'rsd_link');
119remove_action('wp_head', 'wlwmanifest_link');
120remove_action('wp_head', 'wp_shortlink_wp_head');
121remove_action('wp_head', 'wp_oembed_add_discovery_links');
122remove_action('wp_head', 'wp_oembed_add_host_js');
123
124add_filter('posts_where', 'wpse18703_posts_where', 10, 2);
125function wpse18703_posts_where($where, $wp_query){
126 global $wpdb;
127 if ( $wpse18703_title = $wp_query->get( 'wpse18703_title' ) ) {
128 $where .= ' AND ' . $wpdb->posts . '.post_title LIKE \'%' . esc_sql( like_escape( $wpse18703_title ) ) . '%\'';
129 }
130 return $where;
131}
132function count_rating($post_id){
133 global $wpdb;
134 $consulta = $wpdb->get_results("SELECT SUM(rating_count) as contador_rating, COUNT(id) as contador_campos FROM ".$wpdb->prefix."ap_rating WHERE post_id='$post_id'", ARRAY_A);
135 $array = array();
136 if($consulta[0]['contador_campos'] != 0) {
137 $array['contador'] = round($consulta[0]['contador_rating'] / $consulta[0]['contador_campos'], 1);
138 $array['votos_totales'] = $consulta[0]['contador_campos'];
139 } else {
140 $array['contador'] = 0;
141 $array['votos_totales'] = 0;
142 }
143
144 return $array;
145}
146function user_no_voted(){
147 global $wpdb, $post;
148 $ip = $_SERVER['REMOTE_ADDR'];
149 $consulta = $wpdb->get_var("SELECT COUNT(ip) FROM ".$wpdb->prefix."ap_rating WHERE ip='$ip' AND post_id='{$post->ID}' AND date='".date('Y-m-d')."'");
150 if($consulta != 0){
151 return false;
152 }
153 return true;
154}
155function show_rating($calificar = 1){
156 global $post;
157 $count_rating = count_rating($post->ID); ?>
158 <div class="box-rating<?php if(wp_is_mobile()) echo " movil"; if(!user_no_voted() || $calificar == 0) echo " voted"; ?>" data-post-id="<?php echo $post->ID; ?>">
159 <span class="rating">
160 <?php
161 if($calificar == 1){ ?>
162 <span class="ratings-click" title="<?php echo ( !user_no_voted() ) ? __( 'Calificación', 'appyn' ).": ".$count_rating['contador']." ".__( 'estrellas', 'appyn' ): ''; ?>">
163 <span class="rating-click r1" data-count="1"></span>
164 <span class="rating-click r2" data-count="2"></span>
165 <span class="rating-click r3" data-count="3"></span>
166 <span class="rating-click r4" data-count="4"></span>
167 <span class="rating-click r5" data-count="5"></span>
168 </span>
169 <?php } ?><span class="stars" style="width:<?php echo $count_rating['contador'] * 10 * 2; ?>%"></span></span>
170 <?php
171 if($calificar == 1){ ?><span class="text-rating"><b><?php echo $count_rating['contador']; ?></b>/5</span>
172 <span class="rating-text"><?php
173 if($count_rating['votos_totales'] > 0) {
174 echo __( 'Votos', 'appyn' ).': '.$count_rating['votos_totales'];
175 } else {
176 echo __( 'No hay votos', 'appyn' );
177 } ?></span>
178 <?php } ?>
179 </div>
180<?php
181}
182add_action( 'after_switch_theme', 'default_options' );
183function default_options(){
184 $url = get_bloginfo('template_url');
185 $options = array(
186 'logo' => $url.'/images/logo.png',
187 'favicon' => $url.'/images/favicon.png',
188 'titulo_principal' => __( 'Theme Appyn para aplicaciones Android', 'appyn' ),
189 'descripcion_principal' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer fermentum erat ut massa venenatis, vitae ultrices sem dictum. Aliquam leo ipsum, bibendum nec dolor et.',
190 'image_header1' => $url.'/images/minecraft.png',
191 'image_header2' => $url.'/images/free-fire.png',
192 'image_header3' => $url.'/images/plantasvszombies2.png',
193 'social_facebook' => '#',
194 'social_twitter' => '#',
195 'social_google+' => '#',
196 'social_instagram' => '#',
197 'social_youtube' => '#',
198 'social_pinterest' => '#',
199 'footer_texto' => '© '.date('Y').' - '.__( 'Derechos reservados', 'appyn' ).' - <a href="https://themespixel.net/appyn/" target="_blank" rel="nofollow">Appyn Theme</a>',
200 'home_limite' => 12,
201 'categories_home_limite' => 6,
202 'blog_posts_limite' => 10,
203 'mas_calificadas_limite' => 5,
204 'blog_posts_home_limite' => 4,
205 'comments' => 'wp',
206 'readmore_single' => 0,
207 'color_theme_principal' => '1bbc9b',
208 'download_links' => 0,
209 );
210 foreach($options as $key => $value){
211 $getoption = get_option('appyn_'.$key);
212 if(empty($getoption)) {
213 update_option('appyn_'.$key, $value);
214 }
215 }
216}
217add_action( 'after_switch_theme', 'table_register' );
218function table_register(){
219 global $wpdb;
220 $table_name = $wpdb->prefix."ap_rating";
221 $sql = "CREATE TABLE IF NOT EXISTS " . $table_name . "(
222 id int(10) NOT NULL AUTO_INCREMENT,
223 post_id int(10) NOT NULL,
224 rating_count int(10) NOT NULL,
225 ip VARCHAR(100) NOT NULL,
226 date DATE NOT NULL,
227 PRIMARY KEY (id)
228 );";
229 $wpdb->query($sql);
230}
231add_action( 'add_meta_boxes', 'datos_meta_boxes' );
232function datos_meta_boxes(){
233 add_meta_box('datos_informacion', __( 'Información de la aplicación', 'appyn' ), 'callback_informacion', 'post', 'normal');
234 add_meta_box('datos_video', __( 'Video de la aplicación', 'appyn' ), 'callback_video', 'post', 'normal');
235 add_meta_box('datos_imagenes', __( 'Imágenes de la aplicación', 'appyn' ), 'callback_imagenes', 'post', 'normal');
236 add_meta_box('datos_download', __( 'Enlaces de descarga de la aplicación', 'appyn' ), 'datos_download', 'post', 'normal');
237 add_meta_box('custom_boxes', __( 'Cajas personalizadas', 'appyn' ), 'custom_boxes', 'post', 'normal');
238}
239function custom_boxes($post){
240 $custom_boxes = get_post_meta($post->ID, 'custom_boxes', true);
241 echo '<div id="boxes-content">';
242 if(!empty($custom_boxes)) {
243 foreach($custom_boxes as $box_key => $box_value) :
244 if( !empty( $box_value['title'] ) || !empty( $box_value['content'] ) ) { ?>
245 <div class="boxes-a">
246 <p><input type="text" id="custom_boxes-title" class="widefat" name="custom_boxes[<?php echo $box_key; ?>][title]" value="<?php echo $box_value['title']; ?>" placeholder="<?php echo __( 'Título para la caja', 'appyn' ); ?>"></p>
247
248 <p><?php wp_editor($box_value['content'], 'custom_boxes-'.$box_key, array('textarea_name' => 'custom_boxes['.$box_key.'][content]', 'textarea_rows' => 5)); ?></p>
249 <p><a href="javascript:void(0)" class="delete-boxes button"><?php echo __( 'Borrar caja', 'appyn' ); ?></a></p>
250 </div>
251 <?php } endforeach;
252 }
253 echo '</div>';
254 echo '<a href="javascript:void(0)" id="add-boxes" class="button">+ '.__( 'Añadir caja', 'appyn' ).'</a>'; ?>
255<?php
256}
257function callback_informacion($post){
258 $datos_informacion = get_post_meta($post->ID, 'datos_informacion', true);
259?>
260 <p><?php echo __( 'Descripción', 'appyn' ); ?>:<br>
261 <textarea class="widefat" name="datos_informacion[descripcion]" id="descripcion"><?php echo @$datos_informacion['descripcion']; ?></textarea>
262 <p><?php echo __( 'Versión', 'appyn' ); ?>:<br>
263 <input type="text" class="widefat" name="datos_informacion[version]" id="version" value="<?php echo strip_tags(@$datos_informacion['version']); ?>"></p>
264 <p><?php echo __( 'Tamaño', 'appyn' ); ?>:<br>
265 <input type="text" class="widefat" name="datos_informacion[tamano]" id="tamano" value="<?php echo strip_tags(@$datos_informacion['tamano']); ?>"></p>
266 <p><?php echo __( 'Última actualización', 'appyn' ); ?>:<br>
267 <input type="text" class="widefat" name="datos_informacion[fecha_actualizacion]" id="fecha_actualizacion" value="<?php echo strip_tags(@$datos_informacion['fecha_actualizacion']); ?>"></p>
268 <p><?php echo __( 'Requerimientos', 'appyn' ); ?>:<br>
269 <input type="text" class="widefat" name="datos_informacion[requerimientos]" id="requerimientos" value="<?php echo strip_tags(@$datos_informacion['requerimientos']); ?>"></p>
270 <p><?php echo __( 'Consíguelo en', 'appyn' ); ?>:<br>
271 <input type="text" class="widefat" name="datos_informacion[consiguelo]" id="consiguelo" value="<?php echo @$datos_informacion['consiguelo']; ?>"></p>
272 <p><?php echo __( 'Novedades', 'appyn' ); ?>:<br>
273 <?php wp_editor( @$datos_informacion['novedades'], 'novedades', array('textarea_name' => 'datos_informacion[novedades]', 'textarea_rows' => 5));
274 wp_nonce_field( plugin_basename( __FILE__ ), 'dynamicMeta_noncename' );
275}
276function callback_video($post){
277 $datos_video = get_post_meta($post->ID, 'datos_video', true);
278?>
279 <p>ID YouTube:<br>
280 <input type="text" class="widefat" id="id_video" name="datos_video[id]" placeholder="TkErUvyVlhA" value="<?php echo @$datos_video['id']; ?>"></p>
281 <?php
282 wp_nonce_field( plugin_basename( __FILE__ ), 'dynamicMeta_noncename' );
283}
284function callback_imagenes($post){
285 $datos_imagenes = get_post_meta($post->ID, 'datos_imagenes', true);
286 $datos_imagenes = !empty($datos_imagenes) ? $datos_imagenes : array();
287 $c = 4;
288 $input_upload = '<input class="upload_image_button button" type="button" value="'.__( 'Subir', 'appyn' ).'">';
289?>
290 <script>jq1 = jQuery.noConflict();
291 jq1(function($) {
292 var count = <?php echo $c; ?>;
293 $(document).on('click', '.removeimage', function(){
294 $(this).parents('p').remove();
295 count--;
296 });
297 $(".addImg").on('click', function(){
298 $(".ElementImagenes").append('<p><input type="text" name="datos_imagenes['+count+']" value="" class="regular-text upload"><?php echo @$input_upload; ?><a href="javascript:void(0)" class="removeimage">X</a></p>');
299 count++;
300 });
301 });</script>
302 <div class="ElementImagenes">
303 <div class="download"></div>
304 <?php
305 $n = 0;
306 if(count($datos_imagenes)>10){
307 foreach($datos_imagenes as $elemento) { ?>
308 <p><input type="text" name="datos_imagenes[<?php echo $n; ?>]" value="<?php echo (!empty($datos_imagenes[$n])) ? $datos_imagenes[$n] : ''; ?>" id="imagenes<?php echo $n; ?>" class="regular-text upload"><?php echo $input_upload; ?></p>
309 <?php $n++; } ?>
310 <?php } else {
311 for($i=0;$i<10;$i++): ?>
312 <p><input type="text" name="datos_imagenes[<?php echo $i; ?>]" value="<?php echo (!empty($datos_imagenes[$i])) ? $datos_imagenes[$i] : ''; ?>" id="imagenes<?php echo $i; ?>" class="regular-text upload"><?php echo $input_upload; ?></p>
313 <?php endfor; ?>
314 <?php } ?>
315 </div>
316 <p class="addImg button"><b>+ <?php echo __( 'Añadir imágenes', 'appyn' ); ?></b></p>
317
318<?php
319}
320function array_multi_filter_download_empty($var) {
321 if( is_array($var) ) {
322 $var = @array_filter($var);
323 return ($var & !empty($var));
324 } else {
325 return $var;
326 }
327}
328function array_filter_download_links($var) {
329 return (is_numeric($var));
330}
331function datos_download($post){
332 $datos_download = get_post_meta($post->ID, 'datos_download', true);
333 $c = 3;
334?>
335 <script type="text/javascript">
336 jq1 = jQuery.noConflict();
337 jq1(function($) {
338 var count = <?php echo $c; ?>;
339 $(document).on('click', '.removeLink', function(){
340 $(this).parents('tr').remove();
341 count--;
342 });
343 $(".addLink").on('click', function(){
344 $(".ElementLinks table tbody").append('<tr><td><input type="text" name="datos_download['+count+'][link]" value="" class="widefat"></td><td><input type="text" name="datos_download['+count+'][texto]" value="" class="widefat"></td><td><label><input type="checkbox" value="1" name="datos_download['+count+'][follow]"> Follow</label></td><td><a href="javascript:void(0)" class="removeLink button">x</a></td></tr>');
345 count++;
346 });
347
348 $('.dd-options li').on('click', function(){
349 var option = $(this).data('option');
350 $(this).parent().find('li').removeClass('active');
351 $(this).addClass('active');
352 $('.dd-content').hide();
353 $('.dd-content[data-option="'+option+'"]').show();
354 });
355 $('.dd-options li.active').find('input[type=radio]').prop("checked", true);
356 });
357 </script>
358 <?php
359 $datos_download_filter = @array_filter($datos_download, 'array_multi_filter_download_empty');
360 ?>
361 <div class="download-direct">
362 <ul class="dd-options">
363 <?php if(empty($datos_download_filter['option'])) { ?>
364 <li data-option="1" class="button active"><label><?php echo __( 'Enlaces de descarga', 'appyn' ); ?><input type="radio" name="datos_download[option]" value="links" style="display:none;"></label></li>
365 <li data-option="2" class="button"><label><?php echo __( 'Enlace directo / Redirección', 'appyn' ); ?><input type="radio" name="datos_download[option]" value="direct-link" style="display:none;"></label></li>
366 <li data-option="3" class="button"><label><?php echo __( 'Descarga directa', 'appyn' ); ?><input type="radio" name="datos_download[option]" value="direct-download" style="display:none;"></label></li>
367 <?php } else { ?>
368 <li data-option="1" class="button<?php echo (!$datos_download_filter['option'] || $datos_download_filter['option'] == "links") ? ' active': ''; ?>"><label><?php echo __( 'Enlaces de descarga', 'appyn' ); ?><input type="radio" name="datos_download[option]" value="links" style="display:none;"></label></li>
369 <li data-option="2" class="button<?php echo ($datos_download_filter['option'] == "direct-link") ? ' active': ''; ?>"><label><?php echo __( 'Enlace directo / Redirección', 'appyn' ); ?><input type="radio" name="datos_download[option]" value="direct-link" style="display:none;"></label></li>
370 <li data-option="3" class="button<?php echo ($datos_download_filter['option'] == "direct-download") ? ' active': ''; ?>"><label><?php echo __( 'Descarga directa', 'appyn' ); ?><input type="radio" name="datos_download[option]" value="direct-download" style="display:none;"></label></li>
371 <?php } ?>
372 </ul>
373 </div>
374 <p><em><?php echo __( 'Para eliminar un campo solo déjelo vacío', 'appyn' ); ?>.</em><br>
375 <em><?php echo __("Enlaces 'nofollow' por defecto", 'appyn'); ?>.</em></p>
376 <?php if(empty($datos_download_filter['option'])) { ?>
377 <div class="dd-content" data-option="1" style="display:block;">
378 <?php } elseif(!$datos_download_filter['option']) { ?>
379 <div class="dd-content" data-option="1" style="display:block;">
380 <?php } else { ?>
381 <div class="dd-content" data-option="1"<?php echo ($datos_download_filter['option'] == "links") ? ' style="display:block;"': ' style="display:none";'; ?>>
382 <?php } ?>
383 <div class="ElementLinks">
384 <table style="width:100%;">
385 <thead>
386 <tr style="text-align:left;">
387 <th style="width:60%;"><?php echo __( 'Enlace', 'appyn' ); ?></th>
388 <th><?php echo __( 'Texto', 'appyn' ); ?></th>
389 <th><?php echo __( 'Atributo', 'appyn' ); ?></th>
390 <th style="width:30px;"></th>
391 </tr>
392 </thead>
393 <tbody>
394 <?php
395 $n = 0;
396 $datos_download = !empty($datos_download) ? $datos_download : array();
397 $datos_download_default = array_filter($datos_download, 'array_filter_download_links', ARRAY_FILTER_USE_KEY);
398
399 if(count($datos_download_default)>0){ ?>
400 <?php
401 foreach($datos_download_default as $value => $elemento) {
402 if( !is_string($value) ) { ?>
403 <tr>
404 <td><input type="text" name="datos_download[<?php echo $n; ?>][link]" value="<?php echo $datos_download[$n]['link']; ?>" class="widefat"></td>
405 <td><input type="text" name="datos_download[<?php echo $n; ?>][texto]" value="<?php echo $datos_download[$n]['texto']; ?>" class="widefat"></td>
406 <td><label><input type="checkbox" value="1" name="datos_download[<?php echo $n; ?>][follow]" <?php checked(@$datos_download[$n]['follow'], '1'); ?>> Follow</label></td>
407 </tr>
408 <?php $n++; } } ?>
409 <?php } else {
410 for($i=0;$i<3;$i++): ?>
411 <tr>
412 <td><input type="text" name="datos_download[<?php echo $i; ?>][link]" value="<?php echo @$datos_download[$i]['link']; ?>" class="widefat"></td>
413 <td><input type="text" name="datos_download[<?php echo $i; ?>][texto]" value="<?php echo @$datos_download[$i]['texto']; ?>" class="widefat"></td>
414 <td><label><input type="checkbox" value="1" name="datos_download[<?php echo $i; ?>][follow]"> Follow</label></td>
415 </tr>
416 <?php endfor; ?>
417 <?php } ?>
418 </tbody>
419 </table>
420 </div>
421 <p class="addLink button"><b>+ <?php echo __( 'Añadir enlace', 'appyn' ); ?></b></p>
422 <p><a href="<?php bloginfo('url'); ?>/wp-admin/admin.php?page=appyn_documentation#links-download" target="_blank"><?php echo __( 'Ver en la documentación', 'appyn' ); ?></a></p>
423 </div>
424 <div class="dd-content" data-option="2"<?php echo (@$datos_download['option'] == "direct-link") ? ' style="display:block;"': ''; ?>>
425 <p><?php echo __( 'Enlace directo / Redirección', 'appyn' ); ?><br>
426 <input type="text" placeholder="Link" class="widefat" name="datos_download[direct-link]" value="<?php echo @$datos_download['direct-link']; ?>"></p>
427 </div>
428 <div class="dd-content" data-option="3"<?php echo (@$datos_download['option'] == "direct-download") ? ' style="display:block;"': ''; ?>>
429 <p><?php echo __( 'Descarga directa', 'appyn' ); ?><br>
430 <input type="text" placeholder="File link" name="datos_download[direct-download]" value="<?php echo @$datos_download['direct-download']; ?>" class="upload" style="width:500px;"><input class="upload_image_button button" type="button" value="<?php echo __( 'Subir', 'appyn' ); ?>"></p>
431 </div>
432<?php
433}
434add_action( 'save_post', 'cd_quote_meta_save' );
435function cd_quote_meta_save( $id ) {
436 if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
437
438 if(!wp_verify_nonce( @$_POST['dynamicMeta_noncename'], plugin_basename( __FILE__ ))){
439 return;
440 }
441 if( !current_user_can( 'edit_post', $id ) ) return;
442
443 $allowed = array(
444 'p' => array()
445 );
446
447 if($_POST['datos_informacion'])
448 update_post_meta($id, "datos_informacion", $_POST['datos_informacion']);
449 if($_POST['datos_video'])
450 update_post_meta($id, "datos_video", $_POST['datos_video']);
451 if($_POST['datos_imagenes'])
452 update_post_meta($id, "datos_imagenes", $_POST['datos_imagenes']);
453 if($_POST['datos_download'])
454 update_post_meta($id, "datos_download", $_POST['datos_download']);
455 if(isset($_POST['custom_boxes']))
456 update_post_meta($id, "custom_boxes", $_POST['custom_boxes']);
457}
458
459function catch_that_image() {
460 global $post, $posts;
461 $first_img = '';
462 ob_start();
463 ob_end_clean();
464 $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
465 $first_img = $matches[1][0];
466 return $first_img;
467}
468
469add_theme_support( 'nav-menus' );
470register_nav_menus(array('menu' => __('menu')));
471register_nav_menus(array('menu-mobile' => __('menu movil')));
472register_nav_menus(array('menu-footer' => __('menu footer')));
473
474
475register_sidebar(array(
476 'name' => 'sidebar',
477 'id' => 'sidebar-1',
478 'before_widget' => '<li id="%1$s" class="widget %2$s">',
479 'after_widget' => '</li>',
480 'before_title' => '<h2 class="widget-title">',
481 'after_title' => '</h2>',
482 )
483);
484register_sidebar(array(
485 'name' => 'footer',
486 'id' => 'sidebar-footer',
487 'before_widget' => '<li id="%1$s" class="widget %2$s">',
488 'after_widget' => '</li>',
489 'before_title' => '<h2 class="widget-title">',
490 'after_title' => '</h2>',
491));
492
493function excerpt($limit){
494 $excerpt = explode(' ', get_the_excerpt(), $limit);
495 if(count($excerpt)>=$limit) {
496 array_pop($excerpt);
497 $excerpt = implode(" ",$excerpt).'...';
498 } else {
499 $excerpt = implode(" ",$excerpt);
500 }
501 $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
502 return $excerpt;
503}
504function custom_excerpt_length($length) {
505 return 30;
506}
507add_filter('excerpt_length', 'custom_excerpt_length', 999);
508function new_excerpt_more($more) {
509 return '... <div class="readmore"><a href="'.get_permalink( get_the_ID() ).'" title="'.__( 'Seguir leyendo', 'appyn' ).'">'.__( 'Seguir leyendo', 'appyn' ).'</a></div>';
510}
511add_filter('excerpt_more', 'new_excerpt_more');
512add_theme_support( 'post-thumbnails' );
513
514function string_limit_words($string, $word_limit) {
515 $words = explode(' ', $string, ($word_limit + 1));
516 if(count($words) > $word_limit)
517 array_pop($words);
518 return implode(' ', $words);
519}
520
521if (function_exists( 'add_image_size') ) {
522 add_image_size('miniatura', 75, 75, true);
523 add_image_size('medio', 128, 128, true);
524}
525add_filter('image_size_names_choose', 'hmuda_image_sizes');
526function hmuda_image_sizes($sizes) {
527 $addsizes = array(
528 "minimo" => "Mínimo",
529 "medio" =>"Medio"
530 );
531 $newsizes = array_merge($sizes, $addsizes);
532 return $newsizes;
533}
534function getPostViews($postID) {
535 global $wpdb;
536 $table_name = $wpdb->prefix."views";
537 $count = $wpdb->get_var("SELECT total FROM $table_name WHERE post_id='$postID'");
538 return $count;
539}
540function setPostViews($postID) {
541 global $wpdb;
542 $table_name = $wpdb->prefix."views";
543 $sql = "CREATE TABLE IF NOT EXISTS " . $table_name . " (
544 id int(10) NOT NULL AUTO_INCREMENT,
545 post_id int(25) NOT NULL,
546 post_type VARCHAR(50) NOT NULL,
547 total int(11) NOT NULL,
548 PRIMARY KEY (id)
549 );";
550 $wpdb->query($sql);
551 $table_name_temp = $wpdb->prefix."views_temp";
552 $sql = "CREATE TABLE IF NOT EXISTS " . $table_name_temp . " (
553 id int(10) NOT NULL AUTO_INCREMENT,
554 post_id int(25) NOT NULL,
555 ip VARCHAR(20) NOT NULL,
556 fecha date NOT NULL,
557 PRIMARY KEY (id)
558 );";
559 $wpdb->query($sql);
560
561 $ip = $_SERVER['REMOTE_ADDR'];
562
563 $cc = $wpdb->get_var("SELECT COUNT(*)
564FROM information_schema.COLUMNS
565WHERE
566TABLE_SCHEMA = '".DB_NAME."'
567AND TABLE_NAME = '".$wpdb->prefix."views'
568AND COLUMN_NAME = 'ip'");
569 if($cc != 0){
570 $wpdb->query("ALTER TABLE ".$table_name." ADD COLUMN post_type VARCHAR(50) NOT NULL,
571 CHANGE `value` `total` INT(11) NOT NULL,
572 DROP COLUMN ip,
573 DROP COLUMN fecha");
574 }
575
576 $consulta_table_temp = $wpdb->get_var("SELECT fecha FROM ".$table_name_temp." LIMIT 1");
577 if($consulta_table_temp != date('Y-m-d')){
578 $consulta_table_temp = $wpdb->query("TRUNCATE TABLE ".$table_name_temp."");
579 }
580 $consulta = $wpdb->get_var("SELECT COUNT(*) FROM ".$table_name_temp." WHERE fecha='".date('Y-m-d')."' AND ip='$ip' AND post_id='$postID'" );
581 if($consulta==0){
582 $consulta_total = $wpdb->get_var("SELECT COUNT(*) FROM ".$table_name." WHERE post_id='$postID'");
583 if($consulta_total > 1) {
584 $wpdb->query("DELETE FROM $table_name WHERE post_id='$postID'");
585 $wpdb->insert($table_name, array(
586 'post_id' => $postID,
587 'post_type' => get_post_type($postID),
588 'total' => $consulta_total,
589 ));
590 }
591 $consulta_total = $wpdb->get_results("SELECT * FROM ".$table_name." WHERE post_id='$postID'", OBJECT);
592 if($consulta_total) {
593 $total = $consulta_total[0]->total;
594 $actualizar = $wpdb->update($table_name, array(
595 'post_type' => get_post_type($postID),
596 'total' => ($total + 1),
597 ), array(
598 'id' => $consulta_total[0]->id,
599 'post_id' => $postID,
600 ));
601 }
602 if(!isset($actualizar)){ // Registro nuevo
603 $wpdb->insert($table_name, array(
604 'post_id' => $postID,
605 'post_type' => get_post_type($postID),
606 'total' => 1,
607 ));
608 } else { // Borrar registros duplicados
609 $wpdb->query("DELETE FROM $table_name WHERE id!='".$consulta_total[0]->id."' AND post_id='$postID'");
610 }
611
612 // Registro nuevo temporal
613 $wpdb->insert($table_name_temp, array(
614 'post_id' => $postID,
615 'ip' => $ip,
616 'fecha' => date('Y-m-d')
617 ));
618 }
619}
620add_action( 'before_delete_post', 'deleteviews' );
621function deleteviews($postid){
622 global $wpdb;
623 $table_name = $wpdb->prefix."views";
624 $wpdb->get_var("DELETE FROM ".$table_name." WHERE post_id='$postid'");
625 $table_name = $wpdb->prefix."ap_rating";
626 $wpdb->get_var("DELETE FROM ".$table_name." WHERE post_id='$postid'");
627}
628if ( ! function_exists( 'px_comment_nav' ) ) :
629function px_comment_nav() {
630 if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) :
631 ?>
632 <nav class="navigation comment-navigation" role="navigation">
633 <h2 class="screen-reader-text"><?php echo __( 'Navegación de comentarios', 'appyn' ); ?></h2>
634 <div class="nav-links">
635 <?php
636 if ( $prev_link = get_previous_comments_link( __( 'Comentarios antiguos', 'appyn' ) ) ) :
637 printf( '<div class="nav-previous">%s</div>', $prev_link );
638 endif;
639
640 if ( $next_link = get_next_comments_link( __( 'Comentarios más nuevos', 'appyn' ) ) ) :
641 printf( '<div class="nav-next">%s</div>', $next_link );
642 endif;
643 ?>
644 </div><!-- .nav-links -->
645 </nav><!-- .comment-navigation -->
646 <?php
647 endif;
648}
649add_filter( 'comment_text', 'div_comment_content' );
650function div_comment_content( $comment_text ) {
651 $comment_text = '<div class="comment-content">'.wpautop($comment_text).'</div>';
652 return $comment_text;
653}
654endif;
655require_once(TEMPLATEPATH.'/functions/admin.php');
656require_once(TEMPLATEPATH.'/functions/widgets/ultimos_posts.php');
657require_once(TEMPLATEPATH.'/functions/widgets/mejor_calificados.php');
658require_once(TEMPLATEPATH.'/functions/widgets/mas_vistos.php');
659require_once(TEMPLATEPATH.'/functions/widgets/facebook.php');
660require_once(TEMPLATEPATH.'/functions/widgets/twitter.php');
661require_once(TEMPLATEPATH.'/functions/widgets/youtube.php');
662require_once(TEMPLATEPATH.'/functions/widgets/ultimos_posts_blog.php');
663require_once(TEMPLATEPATH.'/functions/widgets/mas_vistos_blog.php');
664require_once(TEMPLATEPATH.'/functions/widgets/mas_calificados.php');
665require_once(TEMPLATEPATH.'/functions/ajax.php');
666
667add_action( 'init', 'blog_register' );
668function blog_register(){
669 $labels = array(
670 'name' => 'Blog',
671 );
672 $args = array(
673 'exclude_from_search' => true,
674 'labels' => $labels,
675 'public' => true,
676 'publicly_queryable' => true,
677 'show_ui' => true,
678 'query_var' => true,
679 'rewrite' => array('slug' => 'blog', 'with_front' => false),
680 'has_archive' => true,
681 'capability_type' => 'post',
682 'hierarchical' => false,
683 'supports' => array('title','editor','thumbnail','comments'),
684 );
685 register_post_type('blog', $args );
686}
687
688function my_theme_setup(){
689 load_theme_textdomain('appyn', get_template_directory() . '/languages');
690}
691add_action( 'after_setup_theme', 'my_theme_setup' );
692
693function alter_table(){
694 global $wpdb;
695 $wpdb->query("ALTER TABLE {$wpdb->prefix}ap_rating CHANGE date date DATE NOT NULL");
696}
697add_action( 'init', 'alter_table');
698function lang_object_ids($object_id, $type) {
699 $current_language= apply_filters( 'wpml_current_language', NULL );
700 if( is_array( $object_id ) ){
701 $translated_object_ids = array();
702 foreach ( $object_id as $id ) {
703 $translated_object_ids[] = apply_filters( 'wpml_object_id', $id, $type, true, $current_language );
704 }
705 return $translated_object_ids;
706 } else {
707 return apply_filters( 'wpml_object_id', $object_id, $type, true, $current_language );
708 }
709}
710
711add_action( 'wp_head', 'add_head', 1 );
712function add_head() {
713 global $post;
714 $favicon = get_option( 'appyn_favicon' );
715 $favicon = ( !empty($favicon) ) ? $favicon: get_bloginfo('template_url').'/images/favicon.png';
716 echo '<link rel="shortcut icon" href="'.$favicon.'">';
717 if( wp_is_mobile() ) {
718 $styles = str_replace("url(images/", "url(".get_bloginfo('template_directory')."/images/",
719 file_get_contents(TEMPLATEPATH.'/style.min.css') );
720 echo '<style>'.$styles.'</style>';
721 }
722 $color_theme_principal = get_option( 'appyn_color_theme_principal' );
723 if($color_theme_principal){
724 echo '<meta name="theme-color" content="#'.$color_theme_principal.'">';
725 } else {
726 echo '<meta name="theme-color" content="#1d222d">';
727 }
728 echo "<script>
729 const loadFont = (url) => {
730 var xhr = new XMLHttpRequest();
731 xhr.open('GET', url, true);
732 xhr.onreadystatechange = () => {
733 if (xhr.readyState == 4 && xhr.status == 200) {
734 let css = xhr.responseText;
735 if( url.indexOf('googleapis') !== -1 ) {
736 css = css.replace(/}/g, 'font-display: swap; }');
737 }
738 const head = document.getElementsByTagName('head')[0];
739 const style = document.createElement('style');
740 style.appendChild(document.createTextNode(css));
741 head.appendChild(style);
742 }
743 };
744 xhr.send();
745 }
746 loadFont('https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700');
747 loadFont('".get_template_directory_uri()."/assets/css/font-awesome.min.css');
748 </script>";
749 $header_codigos = stripslashes(get_option('appyn_header_codigos'));
750 echo $header_codigos;
751 // Estructura de datos
752 if( is_single() ) {
753 $rating = count_rating($post->ID);
754 echo '<script type="application/ld+json">
755 {
756 "@context": "http://schema.org",
757 "@type": "SoftwareApplication",
758 "name": "'.get_the_title().'",
759 "operatingSystem": "ANDROID",
760 "applicationCategory": "http://schema.org/GameApplication",
761 "aggregateRating": {
762 "@type": "AggregateRating",
763 "ratingValue": "'.$rating['contador'].'",
764 "ratingCount": "'.$rating['votos_totales'].'"
765 },
766 "offers": {
767 "@type": "Offer",
768 "price": "0",
769 "priceCurrency": "0"
770 }
771 }
772 </script>';
773
774 $cat = get_the_category();
775 if( !empty($cat[0]) ) {
776 $pos = 1;
777 echo '<script type="application/ld+json">
778 {
779 "@context": "https://schema.org",
780 "@type": "BreadcrumbList",
781 "itemListElement": [';
782 if( $cat[0]->category_parent ) {
783 $cat_parent = get_term_by('id', $cat[0]->category_parent, 'category');
784 echo '{
785 "@type": "ListItem",
786 "position": '.$pos++.',
787 "name": "'.$cat_parent->name.'",
788 "item": "'.get_term_link($cat[0]->category_parent).'"
789 },';
790 }
791 echo '{
792 "@type": "ListItem",
793 "position": '.$pos++.',
794 "name": "'.$cat[0]->name.'",
795 "item": "'.get_term_link($cat[0]->term_id).'"
796 }';
797
798
799 echo ']
800 }
801 </script>';
802 }
803 }
804}
805add_action( 'wp_head', 'add_color_theme', 99 );
806function add_color_theme() {
807 global $post;
808 if( !is_amp_px() ) {
809 echo '<style>';
810 }
811 $css = '';
812 $sidebar_ubicacion = get_option( 'appyn_sidebar_ubicacion' );
813 if($sidebar_ubicacion == "izquierda"){
814 $css .= '
815 #sidebar {
816 float:left;
817 }
818 .aplication-single {
819 float:right;
820 }';
821 }
822 $color_theme = get_option( 'appyn_color_theme' );
823 $color_theme_principal = get_option( 'appyn_color_theme_principal' );
824 if($color_theme == "oscuro") {
825 $css .= '
826 body, .wrapper-inside {
827 color: #d8d2d2;
828 background: #1d222d;
829 }
830 table thead th,
831 #versiones table tbody > tr:nth-child(odd) td {
832 background: rgba(255,255,255,0.05);
833 }
834 table tbody td,
835 table tfoot td,
836 #versiones table tbody tr td {
837 background: rgba(255,255,255,0.02);
838 }
839 #versiones table thead tr th,
840 #versiones table tbody tr td {
841 background: transparent;
842 }
843 #header, #header menu .menu .sub-menu, #header menu .menu .sub-menu li a, footer {
844 background: #13161d;
845 }
846 #subheader {
847 border:0;
848 }
849 .section .title-section {
850 border-color:#323232;
851 }
852 table td, table th, .section .bloque-app .meta, .aplication-single .box h2.box-title, .aplication-single .box #reply-title, .aplication-page .box #reply-title, .section.blog .bloques li, .section.blog .title-section, .aplication-page .box h1.box-title, .box .comments-title, #versiones table thead tr th, #slideimages .item img {
853 border-color: #232834;
854 }
855 .section .bloque-app a, .section .bloque-app .meta, .section .bloque-app-second, .section a.more:hover,
856 #subheader.np #searchBox ul, .section .bloque-blog {
857 background: #282d3a;
858 }
859 table tr:nth-child(even), table tbody th {
860 background: #1f2430;
861 }
862 .section .bloque-app a,
863 .section .bloque-app-second {
864 box-shadow:2px 2px 2px 0px #1a1c1f;
865 }
866 .rating-loading {
867 background-color:rgba(0,0,0,0.5);
868 }
869 a, a:hover, .section .bloque-app-second .title,
870 .section .bloque-app .title, .section .bloque-app .developer,
871 .aplication-single h1.box-title, .botones_sociales.v2 a i,
872 .aplication-single #download.box ul li a,
873 #comments ol.comment-list .comment .comment-body > p,
874 .aplication-single .box h2.box-title, .aplication-single .box #reply-title, .aplication-page .box.box-title h1, .aplication-page .box h3 #reply-title,
875 #subheader.np #searchBox ul li a, .section.blog .bloques li a.title, .aplication-page .box h1.box-title, .section .bloque-blog a.title, .page-woocommerce, .page-woocommerce a, .page-woocommerce a:hover,
876 .aplication-single .bx-download, .aplication-single .bx-download .bxt, .box .comments-title, .box #reply-title, #breadcrumbs a:hover, #main-site .error404 h1, #main-site .error404 h2 {
877 color:#FFF;
878 }
879 .px-carousel-nav .px-prev i, .px-carousel-nav .px-next i {
880 color: #8a8a8a;
881 }
882 .entry, .section.blog .bloques li .excerpt, .aplication-single .entry,
883 .aplication-single .box .box-content {
884 color:#d4d4d4;
885 }
886 #comments ol.comment-list .comment .comment-body .reply a {
887 color:#1bbc9b;
888 }
889 .section .bloque-app-second .meta {
890 color: #78797c;
891 }
892 .aplication-single .box, #subheader.np, .section.blog, .aplication-page .box, .page-woocommerce {
893 background: #282d3a;
894 box-shadow: 2px 2px 2px 0px #1a1c1f;
895 }
896 .botones_sociales.v2 a, #comments textarea, #comments input[type=text], #comments input[type=email], #comments textarea {
897 background: #1d222d;
898 color: #FFF;
899 }
900 .pagination .page-numbers, .pagination .current, .section.blog .pagination .current, .section.blog .pagination .page-numbers {
901 color:#FFF;
902 background: rgba(0,0,0,0.3);
903 }
904 .botones_sociales a {
905 background: #222734;
906 color:#FFF;
907 }
908 .relacionados .bloque-app .title, .widget ul li .s2 .title, #comments ol.comment-list .comment .comment-body .comment-content p {
909 color:#bfbfbf;
910 }
911 .widget {
912 background:transparent;
913 box-shadow:none;
914 }
915 .widget .widget-title, .widget ul li a,
916 #slideimages .px-prev i, #slideimages .px-next i {
917 border-color: #282d3a;
918 }
919 .relacionados .bloque-app .developer, .widget ul li .s2 .developer, .section .bloque-app-second .developer, .section .bloque-app .developer, .section .bloque-app-second .app-date, .section .bloque-app .app-date, .widget ul li .s2 .app-date, .relacionados .bloque-app .app-date {
920 color: #7a7a7a;
921 }
922 .widget ul li:hover a::before {
923 background: #282d3a;
924 }
925 main .error404 {
926 color:#FFF;
927 }
928 main .error404 h1 {
929 text-shadow: 10px 10px 8px rgba(0,0,0,0.4);
930 }
931 .entry blockquote {
932 border-color: #4c5160;
933 }
934 .ratingBoxMovil .box-rating.movil {
935 background: #252935;
936 }
937 .link-report a {
938 color: #bfbfbf;
939 }
940 .link-report a:hover {
941 color: #FFF;
942 }
943 #box-report > div {
944 color: #4c4c4c;
945 }
946 .entry .wp-caption {
947 background: rgba(0,0,0,0.1);
948 }
949 .aplication-single .entry.limit::before {
950 background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(40,45,58,1) 100%);
951 background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(40,45,58,1) 100%);
952 background: linear-gradient(to bottom, rgba(255,255,255,0) 0%,rgba(40,45,58,1) 100%);
953 filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\'#00ffffff\', endColorstr=\'#282d3a\',GradientType=0 );
954 }
955 /*Woocommerce*/
956 .select2-container {
957 color:#000;
958 }
959 .woocommerce div.product .woocommerce-tabs ul.tabs::before,
960 .woocommerce div.product .woocommerce-tabs ul.tabs li,
961 .woocommerce div.product .woocommerce-tabs ul.tabs li.active,
962 .woocommerce #reviews #comments ol.commentlist li .comment-text,
963 #add_payment_method #payment ul.payment_methods,
964 .woocommerce-cart #payment ul.payment_methods,
965 .woocommerce-checkout #payment ul.payment_methods,
966 .page-woocommerce .woocommerce ul.order_details li,
967 #add_payment_method .cart-collaterals .cart_totals tr td,
968 #add_payment_method .cart-collaterals .cart_totals tr th,
969 .woocommerce-cart .cart-collaterals .cart_totals tr td,
970 .woocommerce-cart .cart-collaterals .cart_totals tr th,
971 .woocommerce-checkout .cart-collaterals .cart_totals tr td,
972 .woocommerce-checkout .cart-collaterals .cart_totals tr th {
973 border-color: rgba(255,255,255,0.1);
974 }
975 #subheader.np #searchBox ul li a:hover,
976 .woocommerce div.product .woocommerce-tabs ul.tabs li,
977 .woocommerce div.product .woocommerce-tabs ul.tabs li.active,
978 #add_payment_method #payment,
979 .woocommerce-cart #payment,
980 .woocommerce-checkout #payment,
981 .page-woocommerce .order_details,
982 fieldset {
983 background: rgba(255,255,255,0.1);
984 }
985 .woocommerce div.product .woocommerce-tabs ul.tabs li.active, fieldset legend {
986 background: #282d3a;
987 }
988 .woocommerce div.product .woocommerce-tabs ul.tabs li a {
989 color: rgba(255,255,255,0.3);
990 }
991 /**/
992 @media screen and (max-width:500px){
993 .botones_sociales li {
994 border:none;
995 }
996 }
997 @media screen and (max-width:450px){
998 .aplication-single .box-data-app {
999 background:#1d222d;
1000 }
1001 .aplication-single .data-app span {
1002 border-top-color:#282d3a;
1003 }
1004 }';
1005 }
1006 if( $color_theme_principal ) {
1007 $css .= '
1008 html #header nav .menu > li.menu-item-has-children > .sub-menu::before,
1009 html .section .bloque-app a::after,
1010 html .section .bloque-blog a.title:hover,
1011 html .section.blog .bloques li a.title:hover,
1012 html .aplication-single .box .entry a,
1013 html .aplication-single .box .box-content a,
1014 html .aplication-page .box .entry a,
1015 html .aplication-single #download.box ul li,
1016 html .aplication-single #download.box ul li a:hover,
1017 html .aplication-single .text-rating b,
1018 html .ratingBoxMovil .text-rating b,
1019 html .relacionados .bloque-app a:hover .title,
1020 html #comments ol.comment-list .comment .comment-body .reply a,
1021 html .aplication-single .data-app span a,
1022 html .section .bloque-app-second .title:hover {
1023 color: #'.$color_theme_principal.';
1024 }';
1025 $css .= '
1026 html #header nav ul li.current-menu-item a,
1027 html #header nav .menu > li > a::before,
1028 html #header nav .menu > li.beforeactive > a::before,
1029 html #menu-mobile ul li a:hover,
1030 html body.nav_res #header nav ul.menu.active li a:hover,
1031 html body.nav_res #header nav ul.menu.active li a:hover i::before,
1032 html #subheader #searchBox form button,
1033 html #subheader.np #searchBox form button, #subheader .np .social li a,
1034 html .pagination .page-numbers.current,
1035 html .pagination a.page-numbers:hover,
1036 html .section.blog .pagination .page-numbers.current,
1037 html .section.blog .pagination a.page-numbers:hover,
1038 html .section.blog .bloques li .excerpt .readmore a,
1039 html .section a.more,
1040 html .aplication-single .s2 .categories a,
1041 html .aplication-single .downloadAPK,
1042 html .aplication-single .readmore,
1043 html .aplication-single .etiquetas a,
1044 html .aplication-single .box h2.box-title::after,
1045 html .aplication-single .box h3.box-title::after,
1046 html .aplication-page .box h1.box-title::after,
1047 html h1.box-title::after,
1048 html .box #reply-title::after,
1049 html .box .comments-title::after,
1050 html #slideimages .si-prev i,
1051 html #slideimages .si-next i,
1052 html #comments input[type=submit],
1053 html .widget.widget_tag_cloud a,
1054 html main .error404 form button,
1055 html .ratingBoxMovil button,
1056 html .aplication-single .bx-download ul li,
1057 html #slideimages .px-prev i,
1058 html #slideimages .px-next i,
1059 html .section.blog .pagination .current,
1060 html .section.blog .pagination a:hover,
1061 html #box-report input[type=submit],
1062 #main-site .error404 form button {
1063 background: #'.$color_theme_principal.';
1064 }
1065 html ::-webkit-scrollbar-thumb {
1066 background: #'.$color_theme_principal.';
1067 }';
1068 $css .= '
1069 html #header,
1070 html #header nav .menu > li.menu-item-has-children > .sub-menu::before,
1071 html #subheader,
1072 html .section .bloque-app a::before,
1073 html .section .bloque-app-second,
1074 html #footer {
1075 border-color: #'.$color_theme_principal.';
1076 }';
1077 }
1078 $css = str_replace(array("\n", "\r", "\t", " "), "", $css);
1079 echo $css;
1080 if( !is_amp_px() ) {
1081 echo '</style>';
1082 }
1083}
1084function theme_scripts() {
1085 if( !wp_is_mobile() ) {
1086 wp_enqueue_style( 'style', get_bloginfo("template_directory").'/style.min.css', false, VERSIONPX, 'all' );
1087 }
1088 wp_deregister_script( 'jquery' );
1089 wp_register_script( 'jquery', includes_url( '/js/jquery/jquery.js' ), false, NULL, true );
1090 wp_enqueue_script( 'jquery' );
1091
1092 wp_enqueue_script( 'px-js', get_bloginfo("template_directory").'/assets/js/js.min.js', false, VERSIONPX, true );
1093
1094 if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
1095 wp_enqueue_script( 'comment-reply' );
1096 }
1097}
1098add_action( 'wp_enqueue_scripts', 'theme_scripts' );
1099
1100function style_script_footer() {
1101 $readmore_single = stripslashes(get_option( 'appyn_readmore_single' ));
1102 $footer_codigos = stripslashes(get_option( 'appyn_footer_codigos' ));
1103 echo $footer_codigos.'
1104 <script>';
1105 if( $readmore_single == 1 ) {
1106 echo 'var text_ = false;';
1107 } else {
1108 echo 'var text_ = true;';
1109 }
1110 echo '
1111 var ajaxurl = "' . admin_url('admin-ajax.php') . '";
1112 var text_votar = "'.__( 'Votar', 'appyn' ).'";
1113 var text_votos = "'.__( 'Votos', 'appyn' ).'";
1114 var text_leer_mas = "'.__( 'Leer más', 'appyn' ).'";
1115 var text_leer_menos = "'.__( 'Leer menos', 'appyn' ).'";
1116 var text_de = "'.__( 'de', 'appyn' ).'";
1117 var text_reporte_gracias = "'.__( 'Gracias por enviarnos su reporte.', 'appyn' ).'"';
1118 echo "
1119 </script>";
1120}
1121add_action( 'wp_footer', 'style_script_footer' );
1122
1123function add_footer() {
1124 $recaptcha_site = get_option( 'appyn_recaptcha_site' );
1125 $recaptcha_secret = get_option( 'appyn_recaptcha_secret' );
1126 if( $recaptcha_site && $recaptcha_secret ) {
1127 ?>
1128 <script>
1129 (function($) {
1130 $(document).on('click', '.link-report > a', function(){
1131 var head = document.getElementsByTagName('head')[0];
1132 var script = document.createElement('script');
1133 script.type = 'text/javascript';
1134 script.src = 'https://www.google.com/recaptcha/api.js?render=<?php echo $recaptcha_site; ?>';
1135 head.appendChild(script);
1136 script.onreadystatechange = function() {
1137 if ( script.readyState === "loaded" || script.readyState === "complete" ) {
1138 script.onreadystatechange = null;
1139 grecaptcha.ready(function() {
1140 grecaptcha.execute('<?php echo $recaptcha_site; ?>', {action: 'recaptcha_reports'})
1141 .then(function(token) {
1142 $('#box-report form').append('<input type="hidden" name="token" value="'+token+'">');
1143 $('#box-report form').append('<input type="hidden" name="action" value="recaptcha_reports">');
1144 });
1145 });
1146 }
1147 }
1148 });
1149 })(jQuery);
1150 </script>
1151 <?php }
1152}
1153add_action( 'wp_footer', 'add_footer', 9999 );
1154
1155function paginador($query = false, $num = false, $args = null) {
1156 if( !empty($query) ) {
1157 $numposts = $query->found_posts;
1158 $max_page = $query->max_num_pages;
1159 $posts_per_page = intval($num);
1160 } else {
1161 global $wp_query;
1162 $max_page = $wp_query->max_num_pages;
1163 }
1164
1165 $big = 999999999;
1166
1167 $pages = paginate_links( array(
1168 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
1169 'format' => '?paged=%#%',
1170 'current' => max( 1, get_query_var('paged') ),
1171 'total' => $max_page,
1172 'type' => 'array',
1173 ) );
1174 if( is_array( $pages ) ) {
1175 $paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
1176 echo '<div class="pagination-wrap"><ul class="pagination">';
1177 foreach ( $pages as $page ) {
1178 echo "<li>".str_replace('page-numbers dots', 'dots', $page)."</li>";
1179 }
1180 echo '</ul></div>';
1181 }
1182}
1183
1184
1185function function_pregetposts($query) {
1186 if ( !is_admin() && $query->is_main_query() ) {
1187 if( $query->is_post_type_archive('blog') ) {
1188 $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
1189 $blog_posts_limite = get_option( 'appyn_blog_posts_limite' );
1190 $blog_posts_limite = (empty($blog_posts_limite)) ? '10' : $blog_posts_limite;
1191 $query->set('post_type', 'blog');
1192 $query->set('posts_per_page', $blog_posts_limite);
1193 $query->set('paged', $paged);
1194 }
1195 if( $query->is_search() ) {
1196 $query->set('post_type', 'post');
1197 if( get_option( 'appyn_versiones_mostrar_buscador') == 1 ) {
1198 $query->set('post_parent', 0);
1199 }
1200 }
1201 if( $query->is_tax('dev') ) {
1202 if( get_option( 'appyn_versiones_mostrar_tax_desarrollador') == 1 ) {
1203 $query->set('post_parent', 0);
1204 }
1205 }
1206 if( $query->is_category() ) {
1207 if( get_option( 'appyn_versiones_mostrar_categorias') == 1 ) {
1208 $query->set('post_parent', 0);
1209 }
1210 }
1211 if( $query->is_tag() ) {
1212 if( get_option( 'appyn_versiones_mostrar_tags') == 1 ) {
1213 $query->set('post_parent', 0);
1214 }
1215 }
1216 }
1217 if(is_admin()){
1218 $query->set('orderby', '');
1219 $query->set('order', '');
1220 }
1221}
1222add_action( 'pre_get_posts', 'function_pregetposts' );
1223
1224function px_social($social) {
1225 if( $social == "facebook" ){
1226 $option = get_option( 'appyn_social_facebook' );
1227 }
1228 elseif( $social == "twitter" ){
1229 $option = get_option( 'appyn_social_twitter' );
1230 }
1231 elseif( $social == "google+" ){
1232 $option = get_option( 'appyn_social_google+' );
1233 }
1234 elseif( $social == "instagram" ){
1235 $option = get_option( 'appyn_social_instagram' );
1236 }
1237 elseif( $social == "youtube" ){
1238 $option = get_option( 'appyn_social_youtube' );
1239 }
1240 elseif( $social == "pinterest" ){
1241 $option = get_option( 'appyn_social_pinterest' );
1242 }
1243 return $option;
1244}
1245function load_template_part($template_name, $part_name=null) {
1246 ob_start();
1247 get_template_part($template_name, $part_name);
1248 $var = ob_get_contents();
1249 ob_end_clean();
1250 return $var;
1251}
1252
1253function add_query_vars_filter( $vars ){
1254 $vars[] = "download";
1255 return $vars;
1256}
1257add_filter( 'query_vars', 'add_query_vars_filter' );
1258
1259define('ALLOW_UNFILTERED_UPLOADS', true);
1260
1261function download_opts() {
1262 if( !is_single() ) return;
1263
1264 global $post;
1265 $download_links = get_option( 'appyn_download_links' );
1266 $redirect_timer = ( get_option( 'appyn_redirect_timer' ) ) ? get_option( 'appyn_redirect_timer' ) : 5;
1267 $get_download = get_query_var( 'download', null );
1268 $datos_download = get_post_meta($post->ID, 'datos_download', true);
1269 if( $download_links == 1 ) {
1270 $error_script = "<script>function alert_download() { alert('".__( 'No hay archivo para descargar.', 'appyn' )."'); }</script>";
1271 if( $get_download == "redirect" ) {
1272 if( strlen($datos_download['direct-link']) > 0 ) {
1273 echo '<meta http-equiv="refresh" content="'.$redirect_timer.';url='.$datos_download['direct-link'].'">';
1274 } else {
1275 echo $error_script;
1276 }
1277 }
1278 elseif( $get_download == "true" ) {
1279 if( strlen($datos_download['direct-download']) > 0 ) {
1280 echo '<meta http-equiv="refresh" content="'.$redirect_timer.';url='.esc_url( add_query_arg( 'download', 'file' ) ).'">';
1281 } else {
1282 echo $error_script;
1283 }
1284 }
1285 }
1286}
1287add_action( 'wp_head', 'download_opts' );
1288function download_file(){
1289 if( !is_single() ) return;
1290 global $post;
1291 $get_download = get_query_var( 'download', null );
1292
1293 if( $get_download == "file") {
1294 $post_id = $post->ID;
1295 $datos_download = get_post_meta($post_id, 'datos_download', true);
1296 $url = $datos_download['direct-download'];
1297 require_once(ABSPATH . "wp-admin" . '/includes/image.php');
1298 require_once(ABSPATH . "wp-admin" . '/includes/file.php');
1299 require_once(ABSPATH . "wp-admin" . '/includes/media.php');
1300 $temp_file = download_url( $url );
1301 header("Pragma: public");
1302 header("Expires: 0");
1303 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
1304 header("Content-Type: application/octet-stream");
1305 header("Content-Disposition: attachment; filename=".basename($url)."");
1306 readfile($temp_file);
1307 exit();
1308 }
1309}
1310add_action( 'template_redirect', 'download_file' );
1311
1312function dev_taxonomy_register() {
1313 register_taxonomy(
1314 'dev',
1315 'post',
1316 array(
1317 'label' => __( 'Desarrollador', 'appyn' ),
1318 'sort' => true,
1319 'args' => array('orderby' => 'term_order'),
1320 'show_in_rest' => true,
1321 'rewrite' => array('slug' => 'dev'),
1322 'labels' => array('menu_name' => __( 'Desarrollador', 'appyn' ))
1323 )
1324 );
1325}
1326add_action('init', 'dev_taxonomy_register', 30);
1327
1328function options_report($i) {
1329 if( $i == 1 ) {
1330 return __("No funcionan los enlaces de descarga", "appyn");
1331 } elseif( $i == 2 ) {
1332 return __("Hay una nueva versión", "appyn");
1333 } else {
1334 return __("Otros", "appyn");
1335 }
1336}
1337add_action('registered_post_type', 'igy2411_make_posts_hierarchical', 10, 2 );
1338
1339function igy2411_make_posts_hierarchical($post_type, $pto){
1340 if ($post_type != 'post') return;
1341 global $wp_post_types;
1342 $wp_post_types['post']->hierarchical = 1;
1343 add_post_type_support( 'post', 'page-attributes' );
1344}
1345
1346function analytics_rewrite_add_var( $vars ) {
1347 $vars[] = 'section';
1348 return $vars;
1349}
1350add_filter( 'query_vars', 'analytics_rewrite_add_var');
1351function add_analytic_rewrite_rule() {
1352 add_rewrite_rule(
1353 '^(.*?)([^/]*)/'.__( 'versiones', 'appyn' ).'/?$',
1354 'index.php?name=$matches[2]§ion='.__( 'versiones', 'appyn' ).'',
1355 'top'
1356 );
1357}
1358add_action( 'init', 'add_analytic_rewrite_rule' );
1359
1360function rr_404_versiones() {
1361 global $post;
1362 if ( get_query_var('section') == __( 'versiones', 'appyn' ) && $post->post_parent ) {
1363 global $wp_query;
1364 $wp_query->set_404();
1365 status_header(404);
1366 }
1367}
1368add_action( 'wp', 'rr_404_versiones' );
1369
1370function px_the_content() {
1371 global $post;
1372 $content = get_the_content();
1373 $content = apply_filters('the_content', $content);
1374 $content = str_replace(']]>', ']]>', $content);
1375 echo px_content_filter($content);
1376}
1377function caja_descripcion() {
1378 global $post, $cvn;
1379 $datos_informacion = get_post_meta($post->ID, 'datos_informacion', true);
1380 if( ( $post->post_parent == 0 || !in_array( 'descripcion', $cvn ) ) ) { ?>
1381 <div id="descripcion" class="box">
1382 <h2 class="box-title"><?php echo __( 'Descripción', 'appyn' ); ?></h2>
1383 <div class="entry">
1384 <div class="entry-limit">
1385 <?php px_the_content(); ?>
1386 </div>
1387 </div>
1388 </div>
1389<?php
1390 }
1391}
1392function caja_novedades() {
1393 global $post, $cvn;
1394 $datos_informacion = get_post_meta($post->ID, 'datos_informacion', true);
1395 if( ( $post->post_parent == 0 && !empty($datos_informacion['novedades']) ) || ( !in_array( 'novedades', $cvn ) && !empty($datos_informacion['novedades']) ) ) { ?>
1396 <div id="novedades" class="box">
1397 <h2 class="box-title"><?php echo __( 'Novedades', 'appyn' ); ?></h2>
1398 <div class="box-content">
1399 <?php echo wpautop( $datos_informacion['novedades'] ); ?>
1400 </div>
1401 </div>
1402 <?php
1403 }
1404}
1405function caja_versiones() {
1406 global $wp_query, $wpdb, $post;
1407 //if( $post->post_parent != 0 ) return;
1408
1409 $versiones_cantidad_post = ( get_option( 'appyn_versiones_cantidad_post' ) ) ? get_option( 'appyn_versiones_cantidad_post' ) : 5;
1410 $args = array(
1411 'post_parent' => $post->ID,
1412 'posts_per_page' => $versiones_cantidad_post
1413 );
1414 if( $post->post_parent != 0 ) {
1415 $args['post_parent'] = $post->post_parent;
1416 $args['post__not_in'] = array($post->ID);
1417 $post_add = get_post($post->post_parent);
1418 }
1419 $versiones = new WP_Query( $args );
1420 if( $versiones->have_posts() || isset($post_add) ) :
1421 ?>
1422 <div id="versiones" class="box">
1423 <h2 class="box-title"><?php echo __( 'Versiones', 'appyn' ); ?></h2>
1424 <div class="box-content">
1425 <table>
1426 <thead>
1427 <tr>
1428 <th><?php echo __( 'Versión', 'appyn' ); ?></th>
1429 <th><?php echo __( 'Peso', 'appyn' ); ?></th>
1430 <th><?php echo __( 'Requerimientos', 'appyn' ); ?></th>
1431 <th style="width:100px"><?php echo __( 'Fecha', 'appyn' ); ?></th>
1432 </tr>
1433 </thead>
1434 <tbody>
1435 <?php
1436 $date_change = array(
1437 'enero' => '01',
1438 'febrero' => '02',
1439 'marzo' => '03',
1440 'abril' => '04',
1441 'mayo' => '05',
1442 'junio' => '06',
1443 'julio' => '07',
1444 'agosto' => '08',
1445 'setiembre' => '09',
1446 'octubre' => '10',
1447 'noviembre' => '11',
1448 'diciembre' => '12',
1449 ' de ' => '-',
1450 );
1451 if( $post->post_parent != 0 ) {
1452 $inf = get_post_meta( $post_add->ID, 'datos_informacion', true );
1453 if( is_array($inf) ) {
1454 echo '<tr>
1455 <td><a href="'.get_permalink($post_add->ID).'">'.$post_add->ID.' - '.(( !empty($inf['version']) ) ? $inf['version'] : '-').'</a></td>
1456 <td>'.(( !empty($inf['tamano']) ) ? $inf['tamano'] : '-').'</td>
1457 <td>'.(( !empty($inf['requerimientos']) ) ? $inf['requerimientos'] : '-').'</td>
1458 <td>'.(( !empty($inf['fecha_actualizacion']) ) ? date_i18n( 'd/m/Y', strtotime(strtr($inf['fecha_actualizacion'], $date_change)) ) : '-').'</td>
1459 </tr>';
1460 }
1461 }
1462
1463 while( $versiones->have_posts() ) : $versiones->the_post();
1464 $inf = get_post_meta( $post->ID, 'datos_informacion', true );
1465 if( is_array($inf) ) {
1466 echo '<tr>
1467 <td><a href="'.get_permalink($post->ID).'">'.$post->ID.' - '.(( !empty($inf['version']) ) ? $inf['version'] : '-').'</a></td>
1468 <td>'.(( !empty($inf['tamano']) ) ? $inf['tamano'] : '-').'</td>
1469 <td>'.(( !empty($inf['requerimientos']) ) ? $inf['requerimientos'] : '-').'</td>
1470 <td>'.(( !empty($inf['fecha_actualizacion']) ) ? date_i18n( 'd/m/Y', strtotime(strtr($inf['fecha_actualizacion'], $date_change)) ) : '-').'</td>
1471 </tr>';
1472 }
1473 endwhile; wp_reset_query(); ?>
1474 </tbody>
1475 </table>
1476 </div>
1477 <?php
1478 if( $versiones->found_posts > $versiones_cantidad_post ) { ?>
1479 <a href="<?php the_permalink(); ?><?php echo __( 'versiones', 'appyn' ); ?>/" class="readmore"><?php echo __( 'Ver más versiones', 'appyn' ); ?></a>
1480 <?php } ?>
1481 </div>
1482 <?php endif; wp_reset_query();
1483}
1484
1485function caja_video() {
1486 global $post,$cvn,$datos_video;
1487 $datos_video = get_post_meta($post->ID, 'datos_video', true);
1488 if( ( $post->post_parent == 0 && !empty($datos_video['id']) ) || (!in_array( 'video', $cvn ) && !empty($datos_video['id']) ) ) {?>
1489 <div class="box">
1490 <h2 class="box-title"><?php echo __( 'Video', 'appyn' ); ?></h2>
1491 <div class="iframeBoxVideo" data-id="<?php echo $datos_video['id']; ?>">
1492 <?php
1493 if( is_amp_px() ) {
1494 echo '<amp-youtube data-videoid="'.$datos_video['id'].'" layout="responsive" width="560" height="315"></amp-youtube>';
1495 } else {
1496 $appyn_lazy_loading = ( get_option('appyn_lazy_loading') ) ? get_option('appyn_lazy_loading') : NULL;
1497 if( $appyn_lazy_loading == 1 ) {
1498 ?>
1499 <iframe width="730" height="360" src="<?php echo get_template_directory_uri(); ?>/admin/index.php" data-src="https://www.youtube.com/embed/<?php echo $datos_video['id']; ?>" style="border:0; overflow:hidden;" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen class="lazyload"></iframe>
1500 <?php } else { ?>
1501 <iframe width="730" height="360" src="https://www.youtube.com/embed/<?php echo $datos_video['id']; ?>" style="border:0; overflow:hidden;" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
1502 <?php }
1503 } ?>
1504 </div>
1505 </div>
1506 <?php
1507 }
1508}
1509
1510function caja_imagenes() {
1511 global $post,$cvn;
1512
1513 $datos_imagenes = get_post_meta($post->ID, 'datos_imagenes', true);
1514 if( ( $post->post_parent == 0 && !empty($datos_imagenes ) ) || (!in_array( 'imagenes', $cvn ) && !empty($datos_imagenes ) ) ) {
1515
1516 $datos_imagenes = @array_map('trim', $datos_imagenes);
1517 $datos_imagenes = @array_filter($datos_imagenes, create_function('$a','return $a!=="";'));
1518 if(count($datos_imagenes)>0) { ?>
1519 <div class="box imagenes">
1520 <h2 class="box-title"><?php echo __( 'Imágenes', 'appyn' ); ?></h2>
1521 <div id="slideimages" class="px-carousel" data-title="<?php the_title(); ?>">
1522 <?php
1523 if( is_amp_px() ) { ?>
1524 <amp-carousel height="300" controls layout="fixed-height" type="slides">
1525 <?php
1526 $i = 0;
1527 foreach($datos_imagenes as $imagen) {
1528 if(strpos($imagen, 'googleusercontent.com') !== false || strpos($imagen, 'ggpht.com') !== false) {
1529 $last_pos = strrpos($imagen, '=');
1530 $imagen= substr($imagen, 0, $last_pos)."=h305";
1531 $imagen_big = substr($imagen, 0, $last_pos)."=h650";
1532 } else {
1533 $imagen_id = get_image_id($imagen);
1534 if(empty($imagen_id)){
1535 $imagen_big = $imagen;
1536 $imagen = $imagen;
1537 } else {
1538 $imagen_big = $imagen;
1539 $imagen = wp_get_attachment_image_src($imagen_id, 'medium');
1540 $imagen = $imagen[0];
1541 }
1542 }
1543 ?>
1544 <amp-img src="<?php echo $imagen; ?>" layout="fill"
1545 height="300"
1546 alt="a sample image"></amp-img>
1547 <?php } ?>
1548 </amp-carousel>
1549 <?php
1550 } else { ?>
1551 <div class="px-carousel-nav disabled"><button type="button" role="presentation" class="px-prev disabled"><i class="fa fa-angle-left" aria-hidden="true"></i></button><button type="button" role="presentation" class="px-next disabled"><i class="fa fa-angle-right" aria-hidden="true"></i></button></div>
1552 <div class="px-carousel-wrapper">
1553 <div class="px-carousel-container">
1554 <?php $i = 0;
1555 foreach($datos_imagenes as $imagen) {
1556 if(strpos($imagen, 'googleusercontent.com') !== false || strpos($imagen, 'ggpht.com') !== false) {
1557 $last_pos = strrpos($imagen, '=');
1558 $imagen= substr($imagen, 0, $last_pos)."=h305";
1559 $imagen_big = substr($imagen, 0, $last_pos)."=h650";
1560 } else {
1561 $imagen_id = get_image_id($imagen);
1562 if(empty($imagen_id)){
1563 $imagen_big = $imagen;
1564 $imagen = $imagen;
1565 } else {
1566 $imagen_big = $imagen;
1567 $imagen = wp_get_attachment_image_src($imagen_id, 'medium');
1568 $imagen = $imagen[0];
1569 }
1570 }
1571 $appyn_lazy_loading = ( get_option('appyn_lazy_loading') ) ? get_option('appyn_lazy_loading') : NULL;
1572 if( $appyn_lazy_loading == 1 ) {
1573 $image_blank = get_template_directory_uri().'/images/blank.png';
1574 $color_theme = get_option( 'appyn_color_theme' );
1575 $color_theme_principal = get_option( 'appyn_color_theme_principal' );
1576 if($color_theme == "oscuro") {
1577 $image_blank = get_template_directory_uri().'/images/blank-d.png';
1578 }
1579 echo '<div class="px-carousel-item"><img class="lazyload" src="'.$image_blank.'" data-src="'.$imagen.'" data-big-src="'.$imagen_big.'" alt="'.get_the_title().' '.($i + 1).'"></div>';
1580 } else {
1581 echo '<div class="px-carousel-item"><img src="'.$imagen.'" data-big-src="'.$imagen_big.'" alt="'.get_the_title().' '.($i + 1).'"></div>';
1582 }
1583 $i++;
1584 }
1585 ?>
1586 </div>
1587 </div>
1588 <?php } ?>
1589 </div>
1590 </div>
1591 <?php }
1592 }
1593}
1594
1595function caja_enlaces_descarga() {
1596 global $post, $cvn, $datos_download;
1597 $option_download = get_option( 'appyn_download_links' );
1598 $datos_download = get_datos_download($post->ID);
1599 if( !empty($datos_download['option']) && $option_download != 1) {
1600 unset($datos_download['direct-download'], $datos_download['direct-link'] );
1601 if( !empty($datos_download) && $datos_download['option'] == "links" ) {
1602 ?>
1603 <div id="download" class="box">
1604 <h2 class="box-title"><?php echo __( 'Enlaces de descarga', 'appyn' ); ?></h2>
1605 <ul>
1606 <?php
1607 foreach( $datos_download as $val ) :
1608 if( empty($val['texto']) || empty($val['link']) ) continue;
1609 ?>
1610 <a href="<?php echo $val['link']; ?>" target="_blank" class="downloadAPK"><i class="fa fa-download"></i> <?php echo $val['texto']; ?></a>
1611 <?php endforeach; ?>
1612 </ul>
1613 <center><p><i class="fa fa-shield" style="font-size:18px;color:#2ECC71"></i> Secured By Apknatural Protect</p></center>
1614 </div>
1615 <?php
1616 }
1617 } elseif( ( $post->post_parent == 0 || !in_array( 'enlaces_descarga', $cvn ) ) ) {
1618 if( $option_download != 1 ) {
1619 if( !is_array($datos_download ) ) {
1620 return;
1621 }
1622 if( count($datos_download) > 1 && (!$datos_download['option'] || $datos_download['option'] == 'links') ){
1623 ?>
1624 <div id="download" class="box">
1625 <h2 class="box-title"><?php echo __( 'Enlaces de descarga', 'appyn' ); ?></h2>
1626 <ul>
1627 <?php
1628 $n = 0;
1629 foreach( $datos_download as $value => $elemento ) :
1630 if( !is_string($value) ) : ?>
1631 <li><a href="<?php echo $datos_download[$n]['link']; ?>" target="_blank"><i class="fa fa-download"></i> <?php echo $datos_download[$n]['texto']; ?></a></li>
1632 <?php $n++; endif; endforeach; ?>
1633 </ul<>
1634 </div>
1635 <?php
1636 }
1637 }
1638 }
1639}
1640
1641function caja_apps_relacionadas() {
1642 global $post, $cvn;
1643 $category = get_the_category();
1644 $catid = $category[0]->cat_ID;
1645 if( ( $post->post_parent == 0 || !in_array( 'apps_relacionadas', $cvn ) ) ) {
1646 $query = new WP_Query( array( 'post_type' => 'post', 'category__in' => $catid, 'posts_per_page' => 5, 'post__not_in' => array($post->ID), 'post_parent' => 0, 'orderby' => 'relevance' ) );
1647 if( $query->have_posts() ) { ?>
1648 <div class="box relacionados">
1649 <h2 class="box-title"><?php echo __( 'Apps relacionadas', 'appyn' ); ?></h2>
1650 <div class="bloque-apps">
1651 <?php while( $query->have_posts() ) : $query->the_post();
1652 get_template_part( 'parts/loop/app-related' );
1653 endwhile; ?>
1654 </div>
1655 </div>
1656 <?php } wp_reset_query();
1657 }
1658}
1659
1660function caja_apps_desarrollador() {
1661 global $post, $dev_terms, $cvn;
1662 if( !isset($dev_terms[0]->slug) )
1663 return;
1664 if( ( $post->post_parent == 0 || !in_array( 'apps_desarrollador', $cvn ) ) ) {
1665 $query = new WP_Query( array('post_type' => 'post', 'posts_per_page' => 5, 'post__not_in' => array($post->ID), 'post_parent' => 0, 'tax_query' => array(
1666 array(
1667 'taxonomy' => 'dev',
1668 'field' => 'slug',
1669 'terms' => $dev_terms[0]->slug,
1670 ),
1671 ) ) );
1672 if( $query->have_posts() ) { ?>
1673 <div class="box relacionados">
1674 <h2 class="box-title"><?php echo __( 'Apps del desarrollador', 'appyn' ); ?></h2>
1675 <div class="bloque-apps">
1676 <?php while( $query->have_posts() ) : $query->the_post();
1677 get_template_part( 'parts/loop/app-related' );
1678 endwhile; ?>
1679 </div>
1680 </div>
1681 <?php } wp_reset_query();
1682 }
1683}
1684
1685function cajas_personalizadas() {
1686 global $post, $cvn;
1687 if( ( $post->post_parent == 0 || !in_array( 'cajas_personalizadas', $cvn ) ) ) {
1688 $custom_boxes = get_post_meta( $post->ID, 'custom_boxes', true );
1689 if(!empty($custom_boxes)){
1690 foreach($custom_boxes as $box_key => $box_value) {
1691 if( !empty( $box_value['title'] ) || !empty( $box_value['content'] ) ) { ?>
1692 <div id="box-<?php echo $box_key; ?>" class="box personalizadas">
1693 <h2 class="box-title"><?php echo $box_value['title']; ?></h2>
1694 <div class="box-content"><?php echo wpautop( stripslashes($box_value['content']) ); ?></div>
1695 </div>
1696 <?php }
1697 }
1698 }
1699 }
1700}
1701function caja_etiquetas() {
1702 global $post, $cvn;
1703 if( ( $post->post_parent == 0 || !in_array( 'tags', $cvn ) ) ) {
1704 $post_tags = wp_get_post_tags( $post->ID );
1705 if( !empty($post_tags) ) {?>
1706 <div id="tags" class="box etiquetas">
1707 <h2 class="box-title">TAGS</h2>
1708 <?php the_tags( '', '' ); ?>
1709 </div>
1710 <?php }
1711 }
1712}
1713
1714function caja_apps_mas_versiones() {
1715 global $post, $dev_terms, $cvn;
1716 if( !isset($dev_terms[0]->slug) )
1717 return;
1718 if( ( $post->post_parent == 0 || !in_array( 'apps_desarrollador', $cvn ) ) ) {
1719 $query = new WP_Query( array('post_type' => 'post', 'posts_per_page' => 5, 'post__not_in' => array($post->ID), 'post_parent' => 0, 'tax_query' => array(
1720 array(
1721 'taxonomy' => 'dev',
1722 'field' => 'slug',
1723 'terms' => $dev_terms[0]->slug,
1724 ),
1725 ) ) );
1726 if( $query->have_posts() ) { ?>
1727 <div class="box relacionados">
1728 <h2 class="box-title"><?php echo __( 'Apps del desarrollador', 'appyn' ); ?></h2>
1729 <div class="bloque-apps">
1730 <?php while( $query->have_posts() ) : $query->the_post();
1731 get_template_part( 'parts/loop/app-related' );
1732 endwhile; ?>
1733 </div>
1734 </div>
1735 <?php } wp_reset_query();
1736 }
1737}
1738
1739function is_connected(){
1740 $connected = @fsockopen(get_bloginfo('url'), 80);
1741 if ($connected){
1742 $is_conn = true;
1743 fclose($connected);
1744 }else{
1745 $is_conn = false;
1746 }
1747 return $is_conn;
1748}
1749
1750function orden_cajas() {
1751 global $post, $oc, $cvn, $dev_terms;
1752 $dev_terms = wp_get_post_terms( $post->ID, 'dev', array('fields' => 'all'));
1753 if( get_query_var( 'section' ) == __( 'versiones', 'appyn' ) ) {
1754 get_template_part( "parts/single-versiones" );
1755 return;
1756 }
1757 if( $oc ) {
1758 foreach( $oc as $k => $a ) {
1759 switch ( $k ) {
1760 case "descripcion":
1761 caja_descripcion();
1762 break;
1763 case "ads_single_center":
1764 if( $post->post_parent == 0 || !in_array( 'ads_single_center', $cvn ) ) {
1765 echo ads("ads_single_center");
1766 }
1767 break;
1768 case "versiones":
1769 caja_versiones();
1770 break;
1771 case "novedades":
1772 caja_novedades();
1773 break;
1774 case "imagenes":
1775 caja_imagenes();
1776 break;
1777 case "enlaces_descarga":
1778 caja_enlaces_descarga();
1779 break;
1780 case "video":
1781 caja_video();
1782 break;
1783 case "cajas_personalizadas":
1784 cajas_personalizadas();
1785 break;
1786 case "apps_relacionadas":
1787 caja_apps_relacionadas();
1788 break;
1789 case "apps_desarrollador":
1790 caja_apps_desarrollador();
1791 break;
1792 case "tags":
1793 caja_etiquetas();
1794 break;
1795 }
1796 }
1797 } else {
1798 caja_descripcion();
1799 if( $post->post_parent == 0 || !in_array( 'ads_single_center', $cvn ) ) {
1800 echo ads("ads_single_center");
1801 } caja_versiones();
1802 caja_versiones();
1803 caja_novedades();
1804 caja_imagenes();
1805 caja_enlaces_descarga();
1806 caja_video();
1807 caja_apps_relacionadas();
1808 cajas_personalizadas();
1809 caja_apps_desarrollador();
1810 caja_etiquetas();
1811 }
1812}
1813
1814function px_noimage() {
1815 $noimage = get_template_directory_uri().'/images/noimage.png';
1816 $color_theme = get_option( 'appyn_color_theme' );
1817 $color_theme_principal = get_option( 'appyn_color_theme_principal' );
1818 if($color_theme == "oscuro") {
1819 $noimage = get_template_directory_uri().'/images/noimage-d.png';
1820 }
1821 if( is_amp_px() ) {
1822 return '<amp-img src="'.$noimage.'" layout="responsive" width="150" height="150" alt="No image"></amp-img>';
1823 } else {
1824 return '<img src="'.$noimage.'" width="150" height="150" alt="No image">';
1825 }
1826}
1827
1828function count_reports() {
1829 global $wpdb;
1830 $wpdb->get_results( "SELECT meta_value, post_id FROM ".$wpdb->prefix."postmeta WHERE meta_key = 'px_app_report' ORDER BY meta_id DESC" );
1831 return $wpdb->num_rows;
1832}
1833
1834function wps_deregister_styles() {
1835 wp_dequeue_style( 'wp-block-library' );
1836}
1837add_action( 'wp_print_styles', 'wps_deregister_styles', 100 );
1838
1839function modify_post_thumbnail_html($html, $post_id, $post_thumbnail_id, $size, $attr) {
1840 $appyn_lazy_loading = ( get_option('appyn_lazy_loading') ) ? get_option('appyn_lazy_loading') : NULL;
1841 if( $appyn_lazy_loading == 1 ) {
1842 $id = get_post_thumbnail_id();
1843 $src = wp_get_attachment_image_src($id, $size);
1844 $alt = get_the_title($id);
1845 $class = '';
1846 if( !empty($attr['class']) ) {
1847 $class = $attr['class'];
1848 }
1849 $image_blank = get_template_directory_uri().'/images/blank.png';
1850 $color_theme = get_option( 'appyn_color_theme' );
1851 $color_theme_principal = get_option( 'appyn_color_theme_principal' );
1852 if($color_theme == "oscuro") {
1853 $image_blank = get_template_directory_uri().'/images/blank-d.png';
1854 }
1855 $html = '<img src="'.$image_blank.'" data-src="' . $src[0] . '" alt="' . $alt . '" class="' . $class . ' lazyload" />';
1856 }
1857 return $html;
1858}
1859add_filter('post_thumbnail_html', 'modify_post_thumbnail_html', 99, 5);
1860
1861function appyn_options($option) {
1862 if( !empty(get_option('appyn_'.$option) ) ) {
1863 return get_option('appyn_'.$option);
1864 }
1865}
1866
1867function get_datos_download(){
1868 global $post;
1869 $datos_download = get_post_meta($post->ID, 'datos_download', true);
1870 if( !empty($datos_download) ) {
1871 $datos_download = array_filter($datos_download, 'array_multi_filter_download_empty');
1872 }
1873 return $datos_download;
1874}
1875
1876function category_parents(){
1877 global $post;
1878 $category = get_the_category();
1879 $catid = $category[0]->cat_ID;
1880 $separador = " / ";
1881 $category_parents = get_category_parents( $catid, TRUE, "$separador", FALSE );
1882 $category_parents = explode($separador, $category_parents);
1883 $category_parents = array_filter($category_parents, 'array_multi_filter_download_empty');
1884 return $category_parents;
1885}
1886
1887add_action( 'wp', function(){
1888 global $post;
1889 if( !is_single() ) {
1890 return;
1891 }
1892 setPostViews( $post->ID );
1893});
1894
1895function go_curl($url) {
1896 $ch = curl_init();
1897 curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
1898 curl_setopt($ch, CURLOPT_HEADER, 0);
1899 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
1900 curl_setopt($ch, CURLOPT_URL, $url);
1901 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
1902 curl_setopt($ch, CURLOPT_TIMEOUT, 2);
1903 $data = curl_exec($ch);
1904 $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
1905 if($httpCode != 404) {
1906 return $data;
1907 }
1908 curl_close($ch);
1909}
1910
1911add_filter('upload_mimes', 'allow_custom_mimes');
1912
1913function allow_custom_mimes ( $existing_mimes=array() ) {
1914 $existing_mimes['apk'] = '<code>application/vnd.android.package-archive</code>';
1915 return $existing_mimes;
1916}
1917
1918// AMP
1919define( 'AMP_QUERY_VAR', apply_filters( 'amp_query_var', 'amp' ) );
1920
1921function is_amp_px() {
1922 $amp = appyn_options( 'amp' );
1923 if( $amp ) {
1924 return get_query_var( AMP_QUERY_VAR, false ) !== false;
1925 }
1926}
1927
1928add_rewrite_endpoint( AMP_QUERY_VAR, EP_PERMALINK );
1929add_filter( 'template_include', 'amp_page_template', 99 );
1930function amp_page_template( $template ) {
1931 if( is_amp_px() ) {
1932 $template = $template;
1933 if ( is_singular('post') ) {
1934 $template = get_template_directory() . '/amp/single.php';
1935 }
1936 if ( is_home() ) {
1937 $template = get_template_directory() . '/amp/index.php';
1938 }
1939 }
1940 return $template;
1941}
1942add_action('get_header', function($name){
1943 return "header-amp";
1944});
1945
1946add_action('wp_head', function(){
1947 global $wp_query;
1948 if( is_404() || !appyn_options( 'amp' ) ) return;
1949
1950 if( is_home() || is_single() || is_archive() ) {
1951 if( is_home() ) {
1952 echo '<link rel="amphtml" href="'.get_bloginfo('url').'/?amp">';
1953 } elseif( is_single() ) {
1954 global $post;
1955 echo '<link rel="amphtml" href="'.get_the_permalink().'?amp">';
1956 } elseif( is_archive() ) {
1957 $obj = get_queried_object();
1958 if( $obj->rewrite['slug'] ) {
1959 $l = get_post_type_archive_link($obj->rewrite['slug']);
1960 echo '<link rel="amphtml" href="'.($l).'?amp">';
1961 }
1962 } else {
1963 $obj = get_queried_object();
1964 if( !empty($obj->term_id) ) echo '<link rel="amphtml" href="'.get_term_link($obj->term_id).'?amp">';
1965 }
1966 }
1967});
1968
1969add_filter('post_link', 'wpse230567_filter_post_link', 1, 2);
1970function wpse230567_filter_post_link($link, $post = 0){
1971 if( isset($_GET['amp']) ) {
1972 return $link.'?amp';
1973 }
1974 return $link;
1975}
1976
1977function amp_comment_form(){
1978 global $post;
1979 echo '<p><a href="'.esc_url( remove_query_arg( 'amp', get_the_permalink( $post->ID ) ) ).'#comment">'.__( 'Deja un comentario', 'appyn' ).'</a></p>';
1980}
1981
1982
1983function modify_post_thumbnail_amp($html, $post_id, $post_thumbnail_id, $size, $attr) {
1984 if( is_amp_px() ) {
1985 $id = get_post_thumbnail_id();
1986 $src = wp_get_attachment_image_src($id, $size);
1987 $alt = get_the_title($id);
1988 $class = '';
1989 if( !empty($attr['class']) ) {
1990 $class = $attr['class'];
1991 }
1992
1993 $html = '<amp-img src="'.$src[0].'" width="128" height="128" alt="' . $alt . '" class="' . $class . '" layout="responsive"></amp-img>';
1994 }
1995 return $html;
1996}
1997add_filter('post_thumbnail_html', 'modify_post_thumbnail_amp', 99, 5);
1998
1999function px_amp_logo($logo_url) {
2000 return '<amp-img src="'.$logo_url.'" alt="'.get_bloginfo('title').'" layout="fixed-height" height="40"></amp-img>';
2001}
2002
2003add_filter( 'comment_reply_link', function($args_before_link_args_after){
2004 if( is_amp_px() ) {
2005 return false;
2006 } else {
2007 return $args_before_link_args_after;
2008 }
2009} );
2010
2011add_filter( 'get_avatar_url', 'wpua_get_avatar_url', 50, 3 );
2012function wpua_get_avatar_url( $url, $id_or_email, $args ){
2013 if( class_exists('WP_User_Avatar_Functions') && $id_or_email != 'unknown@gravatar.com' ) {
2014 global $wpua_functions;
2015 $url = $wpua_functions->get_wp_user_avatar_src( $id_or_email, $args['size'] );
2016 }
2017 return $url;
2018}
2019
2020
2021
2022function appyn_comment($comment, $args, $depth) {
2023 if ( 'div' === $args['style'] ) {
2024 $tag = 'div';
2025 $add_below = 'comment';
2026 } else {
2027 $tag = 'li';
2028 $add_below = 'div-comment';
2029 }?>
2030 <<?php echo $tag; ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?> id="comment-<?php comment_ID() ?>"><?php
2031 if ( 'div' != $args['style'] ) { ?>
2032 <div id="div-comment-<?php comment_ID() ?>" class="comment-body"><?php
2033 } ?>
2034 <div class="comment-author vcard"><?php
2035 if ( $args['avatar_size'] != 0 ) {
2036 if( is_amp_px() ) {
2037 echo '<amp-img src="'.get_avatar_url( $comment, $args['avatar_size'] ).'" width="56" height="56"></amp-img>';
2038 } else {
2039 echo get_avatar( $comment, $args['avatar_size'] );
2040 }
2041 }
2042 printf( '<cite class="fn">%s</cite> <span class="says">'.__( 'dice', 'appyn' ).':</span>', get_comment_author_link() ); ?>
2043 </div><?php
2044 if ( $comment->comment_approved == '0' ) { ?>
2045 <em class="comment-awaiting-moderation"><?php echo __( 'Tu comentario está en espera de aprobación.', 'appyn' ); ?></em><br/><?php
2046 } ?>
2047 <div class="comment-meta commentmetadata">
2048 <a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>"><?php
2049 printf(
2050 __( '%1$s a las %2$s', 'appyn' ),
2051 get_comment_date(),
2052 get_comment_time()
2053 ); ?>
2054 </a><?php
2055 edit_comment_link( __( '(Editar)', 'appyn' ), ' ', '' ); ?>
2056 </div>
2057
2058 <?php comment_text(); ?>
2059
2060 <div class="reply"><?php
2061 comment_reply_link(
2062 array_merge(
2063 $args,
2064 array(
2065 'add_below' => $add_below,
2066 'depth' => $depth,
2067 'max_depth' => $args['max_depth']
2068 )
2069 )
2070 ); ?>
2071 </div><?php
2072 if ( 'div' != $args['style'] ) : ?>
2073 </div><?php
2074 endif;
2075}
2076
2077function px_post_thumbnail( $size = 'thumbnail', $post = NULL ) {
2078 if( !$post ) {
2079 global $post;
2080 }
2081 $image = px_noimage();
2082 if( has_post_thumbnail() ) {
2083 $featured_image_url = wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) );
2084 if ( ! empty( $featured_image_url ) ) {
2085 $gtpt = get_the_post_thumbnail($post->ID, $size, array('class'=>'image-single'));
2086 if ( ! empty( $gtpt ) ) {
2087 $image = $gtpt;
2088 }
2089 }
2090 }
2091 return $image;
2092}
2093
2094function px_content_filter($content){
2095 if( is_amp_px() ) {
2096 // Imágenes
2097 $re = '/<img(.*?)src=(\'|\")(.*?)(\'|\")(.*?)(\/)?>/m';
2098 preg_match_all($re, $content, $matches, PREG_SET_ORDER, 0);
2099 $images = array();
2100 foreach( $matches as $m ) {
2101 if( strpos($m[0], 'width=') === false ) {
2102 ob_start();
2103 $data = getimagesize(str_replace(get_bloginfo('url'), $_SERVER['DOCUMENT_ROOT'], $m[3]));
2104 $data = ob_get_clean();
2105 list($width, $height) = $data;
2106 if( !empty($width) ) {
2107 $subst = '<amp-img$1src=$2$3$4$5 layout="responsive" width="'.$width.'" height="'.$height.'"></amp-img>';
2108 } else {
2109 list($width, $height) = getimagesize($m[3]);
2110 $subst = '<amp-img$1src=$2$3$4$5 layout="responsive" width="'.$width.'" height="'.$height.'"></amp-img>';
2111 }
2112 $images[$m[0]] = preg_replace($re, $subst, $m[0]);
2113 } else {
2114 ob_start();
2115 $data = getimagesize(str_replace(get_bloginfo('url'), $_SERVER['DOCUMENT_ROOT'], $m[3]));
2116 $data = ob_get_clean();
2117 list($width, $height) = $data;
2118 if( !empty($width) ) {
2119 $subst = '<amp-img$1src=$2$3$4$5 layout="responsive" style="max-width:'.$width.'px"></amp-img>';
2120 $images[$m[0]] = preg_replace($re, $subst, $m[0]);
2121 } else {
2122 list($width, $height) = getimagesize($m[3]);
2123 $subst = '<amp-img$1src=$2$3$4$5 layout="responsive" style="max-width:'.$width.'px"></amp-img>';
2124 $images[$m[0]] = preg_replace($re, $subst, $m[0]);
2125 }
2126 }
2127 }
2128 $content = strtr($content, $images);
2129
2130 // Videos youtube
2131 $videos = array();
2132 $re = '/<iframe.+?src="https?:\/\/www\.youtube\.com\/embed\/([a-zA-Z0-9_-]{11})"[^>]+?><\/iframe>/ms';
2133 preg_match_all($re, $content, $matches, PREG_SET_ORDER, 0);
2134 foreach( $matches as $v ) {
2135 $videos[$v[0]] = '<amp-youtube data-videoid="'.$v[1].'" layout="responsive" width="480" height="270"></amp-youtube>';
2136 }
2137 $content = strtr($content, $videos);
2138
2139 return $content;
2140 }
2141 return $content;
2142}
2143add_filter( 'locale_stylesheet_uri', function ($localized_stylesheet_uri) {
2144 if( strpos($localized_stylesheet_uri, 'rtl.css') !== false ) {
2145 $time_ver = filemtime( get_stylesheet_directory() . '/rtl.css' );
2146 return add_query_arg( array('ver' => $time_ver), $localized_stylesheet_uri );
2147 }
2148});
2149
2150function app_developer(){
2151 global $post;
2152 $datos_informacion = get_post_meta($post->ID, 'datos_informacion', true);
2153 $output = '';
2154 if( isset($datos_informacion['desarrollador'] ) ) {
2155 $output .= '<span class="developer">'.$datos_informacion['desarrollador'].'</span>';
2156 } else {
2157 $dev_terms = wp_get_post_terms( $post->ID, 'dev', array('fields' => 'all'));
2158 if( !empty($dev_terms) ) {
2159 $output .= '<span class="developer">'.$dev_terms[0]->name.'</span>';
2160 }
2161 }
2162 return $output;
2163}
2164
2165// function appyn_meta($post_id = "", $key, $k = "") {
2166// $pm = get_post_meta( $post_id, $key, true);
2167// if( $pm[$k] )
2168// }
2169function app_date(){
2170 global $post;
2171 $appyn_post_date = appyn_options( 'post_date' );
2172 if( !$appyn_post_date ) return;
2173
2174 $output = '<span class="app-date">'.get_the_date( get_option( 'date_format' ), $post->ID).'</span>';
2175 return $output;
2176}
2177
2178function cover_header() {
2179 $arrayimgs = array();
2180 for($n=1;$n<=5;$n++){
2181 $option = appyn_options( 'image_header'.$n);
2182 if( !empty($option) )
2183 $arrayimgs[] = appyn_options( 'image_header'.$n);
2184 }
2185
2186
2187 if( appyn_options( 'lazy_loading') ) {
2188 return '<img src="'.get_template_directory_uri().'/images/blank-d.png" data-src="'.$arrayimgs[rand(0,(count($arrayimgs) - 1))].'" alt="Portada" class="lazyload">';
2189 } else {
2190 return '<img src="'.$arrayimgs[rand(0,(count($arrayimgs) - 1))].'" alt="Portada">';
2191 }
2192}