Skip to content

Latest commit

Β 

History

History
573 lines (447 loc) Β· 24 KB

README.md

File metadata and controls

573 lines (447 loc) Β· 24 KB

WDS BT

WebDevStudios. Your Success is Our Mission.

License: GPL v3 Code Quality Security

Table of Contents

Overview

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.

Features

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.

πŸ” Back to Top


Requirements


Getting Started

  1. Set up a local WordPress development environment, we recommend using Local.
  2. Ensure you are using WordPress 6.4+.
  3. Clone / download this repository into the /wp-content/themes/ directory of your new WordPress instance.
  4. In the WordPress admin, use the Appearance > Themes screen to activate the theme.

πŸ” Back to Top


Development

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

NPM Scripts

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.

πŸ” Back to Top


Creating Blocks

  1. 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/.

  1. 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.

πŸ” Back to Top


Customizations

Registering Block Styles
  1. Open the inc/hooks/register-block-styles.php file in your theme directory.

  2. 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
  1. Navigate to the assets/scss/blocks/ directory within your theme. If overriding a core block style, use the core folder, if overriding a block from a plugin use the third-party folder.

  2. 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.

  3. 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 main index.scss

  4. After adding your custom SCSS file, run the following command to compile and apply your changes:

    npm run build
Creating Block Variations
  1. 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.

  2. 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.

  3. 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.

Implementation

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.
];

Mixins

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;
}

Stylelint Configuration

Extends

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 and rem
    • line-height: unitless
    • border: allow only px
    • margin: allows only em and rem
    • padding: allows only em and rem

πŸ” Back to Top


Accessibility and Code Quality and Security Checks

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.
  • 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]
  • 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."
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
  1. Commit Changes: Make your changes to the codebase as usual.
  2. Automated Checks on Commit: LeftHook triggers automated checks upon each commit.
  3. Review Reports: Check the generated reports for any accessibility violations or code quality issues.
  4. Address Issues: Address and fix any identified violations or issues.
  5. Recommit: Once all issues are resolved, recommit your changes.
  6. Passing Commit: Your commit will successfully pass through once all checks are clear.
  7. Create Pull Request (PR): When you create a PR, the actions are triggered again to run on the PR branch.
  8. Review PR Checks: Review the checks on the PR to ensure compliance before merging.

Automated Versioning Process

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
  1. Hooking into the style_loader_src and script_loader_src filters, which handle the URLs of enqueued styles and scripts.
  2. Using the filemtime() function to retrieve the last modified time of the style.css file, appending it as the version (ver) parameter in the asset URLs.
  3. This ensures that browsers always fetch the latest version of your CSS and JS files, preventing them from serving cached versions after updates.

Contributing and Support

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.


Acknowledgements

The WDS-BT theme was initially inspired by the Powder theme. We acknowledge and thank the creators of Powder for their work.


πŸ” Back to Top