Plugin Directory

Changeset 3077760


Ignore:
Timestamp:
04/26/2024 04:49:45 PM (2 years ago)
Author:
samuelaguilera
Message:

1.2 release.

Location:
gf-no-duplicates/trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • gf-no-duplicates/trunk/class-gf-no-duplicates.php

    r3017096 r3077760  
    11<?php
     2/**
     3 * GF No Duplicates Add-On.
     4 *
     5 * @since     1.0
     6 * @package GF No Duplicates
     7 * @author    Samuel Aguilera
     8 * @copyright Copyright (c) 2022 Samuel Aguilera
     9 */
    210
    311defined( 'ABSPATH' ) || die();
     
    614GFForms::include_addon_framework();
    715
     16/**
     17 * Class GF_No_Duplicates
     18 *
     19 * Primary class to manage the GF No Duplicates Add-On.
     20 *
     21 * @since 1.0
     22 *
     23 * @uses GFAddOn
     24 */
    825class GF_No_Duplicates extends GFAddOn {
    926
     
    112129
    113130        return self::$_instance;
    114 
    115131    }
    116132
     
    126142        add_filter( 'gform_validation', array( $this, 'validate_token' ), 99999, 1 ); // Low priority required to avoid User Registration validation overriding our validation result.
    127143        add_filter( 'gform_pre_render', array( $this, 'replace_form_string_handler' ), 99999, 1 ); // Try to run later than any other snippet using the same filter.
     144    }
     145
     146
     147
     148    /**
     149     * Return the plugin's icon for the plugin/form settings menu.
     150     *
     151     * @return string
     152     */
     153    public function get_menu_icon() {
     154        return file_get_contents( $this->get_base_path() . '/images/menu-icon.svg' ); // phpcs:ignore
     155    }
     156
     157    /**
     158     * Configures the settings which should be rendered on the add-on settings tab.
     159     *
     160     * @return array
     161     */
     162    public function plugin_settings_fields() {
     163
     164        return array(
     165            array(
     166                'title'       => esc_html__( 'GF No Duplicate Settings', 'gf-no-duplicates' ),
     167                'description' => '<p style="text-align: left;">' . esc_html__( 'The following optional setting allows you to customize the message shown to visitors when a duplicate submission is stopped. Leave it empty to use the default message.', 'gf-no-duplicates' ) . '</p>',
     168                'fields'      => array(
     169                    array(
     170                        'type'          => 'textarea',
     171                        'name'          => 'duplicate_submission_message',
     172                        'label'         => esc_html__( 'Duplicate Submission Message', 'gf-no-duplicates' ),
     173                        'default_value' => '',
     174                        'use_editor'    => true,
     175                        'class'         => 'large',
     176                    ),
     177                ),
     178            ),
     179        );
    128180    }
    129181
     
    262314            $validation_result['is_valid'] = false;
    263315            // Add the token to the $form object for later usage.
    264             $form['failed_gnd_token']      = $gnd_token;
     316            $form['failed_gnd_token'] = $gnd_token;
    265317            $this->log_debug( __METHOD__ . "(): Form validation set as failed and {$gnd_token} added to the form object as value for failed_gnd_token" );
    266318        }
     
    283335            $current_page_url = RGFormsModel::get_current_page_url();
    284336            // translators: Placeholders are HTML tags for a link. Just leave them on the same position.
    285             $message = sprintf( wp_filter_nohtml_kses( __( 'A duplicate submission has been aborted! If you really want to submit the form again, please %1$sclick here%2$s.', 'gf-no-duplicates' ) ), "<a href='$current_page_url' rel='noopener noreferrer'>", '</a>' );
     337            $default_message = sprintf( wp_filter_nohtml_kses( __( 'A duplicate submission has been aborted! If you really want to submit the form again, please %1$sclick here%2$s.', 'gf-no-duplicates' ) ), "<a href='$current_page_url' rel='noopener noreferrer'>", '</a>' );
     338            // Get custom message from settings.
     339            $custom_message = $this->get_plugin_setting( 'duplicate_submission_message' );
     340
     341            // Use custom message if there's any saved.
     342            $message = empty( $custom_message ) ? $default_message : $custom_message;
    286343
    287344            // Filter to allow customization of the warning message displayed.
     
    321378        return $form;
    322379    }
    323 
    324380}
  • gf-no-duplicates/trunk/gf-no-duplicates.php

    r3017096 r3077760  
    33 * Plugin Name: GF No Duplicates
    44 * Description: Prevents duplicate Gravity Forms submissions caused by the same POST request sent more than once.
    5  * Version: 1.1.1
     5 * Version: 1.2
    66 * Author: Samuel Aguilera
    77 * Author URI: https://www.samuelaguilera.com
     
    3333
    3434// Defines the current version of the GF No Duplicates.
    35 define( 'GF_NO_DUPLICATES_VERSION', '1.1.1' );
     35define( 'GF_NO_DUPLICATES_VERSION', '1.2' );
    3636
    3737// Defines the minimum version of Gravity Forms required to run GF No Duplicates.
  • gf-no-duplicates/trunk/readme.txt

    r3030026 r3077760  
    33Tags: gravityforms, Gravity Forms, duplicated submission, duplicated entry, duplicates
    44Requires at least: 4.9
    5 Tested up to: 6.4.3
    6 Stable tag: 1.1.1
     5Tested up to: 6.5.2
     6Stable tag: 1.2
    77Requires PHP: 7.0
    88License: GPLv3
     
    4444
    4545* Install and activate it as you do with any other plugin.
    46 * Enjoy! No settings!
     46* Enjoy!
     47
     48Optionally, you can customize the duplicate submission message shown to users from the settings page or using a filter (see the FAQ).
    4749
    4850= Note about Caching =
     
    6062= Is it possible to customize the message shown for duplicate submissions? =
    6163
    62 Yes. You can use the gnd_duplicate_submission_message filter for it. See the example below:
     64Yes. You can do this from the Forms > Settings > GF No Duplicates settings page. Or using the gnd_duplicate_submission_message filter. See the example below:
    6365
    6466`add_filter( 'gnd_duplicate_submission_message', function( $message, $form ) {
     
    6769}, 10, 2 );`
    6870
     71Using the filter will override the default message and any custom message that you may have added in the settings page.
     72
    6973== Changelog ==
     74
     75= 1.2 =
     76
     77* Added a settings page to allow customizing the duplicate submission message.
    7078
    7179= 1.1.1 =
Note: See TracChangeset for help on using the changeset viewer.