Plugin Directory

Changeset 1538505


Ignore:
Timestamp:
11/22/2016 04:25:31 PM (9 years ago)
Author:
springthistle
Message:

Fixing the excerpt-generating aspect

Location:
aprils-call-posts/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • aprils-call-posts/trunk/ahs_callposts.php

    r1533885 r1538505  
    44Plugin URI: http://springthistle.com/wordpress/plugin_callposts
    55Description: Via shortcode, lets you call in a list of posts that are filtered, displayed and ordered based on criteria you provide. <a href="options-general.php?page=ahs_callposts_admin.php">Edit Settings</a>.
    6 Version: 2.0.11
     6Version: 2.0.12
    77Author: Aaron Hodge Silver
    88Author URI: http://springthistle.com/
     
    196196            $tmpl = str_replace('%%DATE%%',get_the_time($ahscpsett['dateformat'],$post->ID),$tmpl);
    197197
    198             if (strpos('/%%CONTENT/', $tmpl) !== FALSE) {
     198            if (strpos($tmpl, '%%CONTENT') !== FALSE) {
    199199                $content = get_the_content($ahscpsett['continue_text']);
    200200                $content = apply_filters('the_content', $content);
     
    205205            }
    206206
    207             if (strpos('/%%EXCERPT/', $tmpl) !== FALSE) {
     207            if (strpos($tmpl, '%%EXCERPT') !== FALSE) {
    208208                if (!empty($post->post_excerpt)) $excerpt = $post->post_excerpt;
    209                 else $excerpt = ahscp_excerpt($post->post_content);
     209                else $excerpt = get_the_excerpt($post);
    210210                $tmpl = str_replace('%%EXCERPT%%',$excerpt,$tmpl);
    211211            }
     
    232232                if (!empty($post->post_excerpt)) $excerpt = $post->post_excerpt;
    233233//                  else $excerpt = get_the_excerpt();
    234                 else $excerpt = ahscp_excerpt($post->post_content);
     234                else $excerpt = get_the_excerpt();
    235235                $out .= '<p>'.$excerpt.' '.$ahscpsett['pre_continue_text'].'<a href="'.get_permalink($post->ID).'">'.$ahscpsett['continue_text'].'</a></p>';
    236236            } else {
     
    274274
    275275    return $catids;
    276 }
    277 
    278 /*
    279  * ahscp_excerpt()
    280  * returns a string that is an excerpt of the post content. replaces get_the_excerpt() which was causing problems
    281  * @param string post_content
    282  * @returns string excerpt
    283  */
    284 function ahscp_excerpt($text) {
    285     $text = strip_tags($text);
    286     $text = preg_replace('/\[([^[])+\]/','',$text);
    287     $text = preg_replace("/\n|\r/"," ",$text);
    288     $text = ahscp_substrws($text,450);
    289     return $text;
    290 }
    291 
    292 /* Thanks, Benny. http://www.php.net/manual/en/function.substr.php#90724 */
    293 /**
    294 * word-sensitive substring function with html tags awareness
    295 * @param text The text to cut
    296 * @param len The maximum length of the cut string
    297 * @returns string
    298 **/
    299 function ahscp_substrws( $text, $len=180 ) {
    300 
    301     if ( (strlen($text) > $len) ) {
    302 
    303         $whitespaceposition = strpos($text," ",$len)-1;
    304 
    305         if ($whitespaceposition > 0)
    306             $text = substr($text, 0, ($whitespaceposition+1));
    307 
    308         // close unclosed html tags
    309         if (preg_match_all("|<([a-zA-Z]+)>|",$text,$aBuffer) ) {
    310             if( !empty($aBuffer[1]) ) {
    311                 preg_match_all("|</([a-zA-Z]+)>|",$text,$aBuffer2);
    312                 if( count($aBuffer[1]) != count($aBuffer2[1]) ) {
    313                     foreach( $aBuffer[1] as $index => $tag ) {
    314                         if( empty($aBuffer2[1][$index]) || $aBuffer2[1][$index] != $tag)
    315                             $text .= '</'.$tag.'>';
    316                     }
    317                 }
    318             }
    319         }
    320     }
    321 
    322     return $text;
    323276}
    324277
  • aprils-call-posts/trunk/readme.txt

    r1533885 r1538505  
    44Requires at least: 2.9.1
    55Tested up to: 4.6.1
    6 Stable tag: 2.0.11
     6Stable tag: 2.0.12
    77
    88Via shortcode, lets you call in a list of posts that are filtered, ordered, and displayed based on criteria you provide.
     
    4040
    4141== Changelog ==
     42
     43= 2.0.12 =
     44* Replaced a custom expert-generator with WordPress's built-in one, to solve efficiency issues.
    4245
    4346= 2.0.11 =
Note: See TracChangeset for help on using the changeset viewer.