Ticket #13743: 13743.8.patch
File 13743.8.patch, 17.2 KB (added by , 8 years ago) |
---|
-
wp-admin/includes/class-wp-ms-themes-list-table.php
diff --git wp-admin/includes/class-wp-ms-themes-list-table.php wp-admin/includes/class-wp-ms-themes-list-table.php index 0f3865a..e5a4aa0 100644
class WP_MS_Themes_List_Table extends WP_List_Table { 44 44 ) ); 45 45 46 46 $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all'; 47 if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) )47 if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken', 'default' ) ) ) 48 48 $status = 'all'; 49 49 50 50 $page = $this->get_pagenum(); … … class WP_MS_Themes_List_Table extends WP_List_Table { 104 104 'disabled' => array(), 105 105 'upgrade' => array(), 106 106 'broken' => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ), 107 'default' => array( wp_get_theme( get_network_option( null, 'default_theme', WP_DEFAULT_THEME ) ) ), 107 108 ); 108 109 109 110 if ( $this->is_site_themes ) { … … class WP_MS_Themes_List_Table extends WP_List_Table { 301 302 case 'broken' : 302 303 $text = _n( 'Broken <span class="count">(%s)</span>', 'Broken <span class="count">(%s)</span>', $count ); 303 304 break; 305 case 'default' : 306 $text = __( 'Default' ) . ' <span class="count">(1)</span>'; 307 break; 304 308 } 305 309 306 310 if ( $this->is_site_themes ) … … class WP_MS_Themes_List_Table extends WP_List_Table { 396 400 'enable' => '', 397 401 'disable' => '', 398 402 'edit' => '', 399 'delete' => '' 403 'delete' => '', 404 'default' => '', 400 405 ); 401 406 402 407 $stylesheet = $theme->get_stylesheet(); … … class WP_MS_Themes_List_Table extends WP_List_Table { 426 431 ); 427 432 } 428 433 } else { 429 $url = add_query_arg( array( 430 'action' => 'disable', 431 'theme' => $theme_key, 432 'paged' => $page, 433 's' => $s, 434 ), $url ); 434 // Set default theme raw action 435 if ( $theme->get_stylesheet() !== get_network_option( null, 'default_theme', WP_DEFAULT_THEME ) ) { 436 $url = add_query_arg( array( 437 'action' => 'disable', 438 'theme' => $theme_key, 439 'paged' => $page, 440 's' => $s, 441 ), $url ); 435 442 436 if ( $this->is_site_themes ) { 437 /* translators: %s: theme name */ 438 $aria_label = sprintf( __( 'Disable %s' ), $theme->display( 'Name' ) ); 439 } else { 440 /* translators: %s: theme name */ 441 $aria_label = sprintf( __( 'Network Disable %s' ), $theme->display( 'Name' ) ); 443 if ( $this->is_site_themes ) { 444 /* translators: %s: theme name */ 445 $aria_label = sprintf( __( 'Disable %s' ), $theme->display( 'Name' ) ); 446 } else { 447 /* translators: %s: theme name */ 448 $aria_label = sprintf( __( 'Network Disable %s' ), $theme->display( 'Name' ) ); 449 } 450 451 $actions['disable'] = sprintf( '<a href="%s" aria-label="%s">%s</a>', 452 esc_url( wp_nonce_url( $url, 'disable-theme_' . $stylesheet ) ), 453 esc_attr( $aria_label ), 454 ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) 455 ); 456 457 // Set network default theme 458 $url = add_query_arg( array( 459 'action' => 'default', 460 'theme' => $theme_key, 461 'theme_status' => $context, 462 'paged' => $page, 463 's' => $s, 464 ), $url ); 465 466 $actions['default'] = sprintf( '<a href="%s" aria-label="%s">%s</a>', 467 esc_url( wp_nonce_url( $url, 'default-theme_' . $stylesheet ) ), 468 esc_attr( sprintf( __( 'Make Default %s' ), $theme->display( 'Name' ) ) ), 469 __( 'Make Default' ) 470 ); 442 471 } 443 444 $actions['disable'] = sprintf( '<a href="%s" aria-label="%s">%s</a>',445 esc_url( wp_nonce_url( $url, 'disable-theme_' . $stylesheet ) ),446 esc_attr( $aria_label ),447 ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) )448 );449 472 } 450 473 451 474 if ( current_user_can('edit_themes') ) { … … class WP_MS_Themes_List_Table extends WP_List_Table { 643 666 break; 644 667 645 668 case 'name': 646 echo "<td class='theme-title column-primary{$extra_classes}'><strong>" . $item->display('Name') . "</strong>"; 669 printf( "<td class='theme-title column-primary%s'><strong>%s%s</strong>", 670 $extra_classes, 671 $item->display('Name'), 672 ( $item->get_stylesheet() === $item->network_get_default_theme() ) ? ' - ' . __( 'Default Theme' ) : '' 673 ); 647 674 648 675 $this->column_name( $item ); 649 676 -
wp-admin/includes/schema.php
diff --git wp-admin/includes/schema.php wp-admin/includes/schema.php index cd66e19..c68a8ac 100644
function populate_options() { 365 365 $uploads_use_yearmonth_folders = 1; 366 366 } 367 367 368 // If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme.369 368 $stylesheet = $template = WP_DEFAULT_THEME; 370 $theme = wp_get_theme( WP_DEFAULT_THEME ); 371 if ( ! $theme->exists() ) { 372 $theme = WP_Theme::get_core_default_theme(); 369 370 // If it's multisite and WP_DEFAULT_THEME is not redifined in WP Config, get the network default theme 371 if ( is_multisite() ) { 372 $default_theme = get_network_option( null, 'default_theme', false ); 373 374 if ( ! empty( $default_theme ) ) { 375 $theme = wp_get_theme( $default_theme ); 376 if ( $theme->exists() ) { 377 $stylesheet = $theme->get_stylesheet(); 378 $template = $theme->get_template(); 379 } 380 } 381 } 382 383 if ( empty ( $theme ) || ! $theme->exists() ) { 384 $theme = wp_get_theme( WP_DEFAULT_THEME ); 385 386 // If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme. 387 if ( ! $theme->exists() ) { 388 $theme = WP_Theme::get_core_default_theme(); 389 } 373 390 } 374 391 375 392 // If we can't find a core default theme, WP_DEFAULT_THEME is the best we can do. -
wp-admin/network/settings.php
diff --git wp-admin/network/settings.php wp-admin/network/settings.php index 5d81cdf..4646cf3 100644
if ( isset( $_GET['updated'] ) ) { 202 202 </table> 203 203 <h2><?php _e( 'New Site Settings' ); ?></h2> 204 204 <table class="form-table"> 205 206 205 <tr> 207 206 <th scope="row"><label for="welcome_email"><?php _e( 'Welcome Email' ) ?></label></th> 208 207 <td> -
wp-admin/network/themes.php
diff --git wp-admin/network/themes.php wp-admin/network/themes.php index 2b22847..023c9d8 100644
if ( $action ) { 40 40 WP_Theme::network_disable_theme( $_GET['theme'] ); 41 41 wp_safe_redirect( add_query_arg( 'disabled', '1', $referer ) ); 42 42 exit; 43 case 'default': 44 check_admin_referer('default-theme_' . $_GET['theme']); 45 WP_Theme::network_set_default_theme( $_GET['theme'] ); 46 wp_safe_redirect( add_query_arg( 'default', '1', $referer ) ); 47 exit; 43 48 case 'enable-selected': 44 49 check_admin_referer('bulk-themes'); 45 50 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); … … if ( isset( $_GET['enabled'] ) ) { 287 292 $message = _n( '%s theme deleted.', '%s themes deleted.', $deleted ); 288 293 } 289 294 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $deleted ) ) . '</p></div>'; 295 } elseif ( isset( $_GET['default'] ) ) { 296 $message = __( 'Network default theme has been set.' ); 297 echo '<div id="message" class="updated notice is-dismissible"><p>' . $message . '</p></div>'; 290 298 } elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) { 291 299 echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'No theme selected.' ) . '</p></div>'; 292 300 } elseif ( isset( $_GET['error'] ) && 'main' == $_GET['error'] ) { -
wp-includes/class-wp-theme.php
diff --git wp-includes/class-wp-theme.php wp-includes/class-wp-theme.php index f161a63..f58b980 100644
final class WP_Theme implements ArrayAccess { 1431 1431 } 1432 1432 1433 1433 /** 1434 * Set the network default theme. 1435 * 1436 * @since 4.8.0 1437 * @access public 1438 * @static 1439 * 1440 * @param string $stylesheet name. 1441 */ 1442 public static function network_set_default_theme( $stylesheet ) { 1443 if ( ! is_multisite() ) { 1444 return false; 1445 } 1446 1447 $theme = wp_get_theme( $stylesheet ); 1448 if ( ! $theme->exists() ) { 1449 return false; 1450 } 1451 1452 if ( ! $theme->is_allowed() ) { 1453 return false; 1454 } 1455 1456 update_network_option( null, 'default_theme', $stylesheet ); 1457 } 1458 1459 /** 1460 * Get the network default theme. 1461 * 1462 * @since 4.8.0 1463 * @access public 1464 * @static 1465 */ 1466 public static function network_get_default_theme() { 1467 return get_network_option( null, 'default_theme', WP_DEFAULT_THEME ); 1468 } 1469 1470 /** 1434 1471 * Sorts themes by name. 1435 1472 * 1436 1473 * @since 3.4.0