Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak - Hidden field editable compatibility #1327

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion includes/evf-core-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,8 @@
$id = trim( $id );
$parts = array();

$is_edit_entry = isset( $_GET['edit-entry'] ) && ! sanitize_text_field( wp_unslash( empty( $_GET['edit-entry'] ) ) ) ? true : false;

if ( ! empty( $id ) ) {
$id = sanitize_html_class( $id );
if ( ! empty( $id ) ) {
Expand All @@ -984,6 +986,10 @@
if ( ! empty( $class ) ) {
$class = evf_sanitize_classes( $class, true );
if ( ! empty( $class ) ) {
// While editing hidden field should be visible.
if ( $is_edit_entry ) {
$class = str_replace( 'evf-field-hidden', '', $class );
}
$parts[] = 'class="' . $class . '"';
}
}
Expand All @@ -1003,7 +1009,12 @@
} else {
$escaped_att = sanitize_html_class( $att );
}
$parts[] = $escaped_att . '="' . esc_attr( $val ) . '"';
// While editing, fields must be visible even if they are hidden.
if ( 'style' == $escaped_att && $is_edit_entry ) {
$parts[] = 'style = "display: block"';
} else {
$parts[] = $escaped_att . '="' . esc_attr( $val ) . '"';
}
}
}
}
Expand Down Expand Up @@ -1132,7 +1143,7 @@
* @return array of form data.
*/
function evf_get_all_forms( $skip_disabled_entries = false, $check_disable_storing_entry_info = true ) {
if( is_null( evf()->form ) ) {

Check failure on line 1146 in includes/evf-core-functions.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

Space after opening control structure is required

Check failure on line 1146 in includes/evf-core-functions.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

No space before opening parenthesis is prohibited

Check failure on line 1146 in includes/evf-core-functions.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

Expected 1 space(s) after IF keyword; 0 found
return array();
}
$forms = array();
Expand Down Expand Up @@ -1568,11 +1579,11 @@
return false;
}

/** To handle the backward compatibility for those user who is still using the plus and professional plan license key.

Check failure on line 1582 in includes/evf-core-functions.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

Doc comment for parameter "$license_plan" missing
*

Check failure on line 1583 in includes/evf-core-functions.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

Expected 1 space(s) before asterisk; 0 found
* @since 3.0.0

Check failure on line 1584 in includes/evf-core-functions.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

Expected 1 space(s) before asterisk; 0 found
* @param $license_plan License plan.

Check failure on line 1585 in includes/evf-core-functions.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

Expected 1 space(s) before asterisk; 0 found

Check failure on line 1585 in includes/evf-core-functions.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

Missing parameter name
*/

Check failure on line 1586 in includes/evf-core-functions.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

Expected 1 space(s) before asterisk; 0 found
function evf_handle_license_plan_compatibility( $license_plan ) {
$license_plan = ( 'plus' === $license_plan || 'professional' === $license_plan ) ? 'personal' : $license_plan;
return $license_plan;
Expand Down Expand Up @@ -4543,7 +4554,7 @@
$value = wp_kses_post( $data->value );
} elseif ( 'settings[external_url]' === $data->name ) {
$value = esc_url_raw( $data->value );
} elseif ( preg_match( '/evf_email_message/', $data->name ) || preg_match( '/telegram_message/', $data->name )) {

Check failure on line 4557 in includes/evf-core-functions.php

View workflow job for this annotation

GitHub Actions / Code sniff (PHP 7.4 , WP Latest)

No space before closing parenthesis is prohibited
$value = wp_kses_post( $data->value );
} else {
$value = sanitize_text_field( $data->value );
Expand Down
7 changes: 6 additions & 1 deletion includes/fields/class-evf-field-hidden.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,14 @@ public function field_display( $field, $field_atts, $form_data ) {
// Define data.
$primary = $field['properties']['inputs']['primary'];

// For edit purpose.
$is_edit_entry = isset( $_GET['edit-entry'] ) && sanitize_text_field( wp_unslash( $_GET['edit-entry'] ) ) ? true : false;
$field_type = $is_edit_entry ? 'text' : 'hidden';

// Primary field.
printf(
'<input type="hidden" %s>',
'<input type="%s" %s>',
$field_type,
evf_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] )
);
}
Expand Down
Loading