El botón del lightbox copia la URL de la imagen del mapa (v1.6.0)

Sustituye el botón de compartir por «Copy map URL»: copia al
portapapeles la URL del archivo de imagen a tamaño completo del mapa
visible, en lugar del enlace con ancla #map-<slug>, que resultaba
confuso. Los enlaces #map-<slug> siguen funcionando al abrirlos.
This commit is contained in:
Ana
2026-07-17 18:02:33 +02:00
parent aed764c130
commit b860cf6c40
2 changed files with 9 additions and 17 deletions
+6 -14
View File
@@ -128,14 +128,6 @@
* Shareable URLs: #map-<slug> selects that map on page load. * Shareable URLs: #map-<slug> selects that map on page load.
* ---------------------------------------------------------------- */ * ---------------------------------------------------------------- */
function shareUrl() {
var base = window.location.href.split('#')[0];
if (!current) {
return base;
}
return base + HASH_PREFIX + encodeURIComponent(current.getAttribute('data-slug'));
}
function openFromHash() { function openFromHash() {
if (window.location.hash.indexOf(HASH_PREFIX) !== 0) { if (window.location.hash.indexOf(HASH_PREFIX) !== 0) {
return; return;
@@ -185,8 +177,8 @@
'<figure class="geep-lightbox-inner">' + '<figure class="geep-lightbox-inner">' +
'<div class="geep-lightbox-actions">' + '<div class="geep-lightbox-actions">' +
'<button type="button" class="geep-lightbox-btn geep-lightbox-share">' + '<button type="button" class="geep-lightbox-btn geep-lightbox-share">' +
'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.6" y1="10.6" x2="15.4" y2="6.4"/><line x1="8.6" y1="13.4" x2="15.4" y2="17.6"/></svg>' + '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>' +
'<span>' + (labels.share || 'Share map') + '</span>' + '<span>' + (labels.copy || 'Copy map URL') + '</span>' +
'</button>' + '</button>' +
'<button type="button" class="geep-lightbox-btn geep-lightbox-close" aria-label="' + (labels.close || 'Close') + '">&#215;</button>' + '<button type="button" class="geep-lightbox-btn geep-lightbox-close" aria-label="' + (labels.close || 'Close') + '">&#215;</button>' +
'</div>' + '</div>' +
@@ -262,12 +254,12 @@
} }
function share() { function share() {
var url = shareUrl(); // Copy the full-size image URL of the map currently on screen.
var title = current ? current.querySelector('.geep-toggle-title').textContent : document.title; var active = root.querySelector('.geep-map-img.is-active');
if (navigator.share) { if (!active) {
navigator.share({ title: title, url: url }).catch(function () {});
return; return;
} }
var url = active.src; // src attribute holds the full-size file.
if (navigator.clipboard && navigator.clipboard.writeText) { if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(url).then(toast, function () { navigator.clipboard.writeText(url).then(toast, function () {
fallbackCopy(url); fallbackCopy(url);
+3 -3
View File
@@ -3,7 +3,7 @@
* Plugin Name: FP Genocide Maps * Plugin Name: FP Genocide Maps
* Plugin URI: https://freepress.coop * Plugin URI: https://freepress.coop
* Description: Manages the "Architecture of Genocide" maps shown on the home page. Each map is a post (title + description + image); the [geep_maps] shortcode renders the accordion + map image replicating the original Divi design, swapping the image when a toggle is opened. * Description: Manages the "Architecture of Genocide" maps shown on the home page. Each map is a post (title + description + image); the [geep_maps] shortcode renders the accordion + map image replicating the original Divi design, swapping the image when a toggle is opened.
* Version: 1.5.2 * Version: 1.6.0
* Author: Freepress Coop * Author: Freepress Coop
* Author URI: https://www.freepress.coop * Author URI: https://www.freepress.coop
* Requires PHP: 7.4 * Requires PHP: 7.4
@@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
} }
const FPGM_CPT = 'geep_map'; const FPGM_CPT = 'geep_map';
const FPGM_VERSION = '1.5.2'; const FPGM_VERSION = '1.6.0';
/** /**
* Register the Map custom post type (admin-only, not publicly queryable). * Register the Map custom post type (admin-only, not publicly queryable).
@@ -155,7 +155,7 @@ function fpgm_shortcode() {
// UI labels for the lightbox, in the language of the current page. // UI labels for the lightbox, in the language of the current page.
$is_ar = 'ar' === apply_filters( 'wpml_current_language', null ); $is_ar = 'ar' === apply_filters( 'wpml_current_language', null );
$labels = array( $labels = array(
'share' => $is_ar ? 'مشاركة الخريطة' : 'Share map', 'copy' => $is_ar ? 'نسخ رابط الخريطة' : 'Copy map URL',
'copied' => $is_ar ? 'تم نسخ الرابط' : 'Link copied!', 'copied' => $is_ar ? 'تم نسخ الرابط' : 'Link copied!',
'close' => $is_ar ? 'إغلاق' : 'Close', 'close' => $is_ar ? 'إغلاق' : 'Close',
'zoom' => $is_ar ? 'عرض الخريطة بحجم أكبر' : 'View map larger', 'zoom' => $is_ar ? 'عرض الخريطة بحجم أكبر' : 'View map larger',