Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#36367 closed enhancement (fixed)

Give users control on the term redirect

Reported by: alexvandervegt's profile alexvandervegt Owned by: sergeybiryukov's profile 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 8 years ago.

Download all attachments as: .zip

Change History (16)

#2 @joedolson
8 years ago

  • Focuses accessibility removed

#3 @SergeyBiryukov
8 years ago

  • Keywords needs-patch added

#4 follow-up: @SergeyBiryukov
8 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
8 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
8 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.

e.g. https://patch-diff.githubusercontent.com/raw/WordPress/WordPress/pull/193.diff

Last edited 8 years ago by DrewAPicture (previous) (diff)

#7 follow-up: @rmccue
8 years ago

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

#8 @alexvandervegt
8 years ago

Here you go:

<?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;
 }
Version 0, edited 8 years ago by alexvandervegt (next)

#9 @alexvandervegt
8 years ago

  • Keywords needs-patch removed

#10 in reply to: ↑ 7 @alexvandervegt
8 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
8 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
8 years ago

#12 @DrewAPicture
8 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
8 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
8 years ago

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

#15 @SergeyBiryukov
8 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.