Skip to content

Commit

Permalink
Merge branch 'kshojib-kshojib/toggle-woocommerce-position-field'
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyvankooten committed May 2, 2023
2 parents ccc35b4 + 3784666 commit a6df2ae
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
1 change: 1 addition & 0 deletions assets/src/js/admin/show-if.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function toggleElement (el, hide, input, condition) {
el.style.visibility = conditionMet ? '' : 'hidden'
} else {
el.style.opacity = conditionMet ? '' : '0.4'
el.style.pointerEvents = conditionMet ? '' : 'none'
}

// disable input fields inside this element to stop sending their values to server
Expand Down
51 changes: 29 additions & 22 deletions integrations/woocommerce/admin-after.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,35 @@

/** @var MC4WP_Integration $integration */

$body_config = array(
'element' => 'mc4wp_integrations[' . $integration->slug . '][enabled]',
'value' => '1',
'hide' => false,
);

$config = array(
'element' => 'mc4wp_integrations[' . $integration->slug . '][implicit]',
'value' => '0',
);

?>
<table class="form-table">
<?php
$config = array(
'element' => 'mc4wp_integrations[' . $integration->slug . '][implicit]',
'value' => '0',
);
?>
<tr valign="top" data-showif="<?php echo esc_attr( json_encode( $config ) ); ?>">
<th scope="row">
<?php _e( 'Position', 'mailchimp-for-wp' ); ?>
</th>
<td>
<select name="mc4wp_integrations[<?php echo $integration->slug; ?>][position]">
<?php

foreach ( $position_options as $value => $label ) {
printf( '<option value="%s" %s>%s</option>', esc_attr( $value ), selected( $value, $opts['position'], false ), esc_html( $label ) );
}
?>

</select>
</td>
</tr>
<tbody class="integration-toggled-settings" data-showif="<?php echo esc_attr( json_encode( $body_config ) ); ?>">
<tr valign="top" data-showif="<?php echo esc_attr( json_encode( $config ) ); ?>">
<th scope="row">
<?php _e( 'Position', 'mailchimp-for-wp' ); ?>
</th>
<td>
<select name="mc4wp_integrations[<?php echo $integration->slug; ?>][position]">
<?php

foreach ( $position_options as $value => $label ) {
printf( '<option value="%s" %s>%s</option>', esc_attr( $value ), selected( $value, $opts['position'], false ), esc_html( $label ) );
}
?>

</select>
</td>
</tr>
</tbody>
</table>

0 comments on commit a6df2ae

Please sign in to comment.