WP_Widget::__construct
PHP5 constructor.
Метод класса: WP_Widget{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$WP_Widget = new WP_Widget(); $WP_Widget->__construct( $id_base, $name, $widget_options, $control_options );
- $id_base(строка) (обязательный)
- Base ID for the widget, lowercase and unique. If left empty, a portion of the widget's PHP class name will be used. Has to be unique.
- $name(строка) (обязательный)
- Name for the widget displayed on the configuration page.
- $widget_options(массив)
- Widget options. See wp_register_sidebar_widget() for information on accepted arguments.
По умолчанию: empty array - $control_options(массив)
- Widget control options. See wp_register_widget_control() for information on accepted arguments.
По умолчанию: empty array
Список изменений
| С версии 2.8.0 | Введена. |
Код WP_Widget::__construct() WP Widget:: construct WP 6.8.3
public function __construct( $id_base, $name, $widget_options = array(), $control_options = array() ) {
if ( ! empty( $id_base ) ) {
$id_base = strtolower( $id_base );
} else {
$id_base = preg_replace( '/(wp_)?widget_/', '', strtolower( get_class( $this ) ) );
}
$this->id_base = $id_base;
$this->name = $name;
$this->option_name = 'widget_' . $this->id_base;
$this->widget_options = wp_parse_args(
$widget_options,
array(
'classname' => str_replace( '\\', '_', $this->option_name ),
'customize_selective_refresh' => false,
)
);
$this->control_options = wp_parse_args( $control_options, array( 'id_base' => $this->id_base ) );
}