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', ]);
变量定义
注意
- 将
multiple
设置为true
以显示复选框而不是单选按钮 field
变量用于让您根据type
值检索所需的数据(例如:在'type' => 'term'
的情况下,您将默认获取term_id
)
文本定义
接受类型
categories
或category
(有关field
和settings
变量的信息,请参阅 WordPress 参考)menus
或menu
(有关field
和settings
变量的信息,请参阅 WordPress 参考)pages
或page
(有关field
和settings
变量的信息,请参阅 WordPress 参考)posts
或post
(有关field
和settings
变量的信息,请参阅 WordPress 参考)posttypes
或posttype
(有关field
和settings
变量的信息,请参阅 WordPress 参考)tags
或tag
(有关field
和settings
变量的信息,请参阅 WordPress 参考)taxonomies
或taxonomy
(有关field
和settings
变量的信息,请参阅 WordPress 参考)terms
或term
(有关field
和settings
变量的信息,请参阅 WordPress 参考)users
或user
(有关field
和settings
变量的信息,请参阅 WordPress 参考)
检索数据
使用简单的 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>'; }
发布历史
贡献
- 进行分支(https://github.com/GetOlympus/olympus-dionysos-field-wordpress/fork)
- 创建您的功能分支(
git checkout -b feature/fooBar
) - 提交您的更改(
git commit -am '添加一些fooBar'
) - 推送到分支(
git push origin feature/fooBar
) - 创建新的Pull Request
由 Achraf Chouk 使用♥构建 ~ (c)从很久以前开始。