WP_REST_Widget_Types_Controller::get_widgets()
Normalize array of widgets.
Метод класса: WP_REST_Widget_Types_Controller{}
Хуков нет.
Возвращает
Массив
. Array of widgets.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_widgets();
Заметки
- Global. WP_Widget_Factory. $wp_widget_factory
- Global. Массив. $wp_registered_widgets The list of registered widgets.
Список изменений
С версии 5.8.0 | Введена. |
Код WP_REST_Widget_Types_Controller::get_widgets() WP REST Widget Types Controller::get widgets WP 6.6.2
protected function get_widgets() { global $wp_widget_factory, $wp_registered_widgets; $widgets = array(); foreach ( $wp_registered_widgets as $widget ) { $parsed_id = wp_parse_widget_id( $widget['id'] ); $widget_object = $wp_widget_factory->get_widget_object( $parsed_id['id_base'] ); $widget['id'] = $parsed_id['id_base']; $widget['is_multi'] = (bool) $widget_object; if ( isset( $widget['name'] ) ) { $widget['name'] = html_entity_decode( $widget['name'], ENT_QUOTES, get_bloginfo( 'charset' ) ); } if ( isset( $widget['description'] ) ) { $widget['description'] = html_entity_decode( $widget['description'], ENT_QUOTES, get_bloginfo( 'charset' ) ); } unset( $widget['callback'] ); $classname = ''; foreach ( (array) $widget['classname'] as $cn ) { if ( is_string( $cn ) ) { $classname .= '_' . $cn; } elseif ( is_object( $cn ) ) { $classname .= '_' . get_class( $cn ); } } $widget['classname'] = ltrim( $classname, '_' ); $widgets[ $widget['id'] ] = $widget; } ksort( $widgets ); return $widgets; }