Skip to content

Commit

Permalink
Merge pull request #5 from Spcktr/refactor
Browse files Browse the repository at this point in the history
Refactor: Removed duplicate anchor requests

Removed duplicate variables that fetched anchor elements. Resolved them to use elts for querySelectorAll variable.
  • Loading branch information
Spcktr committed Oct 13, 2023
2 parents 90c495b + 3d692e8 commit baa6413
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions divi-button-event-tagger.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Plugin Name: Divi Button Event Tagger
* Plugin URI: https://github.com/Spcktr/divi-button-event-tagger
* Description: Insert missing data-vars-ga attributes for button links. This will help Google Analytics tracking buttons for themes like Divi.
* Version: 1.1.1
* Version: 1.1.2
* Author: Tim H.
* Author URI: https://github.com/spcktr
* License: GNU General Public License v3
Expand All @@ -25,7 +25,7 @@
}

define('DIVI_BUTTON_EVENT_TAGGER_PLUGIN_NAME', 'divi-button-event-tagger');
define('DIVI_BUTTON_EVENT_TAGGER_PLUGIN_VERSION', '1.1.1');
define('DIVI_BUTTON_EVENT_TAGGER_PLUGIN_VERSION', '1.1.2');
define('BUTTON_EVENT_SELECTOR', '.et_pb_button'); // Default for Divi.

/**
Expand Down
10 changes: 4 additions & 6 deletions public/js/divi-button-event-tagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ function addDivibuttonevents() {
}
});
// removes rel='nofollow' from buttons for SEO
const anchors = document.querySelectorAll('.et_pb_button');

anchors.forEach(anchor => {
if (anchor.hasAttribute('rel')) {
const relAttribute = anchor.getAttribute('rel');
elts.forEach(elt => {
if (elt.hasAttribute('rel')) {
const relAttribute = elt.getAttribute('rel');

if (relAttribute.includes('nofollow')) {
anchor.removeAttribute('rel');
elt.removeAttribute('rel');
}
}
});
Expand Down

0 comments on commit baa6413

Please sign in to comment.