Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Frank Goossens

    (@futtta)

    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?
    Thread Starter armude

    (@armude)

    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

    Michael

    (@alchymyth)

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

    time to upgrade your WordPress version…

    Thread Starter armude

    (@armude)

    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.

    Plugin Author Frank Goossens

    (@futtta)

    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 ??

    Thread Starter armude

    (@armude)

    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.

    Thread Starter armude

    (@armude)

    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:
    https://www.armudepictures.es

    Plugin Author Frank Goossens

    (@futtta)

    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;
    Thread Starter armude

    (@armude)

    Now it’s working fine. Thanks!

    Plugin Author Frank Goossens

    (@futtta)

    You’re welcome. I’ll mention you in the liner-notes of the next release ??

    Plugin Author Frank Goossens

    (@futtta)

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

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘wp_trim_words fatal error’ is closed to new replies.