Improvements to settings page
Validate Build / validate-build (push) Failing after 38s
Validate Build / validate-build (push) Failing after 38s
This commit is contained in:
@@ -4,3 +4,4 @@ node_modules
|
||||
*.zip
|
||||
dist
|
||||
*.map
|
||||
.DS_Store
|
||||
|
||||
Generated
+1
-1
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "7a93568ac8ad8943978c2656b568b574",
|
||||
"content-hash": "978b7fe126b61796750d67c4c7231417",
|
||||
"packages": [
|
||||
{
|
||||
"name": "cleverogre/plugin-framework",
|
||||
|
||||
+26
-7
@@ -103,7 +103,16 @@ final class Settings {
|
||||
|
||||
public function menu() {
|
||||
if (!current_user_can(self::CAPABILITY)) return;
|
||||
add_options_page(sprintf(Plugin::__('%s Settings'), Plugin::get_title()), Plugin::get_title(), self::CAPABILITY, Plugin::get_id(), [$this, 'page']);
|
||||
add_options_page(
|
||||
sprintf(
|
||||
Plugin::__('%s Settings'),
|
||||
Plugin::get_title()
|
||||
),
|
||||
Plugin::__('CAPTCHA'),
|
||||
self::CAPABILITY,
|
||||
Plugin::get_id(),
|
||||
[$this, 'page']
|
||||
);
|
||||
}
|
||||
|
||||
public function init() {
|
||||
@@ -139,6 +148,7 @@ final class Settings {
|
||||
args: [
|
||||
'name' => 'site_key',
|
||||
'description' => Plugin::__('Provide your Cap site key.'),
|
||||
'type' => 'password',
|
||||
]
|
||||
);
|
||||
|
||||
@@ -150,6 +160,7 @@ final class Settings {
|
||||
args: [
|
||||
'name' => 'secret_key',
|
||||
'description' => Plugin::__('Provide your Cap secret key.'),
|
||||
'type' => 'password',
|
||||
]
|
||||
);
|
||||
|
||||
@@ -175,10 +186,11 @@ final class Settings {
|
||||
self::LOCATION_LOGIN_PAGE => Plugin::__('Login page'),
|
||||
self::LOCATION_REGISTRATION_PAGE => Plugin::__('Registration page'),
|
||||
self::LOCATION_LOST_PASSWORD_FORM => Plugin::__('Lost password page'),
|
||||
self::LOCATION_LOGIN_FORM => Plugin::__('Custom login form (requires Login Page)'),
|
||||
self::LOCATION_LOGIN_FORM => Plugin::__('Custom login form'),
|
||||
self::LOCATION_COMMENT_FORM => Plugin::__('Comment form'),
|
||||
self::LOCATION_POST_PASSWORD_FORM => Plugin::__('Password-protected posts and pages'),
|
||||
],
|
||||
'description' => Plugin::__('Custom login form requires login page to also be enabled.'),
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -210,7 +222,7 @@ final class Settings {
|
||||
if (empty($args['name'] ?? '')) return;
|
||||
|
||||
$attributes = [
|
||||
'type' => 'text',
|
||||
'type' => $args['type'] ?? 'text',
|
||||
'class' => 'regular-text',
|
||||
'name' => sprintf(
|
||||
'%s[%s]',
|
||||
@@ -261,21 +273,28 @@ final class Settings {
|
||||
}
|
||||
|
||||
public function checkbox_field(array $args):void {
|
||||
if (empty($args['name'] ?? '') || !isset($options) || empty($options)) return;
|
||||
if (empty($args['name'] ?? '') || empty($args['options'] ?? [])) return;
|
||||
|
||||
echo implode('<br>', array_map(
|
||||
fn (string $name, string $label):string => sprintf(
|
||||
'<label><input type="checkbox" name="%s[%s][]" value="%s" %s> %s (%s)</label>',
|
||||
'<label><input type="checkbox" name="%s[%s][]" value="%s" %s> %s</label>',
|
||||
esc_attr(Plugin::get_id()),
|
||||
esc_attr($args['name']),
|
||||
esc_attr($name),
|
||||
checked(self::is_checked($args['name'], $name), display: false),
|
||||
esc_html($label),
|
||||
esc_html($name)
|
||||
esc_html($label)
|
||||
),
|
||||
array_keys($args['options']),
|
||||
array_values($args['options'])
|
||||
));
|
||||
|
||||
if (!empty($args['description'] ?? '')) {
|
||||
printf(
|
||||
'<p class="description" id="%s-description">%s</p>',
|
||||
esc_attr($args['name']),
|
||||
nl2br($args['description'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_url():string {
|
||||
|
||||
Reference in New Issue
Block a user