Пример #1
0
function showyamap($atts, $content = null)
{
    $options = get_option(OIYM_PREFIX . 'options');
    foreach ($options as $k => $v) {
        if (${$k} == '') {
            ${$k} = $v;
        }
    }
    extract(shortcode_atts(array('address' => '', 'center' => '', 'header' => '', 'body' => '', 'footer' => '', 'hint' => '', 'coordinates' => '', 'height' => $height, 'width' => $width, 'zoom' => $zoom, 'iconcontent' => '', 'placemark' => $placemark, 'iconimage' => $iconimage, 'iconsize' => '', 'iconoffset' => '', 'iconrect' => '', 'zoomcontrol' => 1, 'typeselector' => 1, 'maptools' => 1, 'trafficcontrol' => 1, 'routeeditor' => 1), $atts, 'showyamap'));
    $output = '';
    $placemarks = array();
    if ($zoomcontrol == 1 || $typeselector == 1 || $maptools == 1 || $trafficcontrol == 1 || $routeeditor == 1) {
        if ($zoomcontrol == 1) {
            $zoomcontrol = '.add("zoomControl")';
        } else {
            $zoomcontrol = '';
        }
        if ($typeselector == 1) {
            $typeselector = '.add("typeSelector")';
        } else {
            $typeselector = '';
        }
        if ($maptools == 1) {
            $maptools = '.add("mapTools")';
        } else {
            $maptools = '';
        }
        if ($trafficcontrol == 1) {
            $trafficcontrol = '.add("trafficControl")';
        } else {
            $trafficcontrol = '';
        }
        if ($routeeditor == 1) {
            $routeeditor = '.add("routeEditor")';
        } else {
            $routeeditor = '';
        }
        $controls = '
					myMap.controls' . $zoomcontrol . $typeselector . $maptools . $trafficcontrol . $routeeditor . ';

		';
    } else {
        $controls = '';
    }
    foreach (oi_yamaps_defaults() as $k => $v) {
        if (${$k} == '' && $k != 'author_link') {
            ${$k} = $v;
        }
    }
    $id = Ya_map_connected::$id;
    // set id of map block
    if ($coordinates == '') {
        if ($address != '') {
            $coordinates = coordinates($address);
            // take coordinates
        } else {
            $latitude = get_post_meta(get_the_ID(), 'latitude', true);
            // get latitude from post meta
            $longitude = get_post_meta(get_the_ID(), 'longitude', true);
            // get longitude from post meta
            if ($latitude && $longitude) {
                $coordinates = $latitude . ',' . $longitude;
                // split theme
            } else {
                $coordinates = '';
            }
        }
    }
    if ($coordinates != '') {
        $placemarks[] = array('pid' => $id, 'header' => $header, 'body' => $body, 'footer' => $footer, 'hint' => $hint, 'coordinates' => $coordinates, 'iconcontent' => $iconcontent, 'placemark' => $placemark, 'iconimage' => $iconimage, 'iconsize' => '', 'iconoffset' => '', 'iconrect' => '');
    }
    // delete all not necessary simbols from $content
    $record = false;
    // shortcode not started flag
    $out7 = '';
    // shortcode container
    for ($i = 0; $i < strlen($content); $i++) {
        if ($content[$i] == '[') {
            $record = true;
        }
        // shortcode started
        if ($record == true) {
            $out7 .= $content[$i];
        }
        // make shortcode string
        if ($content[$i] == ']') {
            $record = false;
            // set flag
            $placemarks[] = json_decode(do_shortcode($out7), true);
            // add array of vars to $placemarks array
            $out7 = '';
        }
    }
    $center = trim($center);
    if ($center != '') {
        if (!is_int($center[0])) {
            $center = coordinates($center);
            // get coordinates
        }
    }
    if (!empty($placemarks)) {
        // make placemarks string, for adding to code
        $placemark_code = '';
        $lat = array();
        $lon = array();
        foreach ($placemarks as $k => $v) {
            if ($v['placemark'] == '') {
                $v['placemark'] = $placemark;
            }
            if ($center == '') {
                list($lat[], $lon[]) = explode(',', $v['coordinates']);
            }
            $placemark_code .= placemark_code($v);
        }
        if ($center == '') {
            $center = io_ya_map_center($lat, $lon);
            // center betwin all placemarks
        }
        if ($author_link == 1) {
            $author_link = '<a class="author_link" href="http://easywebsite.ru/">' . __('OYM', 'oi_ya_maps') . '</a>';
        }
        $output .= '
		<div id="YMaps_' . $id . '" class="YMaps" style="width:' . $width . ';height:' . $height . '">' . $author_link . '</div>
		<script type="text/javascript">
			ymaps.ready(init);

			function init () {
				var myMap = new ymaps.Map("YMaps_' . $id . '", {
						center: [' . $center . '],
						zoom: ' . $zoom . '
					});
					' . $controls . '
					' . $placemark_code . '
			}
		</script>
		';
        Ya_map_connected::$id++;
        // set new id
        if ($id == 0) {
            return '<script type="text/javascript" src="http://api-maps.yandex.ru/2.0/?load=package.full&lang=ru-RU"></script>' . '<style>.YMaps {position: relative;} .YMaps .author_link {position: absolute;bottom: 9px; right:330px; z-index: 999;padding:0;display: table!important;line-height:12px;text-decoration:underline!important;white-space: nowrap!important;font-family: Verdana,serif!important;font-size: 10px!important;padding-left: 2px!important;color: #000!important;background-color: rgba(255, 255, 255, 0.7)!important;border:none;}</style>' . "\n" . $output;
            // ...and show the map
        } else {
            return $output;
        }
        // show the map
    }
}
Пример #2
0
    /**
     * Options page callback
     */
    public function settings_page()
    {
        // Set class property
        $this->options = get_option(OIYM_PREFIX . 'options', oi_yamaps_defaults());
        ?>
<style>
.block-left {float: left;width: 50%;}
</style>
        <div class="wrap">
            <?php 
        screen_icon();
        ?>
            <h2><?php 
        _e('Oi Yandex Maps Settings', 'oiyamaps');
        ?>
</h2>
			<div class="block-left">
            <form method="post" action="options.php">
            <?php 
        // This prints out all hidden setting fields
        settings_fields(OIYM_PREFIX . 'option_group');
        submit_button();
        do_settings_sections('oiym-setting-admin');
        submit_button();
        ?>
            </form>
			</div>
			<div class="block-left">
			<h4><?php 
        _e('Oi Yandex.Maps for WordPress Needs Your Support', 'oiyamaps');
        ?>
</h4>
<p><?php 
        _e('If you like this plugin, you can support me and make a donation. But even if you don`t, you can use the plugin without any restrictions.', 'oiyamaps');
        ?>
</p>
<p><?php 
        _e('Your donation will help encourage and support the plugin`s continued development and better user support.', 'oiyamaps');
        ?>
</p>
<iframe frameborder="0" allowtransparency="true" scrolling="no" src="https://money.yandex.ru/embed/shop.xml?account=41001112308777&quickpay=shop&payment-type-choice=on&writer=seller&targets=Oi+Ya.Maps+for+WordPress+donation&targets-hint=&default-sum=350&button-text=03&mail=on&successURL=successURL=http%3A%2F%2Fwww.easywebsite.ru%2Fshop%2Fplugins-wordpress%2Foi-ya-maps%3Fmsg%3Dthanks" width="450" height="198"></iframe>

			</div>
        </div>
        <?php 
    }