Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Root-Wiley mrwweb

View GitHub Profile
@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.
View vs-block-variation.css
.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/.
View fixDiviToggleA11y.php
<?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
View button.php
<?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
View faux-block-editor.css
/**
* 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?
View bookmarklet-source.js
( 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 January 20, 2023 16:19
The Events Calendar v2 Template Reset & Customizations
View readme.md

The Events Calendar v2 Template Reset & Customizations

Version 1.5

Introduction

The Events Calendar is a very powerful WordPress plugin for managing events. However, the way its templates and CSS are implemented—especially in "v2"—leave much to be desired.

This contains all the changes I make on a project for The Events Calendar. Hopefully it's useful. If it saves you an hour, maybe you can buy me a cup of coffee or a beer 🍻

@mrwweb
mrwweb / nested-block-alignments.css
Created January 6, 2021 01:18
WordPress Block Alignment Classes with Support for Nested Group Blocks
View nested-block-alignments.css
.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;
}
@mrwweb
mrwweb / block-editor-styles.scss
Created July 9, 2020 01:39
Create a WordPress block editor style variation for the cover block to turn it into a knockout effect. Screenshot: https://cloudup.com/cGrfbjVS8q5
View block-editor-styles.scss
// we load the other CSS styles into the block editor and then override some of them here
// at present, the color overlay is not knocked out in the block editor
.is-style-knockout-text {
.wp-block-cover__inner-container {
z-index: 1;
}
.wp-block > * {
font-size: 160px !important;
font-weight: 900 !important;
color: transparent !important;
@mrwweb
mrwweb / functions.php
Created June 24, 2020 16:34
Show Hidden Products as Cross-Sells in WooCommerce Cart.
View functions.php
<?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 / mrw-tribe-button-in-event-list.php
Created October 28, 2019 20:51
Show Event Website block in Event List for The Events Calendar
View mrw-tribe-button-in-event-list.php
<?php
/**
* Find, parse, and return the Website Button for Tribe's The Events Calendar events
*/
function mrw_get_tribe_website_button( $post_id = false ) {
if( ! $post_id ) {
$post_id = get_the_ID();
}
$post_content = get_post_field( 'post_content', $post_id );