WP Facebook Open Graph protocol
[resolved] Problem with meta description due to substr() (3 posts)

  1. 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 ) );


    $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().



  2. Chuck Reynolds
    Plugin Author

    Posted 1 year ago #

    Hey, thanks for the post... 2.0.7 has some issues pulling meta description in very limited situations and never thought of the charset issue as being to blame for that but I assume in certain situations that could cause issues.

    If you'd like, and are comfortable, feel free to do a pull request https://github.com/chuckreynolds/WPFBOGP

    I'll work this into the beta and test a bit.

  3. ok great, I just made a pull request:


    Hopefully this will fix some of the empty meta description problems for other international users.



    Please consider using full PHP tags <?php ... ?> instead of <? ... ?>.

    These are the WordPress coding standard recommendations:


    It gave me some problems on my install ;-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Facebook Open Graph protocol
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic