Skip to content

Commit

Permalink
Restore the $position parameter in case we need it.
Browse files Browse the repository at this point in the history
  • Loading branch information
techanvil committed Feb 20, 2024
1 parent f7b11c4 commit c593141
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions includes/Core/Tags/GTag.php
Expand Up @@ -36,10 +36,11 @@ public function add_tag( $tag_id, $config = array() ) {
);
}

public function add_command( $command, $parameters ) {
public function add_command( $command, $parameters, $position = 'after' ) {
$this->commands[] = array(
'command' => $command, // e.g. 'config', 'event', etc.
'parameters' => $parameters, // e.g. array( 'send_to', 'AW-123456789' )
'command' => $command, // e.g. 'config', 'event', etc.
'parameters' => $parameters, // e.g. array( 'send_to', 'AW-123456789' )
'position' => $position, // e.g. 'after', 'before'. This determines the position of the inline script relative to the gtag.js script.
);
}

Expand Down Expand Up @@ -69,7 +70,7 @@ protected function enqueue_gtag_script() {
}

foreach ( $this->commands as $command ) {
wp_add_inline_script( self::HANDLE, $this->get_gtag_call_for_command( $command ) );
wp_add_inline_script( self::HANDLE, $this->get_gtag_call_for_command( $command ), $command['position'] );
}

$filter_google_gtagjs = function ( $tag, $handle ) {
Expand Down

0 comments on commit c593141

Please sign in to comment.