Ticket #13743: 13743.10.patch
File 13743.10.patch, 8.0 KB (added by , 7 years ago) |
---|
-
src/wp-admin/includes/class-wp-ms-themes-list-table.php
45 45 ); 46 46 47 47 $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all'; 48 if ( ! in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) ) {48 if ( ! in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken', 'default' ) ) ) { 49 49 $status = 'all'; 50 50 } 51 51 … … 105 105 'disabled' => array(), 106 106 'upgrade' => array(), 107 107 'broken' => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ), 108 'default' => array( wp_get_theme( get_network_option( null, 'default_theme', WP_DEFAULT_THEME ) ) ), 108 109 ); 109 110 110 111 if ( $this->is_site_themes ) { … … 311 312 case 'broken': 312 313 $text = _n( 'Broken <span class="count">(%s)</span>', 'Broken <span class="count">(%s)</span>', $count ); 313 314 break; 315 case 'default': 316 $text = __( 'Default' ) . ' <span class="count">(1)</span>'; 317 break; 314 318 } 315 319 316 320 if ( $this->is_site_themes ) { … … 410 414 'enable' => '', 411 415 'disable' => '', 412 416 'delete' => '', 417 'default' => '', 413 418 ); 414 419 415 420 $stylesheet = $theme->get_stylesheet(); … … 442 447 ); 443 448 } 444 449 } else { 445 $url = add_query_arg( 446 array( 447 'action' => 'disable', 448 'theme' => $theme_key, 449 'paged' => $page, 450 's' => $s, 451 ), $url 452 ); 450 // Set default theme raw action 451 if ( $theme->get_stylesheet() !== get_network_option( null, 'default_theme', WP_DEFAULT_THEME ) ) { 452 $url = add_query_arg( 453 array( 454 'action' => 'disable', 455 'theme' => $theme_key, 456 'paged' => $page, 457 's' => $s, 458 ), $url 459 ); 453 460 454 if ( $this->is_site_themes ) { 455 /* translators: %s: theme name */ 456 $aria_label = sprintf( __( 'Disable %s' ), $theme->display( 'Name' ) ); 457 } else { 458 /* translators: %s: theme name */ 459 $aria_label = sprintf( __( 'Network Disable %s' ), $theme->display( 'Name' ) ); 461 if ( $this->is_site_themes ) { 462 /* translators: %s: theme name */ 463 $aria_label = sprintf( __( 'Disable %s' ), $theme->display( 'Name' ) ); 464 } else { 465 /* translators: %s: theme name */ 466 $aria_label = sprintf( __( 'Network Disable %s' ), $theme->display( 'Name' ) ); 467 } 468 469 $actions['disable'] = sprintf( 470 '<a href="%s" aria-label="%s">%s</a>', 471 esc_url( wp_nonce_url( $url, 'disable-theme_' . $stylesheet ) ), 472 esc_attr( $aria_label ), 473 ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) 474 ); 475 476 // Set network default theme 477 $url = add_query_arg( array( 478 'action' => 'default', 479 'theme' => $theme_key, 480 'theme_status' => $context, 481 'paged' => $page, 482 's' => $s, 483 ), $url ); 484 485 $actions['default'] = sprintf( '<a href="%s" aria-label="%s">%s</a>', 486 esc_url( wp_nonce_url( $url, 'default-theme_' . $stylesheet ) ), 487 esc_attr( sprintf( __( 'Make Default %s' ), $theme->display( 'Name' ) ) ), 488 __( 'Make Default' ) 489 ); 460 490 } 461 462 $actions['disable'] = sprintf(463 '<a href="%s" aria-label="%s">%s</a>',464 esc_url( wp_nonce_url( $url, 'disable-theme_' . $stylesheet ) ),465 esc_attr( $aria_label ),466 ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) )467 );468 491 } 469 492 470 493 if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) ) { … … 665 688 if ( $stylesheet !== $template && $item->get_stylesheet() === $stylesheet ) { 666 689 $active_theme_label = ' — ' . __( 'Active Child Theme' ); 667 690 } 691 692 /* In case this is the network default theme */ 693 if ( $item->get_stylesheet() === $item->network_get_default_theme() ) { 694 $active_theme_label = ' — ' . __( 'Default Theme' ); 695 } 668 696 } 669 697 670 echo "<td class='theme-title column-primary{$extra_classes}'><strong>" . $item->display( 'Name' ) . $active_theme_label . '</strong>'; 698 printf( "<td class='theme-title column-primary%s'><strong>%s%s</strong>", 699 $extra_classes, 700 $item->display( 'Name' ), 701 $active_theme_label 702 ); 671 703 672 704 $this->column_name( $item ); 673 705 -
src/wp-admin/includes/schema.php
370 370 $uploads_use_yearmonth_folders = 1; 371 371 } 372 372 373 // If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme.374 373 $stylesheet = $template = WP_DEFAULT_THEME; 375 $theme = wp_get_theme( WP_DEFAULT_THEME ); 376 if ( ! $theme->exists() ) { 377 $theme = WP_Theme::get_core_default_theme(); 374 375 // If it's multisite and WP_DEFAULT_THEME is not redifined in WP Config, get the network default theme 376 if ( is_multisite() ) { 377 $default_theme = get_network_option( null, 'default_theme', false ); 378 if ( ! empty( $default_theme ) ) { 379 $theme = wp_get_theme( $default_theme ); 380 } 378 381 } 379 382 380 383 // If we can't find a core default theme, WP_DEFAULT_THEME is the best we can do. 381 if ( $theme ) { 384 if ( empty ( $theme ) || ! $theme->exists() ) { 385 $theme = wp_get_theme( WP_DEFAULT_THEME ); 386 387 // If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme. 388 if ( ! $theme->exists() ) { 389 $theme = WP_Theme::get_core_default_theme(); 390 } 391 } 392 393 // Fetch stylesheet and template corresponding to the fetched theme 394 if ( ! empty ( $theme ) && $theme->exists() ) { 382 395 $stylesheet = $theme->get_stylesheet(); 383 396 $template = $theme->get_template(); 384 397 } -
src/wp-admin/network/themes.php
42 42 WP_Theme::network_disable_theme( $_GET['theme'] ); 43 43 wp_safe_redirect( add_query_arg( 'disabled', '1', $referer ) ); 44 44 exit; 45 case 'default': 46 check_admin_referer( 'default-theme_' . $_GET['theme'] ); 47 WP_Theme::network_set_default_theme( $_GET['theme'] ); 48 wp_safe_redirect( add_query_arg( 'default', '1', $referer ) ); 49 exit; 45 50 case 'enable-selected': 46 51 check_admin_referer( 'bulk-themes' ); 47 52 $themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); … … 295 300 $message = _n( '%s theme disabled.', '%s themes disabled.', $disabled ); 296 301 } 297 302 echo '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>'; 303 } elseif ( isset( $_GET['default'] ) ) { 304 $message = __( 'Network default theme has been set.' ); 305 echo '<div id="message" class="updated notice is-dismissible"><p>' . $message . '</p></div>'; 298 306 } elseif ( isset( $_GET['deleted'] ) ) { 299 307 $deleted = absint( $_GET['deleted'] ); 300 308 if ( 1 == $deleted ) { -
src/wp-includes/class-wp-theme.php
1547 1547 } 1548 1548 1549 1549 /** 1550 * Set the network default theme. 1551 * 1552 * @since 5.0.0 1553 * @access public 1554 * @static 1555 * 1556 * @param string $stylesheet name. 1557 */ 1558 public static function network_set_default_theme( $stylesheet ) { 1559 if ( ! is_multisite() ) { 1560 return; 1561 } 1562 1563 $theme = wp_get_theme( $stylesheet ); 1564 if ( ! $theme->exists() || ! $theme->is_allowed() ) { 1565 return; 1566 } 1567 1568 update_network_option( null, 'default_theme', $stylesheet ); 1569 } 1570 1571 /** 1572 * Get the network default theme. 1573 * 1574 * @since 5.0.0 1575 * @access public 1576 * @static 1577 */ 1578 public static function network_get_default_theme() { 1579 return get_network_option( null, 'default_theme', WP_DEFAULT_THEME ); 1580 } 1581 1582 /** 1550 1583 * Sorts themes by name. 1551 1584 * 1552 1585 * @since 3.4.0