Changeset 12044 for trunk/wp-includes/theme.php
- Timestamp:
- 10/15/2009 09:07:00 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/theme.php
r12043 r12044 171 171 */ 172 172 function get_theme_data( $theme_file ) { 173 $default_headers = array( 174 'Name' => 'Theme Name', 175 'URI' => 'Theme URI', 176 'Description' => 'Description', 177 'Author' => 'Author', 178 'AuthorURI' => 'Author URI', 179 'Version' => 'Version', 180 'Template' => 'Template', 181 'Status' => 'Status', 182 'Tags' => 'Tags' 183 ); 184 173 185 $themes_allowed_tags = array( 174 186 'a' => array( … … 186 198 ); 187 199 188 $theme_data = implode( '', file( $theme_file ) ); 189 $theme_data = str_replace ( '\r', '\n', $theme_data ); 190 if ( preg_match( '|Theme Name:(.*)$|mi', $theme_data, $theme_name ) ) 191 $name = $theme = wp_kses( _cleanup_header_comment($theme_name[1]), $themes_allowed_tags ); 200 $theme_data = get_file_data( $theme_file, $default_headers, 'theme' ); 201 202 $theme_data['Name'] = $theme_data['Title'] = wp_kses( $theme_data['Name'], $themes_allowed_tags ); 203 204 $theme_data['URI'] = esc_url( $theme_data['URI'] ); 205 206 $theme_data['Description'] = wptexturize( wp_kses( $theme_data['Description'], $themes_allowed_tags ) ); 207 208 $theme_data['AuthorURI'] = esc_url( $theme_data['AuthorURI'] ); 209 210 $theme_data['Template'] = wp_kses( $theme_data['Template'], $themes_allowed_tags ); 211 212 $theme_data['Version'] = wp_kses( $theme_data['Version'], $themes_allowed_tags ); 213 214 if ( $theme_data['Status'] == '' ) 215 $theme_data['Status'] = 'publish'; 192 216 else 193 $ name = $theme = '';194 195 if ( preg_match( '|Theme URI:(.*)$|mi', $theme_data, $theme_uri ))196 $theme_ uri = esc_url( _cleanup_header_comment($theme_uri[1]));217 $theme_data['Status'] = wp_kses( $theme_data['Status'], $themes_allowed_tags ); 218 219 if ( $theme_data['Tags'] == '' ) 220 $theme_data['Tags'] = array(); 197 221 else 198 $theme_uri = ''; 199 200 if ( preg_match( '|Description:(.*)$|mi', $theme_data, $description ) ) 201 $description = wptexturize( wp_kses( _cleanup_header_comment($description[1]), $themes_allowed_tags ) ); 202 else 203 $description = ''; 204 205 if ( preg_match( '|Author URI:(.*)$|mi', $theme_data, $author_uri ) ) 206 $author_uri = esc_url( _cleanup_header_comment($author_uri[1]) ); 207 else 208 $author_uri = ''; 209 210 if ( preg_match( '|Template:(.*)$|mi', $theme_data, $template ) ) 211 $template = wp_kses( _cleanup_header_comment($template[1]), $themes_allowed_tags ); 212 else 213 $template = ''; 214 215 if ( preg_match( '|Version:(.*)|i', $theme_data, $version ) ) 216 $version = wp_kses( _cleanup_header_comment($version[1]), $themes_allowed_tags ); 217 else 218 $version = ''; 219 220 if ( preg_match('|Status:(.*)|i', $theme_data, $status) ) 221 $status = wp_kses( _cleanup_header_comment($status[1]), $themes_allowed_tags ); 222 else 223 $status = 'publish'; 224 225 if ( preg_match('|Tags:(.*)|i', $theme_data, $tags) ) 226 $tags = array_map( 'trim', explode( ',', wp_kses( _cleanup_header_comment($tags[1]), array() ) ) ); 227 else 228 $tags = array(); 229 230 if ( preg_match( '|Author:(.*)$|mi', $theme_data, $author_name ) ) { 231 if ( empty( $author_uri ) ) { 232 $author = wp_kses( _cleanup_header_comment($author_name[1]), $themes_allowed_tags ); 222 $theme_data['Tags'] = array_map( 'trim', explode( ',', wp_kses( $theme_data['Tags'], array() ) ) ); 223 224 if ( $theme_data['Author'] == '' ) { 225 $theme_data['Author'] = __('Anonymous'); 226 } else { 227 if ( empty( $theme_data['AuthorURI'] ) ) { 228 $theme_data['Author'] = wp_kses( $theme_data['Author'], $themes_allowed_tags ); 233 229 } else { 234 $ author = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $author_uri, __( 'Visit author homepage' ), wp_kses( _cleanup_header_comment($author_name[1]), $themes_allowed_tags ) );230 $theme_data['Author'] = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $theme_data['AuthorURI'], __( 'Visit author homepage' ), wp_kses( $theme_data['Author'], $themes_allowed_tags ) ); 235 231 } 236 } else {237 $author = __('Anonymous');238 232 } 239 233 240 return array( 'Name' => $name, 'Title' => $theme, 'URI' => $theme_uri, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Status' => $status, 'Tags' => $tags );234 return $theme_data; 241 235 } 242 236
Note: See TracChangeset
for help on using the changeset viewer.