$args Optional. account => add --account layout. */ public static function wrapper_class( array $args = array() ): string { $style = Appearance::social_style(); $classes = array( 'forwp-account-signin', 'forwp-account-signin--style-' . $style, ); if ( ! empty( $args['account'] ) ) { $classes[] = 'forwp-account-signin--account'; } if ( ! empty( $args['woocommerce'] ) ) { $classes[] = 'forwp-account-signin--woocommerce'; } return implode( ' ', $classes ); } /** * @param string[] $providers Provider ID => label, or list of IDs. * @param array $args Wrapper args + button args. */ public static function render_list( array $providers, array $args = array() ): string { $labels = ProviderSettings::get_button_labels(); $items = array(); foreach ( $providers as $key => $value ) { if ( is_int( $key ) ) { $id = sanitize_key( (string) $value ); if ( isset( $labels[ $id ] ) ) { $items[ $id ] = $labels[ $id ]; } continue; } $id = sanitize_key( (string) $key ); if ( '' === $id ) { continue; } $items[ $id ] = (string) $value; } if ( empty( $items ) ) { return ''; } $html = '
'; foreach ( $items as $id => $label ) { $html .= self::render_button( (string) $id, (string) $label, $args ); } $html .= '
'; return $html; } /** * @param array $args tag, class, preview, extra_class. */ public static function render_button( string $provider, string $label, array $args = array() ): string { $provider = sanitize_key( $provider ); $style = Appearance::social_style(); $tag = ( isset( $args['tag'] ) && 'span' === $args['tag'] ) ? 'span' : 'button'; $preview = ! empty( $args['preview'] ); $classes = array( 'forwp-account-signin-btn', 'forwp-account-signin-btn-' . $provider, 'forwp-account-signin-btn--' . $style, ); if ( ! empty( $args['extra_class'] ) ) { $classes[] = (string) $args['extra_class']; } $icon = self::icon_html( $provider ); $text = ''; $attrs = array( 'class="' . esc_attr( implode( ' ', $classes ) ) . '"', 'data-provider="' . esc_attr( $provider ) . '"', 'aria-label="' . esc_attr( $label ) . '"', ); if ( 'button' === $tag && ! $preview ) { $attrs[] = 'type="button"'; } return '<' . $tag . ' ' . implode( ' ', $attrs ) . '>' . $icon . $text . ''; } /** * Google outputs both the four-color G and a mono mark; CSS picks one per style. */ public static function icon_html( string $provider ): string { if ( 'gmail' === $provider ) { return '' . ''; } $svg = self::mono_svg( $provider ); if ( '' === $svg ) { return ''; } return ''; } /** * Four-color Google G (native button on white). */ private static function google_color_svg(): string { return ''; } /** * Monochrome marks (currentColor) for solid / icon buttons. */ private static function mono_svg( string $provider ): string { $paths = array( 'gmail' => '', 'github' => '', 'facebook' => '', 'tiktok' => '', 'x' => '', ); if ( ! isset( $paths[ $provider ] ) ) { return ''; } return '' . $paths[ $provider ] . ''; } }