Shorten excerpts option has bug (with fix)
-
I have found a slight bug with the “Shorten excerpts” option.
When selecting the “Shorten to closest space/period” options the result is that this always happens to the excerpt even though the excerpt length is less than the value given in the “Excerpt length” option.
The fix is to alter the scu_element2() function in the lib.php plugin file as follows.
//excerpt function scu_element2() { global $post, $scu_layout, $scu_sc; $l = scu_val('excerptlength', $scu_layout); $filter = scu_val('filter', $scu_layout); //if (strlen($post->post_excerpt) > 1){ // $t = $post->post_excerpt; //}else{ //$t = $post->post_content; //} //main content field, strip all tags if ($filter == 1 or $filter == '') { $t = strip_shortcodes(strip_tags($post->post_content)); } //excerpt field, strip all tags if ($filter == 2) { $t = strip_shortcodes(strip_tags($post->post_excerpt)); } //meta data, full html if ($filter == 3) { $custom = get_post_custom($post->ID); $t = $custom['text'][0]; // $t = str_replace("\n", "<br />", $t); } //show with full html if ($filter == 4) { //warning apply filtersaddfilters outside $t, but is needed on the postpage $t = apply_filters('the_content', $post->post_content); // $t = strip_shortcodes(strip_tags($post->post_content)); // $t = strip_shortcodes($post->post_content); // $t = $post->post_content; // $t = str_replace("\n", "<br />", $t); } //excerpt field, full html if ($filter == 5) { $t = $post->post_excerpt; } //shorten to period if ($filter < 3) { if (strlen($t) > $l) { $cont = '...'; $period = scu_val('excerptshorten', $scu_layout); //period shorten if ($period == 1) { $p = strrpos(substr($t, 0, $l), '.'); if ($p > 0 and $p < $l and $l > 0) { $l = $p + 1; $cont = ''; } } //space shorten if ($period == 2) { $p = strrpos(substr($t, 0, $l), ' '); if ($p > 0 and $p < $l and $l > 0) { $l = $p + 1; //$cont = ''; } } //shorten if (strlen($t) > $l and $l > 0) { $t = substr($t, 0, $l) . $cont; } } } //add a read more link $pe = scu_val('postexcerpt', $scu_layout); if ($pe > 0) { $l = get_permalink($post->ID); $cl = 'scu-readmore'; $t .= ' <a class="' . $cl . '" ' . $style . ' href="' . $l . '">Read more</a>'; } return scu_div($t, 'scu-excerpt-layout' . $scu_layout, 2); }
https://www.ads-software.com/extend/plugins/site-creator-ultimate/
- The topic ‘Shorten excerpts option has bug (with fix)’ is closed to new replies.