diff --git a/src/Model/UserSeo.php b/src/Model/UserSeo.php index 87de0b1..a71d762 100644 --- a/src/Model/UserSeo.php +++ b/src/Model/UserSeo.php @@ -119,12 +119,20 @@ protected function init() { $this->fields = array_merge( $this->fields, [ - 'breadcrumbTitle' => function (): ?string { + 'breadcrumbTitle' => function (): ?string { $title = $this->get_meta( 'breadcrumb_title', '', $this->data->display_name ); return ! empty( $title ) ? html_entity_decode( $title, ENT_QUOTES ) : null; }, - 'ID' => fn (): int => $this->database_id, + 'ID' => fn (): int => $this->database_id, + 'facebookProfileUrl' => fn (): ?string => get_user_meta( $this->database_id, 'facebook', true ) ?: null, + 'twitterUserName' => fn (): ?string => get_user_meta( $this->database_id, 'twitter', true ) ?: null, + 'additionalProfiles' => function (): ?array { + $additional_profiles = get_user_meta( $this->database_id, 'additional_profile_urls', true ); + + return ! empty( $additional_profiles ) ? explode( ' ', $additional_profiles ) : null; + }, + ] ); } diff --git a/src/Type/WPObject/SeoObjects.php b/src/Type/WPObject/SeoObjects.php index a8f8476..8215c1b 100644 --- a/src/Type/WPObject/SeoObjects.php +++ b/src/Type/WPObject/SeoObjects.php @@ -84,7 +84,20 @@ public static function register(): void { [ 'description' => __( 'The user object SEO data', 'wp-graphql-rank-math' ), 'interfaces' => [ Seo::get_type_name() ], - 'fields' => [], + 'fields' => [ + 'facebookProfileUrl' => [ + 'type' => 'String', + 'description' => __( 'The complete Facebook profile URL.', 'wp-graphql-rank-math' ), + ], + 'twitterUserName' => [ + 'type' => 'String', + 'description' => __( 'Twitter Username of the user.', 'wp-graphql-rank-math' ), + ], + 'additionalProfiles' => [ + 'type' => [ 'list_of' => 'String' ], + 'description' => __( 'Additional social profile URLs to add to the sameAs property.', 'wp-graphql-rank-math' ), + ], + ], 'eagerlyLoadType' => true, ] ); diff --git a/tests/functional/UserSeoQueryCept.php b/tests/functional/UserSeoQueryCept.php index 54de178..45dfa81 100644 --- a/tests/functional/UserSeoQueryCept.php +++ b/tests/functional/UserSeoQueryCept.php @@ -56,6 +56,11 @@ title } } + ... on RankMathUserSeo { + additionalProfiles + facebookProfileUrl + twitterUserName + } } } } @@ -94,7 +99,9 @@ $I->assertEquals( 'SUMMARY_LARGE_IMAGE', $response_array['data']['user']['seo']['openGraph']['twitterMeta']['card'] ); $I->assertEmpty( $response_array['data']['user']['seo']['openGraph']['twitterMeta']['description'] ); $I->assertEquals( 'testuser - Test', $response_array['data']['user']['seo']['openGraph']['twitterMeta']['title'] ); - +$I->assertEmpty( $response_array['data']['user']['seo']['additionalProfiles'] ); +$I->assertEmpty( $response_array['data']['user']['seo']['facebookProfileUrl'] ); +$I->assertEmpty( $response_array['data']['user']['seo']['twitterUserName'] ); diff --git a/tests/wpunit/UserSeoQueryTest.php b/tests/wpunit/UserSeoQueryTest.php index 9e6aa3e..428d413 100644 --- a/tests/wpunit/UserSeoQueryTest.php +++ b/tests/wpunit/UserSeoQueryTest.php @@ -65,6 +65,11 @@ public function testUserSeo() { } robots title + ... on RankMathUserSeo { + additionalProfiles + facebookProfileUrl + twitterUserName + } } } } @@ -103,6 +108,9 @@ public function testUserSeo() { ] ), $this->expectedField( 'title', 'display - Test' ), + $this->expectedField( 'additionalProfiles', static::IS_NULL ), + $this->expectedField( 'facebookProfileUrl', static::IS_NULL ), + $this->expectedField( 'twitterUserName', static::IS_NULL ), ] ), ] diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 5ea5fb4..727c398 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'axepress/wp-graphql-rank-math', 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => '61b4feb73cc74c89520312255ee233a3d270fff5', + 'reference' => '68c31b84bdd654febf24ebd5fd63e4ee1dd001d6', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -22,7 +22,7 @@ 'axepress/wp-graphql-rank-math' => array( 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => '61b4feb73cc74c89520312255ee233a3d270fff5', + 'reference' => '68c31b84bdd654febf24ebd5fd63e4ee1dd001d6', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),