Meet WDS BT, a stylish block theme, tailored for WordPress, featuring native blocks and site editor compatibility. Boasting a contemporary aesthetic, an intuitive interface, and seamless WordPress block editor integration, WDS BT ensures a polished and adaptable framework across all devices. It's crucial to understand that WDS BT is crafted as a foundational theme rather than a parent theme. This difference affords users a flexible starting point for customization. Elevate your website with WDS BT, where design effortlessly meets functionality, providing the ideal canvas for your creative expression.
Feature | Description |
---|---|
Native Block Support | Stylish block theme tailored for WordPress with support for native blocks and site editor. |
Contemporary Aesthetic | Boasts a contemporary aesthetic design to enhance the visual appeal of your website. |
Intuitive Interface | Offers an intuitive interface for easy navigation and seamless user experience. |
Seamless Integration with Block Editor | Integrates seamlessly with the WordPress block editor for efficient content creation and editing. |
Foundation Theme, not Parent Theme | Crafted as a foundational theme rather than a parent theme, providing flexibility for customization. |
Polished and Adaptable Framework | Ensures a polished and adaptable framework across all devices, enhancing responsiveness and usability. |
Responsive Design | Responsive design ensures optimal viewing experience across various screen sizes and devices. |
Flexible Starting Point for Customization | Provides a flexible starting point for customization, allowing users to tailor the theme to their needs. |
Automated Workflow Actions for Code Quality | Automated workflow actions to verify code quality adherence using WordPress coding standards. |
Contribution and Support | Welcomes contributions and support tickets from users, with detailed guidelines for submitting pull requests. |
Free Software with GPL License | Released under the terms of the GNU General Public License version 2 or any later version, ensuring freedom and openness. |
- Set up a local WordPress development environment, we recommend using Local.
- Ensure you are using WordPress 6.4+.
- Clone / download this repository into the
/wp-content/themes/
directory of your new WordPress instance. - In the WordPress admin, use the Appearance > Themes screen to activate the theme.
Theme Structure
βββ wds-bt/
βββ CONTRIBUTING.md
βββ README.md
βββ a11y.cjs
βββ assets
βΒ Β βββ fonts
βΒ Β βββ images
βΒ Β βββ index.js
βΒ Β βββ js
βΒ Β βΒ Β βββ block-filters
βΒ Β βΒ Β βΒ Β βββ index.js
βΒ Β βΒ Β βΒ Β βββ unregister-core-embed.js
βΒ Β βΒ Β βββ block-variations
βΒ Β βΒ Β βΒ Β βββ index.js
βΒ Β βΒ Β βββ global
βΒ Β βΒ Β βΒ Β βββ header.js
βΒ Β βΒ Β βΒ Β βββ index.js
βΒ Β βΒ Β βΒ Β βββ table.js
βΒ Β βΒ Β βββ index.js
βΒ Β βΒ Β βββ templates
βΒ Β βΒ Β βββ index.js
βΒ Β βββ scss
βΒ Β βββ _index.scss
βΒ Β βββ abstracts
βΒ Β βΒ Β βββ _index.scss
βΒ Β βΒ Β βββ mobile-only-mixins.scss
βΒ Β βΒ Β βββ responsive-mixins.scss
βΒ Β βΒ Β βββ utility.scss
βΒ Β βββ base
βΒ Β βΒ Β βββ _index.scss
| | βββ forms.scss
βΒ Β βΒ Β βββ global.scss
βΒ Β βΒ Β βββ pagination.scss
βΒ Β βββ blocks
βΒ Β βΒ Β βββ core
βΒ Β βΒ Β βββ audio.scss
βΒ Β βΒ Β βββ button.scss
βΒ Β βΒ Β βββ calendar.scss
βΒ Β βΒ Β βββ code.scss
βΒ Β βΒ Β βββ comments.scss
βΒ Β βΒ Β βββ cover.scss
βΒ Β βΒ Β βββ file.scss
βΒ Β βΒ Β βββ footnotes.scss
βΒ Β βΒ Β βββ gallery.scss
βΒ Β βΒ Β βββ group.scss
βΒ Β βΒ Β βββ latest-comments.scss
βΒ Β βΒ Β βββ latest-posts.scss
βΒ Β βΒ Β βββ list.scss
βΒ Β βΒ Β βββ navigation.scss
βΒ Β βΒ Β βββ page-list.scss
βΒ Β βΒ Β βββ post-author.scss
βΒ Β βΒ Β βββ post-comments-form.scss
βΒ Β βΒ Β βββ post-navigation-link.scss
βΒ Β βΒ Β βββ post-terms.scss
βΒ Β βΒ Β βββ preformatted.scss
βΒ Β βΒ Β βββ pullquote.scss
βΒ Β βΒ Β βββ query-pagination.scss
βΒ Β βΒ Β βββ query.scss
βΒ Β βΒ Β βββ quote.scss
βΒ Β βΒ Β βββ search.scss
βΒ Β βΒ Β βββ separator.scss
βΒ Β βΒ Β βββ social-links.scss
βΒ Β βΒ Β βββ table.scss
βΒ Β βΒ Β βββ tag-cloud.scss
βΒ Β βΒ Β βββ verse.scss
βΒ Β βΒ Β βββ video.scss
βΒ Β βββ template-parts
βΒ Β βΒ Β βββ _index.scss
βΒ Β βΒ Β βββ footer.scss
βΒ Β βΒ Β βββ header.scss
βΒ Β βββ pages
βΒ Β βββ _index.scss
βΒ Β βββ 404.scss
βΒ Β βββ archive.scss
βΒ Β βββ search.scss
βββ composer.json
βββ composer.lock
βββ functions.php
βββ inc
βΒ Β βββ functions
βΒ Β βΒ Β βββ security.php
βΒ Β βββ hooks
βΒ Β βΒ Β βββ enable-svg.php
βΒ Β βΒ Β βββ enqueue-block-stylesheet.php
βΒ Β βΒ Β βββ register-block-categories.php
βΒ Β βΒ Β βββ register-block-pattern-categories.php
βΒ Β βΒ Β βββ register-block-styles.php
βΒ Β βΒ Β βββ register-block-variations.php
βΒ Β βΒ Β βββ remove-archive-title-prefix.php
βΒ Β βΒ Β βββ unregister-block-variations.php
βΒ Β βββ setup
βΒ Β βββ preload-scripts.php
βΒ Β βββ scripts.php
βΒ Β βββ setup.php
βββ lefthook.yml
βββ package-lock.json
βββ package.json
βββ parts
βΒ Β βββ footer.html
βΒ Β βββ header.html
βββ patterns
βΒ Β βββ footer-default.php
βΒ Β βββ header-default.php
βββ phpcs.xml.dist
βββ postcss.config.js
βββ readme.txt
βββ screenshot.png
βββ style.css
βββ styles
βΒ Β βββ dark.json
βββ templates
βΒ Β βββ 404.html
βΒ Β βββ archive.html
βΒ Β βββ index.html
βΒ Β βββ page-blank.html
βΒ Β βββ page-no-title.html
βΒ Β βββ page.html
βΒ Β βββ search.html
βΒ Β βββ single.html
βββ theme.json
βββ webpack.config.js
βββ webpack.prod.js
Setup
From the command line, change directories to your new theme directory:
cd /wp-content/themes/your-theme
The command below will remove node_modules
, vendor
, build
, package-lock.json
, and composer.lock
files. Install theme dependencies and trigger an initial build.
Note: You will need to have Composer 2 and NPM 10 installed first.
npm run setup
From the command line, type any of the following to perform an action:
Command | Description | |
---|---|---|
π | npm run a11y |
Run accessibility tests using Pa11y-CI. |
π οΈ | npm run build |
Build the theme using wp-scripts . |
π¨ | npm run create-block |
Create a custom block with Webpack and @wordpress/create-block. |
π | npm run format |
Format files using wp-scripts and composer . |
π | npm run lint |
Run all linting scripts. |
π¨ | npm run lint:css |
Lint CSS files using wp-scripts . |
π | npm run lint:js |
Lint JavaScript files using wp-scripts . |
π | npm run lint:md:docs |
Lint Markdown files in the docs directory using wp-scripts . |
π | npm run lint:php |
Lint PHP files using composer . |
π¦ | npm run lint:pkg-json |
Lint package.json and composer.json using wp-scripts . |
π | npm run packages-update |
Update dependencies defined in package.json using wp-scripts . |
π | npm run reset |
Remove node_modules , vendor , build , package-lock.json , and composer.lock files. |
π οΈ | npm run setup |
Reset, install dependencies, and build the theme. |
npm run start |
Start the development server using wp-scripts . |
- Run the Block Creation Script Navigate to your project root in the terminal and run the following command to create a new block:
npm run create-block
Follow the prompts to configure your new block. The script will scaffold a new block structure inside assets/blocks/.
- Build your block After editing and configuring your block, build your project to compile assets using webpack:
npm run build
This will process JavaScript, SCSS, optimize images, and generate necessary files in the build/ directory and custom blocks will have files generated in the blocks/ directory.
Registering Block Styles
-
Open the
inc/hooks/register-block-styles.php
file in your theme directory. -
Add a new block style entry with the following mandatory properties:
-
Name: The identifier used to compute a CSS class for the style.
-
Label: A human-readable label for the style.
Example:
'block_name' => array( 'name' => __( 'label', 'wdsbt' ), ),
-
Overriding/Customizing Block Styles
-
Navigate to the
assets/scss/blocks/
directory within your theme. If overriding a core block style, use thecore
folder, if overriding a block from a plugin use thethird-party
folder. -
Create an SCSS file with the exact filename as the block name you want to customize. This file will house your custom styles for that specific block.
-
Files within the
assets/scss/blocks/core/
directory are automatically enqueued, simplifying the integration of your custom styles into the WordPress block editor. Do not import these files into the mainindex.scss
-
After adding your custom SCSS file, run the following command to compile and apply your changes:
npm run build
Creating Block Variations
-
In the
assets/js/block-variations
directory within your theme, create a new JavaScript file. This file will contain the definition of your block variation. -
Import the newly created file into the
assets/js/block-variations/index.js
file. This step ensures that your variation is included in the build process. -
Use the
wp.blocks.registerBlockVariation()
function to officially register your block variation. This function takes the name of the original block and an object defining the variation.Example:
// In your variations JavaScript file wp.blocks.registerBlockVariation('core/paragraph', { name: 'custom-variation', title: __('Custom Variation', 'wdsbt'), attributes: { /* Define your custom attributes here */ }, // Add more variation settings as needed });
Original Block Name: Provide the name of the original block for which you are creating the variation. Variation Object: Define the properties of your block variation, including the name, title, attributes, and any additional settings.
NOTE: To find the correct block name, open the block editor, launch the browser console and type
wp.blocks.getBlockTypes()
. You will see the complete list of block names (from core or third-party).
Unregister Blocks and Variations
This functionality allows you to unregister and disable specific core Gutenberg blocks, styles, and variations that are not needed on your WordPress website. By removing these unused blocks and variations, you can streamline the Gutenberg editor and improve the overall performance of your site.
The script in assets/js/block-filters/unregister-core-embed.js
loops through a list of unused blocks and variations, unregistering them from the Gutenberg editor. Additionally, it keeps only the specified embed variations for the core/embed block.
Example
// List of Gutenberg blocks to unregister
const unusedBlocks = [
'core/file',
'core/latest-comments',
'core/rss',
// Add more unused blocks as needed
];
// List of Gutenberg block variations to unregister
const unregisterBlockVariations = [
// Example:
// {
// blockName: 'core/group',
// blockVariationName: 'group-stack',
// },
];
// Keep only the necessary embed variations
const keepEmbeds = [
'twitter',
'wordpress',
'spotify',
// Add more necessary embed variations as needed.
];
Responsive Mixins
This SCSS file assets/scss/abstracts/_responsive-mixins.scss
provides mixins for creating responsive media queries with both minimum and maximum width conditions. The file promotes modular and maintainable styling by allowing the easy application of responsive styles based on screen width.
To use the responsive mixin, include it in your SCSS code and customize it according to your project's breakpoints. Here's an example:
// Usage examples
.my-element {
width: 100%;
// Apply styles when the screen width is 600px or more
@include responsive-min(600px) {
/* Your responsive styles for min-width: 600px */
}
// Apply styles when the screen width is up to 600px
@include responsive-max(600px) {
/* Your responsive styles for max-width: 600px */
}
// Apply styles when the screen width is between 600px and 1200px
@include responsive-range(600px, 1200px) {
/* Your responsive styles for a range of widths */
}
}
Mobile Only Mixins
This SCSS file assets/scss/abstracts/_mobile-only-mixins.scss
contains a mixin called mobile-only
designed to visually hide elements for accessibility (a11y) while making them visible on mobile devices.
Include the mobile-only
mixin in your SCSS file where you want to hide elements on desktop but make them visible on mobile:
// Example usage:
.my-element {
@include mobile-only;
}
The configuration extends two base configurations:
- @wordpress/stylelint-config/scss: This extends the WordPress SCSS stylelint configuration.
- stylelint-config-prettier: This extends the Prettier stylelint configuration.
These base configurations provide a foundation for enforcing consistent styles and conventions in SCSS files.
Rules
declaration-no-important
: Disallows the use of !important in declarations.scss/at-rule-no-unknown
: Allows specific SCSS at-rules to be ignored, such as @apply, @layer, @variants, @responsive, and @screen.string-quotes
: Enforces the use of single quotes for strings.declaration-property-unit-allowed-list
: Specifies allowed units for the following properties:- font-size: allows only
em
andrem
- line-height: unitless
- border: allow only
px
- margin: allows only
em
andrem
- padding: allows only
em
andrem
- font-size: allows only
WDS BT is equipped with automated workflow actions that ensure code security and uphold code quality standards with every commit. Accessibility check has been integrated into the development process, guaranteeing that websites built with WDS BT prioritize accessibility compliance based on WCAG 2.2 standards. This proactive approach underscores WDS BT's commitment to providing an inclusive user experience for all.
A11y Test (npm run a11y)
- Purpose: To guarantee that the theme meets the Web Content Accessibility Guidelines (WCAG) standards.
- Running the A11y Test Script:
- Accessibility checks are integrated into the development process using
pa11y-ci
by running:npm run a11y
- You will be prompted to enter the URL of the site you want to test for accessibility. If you leave it blank, it will default to https://wdsbt.local.
- Accessibility checks are integrated into the development process using
- Script Details:
The script performs the following actions
- Prompts for URL: You will be prompted to enter the URL of the site you want to test for accessibility. If you leave it blank, it will default to https://wdsbt.local.
- Checks for Sitemap: Attempts to access the sitemap at
[URL]/wp-sitemap.xml
. - Runs Accessibility Tests:
- If the sitemap is found, the script runs
pa11y-ci
on the sitemap URL.$ npm run a11y Please enter the URL to test for accessibility (leave blank to use your local: https://wdsbt.local): > https://example.com Sitemap found at https://example.com/wp-sitemap.xml. Running pa11y-ci on the sitemap... [output from pa11y-ci]
- If the sitemap is not found, the script runs pa11y-ci on the main page URL.
$ npm run a11y Please enter the URL to test for accessibility (leave blank to use your local: https://wdsbt.local): > https://example.com No sitemap found at https://example.com/wp-sitemap.xml. Running pa11y-ci on the main page... [output from pa11y-ci]
- If the sitemap is found, the script runs
- Violation Reports: Any detected accessibility violations are displayed in the console for immediate review and action.
Security Check (security.yml)
- Purpose: Perform security checks on dependencies to identify vulnerabilities.
- Configuration: Uses
symfonycorp/security-checker-action@v5
for security scanning. - Concurrency Handling: Ensures only one instance runs per branch concurrently, cancelling previous runs.
- Job:
- Name: Security check
- OS: Ubuntu latest
- Conditional Execution:
- Runs only if:
- Not a scheduled event (
schedule
), or - Scheduled event, but repository owner is not "webdevstudios."
- Not a scheduled event (
- Runs only if:
Code Quality Check (assertions.yml)
- Purpose: To verify code quality adherence using WordPress coding standards.
- Configuration: The code quality check is performed using predefined assertions in
assertions.yml
. - Action Requirement: All detected code issues and violations must be addressed and fixed before any commit can successfully pass through.
- Report Display: The assertions report will appear in the command-line interface (CLI) during the checks.
Integration Process with LeftHook
- Commit Changes: Make your changes to the codebase as usual.
- Automated Checks on Commit: LeftHook triggers automated checks upon each commit.
- Review Reports: Check the generated reports for any accessibility violations or code quality issues.
- Address Issues: Address and fix any identified violations or issues.
- Recommit: Once all issues are resolved, recommit your changes.
- Passing Commit: Your commit will successfully pass through once all checks are clear.
- Create Pull Request (PR): When you create a PR, the actions are triggered again to run on the PR branch.
- Review PR Checks: Review the checks on the PR to ensure compliance before merging.
To handle cache busting for CSS and JS files, this theme automatically appends the file modification time as a version parameter to the URLs of enqueued styles and scripts, ensuring that browsers fetch the most recent version whenever the files are updated.
How It Works
- Hooking into the
style_loader_src
andscript_loader_src
filters, which handle the URLs of enqueued styles and scripts. - Using the
filemtime()
function to retrieve the last modified time of thestyle.css
file, appending it as the version (ver
) parameter in the asset URLs. - This ensures that browsers always fetch the latest version of your CSS and JS files, preventing them from serving cached versions after updates.
Your contributions and support tickets are welcome. Please see our contributing guidelines before submitting a pull request.
WDS BT is free software, and is released under the terms of the GNU General Public License version 2 or any later version. See LICENSE.md for complete license.
The WDS-BT theme was initially inspired by the Powder theme. We acknowledge and thank the creators of Powder for their work.