Edit File by line
/home/barbar84/www/wp-inclu...
File: formatting.php
// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
[2000] Fix | Delete
$utf8_pcre = @preg_match( '/^./u', 'a' );
[2001] Fix | Delete
}
[2002] Fix | Delete
[2003] Fix | Delete
if ( ! seems_utf8( $filename ) ) {
[2004] Fix | Delete
$_ext = pathinfo( $filename, PATHINFO_EXTENSION );
[2005] Fix | Delete
$_name = pathinfo( $filename, PATHINFO_FILENAME );
[2006] Fix | Delete
$filename = sanitize_title_with_dashes( $_name ) . '.' . $_ext;
[2007] Fix | Delete
}
[2008] Fix | Delete
[2009] Fix | Delete
if ( $utf8_pcre ) {
[2010] Fix | Delete
$filename = preg_replace( "#\x{00a0}#siu", ' ', $filename );
[2011] Fix | Delete
}
[2012] Fix | Delete
[2013] Fix | Delete
/**
[2014] Fix | Delete
* Filters the list of characters to remove from a filename.
[2015] Fix | Delete
*
[2016] Fix | Delete
* @since 2.8.0
[2017] Fix | Delete
*
[2018] Fix | Delete
* @param string[] $special_chars Array of characters to remove.
[2019] Fix | Delete
* @param string $filename_raw The original filename to be sanitized.
[2020] Fix | Delete
*/
[2021] Fix | Delete
$special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw );
[2022] Fix | Delete
[2023] Fix | Delete
$filename = str_replace( $special_chars, '', $filename );
[2024] Fix | Delete
$filename = str_replace( array( '%20', '+' ), '-', $filename );
[2025] Fix | Delete
$filename = preg_replace( '/[\r\n\t -]+/', '-', $filename );
[2026] Fix | Delete
$filename = trim( $filename, '.-_' );
[2027] Fix | Delete
[2028] Fix | Delete
if ( false === strpos( $filename, '.' ) ) {
[2029] Fix | Delete
$mime_types = wp_get_mime_types();
[2030] Fix | Delete
$filetype = wp_check_filetype( 'test.' . $filename, $mime_types );
[2031] Fix | Delete
if ( $filetype['ext'] === $filename ) {
[2032] Fix | Delete
$filename = 'unnamed-file.' . $filetype['ext'];
[2033] Fix | Delete
}
[2034] Fix | Delete
}
[2035] Fix | Delete
[2036] Fix | Delete
// Split the filename into a base and extension[s].
[2037] Fix | Delete
$parts = explode( '.', $filename );
[2038] Fix | Delete
[2039] Fix | Delete
// Return if only one extension.
[2040] Fix | Delete
if ( count( $parts ) <= 2 ) {
[2041] Fix | Delete
/** This filter is documented in wp-includes/formatting.php */
[2042] Fix | Delete
return apply_filters( 'sanitize_file_name', $filename, $filename_raw );
[2043] Fix | Delete
}
[2044] Fix | Delete
[2045] Fix | Delete
// Process multiple extensions.
[2046] Fix | Delete
$filename = array_shift( $parts );
[2047] Fix | Delete
$extension = array_pop( $parts );
[2048] Fix | Delete
$mimes = get_allowed_mime_types();
[2049] Fix | Delete
[2050] Fix | Delete
/*
[2051] Fix | Delete
* Loop over any intermediate extensions. Postfix them with a trailing underscore
[2052] Fix | Delete
* if they are a 2 - 5 character long alpha string not in the allowed extension list.
[2053] Fix | Delete
*/
[2054] Fix | Delete
foreach ( (array) $parts as $part ) {
[2055] Fix | Delete
$filename .= '.' . $part;
[2056] Fix | Delete
[2057] Fix | Delete
if ( preg_match( '/^[a-zA-Z]{2,5}\d?$/', $part ) ) {
[2058] Fix | Delete
$allowed = false;
[2059] Fix | Delete
foreach ( $mimes as $ext_preg => $mime_match ) {
[2060] Fix | Delete
$ext_preg = '!^(' . $ext_preg . ')$!i';
[2061] Fix | Delete
if ( preg_match( $ext_preg, $part ) ) {
[2062] Fix | Delete
$allowed = true;
[2063] Fix | Delete
break;
[2064] Fix | Delete
}
[2065] Fix | Delete
}
[2066] Fix | Delete
if ( ! $allowed ) {
[2067] Fix | Delete
$filename .= '_';
[2068] Fix | Delete
}
[2069] Fix | Delete
}
[2070] Fix | Delete
}
[2071] Fix | Delete
[2072] Fix | Delete
$filename .= '.' . $extension;
[2073] Fix | Delete
[2074] Fix | Delete
/**
[2075] Fix | Delete
* Filters a sanitized filename string.
[2076] Fix | Delete
*
[2077] Fix | Delete
* @since 2.8.0
[2078] Fix | Delete
*
[2079] Fix | Delete
* @param string $filename Sanitized filename.
[2080] Fix | Delete
* @param string $filename_raw The filename prior to sanitization.
[2081] Fix | Delete
*/
[2082] Fix | Delete
return apply_filters( 'sanitize_file_name', $filename, $filename_raw );
[2083] Fix | Delete
}
[2084] Fix | Delete
[2085] Fix | Delete
/**
[2086] Fix | Delete
* Sanitizes a username, stripping out unsafe characters.
[2087] Fix | Delete
*
[2088] Fix | Delete
* Removes tags, octets, entities, and if strict is enabled, will only keep
[2089] Fix | Delete
* alphanumeric, _, space, ., -, @. After sanitizing, it passes the username,
[2090] Fix | Delete
* raw username (the username in the parameter), and the value of $strict as
[2091] Fix | Delete
* parameters for the {@see 'sanitize_user'} filter.
[2092] Fix | Delete
*
[2093] Fix | Delete
* @since 2.0.0
[2094] Fix | Delete
*
[2095] Fix | Delete
* @param string $username The username to be sanitized.
[2096] Fix | Delete
* @param bool $strict Optional. If set limits $username to specific characters.
[2097] Fix | Delete
* Default false.
[2098] Fix | Delete
* @return string The sanitized username, after passing through filters.
[2099] Fix | Delete
*/
[2100] Fix | Delete
function sanitize_user( $username, $strict = false ) {
[2101] Fix | Delete
$raw_username = $username;
[2102] Fix | Delete
$username = wp_strip_all_tags( $username );
[2103] Fix | Delete
$username = remove_accents( $username );
[2104] Fix | Delete
// Kill octets.
[2105] Fix | Delete
$username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username );
[2106] Fix | Delete
// Kill entities.
[2107] Fix | Delete
$username = preg_replace( '/&.+?;/', '', $username );
[2108] Fix | Delete
[2109] Fix | Delete
// If strict, reduce to ASCII for max portability.
[2110] Fix | Delete
if ( $strict ) {
[2111] Fix | Delete
$username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username );
[2112] Fix | Delete
}
[2113] Fix | Delete
[2114] Fix | Delete
$username = trim( $username );
[2115] Fix | Delete
// Consolidate contiguous whitespace.
[2116] Fix | Delete
$username = preg_replace( '|\s+|', ' ', $username );
[2117] Fix | Delete
[2118] Fix | Delete
/**
[2119] Fix | Delete
* Filters a sanitized username string.
[2120] Fix | Delete
*
[2121] Fix | Delete
* @since 2.0.1
[2122] Fix | Delete
*
[2123] Fix | Delete
* @param string $username Sanitized username.
[2124] Fix | Delete
* @param string $raw_username The username prior to sanitization.
[2125] Fix | Delete
* @param bool $strict Whether to limit the sanitization to specific characters.
[2126] Fix | Delete
*/
[2127] Fix | Delete
return apply_filters( 'sanitize_user', $username, $raw_username, $strict );
[2128] Fix | Delete
}
[2129] Fix | Delete
[2130] Fix | Delete
/**
[2131] Fix | Delete
* Sanitizes a string key.
[2132] Fix | Delete
*
[2133] Fix | Delete
* Keys are used as internal identifiers. Lowercase alphanumeric characters,
[2134] Fix | Delete
* dashes, and underscores are allowed.
[2135] Fix | Delete
*
[2136] Fix | Delete
* @since 3.0.0
[2137] Fix | Delete
*
[2138] Fix | Delete
* @param string $key String key
[2139] Fix | Delete
* @return string Sanitized key
[2140] Fix | Delete
*/
[2141] Fix | Delete
function sanitize_key( $key ) {
[2142] Fix | Delete
$raw_key = $key;
[2143] Fix | Delete
$key = strtolower( $key );
[2144] Fix | Delete
$key = preg_replace( '/[^a-z0-9_\-]/', '', $key );
[2145] Fix | Delete
[2146] Fix | Delete
/**
[2147] Fix | Delete
* Filters a sanitized key string.
[2148] Fix | Delete
*
[2149] Fix | Delete
* @since 3.0.0
[2150] Fix | Delete
*
[2151] Fix | Delete
* @param string $key Sanitized key.
[2152] Fix | Delete
* @param string $raw_key The key prior to sanitization.
[2153] Fix | Delete
*/
[2154] Fix | Delete
return apply_filters( 'sanitize_key', $key, $raw_key );
[2155] Fix | Delete
}
[2156] Fix | Delete
[2157] Fix | Delete
/**
[2158] Fix | Delete
* Sanitizes a string into a slug, which can be used in URLs or HTML attributes.
[2159] Fix | Delete
*
[2160] Fix | Delete
* By default, converts accent characters to ASCII characters and further
[2161] Fix | Delete
* limits the output to alphanumeric characters, underscore (_) and dash (-)
[2162] Fix | Delete
* through the {@see 'sanitize_title'} filter.
[2163] Fix | Delete
*
[2164] Fix | Delete
* If `$title` is empty and `$fallback_title` is set, the latter will be used.
[2165] Fix | Delete
*
[2166] Fix | Delete
* @since 1.0.0
[2167] Fix | Delete
*
[2168] Fix | Delete
* @param string $title The string to be sanitized.
[2169] Fix | Delete
* @param string $fallback_title Optional. A title to use if $title is empty. Default empty.
[2170] Fix | Delete
* @param string $context Optional. The operation for which the string is sanitized.
[2171] Fix | Delete
* When set to 'save', the string runs through remove_accents().
[2172] Fix | Delete
* Default 'save'.
[2173] Fix | Delete
* @return string The sanitized string.
[2174] Fix | Delete
*/
[2175] Fix | Delete
function sanitize_title( $title, $fallback_title = '', $context = 'save' ) {
[2176] Fix | Delete
$raw_title = $title;
[2177] Fix | Delete
[2178] Fix | Delete
if ( 'save' === $context ) {
[2179] Fix | Delete
$title = remove_accents( $title );
[2180] Fix | Delete
}
[2181] Fix | Delete
[2182] Fix | Delete
/**
[2183] Fix | Delete
* Filters a sanitized title string.
[2184] Fix | Delete
*
[2185] Fix | Delete
* @since 1.2.0
[2186] Fix | Delete
*
[2187] Fix | Delete
* @param string $title Sanitized title.
[2188] Fix | Delete
* @param string $raw_title The title prior to sanitization.
[2189] Fix | Delete
* @param string $context The context for which the title is being sanitized.
[2190] Fix | Delete
*/
[2191] Fix | Delete
$title = apply_filters( 'sanitize_title', $title, $raw_title, $context );
[2192] Fix | Delete
[2193] Fix | Delete
if ( '' === $title || false === $title ) {
[2194] Fix | Delete
$title = $fallback_title;
[2195] Fix | Delete
}
[2196] Fix | Delete
[2197] Fix | Delete
return $title;
[2198] Fix | Delete
}
[2199] Fix | Delete
[2200] Fix | Delete
/**
[2201] Fix | Delete
* Sanitizes a title with the 'query' context.
[2202] Fix | Delete
*
[2203] Fix | Delete
* Used for querying the database for a value from URL.
[2204] Fix | Delete
*
[2205] Fix | Delete
* @since 3.1.0
[2206] Fix | Delete
*
[2207] Fix | Delete
* @param string $title The string to be sanitized.
[2208] Fix | Delete
* @return string The sanitized string.
[2209] Fix | Delete
*/
[2210] Fix | Delete
function sanitize_title_for_query( $title ) {
[2211] Fix | Delete
return sanitize_title( $title, '', 'query' );
[2212] Fix | Delete
}
[2213] Fix | Delete
[2214] Fix | Delete
/**
[2215] Fix | Delete
* Sanitizes a title, replacing whitespace and a few other characters with dashes.
[2216] Fix | Delete
*
[2217] Fix | Delete
* Limits the output to alphanumeric characters, underscore (_) and dash (-).
[2218] Fix | Delete
* Whitespace becomes a dash.
[2219] Fix | Delete
*
[2220] Fix | Delete
* @since 1.2.0
[2221] Fix | Delete
*
[2222] Fix | Delete
* @param string $title The title to be sanitized.
[2223] Fix | Delete
* @param string $raw_title Optional. Not used. Default empty.
[2224] Fix | Delete
* @param string $context Optional. The operation for which the string is sanitized.
[2225] Fix | Delete
* When set to 'save', additional entities are converted to hyphens
[2226] Fix | Delete
* or stripped entirely. Default 'display'.
[2227] Fix | Delete
* @return string The sanitized title.
[2228] Fix | Delete
*/
[2229] Fix | Delete
function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'display' ) {
[2230] Fix | Delete
$title = strip_tags( $title );
[2231] Fix | Delete
// Preserve escaped octets.
[2232] Fix | Delete
$title = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title );
[2233] Fix | Delete
// Remove percent signs that are not part of an octet.
[2234] Fix | Delete
$title = str_replace( '%', '', $title );
[2235] Fix | Delete
// Restore octets.
[2236] Fix | Delete
$title = preg_replace( '|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title );
[2237] Fix | Delete
[2238] Fix | Delete
if ( seems_utf8( $title ) ) {
[2239] Fix | Delete
if ( function_exists( 'mb_strtolower' ) ) {
[2240] Fix | Delete
$title = mb_strtolower( $title, 'UTF-8' );
[2241] Fix | Delete
}
[2242] Fix | Delete
$title = utf8_uri_encode( $title, 200 );
[2243] Fix | Delete
}
[2244] Fix | Delete
[2245] Fix | Delete
$title = strtolower( $title );
[2246] Fix | Delete
[2247] Fix | Delete
if ( 'save' === $context ) {
[2248] Fix | Delete
// Convert &nbsp, &ndash, and &mdash to hyphens.
[2249] Fix | Delete
$title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title );
[2250] Fix | Delete
// Convert &nbsp, &ndash, and &mdash HTML entities to hyphens.
[2251] Fix | Delete
$title = str_replace( array( '&nbsp;', '&#160;', '&ndash;', '&#8211;', '&mdash;', '&#8212;' ), '-', $title );
[2252] Fix | Delete
// Convert forward slash to hyphen.
[2253] Fix | Delete
$title = str_replace( '/', '-', $title );
[2254] Fix | Delete
[2255] Fix | Delete
// Strip these characters entirely.
[2256] Fix | Delete
$title = str_replace(
[2257] Fix | Delete
array(
[2258] Fix | Delete
// Soft hyphens.
[2259] Fix | Delete
'%c2%ad',
[2260] Fix | Delete
// &iexcl and &iquest.
[2261] Fix | Delete
'%c2%a1',
[2262] Fix | Delete
'%c2%bf',
[2263] Fix | Delete
// Angle quotes.
[2264] Fix | Delete
'%c2%ab',
[2265] Fix | Delete
'%c2%bb',
[2266] Fix | Delete
'%e2%80%b9',
[2267] Fix | Delete
'%e2%80%ba',
[2268] Fix | Delete
// Curly quotes.
[2269] Fix | Delete
'%e2%80%98',
[2270] Fix | Delete
'%e2%80%99',
[2271] Fix | Delete
'%e2%80%9c',
[2272] Fix | Delete
'%e2%80%9d',
[2273] Fix | Delete
'%e2%80%9a',
[2274] Fix | Delete
'%e2%80%9b',
[2275] Fix | Delete
'%e2%80%9e',
[2276] Fix | Delete
'%e2%80%9f',
[2277] Fix | Delete
// Bullet.
[2278] Fix | Delete
'%e2%80%a2',
[2279] Fix | Delete
// &copy, &reg, &deg, &hellip, and &trade.
[2280] Fix | Delete
'%c2%a9',
[2281] Fix | Delete
'%c2%ae',
[2282] Fix | Delete
'%c2%b0',
[2283] Fix | Delete
'%e2%80%a6',
[2284] Fix | Delete
'%e2%84%a2',
[2285] Fix | Delete
// Acute accents.
[2286] Fix | Delete
'%c2%b4',
[2287] Fix | Delete
'%cb%8a',
[2288] Fix | Delete
'%cc%81',
[2289] Fix | Delete
'%cd%81',
[2290] Fix | Delete
// Grave accent, macron, caron.
[2291] Fix | Delete
'%cc%80',
[2292] Fix | Delete
'%cc%84',
[2293] Fix | Delete
'%cc%8c',
[2294] Fix | Delete
),
[2295] Fix | Delete
'',
[2296] Fix | Delete
$title
[2297] Fix | Delete
);
[2298] Fix | Delete
[2299] Fix | Delete
// Convert &times to 'x'.
[2300] Fix | Delete
$title = str_replace( '%c3%97', 'x', $title );
[2301] Fix | Delete
}
[2302] Fix | Delete
[2303] Fix | Delete
// Kill entities.
[2304] Fix | Delete
$title = preg_replace( '/&.+?;/', '', $title );
[2305] Fix | Delete
$title = str_replace( '.', '-', $title );
[2306] Fix | Delete
[2307] Fix | Delete
$title = preg_replace( '/[^%a-z0-9 _-]/', '', $title );
[2308] Fix | Delete
$title = preg_replace( '/\s+/', '-', $title );
[2309] Fix | Delete
$title = preg_replace( '|-+|', '-', $title );
[2310] Fix | Delete
$title = trim( $title, '-' );
[2311] Fix | Delete
[2312] Fix | Delete
return $title;
[2313] Fix | Delete
}
[2314] Fix | Delete
[2315] Fix | Delete
/**
[2316] Fix | Delete
* Ensures a string is a valid SQL 'order by' clause.
[2317] Fix | Delete
*
[2318] Fix | Delete
* Accepts one or more columns, with or without a sort order (ASC / DESC).
[2319] Fix | Delete
* e.g. 'column_1', 'column_1, column_2', 'column_1 ASC, column_2 DESC' etc.
[2320] Fix | Delete
*
[2321] Fix | Delete
* Also accepts 'RAND()'.
[2322] Fix | Delete
*
[2323] Fix | Delete
* @since 2.5.1
[2324] Fix | Delete
*
[2325] Fix | Delete
* @param string $orderby Order by clause to be validated.
[2326] Fix | Delete
* @return string|false Returns $orderby if valid, false otherwise.
[2327] Fix | Delete
*/
[2328] Fix | Delete
function sanitize_sql_orderby( $orderby ) {
[2329] Fix | Delete
if ( preg_match( '/^\s*(([a-z0-9_]+|`[a-z0-9_]+`)(\s+(ASC|DESC))?\s*(,\s*(?=[a-z0-9_`])|$))+$/i', $orderby ) || preg_match( '/^\s*RAND\(\s*\)\s*$/i', $orderby ) ) {
[2330] Fix | Delete
return $orderby;
[2331] Fix | Delete
}
[2332] Fix | Delete
return false;
[2333] Fix | Delete
}
[2334] Fix | Delete
[2335] Fix | Delete
/**
[2336] Fix | Delete
* Sanitizes an HTML classname to ensure it only contains valid characters.
[2337] Fix | Delete
*
[2338] Fix | Delete
* Strips the string down to A-Z,a-z,0-9,_,-. If this results in an empty
[2339] Fix | Delete
* string then it will return the alternative value supplied.
[2340] Fix | Delete
*
[2341] Fix | Delete
* @todo Expand to support the full range of CDATA that a class attribute can contain.
[2342] Fix | Delete
*
[2343] Fix | Delete
* @since 2.8.0
[2344] Fix | Delete
*
[2345] Fix | Delete
* @param string $class The classname to be sanitized
[2346] Fix | Delete
* @param string $fallback Optional. The value to return if the sanitization ends up as an empty string.
[2347] Fix | Delete
* Defaults to an empty string.
[2348] Fix | Delete
* @return string The sanitized value
[2349] Fix | Delete
*/
[2350] Fix | Delete
function sanitize_html_class( $class, $fallback = '' ) {
[2351] Fix | Delete
// Strip out any %-encoded octets.
[2352] Fix | Delete
$sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $class );
[2353] Fix | Delete
[2354] Fix | Delete
// Limit to A-Z, a-z, 0-9, '_', '-'.
[2355] Fix | Delete
$sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized );
[2356] Fix | Delete
[2357] Fix | Delete
if ( '' === $sanitized && $fallback ) {
[2358] Fix | Delete
return sanitize_html_class( $fallback );
[2359] Fix | Delete
}
[2360] Fix | Delete
/**
[2361] Fix | Delete
* Filters a sanitized HTML class string.
[2362] Fix | Delete
*
[2363] Fix | Delete
* @since 2.8.0
[2364] Fix | Delete
*
[2365] Fix | Delete
* @param string $sanitized The sanitized HTML class.
[2366] Fix | Delete
* @param string $class HTML class before sanitization.
[2367] Fix | Delete
* @param string $fallback The fallback string.
[2368] Fix | Delete
*/
[2369] Fix | Delete
return apply_filters( 'sanitize_html_class', $sanitized, $class, $fallback );
[2370] Fix | Delete
}
[2371] Fix | Delete
[2372] Fix | Delete
/**
[2373] Fix | Delete
* Strips out all characters not allowed in a locale name.
[2374] Fix | Delete
*
[2375] Fix | Delete
* @since 6.2.1
[2376] Fix | Delete
*
[2377] Fix | Delete
* @param string $locale_name The locale name to be sanitized.
[2378] Fix | Delete
* @return string The sanitized value.
[2379] Fix | Delete
*/
[2380] Fix | Delete
function sanitize_locale_name( $locale_name ) {
[2381] Fix | Delete
// Limit to A-Z, a-z, 0-9, '_', '-'.
[2382] Fix | Delete
$sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $locale_name );
[2383] Fix | Delete
[2384] Fix | Delete
/**
[2385] Fix | Delete
* Filters a sanitized locale name string.
[2386] Fix | Delete
*
[2387] Fix | Delete
* @since 6.2.1
[2388] Fix | Delete
*
[2389] Fix | Delete
* @param string $sanitized The sanitized locale name.
[2390] Fix | Delete
* @param string $locale_name The locale name before sanitization.
[2391] Fix | Delete
*/
[2392] Fix | Delete
return apply_filters( 'sanitize_locale_name', $sanitized, $locale_name );
[2393] Fix | Delete
}
[2394] Fix | Delete
[2395] Fix | Delete
/**
[2396] Fix | Delete
* Converts lone & characters into `&#038;` (a.k.a. `&amp;`)
[2397] Fix | Delete
*
[2398] Fix | Delete
* @since 0.71
[2399] Fix | Delete
*
[2400] Fix | Delete
* @param string $content String of characters to be converted.
[2401] Fix | Delete
* @param string $deprecated Not used.
[2402] Fix | Delete
* @return string Converted string.
[2403] Fix | Delete
*/
[2404] Fix | Delete
function convert_chars( $content, $deprecated = '' ) {
[2405] Fix | Delete
if ( ! empty( $deprecated ) ) {
[2406] Fix | Delete
_deprecated_argument( __FUNCTION__, '0.71' );
[2407] Fix | Delete
}
[2408] Fix | Delete
[2409] Fix | Delete
if ( strpos( $content, '&' ) !== false ) {
[2410] Fix | Delete
$content = preg_replace( '/&([^#])(?![a-z1-4]{1,8};)/i', '&#038;$1', $content );
[2411] Fix | Delete
}
[2412] Fix | Delete
[2413] Fix | Delete
return $content;
[2414] Fix | Delete
}
[2415] Fix | Delete
[2416] Fix | Delete
/**
[2417] Fix | Delete
* Converts invalid Unicode references range to valid range.
[2418] Fix | Delete
*
[2419] Fix | Delete
* @since 4.3.0
[2420] Fix | Delete
*
[2421] Fix | Delete
* @param string $content String with entities that need converting.
[2422] Fix | Delete
* @return string Converted string.
[2423] Fix | Delete
*/
[2424] Fix | Delete
function convert_invalid_entities( $content ) {
[2425] Fix | Delete
$wp_htmltranswinuni = array(
[2426] Fix | Delete
'&#128;' => '&#8364;', // The Euro sign.
[2427] Fix | Delete
'&#129;' => '',
[2428] Fix | Delete
'&#130;' => '&#8218;', // These are Windows CP1252 specific characters.
[2429] Fix | Delete
'&#131;' => '&#402;', // They would look weird on non-Windows browsers.
[2430] Fix | Delete
'&#132;' => '&#8222;',
[2431] Fix | Delete
'&#133;' => '&#8230;',
[2432] Fix | Delete
'&#134;' => '&#8224;',
[2433] Fix | Delete
'&#135;' => '&#8225;',
[2434] Fix | Delete
'&#136;' => '&#710;',
[2435] Fix | Delete
'&#137;' => '&#8240;',
[2436] Fix | Delete
'&#138;' => '&#352;',
[2437] Fix | Delete
'&#139;' => '&#8249;',
[2438] Fix | Delete
'&#140;' => '&#338;',
[2439] Fix | Delete
'&#141;' => '',
[2440] Fix | Delete
'&#142;' => '&#381;',
[2441] Fix | Delete
'&#143;' => '',
[2442] Fix | Delete
'&#144;' => '',
[2443] Fix | Delete
'&#145;' => '&#8216;',
[2444] Fix | Delete
'&#146;' => '&#8217;',
[2445] Fix | Delete
'&#147;' => '&#8220;',
[2446] Fix | Delete
'&#148;' => '&#8221;',
[2447] Fix | Delete
'&#149;' => '&#8226;',
[2448] Fix | Delete
'&#150;' => '&#8211;',
[2449] Fix | Delete
'&#151;' => '&#8212;',
[2450] Fix | Delete
'&#152;' => '&#732;',
[2451] Fix | Delete
'&#153;' => '&#8482;',
[2452] Fix | Delete
'&#154;' => '&#353;',
[2453] Fix | Delete
'&#155;' => '&#8250;',
[2454] Fix | Delete
'&#156;' => '&#339;',
[2455] Fix | Delete
'&#157;' => '',
[2456] Fix | Delete
'&#158;' => '&#382;',
[2457] Fix | Delete
'&#159;' => '&#376;',
[2458] Fix | Delete
);
[2459] Fix | Delete
[2460] Fix | Delete
if ( strpos( $content, '&#1' ) !== false ) {
[2461] Fix | Delete
$content = strtr( $content, $wp_htmltranswinuni );
[2462] Fix | Delete
}
[2463] Fix | Delete
[2464] Fix | Delete
return $content;
[2465] Fix | Delete
}
[2466] Fix | Delete
[2467] Fix | Delete
/**
[2468] Fix | Delete
* Balances tags if forced to, or if the 'use_balanceTags' option is set to true.
[2469] Fix | Delete
*
[2470] Fix | Delete
* @since 0.71
[2471] Fix | Delete
*
[2472] Fix | Delete
* @param string $text Text to be balanced
[2473] Fix | Delete
* @param bool $force If true, forces balancing, ignoring the value of the option. Default false.
[2474] Fix | Delete
* @return string Balanced text
[2475] Fix | Delete
*/
[2476] Fix | Delete
function balanceTags( $text, $force = false ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
[2477] Fix | Delete
if ( $force || (int) get_option( 'use_balanceTags' ) === 1 ) {
[2478] Fix | Delete
return force_balance_tags( $text );
[2479] Fix | Delete
} else {
[2480] Fix | Delete
return $text;
[2481] Fix | Delete
}
[2482] Fix | Delete
}
[2483] Fix | Delete
[2484] Fix | Delete
/**
[2485] Fix | Delete
* Balances tags of string using a modified stack.
[2486] Fix | Delete
*
[2487] Fix | Delete
* @since 2.0.4
[2488] Fix | Delete
* @since 5.3.0 Improve accuracy and add support for custom element tags.
[2489] Fix | Delete
*
[2490] Fix | Delete
* @author Leonard Lin <leonard@acm.org>
[2491] Fix | Delete
* @license GPL
[2492] Fix | Delete
* @copyright November 4, 2001
[2493] Fix | Delete
* @version 1.1
[2494] Fix | Delete
* @todo Make better - change loop condition to $text in 1.2
[2495] Fix | Delete
* @internal Modified by Scott Reilly (coffee2code) 02 Aug 2004
[2496] Fix | Delete
* 1.1 Fixed handling of append/stack pop order of end text
[2497] Fix | Delete
* Added Cleaning Hooks
[2498] Fix | Delete
* 1.0 First Version
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function