| Server IP : 87.229.120.60 / Your IP : 216.73.216.245 Web Server : Apache System : Linux outside 5.4.8_Algonet_ZeroMAC_0.9.4.8 #6 SMP Mon Feb 3 20:36:07 CET 2020 x86_64 User : server ( 1002) PHP Version : 8.3.20 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,curl_multi_exec,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/faktorteam/www/wp-content/plugins/wordpress-seo/src/presentations/ |
Upload File : |
<?php
namespace Yoast\WP\SEO\Presentations;
use Yoast\WP\SEO\Helpers\Pagination_Helper;
use Yoast\WP\SEO\Models\Indexable;
/**
* Class Archive_Adjacent.
*
* Presentation object for indexables.
*
* @property Indexable $model The indexable.
* @property Pagination_Helper $pagination The pagination helper. Should be defined in the parent
* class because of trait issues in PHP 5.6.
*/
trait Archive_Adjacent {
/**
* Sets the helpers for the trait.
*
* @required
*
* @codeCoverageIgnore
*
* @param Pagination_Helper $pagination The pagination helper.
*/
public function set_archive_adjacent_helpers( Pagination_Helper $pagination ) {
$this->pagination = $pagination;
}
/**
* Generates the rel prev.
*
* @return string
*/
public function generate_rel_prev() {
if ( $this->pagination->is_rel_adjacent_disabled() ) {
return '';
}
$current_page = \max( 1, $this->pagination->get_current_archive_page_number() );
// Check if there is a previous page.
if ( $current_page === 1 ) {
return '';
}
// Check if the previous page is the first page.
if ( $current_page === 2 ) {
return $this->get_permalink();
}
return $this->pagination->get_paginated_url( $this->get_permalink(), ( $current_page - 1 ) );
}
/**
* Generates the rel next.
*
* @return string
*/
public function generate_rel_next() {
if ( $this->pagination->is_rel_adjacent_disabled() ) {
return '';
}
$current_page = \max( 1, $this->pagination->get_current_archive_page_number() );
if ( $this->pagination->get_number_of_archive_pages() <= $current_page ) {
return '';
}
return $this->pagination->get_paginated_url( $this->get_permalink(), ( $current_page + 1 ) );
}
}