Completed
Push — master ( 5ea1a0...83f121 )
by Stephanie
08:40
created
classes/models/fields/FrmFieldType.php 2 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -270,6 +270,9 @@  discard block
 block discarded – undo
270 270
 		return $this->alter_builder_classes( $classes );
271 271
 	}
272 272
 
273
+	/**
274
+	 * @param string $classes
275
+	 */
273 276
 	protected function alter_builder_classes( $classes ) {
274 277
 		return $classes;
275 278
 	}
@@ -443,6 +446,11 @@  discard block
 block discarded – undo
443 446
 		return $html;
444 447
 	}
445 448
 
449
+	/**
450
+	 * @param string $html
451
+	 *
452
+	 * @return string
453
+	 */
446 454
 	protected function after_replace_html_shortcodes( $args, $html ) {
447 455
 		return $html;
448 456
 	}
@@ -667,6 +675,7 @@  discard block
 block discarded – undo
667 675
 	/**
668 676
 	 * Link input to field description for screen readers
669 677
 	 * @since 3.0
678
+	 * @param string $input_html
670 679
 	 */
671 680
 	protected function add_aria_description( $args, &$input_html ) {
672 681
 		if ( $this->get_field_column( 'description' ) != '' ) {
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 		$field_val = '';
99 99
 		if ( is_object( $this->field ) ) {
100 100
 			$field_val = $this->field->{$column};
101
-		} elseif ( is_array( $this->field ) && isset( $this->field[ $column ] ) ) {
102
-			$field_val = $this->field[ $column ];
101
+		} elseif ( is_array( $this->field ) && isset( $this->field[$column] ) ) {
102
+			$field_val = $this->field[$column];
103 103
 		}
104 104
 		return $field_val;
105 105
 	}
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		if ( is_object( $this->field ) ) {
113 113
 			$this->field->{$column} = $value;
114 114
 		} elseif ( is_array( $this->field ) ) {
115
-			$this->field[ $column ] = $value;
115
+			$this->field[$column] = $value;
116 116
 		}
117 117
 	}
118 118
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	}
217 217
 
218 218
 	protected function html_id( $plus = '' ) {
219
-		return apply_filters( 'frm_field_get_html_id', 'field_' . $this->get_field_column('field_key') . $plus, $this->field );
219
+		return apply_filters( 'frm_field_get_html_id', 'field_' . $this->get_field_column( 'field_key' ) . $plus, $this->field );
220 220
     }
221 221
 
222 222
 	public function display_field_settings() {
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	}
308 308
 
309 309
 	protected function default_invalid_msg() {
310
-		$field_name = $this->get_field_column('name');
310
+		$field_name = $this->get_field_column( 'name' );
311 311
 		if ( $field_name == '' ) {
312 312
 			$invalid = __( 'This field is invalid', 'formidable' );
313 313
 		} else {
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
 		$fields = FrmField::field_selection();
324 324
 		$fields = array_merge( $fields, FrmField::pro_field_selection() );
325 325
 
326
-		if ( isset( $fields[ $this->type ] ) ) {
327
-			$name = is_array( $fields[ $this->type ] ) ? $fields[ $this->type ]['name'] : $fields[ $this->type ];
326
+		if ( isset( $fields[$this->type] ) ) {
327
+			$name = is_array( $fields[$this->type] ) ? $fields[$this->type]['name'] : $fields[$this->type];
328 328
 		}
329 329
 
330 330
 		return $name;
@@ -581,12 +581,12 @@  discard block
 block discarded – undo
581 581
 	 * @since 3.0
582 582
 	 */
583 583
 	protected function get_select_box( $values ) {
584
-		$options = $this->get_field_column('options');
584
+		$options = $this->get_field_column( 'options' );
585 585
 		$selected = $values['field_value'];
586 586
 
587 587
 		if ( isset( $values['combo_name'] ) ) {
588
-			$options = $options[ $values['combo_name'] ];
589
-			$selected = ( is_array( $selected ) && isset( $selected[ $values['combo_name'] ] ) ) ? $selected[ $values['combo_name'] ] : '';
588
+			$options = $options[$values['combo_name']];
589
+			$selected = ( is_array( $selected ) && isset( $selected[$values['combo_name']] ) ) ? $selected[$values['combo_name']] : '';
590 590
 		}
591 591
 
592 592
 		$input = $this->select_tag( $values );
@@ -640,8 +640,8 @@  discard block
 block discarded – undo
640 640
 
641 641
 	protected function fill_display_field_values( $args = array() ) {
642 642
 		$defaults = array(
643
-			'field_name'    => 'item_meta[' . $this->get_field_column('id') . ']',
644
-			'field_id'      => $this->get_field_column('id'),
643
+			'field_name'    => 'item_meta[' . $this->get_field_column( 'id' ) . ']',
644
+			'field_id'      => $this->get_field_column( 'id' ),
645 645
 			'field_plus_id' => '',
646 646
 			'section_id'    => '',
647 647
 		);
@@ -720,8 +720,8 @@  discard block
 block discarded – undo
720 720
 		$value = $this->prepare_display_value( $value, $atts );
721 721
 
722 722
 		if ( is_array( $value ) ) {
723
-			if ( isset( $atts['show'] ) && $atts['show'] && isset( $value[ $atts['show'] ] ) ) {
724
-				$value = $value[ $atts['show'] ];
723
+			if ( isset( $atts['show'] ) && $atts['show'] && isset( $value[$atts['show']] ) ) {
724
+				$value = $value[$atts['show']];
725 725
 			} elseif ( ! isset( $atts['return_array'] ) || ! $atts['return_array'] ) {
726 726
 				$sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
727 727
 				$value = implode( $sep, $value );
@@ -788,8 +788,8 @@  discard block
 block discarded – undo
788 788
 		$saved_entries = $atts['ids'];
789 789
 		$new_value = array();
790 790
 		foreach ( (array) $value as $old_child_id ) {
791
-			if ( isset( $saved_entries[ $old_child_id ] ) ) {
792
-				$new_value[] = $saved_entries[ $old_child_id ];
791
+			if ( isset( $saved_entries[$old_child_id] ) ) {
792
+				$new_value[] = $saved_entries[$old_child_id];
793 793
 			}
794 794
 		}
795 795
 
Please login to merge, or discard this patch.
classes/helpers/FrmFormsListHelper.php 2 patches
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -43,28 +43,28 @@  discard block
 block discarded – undo
43 43
 			),
44 44
 		);
45 45
 		switch ( $this->status ) {
46
-		    case 'template':
47
-                $s_query['is_template'] = 1;
48
-                $s_query['status !'] = 'trash';
49
-		        break;
50
-		    case 'draft':
51
-                $s_query['is_template'] = 0;
52
-                $s_query['status'] = 'draft';
53
-		        break;
54
-		    case 'trash':
55
-                $s_query['status'] = 'trash';
56
-		        break;
57
-		    default:
58
-                $s_query['is_template'] = 0;
59
-                $s_query['status !'] = 'trash';
60
-		        break;
46
+			case 'template':
47
+				$s_query['is_template'] = 1;
48
+				$s_query['status !'] = 'trash';
49
+				break;
50
+			case 'draft':
51
+				$s_query['is_template'] = 0;
52
+				$s_query['status'] = 'draft';
53
+				break;
54
+			case 'trash':
55
+				$s_query['status'] = 'trash';
56
+				break;
57
+			default:
58
+				$s_query['is_template'] = 0;
59
+				$s_query['status !'] = 'trash';
60
+				break;
61 61
 		}
62 62
 
63 63
 		$s = self::get_param( array(
64 64
 			'param' => 's',
65 65
 			'sanitize' => 'sanitize_text_field',
66 66
 		) );
67
-	    if ( $s != '' ) {
67
+		if ( $s != '' ) {
68 68
 			preg_match_all( '/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches );
69 69
 			$search_terms = array_map( 'trim', $matches[0] );
70 70
 			foreach ( (array) $search_terms as $term ) {
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 				);
77 77
 				unset( $term );
78 78
 			}
79
-	    }
79
+		}
80 80
 
81 81
 		$this->items = FrmForm::getAll( $s_query, $orderby . ' ' . $order, $start . ',' . $per_page );
82
-        $total_items = FrmDb::get_count( 'frm_forms', $s_query );
82
+		$total_items = FrmDb::get_count( 'frm_forms', $s_query );
83 83
 
84 84
 		$this->set_pagination_args( array(
85 85
 			'total_items' => $total_items,
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	}
89 89
 
90 90
 	public function no_items() {
91
-	    if ( 'template' == $this->status ) {
91
+		if ( 'template' == $this->status ) {
92 92
 			esc_html_e( 'No Templates Found.', 'formidable' );
93 93
 		} else {
94 94
 			esc_html_e( 'No Forms Found.', 'formidable' );
@@ -99,51 +99,51 @@  discard block
 block discarded – undo
99 99
 	}
100 100
 
101 101
 	public function get_bulk_actions() {
102
-	    $actions = array();
102
+		$actions = array();
103 103
 
104
-	    if ( 'trash' == $this->status ) {
105
-	        if ( current_user_can('frm_edit_forms') ) {
106
-	            $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
107
-	        }
104
+		if ( 'trash' == $this->status ) {
105
+			if ( current_user_can('frm_edit_forms') ) {
106
+				$actions['bulk_untrash'] = __( 'Restore', 'formidable' );
107
+			}
108 108
 
109
-	        if ( current_user_can('frm_delete_forms') ) {
110
-	            $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
111
-	        }
112
-	    } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
113
-	        $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
114
-	    } else if ( current_user_can('frm_delete_forms') ) {
115
-	        $actions['bulk_delete'] = __( 'Delete');
116
-	    }
109
+			if ( current_user_can('frm_delete_forms') ) {
110
+				$actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
111
+			}
112
+		} else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
113
+			$actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
114
+		} else if ( current_user_can('frm_delete_forms') ) {
115
+			$actions['bulk_delete'] = __( 'Delete');
116
+		}
117 117
 
118
-        return $actions;
119
-    }
118
+		return $actions;
119
+	}
120 120
 
121 121
 	public function extra_tablenav( $which ) {
122
-        if ( 'top' != $which ) {
123
-            return;
124
-        }
122
+		if ( 'top' != $which ) {
123
+			return;
124
+		}
125 125
 
126
-        if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
126
+		if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
127 127
 ?>
128 128
             <div class="alignleft actions frm_visible_overflow">
129 129
 			<?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
130 130
             </div>
131 131
 <?php
132
-            return;
133
-        }
132
+			return;
133
+		}
134 134
 
135
-        if ( 'template' != $this->status ) {
136
-            return;
137
-        }
135
+		if ( 'template' != $this->status ) {
136
+			return;
137
+		}
138 138
 
139 139
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
140 140
 		$forms = FrmForm::get_published_forms( $where );
141 141
 
142
-        $base = admin_url('admin.php?page=formidable&form_type=template');
143
-        $args = array(
144
-            'frm_action'    => 'duplicate',
145
-            'template'      => true,
146
-        );
142
+		$base = admin_url('admin.php?page=formidable&form_type=template');
143
+		$args = array(
144
+			'frm_action'    => 'duplicate',
145
+			'template'      => true,
146
+		);
147 147
 
148 148
 ?>
149 149
     <div class="alignleft actions frm_visible_overflow">
@@ -155,16 +155,16 @@  discard block
 block discarded – undo
155 155
 		?>
156 156
 			<li class="frm_dropdown_li"><?php esc_html_e( 'You have not created any forms yet. You must create a form before you can make a template.', 'formidable' ) ?></li>
157 157
         <?php
158
-        } else {
159
-            foreach ( $forms as $form ) {
158
+		} else {
159
+			foreach ( $forms as $form ) {
160 160
 				$args['id'] = $form->id;
161 161
 				?>
162 162
 			<li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
163 163
 			<?php
164
-			    unset($form);
164
+				unset($form);
165 165
 			}
166
-        }
167
-        ?>
166
+		}
167
+		?>
168 168
 		</ul>
169 169
 	</div>
170 170
 	</div>
@@ -174,33 +174,33 @@  discard block
 block discarded – undo
174 174
 	public function get_views() {
175 175
 
176 176
 		$statuses = array(
177
-		    'published' => __( 'My Forms', 'formidable' ),
178
-		    'template'  => __( 'Templates', 'formidable' ),
179
-		    'draft'     => __( 'Drafts', 'formidable' ),
180
-		    'trash'     => __( 'Trash', 'formidable' ),
177
+			'published' => __( 'My Forms', 'formidable' ),
178
+			'template'  => __( 'Templates', 'formidable' ),
179
+			'draft'     => __( 'Drafts', 'formidable' ),
180
+			'trash'     => __( 'Trash', 'formidable' ),
181 181
 		);
182 182
 
183
-	    $links = array();
184
-	    $counts = FrmForm::get_count();
183
+		$links = array();
184
+		$counts = FrmForm::get_count();
185 185
 		$form_type = self::get_param( array(
186 186
 			'param' => 'form_type',
187 187
 			'default' => 'published',
188 188
 		) );
189 189
 
190
-	    foreach ( $statuses as $status => $name ) {
190
+		foreach ( $statuses as $status => $name ) {
191 191
 
192
-	        if ( $status == $form_type ) {
193
-    			$class = ' class="current"';
194
-    		} else {
195
-    		    $class = '';
196
-    		}
192
+			if ( $status == $form_type ) {
193
+				$class = ' class="current"';
194
+			} else {
195
+				$class = '';
196
+			}
197 197
 
198
-    		if ( $counts->{$status} || 'published' == $status ) {
198
+			if ( $counts->{$status} || 'published' == $status ) {
199 199
 				$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
200
-		    }
200
+			}
201 201
 
202
-		    unset($status, $name);
203
-	    }
202
+			unset($status, $name);
203
+		}
204 204
 
205 205
 		return $links;
206 206
 	}
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	}
217 217
 
218 218
 	public function single_row( $item, $style = '' ) {
219
-	    global $frm_vars, $mode;
219
+		global $frm_vars, $mode;
220 220
 
221 221
 		// Set up the hover actions for this user
222 222
 		$actions = array();
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
 		$this->get_actions( $actions, $item, $edit_link );
226 226
 
227
-        $action_links = $this->row_actions( $actions );
227
+		$action_links = $this->row_actions( $actions );
228 228
 
229 229
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
230 230
 		$checkbox = '<input type="checkbox" name="item-action[]" id="cb-item-action-' . absint( $item->id ) . '" value="' . esc_attr( $item->id ) . '" />';
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
 
234 234
 		list( $columns, $hidden ) = $this->get_column_info();
235 235
 
236
-        $format = 'Y/m/d';
237
-        if ( 'list' != $mode ) {
238
-            $format .= ' \<\b\r \/\> g:i:s a';
236
+		$format = 'Y/m/d';
237
+		if ( 'list' != $mode ) {
238
+			$format .= ' \<\b\r \/\> g:i:s a';
239 239
 		}
240 240
 
241 241
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 			$style = '';
245 245
 			if ( in_array( $column_name, $hidden ) ) {
246
-                $class .= ' frm_hidden';
246
+				$class .= ' frm_hidden';
247 247
 			}
248 248
 
249 249
 			$class = 'class="' . esc_attr( $class ) . '"';
@@ -256,24 +256,24 @@  discard block
 block discarded – undo
256 256
 					break;
257 257
 				case 'id':
258 258
 				case 'form_key':
259
-				    $val = $item->{$column_name};
260
-				    break;
259
+					$val = $item->{$column_name};
260
+					break;
261 261
 				case 'name':
262
-				    $val = $this->get_form_name( $item, $actions, $edit_link, $mode );
263
-			        $val .= $action_links;
262
+					$val = $this->get_form_name( $item, $actions, $edit_link, $mode );
263
+					$val .= $action_links;
264 264
 
265
-				    break;
265
+					break;
266 266
 				case 'created_at':
267
-				    $date = date($format, strtotime($item->created_at));
267
+					$date = date($format, strtotime($item->created_at));
268 268
 					$val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
269 269
 					break;
270 270
 				case 'shortcode':
271 271
 					$val = '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable id=' . $item->id . ']' ) . '" /><br/>';
272
-				    if ( 'excerpt' == $mode ) {
272
+					if ( 'excerpt' == $mode ) {
273 273
 						$val .= '<input type="text" readonly="readonly" class="frm_select_box" value="' . esc_attr( '[formidable key=' . $item->form_key . ']' ) . '" />';
274
-				    }
275
-			        break;
276
-			    case 'entries':
274
+					}
275
+					break;
276
+				case 'entries':
277 277
 					if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
278 278
 						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Saving entries is disabled for this form', 'formidable' ) . '"></i>';
279 279
 					} else {
@@ -281,16 +281,16 @@  discard block
 block discarded – undo
281 281
 						$val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
282 282
 						unset( $text );
283 283
 					}
284
-			        break;
285
-                case 'type':
286
-                    $val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
287
-                    break;
284
+					break;
285
+				case 'type':
286
+					$val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
287
+					break;
288 288
 			}
289 289
 
290 290
 			if ( isset( $val ) ) {
291
-			    $r .= "<td $attributes>";
292
-			    $r .= $val;
293
-			    $r .= '</td>';
291
+				$r .= "<td $attributes>";
292
+				$r .= $val;
293
+				$r .= '</td>';
294 294
 			}
295 295
 			unset( $val );
296 296
 		}
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
 		return $r;
300 300
 	}
301 301
 
302
-    /**
303
-     * @param string $edit_link
304
-     */
302
+	/**
303
+	 * @param string $edit_link
304
+	 */
305 305
 	private function get_actions( &$actions, $item, $edit_link ) {
306 306
 		$new_actions = FrmFormsHelper::get_action_links( $item->id, $item );
307 307
 		foreach ( $new_actions as $link => $action ) {
@@ -325,52 +325,52 @@  discard block
 block discarded – undo
325 325
 
326 326
 		$actions = array_merge( $actions, $new_actions );
327 327
 		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
328
-    }
328
+	}
329 329
 
330
-    /**
331
-     * @param string $edit_link
332
-     */
330
+	/**
331
+	 * @param string $edit_link
332
+	 */
333 333
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
334
-        $form_name = $item->name;
335
-        if ( trim($form_name) == '' ) {
336
-            $form_name = __( '(no title)');
337
-        }
334
+		$form_name = $item->name;
335
+		if ( trim($form_name) == '' ) {
336
+			$form_name = __( '(no title)');
337
+		}
338 338
 		$form_name = FrmAppHelper::kses( $form_name );
339 339
 		if ( 'excerpt' != $mode ) {
340 340
 			$form_name = FrmAppHelper::truncate( $form_name, 50 );
341 341
 		}
342 342
 
343
-        $val = '<strong>';
344
-        if ( 'trash' == $this->status ) {
345
-            $val .= $form_name;
346
-        } else {
343
+		$val = '<strong>';
344
+		if ( 'trash' == $this->status ) {
345
+			$val .= $form_name;
346
+		} else {
347 347
 			$val .= '<a href="' . esc_url( isset( $actions['frm_edit'] ) ? $edit_link : FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" class="row-title">' . FrmAppHelper::kses( $form_name ) . '</a> ';
348
-        }
348
+		}
349 349
 
350
-        $this->add_draft_label( $item, $val );
351
-        $val .= '</strong>';
350
+		$this->add_draft_label( $item, $val );
351
+		$val .= '</strong>';
352 352
 
353
-        $this->add_form_description( $item, $val );
353
+		$this->add_form_description( $item, $val );
354 354
 
355
-        return $val;
356
-    }
355
+		return $val;
356
+	}
357 357
 
358
-    /**
359
-     * @param string $val
360
-     */
361
-    private function add_draft_label( $item, &$val ) {
362
-        if ( 'draft' == $item->status && 'draft' != $this->status ) {
358
+	/**
359
+	 * @param string $val
360
+	 */
361
+	private function add_draft_label( $item, &$val ) {
362
+		if ( 'draft' == $item->status && 'draft' != $this->status ) {
363 363
 			$val .= ' - <span class="post-state">' . __( 'Draft', 'formidable' ) . '</span>';
364
-        }
365
-    }
366
-
367
-    /**
368
-     * @param string $val
369
-     */
370
-    private function add_form_description( $item, &$val ) {
371
-        global $mode;
372
-        if ( 'excerpt' == $mode ) {
373
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
374
-        }
375
-    }
364
+		}
365
+	}
366
+
367
+	/**
368
+	 * @param string $val
369
+	 */
370
+	private function add_form_description( $item, &$val ) {
371
+		global $mode;
372
+		if ( 'excerpt' == $mode ) {
373
+			$val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
374
+		}
375
+	}
376 376
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 		$page = $this->get_pagenum();
19 19
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_per_page' );
20 20
 
21
-		$mode    = self::get_param( array(
21
+		$mode = self::get_param( array(
22 22
 			'param'   => 'mode',
23 23
 			'default' => 'list',
24 24
 		) );
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 			'param'   => 'orderby',
27 27
 			'default' => 'name',
28 28
 		) );
29
-		$order   = self::get_param( array(
29
+		$order = self::get_param( array(
30 30
 			'param'   => 'order',
31 31
 			'default' => 'ASC',
32 32
 		) );
33
-		$start   = self::get_param( array(
33
+		$start = self::get_param( array(
34 34
 			'param'   => 'start',
35 35
 			'default' => ( $page - 1 ) * $per_page,
36 36
 		) );
@@ -102,17 +102,17 @@  discard block
 block discarded – undo
102 102
 	    $actions = array();
103 103
 
104 104
 	    if ( 'trash' == $this->status ) {
105
-	        if ( current_user_can('frm_edit_forms') ) {
105
+	        if ( current_user_can( 'frm_edit_forms' ) ) {
106 106
 	            $actions['bulk_untrash'] = __( 'Restore', 'formidable' );
107 107
 	        }
108 108
 
109
-	        if ( current_user_can('frm_delete_forms') ) {
109
+	        if ( current_user_can( 'frm_delete_forms' ) ) {
110 110
 	            $actions['bulk_delete'] = __( 'Delete Permanently', 'formidable' );
111 111
 	        }
112
-	    } else if ( EMPTY_TRASH_DAYS && current_user_can('frm_delete_forms') ) {
112
+	    } else if ( EMPTY_TRASH_DAYS && current_user_can( 'frm_delete_forms' ) ) {
113 113
 	        $actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
114
-	    } else if ( current_user_can('frm_delete_forms') ) {
115
-	        $actions['bulk_delete'] = __( 'Delete');
114
+	    } else if ( current_user_can( 'frm_delete_forms' ) ) {
115
+	        $actions['bulk_delete'] = __( 'Delete' );
116 116
 	    }
117 117
 
118 118
         return $actions;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             return;
124 124
         }
125 125
 
126
-        if ( 'trash' == $this->status && current_user_can('frm_delete_forms') ) {
126
+        if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) {
127 127
 ?>
128 128
             <div class="alignleft actions frm_visible_overflow">
129 129
 			<?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
140 140
 		$forms = FrmForm::get_published_forms( $where );
141 141
 
142
-        $base = admin_url('admin.php?page=formidable&form_type=template');
142
+        $base = admin_url( 'admin.php?page=formidable&form_type=template' );
143 143
         $args = array(
144 144
             'frm_action'    => 'duplicate',
145 145
             'template'      => true,
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 				?>
162 162
 			<li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
163 163
 			<?php
164
-			    unset($form);
164
+			    unset( $form );
165 165
 			}
166 166
         }
167 167
         ?>
@@ -196,10 +196,10 @@  discard block
 block discarded – undo
196 196
     		}
197 197
 
198 198
     		if ( $counts->{$status} || 'published' == $status ) {
199
-				$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
199
+				$links[$status] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
200 200
 		    }
201 201
 
202
-		    unset($status, $name);
202
+		    unset( $status, $name );
203 203
 	    }
204 204
 
205 205
 		return $links;
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 
265 265
 				    break;
266 266
 				case 'created_at':
267
-				    $date = date($format, strtotime($item->created_at));
267
+				    $date = date( $format, strtotime( $item->created_at ) );
268 268
 					$val = '<abbr title="' . esc_attr( date( 'Y/m/d g:i:s A', strtotime( $item->created_at ) ) ) . '">' . $date . '</abbr>';
269 269
 					break;
270 270
 				case 'shortcode':
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 			        break;
276 276
 			    case 'entries':
277 277
 					if ( isset( $item->options['no_save'] ) && $item->options['no_save'] ) {
278
-						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr('Saving entries is disabled for this form', 'formidable' ) . '"></i>';
278
+						$val = '<i class="frm_icon_font frm_forbid_icon frm_bstooltip" title="' . esc_attr( 'Saving entries is disabled for this form', 'formidable' ) . '"></i>';
279 279
 					} else {
280 280
 						$text = FrmEntry::getRecordCount( $item->id );
281 281
 						$val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	private function get_actions( &$actions, $item, $edit_link ) {
306 306
 		$new_actions = FrmFormsHelper::get_action_links( $item->id, $item );
307 307
 		foreach ( $new_actions as $link => $action ) {
308
-			$new_actions[ $link ] = FrmFormsHelper::format_link_html( $action, 'short' );
308
+			$new_actions[$link] = FrmFormsHelper::format_link_html( $action, 'short' );
309 309
 		}
310 310
 
311 311
 		if ( 'trash' == $this->status ) {
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 		}
325 325
 
326 326
 		$actions = array_merge( $actions, $new_actions );
327
-		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview') . '</a>';
327
+		$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview' ) . '</a>';
328 328
     }
329 329
 
330 330
     /**
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
      */
333 333
 	private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
334 334
         $form_name = $item->name;
335
-        if ( trim($form_name) == '' ) {
336
-            $form_name = __( '(no title)');
335
+        if ( trim( $form_name ) == '' ) {
336
+            $form_name = __( '(no title)' );
337 337
         }
338 338
 		$form_name = FrmAppHelper::kses( $form_name );
339 339
 		if ( 'excerpt' != $mode ) {
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
     private function add_form_description( $item, &$val ) {
371 371
         global $mode;
372 372
         if ( 'excerpt' == $mode ) {
373
-            $val .= FrmAppHelper::truncate(strip_tags($item->description), 50);
373
+            $val .= FrmAppHelper::truncate( strip_tags( $item->description ), 50 );
374 374
         }
375 375
     }
376 376
 }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesHelper.php 2 patches
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -5,19 +5,19 @@  discard block
 block discarded – undo
5 5
 
6 6
 class FrmEntriesHelper {
7 7
 
8
-    public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
8
+	public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
9 9
 		$values = array(
10 10
 			'name'        => '',
11 11
 			'description' => '',
12 12
 			'item_key'    => '',
13 13
 		);
14 14
 
15
-        $values['fields'] = array();
15
+		$values['fields'] = array();
16 16
 		if ( empty( $fields ) ) {
17 17
 			return apply_filters( 'frm_setup_new_entry', $values );
18 18
 		}
19 19
 
20
-        foreach ( (array) $fields as $field ) {
20
+		foreach ( (array) $fields as $field ) {
21 21
 			$original_default = $field->default_value;
22 22
 			self::prepare_field_default_value( $field );
23 23
 			$new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 
33 33
 			FrmFieldsHelper::prepare_new_front_field( $field_array, $field, $args );
34 34
 
35
-            $field_array = array_merge( $field->field_options, $field_array );
35
+			$field_array = array_merge( $field->field_options, $field_array );
36 36
 
37
-            $values['fields'][] = $field_array;
37
+			$values['fields'][] = $field_array;
38 38
 
39 39
 			if ( ! $form || ! isset( $form->id ) ) {
40 40
 				$form = FrmForm::getOne( $field->form_id );
41 41
 			}
42
-        }
42
+		}
43 43
 
44 44
 		$form->options = maybe_unserialize( $form->options );
45 45
 		if ( is_array( $form->options ) ) {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		$values = array_merge( $form_defaults, $values );
55 55
 
56 56
 		return apply_filters( 'frm_setup_new_entry', $values );
57
-    }
57
+	}
58 58
 
59 59
 	/**
60 60
 	 * @since 2.05
@@ -71,16 +71,16 @@  discard block
 block discarded – undo
71 71
 	}
72 72
 
73 73
 	/**
74
-	* Set the value for each field
75
-	* This function is used when the form is first loaded and on all page turns *for a new entry*
76
-	*
77
-	* @since 2.0.13
78
-	*
79
-	* @param object $field - this is passed by reference since it is an object
80
-	* @param boolean $reset
81
-	* @param array $args
82
-	* @return string|array $new_value
83
-	*/
74
+	 * Set the value for each field
75
+	 * This function is used when the form is first loaded and on all page turns *for a new entry*
76
+	 *
77
+	 * @since 2.0.13
78
+	 *
79
+	 * @param object $field - this is passed by reference since it is an object
80
+	 * @param boolean $reset
81
+	 * @param array $args
82
+	 * @return string|array $new_value
83
+	 */
84 84
 	private static function get_field_value_for_new_entry( $field, $reset, $args ) {
85 85
 		$new_value = $field->default_value;
86 86
 
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 
107 107
 	/**
108
-	* Check if a field has a posted value
109
-	*
110
-	* @since 2.01.0
111
-	* @param object $field
112
-	* @param array $args
113
-	* @return boolean $value_is_posted
114
-	*/
108
+	 * Check if a field has a posted value
109
+	 *
110
+	 * @since 2.01.0
111
+	 * @param object $field
112
+	 * @param array $args
113
+	 * @return boolean $value_is_posted
114
+	 */
115 115
 	public static function value_is_posted( $field, $args ) {
116 116
 		$value_is_posted = false;
117 117
 		if ( $_POST ) {
@@ -129,93 +129,93 @@  discard block
 block discarded – undo
129 129
 
130 130
 	public static function setup_edit_vars( $values, $record ) {
131 131
 		$values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
132
-        $values['form_id'] = $record->form_id;
133
-        $values['is_draft'] = $record->is_draft;
132
+		$values['form_id'] = $record->form_id;
133
+		$values['is_draft'] = $record->is_draft;
134 134
 		return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
135
-    }
135
+	}
136 136
 
137 137
 	public static function replace_default_message( $message, $atts ) {
138 138
 		if ( strpos( $message, '[default-message') === false &&
139 139
 			strpos( $message, '[default_message') === false &&
140
-            ! empty( $message ) ) {
141
-            return $message;
142
-        }
140
+			! empty( $message ) ) {
141
+			return $message;
142
+		}
143 143
 
144 144
 		if ( empty( $message ) ) {
145
-            $message = '[default-message]';
146
-        }
145
+			$message = '[default-message]';
146
+		}
147 147
 
148 148
 		preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
149 149
 
150
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
150
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
151 151
 			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
152 152
 			if ( ! empty( $add_atts ) ) {
153 153
 				$this_atts = array_merge( $atts, $add_atts );
154
-            } else {
155
-                $this_atts = $atts;
156
-            }
154
+			} else {
155
+				$this_atts = $atts;
156
+			}
157 157
 
158 158
 			$default = FrmEntriesController::show_entry_shortcode( $this_atts );
159 159
 
160
-            // Add the default message
161
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
162
-        }
160
+			// Add the default message
161
+			$message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
162
+		}
163 163
 
164
-        return $message;
165
-    }
164
+		return $message;
165
+	}
166 166
 
167 167
 	public static function prepare_display_value( $entry, $field, $atts ) {
168 168
 		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
169 169
 
170
-        if ( FrmAppHelper::pro_is_installed() ) {
170
+		if ( FrmAppHelper::pro_is_installed() ) {
171 171
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
172
-        }
172
+		}
173 173
 
174 174
 		if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
175 175
 			return self::display_value( $field_value, $field, $atts );
176 176
 		}
177 177
 
178
-        // this is an embeded form
179
-        $val = '';
178
+		// this is an embeded form
179
+		$val = '';
180 180
 
181
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
182
-            //this is a repeating section
181
+		if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
182
+			//this is a repeating section
183 183
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
184
-        } else {
185
-            // get all values for this field
186
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
184
+		} else {
185
+			// get all values for this field
186
+			$child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
187 187
 
188
-            if ( $child_values ) {
189
-	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
190
-	        }
191
-	    }
188
+			if ( $child_values ) {
189
+				$child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
190
+			}
191
+		}
192 192
 
193
-	    $field_value = array();
193
+		$field_value = array();
194 194
 
195
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
196
-            return $val;
197
-        }
195
+		if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
196
+			return $val;
197
+		}
198 198
 
199
-        foreach ( $child_entries as $child_entry ) {
200
-            $atts['item_id'] = $child_entry->id;
201
-            $atts['post_id'] = $child_entry->post_id;
199
+		foreach ( $child_entries as $child_entry ) {
200
+			$atts['item_id'] = $child_entry->id;
201
+			$atts['post_id'] = $child_entry->post_id;
202 202
 
203
-            // get the value for this field -- check for post values as well
204
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
203
+			// get the value for this field -- check for post values as well
204
+			$entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
205 205
 
206
-            if ( $entry_val ) {
207
-                // foreach entry get display_value
208
-                $field_value[] = self::display_value($entry_val, $field, $atts);
209
-            }
206
+			if ( $entry_val ) {
207
+				// foreach entry get display_value
208
+				$field_value[] = self::display_value($entry_val, $field, $atts);
209
+			}
210 210
 
211
-            unset($child_entry);
212
-        }
211
+			unset($child_entry);
212
+		}
213 213
 
214
-        $val = implode(', ', (array) $field_value );
214
+		$val = implode(', ', (array) $field_value );
215 215
 		return FrmAppHelper::kses( $val, 'all' );
216
-    }
216
+	}
217 217
 
218
-    /**
218
+	/**
219 219
 	 * Prepare the saved value for display
220 220
 	 *
221 221
 	 * @param array|string $value
@@ -239,35 +239,35 @@  discard block
 block discarded – undo
239 239
 			'return_array' => false,
240 240
 		);
241 241
 
242
-        $atts = wp_parse_args( $atts, $defaults );
242
+		$atts = wp_parse_args( $atts, $defaults );
243 243
 
244 244
 		if ( FrmField::is_image( $field ) || $field->type == 'star' ) {
245 245
 			$atts['truncate'] = false;
246 246
 			$atts['html'] = true;
247 247
 		}
248 248
 
249
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
249
+		$atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
250 250
 
251
-        if ( ! isset($field->field_options['post_field']) ) {
252
-            $field->field_options['post_field'] = '';
253
-        }
251
+		if ( ! isset($field->field_options['post_field']) ) {
252
+			$field->field_options['post_field'] = '';
253
+		}
254 254
 
255
-        if ( ! isset($field->field_options['custom_field']) ) {
256
-            $field->field_options['custom_field'] = '';
257
-        }
255
+		if ( ! isset($field->field_options['custom_field']) ) {
256
+			$field->field_options['custom_field'] = '';
257
+		}
258 258
 
259
-        if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
260
-            $atts['pre_truncate'] = $atts['truncate'];
261
-            $atts['truncate'] = true;
262
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
259
+		if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
260
+			$atts['pre_truncate'] = $atts['truncate'];
261
+			$atts['truncate'] = true;
262
+			$atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
263 263
 
264
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
265
-            $atts['truncate'] = $atts['pre_truncate'];
266
-        }
264
+			$value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
265
+			$atts['truncate'] = $atts['pre_truncate'];
266
+		}
267 267
 
268
-        if ( $value == '' ) {
269
-            return $value;
270
-        }
268
+		if ( $value == '' ) {
269
+			return $value;
270
+		}
271 271
 
272 272
 		$unfiltered_value = maybe_unserialize( $value );
273 273
 		$value = apply_filters( 'frm_display_value_custom', $unfiltered_value, $field, $atts );
@@ -277,130 +277,130 @@  discard block
 block discarded – undo
277 277
 			$value = FrmFieldsHelper::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) );
278 278
 		}
279 279
 
280
-        if ( $atts['truncate'] && $atts['type'] != 'url' ) {
280
+		if ( $atts['truncate'] && $atts['type'] != 'url' ) {
281 281
 			$value = FrmAppHelper::truncate( $value, 50 );
282
-        }
282
+		}
283 283
 
284 284
 		if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
285 285
 			$value = FrmAppHelper::kses( $value, 'all' );
286 286
 		}
287 287
 
288 288
 		return apply_filters( 'frm_display_value', $value, $field, $atts );
289
-    }
289
+	}
290 290
 
291 291
 	public static function set_posted_value( $field, $value, $args ) {
292
-        // If validating a field with "other" opt, set back to prev value now
293
-        if ( isset( $args['other'] ) && $args['other'] ) {
294
-            $value = $args['temp_value'];
295
-        }
292
+		// If validating a field with "other" opt, set back to prev value now
293
+		if ( isset( $args['other'] ) && $args['other'] ) {
294
+			$value = $args['temp_value'];
295
+		}
296 296
 		if ( empty( $args['parent_field_id'] ) ) {
297
-            $_POST['item_meta'][ $field->id ] = $value;
298
-        } else {
299
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
300
-        }
301
-    }
297
+			$_POST['item_meta'][ $field->id ] = $value;
298
+		} else {
299
+			$_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
300
+		}
301
+	}
302 302
 
303 303
 	public static function get_posted_value( $field, &$value, $args ) {
304 304
 		$field_id = is_object( $field ) ? $field->id : $field;
305 305
 
306 306
 		if ( empty( $args['parent_field_id'] ) ) {
307
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
308
-        } else {
309
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
310
-        }
307
+			$value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
308
+		} else {
309
+			$value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
310
+		}
311 311
 		FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
312 312
 		$value = stripslashes_deep( $value );
313
-    }
314
-
315
-    /**
316
-    * Check if field has an "Other" option and if any other values are posted
317
-    *
318
-    * @since 2.0
319
-    *
320
-    * @param object $field
321
-    * @param string|array $value
322
-    * @param array $args
323
-    */
324
-    public static function maybe_set_other_validation( $field, &$value, &$args ) {
325
-        $args['other'] = false;
326
-        if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
327
-            return;
328
-        }
329
-
330
-        // Get other value for fields in repeating section
331
-        self::set_other_repeating_vals( $field, $value, $args );
332
-
333
-        // Check if there are any posted "Other" values
313
+	}
314
+
315
+	/**
316
+	 * Check if field has an "Other" option and if any other values are posted
317
+	 *
318
+	 * @since 2.0
319
+	 *
320
+	 * @param object $field
321
+	 * @param string|array $value
322
+	 * @param array $args
323
+	 */
324
+	public static function maybe_set_other_validation( $field, &$value, &$args ) {
325
+		$args['other'] = false;
326
+		if ( ! $value || empty( $value ) || ! FrmAppHelper::pro_is_installed() ) {
327
+			return;
328
+		}
329
+
330
+		// Get other value for fields in repeating section
331
+		self::set_other_repeating_vals( $field, $value, $args );
332
+
333
+		// Check if there are any posted "Other" values
334 334
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
335 335
 
336
-            // Save original value
337
-            $args['temp_value'] = $value;
338
-            $args['other'] = true;
339
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
340
-
341
-            // Set the validation value now
342
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
343
-        }
344
-    }
345
-
346
-    /**
347
-    * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
348
-    *
349
-    * @since 2.0
350
-    *
351
-    * @param object $field
352
-    * @param string|array $value
353
-    * @param array $args
354
-    */
355
-    public static function set_other_repeating_vals( $field, &$value, &$args ) {
356
-        if ( ! $args['parent_field_id'] ) {
357
-            return;
358
-        }
359
-
360
-        // Check if there are any other posted "other" values for this field
336
+			// Save original value
337
+			$args['temp_value'] = $value;
338
+			$args['other'] = true;
339
+			$other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
340
+
341
+			// Set the validation value now
342
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
343
+		}
344
+	}
345
+
346
+	/**
347
+	 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
348
+	 *
349
+	 * @since 2.0
350
+	 *
351
+	 * @param object $field
352
+	 * @param string|array $value
353
+	 * @param array $args
354
+	 */
355
+	public static function set_other_repeating_vals( $field, &$value, &$args ) {
356
+		if ( ! $args['parent_field_id'] ) {
357
+			return;
358
+		}
359
+
360
+		// Check if there are any other posted "other" values for this field
361 361
 		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
362
-            // Save original value
363
-            $args['temp_value'] = $value;
364
-            $args['other'] = true;
365
-
366
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
367
-
368
-            // Set the validation value now
369
-            self::set_other_validation_val( $value, $other_vals, $field, $args );
370
-        }
371
-    }
372
-
373
-    /**
374
-    * Modify value used for validation
375
-    * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
376
-    * It also adds any text from the free text fields to the value
377
-    *
378
-    * Needs to accommodate for times when other opt is selected, but no other free text is entered
379
-    *
380
-    * @since 2.0
381
-    *
382
-    * @param string|array $value
383
-    * @param string|array $other_vals (usually of posted values)
384
-    * @param object $field
385
-    * @param array $args
386
-    */
387
-    public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
388
-        // Checkboxes and multi-select dropdowns
389
-        if ( is_array( $value ) && $field->type == 'checkbox' ) {
390
-            // Combine "Other" values with checked values. "Other" values will override checked box values.
391
-            $value = array_merge( $value, $other_vals );
392
-            $value = array_filter( $value );
393
-            if ( count( $value ) == 0 ) {
394
-                $value = '';
395
-            }
396
-        } else {
362
+			// Save original value
363
+			$args['temp_value'] = $value;
364
+			$args['other'] = true;
365
+
366
+			$other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
367
+
368
+			// Set the validation value now
369
+			self::set_other_validation_val( $value, $other_vals, $field, $args );
370
+		}
371
+	}
372
+
373
+	/**
374
+	 * Modify value used for validation
375
+	 * This function essentially removes the "Other" radio or checkbox value from the $value being validated.
376
+	 * It also adds any text from the free text fields to the value
377
+	 *
378
+	 * Needs to accommodate for times when other opt is selected, but no other free text is entered
379
+	 *
380
+	 * @since 2.0
381
+	 *
382
+	 * @param string|array $value
383
+	 * @param string|array $other_vals (usually of posted values)
384
+	 * @param object $field
385
+	 * @param array $args
386
+	 */
387
+	public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
388
+		// Checkboxes and multi-select dropdowns
389
+		if ( is_array( $value ) && $field->type == 'checkbox' ) {
390
+			// Combine "Other" values with checked values. "Other" values will override checked box values.
391
+			$value = array_merge( $value, $other_vals );
392
+			$value = array_filter( $value );
393
+			if ( count( $value ) == 0 ) {
394
+				$value = '';
395
+			}
396
+		} else {
397 397
 			// Radio and dropdowns
398 398
 			$other_key = array_filter( array_keys( $field->options ), 'is_string' );
399
-            $other_key = reset( $other_key );
399
+			$other_key = reset( $other_key );
400 400
 
401
-            // Multi-select dropdown
402
-            if ( is_array( $value ) ) {
403
-                $o_key = array_search( $field->options[ $other_key ], $value );
401
+			// Multi-select dropdown
402
+			if ( is_array( $value ) ) {
403
+				$o_key = array_search( $field->options[ $other_key ], $value );
404 404
 
405 405
 				if ( $o_key !== false ) {
406 406
 					// Modify the original value so other key will be preserved
@@ -418,15 +418,15 @@  discard block
 block discarded – undo
418 418
 						unset( $value[ $other_key ] );
419 419
 					}
420 420
 				}
421
-            } else if ( $field->options[ $other_key ] == $value ) {
422
-                $value = $other_vals;
423
-            }
424
-        }
425
-    }
421
+			} else if ( $field->options[ $other_key ] == $value ) {
422
+				$value = $other_vals;
423
+			}
424
+		}
425
+	}
426 426
 
427
-    // Add submitted values to a string for spam checking
427
+	// Add submitted values to a string for spam checking
428 428
 	public static function entry_array_to_string( $values ) {
429
-        $content = '';
429
+		$content = '';
430 430
 		foreach ( $values['item_meta'] as $val ) {
431 431
 			if ( $content != '' ) {
432 432
 				$content .= "\n\n";
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 		}
442 442
 
443 443
 		return $content;
444
-    }
444
+	}
445 445
 
446 446
 	/**
447 447
 	 * Get the browser from the user agent
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		$form_defaults = FrmFormsHelper::get_default_opts();
50 50
 
51 51
 		$frm_settings = FrmAppHelper::get_settings();
52
-		$form_defaults['custom_style']  = ( $frm_settings->load_style != 'none' );
52
+		$form_defaults['custom_style'] = ( $frm_settings->load_style != 'none' );
53 53
 
54 54
 		$values = array_merge( $form_defaults, $values );
55 55
 
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 		if ( $_POST ) {
118 118
 			$repeating = isset( $args['repeating'] ) && $args['repeating'];
119 119
 			if ( $repeating ) {
120
-				if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) {
120
+				if ( isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] ) ) {
121 121
 					$value_is_posted = true;
122 122
 				}
123
-			} else if ( isset( $_POST['item_meta'][ $field->id ] ) ) {
123
+			} else if ( isset( $_POST['item_meta'][$field->id] ) ) {
124 124
 				$value_is_posted = true;
125 125
 			}
126 126
 		}
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
     }
136 136
 
137 137
 	public static function replace_default_message( $message, $atts ) {
138
-		if ( strpos( $message, '[default-message') === false &&
139
-			strpos( $message, '[default_message') === false &&
138
+		if ( strpos( $message, '[default-message' ) === false &&
139
+			strpos( $message, '[default_message' ) === false &&
140 140
             ! empty( $message ) ) {
141 141
             return $message;
142 142
         }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
149 149
 
150 150
         foreach ( $shortcodes[0] as $short_key => $tag ) {
151
-			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
151
+			$add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] );
152 152
 			if ( ! empty( $add_atts ) ) {
153 153
 				$this_atts = array_merge( $atts, $add_atts );
154 154
             } else {
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
 			$default = FrmEntriesController::show_entry_shortcode( $this_atts );
159 159
 
160 160
             // Add the default message
161
-            $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
161
+            $message = str_replace( $shortcodes[0][$short_key], $default, $message );
162 162
         }
163 163
 
164 164
         return $message;
165 165
     }
166 166
 
167 167
 	public static function prepare_display_value( $entry, $field, $atts ) {
168
-		$field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
168
+		$field_value = isset( $entry->metas[$field->id] ) ? $entry->metas[$field->id] : false;
169 169
 
170 170
         if ( FrmAppHelper::pro_is_installed() ) {
171 171
 			FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
@@ -178,12 +178,12 @@  discard block
 block discarded – undo
178 178
         // this is an embeded form
179 179
         $val = '';
180 180
 
181
-	    if ( strpos($atts['embedded_field_id'], 'form') === 0 ) {
181
+	    if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
182 182
             //this is a repeating section
183 183
 			$child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ) );
184 184
         } else {
185 185
             // get all values for this field
186
-	        $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
186
+	        $child_values = isset( $entry->metas[$atts['embedded_field_id']] ) ? $entry->metas[$atts['embedded_field_id']] : false;
187 187
 
188 188
             if ( $child_values ) {
189 189
 	            $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 	    $field_value = array();
194 194
 
195
-        if ( ! isset($child_entries) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
195
+        if ( ! isset( $child_entries ) || ! $child_entries || ! FrmAppHelper::pro_is_installed() ) {
196 196
             return $val;
197 197
         }
198 198
 
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
             $atts['post_id'] = $child_entry->post_id;
202 202
 
203 203
             // get the value for this field -- check for post values as well
204
-            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value($child_entry, $field);
204
+            $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
205 205
 
206 206
             if ( $entry_val ) {
207 207
                 // foreach entry get display_value
208
-                $field_value[] = self::display_value($entry_val, $field, $atts);
208
+                $field_value[] = self::display_value( $entry_val, $field, $atts );
209 209
             }
210 210
 
211
-            unset($child_entry);
211
+            unset( $child_entry );
212 212
         }
213 213
 
214
-        $val = implode(', ', (array) $field_value );
214
+        $val = implode( ', ', (array) $field_value );
215 215
 		return FrmAppHelper::kses( $val, 'all' );
216 216
     }
217 217
 
@@ -246,22 +246,22 @@  discard block
 block discarded – undo
246 246
 			$atts['html'] = true;
247 247
 		}
248 248
 
249
-        $atts = apply_filters('frm_display_value_atts', $atts, $field, $value);
249
+        $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
250 250
 
251
-        if ( ! isset($field->field_options['post_field']) ) {
251
+        if ( ! isset( $field->field_options['post_field'] ) ) {
252 252
             $field->field_options['post_field'] = '';
253 253
         }
254 254
 
255
-        if ( ! isset($field->field_options['custom_field']) ) {
255
+        if ( ! isset( $field->field_options['custom_field'] ) ) {
256 256
             $field->field_options['custom_field'] = '';
257 257
         }
258 258
 
259 259
         if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
260 260
             $atts['pre_truncate'] = $atts['truncate'];
261 261
             $atts['truncate'] = true;
262
-            $atts['exclude_cat'] = isset($field->field_options['exclude_cat']) ? $field->field_options['exclude_cat'] : 0;
262
+            $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
263 263
 
264
-            $value = FrmProEntryMetaHelper::get_post_value($atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts);
264
+            $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
265 265
             $atts['truncate'] = $atts['pre_truncate'];
266 266
         }
267 267
 
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
             $value = $args['temp_value'];
295 295
         }
296 296
 		if ( empty( $args['parent_field_id'] ) ) {
297
-            $_POST['item_meta'][ $field->id ] = $value;
297
+            $_POST['item_meta'][$field->id] = $value;
298 298
         } else {
299
-            $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value;
299
+            $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field->id] = $value;
300 300
         }
301 301
     }
302 302
 
@@ -304,9 +304,9 @@  discard block
 block discarded – undo
304 304
 		$field_id = is_object( $field ) ? $field->id : $field;
305 305
 
306 306
 		if ( empty( $args['parent_field_id'] ) ) {
307
-            $value = isset( $_POST['item_meta'][ $field_id ] ) ? $_POST['item_meta'][ $field_id ] : '';
307
+            $value = isset( $_POST['item_meta'][$field_id] ) ? $_POST['item_meta'][$field_id] : '';
308 308
         } else {
309
-            $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] : '';
309
+            $value = isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] ) ? $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']][$field_id] : '';
310 310
         }
311 311
 		FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
312 312
 		$value = stripslashes_deep( $value );
@@ -331,12 +331,12 @@  discard block
 block discarded – undo
331 331
         self::set_other_repeating_vals( $field, $value, $args );
332 332
 
333 333
         // Check if there are any posted "Other" values
334
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) {
334
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][$field->id] ) ) {
335 335
 
336 336
             // Save original value
337 337
             $args['temp_value'] = $value;
338 338
             $args['other'] = true;
339
-            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][ $field->id ] );
339
+            $other_vals = stripslashes_deep( $_POST['item_meta']['other'][$field->id] );
340 340
 
341 341
             // Set the validation value now
342 342
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -358,12 +358,12 @@  discard block
 block discarded – undo
358 358
         }
359 359
 
360 360
         // Check if there are any other posted "other" values for this field
361
-		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) {
361
+		if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id] ) ) {
362 362
             // Save original value
363 363
             $args['temp_value'] = $value;
364 364
             $args['other'] = true;
365 365
 
366
-            $other_vals = $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ];
366
+            $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id];
367 367
 
368 368
             // Set the validation value now
369 369
             self::set_other_validation_val( $value, $other_vals, $field, $args );
@@ -400,25 +400,25 @@  discard block
 block discarded – undo
400 400
 
401 401
             // Multi-select dropdown
402 402
             if ( is_array( $value ) ) {
403
-                $o_key = array_search( $field->options[ $other_key ], $value );
403
+                $o_key = array_search( $field->options[$other_key], $value );
404 404
 
405 405
 				if ( $o_key !== false ) {
406 406
 					// Modify the original value so other key will be preserved
407
-					$value[ $other_key ] = $value[ $o_key ];
407
+					$value[$other_key] = $value[$o_key];
408 408
 
409 409
 					// By default, the array keys will be numeric for multi-select dropdowns
410 410
 					// If going backwards and forwards between pages, the array key will match the other key
411 411
 					if ( $o_key !== $other_key ) {
412
-						unset( $value[ $o_key ] );
412
+						unset( $value[$o_key] );
413 413
 					}
414 414
 
415 415
 					$args['temp_value'] = $value;
416
-					$value[ $other_key ] = reset( $other_vals );
417
-					if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) {
418
-						unset( $value[ $other_key ] );
416
+					$value[$other_key] = reset( $other_vals );
417
+					if ( FrmAppHelper::is_empty_value( $value[$other_key] ) ) {
418
+						unset( $value[$other_key] );
419 419
 					}
420 420
 				}
421
-            } else if ( $field->options[ $other_key ] == $value ) {
421
+            } else if ( $field->options[$other_key] == $value ) {
422 422
                 $value = $other_vals;
423 423
             }
424 424
         }
Please login to merge, or discard this patch.
classes/helpers/FrmFormsHelper.php 2 patches
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -14,38 +14,38 @@  discard block
 block discarded – undo
14 14
 
15 15
 	public static function get_direct_link( $key, $form = false ) {
16 16
 		$target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
17
-        $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
18
-
19
-        return $target_url;
20
-    }
21
-
22
-    public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
23
-        $defaults = array(
24
-            'blank'     => true,
25
-            'field_id'  => false,
26
-            'onchange'  => false,
27
-            'exclude'   => false,
28
-            'class'     => '',
17
+		$target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
18
+
19
+		return $target_url;
20
+	}
21
+
22
+	public static function forms_dropdown( $field_name, $field_value = '', $args = array() ) {
23
+		$defaults = array(
24
+			'blank'     => true,
25
+			'field_id'  => false,
26
+			'onchange'  => false,
27
+			'exclude'   => false,
28
+			'class'     => '',
29 29
 			'inc_children' => 'exclude',
30
-        );
31
-        $args = wp_parse_args( $args, $defaults );
30
+		);
31
+		$args = wp_parse_args( $args, $defaults );
32 32
 
33
-        if ( ! $args['field_id'] ) {
34
-            $args['field_id'] = $field_name;
35
-        }
33
+		if ( ! $args['field_id'] ) {
34
+			$args['field_id'] = $field_name;
35
+		}
36 36
 
37 37
 		$query = array();
38
-        if ( $args['exclude'] ) {
38
+		if ( $args['exclude'] ) {
39 39
 			$query['id !'] = $args['exclude'];
40
-        }
40
+		}
41 41
 
42
-        $where = apply_filters('frm_forms_dropdown', $query, $field_name);
42
+		$where = apply_filters('frm_forms_dropdown', $query, $field_name);
43 43
 		$forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
44 44
 		$add_html = array();
45 45
 		self::add_html_attr( $args['onchange'], 'onchange', $add_html );
46 46
 		self::add_html_attr( $args['class'], 'class', $add_html );
47 47
 
48
-        ?>
48
+		?>
49 49
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $args['field_id'] ) ?>" <?php echo implode( ' ', $add_html ); ?>>
50 50
 		<?php if ( $args['blank'] ) { ?>
51 51
 			<option value=""><?php echo ( $args['blank'] == 1 ) ? ' ' : '- ' . esc_attr( $args['blank'] ) . ' -'; ?></option>
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		<?php } ?>
58 58
         </select>
59 59
         <?php
60
-    }
60
+	}
61 61
 
62 62
 	/**
63 63
 	 * @param string $class
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		}
73 73
 	}
74 74
 
75
-    public static function form_switcher() {
75
+	public static function form_switcher() {
76 76
 		$where = apply_filters( 'frm_forms_dropdown', array(), '' );
77 77
 		$forms = FrmForm::get_published_forms( $where );
78 78
 
@@ -84,32 +84,32 @@  discard block
 block discarded – undo
84 84
 			unset( $args['form'] );
85 85
 		} else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) {
86 86
 			unset( $args['id'] );
87
-        }
87
+		}
88 88
 
89 89
 		$frm_action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
90 90
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
91
-            $args['frm_action'] = 'list';
92
-            $args['form'] = 0;
91
+			$args['frm_action'] = 'list';
92
+			$args['form'] = 0;
93 93
 		} else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
94
-            $args['frm_action'] = 'edit';
94
+			$args['frm_action'] = 'edit';
95 95
 		} else if ( isset( $_GET['post'] ) ) {
96
-            $args['form'] = 0;
97
-            $base = admin_url('edit.php?post_type=frm_display');
98
-        }
96
+			$args['form'] = 0;
97
+			$base = admin_url('edit.php?post_type=frm_display');
98
+		}
99 99
 
100
-        ?>
100
+		?>
101 101
 		<li id="frm_bs_dropdown" class="dropdown <?php echo esc_attr( is_rtl() ? 'pull-right' : 'pull-left' ) ?>">
102 102
 			<a href="#" id="frm-navbarDrop" class="frm-dropdown-toggle" data-toggle="dropdown"><?php esc_html_e( 'Switch Form', 'formidable' ) ?> <b class="caret"></b></a>
103 103
 		    <ul class="frm-dropdown-menu frm-on-top" role="menu" aria-labelledby="frm-navbarDrop">
104 104
 			<?php
105 105
 			foreach ( $forms as $form ) {
106 106
 				if ( isset( $args['id'] ) ) {
107
-			        $args['id'] = $form->id;
107
+					$args['id'] = $form->id;
108 108
 				}
109
-			    if ( isset( $args['form'] ) ) {
110
-			        $args['form'] = $form->id;
109
+				if ( isset( $args['form'] ) ) {
110
+					$args['form'] = $form->id;
111 111
 				}
112
-                ?>
112
+				?>
113 113
 				<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
114 114
 			<?php
115 115
 				unset( $form );
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			</ul>
119 119
 		</li>
120 120
         <?php
121
-    }
121
+	}
122 122
 
123 123
 	public static function get_sortable_classes( $col, $sort_col, $sort_dir ) {
124 124
 		echo ( $sort_col == $col ) ? 'sorted' : 'sortable';
@@ -169,18 +169,18 @@  discard block
 block discarded – undo
169 169
 		return $message;
170 170
 	}
171 171
 
172
-    /**
173
-     * Used when a form is created
174
-     */
175
-    public static function setup_new_vars( $values = array() ) {
176
-        global $wpdb;
172
+	/**
173
+	 * Used when a form is created
174
+	 */
175
+	public static function setup_new_vars( $values = array() ) {
176
+		global $wpdb;
177 177
 
178
-        if ( ! empty( $values ) ) {
179
-            $post_values = $values;
180
-        } else {
181
-            $values = array();
182
-            $post_values = isset($_POST) ? $_POST : array();
183
-        }
178
+		if ( ! empty( $values ) ) {
179
+			$post_values = $values;
180
+		} else {
181
+			$values = array();
182
+			$post_values = isset($_POST) ? $_POST : array();
183
+		}
184 184
 
185 185
 		$defaults = array(
186 186
 			'name' => '',
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
 		foreach ( $defaults as $var => $default ) {
190 190
 			if ( ! isset( $values[ $var ] ) ) {
191 191
 				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
192
-            }
193
-        }
192
+			}
193
+		}
194 194
 
195
-        $values['description'] = FrmAppHelper::use_wpautop($values['description']);
195
+		$values['description'] = FrmAppHelper::use_wpautop($values['description']);
196 196
 
197 197
 		$defaults = array(
198 198
 			'form_id'        => '',
@@ -210,64 +210,64 @@  discard block
 block discarded – undo
210 210
 		}
211 211
 		unset( $defaults );
212 212
 
213
-        if ( ! isset( $values['form_key'] ) ) {
213
+		if ( ! isset( $values['form_key'] ) ) {
214 214
 			$values['form_key'] = ( $post_values && isset( $post_values['form_key'] ) ) ? $post_values['form_key'] : FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_forms', 'form_key' );
215
-        }
215
+		}
216 216
 
217 217
 		$values = self::fill_default_opts( $values, false, $post_values );
218 218
 		$values['custom_style'] = FrmAppHelper::custom_style_value( $post_values );
219 219
 
220
-        return apply_filters('frm_setup_new_form_vars', $values);
221
-    }
220
+		return apply_filters('frm_setup_new_form_vars', $values);
221
+	}
222 222
 
223
-    /**
224
-     * Used when editing a form
225
-     */
226
-    public static function setup_edit_vars( $values, $record, $post_values = array() ) {
223
+	/**
224
+	 * Used when editing a form
225
+	 */
226
+	public static function setup_edit_vars( $values, $record, $post_values = array() ) {
227 227
 		if ( empty( $post_values ) ) {
228 228
 			$post_values = stripslashes_deep( $_POST );
229 229
 		}
230 230
 
231
-        $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
232
-        $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
233
-        $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
234
-        $values['status'] = $record->status;
231
+		$values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
232
+		$values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
233
+		$values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
234
+		$values['status'] = $record->status;
235 235
 
236 236
 		$values = self::fill_default_opts( $values, $record, $post_values );
237 237
 
238 238
 		return apply_filters( 'frm_setup_edit_form_vars', $values );
239
-    }
239
+	}
240 240
 
241 241
 	public static function fill_default_opts( $values, $record, $post_values ) {
242 242
 
243
-        $defaults = self::get_default_opts();
243
+		$defaults = self::get_default_opts();
244 244
 		foreach ( $defaults as $var => $default ) {
245 245
 			if ( is_array( $default ) ) {
246
-                if ( ! isset( $values[ $var ] ) ) {
246
+				if ( ! isset( $values[ $var ] ) ) {
247 247
 					$values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
248
-                }
248
+				}
249 249
 
250
-                foreach ( $default as $k => $v ) {
250
+				foreach ( $default as $k => $v ) {
251 251
 					$values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v );
252 252
 
253
-                    if ( is_array( $v ) ) {
254
-                        foreach ( $v as $k1 => $v1 ) {
253
+					if ( is_array( $v ) ) {
254
+						foreach ( $v as $k1 => $v1 ) {
255 255
 							$values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
256
-                            unset( $k1, $v1 );
257
-                        }
258
-                    }
256
+							unset( $k1, $v1 );
257
+						}
258
+					}
259 259
 
260 260
 					unset( $k, $v );
261
-                }
262
-            } else {
261
+				}
262
+			} else {
263 263
 				$values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
264
-            }
264
+			}
265 265
 
266 266
 			unset( $var, $default );
267
-        }
267
+		}
268 268
 
269
-        return $values;
270
-    }
269
+		return $values;
270
+	}
271 271
 
272 272
 	public static function get_default_opts() {
273 273
 		$frm_settings = FrmAppHelper::get_settings();
@@ -302,13 +302,13 @@  discard block
 block discarded – undo
302 302
 		}
303 303
 	}
304 304
 
305
-    /**
306
-     * @param string $loc
307
-     */
305
+	/**
306
+	 * @param string $loc
307
+	 */
308 308
 	public static function get_default_html( $loc ) {
309 309
 		if ( $loc == 'submit' ) {
310
-            $draft_link = self::get_draft_link();
311
-            $default_html = <<<SUBMIT_HTML
310
+			$draft_link = self::get_draft_link();
311
+			$default_html = <<<SUBMIT_HTML
312 312
 <div class="frm_submit">
313 313
 [if back_button]<button type="submit" name="frm_prev_page" formnovalidate="formnovalidate" class="frm_prev_page" [back_hook]>[back_label]</button>[/if back_button]
314 314
 <button class="frm_button_submit" type="submit"  [button_action]>[button_label]</button>
@@ -316,22 +316,22 @@  discard block
 block discarded – undo
316 316
 </div>
317 317
 SUBMIT_HTML;
318 318
 		} else if ( $loc == 'before' ) {
319
-            $default_html = <<<BEFORE_HTML
319
+			$default_html = <<<BEFORE_HTML
320 320
 <legend class="frm_screen_reader">[form_name]</legend>
321 321
 [if form_name]<h3 class="frm_form_title">[form_name]</h3>[/if form_name]
322 322
 [if form_description]<div class="frm_description">[form_description]</div>[/if form_description]
323 323
 BEFORE_HTML;
324 324
 		} else {
325
-            $default_html = '';
326
-        }
325
+			$default_html = '';
326
+		}
327 327
 
328
-        return $default_html;
329
-    }
328
+		return $default_html;
329
+	}
330 330
 
331
-    public static function get_draft_link() {
332
-        $link = '[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
333
-        return $link;
334
-    }
331
+	public static function get_draft_link() {
332
+		$link = '[if save_draft]<a href="#" tabindex="0" class="frm_save_draft" [draft_hook]>[draft_label]</a>[/if save_draft]';
333
+		return $link;
334
+	}
335 335
 
336 336
 	public static function get_custom_submit( $html, $form, $submit, $form_action, $values ) {
337 337
 		$button = self::replace_shortcodes( $html, $form, $submit, $form_action, $values );
@@ -358,13 +358,13 @@  discard block
 block discarded – undo
358 358
 		echo $button_parts[1];
359 359
 	}
360 360
 
361
-    /**
362
-     * Automatically add end section fields if they don't exist (2.0 migration)
363
-     * @since 2.0
364
-     *
365
-     * @param boolean $reset_fields
366
-     */
367
-    public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
361
+	/**
362
+	 * Automatically add end section fields if they don't exist (2.0 migration)
363
+	 * @since 2.0
364
+	 *
365
+	 * @param boolean $reset_fields
366
+	 */
367
+	public static function auto_add_end_section_fields( $form, $fields, &$reset_fields ) {
368 368
 		if ( empty( $fields ) ) {
369 369
 			return;
370 370
 		}
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 		$prev_order = false;
375 375
 		$add_order = 0;
376 376
 		$last_field = false;
377
-        foreach ( $fields as $field ) {
377
+		foreach ( $fields as $field ) {
378 378
 			if ( $prev_order === $field->field_order ) {
379 379
 				$add_order++;
380 380
 			}
@@ -385,48 +385,48 @@  discard block
 block discarded – undo
385 385
 				FrmField::update( $field->id, array( 'field_order' => $field->field_order ) );
386 386
 			}
387 387
 
388
-            switch ( $field->type ) {
389
-                case 'divider':
390
-                    // create an end section if open
388
+			switch ( $field->type ) {
389
+				case 'divider':
390
+					// create an end section if open
391 391
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
392 392
 
393
-                    // mark it open for the next end section
394
-                    $open = true;
393
+					// mark it open for the next end section
394
+					$open = true;
395 395
 					break;
396
-                case 'break':
396
+				case 'break':
397 397
 					self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $field, 'move' );
398 398
 					break;
399
-                case 'end_divider':
400
-                    if ( ! $open ) {
401
-                        // the section isn't open, so this is an extra field that needs to be removed
402
-                        FrmField::destroy( $field->id );
403
-                        $reset_fields = true;
404
-                    }
405
-
406
-                    // There is already an end section here, so there is no need to create one
407
-                    $open = false;
408
-            }
399
+				case 'end_divider':
400
+					if ( ! $open ) {
401
+						// the section isn't open, so this is an extra field that needs to be removed
402
+						FrmField::destroy( $field->id );
403
+						$reset_fields = true;
404
+					}
405
+
406
+					// There is already an end section here, so there is no need to create one
407
+					$open = false;
408
+			}
409 409
 			$prev_order = $field->field_order;
410 410
 
411 411
 			$last_field = $field;
412 412
 			unset( $field );
413
-        }
413
+		}
414 414
 
415 415
 		self::maybe_create_end_section( $open, $reset_fields, $add_order, $end_section_values, $last_field );
416
-    }
416
+	}
417 417
 
418 418
 	/**
419 419
 	 * Create end section field if it doesn't exist. This is for migration from < 2.0
420 420
 	 * Fix any ordering that may be messed up
421 421
 	 */
422 422
 	public static function maybe_create_end_section( &$open, &$reset_fields, &$add_order, $end_section_values, $field, $move = 'no' ) {
423
-        if ( ! $open ) {
424
-            return;
425
-        }
423
+		if ( ! $open ) {
424
+			return;
425
+		}
426 426
 
427 427
 		$end_section_values['field_order'] = $field->field_order + 1;
428 428
 
429
-        FrmField::create( $end_section_values );
429
+		FrmField::create( $end_section_values );
430 430
 
431 431
 		if ( $move == 'move' ) {
432 432
 			// bump the order of current field unless we're at the end of the form
@@ -434,9 +434,9 @@  discard block
 block discarded – undo
434 434
 		}
435 435
 
436 436
 		$add_order += 2;
437
-        $open = false;
438
-        $reset_fields = true;
439
-    }
437
+		$open = false;
438
+		$reset_fields = true;
439
+	}
440 440
 
441 441
 	public static function replace_shortcodes( $html, $form, $title = false, $description = false, $values = array() ) {
442 442
 		$codes = array(
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 			}
457 457
 
458 458
 			FrmShortcodeHelper::remove_inline_conditions( ( FrmAppHelper::is_true( $show ) && $replace_with != '' ), $code, $replace_with, $html );
459
-        }
459
+		}
460 460
 
461 461
 		//replace [form_key]
462 462
 		$html = str_replace( '[form_key]', $form->form_key, $html );
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 			$submit_label = apply_filters( 'frm_submit_button', $title, $form );
470 470
 			$submit_label = esc_attr( do_shortcode( $submit_label ) );
471 471
 			$html = str_replace( '[button_label]', $submit_label, $html );
472
-        }
472
+		}
473 473
 
474 474
 		$html = apply_filters( 'frm_form_replace_shortcodes', $html, $form, $values );
475 475
 
@@ -485,17 +485,17 @@  discard block
 block discarded – undo
485 485
 			$html = do_shortcode( $html );
486 486
 		}
487 487
 
488
-        return $html;
489
-    }
488
+		return $html;
489
+	}
490 490
 
491 491
 	public static function submit_button_label( $submit ) {
492 492
 		if ( ! $submit || empty( $submit ) ) {
493
-            $frm_settings = FrmAppHelper::get_settings();
494
-            $submit = $frm_settings->submit_value;
495
-        }
493
+			$frm_settings = FrmAppHelper::get_settings();
494
+			$submit = $frm_settings->submit_value;
495
+		}
496 496
 
497
-        return $submit;
498
-    }
497
+		return $submit;
498
+	}
499 499
 
