epl_elementor_meta_blocked_keys: fields the Custom Field widget won't show

Description #

The Elementor Custom Field widget shows any listing field (meta key) you type into it. This filter is the list of fields it refuses to show for a listing, so a page designer can't reveal something the listing hides. Add keys to block more fields, for example owner or vendor details.

By default the list is:

  • When the listing hides its street address (show_street_address() is false): property_address_street, property_address_street_number, property_address_sub_number, property_address_lot_number and property_address_coordinates.
  • When the listing's property_price_display isn't yes: property_price, property_price_view, property_sold_price, property_rent, property_rent_view and property_com_rent.
  • Otherwise empty.

Whatever the filter returns, the widget never shows protected meta (keys starting with an underscore). For a blocked field the widget shows its "Empty Value" text, or nothing.

Part of the Elementor integration, which is in beta. See Elementor widgets and templates (beta) for how the widgets and templates fit together.


Usage #

add_filter( 'epl_elementor_meta_blocked_keys', 'my_function', 10, 2 );

Parameters #

$blocked (array)
Meta keys the widget won't show for this listing.

$property (EPL_Property_Meta)
The listing being shown.


Examples #

Never show the owner or the commercial outgoings in a Custom Field widget:

function my_epl_block_meta( $blocked, $property ) {
	$blocked[] = 'property_owner';
	$blocked[] = 'property_com_outgoings';
	return $blocked;
}
add_filter( 'epl_elementor_meta_blocked_keys', 'my_epl_block_meta', 10, 2 );

The widget lowercases the key and strips anything other than letters, numbers, dashes and underscores before checking it, so list keys in that form.


Source #

lib/page-builders/elementor/widgets/elements/class-epl-elementor-property-meta.php, in EPL_Elementor_Property_Meta::render(). Since 3.6.