diff --git a/packages/block-library/src/site-logo/index.php b/packages/block-library/src/site-logo/index.php index 6c0646621c323a..7e67656779b839 100644 --- a/packages/block-library/src/site-logo/index.php +++ b/packages/block-library/src/site-logo/index.php @@ -132,7 +132,7 @@ function _sync_custom_logo_to_site_logo( $value ) { * @param array $old_value Previous theme mod settings. * @param array $value Updated theme mod settings. */ -function _delete_site_logo_on_remove_custom_logo( $old_value, $value ) { +function _gutenberg_delete_site_logo_on_remove_custom_logo( $old_value, $value ) { // If the custom_logo is being unset, it's being removed from theme mods. if ( isset( $old_value['custom_logo'] ) && ! isset( $value['custom_logo'] ) ) { delete_option( 'site_logo' ); @@ -142,7 +142,7 @@ function _delete_site_logo_on_remove_custom_logo( $old_value, $value ) { /** * Deletes the site logo when all theme mods are being removed. */ -function _delete_site_logo_on_remove_theme_mods() { +function _gutenberg_delete_site_logo_on_remove_theme_mods() { if ( false !== get_theme_support( 'custom-logo' ) ) { delete_option( 'site_logo' ); } @@ -168,6 +168,11 @@ function _delete_custom_logo_on_remove_site_logo() { $theme = get_option( 'stylesheet' ); // Unhook update and delete actions for custom_logo to prevent a loop of hooks. + // Gutenberg hooks + remove_action( "update_option_theme_mods_$theme", '_gutenberg_delete_site_logo_on_remove_custom_logo', 10 ); + remove_action( "delete_option_theme_mods_$theme", '_gutenberg_delete_site_logo_on_remove_theme_mods' ); + + // Core hooks remove_action( "update_option_theme_mods_$theme", '_delete_site_logo_on_remove_custom_logo', 10 ); remove_action( "delete_option_theme_mods_$theme", '_delete_site_logo_on_remove_theme_mods' ); @@ -175,6 +180,11 @@ function _delete_custom_logo_on_remove_site_logo() { remove_theme_mod( 'custom_logo' ); // Restore update and delete actions. + // Gutenberg hooks + add_action( "update_option_theme_mods_$theme", '_gutenberg_delete_site_logo_on_remove_custom_logo', 10, 2 ); + add_action( "delete_option_theme_mods_$theme", '_gutenberg_delete_site_logo_on_remove_theme_mods' ); + + // Core hooks add_action( "update_option_theme_mods_$theme", '_delete_site_logo_on_remove_custom_logo', 10, 2 ); add_action( "delete_option_theme_mods_$theme", '_delete_site_logo_on_remove_theme_mods' ); }