Completed
Branch 3.0 (7d679c)
by Stephanie
02:50
created
classes/controllers/FrmXMLController.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
     		return;
13 13
     	}
14 14
 
15
-        $set_err = libxml_use_internal_errors(true);
15
+        $set_err = libxml_use_internal_errors( true );
16 16
         $loader = libxml_disable_entity_loader( true );
17 17
 
18 18
 		$files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) );
19 19
 
20 20
         foreach ( (array) $files as $file ) {
21
-            FrmXMLHelper::import_xml($file);
22
-            unset($file);
21
+            FrmXMLHelper::import_xml( $file );
22
+            unset( $file );
23 23
         }
24 24
         /*
25 25
         if(is_wp_error($result))
@@ -70,41 +70,41 @@  discard block
 block discarded – undo
70 70
         $errors = array();
71 71
         $message = '';
72 72
 
73
-        $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce');
73
+        $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'import-xml', 'import-xml-nonce' );
74 74
         if ( $permission_error !== false ) {
75 75
             $errors[] = $permission_error;
76
-            self::form($errors);
76
+            self::form( $errors );
77 77
             return;
78 78
         }
79 79
 
80
-        if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
80
+        if ( ! isset( $_FILES ) || ! isset( $_FILES['frm_import_file'] ) || empty( $_FILES['frm_import_file']['name'] ) || (int) $_FILES['frm_import_file']['size'] < 1 ) {
81 81
             $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' );
82
-            self::form($errors);
82
+            self::form( $errors );
83 83
             return;
84 84
         }
85 85
 
86 86
         $file = $_FILES['frm_import_file']['tmp_name'];
87 87
 
88 88
         if ( ! is_uploaded_file( $file ) ) {
89
-            unset($file);
89
+            unset( $file );
90 90
             $errors[] = __( 'The file does not exist, please try again.', 'formidable' );
91
-            self::form($errors);
91
+            self::form( $errors );
92 92
             return;
93 93
         }
94 94
 
95 95
         //add_filter('upload_mimes', 'FrmXMLController::allow_mime');
96 96
 
97
-        $export_format = apply_filters('frm_export_formats', array(
97
+        $export_format = apply_filters( 'frm_export_formats', array(
98 98
 			'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ),
99 99
 		) );
100 100
 
101
-        $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION));
102
-        if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) {
101
+        $file_type = strtolower( pathinfo( $_FILES['frm_import_file']['name'], PATHINFO_EXTENSION ) );
102
+        if ( $file_type != 'xml' && isset( $export_format[$file_type] ) ) {
103 103
             // allow other file types to be imported
104 104
 			do_action( 'frm_before_import_' . $file_type );
105 105
             return;
106 106
         }
107
-        unset($file_type);
107
+        unset( $file_type );
108 108
 
109 109
 		if ( ! function_exists( 'libxml_disable_entity_loader' ) ) {
110 110
 			$errors[] = __( 'XML import is not enabled on your server.', 'formidable' );
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
 		libxml_use_internal_errors( $set_err );
124 124
 		libxml_disable_entity_loader( $loader );
125 125
 
126
-        self::form($errors, $message);
126
+        self::form( $errors, $message );
127 127
     }
128 128
 
129 129
     public static function export_xml() {
130 130
         $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' );
131
-        if ( ! empty($error) ) {
131
+        if ( ! empty( $error ) ) {
132 132
             wp_die( $error );
133 133
         }
134 134
 
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
         }
143 143
 
144 144
         if ( $format == 'xml' ) {
145
-            self::generate_xml($type, compact('ids'));
145
+            self::generate_xml( $type, compact( 'ids' ) );
146 146
 		} if ( $format == 'csv' ) {
147
-			self::generate_csv( compact('ids') );
147
+			self::generate_csv( compact( 'ids' ) );
148 148
         } else {
149
-			do_action( 'frm_export_format_' . $format, compact('ids') );
149
+			do_action( 'frm_export_format_' . $format, compact( 'ids' ) );
150 150
         }
151 151
 
152 152
         wp_die();
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		foreach ( $type as $tb_type ) {
190 190
             $where = array();
191 191
 			$join = '';
192
-            $table = $tables[ $tb_type ];
192
+            $table = $tables[$tb_type];
193 193
 
194 194
 			$select = $table . '.id';
195 195
             $query_vars = array();
@@ -200,20 +200,20 @@  discard block
 block discarded – undo
200 200
                     if ( $args['ids'] ) {
201 201
 						$where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] );
202 202
                 	} else {
203
-						$where[ $table . '.status !' ] = 'draft';
203
+						$where[$table . '.status !'] = 'draft';
204 204
                 	}
205 205
                 break;
206 206
                 case 'actions':
207 207
 					$select = $table . '.ID';
208 208
 					$where['post_type'] = FrmFormActionsController::$action_post_type;
209
-                    if ( ! empty($args['ids']) ) {
209
+                    if ( ! empty( $args['ids'] ) ) {
210 210
 						$where['menu_order'] = $args['ids'];
211 211
                     }
212 212
                 break;
213 213
                 case 'items':
214 214
                     //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)";
215 215
                     if ( $args['ids'] ) {
216
-						$where[ $table . '.form_id' ] = $args['ids'];
216
+						$where[$table . '.form_id'] = $args['ids'];
217 217
                     }
218 218
                 break;
219 219
                 case 'styles':
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
                     $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)';
248 248
                     $where['pm.meta_key'] = 'frm_form_id';
249 249
 
250
-                    if ( empty($args['ids']) ) {
250
+                    if ( empty( $args['ids'] ) ) {
251 251
                         $where['pm.meta_value >'] = 1;
252 252
                     } else {
253 253
                         $where['pm.meta_value'] = $args['ids'];
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
                 break;
256 256
             }
257 257
 
258
-			$records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select );
259
-            unset($tb_type);
258
+			$records[$tb_type] = FrmDb::get_col( $table . $join, $where, $select );
259
+            unset( $tb_type );
260 260
         }
261 261
 
262
-		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n";
262
+		echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo( 'charset' ) ) . "\" ?>\n";
263 263
 		include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' );
264 264
     }
265 265
 
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
 			$fid = FrmAppHelper::get_param( 'fid', '', 'get', 'sanitize_text_field' );
298 298
 		}
299 299
 
300
-		set_time_limit(0); //Remove time limit to execute this function
301
-		$mem_limit = str_replace('M', '', ini_get('memory_limit'));
300
+		set_time_limit( 0 ); //Remove time limit to execute this function
301
+		$mem_limit = str_replace( 'M', '', ini_get( 'memory_limit' ) );
302 302
 		if ( (int) $mem_limit < 256 ) {
303
-			ini_set('memory_limit', '256M');
303
+			ini_set( 'memory_limit', '256M' );
304 304
 		}
305 305
 
306 306
 		global $wpdb;
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 		$no_export_fields = FrmField::no_save_fields();
356 356
 		foreach ( $csv_fields as $k => $f ) {
357 357
 			if ( in_array( $f->type, $no_export_fields ) ) {
358
-				unset( $csv_fields[ $k ] );
358
+				unset( $csv_fields[$k] );
359 359
 			}
360 360
 		}
361 361
 
Please login to merge, or discard this patch.
classes/models/fields/FrmFieldType.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	protected function set_type( $type ) {
77 77
 		if ( empty( $this->type ) ) {
78
-			$this->type = $this->get_field_column('type');
78
+			$this->type = $this->get_field_column( 'type' );
79 79
 			if ( empty( $this->type ) && ! empty( $type ) ) {
80 80
 				$this->type = $type;
81 81
 			}
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 		$field_val = '';
92 92
 		if ( is_object( $this->field ) ) {
93 93
 			$field_val = $this->field->{$column};
94
-		} elseif ( is_array( $this->field ) && isset( $this->field[ $column ] ) ) {
95
-			$field_val = $this->field[ $column ];
94
+		} elseif ( is_array( $this->field ) && isset( $this->field[$column] ) ) {
95
+			$field_val = $this->field[$column];
96 96
 		}
97 97
 		return $field_val;
98 98
 	}
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
 	}
178 178
 
179 179
 	protected function builder_text_field() {
180
-		return '<input type="text" name="' . esc_attr( $this->html_name() ) . '" id="' . esc_attr( $this->html_id() ) . '" value="' . esc_attr( $this->get_field_column('default_value') ) . '" class="dyn_default_value" />';
180
+		return '<input type="text" name="' . esc_attr( $this->html_name() ) . '" id="' . esc_attr( $this->html_id() ) . '" value="' . esc_attr( $this->get_field_column( 'default_value' ) ) . '" class="dyn_default_value" />';
181 181
 	}
182 182
 
183 183
 	protected function html_name( $name = '' ) {
184 184
 		$prefix = empty( $name ) ? 'item_meta' : $name;
185
-		return $prefix . '[' . $this->get_field_column('id') . ']';
185
+		return $prefix . '[' . $this->get_field_column( 'id' ) . ']';
186 186
 	}
187 187
 
188 188
 	protected function html_id( $plus = '' ) {
189
-		return apply_filters( 'frm_field_get_html_id', 'field_' . $this->get_field_column('field_key') . $plus, $this->field );
189
+		return apply_filters( 'frm_field_get_html_id', 'field_' . $this->get_field_column( 'field_key' ) . $plus, $this->field );
190 190
     }
191 191
 
192 192
 	public function display_field_settings() {
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	}
277 277
 
278 278
 	protected function default_invalid_msg() {
279
-		$field_name = $this->get_field_column('name');
279
+		$field_name = $this->get_field_column( 'name' );
280 280
 		if ( $field_name == '' ) {
281 281
 			$invalid = __( 'This field is invalid', 'formidable' );
282 282
 		} else {
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 		$fields = FrmField::field_selection();
293 293
 		$fields = array_merge( $fields, FrmField::pro_field_selection() );
294 294
 
295
-		if ( isset( $fields[ $this->type ] ) ) {
296
-			$name = is_array( $fields[ $this->type ] ) ? $fields[ $this->type ]['name'] : $fields[ $this->type ];
295
+		if ( isset( $fields[$this->type] ) ) {
296
+			$name = is_array( $fields[$this->type] ) ? $fields[$this->type]['name'] : $fields[$this->type];
297 297
 		}
298 298
 
299 299
 		return $name;
@@ -387,23 +387,23 @@  discard block
 block discarded – undo
387 387
 
388 388
 	protected function replace_input_shortcode( $args, &$html ) {
389 389
 		unset( $args['field'] );
390
-		preg_match_all("/\[(input)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
390
+		preg_match_all( "/\[(input)\b(.*?)(?:(\/))?\]/s", $html, $shortcodes, PREG_PATTERN_ORDER );
391 391
 
392 392
 		foreach ( $shortcodes[0] as $short_key => $tag ) {
393 393
 			$tag = FrmShortcodeHelper::get_shortcode_tag( $shortcodes, $short_key, array( 'conditional' => false, 'conditional_check' => false ) );
394 394
 			if ( $tag == 'input' ) {
395
-				$shortcode_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
395
+				$shortcode_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][$short_key] );
396 396
 				$this->field['shortcodes'] = $this->prepare_input_shortcode_atts( $shortcode_atts );
397 397
 				$input = $this->include_front_field_input( $args, $shortcode_atts );
398 398
 
399
-				$html = str_replace( $shortcodes[0][ $short_key ], $input, $html );
399
+				$html = str_replace( $shortcodes[0][$short_key], $input, $html );
400 400
 			}
401 401
 		}
402 402
 	}
403 403
 
404 404
 	protected function prepare_input_shortcode_atts( $shortcode_atts ) {
405 405
 		if ( isset( $shortcode_atts['opt'] ) ) {
406
-			$shortcode_atts['opt']--;
406
+			$shortcode_atts['opt'] --;
407 407
 		}
408 408
 
409 409
 		$this->field['input_class'] = isset( $shortcode_atts['class'] ) ? $shortcode_atts['class'] : '';
@@ -466,8 +466,8 @@  discard block
 block discarded – undo
466 466
 
467 467
 	protected function fill_display_field_values( $args = array() ) {
468 468
 		$defaults = array(
469
-			'field_name'    => 'item_meta[' . $this->get_field_column('id') . ']',
470
-			'field_id'      => $this->get_field_column('id'),
469
+			'field_name'    => 'item_meta[' . $this->get_field_column( 'id' ) . ']',
470
+			'field_id'      => $this->get_field_column( 'id' ),
471 471
 			'field_plus_id' => '',
472 472
 			'section_id'    => '',
473 473
 		);
@@ -504,8 +504,8 @@  discard block
 block discarded – undo
504 504
 		$value = $this->prepare_display_value( $value, $atts );
505 505
 
506 506
 		if ( is_array( $value ) ) {
507
-			if ( isset( $atts['show'] ) && $atts['show'] && isset( $value[ $atts['show'] ] ) ) {
508
-				$value = $value[ $atts['show'] ];
507
+			if ( isset( $atts['show'] ) && $atts['show'] && isset( $value[$atts['show']] ) ) {
508
+				$value = $value[$atts['show']];
509 509
 			} elseif ( ! isset( $atts['return_array'] ) || ! $atts['return_array'] ) {
510 510
 				$sep = isset( $atts['sep'] ) ? $atts['sep'] : ', ';
511 511
 				$value = implode( $sep, $value );
@@ -564,8 +564,8 @@  discard block
 block discarded – undo
564 564
 		$saved_entries = $atts['ids'];
565 565
 		$new_value = array();
566 566
 		foreach ( (array) $value as $old_child_id ) {
567
-			if ( isset( $saved_entries[ $old_child_id ] ) ) {
568
-				$new_value[] = $saved_entries[ $old_child_id ];
567
+			if ( isset( $saved_entries[$old_child_id] ) ) {
568
+				$new_value[] = $saved_entries[$old_child_id];
569 569
 			}
570 570
 		}
571 571
 
Please login to merge, or discard this patch.
classes/helpers/FrmListHelper.php 1 patch
Spacing   +17 added lines, -17 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
 
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 			return $this->get_pagenum();
198 198
 		}
199 199
 
200
-		if ( isset( $this->_pagination_args[ $key ] ) ) {
201
-			return $this->_pagination_args[ $key ];
200
+		if ( isset( $this->_pagination_args[$key] ) ) {
201
+			return $this->_pagination_args[$key];
202 202
 		}
203 203
 	}
204 204
 
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 	}
254 254
 
255 255
 	private function hidden_search_inputs( $param_name ) {
256
-		if ( ! empty( $_REQUEST[ $param_name ] ) ) {
257
-			echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[ $param_name ] ) . '" />';
256
+		if ( ! empty( $_REQUEST[$param_name] ) ) {
257
+			echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $_REQUEST[$param_name] ) . '" />';
258 258
 		}
259 259
 	}
260 260
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 
298 298
 		echo "<ul class='subsubsub'>\n";
299 299
 		foreach ( $views as $class => $view ) {
300
-			$views[ $class ] = "\t<li class='$class'>$view";
300
+			$views[$class] = "\t<li class='$class'>$view";
301 301
 		}
302 302
 		echo implode( " |</li>\n", $views ) . "</li>\n";
303 303
 		echo '</ul>';
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 
393 393
 	private static function get_bulk_action( $action_name ) {
394 394
 		$action = false;
395
-		if ( isset( $_REQUEST[ $action_name ] ) && -1 != sanitize_text_field( $_REQUEST[ $action_name ] ) ) {
396
-			$action = sanitize_text_field( $_REQUEST[ $action_name ] );
395
+		if ( isset( $_REQUEST[$action_name] ) && -1 != sanitize_text_field( $_REQUEST[$action_name] ) ) {
396
+			$action = sanitize_text_field( $_REQUEST[$action_name] );
397 397
 		}
398 398
 		return $action;
399 399
 	}
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 
419 419
 		$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
420 420
 		foreach ( $actions as $action => $link ) {
421
-			++$i;
421
+			++ $i;
422 422
 			( $i == $action_count ) ? $sep = '' : $sep = ' | ';
423 423
 			$out .= "<span class='$action'>$link$sep</span>";
424 424
 		}
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 			'prev'  => __( 'Previous page' ),
628 628
 			'next'  => __( 'Next page' ),
629 629
 		);
630
-		return $labels[ $link ];
630
+		return $labels[$link];
631 631
 	}
632 632
 
633 633
 	private function current_url() {
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 
716 716
 		// If the primary column doesn't exist fall back to the
717 717
 		// first non-checkbox column.
718
-		if ( ! isset( $columns[ $default ] ) ) {
718
+		if ( ! isset( $columns[$default] ) ) {
719 719
 			$default = FrmListHelper::get_default_primary_column_name();
720 720
 		}
721 721
 
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 		 */
730 730
 		$column  = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
