Easy Property Listings 3.5.16 Code Reference
  • Package
  • Class
  • Tree
  • Todo
  • Hook Reference

Packages

  • EPL
    • Admin
      • Actions
      • Classes
        • ContactsTable
        • EPL
          • Admin
            • Images
        • ReportsGraph
        • Welcome
      • Contacts
      • ContactsActions
      • ContactsFunctions
      • Elements
      • Functions
      • Help
      • HelpSingle
      • Menus
      • MenusAddons
      • MenusExtensions
      • MenusLicenses
      • Plugins
      • Reports
      • ReportsGraphing
      • User
    • Assets
      • ScriptsStyles
      • SVG
    • Classes
      • AuthorLoader
      • AuthorMeta
      • Contact
      • Cron
      • CustomPostType
      • Forms
      • License
      • ListingAdvanced
      • ListingElements
      • MetaboxesCustomFields
      • Pagination
      • PropertyMeta
      • RenderFields
      • RestAPI
      • Search
      • Session
      • Updater
    • Compatibility
      • Extensions
      • Functions
      • Shortcodes
    • Functions
      • Actions
      • ConditionalTags
      • ErrorTracking
      • Formatting
      • Front
      • Global
      • Install
      • Pagination
      • Settings
      • Templates
    • Hooks
      • EnergyCertificate
      • ExternalLinks
      • FloorPlan
      • Map
      • ReadMore
      • WebLink
    • Meta
      • InitCustomFields
      • Meta
    • PostTypes
      • Business
      • Commercial
      • CommercialLand
      • Contact
      • Functions
      • Land
      • Property
      • Rental
      • Rural
    • Shortcode
      • CommercialListingSearch
      • ContactForm
      • Listing
      • ListingAdvanced
      • ListingAuction
      • ListingCategory
      • ListingFeature
      • ListingLocation
      • ListingMetaDoc
      • ListingOpen
      • ListingResults
      • ListingSearch
      • Map
    • Taxonomy
      • BusinessCategories
      • ContactTag
      • Features
      • Location
    • Templates
      • Themes
        • iThemes
        • iThemesBuilder
    • Widget
      • Admin
        • Dashboard
      • Classes
        • Author
        • ContactCapture
        • Gallery
        • Listing
        • Search
      • Functions
  • None
  • WordPress
    • Session

Classes

  • EPL_Admin_Images
  • EPL_Advanced_Shortcode_Listing
  • EPL_Author
  • EPL_Author_Loader
  • EPL_Author_Meta
  • EPL_Contact
  • EPL_Contact_Reports_Table
  • EPL_CPT
  • EPL_Cron
  • EPL_FORM_BUILDER
  • EPL_Graph
  • EPL_License
  • EPL_Listing_Elements
  • EPL_METABOX
  • EPL_Pagination_Call
  • EPL_Property_Meta
  • EPL_Render_Fields
  • EPL_Rest_API
  • EPL_SEARCH
  • EPL_Search_Fields
  • EPL_Session
  • EPL_SL_Plugin_Updater
  • EPL_Welcome
  • EPL_Widget_Author
  • EPL_Widget_Contact_Capture
  • EPL_Widget_Property_Gallery
  • EPL_Widget_Property_Search
  • EPL_Widget_Recent_Property

Functions

  • EPL
  1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 
<?php
/**
 * Pagination option
 *
 * @package     EPL
 * @subpackage  Classes/Pagination
 * @copyright   Copyright (c) 2019, Merv Barrett
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       2.1
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * EPL_Pagination_Call Class
 *
 * @since 3.5.3 Check for class
 */
if ( ! class_exists( 'EPL_Pagination_Call' ) ) :
    /**
     * EPL_Pagination_Call Class
     *
     * @since 2.1
     * @since 3.4.0 Moved class to separate file.
     */
    class EPL_Pagination_Call {

        /**
         * Arguments
         *
         * @var array
         * @since  2.1
         */
        protected $args;

        /**
         * Get things started
         *
         * @param array $args Array of arguments.
         * @since  2.1
         */
        public function __construct( $args ) {
            $this->args = $args;
        }

        /**
         * Get the key
         *
         * @param string $key Key name.
         *
         * @return mixed
         * @since  2.1
         */
        public function __get( $key ) {
            return $this->args[ $key ];
        }

        /**
         * Get Pagination arguments
         *
         * @since  2.1
         */
        public function get_pagination_args() {
            global $numpages;

            $query = $this->query;

            switch ( $this->type ) {
                case 'multipart':
                    // Multipart page.
                    $posts_per_page = 1;
                    $paged          = max( 1, absint( get_query_var( 'page' ) ) );
                    $total_pages    = max( 1, $numpages );
                    break;
                case 'users':
                    // WP_User_Query.
                    $posts_per_page = $query->query_vars['number'];
                    $paged          = max( 1, floor( $query->query_vars['offset'] / $posts_per_page ) + 1 );
                    $total_pages    = max( 1, ceil( $query->total_users / $posts_per_page ) );
                    break;
                default:
                    // WP_Query.
                    $posts_per_page = intval( $query->get( 'posts_per_page' ) );
                    $paged          = max( 1, absint( $query->get( 'paged' ) ) );
                    $total_pages    = max( 1, absint( $query->max_num_pages ) );
                    break;
            }

            return array( $posts_per_page, $paged, $total_pages );
        }

        /**
         * Get the single pagination
         *
         * @param string $page page id.
         * @param string $raw_text text content.
         * @param array  $attr attributes of page.
         * @param string $format format of single page.
         * @param string $tag attributes of single page tag.
         *
         * @return string
         * @since  2.1
         */
        public function get_single( $page, $raw_text, $attr, $format = '%PAGE_NUMBER%', $tag = 'a' ) {
            if ( empty( $raw_text ) ) {
                return '';
            }

            $text = str_replace( $format, number_format_i18n( $page ), $raw_text );
            $text = apply_filters( 'epl_pagination_single_content_text', $text, $raw_text );

            $attr['href'] = $this->get_url( $page );

            list( $posts_per_page, $paged, $total_pages ) = $this->get_pagination_args();
            $tag = apply_filters( 'epl_pagination_single_tag', $tag, $page, $paged );

            return apply_filters( 'epl_pagination_single', epl_pagination_html( $tag, $attr, $text ), $page, $paged, $total_pages, $posts_per_page );
        }

        /**
         * Outputting content of dot sigle elements.
         *
         * @since  2.3.1
         * @param  string $tag        tag of single dot.
         * @param  string $content    content of single dot.
         * @param  array  $attributes attributes of single dot tag.
         * @return string
         */
        public function get_single_dot( $tag = 'span', $content = '...', array $attributes = array() ) {
            $tag        = apply_filters( 'epl_pagination_single_dot_tag', $tag );
            $content    = apply_filters( 'epl_pagination_single_dot_content', $content );
            $attributes = apply_filters( 'epl_pagination_single_dot_attributes', $attributes );

            $output = '<' . $tag;
            if ( is_array( $attributes ) && count( $attributes ) ) {
                foreach ( $attributes as $key => $value ) {
                    if ( ! empty( $key ) && ! empty( $value ) ) {
                        $output .= ' ' . $key . '="' . $value . '"';
                    }
                }
            }
            // Tag is self closed.
            if ( in_array( $tag, array( 'area', 'base', 'basefont', 'br', 'hr', 'input', 'img', 'link', 'meta' ), true ) ) {
                $output .= ' />';
            } else {
                // Tag is not self closed.
                $output .= '>' . $content . '</' . $tag . '>';
            }

            return apply_filters( 'epl_pagination_single_dot', $output );
        }

        /**
         * Get url
         *
         * @param string $page Page number.
         *
         * @return string
         *
         * @since 2.1
         * @since 3.5.1 Fixed shortcode pagination when permalinks are plain.
         * @since 3.5.3 Fixed sorting not working for pagination on shortcode.
         */
        public function get_url( $page ) {
            $link = ( 'multipart' === $this->type ) ? epl_get_multipage_link( $page ) : get_pagenum_link( $page );

            if ( $this->query->get( 'is_epl_shortcode' ) &&
                in_array( $this->query->get( 'epl_shortcode_name' ), epl_get_shortcode_list(), true ) ) {
                $permalink_structure = get_option( 'permalink_structure' );

                if ( empty( $permalink_structure ) ) {
                    $link = epl_add_or_update_params( $link, 'paged', $page );
                }
                $link = epl_add_or_update_params( $link, 'pagination_id', $this->query->get( 'instance_id' ) );
                $link = epl_add_or_update_params( $link, 'instance_id', $this->query->get( 'instance_id' ) );
            }

            return $link;
        }
    }
endif; // End class_exists check.
Easy Property Listings 3.5.16 Code Reference API documentation generated by ApiGen