MAP Url method

This commit is contained in:
Mike Jolley 2015-01-20 13:31:02 +00:00
parent de4129f9b2
commit 5404006b29
2 changed files with 20 additions and 2 deletions

View File

@ -995,6 +995,24 @@ abstract class WC_Abstract_Order {
return $this->formatted_shipping_address;
}
/**
* Get a formatted shipping address for the order.
*
* @return string
*/
public function get_shipping_address_map_url() {
$address = apply_filters( 'woocommerce_shipping_address_map_url_parts', array(
'address_1' => $this->shipping_address_1,
'address_2' => $this->shipping_address_2,
'city' => $this->shipping_city,
'state' => $this->shipping_state,
'postcode' => $this->shipping_postcode,
'country' => $this->shipping_country
), $this );
return apply_filters( 'woocommerce_shipping_address_map_url', 'http://maps.google.com/maps?&q=' . urlencode( implode( ', ', $address ) ) . '&z=16', $this );
}
/**
* Get the billing address in an array.
* @deprecated 2.3

View File

@ -528,8 +528,8 @@ class WC_Admin_Post_Types {
break;
case 'shipping_address' :
if ( $the_order->get_formatted_shipping_address() ) {
echo '<a target="_blank" href="' . esc_url( 'http://maps.google.com/maps?&q=' . urlencode( $the_order->get_shipping_address() ) . '&z=16' ) . '">'. esc_html( preg_replace( '#<br\s*/?>#i', ', ', $the_order->get_formatted_shipping_address() ) ) .'</a>';
if ( $address = $the_order->get_formatted_shipping_address() ) {
echo '<a target="_blank" href="' . esc_url( $the_order->get_shipping_address_map_url() ) . '">'. esc_html( preg_replace( '#<br\s*/?>#i', ', ', $address ) ) .'</a>';
} else {
echo '&ndash;';
}