@@ -111,7 +111,7 @@ |
||
111 | 111 | * @api |
112 | 112 | * @since |
113 | 113 | * |
114 | - * @param $view \GV\View The view! |
|
114 | + * @param View $view \GV\View The view! |
|
115 | 115 | * |
116 | 116 | * @return \GV\Field_Collection A filtered collection of \GV\Fields, filtered by visibility. |
117 | 117 | */ |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @see add_columns_sort_links |
160 | 160 | * @param string $url Single-sort URL |
161 | - * @param array $sort_args Single sorting for rules, in [ field_id, dir ] format |
|
161 | + * @param string[] $sort_args Single sorting for rules, in [ field_id, dir ] format |
|
162 | 162 | * @param \GV\Field $field The current field |
163 | 163 | * |
164 | 164 | * @return string Multisort URL, if there are multiple sorts. Otherwise, existing $url |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * Output a field cell. |
370 | 370 | * |
371 | 371 | * @param \GV\Field $field The field to be ouput. |
372 | - * @param \GV\Field $entry The entry this field is for. |
|
372 | + * @param Entry $entry The entry this field is for. |
|
373 | 373 | * |
374 | 374 | * @return void |
375 | 375 | */ |
@@ -75,22 +75,22 @@ discard block |
||
75 | 75 | if ( is_array( $sorts ) ) { |
76 | 76 | foreach ( (array)$sorts as $key => $direction ) { |
77 | 77 | if ( $key == $field_id ) { |
78 | - $sorting['key'] = $field_id; |
|
79 | - $sorting['direction'] = strtolower( $direction ); |
|
78 | + $sorting[ 'key' ] = $field_id; |
|
79 | + $sorting[ 'direction' ] = strtolower( $direction ); |
|
80 | 80 | break; |
81 | 81 | } |
82 | 82 | } |
83 | 83 | } else { |
84 | 84 | if ( $sorts == $field_id ) { |
85 | - $sorting['key'] = $context_id; |
|
86 | - $sorting['direction'] = strtolower( Utils::_GET( 'dir', '' ) ); |
|
85 | + $sorting[ 'key' ] = $context_id; |
|
86 | + $sorting[ 'direction' ] = strtolower( Utils::_GET( 'dir', '' ) ); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | } else { |
90 | 90 | foreach ( (array)$context->view->settings->get( 'sort_field', array() ) as $i => $sort_field ) { |
91 | 91 | if ( $sort_field == $field_id ) { |
92 | - $sorting['key'] = $sort_field; |
|
93 | - $sorting['direction'] = strtolower( Utils::get( $directions, $i, '' ) ); |
|
92 | + $sorting[ 'key' ] = $sort_field; |
|
93 | + $sorting[ 'direction' ] = strtolower( Utils::get( $directions, $i, '' ) ); |
|
94 | 94 | break; // Only get the first sort |
95 | 95 | } |
96 | 96 | } |
@@ -109,21 +109,21 @@ discard block |
||
109 | 109 | ); |
110 | 110 | |
111 | 111 | // If we are already sorting by the current field... |
112 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
112 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
113 | 113 | |
114 | - switch( $sorting['direction'] ) { |
|
114 | + switch ( $sorting[ 'direction' ] ) { |
|
115 | 115 | // No sort |
116 | 116 | case '': |
117 | - $sort_args[1] = 'asc'; |
|
117 | + $sort_args[ 1 ] = 'asc'; |
|
118 | 118 | $class .= ' gv-icon-caret-up-down'; |
119 | 119 | break; |
120 | 120 | case 'desc': |
121 | - $sort_args[1] = ''; |
|
121 | + $sort_args[ 1 ] = ''; |
|
122 | 122 | $class .= ' gv-icon-sort-asc'; |
123 | 123 | break; |
124 | 124 | case 'asc': |
125 | 125 | default: |
126 | - $sort_args[1] = 'desc'; |
|
126 | + $sort_args[ 1 ] = 'desc'; |
|
127 | 127 | $class .= ' gv-icon-sort-desc'; |
128 | 128 | break; |
129 | 129 | } |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | $url = remove_query_arg( 'sort', $url ); |
137 | 137 | $multisort_url = self::_get_multisort_url( $url, $sort_args, $context->field ); |
138 | 138 | |
139 | - $url = add_query_arg( $sort_args[0], $sort_args[1], $url ); |
|
139 | + $url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $url ); |
|
140 | 140 | |
141 | - $return = '<a href="'. esc_url_raw( $url ) .'"'; |
|
141 | + $return = '<a href="' . esc_url_raw( $url ) . '"'; |
|
142 | 142 | |
143 | 143 | if ( ! empty( $multisort_url ) ) { |
144 | - $return .= ' data-multisort-href="'. esc_url_raw( $multisort_url ) . '"'; |
|
144 | + $return .= ' data-multisort-href="' . esc_url_raw( $multisort_url ) . '"'; |
|
145 | 145 | } |
146 | 146 | |
147 | - $return .= ' class="'. $class .'" ></a> '. $column_label; |
|
147 | + $return .= ' class="' . $class . '" ></a> ' . $column_label; |
|
148 | 148 | |
149 | 149 | return $return; |
150 | 150 | } |
@@ -183,19 +183,19 @@ discard block |
||
183 | 183 | if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) { |
184 | 184 | if ( count( $keys ) ) { |
185 | 185 | $multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url ); |
186 | - $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
186 | + $multisort_url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $multisort_url ); |
|
187 | 187 | } else { |
188 | - $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
188 | + $multisort_url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $multisort_url ); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | // Otherwise, we are just updating the sort order |
192 | 192 | else { |
193 | 193 | |
194 | 194 | // Pass empty value to unset |
195 | - if( '' === $sort_args[1] ) { |
|
195 | + if ( '' === $sort_args[ 1 ] ) { |
|
196 | 196 | unset( $sorts[ $field_id ] ); |
197 | 197 | } else { |
198 | - $sorts[ $field_id ] = $sort_args[1]; |
|
198 | + $sorts[ $field_id ] = $sort_args[ 1 ]; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url ); |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() ); |
334 | 334 | |
335 | 335 | foreach ( $fields->all() as $field ) { |
336 | - if ( isset( $this->view->unions[ $entry['form_id'] ] ) ) { |
|
337 | - if ( isset( $this->view->unions[ $entry['form_id'] ][ $field->ID ] ) ) { |
|
338 | - $field = $this->view->unions[ $entry['form_id'] ][ $field->ID ]; |
|
336 | + if ( isset( $this->view->unions[ $entry[ 'form_id' ] ] ) ) { |
|
337 | + if ( isset( $this->view->unions[ $entry[ 'form_id' ] ][ $field->ID ] ) ) { |
|
338 | + $field = $this->view->unions[ $entry[ 'form_id' ] ][ $field->ID ]; |
|
339 | 339 | } else { |
340 | 340 | if ( ! $field instanceof Internal_Field ) { |
341 | 341 | $field = Internal_Field::from_configuration( array( 'id' => 'custom' ) ); |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | |
20 | 20 | |
21 | 21 | /** |
22 | - * Constructor. Add filters to modify output. |
|
23 | - * |
|
22 | + * Constructor. Add filters to modify output. |
|
23 | + * |
|
24 | 24 | * @since 2.0.4 |
25 | 25 | * |
26 | 26 | * @param View $view |
@@ -29,19 +29,19 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function __construct( View $view, Entry_Collection $entries, Request $request ) { |
31 | 31 | |
32 | - add_filter( 'gravityview/template/field/label', array( __CLASS__, 'add_columns_sort_links' ), 100, 2 ); |
|
32 | + add_filter( 'gravityview/template/field/label', array( __CLASS__, 'add_columns_sort_links' ), 100, 2 ); |
|
33 | 33 | |
34 | 34 | parent::__construct( $view, $entries, $request ); |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | - * Add sorting links to HTML columns that support sorting |
|
39 | - * |
|
40 | - * @since 2.0.4 |
|
41 | - * @since 2.0.5 Made static |
|
42 | - * |
|
43 | - * @static |
|
44 | - * |
|
38 | + * Add sorting links to HTML columns that support sorting |
|
39 | + * |
|
40 | + * @since 2.0.4 |
|
41 | + * @since 2.0.5 Made static |
|
42 | + * |
|
43 | + * @static |
|
44 | + * |
|
45 | 45 | * @param string $column_label Label for the table column |
46 | 46 | * @param \GV\Template_Context $context |
47 | 47 | * |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $sort_columns = $context->view->settings->get( 'sort_columns' ); |
53 | 53 | |
54 | 54 | if ( empty( $sort_columns ) ) { |
55 | - return $column_label; |
|
55 | + return $column_label; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | if ( 'custom' === $context->field->type ) { |
@@ -111,22 +111,22 @@ discard block |
||
111 | 111 | // If we are already sorting by the current field... |
112 | 112 | if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
113 | 113 | |
114 | - switch( $sorting['direction'] ) { |
|
115 | - // No sort |
|
116 | - case '': |
|
117 | - $sort_args[1] = 'asc'; |
|
118 | - $class .= ' gv-icon-caret-up-down'; |
|
119 | - break; |
|
120 | - case 'desc': |
|
121 | - $sort_args[1] = ''; |
|
122 | - $class .= ' gv-icon-sort-asc'; |
|
123 | - break; |
|
124 | - case 'asc': |
|
125 | - default: |
|
126 | - $sort_args[1] = 'desc'; |
|
127 | - $class .= ' gv-icon-sort-desc'; |
|
128 | - break; |
|
129 | - } |
|
114 | + switch( $sorting['direction'] ) { |
|
115 | + // No sort |
|
116 | + case '': |
|
117 | + $sort_args[1] = 'asc'; |
|
118 | + $class .= ' gv-icon-caret-up-down'; |
|
119 | + break; |
|
120 | + case 'desc': |
|
121 | + $sort_args[1] = ''; |
|
122 | + $class .= ' gv-icon-sort-asc'; |
|
123 | + break; |
|
124 | + case 'asc': |
|
125 | + default: |
|
126 | + $sort_args[1] = 'desc'; |
|
127 | + $class .= ' gv-icon-sort-desc'; |
|
128 | + break; |
|
129 | + } |
|
130 | 130 | |
131 | 131 | } else { |
132 | 132 | $class .= ' gv-icon-caret-up-down'; |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $url = remove_query_arg( 'sort', $url ); |
137 | 137 | $multisort_url = self::_get_multisort_url( $url, $sort_args, $context->field ); |
138 | 138 | |
139 | - $url = add_query_arg( $sort_args[0], $sort_args[1], $url ); |
|
139 | + $url = add_query_arg( $sort_args[0], $sort_args[1], $url ); |
|
140 | 140 | |
141 | 141 | $return = '<a href="'. esc_url_raw( $url ) .'"'; |
142 | 142 | |
@@ -150,28 +150,28 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | - * Get the multi-sort URL used in the sorting links |
|
154 | - * |
|
155 | - * @todo Consider moving to Utils? |
|
156 | - * |
|
157 | - * @since 2.3 |
|
158 | - * |
|
159 | - * @see add_columns_sort_links |
|
153 | + * Get the multi-sort URL used in the sorting links |
|
154 | + * |
|
155 | + * @todo Consider moving to Utils? |
|
156 | + * |
|
157 | + * @since 2.3 |
|
158 | + * |
|
159 | + * @see add_columns_sort_links |
|
160 | 160 | * @param string $url Single-sort URL |
161 | 161 | * @param array $sort_args Single sorting for rules, in [ field_id, dir ] format |
162 | - * @param \GV\Field $field The current field |
|
163 | - * |
|
164 | - * @return string Multisort URL, if there are multiple sorts. Otherwise, existing $url |
|
162 | + * @param \GV\Field $field The current field |
|
163 | + * |
|
164 | + * @return string Multisort URL, if there are multiple sorts. Otherwise, existing $url |
|
165 | 165 | */ |
166 | 166 | static public function _get_multisort_url( $url, $sort_args, $field ) { |
167 | 167 | |
168 | 168 | $sorts = Utils::_GET( 'sort' ); |
169 | 169 | |
170 | 170 | if ( ! is_array( $sorts ) ) { |
171 | - return $url; |
|
171 | + return $url; |
|
172 | 172 | } |
173 | 173 | |
174 | - $multisort_url = $url; |
|
174 | + $multisort_url = $url; |
|
175 | 175 | |
176 | 176 | if ( ! $field ) { |
177 | 177 | return $url; |
@@ -184,26 +184,26 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | // If the field has already been sorted by, add the field to the URL |
187 | - if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) { |
|
188 | - if ( count( $keys ) ) { |
|
189 | - $multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url ); |
|
190 | - $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
191 | - } else { |
|
192 | - $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
193 | - } |
|
194 | - } |
|
195 | - // Otherwise, we are just updating the sort order |
|
196 | - else { |
|
197 | - |
|
198 | - // Pass empty value to unset |
|
199 | - if( '' === $sort_args[1] ) { |
|
200 | - unset( $sorts[ $field_id ] ); |
|
201 | - } else { |
|
202 | - $sorts[ $field_id ] = $sort_args[1]; |
|
203 | - } |
|
204 | - |
|
205 | - $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url ); |
|
206 | - } |
|
187 | + if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) { |
|
188 | + if ( count( $keys ) ) { |
|
189 | + $multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url ); |
|
190 | + $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
191 | + } else { |
|
192 | + $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url ); |
|
193 | + } |
|
194 | + } |
|
195 | + // Otherwise, we are just updating the sort order |
|
196 | + else { |
|
197 | + |
|
198 | + // Pass empty value to unset |
|
199 | + if( '' === $sort_args[1] ) { |
|
200 | + unset( $sorts[ $field_id ] ); |
|
201 | + } else { |
|
202 | + $sorts[ $field_id ] = $sort_args[1]; |
|
203 | + } |
|
204 | + |
|
205 | + $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url ); |
|
206 | + } |
|
207 | 207 | |
208 | 208 | return $multisort_url; |
209 | 209 | } |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
236 | - * Returns the label for a column, with support for all deprecated filters |
|
237 | - * |
|
238 | - * @since 2.1 |
|
239 | - * |
|
236 | + * Returns the label for a column, with support for all deprecated filters |
|
237 | + * |
|
238 | + * @since 2.1 |
|
239 | + * |
|
240 | 240 | * @param \GV\Field $field |
241 | 241 | * @param \GV\Template_Context $context |
242 | 242 | */ |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $column_label = apply_filters( 'gravityview/template/field/label', $column_label, $context ); |
260 | 260 | |
261 | 261 | return $column_label; |
262 | - } |
|
262 | + } |
|
263 | 263 | |
264 | 264 | /** |
265 | 265 | * Output the entry row. |
@@ -328,15 +328,15 @@ discard block |
||
328 | 328 | */ |
329 | 329 | do_action( 'gravityview/template/table/cells/before', $context ); |
330 | 330 | |
331 | - /** |
|
332 | - * @action `gravityview_table_cells_before` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
333 | - * @since 1.0.7 |
|
331 | + /** |
|
332 | + * @action `gravityview_table_cells_before` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
333 | + * @since 1.0.7 |
|
334 | 334 | * @param \GravityView_View $this Current GravityView_View object |
335 | 335 | * @deprecated Use `gravityview/template/table/cells/before` |
336 | - */ |
|
337 | - do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() ); |
|
336 | + */ |
|
337 | + do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() ); |
|
338 | 338 | |
339 | - foreach ( $fields->all() as $field ) { |
|
339 | + foreach ( $fields->all() as $field ) { |
|
340 | 340 | if ( isset( $this->view->unions[ $entry['form_id'] ] ) ) { |
341 | 341 | if ( isset( $this->view->unions[ $entry['form_id'] ][ $field->ID ] ) ) { |
342 | 342 | $field = $this->view->unions[ $entry['form_id'] ][ $field->ID ]; |
@@ -356,13 +356,13 @@ discard block |
||
356 | 356 | */ |
357 | 357 | do_action( 'gravityview/template/table/cells/after', $context ); |
358 | 358 | |
359 | - /** |
|
360 | - * @action `gravityview_table_cells_after` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
361 | - * @since 1.0.7 |
|
359 | + /** |
|
360 | + * @action `gravityview_table_cells_after` Inside the `tr` while rendering each entry in the loop. Can be used to insert additional table cells. |
|
361 | + * @since 1.0.7 |
|
362 | 362 | * @param \GravityView_View $this Current GravityView_View object |
363 | 363 | * @deprecated Use `gravityview/template/table/cells/after` |
364 | - */ |
|
365 | - do_action( 'gravityview_table_cells_after', \GravityView_View::getInstance() ); |
|
364 | + */ |
|
365 | + do_action( 'gravityview_table_cells_after', \GravityView_View::getInstance() ); |
|
366 | 366 | |
367 | 367 | ?> |
368 | 368 | </tr> |
@@ -410,9 +410,9 @@ discard block |
||
410 | 410 | 'value' => $value, |
411 | 411 | 'hide_empty' => false, |
412 | 412 | 'zone_id' => 'directory_table-columns', |
413 | - 'label' => self::get_field_column_label( $field, $context ), |
|
413 | + 'label' => self::get_field_column_label( $field, $context ), |
|
414 | 414 | 'markup' => '<td id="{{ field_id }}" class="{{ class }}" data-label="{{label_value:data-label}}">{{ value }}</td>', |
415 | - 'form' => $form, |
|
415 | + 'form' => $form, |
|
416 | 416 | ); |
417 | 417 | |
418 | 418 | /** Output. */ |
@@ -437,11 +437,11 @@ discard block |
||
437 | 437 | do_action( 'gravityview/template/table/body/before', $context ); |
438 | 438 | |
439 | 439 | /** |
440 | - * @action `gravityview_table_body_before` Inside the `tbody`, before any rows are rendered. Can be used to insert additional rows. |
|
441 | - * @deprecated Use `gravityview/template/table/body/before` |
|
442 | - * @since 1.0.7 |
|
443 | - * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
444 | - */ |
|
440 | + * @action `gravityview_table_body_before` Inside the `tbody`, before any rows are rendered. Can be used to insert additional rows. |
|
441 | + * @deprecated Use `gravityview/template/table/body/before` |
|
442 | + * @since 1.0.7 |
|
443 | + * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
444 | + */ |
|
445 | 445 | do_action( 'gravityview_table_body_before', \GravityView_View::getInstance() /** ugh! */ ); |
446 | 446 | } |
447 | 447 | |
@@ -463,11 +463,11 @@ discard block |
||
463 | 463 | do_action( 'gravityview/template/table/body/after', $context ); |
464 | 464 | |
465 | 465 | /** |
466 | - * @action `gravityview_table_body_after` Inside the `tbody`, after any rows are rendered. Can be used to insert additional rows. |
|
467 | - * @deprecated Use `gravityview/template/table/body/after` |
|
468 | - * @since 1.0.7 |
|
469 | - * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
470 | - */ |
|
466 | + * @action `gravityview_table_body_after` Inside the `tbody`, after any rows are rendered. Can be used to insert additional rows. |
|
467 | + * @deprecated Use `gravityview/template/table/body/after` |
|
468 | + * @since 1.0.7 |
|
469 | + * @param \GravityView_View $gravityview_view Current GravityView_View object. |
|
470 | + */ |
|
471 | 471 | do_action( 'gravityview_table_body_after', \GravityView_View::getInstance() /** ugh! */ ); |
472 | 472 | } |
473 | 473 |
@@ -318,12 +318,12 @@ discard block |
||
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
321 | - * @hack |
|
322 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
323 | - */ |
|
321 | + * @hack |
|
322 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
323 | + */ |
|
324 | 324 | if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
325 | - continue; |
|
326 | - } |
|
325 | + continue; |
|
326 | + } |
|
327 | 327 | $fields["{$input['id']}"] = array( |
328 | 328 | 'label' => \GV\Utils::get( $input, 'label' ), |
329 | 329 | 'customLabel' => \GV\Utils::get( $input, 'customLabel' ), |
@@ -1420,7 +1420,7 @@ discard block |
||
1420 | 1420 | ), |
1421 | 1421 | ); |
1422 | 1422 | |
1423 | - $fields = $date_created + $fields; |
|
1423 | + $fields = $date_created + $fields; |
|
1424 | 1424 | |
1425 | 1425 | // Are there custom content fields? |
1426 | 1426 | if ( is_admin() ) { |
@@ -1459,13 +1459,13 @@ discard block |
||
1459 | 1459 | |
1460 | 1460 | } |
1461 | 1461 | |
1462 | - /** |
|
1463 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1464 | - * @since 1.12 |
|
1465 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
1466 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
1467 | - */ |
|
1468 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1462 | + /** |
|
1463 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1464 | + * @since 1.12 |
|
1465 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
1466 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
1467 | + */ |
|
1468 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1469 | 1469 | |
1470 | 1470 | return $fields; |
1471 | 1471 | } |
@@ -1757,26 +1757,26 @@ discard block |
||
1757 | 1757 | } |
1758 | 1758 | |
1759 | 1759 | |
1760 | - /** |
|
1761 | - * Display updated/error notice |
|
1762 | - * |
|
1763 | - * @since 1.19.2 Added $cap and $object_id parameters |
|
1764 | - * |
|
1765 | - * @param string $notice text/HTML of notice |
|
1766 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
1767 | - * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
1768 | - * |
|
1769 | - * @return string |
|
1770 | - */ |
|
1771 | - public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
1772 | - |
|
1773 | - // If $cap is defined, only show notice if user has capability |
|
1774 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1775 | - return ''; |
|
1776 | - } |
|
1777 | - |
|
1778 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1779 | - } |
|
1760 | + /** |
|
1761 | + * Display updated/error notice |
|
1762 | + * |
|
1763 | + * @since 1.19.2 Added $cap and $object_id parameters |
|
1764 | + * |
|
1765 | + * @param string $notice text/HTML of notice |
|
1766 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
1767 | + * @param string $cap [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
|
1768 | + * |
|
1769 | + * @return string |
|
1770 | + */ |
|
1771 | + public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
|
1772 | + |
|
1773 | + // If $cap is defined, only show notice if user has capability |
|
1774 | + if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1775 | + return ''; |
|
1776 | + } |
|
1777 | + |
|
1778 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1779 | + } |
|
1780 | 1780 | |
1781 | 1781 | /** |
1782 | 1782 | * Inspired on \GFCommon::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param bool $url_encode Whether to URL-encode output |
250 | 250 | * @param bool $esc_html Whether to apply `esc_html()` to output |
251 | 251 | * |
252 | - * @return mixed |
|
252 | + * @return string |
|
253 | 253 | */ |
254 | 254 | public function replace_merge_tag( $matches = array(), $text = '', $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
255 | 255 | |
@@ -427,6 +427,9 @@ discard block |
||
427 | 427 | return apply_filters( 'gravityview_field_support_options', $options ); |
428 | 428 | } |
429 | 429 | |
430 | + /** |
|
431 | + * @param string $key |
|
432 | + */ |
|
430 | 433 | function add_field_support( $key, &$field_options ) { |
431 | 434 | |
432 | 435 | $options = $this->field_support_options(); |
@@ -192,7 +192,8 @@ |
||
192 | 192 | continue; |
193 | 193 | } |
194 | 194 | |
195 | - if ( $field->is_numeric ) { // @todo do we not have a filter that controls sorting? |
|
195 | + if ( $field->is_numeric ) { |
|
196 | +// @todo do we not have a filter that controls sorting? |
|
196 | 197 | if ( is_numeric( $value1 ) ) { |
197 | 198 | $value1 = floatval( $value1 ); |
198 | 199 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) { |
56 | 56 | |
57 | - unset ( $field_options['search_filter'], $field_options['show_as_link'], $field_options['new_window'] ); |
|
57 | + unset ( $field_options[ 'search_filter' ], $field_options[ 'show_as_link' ], $field_options[ 'new_window' ] ); |
|
58 | 58 | |
59 | 59 | $new_fields = array( |
60 | 60 | 'content' => array( |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $this->add_field_support( 'is_numeric', $new_fields ); |
92 | 92 | |
93 | 93 | if ( 'edit' === $context ) { |
94 | - unset( $field_options['custom_label'], $field_options['show_label'], $field_options['allow_edit_cap'], $new_fields['wpautop'], $new_fields['oembed'] ); |
|
94 | + unset( $field_options[ 'custom_label' ], $field_options[ 'show_label' ], $field_options[ 'allow_edit_cap' ], $new_fields[ 'wpautop' ], $new_fields[ 'oembed' ] ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | return $new_fields + $field_options; |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | |
126 | 126 | // Loop through the configured Edit Entry fields and add Custom Content fields if there are any |
127 | 127 | // TODO: Make this available to other custom GV field types |
128 | - foreach ( (array) $edit_fields as $edit_field ) { |
|
128 | + foreach ( (array)$edit_fields as $edit_field ) { |
|
129 | 129 | |
130 | - if( 'custom' === \GV\Utils::get( $edit_field, 'id') ) { |
|
130 | + if ( 'custom' === \GV\Utils::get( $edit_field, 'id' ) ) { |
|
131 | 131 | |
132 | 132 | $field_data = array( |
133 | 133 | 'label' => \GV\Utils::get( $edit_field, 'custom_label' ), |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | $field_data[ $key ] = GravityView_Merge_Tags::replace_variables( $field_datum, $form, $entry->as_entry(), false, false ); |
141 | 141 | } |
142 | 142 | |
143 | - $field_data['cssClass'] = \GV\Utils::get( $edit_field, 'custom_class' ); |
|
143 | + $field_data[ 'cssClass' ] = \GV\Utils::get( $edit_field, 'custom_class' ); |
|
144 | 144 | |
145 | - $new_fields[] = new GF_Field_HTML( $field_data ); |
|
145 | + $new_fields[ ] = new GF_Field_HTML( $field_data ); |
|
146 | 146 | |
147 | 147 | } else { |
148 | - if( isset( $fields[ $i ] ) ) { |
|
149 | - $new_fields[] = $fields[ $i ]; |
|
148 | + if ( isset( $fields[ $i ] ) ) { |
|
149 | + $new_fields[ ] = $fields[ $i ]; |
|
150 | 150 | } |
151 | 151 | $i++; |
152 | 152 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | return; // Default sorting may be empty string |
180 | 180 | } |
181 | 181 | |
182 | - $sorts = array_combine( (array) $view->settings->get( 'sort_field' ), (array) $view->settings->get( 'sort_direction' ) ); |
|
182 | + $sorts = array_combine( (array)$view->settings->get( 'sort_field' ), (array)$view->settings->get( 'sort_direction' ) ); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | if ( empty( $sorts ) || ! is_array( $sorts ) ) { |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | if ( strpos( $key, 'custom_' ) === 0 ) { |
202 | 202 | $field = $view->fields->get( str_replace( 'custom_', '', $key ) ); |
203 | 203 | } else { |
204 | - $field = is_numeric( $key ) ? \GV\GF_Field::by_id( $view->form, $key ) : \GV\Internal_Field::by_id( $key ); |
|
204 | + $field = is_numeric( $key ) ? \GV\GF_Field::by_id( $view->form, $key ) : \GV\Internal_Field::by_id( $key ); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | $source = is_numeric( $key ) ? $view->form : new \GV\Internal_Source(); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $supports = array( 'title', 'revisions' ); |
126 | 126 | |
127 | 127 | if ( $is_hierarchical ) { |
128 | - $supports[] = 'page-attributes'; |
|
128 | + $supports[ ] = 'page-attributes'; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -229,12 +229,12 @@ discard block |
||
229 | 229 | $tsv_rule = array( sprintf( '%s/([^/]+)/tsv/?', $slug ), 'index.php?gravityview=$matches[1]&tsv=1', 'top' ); |
230 | 230 | |
231 | 231 | add_filter( 'query_vars', function( $query_vars ) { |
232 | - $query_vars[] = 'csv'; |
|
233 | - $query_vars[] = 'tsv'; |
|
232 | + $query_vars[ ] = 'csv'; |
|
233 | + $query_vars[ ] = 'tsv'; |
|
234 | 234 | return $query_vars; |
235 | 235 | } ); |
236 | 236 | |
237 | - if ( ! isset( $wp_rewrite->extra_rules_top[ $csv_rule[0] ] ) ) { |
|
237 | + if ( ! isset( $wp_rewrite->extra_rules_top[ $csv_rule[ 0 ] ] ) ) { |
|
238 | 238 | call_user_func_array( 'add_rewrite_rule', $csv_rule ); |
239 | 239 | call_user_func_array( 'add_rewrite_rule', $tsv_rule ); |
240 | 240 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | |
296 | 296 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
297 | 297 | |
298 | - $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', esc_attr__( 'Data Source', 'gravityview' ), esc_url( plugins_url( 'assets/images/screenshots/data-source.png', GRAVITYVIEW_FILE ) ) ); |
|
298 | + $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', esc_attr__( 'Data Source', 'gravityview' ), esc_url( plugins_url( 'assets/images/screenshots/data-source.png', GRAVITYVIEW_FILE ) ) ); |
|
299 | 299 | |
300 | 300 | return \GVCommon::generate_notice( '<h3>' . $title . '</h3>' . wpautop( $message . $image ), 'notice' ); |
301 | 301 | } |
@@ -321,13 +321,13 @@ discard block |
||
321 | 321 | return $content; |
322 | 322 | } |
323 | 323 | |
324 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
324 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
325 | 325 | |
326 | 326 | /** |
327 | 327 | * Editing a single entry. |
328 | 328 | */ |
329 | 329 | if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) { |
330 | - if ( $entry['status'] != 'active' ) { |
|
330 | + if ( $entry[ 'status' ] != 'active' ) { |
|
331 | 331 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
332 | 332 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
333 | 333 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | } |
339 | 339 | |
340 | 340 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
341 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
341 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
342 | 342 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
343 | 343 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
344 | 344 | } |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | |
362 | 362 | foreach ( $entryset as $e ) { |
363 | 363 | |
364 | - if ( 'active' !== $e['status'] ) { |
|
364 | + if ( 'active' !== $e[ 'status' ] ) { |
|
365 | 365 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $e->ID ) ); |
366 | 366 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
367 | 367 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | } |
373 | 373 | |
374 | 374 | if ( $show_only_approved && ! $is_admin_and_can_view ) { |
375 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
375 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
376 | 376 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $e->ID ) ); |
377 | 377 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
378 | 378 | } |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | $join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field::by_id( $join_column ); |
548 | 548 | $join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field::by_id( $join_on_column ); |
549 | 549 | |
550 | - $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
550 | + $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | return $joins; |
@@ -637,13 +637,13 @@ discard block |
||
637 | 637 | } |
638 | 638 | |
639 | 639 | foreach ( $_fields as $field ) { |
640 | - if ( ! empty( $field['unions'] ) ) { |
|
641 | - foreach ( $field['unions'] as $form_id => $field_id ) { |
|
640 | + if ( ! empty( $field[ 'unions' ] ) ) { |
|
641 | + foreach ( $field[ 'unions' ] as $form_id => $field_id ) { |
|
642 | 642 | if ( ! isset( $unions[ $form_id ] ) ) { |
643 | 643 | $unions[ $form_id ] = array(); |
644 | 644 | } |
645 | 645 | |
646 | - $unions[ $form_id ][ $field['id'] ] = |
|
646 | + $unions[ $form_id ][ $field[ 'id' ] ] = |
|
647 | 647 | is_numeric( $field_id ) ? \GV\GF_Field::by_id( \GV\GF_Form::by_id( $form_id ), $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
648 | 648 | } |
649 | 649 | } |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | if ( ! $view->form ) { |
699 | 699 | gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
700 | 700 | 'view_id' => $view->ID, |
701 | - 'form_id' => $view->_gravityview_form_id ? : 0, |
|
701 | + 'form_id' => $view->_gravityview_form_id ?: 0, |
|
702 | 702 | ) ); |
703 | 703 | } |
704 | 704 | |
@@ -938,11 +938,11 @@ discard block |
||
938 | 938 | * Remove multiple sorting before calling legacy filters. |
939 | 939 | * This allows us to fake it till we make it. |
940 | 940 | */ |
941 | - if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) { |
|
941 | + if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) { |
|
942 | 942 | $has_multisort = true; |
943 | - $parameters['sort_field'] = reset( $parameters['sort_field'] ); |
|
944 | - if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) { |
|
945 | - $parameters['sort_direction'] = reset( $parameters['sort_direction'] ); |
|
943 | + $parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] ); |
|
944 | + if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) { |
|
945 | + $parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] ); |
|
946 | 946 | } |
947 | 947 | } |
948 | 948 | |
@@ -951,31 +951,30 @@ discard block |
||
951 | 951 | */ |
952 | 952 | $parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $this->form->ID ); |
953 | 953 | |
954 | - $parameters['context_view_id'] = $this->ID; |
|
954 | + $parameters[ 'context_view_id' ] = $this->ID; |
|
955 | 955 | $parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
956 | 956 | |
957 | 957 | if ( ! is_array( $parameters ) ) { |
958 | 958 | $parameters = array(); |
959 | 959 | } |
960 | 960 | |
961 | - if ( ! is_array( $parameters['search_criteria'] ) ) { |
|
962 | - $parameters['search_criteria'] = array(); |
|
961 | + if ( ! is_array( $parameters[ 'search_criteria' ] ) ) { |
|
962 | + $parameters[ 'search_criteria' ] = array(); |
|
963 | 963 | } |
964 | 964 | |
965 | - if ( ( ! isset( $parameters['search_criteria']['field_filters'] ) ) || ( ! is_array( $parameters['search_criteria']['field_filters'] ) ) ) { |
|
966 | - $parameters['search_criteria']['field_filters'] = array(); |
|
965 | + if ( ( ! isset( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) || ( ! is_array( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) ) { |
|
966 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = array(); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | if ( $request instanceof REST\Request ) { |
970 | 970 | $atts = $this->settings->as_atts(); |
971 | 971 | $paging_parameters = wp_parse_args( $request->get_paging(), array( |
972 | - 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
972 | + 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
973 | 973 | ) ); |
974 | - $parameters['paging'] = $paging_parameters['paging']; |
|
974 | + $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
975 | 975 | } |
976 | 976 | |
977 | - $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
978 | - : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 ); |
|
977 | + $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 ); |
|
979 | 978 | |
980 | 979 | /** |
981 | 980 | * Cleanup duplicate field_filter parameters to simplify the query. |
@@ -983,14 +982,14 @@ discard block |
||
983 | 982 | $unique_field_filters = array(); |
984 | 983 | foreach ( Utils::get( $parameters, 'search_criteria/field_filters', array() ) as $key => $filter ) { |
985 | 984 | if ( 'mode' === $key ) { |
986 | - $unique_field_filters['mode'] = $filter; |
|
985 | + $unique_field_filters[ 'mode' ] = $filter; |
|
987 | 986 | } else if ( ! in_array( $filter, $unique_field_filters ) ) { |
988 | - $unique_field_filters[] = $filter; |
|
987 | + $unique_field_filters[ ] = $filter; |
|
989 | 988 | } |
990 | 989 | } |
991 | - $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
990 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
992 | 991 | |
993 | - if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
992 | + if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
994 | 993 | gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
995 | 994 | } |
996 | 995 | |
@@ -999,7 +998,7 @@ discard block |
||
999 | 998 | $query_class = $this->get_query_class(); |
1000 | 999 | |
1001 | 1000 | /** @type \GF_Query $query */ |
1002 | - $query = new $query_class( $this->form->ID, $parameters['search_criteria'], Utils::get( $parameters, 'sorting' ) ); |
|
1001 | + $query = new $query_class( $this->form->ID, $parameters[ 'search_criteria' ], Utils::get( $parameters, 'sorting' ) ); |
|
1003 | 1002 | |
1004 | 1003 | /** |
1005 | 1004 | * Apply multisort. |
@@ -1010,15 +1009,15 @@ discard block |
||
1010 | 1009 | $view_setting_sort_field_ids = \GV\Utils::get( $atts, 'sort_field', array() ); |
1011 | 1010 | $view_setting_sort_directions = \GV\Utils::get( $atts, 'sort_direction', array() ); |
1012 | 1011 | |
1013 | - $has_sort_query_param = ! empty( $_GET['sort'] ) && is_array( $_GET['sort'] ); |
|
1012 | + $has_sort_query_param = ! empty( $_GET[ 'sort' ] ) && is_array( $_GET[ 'sort' ] ); |
|
1014 | 1013 | |
1015 | - if( $has_sort_query_param ) { |
|
1016 | - $has_sort_query_param = array_filter( array_values( $_GET['sort'] ) ); |
|
1014 | + if ( $has_sort_query_param ) { |
|
1015 | + $has_sort_query_param = array_filter( array_values( $_GET[ 'sort' ] ) ); |
|
1017 | 1016 | } |
1018 | 1017 | |
1019 | 1018 | if ( $this->settings->get( 'sort_columns' ) && $has_sort_query_param ) { |
1020 | - $sort_field_ids = array_keys( $_GET['sort'] ); |
|
1021 | - $sort_directions = array_values( $_GET['sort'] ); |
|
1019 | + $sort_field_ids = array_keys( $_GET[ 'sort' ] ); |
|
1020 | + $sort_directions = array_values( $_GET[ 'sort' ] ); |
|
1022 | 1021 | } else { |
1023 | 1022 | $sort_field_ids = $view_setting_sort_field_ids; |
1024 | 1023 | $sort_directions = $view_setting_sort_directions; |
@@ -1026,7 +1025,7 @@ discard block |
||
1026 | 1025 | |
1027 | 1026 | $skip_first = false; |
1028 | 1027 | |
1029 | - foreach ( (array) $sort_field_ids as $key => $sort_field_id ) { |
|
1028 | + foreach ( (array)$sort_field_ids as $key => $sort_field_id ) { |
|
1030 | 1029 | |
1031 | 1030 | if ( ! $skip_first && ! $has_sort_query_param ) { |
1032 | 1031 | $skip_first = true; // Skip the first one, it's already in the query |
@@ -1056,15 +1055,15 @@ discard block |
||
1056 | 1055 | |
1057 | 1056 | $merged_time = false; |
1058 | 1057 | |
1059 | - foreach ( $q['order'] as $oid => $order ) { |
|
1060 | - if ( $order[0] instanceof \GF_Query_Column ) { |
|
1061 | - $column = $order[0]; |
|
1062 | - } else if ( $order[0] instanceof \GF_Query_Call ) { |
|
1063 | - if ( count( $order[0]->columns ) != 1 || ! $order[0]->columns[0] instanceof \GF_Query_Column ) { |
|
1058 | + foreach ( $q[ 'order' ] as $oid => $order ) { |
|
1059 | + if ( $order[ 0 ] instanceof \GF_Query_Column ) { |
|
1060 | + $column = $order[ 0 ]; |
|
1061 | + } else if ( $order[ 0 ] instanceof \GF_Query_Call ) { |
|
1062 | + if ( count( $order[ 0 ]->columns ) != 1 || ! $order[ 0 ]->columns[ 0 ] instanceof \GF_Query_Column ) { |
|
1064 | 1063 | $orders[ $oid ] = $order; |
1065 | 1064 | continue; // Need something that resembles a single sort |
1066 | 1065 | } |
1067 | - $column = $order[0]->columns[0]; |
|
1066 | + $column = $order[ 0 ]->columns[ 0 ]; |
|
1068 | 1067 | } |
1069 | 1068 | |
1070 | 1069 | if ( ( ! $field = \GFAPI::get_field( $column->source, $column->field_id ) ) || $field->type !== 'time' ) { |
@@ -1078,7 +1077,7 @@ discard block |
||
1078 | 1077 | |
1079 | 1078 | $orders[ $oid ] = array( |
1080 | 1079 | new \GV\Mocks\GF_Query_Call_TIMESORT( 'timesort', array( $column, $sql ) ), |
1081 | - $order[1] // Mock it! |
|
1080 | + $order[ 1 ] // Mock it! |
|
1082 | 1081 | ); |
1083 | 1082 | |
1084 | 1083 | $merged_time = true; |
@@ -1089,15 +1088,15 @@ discard block |
||
1089 | 1088 | * ORDER again. |
1090 | 1089 | */ |
1091 | 1090 | if ( ! empty( $orders ) && $_orders = $query->_order_generate( $orders ) ) { |
1092 | - $sql['order'] = 'ORDER BY ' . implode( ', ', $_orders ); |
|
1091 | + $sql[ 'order' ] = 'ORDER BY ' . implode( ', ', $_orders ); |
|
1093 | 1092 | } |
1094 | 1093 | } |
1095 | 1094 | |
1096 | 1095 | return $sql; |
1097 | 1096 | } ); |
1098 | 1097 | |
1099 | - $query->limit( $parameters['paging']['page_size'] ) |
|
1100 | - ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
1098 | + $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
1099 | + ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
1101 | 1100 | |
1102 | 1101 | /** |
1103 | 1102 | * Any joins? |
@@ -1120,7 +1119,7 @@ discard block |
||
1120 | 1119 | |
1121 | 1120 | $query_parameters = $query->_introspect(); |
1122 | 1121 | |
1123 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
1122 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1124 | 1123 | } |
1125 | 1124 | |
1126 | 1125 | /** |
@@ -1154,7 +1153,7 @@ discard block |
||
1154 | 1153 | } |
1155 | 1154 | |
1156 | 1155 | $q = $query->_introspect(); |
1157 | - $query->where( \GF_Query_Condition::_and( $q['where'], $condition ) ); |
|
1156 | + $query->where( \GF_Query_Condition::_and( $q[ 'where' ], $condition ) ); |
|
1158 | 1157 | |
1159 | 1158 | if ( $this->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
1160 | 1159 | |
@@ -1179,7 +1178,7 @@ discard block |
||
1179 | 1178 | |
1180 | 1179 | $query_parameters = $query->_introspect(); |
1181 | 1180 | |
1182 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
1181 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1183 | 1182 | } |
1184 | 1183 | } |
1185 | 1184 | |
@@ -1203,7 +1202,7 @@ discard block |
||
1203 | 1202 | $conditions = array(); |
1204 | 1203 | |
1205 | 1204 | foreach ( $condition->expressions as $_condition ) { |
1206 | - $conditions[] = $recurse( $_condition, $fields, $recurse ); |
|
1205 | + $conditions[ ] = $recurse( $_condition, $fields, $recurse ); |
|
1207 | 1206 | } |
1208 | 1207 | |
1209 | 1208 | return call_user_func_array( |
@@ -1232,10 +1231,10 @@ discard block |
||
1232 | 1231 | $q = new $query_class( $form_id ); |
1233 | 1232 | |
1234 | 1233 | // Copy the WHERE clauses but substitute the field_ids to the respective ones |
1235 | - $q->where( $where_union_substitute( $query_parameters['where'], $fields, $where_union_substitute ) ); |
|
1234 | + $q->where( $where_union_substitute( $query_parameters[ 'where' ], $fields, $where_union_substitute ) ); |
|
1236 | 1235 | |
1237 | 1236 | // Copy the ORDER clause and substitute the field_ids to the respective ones |
1238 | - foreach ( $query_parameters['order'] as $order ) { |
|
1237 | + foreach ( $query_parameters[ 'order' ] as $order ) { |
|
1239 | 1238 | list( $column, $_order ) = $order; |
1240 | 1239 | |
1241 | 1240 | if ( $column && $column instanceof \GF_Query_Column ) { |
@@ -1249,15 +1248,15 @@ discard block |
||
1249 | 1248 | |
1250 | 1249 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( &$unions_sql ) { |
1251 | 1250 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
1252 | - $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
1251 | + $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1253 | 1252 | |
1254 | 1253 | // Record the SQL |
1255 | - $unions_sql[] = array( |
|
1254 | + $unions_sql[ ] = array( |
|
1256 | 1255 | // Remove columns, we'll rebuild them |
1257 | 1256 | 'select' => preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $select ), |
1258 | - 'from' => $sql['from'], |
|
1259 | - 'join' => $sql['join'], |
|
1260 | - 'where' => $sql['where'], |
|
1257 | + 'from' => $sql[ 'from' ], |
|
1258 | + 'join' => $sql[ 'join' ], |
|
1259 | + 'where' => $sql[ 'where' ], |
|
1261 | 1260 | // Remove order and limit |
1262 | 1261 | ); |
1263 | 1262 | |
@@ -1274,11 +1273,11 @@ discard block |
||
1274 | 1273 | |
1275 | 1274 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( $unions_sql ) { |
1276 | 1275 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
1277 | - $sql['select'] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
1276 | + $sql[ 'select' ] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1278 | 1277 | |
1279 | 1278 | // Remove columns, we'll rebuild them |
1280 | - preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql['select'], $select_match ); |
|
1281 | - $sql['select'] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql['select'] ); |
|
1279 | + preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql[ 'select' ], $select_match ); |
|
1280 | + $sql[ 'select' ] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql[ 'select' ] ); |
|
1282 | 1281 | |
1283 | 1282 | $unions = array(); |
1284 | 1283 | |
@@ -1289,30 +1288,30 @@ discard block |
||
1289 | 1288 | }; |
1290 | 1289 | |
1291 | 1290 | // Add all the order columns into the selects, so we can order by the whole union group |
1292 | - preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql['order'], $order_matches ); |
|
1291 | + preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql[ 'order' ], $order_matches ); |
|
1293 | 1292 | |
1294 | 1293 | $columns = array( |
1295 | - sprintf( '%s AS %s', $select_match[1], $column_to_alias( $select_match[1] ) ) |
|
1294 | + sprintf( '%s AS %s', $select_match[ 1 ], $column_to_alias( $select_match[ 1 ] ) ) |
|
1296 | 1295 | ); |
1297 | 1296 | |
1298 | 1297 | foreach ( array_slice( $order_matches, 1 ) as $match ) { |
1299 | - $columns[] = sprintf( '%s AS %s', $match[0], $column_to_alias( $match[0] ) ); |
|
1298 | + $columns[ ] = sprintf( '%s AS %s', $match[ 0 ], $column_to_alias( $match[ 0 ] ) ); |
|
1300 | 1299 | |
1301 | 1300 | // Rewrite the order columns to the shared aliases |
1302 | - $sql['order'] = str_replace( $match[0], $column_to_alias( $match[0] ), $sql['order'] ); |
|
1301 | + $sql[ 'order' ] = str_replace( $match[ 0 ], $column_to_alias( $match[ 0 ] ), $sql[ 'order' ] ); |
|
1303 | 1302 | } |
1304 | 1303 | |
1305 | 1304 | $columns = array_unique( $columns ); |
1306 | 1305 | |
1307 | 1306 | // Add the columns to every UNION |
1308 | 1307 | foreach ( $unions_sql as $union_sql ) { |
1309 | - $union_sql['select'] .= implode( ', ', $columns ); |
|
1310 | - $unions []= implode( ' ', $union_sql ); |
|
1308 | + $union_sql[ 'select' ] .= implode( ', ', $columns ); |
|
1309 | + $unions [ ] = implode( ' ', $union_sql ); |
|
1311 | 1310 | } |
1312 | 1311 | |
1313 | 1312 | // Add the columns to the main SELECT, but only grab the entry id column |
1314 | - $sql['select'] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql['select'] . implode( ', ', $columns ); |
|
1315 | - $sql['order'] = implode( ' ', $unions ) . ') AS u ' . $sql['order']; |
|
1313 | + $sql[ 'select' ] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql[ 'select' ] . implode( ', ', $columns ); |
|
1314 | + $sql[ 'order' ] = implode( ' ', $unions ) . ') AS u ' . $sql[ 'order' ]; |
|
1316 | 1315 | |
1317 | 1316 | return $sql; |
1318 | 1317 | } ); |
@@ -1411,10 +1410,10 @@ discard block |
||
1411 | 1410 | } ); |
1412 | 1411 | } |
1413 | 1412 | |
1414 | - array_map( array( $entries, 'add'), array_slice( |
|
1413 | + array_map( array( $entries, 'add' ), array_slice( |
|
1415 | 1414 | $filtered, |
1416 | - ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ), // Offset and page |
|
1417 | - $parameters['paging']['page_size'] // Per page |
|
1415 | + ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ), // Offset and page |
|
1416 | + $parameters[ 'paging' ][ 'page_size' ] // Per page |
|
1418 | 1417 | ) ); |
1419 | 1418 | |
1420 | 1419 | $entries->add_count_callback( function() use ( $filtered, $v ) { |
@@ -1441,20 +1440,20 @@ discard block |
||
1441 | 1440 | } |
1442 | 1441 | } else { |
1443 | 1442 | $entries = $this->form->entries |
1444 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
1443 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
1445 | 1444 | ->offset( $this->settings->get( 'offset' ) ) |
1446 | - ->limit( $parameters['paging']['page_size'] ) |
|
1445 | + ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
1447 | 1446 | ->page( $page ); |
1448 | 1447 | |
1449 | - if ( ! empty( $parameters['sorting'] ) && is_array( $parameters['sorting'] && ! isset( $parameters['sorting']['key'] ) ) ) { |
|
1448 | + if ( ! empty( $parameters[ 'sorting' ] ) && is_array( $parameters[ 'sorting' ] && ! isset( $parameters[ 'sorting' ][ 'key' ] ) ) ) { |
|
1450 | 1449 | // Pluck off multisort arrays |
1451 | - $parameters['sorting'] = $parameters['sorting'][0]; |
|
1450 | + $parameters[ 'sorting' ] = $parameters[ 'sorting' ][ 0 ]; |
|
1452 | 1451 | } |
1453 | 1452 | |
1454 | - if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
1453 | + if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
1455 | 1454 | $field = new \GV\Field(); |
1456 | - $field->ID = $parameters['sorting']['key']; |
|
1457 | - $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
1455 | + $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
1456 | + $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
1458 | 1457 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
1459 | 1458 | } |
1460 | 1459 | } |
@@ -1539,7 +1538,7 @@ discard block |
||
1539 | 1538 | $allowed = $headers = array(); |
1540 | 1539 | |
1541 | 1540 | foreach ( $view->fields->by_position( "directory_*" )->by_visible( $view )->all() as $id => $field ) { |
1542 | - $allowed[] = $field; |
|
1541 | + $allowed[ ] = $field; |
|
1543 | 1542 | } |
1544 | 1543 | |
1545 | 1544 | $renderer = new Field_Renderer(); |
@@ -1561,17 +1560,17 @@ discard block |
||
1561 | 1560 | } ); |
1562 | 1561 | |
1563 | 1562 | foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) { |
1564 | - $allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
1563 | + $allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
1565 | 1564 | } |
1566 | 1565 | |
1567 | 1566 | foreach ( $allowed as $field ) { |
1568 | 1567 | $source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source(); |
1569 | 1568 | |
1570 | - $return[] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
1569 | + $return[ ] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
1571 | 1570 | |
1572 | 1571 | if ( ! $headers_done ) { |
1573 | 1572 | $label = $field->get_label( $view, $source, $entry ); |
1574 | - $headers[] = $label ? $label : $field->ID; |
|
1573 | + $headers[ ] = $label ? $label : $field->ID; |
|
1575 | 1574 | } |
1576 | 1575 | } |
1577 | 1576 |