GC_Customize_Widgets::parse_widget_setting_id()
最后更新于:2021-11-27 11:36:26
GC_Customize_Widgets::parse_widget_setting_id( string$setting_id)Converts a widget setting ID (option path) to its id_base and number components.
参数
- $setting_id
-
(string) (Required) Widget setting ID.
响应
(array|GC_Error) Array containing a widget’s id_base and number components, or a GC_Error object.
源文件
文件: gc-includes/class-gc-customize-widgets.php
public function parse_widget_setting_id( $setting_id ) {
if ( ! preg_match( '/^(widget_(.+?))(?:[(d+)])?$/', $setting_id, $matches ) ) {
return new GC_Error( 'widget_setting_invalid_id' );
}
$id_base = $matches[2];
$number = isset( $matches[3] ) ? (int) $matches[3] : null;
return compact( 'id_base', 'number' );
}