Skip to content

Allow reset of settings if block_visibility_settings is empty #130

Description

@jam1e

During a generic site update, the option block_visibility_settings was emptied (Nothing to do with the block-visibility plugin).

As we had no settings saved, we weren't able to see the block visibility settings within the block editor. I attempted to reset the settings from the plugin settings page, but was unable to do so.

The issue came from the class-block-visibility-reset-settings-controller.php on line 97.

if ( ! get_option( 'block_visibility_settings' ) ) {
	return new WP_Error( '500', $error_message, array( 'status' => 500 ) );
}

if ( isset( $settings['reset'] ) ) {
	if ( 'all' === $settings['reset'] ) {

		// Delete the currently saved settings and pull the defaults.
		delete_option( 'block_visibility_settings' );
		$new_settings = get_option( 'block_visibility_settings' );

		// ...
	}
}

Would it be possible to have the option not required before deleting the option, and then regenerating it?

Sorry if I've worded this terribly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions