Skip to content

Instantly share code, notes, and snippets.

View mrwweb's full-sized avatar

Mark Root-Wiley mrwweb

View GitHub Profile
@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 / 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 / vs-block-variation.css
Created March 3, 2023 20:36
View Source Hello World Block Variation - A little rough around the edges. Tested successfully in the 2023 theme.
.wp-block-variation-hello-world {
display: flex;
background: #6fbcac;
padding: 0 !important;
}
.wp-block-variation-hello-world .wp-block-group__inner-container {
display: flex;
gap: 1em;
}
@mrwweb
mrwweb / fixDiviToggleA11y.php
Last active December 9, 2022 00:01
A small plugin that attempts to fix the accessibility of the Divi Toggle modle. Make sure to read the plugin description for important caveat about the Accordion module (don't use it). Hat tip to Mike Haydon for convincing me this was doable: https://www.intelliwolf.com/accessible-divi-accordion/.
<?php
/**
* Plugin Name: Fix Divi Toggle Module Accessibility
* Description: Uses JavaScript to insert button in toggle heading, remove tabindex from container, and correctly toggle aria-expanded on toggle button trigger. ⚠ WARNING: This only works for the Toggle module and *BREAKS* the Accordion module (really, it just breaks it more than it was already broken). Therefore, you are encouraged to entirely remove the Accordion module from the site (and the ability for anyone to use it) and only use Toggle modules.
* Author: Mark Root-Wiley, MRW Web Design
* Author URI: https://MRWweb.com
* Version: 1.2.1
*/
namespace MRW\DiviAccordionAria;
@mrwweb
mrwweb / button.php
Created August 26, 2022 15:11
Using get_template_part() for Componentized WordPress Themes
<?php
/**
* $args is available with all values passed in third parameter of get_template_part()
*
* In a real theme, this would go in something like parts/button.php or components/button.php
*
* Think carefully about which $args you assume will always be available and which you need to check for
*
* @link https://developer.wordpress.org/reference/functions/get_template_part/
*/
@mrwweb
mrwweb / faux-block-editor.css
Last active February 10, 2022 17:13
CSS to make the Classic Editor look more like the Block Editor
/**
* faux-block-editor.css v1.1
*
* Styles to make the Classic Editor screen appear more like the Block Editor
*
* Expects the class "faux-block-editor" on any screen that should use these styles
*/
.faux-block-editor {
overflow-x: hidden;
@mrwweb
mrwweb / bookmarklet-source.js
Created April 8, 2021 20:10
Copy/Paste-able Survey Monkey Answers - Paste the following into a bookmark's location setting and then run it on a single page of a Survey Monkey form. You'll then get a list of the questions and answers you can copy and paste. Currently works for radio, textarea, and text input fields. More to come?
( function() {
const questions = document.querySelectorAll( '.question-container' );
let result = '';
questions.forEach( ( q ) => {
let answerText = '';
let question = q.querySelector( '.question-title-container' ).innerText.replace( '* ', '' );
let answer = q.querySelector( 'label.checked' );
if ( null === answer ) {
answer = q.querySelector( 'textarea' );
}
@mrwweb
mrwweb / readme.md
Last active September 27, 2024 22:29
The Events Calendar v2 Template Reset & Customizations - Now on Github
@mrwweb
mrwweb / nested-block-alignments.css
Created January 6, 2021 01:18
WordPress Block Alignment Classes with Support for Nested Group Blocks
.block-container > *, /* [1] */
.wp-block-group__inner-container > * { /* [2] */
max-width: 46.25rem;
margin-left: 1.25rem;
margin-right: 1.25rem;
@media (min-width: 48.75em) { /* [3] */
margin-left: auto;
margin-right: auto;
}