WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#36367 closed enhancement (fixed)

Give users control on the term redirect

Reported by: alexvandervegt Owned by: SergeyBiryukov
Milestone: 4.6 Priority: normal
Severity: normal Version: 4.4.2
Component: Taxonomy Keywords: has-patch
Focuses: administration Cc:

Description

This is a copy of an existing method inside the post.php

wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) );

https://github.com/WordPress/WordPress/pull/193

Attachments (1)

36367.diff (653 bytes) - added by DrewAPicture 4 years ago.

Download all attachments as: .zip

Change History (16)

#2 @joedolson
4 years ago

  • Focuses accessibility removed

#3 @SergeyBiryukov
4 years ago

  • Keywords needs-patch added

#4 follow-up: @SergeyBiryukov
4 years ago

Hi @alexvandervegt, thanks for the ticket! Would you like to add a patch?

Note that new filters need to be documented as per the documentation standards.

#5 @alexvandervegt
4 years ago

Here you go:

<?php
/**
 * Filter the taxonomy redirect destination URL.
 *
 * @since 4.5.0
 *
 * @param string $location  The destination URL.
 * @param object $tax       The taxonomy object.
 */
wp_redirect( apply_filters( 'redirect_term_location', $location, $tax ) );

#6 @DrewAPicture
4 years ago

@alexvandervegt Once you you update your PR with the docs changes, you can add .diff to the end of the PR URL to get a patch to upload to this ticket.

Version 0, edited 4 years ago by DrewAPicture (next)

#7 follow-up: @rmccue
4 years ago

(You can also use https://rmccue.io/patch/ to do that for you too. :) )

#8 @alexvandervegt
4 years ago

Here you go:

https://patch-diff.githubusercontent.com/raw/WordPress/WordPress/pull/195.diff

<?php
diff --git a/wp-admin/edit-tags.php b/wp-admin/edit-tags.php
index b953da6..14290e3 100644
--- a/wp-admin/edit-tags.php
+++ b/wp-admin/edit-tags.php
@@ -205,7 +205,15 @@
        if ( ! empty( $_REQUEST['paged'] ) ) {
                $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
        }
-       wp_redirect( $location );
+       /**
+        * Filter the taxonomy redirect destination URL.
+        *
+        * @since 4.5.0
+        * 
+        * @param string $location  The destination URL.
+        * @param object $tax       The taxonomy object.
+        */
+       wp_redirect( apply_filters( 'redirect_term_location', $location, $tax ) );
        exit;
 }
Last edited 4 years ago by alexvandervegt (previous) (diff)

#9 @alexvandervegt
4 years ago

  • Keywords needs-patch removed

#10 in reply to: ↑ 7 @alexvandervegt
4 years ago

Replying to rmccue:

(You can also use https://rmccue.io/patch/ to do that for you too. :) )

This does not work, it keeps loading at the end

#11 in reply to: ↑ 4 @alexvandervegt
4 years ago

  • Severity changed from normal to blocker

Replying to SergeyBiryukov:

Hi @alexvandervegt, thanks for the ticket! Would you like to add a patch?

Note that new filters need to be documented as per the documentation standards.

The patch is supplied 2 months ago, when will this be implemented?

We are still waiting desperately for this.

@DrewAPicture
4 years ago

#12 @DrewAPicture
4 years ago

  • Keywords has-patch added
  • Severity changed from blocker to normal

@alexvandervegt I've added your patch to the ticket. Can you explain a little bit about the use-case for this filter in this specific location?

#13 @alexvandervegt
4 years ago

Hi @DrewAPicture this is a copy of an existing method inside the post.php

<?php
wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) );

In my case we have a custom redirect scheme so we need to check for double slugs on taxonomies, I use the existing redirect_post_location for posts and this works awesome. However there was no likewise functionality for the taxonomy part so that's where the patch comes in.

#14 @SergeyBiryukov
4 years ago

  • Milestone changed from Awaiting Review to 4.6
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#15 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 37696:

Taxonomy: Introduce a redirect_term_location filter to change the redirect on term editing.

This complements the redirect_post_location filter added in [12260].

Props alexvandervegt.
Fixes #36367.

Note: See TracTickets for help on using tickets.