WordPress.org

Ready to get started?Download WordPress

Forums

WP YouTube Lyte
[resolved] wp_trim_words fatal error (12 posts)

  1. armude
    Member
    Posted 1 year ago #

    it throws wp_trim_words fatal error

    http://wordpress.org/extend/plugins/wp-youtube-lyte/

  2. futtta
    Member
    Plugin Author

    Posted 1 year ago #

    That's weird, works as it should on my testblog.

    some questions:

    • What version of wordpress are you running?
    • What theme do you use?
    • Can you copy/ paste the fatal error message?
  3. armude
    Member
    Posted 1 year ago #

    I'm using wp 3.2.1 with the theme Wallow. The 1.2.1 and the 1.2.0 versions doesn't work, 1.1.9 works fine.

    This is the fatal error:
    Fatal error: Call to undefined function wp_trim_words() in /homepages/44/d453700350/htdocs/wp-content/plugins/wp-youtube-lyte/wp-youtube-lyte.php on line 298

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    wp_trim_words() is integrated to WordPress since: wp3.3.0

    time to upgrade your WordPress version...

  5. armude
    Member
    Posted 1 year ago #

    I dont want to upgrade my wp version, i'm fine with it. You should say that your plugin is not compatible with 3.2.1 since the 1.2.0 version, so the people who has the wp 3.2.1 wont update the plugin, it says that the 1.2.1 version is 100% compatible with wp 3.2.1, that is not true.

    Thanks.

  6. futtta
    Member
    Plugin Author

    Posted 1 year ago #

    You really should consider to upgrade armude (security concerns & stuff), but you are right that it should work with your version of WordPress.

    So here we go; open up /wp-content/plugins/wp-youtube-lyte/wp-youtube-lyte.php and replace

    function lyte_trim_excerpt($text) {
            global $post;
            if ( '' == $text ) {
                    $text = get_the_content('');
                    $text = lyte_parse($text, true);
                    $text = strip_shortcodes( $text );
                    $text = apply_filters('the_content', $text);
                    $text = str_replace(']]>', ']]>', $text);
                    $excerpt_length = apply_filters('excerpt_length', 55);
                    $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
                    $text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
            }
            return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
    }

    with:

    function lyte_trim_excerpt($text) {
            global $post;
            if ( '' == $text ) {
                    $text = get_the_content('');
                    $text = lyte_parse($text, true);
                    $text = strip_shortcodes( $text );
                    $text = apply_filters('the_content', $text);
                    $text = str_replace(']]>', ']]>', $text);
                    $excerpt_length = apply_filters('excerpt_length', 55);
                    $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
                    if (function_exists(wp_trim_words)) {
                            $text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
                    } else {
                            $text = substr( strip_tags(trim(preg_replace('/\s+/', ' ', $text))), 0, $excerpt_length );
                    }
            }
            return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
    }

    I'll make sure this gets into the next version, to ensure I don't break ancient versions of WordPress ;-)

  7. armude
    Member
    Posted 1 year ago #

    ok, thanks for the fix!!

    I have some mods in the theme and wordpress and if i upgrade WP i will lose all the mods, that's why i dont want to upgrade.

  8. armude
    Member
    Posted 1 year ago #

    The fix doesn't works well. I dont get the fatal error anymore, but the post excerpt doesnt works well. the web needs more time to load the content, its weird.

    you can see it here:
    http://www.armudepictures.es

  9. futtta
    Member
    Plugin Author

    Posted 1 year ago #

    Well, there's no reason why it would take longer to load. But I was trimming pretty harshly (characters instead of words), so replace:

    $text = substr( strip_tags(trim(preg_replace('/\s+/', ' ', $text))), 0, $excerpt_length );

    by

    $length=$excerpt_length*6;
    $text = substr( strip_tags(trim(preg_replace('/\s+/', ' ', $text))), 0, $length );
    $text .= $excerpt_more;
  10. armude
    Member
    Posted 1 year ago #

    Now it's working fine. Thanks!

  11. futtta
    Member
    Plugin Author

    Posted 1 year ago #

    You're welcome. I'll mention you in the liner-notes of the next release :-)

  12. futtta
    Member
    Plugin Author

    Posted 1 year ago #

    FYI: I just pushed out 1.2.2 which has amongst others this fix.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.