bsf_set_options()

Set options based on reading $_GET parameters and $_POST parameters


Description

  1. force Check updates
  2. Skip Brainstorm Account Registration
  3. Reset Brainstorm Registration data

Source

File: admin/bsf-core/index.php

	function bsf_set_options() {
		// Force check updates.
		if ( isset( $_GET['force-check-update'] ) || isset( $_GET['force-check'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended

			global $pagenow;
			global $ultimate_referer;

			if ( 'update-core.php' === $pagenow && '1' === $_GET['force-check'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
				$ultimate_referer = 'on-force-check-update-update-core';
			} else {
				$ultimate_referer = 'on-force-check-update';
			}

			bsf_check_product_update();
			update_option( 'bsf_last_update_check', current_time( 'timestamp' ) );
		}

		// Skip Author registration.
		$skip_author_products = apply_filters( 'bsf_skip_author_registration', $products = array() );
		$ids                  = array();
		$skip_author_option   = get_site_option( 'bsf_skip_author', false );
		$brainstorm_products  = bsf_get_brainstorm_products( true );
		foreach ( $brainstorm_products as $key => $product ) {

			if ( isset( $product['id'] ) && ! in_array( $product['id'], $skip_author_products, true ) ) {
				$ids[] = $product['id'];
			}
		}

		if ( isset( $_REQUEST['bsf-skip-author-nonce'] ) && wp_verify_nonce( $_REQUEST['bsf-skip-author-nonce'], 'bsf-skip-author' ) && isset( $_GET['bsf-skip-author'] ) || empty( $ids ) && '' === $skip_author_option ) {
			update_site_option( 'bsf_skip_author', true );
		} elseif ( ! empty( $ids ) && '1' === $skip_author_option ) {
			update_site_option( 'bsf_skip_author', false );
		}

		// Skip Brainstorm Menu.
		$default_skip_brainstorm_menu = array(
			'uabb',
			'convertpro',
			'astra-addon',
			'astra-pro-sites',
			'wp-schema-pro',
			'6892199', // UAVC.
			'10395942', // iMedica.
			'14058953', // Convert Plus.
			'5159016', // Baslider.
			'imedica-mu-companion',
			'astra-sites-showcase',
			'uael',
			'brainstorm-updater',
			'astra-portfolio',
			'7155037', // VC Modal Popups.
			'astra',
		);

		$skip_brainstorm_menu_products = apply_filters( 'bsf_skip_braisntorm_menu', $default_skip_brainstorm_menu );
		$ids                           = array();
		$skip_brainstorm_menu          = get_site_option( 'bsf_skip_braisntorm_menu', false );
		foreach ( $brainstorm_products as $key => $product ) {

			if ( isset( $product['id'] ) && ! in_array( $product['id'], $skip_brainstorm_menu_products, true ) ) {
				$ids[] = $product['id'];
			}
		}

		if ( empty( $ids ) && '' === $skip_brainstorm_menu ) {
			update_site_option( 'bsf_skip_braisntorm_menu', true );
		} elseif ( ! empty( $ids ) && '1' === $skip_brainstorm_menu ) {
			update_site_option( 'bsf_skip_braisntorm_menu', false );
		}

		// Reset Brainstorm Registration.
		if ( isset( $_GET['reset-bsf-users'] ) ) {
			delete_option( 'brainstrom_users' );
			delete_option( 'brainstrom_products' );
			delete_option( 'brainstrom_bundled_products' );
			delete_site_option( 'bsf_skip_author' );
		}

		// Reset Bundled products.
		if ( isset( $_GET['remove-bundled-products'] ) ) {

			global $ultimate_referer;
			$ultimate_referer = 'on-refresh-bundled-products';
			delete_option( 'brainstrom_bundled_products' );
			get_bundled_plugins();

			$redirect = isset( $_GET['redirect'] ) ? esc_url_raw( urldecode( esc_attr( $_GET['redirect'] ) ) ) : '';

			if ( '' !== $redirect && filter_var( $redirect, FILTER_VALIDATE_URL ) ) {
				$redirect = add_query_arg( 'bsf-reload-page', '', $redirect );

				wp_safe_redirect( $redirect );
				exit;
			}
		}

	}


User Contributed Notes

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