500 500
 	/**
501 501
 	 * If the Formidable styling isn't being loaded,
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 			}
524 524
 		}
525 525
 
526
-        //If submit button needs to be inline or centered
526
+		//If submit button needs to be inline or centered
527 527
 		if ( is_object( $form ) ) {
528 528
 			$form = $form->options;
529 529
 		}
@@ -537,10 +537,10 @@  discard block
 block discarded – undo
537 537
 			$class .= ' frm_center_submit';
538 538
 		}
539 539
 
540
-        $class = apply_filters('frm_add_form_style_class', $class, $style);
540
+		$class = apply_filters('frm_add_form_style_class', $class, $style);
541 541
 
542
-        return $class;
543
-    }
542
+		return $class;
543
+	}
544 544
 
545 545
 	/**
546 546
 	 * Returns appropriate class if form has top labels
@@ -591,12 +591,12 @@  discard block
 block discarded – undo
591 591
 		return in_array( $label_position, array( 'top', 'inside', 'hidden' ) );
592 592
 	}
593 593
 
594
-    /**
595
-     * @param string|boolean $form
596
-     *
597
-     * @return string
598
-     */
599
-    public static function get_form_style( $form ) {
594
+	/**
595
+	 * @param string|boolean $form
596
+	 *
597
+	 * @return string
598
+	 */
599
+	public static function get_form_style( $form ) {
600 600
 		$style = 1;
601 601
 		if ( empty( $form ) || 'default' == 'form' ) {
602 602
 			return $style;
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		$style = ( $form && is_object( $form ) && isset( $form->options['custom_style'] ) ) ? $form->options['custom_style'] : $style;
617 617
 
618 618
 		return $style;
619
-    }
619
+	}
620 620
 
621 621
 	/**
622 622
 	 * Display the validation error messages when an entry is submitted
@@ -685,8 +685,8 @@  discard block
 block discarded – undo
685 685
 	}
686 686
 
687 687
 	public static function get_scroll_js( $form_id ) {
688
-        echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>';
689
-    }
688
+		echo '<script type="text/javascript">document.addEventListener(\'DOMContentLoaded\',function(){frmFrontForm.scrollMsg(' . (int) $form_id . ');})</script>';
689
+	}
690 690
 
691 691
 	/**
692 692
 	 * @since 3.0
@@ -740,21 +740,21 @@  discard block
 block discarded – undo
740 740
 	}
741 741
 
742 742
 	public static function edit_form_link( $form_id ) {
743
-        if ( is_object($form_id) ) {
744
-            $form = $form_id;
745
-            $name = $form->name;
746
-            $form_id = $form->id;
747
-        } else {
748
-            $name = FrmForm::getName($form_id);
749
-        }
750
-
751
-        if ( $form_id ) {
743
+		if ( is_object($form_id) ) {
744
+			$form = $form_id;
745
+			$name = $form->name;
746
+			$form_id = $form->id;
747
+		} else {
748
+			$name = FrmForm::getName($form_id);
749
+		}
750
+
751
+		if ( $form_id ) {
752 752
 			$val = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ) ) . '">' . ( '' == $name ? __( '(no title)' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>';
753
-	    } else {
754
-	        $val = '';
755
-	    }
753
+		} else {
754
+			$val = '';
755
+		}
756 756
 
757
-	    return $val;
757
+		return $val;
758 758
 	}
759 759
 
760 760
 	public static function delete_trash_link( $id, $status, $length = 'label' ) {
@@ -935,18 +935,18 @@  discard block
 block discarded – undo
935 935
 	}
936 936
 
937 937
 	public static function status_nice_name( $status ) {
938
-        $nice_names = array(
939
-            'draft'     => __( 'Draft', 'formidable' ),
940
-            'trash'     => __( 'Trash', 'formidable' ),
941
-            'publish'   => __( 'Published', 'formidable' ),
942
-        );
938
+		$nice_names = array(
939
+			'draft'     => __( 'Draft', 'formidable' ),
940
+			'trash'     => __( 'Trash', 'formidable' ),
941
+			'publish'   => __( 'Published', 'formidable' ),
942
+		);
943 943
 
944 944
 		if ( ! in_array( $status, array_keys( $nice_names ) ) ) {
945
-            $status = 'publish';
946
-        }
945
+			$status = 'publish';
946
+		}
947 947
 
948 948
 		$name = $nice_names[ $status ];
949 949
 
950
-        return $name;
951
-    }
950
+		return $name;
951
+	}
952 952
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 	public static function get_direct_link( $key, $form = false ) {
16 16
 		$target_url = esc_url( admin_url( 'admin-ajax.php?action=frm_forms_preview&form=' . $key ) );
17
-        $target_url = apply_filters('frm_direct_link', $target_url, $key, $form);
17
+        $target_url = apply_filters( 'frm_direct_link', $target_url, $key, $form );
18 18
 
19 19
         return $target_url;
20 20
     }
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 			$query['id !'] = $args['exclude'];
40 40
         }
41 41
 
42
-        $where = apply_filters('frm_forms_dropdown', $query, $field_name);
42
+        $where = apply_filters( 'frm_forms_dropdown', $query, $field_name );
43 43
 		$forms = FrmForm::get_published_forms( $where, 999, $args['inc_children'] );
44 44
 		$add_html = array();
45 45
 		self::add_html_attr( $args['onchange'], 'onchange', $add_html );
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public static function add_html_attr( $class, $param, &$add_html ) {
70 70
 		if ( ! empty( $class ) ) {
71
-			$add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"';
71
+			$add_html[$param] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"';
72 72
 		}
73 73
 	}
74 74
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		);
83 83
 		if ( isset( $_GET['id'] ) && ! isset( $_GET['form'] ) ) {
84 84
 			unset( $args['form'] );
85
-		} else if ( isset( $_GET['form']) && ! isset( $_GET['id'] ) ) {
85
+		} else if ( isset( $_GET['form'] ) && ! isset( $_GET['id'] ) ) {
86 86
 			unset( $args['id'] );
87 87
         }
88 88
 
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 		if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $frm_action, array( 'edit', 'show', 'destroy_all' ) ) ) {
91 91
             $args['frm_action'] = 'list';
92 92
             $args['form'] = 0;
93
-		} else if ( FrmAppHelper::is_admin_page('formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
93
+		} else if ( FrmAppHelper::is_admin_page( 'formidable' ) && in_array( $frm_action, array( 'new', 'duplicate' ) ) ) {
94 94
             $args['frm_action'] = 'edit';
95 95
 		} else if ( isset( $_GET['post'] ) ) {
96 96
             $args['form'] = 0;
97
-            $base = admin_url('edit.php?post_type=frm_display');
97
+            $base = admin_url( 'edit.php?post_type=frm_display' );
98 98
         }
99 99
 
100 100
         ?>
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
             $post_values = $values;
180 180
         } else {
181 181
             $values = array();
182
-            $post_values = isset($_POST) ? $_POST : array();
182
+            $post_values = isset( $_POST ) ? $_POST : array();
183 183
         }
184 184
 
185 185
 		$defaults = array(
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
 			'description' => '',
188 188
 		);
189 189
 		foreach ( $defaults as $var => $default ) {
190
-			if ( ! isset( $values[ $var ] ) ) {
191
-				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
190
+			if ( ! isset( $values[$var] ) ) {
191
+				$values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
192 192
             }
193 193
         }
194 194
 
195
-        $values['description'] = FrmAppHelper::use_wpautop($values['description']);
195
+        $values['description'] = FrmAppHelper::use_wpautop( $values['description'] );
196 196
 
197 197
 		$defaults = array(
198 198
 			'form_id'        => '',
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 			'parent_form_id' => 0,
205 205
 		);
206 206
 		foreach ( $defaults as $var => $default ) {
207
-			if ( ! isset( $values[ $var ] ) ) {
208
-				$values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
207
+			if ( ! isset( $values[$var] ) ) {
208
+				$values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' );
209 209
 			}
210 210
 		}
211 211
 		unset( $defaults );
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		$values = self::fill_default_opts( $values, false, $post_values );
218 218
 		$values['custom_style'] = FrmAppHelper::custom_style_value( $post_values );
219 219
 
220
-        return apply_filters('frm_setup_new_form_vars', $values);
220
+        return apply_filters( 'frm_setup_new_form_vars', $values );
221 221
     }
222 222
 
223 223
     /**
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 			$post_values = stripslashes_deep( $_POST );
229 229
 		}
230 230
 
231
-        $values['form_key'] = isset($post_values['form_key']) ? $post_values['form_key'] : $record->form_key;
232
-        $values['default_template'] = isset($post_values['default_template']) ? $post_values['default_template'] : $record->default_template;
233
-        $values['is_template'] = isset($post_values['is_template']) ? $post_values['is_template'] : $record->is_template;
231
+        $values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key;
232
+        $values['default_template'] = isset( $post_values['default_template'] ) ? $post_values['default_template'] : $record->default_template;
233
+        $values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template;
234 234
         $values['status'] = $record->status;
235 235
 
236 236
 		$values = self::fill_default_opts( $values, $record, $post_values );
@@ -243,16 +243,16 @@  discard block
 block discarded – undo
243 243
         $defaults = self::get_default_opts();
244 244
 		foreach ( $defaults as $var => $default ) {
245 245
 			if ( is_array( $default ) ) {
246
-                if ( ! isset( $values[ $var ] ) ) {
247
-					$values[ $var ] = ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : array();
246
+                if ( ! isset( $values[$var] ) ) {
247
+					$values[$var] = ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : array();
248 248
                 }
249 249
 
250 250
                 foreach ( $default as $k => $v ) {
251
-					$values[ $var ][ $k ] = ( $post_values && isset( $post_values[ $var ][ $k ] ) ) ? $post_values[ $var ][ $k ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ) ? $record->options[ $var ][ $k ] : $v );
251
+					$values[$var][$k] = ( $post_values && isset( $post_values[$var][$k] ) ) ? $post_values[$var][$k] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) ) ? $record->options[$var][$k] : $v );
252 252
 
253 253
                     if ( is_array( $v ) ) {
254 254
                         foreach ( $v as $k1 => $v1 ) {
255
-							$values[ $var ][ $k ][ $k1 ] = ( $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ) ? $post_values[ $var ][ $k ][ $k1 ] : ( ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 );
255
+							$values[$var][$k][$k1] = ( $post_values && isset( $post_values[$var][$k][$k1] ) ) ? $post_values[$var][$k][$k1] : ( ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) && isset( $record->options[$var][$k][$k1] ) ) ? $record->options[$var][$k][$k1] : $v1 );
256 256
                             unset( $k1, $v1 );
257 257
                         }
258 258
                     }
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 					unset( $k, $v );
261 261
                 }
262 262
             } else {
263
-				$values[ $var ] = ( $post_values && isset( $post_values['options'][ $var ] ) ) ? $post_values['options'][ $var ] : ( ( $record && isset( $record->options[ $var ] ) ) ? $record->options[ $var ] : $default );
263
+				$values[$var] = ( $post_values && isset( $post_values['options'][$var] ) ) ? $post_values['options'][$var] : ( ( $record && isset( $record->options[$var] ) ) ? $record->options[$var] : $default );
264 264
             }
265 265
 
266 266
 			unset( $var, $default );
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	public static function fill_form_options( &$options, $values ) {
298 298
 		$defaults = self::get_default_opts();
299 299
 		foreach ( $defaults as $var => $default ) {
300
-			$options[ $var ] = isset( $values['options'][ $var ] ) ? $values['options'][ $var ] : $default;
300
+			$options[$var] = isset( $values['options'][$var] ) ? $values['options'][$var] : $default;
301 301
 			unset( $var, $default );
302 302
 		}
303 303
 	}
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 		$last_field = false;
377 377
         foreach ( $fields as $field ) {
378 378
 			if ( $prev_order === $field->field_order ) {
379
-				$add_order++;
379
+				$add_order ++;
380 380
 			}
381 381
 
382 382
 			if ( $add_order ) {
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 			$class .= ' frm_center_submit';
538 538
 		}
539 539
 
540
-        $class = apply_filters('frm_add_form_style_class', $class, $style);
540
+        $class = apply_filters( 'frm_add_form_style_class', $class, $style );
541 541
 
542 542
         return $class;
543 543
     }
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 	 * @since 3.0
693 693
 	 */
694 694
 	public static function actions_dropdown( $atts ) {
695
-		if ( FrmAppHelper::is_admin_page('formidable' ) ) {
695
+		if ( FrmAppHelper::is_admin_page( 'formidable' ) ) {
696 696
 			$status = $atts['status'];
697 697
 			$form_id = isset( $atts['id'] ) ? $atts['id'] : FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
698 698
 			$trash_link = self::delete_trash_info( $form_id, $status );
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 		if ( 'trash' == $form->status ) {
715 715
 			$actions['restore'] = $trash_links['restore'];
716 716
 
717
-			if ( current_user_can('frm_delete_forms') ) {
717
+			if ( current_user_can( 'frm_delete_forms' ) ) {
718 718
 				$actions['trash'] = $trash_links['delete'];
719 719
 			}
720 720
 		} elseif ( current_user_can( 'frm_edit_forms' ) ) {
@@ -740,12 +740,12 @@  discard block
 block discarded – undo
740 740
 	}
741 741
 
742 742
 	public static function edit_form_link( $form_id ) {
743
-        if ( is_object($form_id) ) {
743
+        if ( is_object( $form_id ) ) {
744 744
             $form = $form_id;
745 745
             $name = $form->name;
746 746
             $form_id = $form->id;
747 747
         } else {
748
-            $name = FrmForm::getName($form_id);
748
+            $name = FrmForm::getName( $form_id );
749 749
         }
750 750
 
751 751
         if ( $form_id ) {
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 			} elseif ( isset( $link_details['confirm'] ) ) {
778 778
 				$link .= ' onclick="return confirm(\'' . esc_attr( $link_details['confirm'] ) . '\')"';
779 779
 			}
780
-			$label = ( isset( $link_details[ $length ] ) ? $link_details[ $length ] : $link_details['label'] );
780
+			$label = ( isset( $link_details[$length] ) ? $link_details[$length] : $link_details['label'] );
781 781
 			$link .= '>' . $label . '</a>';
782 782
 		}
783 783
 		return $link;
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 
792 792
 		if ( 'trash' == $status ) {
793 793
 			$info = $labels['restore'];
794
-		} elseif ( current_user_can('frm_delete_forms') ) {
794
+		} elseif ( current_user_can( 'frm_delete_forms' ) ) {
795 795
 			if ( EMPTY_TRASH_DAYS ) {
796 796
 				$info = $labels['trash'];
797 797
 			} else {
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
             $status = 'publish';
946 946
         }
947 947
 
948
-		$name = $nice_names[ $status ];
948
+		$name = $nice_names[$status];
949 949
 
950 950
         return $name;
951 951
     }
Please login to merge, or discard this patch.
classes/helpers/FrmEntriesListHelper.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -6,10 +6,10 @@  discard block
 block discarded – undo
6 6
 	protected $field;
7 7
 
8 8
 	public function prepare_items() {
9
-        global $per_page;
9
+		global $per_page;
10 10
 
11 11
 		$per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
12
-        $form_id = $this->params['form'];
12
+		$form_id = $this->params['form'];
13 13
 
14 14
 		$s_query = array();
15 15
 
@@ -76,16 +76,16 @@  discard block
 block discarded – undo
76 76
 		) );
77 77
 		if ( ! empty( $s ) ) {
78 78
 			esc_html_e( 'No Entries Found', 'formidable' );
79
-            return;
80
-        }
79
+			return;
80
+		}
81 81
 
82 82
 		$form_id = $this->params['form'];
83 83
 		$form = $this->params['form'];
84 84
 
85
-        if ( $form_id ) {
86
-            $form = FrmForm::getOne($form_id);
87
-        }
88
-        $colspan = $this->get_column_count();
85
+		if ( $form_id ) {
86
+			$form = FrmForm::getOne($form_id);
87
+		}
88
+		$colspan = $this->get_column_count();
89 89
 
90 90
 		include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' );
91 91
 	}
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 
107 107
 	/**
108
-	* Gets the name of the primary column in the Entries screen
109
-	*
110
-	* @since 2.0.14
111
-	*
112
-	* @return string $primary_column
113
-	*/
108
+	 * Gets the name of the primary column in the Entries screen
109
+	 *
110
+	 * @since 2.0.14
111
+	 *
112
+	 * @return string $primary_column
113
+	 */
114 114
 	protected function get_primary_column_name() {
115 115
 		$columns = get_column_headers( $this->screen );
116 116
 		$hidden = get_hidden_columns( $this->screen );
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
 		$this->get_actions( $actions, $item, $view_link );
136 136
 
137
-        $action_links = $this->row_actions( $actions );
137
+		$action_links = $this->row_actions( $actions );
138 138
 
139 139
 		// Set up the checkbox ( because the user is editable, otherwise its empty )
140 140
 		$checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		$r = "<tr id='item-action-{$item->id}'$style>";
143 143
 
144 144
 		list( $columns, $hidden, , $primary ) = $this->get_column_info();
145
-        $action_col = false;
145
+		$action_col = false;
146 146
 
147 147
 		foreach ( $columns as $column_name => $column_display_name ) {
148 148
 			$class = $column_name . ' column-' . $column_name;
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 			if ( in_array( $column_name, $hidden ) ) {
155 155
 				$class .= ' frm_hidden';
156 156
 			} else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) {
157
-			    $action_col = $column_name;
158
-            }
157
+				$action_col = $column_name;
158
+			}
159 159
 
160 160
 			$attributes = 'class="' . esc_attr( $class ) . '"';
161 161
 			unset($class);
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 					$val = $this->column_value( $item );
174 174
 				}
175 175
 
176
-			    $r .= "<td $attributes>";
176
+				$r .= "<td $attributes>";
177 177
 				if ( $column_name == $action_col ) {
178 178
 					$edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id;
179 179
 					$r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
180
-			        $r .= $action_links;
180
+					$r .= $action_links;
181 181
 				} else {
182
-			        $r .= $val;
183
-			    }
184
-			    $r .= '</td>';
182
+					$r .= $val;
183
+				}
184
+				$r .= '</td>';
185 185
 			}
186 186
 			unset($val);
187 187
 		}
@@ -234,19 +234,19 @@  discard block
 block discarded – undo
234 234
 		return $val;
235 235
 	}
236 236
 
237
-    /**
238
-     * @param string $view_link
239
-     */
240
-    private function get_actions( &$actions, $item, $view_link ) {
237
+	/**
238
+	 * @param string $view_link
239
+	 */
240
+	private function get_actions( &$actions, $item, $view_link ) {
241 241
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
242 242
 
243
-        if ( current_user_can('frm_delete_entries') ) {
243
+		if ( current_user_can('frm_delete_entries') ) {
244 244
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
245 245
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Are you sure?', 'formidable' ) . '">' . __( 'Delete' ) . '</a>';
246
-	    }
246
+		}
247 247
 
248
-        $actions = apply_filters('frm_row_actions', $actions, $item);
249
-    }
248
+		$actions = apply_filters('frm_row_actions', $actions, $item);
249
+	}
250 250
 
251 251
 	private function get_column_value( $item, &$val ) {
252 252
 		$col_name = $this->column_name;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		$form = $this->params['form'];
84 84
 
85 85
         if ( $form_id ) {
86
-            $form = FrmForm::getOne($form_id);
86
+            $form = FrmForm::getOne( $form_id );
87 87
         }
88 88
         $colspan = $this->get_column_count();
89 89
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 
142 142
 		$r = "<tr id='item-action-{$item->id}'$style>";
143 143
 
144
-		list( $columns, $hidden, , $primary ) = $this->get_column_info();
144
+		list( $columns, $hidden,, $primary ) = $this->get_column_info();
145 145
         $action_col = false;
146 146
 
147 147
 		foreach ( $columns as $column_name => $column_display_name ) {
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             }
159 159
 
160 160
 			$attributes = 'class="' . esc_attr( $class ) . '"';
161
-			unset($class);
161
+			unset( $class );
162 162
 			$attributes .= ' data-colname="' . $column_display_name . '"';
163 163
 
164 164
 			$form_id = $this->params['form'] ? $this->params['form'] : 0;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			    }
184 184
 			    $r .= '</td>';
185 185
 			}
186
-			unset($val);
186
+			unset( $val );
187 187
 		}
188 188
 		$r .= '</tr>';
189 189
 
@@ -240,12 +240,12 @@  discard block
 block discarded – undo
240 240
     private function get_actions( &$actions, $item, $view_link ) {
241 241
 		$actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
242 242
 
243
-        if ( current_user_can('frm_delete_entries') ) {
243
+        if ( current_user_can( 'frm_delete_entries' ) ) {
244 244
 			$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
245 245
 			$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Are you sure?', 'formidable' ) . '">' . __( 'Delete' ) . '</a>';
246 246
 	    }
247 247
 
248
-        $actions = apply_filters('frm_row_actions', $actions, $item);
248
+        $actions = apply_filters( 'frm_row_actions', $actions, $item );
249 249
     }
250 250
 
251 251
 	private function get_column_value( $item, &$val ) {
Please login to merge, or discard this patch.
classes/helpers/FrmFieldsHelper.php 2 patches
Indentation   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
 			}
30 30
 		}
31 31
 
32
-        return $values;
33
-    }
32
+		return $values;
33
+	}
34 34
 
35 35
 	public static function get_html_id( $field, $plus = '' ) {
36 36
 		return apply_filters( 'frm_field_html_id', 'field_' . $field['field_key'] . $plus, $field );
37
-    }
37
+	}
38 38
 
39
-    public static function setup_edit_vars( $field, $doing_ajax = false ) {
39
+	public static function setup_edit_vars( $field, $doing_ajax = false ) {
40 40
 		$values = self::field_object_to_array( $field );
41 41
 		return apply_filters( 'frm_setup_edit_field_vars', $values, array( 'doing_ajax' => $doing_ajax ) );
42
-    }
42
+	}
43 43
 
44 44
 	public static function field_object_to_array( $field ) {
45 45
 		$values = (array) $field;
@@ -239,18 +239,18 @@  discard block
 block discarded – undo
239 239
 		return $field_type->get_new_field_defaults();
240 240
 	}
241 241
 
242
-    public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
243
-        global $wpdb;
242
+	public static function fill_field( &$values, $field, $form_id, $new_key = '' ) {
243
+		global $wpdb;
244 244
 
245 245
 		$values['field_key'] = FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_fields', 'field_key' );
246
-        $values['form_id'] = $form_id;
246
+		$values['form_id'] = $form_id;
247 247
 		$values['options'] = maybe_serialize( $field->options );
248 248
 		$values['default_value'] = maybe_serialize( $field->default_value );
249 249
 
250
-        foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
251
-            $values[ $col ] = $field->{$col};
252
-        }
253
-    }
250
+		foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
251
+			$values[ $col ] = $field->{$col};
252
+		}
253
+	}
254 254
 
255 255
 	/**
256 256
 	 * @since 2.0
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
 	 */
406 406
 	public static function get_shortcode_tag( $shortcodes, $short_key, $args ) {
407 407
 		_deprecated_function( __FUNCTION__, '3.0', 'FrmShortcodeHelper::get_shortcode_tag' );
408
-        return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args );
409
-    }
408
+		return FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, $args );
409
+	}
410 410
 
411 411
 	public static function get_checkbox_id( $field, $opt_key ) {
412 412
 		$id = $field['id'];
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 */
423 423
 	public static function display_recaptcha( $field ) {
424 424
 		_deprecated_function( __FUNCTION__, '3.0', 'FrmFieldCaptcha::field_input' );
425
-    }
425
+	}
426 426
 
427 427
 	public static function show_single_option( $field ) {
428 428
 		if ( ! is_array( $field['options'] ) ) {
@@ -433,26 +433,26 @@  discard block
 block discarded – undo
433 433
 		$html_id = isset( $field['html_id'] ) ? $field['html_id'] : self::get_html_id( $field );
434 434
 
435 435
 		foreach ( $field['options'] as $opt_key => $opt ) {
436
-		    $field_val = self::get_value_from_array( $opt, $opt_key, $field );
437
-		    $opt = self::get_label_from_array( $opt, $opt_key, $field );
436
+			$field_val = self::get_value_from_array( $opt, $opt_key, $field );
437
+			$opt = self::get_label_from_array( $opt, $opt_key, $field );
438 438
 
439 439
 			// Get string for Other text field, if needed
440 440
 			$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
441 441
 
442 442
 			$checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array($field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"' : '';
443 443
 
444
-		    // If this is an "Other" option, get the HTML for it
444
+			// If this is an "Other" option, get the HTML for it
445 445
 			if ( self::is_other_opt( $opt_key ) ) {
446 446
 				if ( FrmAppHelper::pro_is_installed() ) {
447 447
 					require( FrmProAppHelper::plugin_path() . '/classes/views/frmpro-fields/other-option.php' );
448 448
 				}
449
-		    } else {
449
+			} else {
450 450
 				require( FrmAppHelper::plugin_path() . '/classes/views/frm-fields/single-option.php' );
451
-		    }
451
+			}
452 452
 
453 453
 			unset( $checked, $other_val );
454 454
 		}
455
-    }
455
+	}
456 456
 
457 457
 	public static function get_value_from_array( $opt, $opt_key, $field ) {
458 458
 		$opt = apply_filters( 'frm_field_value_saved', $opt, $opt_key, $field );
@@ -470,29 +470,29 @@  discard block
 block discarded – undo
470 470
 	 * @return string
471 471
 	 */
472 472
 	public static function get_term_link( $tax_id ) {
473
-        $tax = get_taxonomy($tax_id);
474
-        if ( ! $tax ) {
475
-            return '';
476
-        }
473
+		$tax = get_taxonomy($tax_id);
474
+		if ( ! $tax ) {
475
+			return '';
476
+		}
477 477
 
478
-        $link = sprintf(
479
-            __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
478
+		$link = sprintf(
479
+			__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
480 480
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
481
-        );
482
-        unset($tax);
481
+		);
482
+		unset($tax);
483 483
 
484
-        return $link;
485
-    }
484
+		return $link;
485
+	}
486 486
 
487 487
 	public static function value_meets_condition( $observed_value, $cond, $hide_opt ) {
488 488
 		$hide_opt = self::get_value_for_comparision( $hide_opt );
489 489
 		$observed_value = self::get_value_for_comparision( $observed_value );
490 490
 
491
-        if ( is_array($observed_value) ) {
492
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
493
-        }
491
+		if ( is_array($observed_value) ) {
492
+			return self::array_value_condition($observed_value, $cond, $hide_opt);
493
+		}
494 494
 
495
-        $m = false;
495
+		$m = false;
496 496
 		if ( $cond == '==' ) {
497 497
 			$m = $observed_value == $hide_opt;
498 498
 		} elseif ( $cond == '!=' ) {
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
 				$m = ( $m === false ) ? false : true;
514 514
 			}
515 515
 		}
516
-        return $m;
517
-    }
516
+		return $m;
517
+	}
518 518
 
519 519
 	/**
520 520
 	 * Trim and sanitize the values
@@ -530,14 +530,14 @@  discard block
 block discarded – undo
530 530
 	}
531 531
 
532 532
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
533
-        $m = false;
534
-        if ( $cond == '==' ) {
535
-            if ( is_array($hide_opt) ) {
536
-                $m = array_intersect($hide_opt, $observed_value);
537
-                $m = empty($m) ? false : true;
538
-            } else {
539
-                $m = in_array($hide_opt, $observed_value);
540
-            }
533
+		$m = false;
534
+		if ( $cond == '==' ) {
535
+			if ( is_array($hide_opt) ) {
536
+				$m = array_intersect($hide_opt, $observed_value);
537
+				$m = empty($m) ? false : true;
538
+			} else {
539
+				$m = in_array($hide_opt, $observed_value);
540
+			}
541 541
 		} elseif ( $cond == '!=' ) {
542 542
 			$m = ! in_array( $hide_opt, $observed_value );
543 543
 		} elseif ( $cond == '>' ) {
@@ -555,62 +555,62 @@  discard block
 block discarded – undo
555 555
 				}
556 556
 			}
557 557
 
558
-            if ( $cond == 'not LIKE' ) {
559
-                $m = ( $m === false ) ? true : false;
560
-            }
561
-        }
558
+			if ( $cond == 'not LIKE' ) {
559
+				$m = ( $m === false ) ? true : false;
560
+			}
561
+		}
562 562
 
563
-        return $m;
564
-    }
563
+		return $m;
564
+	}
565 565
 
566
-    /**
567
-     * Replace a few basic shortcodes and field ids
568
-     * @since 2.0
569
-     * @return string
570
-     */
566
+	/**
567
+	 * Replace a few basic shortcodes and field ids
568
+	 * @since 2.0
569
+	 * @return string
570
+	 */
571 571
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
572 572
 		if ( strpos( $value, '[sitename]') !== false ) {
573
-            $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
574
-            $value = str_replace('[sitename]', $new_value, $value);
575
-        }
573
+			$new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
574
+			$value = str_replace('[sitename]', $new_value, $value);
575
+		}
576 576
 
577
-        $value = apply_filters('frm_content', $value, $form, $entry);
578
-        $value = do_shortcode($value);
577
+		$value = apply_filters('frm_content', $value, $form, $entry);
578
+		$value = do_shortcode($value);
579 579
 
580
-        return $value;
581
-    }
580
+		return $value;
581
+	}
582 582
 
583 583
 	public static function get_shortcodes( $content, $form_id ) {
584
-        if ( FrmAppHelper::pro_is_installed() ) {
585
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
586
-        }
584
+		if ( FrmAppHelper::pro_is_installed() ) {
585
+			return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
586
+		}
587 587
 
588 588
 		$fields = FrmField::getAll( array(
589 589
 			'fi.form_id'  => (int) $form_id,
590 590
 			'fi.type not' => FrmField::no_save_fields(),
591 591
 		) );
592 592
 
593
-        $tagregexp = self::allowed_shortcodes($fields);
593
+		$tagregexp = self::allowed_shortcodes($fields);
594 594
 
595
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
595
+		preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
596 596
 
597
-        return $matches;
598
-    }
597
+		return $matches;
598
+	}
599 599
 
600 600
 	public static function allowed_shortcodes( $fields = array() ) {
601 601
 		$tagregexp = array( 'editlink', 'id', 'key', 'ip', 'siteurl', 'sitename', 'admin_email', 'post[-|_]id', 'created[-|_]at', 'updated[-|_]at', 'updated[-|_]by', 'parent[-|_]id' );
602 602
 
603
-        foreach ( $fields as $field ) {
604
-            $tagregexp[] = $field->id;
605
-            $tagregexp[] = $field->field_key;
606
-        }
603
+		foreach ( $fields as $field ) {
604
+			$tagregexp[] = $field->id;
605
+			$tagregexp[] = $field->field_key;
606
+		}
607 607
 
608
-        $tagregexp = implode('|', $tagregexp);
609
-        return $tagregexp;
610
-    }
608
+		$tagregexp = implode('|', $tagregexp);
609
+		return $tagregexp;
610
+	}
611 611
 
612 612
 	public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
613
-        foreach ( $shortcodes[0] as $short_key => $tag ) {
613
+		foreach ( $shortcodes[0] as $short_key => $tag ) {
614 614
 			if ( empty( $tag ) ) {
615 615
 				continue;
616 616
 			}
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 		}
632 632
 
633 633
 		return $content;
634
-    }
634
+	}
635 635
 
636 636
 	/**
637 637
 	 * @since 3.0
@@ -725,44 +725,44 @@  discard block
 block discarded – undo
725 725
 		return $replace_with;
726 726
 	}
727 727
 
728
-    /**
729
-     * Get the value to replace a few standard shortcodes
730
-     *
731
-     * @since 2.0
732
-     * @return string
733
-     */
734
-    public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
735
-        $new_value = '';
736
-        switch ( $tag ) {
737
-            case 'admin_email':
738
-                $new_value = get_option('admin_email');
739
-                break;
740
-            case 'siteurl':
741
-                $new_value = FrmAppHelper::site_url();
742
-                break;
743
-            case 'frmurl':
744
-                $new_value = FrmAppHelper::plugin_url();
745
-                break;
746
-            case 'sitename':
747
-                $new_value = FrmAppHelper::site_name();
748
-                break;
749
-            case 'get':
750
-                $new_value = self::process_get_shortcode( $atts, $return_array );
751
-        }
752
-
753
-        return $new_value;
754
-    }
755
-
756
-    /**
757
-     * Process the [get] shortcode
758
-     *
759
-     * @since 2.0
760
-     * @return string|array
761
-     */
762
-    public static function process_get_shortcode( $atts, $return_array = false ) {
763
-        if ( ! isset($atts['param']) ) {
764
-            return '';
765
-        }
728
+	/**
729
+	 * Get the value to replace a few standard shortcodes
730
+	 *
731
+	 * @since 2.0
732
+	 * @return string
733
+	 */
734
+	public static function dynamic_default_values( $tag, $atts = array(), $return_array = false ) {
735
+		$new_value = '';
736
+		switch ( $tag ) {
737
+			case 'admin_email':
738
+				$new_value = get_option('admin_email');
739
+				break;
740
+			case 'siteurl':
741
+				$new_value = FrmAppHelper::site_url();
742
+				break;
743
+			case 'frmurl':
744
+				$new_value = FrmAppHelper::plugin_url();
745
+				break;
746
+			case 'sitename':
747
+				$new_value = FrmAppHelper::site_name();
748
+				break;
749
+			case 'get':
750
+				$new_value = self::process_get_shortcode( $atts, $return_array );
751
+		}
752
+
753
+		return $new_value;
754
+	}
755
+
756
+	/**
757
+	 * Process the [get] shortcode
758
+	 *
759
+	 * @since 2.0
760
+	 * @return string|array
761
+	 */
762
+	public static function process_get_shortcode( $atts, $return_array = false ) {
763
+		if ( ! isset($atts['param']) ) {
764
+			return '';
765
+		}
766 766
 
767 767
 		if ( strpos( $atts['param'], '&#91;' ) ) {
768 768
 			$atts['param'] = str_replace( '&#91;', '[', $atts['param'] );
@@ -770,22 +770,22 @@  discard block
 block discarded – undo
770 770
 		}
771 771
 
772 772
 		$new_value = FrmAppHelper::get_param( $atts['param'], '', 'get', 'sanitize_text_field' );
773
-        $new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
773
+		$new_value = FrmAppHelper::get_query_var( $new_value, $atts['param'] );
774 774
 
775
-        if ( $new_value == '' ) {
775
+		if ( $new_value == '' ) {
776 776
 			if ( ! isset( $atts['prev_val'] ) ) {
777
-                $atts['prev_val'] = '';
778
-            }
777
+				$atts['prev_val'] = '';
778
+			}
779 779
 
780 780
 			$new_value = isset( $atts['default'] ) ? $atts['default'] : $atts['prev_val'];
781
-        }
781
+		}
782 782
 
783 783
 		if ( is_array( $new_value ) && ! $return_array ) {
784 784
 			$new_value = implode( ', ', $new_value );
785 785
 		}
786 786
 
787
-        return $new_value;
788
-    }
787
+		return $new_value;
788
+	}
789 789
 
790 790
 	public static function get_display_value( $value, $field, $atts = array() ) {
791 791
 
@@ -855,27 +855,27 @@  discard block
 block discarded – undo
855 855
 
856 856
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
857 857
 
858
-        $field_types = array();
859
-        if ( in_array($type, $single_input) ) {
860
-            self::field_types_for_input( $single_input, $field_selection, $field_types );
861
-        } else if ( in_array($type, $multiple_input) ) {
862
-            self::field_types_for_input( $multiple_input, $field_selection, $field_types );
863
-        } else if ( in_array($type, $other_type) ) {
864
-            self::field_types_for_input( $other_type, $field_selection, $field_types );
858
+		$field_types = array();
859
+		if ( in_array($type, $single_input) ) {
860
+			self::field_types_for_input( $single_input, $field_selection, $field_types );
861
+		} else if ( in_array($type, $multiple_input) ) {
862
+			self::field_types_for_input( $multiple_input, $field_selection, $field_types );
863
+		} else if ( in_array($type, $other_type) ) {
864
+			self::field_types_for_input( $other_type, $field_selection, $field_types );
865 865
 		} else if ( isset( $field_selection[ $type ] ) ) {
866
-            $field_types[ $type ] = $field_selection[ $type ];
867
-        }
866
+			$field_types[ $type ] = $field_selection[ $type ];
867
+		}
868 868
 
869 869
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
870
-        return $field_types;
871
-    }
870
+		return $field_types;
871
+	}
872 872
 
873
-    private static function field_types_for_input( $inputs, $fields, &$field_types ) {
874
-        foreach ( $inputs as $input ) {
875
-            $field_types[ $input ] = $fields[ $input ];
876
-            unset($input);
877
-        }
878
-    }
873
+	private static function field_types_for_input( $inputs, $fields, &$field_types ) {
874
+		foreach ( $inputs as $input ) {
875
+			$field_types[ $input ] = $fields[ $input ];
876
+			unset($input);
877
+		}
878
+	}
879 879
 
880 880
 	/**
881 881
 	 * Check if current field option is an "other" option
@@ -889,14 +889,14 @@  discard block
 block discarded – undo
889 889
 		return $opt_key && strpos( $opt_key, 'other_' ) === 0;
890 890
 	}
891 891
 
892
-    /**
893
-    * Get value that belongs in "Other" text box
894
-    *
895
-    * @since 2.0.6
896
-    *
897
-    * @param array $args
898
-    */
899
-    public static function get_other_val( $args ) {
892
+	/**
893
+	 * Get value that belongs in "Other" text box
894
+	 *
895
+	 * @since 2.0.6
896
+	 *
897
+	 * @param array $args
898
+	 */
899
+	public static function get_other_val( $args ) {
900 900
 		$defaults = array(
901 901
 			'opt_key' => 0,
902 902
 			'field'   => array(),
@@ -974,20 +974,20 @@  discard block
 block discarded – undo
974 974
 		}
975 975
 
976 976
 		return $other_val;
977
-    }
978
-
979
-    /**
980
-    * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
981
-    * Intended for front-end use
982
-    *
983
-    * @since 2.0.6
984
-    *
985
-    * @param array $args should include field, opt_key and field name
986
-    * @param boolean $other_opt
987
-    * @param string $checked
988
-    * @return array $other_args
989
-    */
990
-    public static function prepare_other_input( $args, &$other_opt, &$checked ) {
977
+	}
978
+
979
+	/**
980
+	 * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val.
981
+	 * Intended for front-end use
982
+	 *
983
+	 * @since 2.0.6
984
+	 *
985
+	 * @param array $args should include field, opt_key and field name
986
+	 * @param boolean $other_opt
987
+	 * @param string $checked
988
+	 * @return array $other_args
989
+	 */
990
+	public static function prepare_other_input( $args, &$other_opt, &$checked ) {
991 991
 		//Check if this is an "Other" option
992 992
 		if ( ! self::is_other_opt( $args['opt_key'] ) ) {
993 993
 			return;
@@ -1003,8 +1003,8 @@  discard block
 block discarded – undo
1003 1003
 			$checked = 'checked="checked" ';
1004 1004
 		}
1005 1005
 
1006
-        return $other_args;
1007
-    }
1006
+		return $other_args;
1007
+	}
1008 1008
 
1009 1009
 	/**
1010 1010
 	 * @param array $args
@@ -1059,8 +1059,8 @@  discard block
 block discarded – undo
1059 1059
 	 * @since 2.0.6
1060 1060
 	 */
