class-schema-utils.php 752 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Frontend\Schema
  6. */
  7. /**
  8. * Schema utility functions.
  9. *
  10. * @since 11.6
  11. */
  12. class WPSEO_Schema_Utils {
  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 WPSEO_Schema_Context $context A value object with context variables.
  18. *
  19. * @return string The user's schema ID.
  20. */
  21. public static function get_user_schema_id( $user_id, $context ) {
  22. $user = get_userdata( $user_id );
  23. if ( is_object( $user ) && isset( $user->user_login ) ) {
  24. return $context->site_url . WPSEO_Schema_IDs::PERSON_HASH . wp_hash( $user->user_login . $user_id );
  25. }
  26. return $context->site_url . WPSEO_Schema_IDs::PERSON_HASH;
  27. }
  28. }