PHP
$this->add_control(
"column_distribution",
[
"label" => esc_html__("Spalten Verteilung", "elementor"),
"type" => \Elementor\Controls_Manager::TEXT,
"description" => esc_html__("Trennen Sie die Spalten mit einem , ohne Leerzeichen. ", "elementor"),
"default" => "1"
]
);
protected function zählenDerColumns($dis, $elementCount) {
$data = explode(",", $dis);
$ergebnis = array();
$dataCount = 0;
foreach($data as $elem) {
$item = intval($elem);
$dataCount += $item;
$ergebnis[] = $item;
}
if ($dataCount != $elementCount) {
return 0;
} else {
return $ergebnis;
}
}
protected function render() {
$settings = $this->get_settings_for_display();
$fallback_defaults = [
'fa fa-check',
'fa fa-times',
'fa fa-dot-circle-o',
];
$this->add_render_attribute( 'icon_list', 'class', 'elementor-icon-list-items' );
$this->add_render_attribute( 'list_item', 'class', 'elementor-icon-list-item' );
if ( 'inline' === $settings['view'] ) {
$this->add_render_attribute( 'icon_list', 'class', 'elementor-inline-items' );
$this->add_render_attribute( 'list_item', 'class', 'elementor-inline-item' );
}
?>
<div <?php $this->print_render_attribute_string( 'icon_list' ); ?>>
<?php
$item_count = count($settings["icon_list"]);
$daten = $this->zählenDerColumns($settings["column_distribution"],$item_count);
$datenCount = 0;
$datenIndex = 0;
foreach ( $settings['icon_list'] as $index => $item ) :
$repeater_setting_key = $this->get_repeater_setting_key( 'text', 'icon_list', $index );
$this->add_render_attribute( $repeater_setting_key, 'class', 'elementor-icon-list-text' );
$this->add_inline_editing_attributes( $repeater_setting_key );
$migration_allowed = \Elementor\Icons_Manager::is_migration_allowed();
if($datenCount == 0) {
?> <div> <?php ;
}
?>
<span class="elementor-icon-list-item elementor-inline-item elementor-repeater-item-<?php echo esc_attr($item["_id"]);?> inner-item">
<?php
if ( ! empty( $item['link']['url'] )) {
$link_key = 'link_' . $index;
$this->add_link_attributes( $link_key, $item['link'] );
?>
<a <?php $this->print_render_attribute_string( $link_key ); ?>>
<?php
}
if ( ! isset( $item['icon'] ) && ! $migration_allowed ) {
$item['icon'] = isset( $fallback_defaults[ $index ] ) ? $fallback_defaults[ $index ] : 'fa fa-check';
}
$migrated = isset( $item['__fa4_migrated']['selected_icon'] );
$is_new = ! isset( $item['icon'] ) && $migration_allowed;
if ( ! empty( $item['icon'] ) || ( ! empty( $item['selected_icon']['value'] ) && $is_new ) ) :
?>
<span class="elementor-icon-list-icon">
<?php
if ( $is_new || $migrated ) {
\Elementor\Icons_Manager::render_icon( $item['selected_icon'], [ 'aria-hidden' => 'true' ] );
} else { ?>
<i class="<?php echo esc_attr( $item['icon'] ); ?>" aria-hidden="true"></i>
<?php } ?>
</span>
<?php endif; ?>
<span <?php $this->print_render_attribute_string( $repeater_setting_key ); ?>> </span>
<?php if ( ! empty( $item['link']['url'] )) : ?>
</a>
<?php endif; ?>
</span>
<?php
if ($daten == 0 || $datenCount+1 == $daten[$datenIndex]) {
?> </div> <?php ;
$datenCount = 0;
$datenIndex++;
}
else $datenCount++;
endforeach;
?>
</div>
<?php
}
Alles anzeigen