[wp-trac] [WordPress Trac] #51081: Fatal Error - Undefined get_page_templates() in Customizer
WordPress Trac
noreply at wordpress.org
Thu Aug 20 14:38:13 UTC 2020
#51081: Fatal Error - Undefined get_page_templates() in Customizer
--------------------------------------+-----------------------------
Reporter: Howdy_McGee | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Customize | Version: 5.5
Severity: normal | Keywords:
Focuses: administration, template |
--------------------------------------+-----------------------------
I'm using the `display_post_states` filter hook to display assigned page
templates as "Post State" whenever they're listed. WordPress 5.5 breaks
this functionality when viewing The Customizer. The easiest way to
replicate this issue is to paste the following into any TwentyXX Theme:
{{{
/**
* Add assigned templates to Post States
* - https://developer.wordpress.org/reference/hooks/display_post_states/
*
* @param Array $post_states
*
* @return Array $post_states
*/
function prefix_page_template_labels( $post_states ) {
$page_templates = get_page_templates();
return $post_states;
}
add_filter( 'display_post_states', 'prefix_page_template_labels' );
}}}
At this point, when you go to The Customizer it throws a Fatal Error as
`get_page_templates()` is not defined.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51081>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list