e_settings_for_all_sites' ) && C4WP_Functions::c4wp_same_settings_for_all_sites() ) ? true : false; if ( $append_link || ! is_multisite() ) { array_unshift( $links, $settings_link ); } return $links; } /** * Includs help page content. * * @return void */ public static function display_help_page() { require_once 'templates/help/index.php'; } /** * Includs upgrade page content. * * @return void */ public static function display_upgrade_page() { require_once 'templates/upgrade/index.php'; } /** * Help function to push an item to an associate array. * * @param array $array - Original array. * @param string $key - new item key. * @param string $new - New item svalue. * @return array $array - Updated array. */ public static function push_at_to_associative_array( $array, $key, $new ) { $keys = array_keys( $array ); $index = array_search( $key, $keys, true ); $pos = false === $index ? count( $array ) : $index + 1; $array = array_slice( $array, 0, $pos, true ) + $new + array_slice( $array, $pos, count( $array ) - 1, true ); return $array; } /** * Ignore admin notice. * * @return void */ public static function c4wp_nocaptcha_plugin_notice_ignore() { $posted = filter_input_array( INPUT_POST ); // Grab POSTed data. $nonce = sanitize_text_field( $posted[ 'nonce' ] ); $notice_type = sanitize_text_field( $posted[ 'notice_type' ] ); // Check nonce. if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'dismiss_captcha_notice' ) ) { wp_send_json_error( esc_html__( 'Nonce Verification Failed.', 'advanced-nocaptcha-recaptcha' ) ); } if ( 'multisite' == $notice_type ) { global $current_user; $user_id = $current_user->ID; $updated = add_user_meta( $user_id, 'nocaptcha_plugin_notice_ignore', 'true', true ); if ( method_exists( 'C4WP\\C4WP_Functions', 'c4wp_same_settings_for_all_sites' ) && C4WP_Functions::c4wp_same_settings_for_all_sites() ) { update_site_option( 'c4wp_network_notice_dismissed', true ); } else { update_option( 'c4wp_network_notice_dismissed', true ); } wp_send_json_success( $updated ); } elseif ( 'v3_fallback' == $notice_type ) { if ( method_exists( 'C4WP\\C4WP_Functions', 'c4wp_same_settings_for_all_sites' ) && C4WP_Functions::c4wp_same_settings_for_all_sites() ) { update_site_option( 'c4wp_v3_failover_available', false ); } else { update_option( 'c4wp_v3_failover_available', false ); } } wp_send_json_success(); } /** * Handles markup of the popup settings wizard. * * @return $markup - HTML markup. */ public static function wizard_markup() { $fields = self::get_fields(); // Add intro card if this is running in 'first time' mode. $show_wizard_intro = ( empty( C4WP_Functions::c4wp_get_option( 'captcha_version' ) ) && empty( $site_key ) && empty( $secret_key ) ) ? true : false; $logo_url = C4WP_PLUGIN_URL . 'assets/img/c4wp-logo-full.png'; $settings_url = method_exists( 'C4WP\\C4WP_Functions', 'c4wp_same_settings_for_all_sites' ) && C4WP_Functions::c4wp_same_settings_for_all_sites() ? network_admin_url( 'admin.php?page=c4wp-admin-settings' ) : admin_url( 'admin.php?page=c4wp-admin-settings' ); $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 Business plan.
' : ''; $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__( 'Use 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__( "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_version . ' '; $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' ) . '' . esc_html__( trim( C4WP_Functions::c4wp_get_option( 'failure_v2_site_key' ) ) ) . ' '; $markup .= '' . esc_html__( 'Secret key:', 'advanced-nocaptcha-recaptcha' ) . '' . esc_html__( 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' ) . '' . esc_html__( trim( C4WP_Functions::c4wp_get_option( 'failure_redirect' ) ) ) . ' '; } } $markup .= ' |
---|
' ), 'class' => 'wrap-around-content c4wp-wizard-captcha-version', ); $fields = self::push_at_to_associative_array( $fields, array_key_last( $fields ), $additonal_options ); return $fields; } public static function add_delete_data_settings( $fields ) { $additonal_hide_fields = array( 'disable_submit_title' => array( 'section_id' => 'forms', 'type' => 'html', 'class' => 'wrap-around-content', 'label' => sprintf( '%1$s', esc_html__( 'Disable submit button untill CAPTCHA response is provided?', 'advanced-nocaptcha-recaptcha' ) ), ), 'disable_submit_subtitle' => array( 'section_id' => 'forms', 'type' => 'html', 'class' => 'wrap-around-content', 'label' => sprintf( '
%1$s
', esc_html__( 'When using a visible CAPTCHA method (V2 checkbox etc), should we disable the submit button untill the CAPTCHA challenge is completed?', 'advanced-nocaptcha-recaptcha' ) ), ), 'disable_submit' => array( 'label' => esc_html__( 'Disable submit button', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'forms', 'std' => 0, 'type' => 'checkbox', 'class' => 'checkbox', ), 'pass_on_no_captcha_found_title' => array( 'section_id' => 'forms', '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' => 'forms', '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__( 'Disable CAPTCHA tests for logged in users', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'forms', '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' ), ), ), 'delete_data_subtitle' => array( 'section_id' => 'forms', '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' => 'forms', 'std' => 0, 'type' => 'checkbox', 'class' => 'checkbox', ), ); $fields = \C4WP_Settings::push_at_to_associative_array( $fields, array_key_last( $fields ), $additonal_hide_fields ); return $fields; } } //END CLASS