-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.php
275 lines (221 loc) · 8.17 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<?php
if (!isset($content_width))
$content_width = 654;
if (!function_exists('eticagnu_main_setup')):
function eticagnu_main_setup() {
add_theme_support('automatic-feed-links');
add_theme_support('post-formats', array('aside'));
register_nav_menus(array(
'general-menu' => 'Menú general',
'main-menu' => 'Menú principal'
));
add_theme_support('custom-header', array(
'width' => 70,
'height' => 70,
'default-text-color' => '000',
'flex-width' => true,
'header-text' => true,
'default-image' => get_template_directory_uri() . '/images/header.jpg',
'uploads' => true,
));
add_theme_support('post-thumbnails');
}
endif;
add_action('after_setup_theme', 'eticagnu_main_setup');
function eticagnu_main_scripts() {
wp_enqueue_style('style', get_stylesheet_uri());
if (is_singular() && comments_open() && get_option('thread_comments')) {
wp_enqueue_script('comment-reply');
}
wp_enqueue_script('navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20140512', true);
if (is_singular() && wp_attachment_is_image())
wp_enqueue_script('keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array('jquery'), '20140512');
}
add_action('wp_enqueue_scripts', 'eticagnu_main_scripts');
if (!function_exists('eticagnu_main_posted_on')) :
function eticagnu_main_posted_on() {
printf(
'Publicado el '
. '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a>'
. '<span class="byline"> por <span class="author vcard">'
. '<a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a>'
. '</span></span>', esc_url(get_permalink()), esc_attr(get_the_time()), esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_attr(sprintf('Ver todas las entradas de %s', get_the_author())), esc_html(get_the_author())
);
}
endif;
function eticagnu_main_categorized_blog() {
if (false === ( $allTheCoolCats = get_transient('all_the_cool_cats') )) {
$allTheCoolCats = get_categories(array(
'hide_empty' => 1,
));
$allTheCoolCats = count($allTheCoolCats);
set_transient('allTheCoolCats', $allTheCoolCats);
}
if ('1' != $allTheCoolCats)
return true;
else
return false;
}
function eticagnu_main_category_transient_flusher() {
// Like, beat it. Dig?
delete_transient('allTheCoolCats');
}
add_action('edit_category', 'eticagnu_main_category_transient_flusher');
add_action('save_post', 'eticagnu_main_category_transient_flusher');
if (!function_exists('eticagnu_main_content_nav')) {
function eticagnu_main_content_nav($nav_id) {
global $wp_query, $post;
if (is_single()) {
$previous = ( is_attachment() ) ? get_post($post->post_parent) : get_adjacent_post(false, '', true);
$next = get_adjacent_post(false, '', false);
if (!$next && !$previous)
return;
}
if ($wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ))
return;
$navClass = 'site-navigation paging-navigation';
if (is_single())
$navClass = 'site-navigation post-navigation';
?>
<nav id="<?php echo $nav_id; ?>" class="<?php echo $navClass; ?>" role="navigation">
<?php if (is_single()) : ?>
<?php previous_post_link('<div class="nav-previous"><span class="meta-nav-msg">Entrada anterior</span> %link</div>', '%title'); ?>
<?php next_post_link('<div class="nav-next"><span class="meta-nav-msg">Entrada siguiente</span> %link</div>', '%title'); ?>
<?php elseif ($wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() )) : ?>
<?php if (get_next_posts_link()) : ?>
<div class="nav-previous">
<?php next_posts_link('<span class="meta-nav">←</span> Entradas anteriores'); ?>
</div>
<?php endif; ?>
<?php if (get_previous_posts_link()) : ?>
<div class="nav-next"><?php previous_posts_link('Entradas recientes <span class="meta-nav">→</span>'); ?></div>
<?php endif; ?>
<?php endif; ?>
</nav>
<?php
}
}
if (!function_exists('eticagnu_main_comment')) :
function eticagnu_main_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
switch ($comment->comment_type) :
case 'pingback' :
case 'trackback' :
?>
<li class="post pingback">
<p>Pingback <?php comment_author_link(); ?><?php edit_comment_link('(Editar)', ' ') ?></p>
<?php
break;
default :
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<article id="comment-<?php comment_ID(); ?>" class="comment">
<footer>
<div class="comment-author vcard">
<?php echo get_avatar($comment, 60); ?>
<?php printf('<cite class="fn">%s</cite>', get_comment_author_link()); ?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<p><em>Tu comentario está esperando moderación.</em></p>
<?php endif; ?>
<div class="comment-meta commentmetadata">
<a href="<?php echo esc_url(get_comment_link($comment->comment_ID)); ?>">
<time pubdate datetime="<?php comment_time('c'); ?>">
<?php printf('%1$s a las %2$s', get_comment_date(), get_comment_time()) ?>
</time>
</a>
<?php edit_comment_link('(Editar)', ' ') ?>
</div>
<div class="reply">
<?php
comment_reply_link(array_merge($args, array(
'depth' => $depth,
'max_depth' => $args['max_depth']
)));
?>
</div>
</footer>
<div class="comment-content"><?php comment_text(); ?></div>
</article>
<?php
break;
endswitch;
}
endif;
function eticagnu_main_widgets_init() {
register_sidebar(array(
'name' => 'Primera área de sidebar',
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget col-xs-12 %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
));
register_sidebar(array(
'name' => 'Segunda área de sidebar',
'id' => 'sidebar-2',
'before_widget' => '<aside id="%1$s" class="widget col-xs-12 %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
));
register_sidebar(array(
'name' => 'Primera área de footer',
'id' => 'footer-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
));
register_sidebar(array(
'name' => 'Segunda área de footer',
'id' => 'footer-2',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
));
register_sidebar(array(
'name' => 'Tercera área de footer',
'id' => 'footer-3',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
));
register_sidebar(array(
'name' => 'Cuarta área de footer',
'id' => 'footer-4',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
));
}
add_action('widgets_init', 'eticagnu_main_widgets_init');
function projects_post_type() {
$labels = array(
'name' => _x("Proyectos", "Proyectos"),
'singular_name' => _x("Proyecto", "Proyecto"),
'menu_name' => 'Proyectos',
'add_new' => _x("Agregar nuevo", "proyecto"),
'add_new_item' => __("Agregar nuevo proyecto"),
'edit_item' => __("Editar proyecto"),
'new_item' => __("Nuevo proyecto"),
'view_item' => __("Ver proyecto"),
'search_items' => __("Buscar proyecto"),
'not_found' => __("Proyecto no encontrado"),
'not_found_in_trash' => __("Proyectos en la papelera"),
'parent_item_colon' => ''
);
// Register post type
register_post_type('project', array(
'labels' => $labels,
'public' => true,
'has_archive' => false,
'menu_icon' => 'dashicons-welcome-widgets-menus',
'rewrite' => false,
'supports' => array('title', 'editor', 'thumbnail')
));
}
add_action('init', 'projects_post_type', 0);