* @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 = ""; } if($social['slug'] == "Twitter" && ($value['bg_color'] == "#1ab2e8" || $value['bg_color'] == "rgb(26, 178, 232)") ) { $value['bg_color'] = "#000000"; } $color = ""; if (!empty($value['bg_color'])) { $value['bg_color'] = $this->validate_color($value['bg_color'], $social['color']); $color = "background-color: ".esc_attr($value['bg_color']); } 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']; } // Check if the 'value' field is not empty if (!empty($value['value'])) { // Extract the social slug for readability $socialSlug = $social['slug']; // Check if the social slug is one of the specified values if ($socialSlug == "Whatsapp" || $socialSlug == "Phone" || $socialSlug == "SMS") { // Clean the 'value' field for numbers $value['value'] = $this->cleanStringForNumbers($value['value']); } // Check if the social slug is "Whatsapp" if ($socialSlug == "Whatsapp") { // Remove leading '+' and then prepend '+' $value['value'] = "+" . ltrim($value['value'], "+"); } // Social slugs that require numeric formatting $numericSocials = ["Whatsapp", "Viber"]; // Social slugs that require username formatting $usernameSocials = ["Telegram", "Snapchat", "TikTok"]; // Check if the current social slug requires numeric formatting if (in_array($socialSlug, $numericSocials)) { // Remove unwanted characters and prepend '+' $val = str_replace(["+", "-", " "], "", $value['value']); if(is_numeric($val)) { $value['value'] = "+" . $val; } } // No special formatting required for other social slugs } $isAgent = 0; ?>
  • " data-type="" data-channel="" id="chaty-social-">
    free 1 available">
    ">
    custom-icon- default_image_">
    " name="cht_social_[value]" value="" data-gramm_editor="false" id="channel_input_" />
    [ 'href' => [], 'title' => [], 'target' => [] ], 'br' => [], 'em' => [], 'strong' => [], ]; ?>
    ">
    validate_color($wp_popup_head_bg_color, "#4AA485"); ?>
    " id="-custom-image-upload">
    <?php esc_html_e(" />
    [ 'title' => esc_html__("Name", "chaty"), 'placeholder' => esc_html__("Enter your name", "chaty"), 'is_required' => 1, 'type' => 'input', 'is_enabled' => 1, ], 'email' => [ 'title' => esc_html__("Email", "chaty"), 'placeholder' => esc_html__("Enter your email address", "chaty"), 'is_required' => 1, 'type' => 'email', 'is_enabled' => 1, ], 'phone' => [ 'title' => esc_html__("Phone", "chaty"), 'placeholder' => esc_html__("Enter your phone number", "chaty"), 'is_required' => 1, 'type' => 'input', 'is_enabled' => 1, ], 'message' => [ 'title' => esc_html__("Message", "chaty"), 'placeholder' => esc_html__("Enter your message", "chaty"), 'is_required' => 1, 'type' => 'textarea', 'is_enabled' => 1, ], ]; echo '
    '; foreach ($fields as $label => $field) { $saved_value = isset($value[$label]) ? $value[$label] : []; $field_value = [ 'is_active' => (isset($saved_value['is_active'])) ? $saved_value['is_active'] : 'yes', 'is_required' => (isset($saved_value['is_required'])) ? $saved_value['is_required'] : 'yes', 'placeholder' => (isset($saved_value['placeholder'])) ? $saved_value['placeholder'] : $field['placeholder'], 'field_label' => (isset($saved_value['field_label'])) ? $saved_value['field_label'] : $field['title'], ]; ?>
    ">
    ">
    '; ?>
    del_space($social['slug'])); $slug = str_replace(' ', '_', $slug); $isDesktop = isset($value['is_desktop']) && $value['is_desktop'] == "checked" ? "checked" : ''; $isMobile = isset($value['is_mobile']) && $value['is_mobile'] == "checked" ? "checked" : ''; ?>
    " id="-close-btn" onclick="toggle_chaty_setting('')">
    "> socials; ?>
    validate_color($field_value, "#A886CD"); ?>
    validate_color($fieldValue, "#ffffff"); ?>
    validate_color($fieldValue, "#A886CD"); ?>
    ">
    " type="text" name="cht_social_[redirect_link]" value="">
    ">
    🚀
    validate_color($wechat_header_color, "#A886CD"); ?>
    ">