function huddle_bp_get_the_profile_field_value($value, $type = '', $id = '') { global $field; if (substr_count(strtolower($field->name), 'twitter')) { if (!substr_count($field->data->value, 'twitter.com')) { $value = 'http://twitter.com/' . $value; } } elseif (substr_count(strtolower($field->name), 'about')) { } else { $values = explode(',', $value); if ($values) { foreach ((array) $values as $value) { $value = trim($value); // If the value is a URL, skip it and just make it clickable. if (preg_match('@(https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.]*(\\?\\S+)?)?)?)@', $value)) { $new_values[] = make_clickable($value); } else { if (count(explode(' ', $value)) > 5) { $new_values[] = $value; } else { $new_values[] = '<a href="' . site_url(bp_get_members_root_slug()) . '/?s=' . strip_tags($value) . '" rel="nofollow">' . $value . '</a>'; } } } $value = implode(', ', $new_values); } } return $value; }
function xprofile_filter_link_profile_data($field_value, $field_type = 'textbox') { if ('datebox' == $field_type) { return $field_value; } if (!strpos($field_value, ',') && count(explode(' ', $field_value)) > 5) { return $field_value; } $values = explode(',', $field_value); if ($values) { foreach ($values as $value) { $value = trim($value); /* If the value is a URL, skip it and just make it clickable. */ if (preg_match('@(https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.]*(\\?\\S+)?)?)?)@', $value)) { $new_values[] = make_clickable($value); } else { if (count(explode(' ', $value)) > 5) { $new_values[] = $value; } else { $new_values[] = '<a href="' . site_url(BP_MEMBERS_SLUG) . '/?s=' . $value . '">' . $value . '</a>'; } } } $values = implode(', ', $new_values); } return $values; }
function format_message($message) { if (!function_exists('process_smilies')) { include BASE_DIR . 'include' . DS . 'smilies.inc.php'; } return make_clickable(process_smilies(bb_decode($message))); }
function widget($args, $instance) { extract($args); $title = apply_filters('PhoenixTeam_Widget_Twitter', $instance['title']); $username = $instance['username'] ? $instance['username'] : null; $number = isset($instance['qty']) ? $instance['qty'] : null; static $counter = 1; // IDs for Widget; // echo $args['before_widget']; // It's the right way, but doesn't work with VC :( echo '<div id="' . THEME_SLUG . '-twitter-' . esc_attr($counter) . '" class="footer-twitter widget_' . THEME_SLUG . '-twitter">'; if ($title) { echo '<h4 class="widget-title">' . esc_html($title) . '</h4>'; } // $tweets = $this->get_tweets($args['widget_id'], $instance); // Good old, but doesn't work with VC $tweets = $this->get_tweets(THEME_SLUG . '-twitter-' . $counter, $instance); if (!empty($tweets['tweets']) && empty($tweets['tweets']->errors)) { $user = current($tweets['tweets']); if (is_object($user)) { $user = $user->user; } echo '<ul class="tweet_list">'; $checker = 0; foreach ($tweets['tweets'] as $tweet) { if ($checker <= $number) { if (isset($tweet->text)) { if (is_object($tweet)) { $avatar = $user->profile_image_url; $username = $user->screen_name; $user_url = 'https://twitter.com/' . $username; $tweet_text = htmlentities($tweet->text, ENT_QUOTES, 'UTF-8'); $tweet_text = make_clickable($tweet_text); $tweet_text = popuplinks($tweet_text); if ($tweet_text) { echo '<li> <a class="tweet_avatar" href="' . esc_url($user_url) . '"> <img src="' . esc_url($avatar) . '" alt="' . esc_attr($username) . '" title="' . esc_attr($username) . '"> </a> <span class="tweet_text">' . wp_kses_post($tweet_text) . '</span> </li>'; $checker++; } } } else { if ($checker == 0) { echo '<li><span class="content">' . __("There's no tweets in your feed...", 'grandway') . '</span></li>'; break; } break; } } } echo '</ul>'; } elseif ($tweets['tweets']->errors) { _e('Authentication failed! Please check your Twitter app data.', 'grandway'); } elseif (!$tweets['tweets']) { _e("There's no tweets there", 'grandway'); } echo $args['after_widget']; $counter++; }
/** * Sanitize the input string. HTML tags can be permitted. * The permitted tags can be supplied in an array. * * @TODO: Finish the code needed to support the $permittedTags array. * * @param string $string * @param bool $allowHTML [optional] * @param array $permittedTags [optional] * @return string */ public function sanitizeString($string, $allowHTML = FALSE, $permittedTags = array()) { // Strip all tags except the permitted. if (!$allowHTML) { // Ensure all tags are closed. Uses WordPress method balanceTags(). $balancedText = balanceTags($string, TRUE); $strippedText = strip_tags($balancedText); // Strip all script and style tags. $strippedText = preg_replace('@<(script|style)[^>]*?>.*?</\\1>@si', '', $strippedText); // Escape text using the WordPress method and then strip slashes. $escapedText = stripslashes(esc_attr($strippedText)); // Remove line breaks and trim white space. $escapedText = preg_replace('/[\\r\\n\\t ]+/', ' ', $escapedText); return trim($escapedText); } else { // Strip all script and style tags. $strippedText = preg_replace('@<(script|style)[^>]*?>.*?</\\1>@si', '', $string); $strippedText = preg_replace('/<(script|style).*?>.*?<\\/\\1>/si', '', stripslashes($strippedText)); /* * Use WordPress method make_clickable() to make links clickable and * use kses for filtering. * * http://ottopress.com/2010/wp-quickie-kses/ */ return wptexturize(wpautop(make_clickable(wp_kses_post($strippedText)))); } }
function pmpro_send_html($phpmailer) { // Set the original plain text message $phpmailer->AltBody = wp_specialchars_decode($phpmailer->Body, ENT_QUOTES); // Clean < and > around text links in WP 3.1 $phpmailer->Body = preg_replace('#<(http://[^*]+)>#', '$1', $phpmailer->Body); // Convert line breaks & make links clickable $phpmailer->Body = make_clickable($phpmailer->Body); // Add header to message if found if (file_exists(get_stylesheet_directory() . "/email_header.html")) { $phpmailer->Body = file_get_contents(get_stylesheet_directory() . "/email_header.html") . "\n" . $phpmailer->Body; } elseif (file_exists(get_template_directory() . "/email_header.html")) { $phpmailer->Body = file_get_contents(get_template_directory() . "/email_header.html") . "\n" . $phpmailer->Body; } // Add footer to message if found if (file_exists(get_stylesheet_directory() . "/email_footer.html")) { $phpmailer->Body = $phpmailer->Body . "\n" . file_get_contents(get_stylesheet_directory() . "/email_footer.html"); } elseif (file_exists(get_template_directory() . "/email_footer.html")) { $phpmailer->Body = $phpmailer->Body . "\n" . file_get_contents(get_template_directory() . "/email_footer.html"); } // Replace variables in email global $current_user; $data = array("name" => $current_user->display_name, "sitename" => get_option("blogname"), "login_link" => pmpro_url("account"), "display_name" => $current_user->display_name, "user_email" => $current_user->user_email, "subject" => $phpmailer->Subject); foreach ($data as $key => $value) { $phpmailer->Body = str_replace("!!" . $key . "!!", $value, $phpmailer->Body); } do_action("pmpro_after_phpmailer_init", $phpmailer); do_action("pmpro_after_pmpmailer_init", $phpmailer); //typo left in for backwards compatibility }
/** * Display meta in a formatted list. * * @param bool $flat (default: false) * @param bool $return (default: false) * @param string $hideprefix (default: _) * @param string $delimiter Delimiter used to separate items when $flat is true * @return string|void */ public function display($flat = false, $return = false, $hideprefix = '_', $delimiter = ", \n") { $output = ''; $formatted_meta = $this->get_formatted($hideprefix); if (!empty($formatted_meta)) { $meta_list = array(); foreach ($formatted_meta as $meta) { if ($flat) { $meta_list[] = wp_kses_post($meta['label'] . ': ' . $meta['value']); } else { $meta_list[] = ' <dt class="variation-' . sanitize_html_class(sanitize_text_field($meta['key'])) . '">' . wp_kses_post($meta['label']) . ':</dt> <dd class="variation-' . sanitize_html_class(sanitize_text_field($meta['key'])) . '">' . wp_kses_post(wpautop(make_clickable($meta['value']))) . '</dd> '; } } if (!empty($meta_list)) { if ($flat) { $output .= implode($delimiter, $meta_list); } else { $output .= '<dl class="variation">' . implode('', $meta_list) . '</dl>'; } } } $output = apply_filters('woocommerce_order_items_meta_display', $output, $this); if ($return) { return $output; } else { echo $output; } }
function in_plugin_update_message($plugin_data, $r) { // vars $readme = wp_remote_fopen(str_replace('/info/', '/trunk/readme.txt', $this->settings['remote'])); $regexp = '/== Changelog ==(.*)= ' . $this->get_version() . ' =/sm'; $o = ''; // validate if (!$readme) { return; } // regexp preg_match($regexp, $readme, $matches); if (!isset($matches[1])) { return; } // add style $o .= '<style type="text/css">'; $o .= '#advanced-custom-fields-options-page + .plugin-update-tr .update-message { background: #EAF2FA; border: #C7D7E2 solid 1px; padding: 10px; }'; $o .= '</style>'; // render changelog $changelog = explode('*', $matches[1]); array_shift($changelog); if (!empty($changelog)) { $o .= '<div class="acf-plugin-update-info">'; $o .= '<h3>' . __("What's new", 'acf') . '</h3>'; $o .= '<ul>'; foreach ($changelog as $item) { $o .= '<li>' . make_clickable($item) . '</li>'; } $o .= '</ul></div>'; } echo $o; }
/** * Filters the content of the link format posts. Wraps the content in the make_clickable() function * so that users can enter just a URL into the post content editor. */ function tamatebako_post_format_link_content($content) { if (has_post_format('link') && !preg_match('/<a\\s[^>]*?href=[\'"](.+?)[\'"]/is', $content)) { $content = make_clickable($content); } return $content; }
/** * Generate HTML for the keywords which will be defaulted */ private function default_keywords() { // Default keywords echo WPSEO_News_Wrappers::textinput('default_keywords', __('Default Keywords', 'wordpress-seo-news')); echo '<p>' . __('It might be wise to add some of Google\'s suggested keywords to all of your posts, add them as a comma separated list. Find the list here:', 'wordpress-seo-news') . ' ' . make_clickable('http://www.google.com/support/news_pub/bin/answer.py?answer=116037') . '</p>'; echo WPSEO_News_Wrappers::checkbox('restrict_sitemap_featured_img', __('Only use featured image for XML News sitemap, ignore images in post.', 'wordpress-seo-news'), false); echo '<br><br>'; }
/** * @param $text * @param $target * * @return mixed|string */ function rfbp_make_clickable($text, $target) { $clickable_text = make_clickable($text); if (!empty($target)) { return str_replace('<a href="', '<a target="' . $target . '" href="', $clickable_text); } return $clickable_text; }
public function text_format($text) { if (!$text) { return; } $text = make_clickable($text); $text = wptexturize(str_replace(array("\r\n", "\r", "\n"), '', nl2br(trim($text)))); return $text; }
public function sanitizie_comment($content, $comment) { $post_type = get_post_type($comment->comment_post_ID); if ($post_type == 'dwqa-question' || $post_type == 'dwqa-answer') { $content = str_replace(esc_html('<br>'), '<br>', esc_html($content)); $content = make_clickable($content); $content = preg_replace('/( <a[^>]* )( > )/', '$1 target="_blank" $2', $content); } return $content; }
/** * {@inheritDoc} */ public function get_profile_value($field_value, $field_data) { if (($field_value === null || $field_value === '') && !$field_data['field_show_novalue']) { return null; } $field_value = make_clickable($field_value); $field_value = censor_text($field_value); $field_value = bbcode_nl2br($field_value); return $field_value; }
/** * Convert plaintext URI to HTML links. * * Converts URI, www and ftp, and email addresses. Finishes by fixing links * within links. * * @since 0.71 * * @param string $text Content to convert URIs. * @return string Content with converted URIs. */ public static function Process($text) { $timer = Debug::GetTimer(); $r = ''; $textarr = preg_split('/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE); // split out HTML tags foreach ($textarr as $piece) { if (empty($piece) || $piece[0] == '<' && !preg_match('|^<\\s*[\\w]{1,20}+://|', $piece)) { $r .= $piece; continue; } // Long strings might contain expensive edge cases ... if (10000 < strlen($piece)) { // ... break it up foreach (self::_split_str_by_whitespace($piece, 2100) as $chunk) { // 2100: Extra room for scheme and leading and trailing paretheses if (2101 < strlen($chunk)) { $r .= $chunk; // Too big, no whitespace: bail. } else { $r .= make_clickable($chunk); } } } else { $ret = " {$piece} "; // Pad with whitespace to simplify the regexes $url_clickable = '~ ([\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation ( # 2: URL [\\w]{1,20}+:// # Scheme and hier-part prefix (?=\\S{1,2000}\\s) # Limit to URLs less than about 2000 characters long [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+ # Non-punctuation URL character (?: # Unroll the Loop: Only allow puctuation URL character if followed by a non-punctuation URL character [\'.,;:!?)] # Punctuation URL character [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character )* ) (\\)?) # 3: Trailing closing parenthesis (for parethesis balancing post processing) ~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character. // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times. $ret = preg_replace_callback($url_clickable, 'self::_make_url_clickable_cb', $ret); $ret = preg_replace_callback('#([\\s>])((www|ftp)\\.[\\w\\x80-\\xff\\#$%&~/.\\-;:=,?@\\[\\]+]+)#is', 'self::_make_web_ftp_clickable_cb', $ret); $ret = preg_replace_callback('#([\\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\\.)+[0-9a-z]{2,})#i', 'self::_make_email_clickable_cb', $ret); $ret = substr($ret, 1, -1); // Remove our whitespace padding. $r .= $ret; } } // Cleanup of accidental links within links $r = preg_replace('#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "\$1\$3</a>", $r); Debug::LogEvent(__METHOD__, $timer); return $r; }
/** * Sort the data for CSV output first * * @param int $product_id * @param array $headers * @param array $body * @param array $items */ public static function output_csv($product_id, $headers, $body, $items) { $headers['quantity'] = __('Quantity', 'wcvendors'); $new_body = array(); foreach ($body as $i => $order) { // Remove comments unset($body[$i]['comments']); // Remove all numeric keys in each order (these are the meta values we are redoing into new lines) foreach ($order as $key => $col) { if (is_int($key)) { unset($order[$key]); } } // New order row $new_row = $body[$i]; // Remove order to redo unset($body[$i]); $order = new WC_Order($i); foreach ($items[$i]['items'] as $item) { $product_id = !empty($item['variation_id']) ? $item['variation_id'] : $item['product_id']; $new_row_with_meta = $new_row; // Add the qty row $new_row_with_meta[] = $item['qty']; $item_meta = $item['name']; if ($metadata = $order->has_meta($item['product_id'])) { foreach ($metadata as $meta) { // Skip hidden core fields if (in_array($meta['meta_key'], apply_filters('woocommerce_hidden_order_itemmeta', array('_qty', '_tax_class', '_product_id', '_variation_id', '_line_subtotal', '_line_subtotal_tax', '_line_total', '_line_tax', WC_Vendors::$pv_options->get_option('sold_by_label'))))) { continue; } // Skip serialised meta if (is_serialized($meta['meta_value'])) { continue; } // Get attribute data if (taxonomy_exists(wc_sanitize_taxonomy_name($meta['meta_key']))) { $term = get_term_by('slug', $meta['meta_value'], wc_sanitize_taxonomy_name($meta['meta_key'])); $meta['meta_key'] = wc_attribute_label(wc_sanitize_taxonomy_name($meta['meta_key'])); $meta['meta_value'] = isset($term->name) ? $term->name : $meta['meta_value']; } else { $meta['meta_key'] = apply_filters('woocommerce_attribute_label', wc_attribute_label($meta['meta_key'], $_product), $meta['meta_key']); } $item_meta .= wp_kses_post(rawurldecode($meta['meta_key'])) . ':' . wp_kses_post(wpautop(make_clickable(rawurldecode($meta['meta_value'])))); } } $new_row_with_meta['product'] = $item_meta; $new_body[] = $new_row_with_meta; } } $headers = apply_filters('wcvendors_csv_headers', $headers, $product_id, $items); $body = apply_filters('wcvendors_csv_body', $new_body, $product_id, $items); WCV_Export_CSV::download($headers, $body, $product_id); }
/** * Remove all images, shortcodes, iframes, objects, and other fancy stuff. * * Makes unlinked URIs clickable. * * @param string $content * @return string */ public function strip_fancy_content($content) { // strip images $content = preg_replace('/<img[^>]*>/', '', $content); // strip shortcodes $content = strip_shortcodes($content); // strip iframes and objects $content = preg_replace('#<(iframe|object)[^>]*>.*?<\\/\\1>#', '', $content); // make unlinked URLs clickable $content = make_clickable($content); return $content; }
function display_tweets($show, $tweets, $hidepublicized, $before_tweet, $before_timesince, $account) { $tweets_out = 0; ?> <ul class='tweets'><?php foreach ((array) $tweets as $tweet) { if ($tweets_out >= $show) { break; } if (empty($tweet['text'])) { continue; } if ($hidepublicized && false !== strstr($tweet['source'], 'http://publicize.wp.com/')) { continue; } $tweet['text'] = esc_html($tweet['text']); // escape here so that Twitter handles in Tweets don't get mangled $tweet = $this->expand_tco_links($tweet); $tweet['text'] = make_clickable($tweet['text']); /* * Create links from plain text based on Twitter patterns * @link http://github.com/mzsanford/twitter-text-rb/blob/master/lib/regex.rb Official Twitter regex */ $tweet['text'] = preg_replace_callback('/(^|[^0-9A-Z&\\/]+)(#|\\xef\\xbc\\x83)([0-9A-Z_]*[A-Z_]+[a-z0-9_\\xc0-\\xd6\\xd8-\\xf6\\xf8\\xff]*)/iu', array($this, '_jetpack_widget_twitter_hashtag'), $tweet['text']); $tweet['text'] = preg_replace_callback('/([^a-zA-Z0-9_]|^)([@\\xef\\xbc\\xa0]+)([a-zA-Z0-9_]{1,20})(\\/[a-zA-Z][a-zA-Z0-9\\x80-\\xff-]{0,79})?/u', array($this, '_jetpack_widget_twitter_username'), $tweet['text']); if (isset($tweet['id_str'])) { $tweet_id = urlencode($tweet['id_str']); } else { $tweet_id = urlencode($tweet['id']); } ?> <li> <?php echo esc_attr($before_tweet) . $tweet['text'] . esc_attr($before_timesince); ?> <a href="<?php echo esc_url("http://twitter.com/{$account}/statuses/{$tweet_id}"); ?> " class="timesince"><?php echo esc_html(str_replace(' ', ' ', $this->time_since(strtotime($tweet['created_at'])))); ?> ago</a> </li> <?php unset($tweet_it); $tweets_out++; } ?> </ul><?php }
function columns_data($column) { global $post; $url = get_post_meta($post->ID, '_affurls_redirect', true); $count = get_post_meta($post->ID, '_affurls_count', true); if ($column == 'url') { echo make_clickable(esc_url($url ? $url : '')); } elseif ($column == 'permalink') { echo make_clickable(get_permalink()); } elseif ($column == 'clicks') { echo esc_html($count ? $count : 0); } }
/** * Return the URL for the first link found in this post. * * @param string the_content Post content, falls back to current post content if empty. * @return string URL or empty string when no link is present. */ function chunk_url_grabber($the_content = '') { if (empty($the_content)) { $the_content = make_clickable(get_the_content()); } if (function_exists('get_url_in_content')) { return get_url_in_content($the_content); } if (preg_match('/<a\\s[^>]*?href=([\'"])(.+?)\\1/is', $the_content, $matches)) { return esc_url_raw($matches[1]); } return ''; }
public static function show_entry($atts) { $atts = shortcode_atts(array('id' => false, 'entry' => false, 'fields' => false, 'plain_text' => false, 'user_info' => false, 'include_blank' => false, 'default_email' => false, 'form_id' => false, 'format' => 'text', 'direction' => 'ltr', 'font_size' => '', 'text_color' => '', 'border_width' => '', 'border_color' => '', 'bg_color' => '', 'alt_bg_color' => '', 'clickable' => false), $atts); if ($atts['format'] != 'text') { //format options are text, array, or json $atts['plain_text'] = true; } if (is_object($atts['entry']) && !isset($atts['entry']->metas)) { // if the entry does not include metas, force it again $atts['entry'] = false; } if (!$atts['entry'] || !is_object($atts['entry'])) { if (!$atts['id'] && !$atts['default_email']) { return ''; } if ($atts['id']) { $atts['entry'] = FrmEntry::getOne($atts['id'], true); } } if ($atts['entry']) { $atts['form_id'] = $atts['entry']->form_id; $atts['id'] = $atts['entry']->id; } if (!$atts['fields'] || !is_array($atts['fields'])) { $atts['fields'] = FrmField::get_all_for_form($atts['form_id'], '', 'include'); } $values = array(); foreach ($atts['fields'] as $f) { if ($f->type != 'password' && $f->type != 'credit_card') { self::fill_entry_values($atts, $f, $values); } unset($f); } self::fill_entry_user_info($atts, $values); if ($atts['format'] == 'json') { return json_encode($values); } else { if ($atts['format'] == 'array') { return $values; } } $content = array(); self::convert_entry_to_content($values, $atts, $content); if ('text' == $atts['format']) { $content = implode('', $content); } if ($atts['clickable']) { $content = make_clickable($content); } return $content; }
function replace_stuff($input) { // translations $done = false; while (!$done) { if (preg_match("/(?<=!t\\[)(.*?)(?=\\])/", $input, $match)) { list($en, $vi) = explode(":::", $match[0]); $input = str_replace("!t[{$match[0]}]", "<span class='translated' style='border-bottom: 1px dotted #fff;' title='" . ($_SESSION["language"] == "vi" ? $en : $vi) . "'>" . ($_SESSION["language"] == "vi" ? $vi : $en) . "</span>", $input); } else { $done = true; } } // internal links $done = false; $linkcount = 0; while (!$done) { if (preg_match("/(?<=!l\\[)(.*?)(?=\\])/", $input, $match)) { list($theid, $thetitle) = explode(":::", $match[0]); $link = "<a id='{$theid}{$linkcount}_titlelink'>{$thetitle}</a><script type='text/javascript'> \$('#{$theid}{$linkcount}_titlelink').click(function(){ load_page('view_single_discussion.php?id={$theid}'); }); </script>"; $input = str_replace("!l[{$match[0]}]", $link, $input); $linkcount++; } else { $done = true; } } // youtube videos // $done = false; // while (!$done){ // if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $input, $match)) { // $video_id = $match[1]; // $link = "<iframe width='420' height='315' src='http://www.youtube.com/embed/{$video_id}' frameborder='0' allowfullscreen></iframe>"; // $input = str_replace($match[0],$link,$input); // } else $done = true; // } $user = new User($_SESSION["user"]); $input = str_replace("%title%", mb_convert_case($user->post_name, MB_CASE_TITLE, "UTF-8"), $input); $input = str_replace("%me%", mb_convert_case($user->post_me, MB_CASE_TITLE, "UTF-8"), $input); $input = str_replace("%you%", mb_convert_case($user->post_you, MB_CASE_TITLE, "UTF-8"), $input); // emoticons // $sad = array(":sad:",":(",":-(","):",")-:"); // $input = str_replace($sad,"<img src='files/site_images/emoticons/sad.gif' style='vertical-align: middle;'/>",$input); // $cry = array(":cry:",":'(",":'-(",")':",")-':"); // $input = str_replace($cry,"<img src='files/site_images/emoticons/cry.gif' style='vertical-align: middle;'/>",$input); // $happy = array(":happy:",":)","(:",":-)","(-:",":D",":-D"); // $input = str_replace($happy,"<img src='files/site_images/emoticons/happy.gif' style='vertical-align: middle;'/>",$input); // $cool = array(":cool:"); // $input = str_replace($cool,"<img src='files/site_images/emoticons/cool.gif' style='vertical-align: middle;'/>",$input); $input = make_clickable($input); return $input; }
/** * Convert plaintext URI to HTML links. * * Code from WordPress * https://github.com/WordPress/WordPress/blob/master/wp-includes/formatting.php * * @param string $text * @return string */ function make_clickable($text) { $urlPattern = '~ ([\\s(<.,;:!?]) ( [\\w]{1,20}+:// (?=\\S{1,2000}\\s) [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+ (?: [\'.,;:!?)] [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ )* ) (\\)?) ~xS'; $ftpPattern = '#([\\s>])((www|ftp)\\.[\\w\\x80-\\xff\\#$%&~/.\\-;:=,?@\\[\\]+]+)#is'; $emailPattern = '#([\\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\\.)+[0-9a-z]{2,})#i'; $r = ''; $textarr = preg_split('/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE); $nested = 0; foreach ($textarr as $piece) { if (preg_match('|^<code[\\s>]|i', $piece) || preg_match('|^<pre[\\s>]|i', $piece)) { $nested++; } elseif ((strtolower($piece) === '</code>' || strtolower($piece) === '</pre>') && $nested) { $nested--; } if ($nested || empty($piece) || $piece[0] === '<' && !preg_match('|^<\\s*[\\w]{1,20}+://|', $piece)) { $r .= $piece; continue; } if (strlen($piece) > 10000) { foreach (_split_str_by_whitespace($piece, 2100) as $chunk) { if (strlen($chunk) > 2101) { $r .= $chunk; } else { $r .= make_clickable($chunk); } } } else { $ret = " {$piece} "; $ret = preg_replace_callback($urlPattern, '_make_url_clickable_cb', $ret); $ret = preg_replace_callback($ftpPattern, '_make_web_ftp_clickable_cb', $ret); $ret = preg_replace_callback($emailPattern, '_make_email_clickable_cb', $ret); $ret = substr($ret, 1, -1); $r .= $ret; } } return preg_replace('#(<a([ \\r\\n\\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "\$1\$3</a>", $r); }
public function custom_columns($column) { global $post; switch ($column) { case 'linker_url': echo make_clickable(get_post_meta($post->ID, '_linker_redirect', true)); break; case 'linker_permalink': echo '<input type="text" class="linker-permalink-copy-paste" value="' . esc_attr(get_permalink($post->ID)) . '" readonly />'; break; case 'linker_clicks': echo absint(get_post_meta($post->ID, '_linker_count', true)); break; } }
public function custom_columns($column) { global $post; switch ($column) { case 'linker_url': echo make_clickable(get_post_meta($post->ID, '_linker_redirect', true)); break; case 'linker_permalink': echo make_clickable(get_permalink($post->ID)); break; case 'linker_clicks': echo absint(get_post_meta($post->ID, '_linker_count', true)); break; } }
public static function status_content($status) { $text = $status->text; # @TODO more processing (hashtags, @s etc) $text = make_clickable($text); $text = str_replace(' href="', ' target="_blank" href="', $text); // En-link-ify all the #hashtags in the message text $hashtag_regex = '/(^|\\s)#(\\w*[a-zA-Z_]+\\w*)/'; // preg_match_all( $hashtag_regex, $text, $preg_output ); $text = preg_replace($hashtag_regex, '\\1<a href="http://twitter.com/search?q=%23\\2" target="_blank">#\\2</a>', $text); // En-link-ify all the @usernames in the message text $username_regex = '/(^\\.?|\\s|)\\@(\\w*[a-zA-Z_]+\\w*)/'; // preg_match_all( $username_regex, $text, $preg_output ); $text = preg_replace($username_regex, '\\1<a href="http://twitter.com/\\2" target="_blank">@\\2</a>', $text); return $text; }
function Comment($template, $commentid, $comment, $articlescomments) { global $Settings, $ACDB, $UserDB; $Config = $Settings->co; $output = $template[comment]; $output = str_replace("{number}", $i, $output); if ($comment[parentcid]) { $quotecomment = $articlescomments[$comment[parentcid]]; $quoteout = $template[quote]; $quoteout = str_replace("{name}", $quotecomment[name], $quoteout); $quoteout = str_replace("{quote}", Markdown(kses_filter($quotecomment[content])), $quoteout); $output = str_replace("{parentquote}", $quoteout, $output); } else { $output = str_replace("{parentquote}", "", $output); } # date $dateregexp = '#\\{date=(.*?)\\}#i'; preg_match_all($dateregexp, $output, $datematches, PREG_SET_ORDER); if (!empty($datematches)) { foreach ($datematches as $null => $match) { $output = str_replace($match[0], date($match[1], $commentid + $adjust * 60), $output); } } $output = str_replace("{comment}", Markdown(kses_filter($comment[content])), $output); $output = str_replace("{ip}", $comment[ip], $output); $output = str_replace("{author}", $comment[name], $output); $output = str_replace("{url}", $comment[url], $output); # Output mail if given $comment[email] ? $output = preg_replace("/\\[mail\\=\"(.*)\"\\]/ui", "<a href=\"mailto:{$comment['email']}\">\\1</a>", $output) : ($output = preg_replace("/\\[mail\\=\"(.*)\"\\]/ui", "", $output)); $output = str_replace("{reply}", '<a href="' . $currenturl . '?replyto=' . $commentid . '">reply</a>', $output); # The following will be set if the user is registered $checkuser = KUsers::indatabase(false, $comment[name]); if (eregi("{gravatar}", $output)) { if ($comment[email]) { $gravatarid = trim(md5($comment[email])); $size = $Config[comments][avatar][size]; $default = $Config[comments][avatar][defaulturl]; $gravatarurl = "http://www.gravatar.com/avatar.php?gravatar_id={$gravatarid}&size={$size}&default={$default}&border={$border}"; $output = str_replace("{gravatar}", "<img src=\"{$gravatarurl}\" alt=\"{$comment['name']}_gravatar\" />", $output); } else { $output = str_replace("{gravatar}", "", $output); } } $output = make_clickable($output); return $output; }
function auto_link_text_callback($matches) { $max_url_length = 50; $max_depth_if_over_length = 2; $ellipsis = '…'; $url_full = $matches[0]; $url_short = ''; $myfossil_hosts = array('myfossil.org', 'dev.myfossil.org', 'myfossil.local', 'myfossil.wpengine.com', 'myfossil.staging.wpengine.com'); $parts = parse_url($url_full); if (strpos($url_full, '/fossils/') === false || !in_array($parts['host'], $myfossil_hosts)) { return make_clickable($url_full); } if (strlen($url_full) > $max_url_length) { $url_short = $parts['scheme'] . '://' . preg_replace('/^www\\./', '', $parts['host']) . '/'; $path_components = explode('/', trim($parts['path'], '/')); foreach ($path_components as $dir) { $url_string_components[] = $dir . '/'; } if (!empty($parts['query'])) { $url_string_components[] = '?' . $parts['query']; } if (!empty($parts['fragment'])) { $url_string_components[] = '#' . $parts['fragment']; } for ($k = 0; $k < count($url_string_components); $k++) { $curr_component = $url_string_components[$k]; if ($k >= $max_depth_if_over_length || strlen($url_short) + strlen($curr_component) > $max_url_length) { if ($k == 0 && strlen($url_short) < $max_url_length) { // Always show a portion of first directory $url_short .= substr($curr_component, 0, $max_url_length - strlen($url_short)); } $url_short .= $ellipsis; break; } $url_short .= $curr_component; } } else { $url_short = $url_full; } $url_parts = explode("/", $url_full); $fossil_num = (int) array_pop($url_parts); if ($fossil_num <= 0) { $fossil_num = (int) array_pop($url_parts); } return sprintf('<a rel="nofollow" href="%s">Fossil #%06d</a>', $url_full, $fossil_num); }
function display_tweet($tweet) { echo "<div class='tweetContainer'>"; echo "<table>"; echo "<tr>"; echo "<td class='tweetImage'>"; echo "<img src='./default.jpg' class='tweetPicture' alt='display picture'/>"; echo "</td>"; echo "<td class='tweetContent'>"; echo "<a class='tweetUser' href='./" . $tweet['username'] . "'><strong class='username'>" . $tweet['name'] . "</strong> <span class='useralias'> @" . $tweet['username'] . "</span></a><span class='tweetTime'> - " . getTime($tweet['timestamp']) . "</span>"; $new_tweet = preg_replace('/@(\\w+)/', '<a href=./$1>$0</a>', $tweet['tweet']); $new_tweet = preg_replace('/#(\\w+)/', '<a href=./hashtag/$1>$0</a>', $new_tweet); echo "<div class='tweetText'>" . make_clickable($new_tweet) . "</div>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; }
function rex_email_obfuscator($params) { global $REX; $content = $params['subject']; $javascriptmethod = $REX['ADDON']['email_obfuscator']['settings']['javascriptmethod']; $nojavascriptmethod = $REX['ADDON']['email_obfuscator']['settings']['nojavascriptmethod']; $atPos = strpos($content, '@'); if ($atPos === false || !$javascriptmethod && !$nojavascriptmethod) { // nothing to do return $content; } // wrap anchor tag around email-adresses that don't have already an anchor tag around them $content = make_clickable($content); // replace all email addresses (now all wrapped in anchor tag) with spam aware version $content = preg_replace_callback('`\\<a([^>]+)href\\=\\"mailto\\:([^">]+)\\"([^>]*)\\>(.*?)\\<\\/a\\>`ism', function ($m) { return encode_email($m[2], $m[4]); }, $content); // done! return $content; }