esc_html__( 'Captcha General', 'all-in-one-captcha' ), 'captcha-integration' => esc_html__( 'Captcha Integrations', 'all-in-one-captcha' ), 'login-settings' => esc_html__( 'Login Settings', 'all-in-one-captcha' ), ); ?>
$tab_name ) : ?>

$tab_name ) : ?>
admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'admin-ajax-nonce' ), 'pointer_title' => esc_html__( 'All In One Captcha', 'all-in-one-captcha' ), 'pointer_content' => $pointer_content, ) ); } if ( 'settings_page_aioc-options' === $hook ) { wp_enqueue_style( 'aioc-admin-style', AIOC_URL . '/build/admin.css', array(), AIOC_VERSION ); wp_enqueue_script( 'aioc-admin-script', AIOC_URL . '/build/admin.js', array( 'jquery' ), AIOC_VERSION, true ); wp_localize_script( 'aioc-admin-script', 'AIOC', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'admin-ajax-nonce' ), 'i18n' => array( 'success' => esc_html__( 'Captcha verified successfully.', 'all-in-one-captcha' ), 'error' => esc_html__( 'Error verifying Captcha.', 'all-in-one-captcha' ), 'loading' => esc_html__( 'Loading…', 'all-in-one-captcha' ), 'verify_message' => esc_html__( 'Please submit "Verify Now"', 'all-in-one-captcha' ), 'verify_message_v2' => esc_html__( 'Please check the captcha and submit "Verify Now"', 'all-in-one-captcha' ), ), ) ); } } add_action( 'admin_enqueue_scripts', 'aioc_load_admin_assets' ); /** * Save captcha form data. * * @since 1.0.0 */ function aioc_save_form_data() { if ( isset( $_POST['aioc-nonce'] ) && ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['aioc-nonce'] ) ), 'aioc-captcha-nonce' ) ) { wp_safe_redirect( admin_url( 'options-general.php?page=aioc-options' ) ); exit; } if ( isset( $_POST['aioc-submit'] ) ) { $tab_id = ! empty( $_POST['aioc-tab-id'] ) ? sanitize_text_field( wp_unslash( $_POST['aioc-tab-id'] ) ) : ''; $option_key = ! empty( $_POST['aioc-form-key'] ) ? sanitize_text_field( wp_unslash( $_POST['aioc-form-key'] ) ) : ''; $values = ! empty( $_POST[ $option_key ] ) ? aioc_validate_options_before_save( $_POST[ $option_key ], $tab_id ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash $update_values = ! empty( $_POST[ $option_key ] ) ? aioc_return_merge_options( $option_key, $values ) : ''; aioc_save_form_option( $option_key, $update_values ); $redirect_link = admin_url( 'options-general.php?page=aioc-options' ); $query_array = array( 'aioc-updated' => true ); if ( ! empty( $tab_id ) ) { $query_array['aioc-tab'] = sanitize_text_field( $tab_id ); } $redirect_link = add_query_arg( $query_array, $redirect_link ); wp_safe_redirect( $redirect_link ); exit; } } add_action( 'admin_init', 'aioc_save_form_data' ); /** * Return merge options. * * @since 1.0.0 * * @param string $option_key Key name. * @param array $values Update values. * @return array $option_values Merge values. */ function aioc_return_merge_options( $option_key, $values ) { $key = get_option( $option_key ); $option_values = ! empty( $key ) ? $key : aioc_get_default_options( $option_key ); if ( ! empty( $values ) || $option_values ) { foreach ( $values as $key => $value ) { $option_values[ $key ] = $value; } } return $option_values; } /** * Save form in option table. * * @since 1.0.0 * * @param string $option_key Key name. * @param array $update_values Update values. */ function aioc_save_form_option( $option_key, $update_values ) { if ( ! empty( $option_key ) || ! empty( $update_values ) ) { update_option( $option_key, $update_values ); } } /** * Render admin notice success. * * @since 1.0.0 */ function aioc_admin_notice_success() { $update = isset( $_GET['aioc-updated'] ) ? (int) $_GET['aioc-updated'] : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( $update ) { ?>