Skip to content

Instantly share code, notes, and snippets.

View kenanfallon's full-sized avatar

Kenan Fallon kenanfallon

View GitHub Profile
//Ajax Add to Cart
jQuery(function($) {
if ($( "body" ).hasClass( "single-product" )) {
$(document).on("click", ".single_add_to_cart_button", function(e) {
var product_button = $(this);
$product_form = $( this ).closest('form.cart');
@kenanfallon
kenanfallon / gist:6c4dc429cc10342b80bc835c6de78e97
Created February 15, 2017 06:01
WordPress write to debug.log
if ( ! function_exists('write_log')) {
function write_log ( $log ) {
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
} else {
error_log( $log );
}
}
}
@kenanfallon
kenanfallon / gist:260149218ad43b5252785faa5f968589
Created September 22, 2016 01:32
Protect Nginx Digital Downloads
location ~ ^/wp-content/uploads/woocommerce_uploads/(.*?)\.zip$ {
rewrite / permanent;
}
location ~ ^/wp-content/uploads/woocommerce_uploads/(.*?)\.wav$ {
rewrite / permanent;
}
location ~ ^/wp-content/uploads/woocommerce_uploads/(.*?)\.mp3$ {
rewrite / permanent;
@kenanfallon
kenanfallon / gist:42c8d9028a8f82f226a24346c6fce4ea
Last active May 12, 2016 23:38
WP-API - Specify which fields to return in JSON
add_filter( 'rest_prepare_post', 'my_custom_json_fields', 12, 3 );
function my_custom_json_fields( $data, $post, $context ) {
return [
'title' => $data->data['title']['rendered'],
'link' => $data->data['link'],
];
}
credit: https://github.com/WP-API/WP-API/issues/446#issuecomment-212443511
@kenanfallon
kenanfallon / gist:d9632aee088727da284f
Last active September 18, 2015 01:16 — forked from rutger1140/gist:4994751
Gravity Forms hook - disable auto scrolling to anchor after submit
// Gravity Forms anchor - disable auto scrolling of forms
add_filter("gform_confirmation_anchor", create_function("","return false;"));
//Gravity Forms anchor - with form ID
add_filter( 'gform_confirmation_anchor_5', '__return_false' );