@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | wp_embed_register_handler( 'gravityview_entry', self::get_entry_regex(), array( __CLASS__, 'render' ), 20000 ); |
27 | 27 | wp_oembed_add_provider( self::get_entry_regex(), self::$provider_url, true ); |
28 | 28 | |
29 | - if ( ! empty( $_GET['gv_oembed_provider'] ) && ! empty( $_GET['url'] ) ) { |
|
29 | + if ( ! empty( $_GET[ 'gv_oembed_provider' ] ) && ! empty( $_GET[ 'url' ] ) ) { |
|
30 | 30 | add_action( 'template_redirect', array( __CLASS__, 'render_provider_request' ) ); |
31 | 31 | } |
32 | 32 | |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | * @return void |
44 | 44 | */ |
45 | 45 | public static function render_provider_request() { |
46 | - if ( ! empty( $_GET['url'] ) ) { |
|
47 | - $url = $_GET['url']; |
|
46 | + if ( ! empty( $_GET[ 'url' ] ) ) { |
|
47 | + $url = $_GET[ 'url' ]; |
|
48 | 48 | } else { |
49 | 49 | header( 'HTTP/1.0 404 Not Found' ); |
50 | 50 | exit; |
@@ -111,18 +111,18 @@ discard block |
||
111 | 111 | */ |
112 | 112 | private static function parse_matches( $matches, $url ) { |
113 | 113 | // If not using permalinks, re-assign values for matching groups |
114 | - if ( ! empty( $matches['entry_slug2'] ) ) { |
|
115 | - $matches['is_cpt'] = $matches['is_cpt2']; |
|
116 | - $matches['slug'] = $matches['slug2']; |
|
117 | - $matches['entry_slug'] = $matches['entry_slug2']; |
|
118 | - unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] ); |
|
114 | + if ( ! empty( $matches[ 'entry_slug2' ] ) ) { |
|
115 | + $matches[ 'is_cpt' ] = $matches[ 'is_cpt2' ]; |
|
116 | + $matches[ 'slug' ] = $matches[ 'slug2' ]; |
|
117 | + $matches[ 'entry_slug' ] = $matches[ 'entry_slug2' ]; |
|
118 | + unset( $matches[ 'is_cpt2' ], $matches[ 'slug2' ], $matches[ 'entry_slug2' ] ); |
|
119 | 119 | } |
120 | 120 | |
121 | - if ( empty( $matches['entry_slug'] ) ) { |
|
121 | + if ( empty( $matches[ 'entry_slug' ] ) ) { |
|
122 | 122 | gravityview()->log->error( 'Entry slug not parsed by regex.', array( 'data' => $matches ) ); |
123 | 123 | return null; |
124 | 124 | } else { |
125 | - $entry_id = $matches['entry_slug']; |
|
125 | + $entry_id = $matches[ 'entry_slug' ]; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | if ( ! $entry = \GV\GF_Entry::by_id( $entry_id ) ) { |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | if ( ! $view ) { |
143 | 143 | |
144 | 144 | // If the slug doesn't work, maybe using Plain permalinks and not the slug, only ID |
145 | - if( is_numeric( $matches['slug'] ) ) { |
|
146 | - $view = \GV\View::by_id( $matches['slug'] ); |
|
145 | + if ( is_numeric( $matches[ 'slug' ] ) ) { |
|
146 | + $view = \GV\View::by_id( $matches[ 'slug' ] ); |
|
147 | 147 | } |
148 | 148 | |
149 | - if( ! $view ) { |
|
150 | - $view = \GV\View::from_post( get_page_by_path( $matches['slug'], OBJECT, 'gravityview' ) ); |
|
149 | + if ( ! $view ) { |
|
150 | + $view = \GV\View::from_post( get_page_by_path( $matches[ 'slug' ], OBJECT, 'gravityview' ) ); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | |
179 | 179 | return ' |
180 | 180 | <div class="loading-placeholder" style="background-color:#e6f0f5;"> |
181 | - <h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image.$embed_heading.'</h3> |
|
181 | + <h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image . $embed_heading . '</h3> |
|
182 | 182 | <p style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;"> |
183 | - '.$embed_text.' |
|
183 | + '.$embed_text . ' |
|
184 | 184 | </p> |
185 | 185 | <br style="clear: both;"> |
186 | 186 | </div>'; |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | private static function render_preview_notice() { |
195 | 195 | $floaty = \GravityView_Admin::get_floaty(); |
196 | 196 | $title = esc_html__( 'This will look better when it is embedded.', 'gravityview' ); |
197 | - $message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview'); |
|
198 | - return '<div class="updated notice">'.$floaty.'<h3>'.$title.'</h3><p>'.$message.'</p><br style="clear:both;" /></div>'; |
|
197 | + $message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview' ); |
|
198 | + return '<div class="updated notice">' . $floaty . '<h3>' . $title . '</h3><p>' . $message . '</p><br style="clear:both;" /></div>'; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -214,13 +214,13 @@ discard block |
||
214 | 214 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
215 | 215 | } |
216 | 216 | |
217 | - if ( $entry && 'active' !== $entry['status'] ) { |
|
217 | + if ( $entry && 'active' !== $entry[ 'status' ] ) { |
|
218 | 218 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
219 | 219 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
220 | 220 | } |
221 | 221 | |
222 | 222 | if ( $view->settings->get( 'show_only_approved' ) ) { |
223 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
223 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
224 | 224 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
225 | 225 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
226 | 226 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | // Catch either |
286 | 286 | $match_regex = "(?:{$using_permalinks}|{$not_using_permalinks})"; |
287 | 287 | |
288 | - return '#'.$match_regex.'#i'; |
|
288 | + return '#' . $match_regex . '#i'; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | |
43 | 43 | add_action( 'wp', array( $this, 'process_delete' ), 10000 ); |
44 | 44 | |
45 | - add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field'), 10, 3 ); |
|
45 | + add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 ); |
|
46 | 46 | |
47 | 47 | add_action( 'gravityview_before', array( $this, 'display_message' ) ); |
48 | 48 | |
49 | 49 | // For the Delete Entry Link, you don't want visible to all users. |
50 | - add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps'), 10, 5 ); |
|
50 | + add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps' ), 10, 5 ); |
|
51 | 51 | |
52 | 52 | // Modify the field options based on the name of the field type |
53 | 53 | add_filter( 'gravityview_template_delete_link_options', array( $this, 'delete_link_field_options' ), 10, 5 ); |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | // add template path to check for field |
56 | 56 | add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) ); |
57 | 57 | |
58 | - add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button'), 10, 4 ); |
|
58 | + add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button' ), 10, 4 ); |
|
59 | 59 | |
60 | - add_action ( 'gravityview/delete-entry/deleted', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
61 | - add_action ( 'gravityview/delete-entry/trashed', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
60 | + add_action( 'gravityview/delete-entry/deleted', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
61 | + add_action( 'gravityview/delete-entry/trashed', array( $this, 'process_connected_posts' ), 10, 2 ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | static function getInstance() { |
71 | 71 | |
72 | - if( empty( self::$instance ) ) { |
|
72 | + if ( empty( self::$instance ) ) { |
|
73 | 73 | self::$instance = new self; |
74 | 74 | } |
75 | 75 | |
@@ -105,20 +105,20 @@ discard block |
||
105 | 105 | function delete_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
106 | 106 | |
107 | 107 | // Always a link, never a filter |
108 | - unset( $field_options['show_as_link'], $field_options['search_filter'] ); |
|
108 | + unset( $field_options[ 'show_as_link' ], $field_options[ 'search_filter' ] ); |
|
109 | 109 | |
110 | 110 | // Delete Entry link should only appear to visitors capable of editing entries |
111 | - unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] ); |
|
111 | + unset( $field_options[ 'only_loggedin' ], $field_options[ 'only_loggedin_cap' ] ); |
|
112 | 112 | |
113 | - $add_option['delete_link'] = array( |
|
113 | + $add_option[ 'delete_link' ] = array( |
|
114 | 114 | 'type' => 'text', |
115 | 115 | 'label' => __( 'Delete Link Text', 'gravityview' ), |
116 | 116 | 'desc' => NULL, |
117 | - 'value' => __('Delete Entry', 'gravityview'), |
|
117 | + 'value' => __( 'Delete Entry', 'gravityview' ), |
|
118 | 118 | 'merge_tags' => true, |
119 | 119 | ); |
120 | 120 | |
121 | - $field_options['allow_edit_cap'] = array( |
|
121 | + $field_options[ 'allow_edit_cap' ] = array( |
|
122 | 122 | 'type' => 'select', |
123 | 123 | 'label' => __( 'Allow the following users to delete the entry:', 'gravityview' ), |
124 | 124 | 'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ), |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | */ |
143 | 143 | function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) { |
144 | 144 | |
145 | - if( 'edit' !== $zone ) { |
|
146 | - $entry_default_fields['delete_link'] = array( |
|
145 | + if ( 'edit' !== $zone ) { |
|
146 | + $entry_default_fields[ 'delete_link' ] = array( |
|
147 | 147 | 'label' => __( 'Delete Entry', 'gravityview' ), |
148 | 148 | 'type' => 'delete_link', |
149 | 149 | 'desc' => __( 'A link to delete the entry. Respects the Delete Entry permissions.', 'gravityview' ), |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | function add_available_field( $available_fields = array() ) { |
162 | 162 | |
163 | - $available_fields['delete_link'] = array( |
|
163 | + $available_fields[ 'delete_link' ] = array( |
|
164 | 164 | 'label_text' => __( 'Delete Entry', 'gravityview' ), |
165 | 165 | 'field_id' => 'delete_link', |
166 | 166 | 'label_type' => 'field', |
@@ -188,12 +188,12 @@ discard block |
||
188 | 188 | $caps = $visibility_caps; |
189 | 189 | |
190 | 190 | // If we're configuring fields in the edit context, we want a limited selection |
191 | - if( $field_id === 'delete_link' ) { |
|
191 | + if ( $field_id === 'delete_link' ) { |
|
192 | 192 | |
193 | 193 | // Remove other built-in caps. |
194 | - unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] ); |
|
194 | + unset( $caps[ 'publish_posts' ], $caps[ 'gravityforms_view_entries' ], $caps[ 'delete_others_posts' ] ); |
|
195 | 195 | |
196 | - $caps['read'] = _x('Entry Creator', 'User capability', 'gravityview'); |
|
196 | + $caps[ 'read' ] = _x( 'Entry Creator', 'User capability', 'gravityview' ); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | return $caps; |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * @param [type] $entry [description] |
207 | 207 | */ |
208 | 208 | function set_entry( $entry = null ) { |
209 | - $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[0] : $entry; |
|
209 | + $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[ 0 ] : $entry; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | |
240 | 240 | self::getInstance()->set_entry( $entry ); |
241 | 241 | |
242 | - $base = GravityView_API::directory_link( $post_id ? : $view_id, true ); |
|
242 | + $base = GravityView_API::directory_link( $post_id ?: $view_id, true ); |
|
243 | 243 | |
244 | 244 | if ( empty( $base ) ) { |
245 | 245 | gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) ); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | // Use the slug instead of the ID for consistent security |
250 | - $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
|
250 | + $entry_slug = GravityView_API::get_entry_slug( $entry[ 'id' ], $entry ); |
|
251 | 251 | |
252 | 252 | $actionurl = add_query_arg( array( |
253 | 253 | 'action' => 'delete', |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | 'view_id' => $view_id, |
257 | 257 | ), $base ); |
258 | 258 | |
259 | - $url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' ); |
|
259 | + $url = wp_nonce_url( $actionurl, 'delete_' . $entry_slug, 'delete' ); |
|
260 | 260 | |
261 | 261 | return $url; |
262 | 262 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | public function add_delete_button( $form = array(), $entry = array(), $view_id = null, $post_id = null ) { |
279 | 279 | |
280 | 280 | // Only show the link to those who are allowed to see it. |
281 | - if( !self::check_user_cap_delete_entry( $entry, array(), $view_id ) ) { |
|
281 | + if ( ! self::check_user_cap_delete_entry( $entry, array(), $view_id ) ) { |
|
282 | 282 | return; |
283 | 283 | } |
284 | 284 | |
@@ -289,13 +289,13 @@ discard block |
||
289 | 289 | $show_delete_button = apply_filters( 'gravityview/delete-entry/show-delete-button', true ); |
290 | 290 | |
291 | 291 | // If the button is hidden by the filter, don't show. |
292 | - if( !$show_delete_button ) { |
|
292 | + if ( ! $show_delete_button ) { |
|
293 | 293 | return; |
294 | 294 | } |
295 | 295 | |
296 | 296 | $attributes = array( |
297 | 297 | 'class' => 'btn btn-sm button button-small alignright pull-right btn-danger gv-button-delete', |
298 | - 'tabindex' => ( GFCommon::$tab_index ++ ), |
|
298 | + 'tabindex' => ( GFCommon::$tab_index++ ), |
|
299 | 299 | 'onclick' => self::get_confirm_dialog(), |
300 | 300 | ); |
301 | 301 | |
@@ -319,27 +319,27 @@ discard block |
||
319 | 319 | function process_delete() { |
320 | 320 | |
321 | 321 | // If the form is submitted |
322 | - if( isset( $_GET['action'] ) && 'delete' === $_GET['action'] && isset( $_GET['entry_id'] ) ) { |
|
322 | + if ( isset( $_GET[ 'action' ] ) && 'delete' === $_GET[ 'action' ] && isset( $_GET[ 'entry_id' ] ) ) { |
|
323 | 323 | |
324 | 324 | // Make sure it's a GravityView request |
325 | - $valid_nonce_key = wp_verify_nonce( $_GET['delete'], self::get_nonce_key( $_GET['entry_id'] ) ); |
|
325 | + $valid_nonce_key = wp_verify_nonce( $_GET[ 'delete' ], self::get_nonce_key( $_GET[ 'entry_id' ] ) ); |
|
326 | 326 | |
327 | - if( ! $valid_nonce_key ) { |
|
327 | + if ( ! $valid_nonce_key ) { |
|
328 | 328 | gravityview()->log->debug( 'Delete entry not processed: nonce validation failed.' ); |
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | 332 | // Get the entry slug |
333 | - $entry_slug = esc_attr( $_GET['entry_id'] ); |
|
333 | + $entry_slug = esc_attr( $_GET[ 'entry_id' ] ); |
|
334 | 334 | |
335 | 335 | // See if there's an entry there |
336 | 336 | $entry = gravityview_get_entry( $entry_slug, true, false ); |
337 | 337 | |
338 | - if( $entry ) { |
|
338 | + if ( $entry ) { |
|
339 | 339 | |
340 | 340 | $has_permission = $this->user_can_delete_entry( $entry ); |
341 | 341 | |
342 | - if( is_wp_error( $has_permission ) ) { |
|
342 | + if ( is_wp_error( $has_permission ) ) { |
|
343 | 343 | |
344 | 344 | $messages = array( |
345 | 345 | 'message' => urlencode( $has_permission->get_error_message() ), |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | // Delete the entry |
352 | 352 | $delete_response = $this->delete_or_trash_entry( $entry ); |
353 | 353 | |
354 | - if( is_wp_error( $delete_response ) ) { |
|
354 | + if ( is_wp_error( $delete_response ) ) { |
|
355 | 355 | |
356 | 356 | $messages = array( |
357 | 357 | 'message' => urlencode( $delete_response->get_error_message() ), |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | gravityview()->log->debug( 'Delete entry failed: there was no entry with the entry slug {entry_slug}', array( 'entry_slug' => $entry_slug ) ); |
374 | 374 | |
375 | 375 | $messages = array( |
376 | - 'message' => urlencode( __('The entry does not exist.', 'gravityview') ), |
|
376 | + 'message' => urlencode( __( 'The entry does not exist.', 'gravityview' ) ), |
|
377 | 377 | 'status' => 'error', |
378 | 378 | ); |
379 | 379 | } |
@@ -413,18 +413,18 @@ discard block |
||
413 | 413 | */ |
414 | 414 | private function delete_or_trash_entry( $entry ) { |
415 | 415 | |
416 | - $entry_id = $entry['id']; |
|
416 | + $entry_id = $entry[ 'id' ]; |
|
417 | 417 | |
418 | 418 | $mode = $this->get_delete_mode(); |
419 | 419 | |
420 | - if( 'delete' === $mode ) { |
|
420 | + if ( 'delete' === $mode ) { |
|
421 | 421 | |
422 | 422 | gravityview()->log->debug( 'Starting delete entry: {entry_id}', array( 'entry_id' => $entry_id ) ); |
423 | 423 | |
424 | 424 | // Delete the entry |
425 | 425 | $delete_response = GFAPI::delete_entry( $entry_id ); |
426 | 426 | |
427 | - if( ! is_wp_error( $delete_response ) ) { |
|
427 | + if ( ! is_wp_error( $delete_response ) ) { |
|
428 | 428 | $delete_response = 'deleted'; |
429 | 429 | |
430 | 430 | /** |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | $trashed = GFAPI::update_entry_property( $entry_id, 'status', 'trash' ); |
446 | 446 | new GravityView_Cache; |
447 | 447 | |
448 | - if( ! $trashed ) { |
|
449 | - $delete_response = new WP_Error( 'trash_entry_failed', __('Moving the entry to the trash failed.', 'gravityview' ) ); |
|
448 | + if ( ! $trashed ) { |
|
449 | + $delete_response = new WP_Error( 'trash_entry_failed', __( 'Moving the entry to the trash failed.', 'gravityview' ) ); |
|
450 | 450 | } else { |
451 | 451 | |
452 | 452 | /** |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | public function process_connected_posts( $entry_id = 0, $entry = array() ) { |
478 | 478 | |
479 | 479 | // The entry had no connected post |
480 | - if( empty( $entry['post_id'] ) ) { |
|
480 | + if ( empty( $entry[ 'post_id' ] ) ) { |
|
481 | 481 | return; |
482 | 482 | } |
483 | 483 | |
@@ -488,19 +488,19 @@ discard block |
||
488 | 488 | */ |
489 | 489 | $delete_post = apply_filters( 'gravityview/delete-entry/delete-connected-post', true ); |
490 | 490 | |
491 | - if( false === $delete_post ) { |
|
491 | + if ( false === $delete_post ) { |
|
492 | 492 | return; |
493 | 493 | } |
494 | 494 | |
495 | 495 | $action = current_action(); |
496 | 496 | |
497 | - if( 'gravityview/delete-entry/deleted' === $action ) { |
|
498 | - $result = wp_delete_post( $entry['post_id'], true ); |
|
497 | + if ( 'gravityview/delete-entry/deleted' === $action ) { |
|
498 | + $result = wp_delete_post( $entry[ 'post_id' ], true ); |
|
499 | 499 | } else { |
500 | - $result = wp_trash_post( $entry['post_id'] ); |
|
500 | + $result = wp_trash_post( $entry[ 'post_id' ] ); |
|
501 | 501 | } |
502 | 502 | |
503 | - if( false === $result ) { |
|
503 | + if ( false === $result ) { |
|
504 | 504 | gravityview()->log->error( '(called by {action}): Error processing the Post connected to the entry.', array( 'action' => $action, 'data' => $entry ) ); |
505 | 505 | } else { |
506 | 506 | gravityview()->log->debug( '(called by {action}): Successfully processed Post connected to the entry.', array( 'action' => $action, 'data' => $entry ) ); |
@@ -516,13 +516,13 @@ discard block |
||
516 | 516 | public function verify_nonce() { |
517 | 517 | |
518 | 518 | // No delete entry request was made |
519 | - if( empty( $_GET['entry_id'] ) || empty( $_GET['delete'] ) ) { |
|
519 | + if ( empty( $_GET[ 'entry_id' ] ) || empty( $_GET[ 'delete' ] ) ) { |
|
520 | 520 | return false; |
521 | 521 | } |
522 | 522 | |
523 | - $nonce_key = self::get_nonce_key( $_GET['entry_id'] ); |
|
523 | + $nonce_key = self::get_nonce_key( $_GET[ 'entry_id' ] ); |
|
524 | 524 | |
525 | - $valid = wp_verify_nonce( $_GET['delete'], $nonce_key ); |
|
525 | + $valid = wp_verify_nonce( $_GET[ 'delete' ], $nonce_key ); |
|
526 | 526 | |
527 | 527 | /** |
528 | 528 | * @filter `gravityview/delete-entry/verify_nonce` Override Delete Entry nonce validation. Return true to declare nonce valid. |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | */ |
545 | 545 | public static function get_confirm_dialog() { |
546 | 546 | |
547 | - $confirm = __('Are you sure you want to delete this entry? This cannot be undone.', 'gravityview'); |
|
547 | + $confirm = __( 'Are you sure you want to delete this entry? This cannot be undone.', 'gravityview' ); |
|
548 | 548 | |
549 | 549 | /** |
550 | 550 | * @filter `gravityview/delete-entry/confirm-text` Modify the Delete Entry Javascript confirmation text |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | */ |
553 | 553 | $confirm = apply_filters( 'gravityview/delete-entry/confirm-text', $confirm ); |
554 | 554 | |
555 | - return 'return window.confirm(\''. esc_js( $confirm ) .'\');'; |
|
555 | + return 'return window.confirm(\'' . esc_js( $confirm ) . '\');'; |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
@@ -570,16 +570,16 @@ discard block |
||
570 | 570 | |
571 | 571 | $error = NULL; |
572 | 572 | |
573 | - if( ! $this->verify_nonce() ) { |
|
574 | - $error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview'); |
|
573 | + if ( ! $this->verify_nonce() ) { |
|
574 | + $error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview' ); |
|
575 | 575 | } |
576 | 576 | |
577 | - if( ! self::check_user_cap_delete_entry( $entry, array(), $view_id ) ) { |
|
578 | - $error = __( 'You do not have permission to delete this entry.', 'gravityview'); |
|
577 | + if ( ! self::check_user_cap_delete_entry( $entry, array(), $view_id ) ) { |
|
578 | + $error = __( 'You do not have permission to delete this entry.', 'gravityview' ); |
|
579 | 579 | } |
580 | 580 | |
581 | - if( $entry['status'] === 'trash' ) { |
|
582 | - if( 'trash' === $this->get_delete_mode() ) { |
|
581 | + if ( $entry[ 'status' ] === 'trash' ) { |
|
582 | + if ( 'trash' === $this->get_delete_mode() ) { |
|
583 | 583 | $error = __( 'The entry is already in the trash.', 'gravityview' ); |
584 | 584 | } else { |
585 | 585 | $error = __( 'You cannot delete the entry; it is already in the trash.', 'gravityview' ); |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | } |
588 | 588 | |
589 | 589 | // No errors; everything's fine here! |
590 | - if( empty( $error ) ) { |
|
590 | + if ( empty( $error ) ) { |
|
591 | 591 | return true; |
592 | 592 | } |
593 | 593 | |
@@ -616,10 +616,10 @@ discard block |
||
616 | 616 | |
617 | 617 | $current_user = wp_get_current_user(); |
618 | 618 | |
619 | - $entry_id = isset( $entry['id'] ) ? $entry['id'] : NULL; |
|
619 | + $entry_id = isset( $entry[ 'id' ] ) ? $entry[ 'id' ] : NULL; |
|
620 | 620 | |
621 | 621 | // Or if they can delete any entries (as defined in Gravity Forms), we're good. |
622 | - if( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) { |
|
622 | + if ( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) { |
|
623 | 623 | |
624 | 624 | gravityview()->log->debug( 'Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.' ); |
625 | 625 | |
@@ -628,20 +628,20 @@ discard block |
||
628 | 628 | |
629 | 629 | |
630 | 630 | // If field options are passed, check if current user can view the link |
631 | - if( !empty( $field ) ) { |
|
631 | + if ( ! empty( $field ) ) { |
|
632 | 632 | |
633 | 633 | // If capability is not defined, something is not right! |
634 | - if( empty( $field['allow_edit_cap'] ) ) { |
|
634 | + if ( empty( $field[ 'allow_edit_cap' ] ) ) { |
|
635 | 635 | |
636 | 636 | gravityview()->log->error( 'Cannot read delete entry field caps', array( 'data' => $field ) ); |
637 | 637 | |
638 | 638 | return false; |
639 | 639 | } |
640 | 640 | |
641 | - if( GVCommon::has_cap( $field['allow_edit_cap'] ) ) { |
|
641 | + if ( GVCommon::has_cap( $field[ 'allow_edit_cap' ] ) ) { |
|
642 | 642 | |
643 | 643 | // Do not return true if cap is read, as we need to check if the current user created the entry |
644 | - if( $field['allow_edit_cap'] !== 'read' ) { |
|
644 | + if ( $field[ 'allow_edit_cap' ] !== 'read' ) { |
|
645 | 645 | return true; |
646 | 646 | } |
647 | 647 | |
@@ -654,21 +654,21 @@ discard block |
||
654 | 654 | |
655 | 655 | } |
656 | 656 | |
657 | - if( !isset( $entry['created_by'] ) ) { |
|
657 | + if ( ! isset( $entry[ 'created_by' ] ) ) { |
|
658 | 658 | |
659 | - gravityview()->log->error( 'Entry `created_by` doesn\'t exist.'); |
|
659 | + gravityview()->log->error( 'Entry `created_by` doesn\'t exist.' ); |
|
660 | 660 | |
661 | 661 | return false; |
662 | 662 | } |
663 | 663 | |
664 | 664 | // Only checks user_delete view option if view is already set |
665 | - if( $view_id ) { |
|
665 | + if ( $view_id ) { |
|
666 | 666 | |
667 | 667 | $current_view = gravityview_get_current_view_data( $view_id ); |
668 | 668 | |
669 | - $user_delete = isset( $current_view['atts']['user_delete'] ) ? $current_view['atts']['user_delete'] : false; |
|
669 | + $user_delete = isset( $current_view[ 'atts' ][ 'user_delete' ] ) ? $current_view[ 'atts' ][ 'user_delete' ] : false; |
|
670 | 670 | |
671 | - if( empty( $user_delete ) ) { |
|
671 | + if ( empty( $user_delete ) ) { |
|
672 | 672 | |
673 | 673 | gravityview()->log->debug( 'User Delete is disabled. Returning false.' ); |
674 | 674 | |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | } |
678 | 678 | |
679 | 679 | // If the logged-in user is the same as the user who created the entry, we're good. |
680 | - if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) { |
|
680 | + if ( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry[ 'created_by' ] ) ) { |
|
681 | 681 | |
682 | 682 | gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id' => $current_user->ID ) ); |
683 | 683 | |
@@ -702,16 +702,16 @@ discard block |
||
702 | 702 | */ |
703 | 703 | public function display_message( $current_view_id = 0 ) { |
704 | 704 | |
705 | - if( empty( $_GET['status'] ) || ! self::verify_nonce() ) { |
|
705 | + if ( empty( $_GET[ 'status' ] ) || ! self::verify_nonce() ) { |
|
706 | 706 | return; |
707 | 707 | } |
708 | 708 | |
709 | 709 | // Entry wasn't deleted from current View |
710 | - if( isset( $_GET['view_id'] ) && intval( $_GET['view_id'] ) !== intval( $current_view_id ) ) { |
|
710 | + if ( isset( $_GET[ 'view_id' ] ) && intval( $_GET[ 'view_id' ] ) !== intval( $current_view_id ) ) { |
|
711 | 711 | return; |
712 | 712 | } |
713 | 713 | |
714 | - $status = esc_attr( $_GET['status'] ); |
|
714 | + $status = esc_attr( $_GET[ 'status' ] ); |
|
715 | 715 | $message_from_url = \GV\Utils::_GET( 'message' ); |
716 | 716 | $message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) ); |
717 | 717 | $class = ''; |
@@ -719,14 +719,14 @@ discard block |
||
719 | 719 | switch ( $status ) { |
720 | 720 | case 'error': |
721 | 721 | $class = ' gv-error error'; |
722 | - $error_message = __('There was an error deleting the entry: %s', 'gravityview'); |
|
722 | + $error_message = __( 'There was an error deleting the entry: %s', 'gravityview' ); |
|
723 | 723 | $message = sprintf( $error_message, $message_from_url ); |
724 | 724 | break; |
725 | 725 | case 'trashed': |
726 | - $message = __('The entry was successfully moved to the trash.', 'gravityview'); |
|
726 | + $message = __( 'The entry was successfully moved to the trash.', 'gravityview' ); |
|
727 | 727 | break; |
728 | 728 | default: |
729 | - $message = __('The entry was successfully deleted.', 'gravityview'); |
|
729 | + $message = __( 'The entry was successfully deleted.', 'gravityview' ); |
|
730 | 730 | break; |
731 | 731 | } |
732 | 732 | |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | $message = apply_filters( 'gravityview/delete-entry/message', esc_attr( $message ), $status, $message_from_url ); |
741 | 741 | |
742 | 742 | // DISPLAY ERROR/SUCCESS MESSAGE |
743 | - echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>'; |
|
743 | + echo '<div class="gv-notice' . esc_attr( $class ) . '">' . $message . '</div>'; |
|
744 | 744 | } |
745 | 745 | |
746 | 746 |
@@ -7,15 +7,15 @@ discard block |
||
7 | 7 | <div id="publishing-action"> |
8 | 8 | <?php |
9 | 9 | |
10 | - /** |
|
11 | - * @filter `gravityview/edit_entry/cancel_link` Modify the cancel button link URL |
|
12 | - * @since 1.11.1 |
|
13 | - * @param string $back_link Existing URL of the Cancel link |
|
14 | - * @param array $form The Gravity Forms form |
|
15 | - * @param array $entry The Gravity Forms entry |
|
16 | - * @param int $view_id The current View ID |
|
17 | - */ |
|
18 | - $back_link = apply_filters( 'gravityview/edit_entry/cancel_link', remove_query_arg( array( 'page', 'view', 'edit' ) ), $object->form, $object->entry, $object->view_id ); |
|
10 | + /** |
|
11 | + * @filter `gravityview/edit_entry/cancel_link` Modify the cancel button link URL |
|
12 | + * @since 1.11.1 |
|
13 | + * @param string $back_link Existing URL of the Cancel link |
|
14 | + * @param array $form The Gravity Forms form |
|
15 | + * @param array $entry The Gravity Forms entry |
|
16 | + * @param int $view_id The current View ID |
|
17 | + */ |
|
18 | + $back_link = apply_filters( 'gravityview/edit_entry/cancel_link', remove_query_arg( array( 'page', 'view', 'edit' ) ), $object->form, $object->entry, $object->view_id ); |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @action `gravityview/edit-entry/publishing-action/before` Triggered before the submit buttons in the Edit Entry screen, inside the `<div id="publishing-action">` container. |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * @action `gravityview/edit-entry/publishing-action/after` Triggered after the submit buttons in the Edit Entry screen, inside the `<div id="publishing-action">` container. |
55 | 55 | * @since 1.5.1 |
56 | - * @since 2.0.13 Added $post_id |
|
56 | + * @since 2.0.13 Added $post_id |
|
57 | 57 | * @param array $form The Gravity Forms form |
58 | 58 | * @param array $entry The Gravity Forms entry |
59 | 59 | * @param int $view_id The current View ID |
60 | - * @param int $post_id The current Post ID |
|
60 | + * @param int $post_id The current Post ID |
|
61 | 61 | */ |
62 | 62 | do_action( 'gravityview/edit-entry/publishing-action/after', $object->form, $object->entry, $object->view_id, $object->post_id ); |
63 | 63 |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | |
95 | 95 | /** |
96 | 96 | * ID of the current post. May also be ID of the current View. |
97 | - * |
|
98 | - * @since 2.0.13 |
|
99 | - * |
|
100 | - * @var int |
|
97 | + * |
|
98 | + * @since 2.0.13 |
|
99 | + * |
|
100 | + * @var int |
|
101 | 101 | */ |
102 | 102 | public $post_id; |
103 | 103 | |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | public function prevent_maybe_process_form() { |
170 | 170 | |
171 | 171 | if( ! empty( $_POST ) ) { |
172 | - gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
172 | + gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | if( $this->is_edit_entry_submission() ) { |
176 | 176 | remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -202,14 +202,14 @@ discard block |
||
202 | 202 | * When Edit entry view is requested setup the vars |
203 | 203 | */ |
204 | 204 | private function setup_vars() { |
205 | - global $post; |
|
205 | + global $post; |
|
206 | 206 | |
207 | 207 | $gravityview_view = GravityView_View::getInstance(); |
208 | 208 | |
209 | 209 | |
210 | 210 | $entries = $gravityview_view->getEntries(); |
211 | - self::$original_entry = $entries[0]; |
|
212 | - $this->entry = $entries[0]; |
|
211 | + self::$original_entry = $entries[0]; |
|
212 | + $this->entry = $entries[0]; |
|
213 | 213 | |
214 | 214 | self::$original_form = $gravityview_view->getForm(); |
215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -331,8 +331,8 @@ discard block |
||
331 | 331 | |
332 | 332 | GFFormsModel::save_lead( $form, $this->entry ); |
333 | 333 | |
334 | - // Delete the values for hidden inputs |
|
335 | - $this->unset_hidden_field_values(); |
|
334 | + // Delete the values for hidden inputs |
|
335 | + $this->unset_hidden_field_values(); |
|
336 | 336 | |
337 | 337 | $this->entry['date_created'] = $date_created; |
338 | 338 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | // Perform actions normally performed after updating a lead |
343 | 343 | $this->after_update(); |
344 | 344 | |
345 | - /** |
|
345 | + /** |
|
346 | 346 | * Must be AFTER after_update()! |
347 | 347 | * @see https://github.com/gravityview/GravityView/issues/764 |
348 | 348 | */ |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * @return void |
373 | 373 | */ |
374 | 374 | private function unset_hidden_field_values() { |
375 | - global $wpdb; |
|
375 | + global $wpdb; |
|
376 | 376 | |
377 | 377 | /** |
378 | 378 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -394,27 +394,27 @@ discard block |
||
394 | 394 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
395 | 395 | } |
396 | 396 | |
397 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
397 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
398 | 398 | |
399 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
399 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
400 | 400 | |
401 | - // Reset fields that are hidden |
|
402 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
403 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
401 | + // Reset fields that are hidden |
|
402 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
403 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
404 | 404 | |
405 | - // List fields are stored as empty arrays when empty |
|
406 | - $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
405 | + // List fields are stored as empty arrays when empty |
|
406 | + $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
407 | 407 | |
408 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
408 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
409 | 409 | |
410 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
410 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
411 | 411 | |
412 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
412 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
413 | 413 | // after submission |
414 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
415 | - $_POST[ $post_input_id ] = ''; |
|
416 | - } |
|
417 | - } |
|
414 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
415 | + $_POST[ $post_input_id ] = ''; |
|
416 | + } |
|
417 | + } |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | |
509 | 509 | $form = $this->form; |
510 | 510 | |
511 | - /** @var GF_Field $field */ |
|
511 | + /** @var GF_Field $field */ |
|
512 | 512 | foreach( $form['fields'] as $k => &$field ) { |
513 | 513 | |
514 | 514 | /** |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | |
525 | 525 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
526 | 526 | foreach( $field->inputs as $key => $input ) { |
527 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
527 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
528 | 528 | } |
529 | 529 | } |
530 | 530 | } |
@@ -545,13 +545,13 @@ discard block |
||
545 | 545 | foreach ( $this->fields_with_calculation as $calc_field ) { |
546 | 546 | $inputs = $calc_field->get_entry_inputs(); |
547 | 547 | if ( is_array( $inputs ) ) { |
548 | - foreach ( $inputs as $input ) { |
|
549 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
550 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
551 | - } |
|
548 | + foreach ( $inputs as $input ) { |
|
549 | + $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
550 | + $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
551 | + } |
|
552 | 552 | } else { |
553 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
554 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
553 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
554 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
555 | 555 | } |
556 | 556 | } |
557 | 557 | |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
600 | 600 | |
601 | 601 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
602 | - $ary = stripslashes_deep( $ary ); |
|
602 | + $ary = stripslashes_deep( $ary ); |
|
603 | 603 | $img_url = \GV\Utils::get( $ary, 0 ); |
604 | 604 | |
605 | 605 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | private function maybe_update_post_fields( $form ) { |
673 | 673 | |
674 | 674 | if( empty( $this->entry['post_id'] ) ) { |
675 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
675 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
676 | 676 | return; |
677 | 677 | } |
678 | 678 | |
@@ -707,51 +707,51 @@ discard block |
||
707 | 707 | |
708 | 708 | switch( $field->type ) { |
709 | 709 | |
710 | - case 'post_title': |
|
711 | - $post_title = $value; |
|
712 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
713 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
714 | - } |
|
715 | - $updated_post->post_title = $post_title; |
|
716 | - $updated_post->post_name = $post_title; |
|
717 | - unset( $post_title ); |
|
718 | - break; |
|
719 | - |
|
720 | - case 'post_content': |
|
721 | - $post_content = $value; |
|
722 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
723 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
724 | - } |
|
725 | - $updated_post->post_content = $post_content; |
|
726 | - unset( $post_content ); |
|
727 | - break; |
|
728 | - case 'post_excerpt': |
|
729 | - $updated_post->post_excerpt = $value; |
|
730 | - break; |
|
731 | - case 'post_tags': |
|
732 | - wp_set_post_tags( $post_id, $value, false ); |
|
733 | - break; |
|
734 | - case 'post_category': |
|
735 | - break; |
|
736 | - case 'post_custom_field': |
|
710 | + case 'post_title': |
|
711 | + $post_title = $value; |
|
712 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
713 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
714 | + } |
|
715 | + $updated_post->post_title = $post_title; |
|
716 | + $updated_post->post_name = $post_title; |
|
717 | + unset( $post_title ); |
|
718 | + break; |
|
719 | + |
|
720 | + case 'post_content': |
|
721 | + $post_content = $value; |
|
722 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
723 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
724 | + } |
|
725 | + $updated_post->post_content = $post_content; |
|
726 | + unset( $post_content ); |
|
727 | + break; |
|
728 | + case 'post_excerpt': |
|
729 | + $updated_post->post_excerpt = $value; |
|
730 | + break; |
|
731 | + case 'post_tags': |
|
732 | + wp_set_post_tags( $post_id, $value, false ); |
|
733 | + break; |
|
734 | + case 'post_category': |
|
735 | + break; |
|
736 | + case 'post_custom_field': |
|
737 | 737 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
738 | 738 | $value = $value[ $field_id ]; |
739 | 739 | } |
740 | 740 | |
741 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
742 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
743 | - } |
|
741 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
742 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
743 | + } |
|
744 | 744 | |
745 | - if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
746 | - $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
747 | - } |
|
745 | + if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
746 | + $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
747 | + } |
|
748 | 748 | |
749 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
750 | - break; |
|
749 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
750 | + break; |
|
751 | 751 | |
752 | - case 'post_image': |
|
753 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
754 | - break; |
|
752 | + case 'post_image': |
|
753 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
754 | + break; |
|
755 | 755 | |
756 | 756 | } |
757 | 757 | |
@@ -796,20 +796,20 @@ discard block |
||
796 | 796 | */ |
797 | 797 | private function is_field_json_encoded( $field ) { |
798 | 798 | |
799 | - $json_encoded = false; |
|
799 | + $json_encoded = false; |
|
800 | 800 | |
801 | 801 | $input_type = RGFormsModel::get_input_type( $field ); |
802 | 802 | |
803 | - // Only certain custom field types are supported |
|
804 | - switch( $input_type ) { |
|
805 | - case 'fileupload': |
|
806 | - case 'list': |
|
807 | - case 'multiselect': |
|
808 | - $json_encoded = true; |
|
809 | - break; |
|
810 | - } |
|
803 | + // Only certain custom field types are supported |
|
804 | + switch( $input_type ) { |
|
805 | + case 'fileupload': |
|
806 | + case 'list': |
|
807 | + case 'multiselect': |
|
808 | + $json_encoded = true; |
|
809 | + break; |
|
810 | + } |
|
811 | 811 | |
812 | - return $json_encoded; |
|
812 | + return $json_encoded; |
|
813 | 813 | } |
814 | 814 | |
815 | 815 | /** |
@@ -899,14 +899,14 @@ discard block |
||
899 | 899 | ?><h2 class="gv-edit-entry-title"> |
900 | 900 | <span><?php |
901 | 901 | |
902 | - /** |
|
903 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
904 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
905 | - * @param GravityView_Edit_Entry_Render $this This object |
|
906 | - */ |
|
907 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
902 | + /** |
|
903 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
904 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
905 | + * @param GravityView_Edit_Entry_Render $this This object |
|
906 | + */ |
|
907 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
908 | 908 | |
909 | - echo esc_attr( $edit_entry_title ); |
|
909 | + echo esc_attr( $edit_entry_title ); |
|
910 | 910 | ?></span> |
911 | 911 | </h2> |
912 | 912 | |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | |
1016 | 1016 | ob_get_clean(); |
1017 | 1017 | |
1018 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1018 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1019 | 1019 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
1020 | 1020 | remove_filter( 'gform_disable_view_counter', '__return_true' ); |
1021 | 1021 | remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 ); |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | |
1070 | 1070 | // for now we don't support Save and Continue feature. |
1071 | 1071 | if( ! self::$supports_save_and_continue ) { |
1072 | - unset( $form['save'] ); |
|
1072 | + unset( $form['save'] ); |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | return $form; |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | || ! empty( $field_content ) |
1145 | 1145 | || in_array( $field->type, array( 'honeypot' ) ) |
1146 | 1146 | ) { |
1147 | - return $field_content; |
|
1147 | + return $field_content; |
|
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1152,24 +1152,24 @@ discard block |
||
1152 | 1152 | |
1153 | 1153 | $field_value = $this->get_field_value( $field ); |
1154 | 1154 | |
1155 | - // Prevent any PHP warnings, like undefined index |
|
1156 | - ob_start(); |
|
1155 | + // Prevent any PHP warnings, like undefined index |
|
1156 | + ob_start(); |
|
1157 | 1157 | |
1158 | - $return = null; |
|
1158 | + $return = null; |
|
1159 | 1159 | |
1160 | 1160 | /** @var GravityView_Field $gv_field */ |
1161 | 1161 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
1162 | 1162 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1163 | 1163 | } else { |
1164 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1165 | - } |
|
1164 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1165 | + } |
|
1166 | 1166 | |
1167 | - // If there was output, it's an error |
|
1168 | - $warnings = ob_get_clean(); |
|
1167 | + // If there was output, it's an error |
|
1168 | + $warnings = ob_get_clean(); |
|
1169 | 1169 | |
1170 | - if( !empty( $warnings ) ) { |
|
1171 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1172 | - } |
|
1170 | + if( !empty( $warnings ) ) { |
|
1171 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1172 | + } |
|
1173 | 1173 | |
1174 | 1174 | return $return; |
1175 | 1175 | } |
@@ -1204,8 +1204,8 @@ discard block |
||
1204 | 1204 | $input_id = strval( $input['id'] ); |
1205 | 1205 | |
1206 | 1206 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1207 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1208 | - $allow_pre_populated = false; |
|
1207 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1208 | + $allow_pre_populated = false; |
|
1209 | 1209 | } |
1210 | 1210 | |
1211 | 1211 | } |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
1230 | 1230 | $categories = array(); |
1231 | 1231 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1232 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1232 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1233 | 1233 | } |
1234 | 1234 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1235 | 1235 | } |
@@ -1239,25 +1239,25 @@ discard block |
||
1239 | 1239 | // if value is empty get the default value if defined |
1240 | 1240 | $field_value = $field->get_value_default_if_empty( $field_value ); |
1241 | 1241 | |
1242 | - /** |
|
1243 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1244 | - * @since 1.11 |
|
1245 | - * @since 1.20 Added third param |
|
1246 | - * @param mixed $field_value field value used to populate the input |
|
1247 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1248 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1249 | - */ |
|
1250 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1251 | - |
|
1252 | - /** |
|
1253 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1254 | - * @since 1.17 |
|
1255 | - * @since 1.20 Added third param |
|
1256 | - * @param mixed $field_value field value used to populate the input |
|
1257 | - * @param GF_Field $field Gravity Forms field object |
|
1258 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1259 | - */ |
|
1260 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1242 | + /** |
|
1243 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1244 | + * @since 1.11 |
|
1245 | + * @since 1.20 Added third param |
|
1246 | + * @param mixed $field_value field value used to populate the input |
|
1247 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1248 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1249 | + */ |
|
1250 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1251 | + |
|
1252 | + /** |
|
1253 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1254 | + * @since 1.17 |
|
1255 | + * @since 1.20 Added third param |
|
1256 | + * @param mixed $field_value field value used to populate the input |
|
1257 | + * @param GF_Field $field Gravity Forms field object |
|
1258 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1259 | + */ |
|
1260 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1261 | 1261 | |
1262 | 1262 | return $field_value; |
1263 | 1263 | } |
@@ -1284,7 +1284,7 @@ discard block |
||
1284 | 1284 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1285 | 1285 | // expects certain field array items to be set. |
1286 | 1286 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
1287 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1287 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1288 | 1288 | } |
1289 | 1289 | |
1290 | 1290 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1298,61 +1298,61 @@ discard block |
||
1298 | 1298 | */ |
1299 | 1299 | case 'fileupload': |
1300 | 1300 | |
1301 | - // Set the previous value |
|
1302 | - $entry = $this->get_entry(); |
|
1301 | + // Set the previous value |
|
1302 | + $entry = $this->get_entry(); |
|
1303 | 1303 | |
1304 | - $input_name = 'input_'.$field->id; |
|
1305 | - $form_id = $form['id']; |
|
1304 | + $input_name = 'input_'.$field->id; |
|
1305 | + $form_id = $form['id']; |
|
1306 | 1306 | |
1307 | - $value = NULL; |
|
1307 | + $value = NULL; |
|
1308 | 1308 | |
1309 | - // Use the previous entry value as the default. |
|
1310 | - if( isset( $entry[ $field->id ] ) ) { |
|
1311 | - $value = $entry[ $field->id ]; |
|
1312 | - } |
|
1309 | + // Use the previous entry value as the default. |
|
1310 | + if( isset( $entry[ $field->id ] ) ) { |
|
1311 | + $value = $entry[ $field->id ]; |
|
1312 | + } |
|
1313 | 1313 | |
1314 | - // If this is a single upload file |
|
1315 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1316 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1317 | - $value = $file_path['url']; |
|
1314 | + // If this is a single upload file |
|
1315 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1316 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1317 | + $value = $file_path['url']; |
|
1318 | 1318 | |
1319 | - } else { |
|
1319 | + } else { |
|
1320 | 1320 | |
1321 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1322 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1323 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1321 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1322 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1323 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1324 | 1324 | |
1325 | - } |
|
1325 | + } |
|
1326 | 1326 | |
1327 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1327 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1328 | 1328 | |
1329 | - // If there are fresh uploads, process and merge them. |
|
1330 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1331 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1332 | - $value = empty( $value ) ? '[]' : $value; |
|
1333 | - $value = stripslashes_deep( $value ); |
|
1334 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1335 | - } |
|
1329 | + // If there are fresh uploads, process and merge them. |
|
1330 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1331 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1332 | + $value = empty( $value ) ? '[]' : $value; |
|
1333 | + $value = stripslashes_deep( $value ); |
|
1334 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1335 | + } |
|
1336 | 1336 | |
1337 | - } else { |
|
1337 | + } else { |
|
1338 | 1338 | |
1339 | - // A file already exists when editing an entry |
|
1340 | - // We set this to solve issue when file upload fields are required. |
|
1341 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1339 | + // A file already exists when editing an entry |
|
1340 | + // We set this to solve issue when file upload fields are required. |
|
1341 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1342 | 1342 | |
1343 | - } |
|
1343 | + } |
|
1344 | 1344 | |
1345 | - $this->entry[ $input_name ] = $value; |
|
1346 | - $_POST[ $input_name ] = $value; |
|
1345 | + $this->entry[ $input_name ] = $value; |
|
1346 | + $_POST[ $input_name ] = $value; |
|
1347 | 1347 | |
1348 | - break; |
|
1348 | + break; |
|
1349 | 1349 | |
1350 | 1350 | case 'number': |
1351 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
1352 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1353 | - $_POST['input_'.$field->id ] = NULL; |
|
1354 | - } |
|
1355 | - break; |
|
1351 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
1352 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1353 | + $_POST['input_'.$field->id ] = NULL; |
|
1354 | + } |
|
1355 | + break; |
|
1356 | 1356 | } |
1357 | 1357 | |
1358 | 1358 | } |
@@ -1437,42 +1437,42 @@ discard block |
||
1437 | 1437 | case 'fileupload' : |
1438 | 1438 | case 'post_image': |
1439 | 1439 | |
1440 | - // in case nothing is uploaded but there are already files saved |
|
1441 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1442 | - $field->failed_validation = false; |
|
1443 | - unset( $field->validation_message ); |
|
1444 | - } |
|
1440 | + // in case nothing is uploaded but there are already files saved |
|
1441 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1442 | + $field->failed_validation = false; |
|
1443 | + unset( $field->validation_message ); |
|
1444 | + } |
|
1445 | 1445 | |
1446 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1447 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1446 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1447 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1448 | 1448 | |
1449 | - $input_name = 'input_' . $field->id; |
|
1450 | - //uploaded |
|
1451 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1449 | + $input_name = 'input_' . $field->id; |
|
1450 | + //uploaded |
|
1451 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1452 | 1452 | |
1453 | - //existent |
|
1454 | - $entry = $this->get_entry(); |
|
1455 | - $value = NULL; |
|
1456 | - if( isset( $entry[ $field->id ] ) ) { |
|
1457 | - $value = json_decode( $entry[ $field->id ], true ); |
|
1458 | - } |
|
1453 | + //existent |
|
1454 | + $entry = $this->get_entry(); |
|
1455 | + $value = NULL; |
|
1456 | + if( isset( $entry[ $field->id ] ) ) { |
|
1457 | + $value = json_decode( $entry[ $field->id ], true ); |
|
1458 | + } |
|
1459 | 1459 | |
1460 | - // count uploaded files and existent entry files |
|
1461 | - $count_files = count( $file_names ) + count( $value ); |
|
1460 | + // count uploaded files and existent entry files |
|
1461 | + $count_files = count( $file_names ) + count( $value ); |
|
1462 | 1462 | |
1463 | - if( $count_files > $field->maxFiles ) { |
|
1464 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1465 | - $field->failed_validation = 1; |
|
1466 | - $gv_valid = false; |
|
1463 | + if( $count_files > $field->maxFiles ) { |
|
1464 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1465 | + $field->failed_validation = 1; |
|
1466 | + $gv_valid = false; |
|
1467 | 1467 | |
1468 | - // in case of error make sure the newest upload files are removed from the upload input |
|
1469 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1470 | - } |
|
1468 | + // in case of error make sure the newest upload files are removed from the upload input |
|
1469 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1470 | + } |
|
1471 | 1471 | |
1472 | - } |
|
1472 | + } |
|
1473 | 1473 | |
1474 | 1474 | |
1475 | - break; |
|
1475 | + break; |
|
1476 | 1476 | |
1477 | 1477 | } |
1478 | 1478 | |
@@ -1483,47 +1483,47 @@ discard block |
||
1483 | 1483 | |
1484 | 1484 | switch ( $field_type ) { |
1485 | 1485 | |
1486 | - // Captchas don't need to be re-entered. |
|
1487 | - case 'captcha': |
|
1486 | + // Captchas don't need to be re-entered. |
|
1487 | + case 'captcha': |
|
1488 | 1488 | |
1489 | - // Post Image fields aren't editable, so we un-fail them. |
|
1490 | - case 'post_image': |
|
1491 | - $field->failed_validation = false; |
|
1492 | - unset( $field->validation_message ); |
|
1493 | - break; |
|
1489 | + // Post Image fields aren't editable, so we un-fail them. |
|
1490 | + case 'post_image': |
|
1491 | + $field->failed_validation = false; |
|
1492 | + unset( $field->validation_message ); |
|
1493 | + break; |
|
1494 | 1494 | |
1495 | 1495 | } |
1496 | 1496 | |
1497 | 1497 | // You can't continue inside a switch, so we do it after. |
1498 | 1498 | if( empty( $field->failed_validation ) ) { |
1499 | - continue; |
|
1499 | + continue; |
|
1500 | 1500 | } |
1501 | 1501 | |
1502 | 1502 | // checks if the No Duplicates option is not validating entry against itself, since |
1503 | 1503 | // we're editing a stored entry, it would also assume it's a duplicate. |
1504 | 1504 | if( !empty( $field->noDuplicates ) ) { |
1505 | 1505 | |
1506 | - $entry = $this->get_entry(); |
|
1506 | + $entry = $this->get_entry(); |
|
1507 | 1507 | |
1508 | - // If the value of the entry is the same as the stored value |
|
1509 | - // Then we can assume it's not a duplicate, it's the same. |
|
1510 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1511 | - //if value submitted was not changed, then don't validate |
|
1512 | - $field->failed_validation = false; |
|
1508 | + // If the value of the entry is the same as the stored value |
|
1509 | + // Then we can assume it's not a duplicate, it's the same. |
|
1510 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1511 | + //if value submitted was not changed, then don't validate |
|
1512 | + $field->failed_validation = false; |
|
1513 | 1513 | |
1514 | - unset( $field->validation_message ); |
|
1514 | + unset( $field->validation_message ); |
|
1515 | 1515 | |
1516 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1516 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1517 | 1517 | |
1518 | - continue; |
|
1519 | - } |
|
1518 | + continue; |
|
1519 | + } |
|
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1523 | 1523 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
1524 | - unset( $field->validation_message ); |
|
1525 | - $field->validation_message = false; |
|
1526 | - continue; |
|
1524 | + unset( $field->validation_message ); |
|
1525 | + $field->validation_message = false; |
|
1526 | + continue; |
|
1527 | 1527 | } |
1528 | 1528 | |
1529 | 1529 | $gv_valid = false; |
@@ -1587,8 +1587,8 @@ discard block |
||
1587 | 1587 | // Hide fields depending on admin settings |
1588 | 1588 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
1589 | 1589 | |
1590 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1591 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1590 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1591 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1592 | 1592 | |
1593 | 1593 | /** |
1594 | 1594 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1648,11 +1648,11 @@ discard block |
||
1648 | 1648 | // The edit tab has been configured, so we loop through to configured settings |
1649 | 1649 | foreach ( $configured_fields as $configured_field ) { |
1650 | 1650 | |
1651 | - /** @var GF_Field $field */ |
|
1652 | - foreach ( $fields as $field ) { |
|
1651 | + /** @var GF_Field $field */ |
|
1652 | + foreach ( $fields as $field ) { |
|
1653 | 1653 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
1654 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1655 | - break; |
|
1654 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1655 | + break; |
|
1656 | 1656 | } |
1657 | 1657 | |
1658 | 1658 | } |
@@ -1708,28 +1708,28 @@ discard block |
||
1708 | 1708 | */ |
1709 | 1709 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
1710 | 1710 | |
1711 | - /** |
|
1711 | + /** |
|
1712 | 1712 | * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true |
1713 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1714 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1715 | - * @since 1.9.1 |
|
1716 | - * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
1717 | - * @param array $form GF Form array |
|
1718 | - * @param int $view_id View ID |
|
1719 | - */ |
|
1720 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1721 | - |
|
1722 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1713 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1714 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1715 | + * @since 1.9.1 |
|
1716 | + * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
1717 | + * @param array $form GF Form array |
|
1718 | + * @param int $view_id View ID |
|
1719 | + */ |
|
1720 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1721 | + |
|
1722 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1723 | 1723 | foreach( $fields as $k => $field ) { |
1724 | 1724 | if( $field->adminOnly ) { |
1725 | - unset( $fields[ $k ] ); |
|
1725 | + unset( $fields[ $k ] ); |
|
1726 | 1726 | } |
1727 | 1727 | } |
1728 | 1728 | return $fields; |
1729 | 1729 | } |
1730 | 1730 | |
1731 | - foreach( $fields as &$field ) { |
|
1732 | - $field->adminOnly = false; |
|
1731 | + foreach( $fields as &$field ) { |
|
1732 | + $field->adminOnly = false; |
|
1733 | 1733 | } |
1734 | 1734 | |
1735 | 1735 | return $fields; |
@@ -1762,36 +1762,36 @@ discard block |
||
1762 | 1762 | |
1763 | 1763 | if( 'checkbox' === $field->type ) { |
1764 | 1764 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1765 | - $input_id = $input['id']; |
|
1766 | - $choice = $field->choices[ $key ]; |
|
1767 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1768 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1769 | - if( $match ) { |
|
1770 | - $field->choices[ $key ]['isSelected'] = true; |
|
1771 | - } |
|
1765 | + $input_id = $input['id']; |
|
1766 | + $choice = $field->choices[ $key ]; |
|
1767 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1768 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1769 | + if( $match ) { |
|
1770 | + $field->choices[ $key ]['isSelected'] = true; |
|
1771 | + } |
|
1772 | 1772 | } |
1773 | 1773 | } else { |
1774 | 1774 | |
1775 | 1775 | // We need to run through each field to set the default values |
1776 | 1776 | foreach ( $this->entry as $field_id => $field_value ) { |
1777 | 1777 | |
1778 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1778 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1779 | 1779 | |
1780 | - if( 'list' === $field->type ) { |
|
1781 | - $list_rows = maybe_unserialize( $field_value ); |
|
1780 | + if( 'list' === $field->type ) { |
|
1781 | + $list_rows = maybe_unserialize( $field_value ); |
|
1782 | 1782 | |
1783 | - $list_field_value = array(); |
|
1784 | - foreach ( (array) $list_rows as $row ) { |
|
1785 | - foreach ( (array) $row as $column ) { |
|
1786 | - $list_field_value[] = $column; |
|
1787 | - } |
|
1788 | - } |
|
1783 | + $list_field_value = array(); |
|
1784 | + foreach ( (array) $list_rows as $row ) { |
|
1785 | + foreach ( (array) $row as $column ) { |
|
1786 | + $list_field_value[] = $column; |
|
1787 | + } |
|
1788 | + } |
|
1789 | 1789 | |
1790 | - $field->defaultValue = serialize( $list_field_value ); |
|
1791 | - } else { |
|
1792 | - $field->defaultValue = $field_value; |
|
1793 | - } |
|
1794 | - } |
|
1790 | + $field->defaultValue = serialize( $list_field_value ); |
|
1791 | + } else { |
|
1792 | + $field->defaultValue = $field_value; |
|
1793 | + } |
|
1794 | + } |
|
1795 | 1795 | } |
1796 | 1796 | } |
1797 | 1797 | } |
@@ -1848,7 +1848,7 @@ discard block |
||
1848 | 1848 | return $has_conditional_logic; |
1849 | 1849 | } |
1850 | 1850 | |
1851 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
1851 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
1852 | 1852 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
1853 | 1853 | } |
1854 | 1854 | |
@@ -1915,14 +1915,14 @@ discard block |
||
1915 | 1915 | |
1916 | 1916 | if( $echo && $error !== true ) { |
1917 | 1917 | |
1918 | - $error = esc_html( $error ); |
|
1918 | + $error = esc_html( $error ); |
|
1919 | 1919 | |
1920 | - /** |
|
1921 | - * @since 1.9 |
|
1922 | - */ |
|
1923 | - if ( ! empty( $this->entry ) ) { |
|
1924 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1925 | - } |
|
1920 | + /** |
|
1921 | + * @since 1.9 |
|
1922 | + */ |
|
1923 | + if ( ! empty( $this->entry ) ) { |
|
1924 | + $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1925 | + } |
|
1926 | 1926 | |
1927 | 1927 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
1928 | 1928 | } |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | function load() { |
116 | 116 | |
117 | 117 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
118 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
118 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
119 | 119 | |
120 | 120 | // Don't display an embedded form when editing an entry |
121 | 121 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
122 | 122 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
123 | 123 | |
124 | 124 | // Stop Gravity Forms processing what is ours! |
125 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
125 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
126 | 126 | |
127 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
127 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
128 | 128 | |
129 | 129 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
130 | 130 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
136 | 136 | |
137 | 137 | // Add fields expected by GFFormDisplay::validate() |
138 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
138 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
139 | 139 | |
140 | 140 | // Fix multiselect value for GF 2.2 |
141 | 141 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * @return void |
153 | 153 | */ |
154 | 154 | public function prevent_render_form() { |
155 | - if( $this->is_edit_entry() ) { |
|
156 | - if( 'wp_head' === current_filter() ) { |
|
155 | + if ( $this->is_edit_entry() ) { |
|
156 | + if ( 'wp_head' === current_filter() ) { |
|
157 | 157 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
158 | 158 | } else { |
159 | 159 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -168,13 +168,13 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function prevent_maybe_process_form() { |
170 | 170 | |
171 | - if( ! empty( $_POST ) ) { |
|
171 | + if ( ! empty( $_POST ) ) { |
|
172 | 172 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
173 | 173 | } |
174 | 174 | |
175 | - if( $this->is_edit_entry_submission() ) { |
|
176 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
175 | + if ( $this->is_edit_entry_submission() ) { |
|
176 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function is_edit_entry() { |
186 | 186 | |
187 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
187 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
188 | 188 | |
189 | 189 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
190 | 190 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @return boolean |
196 | 196 | */ |
197 | 197 | public function is_edit_entry_submission() { |
198 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
198 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | |
209 | 209 | |
210 | 210 | $entries = $gravityview_view->getEntries(); |
211 | - self::$original_entry = $entries[0]; |
|
212 | - $this->entry = $entries[0]; |
|
211 | + self::$original_entry = $entries[ 0 ]; |
|
212 | + $this->entry = $entries[ 0 ]; |
|
213 | 213 | |
214 | 214 | self::$original_form = $gravityview_view->getForm(); |
215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $this->view_id = $gravityview_view->getViewId(); |
218 | 218 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
219 | 219 | |
220 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
220 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | } |
242 | 242 | |
243 | 243 | // Multiple Views embedded, don't proceed if nonce fails |
244 | - if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) { |
|
244 | + if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) { |
|
245 | 245 | gravityview()->log->error( 'Nonce validation failed for the Edit Entry request; returning' ); |
246 | 246 | return; |
247 | 247 | } |
248 | 248 | |
249 | 249 | // Sorry, you're not allowed here. |
250 | - if( false === $this->user_can_edit_entry( true ) ) { |
|
250 | + if ( false === $this->user_can_edit_entry( true ) ) { |
|
251 | 251 | gravityview()->log->error( 'User is not allowed to edit this entry; returning', array( 'data' => $this->entry ) ); |
252 | 252 | return; |
253 | 253 | } |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | private function print_scripts() { |
269 | 269 | $gravityview_view = GravityView_View::getInstance(); |
270 | 270 | |
271 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
271 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
272 | 272 | |
273 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
273 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
274 | 274 | |
275 | 275 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
276 | 276 | |
@@ -284,19 +284,19 @@ discard block |
||
284 | 284 | */ |
285 | 285 | private function process_save() { |
286 | 286 | |
287 | - if( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
287 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
288 | 288 | return; |
289 | 289 | } |
290 | 290 | |
291 | 291 | // Make sure the entry, view, and form IDs are all correct |
292 | 292 | $valid = $this->verify_nonce(); |
293 | 293 | |
294 | - if( !$valid ) { |
|
294 | + if ( ! $valid ) { |
|
295 | 295 | gravityview()->log->error( 'Nonce validation failed.' ); |
296 | 296 | return; |
297 | 297 | } |
298 | 298 | |
299 | - if( $this->entry['id'] !== $_POST['lid'] ) { |
|
299 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
300 | 300 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
301 | 301 | return; |
302 | 302 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | |
308 | 308 | $this->validate(); |
309 | 309 | |
310 | - if( $this->is_valid ) { |
|
310 | + if ( $this->is_valid ) { |
|
311 | 311 | |
312 | 312 | gravityview()->log->debug( 'Submission is valid.' ); |
313 | 313 | |
@@ -319,22 +319,22 @@ discard block |
||
319 | 319 | /** |
320 | 320 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
321 | 321 | */ |
322 | - unset( $_GET['page'] ); |
|
322 | + unset( $_GET[ 'page' ] ); |
|
323 | 323 | |
324 | - $date_created = $this->entry['date_created']; |
|
324 | + $date_created = $this->entry[ 'date_created' ]; |
|
325 | 325 | |
326 | 326 | /** |
327 | 327 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
328 | 328 | * @since 1.17.2 |
329 | 329 | */ |
330 | - unset( $this->entry['date_created'] ); |
|
330 | + unset( $this->entry[ 'date_created' ] ); |
|
331 | 331 | |
332 | 332 | GFFormsModel::save_lead( $form, $this->entry ); |
333 | 333 | |
334 | 334 | // Delete the values for hidden inputs |
335 | 335 | $this->unset_hidden_field_values(); |
336 | 336 | |
337 | - $this->entry['date_created'] = $date_created; |
|
337 | + $this->entry[ 'date_created' ] = $date_created; |
|
338 | 338 | |
339 | 339 | // Process calculation fields |
340 | 340 | $this->update_calculation_fields(); |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * @param string $entry_id Numeric ID of the entry that was updated |
355 | 355 | * @param GravityView_Edit_Entry_Render $this This object |
356 | 356 | */ |
357 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this ); |
|
357 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this ); |
|
358 | 358 | |
359 | 359 | } else { |
360 | 360 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -382,16 +382,16 @@ discard block |
||
382 | 382 | */ |
383 | 383 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
384 | 384 | |
385 | - if( ! $unset_hidden_field_values ) { |
|
385 | + if ( ! $unset_hidden_field_values ) { |
|
386 | 386 | return; |
387 | 387 | } |
388 | 388 | |
389 | 389 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
390 | 390 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
391 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
391 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
392 | 392 | } else { |
393 | 393 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
394 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
394 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | } |
473 | 473 | |
474 | 474 | /** No file is being uploaded. */ |
475 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
475 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
476 | 476 | /** So return the original upload */ |
477 | 477 | return $entry[ $input_id ]; |
478 | 478 | } |
@@ -490,11 +490,11 @@ discard block |
||
490 | 490 | * @return mixed |
491 | 491 | */ |
492 | 492 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
493 | - if( ! $this->is_edit_entry() ) { |
|
493 | + if ( ! $this->is_edit_entry() ) { |
|
494 | 494 | return $plupload_init; |
495 | 495 | } |
496 | 496 | |
497 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
497 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
498 | 498 | |
499 | 499 | return $plupload_init; |
500 | 500 | } |
@@ -509,22 +509,22 @@ discard block |
||
509 | 509 | $form = $this->form; |
510 | 510 | |
511 | 511 | /** @var GF_Field $field */ |
512 | - foreach( $form['fields'] as $k => &$field ) { |
|
512 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
513 | 513 | |
514 | 514 | /** |
515 | 515 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
516 | 516 | * @since 1.16.3 |
517 | 517 | * @var GF_Field $field |
518 | 518 | */ |
519 | - if( $field->has_calculation() ) { |
|
520 | - unset( $form['fields'][ $k ] ); |
|
519 | + if ( $field->has_calculation() ) { |
|
520 | + unset( $form[ 'fields' ][ $k ] ); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | $field->adminOnly = false; |
524 | 524 | |
525 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
526 | - foreach( $field->inputs as $key => $input ) { |
|
527 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
525 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
526 | + foreach ( $field->inputs as $key => $input ) { |
|
527 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
528 | 528 | } |
529 | 529 | } |
530 | 530 | } |
@@ -538,30 +538,30 @@ discard block |
||
538 | 538 | $update = false; |
539 | 539 | |
540 | 540 | // get the most up to date entry values |
541 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
541 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
542 | 542 | |
543 | - if( !empty( $this->fields_with_calculation ) ) { |
|
543 | + if ( ! empty( $this->fields_with_calculation ) ) { |
|
544 | 544 | $update = true; |
545 | 545 | foreach ( $this->fields_with_calculation as $calc_field ) { |
546 | 546 | $inputs = $calc_field->get_entry_inputs(); |
547 | 547 | if ( is_array( $inputs ) ) { |
548 | 548 | foreach ( $inputs as $input ) { |
549 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
550 | - $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
549 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
550 | + $entry[ strval( $input[ 'id' ] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
551 | 551 | } |
552 | 552 | } else { |
553 | - $input_name = 'input_' . str_replace( '.', '_', $calc_field->id); |
|
554 | - $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry ); |
|
553 | + $input_name = 'input_' . str_replace( '.', '_', $calc_field->id ); |
|
554 | + $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry[ 'id' ], $entry ); |
|
555 | 555 | } |
556 | 556 | } |
557 | 557 | |
558 | 558 | } |
559 | 559 | |
560 | - if( $update ) { |
|
560 | + if ( $update ) { |
|
561 | 561 | |
562 | 562 | $return_entry = GFAPI::update_entry( $entry ); |
563 | 563 | |
564 | - if( is_wp_error( $return_entry ) ) { |
|
564 | + if ( is_wp_error( $return_entry ) ) { |
|
565 | 565 | gravityview()->log->error( 'Updating the entry calculation fields failed', array( 'data' => $return_entry ) ); |
566 | 566 | } else { |
567 | 567 | gravityview()->log->debug( 'Updating the entry calculation fields succeeded' ); |
@@ -592,19 +592,19 @@ discard block |
||
592 | 592 | |
593 | 593 | $input_name = 'input_' . $field_id; |
594 | 594 | |
595 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
595 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
596 | 596 | |
597 | 597 | // We have a new image |
598 | 598 | |
599 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
599 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
600 | 600 | |
601 | 601 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
602 | 602 | $ary = stripslashes_deep( $ary ); |
603 | 603 | $img_url = \GV\Utils::get( $ary, 0 ); |
604 | 604 | |
605 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
606 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
607 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
605 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
606 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
607 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
608 | 608 | |
609 | 609 | $image_meta = array( |
610 | 610 | 'post_excerpt' => $img_caption, |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | |
614 | 614 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
615 | 615 | if ( ! empty( $img_title ) ) { |
616 | - $image_meta['post_title'] = $img_title; |
|
616 | + $image_meta[ 'post_title' ] = $img_title; |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | /** |
@@ -671,15 +671,15 @@ discard block |
||
671 | 671 | */ |
672 | 672 | private function maybe_update_post_fields( $form ) { |
673 | 673 | |
674 | - if( empty( $this->entry['post_id'] ) ) { |
|
674 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
675 | 675 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
676 | 676 | return; |
677 | 677 | } |
678 | 678 | |
679 | - $post_id = $this->entry['post_id']; |
|
679 | + $post_id = $this->entry[ 'post_id' ]; |
|
680 | 680 | |
681 | 681 | // Security check |
682 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
682 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
683 | 683 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
684 | 684 | return; |
685 | 685 | } |
@@ -692,25 +692,25 @@ discard block |
||
692 | 692 | |
693 | 693 | $field = RGFormsModel::get_field( $form, $field_id ); |
694 | 694 | |
695 | - if( ! $field ) { |
|
695 | + if ( ! $field ) { |
|
696 | 696 | continue; |
697 | 697 | } |
698 | 698 | |
699 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
699 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
700 | 700 | |
701 | 701 | // Get the value of the field, including $_POSTed value |
702 | 702 | $value = RGFormsModel::get_field_value( $field ); |
703 | 703 | |
704 | 704 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
705 | 705 | $entry_tmp = $this->entry; |
706 | - $entry_tmp["{$field_id}"] = $value; |
|
706 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
707 | 707 | |
708 | - switch( $field->type ) { |
|
708 | + switch ( $field->type ) { |
|
709 | 709 | |
710 | 710 | case 'post_title': |
711 | 711 | $post_title = $value; |
712 | 712 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
713 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
713 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
714 | 714 | } |
715 | 715 | $updated_post->post_title = $post_title; |
716 | 716 | $updated_post->post_name = $post_title; |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | case 'post_content': |
721 | 721 | $post_content = $value; |
722 | 722 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
723 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
723 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
724 | 724 | } |
725 | 725 | $updated_post->post_content = $post_content; |
726 | 726 | unset( $post_content ); |
@@ -738,12 +738,12 @@ discard block |
||
738 | 738 | $value = $value[ $field_id ]; |
739 | 739 | } |
740 | 740 | |
741 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
741 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
742 | 742 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
743 | 743 | } |
744 | 744 | |
745 | 745 | if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
746 | - $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value ); |
|
746 | + $value = function_exists( 'wp_json_encode' ) ? wp_json_encode( $value ) : json_encode( $value ); |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | } |
757 | 757 | |
758 | 758 | // update entry after |
759 | - $this->entry["{$field_id}"] = $value; |
|
759 | + $this->entry[ "{$field_id}" ] = $value; |
|
760 | 760 | |
761 | 761 | $update_entry = true; |
762 | 762 | |
@@ -765,11 +765,11 @@ discard block |
||
765 | 765 | |
766 | 766 | } |
767 | 767 | |
768 | - if( $update_entry ) { |
|
768 | + if ( $update_entry ) { |
|
769 | 769 | |
770 | 770 | $return_entry = GFAPI::update_entry( $this->entry ); |
771 | 771 | |
772 | - if( is_wp_error( $return_entry ) ) { |
|
772 | + if ( is_wp_error( $return_entry ) ) { |
|
773 | 773 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
774 | 774 | } else { |
775 | 775 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | |
780 | 780 | $return_post = wp_update_post( $updated_post, true ); |
781 | 781 | |
782 | - if( is_wp_error( $return_post ) ) { |
|
782 | + if ( is_wp_error( $return_post ) ) { |
|
783 | 783 | $return_post->add_data( $updated_post, '$updated_post' ); |
784 | 784 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
785 | 785 | } else { |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | $input_type = RGFormsModel::get_input_type( $field ); |
802 | 802 | |
803 | 803 | // Only certain custom field types are supported |
804 | - switch( $input_type ) { |
|
804 | + switch ( $input_type ) { |
|
805 | 805 | case 'fileupload': |
806 | 806 | case 'list': |
807 | 807 | case 'multiselect': |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
839 | 839 | |
840 | 840 | // replace conditional shortcodes |
841 | - if( $do_shortcode ) { |
|
841 | + if ( $do_shortcode ) { |
|
842 | 842 | $output = do_shortcode( $output ); |
843 | 843 | } |
844 | 844 | |
@@ -857,19 +857,19 @@ discard block |
||
857 | 857 | */ |
858 | 858 | private function after_update() { |
859 | 859 | |
860 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
861 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
860 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
861 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
862 | 862 | |
863 | 863 | // Re-define the entry now that we've updated it. |
864 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
864 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
865 | 865 | |
866 | 866 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
867 | 867 | |
868 | 868 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
869 | 869 | // We need to clear the cache because Gravity Forms caches the field values, which |
870 | 870 | // we have just updated. |
871 | - foreach ($this->form['fields'] as $key => $field) { |
|
872 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
871 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
872 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
873 | 873 | } |
874 | 874 | } |
875 | 875 | |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | |
889 | 889 | <div class="gv-edit-entry-wrapper"><?php |
890 | 890 | |
891 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
891 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
892 | 892 | |
893 | 893 | /** |
894 | 894 | * Fixes weird wpautop() issue |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | * @param string $edit_entry_title Modify the "Edit Entry" title |
905 | 905 | * @param GravityView_Edit_Entry_Render $this This object |
906 | 906 | */ |
907 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
907 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
908 | 908 | |
909 | 909 | echo esc_attr( $edit_entry_title ); |
910 | 910 | ?></span> |
@@ -954,16 +954,16 @@ discard block |
||
954 | 954 | |
955 | 955 | $back_link = esc_url( remove_query_arg( array( 'page', 'view', 'edit' ) ) ); |
956 | 956 | |
957 | - if( ! $this->is_valid ){ |
|
957 | + if ( ! $this->is_valid ) { |
|
958 | 958 | |
959 | 959 | // Keeping this compatible with Gravity Forms. |
960 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
961 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
960 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
961 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
962 | 962 | |
963 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
963 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
964 | 964 | |
965 | 965 | } else { |
966 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); |
|
966 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' ); |
|
967 | 967 | |
968 | 968 | /** |
969 | 969 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -973,7 +973,7 @@ discard block |
||
973 | 973 | * @param array $entry Gravity Forms entry array |
974 | 974 | * @param string $back_link URL to return to the original entry. @since 1.6 |
975 | 975 | */ |
976 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
976 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
977 | 977 | |
978 | 978 | echo GVCommon::generate_notice( $message ); |
979 | 979 | } |
@@ -997,21 +997,21 @@ discard block |
||
997 | 997 | */ |
998 | 998 | do_action( 'gravityview/edit-entry/render/before', $this ); |
999 | 999 | |
1000 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
1001 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
1000 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
1001 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
1002 | 1002 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
1003 | 1003 | |
1004 | 1004 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
1005 | 1005 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
1006 | 1006 | |
1007 | 1007 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
1008 | - unset( $_GET['page'] ); |
|
1008 | + unset( $_GET[ 'page' ] ); |
|
1009 | 1009 | |
1010 | 1010 | // TODO: Verify multiple-page forms |
1011 | 1011 | |
1012 | 1012 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
1013 | 1013 | |
1014 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
1014 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
1015 | 1015 | |
1016 | 1016 | ob_get_clean(); |
1017 | 1017 | |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | * @return string |
1038 | 1038 | */ |
1039 | 1039 | public function render_form_buttons() { |
1040 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
1040 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | |
@@ -1057,10 +1057,10 @@ discard block |
||
1057 | 1057 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
1058 | 1058 | |
1059 | 1059 | // In case we have validated the form, use it to inject the validation results into the form render |
1060 | - if( isset( $this->form_after_validation ) ) { |
|
1060 | + if ( isset( $this->form_after_validation ) ) { |
|
1061 | 1061 | $form = $this->form_after_validation; |
1062 | 1062 | } else { |
1063 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1063 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | $form = $this->filter_conditional_logic( $form ); |
@@ -1068,8 +1068,8 @@ discard block |
||
1068 | 1068 | $form = $this->prefill_conditional_logic( $form ); |
1069 | 1069 | |
1070 | 1070 | // for now we don't support Save and Continue feature. |
1071 | - if( ! self::$supports_save_and_continue ) { |
|
1072 | - unset( $form['save'] ); |
|
1071 | + if ( ! self::$supports_save_and_continue ) { |
|
1072 | + unset( $form[ 'save' ] ); |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | return $form; |
@@ -1090,29 +1090,29 @@ discard block |
||
1090 | 1090 | */ |
1091 | 1091 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
1092 | 1092 | |
1093 | - if( GFCommon::is_post_field( $field ) ) { |
|
1093 | + if ( GFCommon::is_post_field( $field ) ) { |
|
1094 | 1094 | |
1095 | 1095 | $message = null; |
1096 | 1096 | |
1097 | 1097 | // First, make sure they have the capability to edit the post. |
1098 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1098 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1099 | 1099 | |
1100 | 1100 | /** |
1101 | 1101 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
1102 | 1102 | * @param string $message The existing "You don't have permission..." text |
1103 | 1103 | */ |
1104 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1104 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1105 | 1105 | |
1106 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1106 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1107 | 1107 | /** |
1108 | 1108 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
1109 | 1109 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
1110 | 1110 | */ |
1111 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1111 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1112 | 1112 | } |
1113 | 1113 | |
1114 | - if( $message ) { |
|
1115 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1114 | + if ( $message ) { |
|
1115 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1116 | 1116 | } |
1117 | 1117 | } |
1118 | 1118 | |
@@ -1137,8 +1137,8 @@ discard block |
||
1137 | 1137 | |
1138 | 1138 | // If the form has been submitted, then we don't need to pre-fill the values, |
1139 | 1139 | // Except for fileupload type and when a field input is overridden- run always!! |
1140 | - if( |
|
1141 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1140 | + if ( |
|
1141 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1142 | 1142 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1143 | 1143 | && ! GFCommon::is_product_field( $field->type ) |
1144 | 1144 | || ! empty( $field_content ) |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | $return = null; |
1159 | 1159 | |
1160 | 1160 | /** @var GravityView_Field $gv_field */ |
1161 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1161 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1162 | 1162 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1163 | 1163 | } else { |
1164 | 1164 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | // If there was output, it's an error |
1168 | 1168 | $warnings = ob_get_clean(); |
1169 | 1169 | |
1170 | - if( !empty( $warnings ) ) { |
|
1170 | + if ( ! empty( $warnings ) ) { |
|
1171 | 1171 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
1172 | 1172 | } |
1173 | 1173 | |
@@ -1192,7 +1192,7 @@ discard block |
||
1192 | 1192 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1193 | 1193 | |
1194 | 1194 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1195 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1195 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1196 | 1196 | |
1197 | 1197 | $field_value = array(); |
1198 | 1198 | |
@@ -1201,10 +1201,10 @@ discard block |
||
1201 | 1201 | |
1202 | 1202 | foreach ( (array)$field->inputs as $input ) { |
1203 | 1203 | |
1204 | - $input_id = strval( $input['id'] ); |
|
1204 | + $input_id = strval( $input[ 'id' ] ); |
|
1205 | 1205 | |
1206 | 1206 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1207 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1207 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1208 | 1208 | $allow_pre_populated = false; |
1209 | 1209 | } |
1210 | 1210 | |
@@ -1212,7 +1212,7 @@ discard block |
||
1212 | 1212 | |
1213 | 1213 | $pre_value = $field->get_value_submission( array(), false ); |
1214 | 1214 | |
1215 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1215 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1216 | 1216 | |
1217 | 1217 | } else { |
1218 | 1218 | |
@@ -1223,13 +1223,13 @@ discard block |
||
1223 | 1223 | |
1224 | 1224 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1225 | 1225 | // or pre-populated value if not empty and set to override saved value |
1226 | - $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1226 | + $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1227 | 1227 | |
1228 | 1228 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1229 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1229 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1230 | 1230 | $categories = array(); |
1231 | 1231 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1232 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1232 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1233 | 1233 | } |
1234 | 1234 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1235 | 1235 | } |
@@ -1257,7 +1257,7 @@ discard block |
||
1257 | 1257 | * @param GF_Field $field Gravity Forms field object |
1258 | 1258 | * @param GravityView_Edit_Entry_Render $this Current object |
1259 | 1259 | */ |
1260 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1260 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
1261 | 1261 | |
1262 | 1262 | return $field_value; |
1263 | 1263 | } |
@@ -1274,12 +1274,12 @@ discard block |
||
1274 | 1274 | */ |
1275 | 1275 | public function gform_pre_validation( $form ) { |
1276 | 1276 | |
1277 | - if( ! $this->verify_nonce() ) { |
|
1277 | + if ( ! $this->verify_nonce() ) { |
|
1278 | 1278 | return $form; |
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | // Fix PHP warning regarding undefined index. |
1282 | - foreach ( $form['fields'] as &$field) { |
|
1282 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1283 | 1283 | |
1284 | 1284 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1285 | 1285 | // expects certain field array items to be set. |
@@ -1287,7 +1287,7 @@ discard block |
||
1287 | 1287 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
1288 | 1288 | } |
1289 | 1289 | |
1290 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1290 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1291 | 1291 | |
1292 | 1292 | /** |
1293 | 1293 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -1301,26 +1301,26 @@ discard block |
||
1301 | 1301 | // Set the previous value |
1302 | 1302 | $entry = $this->get_entry(); |
1303 | 1303 | |
1304 | - $input_name = 'input_'.$field->id; |
|
1305 | - $form_id = $form['id']; |
|
1304 | + $input_name = 'input_' . $field->id; |
|
1305 | + $form_id = $form[ 'id' ]; |
|
1306 | 1306 | |
1307 | 1307 | $value = NULL; |
1308 | 1308 | |
1309 | 1309 | // Use the previous entry value as the default. |
1310 | - if( isset( $entry[ $field->id ] ) ) { |
|
1310 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1311 | 1311 | $value = $entry[ $field->id ]; |
1312 | 1312 | } |
1313 | 1313 | |
1314 | 1314 | // If this is a single upload file |
1315 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1316 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1317 | - $value = $file_path['url']; |
|
1315 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1316 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1317 | + $value = $file_path[ 'url' ]; |
|
1318 | 1318 | |
1319 | 1319 | } else { |
1320 | 1320 | |
1321 | 1321 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1322 | 1322 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1323 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1323 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1324 | 1324 | |
1325 | 1325 | } |
1326 | 1326 | |
@@ -1328,10 +1328,10 @@ discard block |
||
1328 | 1328 | |
1329 | 1329 | // If there are fresh uploads, process and merge them. |
1330 | 1330 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
1331 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1331 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1332 | 1332 | $value = empty( $value ) ? '[]' : $value; |
1333 | 1333 | $value = stripslashes_deep( $value ); |
1334 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1334 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1335 | 1335 | } |
1336 | 1336 | |
1337 | 1337 | } else { |
@@ -1349,8 +1349,8 @@ discard block |
||
1349 | 1349 | |
1350 | 1350 | case 'number': |
1351 | 1351 | // Fix "undefined index" issue at line 1286 in form_display.php |
1352 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1353 | - $_POST['input_'.$field->id ] = NULL; |
|
1352 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1353 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1354 | 1354 | } |
1355 | 1355 | break; |
1356 | 1356 | } |
@@ -1387,7 +1387,7 @@ discard block |
||
1387 | 1387 | * You can enter whatever you want! |
1388 | 1388 | * We try validating, and customize the results using `self::custom_validation()` |
1389 | 1389 | */ |
1390 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1390 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1391 | 1391 | |
1392 | 1392 | // Needed by the validate funtion |
1393 | 1393 | $failed_validation_page = NULL; |
@@ -1395,14 +1395,14 @@ discard block |
||
1395 | 1395 | |
1396 | 1396 | // Prevent entry limit from running when editing an entry, also |
1397 | 1397 | // prevent form scheduling from preventing editing |
1398 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1398 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1399 | 1399 | |
1400 | 1400 | // Hide fields depending on Edit Entry settings |
1401 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1401 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1402 | 1402 | |
1403 | 1403 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1404 | 1404 | |
1405 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1405 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1406 | 1406 | } |
1407 | 1407 | |
1408 | 1408 | |
@@ -1425,7 +1425,7 @@ discard block |
||
1425 | 1425 | |
1426 | 1426 | $gv_valid = true; |
1427 | 1427 | |
1428 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1428 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1429 | 1429 | |
1430 | 1430 | $value = RGFormsModel::get_field_value( $field ); |
1431 | 1431 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1438,35 +1438,35 @@ discard block |
||
1438 | 1438 | case 'post_image': |
1439 | 1439 | |
1440 | 1440 | // in case nothing is uploaded but there are already files saved |
1441 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1441 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1442 | 1442 | $field->failed_validation = false; |
1443 | 1443 | unset( $field->validation_message ); |
1444 | 1444 | } |
1445 | 1445 | |
1446 | 1446 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1447 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1447 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
1448 | 1448 | |
1449 | 1449 | $input_name = 'input_' . $field->id; |
1450 | 1450 | //uploaded |
1451 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1451 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1452 | 1452 | |
1453 | 1453 | //existent |
1454 | 1454 | $entry = $this->get_entry(); |
1455 | 1455 | $value = NULL; |
1456 | - if( isset( $entry[ $field->id ] ) ) { |
|
1456 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1457 | 1457 | $value = json_decode( $entry[ $field->id ], true ); |
1458 | 1458 | } |
1459 | 1459 | |
1460 | 1460 | // count uploaded files and existent entry files |
1461 | 1461 | $count_files = count( $file_names ) + count( $value ); |
1462 | 1462 | |
1463 | - if( $count_files > $field->maxFiles ) { |
|
1463 | + if ( $count_files > $field->maxFiles ) { |
|
1464 | 1464 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1465 | 1465 | $field->failed_validation = 1; |
1466 | 1466 | $gv_valid = false; |
1467 | 1467 | |
1468 | 1468 | // in case of error make sure the newest upload files are removed from the upload input |
1469 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1469 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1470 | 1470 | } |
1471 | 1471 | |
1472 | 1472 | } |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | // This field has failed validation. |
1480 | - if( !empty( $field->failed_validation ) ) { |
|
1480 | + if ( ! empty( $field->failed_validation ) ) { |
|
1481 | 1481 | |
1482 | 1482 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
1483 | 1483 | |
@@ -1495,19 +1495,19 @@ discard block |
||
1495 | 1495 | } |
1496 | 1496 | |
1497 | 1497 | // You can't continue inside a switch, so we do it after. |
1498 | - if( empty( $field->failed_validation ) ) { |
|
1498 | + if ( empty( $field->failed_validation ) ) { |
|
1499 | 1499 | continue; |
1500 | 1500 | } |
1501 | 1501 | |
1502 | 1502 | // checks if the No Duplicates option is not validating entry against itself, since |
1503 | 1503 | // we're editing a stored entry, it would also assume it's a duplicate. |
1504 | - if( !empty( $field->noDuplicates ) ) { |
|
1504 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1505 | 1505 | |
1506 | 1506 | $entry = $this->get_entry(); |
1507 | 1507 | |
1508 | 1508 | // If the value of the entry is the same as the stored value |
1509 | 1509 | // Then we can assume it's not a duplicate, it's the same. |
1510 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1510 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1511 | 1511 | //if value submitted was not changed, then don't validate |
1512 | 1512 | $field->failed_validation = false; |
1513 | 1513 | |
@@ -1520,7 +1520,7 @@ discard block |
||
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1523 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1523 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1524 | 1524 | unset( $field->validation_message ); |
1525 | 1525 | $field->validation_message = false; |
1526 | 1526 | continue; |
@@ -1532,12 +1532,12 @@ discard block |
||
1532 | 1532 | |
1533 | 1533 | } |
1534 | 1534 | |
1535 | - $validation_results['is_valid'] = $gv_valid; |
|
1535 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1536 | 1536 | |
1537 | 1537 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
1538 | 1538 | |
1539 | 1539 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1540 | - $this->form_after_validation = $validation_results['form']; |
|
1540 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1541 | 1541 | |
1542 | 1542 | return $validation_results; |
1543 | 1543 | } |
@@ -1550,7 +1550,7 @@ discard block |
||
1550 | 1550 | */ |
1551 | 1551 | public function get_entry() { |
1552 | 1552 | |
1553 | - if( empty( $this->entry ) ) { |
|
1553 | + if ( empty( $this->entry ) ) { |
|
1554 | 1554 | // Get the database value of the entry that's being edited |
1555 | 1555 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1556 | 1556 | } |
@@ -1582,10 +1582,10 @@ discard block |
||
1582 | 1582 | } |
1583 | 1583 | |
1584 | 1584 | // If edit tab not yet configured, show all fields |
1585 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1585 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1586 | 1586 | |
1587 | 1587 | // Hide fields depending on admin settings |
1588 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1588 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1589 | 1589 | |
1590 | 1590 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1591 | 1591 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1617,7 +1617,7 @@ discard block |
||
1617 | 1617 | */ |
1618 | 1618 | private function filter_fields( $fields, $configured_fields ) { |
1619 | 1619 | |
1620 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1620 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1621 | 1621 | return $fields; |
1622 | 1622 | } |
1623 | 1623 | |
@@ -1630,18 +1630,18 @@ discard block |
||
1630 | 1630 | |
1631 | 1631 | // Remove the fields that have calculation properties and keep them to be used later |
1632 | 1632 | // @since 1.16.2 |
1633 | - if( $field->has_calculation() ) { |
|
1634 | - $this->fields_with_calculation[] = $field; |
|
1633 | + if ( $field->has_calculation() ) { |
|
1634 | + $this->fields_with_calculation[ ] = $field; |
|
1635 | 1635 | // don't remove the calculation fields on form render. |
1636 | 1636 | } |
1637 | 1637 | |
1638 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1638 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1639 | 1639 | unset( $fields[ $key ] ); |
1640 | 1640 | } |
1641 | 1641 | } |
1642 | 1642 | |
1643 | 1643 | // The Edit tab has not been configured, so we return all fields by default. |
1644 | - if( empty( $configured_fields ) ) { |
|
1644 | + if ( empty( $configured_fields ) ) { |
|
1645 | 1645 | return $fields; |
1646 | 1646 | } |
1647 | 1647 | |
@@ -1650,8 +1650,8 @@ discard block |
||
1650 | 1650 | |
1651 | 1651 | /** @var GF_Field $field */ |
1652 | 1652 | foreach ( $fields as $field ) { |
1653 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1654 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1653 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1654 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1655 | 1655 | break; |
1656 | 1656 | } |
1657 | 1657 | |
@@ -1674,14 +1674,14 @@ discard block |
||
1674 | 1674 | |
1675 | 1675 | $return_field = $field; |
1676 | 1676 | |
1677 | - if( empty( $field_setting['show_label'] ) ) { |
|
1677 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1678 | 1678 | $return_field->label = ''; |
1679 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1680 | - $return_field->label = $field_setting['custom_label']; |
|
1679 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
1680 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
1681 | 1681 | } |
1682 | 1682 | |
1683 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1684 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1683 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
1684 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1685 | 1685 | } |
1686 | 1686 | |
1687 | 1687 | /** |
@@ -1719,16 +1719,16 @@ discard block |
||
1719 | 1719 | */ |
1720 | 1720 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
1721 | 1721 | |
1722 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1723 | - foreach( $fields as $k => $field ) { |
|
1724 | - if( $field->adminOnly ) { |
|
1722 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
1723 | + foreach ( $fields as $k => $field ) { |
|
1724 | + if ( $field->adminOnly ) { |
|
1725 | 1725 | unset( $fields[ $k ] ); |
1726 | 1726 | } |
1727 | 1727 | } |
1728 | 1728 | return $fields; |
1729 | 1729 | } |
1730 | 1730 | |
1731 | - foreach( $fields as &$field ) { |
|
1731 | + foreach ( $fields as &$field ) { |
|
1732 | 1732 | $field->adminOnly = false; |
1733 | 1733 | } |
1734 | 1734 | |
@@ -1752,22 +1752,22 @@ discard block |
||
1752 | 1752 | */ |
1753 | 1753 | function prefill_conditional_logic( $form ) { |
1754 | 1754 | |
1755 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1755 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
1756 | 1756 | return $form; |
1757 | 1757 | } |
1758 | 1758 | |
1759 | 1759 | // Have Conditional Logic pre-fill fields as if the data were default values |
1760 | 1760 | /** @var GF_Field $field */ |
1761 | - foreach ( $form['fields'] as &$field ) { |
|
1761 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1762 | 1762 | |
1763 | - if( 'checkbox' === $field->type ) { |
|
1763 | + if ( 'checkbox' === $field->type ) { |
|
1764 | 1764 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1765 | - $input_id = $input['id']; |
|
1765 | + $input_id = $input[ 'id' ]; |
|
1766 | 1766 | $choice = $field->choices[ $key ]; |
1767 | 1767 | $value = \GV\Utils::get( $this->entry, $input_id ); |
1768 | 1768 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
1769 | - if( $match ) { |
|
1770 | - $field->choices[ $key ]['isSelected'] = true; |
|
1769 | + if ( $match ) { |
|
1770 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
1771 | 1771 | } |
1772 | 1772 | } |
1773 | 1773 | } else { |
@@ -1775,15 +1775,15 @@ discard block |
||
1775 | 1775 | // We need to run through each field to set the default values |
1776 | 1776 | foreach ( $this->entry as $field_id => $field_value ) { |
1777 | 1777 | |
1778 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1778 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1779 | 1779 | |
1780 | - if( 'list' === $field->type ) { |
|
1780 | + if ( 'list' === $field->type ) { |
|
1781 | 1781 | $list_rows = maybe_unserialize( $field_value ); |
1782 | 1782 | |
1783 | 1783 | $list_field_value = array(); |
1784 | - foreach ( (array) $list_rows as $row ) { |
|
1785 | - foreach ( (array) $row as $column ) { |
|
1786 | - $list_field_value[] = $column; |
|
1784 | + foreach ( (array)$list_rows as $row ) { |
|
1785 | + foreach ( (array)$row as $column ) { |
|
1786 | + $list_field_value[ ] = $column; |
|
1787 | 1787 | } |
1788 | 1788 | } |
1789 | 1789 | |
@@ -1818,16 +1818,16 @@ discard block |
||
1818 | 1818 | */ |
1819 | 1819 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
1820 | 1820 | |
1821 | - if( $use_conditional_logic ) { |
|
1821 | + if ( $use_conditional_logic ) { |
|
1822 | 1822 | return $form; |
1823 | 1823 | } |
1824 | 1824 | |
1825 | - foreach( $form['fields'] as &$field ) { |
|
1825 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1826 | 1826 | /* @var GF_Field $field */ |
1827 | 1827 | $field->conditionalLogic = null; |
1828 | 1828 | } |
1829 | 1829 | |
1830 | - unset( $form['button']['conditionalLogic'] ); |
|
1830 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
1831 | 1831 | |
1832 | 1832 | return $form; |
1833 | 1833 | |
@@ -1844,7 +1844,7 @@ discard block |
||
1844 | 1844 | */ |
1845 | 1845 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
1846 | 1846 | |
1847 | - if( ! $this->is_edit_entry() ) { |
|
1847 | + if ( ! $this->is_edit_entry() ) { |
|
1848 | 1848 | return $has_conditional_logic; |
1849 | 1849 | } |
1850 | 1850 | |
@@ -1876,44 +1876,44 @@ discard block |
||
1876 | 1876 | * 2. There are two entries embedded using oEmbed |
1877 | 1877 | * 3. One of the entries has just been saved |
1878 | 1878 | */ |
1879 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
1879 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
1880 | 1880 | |
1881 | 1881 | $error = true; |
1882 | 1882 | |
1883 | 1883 | } |
1884 | 1884 | |
1885 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
1885 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
1886 | 1886 | |
1887 | 1887 | $error = true; |
1888 | 1888 | |
1889 | - } elseif( ! $this->verify_nonce() ) { |
|
1889 | + } elseif ( ! $this->verify_nonce() ) { |
|
1890 | 1890 | |
1891 | 1891 | /** |
1892 | 1892 | * If the Entry is embedded, there may be two entries on the same page. |
1893 | 1893 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
1894 | 1894 | */ |
1895 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1895 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1896 | 1896 | $error = true; |
1897 | 1897 | } else { |
1898 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
1898 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
1899 | 1899 | } |
1900 | 1900 | |
1901 | 1901 | } |
1902 | 1902 | |
1903 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1904 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
1903 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1904 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
1905 | 1905 | } |
1906 | 1906 | |
1907 | - if( $this->entry['status'] === 'trash' ) { |
|
1908 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1907 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
1908 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1909 | 1909 | } |
1910 | 1910 | |
1911 | 1911 | // No errors; everything's fine here! |
1912 | - if( empty( $error ) ) { |
|
1912 | + if ( empty( $error ) ) { |
|
1913 | 1913 | return true; |
1914 | 1914 | } |
1915 | 1915 | |
1916 | - if( $echo && $error !== true ) { |
|
1916 | + if ( $echo && $error !== true ) { |
|
1917 | 1917 | |
1918 | 1918 | $error = esc_html( $error ); |
1919 | 1919 | |
@@ -1921,10 +1921,10 @@ discard block |
||
1921 | 1921 | * @since 1.9 |
1922 | 1922 | */ |
1923 | 1923 | if ( ! empty( $this->entry ) ) { |
1924 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1924 | + $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1925 | 1925 | } |
1926 | 1926 | |
1927 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
1927 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
1928 | 1928 | } |
1929 | 1929 | |
1930 | 1930 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1944,17 +1944,17 @@ discard block |
||
1944 | 1944 | |
1945 | 1945 | $error = NULL; |
1946 | 1946 | |
1947 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1948 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
1947 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1948 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
1949 | 1949 | } |
1950 | 1950 | |
1951 | 1951 | // No errors; everything's fine here! |
1952 | - if( empty( $error ) ) { |
|
1952 | + if ( empty( $error ) ) { |
|
1953 | 1953 | return true; |
1954 | 1954 | } |
1955 | 1955 | |
1956 | - if( $echo ) { |
|
1957 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
1956 | + if ( $echo ) { |
|
1957 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
1958 | 1958 | } |
1959 | 1959 | |
1960 | 1960 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1975,14 +1975,14 @@ discard block |
||
1975 | 1975 | private function check_user_cap_edit_field( $field ) { |
1976 | 1976 | |
1977 | 1977 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
1978 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1978 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1979 | 1979 | return true; |
1980 | 1980 | } |
1981 | 1981 | |
1982 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
1982 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
1983 | 1983 | |
1984 | - if( $field_cap ) { |
|
1985 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
1984 | + if ( $field_cap ) { |
|
1985 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
1986 | 1986 | } |
1987 | 1987 | |
1988 | 1988 | return false; |
@@ -1996,17 +1996,17 @@ discard block |
||
1996 | 1996 | public function verify_nonce() { |
1997 | 1997 | |
1998 | 1998 | // Verify form submitted for editing single |
1999 | - if( $this->is_edit_entry_submission() ) { |
|
1999 | + if ( $this->is_edit_entry_submission() ) { |
|
2000 | 2000 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
2001 | 2001 | } |
2002 | 2002 | |
2003 | 2003 | // Verify |
2004 | - else if( ! $this->is_edit_entry() ) { |
|
2004 | + else if ( ! $this->is_edit_entry() ) { |
|
2005 | 2005 | $valid = false; |
2006 | 2006 | } |
2007 | 2007 | |
2008 | 2008 | else { |
2009 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
2009 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
2010 | 2010 | } |
2011 | 2011 | |
2012 | 2012 | /** |
@@ -63,28 +63,28 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
66 | - * When on the Add/Edit View screen, suggest most popular articles related to that |
|
67 | - * |
|
66 | + * When on the Add/Edit View screen, suggest most popular articles related to that |
|
67 | + * |
|
68 | 68 | * @param array $localization_data Data to be passed to the Support Port JS |
69 | 69 | * |
70 | 70 | * @return array |
71 | 71 | */ |
72 | 72 | function suggest_support_articles( $localization_data = array() ) { |
73 | 73 | |
74 | - if( ! gravityview()->request->is_view() ) { |
|
75 | - return $localization_data; |
|
76 | - } |
|
74 | + if( ! gravityview()->request->is_view() ) { |
|
75 | + return $localization_data; |
|
76 | + } |
|
77 | 77 | |
78 | 78 | $localization_data['suggest'] = array( |
79 | - '57ef23539033602e61d4a560', |
|
80 | - '54c67bb9e4b0512429885513', |
|
81 | - '54c67bb9e4b0512429885512', |
|
82 | - '54c67bbbe4b07997ea3f3f6b', |
|
83 | - '54d1a33ae4b086c0c0964ce9', |
|
84 | - '57ef253c9033602e61d4a563', |
|
85 | - '552355bfe4b0221aadf2572b', |
|
86 | - '54c67bcde4b051242988553e', |
|
87 | - ); |
|
79 | + '57ef23539033602e61d4a560', |
|
80 | + '54c67bb9e4b0512429885513', |
|
81 | + '54c67bb9e4b0512429885512', |
|
82 | + '54c67bbbe4b07997ea3f3f6b', |
|
83 | + '54d1a33ae4b086c0c0964ce9', |
|
84 | + '57ef253c9033602e61d4a563', |
|
85 | + '552355bfe4b0221aadf2572b', |
|
86 | + '54c67bcde4b051242988553e', |
|
87 | + ); |
|
88 | 88 | |
89 | 89 | return $localization_data; |
90 | 90 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | if( empty( $connected_views ) ) { |
170 | 170 | |
171 | - $menu_items['gravityview'] = array( |
|
171 | + $menu_items['gravityview'] = array( |
|
172 | 172 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
173 | 173 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
174 | 174 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | // If there were no items added, then let's create the parent menu |
200 | 200 | if( $sub_menu_items ) { |
201 | 201 | |
202 | - $sub_menu_items[] = array( |
|
203 | - 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
204 | - 'link_class' => 'gv-create-view', |
|
205 | - 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
206 | - 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
207 | - 'capabilities' => array( 'edit_gravityviews' ), |
|
208 | - ); |
|
202 | + $sub_menu_items[] = array( |
|
203 | + 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
|
204 | + 'link_class' => 'gv-create-view', |
|
205 | + 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
|
206 | + 'url' => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ), |
|
207 | + 'capabilities' => array( 'edit_gravityviews' ), |
|
208 | + ); |
|
209 | 209 | |
210 | 210 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
211 | 211 | $sub_menu_items[] = array( |
@@ -588,12 +588,12 @@ discard block |
||
588 | 588 | * Render html for displaying available fields based on a Form ID |
589 | 589 | * $blacklist_field_types - contains the field types which are not proper to be shown in a directory. |
590 | 590 | * |
591 | - * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
591 | + * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action |
|
592 | 592 | * @access public |
593 | - * |
|
593 | + * |
|
594 | 594 | * @param int $form Gravity Forms Form ID (default: '') |
595 | 595 | * @param string $context (default: 'single') |
596 | - * |
|
596 | + * |
|
597 | 597 | * @return void |
598 | 598 | */ |
599 | 599 | function render_available_fields( $form = 0, $context = 'single' ) { |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | |
608 | 608 | if ( ! is_array( $blacklist_field_types ) ) { |
609 | 609 | |
610 | - gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
610 | + gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) ); |
|
611 | 611 | |
612 | 612 | $blacklist_field_types = array(); |
613 | 613 | } |
@@ -739,12 +739,12 @@ discard block |
||
739 | 739 | /** |
740 | 740 | * @since 1.7.2 |
741 | 741 | */ |
742 | - 'other_entries' => array( |
|
743 | - 'label' => __('Other Entries', 'gravityview'), |
|
744 | - 'type' => 'other_entries', |
|
745 | - 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
746 | - ), |
|
747 | - ); |
|
742 | + 'other_entries' => array( |
|
743 | + 'label' => __('Other Entries', 'gravityview'), |
|
744 | + 'type' => 'other_entries', |
|
745 | + 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
746 | + ), |
|
747 | + ); |
|
748 | 748 | |
749 | 749 | if( 'single' !== $zone) { |
750 | 750 | |
@@ -877,11 +877,11 @@ discard block |
||
877 | 877 | |
878 | 878 | $joined_forms = gravityview_get_joined_forms( $post->ID ); |
879 | 879 | |
880 | - foreach ( $joined_forms as $form ) { |
|
881 | - $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
882 | - } |
|
880 | + foreach ( $joined_forms as $form ) { |
|
881 | + $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone ); |
|
882 | + } |
|
883 | 883 | } else { |
884 | - $form_id = $form; |
|
884 | + $form_id = $form; |
|
885 | 885 | $available_items[ $form ] = $this->get_registered_widgets(); |
886 | 886 | } |
887 | 887 | } |
@@ -910,9 +910,9 @@ discard block |
||
910 | 910 | |
911 | 911 | if ( $form_id ) { |
912 | 912 | $original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ; |
913 | - } else { |
|
913 | + } else { |
|
914 | 914 | $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
915 | - } |
|
915 | + } |
|
916 | 916 | |
917 | 917 | if ( !$original_item ) { |
918 | 918 | gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array(' data' => array('available_items' => $available_items, 'field' => $field ) ) ); |
@@ -994,13 +994,13 @@ discard block |
||
994 | 994 | } |
995 | 995 | |
996 | 996 | /** |
997 | - * Renders "Add Field" tooltips |
|
998 | - * |
|
999 | - * @since 2.0.11 |
|
1000 | - * |
|
997 | + * Renders "Add Field" tooltips |
|
998 | + * |
|
999 | + * @since 2.0.11 |
|
1000 | + * |
|
1001 | 1001 | * @param string $context "directory", "single", or "edit" |
1002 | - * |
|
1003 | - * @return void |
|
1002 | + * |
|
1003 | + * @return void |
|
1004 | 1004 | */ |
1005 | 1005 | function render_field_pickers( $context = 'directory' ) { |
1006 | 1006 | |
@@ -1027,7 +1027,7 @@ discard block |
||
1027 | 1027 | </div> |
1028 | 1028 | <?php |
1029 | 1029 | } |
1030 | - } |
|
1030 | + } |
|
1031 | 1031 | |
1032 | 1032 | /** |
1033 | 1033 | * Render the Template Active Areas and configured active fields for a given template id and post id |
@@ -1099,59 +1099,59 @@ discard block |
||
1099 | 1099 | |
1100 | 1100 | // Don't process any scripts below here if it's not a GravityView page. |
1101 | 1101 | if( ! gravityview_is_admin_page( $hook, 'single' ) && ! $is_widgets_page ) { |
1102 | - return; |
|
1102 | + return; |
|
1103 | 1103 | } |
1104 | 1104 | |
1105 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1106 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version ); |
|
1107 | - |
|
1108 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
1109 | - |
|
1110 | - //enqueue scripts |
|
1111 | - wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), GravityView_Plugin::version ); |
|
1112 | - |
|
1113 | - wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1114 | - 'cookiepath' => COOKIEPATH, |
|
1115 | - 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1116 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
1117 | - 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
1118 | - 'label_close' => __( 'Close', 'gravityview' ), |
|
1119 | - 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
1120 | - 'label_continue' => __( 'Continue', 'gravityview' ), |
|
1121 | - 'label_ok' => __( 'Ok', 'gravityview' ), |
|
1122 | - 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
1123 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
1124 | - 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
1125 | - 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
1126 | - 'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ), |
|
1127 | - )); |
|
1128 | - |
|
1129 | - wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array('dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version ); |
|
1130 | - |
|
1131 | - // Enqueue scripts needed for merge tags |
|
1132 | - self::enqueue_gravity_forms_scripts(); |
|
1105 | + wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1106 | + wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version ); |
|
1107 | + |
|
1108 | + $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
1109 | + |
|
1110 | + //enqueue scripts |
|
1111 | + wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), GravityView_Plugin::version ); |
|
1112 | + |
|
1113 | + wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1114 | + 'cookiepath' => COOKIEPATH, |
|
1115 | + 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1116 | + 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
1117 | + 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
1118 | + 'label_close' => __( 'Close', 'gravityview' ), |
|
1119 | + 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
1120 | + 'label_continue' => __( 'Continue', 'gravityview' ), |
|
1121 | + 'label_ok' => __( 'Ok', 'gravityview' ), |
|
1122 | + 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
1123 | + 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
1124 | + 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
1125 | + 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
1126 | + 'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ), |
|
1127 | + )); |
|
1128 | + |
|
1129 | + wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array('dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version ); |
|
1130 | + |
|
1131 | + // Enqueue scripts needed for merge tags |
|
1132 | + self::enqueue_gravity_forms_scripts(); |
|
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | /** |
1136 | 1136 | * Enqueue Gravity Forms scripts, needed for Merge Tags |
1137 | - * |
|
1138 | - * @since 1.0.5-beta |
|
1139 | - * |
|
1140 | - * @return void |
|
1137 | + * |
|
1138 | + * @since 1.0.5-beta |
|
1139 | + * |
|
1140 | + * @return void |
|
1141 | 1141 | */ |
1142 | 1142 | static function enqueue_gravity_forms_scripts() { |
1143 | 1143 | GFForms::register_scripts(); |
1144 | 1144 | |
1145 | 1145 | $scripts = array( |
1146 | - 'sack', |
|
1147 | - 'gform_gravityforms', |
|
1148 | - 'gform_forms', |
|
1149 | - 'gform_form_admin', |
|
1150 | - 'jquery-ui-autocomplete' |
|
1146 | + 'sack', |
|
1147 | + 'gform_gravityforms', |
|
1148 | + 'gform_forms', |
|
1149 | + 'gform_form_admin', |
|
1150 | + 'jquery-ui-autocomplete' |
|
1151 | 1151 | ); |
1152 | 1152 | |
1153 | 1153 | if ( wp_is_mobile() ) { |
1154 | - $scripts[] = 'jquery-touch-punch'; |
|
1154 | + $scripts[] = 'jquery-touch-punch'; |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | wp_enqueue_script( $scripts ); |
@@ -28,31 +28,31 @@ discard block |
||
28 | 28 | add_filter( 'gravityview_blacklist_field_types', array( $this, 'default_field_blacklist' ), 10, 2 ); |
29 | 29 | |
30 | 30 | // Tooltips |
31 | - add_filter( 'gform_tooltips', array( $this, 'tooltips') ); |
|
31 | + add_filter( 'gform_tooltips', array( $this, 'tooltips' ) ); |
|
32 | 32 | |
33 | 33 | // adding styles and scripts |
34 | - add_action( 'admin_enqueue_scripts', array( 'GravityView_Admin_Views', 'add_scripts_and_styles'), 999 ); |
|
35 | - add_filter( 'gform_noconflict_styles', array( $this, 'register_no_conflict') ); |
|
36 | - add_filter( 'gform_noconflict_scripts', array( $this, 'register_no_conflict') ); |
|
37 | - add_filter( 'gravityview_noconflict_styles', array( $this, 'register_no_conflict') ); |
|
38 | - add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict') ); |
|
39 | - |
|
40 | - add_action( 'gravityview_render_directory_active_areas', array( $this, 'render_directory_active_areas'), 10, 4 ); |
|
41 | - add_action( 'gravityview_render_widgets_active_areas', array( $this, 'render_widgets_active_areas'), 10, 3 ); |
|
42 | - add_action( 'gravityview_render_field_pickers', array( $this, 'render_field_pickers') ); |
|
43 | - add_action( 'gravityview_render_available_fields', array( $this, 'render_available_fields'), 10, 2 ); |
|
44 | - add_action( 'gravityview_render_available_widgets', array( $this, 'render_available_widgets') ); |
|
45 | - add_action( 'gravityview_render_active_areas', array( $this, 'render_active_areas'), 10, 5 ); |
|
34 | + add_action( 'admin_enqueue_scripts', array( 'GravityView_Admin_Views', 'add_scripts_and_styles' ), 999 ); |
|
35 | + add_filter( 'gform_noconflict_styles', array( $this, 'register_no_conflict' ) ); |
|
36 | + add_filter( 'gform_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
|
37 | + add_filter( 'gravityview_noconflict_styles', array( $this, 'register_no_conflict' ) ); |
|
38 | + add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) ); |
|
39 | + |
|
40 | + add_action( 'gravityview_render_directory_active_areas', array( $this, 'render_directory_active_areas' ), 10, 4 ); |
|
41 | + add_action( 'gravityview_render_widgets_active_areas', array( $this, 'render_widgets_active_areas' ), 10, 3 ); |
|
42 | + add_action( 'gravityview_render_field_pickers', array( $this, 'render_field_pickers' ) ); |
|
43 | + add_action( 'gravityview_render_available_fields', array( $this, 'render_available_fields' ), 10, 2 ); |
|
44 | + add_action( 'gravityview_render_available_widgets', array( $this, 'render_available_widgets' ) ); |
|
45 | + add_action( 'gravityview_render_active_areas', array( $this, 'render_active_areas' ), 10, 5 ); |
|
46 | 46 | |
47 | 47 | // @todo check if this hook is needed.. |
48 | 48 | //add_action( 'gravityview_render_field_options', array( $this, 'render_field_options'), 10, 9 ); |
49 | 49 | |
50 | 50 | // Add Connected Form column |
51 | - add_filter('manage_gravityview_posts_columns' , array( $this, 'add_post_type_columns' ) ); |
|
51 | + add_filter( 'manage_gravityview_posts_columns', array( $this, 'add_post_type_columns' ) ); |
|
52 | 52 | |
53 | 53 | add_filter( 'gform_toolbar_menu', array( 'GravityView_Admin_Views', 'gform_toolbar_menu' ), 10, 2 ); |
54 | 54 | |
55 | - add_action( 'manage_gravityview_posts_custom_column', array( $this, 'add_custom_column_content'), 10, 2 ); |
|
55 | + add_action( 'manage_gravityview_posts_custom_column', array( $this, 'add_custom_column_content' ), 10, 2 ); |
|
56 | 56 | |
57 | 57 | add_action( 'restrict_manage_posts', array( $this, 'add_view_dropdown' ) ); |
58 | 58 | |
@@ -71,11 +71,11 @@ discard block |
||
71 | 71 | */ |
72 | 72 | function suggest_support_articles( $localization_data = array() ) { |
73 | 73 | |
74 | - if( ! gravityview()->request->is_view() ) { |
|
74 | + if ( ! gravityview()->request->is_view() ) { |
|
75 | 75 | return $localization_data; |
76 | 76 | } |
77 | 77 | |
78 | - $localization_data['suggest'] = array( |
|
78 | + $localization_data[ 'suggest' ] = array( |
|
79 | 79 | '57ef23539033602e61d4a560', |
80 | 80 | '54c67bb9e4b0512429885513', |
81 | 81 | '54c67bb9e4b0512429885512', |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | public function filter_pre_get_posts_by_gravityview_form_id( &$query ) { |
97 | 97 | global $pagenow; |
98 | 98 | |
99 | - if ( !is_admin() ) { |
|
99 | + if ( ! is_admin() ) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
103 | - $form_id = isset( $_GET['gravityview_form_id'] ) ? (int) $_GET['gravityview_form_id'] : false; |
|
103 | + $form_id = isset( $_GET[ 'gravityview_form_id' ] ) ? (int)$_GET[ 'gravityview_form_id' ] : false; |
|
104 | 104 | |
105 | - if( 'edit.php' !== $pagenow || ! $form_id || ! isset( $query->query_vars[ 'post_type' ] ) ) { |
|
105 | + if ( 'edit.php' !== $pagenow || ! $form_id || ! isset( $query->query_vars[ 'post_type' ] ) ) { |
|
106 | 106 | return; |
107 | 107 | } |
108 | 108 | |
@@ -119,18 +119,18 @@ discard block |
||
119 | 119 | function add_view_dropdown() { |
120 | 120 | $current_screen = get_current_screen(); |
121 | 121 | |
122 | - if( 'gravityview' !== $current_screen->post_type ) { |
|
122 | + if ( 'gravityview' !== $current_screen->post_type ) { |
|
123 | 123 | return; |
124 | 124 | } |
125 | 125 | |
126 | 126 | $forms = gravityview_get_forms(); |
127 | 127 | $current_form = \GV\Utils::_GET( 'gravityview_form_id' ); |
128 | 128 | // If there are no forms to select, show no forms. |
129 | - if( !empty( $forms ) ) { ?> |
|
129 | + if ( ! empty( $forms ) ) { ?> |
|
130 | 130 | <select name="gravityview_form_id" id="gravityview_form_id"> |
131 | 131 | <option value="" <?php selected( '', $current_form, true ); ?>><?php esc_html_e( 'All forms', 'gravityview' ); ?></option> |
132 | - <?php foreach( $forms as $form ) { ?> |
|
133 | - <option value="<?php echo $form['id']; ?>" <?php selected( $form['id'], $current_form, true ); ?>><?php echo esc_html( $form['title'] ); ?></option> |
|
132 | + <?php foreach ( $forms as $form ) { ?> |
|
133 | + <option value="<?php echo $form[ 'id' ]; ?>" <?php selected( $form[ 'id' ], $current_form, true ); ?>><?php echo esc_html( $form[ 'title' ] ); ?></option> |
|
134 | 134 | <?php } ?> |
135 | 135 | </select> |
136 | 136 | <?php } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public static function render_setting_row( $key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s' ) { |
145 | 145 | _deprecated_function( 'GravityView_Admin_Views::render_setting_row', '1.1.7', 'GravityView_Render_Settings::render_setting_row' ); |
146 | - GravityView_Render_Settings::render_setting_row( $key, $current_settings, $override_input, $name , $id ); |
|
146 | + GravityView_Render_Settings::render_setting_row( $key, $current_settings, $override_input, $name, $id ); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | |
167 | 167 | $connected_views = gravityview_get_connected_views( $id, array( 'post_status' => 'any' ) ); |
168 | 168 | |
169 | - if( empty( $connected_views ) ) { |
|
169 | + if ( empty( $connected_views ) ) { |
|
170 | 170 | |
171 | - $menu_items['gravityview'] = array( |
|
171 | + $menu_items[ 'gravityview' ] = array( |
|
172 | 172 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
173 | 173 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
174 | 174 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -184,22 +184,22 @@ discard block |
||
184 | 184 | $sub_menu_items = array(); |
185 | 185 | foreach ( (array)$connected_views as $view ) { |
186 | 186 | |
187 | - if( ! GVCommon::has_cap( 'edit_gravityview', $view->ID ) ) { |
|
187 | + if ( ! GVCommon::has_cap( 'edit_gravityview', $view->ID ) ) { |
|
188 | 188 | continue; |
189 | 189 | } |
190 | 190 | |
191 | - $label = empty( $view->post_title ) ? sprintf( __('No Title (View #%d)', 'gravityview' ), $view->ID ) : $view->post_title; |
|
191 | + $label = empty( $view->post_title ) ? sprintf( __( 'No Title (View #%d)', 'gravityview' ), $view->ID ) : $view->post_title; |
|
192 | 192 | |
193 | - $sub_menu_items[] = array( |
|
193 | + $sub_menu_items[ ] = array( |
|
194 | 194 | 'label' => esc_attr( $label ), |
195 | - 'url' => admin_url( 'post.php?action=edit&post='.$view->ID ), |
|
195 | + 'url' => admin_url( 'post.php?action=edit&post=' . $view->ID ), |
|
196 | 196 | ); |
197 | 197 | } |
198 | 198 | |
199 | 199 | // If there were no items added, then let's create the parent menu |
200 | - if( $sub_menu_items ) { |
|
200 | + if ( $sub_menu_items ) { |
|
201 | 201 | |
202 | - $sub_menu_items[] = array( |
|
202 | + $sub_menu_items[ ] = array( |
|
203 | 203 | 'label' => esc_attr__( 'Create a View', 'gravityview' ), |
204 | 204 | 'link_class' => 'gv-create-view', |
205 | 205 | 'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ), |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | ); |
209 | 209 | |
210 | 210 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
211 | - $sub_menu_items[] = array( |
|
211 | + $sub_menu_items[ ] = array( |
|
212 | 212 | 'url' => '#', |
213 | 213 | 'label' => '', |
214 | 214 | 'menu_class' => 'hidden', |
215 | 215 | 'capabilities' => '', |
216 | 216 | ); |
217 | 217 | |
218 | - $menu_items['gravityview'] = array( |
|
218 | + $menu_items[ 'gravityview' ] = array( |
|
219 | 219 | 'label' => __( 'Connected Views', 'gravityview' ), |
220 | 220 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
221 | 221 | 'title' => __( 'GravityView Views using this form as a data source', 'gravityview' ), |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | $add = array( 'captcha', 'page' ); |
245 | 245 | |
246 | 246 | // Don't allowing editing the following values: |
247 | - if( $context === 'edit' ) { |
|
248 | - $add[] = 'post_id'; |
|
247 | + if ( $context === 'edit' ) { |
|
248 | + $add[ ] = 'post_id'; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | $return = array_merge( $array, $add ); |
@@ -268,32 +268,32 @@ discard block |
||
268 | 268 | foreach ( $default_args as $key => $arg ) { |
269 | 269 | |
270 | 270 | // If an arg has `tooltip` defined, but it's false, don't display a tooltip |
271 | - if( isset( $arg['tooltip'] ) && empty( $arg['tooltip'] ) ) { continue; } |
|
271 | + if ( isset( $arg[ 'tooltip' ] ) && empty( $arg[ 'tooltip' ] ) ) { continue; } |
|
272 | 272 | |
273 | 273 | // By default, use `tooltip` if defined. |
274 | - $tooltip = empty( $arg['tooltip'] ) ? NULL : $arg['tooltip']; |
|
274 | + $tooltip = empty( $arg[ 'tooltip' ] ) ? NULL : $arg[ 'tooltip' ]; |
|
275 | 275 | |
276 | 276 | // Otherwise, use the description as a tooltip. |
277 | - if( empty( $tooltip ) && !empty( $arg['desc'] ) ) { |
|
278 | - $tooltip = $arg['desc']; |
|
277 | + if ( empty( $tooltip ) && ! empty( $arg[ 'desc' ] ) ) { |
|
278 | + $tooltip = $arg[ 'desc' ]; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | // If there's no tooltip set, continue |
282 | - if( empty( $tooltip ) ) { |
|
282 | + if ( empty( $tooltip ) ) { |
|
283 | 283 | continue; |
284 | 284 | } |
285 | 285 | |
286 | 286 | // Add the tooltip |
287 | - $gv_tooltips[ 'gv_'.$key ] = array( |
|
288 | - 'title' => $arg['label'], |
|
287 | + $gv_tooltips[ 'gv_' . $key ] = array( |
|
288 | + 'title' => $arg[ 'label' ], |
|
289 | 289 | 'value' => $tooltip, |
290 | 290 | ); |
291 | 291 | |
292 | 292 | } |
293 | 293 | |
294 | - $gv_tooltips['gv_css_merge_tags'] = array( |
|
295 | - 'title' => __('CSS Merge Tags', 'gravityview'), |
|
296 | - 'value' => sprintf( __( 'Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview'), '<code>', '</code>' ) |
|
294 | + $gv_tooltips[ 'gv_css_merge_tags' ] = array( |
|
295 | + 'title' => __( 'CSS Merge Tags', 'gravityview' ), |
|
296 | + 'value' => sprintf( __( 'Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview' ), '<code>', '</code>' ) |
|
297 | 297 | ); |
298 | 298 | |
299 | 299 | /** |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | |
312 | 312 | foreach ( $gv_tooltips as $key => $tooltip ) { |
313 | 313 | |
314 | - $title = empty( $tooltip['title'] ) ? '' : '<h6>'.esc_html( $tooltip['title'] ) .'</h6>'; |
|
314 | + $title = empty( $tooltip[ 'title' ] ) ? '' : '<h6>' . esc_html( $tooltip[ 'title' ] ) . '</h6>'; |
|
315 | 315 | |
316 | - $tooltips[ $key ] = $title . wpautop( esc_html( $tooltip['value'] ) ); |
|
316 | + $tooltips[ $key ] = $title . wpautop( esc_html( $tooltip[ 'value' ] ) ); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | return $tooltips; |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - public function add_custom_column_content( $column_name = NULL, $post_id ) { |
|
330 | + public function add_custom_column_content( $column_name = NULL, $post_id ) { |
|
331 | 331 | |
332 | 332 | $output = ''; |
333 | 333 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | // Generate backup if label doesn't exist: `example_name` => `Example Name` |
350 | 350 | $template_id_pretty = ucwords( implode( ' ', explode( '_', $template_id ) ) ); |
351 | 351 | |
352 | - $output = $template ? $template['label'] : $template_id_pretty; |
|
352 | + $output = $template ? $template[ 'label' ] : $template_id_pretty; |
|
353 | 353 | |
354 | 354 | break; |
355 | 355 | |
@@ -390,44 +390,44 @@ discard block |
||
390 | 390 | static public function get_connected_form_links( $form, $include_form_link = true ) { |
391 | 391 | |
392 | 392 | // Either the form is empty or the form ID is 0, not yet set. |
393 | - if( empty( $form ) ) { |
|
393 | + if ( empty( $form ) ) { |
|
394 | 394 | return ''; |
395 | 395 | } |
396 | 396 | |
397 | 397 | // The $form is passed as the form ID |
398 | - if( !is_array( $form ) ) { |
|
398 | + if ( ! is_array( $form ) ) { |
|
399 | 399 | $form = gravityview_get_form( $form ); |
400 | 400 | } |
401 | 401 | |
402 | - $form_id = $form['id']; |
|
402 | + $form_id = $form[ 'id' ]; |
|
403 | 403 | $links = array(); |
404 | 404 | |
405 | - if( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) { |
|
405 | + if ( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) { |
|
406 | 406 | $form_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&id=%d', $form_id ) ); |
407 | - $form_link = '<strong class="gv-form-title">'.gravityview_get_link( $form_url, $form['title'], 'class=row-title' ).'</strong>'; |
|
408 | - $links[] = '<span>'.gravityview_get_link( $form_url, __('Edit Form', 'gravityview') ).'</span>'; |
|
407 | + $form_link = '<strong class="gv-form-title">' . gravityview_get_link( $form_url, $form[ 'title' ], 'class=row-title' ) . '</strong>'; |
|
408 | + $links[ ] = '<span>' . gravityview_get_link( $form_url, __( 'Edit Form', 'gravityview' ) ) . '</span>'; |
|
409 | 409 | } else { |
410 | - $form_link = '<strong class="gv-form-title">'. esc_html( $form['title'] ). '</strong>'; |
|
410 | + $form_link = '<strong class="gv-form-title">' . esc_html( $form[ 'title' ] ) . '</strong>'; |
|
411 | 411 | } |
412 | 412 | |
413 | - if( GVCommon::has_cap( 'gravityforms_view_entries' ) ) { |
|
413 | + if ( GVCommon::has_cap( 'gravityforms_view_entries' ) ) { |
|
414 | 414 | $entries_url = admin_url( sprintf( 'admin.php?page=gf_entries&id=%d', $form_id ) ); |
415 | - $links[] = '<span>'.gravityview_get_link( $entries_url, __('Entries', 'gravityview') ).'</span>'; |
|
415 | + $links[ ] = '<span>' . gravityview_get_link( $entries_url, __( 'Entries', 'gravityview' ) ) . '</span>'; |
|
416 | 416 | } |
417 | 417 | |
418 | - if( GVCommon::has_cap( array( 'gravityforms_edit_settings', 'gravityview_view_settings' ) ) ) { |
|
418 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_settings', 'gravityview_view_settings' ) ) ) { |
|
419 | 419 | $settings_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&view=settings&id=%d', $form_id ) ); |
420 | - $links[] = '<span>'.gravityview_get_link( $settings_url, __('Settings', 'gravityview'), 'title='.__('Edit settings for this form', 'gravityview') ).'</span>'; |
|
420 | + $links[ ] = '<span>' . gravityview_get_link( $settings_url, __( 'Settings', 'gravityview' ), 'title=' . __( 'Edit settings for this form', 'gravityview' ) ) . '</span>'; |
|
421 | 421 | } |
422 | 422 | |
423 | - if( GVCommon::has_cap( array("gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms") ) ) { |
|
423 | + if ( GVCommon::has_cap( array( "gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms" ) ) ) { |
|
424 | 424 | $preview_url = site_url( sprintf( '?gf_page=preview&id=%d', $form_id ) ); |
425 | - $links[] = '<span>'.gravityview_get_link( $preview_url, __('Preview Form', 'gravityview'), 'title='.__('Preview this form', 'gravityview') ).'</span>'; |
|
425 | + $links[ ] = '<span>' . gravityview_get_link( $preview_url, __( 'Preview Form', 'gravityview' ), 'title=' . __( 'Preview this form', 'gravityview' ) ) . '</span>'; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | $output = ''; |
429 | 429 | |
430 | - if( !empty( $include_form_link ) ) { |
|
430 | + if ( ! empty( $include_form_link ) ) { |
|
431 | 431 | $output .= $form_link; |
432 | 432 | } |
433 | 433 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | */ |
440 | 440 | $links = apply_filters( 'gravityview_connected_form_links', $links, $form ); |
441 | 441 | |
442 | - $output .= '<div class="row-actions">'. implode( ' | ', $links ) .'</div>'; |
|
442 | + $output .= '<div class="row-actions">' . implode( ' | ', $links ) . '</div>'; |
|
443 | 443 | |
444 | 444 | return $output; |
445 | 445 | } |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | // Get the date column and save it for later to add back in. |
454 | 454 | // This adds it after the Data Source column. |
455 | 455 | // This way, we don't need to do array_slice, array_merge, etc. |
456 | - $date = $columns['date']; |
|
457 | - unset( $columns['date'] ); |
|
456 | + $date = $columns[ 'date' ]; |
|
457 | + unset( $columns[ 'date' ] ); |
|
458 | 458 | |
459 | 459 | $data_source_required_caps = array( |
460 | 460 | 'gravityforms_edit_forms', |
@@ -465,14 +465,14 @@ discard block |
||
465 | 465 | 'gravityforms_preview_forms', |
466 | 466 | ); |
467 | 467 | |
468 | - if( GVCommon::has_cap( $data_source_required_caps ) ) { |
|
469 | - $columns['gv_connected_form'] = __( 'Data Source', 'gravityview' ); |
|
468 | + if ( GVCommon::has_cap( $data_source_required_caps ) ) { |
|
469 | + $columns[ 'gv_connected_form' ] = __( 'Data Source', 'gravityview' ); |
|
470 | 470 | } |
471 | 471 | |
472 | - $columns['gv_template'] = _x( 'Template', 'Column title that shows what template is being used for Views', 'gravityview' ); |
|
472 | + $columns[ 'gv_template' ] = _x( 'Template', 'Column title that shows what template is being used for Views', 'gravityview' ); |
|
473 | 473 | |
474 | 474 | // Add the date back in. |
475 | - $columns['date'] = $date; |
|
475 | + $columns[ 'date' ] = $date; |
|
476 | 476 | |
477 | 477 | return $columns; |
478 | 478 | } |
@@ -486,12 +486,12 @@ discard block |
||
486 | 486 | */ |
487 | 487 | function save_postdata( $post_id ) { |
488 | 488 | |
489 | - if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){ |
|
489 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
490 | 490 | return; |
491 | 491 | } |
492 | 492 | |
493 | 493 | // validate post_type |
494 | - if ( ! isset( $_POST['post_type'] ) || 'gravityview' != $_POST['post_type'] ) { |
|
494 | + if ( ! isset( $_POST[ 'post_type' ] ) || 'gravityview' != $_POST[ 'post_type' ] ) { |
|
495 | 495 | return; |
496 | 496 | } |
497 | 497 | |
@@ -506,63 +506,63 @@ discard block |
||
506 | 506 | $statii = array(); |
507 | 507 | |
508 | 508 | // check if this is a start fresh View |
509 | - if ( isset( $_POST['gravityview_select_form_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_form_nonce'], 'gravityview_select_form' ) ) { |
|
509 | + if ( isset( $_POST[ 'gravityview_select_form_nonce' ] ) && wp_verify_nonce( $_POST[ 'gravityview_select_form_nonce' ], 'gravityview_select_form' ) ) { |
|
510 | 510 | |
511 | - $form_id = !empty( $_POST['gravityview_form_id'] ) ? $_POST['gravityview_form_id'] : ''; |
|
511 | + $form_id = ! empty( $_POST[ 'gravityview_form_id' ] ) ? $_POST[ 'gravityview_form_id' ] : ''; |
|
512 | 512 | // save form id |
513 | - $statii['form_id'] = update_post_meta( $post_id, '_gravityview_form_id', $form_id ); |
|
513 | + $statii[ 'form_id' ] = update_post_meta( $post_id, '_gravityview_form_id', $form_id ); |
|
514 | 514 | |
515 | 515 | } |
516 | 516 | |
517 | - if( false === GVCommon::has_cap( 'gravityforms_create_form' ) && empty( $statii['form_id'] ) ) { |
|
517 | + if ( false === GVCommon::has_cap( 'gravityforms_create_form' ) && empty( $statii[ 'form_id' ] ) ) { |
|
518 | 518 | gravityview()->log->error( 'Current user does not have the capability to create a new Form.', array( 'data' => wp_get_current_user() ) ); |
519 | 519 | return; |
520 | 520 | } |
521 | 521 | |
522 | 522 | // Was this a start fresh? |
523 | - if ( ! empty( $_POST['gravityview_form_id_start_fresh'] ) ) { |
|
524 | - $statii['start_fresh'] = add_post_meta( $post_id, '_gravityview_start_fresh', 1 ); |
|
523 | + if ( ! empty( $_POST[ 'gravityview_form_id_start_fresh' ] ) ) { |
|
524 | + $statii[ 'start_fresh' ] = add_post_meta( $post_id, '_gravityview_start_fresh', 1 ); |
|
525 | 525 | } else { |
526 | - $statii['start_fresh'] = delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
|
526 | + $statii[ 'start_fresh' ] = delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | // Check if we have a template id |
530 | - if ( isset( $_POST['gravityview_select_template_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_template_nonce'], 'gravityview_select_template' ) ) { |
|
530 | + if ( isset( $_POST[ 'gravityview_select_template_nonce' ] ) && wp_verify_nonce( $_POST[ 'gravityview_select_template_nonce' ], 'gravityview_select_template' ) ) { |
|
531 | 531 | |
532 | - $template_id = !empty( $_POST['gravityview_directory_template'] ) ? $_POST['gravityview_directory_template'] : ''; |
|
532 | + $template_id = ! empty( $_POST[ 'gravityview_directory_template' ] ) ? $_POST[ 'gravityview_directory_template' ] : ''; |
|
533 | 533 | |
534 | 534 | // now save template id |
535 | - $statii['directory_template'] = update_post_meta( $post_id, '_gravityview_directory_template', $template_id ); |
|
535 | + $statii[ 'directory_template' ] = update_post_meta( $post_id, '_gravityview_directory_template', $template_id ); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | |
539 | 539 | // save View Configuration metabox |
540 | - if ( isset( $_POST['gravityview_view_configuration_nonce'] ) && wp_verify_nonce( $_POST['gravityview_view_configuration_nonce'], 'gravityview_view_configuration' ) ) { |
|
540 | + if ( isset( $_POST[ 'gravityview_view_configuration_nonce' ] ) && wp_verify_nonce( $_POST[ 'gravityview_view_configuration_nonce' ], 'gravityview_view_configuration' ) ) { |
|
541 | 541 | |
542 | 542 | // template settings |
543 | - if( empty( $_POST['template_settings'] ) ) { |
|
544 | - $_POST['template_settings'] = array(); |
|
543 | + if ( empty( $_POST[ 'template_settings' ] ) ) { |
|
544 | + $_POST[ 'template_settings' ] = array(); |
|
545 | 545 | } |
546 | - $statii['template_settings'] = update_post_meta( $post_id, '_gravityview_template_settings', $_POST['template_settings'] ); |
|
546 | + $statii[ 'template_settings' ] = update_post_meta( $post_id, '_gravityview_template_settings', $_POST[ 'template_settings' ] ); |
|
547 | 547 | |
548 | 548 | $fields = array(); |
549 | 549 | |
550 | 550 | // Directory&single Visible Fields |
551 | - if( !empty( $preset_fields ) ) { |
|
551 | + if ( ! empty( $preset_fields ) ) { |
|
552 | 552 | |
553 | 553 | $fields = $preset_fields; |
554 | 554 | |
555 | - } elseif( !empty( $_POST['gv_fields'] ) ) { |
|
555 | + } elseif ( ! empty( $_POST[ 'gv_fields' ] ) ) { |
|
556 | 556 | $fields = _gravityview_process_posted_fields(); |
557 | 557 | } |
558 | 558 | |
559 | - $statii['directory_fields'] = update_post_meta( $post_id, '_gravityview_directory_fields', $fields ); |
|
559 | + $statii[ 'directory_fields' ] = update_post_meta( $post_id, '_gravityview_directory_fields', $fields ); |
|
560 | 560 | |
561 | 561 | // Directory Visible Widgets |
562 | - if( empty( $_POST['widgets'] ) ) { |
|
563 | - $_POST['widgets'] = array(); |
|
562 | + if ( empty( $_POST[ 'widgets' ] ) ) { |
|
563 | + $_POST[ 'widgets' ] = array(); |
|
564 | 564 | } |
565 | - $statii['directory_widgets'] = gravityview_set_directory_widgets( $post_id, $_POST['widgets'] ); |
|
565 | + $statii[ 'directory_widgets' ] = gravityview_set_directory_widgets( $post_id, $_POST[ 'widgets' ] ); |
|
566 | 566 | |
567 | 567 | } // end save view configuration |
568 | 568 | |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | * @param array $statii Array of statuses of the post meta saving processes. If saving worked, each key should be mapped to a value of the post ID (`directory_widgets` => `124`). If failed (or didn't change), the value will be false. |
573 | 573 | * @since 1.17.2 |
574 | 574 | */ |
575 | - do_action('gravityview_view_saved', $post_id, $statii ); |
|
575 | + do_action( 'gravityview_view_saved', $post_id, $statii ); |
|
576 | 576 | |
577 | 577 | gravityview()->log->debug( '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array( 'data' => array_map( 'intval', $statii ) ) ); |
578 | 578 | } |
@@ -616,20 +616,20 @@ discard block |
||
616 | 616 | |
617 | 617 | $output = ''; |
618 | 618 | |
619 | - if( !empty( $fields ) ) { |
|
619 | + if ( ! empty( $fields ) ) { |
|
620 | 620 | |
621 | - foreach( $fields as $id => $details ) { |
|
621 | + foreach ( $fields as $id => $details ) { |
|
622 | 622 | |
623 | - if( in_array( $details['type'], (array) $blacklist_field_types ) ) { |
|
623 | + if ( in_array( $details[ 'type' ], (array)$blacklist_field_types ) ) { |
|
624 | 624 | continue; |
625 | 625 | } |
626 | 626 | |
627 | 627 | // Edit mode only allows editing the parent fields, not single inputs. |
628 | - if( $context === 'edit' && !empty( $details['parent'] ) ) { |
|
628 | + if ( $context === 'edit' && ! empty( $details[ 'parent' ] ) ) { |
|
629 | 629 | continue; |
630 | 630 | } |
631 | 631 | |
632 | - $output .= new GravityView_Admin_View_Field( $details['label'], $id, $details, $settings = array(), $form ); |
|
632 | + $output .= new GravityView_Admin_View_Field( $details[ 'label' ], $id, $details, $settings = array(), $form ); |
|
633 | 633 | |
634 | 634 | } // End foreach |
635 | 635 | } |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | echo $output; |
638 | 638 | |
639 | 639 | // For the EDIT view we only want to allow the form fields. |
640 | - if( $context === 'edit' ) { |
|
640 | + if ( $context === 'edit' ) { |
|
641 | 641 | return; |
642 | 642 | } |
643 | 643 | |
@@ -661,16 +661,16 @@ discard block |
||
661 | 661 | $additional_fields = apply_filters( 'gravityview_additional_fields', array( |
662 | 662 | array( |
663 | 663 | 'label_text' => __( '+ Add All Fields', 'gravityview' ), |
664 | - 'desc' => __('Add all the available fields at once.', 'gravityview'), |
|
664 | + 'desc' => __( 'Add all the available fields at once.', 'gravityview' ), |
|
665 | 665 | 'field_id' => 'all-fields', |
666 | 666 | 'label_type' => 'field', |
667 | 667 | 'input_type' => NULL, |
668 | 668 | 'field_options' => NULL, |
669 | 669 | 'settings_html' => NULL, |
670 | 670 | ) |
671 | - )); |
|
671 | + ) ); |
|
672 | 672 | |
673 | - if( !empty( $additional_fields )) { |
|
673 | + if ( ! empty( $additional_fields ) ) { |
|
674 | 674 | foreach ( (array)$additional_fields as $item ) { |
675 | 675 | |
676 | 676 | // Prevent items from not having index set |
@@ -681,16 +681,16 @@ discard block |
||
681 | 681 | 'input_type' => NULL, |
682 | 682 | 'field_options' => NULL, |
683 | 683 | 'settings_html' => NULL, |
684 | - )); |
|
684 | + ) ); |
|
685 | 685 | |
686 | 686 | // Backward compat. |
687 | - if( !empty( $item['field_options'] ) ) { |
|
687 | + if ( ! empty( $item[ 'field_options' ] ) ) { |
|
688 | 688 | // Use settings_html from now on. |
689 | - $item['settings_html'] = $item['field_options']; |
|
689 | + $item[ 'settings_html' ] = $item[ 'field_options' ]; |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | // Render a label for each of them |
693 | - echo new GravityView_Admin_View_Field( $item['label_text'], $item['field_id'], $item, $settings = array(), $form ); |
|
693 | + echo new GravityView_Admin_View_Field( $item[ 'label_text' ], $item[ 'field_id' ], $item, $settings = array(), $form ); |
|
694 | 694 | |
695 | 695 | } |
696 | 696 | } |
@@ -703,54 +703,54 @@ discard block |
||
703 | 703 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
704 | 704 | * @return array |
705 | 705 | */ |
706 | - function get_entry_default_fields($form, $zone) { |
|
706 | + function get_entry_default_fields( $form, $zone ) { |
|
707 | 707 | |
708 | 708 | $entry_default_fields = array(); |
709 | 709 | |
710 | - if( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
710 | + if ( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
711 | 711 | |
712 | 712 | $entry_default_fields = array( |
713 | 713 | 'id' => array( |
714 | - 'label' => __('Entry ID', 'gravityview'), |
|
714 | + 'label' => __( 'Entry ID', 'gravityview' ), |
|
715 | 715 | 'type' => 'id', |
716 | - 'desc' => __('The unique ID of the entry.', 'gravityview'), |
|
716 | + 'desc' => __( 'The unique ID of the entry.', 'gravityview' ), |
|
717 | 717 | ), |
718 | 718 | 'date_created' => array( |
719 | - 'label' => __('Entry Date', 'gravityview'), |
|
720 | - 'desc' => __('The date the entry was created.', 'gravityview'), |
|
719 | + 'label' => __( 'Entry Date', 'gravityview' ), |
|
720 | + 'desc' => __( 'The date the entry was created.', 'gravityview' ), |
|
721 | 721 | 'type' => 'date_created', |
722 | 722 | ), |
723 | 723 | 'source_url' => array( |
724 | - 'label' => __('Source URL', 'gravityview'), |
|
724 | + 'label' => __( 'Source URL', 'gravityview' ), |
|
725 | 725 | 'type' => 'source_url', |
726 | - 'desc' => __('The URL of the page where the form was submitted.', 'gravityview'), |
|
726 | + 'desc' => __( 'The URL of the page where the form was submitted.', 'gravityview' ), |
|
727 | 727 | ), |
728 | 728 | 'ip' => array( |
729 | - 'label' => __('User IP', 'gravityview'), |
|
729 | + 'label' => __( 'User IP', 'gravityview' ), |
|
730 | 730 | 'type' => 'ip', |
731 | - 'desc' => __('The IP Address of the user who created the entry.', 'gravityview'), |
|
731 | + 'desc' => __( 'The IP Address of the user who created the entry.', 'gravityview' ), |
|
732 | 732 | ), |
733 | 733 | 'created_by' => array( |
734 | - 'label' => __('User', 'gravityview'), |
|
734 | + 'label' => __( 'User', 'gravityview' ), |
|
735 | 735 | 'type' => 'created_by', |
736 | - 'desc' => __('Details of the logged-in user who created the entry (if any).', 'gravityview'), |
|
736 | + 'desc' => __( 'Details of the logged-in user who created the entry (if any).', 'gravityview' ), |
|
737 | 737 | ), |
738 | 738 | |
739 | 739 | /** |
740 | 740 | * @since 1.7.2 |
741 | 741 | */ |
742 | 742 | 'other_entries' => array( |
743 | - 'label' => __('Other Entries', 'gravityview'), |
|
743 | + 'label' => __( 'Other Entries', 'gravityview' ), |
|
744 | 744 | 'type' => 'other_entries', |
745 | - 'desc' => __('Display other entries created by the entry creator.', 'gravityview'), |
|
745 | + 'desc' => __( 'Display other entries created by the entry creator.', 'gravityview' ), |
|
746 | 746 | ), |
747 | 747 | ); |
748 | 748 | |
749 | - if( 'single' !== $zone) { |
|
749 | + if ( 'single' !== $zone ) { |
|
750 | 750 | |
751 | - $entry_default_fields['entry_link'] = array( |
|
752 | - 'label' => __('Link to Entry', 'gravityview'), |
|
753 | - 'desc' => __('A dedicated link to the single entry with customizable text.', 'gravityview'), |
|
751 | + $entry_default_fields[ 'entry_link' ] = array( |
|
752 | + 'label' => __( 'Link to Entry', 'gravityview' ), |
|
753 | + 'desc' => __( 'A dedicated link to the single entry with customizable text.', 'gravityview' ), |
|
754 | 754 | 'type' => 'entry_link', |
755 | 755 | ); |
756 | 756 | } |
@@ -760,10 +760,10 @@ discard block |
||
760 | 760 | /** |
761 | 761 | * @since 1.2 |
762 | 762 | */ |
763 | - $entry_default_fields['custom'] = array( |
|
764 | - 'label' => __('Custom Content', 'gravityview'), |
|
763 | + $entry_default_fields[ 'custom' ] = array( |
|
764 | + 'label' => __( 'Custom Content', 'gravityview' ), |
|
765 | 765 | 'type' => 'custom', |
766 | - 'desc' => __('Insert custom text or HTML.', 'gravityview'), |
|
766 | + 'desc' => __( 'Insert custom text or HTML.', 'gravityview' ), |
|
767 | 767 | ); |
768 | 768 | |
769 | 769 | /** |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | * @param string|array $form form_ID or form object |
773 | 773 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
774 | 774 | */ |
775 | - return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone); |
|
775 | + return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone ); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | /** |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | */ |
784 | 784 | function get_available_fields( $form = '', $zone = NULL ) { |
785 | 785 | |
786 | - if( empty( $form ) ) { |
|
786 | + if ( empty( $form ) ) { |
|
787 | 787 | gravityview()->log->error( '$form is empty' ); |
788 | 788 | return array(); |
789 | 789 | } |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | $fields = gravityview_get_form_fields( $form, true ); |
793 | 793 | |
794 | 794 | // get meta fields ( only if form was already created ) |
795 | - if( !is_array( $form ) ) { |
|
795 | + if ( ! is_array( $form ) ) { |
|
796 | 796 | $meta_fields = gravityview_get_entry_meta( $form ); |
797 | 797 | } else { |
798 | 798 | $meta_fields = array(); |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | $fields = $fields + $meta_fields + $default_fields; |
806 | 806 | |
807 | 807 | // Move Custom Content to top |
808 | - $fields = array( 'custom' => $fields['custom'] ) + $fields; |
|
808 | + $fields = array( 'custom' => $fields[ 'custom' ] ) + $fields; |
|
809 | 809 | |
810 | 810 | return $fields; |
811 | 811 | } |
@@ -819,11 +819,11 @@ discard block |
||
819 | 819 | |
820 | 820 | $widgets = $this->get_registered_widgets(); |
821 | 821 | |
822 | - if( !empty( $widgets ) ) { |
|
822 | + if ( ! empty( $widgets ) ) { |
|
823 | 823 | |
824 | - foreach( $widgets as $id => $details ) { |
|
824 | + foreach ( $widgets as $id => $details ) { |
|
825 | 825 | |
826 | - echo new GravityView_Admin_View_Widget( $details['label'], $id, $details ); |
|
826 | + echo new GravityView_Admin_View_Widget( $details[ 'label' ], $id, $details ); |
|
827 | 827 | |
828 | 828 | } |
829 | 829 | } |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | function render_active_areas( $template_id, $type, $zone, $rows, $values ) { |
853 | 853 | global $post; |
854 | 854 | |
855 | - if( $type === 'widget' ) { |
|
855 | + if ( $type === 'widget' ) { |
|
856 | 856 | $button_label = __( 'Add Widget', 'gravityview' ); |
857 | 857 | } else { |
858 | 858 | $button_label = __( 'Add Field', 'gravityview' ); |
@@ -864,10 +864,10 @@ discard block |
||
864 | 864 | $form_id = null; |
865 | 865 | |
866 | 866 | // if saved values, get available fields to label everyone |
867 | - if( !empty( $values ) && ( !empty( $post->ID ) || !empty( $_POST['template_id'] ) ) ) { |
|
867 | + if ( ! empty( $values ) && ( ! empty( $post->ID ) || ! empty( $_POST[ 'template_id' ] ) ) ) { |
|
868 | 868 | |
869 | - if( !empty( $_POST['template_id'] ) ) { |
|
870 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
869 | + if ( ! empty( $_POST[ 'template_id' ] ) ) { |
|
870 | + $form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] ); |
|
871 | 871 | } else { |
872 | 872 | $form = gravityview_get_form_id( $post->ID ); |
873 | 873 | } |
@@ -886,44 +886,44 @@ discard block |
||
886 | 886 | } |
887 | 887 | } |
888 | 888 | |
889 | - foreach( $rows as $row ) : |
|
890 | - foreach( $row as $col => $areas ) : |
|
891 | - $column = ($col == '2-2') ? '1-2' : $col; ?> |
|
889 | + foreach ( $rows as $row ) : |
|
890 | + foreach ( $row as $col => $areas ) : |
|
891 | + $column = ( $col == '2-2' ) ? '1-2' : $col; ?> |
|
892 | 892 | |
893 | 893 | <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>"> |
894 | 894 | |
895 | - <?php foreach( $areas as $area ) : ?> |
|
895 | + <?php foreach ( $areas as $area ) : ?> |
|
896 | 896 | |
897 | - <div class="gv-droppable-area" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>"> |
|
898 | - <div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>"> |
|
897 | + <div class="gv-droppable-area" data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>"> |
|
898 | + <div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>"> |
|
899 | 899 | |
900 | 900 | <?php // render saved fields |
901 | 901 | |
902 | - if( ! empty( $values[ $zone .'_'. $area['areaid'] ] ) ) { |
|
902 | + if ( ! empty( $values[ $zone . '_' . $area[ 'areaid' ] ] ) ) { |
|
903 | 903 | |
904 | - foreach( $values[ $zone .'_'. $area['areaid'] ] as $uniqid => $field ) { |
|
904 | + foreach ( $values[ $zone . '_' . $area[ 'areaid' ] ] as $uniqid => $field ) { |
|
905 | 905 | |
906 | 906 | // Maybe has a form ID |
907 | - $form_id = empty( $field['form_id'] ) ? $form_id : $field['form_id']; |
|
907 | + $form_id = empty( $field[ 'form_id' ] ) ? $form_id : $field[ 'form_id' ]; |
|
908 | 908 | |
909 | 909 | $input_type = NULL; |
910 | 910 | |
911 | 911 | if ( $form_id ) { |
912 | - $original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ; |
|
912 | + $original_item = isset( $available_items[ $form_id ] [ $field[ 'id' ] ] ) ? $available_items[ $form_id ] [ $field[ 'id' ] ] : false; |
|
913 | 913 | } else { |
914 | - $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
|
914 | + $original_item = isset( $available_items[ $field[ 'id' ] ] ) ? $available_items[ $field[ 'id' ] ] : false; |
|
915 | 915 | } |
916 | 916 | |
917 | - if ( !$original_item ) { |
|
918 | - gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array(' data' => array('available_items' => $available_items, 'field' => $field ) ) ); |
|
917 | + if ( ! $original_item ) { |
|
918 | + gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array( ' data' => array( 'available_items' => $available_items, 'field' => $field ) ) ); |
|
919 | 919 | |
920 | 920 | $original_item = $field; |
921 | 921 | } else { |
922 | - $input_type = isset( $original_item['type'] ) ? $original_item['type'] : NULL; |
|
922 | + $input_type = isset( $original_item[ 'type' ] ) ? $original_item[ 'type' ] : NULL; |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | // Field options dialog box |
926 | - $field_options = GravityView_Render_Settings::render_field_options( $form_id, $type, $template_id, $field['id'], $original_item['label'], $zone .'_'. $area['areaid'], $input_type, $uniqid, $field, $zone, $original_item ); |
|
926 | + $field_options = GravityView_Render_Settings::render_field_options( $form_id, $type, $template_id, $field[ 'id' ], $original_item[ 'label' ], $zone . '_' . $area[ 'areaid' ], $input_type, $uniqid, $field, $zone, $original_item ); |
|
927 | 927 | |
928 | 928 | $item = array( |
929 | 929 | 'input_type' => $input_type, |
@@ -936,23 +936,23 @@ discard block |
||
936 | 936 | $item = wp_parse_args( $item, $original_item ); |
937 | 937 | } |
938 | 938 | |
939 | - switch( $type ) { |
|
939 | + switch ( $type ) { |
|
940 | 940 | case 'widget': |
941 | - echo new GravityView_Admin_View_Widget( $item['label'], $field['id'], $item, $field ); |
|
941 | + echo new GravityView_Admin_View_Widget( $item[ 'label' ], $field[ 'id' ], $item, $field ); |
|
942 | 942 | break; |
943 | 943 | default: |
944 | - echo new GravityView_Admin_View_Field( $field['label'], $field['id'], $item, $field, $form_id ); |
|
944 | + echo new GravityView_Admin_View_Field( $field[ 'label' ], $field[ 'id' ], $item, $field, $form_id ); |
|
945 | 945 | } |
946 | 946 | } |
947 | 947 | |
948 | 948 | } // End if zone is not empty ?> |
949 | 949 | |
950 | - <span class="drop-message"><?php echo sprintf(esc_attr__('"+ %s" or drag existing %ss here.', 'gravityview'), $button_label, $type ); ?></span> |
|
950 | + <span class="drop-message"><?php echo sprintf( esc_attr__( '"+ %s" or drag existing %ss here.', 'gravityview' ), $button_label, $type ); ?></span> |
|
951 | 951 | </div> |
952 | 952 | <div class="gv-droppable-area-action"> |
953 | - <a href="#" class="gv-add-field button-secondary" title="" data-objecttype="<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>" data-formid="<?php echo $view ? esc_attr( $view->form ? $view->form->ID : '' ) : ''; ?>"><?php echo '+ '.esc_html( $button_label ); ?></a> |
|
953 | + <a href="#" class="gv-add-field button-secondary" title="" data-objecttype="<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone . '_' . $area[ 'areaid' ] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>" data-formid="<?php echo $view ? esc_attr( $view->form ? $view->form->ID : '' ) : ''; ?>"><?php echo '+ ' . esc_html( $button_label ); ?></a> |
|
954 | 954 | |
955 | - <p class="gv-droppable-area-title"><strong><?php echo esc_html( $area['title'] ); ?></strong><?php if( !empty( $area['subtitle'] ) ) { ?><span class="gv-droppable-area-subtitle"> – <?php echo esc_html( $area['subtitle'] ); ?></span><?php } ?></p> |
|
955 | + <p class="gv-droppable-area-title"><strong><?php echo esc_html( $area[ 'title' ] ); ?></strong><?php if ( ! empty( $area[ 'subtitle' ] ) ) { ?><span class="gv-droppable-area-subtitle"> – <?php echo esc_html( $area[ 'subtitle' ] ); ?></span><?php } ?></p> |
|
956 | 956 | </div> |
957 | 957 | </div> |
958 | 958 | |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | $default_widget_areas = GravityView_Widget::get_default_widget_areas(); |
975 | 975 | |
976 | 976 | $widgets = array(); |
977 | - if( !empty( $post_id ) ) { |
|
977 | + if ( ! empty( $post_id ) ) { |
|
978 | 978 | $widgets = gravityview_get_directory_widgets( $post_id ); |
979 | 979 | } |
980 | 980 | |
@@ -1007,7 +1007,7 @@ discard block |
||
1007 | 1007 | // list of available fields to be shown in the popup |
1008 | 1008 | $forms = gravityview_get_forms( 'any' ); |
1009 | 1009 | |
1010 | - $form_ids = array_map( function ($form) { return $form['id']; }, $forms); |
|
1010 | + $form_ids = array_map( function( $form ) { return $form[ 'id' ]; }, $forms ); |
|
1011 | 1011 | |
1012 | 1012 | foreach ( $form_ids as $form_id ) { |
1013 | 1013 | $filter_field_id = sprintf( 'gv-field-filter-%s-%d', $context, $form_id ); |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | </div> |
1021 | 1021 | |
1022 | 1022 | <div id="available-fields-<?php echo $filter_field_id; ?>" aria-live="polite" role="listbox"> |
1023 | - <?php do_action('gravityview_render_available_fields', $form_id, $context ); ?> |
|
1023 | + <?php do_action( 'gravityview_render_available_fields', $form_id, $context ); ?> |
|
1024 | 1024 | </div> |
1025 | 1025 | |
1026 | 1026 | <div class="gv-no-results hidden description"><?php esc_html_e( 'No fields were found matching the search.', 'gravityview' ); ?></div> |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | * @return string HTML of the active areas |
1040 | 1040 | */ |
1041 | 1041 | function render_directory_active_areas( $template_id = '', $context = 'single', $post_id = '', $echo = false ) { |
1042 | - if( empty( $template_id ) ) { |
|
1042 | + if ( empty( $template_id ) ) { |
|
1043 | 1043 | gravityview()->log->debug( '[render_directory_active_areas] {template_id} is empty', array( 'template_id' => $template_id ) ); |
1044 | 1044 | return ''; |
1045 | 1045 | } |
@@ -1053,12 +1053,12 @@ discard block |
||
1053 | 1053 | */ |
1054 | 1054 | $template_areas = apply_filters( 'gravityview_template_active_areas', array(), $template_id, $context ); |
1055 | 1055 | |
1056 | - if( empty( $template_areas ) ) { |
|
1056 | + if ( empty( $template_areas ) ) { |
|
1057 | 1057 | |
1058 | 1058 | gravityview()->log->debug( '[render_directory_active_areas] No areas defined. Maybe template {template_id} is disabled.', array( 'data' => $template_id ) ); |
1059 | 1059 | $output = '<div>'; |
1060 | - $output .= '<h2 class="description" style="font-size: 16px; margin:0">'. sprintf( esc_html__( 'This View is configured using the %s View type, which is disabled.', 'gravityview' ), '<em>'.$template_id.'</em>' ) .'</h2>'; |
|
1061 | - $output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">'.esc_html__('The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview').'</p>'; |
|
1060 | + $output .= '<h2 class="description" style="font-size: 16px; margin:0">' . sprintf( esc_html__( 'This View is configured using the %s View type, which is disabled.', 'gravityview' ), '<em>' . $template_id . '</em>' ) . '</h2>'; |
|
1061 | + $output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">' . esc_html__( 'The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview' ) . '</p>'; |
|
1062 | 1062 | $output .= '</div>'; |
1063 | 1063 | } else { |
1064 | 1064 | |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | |
1074 | 1074 | } |
1075 | 1075 | |
1076 | - if( $echo ) { |
|
1076 | + if ( $echo ) { |
|
1077 | 1077 | echo $output; |
1078 | 1078 | } |
1079 | 1079 | |
@@ -1093,26 +1093,26 @@ discard block |
||
1093 | 1093 | $is_widgets_page = ( $pagenow === 'widgets.php' ); |
1094 | 1094 | |
1095 | 1095 | // Add the GV font (with the Astronaut) |
1096 | - wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
1096 | + wp_enqueue_style( 'gravityview_global', plugins_url( 'assets/css/admin-global.css', GRAVITYVIEW_FILE ), array(), GravityView_Plugin::version ); |
|
1097 | 1097 | |
1098 | - wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version, true ); |
|
1098 | + wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
|
1099 | 1099 | |
1100 | 1100 | // Don't process any scripts below here if it's not a GravityView page. |
1101 | - if( ! gravityview_is_admin_page( $hook, 'single' ) && ! $is_widgets_page ) { |
|
1101 | + if ( ! gravityview_is_admin_page( $hook, 'single' ) && ! $is_widgets_page ) { |
|
1102 | 1102 | return; |
1103 | 1103 | } |
1104 | 1104 | |
1105 | 1105 | wp_enqueue_script( 'jquery-ui-datepicker' ); |
1106 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version ); |
|
1106 | + wp_enqueue_style( 'gravityview_views_datepicker', plugins_url( 'assets/css/admin-datepicker.css', GRAVITYVIEW_FILE ), GravityView_Plugin::version ); |
|
1107 | 1107 | |
1108 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
1108 | + $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
1109 | 1109 | |
1110 | 1110 | //enqueue scripts |
1111 | 1111 | wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), GravityView_Plugin::version ); |
1112 | 1112 | |
1113 | - wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
|
1113 | + wp_localize_script( 'gravityview_views_scripts', 'gvGlobals', array( |
|
1114 | 1114 | 'cookiepath' => COOKIEPATH, |
1115 | - 'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ), |
|
1115 | + 'passed_form_id' => (bool)\GV\Utils::_GET( 'form_id' ), |
|
1116 | 1116 | 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
1117 | 1117 | 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
1118 | 1118 | 'label_close' => __( 'Close', 'gravityview' ), |
@@ -1124,9 +1124,9 @@ discard block |
||
1124 | 1124 | 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
1125 | 1125 | 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
1126 | 1126 | 'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ), |
1127 | - )); |
|
1127 | + ) ); |
|
1128 | 1128 | |
1129 | - wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array('dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version ); |
|
1129 | + wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version ); |
|
1130 | 1130 | |
1131 | 1131 | // Enqueue scripts needed for merge tags |
1132 | 1132 | self::enqueue_gravity_forms_scripts(); |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | ); |
1152 | 1152 | |
1153 | 1153 | if ( wp_is_mobile() ) { |
1154 | - $scripts[] = 'jquery-touch-punch'; |
|
1154 | + $scripts[ ] = 'jquery-touch-punch'; |
|
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | wp_enqueue_script( $scripts ); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | $disapproved_result = $wpdb->query( $wpdb->prepare( $sql, GravityView_Entry_Approval_Status::DISAPPROVED, '0' ) ); |
74 | 74 | |
75 | - if( false === $approved_result || false === $disapproved_result ) { |
|
75 | + if ( false === $approved_result || false === $disapproved_result ) { |
|
76 | 76 | gravityview()->log->error( 'There was an error processing the query. {error}', array( 'error' => $wpdb->last_error ) ); |
77 | 77 | } else { |
78 | 78 | // All done: Meta values are migrated |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | $redux_settings = $this->get_redux_settings(); |
106 | 106 | |
107 | 107 | // No need to process |
108 | - if( false === $redux_settings ) { |
|
108 | + if ( false === $redux_settings ) { |
|
109 | 109 | return; |
110 | 110 | } |
111 | 111 | |
112 | - if( empty( $redux_settings['license_key_status'] ) ) { |
|
112 | + if ( empty( $redux_settings[ 'license_key_status' ] ) ) { |
|
113 | 113 | $redux_settings = $this->get_redux_license_status( $redux_settings ); |
114 | 114 | } |
115 | 115 | |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | gravityview()->plugin->settings->update( $updated_settings ); |
124 | 124 | |
125 | 125 | // And now remove the previous option, so this is a one-time thing. |
126 | - delete_option('gravityview_settings'); |
|
127 | - delete_option('gravityview_settings-transients'); |
|
126 | + delete_option( 'gravityview_settings' ); |
|
127 | + delete_option( 'gravityview_settings-transients' ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | |
148 | 148 | $license_call = \GV\License_Handler::get()->license_call( $data ); |
149 | 149 | |
150 | - if( is_object( $license_call ) && isset( $license_call->license ) ) { |
|
151 | - $redux_settings['license_key_status'] = $license_call->license; |
|
152 | - $redux_settings['license_key_response'] = json_encode( $license_call ); |
|
150 | + if ( is_object( $license_call ) && isset( $license_call->license ) ) { |
|
151 | + $redux_settings[ 'license_key_status' ] = $license_call->license; |
|
152 | + $redux_settings[ 'license_key_response' ] = json_encode( $license_call ); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | return $redux_settings; |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | function get_redux_settings() { |
164 | 164 | |
165 | 165 | // Previous settings set by Redux |
166 | - $redux_option = get_option('gravityview_settings'); |
|
166 | + $redux_option = get_option( 'gravityview_settings' ); |
|
167 | 167 | |
168 | 168 | // No Redux settings? Don't proceed. |
169 | - if( false === $redux_option ) { |
|
169 | + if ( false === $redux_option ) { |
|
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | |
@@ -178,19 +178,19 @@ discard block |
||
178 | 178 | |
179 | 179 | if ( $license_array = \GV\Utils::get( $redux_option, 'license' ) ) { |
180 | 180 | |
181 | - $redux_settings['license_key'] = $license_key = \GV\Utils::get( $license_array, 'license' ); |
|
181 | + $redux_settings[ 'license_key' ] = $license_key = \GV\Utils::get( $license_array, 'license' ); |
|
182 | 182 | |
183 | - $redux_last_changed_values = get_option('gravityview_settings-transients'); |
|
183 | + $redux_last_changed_values = get_option( 'gravityview_settings-transients' ); |
|
184 | 184 | |
185 | 185 | // This contains the last response for license validation |
186 | - if( !empty( $redux_last_changed_values ) && $saved_values = \GV\Utils::get( $redux_last_changed_values, 'changed_values' ) ) { |
|
186 | + if ( ! empty( $redux_last_changed_values ) && $saved_values = \GV\Utils::get( $redux_last_changed_values, 'changed_values' ) ) { |
|
187 | 187 | |
188 | 188 | $saved_license = \GV\Utils::get( $saved_values, 'license' ); |
189 | 189 | |
190 | 190 | // Only use the last-saved values if they are for the same license |
191 | - if( $saved_license && \GV\Utils::get( $saved_license, 'license' ) === $license_key ) { |
|
192 | - $redux_settings['license_key_status'] = \GV\Utils::get( $saved_license, 'status' ); |
|
193 | - $redux_settings['license_key_response'] = \GV\Utils::get( $saved_license, 'response' ); |
|
191 | + if ( $saved_license && \GV\Utils::get( $saved_license, 'license' ) === $license_key ) { |
|
192 | + $redux_settings[ 'license_key_status' ] = \GV\Utils::get( $saved_license, 'status' ); |
|
193 | + $redux_settings[ 'license_key_response' ] = \GV\Utils::get( $saved_license, 'response' ); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | } |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | /** ---- Migrate from old search widget to new search widget ---- */ |
203 | 203 | function update_search_on_views() { |
204 | 204 | |
205 | - if( !class_exists('GravityView_Widget_Search') ) { |
|
206 | - include_once( GRAVITYVIEW_DIR .'includes/extensions/search-widget/class-search-widget.php' ); |
|
205 | + if ( ! class_exists( 'GravityView_Widget_Search' ) ) { |
|
206 | + include_once( GRAVITYVIEW_DIR . 'includes/extensions/search-widget/class-search-widget.php' ); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | // Loop through all the views |
@@ -215,20 +215,20 @@ discard block |
||
215 | 215 | |
216 | 216 | $views = get_posts( $query_args ); |
217 | 217 | |
218 | - foreach( $views as $view ) { |
|
218 | + foreach ( $views as $view ) { |
|
219 | 219 | |
220 | 220 | $widgets = gravityview_get_directory_widgets( $view->ID ); |
221 | 221 | $search_fields = null; |
222 | 222 | |
223 | - if( empty( $widgets ) || !is_array( $widgets ) ) { continue; } |
|
223 | + if ( empty( $widgets ) || ! is_array( $widgets ) ) { continue; } |
|
224 | 224 | |
225 | 225 | gravityview()->log->debug( '[GravityView_Migrate/update_search_on_views] Loading View ID: {view_id}', array( 'view_id' => $view->ID ) ); |
226 | 226 | |
227 | - foreach( $widgets as $area => $ws ) { |
|
228 | - foreach( $ws as $k => $widget ) { |
|
229 | - if( $widget['id'] !== 'search_bar' ) { continue; } |
|
227 | + foreach ( $widgets as $area => $ws ) { |
|
228 | + foreach ( $ws as $k => $widget ) { |
|
229 | + if ( $widget[ 'id' ] !== 'search_bar' ) { continue; } |
|
230 | 230 | |
231 | - if( is_null( $search_fields ) ) { |
|
231 | + if ( is_null( $search_fields ) ) { |
|
232 | 232 | $search_fields = $this->get_search_fields( $view->ID ); |
233 | 233 | } |
234 | 234 | |
@@ -236,24 +236,24 @@ discard block |
||
236 | 236 | // [search_free] => 1 |
237 | 237 | // [search_date] => 1 |
238 | 238 | $search_generic = array(); |
239 | - if( !empty( $widget['search_free'] ) ) { |
|
240 | - $search_generic[] = array( 'field' => 'search_all', 'input' => 'input_text' ); |
|
239 | + if ( ! empty( $widget[ 'search_free' ] ) ) { |
|
240 | + $search_generic[ ] = array( 'field' => 'search_all', 'input' => 'input_text' ); |
|
241 | 241 | } |
242 | - if( !empty( $widget['search_date'] ) ) { |
|
243 | - $search_generic[] = array( 'field' => 'entry_date', 'input' => 'date' ); |
|
242 | + if ( ! empty( $widget[ 'search_date' ] ) ) { |
|
243 | + $search_generic[ ] = array( 'field' => 'entry_date', 'input' => 'date' ); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | $search_config = array_merge( $search_generic, $search_fields ); |
247 | 247 | |
248 | 248 | // don't throw '[]' when json_encode an empty array |
249 | - if( empty( $search_config ) ) { |
|
249 | + if ( empty( $search_config ) ) { |
|
250 | 250 | $search_config = ''; |
251 | 251 | } else { |
252 | 252 | $search_config = json_encode( $search_config ); |
253 | 253 | } |
254 | 254 | |
255 | - $widgets[ $area ][ $k ]['search_fields'] = $search_config; |
|
256 | - $widgets[ $area ][ $k ]['search_layout'] = 'horizontal'; |
|
255 | + $widgets[ $area ][ $k ][ 'search_fields' ] = $search_config; |
|
256 | + $widgets[ $area ][ $k ][ 'search_layout' ] = 'horizontal'; |
|
257 | 257 | |
258 | 258 | gravityview()->log->debug( '[GravityView_Migrate/update_search_on_views] Updated Widget: ', array( 'data' => $widgets[ $area ][ $k ] ) ); |
259 | 259 | } |
@@ -281,26 +281,26 @@ discard block |
||
281 | 281 | // check view fields' settings |
282 | 282 | $fields = gravityview_get_directory_fields( $view_id, false ); |
283 | 283 | |
284 | - if( !empty( $fields ) && is_array( $fields ) ) { |
|
284 | + if ( ! empty( $fields ) && is_array( $fields ) ) { |
|
285 | 285 | |
286 | - foreach( $fields as $t => $fs ) { |
|
286 | + foreach ( $fields as $t => $fs ) { |
|
287 | 287 | |
288 | - foreach( $fs as $k => $field ) { |
|
288 | + foreach ( $fs as $k => $field ) { |
|
289 | 289 | // is field a search_filter ? |
290 | - if( empty( $field['search_filter'] ) ) { continue; } |
|
290 | + if ( empty( $field[ 'search_filter' ] ) ) { continue; } |
|
291 | 291 | |
292 | 292 | // get field type & calculate the input type (by default) |
293 | - $form_field = gravityview_get_field( $form, $field['id'] ); |
|
293 | + $form_field = gravityview_get_field( $form, $field[ 'id' ] ); |
|
294 | 294 | |
295 | - if( empty( $form_field['type'] ) ) { |
|
295 | + if ( empty( $form_field[ 'type' ] ) ) { |
|
296 | 296 | continue; |
297 | 297 | } |
298 | 298 | |
299 | 299 | // depending on the field type assign a group of possible search field types |
300 | - $type = GravityView_Widget_Search::get_search_input_types( $field['id'], $form_field['type'] ); |
|
300 | + $type = GravityView_Widget_Search::get_search_input_types( $field[ 'id' ], $form_field[ 'type' ] ); |
|
301 | 301 | |
302 | 302 | // add field to config |
303 | - $search_fields[] = array( 'field' => $field['id'], 'input' => $type ); |
|
303 | + $search_fields[ ] = array( 'field' => $field[ 'id' ], 'input' => $type ); |
|
304 | 304 | |
305 | 305 | } |
306 | 306 | } |