class-wp-user-request.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /**
  3. * WP_User_Request class.
  4. *
  5. * Represents user request data loaded from a WP_Post object.
  6. *
  7. * @since 4.9.6
  8. */
  9. #[AllowDynamicProperties]
  10. final class WP_User_Request {
  11. /**
  12. * Request ID.
  13. *
  14. * @since 4.9.6
  15. * @var int
  16. */
  17. public $ID = 0;
  18. /**
  19. * User ID.
  20. *
  21. * @since 4.9.6
  22. * @var int
  23. */
  24. public $user_id = 0;
  25. /**
  26. * User email.
  27. *
  28. * @since 4.9.6
  29. * @var string
  30. */
  31. public $email = '';
  32. /**
  33. * Action name.
  34. *
  35. * @since 4.9.6
  36. * @var string
  37. */
  38. public $action_name = '';
  39. /**
  40. * Current status.
  41. *
  42. * @since 4.9.6
  43. * @var string
  44. */
  45. public $status = '';
  46. /**
  47. * Timestamp this request was created.
  48. *
  49. * @since 4.9.6
  50. * @var int|null
  51. */
  52. public $created_timestamp = null;
  53. /**
  54. * Timestamp this request was last modified.
  55. *
  56. * @since 4.9.6
  57. * @var int|null
  58. */
  59. public $modified_timestamp = null;
  60. /**
  61. * Timestamp this request was confirmed.
  62. *
  63. * @since 4.9.6
  64. * @var int|null
  65. */
  66. public $confirmed_timestamp = null;
  67. /**
  68. * Timestamp this request was completed.
  69. *
  70. * @since 4.9.6
  71. * @var int|null
  72. */
  73. public $completed_timestamp = null;
  74. /**
  75. * Misc data assigned to this request.
  76. *
  77. * @since 4.9.6
  78. * @var array
  79. */
  80. public $request_data = array();
  81. /**
  82. * Key used to confirm this request.
  83. *
  84. * @since 4.9.6
  85. * @var string
  86. */
  87. public $confirm_key = '';
  88. /**
  89. * Constructor.
  90. *
  91. * @since 4.9.6
  92. *
  93. * @param WP_Post|object $post Post object.
  94. */
  95. public function __construct( $post ) {
  96. $this->ID = $post->ID;
  97. $this->user_id = $post->post_author;
  98. $this->email = $post->post_title;
  99. $this->action_name = $post->post_name;
  100. $this->status = $post->post_status;
  101. $this->created_timestamp = strtotime( $post->post_date_gmt );
  102. $this->modified_timestamp = strtotime( $post->post_modified_gmt );
  103. $this->confirmed_timestamp = (int) get_post_meta( $post->ID, '_wp_user_request_confirmed_timestamp', true );
  104. $this->completed_timestamp = (int) get_post_meta( $post->ID, '_wp_user_request_completed_timestamp', true );
  105. $this->request_data = json_decode( $post->post_content, true );
  106. $this->confirm_key = $post->post_password;
  107. }
  108. }