v1.0.0
This commit is contained in:
commit
e1f5a47c96
22 changed files with 3155 additions and 0 deletions
64
templates/station-card.php
Normal file
64
templates/station-card.php
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
/**
|
||||
* Single station card template.
|
||||
*
|
||||
* @package FontdelboscCombustible
|
||||
*/
|
||||
|
||||
declare( strict_types=1 );
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Template data.
|
||||
*
|
||||
* @var array<string,mixed> $fontdelbosc_data
|
||||
* @var array<string,mixed> $fontdelbosc_options
|
||||
*/
|
||||
$fontdelbosc_station = is_array( $fontdelbosc_data['station'] ?? null ) ? $fontdelbosc_data['station'] : array();
|
||||
$fontdelbosc_options = Fontdelbosc_Combustible_Data_Manager::options();
|
||||
|
||||
$fontdelbosc_brand = Fontdelbosc_Combustible_Payload::str( Fontdelbosc_Combustible_Payload::get( $fontdelbosc_station, 'brand' ) ) ?? '';
|
||||
$fontdelbosc_muni = Fontdelbosc_Combustible_Payload::str( Fontdelbosc_Combustible_Payload::get( $fontdelbosc_station, 'municipality' ) ) ?? '';
|
||||
$fontdelbosc_sched = Fontdelbosc_Combustible_Payload::str( Fontdelbosc_Combustible_Payload::get( $fontdelbosc_station, 'schedule' ) ) ?? '';
|
||||
$fontdelbosc_dist = Fontdelbosc_Combustible_Payload::float( Fontdelbosc_Combustible_Payload::get( $fontdelbosc_station, 'distance' ) );
|
||||
$fontdelbosc_lat = Fontdelbosc_Combustible_Payload::float( Fontdelbosc_Combustible_Payload::get( $fontdelbosc_station, 'lat' ) );
|
||||
$fontdelbosc_lon = Fontdelbosc_Combustible_Payload::float( Fontdelbosc_Combustible_Payload::get( $fontdelbosc_station, 'lon' ) );
|
||||
$fontdelbosc_maps = ( null !== $fontdelbosc_lat && null !== $fontdelbosc_lon )
|
||||
? 'https://www.google.com/maps/search/?api=1&query=' . rawurlencode( $fontdelbosc_lat . ',' . $fontdelbosc_lon )
|
||||
: null;
|
||||
?>
|
||||
<div class="fdbc-card">
|
||||
<p class="fdbc-card__brand"><strong><?php echo esc_html( $fontdelbosc_brand ); ?></strong></p>
|
||||
<p class="fdbc-card__place">
|
||||
<?php
|
||||
echo esc_html( $fontdelbosc_muni );
|
||||
|
||||
if ( ! empty( $fontdelbosc_options['show_distance'] ) && null !== $fontdelbosc_dist ) {
|
||||
/* translators: %s: distance in kilometers. */
|
||||
echo ' ' . esc_html( sprintf( __( '(%s km away)', 'fontdelbosc-combustible' ), number_format_i18n( $fontdelbosc_dist, 1 ) ) );
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
<?php if ( null !== $fontdelbosc_maps ) : ?>
|
||||
<p class="fdbc-card__links">
|
||||
<a class="fdbc-card__map" href="<?php echo esc_url( $fontdelbosc_maps ); ?>" target="_blank" rel="nofollow noopener"><?php esc_html_e( 'Open in Google Maps', 'fontdelbosc-combustible' ); ?></a>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<?php if ( ! empty( $fontdelbosc_options['show_schedule'] ) && '' !== $fontdelbosc_sched ) : ?>
|
||||
<p class="fdbc-card__schedule">
|
||||
<?php
|
||||
/* translators: %s: station opening hours. */
|
||||
echo esc_html( sprintf( __( 'Schedule: %s', 'fontdelbosc-combustible' ), $fontdelbosc_sched ) );
|
||||
?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<ul class="fdbc-card__prices">
|
||||
<?php foreach ( Fontdelbosc_Combustible_Payload::arr( Fontdelbosc_Combustible_Payload::get( $fontdelbosc_station, 'selected_prices' ) ) as $fontdelbosc_label => $fontdelbosc_price ) : ?>
|
||||
<li class="fdbc-card__price">
|
||||
<span class="fdbc-card__fuel"><?php echo esc_html( Fontdelbosc_Combustible_Fuels::label( (string) $fontdelbosc_label ) ); ?></span>
|
||||
<span class="fdbc-card__value"><?php echo esc_html( number_format_i18n( Fontdelbosc_Combustible_Payload::float( $fontdelbosc_price ) ?? 0.0, 3 ) ); ?> €/l</span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
Loading…
Reference in a new issue