WordPress.org

Make WordPress Core

Ticket #13265: core-remove-page-templates.php

File core-remove-page-templates.php, 1.2 KB (added by downstairsdev, 7 years ago)

A plugin test case for the page_templates filter. Removes a page template that is used in the TwentyFourteen theme.

Line 
1<?php
2/**
3 * Plugin Name: Core Remove Page Templates
4 * Plugin URI: https://core.trac.wordpress.org/ticket/13265
5 * Description: This filters the page templates in TwentyFourteen.
6 * Version: 0.1
7 * Author: Devin Price
8 * Author URI: http://profiles.wordpress.org/downstairsdev/profile
9 *
10 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License version 2, as published by the Free Software Foundation.  You may NOT assume
12 * that you can use any other version of the GPL.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
15 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 *
17 */
18
19/**
20 * Filter Templates Page Templates
21 *
22 * @param array $templates Array of templates.
23 * @return array $templates Modified Array of templates.
24 */
25function crpt_page_templates( $templates ) {
26
27        // Unsets a template from TwentyFourteen
28        unset( $templates['page-templates/contributors.php'] );
29
30        // Unsets a template that doesn't exist, no error
31        unset( $templates['page-templates/ignore.php'] );
32
33        return $templates;
34}
35
36add_filter( 'page_templates', 'crpt_page_templates' );