WP_Customize_Widgets::sanitize_sidebar_widgets( string[] $widget_ids )

Ensures sidebar widget arrays only ever contain widget IDS.


Description Description

Used as the ‘sanitize_callback’ for each $sidebars_widgets setting.


Parameters Parameters

$widget_ids

(string[]) (Required) Array of widget IDs.


Top ↑

Return Return

(string[]) Array of sanitized widget IDs.


Top ↑

Source Source

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

	public function sanitize_sidebar_widgets( $widget_ids ) {
		$widget_ids           = array_map( 'strval', (array) $widget_ids );
		$sanitized_widget_ids = array();
		foreach ( $widget_ids as $widget_id ) {
			$sanitized_widget_ids[] = preg_replace( '/[^a-z0-9_\-]/', '', $widget_id );
		}
		return $sanitized_widget_ids;
	}

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.