コード例 #1
0
ファイル: patch.php プロジェクト: leshy-org/leshy_JiaJia
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';
}
コード例 #2
0
ファイル: functions.php プロジェクト: hpilevar/WordPress
/**
 * 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';
}
コード例 #3
0
ファイル: formatting.php プロジェクト: zhoujiangyou/WordPress
/**
 * 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);
}
コード例 #4
0
/**
 * 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 );
}
コード例 #5
0
ファイル: functions.php プロジェクト: nasrulhazim/WordPress
/**
 * 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);

		// 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';

}
コード例 #6
0
ファイル: post_content.php プロジェクト: cjhgithub/ctheme
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';
}