Тема магазина по макету Figma
Каталог, карточка товара, корзина, оформление заказа и блог на WooCommerce. Стили разложены по слоям: токены из Figma, база, компоненты, страницы, брейкпоинты. Цвета, типографика, радиусы и отступы взяты из Variables и текстовых стилей макета, ниже по слоям хардкода нет. Иконки — Phosphor, вставляются инлайном как SVG, символами ничего не рисуется. Стили WooCommerce отключены, вёрстка своя, !important не используется.
This commit is contained in:
commit
29d10ce4cf
72 files changed
+7465
No files matched your search
+144
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
/**
|
||||
* Theme supports, menus and the customizer surface.
|
||||
*
|
||||
* @package VyatkaShop
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure theme features and navigation.
|
||||
*/
|
||||
function vyatka_shop_setup(): void {
|
||||
load_theme_textdomain( 'vyatka-shop', get_template_directory() . '/languages' );
|
||||
add_theme_support( 'title-tag' );
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
add_theme_support( 'html5', array( 'search-form', 'gallery', 'caption', 'style', 'script' ) );
|
||||
add_theme_support(
|
||||
'custom-logo',
|
||||
array(
|
||||
'height' => 100,
|
||||
'width' => 260,
|
||||
'flex-height' => true,
|
||||
'flex-width' => true,
|
||||
)
|
||||
);
|
||||
add_theme_support( 'woocommerce' );
|
||||
add_theme_support( 'wc-product-gallery-lightbox' );
|
||||
add_theme_support( 'wc-product-gallery-slider' );
|
||||
add_image_size( 'vyatka-product', 720, 560, true );
|
||||
add_image_size( 'vyatka-news', 860, 620, true );
|
||||
|
||||
register_nav_menus(
|
||||
array(
|
||||
'primary' => __( 'Главное меню', 'vyatka-shop' ),
|
||||
'footer' => __( 'Меню в подвале', 'vyatka-shop' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action( 'after_setup_theme', 'vyatka_shop_setup' );
|
||||
|
||||
/**
|
||||
* Store options editable from Appearance > Customize.
|
||||
*
|
||||
* @param WP_Customize_Manager $customizer Customizer instance.
|
||||
*/
|
||||
function vyatka_shop_customize_register( WP_Customize_Manager $customizer ): void {
|
||||
$customizer->add_section(
|
||||
'vyatka_home',
|
||||
array(
|
||||
'title' => __( 'Главная страница', 'vyatka-shop' ),
|
||||
'priority' => 30,
|
||||
)
|
||||
);
|
||||
|
||||
$fields = array(
|
||||
'vyatka_hero_title' => array(
|
||||
'label' => __( 'Заголовок', 'vyatka-shop' ),
|
||||
'default' => __( 'Строим тёплые деревянные дома', 'vyatka-shop' ),
|
||||
),
|
||||
'vyatka_hero_text' => array(
|
||||
'label' => __( 'Описание', 'vyatka-shop' ),
|
||||
'default' => __( 'Учитывая ключевые сценарии поведения, существующая теория в значительной степени обусловливает важность дальнейших направлений развития.', 'vyatka-shop' ),
|
||||
),
|
||||
);
|
||||
|
||||
foreach ( $fields as $key => $field ) {
|
||||
$customizer->add_setting(
|
||||
$key,
|
||||
array(
|
||||
'default' => $field['default'],
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
)
|
||||
);
|
||||
$customizer->add_control(
|
||||
$key,
|
||||
array(
|
||||
'label' => $field['label'],
|
||||
'section' => 'vyatka_home',
|
||||
'type' => 'text',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
add_action( 'customize_register', 'vyatka_shop_customize_register' );
|
||||
|
||||
/**
|
||||
* Match the deterministic desktop blog grid from the design.
|
||||
*
|
||||
* @param WP_Query $query Current query.
|
||||
*/
|
||||
function vyatka_shop_blog_query( WP_Query $query ): void {
|
||||
if ( ! is_admin() && $query->is_main_query() && $query->is_home() ) {
|
||||
$query->set( 'posts_per_page', 9 );
|
||||
}
|
||||
}
|
||||
add_action( 'pre_get_posts', 'vyatka_shop_blog_query' );
|
||||
|
||||
/**
|
||||
* Keep the primary navigation labels aligned with the design even when a
|
||||
* previously saved WordPress menu contains an old typo.
|
||||
*
|
||||
* @param array<int,WP_Post> $items Menu items.
|
||||
* @param stdClass $args Menu arguments.
|
||||
* @return array<int,WP_Post>
|
||||
*/
|
||||
function vyatka_shop_primary_menu_labels( array $items, stdClass $args ): array {
|
||||
if ( 'primary' !== ( $args->theme_location ?? '' ) ) {
|
||||
return $items;
|
||||
}
|
||||
|
||||
foreach ( $items as $item ) {
|
||||
$path = (string) wp_parse_url( (string) $item->url, PHP_URL_PATH );
|
||||
if ( '/blog/' === trailingslashit( $path ) ) {
|
||||
$item->title = __( 'Блог', 'vyatka-shop' );
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
add_filter( 'wp_nav_menu_objects', 'vyatka_shop_primary_menu_labels', 10, 2 );
|
||||
|
||||
/**
|
||||
* Render a fallback primary menu before a menu is assigned.
|
||||
*/
|
||||
function vyatka_shop_fallback_menu(): void {
|
||||
$links = array(
|
||||
home_url( '/' ) => __( 'Главная', 'vyatka-shop' ),
|
||||
home_url( '/catalog/' ) => __( 'Каталог', 'vyatka-shop' ),
|
||||
get_post_type_archive_link( 'post' ) ?: home_url( '/blog/' ) => __( 'Блог', 'vyatka-shop' ),
|
||||
home_url( '/#contacts' ) => __( 'Контакты', 'vyatka-shop' ),
|
||||
);
|
||||
echo '<ul>';
|
||||
foreach ( $links as $url => $label ) {
|
||||
printf(
|
||||
'<li><a href="%1$s">%2$s</a></li>',
|
||||
esc_url( $url ),
|
||||
esc_html( $label )
|
||||
);
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
Reference in new issue
Block a user