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
|
<?php
if (!defined('ABSPATH')){
exit;
}
// Funciones Principales
function libre_custom_theme_setup(){
// Agregamos el Soporte para Thumbnails
add_theme_support('post-thumbnails');
// Agregamos un tamaño de imagen y permitimos que la imagen se recorte si no cabe
add_image_size('homepage-thumb', 745, 372, true);
//Carga Traducciones
load_theme_textdomain('Lidra', get_template_directory() . '/languages');
// Agregamos el menu
$locations = array(
'main_nav' => __('Main Menu', 'Lidra'),
'footer_nav' => __('Footer Menu', 'Lidra')
);
register_nav_menus($locations);
}
add_action('after_setup_theme', 'libre_custom_theme_setup');
// Funcion de reemplazo a leer más
function read_more( $more ){
$url_post = get_permalink();
return " <a href='$url_post'><small>" . __('Read more...', 'Lidra') . "</small></a>";
}
add_filter('excerpt_more', 'read_more');
// Funcion de widget
function widgets_activation(){
register_sidebar( array(
'name' => __('Sidebar', 'libre'),
'id' => 'sidebar',
'before_widget' => '<div class="widget"><div class="titulo-seccion">',
'after_widget' => '</div></div>',
'before_title' => '<h3>',
'after_title' => '</h3>'
));
}
add_action('widgets_init', 'widgets_activation');
//Agrega iconos por defecto de WordPress
function load_dashicons_front_end() {
wp_enqueue_style( 'dashicons' );
}
add_action( 'wp_enqueue_scripts', 'load_dashicons_front_end' );
/*Ajustes y Limpieza para WordPress
------------------------------------------------------------------------------*/
//Elimina referencias a la version de WordPress
function quitar_version_wp() {
return '';
}
add_filter('the_generator', 'quitar_version_wp');
function nowp_head_cleanup() {
// Eliminamos lo que sobra de la cabecera
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'start_post_rel_link', 10, 0);
remove_action('wp_head', 'parent_post_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0);
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'feed_links_extra', 3);
// Elimina emoji script
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
global $wp_widget_factory;
remove_action('wp_head', array(
$wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style')
);
if (!class_exists('WPSEO_Frontend')) {
remove_action('wp_head', 'rel_canonical');
add_action('wp_head', 'nowp_rel_canonical');
}
}
function nowp_rel_canonical() {
global $wp_the_query;
if (!is_singular()) {
return;
}
if (!$id = $wp_the_query->get_queried_object_id()) {
return;
}
$link = get_permalink($id);
printf("<link rel=\"canonical\" href=\"$link\">\n");
}
add_action('init', 'nowp_head_cleanup');
// Limpia dns-prefetch en caso de NO usar fuentes del servicio Privativo Google
function remove_dns_prefetch( $hints, $relation_type ) {
if ( 'dns-prefetch' === $relation_type ) {
return array_diff( wp_dependencies_unique_hosts(), $hints );
}
return $hints;
}
add_filter( 'wp_resource_hints', 'remove_dns_prefetch', 10, 2 );
/* LibreVideoJS
------------------------------------------------------------------------------*/
include_once 'librevideojs.php';
|