Skip to content

Instantly share code, notes, and snippets.

@bhwebworks
Created December 1, 2016 02:59
Show Gist options
  • Select an option

  • Save bhwebworks/b64bec11a0b451865edfb6d1953e8a53 to your computer and use it in GitHub Desktop.

Select an option

Save bhwebworks/b64bec11a0b451865edfb6d1953e8a53 to your computer and use it in GitHub Desktop.

Revisions

  1. @richardW8k richardW8k revised this gist Sep 8, 2016. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions all_fields_extra_options.php
    Original file line number Diff line number Diff line change
    @@ -19,12 +19,12 @@ function all_fields_extra_options( $value, $merge_tag, $options, $field, $raw_va
    $exclude = preg_match( "/exclude\[(.*?)\]/", $options , $exclude_match );
    $exclude_array = explode( ',', rgar( $exclude_match, 1 ) );

    $log = "all_fields_extra_options(): {$field['label']}({$field['id']} - {$field['type']}) - ";
    $log = "all_fields_extra_options(): {$field->label}({$field->id} - {$field->type}) - ";

    if ( $include && in_array( $field['id'], $include_array ) ) {
    switch ( $field['type'] ) {
    if ( $include && in_array( $field->id, $include_array ) ) {
    switch ( $field->type ) {
    case 'html' :
    $value = $field['content'];
    $value = $field->content;
    break;
    case 'section' :
    $value .= sprintf( '<tr bgcolor="#FFFFFF">
    @@ -33,7 +33,7 @@ function all_fields_extra_options( $value, $merge_tag, $options, $field, $raw_va
    <font style="font-family: sans-serif; font-size:12px;">%s</font>
    </td>
    </tr>
    ', $field['description'] );
    ', $field->description );
    break;
    case 'signature' :
    $url = GFSignature::get_signature_url( $raw_value );
    @@ -42,7 +42,7 @@ function all_fields_extra_options( $value, $merge_tag, $options, $field, $raw_va
    }
    GFCommon::log_debug( $log . 'included.' );
    }
    if ( $exclude && in_array( $field['id'], $exclude_array ) ) {
    if ( $exclude && in_array( $field->id, $exclude_array ) ) {
    GFCommon::log_debug( $log . 'excluded.' );
    return false;
    }
  2. @richardW8k richardW8k revised this gist Jun 7, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions all_fields_extra_options.php
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,8 @@
    * example: {all_fields:include[6]}
    * example: {all_fields:include[6],exclude[2,3]}
    */
    add_filter( 'gform_merge_tag_filter', 'all_fields_extra_options', 10, 4 );
    function all_fields_extra_options( $value, $merge_tag, $options, $field ) {
    add_filter( 'gform_merge_tag_filter', 'all_fields_extra_options', 11, 5 );
    function all_fields_extra_options( $value, $merge_tag, $options, $field, $raw_value ) {
    if ( $merge_tag != 'all_fields' ) {
    return $value;
    }
  3. @richardW8k richardW8k revised this gist Jun 7, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion all_fields_extra_options.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    /**
    * to exclude field from notification add 'exclude[ID]' option to {all_fields} tag
    * to include HTML field / Section Break field description in notification add 'include[ID]' option to {all_fields} tag
    * 'include[ID]' option includes HTML field / Section Break field description / Signature image in notification
    * see http://www.gravityhelp.com/documentation/page/Merge_Tags for a list of standard options
    * example: {all_fields:exclude[2,3]}
    * example: {all_fields:include[6]}
  4. @richardW8k richardW8k revised this gist Jun 7, 2014. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions all_fields_extra_options.php
    Original file line number Diff line number Diff line change
    @@ -24,11 +24,9 @@ function all_fields_extra_options( $value, $merge_tag, $options, $field ) {
    if ( $include && in_array( $field['id'], $include_array ) ) {
    switch ( $field['type'] ) {
    case 'html' :
    GFCommon::log_debug( $log . ' included.' );
    $value = $field['content'];
    break;
    case 'section' :
    GFCommon::log_debug( $log . ' description included.' );
    $value .= sprintf( '<tr bgcolor="#FFFFFF">
    <td width="20">&nbsp;</td>
    <td>
    @@ -37,10 +35,15 @@ function all_fields_extra_options( $value, $merge_tag, $options, $field ) {
    </tr>
    ', $field['description'] );
    break;
    case 'signature' :
    $url = GFSignature::get_signature_url( $raw_value );
    $value = "<img alt='signature' src='{$url}'/>";
    break;
    }
    GFCommon::log_debug( $log . 'included.' );
    }
    if ( $exclude && in_array( $field['id'], $exclude_array ) ) {
    GFCommon::log_debug( $log . ' excluded.' );
    GFCommon::log_debug( $log . 'excluded.' );
    return false;
    }
    return $value;
  5. @richardW8k richardW8k revised this gist Jun 7, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions all_fields_extra_options.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    /**
    * to exclude field from notifications add 'exclude[ID]' option to {all_fields} tag
    * to include HTML field / Section Break field description in notifications add 'include[ID]' option to {all_fields} tag
    * to exclude field from notification add 'exclude[ID]' option to {all_fields} tag
    * to include HTML field / Section Break field description in notification add 'include[ID]' option to {all_fields} tag
    * see http://www.gravityhelp.com/documentation/page/Merge_Tags for a list of standard options
    * example: {all_fields:exclude[2,3]}
    * example: {all_fields:include[6]}
  6. @richardW8k richardW8k revised this gist Jun 7, 2014. 1 changed file with 39 additions and 32 deletions.
    71 changes: 39 additions & 32 deletions all_fields_extra_options.php
    Original file line number Diff line number Diff line change
    @@ -1,40 +1,47 @@
    /**
    * to exclude field from notifications give field the CSS Class Name 'gf_exclude'
    * to include HTML field / Section Break field description in notifications give field the CSS Class Name 'gf_include'
    * add 'extra_options' option to {all_fields} tag. Example: {all_fields:extra_options}
    * to exclude field from notifications add 'exclude[ID]' option to {all_fields} tag
    * to include HTML field / Section Break field description in notifications add 'include[ID]' option to {all_fields} tag
    * see http://www.gravityhelp.com/documentation/page/Merge_Tags for a list of standard options
    * example: {all_fields:exclude[2,3]}
    * example: {all_fields:include[6]}
    * example: {all_fields:include[6],exclude[2,3]}
    */
    add_filter( 'gform_merge_tag_filter', 'all_fields_extra_options', 10, 4 );
    function all_fields_extra_options( $value, $merge_tag, $options, $field ) {
    $options_array = explode( ",", $options );
    $extra_options = in_array( "extra_options", $options_array );

    if ( $merge_tag == "all_fields" && $extra_options == true ) {
    $class_array = explode( " ", $field["cssClass"] );
    $include_class = in_array( "gf_include", $class_array );
    $exclude_class = in_array( "gf_exclude", $class_array );

    if ( $exclude_class == true ) {
    GFCommon::log_debug( "all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Field excluded." );
    return false;
    } elseif ( $include_class == true && $field["type"] == "html" ) {
    GFCommon::log_debug( "all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Field included." );
    return $field["content"];
    } elseif ( $include_class == true && $field["type"] == "section" ) {
    $field_value = $value . sprintf( '<tr bgcolor="#FFFFFF">
    <td width="20">&nbsp;</td>
    <td>
    <font style="font-family: sans-serif; font-size:12px;">%s</font>
    </td>
    </tr>
    ', $field["description"] );
    GFCommon::log_debug( "all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Description included." );
    return $field_value;
    } else {
    GFCommon::log_debug( "all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Field handled normally." );
    return $value;
    if ( $merge_tag != 'all_fields' ) {
    return $value;
    }

    // usage: {all_fields:include[ID],exclude[ID,ID]}
    $include = preg_match( "/include\[(.*?)\]/", $options , $include_match );
    $include_array = explode( ',', rgar( $include_match, 1 ) );

    $exclude = preg_match( "/exclude\[(.*?)\]/", $options , $exclude_match );
    $exclude_array = explode( ',', rgar( $exclude_match, 1 ) );

    $log = "all_fields_extra_options(): {$field['label']}({$field['id']} - {$field['type']}) - ";

    if ( $include && in_array( $field['id'], $include_array ) ) {
    switch ( $field['type'] ) {
    case 'html' :
    GFCommon::log_debug( $log . ' included.' );
    $value = $field['content'];
    break;
    case 'section' :
    GFCommon::log_debug( $log . ' description included.' );
    $value .= sprintf( '<tr bgcolor="#FFFFFF">
    <td width="20">&nbsp;</td>
    <td>
    <font style="font-family: sans-serif; font-size:12px;">%s</font>
    </td>
    </tr>
    ', $field['description'] );
    break;
    }
    }
    else
    return $value;
    if ( $exclude && in_array( $field['id'], $exclude_array ) ) {
    GFCommon::log_debug( $log . ' excluded.' );
    return false;
    }
    return $value;
    }
  7. @richardW8k richardW8k renamed this gist Jan 22, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  8. richardvav revised this gist Oct 16, 2013. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion all_fields_extra_options
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,13 @@ function all_fields_extra_options( $value, $merge_tag, $options, $field ) {
    GFCommon::log_debug( "all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Field included." );
    return $field["content"];
    } elseif ( $include_class == true && $field["type"] == "section" ) {
    $field_value = $value . sprintf( '<tr bgcolor="#FFFFFF"><td width="20">&nbsp;</td><td><font style="font-family: sans-serif; font-size:12px;">%s</font></td></tr>', $field["description"] );
    $field_value = $value . sprintf( '<tr bgcolor="#FFFFFF">
    <td width="20">&nbsp;</td>
    <td>
    <font style="font-family: sans-serif; font-size:12px;">%s</font>
    </td>
    </tr>
    ', $field["description"] );
    GFCommon::log_debug( "all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Description included." );
    return $field_value;
    } else {
  9. richardvav revised this gist Oct 16, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion all_fields_extra_options
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    /**
    * to exclude field from notifications give field the CSS Class Name 'gf_exclude'
    * to include HTML field in notifications give field the CSS Class Name 'gf_include'
    * to include HTML field / Section Break field description in notifications give field the CSS Class Name 'gf_include'
    * add 'extra_options' option to {all_fields} tag. Example: {all_fields:extra_options}
    * see http://www.gravityhelp.com/documentation/page/Merge_Tags for a list of standard options
    */
  10. richardvav revised this gist Oct 16, 2013. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions all_fields_extra_options
    Original file line number Diff line number Diff line change
    @@ -15,13 +15,17 @@ function all_fields_extra_options( $value, $merge_tag, $options, $field ) {
    $exclude_class = in_array( "gf_exclude", $class_array );

    if ( $exclude_class == true ) {
    GFCommon::log_debug("all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Field excluded.");
    GFCommon::log_debug( "all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Field excluded." );
    return false;
    } elseif ( $include_class == true && $field["type"] == "html" ) {
    GFCommon::log_debug("all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Field included.");
    GFCommon::log_debug( "all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Field included." );
    return $field["content"];
    } elseif ( $include_class == true && $field["type"] == "section" ) {
    $field_value = $value . sprintf( '<tr bgcolor="#FFFFFF"><td width="20">&nbsp;</td><td><font style="font-family: sans-serif; font-size:12px;">%s</font></td></tr>', $field["description"] );
    GFCommon::log_debug( "all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Description included." );
    return $field_value;
    } else {
    GFCommon::log_debug("all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Field handled normally.");
    GFCommon::log_debug( "all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Field handled normally." );
    return $value;
    }
    }
  11. richardvav revised this gist Oct 14, 2013. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion all_fields_extra_options
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,6 @@ function all_fields_extra_options( $value, $merge_tag, $options, $field ) {
    $extra_options = in_array( "extra_options", $options_array );

    if ( $merge_tag == "all_fields" && $extra_options == true ) {

    $class_array = explode( " ", $field["cssClass"] );
    $include_class = in_array( "gf_include", $class_array );
    $exclude_class = in_array( "gf_exclude", $class_array );
  12. richardvav revised this gist Oct 14, 2013. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions all_fields_extra_options
    Original file line number Diff line number Diff line change
    @@ -15,12 +15,16 @@ function all_fields_extra_options( $value, $merge_tag, $options, $field ) {
    $include_class = in_array( "gf_include", $class_array );
    $exclude_class = in_array( "gf_exclude", $class_array );

    if ( $exclude_class == true )
    if ( $exclude_class == true ) {
    GFCommon::log_debug("all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Field excluded.");
    return false;
    elseif ( $include_class == true && $field["type"] == "html" )
    } elseif ( $include_class == true && $field["type"] == "html" ) {
    GFCommon::log_debug("all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Field included.");
    return $field["content"];
    else
    } else {
    GFCommon::log_debug("all_fields_extra_options(): Field ID: {$field["id"]} (Type: {$field["type"]}) - Field handled normally.");
    return $value;
    }
    }
    else
    return $value;
  13. richardvav revised this gist Oct 14, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions all_fields_extra_options
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,8 @@
    */
    add_filter( 'gform_merge_tag_filter', 'all_fields_extra_options', 10, 4 );
    function all_fields_extra_options( $value, $merge_tag, $options, $field ) {
    $options_array = explode( ",", $options );
    $extra_options = in_array( "extra_options", $options_array );
    $options_array = explode( ",", $options );
    $extra_options = in_array( "extra_options", $options_array );

    if ( $merge_tag == "all_fields" && $extra_options == true ) {

  14. richardvav revised this gist Oct 14, 2013. 1 changed file with 10 additions and 12 deletions.
    22 changes: 10 additions & 12 deletions all_fields_extra_options
    Original file line number Diff line number Diff line change
    @@ -1,25 +1,23 @@
    /**
    * to include HTML fields or exclude fields from notifications
    * give field the CSS Class Name 'gf_exclude' and add the 'exclude' option to the {all_fields} tag
    * give HTML field the CSS Class Name 'gf_include' and add the 'html' option to the {all_fields} tag
    * merge tag options can be stacked. example: {all_fields:exclude,html}
    * to exclude field from notifications give field the CSS Class Name 'gf_exclude'
    * to include HTML field in notifications give field the CSS Class Name 'gf_include'
    * add 'extra_options' option to {all_fields} tag. Example: {all_fields:extra_options}
    * see http://www.gravityhelp.com/documentation/page/Merge_Tags for a list of standard options
    */
    add_filter( 'gform_merge_tag_filter', 'all_fields_extra_options', 10, 4 );
    function all_fields_extra_options( $value, $merge_tag, $options, $field ) {
    if ( $merge_tag == "all_fields" ) {
    //break string into array and then return TRUE if string is found in the array
    $options_array = explode( ",", $options );
    $include_html = in_array( "html", $options_array );
    $exclude = in_array( "exclude", $options_array );
    $options_array = explode( ",", $options );
    $extra_options = in_array( "extra_options", $options_array );

    if ( $merge_tag == "all_fields" && $extra_options == true ) {

    $class_array = explode( " ", $field["cssClass"] );
    $include_class = in_array( "gf_include", $class_array );
    $exclude_class = in_array( "gf_exclude", $class_array );

    if ( $exclude == true && $exclude_class == true )
    if ( $exclude_class == true )
    return false;
    elseif ( $include_html == true && $include_class == true && $field["type"] == "html" )
    elseif ( $include_class == true && $field["type"] == "html" )
    return $field["content"];
    else
    return $value;
  15. richardvav revised this gist Oct 13, 2013. 1 changed file with 17 additions and 15 deletions.
    32 changes: 17 additions & 15 deletions all_fields_extra_options
    Original file line number Diff line number Diff line change
    @@ -1,25 +1,27 @@
    //to exclude a field from notifications give it the CSS Class Name 'gf_exclude' and add the 'exclude' option to the {all_fields} tag
    //to include a HTML field in notifications give it the CSS Class Name 'gf_include' and add the 'html' option to the {all_fields} tag
    //merge tag options can be stacked. example: {all_fields:exclude,html}
    //see http://www.gravityhelp.com/documentation/page/Merge_Tags for a list of standard options
    /**
    * to include HTML fields or exclude fields from notifications
    * give field the CSS Class Name 'gf_exclude' and add the 'exclude' option to the {all_fields} tag
    * give HTML field the CSS Class Name 'gf_include' and add the 'html' option to the {all_fields} tag
    * merge tag options can be stacked. example: {all_fields:exclude,html}
    * see http://www.gravityhelp.com/documentation/page/Merge_Tags for a list of standard options
    */
    add_filter( 'gform_merge_tag_filter', 'all_fields_extra_options', 10, 4 );
    function all_fields_extra_options( $value, $merge_tag, $options, $field ) {
    if ( $merge_tag == "all_fields" ) {
    $options_array = explode( ",", $options ); //breaks options into an array
    $include_html = in_array( "html", $options_array ); //returns TRUE if 'html' is found in the array
    $exclude = in_array( "exclude", $options_array ); //returns TRUE if 'exclude' is found in the array
    //break string into array and then return TRUE if string is found in the array
    $options_array = explode( ",", $options );
    $include_html = in_array( "html", $options_array );
    $exclude = in_array( "exclude", $options_array );

    $class_array = explode( " ", $field["cssClass"] ); //breaks the fields CSS classes into an array
    $include_class = in_array( "gf_include", $class_array ); //returns TRUE if 'gf_include' is found in the array
    $exclude_class = in_array( "gf_exclude", $class_array ); //returns TRUE if 'gf_exclude' is found in the array
    $class_array = explode( " ", $field["cssClass"] );
    $include_class = in_array( "gf_include", $class_array );
    $exclude_class = in_array( "gf_exclude", $class_array );

    if ( $exclude == true && $exclude_class == true ) {
    //if merge tag has 'exclude' option and field has 'gf_exclude' class then don't return the field
    if ( $exclude == true && $exclude_class == true )
    return false;
    } elseif ( $include_html == true && $include_class == true && $field["type"] == "html" ) {
    //if merge tag has 'html' option and field is a HTML field with the 'gf_include' class then return the field content
    elseif ( $include_html == true && $include_class == true && $field["type"] == "html" )
    return $field["content"];
    } else
    else
    return $value;
    }
    else
  16. richardvav revised this gist Oct 12, 2013. 2 changed files with 27 additions and 13 deletions.
    27 changes: 27 additions & 0 deletions all_fields_extra_options
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    //to exclude a field from notifications give it the CSS Class Name 'gf_exclude' and add the 'exclude' option to the {all_fields} tag
    //to include a HTML field in notifications give it the CSS Class Name 'gf_include' and add the 'html' option to the {all_fields} tag
    //merge tag options can be stacked. example: {all_fields:exclude,html}
    //see http://www.gravityhelp.com/documentation/page/Merge_Tags for a list of standard options
    add_filter( 'gform_merge_tag_filter', 'all_fields_extra_options', 10, 4 );
    function all_fields_extra_options( $value, $merge_tag, $options, $field ) {
    if ( $merge_tag == "all_fields" ) {
    $options_array = explode( ",", $options ); //breaks options into an array
    $include_html = in_array( "html", $options_array ); //returns TRUE if 'html' is found in the array
    $exclude = in_array( "exclude", $options_array ); //returns TRUE if 'exclude' is found in the array

    $class_array = explode( " ", $field["cssClass"] ); //breaks the fields CSS classes into an array
    $include_class = in_array( "gf_include", $class_array ); //returns TRUE if 'gf_include' is found in the array
    $exclude_class = in_array( "gf_exclude", $class_array ); //returns TRUE if 'gf_exclude' is found in the array

    if ( $exclude == true && $exclude_class == true ) {
    //if merge tag has 'exclude' option and field has 'gf_exclude' class then don't return the field
    return false;
    } elseif ( $include_html == true && $include_class == true && $field["type"] == "html" ) {
    //if merge tag has 'html' option and field is a HTML field with the 'gf_include' class then return the field content
    return $field["content"];
    } else
    return $value;
    }
    else
    return $value;
    }
    13 changes: 0 additions & 13 deletions include_html_all_fields
    Original file line number Diff line number Diff line change
    @@ -1,13 +0,0 @@
    //to include a HTML field in notifications assign the field the CSS Class Name 'gf_include' and then use the {all_fields:html} merge tag
    add_filter( 'gform_merge_tag_filter', 'include_html_all_fields', 10, 4 );
    function include_html_all_fields( $value, $merge_tag, $options, $field ) {
    $options_array = explode( ",", $options ); //breaks options into an array
    $include = in_array( "html", $options_array ); //returns TRUE if 'html' is found in the array
    $class_array = explode( " ", $field["cssClass"] ); //breaks the fields CSS classes into an array
    $include_class = in_array( "gf_include", $class_array ); //returns TRUE if 'gf_include' is found in the array

    if ( $merge_tag == "all_fields" && $include == true && $include_class == true && $field["type"] == "html" )
    return $field["content"];
    else
    return $value;
    }
  17. richardvav created this gist Oct 12, 2013.
    13 changes: 13 additions & 0 deletions include_html_all_fields
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    //to include a HTML field in notifications assign the field the CSS Class Name 'gf_include' and then use the {all_fields:html} merge tag
    add_filter( 'gform_merge_tag_filter', 'include_html_all_fields', 10, 4 );
    function include_html_all_fields( $value, $merge_tag, $options, $field ) {
    $options_array = explode( ",", $options ); //breaks options into an array
    $include = in_array( "html", $options_array ); //returns TRUE if 'html' is found in the array
    $class_array = explode( " ", $field["cssClass"] ); //breaks the fields CSS classes into an array
    $include_class = in_array( "gf_include", $class_array ); //returns TRUE if 'gf_include' is found in the array

    if ( $merge_tag == "all_fields" && $include == true && $include_class == true && $field["type"] == "html" )
    return $field["content"];
    else
    return $value;
    }