Skip to content

Instantly share code, notes, and snippets.

@ajmorris
ajmorris / main.yml
Created October 20, 2021 21:03
Simple workflow file for Github Actions to deploy your WordPress theme
# This is a basic workflow to help you get started with Actions
# The name of the script you are intending to run.
name: Deployment
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch.
# I left my branch name as main, but you could change this to whatever your branches are called.
push:
@ajmorris
ajmorris / itms-theme-helpers.php
Created June 23, 2020 12:13
MU-Plugin for Theme Showdown 2020 - https://ithemes.com/training
<?php
/**
* Plugin Name: Theme Showdown 2020 Helper Plugin
* Plugin URI: https://www.ithemes.com/training
* Description: Plugin that includes handy helpful code snippets for Theme Showdown 2020
* Author: iThemes / AJ Morris
* Author URI: https://www.ithemes.com/training
* Text Domain: ithemes-training
* Domain Path: /languages
* Version: 1.0.0
@ajmorris
ajmorris / functions.php
Last active August 6, 2018 18:08
making the description display for menu items with description filled out
<?php
// Adds the descriptions to menu output
function prefix_nav_description( $item_output, $item, $depth, $args ) {
if ( !empty( $item->description ) ) {
$item_output = str_replace( $args->link_after . '</a>', '<p class="menu-item-description">' . $item->description . '</p>' . $args->link_after . '</a>', $item_output );
}
return $item_output;
}
@ajmorris
ajmorris / functions.php
Created April 18, 2018 17:54 — forked from mikejolley/functions.php
WooCommerce - Notify admin when a new customer account is created
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_action( 'woocommerce_created_customer', 'woocommerce_created_customer_admin_notification' );
function woocommerce_created_customer_admin_notification( $customer_id ) {
wp_send_new_user_notifications( $customer_id, 'admin' );
}
@ajmorris
ajmorris / dropdown-stock-status.php
Created April 18, 2018 17:49 — forked from lawkwok/dropdown-stock-status.php
WooCommerce - Adds stock status to the dropdown on product pages
<?php
add_action( 'woocommerce_after_add_to_cart_form', 'dropdown_waitlist_label' );
function dropdown_waitlist_label() {
echo "
<script>
jQuery(document).ready(function($) {
var variation_data = $('form.variations_form').attr('data-product_variations');
var variation_data = JSON.parse(variation_data);
@ajmorris
ajmorris / functions.php
Created April 18, 2018 17:33 — forked from claudiosanches/functions.php
WooCommerce - Change ajax variation threshold
function custom_wc_ajax_variation_threshold( $qty, $product ) {
return 10;
}
add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 10, 2 );
@ajmorris
ajmorris / custom-woo-acf-tabs.php
Created April 18, 2018 17:32
Create custom product details tabs within WooCommerce using an ACF (Advanced Custom Fields) Repeater field.
<?php
function hwid_load_custom_tab( $tab_key, $tab_info ) {
echo apply_filters( 'the_content', $tab_info['tabContent'] );
}
function hwid_add_content_tabs( $tabs ) {
global $post;
$custom_tabs = get_field( 'tabs', $post->ID );
@ajmorris
ajmorris / acf-fields.php
Last active February 7, 2020 23:47 — forked from hereswhatidid/acf-fields.php
Create custom product details tabs within WooCommerce using an ACF (Advanced Custom Fields) Repeater field.
<?php
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array (
'key' => 'acf_product_options',
'title' => 'Product Options',
'fields' => array (
array (
'key' => 'acf_product_options_tabbedcontent_label',
'label' => 'Tabbed Content',
@ajmorris
ajmorris / functions.php
Created March 28, 2018 18:45
Notify admin when a new customer account is created - WooCommerce
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_action( 'woocommerce_created_customer', 'woocommerce_created_customer_admin_notification' );
function woocommerce_created_customer_admin_notification( $customer_id ) {
wp_send_new_user_notifications( $customer_id, 'admin' );
@ajmorris
ajmorris / functions.php
Created March 28, 2018 18:40
WooCommerce - Adds stock status to the dropdown on product pages
<?php
add_action( 'woocommerce_after_add_to_cart_form', 'dropdown_waitlist_label' );
function dropdown_waitlist_label() {
echo "
<script>
jQuery(document).ready(function($) {
var variation_data = $('form.variations_form').attr('data-product_variations');
var variation_data = JSON.parse(variation_data);
$('#pa_size > option').each(function() {
for (var i = 0; i < variation_data.length; i++) {