public function render(
        string $format = 'actual',
        string $before = '',
        string $after = ''
    ): string {
        $format_allowed = ['actual', 'difference', 'mixed'];
        $format = \in_array($format, $format_allowed) ? $format : 'actual';

        $method = "render_{$format}";

        if (!\is_callable([$this, $method])) {
            return '';
        }

        $time_ago = '';

        if ($before) {
            $time_ago .= '<span class="before">'.$before.'</span> ';
        }

        $time_ago .= $this->$method();

        if ($after) {
            $time_ago .= ' <span class="after">'.$after.'</span>';
        }

        return $time_ago;
    }
public function render(
        string $format = 'actual',
        string $before = '',
        string $after = ''
    ): string {
        $format_allowed = ['actual', 'difference', 'mixed'];
        $format = \in_array($format, $format_allowed) ? $format : 'actual';

        $method = "render_{$format}";

        if (!\is_callable([$this, $method])) {
            return '';
        }

        $time_ago = '';

        if ($before) {
            $time_ago .= '<span class="before">'.$before.'</span> ';
        }

        $time_ago .= $this->$method();

        if ($after) {
            $time_ago .= ' <span class="after">'.$after.'</span>';
        }

        return $time_ago;
    }
public function render ( string $ format = 'actual' , string $ before = '' , string $ after = '' ) : string { $ format_allowed = [ 'actual' , 'difference' , 'mixed' ] ; $ format = \ in_array ( $ format , $ format_allowed ) ? $ format : 'actual' ; $ method = "render_{$format}" ; if ( ! \ is_callable ( [ $ this , $ method ] ) ) { return '' ; } $ time_ago = '' ; if ( $ before ) { $ time_ago .= '<span class="before">' . $ before . '</span> ' ; } $ time_ago .= $ this -> $ method ( ) ; if ( $ after ) { $ time_ago .= ' <span class="after">' . $ after . '</span>' ; } return $ time_ago ; }
Period since publishing or updating a post.

Get (in string form, ready for output) the period since a given post
was either updated or published.

@param string $format 'actual' (eg: Today 8:00), or 'difference'
(eg: 2 mins ago), or 'mixed'.
@param string $before Text string to prepend to time.
@param string $after Text string to append to time.
Period since publishing or updating a post .