Completed
Push — master ( 904e43...f1cd3e )
by Stephanie
03:26
created
classes/controllers/FrmEntriesController.php 1 patch
Spacing   +49 added lines, -49 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,24 +107,24 @@  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 ) {
121 121
 					$col_id .= '-_-form' . $form_col->form_id;
122 122
 				}
123 123
 
124
-				if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] && empty($form_col->field_options['post_field']) ) {
125
-					$columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
124
+				if ( isset( $form_col->field_options['separate_value'] ) && $form_col->field_options['separate_value'] && empty( $form_col->field_options['post_field'] ) ) {
125
+					$columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
126 126
 				}
127
-				$columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
127
+				$columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate( $form_col->name, 35 );
128 128
 			}
129 129
 		}
130 130
 	}
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 
143 143
         global $frm_vars;
144 144
         //add a check so we don't create a loop
145
-        $frm_vars['prev_hidden_cols'] = ( isset($frm_vars['prev_hidden_cols']) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
145
+        $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
146 146
 
147 147
         return $check;
148 148
     }
@@ -157,19 +157,19 @@  discard block
 block discarded – undo
157 157
         }
158 158
 
159 159
         global $frm_vars;
160
-        if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
160
+        if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
161 161
             return; //don't continue if there's no previous value
162 162
         }
163 163
 
164 164
         foreach ( $meta_value as $mk => $mv ) {
165 165
             //remove blank values
166 166
             if ( empty( $mv ) ) {
167
-                unset( $meta_value[ $mk ] );
167
+                unset( $meta_value[$mk] );
168 168
             }
169 169
         }
170 170
 
171
-        $cur_form_prefix = reset($meta_value);
172
-        $cur_form_prefix = explode('_', $cur_form_prefix);
171
+        $cur_form_prefix = reset( $meta_value );
172
+        $cur_form_prefix = explode( '_', $cur_form_prefix );
173 173
         $cur_form_prefix = $cur_form_prefix[0];
174 174
         $save = false;
175 175
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 
189 189
             $meta_value[] = $prev_hidden;
190 190
             $save = true;
191
-            unset($form_prefix);
191
+            unset( $form_prefix );
192 192
         }
193 193
 
194 194
 		if ( $save ) {
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		foreach ( $fields as $field ) {
221 221
 			if ( $field->type != 'checkbox' && ( ! isset( $field->field_options['post_field'] ) || $field->field_options['post_field'] == '' ) ) {
222 222
 				// Can't sort on checkboxes because they are stored serialized, or post fields
223
-				$columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
223
+				$columns[$form_id . '_' . $field->field_key] = 'meta_' . $field->id;
224 224
 			}
225 225
 		}
226 226
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
                     break;
244 244
                 }
245 245
 
246
-                unset($form_prefix);
246
+                unset( $form_prefix );
247 247
             }
248 248
         }
249 249
 
@@ -251,15 +251,15 @@  discard block
 block discarded – undo
251 251
 			return $result;
252 252
 		}
253 253
 
254
-        $i = isset($frm_vars['cols']) ? count($frm_vars['cols']) : 0;
254
+        $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
255 255
         $max_columns = 8;
256 256
         if ( $i <= $max_columns ) {
257 257
 			return $result;
258 258
 		}
259 259
 
260 260
         global $frm_vars;
261
-        if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
262
-            $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
261
+        if ( isset( $frm_vars['current_form'] ) && $frm_vars['current_form'] ) {
262
+            $frm_vars['current_form']->options = maybe_unserialize( $frm_vars['current_form']->options );
263 263
         }
264 264
 
265 265
 		$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'] ) );
@@ -267,23 +267,23 @@  discard block
 block discarded – undo
267 267
             $result = $frm_vars['current_form']->options['hidden_cols'];
268 268
         } else {
269 269
             $cols = $frm_vars['cols'];
270
-            $cols = array_reverse($cols, true);
270
+            $cols = array_reverse( $cols, true );
271 271
 
272 272
 			if ( $form_id ) {
273 273
 				$result[] = $form_id . '_id';
274
-				$i--;
274
+				$i --;
275 275
 			}
276 276
 
277 277
 			$result[] = $form_id . '_item_key';
278
-            $i--;
278
+            $i --;
279 279
 
280 280
 			foreach ( $cols as $col_key => $col ) {
281 281
                 if ( $i > $max_columns ) {
282 282
 					$result[] = $col_key;
283 283
 				}
284 284
                 //remove some columns by default
285
-                $i--;
286
-                unset($col_key, $col);
285
+                $i --;
286
+                unset( $col_key, $col );
287 287
             }
288 288
         }
