Exemplo n.º 1
0
 /**
  * Gets a user's API key, generating one if it does not exist.
  *
  * @param WP_User $user Wordpress user object.
  * @return string User API key.
  */
 public static function get_api_key_by_user($user)
 {
     $key = get_user_meta($user->ID, 'xmaps-api-key', true);
     if (!empty($key)) {
         return $key;
     }
     $key = base64_encode(UUID::v4());
     add_user_meta($user->ID, 'xmaps-api-key', $key, true);
     return $key;
 }
Exemplo n.º 2
0
			jQuery(function($) {
				XMAPS.ObjectXMap($("#xmap-' . $uuid . '"));
			});
			</script>
			';
});
add_shortcode('xmap-collections', function ($attrs) {
    $style = 'style="';
    if (isset($attrs['width'])) {
        $style .= 'width:' . $attrs['width'] . '; ';
    }
    if (isset($attrs['height'])) {
        $style .= 'height:' . $attrs['height'] . ';';
    }
    $style .= '"';
    $uuid = UUID::v4();
    return '<div id="xmap-' . $uuid . '" ' . $style . ' class="xmap-collections-map"></div>
		<script>
		jQuery(function($) {
			XMAPS.CollectionXMap($("#xmap-' . $uuid . '"));
		});
		</script>
		';
});
add_filter('query_vars', function ($vars) {
    $vars[] = 'id';
    $vars[] = 'key';
    $vars[] = 'lat';
    $vars[] = 'lon';
    $vars[] = 'acc';
    $vars[] = 'user-id';