Ticket #15858: 15858.2.diff
File 15858.2.diff, 16.0 KB (added by , 13 years ago) |
---|
-
wp-includes/theme.php
178 178 * @since 1.5.0 179 179 * 180 180 * @param string $theme_file Theme file path. 181 * @param bool $markup Optional. If the returned data should have HTML markup applied. Defaults to true. 182 * @param bool $translate Optional. If the returned data should be translated. Defaults to false. 183 * Note this is unlike the $translate parameter for get_plugin_data(), which defaults to true. 181 184 * @return array Theme data. 182 185 */ 183 function get_theme_data( $theme_file ) {186 function get_theme_data( $theme_file, $markup = true, $translate = false ) { 184 187 $default_headers = array( 185 188 'Name' => 'Theme Name', 186 189 'URI' => 'Theme URI', 187 190 'Description' => 'Description', 188 191 'Author' => 'Author', 189 192 'AuthorURI' => 'Author URI', 193 'TextDomain' => 'Text Domain', 194 'DomainPath' => 'Domain Path', 190 195 'Version' => 'Version', 191 196 'Template' => 'Template', 192 197 'Status' => 'Status', 193 198 'Tags' => 'Tags' 194 199 ); 195 200 196 $themes_allowed_tags = array(197 'a' => array(198 'href' => array(),'title' => array()199 ),200 'abbr' => array(201 'title' => array()202 ),203 'acronym' => array(204 'title' => array()205 ),206 'code' => array(),207 'em' => array(),208 'strong' => array()209 );210 211 201 $theme_data = get_file_data( $theme_file, $default_headers, 'theme' ); 212 202 213 $theme_data ['Name'] = $theme_data['Title'] = wp_kses( $theme_data['Name'], $themes_allowed_tags);203 $theme_data = _get_theme_data_markup_translate( $theme_file, $theme_data, $markup, $translate ); 214 204 215 $theme_data['URI'] = esc_url( $theme_data['URI'] ); 205 return $theme_data; 206 } 216 207 217 $theme_data['Description'] = wptexturize( wp_kses( $theme_data['Description'], $themes_allowed_tags ) ); 208 /** 209 * Sanitizes theme data, optionally adds markup, optionally translates. 210 * 211 * @since 3.4.0 212 * @access private 213 * @see get_theme_data() 214 */ 215 function _get_theme_data_markup_translate( $theme_file, $theme_data, $markup = true, $translate = true ) { 218 216 219 $theme_data['AuthorURI'] = esc_url( $theme_data['AuthorURI'] ); 217 // Translate fields 218 if ( $translate && $textdomain = $theme_data['TextDomain'] ) { 219 if ( $theme_data['DomainPath'] ) 220 load_theme_textdomain( $textdomain, dirname( $theme_file ) . $theme_data['DomainPath'] ); 221 else 222 load_theme_textdomain( $textdomain, dirname( $theme_file ) ); 220 223 221 $theme_data['Template'] = wp_kses( $theme_data['Template'], $themes_allowed_tags ); 224 foreach ( array( 'Name', 'URI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) 225 $theme_data[ $field ] = translate( $theme_data[ $field ], $textdomain ); 226 } 222 227 223 $theme_data['Version'] = wp_kses( $theme_data['Version'], $themes_allowed_tags ); 228 $allowed_tags = $allowed_tags_in_links = array( 229 'abbr' => array( 'title' => array() ), 230 'acronym' => array( 'title' => array() ), 231 'code' => array(), 232 'em' => array(), 233 'strong' => array(), 234 ); 235 $allowed_tags['a'] = array( 'href' => array(), 'title' => array() ); 224 236 225 if ( $theme_data['Status'] == '' ) 237 // Sanitized all displayed data. 238 239 // Author and Name are marked up inside <a> tags. Don't allow these. 240 $theme_data['Author'] = wp_kses( $theme_data['Author'], $allowed_tags_in_links ); 241 $theme_data['AuthorName'] = $theme_data['Author']; 242 243 $theme_data['Name'] = wp_kses( $theme_data['Name'], $allowed_tags_in_links ); 244 $theme_data['Title'] = $theme_data['Name']; 245 246 $theme_data['Description'] = wp_kses( $theme_data['Description'], $allowed_tags ); 247 $theme_data['Version'] = wp_kses( $theme_data['Version'], $allowed_tags ); 248 $theme_data['Template'] = wp_kses( $theme_data['Template'], $allowed_tags ); 249 $theme_data['Status'] = wp_kses( $theme_data['Status'], $allowed_tags ); 250 251 if ( ! $theme_data['Status'] ) 226 252 $theme_data['Status'] = 'publish'; 253 254 $theme_data['URI'] = esc_url( $theme_data['URI'] ); 255 $theme_data['AuthorURI'] = esc_url( $theme_data['AuthorURI'] ); 256 257 if ( $theme_data['Tags'] ) 258 $theme_data['Tags'] = array_map( 'trim', explode( ',', strip_tags( $theme_data['Tags'] ) ) ); 227 259 else 228 $theme_data['Status'] = wp_kses( $theme_data['Status'], $themes_allowed_tags );229 230 if ( $theme_data['Tags'] == '' )231 260 $theme_data['Tags'] = array(); 232 else233 $theme_data['Tags'] = array_map( 'trim', explode( ',', wp_kses( $theme_data['Tags'], array() ) ) );234 261 235 if ( $theme_data['Author'] == '' ) { 236 $theme_data['Author'] = $theme_data['AuthorName'] = __('Anonymous'); 237 } else { 238 $theme_data['AuthorName'] = wp_kses( $theme_data['Author'], $themes_allowed_tags ); 239 if ( empty( $theme_data['AuthorURI'] ) ) { 240 $theme_data['Author'] = $theme_data['AuthorName']; 262 // Apply markup 263 if ( $markup ) { 264 $theme_data['Description'] = wptexturize( $theme_data['Description'] ); 265 266 if ( $theme_data['Author'] ) { 267 if ( $theme_data['AuthorURI'] ) 268 $theme_data['Author'] = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $theme_data['AuthorURI'], esc_attr__( 'Visit author homepage' ), $theme_data['Author'] ); 241 269 } else { 242 $theme_data['Author'] = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $theme_data['AuthorURI'], esc_attr__( 'Visit author homepage' ), $theme_data['AuthorName']);270 $theme_data['Author'] = $theme_data['AuthorName'] = __( 'Anonymous' ); 243 271 } 244 272 } 245 273 … … 287 315 288 316 $name = $theme_data['Name']; 289 317 $title = $theme_data['Title']; 290 $description = wptexturize($theme_data['Description']);318 $description = $theme_data['Description']; 291 319 $version = $theme_data['Version']; 292 320 $author = $theme_data['Author']; 293 321 $template = $theme_data['Template']; … … 437 465 'Tags' => $theme_data['Tags'], 438 466 'Theme Root' => $theme_root, 439 467 'Theme Root URI' => str_replace( WP_CONTENT_DIR, content_url(), $theme_root ), 468 'TextDomain' => $theme_data['TextDomain'], 469 'DomainPath' => $theme_data['DomainPath'], 440 470 ); 441 471 } 442 472 -
wp-content/themes/twentyten/style.css
7 7 License: GNU General Public License 8 8 License URI: license.txt 9 9 Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu 10 Text Domain: twentyten 11 Domain Path: /languages 10 12 */ 11 13 12 14 -
wp-admin/includes/plugin.php
65 65 * @since 1.5.0 66 66 * 67 67 * @param string $plugin_file Path to the plugin file 68 * @param bool $markup If the returned data should have HTML markup applied 69 * @param bool $translate If the returned data should be translated 68 * @param bool $markup Optional. If the returned data should have HTML markup applied. Defaults to true. 69 * @param bool $translate Optional. If the returned data should be translated. Defaults to true. 70 * Note this is unlike the $translate parameter for get_theme_data(), which defaults to false. 70 71 * @return array See above for description. 71 72 */ 72 73 function get_plugin_data( $plugin_file, $markup = true, $translate = true ) { … … 88 89 $plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' ); 89 90 90 91 // Site Wide Only is the old header for Network 91 if ( empty( $plugin_data['Network'] ) && ! empty( $plugin_data['_sitewide'] )) {92 if ( ! $plugin_data['Network'] && $plugin_data['_sitewide'] ) { 92 93 _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The <code>%1$s</code> plugin header is deprecated. Use <code>%2$s</code> instead.' ), 'Site Wide Only: true', 'Network: true' ) ); 93 94 $plugin_data['Network'] = $plugin_data['_sitewide']; 94 95 } 95 96 $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) ); 96 97 unset( $plugin_data['_sitewide'] ); 97 98 98 // For backward compatibility by default Title is the same as Name.99 $plugin_data ['Title'] = $plugin_data['Name'];99 // Sanitize, maybe markup, maybe translate 100 $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate ); 100 101 101 if ( $markup || $translate )102 $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );103 else104 $plugin_data['AuthorName'] = $plugin_data['Author'];105 106 102 return $plugin_data; 107 103 } 108 104 109 function _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup = true, $translate = true) { 105 /** 106 * Sanitizes plugin data, optionally adds markup, optionally translates. 107 * 108 * @since 2.7.0 109 * @access private 110 * @see get_plugin_data() 111 */ 112 function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup = true, $translate = true ) { 110 113 111 // Translate fields114 // Translate fields 112 115 if ( $translate ) { 113 116 if ( $textdomain = $plugin_data['TextDomain'] ) { 114 if ( ! empty( $plugin_data['DomainPath'] ))117 if ( $plugin_data['DomainPath'] ) 115 118 load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) . $plugin_data['DomainPath'] ); 116 119 else 117 120 load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) ); … … 124 127 } 125 128 } 126 129 127 $plugins_allowedtags = array( 128 'a' => array( 'href' => array(), 'title' => array() ), 130 $allowed_tags = $allowed_tags_in_links = array( 129 131 'abbr' => array( 'title' => array() ), 130 132 'acronym' => array( 'title' => array() ), 131 133 'code' => array(), 132 134 'em' => array(), 133 135 'strong' => array(), 134 136 ); 137 $allowed_tags['a'] = array( 'href' => array(), 'title' => array() ); 135 138 136 $plugin_data['AuthorName'] = $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $plugins_allowedtags );139 // Sanitized all displayed data. 137 140 138 //Apply Markup 141 // Author and Name are marked up inside <a> tags. Don't allow these. 142 $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $allowed_tags_in_links ); 143 $plugin_data['AuthorName'] = $plugin_data['Author']; 144 145 $plugin_data['Name'] = wp_kses( $plugin_data['Name'], $allowed_tags_in_links ); 146 $plugin_data['Title'] = $plugin_data['Name']; 147 148 $plugin_data['Description'] = wp_kses( $plugin_data['Description'], $allowed_tags ); 149 $plugin_data['Version'] = wp_kses( $plugin_data['Version'], $allowed_tags ); 150 151 $plugin_data['PluginURI'] = esc_url( $plugin_data['PluginURI'] ); 152 $plugin_data['AuthorURI'] = esc_url( $plugin_data['AuthorURI'] ); 153 154 // Apply markup 139 155 if ( $markup ) { 140 if ( ! empty($plugin_data['PluginURI']) && ! empty($plugin_data['Name']))156 if ( $plugin_data['PluginURI'] && $plugin_data['Name'] ) 141 157 $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . esc_attr__( 'Visit plugin homepage' ) . '">' . $plugin_data['Name'] . '</a>'; 142 else143 $plugin_data['Title'] = $plugin_data['Name'];144 158 145 if ( ! empty($plugin_data['AuthorURI']) && ! empty($plugin_data['Author']))159 if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] ) 146 160 $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . esc_attr__( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>'; 147 161 148 162 $plugin_data['Description'] = wptexturize( $plugin_data['Description'] ); 149 if ( ! empty($plugin_data['Author']) ) 150 $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>'; 163 164 if ( $plugin_data['Author'] ) 165 $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s.'), $plugin_data['Author'] ) . '</cite>'; 151 166 } 152 167 153 // Sanitize all displayed data. Author and AuthorName sanitized above.154 $plugin_data['Title'] = wp_kses( $plugin_data['Title'], $plugins_allowedtags );155 $plugin_data['Version'] = wp_kses( $plugin_data['Version'], $plugins_allowedtags );156 $plugin_data['Description'] = wp_kses( $plugin_data['Description'], $plugins_allowedtags );157 $plugin_data['Name'] = wp_kses( $plugin_data['Name'], $plugins_allowedtags );158 159 168 return $plugin_data; 160 169 } 161 170 -
wp-admin/includes/file.php
61 61 } 62 62 elseif ( file_exists( $file ) && is_file( $file ) ) { 63 63 $template_data = implode( '', file( $file ) ); 64 if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name )) 65 return sprintf( __( '%s Page Template' ), _cleanup_header_comment($name[1]) ); 64 if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) ) { 65 $themes = get_themes(); 66 $theme = get_current_theme(); 67 if ( in_array( $file, $themes[ $theme ]['Template Files'] ) ) { 68 $textdomain = $themes[ $theme ]['TextDomain']; 69 } else { 70 foreach ( $themes as $theme ) { 71 if ( ! in_array( $file, $theme['Template Files'] ) ) 72 continue; 73 $textdomain = $theme['TextDomain']; 74 break; 75 } 76 } 77 $page_template = _cleanup_header_comment( $name[1] ); 78 if ( $textdomain ) 79 $page_template = translate( $page_template, $textdomain ); 80 return sprintf( __( '%s Page Template' ), $page_template ); 81 } 66 82 } 67 83 68 84 return basename( $file ); -
wp-admin/includes/theme.php
177 177 $themes = get_themes(); 178 178 $theme = get_current_theme(); 179 179 $templates = $themes[$theme]['Template Files']; 180 $textdomain = $themes[$theme]['TextDomain']; 180 181 $page_templates = array(); 181 182 182 183 if ( is_array( $templates ) ) { … … 194 195 195 196 $template_data = implode( '', file( $template )); 196 197 197 $name = '';198 198 if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) ) 199 $name = _cleanup_header_comment($name[1]); 199 $name = trim( _cleanup_header_comment( $name[1] ) ); 200 else 201 continue; 200 202 201 if ( !empty( $name ) ) { 202 $page_templates[trim( $name )] = $basename; 203 } 203 if ( $textdomain ) 204 $name = translate( $name, $textdomain ); 205 206 if ( $name ) 207 $page_templates[ $name ] = $basename; 204 208 } 205 209 } 206 210 -
wp-admin/includes/class-wp-plugins-list-table.php
345 345 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . ' <span class="attention">' . __('Inactive:') . '</span></strong> ' . sprintf( __( 'Requires <code>%s</code> in <code>wp-config.php</code>.' ), "define('" . $dropins[ $plugin_file ][1] . "', true);" ) . '</p>'; 346 346 } 347 347 if ( $plugin_data['Description'] ) 348 $description .= '<p>' . $plugin_data['Description']. '</p>';348 $description .= '<p>' . wptexturize( $plugin_data['Description'] ) . '</p>'; 349 349 } else { 350 350 $is_active_for_network = is_plugin_active_for_network($plugin_file); 351 351 if ( $screen->is_network ) … … 389 389 $checkbox_id = "checkbox_" . md5($plugin_data['Name']); 390 390 $checkbox = in_array( $status, array( 'mustuse', 'dropins' ) ) ? '' : "<input type='checkbox' name='checked[]' value='" . esc_attr( $plugin_file ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $plugin_data['Name'] . "</label>"; 391 391 if ( 'dropins' != $context ) { 392 $description = '<p>' . ( $plugin_data['Description'] ? $plugin_data['Description']: ' ' ) . '</p>';392 $description = '<p>' . ( $plugin_data['Description'] ? wptexturize( $plugin_data['Description'] ) : ' ' ) . '</p>'; 393 393 $plugin_name = $plugin_data['Name']; 394 394 } 395 395 -
wp-admin/theme-editor.php
44 44 45 45 wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'theme', 'dir')); 46 46 47 $themes = get_themes(); 47 $themes = get_themes(); // TODO I can haz translated data? 48 48 49 49 if (empty($theme)) { 50 50 $theme = get_current_theme();