diff --git a/wp-facebook-ogp.php b/wp-facebook-ogp.php index d9e1dd2..0b49937 100644 --- a/wp-facebook-ogp.php +++ b/wp-facebook-ogp.php @@ -74,15 +74,15 @@ function wpfbogp_start_ob() { function wpfbogp_callback( $content ) { // Grab the page title and meta description $title = preg_match( '/(.*)<\/title>/', $content, $title_matches ); - $description = preg_match( '/<meta name="description" content="(.*)"/', $content, $description_matches ); + $description = preg_match( '/<meta name="description" content="(.*?)"/', $content, $description_matches ); // Take page title and meta description and place it in the ogp meta tags if ( $title !== FALSE && count( $title_matches ) == 2 ) { - $content = preg_replace( '/<meta property="og:title" content="(.*)">/', '<meta property="og:title" content="' . $title_matches[1] . '">', $content ); + $content = preg_replace( '/<meta property="og:title" content="(.*?)".*\/?>/', '<meta property="og:title" content="' . $title_matches[1] . '"/>', $content ); } - + if ( $description !== FALSE && count( $description_matches ) == 2 ) { - $content = preg_replace( '/<meta property="og:description" content="(.*)">/', '<meta property="og:description" content="' . $description_matches[1] . '">', $content ); + $content = preg_replace( '/<meta property="og:description" content="(.*?)".*\/?>/', '<meta property="og:description" content="' . $description_matches[1] . '"/>', $content ); } return $content;