Skip to content

Instantly share code, notes, and snippets.

View hirejordansmith's full-sized avatar

Jordan Smith hirejordansmith

View GitHub Profile
@hirejordansmith
hirejordansmith / hide-gf-ajax-spinner.css
Created January 21, 2016 05:51
How to hide the Gravity Form Ajax Spinner
body img.gform_ajax_spinner {
display: none!important;
}
@hirejordansmith
hirejordansmith / enable-gf-field-label-visibility-settings.php
Created February 10, 2016 11:24
Enable GF field label visibility settings
<?php
add_filter( 'gform_enable_field_label_visibility_settings', '__return_true' );
?>
@hirejordansmith
hirejordansmith / move-genesis-entry-header-markup-to-site-header.php
Created March 28, 2016 17:16
Move Genesis Entry Header Markup to Site Header
<?php
@hirejordansmith
hirejordansmith / gf-currencies-with-three-decimals.php
Created May 14, 2016 11:07
GF Currencies with three decimals
<?php
add_filter( 'gform_currencies', function( $currencies ) {
$currencies['EUR']['decimals'] = 3;
return $currencies;
} );
?>
@hirejordansmith
hirejordansmith / add-support-merge-tags-gravity-form-labels.php
Created May 28, 2016 11:32
How to Add Support for Merge Tags in Gravity Form Labels
<?php
/**
* Gravity Wiz // Gravity Forms // Add Support for Merge Tags in Gravity Form Labels
* https://gravitywiz.com/add-support-for-merge-tags-gravity-form-labels/
*/
add_filter( 'gppc_replace_merge_tags_in_labels', '__return_true' );
<?php
// Remove gf_hidden and gf_invisible classes from all fields
add_filter( 'gform_pre_render', 'remove_display_hidden_classes' );
add_filter( 'gform_pre_validation', 'remove_display_hidden_classes' );
add_filter( 'gform_pre_submission_filter', 'remove_display_hidden_classes' );
add_filter( 'gform_admin_pre_render', 'remove_display_hidden_classes' );
function remove_display_hidden_classes( $form ) {
foreach ( $form['fields'] as &$field ) {
$classes = explode( ' ', $field->cssClass ); // 'class1 class2' : array( 'class1', 'class2' )
@hirejordansmith
hirejordansmith / change-field-type-gravity-form-field.php
Created June 23, 2016 16:04
Change field type of a Gravity Form field
<?php
add_filter( 'gform_gf_field_create', 'convert_hidden_to_text', 10, 2 );
function convert_hidden_to_text( $field, $properties ) {
if( $field->get_input_type() == 'hidden' ) {
$field = new GF_Field_Text( $properties );
}
return $field;
}
@hirejordansmith
hirejordansmith / replace-woocommerce-product-archive-add-to-cart-button.php
Last active March 7, 2019 09:56
Replace WooCommerce Product Archive Add to Cart Button
<?php
// This just returns an empty value for the archive product button
add_filter( 'woocommerce_loop_add_to_cart_link', 'change_add_to_cart_loop' );
function change_add_to_cart_loop( $product ) {
global $product; // this may not be necessary as it should have pulled the object in already
return '';
}
// Then we add a new button with the same WooCommerce Markup that links directly to the product page
add_action( 'woocommerce_after_shop_loop_item', 'hjs_loop_add_to_cart', 10 );
@hirejordansmith
hirejordansmith / how-to-get-the-current-page-url-with-php.php
Last active August 10, 2016 13:18
How to Get the Current Page URL with PHP
<?php
// Non WordPress
$current_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
// WordPress Site
global $wp;
$current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) );
@hirejordansmith
hirejordansmith / replace-ajax-spinner-with-custom-spinner.css
Created August 11, 2016 21:05
Replace AJAX Spinner with Custom Spinner
/*
hourglass.gif replaces the default AJAX spinner
http://loading.io/ <- Good place to find a new one
*/
body img.gform_ajax_spinner {
position: fixed !important;