diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-10-12 16:21:15 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-10-12 16:21:15 +0000 |
commit | 3a4570b0fc8b3d6339bef71d17d7701554e0bbf7 (patch) | |
tree | 2a06e5261263c68d8afd95a6328879dc289cb909 /wp-includes/theme.php | |
parent | b83c34a7010faee0223f6037025c350da12e05e6 (diff) | |
download | wordpress-mu-3a4570b0fc8b3d6339bef71d17d7701554e0bbf7.tar.gz wordpress-mu-3a4570b0fc8b3d6339bef71d17d7701554e0bbf7.tar.xz wordpress-mu-3a4570b0fc8b3d6339bef71d17d7701554e0bbf7.zip |
Merge with WP 2.3 - testing use only!
Move pluggable functions out of wpmu-functions and into pluggable.php, fixes #439
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1069 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/theme.php')
-rw-r--r-- | wp-includes/theme.php | 94 |
1 files changed, 63 insertions, 31 deletions
diff --git a/wp-includes/theme.php b/wp-includes/theme.php index f20ae68..3362c1d 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -56,35 +56,51 @@ function get_template_directory_uri() { } function get_theme_data( $theme_file ) { + $themes_allowed_tags = array( + 'a' => array( + 'href' => array(),'title' => array() + ), + 'abbr' => array( + 'title' => array() + ), + 'acronym' => array( + 'title' => array() + ), + 'code' => array(), + 'em' => array(), + 'strong' => array() + ); + $theme_data = implode( '', file( $theme_file ) ); - $theme_data = str_replace ( '\r', '\n', $theme_data ); - preg_match( '|Theme Name:(.*)|i', $theme_data, $theme_name ); - preg_match( '|Theme URI:(.*)|i', $theme_data, $theme_uri ); - preg_match( '|Description:(.*)|i', $theme_data, $description ); - preg_match( '|Author:(.*)|i', $theme_data, $author_name ); - preg_match( '|Author URI:(.*)|i', $theme_data, $author_uri ); - preg_match( '|Template:(.*)|i', $theme_data, $template ); + $theme_data = str_replace ( '\r', '\n', $theme_data ); + preg_match( '|Theme Name:(.*)$|mi', $theme_data, $theme_name ); + preg_match( '|Theme URI:(.*)$|mi', $theme_data, $theme_uri ); + preg_match( '|Description:(.*)$|mi', $theme_data, $description ); + preg_match( '|Author:(.*)$|mi', $theme_data, $author_name ); + preg_match( '|Author URI:(.*)$|mi', $theme_data, $author_uri ); + preg_match( '|Template:(.*)$|mi', $theme_data, $template ); + if ( preg_match( '|Version:(.*)|i', $theme_data, $version ) ) - $version = trim( $version[1] ); + $version = wp_kses( trim( $version[1] ), $themes_allowed_tags ); else - $version =''; + $version = ''; + if ( preg_match('|Status:(.*)|i', $theme_data, $status) ) - $status = trim($status[1]); + $status = wp_kses( trim( $status[1] ), $themes_allowed_tags ); else $status = 'publish'; - $description = wptexturize( trim( $description[1] ) ); + $name = $theme = wp_kses( trim( $theme_name[1] ), $themes_allowed_tags ); + $theme_uri = clean_url( trim( $theme_uri[1] ) ); + $description = wptexturize( wp_kses( trim( $description[1] ), $themes_allowed_tags ) ); + $template = wp_kses( trim( $template[1] ), $themes_allowed_tags ); - $name = $theme_name[1]; - $name = trim( $name ); - $theme = $name; - $theme_uri = trim( $theme_uri[1] ); - $template = trim( $template[1] ); + $author_uri = clean_url( trim( $author_uri[1] ) ); - if ( '' == $author_uri[1] ) { - $author = trim( $author_name[1] ); + if ( empty( $author_uri[1] ) ) { + $author = wp_kses( trim( $author_name[1] ), $themes_allowed_tags ); } else { - $author = '<a href="' . trim( $author_uri[1] ) . '" title="' . __('Visit author homepage') . '">' . trim( $author_name[1] ) . '</a>'; + $author = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $author_uri, __( 'Visit author homepage' ), wp_kses( trim( $author_name[1] ), $themes_allowed_tags ) ); } return array( 'Name' => $name, 'Title' => $theme, 'URI' => $theme_uri, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Status' => $status ); @@ -98,50 +114,55 @@ function get_themes() { $themes = array(); $wp_broken_themes = array(); - $theme_root = get_theme_root(); - $theme_loc = str_replace(ABSPATH, '', $theme_root); + $theme_loc = $theme_root = get_theme_root(); + if ( '/' != ABSPATH ) // don't want to replace all forward slashes, see Trac #4541 + $theme_loc = str_replace(ABSPATH, '', $theme_root); // Files in wp-content/themes directory and one subdir down - $themes_dir = @ dir($theme_root); + $themes_dir = @ opendir($theme_root); if ( !$themes_dir ) return false; - while ( ($theme_dir = $themes_dir->read()) !== false ) { + while ( ($theme_dir = readdir($themes_dir)) !== false ) { if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) { if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) continue; - $stylish_dir = @ dir($theme_root . '/' . $theme_dir); + $stylish_dir = @ opendir($theme_root . '/' . $theme_dir); $found_stylesheet = false; - while ( ($theme_file = $stylish_dir->read()) !== false ) { + while ( ($theme_file = readdir($stylish_dir)) !== false ) { if ( $theme_file == 'style.css' ) { $theme_files[] = $theme_dir . '/' . $theme_file; $found_stylesheet = true; break; } } + @closedir($stylish_dir); if ( !$found_stylesheet ) { // look for themes in that dir $subdir = "$theme_root/$theme_dir"; $subdir_name = $theme_dir; - $theme_subdir = @dir( $subdir ); - while ( ($theme_dir = $theme_subdir->read()) !== false ) { + $theme_subdir = @ opendir( $subdir ); + while ( ($theme_dir = readdir($theme_subdir)) !== false ) { if ( is_dir( $subdir . '/' . $theme_dir) && is_readable($subdir . '/' . $theme_dir) ) { if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) continue; - $stylish_dir = @ dir($subdir . '/' . $theme_dir); + $stylish_dir = @ opendir($subdir . '/' . $theme_dir); $found_stylesheet = false; - while ( ($theme_file = $stylish_dir->read()) !== false ) { + while ( ($theme_file = readdir($stylish_dir)) !== false ) { if ( $theme_file == 'style.css' ) { $theme_files[] = $subdir_name . '/' . $theme_dir . '/' . $theme_file; $found_stylesheet = true; break; } } + @closedir($stylish_dir); } } + @closedir($theme_subdir); $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.')); } } } + @closedir($theme_dir); if ( !$themes_dir || !$theme_files ) return $themes; @@ -189,7 +210,7 @@ function get_themes() { if ( !file_exists("$theme_root/$template/index.php") ) { $parent_dir = dirname(dirname($theme_file)); if ( file_exists("$theme_root/$parent_dir/$template/index.php") ) { - $template = "$parent_dir/$template"; + $template = "$parent_dir/$template"; } else { $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.')); continue; @@ -330,6 +351,17 @@ function get_category_template() { return apply_filters('category_template', $template); } +function get_tag_template() { + $template = ''; + if ( file_exists(TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php') ) + $template = TEMPLATEPATH . "/tag-" . get_query_var('tag') . '.php'; + elseif ( file_exists(TEMPLATEPATH . "/tag.php") ) + $template = TEMPLATEPATH . "/tag.php"; + + return apply_filters('tag_template', $template); +} + + function get_date_template() { return get_query_template('date'); } @@ -400,7 +432,7 @@ function get_comments_popup_template() { function load_template($_template_file) { global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query, - $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment; + $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID; if ( is_array($wp_query->query_vars) ) extract($wp_query->query_vars, EXTR_SKIP); |