block_slug` property * * @return mixed */ protected function set_block_slug() { $this->block_slug = 'leaflet-map'; } /** * Set the attributes required on the server side. * * @return mixed */ protected function set_attributes() { $this->attributes = array( 'id' => array( 'type' => 'string', ), 'location' => array( 'type' => 'string', 'default' => 'La Sagrada Familia, Barcelona, Spain', ), 'latitude' => array( 'type' => 'string', 'default' => '41.4036299', ), 'longitude' => array( 'type' => 'string', 'default' => '2.1743558000000576', ), 'zoom' => array( 'type' => 'number', 'default' => 15, ), 'height' => array( 'type' => 'number', 'default' => 400, ), 'markers' => array( 'type' => 'object', 'default' => [], ), 'draggable' => array( 'type' => 'boolean', 'default' => true, ), 'zoomControl' => array( 'type' => 'boolean', 'default' => true, ), 'bbox' => array( 'type' => 'string', 'default' => '2.1207046508789067%2C41.34807736149302%2C2.2288513183593754%2C41.45816618938139', ), ); } /** * Block render function for server-side. * * This method will pe passed to the render_callback parameter and it will output * the server side output of the block. * * @param array $attributes Blocks attrs. * * @return mixed|string */ protected function render( $attributes ) { if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) { $link = 'https://www.openstreetmap.org/export/embed.html?bbox=' . stripslashes( esc_attr( $attributes['bbox'] ) ) . '&layer=mapnik'; $output = ''; $output .= ' '; $output .= ''; return $output; } // Set the ID and the class name. $id = isset( $attributes['id'] ) ? $attributes['id'] : 'wp-block-themeisle-blocks-map-' . wp_rand( 10, 100 ); $class = 'wp-block-themeisle-blocks-map'; if ( isset( $attributes['className'] ) ) { $class .= ' ' . esc_attr( $attributes['className'] ); } if ( isset( $attributes['align'] ) ) { $class .= ' align' . esc_attr( $attributes['align'] ); } // Load the attributes in the page and make a placeholder to render the map. $output = '
' . "\n"; $output .= '' . "\n"; return $output; } }