Лагерь: Секция Hero
This commit is contained in:
parent
015536f687
commit
bfec139818
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
require_once get_template_directory() . '/inc/helpers.php';
|
||||
require_once get_template_directory() . '/inc/template-tags.php';
|
||||
/* --- Удаляем мета из YOASTSEO START--- */
|
||||
add_filter( 'wpseo_json_ld_output', '__return_false' );
|
||||
/* --- Удаляем мета из YOASTSEO END --- */
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'render_hero_metric' ) ) :
|
||||
function render_hero_metric( array $metric ): void {
|
||||
set_query_var( 'hero_metric', $metric );
|
||||
get_template_part( 'template-parts/hero-metric' );
|
||||
}
|
||||
endif;
|
||||
20
wp-content/themes/dekart/inc/template-tags.php
Normal file
20
wp-content/themes/dekart/inc/template-tags.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Вспомогательные функции для шаблонов
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'render_hero_metric' ) ) :
|
||||
function render_hero_metric( array $metric ): void {
|
||||
$icon = ! empty( $metric['img_id'] )
|
||||
? wp_get_attachment_url( $metric['img_id'] )
|
||||
: $metric['default_icon'];
|
||||
|
||||
?>
|
||||
<div class="wrapper__propositions">
|
||||
<img src="<?php echo esc_url( $icon ); ?>" alt="">
|
||||
<h3><?php echo esc_html( $metric['number'] ); ?></h3>
|
||||
<p><?php echo esc_html( $metric['label'] ); ?></p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
endif;
|
||||
@ -54,23 +54,7 @@ $metrics = [
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Вспомогательная функция для вывода одной метрики
|
||||
*/
|
||||
if ( ! function_exists( 'render_hero_metric' ) ) :
|
||||
function render_hero_metric( array $metric ): void {
|
||||
$icon = ! empty( $metric['img_id'] )
|
||||
? wp_get_attachment_url( $metric['img_id'] )
|
||||
: $metric['default_icon'];
|
||||
?>
|
||||
<div class="wrapper__propositions">
|
||||
<img src="<?php echo esc_url( $icon ); ?>" alt="">
|
||||
<h3><?php echo esc_html( $metric['number'] ); ?></h3>
|
||||
<p><?php echo esc_html( $metric['label'] ); ?></p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
endif;
|
||||
|
||||
?>
|
||||
|
||||
<section class="hero-media-search">
|
||||
@ -84,7 +68,9 @@ endif;
|
||||
|
||||
<!-- Метрики (десктоп) -->
|
||||
<div class="hero-media-search__propositions on-desktop">
|
||||
<?php foreach ( $metrics as $metric ) : render_hero_metric( $metric ); endforeach; ?>
|
||||
<?php foreach ( $metrics as $metric ) : ?>
|
||||
<?php render_hero_metric( $metric ); ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<!-- CTA (десктоп) -->
|
||||
@ -121,7 +107,9 @@ endif;
|
||||
<!-- Метрики + CTA (мобильная версия) -->
|
||||
<div class="hero-media-search__wrapper">
|
||||
<div class="hero-media-search__propositions on-mobile">
|
||||
<?php foreach ( $metrics as $metric ) : render_hero_metric( $metric ); endforeach; ?>
|
||||
<?php foreach ( $metrics as $metric ) : ?>
|
||||
<?php render_hero_metric( $metric ); ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div class="hero-cta on-mobile">
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
$metric = get_query_var( 'hero_metric' );
|
||||
$icon_url = $metric['img']
|
||||
? wp_get_attachment_url( $metric['img'] )
|
||||
: $metric['default_icon'];
|
||||
?>
|
||||
<div class="wrapper__propositions">
|
||||
<img src="<?php echo esc_url( $icon_url ); ?>" alt="">
|
||||
<h3><?php echo esc_html( $metric['number'] ); ?></h3>
|
||||
<p><?php echo esc_html( $metric['label'] ); ?></p>
|
||||
</div>
|
||||
Loading…
Reference in New Issue
Block a user