クラス WP_Theme::get_page_templates()
2014/12/17
WP_Theme::get_page_templates()
WP_Theme::定義ファイル : /blog/wp-includes/class-wp-theme.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | public function get_page_templates( $post = null ) { // If you screw up your current theme and we invalidate your parent, most things still work. Let it slide. if ( $this->errors() && $this->errors()->get_error_codes() !== array( 'theme_parent_invalid' ) ) return array(); $page_templates = $this->cache_get( 'page_templates' ); if ( ! is_array( $page_templates ) ) { $page_templates = array(); $files = (array) $this->get_files( 'php', 1 ); foreach ( $files as $file => $full_path ) { if ( ! preg_match( '|Template Name:(.*)$|mi', file_get_contents( $full_path ), $header ) ) continue; $page_templates[ $file ] = _cleanup_header_comment( $header[1] ); } $this->cache_add( 'page_templates', $page_templates ); } if ( $this->load_textdomain() ) { foreach ( $page_templates as &$page_template ) { $page_template = $this->translate_header( 'Template Name', $page_template ); } } if ( $this->parent() ) $page_templates += $this->parent()->get_page_templates( $post ); $return = apply_filters( 'theme_page_templates', $page_templates, $this, $post ); return array_intersect_assoc( $return, $page_templates ); } |