diff --git a/includes/iworks/class-iworks-opengraph.php b/includes/iworks/class-iworks-opengraph.php index c6d21aa..45868a1 100644 --- a/includes/iworks/class-iworks-opengraph.php +++ b/includes/iworks/class-iworks-opengraph.php @@ -15,15 +15,16 @@ class iWorks_OpenGraph { /** * Schema.org mapping * + * @version 2.9.4 * @since 2.9.3 + * @since 2.9.4 Removes invalid `` (fixes iworks/og#9) */ private $schema_org_mapping = array( 'name' => array( 'og', 'title' ), 'headline' => array( 'og', 'blogdescription' ), 'description' => array( 'og', 'description' ), 'datePublished' => array( 'article', 'published_time' ), - 'dateModified' => array( 'article', 'modified_time' ), - 'author' => array( 'profile', 'username' ), + 'dateModified' => array( 'article', 'modified_time' ) ); /** @@ -291,7 +292,6 @@ public function wp_head() { 'tag' => array(), ), 'twitter' => array( - 'partner' => 'ogwp', 'site' => apply_filters( 'og_twitter_site', '' ), 'creator' => apply_filters( 'og_twitter_creator', '' ), 'widgets' => apply_filters( 'og_twitter_widgets', array() ), @@ -587,7 +587,7 @@ public function wp_head() { /** * og:profile */ - $og['article']['author'] = $this->get_the_author_meta_array( $post->post_author ); + $og['article']['author'] = $this->get_the_author_meta_array( $post->post_author )['username']; $og['profile'] = $this->get_the_author_meta_array( $post->post_author ); } /** @@ -884,7 +884,7 @@ public function wp_head() { /** * Twitter */ - foreach ( array( 'title', 'description', 'url' ) as $key ) { + foreach ( array( 'title', 'description' ) as $key ) { if ( isset( $og['og'][ $key ] ) ) { $og['twitter'][ $key ] = $og['og'][ $key ]; } @@ -903,15 +903,6 @@ public function wp_head() { } } } - /** - * site slogan - * - * @since 3.2.3 - */ - $og['schema']['tagline'] = apply_filters( - 'og_schema_tagline', - get_option( 'blogdescription' ) - ); } /** * Produce image extra tags @@ -1546,7 +1537,7 @@ private function get_type() { } /** - * get user array + * get user profile array * * @since 3.0.1 */ @@ -1554,17 +1545,31 @@ private function get_the_author_meta_array( $author_id ) { /** * Filter `og:profile` values. * + * @version 2.8.0 * @since 2.7.6 + * @since 2.8.0 Prevents leaking protected personal data (related to iworks/og#9) + * + * @link https://ogp.me/#type_profile + * @link https://developer.wordpress.org/reference/functions/get_the_author_meta/ * - * @param array Array of `og:profile` values. * @param integer User ID. + * @return array For `og:profile` and `og:article:author:` values. */ + $author_display_name = get_the_author_meta( 'display_name', $author_id ); + $author_first_name = get_the_author_meta( 'first_name', $author_id ); + $author_last_name = get_the_author_meta( 'last_name', $author_id ); + $author_nicename_is_fullname = ($author_display_name === $author_first_name.' '.$author_last_name ? true : false); + return apply_filters( 'og_profile', - array( - 'first_name' => get_the_author_meta( 'first_name', $author_id ), - 'last_name' => get_the_author_meta( 'last_name', $author_id ), - 'username' => get_the_author_meta( 'display_name', $author_id ), + ( $author_nicename_is_fullname ? + array( + 'first_name' => $author_first_name + ,'last_name' => $author_last_name + ,'username' => $author_display_name + ) : array( + 'username' => $author_display_name + ) ), $author_id );