: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Registering a basic block with Gutenberg.
* Simple block, renders and saves the same content without any interactivity.
* editor.css — Editor styles for the block.
* style.css — Editor & Front end styles for the block.
var __ = wp.i18n.__; // The __() for internationalization.
var el = wp.element.createElement; // The wp.element.createElement() function to create elements.
var registerBlockType = wp.blocks.registerBlockType; // The registerBlockType() to register blocks.
block_wrap: { type: "string", default: "" },
id: { type: "string", default: "" },
label: { type: "string", default: "" },
image: { type: "string", default: "" },
paddingTop: { type: "string", default: "56%" },
maxWidth: { type: "string", default: "" },
default: "Select a map in the block options"
className: { type: "string", default: "" }
var preview = function (props) {
var content = props.attributes.content;
var match, hasImage, backgroundContainer;
// empty map, not selected
if (props.attributes.id == "" && !props.isSelected) {
content = "No map selected";
if (props.attributes.label !== "") {
content = props.attributes.label;
// if selected, but something changed
if (props.attributes.id !== "") {
match = igmMapBlockOptions.find(function (o) {
return o.value == props.attributes.id;
if (typeof match === "undefined") {
if (props.attributes.imagePreview !== match.image) {
paddingTop: match.paddingTop + "%",
maxWidth: match.maxWidth !== "" ? match.maxWidth + "px" : "",
imagePreview: match.image !== "" ? match.image : ""
props.attributes.paddingTop =
props.attributes.paddingTop !== "" ? props.attributes.paddingTop : "56%";
if (props.attributes.imagePreview !== "") {
content = "Preview Only";
hasImage = " igm-block-preview-has-image";
backgroundContainer = el("div", {
class: "igm-map-background" + hasImage,
props.attributes.imagePreview !== ""
? "url(" + props.attributes.imagePreview + ")"
class: "dashicons dashicons-admin-site-alt"
props.attributes.className +
" igm-block-preview map_wrapper" +
maxWidth: props.attributes.maxWidth
class: "map_aspect_ratio",
paddingTop: props.attributes.paddingTop
* Registers a new block provided a unique name and an object defining its
* behavior. Once registered, the block is made available as an option to any
* editor interface where blocks are implemented.
* @param {string} name Block name.
* @param {Object} settings Block settings.
* @return {?WPBlock} The block, if it has been successfully
* registered; otherwise `undefined`.
registerBlockType("interactive-geo-maps/display-map", {
// Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
title: "Map", // Block title.
description: "Display a previously created Interactive Map", // Block title.
icon: "admin-site-alt", // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
category: "widgets", // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
keywords: ["map", "interactive-map"],
// The "edit" property must be a valid function.
el(wp.editor.BlockControls, { key: "controls" }),
wp.editor.InspectorControls,
el(wp.components.SelectControl, {
label: "Map to display:",
value: props.attributes.id,
options: igmMapBlockOptions,
onChange: function (id) {
var match = igmMapBlockOptions.find(function (o) {
paddingTop: match.paddingTop + "%",
maxWidth: match.maxWidth !== "" ? match.maxWidth + "px" : "",
imagePreview: match.image !== "" ? match.image : ""
// The "save" property must be specified and must be a valid function.
var attr = props.attributes;
var content = "[display-map";
if (attr.hasOwnProperty("id")) {
content += " id='" + attr.id + "' ";
className: attr.className
var attr = props.attributes;
var content = "[display-map";
if (attr.hasOwnProperty("id")) {
content += " id='" + attr.id + "' ";
className: attr.className