Skip to content

Commit 847b4f0

Browse files
2ndkauboyoutdoor2kode
authored andcommitted
Mu-plugins: Add margin to fixed navigation on sites with the latest event banner
1 parent e13fb5e commit 847b4f0

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

public_html/wp-content/mu-plugins/latest-site-hints.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ function canonical_link_past_home_pages_to_current_year() {
7171
*/
7272
function add_notification_styles() { ?>
7373
<style type="text/css">
74-
html:not(#specificity-hack) {
74+
html:not(#specificity-hack),
75+
.wordcamp-latest-site-notify-fixed-position-fix {
7576
/* 44 = 10px x2 for padding, 24px for line height. */
7677
margin-top: calc(44px + var(--wp-admin--admin-bar--height, 0px)) !important;
7778
}
@@ -110,6 +111,23 @@ function add_notification_styles() { ?>
110111
color: #72aee6;
111112
}
112113
</style>
114+
<script>
115+
document.addEventListener("DOMContentLoaded", (event) => {
116+
const fixedElements = document.querySelectorAll('nav, nav *'); // Select all elements
117+
const fixedElementsArray = Array.from(fixedElements);
118+
119+
const fixedElementsWithPositionFixed = fixedElementsArray.filter(element => {
120+
const computedStyle = getComputedStyle(element);
121+
return computedStyle.position === 'fixed';
122+
});
123+
124+
console.log(fixedElementsWithPositionFixed);
125+
126+
fixedElementsWithPositionFixed.forEach(element => {
127+
element.classList.add('wordcamp-latest-site-notify-fixed-position-fix')
128+
});
129+
});
130+
</script>
113131
<?php }
114132

115133
/**

0 commit comments

Comments
 (0)