manager = new FLOATCONNECT_Manager(); } /** * Register frontend hooks. * * @return void */ public function boot(): void { add_action( 'wp_footer', array( $this, 'render' ) ); } /** * Render frontend output. * * @return void */ public function render(): void { $settings = $this->manager->get_settings(); if ( empty( $settings['enabled'] ) ) { return; } $contact = $settings['contact'] ?? array(); if ( ! is_array( $contact ) ) { return; } $this->render_button( $settings, $contact ); } /** * Render the single Free button. * * @param array $settings Plugin settings. * @param array $contact Contact data. * * @return void */ private function render_button( array $settings, array $contact ): void { $value = isset( $contact['value'] ) ? trim( (string) $contact['value'] ) : ''; if ( '' === $value ) { return; } $position = (string) ( $settings['position'] ?? 'bottom-right' ); $button_size = absint( $settings['button_size'] ?? 60 ); $icon_size = absint( $settings['icon_size'] ?? 32 ); $border_radius = absint( $settings['border_radius'] ?? 50 ); $shadow = (string) ( $settings['shadow'] ?? 'soft' ); $animation = (string) ( $settings['animation'] ?? 'none' ); $hover_effect = ! empty( $settings['hover_effect'] ); $bottom_offset = absint( $settings['bottom_offset'] ?? 24 ); $side_offset = absint( $settings['side_offset'] ?? 24 ); $z_index = absint( $settings['z_index'] ?? 999999 ); $classes = array( 'floatconnect', 'floatconnect--single', 'floatconnect--' . sanitize_html_class( $position ), ); if ( 'none' !== $animation ) { $classes[] = 'floatconnect--animation-' . sanitize_html_class( $animation ); } if ( ! $hover_effect ) { $classes[] = 'floatconnect--no-hover'; } $classes[] = 'floatconnect--shadow-' . sanitize_html_class( $shadow ); $style = sprintf( '--floatconnect-size:%dpx;--floatconnect-icon-size:%dpx;--floatconnect-bottom:%dpx;--floatconnect-side:%dpx;--floatconnect-radius:%d%%;--floatconnect-z:%d;', $button_size, $icon_size, $bottom_offset, $side_offset, $border_radius, $z_index ); ?>
render_contact( $contact ); ?>
$contact Contact data. * * @return void */ private function render_contact( array $contact ): void { $type = isset( $contact['type'] ) ? (string) $contact['type'] : ''; $label = isset( $contact['label'] ) ? (string) $contact['label'] : ''; $value = isset( $contact['value'] ) ? trim( (string) $contact['value'] ) : ''; if ( '' === $value ) { return; } $href = $this->get_contact_url( $type, $value ); if ( '' === $href ) { return; } $aria_label = ( '' !== $label ? $label : ucfirst( $type ) ); $icon_file = ''; $allowed_icons = array( 'whatsapp', 'phone', 'email', 'messenger', 'telegram', 'custom', ); if ( in_array( $type, $allowed_icons, true ) ) { $icon_file = FLOATCONNECT_PATH . 'includes/Frontend/Icons/' . sanitize_file_name( $type ) . '.php'; } ?> target="_blank" rel="noopener noreferrer" >