1061 1061
 	public static function include_other_input( $args ) {
1062
-        if ( ! $args['other_opt'] ) {
1063
-        	return;
1062
+		if ( ! $args['other_opt'] ) {
1063
+			return;
1064 1064
 		}
1065 1065
 
1066 1066
 		$classes = array( 'frm_other_input' );
@@ -1085,15 +1085,15 @@  discard block
 block discarded – undo
1085 1085
 	}
1086 1086
 
1087 1087
 	/**
1088
-	* Get the HTML id for an "Other" text field
1089
-	* Note: This does not affect fields in repeating sections
1090
-	*
1091
-	* @since 2.0.08
1092
-	* @param string $type - field type
1093
-	* @param string $html_id
1094
-	* @param string|boolean $opt_key
1095
-	* @return string $other_id
1096
-	*/
1088
+	 * Get the HTML id for an "Other" text field
1089
+	 * Note: This does not affect fields in repeating sections
1090
+	 *
1091
+	 * @since 2.0.08
1092
+	 * @param string $type - field type
1093
+	 * @param string $html_id
1094
+	 * @param string|boolean $opt_key
1095
+	 * @return string $other_id
1096
+	 */
1097 1097
 	public static function get_other_field_html_id( $type, $html_id, $opt_key = false ) {
1098 1098
 		$other_id = $html_id;
1099 1099
 
@@ -1157,10 +1157,10 @@  discard block
 block discarded – undo
1157 1157
 	}
1158 1158
 
1159 1159
 	public static function switch_field_ids( $val ) {
1160
-        global $frm_duplicate_ids;
1161
-        $replace = array();
1162
-        $replace_with = array();
1163
-        foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1160
+		global $frm_duplicate_ids;
1161
+		$replace = array();
1162
+		$replace_with = array();
1163
+		foreach ( (array) $frm_duplicate_ids as $old => $new ) {
1164 1164
 			$replace[] = '[if ' . $old . ']';
1165 1165
 			$replace_with[] = '[if ' . $new . ']';
1166 1166
 			$replace[] = '[if ' . $old . ' ';
@@ -1175,19 +1175,19 @@  discard block
 block discarded – undo
1175 1175
 			$replace_with[] = '[' . $new . ']';
1176 1176
 			$replace[] = '[' . $old . ' ';
1177 1177
 			$replace_with[] = '[' . $new . ' ';
1178
-            unset($old, $new);
1179
-        }
1178
+			unset($old, $new);
1179
+		}
1180 1180
 		if ( is_array( $val ) ) {
1181 1181
 			foreach ( $val as $k => $v ) {
1182
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1183
-                unset($k, $v);
1184
-            }
1185
-        } else {
1186
-            $val = str_replace($replace, $replace_with, $val);
1187
-        }
1182
+				$val[ $k ] = str_replace( $replace, $replace_with, $v );
1183
+				unset($k, $v);
1184
+			}
1185
+		} else {
1186
+			$val = str_replace($replace, $replace_with, $val);
1187
+		}
1188 1188
 
1189
-        return $val;
1190
-    }
1189
+		return $val;
1190
+	}
1191 1191
 
1192 1192
 	public static function get_us_states() {
1193 1193
 		return apply_filters( 'frm_us_states', array(
@@ -1252,15 +1252,15 @@  discard block
 block discarded – undo
1252 1252
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1253 1253
 		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1254 1254
 
1255
-        $states = FrmFieldsHelper::get_us_states();
1256
-        $state_abv = array_keys($states);
1257
-        sort($state_abv);
1255
+		$states = FrmFieldsHelper::get_us_states();
1256
+		$state_abv = array_keys($states);
1257
+		sort($state_abv);
1258 1258
 		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1259 1259
 
1260
-        $states = array_values($states);
1261
-        sort($states);
1260
+		$states = array_values($states);
1261
+		sort($states);
1262 1262
 		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1263
-        unset($state_abv, $states);
1263
+		unset($state_abv, $states);
1264 1264
 
1265 1265
 		$prepop[ __( 'Age', 'formidable' ) ] = array(
1266 1266
 			__( 'Under 18', 'formidable' ),
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
 		);
1302 1302
 
1303 1303
 		$prepop = apply_filters( 'frm_bulk_field_choices', $prepop );
1304
-    }
1304
+	}
1305 1305
 
1306 1306
 	/**
1307 1307
 	 * Display a field value selector
@@ -1311,10 +1311,10 @@  discard block
 block discarded – undo
1311 1311
 	 * @param int $selector_field_id
1312 1312
 	 * @param array $selector_args
1313 1313
 	 */
1314
-    public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1315
-	    $field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1316
-	    $field_value_selector->display();
1317
-    }
1314
+	public static function display_field_value_selector( $selector_field_id, $selector_args ) {
1315
+		$field_value_selector = FrmFieldFactory::create_field_value_selector( $selector_field_id, $selector_args );
1316
+		$field_value_selector->display();
1317
+	}
1318 1318
 
1319 1319
 	/**
1320 1320
 	 * Convert a field object to a flat array
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 			if ( in_array( $type, array( 'data', 'lookup' ) ) ) {
26 26
 				$values['field_options']['data_type'] = $setting;
27 27
 			} else {
28
-				$values['field_options'][ $setting ] = 1;
28
+				$values['field_options'][$setting] = 1;
29 29
 			}
30 30
 		}
31 31
 
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 		}
128 128
 
129 129
 		foreach ( $defaults as $opt => $default ) {
130
-			$values[ $opt ] = isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default;
130
+			$values[$opt] = isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default;
131 131
 
132 132
 			if ( $check_post ) {
133
-				self::get_posted_field_setting( $opt . '_' . $field->id, $values[ $opt ] );
133
+				self::get_posted_field_setting( $opt . '_' . $field->id, $values[$opt] );
134 134
 			}
135 135
 
136 136
 			unset( $opt, $default );
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 	 * @param mixed $value
174 174
 	 */
175 175
 	private static function get_posted_field_setting( $setting, &$value ) {
176
-		if ( isset( $_POST['field_options'][ $setting ] ) ) {
177
-			$value = maybe_unserialize( $_POST['field_options'][ $setting ] );
176
+		if ( isset( $_POST['field_options'][$setting] ) ) {
177
+			$value = maybe_unserialize( $_POST['field_options'][$setting] );
178 178
 			if ( strpos( $setting, 'html' ) !== false ) {
179 179
 				// strip slashes from HTML but not regex
180 180
 				$value = stripslashes_deep( $value );
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 		$values['default_value'] = maybe_serialize( $field->default_value );
249 249
 
250 250
         foreach ( array( 'name', 'description', 'type', 'field_order', 'field_options', 'required' ) as $col ) {
251
-            $values[ $col ] = $field->{$col};
251
+            $values[$col] = $field->{$col};
252 252
         }
253 253
     }
254 254
 
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
 		$defaults = array(
270 270
 			'unique_msg' => array(
271 271
 				'full' => $default_settings['unique_msg'],
272
-				'part' => sprintf( __('%s must be unique', 'formidable' ), $field_name ),
272
+				'part' => sprintf( __( '%s must be unique', 'formidable' ), $field_name ),
273 273
 			),
274 274
 			'invalid'  => array(
275 275
 				'full' => __( 'This field is invalid', 'formidable' ),
276
-				'part' => sprintf( __('%s is invalid', 'formidable' ), $field_name ),
276
+				'part' => sprintf( __( '%s is invalid', 'formidable' ), $field_name ),
277 277
 			),
278 278
 			'blank'    => array(
279 279
 				'full' => $frm_settings->blank_msg,
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 		);
287 287
 
288 288
 		$msg = FrmField::get_option( $field, $error );
289
-		$msg = empty( $msg ) ? $defaults[ $error ]['part'] : $msg;
289
+		$msg = empty( $msg ) ? $defaults[$error]['part'] : $msg;
290 290
 		$msg = do_shortcode( $msg );
291 291
 		return $msg;
292 292
 	}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 			$default_html = apply_filters( 'frm_other_custom_html', '', $type );
306 306
 		}
307 307
 
308
-		return apply_filters('frm_custom_html', $default_html, $type);
308
+		return apply_filters( 'frm_custom_html', $default_html, $type );
309 309
 	}
310 310
 
311 311
 	/**
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 			// Get string for Other text field, if needed
440 440
 			$other_val = self::get_other_val( compact( 'opt_key', 'field' ) );
441 441
 
442
-			$checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array($field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"' : '';
442
+			$checked = ( $other_val || isset( $field['value'] ) && ( ( ! is_array( $field['value'] ) && $field['value'] == $field_val ) || ( is_array( $field['value'] ) && in_array( $field_val, $field['value'] ) ) ) ) ? ' checked="checked"' : '';
443 443
 
444 444
 		    // If this is an "Other" option, get the HTML for it
445 445
 			if ( self::is_other_opt( $opt_key ) ) {
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 	 * @return string
471 471
 	 */
472 472
 	public static function get_term_link( $tax_id ) {
473
-        $tax = get_taxonomy($tax_id);
473
+        $tax = get_taxonomy( $tax_id );
474 474
         if ( ! $tax ) {
475 475
             return '';
476 476
         }
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
             __( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
480 480
 			'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? __( 'Categories' ) : $tax->labels->name ) . '</a>'
481 481
         );
482
-        unset($tax);
482
+        unset( $tax );
483 483
 
484 484
         return $link;
485 485
     }
@@ -488,8 +488,8 @@  discard block
 block discarded – undo
488 488
 		$hide_opt = self::get_value_for_comparision( $hide_opt );
489 489
 		$observed_value = self::get_value_for_comparision( $observed_value );
490 490
 
491
-        if ( is_array($observed_value) ) {
492
-            return self::array_value_condition($observed_value, $cond, $hide_opt);
491
+        if ( is_array( $observed_value ) ) {
492
+            return self::array_value_condition( $observed_value, $cond, $hide_opt );
493 493
         }
494 494
 
495 495
         $m = false;
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
 	public static function array_value_condition( $observed_value, $cond, $hide_opt ) {
533 533
         $m = false;
534 534
         if ( $cond == '==' ) {
535
-            if ( is_array($hide_opt) ) {
536
-                $m = array_intersect($hide_opt, $observed_value);
537
-                $m = empty($m) ? false : true;
535
+            if ( is_array( $hide_opt ) ) {
536
+                $m = array_intersect( $hide_opt, $observed_value );
537
+                $m = empty( $m ) ? false : true;
538 538
             } else {
539
-                $m = in_array($hide_opt, $observed_value);
539
+                $m = in_array( $hide_opt, $observed_value );
540 540
             }
541 541
 		} elseif ( $cond == '!=' ) {
542 542
 			$m = ! in_array( $hide_opt, $observed_value );
@@ -569,20 +569,20 @@  discard block
 block discarded – undo
569 569
      * @return string
570 570
      */
571 571
 	public static function basic_replace_shortcodes( $value, $form, $entry ) {
572
-		if ( strpos( $value, '[sitename]') !== false ) {
572
+		if ( strpos( $value, '[sitename]' ) !== false ) {
573 573
             $new_value = wp_specialchars_decode( FrmAppHelper::site_name(), ENT_QUOTES );
574
-            $value = str_replace('[sitename]', $new_value, $value);
574
+            $value = str_replace( '[sitename]', $new_value, $value );
575 575
         }
576 576
 
577
-        $value = apply_filters('frm_content', $value, $form, $entry);
578
-        $value = do_shortcode($value);
577
+        $value = apply_filters( 'frm_content', $value, $form, $entry );
578
+        $value = do_shortcode( $value );
579 579
 
580 580
         return $value;
581 581
     }
582 582
 
583 583
 	public static function get_shortcodes( $content, $form_id ) {
584 584
         if ( FrmAppHelper::pro_is_installed() ) {
585
-            return FrmProDisplaysHelper::get_shortcodes($content, $form_id);
585
+            return FrmProDisplaysHelper::get_shortcodes( $content, $form_id );
586 586
         }
587 587
 
588 588
 		$fields = FrmField::getAll( array(
@@ -590,9 +590,9 @@  discard block
 block discarded – undo
590 590
 			'fi.type not' => FrmField::no_save_fields(),
591 591
 		) );
592 592
 
593
-        $tagregexp = self::allowed_shortcodes($fields);
593
+        $tagregexp = self::allowed_shortcodes( $fields );
594 594
 
595
-        preg_match_all("/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER);
595
+        preg_match_all( "/\[(if )?($tagregexp)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", $content, $matches, PREG_PATTERN_ORDER );
596 596
 
597 597
         return $matches;
598 598
     }
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
             $tagregexp[] = $field->field_key;
606 606
         }
607 607
 
608
-        $tagregexp = implode('|', $tagregexp);
608
+        $tagregexp = implode( '|', $tagregexp );
609 609
         return $tagregexp;
610 610
     }
611 611
 
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 				continue;
616 616
 			}
617 617
 
618
-			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][ $short_key ] );
618
+			$atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[3][$short_key] );
619 619
 			$tag  = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key );
620 620
 
621 621
 			$atts['entry'] = $entry;
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 
625 625
 			if ( $replace_with !== null ) {
626 626
 				$replace_with = str_replace( '[', '&#91;', $replace_with ); // prevent shortcodes in fields from being processed
627
-				$content = str_replace( $shortcodes[0][ $short_key ], $replace_with, $content );
627
+				$content = str_replace( $shortcodes[0][$short_key], $replace_with, $content );
628 628
 			}
629 629
 
630 630
 			unset( $atts, $replace_with );
@@ -651,8 +651,8 @@  discard block
 block discarded – undo
651 651
 
652 652
 		$dynamic_default = array( 'admin_email', 'siteurl', 'frmurl', 'sitename', 'get' );
653 653
 
654
-		if ( isset( $shortcode_values[ $atts['tag'] ] ) ) {
655
-			$replace_with = $shortcode_values[ $atts['tag'] ];
654
+		if ( isset( $shortcode_values[$atts['tag']] ) ) {
655
+			$replace_with = $shortcode_values[$atts['tag']];
656 656
 		} elseif ( in_array( $atts['tag'], $dynamic_default ) ) {
657 657
 			$replace_with = self::dynamic_default_values( $atts['tag'], $atts );
658 658
 		} elseif ( $clean_tag == 'user_agent' ) {
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 		if ( isset( $atts['format'] ) ) {
682 682
 			$time_format = ' ';
683 683
 		} else {
684
-			$atts['format'] = get_option('date_format');
684
+			$atts['format'] = get_option( 'date_format' );
685 685
 			$time_format = '';
686 686
 		}
687 687
 
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
         $new_value = '';
736 736
         switch ( $tag ) {
737 737
             case 'admin_email':
738
-                $new_value = get_option('admin_email');
738
+                $new_value = get_option( 'admin_email' );
739 739
                 break;
740 740
             case 'siteurl':
741 741
                 $new_value = FrmAppHelper::site_url();
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
      * @return string|array
761 761
      */
762 762
     public static function process_get_shortcode( $atts, $return_array = false ) {
763
-        if ( ! isset($atts['param']) ) {
763
+        if ( ! isset( $atts['param'] ) ) {
764 764
             return '';
765 765
         }
766 766
 
@@ -822,9 +822,9 @@  discard block
 block discarded – undo
822 822
 			'size'  => 96,
823 823
 		);
824 824
 
825
-		$args = wp_parse_args($args, $defaults);
825
+		$args = wp_parse_args( $args, $defaults );
826 826
 
827
-		$user = get_userdata($user_id);
827
+		$user = get_userdata( $user_id );
828 828
 		$info = '';
829 829
 
830 830
 		if ( $user ) {
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 			} elseif ( $user_info == 'author_link' ) {
834 834
 				$info = get_author_posts_url( $user_id );
835 835
 			} else {
836
-				$info = isset($user->$user_info) ? $user->$user_info : '';
836
+				$info = isset( $user->$user_info ) ? $user->$user_info : '';
837 837
 			}
838 838
 
839 839
 			if ( 'display_name' === $user_info && empty( $info ) && ! $args['blank'] ) {
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 		}
843 843
 
844 844
 		if ( $args['link'] ) {
845
-			$info = '<a href="' . esc_url( admin_url('user-edit.php?user_id=' . $user_id ) ) . '">' . $info . '</a>';
845
+			$info = '<a href="' . esc_url( admin_url( 'user-edit.php?user_id=' . $user_id ) ) . '">' . $info . '</a>';
846 846
 		}
847 847
 
848 848
 		return $info;
@@ -856,14 +856,14 @@  discard block
 block discarded – undo
856 856
 		$field_selection = array_merge( FrmField::pro_field_selection(), FrmField::field_selection() );
857 857
 
858 858
         $field_types = array();
859
-        if ( in_array($type, $single_input) ) {
859
+        if ( in_array( $type, $single_input ) ) {
860 860
             self::field_types_for_input( $single_input, $field_selection, $field_types );
861
-        } else if ( in_array($type, $multiple_input) ) {
861
+        } else if ( in_array( $type, $multiple_input ) ) {
862 862
             self::field_types_for_input( $multiple_input, $field_selection, $field_types );
863
-        } else if ( in_array($type, $other_type) ) {
863
+        } else if ( in_array( $type, $other_type ) ) {
864 864
             self::field_types_for_input( $other_type, $field_selection, $field_types );
865
-		} else if ( isset( $field_selection[ $type ] ) ) {
866
-            $field_types[ $type ] = $field_selection[ $type ];
865
+		} else if ( isset( $field_selection[$type] ) ) {
866
+            $field_types[$type] = $field_selection[$type];
867 867
         }
868 868
 
869 869
 		$field_types = apply_filters( 'frm_switch_field_types', $field_types, compact( 'type' ) );
@@ -872,8 +872,8 @@  discard block
 block discarded – undo
872 872
 
873 873
     private static function field_types_for_input( $inputs, $fields, &$field_types ) {
874 874
         foreach ( $inputs as $input ) {
875
-            $field_types[ $input ] = $fields[ $input ];
876
-            unset($input);
875
+            $field_types[$input] = $fields[$input];
876
+            unset( $input );
877 877
         }
878 878
     }
879 879
 
@@ -920,21 +920,21 @@  discard block
 block discarded – undo
920 920
 		// Check posted vals before checking saved values
921 921
 
922 922
 		// For fields inside repeating sections - note, don't check if $pointer is true because it will often be zero
923
-		if ( $parent && isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] ) ) {
923
+		if ( $parent && isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] ) ) {
924 924
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
925
-				$other_val = isset( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ][ $opt_key ] ) : '';
925
+				$other_val = isset( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']][$opt_key] ) : '';
926 926
 			} else {
927
-				$other_val = sanitize_text_field( $_POST['item_meta'][ $parent ][ $pointer ]['other'][ $field['id'] ] );
927
+				$other_val = sanitize_text_field( $_POST['item_meta'][$parent][$pointer]['other'][$field['id']] );
928 928
 			}
929 929
 			return $other_val;
930 930
 
931
-		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][ $field['id'] ] ) ) {
931
+		} else if ( isset( $field['id'] ) && isset( $_POST['item_meta']['other'][$field['id']] ) ) {
932 932
 			// For normal fields
933 933
 
934 934
 			if ( FrmField::is_field_with_multiple_values( $field ) ) {
935
-				$other_val = isset( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) ? sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ][ $opt_key ] ) : '';
935
+				$other_val = isset( $_POST['item_meta']['other'][$field['id']][$opt_key] ) ? sanitize_text_field( $_POST['item_meta']['other'][$field['id']][$opt_key] ) : '';
936 936
 			} else {
937
-				$other_val = sanitize_text_field( $_POST['item_meta']['other'][ $field['id'] ] );
937
+				$other_val = sanitize_text_field( $_POST['item_meta']['other'][$field['id']] );
938 938
 			}
939 939
 			return $other_val;
940 940
 		}
@@ -943,8 +943,8 @@  discard block
 block discarded – undo
943 943
 		if ( $field['type'] == 'checkbox' && is_array( $field['value'] ) ) {
944 944
 			// Check if there is an "other" val in saved value and make sure the
945 945
 			// "other" val is not equal to the Other checkbox option
946
-			if ( isset( $field['value'][ $opt_key ] ) && $field['options'][ $opt_key ] != $field['value'][ $opt_key ] ) {
947
-				$other_val = $field['value'][ $opt_key ];
946
+			if ( isset( $field['value'][$opt_key] ) && $field['options'][$opt_key] != $field['value'][$opt_key] ) {
947
+				$other_val = $field['value'][$opt_key];
948 948
 			}
949 949
 		} else {
950 950
 			/**
@@ -956,8 +956,8 @@  discard block
 block discarded – undo
956 956
 				// Multi-select dropdowns - key is not preserved
957 957
 				if ( is_array( $field['value'] ) ) {
958 958
 					$o_key = array_search( $temp_val, $field['value'] );
959
-					if ( isset( $field['value'][ $o_key ] ) ) {
960
-						unset( $field['value'][ $o_key ], $o_key );
959
+					if ( isset( $field['value'][$o_key] ) ) {
960
+						unset( $field['value'][$o_key], $o_key );
961 961
 					}
962 962
 				} else if ( $temp_val == $field['value'] ) {
963 963
 					// For radio and regular dropdowns
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
 	private static function set_other_name( $args, &$other_args ) {
1015 1015
 		//Set up name for other field
1016 1016
 		$other_args['name'] = str_replace( '[]', '', $args['field_name'] );
1017
-		$other_args['name'] = preg_replace('/\[' . $args['field']['id'] . '\]$/', '', $other_args['name']);
1017
+		$other_args['name'] = preg_replace( '/\[' . $args['field']['id'] . '\]$/', '', $other_args['name'] );
1018 1018
 		$other_args['name'] = $other_args['name'] . '[other]' . '[' . $args['field']['id'] . ']';
1019 1019
 
1020 1020
 		//Converts item_meta[field_id] => item_meta[other][field_id] and
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 		// Count should only be greater than 3 if inside of a repeating section
1042 1042
 		if ( count( $temp_array ) > 3 ) {
1043 1043
 			$parent = str_replace( ']', '', $temp_array[1] );
1044
-			$pointer = str_replace( ']', '', $temp_array[2]);
1044
+			$pointer = str_replace( ']', '', $temp_array[2] );
1045 1045
 		}
1046 1046
 
1047 1047
 		// Get text for "other" text field
@@ -1175,15 +1175,15 @@  discard block
 block discarded – undo
1175 1175
 			$replace_with[] = '[' . $new . ']';
1176 1176
 			$replace[] = '[' . $old . ' ';
1177 1177
 			$replace_with[] = '[' . $new . ' ';
1178
-            unset($old, $new);
1178
+            unset( $old, $new );
1179 1179
         }
1180 1180
 		if ( is_array( $val ) ) {
1181 1181
 			foreach ( $val as $k => $v ) {
1182
-                $val[ $k ] = str_replace( $replace, $replace_with, $v );
1183
-                unset($k, $v);
1182
+                $val[$k] = str_replace( $replace, $replace_with, $v );
1183
+                unset( $k, $v );
1184 1184
             }
1185 1185
         } else {
1186
-            $val = str_replace($replace, $replace_with, $val);
1186
+            $val = str_replace( $replace, $replace_with, $val );
1187 1187
         }
1188 1188
 
1189 1189
         return $val;
@@ -1250,19 +1250,19 @@  discard block
 block discarded – undo
1250 1250
 	}
1251 1251
 
1252 1252
 	public static function get_bulk_prefilled_opts( array &$prepop ) {
1253
-		$prepop[ __( 'Countries', 'formidable' ) ] = FrmFieldsHelper::get_countries();
1253
+		$prepop[__( 'Countries', 'formidable' )] = FrmFieldsHelper::get_countries();
1254 1254
 
1255 1255
         $states = FrmFieldsHelper::get_us_states();
1256
-        $state_abv = array_keys($states);
1257
-        sort($state_abv);
1258
-		$prepop[ __( 'U.S. State Abbreviations', 'formidable' ) ] = $state_abv;
1256
+        $state_abv = array_keys( $states );
1257
+        sort( $state_abv );
1258
+		$prepop[__( 'U.S. State Abbreviations', 'formidable' )] = $state_abv;
1259 1259
 
1260
-        $states = array_values($states);
1261
-        sort($states);
1262
-		$prepop[ __( 'U.S. States', 'formidable' ) ] = $states;
1263
-        unset($state_abv, $states);
1260
+        $states = array_values( $states );
1261
+        sort( $states );
1262
+		$prepop[__( 'U.S. States', 'formidable' )] = $states;
1263
+        unset( $state_abv, $states );
1264 1264
 
1265
-		$prepop[ __( 'Age', 'formidable' ) ] = array(
1265
+		$prepop[__( 'Age', 'formidable' )] = array(
1266 1266
 			__( 'Under 18', 'formidable' ),
1267 1267
 			__( '18-24', 'formidable' ),
1268 1268
 			__( '25-34', 'formidable' ),
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
 			__( 'Prefer Not to Answer', 'formidable' ),
1274 1274
 		);
1275 1275
 
1276
-		$prepop[ __( 'Satisfaction', 'formidable' ) ] = array(
1276
+		$prepop[__( 'Satisfaction', 'formidable' )] = array(
1277 1277
 			__( 'Very Satisfied', 'formidable' ),
1278 1278
 			__( 'Satisfied', 'formidable' ),
1279 1279
 			__( 'Neutral', 'formidable' ),
@@ -1282,7 +1282,7 @@  discard block
 block discarded – undo
1282 1282
 			__( 'N/A', 'formidable' ),
1283 1283
 		);
1284 1284
 
1285
-		$prepop[ __( 'Importance', 'formidable' ) ] = array(
1285
+		$prepop[__( 'Importance', 'formidable' )] = array(
1286 1286
 			__( 'Very Important', 'formidable' ),
1287 1287
 			__( 'Important', 'formidable' ),
1288 1288
 			__( 'Neutral', 'formidable' ),
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
 			__( 'N/A', 'formidable' ),
1292 1292
 		);
1293 1293
 
1294
-		$prepop[ __( 'Agreement', 'formidable' ) ] = array(
1294
+		$prepop[__( 'Agreement', 'formidable' )] = array(
1295 1295
 			__( 'Strongly Agree', 'formidable' ),
1296 1296
 			__( 'Agree', 'formidable' ),
1297 1297
 			__( 'Neutral', 'formidable' ),
Please login to merge, or discard this patch.
classes/helpers/FrmXMLHelper.php 2 patches
Indentation   +435 added lines, -435 removed lines patch added patch discarded remove patch
@@ -33,24 +33,24 @@  discard block
 block discarded – undo
33 33
 			'styles'  => 0,
34 34
 		);
35 35
 
36
-        $imported = array(
37
-            'imported' => $defaults,
36
+		$imported = array(
37
+			'imported' => $defaults,
38 38
 			'updated'  => $defaults,
39 39
 			'forms'    => array(),
40 40
 			'terms'    => array(),
41
-        );
41
+		);
42 42
 
43 43
 		unset( $defaults );
44 44
 
45 45
 		if ( ! defined( 'WP_IMPORTING' ) ) {
46 46
 			define( 'WP_IMPORTING', true );
47
-        }
47
+		}
48 48
 
49 49
 		if ( ! class_exists( 'DOMDocument' ) ) {
50
-            return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
51
-        }
50
+			return new WP_Error( 'SimpleXML_parse_error', __( 'Your server does not have XML enabled', 'formidable' ), libxml_get_errors() );
51
+		}
52 52
 
53
-        $dom = new DOMDocument;
53
+		$dom = new DOMDocument;
54 54
 		$success = $dom->loadXML( file_get_contents( $file ) );
55 55
 		if ( ! $success ) {
56 56
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
@@ -68,45 +68,45 @@  discard block
 block discarded – undo
68 68
 			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
69 69
 		}
70 70
 
71
-        // add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
71
+		// add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
72 72
 		foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
73
-            // grab cats, tags, and terms, or forms or posts
73
+			// grab cats, tags, and terms, or forms or posts
74 74
 			if ( isset( $xml->{$item_type} ) ) {
75 75
 				$function_name = 'import_xml_' . $item_type . 's';
76 76
 				$imported = self::$function_name( $xml->{$item_type}, $imported );
77 77
 				unset( $function_name, $xml->{$item_type} );
78
-            }
79
-        }
78
+			}
79
+		}
80 80
 
81 81
 		$return = apply_filters( 'frm_importing_xml', $imported, $xml );
82 82
 
83
-	    return $return;
84
-    }
83
+		return $return;
84
+	}
85 85
 
86 86
 	public static function import_xml_terms( $terms, $imported ) {
87
-        foreach ( $terms as $t ) {
87
+		foreach ( $terms as $t ) {
88 88
 			if ( term_exists( (string) $t->term_slug, (string) $t->term_taxonomy ) ) {
89
-			    continue;
89
+				continue;
90 90
 			}
91 91
 
92 92
 			$parent = self::get_term_parent_id( $t );
93 93
 
94 94
 			$term = wp_insert_term( (string) $t->term_name, (string) $t->term_taxonomy, array(
95
-                'slug'          => (string) $t->term_slug,
96
-                'description'   => (string) $t->term_description,
95
+				'slug'          => (string) $t->term_slug,
96
+				'description'   => (string) $t->term_description,
97 97
 				'parent'        => empty( $parent ) ? 0 : $parent,
98
-            ));
98
+			));
99 99
 
100 100
 			if ( $term && is_array( $term ) ) {
101
-                $imported['imported']['terms']++;
101
+				$imported['imported']['terms']++;
102 102
 				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
103
-            }
103
+			}
104 104
 
105 105
 			unset( $term, $t );
106 106
 		}
107 107
 
108 108
 		return $imported;
109
-    }
109
+	}
110 110
 
111 111
 	/**
112 112
 	 * @since 2.0.8
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 		self::put_child_forms_first( $forms );
132 132
 
133 133
 		foreach ( $forms as $item ) {
134
-            $form = self::fill_form( $item );
134
+			$form = self::fill_form( $item );
135 135
 
136 136
 			self::update_custom_style_setting_on_import( $form );
137 137
 
138
-	        $this_form = self::maybe_get_form( $form );
138
+			$this_form = self::maybe_get_form( $form );
139 139
 
140 140
 			$old_id = false;
141 141
 			$form_fields = false;
@@ -147,25 +147,25 @@  discard block
 block discarded – undo
147 147
 				$form_fields = self::get_form_fields( $form_id );
148 148
 			} else {
149 149
 				$form_id = FrmForm::create( $form );
150
-		        if ( $form_id ) {
151
-		            $imported['imported']['forms']++;
152
-		            // Keep track of whether this specific form was updated or not
150
+				if ( $form_id ) {
151
+					$imported['imported']['forms']++;
152
+					// Keep track of whether this specific form was updated or not
153 153
 					$imported['form_status'][ $form_id ] = 'imported';
154 154
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
155
-		        }
155
+				}
156 156
 			}
157 157
 
158 158
 			self::import_xml_fields( $item->field, $form_id, $this_form, $form_fields, $imported );
159 159
 
160 160
 			self::delete_removed_fields( $form_fields );
161 161
 
162
-		    // Update field ids/keys to new ones
162
+			// Update field ids/keys to new ones
163 163
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
164 164
 
165 165
 			$imported['forms'][ (int) $item->id ] = $form_id;
166 166
 
167
-            // Send pre 2.0 form options through function that creates actions
168
-            self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
167
+			// Send pre 2.0 form options through function that creates actions
168
+			self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
169 169
 
170 170
 			do_action( 'frm_after_import_form', $form_id, $form );
171 171
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 		self::maybe_update_child_form_parent_id( $imported['forms'], $child_forms );
176 176
 
177 177
 		return $imported;
178
-    }
178
+	}
179 179
 
180 180
 	private static function fill_form( $item ) {
181 181
 		$form = array(
@@ -246,11 +246,11 @@  discard block
 block discarded – undo
246 246
 	}
247 247
 
248 248
 	/**
249
-	* Put child forms first so they will be imported before parents
250
-	*
251
-	* @since 2.0.16
252
-	* @param array $forms
253
-	*/
249
+	 * Put child forms first so they will be imported before parents
250
+	 *
251
+	 * @since 2.0.16
252
+	 * @param array $forms
253
+	 */
254 254
 	private static function put_child_forms_first( &$forms ) {
255 255
 		$child_forms = array();
256 256
 		$regular_forms = array();
@@ -269,13 +269,13 @@  discard block
 block discarded – undo
269 269
 	}
270 270
 
271 271
 	/**
272
-	* Keep track of all imported child forms
273
-	*
274
-	* @since 2.0.16
275
-	* @param int $form_id
276
-	* @param int $parent_form_id
277
-	* @param array $child_forms
278
-	*/
272
+	 * Keep track of all imported child forms
273
+	 *
274
+	 * @since 2.0.16
275
+	 * @param int $form_id
276
+	 * @param int $parent_form_id
277
+	 * @param array $child_forms
278
+	 */
279 279
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
280 280
 		if ( $parent_form_id ) {
281 281
 			$child_forms[ $form_id ] = $parent_form_id;
@@ -283,13 +283,13 @@  discard block
 block discarded – undo
283 283
 	}
284 284
 
285 285
 	/**
286
-	* Update the parent_form_id on imported child forms
287
-	* Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
288
-	*
289
-	* @since 2.0.6
290
-	* @param array $imported_forms
291
-	* @param array $child_forms
292
-	*/
286
+	 * Update the parent_form_id on imported child forms
287
+	 * Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
288
+	 *
289
+	 * @since 2.0.6
290
+	 * @param array $imported_forms
291
+	 * @param array $child_forms
292
+	 */
293 293
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
294 294
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
295 295
 
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 	}
304 304
 
305 305
 	/**
306
-	* Import all fields for a form
307
-	* @since 2.0.13
308
-	*
309
-	* TODO: Cut down on params
310
-	*/
306
+	 * Import all fields for a form
307
+	 * @since 2.0.13
308
+	 *
309
+	 * TODO: Cut down on params
310
+	 */
311 311
 	private static function import_xml_fields( $xml_fields, $form_id, $this_form, &$form_fields, &$imported ) {
312 312
 		$in_section = 0;
313 313
 
@@ -400,12 +400,12 @@  discard block
 block discarded – undo
400 400
 	}
401 401
 
402 402
 	/**
403
-	* Switch the form_select on a repeating field or embedded form if it needs to be switched
404
-	*
405
-	* @since 2.0.16
406
-	* @param array $f
407
-	* @param array $imported
408
-	*/
403
+	 * Switch the form_select on a repeating field or embedded form if it needs to be switched
404
+	 *
405
+	 * @since 2.0.16
406
+	 * @param array $f
407
+	 * @param array $imported
408
+	 */
409 409
 	private static function maybe_update_form_select( &$f, $imported ) {
410 410
 		if ( ! isset( $imported['forms'] ) ) {
411 411
 			return;
@@ -457,13 +457,13 @@  discard block
 block discarded – undo
457 457
 	}
458 458
 
459 459
 	/**
460
-	* Updates the custom style setting on import
461
-	* Convert the post slug to an ID
462
-	*
463
-	* @since 2.0.19
464
-	* @param array $form
465
-	*
466
-	*/
460
+	 * Updates the custom style setting on import
461
+	 * Convert the post slug to an ID
462
+	 *
463
+	 * @since 2.0.19
464
+	 * @param array $form
465
+	 *
466
+	 */
467 467
 	private static function update_custom_style_setting_on_import( &$form ) {
468 468
 		if ( ! isset( $form['options']['custom_style'] ) ) {
469 469
 			return;
@@ -517,16 +517,16 @@  discard block
 block discarded – undo
517 517
 	}
518 518
 
519 519
 	public static function import_xml_views( $views, $imported ) {
520
-        $imported['posts'] = array();
521
-        $form_action_type = FrmFormActionsController::$action_post_type;
520
+		$imported['posts'] = array();
521
+		$form_action_type = FrmFormActionsController::$action_post_type;
522 522
 
523
-        $post_types = array(
524
-            'frm_display' => 'views',
525
-            $form_action_type => 'actions',
526
-            'frm_styles'    => 'styles',
527
-        );
523
+		$post_types = array(
524
+			'frm_display' => 'views',
525
+			$form_action_type => 'actions',
526
+			'frm_styles'    => 'styles',
527
+		);
528 528
 
529
-        foreach ( $views as $item ) {
529
+		foreach ( $views as $item ) {
530 530
 			$post = array(
531 531
 				'post_title'    => (string) $item->title,
532 532
 				'post_name'     => (string) $item->post_name,
@@ -545,52 +545,52 @@  discard block
 block discarded – undo
545 545
 				'post_date'     => (string) $item->post_date,
546 546
 				'post_date_gmt' => (string) $item->post_date_gmt,
547 547
 				'ping_status'   => (string) $item->ping_status,
548
-                'postmeta'      => array(),
549
-                'tax_input'     => array(),
548
+				'postmeta'      => array(),
549
+				'tax_input'     => array(),
550 550
 			);
551 551
 
552
-            $old_id = $post['post_id'];
553
-            self::populate_post($post, $item, $imported);
552
+			$old_id = $post['post_id'];
553
+			self::populate_post($post, $item, $imported);
554 554
 
555 555
 			unset($item);
556 556
 
557 557
 			$post_id = false;
558
-            if ( $post['post_type'] == $form_action_type ) {
559
-                $action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
558
+			if ( $post['post_type'] == $form_action_type ) {
559
+				$action_control = FrmFormActionsController::get_form_actions( $post['post_excerpt'] );
560 560
 				if ( $action_control && is_object( $action_control ) ) {
561 561
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
562 562
 				}
563
-                unset($action_control);
564
-            } else if ( $post['post_type'] == 'frm_styles' ) {
565
-                // Properly encode post content before inserting the post
566
-                $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
563
+				unset($action_control);
564
+			} else if ( $post['post_type'] == 'frm_styles' ) {
565
+				// Properly encode post content before inserting the post
566
+				$post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
567 567
 				$custom_css = isset( $post['post_content']['custom_css'] ) ? $post['post_content']['custom_css'] : '';
568
-                $post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
568
+				$post['post_content'] = FrmAppHelper::prepare_and_encode( $post['post_content'] );
569 569
 
570
-                // Create/update post now
571
-                $post_id = wp_insert_post( $post );
570
+				// Create/update post now
571
+				$post_id = wp_insert_post( $post );
572 572
 				self::maybe_update_custom_css( $custom_css );
573
-            } else {
574
-                // Create/update post now
575
-                $post_id = wp_insert_post( $post );
576
-            }
573
+			} else {
574
+				// Create/update post now
575
+				$post_id = wp_insert_post( $post );
576
+			}
577 577
 
578
-            if ( ! is_numeric($post_id) ) {
579
-                continue;
580
-            }
578
+			if ( ! is_numeric($post_id) ) {
579
+				continue;
580
+			}
581 581
 
582
-            self::update_postmeta($post, $post_id);
582
+			self::update_postmeta($post, $post_id);
583 583
 
584
-            $this_type = 'posts';
584
+			$this_type = 'posts';
585 585
 			if ( isset( $post_types[ $post['post_type'] ] ) ) {
586 586
 				$this_type = $post_types[ $post['post_type'] ];
587
-            }
587
+			}
588 588
 
589
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
590
-                $imported['updated'][ $this_type ]++;
591
-            } else {
592
-                $imported['imported'][ $this_type ]++;
593
-            }
589
+			if ( isset($post['ID']) && $post_id == $post['ID'] ) {
590
+				$imported['updated'][ $this_type ]++;
591
+			} else {
592
+				$imported['imported'][ $this_type ]++;
593
+			}
594 594
 
595 595
 			$imported['posts'][ (int) $old_id ] = $post_id;
596 596
 
@@ -602,16 +602,16 @@  discard block
 block discarded – undo
602 602
 		self::maybe_update_stylesheet( $imported );
603 603
 
604 604
 		return $imported;
605
-    }
605
+	}
606 606
 
607
-    private static function populate_post( &$post, $item, $imported ) {
607
+	private static function populate_post( &$post, $item, $imported ) {
608 608
 		if ( isset($item->attachment_url) ) {
609 609
 			$post['attachment_url'] = (string) $item->attachment_url;
610 610
 		}
611 611
 
612 612
 		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
613
-		    // update to new form id
614
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
613
+			// update to new form id
614
+			$post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
615 615
 		}
616 616
 
617 617
 		// Don't allow default styles to take over a site's default style
@@ -620,145 +620,145 @@  discard block
 block discarded – undo
620 620
 		}
621 621
 
622 622
 		foreach ( $item->postmeta as $meta ) {
623
-		    self::populate_postmeta($post, $meta, $imported);
623
+			self::populate_postmeta($post, $meta, $imported);
624 624
 			unset($meta);
625 625
 		}
626 626
 
627
-        self::populate_taxonomies($post, $item);
627
+		self::populate_taxonomies($post, $item);
628 628
 
629
-        self::maybe_editing_post($post);
630
-    }
629
+		self::maybe_editing_post($post);
630
+	}
631 631
 
