I need to modify the way a Wordpress plugin (Paid Memberships Pro) displays an excerpt, which has actually become a 2 part question.
The first part: Can someone point me in the direction of info on properly modifying a plugin? Is there something similar to hooks/filters like you can use on core?
The fun part:
I want to modify this bit of code to make sure that only 1 paragraph is displayed, regardless of its length. If the paragraph is shorter than 55 characters, display the whole thing and nothing more. If more than 55 characters, display those 55 characters and nothing more.
Here's the code from the plugin:
//if show excerpts is set, return just the excerpt
if(pmpro_getOption("showexcerpts"))
{
//show excerpt
global $post;
if($post->post_excerpt)
{
//defined exerpt
$content = wpautop($post->post_excerpt);
}
elseif(strpos($content, "<span id=\"more-" . $post->ID . "\"></span>") !== false)
{
//more tag
$pos = strpos($content, "<span id=\"more-" . $post->ID . "\"></span>");
$content = wpautop(substr($content, 0, $pos));
}
elseif(strpos($content, 'class="more-link">') !== false)
{
//more link
$content = preg_replace("/\<a.*class\=\"more\-link\".*\>.*\<\/a\>/", "", $content);
}
else
{
//auto generated excerpt. pulled from wp_trim_excerpt
$content = strip_shortcodes( $content );
$content = str_replace(']]>', ']]>', $content);
$content = strip_tags($content);
$excerpt_length = apply_filters('excerpt_length', 55);
$words = preg_split("/[\n\r\t ]+/", $content, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
if ( count($words) > $excerpt_length ) {
array_pop($words);
$content = implode(' ', $words);
$content = $content . "... ";
} else {
$content = implode(' ', $words) . "... ";
}
$content = wpautop($content);
}
}
Thanks!