'', 'preset' => 'button-1', 'effects' => '', 'tagName' => 'h2', 'classHook' => '', 'displaySeperator' => false, 'seperatorPosition' => 'bottom', 'seperatorType' => 'line', 'separatorIcon' => 'fas fa-arrow-circle-down', 'enableLink' => false, 'openInNewTab' => false, ]; $attributes = wp_parse_args( is_array( $attributes ) ? $attributes : [], $defaults ); $post_id = 0; if ( $block instanceof WP_Block && ! empty( $block->context['postId'] ) ) { $post_id = (int) $block->context['postId']; } elseif ( get_the_ID() ) { $post_id = (int) get_the_ID(); } if ( ! $post_id ) { return ''; } $title = get_the_title( $post_id ); if ( '' === trim( wp_strip_all_tags( $title ) ) ) { return ''; } $title = sprintf( '%s', wp_kses_post( $title ) ); if ( ! empty( $attributes['enableLink'] ) ) { $new_tab = ! empty( $attributes['openInNewTab'] ); $title = sprintf( '%3$s', esc_url( get_permalink( $post_id ) ), $new_tab ? ' target="_blank" rel="noopener"' : '', $title ); } $allowed_tags = [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p' ]; $tag_name = in_array( $attributes['tagName'], $allowed_tags, true ) ? $attributes['tagName'] : 'h2'; $separator = ''; if ( ! empty( $attributes['displaySeperator'] ) ) { $type = 'icon' === $attributes['seperatorType'] ? 'icon' : 'line'; $icon = ''; if ( 'icon' === $type ) { $icon = advanced_heading_render_icon( (string) $attributes['separatorIcon'] ); } $separator = sprintf( '