spacedmonkey/wp-rest-blocks

将gutenberg块数据添加到文章/页面/小工具REST API端点。

资助包维护!
spacedmonkey

安装量: 1,483

依赖项: 0

建议者: 0

安全: 0

星标: 118

关注者: 7

分支: 21

开放问题: 25

类型:wordpress-plugin


README

贡献者:spacedmonkey 捐赠链接:https://github.com/sponsors/spacedmonkey 标签:blocks, gutenberg, api, wp-json, rest-api 需求至少:5.5 测试到:6.5 需求PHP:7.0.0 稳定标签:1.0.2 许可证:GPLv3或更高 许可证URI:https://gnu.ac.cn/licenses/gpl-3.0.en.html

将gutenberg块数据添加到文章/页面REST API端点。

Build Status

描述

一个简单的插件,将块数据以json格式添加到REST API中。安装后,REST API将新增两个新字段:has_blocksblocks。例如输出。

"has_blocks": true,
"block_data": [
  {
	"blockName": "core/image",
	"attrs": {
	  "url": "https://www.spacedmonkey.com/wp-content/uploads/2018/12/test-image.jpg",
	  "alt": "Terminal de aeropuerto",
	  "caption": "fsfsdfdsfdssfd",
	  "href": "https://www.spacedmonkey.com/test-image",
	  "rel": "noreferrer noopener",
	  "linkClass": "jonny-123",
	  "linkTarget": "_blank",
	  "id": 147355,
	  "width": 582,
	  "height": 327,
	  "linkDestination": "attachment"
	},
	"innerBlocks": [
	],
	"innerHTML": "\n<figure class=\"wp-block-image is-resized\"><a class=\"jonny-123\" href=\"https://www.spacedmonkey.com/test-image\" target=\"_blank\" rel=\"noreferrer noopener\"><img src=\"https://www.spacedmonkey.com/wp-content/uploads/2018/12/test-image.jpg\" alt=\"Terminal de aeropuerto\" class=\"wp-image-147355\" width=\"582\" height=\"327\"/></a><figcaption>fsfsdfdsfdssfd</figcaption></figure>\n",
	"innerContent": [
	  "\n<figure class=\"wp-block-image is-resized\"><a class=\"jonny-123\" href=\"https://www.spacedmonkey.com/test-image\" target=\"_blank\" rel=\"noreferrer noopener\"><img src=\"https://www.spacedmonkey.com/wp-content/uploads/2018/12/test-image.jpg\" alt=\"Terminal de aeropuerto\" class=\"wp-image-147355\" width=\"582\" height=\"327\"/></a><figcaption>fsfsdfdsfdssfd</figcaption></figure>\n"
	],
	"rendered": "\n<figure class=\"wp-block-image is-resized\"><a class=\"jonny-123\" href=\"https://www.spacedmonkey.com/test-image\" target=\"_blank\" rel=\"noreferrer noopener\"><img src=\"https://www.spacedmonkey.com/wp-content/uploads/2018/12/test-image.jpg\" alt=\"Terminal de aeropuerto\" class=\"wp-image-147355\" width=\"582\" height=\"327\"/></a><figcaption>fsfsdfdsfdssfd</figcaption></figure>\n"
  }
],

技术说明

  • 需要PHP 5.6+。
  • 需要WordPress 5.5+。
  • 在GitHub仓库:[https://github.com/spacedmonkey/wp-rest-blocks](https://github.com/spacedmonkey/wp-rest-blocks) 欢迎提交问题和拉取请求

安装

使用WordPress仪表盘

  1. 导航到插件仪表盘中的“添加新插件”
  2. 搜索“wp-rest-blocks”
  3. 点击“立即安装”
  4. 在插件仪表盘中激活插件

在WordPress仪表盘中上传

  1. 导航到插件仪表盘中的“添加新插件”
  2. 导航到“上传”区域
  3. 从您的计算机中选择wp-rest-blocks.zip
  4. 点击“立即安装”
  5. 在插件仪表盘中激活插件

使用FTP

  1. 下载wp-rest-blocks.zip
  2. wp-rest-blocks目录解压到您的计算机上
  3. wp-rest-blocks目录上传到/wp-content/plugins/目录
  4. 在插件仪表盘中激活插件

屏幕截图

  1. 向REST API添加字段。

变更日志

1.0.2

  • 修复WordPress 6.5的问题
  • 将编码标准更新到WP编码标准3.1.0
  • 标记测试到WP 6.5

1.0.1

  • 将编码标准更新到WP编码标准3.0.1
  • 标记测试到WP 6.4

1.0.0

重大更改!REST API中的字段从blocks更改为block_data

0.5.0

  • 支持WordPress 5.9中添加的新帖子类型。

0.4.0

  • 添加了对WordPress 5.8中添加的基于块的widget的支持。块数据添加到/wp/v2/widgets端点。

0.3.2

  • 更新翻译

0.3.1

  • 热修复。

0.3.0

  • 改进对具有使用查询源类型的属性的块的支撑。
  • 改进对未使用composer安装此插件的用户的错误处理。

0.2.1

  • 更新依赖关系。

0.2.0

  • 重大更改。字段名称已更改,并要求WordPress 5.5+。

0.1.0

  • 第一个版本。