'aieo-store-head', 'data-rooster-ui' => self::UI, 'data-aieo-shops' => (string) wp_json_encode( AIEO_Store_Hours::config() ), ) ); $out = '

' . esc_html( $store['name'] ) . '

'; if ( '' !== $lead ) { $out .= '

' . esc_html( $lead ) . '

'; } $out .= '
'; if ( has_post_thumbnail( $pid ) ) { $inside = (int) get_post_meta( $pid, AIEO_Store_CPT::META_INSIDE_PHOTO, true ); $inside = ( $inside && wp_attachment_is_image( $inside ) ) ? $inside : 0; $sizes = '(max-width: 1023px) 92vw, 900px'; $out .= '
' . get_the_post_thumbnail( $pid, 'large', array( 'loading' => 'eager', 'fetchpriority' => 'high', 'decoding' => 'async', 'sizes' => $sizes, 'class' => 'aieo-look__front' ) ); if ( $inside ) { $alt = trim( (string) get_post_meta( $inside, '_wp_attachment_image_alt', true ) ); $alt = '' !== $alt ? $alt : sprintf( __( 'Inside %s', 'ai-eshop-optimizer' ), $store['name'] ); $out .= wp_get_attachment_image( $inside, 'large', false, array( 'class' => 'aieo-look__inside', 'loading' => 'lazy', 'decoding' => 'async', 'sizes' => $sizes, 'alt' => $alt ) ) . ''; } $out .= '
'; } $out .= '
'; if ( null !== $state ) { $out .= self::state_line( 'aieo-store-head__state', $state, $now ); } $street = trim( (string) ( $loc['street'] ?? '' ) ); $town = trim( AIEO_Store_Contact::postcode( $loc['postcode'] ?? '' ) . ' ' . trim( (string) ( $loc['locality'] ?? '' ) ) ); $phone = $store['phone']; if ( '' !== $street || '' !== $town || '' !== $phone ) { $out .= '
'; if ( '' !== $street || '' !== $town ) { $out .= '

' . implode( '
', array_map( 'esc_html', array_filter( array( $street, $town ), 'strlen' ) ) ) . '

'; } if ( '' !== $phone ) { $out .= AIEO_Store_Contact::phone( array_merge( $loc, array( 'phone' => $phone ) ), 'aieo-store-head__phone', $state, $now ); } $out .= '
'; } $out .= '
'; $out .= self::scale_table( $iv, $now, $store['name'] ); $acts = ''; $book = AIEO_Store_Page::book_link( $pid ); if ( $book ) { $acts .= '' . esc_html( $book['label'] ) . self::icon( 'arrow-right' ) . ''; } $way = AIEO_Store_Page::way( $pid ); if ( $way['steps'] ) { $acts .= '' . esc_html__( 'How to get here', 'ai-eshop-optimizer' ) . self::icon( 'map-pin' ) . ''; } if ( '' !== $acts ) { $out .= '
' . $acts . '
'; } AIEO_Store_Hours::need(); return $out . '
'; } private static function state_line( $class, array $state, $now ) { $open = __( 'Open now, until %s', 'ai-eshop-optimizer' ); $words = ( $state['open'] && ! $state['always'] ) ? sprintf( $open, AIEO_Store_Hours::hm( $state['minute'] ) ) : AIEO_Store_Hours::state_words( $state, $now ); return '

' . esc_html( $words ) . '

