= 2 || $page >= 2 ) $title = "$title $sep " . sprintf( __( 'Page %s', 'daisy-blue' ), max( $paged, $page ) ); return $title; } add_filter( 'wp_title', 'daisyblue_wp_title', 10, 2 ); /** * Add and remove body_class() classes */ function daisyblue_body_class($classes) { // Add post/page slug if (is_single() || is_page() && !is_front_page()) { $classes[] = basename(get_permalink()); } // Remove unnecessary classes $home_id_class = 'page-id-' . get_option('page_on_front'); $remove_classes = array( 'page-template-default', $home_id_class ); $classes = array_diff($classes, $remove_classes); return $classes; } add_filter('body_class', 'daisyblue_body_class'); /** * add thumbnail class to image with caption */ function daisyblue_caption($output, $attr, $content) { if (is_feed()) { return $output; } $defaults = array( 'id' => '', 'align' => 'alignnone', 'width' => '', 'caption' => '' ); $attr = shortcode_atts($defaults, $attr); // If the width is less than 1 or there is no caption, return the content wrapped between the [caption] tags if ($attr['width'] < 1 || empty($attr['caption'])) { return $content; } // Set up the attributes for the caption
$attributes = (!empty($attr['id']) ? ' id="' . esc_attr($attr['id']) . '"' : '' ); $attributes .= ' class="thumbnail wp-caption ' . esc_attr($attr['align']) . '"'; $attributes .= ' style="width: ' . (esc_attr($attr['width']) + 10) . 'px"'; $output = ''; $output .= do_shortcode($content); $output .= '
' . $attr['caption'] . '
'; $output .= '
'; return $output; } add_filter('img_caption_shortcode', 'daisyblue_caption', 10, 3); /** * excerpt read more link */ function daisyblue_excerpt_more($more) { return ' … ' . __('Continued', 'daisy-blue') . ''; } add_filter('excerpt_more', 'daisyblue_excerpt_more'); /** * search form path */ function daisyblue_get_search_form($form) { $form = ''; locate_template('/templates/searchform.php', true, false); return $form; } add_filter('get_search_form', 'daisyblue_get_search_form'); /** * Breadcrumbs */ function daisyblue_breadcrumbs() { $showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show $delimiter = '/'; // delimiter between crumbs $home = ''; // text for the 'Home' link $showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show $before = '
  • '; // tag before the current crumb $after = '
  • '; // tag after the current crumb global $post; $homeLink = esc_url(home_url()); if (is_home() || is_front_page()) { if ($showOnHome == 1) echo ''; } else { echo ''; } } /** * Protected post/page form. */ function daisyblue_password_form() { global $post; $label = 'password-'.( empty( $post->ID ) ? rand() : $post->ID ); $password_form = '
    '.__('This post is password protected. To view it please enter your password below: ', 'daisy-blue').'
    '; return $password_form; } add_filter( 'the_password_form', 'daisyblue_password_form' ); /** * WordPress Bootstrap Pagination */ function daisyblue_pagination( $args = array() ) { $defaults = array( 'range' => 4, 'custom_query' => FALSE, 'previous_string' => '', 'next_string' => '', 'before_output' => '
    ' ); $args = wp_parse_args( $args, apply_filters( 'wp_bootstrap_pagination_defaults', $defaults ) ); $args['range'] = (int) $args['range'] - 1; if ( !$args['custom_query'] ) $args['custom_query'] = @$GLOBALS['wp_query']; $count = (int) $args['custom_query']->max_num_pages; $page = intval( get_query_var( 'paged' ) ); $ceil = ceil( $args['range'] / 2 ); if ( $count <= 1 ) return FALSE; if ( !$page ) $page = 1; if ( $count > $args['range'] ) { if ( $page <= $args['range'] ) { $min = 1; $max = $args['range'] + 1; } elseif ( $page >= ($count - $ceil) ) { $min = $count - $args['range']; $max = $count; } elseif ( $page >= $args['range'] && $page < ($count - $ceil) ) { $min = $page - $ceil; $max = $page + $ceil; } } else { $min = 1; $max = $count; } $echo = ''; $previous = intval($page) - 1; $previous = esc_attr( get_pagenum_link($previous) ); $firstpage = esc_attr( get_pagenum_link(1) ); if ( $firstpage && (1 != $page) ) $echo .= ''; if ( $previous && (1 != $page) ) $echo .= '
  • ' . $args['previous_string'] . '
  • '; if ( !empty($min) && !empty($max) ) { for( $i = $min; $i <= $max; $i++ ) { if ($page == $i) { $echo .= '
  • ' . str_pad( (int)$i, 2, '0', STR_PAD_LEFT ) . '
  • '; } else { $echo .= sprintf( '
  • %002d
  • ', esc_attr( get_pagenum_link($i) ), $i ); } } } $next = intval($page) + 1; $next = esc_attr( get_pagenum_link($next) ); if ($next && ($count != $page) ) $echo .= '
  • ' . $args['next_string'] . '
  • '; $lastpage = esc_attr( get_pagenum_link($count) ); if ( $lastpage ) { $echo .= ''; } if ( isset($echo) ) echo $args['before_output'] . $echo . $args['after_output']; }