| @@ -7,9 +7,28 @@ | ||
| 7 | 7 | class Model extends BaseModel |
| 8 | 8 | { |
| 9 | 9 | protected $guarded = ['id', 'ID']; |
| 10 | 10 | |
| 11 | + public function __construct($attributes = []) | |
| 12 | + { | |
| 13 | + parent::__construct($attributes); | |
| 14 | + } | |
| 15 | + | |
| 11 | 16 | public function getPerPage() |
| 12 | 17 | { |
| 13 | - return (isset($_REQUEST['per_page'])) ? intval($_REQUEST['per_page']) : 15; | |
| 18 | + if (!isset($_REQUEST['per_page'])) { | |
| 19 | + return 15; | |
| 20 | + } | |
| 21 | + | |
| 22 | + if (isset($_REQUEST['nonce'])) { | |
| 23 | + $nonceAction = (defined('REST_REQUEST') && REST_REQUEST) ? 'wp_rest' : 'fluent-support'; | |
| 24 | + | |
| 25 | + if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['nonce'])), $nonceAction)) { | |
| 26 | + return 15; | |
| 27 | + } | |
| 28 | + } elseif (is_admin() || wp_doing_ajax() || (defined('REST_REQUEST') && REST_REQUEST)) { | |
| 29 | + return intval(sanitize_text_field(wp_unslash($_REQUEST['per_page']))) ?? 15; | |
| 30 | + } | |
| 31 | + | |
| 32 | + return intval(sanitize_text_field(wp_unslash($_REQUEST['per_page']))); | |
| 14 | 33 | } |
| 15 | 34 | } |