get('instance_url')) ? $value : self::DEFAULT_INSTANCE_URL; } public function get_site_key():string { return (string) $this->get('site_key'); } public function get_secret_key():string { return (string) $this->get('secret_key'); } 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']); } public function init() { register_setting(Plugin::get_id(), Plugin::get_id()); add_settings_section( 'default', Plugin::__('Cap API Credentials'), [$this, 'section'], Plugin::get_id(), [ 'description' => 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.'), ] ); 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.'), ] ); } 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 static function get_url():string { return admin_url('options-general.php?page=' . Plugin::get_id()); } } Settings::instance();