Skip to content

Commit

Permalink
2.4.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Gravity Forms authored and remcotolsma committed Aug 12, 2019
1 parent 0bb10dc commit 0dca6dc
Show file tree
Hide file tree
Showing 69 changed files with 1,425 additions and 889 deletions.
119 changes: 76 additions & 43 deletions change_log.txt

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion common.php
Original file line number Diff line number Diff line change
Expand Up @@ -4388,7 +4388,12 @@ public static function calculate( $field, $form, $lead ) {

if ( preg_match( '/^[0-9 -\/*\(\)]+$/', $formula ) ) {
$prev_reporting_level = error_reporting( 0 );
$result = eval( "return {$formula};" );
try {
$result = eval( "return {$formula};" );
} catch ( ParseError $e ) {
GFCommon::log_debug( __METHOD__ . sprintf( '(): Formula could not be parsed: "%s".', $e->getMessage() ) );
$result = 0;
}
error_reporting( $prev_reporting_level );
}

Expand Down
9 changes: 9 additions & 0 deletions css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -4050,6 +4050,15 @@ div#confirmation-editor {
position: relative;
margin-left: 6px;
color: #444;
top:3px;
}

#feed_condition_conditional_logic_container {
margin-top:10px;
}

.add_field_choice {
margin-left: 16px;
}

#confirmation_action_type {
Expand Down
2 changes: 1 addition & 1 deletion css/admin.min.css

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions export.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,10 @@ function EndSelectExportForm(aryFields, filterSettings) {

return false;
});

$('#export_form').on('change', function() {
SelectExportForm($(this).val());
}).trigger('change');
});