289 289
 
@@ -315,14 +315,14 @@  discard block
 block discarded – undo
315 315
         if ( $pagenum > $total_pages && $total_pages > 0 ) {
316 316
 			$url = add_query_arg( 'paged', $total_pages );
317 317
             if ( headers_sent() ) {
318
-                echo FrmAppHelper::js_redirect($url);
318
+                echo FrmAppHelper::js_redirect( $url );
319 319
             } else {
320 320
                 wp_redirect( esc_url_raw( $url ) );
321 321
             }
322 322
             die();
323 323
         }
324 324
 
325
-        if ( empty($message) && isset($_GET['import-message']) ) {
325
+        if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
326 326
             $message = __( 'Your import is complete', 'formidable' );
327 327
         }
328 328
 
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 
340 340
     /* Back End CRUD */
341 341
 	public static function show( $id = 0 ) {
342
-        FrmAppHelper::permission_check('frm_view_entries');
342
+        FrmAppHelper::permission_check( 'frm_view_entries' );
343 343
 
344 344
         if ( ! $id ) {
345 345
 			$id = FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
             }
350 350
         }
351 351
 
352
-        $entry = FrmEntry::getOne($id, true);
352
+        $entry = FrmEntry::getOne( $id, true );
353 353
 		if ( ! $entry ) {
354 354
 			echo '<div id="form_show_entry_page" class="wrap">' .
355 355
 				__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 			return;
358 358
 		}
359 359
 
360
-        $data = maybe_unserialize($entry->description);
360
+        $data = maybe_unserialize( $entry->description );
361 361
 		if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
362 362
 			$data = array( 'referrer' => $data );
363 363
 		}
@@ -369,11 +369,11 @@  discard block
 block discarded – undo
369 369
     }
370 370
 
371 371
     public static function destroy() {
372
-        FrmAppHelper::permission_check('frm_delete_entries');
372
+        FrmAppHelper::permission_check( 'frm_delete_entries' );
373 373
 
374 374
 		$params = FrmForm::get_admin_params();
375 375
 
376
-        if ( isset($params['keep_post']) && $params['keep_post'] ) {
376
+        if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
377 377
             //unlink entry from post
378 378
             global $wpdb;
379 379
 			$wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $params['id'] ) );
@@ -452,9 +452,9 @@  discard block
 block discarded – undo
452 452
         if ( ! isset( $frm_vars['form_params'] ) ) {
453 453
             $frm_vars['form_params'] = array();
454 454
         }
455
-		$frm_vars['form_params'][ $form->id ] = $params;
455
+		$frm_vars['form_params'][$form->id] = $params;
456 456
 
457
-		if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
457
+		if ( isset( $frm_vars['created_entries'][$form_id] ) ) {
458 458
             return;
459 459
         }
460 460
 
@@ -469,13 +469,13 @@  discard block
 block discarded – undo
469 469
 		 */
470 470
 		$errors = apply_filters( 'frm_entries_before_create', $errors, $form );
471 471
 
472
-		$frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
472
+		$frm_vars['created_entries'][$form_id] = array( 'errors' => $errors );
473 473
 
474 474
         if ( empty( $errors ) ) {
475 475
 			$_POST['frm_skip_cookie'] = 1;
476 476
             if ( $params['action'] == 'create' ) {
477
-				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
478
-					$frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST );
477
+				if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][$form_id]['entry_id'] ) ) {
478
+					$frm_vars['created_entries'][$form_id]['entry_id'] = FrmEntry::create( $_POST );
479 479
                 }
480 480
             }
481 481
 
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 	}
511 511
 
512 512
 	public static function filter_shortcode_value( $value, $tag, $atts, $field ) {
513
-        $plain_text = add_filter('frm_plain_text_email', true);
513
+        $plain_text = add_filter( 'frm_plain_text_email', true );
514 514
 		FrmEntryFormat::textarea_display_value( $field->type, $plain_text, $value );
515 515
 
516 516
         return $value;
@@ -522,9 +522,9 @@  discard block
 block discarded – undo
522 522
 	}
523 523
 
524 524
 	public static function entry_sidebar( $entry ) {
525
-        $data = maybe_unserialize($entry->description);
526
-        $date_format = get_option('date_format');
527
-        $time_format = get_option('time_format');
525
+        $data = maybe_unserialize( $entry->description );
526
+        $date_format = get_option( 'date_format' );
527
+        $time_format = get_option( 'time_format' );
528 528
 		if ( isset( $data['browser'] ) ) {
529 529
 			$browser = FrmEntryFormat::get_browser( $data['browser'] );
530 530
 		}
Please login to merge, or discard this patch.