Skip to content

Instantly share code, notes, and snippets.

View MattMcAdams's full-sized avatar
🏠
Working from home

Matthew McAdams MattMcAdams

🏠
Working from home
View GitHub Profile
@MattMcAdams
MattMcAdams / forms.css
Created August 21, 2023 15:16
Simple form validation styling
:invalid:not(:focus) {
color: red;
}
@MattMcAdams
MattMcAdams / tag-sort.css
Created March 4, 2022 03:21
Filter items by tag with JS
body { font-family: sans-serif; max-width: 1300px; margin: 5rem auto; padding: 0 1rem; }
h1, h2, h3, ul, p { margin: 0 0 1rem 0; }
[hidden] { display: none !important; }
.item-list {
margin: 2.5rem 0;
padding: 0;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(15em, 1fr));
grid-gap: 1rem;
@MattMcAdams
MattMcAdams / functions.php
Created March 19, 2021 15:47
Give WP editors access to edit menus and only menus
// Allow editors to see access the Menus page under Appearance but hide other options
function hide_menu() {
$user = wp_get_current_user();
// Check if the current user is an Editor
if ( in_array( 'editor', (array) $user->roles ) ) {
// They're an editor, so grant the edit_theme_options capability if they don't have it
if ( ! current_user_can( 'edit_theme_options' ) ) {
$role_object = get_role( 'editor' );
@MattMcAdams
MattMcAdams / form.html
Created January 28, 2021 21:30
Redirect based on form selection
<form id="myForm">
<select id="select">
<option value="pageSlug1">Page Title 1</option>
<option value="pageSlug2">Page Title 2</option>
<option value="pageSlug3">Page Title 3</option>
</select>
<button onclick="selectRedirect()">Submit</button>
</form>
@MattMcAdams
MattMcAdams / rickroll.txt
Created September 2, 2020 20:16
Rick Roll obvious hackers
Route::redirect('.env', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ')
Route::redirect('wp-login.php', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ')
Route::redirect('wp-admin', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ')
@MattMcAdams
MattMcAdams / link-styles.css
Created September 2, 2020 20:03
Correct order for link pseudo styles
@MattMcAdams
MattMcAdams / grid-center.css
Created September 2, 2020 20:00
Center content with Grid
.parent {
display: grid;
place-items: center;
}
@MattMcAdams
MattMcAdams / from-animation.css
Created September 2, 2020 19:49
CSS Animations with from
@keyframes slide-in-from-left {
from {
transfrom: translateX(-100%);
}
}
.class {
animation: slide-in-from-left .25s ease-in-out;
}
@MattMcAdams
MattMcAdams / html-lint.css
Created September 2, 2020 19:43
Lint your HTML with CSS
/* Headers out of order (i.e. h2 before h1, etc.) */
h2 ~ h1,
h3 ~ h1,
h4 ~ h1,
h5 ~ h1,
h6 ~ h1,
h3 ~ h2:first-of-type,
h4 ~ h2:first-of-type,
h5 ~ h2:first-of-type,
h6 ~ h2:first-of-type,
@MattMcAdams
MattMcAdams / flow-spacing.css
Created September 2, 2020 19:20
Consistant margins inside a container
flow > * + * {
margin-top: var(--flow-space, 1em);
}