'; } public static function title_word_em( $title ) { $title = trim( (string) $title ); if ( '' === $title || ! preg_match( '//u', $title ) ) { return '' === $title ? 0.0 : 0.66 * strlen( $title ); } $title = (string) preg_replace( '/([\x{3040}-\x{30FF}\x{3400}-\x{9FFF}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}])/u', ' $1 ', $title ); $words = preg_split( '/\s+|(?<=[\-\x{2010}-\x{2015}])/u', $title, -1, PREG_SPLIT_NO_EMPTY ); $most = 0.0; foreach ( (array) $words as $word ) { $em = 0.0; preg_match_all( '/\X/u', $word, $chars ); foreach ( $chars[0] as $g ) { $c = (string) preg_replace( '/^(.).*$/us', '$1', $g ); if ( preg_match( '/[\x{3040}-\x{30FF}\x{3400}-\x{9FFF}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]/u', $c ) ) { $em += 1.0; } elseif ( false !== strpos( "ijltfıιίϊΐIJΙ'’.,:;!|-\u{2010}", $c ) ) { $em += 0.40; } elseif ( false !== strpos( 'rsczεέζξςτΊ', $c ) ) { $em += 0.53; } elseif ( false !== strpos( 'mwMWΜΨΦΉΏΎΌ', $c ) ) { $em += 1.06; } elseif ( false !== strpos( 'ωώφψ&', $c ) || preg_match( '/\p{Lu}/u', $c ) ) { $em += 0.82; } else { $em += 0.66; } } $most = max( $most, $em ); } return $most; } public static function hours_scale( array $loc, $pid, $block = null ) { $iv = AIEO_Store_Hours::intervals( $loc ); if ( ! $iv ) { return ''; } $tz = AIEO_Store_Hours::timezone( $loc, (int) $pid ); $zone = AIEO_Store_Hours::zone_attrs( $tz ); $name = (string) ( $loc['label'] ?? '' ); $wrap = self::wrapper( $block, array( 'class' => 'aieo-hours-scale-wrap', 'data-rooster-ui' => self::UI, 'data-aieo-shops' => (string) wp_json_encode( AIEO_Store_Hours::config() ), ) ); AIEO_Store_Hours::need(); return '
' . self::scale_table( $iv, AIEO_Store_Hours::now( null, $tz ), $name ) . '
'; } public static function scale_table( array $iv, $now, $name ) { if ( ! $iv ) { return ''; } self::style( 'aieo-hours-scale' ); $w = AIEO_Store_Hours::words(); $always = 1 === count( $iv ) && 0 === $iv[0][0] && AIEO_Store_Hours::WEEK === $iv[0][1]; $days = array_fill( 0, 7, array() ); foreach ( $iv as $x ) { if ( $always ) { break; } $d = intdiv( $x[0], 1440 ) % 7; $start = $x[0] % 1440; $days[ $d ][] = array( $start, $start + ( $x[1] - $x[0] ) ); } if ( $always ) { $days = array_fill( 0, 7, array( array( 0, 1440 ) ) ); } $a0 = 1440; $a1 = 0; foreach ( $days as $spans ) { foreach ( $spans as $s ) { $a0 = min( $a0, $s[0] ); $a1 = max( $a1, min( 2880, $s[1] ) ); } } if ( $a1 <= $a0 ) { return ''; } $len = $a1 - $a0; $today = intdiv( ( (int) $now % AIEO_Store_Hours::WEEK + AIEO_Store_Hours::WEEK ) % AIEO_Store_Hours::WEEK, 1440 ); $mod = ( (int) $now % 1440 + 1440 ) % 1440; $first = (int) get_option( 'start_of_week', 1 ); $cap = '' !== $name ? sprintf( __( 'Opening hours in %s', 'ai-eshop-optimizer' ), $name ) : __( 'Opening hours', 'ai-eshop-optimizer' ); $out = ''; for ( $i = 0; $i < 7; $i++ ) { $d = ( $first + $i ) % 7; $on = $d === $today; $bars = ''; $texts = array(); foreach ( $days[ $d ] as $s ) { $a = ( max( $a0, $s[0] ) - $a0 ) / $len; $b = ( min( $a1, $s[1] ) - $a0 ) / $len; $bars .= ''; $texts[] = $always ? $w['allDay'] : sprintf( $w['span'], AIEO_Store_Hours::hm( $s[0] ), AIEO_Store_Hours::hm( $s[1] ) ); } if ( $on && $mod >= $a0 && $mod <= $a1 ) { $bars .= ''; } $out .= '' . '' . ''; } return $out . '
' . esc_html( $cap ) . '
' . esc_html( $w['days'][ $d ] ) . '' . ( $texts ? implode( ', ', array_map( static fn ( $t ) => '' . esc_html( $t ) . '', $texts ) ) : esc_html( $w['closedDay'] ) ) . '
'; } public static function render_contact( $attrs, $content = '', $block = null ) { $attrs = wp_parse_args( is_array( $attrs ) ? $attrs : array(), array( 'locationSlug' => '', 'showState' => true, 'showAddress' => true, 'media' => implode( ',', AIEO_Store_Contact::MEDIA ), 'hours' => 'grouped' ) ); if ( ! class_exists( 'AIEO_Google_Reviews_Helpers' ) ) { return ''; } $loc = AIEO_Google_Reviews_Helpers::resolve_single( (string) $attrs['locationSlug'], $block ); if ( ! is_array( $loc ) ) { return ''; } $pid = class_exists( 'AIEO_Store_Locator_Block' ) ? (int) AIEO_Store_Locator_Block::store_post_for_location( $loc ) : 0; $tz = AIEO_Store_Hours::timezone( $loc, $pid ); $zone = AIEO_Store_Hours::zone_attrs( $tz ); $iv = AIEO_Store_Hours::intervals( $loc ); $now = AIEO_Store_Hours::now( null, $tz ); $state = $iv ? AIEO_Store_Hours::state( $iv, $now ) : null; $parts = ''; if ( ! empty( $attrs['showState'] ) && null !== $state ) { $parts .= self::state_line( 'aieo-store-contact__state', $state, $now ); } $facts = ''; if ( ! empty( $attrs['showAddress'] ) ) { $struct = array_filter( array( (string) ( $loc['street'] ?? '' ), trim( AIEO_Store_Contact::postcode( $loc['postcode'] ?? '' ) . ' ' . (string) ( $loc['locality'] ?? '' ) ) ), 'strlen' ); $addr = $struct ? implode( ', ', $struct ) : trim( (string) ( $loc['address'] ?? '' ) ); $maps = (string) AIEO_Google_Reviews_Helpers::maps_url( $loc ); if ( '' !== $addr ) { $facts .= '

