Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-inclu...
File: class-wp-token-map.php
*
[500] Fix | Delete
* Example:
[501] Fix | Delete
*
[502] Fix | Delete
* while ( $at < strlen( $input ) ) {
[503] Fix | Delete
* $next_at = strpos( $input, ':', $at );
[504] Fix | Delete
* if ( false === $next_at ) {
[505] Fix | Delete
* break;
[506] Fix | Delete
* }
[507] Fix | Delete
*
[508] Fix | Delete
* $smily = $smilies->read_token( $input, $next_at, $token_byte_length );
[509] Fix | Delete
* if ( false === $next_at ) {
[510] Fix | Delete
* ++$at;
[511] Fix | Delete
* continue;
[512] Fix | Delete
* }
[513] Fix | Delete
*
[514] Fix | Delete
* $prefix = substr( $input, $at, $next_at - $at );
[515] Fix | Delete
* $at += $token_byte_length;
[516] Fix | Delete
* $output .= "{$prefix}{$smily}";
[517] Fix | Delete
* }
[518] Fix | Delete
*
[519] Fix | Delete
* @since 6.6.0
[520] Fix | Delete
*
[521] Fix | Delete
* @param string $text String in which to search for a lookup key.
[522] Fix | Delete
* @param int $offset Optional. How many bytes into the string where the lookup key ought to start. Default 0.
[523] Fix | Delete
* @param ?int &$matched_token_byte_length Optional. Holds byte-length of found token matched, otherwise not set. Default null.
[524] Fix | Delete
* @param string $case_sensitivity Optional. Pass 'ascii-case-insensitive' to ignore ASCII case when matching. Default 'case-sensitive'.
[525] Fix | Delete
* @return string|null Mapped value of lookup key if found, otherwise `null`.
[526] Fix | Delete
*/
[527] Fix | Delete
public function read_token( $text, $offset = 0, &$matched_token_byte_length = null, $case_sensitivity = 'case-sensitive' ) {
[528] Fix | Delete
$ignore_case = 'ascii-case-insensitive' === $case_sensitivity;
[529] Fix | Delete
$text_length = strlen( $text );
[530] Fix | Delete
[531] Fix | Delete
// Search for a long word first, if the text is long enough, and if that fails, a short one.
[532] Fix | Delete
if ( $text_length > $this->key_length ) {
[533] Fix | Delete
$group_key = substr( $text, $offset, $this->key_length );
[534] Fix | Delete
[535] Fix | Delete
$group_at = $ignore_case ? stripos( $this->groups, $group_key ) : strpos( $this->groups, $group_key );
[536] Fix | Delete
if ( false === $group_at ) {
[537] Fix | Delete
// Perhaps a short word then.
[538] Fix | Delete
return strlen( $this->small_words ) > 0
[539] Fix | Delete
? $this->read_small_token( $text, $offset, $matched_token_byte_length, $case_sensitivity )
[540] Fix | Delete
: null;
[541] Fix | Delete
}
[542] Fix | Delete
[543] Fix | Delete
$group = $this->large_words[ $group_at / ( $this->key_length + 1 ) ];
[544] Fix | Delete
$group_length = strlen( $group );
[545] Fix | Delete
$at = 0;
[546] Fix | Delete
while ( $at < $group_length ) {
[547] Fix | Delete
$token_length = unpack( 'C', $group[ $at++ ] )[1];
[548] Fix | Delete
$token = substr( $group, $at, $token_length );
[549] Fix | Delete
$at += $token_length;
[550] Fix | Delete
$mapping_length = unpack( 'C', $group[ $at++ ] )[1];
[551] Fix | Delete
$mapping_at = $at;
[552] Fix | Delete
[553] Fix | Delete
if ( 0 === substr_compare( $text, $token, $offset + $this->key_length, $token_length, $ignore_case ) ) {
[554] Fix | Delete
$matched_token_byte_length = $this->key_length + $token_length;
[555] Fix | Delete
return substr( $group, $mapping_at, $mapping_length );
[556] Fix | Delete
}
[557] Fix | Delete
[558] Fix | Delete
$at = $mapping_at + $mapping_length;
[559] Fix | Delete
}
[560] Fix | Delete
}
[561] Fix | Delete
[562] Fix | Delete
// Perhaps a short word then.
[563] Fix | Delete
return strlen( $this->small_words ) > 0
[564] Fix | Delete
? $this->read_small_token( $text, $offset, $matched_token_byte_length, $case_sensitivity )
[565] Fix | Delete
: null;
[566] Fix | Delete
}
[567] Fix | Delete
[568] Fix | Delete
/**
[569] Fix | Delete
* Finds a match for a short word at the index.
[570] Fix | Delete
*
[571] Fix | Delete
* @since 6.6.0.
[572] Fix | Delete
*
[573] Fix | Delete
* @param string $text String in which to search for a lookup key.
[574] Fix | Delete
* @param int $offset Optional. How many bytes into the string where the lookup key ought to start. Default 0.
[575] Fix | Delete
* @param ?int &$matched_token_byte_length Optional. Holds byte-length of found lookup key if matched, otherwise not set. Default null.
[576] Fix | Delete
* @param string $case_sensitivity Optional. Pass 'ascii-case-insensitive' to ignore ASCII case when matching. Default 'case-sensitive'.
[577] Fix | Delete
* @return string|null Mapped value of lookup key if found, otherwise `null`.
[578] Fix | Delete
*/
[579] Fix | Delete
private function read_small_token( $text, $offset, &$matched_token_byte_length, $case_sensitivity = 'case-sensitive' ) {
[580] Fix | Delete
$ignore_case = 'ascii-case-insensitive' === $case_sensitivity;
[581] Fix | Delete
$small_length = strlen( $this->small_words );
[582] Fix | Delete
$search_text = substr( $text, $offset, $this->key_length );
[583] Fix | Delete
if ( $ignore_case ) {
[584] Fix | Delete
$search_text = strtoupper( $search_text );
[585] Fix | Delete
}
[586] Fix | Delete
$starting_char = $search_text[0];
[587] Fix | Delete
[588] Fix | Delete
$at = 0;
[589] Fix | Delete
while ( $at < $small_length ) {
[590] Fix | Delete
if (
[591] Fix | Delete
$starting_char !== $this->small_words[ $at ] &&
[592] Fix | Delete
( ! $ignore_case || strtoupper( $this->small_words[ $at ] ) !== $starting_char )
[593] Fix | Delete
) {
[594] Fix | Delete
$at += $this->key_length + 1;
[595] Fix | Delete
continue;
[596] Fix | Delete
}
[597] Fix | Delete
[598] Fix | Delete
for ( $adjust = 1; $adjust < $this->key_length; $adjust++ ) {
[599] Fix | Delete
if ( "\x00" === $this->small_words[ $at + $adjust ] ) {
[600] Fix | Delete
$matched_token_byte_length = $adjust;
[601] Fix | Delete
return $this->small_mappings[ $at / ( $this->key_length + 1 ) ];
[602] Fix | Delete
}
[603] Fix | Delete
[604] Fix | Delete
if (
[605] Fix | Delete
$search_text[ $adjust ] !== $this->small_words[ $at + $adjust ] &&
[606] Fix | Delete
( ! $ignore_case || strtoupper( $this->small_words[ $at + $adjust ] !== $search_text[ $adjust ] ) )
[607] Fix | Delete
) {
[608] Fix | Delete
$at += $this->key_length + 1;
[609] Fix | Delete
continue 2;
[610] Fix | Delete
}
[611] Fix | Delete
}
[612] Fix | Delete
[613] Fix | Delete
$matched_token_byte_length = $adjust;
[614] Fix | Delete
return $this->small_mappings[ $at / ( $this->key_length + 1 ) ];
[615] Fix | Delete
}
[616] Fix | Delete
[617] Fix | Delete
return null;
[618] Fix | Delete
}
[619] Fix | Delete
[620] Fix | Delete
/**
[621] Fix | Delete
* Exports the token map into an associate array of key/value pairs.
[622] Fix | Delete
*
[623] Fix | Delete
* Example:
[624] Fix | Delete
*
[625] Fix | Delete
* $smilies->to_array() === array(
[626] Fix | Delete
* '8O' => '😯',
[627] Fix | Delete
* ':(' => '🙁',
[628] Fix | Delete
* ':)' => '🙂',
[629] Fix | Delete
* ':?' => '😕',
[630] Fix | Delete
* );
[631] Fix | Delete
*
[632] Fix | Delete
* @return array The lookup key/substitution values as an associate array.
[633] Fix | Delete
*/
[634] Fix | Delete
public function to_array() {
[635] Fix | Delete
$tokens = array();
[636] Fix | Delete
[637] Fix | Delete
$at = 0;
[638] Fix | Delete
$small_mapping = 0;
[639] Fix | Delete
$small_length = strlen( $this->small_words );
[640] Fix | Delete
while ( $at < $small_length ) {
[641] Fix | Delete
$key = rtrim( substr( $this->small_words, $at, $this->key_length + 1 ), "\x00" );
[642] Fix | Delete
$value = $this->small_mappings[ $small_mapping++ ];
[643] Fix | Delete
$tokens[ $key ] = $value;
[644] Fix | Delete
[645] Fix | Delete
$at += $this->key_length + 1;
[646] Fix | Delete
}
[647] Fix | Delete
[648] Fix | Delete
foreach ( $this->large_words as $index => $group ) {
[649] Fix | Delete
$prefix = substr( $this->groups, $index * ( $this->key_length + 1 ), 2 );
[650] Fix | Delete
$group_length = strlen( $group );
[651] Fix | Delete
$at = 0;
[652] Fix | Delete
while ( $at < $group_length ) {
[653] Fix | Delete
$length = unpack( 'C', $group[ $at++ ] )[1];
[654] Fix | Delete
$key = $prefix . substr( $group, $at, $length );
[655] Fix | Delete
[656] Fix | Delete
$at += $length;
[657] Fix | Delete
$length = unpack( 'C', $group[ $at++ ] )[1];
[658] Fix | Delete
$value = substr( $group, $at, $length );
[659] Fix | Delete
[660] Fix | Delete
$tokens[ $key ] = $value;
[661] Fix | Delete
$at += $length;
[662] Fix | Delete
}
[663] Fix | Delete
}
[664] Fix | Delete
[665] Fix | Delete
return $tokens;
[666] Fix | Delete
}
[667] Fix | Delete
[668] Fix | Delete
/**
[669] Fix | Delete
* Export the token map for quick loading in PHP source code.
[670] Fix | Delete
*
[671] Fix | Delete
* This function has a specific purpose, to make loading of static token maps fast.
[672] Fix | Delete
* It's used to ensure that the HTML character reference lookups add a minimal cost
[673] Fix | Delete
* to initializing the PHP process.
[674] Fix | Delete
*
[675] Fix | Delete
* Example:
[676] Fix | Delete
*
[677] Fix | Delete
* echo $smilies->precomputed_php_source_table();
[678] Fix | Delete
*
[679] Fix | Delete
* // Output.
[680] Fix | Delete
* WP_Token_Map::from_precomputed_table(
[681] Fix | Delete
* array(
[682] Fix | Delete
* "storage_version" => "6.6.0",
[683] Fix | Delete
* "key_length" => 2,
[684] Fix | Delete
* "groups" => "",
[685] Fix | Delete
* "long_words" => array(),
[686] Fix | Delete
* "small_words" => "8O\x00:)\x00:(\x00:?\x00",
[687] Fix | Delete
* "small_mappings" => array( "😯", "🙂", "🙁", "😕" )
[688] Fix | Delete
* )
[689] Fix | Delete
* );
[690] Fix | Delete
*
[691] Fix | Delete
* @since 6.6.0
[692] Fix | Delete
*
[693] Fix | Delete
* @param string $indent Optional. Use this string for indentation, or rely on the default horizontal tab character. Default "\t".
[694] Fix | Delete
* @return string Value which can be pasted into a PHP source file for quick loading of table.
[695] Fix | Delete
*/
[696] Fix | Delete
public function precomputed_php_source_table( $indent = "\t" ) {
[697] Fix | Delete
$i1 = $indent;
[698] Fix | Delete
$i2 = $i1 . $indent;
[699] Fix | Delete
$i3 = $i2 . $indent;
[700] Fix | Delete
[701] Fix | Delete
$class_version = self::STORAGE_VERSION;
[702] Fix | Delete
[703] Fix | Delete
$output = self::class . "::from_precomputed_table(\n";
[704] Fix | Delete
$output .= "{$i1}array(\n";
[705] Fix | Delete
$output .= "{$i2}\"storage_version\" => \"{$class_version}\",\n";
[706] Fix | Delete
$output .= "{$i2}\"key_length\" => {$this->key_length},\n";
[707] Fix | Delete
[708] Fix | Delete
$group_line = str_replace( "\x00", "\\x00", $this->groups );
[709] Fix | Delete
$output .= "{$i2}\"groups\" => \"{$group_line}\",\n";
[710] Fix | Delete
[711] Fix | Delete
$output .= "{$i2}\"large_words\" => array(\n";
[712] Fix | Delete
[713] Fix | Delete
$prefixes = explode( "\x00", $this->groups );
[714] Fix | Delete
foreach ( $prefixes as $index => $prefix ) {
[715] Fix | Delete
if ( '' === $prefix ) {
[716] Fix | Delete
break;
[717] Fix | Delete
}
[718] Fix | Delete
$group = $this->large_words[ $index ];
[719] Fix | Delete
$group_length = strlen( $group );
[720] Fix | Delete
$comment_line = "{$i3}//";
[721] Fix | Delete
$data_line = "{$i3}\"";
[722] Fix | Delete
$at = 0;
[723] Fix | Delete
while ( $at < $group_length ) {
[724] Fix | Delete
$token_length = unpack( 'C', $group[ $at++ ] )[1];
[725] Fix | Delete
$token = substr( $group, $at, $token_length );
[726] Fix | Delete
$at += $token_length;
[727] Fix | Delete
$mapping_length = unpack( 'C', $group[ $at++ ] )[1];
[728] Fix | Delete
$mapping = substr( $group, $at, $mapping_length );
[729] Fix | Delete
$at += $mapping_length;
[730] Fix | Delete
[731] Fix | Delete
$token_digits = str_pad( dechex( $token_length ), 2, '0', STR_PAD_LEFT );
[732] Fix | Delete
$mapping_digits = str_pad( dechex( $mapping_length ), 2, '0', STR_PAD_LEFT );
[733] Fix | Delete
[734] Fix | Delete
$mapping = preg_replace_callback(
[735] Fix | Delete
"~[\\x00-\\x1f\\x22\\x5c]~",
[736] Fix | Delete
static function ( $match_result ) {
[737] Fix | Delete
switch ( $match_result[0] ) {
[738] Fix | Delete
case '"':
[739] Fix | Delete
return '\\"';
[740] Fix | Delete
[741] Fix | Delete
case '\\':
[742] Fix | Delete
return '\\\\';
[743] Fix | Delete
[744] Fix | Delete
default:
[745] Fix | Delete
$hex = dechex( ord( $match_result[0] ) );
[746] Fix | Delete
return "\\x{$hex}";
[747] Fix | Delete
}
[748] Fix | Delete
},
[749] Fix | Delete
$mapping
[750] Fix | Delete
);
[751] Fix | Delete
[752] Fix | Delete
$comment_line .= " {$prefix}{$token}[{$mapping}]";
[753] Fix | Delete
$data_line .= "\\x{$token_digits}{$token}\\x{$mapping_digits}{$mapping}";
[754] Fix | Delete
}
[755] Fix | Delete
$comment_line .= ".\n";
[756] Fix | Delete
$data_line .= "\",\n";
[757] Fix | Delete
[758] Fix | Delete
$output .= $comment_line;
[759] Fix | Delete
$output .= $data_line;
[760] Fix | Delete
}
[761] Fix | Delete
[762] Fix | Delete
$output .= "{$i2}),\n";
[763] Fix | Delete
[764] Fix | Delete
$small_words = array();
[765] Fix | Delete
$small_length = strlen( $this->small_words );
[766] Fix | Delete
$at = 0;
[767] Fix | Delete
while ( $at < $small_length ) {
[768] Fix | Delete
$small_words[] = substr( $this->small_words, $at, $this->key_length + 1 );
[769] Fix | Delete
$at += $this->key_length + 1;
[770] Fix | Delete
}
[771] Fix | Delete
[772] Fix | Delete
$small_text = str_replace( "\x00", '\x00', implode( '', $small_words ) );
[773] Fix | Delete
$output .= "{$i2}\"small_words\" => \"{$small_text}\",\n";
[774] Fix | Delete
[775] Fix | Delete
$output .= "{$i2}\"small_mappings\" => array(\n";
[776] Fix | Delete
foreach ( $this->small_mappings as $mapping ) {
[777] Fix | Delete
$output .= "{$i3}\"{$mapping}\",\n";
[778] Fix | Delete
}
[779] Fix | Delete
$output .= "{$i2})\n";
[780] Fix | Delete
$output .= "{$i1})\n";
[781] Fix | Delete
$output .= ')';
[782] Fix | Delete
[783] Fix | Delete
return $output;
[784] Fix | Delete
}
[785] Fix | Delete
[786] Fix | Delete
/**
[787] Fix | Delete
* Compares two strings, returning the longest, or whichever
[788] Fix | Delete
* is first alphabetically if they are the same length.
[789] Fix | Delete
*
[790] Fix | Delete
* This is an important sort when building the token map because
[791] Fix | Delete
* it should not form a match on a substring of a longer potential
[792] Fix | Delete
* match. For example, it should not detect `Cap` when matching
[793] Fix | Delete
* against the string `CapitalDifferentialD`.
[794] Fix | Delete
*
[795] Fix | Delete
* @since 6.6.0
[796] Fix | Delete
*
[797] Fix | Delete
* @param string $a First string to compare.
[798] Fix | Delete
* @param string $b Second string to compare.
[799] Fix | Delete
* @return int -1 or lower if `$a` is less than `$b`; 1 or greater if `$a` is greater than `$b`, and 0 if they are equal.
[800] Fix | Delete
*/
[801] Fix | Delete
private static function longest_first_then_alphabetical( $a, $b ) {
[802] Fix | Delete
if ( $a === $b ) {
[803] Fix | Delete
return 0;
[804] Fix | Delete
}
[805] Fix | Delete
[806] Fix | Delete
$length_a = strlen( $a );
[807] Fix | Delete
$length_b = strlen( $b );
[808] Fix | Delete
[809] Fix | Delete
// Longer strings are less-than for comparison's sake.
[810] Fix | Delete
if ( $length_a !== $length_b ) {
[811] Fix | Delete
return $length_b - $length_a;
[812] Fix | Delete
}
[813] Fix | Delete
[814] Fix | Delete
return strcmp( $a, $b );
[815] Fix | Delete
}
[816] Fix | Delete
}
[817] Fix | Delete
[818] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function