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/popup-ma.../classes/Utils
File: CSS.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* CSS Utility
[2] Fix | Delete
*
[3] Fix | Delete
* @package PUM
[4] Fix | Delete
* @copyright Copyright (c) 2023, Code Atlantic LLC
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
class PUM_Utils_CSS {
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* @param string $hex
[11] Fix | Delete
* @param string $return_type
[12] Fix | Delete
*
[13] Fix | Delete
* @return array|string
[14] Fix | Delete
*/
[15] Fix | Delete
public static function hex2rgb( $hex = '#ffffff', $return_type = 'rgb' ) {
[16] Fix | Delete
if ( is_array( $hex ) ) {
[17] Fix | Delete
$hex = implode( '', $hex );
[18] Fix | Delete
}
[19] Fix | Delete
$hex = str_replace( '#', '', $hex );
[20] Fix | Delete
[21] Fix | Delete
if ( strlen( $hex ) === 3 ) {
[22] Fix | Delete
$r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
[23] Fix | Delete
$g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
[24] Fix | Delete
$b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
[25] Fix | Delete
} else {
[26] Fix | Delete
$r = hexdec( substr( $hex, 0, 2 ) );
[27] Fix | Delete
$g = hexdec( substr( $hex, 2, 2 ) );
[28] Fix | Delete
$b = hexdec( substr( $hex, 4, 2 ) );
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
$rgb = [ $r, $g, $b ];
[32] Fix | Delete
[33] Fix | Delete
if ( 'array' === $return_type ) {
[34] Fix | Delete
return $rgb; // returns an array with the rgb values
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
return 'rgb(' . implode( ',', $rgb ) . ')'; // returns the rgb values separated by commas
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
/**
[41] Fix | Delete
* @param string $hex
[42] Fix | Delete
* @param int $opacity
[43] Fix | Delete
*
[44] Fix | Delete
* @return string
[45] Fix | Delete
*/
[46] Fix | Delete
public static function hex2rgba( $hex = '#ffffff', $opacity = 100 ) {
[47] Fix | Delete
$rgb = self::hex2rgb( $hex, 'array' );
[48] Fix | Delete
$opacity = number_format( intval( $opacity ) / 100, 2 );
[49] Fix | Delete
[50] Fix | Delete
return 'rgba( ' . implode( ', ', $rgb ) . ', ' . $opacity . ' )';
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
/**
[54] Fix | Delete
* @param int $thickness
[55] Fix | Delete
* @param string $style
[56] Fix | Delete
* @param string $color
[57] Fix | Delete
*
[58] Fix | Delete
* @return string
[59] Fix | Delete
*/
[60] Fix | Delete
public static function border_style( $thickness = 1, $style = 'solid', $color = '#cccccc' ) {
[61] Fix | Delete
return "{$thickness}px {$style} {$color}";
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* @param int $horizontal
[66] Fix | Delete
* @param int $vertical
[67] Fix | Delete
* @param int $blur
[68] Fix | Delete
* @param int $spread
[69] Fix | Delete
* @param string $hex
[70] Fix | Delete
* @param int $opacity
[71] Fix | Delete
* @param string $inset
[72] Fix | Delete
*
[73] Fix | Delete
* @return string
[74] Fix | Delete
*/
[75] Fix | Delete
public static function box_shadow_style( $horizontal = 0, $vertical = 0, $blur = 0, $spread = 0, $hex = '#000000', $opacity = 50, $inset = 'no' ) {
[76] Fix | Delete
return "{$horizontal}px {$vertical}px {$blur}px {$spread}px " . self::hex2rgba( $hex, $opacity ) . ( 'yes' === $inset ? ' inset' : '' );
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
/**
[80] Fix | Delete
* @param int $horizontal
[81] Fix | Delete
* @param int $vertical
[82] Fix | Delete
* @param int $blur
[83] Fix | Delete
* @param string $hex
[84] Fix | Delete
* @param int $opacity
[85] Fix | Delete
*
[86] Fix | Delete
* @return string
[87] Fix | Delete
*/
[88] Fix | Delete
public static function text_shadow_style( $horizontal = 0, $vertical = 0, $blur = 0, $hex = '#000000', $opacity = 50 ) {
[89] Fix | Delete
return "{$horizontal}px {$vertical}px {$blur}px " . self::hex2rgba( $hex, $opacity );
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* @param int|string $size
[94] Fix | Delete
* @param int|string $weight
[95] Fix | Delete
* @param float|int|string $line_height
[96] Fix | Delete
* @param string $family
[97] Fix | Delete
* @param string|null $style
[98] Fix | Delete
* @param string|null $variant
[99] Fix | Delete
*
[100] Fix | Delete
* @return mixed
[101] Fix | Delete
*/
[102] Fix | Delete
public static function font_style( $size = 16, $weight = 300, $line_height = 1.2, $family = 'Times New Roman', $style = null, $variant = null ) {
[103] Fix | Delete
$size = is_int( $size ) ? "{$size}px" : $size;
[104] Fix | Delete
$line_height = is_int( $line_height ) ? "{$line_height}px" : $line_height;
[105] Fix | Delete
[106] Fix | Delete
return str_replace( ' ', ' ', trim( "$style $variant $weight {$size}/{$line_height} \"$family\"" ) );
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function