Skip to content

Instantly share code, notes, and snippets.

View mrwweb's full-sized avatar

Mark Root-Wiley mrwweb

View GitHub Profile
@mrwweb
mrwweb / reset-rems
Created May 22, 2013 13:22
"Sanity-ize" REMs by setting them to 10px-baseline aka "Tiny Happy Pixels Dancing."
/* this is the "root" in "root em." */
html {
font-size: 62.5%; /* Now 10px = 1rem! */
}
body {
font-size: 16px; /* px fallback */
font-size: 1.6rem; /* default font-size for document */
line-height: 1.5; /* a nice line-height */
}
@mrwweb
mrwweb / useful-console-snippets.js
Created April 4, 2025 22:32
Useful Console Snippets
// Get list of text in items for copy-pasting (where each item is in class ".thing")
console.log(Array.from(document.querySelectorAll('.thing')).map(t=>t.innerText).join("\n"));
// Get multiple strings into a table from a single element
console.table(Array.from(document.querySelectorAll('.thing')).map(t=>[p.getAttribute('title'),p.textContent]));
@mrwweb
mrwweb / tribe_get_events.php
Last active November 13, 2024 16:44
Get Upcoming Events with tribe_get_events()
<?php $proj_events = tribe_get_events( array(
'posts_per_page' => 3,
'eventDisplay' => 'list' // only upcoming
), true ); ?>
<?php if( $proj_events->have_posts() ) :
?>
<div class="project-related__block project-related__block--events">
<h3>Events</h3>
<ul class="bulletless-list">
<?php while( $proj_events->have_posts() ) : $proj_events->the_post(); ?>
@mrwweb
mrwweb / acf-accessibility.js
Created October 8, 2024 17:35
Advanced Custom Fields Front-end Form Accessibility Fixes
/**
* Accessibility fixes for frontend Advanced Custom Fields forms
* v1.0.0
* Mark Root-Wiley, MRW Web Design (https://MRWweb.com)
*
* Fixes 3 issues:
*
* 1. Replace required asterisk with spelled-out label
* 2. Explicitly associate checkbox labels with their inputs using a for and id attribute
* 3. Use fieldset and legend to wrap checkbox and group fields
@mrwweb
mrwweb / readme.md
Last active September 27, 2024 22:29
The Events Calendar v2 Template Reset & Customizations - Now on Github
@mrwweb
mrwweb / convert_milliseconds_to_formatted_time.php
Created September 21, 2024 00:21 — forked from bcls/convert_milliseconds_to_formatted_time.php
convert milliseconds to formatted time #php
/**
* Converts milliseconds to formatted time or seconds.
* @param int [$ms] The length of the media asset in milliseconds
* @param bool [$seconds] Whether to return only seconds
* @return mixed The formatted length or total seconds of the media asset
*/
function convertTime($ms, $seconds = false)
{
$total_seconds = ($ms / 1000);
@mrwweb
mrwweb / functions.php
Created June 24, 2020 16:34
Show Hidden Products as Cross-Sells in WooCommerce Cart.
<?php
add_filter( 'woocommerce_product_is_visible', 'prefix_show_hidden_product_crosssells', 10, 2 );
function prefix_show_hidden_product_crosssells( $is_visible, $id ) {
if( is_cart() ) {
$is_visible = true;
}
return $is_visible;
}
@mrwweb
mrwweb / mu-plugin.php
Created September 29, 2023 18:24
Set Default State/Country in Community Events plugin from The Events Calendar
<?php
/**
* The Community Events plugin offers a "Single Geography" mode but no way
* to specify the default State and Country to use for venues created when
* it's enabled.
*
* Note: Events Calendar PRO allows specifying a default State and Country
* but that shouldn't be required to use Community Events!
*/
namespace SiteName\CommunityEvents;
@mrwweb
mrwweb / replace-helvetica.css
Created May 3, 2023 19:56
CSS to Replace with Segoe UI on Windows - Use a custom CSS add-on in your browser to apply these styles to ALL websites
@font-face { font-family: 'helvetica neue'; src: local('Segoe UI'); }
@font-face { font-family: 'helvetica neue'; font-weight:bold; src: local('Segoe UI Bold'); }
@font-face { font-family: 'helvetica neue'; font-weight:bold; src: local('Segoe UI Bold'); }
@font-face { font-family: 'helvetica neue'; font-style: italic; src: local('Segoe UI Italic'); }
@font-face { font-family: 'helvetica neue'; font-style: italic; font-weight:bold; src: local('Segoe UI Bold Italic'); }
@font-face { font-family: 'helvetica'; src: local('Segoe UI'); }
@font-face { font-family: 'helvetica'; font-weight:bold; src: local('Segoe UI Bold'); }
@font-face { font-family: 'helvetica'; font-style: italic; src: local('Segoe UI Italic'); }
@font-face { font-family: 'helvetica'; font-style: italic; font-weight:bold; src: local('Segoe UI Bold Italic'); }
@font-face { font-family: 'HelveticaNeue-Light'; src: local('Segoe UI Light'); }
@mrwweb
mrwweb / functions.php
Last active March 18, 2023 04:58
Example Child Theme Files
<?php
/*
Important!
Make sure to replace {my_} with your theme's unique prefix.
All future functions you write should use that same prefix.
Example: mrwnten_parent_theme_enqueue_styles()
*/
add_action( 'wp_enqueue_scripts', '{my_}parent_theme_enqueue_styles' );