From 0c071471d6cae58efbf138252cd79210cb48e96c Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 29 Apr 2018 22:18:22 +0000 Subject: [PATCH] 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. Fixes #43872. Built from https://develop.svn.wordpress.org/trunk@43025 git-svn-id: http://core.svn.wordpress.org/trunk@42854 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-theme.php | 17 ++++++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php index 88e22758cf..45bf0ae4b5 100644 --- a/wp-includes/class-wp-theme.php +++ b/wp-includes/class-wp-theme.php @@ -1182,6 +1182,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 5.0.0 + * + * @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. * @@ -1197,7 +1210,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; } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 7b8d0a7381..003b1e2116 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '5.0-alpha-43024'; +$wp_version = '5.0-alpha-43025'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.