Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Maps Cache #25

Open
TornMarketing opened this issue Apr 24, 2023 · 3 comments
Open

Google Maps Cache #25

TornMarketing opened this issue Apr 24, 2023 · 3 comments

Comments

@TornMarketing
Copy link

Is there any scope to support caching google map coordinates?

@zaantar
Copy link
Collaborator

zaantar commented Apr 24, 2023

@TornMarketing, what exactly do you have in mind, in terms of Toolset CLI functionality? Unfortunately, we currently have no capacity to develop new features for this tool, but we accept PRs.

@TornMarketing
Copy link
Author

With toolset maps, I haven't seen an ability to cache google coordinates for Address fields in a programmatic manner.

We use wp all import via cli to bulk import and update records for which there is no ability to insert known coordinates into the cache, field only accepts text addresses.

So looking at options to get coordinates efficiently to selectively purge, update and insert cache address records.

Only solution I have atm is to call the fronend address via the shortcode per record or manually jump in and run the missing records from admin ui

@zaantar
Copy link
Collaborator

zaantar commented May 25, 2023

I have found some pointers, there is a pretty isolated functionality for this in the Toolset Maps code.

The class Toolset_Maps_Ajax_Handler_Add_To_Cache is able to process an AJAX request with this purpose, and especially this snippet would be relevant:

		// This data is coming directly from API, and needs to be saved to cache table as is - especially the address,
		// which is later on a SQL join point between postmeta and address cache table, so even a single character
		// change would break that. That's why any sanitization and/or escaping needs to happen after the data is read
		// from database. We are protected from SQL injection, of course, in update_cached_coordinates(). And, actually
		// lat and lon are sanitized by db itself when they are inserted using ST_PointFromText() SQL function.
		$address_passed = toolset_getpost( 'address' );
		$address = toolset_getpost( 'formattedAddress' );
		$lat = toolset_getpost( 'lat' );
		$lon = toolset_getpost( 'lon' );

		if ( ! array_key_exists( $address_passed, Toolset_Addon_Maps_Common::get_cached_coordinates() ) ) {
			Toolset_Addon_Maps_Common::update_cached_coordinates( $address_passed, $address, $lat, $lon );
		}

toolset_getpost is just a helper function to safely fetching data from $_GET.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants