Add simple select all option to forms settings
This commit is contained in:
+2
-2
@@ -3,8 +3,8 @@
|
||||
* @author cleverogre
|
||||
* @copyright 2026 CleverOgre
|
||||
* @license GLP-3.0-or-later
|
||||
* @version 1.1.2
|
||||
* @since 1.1.2
|
||||
* @version 1.2.0
|
||||
* @since 1.2.0
|
||||
*/
|
||||
|
||||
(() => {
|
||||
|
||||
@@ -250,6 +250,7 @@ final class Settings {
|
||||
self::LOCATION_COMMENT_FORM => Plugin::__('Comment form'),
|
||||
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.'),
|
||||
]
|
||||
);
|
||||
@@ -269,6 +270,7 @@ final class Settings {
|
||||
self::LOCATION_WC_REGISTER => Plugin::__('Register 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 {
|
||||
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 });"> %s</label><br>',
|
||||
esc_attr(Plugin::get_id()),
|
||||
esc_attr($args['name']),
|
||||
Plugin::esc_html__('Select All')
|
||||
);
|
||||
}
|
||||
|
||||
echo implode('<br>', array_map(
|
||||
fn (string $name, string $label):string => sprintf(
|
||||
'<label><input type="%s" name="%s[%s][]" value="%s" %s> %s</label>',
|
||||
|
||||
@@ -30,6 +30,7 @@ If you don't know what plugin you have downloaded, please contact [CleverOgre](t
|
||||
|
||||
= 1.2.0 - 2026-06-09 =
|
||||
* Add floating widget mode support
|
||||
* Add simple select all toggle for form locations settings
|
||||
|
||||
= 1.1.2 - 2026-06-08 =
|
||||
* Prevent captcha in Gravity Forms editor
|
||||
|
||||
Reference in New Issue
Block a user