144 lines
4.3 KiB
PHP
144 lines
4.3 KiB
PHP
<?php
|
|
/**
|
|
* Theme functions and definitions
|
|
*
|
|
* @package SewJoy_Theme
|
|
*/
|
|
|
|
/**
|
|
* Sets up theme defaults and registers support for various WordPress features.
|
|
*/
|
|
function sewjoy_theme_setup() {
|
|
// Let WordPress manage the document title.
|
|
add_theme_support( 'title-tag' );
|
|
|
|
// Enable support for Post Thumbnails on posts and pages.
|
|
add_theme_support( 'post-thumbnails' );
|
|
|
|
// Register navigation menus.
|
|
register_nav_menus( array(
|
|
'menu-1' => esc_html__( 'Primary', 'sewjoy-theme' ),
|
|
) );
|
|
}
|
|
add_action( 'after_setup_theme', 'sewjoy_theme_setup' );
|
|
|
|
/**
|
|
* Register widget areas.
|
|
*/
|
|
function sewjoy_theme_widgets_init() {
|
|
register_sidebar( array(
|
|
'name' => esc_html__( 'Sidebar', 'sewjoy-theme' ),
|
|
'id' => 'sidebar-1',
|
|
'description' => esc_html__( 'Main sidebar widget area.', 'sewjoy-theme' ),
|
|
'before_widget' => '<section id="%1$s" class="widget %2$s">',
|
|
'after_widget' => '</section>',
|
|
'before_title' => '<h2 class="widget-title">',
|
|
'after_title' => '</h2>',
|
|
) );
|
|
}
|
|
add_action( 'widgets_init', 'sewjoy_theme_widgets_init' );
|
|
|
|
/**
|
|
* Enqueue scripts and styles.
|
|
*/
|
|
function sewjoy_theme_scripts() {
|
|
if ( is_front_page() ) {
|
|
// Homepage is self-contained — only load the home stylesheet.
|
|
wp_enqueue_style(
|
|
'sewjoy-theme-style',
|
|
get_stylesheet_uri()
|
|
);
|
|
wp_enqueue_style(
|
|
'sewjoy-theme-home',
|
|
get_template_directory_uri() . '/assets/css/home.css',
|
|
array( 'sewjoy-theme-style' ),
|
|
'1.0.6'
|
|
);
|
|
return;
|
|
}
|
|
|
|
if ( is_page_template( 'page-templates/page-shop.php' ) ) {
|
|
// Shop / product list page — reuses the home canvas + nav/footer,
|
|
// adds the filter bar, product card family, layout switcher, pagination.
|
|
wp_enqueue_style(
|
|
'sewjoy-theme-style',
|
|
get_stylesheet_uri()
|
|
);
|
|
wp_enqueue_style(
|
|
'sewjoy-theme-home',
|
|
get_template_directory_uri() . '/assets/css/home.css',
|
|
array( 'sewjoy-theme-style' ),
|
|
'1.0.6'
|
|
);
|
|
wp_enqueue_style(
|
|
'sewjoy-theme-shop',
|
|
get_template_directory_uri() . '/assets/css/shop.css',
|
|
array( 'sewjoy-theme-home' ),
|
|
'1.0.0'
|
|
);
|
|
return;
|
|
}
|
|
|
|
if ( is_page_template( 'page-templates/page-design.php' ) ) {
|
|
// Design Yours / Custom Design Flow landing — reuses the home
|
|
// canvas + nav/footer + bond-card markup; adds the 3-step splash
|
|
// carousel, the three-series wrapper, and Featured Designs cards.
|
|
wp_enqueue_style(
|
|
'sewjoy-theme-style',
|
|
get_stylesheet_uri()
|
|
);
|
|
wp_enqueue_style(
|
|
'sewjoy-theme-home',
|
|
get_template_directory_uri() . '/assets/css/home.css',
|
|
array( 'sewjoy-theme-style' ),
|
|
'1.0.6'
|
|
);
|
|
wp_enqueue_style(
|
|
'sewjoy-theme-design',
|
|
get_template_directory_uri() . '/assets/css/design.css',
|
|
array( 'sewjoy-theme-home' ),
|
|
'1.0.0'
|
|
);
|
|
wp_enqueue_script(
|
|
'sewjoy-theme-design',
|
|
get_template_directory_uri() . '/assets/js/design.js',
|
|
array( 'jquery' ),
|
|
'1.0.0',
|
|
true
|
|
);
|
|
return;
|
|
}
|
|
|
|
// Main theme stylesheet (style.css from theme root).
|
|
wp_enqueue_style(
|
|
'sewjoy-theme-style',
|
|
get_stylesheet_uri()
|
|
);
|
|
|
|
// Custom main stylesheet from assets/css/.
|
|
wp_enqueue_style(
|
|
'sewjoy-theme-main',
|
|
get_template_directory_uri() . '/assets/css/main.css',
|
|
array( 'sewjoy-theme-style' ),
|
|
'1.0.0'
|
|
);
|
|
|
|
// Main theme script from assets/js/ with jQuery as a dependency.
|
|
wp_enqueue_script(
|
|
'sewjoy-theme-main',
|
|
get_template_directory_uri() . '/assets/js/main.js',
|
|
array( 'jquery' ),
|
|
'1.0.0',
|
|
true
|
|
);
|
|
|
|
// Page Builder / Customizer script, loaded in the footer with jQuery.
|
|
wp_enqueue_script(
|
|
'sewjoy-theme-builder',
|
|
get_template_directory_uri() . '/assets/js/builder.js',
|
|
array( 'jquery' ),
|
|
'1.0.0',
|
|
true
|
|
);
|
|
}
|
|
add_action( 'wp_enqueue_scripts', 'sewjoy_theme_scripts' ); |