wordpress/php-fpm/wordpress_files/themes/sd-bushwick/functions.php
2020-05-22 01:40:23 +00:00

98 lines
3.0 KiB
PHP

<?php
/**
* Disable fonts from google. We use Lato from local, its license is open.
* Just deactivate some lines to return nothing.
*/
/* NOT PLUGABLE
function bushwick_fonts_url() {
$fonts_url = '';
if ( 'off' !== _x( 'on', 'Lato: on or off', 'bushwick' ) ) {
$fonts_url = add_query_arg( array(
'family' => urlencode( 'Lato:400,700,400italic,700italic,900' ),
'subset' => urlencode( 'latin,latin-ext' ),
), 'https://fonts.googleapis.com/css' );
}
return $fonts_url;
}
*/
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function bushwick_posted_on() {
/* printf( '<i>%1$s - %2$s </i> ',
get_the_author(),*/
printf( '<i>%1$s </i> ',
esc_attr( get_the_date( 'j F Y' ) )
);
}
/**
* Displays navigation to next/previous post when applicable.
*
* @return void
*/
function bushwick_post_nav() {
// Deactivate post_nav
//return;
// Don't print empty markup if there's nowhere to navigate.
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( ! $next && ! $previous )
return;
?>
<nav class="navigation post-navigation" role="navigation">
<h1 class="screen-reader-text"><?php _e( 'Post navigation', 'bushwick' ); ?></h1>
<div class="nav-links">
<?php
previous_post_link( '%link', _x( '<span class="meta-nav">&larr;</span>', 'Previous post link', 'bushwick' ), $in_same_term = true );
next_post_link( '%link', _x( '<span class="meta-nav">&rarr;</span>', 'Next post link', 'bushwick' ), $in_same_term = true );
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
/*
* pebles: Automatically retrieve the first image from posts.
*/
function get_first_img_or_any() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $post->post_content, $matches );
$first_img = $matches[1];
if ( empty( $first_img ) ) {
return;
//$first_img = "https://clickwp.com/wp-content/uploads/2014/06/icon-wpcom-to-wp.png";
//}else{
}
$first_img='<div class="post-image"><img src="' . $first_img . '" alt="Post Image" width=100 /></div>';
return $first_img;
}
function custom_excerpt_length( $length ) {
return 60;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
// Replaces the excerpt "Read More" text by a link
function my_the_excerpt() {
$excerpt = get_the_excerpt();
$excerpt = strip_shortcodes($excerpt);
$excerpt = strip_tags($excerpt);
$excerpt = rtrim($excerpt,"[&#8230;] ");
//$excerpt = substr($excerpt, 0, 400);
//$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
//$excerpt = trim(preg_replace( '/s+/', ' ', $excerpt));
$excerpt = rtrim($excerpt,'[&amp;hellip]');
$excerpt = $excerpt.'... <a class="read-more" href="'.get_permalink().'">&nbsp;leer m&aacute;s</a>';
return $excerpt;
}
//add_filter('the_excerpt', 'my_the_excerpt', 5, 1);