mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-09 07:00:01 +00:00
Themes: Add a return value to set_theme_mod()
to allow for error handling.
Props latifi, hareesh-pillai. Fixes #51296. Built from https://develop.svn.wordpress.org/trunk@49214 git-svn-id: http://core.svn.wordpress.org/trunk@48976 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
80be8c138d
commit
caa75a04a8
@ -1038,9 +1038,11 @@ function get_theme_mod( $name, $default = false ) {
|
|||||||
* Updates theme modification value for the current theme.
|
* Updates theme modification value for the current theme.
|
||||||
*
|
*
|
||||||
* @since 2.1.0
|
* @since 2.1.0
|
||||||
|
* @since 5.6.0 A return value was added.
|
||||||
*
|
*
|
||||||
* @param string $name Theme modification name.
|
* @param string $name Theme modification name.
|
||||||
* @param mixed $value Theme modification value.
|
* @param mixed $value Theme modification value.
|
||||||
|
* @return bool True if the value was updated, false otherwise.
|
||||||
*/
|
*/
|
||||||
function set_theme_mod( $name, $value ) {
|
function set_theme_mod( $name, $value ) {
|
||||||
$mods = get_theme_mods();
|
$mods = get_theme_mods();
|
||||||
@ -1061,7 +1063,8 @@ function set_theme_mod( $name, $value ) {
|
|||||||
$mods[ $name ] = apply_filters( "pre_set_theme_mod_{$name}", $value, $old_value );
|
$mods[ $name ] = apply_filters( "pre_set_theme_mod_{$name}", $value, $old_value );
|
||||||
|
|
||||||
$theme = get_option( 'stylesheet' );
|
$theme = get_option( 'stylesheet' );
|
||||||
update_option( "theme_mods_$theme", $mods );
|
|
||||||
|
return update_option( "theme_mods_$theme", $mods );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1087,7 +1090,9 @@ function remove_theme_mod( $name ) {
|
|||||||
remove_theme_mods();
|
remove_theme_mods();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$theme = get_option( 'stylesheet' );
|
$theme = get_option( 'stylesheet' );
|
||||||
|
|
||||||
update_option( "theme_mods_$theme", $mods );
|
update_option( "theme_mods_$theme", $mods );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1104,6 +1109,7 @@ function remove_theme_mods() {
|
|||||||
if ( false === $theme_name ) {
|
if ( false === $theme_name ) {
|
||||||
$theme_name = wp_get_theme()->get( 'Name' );
|
$theme_name = wp_get_theme()->get( 'Name' );
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_option( 'mods_' . $theme_name );
|
delete_option( 'mods_' . $theme_name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.6-alpha-49213';
|
$wp_version = '5.6-alpha-49214';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user