diff( $now ); if ( $diff->y > 0 ) { return $diff->y . ' year' . ( $diff->y > 1 ? 's' : '' ) . ' ago'; } elseif ( $diff->m > 0 ) { return $diff->m . ' month' . ( $diff->m > 1 ? 's' : '' ) . ' ago'; } elseif ( $diff->d > 0 ) { return $diff->d . ' day' . ( $diff->d > 1 ? 's' : '' ) . ' ago'; } else { return 'Today'; } } /** * Retrieves the SVG icon for the author. * * @param array $icon_type Icon type. * @return string The SVG icon HTML. */ public static function get_author_icon( $icon_type ) { $author_icon_list = array( 'outline' => '', 'basic-outline' => '', 'rounded' => '', 'female' => '', 'user-solid' => '', 'circle' => '', 'author' => '', 'minimal' => '', ); return $author_icon_list[ $icon_type ] ?? $author_icon_list['outline']; } /** * Retrieves the svg icon for taxonomy * * @param string $icon_type Icon type. * @return string */ public static function get_svg_icon( $icon_type ) { $svg_icon_list = array( 'taxonomy' => '', 'meta-date' => '', 'comments-count' => '', 'view-count' => '', 'read-time' => '', 'arrow-down' => '', 'preloader' => '', 'popup-share' => '', ); return $svg_icon_list[ $icon_type ] ?? ''; } /** * Retrieves the svg icon for arrow icons * * @param string $icon_type Icon type. * @return string */ public static function get_arrow_icon( $icon_type ) { $arrow_icons = array( 'chevron-solid' => '', 'chevron-outline' => '', 'chevron-bold' => '', 'double-chevron' => '', 'arrow-solid' => '', 'arrow-outline' => '', 'arrow-minimal' => '', 'chevron-border-line' => '', 'double-chevron-outline' => '', 'triangle-outline' => '', ); return $arrow_icons[ $icon_type ] ?? $arrow_icons['chevron-solid']; } /** * Breadcrumb block icons * * @param string $icon_type Icon type. * @return string */ public static function get_post_breadcrumb_icons( $icon_type ) { $arrow_icons = array( 'classic' => ' ', 'modern' => ' ', 'minimal' => ' ', 'tiny' => ' ', 'flip' => ' ', 'grid' => ' ', 'outline' => ' ', 'bold' => ' ', 'fill' => ' ', 'fill-two' => ' ', ); return $arrow_icons[ $icon_type ] ?? $arrow_icons['chevron-solid']; } /** * Converts a slug string to StudlyCase format with underscores. * * @param string $slug The slug string to convert. * @return string The converted string in StudlyCase format with underscores. */ public static function to_studly_case( $slug ) { $parts = explode( '-', $slug ); $parts = array_map( 'ucfirst', $parts ); return implode( '_', $parts ); } /** * Object to array convert function. * * @param array|object $data object data to array. * @return array */ public static function object_to_array( $data ) { $result = array(); if ( ! empty( $data ) ) { foreach ( $data as $key => $value ) { $result[ $key ] = ( is_array( $value ) || is_object( $value ) ) ? self::object_to_array( $value ) : $value; } } return $result; } /** * Extracts image, video, and audio URLs from HTML content. * * Supports: * - * -