' . esc_html__( 'Address', 'ai-eshop-optimizer' ) . ' ' . ( '' !== $maps ? '' . esc_html( $addr ) . '' : '' . esc_html( $addr ) . '' ) . '

'; } } $wanted = array_values( array_intersect( AIEO_Store_Contact::MEDIA, array_map( 'trim', explode( ',', (string) $attrs['media'] ) ) ) ); $media = ''; foreach ( $wanted as $medium ) { $value = AIEO_Store_Contact::value( $loc, $medium, $state, $now, 'span', 'aieo-store-contact__value' ); if ( '' === $value ) { continue; } $hidden = str_contains( $value, ' hidden>' ) ? ' hidden' : ''; $media .= '
  • ' . esc_html( AIEO_Store_Contact::label( $medium ) ) . ' ' . $value . '
  • '; } if ( '' !== $media ) { $facts .= ''; } if ( '' !== $facts ) { $parts .= '
    ' . $facts . '
    '; } if ( $iv && 'scale' === $attrs['hours'] ) { $parts .= '
    ' . self::scale_table( $iv, $now, (string) ( $loc['label'] ?? '' ) ) . '
    '; } elseif ( $iv && 'grouped' === $attrs['hours'] ) { $rows = ''; $today = intdiv( ( (int) $now % AIEO_Store_Hours::WEEK + AIEO_Store_Hours::WEEK ) % AIEO_Store_Hours::WEEK, 1440 ); foreach ( AIEO_Store_Hours::runs( $iv ) as $run ) { $spans = array_map( static fn ( $t ) => '' . esc_html( $t ) . '', explode( ', ', (string) $run['hours'] ) ); $rows .= '
    ' . esc_html( $run['label'] ) . '
    ' . implode( ', ', $spans ) . '
    '; } $cap = '' !== (string) ( $loc['label'] ?? '' ) ? sprintf( __( 'Opening hours in %s', 'ai-eshop-optimizer' ), (string) $loc['label'] ) : __( 'Opening hours', 'ai-eshop-optimizer' ); $parts .= '
    ' . $rows . '
    '; } if ( '' === $parts ) { return ''; } self::style( 'aieo-store-contact' ); AIEO_Store_Hours::need(); $wrap = self::wrapper( $block, array( 'class' => 'aieo-store-contact', 'data-rooster-ui' => 'rooster-one/store_contact', 'data-aieo-shops' => (string) wp_json_encode( AIEO_Store_Hours::config() ), ) ); return '
    ' . $parts . '
    '; } public static function render_staff( $attrs, $content = '', $block = null ) { $pid = AIEO_Store_Page::store_id( $block ); $store = $pid ? AIEO_Store_Page::store( $pid ) : null; $people = $store ? AIEO_Store_Page::people( $pid ) : array(); if ( ! $people ) { return ''; } $loc = AIEO_Store_Page::location( $pid ); $tz = AIEO_Store_Hours::timezone( $loc, $pid ); $zone = AIEO_Store_Hours::zone_attrs( $tz ); $nowdt = new DateTimeImmutable( 'now', $tz ); $words = self::staff_words(); $id = 'aieo-staff-' . $pid; $title = trim( (string) ( $attrs['heading'] ?? '' ) ); $title = '' !== $title ? $title : sprintf( __( 'Who you will meet in %s', 'ai-eshop-optimizer' ), $store['name'] ); $here = array(); foreach ( $people as $k => $p ) { $here[ $k ] = self::here( $p, $nowdt, $words ); } $wide = 0; foreach ( $here as $k => $h ) { if ( $h['in'] ) { $wide = $k; break; } } $page = (string) get_permalink( $pid ); $out = '
    'aieo-staff', 'aria-labelledby' => $id, 'data-rooster-ui' => self::UI, 'data-aieo-staff' => (string) wp_json_encode( array( 'words' => $words ) ), 'data-aieo-tz' => $zone['tz'], 'data-aieo-offset' => (string) $zone['offset'], 'data-aieo-rendered' => (string) $nowdt->getTimestamp(), ) ) . '>

    ' . esc_html( $title ) . '

    '; if ( count( $people ) > 1 && ( ! function_exists( 'rooster_device_class' ) || 'desktop' !== rooster_device_class() ) ) { $out .= '
    '; foreach ( $people as $k => $p ) { $out .= ''; } $out .= '
    '; } $first = (int) get_option( 'start_of_week', 1 ); $today = (int) $nowdt->format( 'w' ); $wpl = isset( $GLOBALS['wp_locale'] ) ? $GLOBALS['wp_locale'] : null; $out .= '
    '; } private static function here( array $p, DateTimeImmutable $now, array $words ) { $ts = $now->getTimestamp(); $tz = $now->getTimezone(); $away = ''; $mow = (int) $now->format( 'w' ) * 1440 + (int) $now->format( 'G' ) * 60 + (int) $now->format( 'i' ); $day0 = intdiv( $mow, 1440 ) * 1440; $week_today = array_filter( $p['week'], static function ( $s ) use ( $day0 ) { return $s[0] >= $day0 && $s[0] < $day0 + 1440; } ); if ( $p['today'] || null !== $p['next'] ) { foreach ( $p['today'] as $s ) { if ( $ts >= $s[0] && $ts < $s[1] ) { return array( 'in' => true, 'text' => sprintf( $words['inUntil'], wp_date( 'H:i', $s[1], $tz ) ), 'away' => '' ); } if ( $ts < $s[0] ) { return array( 'in' => false, 'text' => sprintf( $words['inFrom'], wp_date( 'H:i', $s[0], $tz ) ), 'away' => '' ); } } if ( ! $p['today'] && $week_today ) { $away = $now->format( 'Y-m-d' ); } if ( null !== $p['next'] && $p['next'][0] > $ts ) { return array( 'in' => false, 'text' => self::back( $now, ( new DateTimeImmutable( '@' . $p['next'][0] ) )->setTimezone( $tz ), $words ), 'away' => $away ); } } foreach ( $p['week'] as $s ) { foreach ( array( 0, AIEO_Store_Hours::WEEK ) as $wk ) { if ( '' === $away && $mow + $wk >= $s[0] && $mow + $wk < $s[1] ) { return array( 'in' => true, 'text' => sprintf( $words['inUntil'], AIEO_Store_Hours::hm( $s[1] ) ), 'away' => '' ); } } } $best = null; foreach ( $p['week'] as $s ) { $delta = ( ( $s[0] - $mow ) % AIEO_Store_Hours::WEEK + AIEO_Store_Hours::WEEK ) % AIEO_Store_Hours::WEEK; if ( '' !== $away && $s[0] >= $day0 && $s[0] < $day0 + 1440 ) { continue; } if ( null === $best || $delta < $best ) { $best = $delta; } } if ( null === $best ) { return array( 'in' => false, 'text' => '', 'away' => $away ); } $at = $mow % 1440 + $best; if ( $at < 1440 ) { return array( 'in' => false, 'text' => sprintf( $words['inFrom'], AIEO_Store_Hours::hm( $at ) ), 'away' => $away ); } return array( 'in' => false, 'text' => self::back( $now, $now->modify( '+' . intdiv( $at, 1440 ) . ' days' ), $words ), 'away' => $away ); } private static function back( DateTimeImmutable $now, DateTimeImmutable $then, array $words ) { $days = (int) $now->setTime( 0, 0 )->diff( $then->setTime( 0, 0 ) )->format( '%r%a' ); if ( 1 === $days ) { return $words['backTomorrow']; } if ( $days > 1 && $days < 7 ) { return sprintf( $words['backOn'], $words['days'][ (int) $then->format( 'w' ) ] ); } return sprintf( $words['backOn'], wp_date( 'j F', $then->getTimestamp(), $then->getTimezone() ) ); } public static function staff_words() { $w = AIEO_Store_Hours::words(); return array( 'inUntil' => __( 'In today until %s', 'ai-eshop-optimizer' ), 'inFrom' => __( 'In today from %s', 'ai-eshop-optimizer' ), 'backTomorrow' => __( 'Back tomorrow', 'ai-eshop-optimizer' ), 'backOn' => __( 'Back on %s', 'ai-eshop-optimizer' ), 'days' => $w['days'], ); } public static function render_way( $attrs, $content = '', $block = null ) { $pid = AIEO_Store_Page::store_id( $block ); $way = $pid ? AIEO_Store_Page::way( $pid ) : array( 'steps' => array() ); if ( ! $way['steps'] ) { return ''; } $title = trim( (string) ( $attrs['heading'] ?? '' ) ); $title = '' !== $title ? $title : $way['title']; if ( '' === $title ) { $mins = array_sum( wp_list_pluck( $way['steps'], 'minutes' ) ); $from = (string) $way['steps'][0]['place']; $title = ( $mins > 0 && '' !== $from ) ? sprintf( _n( '%1$s minute from %2$s', '%1$s minutes from %2$s', $mins, 'ai-eshop-optimizer' ), number_format_i18n( $mins ), $from ) : __( 'How to get here', 'ai-eshop-optimizer' ); } $id = 'aieo-way-h-' . $pid; $loc = AIEO_Store_Page::location( $pid ); $maps = $loc && class_exists( 'AIEO_Google_Reviews_Helpers' ) ? AIEO_Google_Reviews_Helpers::maps_url( $loc ) : ''; $out = '
    'aieo-way', 'id' => 'aieo-way', 'aria-labelledby' => $id, 'data-rooster-ui' => self::UI, ) ) . '>

    ' . esc_html( $title ) . '

    '; if ( '' !== $maps ) { $out .= '' . esc_html__( 'Open in maps', 'ai-eshop-optimizer' ) . self::icon( 'external-link' ) . ''; } if ( $way['lines'] ) { $out .= '
    '; foreach ( $way['lines'] as $l ) { $out .= '
    ' . ( '' !== $l['icon'] ? self::icon( $l['icon'] ) : '' ) . '' . esc_html( $l['label'] ) . '
    ' . esc_html( $l['text'] ) . '
    '; } $out .= '
    '; } $out .= '
      '; foreach ( $way['steps'] as $s ) { $out .= '
    1. ' . esc_html( $s['place'] ) . '

      '; if ( '' !== $s['text'] ) { $out .= '

      ' . esc_html( $s['text'] ) . '

      '; } if ( $s['minutes'] > 0 ) { $out .= '' . esc_html( sprintf( __( '%s min', 'ai-eshop-optimizer' ), number_format_i18n( $s['minutes'] ) ) ) . ''; } $out .= '
    2. '; } return $out . '
    '; } public static function review_one( $loc, array $attrs, $block = null ) { if ( ! is_array( $loc ) || empty( $loc['id'] ) || ! class_exists( 'AIEO_Google_Reviews_Helpers' ) ) { return ''; } $min = max( 1, min( 5, (int) ( $attrs['minRating'] ?? 5 ) ) ); $rows = AIEO_Google_Reviews_Helpers::fetch_reviews_for_location( (int) $loc['id'], 12, $min ); $pick = null; foreach ( $rows as $r ) { $len = function_exists( 'mb_strlen' ) ? mb_strlen( trim( (string) $r['review_text'] ) ) : strlen( trim( (string) $r['review_text'] ) ); if ( $len >= 20 && $len <= 260 ) { $pick = $r; break; } if ( null === $pick && $len > 0 ) { $pick = $r; } } if ( null === $pick ) { return ''; } self::style( 'aieo-store-voice' ); $author = trim( (string) strtok( trim( (string) $pick['author_name'] ), ' ' ) ); $when = (int) $pick['review_time'] > 0 ? wp_date( 'F Y', (int) $pick['review_time'] ) : ''; $rating = isset( $loc['baseline_rating'] ) && '' !== (string) $loc['baseline_rating'] ? (float) $loc['baseline_rating'] : 0.0; $count = isset( $loc['baseline_review_count'] ) ? (int) $loc['baseline_review_count'] : 0; $maps = AIEO_Google_Reviews_Helpers::maps_url( $loc ); $out = '
    'aieo-voice', 'aria-label' => __( 'Reviews', 'ai-eshop-optimizer' ), 'data-rooster-ui' => self::UI, ) ) . '>

    ' . esc_html( trim( (string) $pick['review_text'] ) ) . '

    '; if ( '' !== $author ) { $out .= '

    ' . esc_html( '' !== $when ? sprintf( __( '%1$s, %2$s', 'ai-eshop-optimizer' ), $author, $when ) : $author ) . '

    '; } if ( $rating > 0 && $count > 0 ) { $out .= '

    ' . sprintf( esc_html( _n( '%1$s from %2$s Google review', '%1$s from %2$s Google reviews', $count, 'ai-eshop-optimizer' ) ), '' . esc_html( number_format_i18n( $rating, 1 ) ) . '', esc_html( number_format_i18n( $count ) ) ) . '

    '; } if ( '' !== $maps ) { $out .= '

    ' . esc_html__( 'Read them on Google', 'ai-eshop-optimizer' ) . '

    '; } return $out . '
    '; } public static function others( $block = null ) { $pid = AIEO_Store_Page::store_id( $block ); if ( ! $pid ) { return ''; } $rows = ''; $self = AIEO_Store_Page::canonical( $pid ); foreach ( AIEO_Store_Page::stores() as $s ) { if ( (int) $s['id'] === $self ) { continue; } $shown = AIEO_Store_Page::local( (int) $s['id'] ); $loc = AIEO_Store_Page::location( (int) $s['id'] ); $tz = AIEO_Store_Hours::timezone( $loc, (int) $s['id'] ); $zone = AIEO_Store_Hours::zone_attrs( $tz ); $now = AIEO_Store_Hours::now( null, $tz ); $iv = AIEO_Store_Hours::intervals( $loc ); $state = AIEO_Store_Hours::state( $iv, $now ); $lead = trim( (string) get_post_field( 'post_excerpt', $shown ) ); $rows .= ''; if ( has_post_thumbnail( (int) $s['id'] ) ) { $rows .= '
    ' . get_the_post_thumbnail( (int) $s['id'], 'large', array( 'loading' => 'lazy', 'decoding' => 'async', 'sizes' => '(max-width: 1023px) 92vw, 740px', 'alt' => '' ) ) . '
    '; } $rows .= '
    ' . ( '' !== $lead ? '

    ' . esc_html( $lead ) . '

    ' : '' ) . '

    ' . esc_html( $s['name'] ) . self::icon( 'arrow-right' ) . '

    '; if ( null !== $state ) { $rows .= self::state_line( 'aieo-others__state', $state, $now ); } $rows .= '
    '; } if ( '' === $rows ) { return ''; } self::style( 'aieo-store-others' ); AIEO_Store_Hours::need(); return '
    'aieo-others', 'aria-label' => __( 'Our other shops', 'ai-eshop-optimizer' ), 'data-rooster-ui' => self::UI, 'data-aieo-shops' => (string) wp_json_encode( AIEO_Store_Hours::config() ), ) ) . '>' . $rows . '
    '; } private static function wrapper( $block, array $attrs ) { if ( $block instanceof WP_Block ) { return get_block_wrapper_attributes( $attrs ); } $out = array(); foreach ( $attrs as $k => $v ) { $out[] = esc_attr( $k ) . '="' . esc_attr( (string) $v ) . '"'; } return implode( ' ', $out ); } private static function style( $handle ) { AIEO_Store_Page::register_style( $handle, $handle . '.css' ); wp_enqueue_style( $handle ); } private static function icon( $slug ) { if ( function_exists( 'rooster_icon' ) && function_exists( 'rooster_has_icon' ) && rooster_has_icon( $slug ) ) { return (string) rooster_icon( $slug, array( 'class' => 'aieo-store-icon' ) ); } return ''; } private static function num( $v, $decimals = 4 ) { $s = number_format( (float) $v, $decimals, '.', '' ); $s = false !== strpos( $s, '.' ) ? rtrim( rtrim( $s, '0' ), '.' ) : $s; return ( '' === $s || '-0' === $s || '-' === $s ) ? '0' : $s; } } }