WordPress.org

Make WordPress Core

Changeset 34995


Ignore:
Timestamp:
10/09/2015 09:50:05 PM (3 years ago)
Author:
DrewAPicture
Message:

Template: Make it possible to both add and remove items from the page templates list using the theme_page_templates filter.

The theme_page_templates hook was originally added in [27297] as page_templates, and later renamed in [27470]. Previously, it was only possible to remove or rename page templates via this hook.

Fixes #13265. Fixes #25879.

File:
1 edited

Legend:

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

    r34912 r34995  
    10221022         * Filter list of page templates for a theme.
    10231023         *
    1024          * This filter does not currently allow for page templates to be added.
    1025          *
    10261024         * @since 3.9.0
     1025         * @since 4.4.0 Converted to allow complete control over the `$page_templates` array.
    10271026         *
    10281027         * @param array        $page_templates Array of page templates. Keys are filenames,
     
    10311030         * @param WP_Post|null $post           The post being edited, provided for context, or null.
    10321031         */
    1033         $return = apply_filters( 'theme_page_templates', $page_templates, $this, $post );
    1034 
    1035         return array_intersect_assoc( $return, $page_templates );
     1032        return (array) apply_filters( 'theme_page_templates', $page_templates, $this, $post );
    10361033    }
    10371034
Note: See TracChangeset for help on using the changeset viewer.