Skip to content

Instantly share code, notes, and snippets.

@esedic
esedic / gw-limit-checkboxes-usage.php
Created October 23, 2023 15:33 — forked from spivurno/gw-limit-checkboxes-usage.php
Gravity Wiz // Limit Checkboxes Usage
<?php
// standard usage
new GFLimitCheckboxes(115, array(
5 => array(
'min' => 2,
'max' => 3
)
));
@esedic
esedic / gw-gravity-forms-submission-limit.php
Created October 23, 2023 15:33 — forked from spivurno/gw-gravity-forms-submission-limit.php
Gravity Wiz // Gravity Forms // Limit Submissions Per Time Period (by IP, User, Role, Form URL, or Field Value)
<?php
/**
* WARNING! THIS SNIPPET MAY BE OUTDATED.
* The latest version of this snippet can be found in the Gravity Wiz Snippet Library:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-submission-limit.php
*/
/**
* Gravity Wiz // Gravity Forms // Limit Submissions Per Time Period (by IP, User, Role, Form URL, or Field Value)
*
* Limit the number of times a form can be submitted per a specific time period. You modify this limit to apply to
@esedic
esedic / gw-gravity-forms-disable-autocomplete.php
Created October 23, 2023 15:33 — forked from spivurno/gw-gravity-forms-disable-autocomplete.php
Gravity Wiz // Gravity Forms // Disable Auto-complete
<?php
// Disable auto-complete on form.
add_filter( 'gform_form_tag', function( $form_tag ) {
return str_replace( '>', ' autocomplete="off">', $form_tag );
}, 11 );
// Diable auto-complete on each field.
add_filter( 'gform_field_content', function( $input ) {
return preg_replace( '/<(input|textarea)/', '<${1} autocomplete="off" ', $input );
@esedic
esedic / gw-gravity-forms-set-input-as-tel.php
Created October 23, 2023 15:33 — forked from spivurno/gw-gravity-forms-set-input-as-tel.php
Gravity Wiz // Gravity Forms // Set Input Type as Tel
<?php
/**
* Gravity Wiz // Gravity Forms // Set Input Type as Tel
* http://gravitywiz.com/
*/
add_filter( 'gform_field_content_723_10', 'gw_set_tel_input_type' );
function gw_set_tel_input_type( $input ) {
$input = preg_replace( "/type='[\\w]+'/", "type='tel'", $input );
return $input;
}
@esedic
esedic / gw-gravity-forms-first-error-focus.php
Created October 23, 2023 15:32 — forked from spivurno/gw-gravity-forms-first-error-focus.php
Gravity Wiz // Gravity Forms // Give First Validation Error Focus
<?php
/**
* Gravity Wiz // Gravity Forms // Give First Validation Error Focus
* http://gravitywiz.com/
*
* Plugin Name: Gravity Forms First Error Focus
* Plugin URI: https://gravitywiz.com/make-gravity-forms-validation-errors-mobile-friendlyer/
* Description: Automatically focus (and scroll) to the first field with a validation error.
* Author: Gravity Wiz
* Version: 1.1
@esedic
esedic / gravity-forms-move-progress-bar-bottom.php
Created October 23, 2023 15:32 — forked from spivurno/gravity-forms-move-progress-bar-bottom.php
Gravity Forms - Move Progress Bar to Bottom of Form
/**
* Plugin Name: Gravity Forms: Move Progress Bar to Bottom of Form
* Plugin URI: http://www.n7studios.co.uk
* Version: 1.0.1
* Author: n7 Studios
* Author URI: http://www.n7studios.co.uk
* Description: Moves the progress bar from the top to the bottom of the Gravity Form. The Start Paging section of the form MUST have a CSS class = progress-bar-bottom
*/
/**
<?php
/**
* Gravity Perks // Populate Anything // Range Modifier for Live Merge Tags
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
*
* Use the :range modifier with checkbox merge tags to get the range of checked options
* Works well with the :value modifier
*
* Will return `x - y` where the min and max are different, or `x` if they are the same
@esedic
esedic / functions.php
Created October 23, 2023 15:29 — forked from BruceMcKinnon/functions.php
Gravity Forms - Button to delete file uploads for an entry
add_filter( 'gform_entry_detail_meta_boxes', 'add_delete_attachment_meta_box', 10, 3 );
function add_delete_attachment_meta_box( $meta_boxes, $entry, $form ) {
$my_form_id = 3;
if ( $form['id'] == $my_form_id ) {
if ( ! isset( $meta_boxes['payment'] ) ) {
$meta_boxes['payment'] = array(
'title' => esc_html__( 'Delete Attachments', 'gravityforms' ),
@esedic
esedic / get_page_by_post_name.php
Created October 5, 2023 18:25
WordPress function to get post by title
<?php
// Custom function to replace deprecated get_page_by_title()
function get_page_by_post_name($post_name, $output = OBJECT, $post_type = 'post' ) {
global $wpdb;
$page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type= %s", $post_name, $post_type ) );
if ( $page ) {
return get_post( $page, $output );
}
@esedic
esedic / acf_reame.php
Created October 4, 2023 11:01
Update meta fields on ACF field name change
<?php
if (class_exists('acf')) {
/**
* Update meta fields on acf field name change
*/
function update_acf_field_name($data , $postarr)
{
global $wpdb;
$post_id = $postarr['ID'];