astra_remove_widget_design_options()

Check whether widget specific config, dynamic CSS, preview JS needs to remove or not. Following cases considered while implementing this.


Description

  1. Is user is from old Astra setup.
  2. Check if user is new but on lesser WordPress 5.8 versions.
  3. User is new with block widget editor.

Return

(boolean)


Source

File: inc/extras.php

function astra_remove_widget_design_options() {
	$astra_settings               = get_option( ASTRA_THEME_SETTINGS );
	$remove_widget_design_options = isset( $astra_settings['remove-widget-design-options'] ) ? false : true;

	// True -> Hide widget sections, False -> Display widget sections.
	$is_widget_design_sections_hidden = true;

	if ( ! $remove_widget_design_options ) {
		// For old users we will show widget design options by anyways.
		return apply_filters( 'astra_remove_widget_design_options', false );
	}

	// Considering the user is new now.
	if ( isset( $astra_settings['remove-widget-design-options'] ) && $astra_settings['remove-widget-design-options'] ) {
		// User was on WP-5.8 lesser version previously and he may update their WordPress to 5.8 in future. So we display the options in this case.
		$is_widget_design_sections_hidden = false;
	} elseif ( astra_has_widgets_block_editor() ) {
		// User is new & having block widgets active. So we will hide those options.
		$is_widget_design_sections_hidden = true;
	} else {
		// Setting up flag because user is on lesser WP versions and may update WP to 5.8.
		astra_update_option( 'remove-widget-design-options', true );
	}

	return apply_filters( 'astra_remove_widget_design_options', $is_widget_design_sections_hidden );
}

Changelog

Changelog
Version Description
3.6.8 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.