Themes: Introduce theme_templates filter for page templates of all post types.

This complements the `theme_{$post_type}_templates` dynamic filter added in [38951].

Props desrosj.
Merges [43025] and [43027] to the 4.9 branch.
Fixes #43872.
Built from https://develop.svn.wordpress.org/branches/4.9@43028


git-svn-id: http://core.svn.wordpress.org/branches/4.9@42857 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2018-04-29 22:45:24 +00:00
parent 13b6280373
commit 40bd08b50f
2 changed files with 17 additions and 2 deletions

View File

@ -1067,6 +1067,19 @@ final class WP_Theme implements ArrayAccess {
$post_templates = $this->get_post_templates();
$post_templates = isset( $post_templates[ $post_type ] ) ? $post_templates[ $post_type ] : array();
/**
* Filters list of page templates for a theme.
*
* @since 4.9.6
*
* @param string[] $post_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.
* @param string $post_type Post type to get the templates for.
*/
$post_templates = (array) apply_filters( 'theme_templates', $post_templates, $this, $post, $post_type );
/**
* Filters list of page templates for a theme.
*
@ -1082,7 +1095,9 @@ final class WP_Theme implements ArrayAccess {
* @param WP_Post|null $post The post being edited, provided for context, or null.
* @param string $post_type Post type to get the templates for.
*/
return (array) apply_filters( "theme_{$post_type}_templates", $post_templates, $this, $post, $post_type );
$post_templates = (array) apply_filters( "theme_{$post_type}_templates", $post_templates, $this, $post, $post_type );
return $post_templates;
}
/**

View File

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