Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e tests #212

Merged
merged 13 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions classes/class-archive-mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,13 @@ public function converting_load_more_and_infinite_paginate_next_page_to_friendly
* @return array
*/
public function converting_paginate_links_to_friendly_url( $arr, $args, $vp_options ) {
$permalink_structure = get_option( 'permalink_structure' );
// Determine if a page is an archive.
if (
self::is_archive( $vp_options ) &&
isset( $arr ) &&
! empty( $arr )
! empty( $arr ) &&
! empty( $permalink_structure )
) {
if ( $arr['url'] ) {
// Parsing the content of links.
Expand Down Expand Up @@ -1264,24 +1266,28 @@ private function get_relative_archive_link() {
* @return string
*/
private function converting_paginate_link_to_friendly_url( $link, $num_page = null ) {
// Parsing the content of links.
preg_match( '/vp_page=(\d+)/', $link, $match_vp_page );
preg_match( '/page\/(\d+)/', $link, $match_page );
$permalink_structure = get_option( 'permalink_structure' );

if ( empty( $num_page ) && is_array( $match_vp_page ) && ! empty( $match_vp_page ) ) {
$num_page = $match_vp_page[1];
}
if ( ! empty( $permalink_structure ) ) {
// Parsing the content of links.
preg_match( '/vp_page=(\d+)/', $link, $match_vp_page );
preg_match( '/page\/(\d+)/', $link, $match_page );

if ( ! empty( $num_page ) && is_array( $match_page ) && ! empty( $match_page ) ) {
$link = str_replace( $match_page[0], 'page/' . $num_page, $link );
}
if ( empty( $num_page ) && is_array( $match_vp_page ) && ! empty( $match_vp_page ) ) {
$num_page = $match_vp_page[1];
}

if ( ! empty( $num_page ) && empty( $match_page ) ) {
$link = str_replace( '/?', '/page/' . $num_page . '/?', $link );
}
if ( ! empty( $num_page ) && is_array( $match_page ) && ! empty( $match_page ) ) {
$link = str_replace( $match_page[0], 'page/' . $num_page, $link );
}

if ( ! empty( $num_page ) && empty( $match_page ) ) {
$link = str_replace( '/?', '/page/' . $num_page . '/?', $link );
}

if ( strpos( $link, 'vp_page' ) !== false ) {
$link = remove_query_arg( 'vp_page', $link );
if ( strpos( $link, 'vp_page' ) !== false ) {
$link = remove_query_arg( 'vp_page', $link );
}
}

return $link;
Expand All @@ -1298,9 +1304,10 @@ private function converting_paginate_link_to_friendly_url( $link, $num_page = nu
*/
private function convert_category_to_friendly_url( $category_url ) {
preg_match( '/vp_filter=([^&]*)/', $category_url, $match_filter );
$base_page = $this->get_relative_archive_link();
$base_page = $this->get_relative_archive_link();
$permalink_structure = get_option( 'permalink_structure' );

if ( is_array( $match_filter ) && ! empty( $match_filter ) ) {
if ( is_array( $match_filter ) && ! empty( $match_filter ) && ! empty( $permalink_structure ) ) {
// We extract the contents of the filter and form a new link.
$taxonomies = explode( ':', rawurldecode( $match_filter[1] ) );
if ( is_array( $taxonomies ) && 'portfolio_category' === $taxonomies[0] ) {
Expand Down
Loading
Loading