Allows adding and removing buttons.
Parameters
$buttons
$params
(array) associative array with contextual data
You need to have a working knowledge of Hooks before you get started.
Boilerplate Code
Use the boilerplate code to start using the filter, and add your own logic to modify the first argument and return it.
Clickfwd\Hook\Filter::add('listing_detail_action_buttons', function($buttons, $params)
{
// Uncomment line below to view available data passed into hook
// For JReviews 3.x and earlier use dd instead of fwd_dd
// fwd_dd($buttons, $params);
return $buttons;
});
Development & Support
Customizations are not included with support. We provide this information to make it easier for developers to extend the functionality. From time to time we may have some availability for custom work. Get in touch to see if there's an opportunity to work together.
Examples
Integrate the EasySocial message button directly inside the listing detail page, allowing members to contact the listing owner.
function add_easysocial_message_button($buttons, $params)
{
if ( !defined('ES_MESSAGE_FILTER') ) {
require_once(JPATH_ADMINISTRATOR . '/components/com_easysocial/includes/foundry.php');
ES::initialize();
ES::language()->loadSite();
define('ES_MESSAGE_FILTER', 1);
}
// If user not logged in, show sign-up dialog
if (fwd_auth()->user()->isGuest()) {
$url = fwd_request()->createFromGlobals()->fullUrl();
$formData = json_encode(['current_url' => base64_encode($url)]);
$messageButton = '<a href="/jreviews/users/signupModal"
class="jrButton jrSmall jrButton"
rel="nofollow noopener"
data-jr-action="dialog"
data-jr-dialog-modal="1"
data-jr-width="800"
data-jr-title="Requires an Account"
data-form-data=\''.$formData.'\'
>
<span class="jrIconMessage"></span> Send Message
</a>';
$buttons[] = $messageButton;
return $buttons;
}
$listing = $params['listing'];
$easysocial = '
<button type="button" class="jrButton jrSmall"
data-es-conversations-compose
data-es-conversations-id="'.$listing['User']['user_id'].'"
data-es-provide="tooltip"
data-original-title="Contact This Member"
>
<span class="jrIconMessage"></span> Contact This Member
</button>
';
$buttons[] = $easysocial;
return $buttons;
}
Clickfwd\Hook\Filter::add('listing_detail_action_buttons', 'add_easysocial_message_button', 10);
Integrate the BuddyBoss and BuddyPress message button directly inside the listing detail page, allowing members to contact the listing owner.
function add_bb_message_button($buttons, $params)
{
if (! function_exists('bp_loggedin_user_domain')) {
return $buttons;
}
// If user not logged in, show sign-up dialog
if (fwd_auth()->user()->isGuest()) {
$url = fwd_request()->createFromGlobals()->fullUrl();
$formData = json_encode(['current_url' => base64_encode($url)]);
$messageButton = '<a href="/jreviews/users/signupModal"
class="jrButton jrSmall jrButton"
rel="nofollow noopener"
data-jr-action="dialog"
data-jr-dialog-modal="1"
data-jr-width="800"
data-jr-title="Requires an Account"
data-form-data=\''.$formData.'\'
>
<span class="jrIconMessage"></span> Send Message
</a>';
$buttons[] = $messageButton;
return $buttons;
}
$listing = $params['listing'];
$userId = $listing['User']['user_id'];
$url = wp_nonce_url( bp_loggedin_user_domain().bp_get_messages_slug().'/compose/?r='.bp_core_get_username($userId));
$messageButton = '
<a href="'.$url.'" class="jrButton jrSmall">
<span class="jrIconMessage"></span> Send Message
</a>
';
$buttons[] = $messageButton;
return $buttons;
}
Clickfwd\Hook\Filter::add('listing_detail_action_buttons', 'add_bb_message_button', 10);
If you want to show the send inquiry button only for featured listings, you can change the default behavior to hide it when a listing is not featured.
Clickfwd\Hook\Filter::add('listing_detail_action_buttons', function($buttons, $params)
{
if (! $params['listing']['Listing']['featured']) {
unset($buttons['inquiry']);
}
return $buttons;
});
Source
-
/views/helpers/listing_helper.php