Skip to content
Permalink
Browse files

Added Google Maps Block

  • Loading branch information...
David Aguilera
David Aguilera committed Feb 27, 2019
1 parent 2d59350 commit 999c579f838e95ee87966fc9e4a7287536438188
Showing with 1,409 additions and 230 deletions.
  1. +1 −0 .eslintrc
  2. +19 −16 nelio-maps.php
  3. +189 −0 package-lock.json
  4. +2 −0 package.json
  5. +0 −11 packages/blocks/demo/attributes.js
  6. +0 −40 packages/blocks/demo/edit.js
  7. +0 −1 packages/blocks/demo/icon.svg
  8. +0 −44 packages/blocks/demo/index.js
  9. +0 −19 packages/blocks/demo/save.js
  10. +0 −81 packages/blocks/demo/styles/editor.scss
  11. +0 −13 packages/blocks/demo/styles/style.scss
  12. +91 −0 packages/blocks/google-map/address-search.js
  13. +99 −0 packages/blocks/google-map/attributes.js
  14. +149 −0 packages/blocks/google-map/edit.js
  15. +14 −0 packages/blocks/google-map/icon.svg
  16. +43 −0 packages/blocks/google-map/index.js
  17. 0 packages/blocks/{demo → google-map}/index.php
  18. +165 −0 packages/blocks/google-map/inspector.js
  19. +63 −0 packages/blocks/google-map/map-block.js
  20. +12 −0 packages/blocks/google-map/map-styles/custom.js
  21. BIN packages/blocks/google-map/map-styles/custom.png
  22. +14 −0 packages/blocks/google-map/map-styles/dark.js
  23. BIN packages/blocks/google-map/map-styles/dark.png
  24. +14 −0 packages/blocks/google-map/map-styles/dawn.js
  25. BIN packages/blocks/google-map/map-styles/dawn.png
  26. +12 −0 packages/blocks/google-map/map-styles/default.js
  27. BIN packages/blocks/google-map/map-styles/default.png
  28. +14 −0 packages/blocks/google-map/map-styles/light.js
  29. BIN packages/blocks/google-map/map-styles/light.png
  30. +67 −0 packages/blocks/google-map/map-styles/map-styles.js
  31. +14 −0 packages/blocks/google-map/map-styles/night.js
  32. BIN packages/blocks/google-map/map-styles/night.png
  33. +73 −0 packages/blocks/google-map/save.js
  34. +69 −0 packages/blocks/google-map/styles/editor.scss
  35. +23 −0 packages/blocks/google-map/styles/style.scss
  36. +142 −0 packages/blocks/google-map/toolbar.js
  37. +2 −5 packages/blocks/index.js
  38. +54 −0 packages/components/image-picker/image-picker.js
  39. +62 −0 packages/components/image-picker/styles/editor.scss
  40. +2 −0 packages/components/index.php
@@ -18,6 +18,7 @@
}
},
"globals": {
"NelioMaps": true,
"wp": true,
"wpApiSettings": true,
"window": true,
@@ -66,32 +66,29 @@ public function init_hooks() {
add_action( 'admin_init', [ $this, 'admin_init' ] );
// Works only if Gutenberg is available.
if ( function_exists( 'register_block_type' ) ) {
// Add Demo category.
add_filter( 'block_categories', [ $this, 'block_categories' ], 9 );
// Enqueue scripts and styles.
add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_block_editor_assets' ], 9 );
if ( ! function_exists( 'register_block_type' ) ) {
return;
}//end if
add_action( 'init', [ $this, 'register_google_maps_api_key_option' ] );
add_filter( 'block_categories', [ $this, 'add_extra_category' ], 9 );
add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_block_editor_assets' ], 9 );
}//end init_hooks()
public function block_categories( $categories ) {
public function add_extra_category( $categories ) {
return array_merge(
$categories,
array(
array(
'slug' => 'demo',
'title' => __( 'Demo', 'nelio-maps' ),
'slug' => 'extra',
'title' => _x( 'Extra', 'text (block category)', 'nelio-maps' ),
),
)
);
}//end block_categories()
}//end add_extra_category()
public function enqueue_block_editor_assets() {
@@ -114,6 +111,9 @@ public function enqueue_block_editor_assets() {
$this->plugin_version
);
$api_key = get_option( 'nelio_maps_api_key_option', '' );
wp_localize_script( 'nelio-maps-blocks', 'NelioMaps', [ 'googleMapsApiKey' => $api_key ] );
if ( function_exists( 'wp_set_script_translations' ) ) {
wp_set_script_translations( 'nelio-maps-plugin', 'nelio-maps' );
}//end if
@@ -131,11 +131,14 @@ public function admin_init() {
}//end admin_init()
public function admin_menu() {
public function register_google_maps_api_key_option() {
$api_key = get_option( 'nelio_maps_api_key_option', '' );
update_option( 'nelio_maps_api_key_option', $api_key );
}//end admin_menu()
}//end register_google_maps_api_key_option()
}
}//end class
function nelio_maps() {
return NELIO_MAPS::instance();
Oops, something went wrong.

0 comments on commit 999c579

Please sign in to comment.
You can’t perform that action at this time.