Ticket #19627: 19627-patch1.diff
File 19627-patch1.diff, 5.3 KB (added by , 11 years ago) |
---|
-
trunk/wp-includes/theme.php
171 171 * 172 172 * The style.css file must contain theme name, theme URI, and description. The 173 173 * data can also contain author URI, author, template (parent template), 174 * version, status, and finally tags. Some of these are not used by WordPress175 * administration panels, but are used by theme directory web sites which list176 * the theme.174 * version, status, tags, and a recommended display type for the front page 175 * (static or posts). Some of these are not used by WordPress administration 176 * panels, but are used by theme directory web sites which list the theme. 177 177 * 178 178 * @since 1.5.0 179 179 * … … 190 190 'Version' => 'Version', 191 191 'Template' => 'Template', 192 192 'Status' => 'Status', 193 'Tags' => 'Tags' 193 'Tags' => 'Tags', 194 'FrontPage' => 'Front Page' 194 195 ); 195 196 196 197 $themes_allowed_tags = array( … … 207 208 'em' => array(), 208 209 'strong' => array() 209 210 ); 211 212 $themes_allowed_front_page = array( 213 'posts', 214 'static', 215 'null' // default - means neither posts nor static holds more weight 216 ); 210 217 211 218 $theme_data = get_file_data( $theme_file, $default_headers, 'theme' ); 212 219 … … 242 249 $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'] ); 243 250 } 244 251 } 252 253 if ( ! in_array( strtolower( $theme_data['FrontPage'] ), $themes_allowed_front_page ) ) { 254 $theme_data['FrontPage'] = 'null'; 255 } 245 256 246 257 return $theme_data; 247 258 } … … 437 448 'Tags' => $theme_data['Tags'], 438 449 'Theme Root' => $theme_root, 439 450 'Theme Root URI' => str_replace( WP_CONTENT_DIR, content_url(), $theme_root ), 451 'Front Page' => $theme_data['FrontPage'] 440 452 ); 441 453 } 442 454 … … 1247 1259 * @param string $stylesheet Stylesheet name. 1248 1260 */ 1249 1261 function switch_theme($template, $stylesheet) { 1250 global $wp_theme_directories, $sidebars_widgets ;1262 global $wp_theme_directories, $sidebars_widgets, $wp_recommended_front_page; 1251 1263 1252 1264 if ( is_array( $sidebars_widgets ) ) 1253 1265 set_theme_mod( 'sidebars_widgets', array( 'time' => time(), 'data' => $sidebars_widgets ) ); … … 1269 1281 $default_theme_mods = (array) get_option( "mods_$theme" ); 1270 1282 add_option( "theme_mods_$stylesheet", $default_theme_mods ); 1271 1283 } 1284 1285 $current_theme_options = get_theme( $theme ); 1286 if ( 'null' !== $current_theme_options['Front Page'] ) { 1287 $wp_recommended_front_page = $current_theme_options['Front Page']; 1288 } 1272 1289 1273 1290 update_option( 'theme_switched', $old_theme ); 1274 1291 do_action( 'switch_theme', $theme ); -
trunk/wp-admin/themes.php
18 18 if ( 'activate' == $_GET['action'] ) { 19 19 check_admin_referer('switch-theme_' . $_GET['template']); 20 20 switch_theme($_GET['template'], $_GET['stylesheet']); 21 wp_redirect( admin_url('themes.php?activated=true') ); 21 22 // After switch_theme, the recommended front page global is available. 23 global $wp_recommended_front_page; 24 $front_page_query = ( isset( $wp_recommended_front_page ) ) ? '&frontpage=' . urlencode( $wp_recommended_front_page ) : ''; 25 26 wp_redirect( admin_url('themes.php?activated=true' . $front_page_query) ); 22 27 exit; 23 28 } elseif ( 'delete' == $_GET['action'] ) { 24 29 check_admin_referer('delete-theme_' . $_GET['template']); … … 77 82 78 83 <?php if ( ! validate_current_theme() ) : ?> 79 84 <div id="message1" class="updated"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div> 80 <?php elseif ( isset($_GET['activated']) ) : 81 if ( isset($wp_registered_sidebars) && count( (array) $wp_registered_sidebars ) && current_user_can('edit_theme_options') ) { ?> 82 <div id="message2" class="updated"><p><?php printf( __('New theme activated. This theme supports widgets, please visit the <a href="%s">widgets settings</a> screen to configure them.'), admin_url( 'widgets.php' ) ); ?></p></div><?php 83 } else { ?> 84 <div id="message2" class="updated"><p><?php printf( __( 'New theme activated. <a href="%s">Visit site</a>' ), home_url( '/' ) ); ?></p></div><?php 85 } 86 elseif ( isset($_GET['deleted']) ) : ?> 85 <?php elseif ( isset($_GET['activated']) ) : ?> 86 <div id="message2" class="updated"><p> 87 <?php 88 if ( isset($wp_registered_sidebars) && count( (array) $wp_registered_sidebars ) && current_user_can('edit_theme_options') ) { 89 $theme_msg2_out = sprintf( __('New theme activated. This theme supports widgets, please visit the <a href="%s">widgets settings</a> screen to configure them.'), admin_url( 'widgets.php' ) ); 90 } else { 91 $theme_msg2_out = sprintf( __( 'New theme activated. <a href="%s">Visit site</a>' ), home_url( '/' ) ); 92 } 93 94 if ( 'static' == $_GET['frontpage'] && current_user_can('manage_options') ) { 95 $theme_msg2_out .= sprintf( __( ' This theme works best with a static front page. Please visit the <a href="%s">reading settings</a> screen to configure your front page preferences.' ), get_admin_url( null, 'options-reading.php' ) ); 96 } 97 98 echo $theme_msg2_out; 99 unset( $theme_msg2_out ); 100 ?> 101 </p></div> 102 <?php elseif ( isset($_GET['deleted']) ) : ?> 87 103 <div id="message3" class="updated"><p><?php _e('Theme deleted.') ?></p></div> 88 104 <?php endif; ?> 89 105