Make WordPress Core


Ignore:
Timestamp:
07/13/2021 04:39:05 PM (3 years ago)
Author:
youknowriad
Message:

Block Editor: Include the fixes targetted for WordPress 5.8 RC3.

This includes the following fixes:

  • Safari: see if compositing layer size is more reasonable when position fixed divs are not inserted into content.
  • Site Logo Block: update Site Logo block UI and option syncing.
  • Fix moving inner blocks in the Widgets Customizer.
  • Allow themes to provide empty values for color.duotone and spacing.units
  • Update getTermsInfo() to workaround parsing issue for translatable strings.
  • Specify what settings can be part of settings.layout.
  • Update conditions to hide duotone panel.
  • Prevent entering invalid values in the Query Loop block config.
  • Prevent color panel from showing as empty.
  • Avoid calling gutenberg_ functions within code shipped through WordPress Core.

Props desrosj.
See #53397.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks/site-logo.php

    r51091 r51421  
    1515function render_block_core_site_logo( $attributes ) {
    1616    $adjust_width_height_filter = function ( $image ) use ( $attributes ) {
    17         if ( empty( $attributes['width'] ) ) {
     17        if ( empty( $attributes['width'] ) || empty( $image ) ) {
    1818            return $image;
    1919        }
     
    112112 * Updates the site_logo option when the custom_logo theme-mod gets updated.
    113113 *
    114  * This function is hooked on "update_option_theme_mods_$theme" and not
    115  * "pre_set_theme_mod_custom_logo" because by hooking in `update_option`
    116  * the function accounts for remove_theme_mod() as well.
    117  *
    118  * @param mixed $old_value The old option value.
    119  * @param mixed $value     The new option value.
     114 * @param  mixed $value Attachment ID of the custom logo or an empty value.
     115 * @return mixed
    120116 */
    121 function _sync_custom_logo_to_site_logo( $old_value, $value ) {
    122     // Delete the option when the custom logo does not exist or was removed.
    123     // This step ensures the option stays in sync.
    124     if ( empty( $value['custom_logo'] ) ) {
     117function _sync_custom_logo_to_site_logo( $value ) {
     118    if ( empty( $value ) ) {
    125119        delete_option( 'site_logo' );
    126120    } else {
    127         remove_action( 'update_option_site_logo', '_sync_site_logo_to_custom_logo' );
    128         update_option( 'site_logo', $value['custom_logo'] );
    129         add_action( 'update_option_site_logo', '_sync_site_logo_to_custom_logo', 10, 2 );
     121        update_option( 'site_logo', $value );
     122    }
     123
     124    return $value;
     125}
     126
     127add_filter( 'pre_set_theme_mod_custom_logo', '_sync_custom_logo_to_site_logo' );
     128
     129/**
     130 * Deletes the site_logo when the custom_logo theme mod is removed.
     131 *
     132 * @param array $old_value Previous theme mod settings.
     133 * @param array $value     Updated theme mod settings.
     134 */
     135function _delete_site_logo_on_remove_custom_logo( $old_value, $value ) {
     136    // If the custom_logo is being unset, it's being removed from theme mods.
     137    if ( isset( $old_value['custom_logo'] ) && ! isset( $value['custom_logo'] ) ) {
     138        delete_option( 'site_logo' );
    130139    }
    131140}
    132141
    133142/**
    134  * Hooks `_sync_custom_logo_to_site_logo` in `update_option_theme_mods_$theme`.
     143 * Deletes the site logo when all theme mods are being removed.
     144 */
     145function _delete_site_logo_on_remove_theme_mods() {
     146    if ( false !== get_theme_support( 'custom-logo' ) ) {
     147        delete_option( 'site_logo' );
     148    }
     149}
     150
     151/**
     152 * Hooks `_delete_site_logo_on_remove_custom_logo` in `update_option_theme_mods_$theme`.
     153 * Hooks `_delete_site_logo_on_remove_theme_mods` in `delete_option_theme_mods_$theme`.
    135154 *
    136155 * Runs on `setup_theme` to account for dynamically-switched themes in the Customizer.
    137156 */
    138 function _sync_custom_logo_to_site_logo_on_setup_theme() {
     157function _delete_site_logo_on_remove_custom_logo_on_setup_theme() {
    139158    $theme = get_option( 'stylesheet' );
    140     add_action( "update_option_theme_mods_$theme", '_sync_custom_logo_to_site_logo', 10, 2 );
     159    add_action( "update_option_theme_mods_$theme", '_delete_site_logo_on_remove_custom_logo', 10, 2 );
     160    add_action( "delete_option_theme_mods_$theme", '_delete_site_logo_on_remove_theme_mods' );
    141161}
    142 add_action( 'setup_theme', '_sync_custom_logo_to_site_logo_on_setup_theme', 11 );
    143 
    144 /**
    145  * Updates the custom_logo theme-mod when the site_logo option gets updated.
    146  *
    147  * @param mixed $old_value The old option value.
    148  * @param mixed $value     The new option value.
    149  *
    150  * @return void
    151  */
    152 function _sync_site_logo_to_custom_logo( $old_value, $value ) {
    153     // Delete the option when the custom logo does not exist or was removed.
    154     // This step ensures the option stays in sync.
    155     if ( empty( $value ) ) {
    156         remove_theme_mod( 'custom_logo' );
    157     } else {
    158         remove_filter( 'pre_set_theme_mod_custom_logo', '_sync_custom_logo_to_site_logo' );
    159         set_theme_mod( 'custom_logo', $value );
    160         add_filter( 'pre_set_theme_mod_custom_logo', '_sync_custom_logo_to_site_logo' );
    161     }
    162 }
    163 
    164 add_action( 'update_option_site_logo', '_sync_site_logo_to_custom_logo', 10, 2 );
     162add_action( 'setup_theme', '_delete_site_logo_on_remove_custom_logo_on_setup_theme', 11 );
Note: See TracChangeset for help on using the changeset viewer.