MediaShortcodes final class
Minn\Content\MediaShortcodes · public/minn/src/Minn/Content/MediaShortcodes.php · 187 lines
The [video] and [audio] shortcodes as the reference prints them: a plugin may take either over first (wp_*_shortcode_override, handed the shortcode's own attributes and its instance number), then the source by src or by each format's attribute (a file of another kind is only a link; YouTube and Vimeo addresses are video of their own; with none, the post's first attached video or audio), the player's attributes (a video no wider than the content, its height in proportion; the flags bare), each source numbered by the instance, a fallback link, and the class, library and final HTML through their filters.
Constants and properties
| private | YOUTUBE = '#^https?://(?:www\\.)?(?:youtube\\.com/watch|youtu\\.be/)#' | |
| private | VIMEO = '#^https?://(.+\\.)?vimeo\\.com/.*#' |
Public
| static | video(array|string $attr, string $content): ?string# | [video]. @param array<string, mixed>|string $attr
| |||
| static | audio(array|string $attr, string $content): ?string# | [audio]. @param array<string, mixed>|string $attr
| |||
| static | attached(string $type, mixed $post): array# | get_attached_media: the post's attachments of a kind ("video", "audio", a MIME type), as the reference's children query finds them. |
Internals 9
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | sources(array $atts, array $types, ?string $hosted, string $kind): array|string|null# | The sources a shortcode names: the order they print in, the first file, and the attachment when the post's own media stands in. A src of another kind answers as a link; nothing at all as null.
@return array{order: list<string>, file: string, attachment: ?\WP_Post, atts: array<string, mixed>}|string|null | ||||||
| private | anyOwnFormat(array $atts, array $types): bool# | Whether any format attribute names a file of its own kind. @param array<string, mixed> $atts @param list<string> $types
| ||||||
| private | sourceTags(array $atts, array $order, int $instance, ?string $hosted): string# | Each source as a source tag, numbered by the instance (src a hosted video's own type when it is one). @param array<string, mixed> $atts @param list<string> $order
| ||||||
| private | attributes(array $attributes, array $omitEmpty): string# | The attributes as written: the flags bare when on, the empty ones left out. @param array<string, mixed> $attributes @param list<string> $omitEmpty
| ||||||
| private | fitted(int $width, int $height): array# | A video no wider than the content: wider, it takes the content's width and keeps its proportion. @return array{0: int, 1: int} @return array{0: int, 1: int} | ||||||
| private | library(string $kind): string# | The player library (wp_*_shortcode_library), its scripts and styles queued when it is the reference's own. | ||||||
| private | fallback(string $file, string $library): string# | The link a player without the library falls back to (wp_mediaelement_fallback). | ||||||
| private | postId(): int# | |||||||
| private | instance(string $kind): int# | The shortcode's instance number this request, counted whether or not a plugin takes it over. |
Nothing matches.