[wp-trac] [WordPress Trac] #51792: When wp_prepare_attachment_for_js() is called too early, a fatal occurs "Call to undefined function get_media_states()"

WordPress Trac noreply at wordpress.org
Mon Nov 16 18:22:11 UTC 2020


#51792: When wp_prepare_attachment_for_js() is called too early, a fatal occurs
"Call to undefined function get_media_states()"
--------------------------+-----------------------------
 Reporter:  rebasaurus    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  trunk
 Severity:  major         |   Keywords:  needs-patch
  Focuses:                |
--------------------------+-----------------------------
 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:

 {{{#!php
 --- 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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51792>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list