Inventory_Presser_Shortcode_Slider::content( array $atts )
content
Description
Creates the HTML content of the shortcode
Parameters
- $atts
-
(array) (Required)
Return
(string) HTML that renders a vehicle photo flexslider
Source
File: includes/shortcode/class-shortcode-inventory-slider.php
function content( $atts ) { // Canvass shortcode attributes $atts = shortcode_atts( array( 'per_page' => 10, 'captions' => 'true', 'orderby' => 'rand', 'order' => 'ASC', ), $atts, 'inventory_slider' ); // Use shortcode_atts_inventory_slider to filter the incoming attributes // Parse boolean values to make life easy on users. $atts['captions'] = filter_var( $atts['captions'], FILTER_VALIDATE_BOOLEAN ); // Get the vehicle IDs and loop over them $inventory_ids = self::get_vehicle_IDs( $atts ); if ( empty( $inventory_ids ) ) { return ''; } // Need flexslider for this content wp_enqueue_script( 'invp-flexslider' ); wp_enqueue_style( 'invp-flexslider' ); $flex_html = '<div class="flexslider flex-native">' . '<ul class="slides">'; foreach ( $inventory_ids as $inventory_id ) { $flex_html .= sprintf( '<li><a class="flex-link" href="%s">' . '<div class="grid-image" style="background-image: url(\'%s\');">' . '</div>', get_the_permalink( $inventory_id ), invp_get_the_photo_url( 'large', $inventory_id ) ); if ( $atts['captions'] ) { $flex_html .= sprintf( '<p class="flex-caption">%s</p>', get_the_title( $inventory_id ) ); } $flex_html .= '</a></li>'; } return $flex_html . '</ul></div>'; }
Expand full source code Collapse full source code View on Github