Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- needs $theme_dir to be defined
- needs templates to have the Custom Page Template syntax
- <?php
- /*
- Template Name: My Custom Page
- */
- ##
- $templates = $this->get_page_templates();
- ##
- function get_page_templates() {
- $page_templates = array();
- $files = (array) glob(trailingslashit($theme_dir)."*.php",GLOB_BRACE);
- foreach ( $files as $full_path ) {
- if ( ! preg_match( '|Template Name:(.*)$|mi', file_get_contents( $full_path ), $header ) )
- continue;
- $file_chunks = explode(trailingslashit($theme_dir),$full_path);
- $array_k = $file_chunks[1];
- $page_templates[ $array_k ] = _cleanup_header_comment( $header[1] );
- }
- return $page_templates;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement