_attributes['style']['color']['text'] : null; $color_block_styles['text'] = $preset_text_color ? $preset_text_color : $custom_text_color; } // Background colors. if ( $has_background_colors_support && ! wp_should_skip_block_supports_serialization( $block_type, 'color', 'background' ) ) { $preset_background_color = array_key_exists( 'backgroundColor', $block_attributes ) ? "var:preset|color|{$block_attributes['backgroundColor']}" : null; $custom_background_color = isset( $block_attributes['style']['color']['background'] ) ? $block_attributes['style']['color']['background'] : null; $color_block_styles['background'] = $preset_background_color ? $preset_background_color : $custom_background_color; } // Gradients. if ( $has_gradients_support && ! wp_should_skip_block_supports_serialization( $block_type, 'color', 'gradients' ) ) { $preset_gradient_color = array_key_exists( 'gradient', $block_attributes ) ? "var:preset|gradient|{$block_attributes['gradient']}" : null; $custom_gradient_color = isset( $block_attributes['style']['color']['gradient'] ) ? $block_attributes['style']['color']['gradient'] : null; $color_block_styles['gradient'] = $preset_gradient_color ? $preset_gradient_color : $custom_gradient_color; } $attributes = array(); $styles = wp_style_engine_get_styles( array( 'color' => $color_block_styles ), array( 'convert_vars_to_classnames' => true ) ); if ( ! empty( $styles['classnames'] ) ) { $attributes['class'] = $styles['classnames']; } if ( ! empty( $styles['css'] ) ) { $attributes['style'] = $styles['css']; } return $attributes; } // Register the block support. WP_Block_Supports::get_instance()->register( 'colors', array( 'register_attribute' => 'wp_register_colors_support', 'apply' => 'wp_apply_colors_support', ) ); original script, to * avoid losing inline scripts which may have been attached. * * Adapted from `gutenberg_override_script()` in the Gutenberg plugin. * * @link https://github.com/WordPress/gutenberg/blob/132fec1fb5b4ab6af1d7696cbfe0574597644f18/lib/client-assets.php#L56-L105 * * @param WP_Scripts $scripts WP_Scripts instance. * @param string $handle Name of the script. Should be unique. * @param string $src Full URL of the script, or path of the script relative to the WordPress root directory. * @param array $deps Optional. An array of registered script handles this script depends on. Default empty array. * @param string|bool|null $ver Optional. String specifying script version number, if it has one, which is added to the URL * as a query string for cache busting purposes. If version is set to false, a version * number is automatically added equal to current installed WordPress version. * If set to null, no version is added. * @param bool $in_footer Optional. Whether to enqueue the script before instead of in the . * Default `false`. * * @return bool Whether or not the script was overridden. */ public function override_script( $scripts, $handle, $src, $deps = [], $ver = false, $in_footer = false ) { $script = $scripts->query( $handle, 'registered' ); if ( $script ) { /* * In many ways, this is a reimplementation of `wp_register_script` but * bypassing consideration of whether a script by the given handle had * already been registered. */ // See: `_WP_Dependency::__construct()`. $script->src = $src; $script->deps = $deps; $script->ver = $ver; $script->args = $in_footer; /* * The script's `group` designation is an indication of whether it is * to be printed in the header or footer. The behavior here defers to * the arguments as passed. Specifically, group data is not assigned * for a script unless it is designated to be printed in the footer. */ // See: `wp_register_script()` . unset( $script->extra['group'] ); if ( $in_footer ) { $script->add_data( 'group', 1 ); } } else { $scripts->add( $handle, $src, $deps, $ver, $in_footer ); } return (bool) $script; } /** * Registers a style according to `wp_register_style`. Honors this request by deregistering any style by the same * handler before registration. * * Adapted from `gutenberg_override_style()` in the Gutenberg plugin. * * @link https://github.com/WordPress/gutenberg/blob/132fec1fb5b4ab6af1d7696cbfe0574597644f18/lib/client-assets.php#L177-L182 * * @param WP_Styles $styles WP_Styles instance. * @param string $handle Name of the stylesheet. Should be unique. * @param string $src Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory. * @param array $deps Optional. An array of registered stylesheet handles this stylesheet depends on. Default empty array. * @param string|bool|null $ver Optional. String specifying stylesheet version number, if it has one, which is added to the URL * as a query string for cache busting purposes. If version is set to false, a version * number is automatically added equal to current installed WordPress version. * If set to null, no version is added. * @param string $media Optional. The media for which this stylesheet has been defined. * Default 'all'. Accepts media types like 'all', 'print' and 'screen', or media queries like * '(orientation: portrait)' and '(max-width: 640px)'. */ public function override_style( $styles, $handle, $src, $deps = [], $ver = false, $media = 'all' ) { $style = $styles->query( $handle, 'registered' ); if ( $style ) { $styles->remove( $handle ); } $styles->add( $handle, $src, $deps, $ver, $media ); } } original script, to * avoid losing inline scripts which may have been attached. * * Adapted from `gutenberg_override_script()` in the Gutenberg plugin. * * @link https://github.com/WordPress/gutenberg/blob/132fec1fb5b4ab6af1d7696cbfe0574597644f18/lib/client-assets.php#L56-L105 * * @param WP_Scripts $scripts WP_Scripts instance. * @param string $handle Name of the script. Should be unique. * @param string $src Full URL of the script, or path of the script relative to the WordPress root directory. * @param array $deps Optional. An array of registered script handles this script depends on. Default empty array. * @param string|bool|null $ver Optional. String specifying script version number, if it has one, which is added to the URL * as a query string for cache busting purposes. If version is set to false, a version * number is automatically added equal to current installed WordPress version. * If set to null, no version is added. * @param bool $in_footer Optional. Whether to enqueue the script before instead of in the . * Default `false`. * * @return bool Whether or not the script was overridden. */ public function override_script( $scripts, $handle, $src, $deps = [], $ver = false, $in_footer = false ) { $script = $scripts->query( $handle, 'registered' ); if ( $script ) { /* * In many ways, this is a reimplementation of `wp_register_script` but * bypassing consideration of whether a script by the given handle had * already been registered. */ // See: `_WP_Dependency::__construct()`. $script->src = $src; $script->deps = $deps; $script->ver = $ver; $script->args = $in_footer; /* * The script's `group` designation is an indication of whether it is * to be printed in the header or footer. The behavior here defers to * the arguments as passed. Specifically, group data is not assigned * for a script unless it is designated to be printed in the footer. */ // See: `wp_register_script()` . unset( $script->extra['group'] ); if ( $in_footer ) { $script->add_data( 'group', 1 ); } } else { $scripts->add( $handle, $src, $deps, $ver, $in_footer ); } return (bool) $script; } /** * Registers a style according to `wp_register_style`. Honors this request by deregistering any style by the same * handler before registration. * * Adapted from `gutenberg_override_style()` in the Gutenberg plugin. * * @link https://github.com/WordPress/gutenberg/blob/132fec1fb5b4ab6af1d7696cbfe0574597644f18/lib/client-assets.php#L177-L182 * * @param WP_Styles $styles WP_Styles instance. * @param string $handle Name of the stylesheet. Should be unique. * @param string $src Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory. * @param array $deps Optional. An array of registered stylesheet handles this stylesheet depends on. Default empty array. * @param string|bool|null $ver Optional. String specifying stylesheet version number, if it has one, which is added to the URL * as a query string for cache busting purposes. If version is set to false, a version * number is automatically added equal to current installed WordPress version. * If set to null, no version is added. * @param string $media Optional. The media for which this stylesheet has been defined. * Default 'all'. Accepts media types like 'all', 'print' and 'screen', or media queries like * '(orientation: portrait)' and '(max-width: 640px)'. */ public function override_style( $styles, $handle, $src, $deps = [], $ver = false, $media = 'all' ) { $style = $styles->query( $handle, 'registered' ); if ( $style ) { $styles->remove( $handle ); } $styles->add( $handle, $src, $deps, $ver, $media ); } } original script, to * avoid losing inline scripts which may have been attached. * * Adapted from `gutenberg_override_script()` in the Gutenberg plugin. * * @link https://github.com/WordPress/gutenberg/blob/132fec1fb5b4ab6af1d7696cbfe0574597644f18/lib/client-assets.php#L56-L105 * * @param WP_Scripts $scripts WP_Scripts instance. * @param string $handle Name of the script. Should be unique. * @param string $src Full URL of the script, or path of the script relative to the WordPress root directory. * @param array $deps Optional. An array of registered script handles this script depends on. Default empty array. * @param string|bool|null $ver Optional. String specifying script version number, if it has one, which is added to the URL * as a query string for cache busting purposes. If version is set to false, a version * number is automatically added equal to current installed WordPress version. * If set to null, no version is added. * @param bool $in_footer Optional. Whether to enqueue the script before instead of in the . * Default `false`. * * @return bool Whether or not the script was overridden. */ public function override_script( $scripts, $handle, $src, $deps = [], $ver = false, $in_footer = false ) { $script = $scripts->query( $handle, 'registered' ); if ( $script ) { /* * In many ways, this is a reimplementation of `wp_register_script` but * bypassing consideration of whether a script by the given handle had * already been registered. */ // See: `_WP_Dependency::__construct()`. $script->src = $src; $script->deps = $deps; $script->ver = $ver; $script->args = $in_footer; /* * The script's `group` designation is an indication of whether it is * to be printed in the header or footer. The behavior here defers to * the arguments as passed. Specifically, group data is not assigned * for a script unless it is designated to be printed in the footer. */ // See: `wp_register_script()` . unset( $script->extra['group'] ); if ( $in_footer ) { $script->add_data( 'group', 1 ); } } else { $scripts->add( $handle, $src, $deps, $ver, $in_footer ); } return (bool) $script; } /** * Registers a style according to `wp_register_style`. Honors this request by deregistering any style by the same * handler before registration. * * Adapted from `gutenberg_override_style()` in the Gutenberg plugin. * * @link https://github.com/WordPress/gutenberg/blob/132fec1fb5b4ab6af1d7696cbfe0574597644f18/lib/client-assets.php#L177-L182 * * @param WP_Styles $styles WP_Styles instance. * @param string $handle Name of the stylesheet. Should be unique. * @param string $src Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory. * @param array $deps Optional. An array of registered stylesheet handles this stylesheet depends on. Default empty array. * @param string|bool|null $ver Optional. String specifying stylesheet version number, if it has one, which is added to the URL * as a query string for cache busting purposes. If version is set to false, a version * number is automatically added equal to current installed WordPress version. * If set to null, no version is added. * @param string $media Optional. The media for which this stylesheet has been defined. * Default 'all'. Accepts media types like 'all', 'print' and 'screen', or media queries like * '(orientation: portrait)' and '(max-width: 640px)'. */ public function override_style( $styles, $handle, $src, $deps = [], $ver = false, $media = 'all' ) { $style = $styles->query( $handle, 'registered' ); if ( $style ) { $styles->remove( $handle ); } $styles->add( $handle, $src, $deps, $ver, $media ); } } original script, to * avoid losing inline scripts which may have been attached. * * Adapted from `gutenberg_override_script()` in the Gutenberg plugin. * * @link https://github.com/WordPress/gutenberg/blob/132fec1fb5b4ab6af1d7696cbfe0574597644f18/lib/client-assets.php#L56-L105 * * @param WP_Scripts $scripts WP_Scripts instance. * @param string $handle Name of the script. Should be unique. * @param string $src Full URL of the script, or path of the script relative to the WordPress root directory. * @param array $deps Optional. An array of registered script handles this script depends on. Default empty array. * @param string|bool|null $ver Optional. String specifying script version number, if it has one, which is added to the URL * as a query string for cache busting purposes. If version is set to false, a version * number is automatically added equal to current installed WordPress version. * If set to null, no version is added. * @param bool $in_footer Optional. Whether to enqueue the script before instead of in the . * Default `false`. * * @return bool Whether or not the script was overridden. */ public function override_script( $scripts, $handle, $src, $deps = [], $ver = false, $in_footer = false ) { $script = $scripts->query( $handle, 'registered' ); if ( $script ) { /* * In many ways, this is a reimplementation of `wp_register_script` but * bypassing consideration of whether a script by the given handle had * already been registered. */ // See: `_WP_Dependency::__construct()`. $script->src = $src; $script->deps = $deps; $script->ver = $ver; $script->args = $in_footer; /* * The script's `group` designation is an indication of whether it is * to be printed in the header or footer. The behavior here defers to * the arguments as passed. Specifically, group data is not assigned * for a script unless it is designated to be printed in the footer. */ // See: `wp_register_script()` . unset( $script->extra['group'] ); if ( $in_footer ) { $script->add_data( 'group', 1 ); } } else { $scripts->add( $handle, $src, $deps, $ver, $in_footer ); } return (bool) $script; } /** * Registers a style according to `wp_register_style`. Honors this request by deregistering any style by the same * handler before registration. * * Adapted from `gutenberg_override_style()` in the Gutenberg plugin. * * @link https://github.com/WordPress/gutenberg/blob/132fec1fb5b4ab6af1d7696cbfe0574597644f18/lib/client-assets.php#L177-L182 * * @param WP_Styles $styles WP_Styles instance. * @param string $handle Name of the stylesheet. Should be unique. * @param string $src Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory. * @param array $deps Optional. An array of registered stylesheet handles this stylesheet depends on. Default empty array. * @param string|bool|null $ver Optional. String specifying stylesheet version number, if it has one, which is added to the URL * as a query string for cache busting purposes. If version is set to false, a version * number is automatically added equal to current installed WordPress version. * If set to null, no version is added. * @param string $media Optional. The media for which this stylesheet has been defined. * Default 'all'. Accepts media types like 'all', 'print' and 'screen', or media queries like * '(orientation: portrait)' and '(max-width: 640px)'. */ public function override_style( $styles, $handle, $src, $deps = [], $ver = false, $media = 'all' ) { $style = $styles->query( $handle, 'registered' ); if ( $style ) { $styles->remove( $handle ); } $styles->add( $handle, $src, $deps, $ver, $media ); } } Redirecting since AMP version not available.