getolympus / olympus-dionysos-field-header
头部字段,该组件是Olympus Dionysos字段的一部分。
v0.0.2
2020-05-03 00:49 UTC
Requires (Dev)
- phpunit/phpunit: ~5.3
This package is auto-updated.
Last update: 2024-08-29 05:01:00 UTC
README
Dionysos头部字段
此组件是WordPress的Olympus Dionysos字段的一部分。
composer require getolympus/olympus-dionysos-field-header
目录
字段初始化 • 变量定义 • 文本定义 • 接受模式 • 检索数据 • 发布历史 • 贡献
字段初始化
使用以下行在您的WordPress管理页面或自定义帖子类型元字段中添加一个头部字段
return \GetOlympus\Dionysos\Field\Header::build('my_header_field_id', [ 'title' => 'You\'re about to find out what it\'s like to fight a real Super Saiyan...', 'default' => [], 'description' => 'and I\'m not talking about Goku!', 'mode' => 'top', /** * Texts definition * @see the `Texts definition` section below */ 't_align_left' => 'Left', 't_align_center' => 'Center', 't_align_right' => 'Right', 't_align_expand' => 'Expand', 't_header_overall' => 'Overall header', 't_header_main' => 'Main header', 't_header_secondary' => 'Secondary header', 't_logo_no_display' => 'Hide website\'s baseline', 't_logo_display' => 'Display website\'s baseline', 't_navs_label' => 'Navigation menus', 't_search_label' => 'Search displays', 't_search_default' => 'Default', 't_search_drop' => 'Drop', 't_search_dropdown' => 'Dropdown', 't_search_modal' => 'Modal', 't_search_overlay' => 'Overlay', 't_text_default' => 'Call us today! 1.555.555.555', 't_type_label' => 'Choose a content type', 't_type_logo' => 'Website\'s logo', 't_type_nav' => 'Navigation menu', 't_type_search' => 'Search form', 't_type_text' => 'Custom text field', 't_addblock_label' => 'Click on the button to add content', 't_editblock_label' => 'Click on the button to edit content', 't_removeblock_label' => 'Remove', 't_updateblock_label' => 'Update', ]);
变量定义
文本定义
接受模式
top
以默认显示方式显示头部left
以左侧导航显示头部right
以右侧导航显示头部
检索数据
使用简单的get_option('my_header_field_id', [])
从数据库检索您的值(参见WordPress参考)
// Get headers from Database $headers = get_option('my_header_field_id', []); if (!empty($headers)) { echo '<header>'; foreach ($headers as $name => $options) { echo '<nav class="nav '.$name.'">'; echo '<ul>'; foreach ($options['contents'] as $content) { # code... echo '<li>'.$content[0].': '.$content[1].'</li>'; } echo '</ul>'; echo '</nav>'; } echo '</header>'; }
发布历史
贡献
- 分叉它 (https://github.com/GetOlympus/olympus-dionysos-field-header/fork)
- 创建您的功能分支 (
git checkout -b feature/fooBar
) - 提交您的更改 (
git commit -am 'Add some fooBar'
) - 推送到分支 (
git push origin feature/fooBar
) - 创建新的Pull Request
由Achraf Chouk构建,热爱这份工作 ~ (c) 很久以前。