Make WordPress Core

Changeset 36915


Ignore:
Timestamp:
03/09/2016 11:43:49 PM (9 years ago)
Author:
obenland
Message:

Customize: Only add custom logo’s header text control if needed.

Dissolves WP_CustomLogo and adopts a structure similar to custom header and background (See _delete_attachment_theme_mod()).
The option to hide header text only gets added if it’s not already part of custom header, and only if selectors have been registered when theme support for custom logos was declared. Themes can add postMessage support for it as well.

Example:

add_theme_support( 'custom-logo', array(
    'size' => ‘large’,
    'header-text' => array( 'site-title', 'site-description' ),
) );

See #33755.

Location:
trunk
Files:
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/admin.php

    r36838 r36915  
    7373require_once(ABSPATH . 'wp-admin/includes/class-wp-site-icon.php');
    7474
    75 /** WordPress Custom Logo API */
    76 require_once(ABSPATH . 'wp-admin/includes/class-wp-custom-logo.php');
    77 
    7875/** WordPress Update Administration API */
    7976require_once(ABSPATH . 'wp-admin/includes/update.php');
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r36912 r36915  
    19231923        ) );
    19241924
    1925         // Add a setting to hide header text if the theme isn't supporting the feature itself.
    1926         // @todo
    1927         if ( ! current_theme_supports( 'custom-header' ) ) {
     1925        // Add a setting to hide header text if the theme doesn't support custom headers.
     1926        if ( ! current_theme_supports( 'custom-header', 'header-text' ) ) {
    19281927            $this->add_setting( 'header_text', array(
     1928                'theme_supports'    => array( 'custom-logo', 'header-text' ),
    19291929                'default'           => 1,
    19301930                'sanitize_callback' => 'absint',
    1931                 'transport'         => 'postMessage',
    19321931            ) );
    19331932
  • trunk/src/wp-includes/default-filters.php

    r36617 r36915  
    372372// Theme
    373373add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
     374add_action( 'wp_head', '_custom_logo_header_styles' );
    374375add_action( 'plugins_loaded', '_wp_customize_include' );
    375376add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' );
  • trunk/src/wp-includes/general-template.php

    r36837 r36915  
    881881        restore_current_blog();
    882882    }
    883     $size = get_theme_support( 'custom-logo' );
    884     $size = $size[0]['size'];
     883    $size = get_theme_support( 'custom-logo', 'size' );
    885884
    886885    // We have a logo. Logo is go.
  • trunk/src/wp-includes/theme.php

    r36909 r36915  
    17331733
    17341734/**
     1735 * Adds CSS to hide header text for custom logo, based on Customizer setting.
     1736 *
     1737 * @since 4.5.0
     1738 * @access private
     1739 */
     1740function _custom_logo_header_styles() {
     1741    if ( ! current_theme_supports( 'custom-header', 'header-text' ) && get_theme_support( 'custom-logo', 'header-text' ) && ! get_theme_mod( 'header_text', true ) ) {
     1742        $classes = (array) get_theme_support( 'custom-logo', 'header-text' );
     1743        $classes = array_map( 'sanitize_html_class', $classes );
     1744        $classes = '.' . implode( ', .', $classes );
     1745
     1746        ?>
     1747        <!-- Custom Logo: hide header text -->
     1748        <style id="custom-logo-css" type="text/css">
     1749            <?php echo $classes; ?> {
     1750                position: absolute;
     1751                clip: rect(1px, 1px, 1px, 1px);
     1752            }
     1753        </style>
     1754    <?php
     1755    }
     1756}
     1757
     1758/**
    17351759 * Gets the theme support arguments passed when registering that support
    17361760 *
     
    19281952 * @since 3.0.0
    19291953 * @since 4.3.0 Also removes `header_image_data`.
     1954 * @since 4.5.0 Also removes custom logo theme mods.
    19301955 *
    19311956 * @param int $id The attachment id.
     
    19351960    $header_image     = get_header_image();
    19361961    $background_image = get_background_image();
     1962    $custom_logo_id   = get_theme_mod( 'custom_logo' );
     1963
     1964    if ( $custom_logo_id && $custom_logo_id == $id ) {
     1965        remove_theme_mod( 'custom_logo' );
     1966        remove_theme_mod( 'header_text' );
     1967    }
    19371968
    19381969    if ( $header_image && $header_image == $attachment_image ) {
Note: See TracChangeset for help on using the changeset viewer.