GC_Customize_Widgets::sanitize_sidebar_widgets()
最后更新于:2021-11-27 12:14:27
GC_Customize_Widgets::sanitize_sidebar_widgets( string[]$widget_ids)Ensures sidebar widget arrays only ever contain widget IDS.
参数
- $widget_ids
-
(string[]) (Required) Array of widget IDs.
响应
(string[]) Array of sanitized widget IDs.
源文件
文件: gc-includes/class-gc-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;
}