WP_Customize_Widgets::sanitize_widget_instance( array $value )

Sanitizes a widget instance.


Description Description

Unserialize the JS-instance for storing in the options. It’s important that this filter only get applied to an instance once.


Parameters Parameters

$value

(array) (Required) Widget instance to sanitize.


Top ↑

Return Return

(array|void) Sanitized widget instance.


Top ↑

Source Source

File: wp-includes/class-wp-customize-widgets.php

	public function sanitize_widget_instance( $value ) {
		if ( array() === $value ) {
			return $value;
		}

		if ( empty( $value['is_widget_customizer_js_value'] )
			|| empty( $value['instance_hash_key'] )
			|| empty( $value['encoded_serialized_instance'] ) ) {
			return;
		}

		$decoded = base64_decode( $value['encoded_serialized_instance'], true );
		if ( false === $decoded ) {
			return;
		}

		if ( ! hash_equals( $this->get_instance_hash_key( $decoded ), $value['instance_hash_key'] ) ) {
			return;
		}

		$instance = unserialize( $decoded );
		if ( false === $instance ) {
			return;
		}

		return $instance;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.9.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.