Skip to content

Instantly share code, notes, and snippets.


Timothy Wood codearachnid

View GitHub Profile
codearachnid / filter_gf_select_optgroup.php
Last active Feb 22, 2022
Add the optgroup ability to Gravity Forms default select field.
View filter_gf_select_optgroup.php
* Filter Gravity Forms select field display to wrap optgroups where defined
* USE:
* set the value of the select option to `optgroup` within the form editor. The
* filter will then automagically wrap the options following until the start of
* the next option group
add_filter( 'gform_field_content', 'filter_gf_select_optgroup', 10, 2 );
function filter_gf_select_optgroup( $input, $field ) {
codearachnid / woocommerce_update_stock_status.php
Created Jul 7, 2013
set the stock status for all products in your WooCommerce store
View woocommerce_update_stock_status.php
* set the stock status for all products in your WooCommerce store
* @return void
function woocommerce_update_stock_status(){
global $wpdb;
// set all status for products with 0 or less stocked quantity
codearachnid / WooCommerce-Edit-General-SKU.php
Created Nov 19, 2020
Needed a quick drop in script for functions.php to add SKU field on the general tab within WooCommerce product editor
View WooCommerce-Edit-General-SKU.php
// add sku on woocommerce product editor >> general tab
add_action( 'woocommerce_product_options_general_product_data', 'add_the_sku_to_general_product_field' );
function add_the_sku_to_general_product_field() {
global $post;
$product_sku = get_post_meta( $post->ID, '_sku', true );
<div class="options_group">
<p class="form-field _sku_field ">
codearachnid / custom_tribe_event_featured_image.php
Created Jul 19, 2013
rewrite the tribe event featured image on single event view templates with a custom size
View custom_tribe_event_featured_image.php
codearachnid / wp20140226_reset_slugs.php
Last active Oct 11, 2020
Reset the slugs on a particular post type to use the default sanitized slugs. To use, add the following code into your theme's functions.php file, ensure that the desired post type is set when calling `wp20140226_reset_slugs('post');` Then navigate to `wp-admin/options-permalink.php` to activate query to reset slugs. Depending on how many posts …
View wp20140226_reset_slugs.php
* Reset the slugs on a particular post type to use the default sanitized slugs
* @param string $post_type filter by post type
* @param int $offset set the paginated post to start
* @param boolean $force_guid_update * WARNING * never enable this
* @example add the following code into your theme's functions.php file, ensure
codearachnid / series-engine-embed-extend.php
Created May 27, 2015
A simple modification to implement filters for embed display within archive and ajax shortcodes for Series Engine.
View series-engine-embed-extend.php
* implement a filter hook by replacing the original echo in
* serieslistings.php lines 621, 727
* ajaxlink.php lines 632, 746
echo stripslashes($enmse_singlemessage->embed_code);
// with the new filter
codearachnid / report.SQL
Created Feb 6, 2020
Sabai Report Directory Export Report (Camp Finder)
View report.SQL
SELECT t1.entity_id, t2.post_id, t2.post_title, t1.value, t3.address, t3.street,, t3.state,,,, t4.fax,,, DATE_FORMAT(FROM_UNIXTIME(t5.edited_at), "%Y-%m-%d")
FROM wp_sabai_entity_field_content_body as t1
LEFT JOIN wp_sabai_content_post as t2
ON t1.entity_id = t2.post_id
LEFT JOIN wp_sabai_entity_field_directory_location as t3
ON t1.entity_id = t3.entity_id
LEFT JOIN wp_sabai_entity_field_directory_contact as t4
ON t1.entity_id = t4.entity_id
LEFT JOIN wp_sabai_entity_field_content_activity as t5
ON t1.entity_id = t5.entity_id
codearachnid / wc_customer_bought_product.php
Created Feb 27, 2014
WooCommerce check if user has already bought product.
View wc_customer_bought_product.php
// if product is already in global space
global $product;
// or fetch product attributes by ID
if( empty( $product->id ) ){
$wc_pf = new WC_Product_Factory();
$product = $wc_pf->get_product($id);
View Easel Backup Settings
codearachnid / sabai-directory-dashboard-shortcode.php
Created Feb 2, 2019
If you have Sabai and you want to customize the dashboard to be part of another page (like inside of woocommerce my account) use this shortcode
View sabai-directory-dashboard-shortcode.php
add_shortcode('sabai-directory-dashboard', 'sabai_directory_dashboard_get_shortcode');
function sabai_directory_dashboard_get_shortcode($atts, $content, $tag){
$platform = get_sabai_platform();
$path = $platform->getSabai()->getAddon('Directory')->getSlug('dashboard');
return $platform->shortcode($path, (array)$atts, $content);