function process( offset, exportId ) {
Expand Down Expand Up @@ -542,7 +546,7 @@ function process( offset, exportId ) {
</th>
<td>

<select id="export_form" name="export_form" onchange="SelectExportForm(jQuery(this).val());">
<select id="export_form" name="export_form">
<option value=""><?php esc_html_e( 'Select a form', 'gravityforms' ); ?></option>
<?php
$forms = RGFormsModel::get_forms( null, 'title' );
Expand All @@ -558,7 +562,7 @@ function process( offset, exportId ) {

foreach ( $forms as $form ) {
?>
<option value="<?php echo absint( $form->id ) ?>"><?php echo esc_html( $form->title ) ?></option>
<option value="<?php echo absint( $form->id ) ?>" <?php selected( rgget( 'id' ), $form->id ); ?>><?php echo esc_html( $form->title ) ?></option>
<?php
}
?>
Expand Down
8 changes: 3 additions & 5 deletions form_display.php
Original file line number Diff line number Diff line change
Expand Up @@ -2557,15 +2557,13 @@ public static function get_counter_init_script( $form ) {
$error_style = $rte_enabled ? ' ginput_counter_error' : '';

$field_script =
"jQuery('#{$input_id}').textareaCount(" .
" {" .
" 'maxCharacterSize': {$max_length}," .
"if(!jQuery('#{$input_id}+.ginput_counter').length){jQuery('#{$input_id}').textareaCount(" .
" {'maxCharacterSize': {$max_length}," .
" 'originalStyle': 'ginput_counter{$tinymce_style}'," .
" 'truncate': {$truncate}," .
" 'errorStyle' : '{$error_style}'," .
" 'displayFormat' : '#input " . esc_js( __( 'of', 'gravityforms' ) ) . ' #max ' . esc_js( __( 'max characters', 'gravityforms' ) ) . "'" .
" } );" .
"jQuery('#{$input_id}').next( '.ginput_counter' ).attr( 'aria-live', 'polite' );";
" });" . "jQuery('{$input_id}').next('.ginput_counter').attr('aria-live','polite');}";

$script .= gf_apply_filters( array( 'gform_counter_script', $form['id'] ), $field_script, $form['id'], $input_id, $max_length, $field );
}
Expand Down
51 changes: 36 additions & 15 deletions forms_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ public static function update_entry_property( $lead_id, $property_name, $propert

// If property is trash, log user login
if ( $property_name == 'status' && $property_value == 'trash' && ! empty( $current_user->user_login ) ) {
GFCommon::log_debug( __METHOD__ . "(): User ID {$current_user->ID} requested moving of entry #{$lead_id} to trash." );
GFCommon::log_debug( __METHOD__ . "(): User ID {$current_user->ID} requested moving of entry #{$lead_id} to trash." );
}

//updating lead
Expand Down Expand Up @@ -1574,8 +1574,8 @@ public static function delete_entries_by_form( $form_id, $status = '' ) {

// Log user login for user requesting the deletion of entries
if ( ! empty( $current_user->user_login ) ) {
GFCommon::log_debug( __METHOD__ . "(): User ID {$current_user->ID} requested deletion of entries: " . json_encode( $entry_ids ) );
}
GFCommon::log_debug( __METHOD__ . "(): User ID {$current_user->ID} requested deletion of entries: " . json_encode( $entry_ids ) );
}

foreach ( $entry_ids as $entry_id ) {

Expand Down Expand Up @@ -1640,7 +1640,7 @@ public static function delete_views( $form_id ) {
// Log user login for user requesting deletion of views
if ( ! empty( $current_user->user_login ) ) {
GFCommon::log_debug( __METHOD__ . "(): User ID {$current_user->ID} requested deletion of views for form #{$form_id}." );
}
}

$form_view_table = self::get_form_view_table_name();

Expand All @@ -1667,7 +1667,7 @@ public static function delete_form( $form_id ) {
// Log user login for user requesting deletion of form
if ( ! empty( $current_user->user_login ) ) {
GFCommon::log_debug( __METHOD__ . "(): User ID {$current_user->ID} requested deletion of form #{$form_id}." );
}
}

/**
* Fires before a form is deleted
Expand Down Expand Up @@ -1722,7 +1722,7 @@ public static function trash_form( $form_id ) {
// Log user login for user moving the form to trash
if ( ! empty( $current_user->user_login ) ) {
GFCommon::log_debug( __METHOD__ . "(): User ID {$current_user->ID} requested moving of form #{$form_id} to trash." );
}
}
$form_table_name = self::get_form_table_name();
$sql = $wpdb->prepare( "UPDATE $form_table_name SET is_trash=1 WHERE id=%d", $form_id );
$result = $wpdb->query( $sql );
Expand Down Expand Up @@ -2478,7 +2478,7 @@ public static function delete_entry( $entry_id ) {

// Log if user requested deletion of entries
if ( ! empty( $current_user->user_login ) ) {
GFCommon::log_debug( __METHOD__ . "(): User ID {$current_user->ID} requested deletion of entry #{$entry_id}" );
GFCommon::log_debug( __METHOD__ . "(): User ID {$current_user->ID} requested deletion of entry #{$entry_id}" );
}

if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) {
Expand Down Expand Up @@ -3354,7 +3354,13 @@ public static function matches_operation( $val1, $val2, $operation ) {
break;

case 'ends_with' :
// If target value is a 0 set $val2 to 0 rather than the empty string it currently is to prevent false positives.
if ( empty( $val2 ) ) {
$val2 = 0;
}

$start = strlen( $val1 ) - strlen( $val2 );

if ( $start < 0 ) {
return false;
}
Expand Down Expand Up @@ -5059,14 +5065,26 @@ public static function update_entry_field_value( $form, $entry, $field, $entry_m
}

} else {
// Deleting details for this field
$sql = $wpdb->prepare( "DELETE FROM $entry_meta_table_name WHERE entry_id=%d AND meta_key = %s ", $entry_id, $input_id );
if ( $item_index ) {
$sql .= $wpdb->prepare( ' AND item_index=%s', $item_index );
}
$result = $wpdb->query( $sql );
if ( false === $result ) {
return false;
// when the value is empty and no $entry_meta_id was set, check if it's a repeater field.
if ( empty( $entry_meta_id ) && $field instanceof GF_Field_Repeater && isset( $field->fields ) && is_array( $field->fields ) ) {
foreach ( $field->fields as $subfield ) {
self::update_entry_field_value( $form, $entry, $subfield, 0, $subfield->id, '' );
}
} else {
// Deleting details for this field
if ( is_array( $field->inputs ) ) {
$_input_id = ( false === strpos( $input_id, '.' ) ) ? sprintf( '%d.%%', $input_id ) : $input_id;
$sql = $wpdb->prepare( "DELETE FROM $entry_meta_table_name WHERE entry_id=%d AND meta_key LIKE %s ", $entry_id, $_input_id );
} else {
$sql = $wpdb->prepare( "DELETE FROM $entry_meta_table_name WHERE entry_id=%d AND meta_key = %s ", $entry_id, $input_id );
}
if ( $item_index ) {
$sql .= $wpdb->prepare( ' AND item_index=%s', $item_index );
}
$result = $wpdb->query( $sql );
if ( false === $result ) {
return false;
}
}
}

Expand Down Expand Up @@ -5408,6 +5426,9 @@ public static function mu_drop_tables( $drop_tables ) {

$drop_tables = array_merge( $drop_tables, $legacy_tables );

// Prevent the legacy table query notice when they are dropped by wp_uninitialize_site().
remove_filter( 'query', array( 'GFForms', 'filter_query' ) );

return $drop_tables;
}

Expand Down
31 changes: 12 additions & 19 deletions gravityforms.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Gravity Forms
Plugin URI: https://www.gravityforms.com
Description: Easily create web forms and manage form entries within the WordPress admin.
Version: 2.4.10
Version: 2.4.11
Author: rocketgenius
Author URI: https://www.rocketgenius.com
License: GPL-2.0+
Expand Down Expand Up @@ -133,7 +133,7 @@
*
* @var string GF_MIN_WP_VERSION_SUPPORT_TERMS The version number
*/
define( 'GF_MIN_WP_VERSION_SUPPORT_TERMS', '5.0' );
define( 'GF_MIN_WP_VERSION_SUPPORT_TERMS', '5.1' );


if ( ! defined( 'GRAVITY_MANAGER_URL' ) ) {
Expand Down Expand Up @@ -215,7 +215,7 @@ class GFForms {
*
* @var string $version The version number.
*/
public static $version = '2.4.10';
public static $version = '2.4.11';

/**
* Handles background upgrade tasks.
Expand Down Expand Up @@ -586,7 +586,8 @@ public static function activation_hook() {
* @return array $plugins Supported plugins.
*/
public static function set_logging_supported( $plugins ) {
$plugins['gravityforms'] = 'Gravity Forms Core';
$plugins['gravityformsapi'] = 'Gravity Forms API';
$plugins['gravityforms'] = 'Gravity Forms Core';

return $plugins;
}
Expand Down Expand Up @@ -736,20 +737,11 @@ public static function add_security_files() {
* Self-heals suspicious files.
*
* @since Unknown
* @access private
*
* @uses GFForms::heal_wp_upload_dir()
* @uses GFFormsModel::get_upload_root()
* @uses GFForms::rename_suspicious_files_recursive()
*
* @return void
*/
private static function do_self_healing() {

GFCommon::log_debug( __METHOD__ . '(): Start self healing' );

self::heal_wp_upload_dir();

$gf_upload_root = GFFormsModel::get_upload_root();

if ( ! is_dir( $gf_upload_root ) || is_link( $gf_upload_root ) ) {
Expand Down Expand Up @@ -804,12 +796,13 @@ private static function rename_suspicious_files_recursive( $dir ) {
/**
* Renames suspicious content within the wp_upload directory.
*
* @since Unknown
* @access private
* @deprecated 2.4.11
*
* @used-by GFForms::do_self_healing()
* @since Unknown
*/
private static function heal_wp_upload_dir() {
_deprecated_function( 'heal_wp_upload_dir', '2.4.11' );

$wp_upload_dir = wp_upload_dir();

$wp_upload_path = $wp_upload_dir['basedir'];
Expand All @@ -821,7 +814,7 @@ private static function heal_wp_upload_dir() {
// ignores all errors
set_error_handler( '__return_false', E_ALL );

foreach ( glob( $wp_upload_path . DIRECTORY_SEPARATOR . '*_input_*.{php,php5}', GLOB_BRACE ) as $filename ) {
foreach ( glob( $wp_upload_path . DIRECTORY_SEPARATOR . '*_input_*.php' ) as $filename ) {
$mini_hash = substr( wp_hash( $filename ), 0, 6 );
$newName = sprintf( '%s.%s.bak', $filename, $mini_hash );
rename( $filename, $newName );
Expand Down Expand Up @@ -5206,7 +5199,7 @@ public static function delete_old_export_files() {
return;
}
GFCommon::log_debug( __METHOD__ . '(): Start deleting old export files' );
foreach ( glob( $export_folder . DIRECTORY_SEPARATOR . '*.csv', GLOB_BRACE ) as $filename ) {
foreach ( glob( $export_folder . DIRECTORY_SEPARATOR . '*.csv' ) as $filename ) {
$timestamp = filemtime( $filename );
if ( $timestamp < time() - DAY_IN_SECONDS ) {
// Delete files over a day old
Expand Down Expand Up @@ -5238,7 +5231,7 @@ public static function delete_old_log_files() {
return;
}
GFCommon::log_debug( __METHOD__ . '(): Start deleting old log files' );
foreach ( glob( $logs_folder . DIRECTORY_SEPARATOR . '*.txt', GLOB_BRACE ) as $filename ) {
foreach ( glob( $logs_folder . DIRECTORY_SEPARATOR . '*.txt' ) as $filename ) {
$timestamp = filemtime( $filename );
if ( $timestamp < time() - MONTH_IN_SECONDS ) {
// Delete files over one month old
Expand Down
10 changes: 10 additions & 0 deletions includes/addon/class-gf-addon.php
Original file line number Diff line number Diff line change
Expand Up @@ -2540,6 +2540,7 @@ public function settings_dynamic_field_map( $field, $echo = true ) {
$key_field['name'] .= '_key';
$key_field['choices'] = isset( $field['field_map'] ) ? $field['field_map'] : null;
$key_field['class'] = 'key key_{i}';
$key_field['title'] = rgar( $field, 'key_field_title' );

// Define custom key field properties.
$custom_key_field['name'] .= '_custom_key_{i}';
Expand All @@ -2552,6 +2553,7 @@ public function settings_dynamic_field_map( $field, $echo = true ) {
// Define value field properties.
$value_field['name'] .= '_custom_value';
$value_field['class'] = 'value value_{i}';
$value_field['title'] = rgar( $field, 'value_field_title' );

// Remove unneeded field properties.
unset( $field['field_map'], $value_field['field_map'], $key_field['field_map'], $custom_key_field['field_map'] );
Expand All @@ -2561,9 +2563,17 @@ public function settings_dynamic_field_map( $field, $echo = true ) {
$html .= $this->get_error_icon( $field );
}

$header = '';
if ( ! empty( $key_field['title'] ) || ! empty ( $value_field['title'] ) ) {
$header = '<th>' . $key_field['title'] . '</th>' .'
<th>' . $value_field['title'] . '</th>';

}

// Display dynamic field map table.
$html .= '
<table class="settings-field-map-table" cellspacing="0" cellpadding="0">
' . $header . '
<tbody class="repeater">
<tr>
'. $this->get_mapping_field( 'key', $key_field, $custom_key_field ) .'
Expand Down
8 changes: 7 additions & 1 deletion includes/addon/css/gaddon_settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,13 @@ table.settings-field-map-table tbody td {
list-style: decimal;
}

.repeater-buttons .add-item { margin-right: 6px; }
.repeater-buttons .add-item {
margin-right: 6px;
}

.add-item, .remove-item {
color: #444;
}

.mt-gaddon-editor {
float: right;
Expand Down
Loading

0 comments on commit 0dca6dc

Please sign in to comment.