add_menu( array( 'id' => 'method-menu', 'title' => 'C4WP Method Switcher', 'href' => '#', 'meta' => array( 'title' => __( 'C4WP Method Switcher' ), ), ) ); $admin_bar->add_menu( array( 'id' => 'v2-checkbox', 'parent' => 'method-menu', 'title' => 'V2 Checkbox', 'href' => add_query_arg( array( 'override-captcha-version' => 'v2_checkbox' ), $method_override ), 'meta' => array( 'title' => __( 'V2 Checkbox' ), ), ) ); $admin_bar->add_menu( array( 'id' => 'v2-invisible', 'parent' => 'method-menu', 'title' => 'V2 Invisible', 'href' => add_query_arg( array( 'override-captcha-version' => 'v2_invisible' ), $method_override ), 'meta' => array( 'title' => __( 'V2 Invisible' ), ), ) ); $admin_bar->add_menu( array( 'id' => 'v3', 'parent' => 'method-menu', 'title' => 'V3', 'href' => add_query_arg( array( 'override-captcha-version' => 'v3' ), $method_override ), 'meta' => array( 'title' => __( 'V3' ), ), ) ); $admin_bar->add_menu( array( 'id' => 'hcaptcha', 'parent' => 'method-menu', 'title' => 'hCaptcha', 'href' => add_query_arg( array( 'override-captcha-version' => 'hcaptcha' ), $method_override ), 'meta' => array( 'title' => __( 'hCaptcha' ), ), ) ); $admin_bar->add_menu( array( 'id' => 'cloudflare', 'parent' => 'method-menu', 'title' => 'CloudFlare', 'href' => add_query_arg( array( 'override-captcha-version' => 'cloudflare' ), $method_override ), 'meta' => array( 'title' => __( 'CloudFlare' ), ), ) ); $admin_bar->add_menu( array( 'id' => 'script-menu', 'title' => 'C4WP Script Loading', 'href' => '#', 'meta' => array( 'title' => __( 'C4WP Script Loading' ), ), ) ); $admin_bar->add_menu( array( 'id' => 'load-inline', 'parent' => 'script-menu', 'title' => 'Load Inline (default)', 'href' => add_query_arg( array( 'override-load-scripts' => 'false' ), $scripts_override ), 'meta' => array( 'title' => __( 'Load Inline (default)' ), ), ) ); $admin_bar->add_menu( array( 'id' => 'load-file-footer', 'parent' => 'script-menu', 'title' => 'Load file footer', 'href' => add_query_arg( array( 'override-load-scripts' => 'footer' ), $scripts_override ), 'meta' => array( 'title' => __( 'Load file footer' ), ), ) ); $admin_bar->add_menu( array( 'id' => 'load-file-header', 'parent' => 'script-menu', 'title' => 'Load file header', 'href' => add_query_arg( array( 'override-load-scripts' => 'header' ), $scripts_override ), 'meta' => array( 'title' => __( 'Load file header' ), ), ) ); } } /* @dev:end */ /** * Add notice to alert admin to new feature. * * @return void * * @since 7.0.0 */ public static function v3_fallback_notice() { $need_notice = get_option( 'c4wp_v3_failover_available', false ); $current_val = C4WP_Functions::c4wp_get_option( 'failure_action' ); $user = wp_get_current_user(); if ( $need_notice && ! $current_val ) { $user = wp_get_current_user(); $settings_url = add_query_arg( array( 'page' => 'c4wp-admin-captcha' ), network_admin_url( 'admin.php' ) ); $notice_nonce = wp_create_nonce( 'dismiss_captcha_notice' ); $help_text = wp_sprintf( '%1$s %2$s %3$s %4$s %5$s %6$s', '' . esc_html__( 'Important:', 'advanced-nocaptcha-recaptcha' ) . '', esc_html__( 'To reconfigure the failover now, once you are redirected to the plugin\'s configuration page click', 'advanced-nocaptcha-recaptcha' ), '' . esc_html__( 'Reconfigure CAPTCHA integration', 'advanced-nocaptcha-recaptcha' ) . '', esc_html__( 'and click', 'advanced-nocaptcha-recaptcha' ), '' . esc_html__( 'Next', 'advanced-nocaptcha-recaptcha' ) . '', esc_html__( 'in the wizard until you get to the failover settings.', 'advanced-nocaptcha-recaptcha' ) ); if ( in_array( 'administrator', (array) $user->roles, true ) ) { echo '
' . esc_html__( 'In the latest version of CAPTCHA 4WP you can configure a failover action for your CAPTCHA check. This means that you can configure the plugin to show a CAPTCHA checkbox or redirect the user when the current v3 reCAPTCHA check fails. Use the buttons below to configure the failover or close this admin notice.', 'advanced-nocaptcha-recaptcha' ) . '
' . wp_kses( $help_text, C4WP_Functions::c4wp_allowed_kses_args() ) . '
' . esc_html__( 'Configure failover action now', 'advanced-nocaptcha-recaptcha' ) . ' ' . esc_html__( "I'll configure it later", 'advanced-nocaptcha-recaptcha' ) . '%1$s
', sprintf( /* translators:link to help page */ esc_html__( 'To utilize the Google reCAPTCHA service on your website you need to get a Site and Secret key. If you do not have these keys yet, you can option them for free by registering to the Google reCAPTCHA service. Refer to the document %s for a step by step explanation of how to get these keys.', 'advanced-nocaptcha-recaptcha' ), '' . esc_html__( 'how to get the Google reCAPTCHA keys', 'advanced-nocaptcha-recaptcha' ) . '' ) ), 'class' => 'wrap-around-content c4wp-wizard-site-keys', ), 'site_key' => array( 'label' => esc_html__( 'Site Key', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'required' => true, 'class' => 'c4wp-wizard-site-keys', ), 'secret_key' => array( 'label' => esc_html__( 'Secret Key', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'required' => true, 'class' => 'c4wp-wizard-site-keys', ), 'key_validation' => array( 'section_id' => 'google_keys', 'type' => 'html', 'label' => esc_html__( 'Key Validation', 'advanced-nocaptcha-recaptcha' ), 'std' => '' . esc_html__( 'Once you enter the correct Site key above, the CAPTCHA method you want to use on your website will appear below. If the key is incorrect you will instead see an error. If you see an error make sure the CAPTCHA version, website domain and the Site keys match. Before the plugin verifies your secret key, it needs a response to send to your CAPTCHA provider. If needed, please interact with/complete the CAPTCHA challenge below if presented to you to proceed.', 'advanced-nocaptcha-recaptcha' ) . '
', 'class' => 'c4wp-wizard-site-keys', ), 'score_title' => array( 'section_id' => 'google_keys', 'type' => 'html', 'label' => sprintf( '%1$s', esc_html__( 'Optional settings: Fine-tune CAPTCHA to your requirements', 'advanced-nocaptcha-recaptcha' ) ), 'class' => 'wrap-around-content c4wp-wizard-additional-settings', ), 'score_subtitle' => array( 'section_id' => 'google_keys', 'type' => 'html', 'label' => sprintf( '%1$s
', sprintf( esc_html__( 'Use the below settings to configure and fine-tune CAPTCHA to your requirements. All the below settings are optional and with them you can configure different aspects of the CAPTCHA checks on your website, such as look and feel and also sensitivity.', 'advanced-nocaptcha-recaptcha' ) ) ), 'class' => 'wrap-around-content c4wp-wizard-additional-setting', ), 'score' => array( 'label' => esc_html__( 'Captcha Score', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'type' => 'select', 'class' => 'regular toggleable disabled c4wp-show-field-for-v3', 'std' => '0.5', 'options' => $score_values, 'desc' => esc_html__( 'Use this setting to specify sensitivity of the CAPTCHA check. The closer to 1 the more sensitive the CAPTCHA check will be, which also means more traffic will be marked as spam. This option is only available for reCAPTCHA v3.', 'advanced-nocaptcha-recaptcha' ), ), 'v3_script_load' => array( 'label' => esc_html__( 'Load ReCAPTCHA v3 scripts on:', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'type' => 'select', 'class' => 'regular toggleable disabled c4wp-show-field-for-v3', 'std' => 'all_pages', 'options' => array( 'all_pages' => esc_html__( 'All Pages', 'advanced-nocaptcha-recaptcha' ), 'form_pages' => esc_html__( 'Form Pages', 'advanced-nocaptcha-recaptcha' ), ), 'desc' => sprintf( /* translators: %s: link to article. */ __( 'By default, the ReCAPTCHA service can only assess user behavior via the scripts loaded on the form pages. However, when using V3, you can configure it to load on all pages. This allows ReCAPTCHA to get a better context of the traffic so that it can better determine what is spam and what is not. When ReCAPTCHA V3 is configured to load on all pages, it will never prompt or otherwise interrupt users on non-form pages. Note that the ReCAPTCHA V3 check still needs to be included in the form(s). Refer to the %1$s for more information on how to add CAPTCHA checks to your forms.', 'advanced-nocaptcha-recaptcha' ), sprintf( '' . esc_html__( 'CAPTCHA 4WP knowledge base', 'advanced-nocaptcha-recaptcha' ) . '' ) ), ), 'language_handling' => array( 'label' => esc_html__( 'CAPTCHA language', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'type' => 'radio', 'class' => 'regular remove-space-below remove-radio-br', 'std' => 'manually_choose', 'options' => array( 'manually_choose' => esc_html__( 'Select a language', 'advanced-nocaptcha-recaptcha' ), ), 'desc' => $lang_selector_desc, ), 'language' => array( 'label' => '', 'section_id' => 'google_keys', 'type' => 'select', 'std' => 'en', 'class' => 'regular lang_select hide-if-disabled toggleable', 'options' => array( 'ar' => esc_html__( 'Arabic', 'advanced-nocaptcha-recaptcha' ), 'bg' => esc_html__( 'Bulgarian', 'advanced-nocaptcha-recaptcha' ), 'ca' => esc_html__( 'Catalan', 'advanced-nocaptcha-recaptcha' ), 'zh-CN' => esc_html__( 'Chinese (Simplified)', 'advanced-nocaptcha-recaptcha' ), 'hr' => esc_html__( 'Croatian', 'advanced-nocaptcha-recaptcha' ), 'cs' => esc_html__( 'Czech', 'advanced-nocaptcha-recaptcha' ), 'da' => esc_html__( 'Danish', 'advanced-nocaptcha-recaptcha' ), 'nl' => esc_html__( 'Dutch', 'advanced-nocaptcha-recaptcha' ), 'en-GB' => esc_html__( 'English (UK)', 'advanced-nocaptcha-recaptcha' ), 'en' => esc_html__( 'English (US)', 'advanced-nocaptcha-recaptcha' ), 'fil' => esc_html__( 'Filipino', 'advanced-nocaptcha-recaptcha' ), 'fi' => esc_html__( 'Finnish', 'advanced-nocaptcha-recaptcha' ), 'fr' => esc_html__( 'French', 'advanced-nocaptcha-recaptcha' ), 'fr-CA' => esc_html__( 'French (Canadian)', 'advanced-nocaptcha-recaptcha' ), 'de' => esc_html__( 'German', 'advanced-nocaptcha-recaptcha' ), 'de-AT' => esc_html__( 'German (Austria)', 'advanced-nocaptcha-recaptcha' ), 'de-CH' => esc_html__( 'German (Switzerland)', 'advanced-nocaptcha-recaptcha' ), 'el' => esc_html__( 'Greek', 'advanced-nocaptcha-recaptcha' ), 'iw' => esc_html__( 'Hebrew', 'advanced-nocaptcha-recaptcha' ), 'hi' => esc_html__( 'Hindi', 'advanced-nocaptcha-recaptcha' ), 'hu' => esc_html__( 'Hungarian', 'advanced-nocaptcha-recaptcha' ), 'id' => esc_html__( 'Indonesian', 'advanced-nocaptcha-recaptcha' ), 'it' => esc_html__( 'Italian', 'advanced-nocaptcha-recaptcha' ), 'ja' => esc_html__( 'Japanese', 'advanced-nocaptcha-recaptcha' ), 'ko' => esc_html__( 'Korean', 'advanced-nocaptcha-recaptcha' ), 'lv' => esc_html__( 'Latvian', 'advanced-nocaptcha-recaptcha' ), 'lt' => esc_html__( 'Lithuanian', 'advanced-nocaptcha-recaptcha' ), 'no' => esc_html__( 'Norwegian', 'advanced-nocaptcha-recaptcha' ), 'fa' => esc_html__( 'Persian', 'advanced-nocaptcha-recaptcha' ), 'pl' => esc_html__( 'Polish', 'advanced-nocaptcha-recaptcha' ), 'pt' => esc_html__( 'Portuguese', 'advanced-nocaptcha-recaptcha' ), 'pt-BR' => esc_html__( 'Portuguese (Brazil)', 'advanced-nocaptcha-recaptcha' ), 'pt-PT' => esc_html__( 'Portuguese (Portugal)', 'advanced-nocaptcha-recaptcha' ), 'ro' => esc_html__( 'Romanian', 'advanced-nocaptcha-recaptcha' ), 'ru' => esc_html__( 'Russian', 'advanced-nocaptcha-recaptcha' ), 'sr' => esc_html__( 'Serbian', 'advanced-nocaptcha-recaptcha' ), 'sk' => esc_html__( 'Slovak', 'advanced-nocaptcha-recaptcha' ), 'sl' => esc_html__( 'Slovenian', 'advanced-nocaptcha-recaptcha' ), 'es' => esc_html__( 'Spanish', 'advanced-nocaptcha-recaptcha' ), 'es-419' => esc_html__( 'Spanish (Latin America)', 'advanced-nocaptcha-recaptcha' ), 'sv' => esc_html__( 'Swedish', 'advanced-nocaptcha-recaptcha' ), 'th' => esc_html__( 'Thai', 'advanced-nocaptcha-recaptcha' ), 'tr' => esc_html__( 'Turkish', 'advanced-nocaptcha-recaptcha' ), 'uk' => esc_html__( 'Ukrainian', 'advanced-nocaptcha-recaptcha' ), 'vi' => esc_html__( 'Vietnamese', 'advanced-nocaptcha-recaptcha' ), ), ), 'language_cloudflare' => array( 'label' => '', 'section_id' => 'google_keys', 'type' => 'select', 'std' => 'en', 'class' => 'regular lang_select hide-if-disabled toggleable c4wp-show-field-for-cloudflare', 'options' => array( 'ar-eg' => esc_html__( 'Arabic (Egypt)', 'advanced-nocaptcha-recaptcha' ), 'ar' => esc_html__( 'Arabic', 'advanced-nocaptcha-recaptcha' ), 'de' => esc_html__( 'German', 'advanced-nocaptcha-recaptcha' ), 'en' => esc_html__( 'English (US)', 'advanced-nocaptcha-recaptcha' ), 'es' => esc_html__( 'Spanish', 'advanced-nocaptcha-recaptcha' ), 'fa' => esc_html__( 'Persian', 'advanced-nocaptcha-recaptcha' ), 'fr' => esc_html__( 'French', 'advanced-nocaptcha-recaptcha' ), 'id' => esc_html__( 'Indonesian', 'advanced-nocaptcha-recaptcha' ), 'it' => esc_html__( 'Italian', 'advanced-nocaptcha-recaptcha' ), 'ja' => esc_html__( 'Japanese', 'advanced-nocaptcha-recaptcha' ), 'ko' => esc_html__( 'Korean', 'advanced-nocaptcha-recaptcha' ), 'nl' => esc_html__( 'Dutch', 'advanced-nocaptcha-recaptcha' ), 'pl' => esc_html__( 'Polish', 'advanced-nocaptcha-recaptcha' ), 'pt' => esc_html__( 'Portuguese', 'advanced-nocaptcha-recaptcha' ), 'pt-br' => esc_html__( 'Portuguese (Brazil)', 'advanced-nocaptcha-recaptcha' ), 'ru' => esc_html__( 'Russian', 'advanced-nocaptcha-recaptcha' ), 'tlh' => esc_html__( 'Klingon', 'advanced-nocaptcha-recaptcha' ), 'tr' => esc_html__( 'Turkish', 'advanced-nocaptcha-recaptcha' ), 'uk' => esc_html__( 'Ukrainian', 'advanced-nocaptcha-recaptcha' ), 'uk-ua' => esc_html__( 'Ukrainian (Ukraine)', 'advanced-nocaptcha-recaptcha' ), 'zh' => esc_html__( 'Chinese', 'advanced-nocaptcha-recaptcha' ), 'zh-cm' => esc_html__( 'Chinese (Simplified)', 'advanced-nocaptcha-recaptcha' ), 'zh-tw' => esc_html__( 'Chinese (Traditional)', 'advanced-nocaptcha-recaptcha' ), ), ), 'error_message' => array( 'label' => esc_html__( 'Error message', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'std' => esc_html__( 'Please solve the CAPTCHA to proceed', 'advanced-nocaptcha-recaptcha' ), 'desc' => esc_html__( 'Specify the message you want to show users who do not complete the CAPTCHA.', 'advanced-nocaptcha-recaptcha' ), ), 'theme' => array( 'label' => esc_html__( 'Theme', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'type' => 'select', 'class' => 'regular toggleable disabled c4wp-show-field-for-v2_checkbox c4wp-show-field-for-v2_invisible', 'std' => 'light', 'options' => array( 'light' => esc_html__( 'Light', 'advanced-nocaptcha-recaptcha' ), 'dark' => esc_html__( 'Dark', 'advanced-nocaptcha-recaptcha' ), ), ), 'size' => array( 'label' => esc_html__( 'Size', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'type' => 'select', 'class' => 'regular toggleable disabled c4wp-show-field-for-v2_checkbox', 'std' => 'normal', 'options' => array( 'normal' => esc_html__( 'Normal', 'advanced-nocaptcha-recaptcha' ), 'compact' => esc_html__( 'Compact', 'advanced-nocaptcha-recaptcha' ), ), ), 'badge' => array( 'label' => esc_html__( 'Badge', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'type' => 'select', 'class' => 'regular full-hide toggleable disabled c4wp-show-field-for-v2_invisible', 'std' => 'bottomright', 'options' => array( 'bottomright' => esc_html__( 'Bottom Right', 'advanced-nocaptcha-recaptcha' ), 'bottomleft' => esc_html__( 'Bottom Left', 'advanced-nocaptcha-recaptcha' ), 'inline' => esc_html__( 'Inline', 'advanced-nocaptcha-recaptcha' ), ), 'desc' => esc_html__( 'Badge shows for invisible captcha', 'advanced-nocaptcha-recaptcha' ), ), 'badge_v3' => array( 'label' => esc_html__( 'Badge', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'type' => 'select', 'class' => 'regular full-hide toggleable disabled c4wp-show-field-for-v3', 'std' => 'bottomright', 'options' => array( 'bottomright' => esc_html__( 'Bottom Right', 'advanced-nocaptcha-recaptcha' ), 'bottomleft' => esc_html__( 'Bottom Left', 'advanced-nocaptcha-recaptcha' ), ), 'desc' => esc_html__( 'Badge shows for invisible captcha v3', 'advanced-nocaptcha-recaptcha' ), ), 'recaptcha_domain' => array( 'label' => esc_html__( 'reCAPTCHA domain', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'type' => 'select', 'class' => 'regular toggleable c4wp-google-only-setting', 'std' => C4WP_Functions::c4wp_recaptcha_domain(), 'options' => array( 'google.com' => 'google.com', 'google.net' => 'google.net', 'recaptcha.net' => 'recaptcha.net', ), 'desc' => esc_html__( 'Use this setting to change the domain if Google is not accessible or blocked.', 'advanced-nocaptcha-recaptcha' ), ), 'remove_css' => array( 'label' => esc_html__( 'Remove CSS', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'type' => 'checkbox', 'class' => 'checkbox', 'cb_label' => esc_html__( "Remove this plugin's css from login page?", 'advanced-nocaptcha-recaptcha' ), 'desc' => __( 'This css increase login page width to adjust with Captcha width.', 'advanced-nocaptcha-recaptcha' ), ), 'failure_action' => array( 'label' => esc_html__( 'v3 failover action:', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'type' => 'select', 'class' => 'regular', 'std' => 'v2_checkbox', 'options' => array( 'v2_checkbox' => esc_html__( 'Show a v2 CAPTCHA checkbox', 'advanced-nocaptcha-recaptcha' ), 'redirect' => esc_html__( 'Redirect the website visitor to a URL', 'advanced-nocaptcha-recaptcha' ), 'nothing' => esc_html__( 'Take no action', 'advanced-nocaptcha-recaptcha' ), ), ), 'failure_redirect' => array( 'label' => esc_html__( 'Redirect URL', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'required' => false, 'class' => 'c4wp-wizard-site-keys toggleable c4wp-show-field-for-redirect', ), 'failure_v2_site_key' => array( 'label' => esc_html__( 'v2 Site key:', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'required' => false, 'class' => 'c4wp-wizard-site-keys toggleable c4wp-show-field-for-v2_checkbox', ), 'failure_v2_secret_key' => array( 'label' => esc_html__( 'v2 Secret key:', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', 'required' => false, 'class' => 'c4wp-wizard-site-keys toggleable c4wp-show-field-for-v2_checkbox', ), 'failure_key_validation' => array( 'section_id' => 'google_keys', 'type' => 'html', 'label' => esc_html__( 'Key Validation', 'advanced-nocaptcha-recaptcha' ), 'std' => '' . esc_html__( 'Once you enter the correct Site and Secret keys above, the CAPTCHA method you want to use on your website will appear below. If the keys are incorrect you will instead see an error. If you see an error make sure the CAPTCHA version, website domain and both keys match.', 'advanced-nocaptcha-recaptcha' ) . '
', 'class' => 'c4wp-wizard-site-keys toggleable c4wp-show-field-for-v2_checkbox', ), // Settings. 'enabled_forms_title' => array( 'section_id' => 'forms', 'sub_section' => 'forms-placements', 'type' => 'html', 'label' => sprintf( '%1$s', esc_html__( 'Select where on your website you want to add the CAPTCHA check', 'advanced-nocaptcha-recaptcha' ) ), ), 'enabled_forms_subtitle' => array( 'section_id' => 'forms', 'sub_section' => 'forms-placements', 'type' => 'html', 'label' => sprintf( '%1$s
', $forms_preamble_desc ), 'class' => 'wrap-around-content', ), 'enabled_forms' => array( 'label' => esc_html__( 'WordPress pages', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'forms', 'sub_section' => 'forms-placements', 'type' => 'multicheck', 'class' => 'checkbox', 'options' => array( 'login' => esc_html__( 'Login form', 'advanced-nocaptcha-recaptcha' ), 'registration' => esc_html__( 'Registration form', 'advanced-nocaptcha-recaptcha' ), 'reset_password' => esc_html__( 'Reset password form', 'advanced-nocaptcha-recaptcha' ), 'lost_password' => esc_html__( 'Lost password form', 'advanced-nocaptcha-recaptcha' ), 'comment' => $comment_form_label, ), 'std' => array( 'login', 'registration', 'reset_password', 'lost_password', 'comment', ), ), ); $fields = apply_filters( 'c4wp_settings_fields', $fields ); $result = array_filter( $fields, function ( $key ) { if ( 'enabled_forms_title' === $key || 'enabled_forms_subtitle' === $key || 'enabled_forms_wc' === $key ) { return false; } else { return strpos( $key, 'enabled_forms_' ) === 0; } }, ARRAY_FILTER_USE_KEY ); // Sort form fields into order. $keys = array_keys( $result ); asort( $keys ); foreach ( $keys as $key ) { $val = $fields[ $key ]; unset( $fields[ $key ] ); $fields[ $key ] = $val; } if ( is_multisite() ) { $additional_ms_options['enabled_forms_ms'] = array( 'label' => esc_html__( 'Multisite pages', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'forms', 'sub_section' => 'forms-placements', 'type' => 'multicheck', 'class' => 'checkbox', 'options' => array( 'ms_user_signup' => esc_html__( 'Multisite Signup form', 'advanced-nocaptcha-recaptcha' ), ), ); $fields = self::push_at_to_associative_array( $fields, 'enabled_forms_subtitle', $additional_ms_options ); } $fields = apply_filters( 'c4wp_settings_fields_after', $fields ); if ( ! C4WP_Functions::c4wp_is_premium_version() ) : $features_url = add_query_arg( array( 'page' => 'c4wp-admin-upgrade' ), network_admin_url( 'admin.php' ) ); $logos_url = C4WP_PLUGIN_URL . 'assets/img/third-party-logos.png'; $premium_area['premium_title'] = array( 'section_id' => 'settings', 'type' => 'html', 'class' => 'premium-title-wrapper h-140', 'label' => sprintf( 'Upgrade to Premium to:Add spam protection to block spam bots and allow real humans to easily interact with your WordPress website by adding CAPTCHA to any form on your website, including out of the box support for forms on third party plugins such as:
%s
', wp_kses_post( $field['desc'] ) ); } switch ( $field['type'] ) { case 'text': case 'email': case 'url': case 'submit': printf( '', esc_attr( $field['type'] ), esc_attr( $field['id'] ), esc_attr( $field['el_class'] ), esc_attr( $field['id'] ), isset( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '', esc_attr( $value ), wp_kses_post( $attrib ), esc_attr( $field['class'] ) ); break; case 'number': printf( '', esc_attr( $field['type'] ), esc_attr( $field['id'] ), esc_attr( $field['class'] ), esc_attr( $field['id'] ), isset( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '', esc_attr( $value ), wp_kses_post( $attrib ), esc_attr( $field['min_val'] ), esc_attr( $field['max_val'] ) ); break; case 'number-inline': printf( '%8$s %9$s', esc_attr( 'number' ), esc_attr( $field['id'] ), esc_attr( $field['class'] ), esc_attr( $field['id'] ), isset( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '', esc_attr( $value ), wp_kses_post( $attrib ), esc_attr( $field['cb_label'] ), esc_attr( $field['cb_label_after'] ), esc_attr( $field['min_val'] ), esc_attr( $field['max_val'] ) ); break; case 'textarea': printf( '', esc_attr( $field['id'] ), esc_attr( $field['class'] ), esc_attr( $field['id'] ), isset( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '', wp_kses_post( $attrib ), esc_textarea( $value ) ); break; case 'checkbox': printf( '', esc_attr( $field['id'] ) ); printf( '', 'checkbox', esc_attr( $field['id'] ), esc_attr( $field['class'] ), esc_attr( $field['id'] ), '1', checked( $value, '1', false ), esc_attr( $field['cb_label'] ) ); break; case 'multicheck': printf( '', esc_attr( $field['id'] ) ); foreach ( $field['options'] as $key => $label ) { printf( '' . esc_html__( 'The site key that you have entered is invalid. Please try again.', 'advanced-nocaptcha-recaptcha' ) . '
'; } if ( 'empty_secret_key' === $error ) { $notice .= '' . esc_html__( 'The secret key that you have entered is invalid. Please try again.', 'advanced-nocaptcha-recaptcha' ) . '
' . $context . esc_html__( ' updated', 'advanced-nocaptcha-recaptcha' ) . '
' . esc_html__( 'Upgrade to Premium', 'advanced-nocaptcha-recaptcha' ) . '
' . $fields[ $field_key ]['label'] . ' ' . self::callback( $fields[ $field_key ], true ) . '
'; } $contact_forms_text_part2 = ''; $contact_forms_text = sprintf( /* translators:knowledge base link */ __( 'Please refer to the %1$s for mre information about the plugin.', 'advanced-nocaptcha-recaptcha' ), sprintf( '' . esc_html__( 'CAPTCHA 4WP knowledge base', 'advanced-nocaptcha-recaptcha' ) . '' ) ); /* @free:start */ $contact_forms_text_part2 = sprintf( /* translators:knowledge base link */ __( 'To add CAPTCHA checks and geo-blocking rules to forms created with Contact Form 7, Gravity Forms, Ninja Forms, WPForms and other third party plugins, %1$s.', 'advanced-nocaptcha-recaptcha' ), sprintf( '' . esc_html__( 'upgrade to Premium', 'advanced-nocaptcha-recaptcha' ) . '' ) ); /* @free:end */ $intro_content = '' . esc_html__( 'Thank you for installing the CAPTCHA 4WP plugin. This wizard will help you get started with the plugin so you can configure CAPTCHA and protect your website from spam, and fake registrations and orders.', 'advanced-nocaptcha-recaptcha' ) . '
Do you want to use hCaptcha or Cloudflare Turnstile for your website CAPTCHA? Upgrade to Premium.
' : ''; $markup = '' . $fields['captcha_version']['label'] . '
' . self::callback( $fields['captcha_version'], true ) . ' ' . $method_select_upgrade_message . '' . $fields['site_key']['label'] . ' ' . self::callback( $fields['site_key'], true ) . '
' . self::callback( $fields['key_validation'], true ) . '
' . esc_html__( 'Proceed to secret key', 'advanced-nocaptcha-recaptcha' ) . ' ' . esc_html__( 'Back', 'advanced-nocaptcha-recaptcha' ) . '' . esc_html__( 'Using the response from your CAPTCHA input, we can validate your security key', 'advanced-nocaptcha-recaptcha' ) . '
' . $fields['secret_key']['label'] . ' ' . self::callback( $fields['secret_key'], true ) . '
' . esc_html__( 'Validate & proceed', 'advanced-nocaptcha-recaptcha' ) . ' ' . esc_html__( 'Back', 'advanced-nocaptcha-recaptcha' ) . ' ' . esc_html__( 'Proceed', 'advanced-nocaptcha-recaptcha' ) . ' ' . esc_html__( 'Cancel', 'advanced-nocaptcha-recaptcha' ) . '' . esc_html__( 'reCAPTCHA v3 is fully automated. This means that by default, if the CAPTCHA check fails the website visitor cannot proceed with what they are doing unless you configure a failover action. Use the below setting to configure the failover action.', 'advanced-nocaptcha-recaptcha' ) . '
' . $fields['failure_action']['label'] . ' ' . self::callback( $fields['failure_action'], true ) . '
' . $fields['failure_redirect']['label'] . ' ' . self::callback( $fields['failure_redirect'], true ) . '
' . $fields['failure_v2_site_key']['label'] . ' ' . self::callback( $fields['failure_v2_site_key'], true ) . '
' . $fields['failure_v2_secret_key']['label'] . ' ' . self::callback( $fields['failure_v2_secret_key'], true ) . '
' . self::callback( $fields['failure_key_validation'], true ) . '
' . esc_html__( 'Here you can choose which forms to begin protected with your chosen CAPTCHA method.', 'advanced-nocaptcha-recaptcha' ) . '
' . $forms_markup . ' ' . $contact_forms_text . '' . esc_html__( 'Now that your chosen CAPTCHA service is fully integrated you can use the optional settings to fine-tune CAPTCHA to your requirements.', 'advanced-nocaptcha-recaptcha' ) . '
All the CAPTCHA settings are optional and with them you can configure aspects such as look and feel and CAPTCHA sensitivity. When you are ready navigate to the Settings & Placements page to configure where you\'d like to add the CAPTCHA checks.
| Current CAPTCHA configuration: | ';
$markup .= ' ';
$markup .= ' ';
$markup .= '
' . esc_html__( 'CAPTCHA version:', 'advanced-nocaptcha-recaptcha' ) . '' . $captcha_label . ' '; $markup .= '' . esc_html__( 'Site key:', 'advanced-nocaptcha-recaptcha' ) . '' . $site_key . ' '; $markup .= '' . esc_html__( 'Secret key:', 'advanced-nocaptcha-recaptcha' ) . '' . $secret_key . ' '; if ( 'v3' === $captcha_version ) { if ( 'v2_checkbox' === $failure_action ) { $markup .= '' . esc_html__( 'Failover action:', 'advanced-nocaptcha-recaptcha' ) . '' . esc_html__( 'v2 checkbox', 'advanced-nocaptcha-recaptcha' ) . ' '; $markup .= '' . esc_html__( 'Site key:', 'advanced-nocaptcha-recaptcha' ) . '' . sanitize_text_field( trim( C4WP_Functions::c4wp_get_option( 'failure_v2_site_key' ) ) ) . ' '; $markup .= '' . esc_html__( 'Secret key:', 'advanced-nocaptcha-recaptcha' ) . '' . sanitize_text_field( trim( C4WP_Functions::c4wp_get_option( 'failure_v2_secret_key' ) ) ) . ' '; } elseif ( 'redirect' === $failure_action ) { $markup .= '' . esc_html__( 'Failover action:', 'advanced-nocaptcha-recaptcha' ) . '' . esc_html__( 'Redirect to a URL', 'advanced-nocaptcha-recaptcha' ) . ' '; $markup .= '' . esc_html__( 'Failover redirect URL:', 'advanced-nocaptcha-recaptcha' ) . '' . sanitize_text_field( trim( C4WP_Functions::c4wp_get_option( 'failure_redirect' ) ) ) . ' '; } } $markup .= ' |
|---|
' ), 'class' => 'wrap-around-content c4wp-wizard-captcha-version', ); $additional_options['force_submission_locale'] = array( 'section_id' => 'geo-blocking', 'type' => 'text', 'label' => esc_html__( 'Force submission locale (testing):', 'advanced-nocaptcha-recaptcha' ), 'class' => 'regular', ); $fields = self::push_at_to_associative_array( $fields, array_key_last( $fields ), $additional_options ); return $fields; } /* @dev:end */ /** * Add additional setting to settings page. * * @param array $fields - Original settings. * * @return array $field - Appended settings. * * @since 7.6.0 */ public static function add_additional_settings( $fields ) { $additional_hide_fields = array( 'disable_submit_title' => array( 'section_id' => 'settings', 'sub_section' => 'general_settings', 'type' => 'html', 'class' => 'wrap-around-content', 'label' => sprintf( '%1$s', esc_html__( 'Disable submit button until CAPTCHA response is provided?', 'advanced-nocaptcha-recaptcha' ) ), ), 'disable_submit_subtitle' => array( 'section_id' => 'settings', 'sub_section' => 'general_settings', 'type' => 'html', 'class' => 'wrap-around-content', 'label' => sprintf( '
%1$s
', esc_html__( 'When using a visible CAPTCHA method that requires users\' interaction, should the plugin disable the submit button until the CAPTCHA challenge is completed?', 'advanced-nocaptcha-recaptcha' ) ), ), 'disable_submit' => array( 'label' => esc_html__( 'Disable submit button', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'settings', 'sub_section' => 'general_settings', 'std' => 0, 'type' => 'checkbox', 'class' => 'checkbox', ), 'pass_on_no_captcha_found_title' => array( 'section_id' => 'settings', 'sub_section' => 'general_settings', 'type' => 'html', 'class' => 'wrap-around-content', 'label' => sprintf( '%1$s', esc_html__( 'Should CAPTCHA 4WP pass or fail a submission if no CAPTCHA field is found?', 'advanced-nocaptcha-recaptcha' ) ), ), 'pass_on_no_captcha_found_subtitle' => array( 'section_id' => 'settings', 'sub_section' => 'general_settings', 'type' => 'html', 'class' => 'wrap-around-content', 'label' => sprintf( '%1$s
', esc_html__( 'If a form is passed through our plugin for verification and no CAPTCHA field is present, you can choose to either allow the submission or return a failure.', 'advanced-nocaptcha-recaptcha' ) ), ), 'pass_on_no_captcha_found' => array( 'label' => esc_html__( 'How to handle failed submissions', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'settings', 'sub_section' => 'general_settings', 'type' => 'radio', 'class' => 'regular remove-space-below remove-radio-br', 'std' => 'proceed', 'options' => array( 'proceed' => esc_html__( 'Proceed with submission', 'advanced-nocaptcha-recaptcha' ), 'fail' => esc_html__( 'Fail submission', 'advanced-nocaptcha-recaptcha' ), ), ), 'scripts_settings_title' => array( 'section_id' => 'settings', 'sub_section' => 'general_settings', 'type' => 'html', 'class' => 'wrap-around-content', 'label' => sprintf( '%1$s', esc_html__( 'Load scripts inline or via file?', 'advanced-nocaptcha-recaptcha' ) ), ), 'scripts_settings_subtitle' => array( 'section_id' => 'settings', 'sub_section' => 'general_settings', 'type' => 'html', 'class' => 'wrap-around-content', 'label' => sprintf( '%1$s
', esc_html__( 'By default the plugin loads its JS inline within wp_footer, would you like to switch to loading via a JS file instead? In can lead to increased performance in many instances.', 'advanced-nocaptcha-recaptcha' ) ), ), 'inline_or_file' => array( 'label' => esc_html__( 'Script loading method', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'settings', 'sub_section' => 'general_settings', 'type' => 'radio', 'class' => 'regular remove-space-below remove-radio-br', 'std' => 'file', 'options' => array( 'inline' => esc_html__( 'Load inline', 'advanced-nocaptcha-recaptcha' ), 'file' => esc_html__( 'Load file', 'advanced-nocaptcha-recaptcha' ), ), ), 'file_header_or_footer' => array( 'label' => esc_html__( 'File loading method', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'settings', 'sub_section' => 'general_settings', 'type' => 'radio', 'class' => 'regular remove-space-below remove-radio-br', 'std' => 'footer', 'options' => array( 'footer' => esc_html__( 'Footer', 'advanced-nocaptcha-recaptcha' ), 'header' => esc_html__( 'Header', 'advanced-nocaptcha-recaptcha' ), ), ), 'delete_data_subtitle' => array( 'section_id' => 'settings', 'sub_section' => 'general_settings', 'type' => 'html', 'class' => 'wrap-around-content', 'label' => sprintf( '%1$s', esc_html__( 'Do you want delete all plugin data when uninstalling the plugin?', 'advanced-nocaptcha-recaptcha' ) ), ), 'delete_data_enable' => array( 'label' => esc_html__( 'Delete data', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'settings', 'sub_section' => 'general_settings', 'std' => 0, 'type' => 'checkbox', 'class' => 'checkbox', ), ); $fields = self::push_at_to_associative_array( $fields, array_key_last( $fields ), $additional_hide_fields ); return $fields; } }