WP_Customize_Widgets::parse_widget_setting_id()
Converts a widget setting ID (option path) to its id_base and number components.
Метод класса: WP_Customize_Widgets{}
Хуков нет.
Возвращает
Массив|WP_Error
. Array containing a widget's id_base and number components, or a WP_Error object.
Использование
$WP_Customize_Widgets = new WP_Customize_Widgets(); $WP_Customize_Widgets->parse_widget_setting_id( $setting_id );
- $setting_id(строка) (обязательный)
- Widget setting ID.
Список изменений
С версии 3.9.0 | Введена. |
Код WP_Customize_Widgets::parse_widget_setting_id() WP Customize Widgets::parse widget setting id WP 6.6.1
public function parse_widget_setting_id( $setting_id ) { if ( ! preg_match( '/^(widget_(.+?))(?:\[(\d+)\])?$/', $setting_id, $matches ) ) { return new WP_Error( 'widget_setting_invalid_id' ); } $id_base = $matches[2]; $number = isset( $matches[3] ) ? (int) $matches[3] : null; return compact( 'id_base', 'number' ); }