Skip to content

Commit

Permalink
Canonical urls on custom post type archive pages don't include the re…
Browse files Browse the repository at this point in the history
…quired URL variable (#1472)

* Canonical urls on custom post type archive pages don't include the required URL variable #491

* test case

* phpdoc

* phpdoc

* test failure
  • Loading branch information
contactashish13 authored and michaeltorbert committed Oct 12, 2018
1 parent 65d743a commit 0e96033
Show file tree
Hide file tree
Showing 5 changed files with 1,822 additions and 1,772 deletions.
25 changes: 16 additions & 9 deletions aioseop_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2686,6 +2686,9 @@ function aiosp_mrt_get_url( $query, $show_page = true ) {
return false;
}
$link = '';
// this boolean will determine if any additional parameters will be added to the final link or not.
// this is especially useful in issues such as #491.
$add_query_params = false;
$haspost = false;
if ( ! empty( $query->posts ) ) {
$haspost = count( $query->posts ) > 0;
Expand All @@ -2706,6 +2709,7 @@ function aiosp_mrt_get_url( $query, $show_page = true ) {
default:
return false;
}
$add_query_params = true;
} elseif ( $query->is_home && ( get_option( 'show_on_front' ) == 'page' ) && ( $pageid = get_option( 'page_for_posts' ) ) ) {
$link = aioseop_get_permalink( $pageid );
} elseif ( is_front_page() || ( $query->is_home && ( get_option( 'show_on_front' ) != 'page' || ! get_option( 'page_for_posts' ) ) ) ) {
Expand All @@ -2731,18 +2735,14 @@ function aiosp_mrt_get_url( $query, $show_page = true ) {
$link = get_tag_link( $tag->term_id );
}
} elseif ( $query->is_day && $haspost ) {
$link = get_day_link(
get_query_var( 'year' ),
get_query_var( 'monthnum' ),
get_query_var( 'day' )
);
$link = get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) );
$add_query_params = true;
} elseif ( $query->is_month && $haspost ) {
$link = get_month_link(
get_query_var( 'year' ),
get_query_var( 'monthnum' )
);
$link = get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) );
$add_query_params = true;
} elseif ( $query->is_year && $haspost ) {
$link = get_year_link( get_query_var( 'year' ) );
$add_query_params = true;
} elseif ( $query->is_tax && $haspost ) {
$taxonomy = get_query_var( 'taxonomy' );
$term = get_query_var( 'term' );
Expand All @@ -2764,6 +2764,13 @@ function aiosp_mrt_get_url( $query, $show_page = true ) {
$link = $this->get_paged( $link );
}

if ( $add_query_params ) {
$post_type = get_query_var( 'post_type' );
if ( ! empty( $post_type ) ) {
$link = add_query_arg( 'post_type', $post_type, $link );
}
}

return $link;
}

Expand Down
28 changes: 28 additions & 0 deletions js/modules/aioseop_module.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,34 @@ jQuery( document ).ready(
}
);

/**
* @summary workaround for bug that causes radio inputs to lose settings when meta box is dragged.
*
* props to commentluv for this fix
* @author commentluv.
* @link https://core.trac.wordpress.org/ticket/16972
* @since 1.0.0
*/
jQuery(document).ready(
function () {
// listen for drag drop of metaboxes , bind mousedown to .hndle so it only fires when starting to drag
jQuery('.hndle').mousedown(
function () {

// set live event listener for mouse up on the content .wrap and wait a tick to give the dragged div time to settle before firing the reclick function
jQuery('.wrap').mouseup(
function () {
aiosp_store_radio();
setTimeout(function () {
aiosp_reclick_radio();
}, 50);
}
);
}
);
}
);

/**
* @summary Javascript for using WP media uploader. Indentifies which DOM should use custom uploader plugin.
*
Expand Down
Loading

0 comments on commit 0e96033

Please sign in to comment.