api1881.no %s', esc_html__( 'To find or generate a subscription key, log into', '1881-number-lookup' ), \esc_url( 'https://www.api1881.no/' ), esc_html__( 'and navigate to your profile to find your subscriptions. Either create a new set of API keys, or provide the primary key for an existing one.', '1881-number-lookup' ) ); ?>

$option, 'id' => '1881_subscription_key', 'size' => '50', ] ); \add_settings_section( 'dm1881_checkout_settings', esc_html__( 'Checkout Settings', '1881-number-lookup' ), '__return_null', $option, ); \add_settings_field( '1881_checkout_description', esc_html__( 'Checkout text', '1881-number-lookup' ), __NAMESPACE__ . '\\setting_textarea_element_callback', $option, 'dm1881_checkout_settings', [ 'menu' => $option, 'id' => '1881_checkout_description', 'width' => '100', 'height' => '4', 'default' => isset( $defaults['1881_checkout_description'] ) ? $defaults['1881_checkout_description'] : '', 'description' => esc_html__( 'The text shown in checkout before the phone field.', '1881-number-lookup' ), ] ); \add_settings_field( '1881_checkout_no_results_msg', esc_html__( 'Message text when number search gave no results', '1881-number-lookup' ), __NAMESPACE__ . '\\setting_text_element_callback', $option, 'dm1881_checkout_settings', [ 'menu' => $option, 'id' => '1881_checkout_no_results_msg', 'size' => '100', 'default' => isset( $defaults['1881_checkout_no_results_msg'] ) ? $defaults['1881_checkout_no_results_msg'] : '', ] ); // Allow devs to add additional fields. \do_action( 'dm1881_settings_add_settings_fields' ); \register_setting( $option, $option, [ 'type' => 'string', 'sanitize_callback' => __NAMESPACE__ . '\\sanitize_settings', ] ); } /*** * Output standard text input element. * * @param array $args Arguments to setting. */ function setting_text_element_callback( array $args ) { $id = $args['id']; $size = isset( $args['size'] ) ? $args['size'] : '25'; $options = \get_option( $args['menu'] ); if ( isset( $options[ $id ] ) ) { $current = $options[ $id ]; } else { $current = isset( $args['default'] ) ? $args['default'] : ''; } \printf( '', \esc_attr( $id ), \esc_attr( $args['menu'] ), \esc_html( $current ), \esc_attr( $size ) ); if ( isset( $args['description'] ) ) { \printf( '

%s

', \wp_kses_post( $args['description'] ) ); } } /*** * Output standard textarea element. * * @param array $args Arguments to setting. */ function setting_textarea_element_callback( array $args ) { $id = $args['id']; $width = ! empty( $args['width'] ) ? $args['width'] : ''; $height = ! empty( $args['height'] ) ? $args['height'] : ''; $options = \get_option( $args['menu'] ); if ( isset( $options[ $id ] ) ) { $current = $options[ $id ]; } else { $current = isset( $args['default'] ) ? $args['default'] : ''; } \printf( '', \esc_attr( $id ), \esc_attr( $args['menu'] ), \wp_kses_post( $current ), \esc_attr( $width ), \esc_attr( $height ) ); if ( isset( $args['description'] ) ) { \printf( '

%s

', \wp_kses_post( $args['description'] ) ); } } /*** * Sanitize settings. * * @param array $input Settings fields to sanitize. * @return array */ function sanitize_settings( array $input ): array { $output = []; foreach ( $input as $key => $value ) { if ( isset( $input[ $key ] ) ) { if ( \is_array( $input[ $key ] ) ) { foreach ( $input[ $key ] as $sub_key => $sub_value ) { $output[ $key ][ $sub_key ] = \sanitize_text_field( $input[ $key ][ $sub_key ] ); } } else { $output[ $key ] = \sanitize_text_field( $input[ $key ] ); } } } return \apply_filters( 'dm1881_settings_validate_input', $output, $input ); }