X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/03f2fa83c13c1b532284205fa7efcab9b8b2c41f..refs/tags/wordpress-4.5:/wp-includes/theme.php diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 47c96617..f4dfaeed 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -177,7 +177,7 @@ function get_stylesheet_directory() { * * @since 1.5.0 * - * @param string $stylesheet_dir Absolute path to the current them. + * @param string $stylesheet_dir Absolute path to the current theme. * @param string $stylesheet Directory name of the current theme. * @param string $theme_root Absolute path to themes directory. */ @@ -723,7 +723,7 @@ function switch_theme( $stylesheet ) { } else { /* * Since retrieve_widgets() is called when initializing a theme in the Customizer, - * we need to to remove the theme mods to avoid overwriting changes made via + * we need to remove the theme mods to avoid overwriting changes made via * the Customizer when accessing wp-admin/widgets.php. */ if ( 'wp_ajax_customize_save' === current_action() ) { @@ -739,15 +739,18 @@ function switch_theme( $stylesheet ) { } update_option( 'theme_switched', $old_theme->get_stylesheet() ); + /** * Fires after the theme is switched. * * @since 1.5.0 + * @since 4.5.0 Introduced the `$old_theme` parameter. * * @param string $new_name Name of the new theme. * @param WP_Theme $new_theme WP_Theme instance of the new theme. + * @param WP_Theme $old_theme WP_Theme instance of the old theme. */ - do_action( 'switch_theme', $new_name, $new_theme ); + do_action( 'switch_theme', $new_name, $new_theme, $old_theme ); } /** @@ -771,7 +774,7 @@ function validate_current_theme() { * * @since 2.7.0 * - * @param bool true Validation flag to check the current theme. + * @param bool $validate Whether to validate the current theme. Default true. */ if ( wp_installing() || ! apply_filters( 'validate_current_theme', true ) ) return true; @@ -946,18 +949,18 @@ function remove_theme_mods() { } /** - * Retrieve text color for custom header. + * Retrieves the custom header text color in HEX format. * * @since 2.1.0 * - * @return string + * @return string Header text color in HEX format (minus the hash symbol). */ function get_header_textcolor() { return get_theme_mod('header_textcolor', get_theme_support( 'custom-header', 'default-text-color' ) ); } /** - * Display text color for custom header. + * Displays the custom header text color in HEX format (minus the hash symbol). * * @since 2.1.0 */ @@ -1204,7 +1207,7 @@ function get_uploaded_header_images() { foreach ( (array) $headers as $header ) { $url = esc_url_raw( wp_get_attachment_url( $header->ID ) ); $header_data = wp_get_attachment_metadata( $header->ID ); - $header_index = basename($url); + $header_index = $header->ID; $header_images[$header_index] = array(); $header_images[$header_index]['attachment_id'] = $header->ID; @@ -1556,6 +1559,26 @@ function add_theme_support( $feature ) { $args[0] = array_merge( $_wp_theme_features['html5'][0], $args[0] ); break; + case 'custom-logo': + if ( ! is_array( $args ) ) { + $args = array( 0 => array() ); + } + $defaults = array( + 'width' => null, + 'height' => null, + 'flex-width' => false, + 'flex-height' => false, + 'header-text' => '', + ); + $args[0] = wp_parse_args( array_intersect_key( $args[0], $defaults ), $defaults ); + + // Allow full flexibility if no size is specified. + if ( is_null( $args[0]['width'] ) && is_null( $args[0]['height'] ) ) { + $args[0]['flex-width'] = true; + $args[0]['flex-height'] = true; + } + break; + case 'custom-header-uploads' : return add_theme_support( 'custom-header', array( 'uploads' => true ) ); @@ -1728,6 +1751,30 @@ function _custom_header_background_just_in_time() { } } +/** + * Adds CSS to hide header text for custom logo, based on Customizer setting. + * + * @since 4.5.0 + * @access private + */ +function _custom_logo_header_styles() { + if ( ! current_theme_supports( 'custom-header', 'header-text' ) && get_theme_support( 'custom-logo', 'header-text' ) && ! get_theme_mod( 'header_text', true ) ) { + $classes = (array) get_theme_support( 'custom-logo', 'header-text' ); + $classes = array_map( 'sanitize_html_class', $classes ); + $classes = '.' . implode( ', .', $classes ); + + ?> + + +