Plugin::__('The configuration settings for your Cap CAPTCHA API connection.'), ] ); add_settings_field( Plugin::get_id() . '_instance_url', Plugin::__('Instance URL'), [$this, 'field'], Plugin::get_id(), args: [ 'name' => 'instance_url', 'placeholder' => Plugin::__('https://captcha.cleverogre.com/'), 'description' => Plugin::__('Provide the base URL to an instance of Cap. Defaults to CleverOgre\'s CAPTCHA server.'), ] ); add_settings_field( Plugin::get_id() . '_site_key', Plugin::__('Site key'), [$this, 'field'], Plugin::get_id(), args: [ 'name' => 'site_key', 'description' => Plugin::__('Provide your Cap site key.'), 'type' => 'password', ] ); add_settings_field( Plugin::get_id() . '_secret_key', Plugin::__('Secret key'), [$this, 'field'], Plugin::get_id(), args: [ 'name' => 'secret_key', 'description' => Plugin::__('Provide your Cap secret key.'), 'type' => 'password', ] ); add_settings_section( 'forms', Plugin::__('CAPTCHA Forms'), [$this, 'section'], Plugin::get_id(), [ 'description' => Plugin::__('Define which forms you would like to secure with CAPTCHA.'), ] ); add_settings_field( Plugin::get_id() . '_form_locations', Plugin::__('Form locations'), [$this, 'checkbox_field'], Plugin::get_id(), 'forms', [ 'name' => 'form_locations', 'options' => [ 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'), 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.'), ] ); } public function page() { if (!current_user_can(self::CAPABILITY)) return; // Show error/update messages settings_errors(Plugin::get_id()); ?>
%s
', esc_attr($args['name']), nl2br($args['description']) ); } } public function checkbox_field(array $args):void { if (empty($args['name'] ?? '') || empty($args['options'] ?? [])) return; echo implode('%s
', esc_attr($args['name']), nl2br($args['description']) ); } } public static function get_url():string { return admin_url('options-general.php?page=' . Plugin::get_id()); } } Settings::instance();