Use last added venue location when adding a new venue
This commit is contained in:
@@ -45,13 +45,33 @@ function sportspress_venue_edit_form_fields( $term ) {
|
|||||||
add_action( 'sp_venue_edit_form_fields', 'sportspress_venue_edit_form_fields', 10, 2 );
|
add_action( 'sp_venue_edit_form_fields', 'sportspress_venue_edit_form_fields', 10, 2 );
|
||||||
|
|
||||||
function sportspress_venue_add_form_fields() {
|
function sportspress_venue_add_form_fields() {
|
||||||
|
|
||||||
|
$args = array(
|
||||||
|
'orderby' => 'id',
|
||||||
|
'order' => 'DESC',
|
||||||
|
'hide_empty' => false,
|
||||||
|
'number' => 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Get latitude and longitude from the last added venue
|
||||||
|
$terms = get_terms( 'sp_venue', $args );
|
||||||
|
if ( $terms && array_key_exists( 0, $terms) && is_object( $terms[0] ) ):
|
||||||
|
$t_id = $terms[0]->term_id;
|
||||||
|
$term_meta = get_option( "taxonomy_$t_id" );
|
||||||
|
$latitude = sportspress_array_value( $term_meta, 'sp_latitude', '40.7324319' );
|
||||||
|
$longitude = sportspress_array_value( $term_meta, 'sp_longitude', '-73.82480799999996' );
|
||||||
|
else:
|
||||||
|
$latitude = '40.7324319';
|
||||||
|
$longitude = '-73.82480799999996';
|
||||||
|
endif;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<label for="term_meta[sp_address]"><?php _e( 'Address', 'sportspress' ); ?></label>
|
<label for="term_meta[sp_address]"><?php _e( 'Address', 'sportspress' ); ?></label>
|
||||||
<input type="text" class="sp-address" name="term_meta[sp_address]" id="term_meta[sp_address]" value="">
|
<input type="text" class="sp-address" name="term_meta[sp_address]" id="term_meta[sp_address]" value="">
|
||||||
<input type="hidden" class="sp-latitude" name="term_meta[sp_latitude]" id="term_meta[sp_latitude]" value="40.7324319">
|
<input type="hidden" class="sp-latitude" name="term_meta[sp_latitude]" id="term_meta[sp_latitude]" value="<?php echo $latitude; ?>">
|
||||||
<input type="hidden" class="sp-longitude" name="term_meta[sp_longitude]" id="term_meta[sp_longitude]" value="-73.82480799999996">
|
<input type="hidden" class="sp-longitude" name="term_meta[sp_longitude]" id="term_meta[sp_longitude]" value="<?php echo $longitude; ?>">
|
||||||
<p><div class="sp-location-picker"></div></p>
|
<p><div class="sp-location-picker"></div></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user