@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * Try subkeys after split. |
92 | 92 | */ |
93 | 93 | if ( count( $parts = explode( '/', $key, 2 ) ) > 1 ) { |
94 | - return self::get( self::get( $array, $parts[0] ), $parts[1], $default ); |
|
94 | + return self::get( self::get( $array, $parts[ 0 ] ), $parts[ 1 ], $default ); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | return $default; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | public static function gf_query_debug( $query ) { |
146 | 146 | $introspect = $query->_introspect(); |
147 | 147 | return array( |
148 | - 'where' => $query->_where_unwrap( $introspect['where'] ) |
|
148 | + 'where' => $query->_where_unwrap( $introspect[ 'where' ] ) |
|
149 | 149 | ); |
150 | 150 | } |
151 | 151 | } |
@@ -29,11 +29,11 @@ |
||
29 | 29 | $KWS_GF_Change_Lead_Creator = new KWS_GF_Change_Lead_Creator; |
30 | 30 | |
31 | 31 | // Now, no validation is required in the methods; let's hook in. |
32 | - remove_action('admin_init', array( $KWS_GF_Change_Lead_Creator, 'set_screen_mode' ) ); |
|
32 | + remove_action( 'admin_init', array( $KWS_GF_Change_Lead_Creator, 'set_screen_mode' ) ); |
|
33 | 33 | |
34 | - remove_action("gform_entry_info", array( $KWS_GF_Change_Lead_Creator, 'add_select' ), 10 ); |
|
34 | + remove_action( "gform_entry_info", array( $KWS_GF_Change_Lead_Creator, 'add_select' ), 10 ); |
|
35 | 35 | |
36 | - remove_action("gform_after_update_entry", array( $KWS_GF_Change_Lead_Creator, 'update_entry_creator' ), 10 ); |
|
36 | + remove_action( "gform_after_update_entry", array( $KWS_GF_Change_Lead_Creator, 'update_entry_creator' ), 10 ); |
|
37 | 37 | |
38 | 38 | } |
39 | 39 | } |
@@ -10,17 +10,17 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * @since 1.5.1 |
12 | 12 | */ |
13 | - add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
13 | + add_action( 'gform_user_registered', array( $this, 'assign_new_user_to_lead' ), 10, 4 ); |
|
14 | 14 | |
15 | 15 | // ONLY ADMIN FROM HERE ON. |
16 | - if( !is_admin() ) { return; } |
|
16 | + if ( ! is_admin() ) { return; } |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
20 | 20 | * @since 1.7.4 |
21 | 21 | * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
22 | 22 | */ |
23 | - if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
23 | + if ( apply_filters( 'gravityview_disable_change_entry_creator', false ) ) { |
|
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | * Use `init` to fix bbPress warning |
29 | 29 | * @see https://bbpress.trac.wordpress.org/ticket/2309 |
30 | 30 | */ |
31 | - add_action('init', array( $this, 'load'), 100 ); |
|
31 | + add_action( 'init', array( $this, 'load' ), 100 ); |
|
32 | 32 | |
33 | - add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
33 | + add_action( 'plugins_loaded', array( $this, 'prevent_conflicts' ) ); |
|
34 | 34 | |
35 | 35 | } |
36 | 36 | |
@@ -56,20 +56,20 @@ discard block |
||
56 | 56 | $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
57 | 57 | |
58 | 58 | // If filter returns false, do not process |
59 | - if( empty( $assign_to_lead ) ) { |
|
59 | + if ( empty( $assign_to_lead ) ) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
64 | - $result = RGFormsModel::update_entry_property( (int) $entry['id'], 'created_by', (int) $user_id, false, true ); |
|
64 | + $result = RGFormsModel::update_entry_property( (int)$entry[ 'id' ], 'created_by', (int)$user_id, false, true ); |
|
65 | 65 | |
66 | 66 | if ( false === $result ) { |
67 | - $status = __('Error', 'gravityview'); |
|
67 | + $status = __( 'Error', 'gravityview' ); |
|
68 | 68 | global $wpdb; |
69 | 69 | $note = sprintf( '%s: Failed to assign User ID #%d as the entry creator (Last database error: "%s")', $status, $user_id, $wpdb->last_error ); |
70 | 70 | } else { |
71 | - $status = __('Success', 'gravityview'); |
|
72 | - $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
71 | + $status = __( 'Success', 'gravityview' ); |
|
72 | + $note = sprintf( _x( '%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview' ), $status, $user_id ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | gravityview()->log->debug( 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - {note}', array( 'note' => $note ) ); |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | * @since 1.21.5 |
80 | 80 | * @param boolean $disable Disable the Change Entry Creator note. Default: false. |
81 | 81 | */ |
82 | - if( apply_filters('gravityview_disable_change_entry_creator_note', false ) ) { |
|
82 | + if ( apply_filters( 'gravityview_disable_change_entry_creator_note', false ) ) { |
|
83 | 83 | return; |
84 | 84 | } |
85 | 85 | |
86 | - GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
86 | + GravityView_Entry_Notes::add_note( $entry[ 'id' ], -1, 'GravityView', $note, 'gravityview' ); |
|
87 | 87 | |
88 | 88 | } |
89 | 89 | |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | |
96 | 96 | // Plugin that was provided here: |
97 | 97 | // @link https://gravityview.co/support/documentation/201991205/ |
98 | - remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
99 | - remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
98 | + remove_action( "gform_entry_info", 'gravityview_change_entry_creator_form', 10 ); |
|
99 | + remove_action( "gform_after_update_entry", 'gravityview_update_entry_creator', 10 ); |
|
100 | 100 | |
101 | 101 | } |
102 | 102 | |
@@ -107,26 +107,26 @@ discard block |
||
107 | 107 | function load() { |
108 | 108 | |
109 | 109 | // Does GF exist? |
110 | - if( !class_exists('GFCommon') ) { |
|
110 | + if ( ! class_exists( 'GFCommon' ) ) { |
|
111 | 111 | return; |
112 | 112 | } |
113 | 113 | |
114 | 114 | // Can the user edit entries? |
115 | - if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
115 | + if ( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
116 | 116 | return; |
117 | 117 | } |
118 | 118 | |
119 | 119 | // If screen mode isn't set, then we're in the wrong place. |
120 | - if( empty( $_REQUEST['screen_mode'] ) ) { |
|
120 | + if ( empty( $_REQUEST[ 'screen_mode' ] ) ) { |
|
121 | 121 | return; |
122 | 122 | } |
123 | 123 | |
124 | 124 | // Now, no validation is required in the methods; let's hook in. |
125 | - add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
125 | + add_action( 'admin_init', array( &$this, 'set_screen_mode' ) ); |
|
126 | 126 | |
127 | - add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
127 | + add_action( "gform_entry_info", array( &$this, 'add_select' ), 10, 2 ); |
|
128 | 128 | |
129 | - add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
129 | + add_action( "gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2 ); |
|
130 | 130 | |
131 | 131 | } |
132 | 132 | |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | function set_screen_mode() { |
138 | 138 | |
139 | 139 | // If $_GET['screen_mode'] is set to edit, set $_POST value |
140 | - if( \GV\Utils::_GET( 'screen_mode' ) === 'edit' ) { |
|
141 | - $_POST["screen_mode"] = 'edit'; |
|
140 | + if ( \GV\Utils::_GET( 'screen_mode' ) === 'edit' ) { |
|
141 | + $_POST[ "screen_mode" ] = 'edit'; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | } |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | * @param int $entry_id Entry ID |
150 | 150 | * @return void |
151 | 151 | */ |
152 | - function update_entry_creator($form, $entry_id) { |
|
152 | + function update_entry_creator( $form, $entry_id ) { |
|
153 | 153 | global $current_user; |
154 | 154 | |
155 | 155 | // Update the entry |
156 | - $created_by = absint( \GV\Utils::_POST( 'created_by') ); |
|
156 | + $created_by = absint( \GV\Utils::_POST( 'created_by' ) ); |
|
157 | 157 | |
158 | 158 | RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
159 | 159 | |
@@ -161,30 +161,30 @@ discard block |
||
161 | 161 | $originally_created_by = \GV\Utils::_POST( 'originally_created_by' ); |
162 | 162 | |
163 | 163 | // If there's no owner and there didn't used to be, keep going |
164 | - if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
164 | + if ( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
165 | 165 | return; |
166 | 166 | } |
167 | 167 | |
168 | 168 | // If the values have changed |
169 | - if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
169 | + if ( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
170 | 170 | |
171 | - $user_data = get_userdata($current_user->ID); |
|
171 | + $user_data = get_userdata( $current_user->ID ); |
|
172 | 172 | |
173 | - $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
173 | + $user_format = _x( '%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview' ); |
|
174 | 174 | |
175 | - $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
175 | + $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview' ); |
|
176 | 176 | |
177 | - if( !empty( $originally_created_by ) ) { |
|
178 | - $originally_created_by_user_data = get_userdata($originally_created_by); |
|
177 | + if ( ! empty( $originally_created_by ) ) { |
|
178 | + $originally_created_by_user_data = get_userdata( $originally_created_by ); |
|
179 | 179 | $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
180 | 180 | } |
181 | 181 | |
182 | - if( !empty( $created_by ) ) { |
|
183 | - $created_by_user_data = get_userdata($created_by); |
|
182 | + if ( ! empty( $created_by ) ) { |
|
183 | + $created_by_user_data = get_userdata( $created_by ); |
|
184 | 184 | $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
185 | 185 | } |
186 | 186 | |
187 | - GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
187 | + GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __( 'Changed entry creator from %s to %s', 'gravityview' ), $original_name, $created_by_name ), 'note' ); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | } |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | * @param array $entry GF entry array |
196 | 196 | * @return void |
197 | 197 | */ |
198 | - function add_select($form_id, $entry ) { |
|
198 | + function add_select( $form_id, $entry ) { |
|
199 | 199 | |
200 | - if( \GV\Utils::_POST( 'screen_mode' ) !== 'edit' ) { |
|
200 | + if ( \GV\Utils::_POST( 'screen_mode' ) !== 'edit' ) { |
|
201 | 201 | return; |
202 | 202 | } |
203 | 203 | |
@@ -216,23 +216,23 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | $output = '<label for="change_created_by">'; |
219 | - $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
219 | + $output .= esc_html__( 'Change Entry Creator:', 'gravityview' ); |
|
220 | 220 | $output .= '</label>'; |
221 | 221 | |
222 | 222 | // If there are users who are not being shown, show a warning. |
223 | 223 | // TODO: Use AJAX instead of <select> |
224 | 224 | $count_users = count_users(); |
225 | - if( sizeof( $users ) < $count_users['total_users'] ) { |
|
225 | + if ( sizeof( $users ) < $count_users[ 'total_users' ] ) { |
|
226 | 226 | $output .= '<p><i class="dashicons dashicons-warning"></i> ' . sprintf( esc_html__( 'The displayed list of users has been trimmed due to the large number of users. %sLearn how to remove this limit%s.', 'gravityview' ), '<a href="https://docs.gravityview.co/article/251-i-only-see-some-users-in-the-change-entry-creator-dropdown" rel="external">', '</a>' ) . '</p>'; |
227 | 227 | } |
228 | 228 | |
229 | 229 | $output .= '<select name="created_by" id="change_created_by" class="widefat">'; |
230 | - $output .= '<option value="' . selected( $entry['created_by'], '0', false ) . '"> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
231 | - foreach($users as $user) { |
|
232 | - $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
230 | + $output .= '<option value="' . selected( $entry[ 'created_by' ], '0', false ) . '"> — ' . esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview' ) . ' — </option>'; |
|
231 | + foreach ( $users as $user ) { |
|
232 | + $output .= '<option value="' . $user->ID . '"' . selected( $entry[ 'created_by' ], $user->ID, false ) . '>' . esc_attr( $user->display_name . ' (' . $user->user_nicename . ')' ) . '</option>'; |
|
233 | 233 | } |
234 | 234 | $output .= '</select>'; |
235 | - $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
235 | + $output .= '<input name="originally_created_by" value="' . esc_attr( $entry[ 'created_by' ] ) . '" type="hidden" />'; |
|
236 | 236 | |
237 | 237 | unset( $is_created_by_in_users, $created_by_user, $users, $created_by_id, $count_users ); |
238 | 238 |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $supports = array( 'title', 'revisions' ); |
109 | 109 | |
110 | 110 | if ( $is_hierarchical ) { |
111 | - $supports[] = 'page-attributes'; |
|
111 | + $supports[ ] = 'page-attributes'; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -210,11 +210,11 @@ discard block |
||
210 | 210 | $rule = array( sprintf( '%s/([^/]+)/csv/?', $slug ), 'index.php?gravityview=$matches[1]&csv=1', 'top' ); |
211 | 211 | |
212 | 212 | add_filter( 'query_vars', function( $query_vars ) { |
213 | - $query_vars[] = 'csv'; |
|
213 | + $query_vars[ ] = 'csv'; |
|
214 | 214 | return $query_vars; |
215 | 215 | } ); |
216 | 216 | |
217 | - if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[0] ] ) ) { |
|
217 | + if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[ 0 ] ] ) ) { |
|
218 | 218 | call_user_func_array( 'add_rewrite_rule', $rule ); |
219 | 219 | } |
220 | 220 | } |
@@ -283,13 +283,13 @@ discard block |
||
283 | 283 | return $content; |
284 | 284 | } |
285 | 285 | |
286 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
286 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
287 | 287 | |
288 | 288 | /** |
289 | 289 | * Editing a single entry. |
290 | 290 | */ |
291 | 291 | if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) { |
292 | - if ( $entry['status'] != 'active' ) { |
|
292 | + if ( $entry[ 'status' ] != 'active' ) { |
|
293 | 293 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
294 | 294 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
295 | 295 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
303 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
303 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
304 | 304 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
305 | 305 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
306 | 306 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | * Viewing a single entry. |
314 | 314 | */ |
315 | 315 | } else if ( $entry = $request->is_entry( $view->form ? $view->form->ID : 0 ) ) { |
316 | - if ( $entry['status'] != 'active' ) { |
|
316 | + if ( $entry[ 'status' ] != 'active' ) { |
|
317 | 317 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
318 | 318 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
319 | 319 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | } |
325 | 325 | |
326 | 326 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
327 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
327 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
328 | 328 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
329 | 329 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
330 | 330 | } |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field( $join_column ); |
499 | 499 | $join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field( $join_on_column ); |
500 | 500 | |
501 | - $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
501 | + $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | return $joins; |
@@ -540,10 +540,10 @@ discard block |
||
540 | 540 | |
541 | 541 | list( $join, $join_column, $join_on, $join_on_column ) = $meta; |
542 | 542 | |
543 | - $forms_ids [] = GF_Form::by_id( $join_on ); |
|
543 | + $forms_ids [ ] = GF_Form::by_id( $join_on ); |
|
544 | 544 | } |
545 | 545 | |
546 | - return ( !empty( $forms_ids) ) ? $forms_ids : null; |
|
546 | + return ( ! empty( $forms_ids ) ) ? $forms_ids : null; |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | /** |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | if ( ! $view->form ) { |
582 | 582 | gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
583 | 583 | 'view_id' => $view->ID, |
584 | - 'form_id' => $view->_gravityview_form_id ? : 0, |
|
584 | + 'form_id' => $view->_gravityview_form_id ?: 0, |
|
585 | 585 | ) ); |
586 | 586 | } |
587 | 587 | |
@@ -814,34 +814,33 @@ discard block |
||
814 | 814 | * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead |
815 | 815 | */ |
816 | 816 | $parameters = \GravityView_frontend::get_view_entries_parameters( $this->settings->as_atts(), $this->form->ID ); |
817 | - $parameters['context_view_id'] = $this->ID; |
|
817 | + $parameters[ 'context_view_id' ] = $this->ID; |
|
818 | 818 | $parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
819 | 819 | |
820 | 820 | if ( $request instanceof REST\Request ) { |
821 | 821 | $atts = $this->settings->as_atts(); |
822 | 822 | $paging_parameters = wp_parse_args( $request->get_paging(), array( |
823 | - 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
823 | + 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
824 | 824 | ) ); |
825 | - $parameters['paging'] = $paging_parameters['paging']; |
|
825 | + $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
826 | 826 | } |
827 | 827 | |
828 | - $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
829 | - : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 ); |
|
828 | + $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 ); |
|
830 | 829 | |
831 | 830 | /** |
832 | 831 | * Cleanup duplicate field_filter parameters to simplify the query. |
833 | 832 | */ |
834 | 833 | $unique_field_filters = array(); |
835 | - foreach ( $parameters['search_criteria']['field_filters'] as $key => $filter ) { |
|
834 | + foreach ( $parameters[ 'search_criteria' ][ 'field_filters' ] as $key => $filter ) { |
|
836 | 835 | if ( 'mode' === $key ) { |
837 | - $unique_field_filters['mode'] = $filter; |
|
836 | + $unique_field_filters[ 'mode' ] = $filter; |
|
838 | 837 | } else if ( ! in_array( $filter, $unique_field_filters ) ) { |
839 | - $unique_field_filters[] = $filter; |
|
838 | + $unique_field_filters[ ] = $filter; |
|
840 | 839 | } |
841 | 840 | } |
842 | - $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
841 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
843 | 842 | |
844 | - if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
843 | + if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
845 | 844 | gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
846 | 845 | } |
847 | 846 | |
@@ -849,10 +848,10 @@ discard block |
||
849 | 848 | /** |
850 | 849 | * New \GF_Query stuff :) |
851 | 850 | */ |
852 | - $query = new \GF_Query( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] ); |
|
851 | + $query = new \GF_Query( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] ); |
|
853 | 852 | |
854 | - $query->limit( $parameters['paging']['page_size'] ) |
|
855 | - ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
853 | + $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
854 | + ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
856 | 855 | |
857 | 856 | /** |
858 | 857 | * Any joins? |
@@ -894,15 +893,15 @@ discard block |
||
894 | 893 | } ); |
895 | 894 | } else { |
896 | 895 | $entries = $this->form->entries |
897 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
896 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
898 | 897 | ->offset( $this->settings->get( 'offset' ) ) |
899 | - ->limit( $parameters['paging']['page_size'] ) |
|
898 | + ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
900 | 899 | ->page( $page ); |
901 | 900 | |
902 | - if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
901 | + if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
903 | 902 | $field = new \GV\Field(); |
904 | - $field->ID = $parameters['sorting']['key']; |
|
905 | - $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
903 | + $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
904 | + $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
906 | 905 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
907 | 906 | } |
908 | 907 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function register_noconflict( $items ) { |
55 | 55 | |
56 | - $items[] = 'gravityview-admin-installer'; |
|
56 | + $items[ ] = 'gravityview-admin-installer'; |
|
57 | 57 | |
58 | 58 | return $items; |
59 | 59 | } |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
75 | - add_filter( 'plugins_api', function ( $data, $action, $args ) use ( $downloads_data ) { |
|
75 | + add_filter( 'plugins_api', function( $data, $action, $args ) use ( $downloads_data ) { |
|
76 | 76 | foreach ( $downloads_data as $extension ) { |
77 | - if ( empty( $extension['info'] ) || empty( $args->slug ) || $args->slug !== $extension['info']['slug'] ) { |
|
77 | + if ( empty( $extension[ 'info' ] ) || empty( $args->slug ) || $args->slug !== $extension[ 'info' ][ 'slug' ] ) { |
|
78 | 78 | continue; |
79 | 79 | } |
80 | 80 | |
81 | - return (object) array( |
|
82 | - 'slug' => $extension['info']['slug'], |
|
83 | - 'name' => $extension['info']['title'], |
|
84 | - 'version' => $extension['licensing']['version'], |
|
85 | - 'download_link' => $extension['files'][0]['file'], |
|
81 | + return (object)array( |
|
82 | + 'slug' => $extension[ 'info' ][ 'slug' ], |
|
83 | + 'name' => $extension[ 'info' ][ 'title' ], |
|
84 | + 'version' => $extension[ 'licensing' ][ 'version' ], |
|
85 | + 'download_link' => $extension[ 'files' ][ 0 ][ 'file' ], |
|
86 | 86 | ); |
87 | 87 | } |
88 | 88 | |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | |
145 | 145 | foreach ( $all_plugins as $path => $plugin ) { |
146 | 146 | |
147 | - if ( empty( $plugin['TextDomain'] ) ) { |
|
147 | + if ( empty( $plugin[ 'TextDomain' ] ) ) { |
|
148 | 148 | continue; |
149 | 149 | } |
150 | 150 | |
151 | - $wp_plugins[ $plugin['TextDomain'] ] = array( |
|
151 | + $wp_plugins[ $plugin[ 'TextDomain' ] ] = array( |
|
152 | 152 | 'path' => $path, |
153 | - 'version' => $plugin['Version'], |
|
153 | + 'version' => $plugin[ 'Version' ], |
|
154 | 154 | 'activated' => is_plugin_active( $path ) |
155 | 155 | ); |
156 | 156 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | return $downloads_data; |
209 | 209 | } |
210 | 210 | |
211 | - if( \GV\Plugin::is_network_activated() ) { |
|
211 | + if ( \GV\Plugin::is_network_activated() ) { |
|
212 | 212 | $home_url = network_home_url(); |
213 | 213 | } else { |
214 | 214 | $home_url = home_url(); |
@@ -236,13 +236,13 @@ discard block |
||
236 | 236 | |
237 | 237 | $downloads_data = json_decode( wp_remote_retrieve_body( $response ), true ); |
238 | 238 | |
239 | - if ( empty( $downloads_data['products'] ) ) { |
|
239 | + if ( empty( $downloads_data[ 'products' ] ) ) { |
|
240 | 240 | return array(); |
241 | 241 | } |
242 | 242 | |
243 | - $this->set_downloads_data( $downloads_data['products'] ); |
|
243 | + $this->set_downloads_data( $downloads_data[ 'products' ] ); |
|
244 | 244 | |
245 | - return $downloads_data['products']; |
|
245 | + return $downloads_data[ 'products' ]; |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | |
316 | 316 | foreach ( $downloads_data as $extension ) { |
317 | 317 | |
318 | - if ( empty( $extension['info'] ) ) { |
|
318 | + if ( empty( $extension[ 'info' ] ) ) { |
|
319 | 319 | continue; |
320 | 320 | } |
321 | 321 | |
@@ -344,29 +344,29 @@ discard block |
||
344 | 344 | |
345 | 345 | $details = $this->get_download_display_details( $download, $wp_plugins ); |
346 | 346 | |
347 | - $download_info = $details['download_info']; |
|
347 | + $download_info = $details[ 'download_info' ]; |
|
348 | 348 | |
349 | 349 | ?> |
350 | - <div class="item <?php echo esc_attr( $details['item_class'] ); ?>"> |
|
350 | + <div class="item <?php echo esc_attr( $details[ 'item_class' ] ); ?>"> |
|
351 | 351 | <div class="addon-inner"> |
352 | - <a href="<?php echo esc_url( $download_info['link'] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info['thumbnail'] ); ?>" alt="" /></a> |
|
353 | - <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info['title'] ) ); ?></h3> |
|
352 | + <a href="<?php echo esc_url( $download_info[ 'link' ] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info[ 'thumbnail' ] ); ?>" alt="" /></a> |
|
353 | + <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info[ 'title' ] ) ); ?></h3> |
|
354 | 354 | <div> |
355 | - <?php if( ! empty( $details['status_label'] ) ) { ?> |
|
356 | - <div class="status <?php echo esc_attr( $details['status'] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details['status_label'] ) ); ?>"> |
|
357 | - <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details['status_label'] ); ?></span> |
|
355 | + <?php if ( ! empty( $details[ 'status_label' ] ) ) { ?> |
|
356 | + <div class="status <?php echo esc_attr( $details[ 'status' ] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details[ 'status_label' ] ) ); ?>"> |
|
357 | + <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details[ 'status_label' ] ); ?></span> |
|
358 | 358 | </div> |
359 | 359 | <?php } ?> |
360 | 360 | |
361 | - <a data-status="<?php echo esc_attr( $details['status'] ); ?>" data-plugin-path="<?php echo esc_attr( $details['plugin_path'] ); ?>" href="<?php echo esc_url( $details['href'] ); ?>" class="button <?php echo esc_attr( $details['button_class'] ); ?>" title="<?php echo esc_attr( $details['button_title'] ); ?>"> |
|
362 | - <span class="title"><?php echo esc_html( $details['button_label'] ); ?></span> |
|
363 | - <?php if( $details['spinner'] ) { ?><span class="spinner"></span><?php } ?> |
|
361 | + <a data-status="<?php echo esc_attr( $details[ 'status' ] ); ?>" data-plugin-path="<?php echo esc_attr( $details[ 'plugin_path' ] ); ?>" href="<?php echo esc_url( $details[ 'href' ] ); ?>" class="button <?php echo esc_attr( $details[ 'button_class' ] ); ?>" title="<?php echo esc_attr( $details[ 'button_title' ] ); ?>"> |
|
362 | + <span class="title"><?php echo esc_html( $details[ 'button_label' ] ); ?></span> |
|
363 | + <?php if ( $details[ 'spinner' ] ) { ?><span class="spinner"></span><?php } ?> |
|
364 | 364 | </a> |
365 | 365 | </div> |
366 | 366 | |
367 | 367 | <div class="addon-excerpt"><?php |
368 | 368 | |
369 | - $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] ); |
|
369 | + $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info[ 'excerpt' ] ); |
|
370 | 370 | |
371 | 371 | // Allow some pure HTML tags, but remove everything else from the excerpt. |
372 | 372 | $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' ); |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | */ |
407 | 407 | private function get_download_display_details( $download, $wp_plugins ) { |
408 | 408 | |
409 | - $download_info = wp_parse_args( (array) $download['info'], array( |
|
409 | + $download_info = wp_parse_args( (array)$download[ 'info' ], array( |
|
410 | 410 | 'thumbnail' => '', |
411 | 411 | 'title' => '', |
412 | 412 | 'textdomain' => '', |
@@ -418,9 +418,9 @@ discard block |
||
418 | 418 | 'installer_excerpt' => null, // May not be defined |
419 | 419 | ) ); |
420 | 420 | |
421 | - $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info['textdomain'], false ); |
|
421 | + $wp_plugin = \GV\Utils::get( $wp_plugins, $download_info[ 'textdomain' ], false ); |
|
422 | 422 | |
423 | - $has_access = ! empty( $download['files'] ); |
|
423 | + $has_access = ! empty( $download[ 'files' ] ); |
|
424 | 424 | $spinner = true; |
425 | 425 | $href = $plugin_path = '#'; |
426 | 426 | $status = $item_class = $button_title = $button_class = ''; |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $required_license = $galactic_only ? __( 'All Access', 'gravityview' ) : __( 'Core + Extensions', 'gravityview' ); |
431 | 431 | |
432 | 432 | // The license is not active - no matter what level, this should not work |
433 | - if( ! $is_active && empty( $base_price ) ) { |
|
433 | + if ( ! $is_active && empty( $base_price ) ) { |
|
434 | 434 | $spinner = false; |
435 | 435 | $status_label = ''; |
436 | 436 | $button_class = 'disabled disabled-license'; |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | $status_label = ''; |
444 | 444 | $button_label = sprintf( __( 'Purchase Now for %s', 'gravityview' ), '$' . $base_price ); |
445 | 445 | $button_class = 'button-primary button-large'; |
446 | - $href = $download_info['link']; |
|
446 | + $href = $download_info[ 'link' ]; |
|
447 | 447 | $item_class = 'featured'; |
448 | 448 | } |
449 | 449 | |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | $href = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license; |
457 | 457 | } |
458 | 458 | |
459 | - elseif ( ! empty( $download_info['coming_soon'] ) ) { |
|
459 | + elseif ( ! empty( $download_info[ 'coming_soon' ] ) ) { |
|
460 | 460 | $spinner = false; |
461 | 461 | $status = 'notinstalled'; |
462 | 462 | $status_label = __( 'Coming Soon', 'gravityview' ); |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | $href = add_query_arg( |
472 | 472 | array( |
473 | 473 | 'action' => 'install-plugin', |
474 | - 'plugin' => $download_info['slug'], |
|
475 | - '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info['slug'] ), |
|
474 | + 'plugin' => $download_info[ 'slug' ], |
|
475 | + '_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info[ 'slug' ] ), |
|
476 | 476 | ), |
477 | 477 | self_admin_url( 'update.php' ) |
478 | 478 | ); |
@@ -484,25 +484,25 @@ discard block |
||
484 | 484 | } |
485 | 485 | |
486 | 486 | // Access and the plugin is installed but not active |
487 | - elseif ( false === $wp_plugin['activated'] ) { |
|
487 | + elseif ( false === $wp_plugin[ 'activated' ] ) { |
|
488 | 488 | $status = 'inactive'; |
489 | 489 | $status_label = __( 'Inactive', 'gravityview' ); |
490 | 490 | $button_label = __( 'Activate', 'gravityview' ); |
491 | - $plugin_path = $wp_plugin['path']; |
|
491 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
492 | 492 | |
493 | 493 | } |
494 | 494 | |
495 | 495 | // Access and the plugin is installed and active |
496 | 496 | else { |
497 | 497 | |
498 | - $plugin_path = $wp_plugin['path']; |
|
498 | + $plugin_path = $wp_plugin[ 'path' ]; |
|
499 | 499 | $status = 'active'; |
500 | 500 | $status_label = __( 'Active', 'gravityview' ); |
501 | 501 | $button_label = __( 'Deactivate', 'gravityview' ); |
502 | 502 | |
503 | 503 | } |
504 | 504 | |
505 | - return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
505 | + return compact( 'download_info', 'plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' ); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -517,11 +517,11 @@ discard block |
||
517 | 517 | $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 ); |
518 | 518 | $base_price = \GFCommon::to_number( $base_price ); |
519 | 519 | |
520 | - unset( $download['pricing']['amount'] ); |
|
520 | + unset( $download[ 'pricing' ][ 'amount' ] ); |
|
521 | 521 | |
522 | 522 | // Price options array, not single price |
523 | - if ( ! $base_price && ! empty( $download['pricing'] ) ) { |
|
524 | - $base_price = array_shift( $download['pricing'] ); |
|
523 | + if ( ! $base_price && ! empty( $download[ 'pricing' ] ) ) { |
|
524 | + $base_price = array_shift( $download[ 'pricing' ] ); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | return floatval( $base_price ); |
@@ -535,13 +535,13 @@ discard block |
||
535 | 535 | public function activate_download() { |
536 | 536 | $data = \GV\Utils::_POST( 'data', array() ); |
537 | 537 | |
538 | - if ( empty( $data['path'] ) ) { |
|
538 | + if ( empty( $data[ 'path' ] ) ) { |
|
539 | 539 | return; |
540 | 540 | } |
541 | 541 | |
542 | - $result = activate_plugin( $data['path'] ); |
|
542 | + $result = activate_plugin( $data[ 'path' ] ); |
|
543 | 543 | |
544 | - if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) { |
|
544 | + if ( is_wp_error( $result ) || ! is_plugin_active( $data[ 'path' ] ) ) { |
|
545 | 545 | wp_send_json_error( array( |
546 | 546 | 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() ) |
547 | 547 | ) ); |
@@ -558,13 +558,13 @@ discard block |
||
558 | 558 | public function deactivate_download() { |
559 | 559 | $data = \GV\Utils::_POST( 'data', array() ); |
560 | 560 | |
561 | - if ( empty( $data['path'] ) ) { |
|
561 | + if ( empty( $data[ 'path' ] ) ) { |
|
562 | 562 | return; |
563 | 563 | } |
564 | 564 | |
565 | - deactivate_plugins( $data['path'] ); |
|
565 | + deactivate_plugins( $data[ 'path' ] ); |
|
566 | 566 | |
567 | - if( is_plugin_active( $data['path'] ) ) { |
|
567 | + if ( is_plugin_active( $data[ 'path' ] ) ) { |
|
568 | 568 | wp_send_json_error( array( |
569 | 569 | 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) ) |
570 | 570 | ) ); |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | public static function is_value_match( $field_value, $target_value, $operation = 'is', $source_field = null, $rule = null, $form = null ) { |
41 | 41 | |
42 | 42 | if ( in_array( $source_field, array( 'date_created', 'date_updated', 'payment_date' ), true ) ) { |
43 | - $field_value = is_int( $field_value )? $field_value : strtotime( $field_value ); |
|
44 | - $target_value = is_int( $target_value )? $target_value : strtotime( $target_value ); |
|
43 | + $field_value = is_int( $field_value ) ? $field_value : strtotime( $field_value ); |
|
44 | + $target_value = is_int( $target_value ) ? $target_value : strtotime( $target_value ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | if ( $source_field instanceof GF_Field && $source_field->type == 'date' ) { |
48 | - $field_value = is_int( $field_value )? $field_value : strtotime( $field_value ); |
|
49 | - $target_value = is_int( $target_value )? $target_value : strtotime( $target_value ); |
|
48 | + $field_value = is_int( $field_value ) ? $field_value : strtotime( $field_value ); |
|
49 | + $target_value = is_int( $target_value ) ? $target_value : strtotime( $target_value ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | if ( in_array( $_operation = str_replace( ' ', '_', trim( $operation ) ), array( 'in', 'not_in' ) ) ) { |
53 | - return GVCommon::matches_operation( (array) $field_value, (array) $target_value, $_operation ); |
|
53 | + return GVCommon::matches_operation( (array)$field_value, (array)$target_value, $_operation ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | return parent::is_value_match( $field_value, $target_value, $operation, $source_field, $rule, $form ); |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | |
75 | 75 | $post_data = self::get_post_fields( $form, $entry ); |
76 | 76 | |
77 | - $media = get_attached_media( 'image', $entry['post_id'] ); |
|
77 | + $media = get_attached_media( 'image', $entry[ 'post_id' ] ); |
|
78 | 78 | |
79 | 79 | $post_images = array(); |
80 | 80 | |
81 | 81 | foreach ( $media as $media_item ) { |
82 | - foreach( (array) $post_data['images'] as $post_data_item ) { |
|
83 | - if( |
|
82 | + foreach ( (array)$post_data[ 'images' ] as $post_data_item ) { |
|
83 | + if ( |
|
84 | 84 | \GV\Utils::get( $post_data_item, 'title' ) === $media_item->post_title && |
85 | 85 | \GV\Utils::get( $post_data_item, 'description' ) === $media_item->post_content && |
86 | 86 | \GV\Utils::get( $post_data_item, 'caption' ) === $media_item->post_excerpt |
87 | 87 | ) { |
88 | - $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
88 | + $post_images[ "{$post_data_item[ 'field_id' ]}" ] = $media_item->ID; |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * If the method changes to public, use Gravity Forms' method |
114 | 114 | * @todo: If/when the method is public, remove the unneeded copied code. |
115 | 115 | */ |
116 | - if( $reflection->isPublic() ) { |
|
116 | + if ( $reflection->isPublic() ) { |
|
117 | 117 | return parent::get_post_fields( $form, $entry ); |
118 | 118 | } |
119 | 119 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * If the method changes to public, use Gravity Forms' method |
141 | 141 | * @todo: If/when the method is public, remove the unneeded copied code. |
142 | 142 | */ |
143 | - if( $reflection->isPublic() ) { |
|
143 | + if ( $reflection->isPublic() ) { |
|
144 | 144 | return parent::copy_post_image( $url, $post_id ); |
145 | 145 | } |
146 | 146 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * If the method changes to public, use Gravity Forms' method |
176 | 176 | * @todo: If/when the method is public, remove the unneeded copied code. |
177 | 177 | */ |
178 | - if( $reflection->isPublic() ) { |
|
178 | + if ( $reflection->isPublic() ) { |
|
179 | 179 | return parent::media_handle_upload( $url, $post_id, $post_data ); |
180 | 180 | } |
181 | 181 |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | $form = $gravityview_view->getForm(); |
33 | 33 | |
34 | - if ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && ! empty( $GLOBALS['GravityView_API_field_label_override'] ) ) { |
|
34 | + if ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && ! empty( $GLOBALS[ 'GravityView_API_field_label_override' ] ) ) { |
|
35 | 35 | /** Allow to fall through for back compatibility testing purposes. */ |
36 | 36 | } else { |
37 | 37 | return \GV\Mocks\GravityView_API_field_label( $form, $field, $entry, $force_show_label ); |
@@ -39,29 +39,29 @@ discard block |
||
39 | 39 | |
40 | 40 | $label = ''; |
41 | 41 | |
42 | - if( !empty( $field['show_label'] ) || $force_show_label ) { |
|
42 | + if ( ! empty( $field[ 'show_label' ] ) || $force_show_label ) { |
|
43 | 43 | |
44 | - $label = $field['label']; |
|
44 | + $label = $field[ 'label' ]; |
|
45 | 45 | |
46 | 46 | // Support Gravity Forms 1.9+ |
47 | - if( class_exists( 'GF_Field' ) ) { |
|
47 | + if ( class_exists( 'GF_Field' ) ) { |
|
48 | 48 | |
49 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
49 | + $field_object = RGFormsModel::get_field( $form, $field[ 'id' ] ); |
|
50 | 50 | |
51 | - if( $field_object ) { |
|
51 | + if ( $field_object ) { |
|
52 | 52 | |
53 | - $input = GFFormsModel::get_input( $field_object, $field['id'] ); |
|
53 | + $input = GFFormsModel::get_input( $field_object, $field[ 'id' ] ); |
|
54 | 54 | |
55 | 55 | // This is a complex field, with labels on a per-input basis |
56 | - if( $input ) { |
|
56 | + if ( $input ) { |
|
57 | 57 | |
58 | 58 | // Does the input have a custom label on a per-input basis? Otherwise, default label. |
59 | - $label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label']; |
|
59 | + $label = ! empty( $input[ 'customLabel' ] ) ? $input[ 'customLabel' ] : $input[ 'label' ]; |
|
60 | 60 | |
61 | 61 | } else { |
62 | 62 | |
63 | 63 | // This is a field with one label |
64 | - $label = $field_object->get_field_label( true, $field['label'] ); |
|
64 | + $label = $field_object->get_field_label( true, $field[ 'label' ] ); |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | // Use Gravity Forms label by default, but if a custom label is defined in GV, use it. |
73 | - if ( !empty( $field['custom_label'] ) ) { |
|
73 | + if ( ! empty( $field[ 'custom_label' ] ) ) { |
|
74 | 74 | |
75 | - $label = self::replace_variables( $field['custom_label'], $form, $entry ); |
|
75 | + $label = self::replace_variables( $field[ 'custom_label' ], $form, $entry ); |
|
76 | 76 | |
77 | 77 | } |
78 | 78 | |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | |
135 | 135 | $width = NULL; |
136 | 136 | |
137 | - if( !empty( $field['width'] ) ) { |
|
138 | - $width = absint( $field['width'] ); |
|
137 | + if ( ! empty( $field[ 'width' ] ) ) { |
|
138 | + $width = absint( $field[ 'width' ] ); |
|
139 | 139 | |
140 | 140 | // If using percentages, limit to 100% |
141 | - if( '%d%%' === $format && $width > 100 ) { |
|
141 | + if ( '%d%%' === $format && $width > 100 ) { |
|
142 | 142 | $width = 100; |
143 | 143 | } |
144 | 144 | |
@@ -159,42 +159,42 @@ discard block |
||
159 | 159 | public static function field_class( $field, $form = NULL, $entry = NULL ) { |
160 | 160 | $classes = array(); |
161 | 161 | |
162 | - if( !empty( $field['custom_class'] ) ) { |
|
162 | + if ( ! empty( $field[ 'custom_class' ] ) ) { |
|
163 | 163 | |
164 | - $custom_class = $field['custom_class']; |
|
164 | + $custom_class = $field[ 'custom_class' ]; |
|
165 | 165 | |
166 | - if( !empty( $entry ) ) { |
|
166 | + if ( ! empty( $entry ) ) { |
|
167 | 167 | |
168 | 168 | // We want the merge tag to be formatted as a class. The merge tag may be |
169 | 169 | // replaced by a multiple-word value that should be output as a single class. |
170 | 170 | // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
171 | - add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
171 | + add_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
172 | 172 | |
173 | - $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
173 | + $custom_class = self::replace_variables( $custom_class, $form, $entry ); |
|
174 | 174 | |
175 | 175 | // And then we want life to return to normal |
176 | - remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
176 | + remove_filter( 'gform_merge_tag_filter', 'sanitize_html_class' ); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | // And now we want the spaces to be handled nicely. |
180 | - $classes[] = gravityview_sanitize_html_class( $custom_class ); |
|
180 | + $classes[ ] = gravityview_sanitize_html_class( $custom_class ); |
|
181 | 181 | |
182 | 182 | } |
183 | 183 | |
184 | - if(!empty($field['id'])) { |
|
185 | - if( !empty( $form ) && !empty( $form['id'] ) ) { |
|
186 | - $form_id = '-'.$form['id']; |
|
184 | + if ( ! empty( $field[ 'id' ] ) ) { |
|
185 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
186 | + $form_id = '-' . $form[ 'id' ]; |
|
187 | 187 | } else { |
188 | 188 | // @deprecated path. Form should always be given. |
189 | 189 | gravityview()->log->warning( 'GravityView_View::getInstance() legacy API called' ); |
190 | 190 | $gravityview_view = GravityView_View::getInstance(); |
191 | - $form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : ''; |
|
191 | + $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
|
192 | 192 | } |
193 | 193 | |
194 | - $classes[] = 'gv-field'.$form_id.'-'.$field['id']; |
|
194 | + $classes[ ] = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
195 | 195 | } |
196 | 196 | |
197 | - return esc_attr(implode(' ', $classes)); |
|
197 | + return esc_attr( implode( ' ', $classes ) ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -210,11 +210,11 @@ discard block |
||
210 | 210 | * @return string Sanitized unique HTML `id` attribute for the field |
211 | 211 | */ |
212 | 212 | public static function field_html_attr_id( $field, $form = array(), $entry = array() ) { |
213 | - $id = $field['id']; |
|
213 | + $id = $field[ 'id' ]; |
|
214 | 214 | |
215 | 215 | if ( ! empty( $id ) ) { |
216 | - if ( ! empty( $form ) && ! empty( $form['id'] ) ) { |
|
217 | - $form_id = '-' . $form['id']; |
|
216 | + if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) { |
|
217 | + $form_id = '-' . $form[ 'id' ]; |
|
218 | 218 | } else { |
219 | 219 | // @deprecated path. Form should always be given. |
220 | 220 | gravityview()->log->warning( 'GravityView_View::getInstance() legacy API called' ); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
223 | 223 | } |
224 | 224 | |
225 | - $id = 'gv-field' . $form_id . '-' . $field['id']; |
|
225 | + $id = 'gv-field' . $form_id . '-' . $field[ 'id' ]; |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | return esc_attr( $id ); |
@@ -262,14 +262,14 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array(), $base_id = null ) { |
264 | 264 | |
265 | - if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) { |
|
265 | + if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry[ 'id' ] ) ) { |
|
266 | 266 | gravityview()->log->debug( 'Entry not defined; returning null', array( 'data' => $entry ) ); |
267 | 267 | return NULL; |
268 | 268 | } |
269 | 269 | |
270 | 270 | $href = self::entry_link( $entry, $base_id ); |
271 | 271 | |
272 | - if( '' === $href ) { |
|
272 | + if ( '' === $href ) { |
|
273 | 273 | return NULL; |
274 | 274 | } |
275 | 275 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | } else { |
307 | 307 | $gravityview_view = GravityView_View::getInstance(); |
308 | 308 | |
309 | - if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
309 | + if ( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
310 | 310 | $is_search = true; |
311 | 311 | } |
312 | 312 | } |
@@ -403,9 +403,9 @@ discard block |
||
403 | 403 | |
404 | 404 | // If we've saved the permalink in memory, use it |
405 | 405 | // @since 1.3 |
406 | - $link = wp_cache_get( 'gv_directory_link_'.$post_id ); |
|
406 | + $link = wp_cache_get( 'gv_directory_link_' . $post_id ); |
|
407 | 407 | |
408 | - if ( (int) $post_id === (int) get_option( 'page_on_front' ) ) { |
|
408 | + if ( (int)$post_id === (int)get_option( 'page_on_front' ) ) { |
|
409 | 409 | $link = home_url(); |
410 | 410 | } |
411 | 411 | |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | |
415 | 415 | // If not yet saved, cache the permalink. |
416 | 416 | // @since 1.3 |
417 | - wp_cache_set( 'gv_directory_link_'.$post_id, $link ); |
|
417 | + wp_cache_set( 'gv_directory_link_' . $post_id, $link ); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | // Deal with returning to proper pagination for embedded views |
@@ -422,13 +422,13 @@ discard block |
||
422 | 422 | |
423 | 423 | $args = array(); |
424 | 424 | |
425 | - if( $pagenum = \GV\Utils::_GET( 'pagenum' ) ) { |
|
426 | - $args['pagenum'] = intval( $pagenum ); |
|
425 | + if ( $pagenum = \GV\Utils::_GET( 'pagenum' ) ) { |
|
426 | + $args[ 'pagenum' ] = intval( $pagenum ); |
|
427 | 427 | } |
428 | 428 | |
429 | - if( $sort = \GV\Utils::_GET( 'sort' ) ) { |
|
430 | - $args['sort'] = $sort; |
|
431 | - $args['dir'] = \GV\Utils::_GET( 'dir' ); |
|
429 | + if ( $sort = \GV\Utils::_GET( 'sort' ) ) { |
|
430 | + $args[ 'sort' ] = $sort; |
|
431 | + $args[ 'dir' ] = \GV\Utils::_GET( 'dir' ); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | $link = add_query_arg( $args, $link ); |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | private static function get_custom_entry_slug( $id, $entry = array() ) { |
466 | 466 | |
467 | 467 | // Generate an unique hash to use as the default value |
468 | - $slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 ); |
|
468 | + $slug = substr( wp_hash( $id, 'gravityview' . $id ), 0, 8 ); |
|
469 | 469 | |
470 | 470 | /** |
471 | 471 | * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}` |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | $slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry ); |
477 | 477 | |
478 | 478 | // Make sure we have something - use the original ID as backup. |
479 | - if( empty( $slug ) ) { |
|
479 | + if ( empty( $slug ) ) { |
|
480 | 480 | $slug = $id; |
481 | 481 | } |
482 | 482 | |
@@ -570,15 +570,15 @@ discard block |
||
570 | 570 | * @param boolean $custom Should we process the custom entry slug? |
571 | 571 | */ |
572 | 572 | $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
573 | - if( $custom ) { |
|
573 | + if ( $custom ) { |
|
574 | 574 | // create the gravityview_unique_id and save it |
575 | 575 | |
576 | 576 | // Get the entry hash |
577 | - $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
577 | + $hash = self::get_custom_entry_slug( $entry[ 'id' ], $entry ); |
|
578 | 578 | |
579 | - gravityview()->log->debug( 'Setting hash for entry {entry_id}: {hash}', array( 'entry_id' => $entry['id'], 'hash' => $hash ) ); |
|
579 | + gravityview()->log->debug( 'Setting hash for entry {entry_id}: {hash}', array( 'entry_id' => $entry[ 'id' ], 'hash' => $hash ) ); |
|
580 | 580 | |
581 | - gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash, \GV\Utils::get( $entry, 'form_id' ) ); |
|
581 | + gform_update_meta( $entry[ 'id' ], 'gravityview_unique_id', $hash, \GV\Utils::get( $entry, 'form_id' ) ); |
|
582 | 582 | |
583 | 583 | } |
584 | 584 | } |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | |
598 | 598 | if ( ! empty( $entry ) && ! is_array( $entry ) ) { |
599 | 599 | $entry = GVCommon::get_entry( $entry ); |
600 | - } else if( empty( $entry ) ) { |
|
600 | + } else if ( empty( $entry ) ) { |
|
601 | 601 | // @deprecated path |
602 | 602 | $entry = GravityView_frontend::getInstance()->getEntry(); |
603 | 603 | } |
@@ -617,9 +617,9 @@ discard block |
||
617 | 617 | |
618 | 618 | $query_arg_name = \GV\Entry::get_endpoint_name(); |
619 | 619 | |
620 | - $entry_slug = self::get_entry_slug( $entry['id'], $entry ); |
|
620 | + $entry_slug = self::get_entry_slug( $entry[ 'id' ], $entry ); |
|
621 | 621 | |
622 | - if ( get_option('permalink_structure') && !is_preview() ) { |
|
622 | + if ( get_option( 'permalink_structure' ) && ! is_preview() ) { |
|
623 | 623 | |
624 | 624 | $args = array(); |
625 | 625 | |
@@ -629,9 +629,9 @@ discard block |
||
629 | 629 | */ |
630 | 630 | $link_parts = explode( '?', $directory_link ); |
631 | 631 | |
632 | - $query = !empty( $link_parts[1] ) ? '?'.$link_parts[1] : ''; |
|
632 | + $query = ! empty( $link_parts[ 1 ] ) ? '?' . $link_parts[ 1 ] : ''; |
|
633 | 633 | |
634 | - $directory_link = trailingslashit( $link_parts[0] ) . $query_arg_name . '/'. $entry_slug .'/' . $query; |
|
634 | + $directory_link = trailingslashit( $link_parts[ 0 ] ) . $query_arg_name . '/' . $entry_slug . '/' . $query; |
|
635 | 635 | |
636 | 636 | } else { |
637 | 637 | |
@@ -643,21 +643,21 @@ discard block |
||
643 | 643 | */ |
644 | 644 | if ( $add_directory_args ) { |
645 | 645 | |
646 | - if ( ! empty( $_GET['pagenum'] ) ) { |
|
647 | - $args['pagenum'] = intval( $_GET['pagenum'] ); |
|
646 | + if ( ! empty( $_GET[ 'pagenum' ] ) ) { |
|
647 | + $args[ 'pagenum' ] = intval( $_GET[ 'pagenum' ] ); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | /** |
651 | 651 | * @since 1.7 |
652 | 652 | */ |
653 | 653 | if ( $sort = \GV\Utils::_GET( 'sort' ) ) { |
654 | - $args['sort'] = $sort; |
|
655 | - $args['dir'] = \GV\Utils::_GET( 'dir' ); |
|
654 | + $args[ 'sort' ] = $sort; |
|
655 | + $args[ 'dir' ] = \GV\Utils::_GET( 'dir' ); |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | } |
659 | 659 | |
660 | - if( $post_id ) { |
|
660 | + if ( $post_id ) { |
|
661 | 661 | $passed_post = get_post( $post_id ); |
662 | 662 | $views = \GV\View_Collection::from_post( $passed_post ); |
663 | 663 | $has_multiple_views = $views->count() > 1; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | } |
667 | 667 | |
668 | 668 | if ( $has_multiple_views ) { |
669 | - $args['gvid'] = gravityview_get_view_id(); |
|
669 | + $args[ 'gvid' ] = gravityview_get_view_id(); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | return add_query_arg( $args, $directory_link ); |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | } |
688 | 688 | |
689 | 689 | function gv_class( $field, $form = NULL, $entry = array() ) { |
690 | - return GravityView_API::field_class( $field, $form, $entry ); |
|
690 | + return GravityView_API::field_class( $field, $form, $entry ); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | /** |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | $view_id = 0; |
711 | 711 | if ( $context->view ) { |
712 | 712 | $view_id = $context->view->ID; |
713 | - if( $context->view->settings->get( 'hide_until_searched' ) ) { |
|
713 | + if ( $context->view->settings->get( 'hide_until_searched' ) ) { |
|
714 | 714 | $hide_until_searched = ( empty( $context->entry ) && ! $context->request->is_search() ); |
715 | 715 | } |
716 | 716 | } |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | $default_css_class .= ' gv-container-no-results'; |
739 | 739 | } |
740 | 740 | |
741 | - $css_class = trim( $passed_css_class . ' '. $default_css_class ); |
|
741 | + $css_class = trim( $passed_css_class . ' ' . $default_css_class ); |
|
742 | 742 | |
743 | 743 | /** |
744 | 744 | * @filter `gravityview/render/container/class` Modify the CSS class to be added to the wrapper <div> of a View |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | |
766 | 766 | $value = GravityView_API::field_value( $entry, $field ); |
767 | 767 | |
768 | - if( $value === '' ) { |
|
768 | + if ( $value === '' ) { |
|
769 | 769 | /** |
770 | 770 | * @filter `gravityview_empty_value` What to display when a field is empty |
771 | 771 | * @param string $value (empty string) |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | */ |
879 | 879 | function gravityview_get_field_value( $entry, $field_id, $display_value ) { |
880 | 880 | |
881 | - if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
881 | + if ( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
882 | 882 | |
883 | 883 | // For the complete field value as generated by Gravity Forms |
884 | 884 | return $display_value; |
@@ -912,16 +912,16 @@ discard block |
||
912 | 912 | $terms = explode( ', ', $value ); |
913 | 913 | } |
914 | 914 | |
915 | - foreach ($terms as $term_name ) { |
|
915 | + foreach ( $terms as $term_name ) { |
|
916 | 916 | |
917 | 917 | // If we're processing a category, |
918 | - if( $taxonomy === 'category' ) { |
|
918 | + if ( $taxonomy === 'category' ) { |
|
919 | 919 | |
920 | 920 | // Use rgexplode to prevent errors if : doesn't exist |
921 | 921 | list( $term_name, $term_id ) = rgexplode( ':', $term_name, 2 ); |
922 | 922 | |
923 | 923 | // The explode was succesful; we have the category ID |
924 | - if( !empty( $term_id )) { |
|
924 | + if ( ! empty( $term_id ) ) { |
|
925 | 925 | $term = get_term_by( 'id', $term_id, $taxonomy ); |
926 | 926 | } else { |
927 | 927 | // We have to fall back to the name |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | } |
935 | 935 | |
936 | 936 | // There's still a tag/category here. |
937 | - if( $term ) { |
|
937 | + if ( $term ) { |
|
938 | 938 | |
939 | 939 | $term_link = get_term_link( $term, $taxonomy ); |
940 | 940 | |
@@ -943,11 +943,11 @@ discard block |
||
943 | 943 | continue; |
944 | 944 | } |
945 | 945 | |
946 | - $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
946 | + $output[ ] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
947 | 947 | } |
948 | 948 | } |
949 | 949 | |
950 | - return implode(', ', $output ); |
|
950 | + return implode( ', ', $output ); |
|
951 | 951 | } |
952 | 952 | |
953 | 953 | /** |
@@ -961,8 +961,8 @@ discard block |
||
961 | 961 | |
962 | 962 | $output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' ); |
963 | 963 | |
964 | - if( empty( $link ) ) { |
|
965 | - return strip_tags( $output); |
|
964 | + if ( empty( $link ) ) { |
|
965 | + return strip_tags( $output ); |
|
966 | 966 | } |
967 | 967 | |
968 | 968 | return $output; |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | $fe = GravityView_frontend::getInstance(); |
982 | 982 | |
983 | 983 | // Solve problem when loading content via admin-ajax.php |
984 | - if( ! $fe->getGvOutputData() ) { |
|
984 | + if ( ! $fe->getGvOutputData() ) { |
|
985 | 985 | |
986 | 986 | gravityview()->log->debug( 'gv_output_data not defined; parsing content.' ); |
987 | 987 | |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | } |
990 | 990 | |
991 | 991 | // Make 100% sure that we're dealing with a properly called situation |
992 | - if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
992 | + if ( ! is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
993 | 993 | |
994 | 994 | gravityview()->log->debug( 'gv_output_data not an object or get_view not callable.', array( 'data' => $fe->getGvOutputData() ) ); |
995 | 995 | |
@@ -1211,12 +1211,12 @@ discard block |
||
1211 | 1211 | function gravityview_get_files_array( $value, $gv_class = '', $context = null ) { |
1212 | 1212 | /** @define "GRAVITYVIEW_DIR" "../" */ |
1213 | 1213 | |
1214 | - if( !class_exists( 'GravityView_Field' ) ) { |
|
1215 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' ); |
|
1214 | + if ( ! class_exists( 'GravityView_Field' ) ) { |
|
1215 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field.php' ); |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | - if( !class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
1219 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field-fileupload.php' ); |
|
1218 | + if ( ! class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
1219 | + include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field-fileupload.php' ); |
|
1220 | 1220 | } |
1221 | 1221 | |
1222 | 1222 | if ( is_null( $context ) ) { |
@@ -1319,21 +1319,21 @@ discard block |
||
1319 | 1319 | } else { |
1320 | 1320 | // @deprecated path |
1321 | 1321 | // Required fields. |
1322 | - if ( empty( $args['field'] ) || empty( $args['form'] ) ) { |
|
1322 | + if ( empty( $args[ 'field' ] ) || empty( $args[ 'form' ] ) ) { |
|
1323 | 1323 | gravityview()->log->error( 'Field or form are empty.', array( 'data' => $args ) ); |
1324 | 1324 | return ''; |
1325 | 1325 | } |
1326 | 1326 | } |
1327 | 1327 | |
1328 | 1328 | if ( $context instanceof \GV\Template_Context ) { |
1329 | - $entry = $args['entry'] ? : ( $context->entry ? $context->entry->as_entry() : array() ); |
|
1330 | - $field = $args['field'] ? : ( $context->field ? $context->field->as_configuration() : array() ); |
|
1331 | - $form = $args['form'] ? : ( $context->view->form ? $context->view->form->form : array() ); |
|
1329 | + $entry = $args[ 'entry' ] ?: ( $context->entry ? $context->entry->as_entry() : array() ); |
|
1330 | + $field = $args[ 'field' ] ?: ( $context->field ? $context->field->as_configuration() : array() ); |
|
1331 | + $form = $args[ 'form' ] ?: ( $context->view->form ? $context->view->form->form : array() ); |
|
1332 | 1332 | } else { |
1333 | 1333 | // @deprecated path |
1334 | - $entry = empty( $args['entry'] ) ? array() : $args['entry']; |
|
1335 | - $field = $args['field']; |
|
1336 | - $form = $args['form']; |
|
1334 | + $entry = empty( $args[ 'entry' ] ) ? array() : $args[ 'entry' ]; |
|
1335 | + $field = $args[ 'field' ]; |
|
1336 | + $form = $args[ 'form' ]; |
|
1337 | 1337 | } |
1338 | 1338 | |
1339 | 1339 | /** |
@@ -1353,43 +1353,43 @@ discard block |
||
1353 | 1353 | ); |
1354 | 1354 | |
1355 | 1355 | if ( $context instanceof \GV\Template_Context ) { |
1356 | - $placeholders['value'] = \GV\Utils::get( $args, 'value', '' ); |
|
1356 | + $placeholders[ 'value' ] = \GV\Utils::get( $args, 'value', '' ); |
|
1357 | 1357 | } else { |
1358 | 1358 | // @deprecated path |
1359 | - $placeholders['value'] = gv_value( $entry, $field ); |
|
1359 | + $placeholders[ 'value' ] = gv_value( $entry, $field ); |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | // If the value is empty and we're hiding empty, return empty. |
1363 | - if ( $placeholders['value'] === '' && ! empty( $args['hide_empty'] ) ) { |
|
1363 | + if ( $placeholders[ 'value' ] === '' && ! empty( $args[ 'hide_empty' ] ) ) { |
|
1364 | 1364 | return ''; |
1365 | 1365 | } |
1366 | 1366 | |
1367 | - if ( $placeholders['value'] !== '' && ! empty( $args['wpautop'] ) ) { |
|
1368 | - $placeholders['value'] = wpautop( $placeholders['value'] ); |
|
1367 | + if ( $placeholders[ 'value' ] !== '' && ! empty( $args[ 'wpautop' ] ) ) { |
|
1368 | + $placeholders[ 'value' ] = wpautop( $placeholders[ 'value' ] ); |
|
1369 | 1369 | } |
1370 | 1370 | |
1371 | 1371 | // Get width setting, if exists |
1372 | - $placeholders['width'] = GravityView_API::field_width( $field ); |
|
1372 | + $placeholders[ 'width' ] = GravityView_API::field_width( $field ); |
|
1373 | 1373 | |
1374 | 1374 | // If replacing with CSS inline formatting, let's do it. |
1375 | - $placeholders['width:style'] = GravityView_API::field_width( $field, 'width:' . $placeholders['width'] . '%;' ); |
|
1375 | + $placeholders[ 'width:style' ] = GravityView_API::field_width( $field, 'width:' . $placeholders[ 'width' ] . '%;' ); |
|
1376 | 1376 | |
1377 | 1377 | // Grab the Class using `gv_class` |
1378 | - $placeholders['class'] = gv_class( $field, $form, $entry ); |
|
1379 | - $placeholders['field_id'] = GravityView_API::field_html_attr_id( $field, $form, $entry ); |
|
1378 | + $placeholders[ 'class' ] = gv_class( $field, $form, $entry ); |
|
1379 | + $placeholders[ 'field_id' ] = GravityView_API::field_html_attr_id( $field, $form, $entry ); |
|
1380 | 1380 | |
1381 | 1381 | if ( $context instanceof \GV\Template_Context ) { |
1382 | - $placeholders['label_value'] = \GV\Utils::get( $args, 'label' ); |
|
1382 | + $placeholders[ 'label_value' ] = \GV\Utils::get( $args, 'label' ); |
|
1383 | 1383 | } else { |
1384 | 1384 | // Default Label value |
1385 | - $placeholders['label_value'] = gv_label( $field, $entry ); |
|
1385 | + $placeholders[ 'label_value' ] = gv_label( $field, $entry ); |
|
1386 | 1386 | } |
1387 | 1387 | |
1388 | - $placeholders['label_value:data-label'] = trim( esc_attr( strip_tags( str_replace( '> ', '>', $placeholders['label_value'] ) ) ) ); |
|
1389 | - $placeholders['label_value:esc_attr'] = esc_attr( $placeholders['label_value'] ); |
|
1388 | + $placeholders[ 'label_value:data-label' ] = trim( esc_attr( strip_tags( str_replace( '> ', '>', $placeholders[ 'label_value' ] ) ) ) ); |
|
1389 | + $placeholders[ 'label_value:esc_attr' ] = esc_attr( $placeholders[ 'label_value' ] ); |
|
1390 | 1390 | |
1391 | - if ( empty( $placeholders['label'] ) && ! empty( $placeholders['label_value'] ) ){ |
|
1392 | - $placeholders['label'] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
1391 | + if ( empty( $placeholders[ 'label' ] ) && ! empty( $placeholders[ 'label_value' ] ) ) { |
|
1392 | + $placeholders[ 'label' ] = '<span class="gv-field-label">{{ label_value }}</span>'; |
|
1393 | 1393 | } |
1394 | 1394 | |
1395 | 1395 | /** |
@@ -1400,7 +1400,7 @@ discard block |
||
1400 | 1400 | * @since 2.0 |
1401 | 1401 | * @param \GV\Template_Context $context The context. |
1402 | 1402 | */ |
1403 | - $html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args, $context ); |
|
1403 | + $html = apply_filters( 'gravityview/field_output/pre_html', $args[ 'markup' ], $args, $context ); |
|
1404 | 1404 | |
1405 | 1405 | /** |
1406 | 1406 | * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders |
@@ -1427,7 +1427,7 @@ discard block |
||
1427 | 1427 | foreach ( $placeholders as $tag => $value ) { |
1428 | 1428 | |
1429 | 1429 | // If the tag doesn't exist just skip it |
1430 | - if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){ |
|
1430 | + if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ) { |
|
1431 | 1431 | continue; |
1432 | 1432 | } |
1433 | 1433 |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | |
105 | 105 | /** Call all lazy callbacks. */ |
106 | 106 | foreach ( $this->callbacks as $callback ) { |
107 | - if ( $callback[0] != 'count' ) { |
|
107 | + if ( $callback[ 0 ] != 'count' ) { |
|
108 | 108 | continue; |
109 | 109 | } |
110 | 110 | |
111 | - $total += $callback[1]( $this->filters ); |
|
111 | + $total += $callback[ 1 ]( $this->filters ); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | if ( ! $total ) { |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | |
186 | 186 | /** Call all lazy callbacks. */ |
187 | 187 | foreach ( $this->callbacks as $i => $callback ) { |
188 | - if ( $callback[0] != 'fetch' ) { |
|
188 | + if ( $callback[ 0 ] != 'fetch' ) { |
|
189 | 189 | continue; |
190 | 190 | } |
191 | 191 | |
192 | - $this->merge( $callback[1]( $this->filters, $this->sorts, $offset ) ); |
|
192 | + $this->merge( $callback[ 1 ]( $this->filters, $this->sorts, $offset ) ); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | $this->fetched = parent::count(); |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | return; |
346 | 346 | } |
347 | 347 | |
348 | - $this->callbacks []= array( $type, $callback ); |
|
348 | + $this->callbacks [ ] = array( $type, $callback ); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | /** |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | |
126 | 126 | $form = false; |
127 | 127 | |
128 | - if( $entry ) { |
|
129 | - $form = GFAPI::get_form( $entry['form_id'] ); |
|
128 | + if ( $entry ) { |
|
129 | + $form = GFAPI::get_form( $entry[ 'form_id' ] ); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | return $form; |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | - return (bool) $has_transaction_data; |
|
205 | + return (bool)$has_transaction_data; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | |
241 | 241 | $results = GFAPI::get_entries( intval( $form_id ), $search_criteria, null, $paging ); |
242 | 242 | |
243 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
243 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
244 | 244 | |
245 | 245 | return $result; |
246 | 246 | } |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms |
259 | 259 | */ |
260 | - public static function get_forms( $active = true, $trash = false ) { |
|
260 | + public static function get_forms( $active = true, $trash = false ) { |
|
261 | 261 | $forms = array(); |
262 | 262 | if ( class_exists( 'GFAPI' ) ) { |
263 | - if( 'any' === $active ) { |
|
263 | + if ( 'any' === $active ) { |
|
264 | 264 | $active_forms = GFAPI::get_forms( true, $trash ); |
265 | 265 | $inactive_forms = GFAPI::get_forms( false, $trash ); |
266 | 266 | $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) ); |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | $has_post_fields = false; |
292 | 292 | |
293 | 293 | if ( $form ) { |
294 | - foreach ( $form['fields'] as $field ) { |
|
295 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
296 | - $fields["{$field['id']}"] = array( |
|
294 | + foreach ( $form[ 'fields' ] as $field ) { |
|
295 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
296 | + $fields[ "{$field[ 'id' ]}" ] = array( |
|
297 | 297 | 'label' => \GV\Utils::get( $field, 'label' ), |
298 | 298 | 'parent' => null, |
299 | 299 | 'type' => \GV\Utils::get( $field, 'type' ), |
@@ -302,10 +302,10 @@ discard block |
||
302 | 302 | ); |
303 | 303 | } |
304 | 304 | |
305 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
306 | - foreach ( $field['inputs'] as $input ) { |
|
305 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
306 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
307 | 307 | |
308 | - if( ! empty( $input['isHidden'] ) ) { |
|
308 | + if ( ! empty( $input[ 'isHidden' ] ) ) { |
|
309 | 309 | continue; |
310 | 310 | } |
311 | 311 | |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | * @hack |
314 | 314 | * In case of email/email confirmation, the input for email has the same id as the parent field |
315 | 315 | */ |
316 | - if( 'email' === $field['type'] && false === strpos( $input['id'], '.' ) ) { |
|
316 | + if ( 'email' === $field[ 'type' ] && false === strpos( $input[ 'id' ], '.' ) ) { |
|
317 | 317 | continue; |
318 | 318 | } |
319 | - $fields["{$input['id']}"] = array( |
|
319 | + $fields[ "{$input[ 'id' ]}" ] = array( |
|
320 | 320 | 'label' => \GV\Utils::get( $input, 'label' ), |
321 | 321 | 'customLabel' => \GV\Utils::get( $input, 'customLabel' ), |
322 | 322 | 'parent' => $field, |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | } |
329 | 329 | |
330 | 330 | |
331 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
331 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
332 | 332 | $has_product_fields = true; |
333 | 333 | } |
334 | 334 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * @since 1.7 |
343 | 343 | */ |
344 | 344 | if ( $has_post_fields ) { |
345 | - $fields['post_id'] = array( |
|
345 | + $fields[ 'post_id' ] = array( |
|
346 | 346 | 'label' => __( 'Post ID', 'gravityview' ), |
347 | 347 | 'type' => 'post_id', |
348 | 348 | ); |
@@ -355,11 +355,11 @@ discard block |
||
355 | 355 | foreach ( $payment_fields as $payment_field ) { |
356 | 356 | |
357 | 357 | // Either the field exists ($fields['shipping']) or the form explicitly contains a `shipping` field with numeric key |
358 | - if( isset( $fields["{$payment_field->name}"] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
358 | + if ( isset( $fields[ "{$payment_field->name}" ] ) || GFCommon::get_fields_by_type( $form, $payment_field->name ) ) { |
|
359 | 359 | continue; |
360 | 360 | } |
361 | 361 | |
362 | - $fields["{$payment_field->name}"] = array( |
|
362 | + $fields[ "{$payment_field->name}" ] = array( |
|
363 | 363 | 'label' => $payment_field->label, |
364 | 364 | 'desc' => $payment_field->description, |
365 | 365 | 'type' => $payment_field->name, |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | |
392 | 392 | $fields = array(); |
393 | 393 | |
394 | - foreach ( $extra_fields as $key => $field ){ |
|
395 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
396 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
394 | + foreach ( $extra_fields as $key => $field ) { |
|
395 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
396 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | |
@@ -433,33 +433,33 @@ discard block |
||
433 | 433 | 'search_criteria' => null, |
434 | 434 | 'sorting' => null, |
435 | 435 | 'paging' => null, |
436 | - 'cache' => (isset( $passed_criteria['cache'] ) ? (bool) $passed_criteria['cache'] : true), |
|
436 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? (bool)$passed_criteria[ 'cache' ] : true ), |
|
437 | 437 | 'context_view_id' => null, |
438 | 438 | ); |
439 | 439 | |
440 | 440 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
441 | 441 | |
442 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
443 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
442 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
443 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
444 | 444 | |
445 | 445 | if ( ! is_array( $filter ) ) { |
446 | 446 | continue; |
447 | 447 | } |
448 | 448 | |
449 | 449 | // By default, we want searches to be wildcard for each field. |
450 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
450 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
451 | 451 | |
452 | 452 | /** |
453 | 453 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
454 | 454 | * @param string $operator Existing search operator |
455 | 455 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
456 | 456 | */ |
457 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
457 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | // don't send just the [mode] without any field filter. |
461 | - if( count( $criteria['search_criteria']['field_filters'] ) === 1 && array_key_exists( 'mode' , $criteria['search_criteria']['field_filters'] ) ) { |
|
462 | - unset( $criteria['search_criteria']['field_filters']['mode'] ); |
|
461 | + if ( count( $criteria[ 'search_criteria' ][ 'field_filters' ] ) === 1 && array_key_exists( 'mode', $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
462 | + unset( $criteria[ 'search_criteria' ][ 'field_filters' ][ 'mode' ] ); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | } |
@@ -470,33 +470,33 @@ discard block |
||
470 | 470 | * Prepare date formats to be in Gravity Forms DB format; |
471 | 471 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
472 | 472 | */ |
473 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
473 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
474 | 474 | |
475 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
475 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
476 | 476 | |
477 | 477 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
478 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
478 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
479 | 479 | |
480 | 480 | if ( $date ) { |
481 | 481 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
482 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
482 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
483 | 483 | } else { |
484 | - gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria['search_criteria'][ $key ] ) ); |
|
484 | + gravityview()->log->error( '{key} Date format not valid:', array( 'key' => $key, $criteria[ 'search_criteria' ][ $key ] ) ); |
|
485 | 485 | |
486 | 486 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
487 | - unset( $criteria['search_criteria'][ $key ] ); |
|
487 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
488 | 488 | } |
489 | 489 | } |
490 | 490 | } |
491 | 491 | |
492 | - if ( empty( $criteria['context_view_id'] ) ) { |
|
492 | + if ( empty( $criteria[ 'context_view_id' ] ) ) { |
|
493 | 493 | // Calculate the context view id and send it to the advanced filter |
494 | 494 | if ( GravityView_frontend::getInstance()->getSingleEntry() ) { |
495 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
495 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
496 | 496 | } else if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance() && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
497 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
497 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
498 | 498 | } else if ( 'delete' === GFForms::get( 'action' ) ) { |
499 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
|
499 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? intval( $_GET[ 'view_id' ] ) : null; |
|
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | * @param array $form_ids Forms to search |
507 | 507 | * @param int $view_id ID of the view being used to search |
508 | 508 | */ |
509 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
509 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
510 | 510 | |
511 | 511 | return (array)$criteria; |
512 | 512 | } |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | /** Reduce # of database calls */ |
542 | 542 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
543 | 543 | |
544 | - if ( ! empty( $criteria['cache'] ) ) { |
|
544 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
545 | 545 | |
546 | 546 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
547 | 547 | |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | |
550 | 550 | // Still update the total count when using cached results |
551 | 551 | if ( ! is_null( $total ) ) { |
552 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
552 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | $return = $entries; |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | $entries = apply_filters_ref_array( 'gravityview_before_get_entries', array( null, $criteria, $passed_criteria, &$total ) ); |
572 | 572 | |
573 | 573 | // No entries returned from gravityview_before_get_entries |
574 | - if( is_null( $entries ) ) { |
|
574 | + if ( is_null( $entries ) ) { |
|
575 | 575 | |
576 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
576 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
577 | 577 | |
578 | 578 | if ( is_wp_error( $entries ) ) { |
579 | 579 | gravityview()->log->error( '{error}', array( 'error' => $entries->get_error_message(), 'data' => $entries ) ); |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
587 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
587 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
588 | 588 | |
589 | 589 | // Cache results |
590 | 590 | $Cache->set( $entries, 'entries' ); |
@@ -693,12 +693,12 @@ discard block |
||
693 | 693 | */ |
694 | 694 | $check_entry_display = apply_filters( 'gravityview/common/get_entry/check_entry_display', $check_entry_display, $entry ); |
695 | 695 | |
696 | - if( $check_entry_display ) { |
|
696 | + if ( $check_entry_display ) { |
|
697 | 697 | // Is the entry allowed |
698 | 698 | $entry = self::check_entry_display( $entry ); |
699 | 699 | } |
700 | 700 | |
701 | - if( is_wp_error( $entry ) ) { |
|
701 | + if ( is_wp_error( $entry ) ) { |
|
702 | 702 | gravityview()->log->error( '{error}', array( 'error' => $entry->get_error_message() ) ); |
703 | 703 | return false; |
704 | 704 | } |
@@ -732,12 +732,12 @@ discard block |
||
732 | 732 | |
733 | 733 | $value = false; |
734 | 734 | |
735 | - if( 'context' === $val1 ) { |
|
735 | + if ( 'context' === $val1 ) { |
|
736 | 736 | |
737 | 737 | $matching_contexts = array( $val2 ); |
738 | 738 | |
739 | 739 | // We allow for non-standard contexts. |
740 | - switch( $val2 ) { |
|
740 | + switch ( $val2 ) { |
|
741 | 741 | // Check for either single or edit |
742 | 742 | case 'singular': |
743 | 743 | $matching_contexts = array( 'single', 'edit' ); |
@@ -780,18 +780,18 @@ discard block |
||
780 | 780 | $json_val_1 = json_decode( $val1, true ); |
781 | 781 | $json_val_2 = json_decode( $val2, true ); |
782 | 782 | |
783 | - if( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
783 | + if ( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) { |
|
784 | 784 | |
785 | 785 | $json_in = false; |
786 | - $json_val_1 = $json_val_1 ? (array) $json_val_1 : array( $val1 ); |
|
787 | - $json_val_2 = $json_val_2 ? (array) $json_val_2 : array( $val2 ); |
|
786 | + $json_val_1 = $json_val_1 ? (array)$json_val_1 : array( $val1 ); |
|
787 | + $json_val_2 = $json_val_2 ? (array)$json_val_2 : array( $val2 ); |
|
788 | 788 | |
789 | 789 | // For JSON, we want to compare as "in" or "not in" rather than "contains" |
790 | 790 | foreach ( $json_val_1 as $item_1 ) { |
791 | 791 | foreach ( $json_val_2 as $item_2 ) { |
792 | 792 | $json_in = self::matches_operation( $item_1, $item_2, 'is' ); |
793 | 793 | |
794 | - if( $json_in ) { |
|
794 | + if ( $json_in ) { |
|
795 | 795 | break 2; |
796 | 796 | } |
797 | 797 | } |
@@ -843,10 +843,10 @@ discard block |
||
843 | 843 | public static function check_entry_display( $entry, $view = null ) { |
844 | 844 | |
845 | 845 | if ( ! $entry || is_wp_error( $entry ) ) { |
846 | - return new WP_Error('entry_not_found', 'Entry was not found.', $entry ); |
|
846 | + return new WP_Error( 'entry_not_found', 'Entry was not found.', $entry ); |
|
847 | 847 | } |
848 | 848 | |
849 | - if ( empty( $entry['form_id'] ) ) { |
|
849 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
850 | 850 | return new WP_Error( 'form_id_not_set', '[apply_filters_to_entry] Entry is empty!', $entry ); |
851 | 851 | } |
852 | 852 | |
@@ -855,15 +855,15 @@ discard block |
||
855 | 855 | * Check whether the entry is in the entries subset by running a modified query. |
856 | 856 | */ |
857 | 857 | add_action( 'gravityview/view/query', $entry_subset_callback = function( &$query, $view, $request ) use ( $entry ) { |
858 | - $_tmp_query = new \GF_Query( $view->form->ID, array( 'field_filters' => array( 'mode' => 'all', array( 'key' => 'id', 'operation' => 'is', 'value' => $entry['id'] ) ) ) ); |
|
858 | + $_tmp_query = new \GF_Query( $view->form->ID, array( 'field_filters' => array( 'mode' => 'all', array( 'key' => 'id', 'operation' => 'is', 'value' => $entry[ 'id' ] ) ) ) ); |
|
859 | 859 | $_tmp_query_parts = $_tmp_query->_introspect(); |
860 | 860 | |
861 | 861 | $query_parts = $query->_introspect(); |
862 | 862 | |
863 | - $query->where( \GF_Query_Condition::_and( $_tmp_query_parts['where'], $query_parts['where'] ) ); |
|
863 | + $query->where( \GF_Query_Condition::_and( $_tmp_query_parts[ 'where' ], $query_parts[ 'where' ] ) ); |
|
864 | 864 | }, 10, 3 ); |
865 | 865 | |
866 | - if ( ( ! $entries = $view->get_entries()->all() ) || $entries[0]->ID !== $entry['id'] ) { |
|
866 | + if ( ( ! $entries = $view->get_entries()->all() ) || $entries[ 0 ]->ID !== $entry[ 'id' ] ) { |
|
867 | 867 | remove_action( 'gravityview/view/query', $entry_subset_callback ); |
868 | 868 | return new \WP_Error( 'failed_criteria', 'Entry failed search_criteria and field_filters' ); |
869 | 869 | } |
@@ -876,59 +876,59 @@ discard block |
||
876 | 876 | 'context_view_id' => $view ? $view->ID : null, |
877 | 877 | ) ); |
878 | 878 | |
879 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
879 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
880 | 880 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved! No search criteria found:', array( 'data' => $criteria ) ); |
881 | 881 | return $entry; |
882 | 882 | } |
883 | 883 | |
884 | 884 | // Make sure the current View is connected to the same form as the Entry |
885 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
886 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
885 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
886 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
887 | 887 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
888 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
889 | - return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
888 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
889 | + return new WP_Error( 'view_id_not_match', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
890 | 890 | } |
891 | 891 | } |
892 | 892 | |
893 | - $search_criteria = $criteria['search_criteria']; |
|
893 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
894 | 894 | |
895 | 895 | // check entry status |
896 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
897 | - return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
896 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
897 | + return new WP_Error( 'status_not_valid', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
898 | 898 | } |
899 | 899 | |
900 | 900 | // check entry date |
901 | 901 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
902 | 902 | |
903 | 903 | // field_filters |
904 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
904 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
905 | 905 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved! No field filters criteria found:', array( 'data' => $search_criteria ) ); |
906 | 906 | return $entry; |
907 | 907 | } |
908 | 908 | |
909 | - $filters = $search_criteria['field_filters']; |
|
909 | + $filters = $search_criteria[ 'field_filters' ]; |
|
910 | 910 | |
911 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
911 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
912 | 912 | |
913 | - $mode = $mode ? : 'all'; // If mode is an empty string, assume it's 'all' |
|
913 | + $mode = $mode ?: 'all'; // If mode is an empty string, assume it's 'all' |
|
914 | 914 | |
915 | 915 | // Prevent the mode from being processed below |
916 | - unset( $filters['mode'] ); |
|
916 | + unset( $filters[ 'mode' ] ); |
|
917 | 917 | |
918 | - $form = self::get_form( $entry['form_id'] ); |
|
918 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
919 | 919 | |
920 | 920 | foreach ( $filters as $filter ) { |
921 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
921 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
922 | 922 | |
923 | - if ( ! isset( $filter['key'] ) ) { |
|
923 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
924 | 924 | gravityview()->log->debug( '[apply_filters_to_entry] Filter key not set, any field mode', array( 'filter' => $filter ) ); |
925 | 925 | /** |
926 | 926 | * This is a cross-field search. Let's start digging'. |
927 | 927 | */ |
928 | 928 | foreach ( \GV\Utils::get( $form, 'fields', array() ) as $field ) { |
929 | 929 | $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
930 | - if ( $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ) ) { |
|
931 | - if ( 'any' === $mode) { |
|
930 | + if ( $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ) ) { |
|
931 | + if ( 'any' === $mode ) { |
|
932 | 932 | return $entry; // All good here |
933 | 933 | } // mode === 'all' |
934 | 934 | continue 2; // Next filter |
@@ -937,13 +937,13 @@ discard block |
||
937 | 937 | } |
938 | 938 | |
939 | 939 | if ( 'all' === $mode ) { |
940 | - return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a subcriterium for any field in ALL mode', $filter ); |
|
940 | + return new WP_Error( 'failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a subcriterium for any field in ALL mode', $filter ); |
|
941 | 941 | } |
942 | 942 | |
943 | 943 | continue; |
944 | 944 | } |
945 | 945 | |
946 | - $k = $filter['key']; |
|
946 | + $k = $filter[ 'key' ]; |
|
947 | 947 | |
948 | 948 | $field = self::get_field( $form, $k ); |
949 | 949 | |
@@ -951,12 +951,12 @@ discard block |
||
951 | 951 | $field_value = isset( $entry[ $k ] ) ? $entry[ $k ] : null; |
952 | 952 | $field = $k; |
953 | 953 | } else { |
954 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
954 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
955 | 955 | // If it's a complex field, then fetch the input's value, if exists at the current key. Otherwise, let GF handle it |
956 | 956 | $field_value = ( is_array( $field_value ) && isset( $field_value[ $k ] ) ) ? \GV\Utils::get( $field_value, $k ) : $field_value; |
957 | 957 | } |
958 | 958 | |
959 | - $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
959 | + $is_value_match = GravityView_GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
960 | 960 | |
961 | 961 | // Any match is all we need to know |
962 | 962 | if ( $is_value_match && 'any' === $mode ) { |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | |
966 | 966 | // Any failed match is a total fail |
967 | 967 | if ( ! $is_value_match && 'all' === $mode ) { |
968 | - return new WP_Error('failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
968 | + return new WP_Error( 'failed_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed a criterium for ALL mode', $filter ); |
|
969 | 969 | } |
970 | 970 | } |
971 | 971 | |
@@ -975,7 +975,7 @@ discard block |
||
975 | 975 | gravityview()->log->debug( '[apply_filters_to_entry] Entry approved: all conditions were met' ); |
976 | 976 | return $entry; |
977 | 977 | } else { |
978 | - return new WP_Error('failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
978 | + return new WP_Error( 'failed_any_criteria', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
979 | 979 | } |
980 | 980 | |
981 | 981 | } |
@@ -1016,18 +1016,18 @@ discard block |
||
1016 | 1016 | * Gravity Forms code to adjust date to locally-configured Time Zone |
1017 | 1017 | * @see GFCommon::format_date() for original code |
1018 | 1018 | */ |
1019 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
1019 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
1020 | 1020 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
1021 | 1021 | |
1022 | - $format = \GV\Utils::get( $atts, 'format' ); |
|
1023 | - $is_human = ! empty( $atts['human'] ); |
|
1024 | - $is_diff = ! empty( $atts['diff'] ); |
|
1025 | - $is_raw = ! empty( $atts['raw'] ); |
|
1026 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
1027 | - $include_time = ! empty( $atts['time'] ); |
|
1022 | + $format = \GV\Utils::get( $atts, 'format' ); |
|
1023 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
1024 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
1025 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
1026 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
1027 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
1028 | 1028 | |
1029 | 1029 | // If we're using time diff, we want to have a different default format |
1030 | - if( empty( $format ) ) { |
|
1030 | + if ( empty( $format ) ) { |
|
1031 | 1031 | /* translators: %s: relative time from now, used for generic date comparisons. "1 day ago", or "20 seconds ago" */ |
1032 | 1032 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
1033 | 1033 | } |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | // If raw was specified, don't modify the stored value |
1036 | 1036 | if ( $is_raw ) { |
1037 | 1037 | $formatted_date = $date_string; |
1038 | - } elseif( $is_timestamp ) { |
|
1038 | + } elseif ( $is_timestamp ) { |
|
1039 | 1039 | $formatted_date = $date_local_timestamp; |
1040 | 1040 | } elseif ( $is_diff ) { |
1041 | 1041 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | |
1070 | 1070 | $label = \GV\Utils::get( $field, 'label' ); |
1071 | 1071 | |
1072 | - if( floor( $field_id ) !== floatval( $field_id ) ) { |
|
1072 | + if ( floor( $field_id ) !== floatval( $field_id ) ) { |
|
1073 | 1073 | $label = GFFormsModel::get_choice_text( $field, $field_value, $field_id ); |
1074 | 1074 | } |
1075 | 1075 | |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | $form = GFAPI::get_form( $form ); |
1098 | 1098 | } |
1099 | 1099 | |
1100 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
1100 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
1101 | 1101 | return GFFormsModel::get_field( $form, $field_id ); |
1102 | 1102 | } else { |
1103 | 1103 | return null; |
@@ -1144,19 +1144,19 @@ discard block |
||
1144 | 1144 | $shortcodes = array(); |
1145 | 1145 | |
1146 | 1146 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
1147 | - if ( empty( $matches ) ){ |
|
1147 | + if ( empty( $matches ) ) { |
|
1148 | 1148 | return false; |
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | foreach ( $matches as $shortcode ) { |
1152 | - if ( $tag === $shortcode[2] ) { |
|
1152 | + if ( $tag === $shortcode[ 2 ] ) { |
|
1153 | 1153 | |
1154 | 1154 | // Changed this to $shortcode instead of true so we get the parsed atts. |
1155 | - $shortcodes[] = $shortcode; |
|
1155 | + $shortcodes[ ] = $shortcode; |
|
1156 | 1156 | |
1157 | - } else if ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
1158 | - foreach( $results as $result ) { |
|
1159 | - $shortcodes[] = $result; |
|
1157 | + } else if ( isset( $shortcode[ 5 ] ) && $results = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
1158 | + foreach ( $results as $result ) { |
|
1159 | + $shortcodes[ ] = $result; |
|
1160 | 1160 | } |
1161 | 1161 | } |
1162 | 1162 | } |
@@ -1188,7 +1188,7 @@ discard block |
||
1188 | 1188 | 'post_type' => 'gravityview', |
1189 | 1189 | 'posts_per_page' => 100, |
1190 | 1190 | 'meta_key' => '_gravityview_form_id', |
1191 | - 'meta_value' => (int) $form_id, |
|
1191 | + 'meta_value' => (int)$form_id, |
|
1192 | 1192 | ); |
1193 | 1193 | $args = wp_parse_args( $args, $defaults ); |
1194 | 1194 | $views = get_posts( $args ); |
@@ -1200,21 +1200,21 @@ discard block |
||
1200 | 1200 | |
1201 | 1201 | $data = unserialize( $view->meta_value ); |
1202 | 1202 | |
1203 | - if( ! $data || ! is_array( $data ) ) { |
|
1203 | + if ( ! $data || ! is_array( $data ) ) { |
|
1204 | 1204 | continue; |
1205 | 1205 | } |
1206 | 1206 | |
1207 | 1207 | foreach ( $data as $datum ) { |
1208 | - if ( ! empty( $datum[2] ) && (int) $datum[2] === (int) $form_id ) { |
|
1209 | - $joined_forms[] = $view->post_id; |
|
1208 | + if ( ! empty( $datum[ 2 ] ) && (int)$datum[ 2 ] === (int)$form_id ) { |
|
1209 | + $joined_forms[ ] = $view->post_id; |
|
1210 | 1210 | } |
1211 | 1211 | } |
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | if ( $joined_forms ) { |
1215 | - $joined_args = array( |
|
1215 | + $joined_args = array( |
|
1216 | 1216 | 'post_type' => 'gravityview', |
1217 | - 'posts_per_page' => $args['posts_per_page'], |
|
1217 | + 'posts_per_page' => $args[ 'posts_per_page' ], |
|
1218 | 1218 | 'post__in' => $joined_forms, |
1219 | 1219 | ); |
1220 | 1220 | $views = array_merge( $views, get_posts( $joined_args ) ); |
@@ -1370,7 +1370,7 @@ discard block |
||
1370 | 1370 | |
1371 | 1371 | $directory_widgets = wp_parse_args( $view_widgets, $defaults ); |
1372 | 1372 | |
1373 | - if( $json_decode ) { |
|
1373 | + if ( $json_decode ) { |
|
1374 | 1374 | $directory_widgets = gv_map_deep( $directory_widgets, 'gv_maybe_json_decode' ); |
1375 | 1375 | } |
1376 | 1376 | |
@@ -1386,7 +1386,7 @@ discard block |
||
1386 | 1386 | * @return string html |
1387 | 1387 | */ |
1388 | 1388 | public static function get_sortable_fields( $formid, $current = '' ) { |
1389 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1389 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
1390 | 1390 | |
1391 | 1391 | if ( empty( $formid ) ) { |
1392 | 1392 | return $output; |
@@ -1399,11 +1399,11 @@ discard block |
||
1399 | 1399 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
1400 | 1400 | |
1401 | 1401 | foreach ( $fields as $id => $field ) { |
1402 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1402 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1403 | 1403 | continue; |
1404 | 1404 | } |
1405 | 1405 | |
1406 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1406 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
1407 | 1407 | } |
1408 | 1408 | } |
1409 | 1409 | |
@@ -1438,9 +1438,9 @@ discard block |
||
1438 | 1438 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1439 | 1439 | |
1440 | 1440 | // TODO: Convert to using array_filter |
1441 | - foreach( $fields as $id => $field ) { |
|
1441 | + foreach ( $fields as $id => $field ) { |
|
1442 | 1442 | |
1443 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1443 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1444 | 1444 | unset( $fields[ $id ] ); |
1445 | 1445 | } |
1446 | 1446 | } |
@@ -1481,14 +1481,14 @@ discard block |
||
1481 | 1481 | * @param int|array $field field key or field array |
1482 | 1482 | * @return boolean |
1483 | 1483 | */ |
1484 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1484 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
1485 | 1485 | |
1486 | 1486 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
1487 | 1487 | $form = self::get_form( $form ); |
1488 | 1488 | } |
1489 | 1489 | |
1490 | 1490 | // If entry meta, it's a string. Otherwise, numeric |
1491 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1491 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1492 | 1492 | $type = $field; |
1493 | 1493 | } else { |
1494 | 1494 | $type = self::get_field_type( $form, $field ); |
@@ -1502,9 +1502,9 @@ discard block |
||
1502 | 1502 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
1503 | 1503 | |
1504 | 1504 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
1505 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1506 | - if( true === $gv_field->is_numeric ) { |
|
1507 | - $numeric_types[] = $gv_field->is_numeric; |
|
1505 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1506 | + if ( true === $gv_field->is_numeric ) { |
|
1507 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
1508 | 1508 | } |
1509 | 1509 | } |
1510 | 1510 | |
@@ -1654,18 +1654,18 @@ discard block |
||
1654 | 1654 | $final_atts = array_filter( $final_atts ); |
1655 | 1655 | |
1656 | 1656 | // If the href wasn't passed as an attribute, use the value passed to the function |
1657 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1658 | - $final_atts['href'] = $href; |
|
1657 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
1658 | + $final_atts[ 'href' ] = $href; |
|
1659 | 1659 | } |
1660 | 1660 | |
1661 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1661 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
1662 | 1662 | |
1663 | 1663 | /** |
1664 | 1664 | * Fix potential security issue with target=_blank |
1665 | 1665 | * @see https://dev.to/ben/the-targetblank-vulnerability-by-example |
1666 | 1666 | */ |
1667 | - if( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
1668 | - $final_atts['rel'] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1667 | + if ( '_blank' === \GV\Utils::get( $final_atts, 'target' ) ) { |
|
1668 | + $final_atts[ 'rel' ] = trim( \GV\Utils::get( $final_atts, 'rel', '' ) . ' noopener noreferrer' ); |
|
1669 | 1669 | } |
1670 | 1670 | |
1671 | 1671 | // Sort the attributes alphabetically, to help testing |
@@ -1677,7 +1677,7 @@ discard block |
||
1677 | 1677 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
1678 | 1678 | } |
1679 | 1679 | |
1680 | - if( '' !== $output ) { |
|
1680 | + if ( '' !== $output ) { |
|
1681 | 1681 | $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
1682 | 1682 | } |
1683 | 1683 | |
@@ -1704,7 +1704,7 @@ discard block |
||
1704 | 1704 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
1705 | 1705 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
1706 | 1706 | } else if ( is_numeric( $key ) && isset( $merged[ $key ] ) ) { |
1707 | - $merged[] = $value; |
|
1707 | + $merged[ ] = $value; |
|
1708 | 1708 | } else { |
1709 | 1709 | $merged[ $key ] = $value; |
1710 | 1710 | } |
@@ -1737,7 +1737,7 @@ discard block |
||
1737 | 1737 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1738 | 1738 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1739 | 1739 | */ |
1740 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1740 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1741 | 1741 | |
1742 | 1742 | return get_users( $get_users_settings ); |
1743 | 1743 | } |
@@ -1757,11 +1757,11 @@ discard block |
||
1757 | 1757 | public static function generate_notice( $notice, $class = '', $cap = '', $object_id = null ) { |
1758 | 1758 | |
1759 | 1759 | // If $cap is defined, only show notice if user has capability |
1760 | - if( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1760 | + if ( $cap && ! GVCommon::has_cap( $cap, $object_id ) ) { |
|
1761 | 1761 | return ''; |
1762 | 1762 | } |
1763 | 1763 | |
1764 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1764 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
1765 | 1765 | } |
1766 | 1766 | |
1767 | 1767 | /** |