WP_Widget::get_settings()publicWP 2.8.0

Retrieves the settings for all instances of the widget class.

Метод класса: WP_Widget{}

Хуков нет.

Возвращает

Массив. Multi-dimensional array of widget instance settings.

Использование

$WP_Widget = new WP_Widget();
$WP_Widget->get_settings();

Список изменений

С версии 2.8.0 Введена.

Код WP_Widget::get_settings() WP 6.6.2

public function get_settings() {

	$settings = get_option( $this->option_name );

	if ( false === $settings ) {
		$settings = array();
		if ( isset( $this->alt_option_name ) ) {
			// Get settings from alternative (legacy) option.
			$settings = get_option( $this->alt_option_name, array() );

			// Delete the alternative (legacy) option as the new option will be created using `$this->option_name`.
			delete_option( $this->alt_option_name );
		}
		// Save an option so it can be autoloaded next time.
		$this->save_settings( $settings );
	}

	if ( ! is_array( $settings ) && ! ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) ) {
		$settings = array();
	}

	if ( ! empty( $settings ) && ! isset( $settings['_multiwidget'] ) ) {
		// Old format, convert if single widget.
		$settings = wp_convert_widget_settings( $this->id_base, $this->option_name, $settings );
	}

	unset( $settings['_multiwidget'], $settings['__i__'] );

	return $settings;
}