632
-    private static function populate_postmeta( &$post, $meta, $imported ) {
633
-        global $frm_duplicate_ids;
632
+	private static function populate_postmeta( &$post, $meta, $imported ) {
633
+		global $frm_duplicate_ids;
634 634
 
635
-	    $m = array(
635
+		$m = array(
636 636
 			'key'   => (string) $meta->meta_key,
637 637
 			'value' => (string) $meta->meta_value,
638 638
 		);
639 639
 
640 640
 		//switch old form and field ids to new ones
641 641
 		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
642
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
642
+			$m['value'] = $imported['forms'][ (int) $m['value'] ];
643 643
 		} else {
644
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
644
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
645 645
 
646
-		    if ( ! empty($frm_duplicate_ids) ) {
646
+			if ( ! empty($frm_duplicate_ids) ) {
647 647
 
648
-		        if ( $m['key'] == 'frm_dyncontent' ) {
649
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
650
-    		    } else if ( $m['key'] == 'frm_options' ) {
648
+				if ( $m['key'] == 'frm_dyncontent' ) {
649
+					$m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
650
+				} else if ( $m['key'] == 'frm_options' ) {
651 651
 
652 652
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
653 653
 						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
654 654
 							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
655
-    		            }
656
-    		        }
657
-
658
-                    $check_dup_array = array();
659
-    		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
660
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
661
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
662
-    		            } else if ( is_array( $m['value']['order_by'] ) ) {
663
-                            $check_dup_array[] = 'order_by';
664
-    		            }
665
-    		        }
666
-
667
-    		        if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
668
-    		            $check_dup_array[] = 'where';
669
-    		        }
670
-
671
-                    foreach ( $check_dup_array as $check_k ) {
655
+						}
656
+					}
657
+
658
+					$check_dup_array = array();
659
+					if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
660
+						if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
661
+							$m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
662
+						} else if ( is_array( $m['value']['order_by'] ) ) {
663
+							$check_dup_array[] = 'order_by';
664
+						}
665
+					}
666
+
667
+					if ( isset( $m['value']['where'] ) && ! empty( $m['value']['where'] ) ) {
668
+						$check_dup_array[] = 'where';
669
+					}
670
+
671
+					foreach ( $check_dup_array as $check_k ) {
672 672
 						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
673 673
 							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
674 674
 								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
675
-		                    }
676
-		                    unset($mk, $mv);
677
-		                }
678
-                    }
679
-    		    }
680
-		    }
675
+							}
676
+							unset($mk, $mv);
677
+						}
678
+					}
679
+				}
680
+			}
681 681
 		}
682 682
 
683 683
 		if ( ! is_array($m['value']) ) {
684
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
684
+			$m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
685 685
 		}
686 686
 
687 687
 		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
688
-    }
689
-
690
-    /**
691
-     * Add terms to post
692
-     * @param array $post by reference
693
-     * @param object $item The XML object data
694
-     */
695
-    private static function populate_taxonomies( &$post, $item ) {
688
+	}
689
+
690
+	/**
691
+	 * Add terms to post
692
+	 * @param array $post by reference
693
+	 * @param object $item The XML object data
694
+	 */
695
+	private static function populate_taxonomies( &$post, $item ) {
696 696
 		foreach ( $item->category as $c ) {
697 697
 			$att = $c->attributes();
698 698
 			if ( ! isset( $att['nicename'] ) ) {
699
-                continue;
700
-            }
701
-
702
-		    $taxonomy = (string) $att['domain'];
703
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
704
-		        $name = (string) $att['nicename'];
705
-		        $h_term = get_term_by('slug', $name, $taxonomy);
706
-		        if ( $h_term ) {
707
-		            $name = $h_term->term_id;
708
-		        }
709
-		        unset($h_term);
710
-		    } else {
711
-		        $name = (string) $c;
712
-		    }
699
+				continue;
700
+			}
701
+
702
+			$taxonomy = (string) $att['domain'];
703
+			if ( is_taxonomy_hierarchical($taxonomy) ) {
704
+				$name = (string) $att['nicename'];
705
+				$h_term = get_term_by('slug', $name, $taxonomy);
706
+				if ( $h_term ) {
707
+					$name = $h_term->term_id;
708
+				}
709
+				unset($h_term);
710
+			} else {
711
+				$name = (string) $c;
712
+			}
713 713
 
714 714
 			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
715 715
 				$post['tax_input'][ $taxonomy ] = array();
716 716
 			}
717 717
 
718 718
 			$post['tax_input'][ $taxonomy ][] = $name;
719
-		    unset($name);
719
+			unset($name);
720 720
 		}
721
-    }
721
+	}
722 722
 
723
-    /**
724
-     * Edit post if the key and created time match
725
-     */
726
-    private static function maybe_editing_post( &$post ) {
723
+	/**
724
+	 * Edit post if the key and created time match
725
+	 */
726
+	private static function maybe_editing_post( &$post ) {
727 727
 		$match_by = array(
728
-		    'post_type'     => $post['post_type'],
729
-		    'name'          => $post['post_name'],
730
-		    'post_status'   => $post['post_status'],
731
-		    'posts_per_page' => 1,
728
+			'post_type'     => $post['post_type'],
729
+			'name'          => $post['post_name'],
730
+			'post_status'   => $post['post_status'],
731
+			'posts_per_page' => 1,
732 732
 		);
733 733
 
734 734
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
735
-		    $match_by['include'] = $post['post_id'];
736
-		    unset($match_by['name']);
735
+			$match_by['include'] = $post['post_id'];
736
+			unset($match_by['name']);
737 737
 		}
738 738
 
739 739
 		$editing = get_posts($match_by);
740 740
 
741
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
742
-            // set the id of the post to edit
743
-            $post['ID'] = current($editing)->ID;
744
-        }
745
-    }
741
+		if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
742
+			// set the id of the post to edit
743
+			$post['ID'] = current($editing)->ID;
744
+		}
745
+	}
746 746
 
747
-    private static function update_postmeta( &$post, $post_id ) {
748
-        foreach ( $post['postmeta'] as $k => $v ) {
749
-            if ( '_edit_last' == $k ) {
747
+	private static function update_postmeta( &$post, $post_id ) {
748
+		foreach ( $post['postmeta'] as $k => $v ) {
749
+			if ( '_edit_last' == $k ) {
750 750
 				$v = FrmAppHelper::get_user_id_param( $v );
751
-            } else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
752
-                //change the attachment ID
751
+			} else if ( '_thumbnail_id' == $k && FrmAppHelper::pro_is_installed() ) {
752
+				//change the attachment ID
753 753
 				$field_obj = FrmFieldFactory::get_field_type( 'file' );
754 754
 				$v = $field_obj->get_file_id( $v );
755
-            }
755
+			}
756 756
 
757 757
 			update_post_meta( $post_id, $k, $v );
758 758
 
759 759
 			unset( $k, $v );
760
-        }
761
-    }
760
+		}
761
+	}
762 762
 
763 763
 	/**
764 764
 	 * If a template includes custom css, let's include it.
@@ -791,32 +791,32 @@  discard block
 block discarded – undo
791 791
 		}
792 792
 	}
793 793
 
794
-    /**
795
-     * @param string $message
796
-     */
794
+	/**
795
+	 * @param string $message
796
+	 */
797 797
 	public static function parse_message( $result, &$message, &$errors ) {
798 798
 		if ( is_wp_error( $result ) ) {
799
-            $errors[] = $result->get_error_message();
800
-        } else if ( ! $result ) {
801
-            return;
802
-        }
799
+			$errors[] = $result->get_error_message();
800
+		} else if ( ! $result ) {
801
+			return;
802
+		}
803 803
 
804 804
 		if ( ! is_array( $result ) ) {
805
-            $message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) );
806
-            return;
807
-        }
805
+			$message = is_string( $result ) ? $result : htmlentities( print_r( $result, 1 ) );
806
+			return;
807
+		}
808 808
 
809
-        $t_strings = array(
810
-            'imported'  => __( 'Imported', 'formidable' ),
811
-            'updated'   => __( 'Updated', 'formidable' ),
812
-        );
809
+		$t_strings = array(
810
+			'imported'  => __( 'Imported', 'formidable' ),
811
+			'updated'   => __( 'Updated', 'formidable' ),
812
+		);
813 813
 
814
-        $message = '<ul>';
815
-        foreach ( $result as $type => $results ) {
814
+		$message = '<ul>';
815
+		foreach ( $result as $type => $results ) {
816 816
 			if ( ! isset( $t_strings[ $type ] ) ) {
817
-                // only print imported and updated
818
-                continue;
819
-            }
817
+				// only print imported and updated
818
+				continue;
819
+			}
820 820
 
821 821
 			$s_message = array();
822 822
 			foreach ( $results as $k => $m ) {
@@ -829,34 +829,34 @@  discard block
 block discarded – undo
829 829
 				$message .= implode( ', ', $s_message );
830 830
 				$message .= '</li>';
831 831
 			}
832
-        }
832
+		}
833 833
 
834
-        if ( $message == '<ul>' ) {
835
-            $message = '';
836
-            $errors[] = __( 'Nothing was imported or updated', 'formidable' );
837
-        } else {
838
-            $message .= '</ul>';
839
-        }
840
-    }
834
+		if ( $message == '<ul>' ) {
835
+			$message = '';
836
+			$errors[] = __( 'Nothing was imported or updated', 'formidable' );
837
+		} else {
838
+			$message .= '</ul>';
839
+		}
840
+	}
841 841
 
842 842
 	public static function item_count_message( $m, $type, &$s_message ) {
843
-        if ( ! $m ) {
844
-            return;
845
-        }
846
-
847
-        $strings = array(
848
-            'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
849
-            'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
850
-            'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
851
-            'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
852
-            'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
853
-            'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
854
-            'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
855
-            'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
856
-        );
843
+		if ( ! $m ) {
844
+			return;
845
+		}
846
+
847
+		$strings = array(
848
+			'forms'     => sprintf( _n( '%1$s Form', '%1$s Forms', $m, 'formidable' ), $m ),
849
+			'fields'    => sprintf( _n( '%1$s Field', '%1$s Fields', $m, 'formidable' ), $m ),
850
+			'items'     => sprintf( _n( '%1$s Entry', '%1$s Entries', $m, 'formidable' ), $m ),
851
+			'views'     => sprintf( _n( '%1$s View', '%1$s Views', $m, 'formidable' ), $m ),
852
+			'posts'     => sprintf( _n( '%1$s Post', '%1$s Posts', $m, 'formidable' ), $m ),
853
+			'styles'     => sprintf( _n( '%1$s Style', '%1$s Styles', $m, 'formidable' ), $m ),
854
+			'terms'     => sprintf( _n( '%1$s Term', '%1$s Terms', $m, 'formidable' ), $m ),
855
+			'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
856
+		);
857 857
 
858 858
 		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
859
-    }
859
+	}
860 860
 
861 861
 	/**
862 862
 	 * Prepare the form options for export
@@ -894,9 +894,9 @@  discard block
 block discarded – undo
894 894
 			$str = utf8_encode( $str );
895 895
 		}
896 896
 
897
-        if ( is_numeric($str) ) {
898
-            return $str;
899
-        }
897
+		if ( is_numeric($str) ) {
898
+			return $str;
899
+		}
900 900
 
901 901
 		self::remove_invalid_characters_from_xml( $str );
902 902
 
@@ -917,54 +917,54 @@  discard block
 block discarded – undo
917 917
 		$str = str_replace( '\x1F', '', $str );
918 918
 	}
919 919
 
920
-    public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
921
-        // Get post type
922
-        $post_type = FrmFormActionsController::$action_post_type;
923
-
924
-        // Set up imported index, if not set up yet
925
-        if ( ! isset( $imported['imported']['actions'] ) ) {
926
-            $imported['imported']['actions'] = 0;
927
-        }
928
-
929
-        // Migrate post settings to action
930
-        self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
931
-
932
-        // Migrate email settings to action
933
-        self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
934
-    }
935
-
936
-    /**
937
-    * Migrate post settings to form action
938
-    *
939
-    * @param string $post_type
940
-    */
941
-    private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
942
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
943
-            return;
944
-        }
945
-
946
-        $new_action = array(
947
-            'post_type'     => $post_type,
948
-            'post_excerpt'  => 'wppost',
920
+	public static function migrate_form_settings_to_actions( $form_options, $form_id, &$imported = array(), $switch = false ) {
921
+		// Get post type
922
+		$post_type = FrmFormActionsController::$action_post_type;
923
+
924
+		// Set up imported index, if not set up yet
925
+		if ( ! isset( $imported['imported']['actions'] ) ) {
926
+			$imported['imported']['actions'] = 0;
927
+		}
928
+
929
+		// Migrate post settings to action
930
+		self::migrate_post_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
931
+
932
+		// Migrate email settings to action
933
+		self::migrate_email_settings_to_action( $form_options, $form_id, $post_type, $imported, $switch );
934
+	}
935
+
936
+	/**
937
+	 * Migrate post settings to form action
938
+	 *
939
+	 * @param string $post_type
940
+	 */
941
+	private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
942
+		if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
943
+			return;
944
+		}
945
+
946
+		$new_action = array(
947
+			'post_type'     => $post_type,
948
+			'post_excerpt'  => 'wppost',
949 949
 			'post_title'    => __( 'Create Posts', 'formidable' ),
950
-            'menu_order'    => $form_id,
951
-            'post_status'   => 'publish',
952
-            'post_content'  => array(),
950
+			'menu_order'    => $form_id,
951
+			'post_status'   => 'publish',
952
+			'post_content'  => array(),
953 953
 			'post_name'     => $form_id . '_wppost_1',
954
-        );
954
+		);
955 955
 
956 956
 		$post_settings = array( 'post_type', 'post_category', 'post_content', 'post_excerpt', 'post_title', 'post_name', 'post_date', 'post_status', 'post_custom_fields', 'post_password' );
957 957
 
958
-        foreach ( $post_settings as $post_setting ) {
958
+		foreach ( $post_settings as $post_setting ) {
959 959
 			if ( isset( $form_options[ $post_setting ] ) ) {
960 960
 				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
961
-            }
962
-            unset($post_setting);
963
-        }
961
+			}
962
+			unset($post_setting);
963
+		}
964 964
 
965 965
 		$new_action['event'] = array( 'create', 'update' );
966 966
 
967
-        if ( $switch ) {
967
+		if ( $switch ) {
968 968
 			// Fields with string or int saved
969 969
 			$basic_fields = array( 'post_title', 'post_content', 'post_excerpt', 'post_password', 'post_date', 'post_status' );
970 970
 
@@ -972,22 +972,22 @@  discard block
 block discarded – undo
972 972
 			$array_fields = array( 'post_category', 'post_custom_fields' );
973 973
 
974 974
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
975
-        }
976
-        $new_action['post_content'] = json_encode($new_action['post_content']);
975
+		}
976
+		$new_action['post_content'] = json_encode($new_action['post_content']);
977 977
 
978
-        $exists = get_posts( array(
979
-            'name'          => $new_action['post_name'],
980
-            'post_type'     => $new_action['post_type'],
981
-            'post_status'   => $new_action['post_status'],
982
-            'numberposts'   => 1,
983
-        ) );
978
+		$exists = get_posts( array(
979
+			'name'          => $new_action['post_name'],
980
+			'post_type'     => $new_action['post_type'],
981
+			'post_status'   => $new_action['post_status'],
982
+			'numberposts'   => 1,
983
+		) );
984 984
 
985
-        if ( ! $exists ) {
985
+		if ( ! $exists ) {
986 986
 			// this isn't an email, but we need to use a class that will always be included
987 987
 			FrmDb::save_json_post( $new_action );
988
-            $imported['imported']['actions']++;
989
-        }
990
-    }
988
+			$imported['imported']['actions']++;
989
+		}
990
+	}
991 991
 
992 992
 	/**
993 993
 	 * Switch old field IDs for new field IDs in emails and post
@@ -1000,88 +1000,88 @@  discard block
 block discarded – undo
1000 1000
 	 * @return string $post_content - new field IDs
1001 1001
 	 */
1002 1002
 	private static function switch_action_field_ids( $post_content, $basic_fields, $array_fields = array() ) {
1003
-        global $frm_duplicate_ids;
1003
+		global $frm_duplicate_ids;
1004 1004
 
1005
-        // If there aren't IDs that were switched, end now
1006
-        if ( ! $frm_duplicate_ids ) {
1007
-            return;
1008
-        }
1005
+		// If there aren't IDs that were switched, end now
1006
+		if ( ! $frm_duplicate_ids ) {
1007
+			return;
1008
+		}
1009 1009
 
1010
-        // Get old IDs
1011
-        $old = array_keys( $frm_duplicate_ids );
1010
+		// Get old IDs
1011
+		$old = array_keys( $frm_duplicate_ids );
1012 1012
 
1013
-        // Get new IDs
1014
-        $new = array_values( $frm_duplicate_ids );
1013
+		// Get new IDs
1014
+		$new = array_values( $frm_duplicate_ids );
1015 1015
 
1016
-        // Do a str_replace with each item to set the new IDs
1017
-        foreach ( $post_content as $key => $setting ) {
1018
-            if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1019
-                // Replace old IDs with new IDs
1016
+		// Do a str_replace with each item to set the new IDs
1017
+		foreach ( $post_content as $key => $setting ) {
1018
+			if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1019
+				// Replace old IDs with new IDs
1020 1020
 				$post_content[ $key ] = str_replace( $old, $new, $setting );
1021
-            } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1022
-                foreach ( $setting as $k => $val ) {
1023
-                    // Replace old IDs with new IDs
1021
+			} else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1022
+				foreach ( $setting as $k => $val ) {
1023
+					// Replace old IDs with new IDs
1024 1024
 					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
1025
-                }
1026
-            }
1027
-            unset( $key, $setting );
1028
-        }
1029
-        return $post_content;
1030
-    }
1031
-
1032
-    private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
1033
-        // No old notifications or autoresponders to carry over
1025
+				}
1026
+			}
1027
+			unset( $key, $setting );
1028
+		}
1029
+		return $post_content;
1030
+	}
1031
+
1032
+	private static function migrate_email_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
1033
+		// No old notifications or autoresponders to carry over
1034 1034
 		if ( ! isset( $form_options['auto_responder'] ) && ! isset( $form_options['notification'] ) && ! isset( $form_options['email_to'] ) ) {
1035
-            return;
1036
-        }
1035
+			return;
1036
+		}
1037 1037
 
1038
-        // Initialize notifications array
1039
-        $notifications = array();
1038
+		// Initialize notifications array
1039
+		$notifications = array();
1040 1040
 
1041
-        // Migrate regular notifications
1042
-        self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
1041
+		// Migrate regular notifications
1042
+		self::migrate_notifications_to_action( $form_options, $form_id, $notifications );
1043 1043
 
1044
-        // Migrate autoresponders
1045
-        self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
1044
+		// Migrate autoresponders
1045
+		self::migrate_autoresponder_to_action( $form_options, $form_id, $notifications );
1046 1046
 
1047
-        if ( empty( $notifications ) ) {
1048
-            return;
1049
-        }
1047
+		if ( empty( $notifications ) ) {
1048
+			return;
1049
+		}
1050 1050
 
1051
-        foreach ( $notifications as $new_notification ) {
1052
-            $new_notification['post_type']      = $post_type;
1053
-            $new_notification['post_excerpt']   = 'email';
1051
+		foreach ( $notifications as $new_notification ) {
1052
+			$new_notification['post_type']      = $post_type;
1053
+			$new_notification['post_excerpt']   = 'email';
1054 1054
 			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
1055
-            $new_notification['menu_order']     = $form_id;
1056
-            $new_notification['post_status']    = 'publish';
1055
+			$new_notification['menu_order']     = $form_id;
1056
+			$new_notification['post_status']    = 'publish';
1057 1057
 
1058
-            // Switch field IDs and keys, if needed
1059
-            if ( $switch ) {
1058
+			// Switch field IDs and keys, if needed
1059
+			if ( $switch ) {
1060 1060
 
1061 1061
 				// Switch field IDs in email conditional logic
1062 1062
 				self::switch_email_contition_field_ids( $new_notification['post_content'] );
1063 1063
 
1064 1064
 				// Switch all other field IDs in email
1065
-                $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1066
-            }
1067
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1068
-
1069
-            $exists = get_posts( array(
1070
-                'name'          => $new_notification['post_name'],
1071
-                'post_type'     => $new_notification['post_type'],
1072
-                'post_status'   => $new_notification['post_status'],
1073
-                'numberposts'   => 1,
1074
-            ) );
1075
-
1076
-            if ( empty($exists) ) {
1065
+				$new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1066
+			}
1067
+			$new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1068
+
1069
+			$exists = get_posts( array(
1070
+				'name'          => $new_notification['post_name'],
1071
+				'post_type'     => $new_notification['post_type'],
1072
+				'post_status'   => $new_notification['post_status'],
1073
+				'numberposts'   => 1,
1074
+			) );
1075
+
1076
+			if ( empty($exists) ) {
1077 1077
 				FrmDb::save_json_post( $new_notification );
1078
-                $imported['imported']['actions']++;
1079
-            }
1080
-            unset($new_notification);
1081
-        }
1078
+				$imported['imported']['actions']++;
1079
+			}
1080
+			unset($new_notification);
1081
+		}
1082 1082
 
1083 1083
 		self::remove_deprecated_notification_settings( $form_id, $form_options );
1084
-    }
1084
+	}
1085 1085
 
1086 1086
 	/**
1087 1087
 	 * Remove deprecated notification settings after migration
@@ -1101,17 +1101,17 @@  discard block
 block discarded – undo
1101 1101
 		FrmForm::update( $form_id, array( 'options' => $form_options ) );
1102 1102
 	}
1103 1103
 
1104
-    private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1105
-        if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1106
-            // add old settings into notification array
1104
+	private static function migrate_notifications_to_action( $form_options, $form_id, &$notifications ) {
1105
+		if ( ! isset( $form_options['notification'] ) && isset( $form_options['email_to'] ) && ! empty( $form_options['email_to'] ) ) {
1106
+			// add old settings into notification array
1107 1107
 			$form_options['notification'] = array( 0 => $form_options );
1108
-        } else if ( isset( $form_options['notification']['email_to'] ) ) {
1109
-            // make sure it's in the correct format
1108
+		} else if ( isset( $form_options['notification']['email_to'] ) ) {
1109
+			// make sure it's in the correct format
1110 1110
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1111
-        }
1111
+		}
1112 1112
 
1113
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1114
-            foreach ( $form_options['notification'] as $email_key => $notification ) {
1113
+		if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1114
+			foreach ( $form_options['notification'] as $email_key => $notification ) {
1115 1115
 
1116 1116
 				$atts = array(
1117 1117
 					'email_to'  => '',
@@ -1122,119 +1122,119 @@  discard block
 block discarded – undo
1122 1122
 					'email_key' => $email_key,
1123 1123
 				);
1124 1124
 
1125
-                // Format the email data
1126
-                self::format_email_data( $atts, $notification );
1125
+				// Format the email data
1126
+				self::format_email_data( $atts, $notification );
1127 1127
 
1128 1128
 				if ( isset( $notification['twilio'] ) && $notification['twilio'] ) {
1129 1129
 					do_action( 'frm_create_twilio_action', $atts, $notification );
1130 1130
 				}
1131 1131
 
1132
-                // Setup the new notification
1133
-                $new_notification = array();
1134
-                self::setup_new_notification( $new_notification, $notification, $atts );
1132
+				// Setup the new notification
1133
+				$new_notification = array();
1134
+				self::setup_new_notification( $new_notification, $notification, $atts );
1135 1135
 
1136
-                $notifications[] = $new_notification;
1137
-            }
1138
-        }
1139
-    }
1136
+				$notifications[] = $new_notification;
1137
+			}
1138
+		}
1139
+	}
1140 1140
 
1141
-    private static function format_email_data( &$atts, $notification ) {
1142
-        // Format email_to
1143
-        self::format_email_to_data( $atts, $notification );
1141
+	private static function format_email_data( &$atts, $notification ) {
1142
+		// Format email_to
1143
+		self::format_email_to_data( $atts, $notification );
1144 1144
 
1145
-        // Format the reply to email and name
1145
+		// Format the reply to email and name
1146 1146
 		$reply_fields = array(
1147 1147
 			'reply_to'      => '',
1148 1148
 			'reply_to_name' => '',
1149 1149
 		);
1150
-        foreach ( $reply_fields as $f => $val ) {
1150
+		foreach ( $reply_fields as $f => $val ) {
1151 1151
 			if ( isset( $notification[ $f ] ) ) {
1152 1152
 				$atts[ $f ] = $notification[ $f ];
1153 1153
 				if ( 'custom' == $notification[ $f ] ) {
1154 1154
 					$atts[ $f ] = $notification[ 'cust_' . $f ];
1155 1155
 				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1156 1156
 					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1157
-                }
1158
-            }
1159
-            unset( $f, $val );
1160
-        }
1157
+				}
1158
+			}
1159
+			unset( $f, $val );
1160
+		}
1161 1161
 
1162
-        // Format event
1162
+		// Format event
1163 1163
 		$atts['event'] = array( 'create' );
1164
-        if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1165
-            $atts['event'][] = 'update';
1166
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1164
+		if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1165
+			$atts['event'][] = 'update';
1166
+		} else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1167 1167
 			$atts['event'] = array( 'update' );
1168
-        }
1169
-    }
1168
+		}
1169
+	}
1170 1170
 
1171
-    private static function format_email_to_data( &$atts, $notification ) {
1172
-        if ( isset( $notification['email_to'] ) ) {
1171
+	private static function format_email_to_data( &$atts, $notification ) {
1172
+		if ( isset( $notification['email_to'] ) ) {
1173 1173
 			$atts['email_to'] = preg_split( '/ (,|;) /', $notification['email_to'] );
1174
-        } else {
1175
-            $atts['email_to'] = array();
1176
-        }
1174
+		} else {
1175
+			$atts['email_to'] = array();
1176
+		}
1177 1177
 
1178
-        if ( isset( $notification['also_email_to'] ) ) {
1179
-            $email_fields = (array) $notification['also_email_to'];
1180
-            $atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1181
-            unset( $email_fields );
1182
-        }
1178
+		if ( isset( $notification['also_email_to'] ) ) {
1179
+			$email_fields = (array) $notification['also_email_to'];
1180
+			$atts['email_to'] = array_merge( $email_fields, $atts['email_to'] );
1181
+			unset( $email_fields );
1182
+		}
1183 1183
 
1184
-        foreach ( $atts['email_to'] as $key => $email_field ) {
1184
+		foreach ( $atts['email_to'] as $key => $email_field ) {
1185 1185
 
1186
-            if ( is_numeric( $email_field ) ) {
1186
+			if ( is_numeric( $email_field ) ) {
1187 1187
 				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1188
-            }
1188
+			}
1189 1189
 
1190
-            if ( strpos( $email_field, '|') ) {
1191
-                $email_opt = explode( '|', $email_field );
1192
-                if ( isset( $email_opt[0] ) ) {
1190
+			if ( strpos( $email_field, '|') ) {
1191
+				$email_opt = explode( '|', $email_field );
1192
+				if ( isset( $email_opt[0] ) ) {
1193 1193
 					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1194
-                }
1195
-                unset( $email_opt );
1196
-            }
1197
-        }
1198
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1199
-    }
1200
-
1201
-    private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1202
-        // Set up new notification
1203
-        $new_notification = array(
1204
-            'post_content'  => array(
1205
-                'email_to'      => $atts['email_to'],
1206
-                'event'         => $atts['event'],
1207
-            ),
1194
+				}
1195
+				unset( $email_opt );
1196
+			}
1197
+		}
1198
+		$atts['email_to'] = implode(', ', $atts['email_to']);
1199
+	}
1200
+
1201
+	private static function setup_new_notification( &$new_notification, $notification, $atts ) {
1202
+		// Set up new notification
1203
+		$new_notification = array(
1204
+			'post_content'  => array(
1205
+				'email_to'      => $atts['email_to'],
1206
+				'event'         => $atts['event'],
1207
+			),
1208 1208
 			'post_name'         => $atts['form_id'] . '_email_' . $atts['email_key'],
1209
-        );
1209
+		);
1210 1210
 
1211
-        // Add more fields to the new notification
1212
-        $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1213
-        foreach ( $add_fields as $add_field ) {
1211
+		// Add more fields to the new notification
1212
+		$add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1213
+		foreach ( $add_fields as $add_field ) {
1214 1214
 			if ( isset( $notification[ $add_field ] ) ) {
1215 1215
 				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1216
-            } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1216
+			} else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1217 1217
 				$new_notification['post_content'][ $add_field ] = 0;
1218
-            } else {
1218
+			} else {
1219 1219
 				$new_notification['post_content'][ $add_field ] = '';
1220
-            }
1221
-            unset( $add_field );
1222
-        }
1220
+			}
1221
+			unset( $add_field );
1222
+		}
1223 1223
 
1224 1224
 		// Set reply to
1225 1225
 		$new_notification['post_content']['reply_to'] = $atts['reply_to'];
1226 1226
 
1227
-        // Set from
1227
+		// Set from
1228 1228
 		if ( ! empty( $atts['reply_to'] ) || ! empty( $atts['reply_to_name'] ) ) {
1229 1229
 			$new_notification['post_content']['from'] = ( empty( $atts['reply_to_name'] ) ? '[sitename]' : $atts['reply_to_name'] ) . ' <' . ( empty( $atts['reply_to'] ) ? '[admin_email]' : $atts['reply_to'] ) . '>';
1230
-        }
1231
-    }
1230
+		}
1231
+	}
1232 1232
 
1233 1233
 	/**
1234
-	* Switch field IDs in pre-2.0 email conditional logic
1235
-	*
1236
-	* @param $post_content array, pass by reference
1237
-	*/
1234
+	 * Switch field IDs in pre-2.0 email conditional logic
1235
+	 *
1236
+	 * @param $post_content array, pass by reference
1237
+	 */
1238 1238
 	private static function switch_email_contition_field_ids( &$post_content ) {
1239 1239
 		// Switch field IDs in conditional logic
1240 1240
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
 		}
1248 1248
 	}
1249 1249
 
1250
-    private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1250
+	private static function migrate_autoresponder_to_action( $form_options, $form_id, &$notifications ) {
1251 1251
 		if ( isset( $form_options['auto_responder'] ) && $form_options['auto_responder'] && isset( $form_options['ar_email_message'] ) && $form_options['ar_email_message'] ) {
1252 1252
 			// migrate autoresponder
1253 1253
 
@@ -1263,8 +1263,8 @@  discard block
 block discarded – undo
1263 1263
 				$email_field = '[' . $email_field . ']';
1264 1264
 			}
1265 1265
 
1266
-            $notification = $form_options;
1267
-            $new_notification2 = array(
1266
+			$notification = $form_options;
1267
+			$new_notification2 = array(
1268 1268
 				'post_content'  => array(
1269 1269
 					'email_message' => $notification['ar_email_message'],
1270 1270
 					'email_subject' => isset( $notification['ar_email_subject'] ) ? $notification['ar_email_subject'] : '',
@@ -1273,10 +1273,10 @@  discard block
 block discarded – undo
1273 1273
 					'inc_user_info' => 0,
1274 1274
 				),
1275 1275
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1276
-            );
1276
+			);
1277 1277
 
1278
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1279
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1278
+			$reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1279
+			$reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1280 1280
 
1281 1281
 			if ( ! empty( $reply_to ) ) {
1282 1282
 				$new_notification2['post_content']['reply_to'] = $reply_to;
@@ -1286,9 +1286,9 @@  discard block
 block discarded – undo
1286 1286
 				$new_notification2['post_content']['from'] = ( empty( $reply_to_name ) ? '[sitename]' : $reply_to_name ) . ' <' . ( empty( $reply_to ) ? '[admin_email]' : $reply_to ) . '>';
1287 1287
 			}
1288 1288
 
1289
-            $notifications[] = $new_notification2;
1290
-            unset( $new_notification2 );
1291
-        }
1292
-    }
1289
+			$notifications[] = $new_notification2;
1290
+			unset( $new_notification2 );
1291
+		}
1292
+	}
1293 1293
 }
1294 1294
 
Please login to merge, or discard this patch.
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
                 'slug'          => (string) $t->term_slug,
96 96
                 'description'   => (string) $t->term_description,
97 97
 				'parent'        => empty( $parent ) ? 0 : $parent,
98
-            ));
98
+            ) );
99 99
 
100 100
 			if ( $term && is_array( $term ) ) {
101
-                $imported['imported']['terms']++;
102
-				$imported['terms'][ (int) $t->term_id ] = $term['term_id'];
101
+                $imported['imported']['terms'] ++;
102
+				$imported['terms'][(int) $t->term_id] = $term['term_id'];
103 103
             }
104 104
 
