summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury German <blueknight@gentoo.org>2019-04-28 17:39:03 -0400
committerYury German <blueknight@gentoo.org>2019-04-28 17:39:03 -0400
commit2ab16973706e120bc344c83be6295b54fd908c57 (patch)
tree358267a52d9542c77c90e3663cea32d13b8cb639 /plugins/jetpack/extensions/blocks/map/map.php
parentUpdate twentysixteen 1.7 (diff)
downloadblogs-gentoo-2ab16973706e120bc344c83be6295b54fd908c57.tar.gz
blogs-gentoo-2ab16973706e120bc344c83be6295b54fd908c57.tar.bz2
blogs-gentoo-2ab16973706e120bc344c83be6295b54fd908c57.zip
Updating packages for 5.1.1
Signed-off-by: Yury German <blueknight@gentoo.org>
Diffstat (limited to 'plugins/jetpack/extensions/blocks/map/map.php')
-rw-r--r--plugins/jetpack/extensions/blocks/map/map.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/plugins/jetpack/extensions/blocks/map/map.php b/plugins/jetpack/extensions/blocks/map/map.php
new file mode 100644
index 00000000..6e8c9d2a
--- /dev/null
+++ b/plugins/jetpack/extensions/blocks/map/map.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Map block.
+ *
+ * @since 6.8.0
+ *
+ * @package Jetpack
+ */
+
+jetpack_register_block(
+ 'jetpack/map',
+ array(
+ 'render_callback' => 'jetpack_map_block_load_assets',
+ )
+);
+
+/**
+ * Map block registration/dependency declaration.
+ *
+ * @param array $attr Array containing the map block attributes.
+ * @param string $content String containing the map block content.
+ *
+ * @return string
+ */
+function jetpack_map_block_load_assets( $attr, $content ) {
+ $dependencies = array(
+ 'lodash',
+ 'wp-element',
+ 'wp-i18n',
+ );
+
+ $api_key = Jetpack_Options::get_option( 'mapbox_api_key' );
+
+ Jetpack_Gutenberg::load_assets_as_required( 'map', $dependencies );
+
+ return preg_replace( '/<div /', '<div data-api-key="' . esc_attr( $api_key ) . '" ', $content, 1 );
+}