Inventory_Presser_Shortcode_Photo_Slider::content( array $atts )

content

Description Description

Creates the HTML content of the shortcode


Top ↑

Parameters Parameters

$atts

(array) (Required)


Top ↑

Return Return

(string) HTML that renders a vehicle photo flexslider


Top ↑

Source Source

File: includes/shortcode/class-shortcode-photo-slider.php

			array(
				'id'               => null,
				'include_carousel' => true,
			),
			$atts,
			'photo_slider'
		); // Use shortcode_atts_inventory_slider to filter the incoming attributes.

		// Parse boolean values to make life easy on users.
		$atts['include_carousel'] = filter_var( $atts['include_carousel'], FILTER_VALIDATE_BOOLEAN );

		// Need flexslider for this content.
		wp_enqueue_style( 'flexslider' );
		wp_enqueue_style( 'invp-flexslider' );
		wp_enqueue_script( 'invp-flexslider' );

		// Was the post ID passed in as an argument?
		if ( ! empty( $atts['id'] ) ) {
			$post_id = intval( $atts['id'] );
		} else {
			$post_id = get_the_ID();
		}

		$image_url_lists = invp_get_the_photos( array( 'full', 'large', 'thumb' ), $post_id );

		ob_start();
		?>
		<div id="slider-width"></div>
		<div id="slider" class="flexslider">
			<ul class="slides">
			<?php

			if ( isset( $image_url_lists['large'] ) ) {
				$image_count = count( $image_url_lists['large'] );
				for ( $p = 0; $p < $image_count; $p++ ) {
					// Inventory Presser versions 8.1.0 and above provide the 'urls'.
					if ( isset( $image_url_lists['urls'][ $p ] ) ) {
						printf(
							'<li><a data-href="%s">%s</a></li>',
							$image_url_lists['urls'][ $p ],
							$image_url_lists['large'][ $p ]
						);
					} else {
						printf(
							'<li>%s</li>',
							$image_url_lists['large'][ $p ]
						);
					}
				}
			}
			?>
			</ul>
		</div>
		<?php

		if ( $atts['include_carousel'] && isset( $image_url_lists['thumb'] ) && count( $image_url_lists['thumb'] ) > 1 ) {
			?>
			<div id="carousel" class="flexslider no-preview">
				<ul class="slides">
				<?php

				foreach ( $image_url_lists['thumb'] as $image ) {
					printf( '<li>%s</li>', $image );
				}

				?>
				</ul>
			</div>