105 105
 			unset( $term, $t );
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 			} else {
149 149
 				$form_id = FrmForm::create( $form );
150 150
 		        if ( $form_id ) {
151
-		            $imported['imported']['forms']++;
151
+		            $imported['imported']['forms'] ++;
152 152
 		            // Keep track of whether this specific form was updated or not
153
-					$imported['form_status'][ $form_id ] = 'imported';
153
+					$imported['form_status'][$form_id] = 'imported';
154 154
 					self::track_imported_child_forms( (int) $form_id, $form['parent_form_id'], $child_forms );
155 155
 		        }
156 156
 			}
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		    // Update field ids/keys to new ones
163 163
 			do_action( 'frm_after_duplicate_form', $form_id, $form, array( 'old_id' => $old_id ) );
164 164
 
165
-			$imported['forms'][ (int) $item->id ] = $form_id;
165
+			$imported['forms'][(int) $item->id] = $form_id;
166 166
 
167 167
             // Send pre 2.0 form options through function that creates actions
168 168
             self::migrate_form_settings_to_actions( $form['options'], $form_id, $imported, true );
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
 	private static function update_form( $this_form, $form, &$imported ) {
215 215
 		$form_id = $this_form->id;
216 216
 		FrmForm::update( $form_id, $form );
217
-		$imported['updated']['forms']++;
217
+		$imported['updated']['forms'] ++;
218 218
 		// Keep track of whether this specific form was updated or not
219
-		$imported['form_status'][ $form_id ] = 'updated';
219
+		$imported['form_status'][$form_id] = 'updated';
220 220
 	}
221 221
 
222 222
 	private static function get_form_fields( $form_id ) {
223 223
 		$form_fields = FrmField::get_all_for_form( $form_id, '', 'exclude', 'exclude' );
224 224
 		$old_fields = array();
225 225
 		foreach ( $form_fields as $f ) {
226
-			$old_fields[ $f->id ] = $f;
227
-			$old_fields[ $f->field_key ] = $f->id;
226
+			$old_fields[$f->id] = $f;
227
+			$old_fields[$f->field_key] = $f->id;
228 228
 			unset( $f );
229 229
 		}
230 230
 		$form_fields = $old_fields;
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	*/
279 279
 	private static function track_imported_child_forms( $form_id, $parent_form_id, &$child_forms ) {
280 280
 		if ( $parent_form_id ) {
281
-			$child_forms[ $form_id ] = $parent_form_id;
281
+			$child_forms[$form_id] = $parent_form_id;
282 282
 		}
283 283
 	}
284 284
 
@@ -293,9 +293,9 @@  discard block
 block discarded – undo
293 293
 	private static function maybe_update_child_form_parent_id( $imported_forms, $child_forms ) {
294 294
 		foreach ( $child_forms as $child_form_id => $old_parent_form_id ) {
295 295
 
296
-			if ( isset( $imported_forms[ $old_parent_form_id ] ) && $imported_forms[ $old_parent_form_id ] != $old_parent_form_id ) {
296
+			if ( isset( $imported_forms[$old_parent_form_id] ) && $imported_forms[$old_parent_form_id] != $old_parent_form_id ) {
297 297
 				// Update all children with this old parent_form_id
298
-				$new_parent_form_id = (int) $imported_forms[ $old_parent_form_id ];
298
+				$new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
299 299
 
300 300
 				FrmForm::update( $child_form_id, array( 'parent_form_id' => $new_parent_form_id ) );
301 301
 			}
@@ -329,25 +329,25 @@  discard block
 block discarded – undo
329 329
 
330 330
 			if ( ! empty( $this_form ) ) {
331 331
 				// check for field to edit by field id
332
-				if ( isset( $form_fields[ $f['id'] ] ) ) {
332
+				if ( isset( $form_fields[$f['id']] ) ) {
333 333
 					FrmField::update( $f['id'], $f );
334
-					$imported['updated']['fields']++;
334
+					$imported['updated']['fields'] ++;
335 335
 
336
-					unset( $form_fields[ $f['id'] ] );
336
+					unset( $form_fields[$f['id']] );
337 337
 
338 338
 					//unset old field key
339
-					if ( isset( $form_fields[ $f['field_key'] ] ) ) {
340
-						unset( $form_fields[ $f['field_key'] ] );
339
+					if ( isset( $form_fields[$f['field_key']] ) ) {
340
+						unset( $form_fields[$f['field_key']] );
341 341
 					}
342
-				} else if ( isset( $form_fields[ $f['field_key'] ] ) ) {
342
+				} else if ( isset( $form_fields[$f['field_key']] ) ) {
343 343
 					// check for field to edit by field key
344 344
 					unset( $f['id'] );
345 345
 
346
-					FrmField::update( $form_fields[ $f['field_key'] ], $f );
347
-					$imported['updated']['fields']++;
346
+					FrmField::update( $form_fields[$f['field_key']], $f );
347
+					$imported['updated']['fields'] ++;
348 348
 
349
-					unset( $form_fields[ $form_fields[ $f['field_key'] ] ] ); //unset old field id
350
-					unset( $form_fields[ $f['field_key'] ] ); //unset old field key
349
+					unset( $form_fields[$form_fields[$f['field_key']]] ); //unset old field id
350
+					unset( $form_fields[$f['field_key']] ); //unset old field key
351 351
 				} else {
352 352
 					// if no matching field id or key in this form, create the field
353 353
 					self::create_imported_field( $f, $imported );
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
 		if ( $f['type'] == 'form' || ( $f['type'] == 'divider' && FrmField::is_option_true( $f['field_options'], 'repeat' ) ) ) {
415 415
 			if ( FrmField::is_option_true( $f['field_options'], 'form_select' ) ) {
416 416
 				$form_select = (int) $f['field_options']['form_select'];
417
-				if ( isset( $imported['forms'][ $form_select ] ) ) {
418
-					$f['field_options']['form_select'] = $imported['forms'][ $form_select ];
417
+				if ( isset( $imported['forms'][$form_select] ) ) {
418
+					$f['field_options']['form_select'] = $imported['forms'][$form_select];
419 419
 				}
420 420
 			}
421 421
 		}
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 
436 436
 		if ( FrmField::is_option_true_in_array( $f['field_options'], 'get_values_form' ) ) {
437 437
 			$old_form = $f['field_options']['get_values_form'];
438
-			if ( isset( $imported['forms'][ $old_form ] ) ) {
439
-				$f['field_options']['get_values_form'] = $imported['forms'][ $old_form ];
438
+			if ( isset( $imported['forms'][$old_form] ) ) {
439
+				$f['field_options']['get_values_form'] = $imported['forms'][$old_form];
440 440
 			}
441 441
 		}
442 442
 	}
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	private static function create_imported_field( $f, &$imported ) {
452 452
 		$new_id = FrmField::create( $f );
453 453
 		if ( $new_id != false ) {
454
-			$imported['imported']['fields']++;
454
+			$imported['imported']['fields'] ++;
455 455
 			do_action( 'frm_after_field_is_imported', $f, $new_id );
456 456
 		}
457 457
 	}
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
 			);
551 551
 
552 552
             $old_id = $post['post_id'];
553
-            self::populate_post($post, $item, $imported);
553
+            self::populate_post( $post, $item, $imported );
554 554
 
555
-			unset($item);
555
+			unset( $item );
556 556
 
557 557
 			$post_id = false;
558 558
             if ( $post['post_type'] == $form_action_type ) {
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 				if ( $action_control && is_object( $action_control ) ) {
561 561
 					$post_id = $action_control->maybe_create_action( $post, $imported['form_status'] );
562 562
 				}
563
-                unset($action_control);
563
+                unset( $action_control );
564 564
             } else if ( $post['post_type'] == 'frm_styles' ) {
565 565
                 // Properly encode post content before inserting the post
566 566
                 $post['post_content'] = FrmAppHelper::maybe_json_decode( $post['post_content'] );
@@ -575,24 +575,24 @@  discard block
 block discarded – undo
575 575
                 $post_id = wp_insert_post( $post );
576 576
             }
577 577
 
578
-            if ( ! is_numeric($post_id) ) {
578
+            if ( ! is_numeric( $post_id ) ) {
579 579
                 continue;
580 580
             }
581 581
 
582
-            self::update_postmeta($post, $post_id);
582
+            self::update_postmeta( $post, $post_id );
583 583
 
584 584
             $this_type = 'posts';
585
-			if ( isset( $post_types[ $post['post_type'] ] ) ) {
586
-				$this_type = $post_types[ $post['post_type'] ];
585
+			if ( isset( $post_types[$post['post_type']] ) ) {
586
+				$this_type = $post_types[$post['post_type']];
587 587
             }
588 588
 
589
-            if ( isset($post['ID']) && $post_id == $post['ID'] ) {
590
-                $imported['updated'][ $this_type ]++;
589
+            if ( isset( $post['ID'] ) && $post_id == $post['ID'] ) {
590
+                $imported['updated'][$this_type] ++;
591 591
             } else {
592
-                $imported['imported'][ $this_type ]++;
592
+                $imported['imported'][$this_type] ++;
593 593
             }
594 594
 
595
-			$imported['posts'][ (int) $old_id ] = $post_id;
595
+			$imported['posts'][(int) $old_id] = $post_id;
596 596
 
597 597
 			do_action( 'frm_after_import_view', $post_id, $post );
598 598
 
@@ -605,13 +605,13 @@  discard block
 block discarded – undo
605 605
     }
606 606
 
607 607
     private static function populate_post( &$post, $item, $imported ) {
608
-		if ( isset($item->attachment_url) ) {
608
+		if ( isset( $item->attachment_url ) ) {
609 609
 			$post['attachment_url'] = (string) $item->attachment_url;
610 610
 		}
611 611
 
612
-		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][ (int) $post['menu_order'] ] ) ) {
612
+		if ( $post['post_type'] == FrmFormActionsController::$action_post_type && isset( $imported['forms'][(int) $post['menu_order']] ) ) {
613 613
 		    // update to new form id
614
-		    $post['menu_order'] = $imported['forms'][ (int) $post['menu_order'] ];
614
+		    $post['menu_order'] = $imported['forms'][(int) $post['menu_order']];
615 615
 		}
616 616
 
617 617
 		// Don't allow default styles to take over a site's default style
@@ -620,13 +620,13 @@  discard block
 block discarded – undo
620 620
 		}
621 621
 
622 622
 		foreach ( $item->postmeta as $meta ) {
623
-		    self::populate_postmeta($post, $meta, $imported);
624
-			unset($meta);
623
+		    self::populate_postmeta( $post, $meta, $imported );
624
+			unset( $meta );
625 625
 		}
626 626
 
627
-        self::populate_taxonomies($post, $item);
627
+        self::populate_taxonomies( $post, $item );
628 628
 
629
-        self::maybe_editing_post($post);
629
+        self::maybe_editing_post( $post );
630 630
     }
631 631
 
632 632
     private static function populate_postmeta( &$post, $meta, $imported ) {
@@ -638,27 +638,27 @@  discard block
 block discarded – undo
638 638
 		);
639 639
 
640 640
 		//switch old form and field ids to new ones
641
-		if ( $m['key'] == 'frm_form_id' && isset($imported['forms'][ (int) $m['value'] ]) ) {
642
-		    $m['value'] = $imported['forms'][ (int) $m['value'] ];
641
+		if ( $m['key'] == 'frm_form_id' && isset( $imported['forms'][(int) $m['value']] ) ) {
642
+		    $m['value'] = $imported['forms'][(int) $m['value']];
643 643
 		} else {
644
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
644
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
645 645
 
646
-		    if ( ! empty($frm_duplicate_ids) ) {
646
+		    if ( ! empty( $frm_duplicate_ids ) ) {
647 647
 
648 648
 		        if ( $m['key'] == 'frm_dyncontent' ) {
649
-		            $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
649
+		            $m['value'] = FrmFieldsHelper::switch_field_ids( $m['value'] );
650 650
     		    } else if ( $m['key'] == 'frm_options' ) {
651 651
 
652 652
 					foreach ( array( 'date_field_id', 'edate_field_id' ) as $setting_name ) {
653
-						if ( isset( $m['value'][ $setting_name ] ) && is_numeric( $m['value'][ $setting_name ] ) && isset( $frm_duplicate_ids[ $m['value'][ $setting_name ] ] ) ) {
654
-							$m['value'][ $setting_name ] = $frm_duplicate_ids[ $m['value'][ $setting_name ] ];
653
+						if ( isset( $m['value'][$setting_name] ) && is_numeric( $m['value'][$setting_name] ) && isset( $frm_duplicate_ids[$m['value'][$setting_name]] ) ) {
654
+							$m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]];
655 655
     		            }
656 656
     		        }
657 657
 
658 658
                     $check_dup_array = array();
659 659
     		        if ( isset( $m['value']['order_by'] ) && ! empty( $m['value']['order_by'] ) ) {
660
-    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[ $m['value']['order_by'] ] ) ) {
661
-    		                $m['value']['order_by'] = $frm_duplicate_ids[ $m['value']['order_by'] ];
660
+    		            if ( is_numeric( $m['value']['order_by'] ) && isset( $frm_duplicate_ids[$m['value']['order_by']] ) ) {
661
+    		                $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']];
662 662
     		            } else if ( is_array( $m['value']['order_by'] ) ) {
663 663
                             $check_dup_array[] = 'order_by';
664 664
     		            }
@@ -669,22 +669,22 @@  discard block
 block discarded – undo
669 669
     		        }
670 670
 
671 671
                     foreach ( $check_dup_array as $check_k ) {
672
-						foreach ( (array) $m['value'][ $check_k ] as $mk => $mv ) {
673
-							if ( isset( $frm_duplicate_ids[ $mv ] ) ) {
674
-								$m['value'][ $check_k ][ $mk ] = $frm_duplicate_ids[ $mv ];
672
+						foreach ( (array) $m['value'][$check_k] as $mk => $mv ) {
673
+							if ( isset( $frm_duplicate_ids[$mv] ) ) {
674
+								$m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv];
675 675
 		                    }
676
-		                    unset($mk, $mv);
676
+		                    unset( $mk, $mv );
677 677
 		                }
678 678
                     }
679 679
     		    }
680 680
 		    }
681 681
 		}
682 682
 
683
-		if ( ! is_array($m['value']) ) {
684
-		    $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
683
+		if ( ! is_array( $m['value'] ) ) {
684
+		    $m['value'] = FrmAppHelper::maybe_json_decode( $m['value'] );
685 685
 		}
686 686
 
687
-		$post['postmeta'][ (string) $meta->meta_key ] = $m['value'];
687
+		$post['postmeta'][(string) $meta->meta_key] = $m['value'];
688 688
     }
689 689
 
690 690
     /**
@@ -700,23 +700,23 @@  discard block
 block discarded – undo
700 700
             }
701 701
 
702 702
 		    $taxonomy = (string) $att['domain'];
703
-		    if ( is_taxonomy_hierarchical($taxonomy) ) {
703
+		    if ( is_taxonomy_hierarchical( $taxonomy ) ) {
704 704
 		        $name = (string) $att['nicename'];
705
-		        $h_term = get_term_by('slug', $name, $taxonomy);
705
+		        $h_term = get_term_by( 'slug', $name, $taxonomy );
706 706
 		        if ( $h_term ) {
707 707
 		            $name = $h_term->term_id;
708 708
 		        }
709
-		        unset($h_term);
709
+		        unset( $h_term );
710 710
 		    } else {
711 711
 		        $name = (string) $c;
712 712
 		    }
713 713
 
714
-			if ( ! isset( $post['tax_input'][ $taxonomy ] ) ) {
715
-				$post['tax_input'][ $taxonomy ] = array();
714
+			if ( ! isset( $post['tax_input'][$taxonomy] ) ) {
715
+				$post['tax_input'][$taxonomy] = array();
716 716
 			}
717 717
 
718
-			$post['tax_input'][ $taxonomy ][] = $name;
719
-		    unset($name);
718
+			$post['tax_input'][$taxonomy][] = $name;
719
+		    unset( $name );
720 720
 		}
721 721
     }
722 722
 
@@ -733,14 +733,14 @@  discard block
 block discarded – undo
733 733
 
734 734
 		if ( in_array( $post['post_status'], array( 'trash', 'draft' ) ) ) {
735 735
 		    $match_by['include'] = $post['post_id'];
736
-		    unset($match_by['name']);
736
+		    unset( $match_by['name'] );
737 737
 		}
738 738
 
739
-		$editing = get_posts($match_by);
739
+		$editing = get_posts( $match_by );
740 740
 
741
-        if ( ! empty($editing) && current($editing)->post_date == $post['post_date'] ) {
741
+        if ( ! empty( $editing ) && current( $editing )->post_date == $post['post_date'] ) {
742 742
             // set the id of the post to edit
743
-            $post['ID'] = current($editing)->ID;
743
+            $post['ID'] = current( $editing )->ID;
744 744
         }
745 745
     }
746 746
 
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 
814 814
         $message = '<ul>';
815 815
         foreach ( $result as $type => $results ) {
816
-			if ( ! isset( $t_strings[ $type ] ) ) {
816
+			if ( ! isset( $t_strings[$type] ) ) {
817 817
                 // only print imported and updated
818 818
                 continue;
819 819
             }
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 			}
826 826
 
827 827
 			if ( ! empty( $s_message ) ) {
828
-				$message .= '<li><strong>' . $t_strings[ $type ] . ':</strong> ';
828
+				$message .= '<li><strong>' . $t_strings[$type] . ':</strong> ';
829 829
 				$message .= implode( ', ', $s_message );
830 830
 				$message .= '</li>';
831 831
 			}
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
             'actions'   => sprintf( _n( '%1$s Form Action', '%1$s Form Actions', $m, 'formidable' ), $m ),
856 856
         );
857 857
 
858
-		$s_message[] = isset( $strings[ $type ] ) ? $strings[ $type ] : ' ' . $m . ' ' . ucfirst( $type );
858
+		$s_message[] = isset( $strings[$type] ) ? $strings[$type] : ' ' . $m . ' ' . ucfirst( $type );
859 859
     }
860 860
 
861 861
 	/**
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 			$str = utf8_encode( $str );
895 895
 		}
896 896
 
897
-        if ( is_numeric($str) ) {
897
+        if ( is_numeric( $str ) ) {
898 898
             return $str;
899 899
         }
900 900
 
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
     * @param string $post_type
940 940
     */
941 941
     private static function migrate_post_settings_to_action( $form_options, $form_id, $post_type, &$imported, $switch ) {
942
-        if ( ! isset($form_options['create_post']) || ! $form_options['create_post'] ) {
942
+        if ( ! isset( $form_options['create_post'] ) || ! $form_options['create_post'] ) {
943 943
             return;
944 944
         }
945 945
 
@@ -956,10 +956,10 @@  discard block
 block discarded – undo
956 956
 		$post_settings = array( 'post_type', 'post_category', 'post_content', 'post_excerpt', 'post_title', 'post_name', 'post_date', 'post_status', 'post_custom_fields', 'post_password' );
957 957
 
958 958
         foreach ( $post_settings as $post_setting ) {
959
-			if ( isset( $form_options[ $post_setting ] ) ) {
960
-				$new_action['post_content'][ $post_setting ] = $form_options[ $post_setting ];
959
+			if ( isset( $form_options[$post_setting] ) ) {
960
+				$new_action['post_content'][$post_setting] = $form_options[$post_setting];
961 961
             }
962
-            unset($post_setting);
962
+            unset( $post_setting );
963 963
         }
964 964
 
965 965
 		$new_action['event'] = array( 'create', 'update' );
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
 
974 974
 			$new_action['post_content'] = self::switch_action_field_ids( $new_action['post_content'], $basic_fields, $array_fields );
975 975
         }
976
-        $new_action['post_content'] = json_encode($new_action['post_content']);
976
+        $new_action['post_content'] = json_encode( $new_action['post_content'] );
977 977
 
978 978
         $exists = get_posts( array(
979 979
             'name'          => $new_action['post_name'],
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
         if ( ! $exists ) {
986 986
 			// this isn't an email, but we need to use a class that will always be included
987 987
 			FrmDb::save_json_post( $new_action );
988
-            $imported['imported']['actions']++;
988
+            $imported['imported']['actions'] ++;
989 989
         }
990 990
     }
991 991
 
@@ -1017,11 +1017,11 @@  discard block
 block discarded – undo
1017 1017
         foreach ( $post_content as $key => $setting ) {
1018 1018
             if ( ! is_array( $setting ) && in_array( $key, $basic_fields ) ) {
1019 1019
                 // Replace old IDs with new IDs
1020
-				$post_content[ $key ] = str_replace( $old, $new, $setting );
1020
+				$post_content[$key] = str_replace( $old, $new, $setting );
1021 1021
             } else if ( is_array( $setting ) && in_array( $key, $array_fields ) ) {
1022 1022
                 foreach ( $setting as $k => $val ) {
1023 1023
                     // Replace old IDs with new IDs
1024
-					$post_content[ $key ][ $k ] = str_replace( $old, $new, $val );
1024
+					$post_content[$key][$k] = str_replace( $old, $new, $val );
1025 1025
                 }
1026 1026
             }
1027 1027
             unset( $key, $setting );
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
         foreach ( $notifications as $new_notification ) {
1052 1052
             $new_notification['post_type']      = $post_type;
1053 1053
             $new_notification['post_excerpt']   = 'email';
1054
-			$new_notification['post_title']     = __( 'Email Notification', 'formidable' );
1054
+			$new_notification['post_title'] = __( 'Email Notification', 'formidable' );
1055 1055
             $new_notification['menu_order']     = $form_id;
1056 1056
             $new_notification['post_status']    = 'publish';
1057 1057
 
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
 				// Switch all other field IDs in email
1065 1065
                 $new_notification['post_content'] = FrmFieldsHelper::switch_field_ids( $new_notification['post_content'] );
1066 1066
             }
1067
-            $new_notification['post_content']   = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1067
+            $new_notification['post_content'] = FrmAppHelper::prepare_and_encode( $new_notification['post_content'] );
1068 1068
 
1069 1069
             $exists = get_posts( array(
1070 1070
                 'name'          => $new_notification['post_name'],
@@ -1073,11 +1073,11 @@  discard block
 block discarded – undo
1073 1073
                 'numberposts'   => 1,
1074 1074
             ) );
1075 1075
 
1076
-            if ( empty($exists) ) {
1076
+            if ( empty( $exists ) ) {
1077 1077
 				FrmDb::save_json_post( $new_notification );
1078
-                $imported['imported']['actions']++;
1078
+                $imported['imported']['actions'] ++;
1079 1079
             }
1080
-            unset($new_notification);
1080
+            unset( $new_notification );
1081 1081
         }
1082 1082
 
1083 1083
 		self::remove_deprecated_notification_settings( $form_id, $form_options );
@@ -1094,8 +1094,8 @@  discard block
 block discarded – undo
1094 1094
 	private static function remove_deprecated_notification_settings( $form_id, $form_options ) {
1095 1095
 		$delete_settings = array( 'notification', 'autoresponder', 'email_to' );
1096 1096
 		foreach ( $delete_settings as $index ) {
1097
-			if ( isset( $form_options[ $index ] ) ) {
1098
-				unset( $form_options[ $index ] );
1097
+			if ( isset( $form_options[$index] ) ) {
1098
+				unset( $form_options[$index] );
1099 1099
 			}
1100 1100
 		}
1101 1101
 		FrmForm::update( $form_id, array( 'options' => $form_options ) );
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
 			$form_options['notification'] = array( 0 => $form_options['notification'] );
1111 1111
         }
1112 1112
 
1113
-        if ( isset( $form_options['notification'] ) && is_array($form_options['notification']) ) {
1113
+        if ( isset( $form_options['notification'] ) && is_array( $form_options['notification'] ) ) {
1114 1114
             foreach ( $form_options['notification'] as $email_key => $notification ) {
1115 1115
 
1116 1116
 				$atts = array(
@@ -1148,12 +1148,12 @@  discard block
 block discarded – undo
1148 1148
 			'reply_to_name' => '',
1149 1149
 		);
1150 1150
         foreach ( $reply_fields as $f => $val ) {
1151
-			if ( isset( $notification[ $f ] ) ) {
1152
-				$atts[ $f ] = $notification[ $f ];
1153
-				if ( 'custom' == $notification[ $f ] ) {
1154
-					$atts[ $f ] = $notification[ 'cust_' . $f ];
1155
-				} else if ( is_numeric( $atts[ $f ] ) && ! empty( $atts[ $f ] ) ) {
1156
-					$atts[ $f ] = '[' . $atts[ $f ] . ']';
1151
+			if ( isset( $notification[$f] ) ) {
1152
+				$atts[$f] = $notification[$f];
1153
+				if ( 'custom' == $notification[$f] ) {
1154
+					$atts[$f] = $notification['cust_' . $f];
1155
+				} else if ( is_numeric( $atts[$f] ) && ! empty( $atts[$f] ) ) {
1156
+					$atts[$f] = '[' . $atts[$f] . ']';
1157 1157
                 }
1158 1158
             }
1159 1159
             unset( $f, $val );
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 		$atts['event'] = array( 'create' );
1164 1164
         if ( isset( $notification['update_email'] ) && 1 == $notification['update_email'] ) {
1165 1165
             $atts['event'][] = 'update';
1166
-        } else if ( isset($notification['update_email']) && 2 == $notification['update_email'] ) {
1166
+        } else if ( isset( $notification['update_email'] ) && 2 == $notification['update_email'] ) {
1167 1167
 			$atts['event'] = array( 'update' );
1168 1168
         }
1169 1169
     }
@@ -1184,18 +1184,18 @@  discard block
 block discarded – undo
1184 1184
         foreach ( $atts['email_to'] as $key => $email_field ) {
1185 1185
 
1186 1186
             if ( is_numeric( $email_field ) ) {
1187
-				$atts['email_to'][ $key ] = '[' . $email_field . ']';
1187
+				$atts['email_to'][$key] = '[' . $email_field . ']';
1188 1188
             }
1189 1189
 
1190
-            if ( strpos( $email_field, '|') ) {
1190
+            if ( strpos( $email_field, '|' ) ) {
1191 1191
                 $email_opt = explode( '|', $email_field );
1192 1192
                 if ( isset( $email_opt[0] ) ) {
1193
-					$atts['email_to'][ $key ] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1193
+					$atts['email_to'][$key] = '[' . $email_opt[0] . ' show=' . $email_opt[1] . ']';
1194 1194
                 }
1195 1195
                 unset( $email_opt );
1196 1196
             }
1197 1197
         }
1198
-        $atts['email_to'] = implode(', ', $atts['email_to']);
1198
+        $atts['email_to'] = implode( ', ', $atts['email_to'] );
1199 1199
     }
1200 1200
 
1201 1201
     private static function setup_new_notification( &$new_notification, $notification, $atts ) {
@@ -1211,12 +1211,12 @@  discard block
 block discarded – undo
1211 1211
         // Add more fields to the new notification
1212 1212
         $add_fields = array( 'email_message', 'email_subject', 'plain_text', 'inc_user_info', 'conditions' );
1213 1213
         foreach ( $add_fields as $add_field ) {
1214
-			if ( isset( $notification[ $add_field ] ) ) {
1215
-				$new_notification['post_content'][ $add_field ] = $notification[ $add_field ];
1214
+			if ( isset( $notification[$add_field] ) ) {
1215
+				$new_notification['post_content'][$add_field] = $notification[$add_field];
1216 1216
             } else if ( in_array( $add_field, array( 'plain_text', 'inc_user_info' ) ) ) {
1217
-				$new_notification['post_content'][ $add_field ] = 0;
1217
+				$new_notification['post_content'][$add_field] = 0;
1218 1218
             } else {
1219
-				$new_notification['post_content'][ $add_field ] = '';
1219
+				$new_notification['post_content'][$add_field] = '';
1220 1220
             }
1221 1221
             unset( $add_field );
1222 1222
         }
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
 		if ( isset( $post_content['conditions'] ) && is_array( $post_content['conditions'] ) ) {
1241 1241
 			foreach ( $post_content['conditions'] as $email_key => $val ) {
1242 1242
 				if ( is_numeric( $email_key ) ) {
1243
-					$post_content['conditions'][ $email_key ] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1243
+					$post_content['conditions'][$email_key] = self::switch_action_field_ids( $val, array( 'hide_field' ) );
1244 1244
 				}
1245 1245
 				unset( $email_key, $val );
1246 1246
 			}
@@ -1275,8 +1275,8 @@  discard block
 block discarded – undo
1275 1275
 				'post_name'     => $form_id . '_email_' . count( $notifications ),
1276 1276
             );
1277 1277
 
1278
-            $reply_to = isset($notification['ar_reply_to']) ? $notification['ar_reply_to'] : '';
1279
-            $reply_to_name = isset($notification['ar_reply_to_name']) ? $notification['ar_reply_to_name'] : '';
1278
+            $reply_to = isset( $notification['ar_reply_to'] ) ? $notification['ar_reply_to'] : '';
1279
+            $reply_to_name = isset( $notification['ar_reply_to_name'] ) ? $notification['ar_reply_to_name'] : '';
1280 1280
 
1281 1281
 			if ( ! empty( $reply_to ) ) {
1282 1282
 				$new_notification2['post_content']['reply_to'] = $reply_to;
Please login to merge, or discard this patch.
classes/helpers/FrmAppHelper.php 2 patches
Indentation   +615 added lines, -615 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
 	 */
14 14
 	public static $plug_version = '3.01';
15 15
 
16
-    /**
17
-     * @since 1.07.02
18
-     *
19
-     * @param none
20
-     * @return string The version of this plugin
21
-     */
22
-    public static function plugin_version() {
23
-        return self::$plug_version;
24
-    }
16
+	/**
17
+	 * @since 1.07.02
18
+	 *
19
+	 * @param none
20
+	 * @return string The version of this plugin
21
+	 */
22
+	public static function plugin_version() {
23
+		return self::$plug_version;
24
+	}
25 25
 
26 26
 	public static function plugin_folder() {
27 27
 		return basename( self::plugin_path() );
@@ -31,29 +31,29 @@  discard block
 block discarded – undo
31 31
 		return dirname( dirname( dirname( __FILE__ ) ) );
32 32
 	}
33 33
 
34
-    public static function plugin_url() {
35
-        //prevously FRM_URL constant
34
+	public static function plugin_url() {
35
+		//prevously FRM_URL constant
36 36
 		return plugins_url( '', self::plugin_path() . '/formidable.php' );
37
-    }
37
+	}
38 38
 
39 39
 	public static function relative_plugin_url() {
40 40
 		return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
41 41
 	}
42 42
 
43
-    /**
44
-     * @return string Site URL
45
-     */
46
-    public static function site_url() {
47
-        return site_url();
48
-    }
49
-
50
-    /**
51
-     * Get the name of this site
52
-     * Used for [sitename] shortcode
53
-     *
54
-     * @since 2.0
55
-     * @return string
56
-     */
43
+	/**
44
+	 * @return string Site URL
45
+	 */
46
+	public static function site_url() {
47
+		return site_url();
48
+	}
49
+
50
+	/**
51
+	 * Get the name of this site
52
+	 * Used for [sitename] shortcode
53
+	 *
54
+	 * @since 2.0
55
+	 * @return string
56
+	 */
57 57
 	public static function site_name() {
58 58
 		return get_option( 'blogname' );
59 59
 	}
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
 		return absint( apply_filters( 'frm_affiliate_id', 0 ) );
72 72
 	}
73 73
 
74
-    /**
75
-     * Get the Formidable settings
76
-     *
77
-     * @since 2.0
78
-     *
79
-     * @param None
80
-     * @return FrmSettings $frm_setings
81
-     */
74
+	/**
75
+	 * Get the Formidable settings
76
+	 *
77
+	 * @since 2.0
78
+	 *
79
+	 * @param None
80
+	 * @return FrmSettings $frm_setings
81
+	 */
82 82
 	public static function get_settings() {
83 83
 		global $frm_settings;
84 84
 		if ( empty( $frm_settings ) ) {
@@ -119,50 +119,50 @@  discard block
 block discarded – undo
119 119
 		return $is_formidable;
120 120
 	}
121 121
 
122
-    /**
123
-     * Check for certain page in Formidable settings
124
-     *
125
-     * @since 2.0
126
-     *
127
-     * @param string $page The name of the page to check
128
-     * @return boolean
129
-     */
122
+	/**
123
+	 * Check for certain page in Formidable settings
124
+	 *
125
+	 * @since 2.0
126
+	 *
127
+	 * @param string $page The name of the page to check
128
+	 * @return boolean
129
+	 */
130 130
 	public static function is_admin_page( $page = 'formidable' ) {
131
-        global $pagenow;
131
+		global $pagenow;
132 132
 		$get_page = self::simple_get( 'page', 'sanitize_title' );
133
-        if ( $pagenow ) {
133
+		if ( $pagenow ) {
134 134
 			// allow this to be true during ajax load i.e. ajax form builder loading
135 135
 			return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page;
136
-        }
136
+		}
137 137
 
138 138
 		return is_admin() && $get_page == $page;
139
-    }
140
-
141
-    /**
142
-     * Check for the form preview page
143
-     *
144
-     * @since 2.0
145
-     *
146
-     * @param None
147
-     * @return boolean
148
-     */
149
-    public static function is_preview_page() {
150
-        global $pagenow;
139
+	}
140
+
141
+	/**
142
+	 * Check for the form preview page
143
+	 *
144
+	 * @since 2.0
145
+	 *
146
+	 * @param None
147
+	 * @return boolean
148
+	 */
149
+	public static function is_preview_page() {
150
+		global $pagenow;
151 151
 		$action = FrmAppHelper::simple_get( 'action', 'sanitize_title' );
152 152
 		return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
153
-    }
154
-
155
-    /**
156
-     * Check for ajax except the form preview page
157
-     *
158
-     * @since 2.0
159
-     *
160
-     * @param None
161
-     * @return boolean
162
-     */
163
-    public static function doing_ajax() {
164
-        return self::wp_doing_ajax() && ! self::is_preview_page();
165
-    }
153
+	}
154
+
155
+	/**
156
+	 * Check for ajax except the form preview page
157
+	 *
158
+	 * @since 2.0
159
+	 *
160
+	 * @param None
161
+	 * @return boolean
162
+	 */
163
+	public static function doing_ajax() {
164
+		return self::wp_doing_ajax() && ! self::is_preview_page();
165
+	}
166 166
 
167 167
 	public static function js_suffix() {
168 168
 		return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
@@ -189,81 +189,81 @@  discard block
 block discarded – undo
189 189
 		return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
190 190
 	}
191 191
 
192
-    /**
193
-     * Check if on an admin page
194
-     *
195
-     * @since 2.0
196
-     *
197
-     * @param None
198
-     * @return boolean
199
-     */
200
-    public static function is_admin() {
201
-        return is_admin() && ! self::wp_doing_ajax();
202
-    }
203
-
204
-    /**
205
-     * Check if value contains blank value or empty array
206
-     *
207
-     * @since 2.0
208
-     * @param mixed $value - value to check
192
+	/**
193
+	 * Check if on an admin page
194
+	 *
195
+	 * @since 2.0
196
+	 *
197
+	 * @param None
198
+	 * @return boolean
199
+	 */
200
+	public static function is_admin() {
201
+		return is_admin() && ! self::wp_doing_ajax();
202
+	}
203
+
204
+	/**
205
+	 * Check if value contains blank value or empty array
206
+	 *
207
+	 * @since 2.0
208
+	 * @param mixed $value - value to check
209 209
 	 * @param string
210
-     * @return boolean
211
-     */
212
-    public static function is_empty_value( $value, $empty = '' ) {
213
-        return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
214
-    }
215
-
216
-    public static function is_not_empty_value( $value, $empty = '' ) {
217
-        return ! self::is_empty_value( $value, $empty );
218
-    }
219
-
220
-    /**
221
-     * Get any value from the $_SERVER
222
-     *
223
-     * @since 2.0
224
-     * @param string $value
225
-     * @return string
226
-     */
210
+	 * @return boolean
211
+	 */
212
+	public static function is_empty_value( $value, $empty = '' ) {
213
+		return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
214
+	}
215
+
216
+	public static function is_not_empty_value( $value, $empty = '' ) {
217
+		return ! self::is_empty_value( $value, $empty );
218
+	}
219
+
220
+	/**
221
+	 * Get any value from the $_SERVER
222
+	 *
223
+	 * @since 2.0
224
+	 * @param string $value
225
+	 * @return string
226
+	 */
227 227
 	public static function get_server_value( $value ) {
228
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
229
-    }
230
-
231
-    /**
232
-     * Check for the IP address in several places
233
-     * Used by [ip] shortcode
234
-     *
235
-     * @return string The IP address of the current user
236
-     */
237
-    public static function get_ip_address() {
228
+		return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
229
+	}
230
+
231
+	/**
232
+	 * Check for the IP address in several places
233
+	 * Used by [ip] shortcode
234
+	 *
235
+	 * @return string The IP address of the current user
236
+	 */
237
+	public static function get_ip_address() {
238 238
 		$ip = '';
239 239
 		foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) {
240
-            if ( ! isset( $_SERVER[ $key ] ) ) {
241
-                continue;
242
-            }
240
+			if ( ! isset( $_SERVER[ $key ] ) ) {
241
+				continue;
242
+			}
243 243
 
244
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
244
+			foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
245 245
 				$ip = trim( $ip ); // just to be safe
246 246
 
247 247
 				if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
248
-                    return sanitize_text_field( $ip );
249
-                }
250
-            }
251
-        }
248
+					return sanitize_text_field( $ip );
249
+				}
250
+			}
251
+		}
252 252
 
253 253
 		return sanitize_text_field( $ip );
254
-    }
254
+	}
255 255
 
256
-    public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
256
+	public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
257 257
 		if ( strpos( $param, '[' ) ) {
258 258
 			$params = explode( '[', $param );
259
-            $param = $params[0];
260
-        }
259
+			$param = $params[0];
260
+		}
261 261
 
262 262
 		if ( $src == 'get' ) {
263
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
264
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
265
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
266
-            }
263
+			$value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
264
+			if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
265
+				$value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
266
+			}
267 267
 			self::sanitize_value( $sanitize, $value );
268 268
 		} else {
269 269
 			$value = self::get_simple_request( array(
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 			}
286 286
 		}
287 287
 
288
-        return $value;
289
-    }
288
+		return $value;
289
+	}
290 290
 
291 291
 	public static function get_post_param( $param, $default = '', $sanitize = '' ) {
292 292
 		return self::get_simple_request( array(
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
 	}
351 351
 
352 352
 	/**
353
-	* Preserve backslashes in a value, but make sure value doesn't get compounding slashes
354
-	*
355
-	* @since 2.0.8
356
-	* @param string $value
357
-	* @return string $value
358
-	*/
353
+	 * Preserve backslashes in a value, but make sure value doesn't get compounding slashes
354
+	 *
355
+	 * @since 2.0.8
356
+	 * @param string $value
357
+	 * @return string $value
358
+	 */
359 359
 	public static function preserve_backslashes( $value ) {
360 360
 		// If backslashes have already been added, don't add them again
361 361
 		if ( strpos( $value, '\\\\' ) === false ) {
@@ -377,14 +377,14 @@  discard block
 block discarded – undo
377 377
 		}
378 378
 	}
379 379
 
380
-    public static function sanitize_request( $sanitize_method, &$values ) {
381
-        $temp_values = $values;
382
-        foreach ( $temp_values as $k => $val ) {
383
-            if ( isset( $sanitize_method[ $k ] ) ) {
380
+	public static function sanitize_request( $sanitize_method, &$values ) {
381
+		$temp_values = $values;
382
+		foreach ( $temp_values as $k => $val ) {
383
+			if ( isset( $sanitize_method[ $k ] ) ) {
384 384
 				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
385
-            }
386
-        }
387
-    }
385
+			}
386
+		}
387
+	}
388 388
 
389 389
 	/**
390 390
 	 * @deprecated 3.01
@@ -514,39 +514,39 @@  discard block
 block discarded – undo
514 514
 		);
515 515
 	}
516 516
 
517
-    /**
518
-     * Used when switching the action for a bulk action
519
-     * @since 2.0
520
-     */
517
+	/**
518
+	 * Used when switching the action for a bulk action
519
+	 * @since 2.0
520
+	 */
521 521
 	public static function remove_get_action() {
522 522
 		if ( ! isset( $_GET ) ) {
523 523
 			return;
524 524
 		}
525 525
 
526
-        $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
527
-        if ( ! empty( $new_action ) ) {
526
+		$new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' );
527
+		if ( ! empty( $new_action ) ) {
528 528
 			$_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
529
-        }
530
-    }
529
+		}
530
+	}
531 531
 
532
-    /**
533
-     * Check the WP query for a parameter
534
-     *
535
-     * @since 2.0
536
-     * @return string|array
537
-     */
538
-    public static function get_query_var( $value, $param ) {
539
-        if ( $value != '' ) {
540
-            return $value;
541
-        }
532
+	/**
533
+	 * Check the WP query for a parameter
534
+	 *
535
+	 * @since 2.0
536
+	 * @return string|array
537
+	 */
538
+	public static function get_query_var( $value, $param ) {
539
+		if ( $value != '' ) {
540
+			return $value;
541
+		}
542 542
 
543
-        global $wp_query;
544
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
545
-            $value = $wp_query->query_vars[ $param ];
546
-        }
543
+		global $wp_query;
544
+		if ( isset( $wp_query->query_vars[ $param ] ) ) {
545
+			$value = $wp_query->query_vars[ $param ];
546
+		}
547 547
 
548
-        return $value;
549
-    }
548
+		return $value;
549
+	}
550 550
 
551 551
 	/**
552 552
 	 * @since 3.0
@@ -568,16 +568,16 @@  discard block
 block discarded – undo
568 568
 		}
569 569
 	}
570 570
 
571
-    /**
572
-     * @param string $type
573
-     */
574
-    public static function trigger_hook_load( $type, $object = null ) {
575
-        // only load the form hooks once
571
+	/**
572
+	 * @param string $type
573
+	 */
574
+	public static function trigger_hook_load( $type, $object = null ) {
575
+		// only load the form hooks once
576 576
 		$hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
577
-        if ( ! $hooks_loaded ) {
577
+		if ( ! $hooks_loaded ) {
578 578
 			do_action( 'frm_load_' . $type . '_hooks' );
579
-        }
580
-    }
579
+		}
580
+	}
581 581
 
582 582
 	/**
583 583
 	 * Save all front-end js scripts into a single file
@@ -599,29 +599,29 @@  discard block
 block discarded – undo
599 599
 		$new_file->combine_files( $files );
600 600
 	}
601 601
 
602
-    /**
603
-     * Check a value from a shortcode to see if true or false.
604
-     * True when value is 1, true, 'true', 'yes'
605
-     *
606
-     * @since 1.07.10
607
-     *
608
-     * @param string $value The value to compare
609
-     * @return boolean True or False
610
-     */
602
+	/**
603
+	 * Check a value from a shortcode to see if true or false.
604
+	 * True when value is 1, true, 'true', 'yes'
605
+	 *
606
+	 * @since 1.07.10
607
+	 *
608
+	 * @param string $value The value to compare
609
+	 * @return boolean True or False
610
+	 */
611 611
 	public static function is_true( $value ) {
612
-        return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
613
-    }
612
+		return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
613
+	}
614 614
 
615
-    /**
616
-     * Used to filter shortcode in text widgets
615
+	/**
616
+	 * Used to filter shortcode in text widgets
617 617
 	 *
618 618
 	 * @deprecated 2.5.4
619 619
 	 * @codeCoverageIgnore
620
-     */
621
-    public static function widget_text_filter_callback( $matches ) {
620
+	 */
621
+	public static function widget_text_filter_callback( $matches ) {
622 622
 		_deprecated_function( __METHOD__, '2.5.4' );
623
-        return do_shortcode( $matches[0] );
624
-    }
623
+		return do_shortcode( $matches[0] );
624
+	}
625 625
 
626 626
 	public static function get_pages() {
627 627
 		return get_posts( array(
@@ -633,10 +633,10 @@  discard block
 block discarded – undo
633 633
 		) );
634 634
 	}
635 635
 
636
-    public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
637
-        $pages = self::get_pages();
636
+	public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) {
637
+		$pages = self::get_pages();
638 638
 		$selected = self::get_post_param( $field_name, $page_id, 'absint' );
639
-    ?>
639
+	?>
640 640
 		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown">
641 641
             <option value=""> </option>
642 642
             <?php foreach ( $pages as $page ) { ?>
@@ -646,16 +646,16 @@  discard block
 block discarded – undo
646 646
             <?php } ?>
647 647
         </select>
648 648
     <?php
649
-    }
649
+	}
650 650
 
651 651
 	public static function post_edit_link( $post_id ) {
652 652
 		$post = get_post( $post_id );
653
-        if ( $post ) {
653
+		if ( $post ) {
654 654
 			$post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
655 655
 			return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
656
-        }
657
-        return '';
658
-    }
656
+		}
657
+		return '';
658
+	}
659 659
 
660 660
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
661 661
 		?>
@@ -666,73 +666,73 @@  discard block
 block discarded – undo
666 666
 	}
667 667
 
668 668
 	public static function roles_options( $capability ) {
669
-        global $frm_vars;
670
-        if ( isset($frm_vars['editable_roles']) ) {
671
-            $editable_roles = $frm_vars['editable_roles'];
672
-        } else {
673
-            $editable_roles = get_editable_roles();
674
-            $frm_vars['editable_roles'] = $editable_roles;
675
-        }
676
-
677
-        foreach ( $editable_roles as $role => $details ) {
669
+		global $frm_vars;
670
+		if ( isset($frm_vars['editable_roles']) ) {
671
+			$editable_roles = $frm_vars['editable_roles'];
672
+		} else {
673
+			$editable_roles = get_editable_roles();
674
+			$frm_vars['editable_roles'] = $editable_roles;
675
+		}
676
+
677
+		foreach ( $editable_roles as $role => $details ) {
678 678
 			$name = translate_user_role( $details['name'] );
679 679
 			?>
680 680
 		<option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option>
681 681
 <?php
682 682
 			unset( $role, $details );
683
-        }
684
-    }
683
+		}
684
+	}
685 685
 
686 686
 	public static function frm_capabilities( $type = 'auto' ) {
687
-        $cap = array(
688
-            'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
689
-            'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
690
-            'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
691
-            'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
692
-            'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
693
-            'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
694
-        );
687
+		$cap = array(
688
+			'frm_view_forms'        => __( 'View Forms and Templates', 'formidable' ),
689
+			'frm_edit_forms'        => __( 'Add/Edit Forms and Templates', 'formidable' ),
690
+			'frm_delete_forms'      => __( 'Delete Forms and Templates', 'formidable' ),
691
+			'frm_change_settings'   => __( 'Access this Settings Page', 'formidable' ),
692
+			'frm_view_entries'      => __( 'View Entries from Admin Area', 'formidable' ),
693
+			'frm_delete_entries'    => __( 'Delete Entries from Admin Area', 'formidable' ),
694
+		);
695 695
 
696 696
 		if ( ! self::pro_is_installed() && 'pro' != $type ) {
697
-            return $cap;
698
-        }
697
+			return $cap;
698
+		}
699 699
 
700
-        $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
701
-        $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
702
-        $cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
703
-        $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
700
+		$cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' );
701
+		$cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' );
702
+		$cap['frm_view_reports'] = __( 'View Reports', 'formidable' );
703
+		$cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
704 704
 
705
-        return $cap;
706
-    }
705
+		return $cap;
706
+	}
707 707
 
708 708
 	public static function user_has_permission( $needed_role ) {
709
-        if ( $needed_role == '-1' ) {
710
-            return false;
709
+		if ( $needed_role == '-1' ) {
710
+			return false;
711 711
 		}
712 712
 
713
-        // $needed_role will be equal to blank if "Logged-in users" is selected
714
-        if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
715
-            return true;
716
-        }
713
+		// $needed_role will be equal to blank if "Logged-in users" is selected
714
+		if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) {
715
+			return true;
716
+		}
717 717
 
718
-        $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
719
-        foreach ( $roles as $role ) {
718
+		$roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
719
+		foreach ( $roles as $role ) {
720 720
 			if ( current_user_can( $role ) ) {
721
-        		return true;
721
+				return true;
722 722
 			}
723
-        	if ( $role == $needed_role ) {
724
-        		break;
723
+			if ( $role == $needed_role ) {
724
+				break;
725 725
 			}
726
-        }
727
-        return false;
728
-    }
729
-
730
-    /**
731
-     * Make sure administrators can see Formidable menu
732
-     *
733
-     * @since 2.0
734
-     */
735
-    public static function maybe_add_permissions() {
726
+		}
727
+		return false;
728
+	}
729
+
730
+	/**
731
+	 * Make sure administrators can see Formidable menu
732
+	 *
733
+	 * @since 2.0
734
+	 */
735
+	public static function maybe_add_permissions() {
736 736
 		self::force_capability( 'frm_view_entries' );
737 737
 
738 738
 		if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
@@ -741,12 +741,12 @@  discard block
 block discarded – undo
741 741
 
742 742
 		$user_id = get_current_user_id();
743 743
 		$user = new WP_User( $user_id );
744
-        $frm_roles = self::frm_capabilities();
745
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
744
+		$frm_roles = self::frm_capabilities();
745
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
746 746
 			$user->add_cap( $frm_role );
747 747
 			unset( $frm_role, $frm_role_description );
748
-        }
749
-    }
748
+		}
749
+	}
750 750
 
