-
-
Save rynokins/8089d4d5641edd11fe09cbc50765df7c to your computer and use it in GitHub Desktop.
Addition to Jay Hoffmann's 'add_bootstrap_container_class' filter for Gravity Forms, replacing size classes with columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @description Gravity Forms size overides using Bootstrap Columns | |
* | |
* @author Jay Hoffmann (modified by Ryan Edwards) | |
* | |
* @source https://jayhoffmann.com/using-gravity-forms-bootstrap-styles/ | |
*/ | |
add_filter( 'gform_field_container', 'add_bootstrap_container_class', 10, 6 ); | |
function add_bootstrap_container_class( $field_container, $field, $form, $css_class, $style, $field_content ) { | |
$id = $field->id; | |
$field_id = is_admin() || empty( $form ) ? "field_{$id}" : 'field_' . $form['id'] . "_$id"; | |
switch ( $field->size ) { | |
case 'medium': | |
$col = 'col-8'; | |
break; | |
case 'small': | |
$col = 'col-4'; | |
break; | |
default: | |
$col = 'col'; | |
break; | |
} | |
if ( is_admin() ) { | |
return $field_container; | |
} else { | |
return '<li id="' . $field_id . '" class="' . $col . '">{FIELD_CONTENT}</li>'; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment