WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/23/2005 01:14:05 AM (15 years ago)
Author:
ryan
Message:

Gracefully handle the lack of themes in get_page_templates(). http://mosquito.wordpress.org/view.php?id=1153 Props: donncha

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r2432 r2474  
    627627    $page_templates = array();
    628628
    629     foreach ($templates as $template) {
    630         $template_data = implode('', file(ABSPATH . $template));
    631         preg_match("|Template Name:(.*)|i", $template_data, $name);
    632         preg_match("|Description:(.*)|i", $template_data, $description);
    633 
    634         $name = $name[1];
    635         $description = $description[1];
    636 
    637         if (! empty($name)) {
    638             $page_templates[trim($name)] = basename($template);
     629    if( is_array( $templates ) ) {
     630        foreach ($templates as $template) {
     631            $template_data = implode('', file(ABSPATH . $template));
     632            preg_match("|Template Name:(.*)|i", $template_data, $name);
     633            preg_match("|Description:(.*)|i", $template_data, $description);
     634
     635            $name = $name[1];
     636            $description = $description[1];
     637
     638            if (! empty($name)) {
     639                $page_templates[trim($name)] = basename($template);
     640            }
    639641        }
    640642    }
Note: See TracChangeset for help on using the changeset viewer.