Function Reference: geodir_payment_sidebar_show_send_to_friend

Summary

Display send to friend link on detail page sidebar when geodir_email field disabled for price package.

Description

This fixes the problem of “displaying send to friend link only when geodir_email enabled for price package”.

Global Values

$post
(object) (required) The current post object.

Default: None
$send_to_friend
(bool) (required) True if send to friend link already rendered. Otherwise false.

Default: None

Package

GeoDirectory_Payment_Manager

Change Log

Since: 1.3.6

Source Code

function geodir_payment_sidebar_show_send_to_friend() {
	global $post, $send_to_friend;
	
	if ($send_to_friend) {
		return; // Already shown or disabled.
	}
	
	if ( !(!empty($post) && geodir_is_page('detail') && !empty($post->post_type) && !empty($post->ID))) {
		return;
	}
	
	$package_info = geodir_post_package_info(array(), $post);
	if (!(!empty($package_info) && !empty($package_info->sendtofriend))) {
		return;
	}
	
	$field = geodir_get_field_infoby('htmlvar_name', 'geodir_email', $post->post_type);	
	$field_icon = !empty($field) && isset($field->field_icon) ? $field->field_icon : '';
	
	if (strpos($field_icon, 'http') !== false) {
		$field_icon_af = '';
	} elseif ($field_icon == '') {
		$field_icon_af = '<i class="fa fa-envelope"></i>';
	} else {
		$field_icon_af = $field_icon;
		$field_icon = '';
	}
	
	$content = '<input type="hidden" name="geodir_popup_post_id" value="' . $post->ID . '" /><div class="geodir_display_popup_forms"></div><div class="geodir_more_info geodir_email"><span class="geodir-i-email" style="' . esc_attr($field_icon) . '">' . $field_icon_af . '<a class="b_sendtofriend" href="javascript:void(0);">' . SEND_TO_FRIEND . '</a></span></div>';
	
	if (isset($_REQUEST['sendtofrnd']) && $_REQUEST['sendtofrnd'] == 'success') {
		$content .= '<p class="sucess_msg">' . SEND_FRIEND_SUCCESS . '</p>';
	} elseif (isset($_REQUEST['emsg']) && $_REQUEST['emsg'] == 'captch') {
		$content .= '<p class="error_msg_fix">' . WRONG_CAPTCH_MSG . '</p>';
	}
	
	/**
	 * Filter send to friend link content on detail page sidebar info.
	 *
	 * @since 1.3.6
	 *
	 * @param string $content Send to friend link html.
	 * @param object $post The current post object.
	 */
	apply_filters('geodir_payment_sidebar_show_send_to_friend', $content, $post);
	
	echo $content;
}