current_repeater = $this->block_type->default_value; $template = sprintf( '', $this->render_repeater_row( $wp_block, false ) ); $html = sprintf( '
%4$s', $this->block_type->block_attrs['name'], $this->block_type->settings, $this->block_type->calc_dataset, $template ); $html .= '
'; if ( ! empty( $this->current_repeater['default'] ) && is_array( $this->current_repeater['default'] ) ) { $i = 0; foreach ( $this->current_repeater['default'] as $item ) { $this->current_repeater['values'] = $item; $html .= $this->render_repeater_row( $wp_block, $i ); $i ++; } $this->current_repeater['values'] = false; } $html .= '
'; if ( 'manually' === $this->block_type->manage_items ) { $html .= sprintf( '
', $this->block_type->new_item_label ); } $html .= '
'; $this->current_repeater = false; return parent::render( null, $html ); } /** * Render current repeater row * * @param $wp_block * @param bool $index * * @return string */ public function render_repeater_row( $wp_block, $index = false ) { if ( false !== $index ) { $this->current_repeater_i = $index; } else { $index = 0; } $html = '
block_type->calc_dataset . '>'; $html .= '
'; Live_Form::instance()->set_repeater( $this->current_repeater, $this->current_repeater_i ); foreach ( $wp_block['innerBlocks'] as $block ) { $html .= render_block( $block ); } $html .= '
'; Live_Form::instance()->set_repeater( false ); if ( 'manually' === $this->block_type->manage_items ) { $html .= '
'; $html .= ''; $html .= '
'; } return $html . '
'; } }