Skip to content
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
53 changes: 28 additions & 25 deletions classes/helpers/FrmAppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1959,31 +1959,32 @@ public static function maybe_autocomplete_options( $args ) {
<?php endforeach; ?>
</select>
<?php
} else {
$options = array();
$autocomplete_value = '';
return;
}

foreach ( $args['source'] as $key => $source ) {
$value_label = self::get_dropdown_value_and_label_from_option( $source, $key, $args );
$options = array();
$autocomplete_value = '';

if ( $value_label['value'] === $args['selected'] ) {
$autocomplete_value = $value_label['label'];
}
foreach ( $args['source'] as $key => $source ) {
$value_label = self::get_dropdown_value_and_label_from_option( $source, $key, $args );

$options[] = $value_label;
if ( $value_label['value'] === $args['selected'] ) {
$autocomplete_value = $value_label['label'];
}

$html_attrs['type'] = 'hidden';
$html_attrs['class'] = 'frm_autocomplete_value_input';
$html_attrs['value'] = $args['selected'];
?>
<input type="text" class="frm-custom-search"
data-source="<?php echo esc_attr( wp_json_encode( $options ) ); ?>"
placeholder="<?php echo esc_attr( $args['autocomplete_placeholder'] ); ?>"
value="<?php echo esc_attr( $autocomplete_value ); ?>" />
<input <?php self::array_to_html_params( $html_attrs, true ); ?> />
<?php
}//end if
$options[] = $value_label;
}

$html_attrs['type'] = 'hidden';
$html_attrs['class'] = 'frm_autocomplete_value_input';
$html_attrs['value'] = $args['selected'];
?>
<input type="text" class="frm-custom-search"
data-source="<?php echo esc_attr( wp_json_encode( $options ) ); ?>"
placeholder="<?php echo esc_attr( $args['autocomplete_placeholder'] ); ?>"
value="<?php echo esc_attr( $autocomplete_value ); ?>" />
<input <?php self::array_to_html_params( $html_attrs, true ); ?> />
<?php
}

/**
Expand Down Expand Up @@ -3606,13 +3607,15 @@ private static function prepare_action_slashes( $val, $key, &$post_content ) {
self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
unset( $k1, $v1 );
}
} else {
// Strip all slashes so everything is the same, no matter where the value is coming from
$val = stripslashes( $val );

// Add backslashes before double quotes and forward slashes only
$post_content[ $key ] = addcslashes( $val, '"\\/' );
return;
}

// Strip all slashes so everything is the same, no matter where the value is coming from
$val = stripslashes( $val );

// Add backslashes before double quotes and forward slashes only
$post_content[ $key ] = addcslashes( $val, '"\\/' );
}

/**
Expand Down
16 changes: 9 additions & 7 deletions classes/helpers/FrmFieldsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,16 @@ private static function prepare_front_field( &$field_array, $field, $args ) {
* @param array $args
*/
$field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $args['entry_id'], $args );
} else {
/**
* @param array $field_array
* @param stdClass $field
* @param array $args
*/
$field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field, $args );

return;
}

/**
* @param array $field_array
* @param stdClass $field
* @param array $args
*/
$field_array = apply_filters( 'frm_setup_new_fields_vars', $field_array, $field, $args );
}

/**
Expand Down
92 changes: 51 additions & 41 deletions classes/helpers/FrmXMLHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -919,27 +919,30 @@ private static function update_custom_style_setting_on_import( &$form ) {
if ( is_numeric( $form['options']['custom_style'] ) && 1 === intval( $form['options']['custom_style'] ) ) {
// Set to default
$form['options']['custom_style'] = 1;
} else {
// Replace the style name with the style ID on import
global $wpdb;
$table = $wpdb->prefix . 'posts';
$where = array(
'post_name' => $form['options']['custom_style'],
'post_type' => 'frm_styles',
);
$select = 'ID';
$style_id = FrmDb::get_var( $table, $where, $select );

if ( $style_id ) {
$form['options']['custom_style'] = $style_id;
} else {
// save the old style to maybe update after styles import
$form['options']['old_style'] = $form['options']['custom_style'];
return;
}

// Set to default
$form['options']['custom_style'] = 1;
}
}//end if
// Replace the style name with the style ID on import
global $wpdb;
$table = $wpdb->prefix . 'posts';
$where = array(
'post_name' => $form['options']['custom_style'],
'post_type' => 'frm_styles',
);
$select = 'ID';
$style_id = FrmDb::get_var( $table, $where, $select );

if ( $style_id ) {
$form['options']['custom_style'] = $style_id;
return;
}

// save the old style to maybe update after styles import
$form['options']['old_style'] = $form['options']['custom_style'];

// Set to default
$form['options']['custom_style'] = 1;
}

/**
Expand Down Expand Up @@ -1524,6 +1527,8 @@ private static function maybe_update_stylesheet( $imported ) {
* @param mixed $result
* @param string $message
* @param array $errors
*
* @return void
*/
public static function parse_message( $result, &$message, &$errors ) {
if ( is_wp_error( $result ) ) {
Expand Down Expand Up @@ -1592,24 +1597,28 @@ public static function parse_message( $result, &$message, &$errors ) {
if ( $message === '<ul>' ) {
$message = '';
$errors[] = __( 'Nothing was imported or updated', 'formidable' );
} else {
self::add_form_link_to_message( $result, $message );

/**
* @since 5.3
*
* @param string $message
* @param array $result
*/
$message = apply_filters( 'frm_xml_parsed_message', $message, $result );
$message .= '</ul>';
return;
}

self::add_form_link_to_message( $result, $message );

/**
* @since 5.3
*
* @param string $message
* @param array $result
*/
$message = apply_filters( 'frm_xml_parsed_message', $message, $result );
$message .= '</ul>';
}

/**
* @param int $m
* @param string $type
* @param array<string> $s_message
*
* @return void
*/
public static function item_count_message( $m, $type, &$s_message ) {
if ( ! $m ) {
Expand Down Expand Up @@ -1637,19 +1646,20 @@ public static function item_count_message( $m, $type, &$s_message ) {

if ( isset( $strings[ $type ] ) ) {
$s_message[] = $strings[ $type ];
} else {
$string = ' ' . $m . ' ' . ucfirst( $type );

/**
* @since 5.3
*
* @param string $string Message string for imported item.
* @param int $m Number of item that was imported.
* }
*/
$string = apply_filters( 'frm_xml_' . $type . '_count_message', $string, $m );
$s_message[] = $string;
return;
}

$string = ' ' . $m . ' ' . ucfirst( $type );

/**
* @since 5.3
*
* @param string $string Message string for imported item.
* @param int $m Number of item that was imported.
* }
*/
$string = apply_filters( 'frm_xml_' . $type . '_count_message', $string, $m );
$s_message[] = $string;
}

/**
Expand Down
Loading