Skip to content

Commit

Permalink
Merge pull request #2718 from QuizandSurveyMaster/CU-86cx4ghmv-undefi…
Browse files Browse the repository at this point in the history
…ne-array-key-issue

Cu 86cx4ghmv undefine array key issue
  • Loading branch information
zubairraeen authored Nov 26, 2024
2 parents 35228fb + d17eafa commit 7a8d289
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion php/classes/class-qmn-plugin-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ public function convert_contacts_to_preferred_date_format( $qsm_qna_array ) {

$qsm_contact_array = $qsm_qna_array['contact'];
foreach ( $qsm_contact_array as $qsm_contact_id => $qsm_contact ) {
if ( 'date' === $qsm_contact['type'] && '' !== $qsm_contact['value'] && null !== $GLOBALS['qsm_date_format'] ) {
if ( ( isset($qsm_contact['type']) && 'date' === $qsm_contact['type'] ) && ( isset($qsm_contact['value']) && '' !== $qsm_contact['value'] ) && null !== $GLOBALS['qsm_date_format'] ) {
$qsm_qna_array['contact'][ $qsm_contact_id ]['value'] = date_i18n( $GLOBALS['qsm_date_format'], strtotime( ( $qsm_contact['value'] ) ) );
}
}
Expand Down
12 changes: 7 additions & 5 deletions php/template-variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,14 @@ function qsm_all_contact_fields_variable( $content, $results ) {
$return = '';
if ( isset( $results['contact'] ) && ( is_array( $results['contact'] ) || is_object( $results['contact'] ) ) ) {
foreach ( $results['contact'] as $results_contact ) {
$options = qsm_get_options_of_contact_fields($contact_form, $results_contact['label'], $results_contact['type'] );
$isRadioOrSelect = in_array($results_contact['type'], [ 'radio', 'select' ], true);
$hasOptions = ! empty(trim($options));
if ( isset( $results_contact['label'] ) && isset( $results_contact['type'] ) && isset( $results_contact['value'] ) ) {
$options = qsm_get_options_of_contact_fields($contact_form, $results_contact['label'], $results_contact['type'] );
$isRadioOrSelect = in_array($results_contact['type'], [ 'radio', 'select' ], true);
$hasOptions = ! empty(trim($options));

if ( ($isRadioOrSelect && $hasOptions) || ! $isRadioOrSelect ) {
$return .= $results_contact['label'] . ': ' . $results_contact['value'] . '<br>';
if ( ($isRadioOrSelect && $hasOptions) || ! $isRadioOrSelect ) {
$return .= $results_contact['label'] . ': ' . $results_contact['value'] . '<br>';
}
}
}
}
Expand Down

0 comments on commit 7a8d289

Please sign in to comment.