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
/home/sportsfe.../httpdocs/wp-conte.../plugins/sitepres.../inc
File: functions-sanitation.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* @param string $input
[2] Fix | Delete
* @param string $default_if_invalid
[3] Fix | Delete
*
[4] Fix | Delete
* @return string
[5] Fix | Delete
*/
[6] Fix | Delete
function wpml_sanitize_hex_color( $input, $default_if_invalid = '' ) {
[7] Fix | Delete
$input = sanitize_text_field( $input );
[8] Fix | Delete
$result = $input;
[9] Fix | Delete
if ( ! is_string( $input ) || ! wpml_is_valid_hex_color( $input ) ) {
[10] Fix | Delete
$result = $default_if_invalid;
[11] Fix | Delete
}
[12] Fix | Delete
[13] Fix | Delete
return $result;
[14] Fix | Delete
}
[15] Fix | Delete
[16] Fix | Delete
function wpml_sanitize_hex_color_array( $input, $default_if_invalid = '', $bypass_non_strings = true, $recursive = false ) {
[17] Fix | Delete
$result = $input;
[18] Fix | Delete
if ( is_array( $input ) ) {
[19] Fix | Delete
$result = array();
[20] Fix | Delete
foreach ( $input as $key => $value ) {
[21] Fix | Delete
if ( is_array( $value ) && $recursive ) {
[22] Fix | Delete
$result[ $key ] = wpml_sanitize_hex_color_array( $value, $default_if_invalid, $recursive );
[23] Fix | Delete
} elseif ( is_string( $value ) ) {
[24] Fix | Delete
$result[ $key ] = wpml_sanitize_hex_color( $value, $default_if_invalid );
[25] Fix | Delete
} elseif ( $bypass_non_strings ) {
[26] Fix | Delete
$result[ $key ] = $value;
[27] Fix | Delete
}
[28] Fix | Delete
}
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
return $result;
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* @param string $input
[36] Fix | Delete
*
[37] Fix | Delete
* @return bool
[38] Fix | Delete
*/
[39] Fix | Delete
function wpml_is_valid_hex_color( $input ) {
[40] Fix | Delete
if ( 'transparent' === $input || preg_match( '/' . wpml_get_valid_hex_color_pattern() . '/i', $input ) ) {
[41] Fix | Delete
$is_valid = true;
[42] Fix | Delete
} else {
[43] Fix | Delete
$try_rgb2hex = wpml_rgb_to_hex( $input );
[44] Fix | Delete
$is_valid = $try_rgb2hex ? preg_match( '/' . wpml_get_valid_hex_color_pattern() . '/i', $try_rgb2hex ) : false;
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
return $is_valid;
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
function wpml_get_valid_hex_color_pattern() {
[51] Fix | Delete
return '(^#[a-fA-F0-9]{6}$)|(^#[a-fA-F0-9]{3}$)';
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Convert RGB color code to HEX code.
[56] Fix | Delete
*
[57] Fix | Delete
* @param array $rgb
[58] Fix | Delete
*
[59] Fix | Delete
* @return bool|string
[60] Fix | Delete
*/
[61] Fix | Delete
function wpml_rgb_to_hex( $rgb ) {
[62] Fix | Delete
if ( ! is_array( $rgb ) || count( $rgb ) < 3 ) {
[63] Fix | Delete
return false;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
$hex = '#';
[67] Fix | Delete
$hex .= str_pad( dechex( $rgb[0] ), 2, '0', STR_PAD_LEFT );
[68] Fix | Delete
$hex .= str_pad( dechex( $rgb[1] ), 2, '0', STR_PAD_LEFT );
[69] Fix | Delete
$hex .= str_pad( dechex( $rgb[2] ), 2, '0', STR_PAD_LEFT );
[70] Fix | Delete
[71] Fix | Delete
return $hex;
[72] Fix | Delete
}
[73] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function