WordPress.org

Forums

Events Manager
[resolved] Conditionals location placeholder (2 posts)

  1. cimbalo
    Member
    Posted 3 years ago #

    I wrote a patch to fix the filter 'em_location_output_condition'.
    Without this fix you are unable to add custom conditionals location placeholder.
    Will it be included in the next release?

    +++ classes/em-location.php
    @@ -539,15 +539,15 @@
    
     	function output($format, $target="html") {
     		$location_string = $format;
    -		preg_match_all('/\{([a-zA-Z0-9_]+)\}([^{]+)\{\/[a-zA-Z0-9_]+\}/', $format, $conditionals);
    +		preg_match_all('/\{([a-zA-Z0-9_]+)\}(.+?)\{\/\1\}/s', $location_string, $conditionals);
     		if( count($conditionals[0]) > 0 ){
     			//Check if the language we want exists, if not we take the first language there
     			foreach($conditionals[1] as $key => $condition){
    -				$format = str_replace($conditionals[0][$key], apply_filters('em_location_output_condition', '', $conditionals[0][$key], $condition, $this), $format);
    +				$location_string = str_replace($conditionals[0][$key], apply_filters('em_location_output_condition', '', $conditionals[0][$key], $condition, $this), $location_string);
     			}
     		}
     		//This is for the custom attributes
    -		preg_match_all('/#_LATT\{([^}]+)\}(\{([^}]+)\})?/', $format, $results);
    +		preg_match_all('/#_LATT\{([^}]+)\}(\{([^}]+)\})?/', $location_string, $results);
     		foreach($results[0] as $resultKey => $result) {
     			//Strip string of placeholder and just leave the reference
     			$attRef = substr( substr($result, 0, strpos($result, '}')), 7 );
    @@ -561,7 +561,7 @@
     			$attString = apply_filters('em_location_output_placeholder', $attString, $this, $result, $target);
     			$location_string = str_replace($result, $attString ,$location_string );
     		}
    -	 	preg_match_all("/(#@?_?[A-Za-z0-9]+)({([a-zA-Z0-9,]+)})?/", $format, $placeholders);
    +	 	preg_match_all("/(#@?_?[A-Za-z0-9]+)({([a-zA-Z0-9,]+)})?/", $location_string, $placeholders);
     	 	$replaces = array();
     		foreach($placeholders[1] as $key => $result) {
     			$replace = '';

    Andrea

    http://wordpress.org/extend/plugins/events-manager/

  2. Daedalon
    Member
    Posted 3 years ago #

    Sounds like a useful fix. Haven't ran into a placeholder that requires this, but bookmarked just in case.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Events Manager
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic