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 $items Menu items. * @param stdClass $args Menu arguments. * @return array */ 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 ''; }