当前位置: 首页>>代码示例>>PHP>>正文


PHP make_clickable函数代码示例

本文整理汇总了PHP中make_clickable函数的典型用法代码示例。如果您正苦于以下问题:PHP make_clickable函数的具体用法?PHP make_clickable怎么用?PHP make_clickable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了make_clickable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: huddle_bp_get_the_profile_field_value

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;
}
开发者ID:nxtclass,项目名称:NXTClass-themes,代码行数:29,代码来源:functions.php

示例2: xprofile_filter_link_profile_data

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;
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:27,代码来源:bp-xprofile-filters.php

示例3: format_message

 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)));
 }
开发者ID:phill104,项目名称:branches,代码行数:7,代码来源:forum_helper.php

示例4: widget

 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++;
 }
开发者ID:WillLin,项目名称:CS-SC-Front-End,代码行数:60,代码来源:widget-twitter.php

示例5: sanitizeString

 /**
  * 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('/&lt;(script|style).*?&gt;.*?&lt;\\/\\1&gt;/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))));
     }
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:38,代码来源:class.utility.php

示例6: pmpro_send_html

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
}
开发者ID:Tanya-atsocial,项目名称:paid-memberships-pro,代码行数:30,代码来源:email.php

示例7: display

    /**
     * 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;
        }
    }
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:40,代码来源:class-wc-order-item-meta.php

示例8: in_plugin_update_message

 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;
 }
开发者ID:adhitiadarmawan,项目名称:rsa,代码行数:33,代码来源:acf-options-page-update.php

示例9: tamatebako_post_format_link_content

/**
 * 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;
}
开发者ID:WPDevHQ,项目名称:nevertheless,代码行数:11,代码来源:post-formats.php

示例10: default_keywords

 /**
  * 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>';
 }
开发者ID:scottnkerr,项目名称:eeco,代码行数:11,代码来源:class-admin-page.php

示例11: rfbp_make_clickable

/**
 * @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;
}
开发者ID:fedeB-IT-dept,项目名称:fedeB_website,代码行数:14,代码来源:helpers.php

示例12: text_format

 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;
 }
开发者ID:lykeven,项目名称:graspzhihu,代码行数:9,代码来源:class-quotes-collection-quote.php

示例13: sanitizie_comment

 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;
 }
开发者ID:layoutzweb,项目名称:dw-question-answer,代码行数:10,代码来源:Comment.php

示例14: Process

    /**
     * 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;
    }
开发者ID:railpage,项目名称:railpagecore,代码行数:65,代码来源:MakeClickable.php

示例15: output_csv

 /**
  * 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);
 }
开发者ID:stodorovic,项目名称:wcvendors,代码行数:61,代码来源:class-export-csv.php


注:本文中的make_clickable函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。