query_vars["pagename"]; } elseif (is_single()) { $page = 'single'; } elseif (is_archive()) { $page = 'archive'; } elseif (is_search()) { $page = 'search'; } if ($page) echo 'class="page '. $page. '"'; } endif; // ********* DEPRECATED wp_title in 4.4 *********** if ( ! function_exists( 'dw_page_title') ) : function dw_page_title() { global $page, $paged; wp_title( '|', true, 'right' ); bloginfo( 'name' ); $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) echo " | $site_description"; if ( $paged >= 2 || $page >= 2 ) echo ' | ' . sprintf( __( 'Page %s', 'dw' ), max( $paged, $page ) ); } add_filter( 'document_title_separator', function () { return '|'; } ); endif; /*========= Wait until WP 4.4 ============ function filter_wp_title( $title, $sep ) { global $paged, $page; if ( is_feed() ) return $title; $title .= get_bloginfo( 'name' ); $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) $title = "$title $sep $site_description"; if ( $paged >= 2 || $page >= 2 ) $title = "$title $sep " . sprintf( __( 'Page %s', 'dw' ), max( $paged, $page ) ); return $title; } add_filter( 'wp_title', 'filter_wp_title', 10, 2 ); add_filter( 'document_title_separator', function () { return '|'; } ); */ if ( ! function_exists( 'dw_meta_desc') ) : function dw_meta_desc() { global $post; $post = get_post( $post ); setup_postdata( $post ); if ( is_single() || is_page() ) { $meta_desc_value = get_post_meta( $post->ID, 'meta_desc', true ); if ( $meta_desc_value !== '') { echo $meta_desc_value; } elseif ( $meta_desc_value == '') { $meta_excerpt = dw_good_excerpt(300); echo $meta_excerpt; } } } endif; if ( ! function_exists( 'dw_good_excerpt') ) : function dw_good_excerpt($length) { global $post; $text = $post->post_excerpt; if ( '' == $text ) { $text = get_the_content(''); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); } $text = strip_shortcodes($text); $text = strip_tags($text); $text = substr($text,0,$length); if ( strlen($text) < 15 ) { $text = the_title('', ' - ', false); } $allowed_end = array('.', '!', '?', '...'); $excerpt = reverse_strrchr($text, '.', 2); if( $excerpt ) { echo apply_filters('get_the_excerpt',$excerpt); } else { echo apply_filters('get_the_excerpt',$text); } } function reverse_strrchr($haystack, $needle, $trail) { return strrpos($haystack, $needle) ? substr($haystack, 0, strrpos($haystack, $needle) + $trail) : false; } endif; if ( ! function_exists( 'dw_excerpt') ) : function dw_excerpt($count){ $permalink = get_permalink($post->ID); $excerpt = get_the_content(); $excerpt = strip_tags($excerpt); $excerpt = substr($excerpt, 0, $count); $excerpt = $excerpt.'... more'; return $excerpt; } endif; if ( ! function_exists( 'dw_paging_nav' ) ) : function dw_paging_nav() { if ( $GLOBALS['wp_query']->max_num_pages < 2 ) { return; } $paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; $pagenum_link = html_entity_decode( get_pagenum_link() ); $query_args = array(); $url_parts = explode( '?', $pagenum_link ); if ( isset( $url_parts[1] ) ) { wp_parse_str( $url_parts[1], $query_args ); } $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link ); $pagenum_link = trailingslashit( $pagenum_link ) . '%_%'; $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : ''; $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%'; $links = paginate_links( array( 'base' => $pagenum_link, 'format' => $format, 'total' => $GLOBALS['wp_query']->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map( 'urlencode', $query_args ), 'prev_text' => __( '←  ', 'dw' ), 'next_text' => __( '  →', 'dw' ), ) ); if ( $links ) : ?> posted on  '; } elseif ( in_category( array( 'twitter', 'tumblr' ) )) { } else { echo '' . $categories_list . ''; } } endif; if ( ! function_exists( 'dw_posted_on' ) ) : function dw_posted_on() { return sprintf( __( ' %2$s by %3$s', 'daw' ), 'class="meta-prep meta-prep-author"', sprintf( '%3$s ', get_permalink(), esc_attr( get_the_time() ), get_the_date() ), sprintf( ' %3$s', get_author_posts_url( get_the_author_meta( 'ID' ) ), sprintf( esc_attr__( 'View all posts by %s', 'daw' ), get_the_author() ), get_the_author() ) ); } endif; if ( ! function_exists( 'dw_posted_in' ) ) : function dw_posted_in() { $tag_list = get_the_tag_list( '', ', ', '' ); if ( $tag_list ) { $utility_text = __( '%1$s and tagged %2$s. permalink.', 'dw' ); } else { $utility_text = __( '%1$s. permalink.', 'dw' ); } return sprintf( $utility_text, get_the_category_list( ', ' ), $tag_list, get_permalink(), the_title_attribute( 'echo=0' ), get_post_comments_feed_link() ); } endif; if ( ! function_exists( 'dw_get_next_attachment_url' ) ) : function dw_get_next_attachment_url() { global $post; $post = get_post( $post ); $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) ); foreach ( $attachments as $k => $attachment ) { if ( $attachment->ID == $post->ID ) break; } $k++; if ( isset( $attachments[ $k ] ) ) return get_attachment_link( $attachments[ $k ]->ID ); else return get_permalink( $post->post_parent ); } endif; if ( ! function_exists( 'dw_post_nav' ) ) : function dw_post_nav() { $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); $next = get_adjacent_post( false, '', false ); if ( ! $next && ! $previous ) { return; } ?> get_queried_object(); $terms = wp_get_object_terms( $post->ID, $taxonomy ); if ( isset( $current_term->taxonomy ) && $taxonomy == $current_term->taxonomy ) { foreach ( (array) $terms as $key => $term ) { if ( $term->term_id == $current_term->term_id ) { unset( $terms[$key] ); break; } } $text = $also_text; } $tlist = array(); $rel = 'category' == $taxonomy ? 'rel="category"' : 'rel="tag"'; foreach ( (array) $terms as $term ) { $tlist[] = '' . $term->name . ''; } if ( ! empty( $tlist ) ) return sprintf( $text, join( $glue, $tlist ) ); return ''; } endif; if ( ! function_exists( 'dw_comment' ) ) : function dw_comment( $comment, $args, $depth ) { $GLOBALS ['comment'] = $comment; ?>
  • id="li-comment-">
    %s:', 'daw' ), get_comment_author_link() ); ?>
    comment_approved == '0' ) : ?>
    $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  • '
    ' . ' ' . '
    ', 'email' => '
    ' . '
    ', 'url' => '
    ' . '
    ', ); return $fields; } add_filter( 'comment_form_defaults', 'dw_comment_form' ); function dw_comment_form( $args ) { $args['comment_field'] = '
    '; return $args; } add_action('comment_form', 'dw_comment_button' ); function dw_comment_button() { echo ''; }