Skip to content

Add support for 0BSD and SPDX BSD-2/3-Clause licenses - #1571

Merged
davidperezgar merged 1 commit into
trunkfrom
fix/0bsd-license
Dec 5, 2026
Merged

davidperezgar merged 1 commit into
trunkfrom
fix/0bsd-license

Conversation

@davidperezgar

@davidperezgar davidperezgar commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

What?

Closes #1570

Adds support for the Zero-Clause BSD (0BSD) license and fixes matching of the SPDX identifiers BSD-2-Clause and BSD-3-Clause in the plugin header license check.

Why?

Plugins licensed under 0BSD (a permissive, public-domain-equivalent, GPL-compatible license) get a false plugin_header_invalid_license error.

While testing, I also found that BSD-3-Clause and BSD-2-Clause fail end to end: get_normalized_license() strips dashes (BSD-3-Clause becomes BSD3Clause), and is_license_gpl_compatible() only matched the dashed form, so the plugin header check rejected them too.

How?

  • get_normalized_license(): normalize Zero-Clause BSD variants (Zero-Clause BSD, BSD Zero Clause License, BSD-0-Clause, 0-clause BSD) to 0BSD.
  • is_license_gpl_compatible(): accept 0BSD, and replace the BSD-3-Clause|BSD 3 Clause patterns with BSD[\s\-]*[23][\s\-]*Clause, so the dashed, spaced and normalized forms of BSD-2-Clause and BSD-3-Clause all match. BSD-4-Clause is still rejected (it is not GPL compatible).
  • Added test cases to License_Utils_Tests, including a negative case for BSD4Clause.

Testing Instructions

  1. Create a test plugin with License: 0BSD in the main file header.
  2. Run Plugin Check on it (or wp plugin check <slug> --checks=plugin_header_fields).
  3. Before this PR: plugin_header_invalid_license error. After: no license error.
  4. Repeat with License: BSD-3-Clause, License: BSD-2-Clause and License: Zero-Clause BSD; none should error.
  5. License: BSD-4-Clause should still return the error.
  6. Run npm run test-php -- --filter License_Utils_Tests.

AI Usage Disclosure

  • This PR was created without the help of AI tools
  • This PR includes AI-assisted code or content

If AI tools were used, please describe how they were used:
Used Claude Code to find the cause, write the fix and tests, and draft this description. I reviewed the changes.

Open WordPress Playground Preview

Normalize Zero-Clause BSD variants to 0BSD and accept it as GPL
compatible. Also match BSD-2-Clause and BSD-3-Clause after
normalization strips dashes, which previously caused false
plugin_header_invalid_license errors.

Fixes #1570

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: davidperezgar <davidperez@git.wordpress.org>
Co-authored-by: marceltannich <mardroid@git.wordpress.org>
Co-authored-by: ernilambar <nilambar@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@marceltannich marceltannich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested manually on a local site: 0BSD, BSD-3-Clause, BSD-2-Clause and Zero-Clause BSD all errored before and pass now; BSD-4-Clause is still rejected.

@davidperezgar
davidperezgar merged commit e6132f1 into trunk Dec 5, 2026
28 checks passed
@davidperezgar
davidperezgar deleted the fix/0bsd-license branch December 5, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for the 0BSD (Zero-Clause BSD) license

3 participants