invp_get_the_carfax_icon_html( int|null $post_ID = null )
Outputs Carfax button HTML or empty string if the vehicle is not eligible or does not have a free report.
Parameters Parameters
- $post_ID
-
(int|null) (Optional) The post ID of a vehicle. Must be passed when using this method outside the loop.
Default value: null
Return Return
(string) HTML that renders a Carfax button or empty string
Source Source
File: includes/template-tags.php
function invp_get_the_carfax_icon_html( $post_ID = null ) { // Does this vehicle have a Carfax-eligible VIN? if ( strlen( invp_get_the_VIN( $post_ID ) ) !== 17 || invp_get_the_year( $post_ID ) < 1980 ) { return ''; } /** * Do we have a report? Can't just rely on there being a report URL * because as long as we have a VIN we can create a fallback report * URL. */ if ( ! invp_have_carfax_report( $post_ID ) ) { return ''; } $svg_url = invp_get_the_carfax_url_svg( $post_ID ); if ( empty( $svg_url ) ) { return ''; } return sprintf( '<a href="%s" target="_blank" rel="noopener noreferrer"><img src="%s" alt="SHOW ME THE CARFAX" /></a>', invp_get_the_carfax_url_report( $post_ID ), $svg_url ); }
Expand full source codeCollapse full source codeView on Github