Skip to content

Commit

Permalink
Mu-plugins: Add margin to fixed navigation on sites with the latest e…
Browse files Browse the repository at this point in the history
…vent banner
  • Loading branch information
2ndkauboy committed Oct 19, 2023
1 parent 059cfc3 commit 41d4d90
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion public_html/wp-content/mu-plugins/latest-site-hints.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ function canonical_link_past_home_pages_to_current_year() {
*/
function add_notification_styles() { ?>
<style type="text/css">
html:not(#specificity-hack) {
html:not(#specificity-hack),
.wordcamp-latest-site-notify-fixed-position-fix {
/* 44 = 10px x2 for padding, 24px for line height. */
margin-top: calc(44px + var(--wp-admin--admin-bar--height, 0px)) !important;
}
Expand Down Expand Up @@ -105,6 +106,23 @@ function add_notification_styles() { ?>
color: #72aee6;
}
</style>
<script>
document.addEventListener("DOMContentLoaded", (event) => {
const fixedElements = document.querySelectorAll('nav, nav *'); // Select all elements
const fixedElementsArray = Array.from(fixedElements);

const fixedElementsWithPositionFixed = fixedElementsArray.filter(element => {
const computedStyle = getComputedStyle(element);
return computedStyle.position === 'fixed';
});

console.log(fixedElementsWithPositionFixed);

fixedElementsWithPositionFixed.forEach(element => {
element.classList.add('wordcamp-latest-site-notify-fixed-position-fix')
});
});
</script>
<?php }

/**
Expand Down

0 comments on commit 41d4d90

Please sign in to comment.