Changeset 3077760
- Timestamp:
- 04/26/2024 04:49:45 PM (2 years ago)
- Location:
- gf-no-duplicates/trunk
- Files:
-
- 2 added
- 3 edited
-
class-gf-no-duplicates.php (modified) (7 diffs)
-
gf-no-duplicates.php (modified) (2 diffs)
-
images (added)
-
images/menu-icon.svg (added)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gf-no-duplicates/trunk/class-gf-no-duplicates.php
r3017096 r3077760 1 1 <?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 */ 2 10 3 11 defined( 'ABSPATH' ) || die(); … … 6 14 GFForms::include_addon_framework(); 7 15 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 */ 8 25 class GF_No_Duplicates extends GFAddOn { 9 26 … … 112 129 113 130 return self::$_instance; 114 115 131 } 116 132 … … 126 142 add_filter( 'gform_validation', array( $this, 'validate_token' ), 99999, 1 ); // Low priority required to avoid User Registration validation overriding our validation result. 127 143 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 ); 128 180 } 129 181 … … 262 314 $validation_result['is_valid'] = false; 263 315 // Add the token to the $form object for later usage. 264 $form['failed_gnd_token'] = $gnd_token;316 $form['failed_gnd_token'] = $gnd_token; 265 317 $this->log_debug( __METHOD__ . "(): Form validation set as failed and {$gnd_token} added to the form object as value for failed_gnd_token" ); 266 318 } … … 283 335 $current_page_url = RGFormsModel::get_current_page_url(); 284 336 // 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; 286 343 287 344 // Filter to allow customization of the warning message displayed. … … 321 378 return $form; 322 379 } 323 324 380 } -
gf-no-duplicates/trunk/gf-no-duplicates.php
r3017096 r3077760 3 3 * Plugin Name: GF No Duplicates 4 4 * Description: Prevents duplicate Gravity Forms submissions caused by the same POST request sent more than once. 5 * Version: 1. 1.15 * Version: 1.2 6 6 * Author: Samuel Aguilera 7 7 * Author URI: https://www.samuelaguilera.com … … 33 33 34 34 // Defines the current version of the GF No Duplicates. 35 define( 'GF_NO_DUPLICATES_VERSION', '1. 1.1' );35 define( 'GF_NO_DUPLICATES_VERSION', '1.2' ); 36 36 37 37 // Defines the minimum version of Gravity Forms required to run GF No Duplicates. -
gf-no-duplicates/trunk/readme.txt
r3030026 r3077760 3 3 Tags: gravityforms, Gravity Forms, duplicated submission, duplicated entry, duplicates 4 4 Requires at least: 4.9 5 Tested up to: 6. 4.36 Stable tag: 1. 1.15 Tested up to: 6.5.2 6 Stable tag: 1.2 7 7 Requires PHP: 7.0 8 8 License: GPLv3 … … 44 44 45 45 * Install and activate it as you do with any other plugin. 46 * Enjoy! No settings! 46 * Enjoy! 47 48 Optionally, you can customize the duplicate submission message shown to users from the settings page or using a filter (see the FAQ). 47 49 48 50 = Note about Caching = … … 60 62 = Is it possible to customize the message shown for duplicate submissions? = 61 63 62 Yes. You can use the gnd_duplicate_submission_message filter for it. See the example below:64 Yes. 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: 63 65 64 66 `add_filter( 'gnd_duplicate_submission_message', function( $message, $form ) { … … 67 69 }, 10, 2 );` 68 70 71 Using the filter will override the default message and any custom message that you may have added in the settings page. 72 69 73 == Changelog == 74 75 = 1.2 = 76 77 * Added a settings page to allow customizing the duplicate submission message. 70 78 71 79 = 1.1.1 =
Note: See TracChangeset
for help on using the changeset viewer.