mirror of
https://git.sindominio.net/estibadores/wordpress.git
synced 2024-11-14 23:21:07 +01:00
127 lines
4.1 KiB
PHP
127 lines
4.1 KiB
PHP
<?php
|
|
|
|
/* Changing excerpt length
|
|
function new_excerpt_length($length) {
|
|
return 150;
|
|
}
|
|
add_filter('excerpt_length', 'new_excerpt_length');
|
|
*/
|
|
|
|
/* Changing excerpt more
|
|
function new_excerpt_more($more) {
|
|
return '...';
|
|
}
|
|
add_filter('excerpt_more', 'new_excerpt_more');
|
|
*/
|
|
|
|
|
|
/******************************************************************************
|
|
* @Author: Boutros AbiChedid
|
|
* @Date: June 20, 2011
|
|
* @Websites: http://bacsoftwareconsulting.com/ ; http://blueoliveonline.com/
|
|
* @Description: Preserves HTML formating to the automatically generated Excerpt.
|
|
* Also Code modifies the default excerpt_length and excerpt_more filters.
|
|
* @Tested: Up to WordPress version 3.1.3
|
|
*******************************************************************************/
|
|
function custom_wp_trim_excerpt($text) {
|
|
$raw_excerpt = $text;
|
|
if ( '' == $text ) {
|
|
//Retrieve the post content.
|
|
$text = get_the_content('');
|
|
|
|
//Delete all shortcode tags from the content.
|
|
$text = strip_shortcodes( $text );
|
|
|
|
$text = apply_filters('the_content', $text);
|
|
$text = str_replace(']]>', ']]>', $text);
|
|
|
|
$allowed_tags = '<p>,<a>,<em>,<strong>,<i>,<img>';
|
|
//$allowed_tags = '<p>'; /*** MODIFY THIS. Add the allowed HTML tags separated by a comma.***/
|
|
$text = strip_tags($text, $allowed_tags);
|
|
|
|
$excerpt_word_count = 100; /*** MODIFY THIS. change the excerpt word count to any integer you like.***/
|
|
$excerpt_length = apply_filters('excerpt_length', $excerpt_word_count);
|
|
|
|
$excerpt_end = '[...]'; /*** MODIFY THIS. change the excerpt endind to something else.***/
|
|
$excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end);
|
|
|
|
$words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
|
|
if ( count($words) > $excerpt_length ) {
|
|
array_pop($words);
|
|
$text = implode(' ', $words);
|
|
$text = $text . $excerpt_more;
|
|
} else {
|
|
$text = implode(' ', $words);
|
|
}
|
|
}
|
|
return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
|
|
}
|
|
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
|
|
add_filter('get_the_excerpt', 'custom_wp_trim_excerpt');
|
|
|
|
|
|
|
|
|
|
|
|
/* Hide widget title */
|
|
add_filter('widget_title','my_widget_title');
|
|
function my_widget_title($t)
|
|
{
|
|
if ( ($t == 'MST') OR ( $t == 'Etiquetas') ):
|
|
return null;
|
|
else:
|
|
return $t;
|
|
endif;
|
|
}
|
|
|
|
|
|
/* Search BOX in MENU*/
|
|
//add_theme_support('html5', array('search-form'));
|
|
add_filter( 'wp_nav_menu_items','add_search_box', 10, 2 );
|
|
function add_search_box( $items, $args ) {
|
|
$items .= '<li id="searchli">' . get_search_form( false ) . '</li>';
|
|
return $items;
|
|
}
|
|
|
|
|
|
/* CUSTOM ENTRY META*/
|
|
if ( ! function_exists( 'twentytwelve_entry_meta' ) ) {
|
|
/**
|
|
* Set up post entry meta.
|
|
* Prints HTML with meta information for current post: categories, tags, permalink, author, and date.
|
|
* Create your own twentytwelve_entry_meta() to override in a child theme.
|
|
* @since Twenty Twelve 1.0
|
|
*/
|
|
function twentytwelve_entry_meta($ID) {
|
|
// Translators: used between list items, there is a space after the comma.
|
|
$categories_list = '<span class="post-cats">'.get_the_category_list( __( ', ', 'twentytwelve' ) ).'</span>';
|
|
|
|
// Translators: used between list items, there is a space after the comma.
|
|
$tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );
|
|
|
|
$date = sprintf( '<span class="the_date">%1$s</span>', esc_html( get_the_date() ) );
|
|
|
|
$author = sprintf( '<span class="author vcard">%1$s</span>', get_the_author() ) ;
|
|
|
|
|
|
|
|
// Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
|
|
if ( $tag_list ) {
|
|
$utility_text = __( '%3$s - %1$s ' , 'twentytwelve' );
|
|
//$utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
|
|
} elseif ( $categories_list ) {
|
|
$utility_text = __( '%3$s - %1$s ' , 'twentytwelve' );
|
|
} else {
|
|
$utility_text = __( 'his entry was posted on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
|
|
}
|
|
printf(
|
|
$utility_text,
|
|
$categories_list,
|
|
$tag_list,
|
|
$date,
|
|
$author
|
|
);
|
|
}
|
|
|
|
}
|