Skip to main content
Typo, Grammar & Formatting fix + accurate wording from customizer for future search results
Source Link

Hide header-texts texts (Title & Tagline) in custom-header.php

I am currently trying to enhance my theme-development-skills development skills and still have a lot to learn in php... . Investigating

I'm investigating the code of underscores.meUnderscores and twenty-seventeen... Twenty Seventeen themes. I simply do not understand, why the following code works (whatand what it does) to hide titleSite Title and subtitleTagline, if littlethe Display Site Title and Tagline checkbox in Customizer is unchecked.

In custom-header.phpcustom-header.php, after setting up the custom header with a default-text-color text color of #000000 themes#000000, themes set up a function for header-style. style:

function underscores_header_style() {
    $header_text_color = get_header_textcolor();

    /*
     * If no custom options for text are set, let's bail.
     * get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: add_theme_support( 'custom-header' ).
     */
    if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
        return;
    }

    // If we get this far, we have custom styles. Let's do this.
    ?>
    <style type="text/css"> ... 

If I now set the color of Header Text to #00000#000000 in Customizer, in my opinion, the first ifif clause should become true, the „return;“return; should end the function and the holewhole following styling part (hiding … )for hiding and beyond shouldn't be working.

So far II've checked with var_dump() get_header_textcolorvar_dump() for get_header_textcolor() and get_theme_support('custom-header', 'default-text-color')get_theme_support('custom-header', 'default-text-color'). Both the values are '000000'000000.

In contrast to my above considerations: Everything works correctcorrectly.

I don't want to just „copy"copypaste“paste" this issue in my theme, I want to understand it. Where is my thinking error?

Sorry for my English and so many thanks in advance.

Hide header-texts (Title & Tagline) custom-header

I am currently trying to enhance my theme-development-skills and still have a lot to learn in php... . Investigating code of underscores.me and twenty-seventeen... . I simply do not understand, why the following code works (what it does) to hide title and subtitle, if little checkbox in Customizer is unchecked.

In custom-header.php, after setting up the custom header with a default-text-color of #000000 themes set up a function for header-style.

function underscores_header_style() {
    $header_text_color = get_header_textcolor();

    Default: add_theme_support( 'custom-header' ).

    if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
    return;
}

// If we get this far, we have custom styles. Let's do this.
?>
<style type="text/css"> ... 

If I now set the color of Header Text to #00000 in Customizer in my opinion the first if clause should become true, the „return;“ should end the function and the hole following styling part (hiding … ) beyond shouldn't be working.

So far I checked with var_dump() get_header_textcolor and get_theme_support('custom-header', 'default-text-color'). Both values are '000000'.

In contrast to my above considerations: Everything works correct.

I don't want just „copypaste“ this issue in my theme, I want to understand it. Where is my thinking error?

Sorry for my English and so many thanks in advance.

Hide header texts (Title & Tagline) in custom-header.php

I am currently trying to enhance my theme development skills and still have a lot to learn in php.

I'm investigating the code of Underscores and Twenty Seventeen themes. I simply do not understand why the following code works and what it does to hide Site Title and Tagline, if the Display Site Title and Tagline checkbox in Customizer is unchecked.

In custom-header.php, after setting up the custom header with a default text color of #000000, themes set up a function for header style:

function underscores_header_style() {
    $header_text_color = get_header_textcolor();

    /*
     * If no custom options for text are set, let's bail.
     * get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: add_theme_support( 'custom-header' ).
     */
    if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
        return;
    }

    // If we get this far, we have custom styles. Let's do this.
    ?>
    <style type="text/css">

If I now set the color of Header Text to #000000 in Customizer, in my opinion, the first if clause should become true, the return; should end the function and the whole following styling part for hiding and beyond shouldn't be working.

So far I've checked with var_dump() for get_header_textcolor() and get_theme_support('custom-header', 'default-text-color'). Both the values are 000000.

In contrast to my above considerations: Everything works correctly.

I don't want to just "copypaste" this issue in my theme, I want to understand it. Where is my thinking error?

edited tags; edited title
Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459

Theme-Development: Hide header-texts (Title & Tagline) custom-header

Source Link

Theme-Development: Hide header-texts (Title & Tagline) custom-header

I am currently trying to enhance my theme-development-skills and still have a lot to learn in php... . Investigating code of underscores.me and twenty-seventeen... . I simply do not understand, why the following code works (what it does) to hide title and subtitle, if little checkbox in Customizer is unchecked.

In custom-header.php, after setting up the custom header with a default-text-color of #000000 themes set up a function for header-style.

function underscores_header_style() {
    $header_text_color = get_header_textcolor();

    Default: add_theme_support( 'custom-header' ).

    if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
    return;
}

// If we get this far, we have custom styles. Let's do this.
?>
<style type="text/css"> ... 

If I now set the color of Header Text to #00000 in Customizer in my opinion the first if clause should become true, the „return;“ should end the function and the hole following styling part (hiding … ) beyond shouldn't be working.

So far I checked with var_dump() get_header_textcolor and get_theme_support('custom-header', 'default-text-color'). Both values are '000000'.

In contrast to my above considerations: Everything works correct.

I don't want just „copy – paste“ this issue in my theme, I want to understand it. Where is my thinking error?

Sorry for my English and so many thanks in advance.