spivurno
8/4/2014 - 8:18 PM

Gravity Wiz // Gravity Forms // gw_has_css_class()

Gravity Wiz // Gravity Forms // gw_has_css_class()

<?php
/**
 * Gravity Wiz // Gravity Forms // gw_has_css_class()
 *
 * A simple function to determine whether a form or field object has the specified CSS class.
 *
 * @author    David Smith <david@gravitywiz.com>
 * @license   GPL-2.0+
 * @link      http://gravitywiz.com/...
 */
if( ! function_exists( 'gw_has_css_class' ) ) {
    function gw_has_css_class( $form_or_field, $class ) {
        if( ! isset( $form_or_field['cssClass'] ) ) {
            return false;
        } else {
            $classes = array_map( 'trim', explode( ' ', $form_or_field['cssClass'] ) );
            return in_array( $class, $classes );
        }
    }
}