: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @copyright Copyright (c) 2023, Code Atlantic LLC
if ( ! defined( 'ABSPATH' ) ) {
* Removes <p></p> around URLs
public static function unwrap_urls( $content = '' ) {
$content = preg_replace( '/<\\w+>((([A-Za-z]{3,9}:(?:\\/\\/)?)(?:[-;:&=\\+\$,\\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\\+\$,\\w]+@)[A-Za-z0-9.-]+)((?:\\/[\\+~%\\/.\\w-_]*)?\\??(?:[-\\+=&;%@.\\w_]*)#?(?:[.\\!\\/\\\\w]*))?)<\\/\\w+>/', "$1\n\n", $content );
$content = str_replace( '</p>', "</p>\n\n", $content );
* @param string $format U|human
* @return false|int|mixed
public static function time( $time, $format = 'U' ) {
if ( ! PUM_Utils_Time::is_timestamp( $time ) ) {
$time = strtotime( $time );
return self::human_time( $time );
* @param int|float $number
public static function number( $number, $format = '' ) {
return self::abbreviated_number( $number );
* Convert the timestamp to a nice time format
* @param int|null $current
public static function human_time( $time, $current = null ) {
if ( empty( $current ) ) {
$diff = (int) abs( $current - $time );
$since = sprintf( __( '%ss', 'popup-maker' ), $diff );
} elseif ( $diff < HOUR_IN_SECONDS ) {
$mins = round( $diff / MINUTE_IN_SECONDS );
$since = sprintf( __( '%smin', 'popup-maker' ), $mins );
} elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) {
$hours = round( $diff / HOUR_IN_SECONDS );
$since = sprintf( __( '%shr', 'popup-maker' ), $hours );
} elseif ( $diff < WEEK_IN_SECONDS && $diff >= DAY_IN_SECONDS ) {
$days = round( $diff / DAY_IN_SECONDS );
$since = sprintf( __( '%sd', 'popup-maker' ), $days );
} elseif ( $diff < MONTH_IN_SECONDS && $diff >= WEEK_IN_SECONDS ) {
$weeks = round( $diff / WEEK_IN_SECONDS );
$since = sprintf( __( '%sw', 'popup-maker' ), $weeks );
return apply_filters( 'pum_human_time_diff', $since, $diff, $time, $current );
public static function abbreviated_number( $n, $point = '.', $sep = ',' ) {
return number_format( $n, 0, $point, $sep );
$d = $n < 1000000 ? 1000 : 1000000;
$f = round( $n / $d, 1 );
return number_format( $f, $f - intval( $f ) ? 1 : 0, $point, $sep ) . ( 1000 === $d ? 'K' : 'M' );
* Strips line breaks, tabs & carriage returns from html.
* Used to prevent WP from adding <br> and <p> tags.
public static function strip_white_space( $string = '' ) {
return str_replace( [ "\t", "\r", "\n" ], '', $string );