kucrut/bridge
Composer 安装命令:
composer require kucrut/bridge
包简介
Additional REST API endpoints and functionalities
关键字:
README 文档
README
This plugin was built to provide a bridge between WordPress and Minnie. It modifies the results of some WP API requests.
Requirements
- WordPress 4.5
- WP API 2.0-beta13
More bridges:
Endpoints
Info
Endpoint: /wp-json/bridge/v1/info
{
"url": "https://kucrut.org/wp",
"home": "https://kucrut.org",
"name": "Dzikri Aziz",
"description": "WordPress Developer, Traveler.",
"lang": "en-US",
"html_dir": "ltr",
"settings": {
"archive": {
"per_page": 11
},
"comments": {
"per_page": 50,
"threads": true,
"threads_depth": 3
}
}
}
Results Modifications
To get a modified result, a "Client ID" must be registered first:
/** * Register to the Bridge plugin * * @param array $client_ids Client IDs. * @wp_hook filter bridge_client_ids * @return array */ function minnie_register_to_bridge( $client_ids ) { $client_ids[] = 'minnie'; return $client_ids; } add_filter( 'bridge_client_ids', 'minnie_register_to_bridge' );
Then, every API request must include an X-Requested-With header and the value set to the registered Client ID, in this case minnie.
Terms
Home URL is stripped from term links.
Original Result
[
{
"id": 3,
"count": 0,
"description": "",
"link": "http://example.org/blog/type/aside/",
"name": "Aside",
"slug": "post-format-aside",
"taxonomy": "post_format"
}
]
Modified Result
[
{
"id": 3,
"count": 0,
"description": "",
"link": "/blog/type/aside/",
"name": "Aside",
"slug": "post-format-aside",
"taxonomy": "post_format"
}
]
Posts
The result of requests to posts endpoints will have these modifications:
- Home URL is stripped from
link,content.rendered. titlegets a new item:from_content. It's generated from post content and is useful in case the post doesn't have a title and you still want to display a generated title on the client app.date_formattedandmodified_formattedare added, so you don't need to format the post dates in the client app.- The value of
categories,tagsandformatsis converted to WP_Term objects. - When post preview is requested (by setting the
previewparameter to1), the title and content will be replaced with the ones from the post's latest revision.
Original Result
{
"id": 1,
"date": "2016-02-20T02:09:47",
"date_gmt": "2016-02-20T02:09:47",
"guid": {
"rendered": "http://src.wordpress-develop.dev/?p=1"
},
"modified": "2016-05-24T11:34:19",
"modified_gmt": "2016-05-24T11:34:19",
"slug": "hello-world",
"type": "post",
"link": "http://src.wordpress-develop.dev/blog/2016/02/20/hello-world/",
"title": {
"rendered": "Hello world!"
},
"content": {
"rendered": "<p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing!</p>\n"
},
"excerpt": {
"rendered": "<p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing!</p>\n"
},
"author": 1,
"featured_media": 0,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"format": "aside",
"categories": [
1
],
"tags": [
5
],
"formats": [
3
]
}
Modified Result
{
"id": 1,
"date": "2016-02-20T02:09:47",
"date_gmt": "2016-02-20T02:09:47",
"guid": {
"rendered": "http://src.wordpress-develop.dev/?p=1"
},
"modified": "2016-05-24T11:34:19",
"modified_gmt": "2016-05-24T11:34:19",
"slug": "hello-world",
"type": "post",
"link": "/blog/2016/02/20/hello-world/",
"title": {
"rendered": "Hello world!",
"from_content": "Welcome to WordPress. This is your first pos…"
},
"content": {
"rendered": "<p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing!</p>\n"
},
"excerpt": {
"rendered": "<p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing!</p>\n"
},
"author": 1,
"featured_media": 0,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"format": "aside",
"categories": [
{
"id": 1,
"name": "Uncategorized",
"slug": "uncategorized",
"description": "",
"link": "/blog/category/uncategorized/"
}
],
"tags": [
{
"id": 5,
"name": "misc",
"slug": "misc",
"description": "",
"link": "/blog/tag/misc/"
}
],
"formats": [
{
"id": 3,
"name": "Aside",
"slug": "post-format-aside",
"description": "",
"link": "/blog/type/aside/"
}
],
"date_formatted": "February 20, 2016",
"modified_formatted": "May 24, 2016",
}
Attachments
In additions to the modifications above, the result of requests to attachments/media will have these modifications:
parent_postis added.
Modified Result
{
"parent_post": {
"id": 1,
"link": "/blog/2016/02/20/hello-world/",
"title": {
"rendered": "Hello world!"
}
}
}
Comments
Original Result
{
"id": 1,
"post": 1,
"parent": 0,
"author": 0,
"author_name": "Mr WordPress",
"author_url": "https://wordpress.org/",
"date": "2016-02-20T02:09:47",
"date_gmt": "2016-02-20T02:09:47",
"content": {
"rendered": "<p>Hi, this is a comment.<br />\nTo delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.</p>\n"
},
"link": "http://src.wordpress-develop.dev/blog/2016/02/20/hello-world/#comment-1",
"status": "approved",
"type": "comment",
"author_avatar_urls": {
"24": "http://1.gravatar.com/avatar/?s=24&d=mm&r=g",
"48": "http://1.gravatar.com/avatar/?s=48&d=mm&r=g",
"96": "http://2.gravatar.com/avatar/?s=96&d=mm&r=g"
},
"_links": {
"self": [
{
"href": "http://src.wordpress-develop.dev/wp-json/wp/v2/comments/1"
}
],
"collection": [
{
"href": "http://src.wordpress-develop.dev/wp-json/wp/v2/comments"
}
],
"up": [
{
"embeddable": true,
"post_type": "post",
"href": "http://src.wordpress-develop.dev/wp-json/wp/v2/posts/1"
}
]
}
}
Modified Result
{
"id": 1,
"post": 1,
"parent": 0,
"author": 0,
"author_name": "Mr WordPress",
"author_url": "https://wordpress.org/",
"date": "2016-02-20T02:09:47",
"date_gmt": "2016-02-20T02:09:47",
"content": {
"rendered": "<p>Hi, this is a comment.<br />\nTo delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.</p>\n"
},
"link": "/blog/2016/02/20/hello-world/#comment-1",
"status": "approved",
"type": "comment",
"author_avatar_urls": {
"24": "http://2.gravatar.com/avatar/?s=24&d=mm&r=g",
"48": "http://1.gravatar.com/avatar/?s=48&d=mm&r=g",
"96": "http://0.gravatar.com/avatar/?s=96&d=mm&r=g"
},
"children_count": 0,
"date_formatted": "February 20, 2016 at 2:09 am",
"_links": {
"self": [
{
"href": "http://src.wordpress-develop.dev/wp-json/wp/v2/comments/1"
}
],
"collection": [
{
"href": "http://src.wordpress-develop.dev/wp-json/wp/v2/comments"
}
],
"up": [
{
"embeddable": true,
"post_type": "post",
"href": "http://src.wordpress-develop.dev/wp-json/wp/v2/posts/1"
}
]
}
}
Changelog
0.8.0
- Fix compatibility with WordPress 4.7
0.7.0
- Support custom taxonomies
0.6.0
- Add
/infoendpoint
0.5.0
- Live Preview
0.4.0
- Comments mods
0.3.0
- Strip
home_url()from menu items' url.
0.2.1
- Add
langandhtml_dirto index's response
0.2.0
- Remove Menus & Post Formats (now as standalone plugins)
0.1.0
- Initial
kucrut/bridge 适用场景与选型建议
kucrut/bridge 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 268 次下载、GitHub Stars 达 7, 最近一次更新时间为 2016 年 05 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「rest」 「wordpress」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kucrut/bridge 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kucrut/bridge 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kucrut/bridge 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Api bundle
A Flickr wrapper to allow you to call the Flickr api with Guzzle as the backend.Goal is to have 100% Flickr api coverage rather than just upload/display photos (currently at 23%).
Must-use plugin integrating WordPress with the Upsun platform: environment awareness, router-cache friendliness, safe preview clones, deploy migrations, Site Health checks, and a wp upsun CLI command.
BlockCypher's PHP SDK for REST API
Helper classes for creating cookie headers
统计信息
- 总下载量: 268
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2016-05-28