Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A Mapbox-backed WordPress map block. Markers are child blocks holding a coordinate pair plus arbitrary content, revealed either as a carousel of slides beside/below the map or as popup cards inside it.

Extracted and generalized from the map functionality we built for the Wikimedia Foundation's digital-first annual reports.
Extracted and generalized from the map functionality built for the Wikimedia Foundation's [digital-first annual reports plugin](https://github.com/wikimedia/wikimedia-wordpress-annual-report-plugin/).

## Features

Expand Down Expand Up @@ -41,19 +41,6 @@ The blocks work out of the box, but visual design is intentionally left to the i
- **JS events**: the block wrapper dispatches `hm-map:ready` (detail: `{ map }`) and `hm-map:pin-activate` (detail: `{ index }`) CustomEvents for site code to hook into.
- **Content Security Policy**: if your site sends a CSP, allow `https://api.mapbox.com` in `script-src`/`style-src`, `https://api.mapbox.com https://events.mapbox.com` in `connect-src`, and `blob:` in `worker-src` (Mapbox GL uses web workers).

## Migrating from the annual report plugin

Content authored with `wmf-reports/map` and `wmf-reports/marker` keeps rendering on the frontend: the legacy block names are registered against the current render templates (editor support is not provided for the legacy names).

To migrate stored content to the new format, run:

```
wp hm-map migrate --dry-run # report what would change
wp hm-map migrate # rewrite block names, slide classes, and copy the API key option
```

The command rewrites the block delimiters, renames the `wmf-pattern-reports-carousel-slide` class to `hm-map-slide`, and copies the `wmf-map-api-key` option to `hm_map_api_key` if unset. `wmf-reports/overlay` blocks (a separate feature of the source plugin) are left untouched. Note the default map style is now Mapbox Light rather than Wikimedia's custom style; set a Custom style URI on migrated maps if the old look is required.

## Development

### Build commands
Expand Down
5 changes: 2 additions & 3 deletions inc/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function bootstrap(): void {
// Enqueue frontend assets when a map actually renders: has_block() based
// checks miss archive and home views which render many posts.
add_filter( 'render_block_hm/map', __NAMESPACE__ . '\\enqueue_frontend_assets', 10, 2 );
add_filter( 'render_block_wmf-reports/map', __NAMESPACE__ . '\\enqueue_frontend_assets', 10, 2 );
}

/**
Expand Down Expand Up @@ -80,8 +79,8 @@ function enqueue_editor_mapbox_styles(): void {
/**
* Enqueue Mapbox styles and localize the API key when a map block renders.
*
* Runs on the render_block filter for both current and legacy block names,
* which fires before footer scripts print regardless of the query type.
* Runs on the render_block filter, which fires before footer scripts print
* regardless of the query type.
*
* @param string $block_content Rendered block markup.
* @param array $block Parsed block, including attributes.
Expand Down
110 changes: 0 additions & 110 deletions inc/cli.php

This file was deleted.

90 changes: 0 additions & 90 deletions inc/compat.php

This file was deleted.

2 changes: 0 additions & 2 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ function bootstrap(): void {

Assets\bootstrap();
Settings\bootstrap();
Compat\bootstrap();
CLI\bootstrap();
}

/**
Expand Down
2 changes: 0 additions & 2 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,5 @@
require_once __DIR__ . '/inc/namespace.php';
require_once __DIR__ . '/inc/assets.php';
require_once __DIR__ . '/inc/settings.php';
require_once __DIR__ . '/inc/compat.php';
require_once __DIR__ . '/inc/cli.php';

bootstrap();