public function saveSettings() {
		// Check user permissions.
		if ( ! current_user_can( 'update_plugins' ) ) {
			wp_send_json_error( array(
				'error' => __( 'User access violation!', 'boldgrid-library' ),
			) );
		}

		// Check security nonce and referer.
		if ( ! check_admin_referer( 'boldgrid_library_connect_settings_save' ) ) {
			wp_send_json_error( array(
				'error' => __( 'Security violation! Please try again.', 'boldgrid-library' ),
			) );
		}

		// Read settings form POST request, sanitize, and merge settings with saved.
		$boldgridSettings = array_merge(
			get_option( 'boldgrid_settings' ),
			self::sanitizeSettings(
				array(
					'autoupdate'            => ! empty( $_POST['autoupdate'] ) ?
						(array) $_POST['autoupdate'] : array(),
					'release_channel'       => ! empty( $_POST['plugin_release_channel'] ) ?
						sanitize_key( $_POST['plugin_release_channel'] ) : 'stable',
					'theme_release_channel' => ! empty( $_POST['theme_release_channel'] ) ?
						sanitize_key( $_POST['theme_release_channel'] ) : 'stable',
				)
			)
		);

		// If new auto-update settings were passed, then remove deprecated settings.
		if ( ! empty( $_POST['autoupdate'] ) ) {
			unset( $boldgridSettings['plugin_autoupdate'], $boldgridSettings['theme_autoupdate'] );
		}

		update_option( 'boldgrid_settings', $boldgridSettings );

		wp_send_json_success();
	}