Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Root-Wiley mrwweb

View GitHub Profile
@mrwweb
mrwweb / block-editor-styles.scss
Created Jul 9, 2020
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 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 );
View session.html
<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 / mrw-clear-shortcode.php
Last active Feb 9, 2018
A very simple shortcode to clear content following aligned images.
View mrw-clear-shortcode.php
<?php
/*
Plugin Name: Clear Aligned Content Shortcode
Description: A way to ensure floated images in page content don't wrap. Use [clear] in editor to push following content below any aligned images.
Author: Mark Root-Wiley
Version: 1.0
Author URI: https://MRWweb.com
Plugin URI: https://gist.githubusercontent.com/mrwweb/f627f3fe407a64293f6a99d701526b94/raw/c0e23d2f5b0252332e4f7c549a2990b4c944cfe1/mrw-clear-shortcode.php
USAGE:
@mrwweb
mrwweb / index.html
Last active Jan 25, 2018
Testing mapbox-gl.js upgrade
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@mrwweb
mrwweb / truncate-fpw-excerpt.php
Created Mar 9, 2017
A custom plugin to limit the length of excerpts *only* when they appear in Feature a Page Widget. (https://wordpress.org/plugins/feature-a-page-widget/) Save this file as `truncate-fpw-excerpt.php` and then place it in `/wp-content/mu-plugins/`. You may need to create this directory if it doesn't exist yet.
View truncate-fpw-excerpt.php
<?php
/*
Plugin Name: Truncate Feature a Page Widget Excerpt
Description: Limits excerpt to 30 words. Ends cut-off excerpts with "..."
Version: 1.0
Author: Mark Root-Wiley
Author URI: https://mrwweb.com
*/
add_filter( 'fpw_excerpt', 'wp8887975_trim_fpw_excerpt' );
function wp8887975_trim_fpw_excerpt( $excerpt ) {
View alt-text-example.html
<img src="/your-image.jpg" alt="The alt text describing that image" />
View nten-pdf-embed-shortcode.php
<?php
/*
Plugin Name: Google PDF Viewer Shortcode
Description: Display a PDF in the browser with Google's PDF viewer. Usage: [pdf]http://example.org/some-public-document.pdf[/pdf]. Can specify optional width and height attribrutes like this [pdf width="100" height="100"]http://example.org/a-very-tiny-document.pdf[/pdf]
Version: 1.0
Author: Mark Root-Wiley
Author URI: https://mrwweb.com
*/
/* a shortcode for embedding PDFs via Google Docs viewer */
function nten_pdf_shortcode( $atts, $content = '' ) {
@mrwweb
mrwweb / superclick-init-plus.js
Created Dec 16, 2016
Some nice little tweaks to the default superclick init
View superclick-init-plus.js
(function($){ //create closure so we can safely use $ as alias for jQuery
"use strict";
$(document).ready(function(){
var mainMenu = $('#primary-menu').superclick({
activeClass: 'sf-active', // change active class from sfHover to sf-active
cssArrows: false, // no arrows (but you should probably provide your own)
speed: 1, // "no animation"
onShow: function() {
// keep off screen momentarily
You can’t perform that action at this time.