packages/kirki-framework/module-postmessage/src/Module.php
public function postmessage() {
		wp_enqueue_script( 'kirki_auto_postmessage', URL::get_from_path( __DIR__ . '/assets/scripts/script.js' ), [ 'jquery', 'customize-preview' ], KIRKI_VERSION, true );
		$fields = array_merge( Kirki::$fields, $this->fields );
		$data   = [];
		foreach ( $fields as $field ) {
			if ( isset( $field['transport'] ) && 'postMessage' === $field['transport'] && isset( $field['js_vars'] ) && ! empty( $field['js_vars'] ) && is_array( $field['js_vars'] ) && isset( $field['settings'] ) ) {
				$data[] = $field;
			}
		}
		wp_localize_script( 'kirki_auto_postmessage', 'kirkiPostMessageFields', $data );
		$extras = apply_filters( 'kirki_postmessage_script', false );
		if ( $extras ) {
			wp_add_inline_script( 'kirki_auto_postmessage', $extras, 'after' );
		}
	}
public function postmessage() {
		wp_enqueue_script( 'kirki_auto_postmessage', URL::get_from_path( __DIR__ . '/assets/scripts/script.js' ), [ 'jquery', 'customize-preview' ], KIRKI_VERSION, true );
		$fields = array_merge( Kirki::$fields, $this->fields );
		$data   = [];
		foreach ( $fields as $field ) {
			if ( isset( $field['transport'] ) && 'postMessage' === $field['transport'] && isset( $field['js_vars'] ) && ! empty( $field['js_vars'] ) && is_array( $field['js_vars'] ) && isset( $field['settings'] ) ) {
				$data[] = $field;
			}
		}
		wp_localize_script( 'kirki_auto_postmessage', 'kirkiPostMessageFields', $data );
		$extras = apply_filters( 'kirki_postmessage_script', false );
		if ( $extras ) {
			wp_add_inline_script( 'kirki_auto_postmessage', $extras, 'after' );
		}
	}
public function postmessage ( ) { wp_enqueue_script ( 'kirki_auto_postmessage' , URL :: get_from_path ( __DIR__ . '/assets/scripts/script.js' ) , [ 'jquery' , 'customize-preview' ] , KIRKI_VERSION , true ) ; $ fields = array_merge ( Kirki :: $ fields , $ this -> fields ) ; $ data = [ ] ; foreach ( $ fields as $ field ) { if ( isset ( $ field [ 'transport' ] ) && 'postMessage' === $ field [ 'transport' ] && isset ( $ field [ 'js_vars' ] ) && ! empty ( $ field [ 'js_vars' ] ) && is_array ( $ field [ 'js_vars' ] ) && isset ( $ field [ 'settings' ] ) ) { $ data [ ] = $ field ; } } wp_localize_script ( 'kirki_auto_postmessage' , 'kirkiPostMessageFields' , $ data ) ; $ extras = apply_filters ( 'kirki_postmessage_script' , false ) ; if ( $ extras ) { wp_add_inline_script ( 'kirki_auto_postmessage' , $ extras , 'after' ) ; } }
Enqueues the postMessage script
and adds variables to it using the wp_localize_script function.
The rest is handled via JS.
Enqueues the postMessage script and adds variables to it using the wp_localize_script function . The rest is handled via JS .