Server IP : 104.21.14.48 / Your IP : 18.116.23.51 [ Web Server : Apache System : Linux b70eb322-3aee-0c53-7c82-0db91281f2c6.secureserver.net 6.1.90-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 2 12:09:22 EDT 2024 x86_64 User : root ( 0) PHP Version : 8.0.30.2 Disable Function : NONE Domains : 0 Domains MySQL : ON | cURL : ON | WGET : ON | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/wp-content/mu-plugins/vendor/wptool/wp-admin-dash/src/adminDash/services/ |
Upload File : |
<?php namespace Wptool\adminDash\services; use Wptool\adminDash\constants\ToggleStatus; use Wptool\adminDash\exceptions\CaptchaDisabledException; class CaptchaService { /** * This function update wp_options, if the option does not exist, it will be created. * Otherwise, it will set opposite status from one in database. * Return mwp captcha status, zero or one as string. * * @return bool */ public function toggle_wpsec_captcha() { $captcha = get_option( 'wpsec_captcha_enabled' ); $status = ToggleStatus::ENABLED; if ( ToggleStatus::ENABLED === $captcha ) { $status = ToggleStatus::DISABLED; } update_option( 'wpsec_captcha_enabled', $status ); return ToggleStatus::ENABLED === $status; } /** * * This function return either captcha is disabled or not. * Captcha should be considered to be disabled only if option is present and set to 0. * * @return bool * */ public function is_wpsec_captcha_enabled() { return get_option( 'wpsec_captcha_enabled', ToggleStatus::ENABLED ) === ToggleStatus::ENABLED; } /** * * This function update value in wp_options. If the option does not exist, it will be created * By default captcha is enabled. * @return bool * @throws CaptchaDisabledException */ public function toggle_wpsec_captcha_comment() { if ( ! $this->is_wpsec_captcha_enabled() ) { throw new CaptchaDisabledException(); } $comment_captcha = get_option( 'wpsec_comment_captcha_enabled' ); $status = ToggleStatus::ENABLED; if ( ToggleStatus::ENABLED === $comment_captcha ) { $status = ToggleStatus::DISABLED; } update_option( 'wpsec_comment_captcha_enabled', $status ); return ToggleStatus::ENABLED === $status; } /** * * This function return either captcha is enabled for comments or not. * @return bool */ public function is_wpsec_captcha_comment_enabled() { if ( ! $this->is_wpsec_captcha_enabled() ) { return false; } return get_option( 'wpsec_comment_captcha_enabled', ToggleStatus::ENABLED ) === ToggleStatus::ENABLED; } /** * * This function update value in wp_options. If the option does not exist, it will be created * By default captcha is enabled. * @return bool * @throws CaptchaDisabledException */ public function toggle_wpsec_captcha_login() { if ( ! $this->is_wpsec_captcha_enabled() ) { throw new CaptchaDisabledException(); } $comment_captcha = get_option( 'wpsec_login_captcha_enabled' ); $status = ToggleStatus::ENABLED; if ( ToggleStatus::ENABLED === $comment_captcha ) { $status = ToggleStatus::DISABLED; } update_option( 'wpsec_login_captcha_enabled', $status ); return ToggleStatus::ENABLED === $status; } /** * * This function return either captcha is enabled for comments or not. * @return bool */ public function is_wpsec_captcha_login_enabled() { if ( ! $this->is_wpsec_captcha_enabled() ) { return false; } return get_option( 'wpsec_login_captcha_enabled', ToggleStatus::ENABLED ) === ToggleStatus::ENABLED; } }