Problem/Motivation
Shortcode Gmap is still a Drupal 7 module: it ships a legacy shortcode_gmap.info file (not .info.yml) with core = 7.x, and its .module file implements the removed procedural hook_shortcode_info() API, calling D7-only helpers such as theme(), shortcode_attrs(), shortcode_bool(), and $GLOBALS['language'].
The Shortcode module it depends on has since been rewritten around a PHP attribute-based plugin system (#[Shortcode(...)] on classes extending ShortcodeBase) and currently declares core_version_requirement: ^11.1 || ^12. Shortcode Gmap needs a full port to that architecture so it can run on Drupal 11.1+/12 alongside the current Shortcode API.
Steps to reproduce
Not applicable — this is a compatibility port, not a bug report. Attempting to enable shortcode_gmap on a Drupal 11/12 site fails outright: the module has no .info.yml, so Drupal never discovers it, and even if renamed, hook_shortcode_info() is no longer invoked by the current Shortcode module.
Proposed resolution
- Add
shortcode_gmap.info.ymlwithcore_version_requirement: ^11.1 || ^12and a dependency on the current Shortcode API (shortcode:shortcode (>=3.0)or equivalent), replacing the legacy.infofile. - Replace
shortcode_gmap_shortcode_info()with aGmapShortcodeplugin undersrc/Plugin/Shortcode/, tagged with#[Shortcode(id: 'gmap', title: ..., description: ...)]and extendingShortcodeBase, following the pattern inshortcode_basic_tags/src/Plugin/Shortcode/ImageShortcode.php. - Move attribute parsing/defaults (
include_map,include_link,width,height,address,zoom,information_bubble,link_text,address_text,map_type,langcode,url_suffix) intoprocess(), using$this->getAttributes()instead of the removedshortcode_attrs()/shortcode_bool(). - Replace
$GLOBALS['language']->languagewith the injected language manager (current interface language). - Convert
hook_theme()+theme_shortcode_gmap()into a class-based hook (#[Hook('theme')], perShortcodeBasicTagsHooks::theme()) declaring ashortcode_gmaptheme hook, and move the markup into a Twig template, dropping the manually concatenated HTML string. - Implement
tips()on the plugin instead of a standalone tips callback. - Update the map embed markup as needed (the D7 version already used the modern
maps.google.com/maps?...&output=embediframe URL, so this likely carries over largely unchanged).
Remaining tasks
- Write
shortcode_gmap.info.yml. - Implement
GmapShortcodeplugin (process(),tips()). - Add class-based hook for
hook_theme()and a Twig template for the map/link/address markup. - Remove the legacy
.infoand procedural.modulecode. - Add automated tests (Kernel or ExistingSite, per project convention).
- Run
phpcs/phpstanagainst Drupal coding standards; verify no deprecated API usage for Drupal 12. - Update
README/module description if needed.
User interface changes
None expected — the rendered map/link/address output should remain functionally equivalent to the current shortcode output.
API changes
The gmap shortcode is redefined as a plugin class (Drupal\shortcode_gmap\Plugin\Shortcode\GmapShortcode) instead of a procedural hook_shortcode_info() implementation. Any code relying on the old D7 function names (shortcode_gmap_shortcode_gmap(), theme_shortcode_gmap()) will need to be updated; there is no BC layer since the D7 API itself is gone from Drupal 11/12.
Data model changes
None.
Issue fork shortcode_gmap-3623466
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
denes.szabo commentedDone. 3.0.0 released.
Comment #5
denes.szabo commented