Astra_Addon_Admin_Ajax::enable_disable_file_generation()

Ajax handler to enable / disable the file generation of scripts/styles for Astra Theme and Astra Pro.


Description


Return

(void)


Source

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

	public function enable_disable_file_generation() {
		$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 );
		}

		$status = isset( $_POST['status'] ) ? sanitize_text_field( $_POST['status'] ) : false;

		if ( false !== $status ) {
			update_option( '_astra_file_generation', $status );
			wp_send_json_success();
		}

		wp_send_json_error();
	}

Changelog

Changelog
Version Description
1.5.1 Introduced.


User Contributed Notes

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