diff options
author | Heckyel <heckyel@openmailbox.org> | 2017-03-10 18:27:37 -0500 |
---|---|---|
committer | Heckyel <heckyel@openmailbox.org> | 2017-03-10 18:27:37 -0500 |
commit | bb98b20786c8e3d1d834d2cd30d35cc500a46ab8 (patch) | |
tree | 44cfe5b9bf04bd113c136fb9fd9569140493adb0 /functions.php | |
parent | 591809d44a736e70c3e35d91904be189214a9373 (diff) | |
download | lidra-theme-bb98b20786c8e3d1d834d2cd30d35cc500a46ab8.tar.lz lidra-theme-bb98b20786c8e3d1d834d2cd30d35cc500a46ab8.tar.xz lidra-theme-bb98b20786c8e3d1d834d2cd30d35cc500a46ab8.zip |
Optimización del código + LibreVideoJS v2.0 + Languages
Diffstat (limited to 'functions.php')
-rw-r--r-- | functions.php | 88 |
1 files changed, 85 insertions, 3 deletions
diff --git a/functions.php b/functions.php index dc5fb46..c87eff1 100644 --- a/functions.php +++ b/functions.php @@ -1,15 +1,23 @@ <?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' => __('Menú Principal', 'libre'), - 'footer_nav' => __('Menú Footer', 'libre') + 'main_nav' => __('Main Menu', 'Lidra'), + 'footer_nav' => __('Footer Menu', 'Lidra') ); register_nav_menus($locations); } @@ -18,7 +26,7 @@ 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>" . __('leer más...', 'libre') . "</small></a>"; + return " <a href='$url_post'><small>" . __('Read more...', 'Lidra') . "</small></a>"; } add_filter('excerpt_more', 'read_more'); @@ -35,3 +43,77 @@ function widgets_activation(){ } 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'; |