diff --git a/includes/class-ajax-geo.php b/includes/class-ajax-geo.php index 7f5ab41..9d11c75 100644 --- a/includes/class-ajax-geo.php +++ b/includes/class-ajax-geo.php @@ -19,7 +19,7 @@ public static function get_address_data() { if ( empty( $_POST['longitude'] ) || empty( $_POST['latitude'] ) ) { wp_send_json_error( new WP_Error( 'nogeo', __( 'You must specify coordinates', 'simple-location' ) ) ); } - $reverse = new Geo_Provider_OSM(); + $reverse = loc_config::default_reverse_provider(); $reverse->set( $_POST['latitude'], $_POST['longitude'] ); $reverse_adr = $reverse->reverse_lookup(); if ( is_wp_error( $reverse_adr ) ) { diff --git a/includes/class-venue-taxonomy.php b/includes/class-venue-taxonomy.php index 23e07ea..65c1303 100644 --- a/includes/class-venue-taxonomy.php +++ b/includes/class-venue-taxonomy.php @@ -18,33 +18,29 @@ public static function init() { // Remove Meta Box add_action( 'admin_menu', array( 'Venue_Taxonomy', 'remove_meta_box' ) ); - add_action( 'admin_enqueue_scripts', array( 'Venue_Taxonomy', 'enqueue_admin_scripts' ) ); + add_action( 'admin_print_scripts-term.php', array( 'Venue_Taxonomy', 'enqueue_term_scripts' ) ); + add_action( 'admin_print_scripts-edit-tags.php', array( 'Venue_Taxonomy', 'enqueue_term_scripts' ) ); - // add_action( 'created_term', array( 'Venue_Taxonomy', 'save_venue_meta' ), 10, 2 ); - // add_action( 'edited_term', array( 'Venue_Taxonomy', 'save_venue_meta' ), 10, 2 ); - register_meta( 'term', 'latitude', array( 'Venue_Taxonomy', 'clean_coordinate' ) ); - register_meta( 'term', 'longitude', array( 'Venue_Taxonomy', 'clean_coordinate' ) ); + if ( is_admin() ) { + add_action( 'venue_add_form_fields', array( 'Venue_Taxonomy', 'create_screen_fields' ), 10, 1 ); + add_action( 'venue_edit_form_fields', array( 'Venue_Taxonomy', 'edit_screen_fields' ), 10, 2 ); + add_action( 'created_venue', array( 'Venue_Taxonomy', 'save_data' ), 10, 1 ); + add_action( 'edited_venue', array( 'Venue_Taxonomy', 'save_data' ), 10, 1 ); + } } - public static function enqueue_admin_scripts() { - if ( 'venue' === get_current_screen()->taxonomy ) { + public static function enqueue_term_scripts() { + if ( 'venue' === $_GET['taxonomy'] ) { wp_enqueue_script( - 'venue-get', - plugins_url( 'simple-location/includes/retrieve.js' ), + 'location', + plugins_url( 'simple-location/js/location.js' ), array( 'jquery' ), SIMPLE_LOCATION_VERSION ); } } - public static function clean_coordinate($coordinate) { - $pattern = '/^(\-)?(\d{1,3})\.(\d{1,15})/'; - preg_match( $pattern, $coordinate, $matches ); - return $matches[0]; - } - - /** * Register the custom taxonomy for venues. */ @@ -89,39 +85,55 @@ public static function remove_meta_box() { remove_meta_box( 'tagsdiv-venue', 'post', 'normal' ); } - public static function get_venue_meta($term_id, $key) { - $value = get_term_meta( $term_id, $key, true ); - if ( ! $value ) { - return false; - } - return sanitize_text_field( $value ); - } + public static function create_screen_fields( $taxonomy ) { +?> +
+ + + + - public static function set_meta($term_id = 0, $key = '') { - // No meta_key, so delete - if ( empty( $_POST[$key] ) ) { - delete_term_meta( $term_id, $key ); - // Update meta_key value - } else { - update_term_meta( $term_id, $key, $_POST[$key] ); - } + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +