| @@ -12,9 +12,40 @@ | ||
| 12 | 12 | { |
| 13 | 13 | parent::__construct($attributes); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | + /** | |
| 17 | + * Dates go out as stored: site time, "Y-m-d H:i:s", like every other date | |
| 18 | + * column. The framework default is an ISO UTC moment, which made | |
| 19 | + * created_at/updated_at the only dates in another format. | |
| 20 | + * | |
| 21 | + * @param \DateTimeInterface $date | |
| 22 | + * @return string | |
| 23 | + */ | |
| 24 | + protected function serializeDate(\DateTimeInterface $date) | |
| 25 | + { | |
| 26 | + if ($date instanceof \DateTime || $date instanceof \DateTimeImmutable) { | |
| 27 | + $date = (clone $date)->setTimezone(wp_timezone()); | |
| 28 | + } | |
| 29 | + | |
| 30 | + return $date->format('Y-m-d H:i:s'); | |
| 31 | + } | |
| 32 | + | |
| 16 | 33 | public function getPerPage() |
| 17 | 34 | { |
| 18 | - return (isset($_REQUEST['per_page'])) ? intval($_REQUEST['per_page']) : 15; | |
| 35 | + if (!isset($_REQUEST['per_page'])) { | |
| 36 | + return 15; | |
| 37 | + } | |
| 38 | + | |
| 39 | + if (isset($_REQUEST['nonce'])) { | |
| 40 | + $nonceAction = (defined('REST_REQUEST') && REST_REQUEST) ? 'wp_rest' : 'fluent-support'; | |
| 41 | + | |
| 42 | + if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['nonce'])), $nonceAction)) { | |
| 43 | + return 15; | |
| 44 | + } | |
| 45 | + } elseif (is_admin() || wp_doing_ajax() || (defined('REST_REQUEST') && REST_REQUEST)) { | |
| 46 | + return intval(sanitize_text_field(wp_unslash($_REQUEST['per_page']))) ?? 15; | |
| 47 | + } | |
| 48 | + | |
| 49 | + return intval(sanitize_text_field(wp_unslash($_REQUEST['per_page']))); | |
| 19 | 50 | } |
| 20 | 51 | } |