hsimah-services/wp-graphql-metabox 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hsimah-services/wp-graphql-metabox

Composer 安装命令:

composer require hsimah-services/wp-graphql-metabox

包简介

WPGraphQL integration for Metabox

README 文档

README

Quick Install

Download and install like any WordPress plugin.

Documentation

The WPGraphQL documentation can be found here.

  • Requires PHP 7.3+
  • Requires WordPress 5.4+
  • Requires WPGraphQL 1.1.3+
  • Requires Meta Box 5.3.8+
    • Requires MB User Meta extension for User fields

Overview

This plugin provides an integration for Meta Box and WPGraphQL.

By simply adding an extra graphql_name property to the field registration the field will be exposed in the GraphQL schema.

Usage:

This assume you know how to expose custom post types in WPGraphQL - read their documentation for further info.

Using Meta Box, define a custom field. Copy and paste the generated code to your functions.php (or where ever you store your custom code).

wp-graphql-metabox options

option type effect
graphql_name string adds the field to the GraphQL object(s) identified in post_types
graphql_mutate boolean adds the field to the GraphQL object(s) create and update mutation input

Add in the graphql_name to the field definition:

$meta_boxes[] = [
    'title' => 'Extra Fields',
    'id' => 'extra-fields',
    'post_types' => [
        0 => 'post',
    ],
    'context' => 'after_title',
    'priority' => 'high',
    'autosave' => true,
    'fields' => [
        [
            'id' => 'a_random_number',
            'name' => 'A Random Number',
            'type' => 'number',
            'std' => 5,
            'columns' => 2,
            'size' => 3,
            'graphql_name' => 'randomNumber',
            'graphql_mutate' => true
        ],
    ],
];

That's it. The field randomNumber will be exposed on the type post. This will work for any custom post types you may create.

NB: You must expose custom types by adding show_in_graphql to the configuration of the CPT.

A simple query might look like this:

query {
    posts {
        nodes {
            title
            content
            randomNumber
        }
    }
}

Limitations

Currently the plugin only supports custom fields on post and user types (ie no Settings Pages).

Currently the plugin only supports using the following Meta Box types:

  • taxonomy
  • taxonomy_advanced
  • switch
  • checkbox
  • checkbox_list
  • background
  • color
  • custom_html
  • date
  • heading
  • datetime
  • oembed
  • password
  • radio
  • textarea
  • time
  • select
  • email
  • tel
  • text
  • url
  • wysiwyg
  • fieldset_text
  • select_advanced
  • text_list
  • key_value
  • number
  • range
  • single_image
  • user
  • post
  • group If you require a field which is not supported please feel free to submit an issue (or better yet, a PR!)

hsimah-services/wp-graphql-metabox 适用场景与选型建议

hsimah-services/wp-graphql-metabox 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 676 次下载、GitHub Stars 达 28, 最近一次更新时间为 2020 年 06 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 hsimah-services/wp-graphql-metabox 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hsimah-services/wp-graphql-metabox 我们能提供哪些服务?
定制开发 / 二次开发

基于 hsimah-services/wp-graphql-metabox 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 676
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 28
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 28
  • Watchers: 5
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2020-06-01