Skip to content

Write a License: header into installed pattern files #53

Description

@pbking

Depends on Twenty-Bellows/patternbuilderwp.com#29, which adds the license field to pbp/1.

Why

A pattern installed from the cloud today carries no licence information anywhere. Pattern_File_Store writes Title, Slug, Description, Categories, Keywords, Block Types, Post Types, Template Types, Viewport Width, Inserter, Synced and Origin — and nothing about terms. A grep for license across this plugin returns only Freemius billing identifiers.

That matters most in the case the pattern is most likely to end up in: a designer downloads a pattern, it lands in patterns/{handle}/{collection}/{slug}.php, and the theme is distributed. GPLv2 §1 requires the notice to travel with the copy, and right now nothing does.

The precedent is already set by Origin: — as the architecture notes put it, "it travels in the file because it has to survive a theme being distributed." The licence has a stronger claim to that treatment than the origin does.

Scope

Theme patterns. One line in the header block built at includes/class-pattern-file-store.php:445-462, beside $origin:

$license = $pattern->license ? "\n * License: " . $pattern->license : '';

Conditional in the same way, so a pattern with no licence — a local one that never came from the cloud — is written exactly as it is today and no existing file churns.

User patterns. Post meta, mirroring how Origin: is handled for wp_block destinations, so both install destinations carry it.

Read it back. The header has to parse on read as well as write, so a re-upload or a round trip does not drop it, and so the UI issue has something to display.

Caveat worth recording

Once the file sits inside a distributed theme, the theme's own style.css and readme.txt arguably cover it, which makes this belt-and-braces rather than strictly required. It earns its place for the case where a pattern file moves between themes or sites on its own, where nothing else states the terms. Not a reason to skip it, but a reason not to over-build it.

Acceptance criteria

  • License: written for a cloud-installed theme pattern
  • Equivalent meta for a wp_block destination
  • Header parses on read; a round trip preserves it
  • A pattern with no licence is written byte-identically to today — verified, not assumed
  • WordPress's pattern scanner still registers the file (unknown headers are ignored, but confirm)
  • npm run test:php (or the SQLite fallback) passes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions