chore: complete M1.1 runtime QA and release packaging
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
add_action('wp_enqueue_scripts', 'xshop_enqueue_assets');
|
||||
|
||||
function xshop_enqueue_assets(): void {
|
||||
$ver = defined('XSHOP_VERSION') ? XSHOP_VERSION : '1.0.0';
|
||||
|
||||
// Tokens → base → layout → components → utilities → style.css
|
||||
wp_enqueue_style('xshop-tokens', XSHOP_THEME_URI . '/assets/css/tokens.css', [], $ver);
|
||||
wp_enqueue_style('xshop-base', XSHOP_THEME_URI . '/assets/css/base.css', ['xshop-tokens'], $ver);
|
||||
wp_enqueue_style('xshop-layout', XSHOP_THEME_URI . '/assets/css/layout.css', ['xshop-base'], $ver);
|
||||
wp_enqueue_style('xshop-components', XSHOP_THEME_URI . '/assets/css/components.css', ['xshop-layout'], $ver);
|
||||
wp_enqueue_style('xshop-utilities', XSHOP_THEME_URI . '/assets/css/utilities.css', ['xshop-components'], $ver);
|
||||
wp_enqueue_style('xshop-style', get_stylesheet_uri(), ['xshop-utilities'], $ver);
|
||||
wp_style_add_data('xshop-style', 'rtl', 'replace');
|
||||
|
||||
// Conditionally avoid WooCommerce styles on non-WC pages – WC styles already dequeued in inc/woocommerce/setup.php.
|
||||
// Theme JS is tiny; feature modules conditionally enqueued elsewhere.
|
||||
wp_enqueue_script('xshop', XSHOP_THEME_URI . '/assets/js/theme.js', [], $ver, true);
|
||||
|
||||
// Localized data for REST/AJAX (nonces, i18n hints).
|
||||
wp_localize_script('xshop', 'xshopData', [
|
||||
'restUrl' => esc_url_raw(rest_url('xshop/v1/')),
|
||||
'nonce' => wp_create_nonce('wp_rest'),
|
||||
'isRtl' => is_rtl(),
|
||||
'i18n' => [
|
||||
'searchPlaceholder' => esc_html__('Search products…', 'xshop'),
|
||||
'noResults' => esc_html__('No results found.', 'xshop'),
|
||||
],
|
||||
]);
|
||||
|
||||
if (is_singular() && comments_open() && get_option('thread_comments')) {
|
||||
wp_enqueue_script('comment-reply');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
add_filter('body_class', 'xshop_body_classes');
|
||||
|
||||
function xshop_body_classes(array $classes): array {
|
||||
$classes[] = 'xshop';
|
||||
$classes[] = xshop_is_dark_mode() ? 'xshop--dark' : 'xshop--light';
|
||||
if (xshop_has_woocommerce()) {
|
||||
$classes[] = 'xshop--has-woo';
|
||||
if (xshop_is_woocommerce_page()) {
|
||||
$classes[] = 'xshop--woo-page';
|
||||
}
|
||||
} else {
|
||||
$classes[] = 'xshop--no-woo';
|
||||
}
|
||||
if (is_rtl()) {
|
||||
$classes[] = 'xshop--rtl';
|
||||
}
|
||||
return $classes;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
add_action('after_setup_theme', 'xshop_register_menus');
|
||||
|
||||
function xshop_register_menus(): void {
|
||||
register_nav_menus([
|
||||
'xshop-primary' => esc_html__('Primary Menu', 'xshop'),
|
||||
'xshop-mobile' => esc_html__('Mobile Menu', 'xshop'),
|
||||
'xshop-footer' => esc_html__('Footer Menu', 'xshop'),
|
||||
'xshop-topbar' => esc_html__('Top Bar Menu', 'xshop'),
|
||||
]);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
add_action('widgets_init', 'xshop_register_sidebars');
|
||||
|
||||
function xshop_register_sidebars(): void {
|
||||
$sidebars = [
|
||||
['id'=>'sidebar-main','name'=>__('Main Sidebar','xshop'),'desc'=>__('Appears on blog and pages.','xshop')],
|
||||
['id'=>'sidebar-shop','name'=>__('Shop Sidebar','xshop'),'desc'=>__('Appears on shop archives.','xshop')],
|
||||
['id'=>'footer-1','name'=>__('Footer Column 1','xshop'),'desc'=>''],
|
||||
['id'=>'footer-2','name'=>__('Footer Column 2','xshop'),'desc'=>''],
|
||||
['id'=>'footer-3','name'=>__('Footer Column 3','xshop'),'desc'=>''],
|
||||
['id'=>'footer-4','name'=>__('Footer Column 4','xshop'),'desc'=>''],
|
||||
];
|
||||
foreach ($sidebars as $s) {
|
||||
register_sidebar([
|
||||
'name' => $s['name'],
|
||||
'id' => $s['id'],
|
||||
'description' => $s['desc'],
|
||||
'before_widget' => '<section id="%1$s" class="xshop-widget %2$s">',
|
||||
'after_widget' => '</section>',
|
||||
'before_title' => '<h3 class="xshop-widget__title">',
|
||||
'after_title' => '</h3>',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
add_action('after_setup_theme', 'xshop_setup_theme_support');
|
||||
|
||||
function xshop_setup_theme_support(): void {
|
||||
add_theme_support('title-tag');
|
||||
add_theme_support('post-thumbnails');
|
||||
add_theme_support('html5', ['search-form','comment-form','comment-list','gallery','caption','style','script']);
|
||||
add_theme_support('custom-logo', ['height'=>56,'width'=>200,'flex-height'=>true,'flex-width'=>true]);
|
||||
add_theme_support('automatic-feed-links');
|
||||
add_theme_support('responsive-embeds');
|
||||
add_theme_support('editor-styles');
|
||||
add_theme_support('wp-block-styles');
|
||||
add_theme_support('woocommerce', [
|
||||
'thumbnail_image_width' => 400,
|
||||
'single_image_width' => 800,
|
||||
]);
|
||||
add_theme_support('wc-product-gallery-zoom');
|
||||
add_theme_support('wc-product-gallery-lightbox');
|
||||
add_theme_support('wc-product-gallery-slider');
|
||||
|
||||
load_theme_textdomain('xshop', XSHOP_THEME_DIR . '/languages');
|
||||
|
||||
// Image sizes.
|
||||
add_image_size('xshop-card', 400, 400, false);
|
||||
add_image_size('xshop-card-2x', 800, 800, false);
|
||||
}
|
||||
Reference in New Issue
Block a user