Inventory_Presser_Shortcode_Archive::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 an archive-vehicle template


Top ↑

Source Source

File: includes/class-shortcode-archive.php

	function content( $atts )
	{
		wp_enqueue_style( 'invp-attribute-table' );
		wp_enqueue_style( 'invp_archive_vehicle' );
		$plugin_settings = INVP::settings();

		$atts = shortcode_atts( array(
			'meta_key'       => apply_filters( 'invp_prefix_meta_key', $plugin_settings['sort_vehicles_by'] ),
			'order'          => $plugin_settings['sort_vehicles_order'],
			'orderby'        => apply_filters( 'invp_prefix_meta_key', $plugin_settings['sort_vehicles_by'] ),
			'paged'          => ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1,
			'posts_per_page' => get_option( 'posts_per_page' ),
			'post_status'    => 'publish',
			'show_titles'    => true,
		), $atts );

		//Don't let input change the post type, that would be silly.
		$atts['post_type'] = INVP::POST_TYPE;
	 
		query_posts( $this->clean_attributes_for_query( $atts ) );
		$output = '';
		if ( have_posts() )
		{
			while ( have_posts() )
			{
				the_post();
				$shortcode = sprintf( '[invp_archive_vehicle show_titles="%s"]', strval( $atts['show_titles'] ) );
				$output .= apply_shortcodes( $shortcode );
			}
		}

		//Paged navigation
		$output .= $this->paging_html();

		wp_reset_query();
		return $output;
	}