Skip to content

Commit

Permalink
Merge branch '1.9.0-dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhobo committed Sep 22, 2016
2 parents 7162b54 + 86db48d commit f3f1d8d
Show file tree
Hide file tree
Showing 24 changed files with 1,060 additions and 1,937 deletions.
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ language: php

php:
- 5.3
- 5.4
- 5.6
- 7.0

env:
- WP_VERSION=latest WP_MULTISITE=0
- WP_VERSION=latest WP_MULTISITE=1
- WP_VERSION=3.7 WP_MULTISITE=0
- WP_VERSION=3.7 WP_MULTISITE=1
- WP_VERSION=4.1 WP_MULTISITE=0
- WP_VERSION=4.1 WP_MULTISITE=1

matrix:
exclude:
- php: 7.0
env: WP_VERSION=4.1 WP_MULTISITE=0
- php: 7.0
env: WP_VERSION=4.1 WP_MULTISITE=1

before_script:
- bash tools/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
Expand Down
35 changes: 9 additions & 26 deletions geo-mashup-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,8 @@ public static function geocode( $query, &$location, $language = '' ) {

// Try GeoCoding services (google, nominatim, geonames) until one gives an answer
$results = array();
if ( 'google' == substr( $geo_mashup_options->get( 'overall', 'map_api' ), 0, 6 ) ) {
// Only try the google service if a google API is selected as the default
if ( $geo_mashup_options->get( 'overall', 'google_server_key' ) ) {
// Only try the google service if a google server key is present
$google_geocoder = new GeoMashupGoogleGeocoder( array( 'language' => $language ) );
$results = $google_geocoder->geocode( $query );
}
Expand Down Expand Up @@ -950,7 +950,7 @@ private static function reverse_geocode_location( &$location, $language = '' ) {
private static function make_alternate_reverse_geocoder() {
global $geo_mashup_options;
// Choose a geocoding service based on the default API in use
if ( 'google' == substr( $geo_mashup_options->get( 'overall', 'map_api' ), 0, 6 ) ) {
if ( $geo_mashup_options->get( 'overall', 'google_server_key' ) ) {
return new GeoMashupGoogleGeocoder();
} else if ( 'openlayers' == $geo_mashup_options->get( 'overall', 'map_api' ) ) {
return new GeoMashupNominatimGeocoder();
Expand Down Expand Up @@ -1644,29 +1644,12 @@ public static function get_object_locations( $query_args = '' ) {
$limit = '';

if ( ! $query_args['suppress_filters'] ) {
$field_string = apply_filters( 'geo_mashup_locations_fields', $field_string );
$table_string = apply_filters( 'geo_mashup_locations_join', $table_string );
$where = apply_filters( 'geo_mashup_locations_where', $where );
$sort = apply_filters( 'geo_mashup_locations_orderby', $sort );
$groupby = apply_filters( 'geo_mashup_locations_groupby', $groupby );
$limit = apply_filters( 'geo_mashup_locations_limits', $limit );

$suppress_post_filters = defined( 'GEO_MASHUP_SUPPRESS_POST_FILTERS' ) && GEO_MASHUP_SUPPRESS_POST_FILTERS;
if ( 'post' === $object_name and ! $suppress_post_filters and isset( $GLOBALS['wpml_query_filter'] ) ) {
// Ok, we're catering to WPML here. If we ever integrate with a WP_Query object for posts,
// this could be made more general

// Apply post query filters, changing posts table references to our alias
$table_string = $GLOBALS['wpml_query_filter']->filter_single_type_join( $table_string, 'any' );
$table_string = str_replace( $wpdb->posts . '.', 'o.', $table_string );
$where = $GLOBALS['wpml_query_filter']->filter_single_type_where(
$where,
$GLOBALS['geo_mashup_options']->get( 'overall', 'located_post_types' )
);
$where = str_replace( $wpdb->posts . '.', 'o.', $where );

remove_filter( 'get_translatable_documents', array( __CLASS__, 'wpml_filter_get_translatable_documents' ) );
}
$field_string = apply_filters( 'geo_mashup_locations_fields', $field_string, $query_args );
$table_string = apply_filters( 'geo_mashup_locations_join', $table_string, $query_args );
$where = apply_filters( 'geo_mashup_locations_where', $where, $query_args );
$sort = apply_filters( 'geo_mashup_locations_orderby', $sort, $query_args );
$groupby = apply_filters( 'geo_mashup_locations_groupby', $groupby, $query_args );
$limit = apply_filters( 'geo_mashup_locations_limits', $limit, $query_args );
}

$query_string = "SELECT $field_string FROM $table_string $where $groupby $having $sort $limit";
Expand Down
13 changes: 6 additions & 7 deletions geo-mashup-geocoders.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class GeoMashupHttpGeocoder {
/**
* Constructor
*
* @param string $args Optional array of arguments:
* @param array $args Optional array of arguments:
* language - two digit language code, defaults to blog language
* max_results - maximum number of results to fetch
* default http params - array of WP_Http request parameters, including timeout
Expand All @@ -54,10 +54,9 @@ public function __construct( $args = array() ) {
'request_params' => array( 'timeout' => 3.0 )
);
$args = wp_parse_args( $args, $defaults );
extract( $args );
$this->language = GeoMashupDB::primary_language_code( $language );
$this->max_results = absint( $max_results );
$this->request_params = $request_params;
$this->language = GeoMashupDB::primary_language_code( $args['language'] );
$this->max_results = absint( $args['max_results'] );
$this->request_params = $args['request_params'];
if( !class_exists( 'WP_Http' ) )
include_once( ABSPATH . WPINC. '/class-http.php' );
$this->http = new WP_Http();
Expand Down Expand Up @@ -179,7 +178,6 @@ public function geocode( $query ) {
}

public function reverse_geocode( $lat, $lng ) {
global $geo_mashup_options;

if ( !is_numeric( $lat ) or !is_numeric( $lng ) ) // Bad Request
return new WP_Error( 'bad_reverse_geocode_request', __( 'Reverse geocoding requires numeric coordinates.', 'GeoMashup' ) );
Expand Down Expand Up @@ -335,7 +333,8 @@ private function query( $query_type, $query ) {
global $geo_mashup_options;

$google_geocode_url = 'https://maps.google.com/maps/api/geocode/json?' . $query_type . '=' .
self::url_utf8_encode( $query ) . '&language=' . $this->language;
self::url_utf8_encode( $query ) . '&language=' . $this->language .
'&key=' . self::url_utf8_encode( $geo_mashup_options->get( 'overall', 'google_server_key' ) );

$response = $this->http->get( $google_geocode_url, $this->request_params );
if ( is_wp_error( $response ) ) {
Expand Down
18 changes: 9 additions & 9 deletions geo-mashup-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class GeoMashupOptions {
'version' => '',
'google_key' => '',
'googlev3_key' => '',
'google_server_key' => '',
'mashup_page' => '',
'category_link_separator' => '::',
'category_link_text' => 'map',
Expand All @@ -38,7 +39,6 @@ class GeoMashupOptions {
'user' => 'false',
'comment' => 'false' ),
'enable_reverse_geocoding' => 'true',
'adsense_code' => 'partner-pub-5088093001880917',
'geonames_username' => 'geomashup',
'map_api' => 'googlev3',
'import_custom_field' => '',
Expand All @@ -53,7 +53,6 @@ class GeoMashupOptions {
'map_control' => 'GSmallZoomControl3D',
'add_map_type_control' => array(),
'add_overview_control' => 'false',
'add_google_bar' => 'false',
'enable_scroll_wheel_zoom' => 'true',
'show_post' => 'false',
'show_future' => 'false',
Expand All @@ -76,7 +75,6 @@ class GeoMashupOptions {
'background_color' => 'c0c0c0',
'add_overview_control' => 'false',
'add_map_type_control' => array(),
'add_google_bar' => 'false',
'enable_scroll_wheel_zoom' => 'true',
'click_to_load' => 'false',
'click_to_load_text' => '' ),
Expand All @@ -89,7 +87,6 @@ class GeoMashupOptions {
'background_color' => 'c0c0c0',
'add_overview_control' => 'false',
'add_map_type_control' => array(),
'add_google_bar' => 'false',
'enable_scroll_wheel_zoom' => 'true',
'marker_select_info_window' => 'true',
'marker_select_highlight' => 'false',
Expand Down Expand Up @@ -236,6 +233,12 @@ private function convert_old_settings( $settings ) {
$settings['global_map']['term_options']['category']['line_zoom'] = $settings['global_map']['category_line_zoom'];
unset( $settings['global_map']['category_line_zoom'] );
}

// In 1.9 we removed v2 of the Google API
if ( isset( $settings['overall']['map_api'] ) and 'google' == $settings['overall']['map_api'] ) {
$settings['overall']['map_api'] = 'googlev3';
$settings['overall']['googlev3_key'] = $settings['overall']['google_key'];
}
return $settings;
}

Expand Down Expand Up @@ -400,7 +403,7 @@ public function is_valid( $key, &$value ) {
return true;

case 'map_api':
$valid_apis = array( 'google', 'openlayers', 'googlev3', 'leaflet' );
$valid_apis = array( 'openlayers', 'googlev3', 'leaflet' );
if ( !in_array ( $value, $valid_apis ) ) {
array_push ( $this->validation_errors, '"'. $value . '" ' . __('is invalid for', 'GeoMashup') . ' ' . $key .
__(', which must be a valid map provider.', 'GeoMashup') );
Expand All @@ -418,9 +421,6 @@ public function is_valid( $key, &$value ) {
return true;

// strings without HTML
case 'adsense_code':
if ( empty( $value ) )
$value = 'partner-pub-5088093001880917';
case 'geonames_username':
if ( empty( $value ) )
$value = 'geomashup';
Expand All @@ -431,6 +431,7 @@ public function is_valid( $key, &$value ) {
if ( empty ( $value ) ) return true;
case 'google_key':
case 'googlev3_key':
case 'google_server_key':
case 'version':
case 'mashup_page':
if ( !is_string ( $value ) ) {
Expand Down Expand Up @@ -467,7 +468,6 @@ public function is_valid( $key, &$value ) {
case 'auto_info_open':
case 'add_category_links':
case 'add_overview_control':
case 'add_google_bar':
case 'copy_geodata':
case 'enable_scroll_wheel_zoom':
case 'marker_select_info_window':
Expand Down
27 changes: 2 additions & 25 deletions geo-mashup-ui-managers.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class GeoMashupUIManager {
* @since 1.3
*
* @param string $name The class name of the manager.
* @return GeoMashupUIPostManager|GeoMashupUIUserManager|GeoMashupUICommentManager The singleton object.
* @return GeoMashupPostUIManager|GeoMashupUserUIManager|GeoMashupCommentUIManager The singleton object.
*/
public static function get_instance( $name ) {
static $instances = array();
Expand Down Expand Up @@ -77,30 +77,7 @@ public function enqueue_form_client_items() {
$geo_mashup_url_path = GEO_MASHUP_URL_PATH;
wp_localize_script( 'mxn-core', 'geo_mashup_location_editor_settings', compact( 'map_api', 'copy_geodata', 'ajax_url', 'geo_mashup_url_path', 'geonames_username' ) );
$required_scripts = array( 'jquery');
if ( 'google' == $map_api ) {
wp_register_script(
'google-maps-2',
'//maps.google.com/maps?file=api&v=2&sensor=false&key=' . $geo_mashup_options->get( 'overall', 'google_key' ) . '&hl=' . GeoMashup::get_language_code(),
null,
'',
true );

GeoMashup::register_script(
'mxn-google-2',
'js/mxn/mxn.google.core.js',
array( 'mxn-core', 'google-maps-2' ),
GEO_MASHUP_VERSION,
true );

GeoMashup::register_script(
'mxn-google-2-gm',
'js/mxn/mxn.google.geo-mashup.js',
array( 'mxn-google-2' ),
GEO_MASHUP_VERSION,
true );

$required_scripts[] = 'mxn-google-2-gm';
} else if ( 'googlev3' == $map_api ) {
if ( 'googlev3' == $map_api ) {
wp_register_script(
'google-maps-3',
'//maps.google.com/maps/api/js?key=' . $geo_mashup_options->get( 'overall', 'googlev3_key' ) . '&language=' . GeoMashup::get_language_code(),
Expand Down

0 comments on commit f3f1d8d

Please sign in to comment.