get_sections() as $section_id => $section ) { add_settings_section( $section_id, $section['section_title'], ! empty( $section['section_callback'] ) ? $section['section_callback'] : null, 'anr_admin_options' ); } foreach ( $this->get_fields() as $field_id => $field ) { $args = wp_parse_args( $field, array( 'id' => $field_id, 'label' => '', 'cb_label' => '', 'type' => 'text', 'class' => 'regular-text', 'section_id' => '', 'desc' => '', 'std' => '', ) ); add_settings_field( $args['id'], $args['label'], ! empty( $args['callback'] ) ? $args['callback'] : array( $this, 'callback' ), 'anr_admin_options', $args['section_id'], $args ); } } function get_sections() { $sections = array( 'google_keys' => array( 'section_title' => __( 'Google Keys', 'advanced-nocaptcha-recaptcha' ), 'section_callback' => function() { printf( __( 'Get reCaptcha v2 keys from Google. If you select Invisible captcha, make sure to get keys for Invisible captcha.', 'advanced-nocaptcha-recaptcha' ), 'https://www.google.com/recaptcha/admin' ); }, ), 'forms' => array( 'section_title' => __( 'Forms', 'advanced-nocaptcha-recaptcha' ), ), 'other' => array( 'section_title' => __( 'Other Settings', 'advanced-nocaptcha-recaptcha' ), ), ); return apply_filters( 'anr_settings_sections', $sections ); } function get_fields() { $fields = array( 'site_key' => array( 'label' => __( 'Site Key', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', ), 'secret_key' => array( 'label' => __( 'Secret Key', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'google_keys', ), 'enabled_forms' => array( 'label' => __( 'Enabled Forms', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'forms', 'type' => 'multicheck', 'class' => 'checkbox', 'options' => array( 'login' => __( 'Login Form', 'advanced-nocaptcha-recaptcha' ), 'registration' => __( 'Registration Form', 'advanced-nocaptcha-recaptcha' ), 'ms_user_signup' => __( 'Multisite User Signup Form', 'advanced-nocaptcha-recaptcha' ), 'lost_password' => __( 'Lost Password Form', 'advanced-nocaptcha-recaptcha' ), 'reset_password' => __( 'Reset Password Form', 'advanced-nocaptcha-recaptcha' ), 'comment' => __( 'Comment Form', 'advanced-nocaptcha-recaptcha' ), 'bbp_new' => __( 'bbPress New topic', 'advanced-nocaptcha-recaptcha' ), 'bbp_reply' => __( 'bbPress reply to topic', 'advanced-nocaptcha-recaptcha' ), 'bp_register' => __( 'BuddyPress register', 'advanced-nocaptcha-recaptcha' ), 'wc_checkout' => __( 'WooCommerce Checkout', 'advanced-nocaptcha-recaptcha' ), ), 'desc' => sprintf( __( 'For other forms see Instruction', 'advanced-nocaptcha-recaptcha' ), esc_url( admin_url( 'admin.php?page=anr-instruction' ) ) ), ), 'error_message' => array( 'label' => __( 'Error Message', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'other', 'std' => __( 'Please solve Captcha correctly', 'advanced-nocaptcha-recaptcha' ), ), 'language' => array( 'label' => __( 'Captcha Language', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'other', 'type' => 'select', 'class' => 'regular', 'options' => array( '' => __( 'Auto Detect', 'advanced-nocaptcha-recaptcha' ), 'ar' => __( 'Arabic', 'advanced-nocaptcha-recaptcha' ), 'bg' => __( 'Bulgarian', 'advanced-nocaptcha-recaptcha' ), 'ca' => __( 'Catalan', 'advanced-nocaptcha-recaptcha' ), 'zh-CN' => __( 'Chinese (Simplified)', 'advanced-nocaptcha-recaptcha' ), 'zh-CN' => __( 'Chinese (Traditional)', 'advanced-nocaptcha-recaptcha' ), 'hr' => __( 'Croatian', 'advanced-nocaptcha-recaptcha' ), 'cs' => __( 'Czech', 'advanced-nocaptcha-recaptcha' ), 'da' => __( 'Danish', 'advanced-nocaptcha-recaptcha' ), 'nl' => __( 'Dutch', 'advanced-nocaptcha-recaptcha' ), 'en-GB' => __( 'English (UK)', 'advanced-nocaptcha-recaptcha' ), 'en' => __( 'English (US)', 'advanced-nocaptcha-recaptcha' ), 'fil' => __( 'Filipino', 'advanced-nocaptcha-recaptcha' ), 'fi' => __( 'Finnish', 'advanced-nocaptcha-recaptcha' ), 'fr' => __( 'French', 'advanced-nocaptcha-recaptcha' ), 'fr-CA' => __( 'French (Canadian)', 'advanced-nocaptcha-recaptcha' ), 'de' => __( 'German', 'advanced-nocaptcha-recaptcha' ), 'de-AT' => __( 'German (Austria)', 'advanced-nocaptcha-recaptcha' ), 'de-CH' => __( 'German (Switzerland)', 'advanced-nocaptcha-recaptcha' ), 'el' => __( 'Greek', 'advanced-nocaptcha-recaptcha' ), 'iw' => __( 'Hebrew', 'advanced-nocaptcha-recaptcha' ), 'hi' => __( 'Hindi', 'advanced-nocaptcha-recaptcha' ), 'hu' => __( 'Hungarain', 'advanced-nocaptcha-recaptcha' ), 'id' => __( 'Indonesian', 'advanced-nocaptcha-recaptcha' ), 'it' => __( 'Italian', 'advanced-nocaptcha-recaptcha' ), 'ja' => __( 'Japanese', 'advanced-nocaptcha-recaptcha' ), 'ko' => __( 'Korean', 'advanced-nocaptcha-recaptcha' ), 'lv' => __( 'Latvian', 'advanced-nocaptcha-recaptcha' ), 'lt' => __( 'Lithuanian', 'advanced-nocaptcha-recaptcha' ), 'no' => __( 'Norwegian', 'advanced-nocaptcha-recaptcha' ), 'fa' => __( 'Persian', 'advanced-nocaptcha-recaptcha' ), 'pl' => __( 'Polish', 'advanced-nocaptcha-recaptcha' ), 'pt' => __( 'Portuguese', 'advanced-nocaptcha-recaptcha' ), 'pt-BR' => __( 'Portuguese (Brazil)', 'advanced-nocaptcha-recaptcha' ), 'pt-PT' => __( 'Portuguese (Portugal)', 'advanced-nocaptcha-recaptcha' ), 'ro' => __( 'Romanian', 'advanced-nocaptcha-recaptcha' ), 'ru' => __( 'Russian', 'advanced-nocaptcha-recaptcha' ), 'sr' => __( 'Serbian', 'advanced-nocaptcha-recaptcha' ), 'sk' => __( 'Slovak', 'advanced-nocaptcha-recaptcha' ), 'sl' => __( 'Slovenian', 'advanced-nocaptcha-recaptcha' ), 'es' => __( 'Spanish', 'advanced-nocaptcha-recaptcha' ), 'es-419' => __( 'Spanish (Latin America)', 'advanced-nocaptcha-recaptcha' ), 'sv' => __( 'Swedish', 'advanced-nocaptcha-recaptcha' ), 'th' => __( 'Thai', 'advanced-nocaptcha-recaptcha' ), 'tr' => __( 'Turkish', 'advanced-nocaptcha-recaptcha' ), 'uk' => __( 'Ukrainian', 'advanced-nocaptcha-recaptcha' ), 'vi' => __( 'Vietnamese', 'advanced-nocaptcha-recaptcha' ), ), ), 'theme' => array( 'label' => __( 'Theme', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'other', 'type' => 'select', 'class' => 'regular', 'std' => 'light', 'options' => array( 'light' => __( 'Light', 'advanced-nocaptcha-recaptcha' ), 'dark' => __( 'Dark', 'advanced-nocaptcha-recaptcha' ), ), ), 'size' => array( 'label' => __( 'Size', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'other', 'type' => 'select', 'class' => 'regular', 'std' => 'normal', 'options' => array( 'normal' => __( 'Normal', 'advanced-nocaptcha-recaptcha' ), 'compact' => __( 'Compact', 'advanced-nocaptcha-recaptcha' ), 'invisible' => __( 'Invisible', 'advanced-nocaptcha-recaptcha' ), ), 'desc' => __( 'For invisible captcha set this as Invisible. Make sure to use site key and secret key for invisible captcha', 'advanced-nocaptcha-recaptcha' ), ), 'badge' => array( 'label' => __( 'Badge', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'other', 'type' => 'select', 'class' => 'regular', 'std' => 'bottomright', 'options' => array( 'bottomright' => __( 'Bottom Right', 'advanced-nocaptcha-recaptcha' ), 'bottomleft' => __( 'Bottom Left', 'advanced-nocaptcha-recaptcha' ), 'inline' => __( 'Inline', 'advanced-nocaptcha-recaptcha' ), ), 'desc' => __( 'Badge shows for invisible captcha', 'advanced-nocaptcha-recaptcha' ), ), 'failed_login_allow' => array( 'label' => __( 'Failed login Captcha', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'other', 'std' => 0, 'type' => 'number', 'class' => 'regular-number', 'sanitize_callback' => 'absint', 'desc' => __( 'Show login Captcha after how many failed attempts? 0 = show always', 'advanced-nocaptcha-recaptcha' ), ), 'loggedin_hide' => array( 'label' => __( 'Logged in Hide', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'other', 'type' => 'checkbox', 'class' => 'checkbox', 'cb_label' => __( 'Hide Captcha for logged in users?', 'advanced-nocaptcha-recaptcha' ), ), 'remove_css' => array( 'label' => __( 'Remove CSS', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'other', 'type' => 'checkbox', 'class' => 'checkbox', 'cb_label' => __( "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' ), ), 'no_js' => array( 'label' => __( 'No JS Captcha', 'advanced-nocaptcha-recaptcha' ), 'section_id' => 'other', 'type' => 'checkbox', 'class' => 'checkbox', 'cb_label' => __( 'Show captcha if javascript disabled?', 'advanced-nocaptcha-recaptcha' ), 'desc' => __( 'If JavaScript is a requirement for your site, we advise that you do NOT check this.', 'advanced-nocaptcha-recaptcha' ), ), ); if ( ! class_exists( 'ANR_Pro' ) ) : $fields['pro_notice'] = array( 'section_id' => 'forms', 'type' => 'html', 'std' => '
To support development of "Advanced noCaptcha & invisible Captcha" plugin please purchase PRO version. View Details
%s
', $field['desc'] ); } } function options_sanitize( $value ) { if ( ! $value || ! is_array( $value ) ) { return $value; } $fields = $this->get_fields(); foreach ( $value as $option_slug => $option_value ) { if ( isset( $fields[ $option_slug ] ) && ! empty( $fields[ $option_slug ]['sanitize_callback'] ) ) { $value[ $option_slug ] = call_user_func( $fields[ $option_slug ]['sanitize_callback'], $option_value ); } } return $value; } function menu_page() { add_options_page( __( 'Advanced noCaptcha & invisible captcha Settings', 'advanced-nocaptcha-recaptcha' ), __( 'Advanced noCaptcha & invisible captcha', 'advanced-nocaptcha-recaptcha' ), 'manage_options', 'anr-admin-settings', array( $this, 'admin_settings' ) ); add_submenu_page( 'anr-non-exist-menu', 'Advanced noCaptcha reCaptcha - ' . __( 'Instruction', 'advanced-nocaptcha-recaptcha' ), __( 'Instruction', 'advanced-nocaptcha-recaptcha' ), 'manage_options', 'anr-instruction', array( $this, 'instruction_page' ) ); } function admin_settings() { if ( isset( $_POST['anr_admin_options'] ) && isset( $_POST['action'] ) && 'update' === $_POST['action'] ) { check_admin_referer( 'anr_admin_options-options' ); $value = wp_unslash( $_POST['anr_admin_options'] ); if ( ! is_array( $value ) ) { $value = []; } anr_update_option( $value ); wp_safe_redirect( admin_url( 'options-general.php?page=anr-admin-settings&updated=true' ) ); exit; } ?>