Allow settings items without titles

This commit is contained in:
Alex P 2022-01-13 08:24:33 +02:00
parent 39367e7b51
commit f5e02e8c93
2 changed files with 17 additions and 4 deletions

View file

@ -81,7 +81,7 @@
}
/* Probably not the best location for this but will do until there's a general purpose settings CSS file. */
.ppcp-settings-field-heading td, .ppcp-settings-field-heading th {
.ppcp-settings-field-heading td, .ppcp-settings-field-heading th, .ppcp-settings-no-title-col td {
padding-left: 0;
}

View file

@ -377,6 +377,16 @@ $data_rows_html
?>
<input type="hidden" name="ppcp-nonce" value="<?php echo esc_attr( $nonce ); ?>">
<?php
// Create a hidden first row with 2 cells to avoid issues with table-layout: fixed
// when the first visible row needs to have one cell.
?>
<tr style="height: 1px; padding-top: 0; padding-bottom: 0;">
<th style="padding-top: 0; padding-bottom: 0;"></th>
<td style="padding-top: 0; padding-bottom: 0;"></td>
</tr>
<?php
foreach ( $this->fields as $field => $config ) :
if ( ! in_array( $this->state->current_state(), $config['screens'], true ) ) {
continue;
@ -406,14 +416,17 @@ $data_rows_html
$key = 'ppcp[' . $field . ']';
$id = 'ppcp-' . $field;
$config['id'] = $id;
$colspan = 'ppcp-heading' !== $config['type'] ? 1 : 2;
$colspan = ( 'ppcp-heading' !== $config['type'] && isset( $config['title'] ) ) ? 1 : 2;
$classes = isset( $config['classes'] ) ? $config['classes'] : array();
$classes[] = sprintf( 'ppcp-settings-field-%s', str_replace( 'ppcp-', '', $config['type'] ) );
$description = isset( $config['description'] ) ? $config['description'] : '';
if ( 1 !== $colspan ) {
$classes[] = 'ppcp-settings-no-title-col';
}
$description = isset( $config['description'] ) ? $config['description'] : '';
unset( $config['description'] );
?>
<tr valign="top" id="<?php echo esc_attr( 'field-' . $field ); ?>" class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>">
<?php if ( 'ppcp-heading' !== $config['type'] ) : ?>
<?php if ( 'ppcp-heading' !== $config['type'] && isset( $config['title'] ) ) : ?>
<th scope="row">
<label
for="<?php echo esc_attr( $id ); ?>"