$value ) { // Check to see if the current option has a value. If so, process it. if( isset( $input[ $key ] ) ) { // Sanitize phone number if ( $key == 'phone_number' ) { preg_replace('/[^0-9]/', '', $input[$key]); if ( !preg_match("/^\d+$/", $input[$key]) ) { add_settings_error( 'awb_phone_number_invalid', esc_attr( 'settings_updated' ), esc_html__( 'The value you entered in the phone number field is invalid. Please enter a valid number.', 'add-whatsapp-button' ) ); add_action( 'admin_notices', 'print_errors' ); $input[$key] = ''; } } // button_text allows limited inline markup for use as icon label if ( $key === 'button_text' ) { $allowed_label_html = [ 'strong' => [], 'em' => [], 'br' => [] ]; $output[ $key ] = wp_kses( stripslashes( $input[ $key ] ), $allowed_label_html ); } elseif ( $key === 'active_days' ) { // Array of active weekday numbers submitted as awb_settings[active_days][N] $output[ $key ] = is_array( $input[ $key ] ) ? array_values( array_map( 'intval', array_keys( $input[ $key ] ) ) ) : []; } else { // Strip all HTML and PHP tags and properly handle quoted strings $output[ $key ] = strip_tags( stripslashes( $input[ $key ] ) ); } } // end if } // end foreach // Return the array processing any additional functions filtered by this action return apply_filters( 'awb_sanitize_inputs', $output, $input ); } /** * Validate Limiting Hours * * @since 2.0.0 * * @param $hour */ private function validate_limiting_hours( $hour ) { if ( is_numeric( $hour ) && $hour >= 0 && $hour <= 24 ) { return $hour; } else { return ''; } } /** * Print Options Page Content * * Called as a callback in `add_options_page()` for the plugin's settings page. * * @since 2.0.0 */ public function print_options_page_content() { $settings = Plugin::$instance->get_plugin_options(); // Set default button style for Settings Page Preview $button_style = ! empty( $settings['button_type'] ) ? $settings['button_type'] : 'wab-side-rectangle'; // Create default button text (allows limited inline markup) $allowed_label_html = [ 'strong' => [], 'em' => [], 'br' => [] ]; $button_text = ! empty( $settings['button_text'] ) ? wp_kses( $settings['button_text'], $allowed_label_html ) : esc_html__( 'Message Us on WhatsApp', 'add-whatsapp-button' ); // Hide Text span if selected button style is "Icon" $displayNoneIfIcon = ( ! empty( $settings['button_type'] ) && $settings['button_type'] == 'wab-icon-plain' ) ? 'class="awb-hide"' : ''; // Show label rows only when icon type is selected and label is enabled $il_no_show_class = ( ( ! empty( $settings['button_type'] ) && 'wab-icon-plain' !== $settings['button_type'] ) || empty( $settings['icon_label_enable'] ) ) ? ' class="awb-hide"' : ''; // Set default icon size if the button type is WhatsApp icon $icon_size = ! empty( $settings['icon_size'] ) ? sanitize_text_field( $settings['icon_size'] ) : '80'; // If the breakpoint setting is inactive (the "enable breakpoint" checkbox is checked), hide the breakpoint settings. $bp_no_show_class = empty( $settings['enable_breakpoint'] ) ? ' class="awb-hide"' : ''; // If the 'limit hours' setting is inactive, hide the hour controls. $lh_no_show_class = empty( $settings['limit_hours'] ) ? ' class="awb-hide"' : ''; // Default active days Mon–Fri (1–5) when the setting has not been saved yet. $active_days = isset( $settings['active_days'] ) ? (array) $settings['active_days'] : [ 0, 1, 2, 3, 4, 5, 6 ]; $ld_no_show_class = empty( $settings['limit_days'] ) ? ' class="awb-hide"' : ''; // If the 'Hide Button' setting is inactive, hide the radio buttons with the hiding settings. $hb_no_show_class = empty( $settings['enable_hide_button'] ) ? ' class="awb-hide"' : ''; // If the 'Enable Message' setting is inactive, hide the textarea. $em_no_show_class = empty( $settings['enable_message'] ) ? ' class="awb-hide"' : ''; // If the saved button type is not a WhatsApp icon, hide the icon size control. $is_no_show_class = ! empty( $settings['button_type'] ) && 'wab-icon-plain' !== $settings['button_type'] ? ' class="awb-hide"' : ''; // Hide rectangle size rows when button type is icon or unset. $rect_no_show_class = ( empty( $settings['button_type'] ) || 'wab-side-rectangle' !== $settings['button_type'] && 'wab-bottom-rectangle' !== $settings['button_type'] ) ? ' class="awb-hide"' : ''; $button_inline_styles = ''; // Inline Style if ( ! empty( $settings['button_bg_color'] ) || ! empty( $settings['button_text_color'] ) ) { $button_inline_styles = ' style="'; // If there is a saved background color, add it to the button with a style tag. $button_is_not_plain_icon = empty( $settings['button_type'] ) || ( ! empty( $settings['button_type'] ) && 'wab-icon-plain' === $settings['button_type'] ); if ( ! empty( $settings['button_bg_color'] ) && $button_is_not_plain_icon ) { $button_inline_styles .= 'background-color: ' . $settings['button_bg_color'] . ';'; } // If there is a saved text color, add it to the button with a style tag. if ( ! empty( $settings['button_text_color'] ) ) { $button_inline_styles .= ' color: ' . $settings['button_text_color'] . ';'; } $button_inline_styles .= '"'; } ob_start(); ?>


>

>

>

>

> /> Full Remove

/> Hide with toggle button


>

>

>

>

>

>

style="margin-top: 8px;"> __( 'Sun', 'add-whatsapp-button' ), 1 => __( 'Mon', 'add-whatsapp-button' ), 2 => __( 'Tue', 'add-whatsapp-button' ), 3 => __( 'Wed', 'add-whatsapp-button' ), 4 => __( 'Thu', 'add-whatsapp-button' ), 5 => __( 'Fri', 'add-whatsapp-button' ), 6 => __( 'Sat', 'add-whatsapp-button' ), ]; foreach ( $day_labels as $day_num => $day_label ) : ?>

> > > > > > > > > > > > > > > > > >

>

>

>

id == 'settings_page_awb-options' ) { ?>