Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/wpforms-.../includes/fields
File: class-checkbox.php
[500] Fix | Delete
// The required constraint in HTML5 form validation does not work with checkbox groups, so omit in AMP.
[501] Fix | Delete
$required_attr = wpforms_is_amp() && count( $choices ) > 1 ? '' : $choice['required'];
[502] Fix | Delete
[503] Fix | Delete
if ( $using_image_choices ) {
[504] Fix | Delete
[505] Fix | Delete
// Make sure the image choices are keyboard-accessible.
[506] Fix | Delete
$choice['label']['attr']['tabindex'] = 0;
[507] Fix | Delete
[508] Fix | Delete
if ( wpforms_is_amp() ) {
[509] Fix | Delete
$choice['label']['attr']['on'] = sprintf(
[510] Fix | Delete
'tap:AMP.setState({ %s: { %s: ! %s[%s] } })',
[511] Fix | Delete
wp_json_encode( $amp_state_id ),
[512] Fix | Delete
wp_json_encode( $choice['id'] ),
[513] Fix | Delete
$amp_state_id,
[514] Fix | Delete
wp_json_encode( $choice['id'] )
[515] Fix | Delete
);
[516] Fix | Delete
$choice['label']['attr']['role'] = 'button';
[517] Fix | Delete
}
[518] Fix | Delete
if ( is_array( $choice['label']['class'] ) && wpforms_is_empty_string( $label ) ) {
[519] Fix | Delete
$choice['label']['class'][] = 'wpforms-field-label-inline-empty';
[520] Fix | Delete
}
[521] Fix | Delete
[522] Fix | Delete
// Image choices.
[523] Fix | Delete
printf(
[524] Fix | Delete
'<label %s>',
[525] Fix | Delete
wpforms_html_attributes( $choice['label']['id'], $choice['label']['class'], $choice['label']['data'], $choice['label']['attr'] )
[526] Fix | Delete
);
[527] Fix | Delete
[528] Fix | Delete
echo '<span class="wpforms-image-choices-image">';
[529] Fix | Delete
[530] Fix | Delete
if ( ! empty( $choice['image'] ) ) {
[531] Fix | Delete
printf(
[532] Fix | Delete
'<img src="%s" alt="%s"%s>',
[533] Fix | Delete
esc_url( $choice['image'] ),
[534] Fix | Delete
esc_attr( $label ),
[535] Fix | Delete
! empty( $label ) ? ' title="' . esc_attr( $label ) . '"' : ''
[536] Fix | Delete
);
[537] Fix | Delete
}
[538] Fix | Delete
[539] Fix | Delete
echo '</span>';
[540] Fix | Delete
[541] Fix | Delete
if ( $field['choices_images_style'] === 'none' ) {
[542] Fix | Delete
echo '<br>';
[543] Fix | Delete
}
[544] Fix | Delete
[545] Fix | Delete
$choice['attr']['tabindex'] = '-1';
[546] Fix | Delete
[547] Fix | Delete
if ( wpforms_is_amp() ) {
[548] Fix | Delete
$choice['attr']['[checked]'] = sprintf(
[549] Fix | Delete
'%s[%s]',
[550] Fix | Delete
$amp_state_id,
[551] Fix | Delete
wp_json_encode( $choice['id'] )
[552] Fix | Delete
);
[553] Fix | Delete
}
[554] Fix | Delete
[555] Fix | Delete
printf(
[556] Fix | Delete
'<input type="checkbox" %s %s %s>',
[557] Fix | Delete
wpforms_html_attributes( $choice['id'], $choice['class'], $choice['data'], $choice['attr'] ),
[558] Fix | Delete
esc_attr( $required_attr ),
[559] Fix | Delete
checked( '1', $choice['default'], false )
[560] Fix | Delete
);
[561] Fix | Delete
[562] Fix | Delete
echo '<span class="wpforms-image-choices-label">' . wp_kses_post( $label ) . '</span>';
[563] Fix | Delete
[564] Fix | Delete
echo '</label>';
[565] Fix | Delete
[566] Fix | Delete
} elseif ( $using_icon_choices ) {
[567] Fix | Delete
[568] Fix | Delete
if ( wpforms_is_amp() ) {
[569] Fix | Delete
$choice['label']['attr']['on'] = sprintf(
[570] Fix | Delete
'tap:AMP.setState({ %s: { %s: ! %s[%s] } })',
[571] Fix | Delete
wp_json_encode( $amp_state_id ),
[572] Fix | Delete
wp_json_encode( $choice['id'] ),
[573] Fix | Delete
$amp_state_id,
[574] Fix | Delete
wp_json_encode( $choice['id'] )
[575] Fix | Delete
);
[576] Fix | Delete
$choice['label']['attr']['role'] = 'button';
[577] Fix | Delete
}
[578] Fix | Delete
[579] Fix | Delete
$choice['attr']['autocomplete'] = 'off';
[580] Fix | Delete
[581] Fix | Delete
// Icon Choices.
[582] Fix | Delete
wpforms()->get( 'icon_choices' )->field_display( $field, $choice, 'checkbox' );
[583] Fix | Delete
[584] Fix | Delete
} else {
[585] Fix | Delete
[586] Fix | Delete
// Normal display.
[587] Fix | Delete
printf(
[588] Fix | Delete
'<input type="checkbox" %s %s %s>',
[589] Fix | Delete
wpforms_html_attributes( $choice['id'], $choice['class'], $choice['data'], $choice['attr'] ),
[590] Fix | Delete
esc_attr( $required_attr ),
[591] Fix | Delete
checked( '1', $choice['default'], false )
[592] Fix | Delete
);
[593] Fix | Delete
[594] Fix | Delete
printf(
[595] Fix | Delete
'<label %s>%s%s</label>',
[596] Fix | Delete
wpforms_html_attributes( $choice['label']['id'], $choice['label']['class'], $choice['label']['data'], $choice['label']['attr'] ),
[597] Fix | Delete
wp_kses_post( $label ),
[598] Fix | Delete
wp_kses(
[599] Fix | Delete
$required,
[600] Fix | Delete
[
[601] Fix | Delete
'span' => [
[602] Fix | Delete
'class' => true,
[603] Fix | Delete
],
[604] Fix | Delete
]
[605] Fix | Delete
)
[606] Fix | Delete
);
[607] Fix | Delete
}
[608] Fix | Delete
[609] Fix | Delete
echo '</li>';
[610] Fix | Delete
}
[611] Fix | Delete
[612] Fix | Delete
echo '</ul>';
[613] Fix | Delete
}
[614] Fix | Delete
[615] Fix | Delete
/**
[616] Fix | Delete
* Validate field on form submit.
[617] Fix | Delete
*
[618] Fix | Delete
* @since 1.5.2
[619] Fix | Delete
*
[620] Fix | Delete
* @param int $field_id Field ID.
[621] Fix | Delete
* @param array $field_submit Submitted field value (raw data).
[622] Fix | Delete
* @param array $form_data Form data.
[623] Fix | Delete
*/
[624] Fix | Delete
public function validate( $field_id, $field_submit, $form_data ) {
[625] Fix | Delete
[626] Fix | Delete
$field = $form_data['fields'][ $field_id ];
[627] Fix | Delete
[628] Fix | Delete
// Skip validation if field is dynamic and choices are empty.
[629] Fix | Delete
if ( $this->is_dynamic_choices_empty( $field, $form_data ) ) {
[630] Fix | Delete
return;
[631] Fix | Delete
}
[632] Fix | Delete
[633] Fix | Delete
$field_submit = (array) $field_submit;
[634] Fix | Delete
$choice_limit = empty( $form_data['fields'][ $field_id ]['choice_limit'] ) ? 0 : (int) $form_data['fields'][ $field_id ]['choice_limit'];
[635] Fix | Delete
$count_choices = count( $field_submit );
[636] Fix | Delete
[637] Fix | Delete
if ( $choice_limit > 0 && $count_choices > $choice_limit ) {
[638] Fix | Delete
// Generating the error.
[639] Fix | Delete
$error = wpforms_setting( 'validation-check-limit', esc_html__( 'You have exceeded the number of allowed selections: {#}.', 'wpforms-lite' ) );
[640] Fix | Delete
$error = str_replace( '{#}', $choice_limit, $error );
[641] Fix | Delete
}
[642] Fix | Delete
[643] Fix | Delete
// Basic required check - If field is marked as required, check for entry data.
[644] Fix | Delete
if (
[645] Fix | Delete
! empty( $form_data['fields'][ $field_id ]['required'] ) &&
[646] Fix | Delete
(
[647] Fix | Delete
empty( $field_submit ) ||
[648] Fix | Delete
(
[649] Fix | Delete
count( $field_submit ) === 1 &&
[650] Fix | Delete
( ! isset( $field_submit[0] ) || (string) $field_submit[0] === '' )
[651] Fix | Delete
)
[652] Fix | Delete
)
[653] Fix | Delete
) {
[654] Fix | Delete
$error = wpforms_get_required_label();
[655] Fix | Delete
}
[656] Fix | Delete
[657] Fix | Delete
if ( ! empty( $error ) ) {
[658] Fix | Delete
wpforms()->get( 'process' )->errors[ $form_data['id'] ][ $field_id ] = $error;
[659] Fix | Delete
}
[660] Fix | Delete
}
[661] Fix | Delete
[662] Fix | Delete
/**
[663] Fix | Delete
* Format and sanitize field.
[664] Fix | Delete
*
[665] Fix | Delete
* @since 1.0.2
[666] Fix | Delete
*
[667] Fix | Delete
* @param int $field_id Field ID.
[668] Fix | Delete
* @param array $field_submit Submitted form data.
[669] Fix | Delete
* @param array $form_data Form data and settings.
[670] Fix | Delete
*/
[671] Fix | Delete
public function format( $field_id, $field_submit, $form_data ) {
[672] Fix | Delete
[673] Fix | Delete
$field_submit = (array) $field_submit;
[674] Fix | Delete
$field = $form_data['fields'][ $field_id ];
[675] Fix | Delete
$dynamic = ! empty( $field['dynamic_choices'] ) ? $field['dynamic_choices'] : false;
[676] Fix | Delete
$name = sanitize_text_field( $field['label'] );
[677] Fix | Delete
$value_raw = wpforms_sanitize_array_combine( $field_submit );
[678] Fix | Delete
[679] Fix | Delete
$data = [
[680] Fix | Delete
'name' => $name,
[681] Fix | Delete
'value' => '',
[682] Fix | Delete
'value_raw' => $value_raw,
[683] Fix | Delete
'id' => wpforms_validate_field_id( $field_id ),
[684] Fix | Delete
'type' => $this->type,
[685] Fix | Delete
];
[686] Fix | Delete
[687] Fix | Delete
if ( 'post_type' === $dynamic && ! empty( $field['dynamic_post_type'] ) ) {
[688] Fix | Delete
[689] Fix | Delete
// Dynamic population is enabled using post type.
[690] Fix | Delete
$value_raw = implode( ',', array_map( 'absint', $field_submit ) );
[691] Fix | Delete
$data['value_raw'] = $value_raw;
[692] Fix | Delete
$data['dynamic'] = 'post_type';
[693] Fix | Delete
$data['dynamic_items'] = $value_raw;
[694] Fix | Delete
$data['dynamic_post_type'] = $field['dynamic_post_type'];
[695] Fix | Delete
$posts = [];
[696] Fix | Delete
[697] Fix | Delete
foreach ( $field_submit as $id ) {
[698] Fix | Delete
$post = get_post( $id );
[699] Fix | Delete
[700] Fix | Delete
if ( ! is_wp_error( $post ) && ! empty( $post ) && $data['dynamic_post_type'] === $post->post_type ) {
[701] Fix | Delete
$posts[] = esc_html( wpforms_get_post_title( $post ) );
[702] Fix | Delete
}
[703] Fix | Delete
}
[704] Fix | Delete
[705] Fix | Delete
$data['value'] = ! empty( $posts ) ? wpforms_sanitize_array_combine( $posts ) : '';
[706] Fix | Delete
[707] Fix | Delete
}
[708] Fix | Delete
elseif ( 'taxonomy' === $dynamic && ! empty( $field['dynamic_taxonomy'] ) ) {
[709] Fix | Delete
[710] Fix | Delete
// Dynamic population is enabled using taxonomy.
[711] Fix | Delete
$value_raw = implode( ',', array_map( 'absint', $field_submit ) );
[712] Fix | Delete
$data['value_raw'] = $value_raw;
[713] Fix | Delete
$data['dynamic'] = 'taxonomy';
[714] Fix | Delete
$data['dynamic_items'] = $value_raw;
[715] Fix | Delete
$data['dynamic_taxonomy'] = $field['dynamic_taxonomy'];
[716] Fix | Delete
$terms = [];
[717] Fix | Delete
[718] Fix | Delete
foreach ( $field_submit as $id ) {
[719] Fix | Delete
$term = get_term( $id, $field['dynamic_taxonomy'] );
[720] Fix | Delete
[721] Fix | Delete
if ( ! is_wp_error( $term ) && ! empty( $term ) ) {
[722] Fix | Delete
$terms[] = esc_html( wpforms_get_term_name( $term ) );
[723] Fix | Delete
}
[724] Fix | Delete
}
[725] Fix | Delete
[726] Fix | Delete
$data['value'] = ! empty( $terms ) ? wpforms_sanitize_array_combine( $terms ) : '';
[727] Fix | Delete
[728] Fix | Delete
} else {
[729] Fix | Delete
[730] Fix | Delete
// Normal processing, dynamic population is off.
[731] Fix | Delete
$choice_keys = [];
[732] Fix | Delete
[733] Fix | Delete
// If show_values is true, that means values posted are the raw values
[734] Fix | Delete
// and not the labels. So we need to set label values. Also store
[735] Fix | Delete
// the choice keys.
[736] Fix | Delete
if ( ! empty( $field['show_values'] ) && (int) $field['show_values'] === 1 ) {
[737] Fix | Delete
[738] Fix | Delete
foreach ( $field_submit as $item ) {
[739] Fix | Delete
foreach ( $field['choices'] as $key => $choice ) {
[740] Fix | Delete
// Check if the submitted value is the same as the choice value or if the value is empty and the key matches.
[741] Fix | Delete
// Skip if the submitted value is empty.
[742] Fix | Delete
if ( ( ! empty( $item ) && $item === $choice['value'] ) || ( empty( $choice['value'] ) && (int) str_replace( 'Choice ', '', $item ) === $key ) ) {
[743] Fix | Delete
$value[] = $choice['label'];
[744] Fix | Delete
$choice_keys[] = $key;
[745] Fix | Delete
[746] Fix | Delete
break;
[747] Fix | Delete
}
[748] Fix | Delete
}
[749] Fix | Delete
}
[750] Fix | Delete
[751] Fix | Delete
$data['value'] = ! empty( $value ) ? wpforms_sanitize_array_combine( $value ) : '';
[752] Fix | Delete
[753] Fix | Delete
} else {
[754] Fix | Delete
[755] Fix | Delete
$data['value'] = $value_raw;
[756] Fix | Delete
[757] Fix | Delete
// Determine choices keys, this is needed for image choices.
[758] Fix | Delete
foreach ( $field_submit as $item ) {
[759] Fix | Delete
foreach ( $field['choices'] as $key => $choice ) {
[760] Fix | Delete
/* translators: %s - choice number. */
[761] Fix | Delete
if ( $item === $choice['label'] || $item === sprintf( esc_html__( 'Choice %s', 'wpforms-lite' ), $key ) ) {
[762] Fix | Delete
$choice_keys[] = $key;
[763] Fix | Delete
[764] Fix | Delete
break;
[765] Fix | Delete
}
[766] Fix | Delete
}
[767] Fix | Delete
}
[768] Fix | Delete
}
[769] Fix | Delete
[770] Fix | Delete
// Images choices are enabled, lookup and store image URLs.
[771] Fix | Delete
if ( ! empty( $choice_keys ) && ! empty( $field['choices_images'] ) ) {
[772] Fix | Delete
[773] Fix | Delete
$data['images'] = [];
[774] Fix | Delete
[775] Fix | Delete
foreach ( $choice_keys as $key ) {
[776] Fix | Delete
$data['images'][] = ! empty( $field['choices'][ $key ]['image'] ) ? esc_url_raw( $field['choices'][ $key ]['image'] ) : '';
[777] Fix | Delete
}
[778] Fix | Delete
}
[779] Fix | Delete
}
[780] Fix | Delete
[781] Fix | Delete
// Push field details to be saved.
[782] Fix | Delete
wpforms()->get( 'process' )->fields[ $field_id ] = $data;
[783] Fix | Delete
}
[784] Fix | Delete
}
[785] Fix | Delete
[786] Fix | Delete
new WPForms_Field_Checkbox();
[787] Fix | Delete
[788] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function