Untitled
webwizards
plain_text
10 months ago
1.3 kB
20
Indexable
add_filter('salesking_make_offer_additional_text', function($conversationid){
// Get the post meta data
$conversation_data = get_post_meta($conversationid, 'b2bking_conversation_message_1', true);
if (empty($conversation_data)) {
return '';
}
// Pattern to match "Message:" in English or French (case insensitive)
$pattern = '/<b>[^<]*message[^<]*:<\/b><br\s*\/?><br\s*\/?>(.*?)<br\s*\/?><br\s*\/?><b>/is';
if (preg_match($pattern, $conversation_data, $matches)) {
// Find everything after the message content
$after_message = substr($conversation_data, strpos($conversation_data, $matches[0]) + strlen($matches[0]) - 3); // -3 to include the <b>
// Replace <br> tags with newlines (handle both <br> and <br/>)
$after_message = preg_replace('/<br\s*\/?>/i', "\n", $after_message);
// Remove all remaining HTML tags
$after_message = strip_tags($after_message);
// Remove "titre:" and everything until "adresse:" (case insensitive)
$after_message = preg_replace('/titre:.*?(?=adresse:)/is', '', $after_message);
// Clean up extra whitespace and return
return trim($after_message);
}
return '';
}, 10, 1);Editor is loading...
Leave a Comment