* : The url of the Cap instance. * * ## EXAMPLES * * wp ogre-captcha instance_url https://captcha.cleverogre.com * * @when after_wp_load */ public function instance_url(array $args, array $assoc_args):void { list($value) = $args; if (Settings::set_instance_url($value)) { WP_CLI::success(Plugin::__('Successfully updated api instance url')); } else { WP_CLI::error(Plugin::__('Invalid url')); } } /** * Set Cap API site key. * * ## OPTIONS * * * : The value of the site key. Typically 10 characters. * * ## EXAMPLES * * wp ogre-captcha site_key ########## * * @when after_wp_load */ public function site_key(array $args, array $assoc_args):void { list($value) = $args; if (Settings::set_site_key($value)) { WP_CLI::success(Plugin::__('Successfully updated api site key')); } else { WP_CLI::error(Plugin::__('Invalid site key')); } } /** * Set Cap API secret key. * * ## OPTIONS * * * : The value of the secret key. Typically 43 characters. * * ## EXAMPLES * * wp ogre-captcha secret_key sk-######################################## * * @when after_wp_load */ public function secret_key(array $args, array $assoc_args):void { list($value) = $args; if (Settings::set_secret_key($value)) { WP_CLI::success(Plugin::__('Successfully updated api secret key')); } else { WP_CLI::error(Plugin::__('Invalid secret key')); } } /** * Enable (or disable) CAPTCHA on the designated forms. * * ## OPTIONS * * [...] * : The form locations to alter. The following values are accepted. "login_page", "registration_page", "lost_password_page", "login_form", "comment_form", "post_password_form", "wc_login", "wc_lost_password", "wc_register", "wc_checkout" * * [--all] * : Whether or not to include all possible form locations. * * [--disable] * : Whether or not to disable the designated form locations rather than enable. * * ## EXAMPLES * * wp ogre-captcha form --all * * @when after_wp_load */ public function form(array $args, array $assoc_args):void { $locations = !empty($args) ? (array) array_values($args)[0] : []; $all = $assoc_args['all'] ?? false; $disable = $assoc_args['disable'] ?? false; if (empty($locations) && !$all) { WP_CLI::error('Please specify one or more form locations, or use --all.'); return; } if (!!$all) $locations = Settings::ALL_LOCATIONS; $locations = array_filter($locations, fn ($location) => !Settings::set_form_location($location, !$disable)); if (empty($locations)) { WP_CLI::success(Plugin::__('Successfully updated all form locations')); } else { WP_CLI::error( Plugin::__('Failed to alter form locations: %s'), implode(', ', $locations) ); } } /** * Set Cap widget type. * * ## OPTIONS * * * : The value of the widget type. Either "standard" or "floating". * * ## EXAMPLES * * wp ogre-captcha widget_type floating * * @when after_wp_load */ public function widget_type(array $args, array $assoc_args):void { list($value) = $args; if (Settings::set_widget_type($value)) { WP_CLI::success(Plugin::__('Successfully updated widget type')); } else { WP_CLI::error(Plugin::__('Invalid widget type')); } } /** * Enable or disable CAPTCHA on Gravity Forms. * * ## OPTIONS * * * : Whether or not to enable CAPTCHA on all forms by default. * --- * options: * - enable * - disable * --- * * ## EXAMPLES * * wp ogre-captcha gravityforms enable * * @when gform_loaded */ public function gravityforms(array $args, array $assoc_args):void { list($value) = $args; $value = $value == 'enable'; if (!Plugin::is_gravityforms_active()) { WP_CLI::error(Plugin::__('Gravity Forms not active')); return; } if (GFAddon::get_instance()?->set_enabled($value)) { WP_CLI::success(Plugin::__('Successfully updated Gravity Forms integration')); } else { WP_CLI::error(Plugin::__('Unable to update setting')); } } } WP_CLI::add_command(Plugin::get_id(), CLI::class);