nt. * @param WP_Block $block Block instance. * * @return string Rendered block output. */ protected function render( $attributes, $content, $block ) { $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes ); $account_link = get_option( 'woocommerce_myaccount_page_id' ) ? wc_get_account_endpoint_url( 'dashboard' ) : wp_login_url(); $allowed_svg = array( 'svg' => array( 'class' => true, 'xmlns' => true, 'width' => true, 'height' => true, 'viewbox' => true, ), 'path' => array( 'd' => true, 'fill' => true, 'fill-rule' => true, 'clip-rule' => true, ), 'circle' => array( 'cx' => true, 'cy' => true, 'r' => true, 'stroke' => true, 'stroke-width' => true, 'fill' => true, ), ); // Only provide aria-label if the display style is icon only. $aria_label = self::ICON_ONLY === $attributes['displayStyle'] ? 'aria-label="' . esc_attr( $this->render_label() ) . '"' : ''; $label_markup = self::ICON_ONLY === $attributes['displayStyle'] ? '' : '' . wp_kses( $this->render_label(), array() ) . ''; return "
" . wp_kses( $this->render_icon( $attributes ), $allowed_svg ) . $label_markup . '
'; } /** * Gets the icon to render depending on the iconStyle and displayStyle. * * @param array $attributes Block attributes. * * @return string Label to render on the block */ private function render_icon( $attributes ) { if ( self::TEXT_ONLY === $attributes['displayStyle'] ) { return ''; } if ( self::DISPLAY_LINE === $attributes['iconStyle'] ) { return ' '; } if ( self::DISPLAY_ALT === $attributes['iconStyle'] ) { return ' '; } return ' '; } /** * Gets the label to render depending on the displayStyle. * * @return string Label to render on the block. */ private function render_label() { return get_current_user_id() ? __( 'My Account', 'woocommerce' ) : __( 'Login', 'woocommerce' ); } /** * Get the frontend script handle for this block type. * * @param string $key Data to get, or default to everything. * * @return null This block has no frontend script. */ protected function get_block_type_script( $key = null ) { return null; } }