WordPress.org

Make WordPress Core

Opened 7 weeks ago

Closed 6 days ago

#49374 closed enhancement (fixed)

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

Reported by: garrett-eclipse Owned by: 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 7 weeks 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 7 weeks 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 7 weeks ago.
After (special pages are denoted properly)

Download all attachments as: .zip

Change History (17)

@garrett-eclipse
7 weeks ago

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

@garrett-eclipse
7 weeks ago

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

@garrett-eclipse
7 weeks ago

After (special pages are denoted properly)

#1 @garrett-eclipse
7 weeks ago

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

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

#2 @garrett-eclipse
7 weeks ago

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

#3 @SergeyBiryukov
6 weeks ago

  • Milestone changed from Awaiting Review to 5.4

#4 @SergeyBiryukov
6 weeks 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
6 weeks 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
6 weeks 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
6 weeks 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.


10 days ago

#9 follow-up: @stiofansisland
10 days 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
8 days 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
8 days 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
8 days 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
7 days ago

  • Keywords dev-reviewed added; dev-feedback removed

#14 @SergeyBiryukov
6 days 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.

Note: See TracTickets for help on using tickets.