function alo_em_placeholders_replace_customlink_tag($content, $newsletter, $recipient, $stop_recursive_the_content = false) { if (!is_object($recipient)) { $recipient = new stdClass(); } if (empty($recipient->lang)) { $recipient->lang = alo_em_short_langcode(get_locale()); } if (preg_match_all('/\\[CUSTOM-LINK(.*)\\]/i', $content, $matches, PREG_SET_ORDER)) { if (is_array($matches)) { foreach ($matches as $match) { // Complete palceholder $found = $match[0]; // Placeholder attributes $atts = shortcode_parse_atts(trim($match[1])); $params = shortcode_atts(array('href' => '', 'title' => '', 'tracking' => 1, 'class' => 'alo-easymail-link', 'style' => ''), $atts); if (empty($params['href'])) { continue; } // skip if 'href' is empty // Numeric = post ID if (is_numeric($params['href'])) { if ($obj_post = get_post($params['href'])) { $title = !empty($params['title']) ? stripslashes($params['title']) : stripslashes(alo_em_translate_text($recipient->lang, $obj_post->post_title, $obj_post->ID, 'post_title')); $link = alo_em_translate_url($obj_post->ID, $recipient->lang); } } else { $title = !empty($params['title']) ? stripslashes($params['title']) : esc_url($params['href']); $link = esc_url($params['href']); } if ($params['tracking'] == 1) { $link = alo_em_make_url_trackable($recipient, $link); } $content = str_replace($found, '<a href="' . $link . '" class="' . esc_attr($params['class']) . '" style="' . esc_attr($params['style']) . '">' . $title . '</a>', $content); } } } return $content; }