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.

Built from https://develop.svn.wordpress.org/trunk@34995


git-svn-id: http://core.svn.wordpress.org/trunk@34960 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Drew Jaynes 2015-10-09 21:51:25 +00:00
parent 662ad721ec
commit 1b1e18027d
2 changed files with 3 additions and 6 deletions

View File

@ -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 );
}
/**

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34994';
$wp_version = '4.4-alpha-34995';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.