Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function dez_get_custom_the_excerpt($limit='',$more='') {
- global $post;
- $thepostlink = '<a class="readmore" href="'. get_permalink() . '" title="' . the_title_attribute('echo=0') . '">';
- $custom_text = get_post_field('post_excerpt',$post->ID);
- $content = get_the_content();
- //if use manual excerpt
- if($custom_text) {
- if($more) {
- $excerpt = $custom_text . $thepostlink . $more . '</a>';
- } else {
- $excerpt = $custom_text;
- }
- } else {
- //check if its chinese character input
- $chinese_output = preg_match_all("/\p{Han}+/u", $post->post_content, $matches);
- if($chinese_output) {
- if($more) {
- $excerpt = mb_substr( get_the_excerpt(), 0, $limit*2 ) . '...' . $thepostlink . $more.'</a>';
- } else {
- $excerpt = mb_substr( get_the_excerpt(), 0, $limit*2 ) . '...';
- }
- } else {
- //remove caption tag
- $content_filter_cap = strip_shortcodes( $content );
- //remove email tag
- $pattern = "/[^@\s]*@[^@\s]*\.[^@\s]*/";
- $replacement = "";
- $content_filter = preg_replace($pattern, $replacement, $content_filter_cap);
- if($more) {
- $excerpt = wp_trim_words($content_filter, $limit) . $thepostlink.$more.'</a>';
- } else {
- $excerpt = wp_trim_words($content_filter, $limit);
- }
- }
- }
- return apply_filters('meso_get_custom_excerpt',$excerpt);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement