JPKCom Bootstrap 5 Dark Mode Switch — Guide & Tips

Add a Bootstrap 5 dark mode switch to WordPress via shortcode — installation, shortcode and practical tips for JPKCom Bootstrap 5 Dark Mode Switch.

JPKCom Bootstrap 5 Dark Mode Switch provides the [jpkcom-bs-dark-mode] shortcode and accompanying JavaScript to add a Bootstrap 5 dark mode switch to your WordPress site.

Guide

Requirements

  • WordPress 6.9 or newer (tested up to WordPress 7.1)
  • PHP 8.3 or newer

Installation

  1. In your admin panel, go to Plugins → Add New and click Upload Plugin.
  2. Choose the plugin's ZIP file and click Install Now.
  3. Click Activate — the plugin takes effect immediately.

Usage

Place the shortcode wherever you want the switch in your content or template:

[jpkcom-bs-dark-mode]

In PHP templates you can output it via do_shortcode():

<?php
echo do_shortcode( '[jpkcom-bs-dark-mode]' );

For more on do_shortcode(), see the WordPress function reference (opens in a new tab).

Tips & Tricks

  • Bootstrap 5 required: The switch is built around Bootstrap 5's color mode system — make sure your theme loads Bootstrap 5 so dark mode applies correctly.
  • In the template, not the content: If the switch should live in your header or footer, embed it via do_shortcode( '[jpkcom-bs-dark-mode]' ) directly in the template instead of writing it into every post.
  • Reproducible updates: Since version 2.0.3 the plugin uses secure self-hosted updates via GitHub with SHA256 checksums and runs with declare(strict_types=1). Since 2.0.9 it also carries the Update URI header: the wordpress.org update API then no longer returns updates for this plugin, so a plugin published there under the same slug cannot pose as an update. Since 2.0.10 Dashboard → Updates shows the JPKCom logo next to the plugin.
  • Updates even while deactivated: Since 2.0.11 (updater 1.5.0) the plugin is offered updates even when it is deactivated — provided another JPKCom plugin with updater 1.5.0 or newer is active. Its updater answers the update check for all installed JPKCom plugins, with the update row, icon and “View details”, and the SHA256 check applies exactly as for an active plugin. On multisite at least one JPKCom plugin must be network-active or active on the main site. Also since 2.0.11: the stored update list no longer contains JPKCom download URLs, the updater adds them back only while it is loaded; the checksum is also verified for a package supplied by another plugin, and for every GitHub address of the release file. If the plugin sits in a Git or other VCS checkout, you are told about a new release, but WordPress never updates it automatically — the update would delete the checkout. The same applies to an active plugin in a renamed folder; a deactivated plugin in a renamed folder is not found by the updater at all. The updater fetches update information only for users who can update plugins, in the update cron and in WP-CLI, never for anonymous visitors.

Further reading