@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | if ( ! $table_info ) { |
16 | 16 | $table_info = array(); |
17 | 17 | foreach ( $db->get_tables() as $table ) { |
18 | - $table_info[] = array( |
|
18 | + $table_info[ ] = array( |
|
19 | 19 | 'title' => $table->get_title(), |
20 | 20 | 'count' => $table->count_records(), |
21 | 21 | 'url' => $table->get_url(), |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | // Reports. |
32 | 32 | $reports_table = $db->get_table( \WordPress\Tabulate\DB\Reports::reports_table_name() ); |
33 | - $template->reports = ($reports_table) ? $reports_table->get_records( false ) : array(); |
|
33 | + $template->reports = ( $reports_table ) ? $reports_table->get_records( false ) : array(); |
|
34 | 34 | |
35 | 35 | return $template->render(); |
36 | 36 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $db = new Database( $this->wpdb ); |
48 | 48 | $out = array(); |
49 | 49 | foreach ( $db->get_tables( false ) as $table ) { |
50 | - $out[] = array( |
|
50 | + $out[ ] = array( |
|
51 | 51 | 'value' => $table->get_name(), |
52 | 52 | 'label' => $table->get_title(), |
53 | 53 | ); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $out = array(); |
66 | 66 | foreach ( $tables as $table ) { |
67 | 67 | if ( Grants::current_user_can( Grants::CREATE, $table->get_name() ) ) { |
68 | - $out[] = $table->get_name(); |
|
68 | + $out[ ] = $table->get_name(); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | return $out; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @return array |
82 | 82 | */ |
83 | 83 | public function foreign_key_values( \WP_REST_Request $request ) { |
84 | - if ( ! isset( $this->get['term'] ) ) { |
|
84 | + if ( ! isset( $this->get[ 'term' ] ) ) { |
|
85 | 85 | return array(); |
86 | 86 | } |
87 | 87 | $db = new Database( $this->wpdb ); |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | return array(); |
91 | 91 | } |
92 | 92 | // First get any exact matches. |
93 | - $out = $this->foreign_key_values_build( $table, '=', $this->get['term'] ); |
|
93 | + $out = $this->foreign_key_values_build( $table, '=', $this->get[ 'term' ] ); |
|
94 | 94 | // Then get any 'contains' matches. |
95 | - $out += $this->foreign_key_values_build( $table, 'like', '%' . $this->get['term'] . '%' ); |
|
95 | + $out += $this->foreign_key_values_build( $table, 'like', '%' . $this->get[ 'term' ] . '%' ); |
|
96 | 96 | return $out; |
97 | 97 | } |
98 | 98 |
@@ -25,7 +25,7 @@ |
||
25 | 25 | */ |
26 | 26 | public function index( $args ) { |
27 | 27 | $db = new Database( $this->wpdb ); |
28 | - $id = isset( $args['id'] ) ? $args['id'] : Reports::DEFAULT_REPORT_ID; |
|
28 | + $id = isset( $args[ 'id' ] ) ? $args[ 'id' ] : Reports::DEFAULT_REPORT_ID; |
|
29 | 29 | $reports = new Reports( $db ); |
30 | 30 | $template = $reports->get_template( $id ); |
31 | 31 | $out = $template->render(); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | public static function add_path( $new_path ) { |
83 | 83 | $path = realpath( $new_path ); |
84 | 84 | if ( ! in_array( $path, self::$paths, true ) ) { |
85 | - self::$paths[] = $path; |
|
85 | + self::$paths[ ] = $path; |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | foreach ( self::$paths as $path ) { |
106 | 106 | $dir = $path . '/' . ltrim( $directory, '/' ); |
107 | 107 | foreach ( preg_grep( '/^[^\.].*\.(twig|html)$/', scandir( $dir ) ) as $file ) { |
108 | - $templates[] = $directory . '/' . $file; |
|
108 | + $templates[ ] = $directory . '/' . $file; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | return $templates; |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | * @param string $message The message to display. |
151 | 151 | */ |
152 | 152 | public function add_notice( $type, $message ) { |
153 | - $this->data['notices'][] = array( |
|
153 | + $this->data[ 'notices' ][ ] = array( |
|
154 | 154 | 'type' => $type, |
155 | 155 | 'message' => $message, |
156 | 156 | ); |
157 | - set_transient( $this->transient_notices, $this->data['notices'] ); |
|
157 | + set_transient( $this->transient_notices, $this->data[ 'notices' ] ); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $twig->addFunction( $f, new \Twig_SimpleFunction( $f, $f ) ); |
183 | 183 | } |
184 | 184 | // Handle wp_nonce_field() differently in order to default it to returning the string. |
185 | - $wp_nonce_field = new \Twig_SimpleFunction( 'wp_nonce_field', function ( $action = -1, $name = "_wpnonce", $referer = true, $echo = false ) { |
|
185 | + $wp_nonce_field = new \Twig_SimpleFunction( 'wp_nonce_field', function( $action = -1, $name = "_wpnonce", $referer = true, $echo = false ) { |
|
186 | 186 | return wp_nonce_field( $action, $name, $referer, $echo ); |
187 | 187 | } ); |
188 | 188 | $twig->addFunction( $wp_nonce_field ); |
@@ -163,10 +163,10 @@ |
||
163 | 163 | ); |
164 | 164 | // Daft workaround for https://core.trac.wordpress.org/ticket/15158 . |
165 | 165 | if ( ! is_null( $old_val ) ) { |
166 | - $data['old_value'] = $old_val; |
|
166 | + $data[ 'old_value' ] = $old_val; |
|
167 | 167 | } |
168 | 168 | if ( ! is_null( $new_val ) ) { |
169 | - $data['new_value'] = $new_val; |
|
169 | + $data[ 'new_value' ] = $new_val; |
|
170 | 170 | } |
171 | 171 | // Save the change record. |
172 | 172 | $this->wpdb->insert( $this->changes_name(), $data ); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function __construct( $table, $data = array() ) { |
43 | 43 | $this->table = $table; |
44 | - $this->data = (object) $data; |
|
44 | + $this->data = ( object ) $data; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $title_parts = array(); |
176 | 176 | foreach ( $this->table->get_columns() as $col ) { |
177 | 177 | $col_name = $col->get_name() . self::FKTITLE; |
178 | - $title_parts[] = $this->$col_name(); |
|
178 | + $title_parts[ ] = $this->$col_name(); |
|
179 | 179 | } |
180 | 180 | return '[ ' . join( ' | ', $title_parts ) . ' ]'; |
181 | 181 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | 'table' => $this->table->get_name(), |
228 | 228 | ); |
229 | 229 | if ( $include_ident && false !== $this->get_primary_key() ) { |
230 | - $params['ident'] = $this->get_primary_key(); |
|
230 | + $params[ 'ident' ] = $this->get_primary_key(); |
|
231 | 231 | } |
232 | 232 | if ( is_array( $extra_params ) ) { |
233 | 233 | $params = array_merge( $params, $extra_params ); |
@@ -38,7 +38,7 @@ discard block |
||
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 |
||
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 | } |
@@ -37,10 +37,10 @@ |
||
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. |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | public function index( $args ) { |
38 | 38 | // Get database and table. |
39 | 39 | $db = new \WordPress\Tabulate\DB\Database( $this->wpdb ); |
40 | - $table = $db->get_table( $args['table'] ); |
|
40 | + $table = $db->get_table( $args[ 'table' ] ); |
|
41 | 41 | |
42 | 42 | // Give it all to the template. |
43 | 43 | $template = $this->get_template( $table ); |
44 | - if ( isset( $args['ident'] ) ) { |
|
45 | - $template->record = $table->get_record( $args['ident'] ); |
|
44 | + if ( isset( $args[ 'ident' ] ) ) { |
|
45 | + $template->record = $table->get_record( $args[ 'ident' ] ); |
|
46 | 46 | // Check permission. |
47 | 47 | if ( ! Grants::current_user_can( Grants::UPDATE, $table->get_name() ) ) { |
48 | 48 | $template->add_notice( 'error', 'You do not have permission to update data in this table.' ); |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | $template->add_notice( 'error', 'You do not have permission to create records in this table.' ); |
56 | 56 | } |
57 | 57 | // Add query-string values. |
58 | - if ( isset( $args['defaults'] ) ) { |
|
59 | - $template->record->set_multiple( $args['defaults'] ); |
|
58 | + if ( isset( $args[ 'defaults' ] ) ) { |
|
59 | + $template->record->set_multiple( $args[ 'defaults' ] ); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | // Don't save to non-updatable views. |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | wp_enqueue_script( 'dashboard' ); |
69 | 69 | |
70 | 70 | // Return to URL. |
71 | - if ( isset( $args['return_to'] ) ) { |
|
72 | - $template->return_to = $args['return_to']; |
|
71 | + if ( isset( $args[ 'return_to' ] ) ) { |
|
72 | + $template->return_to = $args[ 'return_to' ]; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | return $template->render(); |
@@ -83,21 +83,21 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function save( $args ) { |
85 | 85 | $db = new \WordPress\Tabulate\DB\Database( $this->wpdb ); |
86 | - $table = $db->get_table( $args['table'] ); |
|
86 | + $table = $db->get_table( $args[ 'table' ] ); |
|
87 | 87 | if ( ! $table ) { |
88 | 88 | // It shouldn't be possible to get here via the UI, so no message. |
89 | 89 | return false; |
90 | 90 | } |
91 | 91 | |
92 | 92 | // Guard against non-post requests. c.f. wp-comments-post.php. |
93 | - if ( ! isset( $_SERVER['REQUEST_METHOD'] ) || 'POST' !== $_SERVER['REQUEST_METHOD'] ) { |
|
93 | + if ( ! isset( $_SERVER[ 'REQUEST_METHOD' ] ) || 'POST' !== $_SERVER[ 'REQUEST_METHOD' ] ) { |
|
94 | 94 | header( 'Allow: POST' ); |
95 | 95 | header( 'HTTP/1.1 405 Method Not Allowed' ); |
96 | 96 | header( 'Content-Type: text/plain' ); |
97 | 97 | return false; |
98 | 98 | } |
99 | 99 | |
100 | - $record_ident = isset( $args['ident'] ) ? $args['ident'] : false; |
|
100 | + $record_ident = isset( $args[ 'ident' ] ) ? $args[ 'ident' ] : false; |
|
101 | 101 | $this->verify_nonce( 'tabulate-record-' . $record_ident ); |
102 | 102 | $template = $this->get_template( $table ); |
103 | 103 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $existing = $table->get_record( $pk ); |
108 | 108 | if ( ! $record_ident && $existing ) { |
109 | 109 | $template->add_notice( 'updated', "The record identified by '$pk' already exists." ); |
110 | - $_REQUEST['return_to'] = $existing->get_url(); |
|
110 | + $_REQUEST[ 'return_to' ] = $existing->get_url(); |
|
111 | 111 | } else { |
112 | 112 | // Otherwise, create a new one. |
113 | 113 | try { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } |
123 | 123 | } |
124 | 124 | // Redirect back to the edit form. |
125 | - $return_to = ( ! empty( $_REQUEST['return_to'] ) ) ? $_REQUEST['return_to'] : $template->record->get_url(); |
|
125 | + $return_to = ( ! empty( $_REQUEST[ 'return_to' ] ) ) ? $_REQUEST[ 'return_to' ] : $template->record->get_url(); |
|
126 | 126 | wp_safe_redirect( $return_to ); |
127 | 127 | exit; |
128 | 128 | } |
@@ -135,15 +135,15 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function delete( $args ) { |
137 | 137 | $db = new \WordPress\Tabulate\DB\Database( $this->wpdb ); |
138 | - $table = $db->get_table( $args['table'] ); |
|
139 | - $record_ident = isset( $args['ident'] ) ? $args['ident'] : false; |
|
138 | + $table = $db->get_table( $args[ 'table' ] ); |
|
139 | + $record_ident = isset( $args[ 'ident' ] ) ? $args[ 'ident' ] : false; |
|
140 | 140 | if ( ! $record_ident ) { |
141 | 141 | wp_safe_redirect( $table->get_url() ); |
142 | 142 | exit; |
143 | 143 | } |
144 | 144 | |
145 | 145 | // Ask for confirmation. |
146 | - if ( ! isset( $_POST['confirm_deletion'] ) ) { |
|
146 | + if ( ! isset( $_POST[ 'confirm_deletion' ] ) ) { |
|
147 | 147 | $template = new \WordPress\Tabulate\Template( 'record/delete.html' ); |
148 | 148 | $template->table = $table; |
149 | 149 | $template->record = $table->get_record( $record_ident ); |