Make WordPress Core

Ticket #41990: 41990.diff

File 41990.diff, 1.2 KB (added by Howdy_McGee, 2 years ago)
  • wp-includes/class-wp-scripts.php

     
    134134        private $type_attr = '';
    135135
    136136        /**
     137         * Holds an array of script handles whose extras still need to run.
     138         *
     139         * Any add_inline_script() 'after' scripts that were added during
     140         * runtime and missed the wp_print_scripts action. These will be
     141         * fired off in the footer at the end of the script process.
     142         *
     143         * @since 6.3.0
     144         * @var array
     145         */
     146        private $deferred_extras = array();
     147
     148        /**
    137149         * Constructor.
    138150         *
    139151         * @since 2.6.0
     
    433445
    434446                if ( 'after' !== $position ) {
    435447                        $position = 'before';
     448                } else if ( did_action( 'wp_print_scripts' ) ) {
     449                        $this->deferred_extras[ $handle ] = $position;
    436450                }
    437451
    438452                $script   = (array) $this->get_data( $handle, $position );
     
    686700         */
    687701        public function do_footer_items() {
    688702                $this->do_items( false, 1 );
     703
     704                foreach ( $this->deferred_extras as $handle => $position ) {
     705                        $this->print_inline_script( $handle, 'after', true );
     706                }
     707
    689708                return $this->done;
    690709        }
    691710