valu/wp-graphql-polylang
Composer 安装命令:
composer require valu/wp-graphql-polylang
包简介
Polylang bindings for wp-graphql
README 文档
README
Extend WPGraphQL schema with language data from the Polylang plugin.
Features
For posts and terms (custom ones too!)
- Adds
languageandtranslationsfields - Filter with a
languagewhere argument - Set the language on create and update mutations
- Show all translations in the api by default
- Polylang patches the WP Query to only list items with the current default language. This plugin reverts that for the GraphQL api
- ACF Options Pages support
Root queries
defaultLanguageget the current default languagelanguageslist all configured languages
Menu
- Filter menu items by language
For details please refer to the generated docs in GraphiQL.
Example
Example showing all features
query PolylangExample { # Filter pages by language. If not set it defaults to ALL pages(where: { language: EN }) { nodes { title # Get language of each page language { code # Language code name # Human readable name of the language } # Get links to the translates versions of each page # This is an array of post objects translations { title link language { code } } } } # Taxonomies such as tags can be filtered like post objects tags(where: { language: EN }) { nodes { name language { code name } } } # Get translated version of a given menu menuItems(where: { language: EN, location: FOOTER_MENU }) { nodes { url } } # Get the default language defaultLanguage { name code } # Get all configured languages languages { name code } # Get translations for ACF Options Pages. # See the section in the README. siteSettings(language: EN) { siteSettings { footerTitle } } }
Requirements
- PHP 7.2 or later
- WPGraphQL 0.13.x or later
- Polylang 2.6.5 or later
- The free version is enough
- If you get the PRO version the pro features such as translated slugs will work too
Installation
If you use composer you can install it from Packagist
composer require valu/wp-graphql-polylang
Otherwise you can clone it from Github to your plugins using the stable branch
cd wp-content/plugins
git clone --branch stable https://github.com/valu-digital/wp-graphql-polylang.git
ACF Options Pages
In addition to WPGraphQL and Polylang plugins you'll need these plugins too
- Advanced Custom Fields Pro
- It's Pro only feature
- ACF Options For Polylang
- WPGraphQL for Advanced Custom Fields
- v0.3.2 or later is required
You can install the free plugins using Composer. You'll need to have the WordPress Packagist repository enabled.
composer require wp-graphql/wp-graphql-acf wpackagist-plugin/acf-options-for-polylang
When registering the Options Page you must pass in show_in_graphql and
graphql_field_name arguments.
acf_add_options_page([ 'page_title' => __('Site settings', 'theme'), 'menu_title' => __('Site settings', 'theme'), 'menu_slug' => 'site-settings', 'capability' => 'manage_options', 'redirect' => false, 'show_in_graphql' => true, 'graphql_field_name' => 'siteSettings' ]);
Slack
You can find us from the WPGraphQL Slack on the #polylang channel.
WPML
But I'm using WPML?!
There's rburgst/wp-graphql-wpml.
Or you might want to checkout migration docs
https://polylang.pro/how-to-switch-from-wpml-to-polylang/
Contributing
Checkout CONTRIBUTING.md
valu/wp-graphql-polylang 适用场景与选型建议
valu/wp-graphql-polylang 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 108.68k 次下载、GitHub Stars 达 146, 最近一次更新时间为 2019 年 11 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 valu/wp-graphql-polylang 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 valu/wp-graphql-polylang 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 108.68k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 146
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2019-11-06