@@ -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 ); |
@@ -144,33 +144,33 @@ discard block |
||
144 | 144 | protected function parse_info( $info ) { |
145 | 145 | |
146 | 146 | // Name. |
147 | - $this->name = $info['Field']; |
|
147 | + $this->name = $info[ 'Field' ]; |
|
148 | 148 | |
149 | 149 | // Type. |
150 | - $this->parse_type( $info['Type'] ); |
|
150 | + $this->parse_type( $info[ 'Type' ] ); |
|
151 | 151 | |
152 | 152 | // Default. |
153 | - $this->default_value = $info['Default']; |
|
153 | + $this->default_value = $info[ 'Default' ]; |
|
154 | 154 | |
155 | 155 | // Primary key. |
156 | - if ( 'PRI' === strtoupper( $info['Key'] ) ) { |
|
156 | + if ( 'PRI' === strtoupper( $info[ 'Key' ] ) ) { |
|
157 | 157 | $this->is_primary_key = true; |
158 | - if ( 'auto_increment' === $info['Extra'] ) { |
|
158 | + if ( 'auto_increment' === $info[ 'Extra' ] ) { |
|
159 | 159 | $this->is_auto_increment = true; |
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Unique key. |
164 | - $this->is_unique = ( 'UNI' === strtoupper( $info['Key'] ) ); |
|
164 | + $this->is_unique = ( 'UNI' === strtoupper( $info[ 'Key' ] ) ); |
|
165 | 165 | |
166 | 166 | // Comment. |
167 | - $this->comment = $info['Comment']; |
|
167 | + $this->comment = $info[ 'Comment' ]; |
|
168 | 168 | |
169 | 169 | // Collation. |
170 | - $this->collation = $info['Collation']; |
|
170 | + $this->collation = $info[ 'Collation' ]; |
|
171 | 171 | |
172 | 172 | // Is this column NULL? |
173 | - $this->nullable = ( 'YES' === $info['Null'] ); |
|
173 | + $this->nullable = ( 'YES' === $info[ 'Null' ] ); |
|
174 | 174 | |
175 | 175 | // Is this a foreign key? |
176 | 176 | if ( in_array( $this->get_name(), $this->get_table()->get_foreign_key_names(), true ) ) { |
@@ -302,14 +302,14 @@ discard block |
||
302 | 302 | public function get_xtype() { |
303 | 303 | $xtypes = self::get_xtypes(); |
304 | 304 | if ( $this->is_foreign_key() ) { |
305 | - return $xtypes['fk']; |
|
305 | + return $xtypes[ 'fk' ]; |
|
306 | 306 | } |
307 | 307 | if ( $this->is_boolean() ) { |
308 | - return $xtypes['boolean']; |
|
308 | + return $xtypes[ 'boolean' ]; |
|
309 | 309 | } |
310 | 310 | // Otherwise fall back on the first xtype with a matching type. |
311 | 311 | foreach ( $xtypes as $xtype ) { |
312 | - if ( strtoupper( $this->get_type() ) === $xtype['type'] ) { |
|
312 | + if ( strtoupper( $this->get_type() ) === $xtype[ 'type' ] ) { |
|
313 | 313 | return $xtype; |
314 | 314 | } |
315 | 315 | } |
@@ -506,22 +506,22 @@ discard block |
||
506 | 506 | $this->scale = null; |
507 | 507 | $this->options = null; |
508 | 508 | if ( preg_match( $varchar_pattern, $type_string, $matches ) ) { |
509 | - $this->type = $matches[1]; |
|
510 | - $this->size = (int) $matches[2]; |
|
509 | + $this->type = $matches[ 1 ]; |
|
510 | + $this->size = ( int ) $matches[ 2 ]; |
|
511 | 511 | } elseif ( preg_match( $decimal_pattern, $type_string, $matches ) ) { |
512 | 512 | $this->type = 'decimal'; |
513 | - $this->precision = $matches[1]; |
|
514 | - $this->scale = $matches[2]; |
|
513 | + $this->precision = $matches[ 1 ]; |
|
514 | + $this->scale = $matches[ 2 ]; |
|
515 | 515 | } elseif ( preg_match( $float_pattern, $type_string, $matches ) ) { |
516 | 516 | $this->type = 'float'; |
517 | - $this->precision = $matches[1]; |
|
518 | - $this->scale = $matches[2]; |
|
517 | + $this->precision = $matches[ 1 ]; |
|
518 | + $this->scale = $matches[ 2 ]; |
|
519 | 519 | } elseif ( preg_match( $integer_pattern, $type_string, $matches ) ) { |
520 | - $this->type = $matches[1]; |
|
521 | - $this->size = (int) $matches[2]; |
|
520 | + $this->type = $matches[ 1 ]; |
|
521 | + $this->size = ( int ) $matches[ 2 ]; |
|
522 | 522 | } elseif ( preg_match( $enum_pattern, $type_string, $matches ) ) { |
523 | - $this->type = $matches[1]; |
|
524 | - $values = explode( "','", $matches[2] ); |
|
523 | + $this->type = $matches[ 1 ]; |
|
524 | + $values = explode( "','", $matches[ 2 ] ); |
|
525 | 525 | $this->options = array_combine( $values, $values ); |
526 | 526 | } |
527 | 527 | } |
@@ -532,14 +532,14 @@ discard block |
||
532 | 532 | * @return string |
533 | 533 | */ |
534 | 534 | public function __toString() { |
535 | - $pk = ($this->is_primary_key) ? ' PK' : ''; |
|
536 | - $auto = ($this->is_auto_increment) ? ' AI' : ''; |
|
535 | + $pk = ( $this->is_primary_key ) ? ' PK' : ''; |
|
536 | + $auto = ( $this->is_auto_increment ) ? ' AI' : ''; |
|
537 | 537 | if ( $this->references ) { |
538 | 538 | $ref = ' References ' . $this->references . '.'; |
539 | 539 | } else { |
540 | 540 | $ref = ''; |
541 | 541 | } |
542 | - $size = ($this->size > 0) ? "($this->size)" : ''; |
|
542 | + $size = ( $this->size > 0 ) ? "($this->size)" : ''; |
|
543 | 543 | return $this->name . ' ' . strtoupper( $this->type ) . $size . $pk . $auto . $ref; |
544 | 544 | } |
545 | 545 | |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | public function get_current_column_definition() { |
552 | 552 | return self::get_column_definition( |
553 | 553 | $this->get_name(), |
554 | - $this->get_xtype()['name'], |
|
554 | + $this->get_xtype()[ 'name' ], |
|
555 | 555 | $this->get_size(), |
556 | 556 | $this->nullable(), |
557 | 557 | $this->get_default(), |
@@ -580,14 +580,14 @@ discard block |
||
580 | 580 | */ |
581 | 581 | public function alter( $new_name = null, $xtype_name = null, $size = null, $nullable = null, $default = null, $auto_increment = null, $unique = null, $comment = null, $target_table = null, $after = null ) { |
582 | 582 | // Any that have not been set explicitely should be unchanged. |
583 | - $new_name = ! is_null( $new_name ) ? (string) $new_name : $this->get_name(); |
|
584 | - $xtype_name = ! is_null( $xtype_name ) ? (string) $xtype_name : $this->get_xtype()['name']; |
|
583 | + $new_name = ! is_null( $new_name ) ? ( string ) $new_name : $this->get_name(); |
|
584 | + $xtype_name = ! is_null( $xtype_name ) ? ( string ) $xtype_name : $this->get_xtype()[ 'name' ]; |
|
585 | 585 | $size = ! is_null( $size ) ? $size : $this->get_size(); |
586 | - $nullable = ! is_null( $nullable ) ? (boolean) $nullable : $this->nullable(); |
|
587 | - $default = ! is_null( $default ) ? (string) $default : $this->get_default(); |
|
588 | - $auto_increment = ! is_null( $auto_increment ) ? (boolean) $auto_increment : $this->is_auto_increment(); |
|
589 | - $unique = ! is_null( $unique ) ? (boolean) $unique : $this->is_unique(); |
|
590 | - $comment = ! is_null( $comment ) ? (string) $comment : $this->get_comment(); |
|
586 | + $nullable = ! is_null( $nullable ) ? ( boolean ) $nullable : $this->nullable(); |
|
587 | + $default = ! is_null( $default ) ? ( string ) $default : $this->get_default(); |
|
588 | + $auto_increment = ! is_null( $auto_increment ) ? ( boolean ) $auto_increment : $this->is_auto_increment(); |
|
589 | + $unique = ! is_null( $unique ) ? ( boolean ) $unique : $this->is_unique(); |
|
590 | + $comment = ! is_null( $comment ) ? ( string ) $comment : $this->get_comment(); |
|
591 | 591 | $target_table = ! is_null( $target_table ) ? $target_table : $this->get_referenced_table(); |
592 | 592 | |
593 | 593 | // Check the current column definition. |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | if ( $this->is_unique() ) { |
603 | 603 | $sql = 'SHOW INDEXES FROM `' . $table->get_name() . '` WHERE Column_name LIKE "' . $this->get_name() . '"'; |
604 | 604 | foreach ( $wpdb->get_results( $sql, ARRAY_A ) as $index ) { |
605 | - $sql = "DROP INDEX `" . $index['Key_name'] . "` ON `" . $table->get_name() . "`"; |
|
605 | + $sql = "DROP INDEX `" . $index[ 'Key_name' ] . "` ON `" . $table->get_name() . "`"; |
|
606 | 606 | $wpdb->query( $sql ); |
607 | 607 | } |
608 | 608 | } |
@@ -660,23 +660,23 @@ discard block |
||
660 | 660 | public static function get_column_definition( $name, $xtype_name = null, $size = null, $nullable = true, $default = null, $auto_increment = null, $unique = null, $comment = null, $target_table = null, $after = null ) { |
661 | 661 | // Type. |
662 | 662 | $xtypes = self::get_xtypes(); |
663 | - $xtype = ( isset( $xtypes[ $xtype_name ] ) ) ? $xtypes[ $xtype_name ] : $xtypes['text_short']; |
|
664 | - $type_str = $xtype['type']; |
|
663 | + $xtype = ( isset( $xtypes[ $xtype_name ] ) ) ? $xtypes[ $xtype_name ] : $xtypes[ 'text_short' ]; |
|
664 | + $type_str = $xtype[ 'type' ]; |
|
665 | 665 | // Size. |
666 | 666 | $size_str = ''; |
667 | - if ( $xtype['sizes'] > 0 ) { |
|
668 | - $size_str = '(' . ( $size ? : 50 ) . ')'; |
|
667 | + if ( $xtype[ 'sizes' ] > 0 ) { |
|
668 | + $size_str = '(' . ( $size ?: 50 ) . ')'; |
|
669 | 669 | } |
670 | 670 | if ( 'boolean' === $xtype_name ) { |
671 | 671 | $size_str = '(1)'; |
672 | 672 | } |
673 | - $null_str = (true === $nullable) ? 'NULL' : 'NOT NULL'; |
|
673 | + $null_str = ( true === $nullable ) ? 'NULL' : 'NOT NULL'; |
|
674 | 674 | $default_str = ''; |
675 | 675 | if ( 'text_long' !== $xtype_name ) { |
676 | 676 | $default_str = ! empty( $default ) ? "DEFAULT '$default'" : ( $nullable ? 'DEFAULT NULL' : '' ); |
677 | 677 | } |
678 | 678 | $auto_increment_str = ''; |
679 | - if ( $auto_increment && 'integer' === $xtype['name'] ) { |
|
679 | + if ( $auto_increment && 'integer' === $xtype[ 'name' ] ) { |
|
680 | 680 | $auto_increment_str = 'AUTO_INCREMENT'; |
681 | 681 | } |
682 | 682 | $unique_str = $unique ? 'UNIQUE' : ''; |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | . ' (`' . $pk_col->get_name() . '`)'; |
698 | 698 | $type_str = $pk_col->get_type(); |
699 | 699 | $size_str = '(' . $pk_col->get_size() . ')'; |
700 | - $sign_str = ($pk_col->is_unsigned()) ? 'UNSIGNED' : ''; |
|
700 | + $sign_str = ( $pk_col->is_unsigned() ) ? 'UNSIGNED' : ''; |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | // Put it all together. |
@@ -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 ); |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | $db = new Database( $this->wpdb ); |
34 | 34 | $template->action = 'structure'; |
35 | 35 | $template->tables = $db->get_tables(); |
36 | - if ( isset( $args['table'] ) ) { |
|
37 | - $template->table = $db->get_table( $args['table'] ); |
|
36 | + if ( isset( $args[ 'table' ] ) ) { |
|
37 | + $template->table = $db->get_table( $args[ 'table' ] ); |
|
38 | 38 | $template->record = $template->table->get_default_record(); |
39 | 39 | } |
40 | 40 | $template->xtypes = Column::get_xtypes(); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function newtable( $args ) { |
50 | 50 | // Create table. |
51 | 51 | $db = new Database( $this->wpdb ); |
52 | - $table = $db->create_table( $args['new_table_name'] ); |
|
52 | + $table = $db->create_table( $args[ 'new_table_name' ] ); |
|
53 | 53 | |
54 | 54 | // Redirect user with message. |
55 | 55 | $template = new Template( 'table/schema.html' ); |
@@ -65,49 +65,49 @@ discard block |
||
65 | 65 | * @param string[] $args The request arguments. |
66 | 66 | */ |
67 | 67 | public function save( $args ) { |
68 | - if ( ! isset( $args['table'] ) || ! current_user_can( 'promote_users' ) ) { |
|
68 | + if ( ! isset( $args[ 'table' ] ) || ! current_user_can( 'promote_users' ) ) { |
|
69 | 69 | $url = admin_url( 'admin.php?page=tabulate' ); |
70 | 70 | wp_safe_redirect( $url ); |
71 | 71 | exit; |
72 | 72 | } |
73 | 73 | $db = new Database( $this->wpdb ); |
74 | - $table = $db->get_table( $args['table'] ); |
|
75 | - if ( isset( $args['delete'] ) ) { |
|
74 | + $table = $db->get_table( $args[ 'table' ] ); |
|
75 | + if ( isset( $args[ 'delete' ] ) ) { |
|
76 | 76 | wp_safe_redirect( $table->get_url( 'delete', null, 'schema' ) ); |
77 | 77 | exit; |
78 | 78 | } |
79 | 79 | |
80 | 80 | // Rename. |
81 | - $new_name = $args['table']; |
|
82 | - if ( $table instanceof Table && ! empty( $args['new_name'] ) ) { |
|
83 | - $table->rename( $args['new_name'] ); |
|
81 | + $new_name = $args[ 'table' ]; |
|
82 | + if ( $table instanceof Table && ! empty( $args[ 'new_name' ] ) ) { |
|
83 | + $table->rename( $args[ 'new_name' ] ); |
|
84 | 84 | $new_name = $table->get_name(); |
85 | 85 | } |
86 | 86 | |
87 | 87 | // Set comment. |
88 | - if ( isset( $args['new_comment'] ) ) { |
|
89 | - $table->set_comment( $args['new_comment'] ); |
|
88 | + if ( isset( $args[ 'new_comment' ] ) ) { |
|
89 | + $table->set_comment( $args[ 'new_comment' ] ); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | // Update columns. |
93 | - foreach ( $args['columns'] as $col_info ) { |
|
93 | + foreach ( $args[ 'columns' ] as $col_info ) { |
|
94 | 94 | // Validate inputs. |
95 | - $old_col_name = isset( $col_info['old_name'] ) ? $col_info['old_name'] : null; |
|
96 | - $new_col_name = isset( $col_info['new_name'] ) ? $col_info['new_name'] : null; |
|
97 | - $xtype = isset( $col_info['xtype'] ) ? $col_info['xtype'] : null; |
|
98 | - $size = isset( $col_info['size'] ) ? $col_info['size'] : null; |
|
99 | - $nullable = isset( $col_info['nullable'] ); |
|
100 | - $default = isset( $col_info['default'] ) ? $col_info['default'] : null; |
|
101 | - $auto_increment = isset( $args['auto_increment'] ) && $args['auto_increment'] === $old_col_name; |
|
102 | - $unique = isset( $col_info['unique'] ); |
|
103 | - $comment = isset( $col_info['comment'] ) ? $col_info['comment'] : null; |
|
104 | - $target_table = isset( $col_info['target_table'] ) ? $db->get_table( $col_info['target_table'] ) : null; |
|
105 | - $after = isset( $col_info['after'] ) ? $col_info['after'] : null; |
|
95 | + $old_col_name = isset( $col_info[ 'old_name' ] ) ? $col_info[ 'old_name' ] : null; |
|
96 | + $new_col_name = isset( $col_info[ 'new_name' ] ) ? $col_info[ 'new_name' ] : null; |
|
97 | + $xtype = isset( $col_info[ 'xtype' ] ) ? $col_info[ 'xtype' ] : null; |
|
98 | + $size = isset( $col_info[ 'size' ] ) ? $col_info[ 'size' ] : null; |
|
99 | + $nullable = isset( $col_info[ 'nullable' ] ); |
|
100 | + $default = isset( $col_info[ 'default' ] ) ? $col_info[ 'default' ] : null; |
|
101 | + $auto_increment = isset( $args[ 'auto_increment' ] ) && $args[ 'auto_increment' ] === $old_col_name; |
|
102 | + $unique = isset( $col_info[ 'unique' ] ); |
|
103 | + $comment = isset( $col_info[ 'comment' ] ) ? $col_info[ 'comment' ] : null; |
|
104 | + $target_table = isset( $col_info[ 'target_table' ] ) ? $db->get_table( $col_info[ 'target_table' ] ) : null; |
|
105 | + $after = isset( $col_info[ 'after' ] ) ? $col_info[ 'after' ] : null; |
|
106 | 106 | |
107 | 107 | // Change existing or insert new column. |
108 | 108 | $altered = false; |
109 | 109 | if ( $old_col_name ) { |
110 | - $col = $table->get_column( $col_info['old_name'] ); |
|
110 | + $col = $table->get_column( $col_info[ 'old_name' ] ); |
|
111 | 111 | if ( $col instanceof Column ) { |
112 | 112 | $col->alter( $new_col_name, $xtype, $size, $nullable, $default, $auto_increment, $unique, $comment, $target_table, $after ); |
113 | 113 | $altered = true; |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | public function delete( $args ) { |
135 | 135 | $template = new Template( 'table/delete.html' ); |
136 | 136 | $db = new Database( $this->wpdb ); |
137 | - $table = $db->get_table( $args['table'] ); |
|
137 | + $table = $db->get_table( $args[ 'table' ] ); |
|
138 | 138 | |
139 | 139 | // Ask for confirmation. |
140 | - if ( ! isset( $args['confirm_deletion'] ) ) { |
|
140 | + if ( ! isset( $args[ 'confirm_deletion' ] ) ) { |
|
141 | 141 | $template->table = $table; |
142 | 142 | return $template->render(); |
143 | 143 | } |
@@ -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 | } |