epl_energy_certificate_keys: which fields make energy certificate buttons
Description #
The list of listing fields EPL turns into energy certificate buttons on the single listing (the epl_buttons_single_property action). EPL makes one button for each field in the list that has a value.
Add a field to show another button, or take one out. Since 3.6 epl_listing_has_links() reads the same list, so a template that hides an empty buttons area sees your fields too.
Usage #
add_filter( 'epl_energy_certificate_keys', 'my_energy_certificate_keys' );
Parameters #
$keys (array)
Field (meta key) names. Default: property_energy_certificate.
Examples #
Add a field of your own:
function my_energy_certificate_keys( $keys ) {
$keys[] = 'my_energy_report'; // A custom field holding a URL.
return $keys;
}
add_filter( 'epl_energy_certificate_keys', 'my_energy_certificate_keys' );
function my_energy_report_label( $label ) {
return 'Energy Report';
}
add_filter( 'epl_button_label_my_energy_report', 'my_energy_report_label' );
The default button text is "Energy Certificate" followed by the last character of the field name, so give your field a label: save it in {field}_label or use the epl_button_label_my_energy_report filter.
Take a field out:
add_filter( 'epl_energy_certificate_keys', '__return_empty_array' ); // No energy certificate button.
Notes #
- To hide one button without changing the list, return false from
epl_show_{field}, for exampleadd_filter( 'epl_show_property_energy_certificate', '__return_false' );. - Change a button's text with
epl_button_label_{field}, or for all of themepl_button_label_energy_certificate. - Each button has the class
epl-energy-certificate.
Related #
- Conditional tags:
epl_listing_has_links()andepl_listing_has_any_meta().
Source #
lib/hooks/hook-energy-certificate.php, in epl_button_energy_certificate() (since 3.4.38), and lib/includes/conditional-tags.php, in epl_listing_has_links() (since 3.6).