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 authored and renintw committed May 20, 2024
1 parent e13fb5e commit 847b4f0
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 @@ -71,7 +71,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 @@ -110,6 +111,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 847b4f0

Please sign in to comment.