'fa-facebook', 'twitter' => 'fa-twitter', 'linkedin' => 'fa-linkedin', 'instagram' => 'fa-instagram', 'youtube' => 'fa-youtube', ); } /** * Resolves the image URL for a testimonial's `image` attribute value, * falling back to the URL captured at selection time if the attachment * no longer exists. * * @param array $image Item image data: [ 'id' => int, 'url' => string ]. * @param string $size Registered image size name. */ public static function image_url( array $image, string $size = 'thumbnail' ): string { if ( ! empty( $image['id'] ) ) { $url = wp_get_attachment_image_url( (int) $image['id'], $size ); if ( $url ) { return $url; } } return $image['url'] ?? ''; } public static function format_date( string $raw_date ): string { if ( '' === trim( $raw_date ) ) { return ''; } $timestamp = strtotime( $raw_date ); if ( false === $timestamp ) { return $raw_date; } return date_i18n( get_option( 'date_format', 'F j, Y' ), $timestamp ); } /** * Filters the configured social platforms down to only the ones this * testimonial has a non-empty URL for. */ public static function active_social_links( array $item ): array { $social = is_array( $item['social'] ?? null ) ? $item['social'] : array(); $active = array(); foreach ( self::social_platforms() as $key => $icon_class ) { if ( ! empty( $social[ $key ] ) ) { $active[ $key ] = array( 'url' => $social[ $key ], 'icon' => $icon_class, ); } } return $active; } /** * Builds the class list for a testimonial's `.cfbk-testimonial-display-wrapper` * card, shared by every template (templates/template-1.php etc.) so the * "no image" reflow class doesn't have to be duplicated in each one. * * @param array $item A single testimonials[] entry. * @param array $extra Extra classes specific to the calling template * (e.g. template-3's 'cfbk-alt-left' / 'cfbk-alt-right'). */ public static function wrapper_classes( array $item, array $extra = array() ): string { $classes = array_merge( array( 'cfbk-testimonial-display-wrapper', 'cfbk-grid-boxes' ), $extra ); if ( empty( $item['image']['url'] ) && empty( $item['image']['id'] ) ) { $classes[] = 'cfbk-no-img-class'; } return implode( ' ', $classes ); } }