Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add production blocks metadata #32497

Merged
merged 6 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/add-prod-blocks-metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: enhancement

Add block.json metadata file to part of production blocks
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "jetpack/payment-buttons",
"title": "Payment Buttons",
"description": "Prompt visitors to purchase your products and subscriptions with a group of buttons.",
"keywords": [
"buy", "contribution", "commerce", "credit card", "debit card", "donate", "Donations",
"earn", "ecommerce", "gofundme", "memberships", "money", "paid", "patreon", "pay",
"payments", "products", "purchase", "recurring", "sell", "shop", "stripe", "subscribe",
"subscriptions", "sponsor", "square", "toast", "venmo"
],
"version": "12.5.0",
"textdomain": "jetpack",
"category": "earn",
"icon": "block-default",
"supports": {
"__experimentalExposeControlsToChildren": true,
"align": [ "wide", "full" ],
"spacing": {
"blockGap": true,
"margin": [ "vertical" ],
"__experimentalDefaultControls": {
"blockGap": true
}
},
"__experimentalLayout": {
"allowSwitching": false,
"allowInheriting": false,
"default": {
"type": "flex"
}
},
"typography": {
"fontSize": true,
"__experimentalFontFamily": true,
"__experimentalTextTransform": true,
"__experimentalDefaultControls": {
"fontSize": true
}
}
},
"attributes":{ },
"editorScript": "file:../editor.js"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if we need this one, since that's just a parent block for the Payments button, Donations, and Paid content blocks?

Copy link
Member

Choose a reason for hiding this comment

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

jetpack/payments-intro is a block like any other: it's registered with register_block_type, can be inserted from the inserter, and is serialized as <!-- wp:jetpack/payments-intro /-->. What is special about is that it's meant to be a temporary placeholder, to be quickly replaced by one of the "real" payment blocks. But that's just semantics, formally it's a block.

Copy link
Member

Choose a reason for hiding this comment

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

Right, but I'm not sure it's one that we must publicize on W.org, given that we already publicize the "real" payment blocks. It may create more confusion than anything else.

Copy link
Member

Choose a reason for hiding this comment

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

Having a block.json file should be useful and preferred for all blocks. For example, they are then properly visible in the /block-types REST endpoint. If we don't want to publicize them on W.org, maybe there is a block.json flag for that? @gziolo will know.

Copy link
Member

Choose a reason for hiding this comment

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

You don't need block.json to expose the block in the REST endpoint. All you need is to register it with register_block_type so it's available in the block type registry.

I don't know precisely how W.org scans the code of the plugin when looking for block types. I bet though, that when you alias the function with something else, it won't list it.

Copy link
Member

Choose a reason for hiding this comment

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

All you need is to register it with register_block_type so it's available in the block type registry.

Jetpack currently doesn't do server-side block registration with the block.json. The subset of fields that it passes to register_block_type is a very small subset, and it's duplicated. So, the info available in the REST endpoint will be very limited. It would be a nice follow-up to improve this.

I don't know precisely how W.org scans the code of the plugin when looking for block types.

That would be nice to know, especially if there is any "opt-out from public registry listing" flag. It would be very useful for cases like this one.

