const cookieBlock = document.querySelector('#cookie-notice'); if ( ( cookieBlock ) ) { matches = cookieBlock.matches ? cookieBlock.matches('#cookie-notice') : cookieBlock.msMatchesSelector('#cookie-notice'); if ( matches === true ) { const bodyWrapper = document.querySelector( 'body' ); const headerContent = document.querySelector( '.nhsuk-header' ); bodyWrapper.insertBefore( cookieBlock, headerContent ); } } "; echo $scriptout; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** * Now run the function in the footer. * needs weighting of 1003 to load AFTER the cookie element has been placed in footer. */ add_action( 'wp_footer', 'nightingale_cookie_footer', 1003 );