Fix Jetpack comments redirect
This commit is contained in:
parent
5dab7fb87d
commit
09477722ce
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
function fictioneer_redirect_comment( $location, $commentdata ) {
|
||||
if ( ! isset( $commentdata ) || empty( $commentdata->comment_post_ID ) || ( $_REQUEST['for'] ?? 0 ) === 'jetpack' ) {
|
||||
if ( ! isset( $commentdata ) || empty( $commentdata->comment_post_ID ) ) {
|
||||
return $location;
|
||||
}
|
||||
|
||||
@ -30,6 +30,19 @@ function fictioneer_redirect_comment( $location, $commentdata ) {
|
||||
$order = fictioneer_sanitize_query_var( $_REQUEST['corder'] ?? 0, ['desc', 'asc'], get_option( 'comment_order' ) );
|
||||
$commentcode = wp_hash( $commentdata->comment_date_gmt );
|
||||
|
||||
if ( ( $_REQUEST['for'] ?? 0 ) === 'jetpack' ) {
|
||||
$location = get_option( 'default_comments_page', 'oldest' ) ?
|
||||
get_permalink( $commentdata->comment_post_ID ) . '#comments' : $location;
|
||||
|
||||
return add_query_arg(
|
||||
array(
|
||||
'corder' => $order,
|
||||
'commentcode' => $commentcode
|
||||
),
|
||||
$location
|
||||
);
|
||||
}
|
||||
|
||||
// Redirect to last page
|
||||
if ( $order === 'asc' && ! $commentdata->comment_parent ) {
|
||||
return add_query_arg(
|
||||
|
Loading…
x
Reference in New Issue
Block a user