Home › Forums › Calendar Products › Events Calendar PRO › City Default Content Not Working
- This topic has 13 replies, 3 voices, and was last updated 9 years, 7 months ago by
Ben.
-
AuthorPosts
-
July 23, 2016 at 6:14 pm #1143463
Ben
ParticipantIn the latest version of Events Calendar Pro, the city default content is not working. The files attached show the bug.
July 25, 2016 at 3:51 pm #1143867Nico
MemberHi there Gene,
Thanks for reaching out to us and thanks for the report!
I could confirm this is a legit bug as I was able to reproduce it in my local install as well. I went ahead and logged this bug in the system, I also attached this thread to the ticket so you’ll get a heads up when a fix for this is available.
Thanks once again for the report,
Best,
NicoAugust 21, 2016 at 4:50 pm #1154186Ben
ParticipantAny forecast on when this will be fixed?
August 22, 2016 at 12:26 pm #1154480Nico
MemberHey Gene,
Thanks for reaching out once again! There’s still no date set for the fix of this issue, moreso due to some related tickets the ‘Default Content’ feature is being revisited and might end up redefined a bit. I’ll probably have more news on this later this week, I’ll let you know when I have some more info on this.
Best,
NicoSeptember 22, 2016 at 12:39 pm #1167626Ben
ParticipantAny news on fix for City and State default not working?
September 23, 2016 at 1:36 pm #1168129Nico
MemberHey Gene,
Thanks for keeping this in mind and sorry for not having news about this yet π
I took some time and coded a temporary solution for you. Just paste the code below to your theme’s (or child theme’s) functions.php file and it will add the city default value to the ‘add event’ screen:
/* Tribe, add default city to the new events venue city value */
function admin_footer_js( ) {if( !isset($_GET['post_type']) || 'tribe_events' != $_GET['post_type'] ) return false;
$screen = get_current_screen();
if ( 'add' != $screen->action ) return false;
$default_city = tribe_get_option( 'eventsDefaultCity', '' );
if ( $default_city == '' ) return false;
?>
<script type="text/javascript">
jQuery('document').ready ( function ( $ ) {
$('input[name="venue[City][]"').val('<?php echo $default_city; ?>');
});
</script>
<?php
}add_action( 'admin_print_footer_scripts', 'admin_footer_js' );
Please give a try and let me know if this solves the issue for now and if the code can be enhanced to account for other scenarios,
Have a great weekend,
NicoSeptember 24, 2016 at 11:35 am #1168375Ben
ParticipantThanks for your help Nico. I’m getting this error:
Parse error: syntax error, unexpected ‘&’ in /home/jsowebmaster/jazzoregon.com/wp-content/plugins/JSO-updates/JSO-updates.php on line 47.
Here is line 47: if ( ‘add’ != $screen->action ) return false;
Must be a typo somewhere.
Could I also fix state and country by duplicating the code and making these changes…
eventsDefaultCity –> eventsDefaultState, eventsDefaultCountry?
venue[City][] –> venue[State][], venue[Country][]
$default_city –> $default_State, $default_CountryGene
September 24, 2016 at 11:37 am #1168377Ben
ParticipantP.S. Line 47 actually looks like this:
if ( ‘add’ != $screen->action ) return false;
Somehow the > got converted to > when I entered the code in the Forum.
September 26, 2016 at 9:31 am #1168775Nico
MemberThanks for following up Gene!
I’ve added the state and country fields to the snippet (the change is not so lineal):
/* Tribe, set default values for venues in new event page */
function tribe_set_default_values( ) {// bail if we are not in an events page
if( !isset($_GET['post_type']) || 'tribe_events' != $_GET['post_type'] ) return false;$screen = get_current_screen();
// bails if it's not Add Event page
if ( 'add' != $screen->action ) return false;// bail if PRO is not active
if ( !class_exists('Tribe__Events__Pro__Default_Values') ) return false;$defaults = new Tribe__Events__Pro__Default_Values;
$default_city = $defaults->city();
$default_state = $defaults->state();
$default_country = $defaults->country();
$default_country = $default_country[1];?>
<script type="text/javascript">
jQuery('document').ready ( function ( $ ) {
$('input[name="venue[City][]"]' ).val('<?php echo $default_city; ?>');
$('select[name="venue[Country][]"]').val('<?php echo $default_country; ?>');
$('select[name="venue[Country][]"]').change();$('select[name="venue[State]"]' ).val('<?php echo $default_state; ?>');
});</script>
<?php
}add_action( 'admin_print_footer_scripts', 'tribe_set_default_values' );
Replace the snippet I sent before and try this one instead. Regarding the error description you sent I’m curious why the path to the error is ‘/plugins/JSO-updates/JSO-updates.php’ and not the functions.php file from your theme (or child theme). Anyway try pasting the code snippet in a plain text editor and then copy it over to the actual functions.php file.
Please let me know if it works as expected now,
Best,
NicoSeptember 26, 2016 at 11:02 am #1168833Ben
ParticipantYes, this works. The first time some of the text got converted in the email message (< and > converted to < >). I went back to the support forum and copied from there and it works fine. I placed the code in a patch plugin to isolate it form the Illustrious code, which gets updated from time to time. Thanks for your help! Gene
September 27, 2016 at 6:47 am #1169170Nico
MemberNice! Thanks for the heads-up Gene and glad to hear I could provide a workaround until this feature can be revisited π
Do you think we are in a good spot to close out this thread?
Please let me know about it,
Best,
NicoSeptember 27, 2016 at 9:38 am #1169292Ben
ParticipantThis reply is private.
September 27, 2016 at 11:53 am #1169388Nico
MemberThanks for confirming Gene π
Iβll go ahead and close out this thread, but if you need help with anything else please donβt hesitate to create a new one and we will be happy to assist you.
Best,
Nico -
AuthorPosts
- The topic ‘City Default Content Not Working’ is closed to new replies.
