Inventory_Presser_Admin_Options::detect_manage_vehicles_query_var()


Source

File: includes/admin/class-admin-options.php

	public function detect_manage_vehicles_query_var() {
		if ( 'GET' != $_SERVER['REQUEST_METHOD'] ) {
			return;
		}

		if ( empty( $_GET['_wpnonce'] ) || empty( $_GET[ self::QUERY_VAR_MANAGE_VEHICLES ] ) ) {
			return;
		}

		if ( ! wp_verify_nonce( $_GET['_wpnonce'], self::QUERY_VAR_MANAGE_VEHICLES ) ) {
			return;
		}

		$action = sanitize_text_field( $_GET[ self::QUERY_VAR_MANAGE_VEHICLES ] );
		switch ( $action ) {
			case 'delete_all_vehicles':
				INVP::delete_all_inventory();
				break;
			case 'load_sample_vehicles':
				INVP::load_sample_vehicles();
				break;
		}

		// Redirect to prevent duplicate actions on reloads.
		wp_safe_redirect( admin_url( 'edit.php?post_type=' . INVP::POST_TYPE . '&page=' . INVP::OPTION_PAGE ) );
		exit;
	}