Changeset 3435083
- Timestamp:
- 01/08/2026 11:41:33 AM (3 months ago)
- Location:
- recras
- Files:
-
- 12 edited
- 1 copied
-
tags/6.5.0 (copied) (copied from recras/trunk)
-
tags/6.5.0/changelog.md (modified) (1 diff)
-
tags/6.5.0/js/recras.js (modified) (5 diffs)
-
tags/6.5.0/readme.txt (modified) (2 diffs)
-
tags/6.5.0/recras-wordpress-plugin.php (modified) (1 diff)
-
tags/6.5.0/src/ContactForm.php (modified) (6 diffs)
-
tags/6.5.0/src/Plugin.php (modified) (1 diff)
-
trunk/changelog.md (modified) (1 diff)
-
trunk/js/recras.js (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/recras-wordpress-plugin.php (modified) (1 diff)
-
trunk/src/ContactForm.php (modified) (6 diffs)
-
trunk/src/Plugin.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
recras/tags/6.5.0/changelog.md
r3434941 r3435083 1 1 # Changelog 2 3 ## 6.5.0 (2026-01-08) 4 * Add anti-spam check to contact forms 2 5 3 6 ## 6.4.3 (2026-01-08) -
recras/tags/6.5.0/js/recras.js
r3369571 r3435083 2 2 { 3 3 const els = document.querySelectorAll('.' + className); 4 for (let i = 0; i < els.length; i++) {5 el s[i].parentNode.removeChild(els[i]);4 for (let el of els) { 5 el.parentNode.removeChild(el); 6 6 } 7 7 } … … 15 15 let elements = {}; 16 16 17 for (let i = 0; i < formElements.length; i++) {18 if ( formElements[i].type === 'submit') {17 for (let el of formElements) { 18 if (el.type === 'submit') { 19 19 continue; 20 20 } 21 if ( formElements[i].value === '' && formElements[i].required === false) {22 formElements[i].value = null;21 if (el.value === '' && el.required === false) { 22 el.value = null; 23 23 } 24 if ( formElements[i].type === 'radio') {25 const selected = document.querySelector('input[name="' + formElements[i].name + '"]:checked');26 elements[ formElements[i].name] = selected.value;27 } else if ( formElements[i].type === 'checkbox') {28 elements[ formElements[i].name] = [];29 const checked = document.querySelectorAll('input[name="' + formElements[i].name + '"]:checked');24 if (el.type === 'radio') { 25 const selected = document.querySelector('input[name="' + el.name + '"]:checked'); 26 elements[el.name] = selected.value; 27 } else if (el.type === 'checkbox') { 28 elements[el.name] = []; 29 const checked = document.querySelectorAll('input[name="' + el.name + '"]:checked'); 30 30 if (checked.length === 0) { 31 const isRequired = document.querySelector('input[name="' + formElements[i].name + '"][data-required="1"]');31 const isRequired = document.querySelector('input[name="' + el.name + '"][data-required="1"]'); 32 32 if (isRequired) { 33 33 formEl 34 .querySelector('[name="' + formElements[i].name + '"]')34 .querySelector('[name="' + el.name + '"]') 35 35 .parentNode 36 36 .insertAdjacentHTML('beforeend', '<span class="recras-error">' + recras_l10n.checkboxRequired + '</span>'); … … 38 38 } 39 39 } 40 for (let j = 0; j < checked.length; j++) {41 elements[ formElements[i].name].push(checked[j].value);40 for (let c of checked) { 41 elements[el.name].push(c.value); 42 42 } 43 43 } else { 44 elements[ formElements[i].name] = formElements[i].value;44 elements[el.name] = el.value; 45 45 } 46 46 } … … 56 56 xhr.open('POST', 'https://' + instance + '/api2/contactformulieren/' + formEl.dataset.formid + '/opslaan'); 57 57 xhr.send(JSON.stringify(elements)); 58 xhr.onreadystatechange = function (){58 xhr.onreadystatechange = function () { 59 59 if (xhr.readyState === 4) { 60 60 removeElsWithClass('recras-loading'); … … 112 112 if (typeof Pikaday === 'function') { 113 113 const dateEls = document.querySelectorAll('.recras-input-date'); 114 for (let i = 0; i < dateEls.length; i++) {115 initPikaday( dateEls[i]);114 for (let el of dateEls) { 115 initPikaday(el); 116 116 } 117 117 } -
recras/tags/6.5.0/readme.txt
r3434941 r3435083 3 3 Tags: recras, recreation, reservation, booking, voucher 4 4 Tested up to: 6.9 5 Stable tag: 6. 4.35 Stable tag: 6.5.0 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 75 75 == Changelog == 76 76 77 = 6.5.0 = 78 * Add anti-spam check to contact forms 79 77 80 = 6.4.3 = 78 81 * Fixed error when using an invalid Recras domain -
recras/tags/6.5.0/recras-wordpress-plugin.php
r3434941 r3435083 3 3 Plugin Name: Recras 4 4 Plugin URI: https://www.recras.com/ 5 Version: 6. 4.35 Version: 6.5.0 6 6 Description: Easily integrate your Recras data into your own site 7 7 Requires at least: 6.7 -
recras/tags/6.5.0/src/ContactForm.php
r3432851 r3435083 24 24 * @return object|string 25 25 */ 26 public static function getForm(string $instance, int $id )26 public static function getForm(string $instance, int $id, bool $useCache = true) 27 27 { 28 28 $form = Transient::get($instance . '_contactform_' . $id . '_v2'); 29 if ($form === false ) {29 if ($form === false || !$useCache) { 30 30 try { 31 31 $form = Http::get($instance, 'contactformulieren/' . $id . '?embed=Velden'); … … 65 65 66 66 // Get basic info for the form 67 $form = self::getForm($instance, $attributes['id'] );67 $form = self::getForm($instance, $attributes['id'], false); 68 68 if (is_string($form)) { 69 69 // Not a form, but an error … … 140 140 ]; 141 141 142 return self::generateForm($attributes['id'], $formFields, $ options);142 return self::generateForm($attributes['id'], $formFields, $form->nonce ?? null, $options); 143 143 } 144 144 … … 206 206 * Generate a contact form 207 207 */ 208 public static function generateForm(int $formID, array $formFields, array $options): string208 public static function generateForm(int $formID, array $formFields, ?string $nonce = null, array $options): string 209 209 { 210 210 global $recrasPlugin; … … 437 437 } 438 438 $html .= self::generateEndTag($options['element']); 439 if ($nonce) { 440 $html .= '<input type="hidden" name="nonce" value="' . $nonce . '">'; 441 } 439 442 440 443 $html .= '<input type="submit" value="' . $options['submitText'] . '">'; … … 452 455 const clearRadioEls = document.querySelectorAll(".clearRadioChoice"); 453 456 if (clearRadioEls.length) { 454 for (let i = 0; i < clearRadioEls.length; i++) {455 clearRadioEls[i].addEventListener("click", function() {457 for (let el of clearRadioEls) { 458 el.addEventListener("click", function() { 456 459 const radioElChecked = this.parentNode.querySelector("input[type=\'radio\']:checked"); 457 460 if (radioElChecked) { -
recras/tags/6.5.0/src/Plugin.php
r3432851 r3435083 328 328 // Generic functionality & localisation script 329 329 $scriptName = 'recras-frontend'; 330 wp_register_script($scriptName, $this->baseUrl . '/js/recras.js', ['jquery'], '6. 4.0', true);330 wp_register_script($scriptName, $this->baseUrl . '/js/recras.js', ['jquery'], '6.5.0', true); 331 331 wp_localize_script($scriptName, 'recras_l10n', $localisation); 332 332 wp_enqueue_script($scriptName); -
recras/trunk/changelog.md
r3434941 r3435083 1 1 # Changelog 2 3 ## 6.5.0 (2026-01-08) 4 * Add anti-spam check to contact forms 2 5 3 6 ## 6.4.3 (2026-01-08) -
recras/trunk/js/recras.js
r3369571 r3435083 2 2 { 3 3 const els = document.querySelectorAll('.' + className); 4 for (let i = 0; i < els.length; i++) {5 el s[i].parentNode.removeChild(els[i]);4 for (let el of els) { 5 el.parentNode.removeChild(el); 6 6 } 7 7 } … … 15 15 let elements = {}; 16 16 17 for (let i = 0; i < formElements.length; i++) {18 if ( formElements[i].type === 'submit') {17 for (let el of formElements) { 18 if (el.type === 'submit') { 19 19 continue; 20 20 } 21 if ( formElements[i].value === '' && formElements[i].required === false) {22 formElements[i].value = null;21 if (el.value === '' && el.required === false) { 22 el.value = null; 23 23 } 24 if ( formElements[i].type === 'radio') {25 const selected = document.querySelector('input[name="' + formElements[i].name + '"]:checked');26 elements[ formElements[i].name] = selected.value;27 } else if ( formElements[i].type === 'checkbox') {28 elements[ formElements[i].name] = [];29 const checked = document.querySelectorAll('input[name="' + formElements[i].name + '"]:checked');24 if (el.type === 'radio') { 25 const selected = document.querySelector('input[name="' + el.name + '"]:checked'); 26 elements[el.name] = selected.value; 27 } else if (el.type === 'checkbox') { 28 elements[el.name] = []; 29 const checked = document.querySelectorAll('input[name="' + el.name + '"]:checked'); 30 30 if (checked.length === 0) { 31 const isRequired = document.querySelector('input[name="' + formElements[i].name + '"][data-required="1"]');31 const isRequired = document.querySelector('input[name="' + el.name + '"][data-required="1"]'); 32 32 if (isRequired) { 33 33 formEl 34 .querySelector('[name="' + formElements[i].name + '"]')34 .querySelector('[name="' + el.name + '"]') 35 35 .parentNode 36 36 .insertAdjacentHTML('beforeend', '<span class="recras-error">' + recras_l10n.checkboxRequired + '</span>'); … … 38 38 } 39 39 } 40 for (let j = 0; j < checked.length; j++) {41 elements[ formElements[i].name].push(checked[j].value);40 for (let c of checked) { 41 elements[el.name].push(c.value); 42 42 } 43 43 } else { 44 elements[ formElements[i].name] = formElements[i].value;44 elements[el.name] = el.value; 45 45 } 46 46 } … … 56 56 xhr.open('POST', 'https://' + instance + '/api2/contactformulieren/' + formEl.dataset.formid + '/opslaan'); 57 57 xhr.send(JSON.stringify(elements)); 58 xhr.onreadystatechange = function (){58 xhr.onreadystatechange = function () { 59 59 if (xhr.readyState === 4) { 60 60 removeElsWithClass('recras-loading'); … … 112 112 if (typeof Pikaday === 'function') { 113 113 const dateEls = document.querySelectorAll('.recras-input-date'); 114 for (let i = 0; i < dateEls.length; i++) {115 initPikaday( dateEls[i]);114 for (let el of dateEls) { 115 initPikaday(el); 116 116 } 117 117 } -
recras/trunk/readme.txt
r3434941 r3435083 3 3 Tags: recras, recreation, reservation, booking, voucher 4 4 Tested up to: 6.9 5 Stable tag: 6. 4.35 Stable tag: 6.5.0 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 75 75 == Changelog == 76 76 77 = 6.5.0 = 78 * Add anti-spam check to contact forms 79 77 80 = 6.4.3 = 78 81 * Fixed error when using an invalid Recras domain -
recras/trunk/recras-wordpress-plugin.php
r3434941 r3435083 3 3 Plugin Name: Recras 4 4 Plugin URI: https://www.recras.com/ 5 Version: 6. 4.35 Version: 6.5.0 6 6 Description: Easily integrate your Recras data into your own site 7 7 Requires at least: 6.7 -
recras/trunk/src/ContactForm.php
r3432851 r3435083 24 24 * @return object|string 25 25 */ 26 public static function getForm(string $instance, int $id )26 public static function getForm(string $instance, int $id, bool $useCache = true) 27 27 { 28 28 $form = Transient::get($instance . '_contactform_' . $id . '_v2'); 29 if ($form === false ) {29 if ($form === false || !$useCache) { 30 30 try { 31 31 $form = Http::get($instance, 'contactformulieren/' . $id . '?embed=Velden'); … … 65 65 66 66 // Get basic info for the form 67 $form = self::getForm($instance, $attributes['id'] );67 $form = self::getForm($instance, $attributes['id'], false); 68 68 if (is_string($form)) { 69 69 // Not a form, but an error … … 140 140 ]; 141 141 142 return self::generateForm($attributes['id'], $formFields, $ options);142 return self::generateForm($attributes['id'], $formFields, $form->nonce ?? null, $options); 143 143 } 144 144 … … 206 206 * Generate a contact form 207 207 */ 208 public static function generateForm(int $formID, array $formFields, array $options): string208 public static function generateForm(int $formID, array $formFields, ?string $nonce = null, array $options): string 209 209 { 210 210 global $recrasPlugin; … … 437 437 } 438 438 $html .= self::generateEndTag($options['element']); 439 if ($nonce) { 440 $html .= '<input type="hidden" name="nonce" value="' . $nonce . '">'; 441 } 439 442 440 443 $html .= '<input type="submit" value="' . $options['submitText'] . '">'; … … 452 455 const clearRadioEls = document.querySelectorAll(".clearRadioChoice"); 453 456 if (clearRadioEls.length) { 454 for (let i = 0; i < clearRadioEls.length; i++) {455 clearRadioEls[i].addEventListener("click", function() {457 for (let el of clearRadioEls) { 458 el.addEventListener("click", function() { 456 459 const radioElChecked = this.parentNode.querySelector("input[type=\'radio\']:checked"); 457 460 if (radioElChecked) { -
recras/trunk/src/Plugin.php
r3432851 r3435083 328 328 // Generic functionality & localisation script 329 329 $scriptName = 'recras-frontend'; 330 wp_register_script($scriptName, $this->baseUrl . '/js/recras.js', ['jquery'], '6. 4.0', true);330 wp_register_script($scriptName, $this->baseUrl . '/js/recras.js', ['jquery'], '6.5.0', true); 331 331 wp_localize_script($scriptName, 'recras_l10n', $localisation); 332 332 wp_enqueue_script($scriptName);
Note: See TracChangeset
for help on using the changeset viewer.