function process_groups_shortcode($args = array(), $content = false) { $groups_args = wp_parse_args($args, array('exclude' => false, 'show_members' => false, 'group_marker' => 'icon')); $exclude = !empty($groups_args['exclude']) ? array_filter(array_map('intval', array_map('trim', explode(',', $groups_args['exclude'])))) : array(); $rpl = new AgmMarkerReplacer(); $overrides = $rpl->arguments_to_overrides($args); $raw = groups_get_groups(array('user_id' => false, 'exclude' => $exclude)); if (empty($raw['groups'])) { return $content; } $maps = array(); foreach ($raw['groups'] as $group) { if (empty($group->id)) { continue; } $map = $this->_get_group_map($group->id, array('show_members' => $groups_args['show_members'], 'group_marker' => $groups_args['group_marker'])); if (!$map) { continue; } $maps[] = $map; } if (empty($maps)) { return $content; } return $rpl->create_overlay_tag($maps, $overrides); }
/** * Events map shortcode * @param array $args Shortcode arguments * @param boolean $content Fallback content * @return string Map string or fallback content */ function process_events_map_shortcode($args = array(), $content = false) { if (!class_exists('AgmMapModel') || !class_exists('AgmMarkerReplacer')) { return $content; } $map_args = $args; $args = $this->_preparse_arguments($args, array('relative_date' => false, 'date' => false, 'lookahead' => false, 'weeks' => false, 'category' => false, 'categories' => false, 'limit' => false, 'order' => false, 'allow_multiple_markers' => false, 'open_only' => true, 'show_date' => true, 'show_excerpt' => false, 'excerpt_length' => 55, 'legacy' => false, 'featured_image' => false, 'class' => false, 'template' => 'get_shortcode_events_map_marker_body_output')); $args['featured_image'] = $this->_arg_to_bool($args['featured_image']); $args['show_date'] = $this->_arg_to_bool($args['show_date']); $args['show_excerpt'] = $this->_arg_to_bool($args['show_excerpt']); $args['allow_multiple_markers'] = $this->_arg_to_bool($args['allow_multiple_markers']); $class = $args['class'] ? 'class="' . $args['class'] . '"' : ''; $query = $this->_to_query_args($args); $order_method = $args['order'] ? create_function('', 'return "' . $args['order'] . '";') : false; if ($order_method) { add_filter('eab-collection-date_ordering_direction', $order_method); } $maps = array(); if ($this->_arg_to_bool($args['legacy'])) { // Lookahead - depending on presence, use regular upcoming query, or poll week count if ($args['lookahead']) { $method = $args['weeks'] ? create_function('', 'return ' . $args['weeks'] . ';') : false; if ($method) { add_filter('eab-collection-upcoming_weeks-week_number', $method); } $events = Eab_CollectionFactory::get_upcoming_weeks($args['date'], $query); if ($method) { remove_filter('eab-collection-upcoming_weeks-week_number', $method); } } else { // No lookahead, get the full month only $events = Eab_CollectionFactory::get_upcoming($args['date'], $query); } if ($order_method) { remove_filter('eab-collection-date_ordering_direction', $order_method); } $model = new AgmMapModel(); $raw_maps = $model->get_custom_maps($events->query); if (empty($raw_maps)) { return $content; } foreach ($raw_maps as $key => $map) { if (empty($map['markers']) || count($map['markers']) > 1) { continue; } $event = !empty($map['post_ids']) && !empty($map['post_ids'][0]) ? new Eab_EventModel(get_post($map['post_ids'][0])) : false; if (!$event) { continue; } $map['markers'][0]['title'] = $event->get_title(); $map['markers'][0]['body'] = Eab_Template::util_apply_shortcode_template($event, $args); if ($args['featured_image']) { $icon = $event->get_featured_image_url(); if ($icon) { $map['markers'][0]['icon'] = $icon; } } $maps[] = $map; } } else { if ($args['lookahead']) { $method = $args['weeks'] ? create_function('', 'return ' . $args['weeks'] . ';') : false; if ($method) { add_filter('eab-collection-upcoming_weeks-week_number', $method); } $events = Eab_CollectionFactory::get_upcoming_weeks_events($args['date'], $query); if ($method) { remove_filter('eab-collection-upcoming_weeks-week_number', $method); } } else { // No lookahead, get the full month only $events = Eab_CollectionFactory::get_upcoming_events($args['date'], $query); } if ($order_method) { remove_filter('eab-collection-date_ordering_direction', $order_method); } $open_only = $this->_arg_to_bool($args['open_only']); foreach ($events as $event) { if ($open_only && !$event->is_open()) { continue; } $map = $event->get_raw_map(); if (!is_array($map) || empty($map)) { continue; } if (empty($map['markers'])) { continue; } if (empty($args['allow_multiple_markers']) && count($map['markers']) > 1) { continue; } // Even with multiple markers, only deal with the first one $marker_body = Eab_Template::util_apply_shortcode_template($event, $args); $map['markers'][0]['title'] = $event->get_title(); $icon = $args['featured_image'] ? $event->get_featured_image_url() : false; foreach ($map['markers'] as $idx => $mrk) { $map['markers'][$idx]['body'] = $marker_body; if ($args['featured_image'] && !empty($icon)) { $map['markers'][$idx]['icon'] = $icon; } } $maps[] = $map; } } if (!$maps) { return $content; } if (!is_array($map_args)) { $map_args = array(); } $codec = new AgmMarkerReplacer(); return "<div {$class}>" . $codec->create_overlay_tag($maps, $map_args) . '</div>'; }
public function add_joint_my_appointments_map($out, $my_appointments) { if (empty($my_appointments)) { return $out; } if (!class_exists('AgmMarkerReplacer')) { return $out; } $maps = array(); foreach ($my_appointments as $app) { if (empty($app->location)) { continue; } $location = $this->_locations->find_by('id', $app->location); $map = $location->to_map(); if (!$map) { continue; } $maps[] = $map; } if (empty($maps)) { return $out; } $codec = new AgmMarkerReplacer(); $overrides = !empty($this->_data['google_maps']['overrides']) ? $this->_data['google_maps']['overrides'] : array(); $overrides['show_images'] = !empty($overrides['show_images']) ? $overrides['show_images'] : 0; $out .= $codec->create_overlay_tag($maps, $overrides); return $out; }