su_shortcode_gmap

The shortcodes-ultimate su shortcode gmap function.

Published Date - February 15, 2021

Description

su_shortcode_gmap( $atts, $content );

Parameters

  1. $atts

  2. $content


Usage

The following example is for adding a hook callback.

if ( !function_exists( 'su_shortcode_gmap' ) ) {
    require_once ABSPATH . PLUGINDIR . 'shortcodes-ultimateshortcodes-ultimate/includes/shortcodes/gmap.php';
}

// The input(s). 
$atts = null;
$content = null;

// NOTICE! Understand what this does before running.
$result = su_shortcode_gmap( $atts, $content );
            

Defined

The function is defined in the following location(s).

shortcodes-ultimate/includes/shortcodes/gmap.php

function su_shortcode_gmap( $atts = null, $content = null ) {

	$atts = shortcode_atts(
		array(
			'width'      => 600,
			'height'     => 400,
			'responsive' => 'yes',
			'address'    => 'Moscow',
			'zoom'       => 0,
			'title'      => '',
			'class'      => '',
		),
		$atts,
		'gmap'
	);

	$atts['zoom'] = is_numeric( $atts['zoom'] ) && $atts['zoom'] > 0
		? '&z=' . $atts['zoom']
		: '';

	su_query_asset( 'css', 'su-shortcodes' );

	return sprintf(
		'<div class="su-gmap su-u-responsive-media-%s%s"><iframe width="%s" height="%s" src="//maps.google.com/maps?q=%s&output=embed%s" title="%s"></iframe></div>',
		esc_attr( $atts['responsive'] ),
		su_get_css_class( $atts ),
		intval( $atts['width'] ),
		intval( $atts['height'] ),
		rawurlencode( su_do_attribute( $atts['address'] ) ),
		$atts['zoom'],
		esc_attr( $atts['title'] )
	);

}