@@ -39,19 +39,19 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function merge_content_meta_keys( $meta_keys = array(), $post = null, & $views = null ) { |
41 | 41 | |
42 | - if( empty( $post->panels_data ) || empty( $post->panels_data['widgets'] ) ) { |
|
42 | + if ( empty( $post->panels_data ) || empty( $post->panels_data[ 'widgets' ] ) ) { |
|
43 | 43 | return $meta_keys; |
44 | 44 | } |
45 | 45 | |
46 | - foreach ( (array) $post->panels_data['widgets'] as $widget ) { |
|
46 | + foreach ( (array)$post->panels_data[ 'widgets' ] as $widget ) { |
|
47 | 47 | |
48 | 48 | $views->merge( \GV\View_Collection::from_content( \GV\Utils::get( $widget, 'text' ) ) ); |
49 | 49 | |
50 | - if ( empty( $widget['tabs'] ) || ! is_array( $widget['tabs'] ) ) { |
|
50 | + if ( empty( $widget[ 'tabs' ] ) || ! is_array( $widget[ 'tabs' ] ) ) { |
|
51 | 51 | continue; |
52 | 52 | } |
53 | 53 | |
54 | - foreach ( $widget['tabs'] as $tab ) { |
|
54 | + foreach ( $widget[ 'tabs' ] as $tab ) { |
|
55 | 55 | |
56 | 56 | // Livemesh Tabs |
57 | 57 | $backup = \GV\Utils::get( $tab, 'tab_content' ); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // SiteOrigin Tabs |
60 | 60 | $content = \GV\Utils::get( $tab, 'content_text', $backup ); |
61 | 61 | |
62 | - if( $content ) { |
|
62 | + if ( $content ) { |
|
63 | 63 | $views->merge( \GV\View_Collection::from_content( $content ) ); |
64 | 64 | } |
65 | 65 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $acf_keys = get_field_objects( $post->ID, array( 'load_value' => false ) ); |
57 | 57 | |
58 | - if( $acf_keys ) { |
|
58 | + if ( $acf_keys ) { |
|
59 | 59 | return array_merge( array_keys( $acf_keys ), $meta_keys ); |
60 | 60 | } |
61 | 61 | |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * @return void |
71 | 71 | */ |
72 | 72 | private function fix_posted_fields() { |
73 | - if( is_admin() && isset( $_POST['action'] ) && isset( $_POST['post_type'] ) ) { |
|
74 | - if( 'editpost' === $_POST['action'] && 'gravityview' === $_POST['post_type'] ) { |
|
75 | - $_POST['fields'] = _gravityview_process_posted_fields(); |
|
73 | + if ( is_admin() && isset( $_POST[ 'action' ] ) && isset( $_POST[ 'post_type' ] ) ) { |
|
74 | + if ( 'editpost' === $_POST[ 'action' ] && 'gravityview' === $_POST[ 'post_type' ] ) { |
|
75 | + $_POST[ 'fields' ] = _gravityview_process_posted_fields(); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | } |
@@ -24,9 +24,8 @@ |
||
24 | 24 | /** |
25 | 25 | * Get a \GV\Field by Field ID for this data source. |
26 | 26 | * |
27 | - * @param int $field_id The internal field ID (custom content, etc.) |
|
28 | 27 | * |
29 | - * @return \GV\Field|null The requested field or null if not found. |
|
28 | + * @return null|Internal_Field The requested field or null if not found. |
|
30 | 29 | */ |
31 | 30 | public static function get_field( /** varargs */ ) { |
32 | 31 | $args = func_get_args(); |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | */ |
45 | 45 | $atts = apply_filters( 'gravityview/shortcodes/gventry/atts', $atts ); |
46 | 46 | |
47 | - $view = \GV\View::by_id( $atts['view_id'] ); |
|
47 | + $view = \GV\View::by_id( $atts[ 'view_id' ] ); |
|
48 | 48 | |
49 | 49 | if ( ! $view ) { |
50 | - gravityview()->log->error( 'View does not exist #{view_id}', array( 'view_id' => $atts['view_id'] ) ); |
|
50 | + gravityview()->log->error( 'View does not exist #{view_id}', array( 'view_id' => $atts[ 'view_id' ] ) ); |
|
51 | 51 | return apply_filters( 'gravityview/shortcodes/gventry/output', '', null, null, $atts ); |
52 | 52 | } |
53 | 53 | |
54 | - $entry_id = ! empty( $atts['entry_id'] ) ? $atts['entry_id'] : $atts['id']; |
|
54 | + $entry_id = ! empty( $atts[ 'entry_id' ] ) ? $atts[ 'entry_id' ] : $atts[ 'id' ]; |
|
55 | 55 | |
56 | - switch( $entry_id ): |
|
56 | + switch ( $entry_id ): |
|
57 | 57 | case 'last': |
58 | 58 | if ( class_exists( '\GF_Query' ) ) { |
59 | 59 | /** |
@@ -62,17 +62,17 @@ discard block |
||
62 | 62 | * Since we're using \GF_Query shorthand initialization we have to reverse the order parameters here. |
63 | 63 | */ |
64 | 64 | add_filter( 'gravityview_get_entries', $filter = function( $parameters, $args, $form_id ) { |
65 | - if ( ! empty( $parameters['sorting'] ) ) { |
|
65 | + if ( ! empty( $parameters[ 'sorting' ] ) ) { |
|
66 | 66 | /** |
67 | 67 | * Reverse existing sorts. |
68 | 68 | */ |
69 | - $sort = &$parameters['sorting']; |
|
70 | - $sort['direction'] = $sort['direction'] == 'RAND' ? : ( $sort['direction'] == 'ASC' ? 'DESC' : 'ASC' ); |
|
69 | + $sort = &$parameters[ 'sorting' ]; |
|
70 | + $sort[ 'direction' ] = $sort[ 'direction' ] == 'RAND' ?: ( $sort[ 'direction' ] == 'ASC' ? 'DESC' : 'ASC' ); |
|
71 | 71 | } else { |
72 | 72 | /** |
73 | 73 | * Otherwise, sort by date_created. |
74 | 74 | */ |
75 | - $parameters['sorting'] = array( |
|
75 | + $parameters[ 'sorting' ] = array( |
|
76 | 76 | 'key' => 'id', |
77 | 77 | 'direction' => 'ASC', |
78 | 78 | 'is_numeric' => true |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | /** If a sort already exists, reverse it. */ |
89 | 89 | if ( $sort = end( $entries->sorts ) ) { |
90 | - $entries = $entries->sort( new \GV\Entry_Sort( $sort->field, $sort->direction == \GV\Entry_Sort::RAND ? : ( $sort->direction == \GV\Entry_Sort::ASC ? \GV\Entry_Sort::DESC : \GV\Entry_Sort::ASC ) ), $sort->mode ); |
|
90 | + $entries = $entries->sort( new \GV\Entry_Sort( $sort->field, $sort->direction == \GV\Entry_Sort::RAND ?: ( $sort->direction == \GV\Entry_Sort::ASC ? \GV\Entry_Sort::DESC : \GV\Entry_Sort::ASC ) ), $sort->mode ); |
|
91 | 91 | } else { |
92 | 92 | /** Otherwise, sort by date_created */ |
93 | 93 | $entries = $entries->sort( new \GV\Entry_Sort( \GV\Internal_Field::by_id( 'id' ), \GV\Entry_Sort::ASC ), \GV\Entry_Sort::NUMERIC ); |
@@ -105,12 +105,12 @@ discard block |
||
105 | 105 | break; |
106 | 106 | default: |
107 | 107 | if ( ! $entry = \GV\GF_Entry::by_id( $entry_id ) ) { |
108 | - gravityview()->log->error( 'Entry #{entry_id} not found', array( 'view_id' => $atts['view_id'] ) ); |
|
108 | + gravityview()->log->error( 'Entry #{entry_id} not found', array( 'view_id' => $atts[ 'view_id' ] ) ); |
|
109 | 109 | return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, null, $atts ); |
110 | 110 | } |
111 | 111 | endswitch; |
112 | 112 | |
113 | - if ( $view->form->ID != $entry['form_id'] ) { |
|
113 | + if ( $view->form->ID != $entry[ 'form_id' ] ) { |
|
114 | 114 | gravityview()->log->error( 'Entry does not belong to view (form mismatch)' ); |
115 | 115 | return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts ); |
116 | 116 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | return apply_filters( 'gravityview/shortcodes/gventry/output', get_the_password_form( $view->ID ), $view, $entry, $atts ); |
121 | 121 | } |
122 | 122 | |
123 | - if ( ! $view->form ) { |
|
123 | + if ( ! $view->form ) { |
|
124 | 124 | gravityview()->log->notice( 'View #{id} has no form attached to it.', array( 'id' => $view->ID ) ); |
125 | 125 | |
126 | 126 | /** |
@@ -143,15 +143,15 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | /** Unapproved entries. */ |
146 | - if ( $entry['status'] != 'active' ) { |
|
146 | + if ( $entry[ 'status' ] != 'active' ) { |
|
147 | 147 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
148 | 148 | return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts ); |
149 | 149 | } |
150 | 150 | |
151 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
151 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
152 | 152 | |
153 | 153 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
154 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
154 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
155 | 155 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
156 | 156 | return apply_filters( 'gravityview/shortcodes/gventry/output', '', $view, $entry, $atts ); |
157 | 157 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $renderer = new \GV\Entry_Renderer(); |
164 | 164 | |
165 | 165 | $request = new \GV\Mock_Request(); |
166 | - $request->returns['is_entry'] = $entry; |
|
166 | + $request->returns[ 'is_entry' ] = $entry; |
|
167 | 167 | |
168 | 168 | $output = $renderer->render( $entry, $view, $request ); |
169 | 169 |
@@ -29,12 +29,12 @@ |
||
29 | 29 | */ |
30 | 30 | public static function from_configuration( $configuration ) { |
31 | 31 | |
32 | - if ( empty( $configuration['id'] ) || ! is_string( $configuration['id'] ) ) { |
|
32 | + if ( empty( $configuration[ 'id' ] ) || ! is_string( $configuration[ 'id' ] ) ) { |
|
33 | 33 | gravityview()->log->error( 'Invalid configuration[id] supplied.' ); |
34 | 34 | return null; |
35 | 35 | } |
36 | 36 | |
37 | - $field = self::by_id( $configuration['id'] ); |
|
37 | + $field = self::by_id( $configuration[ 'id' ] ); |
|
38 | 38 | |
39 | 39 | $field->update_configuration( $configuration ); |
40 | 40 |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @return \GV\Field The field implementation from configuration (\GV\GF_Field, \GV\Internal_Field). |
167 | 167 | */ |
168 | 168 | public static function from_configuration( $configuration ) { |
169 | - if ( empty( $configuration['id'] ) ) { |
|
169 | + if ( empty( $configuration[ 'id' ] ) ) { |
|
170 | 170 | $field = new self(); |
171 | 171 | gravityview()->log->error( 'Trying to get field from configuration without a field ID.', array( 'data' => $configuration ) ); |
172 | 172 | $field->update_configuration( $configuration ); |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | } else { |
180 | 180 | $trace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); |
181 | 181 | } |
182 | - $trace = $trace[1]; |
|
183 | - if ( $trace['function'] == 'from_configuration' && $trace['class'] == __CLASS__ ) { |
|
182 | + $trace = $trace[ 1 ]; |
|
183 | + if ( $trace[ 'function' ] == 'from_configuration' && $trace[ 'class' ] == __CLASS__ ) { |
|
184 | 184 | $field = new self(); |
185 | 185 | gravityview()->log->error( 'Infinite loop protection tripped. Returning default class here.' ); |
186 | 186 | $field->update_configuration( $configuration ); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | /** Determine the field implementation to use, and try to use. */ |
191 | - $field_class = is_numeric( $configuration['id'] ) ? '\GV\GF_Field' : '\GV\Internal_Field'; |
|
191 | + $field_class = is_numeric( $configuration[ 'id' ] ) ? '\GV\GF_Field' : '\GV\Internal_Field'; |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * @filter `gravityview/field/class` Filter the field class about to be created from the configuration. |
@@ -227,24 +227,24 @@ discard block |
||
227 | 227 | public function update_configuration( $configuration ) { |
228 | 228 | $configuration = wp_parse_args( $configuration, $this->as_configuration() ); |
229 | 229 | |
230 | - if ( $this->ID != $configuration['id'] ) { |
|
230 | + if ( $this->ID != $configuration[ 'id' ] ) { |
|
231 | 231 | /** Smelling trouble here... */ |
232 | 232 | gravityview()->log->warning( 'ID is being changed for {field_class} instance, but implementation is not. Use ::from_configuration instead', array( 'field_class', __CLASS__ ) ); |
233 | 233 | } |
234 | 234 | |
235 | - $this->ID = $configuration['id']; |
|
236 | - $this->label = $configuration['label']; |
|
237 | - $this->show_label = $configuration['show_label'] == '1'; |
|
238 | - $this->custom_label = $configuration['custom_label']; |
|
239 | - $this->custom_class = $configuration['custom_class']; |
|
240 | - $this->cap = $configuration['only_loggedin'] == '1' ? $configuration['only_loggedin_cap'] : ''; |
|
241 | - $this->search_filter = $configuration['search_filter'] == '1'; |
|
242 | - $this->show_as_link = $configuration['show_as_link'] == '1'; |
|
235 | + $this->ID = $configuration[ 'id' ]; |
|
236 | + $this->label = $configuration[ 'label' ]; |
|
237 | + $this->show_label = $configuration[ 'show_label' ] == '1'; |
|
238 | + $this->custom_label = $configuration[ 'custom_label' ]; |
|
239 | + $this->custom_class = $configuration[ 'custom_class' ]; |
|
240 | + $this->cap = $configuration[ 'only_loggedin' ] == '1' ? $configuration[ 'only_loggedin_cap' ] : ''; |
|
241 | + $this->search_filter = $configuration[ 'search_filter' ] == '1'; |
|
242 | + $this->show_as_link = $configuration[ 'show_as_link' ] == '1'; |
|
243 | 243 | |
244 | 244 | /** Shared among all field types (sort of). */ |
245 | 245 | $shared_configuration_keys = array( |
246 | 246 | 'id', 'label', 'show_label', 'custom_label', 'custom_class', |
247 | - 'only_loggedin' ,'only_loggedin_cap', 'search_filter', 'show_as_link', |
|
247 | + 'only_loggedin', 'only_loggedin_cap', 'search_filter', 'show_as_link', |
|
248 | 248 | ); |
249 | 249 | |
250 | 250 | /** Everything else goes into the properties for now. @todo subclasses! */ |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | |
274 | 274 | /** A custom label is available. */ |
275 | 275 | if ( ! empty( $this->custom_label ) ) { |
276 | - return \GravityView_API::replace_variables( $this->custom_label, $source ? $source->form ? : null : null, $entry ? $entry->as_entry() : null ); |
|
276 | + return \GravityView_API::replace_variables( $this->custom_label, $source ? $source->form ?: null : null, $entry ? $entry->as_entry() : null ); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | return ''; |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * @return mixed|null The value for the given configuration key, null if doesn't exist. |
351 | 351 | */ |
352 | 352 | public function __get( $key ) { |
353 | - switch( $key ): |
|
353 | + switch ( $key ): |
|
354 | 354 | default: |
355 | 355 | if ( isset( $this->configuration[ $key ] ) ) { |
356 | 356 | return $this->configuration[ $key ]; |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * @return boolean Whether this $key is set or not. |
367 | 367 | */ |
368 | 368 | public function __isset( $key ) { |
369 | - switch( $key ): |
|
369 | + switch ( $key ): |
|
370 | 370 | default: |
371 | 371 | return isset( $this->configuration[ $key ] ); |
372 | 372 | endswitch; |
@@ -53,7 +53,6 @@ discard block |
||
53 | 53 | * Columns are able to be added to View layouts, but not separately searched! |
54 | 54 | * |
55 | 55 | * @param array $fields |
56 | - * @param int $form_id |
|
57 | 56 | * |
58 | 57 | * @return array |
59 | 58 | */ |
@@ -133,7 +132,7 @@ discard block |
||
133 | 132 | * |
134 | 133 | * @param GF_Field_List $field Gravity Forms field |
135 | 134 | * @param string|array $field_value Serialized or unserialized array value for the field |
136 | - * @param int|string $column_id The numeric key of the column (0-index) or the label of the column |
|
135 | + * @param integer $column_id The numeric key of the column (0-index) or the label of the column |
|
137 | 136 | * @param string $format If set to 'raw', return an array of values for the column. Otherwise, allow Gravity Forms to render using `html` or `text` |
138 | 137 | * |
139 | 138 | * @return array|string|null Returns null if the $field_value passed wasn't an array or serialized array |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public function remove_columns_from_searchable_fields( $fields ) { |
61 | 61 | |
62 | 62 | foreach ( $fields as $key => $field ) { |
63 | - if ( isset( $field['parent'] ) && $field['parent'] instanceof \GF_Field_List ) { |
|
63 | + if ( isset( $field[ 'parent' ] ) && $field[ 'parent' ] instanceof \GF_Field_List ) { |
|
64 | 64 | unset( $fields[ $key ] ); |
65 | 65 | } |
66 | 66 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | // Add the list columns |
87 | 87 | foreach ( $list_fields as $list_field ) { |
88 | 88 | |
89 | - if( empty( $list_field->enableColumns ) ) { |
|
89 | + if ( empty( $list_field->enableColumns ) ) { |
|
90 | 90 | continue; |
91 | 91 | } |
92 | 92 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | // If there are columns, add them under the parent field |
110 | - if( ! empty( $list_columns ) ) { |
|
110 | + if ( ! empty( $list_columns ) ) { |
|
111 | 111 | |
112 | 112 | $index = array_search( $list_field->id, array_keys( $fields ) ) + 1; |
113 | 113 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * Merge the $list_columns into the $fields array at $index |
116 | 116 | * @see https://stackoverflow.com/a/1783125 |
117 | 117 | */ |
118 | - $fields = array_slice( $fields, 0, $index, true) + $list_columns + array_slice( $fields, $index, null, true); |
|
118 | + $fields = array_slice( $fields, 0, $index, true ) + $list_columns + array_slice( $fields, $index, null, true ); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | unset( $list_columns, $index, $input_id ); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | $list_rows = maybe_unserialize( $field_value ); |
144 | 144 | |
145 | - if( ! is_array( $list_rows ) ) { |
|
145 | + if ( ! is_array( $list_rows ) ) { |
|
146 | 146 | gravityview()->log->error( '$field_value did not unserialize', array( 'data' => $field_value ) ); |
147 | 147 | return null; |
148 | 148 | } |
@@ -152,18 +152,18 @@ discard block |
||
152 | 152 | // Each list row |
153 | 153 | foreach ( $list_rows as $list_row ) { |
154 | 154 | $current_column = 0; |
155 | - foreach ( (array) $list_row as $column_key => $column_value ) { |
|
155 | + foreach ( (array)$list_row as $column_key => $column_value ) { |
|
156 | 156 | |
157 | 157 | // If the label of the column matches $column_id, or the numeric key value matches, add the value |
158 | - if( (string)$column_key === (string)$column_id || ( is_numeric( $column_id ) && (int)$column_id === $current_column ) ) { |
|
159 | - $column_values[] = $column_value; |
|
158 | + if ( (string)$column_key === (string)$column_id || ( is_numeric( $column_id ) && (int)$column_id === $current_column ) ) { |
|
159 | + $column_values[ ] = $column_value; |
|
160 | 160 | } |
161 | 161 | $current_column++; |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | 165 | // Return the array of values |
166 | - if( 'raw' === $format ) { |
|
166 | + if ( 'raw' === $format ) { |
|
167 | 167 | return $column_values; |
168 | 168 | } |
169 | 169 | // Return the Gravity Forms Field output |
@@ -186,22 +186,22 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function _filter_field_label( $label, $field, $form, $entry ) { |
188 | 188 | |
189 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
189 | + $field_object = RGFormsModel::get_field( $form, $field[ 'id' ] ); |
|
190 | 190 | |
191 | 191 | // Not a list field |
192 | - if( ! $field_object || 'list' !== $field_object->type ) { |
|
192 | + if ( ! $field_object || 'list' !== $field_object->type ) { |
|
193 | 193 | return $label; |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Custom label is defined, so use it |
197 | - if( ! empty( $field['custom_label'] ) ) { |
|
197 | + if ( ! empty( $field[ 'custom_label' ] ) ) { |
|
198 | 198 | return $label; |
199 | 199 | } |
200 | 200 | |
201 | - $column_id = gravityview_get_input_id_from_id( $field['id'] ); |
|
201 | + $column_id = gravityview_get_input_id_from_id( $field[ 'id' ] ); |
|
202 | 202 | |
203 | 203 | // Parent field, not column field |
204 | - if( false === $column_id ) { |
|
204 | + if ( false === $column_id ) { |
|
205 | 205 | return $label; |
206 | 206 | } |
207 | 207 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | public static function get_column_label( GF_Field_List $field, $column_id, $backup_label = '' ) { |
223 | 223 | |
224 | 224 | // Doesn't have columns enabled |
225 | - if( ! isset( $field->choices ) || ! $field->enableColumns ) { |
|
225 | + if ( ! isset( $field->choices ) || ! $field->enableColumns ) { |
|
226 | 226 | return $backup_label; |
227 | 227 | } |
228 | 228 |
@@ -603,7 +603,8 @@ discard block |
||
603 | 603 | // Fast-forward 24 hour on the end time |
604 | 604 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
605 | 605 | $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
606 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
606 | + if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { |
|
607 | +// See https://github.com/gravityview/GravityView/issues/1056 |
|
607 | 608 | $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
608 | 609 | } |
609 | 610 | } |
@@ -874,7 +875,7 @@ discard block |
||
874 | 875 | 'ymd_dot' => 'Y.m.d', |
875 | 876 | ); |
876 | 877 | |
877 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
878 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
878 | 879 | $format = $datepicker[ $field->dateFormat ]; |
879 | 880 | } |
880 | 881 |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | /** |
244 | 244 | * Add admin script to the no-conflict scripts whitelist |
245 | 245 | * @param array $allowed Scripts allowed in no-conflict mode |
246 | - * @return array Scripts allowed in no-conflict mode, plus the search widget script |
|
246 | + * @return string[] Scripts allowed in no-conflict mode, plus the search widget script |
|
247 | 247 | */ |
248 | 248 | public function register_no_conflict( $allowed ) { |
249 | 249 | $allowed[] = 'gravityview_searchwidget_admin'; |
@@ -709,7 +709,6 @@ discard block |
||
709 | 709 | * Dropin for the legacy flat filters when \GF_Query is available. |
710 | 710 | * |
711 | 711 | * @param \GF_Query $query The current query object reference |
712 | - * @param \GV\View $this The current view object |
|
713 | 712 | * @param \GV\Request $request The request object |
714 | 713 | */ |
715 | 714 | public function gf_query_filter( &$query, $view, $request ) { |
@@ -1199,7 +1198,7 @@ discard block |
||
1199 | 1198 | /** |
1200 | 1199 | * Get the label for a search form field |
1201 | 1200 | * @param array $field Field setting as sent by the GV configuration - has `field`, `input` (input type), and `label` keys |
1202 | - * @param array $form_field Form field data, as fetched by `gravityview_get_field()` |
|
1201 | + * @param GF_Field|null $form_field Form field data, as fetched by `gravityview_get_field()` |
|
1203 | 1202 | * @return string Label for the search form |
1204 | 1203 | */ |
1205 | 1204 | private static function get_field_label( $field, $form_field = array() ) { |
@@ -1364,7 +1363,7 @@ discard block |
||
1364 | 1363 | /** |
1365 | 1364 | * Require the datepicker script for the frontend GV script |
1366 | 1365 | * @param array $js_dependencies Array of existing required scripts for the fe-views.js script |
1367 | - * @return array Array required scripts, with `jquery-ui-datepicker` added |
|
1366 | + * @return string[] Array required scripts, with `jquery-ui-datepicker` added |
|
1368 | 1367 | */ |
1369 | 1368 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1370 | 1369 | |
@@ -1376,7 +1375,7 @@ discard block |
||
1376 | 1375 | /** |
1377 | 1376 | * Modify the array passed to wp_localize_script() |
1378 | 1377 | * |
1379 | - * @param array $js_localization The data padded to the Javascript file |
|
1378 | + * @param array $localizations The data padded to the Javascript file |
|
1380 | 1379 | * @param array $view_data View data array with View settings |
1381 | 1380 | * |
1382 | 1381 | * @return array |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | 'type' => 'radio', |
65 | 65 | 'full_width' => true, |
66 | 66 | 'label' => esc_html__( 'Search Mode', 'gravityview' ), |
67 | - 'desc' => __('Should search results match all search fields, or any?', 'gravityview'), |
|
67 | + 'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ), |
|
68 | 68 | 'value' => 'any', |
69 | 69 | 'class' => 'hide-if-js', |
70 | 70 | 'options' => array( |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | // admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999 |
88 | 88 | add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 ); |
89 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') ); |
|
89 | + add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
90 | 90 | add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
91 | 91 | |
92 | 92 | // ajax - get the searchable fields |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
228 | 228 | $script_source = empty( $script_min ) ? '/source' : ''; |
229 | 229 | |
230 | - wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
230 | + wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version ); |
|
231 | 231 | |
232 | 232 | wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array( |
233 | 233 | 'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ), |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @return array Scripts allowed in no-conflict mode, plus the search widget script |
250 | 250 | */ |
251 | 251 | public function register_no_conflict( $allowed ) { |
252 | - $allowed[] = 'gravityview_searchwidget_admin'; |
|
252 | + $allowed[ ] = 'gravityview_searchwidget_admin'; |
|
253 | 253 | return $allowed; |
254 | 254 | } |
255 | 255 | |
@@ -262,24 +262,24 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public static function get_searchable_fields() { |
264 | 264 | |
265 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) { |
|
265 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) { |
|
266 | 266 | exit( '0' ); |
267 | 267 | } |
268 | 268 | |
269 | 269 | $form = ''; |
270 | 270 | |
271 | 271 | // Fetch the form for the current View |
272 | - if ( ! empty( $_POST['view_id'] ) ) { |
|
272 | + if ( ! empty( $_POST[ 'view_id' ] ) ) { |
|
273 | 273 | |
274 | - $form = gravityview_get_form_id( $_POST['view_id'] ); |
|
274 | + $form = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
275 | 275 | |
276 | - } elseif ( ! empty( $_POST['formid'] ) ) { |
|
276 | + } elseif ( ! empty( $_POST[ 'formid' ] ) ) { |
|
277 | 277 | |
278 | - $form = (int) $_POST['formid']; |
|
278 | + $form = (int)$_POST[ 'formid' ]; |
|
279 | 279 | |
280 | - } elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
280 | + } elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) { |
|
281 | 281 | |
282 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
282 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
283 | 283 | |
284 | 284 | } |
285 | 285 | |
@@ -329,14 +329,14 @@ discard block |
||
329 | 329 | ); |
330 | 330 | |
331 | 331 | if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) { |
332 | - $custom_fields['is_approved'] = array( |
|
332 | + $custom_fields[ 'is_approved' ] = array( |
|
333 | 333 | 'text' => esc_html__( 'Is Approved', 'gravityview' ), |
334 | 334 | 'type' => 'boolean', |
335 | 335 | ); |
336 | 336 | } |
337 | 337 | |
338 | - foreach( $custom_fields as $custom_field_key => $custom_field ) { |
|
339 | - $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] ); |
|
338 | + foreach ( $custom_fields as $custom_field_key => $custom_field ) { |
|
339 | + $output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field[ 'type' ], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field[ 'text' ] ); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | // Get fields with sub-inputs and no parent |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | |
359 | 359 | foreach ( $fields as $id => $field ) { |
360 | 360 | |
361 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
361 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
362 | 362 | continue; |
363 | 363 | } |
364 | 364 | |
365 | - $types = self::get_search_input_types( $id, $field['type'] ); |
|
365 | + $types = self::get_search_input_types( $id, $field[ 'type' ] ); |
|
366 | 366 | |
367 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>'; |
|
367 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>'; |
|
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | public static function get_search_input_types( $field_id = '', $field_type = null ) { |
388 | 388 | |
389 | 389 | // @todo - This needs to be improved - many fields have . including products and addresses |
390 | - if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
390 | + if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) { |
|
391 | 391 | $input_type = 'boolean'; // on/off checkbox |
392 | 392 | } elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) { |
393 | 393 | $input_type = 'multi'; //multiselect |
@@ -431,19 +431,19 @@ discard block |
||
431 | 431 | $post_id = 0; |
432 | 432 | |
433 | 433 | // We're in the WordPress Widget context, and an overriding post ID has been set. |
434 | - if ( ! empty( $widget_args['post_id'] ) ) { |
|
435 | - $post_id = absint( $widget_args['post_id'] ); |
|
434 | + if ( ! empty( $widget_args[ 'post_id' ] ) ) { |
|
435 | + $post_id = absint( $widget_args[ 'post_id' ] ); |
|
436 | 436 | } |
437 | 437 | // We're in the WordPress Widget context, and the base View ID should be used |
438 | - else if ( ! empty( $widget_args['view_id'] ) ) { |
|
439 | - $post_id = absint( $widget_args['view_id'] ); |
|
438 | + else if ( ! empty( $widget_args[ 'view_id' ] ) ) { |
|
439 | + $post_id = absint( $widget_args[ 'view_id' ] ); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | $args = gravityview_get_permalink_query_args( $post_id ); |
443 | 443 | |
444 | 444 | // Add hidden fields to the search form |
445 | 445 | foreach ( $args as $key => $value ) { |
446 | - $search_fields[] = array( |
|
446 | + $search_fields[ ] = array( |
|
447 | 447 | 'name' => $key, |
448 | 448 | 'input' => 'hidden', |
449 | 449 | 'value' => $value, |
@@ -482,22 +482,22 @@ discard block |
||
482 | 482 | /** |
483 | 483 | * Include the sidebar Widgets. |
484 | 484 | */ |
485 | - $widgets = (array) get_option( 'widget_gravityview_search', array() ); |
|
485 | + $widgets = (array)get_option( 'widget_gravityview_search', array() ); |
|
486 | 486 | |
487 | 487 | foreach ( $widgets as $widget ) { |
488 | - if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) { |
|
489 | - if( $_fields = json_decode( $widget['search_fields'], true ) ) { |
|
488 | + if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) { |
|
489 | + if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) { |
|
490 | 490 | foreach ( $_fields as $field ) { |
491 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
491 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
492 | 492 | } |
493 | 493 | } |
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | 497 | foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) { |
498 | - if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
498 | + if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) { |
|
499 | 499 | foreach ( $_fields as $field ) { |
500 | - $searchable_fields [] = $with_full_field ? $field : $field['field']; |
|
500 | + $searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ]; |
|
501 | 501 | } |
502 | 502 | } |
503 | 503 | } |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | return $search_criteria; // Return the original criteria, GF_Query modification kicks in later |
528 | 528 | } |
529 | 529 | |
530 | - if( 'post' === $this->search_method ) { |
|
530 | + if ( 'post' === $this->search_method ) { |
|
531 | 531 | $get = $_POST; |
532 | 532 | } else { |
533 | 533 | $get = $_GET; |
@@ -546,14 +546,14 @@ discard block |
||
546 | 546 | $get = gv_map_deep( $get, 'rawurldecode' ); |
547 | 547 | |
548 | 548 | // Make sure array key is set up |
549 | - $search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
549 | + $search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() ); |
|
550 | 550 | |
551 | 551 | $searchable_fields = $this->get_view_searchable_fields( $view ); |
552 | 552 | |
553 | 553 | // add free search |
554 | - if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) { |
|
554 | + if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) { |
|
555 | 555 | |
556 | - $search_all_value = trim( $get['gv_search'] ); |
|
556 | + $search_all_value = trim( $get[ 'gv_search' ] ); |
|
557 | 557 | |
558 | 558 | /** |
559 | 559 | * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase? |
@@ -578,7 +578,7 @@ discard block |
||
578 | 578 | } |
579 | 579 | |
580 | 580 | foreach ( $words as $word ) { |
581 | - $search_criteria['field_filters'][] = array( |
|
581 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
582 | 582 | 'key' => null, // The field ID to search |
583 | 583 | 'value' => $word, // The value to search |
584 | 584 | 'operator' => 'contains', // What to search in. Options: `is` or `contains` |
@@ -591,14 +591,14 @@ discard block |
||
591 | 591 | /** |
592 | 592 | * Get and normalize the dates according to the input format. |
593 | 593 | */ |
594 | - if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) { |
|
595 | - if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
594 | + if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) { |
|
595 | + if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) { |
|
596 | 596 | $curr_start = $curr_start_date->format( 'Y-m-d' ); |
597 | 597 | } |
598 | 598 | } |
599 | 599 | |
600 | - if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) { |
|
601 | - if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
600 | + if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) { |
|
601 | + if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) { |
|
602 | 602 | $curr_end = $curr_end_date->format( 'Y-m-d' ); |
603 | 603 | } |
604 | 604 | } |
@@ -633,22 +633,22 @@ discard block |
||
633 | 633 | */ |
634 | 634 | if ( ! empty( $curr_start ) ) { |
635 | 635 | $curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) ); |
636 | - $search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
636 | + $search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start; |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | if ( ! empty( $curr_end ) ) { |
640 | 640 | // Fast-forward 24 hour on the end time |
641 | 641 | $curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS ); |
642 | - $search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
643 | - if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
644 | - $search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 ); |
|
642 | + $search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end; |
|
643 | + if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056 |
|
644 | + $search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 ); |
|
645 | 645 | } |
646 | 646 | } |
647 | 647 | } |
648 | 648 | |
649 | 649 | // search for a specific entry ID |
650 | 650 | if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) { |
651 | - $search_criteria['field_filters'][] = array( |
|
651 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
652 | 652 | 'key' => 'id', |
653 | 653 | 'value' => absint( $get[ 'gv_id' ] ), |
654 | 654 | 'operator' => '=', |
@@ -657,42 +657,42 @@ discard block |
||
657 | 657 | |
658 | 658 | // search for a specific Created_by ID |
659 | 659 | if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) { |
660 | - $search_criteria['field_filters'][] = array( |
|
660 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
661 | 661 | 'key' => 'created_by', |
662 | - 'value' => absint( $get['gv_by'] ), |
|
662 | + 'value' => absint( $get[ 'gv_by' ] ), |
|
663 | 663 | 'operator' => '=', |
664 | 664 | ); |
665 | 665 | } |
666 | 666 | |
667 | 667 | |
668 | 668 | // Get search mode passed in URL |
669 | - $mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ? $get['mode'] : 'any'; |
|
669 | + $mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any'; |
|
670 | 670 | |
671 | 671 | // get the other search filters |
672 | 672 | foreach ( $get as $key => $value ) { |
673 | 673 | |
674 | - if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) { |
|
674 | + if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) { |
|
675 | 675 | continue; |
676 | 676 | } |
677 | 677 | |
678 | 678 | $filter_key = $this->convert_request_key_to_filter_key( $key ); |
679 | 679 | |
680 | 680 | // could return simple filter or multiple filters |
681 | - if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key , $searchable_fields ) ) { |
|
681 | + if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key, $searchable_fields ) ) { |
|
682 | 682 | continue; |
683 | 683 | } |
684 | 684 | |
685 | 685 | $filter = $this->prepare_field_filter( $filter_key, $value, $view ); |
686 | 686 | |
687 | - if ( isset( $filter[0]['value'] ) ) { |
|
688 | - $search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter ); |
|
687 | + if ( isset( $filter[ 0 ][ 'value' ] ) ) { |
|
688 | + $search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter ); |
|
689 | 689 | |
690 | 690 | // if date range type, set search mode to ALL |
691 | - if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) { |
|
691 | + if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) { |
|
692 | 692 | $mode = 'all'; |
693 | 693 | } |
694 | - } elseif( !empty( $filter ) ) { |
|
695 | - $search_criteria['field_filters'][] = $filter; |
|
694 | + } elseif ( ! empty( $filter ) ) { |
|
695 | + $search_criteria[ 'field_filters' ][ ] = $filter; |
|
696 | 696 | } |
697 | 697 | } |
698 | 698 | |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | * @since 1.5.1 |
702 | 702 | * @param[out,in] string $mode Search mode (`any` vs `all`) |
703 | 703 | */ |
704 | - $search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode ); |
|
704 | + $search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode ); |
|
705 | 705 | |
706 | 706 | gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) ); |
707 | 707 | |
@@ -726,15 +726,15 @@ discard block |
||
726 | 726 | */ |
727 | 727 | $search_criteria = $this->filter_entries( array(), null, array( 'id' => $view->ID ), true /** force search_criteria */ ); |
728 | 728 | |
729 | - if ( empty( $search_criteria['field_filters'] ) ) { |
|
729 | + if ( empty( $search_criteria[ 'field_filters' ] ) ) { |
|
730 | 730 | return; |
731 | 731 | } |
732 | 732 | |
733 | 733 | $widgets = $view->widgets->by_id( $this->widget_id ); |
734 | 734 | if ( $widgets->count() ) { |
735 | - $widget = $widgets->all()[0]; |
|
735 | + $widget = $widgets->all()[ 0 ]; |
|
736 | 736 | foreach ( $search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) as $search_field ) { |
737 | - if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) { |
|
737 | + if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) { |
|
738 | 738 | $created_by_text_mode = true; |
739 | 739 | } |
740 | 740 | } |
@@ -742,19 +742,19 @@ discard block |
||
742 | 742 | |
743 | 743 | $extra_conditions = array(); |
744 | 744 | |
745 | - foreach ( $search_criteria['field_filters'] as &$filter ) { |
|
745 | + foreach ( $search_criteria[ 'field_filters' ] as &$filter ) { |
|
746 | 746 | if ( ! is_array( $filter ) ) { |
747 | 747 | continue; |
748 | 748 | } |
749 | 749 | |
750 | 750 | // Construct a manual query for unapproved statuses |
751 | - if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, $filter['value'] ) ) { |
|
752 | - $_tmp_query = new GF_Query( $view->form->ID, array( |
|
751 | + if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, $filter[ 'value' ] ) ) { |
|
752 | + $_tmp_query = new GF_Query( $view->form->ID, array( |
|
753 | 753 | 'field_filters' => array( |
754 | 754 | array( |
755 | 755 | 'operator' => 'in', |
756 | 756 | 'key' => 'is_approved', |
757 | - 'value' => $filter['value'], |
|
757 | + 'value' => $filter[ 'value' ], |
|
758 | 758 | ), |
759 | 759 | array( |
760 | 760 | 'operator' => 'is', |
@@ -766,17 +766,17 @@ discard block |
||
766 | 766 | ) ); |
767 | 767 | $_tmp_query_parts = $_tmp_query->_introspect(); |
768 | 768 | |
769 | - $extra_conditions[] = $_tmp_query_parts['where']; |
|
769 | + $extra_conditions[ ] = $_tmp_query_parts[ 'where' ]; |
|
770 | 770 | |
771 | 771 | $filter = false; |
772 | 772 | continue; |
773 | 773 | } |
774 | 774 | |
775 | 775 | // Construct manual query for text mode creator search |
776 | - if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) { |
|
777 | - $extra_conditions[] = new class( $filter, $view ) extends \GF_Query_Condition { |
|
776 | + if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) { |
|
777 | + $extra_conditions[ ] = new class( $filter, $view ) extends \GF_Query_Condition { |
|
778 | 778 | public function __construct( $filter, $view ) { |
779 | - $this->value = $filter['value']; |
|
779 | + $this->value = $filter[ 'value' ]; |
|
780 | 780 | $this->view = $view; |
781 | 781 | } |
782 | 782 | |
@@ -810,11 +810,11 @@ discard block |
||
810 | 810 | $conditions = array(); |
811 | 811 | |
812 | 812 | foreach ( $user_fields as $user_field ) { |
813 | - $conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
813 | + $conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | foreach ( $user_meta_fields as $meta_field ) { |
817 | - $conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
817 | + $conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' ); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | $conditions = '(' . implode( ' OR ', $conditions ) . ')'; |
@@ -830,11 +830,11 @@ discard block |
||
830 | 830 | } |
831 | 831 | |
832 | 832 | // By default, we want searches to be wildcard for each field. |
833 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
833 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
834 | 834 | |
835 | 835 | // For multichoice, let's have an in (OR) search. |
836 | - if ( is_array( $filter['value'] ) ) { |
|
837 | - $filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
836 | + if ( is_array( $filter[ 'value' ] ) ) { |
|
837 | + $filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)? |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | /** |
@@ -842,10 +842,10 @@ discard block |
||
842 | 842 | * @param string $operator Existing search operator |
843 | 843 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
844 | 844 | */ |
845 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
845 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
846 | 846 | } |
847 | 847 | |
848 | - $search_criteria['field_filters'] = array_filter( $search_criteria['field_filters'] ); |
|
848 | + $search_criteria[ 'field_filters' ] = array_filter( $search_criteria[ 'field_filters' ] ); |
|
849 | 849 | |
850 | 850 | /** |
851 | 851 | * Parse the filter criteria to generate the needed |
@@ -858,12 +858,12 @@ discard block |
||
858 | 858 | /** |
859 | 859 | * Grab the current clauses. We'll be combining them shortly. |
860 | 860 | */ |
861 | - $query_parts = $query->_introspect(); |
|
861 | + $query_parts = $query->_introspect(); |
|
862 | 862 | |
863 | 863 | /** |
864 | 864 | * Combine the parts as a new WHERE clause. |
865 | 865 | */ |
866 | - $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'], $_tmp_query_parts['where'] ), $extra_conditions ) ); |
|
866 | + $where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ], $_tmp_query_parts[ 'where' ] ), $extra_conditions ) ); |
|
867 | 867 | $query->where( $where ); |
868 | 868 | } |
869 | 869 | |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | $field_id = str_replace( 'filter_', '', $key ); |
887 | 887 | |
888 | 888 | // calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox ) |
889 | - if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) { |
|
889 | + if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) { |
|
890 | 890 | $field_id = str_replace( '_', '.', $field_id ); |
891 | 891 | } |
892 | 892 | |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | |
922 | 922 | case 'select': |
923 | 923 | case 'radio': |
924 | - $filter['operator'] = 'is'; |
|
924 | + $filter[ 'operator' ] = 'is'; |
|
925 | 925 | break; |
926 | 926 | |
927 | 927 | case 'post_category': |
@@ -935,7 +935,7 @@ discard block |
||
935 | 935 | |
936 | 936 | foreach ( $value as $val ) { |
937 | 937 | $cat = get_term( $val, 'category' ); |
938 | - $filter[] = array( |
|
938 | + $filter[ ] = array( |
|
939 | 939 | 'key' => $filter_key, |
940 | 940 | 'value' => esc_attr( $cat->name ) . ':' . $val, |
941 | 941 | 'operator' => 'is', |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | $filter = array(); |
955 | 955 | |
956 | 956 | foreach ( $value as $val ) { |
957 | - $filter[] = array( 'key' => $filter_key, 'value' => $val ); |
|
957 | + $filter[ ] = array( 'key' => $filter_key, 'value' => $val ); |
|
958 | 958 | } |
959 | 959 | |
960 | 960 | break; |
@@ -963,9 +963,9 @@ discard block |
||
963 | 963 | // convert checkbox on/off into the correct search filter |
964 | 964 | if ( false !== strpos( $filter_key, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) { |
965 | 965 | foreach ( $form_field->inputs as $k => $input ) { |
966 | - if ( $input['id'] == $filter_key ) { |
|
967 | - $filter['value'] = $form_field->choices[ $k ]['value']; |
|
968 | - $filter['operator'] = 'is'; |
|
966 | + if ( $input[ 'id' ] == $filter_key ) { |
|
967 | + $filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ]; |
|
968 | + $filter[ 'operator' ] = 'is'; |
|
969 | 969 | break; |
970 | 970 | } |
971 | 971 | } |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | $filter = array(); |
976 | 976 | |
977 | 977 | foreach ( $value as $val ) { |
978 | - $filter[] = array( |
|
978 | + $filter[ ] = array( |
|
979 | 979 | 'key' => $filter_key, |
980 | 980 | 'value' => $val, |
981 | 981 | 'operator' => 'is', |
@@ -996,9 +996,9 @@ discard block |
||
996 | 996 | foreach ( $words as $word ) { |
997 | 997 | if ( ! empty( $word ) && strlen( $word ) > 1 ) { |
998 | 998 | // Keep the same key for each filter |
999 | - $filter['value'] = $word; |
|
999 | + $filter[ 'value' ] = $word; |
|
1000 | 1000 | // Add a search for the value |
1001 | - $filters[] = $filter; |
|
1001 | + $filters[ ] = $filter; |
|
1002 | 1002 | } |
1003 | 1003 | } |
1004 | 1004 | |
@@ -1012,19 +1012,19 @@ discard block |
||
1012 | 1012 | |
1013 | 1013 | foreach ( $searchable_fields as $searchable_field ) { |
1014 | 1014 | |
1015 | - if( $form_field->ID !== $searchable_field['field'] ) { |
|
1015 | + if ( $form_field->ID !== $searchable_field[ 'field' ] ) { |
|
1016 | 1016 | continue; |
1017 | 1017 | } |
1018 | 1018 | |
1019 | 1019 | // Only exact-match dropdowns, not text search |
1020 | - if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) { |
|
1020 | + if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) { |
|
1021 | 1021 | continue; |
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | $input_id = gravityview_get_input_id_from_id( $form_field->ID ); |
1025 | 1025 | |
1026 | 1026 | if ( 4 === $input_id ) { |
1027 | - $filter['operator'] = 'is'; |
|
1027 | + $filter[ 'operator' ] = 'is'; |
|
1028 | 1028 | }; |
1029 | 1029 | } |
1030 | 1030 | } |
@@ -1051,12 +1051,12 @@ discard block |
||
1051 | 1051 | * @since 1.16.3 |
1052 | 1052 | * Safeguard until GF implements '<=' operator |
1053 | 1053 | */ |
1054 | - if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1054 | + if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) { |
|
1055 | 1055 | $operator = '<'; |
1056 | 1056 | $date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) ); |
1057 | 1057 | } |
1058 | 1058 | |
1059 | - $filter[] = array( |
|
1059 | + $filter[ ] = array( |
|
1060 | 1060 | 'key' => $filter_key, |
1061 | 1061 | 'value' => self::get_formatted_date( $date, 'Y-m-d', $date_format ), |
1062 | 1062 | 'operator' => $operator, |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | } |
1065 | 1065 | } else { |
1066 | 1066 | $date = $value; |
1067 | - $filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1067 | + $filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format ); |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | break; |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | 'ymd_dot' => 'Y.m.d', |
1096 | 1096 | ); |
1097 | 1097 | |
1098 | - if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){ |
|
1098 | + if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) { |
|
1099 | 1099 | $format = $datepicker[ $field->dateFormat ]; |
1100 | 1100 | } |
1101 | 1101 | |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | public function add_template_path( $file_paths ) { |
1133 | 1133 | |
1134 | 1134 | // Index 100 is the default GravityView template path. |
1135 | - $file_paths[102] = self::$file . 'templates/'; |
|
1135 | + $file_paths[ 102 ] = self::$file . 'templates/'; |
|
1136 | 1136 | |
1137 | 1137 | return $file_paths; |
1138 | 1138 | } |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | $has_date = false; |
1152 | 1152 | |
1153 | 1153 | foreach ( $search_fields as $k => $field ) { |
1154 | - if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1154 | + if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) { |
|
1155 | 1155 | $has_date = true; |
1156 | 1156 | break; |
1157 | 1157 | } |
@@ -1178,7 +1178,7 @@ discard block |
||
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | // get configured search fields |
1181 | - $search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : ''; |
|
1181 | + $search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : ''; |
|
1182 | 1182 | |
1183 | 1183 | if ( empty( $search_fields ) || ! is_array( $search_fields ) ) { |
1184 | 1184 | gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) ); |
@@ -1193,41 +1193,41 @@ discard block |
||
1193 | 1193 | |
1194 | 1194 | $updated_field = $this->get_search_filter_details( $updated_field ); |
1195 | 1195 | |
1196 | - switch ( $field['field'] ) { |
|
1196 | + switch ( $field[ 'field' ] ) { |
|
1197 | 1197 | |
1198 | 1198 | case 'search_all': |
1199 | - $updated_field['key'] = 'search_all'; |
|
1200 | - $updated_field['input'] = 'search_all'; |
|
1201 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1199 | + $updated_field[ 'key' ] = 'search_all'; |
|
1200 | + $updated_field[ 'input' ] = 'search_all'; |
|
1201 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' ); |
|
1202 | 1202 | break; |
1203 | 1203 | |
1204 | 1204 | case 'entry_date': |
1205 | - $updated_field['key'] = 'entry_date'; |
|
1206 | - $updated_field['input'] = 'entry_date'; |
|
1207 | - $updated_field['value'] = array( |
|
1205 | + $updated_field[ 'key' ] = 'entry_date'; |
|
1206 | + $updated_field[ 'input' ] = 'entry_date'; |
|
1207 | + $updated_field[ 'value' ] = array( |
|
1208 | 1208 | 'start' => $this->rgget_or_rgpost( 'gv_start' ), |
1209 | 1209 | 'end' => $this->rgget_or_rgpost( 'gv_end' ), |
1210 | 1210 | ); |
1211 | 1211 | break; |
1212 | 1212 | |
1213 | 1213 | case 'entry_id': |
1214 | - $updated_field['key'] = 'entry_id'; |
|
1215 | - $updated_field['input'] = 'entry_id'; |
|
1216 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1214 | + $updated_field[ 'key' ] = 'entry_id'; |
|
1215 | + $updated_field[ 'input' ] = 'entry_id'; |
|
1216 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' ); |
|
1217 | 1217 | break; |
1218 | 1218 | |
1219 | 1219 | case 'created_by': |
1220 | - $updated_field['key'] = 'created_by'; |
|
1221 | - $updated_field['name'] = 'gv_by'; |
|
1222 | - $updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1223 | - $updated_field['choices'] = self::get_created_by_choices(); |
|
1220 | + $updated_field[ 'key' ] = 'created_by'; |
|
1221 | + $updated_field[ 'name' ] = 'gv_by'; |
|
1222 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' ); |
|
1223 | + $updated_field[ 'choices' ] = self::get_created_by_choices(); |
|
1224 | 1224 | break; |
1225 | 1225 | |
1226 | 1226 | case 'is_approved': |
1227 | - $updated_field['key'] = 'is_approved'; |
|
1228 | - $updated_field['input'] = 'checkbox'; |
|
1229 | - $updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1230 | - $updated_field['choices'] = self::get_is_approved_choices(); |
|
1227 | + $updated_field[ 'key' ] = 'is_approved'; |
|
1228 | + $updated_field[ 'input' ] = 'checkbox'; |
|
1229 | + $updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' ); |
|
1230 | + $updated_field[ 'choices' ] = self::get_is_approved_choices(); |
|
1231 | 1231 | break; |
1232 | 1232 | } |
1233 | 1233 | |
@@ -1246,16 +1246,16 @@ discard block |
||
1246 | 1246 | */ |
1247 | 1247 | $gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context ); |
1248 | 1248 | |
1249 | - $gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal'; |
|
1249 | + $gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal'; |
|
1250 | 1250 | |
1251 | 1251 | /** @since 1.14 */ |
1252 | - $gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any'; |
|
1252 | + $gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any'; |
|
1253 | 1253 | |
1254 | - $custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : ''; |
|
1254 | + $custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : ''; |
|
1255 | 1255 | |
1256 | 1256 | $gravityview_view->search_class = self::get_search_class( $custom_class ); |
1257 | 1257 | |
1258 | - $gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false; |
|
1258 | + $gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false; |
|
1259 | 1259 | |
1260 | 1260 | if ( $this->has_date_field( $search_fields ) ) { |
1261 | 1261 | // enqueue datepicker stuff only if needed! |
@@ -1277,10 +1277,10 @@ discard block |
||
1277 | 1277 | public static function get_search_class( $custom_class = '' ) { |
1278 | 1278 | $gravityview_view = GravityView_View::getInstance(); |
1279 | 1279 | |
1280 | - $search_class = 'gv-search-'.$gravityview_view->search_layout; |
|
1280 | + $search_class = 'gv-search-' . $gravityview_view->search_layout; |
|
1281 | 1281 | |
1282 | - if ( ! empty( $custom_class ) ) { |
|
1283 | - $search_class .= ' '.$custom_class; |
|
1282 | + if ( ! empty( $custom_class ) ) { |
|
1283 | + $search_class .= ' ' . $custom_class; |
|
1284 | 1284 | } |
1285 | 1285 | |
1286 | 1286 | /** |
@@ -1324,9 +1324,9 @@ discard block |
||
1324 | 1324 | |
1325 | 1325 | if ( ! $label ) { |
1326 | 1326 | |
1327 | - $label = isset( $form_field['label'] ) ? $form_field['label'] : ''; |
|
1327 | + $label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : ''; |
|
1328 | 1328 | |
1329 | - switch( $field['field'] ) { |
|
1329 | + switch ( $field[ 'field' ] ) { |
|
1330 | 1330 | case 'search_all': |
1331 | 1331 | $label = __( 'Search Entries:', 'gravityview' ); |
1332 | 1332 | break; |
@@ -1338,10 +1338,10 @@ discard block |
||
1338 | 1338 | break; |
1339 | 1339 | default: |
1340 | 1340 | // If this is a field input, not a field |
1341 | - if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) { |
|
1341 | + if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) { |
|
1342 | 1342 | |
1343 | 1343 | // Get the label for the field in question, which returns an array |
1344 | - $items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) ); |
|
1344 | + $items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) ); |
|
1345 | 1345 | |
1346 | 1346 | // Get the item with the `label` key |
1347 | 1347 | $values = wp_list_pluck( $items, 'label' ); |
@@ -1380,32 +1380,32 @@ discard block |
||
1380 | 1380 | $form = $gravityview_view->getForm(); |
1381 | 1381 | |
1382 | 1382 | // for advanced field ids (eg, first name / last name ) |
1383 | - $name = 'filter_' . str_replace( '.', '_', $field['field'] ); |
|
1383 | + $name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] ); |
|
1384 | 1384 | |
1385 | 1385 | // get searched value from $_GET/$_POST (string or array) |
1386 | 1386 | $value = $this->rgget_or_rgpost( $name ); |
1387 | 1387 | |
1388 | 1388 | // get form field details |
1389 | - $form_field = gravityview_get_field( $form, $field['field'] ); |
|
1389 | + $form_field = gravityview_get_field( $form, $field[ 'field' ] ); |
|
1390 | 1390 | |
1391 | 1391 | $filter = array( |
1392 | - 'key' => $field['field'], |
|
1392 | + 'key' => $field[ 'field' ], |
|
1393 | 1393 | 'name' => $name, |
1394 | 1394 | 'label' => self::get_field_label( $field, $form_field ), |
1395 | - 'input' => $field['input'], |
|
1395 | + 'input' => $field[ 'input' ], |
|
1396 | 1396 | 'value' => $value, |
1397 | - 'type' => $form_field['type'], |
|
1397 | + 'type' => $form_field[ 'type' ], |
|
1398 | 1398 | ); |
1399 | 1399 | |
1400 | 1400 | // collect choices |
1401 | - if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) { |
|
1402 | - $filter['choices'] = gravityview_get_terms_choices(); |
|
1403 | - } elseif ( ! empty( $form_field['choices'] ) ) { |
|
1404 | - $filter['choices'] = $form_field['choices']; |
|
1401 | + if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) { |
|
1402 | + $filter[ 'choices' ] = gravityview_get_terms_choices(); |
|
1403 | + } elseif ( ! empty( $form_field[ 'choices' ] ) ) { |
|
1404 | + $filter[ 'choices' ] = $form_field[ 'choices' ]; |
|
1405 | 1405 | } |
1406 | 1406 | |
1407 | - if ( 'date_range' === $field['input'] && empty( $value ) ) { |
|
1408 | - $filter['value'] = array( 'start' => '', 'end' => '' ); |
|
1407 | + if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) { |
|
1408 | + $filter[ 'value' ] = array( 'start' => '', 'end' => '' ); |
|
1409 | 1409 | } |
1410 | 1410 | |
1411 | 1411 | return $filter; |
@@ -1429,7 +1429,7 @@ discard block |
||
1429 | 1429 | |
1430 | 1430 | $choices = array(); |
1431 | 1431 | foreach ( $users as $user ) { |
1432 | - $choices[] = array( |
|
1432 | + $choices[ ] = array( |
|
1433 | 1433 | 'value' => $user->ID, |
1434 | 1434 | 'text' => $user->display_name, |
1435 | 1435 | ); |
@@ -1449,9 +1449,9 @@ discard block |
||
1449 | 1449 | |
1450 | 1450 | $choices = array(); |
1451 | 1451 | foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) { |
1452 | - $choices[] = array( |
|
1453 | - 'value' => $status['value'], |
|
1454 | - 'text' => $status['label'], |
|
1452 | + $choices[ ] = array( |
|
1453 | + 'value' => $status[ 'value' ], |
|
1454 | + 'text' => $status[ 'label' ], |
|
1455 | 1455 | ); |
1456 | 1456 | } |
1457 | 1457 | |
@@ -1503,7 +1503,7 @@ discard block |
||
1503 | 1503 | */ |
1504 | 1504 | public function add_datepicker_js_dependency( $js_dependencies ) { |
1505 | 1505 | |
1506 | - $js_dependencies[] = 'jquery-ui-datepicker'; |
|
1506 | + $js_dependencies[ ] = 'jquery-ui-datepicker'; |
|
1507 | 1507 | |
1508 | 1508 | return $js_dependencies; |
1509 | 1509 | } |
@@ -1547,7 +1547,7 @@ discard block |
||
1547 | 1547 | 'isRTL' => is_rtl(), |
1548 | 1548 | ), $view_data ); |
1549 | 1549 | |
1550 | - $localizations['datepicker'] = $datepicker_settings; |
|
1550 | + $localizations[ 'datepicker' ] = $datepicker_settings; |
|
1551 | 1551 | |
1552 | 1552 | return $localizations; |
1553 | 1553 | |
@@ -1574,7 +1574,7 @@ discard block |
||
1574 | 1574 | * @return void |
1575 | 1575 | */ |
1576 | 1576 | private function maybe_enqueue_flexibility() { |
1577 | - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
1577 | + if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) { |
|
1578 | 1578 | wp_enqueue_script( 'gv-flexibility' ); |
1579 | 1579 | } |
1580 | 1580 | } |
@@ -1596,7 +1596,7 @@ discard block |
||
1596 | 1596 | add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 ); |
1597 | 1597 | |
1598 | 1598 | $scheme = is_ssl() ? 'https://' : 'http://'; |
1599 | - wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1599 | + wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' ); |
|
1600 | 1600 | |
1601 | 1601 | /** |
1602 | 1602 | * @filter `gravityview_search_datepicker_class` |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public static function is_add_oembed_preview() { |
47 | 47 | /** The preview request is a parse-embed AJAX call without a type set. */ |
48 | - return ( self::is_ajax() && ! empty( $_POST['action'] ) && $_POST['action'] == 'parse-embed' && ! isset( $_POST['type'] ) ); |
|
48 | + return ( self::is_ajax() && ! empty( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'parse-embed' && ! isset( $_POST[ 'type' ] ) ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return boolean |
64 | 64 | */ |
65 | 65 | public static function is_rest() { |
66 | - return ! empty( $GLOBALS['wp']->query_vars['rest_route'] ); |
|
66 | + return ! empty( $GLOBALS[ 'wp' ]->query_vars[ 'rest_route' ] ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -141,15 +141,15 @@ discard block |
||
141 | 141 | $get = $_GET; |
142 | 142 | } |
143 | 143 | |
144 | - unset( $get['mode'] ); |
|
144 | + unset( $get[ 'mode' ] ); |
|
145 | 145 | |
146 | 146 | $get = array_filter( $get, 'gravityview_is_not_empty_string' ); |
147 | 147 | |
148 | - if( $has_field_key = $this->_has_field_key( $get ) ) { |
|
148 | + if ( $has_field_key = $this->_has_field_key( $get ) ) { |
|
149 | 149 | return true; |
150 | 150 | } |
151 | 151 | |
152 | - return isset( $get['gv_search'] ) || isset( $get['gv_start'] ) || isset( $get['gv_end'] ) || isset( $get['gv_by'] ) || isset( $get['gv_id'] ); |
|
152 | + return isset( $get[ 'gv_search' ] ) || isset( $get[ 'gv_start' ] ) || isset( $get[ 'gv_end' ] ) || isset( $get[ 'gv_by' ] ) || isset( $get[ 'gv_id' ] ); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | |
173 | 173 | $meta = array(); |
174 | 174 | foreach ( $fields as $field ) { |
175 | - if( empty( $field->_gf_field_class_name ) ) { |
|
176 | - $meta[] = preg_quote( $field->name ); |
|
175 | + if ( empty( $field->_gf_field_class_name ) ) { |
|
176 | + $meta[ ] = preg_quote( $field->name ); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | 180 | foreach ( $get as $key => $value ) { |
181 | - if ( preg_match('/^filter_(([0-9_]+)|'. implode( '|', $meta ) .')$/sm', $key ) ) { |
|
181 | + if ( preg_match( '/^filter_(([0-9_]+)|' . implode( '|', $meta ) . ')$/sm', $key ) ) { |
|
182 | 182 | $has_field_key = true; |
183 | 183 | break; |
184 | 184 | } |
@@ -128,10 +128,10 @@ |
||
128 | 128 | */ |
129 | 129 | public function is_edit_entry( $form_id = 0 ) { |
130 | 130 | /** |
131 | - * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n |
|
132 | - * The Edit Entry functionality overrides this value. |
|
133 | - * @param boolean $is_edit_entry |
|
134 | - */ |
|
131 | + * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n |
|
132 | + * The Edit Entry functionality overrides this value. |
|
133 | + * @param boolean $is_edit_entry |
|
134 | + */ |
|
135 | 135 | if ( ( $entry = $this->is_entry( $form_id ) ) && apply_filters( 'gravityview_is_edit_entry', false ) ) { |
136 | 136 | return $entry; |
137 | 137 | } |