: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
public function form_callback( $widget_args = 1 ) {
if ( is_numeric( $widget_args ) ) {
$widget_args = array( 'number' => $widget_args );
$widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) );
$all_instances = $this->get_settings();
if ( -1 === $widget_args['number'] ) {
// We echo out a form where 'number' can be set later.
$this->_set( $widget_args['number'] );
$instance = $all_instances[ $widget_args['number'] ];
* Filters the widget instance's settings before displaying the control form.
* Returning false effectively short-circuits display of the control form.
* @param array $instance The current widget instance's settings.
* @param WP_Widget $widget The current widget instance.
$instance = apply_filters( 'widget_form_callback', $instance, $this );
if ( false !== $instance ) {
$return = $this->form( $instance );
* Fires at the end of the widget control form.
* Use this hook to add extra fields to the widget form. The hook
* is only fired if the value passed to the 'widget_form_callback'
* Note: If the widget has no form, the text echoed from the default
* form method can be hidden using CSS.
* @param WP_Widget $widget The widget instance (passed by reference).
* @param null $return Return null if new fields are added.
* @param array $instance An array of the widget's settings.
do_action_ref_array( 'in_widget_form', array( &$this, &$return, $instance ) );
* Registers an instance of the widget class.
* @param int $number Optional. The unique order number of this widget instance
* compared to other instances of the same class. Default -1.
public function _register_one( $number = -1 ) {
wp_register_sidebar_widget(
$this->_get_display_callback(),
array( 'number' => $number )
_register_widget_update_callback(
$this->_get_update_callback(),
_register_widget_form_callback(
$this->_get_form_callback(),
array( 'number' => $number )
* Saves the settings for all instances of the widget class.
* @param array $settings Multi-dimensional array of widget instance settings.
public function save_settings( $settings ) {
$settings['_multiwidget'] = 1;
update_option( $this->option_name, $settings );
* Retrieves the settings for all instances of the widget class.
* @return array Multi-dimensional array of widget instance settings.
public function get_settings() {
$settings = get_option( $this->option_name );
if ( false === $settings ) {
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 ) ) {
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__'] );