getolympus / olympus-wordpress-field
此包已被废弃,不再维护。作者建议使用 getolympus/olympus-dionysos-field-wordpress 包代替。
WordPress 字段,此组件是 Olympus Dionysos 字段的一部分。
v0.0.21
2020-04-02 17:27 UTC
Requires (Dev)
- phpunit/phpunit: ~5.3
README
Dionysos WordPress 字段
此组件是针对 WordPress 的 Olympus Dionysos 字段 的一部分。它使用复制的
findPosts
WordPress 自定义模态来管理字段。
composer require getolympus/olympus-dionysos-field-wordpress
目录
字段初始化 • 变量定义 • 文本定义 • 接受类型 • 检索数据 • 发布历史 • 贡献
字段初始化
使用以下行在您的 WordPress 管理页面或自定义文章类型元字段中添加 wordpress field
return \GetOlympus\Dionysos\Field\Wordpress::build('my_wordpress_field_id', [ 'title' => 'Which is your favourite post?', 'default' => [], 'description' => 'Tell us which one did like this week.', 'field' => 'ID', 'multiple' => false, 'type' => 'post', 'settings' => [], /** * Texts definition * @see the `Texts definition` section below */ 't_addblock_title' => 'Click on the edit button', 't_addblock_description' => 'Click on the "+" button to add your item.', 't_addblocks_description' => 'Click on the "+" button to add a new item.', 't_addblock_label' => 'Add', 't_editblock_label' => 'Edit', 't_removeblock_label' => 'Remove', 't_modaltitle_label' => 'Choose a content', 't_modalclose_label' => 'Close', 't_modalsearch_label' => 'Search', 't_modalsubmit_label' => 'Select', 't_ajaxerror_label' => 'No item found', ]);
变量定义
变量 | 类型 | 未设置时的默认值 | 接受值 |
---|---|---|---|
title |
字符串 | 'Code' |
empty |
default |
Array | empty | empty |
description |
字符串 | empty | empty |
field |
字符串 | ID |
取决于 type 值 |
multiple |
布尔值 | false |
true 或 false |
type |
字符串 | post |
参见 接受类型 |
settings |
Array | empty | 取决于 type 值 |
注释
- 将
multiple
设置为true
以显示复选框而不是单选按钮 field
变量用于让您根据type
值检索所需数据(例如,在'type' => 'term'
的情况下,您将默认获得term_id
)
文本定义
代码 | 默认值 | 定义 |
---|---|---|
t_addblock_title |
点击编辑按钮 | 用作当没有标签时的提示,以帮助用户 |
t_addblock_description |
点击 "+" 按钮添加您的项目。 | 用作单格式中的提示,以帮助用户 |
t_addblocks_description |
点击 "+" 按钮添加新项目。 | 用作多格式中的提示,以帮助用户 |
t_addblock_label |
添加 | 添加按钮标签 |
t_editblock_label |
编辑 | 编辑按钮标签 |
t_removeblock_label |
删除 | 删除按钮标签 |
t_modaltitle_label |
选择内容 | 模态标题 |
t_modalclose_label |
关闭 | 模态关闭按钮标签 |
模态搜索标签 |
搜索 | 模态搜索按钮标签 |
模态提交标签 |
选择 | 模态选择按钮标签 |
ajax错误标签 |
未找到项目 | AJAX失败时的错误信息 |
接受类型
categories
或category
(参见get_categories
在 WordPress 参考 中的field
和settings
变量)menus
或menu
(参见wp_get_nav_menus
在 WordPress 参考 中的field
和settings
变量)pages
或page
(参见get_pages
在 WordPress 参考 中的field
和settings
变量)posts
或post
(参见wp_get_recent_posts
在 WordPress 参考 中的field
和settings
变量)posttypes
或posttype
(参见get_post_types
在 WordPress 参考 中的field
和settings
变量)tags
或tag
(参见get_the_tags
在 WordPress 参考 中的field
和settings
变量)taxonomies
或taxonomy
(参见get_taxonomies
在 WordPress 参考 中的field
和settings
变量)terms
或term
(参见get_terms
在 WordPress 参考 中的field
和settings
变量)users
或user
(参见get_users
在 WordPress 参考 中的field
和settings
变量)
检索数据
使用简单的 get_option('my_wordpress_field_id', [])
从数据库检索您的值(参见 WordPress 参考)
// Get wordpress from Database $wordpress = get_option('my_wordpress_field_id', []); if (!empty($wordpress)) { echo '<ul>'; foreach ($wordpress as $post_id) { echo '<li>'.get_the_title($post_id).'</li>'; } echo '</ul>'; }
发布历史
版本 | 注意 |
---|---|
0.0.21 | 在AJAX调用中添加检查 |
0.0.20 | 添加 wp-util WordPress集成 |
0.0.19 | 修复显示和WordPress核心函数集成 |
贡献
- 将其分叉(https://github.com/GetOlympus/olympus-dionysos-field-wordpress/fork)
- 创建您的功能分支(
git checkout -b feature/fooBar
) - 提交您的更改(
git commit -am 'Add some fooBar'
) - 推送到分支(
git push origin feature/fooBar
) - 创建一个新的Pull Request
由 Achraf Chouk 用♥构建 ~ 自从很久以前以来(c)。