WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/13/2016 02:42:04 AM (4 years ago)
Author:
westonruter
Message:

Customize: Improve extensibility of Custom CSS.

  • Add customize_value_custom_css filter to WP_Customize_Custom_CSS::value() method.
  • Introduce customize_update_custom_css_post_content_args filter in WP_Customize_Custom_CSS::update() method.
  • Make clear that wp_get_custom_css() and wp_get_custom_css filter are specifically for obtaining the value to render/display. Eliminate use of wp_get_custom_css() when getting the setting value. Use the underlying post_value directly when is_previewed.
  • Move anonymous functions handing JS previewing for custom_logo, custom_css, and background into named functions on the wp.customize.settingPreviewHandlers to allow plugins to override/extend preview logic.
  • Update _custom_background_cb to always print a style tag wen in the customizer preview, and update background preview logic to replace existing style element instead of appending a new style to the head so that background changes don't unexpectedly override any Custom CSS in the preview's stylesheet cascade.

Props westonruter, georgestephanis.
See #22058.
Fixes #38672.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/theme.php

    r39185 r39209  
    15011501    }
    15021502
    1503     if ( ! $background && ! $color )
     1503    if ( ! $background && ! $color ) {
     1504        if ( is_customize_preview() ) {
     1505            echo '<style type="text/css" id="custom-background-css"></style>';
     1506        }
    15041507        return;
     1508    }
    15051509
    15061510    $style = $color ? "background-color: #$color;" : '';
     
    16221626
    16231627/**
    1624  * Fetch the saved Custom CSS content.
     1628 * Fetch the saved Custom CSS content for rendering.
    16251629 *
    16261630 * @since 4.7.0
Note: See TracChangeset for help on using the changeset viewer.