* (wp_footer runs just before ), so position:fixed is always * relative to the viewport rather than whatever themed wrapper the block * happened to be placed inside. * * Also prints the tracking script directly here (rather than relying on the * block's viewScript auto-enqueue) because WordPress only auto-enqueues a * block's viewScript when that block's render callback returns non-empty * output — this block deliberately renders nothing in place (see * blocks/reading-progress-bar/render.php), so that auto-enqueue never fires. * By the time wp_footer runs we definitively know whether any bar was * placed on this page, which a wp_enqueue_scripts-time check couldn't. */ function awp_print_reading_progress_bars() { global $awp_reading_progress_bars; if ( empty( $awp_reading_progress_bars ) ) { return; } foreach ( $awp_reading_progress_bars as $settings ) { ?>
AWP_URL . 'blocks/reading-progress-bar/view.js', 'id' => 'advance-widget-pack-reading-progress-bar-view-script', ) ); } add_action( 'wp_footer', 'awp_print_reading_progress_bars' ); /** * Echoes an escaped