Completed
Pull Request — master (#53)
by Jamie
03:30
created
classes/controllers/FrmEntriesController.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
     public static function menu() {
6 6
 		FrmAppHelper::force_capability( 'frm_view_entries' );
7 7
 
8
-        add_submenu_page('formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
8
+        add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
9 9
 
10 10
 		if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show' ) ) ) {
11 11
 			$menu_name = FrmAppHelper::get_menu_name();
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             'id'      => 'formidable-entries-tab',
54 54
             'title'   => __( 'Overview', 'formidable' ),
55 55
 			'content' => '<p>' . esc_html__( 'This screen provides access to all of your entries. You can customize the display of this screen to suit your workflow.', 'formidable' ) . '</p> <p>' . esc_html__( 'Hovering over a row in the entries list will display action links that allow you to manage your entry.', 'formidable' ) . '</p>',
56
-        ));
56
+        ) );
57 57
 
58 58
         $screen->set_help_sidebar(
59 59
 			'<p><strong>' . esc_html__( 'For more information:', 'formidable' ) . '</strong></p>' .
@@ -68,20 +68,20 @@  discard block
 block discarded – undo
68 68
         global $frm_vars;
69 69
 		$form_id = FrmForm::get_current_form_id();
70 70
 
71
-		$columns[ $form_id . '_id' ] = 'ID';
72
-		$columns[ $form_id . '_item_key' ] = esc_html__( 'Entry Key', 'formidable' );
71
+		$columns[$form_id . '_id'] = 'ID';
72
+		$columns[$form_id . '_item_key'] = esc_html__( 'Entry Key', 'formidable' );
73 73
 
74 74
 		if ( $form_id ) {
75 75
 			self::get_columns_for_form( $form_id, $columns );
76 76
 		} else {
77
-			$columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' );
78
-			$columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' );
79
-			$columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' );
77
+			$columns[$form_id . '_form_id'] = __( 'Form', 'formidable' );
78
+			$columns[$form_id . '_name'] = __( 'Entry Name', 'formidable' );
79
+			$columns[$form_id . '_user_id'] = __( 'Created By', 'formidable' );
80 80
 		}
81 81
 
82
-		$columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
83
-		$columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
84
-		$columns[ $form_id . '_ip' ] = 'IP';
82
+		$columns[$form_id . '_created_at'] = __( 'Entry creation date', 'formidable' );
83
+		$columns[$form_id . '_updated_at'] = __( 'Entry update date', 'formidable' );
84
+		$columns[$form_id . '_ip'] = 'IP';
85 85
 
86 86
         $frm_vars['cols'] = $columns;
87 87
 
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
 				if ( $sub_form_cols ) {
108 108
 					foreach ( $sub_form_cols as $k => $sub_form_col ) {
109 109
 						if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
110
-							unset( $sub_form_cols[ $k ] );
110
+							unset( $sub_form_cols[$k] );
111 111
 							continue;
112 112
 						}
113
-						$columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
114
-						unset($sub_form_col);
113
+						$columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
114
+						unset( $sub_form_col );
115 115
 					}
116 116
 				}
117
-				unset($sub_form_cols);
117
+				unset( $sub_form_cols );
118 118
 			} else {
119 119
 				$col_id = $form_col->field_key;
120 120
 				if ( $form_col->form_id != $form_id ) {
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 				$has_separate_value = ! FrmField::is_option_empty( $form_col, 'separate_value' );
125 125
 				$is_post_status     = FrmField::is_option_true( $form_col, 'post_field' ) && $form_col->field_options['post_field'] == 'post_status';
126 126
 				if ( $has_separate_value && ! $is_post_status ) {
127
-					$columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
127
+					$columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
128 128
 				}
129
-				$columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
129
+				$columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
130 130
 			}
131 131
 		}
132 132
 	}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
         global $frm_vars;
146 146
         //add a check so we don't create a loop
147
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
147
+        $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
148 148
 
149 149
         return $check;
150 150
     }
@@ -159,19 +159,19 @@  discard block
 block discarded – undo
159 159
         }
160 160
 
161 161
         global $frm_vars;
