API / Minn\Media / MediaModal

MediaModal final class

Minn\Media\MediaModal · public/minn/src/Minn/Media/MediaModal.php · 219 lines

WordPress's media modal, set up for a page that opens it (wp_enqueue_media): a page builder's editor picks and uploads images through it. Its scripts, styles, words and templates are WordPress's and come with the Minn Legacy Pack. The engine queues them and tells them about the site, as the reference does and through the same filters: the post being edited, the file types and the months the library holds, the nonces, the upload settings, and the templates printed in the footer. Without the pack's scripts there is no modal to set up and nothing happens.

Public

staticenqueue(array $args, Minn\Runtime\Assets $scripts, Minn\Runtime\Assets $styles): void#

Queues the modal for the page, once a request.

$argsarray<string, mixed>'post': the post being edited, an ID or a post object
staticuploadSettings(Minn\Runtime\Assets $scripts): void#

The upload settings the modal's uploader reads (wp_plupload_default_settings): where files go, how large, which types, with which nonce, added to the data the uploader's script already carries.

Internals 9

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatepostId(mixed $post): int#
privatetabs(): array#

The upload tabs plugins add; WordPress's own four are the modal's views, not tabs. @return array<string, string>

@return array<string, string>
privatemimeTypes(): array#

The library's file-type filter: each kind's label, by its MIME pattern (get_post_mime_types). @return array<string, string>

@return array<string, string>
privateshows(mixed $answer, string $kind): bool#

Whether the library offers audio or video playlists: a plugin's answer, or whether it holds any such file.

privatemonths(): array#

The months the library has files from, newest first, as the modal's date filter lists them. @return list<array{year: string, month: string, text: string}>

@return list<array{year: string, month: string, text: string}>
privateembeds(): array#

The audio and video extensions the modal embeds, and the MIME type of each. @return array{list<string>, array<string, string>}

@return array{list<string>, array<string, string>}
privatemaxUploadSize(): int#

The largest upload the server takes, the smaller of PHP's two limits, as plugins leave it (upload_size_limit).

privatebytes(string $value): int#
privatecanUpload(): bool#

Whether the browser can upload: every desktop, and iOS from 6.