getolympus / olympus-dionysos-field-oembed
oEmbed field, this component is a part of the Olympus Dionysos fields.
Installs: 173
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Language:JavaScript
Type:olympus-field
Requires (Dev)
- phpunit/phpunit: ~5.3
This package is auto-updated.
Last update: 2024-11-21 00:53:49 UTC
README
Dionysos oEmbed Field
This component is a part of the Olympus Dionysos fields for WordPress.
composer require getolympus/olympus-dionysos-field-oembed
Table of contents
Field initialization • Variables definition • Texts definition • Retrive data • Release history • Contributing
Field initialization
Use the following lines to add an oembed field
in your WordPress admin pages or custom post type meta fields:
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', ]);
Variables definition
Texts definition
Retrive data
Retrieve your value from Database with a simple get_option('my_oembed_field_id', [])
(see WordPress reference).
Below, a json_encode()
example to understand how data are stored in Database:
{ "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>" }
And below, a simple example to show how to iterate on the data array in 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']); }
Release history
Contributing
- Fork it (https://github.com/GetOlympus/olympus-dionysos-field-oembed/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
Built with ♥ by Achraf Chouk ~ (c) since a long time.