= 1000000 ) { /* translators: %s: millions of active installs, e.g. 5. */ return sprintf( __( '%s+ million', 'trackpluse' ), number_format_i18n( floor( $installs / 1000000 ) ) ); } return number_format_i18n( $installs ) . '+'; } /** * A count in short form: "1.2 billion", "45 million", "1,234". * * @param int $count The count. * @return string */ public static function count( $count ) { $count = (int) $count; if ( $count >= 1000000000 ) { /* translators: %s: a number of billions, e.g. 1.2. */ return sprintf( __( '%s billion', 'trackpluse' ), number_format_i18n( $count / 1000000000, 1 ) ); } if ( $count >= 1000000 ) { /* translators: %s: a number of millions, e.g. 4.5. */ return sprintf( __( '%s million', 'trackpluse' ), number_format_i18n( $count / 1000000, 1 ) ); } return number_format_i18n( $count ); } /** * "3 days ago" for a Y-m-d date, or '' without one. * * @param string|null $date The date. * @return string */ public static function ago( $date ) { $time = is_string( $date ) && '' !== $date ? strtotime( $date . ' 00:00:00 UTC' ) : false; if ( false === $time ) { return ''; } if ( time() - $time < DAY_IN_SECONDS ) { return __( 'today', 'trackpluse' ); } /* translators: %s: a time span, e.g. 3 days. */ return sprintf( __( '%s ago', 'trackpluse' ), human_time_diff( $time ) ); } /** * A listing icon's address, only from WordPress.org's own servers. * * @param mixed $url The address the API gave. * @return string The address, or '' when it isn't a WordPress.org one. */ public static function icon( $url ) { if ( ! is_string( $url ) || 0 !== strpos( $url, 'https://' ) ) { return ''; } $host = (string) wp_parse_url( $url, PHP_URL_HOST ); return ( 'w.org' === $host || '.w.org' === substr( $host, -6 ) ) ? $url : ''; } }