wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema



wp_convert_hr_to_bytes › WordPress Function

Desde2.3.0
Obsoleton/a
wp_convert_hr_to_bytes ( $value )
Parâmetros:
  • (string) $value A (PHP ini) byte value, either shorthand or ordinary.
    Required: Yes
Links:
Retorna:
  • (int) An integer byte value.
Definido em:
Codex:
Log de mudanças:
  • 4.6.0

Converts a shorthand byte value to an integer byte value.



Fonte

function wp_convert_hr_to_bytes( $value ) {
	$value = strtolower( trim( $value ) );
	$bytes = (int) $value;

	if ( str_contains( $value, 'g' ) ) {
		$bytes *= GB_IN_BYTES;
	} elseif ( str_contains( $value, 'm' ) ) {
		$bytes *= MB_IN_BYTES;
	} elseif ( str_contains( $value, 'k' ) ) {
		$bytes *= KB_IN_BYTES;
	}

	// Deal with large (float) values which run into the maximum integer size.
	return min( $bytes, PHP_INT_MAX );
}