getolympus/olympus-dionysos-field-oembed

oEmbed字段,该组件是Olympus Dionysos字段的一部分。

安装: 164

依赖项: 2

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

公开问题: 0

语言:JavaScript

类型:olympus-field

v0.0.4 2023-12-18 19:08 UTC

This package is auto-updated.

Last update: 2024-09-21 00:29:10 UTC


README

Dionysos oEmbed字段

Olympus Component CodeFactor Grade Packagist Version MIT

该组件是针对WordPressOlympus 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']);
}

发布历史

贡献

  1. 分叉它(https://github.com/GetOlympus/olympus-dionysos-field-oembed/fork
  2. 创建您的功能分支(git checkout -b feature/fooBar
  3. 提交您的更改(git commit -am 'Add some fooBar'
  4. 将更改推送到分支(git push origin feature/fooBar
  5. 创建新的拉取请求

Achraf Chouk倾情打造 ~ (c) 很长时间以来。