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


PHP wp_spaces_regexp函数代码示例

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


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

示例1: smilies_init_old

function smilies_init_old()
{
    global $wpsmiliestrans, $wp_smiliessearch;
    // don't bother setting up smilies if they are disabled
    if (!get_option('use_smilies')) {
        return;
    }
    if (!isset($wpsmiliestrans)) {
        $wpsmiliestrans = array(':mrgreen:' => 'icon_mrgreen.gif', ':neutral:' => 'icon_neutral.gif', ':twisted:' => 'icon_twisted.gif', ':arrow:' => 'icon_arrow.gif', ':shock:' => 'icon_eek.gif', ':smile:' => 'icon_smile.gif', ':???:' => 'icon_confused.gif', ':cool:' => 'icon_cool.gif', ':evil:' => 'icon_evil.gif', ':grin:' => 'icon_biggrin.gif', ':idea:' => 'icon_idea.gif', ':oops:' => 'icon_redface.gif', ':razz:' => 'icon_razz.gif', ':roll:' => 'icon_rolleyes.gif', ':wink:' => 'icon_wink.gif', ':cry:' => 'icon_cry.gif', ':eek:' => 'icon_surprised.gif', ':lol:' => 'icon_lol.gif', ':mad:' => 'icon_mad.gif', ':sad:' => 'icon_sad.gif', '8-)' => 'icon_cool.gif', '8-O' => 'icon_eek.gif', ':-(' => 'icon_sad.gif', ':-)' => 'icon_smile.gif', ':-?' => 'icon_confused.gif', ':-D' => 'icon_biggrin.gif', ':-P' => 'icon_razz.gif', ':-o' => 'icon_surprised.gif', ':-x' => 'icon_mad.gif', ':-|' => 'icon_neutral.gif', ';-)' => 'icon_wink.gif', '8O' => 'icon_eek.gif', ':(' => 'icon_sad.gif', ':)' => 'icon_smile.gif', ':?' => 'icon_confused.gif', ':D' => 'icon_biggrin.gif', ':P' => 'icon_razz.gif', ':o' => 'icon_surprised.gif', ':x' => 'icon_mad.gif', ':|' => 'icon_neutral.gif', ';)' => 'icon_wink.gif', ':!:' => 'icon_exclaim.gif', ':?:' => 'icon_question.gif');
    }
    if (count($wpsmiliestrans) == 0) {
        return;
    }
    /*
     * NOTE: we sort the smilies in reverse key order. This is to make sure
     * we match the longest possible smilie (:???: vs :?) as the regular
     * expression used below is first-match
     */
    krsort($wpsmiliestrans);
    $spaces = wp_spaces_regexp();
    // Begin first "subpattern"
    $wp_smiliessearch = '/(?<=' . $spaces . '|^)';
    $subchar = '';
    foreach ((array) $wpsmiliestrans as $smiley => $img) {
        $firstchar = substr($smiley, 0, 1);
        $rest = substr($smiley, 1);
        // new subpattern?
        if ($firstchar != $subchar) {
            if ($subchar != '') {
                $wp_smiliessearch .= ')(?=' . $spaces . '|$)';
                // End previous "subpattern"
                $wp_smiliessearch .= '|(?<=' . $spaces . '|^)';
                // Begin another "subpattern"
            }
            $subchar = $firstchar;
            $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
        } else {
            $wp_smiliessearch .= '|';
        }
        $wp_smiliessearch .= preg_quote($rest, '/');
    }
    $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
}
开发者ID:leshy-org,项目名称:leshy_JiaJia,代码行数:43,代码来源:patch.php

示例2: smilies_init

/**
 * Convert smiley code to the icon graphic file equivalent.
 *
 * You can turn off smilies, by going to the write setting screen and unchecking
 * the box, or by setting 'use_smilies' option to false or removing the option.
 *
 * Plugins may override the default smiley list by setting the $wpsmiliestrans
 * to an array, with the key the code the blogger types in and the value the
 * image file.
 *
 * The $wp_smiliessearch global is for the regular expression and is set each
 * time the function is called.
 *
 * The full list of smilies can be found in the function and won't be listed in
 * the description. Probably should create a Codex page for it, so that it is
 * available.
 *
 * @global array $wpsmiliestrans
 * @global array $wp_smiliessearch
 *
 * @since 2.2.0
 */
