Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#34045 closed defect (bug) (fixed)

"Add New" button links to wrong location

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

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 11 years ago.
Safari Inspector shot of UI & HTML
34041.01.patch​ (2.2 KB ) - added by johnjamesjacoby 11 years ago.
First pass fix. Not confident in the approach, but it solves the problem.
30405-02.diff​ (426 bytes ) - added by norcross 11 years ago.
Added a check for being on post-new.php and unsets the button

Download all attachments as: .zip

Change History (14)

@johnjamesjacoby
11 years ago

Safari Inspector shot of UI & HTML

#1 @johnjamesjacoby
11 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
11 years ago

  • Keywords needs-patch added
  • Milestone Awaiting Review → 4.4

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

@johnjamesjacoby
11 years ago

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

#3 in reply to: ↑ 2 @johnjamesjacoby
11 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 11 years ago by johnjamesjacoby (previous) (diff)

#4 @afercia
11 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
11 years ago

  • Owner set to norcross
  • Status new → assigned

@norcross is currently patching.

@norcross
11 years ago

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

#6 @norcross
11 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
11 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
11 years ago

unintentional

#9 @SergeyBiryukov
11 years ago

  • Component Administration → Posts, Post Types
  • Version → trunk

#10 @helen
11 years ago

Going to combine the concepts behind both patches and commit.

#11 @helen
11 years ago

  • Resolution → fixed
  • Status assigned → 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.