751 751
 	/**
752 752
 	 * Make sure admins have permission to see the menu items
@@ -762,28 +762,28 @@  discard block
 block discarded – undo
762 762
 		}
763 763
 	}
764 764
 
765
-    /**
766
-     * Check if the user has permision for action.
767
-     * Return permission message and stop the action if no permission
768
-     * @since 2.0
769
-     * @param string $permission
770
-     */
765
+	/**
766
+	 * Check if the user has permision for action.
767
+	 * Return permission message and stop the action if no permission
768
+	 * @since 2.0
769
+	 * @param string $permission
770
+	 */
771 771
 	public static function permission_check( $permission, $show_message = 'show' ) {
772
-        $permission_error = self::permission_nonce_error($permission);
773
-        if ( $permission_error !== false ) {
774
-            if ( 'hide' == $show_message ) {
775
-                $permission_error = '';
776
-            }
777
-            wp_die($permission_error);
778
-        }
779
-    }
780
-
781
-    /**
782
-     * Check user permission and nonce
783
-     * @since 2.0
784
-     * @param string $permission
785
-     * @return false|string The permission message or false if allowed
786
-     */
772
+		$permission_error = self::permission_nonce_error($permission);
773
+		if ( $permission_error !== false ) {
774
+			if ( 'hide' == $show_message ) {
775
+				$permission_error = '';
776
+			}
777
+			wp_die($permission_error);
778
+		}
779
+	}
780
+
781
+	/**
782
+	 * Check user permission and nonce
783
+	 * @since 2.0
784
+	 * @param string $permission
785
+	 * @return false|string The permission message or false if allowed
786
+	 */
787 787
 	public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
788 788
 		if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
789 789
 			$frm_settings = self::get_settings();
@@ -791,23 +791,23 @@  discard block
 block discarded – undo
791 791
 		}
792 792
 
793 793
 		$error = false;
794
-        if ( empty($nonce_name) ) {
795
-            return $error;
796
-        }
794
+		if ( empty($nonce_name) ) {
795
+			return $error;
796
+		}
797 797
 
798
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
799
-            $frm_settings = self::get_settings();
800
-            $error = $frm_settings->admin_permission;
801
-        }
798
+		if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
799
+			$frm_settings = self::get_settings();
800
+			$error = $frm_settings->admin_permission;
801
+		}
802 802
 
803
-        return $error;
804
-    }
803
+		return $error;
804
+	}
805 805
 
806
-    public static function checked( $values, $current ) {
806
+	public static function checked( $values, $current ) {
807 807
 		if ( self::check_selected( $values, $current ) ) {
808
-            echo ' checked="checked"';
808
+			echo ' checked="checked"';
809 809
 		}
810
-    }
810
+	}
811 811
 
812 812
 	public static function check_selected( $values, $current ) {
813 813
 		$values = self::recursive_function_map( $values, 'trim' );
@@ -845,24 +845,24 @@  discard block
 block discarded – undo
845 845
 		return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
846 846
 	}
847 847
 
848
-    /**
849
-     * Flatten a multi-dimensional array
850
-     */
848
+	/**
849
+	 * Flatten a multi-dimensional array
850
+	 */
851 851
 	public static function array_flatten( $array, $keys = 'keep' ) {
852
-        $return = array();
853
-        foreach ( $array as $key => $value ) {
854
-            if ( is_array($value) ) {
852
+		$return = array();
853
+		foreach ( $array as $key => $value ) {
854
+			if ( is_array($value) ) {
855 855
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
856
-            } else {
856
+			} else {
857 857
 				if ( $keys == 'keep' ) {
858 858
 					$return[ $key ] = $value;
859 859
 				} else {
860 860
 					$return[] = $value;
861 861
 				}
862
-            }
863
-        }
864
-        return $return;
865
-    }
862
+			}
863
+		}
864
+		return $return;
865
+	}
866 866
 
867 867
 	public static function esc_textarea( $text, $is_rich_text = false ) {
868 868
 		$safe_text = str_replace( '&quot;', '"', $text );
@@ -873,38 +873,38 @@  discard block
 block discarded – undo
873 873
 		return apply_filters( 'esc_textarea', $safe_text, $text );
874 874
 	}
875 875
 
876
-    /**
877
-     * Add auto paragraphs to text areas
878
-     * @since 2.0
879
-     */
876
+	/**
877
+	 * Add auto paragraphs to text areas
878
+	 * @since 2.0
879
+	 */
880 880
 	public static function use_wpautop( $content ) {
881
-        if ( apply_filters('frm_use_wpautop', true) ) {
882
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
883
-        }
884
-        return $content;
885
-    }
881
+		if ( apply_filters('frm_use_wpautop', true) ) {
882
+			$content = wpautop(str_replace( '<br>', '<br />', $content));
883
+		}
884
+		return $content;
885
+	}
886 886
 
887 887
 	public static function replace_quotes( $val ) {
888
-        //Replace double quotes
888
+		//Replace double quotes
889 889
 		$val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
890
-        //Replace single quotes
891
-        $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
892
-        return $val;
893
-    }
894
-
895
-    /**
896
-     * @since 2.0
897
-     * @return string The base Google APIS url for the current version of jQuery UI
898
-     */
899
-    public static function jquery_ui_base_url() {
890
+		//Replace single quotes
891
+		$val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
892
+		return $val;
893
+	}
894
+
895
+	/**
896
+	 * @since 2.0
897
+	 * @return string The base Google APIS url for the current version of jQuery UI
898
+	 */
899
+	public static function jquery_ui_base_url() {
900 900
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
901
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
902
-        return $url;
903
-    }
901
+		$url = apply_filters('frm_jquery_ui_base_url', $url);
902
+		return $url;
903
+	}
904 904
 
905
-    /**
906
-     * @param string $handle
907
-     */
905
+	/**
906
+	 * @param string $handle
907
+	 */
908 908
 	public static function script_version( $handle, $default = 0 ) {
909 909
 		global $wp_scripts;
910 910
 		if ( ! $wp_scripts ) {
@@ -926,12 +926,12 @@  discard block
 block discarded – undo
926 926
 
927 927
 	public static function js_redirect( $url ) {
928 928
 		return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
929
-    }
929
+	}
930 930
 
931 931
 	public static function get_user_id_param( $user_id ) {
932
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
933
-            return $user_id;
934
-        }
932
+		if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
933
+			return $user_id;
934
+		}
935 935
 
936 936
 		$user_id = sanitize_text_field( $user_id );
937 937
 		if ( $user_id == 'current' ) {
@@ -943,14 +943,14 @@  discard block
 block discarded – undo
943 943
 				$user = get_user_by( 'login', $user_id );
944 944
 			}
945 945
 
946
-            if ( $user ) {
947
-                $user_id = $user->ID;
948
-            }
946
+			if ( $user ) {
947
+				$user_id = $user->ID;
948
+			}
949 949
 			unset( $user );
950
-        }
950
+		}
951 951
 
952
-        return $user_id;
953
-    }
952
+		return $user_id;
953
+	}
954 954
 
955 955
 	public static function get_file_contents( $filename, $atts = array() ) {
956 956
 		if ( ! is_file( $filename ) ) {
@@ -965,36 +965,36 @@  discard block
 block discarded – undo
965 965
 		return $contents;
966 966
 	}
967 967
 
968
-    /**
969
-     * @param string $table_name
970
-     * @param string $column
968
+	/**
969
+	 * @param string $table_name
970
+	 * @param string $column
971 971
 	 * @param int $id
972 972
 	 * @param int $num_chars
973
-     */
974
-    public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
975
-        $key = '';
973
+	 */
974
+	public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) {
975
+		$key = '';
976 976
 
977
-        if ( ! empty( $name ) ) {
978
-            $key = sanitize_key($name);
979
-        }
977
+		if ( ! empty( $name ) ) {
978
+			$key = sanitize_key($name);
979
+		}
980 980
 
981 981
 		if ( empty( $key ) ) {
982
-            $max_slug_value = pow(36, $num_chars);
983
-            $min_slug_value = 37; // we want to have at least 2 characters in the slug
984
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
985
-        }
982
+			$max_slug_value = pow(36, $num_chars);
983
+			$min_slug_value = 37; // we want to have at least 2 characters in the slug
984
+			$key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
985
+		}
986 986
 
987 987
 		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
988 988
 			$key = $key . 'a';
989
-        }
989
+		}
990 990
 
991 991
 		$key_check = FrmDb::get_var( $table_name, array(
992 992
 			$column => $key,
993 993
 			'ID !'  => $id,
994 994
 		), $column );
995 995
 
996
-        if ( $key_check || is_numeric($key_check) ) {
997
-            $suffix = 2;
996
+		if ( $key_check || is_numeric($key_check) ) {
997
+			$suffix = 2;
998 998
 			do {
999 999
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
1000 1000
 				$key_check = FrmDb::get_var( $table_name, array(
@@ -1004,19 +1004,19 @@  discard block
 block discarded – undo
1004 1004
 				$suffix++;
1005 1005
 			} while ( $key_check || is_numeric( $key_check ) );
1006 1006
 			$key = $alt_post_name;
1007
-        }
1008
-        return $key;
1009
-    }
1010
-
1011
-    /**
1012
-     * Editing a Form or Entry
1013
-     * @param string $table
1014
-     * @return bool|array
1015
-     */
1016
-    public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1017
-        if ( ! $record ) {
1018
-            return false;
1019
-        }
1007
+		}
1008
+		return $key;
1009
+	}
1010
+
1011
+	/**
1012
+	 * Editing a Form or Entry
1013
+	 * @param string $table
1014
+	 * @return bool|array
1015
+	 */
1016
+	public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
1017
+		if ( ! $record ) {
1018
+			return false;
1019
+		}
1020 1020
 
1021 1021
 		if ( empty( $post_values ) ) {
1022 1022
 			$post_values = stripslashes_deep( $_POST );
@@ -1039,14 +1039,14 @@  discard block
 block discarded – undo
1039 1039
 
1040 1040
 		self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) );
1041 1041
 
1042
-        if ( $table == 'entries' ) {
1043
-            $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1044
-        } else if ( $table == 'forms' ) {
1045
-            $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1046
-        }
1042
+		if ( $table == 'entries' ) {
1043
+			$values = FrmEntriesHelper::setup_edit_vars( $values, $record );
1044
+		} else if ( $table == 'forms' ) {
1045
+			$values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
1046
+		}
1047 1047
 
1048
-        return $values;
1049
-    }
1048
+		return $values;
1049
+	}
1050 1050
 
1051 1051
 	private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
1052 1052
 		if ( ! empty( $fields ) ) {
@@ -1059,46 +1059,46 @@  discard block
 block discarded – undo
1059 1059
 	}
1060 1060
 
1061 1061
 	private static function fill_field_defaults( $field, $record, array &$values, $args ) {
1062
-        $post_values = $args['post_values'];
1063
-
1064
-        if ( $args['default'] ) {
1065
-            $meta_value = $field->default_value;
1066
-        } else {
1067
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1068
-                if ( ! isset($field->field_options['custom_field']) ) {
1069
-                    $field->field_options['custom_field'] = '';
1070
-                }
1062
+		$post_values = $args['post_values'];
1063
+
1064
+		if ( $args['default'] ) {
1065
+			$meta_value = $field->default_value;
1066
+		} else {
1067
+			if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1068
+				if ( ! isset($field->field_options['custom_field']) ) {
1069
+					$field->field_options['custom_field'] = '';
1070
+				}
1071 1071
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array(
1072 1072
 					'truncate' => false,
1073 1073
 					'type' => $field->type,
1074 1074
 					'form_id' => $field->form_id,
1075 1075
 					'field' => $field,
1076 1076
 				) );
1077
-            } else {
1077
+			} else {
1078 1078
 				$meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1079
-            }
1080
-        }
1079
+			}
1080
+		}
1081 1081
 
1082 1082
 		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1083
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1083
+		$new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1084 1084
 
1085 1085
 		$field_array = self::start_field_array( $field );
1086 1086
 		$field_array['value'] = $new_value;
1087 1087
 		$field_array['type']  = apply_filters( 'frm_field_type', $field_type, $field, $new_value );
1088 1088
 		$field_array['parent_form_id'] = $args['parent_form_id'];
1089 1089
 
1090
-        $args['field_type'] = $field_type;
1090
+		$args['field_type'] = $field_type;
1091 1091
 
1092 1092
 		FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
1093 1093
 
1094
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1095
-            $field_array['unique_msg'] = '';
1096
-        }
1094
+		if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1095
+			$field_array['unique_msg'] = '';
1096
+		}
1097 1097
 
1098
-        $field_array = array_merge( $field->field_options, $field_array );
1098
+		$field_array = array_merge( $field->field_options, $field_array );
1099 1099
 
1100
-        $values['fields'][ $field->id ] = $field_array;
1101
-    }
1100
+		$values['fields'][ $field->id ] = $field_array;
1101
+	}
1102 1102
 
1103 1103
 	/**
1104 1104
 	 * @since 3.0
@@ -1119,48 +1119,48 @@  discard block
 block discarded – undo
1119 1119
 		);
1120 1120
 	}
1121 1121
 
1122
-    /**
1123
-     * @param string $table
1124
-     */
1122
+	/**
1123
+	 * @param string $table
1124
+	 */
1125 1125
 	private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
1126
-        if ( $table == 'entries' ) {
1127
-            $form = $record->form_id;
1126
+		if ( $table == 'entries' ) {
1127
+			$form = $record->form_id;
1128 1128
 			FrmForm::maybe_get_form( $form );
1129
-        } else {
1130
-            $form = $record;
1131
-        }
1129
+		} else {
1130
+			$form = $record;
1131
+		}
1132 1132
 
1133
-        if ( ! $form ) {
1134
-            return;
1135
-        }
1133
+		if ( ! $form ) {
1134
+			return;
1135
+		}
1136 1136
 
1137
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1137
+		$values['form_name'] = isset($record->form_id) ? $form->name : '';
1138 1138
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1139 1139
 
1140 1140
 		if ( ! is_array( $form->options ) ) {
1141 1141
 			return;
1142 1142
 		}
1143 1143
 
1144
-        foreach ( $form->options as $opt => $value ) {
1145
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1146
-        }
1144
+		foreach ( $form->options as $opt => $value ) {
1145
+			$values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1146
+		}
1147 1147
 
1148 1148
 		self::fill_form_defaults( $post_values, $values );
1149
-    }
1149
+	}
1150 1150
 
1151
-    /**
1152
-     * Set to POST value or default
1153
-     */
1151
+	/**
1152
+	 * Set to POST value or default
1153
+	 */
1154 1154
 	private static function fill_form_defaults( $post_values, array &$values ) {
1155
-        $form_defaults = FrmFormsHelper::get_default_opts();
1155
+		$form_defaults = FrmFormsHelper::get_default_opts();
1156 1156
 
1157
-        foreach ( $form_defaults as $opt => $default ) {
1158
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1157
+		foreach ( $form_defaults as $opt => $default ) {
1158
+			if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1159 1159
 				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1160
-            }
1160
+			}
1161 1161
 
1162 1162
 			unset( $opt, $default );
1163
-        }
1163
+		}
1164 1164
 
1165 1165
 		if ( ! isset( $values['custom_style'] ) ) {
1166 1166
 			$values['custom_style'] = self::custom_style_value( $post_values );
@@ -1169,10 +1169,10 @@  discard block
 block discarded – undo
1169 1169
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1170 1170
 			if ( ! isset( $values[ $h . '_html' ] ) ) {
1171 1171
 				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1172
-            }
1172
+			}
1173 1173
 			unset( $h );
1174
-        }
1175
-    }
1174
+		}
1175
+	}
1176 1176
 
1177 1177
 	/**
1178 1178
 	 * @since 2.2.10
@@ -1195,55 +1195,55 @@  discard block
 block discarded – undo
1195 1195
 		if ( $possible_email_field ) {
1196 1196
 			$class .= 'show_frm_not_email_to';
1197 1197
 		}
1198
-    ?>
1198
+	?>
1199 1199
 <li>
1200 1200
 	<a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['id'] ); ?>" >[<?php echo esc_attr( $args['id'] ); ?>]</a>
1201 1201
 	<a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['key'] ); ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ); ?>]</a>
1202 1202
 	<a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ); ?>" data-code="<?php echo esc_attr( $args['id'] ); ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ); ?></a>
1203 1203
 </li>
1204 1204
     <?php
1205
-    }
1205
+	}
1206 1206
 
1207 1207
 	public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
1208
-        if ( is_array( $str ) ) {
1209
-            return '';
1208
+		if ( is_array( $str ) ) {
1209
+			return '';
1210 1210
 		}
1211 1211
 
1212
-        $length = (int) $length;
1212
+		$length = (int) $length;
1213 1213
 		$str = wp_strip_all_tags( $str );
1214 1214
 		$original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
1215 1215
 
1216 1216
 		if ( $length == 0 ) {
1217
-            return '';
1218
-        } else if ( $length <= 10 ) {
1217
+			return '';
1218
+		} else if ( $length <= 10 ) {
1219 1219
 			$sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
1220 1220
 			return $sub . ( ( $length < $original_len ) ? $continue : '' );
1221
-        }
1221
+		}
1222 1222
 
1223
-        $sub = '';
1224
-        $len = 0;
1223
+		$sub = '';
1224
+		$len = 0;
1225 1225
 
1226 1226
 		$words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
1227 1227
 
1228 1228
 		foreach ( $words as $word ) {
1229 1229
 			$part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1230 1230
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1231
-            if ( $total_len > $length && str_word_count($sub) ) {
1232
-                break;
1233
-            }
1231
+			if ( $total_len > $length && str_word_count($sub) ) {
1232
+				break;
1233
+			}
1234 1234
 
1235
-            $sub .= $part;
1235
+			$sub .= $part;
1236 1236
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1237 1237
 
1238
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1239
-                break;
1240
-            }
1238
+			if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1239
+				break;
1240
+			}
1241 1241
 
1242
-            unset($total_len, $word);
1243
-        }
1242
+			unset($total_len, $word);
1243
+		}
1244 1244
 
1245 1245
 		return $sub . ( ( $len < $original_len ) ? $continue : '' );
1246
-    }
1246
+	}
1247 1247
 
1248 1248
 	public static function mb_function( $function_names, $args ) {
1249 1249
 		$mb_function_name = $function_names[0];
@@ -1255,18 +1255,18 @@  discard block
 block discarded – undo
1255 1255
 	}
1256 1256
 
1257 1257
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1258
-        if ( empty($date) ) {
1259
-            return $date;
1260
-        }
1258
+		if ( empty($date) ) {
1259
+			return $date;
1260
+		}
1261 1261
 
1262
-        if ( empty($date_format) ) {
1263
-            $date_format = get_option('date_format');
1264
-        }
1262
+		if ( empty($date_format) ) {
1263
+			$date_format = get_option('date_format');
1264
+		}
1265 1265
 
1266
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1267
-            $frmpro_settings = new FrmProSettings();
1268
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1269
-        }
1266
+		if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1267
+			$frmpro_settings = new FrmProSettings();
1268
+			$date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1269
+		}
1270 1270
 
1271 1271
 		$formatted = self::get_localized_date( $date_format, $date );
1272 1272
 
@@ -1275,8 +1275,8 @@  discard block
 block discarded – undo
1275 1275
 			$formatted .= self::add_time_to_date( $time_format, $date );
1276 1276
 		}
1277 1277
 
1278
-        return $formatted;
1279
-    }
1278
+		return $formatted;
1279
+	}
1280 1280
 
1281 1281
 	private static function add_time_to_date( $time_format, $date ) {
1282 1282
 		if ( empty( $time_format ) ) {
@@ -1358,119 +1358,119 @@  discard block
 block discarded – undo
1358 1358
 		);
1359 1359
 	}
1360 1360
 
1361
-    // Pagination Methods
1361
+	// Pagination Methods
1362 1362
 
1363
-    /**
1364
-     * @param integer $current_p
1365
-     */
1363
+	/**
1364
+	 * @param integer $current_p
1365
+	 */
1366 1366
 	public static function get_last_record_num( $r_count, $current_p, $p_size ) {
1367 1367
 		return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
1368 1368
 	}
1369 1369
 
1370
-    /**
1371
-     * @param integer $current_p
1372
-     */
1373
-    public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1374
-        if ( $current_p == 1 ) {
1375
-            return 1;
1376
-        } else {
1377
-            return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1378
-        }
1379
-    }
1370
+	/**
1371
+	 * @param integer $current_p
1372
+	 */
1373
+	public static function get_first_record_num( $r_count, $current_p, $p_size ) {
1374
+		if ( $current_p == 1 ) {
1375
+			return 1;
1376
+		} else {
1377
+			return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
1378
+		}
1379
+	}
1380 1380
 
1381 1381
 	/**
1382 1382
 	 * @return array
1383 1383
 	 */
1384 1384
 	public static function json_to_array( $json_vars ) {
1385
-        $vars = array();
1386
-        foreach ( $json_vars as $jv ) {
1387
-            $jv_name = explode('[', $jv['name']);
1388
-            $last = count($jv_name) - 1;
1389
-            foreach ( $jv_name as $p => $n ) {
1390
-                $name = trim($n, ']');
1391
-                if ( ! isset($l1) ) {
1392
-                    $l1 = $name;
1393
-                }
1394
-
1395
-                if ( ! isset($l2) ) {
1396
-                    $l2 = $name;
1397
-                }
1398
-
1399
-                if ( ! isset($l3) ) {
1400
-                    $l3 = $name;
1401
-                }
1402
-
1403
-                $this_val = ( $p == $last ) ? $jv['value'] : array();
1404
-
1405
-                switch ( $p ) {
1406
-                    case 0:
1407
-                        $l1 = $name;
1408
-                        self::add_value_to_array( $name, $l1, $this_val, $vars );
1385
+		$vars = array();
1386
+		foreach ( $json_vars as $jv ) {
1387
+			$jv_name = explode('[', $jv['name']);
1388
+			$last = count($jv_name) - 1;
1389
+			foreach ( $jv_name as $p => $n ) {
1390
+				$name = trim($n, ']');
1391
+				if ( ! isset($l1) ) {
1392
+					$l1 = $name;
1393
+				}
1394
+
1395
+				if ( ! isset($l2) ) {
1396
+					$l2 = $name;
1397
+				}
1398
+
1399
+				if ( ! isset($l3) ) {
1400
+					$l3 = $name;
1401
+				}
1402
+
1403
+				$this_val = ( $p == $last ) ? $jv['value'] : array();
1404
+
1405
+				switch ( $p ) {
1406
+					case 0:
1407
+						$l1 = $name;
1408
+						self::add_value_to_array( $name, $l1, $this_val, $vars );
1409 1409
 						break;
1410 1410
 
1411
-                    case 1:
1412
-                        $l2 = $name;
1413
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1411
+					case 1:
1412
+						$l2 = $name;
1413
+						self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1414 1414
 						break;
1415 1415
 
1416
-                    case 2:
1417
-                        $l3 = $name;
1418
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1416
+					case 2:
1417
+						$l3 = $name;
1418
+						self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1419 1419
 						break;
1420 1420
 
1421
-                    case 3:
1422
-                        $l4 = $name;
1423
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1424
-                }
1421
+					case 3:
1422
+						$l4 = $name;
1423
+						self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1424
+				}
1425 1425
 
1426
-                unset($this_val, $n);
1427
-            }
1426
+				unset($this_val, $n);
1427
+			}
1428 1428
 
1429
-            unset($last, $jv);
1430
-        }
1429
+			unset($last, $jv);
1430
+		}
1431 1431
 
1432
-        return $vars;
1433
-    }
1432
+		return $vars;
1433
+	}
1434 1434
 
1435
-    /**
1436
-     * @param string $name
1437
-     * @param string $l1
1438
-     */
1439
-    public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1440
-        if ( $name == '' ) {
1441
-            $vars[] = $val;
1442
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1443
-            $vars[ $l1 ] = $val;
1444
-        }
1445
-    }
1435
+	/**
1436
+	 * @param string $name
1437
+	 * @param string $l1
1438
+	 */
1439
+	public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1440
+		if ( $name == '' ) {
1441
+			$vars[] = $val;
1442
+		} else if ( ! isset( $vars[ $l1 ] ) ) {
1443
+			$vars[ $l1 ] = $val;
1444
+		}
1445
+	}
1446 1446
 