function smilies_init()
{
    global $wpsmiliestrans, $wp_smiliessearch;
    // don't bother setting up smilies if they are disabled
    if (!get_option('use_smilies')) {
        return;
    }
    if (!isset($wpsmiliestrans)) {
        $wpsmiliestrans = array(':mrgreen:' => 'mrgreen.png', ':neutral:' => "😐", ':twisted:' => "😈", ':arrow:' => "➡", ':shock:' => "😯", ':smile:' => 'simple-smile.png', ':???:' => "😕", ':cool:' => "😎", ':evil:' => "👿", ':grin:' => "😀", ':idea:' => "💡", ':oops:' => "😳", ':razz:' => "😛", ':roll:' => 'rolleyes.png', ':wink:' => "😉", ':cry:' => "😥", ':eek:' => "😮", ':lol:' => "😆", ':mad:' => "😡", ':sad:' => 'frownie.png', '8-)' => "😎", '8-O' => "😯", ':-(' => 'frownie.png', ':-)' => 'simple-smile.png', ':-?' => "😕", ':-D' => "😀", ':-P' => "😛", ':-o' => "😮", ':-x' => "😡", ':-|' => "😐", ';-)' => "😉", '8O' => "😯", ':(' => 'frownie.png', ':)' => 'simple-smile.png', ':?' => "😕", ':D' => "😀", ':P' => "😛", ':o' => "😮", ':x' => "😡", ':|' => "😐", ';)' => "😉", ':!:' => "❗", ':?:' => "❓");
    }
    if (count($wpsmiliestrans) == 0) {
        return;
    }
    /*
     * NOTE: we sort the smilies in reverse key order. This is to make sure
     * we match the longest possible smilie (:???: vs :?) as the regular
     * expression used below is first-match
     */
    krsort($wpsmiliestrans);
    $spaces = wp_spaces_regexp();
    // Begin first "subpattern"
    $wp_smiliessearch = '/(?<=' . $spaces . '|^)';
    $subchar = '';
    foreach ((array) $wpsmiliestrans as $smiley => $img) {
        $firstchar = substr($smiley, 0, 1);
        $rest = substr($smiley, 1);
        // new subpattern?
        if ($firstchar != $subchar) {
            if ($subchar != '') {
                $wp_smiliessearch .= ')(?=' . $spaces . '|$)';
                // End previous "subpattern"
                $wp_smiliessearch .= '|(?<=' . $spaces . '|^)';
                // Begin another "subpattern"
            }
            $subchar = $firstchar;
            $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
        } else {
            $wp_smiliessearch .= '|';
        }
        $wp_smiliessearch .= preg_quote($rest, '/');
    }
    $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
}
开发者ID:hpilevar,项目名称:WordPress,代码行数:65,代码来源:functions.php

示例3: shortcode_unautop

/**
 * Don't auto-p wrap shortcodes that stand alone
 *
 * Ensures that shortcodes are not wrapped in `<p>...</p>`.
 *
 * @since 2.9.0
 *
 * @global array $shortcode_tags
 *
 * @param string $pee The content.
 * @return string The filtered content.
 */
function shortcode_unautop($pee)
{
    global $shortcode_tags;
    if (empty($shortcode_tags) || !is_array($shortcode_tags)) {
        return $pee;
    }
    $tagregexp = join('|', array_map('preg_quote', array_keys($shortcode_tags)));
    $spaces = wp_spaces_regexp();
    $pattern = '/' . '<p>' . '(?:' . $spaces . ')*+' . '(' . '\\[' . "({$tagregexp})" . '(?![\\w-])' . '[^\\]\\/]*' . '(?:' . '\\/(?!\\])' . '[^\\]\\/]*' . ')*?' . '(?:' . '\\/\\]' . '|' . '\\]' . '(?:' . '[^\\[]*+' . '(?:' . '\\[(?!\\/\\2\\])' . '[^\\[]*+' . ')*+' . '\\[\\/\\2\\]' . ')?' . ')' . ')' . '(?:' . $spaces . ')*+' . '<\\/p>' . '/';
    return preg_replace($pattern, '$1', $pee);
}
开发者ID:zhoujiangyou,项目名称:WordPress,代码行数:23,代码来源:formatting.php

示例4: shortcode_unautop

/**
 * Don't auto-p wrap shortcodes that stand alone
 *
 * Ensures that shortcodes are not wrapped in `<p>...</p>`.
 *
 * @since 2.9.0
 *
 * @global array $shortcode_tags
 *
 * @param string $pee The content.
 * @return string The filtered content.
 */
function shortcode_unautop( $pee ) {
	global $shortcode_tags;

	if ( empty( $shortcode_tags ) || !is_array( $shortcode_tags ) ) {
		return $pee;
	}

	$tagregexp = join( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) );
	$spaces = wp_spaces_regexp();

	$pattern =
		  '/'
		. '<p>'                              // Opening paragraph
		. '(?:' . $spaces . ')*+'            // Optional leading whitespace
		. '('                                // 1: The shortcode
		.     '\\['                          // Opening bracket
		.     "($tagregexp)"                 // 2: Shortcode name
		.     '(?![\\w-])'                   // Not followed by word character or hyphen
		                                     // Unroll the loop: Inside the opening shortcode tag
		.     '[^\\]\\/]*'                   // Not a closing bracket or forward slash
		.     '(?:'
		.         '\\/(?!\\])'               // A forward slash not followed by a closing bracket
		.         '[^\\]\\/]*'               // Not a closing bracket or forward slash
		.     ')*?'
		.     '(?:'
		.         '\\/\\]'                   // Self closing tag and closing bracket
		.     '|'
		.         '\\]'                      // Closing bracket
		.         '(?:'                      // Unroll the loop: Optionally, anything between the opening and closing shortcode tags
		.             '[^\\[]*+'             // Not an opening bracket
		.             '(?:'
		.                 '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag
		.                 '[^\\[]*+'         // Not an opening bracket
		.             ')*+'
		.             '\\[\\/\\2\\]'         // Closing shortcode tag
		.         ')?'
		.     ')'
		. ')'
		. '(?:' . $spaces . ')*+'            // optional trailing whitespace
		. '<\\/p>'                           // closing paragraph
		. '/';

	return preg_replace( $pattern, '$1', $pee );
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:56,代码来源:formatting.php

示例5: smilies_init

/**
 * Convert smiley code to the icon graphic file equivalent.
 *
 * You can turn off smilies, by going to the write setting screen and unchecking
 * the box, or by setting 'use_smilies' option to false or removing the option.
 *
 * Plugins may override the default smiley list by setting the $wpsmiliestrans
 * to an array, with the key the code the blogger types in and the value the
 * image file.
 *
 * The $wp_smiliessearch global is for the regular expression and is set each
 * time the function is called.
 *
 * The full list of smilies can be found in the function and won't be listed in
 * the description. Probably should create a Codex page for it, so that it is
 * available.
 *
 * @global array $wpsmiliestrans
 * @global array $wp_smiliessearch
 *
 * @since 2.2.0
 */
function smilies_init() {
	global $wpsmiliestrans, $wp_smiliessearch;

	// don't bother setting up smilies if they are disabled
	if ( !get_option( 'use_smilies' ) )
		return;

	if ( !isset( $wpsmiliestrans ) ) {
		$wpsmiliestrans = array(
		':mrgreen:' => 'mrgreen.png',
		':neutral:' => "\xf0\x9f\x98\x90",
		':twisted:' => "\xf0\x9f\x98\x88",
		  ':arrow:' => "\xe2\x9e\xa1",
		  ':shock:' => "\xf0\x9f\x98\xaf",
		  ':smile:' => 'simple-smile.png',
		    ':???:' => "\xf0\x9f\x98\x95",
		   ':cool:' => "\xf0\x9f\x98\x8e",
		   ':evil:' => "\xf0\x9f\x91\xbf",
		   ':grin:' => "\xf0\x9f\x98\x80",
		   ':idea:' => "\xf0\x9f\x92\xa1",
		   ':oops:' => "\xf0\x9f\x98\xb3",
		   ':razz:' => "\xf0\x9f\x98\x9b",
		   ':roll:' => 'rolleyes.png',
		   ':wink:' => "\xf0\x9f\x98\x89",
		    ':cry:' => "\xf0\x9f\x98\xa5",
		    ':eek:' => "\xf0\x9f\x98\xae",
		    ':lol:' => "\xf0\x9f\x98\x86",
		    ':mad:' => "\xf0\x9f\x98\xa1",
		    ':sad:' => 'frownie.png',
		      '8-)' => "\xf0\x9f\x98\x8e",
		      '8-O' => "\xf0\x9f\x98\xaf",
		      ':-(' => 'frownie.png',
		      ':-)' => 'simple-smile.png',
		      ':-?' => "\xf0\x9f\x98\x95",
		      ':-D' => "\xf0\x9f\x98\x80",
		      ':-P' => "\xf0\x9f\x98\x9b",
		      ':-o' => "\xf0\x9f\x98\xae",
		      ':-x' => "\xf0\x9f\x98\xa1",
		      ':-|' => "\xf0\x9f\x98\x90",
		      ';-)' => "\xf0\x9f\x98\x89",
		// This one transformation breaks regular text with frequency.
		//     '8)' => "\xf0\x9f\x98\x8e",
		       '8O' => "\xf0\x9f\x98\xaf",
		       ':(' => 'frownie.png',
		       ':)' => 'simple-smile.png',
		       ':?' => "\xf0\x9f\x98\x95",
		       ':D' => "\xf0\x9f\x98\x80",
		       ':P' => "\xf0\x9f\x98\x9b",
		       ':o' => "\xf0\x9f\x98\xae",
		       ':x' => "\xf0\x9f\x98\xa1",
		       ':|' => "\xf0\x9f\x98\x90",
		       ';)' => "\xf0\x9f\x98\x89",
		      ':!:' => "\xe2\x9d\x97",
		      ':?:' => "\xe2\x9d\x93",
		);
	}

	if (count($wpsmiliestrans) == 0) {
		return;
	}

	/*
	 * NOTE: we sort the smilies in reverse key order. This is to make sure
	 * we match the longest possible smilie (:???: vs :?) as the regular
	 * expression used below is first-match
	 */
	krsort($wpsmiliestrans);

	$spaces = wp_spaces_regexp();

	// Begin first "subpattern"
	$wp_smiliessearch = '/(?<=' . $spaces . '|^)';

	$subchar = '';
	foreach ( (array) $wpsmiliestrans as $smiley => $img ) {
		$firstchar = substr($smiley, 0, 1);
		$rest = substr($smiley, 1);

//.........这里部分代码省略.........
开发者ID:nasrulhazim,项目名称:WordPress,代码行数:101,代码来源:functions.php

示例6: smilies_initx

function smilies_initx()
{
    global $wpsmiliestrans, $wp_smiliessearch;
    if (!get_option('use_smilies')) {
        return;
    }
    if (!isset($wpsmiliestrans)) {
        // TODO
    }
    if (count($wpsmiliestrans) == 0) {
        return;
    }
    krsort($wpsmiliestrans);
    $spaces = wp_spaces_regexp();
    $wp_smiliessearch = '/(?<=' . $spaces . '|^)';
    $subchar = '';
    foreach ((array) $wpsmiliestrans as $smiley => $img) {
        $firstchar = substr($smiley, 0, 1);
        $rest = substr($smiley, 1);
        if ($firstchar != $subchar) {
            if ($subchar != '') {
                $wp_smiliessearch .= ')(?=' . $spaces . '|$)';
                // End previous "subpattern"
                $wp_smiliessearch .= '|(?<=' . $spaces . '|^)';
                // Begin another "subpattern"
            }
            $subchar = $firstchar;
            $wp_smiliessearch .= preg_quote($firstchar, '/') . '(?:';
        } else {
            $wp_smiliessearch .= '|';
        }
        $wp_smiliessearch .= preg_quote($rest, '/');
    }
    $wp_smiliessearch .= ')(?=' . $spaces . '|$)/m';
}
开发者ID:cjhgithub,项目名称:ctheme,代码行数:35,代码来源:post_content.php


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