WordPress.org

Make WordPress Core

Ticket #21891: 21891.2.patch

File 21891.2.patch, 765 bytes (added by ethitter, 8 years ago)

Introduces the page_templates_to_remove filter

  • wp-includes/class-wp-theme.php

     
    948948                if ( $this->parent() )
    949949                        $page_templates += $this->parent()->get_page_templates();
    950950
     951                // Allow specific templates to be removed by providing their keys (file paths relative to theme directory).
     952                $templates_to_remove = apply_filters( 'page_templates_to_remove', array(), $this->get_stylesheet(), $this->get_template() );
     953                if ( is_array( $templates_to_remove ) ) {
     954                        foreach ( $templates_to_remove as $template_to_remove ) {
     955                                unset( $page_templates[ $template_to_remove ] );
     956                        }
     957                }
     958
    951959                return $page_templates;
    952960        }
    953961