1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172:
<?php
class Inbound_Email_Template_Shortcodes {
public function __construct() {
self::load_hooks();
}
public function load_hooks() {
add_shortcode('inbound-email-post-params', array(__CLASS__, 'post_params_table'), 1);
add_shortcode('inbound-gravitar', array(__CLASS__, 'generate_gravitar'), 1);
}
public static function post_params_table($atts) {
$html = '';
$post_params = apply_filters('inbound-email-post-params', $_POST);
$blacklist = array('action', 'event', 'post_type', 'mapped_params', 'raw_params', 'url_params', 'page_views', 'g-recaptcha-response', 'inbound_submitted', 'inbound_notify', 'inbound_params', 'inbound_furl', 'phone_xoxo', 'page_id', 'search_data', 'first_name', 'full_name', 'last_name', 'email');
if (isset($_POST['inbound_params']) && $_POST['inbound_params'] != "") {
$url_params = json_decode(stripslashes($_POST['inbound_params']));
foreach ($url_params as $field => $value) {
if (preg_match('/utm_/i', $field)) {
$post_params[$field] = strip_tags($value);
}
}
}
if (isset( $post_params['email'] ) ) {
$post_params['email'] = str_replace('%40', '@', $post_params['email']);
}
if (isset($_POST['mapped_params'])) {
parse_str($_POST['mapped_params'], $mapped_params);
foreach ($mapped_params as $key => $value) {
$post_params = array($key => $value) + $post_params;
}
}
if (isset($_POST['raw_params'])) {
parse_str($_POST['raw_params'], $raw_params);
foreach ($raw_params as $key => $value) {
if (!isset($post_params[$key])) {
$post_params = $post_params + array($key => $value);
}
}
}
$post_params = apply_filters('inbound_email_response/post_params', $post_params);
foreach ($post_params as $key => $value) {
$name = str_replace(array('-', '_'), ' ', $key);
$name = ucwords($name);
if (in_array($key, $blacklist)) {
continue;
}
if (is_array($value)) {
$value = implode(', ', $value);
} else if (strlen($value) < 1 || !$value) {
continue;
}
if (preg_match('/utm_/i', $key)) {
$name = ucfirst(str_replace("utm_", "", $key));
}
$name = str_replace('Wpleads ', '', $name);
if ($key == "inbound_form_id") {
$value = "<a title='" . __('View/Edit this form', 'inbound-pro') . "' href='" . admin_url('post.php?post=' . $value . '&action=edit') . "'>" . $value . "</a>";
}
if ($key == "inbound_form_lists" && $value != "") {
$name = 'Added to Lists:';
$lists = explode(',', $value);
$count = count($lists) - 1;
$list_links = "";
foreach ($lists as $list) {
$list_links .= "<a title='" . __('View this list', 'inbound-pro') . "' href='" . admin_url('edit.php?page=lead_management&post_type=wp-lead&wplead_list_category%5B%5D=' . $list . '&relation=AND&orderby=date&order=asc&s=&t=&submit=Search+Leads') . "'>" . $list . "</a>";
if ($count) {
$list_links .= ' - ';
$count--;
}
}
$value = $list_links;
}
if ($key == "wp_cta_id") {
$value = "<a title=' " . __('View/Edit this CTA', 'inbound-pro') . "' href='" . admin_url('post.php?post=' . $value . '&action=edit') . "'>" . $value . "</a>";
}
if ($key == "inbound_current_page_url") {
$name = __("Converted on Page", 'inbound-pro');
}
$html .= '<tr style="border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#cccccc;">';
$html .= '<td width="600" style="border-right:1px solid #cccccc;">';
$html .= '<table cellpadding="10" style="width:100%;max-width:600px;border-collapse:collapse;border:none;background:white;"><tbody><tr style="background:#ffffff;height:27px;font-weight:lighter;color:#555;font-size:16px;border:none;text-align:left;"><td align="left" width="200" style="color:#555;font-size:16px;font-weight:bold;">';
$html .= $name;
$html .= '</td><td align="left" width="400" style="font-size:14px;color:#000;">';
$html .= $value;
$html .= '</td></tr></tbody></table>';
$html .= '</td></tr>';
}
return $html;
}
public static function generate_gravitar($atts) {
extract(shortcode_atts(array(
'email' => 'default@gravitar.com',
'size' => '60',
'default' => 'mm'
), $atts));
return "//www.gravatar.com/avatar/" . md5(strtolower(trim($email))) . "?d=" . urlencode($default) . "&s=" . $size;
}
}
new Inbound_Email_Template_Shortcodes();