1, 'tab_links' => false, 'tab_align' => 'left', 'validate_steps' => false, 'total_steps' => count( $block['innerBlocks'] ) ]; } return $block_content; } public function render($attr, $content, $block) { if ( empty( $block->inner_blocks ) ) { return '

' . esc_html__( 'Please add some steps to this block.', 'frontend-admin' ) . '

'; } $active_step = 0; $tab_links = isset( $attr['tab_links'] ) ? boolval( $attr['tab_links'] ) : false; $tab_align = isset( $attr['tabs_align'] ) ? $attr['tabs_align'] : 'left'; $validate_steps = ! empty( $attr['validate_steps'] ); global $fea_steps_context; $steps_total = count( $block->inner_blocks ); $fea_steps_context = [ 'active_step' => $active_step, 'tab_links' => $tab_links, 'tab_align' => $tab_align, 'validate_steps' => $validate_steps, 'total_steps' => $steps_total, ]; $tabs = ''; $steps = ''; if( ! empty( $attr['steps_counter_display'] ) ){ $the_step = '' . $active_step . ''; if ( isset( $attr['counter_text'] ) ) { $counter_text = str_replace( '{current_step}', $the_step, esc_html( $attr['counter_text'] ) ); $counter_text = str_replace( '{total_steps}', $steps_total, $counter_text ); } else { $counter_text = esc_html( $attr['counter_prefix'] ) . $the_step . esc_html( $attr['counter_suffix'] ); } $counter = sprintf( '
%s
', $counter_text ); } if ( ! empty( $attr['steps_tabs_display'] ) ) { foreach ( $block->inner_blocks as $index => $step_block ) { $title = ! empty( $step_block->attributes['title'] ) ? $step_block->attributes['title'] : 'Step ' . ( $index + 1 ); $active_class = $index === $active_step ? 'active' : ''; $tabs .= sprintf( '', $active_class, $tab_links ? 'change-step' : '', $index + 1, esc_html( $title ) ); } } $container_attributes = sprintf( 'class="frontend-admin-steps fea-form-steps-tabs-align-%s"', esc_attr( $tab_align ) ); if( $validate_steps ){ $container_attributes .= ' data-validate-steps="true"'; } ob_start(); ?>
>