acf_field_icon_picker::render_icon_list_tab
Renders an icon list tab (i.e. dashicons, custom icons).
Method of the class: acf_field_icon_picker{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$acf_field_icon_picker = new acf_field_icon_picker(); $acf_field_icon_picker->render_icon_list_tab( $tab_name, $field );
- $tab_name(string) (required)
- The name of the tab being rendered.
- $field(array) (required)
- The Icon Picker field being rendered.
Changelog
| Since 6.4 | Introduced. |
acf_field_icon_picker::render_icon_list_tab() acf field icon picker::render icon list tab code ACF 6.8.8
<?php
public function render_icon_list_tab( $tab_name, $field ) {
$custom_icons = '';
if ( 'dashicons' !== $tab_name ) {
$custom_icons = apply_filters( 'acf/fields/icon_picker/' . $tab_name . '/icons', array(), $field );
// Bail if this is a custom tab and no icons are provided.
if ( ! is_array( $custom_icons ) || empty( $custom_icons ) ) {
return;
}
}
?>
<div class="acf-icon-list-search-wrap">
<?php
acf_text_input(
array(
'class' => 'acf-icon-list-search-input',
'placeholder' => esc_html__( 'Search icons...', 'acf' ),
'type' => 'search',
)
);
?>
</div>
<div
class="acf-icon-list"
role="radiogroup"
data-parent-tab="<?php echo esc_attr( $tab_name ); ?>"
<?php if ( ! empty( $custom_icons ) ) : ?>
<?php printf( 'data-icons="%s"', esc_attr( wp_json_encode( $custom_icons ) ) ); ?>
<?php endif; ?>
></div>
<div class="acf-icon-list-empty">
<img src="<?php echo esc_url( acf_get_url( 'assets/images/face-sad.svg' ) ); ?>" />
<p class="acf-no-results-text">
<?php
printf(
/* translators: %s: The invalid search term */
esc_html__( "No search results for '%s'", 'acf' ),
'<span class="acf-invalid-icon-list-search-term"></span>'
);
?>
</p>
</div>
<?php
}