Edit File by line
/home/barbar84/www/wp-inclu...
File: formatting.php
/**
[5000] Fix | Delete
* Callback function used by preg_replace.
[5001] Fix | Delete
*
[5002] Fix | Delete
* @since 2.3.0
[5003] Fix | Delete
*
[5004] Fix | Delete
* @param array $matches Populated by matches to preg_replace.
[5005] Fix | Delete
* @return string The text returned after esc_html if needed.
[5006] Fix | Delete
*/
[5007] Fix | Delete
function wp_pre_kses_less_than_callback( $matches ) {
[5008] Fix | Delete
if ( false === strpos( $matches[0], '>' ) ) {
[5009] Fix | Delete
return esc_html( $matches[0] );
[5010] Fix | Delete
}
[5011] Fix | Delete
return $matches[0];
[5012] Fix | Delete
}
[5013] Fix | Delete
[5014] Fix | Delete
/**
[5015] Fix | Delete
* Remove non-allowable HTML from parsed block attribute values when filtering
[5016] Fix | Delete
* in the post context.
[5017] Fix | Delete
*
[5018] Fix | Delete
* @since 5.3.1
[5019] Fix | Delete
*
[5020] Fix | Delete
* @param string $string Content to be run through KSES.
[5021] Fix | Delete
* @param array[]|string $allowed_html An array of allowed HTML elements
[5022] Fix | Delete
* and attributes, or a context name
[5023] Fix | Delete
* such as 'post'.
[5024] Fix | Delete
* @param string[] $allowed_protocols Array of allowed URL protocols.
[5025] Fix | Delete
* @return string Filtered text to run through KSES.
[5026] Fix | Delete
*/
[5027] Fix | Delete
function wp_pre_kses_block_attributes( $string, $allowed_html, $allowed_protocols ) {
[5028] Fix | Delete
/*
[5029] Fix | Delete
* `filter_block_content` is expected to call `wp_kses`. Temporarily remove
[5030] Fix | Delete
* the filter to avoid recursion.
[5031] Fix | Delete
*/
[5032] Fix | Delete
remove_filter( 'pre_kses', 'wp_pre_kses_block_attributes', 10 );
[5033] Fix | Delete
$string = filter_block_content( $string, $allowed_html, $allowed_protocols );
[5034] Fix | Delete
add_filter( 'pre_kses', 'wp_pre_kses_block_attributes', 10, 3 );
[5035] Fix | Delete
[5036] Fix | Delete
return $string;
[5037] Fix | Delete
}
[5038] Fix | Delete
[5039] Fix | Delete
/**
[5040] Fix | Delete
* WordPress implementation of PHP sprintf() with filters.
[5041] Fix | Delete
*
[5042] Fix | Delete
* @since 2.5.0
[5043] Fix | Delete
* @since 5.3.0 Formalized the existing and already documented `...$args` parameter
[5044] Fix | Delete
* by adding it to the function signature.
[5045] Fix | Delete
*
[5046] Fix | Delete
* @link https://www.php.net/sprintf
[5047] Fix | Delete
*
[5048] Fix | Delete
* @param string $pattern The string which formatted args are inserted.
[5049] Fix | Delete
* @param mixed ...$args Arguments to be formatted into the $pattern string.
[5050] Fix | Delete
* @return string The formatted string.
[5051] Fix | Delete
*/
[5052] Fix | Delete
function wp_sprintf( $pattern, ...$args ) {
[5053] Fix | Delete
$len = strlen( $pattern );
[5054] Fix | Delete
$start = 0;
[5055] Fix | Delete
$result = '';
[5056] Fix | Delete
$arg_index = 0;
[5057] Fix | Delete
while ( $len > $start ) {
[5058] Fix | Delete
// Last character: append and break.
[5059] Fix | Delete
if ( strlen( $pattern ) - 1 == $start ) {
[5060] Fix | Delete
$result .= substr( $pattern, -1 );
[5061] Fix | Delete
break;
[5062] Fix | Delete
}
[5063] Fix | Delete
[5064] Fix | Delete
// Literal %: append and continue.
[5065] Fix | Delete
if ( '%%' === substr( $pattern, $start, 2 ) ) {
[5066] Fix | Delete
$start += 2;
[5067] Fix | Delete
$result .= '%';
[5068] Fix | Delete
continue;
[5069] Fix | Delete
}
[5070] Fix | Delete
[5071] Fix | Delete
// Get fragment before next %.
[5072] Fix | Delete
$end = strpos( $pattern, '%', $start + 1 );
[5073] Fix | Delete
if ( false === $end ) {
[5074] Fix | Delete
$end = $len;
[5075] Fix | Delete
}
[5076] Fix | Delete
$fragment = substr( $pattern, $start, $end - $start );
[5077] Fix | Delete
[5078] Fix | Delete
// Fragment has a specifier.
[5079] Fix | Delete
if ( '%' === $pattern[ $start ] ) {
[5080] Fix | Delete
// Find numbered arguments or take the next one in order.
[5081] Fix | Delete
if ( preg_match( '/^%(\d+)\$/', $fragment, $matches ) ) {
[5082] Fix | Delete
$index = $matches[1] - 1; // 0-based array vs 1-based sprintf() arguments.
[5083] Fix | Delete
$arg = isset( $args[ $index ] ) ? $args[ $index ] : '';
[5084] Fix | Delete
$fragment = str_replace( "%{$matches[1]}$", '%', $fragment );
[5085] Fix | Delete
} else {
[5086] Fix | Delete
$arg = isset( $args[ $arg_index ] ) ? $args[ $arg_index ] : '';
[5087] Fix | Delete
++$arg_index;
[5088] Fix | Delete
}
[5089] Fix | Delete
[5090] Fix | Delete
/**
[5091] Fix | Delete
* Filters a fragment from the pattern passed to wp_sprintf().
[5092] Fix | Delete
*
[5093] Fix | Delete
* If the fragment is unchanged, then sprintf() will be run on the fragment.
[5094] Fix | Delete
*
[5095] Fix | Delete
* @since 2.5.0
[5096] Fix | Delete
*
[5097] Fix | Delete
* @param string $fragment A fragment from the pattern.
[5098] Fix | Delete
* @param string $arg The argument.
[5099] Fix | Delete
*/
[5100] Fix | Delete
$_fragment = apply_filters( 'wp_sprintf', $fragment, $arg );
[5101] Fix | Delete
if ( $_fragment != $fragment ) {
[5102] Fix | Delete
$fragment = $_fragment;
[5103] Fix | Delete
} else {
[5104] Fix | Delete
$fragment = sprintf( $fragment, (string) $arg );
[5105] Fix | Delete
}
[5106] Fix | Delete
}
[5107] Fix | Delete
[5108] Fix | Delete
// Append to result and move to next fragment.
[5109] Fix | Delete
$result .= $fragment;
[5110] Fix | Delete
$start = $end;
[5111] Fix | Delete
}
[5112] Fix | Delete
[5113] Fix | Delete
return $result;
[5114] Fix | Delete
}
[5115] Fix | Delete
[5116] Fix | Delete
/**
[5117] Fix | Delete
* Localize list items before the rest of the content.
[5118] Fix | Delete
*
[5119] Fix | Delete
* The '%l' must be at the first characters can then contain the rest of the
[5120] Fix | Delete
* content. The list items will have ', ', ', and', and ' and ' added depending
[5121] Fix | Delete
* on the amount of list items in the $args parameter.
[5122] Fix | Delete
*
[5123] Fix | Delete
* @since 2.5.0
[5124] Fix | Delete
*
[5125] Fix | Delete
* @param string $pattern Content containing '%l' at the beginning.
[5126] Fix | Delete
* @param array $args List items to prepend to the content and replace '%l'.
[5127] Fix | Delete
* @return string Localized list items and rest of the content.
[5128] Fix | Delete
*/
[5129] Fix | Delete
function wp_sprintf_l( $pattern, $args ) {
[5130] Fix | Delete
// Not a match.
[5131] Fix | Delete
if ( '%l' !== substr( $pattern, 0, 2 ) ) {
[5132] Fix | Delete
return $pattern;
[5133] Fix | Delete
}
[5134] Fix | Delete
[5135] Fix | Delete
// Nothing to work with.
[5136] Fix | Delete
if ( empty( $args ) ) {
[5137] Fix | Delete
return '';
[5138] Fix | Delete
}
[5139] Fix | Delete
[5140] Fix | Delete
/**
[5141] Fix | Delete
* Filters the translated delimiters used by wp_sprintf_l().
[5142] Fix | Delete
* Placeholders (%s) are included to assist translators and then
[5143] Fix | Delete
* removed before the array of strings reaches the filter.
[5144] Fix | Delete
*
[5145] Fix | Delete
* Please note: Ampersands and entities should be avoided here.
[5146] Fix | Delete
*
[5147] Fix | Delete
* @since 2.5.0
[5148] Fix | Delete
*
[5149] Fix | Delete
* @param array $delimiters An array of translated delimiters.
[5150] Fix | Delete
*/
[5151] Fix | Delete
$l = apply_filters(
[5152] Fix | Delete
'wp_sprintf_l',
[5153] Fix | Delete
array(
[5154] Fix | Delete
/* translators: Used to join items in a list with more than 2 items. */
[5155] Fix | Delete
'between' => sprintf( __( '%1$s, %2$s' ), '', '' ),
[5156] Fix | Delete
/* translators: Used to join last two items in a list with more than 2 times. */
[5157] Fix | Delete
'between_last_two' => sprintf( __( '%1$s, and %2$s' ), '', '' ),
[5158] Fix | Delete
/* translators: Used to join items in a list with only 2 items. */
[5159] Fix | Delete
'between_only_two' => sprintf( __( '%1$s and %2$s' ), '', '' ),
[5160] Fix | Delete
)
[5161] Fix | Delete
);
[5162] Fix | Delete
[5163] Fix | Delete
$args = (array) $args;
[5164] Fix | Delete
$result = array_shift( $args );
[5165] Fix | Delete
if ( count( $args ) == 1 ) {
[5166] Fix | Delete
$result .= $l['between_only_two'] . array_shift( $args );
[5167] Fix | Delete
}
[5168] Fix | Delete
[5169] Fix | Delete
// Loop when more than two args.
[5170] Fix | Delete
$i = count( $args );
[5171] Fix | Delete
while ( $i ) {
[5172] Fix | Delete
$arg = array_shift( $args );
[5173] Fix | Delete
$i--;
[5174] Fix | Delete
if ( 0 == $i ) {
[5175] Fix | Delete
$result .= $l['between_last_two'] . $arg;
[5176] Fix | Delete
} else {
[5177] Fix | Delete
$result .= $l['between'] . $arg;
[5178] Fix | Delete
}
[5179] Fix | Delete
}
[5180] Fix | Delete
[5181] Fix | Delete
return $result . substr( $pattern, 2 );
[5182] Fix | Delete
}
[5183] Fix | Delete
[5184] Fix | Delete
/**
[5185] Fix | Delete
* Safely extracts not more than the first $count characters from HTML string.
[5186] Fix | Delete
*
[5187] Fix | Delete
* UTF-8, tags and entities safe prefix extraction. Entities inside will *NOT*
[5188] Fix | Delete
* be counted as one character. For example & will be counted as 4, < as
[5189] Fix | Delete
* 3, etc.
[5190] Fix | Delete
*
[5191] Fix | Delete
* @since 2.5.0
[5192] Fix | Delete
*
[5193] Fix | Delete
* @param string $str String to get the excerpt from.
[5194] Fix | Delete
* @param int $count Maximum number of characters to take.
[5195] Fix | Delete
* @param string $more Optional. What to append if $str needs to be trimmed. Defaults to empty string.
[5196] Fix | Delete
* @return string The excerpt.
[5197] Fix | Delete
*/
[5198] Fix | Delete
function wp_html_excerpt( $str, $count, $more = null ) {
[5199] Fix | Delete
if ( null === $more ) {
[5200] Fix | Delete
$more = '';
[5201] Fix | Delete
}
[5202] Fix | Delete
[5203] Fix | Delete
$str = wp_strip_all_tags( $str, true );
[5204] Fix | Delete
$excerpt = mb_substr( $str, 0, $count );
[5205] Fix | Delete
[5206] Fix | Delete
// Remove part of an entity at the end.
[5207] Fix | Delete
$excerpt = preg_replace( '/&[^;\s]{0,6}$/', '', $excerpt );
[5208] Fix | Delete
if ( $str != $excerpt ) {
[5209] Fix | Delete
$excerpt = trim( $excerpt ) . $more;
[5210] Fix | Delete
}
[5211] Fix | Delete
[5212] Fix | Delete
return $excerpt;
[5213] Fix | Delete
}
[5214] Fix | Delete
[5215] Fix | Delete
/**
[5216] Fix | Delete
* Add a Base url to relative links in passed content.
[5217] Fix | Delete
*
[5218] Fix | Delete
* By default it supports the 'src' and 'href' attributes. However this can be
[5219] Fix | Delete
* changed via the 3rd param.
[5220] Fix | Delete
*
[5221] Fix | Delete
* @since 2.7.0
[5222] Fix | Delete
*
[5223] Fix | Delete
* @global string $_links_add_base
[5224] Fix | Delete
*
[5225] Fix | Delete
* @param string $content String to search for links in.
[5226] Fix | Delete
* @param string $base The base URL to prefix to links.
[5227] Fix | Delete
* @param array $attrs The attributes which should be processed.
[5228] Fix | Delete
* @return string The processed content.
[5229] Fix | Delete
*/
[5230] Fix | Delete
function links_add_base_url( $content, $base, $attrs = array( 'src', 'href' ) ) {
[5231] Fix | Delete
global $_links_add_base;
[5232] Fix | Delete
$_links_add_base = $base;
[5233] Fix | Delete
$attrs = implode( '|', (array) $attrs );
[5234] Fix | Delete
return preg_replace_callback( "!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content );
[5235] Fix | Delete
}
[5236] Fix | Delete
[5237] Fix | Delete
/**
[5238] Fix | Delete
* Callback to add a base url to relative links in passed content.
[5239] Fix | Delete
*
[5240] Fix | Delete
* @since 2.7.0
[5241] Fix | Delete
* @access private
[5242] Fix | Delete
*
[5243] Fix | Delete
* @global string $_links_add_base
[5244] Fix | Delete
*
[5245] Fix | Delete
* @param string $m The matched link.
[5246] Fix | Delete
* @return string The processed link.
[5247] Fix | Delete
*/
[5248] Fix | Delete
function _links_add_base( $m ) {
[5249] Fix | Delete
global $_links_add_base;
[5250] Fix | Delete
// 1 = attribute name 2 = quotation mark 3 = URL.
[5251] Fix | Delete
return $m[1] . '=' . $m[2] .
[5252] Fix | Delete
( preg_match( '#^(\w{1,20}):#', $m[3], $protocol ) && in_array( $protocol[1], wp_allowed_protocols(), true ) ?
[5253] Fix | Delete
$m[3] :
[5254] Fix | Delete
WP_Http::make_absolute_url( $m[3], $_links_add_base )
[5255] Fix | Delete
)
[5256] Fix | Delete
. $m[2];
[5257] Fix | Delete
}
[5258] Fix | Delete
[5259] Fix | Delete
/**
[5260] Fix | Delete
* Adds a Target attribute to all links in passed content.
[5261] Fix | Delete
*
[5262] Fix | Delete
* This function by default only applies to `<a>` tags, however this can be
[5263] Fix | Delete
* modified by the 3rd param.
[5264] Fix | Delete
*
[5265] Fix | Delete
* *NOTE:* Any current target attributed will be stripped and replaced.
[5266] Fix | Delete
*
[5267] Fix | Delete
* @since 2.7.0
[5268] Fix | Delete
*
[5269] Fix | Delete
* @global string $_links_add_target
[5270] Fix | Delete
*
[5271] Fix | Delete
* @param string $content String to search for links in.
[5272] Fix | Delete
* @param string $target The Target to add to the links.
[5273] Fix | Delete
* @param string[] $tags An array of tags to apply to.
[5274] Fix | Delete
* @return string The processed content.
[5275] Fix | Delete
*/
[5276] Fix | Delete
function links_add_target( $content, $target = '_blank', $tags = array( 'a' ) ) {
[5277] Fix | Delete
global $_links_add_target;
[5278] Fix | Delete
$_links_add_target = $target;
[5279] Fix | Delete
$tags = implode( '|', (array) $tags );
[5280] Fix | Delete
return preg_replace_callback( "!<($tags)((\s[^>]*)?)>!i", '_links_add_target', $content );
[5281] Fix | Delete
}
[5282] Fix | Delete
[5283] Fix | Delete
/**
[5284] Fix | Delete
* Callback to add a target attribute to all links in passed content.
[5285] Fix | Delete
*
[5286] Fix | Delete
* @since 2.7.0
[5287] Fix | Delete
* @access private
[5288] Fix | Delete
*
[5289] Fix | Delete
* @global string $_links_add_target
[5290] Fix | Delete
*
[5291] Fix | Delete
* @param string $m The matched link.
[5292] Fix | Delete
* @return string The processed link.
[5293] Fix | Delete
*/
[5294] Fix | Delete
function _links_add_target( $m ) {
[5295] Fix | Delete
global $_links_add_target;
[5296] Fix | Delete
$tag = $m[1];
[5297] Fix | Delete
$link = preg_replace( '|( target=([\'"])(.*?)\2)|i', '', $m[2] );
[5298] Fix | Delete
return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">';
[5299] Fix | Delete
}
[5300] Fix | Delete
[5301] Fix | Delete
/**
[5302] Fix | Delete
* Normalize EOL characters and strip duplicate whitespace.
[5303] Fix | Delete
*
[5304] Fix | Delete
* @since 2.7.0
[5305] Fix | Delete
*
[5306] Fix | Delete
* @param string $str The string to normalize.
[5307] Fix | Delete
* @return string The normalized string.
[5308] Fix | Delete
*/
[5309] Fix | Delete
function normalize_whitespace( $str ) {
[5310] Fix | Delete
$str = trim( $str );
[5311] Fix | Delete
$str = str_replace( "\r", "\n", $str );
[5312] Fix | Delete
$str = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str );
[5313] Fix | Delete
return $str;
[5314] Fix | Delete
}
[5315] Fix | Delete
[5316] Fix | Delete
/**
[5317] Fix | Delete
* Properly strip all HTML tags including script and style
[5318] Fix | Delete
*
[5319] Fix | Delete
* This differs from strip_tags() because it removes the contents of
[5320] Fix | Delete
* the `<script>` and `<style>` tags. E.g. `strip_tags( '<script>something</script>' )`
[5321] Fix | Delete
* will return 'something'. wp_strip_all_tags will return ''
[5322] Fix | Delete
*
[5323] Fix | Delete
* @since 2.9.0
[5324] Fix | Delete
*
[5325] Fix | Delete
* @param string $string String containing HTML tags
[5326] Fix | Delete
* @param bool $remove_breaks Optional. Whether to remove left over line breaks and white space chars
[5327] Fix | Delete
* @return string The processed string.
[5328] Fix | Delete
*/
[5329] Fix | Delete
function wp_strip_all_tags( $string, $remove_breaks = false ) {
[5330] Fix | Delete
$string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );
[5331] Fix | Delete
$string = strip_tags( $string );
[5332] Fix | Delete
[5333] Fix | Delete
if ( $remove_breaks ) {
[5334] Fix | Delete
$string = preg_replace( '/[\r\n\t ]+/', ' ', $string );
[5335] Fix | Delete
}
[5336] Fix | Delete
[5337] Fix | Delete
return trim( $string );
[5338] Fix | Delete
}
[5339] Fix | Delete
[5340] Fix | Delete
/**
[5341] Fix | Delete
* Sanitizes a string from user input or from the database.
[5342] Fix | Delete
*
[5343] Fix | Delete
* - Checks for invalid UTF-8,
[5344] Fix | Delete
* - Converts single `<` characters to entities
[5345] Fix | Delete
* - Strips all tags
[5346] Fix | Delete
* - Removes line breaks, tabs, and extra whitespace
[5347] Fix | Delete
* - Strips octets
[5348] Fix | Delete
*
[5349] Fix | Delete
* @since 2.9.0
[5350] Fix | Delete
*
[5351] Fix | Delete
* @see sanitize_textarea_field()
[5352] Fix | Delete
* @see wp_check_invalid_utf8()
[5353] Fix | Delete
* @see wp_strip_all_tags()
[5354] Fix | Delete
*
[5355] Fix | Delete
* @param string $str String to sanitize.
[5356] Fix | Delete
* @return string Sanitized string.
[5357] Fix | Delete
*/
[5358] Fix | Delete
function sanitize_text_field( $str ) {
[5359] Fix | Delete
$filtered = _sanitize_text_fields( $str, false );
[5360] Fix | Delete
[5361] Fix | Delete
/**
[5362] Fix | Delete
* Filters a sanitized text field string.
[5363] Fix | Delete
*
[5364] Fix | Delete
* @since 2.9.0
[5365] Fix | Delete
*
[5366] Fix | Delete
* @param string $filtered The sanitized string.
[5367] Fix | Delete
* @param string $str The string prior to being sanitized.
[5368] Fix | Delete
*/
[5369] Fix | Delete
return apply_filters( 'sanitize_text_field', $filtered, $str );
[5370] Fix | Delete
}
[5371] Fix | Delete
[5372] Fix | Delete
/**
[5373] Fix | Delete
* Sanitizes a multiline string from user input or from the database.
[5374] Fix | Delete
*
[5375] Fix | Delete
* The function is like sanitize_text_field(), but preserves
[5376] Fix | Delete
* new lines (\n) and other whitespace, which are legitimate
[5377] Fix | Delete
* input in textarea elements.
[5378] Fix | Delete
*
[5379] Fix | Delete
* @see sanitize_text_field()
[5380] Fix | Delete
*
[5381] Fix | Delete
* @since 4.7.0
[5382] Fix | Delete
*
[5383] Fix | Delete
* @param string $str String to sanitize.
[5384] Fix | Delete
* @return string Sanitized string.
[5385] Fix | Delete
*/
[5386] Fix | Delete
function sanitize_textarea_field( $str ) {
[5387] Fix | Delete
$filtered = _sanitize_text_fields( $str, true );
[5388] Fix | Delete
[5389] Fix | Delete
/**
[5390] Fix | Delete
* Filters a sanitized textarea field string.
[5391] Fix | Delete
*
[5392] Fix | Delete
* @since 4.7.0
[5393] Fix | Delete
*
[5394] Fix | Delete
* @param string $filtered The sanitized string.
[5395] Fix | Delete
* @param string $str The string prior to being sanitized.
[5396] Fix | Delete
*/
[5397] Fix | Delete
return apply_filters( 'sanitize_textarea_field', $filtered, $str );
[5398] Fix | Delete
}
[5399] Fix | Delete
[5400] Fix | Delete
/**
[5401] Fix | Delete
* Internal helper function to sanitize a string from user input or from the db
[5402] Fix | Delete
*
[5403] Fix | Delete
* @since 4.7.0
[5404] Fix | Delete
* @access private
[5405] Fix | Delete
*
[5406] Fix | Delete
* @param string $str String to sanitize.
[5407] Fix | Delete
* @param bool $keep_newlines Optional. Whether to keep newlines. Default: false.
[5408] Fix | Delete
* @return string Sanitized string.
[5409] Fix | Delete
*/
[5410] Fix | Delete
function _sanitize_text_fields( $str, $keep_newlines = false ) {
[5411] Fix | Delete
if ( is_object( $str ) || is_array( $str ) ) {
[5412] Fix | Delete
return '';
[5413] Fix | Delete
}
[5414] Fix | Delete
[5415] Fix | Delete
$str = (string) $str;
[5416] Fix | Delete
[5417] Fix | Delete
$filtered = wp_check_invalid_utf8( $str );
[5418] Fix | Delete
[5419] Fix | Delete
if ( strpos( $filtered, '<' ) !== false ) {
[5420] Fix | Delete
$filtered = wp_pre_kses_less_than( $filtered );
[5421] Fix | Delete
// This will strip extra whitespace for us.
[5422] Fix | Delete
$filtered = wp_strip_all_tags( $filtered, false );
[5423] Fix | Delete
[5424] Fix | Delete
// Use HTML entities in a special case to make sure no later
[5425] Fix | Delete
// newline stripping stage could lead to a functional tag.
[5426] Fix | Delete
$filtered = str_replace( "<\n", "&lt;\n", $filtered );
[5427] Fix | Delete
}
[5428] Fix | Delete
[5429] Fix | Delete
if ( ! $keep_newlines ) {
[5430] Fix | Delete
$filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered );
[5431] Fix | Delete
}
[5432] Fix | Delete
$filtered = trim( $filtered );
[5433] Fix | Delete
[5434] Fix | Delete
$found = false;
[5435] Fix | Delete
while ( preg_match( '/%[a-f0-9]{2}/i', $filtered, $match ) ) {
[5436] Fix | Delete
$filtered = str_replace( $match[0], '', $filtered );
[5437] Fix | Delete
$found = true;
[5438] Fix | Delete
}
[5439] Fix | Delete
[5440] Fix | Delete
if ( $found ) {
[5441] Fix | Delete
// Strip out the whitespace that may now exist after removing the octets.
[5442] Fix | Delete
$filtered = trim( preg_replace( '/ +/', ' ', $filtered ) );
[5443] Fix | Delete
}
[5444] Fix | Delete
[5445] Fix | Delete
return $filtered;
[5446] Fix | Delete
}
[5447] Fix | Delete
[5448] Fix | Delete
/**
[5449] Fix | Delete
* i18n friendly version of basename()
[5450] Fix | Delete
*
[5451] Fix | Delete
* @since 3.1.0
[5452] Fix | Delete
*
[5453] Fix | Delete
* @param string $path A path.
[5454] Fix | Delete
* @param string $suffix If the filename ends in suffix this will also be cut off.
[5455] Fix | Delete
* @return string
[5456] Fix | Delete
*/
[5457] Fix | Delete
function wp_basename( $path, $suffix = '' ) {
[5458] Fix | Delete
return urldecode( basename( str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) );
[5459] Fix | Delete
}
[5460] Fix | Delete
[5461] Fix | Delete
// phpcs:disable WordPress.WP.CapitalPDangit.Misspelled, WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid -- 8-)
[5462] Fix | Delete
/**
[5463] Fix | Delete
* Forever eliminate "Wordpress" from the planet (or at least the little bit we can influence).
[5464] Fix | Delete
*
[5465] Fix | Delete
* Violating our coding standards for a good function name.
[5466] Fix | Delete
*
[5467] Fix | Delete
* @since 3.0.0
[5468] Fix | Delete
*
[5469] Fix | Delete
* @param string $text The text to be modified.
[5470] Fix | Delete
* @return string The modified text.
[5471] Fix | Delete
*/
[5472] Fix | Delete
function capital_P_dangit( $text ) {
[5473] Fix | Delete
// Simple replacement for titles.
[5474] Fix | Delete
$current_filter = current_filter();
[5475] Fix | Delete
if ( 'the_title' === $current_filter || 'wp_title' === $current_filter ) {
[5476] Fix | Delete
return str_replace( 'Wordpress', 'WordPress', $text );
[5477] Fix | Delete
}
[5478] Fix | Delete
// Still here? Use the more judicious replacement.
[5479] Fix | Delete
static $dblq = false;
[5480] Fix | Delete
if ( false === $dblq ) {
[5481] Fix | Delete
$dblq = _x( '&#8220;', 'opening curly double quote' );
[5482] Fix | Delete
}
[5483] Fix | Delete
return str_replace(
[5484] Fix | Delete
array( ' Wordpress', '&#8216;Wordpress', $dblq . 'Wordpress', '>Wordpress', '(Wordpress' ),
[5485] Fix | Delete
array( ' WordPress', '&#8216;WordPress', $dblq . 'WordPress', '>WordPress', '(WordPress' ),
[5486] Fix | Delete
$text
[5487] Fix | Delete
);
[5488] Fix | Delete
}
[5489] Fix | Delete
// phpcs:enable
[5490] Fix | Delete
[5491] Fix | Delete
/**
[5492] Fix | Delete
* Sanitize a mime type
[5493] Fix | Delete
*
[5494] Fix | Delete
* @since 3.1.3
[5495] Fix | Delete
*
[5496] Fix | Delete
* @param string $mime_type Mime type
[5497] Fix | Delete
* @return string Sanitized mime type
[5498] Fix | Delete
*/
[5499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function