From 1758d36a88bd2dbbc77bf22315f6cebc165ae0ee Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Fri, 9 Oct 2015 21:50:05 +0000 Subject: [PATCH] Template: Make it possible to both ''add'' and ''remove'' items from the page templates list using the `theme_page_templates` filter. The `theme_page_templates` hook was originally added in [27297] as `page_templates`, and later renamed in [27470]. Previously, it was only possible to remove or rename page templates via this hook. Fixes #13265. Fixes #25879. git-svn-id: https://develop.svn.wordpress.org/trunk@34995 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-theme.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/class-wp-theme.php b/src/wp-includes/class-wp-theme.php index 7bd9dca3bf..e7e142d6fb 100644 --- a/src/wp-includes/class-wp-theme.php +++ b/src/wp-includes/class-wp-theme.php @@ -1021,18 +1021,15 @@ final class WP_Theme implements ArrayAccess { /** * Filter list of page templates for a theme. * - * This filter does not currently allow for page templates to be added. - * * @since 3.9.0 + * @since 4.4.0 Converted to allow complete control over the `$page_templates` array. * * @param array $page_templates Array of page templates. Keys are filenames, * values are translated names. * @param WP_Theme $this The theme object. * @param WP_Post|null $post The post being edited, provided for context, or null. */ - $return = apply_filters( 'theme_page_templates', $page_templates, $this, $post ); - - return array_intersect_assoc( $return, $page_templates ); + return (array) apply_filters( 'theme_page_templates', $page_templates, $this, $post ); } /**