Skip to content

Commit 0379d49

Browse files
committed
v1.0.0
1 parent 8820002 commit 0379d49

File tree

12 files changed

+199
-2
lines changed

12 files changed

+199
-2
lines changed

.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Compiled source
2+
*.com
3+
*.class
4+
*.dll
5+
*.exe
6+
*.o
7+
*.so
8+
9+
# Packages
10+
*.7z
11+
*.dmg
12+
*.gz
13+
*.iso
14+
*.jar
15+
*.rar
16+
*.tar
17+
*.zip
18+
19+
# Logs and databases
20+
*.log
21+
*.sql
22+
*.sqlite
23+
24+
# OS generated files
25+
.DS_Store
26+
.DS_Store?
27+
._*
28+
.Spotlight-V100
29+
.Trashes
30+
ehthumbs.db
31+
Thumbs.db

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1-
# barely-minimum-bootstrap-5-wordpress-starter-theme
2-
Barely minimum Bootstrap 5 WordPress starter theme [boilerplater for developers only]
1+
# Barely minimum Bootstrap 5 WordPress starter theme [boilerplater for developers only]
2+
[barely-minimum-bootstrap-5-wordpress-starter-theme](https://github.com/AlexWebLab/barely-minimum-bootstrap-5-wordpress-starter-theme)
3+
## Theme features:
4+
* minimum amount of files required for a WordPress theme (index.php and style.css)
5+
* Bootstrap 5 CSS & JS files enqueued (in function.php from /functions/enqueues.php)
6+
* jQuery removed but optionally available commenting out one line from /functions/enqueues.php
7+
* Bootstrap 5 starter template (separated in 3 files: header.php, index.php and footer.php)
8+
* custom wp_nav_menu walker for Bootstrap 5 navbar (in function.php from /functions/navbar.php)
9+
* empty custom.css & custom.js files (located in /css and /js, respectively)

bs5starter/css/custom.css

Whitespace-only changes.

bs5starter/footer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php wp_footer(); ?>
2+
</body>
3+
4+
</html>

bs5starter/functions.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
if (!defined('ABSPATH')) {
3+
exit;
4+
}
5+
require get_template_directory() . '/functions/setup.php';
6+
require get_template_directory() . '/functions/enqueues.php';
7+
require get_template_directory() . '/functions/navbar.php';

bs5starter/functions/enqueues.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
function custom_enqueue_scripts()
3+
{
4+
// * styles *
5+
6+
// Bootstrap 5 style
7+
wp_register_style('bootstrap5', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css', false, '5.0.0-beta1', null);
8+
wp_enqueue_style('bootstrap5');
9+
10+
// custom style
11+
wp_register_style('custom', get_template_directory_uri() . '/css/custom.css', false, '1.0.0', null);
12+
wp_enqueue_style('custom');
13+
14+
// * scripts *
15+
16+
// remove jQuery
17+
wp_deregister_script('jquery');
18+
// add latest jQuery * uncomment to enable jQuery *
19+
// wp_register_script('jquery', 'https://code.jquery.com/jquery-3.5.1.js', false, '3.5.1', false);
20+
// wp_enqueue_script('jquery');
21+
22+
wp_register_script('bootstrap5', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js', false, '5.0.0-beta1', true);
23+
wp_enqueue_script('bootstrap5');
24+
25+
// custom script
26+
wp_register_script('custom', get_template_directory_uri() . '/js/custom.js', false, '1.0.0', true);
27+
wp_enqueue_script('custom');
28+
}
29+
30+
add_action('wp_enqueue_scripts', 'custom_enqueue_scripts', 100);

bs5starter/functions/navbar.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
// bootstrap 5 wp_nav_menu walker
3+
class bootstrap_5_wp_nav_menu_walker extends Walker_Nav_menu
4+
{
5+
function start_lvl(&$output, $depth = 0, $args = array())
6+
{
7+
$indent = str_repeat("\t", $depth);
8+
$submenu = ($depth > 0) ? ' sub-menu' : '';
9+
$output .= "\n$indent<ul class=\"dropdown-menu$submenu depth_$depth\">\n";
10+
}
11+
12+
function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
13+
{
14+
15+
$indent = ($depth) ? str_repeat("\t", $depth) : '';
16+
17+
$li_attributes = '';
18+
$class_names = $value = '';
19+
20+
$classes = empty($item->classes) ? array() : (array) $item->classes;
21+
22+
$classes[] = ($args->walker->has_children) ? 'dropdown' : '';
23+
$classes[] = ($item->current || $item->current_item_ancestor) ? 'active' : '';
24+
$classes[] = 'nav-item';
25+
$classes[] = 'nav-item-' . $item->ID;
26+
if ($depth && $args->walker->has_children) {
27+
$classes[] = 'dropdown-menu dropdown-menu-end';
28+
}
29+
30+
$class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args));
31+
$class_names = ' class="' . esc_attr($class_names) . '"';
32+
33+
$id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args);
34+
$id = strlen($id) ? ' id="' . esc_attr($id) . '"' : '';
35+
36+
$output .= $indent . '<li ' . $id . $value . $class_names . $li_attributes . '>';
37+
38+
$attributes = !empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) . '"' : '';
39+
$attributes .= !empty($item->target) ? ' target="' . esc_attr($item->target) . '"' : '';
40+
$attributes .= !empty($item->xfn) ? ' rel="' . esc_attr($item->xfn) . '"' : '';
41+
$attributes .= !empty($item->url) ? ' href="' . esc_attr($item->url) . '"' : '';
42+
43+
$attributes .= ($args->walker->has_children) ? ' class="nav-link dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"' : ' class="nav-link"';
44+
45+
$item_output = $args->before;
46+
$item_output .= ($depth > 0) ? '<a class="dropdown-item"' . $attributes . '>' : '<a' . $attributes . '>';
47+
$item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after;
48+
$item_output .= '</a>';
49+
$item_output .= $args->after;
50+
51+
$output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);
52+
}
53+
}

bs5starter/functions/setup.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
add_theme_support('title-tag');
3+
add_theme_support('post-thumbnails');
4+
register_nav_menu('main-menu', 'Main menu');
5+
add_action('after_setup_theme', 'custom_image_sizes');
6+
function custom_image_sizes()
7+
{
8+
add_image_size('image-1920px-wide', 1920); // used as alternative for maximum size of images instead of 'full'
9+
// 'medium_large' for 768 pixels wide is automatically added by WordPress
10+
}

bs5starter/header.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<?php wp_head(); ?>
8+
</head>
9+
10+
<body>
11+
<nav class="navbar navbar-expand-md navbar-light bg-light">
12+
<div class="container-fluid">
13+
<a class="navbar-brand" href="#">Navbar</a>
14+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#main-menu" aria-controls="main-menu" aria-expanded="false" aria-label="Toggle navigation">
15+
<span class="navbar-toggler-icon"></span>
16+
</button>
17+
18+
<div class="collapse navbar-collapse" id="main-menu">
19+
<?php
20+
wp_nav_menu(array(
21+
'theme_location' => 'main-menu',
22+
'container' => false,
23+
'menu_class' => '',
24+
'fallback_cb' => '__return_false',
25+
'items_wrap' => '<ul id="%1$s" class="navbar-nav me-auto mb-2 mb-md-0 %2$s">%3$s</ul>',
26+
'depth' => 2,
27+
'walker' => new bootstrap_5_wp_nav_menu_walker()
28+
));
29+
?>
30+
</div>
31+
</div>
32+
</nav>

bs5starter/index.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php get_header(); ?>
2+
3+
<main class="container">
4+
5+
<div class="starter-template text-center py-5 px-3">
6+
<h1>Bootstrap 5 starter template</h1>
7+
<p class="lead">Use this document as a way to quickly start any new project.<br> All you get is this text and a mostly barebones HTML document.</p>
8+
</div>
9+
10+
</main>
11+
12+
<?php get_footer(); ?>

0 commit comments

Comments
 (0)