-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
executable file
·152 lines (134 loc) · 5.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
<?php
/***********************************************
* REMOVE ADMIN BAR
***********************************************/
add_filter('show_admin_bar', '__return_false');
/***********************************************
* MENUS
***********************************************/
if ( function_exists( 'add_theme_support' ) ){
add_theme_support( 'nav-menus' );
register_nav_menus(array(
'main_left' => 'Menú a la izquierda del logo',
'main_right' => 'Menú a la derecha del logo',
'paquetes' => 'Menú de paquetes (categorías de destinos)',
'main_footer' => 'Menú del footer'
));
}
/***********************************************
* POST THUMBNAILS
***********************************************/
if ( function_exists( 'add_theme_support' ) )
add_theme_support( 'post-thumbnails' );
/* Custom image sizes */
add_image_size( 'destino-thumb', 400, 280, array( 'center', 'top' ) );
/*add_image_size( 'custom-medium', 1200, 10000, false);
add_image_size( 'custom-large', 1880, 15000, false);*/
/* URL THUMBNAILS */
function url_thumbnail($id, $tamagno){
$src = wp_get_attachment_image_src( $id , $tamagno);
echo $src[0];
}
// Override img caption shortcode to fix 10px issue.
function fix_img_caption_shortcode($val, $attr, $content = null) {
extract(shortcode_atts(array(
'id' => '',
'align' => '',
'width' => '',
'caption' => ''
), $attr));
if ( 1 > (int) $width || empty($caption) ) return $val;
return '<div id="' . $id . '" class="wp-caption ' . esc_attr($align) . '" style="max-width: ' . (0 + (int) $width) . 'px">' . do_shortcode( $content ) . '<p class="wp-caption-text">' . $caption . '</p></div>';
}
add_filter('img_caption_shortcode', 'fix_img_caption_shortcode', 10, 3);
/***********************************************
* CUSTOM LENGTH EXCERPT
***********************************************/
function custom_excerpt_length( $length ) {
global $post;
if ($post->post_type == 'post'){
return 14;
} else if ($post->post_type == 'illustration'){
return 50;
}
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
/**********************************************
* To remove <p> before category description
**********************************************/
remove_filter('term_description','wpautop');
/***********************************************
* CUSTOM TYPE: Testimonio
***********************************************/
function create_testimonio_type() {
$args = array(
'labels' => array(
'name' => 'Testimonios',
'singular_name' => 'Testimonio'
),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'show_tagcloud' => false,
'show_in_nav_menus' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-format-chat',
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'custom-fields' )
);
register_post_type('testimonio',$args);
}
add_action( 'init', 'create_testimonio_type' );
/***********************************************
* SIDEBAR
***********************************************/
function sidebar_init() {
// Area 1, located at the top of the sidebar.
register_sidebar( array(
'name' => 'Primary Widget',
'id' => 'primary-widget-area',
'description' => 'The primary widget area',
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// Area 2, located below the Primary Widget Area in the sidebar. Empty by default.
register_sidebar( array(
'name' => 'Secondary Widget',
'id' => 'secondary-widget-area',
'description' => 'The secondary widget area',
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'sidebar_init' );
add_theme_support( 'html5', array( 'search-form' ) );
/***********************************************
* Show post content
***********************************************/
function show_post_content($path) {
$post = get_page_by_path($path);
$content = apply_filters('the_content', $post->post_content);
echo $content;
}
// Dependencies
function setur_dependencies(){
// CSS
wp_enqueue_style( 'ubuntu_fonts', 'http://fonts.googleapis.com/css?family=Ubuntu:400,700,300,300italic', array(), '1');
wp_enqueue_style( 'theme', get_template_directory_uri() . '/css/theme.css', array(), '1');
wp_enqueue_style( 'style', get_stylesheet_uri());
// JS
wp_enqueue_script( 'html5shiv', get_template_directory_uri() . '/js/libs/html5-3.4-respond-1.1.0.min.js', array(), '1');
wp_script_add_data( 'html5shiv', 'conditional', 'lt IE 9' );
wp_enqueue_script( 'app', get_template_directory_uri() . '/js/app.js', array( 'jquery' ),'1' );
}
add_action( 'wp_enqueue_scripts', 'setur_dependencies' );
?>