Skip to content

Instantly share code, notes, and snippets.


Leesa Ward doubleedesign

View GitHub Profile
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 / 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 / cpt-case_study.php
Created Jun 28, 2021
Use a WooCommerce product attribute taxonomy for a custom post type
View cpt-case_study.php
// Register Custom Post Type
// Note: Using woocommerce_after_register_taxonomy hook instead of init because we're using a product attribute taxonomy with this CPT
function doublee_cpt_case_study() {
$labels = array(
'name' => _x('Case studies', 'Post Type General Name', 'doubleedesign'),
'singular_name' => _x('Case study', 'Post Type Singular Name', 'doubleedesign'),
'menu_name' => __('Case studies', 'doubleedesign'),
'name_admin_bar' => __('Case study', 'doubleedesign'),
doubleedesign / functions.php
Created Apr 28, 2021
Log all WordPress hooks that run
View functions.php
function doublee_log_all_actions() {
foreach($GLOBALS['wp_actions'] as $action => $count) {
error_log(print_r($action, true));
add_action('shutdown', 'doublee_log_all_actions');
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
* 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 / 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
* 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 / create-zip.php
Last active Jan 17, 2021
Add a "download all" option to emails for WooCommerce downloadable products. Zips all the files and stores the zip in a specified directory.
View create-zip.php
* Utility function to create a zip file from an array of file URLs
* Used for download links in emails
* @param array $files
* @param string $filename
* @return string
function doublee_zip_order_files(array $files, string $filename) {
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
* 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 / _export-orders.php
Last active Jan 18, 2021
Export selected data about the currently shown WooCommerce orders to a CSV file
View _export-orders.php
* Function to export the orders list to a CSV download (not stored anywhere)
* CSV construction based on
* Dev notes:
* - This file is designed to be called via AJAX, with that function providing the order IDs.
* - To use this without AJAX you would just need to define $order_ids = wp_list_pluck($wp_query->posts, 'ID') instead,
* and define $filename as something appropriate here.
function doublee_export_orders() {
doubleedesign / current-menu-item.php
Created Jan 3, 2021
Add class to CPT archive link in menus when viewing a post of that type
View current-menu-item.php
// Add current-menu-item to post type archive link for this post's type
function doublee_menu_classes($classes, $item) {
global $post;
$id = (isset($post->ID) ? get_the_ID() : NULL);
if(isset($id) && $item->type == 'post_type_archive') {
$current_post_type = get_post_type($id);
$link_post_type = $item->object;
if($current_post_type == $link_post_type) {