Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#34045 closed defect (bug) (fixed)

"Add New" button links to wrong location

Reported by: johnjamesjacoby's profile johnjamesjacoby Owned by: norcross's profile norcross
Milestone: 4.4 Priority: normal
Severity: normal Version: 4.4
Component: Posts, Post Types Keywords: has-patch
Focuses: administration Cc:

Description

When viewing wp-admin/post-new.php the "Add New" link in the h1 tag links to:
/wp-admin/post-new.php?post_type=page

Attachments (3)

Screen Shot 2015-09-27 at 2.28.37 PM.png (155.9 KB) - added by johnjamesjacoby 10 years ago.
Safari Inspector shot of UI & HTML
34041.01.patch (2.2 KB) - added by johnjamesjacoby 10 years ago.
First pass fix. Not confident in the approach, but it solves the problem.
30405-02.diff (426 bytes) - added by norcross 10 years ago.
Added a check for being on post-new.php and unsets the button

Download all attachments as: .zip

Change History (14)

@johnjamesjacoby
10 years ago

Safari Inspector shot of UI & HTML

#1 @johnjamesjacoby
10 years ago

This looks to be caused by the $post_new_file global getting overwritten by menu.php, as the URL in this link-button is influenced by whichever custom post type is positioned lastly in the admin menu.

#2 follow-up: @helen
10 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 4.4

There shouldn't an Add New link there in the first place, because that's already what you're doing.

@johnjamesjacoby
10 years ago

First pass fix. Not confident in the approach, but it solves the problem.

#3 in reply to: ↑ 2 @johnjamesjacoby
10 years ago

Replying to helen:

There shouldn't an Add New link there in the first place, because that's already what you're doing.

I'd considered this. There are many inconsistencies across objects in regard to this link placement specifically:

  • Media is similar to Posts/Pages
  • Plugins alternates between "Add New" "Upload Plugin" and "Browse"
  • Themes alternates between "Add New" "Upload Theme" and "Browse"
  • Users has no "Add New" link when viewing the "Add New User" page
  • Comments has no "Add New" link when editing a single comment
  • Tools and Settings are not applicable IMO

We could toggle the "Add New" links in question to be "All" links to take the user back instead. Or we could remove them entirely, which would give us a clean slate if we want to do anything else here later.

Last edited 10 years ago by johnjamesjacoby (previous) (diff)

#4 @afercia
10 years ago

I think this is because $post_new_file is now set also on the post-new.php screen because defined in menu.php after [33723]

#5 @helen
10 years ago

  • Owner set to norcross
  • Status changed from new to assigned

@norcross is currently patching.

@norcross
10 years ago

Added a check for being on post-new.php and unsets the button

#6 @norcross
10 years ago

  • Keywords has-patch added; needs-patch removed

added patch to remove the button on post-new.php. confirmed working as expected on new posts and pages

#7 @helen
10 years ago

There was no "Add New" link there previously, and there shouldn't be one there, so the goal now is to remove it again.

30405-02.diff is the most immediately obvious way to do it - $post_new_file gets redefined in other files, so unsetting it in this case is a way to accomplish this, and possibly is the right thing to do. However, looking at 34041.01.patch does make me wonder if maybe we shouldn't be reusing a global variable like this and if it was intentional or not. @wonderboymusic - was there a reason you reused that variable name in [33723]?

#8 @wonderboymusic
10 years ago

unintentional

#9 @SergeyBiryukov
10 years ago

  • Component changed from Administration to Posts, Post Types
  • Version set to trunk

#10 @helen
10 years ago

Going to combine the concepts behind both patches and commit.

#11 @helen
10 years ago

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

In 34723:

Don't show the "Add New" link on post-new.php.

Using the same $post_new_file global variable name in wp-admin/menu.php in [33723] was unintentional, but we're already unsetting other variables that are in global scope so we can just unset this one as well. Someday the admin menu won't be a big pile of sad and cryptic globals. Maybe.

props johnjamesjacoby, norcross.
fixes #34045.

Note: See TracTickets for help on using tickets.