get_render_attribute_string( $slide_setting_key ) . '>' . $link_tag . '
';
if ( $link ) {
$slide_html .= '';
}
$slide_html .= '
';
$slides[] = $slide_html;
}
if ( empty( $slides ) ) {
return;
}
$swiper_class = Plugin::$instance->experiments->is_feature_active( 'e_swiper_latest' ) ? 'swiper' : 'swiper-container';
$has_autoplay_enabled = 'yes' === $this->get_settings_for_display( 'autoplay' );
$this->add_render_attribute( [
'carousel' => [
'class' => 'elementor-image-carousel swiper-wrapper',
'aria-live' => $has_autoplay_enabled ? 'off' : 'polite',
],
'carousel-wrapper' => [
'class' => 'elementor-image-carousel-wrapper ' . $swiper_class,
'dir' => $settings['direction'],
],
] );
$show_dots = ( in_array( $settings['navigation'], [ 'dots', 'both' ] ) );
$show_arrows = ( in_array( $settings['navigation'], [ 'arrows', 'both' ] ) );
if ( 'yes' === $settings['image_stretch'] ) {
$this->add_render_attribute( 'carousel', 'class', 'swiper-image-stretch' );
}
$slides_count = count( $settings['carousel'] );
?>
print_render_attribute_string( 'carousel-wrapper' ); ?>>
print_render_attribute_string( 'carousel' ); ?>>
render_swiper_button( 'previous' ); ?>
render_swiper_button( 'next' ); ?>
wp_get_attachment_url( $attachment['id'] ),
];
}
/**
* Retrieve image carousel caption.
*
* @since 1.2.0
* @access private
*
* @param array $attachment
*
* @return string The caption of the image.
*/
private function get_image_caption( $attachment ) {
$caption_type = $this->get_settings_for_display( 'caption_type' );
if ( empty( $caption_type ) ) {
return '';
}
$attachment_post = get_post( $attachment['id'] );
if ( Utils::has_invalid_post_permissions( $attachment_post ) ) {
return '';
}
if ( 'caption' === $caption_type ) {
return $attachment_post->post_excerpt;
}
if ( 'title' === $caption_type ) {
return $attachment_post->post_title;
}
if ( empty( $attachment_post->post_content ) ) {
return '';
}
return $attachment_post->post_content;
}
private function render_swiper_button( $type ) {
$direction = 'next' === $type ? 'right' : 'left';
$icon_settings = $this->get_settings_for_display( 'navigation_' . $type . '_icon' );
if ( empty( $icon_settings['value'] ) ) {
$icon_settings = [
'library' => 'eicons',
'value' => 'eicon-chevron-' . $direction,
];
}
Icons_Manager::render_icon( $icon_settings, [ 'aria-hidden' => 'true' ] );
}
}