From faed7981538e80b55779ff0837db361eafa1892d Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 23 Mar 2005 01:14:05 +0000 Subject: [PATCH] Gracefully handle the lack of themes in get_page_templates(). http://mosquito.wordpress.org/view.php?id=1153 Props: donncha git-svn-id: https://develop.svn.wordpress.org/trunk@2474 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/admin-functions.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 2c17efbf5b..6c67697614 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -626,16 +626,18 @@ function get_page_templates() { $templates = $themes[$theme]['Template Files']; $page_templates = array(); - foreach ($templates as $template) { - $template_data = implode('', file(ABSPATH . $template)); - preg_match("|Template Name:(.*)|i", $template_data, $name); - preg_match("|Description:(.*)|i", $template_data, $description); + if( is_array( $templates ) ) { + foreach ($templates as $template) { + $template_data = implode('', file(ABSPATH . $template)); + preg_match("|Template Name:(.*)|i", $template_data, $name); + preg_match("|Description:(.*)|i", $template_data, $description); - $name = $name[1]; - $description = $description[1]; + $name = $name[1]; + $description = $description[1]; - if (! empty($name)) { - $page_templates[trim($name)] = basename($template); + if (! empty($name)) { + $page_templates[trim($name)] = basename($template); + } } }