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.'), 'attributes' => [ 'autocomplete' => 'off', ], ] ); 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', 'attributes' => [ 'autocomplete' => 'off', ], ] ); add_settings_section( 'forms', Plugin::__('Forms'), [$this, 'section'], Plugin::get_id(), [ 'description' => Plugin::__('Define which forms you would like to secure with Cap.'), ] ); add_settings_field( Plugin::get_id() . '_form_locations', Plugin::__('WordPress 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'), ], 'select_all' => true, 'description' => Plugin::__('Custom login form requires login page to also be enabled.'), ] ); if (Plugin::is_woocommerce_active()) { add_settings_field( Plugin::get_id() . '_wc_form_locations', Plugin::__('WooCommerce form locations'), [$this, 'checkbox_field'], Plugin::get_id(), 'forms', [ 'name' => 'wc_form_locations', 'options' => [ self::LOCATION_WC_LOGIN => Plugin::__('Login form'), self::LOCATION_WC_LOST_PASSWORD => Plugin::__('Lost password form'), self::LOCATION_WC_REGISTER => Plugin::__('Register form'), self::LOCATION_WC_CHECKOUT => Plugin::__('Checkout form'), ], 'select_all' => true, ] ); } add_settings_section( 'widget', Plugin::__('Widget'), [$this, 'section'], Plugin::get_id(), [ 'description' => Plugin::__('Change how the Cap widget is displayed on the frontend.'), ] ); add_settings_field( Plugin::get_id() . '_widget_type', Plugin::__('Widget type'), [$this, 'checkbox_field'], Plugin::get_id(), 'widget', [ 'type' => 'radio', 'name' => 'widget_type', 'options' => [ self::WIDGET_TYPE_STANDARD => Plugin::__('Standard (default)'), self::WIDGET_TYPE_FLOATING => Plugin::__('Floating'), ], 'default' => self::WIDGET_TYPE_STANDARD, 'description' => Plugin::__('Not sure which type you want to use? View the demo to try them out.'), ] ); } 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; if (!!($args['select_all'] ?? false) && ($args['type'] ?? 'checkbox') == 'checkbox') { printf( '%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();