HEX
Server: LiteSpeed
System: Linux sg-cp4.cloudnetwork.vn 4.18.0-553.69.1.lve.el8.x86_64 #1 SMP Wed Aug 13 19:53:59 UTC 2025 x86_64
User: thu28850 (1134)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //home/thu28850/public_html/wp-content/plugins/kirki/kirki-packages/field-background/src/script.js
/* global kirkiPostMessage */

/**
 * Hook in the kirkiPostMessageStylesOutput filter.
 *
 * Handles postMessage styles for typography controls.
 */
jQuery( document ).ready( function() {
	wp.hooks.addFilter(
		'kirkiPostMessageStylesOutput',
		'kirki',

		/**
		 * Append styles for this control.
		 *
		 * @param {string} styles      - The styles.
		 * @param {Object} value       - The control value.
		 * @param {Object} output      - The control's "output" argument.
		 * @param {string} controlType - The control type.
		 * @returns {string} - Returns CSS styles as a string.
		 */
		function( styles, value, output, controlType ) {
			var processedValue;
			if ( 'kirki-background' === controlType ) {
				styles += output.element + '{';
				_.each( value, function( val, key ) {
					if ( output.choice && key !== output.choice ) {
						return;
					}
					if ( 'background-image' === key ) {
						val = -1 === val.indexOf( 'url(' ) ? 'url(' + val + ')' : val;
					}

					processedValue = kirkiPostMessage.util.processValue( output, val );

					if ( '' === processedValue ) {
						if ( 'background-color' === output.property ) {
							processedValue = 'unset';
						} else if ( 'background-image' === output.property ) {
							processedValue = 'none';
						}
					}

					if ( false !== processedValue ) {
						styles += output.property ? output.property + ':' + processedValue + ';' : key + ':' + processedValue + ';';
					}
				} );
				styles += '}';
			}
			return styles;
		}
	);
} );