Skip to content

Instantly share code, notes, and snippets.

@mgibbs189
Created September 25, 2019 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgibbs189/3239d45c7788c75e1a9a0120172fd35b to your computer and use it in GitHub Desktop.
Save mgibbs189/3239d45c7788c75e1a9a0120172fd35b to your computer and use it in GitHub Desktop.
Layout builder - color icons based on ACF repeater color field
<?php
add_filter( 'facetwp_builder_item_value', function( $value, $item ) {
if ( 'phone-colors' == $item['settings']['name'] ) {
if ( is_array( $value ) ) {
$temp = '<style>.color-square { display: inline-block; width: 20px; height: 20px; border: 1px solid #000; border-radius: 50%; margin-right:5px; }</style>';
$value = wp_list_pluck( $value, 'color' );
foreach ( $value as $val ) {
$temp .= '<div class="color-square" style="background-color:' . $val . '"></div>';
}
$value = $temp;
}
}
return $value;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment