Make WordPress Core


Ignore:
Timestamp:
04/29/2018 10:44:31 PM (6 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.
Merges [43025] and [43027] to the 4.9 branch.
Fixes #43872.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-includes/class-wp-theme.php

    r42243 r43028  
    10711071         * Filters list of page templates for a theme.
    10721072         *
     1073         * @since 4.9.6
     1074         *
     1075         * @param string[]     $post_templates Array of page templates. Keys are filenames,
     1076         *                                     values are translated names.
     1077         * @param WP_Theme     $this           The theme object.
     1078         * @param WP_Post|null $post           The post being edited, provided for context, or null.
     1079         * @param string       $post_type      Post type to get the templates for.
     1080         */
     1081        $post_templates = (array) apply_filters( 'theme_templates', $post_templates, $this, $post, $post_type );
     1082
     1083        /**
     1084         * Filters list of page templates for a theme.
     1085         *
    10731086         * The dynamic portion of the hook name, `$post_type`, refers to the post type.
    10741087         *
     
    10831096         * @param string       $post_type      Post type to get the templates for.
    10841097         */
    1085         return (array) apply_filters( "theme_{$post_type}_templates", $post_templates, $this, $post, $post_type );
     1098        $post_templates = (array) apply_filters( "theme_{$post_type}_templates", $post_templates, $this, $post, $post_type );
     1099
     1100        return $post_templates;
    10861101    }
    10871102
Note: See TracChangeset for help on using the changeset viewer.