Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#49374 closed enhancement (fixed)

Use get_post_states to denote special pages on the added menu item accordions

Reported by: garrett-eclipse's profile garrett-eclipse Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.4 Priority: normal
Severity: normal Version: 5.3
Component: Menus Keywords: has-patch has-screenshots commit fixed-major dev-reviewed
Focuses: ui, administration Cc:

Description

This is a follow-up ticket to #37782 which introduced the use of get_post_states to denote special pages in the menu editor. When a special page is selected and added to the menu now the item is just denoted as Page but would be nice to follow suit and denote it as appropriate (Front Page, Posts Page, Privacy Policy Page).

Attachments (3)

49374.diff (728 bytes) - added by garrett-eclipse 5 years ago.
Patch to denote special pages (Front Page, Posts Page and Privacy Policy Page) when inserted into the menu
Screen Shot 2020-02-06 at 12.11.51 AM.png (26.4 KB) - added by garrett-eclipse 5 years ago.
Before (All pages are just denoted as 'Page')
Screen Shot 2020-02-06 at 12.13.57 AM.png (38.0 KB) - added by garrett-eclipse 5 years ago.
After (special pages are denoted properly)

Download all attachments as: .zip

Change History (19)

@garrett-eclipse
5 years ago

Patch to denote special pages (Front Page, Posts Page and Privacy Policy Page) when inserted into the menu

@garrett-eclipse
5 years ago

Before (All pages are just denoted as 'Page')

@garrett-eclipse
5 years ago

After (special pages are denoted properly)

#1 @garrett-eclipse
5 years ago

  • Keywords has-patch has-screenshots needs-testing added

I've uploaded a patch and screenshots to illustrate the change.

#2 @garrett-eclipse
5 years ago

Also related to the Customizer ticket that's pending commit - #46829

#3 @SergeyBiryukov
5 years ago

  • Milestone changed from Awaiting Review to 5.4

#4 @SergeyBiryukov
5 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 47211:

Menus: Use get_post_states() to denote special pages on the added menu item accordions.

Front Page, Posts Page, or Privacy Policy Page should now be marked as such on the added menu items.

Props garrett-eclipse.
Fixes #49374.

#5 @SergeyBiryukov
5 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Since get_post_states() is only available in the admin, this is causing fatal errors on front end:

Fatal error: Uncaught Error: Call to undefined function get_post_states() in wp-includes/nav-menu.php:82

#6 @SergeyBiryukov
5 years ago

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

In 47213:

Menus: When adding a label for special pages in wp_setup_nav_menu_item(), check if get_post_states() is available, to avoid fatal errors on front end.

Fixes #49374.

#7 @garrett-eclipse
5 years ago

Thanks @SergeyBiryukov appreciate the catch, I overlooked that was also available to the front-end.

This ticket was mentioned in Slack in #core by pbiron. View the logs.


5 years ago

#9 follow-up: @stiofansisland
5 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

In the original use case for the get_post_states() function to add statuses to the pages backend is not escaped, this allowed several plugins to add hints to the output:
https://i.imgur.com/IvlbXQA.png

Now in the edit menu screen it is escaped which causes issues:
https://i.imgur.com/cYbF6sz.png

I would be nice to keep the hints but if not an option then esc_html() should be replaced with wp_strip_all_tags()

#10 in reply to: ↑ 9 @SergeyBiryukov
5 years ago

Replying to stiofansisland:

Now in the edit menu screen it is escaped which causes issues:
https://i.imgur.com/cYbF6sz.png

It would be nice to keep the hints but if not an option then esc_html() should be replaced with wp_strip_all_tags()

Thanks for catching that! Since we're in late RC stage for 5.4, going with the latter option for now seems safer.

#11 @SergeyBiryukov
5 years ago

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

In 47458:

Menus: When adding a label for special pages in wp_setup_nav_menu_item() strip all HTML tags, as the label is escaped on output.

Follow-up to [47211], [47213].

Props stiofansisland.
Fixes #49374.

#12 @SergeyBiryukov
5 years ago

  • Keywords commit fixed-major dev-feedback added; needs-testing removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for backporting to the 5.4 branch after a second committer's review.

#13 @whyisjake
5 years ago

  • Keywords dev-reviewed added; dev-feedback removed

#14 @SergeyBiryukov
5 years ago

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

In 47465:

Menus: When adding a label for special pages in wp_setup_nav_menu_item() strip all HTML tags, as the label is escaped on output.

Follow-up to [47211], [47213].

Props stiofansisland.
Reviewed by whyisjake, SergeyBiryukov.
Merges [47458] to the 5.4 branch.
Fixes #49374.

#15 @SergeyBiryukov
4 years ago

In 48619:

Posts, Post Types: Make get_post_states() available on frontend.

This allows special pages to be denoted as such when editing a menu in the Customizer.

This applies to the Front Page, Posts Page, and Privacy Policy Page.

Follow-up to [47211], [47213], [47763].

Props dlh, whyisjake, SergeyBiryukov.
Fixes #46829. See #49374.

#16 @SergeyBiryukov
4 years ago

In 48620:

Posts, Post Types: Move get_post_states() back to the admin for now, require the file in WP_Customize_Nav_Menus::customize_register() instead.

This provides a minor performance improvement by only running the function in contexts where it's needed.

Follow-up to [47211], [47213], [47763], [48619].

See #46829, #49374.

Note: See TracTickets for help on using tickets.