162
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
162
+        if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
163 163
             return; //don't continue if there's no previous value
164 164
         }
165 165
 
166 166
         foreach ( $meta_value as $mk => $mv ) {
167 167
             //remove blank values
168 168
             if ( empty( $mv ) ) {
169
-                unset( $meta_value[ $mk ] );
169
+                unset( $meta_value[$mk] );
170 170
             }
171 171
         }
172 172
 
173
-        $cur_form_prefix = reset($meta_value);
174
-        $cur_form_prefix = explode('_', $cur_form_prefix);
173
+        $cur_form_prefix = reset( $meta_value );
174
+        $cur_form_prefix = explode( '_', $cur_form_prefix );
175 175
         $cur_form_prefix = $cur_form_prefix[0];
176 176
         $save = false;
177 177
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 
191 191
             $meta_value[] = $prev_hidden;
192 192
             $save = true;
193
-            unset($form_prefix);
193
+            unset( $form_prefix );
194 194
         }
195 195
 
196 196
 		if ( $save ) {
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		foreach ( $fields as $field ) {
223 223
 			if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
224 224
 				// Can't sort on checkboxes because they are stored serialized, or post fields
225
-				$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
225
+				$columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id;
226 226
 			}
227 227
 		}
228 228
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                     break;
246 246
                 }
247 247
 
248
-                unset($form_prefix);
248
+                unset( $form_prefix );
249 249
             }
250 250
         }
251 251
 
@@ -253,15 +253,15 @@  discard block
 block discarded – undo
253 253
 			return $result;
254 254
 		}
255 255
 
256
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
256
+        $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
257 257
         $max_columns = 8;
258 258
         if ( $i <= $max_columns ) {
259 259
 			return $result;
260 260
 		}
261 261
 
262 262
         global $frm_vars;
263
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
264
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
263
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) {
264
+            $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options );
265 265
         }
266 266
 
267 267
 		$has_custom_hidden_columns = ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] && isset( $frm_vars['current_form']->options['hidden_cols'] ) && ! empty( $frm_vars['current_form']->options['hidden_cols'] ) );
@@ -269,23 +269,23 @@  discard block
 block discarded – undo
269 269
             $result = $frm_vars['current_form']->options['hidden_cols'];
270 270
         } else {
271 271
             $cols = $frm_vars['cols'];
272
-            $cols = array_reverse($cols, true);
272
+            $cols = array_reverse( $cols, true );
273 273
 
274 274
 			if ( $form_id ) {
275 275
 				$result[] = $form_id . '_id';
276
-				$i--;
276
+				$i --;
277 277
 			}
278 278
 
279 279
 			$result[] = $form_id . '_item_key';
280
-            $i--;
280
+            $i --;
281 281
 
282 282
 			foreach ( $cols as $col_key => $col ) {
283 283
                 if ( $i > $max_columns ) {
284 284
 					$result[] = $col_key;
285 285
 				}
286 286
                 //remove some columns by default
287
-                $i--;
288
-                unset($col_key, $col);
287
+                $i --;
288
+                unset( $col_key, $col );
289 289
             }
290 290
         }
291 291
 
@@ -317,14 +317,14 @@  discard block
 block discarded – undo
317 317
         if ( $pagenum > $total_pages && $total_pages > 0 ) {
318 318
 			$url = add_query_arg( 'paged', $total_pages );
319 319
             if ( headers_sent() ) {
320
-                echo FrmAppHelper::js_redirect($url);
320
+                echo FrmAppHelper::js_redirect( $url );
321 321
             } else {
322 322
                 wp_redirect( esc_url_raw( $url ) );
323 323
             }
324 324
             die();
325 325
         }
326 326
 
327
-        if ( empty($message) && isset($_GET['import-message']) ) {
327
+        if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
328 328
             $message = __( 'Your import is complete', 'formidable' );
329 329
         }
330 330
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 
342 342
     /* Back End CRUD */
343 343
 	public static function show( $id = 0 ) {
344
-        FrmAppHelper::permission_check('frm_view_entries');
344
+        FrmAppHelper::permission_check( 'frm_view_entries' );
345 345
 
346 346
         if ( ! $id ) {
347 347
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
             }
352 352
         }
