ngs page. * * @since 1.8.0 */ public function enqueues() { $current_captcha = $this->get_current_captcha(); if ( ! $current_captcha ) { return; } $current_captcha->enqueues(); } /** * Get current active captcha object. * * @since 1.8.0 * * @return object|string */ private function get_current_captcha() { return ! empty( $this->captchas[ $this->settings['provider'] ] ) ? $this->captchas[ $this->settings['provider'] ] : ''; } /** * Use the CAPTCHA no-conflict mode. * * When enabled in the WPForms settings, forcefully remove all other * CAPTCHA enqueues to prevent conflicts. Filter can be used to target * specific pages, etc. * * @since 1.6.4 */ public function apply_noconflict() { if ( ! wpforms_is_admin_page( 'settings', self::VIEW ) || empty( wpforms_setting( 'recaptcha-noconflict' ) ) || /** * Allow/disallow applying non-conflict mode for captcha scripts. * * @since 1.6.4 * * @param boolean $allow True/false. Default: true. */ ! apply_filters( 'wpforms_admin_settings_captcha_apply_noconflict', true ) // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName ) { return; } $scripts = wp_scripts(); $urls = [ 'google.com/recaptcha', 'gstatic.com/recaptcha', 'hcaptcha.com/1', 'challenges.cloudflare.com/turnstile' ]; foreach ( $scripts->queue as $handle ) { // Skip the WPForms JavaScript assets. if ( ! isset( $scripts->registered[ $handle ] ) || false !== strpos( $scripts->registered[ $handle ]->handle, 'wpforms' ) ) { return; } foreach ( $urls as $url ) { if ( false !== strpos( $scripts->registered[ $handle ]->src, $url ) ) { wp_dequeue_script( $handle ); wp_deregister_script( $handle ); break; } } } } }