Skip to content

Commit

Permalink
better checkbox html
Browse files Browse the repository at this point in the history
  • Loading branch information
liedekef committed Jan 18, 2025
1 parent d394130 commit e12a45b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
4 changes: 2 additions & 2 deletions eme-events.php
Original file line number Diff line number Diff line change
Expand Up @@ -7189,9 +7189,9 @@ function eme_meta_box_div_event_datetime( $event, $recurrence, $edit_recurrence
<?php esc_html_e( 'The time of the event beginning and end', 'events-made-easy' ); ?>
</p>
</div>
<br>
<p>
<?php echo eme_ui_checkbox_binary( $event['event_properties']['all_day'], 'eme_prop_all_day', __( 'This event lasts all day', 'events-made-easy' ) ); ?>
<br>
</p>
<?php
if ( $show_recurrent_form == 1 ) {
?>
Expand Down
20 changes: 10 additions & 10 deletions eme-formfields.php
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ function eme_replace_task_signupformfields_placeholders( $format ) {
$label = __('Remember me?','events-made-easy');
}
if ( ! $eme_is_admin_request && ! is_user_logged_in()) {
$replacement = eme_ui_checkbox_binary( 0, 'eme_rememberme', $label, 0, 'eme-rememberme-field' );
$replacement = eme_nobreak_checkbox_binary( 0, 'eme_rememberme', $label, 0, 'eme-rememberme-field' );
}
} elseif ( preg_match( '/#_BIRTHDATE(\{.+?\})?$/', $result, $matches ) ) {
if ( isset( $matches[1] ) ) {
Expand Down Expand Up @@ -1337,7 +1337,7 @@ function eme_replace_task_signupformfields_placeholders( $format ) {
}
$fieldname = 'task_gdpr';
if ( ! $eme_is_admin_request ) {
$replacement = eme_ui_checkbox_binary( $gdpr, $fieldname, $label, 1, 'eme-gdpr-field' );
$replacement = eme_nobreak_checkbox_binary( $gdpr, $fieldname, $label, 1, 'eme-gdpr-field' );
}
} elseif ( preg_match( '/#_CFCAPTCHA|#_HCAPTCHA|#_RECAPTCHA|#_CAPTCHA$/', $result ) ) {
if ( !empty($selected_captcha) && ! $captcha_set ) {
Expand Down Expand Up @@ -1938,7 +1938,7 @@ function eme_replace_extra_multibooking_formfields_placeholders( $format, $event
$label = '';
}
if ( ! $eme_is_admin_request ) {
$replacement = eme_ui_checkbox_binary( $gdpr, 'gdpr', $label, 1, 'eme-gdpr-field nodynamicupdates' );
$replacement = eme_nobreak_checkbox_binary( $gdpr, 'gdpr', $label, 1, 'eme-gdpr-field nodynamicupdates' );
}
} elseif ( preg_match( '/#_REMEMBERME(\{.+?\})?/', $result, $matches ) ) {
if ( isset( $matches[1] ) ) {
Expand All @@ -1948,7 +1948,7 @@ function eme_replace_extra_multibooking_formfields_placeholders( $format, $event
$label = __('Remember me?','events-made-easy');
}
if ( ! $eme_is_admin_request && ! is_user_logged_in()) {
$replacement = eme_ui_checkbox_binary( 0, 'eme_rememberme', $label, 0, 'eme-rememberme-field nodynamicupdates' );
$replacement = eme_nobreak_checkbox_binary( 0, 'eme_rememberme', $label, 0, 'eme-rememberme-field nodynamicupdates' );
}
} elseif ( preg_match( '/#_SUBSCRIBE_TO_GROUP\{(.+?)\}(\{.+?\})?/', $result, $matches ) ) {
if ( is_numeric( $matches[1] ) ) {
Expand Down Expand Up @@ -3054,7 +3054,7 @@ function eme_replace_rsvp_formfields_placeholders( $event, $booking, $format = '
}
$fieldname = 'gdpr';
if ( ! $eme_is_admin_request ) {
$replacement = eme_ui_checkbox_binary( $gdpr, $fieldname, $label, 1, 'eme-gdpr-field nodynamicupdates', $disabled );
$replacement = eme_nobreak_checkbox_binary( $gdpr, $fieldname, $label, 1, 'eme-gdpr-field nodynamicupdates', $disabled );
}
}
} elseif ( preg_match( '/#_REMEMBERME(\{.+?\})?/', $result, $matches ) ) {
Expand All @@ -3066,7 +3066,7 @@ function eme_replace_rsvp_formfields_placeholders( $event, $booking, $format = '
$label = __('Remember me?','events-made-easy');
}
if ( ! $eme_is_admin_request && ! is_user_logged_in()) {
$replacement = eme_ui_checkbox_binary( 0, 'eme_rememberme', $label, 0, 'eme-rememberme-field nodynamicupdates' );
$replacement = eme_nobreak_checkbox_binary( 0, 'eme_rememberme', $label, 0, 'eme-rememberme-field nodynamicupdates' );
}
}
} elseif ( preg_match( '/#_SUBSCRIBE_TO_GROUP\{(.+?)\}(\{.+?\})?/', $result, $matches ) ) {
Expand Down Expand Up @@ -3977,7 +3977,7 @@ function eme_replace_membership_formfields_placeholders( $membership, $member, $
}
$fieldname = 'gdpr';
if ( ! $eme_is_admin_request ) {
$replacement = eme_ui_checkbox_binary( $gdpr, $fieldname, $label, 1, "eme-gdpr-field nodynamicupdates $personal_info_class", $disabled );
$replacement = eme_nobreak_checkbox_binary( $gdpr, $fieldname, $label, 1, "eme-gdpr-field nodynamicupdates $personal_info_class", $disabled );
}
} elseif ( preg_match( '/#_REMEMBERME(\{.+?\})?/', $result, $matches ) ) {
if ( isset( $matches[1] ) ) {
Expand All @@ -3987,7 +3987,7 @@ function eme_replace_membership_formfields_placeholders( $membership, $member, $
$label = __('Remember me?','events-made-easy');
}
if ( ! $eme_is_admin_request && ! is_user_logged_in()) {
$replacement = eme_ui_checkbox_binary( 0, 'eme_rememberme', $label, 0, 'eme-rememberme-field nodynamicupdates' );
$replacement = eme_nobreak_checkbox_binary( 0, 'eme_rememberme', $label, 0, 'eme-rememberme-field nodynamicupdates' );
}
} elseif ( preg_match( '/#_SUBSCRIBE_TO_GROUP\{(.+?)\}(\{.+?\})?/', $result, $matches ) ) {
if ( is_numeric( $matches[1] ) ) {
Expand Down Expand Up @@ -4332,7 +4332,7 @@ function eme_replace_subscribeform_placeholders( $format, $unsubscribe = 0 ) {
} else {
$label = '';
}
$replacement = eme_ui_checkbox_binary( $gdpr, 'gdpr', $label, 1, 'eme-gdpr-field' );
$replacement = eme_nobreak_checkbox_binary( $gdpr, 'gdpr', $label, 1, 'eme-gdpr-field' );
} elseif ( preg_match( '/#_REMEMBERME(\{.+?\})?/', $result, $matches ) ) {
if ( isset( $matches[1] ) ) {
// remove { and } (first and last char of second match)
Expand All @@ -4341,7 +4341,7 @@ function eme_replace_subscribeform_placeholders( $format, $unsubscribe = 0 ) {
$label = __('Remember me?','events-made-easy');
}
if ( ! is_user_logged_in()) {
$replacement = eme_ui_checkbox_binary( 0, 'eme_rememberme', $label, 0, 'eme-rememberme-field nodynamicupdates' );
$replacement = eme_nobreak_checkbox_binary( 0, 'eme_rememberme', $label, 0, 'eme-rememberme-field nodynamicupdates' );
}
} elseif ( preg_match( '/#_CFCAPTCHA|#_HCAPTCHA|#_RECAPTCHA|#_CAPTCHA$/', $result ) ) {
if ( !empty($selected_captcha) && ! $captcha_set ) {
Expand Down
2 changes: 1 addition & 1 deletion eme-members.php
Original file line number Diff line number Diff line change
Expand Up @@ -3047,7 +3047,7 @@ function eme_render_members_searchfields( $limit_to_group = 0, $group_to_edit =
$label = __( 'Exact?', 'events-made-easy' );
}
$title = esc_attr(__( 'Exact custom field search match', 'events-made-easy' ));
echo eme_ui_checkbox_binary( $value, 'search_exactmatch', $label, 0, '', "title='$title'");
echo eme_nobreak_checkbox_binary( $value, 'search_exactmatch', $label, 0, '', "title='$title'");
}
}

Expand Down
2 changes: 1 addition & 1 deletion eme-people.php
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@ function eme_render_people_searchfields( $limit_to_group = 0, $group_to_edit = [
$label = __( 'Exact?', 'events-made-easy' );
}
$title = esc_attr(__( 'Exact custom field search match', 'events-made-easy' ));
echo eme_ui_checkbox_binary( $value, 'search_exactmatch', $label, 0, '', "title='$title'");
echo eme_nobreak_checkbox_binary( $value, 'search_exactmatch', $label, 0, '', "title='$title'");
}
}

Expand Down
8 changes: 7 additions & 1 deletion eme-ui-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,16 @@ function eme_ui_checkbox_binary( $option_value, $name, $label = '', $required =
}

$name = wp_strip_all_tags( $name );
$val = "<div class='eme-item'><input $required_att type='checkbox' name='{$name}' id='{$name}' $class_att value='1' $selected $extra_attributes>";
$val = "<input $required_att type='checkbox' name='{$name}' id='{$name}' $class_att value='1' $selected $extra_attributes>";
if ( ! empty( $label ) ) {
$val .= "&nbsp;<label for='{$name}'>" . eme_esc_html_keep_br( $label ) . '</label>';
}
return $val;
}

function eme_nobreak_checkbox_binary( $option_value, $name, $label = '', $required = 0, $class = '', $extra_attributes = '' ) {
$val = "<div class='eme-item'>";
$val .= eme_ui_checkbox_binary( $option_value, $name, $label, $required, $class, $extra_attributes);
$val .= "</div>";
return $val;
}
Expand Down

0 comments on commit e12a45b

Please sign in to comment.