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: formatting.php
* @access private
[3000] Fix | Delete
*
[3001] Fix | Delete
* @param array $matches Single Regex Match.
[3002] Fix | Delete
* @return string HTML A element with email address.
[3003] Fix | Delete
*/
[3004] Fix | Delete
function _make_email_clickable_cb( $matches ) {
[3005] Fix | Delete
$email = $matches[2] . '@' . $matches[3];
[3006] Fix | Delete
[3007] Fix | Delete
return $matches[1] . "<a href=\"mailto:{$email}\">{$email}</a>";
[3008] Fix | Delete
}
[3009] Fix | Delete
[3010] Fix | Delete
/**
[3011] Fix | Delete
* Helper function used to build the "rel" attribute for a URL when creating an anchor using make_clickable().
[3012] Fix | Delete
*
[3013] Fix | Delete
* @since 6.2.0
[3014] Fix | Delete
*
[3015] Fix | Delete
* @param string $url The URL.
[3016] Fix | Delete
* @return string The rel attribute for the anchor or an empty string if no rel attribute should be added.
[3017] Fix | Delete
*/
[3018] Fix | Delete
function _make_clickable_rel_attr( $url ) {
[3019] Fix | Delete
$rel_parts = array();
[3020] Fix | Delete
$scheme = strtolower( wp_parse_url( $url, PHP_URL_SCHEME ) );
[3021] Fix | Delete
$nofollow_schemes = array_intersect( wp_allowed_protocols(), array( 'https', 'http' ) );
[3022] Fix | Delete
[3023] Fix | Delete
// Apply "nofollow" to external links with qualifying URL schemes (mailto:, tel:, etc... shouldn't be followed).
[3024] Fix | Delete
if ( ! wp_is_internal_link( $url ) && in_array( $scheme, $nofollow_schemes, true ) ) {
[3025] Fix | Delete
$rel_parts[] = 'nofollow';
[3026] Fix | Delete
}
[3027] Fix | Delete
[3028] Fix | Delete
// Apply "ugc" when in comment context.
[3029] Fix | Delete
if ( 'comment_text' === current_filter() ) {
[3030] Fix | Delete
$rel_parts[] = 'ugc';
[3031] Fix | Delete
}
[3032] Fix | Delete
[3033] Fix | Delete
$rel = implode( ' ', $rel_parts );
[3034] Fix | Delete
[3035] Fix | Delete
/**
[3036] Fix | Delete
* Filters the rel value that is added to URL matches converted to links.
[3037] Fix | Delete
*
[3038] Fix | Delete
* @since 5.3.0
[3039] Fix | Delete
*
[3040] Fix | Delete
* @param string $rel The rel value.
[3041] Fix | Delete
* @param string $url The matched URL being converted to a link tag.
[3042] Fix | Delete
*/
[3043] Fix | Delete
$rel = apply_filters( 'make_clickable_rel', $rel, $url );
[3044] Fix | Delete
[3045] Fix | Delete
$rel_attr = $rel ? ' rel="' . esc_attr( $rel ) . '"' : '';
[3046] Fix | Delete
[3047] Fix | Delete
return $rel_attr;
[3048] Fix | Delete
}
[3049] Fix | Delete
[3050] Fix | Delete
/**
[3051] Fix | Delete
* Converts plaintext URI to HTML links.
[3052] Fix | Delete
*
[3053] Fix | Delete
* Converts URI, www and ftp, and email addresses. Finishes by fixing links
[3054] Fix | Delete
* within links.
[3055] Fix | Delete
*
[3056] Fix | Delete
* @since 0.71
[3057] Fix | Delete
*
[3058] Fix | Delete
* @param string $text Content to convert URIs.
[3059] Fix | Delete
* @return string Content with converted URIs.
[3060] Fix | Delete
*/
[3061] Fix | Delete
function make_clickable( $text ) {
[3062] Fix | Delete
$r = '';
[3063] Fix | Delete
$textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // Split out HTML tags.
[3064] Fix | Delete
$nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>.
[3065] Fix | Delete
foreach ( $textarr as $piece ) {
[3066] Fix | Delete
[3067] Fix | Delete
if ( preg_match( '|^<code[\s>]|i', $piece )
[3068] Fix | Delete
|| preg_match( '|^<pre[\s>]|i', $piece )
[3069] Fix | Delete
|| preg_match( '|^<script[\s>]|i', $piece )
[3070] Fix | Delete
|| preg_match( '|^<style[\s>]|i', $piece )
[3071] Fix | Delete
) {
[3072] Fix | Delete
++$nested_code_pre;
[3073] Fix | Delete
} elseif ( $nested_code_pre
[3074] Fix | Delete
&& ( '</code>' === strtolower( $piece )
[3075] Fix | Delete
|| '</pre>' === strtolower( $piece )
[3076] Fix | Delete
|| '</script>' === strtolower( $piece )
[3077] Fix | Delete
|| '</style>' === strtolower( $piece )
[3078] Fix | Delete
)
[3079] Fix | Delete
) {
[3080] Fix | Delete
--$nested_code_pre;
[3081] Fix | Delete
}
[3082] Fix | Delete
[3083] Fix | Delete
if ( $nested_code_pre
[3084] Fix | Delete
|| empty( $piece )
[3085] Fix | Delete
|| ( '<' === $piece[0] && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) )
[3086] Fix | Delete
) {
[3087] Fix | Delete
$r .= $piece;
[3088] Fix | Delete
continue;
[3089] Fix | Delete
}
[3090] Fix | Delete
[3091] Fix | Delete
// Long strings might contain expensive edge cases...
[3092] Fix | Delete
if ( 10000 < strlen( $piece ) ) {
[3093] Fix | Delete
// ...break it up.
[3094] Fix | Delete
foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing parentheses.
[3095] Fix | Delete
if ( 2101 < strlen( $chunk ) ) {
[3096] Fix | Delete
$r .= $chunk; // Too big, no whitespace: bail.
[3097] Fix | Delete
} else {
[3098] Fix | Delete
$r .= make_clickable( $chunk );
[3099] Fix | Delete
}
[3100] Fix | Delete
}
[3101] Fix | Delete
} else {
[3102] Fix | Delete
$ret = " $piece "; // Pad with whitespace to simplify the regexes.
[3103] Fix | Delete
[3104] Fix | Delete
$url_clickable = '~
[3105] Fix | Delete
([\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation.
[3106] Fix | Delete
( # 2: URL.
[3107] Fix | Delete
[\\w]{1,20}+:// # Scheme and hier-part prefix.
[3108] Fix | Delete
(?=\S{1,2000}\s) # Limit to URLs less than about 2000 characters long.
[3109] Fix | Delete
[\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+ # Non-punctuation URL character.
[3110] Fix | Delete
(?: # Unroll the Loop: Only allow punctuation URL character if followed by a non-punctuation URL character.
[3111] Fix | Delete
[\'.,;:!?)] # Punctuation URL character.
[3112] Fix | Delete
[\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character.
[3113] Fix | Delete
)*
[3114] Fix | Delete
)
[3115] Fix | Delete
(\)?) # 3: Trailing closing parenthesis (for parenthesis balancing post processing).
[3116] Fix | Delete
~xS';
[3117] Fix | Delete
/*
[3118] Fix | Delete
* The regex is a non-anchored pattern and does not have a single fixed starting character.
[3119] Fix | Delete
* Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times.
[3120] Fix | Delete
*/
[3121] Fix | Delete
[3122] Fix | Delete
$ret = preg_replace_callback( $url_clickable, '_make_url_clickable_cb', $ret );
[3123] Fix | Delete
[3124] Fix | Delete
$ret = preg_replace_callback( '#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret );
[3125] Fix | Delete
$ret = preg_replace_callback( '#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret );
[3126] Fix | Delete
[3127] Fix | Delete
$ret = substr( $ret, 1, -1 ); // Remove our whitespace padding.
[3128] Fix | Delete
$r .= $ret;
[3129] Fix | Delete
}
[3130] Fix | Delete
}
[3131] Fix | Delete
[3132] Fix | Delete
// Cleanup of accidental links within links.
[3133] Fix | Delete
return preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', '$1$3</a>', $r );
[3134] Fix | Delete
}
[3135] Fix | Delete
[3136] Fix | Delete
/**
[3137] Fix | Delete
* Breaks a string into chunks by splitting at whitespace characters.
[3138] Fix | Delete
*
[3139] Fix | Delete
* The length of each returned chunk is as close to the specified length goal as possible,
[3140] Fix | Delete
* with the caveat that each chunk includes its trailing delimiter.
[3141] Fix | Delete
* Chunks longer than the goal are guaranteed to not have any inner whitespace.
[3142] Fix | Delete
*
[3143] Fix | Delete
* Joining the returned chunks with empty delimiters reconstructs the input string losslessly.
[3144] Fix | Delete
*
[3145] Fix | Delete
* Input string must have no null characters (or eventual transformations on output chunks must not care about null characters)
[3146] Fix | Delete
*
[3147] Fix | Delete
* _split_str_by_whitespace( "1234 67890 1234 67890a cd 1234 890 123456789 1234567890a 45678 1 3 5 7 90 ", 10 ) ==
[3148] Fix | Delete
* array (
[3149] Fix | Delete
* 0 => '1234 67890 ', // 11 characters: Perfect split.
[3150] Fix | Delete
* 1 => '1234 ', // 5 characters: '1234 67890a' was too long.
[3151] Fix | Delete
* 2 => '67890a cd ', // 10 characters: '67890a cd 1234' was too long.
[3152] Fix | Delete
* 3 => '1234 890 ', // 11 characters: Perfect split.
[3153] Fix | Delete
* 4 => '123456789 ', // 10 characters: '123456789 1234567890a' was too long.
[3154] Fix | Delete
* 5 => '1234567890a ', // 12 characters: Too long, but no inner whitespace on which to split.
[3155] Fix | Delete
* 6 => ' 45678 ', // 11 characters: Perfect split.
[3156] Fix | Delete
* 7 => '1 3 5 7 90 ', // 11 characters: End of $text.
[3157] Fix | Delete
* );
[3158] Fix | Delete
*
[3159] Fix | Delete
* @since 3.4.0
[3160] Fix | Delete
* @access private
[3161] Fix | Delete
*
[3162] Fix | Delete
* @param string $text The string to split.
[3163] Fix | Delete
* @param int $goal The desired chunk length.
[3164] Fix | Delete
* @return array Numeric array of chunks.
[3165] Fix | Delete
*/
[3166] Fix | Delete
function _split_str_by_whitespace( $text, $goal ) {
[3167] Fix | Delete
$chunks = array();
[3168] Fix | Delete
[3169] Fix | Delete
$string_nullspace = strtr( $text, "\r\n\t\v\f ", "\000\000\000\000\000\000" );
[3170] Fix | Delete
[3171] Fix | Delete
while ( $goal < strlen( $string_nullspace ) ) {
[3172] Fix | Delete
$pos = strrpos( substr( $string_nullspace, 0, $goal + 1 ), "\000" );
[3173] Fix | Delete
[3174] Fix | Delete
if ( false === $pos ) {
[3175] Fix | Delete
$pos = strpos( $string_nullspace, "\000", $goal + 1 );
[3176] Fix | Delete
if ( false === $pos ) {
[3177] Fix | Delete
break;
[3178] Fix | Delete
}
[3179] Fix | Delete
}
[3180] Fix | Delete
[3181] Fix | Delete
$chunks[] = substr( $text, 0, $pos + 1 );
[3182] Fix | Delete
$text = substr( $text, $pos + 1 );
[3183] Fix | Delete
$string_nullspace = substr( $string_nullspace, $pos + 1 );
[3184] Fix | Delete
}
[3185] Fix | Delete
[3186] Fix | Delete
if ( $text ) {
[3187] Fix | Delete
$chunks[] = $text;
[3188] Fix | Delete
}
[3189] Fix | Delete
[3190] Fix | Delete
return $chunks;
[3191] Fix | Delete
}
[3192] Fix | Delete
[3193] Fix | Delete
/**
[3194] Fix | Delete
* Callback to add a rel attribute to HTML A element.
[3195] Fix | Delete
*
[3196] Fix | Delete
* Will remove already existing string before adding to prevent invalidating (X)HTML.
[3197] Fix | Delete
*
[3198] Fix | Delete
* @since 5.3.0
[3199] Fix | Delete
*
[3200] Fix | Delete
* @param array $matches Single match.
[3201] Fix | Delete
* @param string $rel The rel attribute to add.
[3202] Fix | Delete
* @return string HTML A element with the added rel attribute.
[3203] Fix | Delete
*/
[3204] Fix | Delete
function wp_rel_callback( $matches, $rel ) {
[3205] Fix | Delete
$text = $matches[1];
[3206] Fix | Delete
$atts = wp_kses_hair( $matches[1], wp_allowed_protocols() );
[3207] Fix | Delete
[3208] Fix | Delete
if ( ! empty( $atts['href'] ) && wp_is_internal_link( $atts['href']['value'] ) ) {
[3209] Fix | Delete
$rel = trim( str_replace( 'nofollow', '', $rel ) );
[3210] Fix | Delete
}
[3211] Fix | Delete
[3212] Fix | Delete
if ( ! empty( $atts['rel'] ) ) {
[3213] Fix | Delete
$parts = array_map( 'trim', explode( ' ', $atts['rel']['value'] ) );
[3214] Fix | Delete
$rel_array = array_map( 'trim', explode( ' ', $rel ) );
[3215] Fix | Delete
$parts = array_unique( array_merge( $parts, $rel_array ) );
[3216] Fix | Delete
$rel = implode( ' ', $parts );
[3217] Fix | Delete
unset( $atts['rel'] );
[3218] Fix | Delete
[3219] Fix | Delete
$html = '';
[3220] Fix | Delete
foreach ( $atts as $name => $value ) {
[3221] Fix | Delete
if ( isset( $value['vless'] ) && 'y' === $value['vless'] ) {
[3222] Fix | Delete
$html .= $name . ' ';
[3223] Fix | Delete
} else {
[3224] Fix | Delete
$html .= "{$name}=\"" . esc_attr( $value['value'] ) . '" ';
[3225] Fix | Delete
}
[3226] Fix | Delete
}
[3227] Fix | Delete
$text = trim( $html );
[3228] Fix | Delete
}
[3229] Fix | Delete
[3230] Fix | Delete
$rel_attr = $rel ? ' rel="' . esc_attr( $rel ) . '"' : '';
[3231] Fix | Delete
[3232] Fix | Delete
return "<a {$text}{$rel_attr}>";
[3233] Fix | Delete
}
[3234] Fix | Delete
[3235] Fix | Delete
/**
[3236] Fix | Delete
* Adds `rel="nofollow"` string to all HTML A elements in content.
[3237] Fix | Delete
*
[3238] Fix | Delete
* @since 1.5.0
[3239] Fix | Delete
*
[3240] Fix | Delete
* @param string $text Content that may contain HTML A elements.
[3241] Fix | Delete
* @return string Converted content.
[3242] Fix | Delete
*/
[3243] Fix | Delete
function wp_rel_nofollow( $text ) {
[3244] Fix | Delete
// This is a pre-save filter, so text is already escaped.
[3245] Fix | Delete
$text = stripslashes( $text );
[3246] Fix | Delete
$text = preg_replace_callback(
[3247] Fix | Delete
'|<a (.+?)>|i',
[3248] Fix | Delete
static function ( $matches ) {
[3249] Fix | Delete
return wp_rel_callback( $matches, 'nofollow' );
[3250] Fix | Delete
},
[3251] Fix | Delete
$text
[3252] Fix | Delete
);
[3253] Fix | Delete
return wp_slash( $text );
[3254] Fix | Delete
}
[3255] Fix | Delete
[3256] Fix | Delete
/**
[3257] Fix | Delete
* Callback to add `rel="nofollow"` string to HTML A element.
[3258] Fix | Delete
*
[3259] Fix | Delete
* @since 2.3.0
[3260] Fix | Delete
* @deprecated 5.3.0 Use wp_rel_callback()
[3261] Fix | Delete
*
[3262] Fix | Delete
* @param array $matches Single match.
[3263] Fix | Delete
* @return string HTML A Element with `rel="nofollow"`.
[3264] Fix | Delete
*/
[3265] Fix | Delete
function wp_rel_nofollow_callback( $matches ) {
[3266] Fix | Delete
return wp_rel_callback( $matches, 'nofollow' );
[3267] Fix | Delete
}
[3268] Fix | Delete
[3269] Fix | Delete
/**
[3270] Fix | Delete
* Adds `rel="nofollow ugc"` string to all HTML A elements in content.
[3271] Fix | Delete
*
[3272] Fix | Delete
* @since 5.3.0
[3273] Fix | Delete
*
[3274] Fix | Delete
* @param string $text Content that may contain HTML A elements.
[3275] Fix | Delete
* @return string Converted content.
[3276] Fix | Delete
*/
[3277] Fix | Delete
function wp_rel_ugc( $text ) {
[3278] Fix | Delete
// This is a pre-save filter, so text is already escaped.
[3279] Fix | Delete
$text = stripslashes( $text );
[3280] Fix | Delete
$text = preg_replace_callback(
[3281] Fix | Delete
'|<a (.+?)>|i',
[3282] Fix | Delete
static function ( $matches ) {
[3283] Fix | Delete
return wp_rel_callback( $matches, 'nofollow ugc' );
[3284] Fix | Delete
},
[3285] Fix | Delete
$text
[3286] Fix | Delete
);
[3287] Fix | Delete
return wp_slash( $text );
[3288] Fix | Delete
}
[3289] Fix | Delete
[3290] Fix | Delete
/**
[3291] Fix | Delete
* Adds `rel="noopener"` to all HTML A elements that have a target.
[3292] Fix | Delete
*
[3293] Fix | Delete
* @since 5.1.0
[3294] Fix | Delete
* @since 5.6.0 Removed 'noreferrer' relationship.
[3295] Fix | Delete
*
[3296] Fix | Delete
* @param string $text Content that may contain HTML A elements.
[3297] Fix | Delete
* @return string Converted content.
[3298] Fix | Delete
*/
[3299] Fix | Delete
function wp_targeted_link_rel( $text ) {
[3300] Fix | Delete
// Don't run (more expensive) regex if no links with targets.
[3301] Fix | Delete
if ( stripos( $text, 'target' ) === false || stripos( $text, '<a ' ) === false || is_serialized( $text ) ) {
[3302] Fix | Delete
return $text;
[3303] Fix | Delete
}
[3304] Fix | Delete
[3305] Fix | Delete
$script_and_style_regex = '/<(script|style).*?<\/\\1>/si';
[3306] Fix | Delete
[3307] Fix | Delete
preg_match_all( $script_and_style_regex, $text, $matches );
[3308] Fix | Delete
$extra_parts = $matches[0];
[3309] Fix | Delete
$html_parts = preg_split( $script_and_style_regex, $text );
[3310] Fix | Delete
[3311] Fix | Delete
foreach ( $html_parts as &$part ) {
[3312] Fix | Delete
$part = preg_replace_callback( '|<a\s([^>]*target\s*=[^>]*)>|i', 'wp_targeted_link_rel_callback', $part );
[3313] Fix | Delete
}
[3314] Fix | Delete
[3315] Fix | Delete
$text = '';
[3316] Fix | Delete
for ( $i = 0; $i < count( $html_parts ); $i++ ) {
[3317] Fix | Delete
$text .= $html_parts[ $i ];
[3318] Fix | Delete
if ( isset( $extra_parts[ $i ] ) ) {
[3319] Fix | Delete
$text .= $extra_parts[ $i ];
[3320] Fix | Delete
}
[3321] Fix | Delete
}
[3322] Fix | Delete
[3323] Fix | Delete
return $text;
[3324] Fix | Delete
}
[3325] Fix | Delete
[3326] Fix | Delete
/**
[3327] Fix | Delete
* Callback to add `rel="noopener"` string to HTML A element.
[3328] Fix | Delete
*
[3329] Fix | Delete
* Will not duplicate an existing 'noopener' value to avoid invalidating the HTML.
[3330] Fix | Delete
*
[3331] Fix | Delete
* @since 5.1.0
[3332] Fix | Delete
* @since 5.6.0 Removed 'noreferrer' relationship.
[3333] Fix | Delete
*
[3334] Fix | Delete
* @param array $matches Single match.
[3335] Fix | Delete
* @return string HTML A Element with `rel="noopener"` in addition to any existing values.
[3336] Fix | Delete
*/
[3337] Fix | Delete
function wp_targeted_link_rel_callback( $matches ) {
[3338] Fix | Delete
$link_html = $matches[1];
[3339] Fix | Delete
$original_link_html = $link_html;
[3340] Fix | Delete
[3341] Fix | Delete
// Consider the HTML escaped if there are no unescaped quotes.
[3342] Fix | Delete
$is_escaped = ! preg_match( '/(^|[^\\\\])[\'"]/', $link_html );
[3343] Fix | Delete
if ( $is_escaped ) {
[3344] Fix | Delete
// Replace only the quotes so that they are parsable by wp_kses_hair(), leave the rest as is.
[3345] Fix | Delete
$link_html = preg_replace( '/\\\\([\'"])/', '$1', $link_html );
[3346] Fix | Delete
}
[3347] Fix | Delete
[3348] Fix | Delete
$atts = wp_kses_hair( $link_html, wp_allowed_protocols() );
[3349] Fix | Delete
[3350] Fix | Delete
/**
[3351] Fix | Delete
* Filters the rel values that are added to links with `target` attribute.
[3352] Fix | Delete
*
[3353] Fix | Delete
* @since 5.1.0
[3354] Fix | Delete
*
[3355] Fix | Delete
* @param string $rel The rel values.
[3356] Fix | Delete
* @param string $link_html The matched content of the link tag including all HTML attributes.
[3357] Fix | Delete
*/
[3358] Fix | Delete
$rel = apply_filters( 'wp_targeted_link_rel', 'noopener', $link_html );
[3359] Fix | Delete
[3360] Fix | Delete
// Return early if no rel values to be added or if no actual target attribute.
[3361] Fix | Delete
if ( ! $rel || ! isset( $atts['target'] ) ) {
[3362] Fix | Delete
return "<a $original_link_html>";
[3363] Fix | Delete
}
[3364] Fix | Delete
[3365] Fix | Delete
if ( isset( $atts['rel'] ) ) {
[3366] Fix | Delete
$all_parts = preg_split( '/\s/', "{$atts['rel']['value']} $rel", -1, PREG_SPLIT_NO_EMPTY );
[3367] Fix | Delete
$rel = implode( ' ', array_unique( $all_parts ) );
[3368] Fix | Delete
}
[3369] Fix | Delete
[3370] Fix | Delete
$atts['rel']['whole'] = 'rel="' . esc_attr( $rel ) . '"';
[3371] Fix | Delete
$link_html = implode( ' ', array_column( $atts, 'whole' ) );
[3372] Fix | Delete
[3373] Fix | Delete
if ( $is_escaped ) {
[3374] Fix | Delete
$link_html = preg_replace( '/[\'"]/', '\\\\$0', $link_html );
[3375] Fix | Delete
}
[3376] Fix | Delete
[3377] Fix | Delete
return "<a $link_html>";
[3378] Fix | Delete
}
[3379] Fix | Delete
[3380] Fix | Delete
/**
[3381] Fix | Delete
* Adds all filters modifying the rel attribute of targeted links.
[3382] Fix | Delete
*
[3383] Fix | Delete
* @since 5.1.0
[3384] Fix | Delete
*/
[3385] Fix | Delete
function wp_init_targeted_link_rel_filters() {
[3386] Fix | Delete
$filters = array(
[3387] Fix | Delete
'title_save_pre',
[3388] Fix | Delete
'content_save_pre',
[3389] Fix | Delete
'excerpt_save_pre',
[3390] Fix | Delete
'content_filtered_save_pre',
[3391] Fix | Delete
'pre_comment_content',
[3392] Fix | Delete
'pre_term_description',
[3393] Fix | Delete
'pre_link_description',
[3394] Fix | Delete
'pre_link_notes',
[3395] Fix | Delete
'pre_user_description',
[3396] Fix | Delete
);
[3397] Fix | Delete
[3398] Fix | Delete
foreach ( $filters as $filter ) {
[3399] Fix | Delete
add_filter( $filter, 'wp_targeted_link_rel' );
[3400] Fix | Delete
}
[3401] Fix | Delete
}
[3402] Fix | Delete
[3403] Fix | Delete
/**
[3404] Fix | Delete
* Removes all filters modifying the rel attribute of targeted links.
[3405] Fix | Delete
*
[3406] Fix | Delete
* @since 5.1.0
[3407] Fix | Delete
*/
[3408] Fix | Delete
function wp_remove_targeted_link_rel_filters() {
[3409] Fix | Delete
$filters = array(
[3410] Fix | Delete
'title_save_pre',
[3411] Fix | Delete
'content_save_pre',
[3412] Fix | Delete
'excerpt_save_pre',
[3413] Fix | Delete
'content_filtered_save_pre',
[3414] Fix | Delete
'pre_comment_content',
[3415] Fix | Delete
'pre_term_description',
[3416] Fix | Delete
'pre_link_description',
[3417] Fix | Delete
'pre_link_notes',
[3418] Fix | Delete
'pre_user_description',
[3419] Fix | Delete
);
[3420] Fix | Delete
[3421] Fix | Delete
foreach ( $filters as $filter ) {
[3422] Fix | Delete
remove_filter( $filter, 'wp_targeted_link_rel' );
[3423] Fix | Delete
}
[3424] Fix | Delete
}
[3425] Fix | Delete
[3426] Fix | Delete
/**
[3427] Fix | Delete
* Converts one smiley code to the icon graphic file equivalent.
[3428] Fix | Delete
*
[3429] Fix | Delete
* Callback handler for convert_smilies().
[3430] Fix | Delete
*
[3431] Fix | Delete
* Looks up one smiley code in the $wpsmiliestrans global array and returns an
[3432] Fix | Delete
* `<img>` string for that smiley.
[3433] Fix | Delete
*
[3434] Fix | Delete
* @since 2.8.0
[3435] Fix | Delete
*
[3436] Fix | Delete
* @global array $wpsmiliestrans
[3437] Fix | Delete
*
[3438] Fix | Delete
* @param array $matches Single match. Smiley code to convert to image.
[3439] Fix | Delete
* @return string Image string for smiley.
[3440] Fix | Delete
*/
[3441] Fix | Delete
function translate_smiley( $matches ) {
[3442] Fix | Delete
global $wpsmiliestrans;
[3443] Fix | Delete
[3444] Fix | Delete
if ( count( $matches ) === 0 ) {
[3445] Fix | Delete
return '';
[3446] Fix | Delete
}
[3447] Fix | Delete
[3448] Fix | Delete
$smiley = trim( reset( $matches ) );
[3449] Fix | Delete
$img = $wpsmiliestrans[ $smiley ];
[3450] Fix | Delete
[3451] Fix | Delete
$matches = array();
[3452] Fix | Delete
$ext = preg_match( '/\.([^.]+)$/', $img, $matches ) ? strtolower( $matches[1] ) : false;
[3453] Fix | Delete
$image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'webp', 'avif' );
[3454] Fix | Delete
[3455] Fix | Delete
// Don't convert smilies that aren't images - they're probably emoji.
[3456] Fix | Delete
if ( ! in_array( $ext, $image_exts, true ) ) {
[3457] Fix | Delete
return $img;
[3458] Fix | Delete
}
[3459] Fix | Delete
[3460] Fix | Delete
/**
[3461] Fix | Delete
* Filters the Smiley image URL before it's used in the image element.
[3462] Fix | Delete
*
[3463] Fix | Delete
* @since 2.9.0
[3464] Fix | Delete
*
[3465] Fix | Delete
* @param string $smiley_url URL for the smiley image.
[3466] Fix | Delete
* @param string $img Filename for the smiley image.
[3467] Fix | Delete
* @param string $site_url Site URL, as returned by site_url().
[3468] Fix | Delete
*/
[3469] Fix | Delete
$src_url = apply_filters( 'smilies_src', includes_url( "images/smilies/$img" ), $img, site_url() );
[3470] Fix | Delete
[3471] Fix | Delete
return sprintf( '<img src="%s" alt="%s" class="wp-smiley" style="height: 1em; max-height: 1em;" />', esc_url( $src_url ), esc_attr( $smiley ) );
[3472] Fix | Delete
}
[3473] Fix | Delete
[3474] Fix | Delete
/**
[3475] Fix | Delete
* Converts text equivalent of smilies to images.
[3476] Fix | Delete
*
[3477] Fix | Delete
* Will only convert smilies if the option 'use_smilies' is true and the global
[3478] Fix | Delete
* used in the function isn't empty.
[3479] Fix | Delete
*
[3480] Fix | Delete
* @since 0.71
[3481] Fix | Delete
*
[3482] Fix | Delete
* @global string|array $wp_smiliessearch
[3483] Fix | Delete
*
[3484] Fix | Delete
* @param string $text Content to convert smilies from text.
[3485] Fix | Delete
* @return string Converted content with text smilies replaced with images.
[3486] Fix | Delete
*/
[3487] Fix | Delete
function convert_smilies( $text ) {
[3488] Fix | Delete
global $wp_smiliessearch;
[3489] Fix | Delete
$output = '';
[3490] Fix | Delete
if ( get_option( 'use_smilies' ) && ! empty( $wp_smiliessearch ) ) {
[3491] Fix | Delete
// HTML loop taken from texturize function, could possible be consolidated.
[3492] Fix | Delete
$textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // Capture the tags as well as in between.
[3493] Fix | Delete
$stop = count( $textarr ); // Loop stuff.
[3494] Fix | Delete
[3495] Fix | Delete
// Ignore processing of specific tags.
[3496] Fix | Delete
$tags_to_ignore = 'code|pre|style|script|textarea';
[3497] Fix | Delete
$ignore_block_element = '';
[3498] Fix | Delete
[3499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function