ACF_Repeater_Table::row
Renders an individual row.
Метод класса: ACF_Repeater_Table{}
Хуков нет.
Возвращает
Строку|null.
Использование
$ACF_Repeater_Table = new ACF_Repeater_Table(); $ACF_Repeater_Table->row( $i, $row, $return );
- $i(int) (обязательный)
- The row number.
- $row(массив) (обязательный)
- An array containing the row values.
- $return(true|false)
- If we should return the row or render it.
По умолчанию:false
Список изменений
| С версии 6.0.0 | Введена. |
Код ACF_Repeater_Table::row() ACF Repeater Table::row ACF 6.4.2
public function row( $i, $row, $return = false ) {
if ( $return ) {
ob_start();
}
$id = "row-$i";
$class = 'acf-row';
if ( 'acfcloneindex' === $i ) {
$id = 'acfcloneindex';
$class .= ' acf-clone';
}
$el = 'td';
$before_fields = '';
$after_fields = '';
if ( 'row' === $this->field['layout'] ) {
$el = 'div';
$before_fields = '<td class="acf-fields -left">';
$after_fields = '</td>';
} elseif ( 'block' === $this->field['layout'] ) {
$el = 'div';
$before_fields = '<td class="acf-fields">';
$after_fields = '</td>';
}
printf(
'<tr class="%s" data-id="%s">',
esc_attr( $class ),
esc_attr( $id )
);
$this->row_handle( $i );
echo $before_fields; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- string only contains guarenteed safe HTML.
foreach ( $this->sub_fields as $sub_field ) {
if ( isset( $row[ $sub_field['key'] ] ) ) {
$sub_field['value'] = $row[ $sub_field['key'] ];
} elseif ( isset( $sub_field['default_value'] ) ) {
$sub_field['value'] = $sub_field['default_value'];
}
// Update prefix to allow for nested values.
$sub_field['prefix'] = $this->field['name'] . '[' . $id . ']';
acf_render_field_wrap( $sub_field, $el );
}
echo $after_fields; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- string only contains guarenteed safe HTML.
$this->row_actions();
echo '</tr>';
if ( $return ) {
return ob_get_clean();
}
}