from an RGBA color string. * * @param string $rgba The RGBA color string. * @return string The corresponding RGB string. */ public static function rgba_to_rgb( $rgba ) { return Avada_Color::rgba_to_rgb( $rgba ); } /** * Properly escape some characters in image URLs so that they may be properly used in CSS. * From W3C: * > Some characters appearing in an unquoted URI, * > such as parentheses, white space characters, single quotes (') and double quotes ("), * > must be escaped with a backslash so that the resulting URI value is a URI token: '\(', '\)'. */ public static function css_asset_url( $url ) { $url = esc_url_raw( $url ); $url = str_replace( '(', '\(', $url ); $url = str_replace( ')', '\)', $url ); $url = str_replace( '"', '\"', $url ); $url = str_replace( ' ', '\ ', $url ); $url = str_replace( "'", "\'", $url ); return $url; } /** * Removes the scheme of the passed URL to fit the current page * * @var string The URL that needs sanitation * @return string Full URL without scheme */ public static function get_url_with_correct_scheme( $url ) { $url = str_replace( 'http://', '//', str_replace( 'https://', '//', $url ) ); return $url; } /** * Sanitizes a number value * * @var string * @return float */ public static function number( $value ) { return filter_var( $value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); } /** * Orders an array like another one with the same keys * * @since 4.0 * * @param array $to_be_ordered The array that should be ordered. * @param array $order_like The array that should be used to order $to_be_ordered. * * @return array The correctly ordered version of $to_be_ordered */ public static function order_array_like_array( Array $to_be_ordered, Array $order_like ) { $ordered = array(); foreach( $order_like as $key => $value ) { if ( array_key_exists( $key, $to_be_ordered ) ) { $ordered[$key] = $to_be_ordered[$key]; unset( $to_be_ordered[$key] ); } } return $ordered + $to_be_ordered; } }