Skip to content

Instantly share code, notes, and snippets.

@bacoords
bacoords / understrap-post-nav.php
Created January 19, 2022 00:29
Replace Understrap post nav font-awesome reference with inline Bootstrap Icons SVGs
<?php
/**
* Display navigation to next/previous post when applicable.
*/
function understrap_post_nav() {
// Don't print empty markup if there's nowhere to navigate.
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( ! $next && ! $previous ) {
return;
@bacoords
bacoords / content-card.php
Created January 15, 2022 20:27
Understrap post content with card classes
<?php
/**
* Post rendering content according to caller of get_template_part
*
* @package Understrap
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
?>
@bacoords
bacoords / archive.php
Created January 15, 2022 20:26
Understrap archive with columns layout
<?php
/**
* The template for displaying archive pages
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package Understrap
*/
// Exit if accessed directly.
@bacoords
bacoords / custom-javascript.js
Created January 11, 2022 21:03
Understrap - how to use bootstrap components
// Add your custom JS here.
import Popover from 'bootstrap/js/dist/popover'
var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
return new Popover(popoverTriggerEl)
@bacoords
bacoords / functions.php
Created October 20, 2021 18:15
Remove lazy loading from WordPress custom logo
<?php
function understrap_get_custom_logo_attributes( $custom_logo_attr ){
$custom_logo_attr['data-no-lazy'] = '1';
$custom_logo_attr['loading'] = 'eager';
return $custom_logo_attr;
}
add_filter( 'get_custom_logo_image_attributes', 'understrap_get_custom_logo_attributes' );
@bacoords
bacoords / shortcode-javascript.php
Last active June 10, 2021 16:20
how to enqueue js for a shortcode
<?php
/**
* Our theme/plugin enqueue scripts function.
*/
function example_enqueue_scripts() {
// Register the script in the normal WordPress way.
wp_register_script( 'example-shortcode-js', '...example-shortcode-script.js' );
@bacoords
bacoords / understrap-child-allow-dropdown-links.php
Created March 18, 2021 22:20
All dropdown to be links when using the bootstrap nav walked or under strap theme.

Underscores Tutorial

howarddc.com | 2.25.2021

Tutorial

Dev Prereqs

The first step is to confirm that your machine is ready for development using Node, NPM, and Gulp.

  • NVM: Node Version Manager can be confirmed by running command -v nvm.
  • Gulp CLI should be installed globally via npm install --global gulp-cli. You can confirm it by running gulp --version.
@bacoords
bacoords / public-listener-example.js
Last active October 23, 2020 19:09
Setting up function for 'onload' more properly
function addClickEvents() {
//events added here to ensure all image elements fully loaded prior to adding events
d3.select("#poster-image") //Extinction Rebellion
.on("mouseover", function() { showExcerpt("xr", 450, 125, "R", 500, 500, boxText); })
.on("mouseout", function() {hideExcerpt("xr");})
.on("click", showContrib);
d3.select("#blockUpperText3") //Robin Wall Kimmerer
@bacoords
bacoords / replace-images.js
Created October 13, 2020 03:58
public - function to load large images
// Function to background load images and swap out their source.
function replaceImageSrc() {
jQuery('svg image').each(function(){
var el = jQuery(this);
// Get the new href.
var href = el.attr('xlink:href');
href = href.replace( 'assets_small', 'assets_large' );
href = href.replace( '-s.', '-l.' );