array( ' ', 'Вконтакте', '#0089FA', ), "facebook.com" => array('facebook', 'Facebook', '#3b5998'), "ok.ru" => array('odnoklassniki', 'Одноклассники', '#F57C20'), "plus.google.com" => array('google-plus', 'Google+', '#DB4437'), "pinterest.com" => array('pinterest', 'Pinterest', '#E60023'), "twitter.com" => array('twitter', 'Twitter', '#1DA1F2'), "del.icio.us" => array('vk', 'Delicious', '#C3C3C3'), "digg.com" => array('digg', 'Digg', '#A500B5'), "reddit.com" => array('reddit', 'Reddit', '#FF4500'), "linkedin.com" => array('linkedin', 'LinkedIn', '#0077B5'), "renren-inc.com" => array('renren', 'Renren', '#F8B400'), "tumblr.com" => array('tumblr', 'Tumblr', '#35465C'), "whatsapp.com" => array('whatsapp', 'WhatsApp', '#25D366'), "skype.com" => array('skype', 'Skype', '#00AFF0'), "telegram.org" => array('telegram', 'Telegram', "#2AABEE"), "t.me" => array('telegram', 'Telegram', "#2AABEE"), "instagram.com" => array('instagram', 'Instagram', '#C13584'), "instagr.am" => array('instagram', 'Instagram', '#C13584'), ); $urls = preg_split("/(\\r\\n|\n| |,)/", $text); $return = ""; foreach ($urls as $url) { preg_match_all( '/^ [a-z][a-z0-9+\-.]*:\/\/ # Scheme ([a-z0-9\-._~%!$&\'()*+,;=]+@)? # User (?P[a-z0-9\-._~%]+ # Named or IPv4 host |\[[a-z0-9\-._~%!$&\'()*+,;=:]+\]) # IPv6+ host /ix', $url, $result, PREG_PATTERN_ORDER ); $host = str_replace("www.", "", isset($result['host'][0]) ? $result['host'][0] : ''); if (!empty($social[$host][0])) { $arrSearch = array( '%URL', '%ICON', '%NAME', ); if (strpos($social[$host][0], "svg") !== false) { $icon = $social[$host][0]; } else { $icon = nc_get_icon_from_library( 'font_awesome', $social[$host][0], array( "width" => 24, "height" => 24, "fill" => $social[$host][2] ?: "", ) ); } $arrReplace = array( $url, $icon, $social[$host][1], ); $return .= str_replace($arrSearch, $arrReplace, $template); } } return $return; } }