| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Helpers\Schema; |
| 4 |
|
| 5 |
use Yoast\WP\SEO\Config\Schema_IDs; |
| 6 |
use Yoast\WP\SEO\Context\Meta_Tags_Context; |
| 7 |
|
| 8 |
/** |
| 9 |
* Schema utility functions. |
| 10 |
*/ |
| 11 |
class ID_Helper { |
| 12 |
|
| 13 |
/** |
| 14 |
* Retrieve a users Schema ID. |
| 15 |
* |
| 16 |
* @param int $user_id The ID of the User you need a Schema ID for. |
| 17 |
* @param Meta_Tags_Context $context A value object with context variables. |
| 18 |
* |
| 19 |
* @return string The user's schema ID. |
| 20 |
*/ |
| 21 |
public function get_user_schema_id( $user_id, $context ) { |
| 22 |
$user = \get_userdata( $user_id ); |
| 23 |
if ( \is_a( $user, 'WP_User' ) ) { |
| 24 |
return $context->site_url . Schema_IDs::PERSON_HASH . \wp_hash( $user->user_login . $user_id ); |
| 25 |
} |
| 26 |
|
| 27 |
return ''; |
| 28 |
} |
| 29 |
} |
| 30 |
|