class-wp-user-request.php 1.9 KB

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