|
@@ -17,15 +17,40 @@ function dw_page_desc() {
|
|
|
global $post;
|
|
|
$post = get_post( $post );
|
|
|
setup_postdata( $post );
|
|
|
- $excerpt = get_the_excerpt();
|
|
|
+ $excerpt = dw_good_excerpt(115);
|
|
|
if (is_single()||is_page()){
|
|
|
if (get_post_meta($post->ID, "meta-desc", true) !='' )
|
|
|
echo get_post_meta($post->ID, "meta-desc", true);
|
|
|
- else echo substr(get_the_excerpt(), 0,60);;
|
|
|
+ else echo $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);
|
|
|
+ $allowed_end = array('.', '!', '?', '...');
|
|
|
+ $excerpt = reverse_strrchr($text, '.', 1);
|
|
|
+ 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);
|