Skip to content

Instantly share code, notes, and snippets.

Richard Wawrzyniak richardW8k

Block or report user

Report or block richardW8k

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@richardW8k
richardW8k / rw_change_checkbox_structure.php
Created Mar 19, 2014
change Gravity Forms checkbox structure so it doesn't use the extra ul and li's
View rw_change_checkbox_structure.php
add_filter( 'gform_field_input', 'rw_change_checkbox_structure', 10, 5 );
function rw_change_checkbox_structure($input, $field, $value, $lead_id, $form_id){
$input_type = RGFormsModel::get_input_type($field);
if($input_type != "checkbox" || IS_ADMIN && RG_CURRENT_VIEW == "entry")
return $input;
$choices = "";
if(is_array($field["choices"])){
$choice_number = 1;
@richardW8k
richardW8k / change_column_to_checkbox.php
Created May 3, 2014
To convert a list field column to use a checkbox add the php excluding the first line to your theme functions.php file. The JavaScript can be placed between script tags in a HTML field on the form.
View change_column_to_checkbox.php
<?php
// format: gform_column_input_content_FORMID_FIELDID_COLUMN
add_filter( 'gform_column_input_content_524_2_2', 'change_column_to_checkbox', 10, 6 );
function change_column_to_checkbox( $input, $input_info, $field, $text, $value, $form_id ) {
$input_field_name = "input_{$field['id']}[]";
$tabindex = GFCommon::get_tabindex();
$new_input = "<input type='checkbox' {$tabindex} /><input type='hidden' name='{$input_field_name}' value=' ' />";
return $new_input;
}
@richardW8k
richardW8k / change_col_to_checkboxes.php
Created May 3, 2014
To convert a list field column to use checkboxes add the php excluding the first line to your theme functions.php file. The JavaScript can be placed between script tags in a HTML field on the form.
View change_col_to_checkboxes.php
<?php
// format: gform_column_input_content_FORMID_FIELDID_COLUMN
add_filter( 'gform_column_input_content_524_2_2', 'change_column_to_checkbox', 10, 6 );
function change_column_to_checkbox( $input, $input_info, $field, $text, $value, $form_id ) {
$input_field_name = "input_{$field['id']}[]";
$tabindex = GFCommon::get_tabindex();
$new_input = "<div class='ginput_container'><ul class='gfield_checkbox'>" .
"<li><input type='checkbox' {$tabindex} value='First Choice' /><label>First Choice</label></li>" .
"<li><input type='checkbox' {$tabindex} value='Second Choice' /><label>Second Choice</label></li>" .
"</ul><input type='hidden' name='{$input_field_name}' value='' /></div>";
@richardW8k
richardW8k / logging.php
Last active Aug 29, 2015
Logging statements for Gravity Forms.
View logging.php
<?php
add_filter( 'gform_pre_render', 'log_pre_render' );
function log_pre_render( $form ) {
GFCommon::log_debug( "log_pre_render(): \$form => " . print_r( $form, true ) );
return $form;
}
add_action( 'gform_pre_process', 'log_pre_process' );
function log_pre_process( $form ) {
@richardW8k
richardW8k / GF_Field_Button.php
Last active Aug 29, 2015
Testing the GF_Field class in Gravity Forms 1.9
View GF_Field_Button.php
<?php
/**
* Plugin Name: Gravity Forms Button Field
* Last Modified: 18/08/2014
*/
if ( ! class_exists( 'GFForms' ) ) {
die();
}
@richardW8k
richardW8k / extend_conditional_logic.php
Last active Aug 29, 2015
adding support for multi-input fields like the address field.
View extend_conditional_logic.php
/*
Trigger conditional logic by adding an onclick or onchange event to your custom field input or by using something like the following
jQuery('#input_8_1 :input').on('change', function () {
gf_apply_rules(8, [2, 3, 4]);
});
*/
add_filter( 'gform_pre_render', 'extend_conditional_logic_frontend' );
function extend_conditional_logic_frontend( $form ) {
@richardW8k
richardW8k / gform_chosen_options
Last active Dec 20, 2015
for use with Gravity Forms to set options for enhanced ui drop downs, add to theme's functions.php file
View gform_chosen_options
// set options for chosen e.g disable search or set width to use percentage
add_action('gform_pre_render','set_chosen_options');
function set_chosen_options($form){
if(wp_script_is('gforms_chosen',$list='queue')){
?>
<script>
gform.addFilter('gform_chosen_options','set_chosen_options_js');
function set_chosen_options_js(options,element){
//options.placeholder_text_single = 'Selectionner une Option'; // set default placeholder for blank first option
//options.search_contains = true; // search options for partial matches
@richardW8k
richardW8k / form_settings_status
Last active Dec 27, 2015
adds form active/inactive status switch to Gravity Forms form settings page
View form_settings_status
// display form active/inactive status on the form settings view
add_filter('gform_form_settings', 'form_settings_status', 10, 2);
function form_settings_status($settings, $form){
$form_info = RGFormsModel::get_form($form["id"]);
$status_val = intval($form_info->is_active);
$status = $status_val ? __('Active', 'gravityforms') : __('Inactive', 'gravityforms');
$settings["Form Basics"]["form_status"] = "<tr><th><label>Form status</label></th><td><img class='gform_active_icon' src='".GFCommon::get_base_url()."/images/active{$status_val}.png' style='cursor:pointer;margin:5px 0 0 0;float:left;' alt='{$status}' title='{$status}' onclick='ToggleActive( this, {$form["id"]} );' /> <span class='gform_status' style='margin:3px 0 0 10px;float:left;' >{$status}</span></td></tr>";
return $settings;
}
// add script to settings page to allow toggling of active/inactive status
@richardW8k
richardW8k / log_uploads
Last active Dec 28, 2015
Logs file uploads for single file and multi-file upload fields pre and post submission to the Gravity Forms logging add-on: http://www.gravityhelp.com/downloads/#Gravity_Forms_Logging_Tool
View log_uploads
add_action( 'gform_pre_submission_8', 'uploads_log_pre_submission' );
function uploads_log_pre_submission( $form ) {
foreach ( $form["fields"] as &$field ) {
if ( $field["type"] == "fileupload" ) {
$id = "input_".$field["id"];
if ( $field["multipleFiles"] ) {
if ( empty( $_POST["gform_uploaded_files"] ) )
continue;
@richardW8k
richardW8k / ListFieldMaskedInput
Last active Dec 28, 2015
Activate input masks for List Field columns.
View ListFieldMaskedInput
add_filter('gform_enqueue_scripts_11', 'list_columns_mask_script');
function list_columns_mask_script() {
wp_enqueue_script( 'gform_masked_input', array( 'jquery' ), false, true );
}
add_filter('gform_register_init_scripts_11', 'list_columns_mask_init');
function list_columns_mask_init( $form ) {
$init = "";
/**
* Add a function call for each list field column you want to activate an input mask for
* $init .= "ListFieldMaskedInput( formId, fieldId, column, 'mask' );";
You can’t perform that action at this time.