web/wp-admin/includes/theme.php
branchwordpress
changeset 132 4d4862461b8d
parent 109 03b0d1493584
equal deleted inserted replaced
131:a4642baaf829 132:4d4862461b8d
    26 	$ct->stylesheet = $themes[$current_theme]['Stylesheet'];
    26 	$ct->stylesheet = $themes[$current_theme]['Stylesheet'];
    27 	$ct->screenshot = $themes[$current_theme]['Screenshot'];
    27 	$ct->screenshot = $themes[$current_theme]['Screenshot'];
    28 	$ct->description = $themes[$current_theme]['Description'];
    28 	$ct->description = $themes[$current_theme]['Description'];
    29 	$ct->author = $themes[$current_theme]['Author'];
    29 	$ct->author = $themes[$current_theme]['Author'];
    30 	$ct->tags = $themes[$current_theme]['Tags'];
    30 	$ct->tags = $themes[$current_theme]['Tags'];
       
    31 	$ct->theme_root = $themes[$current_theme]['Theme Root'];
       
    32 	$ct->theme_root_uri = $themes[$current_theme]['Theme Root URI'];
    31 	return $ct;
    33 	return $ct;
    32 }
    34 }
    33 
    35 
    34 /**
    36 /**
    35  * Remove a theme
    37  * Remove a theme
   113 	get_themes();
   115 	get_themes();
   114 	return $wp_broken_themes;
   116 	return $wp_broken_themes;
   115 }
   117 }
   116 
   118 
   117 /**
   119 /**
   118  * {@internal Missing Short Description}}
   120  * Get the Page Templates available in this theme
   119  *
   121  *
   120  * @since unknown
   122  * @since unknown
   121  *
   123  *
   122  * @return unknown
   124  * @return array Key is template name, Value is template name
   123  */
   125  */
   124 function get_page_templates() {
   126 function get_page_templates() {
   125 	$themes = get_themes();
   127 	$themes = get_themes();
   126 	$theme = get_current_theme();
   128 	$theme = get_current_theme();
   127 	$templates = $themes[$theme]['Template Files'];
   129 	$templates = $themes[$theme]['Template Files'];
   128 	$page_templates = array ();
   130 	$page_templates = array();
   129 
   131 
   130 	if ( is_array( $templates ) ) {
   132 	if ( is_array( $templates ) ) {
       
   133 		$base = array( trailingslashit(get_template_directory()), trailingslashit(get_stylesheet_directory()) );
       
   134 
   131 		foreach ( $templates as $template ) {
   135 		foreach ( $templates as $template ) {
   132 			$template_data = implode( '', file( WP_CONTENT_DIR.$template ));
   136 			$basename = str_replace($base, '', $template);
       
   137 
       
   138 			// don't allow template files in subdirectories
       
   139 			if ( false !== strpos($basename, '/') )
       
   140 				continue;
       
   141 
       
   142 			$template_data = implode( '', file( $template ));
   133 
   143 
   134 			$name = '';
   144 			$name = '';
   135 			if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) )
   145 			if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) )
   136 				$name = _cleanup_header_comment($name[1]);
   146 				$name = _cleanup_header_comment($name[1]);
   137 
   147 
   138 			if ( !empty( $name ) ) {
   148 			if ( !empty( $name ) ) {
   139 				$page_templates[trim( $name )] = basename( $template );
   149 				$page_templates[trim( $name )] = $basename;
   140 			}
   150 			}
   141 		}
   151 		}
   142 	}
   152 	}
   143 
   153 
   144 	return $page_templates;
   154 	return $page_templates;
   145 }
   155 }
   146 
   156 
       
   157 /**
       
   158  * Tidies a filename for url display by the theme editor.
       
   159  * 
       
   160  * @since 2.9.0
       
   161  * @private
       
   162  * 
       
   163  * @param string $fullpath Full path to the theme file
       
   164  * @param string $containingfolder Path of the theme parent folder
       
   165  * @return string
       
   166  */
       
   167 function _get_template_edit_filename($fullpath, $containingfolder) {
       
   168 	return str_replace(dirname(dirname( $containingfolder )) , '', $fullpath);
       
   169 }
       
   170 
   147 ?>
   171 ?>