IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+><?php\n/**\n * Main WordPress Formatting API.\n *\n * Handles many functions for formatting output.\n *\n * @package WordPress\n **/\n\n/**\n * Replaces common plain text characters into formatted entities\n *\n * As an example,\n * <code>\n * 'cause today's effort makes it worth tomorrow's \"holiday\"...\n * </code>\n * Becomes:\n * <code>\n * ’cause today’s effort makes it worth tomorrow’s “holiday”…\n * </code>\n * Code within certain html blocks are skipped.\n *\n * @since 0.71\n * @uses $wp_cockneyreplace Array of formatted entities for certain common phrases\n *\n * @param string $text The text to be formatted\n * @return string The string replaced with html entities\n */\nfunction wptexturize($text) {\n\tglobal $wp_cockneyreplace;\n\tstatic $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements,\n\t\t$default_no_texturize_tags, $default_no_texturize_shortcodes;\n\n\t// No need to set up these static variables more than once\n\tif ( ! isset( $static_characters ) ) {\n\t\t/* translators: opening curly double quote */\n\t\t$opening_quote = _x( '“', 'opening curly double quote' );\n\t\t/* translators: closing curly double quote */\n\t\t$closing_quote = _x( '”', 'closing curly double quote' );\n\n\t\t/* translators: apostrophe, for example in 'cause or can't */\n\t\t$apos = _x( '’', 'apostrophe' );\n\n\t\t/* translators: prime, for example in 9' (nine feet) */\n\t\t$prime = _x( '′', 'prime' );\n\t\t/* translators: double prime, for example in 9\" (nine inches) */\n\t\t$double_prime = _x( '″', 'double prime' );\n\n\t\t/* translators: opening curly single quote */\n\t\t$opening_single_quote = _x( '‘', 'opening curly single quote' );\n\t\t/* translators: closing curly single quote */\n\t\t$closing_single_quote = _x( '’', 'closing curly single quote' );\n\n\t\t/* translators: en dash */\n\t\t$en_dash = _x( '–', 'en dash' );\n\t\t/* translators: em dash */\n\t\t$em_dash = _x( '—', 'em dash' );\n\n\t\t$default_no_texturize_tags = array('pre', 'code', 'kbd', 'style', 'script', 'tt');\n\t\t$default_no_texturize_shortcodes = array('code');\n\n\t\t// if a plugin has provided an autocorrect array, use it\n\t\tif ( isset($wp_cockneyreplace) ) {\n\t\t\t$cockney = array_keys($wp_cockneyreplace);\n\t\t\t$cockneyreplace = array_values($wp_cockneyreplace);\n\t\t} elseif ( \"'\" != $apos ) { // Only bother if we're doing a replacement.\n\t\t\t$cockney = array( \"'tain't\", \"'twere\", \"'twas\", \"'tis\", \"'twill\", \"'til\", \"'bout\", \"'nuff\", \"'round\", \"'cause\" );\n\t\t\t$cockneyreplace = array( $apos . \"tain\" . $apos . \"t\", $apos . \"twere\", $apos . \"twas\", $apos . \"tis\", $apos . \"twill\", $apos . \"til\", $apos . \"bout\", $apos . \"nuff\", $apos . \"round\", $apos . \"cause\" );\n\t\t} else {\n\t\t\t$cockney = $cockneyreplace = array();\n\t\t}\n\n\t\t$static_characters = array_merge( array( '---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\\'\\'', ' (tm)' ), $cockney );\n\t\t$static_replacements = array_merge( array( $em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace );\n\n\t\t$dynamic = array();\n\t\tif ( \"'\" != $apos ) {\n\t\t\t$dynamic[ '/\\'(\\d\\d(?:’|\\')?s)/' ] = $apos . '$1'; // '99's\n\t\t\t$dynamic[ '/\\'(\\d)/' ] = $apos . '$1'; // '99\n\t\t}\n\t\tif ( \"'\" != $opening_single_quote )\n\t\t\t$dynamic[ '/(\\s|\\A|[([{<]|\")\\'/' ] = '$1' . $opening_single_quote; // opening single quote, even after (, {, <, [\n\t\tif ( '\"' != $double_prime )\n\t\t\t$dynamic[ '/(\\d)\"/' ] = '$1' . $double_prime; // 9\" (double prime)\n\t\tif ( \"'\" != $prime )\n\t\t\t$dynamic[ '/(\\d)\\'/' ] = '$1' . $prime; // 9' (prime)\n\t\tif ( \"'\" != $apos )\n\t\t\t$dynamic[ '/(\\S)\\'([^\\'\\s])/' ] = '$1' . $apos . '$2'; // apostrophe in a word\n\t\tif ( '\"' != $opening_quote )\n\t\t\t$dynamic[ '/(\\s|\\A|[([{<])\"(?!\\s)/' ] = '$1' . $opening_quote . '$2'; // opening double quote, even after (, {, <, [\n\t\tif ( '\"' != $closing_quote )\n\t\t\t$dynamic[ '/\"(\\s|\\S|\\Z)/' ] = $closing_quote . '$1'; // closing double quote\n\t\tif ( \"'\" != $closing_single_quote )\n\t\t\t$dynamic[ '/\\'([\\s.]|\\Z)/' ] = $closing_single_quote . '$1'; // closing single quote\n\n\t\t$dynamic[ '/\\b(\\d+)x(\\d+)\\b/' ] = '$1×$2'; // 9x9 (times)\n\n\t\t$dynamic_characters = array_keys( $dynamic );\n\t\t$dynamic_replacements = array_values( $dynamic );\n\t}\n\n\t// Transform into regexp sub-expression used in _wptexturize_pushpop_element\n\t// Must do this every time in case plugins use these filters in a context sensitive manner\n\t$no_texturize_tags = '(' . implode('|', apply_filters('no_texturize_tags', $default_no_texturize_tags) ) . ')';\n\t$no_texturize_shortcodes = '(' . implode('|', apply_filters('no_texturize_shortcodes', $default_no_texturize_shortcodes) ) . ')';\n\n\t$no_texturize_tags_stack = array();\n\t$no_texturize_shortcodes_stack = array();\n\n\t$textarr = preg_split('/(<.*>|\\[.*\\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE);\n\n\tforeach ( $textarr as &$curl ) {\n\t\tif ( empty( $curl ) )\n\t\t\tcontinue;\n\n\t\t// Only call _wptexturize_pushpop_element if first char is correct tag opening\n\t\t$first = $curl[0];\n\t\tif ( '<' === $first ) {\n\t\t\t_wptexturize_pushpop_element($curl, $no_texturize_tags_stack, $no_texturize_tags, '<', '>');\n\t\t} elseif ( '[' === $first ) {\n\t\t\t_wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes, '[', ']');\n\t\t} elseif ( empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack) ) {\n\t\t\t// This is not a tag, nor is the texturization disabled static strings\n\t\t\t$curl = str_replace($static_characters, $static_replacements, $curl);\n\t\t\t// regular expressions\n\t\t\t$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);\n\t\t}\n\t\t$curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&$1', $curl);\n\t}\n\treturn implode( '', $textarr );\n}\n\n/**\n * Search for disabled element tags. Push element to stack on tag open and pop\n * on tag close. Assumes first character of $text is tag opening.\n *\n * @access private\n * @since 2.9.0\n *\n * @param string $text Text to check. First character is assumed to be $opening\n * @param array $stack Array used as stack of opened tag elements\n * @param string $disabled_elements Tags to match against formatted as regexp sub-expression\n * @param string $opening Tag opening character, assumed to be 1 character long\n * @param string $closing Tag closing character\n */\nfunction _wptexturize_pushpop_element($text, &$stack, $disabled_elements, $opening = '<', $closing = '>') {\n\t// Check if it is a closing tag -- otherwise assume opening tag\n\tif (strncmp($opening . '/', $text, 2)) {\n\t\t// Opening? Check $text+1 against disabled elements\n\t\tif (preg_match('/^' . $disabled_elements . '\\b/', substr($text, 1), $matches)) {\n\t\t\t/*\n\t\t\t * This disables texturize until we find a closing tag of our type\n\t\t\t * (e.g. <pre>) even if there was invalid nesting before that\n\t\t\t *\n\t\t\t * Example: in the case <pre>sadsadasd</code>\"baba\"</pre>\n\t\t\t * \"baba\" won't be texturize\n\t\t\t */\n\n\t\t\tarray_push($stack, $matches[1]);\n\t\t}\n\t} else {\n\t\t// Closing? Check $text+2 against disabled elements\n\t\t$c = preg_quote($closing, '/');\n\t\tif (preg_match('/^' . $disabled_elements . $c . '/', substr($text, 2), $matches)) {\n\t\t\t$last = array_pop($stack);\n\n\t\t\t// Make sure it matches the opening tag\n\t\t\tif ($last != $matches[1])\n\t\t\t\tarray_push($stack, $last);\n\t\t}\n\t}\n}\n\n/**\n * Replaces double line-breaks with paragraph elements.\n *\n * A group of regex replaces used to identify text formatted with newlines and\n * replace double line-breaks with HTML paragraph tags. The remaining\n * line-breaks after conversion become <<br />> tags, unless $br is set to '0'\n * or 'false'.\n *\n * @since 0.71\n *\n * @param string $pee The text which has to be formatted.\n * @param bool $br Optional. If set, this will convert all remaining line-breaks after paragraphing. Default true.\n * @return string Text which has been converted into correct paragraph tags.\n */\nfunction wpautop($pee, $br = true) {\n\t$pre_tags = array();\n\n\tif ( trim($pee) === '' )\n\t\treturn '';\n\n\t$pee = $pee . \"\\n\"; // just to make things a little easier, pad the end\n\n\tif ( strpos($pee, '<pre') !== false ) {\n\t\t$pee_parts = explode( '</pre>', $pee );\n\t\t$last_pee = array_pop($pee_parts);\n\t\t$pee = '';\n\t\t$i = 0;\n\n\t\tforeach ( $pee_parts as $pee_part ) {\n\t\t\t$start = strpos($pee_part, '<pre');\n\n\t\t\t// Malformed html?\n\t\t\tif ( $start === false ) {\n\t\t\t\t$pee .= $pee_part;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t$name = \"<pre wp-pre-tag-$i></pre>\";\n\t\t\t$pre_tags[$name] = substr( $pee_part, $start ) . '</pre>';\n\n\t\t\t$pee .= substr( $pee_part, 0, $start ) . $name;\n\t\t\t$i++;\n\t\t}\n\n\t\t$pee .= $last_pee;\n\t}\n\n\t$pee = preg_replace('|<br />\\s*<br />|', \"\\n\\n\", $pee);\n\t// Space things out a little\n\t$allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|noscript|samp|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';\n\t$pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', \"\\n$1\", $pee);\n\t$pee = preg_replace('!(</' . $allblocks . '>)!', \"$1\\n\\n\", $pee);\n\t$pee = str_replace(array(\"\\r\\n\", \"\\r\"), \"\\n\", $pee); // cross-platform newlines\n\tif ( strpos($pee, '<object') !== false ) {\n\t\t$pee = preg_replace('|\\s*<param([^>]*)>\\s*|', \"<param$1>\", $pee); // no pee inside object/embed\n\t\t$pee = preg_replace('|\\s*</embed>\\s*|', '</embed>', $pee);\n\t}\n\t$pee = preg_replace(\"/\\n\\n+/\", \"\\n\\n\", $pee); // take care of duplicates\n\t// make paragraphs, including one at the end\n\t$pees = preg_split('/\\n\\s*\\n/', $pee, -1, PREG_SPLIT_NO_EMPTY);\n\t$pee = '';\n\tforeach ( $pees as $tinkle )\n\t\t$pee .= '<p>' . trim($tinkle, \"\\n\") . \"</p>\\n\";\n\t$pee = preg_replace('|<p>\\s*</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace\n\t$pee = preg_replace('!<p>([^<]+)</(div|address|form)>!', \"<p>$1</p></$2>\", $pee);\n\t$pee = preg_replace('!<p>\\s*(</?' . $allblocks . '[^>]*>)\\s*</p>!', \"$1\", $pee); // don't pee all over a tag\n\t$pee = preg_replace(\"|<p>(<li.+?)</p>|\", \"$1\", $pee); // problem with nested lists\n\t$pee = preg_replace('|<p><blockquote([^>]*)>|i', \"<blockquote$1><p>\", $pee);\n\t$pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);\n\t$pee = preg_replace('!<p>\\s*(</?' . $allblocks . '[^>]*>)!', \"$1\", $pee);\n\t$pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\\s*</p>!', \"$1\", $pee);\n\tif ( $br ) {\n\t\t$pee = preg_replace_callback('/<(script|style).*?<\\/\\\\1>/s', '_autop_newline_preservation_helper', $pee);\n\t\t$pee = preg_replace('|(?<!<br />)\\s*\\n|', \"<br />\\n\", $pee); // optionally make line breaks\n\t\t$pee = str_replace('<WPPreserveNewline />', \"\\n\", $pee);\n\t}\n\t$pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\\s*<br />!', \"$1\", $pee);\n\t$pee = preg_replace('!<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);\n\t$pee = preg_replace( \"|\\n</p>$|\", '</p>', $pee );\n\n\tif ( !empty($pre_tags) )\n\t\t$pee = str_replace(array_keys($pre_tags), array_values($pre_tags), $pee);\n\n\treturn $pee;\n}\n\n/**\n * Newline preservation help function for wpautop\n *\n * @since 3.1.0\n * @access private\n * @param array $matches preg_replace_callback matches array\n * @return string\n */\nfunction _autop_newline_preservation_helper( $matches ) {\n\treturn str_replace(\"\\n\", \"<WPPreserveNewline />\", $matches[0]);\n}\n\n/**\n * Don't auto-p wrap shortcodes that stand alone\n *\n * Ensures that shortcodes are not wrapped in <<p>>...<</p>>.\n *\n * @since 2.9.0\n *\n * @param string $pee The content.\n * @return string The filtered content.\n */\nfunction shortcode_unautop( $pee ) {\n\tglobal $shortcode_tags;\n\n\tif ( empty( $shortcode_tags ) || !is_array( $shortcode_tags ) ) {\n\t\treturn $pee;\n\t}\n\n\t$tagregexp = join( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) );\n\n\t$pattern =\n\t\t '/'\n\t\t. '<p>' // Opening paragraph\n\t\t. '\\\\s*+' // Optional leading whitespace\n\t\t. '(' // 1: The shortcode\n\t\t. '\\\\[' // Opening bracket\n\t\t. \"($tagregexp)\" // 2: Shortcode name\n\t\t. '(?![\\\\w-])' // Not followed by word character or hyphen\n\t\t // Unroll the loop: Inside the opening shortcode tag\n\t\t. '[^\\\\]\\\\/]*' // Not a closing bracket or forward slash\n\t\t. '(?:'\n\t\t. '\\\\/(?!\\\\])' // A forward slash not followed by a closing bracket\n\t\t. '[^\\\\]\\\\/]*' // Not a closing bracket or forward slash\n\t\t. ')*?'\n\t\t. '(?:'\n\t\t. '\\\\/\\\\]' // Self closing tag and closing bracket\n\t\t. '|'\n\t\t. '\\\\]' // Closing bracket\n\t\t. '(?:' // Unroll the loop: Optionally, anything between the opening and closing shortcode tags\n\t\t. '[^\\\\[]*+' // Not an opening bracket\n\t\t. '(?:'\n\t\t. '\\\\[(?!\\\\/\\\\2\\\\])' // An opening bracket not followed by the closing shortcode tag\n\t\t. '[^\\\\[]*+' // Not an opening bracket\n\t\t. ')*+'\n\t\t. '\\\\[\\\\/\\\\2\\\\]' // Closing shortcode tag\n\t\t. ')?'\n\t\t. ')'\n\t\t. ')'\n\t\t. '\\\\s*+' // optional trailing whitespace\n\t\t. '<\\\\/p>' // closing paragraph\n\t\t. '/s';\n\n\treturn preg_replace( $pattern, '$1', $pee );\n}\n\n/**\n * Checks to see if a string is utf8 encoded.\n *\n * NOTE: This function checks for 5-Byte sequences, UTF8\n * has Bytes Sequences with a maximum length of 4.\n *\n * @author bmorel at ssi dot fr (modified)\n * @since 1.2.1\n *\n * @param string $str The string to be checked\n * @return bool True if $str fits a UTF-8 model, false otherwise.\n */\nfunction seems_utf8($str) {\n\t$length = strlen($str);\n\tfor ($i=0; $i < $length; $i++) {\n\t\t$c = ord($str[$i]);\n\t\tif ($c < 0x80) $n = 0; # 0bbbbbbb\n\t\telseif (($c & 0xE0) == 0xC0) $n=1; # 110bbbbb\n\t\telseif (($c & 0xF0) == 0xE0) $n=2; # 1110bbbb\n\t\telseif (($c & 0xF8) == 0xF0) $n=3; # 11110bbb\n\t\telseif (($c & 0xFC) == 0xF8) $n=4; # 111110bb\n\t\telseif (($c & 0xFE) == 0xFC) $n=5; # 1111110b\n\t\telse return false; # Does not match any model\n\t\tfor ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?\n\t\t\tif ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80))\n\t\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Converts a number of special characters into their HTML entities.\n *\n * Specifically deals with: &, <, >, \", and '.\n *\n * $quote_style can be set to ENT_COMPAT to encode \" to\n * ", or ENT_QUOTES to do both. Default is ENT_NOQUOTES where no quotes are encoded.\n *\n * @since 1.2.2\n *\n * @param string $string The text which is to be encoded.\n * @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.\n * @param string $charset Optional. The character encoding of the string. Default is false.\n * @param boolean $double_encode Optional. Whether to encode existing html entities. Default is false.\n * @return string The encoded text with HTML entities.\n */\nfunction _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) {\n\t$string = (string) $string;\n\n\tif ( 0 === strlen( $string ) )\n\t\treturn '';\n\n\t// Don't bother if there are no specialchars - saves some processing\n\tif ( ! preg_match( '/[&<>\"\\']/', $string ) )\n\t\treturn $string;\n\n\t// Account for the previous behaviour of the function when the $quote_style is not an accepted value\n\tif ( empty( $quote_style ) )\n\t\t$quote_style = ENT_NOQUOTES;\n\telseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) )\n\t\t$quote_style = ENT_QUOTES;\n\n\t// Store the site charset as a static to avoid multiple calls to wp_load_alloptions()\n\tif ( ! $charset ) {\n\t\tstatic $_charset;\n\t\tif ( ! isset( $_charset ) ) {\n\t\t\t$alloptions = wp_load_alloptions();\n\t\t\t$_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : '';\n\t\t}\n\t\t$charset = $_charset;\n\t}\n\n\tif ( in_array( $charset, array( 'utf8', 'utf-8', 'UTF8' ) ) )\n\t\t$charset = 'UTF-8';\n\n\t$_quote_style = $quote_style;\n\n\tif ( $quote_style === 'double' ) {\n\t\t$quote_style = ENT_COMPAT;\n\t\t$_quote_style = ENT_COMPAT;\n\t} elseif ( $quote_style === 'single' ) {\n\t\t$quote_style = ENT_NOQUOTES;\n\t}\n\n\t// Handle double encoding ourselves\n\tif ( $double_encode ) {\n\t\t$string = @htmlspecialchars( $string, $quote_style, $charset );\n\t} else {\n\t\t// Decode & into &\n\t\t$string = wp_specialchars_decode( $string, $_quote_style );\n\n\t\t// Guarantee every &entity; is valid or re-encode the &\n\t\t$string = wp_kses_normalize_entities( $string );\n\n\t\t// Now re-encode everything except &entity;\n\t\t$string = preg_split( '/(&#?x?[0-9a-z]+;)/i', $string, -1, PREG_SPLIT_DELIM_CAPTURE );\n\n\t\tfor ( $i = 0; $i < count( $string ); $i += 2 )\n\t\t\t$string[$i] = @htmlspecialchars( $string[$i], $quote_style, $charset );\n\n\t\t$string = implode( '', $string );\n\t}\n\n\t// Backwards compatibility\n\tif ( 'single' === $_quote_style )\n\t\t$string = str_replace( \"'\", ''', $string );\n\n\treturn $string;\n}\n\n/**\n * Converts a number of HTML entities into their special characters.\n *\n * Specifically deals with: &, <, >, \", and '.\n *\n * $quote_style can be set to ENT_COMPAT to decode \" entities,\n * or ENT_QUOTES to do both \" and '. Default is ENT_NOQUOTES where no quotes are decoded.\n *\n * @since 2.8\n *\n * @param string $string The text which is to be decoded.\n * @param mixed $quote_style Optional. Converts double quotes if set to ENT_COMPAT, both single and double if set to ENT_QUOTES or none if set to ENT_NOQUOTES. Also compatible with old _wp_specialchars() values; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES.\n * @return string The decoded text without HTML entities.\n */\nfunction wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) {\n\t$string = (string) $string;\n\n\tif ( 0 === strlen( $string ) ) {\n\t\treturn '';\n\t}\n\n\t// Don't bother if there are no entities - saves a lot of processing\n\tif ( strpos( $string, '&' ) === false ) {\n\t\treturn $string;\n\t}\n\n\t// Match the previous behaviour of _wp_specialchars() when the $quote_style is not an accepted value\n\tif ( empty( $quote_style ) ) {\n\t\t$quote_style = ENT_NOQUOTES;\n\t} elseif ( !in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) {\n\t\t$quote_style = ENT_QUOTES;\n\t}\n\n\t// More complete than get_html_translation_table( HTML_SPECIALCHARS )\n\t$single = array( ''' => '\\'', ''' => '\\'' );\n\t$single_preg = array( '/�*39;/' => ''', '/�*27;/i' => ''' );\n\t$double = array( '"' => '\"', '"' => '\"', '"' => '\"' );\n\t$double_preg = array( '/�*34;/' => '"', '/�*22;/i' => '"' );\n\t$others = array( '<' => '<', '<' => '<', '>' => '>', '>' => '>', '&' => '&', '&' => '&', '&' => '&' );\n\t$others_preg = array( '/�*60;/' => '<', '/�*62;/' => '>', '/�*38;/' => '&', '/�*26;/i' => '&' );\n\n\tif ( $quote_style === ENT_QUOTES ) {\n\t\t$translation = array_merge( $single, $double, $others );\n\t\t$translation_preg = array_merge( $single_preg, $double_preg, $others_preg );\n\t} elseif ( $quote_style === ENT_COMPAT || $quote_style === 'double' ) {\n\t\t$translation = array_merge( $double, $others );\n\t\t$translation_preg = array_merge( $double_preg, $others_preg );\n\t} elseif ( $quote_style === 'single' ) {\n\t\t$translation = array_merge( $single, $others );\n\t\t$translation_preg = array_merge( $single_preg, $others_preg );\n\t} elseif ( $quote_style === ENT_NOQUOTES ) {\n\t\t$translation = $others;\n\t\t$translation_preg = $others_preg;\n\t}\n\n\t// Remove zero padding on numeric entities\n\t$string = preg_replace( array_keys( $translation_preg ), array_values( $translation_preg ), $string );\n\n\t// Replace characters according to translation table\n\treturn strtr( $string, $translation );\n}\n\n/**\n * Checks for invalid UTF8 in a string.\n *\n * @since 2.8\n *\n * @param string $string The text which is to be checked.\n * @param boolean $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false.\n * @return string The checked text.\n */\nfunction wp_check_invalid_utf8( $string, $strip = false ) {\n\t$string = (string) $string;\n\n\tif ( 0 === strlen( $string ) ) {\n\t\treturn '';\n\t}\n\n\t// Store the site charset as a static to avoid multiple calls to get_option()\n\tstatic $is_utf8;\n\tif ( !isset( $is_utf8 ) ) {\n\t\t$is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) );\n\t}\n\tif ( !$is_utf8 ) {\n\t\treturn $string;\n\t}\n\n\t// Check for support for utf8 in the installed PCRE library once and store the result in a static\n\tstatic $utf8_pcre;\n\tif ( !isset( $utf8_pcre ) ) {\n\t\t$utf8_pcre = @preg_match( '/^./u', 'a' );\n\t}\n\t// We can't demand utf8 in the PCRE installation, so just return the string in those cases\n\tif ( !$utf8_pcre ) {\n\t\treturn $string;\n\t}\n\n\t// preg_match fails when it encounters invalid UTF8 in $string\n\tif ( 1 === @preg_match( '/^./us', $string ) ) {\n\t\treturn $string;\n\t}\n\n\t// Attempt to strip the bad chars if requested (not recommended)\n\tif ( $strip && function_exists( 'iconv' ) ) {\n\t\treturn iconv( 'utf-8', 'utf-8', $string );\n\t}\n\n\treturn '';\n}\n\n/**\n * Encode the Unicode values to be used in the URI.\n *\n * @since 1.5.0\n *\n * @param string $utf8_string\n * @param int $length Max length of the string\n * @return string String with Unicode encoded for URI.\n */\nfunction utf8_uri_encode( $utf8_string, $length = 0 ) {\n\t$unicode = '';\n\t$values = array();\n\t$num_octets = 1;\n\t$unicode_length = 0;\n\n\t$string_length = strlen( $utf8_string );\n\tfor ($i = 0; $i < $string_length; $i++ ) {\n\n\t\t$value = ord( $utf8_string[ $i ] );\n\n\t\tif ( $value < 128 ) {\n\t\t\tif ( $length && ( $unicode_length >= $length ) )\n\t\t\t\tbreak;\n\t\t\t$unicode .= chr($value);\n\t\t\t$unicode_length++;\n\t\t} else {\n\t\t\tif ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;\n\n\t\t\t$values[] = $value;\n\n\t\t\tif ( $length && ( $unicode_length + ($num_octets * 3) ) > $length )\n\t\t\t\tbreak;\n\t\t\tif ( count( $values ) == $num_octets ) {\n\t\t\t\tif ($num_octets == 3) {\n\t\t\t\t\t$unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]);\n\t\t\t\t\t$unicode_length += 9;\n\t\t\t\t} else {\n\t\t\t\t\t$unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]);\n\t\t\t\t\t$unicode_length += 6;\n\t\t\t\t}\n\n\t\t\t\t$values = array();\n\t\t\t\t$num_octets = 1;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn $unicode;\n}\n\n/**\n * Converts all accent characters to ASCII characters.\n *\n * If there are no accent characters, then the string given is just returned.\n *\n * @since 1.2.1\n *\n * @param string $string Text that might have accent characters\n * @return string Filtered string with replaced \"nice\" characters.\n */\nfunction remove_accents($string) {\n\tif ( !preg_match('/[\\x80-\\xff]/', $string) )\n\t\treturn $string;\n\n\tif (seems_utf8($string)) {\n\t\t$chars = array(\n\t\t// Decompositions for Latin-1 Supplement\n\t\tchr(194).chr(170) => 'a', chr(194).chr(186) => 'o',\n\t\tchr(195).chr(128) => 'A', chr(195).chr(129) => 'A',\n\t\tchr(195).chr(130) => 'A', chr(195).chr(131) => 'A',\n\t\tchr(195).chr(132) => 'A', chr(195).chr(133) => 'A',\n\t\tchr(195).chr(134) => 'AE',chr(195).chr(135) => 'C',\n\t\tchr(195).chr(136) => 'E', chr(195).chr(137) => 'E',\n\t\tchr(195).chr(138) => 'E', chr(195).chr(139) => 'E',\n\t\tchr(195).chr(140) => 'I', chr(195).chr(141) => 'I',\n\t\tchr(195).chr(142) => 'I', chr(195).chr(143) => 'I',\n\t\tchr(195).chr(144) => 'D', chr(195).chr(145) => 'N',\n\t\tchr(195).chr(146) => 'O', chr(195).chr(147) => 'O',\n\t\tchr(195).chr(148) => 'O', chr(195).chr(149) => 'O',\n\t\tchr(195).chr(150) => 'O', chr(195).chr(153) => 'U',\n\t\tchr(195).chr(154) => 'U', chr(195).chr(155) => 'U',\n\t\tchr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',\n\t\tchr(195).chr(158) => 'TH',chr(195).chr(159) => 's',\n\t\tchr(195).chr(160) => 'a', chr(195).chr(161) => 'a',\n\t\tchr(195).chr(162) => 'a', chr(195).chr(163) => 'a',\n\t\tchr(195).chr(164) => 'a', chr(195).chr(165) => 'a',\n\t\tchr(195).chr(166) => 'ae',chr(195).chr(167) => 'c',\n\t\tchr(195).chr(168) => 'e', chr(195).chr(169) => 'e',\n\t\tchr(195).chr(170) => 'e', chr(195).chr(171) => 'e',\n\t\tchr(195).chr(172) => 'i', chr(195).chr(173) => 'i',\n\t\tchr(195).chr(174) => 'i', chr(195).chr(175) => 'i',\n\t\tchr(195).chr(176) => 'd', chr(195).chr(177) => 'n',\n\t\tchr(195).chr(178) => 'o', chr(195).chr(179) => 'o',\n\t\tchr(195).chr(180) => 'o', chr(195).chr(181) => 'o',\n\t\tchr(195).chr(182) => 'o', chr(195).chr(184) => 'o',\n\t\tchr(195).chr(185) => 'u', chr(195).chr(186) => 'u',\n\t\tchr(195).chr(187) => 'u', chr(195).chr(188) => 'u',\n\t\tchr(195).chr(189) => 'y', chr(195).chr(190) => 'th',\n\t\tchr(195).chr(191) => 'y', chr(195).chr(152) => 'O',\n\t\t// Decompositions for Latin Extended-A\n\t\tchr(196).chr(128) => 'A', chr(196).chr(129) => 'a',\n\t\tchr(196).chr(130) => 'A', chr(196).chr(131) => 'a',\n\t\tchr(196).chr(132) => 'A', chr(196).chr(133) => 'a',\n\t\tchr(196).chr(134) => 'C', chr(196).chr(135) => 'c',\n\t\tchr(196).chr(136) => 'C', chr(196).chr(137) => 'c',\n\t\tchr(196).chr(138) => 'C', chr(196).chr(139) => 'c',\n\t\tchr(196).chr(140) => 'C', chr(196).chr(141) => 'c',\n\t\tchr(196).chr(142) => 'D', chr(196).chr(143) => 'd',\n\t\tchr(196).chr(144) => 'D', chr(196).chr(145) => 'd',\n\t\tchr(196).chr(146) => 'E', chr(196).chr(147) => 'e',\n\t\tchr(196).chr(148) => 'E', chr(196).chr(149) => 'e',\n\t\tchr(196).chr(150) => 'E', chr(196).chr(151) => 'e',\n\t\tchr(196).chr(152) => 'E', chr(196).chr(153) => 'e',\n\t\tchr(196).chr(154) => 'E', chr(196).chr(155) => 'e',\n\t\tchr(196).chr(156) => 'G', chr(196).chr(157) => 'g',\n\t\tchr(196).chr(158) => 'G', chr(196).chr(159) => 'g',\n\t\tchr(196).chr(160) => 'G', chr(196).chr(161) => 'g',\n\t\tchr(196).chr(162) => 'G', chr(196).chr(163) => 'g',\n\t\tchr(196).chr(164) => 'H', chr(196).chr(165) => 'h',\n\t\tchr(196).chr(166) => 'H', chr(196).chr(167) => 'h',\n\t\tchr(196).chr(168) => 'I', chr(196).chr(169) => 'i',\n\t\tchr(196).chr(170) => 'I', chr(196).chr(171) => 'i',\n\t\tchr(196).chr(172) => 'I', chr(196).chr(173) => 'i',\n\t\tchr(196).chr(174) => 'I', chr(196).chr(175) => 'i',\n\t\tchr(196).chr(176) => 'I', chr(196).chr(177) => 'i',\n\t\tchr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',\n\t\tchr(196).chr(180) => 'J', chr(196).chr(181) => 'j',\n\t\tchr(196).chr(182) => 'K', chr(196).chr(183) => 'k',\n\t\tchr(196).chr(184) => 'k', chr(196).chr(185) => 'L',\n\t\tchr(196).chr(186) => 'l', chr(196).chr(187) => 'L',\n\t\tchr(196).chr(188) => 'l', chr(196).chr(189) => 'L',\n\t\tchr(196).chr(190) => 'l', chr(196).chr(191) => 'L',\n\t\tchr(197).chr(128) => 'l', chr(197).chr(129) => 'L',\n\t\tchr(197).chr(130) => 'l', chr(197).chr(131) => 'N',\n\t\tchr(197).chr(132) => 'n', chr(197).chr(133) => 'N',\n\t\tchr(197).chr(134) => 'n', chr(197).chr(135) => 'N',\n\t\tchr(197).chr(136) => 'n', chr(197).chr(137) => 'N',\n\t\tchr(197).chr(138) => 'n', chr(197).chr(139) => 'N',\n\t\tchr(197).chr(140) => 'O', chr(197).chr(141) => 'o',\n\t\tchr(197).chr(142) => 'O', chr(197).chr(143) => 'o',\n\t\tchr(197).chr(144) => 'O', chr(197).chr(145) => 'o',\n\t\tchr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',\n\t\tchr(197).chr(148) => 'R',chr(197).chr(149) => 'r',\n\t\tchr(197).chr(150) => 'R',chr(197).chr(151) => 'r',\n\t\tchr(197).chr(152) => 'R',chr(197).chr(153) => 'r',\n\t\tchr(197).chr(154) => 'S',chr(197).chr(155) => 's',\n\t\tchr(197).chr(156) => 'S',chr(197).chr(157) => 's',\n\t\tchr(197).chr(158) => 'S',chr(197).chr(159) => 's',\n\t\tchr(197).chr(160) => 'S', chr(197).chr(161) => 's',\n\t\tchr(197).chr(162) => 'T', chr(197).chr(163) => 't',\n\t\tchr(197).chr(164) => 'T', chr(197).chr(165) => 't',\n\t\tchr(197).chr(166) => 'T', chr(197).chr(167) => 't',\n\t\tchr(197).chr(168) => 'U', chr(197).chr(169) => 'u',\n\t\tchr(197).chr(170) => 'U', chr(197).chr(171) => 'u',\n\t\tchr(197).chr(172) => 'U', chr(197).chr(173) => 'u',\n\t\tchr(197).chr(174) => 'U', chr(197).chr(175) => 'u',\n\t\tchr(197).chr(176) => 'U', chr(197).chr(177) => 'u',\n\t\tchr(197).chr(178) => 'U', chr(197).chr(179) => 'u',\n\t\tchr(197).chr(180) => 'W', chr(197).chr(181) => 'w',\n\t\tchr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',\n\t\tchr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',\n\t\tchr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',\n\t\tchr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',\n\t\tchr(197).chr(190) => 'z', chr(197).chr(191) => 's',\n\t\t// Decompositions for Latin Extended-B\n\t\tchr(200).chr(152) => 'S', chr(200).chr(153) => 's',\n\t\tchr(200).chr(154) => 'T', chr(200).chr(155) => 't',\n\t\t// Euro Sign\n\t\tchr(226).chr(130).chr(172) => 'E',\n\t\t// GBP (Pound) Sign\n\t\tchr(194).chr(163) => '',\n\t\t// Vowels with diacritic (Vietnamese)\n\t\t// unmarked\n\t\tchr(198).chr(160) => 'O', chr(198).chr(161) => 'o',\n\t\tchr(198).chr(175) => 'U', chr(198).chr(176) => 'u',\n\t\t// grave accent\n\t\tchr(225).chr(186).chr(166) => 'A', chr(225).chr(186).chr(167) => 'a',\n\t\tchr(225).chr(186).chr(176) => 'A', chr(225).chr(186).chr(177) => 'a',\n\t\tchr(225).chr(187).chr(128) => 'E', chr(225).chr(187).chr(129) => 'e',\n\t\tchr(225).chr(187).chr(146) => 'O', chr(225).chr(187).chr(147) => 'o',\n\t\tchr(225).chr(187).chr(156) => 'O', chr(225).chr(187).chr(157) => 'o',\n\t\tchr(225).chr(187).chr(170) => 'U', chr(225).chr(187).chr(171) => 'u',\n\t\tchr(225).chr(187).chr(178) => 'Y', chr(225).chr(187).chr(179) => 'y',\n\t\t// hook\n\t\tchr(225).chr(186).chr(162) => 'A', chr(225).chr(186).chr(163) => 'a',\n\t\tchr(225).chr(186).chr(168) => 'A', chr(225).chr(186).chr(169) => 'a',\n\t\tchr(225).chr(186).chr(178) => 'A', chr(225).chr(186).chr(179) => 'a',\n\t\tchr(225).chr(186).chr(186) => 'E', chr(225).chr(186).chr(187) => 'e',\n\t\tchr(225).chr(187).chr(130) => 'E', chr(225).chr(187).chr(131) => 'e',\n\t\tchr(225).chr(187).chr(136) => 'I', chr(225).chr(187).chr(137) => 'i',\n\t\tchr(225).chr(187).chr(142) => 'O', chr(225).chr(187).chr(143) => 'o',\n\t\tchr(225).chr(187).chr(148) => 'O', chr(225).chr(187).chr(149) => 'o',\n\t\tchr(225).chr(187).chr(158) => 'O', chr(225).chr(187).chr(159) => 'o',\n\t\tchr(225).chr(187).chr(166) => 'U', chr(225).chr(187).chr(167) => 'u',\n\t\tchr(225).chr(187).chr(172) => 'U', chr(225).chr(187).chr(173) => 'u',\n\t\tchr(225).chr(187).chr(182) => 'Y', chr(225).chr(187).chr(183) => 'y',\n\t\t// tilde\n\t\tchr(225).chr(186).chr(170) => 'A', chr(225).chr(186).chr(171) => 'a',\n\t\tchr(225).chr(186).chr(180) => 'A', chr(225).chr(186).chr(181) => 'a',\n\t\tchr(225).chr(186).chr(188) => 'E', chr(225).chr(186).chr(189) => 'e',\n\t\tchr(225).chr(187).chr(132) => 'E', chr(225).chr(187).chr(133) => 'e',\n\t\tchr(225).chr(187).chr(150) => 'O', chr(225).chr(187).chr(151) => 'o',\n\t\tchr(225).chr(187).chr(160) => 'O', chr(225).chr(187).chr(161) => 'o',\n\t\tchr(225).chr(187).chr(174) => 'U', chr(225).chr(187).chr(175) => 'u',\n\t\tchr(225).chr(187).chr(184) => 'Y', chr(225).chr(187).chr(185) => 'y',\n\t\t// acute accent\n\t\tchr(225).chr(186).chr(164) => 'A', chr(225).chr(186).chr(165) => 'a',\n\t\tchr(225).chr(186).chr(174) => 'A', chr(225).chr(186).chr(175) => 'a',\n\t\tchr(225).chr(186).chr(190) => 'E', chr(225).chr(186).chr(191) => 'e',\n\t\tchr(225).chr(187).chr(144) => 'O', chr(225).chr(187).chr(145) => 'o',\n\t\tchr(225).chr(187).chr(154) => 'O', chr(225).chr(187).chr(155) => 'o',\n\t\tchr(225).chr(187).chr(168) => 'U', chr(225).chr(187).chr(169) => 'u',\n\t\t// dot below\n\t\tchr(225).chr(186).chr(160) => 'A', chr(225).chr(186).chr(161) => 'a',\n\t\tchr(225).chr(186).chr(172) => 'A', chr(225).chr(186).chr(173) => 'a',\n\t\tchr(225).chr(186).chr(182) => 'A', chr(225).chr(186).chr(183) => 'a',\n\t\tchr(225).chr(186).chr(184) => 'E', chr(225).chr(186).chr(185) => 'e',\n\t\tchr(225).chr(187).chr(134) => 'E', chr(225).chr(187).chr(135) => 'e',\n\t\tchr(225).chr(187).chr(138) => 'I', chr(225).chr(187).chr(139) => 'i',\n\t\tchr(225).chr(187).chr(140) => 'O', chr(225).chr(187).chr(141) => 'o',\n\t\tchr(225).chr(187).chr(152) => 'O', chr(225).chr(187).chr(153) => 'o',\n\t\tchr(225).chr(187).chr(162) => 'O', chr(225).chr(187).chr(163) => 'o',\n\t\tchr(225).chr(187).chr(164) => 'U', chr(225).chr(187).chr(165) => 'u',\n\t\tchr(225).chr(187).chr(176) => 'U', chr(225).chr(187).chr(177) => 'u',\n\t\tchr(225).chr(187).chr(180) => 'Y', chr(225).chr(187).chr(181) => 'y',\n\t\t// Vowels with diacritic (Chinese, Hanyu Pinyin)\n\t\tchr(201).chr(145) => 'a',\n\t\t// macron\n\t\tchr(199).chr(149) => 'U', chr(199).chr(150) => 'u',\n\t\t// acute accent\n\t\tchr(199).chr(151) => 'U', chr(199).chr(152) => 'u',\n\t\t// caron\n\t\tchr(199).chr(141) => 'A', chr(199).chr(142) => 'a',\n\t\tchr(199).chr(143) => 'I', chr(199).chr(144) => 'i',\n\t\tchr(199).chr(145) => 'O', chr(199).chr(146) => 'o',\n\t\tchr(199).chr(147) => 'U', chr(199).chr(148) => 'u',\n\t\tchr(199).chr(153) => 'U', chr(199).chr(154) => 'u',\n\t\t// grave accent\n\t\tchr(199).chr(155) => 'U', chr(199).chr(156) => 'u',\n\t\t);\n\n\t\t$string = strtr($string, $chars);\n\t} else {\n\t\t// Assume ISO-8859-1 if not UTF-8\n\t\t$chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158)\n\t\t\t.chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194)\n\t\t\t.chr(195).chr(196).chr(197).chr(199).chr(200).chr(201).chr(202)\n\t\t\t.chr(203).chr(204).chr(205).chr(206).chr(207).chr(209).chr(210)\n\t\t\t.chr(211).chr(212).chr(213).chr(214).chr(216).chr(217).chr(218)\n\t\t\t.chr(219).chr(220).chr(221).chr(224).chr(225).chr(226).chr(227)\n\t\t\t.chr(228).chr(229).chr(231).chr(232).chr(233).chr(234).chr(235)\n\t\t\t.chr(236).chr(237).chr(238).chr(239).chr(241).chr(242).chr(243)\n\t\t\t.chr(244).chr(245).chr(246).chr(248).chr(249).chr(250).chr(251)\n\t\t\t.chr(252).chr(253).chr(255);\n\n\t\t$chars['out'] = \"EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy\";\n\n\t\t$string = strtr($string, $chars['in'], $chars['out']);\n\t\t$double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254));\n\t\t$double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th');\n\t\t$string = str_replace($double_chars['in'], $double_chars['out'], $string);\n\t}\n\n\treturn $string;\n}\n\n/**\n * Sanitizes a filename replacing whitespace with dashes\n *\n * Removes special characters that are illegal in filenames on certain\n * operating systems and special characters requiring special escaping\n * to manipulate at the command line. Replaces spaces and consecutive\n * dashes with a single dash. Trim period, dash and underscore from beginning\n * and end of filename.\n *\n * @since 2.1.0\n *\n * @param string $filename The filename to be sanitized\n * @return string The sanitized filename\n */\nfunction sanitize_file_name( $filename ) {\n\t$filename_raw = $filename;\n\t$special_chars = array(\"?\", \"[\", \"]\", \"/\", \"\\\\\", \"=\", \"<\", \">\", \":\", \";\", \",\", \"'\", \"\\\"\", \"&\", \"$\", \"#\", \"*\", \"(\", \")\", \"|\", \"~\", \"`\", \"!\", \"{\", \"}\", chr(0));\n\t$special_chars = apply_filters('sanitize_file_name_chars', $special_chars, $filename_raw);\n\t$filename = str_replace($special_chars, '', $filename);\n\t$filename = preg_replace('/[\\s-]+/', '-', $filename);\n\t$filename = trim($filename, '.-_');\n\n\t// Split the filename into a base and extension[s]\n\t$parts = explode('.', $filename);\n\n\t// Return if only one extension\n\tif ( count($parts) <= 2 )\n\t\treturn apply_filters('sanitize_file_name', $filename, $filename_raw);\n\n\t// Process multiple extensions\n\t$filename = array_shift($parts);\n\t$extension = array_pop($parts);\n\t$mimes = get_allowed_mime_types();\n\n\t// Loop over any intermediate extensions. Munge them with a trailing underscore if they are a 2 - 5 character\n\t// long alpha string not in the extension whitelist.\n\tforeach ( (array) $parts as $part) {\n\t\t$filename .= '.' . $part;\n\n\t\tif ( preg_match(\"/^[a-zA-Z]{2,5}\\d?$/\", $part) ) {\n\t\t\t$allowed = false;\n\t\t\tforeach ( $mimes as $ext_preg => $mime_match ) {\n\t\t\t\t$ext_preg = '!^(' . $ext_preg . ')$!i';\n\t\t\t\tif ( preg_match( $ext_preg, $part ) ) {\n\t\t\t\t\t$allowed = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( !$allowed )\n\t\t\t\t$filename .= '_';\n\t\t}\n\t}\n\t$filename .= '.' . $extension;\n\n\treturn apply_filters('sanitize_file_name', $filename, $filename_raw);\n}\n\n/**\n * Sanitize username stripping out unsafe characters.\n *\n * Removes tags, octets, entities, and if strict is enabled, will only keep\n * alphanumeric, _, space, ., -, @. After sanitizing, it passes the username,\n * raw username (the username in the parameter), and the value of $strict as\n * parameters for the 'sanitize_user' filter.\n *\n * @since 2.0.0\n * @uses apply_filters() Calls 'sanitize_user' hook on username, raw username,\n *\t\tand $strict parameter.\n *\n * @param string $username The username to be sanitized.\n * @param bool $strict If set limits $username to specific characters. Default false.\n * @return string The sanitized username, after passing through filters.\n */\nfunction sanitize_user( $username, $strict = false ) {\n\t$raw_username = $username;\n\t$username = wp_strip_all_tags( $username );\n\t$username = remove_accents( $username );\n\t// Kill octets\n\t$username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username );\n\t$username = preg_replace( '/&.+?;/', '', $username ); // Kill entities\n\n\t// If strict, reduce to ASCII for max portability.\n\tif ( $strict )\n\t\t$username = preg_replace( '|[^a-z0-9 _.\\-@]|i', '', $username );\n\n\t$username = trim( $username );\n\t// Consolidate contiguous whitespace\n\t$username = preg_replace( '|\\s+|', ' ', $username );\n\n\treturn apply_filters( 'sanitize_user', $username, $raw_username, $strict );\n}\n\n/**\n * Sanitize a string key.\n *\n * Keys are used as internal identifiers. Lowercase alphanumeric characters, dashes and underscores are allowed.\n *\n * @since 3.0.0\n *\n * @param string $key String key\n * @return string Sanitized key\n */\nfunction sanitize_key( $key ) {\n\t$raw_key = $key;\n\t$key = strtolower( $key );\n\t$key = preg_replace( '/[^a-z0-9_\\-]/', '', $key );\n\treturn apply_filters( 'sanitize_key', $key, $raw_key );\n}\n\n/**\n * Sanitizes title or use fallback title.\n *\n * Specifically, HTML and PHP tags are stripped. Further actions can be added\n * via the plugin API. If $title is empty and $fallback_title is set, the latter\n * will be used.\n *\n * @since 1.0.0\n *\n * @param string $title The string to be sanitized.\n * @param string $fallback_title Optional. A title to use if $title is empty.\n * @param string $context Optional. The operation for which the string is sanitized\n * @return string The sanitized string.\n */\nfunction sanitize_title($title, $fallback_title = '', $context = 'save') {\n\t$raw_title = $title;\n\n\tif ( 'save' == $context )\n\t\t$title = remove_accents($title);\n\n\t$title = apply_filters('sanitize_title', $title, $raw_title, $context);\n\n\tif ( '' === $title || false === $title )\n\t\t$title = $fallback_title;\n\n\treturn $title;\n}\n\nfunction sanitize_title_for_query($title) {\n\treturn sanitize_title($title, '', 'query');\n}\n\n/**\n * Sanitizes title, replacing whitespace and a few other characters with dashes.\n *\n * Limits the output to alphanumeric characters, underscore (_) and dash (-).\n * Whitespace becomes a dash.\n *\n * @since 1.2.0\n *\n * @param string $title The title to be sanitized.\n * @param string $raw_title Optional. Not used.\n * @param string $context Optional. The operation for which the string is sanitized.\n * @return string The sanitized title.\n */\nfunction sanitize_title_with_dashes($title, $raw_title = '', $context = 'display') {\n\t$title = strip_tags($title);\n\t// Preserve escaped octets.\n\t$title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);\n\t// Remove percent signs that are not part of an octet.\n\t$title = str_replace('%', '', $title);\n\t// Restore octets.\n\t$title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);\n\n\tif (seems_utf8($title)) {\n\t\tif (function_exists('mb_strtolower')) {\n\t\t\t$title = mb_strtolower($title, 'UTF-8');\n\t\t}\n\t\t$title = utf8_uri_encode($title, 200);\n\t}\n\n\t$title = strtolower($title);\n\t$title = preg_replace('/&.+?;/', '', $title); // kill entities\n\t$title = str_replace('.', '-', $title);\n\n\tif ( 'save' == $context ) {\n\t\t// Convert nbsp, ndash and mdash to hyphens\n\t\t$title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title );\n\n\t\t// Strip these characters entirely\n\t\t$title = str_replace( array(\n\t\t\t// iexcl and iquest\n\t\t\t'%c2%a1', '%c2%bf',\n\t\t\t// angle quotes\n\t\t\t'%c2%ab', '%c2%bb', '%e2%80%b9', '%e2%80%ba',\n\t\t\t// curly quotes\n\t\t\t'%e2%80%98', '%e2%80%99', '%e2%80%9c', '%e2%80%9d',\n\t\t\t'%e2%80%9a', '%e2%80%9b', '%e2%80%9e', '%e2%80%9f',\n\t\t\t// copy, reg, deg, hellip and trade\n\t\t\t'%c2%a9', '%c2%ae', '%c2%b0', '%e2%80%a6', '%e2%84%a2',\n\t\t\t// grave accent, acute accent, macron, caron\n\t\t\t'%cc%80', '%cc%81', '%cc%84', '%cc%8c',\n\t\t), '', $title );\n\n\t\t// Convert times to x\n\t\t$title = str_replace( '%c3%97', 'x', $title );\n\t}\n\n\t$title = preg_replace('/[^%a-z0-9 _-]/', '', $title);\n\t$title = preg_replace('/\\s+/', '-', $title);\n\t$title = preg_replace('|-+|', '-', $title);\n\t$title = trim($title, '-');\n\n\treturn $title;\n}\n\n/**\n * Ensures a string is a valid SQL order by clause.\n *\n * Accepts one or more columns, with or without ASC/DESC, and also accepts\n * RAND().\n *\n * @since 2.5.1\n *\n * @param string $orderby Order by string to be checked.\n * @return string|bool Returns the order by clause if it is a match, false otherwise.\n */\nfunction sanitize_sql_orderby( $orderby ){\n\tpreg_match('/^\\s*([a-z0-9_]+(\\s+(ASC|DESC))?(\\s*,\\s*|\\s*$))+|^\\s*RAND\\(\\s*\\)\\s*$/i', $orderby, $obmatches);\n\tif ( !$obmatches )\n\t\treturn false;\n\treturn $orderby;\n}\n\n/**\n * Santizes a html classname to ensure it only contains valid characters\n *\n * Strips the string down to A-Z,a-z,0-9,_,-. If this results in an empty\n * string then it will return the alternative value supplied.\n *\n * @todo Expand to support the full range of CDATA that a class attribute can contain.\n *\n * @since 2.8.0\n *\n * @param string $class The classname to be sanitized\n * @param string $fallback Optional. The value to return if the sanitization end's up as an empty string.\n * \tDefaults to an empty string.\n * @return string The sanitized value\n */\nfunction sanitize_html_class( $class, $fallback = '' ) {\n\t//Strip out any % encoded octets\n\t$sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $class );\n\n\t//Limit to A-Z,a-z,0-9,_,-\n\t$sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized );\n\n\tif ( '' == $sanitized )\n\t\t$sanitized = $fallback;\n\n\treturn apply_filters( 'sanitize_html_class', $sanitized, $class, $fallback );\n}\n\n/**\n * Converts a number of characters from a string.\n *\n * Metadata tags <<title>> and <<category>> are removed, <<br>> and <<hr>> are\n * converted into correct XHTML and Unicode characters are converted to the\n * valid range.\n *\n * @since 0.71\n *\n * @param string $content String of characters to be converted.\n * @param string $deprecated Not used.\n * @return string Converted string.\n */\nfunction convert_chars($content, $deprecated = '') {\n\tif ( !empty( $deprecated ) )\n\t\t_deprecated_argument( __FUNCTION__, '0.71' );\n\n\t// Translation of invalid Unicode references range to valid range\n\t$wp_htmltranswinuni = array(\n\t'€' => '€', // the Euro sign\n\t'' => '',\n\t'‚' => '‚', // these are Windows CP1252 specific characters\n\t'ƒ' => 'ƒ', // they would look weird on non-Windows browsers\n\t'„' => '„',\n\t'…' => '…',\n\t'†' => '†',\n\t'‡' => '‡',\n\t'ˆ' => 'ˆ',\n\t'‰' => '‰',\n\t'Š' => 'Š',\n\t'‹' => '‹',\n\t'Œ' => 'Œ',\n\t'' => '',\n\t'Ž' => 'Ž',\n\t'' => '',\n\t'' => '',\n\t'‘' => '‘',\n\t'’' => '’',\n\t'“' => '“',\n\t'”' => '”',\n\t'•' => '•',\n\t'–' => '–',\n\t'—' => '—',\n\t'˜' => '˜',\n\t'™' => '™',\n\t'š' => 'š',\n\t'›' => '›',\n\t'œ' => 'œ',\n\t'' => '',\n\t'ž' => 'ž',\n\t'Ÿ' => 'Ÿ'\n\t);\n\n\t// Remove metadata tags\n\t$content = preg_replace('/<title>(.+?)<\\/title>/','',$content);\n\t$content = preg_replace('/<category>(.+?)<\\/category>/','',$content);\n\n\t// Converts lone & characters into & (a.k.a. &)\n\t$content = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content);\n\n\t// Fix Word pasting\n\t$content = strtr($content, $wp_htmltranswinuni);\n\n\t// Just a little XHTML help\n\t$content = str_replace('<br>', '<br />', $content);\n\t$content = str_replace('<hr>', '<hr />', $content);\n\n\treturn $content;\n}\n\n/**\n * Will only balance the tags if forced to and the option is set to balance tags.\n *\n * The option 'use_balanceTags' is used to determine whether the tags will be balanced.\n *\n * @since 0.71\n *\n * @param string $text Text to be balanced\n * @param bool $force If true, forces balancing, ignoring the value of the option. Default false.\n * @return string Balanced text\n */\nfunction balanceTags( $text, $force = false ) {\n\tif ( !$force && get_option('use_balanceTags') == 0 )\n\t\treturn $text;\n\treturn force_balance_tags( $text );\n}\n\n/**\n * Balances tags of string using a modified stack.\n *\n * @since 2.0.4\n *\n * @author Leonard Lin <leonard@acm.org>\n * @license GPL\n * @copyright November 4, 2001\n * @version 1.1\n * @todo Make better - change loop condition to $text in 1.2\n * @internal Modified by Scott Reilly (coffee2code) 02 Aug 2004\n *\t\t1.1 Fixed handling of append/stack pop order of end text\n *\t\t\t Added Cleaning Hooks\n *\t\t1.0 First Version\n *\n * @param string $text Text to be balanced.\n * @return string Balanced text.\n */\nfunction force_balance_tags( $text ) {\n\t$tagstack = array();\n\t$stacksize = 0;\n\t$tagqueue = '';\n\t$newtext = '';\n\t// Known single-entity/self-closing tags\n\t$single_tags = array( 'area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source' );\n\t// Tags that can be immediately nested within themselves\n\t$nestable_tags = array( 'blockquote', 'div', 'object', 'q', 'span' );\n\n\t// WP bug fix for comments - in case you REALLY meant to type '< !--'\n\t$text = str_replace('< !--', '< !--', $text);\n\t// WP bug fix for LOVE <3 (and other situations with '<' before a number)\n\t$text = preg_replace('#<([0-9]{1})#', '<$1', $text);\n\n\twhile ( preg_match(\"/<(\\/?[\\w:]*)\\s*([^>]*)>/\", $text, $regex) ) {\n\t\t$newtext .= $tagqueue;\n\n\t\t$i = strpos($text, $regex[0]);\n\t\t$l = strlen($regex[0]);\n\n\t\t// clear the shifter\n\t\t$tagqueue = '';\n\t\t// Pop or Push\n\t\tif ( isset($regex[1][0]) && '/' == $regex[1][0] ) { // End Tag\n\t\t\t$tag = strtolower(substr($regex[1],1));\n\t\t\t// if too many closing tags\n\t\t\tif( $stacksize <= 0 ) {\n\t\t\t\t$tag = '';\n\t\t\t\t// or close to be safe $tag = '/' . $tag;\n\t\t\t}\n\t\t\t// if stacktop value = tag close value then pop\n\t\t\telse if ( $tagstack[$stacksize - 1] == $tag ) { // found closing tag\n\t\t\t\t$tag = '</' . $tag . '>'; // Close Tag\n\t\t\t\t// Pop\n\t\t\t\tarray_pop( $tagstack );\n\t\t\t\t$stacksize--;\n\t\t\t} else { // closing tag not at top, search for it\n\t\t\t\tfor ( $j = $stacksize-1; $j >= 0; $j-- ) {\n\t\t\t\t\tif ( $tagstack[$j] == $tag ) {\n\t\t\t\t\t// add tag to tagqueue\n\t\t\t\t\t\tfor ( $k = $stacksize-1; $k >= $j; $k--) {\n\t\t\t\t\t\t\t$tagqueue .= '</' . array_pop( $tagstack ) . '>';\n\t\t\t\t\t\t\t$stacksize--;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t$tag = '';\n\t\t\t}\n\t\t} else { // Begin Tag\n\t\t\t$tag = strtolower($regex[1]);\n\n\t\t\t// Tag Cleaning\n\n\t\t\t// If it's an empty tag \"< >\", do nothing\n\t\t\tif ( '' == $tag ) {\n\t\t\t\t// do nothing\n\t\t\t}\n\t\t\t// ElseIf it presents itself as a self-closing tag...\n\t\t\telseif ( substr( $regex[2], -1 ) == '/' ) {\n\t\t\t\t// ...but it isn't a known single-entity self-closing tag, then don't let it be treated as such and\n\t\t\t\t// immediately close it with a closing tag (the tag will encapsulate no text as a result)\n\t\t\t\tif ( ! in_array( $tag, $single_tags ) )\n\t\t\t\t\t$regex[2] = trim( substr( $regex[2], 0, -1 ) ) . \"></$tag\";\n\t\t\t}\n\t\t\t// ElseIf it's a known single-entity tag but it doesn't close itself, do so\n\t\t\telseif ( in_array($tag, $single_tags) ) {\n\t\t\t\t$regex[2] .= '/';\n\t\t\t}\n\t\t\t// Else it's not a single-entity tag\n\t\t\telse {\n\t\t\t\t// If the top of the stack is the same as the tag we want to push, close previous tag\n\t\t\t\tif ( $stacksize > 0 && !in_array($tag, $nestable_tags) && $tagstack[$stacksize - 1] == $tag ) {\n\t\t\t\t\t$tagqueue = '</' . array_pop( $tagstack ) . '>';\n\t\t\t\t\t$stacksize--;\n\t\t\t\t}\n\t\t\t\t$stacksize = array_push( $tagstack, $tag );\n\t\t\t}\n\n\t\t\t// Attributes\n\t\t\t$attributes = $regex[2];\n\t\t\tif( ! empty( $attributes ) && $attributes[0] != '>' )\n\t\t\t\t$attributes = ' ' . $attributes;\n\n\t\t\t$tag = '<' . $tag . $attributes . '>';\n\t\t\t//If already queuing a close tag, then put this tag on, too\n\t\t\tif ( !empty($tagqueue) ) {\n\t\t\t\t$tagqueue .= $tag;\n\t\t\t\t$tag = '';\n\t\t\t}\n\t\t}\n\t\t$newtext .= substr($text, 0, $i) . $tag;\n\t\t$text = substr($text, $i + $l);\n\t}\n\n\t// Clear Tag Queue\n\t$newtext .= $tagqueue;\n\n\t// Add Remaining text\n\t$newtext .= $text;\n\n\t// Empty Stack\n\twhile( $x = array_pop($tagstack) )\n\t\t$newtext .= '</' . $x . '>'; // Add remaining tags to close\n\n\t// WP fix for the bug with HTML comments\n\t$newtext = str_replace(\"< !--\",\"<!--\",$newtext);\n\t$newtext = str_replace(\"< !--\",\"< !--\",$newtext);\n\n\treturn $newtext;\n}\n\n/**\n * Acts on text which is about to be edited.\n *\n * The $content is run through esc_textarea(), which uses htmlspecialchars()\n * to convert special characters to HTML entities. If $richedit is set to true,\n * it is simply a holder for the 'format_to_edit' filter.\n *\n * @since 0.71\n *\n * @param string $content The text about to be edited.\n * @param bool $richedit Whether the $content should not pass through htmlspecialchars(). Default false (meaning it will be passed).\n * @return string The text after the filter (and possibly htmlspecialchars()) has been run.\n */\nfunction format_to_edit( $content, $richedit = false ) {\n\t$content = apply_filters( 'format_to_edit', $content );\n\tif ( ! $richedit )\n\t\t$content = esc_textarea( $content );\n\treturn $content;\n}\n\n/**\n * Holder for the 'format_to_post' filter.\n *\n * @since 0.71\n *\n * @param string $content The text to pass through the filter.\n * @return string Text returned from the 'format_to_post' filter.\n */\nfunction format_to_post($content) {\n\t$content = apply_filters('format_to_post', $content);\n\treturn $content;\n}\n\n/**\n * Add leading zeros when necessary.\n *\n * If you set the threshold to '4' and the number is '10', then you will get\n * back '0010'. If you set the threshold to '4' and the number is '5000', then you\n * will get back '5000'.\n *\n * Uses sprintf to append the amount of zeros based on the $threshold parameter\n * and the size of the number. If the number is large enough, then no zeros will\n * be appended.\n *\n * @since 0.71\n *\n * @param mixed $number Number to append zeros to if not greater than threshold.\n * @param int $threshold Digit places number needs to be to not have zeros added.\n * @return string Adds leading zeros to number if needed.\n */\nfunction zeroise($number, $threshold) {\n\treturn sprintf('%0'.$threshold.'s', $number);\n}\n\n/**\n * Adds backslashes before letters and before a number at the start of a string.\n *\n * @since 0.71\n *\n * @param string $string Value to which backslashes will be added.\n * @return string String with backslashes inserted.\n */\nfunction backslashit($string) {\n\t$string = preg_replace('/^([0-9])/', '\\\\\\\\\\\\\\\\\\1', $string);\n\t$string = preg_replace('/([a-z])/i', '\\\\\\\\\\1', $string);\n\treturn $string;\n}\n\n/**\n * Appends a trailing slash.\n *\n * Will remove trailing slash if it exists already before adding a trailing\n * slash. This prevents double slashing a string or path.\n *\n * The primary use of this is for paths and thus should be used for paths. It is\n * not restricted to paths and offers no specific path support.\n *\n * @since 1.2.0\n * @uses untrailingslashit() Unslashes string if it was slashed already.\n *\n * @param string $string What to add the trailing slash to.\n * @return string String with trailing slash added.\n */\nfunction trailingslashit($string) {\n\treturn untrailingslashit($string) . '/';\n}\n\n/**\n * Removes trailing slash if it exists.\n *\n * The primary use of this is for paths and thus should be used for paths. It is\n * not restricted to paths and offers no specific path support.\n *\n * @since 2.2.0\n *\n * @param string $string What to remove the trailing slash from.\n * @return string String without the trailing slash.\n */\nfunction untrailingslashit($string) {\n\treturn rtrim($string, '/');\n}\n\n/**\n * Adds slashes to escape strings.\n *\n * Slashes will first be removed if magic_quotes_gpc is set, see {@link\n * http://www.php.net/magic_quotes} for more details.\n *\n * @since 0.71\n *\n * @param string $gpc The string returned from HTTP request data.\n * @return string Returns a string escaped with slashes.\n */\nfunction addslashes_gpc($gpc) {\n\tif ( get_magic_quotes_gpc() )\n\t\t$gpc = stripslashes($gpc);\n\n\treturn esc_sql($gpc);\n}\n\n/**\n * Navigates through an array and removes slashes from the values.\n *\n * If an array is passed, the array_map() function causes a callback to pass the\n * value back to the function. The slashes from this value will removed.\n *\n * @since 2.0.0\n *\n * @param mixed $value The value to be stripped.\n * @return mixed Stripped value.\n */\nfunction stripslashes_deep($value) {\n\tif ( is_array($value) ) {\n\t\t$value = array_map('stripslashes_deep', $value);\n\t} elseif ( is_object($value) ) {\n\t\t$vars = get_object_vars( $value );\n\t\tforeach ($vars as $key=>$data) {\n\t\t\t$value->{$key} = stripslashes_deep( $data );\n\t\t}\n\t} elseif ( is_string( $value ) ) {\n\t\t$value = stripslashes($value);\n\t}\n\n\treturn $value;\n}\n\n/**\n * Navigates through an array and encodes the values to be used in a URL.\n *\n *\n * @since 2.2.0\n *\n * @param array|string $value The array or string to be encoded.\n * @return array|string $value The encoded array (or string from the callback).\n */\nfunction urlencode_deep($value) {\n\t$value = is_array($value) ? array_map('urlencode_deep', $value) : urlencode($value);\n\treturn $value;\n}\n\n/**\n * Navigates through an array and raw encodes the values to be used in a URL.\n *\n * @since 3.4.0\n *\n * @param array|string $value The array or string to be encoded.\n * @return array|string $value The encoded array (or string from the callback).\n */\nfunction rawurlencode_deep( $value ) {\n\treturn is_array( $value ) ? array_map( 'rawurlencode_deep', $value ) : rawurlencode( $value );\n}\n\n/**\n * Converts email addresses characters to HTML entities to block spam bots.\n *\n * @since 0.71\n *\n * @param string $emailaddy Email address.\n * @param int $mailto Optional. Range from 0 to 1. Used for encoding.\n * @return string Converted email address.\n */\nfunction antispambot($emailaddy, $mailto=0) {\n\t$emailNOSPAMaddy = '';\n\tsrand ((float) microtime() * 1000000);\n\tfor ($i = 0; $i < strlen($emailaddy); $i = $i + 1) {\n\t\t$j = floor(rand(0, 1+$mailto));\n\t\tif ($j==0) {\n\t\t\t$emailNOSPAMaddy .= '&#'.ord(substr($emailaddy,$i,1)).';';\n\t\t} elseif ($j==1) {\n\t\t\t$emailNOSPAMaddy .= substr($emailaddy,$i,1);\n\t\t} elseif ($j==2) {\n\t\t\t$emailNOSPAMaddy .= '%'.zeroise(dechex(ord(substr($emailaddy, $i, 1))), 2);\n\t\t}\n\t}\n\t$emailNOSPAMaddy = str_replace('@','@',$emailNOSPAMaddy);\n\treturn $emailNOSPAMaddy;\n}\n\n/**\n * Callback to convert URI match to HTML A element.\n *\n * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link\n * make_clickable()}.\n *\n * @since 2.3.2\n * @access private\n *\n * @param array $matches Single Regex Match.\n * @return string HTML A element with URI address.\n */\nfunction _make_url_clickable_cb($matches) {\n\t$url = $matches[2];\n\n\tif ( ')' == $matches[3] && strpos( $url, '(' ) ) {\n\t\t// If the trailing character is a closing parethesis, and the URL has an opening parenthesis in it, add the closing parenthesis to the URL.\n\t\t// Then we can let the parenthesis balancer do its thing below.\n\t\t$url .= $matches[3];\n\t\t$suffix = '';\n\t} else {\n\t\t$suffix = $matches[3];\n\t}\n\n\t// Include parentheses in the URL only if paired\n\twhile ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) {\n\t\t$suffix = strrchr( $url, ')' ) . $suffix;\n\t\t$url = substr( $url, 0, strrpos( $url, ')' ) );\n\t}\n\n\t$url = esc_url($url);\n\tif ( empty($url) )\n\t\treturn $matches[0];\n\n\treturn $matches[1] . \"<a href=\\\"$url\\\" rel=\\\"nofollow\\\">$url</a>\" . $suffix;\n}\n\n/**\n * Callback to convert URL match to HTML A element.\n *\n * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link\n * make_clickable()}.\n *\n * @since 2.3.2\n * @access private\n *\n * @param array $matches Single Regex Match.\n * @return string HTML A element with URL address.\n */\nfunction _make_web_ftp_clickable_cb($matches) {\n\t$ret = '';\n\t$dest = $matches[2];\n\t$dest = 'http://' . $dest;\n\t$dest = esc_url($dest);\n\tif ( empty($dest) )\n\t\treturn $matches[0];\n\n\t// removed trailing [.,;:)] from URL\n\tif ( in_array( substr($dest, -1), array('.', ',', ';', ':', ')') ) === true ) {\n\t\t$ret = substr($dest, -1);\n\t\t$dest = substr($dest, 0, strlen($dest)-1);\n\t}\n\treturn $matches[1] . \"<a href=\\\"$dest\\\" rel=\\\"nofollow\\\">$dest</a>$ret\";\n}\n\n/**\n * Callback to convert email address match to HTML A element.\n *\n * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link\n * make_clickable()}.\n *\n * @since 2.3.2\n * @access private\n *\n * @param array $matches Single Regex Match.\n * @return string HTML A element with email address.\n */\nfunction _make_email_clickable_cb($matches) {\n\t$email = $matches[2] . '@' . $matches[3];\n\treturn $matches[1] . \"<a href=\\\"mailto:$email\\\">$email</a>\";\n}\n\n/**\n * Convert plaintext URI to HTML links.\n *\n * Converts URI, www and ftp, and email addresses. Finishes by fixing links\n * within links.\n *\n * @since 0.71\n *\n * @param string $text Content to convert URIs.\n * @return string Content with converted URIs.\n */\nfunction make_clickable( $text ) {\n\t$r = '';\n\t$textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags\n\tforeach ( $textarr as $piece ) {\n\t\tif ( empty( $piece ) || ( $piece[0] == '<' && ! preg_match('|^<\\s*[\\w]{1,20}+://|', $piece) ) ) {\n\t\t\t$r .= $piece;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Long strings might contain expensive edge cases ...\n\t\tif ( 10000 < strlen( $piece ) ) {\n\t\t\t// ... break it up\n\t\t\tforeach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses\n\t\t\t\tif ( 2101 < strlen( $chunk ) ) {\n\t\t\t\t\t$r .= $chunk; // Too big, no whitespace: bail.\n\t\t\t\t} else {\n\t\t\t\t\t$r .= make_clickable( $chunk );\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t$ret = \" $piece \"; // Pad with whitespace to simplify the regexes\n\n\t\t\t$url_clickable = '~\n\t\t\t\t([\\\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation\n\t\t\t\t( # 2: URL\n\t\t\t\t\t[\\\\w]{1,20}+:// # Scheme and hier-part prefix\n\t\t\t\t\t(?=\\S{1,2000}\\s) # Limit to URLs less than about 2000 characters long\n\t\t\t\t\t[\\\\w\\\\x80-\\\\xff#%\\\\~/@\\\\[\\\\]*(+=&$-]*+ # Non-punctuation URL character\n\t\t\t\t\t(?: # Unroll the Loop: Only allow puctuation URL character if followed by a non-punctuation URL character\n\t\t\t\t\t\t[\\'.,;:!?)] # Punctuation URL character\n\t\t\t\t\t\t[\\\\w\\\\x80-\\\\xff#%\\\\~/@\\\\[\\\\]*(+=&$-]++ # Non-punctuation URL character\n\t\t\t\t\t)*\n\t\t\t\t)\n\t\t\t\t(\\)?) # 3: Trailing closing parenthesis (for parethesis balancing post processing)\n\t\t\t~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character.\n\t\t\t // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times.\n\n\t\t\t$ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret );\n\n\t\t\t$ret = preg_replace_callback( '#([\\s>])((www|ftp)\\.[\\w\\\\x80-\\\\xff\\#$%&~/.\\-;:=,?@\\[\\]+]+)#is', '_make_web_ftp_clickable_cb', $ret );\n\t\t\t$ret = preg_replace_callback( '#([\\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret );\n\n\t\t\t$ret = substr( $ret, 1, -1 ); // Remove our whitespace padding.\n\t\t\t$r .= $ret;\n\t\t}\n\t}\n\n\t// Cleanup of accidental links within links\n\t$r = preg_replace( '#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', \"$1$3</a>\", $r );\n\treturn $r;\n}\n\n/**\n * Breaks a string into chunks by splitting at whitespace characters.\n * The length of each returned chunk is as close to the specified length goal as possible,\n * with the caveat that each chunk includes its trailing delimiter.\n * Chunks longer than the goal are guaranteed to not have any inner whitespace.\n *\n * Joining the returned chunks with empty delimiters reconstructs the input string losslessly.\n *\n * Input string must have no null characters (or eventual transformations on output chunks must not care about null characters)\n *\n * <code>\n * _split_str_by_whitespace( \"1234 67890 1234 67890a cd 1234 890 123456789 1234567890a 45678 1 3 5 7 90 \", 10 ) ==\n * array (\n * 0 => '1234 67890 ', // 11 characters: Perfect split\n * 1 => '1234 ', // 5 characters: '1234 67890a' was too long\n * 2 => '67890a cd ', // 10 characters: '67890a cd 1234' was too long\n * 3 => '1234 890 ', // 11 characters: Perfect split\n * 4 => '123456789 ', // 10 characters: '123456789 1234567890a' was too long\n * 5 => '1234567890a ', // 12 characters: Too long, but no inner whitespace on which to split\n * 6 => ' 45678 ', // 11 characters: Perfect split\n * 7 => '1 3 5 7 9', // 9 characters: End of $string\n * );\n * </code>\n *\n * @since 3.4.0\n * @access private\n *\n * @param string $string The string to split.\n * @param int $goal The desired chunk length.\n * @return array Numeric array of chunks.\n */\nfunction _split_str_by_whitespace( $string, $goal ) {\n\t$chunks = array();\n\n\t$string_nullspace = strtr( $string, \"\\r\\n\\t\\v\\f \", \"\\000\\000\\000\\000\\000\\000\" );\n\n\twhile ( $goal < strlen( $string_nullspace ) ) {\n\t\t$pos = strrpos( substr( $string_nullspace, 0, $goal + 1 ), \"\\000\" );\n\n\t\tif ( false === $pos ) {\n\t\t\t$pos = strpos( $string_nullspace, \"\\000\", $goal + 1 );\n\t\t\tif ( false === $pos ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t$chunks[] = substr( $string, 0, $pos + 1 );\n\t\t$string = substr( $string, $pos + 1 );\n\t\t$string_nullspace = substr( $string_nullspace, $pos + 1 );\n\t}\n\n\tif ( $string ) {\n\t\t$chunks[] = $string;\n\t}\n\n\treturn $chunks;\n}\n\n/**\n * Adds rel nofollow string to all HTML A elements in content.\n *\n * @since 1.5.0\n *\n * @param string $text Content that may contain HTML A elements.\n * @return string Converted content.\n */\nfunction wp_rel_nofollow( $text ) {\n\t// This is a pre save filter, so text is already escaped.\n\t$text = stripslashes($text);\n\t$text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text);\n\t$text = esc_sql($text);\n\treturn $text;\n}\n\n/**\n * Callback to used to add rel=nofollow string to HTML A element.\n *\n * Will remove already existing rel=\"nofollow\" and rel='nofollow' from the\n * string to prevent from invalidating (X)HTML.\n *\n * @since 2.3.0\n *\n * @param array $matches Single Match\n * @return string HTML A Element with rel nofollow.\n */\nfunction wp_rel_nofollow_callback( $matches ) {\n\t$text = $matches[1];\n\t$text = str_replace(array(' rel=\"nofollow\"', \" rel='nofollow'\"), '', $text);\n\treturn \"<a $text rel=\\\"nofollow\\\">\";\n}\n\n/**\n * Convert one smiley code to the icon graphic file equivalent.\n *\n * Looks up one smiley code in the $wpsmiliestrans global array and returns an\n * <img> string for that smiley.\n *\n * @global array $wpsmiliestrans\n * @since 2.8.0\n *\n * @param string $smiley Smiley code to convert to image.\n * @return string Image string for smiley.\n */\nfunction translate_smiley($smiley) {\n\tglobal $wpsmiliestrans;\n\n\tif (count($smiley) == 0) {\n\t\treturn '';\n\t}\n\n\t$smiley = trim(reset($smiley));\n\t$img = $wpsmiliestrans[$smiley];\n\t$smiley_masked = esc_attr($smiley);\n\n\t$srcurl = apply_filters('smilies_src', includes_url(\"images/smilies/$img\"), $img, site_url());\n\n\treturn \" <img src='$srcurl' alt='$smiley_masked' class='wp-smiley' /> \";\n}\n\n/**\n * Convert text equivalent of smilies to images.\n *\n * Will only convert smilies if the option 'use_smilies' is true and the global\n * used in the function isn't empty.\n *\n * @since 0.71\n * @uses $wp_smiliessearch\n *\n * @param string $text Content to convert smilies from text.\n * @return string Converted content with text smilies replaced with images.\n */\nfunction convert_smilies($text) {\n\tglobal $wp_smiliessearch;\n\t$output = '';\n\tif ( get_option('use_smilies') && !empty($wp_smiliessearch) ) {\n\t\t// HTML loop taken from texturize function, could possible be consolidated\n\t\t$textarr = preg_split(\"/(<.*>)/U\", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between\n\t\t$stop = count($textarr);// loop stuff\n\t\tfor ($i = 0; $i < $stop; $i++) {\n\t\t\t$content = $textarr[$i];\n\t\t\tif ((strlen($content) > 0) && ('<' != $content[0])) { // If it's not a tag\n\t\t\t\t$content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content);\n\t\t\t}\n\t\t\t$output .= $content;\n\t\t}\n\t} else {\n\t\t// return default text.\n\t\t$output = $text;\n\t}\n\treturn $output;\n}\n\n/**\n * Verifies that an email is valid.\n *\n * Does not grok i18n domains. Not RFC compliant.\n *\n * @since 0.71\n *\n * @param string $email Email address to verify.\n * @param boolean $deprecated Deprecated.\n * @return string|bool Either false or the valid email address.\n */\nfunction is_email( $email, $deprecated = false ) {\n\tif ( ! empty( $deprecated ) )\n\t\t_deprecated_argument( __FUNCTION__, '3.0' );\n\n\t// Test for the minimum length the email can be\n\tif ( strlen( $email ) < 3 ) {\n\t\treturn apply_filters( 'is_email', false, $email, 'email_too_short' );\n\t}\n\n\t// Test for an @ character after the first position\n\tif ( strpos( $email, '@', 1 ) === false ) {\n\t\treturn apply_filters( 'is_email', false, $email, 'email_no_at' );\n\t}\n\n\t// Split out the local and domain parts\n\tlist( $local, $domain ) = explode( '@', $email, 2 );\n\n\t// LOCAL PART\n\t// Test for invalid characters\n\tif ( !preg_match( '/^[a-zA-Z0-9!#$%&\\'*+\\/=?^_`{|}~\\.-]+$/', $local ) ) {\n\t\treturn apply_filters( 'is_email', false, $email, 'local_invalid_chars' );\n\t}\n\n\t// DOMAIN PART\n\t// Test for sequences of periods\n\tif ( preg_match( '/\\.{2,}/', $domain ) ) {\n\t\treturn apply_filters( 'is_email', false, $email, 'domain_period_sequence' );\n\t}\n\n\t// Test for leading and trailing periods and whitespace\n\tif ( trim( $domain, \" \\t\\n\\r\\0\\x0B.\" ) !== $domain ) {\n\t\treturn apply_filters( 'is_email', false, $email, 'domain_period_limits' );\n\t}\n\n\t// Split the domain into subs\n\t$subs = explode( '.', $domain );\n\n\t// Assume the domain will have at least two subs\n\tif ( 2 > count( $subs ) ) {\n\t\treturn apply_filters( 'is_email', false, $email, 'domain_no_periods' );\n\t}\n\n\t// Loop through each sub\n\tforeach ( $subs as $sub ) {\n\t\t// Test for leading and trailing hyphens and whitespace\n\t\tif ( trim( $sub, \" \\t\\n\\r\\0\\x0B-\" ) !== $sub ) {\n\t\t\treturn apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' );\n\t\t}\n\n\t\t// Test for invalid characters\n\t\tif ( !preg_match('/^[a-z0-9-]+$/i', $sub ) ) {\n\t\t\treturn apply_filters( 'is_email', false, $email, 'sub_invalid_chars' );\n\t\t}\n\t}\n\n\t// Congratulations your email made it!\n\treturn apply_filters( 'is_email', $email, $email, null );\n}\n\n/**\n * Convert to ASCII from email subjects.\n *\n * @since 1.2.0\n *\n * @param string $string Subject line\n * @return string Converted string to ASCII\n */\nfunction wp_iso_descrambler($string) {\n\t/* this may only work with iso-8859-1, I'm afraid */\n\tif (!preg_match('#\\=\\?(.+)\\?Q\\?(.+)\\?\\=#i', $string, $matches)) {\n\t\treturn $string;\n\t} else {\n\t\t$subject = str_replace('_', ' ', $matches[2]);\n\t\t$subject = preg_replace_callback('#\\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject);\n\t\treturn $subject;\n\t}\n}\n\n/**\n * Helper function to convert hex encoded chars to ASCII\n *\n * @since 3.1.0\n * @access private\n * @param array $match The preg_replace_callback matches array\n * @return array Converted chars\n */\nfunction _wp_iso_convert( $match ) {\n\treturn chr( hexdec( strtolower( $match[1] ) ) );\n}\n\n/**\n * Returns a date in the GMT equivalent.\n *\n * Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the\n * value of the 'gmt_offset' option. Return format can be overridden using the\n * $format parameter. The DateTime and DateTimeZone classes are used to respect\n * time zone differences in DST.\n *\n * @since 1.2.0\n *\n * @uses get_option() to retrieve the the value of 'gmt_offset'.\n * @param string $string The date to be converted.\n * @param string $format The format string for the returned date (default is Y-m-d H:i:s)\n * @return string GMT version of the date provided.\n */\nfunction get_gmt_from_date($string, $format = 'Y-m-d H:i:s') {\n\tpreg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);\n\tif ( ! $matches )\n\t\treturn date( $format, 0 );\n\n\t$tz = get_option('timezone_string');\n\tif ( $tz ) {\n\t\tdate_default_timezone_set( $tz );\n\t\t$datetime = date_create( $string );\n\t\tif ( ! $datetime )\n\t\t\treturn date( $format, 0 );\n\n\t\t$datetime->setTimezone( new DateTimeZone('UTC') );\n\t\t$offset = $datetime->getOffset();\n\t\t$datetime->modify( '+' . $offset / HOUR_IN_SECONDS . ' hours');\n\t\t$string_gmt = gmdate($format, $datetime->format('U'));\n\n\t\tdate_default_timezone_set('UTC');\n\t} else {\n\t\t$string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);\n\t\t$string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * HOUR_IN_SECONDS);\n\t}\n\treturn $string_gmt;\n}\n\n/**\n * Converts a GMT date into the correct format for the blog.\n *\n * Requires and returns in the Y-m-d H:i:s format. Simply adds the value of\n * gmt_offset.Return format can be overridden using the $format parameter\n *\n * @since 1.2.0\n *\n * @param string $string The date to be converted.\n * @param string $format The format string for the returned date (default is Y-m-d H:i:s)\n * @return string Formatted date relative to the GMT offset.\n */\nfunction get_date_from_gmt($string, $format = 'Y-m-d H:i:s') {\n\tpreg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);\n\t$string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);\n\t$string_localtime = gmdate($format, $string_time + get_option('gmt_offset') * HOUR_IN_SECONDS);\n\treturn $string_localtime;\n}\n\n/**\n * Computes an offset in seconds from an iso8601 timezone.\n *\n * @since 1.5.0\n *\n * @param string $timezone Either 'Z' for 0 offset or '±hhmm'.\n * @return int|float The offset in seconds.\n */\nfunction iso8601_timezone_to_offset($timezone) {\n\t// $timezone is either 'Z' or '[+|-]hhmm'\n\tif ($timezone == 'Z') {\n\t\t$offset = 0;\n\t} else {\n\t\t$sign = (substr($timezone, 0, 1) == '+') ? 1 : -1;\n\t\t$hours = intval(substr($timezone, 1, 2));\n\t\t$minutes = intval(substr($timezone, 3, 4)) / 60;\n\t\t$offset = $sign * HOUR_IN_SECONDS * ($hours + $minutes);\n\t}\n\treturn $offset;\n}\n\n/**\n * Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt].\n *\n * @since 1.5.0\n *\n * @param string $date_string Date and time in ISO 8601 format {@link http://en.wikipedia.org/wiki/ISO_8601}.\n * @param string $timezone Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'.\n * @return string The date and time in MySQL DateTime format - Y-m-d H:i:s.\n */\nfunction iso8601_to_datetime($date_string, $timezone = 'user') {\n\t$timezone = strtolower($timezone);\n\n\tif ($timezone == 'gmt') {\n\n\t\tpreg_match('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\\+|\\-][0-9]{2,4}){0,1}#', $date_string, $date_bits);\n\n\t\tif (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset\n\t\t\t$offset = iso8601_timezone_to_offset($date_bits[7]);\n\t\t} else { // we don't have a timezone, so we assume user local timezone (not server's!)\n\t\t\t$offset = HOUR_IN_SECONDS * get_option('gmt_offset');\n\t\t}\n\n\t\t$timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]);\n\t\t$timestamp -= $offset;\n\n\t\treturn gmdate('Y-m-d H:i:s', $timestamp);\n\n\t} else if ($timezone == 'user') {\n\t\treturn preg_replace('#([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(Z|[\\+|\\-][0-9]{2,4}){0,1}#', '$1-$2-$3 $4:$5:$6', $date_string);\n\t}\n}\n\n/**\n * Adds a element attributes to open links in new windows.\n *\n * Comment text in popup windows should be filtered through this. Right now it's\n * a moderately dumb function, ideally it would detect whether a target or rel\n * attribute was already there and adjust its actions accordingly.\n *\n * @since 0.71\n *\n * @param string $text Content to replace links to open in a new window.\n * @return string Content that has filtered links.\n */\nfunction popuplinks($text) {\n\t$text = preg_replace('/<a (.+?)>/i', \"<a $1 target='_blank' rel='external'>\", $text);\n\treturn $text;\n}\n\n/**\n * Strips out all characters that are not allowable in an email.\n *\n * @since 1.5.0\n *\n * @param string $email Email address to filter.\n * @return string Filtered email address.\n */\nfunction sanitize_email( $email ) {\n\t// Test for the minimum length the email can be\n\tif ( strlen( $email ) < 3 ) {\n\t\treturn apply_filters( 'sanitize_email', '', $email, 'email_too_short' );\n\t}\n\n\t// Test for an @ character after the first position\n\tif ( strpos( $email, '@', 1 ) === false ) {\n\t\treturn apply_filters( 'sanitize_email', '', $email, 'email_no_at' );\n\t}\n\n\t// Split out the local and domain parts\n\tlist( $local, $domain ) = explode( '@', $email, 2 );\n\n\t// LOCAL PART\n\t// Test for invalid characters\n\t$local = preg_replace( '/[^a-zA-Z0-9!#$%&\\'*+\\/=?^_`{|}~\\.-]/', '', $local );\n\tif ( '' === $local ) {\n\t\treturn apply_filters( 'sanitize_email', '', $email, 'local_invalid_chars' );\n\t}\n\n\t// DOMAIN PART\n\t// Test for sequences of periods\n\t$domain = preg_replace( '/\\.{2,}/', '', $domain );\n\tif ( '' === $domain ) {\n\t\treturn apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' );\n\t}\n\n\t// Test for leading and trailing periods and whitespace\n\t$domain = trim( $domain, \" \\t\\n\\r\\0\\x0B.\" );\n\tif ( '' === $domain ) {\n\t\treturn apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' );\n\t}\n\n\t// Split the domain into subs\n\t$subs = explode( '.', $domain );\n\n\t// Assume the domain will have at least two subs\n\tif ( 2 > count( $subs ) ) {\n\t\treturn apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' );\n\t}\n\n\t// Create an array that will contain valid subs\n\t$new_subs = array();\n\n\t// Loop through each sub\n\tforeach ( $subs as $sub ) {\n\t\t// Test for leading and trailing hyphens\n\t\t$sub = trim( $sub, \" \\t\\n\\r\\0\\x0B-\" );\n\n\t\t// Test for invalid characters\n\t\t$sub = preg_replace( '/[^a-z0-9-]+/i', '', $sub );\n\n\t\t// If there's anything left, add it to the valid subs\n\t\tif ( '' !== $sub ) {\n\t\t\t$new_subs[] = $sub;\n\t\t}\n\t}\n\n\t// If there aren't 2 or more valid subs\n\tif ( 2 > count( $new_subs ) ) {\n\t\treturn apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' );\n\t}\n\n\t// Join valid subs into the new domain\n\t$domain = join( '.', $new_subs );\n\n\t// Put the email back together\n\t$email = $local . '@' . $domain;\n\n\t// Congratulations your email made it!\n\treturn apply_filters( 'sanitize_email', $email, $email, null );\n}\n\n/**\n * Determines the difference between two timestamps.\n *\n * The difference is returned in a human readable format such as \"1 hour\",\n * \"5 mins\", \"2 days\".\n *\n * @since 1.5.0\n *\n * @param int $from Unix timestamp from which the difference begins.\n * @param int $to Optional. Unix timestamp to end the time difference. Default becomes time() if not set.\n * @return string Human readable time difference.\n */\nfunction human_time_diff( $from, $to = '' ) {\n\tif ( empty( $to ) )\n\t\t$to = time();\n\t$diff = (int) abs( $to - $from );\n\tif ( $diff <= HOUR_IN_SECONDS ) {\n\t\t$mins = round( $diff / MINUTE_IN_SECONDS );\n\t\tif ( $mins <= 1 ) {\n\t\t\t$mins = 1;\n\t\t}\n\t\t/* translators: min=minute */\n\t\t$since = sprintf( _n( '%s min', '%s mins', $mins ), $mins );\n\t} elseif ( ( $diff <= DAY_IN_SECONDS ) && ( $diff > HOUR_IN_SECONDS ) ) {\n\t\t$hours = round( $diff / HOUR_IN_SECONDS );\n\t\tif ( $hours <= 1 ) {\n\t\t\t$hours = 1;\n\t\t}\n\t\t$since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours );\n\t} elseif ( $diff >= DAY_IN_SECONDS ) {\n\t\t$days = round( $diff / DAY_IN_SECONDS );\n\t\tif ( $days <= 1 ) {\n\t\t\t$days = 1;\n\t\t}\n\t\t$since = sprintf( _n( '%s day', '%s days', $days ), $days );\n\t}\n\treturn $since;\n}\n\n/**\n * Generates an excerpt from the content, if needed.\n *\n * The excerpt word amount will be 55 words and if the amount is greater than\n * that, then the string ' [...]' will be appended to the excerpt. If the string\n * is less than 55 words, then the content will be returned as is.\n *\n * The 55 word limit can be modified by plugins/themes using the excerpt_length filter\n * The ' [...]' string can be modified by plugins/themes using the excerpt_more filter\n *\n * @since 1.5.0\n *\n * @param string $text Optional. The excerpt. If set to empty, an excerpt is generated.\n * @return string The excerpt.\n */\nfunction wp_trim_excerpt($text = '') {\n\t$raw_excerpt = $text;\n\tif ( '' == $text ) {\n\t\t$text = get_the_content('');\n\n\t\t$text = strip_shortcodes( $text );\n\n\t\t$text = apply_filters('the_content', $text);\n\t\t$text = str_replace(']]>', ']]>', $text);\n\t\t$excerpt_length = apply_filters('excerpt_length', 55);\n\t\t$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');\n\t\t$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );\n\t}\n\treturn apply_filters('wp_trim_excerpt', $text, $raw_excerpt);\n}\n\n/**\n * Trims text to a certain number of words.\n *\n * This function is localized. For languages that count 'words' by the individual\n * character (such as East Asian languages), the $num_words argument will apply\n * to the number of individual characters.\n *\n * @since 3.3.0\n *\n * @param string $text Text to trim.\n * @param int $num_words Number of words. Default 55.\n * @param string $more What to append if $text needs to be trimmed. Default '…'.\n * @return string Trimmed text.\n */\nfunction wp_trim_words( $text, $num_words = 55, $more = null ) {\n\tif ( null === $more )\n\t\t$more = __( '…' );\n\t$original_text = $text;\n\t$text = wp_strip_all_tags( $text );\n\t/* translators: If your word count is based on single characters (East Asian characters),\n\t enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */\n\tif ( 'characters' == _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\\-?8$/i', get_option( 'blog_charset' ) ) ) {\n\t\t$text = trim( preg_replace( \"/[\\n\\r\\t ]+/\", ' ', $text ), ' ' );\n\t\tpreg_match_all( '/./u', $text, $words_array );\n\t\t$words_array = array_slice( $words_array[0], 0, $num_words + 1 );\n\t\t$sep = '';\n\t} else {\n\t\t$words_array = preg_split( \"/[\\n\\r\\t ]+/\", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY );\n\t\t$sep = ' ';\n\t}\n\tif ( count( $words_array ) > $num_words ) {\n\t\tarray_pop( $words_array );\n\t\t$text = implode( $sep, $words_array );\n\t\t$text = $text . $more;\n\t} else {\n\t\t$text = implode( $sep, $words_array );\n\t}\n\treturn apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text );\n}\n\n/**\n * Converts named entities into numbered entities.\n *\n * @since 1.5.1\n *\n * @param string $text The text within which entities will be converted.\n * @return string Text with converted entities.\n */\nfunction ent2ncr($text) {\n\n\t// Allow a plugin to short-circuit and override the mappings.\n\t$filtered = apply_filters( 'pre_ent2ncr', null, $text );\n\tif( null !== $filtered )\n\t\treturn $filtered;\n\n\t$to_ncr = array(\n\t\t'"' => '"',\n\t\t'&' => '&',\n\t\t'⁄' => '/',\n\t\t'<' => '<',\n\t\t'>' => '>',\n\t\t'|' => '|',\n\t\t' ' => ' ',\n\t\t'¡' => '¡',\n\t\t'¢' => '¢',\n\t\t'£' => '£',\n\t\t'¤' => '¤',\n\t\t'¥' => '¥',\n\t\t'¦' => '¦',\n\t\t'&brkbar;' => '¦',\n\t\t'§' => '§',\n\t\t'¨' => '¨',\n\t\t'¨' => '¨',\n\t\t'©' => '©',\n\t\t'ª' => 'ª',\n\t\t'«' => '«',\n\t\t'¬' => '¬',\n\t\t'­' => '­',\n\t\t'®' => '®',\n\t\t'¯' => '¯',\n\t\t'&hibar;' => '¯',\n\t\t'°' => '°',\n\t\t'±' => '±',\n\t\t'²' => '²',\n\t\t'³' => '³',\n\t\t'´' => '´',\n\t\t'µ' => 'µ',\n\t\t'¶' => '¶',\n\t\t'·' => '·',\n\t\t'¸' => '¸',\n\t\t'¹' => '¹',\n\t\t'º' => 'º',\n\t\t'»' => '»',\n\t\t'¼' => '¼',\n\t\t'½' => '½',\n\t\t'¾' => '¾',\n\t\t'¿' => '¿',\n\t\t'À' => 'À',\n\t\t'Á' => 'Á',\n\t\t'Â' => 'Â',\n\t\t'Ã' => 'Ã',\n\t\t'Ä' => 'Ä',\n\t\t'Å' => 'Å',\n\t\t'Æ' => 'Æ',\n\t\t'Ç' => 'Ç',\n\t\t'È' => 'È',\n\t\t'É' => 'É',\n\t\t'Ê' => 'Ê',\n\t\t'Ë' => 'Ë',\n\t\t'Ì' => 'Ì',\n\t\t'Í' => 'Í',\n\t\t'Î' => 'Î',\n\t\t'Ï' => 'Ï',\n\t\t'Ð' => 'Ð',\n\t\t'Ñ' => 'Ñ',\n\t\t'Ò' => 'Ò',\n\t\t'Ó' => 'Ó',\n\t\t'Ô' => 'Ô',\n\t\t'Õ' => 'Õ',\n\t\t'Ö' => 'Ö',\n\t\t'×' => '×',\n\t\t'Ø' => 'Ø',\n\t\t'Ù' => 'Ù',\n\t\t'Ú' => 'Ú',\n\t\t'Û' => 'Û',\n\t\t'Ü' => 'Ü',\n\t\t'Ý' => 'Ý',\n\t\t'Þ' => 'Þ',\n\t\t'ß' => 'ß',\n\t\t'à' => 'à',\n\t\t'á' => 'á',\n\t\t'â' => 'â',\n\t\t'ã' => 'ã',\n\t\t'ä' => 'ä',\n\t\t'å' => 'å',\n\t\t'æ' => 'æ',\n\t\t'ç' => 'ç',\n\t\t'è' => 'è',\n\t\t'é' => 'é',\n\t\t'ê' => 'ê',\n\t\t'ë' => 'ë',\n\t\t'ì' => 'ì',\n\t\t'í' => 'í',\n\t\t'î' => 'î',\n\t\t'ï' => 'ï',\n\t\t'ð' => 'ð',\n\t\t'ñ' => 'ñ',\n\t\t'ò' => 'ò',\n\t\t'ó' => 'ó',\n\t\t'ô' => 'ô',\n\t\t'õ' => 'õ',\n\t\t'ö' => 'ö',\n\t\t'÷' => '÷',\n\t\t'ø' => 'ø',\n\t\t'ù' => 'ù',\n\t\t'ú' => 'ú',\n\t\t'û' => 'û',\n\t\t'ü' => 'ü',\n\t\t'ý' => 'ý',\n\t\t'þ' => 'þ',\n\t\t'ÿ' => 'ÿ',\n\t\t'Œ' => 'Œ',\n\t\t'œ' => 'œ',\n\t\t'Š' => 'Š',\n\t\t'š' => 'š',\n\t\t'Ÿ' => 'Ÿ',\n\t\t'ƒ' => 'ƒ',\n\t\t'ˆ' => 'ˆ',\n\t\t'˜' => '˜',\n\t\t'Α' => 'Α',\n\t\t'Β' => 'Β',\n\t\t'Γ' => 'Γ',\n\t\t'Δ' => 'Δ',\n\t\t'Ε' => 'Ε',\n\t\t'Ζ' => 'Ζ',\n\t\t'Η' => 'Η',\n\t\t'Θ' => 'Θ',\n\t\t'Ι' => 'Ι',\n\t\t'Κ' => 'Κ',\n\t\t'Λ' => 'Λ',\n\t\t'Μ' => 'Μ',\n\t\t'Ν' => 'Ν',\n\t\t'Ξ' => 'Ξ',\n\t\t'Ο' => 'Ο',\n\t\t'Π' => 'Π',\n\t\t'Ρ' => 'Ρ',\n\t\t'Σ' => 'Σ',\n\t\t'Τ' => 'Τ',\n\t\t'Υ' => 'Υ',\n\t\t'Φ' => 'Φ',\n\t\t'Χ' => 'Χ',\n\t\t'Ψ' => 'Ψ',\n\t\t'Ω' => 'Ω',\n\t\t'α' => 'α',\n\t\t'β' => 'β',\n\t\t'γ' => 'γ',\n\t\t'δ' => 'δ',\n\t\t'ε' => 'ε',\n\t\t'ζ' => 'ζ',\n\t\t'η' => 'η',\n\t\t'θ' => 'θ',\n\t\t'ι' => 'ι',\n\t\t'κ' => 'κ',\n\t\t'λ' => 'λ',\n\t\t'μ' => 'μ',\n\t\t'ν' => 'ν',\n\t\t'ξ' => 'ξ',\n\t\t'ο' => 'ο',\n\t\t'π' => 'π',\n\t\t'ρ' => 'ρ',\n\t\t'ς' => 'ς',\n\t\t'σ' => 'σ',\n\t\t'τ' => 'τ',\n\t\t'υ' => 'υ',\n\t\t'φ' => 'φ',\n\t\t'χ' => 'χ',\n\t\t'ψ' => 'ψ',\n\t\t'ω' => 'ω',\n\t\t'ϑ' => 'ϑ',\n\t\t'ϒ' => 'ϒ',\n\t\t'ϖ' => 'ϖ',\n\t\t' ' => ' ',\n\t\t' ' => ' ',\n\t\t' ' => ' ',\n\t\t'‌' => '‌',\n\t\t'‍' => '‍',\n\t\t'‎' => '‎',\n\t\t'‏' => '‏',\n\t\t'–' => '–',\n\t\t'—' => '—',\n\t\t'‘' => '‘',\n\t\t'’' => '’',\n\t\t'‚' => '‚',\n\t\t'“' => '“',\n\t\t'”' => '”',\n\t\t'„' => '„',\n\t\t'†' => '†',\n\t\t'‡' => '‡',\n\t\t'•' => '•',\n\t\t'…' => '…',\n\t\t'‰' => '‰',\n\t\t'′' => '′',\n\t\t'″' => '″',\n\t\t'‹' => '‹',\n\t\t'›' => '›',\n\t\t'‾' => '‾',\n\t\t'⁄' => '⁄',\n\t\t'€' => '€',\n\t\t'ℑ' => 'ℑ',\n\t\t'℘' => '℘',\n\t\t'ℜ' => 'ℜ',\n\t\t'™' => '™',\n\t\t'ℵ' => 'ℵ',\n\t\t'↵' => '↵',\n\t\t'⇐' => '⇐',\n\t\t'⇑' => '⇑',\n\t\t'⇒' => '⇒',\n\t\t'⇓' => '⇓',\n\t\t'⇔' => '⇔',\n\t\t'∀' => '∀',\n\t\t'∂' => '∂',\n\t\t'∃' => '∃',\n\t\t'∅' => '∅',\n\t\t'∇' => '∇',\n\t\t'∈' => '∈',\n\t\t'∉' => '∉',\n\t\t'∋' => '∋',\n\t\t'∏' => '∏',\n\t\t'∑' => '∑',\n\t\t'−' => '−',\n\t\t'∗' => '∗',\n\t\t'√' => '√',\n\t\t'∝' => '∝',\n\t\t'∞' => '∞',\n\t\t'∠' => '∠',\n\t\t'∧' => '∧',\n\t\t'∨' => '∨',\n\t\t'∩' => '∩',\n\t\t'∪' => '∪',\n\t\t'∫' => '∫',\n\t\t'∴' => '∴',\n\t\t'∼' => '∼',\n\t\t'≅' => '≅',\n\t\t'≈' => '≈',\n\t\t'≠' => '≠',\n\t\t'≡' => '≡',\n\t\t'≤' => '≤',\n\t\t'≥' => '≥',\n\t\t'⊂' => '⊂',\n\t\t'⊃' => '⊃',\n\t\t'⊄' => '⊄',\n\t\t'⊆' => '⊆',\n\t\t'⊇' => '⊇',\n\t\t'⊕' => '⊕',\n\t\t'⊗' => '⊗',\n\t\t'⊥' => '⊥',\n\t\t'⋅' => '⋅',\n\t\t'⌈' => '⌈',\n\t\t'⌉' => '⌉',\n\t\t'⌊' => '⌊',\n\t\t'⌋' => '⌋',\n\t\t'⟨' => '〈',\n\t\t'⟩' => '〉',\n\t\t'←' => '←',\n\t\t'↑' => '↑',\n\t\t'→' => '→',\n\t\t'↓' => '↓',\n\t\t'↔' => '↔',\n\t\t'◊' => '◊',\n\t\t'♠' => '♠',\n\t\t'♣' => '♣',\n\t\t'♥' => '♥',\n\t\t'♦' => '♦'\n\t);\n\n\treturn str_replace( array_keys($to_ncr), array_values($to_ncr), $text );\n}\n\n/**\n * Formats text for the rich text editor.\n *\n * The filter 'richedit_pre' is applied here. If $text is empty the filter will\n * be applied to an empty string.\n *\n * @since 2.0.0\n *\n * @param string $text The text to be formatted.\n * @return string The formatted text after filter is applied.\n */\nfunction wp_richedit_pre($text) {\n\t// Filtering a blank results in an annoying <br />\\n\n\tif ( empty($text) ) return apply_filters('richedit_pre', '');\n\n\t$output = convert_chars($text);\n\t$output = wpautop($output);\n\t$output = htmlspecialchars($output, ENT_NOQUOTES);\n\n\treturn apply_filters('richedit_pre', $output);\n}\n\n/**\n * Formats text for the HTML editor.\n *\n * Unless $output is empty it will pass through htmlspecialchars before the\n * 'htmledit_pre' filter is applied.\n *\n * @since 2.5.0\n *\n * @param string $output The text to be formatted.\n * @return string Formatted text after filter applied.\n */\nfunction wp_htmledit_pre($output) {\n\tif ( !empty($output) )\n\t\t$output = htmlspecialchars($output, ENT_NOQUOTES); // convert only < > &\n\n\treturn apply_filters('htmledit_pre', $output);\n}\n\n/**\n * Perform a deep string replace operation to ensure the values in $search are no longer present\n *\n * Repeats the replacement operation until it no longer replaces anything so as to remove \"nested\" values\n * e.g. $subject = '%0%0%0DDD', $search ='%0D', $result ='' rather than the '%0%0DD' that\n * str_replace would return\n *\n * @since 2.8.1\n * @access private\n *\n * @param string|array $search\n * @param string $subject\n * @return string The processed string\n */\nfunction _deep_replace( $search, $subject ) {\n\t$found = true;\n\t$subject = (string) $subject;\n\twhile ( $found ) {\n\t\t$found = false;\n\t\tforeach ( (array) $search as $val ) {\n\t\t\twhile ( strpos( $subject, $val ) !== false ) {\n\t\t\t\t$found = true;\n\t\t\t\t$subject = str_replace( $val, '', $subject );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn $subject;\n}\n\n/**\n * Escapes data for use in a MySQL query\n *\n * This is just a handy shortcut for $wpdb->escape(), for completeness' sake\n *\n * @since 2.8.0\n * @param string $sql Unescaped SQL data\n * @return string The cleaned $sql\n */\nfunction esc_sql( $sql ) {\n\tglobal $wpdb;\n\treturn $wpdb->escape( $sql );\n}\n\n/**\n * Checks and cleans a URL.\n *\n * A number of characters are removed from the URL. If the URL is for displaying\n * (the default behaviour) ampersands are also replaced. The 'clean_url' filter\n * is applied to the returned cleaned URL.\n *\n * @since 2.8.0\n * @uses wp_kses_bad_protocol() To only permit protocols in the URL set\n *\t\tvia $protocols or the common ones set in the function.\n *\n * @param string $url The URL to be cleaned.\n * @param array $protocols Optional. An array of acceptable protocols.\n *\t\tDefaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn' if not set.\n * @param string $_context Private. Use esc_url_raw() for database usage.\n * @return string The cleaned $url after the 'clean_url' filter is applied.\n */\nfunction esc_url( $url, $protocols = null, $_context = 'display' ) {\n\t$original_url = $url;\n\n\tif ( '' == $url )\n\t\treturn $url;\n\t$url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\\|*\\'()\\\\x80-\\\\xff]|i', '', $url);\n\t$strip = array('%0d', '%0a', '%0D', '%0A');\n\t$url = _deep_replace($strip, $url);\n\t$url = str_replace(';//', '://', $url);\n\t/* If the URL doesn't appear to contain a scheme, we\n\t * presume it needs http:// appended (unless a relative\n\t * link starting with /, # or ? or a php file).\n\t */\n\tif ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) &&\n\t\t! preg_match('/^[a-z0-9-]+?\\.php/i', $url) )\n\t\t$url = 'http://' . $url;\n\n\t// Replace ampersands and single quotes only when displaying.\n\tif ( 'display' == $_context ) {\n\t\t$url = wp_kses_normalize_entities( $url );\n\t\t$url = str_replace( '&', '&', $url );\n\t\t$url = str_replace( \"'\", ''', $url );\n\t}\n\n\tif ( ! is_array( $protocols ) )\n\t\t$protocols = wp_allowed_protocols();\n\tif ( wp_kses_bad_protocol( $url, $protocols ) != $url )\n\t\treturn '';\n\n\treturn apply_filters('clean_url', $url, $original_url, $_context);\n}\n\n/**\n * Performs esc_url() for database usage.\n *\n * @since 2.8.0\n * @uses esc_url()\n *\n * @param string $url The URL to be cleaned.\n * @param array $protocols An array of acceptable protocols.\n * @return string The cleaned URL.\n */\nfunction esc_url_raw( $url, $protocols = null ) {\n\treturn esc_url( $url, $protocols, 'db' );\n}\n\n/**\n * Convert entities, while preserving already-encoded entities.\n *\n * @link http://www.php.net/htmlentities Borrowed from the PHP Manual user notes.\n *\n * @since 1.2.2\n *\n * @param string $myHTML The text to be converted.\n * @return string Converted text.\n */\nfunction htmlentities2($myHTML) {\n\t$translation_table = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES );\n\t$translation_table[chr(38)] = '&';\n\treturn preg_replace( \"/&(?![A-Za-z]{0,4}\\w{2,3};|#[0-9]{2,3};)/\", \"&\", strtr($myHTML, $translation_table) );\n}\n\n/**\n * Escape single quotes, htmlspecialchar \" < > &, and fix line endings.\n *\n * Escapes text strings for echoing in JS. It is intended to be used for inline JS\n * (in a tag attribute, for example onclick=\"...\"). Note that the strings have to\n * be in single quotes. The filter 'js_escape' is also applied here.\n *\n * @since 2.8.0\n *\n * @param string $text The text to be escaped.\n * @return string Escaped text.\n */\nfunction esc_js( $text ) {\n\t$safe_text = wp_check_invalid_utf8( $text );\n\t$safe_text = _wp_specialchars( $safe_text, ENT_COMPAT );\n\t$safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', \"'\", stripslashes( $safe_text ) );\n\t$safe_text = str_replace( \"\\r\", '', $safe_text );\n\t$safe_text = str_replace( \"\\n\", '\\\\n', addslashes( $safe_text ) );\n\treturn apply_filters( 'js_escape', $safe_text, $text );\n}\n\n/**\n * Escaping for HTML blocks.\n *\n * @since 2.8.0\n *\n * @param string $text\n * @return string\n */\nfunction esc_html( $text ) {\n\t$safe_text = wp_check_invalid_utf8( $text );\n\t$safe_text = _wp_specialchars( $safe_text, ENT_QUOTES );\n\treturn apply_filters( 'esc_html', $safe_text, $text );\n}\n\n/**\n * Escaping for HTML attributes.\n *\n * @since 2.8.0\n *\n * @param string $text\n * @return string\n */\nfunction esc_attr( $text ) {\n\t$safe_text = wp_check_invalid_utf8( $text );\n\t$safe_text = _wp_specialchars( $safe_text, ENT_QUOTES );\n\treturn apply_filters( 'attribute_escape', $safe_text, $text );\n}\n\n/**\n * Escaping for textarea values.\n *\n * @since 3.1\n *\n * @param string $text\n * @return string\n */\nfunction esc_textarea( $text ) {\n\t$safe_text = htmlspecialchars( $text, ENT_QUOTES );\n\treturn apply_filters( 'esc_textarea', $safe_text, $text );\n}\n\n/**\n * Escape a HTML tag name.\n *\n * @since 2.5.0\n *\n * @param string $tag_name\n * @return string\n */\nfunction tag_escape($tag_name) {\n\t$safe_tag = strtolower( preg_replace('/[^a-zA-Z0-9_:]/', '', $tag_name) );\n\treturn apply_filters('tag_escape', $safe_tag, $tag_name);\n}\n\n/**\n * Escapes text for SQL LIKE special characters % and _.\n *\n * @since 2.5.0\n *\n * @param string $text The text to be escaped.\n * @return string text, safe for inclusion in LIKE query.\n */\nfunction like_escape($text) {\n\treturn str_replace(array(\"%\", \"_\"), array(\"\\\\%\", \"\\\\_\"), $text);\n}\n\n/**\n * Convert full URL paths to absolute paths.\n *\n * Removes the http or https protocols and the domain. Keeps the path '/' at the\n * beginning, so it isn't a true relative link, but from the web root base.\n *\n * @since 2.1.0\n *\n * @param string $link Full URL path.\n * @return string Absolute path.\n */\nfunction wp_make_link_relative( $link ) {\n\treturn preg_replace( '|https?://[^/]+(/.*)|i', '$1', $link );\n}\n\n/**\n * Sanitises various option values based on the nature of the option.\n *\n * This is basically a switch statement which will pass $value through a number\n * of functions depending on the $option.\n *\n * @since 2.0.5\n *\n * @param string $option The name of the option.\n * @param string $value The unsanitised value.\n * @return string Sanitized value.\n */\nfunction sanitize_option($option, $value) {\n\n\tswitch ( $option ) {\n\t\tcase 'admin_email' :\n\t\tcase 'new_admin_email' :\n\t\t\t$value = sanitize_email( $value );\n\t\t\tif ( ! is_email( $value ) ) {\n\t\t\t\t$value = get_option( $option ); // Resets option to stored value in the case of failed sanitization\n\t\t\t\tif ( function_exists( 'add_settings_error' ) )\n\t\t\t\t\tadd_settings_error( $option, 'invalid_admin_email', __( 'The email address entered did not appear to be a valid email address. Please enter a valid email address.' ) );\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase 'thumbnail_size_w':\n\t\tcase 'thumbnail_size_h':\n\t\tcase 'medium_size_w':\n\t\tcase 'medium_size_h':\n\t\tcase 'large_size_w':\n\t\tcase 'large_size_h':\n\t\tcase 'mailserver_port':\n\t\tcase 'comment_max_links':\n\t\tcase 'page_on_front':\n\t\tcase 'page_for_posts':\n\t\tcase 'rss_excerpt_length':\n\t\tcase 'default_category':\n\t\tcase 'default_email_category':\n\t\tcase 'default_link_category':\n\t\tcase 'close_comments_days_old':\n\t\tcase 'comments_per_page':\n\t\tcase 'thread_comments_depth':\n\t\tcase 'users_can_register':\n\t\tcase 'start_of_week':\n\t\t\t$value = absint( $value );\n\t\t\tbreak;\n\n\t\tcase 'posts_per_page':\n\t\tcase 'posts_per_rss':\n\t\t\t$value = (int) $value;\n\t\t\tif ( empty($value) )\n\t\t\t\t$value = 1;\n\t\t\tif ( $value < -1 )\n\t\t\t\t$value = abs($value);\n\t\t\tbreak;\n\n\t\tcase 'default_ping_status':\n\t\tcase 'default_comment_status':\n\t\t\t// Options that if not there have 0 value but need to be something like \"closed\"\n\t\t\tif ( $value == '0' || $value == '')\n\t\t\t\t$value = 'closed';\n\t\t\tbreak;\n\n\t\tcase 'blogdescription':\n\t\tcase 'blogname':\n\t\t\t$value = wp_kses_post( $value );\n\t\t\t$value = esc_html( $value );\n\t\t\tbreak;\n\n\t\tcase 'blog_charset':\n\t\t\t$value = preg_replace('/[^a-zA-Z0-9_-]/', '', $value); // strips slashes\n\t\t\tbreak;\n\n\t\tcase 'blog_public':\n\t\t\t// This is the value if the settings checkbox is not checked on POST. Don't rely on this.\n\t\t\tif ( null === $value )\n\t\t\t\t$value = 1;\n\t\t\telse\n\t\t\t\t$value = intval( $value );\n\t\t\tbreak;\n\n\t\tcase 'date_format':\n\t\tcase 'time_format':\n\t\tcase 'mailserver_url':\n\t\tcase 'mailserver_login':\n\t\tcase 'mailserver_pass':\n\t\tcase 'upload_path':\n\t\t\t$value = strip_tags( $value );\n\t\t\t$value = wp_kses_data( $value );\n\t\t\tbreak;\n\n\t\tcase 'ping_sites':\n\t\t\t$value = explode( \"\\n\", $value );\n\t\t\t$value = array_filter( array_map( 'trim', $value ) );\n\t\t\t$value = array_filter( array_map( 'esc_url_raw', $value ) );\n\t\t\t$value = implode( \"\\n\", $value );\n\t\t\tbreak;\n\n\t\tcase 'gmt_offset':\n\t\t\t$value = preg_replace('/[^0-9:.-]/', '', $value); // strips slashes\n\t\t\tbreak;\n\n\t\tcase 'siteurl':\n\t\t\tif ( (bool)preg_match( '#http(s?)://(.+)#i', $value) ) {\n\t\t\t\t$value = esc_url_raw($value);\n\t\t\t} else {\n\t\t\t\t$value = get_option( $option ); // Resets option to stored value in the case of failed sanitization\n\t\t\t\tif ( function_exists('add_settings_error') )\n\t\t\t\t\tadd_settings_error('siteurl', 'invalid_siteurl', __('The WordPress address you entered did not appear to be a valid URL. Please enter a valid URL.'));\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase 'home':\n\t\t\tif ( (bool)preg_match( '#http(s?)://(.+)#i', $value) ) {\n\t\t\t\t$value = esc_url_raw($value);\n\t\t\t} else {\n\t\t\t\t$value = get_option( $option ); // Resets option to stored value in the case of failed sanitization\n\t\t\t\tif ( function_exists('add_settings_error') )\n\t\t\t\t\tadd_settings_error('home', 'invalid_home', __('The Site address you entered did not appear to be a valid URL. Please enter a valid URL.'));\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase 'WPLANG':\n\t\t\t$allowed = get_available_languages();\n\t\t\tif ( ! in_array( $value, $allowed ) && ! empty( $value ) )\n\t\t\t\t$value = get_option( $option );\n\t\t\tbreak;\n\n\t\tcase 'illegal_names':\n\t\t\tif ( ! is_array( $value ) )\n\t\t\t\t$value = explode( \"\\n\", $value );\n\n\t\t\t$value = array_values( array_filter( array_map( 'trim', $value ) ) );\n\n\t\t\tif ( ! $value )\n\t\t\t\t$value = '';\n\t\t\tbreak;\n\n\t\tcase 'limited_email_domains':\n\t\tcase 'banned_email_domains':\n\t\t\tif ( ! is_array( $value ) )\n\t\t\t\t$value = explode( \"\\n\", $value );\n\n\t\t\t$domains = array_values( array_filter( array_map( 'trim', $value ) ) );\n\t\t\t$value = array();\n\n\t\t\tforeach ( $domains as $domain ) {\n\t\t\t\tif ( ! preg_match( '/(--|\\.\\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\\.])+$|', $domain ) )\n\t\t\t\t\t$value[] = $domain;\n\t\t\t}\n\t\t\tif ( ! $value )\n\t\t\t\t$value = '';\n\t\t\tbreak;\n\n\t\tcase 'timezone_string':\n\t\t\t$allowed_zones = timezone_identifiers_list();\n\t\t\tif ( ! in_array( $value, $allowed_zones ) && ! empty( $value ) ) {\n\t\t\t\t$value = get_option( $option ); // Resets option to stored value in the case of failed sanitization\n\t\t\t\tif ( function_exists('add_settings_error') )\n\t\t\t\t\tadd_settings_error('timezone_string', 'invalid_timezone_string', __('The timezone you have entered is not valid. Please select a valid timezone.') );\n\t\t\t}\n\t\t\tbreak;\n\n\t\tcase 'permalink_structure':\n\t\tcase 'category_base':\n\t\tcase 'tag_base':\n\t\t\t$value = esc_url_raw( $value );\n\t\t\t$value = str_replace( 'http://', '', $value );\n\t\t\tbreak;\n\t}\n\n\t$value = apply_filters(\"sanitize_option_{$option}\", $value, $option);\n\n\treturn $value;\n}\n\n/**\n * Parses a string into variables to be stored in an array.\n *\n * Uses {@link http://www.php.net/parse_str parse_str()} and stripslashes if\n * {@link http://www.php.net/magic_quotes magic_quotes_gpc} is on.\n *\n * @since 2.2.1\n * @uses apply_filters() for the 'wp_parse_str' filter.\n *\n * @param string $string The string to be parsed.\n * @param array $array Variables will be stored in this array.\n */\nfunction wp_parse_str( $string, &$array ) {\n\tparse_str( $string, $array );\n\tif ( get_magic_quotes_gpc() )\n\t\t$array = stripslashes_deep( $array );\n\t$array = apply_filters( 'wp_parse_str', $array );\n}\n\n/**\n * Convert lone less than signs.\n *\n * KSES already converts lone greater than signs.\n *\n * @uses wp_pre_kses_less_than_callback in the callback function.\n * @since 2.3.0\n *\n * @param string $text Text to be converted.\n * @return string Converted text.\n */\nfunction wp_pre_kses_less_than( $text ) {\n\treturn preg_replace_callback('%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text);\n}\n\n/**\n * Callback function used by preg_replace.\n *\n * @uses esc_html to format the $matches text.\n * @since 2.3.0\n *\n * @param array $matches Populated by matches to preg_replace.\n * @return string The text returned after esc_html if needed.\n */\nfunction wp_pre_kses_less_than_callback( $matches ) {\n\tif ( false === strpos($matches[0], '>') )\n\t\treturn esc_html($matches[0]);\n\treturn $matches[0];\n}\n\n/**\n * WordPress implementation of PHP sprintf() with filters.\n *\n * @since 2.5.0\n * @link http://www.php.net/sprintf\n *\n * @param string $pattern The string which formatted args are inserted.\n * @param mixed $args,... Arguments to be formatted into the $pattern string.\n * @return string The formatted string.\n */\nfunction wp_sprintf( $pattern ) {\n\t$args = func_get_args( );\n\t$len = strlen($pattern);\n\t$start = 0;\n\t$result = '';\n\t$arg_index = 0;\n\twhile ( $len > $start ) {\n\t\t// Last character: append and break\n\t\tif ( strlen($pattern) - 1 == $start ) {\n\t\t\t$result .= substr($pattern, -1);\n\t\t\tbreak;\n\t\t}\n\n\t\t// Literal %: append and continue\n\t\tif ( substr($pattern, $start, 2) == '%%' ) {\n\t\t\t$start += 2;\n\t\t\t$result .= '%';\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Get fragment before next %\n\t\t$end = strpos($pattern, '%', $start + 1);\n\t\tif ( false === $end )\n\t\t\t$end = $len;\n\t\t$fragment = substr($pattern, $start, $end - $start);\n\n\t\t// Fragment has a specifier\n\t\tif ( $pattern[$start] == '%' ) {\n\t\t\t// Find numbered arguments or take the next one in order\n\t\t\tif ( preg_match('/^%(\\d+)\\$/', $fragment, $matches) ) {\n\t\t\t\t$arg = isset($args[$matches[1]]) ? $args[$matches[1]] : '';\n\t\t\t\t$fragment = str_replace(\"%{$matches[1]}$\", '%', $fragment);\n\t\t\t} else {\n\t\t\t\t++$arg_index;\n\t\t\t\t$arg = isset($args[$arg_index]) ? $args[$arg_index] : '';\n\t\t\t}\n\n\t\t\t// Apply filters OR sprintf\n\t\t\t$_fragment = apply_filters( 'wp_sprintf', $fragment, $arg );\n\t\t\tif ( $_fragment != $fragment )\n\t\t\t\t$fragment = $_fragment;\n\t\t\telse\n\t\t\t\t$fragment = sprintf($fragment, strval($arg) );\n\t\t}\n\n\t\t// Append to result and move to next fragment\n\t\t$result .= $fragment;\n\t\t$start = $end;\n\t}\n\treturn $result;\n}\n\n/**\n * Localize list items before the rest of the content.\n *\n * The '%l' must be at the first characters can then contain the rest of the\n * content. The list items will have ', ', ', and', and ' and ' added depending\n * on the amount of list items in the $args parameter.\n *\n * @since 2.5.0\n *\n * @param string $pattern Content containing '%l' at the beginning.\n * @param array $args List items to prepend to the content and replace '%l'.\n * @return string Localized list items and rest of the content.\n */\nfunction wp_sprintf_l($pattern, $args) {\n\t// Not a match\n\tif ( substr($pattern, 0, 2) != '%l' )\n\t\treturn $pattern;\n\n\t// Nothing to work with\n\tif ( empty($args) )\n\t\treturn '';\n\n\t// Translate and filter the delimiter set (avoid ampersands and entities here)\n\t$l = apply_filters('wp_sprintf_l', array(\n\t\t/* translators: used between list items, there is a space after the comma */\n\t\t'between' => __(', '),\n\t\t/* translators: used between list items, there is a space after the and */\n\t\t'between_last_two' => __(', and '),\n\t\t/* translators: used between only two list items, there is a space after the and */\n\t\t'between_only_two' => __(' and '),\n\t\t));\n\n\t$args = (array) $args;\n\t$result = array_shift($args);\n\tif ( count($args) == 1 )\n\t\t$result .= $l['between_only_two'] . array_shift($args);\n\t// Loop when more than two args\n\t$i = count($args);\n\twhile ( $i ) {\n\t\t$arg = array_shift($args);\n\t\t$i--;\n\t\tif ( 0 == $i )\n\t\t\t$result .= $l['between_last_two'] . $arg;\n\t\telse\n\t\t\t$result .= $l['between'] . $arg;\n\t}\n\treturn $result . substr($pattern, 2);\n}\n\n/**\n * Safely extracts not more than the first $count characters from html string.\n *\n * UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT*\n * be counted as one character. For example & will be counted as 4, < as\n * 3, etc.\n *\n * @since 2.5.0\n *\n * @param integer $str String to get the excerpt from.\n * @param integer $count Maximum number of characters to take.\n * @return string The excerpt.\n */\nfunction wp_html_excerpt( $str, $count ) {\n\t$str = wp_strip_all_tags( $str, true );\n\t$str = mb_substr( $str, 0, $count );\n\t// remove part of an entity at the end\n\t$str = preg_replace( '/&[^;\\s]{0,6}$/', '', $str );\n\treturn $str;\n}\n\n/**\n * Add a Base url to relative links in passed content.\n *\n * By default it supports the 'src' and 'href' attributes. However this can be\n * changed via the 3rd param.\n *\n * @since 2.7.0\n *\n * @param string $content String to search for links in.\n * @param string $base The base URL to prefix to links.\n * @param array $attrs The attributes which should be processed.\n * @return string The processed content.\n */\nfunction links_add_base_url( $content, $base, $attrs = array('src', 'href') ) {\n\tglobal $_links_add_base;\n\t$_links_add_base = $base;\n\t$attrs = implode('|', (array)$attrs);\n\treturn preg_replace_callback( \"!($attrs)=(['\\\"])(.+?)\\\\2!i\", '_links_add_base', $content );\n}\n\n/**\n * Callback to add a base url to relative links in passed content.\n *\n * @since 2.7.0\n * @access private\n *\n * @param string $m The matched link.\n * @return string The processed link.\n */\nfunction _links_add_base($m) {\n\tglobal $_links_add_base;\n\t//1 = attribute name 2 = quotation mark 3 = URL\n\treturn $m[1] . '=' . $m[2] .\n\t\t( preg_match( '#^(\\w{1,20}):#', $m[3], $protocol ) && in_array( $protocol[1], wp_allowed_protocols() ) ?\n\t\t\t$m[3] :\n\t\t\tpath_join( $_links_add_base, $m[3] ) )\n\t\t. $m[2];\n}\n\n/**\n * Adds a Target attribute to all links in passed content.\n *\n * This function by default only applies to <a> tags, however this can be\n * modified by the 3rd param.\n *\n * <b>NOTE:</b> Any current target attributed will be stripped and replaced.\n *\n * @since 2.7.0\n *\n * @param string $content String to search for links in.\n * @param string $target The Target to add to the links.\n * @param array $tags An array of tags to apply to.\n * @return string The processed content.\n */\nfunction links_add_target( $content, $target = '_blank', $tags = array('a') ) {\n\tglobal $_links_add_target;\n\t$_links_add_target = $target;\n\t$tags = implode('|', (array)$tags);\n\treturn preg_replace_callback( \"!<($tags)(.+?)>!i\", '_links_add_target', $content );\n}\n\n/**\n * Callback to add a target attribute to all links in passed content.\n *\n * @since 2.7.0\n * @access private\n *\n * @param string $m The matched link.\n * @return string The processed link.\n */\nfunction _links_add_target( $m ) {\n\tglobal $_links_add_target;\n\t$tag = $m[1];\n\t$link = preg_replace('|(target=[\\'\"](.*?)[\\'\"])|i', '', $m[2]);\n\treturn '<' . $tag . $link . ' target=\"' . esc_attr( $_links_add_target ) . '\">';\n}\n\n// normalize EOL characters and strip duplicate whitespace\nfunction normalize_whitespace( $str ) {\n\t$str = trim($str);\n\t$str = str_replace(\"\\r\", \"\\n\", $str);\n\t$str = preg_replace( array( '/\\n+/', '/[ \\t]+/' ), array( \"\\n\", ' ' ), $str );\n\treturn $str;\n}\n\n/**\n * Properly strip all HTML tags including script and style\n *\n * @since 2.9.0\n *\n * @param string $string String containing HTML tags\n * @param bool $remove_breaks optional Whether to remove left over line breaks and white space chars\n * @return string The processed string.\n */\nfunction wp_strip_all_tags($string, $remove_breaks = false) {\n\t$string = preg_replace( '@<(script|style)[^>]*?>.*?</\\\\1>@si', '', $string );\n\t$string = strip_tags($string);\n\n\tif ( $remove_breaks )\n\t\t$string = preg_replace('/[\\r\\n\\t ]+/', ' ', $string);\n\n\treturn trim( $string );\n}\n\n/**\n * Sanitize a string from user input or from the db\n *\n * check for invalid UTF-8,\n * Convert single < characters to entity,\n * strip all tags,\n * remove line breaks, tabs and extra white space,\n * strip octets.\n *\n * @since 2.9.0\n *\n * @param string $str\n * @return string\n */\nfunction sanitize_text_field($str) {\n\t$filtered = wp_check_invalid_utf8( $str );\n\n\tif ( strpos($filtered, '<') !== false ) {\n\t\t$filtered = wp_pre_kses_less_than( $filtered );\n\t\t// This will strip extra whitespace for us.\n\t\t$filtered = wp_strip_all_tags( $filtered, true );\n\t} else {\n\t\t$filtered = trim( preg_replace('/[\\r\\n\\t ]+/', ' ', $filtered) );\n\t}\n\n\t$match = array();\n\t$found = false;\n\twhile ( preg_match('/%[a-f0-9]{2}/i', $filtered, $match) ) {\n\t\t$filtered = str_replace($match[0], '', $filtered);\n\t\t$found = true;\n\t}\n\n\tif ( $found ) {\n\t\t// Strip out the whitespace that may now exist after removing the octets.\n\t\t$filtered = trim( preg_replace('/ +/', ' ', $filtered) );\n\t}\n\n\treturn apply_filters('sanitize_text_field', $filtered, $str);\n}\n\n/**\n * i18n friendly version of basename()\n *\n * @since 3.1.0\n *\n * @param string $path A path.\n * @param string $suffix If the filename ends in suffix this will also be cut off.\n * @return string\n */\nfunction wp_basename( $path, $suffix = '' ) {\n\treturn urldecode( basename( str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) );\n}\n\n/**\n * Forever eliminate \"Wordpress\" from the planet (or at least the little bit we can influence).\n *\n * Violating our coding standards for a good function name.\n *\n * @since 3.0.0\n */\nfunction capital_P_dangit( $text ) {\n\t// Simple replacement for titles\n\tif ( 'the_title' === current_filter() )\n\t\treturn str_replace( 'Wordpress', 'WordPress', $text );\n\t// Still here? Use the more judicious replacement\n\tstatic $dblq = false;\n\tif ( false === $dblq )\n\t\t$dblq = _x( '“', 'opening curly double quote' );\n\treturn str_replace(\n\t\tarray( ' Wordpress', '‘Wordpress', $dblq . 'Wordpress', '>Wordpress', '(Wordpress' ),\n\t\tarray( ' WordPress', '‘WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ),\n\t$text );\n\n}\n\n/**\n * Sanitize a mime type\n *\n * @since 3.1.3\n *\n * @param string $mime_type Mime type\n * @return string Sanitized mime type\n */\nfunction sanitize_mime_type( $mime_type ) {\n\t$sani_mime_type = preg_replace( '/[^-+*.a-zA-Z0-9\\/]/', '', $mime_type );\n\treturn apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type );\n}\n\n/**\n * Sanitize space or carriage return separated URLs that are used to send trackbacks.\n *\n * @since 3.4.0\n *\n * @param string $to_ping Space or carriage return separated URLs\n * @return string URLs starting with the http or https protocol, separated by a carriage return.\n */\nfunction sanitize_trackback_urls( $to_ping ) {\n\t$urls_to_ping = preg_split( '/[\\r\\n\\t ]/', trim( $to_ping ), -1, PREG_SPLIT_NO_EMPTY );\n\tforeach ( $urls_to_ping as $k => $url ) {\n\t\tif ( !preg_match( '#^https?://.#i', $url ) )\n\t\t\tunset( $urls_to_ping[$k] );\n\t}\n\t$urls_to_ping = array_map( 'esc_url_raw', $urls_to_ping );\n\t$urls_to_ping = implode( \"\\n\", $urls_to_ping );\n\treturn apply_filters( 'sanitize_trackback_urls', $urls_to_ping, $to_ping );\n}\n
|
|
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | /** |
1037 | | * Santizes a html classname to ensure it only contains valid characters |
| 1037 | * Sanitizes a html classname to ensure it only contains valid characters |
1038 | 1038 | * |
1039 | 1039 | * Strips the string down to A-Z,a-z,0-9,_,-. If this results in an empty |
1040 | 1040 | * string then it will return the alternative value supplied. |