250,
'width' => 250,
'flex-width' => true,
'flex-height' => true,
)
);
add_theme_support(
'custom-background',
apply_filters(
'bsd_custom_background_args',
array(
'default-color' => 'ffffff',
'default-image' => '',
)
)
);
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'style',
'script',
'navigation-widgets',
)
);
register_nav_menus(
array(
'menu-1' => esc_html__( 'Primary', 'basic-starter-dev' ),
'footer' => esc_html__( 'Footer Menu', 'basic-starter-dev' ),
)
);
// Load editor styles
add_editor_style( 'editor-style.css' );
}
add_action( 'after_setup_theme', 'bsd_setup' );
function bsd_register_block_styles() {
register_block_style(
'core/image',
array(
'name' => 'fancy-border',
'label' => __( 'Fancy Border', 'basic-starter-dev' ),
'inline_style' => '.is-style-fancy-border { border: 5px double #000; padding: 10px; }',
)
);
register_block_pattern(
'basic-starter-dev/hero-text',
array(
'title' => __( 'Hero Text Section', 'basic-starter-dev' ),
'description' => _x( 'A centered hero section with text.', 'Block pattern description', 'basic-starter-dev' ),
'content' => "
" . esc_html__('Welcome to Our Website!', 'basic-starter-dev') . "
",
)
);
}
add_action( 'init', 'bsd_register_block_styles' );
/**
* Set the content width
*/
function bsd_content_width() {
$GLOBALS['content_width'] = apply_filters( 'bsd_content_width', 640 );
}
add_action( 'after_setup_theme', 'bsd_content_width', 0 );
/**
* Register widget area
*/
function bsd_widgets_init() {
register_sidebar(
array(
'name' => esc_html__( 'Sidebar', 'basic-starter-dev' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'basic-starter-dev' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar(
array(
'name' => esc_html__( 'Footer Widget Area', 'basic-starter-dev' ),
'id' => 'footer-1',
'description' => esc_html__( 'Add widgets here.', 'basic-starter-dev' ),
'before_widget' => '',
'before_title' => '',
)
);
}
add_action( 'widgets_init', 'bsd_widgets_init' );
/**
* Enqueue scripts and styles
*/
function bsd_scripts() {
wp_enqueue_style( 'bsd-style', get_stylesheet_uri(), array(), BSD_VERSION );
wp_style_add_data( 'bsd-style', 'rtl', 'replace' );
wp_enqueue_script(
'bsd-navigation',
get_template_directory_uri() . '/js/navigation.js',
array(),
BSD_VERSION,
true
);
wp_enqueue_script(
'bsd-custom',
get_template_directory_uri() . '/js/custom.js',
array('jquery'), // if your JS depends on jQuery
BSD_VERSION,
true
);
// Customizer live preview
if ( is_customize_preview() ) {
wp_enqueue_script(
'bsd-customizer',
get_template_directory_uri() . '/js/customizer.js',
array( 'jquery', 'customize-preview' ),
BSD_VERSION,
true
);
}
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'bsd_scripts' );
/**
* Custom Navigation Walker for better accessibility
*/
class BSD_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_el(&$output, $item, $depth = 0, $args = null, $id = 0) {
$indent = ($depth) ? str_repeat("\t", $depth) : '';
$classes = empty($item->classes) ? array() : (array) $item->classes;
$classes[] = 'menu-item-' . $item->ID;
// Add has-children class if item has children
if (in_array('menu-item-has-children', $classes)) {
$classes[] = 'has-children';
}
$class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args));
$class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : '';
$id = apply_filters('nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args);
$id = $id ? ' id="' . esc_attr($id) . '"' : '';
$output .= $indent . '';
$attributes = ! empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) .'"' : '';
$attributes .= ! empty($item->target) ? ' target="' . esc_attr($item->target ) .'"' : '';
$attributes .= ! empty($item->xfn) ? ' rel="' . esc_attr($item->xfn ) .'"' : '';
$attributes .= ! empty($item->url) ? ' href="' . esc_attr($item->url ) .'"' : '';
// Add ARIA attributes for items with children
if (in_array('menu-item-has-children', $classes)) {
$attributes .= ' aria-haspopup="true"';
$attributes .= ' aria-expanded="false"';
}
$item_output = $args->before;
$item_output .= '';
$item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
$item_output .= '';
$item_output .= $args->after;
$output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
}
}
/**
* Include theme files
*/
require get_template_directory() . '/inc/custom-header.php';
require get_template_directory() . '/inc/template-tags.php';
require get_template_directory() . '/inc/template-functions.php';
require get_template_directory() . '/inc/customizer.php';
if ( defined( 'JETPACK__VERSION' ) ) {
require get_template_directory() . '/inc/jetpack.php';
}