"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "jetpack/payments-intro",
"title": "Payments",
"description": "Sell products and services or receive donations on your website.",
"keywords": [ "donations", "paid", "pay", "money", "checkout", "pay", "checkout" ],
"version": "12.5.0",
"textdomain": "jetpack",
"category": "earn",
"icon": "money-alt",
"supports": {
"alignWide": false,
"className": true,
"customClassName": false,
"html": false,
"reusable": false
},
"attributes":{},
"editorScript": "file:../editor.js"
}
27 changes: 27 additions & 0 deletions projects/plugins/jetpack/extensions/blocks/pinterest/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "jetpack/pinterest",
"title": "Pinterest",
"description": "Embed a Pinterest pin, board, or user.",
"keywords": [ "social", "pinboard", "pins" ],
"version": "12.5.0",
"textdomain": "jetpack",
"category": "embed",
"icon": "pinterest",
"supports": {
"html": false,
"align": false
},
"attributes":{
"url": {
"type": "string"
}
},
"example": {
"attributes": {
"url": "https://pinterest.com/anapinskywalker/"
}
},
"editorScript": "file:../editor.js"
}
110 changes: 110 additions & 0 deletions projects/plugins/jetpack/extensions/blocks/podcast-player/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "jetpack/podcast-player",
"title": "Podcast Player",
"description": "Select and play episodes from a single podcast.",
"keywords": [ "audio", "embed"],
"version": "12.5.0",
"textdomain": "jetpack",
"category": "embed",
"icon": "playlist-audio",
"supports": {
"align": [ "wide", "full" ],
"spacing": {
"padding": true,
"margin": true
},
"anchor": false,
"customClassName": true,
"className": true,
"html": false,
"multiple": true,
"reusable": true
},
"attributes": {
"url": {
"type": "string",
"validator": "isUrl"
},
"selectedEpisodes": {
"type": "array",
"default": []
},
"itemsToShow": {
"type": "integer",
"default": 5
},
"showCoverArt": {
"type": "boolean",
"default": true
},
"showEpisodeTitle": {
"type": "boolean",
"default": true
},
"showEpisodeDescription": {
"type": "boolean",
"default": true
},
"primaryColor": {
"type": "string"
},
"customPrimaryColor": {
"type": "string"
},
"hexPrimaryColor": {
"type": "string"
},
"secondaryColor": {
"type": "string"
},
"customSecondaryColor": {
"type": "string"
},
"hexSecondaryColor": {
"type": "string"
},
"backgroundColor": {
"type": "string"
},
"customBackgroundColor": {
"type": "string"
},
"hexBackgroundColor": {
"type": "string"
},
"exampleFeedData": {
"type": "object"
}
},
"example": {
"attributes": {
"customPrimaryColor": "GREEN",
"hexPrimaryColor": "GREEN",
"exampleFeedData": {
"title": "Jetpack Example Podcast",
"link": "https://jetpack.com",
"cover": "https://jetpackme.files.wordpress.com/2020/05/jetpack-example-podcast-cover.png?w=160",
"tracks": [
{
"id": "3",
"title": "3. Our third episode",
"duration": "14:58"
},
{
"id": "2",
"title": "2. Interview with a special guest",
"duration": "19:17"
},
{
"id": "1",
"title": "1. Welcome to Example Podcast",
"duration": "11:25"
}
]
}
}
},
"editorScript": "file:../editor.js"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "jetpack/premium-content",
"title": "Paid Content",
"description": "Restrict access to your content for paying subscribers.",
"keywords": [ "buy", "credit card", "debit card", "earn", "exclusive", "gated", "gofundme", "memberships", "money", "newsletter", "paid", "patreon", "pay", "payments", "paywall", "premium content", "purchase", "recurring", "repeat", "signin", "stripe", "subscribe", "subscriptions", "support", "sponsor", "square", "toast", "venmo", "stripe", "substack"],
"version": "12.5.0",
"textdomain": "jetpack",
"category": "grow",
"icon": "yes-alt",
"supports": {
"html": false
},
"providesContext": {
"premium-content/planId": "selectedPlanId",
"premium-content/isPreview": "isPreview",
"isPremiumContentChild": "isPremiumContentChild"
},
"attributes": {
"newPlanName": {
"type": "string",
"default": "Monthly Subscription"
},
"newPlanCurrency": {
"type": "string",
"default": "USD"
},
"newPlanPrice": {
"type": "number",
"default": 5
},
"newPlanInterval": {
"type": "string",
"default": "1 month"
},
"selectedPlanId": {
"type": "number",
"default": 0
},
"isPreview": {
"type": "boolean",
"default": false
},
"isPremiumContentChild": {
"type": "boolean",
"default": true
}
},
"example": {
"attributes": {
"isPreview": true
}
},
"editorScript": "file:../editor.js"
}
44 changes: 44 additions & 0 deletions projects/plugins/jetpack/extensions/blocks/rating-star/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "jetpack/rating-star",
"title": "Star Rating",
"description": "Rate movies, books, songs, recipes — anything you can put a number on.",
"keywords": ["star", "rating", "review"],
"version": "12.5.0",
"textdomain": "jetpack",
"category": "widgets",
"icon": "star-half",
"supports": {
"html": false
},
"styles": [
{
"name": "filled",
"label": "Filled",
"isDefault": true
},
{
"name": "outlined",
"label": "Outlined"
}
],
"attributes": {
"rating": {
"type": "number",
"default": 1
},
"maxRating": {
"type": "number",
"default": 5
},
"color": {
"type": "string"
},
"align": {
"type": "string",
"default": "left"
}
},
"editorScript": "file:../editor.js"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "jetpack/recurring-payments",
"title": "Payment Button",
"description": "Button allowing you to sell products and subscriptions.",
"keywords": [
"buy", "contribution", "commerce", "credit card", "debit card", "donate", "Donations",
"earn", "ecommerce", "gofundme", "memberships", "money", "paid", "patreon", "pay",
"payments", "products", "purchase", "recurring", "sell", "shop", "stripe", "subscribe",
"subscriptions", "sponsor", "square", "toast", "venmo"
],
"version": "12.5.0",
"textdomain": "jetpack",
"category": "earn",
"icon": "cart",
"supports": {
"html": false,
"__experimentalExposeControlsToChildren": true,
},
"usesContext": [ "isPremiumContentChild" ],
"providesContext": {
"jetpack/parentBlockWidth": "width",
},
"attributes": {
"planId": {
"type": "integer"
},
"align": {
"type": "string"
},
"url": {
"type": "string",
"default": "#"
},
"uniqueId": {
"type": "string",
"default": "id"
},
"width": {
"type": "string"
}
},
"editorScript": "file:../editor.js"
}
Loading