Skip to content

Instantly share code, notes, and snippets.

Avatar

Leesa Ward doubleedesign

View GitHub Profile
@doubleedesign
doubleedesign / scripts.js
Created May 18, 2020
Use Animate.css for Slick slider transitions
View scripts.js
// Note: This assumes you already have the CSS set up for the classes you want to use.
function initCarousel() {
$('.my-carousel').slick({
slidesToShow: 1,
slidesToScroll: 1,
autoplay: false,
adaptiveHeight: false,
fade: true,
@doubleedesign
doubleedesign / widget-product-categories.php
Created Jan 17, 2021
Override the output of the WooCommerce product categories widget to be a Bootstrap accordion
View widget-product-categories.php
<?php
/**
* Product Categories Widget
* Modifies the WooCommerce product categories widget to display as a Bootstrap accordion.
*
* @package WooCommerce/Widgets
* @version 2.3.0
*/
defined( 'ABSPATH' ) || exit;
@doubleedesign
doubleedesign / filter-orders-by-role.php
Last active Jan 13, 2023
Add the ability to filter WooCommerce orders by role in wp-admin
View filter-orders-by-role.php
<?php
/**
* Add role drop-down to orders screen
*/
function doublee_add_order_user_role_filter_selectbox() {
global $typenow, $wp_query;
if (in_array($typenow, wc_get_order_types('order-meta-boxes'))) :
$user_role = '';
@doubleedesign
doubleedesign / acf-tsf-integration.php
Last active Dec 9, 2022
Get meta descriptions in The SEO Framework from ACF flexible content fields
View acf-tsf-integration.php
<?php
/**
* The SEO Framework + ACF flexible content integration
* TSF will look at the excerpt and then the content to generate the default meta description.
* If both of those are empty, this code looks for ACF flexible modules to get it from.
* // TODO: Make this work with archives as well as posts
* @param $description
* @param $args
*
* @return mixed|string
@doubleedesign
doubleedesign / excerpt-metabox-to-top.php
Created Dec 4, 2018
Move the WordPress Excerpt metabox to the top of post and page edit screens
View excerpt-metabox-to-top.php
/**
* Move the excerpt metabox to the top
* @param $post_type
*/
function doublee_custom_excerpt_metabox( $post_type ) {
if(in_array($post_type, array('post','page'))) {
add_meta_box(
'excerpt_meta', __( 'Excerpt' ), 'post_excerpt_meta_box', $post_type, 'temp', 'high'
);
}
@doubleedesign
doubleedesign / YearbookClasses.jsx
Last active Nov 23, 2022
InDesign Image Catalog for multiple folders at once (and multiple folders per page). Created for school yearbook projects (one folder per class, two classes per page) but could be adapted for other use cases where you want to lay out contact sheets of multiple folders automatically.
View YearbookClasses.jsx
/**
* Custom Image Catalog script that runs for all subfolders in a selected folder.
* Lays out each folder of images in the specified number of rows and columns, 2 folders per page, shows an alert if there's more images than allowed for,
* labels each group with the folder name, creates paragraph styles for the captions and group headings, and saves the file.
*
* Based on the built-in Image Catalog script but modified and simplified (e.g. hard-coding the settings) for my use case.
* Could be modified to suit different numbers of folders per page, different image quantities etc by changing the settings at the top
* and making tweaks to other code as needed.
*
* Could also be extended to show one dialog for settings prior to the loop,
@doubleedesign
doubleedesign / checkout-functions.php
Created May 17, 2019
Add reCaptcha v2 to WooCommerce Checkout
View checkout-functions.php
<?php
/**
* Add reCaptcha to checkout form
* Note: Can't place within the payment part of the form, WooCommerce just won't show it, choose an appropriate action to add it to accordingly
* @param $checkout
*/
function doublee_show_me_the_checkout_captcha($checkout) {
echo '<div class="g-recaptcha" data-sitekey="YOUR_KEY_HERE"></div>';
}
add_action('woocommerce_checkout_order_review', 'doublee_show_me_the_checkout_captcha', 18);
@doubleedesign
doubleedesign / class-unhooky-plugin-custom-admin-stuff.php
Last active Nov 7, 2022
How to unhook a Ninja Forms plugin action from within another plugin. The context for this example was using Ninja Forms for Expression of Interest forms associated with Jobs (a custom post type), and a customised admin screen for viewing submissions. (This isn't the whole plugin, it's just the parts required to show how to unhook a Ninja Forms …
View class-unhooky-plugin-custom-admin-stuff.php
/**
* Job listings functionality for Client Website
* Note: Requires Ninja Forms plugin
* Note: Truncated for use in a gist to demonstrate unhooking a Ninja Forms function
*
* @since 1.0.0
* @package MyPlugin
* @subpackage MyPlugin/admin
*/
class MyPlugin_Jobs extends MyPlugin_Settings {
@doubleedesign
doubleedesign / breadcrumbs-list.php
Created Dec 4, 2018
Mark up Yoast breadcrumbs as an unordered list
View breadcrumbs-list.php
<?php
/**
* Filter the output of Yoast breadcrumbs so each item is an <li> with schema markup
* @param $link_output
* @param $link
*
* @return string
*/
function doublee_filter_yoast_breadcrumb_items( $link_output, $link ) {
@doubleedesign
doubleedesign / javascript-delayed-event.js
Created Dec 9, 2018
How to delay a JavaScript event within an event listener
View javascript-delayed-event.js
function myDelayedThing() {
var mySelectors = document.querySelectorAll('.something');
// Loop through mySelectors
for(var i = 0; i < menuLinks.length; i++) {
// Add 'open' class on mouseover
menuLinks[i].addEventListener('mouseover', function() {
this.classList.add('open');