* @license : GPL2 * */ if (defined('ABSPATH') === false) { exit; } $value = get_option('cht_social_'.$social['slug']); // get setting for media if already saved $imageUrl = plugin_dir_url("")."chaty/admin/assets/images/chaty-default.png"; if (empty($value)) { // Initialize default values if not found $value = [ 'value' => '', 'is_mobile' => 'checked', 'is_desktop' => 'checked', 'image_id' => '', 'title' => $social['title'], 'bg_color' => "", ]; } if (!isset($value['bg_color']) || empty($value['bg_color'])) { $value['bg_color'] = $social['color']; // Initialize background color value if not exists. 2.1.0 change } if (!isset($value['image_id'])) { $value['image_id'] = ''; // Initialize custom image id if not exists. 2.1.0 change } if (!isset($value['title'])) { $value['title'] = $social['title']; // Initialize title if not exists. 2.1.0 change } if (!isset($value['fa_icon'])) { $value['fa_icon'] = ""; // Initialize title if not exists. 2.1.0 change } if (!isset($value['value'])) { $value['value'] = ""; // Initialize title if not exists. 2.1.0 change } $imageId = $value['image_id']; $status = 0; if (!empty($imageId)) { $imageUrl = wp_get_attachment_image_src($imageId, "full")[0]; // get custom image URL if exists $status = 1; } if ($imageUrl == "") { $imageUrl = plugin_dir_url("")."chaty/admin/assets/images/chaty-default.png"; // Initialize with default image if custom image is not exists $status = 0; $imageId = ""; } $color = ""; if (!empty($value['bg_color'])) { $color = "background-color: ".$value['bg_color']; // set background color of icon it it is exists } if ($social['slug'] == "Whatsapp") { // $val = $value['value']; // $val = str_replace("+", "", $val); // $value['value'] = $val; } else if ($social['slug'] == "Facebook_Messenger") { $val = $value['value']; $val = str_replace("facebook.com", "m.me", $val); // Replace facebook.com with m.me version 2.0.1 change. $val = str_replace("www.", "", $val); // Replace www. with blank version 2.0.1 change. $value['value'] = $val; $val = trim($val, "/"); $valArray = explode("/", $val); $total = (count($valArray) - 1); $lastValue = $valArray[$total]; $lastValue = explode("-", $lastValue); $totalText = (count($lastValue) - 1); $totalText = $lastValue[$totalText]; if (is_numeric($totalText)) { $valArray[$total] = $totalText; $value['value'] = implode("/", $valArray); } }//end if $value['value'] = esc_attr(wp_unslash($value['value'])); $value['title'] = esc_attr(wp_unslash($value['title'])); $svgIcon = $social['svg']; $helpTitle = ""; $helpText = ""; $helpLink = ""; if ((isset($social['help']) && !empty($social['help'])) || isset($social['help_link'])) { $helpTitle = isset($social['help_title']) ? $social['help_title'] : "Doesn't work?"; $helpText = isset($social['help']) ? $social['help'] : ""; if (isset($social['help_link']) && !empty($social['help_link'])) { $helpLink = $social['help_link']; } } $channelType = ""; $placeholder = $social['example']; if ($social['slug'] == "Link" || $social['slug'] == "Custom_Link" || $social['slug'] == "Custom_Link_3" || $social['slug'] == "Custom_Link_4" || $social['slug'] == "Custom_Link_5") { if (isset($value['channel_type'])) { $channelType = esc_attr(wp_unslash($value['channel_type'])); } if (!empty($channelType)) { foreach ($this->socials as $icon) { if ($icon['slug'] == $channelType) { $svgIcon = $icon['svg']; $placeholder = $icon['example']; if ((isset($icon['help']) && !empty($icon['help'])) || isset($icon['help_link'])) { $helpTitle = isset($icon['help_title']) ? $icon['help_title'] : "Doesn't work?"; $helpText = isset($icon['help']) ? $icon['help'] : ""; if (isset($icon['help_link']) && !empty($icon['help_link'])) { $helpLink = $icon['help_link']; } } } } } }//end if if (empty($channelType)) { $channelType = $social['slug']; } if(!empty($value['value'])) { if($social['slug'] == "Whatsapp" || $social['slug'] == "SMS" || $social['slug'] == "Viber") { $val = $value['value']; $val = str_replace("+","",$val); $val = str_replace("-","",$val); $val = str_replace(" ","",$val); $value['value'] = "+" . $val; } if ($social['slug'] == "Telegram" || $social['slug'] == "Instagram" || $social['slug'] == "Snapchat" || $social['slug'] == "TikTok") { $value['value'] = trim($value['value'], "@"); $value['value'] = "@" . $value['value']; } } $isAgent = 0; ?>