Make WordPress Core

Changeset 43025


Ignore:
Timestamp:
04/29/2018 10:17:20 PM (8 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme.php

    r42876 r43025  
    11861186                 * Filters list of page templates for a theme.
    11871187                 *
     1188                 * @since 5.0.0
     1189                 *
     1190                 * @param string[]     $post_templates Array of page templates. Keys are filenames,
     1191                 *                                     values are translated names.
     1192                 * @param WP_Theme     $this           The theme object.
     1193                 * @param WP_Post|null $post           The post being edited, provided for context, or null.
     1194                 * @param string       $post_type      Post type to get the templates for.
     1195                 */
     1196                $post_templates = (array) apply_filters( 'theme_templates', $post_templates, $this, $post, $post_type );
     1197
     1198                /**
     1199                 * Filters list of page templates for a theme.
     1200                 *
    11881201                 * The dynamic portion of the hook name, `$post_type`, refers to the post type.
    11891202                 *
    … …  
    11981211                 * @param string       $post_type      Post type to get the templates for.
    11991212                 */
    1200                 return (array) apply_filters( "theme_{$post_type}_templates", $post_templates, $this, $post, $post_type );
     1213                $post_templates = (array) apply_filters( "theme_{$post_type}_templates", $post_templates, $this, $post, $post_type );
     1214
     1215                return $post_templates;
    12011216        }
    12021217
Note: See TracChangeset for help on using the changeset viewer.