print_render_attribute_string('accordion'); ?>>
$item) :
$loopCounter = $index + 1;
// Builds the accordion ID
$acc_id = $item['tab_title']
? 'ui-e-' . sanitize_title($item['tab_title'])
: $ID . $loopCounter;
// Build the Aria ID
if ('sectionId' == $item['source']) {
$aria_id = 'ui-' . preg_replace('/#/', '', $item['section_id']);
} else {
$aria_id = 'ui-e-acc-' . $loopCounter;
}
// Creates the title and content atts
$tab_title_setting_key = $this->get_repeater_setting_key('tab_title', 'tabs', $index);
$tab_content_setting_key = $this->get_repeater_setting_key('tab_content', 'tabs', $index);
// Render title atts
// TODO: remove `ui-e-title` class after, at least, 3 releases from 1.2.1. Kept for compatibility purposes
$this->add_render_attribute($tab_title_setting_key, [
'class' => ['ui-e-accordion-title ui-e-title'],
]);
$this->add_render_attribute($tab_title_setting_key, 'class', ('right' == $settings['icon_align']) ? 'ui-right' : '');
// Render content atts
// TODO: remove `ui-e-content` class after, at least, 3 releases from 1.2.1. Kept for compatibility purposes
$this->add_render_attribute($tab_content_setting_key, [
'class' => ['ui-e-accordion-content ui-e-content'],
'style' => ($loopCounter === $settings['active_item']) ? '' : 'display:none;', // keep content hide if item not active (has to be set inline so jquery can take control over it)
'aria-labelledby' => $acc_id,
'id' => $aria_id
]);
// Check if the current accordion item uses sectionId as source
if ('sectionId' == $item['source']) {
// and also check if an ID was set
if ($item['section_id'] != '') {
$this->add_render_attribute($tab_content_setting_key, ['class' => ['ui-section-id']]); // class used by JS
$sectionWarning = "The element with ID
{$item['section_id']} is going to be inserted here on the front-end";
} else {
$sectionWarning = esc_html__("You didn't define an ID.", 'uicore-elements');
}
}
// Render item atts
// TODO: remove `ui-e-item` class after, at least, 3 releases from 1.2.1. Kept for compatibility purposes
$item_key = 'ui-e-item-' . $index;
$this->add_render_attribute($item_key, [
'class' => ($loopCounter === $settings['active_item']) ? 'ui-e-accordion-item ui-e-item ui-open' : 'ui-e-accordion-item ui-e-item',
'role' => 'button',
'tabindex' => '0',
'aria-expanded' => ($loopCounter === $settings['active_item']) ? 'true' : 'false',
'aria-controls' => $aria_id,
'id' => $acc_id,
]);
// Render schema atts if active
if ($this->is_option('schema_activity', 'yes')) {
$this->add_render_attribute($item_key, 'itemscope');
$this->add_render_attribute($item_key, 'itemprop', 'mainEntity');
$this->add_render_attribute($item_key, 'itemtype', 'https://schema.org/Question');
$this->add_render_attribute($tab_content_setting_key, 'itemscope');
$this->add_render_attribute($tab_content_setting_key, 'itemprop', 'acceptedAnswer', true);
$this->add_render_attribute($tab_content_setting_key, 'itemtype', 'https://schema.org/Answer', true);
$schema_text = $this->get_repeater_setting_key('schema_text', 'tabs', $index);
$schema_name = $this->get_repeater_setting_key('schema_name', 'tabs', $index);
$this->add_render_attribute($schema_text, 'itemprop', 'text');
$this->add_render_attribute($schema_name, 'itemprop', 'name');
// Sets the variables to empty to avoid undefined variable problems
} else {
$schema_text = $schema_name = '';
}
?>
print_render_attribute_string($item_key); ?>>
< print_render_attribute_string($tab_title_setting_key); ?>>
'true']); ?>
'true']); ?>
print_render_attribute_string($schema_name); ?>>
is_option('show_custom_icon', 'yes')) : ?>
'true']); ?>
>
print_render_attribute_string($tab_content_setting_key); ?>>
is_option('schema_activity', 'yes')) {
?>
print_render_attribute_string($schema_text); ?>>
parse_text_editor($item['tab_content']); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ($this->is_option('schema_activity', 'yes')) {
?>
is_edit_mode()) {
echo wp_kses($sectionWarning, ['em' => []]);
}
?>
widgets_manager->register(new Accordion());