353 353
 
354
-        $entry = FrmEntry::getOne($id, true);
354
+        $entry = FrmEntry::getOne( $id, true );
355 355
 		if ( ! $entry ) {
356 356
 			echo '<div id="form_show_entry_page" class="wrap">' .
357 357
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 			return;
360 360
 		}
361 361
 
362
-        $data = maybe_unserialize($entry->description);
362
+        $data = maybe_unserialize( $entry->description );
363 363
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
364 364
 			$data = array( 'referrer' => $data );
365 365
 		}
@@ -371,11 +371,11 @@  discard block
 block discarded – undo
371 371
     }
372 372
 
373 373
     public static function destroy() {
374
-        FrmAppHelper::permission_check('frm_delete_entries');
374
+        FrmAppHelper::permission_check( 'frm_delete_entries' );
375 375
 
376 376
 		$params = FrmForm::get_admin_params();
377 377
 
378
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
378
+        if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
379 379
             //unlink entry from post
380 380
             global $wpdb;
381 381
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
@@ -454,9 +454,9 @@  discard block
 block discarded – undo
454 454
         if ( ! isset( $frm_vars['form_params'] ) ) {
455 455
             $frm_vars['form_params'] = array();
456 456
         }
457
-		$frm_vars['form_params'][ $form->id ] = $params;
457
+		$frm_vars['form_params'][$form->id] = $params;
458 458
 
459
-		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
459
+		if ( isset( $frm_vars['created_entries'][$form_id] ) ) {
460 460
             return;
461 461
         }
462 462
 
@@ -471,13 +471,13 @@  discard block
 block discarded – undo
471 471
 		 */
472 472
 		$errors = apply_filters( 'frm_entries_before_create', $errors, $form );
473 473
 
474
-		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
474
+		$frm_vars['created_entries'][$form_id] = array( 'errors' => $errors );
475 475
 
476 476
         if ( empty( $errors ) ) {
477 477
 			$_POST['frm_skip_cookie'] = 1;
478 478
             if ( $params['action'] == 'create' ) {
479
-				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
480
-					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
479
+				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) {
480
+					$frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST );
481 481
                 }
482 482
             }
483 483
 
@@ -517,9 +517,9 @@  discard block
 block discarded – undo
517 517
 	}
518 518
 
519 519
 	public static function entry_sidebar( $entry ) {
520
-        $data = maybe_unserialize($entry->description);
521
-        $date_format = get_option('date_format');
522
-        $time_format = get_option('time_format');
520
+        $data = maybe_unserialize( $entry->description );
521
+        $date_format = get_option( 'date_format' );
522
+        $time_format = get_option( 'time_format' );
523 523
 		if ( isset( $data['browser'] ) ) {
524 524
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
525 525
 		}
Please login to merge, or discard this patch.
classes/models/FrmEntryFormat.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			if ( ! self::skip_field( $atts, $f ) ) {
53 53
 				self::fill_entry_values( $atts, $f, $values );
54 54
 			}
55
-			unset($f);
55
+			unset( $f );
56 56
 		}
57 57
 
58 58
 		self::fill_entry_user_info( $atts, $values );
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 			'type'  => $f->type,
122 122
 		);
123 123
 
124
-		$values[ $f->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f );
124
+		$values[$f->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f );
125 125
 	}
126 126
 
127 127
 	public static function fill_entry_values( $atts, $f, array &$values ) {
@@ -153,22 +153,22 @@  discard block
 block discarded – undo
153 153
 		self::prepare_field_output( $atts, $val );
154 154
 
155 155
 		if ( $atts['format'] != 'text' ) {
156
-			$values[ $f->field_key ] = $val;
156
+			$values[$f->field_key] = $val;
157 157
 			if ( $atts['entry'] && $f->type != 'textarea' ) {
158
-				$prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
158
+				$prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] );
159 159
 				if ( $prev_val != $val ) {
160
-					$values[ $f->field_key . '-value' ] = $prev_val;
160
+					$values[$f->field_key . '-value'] = $prev_val;
161 161
 				}
162 162
 			}
163 163
 		} else {
164
-			$values[ $f->id ] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type );
164
+			$values[$f->id] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type );
165 165
 		}
166 166
 	}
167 167
 
168 168
 	private static function fill_missing_fields( $atts, &$values ) {
169
-		if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $atts['field']->id ] ) ) {
169
+		if ( $atts['entry'] && ! isset( $atts['entry']->metas[$atts['field']->id] ) ) {
170 170
 			// In case include_blank is set
171
-			$atts['entry']->metas[ $atts['field']->id ] = '';
171
+			$atts['entry']->metas[$atts['field']->id] = '';
172 172
 			$atts['entry'] = apply_filters( 'frm_prepare_entry_content', $atts['entry'], array( 'field' => $atts['field'] ) );
173 173
 			self::fill_values_from_entry( $atts, $values );
174 174
 		}
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	private static function get_field_value( $atts, &$val ) {
182 182
 		$f = $atts['field'];
183 183
 		if ( $atts['entry'] ) {
184
-			$prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] );
184
+			$prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] );
185 185
 			$meta = array( 'item_id' => $atts['id'], 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type );
186 186
 
187 187
 			//This filter applies to the default-message shortcode and frm-show-entry shortcode only
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			return;
253 253
 		}
254 254
 
255
-		$data  = self::get_entry_description_data( $atts );
255
+		$data = self::get_entry_description_data( $atts );
256 256
 
257 257
 		if ( $atts['default_email'] ) {
258 258
 			$atts['entry']->ip = '[ip]';
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 		preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
340 340
 
341 341
 		// see how many we have
342
-		$i = count($matches['browser']);
342
+		$i = count( $matches['browser'] );
343 343
 
344 344
 		if ( $i > 1 ) {
345 345
 			//we will have two since we are not using 'other' argument yet
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 		self::convert_entry_to_content( $values, $atts, $content );
368 368
 
369 369
 		if ( 'text' == $atts['format'] ) {
370
-			$content = implode('', $content);
370
+			$content = implode( '', $content );
371 371
 		}
372 372
 
373 373
 		if ( $atts['clickable'] ) {
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
 
421 421
 		// merge defaults, global settings, and shortcode options
422 422
 		foreach ( $default_settings as $key => $setting ) {
423
-			if ( $atts[ $key ] != '' ) {
423
+			if ( $atts[$key] != '' ) {
424 424
 				continue;
425 425
 			}
426 426
 
427
-			$atts[ $key ] = $setting;
427
+			$atts[$key] = $setting;
428 428
 			unset( $key, $setting );
429 429
 		}
430 430
 	}
Please login to merge, or discard this patch.
classes/models/FrmEmail.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 			'entry'     => $this->entry,
96 96
 			'form'      => $this->form,
97 97
 		);
98
-		$to     = apply_filters( 'frm_to_email', $to, $values, $this->form->id, $args );
98
+		$to = apply_filters( 'frm_to_email', $to, $values, $this->form->id, $args );
99 99
 
100 100
 		$this->to = array_unique( (array) $to );
101 101
 
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	 * @return array
434 434
 	 */
435 435
 	private function package_header() {
436
-		$header   = array();
436
+		$header = array();
437 437
 
438 438
 		if ( ! empty( $this->cc ) ) {
439 439
 			$header[] = 'CC: ' . implode( ',', $this->cc );
@@ -546,12 +546,12 @@  discard block
 block discarded – undo
546 546
 					$name = trim( str_replace( $email, '', $val ) );
547 547
 				} else {
548 548
 					// If user enters a name without an email
549
-					unset( $recipients[ $key ] );
549
+					unset( $recipients[$key] );
550 550
 					continue;
551 551
 				}
552 552
 			}
553 553
 
554
-			$recipients[ $key ] = $name . ' <' . $email . '>';
554
+			$recipients[$key] = $name . ' <' . $email . '>';
555 555
 		}
556 556
 
557 557
 		return $recipients;
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 				) );
669 669
 
670 670
 				// Remove phone number from to addresses
671
-				unset( $this->to[ $key ] );
671
+				unset( $this->to[$key] );
672 672
 			}
673 673
 		}
674 674
 	}
Please login to merge, or discard this patch.