Astra_Addon_Admin_Ajax::bulk_deactivate_modules()

Deactivate all module


Description


Source

File: admin/core/includes/class-astra-addon-admin-ajax.php

	public function bulk_deactivate_modules() {

		$response_data = array( 'message' => $this->get_error_msg( 'permission' ) );

		if ( ! current_user_can( 'manage_options' ) ) {
			wp_send_json_error( $response_data );
		}

		if ( empty( $_POST ) ) {
			$response_data = array( 'message' => $this->get_error_msg( 'invalid' ) );
			wp_send_json_error( $response_data );
		}

		/**
		 * Nonce verification.
		 */
		if ( ! check_ajax_referer( 'astra_addon_update_admin_setting', 'security', false ) ) {
			$response_data = array( 'message' => $this->get_error_msg( 'nonce' ) );
			wp_send_json_error( $response_data );
		}

		// Get all extensions.
		$old_extensions = array_map( 'sanitize_text_field', Astra_Ext_Extension::get_enabled_addons() );
		$new_extensions = array();

		// Set all extension to enabled.
		foreach ( $old_extensions  as $slug => $value ) {
			$new_extensions[ $slug ] = false;
		}

		// Escape attrs.
		$new_extensions = array_map( 'esc_attr', $new_extensions );

		// Update new_extensions.
		Astra_Admin_Helper::update_admin_settings_option( '_astra_ext_enabled_extensions', $new_extensions );

		Astra_Admin_Helper::delete_admin_settings_option( '_astra_ext_http2' );

		set_transient( 'astra_addon_deactivated_transient', $new_extensions );

		wp_send_json_success();
	}


User Contributed Notes

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