@@ -7,14 +7,14 @@ |
||
| 7 | 7 | |
| 8 | 8 | $gravityview_view = GravityView_View::getInstance(); |
| 9 | 9 | $view_id = $gravityview_view->getViewId(); |
| 10 | -$value = $gravityview_view->search_field['value']; |
|
| 11 | -$label = $gravityview_view->search_field['label']; |
|
| 10 | +$value = $gravityview_view->search_field[ 'value' ]; |
|
| 11 | +$label = $gravityview_view->search_field[ 'label' ]; |
|
| 12 | 12 | |
| 13 | 13 | ?> |
| 14 | 14 | |
| 15 | 15 | <div class="gv-search-box gv-search-field-text gv-search-field-search_all"> |
| 16 | 16 | <div class="gv-search"> |
| 17 | - <?php if( ! gv_empty( $label, false, false ) ) { ?> |
|
| 17 | + <?php if ( ! gv_empty( $label, false, false ) ) { ?> |
|
| 18 | 18 | <label for="gv_search_<?php echo $view_id; ?>"><?php echo esc_html( $label ); ?></label> |
| 19 | 19 | <?php } ?> |
| 20 | 20 | <p><input type="text" name="gv_search" id="gv_search_<?php echo $view_id; ?>" value="<?php echo $value; ?>" /></p> |
@@ -12,8 +12,8 @@ |
||
| 12 | 12 | ?> |
| 13 | 13 | |
| 14 | 14 | <div class="gv-search-box gv-search-field-single_checkbox"> |
| 15 | - <label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" class="gv-check-radio"> |
|
| 16 | - <input type="checkbox" name="<?php echo esc_attr( $search_field['name'] ); ?>" value="1" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" <?php checked( '1', $search_field['value'], true ); ?>> |
|
| 17 | - <?php if( ! gv_empty( $search_field['label'], false, false ) ) { echo esc_html( $search_field['label'] ); } ?> |
|
| 15 | + <label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" class="gv-check-radio"> |
|
| 16 | + <input type="checkbox" name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" value="1" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" <?php checked( '1', $search_field[ 'value' ], true ); ?>> |
|
| 17 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false, false ) ) { echo esc_html( $search_field[ 'label' ] ); } ?> |
|
| 18 | 18 | </label> |
| 19 | 19 | </div> |
| 20 | 20 | \ No newline at end of file |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * @see RGFormsModel::update_lead_property() Trigger when any entry property changes |
| 83 | 83 | */ |
| 84 | - foreach( $this->lead_db_columns as $column ) { |
|
| 84 | + foreach ( $this->lead_db_columns as $column ) { |
|
| 85 | 85 | add_action( 'gform_update_' . $column, array( $this, 'entry_status_changed' ), 10, 3 ); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | return; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - do_action( 'gravityview_log_debug', __METHOD__ . ' adding form ' . $entry['form_id'] . ' to blacklist because entry #' . $lead_id . ' was deleted', array( 'value' => $property_value, 'previous' => $previous_value ) ); |
|
| 117 | + do_action( 'gravityview_log_debug', __METHOD__ . ' adding form ' . $entry[ 'form_id' ] . ' to blacklist because entry #' . $lead_id . ' was deleted', array( 'value' => $property_value, 'previous' => $previous_value ) ); |
|
| 118 | 118 | |
| 119 | - $this->blacklist_add( $entry['form_id'] ); |
|
| 119 | + $this->blacklist_add( $entry[ 'form_id' ] ); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function entry_updated( $form, $lead_id ) { |
| 131 | 131 | |
| 132 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_updated] adding form ' . $form['id'] . ' to blacklist because entry #' . $lead_id . ' was updated' ); |
|
| 132 | + do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_updated] adding form ' . $form[ 'id' ] . ' to blacklist because entry #' . $lead_id . ' was updated' ); |
|
| 133 | 133 | |
| 134 | - $this->blacklist_add( $form['id'] ); |
|
| 134 | + $this->blacklist_add( $form[ 'id' ] ); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -146,9 +146,9 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function entry_created( $entry, $form ) { |
| 148 | 148 | |
| 149 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_created] adding form ' . $form['id'] . ' to blacklist because entry #' . $entry['id'] . ' was created' ); |
|
| 149 | + do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_created] adding form ' . $form[ 'id' ] . ' to blacklist because entry #' . $entry[ 'id' ] . ' was created' ); |
|
| 150 | 150 | |
| 151 | - $this->blacklist_add( $form['id'] ); |
|
| 151 | + $this->blacklist_add( $form[ 'id' ] ); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -164,9 +164,9 @@ discard block |
||
| 164 | 164 | return; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_added] adding form ' . $form['id'] . ' to blacklist because entry #' . $entry['id'] . ' was added' ); |
|
| 167 | + do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_added] adding form ' . $form[ 'id' ] . ' to blacklist because entry #' . $entry[ 'id' ] . ' was added' ); |
|
| 168 | 168 | |
| 169 | - $this->blacklist_add( $form['id'] ); |
|
| 169 | + $this->blacklist_add( $form[ 'id' ] ); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | // Normally just one form, but supports multiple forms |
| 186 | 186 | // |
| 187 | 187 | // Array of IDs 12, 5, 14 would result in `f:12-f:5-f:14` |
| 188 | - $forms = 'f:' . implode( '-f:', (array) $form_ids ); |
|
| 188 | + $forms = 'f:' . implode( '-f:', (array)$form_ids ); |
|
| 189 | 189 | |
| 190 | 190 | // Prefix for transient keys |
| 191 | 191 | // Now the prefix would be: `gv-cache-f:12-f:5-f:14-` |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | ) ); |
| 243 | 243 | |
| 244 | 244 | // Add the passed form IDs |
| 245 | - $blacklist = array_merge( (array) $blacklist, $form_ids ); |
|
| 245 | + $blacklist = array_merge( (array)$blacklist, $form_ids ); |
|
| 246 | 246 | |
| 247 | 247 | // Don't duplicate |
| 248 | 248 | $blacklist = array_unique( $blacklist ); |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | $blacklist = get_option( self::BLACKLIST_OPTION_NAME, array() ); |
| 267 | 267 | |
| 268 | - $updated_list = array_diff( $blacklist, (array) $form_ids ); |
|
| 268 | + $updated_list = array_diff( $blacklist, (array)$form_ids ); |
|
| 269 | 269 | |
| 270 | 270 | do_action( 'gravityview_log_debug', 'GravityView_Cache[blacklist_remove] Removing form IDs from cache blacklist', array( |
| 271 | 271 | '$form_ids' => $form_ids, |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | return false; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - foreach ( (array) $form_ids as $form_id ) { |
|
| 301 | + foreach ( (array)$form_ids as $form_id ) { |
|
| 302 | 302 | |
| 303 | 303 | if ( in_array( $form_id, $blacklist ) ) { |
| 304 | 304 | |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | * @filter `gravityview_cache_time_{$filter_name}` Modify the cache time for a type of cache |
| 371 | 371 | * @param int $time_in_seconds Default: `DAY_IN_SECONDS` |
| 372 | 372 | */ |
| 373 | - $cache_time = (int) apply_filters( 'gravityview_cache_time_' . $filter_name, DAY_IN_SECONDS ); |
|
| 373 | + $cache_time = (int)apply_filters( 'gravityview_cache_time_' . $filter_name, DAY_IN_SECONDS ); |
|
| 374 | 374 | |
| 375 | 375 | do_action( 'gravityview_log_debug', 'GravityView_Cache[set] Setting cache with transient key ' . $this->key . ' for ' . $cache_time . ' seconds' ); |
| 376 | 376 | |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | return; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - foreach ( (array) $form_ids as $form_id ) { |
|
| 409 | + foreach ( (array)$form_ids as $form_id ) { |
|
| 410 | 410 | |
| 411 | 411 | $key = '_transient_gv-cache-'; |
| 412 | 412 | |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | |
| 526 | 526 | if ( GVCommon::has_cap( 'edit_gravityviews' ) ) { |
| 527 | 527 | |
| 528 | - if ( isset( $_GET['cache'] ) || isset( $_GET['nocache'] ) ) { |
|
| 528 | + if ( isset( $_GET[ 'cache' ] ) || isset( $_GET[ 'nocache' ] ) ) { |
|
| 529 | 529 | |
| 530 | 530 | do_action( 'gravityview_log_debug', 'GravityView_Cache[use_cache] Not using cache: ?cache or ?nocache is in the URL' ); |
| 531 | 531 | |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | */ |
| 553 | 553 | $use_cache = apply_filters( 'gravityview_use_cache', $use_cache, $this ); |
| 554 | 554 | |
| 555 | - return (boolean) $use_cache; |
|
| 555 | + return (boolean)$use_cache; |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $this->link_format = $link_format; |
| 84 | 84 | $this->after_link = $after_link; |
| 85 | 85 | $this->context = $context; |
| 86 | - $this->empty_message = function_exists( 'gv_no_results' ) ? gv_no_results() : __('No entries match your request.', 'gravityview'); |
|
| 86 | + $this->empty_message = function_exists( 'gv_no_results' ) ? gv_no_results() : __( 'No entries match your request.', 'gravityview' ); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -169,25 +169,25 @@ discard block |
||
| 169 | 169 | public function get_output() { |
| 170 | 170 | |
| 171 | 171 | // No Entries |
| 172 | - if( empty( $this->entries ) ) { |
|
| 173 | - return '<div class="gv-no-results">'.$this->empty_message.'</div>'; |
|
| 172 | + if ( empty( $this->entries ) ) { |
|
| 173 | + return '<div class="gv-no-results">' . $this->empty_message . '</div>'; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | $output = ''; |
| 177 | 177 | $current_entry = GravityView_View::getInstance()->getCurrentEntry(); |
| 178 | 178 | |
| 179 | - $output .= '<'. $this->wrapper_tag .'>'; |
|
| 179 | + $output .= '<' . $this->wrapper_tag . '>'; |
|
| 180 | 180 | |
| 181 | - foreach( $this->entries as $entry ) { |
|
| 181 | + foreach ( $this->entries as $entry ) { |
|
| 182 | 182 | |
| 183 | - if( $this->skip_entry( $entry, $current_entry ) ) { |
|
| 183 | + if ( $this->skip_entry( $entry, $current_entry ) ) { |
|
| 184 | 184 | continue; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | $output .= $this->get_item_output( $entry ); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - $output .= '</'. $this->wrapper_tag .'>'; |
|
| 190 | + $output .= '</' . $this->wrapper_tag . '>'; |
|
| 191 | 191 | |
| 192 | 192 | /** |
| 193 | 193 | * @filter `gravityview/widget/recent-entries/output` Modify the HTML of the Recent Entries widget output |
@@ -210,15 +210,15 @@ discard block |
||
| 210 | 210 | private function skip_entry( $entry, $current_entry ) { |
| 211 | 211 | |
| 212 | 212 | // If skip entry is off, or there's no current entry, return false |
| 213 | - if( empty( $this->skip_current_entry ) || empty( $current_entry ) ) { |
|
| 213 | + if ( empty( $this->skip_current_entry ) || empty( $current_entry ) ) { |
|
| 214 | 214 | return false; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | // If in Single or Edit mode, $current_entry will be an array. |
| 218 | - $current_entry_id = is_array( $current_entry ) ? $current_entry['id'] : $current_entry; |
|
| 218 | + $current_entry_id = is_array( $current_entry ) ? $current_entry[ 'id' ] : $current_entry; |
|
| 219 | 219 | |
| 220 | 220 | // If the entry ID matches the current entry, yes: skip |
| 221 | - if( $entry['id'] === $current_entry_id ) { |
|
| 221 | + if ( $entry[ 'id' ] === $current_entry_id ) { |
|
| 222 | 222 | return true; |
| 223 | 223 | } |
| 224 | 224 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | |
| 246 | 246 | $item_output = gravityview_get_link( $link, $this->link_format ); |
| 247 | 247 | |
| 248 | - if( !empty( $this->after_link ) ) { |
|
| 248 | + if ( ! empty( $this->after_link ) ) { |
|
| 249 | 249 | |
| 250 | 250 | /** |
| 251 | 251 | * @filter `gravityview/entry-list/after-link` Modify the content displayed after the entry link in an entry list |
@@ -254,14 +254,14 @@ discard block |
||
| 254 | 254 | * @param array $entry Gravity Forms entry array |
| 255 | 255 | * @param GravityView_Entry_List $this The current class instance |
| 256 | 256 | */ |
| 257 | - $after_link = apply_filters( 'gravityview/entry-list/after-link', '<div>'.$this->after_link.'</div>', $entry, $this ); |
|
| 257 | + $after_link = apply_filters( 'gravityview/entry-list/after-link', '<div>' . $this->after_link . '</div>', $entry, $this ); |
|
| 258 | 258 | |
| 259 | 259 | $item_output .= $after_link; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | $item_output = GravityView_API::replace_variables( $item_output, $this->form, $entry ); |
| 263 | 263 | |
| 264 | - $item_output = '<'. $this->item_tag .'>'. $item_output .'</'. $this->item_tag .'>'; |
|
| 264 | + $item_output = '<' . $this->item_tag . '>' . $item_output . '</' . $this->item_tag . '>'; |
|
| 265 | 265 | |
| 266 | 266 | /** |
| 267 | 267 | * @filter `gravityview/entry-list/item` Modify each item's output in an entry list |
@@ -79,11 +79,11 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $sidebars_widgets = wp_get_sidebars_widgets(); |
| 82 | - if ( empty( $sidebars_widgets[ $matches[1] ] ) ) { |
|
| 82 | + if ( empty( $sidebars_widgets[ $matches[ 1 ] ] ) ) { |
|
| 83 | 83 | return $shortcodes; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - foreach ( $sidebars_widgets[ $matches[1] ] as $widgets ) { |
|
| 86 | + foreach ( $sidebars_widgets[ $matches[ 1 ] ] as $widgets ) { |
|
| 87 | 87 | if ( |
| 88 | 88 | /** |
| 89 | 89 | * Blacklisted widgets. |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | strpos( $widgets, 'gv_recent_entries' ) === 0 |
| 93 | 93 | ) { |
| 94 | 94 | |
| 95 | - $shortcodes []= 'et_pb_sidebar'; |
|
| 95 | + $shortcodes [ ] = 'et_pb_sidebar'; |
|
| 96 | 96 | break; |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -22,13 +22,13 @@ |
||
| 22 | 22 | |
| 23 | 23 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
| 24 | 24 | |
| 25 | - unset( $field_options['show_as_link'] ); |
|
| 25 | + unset( $field_options[ 'show_as_link' ] ); |
|
| 26 | 26 | |
| 27 | - if( 'edit' === $context ) { |
|
| 27 | + if ( 'edit' === $context ) { |
|
| 28 | 28 | return $field_options; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - $this->add_field_support('dynamic_data', $field_options ); |
|
| 31 | + $this->add_field_support( 'dynamic_data', $field_options ); |
|
| 32 | 32 | |
| 33 | 33 | return $field_options; |
| 34 | 34 | } |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | |
| 943 | 943 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
| 944 | 944 | |
| 945 | - if( ! $this->is_valid ){ |
|
| 945 | + if( ! $this->is_valid ) { |
|
| 946 | 946 | |
| 947 | 947 | // Keeping this compatible with Gravity Forms. |
| 948 | 948 | $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
@@ -1996,9 +1996,7 @@ discard block |
||
| 1996 | 1996 | // Verify |
| 1997 | 1997 | else if( ! $this->is_edit_entry() ) { |
| 1998 | 1998 | $valid = false; |
| 1999 | - } |
|
| 2000 | - |
|
| 2001 | - else { |
|
| 1999 | + } else { |
|
| 2002 | 2000 | $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
| 2003 | 2001 | } |
| 2004 | 2002 | |
@@ -359,9 +359,9 @@ |
||
| 359 | 359 | |
| 360 | 360 | /** |
| 361 | 361 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
| 362 | - * @since 1.22.2 |
|
| 363 | - * @param bool $unset_hidden_field_values Default: true |
|
| 364 | - * @param GravityView_Edit_Entry_Render $this This object |
|
| 362 | + * @since 1.22.2 |
|
| 363 | + * @param bool $unset_hidden_field_values Default: true |
|
| 364 | + * @param GravityView_Edit_Entry_Render $this This object |
|
| 365 | 365 | */ |
| 366 | 366 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
| 367 | 367 | |
@@ -106,16 +106,16 @@ discard block |
||
| 106 | 106 | function load() { |
| 107 | 107 | |
| 108 | 108 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
| 109 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
| 109 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
| 110 | 110 | |
| 111 | 111 | // Don't display an embedded form when editing an entry |
| 112 | 112 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
| 113 | 113 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
| 114 | 114 | |
| 115 | 115 | // Stop Gravity Forms processing what is ours! |
| 116 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
| 116 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
| 117 | 117 | |
| 118 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
| 118 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
| 119 | 119 | |
| 120 | 120 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
| 121 | 121 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
| 127 | 127 | |
| 128 | 128 | // Add fields expected by GFFormDisplay::validate() |
| 129 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
| 129 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
| 130 | 130 | |
| 131 | 131 | // Fix multiselect value for GF 2.2 |
| 132 | 132 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -143,8 +143,8 @@ discard block |
||
| 143 | 143 | * @return void |
| 144 | 144 | */ |
| 145 | 145 | public function prevent_render_form() { |
| 146 | - if( $this->is_edit_entry() ) { |
|
| 147 | - if( 'wp_head' === current_filter() ) { |
|
| 146 | + if ( $this->is_edit_entry() ) { |
|
| 147 | + if ( 'wp_head' === current_filter() ) { |
|
| 148 | 148 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
| 149 | 149 | } else { |
| 150 | 150 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -159,13 +159,13 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public function prevent_maybe_process_form() { |
| 161 | 161 | |
| 162 | - if( ! empty( $_POST ) ) { |
|
| 162 | + if ( ! empty( $_POST ) ) { |
|
| 163 | 163 | do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if( $this->is_edit_entry_submission() ) { |
|
| 167 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
| 168 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 166 | + if ( $this->is_edit_entry_submission() ) { |
|
| 167 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
| 168 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | public function is_edit_entry() { |
| 177 | 177 | |
| 178 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
| 178 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
| 179 | 179 | |
| 180 | 180 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
| 181 | 181 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @return boolean |
| 187 | 187 | */ |
| 188 | 188 | public function is_edit_entry_submission() { |
| 189 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
| 189 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -197,15 +197,15 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | |
| 199 | 199 | $entries = $gravityview_view->getEntries(); |
| 200 | - self::$original_entry = $entries[0]; |
|
| 201 | - $this->entry = $entries[0]; |
|
| 200 | + self::$original_entry = $entries[ 0 ]; |
|
| 201 | + $this->entry = $entries[ 0 ]; |
|
| 202 | 202 | |
| 203 | 203 | self::$original_form = $gravityview_view->getForm(); |
| 204 | 204 | $this->form = $gravityview_view->getForm(); |
| 205 | 205 | $this->form_id = $gravityview_view->getFormId(); |
| 206 | 206 | $this->view_id = $gravityview_view->getViewId(); |
| 207 | 207 | |
| 208 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
| 208 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | |
@@ -226,14 +226,14 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | // Multiple Views embedded, don't proceed if nonce fails |
| 228 | 228 | $multiple_views = defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) ? gravityview()->views->count() > 1 : $gv_data->has_multiple_views(); |
| 229 | - if( $multiple_views && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) { |
|
| 230 | - do_action('gravityview_log_error', __METHOD__ . ': Nonce validation failed for the Edit Entry request; returning' ); |
|
| 229 | + if ( $multiple_views && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) { |
|
| 230 | + do_action( 'gravityview_log_error', __METHOD__ . ': Nonce validation failed for the Edit Entry request; returning' ); |
|
| 231 | 231 | return; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | // Sorry, you're not allowed here. |
| 235 | - if( false === $this->user_can_edit_entry( true ) ) { |
|
| 236 | - do_action('gravityview_log_error', __METHOD__ . ': User is not allowed to edit this entry; returning', $this->entry ); |
|
| 235 | + if ( false === $this->user_can_edit_entry( true ) ) { |
|
| 236 | + do_action( 'gravityview_log_error', __METHOD__ . ': User is not allowed to edit this entry; returning', $this->entry ); |
|
| 237 | 237 | return; |
| 238 | 238 | } |
| 239 | 239 | |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | private function print_scripts() { |
| 254 | 254 | $gravityview_view = GravityView_View::getInstance(); |
| 255 | 255 | |
| 256 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 256 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 257 | 257 | |
| 258 | - GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false); |
|
| 258 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
| 259 | 259 | |
| 260 | 260 | // Sack is required for images |
| 261 | 261 | wp_print_scripts( array( 'sack', 'gform_gravityforms' ) ); |
@@ -267,32 +267,32 @@ discard block |
||
| 267 | 267 | */ |
| 268 | 268 | private function process_save() { |
| 269 | 269 | |
| 270 | - if( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
| 270 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
| 271 | 271 | return; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | // Make sure the entry, view, and form IDs are all correct |
| 275 | 275 | $valid = $this->verify_nonce(); |
| 276 | 276 | |
| 277 | - if( !$valid ) { |
|
| 278 | - do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); |
|
| 277 | + if ( ! $valid ) { |
|
| 278 | + do_action( 'gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); |
|
| 279 | 279 | return; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - if( $this->entry['id'] !== $_POST['lid'] ) { |
|
| 283 | - do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); |
|
| 282 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
| 283 | + do_action( 'gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); |
|
| 284 | 284 | return; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - do_action('gravityview_log_debug', __METHOD__ . ': $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
| 287 | + do_action( 'gravityview_log_debug', __METHOD__ . ': $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
| 288 | 288 | |
| 289 | 289 | $this->process_save_process_files( $this->form_id ); |
| 290 | 290 | |
| 291 | 291 | $this->validate(); |
| 292 | 292 | |
| 293 | - if( $this->is_valid ) { |
|
| 293 | + if ( $this->is_valid ) { |
|
| 294 | 294 | |
| 295 | - do_action('gravityview_log_debug', __METHOD__ . ': Submission is valid.' ); |
|
| 295 | + do_action( 'gravityview_log_debug', __METHOD__ . ': Submission is valid.' ); |
|
| 296 | 296 | |
| 297 | 297 | /** |
| 298 | 298 | * @hack This step is needed to unset the adminOnly from form fields, to add the calculation fields |
@@ -302,22 +302,22 @@ discard block |
||
| 302 | 302 | /** |
| 303 | 303 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
| 304 | 304 | */ |
| 305 | - unset( $_GET['page'] ); |
|
| 305 | + unset( $_GET[ 'page' ] ); |
|
| 306 | 306 | |
| 307 | - $date_created = $this->entry['date_created']; |
|
| 307 | + $date_created = $this->entry[ 'date_created' ]; |
|
| 308 | 308 | |
| 309 | 309 | /** |
| 310 | 310 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
| 311 | 311 | * @since 1.17.2 |
| 312 | 312 | */ |
| 313 | - unset( $this->entry['date_created'] ); |
|
| 313 | + unset( $this->entry[ 'date_created' ] ); |
|
| 314 | 314 | |
| 315 | 315 | GFFormsModel::save_lead( $form, $this->entry ); |
| 316 | 316 | |
| 317 | 317 | // Delete the values for hidden inputs |
| 318 | 318 | $this->unset_hidden_field_values(); |
| 319 | 319 | |
| 320 | - $this->entry['date_created'] = $date_created; |
|
| 320 | + $this->entry[ 'date_created' ] = $date_created; |
|
| 321 | 321 | |
| 322 | 322 | // Process calculation fields |
| 323 | 323 | $this->update_calculation_fields(); |
@@ -337,10 +337,10 @@ discard block |
||
| 337 | 337 | * @param string $entry_id Numeric ID of the entry that was updated |
| 338 | 338 | * @param GravityView_Edit_Entry_Render $this This object |
| 339 | 339 | */ |
| 340 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this ); |
|
| 340 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this ); |
|
| 341 | 341 | |
| 342 | 342 | } else { |
| 343 | - do_action('gravityview_log_error', __METHOD__ . ': Submission is NOT valid.', $this->entry ); |
|
| 343 | + do_action( 'gravityview_log_error', __METHOD__ . ': Submission is NOT valid.', $this->entry ); |
|
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | } // process_save |
@@ -365,16 +365,16 @@ discard block |
||
| 365 | 365 | */ |
| 366 | 366 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
| 367 | 367 | |
| 368 | - if( ! $unset_hidden_field_values ) { |
|
| 368 | + if ( ! $unset_hidden_field_values ) { |
|
| 369 | 369 | return; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) ) { |
| 373 | 373 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 374 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
| 374 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
| 375 | 375 | } else { |
| 376 | 376 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 377 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
| 377 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | /** No file is being uploaded. */ |
| 458 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 458 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 459 | 459 | /** So return the original upload */ |
| 460 | 460 | return $entry[ $input_id ]; |
| 461 | 461 | } |
@@ -473,11 +473,11 @@ discard block |
||
| 473 | 473 | * @return mixed |
| 474 | 474 | */ |
| 475 | 475 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
| 476 | - if( ! $this->is_edit_entry() ) { |
|
| 476 | + if ( ! $this->is_edit_entry() ) { |
|
| 477 | 477 | return $plupload_init; |
| 478 | 478 | } |
| 479 | 479 | |
| 480 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
| 480 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
| 481 | 481 | |
| 482 | 482 | return $plupload_init; |
| 483 | 483 | } |
@@ -492,22 +492,22 @@ discard block |
||
| 492 | 492 | $form = $this->form; |
| 493 | 493 | |
| 494 | 494 | /** @var GF_Field $field */ |
| 495 | - foreach( $form['fields'] as $k => &$field ) { |
|
| 495 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
| 496 | 496 | |
| 497 | 497 | /** |
| 498 | 498 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
| 499 | 499 | * @since 1.16.3 |
| 500 | 500 | * @var GF_Field $field |
| 501 | 501 | */ |
| 502 | - if( $field->has_calculation() ) { |
|
| 503 | - unset( $form['fields'][ $k ] ); |
|
| 502 | + if ( $field->has_calculation() ) { |
|
| 503 | + unset( $form[ 'fields' ][ $k ] ); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | $field->adminOnly = false; |
| 507 | 507 | |
| 508 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 509 | - foreach( $field->inputs as $key => $input ) { |
|
| 510 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 508 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 509 | + foreach ( $field->inputs as $key => $input ) { |
|
| 510 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
| 511 | 511 | } |
| 512 | 512 | } |
| 513 | 513 | } |
@@ -521,21 +521,21 @@ discard block |
||
| 521 | 521 | $update = false; |
| 522 | 522 | |
| 523 | 523 | // get the most up to date entry values |
| 524 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 524 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 525 | 525 | |
| 526 | - if( !empty( $this->fields_with_calculation ) ) { |
|
| 526 | + if ( ! empty( $this->fields_with_calculation ) ) { |
|
| 527 | 527 | $update = true; |
| 528 | 528 | foreach ( $this->fields_with_calculation as $calc_field ) { |
| 529 | 529 | $inputs = $calc_field->get_entry_inputs(); |
| 530 | 530 | if ( is_array( $inputs ) ) { |
| 531 | 531 | foreach ( $inputs as $input ) { |
| 532 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 532 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
| 533 | 533 | list( $prefix, $field_id, $input_id ) = rgexplode( '_', $input_name, 3 ); |
| 534 | 534 | |
| 535 | 535 | switch ( $input_id ) { |
| 536 | 536 | case 1: |
| 537 | 537 | /** Never void the labels. */ |
| 538 | - $value = $entry[ $input['id'] ]; |
|
| 538 | + $value = $entry[ $input[ 'id' ] ]; |
|
| 539 | 539 | break; |
| 540 | 540 | case 2: |
| 541 | 541 | /** Always recalcualte the final price. */ |
@@ -543,25 +543,25 @@ discard block |
||
| 543 | 543 | break; |
| 544 | 544 | case 3: |
| 545 | 545 | /** Fetch the quantity form the request. */ |
| 546 | - $value = rgpost( $input_name, $entry[ $input['id'] ] ); |
|
| 546 | + $value = rgpost( $input_name, $entry[ $input[ 'id' ] ] ); |
|
| 547 | 547 | break; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, $value, $input_name, $entry['id'], $entry ); |
|
| 550 | + $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, $value, $input_name, $entry[ 'id' ], $entry ); |
|
| 551 | 551 | } |
| 552 | 552 | } else { |
| 553 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
| 554 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
| 553 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id ); |
|
| 554 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | - if( $update ) { |
|
| 560 | + if ( $update ) { |
|
| 561 | 561 | |
| 562 | 562 | $return_entry = GFAPI::update_entry( $entry ); |
| 563 | 563 | |
| 564 | - if( is_wp_error( $return_entry ) ) { |
|
| 564 | + if ( is_wp_error( $return_entry ) ) { |
|
| 565 | 565 | do_action( 'gravityview_log_error', 'Updating the entry calculation fields failed', $return_entry ); |
| 566 | 566 | } else { |
| 567 | 567 | do_action( 'gravityview_log_debug', 'Updating the entry calculation fields succeeded' ); |
@@ -592,18 +592,18 @@ discard block |
||
| 592 | 592 | |
| 593 | 593 | $input_name = 'input_' . $field_id; |
| 594 | 594 | |
| 595 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 595 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 596 | 596 | |
| 597 | 597 | // We have a new image |
| 598 | 598 | |
| 599 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
| 599 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
| 600 | 600 | |
| 601 | 601 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 602 | 602 | $img_url = rgar( $ary, 0 ); |
| 603 | 603 | |
| 604 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
| 605 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
| 606 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
| 604 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
| 605 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
| 606 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
| 607 | 607 | |
| 608 | 608 | $image_meta = array( |
| 609 | 609 | 'post_excerpt' => $img_caption, |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | |
| 613 | 613 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
| 614 | 614 | if ( ! empty( $img_title ) ) { |
| 615 | - $image_meta['post_title'] = $img_title; |
|
| 615 | + $image_meta[ 'post_title' ] = $img_title; |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | /** |
@@ -627,13 +627,13 @@ discard block |
||
| 627 | 627 | set_post_thumbnail( $post_id, $media_id ); |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | - } elseif ( !empty( $_POST[ $input_name ] ) && is_array( $value ) ) { |
|
| 630 | + } elseif ( ! empty( $_POST[ $input_name ] ) && is_array( $value ) ) { |
|
| 631 | 631 | |
| 632 | 632 | $img_url = $_POST[ $input_name ]; |
| 633 | 633 | |
| 634 | - $img_title = rgar( $_POST, $input_name.'_1' ); |
|
| 635 | - $img_caption = rgar( $_POST, $input_name .'_4' ); |
|
| 636 | - $img_description = rgar( $_POST, $input_name .'_7' ); |
|
| 634 | + $img_title = rgar( $_POST, $input_name . '_1' ); |
|
| 635 | + $img_caption = rgar( $_POST, $input_name . '_4' ); |
|
| 636 | + $img_description = rgar( $_POST, $input_name . '_7' ); |
|
| 637 | 637 | |
| 638 | 638 | $value = ! empty( $img_url ) ? $img_url . "|:|" . $img_title . "|:|" . $img_caption . "|:|" . $img_description : ''; |
| 639 | 639 | |
@@ -671,16 +671,16 @@ discard block |
||
| 671 | 671 | */ |
| 672 | 672 | private function maybe_update_post_fields( $form ) { |
| 673 | 673 | |
| 674 | - if( empty( $this->entry['post_id'] ) ) { |
|
| 674 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
| 675 | 675 | do_action( 'gravityview_log_debug', __METHOD__ . ': This entry has no post fields. Continuing...' ); |
| 676 | 676 | return; |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - $post_id = $this->entry['post_id']; |
|
| 679 | + $post_id = $this->entry[ 'post_id' ]; |
|
| 680 | 680 | |
| 681 | 681 | // Security check |
| 682 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 683 | - do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id ); |
|
| 682 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 683 | + do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #' . $post_id ); |
|
| 684 | 684 | return; |
| 685 | 685 | } |
| 686 | 686 | |
@@ -692,25 +692,25 @@ discard block |
||
| 692 | 692 | |
| 693 | 693 | $field = RGFormsModel::get_field( $form, $field_id ); |
| 694 | 694 | |
| 695 | - if( ! $field ) { |
|
| 695 | + if ( ! $field ) { |
|
| 696 | 696 | continue; |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 699 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 700 | 700 | |
| 701 | 701 | // Get the value of the field, including $_POSTed value |
| 702 | 702 | $value = RGFormsModel::get_field_value( $field ); |
| 703 | 703 | |
| 704 | 704 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
| 705 | 705 | $entry_tmp = $this->entry; |
| 706 | - $entry_tmp["{$field_id}"] = $value; |
|
| 706 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
| 707 | 707 | |
| 708 | - switch( $field->type ) { |
|
| 708 | + switch ( $field->type ) { |
|
| 709 | 709 | |
| 710 | 710 | case 'post_title': |
| 711 | 711 | $post_title = $value; |
| 712 | - if( rgar( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 713 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 712 | + if ( rgar( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 713 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
| 714 | 714 | } |
| 715 | 715 | $updated_post->post_title = $post_title; |
| 716 | 716 | $updated_post->post_name = $post_title; |
@@ -719,8 +719,8 @@ discard block |
||
| 719 | 719 | |
| 720 | 720 | case 'post_content': |
| 721 | 721 | $post_content = $value; |
| 722 | - if( rgar( $form, 'postContentTemplateEnabled' ) ) { |
|
| 723 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 722 | + if ( rgar( $form, 'postContentTemplateEnabled' ) ) { |
|
| 723 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
| 724 | 724 | } |
| 725 | 725 | $updated_post->post_content = $post_content; |
| 726 | 726 | unset( $post_content ); |
@@ -738,12 +738,12 @@ discard block |
||
| 738 | 738 | $value = $value[ $field_id ]; |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 741 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 742 | 742 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
| 746 | - $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
| 746 | + $value = function_exists( 'wp_json_encode' ) ? wp_json_encode( $value ) : json_encode( $value ); |
|
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | // update entry after |
| 759 | - $this->entry["{$field_id}"] = $value; |
|
| 759 | + $this->entry[ "{$field_id}" ] = $value; |
|
| 760 | 760 | |
| 761 | 761 | $update_entry = true; |
| 762 | 762 | |
@@ -765,25 +765,25 @@ discard block |
||
| 765 | 765 | |
| 766 | 766 | } |
| 767 | 767 | |
| 768 | - if( $update_entry ) { |
|
| 768 | + if ( $update_entry ) { |
|
| 769 | 769 | |
| 770 | 770 | $return_entry = GFAPI::update_entry( $this->entry ); |
| 771 | 771 | |
| 772 | - if( is_wp_error( $return_entry ) ) { |
|
| 772 | + if ( is_wp_error( $return_entry ) ) { |
|
| 773 | 773 | do_action( 'gravityview_log_error', 'Updating the entry post fields failed', array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ); |
| 774 | 774 | } else { |
| 775 | - do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' ); |
|
| 775 | + do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #' . $post_id . ' succeeded' ); |
|
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | $return_post = wp_update_post( $updated_post, true ); |
| 781 | 781 | |
| 782 | - if( is_wp_error( $return_post ) ) { |
|
| 782 | + if ( is_wp_error( $return_post ) ) { |
|
| 783 | 783 | $return_post->add_data( $updated_post, '$updated_post' ); |
| 784 | 784 | do_action( 'gravityview_log_error', 'Updating the post content failed', compact( 'updated_post', 'return_post' ) ); |
| 785 | 785 | } else { |
| 786 | - do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded', $updated_post ); |
|
| 786 | + do_action( 'gravityview_log_debug', 'Updating the post content for post #' . $post_id . ' succeeded', $updated_post ); |
|
| 787 | 787 | } |
| 788 | 788 | } |
| 789 | 789 | |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | $input_type = RGFormsModel::get_input_type( $field ); |
| 802 | 802 | |
| 803 | 803 | // Only certain custom field types are supported |
| 804 | - switch( $input_type ) { |
|
| 804 | + switch ( $input_type ) { |
|
| 805 | 805 | case 'fileupload': |
| 806 | 806 | case 'list': |
| 807 | 807 | case 'multiselect': |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
| 839 | 839 | |
| 840 | 840 | // replace conditional shortcodes |
| 841 | - if( $do_shortcode ) { |
|
| 841 | + if ( $do_shortcode ) { |
|
| 842 | 842 | $output = do_shortcode( $output ); |
| 843 | 843 | } |
| 844 | 844 | |
@@ -857,19 +857,19 @@ discard block |
||
| 857 | 857 | */ |
| 858 | 858 | private function after_update() { |
| 859 | 859 | |
| 860 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
| 861 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
| 860 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 861 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 862 | 862 | |
| 863 | 863 | // Re-define the entry now that we've updated it. |
| 864 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
| 864 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
| 865 | 865 | |
| 866 | 866 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
| 867 | 867 | |
| 868 | 868 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
| 869 | 869 | // We need to clear the cache because Gravity Forms caches the field values, which |
| 870 | 870 | // we have just updated. |
| 871 | - foreach ($this->form['fields'] as $key => $field) { |
|
| 872 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
| 871 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
| 872 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
| 873 | 873 | } |
| 874 | 874 | } |
| 875 | 875 | |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | |
| 889 | 889 | <div class="gv-edit-entry-wrapper"><?php |
| 890 | 890 | |
| 891 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
| 891 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
| 892 | 892 | |
| 893 | 893 | /** |
| 894 | 894 | * Fixes weird wpautop() issue |
@@ -904,7 +904,7 @@ discard block |
||
| 904 | 904 | * @param string $edit_entry_title Modify the "Edit Entry" title |
| 905 | 905 | * @param GravityView_Edit_Entry_Render $this This object |
| 906 | 906 | */ |
| 907 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 907 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
| 908 | 908 | |
| 909 | 909 | echo esc_attr( $edit_entry_title ); |
| 910 | 910 | ?></span> |
@@ -950,20 +950,20 @@ discard block |
||
| 950 | 950 | */ |
| 951 | 951 | private function maybe_print_message() { |
| 952 | 952 | |
| 953 | - if( rgpost('action') === 'update' ) { |
|
| 953 | + if ( rgpost( 'action' ) === 'update' ) { |
|
| 954 | 954 | |
| 955 | 955 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
| 956 | 956 | |
| 957 | - if( ! $this->is_valid ){ |
|
| 957 | + if ( ! $this->is_valid ) { |
|
| 958 | 958 | |
| 959 | 959 | // Keeping this compatible with Gravity Forms. |
| 960 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
| 961 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
| 960 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
| 961 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
| 962 | 962 | |
| 963 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
| 963 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
| 964 | 964 | |
| 965 | 965 | } else { |
| 966 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); |
|
| 966 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' ); |
|
| 967 | 967 | |
| 968 | 968 | /** |
| 969 | 969 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | * @param array $entry Gravity Forms entry array |
| 974 | 974 | * @param string $back_link URL to return to the original entry. @since 1.6 |
| 975 | 975 | */ |
| 976 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
| 976 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
| 977 | 977 | |
| 978 | 978 | echo GVCommon::generate_notice( $message ); |
| 979 | 979 | } |
@@ -997,21 +997,21 @@ discard block |
||
| 997 | 997 | */ |
| 998 | 998 | do_action( 'gravityview/edit-entry/render/before', $this ); |
| 999 | 999 | |
| 1000 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
| 1001 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
| 1000 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
| 1001 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
| 1002 | 1002 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
| 1003 | 1003 | |
| 1004 | 1004 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
| 1005 | 1005 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
| 1006 | 1006 | |
| 1007 | 1007 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
| 1008 | - unset( $_GET['page'] ); |
|
| 1008 | + unset( $_GET[ 'page' ] ); |
|
| 1009 | 1009 | |
| 1010 | 1010 | // TODO: Verify multiple-page forms |
| 1011 | 1011 | |
| 1012 | 1012 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
| 1013 | 1013 | |
| 1014 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
| 1014 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
| 1015 | 1015 | |
| 1016 | 1016 | ob_get_clean(); |
| 1017 | 1017 | |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | * @return string |
| 1038 | 1038 | */ |
| 1039 | 1039 | public function render_form_buttons() { |
| 1040 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
| 1040 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | 1043 | |
@@ -1057,10 +1057,10 @@ discard block |
||
| 1057 | 1057 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
| 1058 | 1058 | |
| 1059 | 1059 | // In case we have validated the form, use it to inject the validation results into the form render |
| 1060 | - if( isset( $this->form_after_validation ) ) { |
|
| 1060 | + if ( isset( $this->form_after_validation ) ) { |
|
| 1061 | 1061 | $form = $this->form_after_validation; |
| 1062 | 1062 | } else { |
| 1063 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1063 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | 1066 | $form = $this->filter_conditional_logic( $form ); |
@@ -1068,8 +1068,8 @@ discard block |
||
| 1068 | 1068 | $form = $this->prefill_conditional_logic( $form ); |
| 1069 | 1069 | |
| 1070 | 1070 | // for now we don't support Save and Continue feature. |
| 1071 | - if( ! self::$supports_save_and_continue ) { |
|
| 1072 | - unset( $form['save'] ); |
|
| 1071 | + if ( ! self::$supports_save_and_continue ) { |
|
| 1072 | + unset( $form[ 'save' ] ); |
|
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | 1075 | return $form; |
@@ -1090,29 +1090,29 @@ discard block |
||
| 1090 | 1090 | */ |
| 1091 | 1091 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
| 1092 | 1092 | |
| 1093 | - if( GFCommon::is_post_field( $field ) ) { |
|
| 1093 | + if ( GFCommon::is_post_field( $field ) ) { |
|
| 1094 | 1094 | |
| 1095 | 1095 | $message = null; |
| 1096 | 1096 | |
| 1097 | 1097 | // First, make sure they have the capability to edit the post. |
| 1098 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1098 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
| 1099 | 1099 | |
| 1100 | 1100 | /** |
| 1101 | 1101 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
| 1102 | 1102 | * @param string $message The existing "You don't have permission..." text |
| 1103 | 1103 | */ |
| 1104 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1104 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
| 1105 | 1105 | |
| 1106 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1106 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
| 1107 | 1107 | /** |
| 1108 | 1108 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
| 1109 | 1109 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
| 1110 | 1110 | */ |
| 1111 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1111 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | - if( $message ) { |
|
| 1115 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1114 | + if ( $message ) { |
|
| 1115 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1116 | 1116 | } |
| 1117 | 1117 | } |
| 1118 | 1118 | |
@@ -1137,8 +1137,8 @@ discard block |
||
| 1137 | 1137 | |
| 1138 | 1138 | // If the form has been submitted, then we don't need to pre-fill the values, |
| 1139 | 1139 | // Except for fileupload type and when a field input is overridden- run always!! |
| 1140 | - if( |
|
| 1141 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1140 | + if ( |
|
| 1141 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1142 | 1142 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
| 1143 | 1143 | && ! GFCommon::is_product_field( $field->type ) |
| 1144 | 1144 | || ! empty( $field_content ) |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | $return = null; |
| 1159 | 1159 | |
| 1160 | 1160 | /** @var GravityView_Field $gv_field */ |
| 1161 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1161 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1162 | 1162 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1163 | 1163 | } else { |
| 1164 | 1164 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1167,7 +1167,7 @@ discard block |
||
| 1167 | 1167 | // If there was output, it's an error |
| 1168 | 1168 | $warnings = ob_get_clean(); |
| 1169 | 1169 | |
| 1170 | - if( !empty( $warnings ) ) { |
|
| 1170 | + if ( ! empty( $warnings ) ) { |
|
| 1171 | 1171 | do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value ); |
| 1172 | 1172 | } |
| 1173 | 1173 | |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
| 1193 | 1193 | |
| 1194 | 1194 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
| 1195 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1195 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1196 | 1196 | |
| 1197 | 1197 | $field_value = array(); |
| 1198 | 1198 | |
@@ -1201,10 +1201,10 @@ discard block |
||
| 1201 | 1201 | |
| 1202 | 1202 | foreach ( (array)$field->inputs as $input ) { |
| 1203 | 1203 | |
| 1204 | - $input_id = strval( $input['id'] ); |
|
| 1204 | + $input_id = strval( $input[ 'id' ] ); |
|
| 1205 | 1205 | |
| 1206 | 1206 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1207 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1207 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1208 | 1208 | $allow_pre_populated = false; |
| 1209 | 1209 | } |
| 1210 | 1210 | |
@@ -1212,7 +1212,7 @@ discard block |
||
| 1212 | 1212 | |
| 1213 | 1213 | $pre_value = $field->get_value_submission( array(), false ); |
| 1214 | 1214 | |
| 1215 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1215 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1216 | 1216 | |
| 1217 | 1217 | } else { |
| 1218 | 1218 | |
@@ -1223,13 +1223,13 @@ discard block |
||
| 1223 | 1223 | |
| 1224 | 1224 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
| 1225 | 1225 | // or pre-populated value if not empty and set to override saved value |
| 1226 | - $field_value = !gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1226 | + $field_value = ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1227 | 1227 | |
| 1228 | 1228 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
| 1229 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
| 1229 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
| 1230 | 1230 | $categories = array(); |
| 1231 | 1231 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1232 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1232 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1233 | 1233 | } |
| 1234 | 1234 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1235 | 1235 | } |
@@ -1257,7 +1257,7 @@ discard block |
||
| 1257 | 1257 | * @param GF_Field $field Gravity Forms field object |
| 1258 | 1258 | * @param GravityView_Edit_Entry_Render $this Current object |
| 1259 | 1259 | */ |
| 1260 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1260 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
| 1261 | 1261 | |
| 1262 | 1262 | return $field_value; |
| 1263 | 1263 | } |
@@ -1274,12 +1274,12 @@ discard block |
||
| 1274 | 1274 | */ |
| 1275 | 1275 | public function gform_pre_validation( $form ) { |
| 1276 | 1276 | |
| 1277 | - if( ! $this->verify_nonce() ) { |
|
| 1277 | + if ( ! $this->verify_nonce() ) { |
|
| 1278 | 1278 | return $form; |
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | // Fix PHP warning regarding undefined index. |
| 1282 | - foreach ( $form['fields'] as &$field) { |
|
| 1282 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1283 | 1283 | |
| 1284 | 1284 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1285 | 1285 | // expects certain field array items to be set. |
@@ -1287,7 +1287,7 @@ discard block |
||
| 1287 | 1287 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
| 1288 | 1288 | } |
| 1289 | 1289 | |
| 1290 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
| 1290 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
| 1291 | 1291 | |
| 1292 | 1292 | /** |
| 1293 | 1293 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -1301,37 +1301,37 @@ discard block |
||
| 1301 | 1301 | // Set the previous value |
| 1302 | 1302 | $entry = $this->get_entry(); |
| 1303 | 1303 | |
| 1304 | - $input_name = 'input_'.$field->id; |
|
| 1305 | - $form_id = $form['id']; |
|
| 1304 | + $input_name = 'input_' . $field->id; |
|
| 1305 | + $form_id = $form[ 'id' ]; |
|
| 1306 | 1306 | |
| 1307 | 1307 | $value = NULL; |
| 1308 | 1308 | |
| 1309 | 1309 | // Use the previous entry value as the default. |
| 1310 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1310 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1311 | 1311 | $value = $entry[ $field->id ]; |
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | 1314 | // If this is a single upload file |
| 1315 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1316 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1317 | - $value = $file_path['url']; |
|
| 1315 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 1316 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
| 1317 | + $value = $file_path[ 'url' ]; |
|
| 1318 | 1318 | |
| 1319 | 1319 | } else { |
| 1320 | 1320 | |
| 1321 | 1321 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
| 1322 | 1322 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
| 1323 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1323 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
| 1324 | 1324 | |
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | - if( rgar($field, "multipleFiles") ) { |
|
| 1327 | + if ( rgar( $field, "multipleFiles" ) ) { |
|
| 1328 | 1328 | |
| 1329 | 1329 | // If there are fresh uploads, process and merge them. |
| 1330 | 1330 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
| 1331 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1331 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
| 1332 | 1332 | $value = empty( $value ) ? '[]' : $value; |
| 1333 | 1333 | $value = stripslashes_deep( $value ); |
| 1334 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1334 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
| 1335 | 1335 | } |
| 1336 | 1336 | |
| 1337 | 1337 | } else { |
@@ -1349,8 +1349,8 @@ discard block |
||
| 1349 | 1349 | |
| 1350 | 1350 | case 'number': |
| 1351 | 1351 | // Fix "undefined index" issue at line 1286 in form_display.php |
| 1352 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1353 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1352 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
| 1353 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
| 1354 | 1354 | } |
| 1355 | 1355 | break; |
| 1356 | 1356 | } |
@@ -1392,7 +1392,7 @@ discard block |
||
| 1392 | 1392 | * You can enter whatever you want! |
| 1393 | 1393 | * We try validating, and customize the results using `self::custom_validation()` |
| 1394 | 1394 | */ |
| 1395 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
| 1395 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
| 1396 | 1396 | |
| 1397 | 1397 | // Needed by the validate funtion |
| 1398 | 1398 | $failed_validation_page = NULL; |
@@ -1400,14 +1400,14 @@ discard block |
||
| 1400 | 1400 | |
| 1401 | 1401 | // Prevent entry limit from running when editing an entry, also |
| 1402 | 1402 | // prevent form scheduling from preventing editing |
| 1403 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
| 1403 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
| 1404 | 1404 | |
| 1405 | 1405 | // Hide fields depending on Edit Entry settings |
| 1406 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1406 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1407 | 1407 | |
| 1408 | 1408 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
| 1409 | 1409 | |
| 1410 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1410 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1411 | 1411 | remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'user_registration_validation' ), 10 ); |
| 1412 | 1412 | } |
| 1413 | 1413 | |
@@ -1424,7 +1424,7 @@ discard block |
||
| 1424 | 1424 | $user_registration = GF_User_Registration::get_instance(); |
| 1425 | 1425 | |
| 1426 | 1426 | $entry = $this->get_entry(); |
| 1427 | - $form = $validation_results['form']; |
|
| 1427 | + $form = $validation_results[ 'form' ]; |
|
| 1428 | 1428 | |
| 1429 | 1429 | if ( ! $feed = $user_registration->get_single_submission_feed( $entry, $form ) ) { |
| 1430 | 1430 | return $validation_results; |
@@ -1440,18 +1440,18 @@ discard block |
||
| 1440 | 1440 | if ( $user_email != $value && email_exists( $value ) ) { |
| 1441 | 1441 | $email_field->failed_validation = 1; |
| 1442 | 1442 | $email_field->validation_message = __( 'This email is already in use', 'gravityview' ); |
| 1443 | - $validation_results['is_valid'] = false; |
|
| 1443 | + $validation_results[ 'is_valid' ] = false; |
|
| 1444 | 1444 | } |
| 1445 | 1445 | |
| 1446 | 1446 | $value = RGFormsModel::get_field_value( $username_field ); |
| 1447 | 1447 | if ( $username != $value ) { |
| 1448 | 1448 | $username_field->failed_validation = 1; |
| 1449 | 1449 | $username_field->validation_message = __( 'Usernames cannot be changed', 'gravityview' ); |
| 1450 | - $validation_results['is_valid'] = false; |
|
| 1450 | + $validation_results[ 'is_valid' ] = false; |
|
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | 1453 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1454 | - $this->form_after_validation = $validation_results['form']; |
|
| 1454 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1455 | 1455 | |
| 1456 | 1456 | return $validation_results; |
| 1457 | 1457 | } |
@@ -1469,13 +1469,13 @@ discard block |
||
| 1469 | 1469 | */ |
| 1470 | 1470 | public function custom_validation( $validation_results ) { |
| 1471 | 1471 | |
| 1472 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); |
|
| 1472 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); |
|
| 1473 | 1473 | |
| 1474 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
| 1474 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
| 1475 | 1475 | |
| 1476 | 1476 | $gv_valid = true; |
| 1477 | 1477 | |
| 1478 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
| 1478 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
| 1479 | 1479 | |
| 1480 | 1480 | $value = RGFormsModel::get_field_value( $field ); |
| 1481 | 1481 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1488,35 +1488,35 @@ discard block |
||
| 1488 | 1488 | case 'post_image': |
| 1489 | 1489 | |
| 1490 | 1490 | // in case nothing is uploaded but there are already files saved |
| 1491 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1491 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
| 1492 | 1492 | $field->failed_validation = false; |
| 1493 | 1493 | unset( $field->validation_message ); |
| 1494 | 1494 | } |
| 1495 | 1495 | |
| 1496 | 1496 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
| 1497 | - if( rgobj( $field, 'maxFiles') && rgobj( $field, 'multipleFiles') ) { |
|
| 1497 | + if ( rgobj( $field, 'maxFiles' ) && rgobj( $field, 'multipleFiles' ) ) { |
|
| 1498 | 1498 | |
| 1499 | 1499 | $input_name = 'input_' . $field->id; |
| 1500 | 1500 | //uploaded |
| 1501 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1501 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
| 1502 | 1502 | |
| 1503 | 1503 | //existent |
| 1504 | 1504 | $entry = $this->get_entry(); |
| 1505 | 1505 | $value = NULL; |
| 1506 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1506 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1507 | 1507 | $value = json_decode( $entry[ $field->id ], true ); |
| 1508 | 1508 | } |
| 1509 | 1509 | |
| 1510 | 1510 | // count uploaded files and existent entry files |
| 1511 | 1511 | $count_files = count( $file_names ) + count( $value ); |
| 1512 | 1512 | |
| 1513 | - if( $count_files > $field->maxFiles ) { |
|
| 1513 | + if ( $count_files > $field->maxFiles ) { |
|
| 1514 | 1514 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
| 1515 | 1515 | $field->failed_validation = 1; |
| 1516 | 1516 | $gv_valid = false; |
| 1517 | 1517 | |
| 1518 | 1518 | // in case of error make sure the newest upload files are removed from the upload input |
| 1519 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1519 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
| 1520 | 1520 | } |
| 1521 | 1521 | |
| 1522 | 1522 | } |
@@ -1527,7 +1527,7 @@ discard block |
||
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | 1529 | // This field has failed validation. |
| 1530 | - if( !empty( $field->failed_validation ) ) { |
|
| 1530 | + if ( ! empty( $field->failed_validation ) ) { |
|
| 1531 | 1531 | |
| 1532 | 1532 | do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) ); |
| 1533 | 1533 | |
@@ -1545,32 +1545,32 @@ discard block |
||
| 1545 | 1545 | } |
| 1546 | 1546 | |
| 1547 | 1547 | // You can't continue inside a switch, so we do it after. |
| 1548 | - if( empty( $field->failed_validation ) ) { |
|
| 1548 | + if ( empty( $field->failed_validation ) ) { |
|
| 1549 | 1549 | continue; |
| 1550 | 1550 | } |
| 1551 | 1551 | |
| 1552 | 1552 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1553 | 1553 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1554 | - if( !empty( $field->noDuplicates ) ) { |
|
| 1554 | + if ( ! empty( $field->noDuplicates ) ) { |
|
| 1555 | 1555 | |
| 1556 | 1556 | $entry = $this->get_entry(); |
| 1557 | 1557 | |
| 1558 | 1558 | // If the value of the entry is the same as the stored value |
| 1559 | 1559 | // Then we can assume it's not a duplicate, it's the same. |
| 1560 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1560 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1561 | 1561 | //if value submitted was not changed, then don't validate |
| 1562 | 1562 | $field->failed_validation = false; |
| 1563 | 1563 | |
| 1564 | 1564 | unset( $field->validation_message ); |
| 1565 | 1565 | |
| 1566 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); |
|
| 1566 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); |
|
| 1567 | 1567 | |
| 1568 | 1568 | continue; |
| 1569 | 1569 | } |
| 1570 | 1570 | } |
| 1571 | 1571 | |
| 1572 | 1572 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1573 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1573 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1574 | 1574 | unset( $field->validation_message ); |
| 1575 | 1575 | $field->validation_message = false; |
| 1576 | 1576 | continue; |
@@ -1582,12 +1582,12 @@ discard block |
||
| 1582 | 1582 | |
| 1583 | 1583 | } |
| 1584 | 1584 | |
| 1585 | - $validation_results['is_valid'] = $gv_valid; |
|
| 1585 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
| 1586 | 1586 | |
| 1587 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); |
|
| 1587 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); |
|
| 1588 | 1588 | |
| 1589 | 1589 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1590 | - $this->form_after_validation = $validation_results['form']; |
|
| 1590 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1591 | 1591 | |
| 1592 | 1592 | return $validation_results; |
| 1593 | 1593 | } |
@@ -1600,7 +1600,7 @@ discard block |
||
| 1600 | 1600 | */ |
| 1601 | 1601 | public function get_entry() { |
| 1602 | 1602 | |
| 1603 | - if( empty( $this->entry ) ) { |
|
| 1603 | + if ( empty( $this->entry ) ) { |
|
| 1604 | 1604 | // Get the database value of the entry that's being edited |
| 1605 | 1605 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
| 1606 | 1606 | } |
@@ -1635,10 +1635,10 @@ discard block |
||
| 1635 | 1635 | } |
| 1636 | 1636 | |
| 1637 | 1637 | // If edit tab not yet configured, show all fields |
| 1638 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
| 1638 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
| 1639 | 1639 | |
| 1640 | 1640 | // Hide fields depending on admin settings |
| 1641 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
| 1641 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
| 1642 | 1642 | |
| 1643 | 1643 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
| 1644 | 1644 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1670,7 +1670,7 @@ discard block |
||
| 1670 | 1670 | */ |
| 1671 | 1671 | private function filter_fields( $fields, $configured_fields ) { |
| 1672 | 1672 | |
| 1673 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
| 1673 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
| 1674 | 1674 | return $fields; |
| 1675 | 1675 | } |
| 1676 | 1676 | |
@@ -1683,18 +1683,18 @@ discard block |
||
| 1683 | 1683 | |
| 1684 | 1684 | // Remove the fields that have calculation properties and keep them to be used later |
| 1685 | 1685 | // @since 1.16.2 |
| 1686 | - if( $field->has_calculation() ) { |
|
| 1687 | - $this->fields_with_calculation[] = $field; |
|
| 1686 | + if ( $field->has_calculation() ) { |
|
| 1687 | + $this->fields_with_calculation[ ] = $field; |
|
| 1688 | 1688 | // don't remove the calculation fields on form render. |
| 1689 | 1689 | } |
| 1690 | 1690 | |
| 1691 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1691 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1692 | 1692 | unset( $fields[ $key ] ); |
| 1693 | 1693 | } |
| 1694 | 1694 | } |
| 1695 | 1695 | |
| 1696 | 1696 | // The Edit tab has not been configured, so we return all fields by default. |
| 1697 | - if( empty( $configured_fields ) ) { |
|
| 1697 | + if ( empty( $configured_fields ) ) { |
|
| 1698 | 1698 | return $fields; |
| 1699 | 1699 | } |
| 1700 | 1700 | |
@@ -1704,8 +1704,8 @@ discard block |
||
| 1704 | 1704 | /** @var GF_Field $field */ |
| 1705 | 1705 | foreach ( $fields as $field ) { |
| 1706 | 1706 | |
| 1707 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1708 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1707 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1708 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1709 | 1709 | break; |
| 1710 | 1710 | } |
| 1711 | 1711 | |
@@ -1728,14 +1728,14 @@ discard block |
||
| 1728 | 1728 | |
| 1729 | 1729 | $return_field = $field; |
| 1730 | 1730 | |
| 1731 | - if( empty( $field_setting['show_label'] ) ) { |
|
| 1731 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
| 1732 | 1732 | $return_field->label = ''; |
| 1733 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
| 1734 | - $return_field->label = $field_setting['custom_label']; |
|
| 1733 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
| 1734 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
| 1735 | 1735 | } |
| 1736 | 1736 | |
| 1737 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
| 1738 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
| 1737 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
| 1738 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
| 1739 | 1739 | } |
| 1740 | 1740 | |
| 1741 | 1741 | /** |
@@ -1773,16 +1773,16 @@ discard block |
||
| 1773 | 1773 | */ |
| 1774 | 1774 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
| 1775 | 1775 | |
| 1776 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1777 | - foreach( $fields as $k => $field ) { |
|
| 1778 | - if( $field->adminOnly ) { |
|
| 1776 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
| 1777 | + foreach ( $fields as $k => $field ) { |
|
| 1778 | + if ( $field->adminOnly ) { |
|
| 1779 | 1779 | unset( $fields[ $k ] ); |
| 1780 | 1780 | } |
| 1781 | 1781 | } |
| 1782 | 1782 | return $fields; |
| 1783 | 1783 | } |
| 1784 | 1784 | |
| 1785 | - foreach( $fields as &$field ) { |
|
| 1785 | + foreach ( $fields as &$field ) { |
|
| 1786 | 1786 | $field->adminOnly = false; |
| 1787 | 1787 | } |
| 1788 | 1788 | |
@@ -1806,22 +1806,22 @@ discard block |
||
| 1806 | 1806 | */ |
| 1807 | 1807 | function prefill_conditional_logic( $form ) { |
| 1808 | 1808 | |
| 1809 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1809 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1810 | 1810 | return $form; |
| 1811 | 1811 | } |
| 1812 | 1812 | |
| 1813 | 1813 | // Have Conditional Logic pre-fill fields as if the data were default values |
| 1814 | 1814 | /** @var GF_Field $field */ |
| 1815 | - foreach ( $form['fields'] as &$field ) { |
|
| 1815 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1816 | 1816 | |
| 1817 | - if( 'checkbox' === $field->type ) { |
|
| 1817 | + if ( 'checkbox' === $field->type ) { |
|
| 1818 | 1818 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1819 | - $input_id = $input['id']; |
|
| 1819 | + $input_id = $input[ 'id' ]; |
|
| 1820 | 1820 | $choice = $field->choices[ $key ]; |
| 1821 | 1821 | $value = rgar( $this->entry, $input_id ); |
| 1822 | 1822 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
| 1823 | - if( $match ) { |
|
| 1824 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1823 | + if ( $match ) { |
|
| 1824 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
| 1825 | 1825 | } |
| 1826 | 1826 | } |
| 1827 | 1827 | } else { |
@@ -1829,15 +1829,15 @@ discard block |
||
| 1829 | 1829 | // We need to run through each field to set the default values |
| 1830 | 1830 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1831 | 1831 | |
| 1832 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1832 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1833 | 1833 | |
| 1834 | - if( 'list' === $field->type ) { |
|
| 1834 | + if ( 'list' === $field->type ) { |
|
| 1835 | 1835 | $list_rows = maybe_unserialize( $field_value ); |
| 1836 | 1836 | |
| 1837 | 1837 | $list_field_value = array(); |
| 1838 | - foreach ( (array) $list_rows as $row ) { |
|
| 1839 | - foreach ( (array) $row as $column ) { |
|
| 1840 | - $list_field_value[] = $column; |
|
| 1838 | + foreach ( (array)$list_rows as $row ) { |
|
| 1839 | + foreach ( (array)$row as $column ) { |
|
| 1840 | + $list_field_value[ ] = $column; |
|
| 1841 | 1841 | } |
| 1842 | 1842 | } |
| 1843 | 1843 | |
@@ -1872,16 +1872,16 @@ discard block |
||
| 1872 | 1872 | */ |
| 1873 | 1873 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
| 1874 | 1874 | |
| 1875 | - if( $use_conditional_logic ) { |
|
| 1875 | + if ( $use_conditional_logic ) { |
|
| 1876 | 1876 | return $form; |
| 1877 | 1877 | } |
| 1878 | 1878 | |
| 1879 | - foreach( $form['fields'] as &$field ) { |
|
| 1879 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1880 | 1880 | /* @var GF_Field $field */ |
| 1881 | 1881 | $field->conditionalLogic = null; |
| 1882 | 1882 | } |
| 1883 | 1883 | |
| 1884 | - unset( $form['button']['conditionalLogic'] ); |
|
| 1884 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
| 1885 | 1885 | |
| 1886 | 1886 | return $form; |
| 1887 | 1887 | |
@@ -1898,7 +1898,7 @@ discard block |
||
| 1898 | 1898 | */ |
| 1899 | 1899 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
| 1900 | 1900 | |
| 1901 | - if( ! $this->is_edit_entry() ) { |
|
| 1901 | + if ( ! $this->is_edit_entry() ) { |
|
| 1902 | 1902 | return $has_conditional_logic; |
| 1903 | 1903 | } |
| 1904 | 1904 | |
@@ -1930,44 +1930,44 @@ discard block |
||
| 1930 | 1930 | * 2. There are two entries embedded using oEmbed |
| 1931 | 1931 | * 3. One of the entries has just been saved |
| 1932 | 1932 | */ |
| 1933 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
| 1933 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
| 1934 | 1934 | |
| 1935 | 1935 | $error = true; |
| 1936 | 1936 | |
| 1937 | 1937 | } |
| 1938 | 1938 | |
| 1939 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
| 1939 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
| 1940 | 1940 | |
| 1941 | 1941 | $error = true; |
| 1942 | 1942 | |
| 1943 | - } elseif( ! $this->verify_nonce() ) { |
|
| 1943 | + } elseif ( ! $this->verify_nonce() ) { |
|
| 1944 | 1944 | |
| 1945 | 1945 | /** |
| 1946 | 1946 | * If the Entry is embedded, there may be two entries on the same page. |
| 1947 | 1947 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
| 1948 | 1948 | */ |
| 1949 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1949 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1950 | 1950 | $error = true; |
| 1951 | 1951 | } else { |
| 1952 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
| 1952 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 1953 | 1953 | } |
| 1954 | 1954 | |
| 1955 | 1955 | } |
| 1956 | 1956 | |
| 1957 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1958 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
| 1957 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1958 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
| 1959 | 1959 | } |
| 1960 | 1960 | |
| 1961 | - if( $this->entry['status'] === 'trash' ) { |
|
| 1962 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1961 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
| 1962 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1963 | 1963 | } |
| 1964 | 1964 | |
| 1965 | 1965 | // No errors; everything's fine here! |
| 1966 | - if( empty( $error ) ) { |
|
| 1966 | + if ( empty( $error ) ) { |
|
| 1967 | 1967 | return true; |
| 1968 | 1968 | } |
| 1969 | 1969 | |
| 1970 | - if( $echo && $error !== true ) { |
|
| 1970 | + if ( $echo && $error !== true ) { |
|
| 1971 | 1971 | |
| 1972 | 1972 | $error = esc_html( $error ); |
| 1973 | 1973 | |
@@ -1975,13 +1975,13 @@ discard block |
||
| 1975 | 1975 | * @since 1.9 |
| 1976 | 1976 | */ |
| 1977 | 1977 | if ( ! empty( $this->entry ) ) { |
| 1978 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
| 1978 | + $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
| 1979 | 1979 | } |
| 1980 | 1980 | |
| 1981 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
| 1981 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
| 1982 | 1982 | } |
| 1983 | 1983 | |
| 1984 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); |
|
| 1984 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); |
|
| 1985 | 1985 | |
| 1986 | 1986 | return false; |
| 1987 | 1987 | } |
@@ -1998,20 +1998,20 @@ discard block |
||
| 1998 | 1998 | |
| 1999 | 1999 | $error = NULL; |
| 2000 | 2000 | |
| 2001 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2002 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
| 2001 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2002 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
| 2003 | 2003 | } |
| 2004 | 2004 | |
| 2005 | 2005 | // No errors; everything's fine here! |
| 2006 | - if( empty( $error ) ) { |
|
| 2006 | + if ( empty( $error ) ) { |
|
| 2007 | 2007 | return true; |
| 2008 | 2008 | } |
| 2009 | 2009 | |
| 2010 | - if( $echo ) { |
|
| 2011 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
| 2010 | + if ( $echo ) { |
|
| 2011 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
| 2012 | 2012 | } |
| 2013 | 2013 | |
| 2014 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); |
|
| 2014 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); |
|
| 2015 | 2015 | |
| 2016 | 2016 | return false; |
| 2017 | 2017 | |
@@ -2029,15 +2029,15 @@ discard block |
||
| 2029 | 2029 | private function check_user_cap_edit_field( $field ) { |
| 2030 | 2030 | |
| 2031 | 2031 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
| 2032 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2032 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2033 | 2033 | return true; |
| 2034 | 2034 | } |
| 2035 | 2035 | |
| 2036 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
| 2036 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
| 2037 | 2037 | |
| 2038 | 2038 | // If the field has custom editing capaibilities set, check those |
| 2039 | - if( $field_cap ) { |
|
| 2040 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
| 2039 | + if ( $field_cap ) { |
|
| 2040 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
| 2041 | 2041 | } |
| 2042 | 2042 | |
| 2043 | 2043 | return false; |
@@ -2051,17 +2051,17 @@ discard block |
||
| 2051 | 2051 | public function verify_nonce() { |
| 2052 | 2052 | |
| 2053 | 2053 | // Verify form submitted for editing single |
| 2054 | - if( $this->is_edit_entry_submission() ) { |
|
| 2054 | + if ( $this->is_edit_entry_submission() ) { |
|
| 2055 | 2055 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
| 2056 | 2056 | } |
| 2057 | 2057 | |
| 2058 | 2058 | // Verify |
| 2059 | - else if( ! $this->is_edit_entry() ) { |
|
| 2059 | + else if ( ! $this->is_edit_entry() ) { |
|
| 2060 | 2060 | $valid = false; |
| 2061 | 2061 | } |
| 2062 | 2062 | |
| 2063 | 2063 | else { |
| 2064 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
| 2064 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
| 2065 | 2065 | } |
| 2066 | 2066 | |
| 2067 | 2067 | /** |
@@ -42,9 +42,9 @@ discard block |
||
| 42 | 42 | $tables = array(); |
| 43 | 43 | |
| 44 | 44 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) ) { |
| 45 | - $tables []= GFFormsModel::get_entry_meta_table_name(); |
|
| 45 | + $tables [ ] = GFFormsModel::get_entry_meta_table_name(); |
|
| 46 | 46 | } |
| 47 | - $tables []= GFFormsModel::get_lead_meta_table_name(); |
|
| 47 | + $tables [ ] = GFFormsModel::get_lead_meta_table_name(); |
|
| 48 | 48 | |
| 49 | 49 | $suppress = $wpdb->suppress_errors(); |
| 50 | 50 | foreach ( $tables as $meta_table ) { |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | $tables = array(); |
| 71 | 71 | |
| 72 | 72 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) ) { |
| 73 | - $tables []= GFFormsModel::get_entry_notes_table_name(); |
|
| 73 | + $tables [ ] = GFFormsModel::get_entry_notes_table_name(); |
|
| 74 | 74 | } |
| 75 | - $tables []= GFFormsModel::get_lead_notes_table_name(); |
|
| 75 | + $tables [ ] = GFFormsModel::get_lead_notes_table_name(); |
|
| 76 | 76 | |
| 77 | - $disapproved = __('Disapproved the Entry for GravityView', 'gravityview'); |
|
| 78 | - $approved = __('Approved the Entry for GravityView', 'gravityview'); |
|
| 77 | + $disapproved = __( 'Disapproved the Entry for GravityView', 'gravityview' ); |
|
| 78 | + $approved = __( 'Approved the Entry for GravityView', 'gravityview' ); |
|
| 79 | 79 | |
| 80 | 80 | $suppress = $wpdb->suppress_errors(); |
| 81 | 81 | foreach ( $tables as $notes_table ) { |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $self = new self(); |
| 56 | 56 | $self->form = $form; |
| 57 | 57 | |
| 58 | - $self->ID = $self->form['id']; |
|
| 58 | + $self->ID = $self->form[ 'id' ]; |
|
| 59 | 59 | |
| 60 | 60 | return $self; |
| 61 | 61 | } |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | /** The offset and limit */ |
| 100 | 100 | if ( ! empty( $offset->limit ) ) { |
| 101 | - $paging['page_size'] = $offset->limit; |
|
| 101 | + $paging[ 'page_size' ] = $offset->limit; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | if ( ! empty( $offset->offset ) ) { |
| 105 | - $paging['offset'] = $offset->offset; |
|
| 105 | + $paging[ 'offset' ] = $offset->offset; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | foreach ( \GFAPI::get_entries( $form->ID, $search_criteria, $sorting, $paging ) as $entry ) { |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * @return bool Whether the offset exists or not. |
| 139 | 139 | */ |
| 140 | 140 | public function offsetExists( $offset ) { |
| 141 | - return isset( $this->form[$offset] ); |
|
| 141 | + return isset( $this->form[ $offset ] ); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @return mixed The value of the requested form data. |
| 154 | 154 | */ |
| 155 | 155 | public function offsetGet( $offset ) { |
| 156 | - return $this->form[$offset]; |
|
| 156 | + return $this->form[ $offset ]; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |