src/includes/classes/Core/Paginator.php
public function links(): string
    {
        $first_page = 1; // Always `1` (first page).
        $last_page  = (int) ceil($this->found_rows / $this->per_page);

        // Note: `6` = Prev, [x], ..., ..., [x], Next.
        // Calculations below force a consistent menu width.
        // i.e., Always the same number of links in the menu.

        if ($last_page < ($this->range * 2) + 6) {
            $start_page = $first_page;
            $end_page   = $last_page;
        } elseif ($this->page < ($this->range * 2) + 1) {
            $start_page = $first_page;
            $end_page   = ($this->range * 2) + 3;
        } elseif ($this->page > $last_page - ($this->range * 2)) {
            $start_page = $last_page - ($this->range * 2) - 2;
            $end_page   = $last_page;
        } else {
            $start_page = $this->page - $this->range;
            $end_page   = $this->page + $this->range;
        }
        $start_page = max($first_page, $start_page);
        $end_page   = min($last_page, $end_page);

        $links = '<div class="'.$this->pages_class.'">';

        $links .= '<a class="-prev-page '.$this->c::escAttr($this->page === $first_page ? $this->page_icon_disabled_class : $this->page_icon_class).'"'.
                    ' href="'.$this->c::escUrl($this->page === $first_page ? '#' : $this->pageUrl($this->page - 1)).'">';
        $links .= $this->prev_page_icon.' '.$this->c::escHtml($this->prev_page_text);
        $links .= '</a>';

        if ($start_page > $first_page) {
            $links .= '<a class="-first-page '.$this->c::escAttr($this->page_class).'"'.
                        ' href="'.$this->c::escUrl($this->pageUrl($first_page)).'">';
            $links .= $this->first_page_icon.' '.$first_page;
            $links .= '</a>';

            $links .= '<span class="-ellipsis '.$this->c::escAttr($this->page_icon_disabled_class).'">';
            $links .= $this->ellipsis_icon;
            $links .= '</span>';
        }
        for ($_page = $start_page; $_page <= $end_page; ++$_page) {
            $links .= '<a class="-page '.$this->c::escAttr($_page === $this->page ? $this->page_active_class : $this->page_class).'"'.
                        ' href="'.$this->c::escUrl($_page === $this->page ? '#' : $this->pageUrl($_page)).'">';
            $links .= $_page;
            $links .= '</a>';
        }
        if ($end_page < $last_page) {
            $links .= '<span class="-ellipsis '.$this->c::escAttr($this->page_icon_disabled_class).'">';
            $links .= $this->ellipsis_icon;
            $links .= '</span>';

            $links .= '<a class="-last-page '.$this->c::escAttr($this->page_class).'"'.
                        ' href="'.$this->c::escUrl($this->pageUrl($last_page)).'">';
            $links .= $last_page.' '.$this->last_page_icon;
            $links .= '</a>';
        }
        $links .= '<a class="-next-page '.$this->c::escAttr($this->page === $last_page ? $this->page_icon_disabled_class : $this->page_icon_class).'"'.
                    ' href="'.$this->c::escUrl($this->page === $last_page ? '#' : $this->pageUrl($this->page + 1)).'">';
        $links .= $this->c::escHtml($this->next_page_text).' '.$this->next_page_icon;
        $links .= '</a>';

        $links .= '</div>';

        return $links;
    }
public function links(): string
    {
        $first_page = 1; // Always `1` (first page).
        $last_page  = (int) ceil($this->found_rows / $this->per_page);

        // Note: `6` = Prev, [x], ..., ..., [x], Next.
        // Calculations below force a consistent menu width.
        // i.e., Always the same number of links in the menu.

        if ($last_page < ($this->range * 2) + 6) {
            $start_page = $first_page;
            $end_page   = $last_page;
        } elseif ($this->page < ($this->range * 2) + 1) {
            $start_page = $first_page;
            $end_page   = ($this->range * 2) + 3;
        } elseif ($this->page > $last_page - ($this->range * 2)) {
            $start_page = $last_page - ($this->range * 2) - 2;
            $end_page   = $last_page;
        } else {
            $start_page = $this->page - $this->range;
            $end_page   = $this->page + $this->range;
        }
        $start_page = max($first_page, $start_page);
        $end_page   = min($last_page, $end_page);

        $links = '<div class="'.$this->pages_class.'">';

        $links .= '<a class="-prev-page '.$this->c::escAttr($this->page === $first_page ? $this->page_icon_disabled_class : $this->page_icon_class).'"'.
                    ' href="'.$this->c::escUrl($this->page === $first_page ? '#' : $this->pageUrl($this->page - 1)).'">';
        $links .= $this->prev_page_icon.' '.$this->c::escHtml($this->prev_page_text);
        $links .= '</a>';

        if ($start_page > $first_page) {
            $links .= '<a class="-first-page '.$this->c::escAttr($this->page_class).'"'.
                        ' href="'.$this->c::escUrl($this->pageUrl($first_page)).'">';
            $links .= $this->first_page_icon.' '.$first_page;
            $links .= '</a>';

            $links .= '<span class="-ellipsis '.$this->c::escAttr($this->page_icon_disabled_class).'">';
            $links .= $this->ellipsis_icon;
            $links .= '</span>';
        }
        for ($_page = $start_page; $_page <= $end_page; ++$_page) {
            $links .= '<a class="-page '.$this->c::escAttr($_page === $this->page ? $this->page_active_class : $this->page_class).'"'.
                        ' href="'.$this->c::escUrl($_page === $this->page ? '#' : $this->pageUrl($_page)).'">';
            $links .= $_page;
            $links .= '</a>';
        }
        if ($end_page < $last_page) {
            $links .= '<span class="-ellipsis '.$this->c::escAttr($this->page_icon_disabled_class).'">';
            $links .= $this->ellipsis_icon;
            $links .= '</span>';

            $links .= '<a class="-last-page '.$this->c::escAttr($this->page_class).'"'.
                        ' href="'.$this->c::escUrl($this->pageUrl($last_page)).'">';
            $links .= $last_page.' '.$this->last_page_icon;
            $links .= '</a>';
        }
        $links .= '<a class="-next-page '.$this->c::escAttr($this->page === $last_page ? $this->page_icon_disabled_class : $this->page_icon_class).'"'.
                    ' href="'.$this->c::escUrl($this->page === $last_page ? '#' : $this->pageUrl($this->page + 1)).'">';
        $links .= $this->c::escHtml($this->next_page_text).' '.$this->next_page_icon;
        $links .= '</a>';

        $links .= '</div>';

        return $links;
    }
Build pagination links.

@since 161006 Paginator.

@return string Pagination links.