WordPress.org

Make WordPress Core

Changeset 27470


Ignore:
Timestamp:
03/08/2014 04:18:30 AM (6 years ago)
Author:
nacin
Message:

Rename the new page_templates filter to theme_page_templates, and pass it a post object for proper context.

see #13265.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/meta-boxes.php

    r27325 r27470  
    706706        } // end empty pages check
    707707    } // end hierarchical check.
    708     if ( 'page' == $post->post_type && 0 != count( get_page_templates() ) ) {
     708    if ( 'page' == $post->post_type && 0 != count( get_page_templates( $post ) ) ) {
    709709        $template = !empty($post->page_template) ? $post->page_template : false;
    710710        ?>
  • trunk/src/wp-admin/includes/template.php

    r27401 r27470  
    742742 */
    743743function page_template_dropdown( $default = '' ) {
    744     $templates = get_page_templates();
     744    $templates = get_page_templates( get_post() );
    745745    ksort( $templates );
    746746    foreach ( array_keys( $templates ) as $template ) {
  • trunk/src/wp-admin/includes/theme.php

    r27369 r27470  
    7979 * @since 1.5.0
    8080 *
     81 * @param WP_Post|null $post Optional. The post being edited, provided for context.
    8182 * @return array Key is the template name, value is the filename of the template
    8283 */
    83 function get_page_templates() {
    84     return array_flip( wp_get_theme()->get_page_templates() );
     84function get_page_templates( $post = null ) {
     85    return array_flip( wp_get_theme()->get_page_templates( $post ) );
    8586}
    8687
  • trunk/src/wp-includes/class-wp-theme.php

    r27297 r27470  
    932932     * @access public
    933933     *
     934     * @param WP_Post|null $post Optional. The post being edited, provided for context.
    934935     * @return array Array of page templates, keyed by filename, with the value of the translated header name.
    935936     */
    936     public function get_page_templates() {
     937    public function get_page_templates( $post = null ) {
    937938        // If you screw up your current theme and we invalidate your parent, most things still work. Let it slide.
    938939        if ( $this->errors() && $this->errors()->get_error_codes() !== array( 'theme_parent_invalid' ) )
     
    962963
    963964        if ( $this->parent() )
    964             $page_templates += $this->parent()->get_page_templates();
     965            $page_templates += $this->parent()->get_page_templates( $post );
    965966
    966967        /**
     
    971972         * @since 3.9.0
    972973         *
    973          * @param array    $page_templates Array of page templates. Keys are filenames,
    974          *                                 values are translated names.
    975          * @param WP_Theme $this           The theme object.
     974         * @param array        $page_templates Array of page templates. Keys are filenames,
     975         *                                     values are translated names.
     976         * @param WP_Theme     $this           The theme object.
     977         * @param WP_Post|null $post           The post being edited, provided for context, or null.
    976978         */
    977         $return = apply_filters( 'page_templates', $page_templates, $this );
     979        error_log( serialize( $this ) );
     980        $return = apply_filters( 'theme_page_templates', $page_templates, $this, $post );
    978981        return array_intersect_assoc( $return, $page_templates );
    979982    }
  • trunk/src/wp-includes/post.php

    r27423 r27470  
    29492949    if ( !empty($page_template) && 'page' == $data['post_type'] ) {
    29502950        $post->page_template = $page_template;
    2951         $page_templates = wp_get_theme()->get_page_templates();
     2951        $page_templates = wp_get_theme()->get_page_templates( $post );
    29522952        if ( 'default' != $page_template && ! isset( $page_templates[ $page_template ] ) ) {
    29532953            if ( $wp_error )
Note: See TracChangeset for help on using the changeset viewer.