WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#11870 closed defect (bug) (wontfix)

categories.php does not redirect to front-end.

Reported by: mfields Owned by: dancole
Milestone: Priority: normal
Severity: normal Version: 2.9.1
Component: Administration Keywords: close
Focuses: Cc:

Description

Hi, This is my first post here, so please go easy on me if I have done something incorrectly...

When I add a link to edit a category from my theme, Wordpress appears to be coded to allow me to redirect back to the page where the link was originally clicked. I believe that the logic in /wp-admin/categories.php is backwards thus always forcing redirect to categories.php.

The following code can be found starting on line 99 of /wp-admin/categories.php:

$location = 'categories.php';
if ( $referer = wp_get_original_referer() ) {
	if ( false !== strpos($referer, 'categories.php') )
		$location = $referer;
}

by changing this conditional statement:

if ( false !== strpos($referer, 'categories.php') )

to:

if ( false === strpos($referer, 'categories.php') )

The bug was fixed for me on 2.9.1

Attachments (2)

11870a.diff (431 bytes) - added by dancole 6 years ago.
Changes not an exact match to an exact match
11870b.diff (939 bytes) - added by scribu 6 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 follow-up: @dancole6 years ago

  • Keywords 2nd-opinion added; category redirect removed
  • Owner set to dancole
  • Status changed from new to assigned

I think your right, but I haven't tested it. It doesn't make sense to allow it to be anything but false with an exact match. Maybe I'm confused.. I'll attach a patch anyway and have someone else confirm this.

@dancole6 years ago

Changes not an exact match to an exact match

comment:2 follow-up: @scribu6 years ago

  • Keywords dev-feedback added; 2nd-opinion removed

The current code restricts redirection to the current admin page. I don't know why that restriction is in place. Perhaps someone has any info on that.

I do know that the proposed solution isn't good:

With the current patch, if you're on wp-admin/categories.php?pagenum=2 and you edit a category, you will loose the ?pagenum=2 part.

@scribu6 years ago

comment:3 follow-up: @scribu6 years ago

  • Keywords close added; dev-feedback removed

11870b.diff allows redirects to the front-end, but you lose the feedback, i.e. you won't know if the category edit was successful or not.

The only fix for that would be to reintroduce the "Go back" button, so I'm thinking wontfix for this ticket.

PS: You might want to try my Front-end Editor plugin. :)

comment:4 in reply to: ↑ 1 @mfields6 years ago

Replying to dancole:

I think your right, but I haven't tested it. It doesn't make sense to allow it to be anything but false with an exact match. Maybe I'm confused.. I'll attach a patch anyway and have someone else confirm this.

Thanks for the attention on this!

comment:5 in reply to: ↑ 2 @mfields6 years ago

Replying to scribu:

The current code restricts redirection to the current admin page. I don't know why that restriction is in place. Perhaps someone has any info on that.

I do know that the proposed solution isn't good:

With the current patch, if you're on wp-admin/categories.php?pagenum=2 and you edit a category, you will loose the ?pagenum=2 part.

Ahhh... good catch, My test installation did not have enough categories to test this - sorry for the oversight. I have reproduced this and have worked out another possible solution. I appears that the conditional statement may be able to be reduced. I have tested the following code in all known scenarios with success. It should replace the code I originally posted (Sorry, but I do not know how to make the .diff files yet - if I even have permissions for that kind of thing - new to all this)

if ( $referer = wp_get_original_referer() )
	$location = $referer;

comment:6 @scribu6 years ago

I think you missed this comment: 3

comment:7 in reply to: ↑ 3 @mfields6 years ago

Replying to scribu:

11870b.diff allows redirects to the front-end, but you lose the feedback, i.e. you won't know if the category edit was successful or not.

This can easily be introduced by customization via theme or plugin. Which IMO would be ok mainly due to the fact that a theme or plugin would need to provided the link to edit the category.

The only fix for that would be to reintroduce the "Go back" button, so I'm thinking wontfix for this ticket.

PS: You might want to try my Front-end Editor plugin. :)

Thanks for the link. I will definitely look into this.

comment:8 @markjaquith6 years ago

  • Resolution set to wontfix
  • Status changed from assigned to closed

Wontfix, for the reasons scribu noted.

comment:9 @filosofo6 years ago

  • Milestone Unassigned deleted
Note: See TracTickets for help on using tickets.