Make WordPress Core

Ticket #28637: 28637c.diff

File 28637c.diff, 542 bytes (added by philipjohn, 10 years ago)

Following from obenland's suggestion, I have a new patch which instead checks whether the new value for the theme mod is empty. If it is, the array index for the 'theme_mod_{$theme}' option is removed, which results in get_theme_mod() reliably returning false rather than an empty string.

  • src/wp-includes/theme.php

    diff --git src/wp-includes/theme.php src/wp-includes/theme.php
    index 85119ed..b17f934 100644
    function set_theme_mod( $name, $value ) { 
    955955         */
    956956        $mods[ $name ] = apply_filters( "pre_set_theme_mod_$name", $value, $old_value );
    957957
     958    // If the new value is empty, remove it entirely so that get_theme_mod() returns false
     959    if ( empty( $value ) ) unset( $mods[ $name ] );
     960
    958961        $theme = get_option( 'stylesheet' );
    959962        update_option( "theme_mods_$theme", $mods );
    960963}