Skip to content

Instantly share code, notes, and snippets.

View willgorham's full-sized avatar

Will G willgorham

View GitHub Profile
@willgorham
willgorham / wp-cli-auto-add-pages-to-menu.php
Last active September 29, 2018 00:32
WordPress: Set specific menus (theme locations) to auto-add pages
<?php
/**
* Allows programatically seting of specific menu locations (or more specifically,
* the menus assigned to those locations) to automatically add new pages.
* [I.e. enables the 'Automatically add new top-level pages to this menu' setting]
*
* Usage (via WP CLI):
* - Add file to mu-plugins folder (might also work in functions.php?)
* - Get theme menu location slugs you want to enable auto-added pages (e.g. 'home' and 'footer-nav')
* - From the command line (SSH or otherwise), call:
@willgorham
willgorham / woocommerce-auto-complete-virtual-orders.php
Last active June 4, 2024 05:26
WooCommerce: Automatically complete virtual orders
<?php
add_filter( 'woocommerce_payment_complete_order_status', 'wmg_auto_complete_virtual_orders', 10, 3 );
/**
* Automatically complete orders with only virtual products
*
* @param string $payment_complete_status Order status used after an order payment is received
* @param int $order_id ID of the order being processed
* @param WC_Order $order Order object being processed