| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentSupport\App\Models; |
| 4 |
|
| 5 |
use FluentSupport\Framework\Database\Orm\Model as BaseModel; |
| 6 |
|
| 7 |
class Model extends BaseModel |
| 8 |
{ |
| 9 |
protected $guarded = ['id', 'ID']; |
| 10 |
|
| 11 |
public function __construct($attributes = []) |
| 12 |
{ |
| 13 |
parent::__construct($attributes); |
| 14 |
} |
| 15 |
|
| 16 |
public function getPerPage() |
| 17 |
{ |
| 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']))); |
| 33 |
} |
| 34 |
} |
| 35 |
|