Completed
Push — master ( de6a17...35dc2a )
by Sam
02:15
created
src/Controllers/MapController.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	protected function set_up( $args ) {
40 40
 		$db = new Database( $this->wpdb );
41
-		$this->table = $db->get_table( $args['table'] );
41
+		$this->table = $db->get_table( $args[ 'table' ] );
42 42
 
43 43
 		// Check that a point column exists.
44 44
 		$points = $this->table->get_columns( 'point' );
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		$this->point_col_name = $point_col->get_name();
50 50
 
51 51
 		// Apply filters.
52
-		$filter_param = (isset( $args['filter'] )) ? $args['filter'] : array();
52
+		$filter_param = ( isset( $args[ 'filter' ] ) ) ? $args[ 'filter' ] : array();
53 53
 		$this->table->add_filters( $filter_param );
54 54
 		$this->table->add_filter( $this->point_col_name, 'not empty', '' );
55 55
 	}
Please login to merge, or discard this patch.
src/Controllers/ErdController.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,10 +37,10 @@
 block discarded – undo
37 37
 		$db = new \WordPress\Tabulate\DB\Database( $this->wpdb );
38 38
 		$this->selected_tables = array();
39 39
 		foreach ( $db->get_tables() as $table ) {
40
-			$this->tables[] = $table;
40
+			$this->tables[ ] = $table;
41 41
 			// If any tables are requested, only show them.
42
-			if ( isset( $_GET['tables'] ) && count( $_GET['tables'] ) > 0 ) {
43
-				if ( isset( $_GET['tables'][ $table->get_name() ] ) ) {
42
+			if ( isset( $_GET[ 'tables' ] ) && count( $_GET[ 'tables' ] ) > 0 ) {
43
+				if ( isset( $_GET[ 'tables' ][ $table->get_name() ] ) ) {
44 44
 					$this->selected_tables[ $table->get_name() ] = $table;
45 45
 				}
46 46
 			} else { // Otherwise, default to all linked tables.
Please login to merge, or discard this patch.
src/Controllers/ShortcodeController.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 			'search' => null,
54 54
 		);
55 55
 		$attrs = shortcode_atts( $defaults, $raw_attrs );
56
-		if ( ! isset( $attrs['table'] ) ) {
56
+		if ( ! isset( $attrs[ 'table' ] ) ) {
57 57
 			$msg = "The 'table' attribute must be set. Attributes found: [";
58 58
 			foreach ( $raw_attrs as $k => $v ) {
59 59
 				$msg .= ' ' . htmlentities2( $k ) . ' = "' . htmlentities2( $v ) . '" ';
@@ -61,19 +61,19 @@  discard block
 block discarded – undo
61 61
 			$msg .= "]";
62 62
 			return $this->error( $msg );
63 63
 		}
64
-		$table = $this->db->get_table( $attrs['table'] );
64
+		$table = $this->db->get_table( $attrs[ 'table' ] );
65 65
 		if ( ! $table ) {
66 66
 			if ( ! is_user_logged_in() ) {
67 67
 				return $this->error( "You are not logged in. " . wp_loginout( get_the_permalink(), false ) );
68 68
 			}
69 69
 			return $this->error();
70 70
 		}
71
-		$format_method = $attrs['format'] . '_format';
71
+		$format_method = $attrs[ 'format' ] . '_format';
72 72
 		if ( is_callable( array( $this, $format_method ) ) ) {
73 73
 			wp_enqueue_script( 'tabulate-scripts' );
74 74
 			return $this->$format_method( $table, $attrs, $_REQUEST );
75 75
 		} else {
76
-			return $this->error( "Format '{$attrs['format']}' not available." );
76
+			return $this->error( "Format '{$attrs[ 'format' ]}' not available." );
77 77
 		}
78 78
 	}
79 79
 
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	protected function record_format( Table $table, $attrs, $query = null ) {
105 105
 		// Check for the ident shortcode parameter...
106
-		if ( isset( $attrs['ident'] ) ) {
107
-			$ident = $attrs['ident'];
106
+		if ( isset( $attrs[ 'ident' ] ) ) {
107
+			$ident = $attrs[ 'ident' ];
108 108
 		}
109 109
 		// ...or the tablename=ident URL parameter.
110 110
 		if ( isset( $query[ $table->get_name() ] ) && is_scalar( $query[ $table->get_name() ] ) ) {
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		$template = new Template( 'record/shortcode.html' );
140 140
 		$template->table = $table;
141 141
 		$template->record = $table->get_default_record();
142
-		$template->return_to = ( isset( $attrs['return_to'] ) ) ? $attrs['return_to'] : get_the_permalink();
142
+		$template->return_to = ( isset( $attrs[ 'return_to' ] ) ) ? $attrs[ 'return_to' ] : get_the_permalink();
143 143
 		return $template->render();
144 144
 	}
145 145
 
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 	protected function list_format( Table $table, $attrs ) {
165 165
 		$titles = array();
166 166
 		foreach ( $table->get_records() as $rec ) {
167
-			$titles[] = $rec->get_title();
167
+			$titles[ ] = $rec->get_title();
168 168
 		}
169
-		$glue = ( ! empty( $attrs['glue'] ) ) ? $attrs['glue'] : ', ';
169
+		$glue = ( ! empty( $attrs[ 'glue' ] ) ) ? $attrs[ 'glue' ] : ', ';
170 170
 		return '<span class="tabulate list-format">' . join( $glue, $titles ) . '</span>';
171 171
 	}
172 172
 
@@ -181,19 +181,19 @@  discard block
 block discarded – undo
181 181
 	protected function table_format( Table $table, $attrs, $query = null ) {
182 182
 		// Filters.
183 183
 		// Apply filters from the URL query parameters.
184
-		if ( isset( $query['table'] ) && $query['table'] === $table->get_name() ) {
185
-			$query_filters = (isset( $query['filter'] )) ? $query['filter'] : array();
184
+		if ( isset( $query[ 'table' ] ) && $query[ 'table' ] === $table->get_name() ) {
185
+			$query_filters = ( isset( $query[ 'filter' ] ) ) ? $query[ 'filter' ] : array();
186 186
 			$table->add_filters( $query_filters );
187 187
 		}
188 188
 
189 189
 		// Pagination.
190 190
 		$page_num = 1;
191
-		if ( isset( $query['tabulate_p'] ) && is_numeric( $query['tabulate_p'] ) ) {
192
-			$page_num = abs( $query['tabulate_p'] );
191
+		if ( isset( $query[ 'tabulate_p' ] ) && is_numeric( $query[ 'tabulate_p' ] ) ) {
192
+			$page_num = abs( $query[ 'tabulate_p' ] );
193 193
 		}
194 194
 		$table->set_current_page_num( $page_num );
195
-		if ( isset( $query['tabulate_psize'] ) ) {
196
-			$table->set_records_per_page( $query['tabulate_psize'] );
195
+		if ( isset( $query[ 'tabulate_psize' ] ) ) {
196
+			$table->set_records_per_page( $query[ 'tabulate_psize' ] );
197 197
 		}
198 198
 
199 199
 		// Construct the HTML.
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		$template->records = $table->get_records();
204 204
 
205 205
 		// Add the search form if required.
206
-		$template->search = ! empty( $attrs['search'] );
206
+		$template->search = ! empty( $attrs[ 'search' ] );
207 207
 		$template->form_action = get_the_permalink();
208 208
 
209 209
 		// Return completed HTML output.
Please login to merge, or discard this patch.
src/DB/Grants.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 			self::ANON_ROLE => 'Anonymous User',
68 68
 		);
69 69
 		foreach ( wp_roles()->roles as $role_name => $role ) {
70
-			$roles[ $role_name ] = $role['name'];
70
+			$roles[ $role_name ] = $role[ 'name' ];
71 71
 		}
72 72
 		return $roles;
73 73
 	}
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 		$cap = substr( $cap_full_name, strlen( TABULATE_SLUG ) + 1 );
123 123
 
124 124
 		// Set up basic data.
125
-		$table_name = ( $args[2] ) ? $args[2] : false;
125
+		$table_name = ( $args[ 2 ] ) ? $args[ 2 ] : false;
126 126
 		$grants = new self();
127 127
 
128 128
 		// Users with 'promote_users' capability can do everything.
129
-		if ( isset( $all_capabilities['promote_users'] ) ) {
129
+		if ( isset( $all_capabilities[ 'promote_users' ] ) ) {
130 130
 			$all_capabilities[ $cap_full_name ] = true;
131 131
 		}
132 132
 
Please login to merge, or discard this patch.
src/Menus.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,6 @@
 block discarded – undo
7 7
 
8 8
 namespace WordPress\Tabulate;
9 9
 
10
-use WordPress\Tabulate\Controllers\ControllerBase;
11
-
12 10
 /**
13 11
  * This class is an attempt to group all functionality around managing the menus
14 12
  * in the Admin Area in one place. It includes adding scripts and stylesheets.
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 		// Home page (also change the first submenu item's title).
74 74
 		add_menu_page( 'Tabulate', 'Tabulate', 'read', TABULATE_SLUG, $dispatch_callback );
75
-		$page_title = ( isset( $_GET['table'] ) ) ? Text::titlecase( $_GET['table'] ) : 'Tabulate';
75
+		$page_title = ( isset( $_GET[ 'table' ] ) ) ? Text::titlecase( $_GET[ 'table' ] ) : 'Tabulate';
76 76
 		add_submenu_page( TABULATE_SLUG, $page_title, 'Overview', 'read', TABULATE_SLUG, $dispatch_callback );
77 77
 
78 78
 		// Add submenu pages.
@@ -129,25 +129,25 @@  discard block
 block discarded – undo
129 129
 
130 130
 		// Only dispatch when it's our page.
131 131
 		$slug_lenth = strlen( TABULATE_SLUG );
132
-		if ( ! isset( $request['page'] ) || substr( $request['page'], 0, $slug_lenth ) !== TABULATE_SLUG ) {
132
+		if ( ! isset( $request[ 'page' ] ) || substr( $request[ 'page' ], 0, $slug_lenth ) !== TABULATE_SLUG ) {
133 133
 			return;
134 134
 		}
135 135
 
136 136
 		// Discern the controller name, based on an explicit request parameter, or
137 137
 		// the trailing part of the page slug (i.e. after 'tabulate_').
138 138
 		$controller_name = 'home';
139
-		if ( isset( $request['controller'] ) && strlen( $request['controller'] ) > 0 ) {
140
-			$controller_name = $request['controller'];
141
-		} elseif ( isset( $request['page'] ) && strlen( $request['page'] ) > $slug_lenth ) {
142
-			$controller_name = substr( $request['page'], $slug_lenth + 1 );
139
+		if ( isset( $request[ 'controller' ] ) && strlen( $request[ 'controller' ] ) > 0 ) {
140
+			$controller_name = $request[ 'controller' ];
141
+		} elseif ( isset( $request[ 'page' ] ) && strlen( $request[ 'page' ] ) > $slug_lenth ) {
142
+			$controller_name = substr( $request[ 'page' ], $slug_lenth + 1 );
143 143
 		}
144 144
 
145 145
 		// Create the controller and run the action.
146 146
 		$controller_classname = '\\WordPress\\Tabulate\\Controllers\\' . ucfirst( $controller_name ) . 'Controller';
147 147
 		$controller = new $controller_classname( $this->wpdb );
148 148
 		$controller->set_filesystem( $this->filesystem );
149
-		$action = ! empty( $request['action'] ) ? $request['action'] : 'index';
150
-		unset( $request['page'], $request['controller'], $request['action'] );
149
+		$action = ! empty( $request[ 'action' ] ) ? $request[ 'action' ] : 'index';
150
+		unset( $request[ 'page' ], $request[ 'controller' ], $request[ 'action' ] );
151 151
 		try {
152 152
 			$this->output = $controller->$action( $request );
153 153
 		} catch ( \Exception $e ) {
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		$script_url = plugins_url( TABULATE_SLUG ) . '/assets/scripts.js';
195 195
 		$deps = array( 'jquery-ui-autocomplete', 'tabulate-leaflet', 'tabulate-maskedinput', 'tabulate-timepicker' );
196 196
 		if ( Util::is_plugin_active( 'rest-api/plugin.php' ) ) {
197
-			$deps[] = 'wp-api';
197
+			$deps[ ] = 'wp-api';
198 198
 		}
199 199
 		wp_enqueue_script( 'tabulate-scripts', $script_url, $deps, TABULATE_VERSION, true );
200 200
 
Please login to merge, or discard this patch.
src/CSV.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
 	 * @throws \Exception On upload error or if the file isn't a CSV.
82 82
 	 */
83 83
 	private function save_file( $uploaded ) {
84
-		if ( isset( $uploaded['error'] ) ) {
85
-			throw new \Exception( $uploaded['error'] );
84
+		if ( isset( $uploaded[ 'error' ] ) ) {
85
+			throw new \Exception( $uploaded[ 'error' ] );
86 86
 		}
87
-		if ( 'text/csv' !== $uploaded['type'] ) {
88
-			unlink( $uploaded['file'] );
87
+		if ( 'text/csv' !== $uploaded[ 'type' ] ) {
88
+			unlink( $uploaded[ 'file' ] );
89 89
 			throw new \Exception( 'Only CSV files can be imported.' );
90 90
 		}
91 91
 		$this->hash = uniqid( TABULATE_SLUG );
92
-		rename( $uploaded['file'], get_temp_dir() . '/' . $this->hash );
92
+		rename( $uploaded[ 'file' ], get_temp_dir() . '/' . $this->hash );
93 93
 	}
94 94
 
95 95
 	/**
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 		$this->data = array();
113 113
 		$lines = $this->filesystem->get_contents_array( $file_path );
114 114
 		foreach ( $lines as $line ) {
115
-			$this->data[] = str_getcsv( $line );
115
+			$this->data[ ] = str_getcsv( $line );
116 116
 		}
117 117
 
118 118
 		// Extract headers.
119
-		$this->headers = $this->data[0];
120
-		unset( $this->data[0] );
119
+		$this->headers = $this->data[ 0 ];
120
+		unset( $this->data[ 0 ] );
121 121
 	}
122 122
 
123 123
 	/**
@@ -196,36 +196,36 @@  discard block
 block discarded – undo
196 196
 				$column = $table->get_column( $db_column_name );
197 197
 				// Required, is not an update, has no default, and is empty.
198 198
 				if ( $column->is_required() && ! $pk_set && ! $column->get_default() && empty( $value ) ) {
199
-					$col_errors[] = 'Required but empty';
199
+					$col_errors[ ] = 'Required but empty';
200 200
 				}
201 201
 				// Already exists, and is not an update.
202 202
 				if ( $column->is_unique() && ! $pk_set && $this->value_exists( $table, $column, $value ) ) {
203
-					$col_errors[] = "Unique value already present: '$value'";
203
+					$col_errors[ ] = "Unique value already present: '$value'";
204 204
 				}
205 205
 				// Too long (if the column has a size and the value is greater than this).
206 206
 				if ( ! $column->is_foreign_key() && ! $column->is_boolean()
207 207
 						&& $column->get_size() > 0
208 208
 						&& strlen( $value ) > $column->get_size() ) {
209
-					$col_errors[] = 'Value (' . $value . ') too long (maximum length of ' . $column->get_size() . ')';
209
+					$col_errors[ ] = 'Value (' . $value . ') too long (maximum length of ' . $column->get_size() . ')';
210 210
 				}
211 211
 				// Invalid foreign key value.
212 212
 				if ( ! empty( $value ) && $column->is_foreign_key() ) {
213 213
 					$err = $this->validate_foreign_key( $column, $value );
214 214
 					if ( $err ) {
215
-						$col_errors[] = $err;
215
+						$col_errors[ ] = $err;
216 216
 					}
217 217
 				}
218 218
 				// Dates.
219 219
 				if ( 'date' === $column->get_type() && ! empty( $value ) && 1 !== preg_match( '/\d{4}-\d{2}-\d{2}/', $value ) ) {
220
-					$col_errors[] = 'Value (' . $value . ') not in date format';
220
+					$col_errors[ ] = 'Value (' . $value . ') not in date format';
221 221
 				}
222 222
 				if ( 'year' === $column->get_type() && ! empty( $value ) && ( $value < 1901 || $value > 2155 ) ) {
223
-					$col_errors[] = 'Year values must be between 1901 and 2155 (' . $value . ' given)';
223
+					$col_errors[ ] = 'Year values must be between 1901 and 2155 (' . $value . ' given)';
224 224
 				}
225 225
 
226 226
 				if ( count( $col_errors ) > 0 ) {
227 227
 					// Construct error details array.
228
-					$errors[] = array(
228
+					$errors[ ] = array(
229 229
 						'column_name' => $this->headers[ $col_num ],
230 230
 						'column_number' => $col_num,
231 231
 						'field_name' => $column->get_name(),
Please login to merge, or discard this patch.
src/Controllers/ControllerBase.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @param string|boolean $download_name The name of the file, for the user to download.
64 64
 	 */
65 65
 	protected function send_file( $ext, $mime, $content, $download_name = false ) {
66
-		$download_name = ($download_name ?: date( 'Y-m-d' ) ) . '.' . $ext;
66
+		$download_name = ( $download_name ?: date( 'Y-m-d' ) ) . '.' . $ext;
67 67
 		header( 'Content-Encoding: UTF-8' );
68 68
 		header( 'Content-type: ' . $mime . '; charset=UTF-8' );
69 69
 		header( 'Content-Disposition: attachment; filename="' . $download_name . '"' );
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * @param string $action The action name.
78 78
 	 */
79 79
 	public function verify_nonce( $action ) {
80
-		$nonce = wp_verify_nonce( $_REQUEST['_wpnonce'], $action );
80
+		$nonce = wp_verify_nonce( $_REQUEST[ '_wpnonce' ], $action );
81 81
 		if ( ! $nonce ) {
82 82
 			wp_die();
83 83
 		}
Please login to merge, or discard this patch.
src/Controllers/TableController.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -49,28 +49,28 @@  discard block
 block discarded – undo
49 49
 	 * @return string
50 50
 	 */
51 51
 	public function index( $args ) {
52
-		$table = $this->get_table( $args['table'] );
52
+		$table = $this->get_table( $args[ 'table' ] );
53 53
 		if ( ! $table instanceof Table ) {
54 54
 			return $table;
55 55
 		}
56 56
 
57 57
 		// Pagination.
58
-		$page_num = (isset( $args['p'] ) && is_numeric( $args['p'] ) ) ? abs( $args['p'] ) : 1;
58
+		$page_num = ( isset( $args[ 'p' ] ) && is_numeric( $args[ 'p' ] ) ) ? abs( $args[ 'p' ] ) : 1;
59 59
 		$table->set_current_page_num( $page_num );
60
-		if ( isset( $args['psize'] ) ) {
61
-			$table->set_records_per_page( $args['psize'] );
60
+		if ( isset( $args[ 'psize' ] ) ) {
61
+			$table->set_records_per_page( $args[ 'psize' ] );
62 62
 		}
63 63
 
64 64
 		// Ordering.
65
-		if ( isset( $args['order_by'] ) ) {
66
-			$table->set_order_by( $args['order_by'] );
65
+		if ( isset( $args[ 'order_by' ] ) ) {
66
+			$table->set_order_by( $args[ 'order_by' ] );
67 67
 		}
68
-		if ( isset( $args['order_dir'] ) ) {
69
-			$table->set_order_dir( $args['order_dir'] );
68
+		if ( isset( $args[ 'order_dir' ] ) ) {
69
+			$table->set_order_dir( $args[ 'order_dir' ] );
70 70
 		}
71 71
 
72 72
 		// Filters.
73
-		$filter_param = (isset( $args['filter'] )) ? $args['filter'] : array();
73
+		$filter_param = ( isset( $args[ 'filter' ] ) ) ? $args[ 'filter' ] : array();
74 74
 		$table->add_filters( $filter_param );
75 75
 
76 76
 		// Give it all to the template.
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 		$template->stage = 'choose_file';
123 123
 
124 124
 		// First make sure the user is allowed to import data into this table.
125
-		$table = $this->get_table( $args['table'] );
125
+		$table = $this->get_table( $args[ 'table' ] );
126 126
 		$template->record = $table->get_default_record();
127 127
 		$template->action = 'import';
128 128
 		$template->table = $table;
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 		require_once ABSPATH . '/wp-admin/includes/file.php';
139 139
 		$template->form_action = $table->get_url( 'import' );
140 140
 		try {
141
-			$hash = isset( $_GET['hash'] ) ? $_GET['hash'] : false;
141
+			$hash = isset( $_GET[ 'hash' ] ) ? $_GET[ 'hash' ] : false;
142 142
 			$uploaded = false;
143
-			if ( isset( $_FILES['file'] ) ) {
143
+			if ( isset( $_FILES[ 'file' ] ) ) {
144 144
 				check_admin_referer( 'import-upload' );
145
-				$uploaded = wp_handle_upload( $_FILES['file'], array(
145
+				$uploaded = wp_handle_upload( $_FILES[ 'file' ], array(
146 146
 					'action' => $template->action,
147 147
 				) );
148 148
 			}
@@ -157,28 +157,28 @@  discard block
 block discarded – undo
157 157
 		 */
158 158
 		if ( $csv_file->loaded() ) {
159 159
 			$template->file = $csv_file;
160
-			$template->stage = $template->stages[1];
160
+			$template->stage = $template->stages[ 1 ];
161 161
 			$template->form_action .= "&hash=" . $csv_file->hash;
162 162
 		}
163 163
 
164 164
 		/*
165 165
 		 * Stage 3 of 4: Previewing.
166 166
 		 */
167
-		if ( $csv_file->loaded() && isset( $_POST['preview'] ) ) {
167
+		if ( $csv_file->loaded() && isset( $_POST[ 'preview' ] ) ) {
168 168
 			check_admin_referer( 'import-preview' );
169
-			$template->stage = $template->stages[2];
170
-			$template->columns = wp_json_encode( $_POST['columns'], [ true ] );
169
+			$template->stage = $template->stages[ 2 ];
170
+			$template->columns = wp_json_encode( $_POST[ 'columns' ], [ true ] );
171 171
 			$errors = array();
172 172
 			// Make sure all required columns are selected.
173 173
 			foreach ( $table->get_columns() as $col ) {
174 174
 				// Handle missing columns separately; other column errors are
175 175
 				// done in the CSV class. Missing columns don't matter if importing
176 176
 				// existing records.
177
-				$is_missing = empty( $_POST['columns'][ $col->get_name() ] );
177
+				$is_missing = empty( $_POST[ 'columns' ][ $col->get_name() ] );
178 178
 				$pk = $table->get_pk_column();
179
-				$pk_present = $pk && isset( $_POST['columns'][ $pk->get_name() ] );
179
+				$pk_present = $pk && isset( $_POST[ 'columns' ][ $pk->get_name() ] );
180 180
 				if ( ! $pk_present && $col->is_required() && $is_missing ) {
181
-					$errors[] = array(
181
+					$errors[ ] = array(
182 182
 						'column_name' => '',
183 183
 						'column_number' => '',
184 184
 						'field_name' => $col->get_name(),
@@ -187,17 +187,17 @@  discard block
 block discarded – undo
187 187
 					);
188 188
 				}
189 189
 			}
190
-			$template->errors = empty( $errors ) ? $csv_file->match_fields( $table, wp_unslash( $_POST['columns'] ) ) : $errors;
190
+			$template->errors = empty( $errors ) ? $csv_file->match_fields( $table, wp_unslash( $_POST[ 'columns' ] ) ) : $errors;
191 191
 		}
192 192
 
193 193
 		/*
194 194
 		 * Stage 4 of 4: Import.
195 195
 		 */
196
-		if ( $csv_file->loaded() && isset( $_POST['import'] ) ) {
196
+		if ( $csv_file->loaded() && isset( $_POST[ 'import' ] ) ) {
197 197
 			check_admin_referer( 'import-finish' );
198
-			$template->stage = $template->stages[3];
198
+			$template->stage = $template->stages[ 3 ];
199 199
 			$this->wpdb->query( 'BEGIN' );
200
-			$result = $csv_file->import_data( $table, json_decode( wp_unslash( $_POST['columns'] ), true ) );
200
+			$result = $csv_file->import_data( $table, json_decode( wp_unslash( $_POST[ 'columns' ] ), true ) );
201 201
 			$this->wpdb->query( 'COMMIT' );
202 202
 			$template->add_notice( 'updated', 'Import complete; ' . $result . ' rows imported.' );
203 203
 		}
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 	 */
214 214
 	public function calendar( $args ) {
215 215
 		// @todo Validate args.
216
-		$year_num = (isset( $args['year'] )) ? $args['year'] : date( 'Y' );
217
-		$month_num = (isset( $args['month'] )) ? $args['month'] : date( 'm' );
216
+		$year_num = ( isset( $args[ 'year' ] ) ) ? $args[ 'year' ] : date( 'Y' );
217
+		$month_num = ( isset( $args[ 'month' ] ) ) ? $args[ 'month' ] : date( 'm' );
218 218
 
219 219
 		$template = new \WordPress\Tabulate\Template( 'calendar.html' );
220
-		$table = $this->get_table( $args['table'] );
220
+		$table = $this->get_table( $args[ 'table' ] );
221 221
 
222 222
 		$template->table = $table;
223 223
 		$template->action = 'calendar';
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 					$records[ $date_val ] = array();
241 241
 				}
242 242
 				// Add this record to the day's list.
243
-				$records[ $date_val ][] = $rec;
243
+				$records[ $date_val ][ ] = $rec;
244 244
 			}
245 245
 		}
246 246
 		// $records is grouped by date, with each item in a single date being
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 	 */
260 260
 	public function export( $args ) {
261 261
 		// Get table.
262
-		$table = $this->get_table( $args['table'] );
262
+		$table = $this->get_table( $args[ 'table' ] );
263 263
 
264 264
 		// Filter and export.
265
-		$filter_param = ( isset( $args['filter'] )) ? $args['filter'] : array();
265
+		$filter_param = ( isset( $args[ 'filter' ] ) ) ? $args[ 'filter' ] : array();
266 266
 		$table->add_filters( $filter_param );
267 267
 		$filename = $table->export();
268 268
 
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 	 */
284 284
 	public function notfound( $args ) {
285 285
 		// Get table.
286
-		$table = $this->get_table( $args['table'] );
286
+		$table = $this->get_table( $args[ 'table' ] );
287 287
 
288 288
 		// Get the values from the request, or give up.
289
-		$filter_id = isset( $args['notfound'] ) ? $args['notfound'] : false;
290
-		$values_string = isset( $args['filter'][ $filter_id ]['value'] ) ? $args['filter'][ $filter_id ]['value'] : false;
289
+		$filter_id = isset( $args[ 'notfound' ] ) ? $args[ 'notfound' ] : false;
290
+		$values_string = isset( $args[ 'filter' ][ $filter_id ][ 'value' ] ) ? $args[ 'filter' ][ $filter_id ][ 'value' ] : false;
291 291
 		if ( ! $table instanceof Table || ! $values_string ) {
292 292
 			return;
293 293
 		}
@@ -322,12 +322,12 @@  discard block
 block discarded – undo
322 322
 	 * @return string
323 323
 	 */
324 324
 	public function timeline( $args ) {
325
-		$table = $this->get_table( $args['table'] );
325
+		$table = $this->get_table( $args[ 'table' ] );
326 326
 		$template = new \WordPress\Tabulate\Template( 'timeline.html' );
327 327
 		$template->action = 'timeline';
328 328
 		$template->table = $table;
329
-		$start_date_arg = (isset( $args['start_date'] )) ? $args['start_date'] : date( 'Y-m-d' );
330
-		$end_date_arg = (isset( $args['end_date'] )) ? $args['end_date'] : date( 'Y-m-d' );
329
+		$start_date_arg = ( isset( $args[ 'start_date' ] ) ) ? $args[ 'start_date' ] : date( 'Y-m-d' );
330
+		$end_date_arg = ( isset( $args[ 'end_date' ] ) ) ? $args[ 'end_date' ] : date( 'Y-m-d' );
331 331
 		$start_date = new \DateTime( $start_date_arg );
332 332
 		$end_date = new \DateTime( $end_date_arg );
333 333
 		if ( $start_date->diff( $end_date, true )->d < 7 ) {
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 			if ( ! isset( $data[ $record->get_title() ] ) ) {
344 344
 				$data[ $record->get_title() ] = array();
345 345
 			}
346
-			$data[ $record->get_title() ][] = $record;
346
+			$data[ $record->get_title() ][ ] = $record;
347 347
 		}
348 348
 		$template->data = $data;
349 349
 		return $template->render();
Please login to merge, or discard this patch.