Add simple select all option to forms settings

This commit is contained in:
Cooper Dalrymple
2026-06-09 13:04:40 -05:00
parent 79f95fa0df
commit 8159c4a46c
3 changed files with 14 additions and 2 deletions
+2 -2
View File
@@ -3,8 +3,8 @@
* @author cleverogre * @author cleverogre
* @copyright 2026 CleverOgre * @copyright 2026 CleverOgre
* @license GLP-3.0-or-later * @license GLP-3.0-or-later
* @version 1.1.2 * @version 1.2.0
* @since 1.1.2 * @since 1.2.0
*/ */
(() => { (() => {
+11
View File
@@ -250,6 +250,7 @@ final class Settings {
self::LOCATION_COMMENT_FORM => Plugin::__('Comment form'), self::LOCATION_COMMENT_FORM => Plugin::__('Comment form'),
self::LOCATION_POST_PASSWORD_FORM => Plugin::__('Password-protected posts and pages'), self::LOCATION_POST_PASSWORD_FORM => Plugin::__('Password-protected posts and pages'),
], ],
'select_all' => true,
'description' => Plugin::__('Custom login form requires login page to also be enabled.'), 'description' => Plugin::__('Custom login form requires login page to also be enabled.'),
] ]
); );
@@ -269,6 +270,7 @@ final class Settings {
self::LOCATION_WC_REGISTER => Plugin::__('Register form'), self::LOCATION_WC_REGISTER => Plugin::__('Register form'),
self::LOCATION_WC_CHECKOUT => Plugin::__('Checkout form'), self::LOCATION_WC_CHECKOUT => Plugin::__('Checkout form'),
], ],
'select_all' => true,
] ]
); );
} }
@@ -384,6 +386,15 @@ final class Settings {
public function checkbox_field(array $args):void { public function checkbox_field(array $args):void {
if (empty($args['name'] ?? '') || empty($args['options'] ?? [])) return; if (empty($args['name'] ?? '') || empty($args['options'] ?? [])) return;
if (!!($args['select_all'] ?? false) && ($args['type'] ?? 'checkbox') == 'checkbox') {
printf(
'<label><input type="checkbox" onClick="document.getElementsByName(\'%s[%s][]\').forEach(element => { element.checked = this.checked });">&nbsp;%s</label><br>',
esc_attr(Plugin::get_id()),
esc_attr($args['name']),
Plugin::esc_html__('Select All')
);
}
echo implode('<br>', array_map( echo implode('<br>', array_map(
fn (string $name, string $label):string => sprintf( fn (string $name, string $label):string => sprintf(
'<label><input type="%s" name="%s[%s][]" value="%s" %s>&nbsp;%s</label>', '<label><input type="%s" name="%s[%s][]" value="%s" %s>&nbsp;%s</label>',
+1
View File
@@ -30,6 +30,7 @@ If you don't know what plugin you have downloaded, please contact [CleverOgre](t
= 1.2.0 - 2026-06-09 = = 1.2.0 - 2026-06-09 =
* Add floating widget mode support * Add floating widget mode support
* Add simple select all toggle for form locations settings
= 1.1.2 - 2026-06-08 = = 1.1.2 - 2026-06-08 =
* Prevent captcha in Gravity Forms editor * Prevent captcha in Gravity Forms editor