1447 1447
 	public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
1448
-        $tooltips = array(
1449
-            'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1450
-            'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1451
-            'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1452
-            'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1453
-            'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1454
-            'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1455
-            'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1456
-        );
1457
-
1458
-        if ( ! isset( $tooltips[ $name ] ) ) {
1459
-            return;
1460
-        }
1461
-
1462
-        if ( 'open' == $class ) {
1463
-            echo ' frm_help"';
1464
-        } else {
1465
-            echo ' class="frm_help"';
1466
-        }
1448
+		$tooltips = array(
1449
+			'action_title'  => __( 'Give this action a label for easy reference.', 'formidable' ),
1450
+			'email_to'      => __( 'Add one or more recipient addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].  [admin_email] is the address set in WP General Settings.', 'formidable' ),
1451
+			'cc'            => __( 'Add CC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1452
+			'bcc'           => __( 'Add BCC addresses separated by a ",".  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1453
+			'reply_to'      => __( 'If you would like a different reply to address than the "from" address, add a single address here.  FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
1454
+			'from'          => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
1455
+			'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1456
+		);
1457
+
1458
+		if ( ! isset( $tooltips[ $name ] ) ) {
1459
+			return;
1460
+		}
1461
+
1462
+		if ( 'open' == $class ) {
1463
+			echo ' frm_help"';
1464
+		} else {
1465
+			echo ' class="frm_help"';
1466
+		}
1467 1467
 
1468 1468
 		echo ' title="' . esc_attr( $tooltips[ $name ] );
1469 1469
 
1470
-        if ( 'open' != $class ) {
1471
-            echo '"';
1472
-        }
1473
-    }
1470
+		if ( 'open' != $class ) {
1471
+			echo '"';
1472
+		}
1473
+	}
1474 1474
 
1475 1475
 	/**
1476 1476
 	 * Add the current_page class to that page in the form nav
@@ -1486,35 +1486,35 @@  discard block
 block discarded – undo
1486 1486
 		}
1487 1487
 	}
1488 1488
 
1489
-    /**
1490
-     * Prepare and json_encode post content
1491
-     *
1492
-     * @since 2.0
1493
-     *
1494
-     * @param array $post_content
1495
-     * @return string $post_content ( json encoded array )
1496
-     */
1497
-    public static function prepare_and_encode( $post_content ) {
1498
-        //Loop through array to strip slashes and add only the needed ones
1489
+	/**
1490
+	 * Prepare and json_encode post content
1491
+	 *
1492
+	 * @since 2.0
1493
+	 *
1494
+	 * @param array $post_content
1495
+	 * @return string $post_content ( json encoded array )
1496
+	 */
1497
+	public static function prepare_and_encode( $post_content ) {
1498
+		//Loop through array to strip slashes and add only the needed ones
1499 1499
 		foreach ( $post_content as $key => $val ) {
1500 1500
 			// Replace problematic characters (like &quot;)
1501 1501
 			$val = str_replace( '&quot;', '"', $val );
1502 1502
 
1503 1503
 			self::prepare_action_slashes( $val, $key, $post_content );
1504
-            unset( $key, $val );
1505
-        }
1504
+			unset( $key, $val );
1505
+		}
1506 1506
 
1507
-        // json_encode the array
1508
-        $post_content = json_encode( $post_content );
1507
+		// json_encode the array
1508
+		$post_content = json_encode( $post_content );
1509 1509
 
1510
-	    // add extra slashes for \r\n since WP strips them
1510
+		// add extra slashes for \r\n since WP strips them
1511 1511
 		$post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
1512 1512
 
1513
-        // allow for &quot
1514
-	    $post_content = str_replace( '&quot;', '\\"', $post_content );
1513
+		// allow for &quot
1514
+		$post_content = str_replace( '&quot;', '\\"', $post_content );
1515 1515
 
1516
-        return $post_content;
1517
-    }
1516
+		return $post_content;
1517
+	}
1518 1518
 
1519 1519
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1520 1520
 		if ( ! isset( $post_content[ $key ] ) ) {
@@ -1536,64 +1536,64 @@  discard block
 block discarded – undo
1536 1536
 	}
1537 1537
 
1538 1538
 	public static function maybe_json_decode( $string ) {
1539
-        if ( is_array($string) ) {
1540
-            return $string;
1541
-        }
1539
+		if ( is_array($string) ) {
1540
+			return $string;
1541
+		}
1542 1542
 
1543
-        $new_string = json_decode($string, true);
1544
-        if ( function_exists('json_last_error') ) {
1543
+		$new_string = json_decode($string, true);
1544
+		if ( function_exists('json_last_error') ) {
1545 1545
 			// php 5.3+
1546
-            if ( json_last_error() == JSON_ERROR_NONE ) {
1547
-                $string = $new_string;
1548
-            }
1549
-        } else if ( isset($new_string) ) {
1546
+			if ( json_last_error() == JSON_ERROR_NONE ) {
1547
+				$string = $new_string;
1548
+			}
1549
+		} else if ( isset($new_string) ) {
1550 1550
 			// php < 5.3 fallback
1551
-            $string = $new_string;
1552
-        }
1553
-        return $string;
1554
-    }
1555
-
1556
-    /**
1557
-     * @since 1.07.10
1558
-     *
1559
-     * @param string $post_type The name of the post type that may need to be highlighted
1560
-     * echo The javascript to open and highlight the Formidable menu
1561
-     */
1551
+			$string = $new_string;
1552
+		}
1553
+		return $string;
1554
+	}
1555
+
1556
+	/**
1557
+	 * @since 1.07.10
1558
+	 *
1559
+	 * @param string $post_type The name of the post type that may need to be highlighted
1560
+	 * echo The javascript to open and highlight the Formidable menu
1561
+	 */
1562 1562
 	public static function maybe_highlight_menu( $post_type ) {
1563
-        global $post;
1563
+		global $post;
1564 1564
 
1565
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1566
-            return;
1567
-        }
1565
+		if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1566
+			return;
1567
+		}
1568 1568
 
1569
-        if ( is_object($post) && $post->post_type != $post_type ) {
1570
-            return;
1571
-        }
1569
+		if ( is_object($post) && $post->post_type != $post_type ) {
1570
+			return;
1571
+		}
1572 1572
 
1573
-        self::load_admin_wide_js();
1574
-        echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1575
-    }
1573
+		self::load_admin_wide_js();
1574
+		echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>';
1575
+	}
1576 1576
 
1577
-    /**
1578
-     * Load the JS file on non-Formidable pages in the admin area
1579
-     * @since 2.0
1580
-     */
1577
+	/**
1578
+	 * Load the JS file on non-Formidable pages in the admin area
1579
+	 * @since 2.0
1580
+	 */
1581 1581
 	public static function load_admin_wide_js( $load = true ) {
1582
-        $version = FrmAppHelper::plugin_version();
1582
+		$version = FrmAppHelper::plugin_version();
1583 1583
 		wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
1584 1584
 
1585
-        wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1585
+		wp_localize_script( 'formidable_admin_global', 'frmGlobal', array(
1586 1586
 			'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
1587
-            'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1587
+			'deauthorize'  => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
1588 1588
 			'url'          => FrmAppHelper::plugin_url(),
1589 1589
 			'loading'      => __( 'Loading&hellip;' ),
1590 1590
 			'nonce'        => wp_create_nonce( 'frm_ajax' ),
1591
-        ) );
1591
+		) );
1592 1592
 
1593 1593
 		if ( $load ) {
1594 1594
 			wp_enqueue_script( 'formidable_admin_global' );
1595 1595
 		}
1596
-    }
1596
+	}
1597 1597
 
1598 1598
 	/**
1599 1599
 	 * @since 2.0.9
@@ -1602,9 +1602,9 @@  discard block
 block discarded – undo
1602 1602
 		wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
1603 1603
 	}
1604 1604
 
1605
-    /**
1606
-     * @param string $location
1607
-     */
1605
+	/**
1606
+	 * @param string $location
1607
+	 */
1608 1608
 	public static function localize_script( $location ) {
1609 1609
 		$ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
1610 1610
 		$ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
@@ -1660,27 +1660,27 @@  discard block
 block discarded – undo
1660 1660
 		}
1661 1661
 	}
1662 1662
 
1663
-    /**
1663
+	/**
1664 1664
 	 * echo the message on the plugins listing page
1665
-     * @since 1.07.10
1666
-     *
1667
-     * @param float $min_version The version the add-on requires
1668
-     */
1665
+	 * @since 1.07.10
1666
+	 *
1667
+	 * @param float $min_version The version the add-on requires
1668
+	 */
1669 1669
 	public static function min_version_notice( $min_version ) {
1670
-        $frm_version = self::plugin_version();
1670
+		$frm_version = self::plugin_version();
1671 1671
 
1672
-        // check if Formidable meets minimum requirements
1673
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1674
-            return;
1675
-        }
1672
+		// check if Formidable meets minimum requirements
1673
+		if ( version_compare($frm_version, $min_version, '>=') ) {
1674
+			return;
1675
+		}
1676 1676
 
1677
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1677
+		$wp_list_table = _get_list_table('WP_Plugins_List_Table');
1678 1678
 		echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' .
1679
-        __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1680
-        '</div></td></tr>';
1681
-    }
1679
+		__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1680
+		'</div></td></tr>';
1681
+	}
1682 1682
 
1683
-    public static function locales( $type = 'date' ) {
1683
+	public static function locales( $type = 'date' ) {
1684 1684
 		$locales = array(
1685 1685
 			'en' => __( 'English', 'formidable' ),
1686 1686
 			''   => __( 'English/Western', 'formidable' ),
@@ -1759,8 +1759,8 @@  discard block
 block discarded – undo
1759 1759
 		$locales = array_diff_key( $locales, array_flip( $unset ) );
1760 1760
 		$locales = apply_filters( 'frm_locales', $locales );
1761 1761
 
1762
-        return $locales;
1763
-    }
1762
+		return $locales;
1763
+	}
1764 1764
 
1765 1765
 	/**
1766 1766
 	 * Prepare and save settings in styles and actions
Please login to merge, or discard this patch.
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined('ABSPATH') ) {
2
+if ( ! defined( 'ABSPATH' ) ) {
3 3
 	die( 'You are not allowed to call this page directly.' );
4 4
 }
5 5
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
      * @return string
226 226
      */
227 227
 	public static function get_server_value( $value ) {
228
-        return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : '';
228
+        return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : '';
229 229
     }
230 230
 
231 231
     /**
@@ -237,11 +237,11 @@  discard block
 block discarded – undo
237 237
     public static function get_ip_address() {
238 238
 		$ip = '';
239 239
 		foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) {
240
-            if ( ! isset( $_SERVER[ $key ] ) ) {
240
+            if ( ! isset( $_SERVER[$key] ) ) {
241 241
                 continue;
242 242
             }
243 243
 
244
-            foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) {
244
+            foreach ( explode( ',', $_SERVER[$key] ) as $ip ) {
245 245
 				$ip = trim( $ip ); // just to be safe
246 246
 
247 247
 				if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
         }
261 261
 
262 262
 		if ( $src == 'get' ) {
263
-            $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default );
264
-            if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
265
-                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) );
263
+            $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default );
264
+            if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) {
265
+                $value = stripslashes_deep( htmlspecialchars_decode( $_GET[$param] ) );
266 266
             }
267 267
 			self::sanitize_value( $sanitize, $value );
268 268
 		} else {
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 				}
282 282
 
283 283
 				$p = trim( $p, ']' );
284
-				$value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
284
+				$value = isset( $value[$p] ) ? $value[$p] : $default;
285 285
 			}
286 286
 		}
287 287
 
@@ -332,16 +332,16 @@  discard block
 block discarded – undo
332 332
 
333 333
 		$value = $args['default'];
334 334
 		if ( $args['type'] == 'get' ) {
335
-			if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
336
-				$value = $_GET[ $args['param'] ];
335
+			if ( $_GET && isset( $_GET[$args['param']] ) ) {
336
+				$value = $_GET[$args['param']];
337 337
 			}
338 338
 		} else if ( $args['type'] == 'post' ) {
339
-			if ( isset( $_POST[ $args['param'] ] ) ) {
340
-				$value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) );
339
+			if ( isset( $_POST[$args['param']] ) ) {
340
+				$value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) );
341 341
 			}
342 342
 		} else {
343
-			if ( isset( $_REQUEST[ $args['param'] ] ) ) {
344
-				$value = $_REQUEST[ $args['param'] ];
343
+			if ( isset( $_REQUEST[$args['param']] ) ) {
344
+				$value = $_REQUEST[$args['param']];
345 345
 			}
346 346
 		}
347 347
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 			if ( is_array( $value ) ) {
370 370
 				$temp_values = $value;
371 371
 				foreach ( $temp_values as $k => $v ) {
372
-					FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] );
372
+					FrmAppHelper::sanitize_value( $sanitize, $value[$k] );
373 373
 				}
374 374
 			} else {
375 375
 				$value = call_user_func( $sanitize, $value );
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
     public static function sanitize_request( $sanitize_method, &$values ) {
381 381
         $temp_values = $values;
382 382
         foreach ( $temp_values as $k => $val ) {
383
-            if ( isset( $sanitize_method[ $k ] ) ) {
384
-				$values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
383
+            if ( isset( $sanitize_method[$k] ) ) {
384
+				$values[$k] = call_user_func( $sanitize_method[$k], $val );
385 385
             }
386 386
         }
387 387
     }
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 			$allowed_html = $html;
419 419
 		} elseif ( ! empty( $allowed ) ) {
420 420
 			foreach ( (array) $allowed as $a ) {
421
-				$allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
421
+				$allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array();
422 422
 			}
423 423
 		}
424 424
 
@@ -541,8 +541,8 @@  discard block
 block discarded – undo
541 541
         }
542 542
 
543 543
         global $wp_query;
544
-        if ( isset( $wp_query->query_vars[ $param ] ) ) {
545
-            $value = $wp_query->query_vars[ $param ];
544
+        if ( isset( $wp_query->query_vars[$param] ) ) {
545
+            $value = $wp_query->query_vars[$param];
546 546
         }
547 547
 
548 548
         return $value;
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 		return get_posts( array(
628 628
 			'post_type'   => 'page',
629 629
 			'post_status' => array( 'publish', 'private' ),
630
-			'numberposts' => -1,
630
+			'numberposts' => - 1,
631 631
 			'orderby'     => 'title',
632 632
 			'order'       => 'ASC',
633 633
 		) );
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 
660 660
 	public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
661 661
 		?>
662
-		<select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php echo ( 'multiple' === $multiple ) ? 'multiple="multiple"' : ''; ?> class="frm_multiselect">
662
+		<select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php echo ( 'multiple' === $multiple ) ? 'multiple="multiple"' : ''; ?> class="frm_multiselect">
663 663
 			<?php self::roles_options( $capability ); ?>
664 664
 		</select>
665 665
 		<?php
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 
668 668
 	public static function roles_options( $capability ) {
669 669
         global $frm_vars;
670
-        if ( isset($frm_vars['editable_roles']) ) {
670
+        if ( isset( $frm_vars['editable_roles'] ) ) {
671 671
             $editable_roles = $frm_vars['editable_roles'];
672 672
         } else {
673 673
             $editable_roles = get_editable_roles();
@@ -769,12 +769,12 @@  discard block
 block discarded – undo
769 769
      * @param string $permission
770 770
      */
771 771
 	public static function permission_check( $permission, $show_message = 'show' ) {
772
-        $permission_error = self::permission_nonce_error($permission);
772
+        $permission_error = self::permission_nonce_error( $permission );
773 773
         if ( $permission_error !== false ) {
774 774
             if ( 'hide' == $show_message ) {
775 775
                 $permission_error = '';
776 776
             }
777
-            wp_die($permission_error);
777
+            wp_die( $permission_error );
778 778
         }
779 779
     }
780 780
 
@@ -791,11 +791,11 @@  discard block
 block discarded – undo
791 791
 		}
792 792
 
793 793
 		$error = false;
794
-        if ( empty($nonce_name) ) {
794
+        if ( empty( $nonce_name ) ) {
795 795
             return $error;
796 796
         }
797 797
 
798
-        if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) {
798
+        if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) {
799 799
             $frm_settings = self::get_settings();
800 800
             $error = $frm_settings->admin_permission;
801 801
         }
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 			} else {
831 831
 				foreach ( $value as $k => $v ) {
832 832
 					if ( ! is_array( $v ) ) {
833
-						$value[ $k ] = call_user_func( $original_function, $v );
833
+						$value[$k] = call_user_func( $original_function, $v );
834 834
 					}
835 835
 				}
836 836
 			}
@@ -851,11 +851,11 @@  discard block
 block discarded – undo
851 851
 	public static function array_flatten( $array, $keys = 'keep' ) {
852 852
         $return = array();
853 853
         foreach ( $array as $key => $value ) {
854
-            if ( is_array($value) ) {
854
+            if ( is_array( $value ) ) {
855 855
 				$return = array_merge( $return, self::array_flatten( $value, $keys ) );
856 856
             } else {
857 857
 				if ( $keys == 'keep' ) {
858
-					$return[ $key ] = $value;
858
+					$return[$key] = $value;
859 859
 				} else {
860 860
 					$return[] = $value;
861 861
 				}
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
      * @since 2.0
879 879
      */
880 880
 	public static function use_wpautop( $content ) {
881
-        if ( apply_filters('frm_use_wpautop', true) ) {
882
-            $content = wpautop(str_replace( '<br>', '<br />', $content));
881
+        if ( apply_filters( 'frm_use_wpautop', true ) ) {
882
+            $content = wpautop( str_replace( '<br>', '<br />', $content ) );
883 883
         }
884 884
         return $content;
885 885
     }
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
      */
899 899
     public static function jquery_ui_base_url() {
900 900
 		$url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
901
-        $url = apply_filters('frm_jquery_ui_base_url', $url);
901
+        $url = apply_filters( 'frm_jquery_ui_base_url', $url );
902 902
         return $url;
903 903
     }
904 904
 
@@ -912,11 +912,11 @@  discard block
 block discarded – undo
912 912
 		}
913 913
 
914 914
 		$ver = $default;
915
-		if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
915
+		if ( ! isset( $wp_scripts->registered[$handle] ) ) {
916 916
 			return $ver;
917 917
 		}
918 918
 
919
-		$query = $wp_scripts->registered[ $handle ];
919
+		$query = $wp_scripts->registered[$handle];
920 920
 		if ( is_object( $query ) && ! empty( $query->ver ) ) {
921 921
 			$ver = $query->ver;
922 922
 		}
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
     }
930 930
 
931 931
 	public static function get_user_id_param( $user_id ) {
932
-        if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) {
932
+        if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) {
933 933
             return $user_id;
934 934
         }
935 935
 
@@ -975,16 +975,16 @@  discard block
 block discarded – undo
975 975
         $key = '';
976 976
 
977 977
         if ( ! empty( $name ) ) {
978
-            $key = sanitize_key($name);
978
+            $key = sanitize_key( $name );
979 979
         }
980 980
 
981 981
 		if ( empty( $key ) ) {
982
-            $max_slug_value = pow(36, $num_chars);
982
+            $max_slug_value = pow( 36, $num_chars );
983 983
             $min_slug_value = 37; // we want to have at least 2 characters in the slug
984
-            $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 );
984
+            $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
985 985
         }
986 986
 
987
-		if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
987
+		if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) {
988 988
 			$key = $key . 'a';
989 989
         }
990 990
 
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
 			'ID !'  => $id,
994 994
 		), $column );
995 995
 
996
-        if ( $key_check || is_numeric($key_check) ) {
996
+        if ( $key_check || is_numeric( $key_check ) ) {
997 997
             $suffix = 2;
998 998
 			do {
999 999
 				$alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix;
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
 					$column => $alt_post_name,
1002 1002
 					'ID !'  => $id,
1003 1003
 				), $column );
1004
-				$suffix++;
1004
+				$suffix ++;
1005 1005
 			} while ( $key_check || is_numeric( $key_check ) );
1006 1006
 			$key = $alt_post_name;
1007 1007
         }
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
 
1030 1030
 		foreach ( array( 'name', 'description' ) as $var ) {
1031 1031
 			$default_val = isset( $record->{$var} ) ? $record->{$var} : '';
1032
-			$values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
1032
+			$values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
1033 1033
 			unset( $var, $default_val );
1034 1034
 		}
1035 1035
 
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 	private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
1052 1052
 		if ( ! empty( $fields ) ) {
1053 1053
 			foreach ( (array) $fields as $field ) {
1054
-				$field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true );
1054
+				$field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
1055 1055
 				$args['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
1056 1056
 				self::fill_field_defaults( $field, $record, $values, $args );
1057 1057
 			}
@@ -1064,8 +1064,8 @@  discard block
 block discarded – undo
1064 1064
         if ( $args['default'] ) {
1065 1065
             $meta_value = $field->default_value;
1066 1066
         } else {
1067
-            if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) {
1068
-                if ( ! isset($field->field_options['custom_field']) ) {
1067
+            if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1068
+                if ( ! isset( $field->field_options['custom_field'] ) ) {
1069 1069
                     $field->field_options['custom_field'] = '';
1070 1070
                 }
1071 1071
 				$meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array(
@@ -1079,8 +1079,8 @@  discard block
 block discarded – undo
1079 1079
             }
1080 1080
         }
1081 1081
 
1082
-		$field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
1083
-        $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value;
1082
+		$field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type;
1083
+        $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value;
1084 1084
 
1085 1085
 		$field_array = self::start_field_array( $field );
1086 1086
 		$field_array['value'] = $new_value;
@@ -1091,13 +1091,13 @@  discard block
 block discarded – undo
1091 1091
 
1092 1092
 		FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
1093 1093
 
1094
-        if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) {
1094
+        if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
1095 1095
             $field_array['unique_msg'] = '';
1096 1096
         }
1097 1097
 
1098 1098
         $field_array = array_merge( $field->field_options, $field_array );
1099 1099
 
1100
-        $values['fields'][ $field->id ] = $field_array;
1100
+        $values['fields'][$field->id] = $field_array;
1101 1101
     }
1102 1102
 
1103 1103
 	/**
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
             return;
1135 1135
         }
1136 1136
 
1137
-        $values['form_name'] = isset($record->form_id) ? $form->name : '';
1137
+        $values['form_name'] = isset( $record->form_id ) ? $form->name : '';
1138 1138
 		$values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0;
1139 1139
 
1140 1140
 		if ( ! is_array( $form->options ) ) {
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
 		}
1143 1143
 
1144 1144
         foreach ( $form->options as $opt => $value ) {
1145
-            $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value;
1145
+            $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value;
1146 1146
         }
1147 1147
 
1148 1148
 		self::fill_form_defaults( $post_values, $values );
@@ -1155,8 +1155,8 @@  discard block
 block discarded – undo
1155 1155
         $form_defaults = FrmFormsHelper::get_default_opts();
1156 1156
 
1157 1157
         foreach ( $form_defaults as $opt => $default ) {
1158
-            if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
1159
-				$values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
1158
+            if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) {
1159
+				$values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default;
1160 1160
             }
1161 1161
 
1162 1162
 			unset( $opt, $default );
@@ -1167,8 +1167,8 @@  discard block
 block discarded – undo
1167 1167
 		}
1168 1168
 
1169 1169
 		foreach ( array( 'before', 'after', 'submit' ) as $h ) {
1170
-			if ( ! isset( $values[ $h . '_html' ] ) ) {
1171
-				$values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
1170
+			if ( ! isset( $values[$h . '_html'] ) ) {
1171
+				$values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) );
1172 1172
             }
1173 1173
 			unset( $h );
1174 1174
         }
@@ -1228,18 +1228,18 @@  discard block
 block discarded – undo
1228 1228
 		foreach ( $words as $word ) {
1229 1229
 			$part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
1230 1230
 			$total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
1231
-            if ( $total_len > $length && str_word_count($sub) ) {
1231
+            if ( $total_len > $length && str_word_count( $sub ) ) {
1232 1232
                 break;
1233 1233
             }
1234 1234
 
1235 1235
             $sub .= $part;
1236 1236
 			$len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) );
1237 1237
 
1238
-            if ( str_word_count($sub) > $minword && $total_len >= $length ) {
1238
+            if ( str_word_count( $sub ) > $minword && $total_len >= $length ) {
1239 1239
                 break;
1240 1240
             }
1241 1241
 
1242
-            unset($total_len, $word);
1242
+            unset( $total_len, $word );
1243 1243
         }
1244 1244
 
1245 1245
 		return $sub . ( ( $len < $original_len ) ? $continue : '' );
@@ -1255,17 +1255,17 @@  discard block
 block discarded – undo
1255 1255
 	}
1256 1256
 
1257 1257
 	public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
1258
-        if ( empty($date) ) {
1258
+        if ( empty( $date ) ) {
1259 1259
             return $date;
1260 1260
         }
1261 1261
 
1262
-        if ( empty($date_format) ) {
1263
-            $date_format = get_option('date_format');
1262
+        if ( empty( $date_format ) ) {
1263
+            $date_format = get_option( 'date_format' );
1264 1264
         }
1265 1265
 
1266
-        if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) {
1266
+        if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
1267 1267
             $frmpro_settings = new FrmProSettings();
1268
-            $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d');
1268
+            $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
1269 1269
         }
1270 1270
 
1271 1271
 		$formatted = self::get_localized_date( $date_format, $date );
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
 
1281 1281
 	private static function add_time_to_date( $time_format, $date ) {
1282 1282
 		if ( empty( $time_format ) ) {
1283
-			$time_format = get_option('time_format');
1283
+			$time_format = get_option( 'time_format' );
1284 1284
 		}
1285 1285
 
1286 1286
 		$trimmed_format = trim( $time_format );
@@ -1326,10 +1326,10 @@  discard block
 block discarded – undo
1326 1326
 		$time_strings = self::get_time_strings();
1327 1327
 
1328 1328
 		foreach ( $time_strings as $k => $v ) {
1329
-			if ( $diff[ $k ] ) {
1330
-				$time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
1329
+			if ( $diff[$k] ) {
1330
+				$time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] );
1331 1331
 			} else {
1332
-				unset( $time_strings[ $k ] );
1332
+				unset( $time_strings[$k] );
1333 1333
 			}
1334 1334
 		}
1335 1335
 
@@ -1384,19 +1384,19 @@  discard block
 block discarded – undo
1384 1384
 	public static function json_to_array( $json_vars ) {
1385 1385
         $vars = array();
1386 1386
         foreach ( $json_vars as $jv ) {
1387
-            $jv_name = explode('[', $jv['name']);
1388
-            $last = count($jv_name) - 1;
1387
+            $jv_name = explode( '[', $jv['name'] );
1388
+            $last = count( $jv_name ) - 1;
1389 1389
             foreach ( $jv_name as $p => $n ) {
1390
-                $name = trim($n, ']');
1391
-                if ( ! isset($l1) ) {
1390
+                $name = trim( $n, ']' );
1391
+                if ( ! isset( $l1 ) ) {
1392 1392
                     $l1 = $name;
1393 1393
                 }
1394 1394
 
1395
-                if ( ! isset($l2) ) {
1395
+                if ( ! isset( $l2 ) ) {
1396 1396
                     $l2 = $name;
1397 1397
                 }
1398 1398
 
1399
-                if ( ! isset($l3) ) {
1399
+                if ( ! isset( $l3 ) ) {
1400 1400
                     $l3 = $name;
1401 1401
                 }
1402 1402
 
@@ -1410,23 +1410,23 @@  discard block
 block discarded – undo
1410 1410
 
1411 1411
                     case 1:
1412 1412
                         $l2 = $name;
1413
-                        self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] );
1413
+                        self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] );
1414 1414
 						break;
1415 1415
 
1416 1416
                     case 2:
1417 1417
                         $l3 = $name;
1418
-                        self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] );
1418
+                        self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] );
1419 1419
 						break;
1420 1420
 
1421 1421
                     case 3:
1422 1422
                         $l4 = $name;
1423
-                        self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
1423
+                        self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] );
1424 1424
                 }
1425 1425
 
1426
-                unset($this_val, $n);
1426
+                unset( $this_val, $n );
1427 1427
             }
1428 1428
 
1429
-            unset($last, $jv);
1429
+            unset( $last, $jv );
1430 1430
         }
1431 1431
 
1432 1432
         return $vars;
@@ -1439,8 +1439,8 @@  discard block
 block discarded – undo
1439 1439
     public static function add_value_to_array( $name, $l1, $val, &$vars ) {
1440 1440
         if ( $name == '' ) {
1441 1441
             $vars[] = $val;
1442
-        } else if ( ! isset( $vars[ $l1 ] ) ) {
1443
-            $vars[ $l1 ] = $val;
1442
+        } else if ( ! isset( $vars[$l1] ) ) {
1443
+            $vars[$l1] = $val;
1444 1444
         }
1445 1445
     }
1446 1446
 
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
             'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
1456 1456
         );
1457 1457
 
1458
-        if ( ! isset( $tooltips[ $name ] ) ) {
1458
+        if ( ! isset( $tooltips[$name] ) ) {
1459 1459
             return;
1460 1460
         }
1461 1461
 
@@ -1465,7 +1465,7 @@  discard block
 block discarded – undo
1465 1465
             echo ' class="frm_help"';
1466 1466
         }
1467 1467
 
1468
-		echo ' title="' . esc_attr( $tooltips[ $name ] );
1468
+		echo ' title="' . esc_attr( $tooltips[$name] );
1469 1469
 
1470 1470
         if ( 'open' != $class ) {
1471 1471
             echo '"';
@@ -1517,13 +1517,13 @@  discard block
 block discarded – undo
1517 1517
     }
1518 1518
 
1519 1519
 	private static function prepare_action_slashes( $val, $key, &$post_content ) {
1520
-		if ( ! isset( $post_content[ $key ] ) ) {
1520
+		if ( ! isset( $post_content[$key] ) ) {
1521 1521
 			return;
1522 1522
 		}
1523 1523
 
1524 1524
 		if ( is_array( $val ) ) {
1525 1525
 			foreach ( $val as $k1 => $v1 ) {
1526
-				self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
1526
+				self::prepare_action_slashes( $v1, $k1, $post_content[$key] );
1527 1527
 				unset( $k1, $v1 );
1528 1528
 			}
1529 1529
 		} else {
@@ -1531,22 +1531,22 @@  discard block
 block discarded – undo
1531 1531
 			$val = stripslashes( $val );
1532 1532
 
1533 1533
 			// Add backslashes before double quotes and forward slashes only
1534
-			$post_content[ $key ] = addcslashes( $val, '"\\/' );
1534
+			$post_content[$key] = addcslashes( $val, '"\\/' );
1535 1535
 		}
1536 1536
 	}
1537 1537
 
1538 1538
 	public static function maybe_json_decode( $string ) {
1539
-        if ( is_array($string) ) {
1539
+        if ( is_array( $string ) ) {
1540 1540
             return $string;
1541 1541
         }
1542 1542
 
1543
-        $new_string = json_decode($string, true);
1544
-        if ( function_exists('json_last_error') ) {
1543
+        $new_string = json_decode( $string, true );
1544
+        if ( function_exists( 'json_last_error' ) ) {
1545 1545
 			// php 5.3+
1546 1546
             if ( json_last_error() == JSON_ERROR_NONE ) {
1547 1547
                 $string = $new_string;
1548 1548
             }
1549
-        } else if ( isset($new_string) ) {
1549
+        } else if ( isset( $new_string ) ) {
1550 1550
 			// php < 5.3 fallback
1551 1551
             $string = $new_string;
1552 1552
         }
@@ -1562,11 +1562,11 @@  discard block
 block discarded – undo
1562 1562
 	public static function maybe_highlight_menu( $post_type ) {
1563 1563
         global $post;
1564 1564
 
1565
-        if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) {
1565
+        if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
1566 1566
             return;
1567 1567
         }
1568 1568
 
1569
-        if ( is_object($post) && $post->post_type != $post_type ) {
1569
+        if ( is_object( $post ) && $post->post_type != $post_type ) {
1570 1570
             return;
1571 1571
         }
1572 1572
 
@@ -1670,11 +1670,11 @@  discard block
 block discarded – undo
1670 1670
         $frm_version = self::plugin_version();
1671 1671
 
1672 1672
         // check if Formidable meets minimum requirements
1673
-        if ( version_compare($frm_version, $min_version, '>=') ) {
1673
+        if ( version_compare( $frm_version, $min_version, '>=' ) ) {
1674 1674
             return;
1675 1675
         }
1676 1676
 
1677
-        $wp_list_table = _get_list_table('WP_Plugins_List_Table');
1677
+        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
1678 1678
 		echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' .
1679 1679
         __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
1680 1680
         '</div></td></tr>';
Please login to merge, or discard this patch.
classes/helpers/FrmListHelper.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
 			return $this->get_pagenum();
205 205
 		}
206 206
 
207
-		if ( isset( $this->_pagination_args[ $key ] ) ) {
208
-			return $this->_pagination_args[ $key ];
207
+		if ( isset( $this->_pagination_args[$key] ) ) {
208
+			return $this->_pagination_args[$key];
209 209
 		}
210 210
 	}
211 211
 
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 	}
261 261
 
262 262
 	private function hidden_search_inputs( $param_name ) {
263
-		if ( ! empty( $_REQUEST[ $param_name ] ) ) {
264
-			echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />';
263
+		if ( ! empty( $_REQUEST[$param_name] ) ) {
264
+			echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[$param_name] ) . '" />';
265 265
 		}
266 266
 	}
267 267
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 
305 305
 		echo "<ul class='subsubsub'>\n";
306 306
 		foreach ( $views as $class => $view ) {
307
-			$views[ $class ] = "\t<li class='$class'>$view";
307
+			$views[$class] = "\t<li class='$class'>$view";
308 308
 		}
309 309
 		echo implode( " |</li>\n", $views ) . "</li>\n";
310 310
 		echo '</ul>';
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 
430 430
 		$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
431 431
 		foreach ( $actions as $action => $link ) {
432
-			++$i;
432
+			++ $i;
433 433
 			( $i == $action_count ) ? $sep = '' : $sep = ' | ';
434 434
 			$out .= "<span class='$action'>$link$sep</span>";
435 435
 		}
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 			'prev'  => __( 'Previous page' ),
643 643
 			'next'  => __( 'Next page' ),
644 644
 		);
645
-		return $labels[ $link ];
645
+		return $labels[$link];
646 646
 	}
647 647
 
648 648
 	private function current_url() {
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 
731 731
 		// If the primary column doesn't exist fall back to the
732 732
 		// first non-checkbox column.
733
-		if ( ! isset( $columns[ $default ] ) ) {
733
+		if ( ! isset( $columns[$default] ) ) {
734 734
 			$default = FrmListHelper::get_default_primary_column_name();
735 735
 		}
736 736
 
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 		 */
745 745
 		$column  = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
746 746
 
747
-		if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
747
+		if ( empty( $column ) || ! isset( $columns[$column] ) ) {
748 748
 			$column = $default;
749 749
 		}
750 750
 
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 			// In 4.3, we added a fourth argument for primary column.
767 767
 			$column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
768 768
 			foreach ( $this->_column_headers as $key => $value ) {
769
-				$column_headers[ $key ] = $value;
769
+				$column_headers[$key] = $value;
770 770
 			}
771 771
 
772 772
 			return $column_headers;
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 				$data[1] = false;
800 800
 			}
801 801
 
802
-			$sortable[ $id ] = $data;
802
+			$sortable[$id] = $data;
803 803
 		}
804 804
 
805 805
 		$primary = $this->get_primary_column_name();
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 			static $cb_counter = 1;
855 855
 			$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
856 856
 				. '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
857
-			$cb_counter++;
857
+			$cb_counter ++;
858 858
 		}
859 859
 
860 860
 		foreach ( $columns as $column_key => $column_display_name ) {
@@ -874,8 +874,8 @@  discard block
 block discarded – undo
874 874
 				$class[] = 'column-primary';
875 875
 			}
876 876
 
877
-			if ( isset( $sortable[ $column_key ] ) ) {
878
-				list( $orderby, $desc_first ) = $sortable[ $column_key ];
877
+			if ( isset( $sortable[$column_key] ) ) {
878
+				list( $orderby, $desc_first ) = $sortable[$column_key];
879 879
 
880 880
 				if ( $current_orderby == $orderby ) {
881 881
 					$order = 'asc' == $current_order ? 'desc' : 'asc';
Please login to merge, or discard this patch.