當前位置: 首頁>>代碼示例>>PHP>>正文


PHP wp_pre_kses_less_than函數代碼示例

本文整理匯總了PHP中wp_pre_kses_less_than函數的典型用法代碼示例。如果您正苦於以下問題:PHP wp_pre_kses_less_than函數的具體用法?PHP wp_pre_kses_less_than怎麽用?PHP wp_pre_kses_less_than使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了wp_pre_kses_less_than函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: wpcf7_sanitize_query_var

function wpcf7_sanitize_query_var($text)
{
    $text = wp_unslash($text);
    $text = wp_check_invalid_utf8($text);
    if (false !== strpos($text, '<')) {
        $text = wp_pre_kses_less_than($text);
        $text = wp_strip_all_tags($text);
    }
    $text = preg_replace('/%[a-f0-9]{2}/i', '', $text);
    $text = preg_replace('/ +/', ' ', $text);
    $text = trim($text, ' ');
    return $text;
}
開發者ID:abcode619,項目名稱:wpstuff,代碼行數:13,代碼來源:formatting.php

示例2: sanitize_multiline_text_field

/**
 * Filter a sanitized multi line text field string without removing linebreaks and tabs.
 *
 * @since 1.4.3
 *
 * @param string $filtered The sanitized string.
 * @param string $str      The string prior to being sanitized.
 */
function sanitize_multiline_text_field($str)
{
    $filtered = wp_check_invalid_utf8($str);
    if (strpos($filtered, '<') !== false) {
        $filtered = wp_pre_kses_less_than($filtered);
        // This will strip extra whitespace for us.
        $filtered = wp_strip_all_tags($filtered, true);
    }
    $found = false;
    while (preg_match('/%[a-f0-9]{2}/i', $filtered, $match)) {
        $filtered = str_replace($match[0], '', $filtered);
        $found = true;
    }
    if ($found) {
        // Strip out the whitespace that may now exist after removing the octets.
        $filtered = trim(preg_replace('/ +/', ' ', $filtered));
    }
    return $filtered;
}
開發者ID:Jamesits,項目名稱:wp-keybase-verification,代碼行數:27,代碼來源:write.php

示例3: sanitize_text_field

/**
 * Sanitize a string from user input or from the db
 *
 * check for invalid UTF-8,
 * Convert single < characters to entity,
 * strip all tags,
 * remove line breaks, tabs and extra white space,
 * strip octets.
 *
 * @since 2.9.0
 *
 * @param string $str
 * @return string
 */
function sanitize_text_field($str)
{
    $filtered = wp_check_invalid_utf8($str);
    if (strpos($filtered, '<') !== false) {
        $filtered = wp_pre_kses_less_than($filtered);
        // This will strip extra whitespace for us.
        $filtered = wp_strip_all_tags($filtered, true);
    } else {
        $filtered = trim(preg_replace('/[\\r\\n\\t ]+/', ' ', $filtered));
    }
    $found = false;
    while (preg_match('/%[a-f0-9]{2}/i', $filtered, $match)) {
        $filtered = str_replace($match[0], '', $filtered);
        $found = true;
    }
    if ($found) {
        // Strip out the whitespace that may now exist after removing the octets.
        $filtered = trim(preg_replace('/ +/', ' ', $filtered));
    }
    /**
     * Filter a sanitized text field string.
     *
     * @since 2.9.0
     *
     * @param string $filtered The sanitized string.
     * @param string $str      The string prior to being sanitized.
     */
    return apply_filters('sanitize_text_field', $filtered, $str);
}
開發者ID:zhoujiangyou,項目名稱:WordPress,代碼行數:43,代碼來源:formatting.php

示例4: sanitize_text_field

/**
 * Sanitize a string from user input or from the db
 *
 * check for invalid UTF-8,
 * Convert single < characters to entity,
 * strip all tags,
 * remove line breaks, tabs and extra whitre space,
 * strip octets.
 *
 * @since 2.9
 *
 * @param string $str
 * @return string
 */
function sanitize_text_field($str)
{
    $filtered = wp_check_invalid_utf8($str);
    if (strpos($filtered, '<') !== false) {
        $filtered = wp_pre_kses_less_than($filtered);
        $filtered = wp_strip_all_tags($filtered, true);
    } else {
        $filtered = trim(preg_replace('/\\s+/', ' ', $filtered));
    }
    $match = array();
    while (preg_match('/%[a-f0-9]{2}/i', $filtered, $match)) {
        $filtered = str_replace($match[0], '', $filtered);
    }
    return apply_filters('sanitize_text_field', $filtered, $str);
}
開發者ID:bluedanbob,項目名稱:wordpress,代碼行數:29,代碼來源:formatting.php

示例5: amt_metatag_highlighter

/**
 * Custom meta tag highlighter.
 *
 * Expects string.
 */
function amt_metatag_highlighter($metatags)
{
    // Convert special chars, but leave quotes.
    $metatags = htmlspecialchars($metatags, ENT_NOQUOTES);
    preg_match_all('#([^\\s]+="[^"]+?)"#i', $metatags, $matches);
    if (!$matches) {
        return $metatags;
    }
    //var_dump($matches[0]);
    foreach ($matches[0] as $match) {
        $highlighted = preg_replace('#^([^=]+)="(.+)"$#i', '<span style="font-weight:bold;color:black;">$1</span>="<span style="color:blue;">$2</span>"', $match);
        //var_dump($highlighted);
        $metatags = str_replace($match, $highlighted, $metatags);
    }
    // Highlight 'itemscope'
    $metatags = str_replace('itemscope', '<span style="font-weight: bold; color: #B90746;">itemscope</span>', $metatags);
    // Do some conversions
    $metatags = wp_pre_kses_less_than($metatags);
    // Done by wp_pre_kses_less_than()
    //$metatags = str_replace('<meta', '&lt;meta', $metatags);
    //$metatags = str_replace('/>', '/&gt;', $metatags);
    return $metatags;
}
開發者ID:RomualdKarbido,項目名稱:Zeroom,代碼行數:28,代碼來源:amt-utils.php

示例6: amt_metatag_highlighter

/**
 * Custom meta tag highlighter.
 *
 * Expects string.
 */
function amt_metatag_highlighter($metatags)
{
    // Convert special chars, but leave quotes.
    // Required for pre box.
    $metatags = htmlspecialchars($metatags, ENT_NOQUOTES);
    if (!apply_filters('amt_metadata_review_mode_enable_highlighter', true)) {
        return $metatags;
    }
    // Find all property/value pairs
    preg_match_all('#([^\\s]+="[^"]+?)"#i', $metatags, $matches);
    if (!$matches) {
        return $metatags;
    }
    // Highlight properties and values.
    //var_dump($matches[0]);
    foreach ($matches[0] as $match) {
        $highlighted = preg_replace('#^([^=]+)="(.+)"$#i', '<span class="amt-ht-attribute">$1</span>="<span class="amt-ht-value">$2</span>"', $match);
        //var_dump($highlighted);
        $metatags = str_replace($match, $highlighted, $metatags);
    }
    // Highlight 'itemscope'
    $metatags = str_replace('itemscope', '<span class="amt-ht-itemscope">itemscope</span>', $metatags);
    // Highlight Schema.org object
    //$metatags = preg_replace('#: ([a-zA-Z0-9]+) --&gt;#', ': <span class="amt-ht-important">$1</span> --&gt;', $metatags);
    // Highlight HTML comments
    $metatags = str_replace('&lt;!--', '<span class="amt-ht-comment">&lt;!--', $metatags);
    $metatags = str_replace('--&gt;', '--&gt;</span>', $metatags);
    // Do some conversions
    $metatags = wp_pre_kses_less_than($metatags);
    // Done by wp_pre_kses_less_than()
    //$metatags = str_replace('<meta', '&lt;meta', $metatags);
    //$metatags = str_replace('/>', '/&gt;', $metatags);
    //$metatags = str_replace('<br />', '___', $metatags);
    //$metatags = str_replace('___', '<br />', $metatags);
    return $metatags;
}
開發者ID:ashenkar,項目名稱:sanga,代碼行數:41,代碼來源:amt-utils.php

