/** @see WP_Widget::widget */ function widget($args, $instance) { $title = apply_filters('widget_title', $instance['title']); $location_id = !empty($instance['location_id']) ? $instance['location_id'] : ''; $show_country = !empty($instance['show_country']) && $instance['show_country'] == '1'; $show_state = !empty($instance['show_state']) && $instance['show_state'] == '1'; $show_phone = !empty($instance['show_phone']) && $instance['show_phone'] == '1'; $show_phone_2 = !empty($instance['show_phone_2']) && $instance['show_phone_2'] == '1'; $show_fax = !empty($instance['show_fax']) && $instance['show_fax'] == '1'; $show_email = !empty($instance['show_email']) && $instance['show_email'] == '1'; $show_vat = !empty($instance['show_vat']) && $instance['show_vat'] == '1'; $show_tax = !empty($instance['show_tax']) && $instance['show_tax'] == '1'; $show_coc = !empty($instance['show_coc']) && $instance['show_coc'] == '1'; $show_opening_hours = !empty($instance['show_opening_hours']) && $instance['show_opening_hours'] == '1'; $hide_closed = !empty($instance['hide_closed']) && $instance['hide_closed'] == '1'; $show_oneline = !empty($instance['show_oneline']) && $instance['show_oneline'] == '1'; $comment = !empty($instance['comment']) ? esc_attr($instance['comment']) : ''; if ($location_id == '' && wpseo_has_multiple_locations() || $location_id == 'current' && !is_singular('wpseo_locations')) { return ''; } if (isset($args['before_widget'])) { echo $args['before_widget']; } if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } $shortcode_args = array('id' => $location_id, 'show_country' => $show_country, 'show_state' => $show_state, 'show_phone' => $show_phone, 'show_phone_2' => $show_phone_2, 'show_fax' => $show_fax, 'show_email' => $show_email, 'show_vat' => $show_vat, 'show_tax' => $show_tax, 'show_coc' => $show_coc, 'show_opening_hours' => $show_opening_hours, 'hide_closed' => $hide_closed, 'oneline' => $show_oneline, 'comment' => $comment, 'from_widget' => true, 'widget_title' => $title, 'before_title' => $args['before_title'], 'after_title' => $args['after_title']); echo wpseo_local_show_address($shortcode_args); if (isset($args['after_widget'])) { echo $args['after_widget']; } return true; }
function enhance_location_search_results($excerpt) { if (is_search()) { global $post; if ('wpseo_locations' === get_post_type($post->ID)) { $excerpt .= '<div class="wpseo-local-search-details">'; $excerpt .= wpseo_local_show_address(array('id' => $post->ID, 'hide_name' => true)); $excerpt .= '</div>'; } } return $excerpt; }
/** * Shortcode for shoing all locations at once. May come handy for "office overview" pages * * @since 1.1.7 * * @param array $atts Array of shortcode parameters * * @return string */ function wpseo_local_show_all_locations($atts) { $atts = wpseo_check_falses(shortcode_atts(array('number' => -1, 'term_id' => '', 'orderby' => 'menu_order title', 'order' => 'ASC', 'show_state' => true, 'show_country' => true, 'show_phone' => true, 'show_phone_2' => true, 'show_fax' => true, 'show_email' => true, 'show_url' => false, 'show_opening_hours' => false, 'hide_closed' => false, 'oneline' => false, 'echo' => false), $atts)); // Don' show any data when post_type is not activated. This function/shortcode makes no sense for single location if (!wpseo_has_multiple_locations()) { return ''; } $output = ''; $tax_query = array(); if ('' != $atts['term_id']) { $tax_query[] = array('taxonomy' => 'wpseo_locations_category', 'field' => 'term_id', 'terms' => $atts['term_id']); } $locations = new WP_Query(array('post_type' => 'wpseo_locations', 'posts_per_page' => $atts['number'], 'orderby' => $atts['orderby'], 'order' => $atts['order'], 'fields' => 'ids', 'tax_query' => $tax_query)); if ($locations->post_count > 0) { $output .= '<div class="wpseo-all-locations">'; foreach ($locations->posts as $location_id) { $location = apply_filters('wpseo_all_locations_location', wpseo_local_show_address(array('id' => $location_id, 'show_state' => $atts['show_state'], 'show_country' => $atts['show_country'], 'show_phone' => $atts['show_phone'], 'show_phone_2' => $atts['show_phone_2'], 'show_fax' => $atts['show_fax'], 'show_email' => $atts['show_email'], 'show_url' => $atts['show_url'], 'show_opening_hours' => $atts['show_opening_hours'], 'hide_closed' => $atts['hide_closed'], 'oneline' => $atts['oneline'], 'echo' => false))); $output .= $location; } $output .= '</div>'; } else { echo '<p>' . __('There are no locations to show.', 'yoast-local-seo') . '</p>'; } if ($atts['echo']) { echo $output; } return $output; }
public function get_location_details($location_id, $atts) { $coords_lat = get_post_meta($location_id, '_wpseo_coordinates_lat', true); $coords_long = get_post_meta($location_id, '_wpseo_coordinates_long', true); ?> <div class="wpseo-result"> <?php $location = wpseo_local_show_address(array('id' => $location_id, 'show_state' => $atts['show_state'], 'show_country' => $atts['show_country'], 'show_phone' => $atts['show_phone'], 'show_phone_2' => $atts['show_phone_2'], 'show_fax' => $atts['show_fax'], 'show_email' => $atts['show_email'], 'show_url' => $atts['show_url'], 'show_opening_hours' => $atts['show_opening_hours'], 'hide_closed' => $atts['hide_closed'], 'oneline' => $atts['oneline'], 'from_sl' => true, 'echo' => false)); echo apply_filters('wpseo_local_sl_result', $location, $location_id); ?> <div class="wpseo-sl-route"> <a href="javascript:;" onclick="wpseo_sl_show_route( this, '<?php echo $coords_lat; ?> ', '<?php echo $coords_long; ?> ' );"><?php echo $atts['show_route_label']; ?> </a> </div> </div> <?php }