Нема описа

PageLimit.php 662B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace MailPoet\Listing;
  3. if (!defined('ABSPATH')) exit;
  4. use MailPoet\WP\Functions as WPFunctions;
  5. class PageLimit {
  6. const DEFAULT_LIMIT_PER_PAGE = 20;
  7. /** @var WPFunctions */
  8. private $wp;
  9. public function __construct(
  10. WPFunctions $wp
  11. ) {
  12. $this->wp = $wp;
  13. }
  14. public function getLimitPerPage($model = null) {
  15. if ($model === null) {
  16. return self::DEFAULT_LIMIT_PER_PAGE;
  17. }
  18. $listingPerPage = $this->wp->getUserMeta(
  19. $this->wp->getCurrentUserId(), 'mailpoet_' . $model . '_per_page', true
  20. );
  21. return (!empty($listingPerPage))
  22. ? (int)$listingPerPage
  23. : self::DEFAULT_LIMIT_PER_PAGE;
  24. }
  25. }