Handler.php
1 month ago
ListingDateRangeFilterTrait.php
1 month ago
ListingDefinition.php
1 year ago
ListingRepository.php
1 month ago
PageLimit.php
2 years ago
index.php
3 years ago
PageLimit.php
37 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\Listing; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\WP\Functions as WPFunctions; |
| 9 | |
| 10 | class PageLimit { |
| 11 | const DEFAULT_LIMIT_PER_PAGE = 20; |
| 12 | |
| 13 | /** @var WPFunctions */ |
| 14 | private $wp; |
| 15 | |
| 16 | public function __construct( |
| 17 | WPFunctions $wp |
| 18 | ) { |
| 19 | $this->wp = $wp; |
| 20 | } |
| 21 | |
| 22 | public function getLimitPerPage($model = null) { |
| 23 | if ($model === null) { |
| 24 | return self::DEFAULT_LIMIT_PER_PAGE; |
| 25 | } |
| 26 | |
| 27 | $listingPerPage = $this->wp->getUserMeta( |
| 28 | $this->wp->getCurrentUserId(), |
| 29 | 'mailpoet_' . $model . '_per_page', |
| 30 | true |
| 31 | ); |
| 32 | return (!empty($listingPerPage)) |
| 33 | ? (int)$listingPerPage |
| 34 | : self::DEFAULT_LIMIT_PER_PAGE; |
| 35 | } |
| 36 | } |
| 37 |