Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter nikova

    (@nikova)

    Hello,

    This problem still presists at this day with 8.1.3.
    Finnish is in lowercase at trunk

    It wasn’t changed either in 8.1.2

    Hey,

    I’ve noticed same problem and I came up with solution below:

    function add_custom_check_for_location( $show_condition, $condition, $key, $event ) {
    	global $EM_Event;
    	if ( $condition !== 'has_location' || !isset( $EM_Event ) ) {
    		return $show_condition;
    	}
    
    	if ( ( $parent_id = $EM_Event->parent ) && in_array( $EM_Event->event_language, [ 'en_US', 'sv_SE' ] ) ) {
    		$parent = em_get_event( $parent_id );
    		if ( $parent->event_location_type === 'url' && !empty( $parent->event_location_data ) ) {
    			$EM_Event->event_location_type = 'url';
    			$EM_Event->event_location_data = $parent->event_location_data;
    			$show_condition = true;
    		}
    	}
    	return $show_condition;
    }
    
    add_filter( 'em_event_output_show_condition', 'add_custom_check_for_location', 10, 4 );

    This works if you are using {has_location}{/has_location} checks for showing event URL. You can replace en_US, sv_SE with what ever language code you are using.

    If you want to make url data translatable via WPML you could use following version instead:

    function add_custom_check_for_location( $show_condition, $condition, $key, $event ) {
    	global $EM_Event;
    	if ( $condition !== 'has_location' || !isset( $EM_Event ) ) {
    		return $show_condition;
    	}
    	if ( ( $parent_id = $EM_Event->parent ) && in_array( $EM_Event->event_language, [ 'en_US', 'sv_SE' ] ) ) {
    		$parent = em_get_event( $parent_id );
    		if ( $parent->event_location_type === 'url' && !empty( $parent->event_location_data ) ) {
    			$location_data = [];
    			array_walk($parent->event_location_data, function( $v, $k ) use( &$location_data ) {
    				do_action( 'wpml_register_single_string', 'textdomain', $k, $v );
    				$location_data[ $k ] = __( $v, 'textdomain' );
    			} );
    			$EM_Event->event_location_type = 'url';
    			$EM_Event->event_location_data = $location_data;
    			$show_condition = true;
    		}
    	}
    	return $show_condition;
    }
    
    add_filter( 'em_event_output_show_condition', 'add_custom_check_for_location', 10, 4 );

    I Hope these helps and you can add one of those snippets to functions.php file. 🙂

    • This reply was modified 5 years, 6 months ago by nikova.
Viewing 2 replies - 1 through 2 (of 2 total)