Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save anythinggraphic/6106f321a6c1e92b5fe7 to your computer and use it in GitHub Desktop.

Select an option

Save anythinggraphic/6106f321a6c1e92b5fe7 to your computer and use it in GitHub Desktop.

Revisions

  1. anythinggraphic revised this gist May 12, 2017. 2 changed files with 14 additions and 2 deletions.
    13 changes: 13 additions & 0 deletions gravity-forms-notification-popup-keep-form.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    <?php

    //* OPTIONAL STEP - Keep the form disappearing.
    //* Gravity Forms notification popup instead of the page redirect or AJAX notification.
    //* Props to @WilliamAlexander in the comments
    //* @link https://anythinggraphic.net/gravity-forms-notification-popup

    add_filter( 'gform_confirmation', 'ag_custom_confirmation', 10, 4 );
    function ag_custom_confirmation( $confirmation, $form, $entry, $ajax ) {
    add_filter( 'wp_footer', 'ag_overlay');
    $thisform = $form['id'];
    return '[gravityform id=' . $thisform . ' title=false description=false]' . $confirmation . '<a href="#" rel="nofollow">OK</a>';
    }
    3 changes: 1 addition & 2 deletions gravity-forms-notification-popup.css
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,8 @@
    display: block;
    float: left;
    height: 100%;
    left: 0;
    position: fixed;
    top: 0;
    top: 0; left: 0;
    width: 100%;
    z-index: 99;
    }
  2. anythinggraphic revised this gist Aug 3, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gravity-forms-notification-popup.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    <?php
    //* Gravity Forms notification pop-up instead of the page redirect or AJAX notification
    //* @link https://anythinggraphic.net/gravity-forms-notification-pop-up
    //* Gravity Forms notification popup instead of the page redirect or AJAX notification
    //* @link https://anythinggraphic.net/gravity-forms-notification-popup

    /* Override the default Gravity Forms confirmation behavior, displaying it in a popup. Remember to style the divs.
    ----------------------------------------------------------------------------------------*/
  3. anythinggraphic revised this gist Aug 3, 2015. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions gravity-forms-notification-popup.css
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,14 @@
    #overlay {
    background: #000;
    background: rgba(0, 0, 0, 0.3);
    display: block;
    float: left;
    height: 100%;
    left: 0;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 99;
    background: #000;
    background: rgba(0, 0, 0, 0.3);
    display: block;
    float: left;
    height: 100%;
    left: 0;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 99;
    }

    #gform-notification {
  4. anythinggraphic revised this gist Aug 1, 2015. 1 changed file with 32 additions and 0 deletions.
    32 changes: 32 additions & 0 deletions gravity-forms-notification-popup.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    #overlay {
    background: #000;
    background: rgba(0, 0, 0, 0.3);
    display: block;
    float: left;
    height: 100%;
    left: 0;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 99;
    }

    #gform-notification {
    background: #fff;
    border-radius: 10px;
    display: block;
    margin: auto;
    max-height: 237px;
    max-width: 520px;
    padding: 61px;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    text-align: center;
    width: 100%;
    z-index: 101;
    }

    #gform-notification .button {
    margin: 20px 0 0;
    padding: 12px 24px;
    }
  5. anythinggraphic created this gist Aug 1, 2015.
    27 changes: 27 additions & 0 deletions gravity-forms-notification-popup.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    <?php
    //* Gravity Forms notification pop-up instead of the page redirect or AJAX notification
    //* @link https://anythinggraphic.net/gravity-forms-notification-pop-up

    /* Override the default Gravity Forms confirmation behavior, displaying it in a popup. Remember to style the divs.
    ----------------------------------------------------------------------------------------*/
    add_filter( 'gform_confirmation', 'ag_custom_confirmation', 10, 4 );
    function ag_custom_confirmation( $confirmation, $form, $entry, $ajax ) {
    add_filter( 'genesis_after_footer', 'ag_overlay');
    return '<div id="gform-notification">' . $confirmation . '<a class="button" href="#">OK</a></div>';
    }

    /* Add script to remove the overlay and confirmation message once the button in the popup is clicked.
    ----------------------------------------------------------------------------------------*/
    function ag_overlay() {
    echo '<div id="overlay"></div>';
    echo '
    <script type="text/javascript">
    jQuery("body").addClass("message-sent");
    jQuery("#gform-notification a").click(function() {
    jQuery("#overlay,#gform-notification").fadeOut("normal", function() {
    $(this).remove();
    });
    });
    </script>
    ';
    }