Modifying Placeholder Default Information
Some default placeholders can be directly modified with template files. However, since some placeholders require such small information, it's not worth making every bit of information require a template file.
This also works exactly like creating your own custom placeholder, but instead you replace the contents that were previously being output compared to a blank string. In the following example, we'll make a simple modification to the #_LOCATIONNAME
placeholder.
add_filter('em_location_output_placeholder','my_em_placeholder_mod',1,3);
function my_em_placeholder_mod($replace, $EM_Location, $result){
if ( $result == '#_LOCATIONNAME' ) {
$replace = $replace . " plus some modifications";
}
return $replace;
}
Firstly, we add a function to the em_location_output_placeholder
filter, which is just like the em_event_output_placeholder
filter but for locations. This function will take three arguments:
$replace
- is the value of what this placeholder would be replaced with (and since this is not an EM placeholder, this would always be an empty string)$EM_Location
- is the EM_Location object$result
- is the placeholder that was matched
By checking $result
we're making sure we're dealing with the right placeholder, and if we are, we can alter the $replace
variable before it's returned and change the placeholder information.
This doesn't mean you can't use template files should you want to, you can create your own file in your theme folder and link to it using the em_locate_template
function during the filter that you would have to create in order to modify the placeholder contents. Here's an example where I created a file in mytheme/plugins/events-manager/placeholders/locationname.php
for more complex HTML
add_filter('em_location_output_placeholder','my_em_placeholder_mod',1,3);
function my_em_placeholder_mod($replace, $EM_Location, $result){
if ( $result == '#_LOCATIONNAME' ) {
ob_start();
$template = em_locate_template('placeholders/locationname.php', true, array('EM_Event'=>$EM_Location));
$replace = ob_get_clean();
}
return $replace;
}