getolympus / olympus-dionysos-field-font
字体字段,该组件是Olympus Dionysos字段的一部分。
v0.0.2
2020-04-02 18:03 UTC
Requires (Dev)
- phpunit/phpunit: ~5.3
This package is auto-updated.
Last update: 2024-09-05 06:53:47 UTC
README
该组件是用于 WordPress 的 Olympus Dionysos 字段 的一部分。
composer require getolympus/olympus-dionysos-field-font
字段初始化
使用以下行在您的 WordPress 管理页面或自定义文章类型元字段中添加 font field
return \GetOlympus\Dionysos\Field\Font::build('my_font_field_id', [ 'title' => 'Select your character!', 'default' => [ 'family' => 'Open Sans', 'backup' => 'Arial, Helvetica, sans-serif', 'subset' => 'latin', 'variant' => 'regular', 'size' => '16px', 'lineheight' => '1.8', 'letterspacing' => '0', 'color' => '#000000', ], 'description' => 'Select your fighting stage!', ]);
变量定义
检索数据
使用简单的 get_option('my_font_field_id', [])
从数据库中检索您的值(请参阅 WordPress 参考)。
以下是一个 json_encode()
的示例,以了解数据是如何存储在数据库中的
{ "family": "Open Sans", "backup": "Arial, Helvetica, sans-serif", "subset": "latin", "variant": "regular", "size": "16px", "lineheight": "1.8", "letterspacing": "0", "color": "#000000" }
以下是一个简单的示例,展示如何在 PHP
中迭代数据数组
// Get font from Database $font = get_option('my_font_field_id', []); // Check if font is empty and display it if (!empty($font)) { echo '<h1 style="font-family:'.$font['family'].';font-size:'.$font['size'].'">My custom title</h1>'; }
版本历史
0.0.2
- 添加Ajax调用
- 添加显示
- 添加Google字体
0.0.1
- 首次提交
贡献
- 分叉它 (https://github.com/GetOlympus/olympus-dionysos-field-font/fork)
- 创建您的功能分支 (
git checkout -b feature/fooBar
) - 提交您的更改 (
git commit -am 'Add some fooBar'
) - 推送到分支 (
git push origin feature/fooBar
) - 创建一个新的Pull Request
由 Achraf Chouk 用爱心构建 ~ (c) 很长时间以来。