示例7: sanitize_permalink

 /**
  * Runs a simple sanitisation of the custom post type permalink structures
  * and adds an error if no post ID or post name present
  *
  * @param string $permalink The permalink structure
  *
  * @return string    Sanitised permalink structure
  */
 public function sanitize_permalink($permalink)
 {
     if (!empty($permalink) && !preg_match('/%(post_id|postname)%/', $permalink)) {
         add_settings_error('permalink_structure', 10, __('Permalink structures must contain at least the <code>%post_id%</code> or <code>%postname%</code>.'));
     }
     $filtered = wp_check_invalid_utf8($permalink);
     if (strpos($filtered, '<') !== false) {
         $filtered = wp_pre_kses_less_than($filtered);
         // This will strip extra whitespace for us.
         $filtered = wp_strip_all_tags($filtered, true);
     } else {
         $filtered = trim(preg_replace('/[\\r\\n\\t ]+/', ' ', $filtered));
     }
     return preg_replace('/[^a-zA-Z0-9\\/\\%_-]*/', '', $filtered);
 }
開發者ID:simonbbrown,項目名稱:wp-permastructure,代碼行數:23,代碼來源:wp-permastructure.php

示例8: _sanitize_text_fields

/**
 * Internal helper function to sanitize a string from user input or from the db
 *
 * @since 4.7.0
 * @access private
 *
 * @param string $str String to sanitize.
 * @param bool $keep_newlines optional Whether to keep newlines. Default: false.
 * @return string Sanitized string.
 */
function _sanitize_text_fields($str, $keep_newlines = false)
{
    $filtered = wp_check_invalid_utf8($str);
    if (strpos($filtered, '<') !== false) {
        $filtered = wp_pre_kses_less_than($filtered);
        // This will strip extra whitespace for us.
        $filtered = wp_strip_all_tags($filtered, false);
        // Use html entities in a special case to make sure no later
        // newline stripping stage could lead to a functional tag
        $filtered = str_replace("<\n", "&lt;\n", $filtered);
    }
    if (!$keep_newlines) {
        $filtered = preg_replace('/[\\r\\n\\t ]+/', ' ', $filtered);
    }
    $filtered = trim($filtered);
    $found = false;
    while (preg_match('/%[a-f0-9]{2}/i', $filtered, $match)) {
        $filtered = str_replace($match[0], '', $filtered);
        $found = true;
    }
    if ($found) {
        // Strip out the whitespace that may now exist after removing the octets.
        $filtered = trim(preg_replace('/ +/', ' ', $filtered));
    }
    return $filtered;
}
開發者ID:kucrut,項目名稱:wordpress,代碼行數:36,代碼來源:formatting.php

示例9: social_sanitize_text

 function social_sanitize_text($input)
 {
     $filtered = wp_check_invalid_utf8($input);
     if (strpos($filtered, '<') !== false) {
         $filtered = wp_pre_kses_less_than($filtered);
         // This will strip extra whitespace.
         $filtered = wp_strip_all_tags($filtered, true);
     } else {
         $filtered = trim(preg_replace('/[\\r\\n\\t ]+/', ' ', $filtered));
     }
     return wp_kses_post(force_balance_tags($input));
 }
開發者ID:OanaRaluca,項目名稱:Wordpress-theme-7,代碼行數:12,代碼來源:social-customizer.php


注:本文中的wp_pre_kses_less_than函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。