get_method_proxy( 'setup_gtag' ), 20 ); add_filter( 'script_loader_tag', $this->get_method_proxy( 'filter_tag_output' ), 10, 2 ); $this->do_init_tag_action(); } /** * Outputs gtag snippet. * * @since 1.124.0 */ protected function render() { // Do nothing, gtag script is enqueued. } /** * Configures gtag script. * * @since 1.124.0 * * @param GTag $gtag GTag instance. */ protected function setup_gtag( $gtag ) { $gtag->add_tag( $this->tag_id ); } /** * Filters output of tag HTML. * * @param string $tag Tag HTML. * @param string $handle WP script handle of given tag. * @return string */ protected function filter_tag_output( $tag, $handle ) { // The tag will either have its own handle or use the common GTag handle, not both. if ( GTag::get_handle_for_tag( $this->tag_id ) !== $handle && GTag::HANDLE !== $handle ) { return $tag; } // Retain this comment for detection of Site Kit placed tag. $snippet_comment = sprintf( "\n", esc_html__( 'Google Ads snippet added by Site Kit', 'google-site-kit' ) ); return $snippet_comment . $tag; } }