Skip Navigation

[Resolved] Add API nag for maps at the top of installed plugins page in wp-admin with OSM

This thread is resolved. Here is a description of the problem and solution.

Problem:

Toolset Maps displayed a Google Maps API-key notice on the WordPress Plugins page even though OpenStreetMap was selected as the map provider.

Solution:

The issue was reproduced and reported internally. As a temporary workaround, custom code was added under Toolset → Settings → Custom Code to load dashboard-only CSS that hides the incorrect notice on plugins.php.

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 5 replies, has 1 voice.

Last updated by - 3 weeks, 6 days ago.

Assisted by: Christopher Amirian.

Author
Posts
#2875719

I am trying to:
remove wp-admin notice/nag at the top of installed plugins page

Link to a page where the issue can be seen:
only appears in wp-admin, front end is fine.
Here's a link to an image of what i see: hidden link

I expected to see:
nothing.

Instead, I got:
a nag at the top of the installed plugins page in wp-admin asking for an API key for maps when OSM is selected as the map source

#2875793

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Welcome to Toolset support. If you keep the Toolset Maps plugin enabled, that message will remain until you add the proper map key in WP Dashboard > Toolset > Settings > Map.

Thanks,

#2875860

But why would I need to use a google maps API key if I've chosen to use OpenStreetMaps?

#2876213

I see. Please go to "Toolset > Settings > Maps," select OpenStreetMap, and save the settings. This should remove the message.

If the issue persists, please provide the URL, username, and password for your WordPress dashboard after confirming that you have created a backup of your website.

It is essential that you confirm you have a backup so that you have a restore point in case anything goes wrong.

Please set your next reply as private.

#2876881

Is there any resolution to this issue? If I've picked OpenStreetmaps as my map provider, why am I still told to enter a Google API key in the wp-admin plugins area?

#2876971

Hi,

Thank you for the login information. I checked, and the same issue occurs on my installation, but only on the Plugins page. I created an internal report for this.

For now, I added the code below:

toolset_snippet_security_check() or die( 'Direct access is not allowed' );

function atx_hide_toolset_maps_api_key_notice( $hook_suffix ) {
	if ( 'plugins.php' !== $hook_suffix ) {
		return;
	}

	$handle = 'atx-hide-toolset-maps-api-key-notice';

	wp_register_style( $handle, false, array(), null );
	wp_enqueue_style( $handle );

	wp_add_inline_style(
		$handle,
		'body.plugins-php div.message.notice.notice-warning:has(i.icon-toolset-map-logo):has(a[href*="page=toolset-settings"][href*="tab=maps"]) {
			display: none !important;
		}'
	);
}
add_action( 'admin_enqueue_scripts', 'atx_hide_toolset_maps_api_key_notice' );

I added it to Toolset > Settings > Custom Code > hidemessage.php. It runs only in the WordPress Dashboard and removes the message.

Thanks.

#2877116

Hey, thanks you taught me something new, i've been using Toolset since around 2011 and never noticed that custom code area. Now I need to move a bunch of code in there! thanks a lot, much appreciated.