WordPress.org

Make WordPress Core

Opened 13 months ago

Last modified 13 months ago

#51791 closed defect (bug)

When wp_prepare_attachment_for_js() is called too early, a fatal occurs "Call to undefined function get_media_states()" — at Initial Version

Reported by: rebasaurus Owned by:
Milestone: 5.6 Priority: normal
Severity: major Version: 5.6
Component: Media Keywords: has-patch commit
Focuses: Cc:

Description

When we call wp_prepare_attachment_for_js() too early, we see the fatal:

Call to undefined function get_media_states()

Introduced in https://core.trac.wordpress.org/changeset/49223 from #42063.

To test in twentytwenty:

--- a/themes/twentytwenty/header.php
+++ b/themes/twentytwenty/header.php
@@ -26,6 +26,7 @@

        <body <?php body_class(); ?>>

+               <?php var_dump( wp_prepare_attachment_for_js( '28' ) ); ?>
                <?php
                wp_body_open();
                ?>

You will see it fatal.

Change History (0)

Note: See TracTickets for help on using tickets.