getolympus / olympus-dionysos-field-oembed
oEmbed字段,该组件是Olympus Dionysos字段的一部分。
v0.0.4
2023-12-18 19:08 UTC
Requires (Dev)
- phpunit/phpunit: ~5.3
This package is auto-updated.
Last update: 2024-09-21 00:29:10 UTC
README
Dionysos oEmbed字段
该组件是针对WordPress的Olympus Dionysos字段的一部分。
composer require getolympus/olympus-dionysos-field-oembed
目录
字段初始化 • 变量定义 • 文本定义 • 检索数据 • 发布历史 • 贡献
字段初始化
使用以下行在您的WordPress管理页面或自定义文章类型元字段中添加oembed字段
return \GetOlympus\Dionysos\Field\Oembed::build('my_oembed_field_id', [ 'title' => 'Never gonna give you up!', 'default' => [ 'url' => 'https://www.youtube.com/watch?v=Xxbd5keKhPU', 'height' => 1000, 'width' => 916, 'html' => '<iframe title="Popopooooo" width="916" height="515" src="https://www.youtube.com/embed/Xxbd5keKhPU?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>', ], 'description' => 'You\'ve been Rick rolled!', /** * Texts definition * @see the `Texts definition` section below */ 't_addblock_label' => 'Enter URL here.', 't_removeblock_label' => 'Clear', ]);
变量定义
文本定义
检索数据
使用简单的get_option('my_oembed_field_id', [])
从数据库中检索您的值(参见WordPress参考)。
下面是一个json_encode()
的示例,说明数据如何存储在数据库中。
{ "url": "https://www.youtube.com/watch?v=Xxbd5keKhPU", "height": 1000, "width": 916, "html": "<iframe title=\"Popopooooo\" width=\"916\" height=\"515\" src=\"https://www.youtube.com/embed/Xxbd5keKhPU?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>" }
下面是一个简单的示例,说明如何在PHP
中迭代数据数组。
// Get embed from Database $embed = get_option('my_oembed_field_id', []); // Check if embed is empty and display it if (!empty($embed)) { echo stripcslashes($embed['html']); }
发布历史
贡献
- 分叉它(https://github.com/GetOlympus/olympus-dionysos-field-oembed/fork)
- 创建您的功能分支(
git checkout -b feature/fooBar
) - 提交您的更改(
git commit -am 'Add some fooBar'
) - 将更改推送到分支(
git push origin feature/fooBar
) - 创建新的拉取请求
由Achraf Chouk倾情打造 ~ (c) 很长时间以来。