Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Root-Wiley mrwweb

View GitHub Profile
@mrwweb
mrwweb / tribe_get_events.php
Last active Sep 28, 2022
Get Upcoming Events with tribe_get_events()
View tribe_get_events.php
<?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 / readme.md
Last active Sep 28, 2022
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 / mrw-tinymce-filter-example.php
Last active Sep 1, 2022
A plugin to modify the TinyMCE editor in WordPress 3.9+. Now available on WP.org! https://wordpress.org/plugins/mrw-web-design-simple-tinymce/
View mrw-tinymce-filter-example.php
<?php
/**
* Example filter to add text style to TinyMCE filter with Mark's "MRW TinyMCE Mods" plugin
*
* Adds a "Text Styles" submenu to the "Formats" dropdown
*
* This would go in a functions.php file or mu-plugin so you don't have to modify the original plugin.
*
* $styles array Contains arrays of style_format arguments to define styles.
* Note: Should be an "array of arrays"
@mrwweb
mrwweb / button.php
Created Aug 26, 2022
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 / reset-rems
Created May 22, 2013
"Sanity-ize" REMs by setting them to 10px-baseline aka "Tiny Happy Pixels Dancing."
View reset-rems
/* 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 / functions.php
Last active Jul 10, 2022
Example Child Theme Files
View functions.php
<?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' );
@mrwweb
mrwweb / functions.php
Created Jun 24, 2020
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 Oct 28, 2019
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 );
@mrwweb
mrwweb / faux-block-editor.css
Last active Feb 10, 2022
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 Apr 8, 2021
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' );
}