92 lines
2.5 KiB
PHP
92 lines
2.5 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.5'
|
|
);
|
|
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' ); |