731 731
 
732
-		if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
732
+		if ( empty( $column ) || ! isset( $columns[$column] ) ) {
733 733
 			$column = $default;
734 734
 		}
735 735
 
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
 			// In 4.3, we added a fourth argument for primary column.
752 752
 			$column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
753 753
 			foreach ( $this->_column_headers as $key => $value ) {
754
-				$column_headers[ $key ] = $value;
754
+				$column_headers[$key] = $value;
755 755
 			}
756 756
 
757 757
 			return $column_headers;
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 				$data[1] = false;
785 785
 			}
786 786
 
787
-			$sortable[ $id ] = $data;
787
+			$sortable[$id] = $data;
788 788
 		}
789 789
 
790 790
 		$primary = $this->get_primary_column_name();
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
 			static $cb_counter = 1;
840 840
 			$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
841 841
 				. '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
842
-			$cb_counter++;
842
+			$cb_counter ++;
843 843
 		}
844 844
 
845 845
 		foreach ( $columns as $column_key => $column_display_name ) {
@@ -859,8 +859,8 @@  discard block
 block discarded – undo
859 859
 				$class[] = 'column-primary';
860 860
 			}
861 861
 
862
-			if ( isset( $sortable[ $column_key ] ) ) {
863
-				list( $orderby, $desc_first ) = $sortable[ $column_key ];
862
+			if ( isset( $sortable[$column_key] ) ) {
863
+				list( $orderby, $desc_first ) = $sortable[$column_key];
864 864
 
865 865
 				if ( $current_orderby == $orderby ) {
866 866
 					$order = 'asc' == $current_order ? 'desc' : 'asc';
Please login to merge, or discard this patch.