WordPress.org

Support

Support » Plugins and Hacks » WP Facebook Open Graph protocol » [Resolved] Problem with meta description due to substr()

[Resolved] Problem with meta description due to substr()

  • Hi, thanks for this nice plugin.

    On some posts (written in Icelandic) I’ve noticed that the meta description is missing.

    This happens on wp 3.6.1 with plugin version 2.0.7.

    I’m not sure what exactly triggers this, but I managed to solve it by replacing this line:

    $description = str_replace( "\r\n", ' ' , substr( strip_tags( strip_shortcodes( $post->post_content ) ), 0, 160 ) );

    with:

    $charset = get_option( 'blog_charset' );
    if( ! $charset )
        $charset = 'UTF-8';
    
    $wpfbogp_description = str_replace( "\r\n", ' ' , mb_substr( strip_tags( strip_shortcodes( $post->post_content ) ), 0, 160, $charset ) );

    where I use mb_substr() instead of substr(), i.e. the multi-byte version of substr().

    cheers

    http://wordpress.org/plugins/wp-facebook-open-graph-protocol/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Problem with meta description due to substr()’ is closed to new replies.
Skip to toolbar