self::PAGE ), $a ), admin_url( 'admin.php' ) ); } public static function save(): void { if ( ! current_user_can( self::CAP ) ) { wp_die( esc_html__( 'You are not allowed to do this.', 'ason-chat-button' ), 403 ); } check_admin_referer( 'ason_cb_save' ); $in = isset( $_POST['s'] ) && is_array( $_POST['s'] ) ? wp_unslash( $_POST['s'] ) : array(); $new = Settings::sanitize( (array) $in ); update_option( Settings::OPT, $new, true ); Settings::register_strings(); $args = array( 'saved' => 1 ); if ( isset( $in['phone'] ) && '' !== trim( (string) $in['phone'] ) && '' === $new['phone'] ) { $args['bad_phone'] = 1; } wp_safe_redirect( self::url( $args ) ); exit; } private static function tabs(): array { return (array) apply_filters( 'ason_chat_button_admin_tabs', array( 'settings' => __( 'Settings', 'ason-chat-button' ), 'usage' => __( 'Usage', 'ason-chat-button' ), ) ); } public static function render(): void { if ( ! current_user_can( self::CAP ) ) { return; } $tabs = self::tabs(); $tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : 'settings'; $tab = isset( $tabs[ $tab ] ) ? $tab : 'settings'; echo '
' . esc_html__( 'Settings saved.', 'ason-chat-button' ) . '
' . esc_html__( 'The phone number is not valid. Enter it with the country code, digits only (8–15 digits), e.g. 90 5xx xxx xx xx. The button is hidden until a valid number is saved.', 'ason-chat-button' ) . '
' . esc_html( $t ) . '
'; } private static function render_settings(): void { $s = Settings::all(); echo ''; if ( '' !== $s['phone'] ) { $ctx = array( 'type' => 'general', 'title' => wp_specialchars_decode( (string) get_bloginfo( 'name' ), ENT_QUOTES ), 'url' => home_url( '/' ), 'site' => wp_specialchars_decode( (string) get_bloginfo( 'name' ), ENT_QUOTES ), 'id' => 0, ); echo '' . esc_html( Render::link( $s['phone'], Render::message( $ctx ) ) ) . '
' . esc_html__( 'One floating "⋯" button replaces the WhatsApp button and opens the actions below. Works without JavaScript; a small optional script closes the menu after an action. Corner, size, distances and devices above also apply to this button.', 'ason-chat-button' ) . '
[ason_chat_button] ' . esc_html__( 'adds an inline WhatsApp button, e.g. next to a product call to action.', 'ason-chat-button' ) . '
[ason_chat_button text="Get a quote" message="Hello, I need a quote for {title} ({url})"]