Skip to content

Commit 41d4d90

Browse files
committed
Mu-plugins: Add margin to fixed navigation on sites with the latest event banner
1 parent 059cfc3 commit 41d4d90

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
@@ -66,7 +66,8 @@ function canonical_link_past_home_pages_to_current_year() {
6666
*/
6767
function add_notification_styles() { ?>
6868
<style type="text/css">
69-
html:not(#specificity-hack) {
69+
html:not(#specificity-hack),
70+
.wordcamp-latest-site-notify-fixed-position-fix {
7071
/* 44 = 10px x2 for padding, 24px for line height. */
7172
margin-top: calc(44px + var(--wp-admin--admin-bar--height, 0px)) !important;
7273
}
@@ -105,6 +106,23 @@ function add_notification_styles() { ?>
105106
color: #72aee6;
106107
}
107108
</style>
109+
<script>
110+
document.addEventListener("DOMContentLoaded", (event) => {
111+
const fixedElements = document.querySelectorAll('nav, nav *'); // Select all elements
112+
const fixedElementsArray = Array.from(fixedElements);
113+
114+
const fixedElementsWithPositionFixed = fixedElementsArray.filter(element => {
115+
const computedStyle = getComputedStyle(element);
116+
return computedStyle.position === 'fixed';
117+
});
118+
119+
console.log(fixedElementsWithPositionFixed);
120+
121+
fixedElementsWithPositionFixed.forEach(element => {
122+
element.classList.add('wordcamp-latest-site-notify-fixed-position-fix')
123+
});
124+
});
125+
</script>
108126
<?php }
109127

110128
/**

0 commit comments

Comments
 (0)