Skip to content

Instantly share code, notes, and snippets.

View woo fields not required
add_filter( 'woocommerce_default_address_fields' , 'fx_free', 99999 );
function fx_free( $fields ) {
$fields['address_1']['required'] = false;
$fields['address_2']['required'] = false;
$fields['city']['required'] = false;
$fields['state']['required'] = false;
$fields['postcode']['required'] = false;
View gist:45645b171d3278e7197a97b08689ac41
curl -o /dev/null -w 'lookup: %{time_namelookup}\nconnect: %{time_connect}\nsslconnect: %{time_appconnect}\nTTFB: %{time_starttransfer}\ntotal: %{time_total}\n' 'https://www.yourserver.com'
@johnmontfx
johnmontfx / gist:c073ddf3506df3de3fb431098f48f51a
Last active Jul 25, 2017
Hide fields in woo based upon category
View gist:c073ddf3506df3de3fb431098f48f51a
## Based upon code from https://calebburks.com/conditionally-showhide-woocommerce-checkout-fields/
function fx_category_is_in_the_cart() {
// Add the category slugs here that you want to have the fields removed for
$categories = array( 'clothing', 'posters' );
// Products currently in the cart
$cart_ids = array();
@johnmontfx
johnmontfx / header-meta-tags.php
Created Sep 22, 2016
Modification of file to allow more friendly filtering for custom functions for Social Warfare WordPress Function
View header-meta-tags.php
// This begins around line 148 of the file
// Queue up our header hook function
if( is_swp_registered() ):
add_filter( 'swp_meta_tags' , 'swp_open_graph_tags' , 2 );
add_filter( 'swp_meta_tags' , 'swp_add_twitter_card' , 4 );
endif;
add_filter( 'swp_meta_tags' , 'swp_frame_buster' , 6 );
add_filter( 'swp_meta_tags' , 'swp_output_custom_color' , 8 );
@johnmontfx
johnmontfx / gist:719658db79be0780fab5
Created Mar 19, 2016
Testing the wc-ajax function
View gist:719658db79be0780fab5
add_action( 'wp_ajax_my_ajax_function_', 'my_ajax_function' );
function my_ajax_function() {
$mystuff = $_POST['stuff'];
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
set_transient('fx_mystuff' , $mystuff, '0');
}
die();
}
View gist:5696ae36959f94762789
add_action( 'plugins_loaded', 'my_overrides');
function my_overrides() {
add_action( 'woocommerce_saved_order_items','my_function_one' );
add_action( 'woocommerce_checkout_order_processed', 'my_function_two' );
}
@johnmontfx
johnmontfx / gist:3fc8899b28e95fadfb54
Last active Jan 26, 2016
A quick example of transients
View gist:3fc8899b28e95fadfb54
// set the variable $instagram_data to the data previously stored as a transient.
// if the transient has expired or there is not data, the variable will be empty.
$instagram_data = get_transient('myprefix_instagram_data');
// if the variable is empty, we need to get the new data from instagram
// But if it is not empty, it will skip all the steps inside this loop, saving time.
if ( !$instagram_data ) {
View Attempting to remove Pencil Unread Action
## Action as added by Pencil Unread Plugin
//mark as read
add_action('bbp_template_after_pagination_loop', array(&$this,"mark_as_read_single_forum_link"));
## Attempted remove action in my functions file, but it doesn't get removed
remove_action('bbp_template_after_pagination_loop', array("bbP_Pencil_Unread","mark_as_read_single_forum_link"));
## A look a the filter, where you see it was set by the plugin. Just not sure how to reference it.
@johnmontfx
johnmontfx / gist:2be28f980f40e124fd54
Created Jan 19, 2015
Patch shoestrap-extras includes/cmf/init.php file to better deal with SSL admin
View gist:2be28f980f40e124fd54
--- /Users/johnmont/Downloads/shoestrap-extras-pack/includes/cmf/init.php 2015-01-19 13:30:17.000000000 -0800
+++ /Users/johnmont/Downloads/shoestrap-extras-pack/includes/cmf/init.new.php 2015-01-19 13:27:48.000000000 -0800
@@ -889,13 +889,13 @@
if ( strtoupper( substr( PHP_OS, 0, 3 ) ) === 'WIN' ) {
// Windows
$content_dir = str_replace( '/', DIRECTORY_SEPARATOR, WP_CONTENT_DIR );
- $content_url = str_replace( $content_dir, WP_CONTENT_URL, dirname(__FILE__) );
+ $content_url = str_replace( $content_dir, content_url(), dirname(__FILE__) );
$cmb_url = str_replace( DIRECTORY_SEPARATOR, '/', $content_url );