Skip to content

Instantly share code, notes, and snippets.

View mrwweb's full-sized avatar

Mark Root-Wiley mrwweb

View GitHub Profile
@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 / mrw-tribe-button-in-event-list.php
Created October 28, 2019 20:51
Show Event Website block in Event List for The Events Calendar
<?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 );
@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 / 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;
}
@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
// 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 / bar.php
Created September 25, 2014 22:37
"Disabliing AJAX" in Event Views (List, Month, etc.) in The Event Calendar by Modern Tribe
<?php
/**
* Events Navigation Bar Module Template
* Renders our events navigation bar used across our views
*
* Override this template in your own theme by creating a file at [your-theme]/tribe-events/modules/bar.php
*
* $filters and $views variables are loaded in and coming from
* the show funcion in: lib/tribe-events-bar.class.php
*
@mrwweb
mrwweb / append-file-types.css
Created June 9, 2014 14:33
CSS to automatically add a filetype to the end of a link. (e.g. "[PDF]") This is a best practice for accessibility and usability. Add or remove types as you see fit.
/* ID Link Mimetypes for Common Filetypes */
a[href$=".doc"]::after {
content: " [DOC]";
}
a[href$=".docx"]::after {
content: " [DOCX]";
}
a[href$=".rtf"]::after {
content: " [RTF]";
<div id="session-1" class="session session-1 track-1" style="grid-column: track-1; grid-row: time-0800 / time-0900;">
<h3 class="session_title">Talk Title</h3>
<span class="session_time">
<span class="session_time_start">8:00</span>
<span class="session_time_sep"> - </span>
<span class="session_time_end">9:00</span>
</span>
<span class="session_track">Track: 1</span>
<span class="session_author"><span class="session_author_gravatar"><img src="..."></span>Mike Rofone</span>
</div>
@mrwweb
mrwweb / editor-style.css
Last active October 5, 2018 22:58
First pass at an editor-style.css for the Sequential WordPress theme
html {
padding: 36px;
font-size: 62.5%;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
body {
max-width: 700px; /* default $content_width */
margin: 0 auto;