暫無描述

class-wp-user-request.php 2.1KB

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