epl_external_link_keys: which fields make external link (tour) buttons
Description #
The list of listing fields EPL turns into external link (tour) 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_external_link_keys', 'my_external_link_keys' );
Parameters #
$keys (array)
Field (meta key) names. Default: property_external_link, property_external_link_2, property_external_link_3.
Examples #
Add a field of your own:
function my_external_link_keys( $keys ) {
$keys[] = 'my_virtual_tour'; // A custom field holding a URL.
return $keys;
}
add_filter( 'epl_external_link_keys', 'my_external_link_keys' );
function my_virtual_tour_label( $label ) {
return '3D Tour';
}
add_filter( 'epl_button_label_my_virtual_tour', 'my_virtual_tour_label' );
The default button text is "Tour" followed by the last character of the field name, so give your field a label: save it in {field}_label (for example my_virtual_tour_label) or use the epl_button_label_my_virtual_tour filter.
Take a field out:
function my_external_link_keys( $keys ) {
return array_diff( $keys, array( 'property_external_link_3' ) );
}
add_filter( 'epl_external_link_keys', 'my_external_link_keys' );
Notes #
- To hide one button without changing the list, return false from
epl_show_{field}, for exampleadd_filter( 'epl_show_property_external_link', '__return_false' );. - Change a button's text with
epl_button_label_{field}, or for all of themepl_button_label_tour(see epl_button_label_tour). - Each button has the class
epl-external-link.
Related #
- Conditional tags:
epl_listing_has_links()andepl_listing_has_any_meta().
Source #
lib/hooks/hook-external-links.php, in epl_button_external_link() (since 3.4.38), and lib/includes/conditional-tags.php, in epl_listing_has_links() (since 3.6).