: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$this->rendering_sidebar_id = $context['sidebar_id'];
if ( isset( $context['sidebar_instance_number'] ) ) {
$this->context_sidebar_instance_number = (int) $context['sidebar_instance_number'];
// Filter sidebars_widgets so that only the queried widget is in the sidebar.
$this->rendering_widget_id = $widget_id;
$filter_callback = array( $this, 'filter_sidebars_widgets_for_rendering_widget' );
add_filter( 'sidebars_widgets', $filter_callback, 1000 );
$this->rendering_sidebar_id = $context['sidebar_id'];
dynamic_sidebar( $this->rendering_sidebar_id );
$container = ob_get_clean();
// Reset variables for next partial render.
remove_filter( 'sidebars_widgets', $filter_callback, 1000 );
$this->context_sidebar_instance_number = null;
$this->rendering_sidebar_id = null;
$this->rendering_widget_id = null;
// Option Update Capturing.
* List of captured widget option updates.
* @var array $_captured_options Values updated while option capture is happening.
protected $_captured_options = array();
* Whether option capture is currently happening.
* @var bool $_is_current Whether option capture is currently happening or not.
protected $_is_capturing_option_updates = false;
* Determines whether the captured option update should be ignored.
* @param string $option_name Option name.
* @return bool Whether the option capture is ignored.
protected function is_option_capture_ignored( $option_name ) {
return ( str_starts_with( $option_name, '_transient_' ) );
* Retrieves captured widget option updates.
* @return array Array of captured options.
protected function get_captured_options() {
return $this->_captured_options;
* Retrieves the option that was captured from being saved.
* @param string $option_name Option name.
* @param mixed $default_value Optional. Default value to return if the option does not exist. Default false.
* @return mixed Value set for the option.
protected function get_captured_option( $option_name, $default_value = false ) {
if ( array_key_exists( $option_name, $this->_captured_options ) ) {
$value = $this->_captured_options[ $option_name ];
* Retrieves the number of captured widget option updates.
* @return int Number of updated options.
protected function count_captured_options() {
return count( $this->_captured_options );
* Begins keeping track of changes to widget options, caching new values.
protected function start_capturing_option_updates() {
if ( $this->_is_capturing_option_updates ) {
$this->_is_capturing_option_updates = true;
add_filter( 'pre_update_option', array( $this, 'capture_filter_pre_update_option' ), 10, 3 );
* Pre-filters captured option values before updating.
* @param mixed $new_value The new option value.
* @param string $option_name Name of the option.
* @param mixed $old_value The old option value.
* @return mixed Filtered option value.
public function capture_filter_pre_update_option( $new_value, $option_name, $old_value ) {
if ( $this->is_option_capture_ignored( $option_name ) ) {
if ( ! isset( $this->_captured_options[ $option_name ] ) ) {
add_filter( "pre_option_{$option_name}", array( $this, 'capture_filter_pre_get_option' ) );
$this->_captured_options[ $option_name ] = $new_value;
* Pre-filters captured option values before retrieving.
* @param mixed $value Value to return instead of the option value.
* @return mixed Filtered option value.
public function capture_filter_pre_get_option( $value ) {
$option_name = preg_replace( '/^pre_option_/', '', current_filter() );
if ( isset( $this->_captured_options[ $option_name ] ) ) {
$value = $this->_captured_options[ $option_name ];
/** This filter is documented in wp-includes/option.php */
$value = apply_filters( 'option_' . $option_name, $value, $option_name );
* Undoes any changes to the options since options capture began.
protected function stop_capturing_option_updates() {
if ( ! $this->_is_capturing_option_updates ) {
remove_filter( 'pre_update_option', array( $this, 'capture_filter_pre_update_option' ), 10 );
foreach ( array_keys( $this->_captured_options ) as $option_name ) {
remove_filter( "pre_option_{$option_name}", array( $this, 'capture_filter_pre_get_option' ) );
$this->_captured_options = array();
$this->_is_capturing_option_updates = false;
* {@internal Missing Summary}
* See the {@see 'customize_dynamic_setting_args'} filter.
* @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter.
public function setup_widget_addition_previews() {
_deprecated_function( __METHOD__, '4.2.0', 'customize_dynamic_setting_args' );
* {@internal Missing Summary}
* See the {@see 'customize_dynamic_setting_args'} filter.
* @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter.
public function prepreview_added_sidebars_widgets() {
_deprecated_function( __METHOD__, '4.2.0', 'customize_dynamic_setting_args' );
* {@internal Missing Summary}
* See the {@see 'customize_dynamic_setting_args'} filter.
* @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter.
public function prepreview_added_widget_instance() {
_deprecated_function( __METHOD__, '4.2.0', 'customize_dynamic_setting_args' );
* {@internal Missing Summary}
* See the {@see 'customize_dynamic_setting_args'} filter.
* @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter.
public function remove_prepreview_filters() {
_deprecated_function( __METHOD__, '4.2.0', 'customize_dynamic_setting_args' );