Add upstream plugins

Signed-off-by: Adrian Nöthlich <git@promasu.tech>
This commit is contained in:
2019-10-25 22:42:20 +02:00
parent 5d3c2ec184
commit 290736650a
1186 changed files with 302577 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
<?php
/**
* Size converter utility
*
* @author Time.ly Network, Inc.
* @since 2.0
* @package Ai1EC
* @subpackage Ai1EC.Size
*/
class Ai1ec_Size_Converter_Utility extends Ai1ec_Base {
/**
* Returns number of bytes from human readable string
* Note: This is similar to wp_convert_hr_bytes(), but this one accepts values with decimals
*
* @param string $size Human readable size string
*
* @return string Converted number of bytes from human readable size string
*/
public function convert_hr_to_bytes( $size ) {
$size = strtolower( $size );
$bytes = preg_replace( '/[^0-9\.]/', '', $size );
// Sanity check
if ( empty( $bytes ) ) {
$bytes = 0;
}
if ( strpos( $size, 'k' ) !== false ) {
$bytes = $bytes * 1024;
} elseif ( strpos( $size, 'm' ) !== false ) {
$bytes = $bytes * 1024 * 1024;
} elseif ( strpos( $size, 'g' ) !== false ) {
$bytes = $bytes * 1024 * 1024 * 1024;
}
return $bytes;
}
}