-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
157 lines (132 loc) · 4.59 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
/**
* Sage includes
*
* The $sage_includes array determines the code library included in your theme.
* Add or remove files to the array as needed. Supports child theme overrides.
*
* Please note that missing files will produce a fatal error.
*
* @link https://github.com/roots/sage/pull/1042
*/
$sage_includes = [
'lib/assets.php', // Scripts and stylesheets
'lib/extras.php', // Custom functions
'lib/setup.php', // Theme setup
'lib/titles.php', // Page titles
'lib/wrapper.php', // Theme wrapper class
'lib/customizer.php', // Theme customizer
'lib/nav-walker.php' // Theme customizer
];
foreach ($sage_includes as $file) {
if (!$filepath = locate_template($file)) {
trigger_error(sprintf(__('Error locating %s for inclusion', 'sage'), $file), E_USER_ERROR);
}
require_once $filepath;
}
unset($file, $filepath);
// EXCERPT LENGHT
function custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
// DELETE COMMENTS BUTTON ON ADMIN
add_action( 'admin_init', 'my_remove_admin_menus' );
function my_remove_admin_menus() {
remove_menu_page( 'edit-comments.php' );
}
// REMOVE POST FORMAT SUPPORT
add_action('after_setup_theme', 'remove_post_formats', 11);
function remove_post_formats() {
remove_theme_support('post-formats');
}
function iproRenderProductos($post){
?>
<div class="col-md-3 col-sm-6 col-xs-12 minpadtop">
<div class="iproRenderProductos">
<div class="textright strong minpadbottom"><?php $terms = get_the_term_list($post->ID,'categoria'); echo strip_tags( $terms );?></div>
<?php if(has_post_thumbnail()): ?><img src="<?= the_post_thumbnail_url(); ?>"><?php endif; ?>
<div class="iproProductoInner">
<div class="medpadbottom medpadtop productTitle"><?php echo get_the_title(); ?></div>
<div class="iproText"><?php echo get_the_excerpt(); ?></div>
</div>
</div>
</div>
<?php
}
function iproRenderNoticias($post){
?>
<div class="col-md-6 col-sm-6 col-xs-12 minpadtop">
<!--<div style="float:right; color:#777; padding-bottom:8px;"><?php echo get_the_date(); ?></div>-->
<div class="iproRenderNoticias">
<?php if(has_post_thumbnail($post->ID)): ?><img src="<?= the_post_thumbnail_url($post->ID); ?>"><?php endif; ?>
<div class="iproProductoInner">
<div class="medpadbottom medpadtop productTitle textcenter darkgrey" style="text-transform:uppercase;"><?php echo get_the_title($post->ID); ?></div>
<div class="iproText color1"><?php if (has_excerpt( $post->ID )) echo get_the_excerpt($post->ID); ?><br /> </div>
<!--<div class="iproDown color1 strong">LEER MÁS ></div>-->
</div>
</div>
</div>
<?php
}
function iproNoticias($categoria = 'destacadas', $excludePostId = ''){ ?>
<!-- NOTICIAS -->
<div class="text-center bg1container">
<?php
wp_reset_query();
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'category_name' => $categoria,
'posts_per_page' => '2',
'post__not_in' => array($excludePostId),
'cache_results' => false, // para mejorar rendimiento en dev o prod
'update_post_term_cache' => false,
'update_post_meta_cache' => false,
'no_found_rows' => true, // para mejorar rendimiento si no existe paginacion
);
$noticias = new WP_Query($args);
while ( $noticias->have_posts() ) {
$noticias->the_post();
iproRenderNoticias ($noticias);
}
?>
</div>
<!-- FIN NOTICIAS -->
<?php
}
function iproRenderForm1(){
?>
<!-- CONTACT FORM 1 -->
<div class="text-center bg1container iproForm">
<?php echo do_shortcode('[contact-form-7 id="41" title="Form portada"]'); ?>
</div>
<!-- FIN FORM -->
<?php }
function iproRenderForm1_es(){
?>
<!-- CONTACT FORM 1 -->
<div class="text-center bg1container iproForm">
<?php echo do_shortcode('[contact-form-7 id="1017" title="Form portada_ES"]'); ?>
</div>
<!-- FIN FORM -->
<?php }
function printTel(){
echo '<a class="white" href="tel:+34 93 822 82 50">93 822 82 50</a>';
}
// Allow shortcodes in Contact Form 7
function shortcodes_in_cf7( $form ) {
$form = do_shortcode( $form );
return $form;
}
add_filter( 'wpcf7_form_elements', 'shortcodes_in_cf7' );
// Update CSS within in Admin
function admin_style() {
wp_enqueue_style('admin-styles', get_template_directory_uri().'/admin.css');
}
add_action('admin_enqueue_scripts', 'admin_style');
// Enqueue if !Home page
function iproLightSlider() {
wp_enqueue_script( 'lightSlider', get_template_directory_uri() . '/dist/scripts/lightslider.min.js', array( 'jquery' ), null, false );
}
add_action( 'wp_enqueue_scripts', 'iproLightSlider' );