Skip to content
Snippets Groups Projects
Commit 72562a5b authored by Michael Lee's avatar Michael Lee
Browse files

Merge branch 'google_tag' into lee5151

parents 3a44dcfc b0bf7355
No related branches found
No related tags found
No related merge requests found
Showing
with 68 additions and 61 deletions
...@@ -4305,26 +4305,26 @@ ...@@ -4305,26 +4305,26 @@
}, },
{ {
"name": "drupal/google_tag", "name": "drupal/google_tag",
"version": "1.5.0", "version": "1.6.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://git.drupalcode.org/project/google_tag.git", "url": "https://git.drupalcode.org/project/google_tag.git",
"reference": "8.x-1.5" "reference": "8.x-1.6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://ftp.drupal.org/files/projects/google_tag-8.x-1.5.zip", "url": "https://ftp.drupal.org/files/projects/google_tag-8.x-1.6.zip",
"reference": "8.x-1.5", "reference": "8.x-1.6",
"shasum": "b2929a517cc86bb3e54dded127556f18236a8628" "shasum": "d084315e54c2e561b8b64eef86081c2634d054cd"
}, },
"require": { "require": {
"drupal/core": "^8.8 || ^9" "drupal/core": "^8.8 || ^9 || ^10"
}, },
"type": "drupal-module", "type": "drupal-module",
"extra": { "extra": {
"drupal": { "drupal": {
"version": "8.x-1.5", "version": "8.x-1.6",
"datestamp": "1648569365", "datestamp": "1671145853",
"security-coverage": { "security-coverage": {
"status": "covered", "status": "covered",
"message": "Covered by Drupal's security advisory policy" "message": "Covered by Drupal's security advisory policy"
......
...@@ -4455,27 +4455,27 @@ ...@@ -4455,27 +4455,27 @@
}, },
{ {
"name": "drupal/google_tag", "name": "drupal/google_tag",
"version": "1.5.0", "version": "1.6.0",
"version_normalized": "1.5.0.0", "version_normalized": "1.6.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://git.drupalcode.org/project/google_tag.git", "url": "https://git.drupalcode.org/project/google_tag.git",
"reference": "8.x-1.5" "reference": "8.x-1.6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://ftp.drupal.org/files/projects/google_tag-8.x-1.5.zip", "url": "https://ftp.drupal.org/files/projects/google_tag-8.x-1.6.zip",
"reference": "8.x-1.5", "reference": "8.x-1.6",
"shasum": "b2929a517cc86bb3e54dded127556f18236a8628" "shasum": "d084315e54c2e561b8b64eef86081c2634d054cd"
}, },
"require": { "require": {
"drupal/core": "^8.8 || ^9" "drupal/core": "^8.8 || ^9 || ^10"
}, },
"type": "drupal-module", "type": "drupal-module",
"extra": { "extra": {
"drupal": { "drupal": {
"version": "8.x-1.5", "version": "8.x-1.6",
"datestamp": "1648569365", "datestamp": "1671145853",
"security-coverage": { "security-coverage": {
"status": "covered", "status": "covered",
"message": "Covered by Drupal's security advisory policy" "message": "Covered by Drupal's security advisory policy"
...@@ -4488,6 +4488,22 @@ ...@@ -4488,6 +4488,22 @@
"GPL-2.0-or-later" "GPL-2.0-or-later"
], ],
"authors": [ "authors": [
{
"name": "acquia",
"homepage": "https://www.drupal.org/user/1231722"
},
{
"name": "japerry",
"homepage": "https://www.drupal.org/user/45640"
},
{
"name": "kaynen",
"homepage": "https://www.drupal.org/user/733308"
},
{
"name": "mglaman",
"homepage": "https://www.drupal.org/user/2416470"
},
{ {
"name": "solotandem", "name": "solotandem",
"homepage": "https://www.drupal.org/user/240748" "homepage": "https://www.drupal.org/user/240748"
......
...@@ -779,9 +779,9 @@ ...@@ -779,9 +779,9 @@
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'drupal/google_tag' => array( 'drupal/google_tag' => array(
'pretty_version' => '1.5.0', 'pretty_version' => '1.6.0',
'version' => '1.5.0.0', 'version' => '1.6.0.0',
'reference' => '8.x-1.5', 'reference' => '8.x-1.6',
'type' => 'drupal-module', 'type' => 'drupal-module',
'install_path' => __DIR__ . '/../../web/modules/google_tag', 'install_path' => __DIR__ . '/../../web/modules/google_tag',
'aliases' => array(), 'aliases' => array(),
......
...@@ -95,6 +95,11 @@ code on the script tag. It does not load the snippet file and inspect the code ...@@ -95,6 +95,11 @@ code on the script tag. It does not load the snippet file and inspect the code
therein. Instead of relying on this bot, check whether the GTM snippets are therein. Instead of relying on this bot, check whether the GTM snippets are
loaded as a result of the snippet added by this project. loaded as a result of the snippet added by this project.
If you run Drush as other than the web user, then do not enable the 'Recreate
snippets on cache rebuild' module setting. Otherwise snippet files will be
created and owned by the user running Drush. On the next cache rebuild the web
user may not be able to delete the files (resulting in a fatal error).
## MAINTAINERS ## MAINTAINERS
Current maintainer: Current maintainer:
......
...@@ -2,8 +2,5 @@ ...@@ -2,8 +2,5 @@
"name": "drupal/google_tag", "name": "drupal/google_tag",
"description": "Allows your website analytics to be managed using Google Tag Manager.", "description": "Allows your website analytics to be managed using Google Tag Manager.",
"type": "drupal-module", "type": "drupal-module",
"license": "GPL-2.0-or-later", "license": "GPL-2.0-or-later"
"require": {
"drupal/core": "^8.8 || ^9"
}
} }
uri: 'public:/' uri: 'public:/'
compact_snippet: true compact_snippet: true
include_file: true include_file: true
rebuild_snippets: true rebuild_snippets: false
flush_snippets: false flush_snippets: false
debug_output: false debug_output: false
_default_container: _default_container:
container_id: '' container_id: ''
path_toggle: 'exclude listed' path_toggle: 'exclude listed'
path_list: "/admin*\n/batch*\n/node/add*\n/node/*/edit\n/node/*/delete\n/user/*/edit*\n/user/*/cancel*" path_list: "/admin*\n/batch*\n/node/add*\n/node/*/edit\n/node/*/delete\n/node/*/layout\n/taxonomy/term/*/edit\n/taxonomy/term/*/layout\n/user/*/edit*\n/user/*/cancel*\n/user/*/layout"
role_toggle: 'exclude listed' role_toggle: 'exclude listed'
role_list: {} role_list: {}
status_toggle: 'exclude listed' status_toggle: 'exclude listed'
......
...@@ -2,10 +2,10 @@ name: 'Google Tag Manager' ...@@ -2,10 +2,10 @@ name: 'Google Tag Manager'
type: module type: module
description: 'Allows your website analytics to be managed using Google Tag Manager.' description: 'Allows your website analytics to be managed using Google Tag Manager.'
package: 'Statistics' package: 'Statistics'
core_version_requirement: ^8.8 || ^9 core_version_requirement: ^8.8 || ^9 || ^10
configure: google_tag.settings_form configure: google_tag.settings_form
# Information added by Drupal.org packaging script on 2022-03-29 # Information added by Drupal.org packaging script on 2022-12-15
version: '8.x-1.5' version: '8.x-1.6'
project: 'google_tag' project: 'google_tag'
datestamp: 1648569368 datestamp: 1671145855
...@@ -22,28 +22,18 @@ ...@@ -22,28 +22,18 @@
var str = ''; var str = '';
var toggle = $('input[type="radio"]:checked', context).val(); var toggle = $('input[type="radio"]:checked', context).val();
var values; var values;
if (element == 'checkbox') {
values = $('input[type="checkbox"]:checked + label', context).length; values = element === 'checkbox' ?
} $('input[type="checkbox"]:checked + label', context).length :
else { $('textarea', context).val();
var values = $('textarea', context).val();
} if (toggle === 'exclude listed') {
if (toggle == 'exclude listed') { str = !values ? 'All !plural' : 'All !plural except !adjective !plural';
if (!values) {
str = 'All !plural';
}
else {
str = 'All !plural except !adjective !plural';
}
} }
else { else {
if (!values) { str = !values ? 'No !plural' : 'Only !adjective !plural';
str = 'No !plural';
}
else {
str = 'Only !adjective !plural';
}
} }
const args = {'!plural': plural, '!adjective': adjective}; const args = {'!plural': plural, '!adjective': adjective};
return Drupal.t(Drupal.formatString(str, args)); return Drupal.t(Drupal.formatString(str, args));
} }
......
...@@ -244,7 +244,7 @@ public function snippets() { ...@@ -244,7 +244,7 @@ public function snippets() {
'data_layer' => $this->dataLayerSnippet(), 'data_layer' => $this->dataLayerSnippet(),
]; ];
// Allow other modules to alter the snippets. // Allow other modules to alter the snippets.
\Drupal::moduleHandler()->alter('google_tag_snippets', $snippets, $this); $this->moduleHandler()->alter('google_tag_snippets', $snippets, $this);
return $snippets; return $snippets;
} }
...@@ -289,7 +289,7 @@ protected function noscriptSnippet() { ...@@ -289,7 +289,7 @@ protected function noscriptSnippet() {
// Build noscript snippet. // Build noscript snippet.
$noscript = <<<EOS $noscript = <<<EOS
<noscript aria-hidden="true"><iframe src="https://www.googletagmanager.com/ns.html?id=$container_id$query" <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=$container_id$query"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
EOS; EOS;
return $this->compactSnippet($noscript, ["\n"]); return $this->compactSnippet($noscript, ["\n"]);
...@@ -407,7 +407,7 @@ public function insertSnippet() { ...@@ -407,7 +407,7 @@ public function insertSnippet() {
} }
// Allow other modules to alter the insertion criteria. // Allow other modules to alter the insertion criteria.
\Drupal::moduleHandler()->alter('google_tag_insert', $satisfied[$this->id], $this); $this->moduleHandler()->alter('google_tag_insert', $satisfied[$this->id], $this);
$this->displayMessage('after alter @satisfied', ['@satisfied' => $satisfied[$this->id]]); $this->displayMessage('after alter @satisfied', ['@satisfied' => $satisfied[$this->id]]);
} }
return $satisfied[$this->id]; return $satisfied[$this->id];
...@@ -557,8 +557,7 @@ public function fileTag($type, $weight) { ...@@ -557,8 +557,7 @@ public function fileTag($type, $weight) {
$uri = $this->snippetURI($type); $uri = $this->snippetURI($type);
// Remove the if-else when core_version_requirement >= 9.3 for this module. // Remove the if-else when core_version_requirement >= 9.3 for this module.
if (\Drupal::hasService('file_url_generator')) { if (\Drupal::hasService('file_url_generator')) {
$generator = \Drupal::service('file_url_generator'); $url = \Drupal::service('file_url_generator')->generateString($uri);
$url = $generator->transformRelative($generator->generateAbsoluteString($uri));
} }
else { else {
$url = file_url_transform_relative(file_create_url($uri)); $url = file_url_transform_relative(file_create_url($uri));
......
...@@ -110,7 +110,7 @@ public function moduleFieldset(FormStateInterface $form_state) { ...@@ -110,7 +110,7 @@ public function moduleFieldset(FormStateInterface $form_state) {
$fieldset['rebuild_snippets'] = [ $fieldset['rebuild_snippets'] = [
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => $this->t('Recreate snippets on cache rebuild'), '#title' => $this->t('Recreate snippets on cache rebuild'),
'#description' => $this->t('If checked, then the JavaScript snippet files will be created during a cache rebuild. This is <strong>recommended on production sites</strong>. If not checked, any missing snippet files will be created during a page response.'), '#description' => $this->t('If checked, then the JavaScript snippet files will be created during a cache rebuild. If not checked, any missing snippet files will be created during a page response. NOTE: If Drush commands are run as a user other than the web user, then do NOT enable this setting unless the web user has permission to delete files created by the Drush user.'),
'#default_value' => $config->get('rebuild_snippets'), '#default_value' => $config->get('rebuild_snippets'),
]; ];
......
...@@ -87,7 +87,7 @@ public function summary() { ...@@ -87,7 +87,7 @@ public function summary() {
$languages = $this->languageManager->getLanguages(LanguageInterface::STATE_ALL); $languages = $this->languageManager->getLanguages(LanguageInterface::STATE_ALL);
$selected = $this->configuration['language_list']; $selected = $this->configuration['language_list'];
// Reduce the language object list to a language name list. // Reduce the language object list to a language name list.
$this->values = array_reduce($languages, function (&$names, $language) use ($selected) { $this->values = array_reduce($languages, function ($names, $language) use ($selected) {
if (!empty($selected[$language->getId()])) { if (!empty($selected[$language->getId()])) {
$names[$language->getId()] = $language->getName(); $names[$language->getId()] = $language->getName();
} }
......
...@@ -84,8 +84,7 @@ protected function checkPageResponseFile() { ...@@ -84,8 +84,7 @@ protected function checkPageResponseFile() {
$uri = "$this->basePath/google_tag/{$key}/google_tag.$type.js"; $uri = "$this->basePath/google_tag/{$key}/google_tag.$type.js";
// Remove the if-else when core_version_requirement >= 9.3 for this module. // Remove the if-else when core_version_requirement >= 9.3 for this module.
if (\Drupal::hasService('file_url_generator')) { if (\Drupal::hasService('file_url_generator')) {
$generator = \Drupal::service('file_url_generator'); $url = \Drupal::service('file_url_generator')->generateString($uri);
$url = $generator->transformRelative($generator->generateAbsoluteString($uri));
} }
else { else {
$url = file_url_transform_relative(file_create_url($uri)); $url = file_url_transform_relative(file_create_url($uri));
......
...@@ -62,7 +62,7 @@ abstract class GTMTestBase extends BrowserTestBase { ...@@ -62,7 +62,7 @@ abstract class GTMTestBase extends BrowserTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function setUp() { protected function setUp(): void {
$this->defaultTheme = 'stark'; $this->defaultTheme = 'stark';
parent::setUp(); parent::setUp();
$this->basePath = $this->config('google_tag.settings')->get('uri'); $this->basePath = $this->config('google_tag.settings')->get('uri');
...@@ -190,7 +190,8 @@ protected function deleteContainers() { ...@@ -190,7 +190,8 @@ protected function deleteContainers() {
// Confirm no snippet files. // Confirm no snippet files.
$message = 'No snippet files found after delete'; $message = 'No snippet files found after delete';
parent::assertDirectoryNotExists($directory . '/google_tag', $message); $method = method_exists($parent, $a = 'assertDirectoryDoesNotExist') ? $a : 'assertDirectoryNotExists';
parent::$method($directory . '/google_tag', $message);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment